@mlightcad/cad-simple-viewer-cli 1.7.8-preview.6 → 1.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +163 -163
- package/dist-runner/assets/{cad-html-plugin-BX7V6aIa.js → cad-html-plugin-Dt0Deu5V.js} +17 -17
- package/dist-runner/assets/{cad-pdf-plugin-D2a22XTJ.js → cad-pdf-plugin-B1YVvog9.js} +2 -2
- package/dist-runner/assets/{cad-svg-plugin-BCNrpc7g.js → cad-svg-plugin-Cemy-AI-.js} +2 -2
- package/dist-runner/assets/{index-BCz7pt73.js → index-BXbm-bLy.js} +137 -137
- package/dist-runner/index.html +12 -12
- package/dist-runner/viewer-runtime.iife.js +2 -2
- package/dist-runner/workers/mtext-renderer-worker.js +1208 -1178
- package/examples/batch-export-html-multi-preview.mjs +306 -306
- package/examples/batch-export-html.mjs +105 -105
- package/examples/batch-export-png.mjs +103 -103
- package/examples/create-drawing-dxf.scr +15 -15
- package/examples/create-drawing-png.scr +19 -19
- package/examples/create-shapes-dxf.scr +17 -17
- package/examples/export-dxf.scr +5 -5
- package/examples/export-html-multi-preview.scr +21 -21
- package/examples/export-html-multi.scr +16 -16
- package/examples/export-html.scr +13 -13
- package/examples/export-pdf.scr +9 -9
- package/examples/export-png.scr +9 -9
- package/examples/freeze-layer-png.scr +15 -15
- package/examples/index.json +114 -114
- package/examples/open-quit.scr +2 -2
- package/package.json +10 -10
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(){"use strict";var li=Uint8Array,ho=Uint16Array,vM=Int32Array,Ay=new li([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Cy=new li([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),_M=new li([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ty=function(n,t){for(var e=new ho(31),i=0;i<31;++i)e[i]=t+=1<<n[i-1];for(var r=new vM(e[30]),i=1;i<30;++i)for(var s=e[i];s<e[i+1];++s)r[s]=s-e[i]<<5|i;return{b:e,r}},Ly=Ty(Ay,2),Iy=Ly.b,xM=Ly.r;Iy[28]=258,xM[258]=28;for(var bM=Ty(Cy,0),SM=bM.b,_d=new ho(32768),tn=0;tn<32768;++tn){var is=(tn&43690)>>1|(tn&21845)<<1;is=(is&52428)>>2|(is&13107)<<2,is=(is&61680)>>4|(is&3855)<<4,_d[tn]=((is&65280)>>8|(is&255)<<8)>>1}for(var Ha=(function(n,t,e){for(var i=n.length,r=0,s=new ho(t);r<i;++r)n[r]&&++s[n[r]-1];var o=new ho(t);for(r=1;r<t;++r)o[r]=o[r-1]+s[r-1]<<1;var a;if(e){a=new ho(1<<t);var l=15-t;for(r=0;r<i;++r)if(n[r])for(var c=r<<4|n[r],u=t-n[r],h=o[n[r]-1]++<<u,d=h|(1<<u)-1;h<=d;++h)a[_d[h]>>l]=c}else for(a=new ho(i),r=0;r<i;++r)n[r]&&(a[r]=_d[o[n[r]-1]++]>>15-n[r]);return a}),Ga=new li(288),tn=0;tn<144;++tn)Ga[tn]=8;for(var tn=144;tn<256;++tn)Ga[tn]=9;for(var tn=256;tn<280;++tn)Ga[tn]=7;for(var tn=280;tn<288;++tn)Ga[tn]=8;for(var Py=new li(32),tn=0;tn<32;++tn)Py[tn]=5;var wM=Ha(Ga,9,1),MM=Ha(Py,5,1),xd=function(n){for(var t=n[0],e=1;e<n.length;++e)n[e]>t&&(t=n[e]);return t},Fi=function(n,t,e){var i=t/8|0;return(n[i]|n[i+1]<<8)>>(t&7)&e},bd=function(n,t){var e=t/8|0;return(n[e]|n[e+1]<<8|n[e+2]<<16)>>(t&7)},EM=function(n){return(n+7)/8|0},Ry=function(n,t,e){return(t==null||t<0)&&(t=0),(e==null||e>n.length)&&(e=n.length),new li(n.subarray(t,e))},AM=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],wi=function(n,t,e){var i=new Error(t||AM[n]);if(i.code=n,Error.captureStackTrace&&Error.captureStackTrace(i,wi),!e)throw i;return i},CM=function(n,t,e,i){var r=n.length,s=0;if(!r||t.f&&!t.l)return e||new li(0);var o=!e,a=o||t.i!=2,l=t.i;o&&(e=new li(r*3));var c=function(Lt){var oe=e.length;if(Lt>oe){var Me=new li(Math.max(oe*2,Lt));Me.set(e),e=Me}},u=t.f||0,h=t.p||0,d=t.b||0,f=t.l,p=t.d,g=t.m,y=t.n,m=r*8;do{if(!f){u=Fi(n,h,1);var v=Fi(n,h+1,3);if(h+=3,v)if(v==1)f=wM,p=MM,g=9,y=5;else if(v==2){var w=Fi(n,h,31)+257,C=Fi(n,h+10,15)+4,E=w+Fi(n,h+5,31)+1;h+=14;for(var T=new li(E),k=new li(19),O=0;O<C;++O)k[_M[O]]=Fi(n,h+O*3,7);h+=C*3;for(var U=xd(k),z=(1<<U)-1,L=Ha(k,U,1),O=0;O<E;){var N=L[Fi(n,h,z)];h+=N&15;var x=N>>4;if(x<16)T[O++]=x;else{var F=0,G=0;for(x==16?(G=3+Fi(n,h,3),h+=2,F=T[O-1]):x==17?(G=3+Fi(n,h,7),h+=3):x==18&&(G=11+Fi(n,h,127),h+=7);G--;)T[O++]=F}}var V=T.subarray(0,w),D=T.subarray(w);g=xd(V),y=xd(D),f=Ha(V,g,1),p=Ha(D,y,1)}else wi(1);else{var x=EM(h)+4,_=n[x-4]|n[x-3]<<8,b=x+_;if(b>r){l&&wi(0);break}a&&c(d+_),e.set(n.subarray(x,b),d),t.b=d+=_,t.p=h=b*8,t.f=u;continue}if(h>m){l&&wi(0);break}}a&&c(d+131072);for(var Y=(1<<g)-1,Z=(1<<y)-1,ft=h;;ft=h){var F=f[bd(n,h)&Y],gt=F>>4;if(h+=F&15,h>m){l&&wi(0);break}if(F||wi(2),gt<256)e[d++]=gt;else if(gt==256){ft=h,f=null;break}else{var qt=gt-254;if(gt>264){var O=gt-257,Vt=Ay[O];qt=Fi(n,h,(1<<Vt)-1)+Iy[O],h+=Vt}var Xt=p[bd(n,h)&Z],it=Xt>>4;Xt||wi(3),h+=Xt&15;var D=SM[it];if(it>3){var Vt=Cy[it];D+=bd(n,h)&(1<<Vt)-1,h+=Vt}if(h>m){l&&wi(0);break}a&&c(d+131072);var ct=d+qt;if(d<D){var kt=s-D,ce=Math.min(D,ct);for(kt+d<0&&wi(3);d<ce;++d)e[d]=i[kt+d]}for(;d<ct;++d)e[d]=e[d-D]}}t.l=f,t.p=ft,t.b=d,t.f=u,f&&(u=1,t.m=g,t.d=p,t.n=y)}while(!u);return d!=e.length&&o?Ry(e,0,d):e.subarray(0,d)},TM=new li(0),LM=function(n){(n[0]!=31||n[1]!=139||n[2]!=8)&&wi(6,"invalid gzip data");var t=n[3],e=10;t&4&&(e+=(n[10]|n[11]<<8)+2);for(var i=(t>>3&1)+(t>>4&1);i>0;i-=!n[e++]);return e+(t&2)},IM=function(n){var t=n.length;return(n[t-4]|n[t-3]<<8|n[t-2]<<16|n[t-1]<<24)>>>0};function PM(n,t){var e=LM(n);return e+8>n.length&&wi(6,"invalid gzip data"),CM(n.subarray(e,-8),{i:2},new li(IM(n)),t)}var Sd=typeof TextDecoder<"u"&&new TextDecoder,RM=0;try{Sd.decode(TM,{stream:!0}),RM=1}catch{}var kM=function(n){for(var t="",e=0;;){var i=n[e++],r=(i>127)+(i>223)+(i>239);if(e+r>n.length)return{s:t,r:Ry(n,e-1)};r?r==3?(i=((i&15)<<18|(n[e++]&63)<<12|(n[e++]&63)<<6|n[e++]&63)-65536,t+=String.fromCharCode(55296|i>>10,56320|i&1023)):r&1?t+=String.fromCharCode((i&31)<<6|n[e++]&63):t+=String.fromCharCode((i&15)<<12|(n[e++]&63)<<6|n[e++]&63):t+=String.fromCharCode(i)}};function ky(n,t){var e;if(Sd)return Sd.decode(n);var i=kM(n),r=i.s,e=i.r;return e.length&&wi(8),r}const OM=512*1024*1024,Oy=512*1024*1024;class wd{constructor(t){this.bytes=t,this.offset=0}ensureAvailable(t){if(t<0||!Number.isFinite(t))throw new Error("Invalid binary length");if(this.offset+t>this.bytes.length)throw new Error("Unexpected end of binary buffer")}readU8(){return this.ensureAvailable(1),this.bytes[this.offset++]}readU32(){this.ensureAvailable(4);const e=new DataView(this.bytes.buffer,this.bytes.byteOffset+this.offset,4).getUint32(0,!0);return this.offset+=4,e}readI32(){this.ensureAvailable(4);const e=new DataView(this.bytes.buffer,this.bytes.byteOffset+this.offset,4).getInt32(0,!0);return this.offset+=4,e}readF32(){this.ensureAvailable(4);const e=new DataView(this.bytes.buffer,this.bytes.byteOffset+this.offset,4).getFloat32(0,!0);return this.offset+=4,e}readF64(){this.ensureAvailable(8);const e=new DataView(this.bytes.buffer,this.bytes.byteOffset+this.offset,8).getFloat64(0,!0);return this.offset+=8,e}readBytes(t){this.ensureAvailable(t);const e=this.bytes.subarray(this.offset,this.offset+t);return this.offset+=t,e}readString(){const t=this.readU32();if(t===0)return"";if(t>OM)throw new Error("Binary string exceeds size limit");return ky(this.readBytes(t))}readJson(){const t=this.readString();if(t.length===0)throw new Error("Expected JSON payload");return JSON.parse(t)}alignTo(t){const e=this.offset%t;if(e===0)return;const i=t-e;this.ensureAvailable(i),this.offset+=i}readFloat32Array(){this.alignTo(4);const t=this.readU32();if(t===0)return new Float32Array(0);if(t%4!==0)throw new Error("Invalid float32 buffer length");if(t>Oy)throw new Error("Float32 buffer exceeds size limit");const e=this.readBytes(t);if(e.byteOffset%4===0)return new Float32Array(e.buffer,e.byteOffset,t/4);const i=new ArrayBuffer(t);return new Uint8Array(i).set(e),new Float32Array(i)}readUint32Array(){this.alignTo(4);const t=this.readU32();if(t===0)return new Uint32Array(0);if(t%4!==0)throw new Error("Invalid uint32 buffer length");if(t>Oy)throw new Error("Uint32 buffer exceeds size limit");const e=this.readBytes(t);if(e.byteOffset%4===0)return new Uint32Array(e.buffer,e.byteOffset,t/4);const i=new ArrayBuffer(t);return new Uint8Array(i).set(e),new Uint32Array(i)}}const fo=4,BM=512*1024*1024,Va=256*1024*1024;function By(n){return n.byteLength>=2&&n[0]===31&&n[1]===139}function Md(n){if(n.byteLength>Va)throw new Error("Compressed payload exceeds size limit");const t=PM(n);if(t.byteLength>BM)throw new Error("Decompressed payload exceeds size limit");return t}const yc="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%()*+,-.;=?@[]^_{|}~",Ed=new Int16Array(128).fill(-1);for(let n=0;n<yc.length;n++)Ed[yc.charCodeAt(n)]=n;function Ad(n){const t=(n==null?void 0:n.toLowerCase())??"";return t.includes(";base85")||t.endsWith("base85")?"base85":"base64"}function NM(n,t){return t==="base85"?DM(n):FM(n)}function Cd(n,t){const e=n.length>0&&(n.charCodeAt(0)<=32||n.charCodeAt(n.length-1)<=32)?n.trim():n;return t==="base85"?UM(e):HM(e)}function DM(n){const t=n.length;if(t===0)return"";const e=(4-t%4)%4,i=t+e,r=[];for(let o=0;o<i;o+=4){const a=n[o]??0,l=o+1<t?n[o+1]:0,c=o+2<t?n[o+2]:0,u=o+3<t?n[o+3]:0;let h=(a<<24>>>0)+(l<<16)+(c<<8)+u;const d=new Array(5);for(let f=4;f>=0;f--)d[f]=h%85,h=h/85|0;for(let f=0;f<5;f++)r.push(yc[d[f]])}const s=Math.ceil(t*5/4);return r.slice(0,s).join("")}function UM(n){const t=n.replace(/\s+/g,""),e=t.length;if(e===0)return new Uint8Array(0);const i=Math.floor(e*4/5),r=(5-e%5)%5,s=e+r,o=new Uint8Array(s/5*4),a=yc.length-1;let l=0;for(let c=0;c<s;c+=5){let u=0;for(let h=0;h<5;h++){const d=c+h<e?zM(t.charCodeAt(c+h)):a;u=u*85+d}o[l++]=u>>>24&255,o[l++]=u>>>16&255,o[l++]=u>>>8&255,o[l++]=u&255}return o.subarray(0,i)}function zM(n){if(n<0||n>=Ed.length)throw new Error("Invalid base85 character");const t=Ed[n];if(t<0)throw new Error("Invalid base85 character");return t}function FM(n){let t="";for(let e=0;e<n.length;e++)t+=String.fromCharCode(n[e]);return btoa(t)}function HM(n){const t=atob(n),e=new Uint8Array(t.length);for(let i=0;i<t.length;i++)e[i]=t.charCodeAt(i);return e}const GM=1,VM=2,WM=4,XM=8,jM=16,$M=32,YM=1,qM=2,KM=4,ZM=8,JM=16,QM=32,t2=64,e2=128;function Ny(n){const t=n.readString(),e=n.readU32(),i=[n.readF64(),n.readF64(),n.readF64()],r=n.readFloat32Array(),s=n.readU8(),o={layer:t,color:e,offset:i,positions:r};return s&GM&&(o.indices=n.readUint32Array()),s&VM&&(o.linePattern=n.readJson()),s&WM&&(o.lineDistances=n.readFloat32Array()),s&XM&&(o.lineWidth=n.readF32()),s&jM&&(o.renderOrder=n.readI32()),s&$M&&(o.excludeFromOsnap=!0),o}function Dy(n){const t=n.readString(),e=n.readU32(),i=[n.readF64(),n.readF64(),n.readF64()],r=n.readFloat32Array(),s=n.readU8(),o={layer:t,color:e,offset:i,positions:r};if(s&YM&&(o.indices=n.readUint32Array()),s&qM&&(o.hatchPattern=n.readJson()),s&KM&&(o.gradientFill=n.readJson()),s&ZM&&(o.gradientPositions=n.readFloat32Array()),s&JM&&(o.side=n.readU8()),s&QM&&(o.points=!0),s&t2&&(o.renderOrder=n.readI32()),s&e2){o.uvs=n.readFloat32Array();const a=n.readString()||"image/png",l=n.readU32();o.texture={mimeType:a,bytes:n.readBytes(l)}}return o}const Uy=1329939265,n2=1,zy=5e5,i2=1e5,r2=1,s2=2,o2=3,a2=4,l2=5,c2=6,u2=7;function Td(n){const t=new wd(n);if(t.readU32()!==Uy)throw new Error("Invalid osnap catalog magic");const i=t.readU8();if(t.readU8(),t.readU8(),t.readU8(),i!==n2)throw new Error(`Unsupported osnap catalog version: ${i}`);const r=t.readU32();if(r>i2)throw new Error("Osnap layer count exceeds limit");const s=[];for(let l=0;l<r;l++)s.push(t.readString());const o=t.readU32();if(o>zy)throw new Error("Osnap primitive count exceeds limit");const a=[];for(let l=0;l<o;l++)a.push(f2(t,s));return{primitives:a}}function h2(n){return Td(Md(n))}function d2(n){return By(n)?h2(n):Td(n)}function Ld(n){return n.readU8()===0?-1:1}function Wa(n){const t=n.readU32();if(t>zy)throw new Error("Float64 array count exceeds limit");const e=[];for(let i=0;i<t;i++)e.push(n.readF64());return e}function f2(n,t){const e=n.readU8(),i=n.readU32(),r=t[i];if(r==null)throw new Error(`Invalid osnap layer index: ${i}`);switch(e){case r2:return{kind:"line",layer:r,x0:n.readF64(),y0:n.readF64(),x1:n.readF64(),y1:n.readF64()};case s2:return{kind:"circle",layer:r,cx:n.readF64(),cy:n.readF64(),r:n.readF64(),normalSign:Ld(n)};case o2:return{kind:"arc",layer:r,cx:n.readF64(),cy:n.readF64(),r:n.readF64(),startAngle:n.readF64(),endAngle:n.readF64(),normalSign:Ld(n)};case a2:return{kind:"ellipse",layer:r,cx:n.readF64(),cy:n.readF64(),majorX:n.readF64(),majorY:n.readF64(),majorR:n.readF64(),minorR:n.readF64(),startAngle:n.readF64(),endAngle:n.readF64(),closed:n.readU8()!==0,normalSign:Ld(n)};case l2:{const s=Wa(n),o=n.readU32(),a=Wa(n),l=Wa(n),c=n.readU8()!==0,u=Wa(n);return{kind:"spline",layer:r,controlPoints:s,degree:o,knots:a,weights:l,closed:c,...u.length>0?{fitPoints:u}:{}}}case c2:return{kind:"point",layer:r,x:n.readF64(),y:n.readF64()};case u2:{const s=n.readU8()!==0,o=Wa(n);return{kind:"path",layer:r,closed:s,vertices:o}}default:throw new Error(`Unsupported osnap primitive kind: ${e}`)}}const p2=1480934209;function m2(n){const t=new wd(n);if(t.readU32()!==p2)throw new Error("Invalid snapshot magic");const i=t.readU8();if(t.readU8(),t.readU8(),t.readU8(),i!==fo)throw new Error(`Unsupported snapshot version: ${i}`);const r=t.readJson(),s=t.readJson(),o=t.readString(),a=t.readU32(),l=[];for(let c=0;c<a;c++)l.push(y2(t));return g2(l,r.savedViews,r.fitExtents),{version:fo,meta:r,layers:s,layouts:l,activeLayoutBtrId:o}}function g2(n,t,e){if(!(!t&&!e))for(const i of n){if(!i.savedView){const r=t==null?void 0:t[i.btrId];r&&(i.savedView=r)}if(!i.fitExtents){const r=e==null?void 0:e[i.btrId];r&&(i.fitExtents=r)}}}function y2(n){const t=n.readString(),e=n.readString(),i=n.readU8()!==0,r=_2(n),s=v2(n.readJson()),o=n.readU32(),a=[];for(let u=0;u<o;u++)a.push(Ny(n));const l=n.readU32(),c=[];for(let u=0;u<l;u++)c.push(Dy(n));return{btrId:t,name:e,isModelSpace:i,lineBatches:a,meshBatches:c,osnap:r,viewports:s}}function v2(n){if(n!=null){if(Array.isArray(n))return n;if(typeof n=="object")return n.viewports??void 0}}function _2(n){const t=n.readU32();if(t===0)return;const e=n.readBytes(t);if(x2(e))return Td(e);const i=ky(e);if(!(i.length===0||i==="null"))return JSON.parse(i)}function x2(n){return n.length<4?!1:(n[0]|n[1]<<8|n[2]<<16|n[3]<<24)>>>0===Uy}function Fy(n){const t=Md(n);return m2(t)}function b2(n,t="base85"){const e=t==="base64"||t==="base85"?t:Ad(t);return Cd(n,e)}var ci;(function(n){n[n.Invalid=-9999]="Invalid",n[n.Start=0]="Start",n[n.Text=1]="Text",n[n.AttributeTag=2]="AttributeTag",n[n.BlockName=2]="BlockName",n[n.ShapeName=2]="ShapeName",n[n.SymbolTableName=2]="SymbolTableName",n[n.SymbolTableRecordName=2]="SymbolTableRecordName",n[n.MlineStyleName=2]="MlineStyleName",n[n.AttributePrompt=3]="AttributePrompt",n[n.Description=3]="Description",n[n.DimPostString=3]="DimPostString",n[n.DimStyleName=3]="DimStyleName",n[n.LinetypeProse=3]="LinetypeProse",n[n.TextFontFile=3]="TextFontFile",n[n.CLShapeName=4]="CLShapeName",n[n.DimensionAlternativePrefixSuffix=4]="DimensionAlternativePrefixSuffix",n[n.SymbolTableRecordComments=4]="SymbolTableRecordComments",n[n.TextBigFontFile=4]="TextBigFontFile",n[n.Handle=5]="Handle",n[n.DimensionBlock=5]="DimensionBlock",n[n.LinetypeName=6]="LinetypeName",n[n.DimBlk1=6]="DimBlk1",n[n.TextStyleName=7]="TextStyleName",n[n.DimBlk2=7]="DimBlk2",n[n.LayerName=8]="LayerName",n[n.CLShapeText=9]="CLShapeText",n[n.XCoordinate=10]="XCoordinate",n[n.YCoordinate=20]="YCoordinate",n[n.ZCoordinate=30]="ZCoordinate",n[n.Real=40]="Real",n[n.TxtSize=40]="TxtSize",n[n.ViewportHeight=40]="ViewportHeight",n[n.Angle=50]="Angle",n[n.ViewportSnapAngle=50]="ViewportSnapAngle",n[n.Visibility=60]="Visibility",n[n.Int16=70]="Int16",n[n.Int32=90]="Int32",n[n.Int64=160]="Int64",n[n.Int8=280]="Int8",n[n.Thickness=39]="Thickness",n[n.Elevation=38]="Elevation",n[n.LinetypeScale=48]="LinetypeScale",n[n.DashLength=49]="DashLength",n[n.MlineOffset=49]="MlineOffset",n[n.LinetypeElement=49]="LinetypeElement",n[n.NormalX=210]="NormalX",n[n.NormalY=220]="NormalY",n[n.NormalZ=230]="NormalZ",n[n.UcsOrg=110]="UcsOrg",n[n.UcsOrientationX=111]="UcsOrientationX",n[n.UcsOrientationY=112]="UcsOrientationY",n[n.ViewHeight=45]="ViewHeight",n[n.ViewWidth=41]="ViewWidth",n[n.ViewLensLength=42]="ViewLensLength",n[n.ViewFrontClip=43]="ViewFrontClip",n[n.ViewBackClip=44]="ViewBackClip",n[n.ViewBrightness=141]="ViewBrightness",n[n.ViewContrast=142]="ViewContrast",n[n.ViewMode=71]="ViewMode",n[n.ViewportActive=68]="ViewportActive",n[n.ViewportAspect=41]="ViewportAspect",n[n.ViewportGrid=76]="ViewportGrid",n[n.ViewportIcon=74]="ViewportIcon",n[n.ViewportNumber=69]="ViewportNumber",n[n.ViewportSnap=75]="ViewportSnap",n[n.ViewportSnapPair=78]="ViewportSnapPair",n[n.ViewportSnapStyle=77]="ViewportSnapStyle",n[n.ViewportTwist=51]="ViewportTwist",n[n.ViewportVisibility=67]="ViewportVisibility",n[n.ViewportZoom=73]="ViewportZoom",n[n.Color=62]="Color",n[n.ColorRgb=420]="ColorRgb",n[n.ColorName=430]="ColorName",n[n.LineWeight=370]="LineWeight",n[n.PlotStyleNameType=380]="PlotStyleNameType",n[n.PlotStyleNameId=390]="PlotStyleNameId",n[n.GradientObjType=450]="GradientObjType",n[n.GradientAngle=460]="GradientAngle",n[n.GradientName=470]="GradientName",n[n.GradientColCount=453]="GradientColCount",n[n.GradientPatType=451]="GradientPatType",n[n.GradientTintType=452]="GradientTintType",n[n.GradientShift=461]="GradientShift",n[n.GradientColVal=463]="GradientColVal",n[n.GradientTintVal=462]="GradientTintVal",n[n.SoftPointerId=330]="SoftPointerId",n[n.HardPointerId=340]="HardPointerId",n[n.SoftOwnershipId=350]="SoftOwnershipId",n[n.HardOwnershipId=360]="HardOwnershipId",n[n.ArbitraryHandle=320]="ArbitraryHandle",n[n.ExtendedDataAsciiString=1e3]="ExtendedDataAsciiString",n[n.ExtendedDataRegAppName=1001]="ExtendedDataRegAppName",n[n.ExtendedDataControlString=1002]="ExtendedDataControlString",n[n.ExtendedDataLayerName=1003]="ExtendedDataLayerName",n[n.ExtendedDataBinaryChunk=1004]="ExtendedDataBinaryChunk",n[n.ExtendedDataHandle=1005]="ExtendedDataHandle",n[n.ExtendedDataXCoordinate=1010]="ExtendedDataXCoordinate",n[n.ExtendedDataWorldXCoordinate=1011]="ExtendedDataWorldXCoordinate",n[n.ExtendedDataWorldXDisp=1012]="ExtendedDataWorldXDisp",n[n.ExtendedDataWorldXDir=1013]="ExtendedDataWorldXDir",n[n.ExtendedDataYCoordinate=1020]="ExtendedDataYCoordinate",n[n.ExtendedDataWorldYCoordinate=1021]="ExtendedDataWorldYCoordinate",n[n.ExtendedDataWorldYDisp=1022]="ExtendedDataWorldYDisp",n[n.ExtendedDataWorldYDir=1023]="ExtendedDataWorldYDir",n[n.ExtendedDataZCoordinate=1030]="ExtendedDataZCoordinate",n[n.ExtendedDataWorldZCoordinate=1031]="ExtendedDataWorldZCoordinate",n[n.ExtendedDataWorldZDisp=1032]="ExtendedDataWorldZDisp",n[n.ExtendedDataWorldZDir=1033]="ExtendedDataWorldZDir",n[n.ExtendedDataReal=1040]="ExtendedDataReal",n[n.ExtendedDataDist=1041]="ExtendedDataDist",n[n.ExtendedDataScale=1042]="ExtendedDataScale",n[n.ExtendedDataInteger16=1070]="ExtendedDataInteger16",n[n.ExtendedDataInteger32=1071]="ExtendedDataInteger32",n[n.XTextString=300]="XTextString",n[n.XReal=140]="XReal",n[n.XInt16=170]="XInt16",n[n.XXInt16=270]="XXInt16",n[n.Subclass=100]="Subclass",n[n.ControlString=102]="ControlString",n[n.EmbeddedObjectStart=101]="EmbeddedObjectStart",n[n.End=-1]="End",n[n.FirstEntityId=-2]="FirstEntityId",n[n.HeaderId=-2]="HeaderId",n[n.XDataStart=-3]="XDataStart",n[n.Operator=-4]="Operator",n[n.PReactors=-5]="PReactors",n[n.XDictionary=-6]="XDictionary"})(ci||(ci={}));var fe;(function(n){n[n.ByColor=1]="ByColor",n[n.ByACI=2]="ByACI",n[n.ByLayer=3]="ByLayer",n[n.ByBlock=4]="ByBlock",n[n.None=0]="None"})(fe||(fe={}));var S2=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},w2=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},Hy={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Id=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215,0],rs=(function(){function n(){}return n.getColorByIndex=function(t){return Id[t]},n.getIndexByColor=function(t){for(var e=Id.length-1,i=1;i<e;++i)if(Id[i]===t)return i},n.getColorByName=function(t){return Hy[t.toLowerCase()]},n.getNameByColor=function(t){var e,i;try{for(var r=S2(Object.entries(Hy)),s=r.next();!s.done;s=r.next()){var o=w2(s.value,2),a=o[0],l=o[1];if(l===t)return a}}catch(c){e={error:c}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(e)throw e.error}}},n.getNameByIndex=function(t){var e=this.getColorByIndex(t);return this.getNameByColor(e)},n})(),M2=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},rn=(function(){function n(t,e){if(t===void 0&&(t=fe.ByLayer),this._colorMethod=t,this._colorMethod==fe.ByColor&&e==null)this._value=16777215;else if(this._colorMethod==fe.ByACI)if(e==null)this._value=8;else if(e===0)this._colorMethod=fe.ByBlock;else if(e===256)this._colorMethod=fe.ByLayer;else{var i=Math.max(0,Math.min(256,Math.round(Number(e))));!Number.isFinite(i)||i===0?(this._colorMethod=fe.ByBlock,this._value=void 0):i===256?(this._colorMethod=fe.ByLayer,this._value=void 0):this._value=i}else this._value=e}return Object.defineProperty(n.prototype,"colorMethod",{get:function(){return this._colorMethod},set:function(t){this._colorMethod=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"red",{get:function(){var t=this.RGB;return t!=null?t>>16&255:void 0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"green",{get:function(){var t=this.RGB;return t!=null?t>>8&255:void 0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"blue",{get:function(){var t=this.RGB;return t!=null?t&255:void 0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"RGB",{get:function(){switch(this._colorMethod){case fe.ByColor:case fe.ByBlock:case fe.ByLayer:return this._value;case fe.ByACI:return this._value?rs.getColorByIndex(this._value):this._value;default:return}},enumerable:!1,configurable:!0}),n.prototype.setRGB=function(t,e,i){var r=Math.max(0,Math.min(255,Math.round(t))),s=Math.max(0,Math.min(255,Math.round(e))),o=Math.max(0,Math.min(255,Math.round(i)));return this._value=r<<16|s<<8|o,this._colorMethod=fe.ByColor,this},n.prototype.setRGBValue=function(t){return t==null||!Number.isFinite(t)?(console.warn("Invalid RGB value:",t),this):(this._value=t&16777215,this._colorMethod=fe.ByColor,this)},n.prototype.setRGBFromCss=function(t){if(!t)return this;var e=t.trim().toLowerCase();if(e.startsWith("#")){var i=0,r=0,s=0;if(e.length===7)i=parseInt(e.substr(1,2),16),r=parseInt(e.substr(3,2),16),s=parseInt(e.substr(5,2),16);else if(e.length===4)i=parseInt(e[1]+e[1],16),r=parseInt(e[2]+e[2],16),s=parseInt(e[3]+e[3],16);else return console.warn("Invalid hex color:",t),this;return this.setRGB(i,r,s)}var o=e.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);if(o){var i=parseInt(o[1],10),r=parseInt(o[2],10),s=parseInt(o[3],10);return this.setRGB(i,r,s)}var a=rs.getColorByName(t);return a!==void 0?this.setRGBValue(a):(console.warn("Unknown CSS color string:",t),this)},n.prototype.setScalar=function(t){return this.setRGB(t,t,t)},Object.defineProperty(n.prototype,"hexColor",{get:function(){var t=this.RGB;if(t!=null){var e=t.toString(16).padStart(6,"0").toUpperCase();return"0x"+e}},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"cssColor",{get:function(){var t=this.RGB;if(t!=null)return"rgb(".concat(t>>16&255,",").concat(t>>8&255,",").concat(t&255,")")},enumerable:!1,configurable:!0}),n.prototype.cssColorAlpha=function(t){var e=this.RGB;if(e!=null)return"rgba(".concat(e>>16&255,",").concat(e>>8&255,",").concat(e&255,",").concat(t,")")},Object.defineProperty(n.prototype,"colorIndex",{get:function(){return this._colorMethod===fe.ByACI?this._value:this._colorMethod===fe.ByLayer?256:this._colorMethod===fe.ByBlock?0:void 0},set:function(t){if(t!=null){var e=Math.max(0,Math.min(256,Math.round(Number(t))));if(!Number.isFinite(e)){this._colorMethod=fe.ByBlock,this._value=void 0;return}e===0?(this._colorMethod=fe.ByBlock,this._value=void 0):e===256?(this._colorMethod=fe.ByLayer,this._value=void 0):(this._colorMethod=fe.ByACI,this._value=e)}},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isByColor",{get:function(){return this._colorMethod===fe.ByColor},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isByACI",{get:function(){return this._colorMethod===fe.ByACI},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isForeground",{get:function(){return this._colorMethod===fe.ByACI&&this._value===7},enumerable:!1,configurable:!0}),n.prototype.setForeground=function(){return this._colorMethod=fe.ByACI,this._value=7,this},Object.defineProperty(n.prototype,"isByLayer",{get:function(){return this._colorMethod===fe.ByLayer},enumerable:!1,configurable:!0}),n.prototype.setByLayer=function(t){return this._colorMethod=fe.ByLayer,t==null?this._value=256:this._value=t,this},Object.defineProperty(n.prototype,"isByBlock",{get:function(){return this._colorMethod===fe.ByBlock},enumerable:!1,configurable:!0}),n.prototype.setByBlock=function(t){return this._colorMethod=fe.ByBlock,t==null?this._value=0:this._value=t,this},Object.defineProperty(n.prototype,"colorName",{get:function(){switch(this._colorMethod){case fe.ByLayer:return"ByLayer";case fe.ByBlock:return"ByBlock";case fe.ByColor:return this._value?rs.getNameByColor(this._value):"";case fe.ByACI:return this._value?rs.getNameByIndex(this._value):"";default:return}},set:function(t){if(t){var e=rs.getColorByName(t);e!==void 0?(this._value=e,this._colorMethod=fe.ByColor):console.warn("Unknown color name:",t)}},enumerable:!1,configurable:!0}),n.prototype.clone=function(){var t=new n;return t._colorMethod=this._colorMethod,t._value=this._value,t},n.prototype.copy=function(t){return this._colorMethod=t._colorMethod,this._value=t._value,this},n.prototype.equals=function(t){return this._colorMethod===t._colorMethod&&this._value===t._value},n.prototype.toString=function(){switch(this._colorMethod){case fe.None:return"None";case fe.ByLayer:return"ByLayer";case fe.ByBlock:return"ByBlock";case fe.ByACI:return this._value!==void 0?String(this._value):"";case fe.ByColor:return this._value?"RGB:".concat(this.red,",").concat(this.green,",").concat(this.blue):"";default:return""}},n.fromString=function(t){if(t){var e=t.trim();if(/^none$/i.test(e))return new n(fe.None);if(/^bylayer$/i.test(e))return new n(fe.ByLayer);if(/^byblock$/i.test(e))return new n(fe.ByBlock);var i=e.match(/^rgb\s*:\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})$/i);if(i){var r=Number(i[1]),s=Number(i[2]),o=Number(i[3]),a=new n(fe.ByColor);return a.setRGB(r,s,o),a}if(/^\d{1,3},\d{1,3},\d{1,3}$/.test(e)){var l=M2(e.split(",").map(Number),3),r=l[0],s=l[1],o=l[2],a=new n(fe.ByColor);return a.setRGB(r,s,o),a}if(/^\d+$/.test(e)){var c=parseInt(e,10);return new n(fe.ByACI,c)}if(/^book\$/i.test(e)){var u=e.substring(e.indexOf("$")+1),h=rs.getColorByName(u);if(h!=null)return new n(fe.ByColor,h);console.warn("Unknown color book entry:",t);return}var d=rs.getColorByName(e);if(d!=null)return new n(fe.ByColor,d);console.warn("Unknown color name:",t)}},n})(),Lr={get ILLEGAL_PARAMETERS(){return new ReferenceError("Illegal Parameters")}},E2=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},A2=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},C2=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))},vc=(function(){function n(){this.listeners=[]}return Object.defineProperty(n.prototype,"listenerCount",{get:function(){return this.listeners.length},enumerable:!1,configurable:!0}),n.prototype.addEventListener=function(t){this.listeners.push(t)},n.prototype.removeEventListener=function(t){this.listeners=this.listeners.filter(function(e){return e!==t})},n.prototype.replaceEventListener=function(t){this.removeEventListener(t),this.addEventListener(t)},n.prototype.dispatch=function(t){for(var e,i,r=[],s=1;s<arguments.length;s++)r[s-1]=arguments[s];try{for(var o=E2(this.listeners),a=o.next();!a.done;a=o.next()){var l=a.value,c=l;c.call.apply(c,C2([null,t],A2(r),!1))}}catch(u){e={error:u}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(e)throw e.error}}},n})(),Pd=function(){return Pd=Object.assign||function(n){for(var t,e=1,i=arguments.length;e<i;e++){t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},Pd.apply(this,arguments)},T2=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},L2=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))},Gy=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function Xa(n){return n===null||typeof n!="object"?n:Array.isArray(n)?L2([],T2(n),!1):Pd({},n)}function Rd(n){for(var t,e,i=[],r=1;r<arguments.length;r++)i[r-1]=arguments[r];try{for(var s=Gy(i),o=s.next();!o.done;o=s.next()){var a=o.value;if(a)for(var l in a)Object.prototype.hasOwnProperty.call(a,l)&&n[l]===void 0&&(n[l]=a[l])}}catch(c){t={error:c}}finally{try{o&&!o.done&&(e=s.return)&&e.call(s)}finally{if(t)throw t.error}}return n}function I2(n,t){return n!=null&&Object.prototype.hasOwnProperty.call(n,t)}function P2(n){return n==null?!0:Array.isArray(n)||typeof n=="string"?n.length===0:n instanceof Map||n instanceof Set?n.size===0:typeof n=="object"?Object.keys(n).length===0:!1}function po(n,t){var e,i;if(n===t)return!0;if(n==null||t==null)return n===t;if(typeof n!=typeof t)return!1;if(typeof n!="object")return n===t;if(Array.isArray(n)!==Array.isArray(t))return!1;if(Array.isArray(n)){if(n.length!==t.length)return!1;for(var r=0;r<n.length;r++)if(!po(n[r],t[r]))return!1;return!0}var s=Object.keys(n),o=Object.keys(t);if(s.length!==o.length)return!1;try{for(var a=Gy(s),l=a.next();!l.done;l=a.next()){var c=l.value;if(!Object.prototype.hasOwnProperty.call(t,c)||!po(n[c],t[c]))return!1}}catch(u){e={error:u}}finally{try{l&&!l.done&&(i=a.return)&&i.call(a)}finally{if(e)throw e.error}}return!0}var Vy=(function(){function n(t,e){this._changing=!1,this._pending=!1;var i=t||{};e&&Rd(i,e),this.attributes=i}return Object.defineProperty(n.prototype,"events",{get:function(){var t;return(t=this._events)!==null&&t!==void 0?t:this._events={attrChanged:new vc,modelChanged:new vc}},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"changed",{get:function(){var t;return(t=this._changed)!==null&&t!==void 0?t:this._changed={}},enumerable:!1,configurable:!0}),n.prototype.get=function(t){return this.attributes[t]},n.prototype.set=function(t,e,i){var r,s,o,a;if(t==null)return this;var l;typeof t=="object"?(l=t,i=e):(l={},l[t]=e),i||(i={});var c=i.unset,u=i.silent,h=this._events;if(!c&&!this._changing&&(h===void 0||h.attrChanged.listenerCount===0&&h.modelChanged.listenerCount===0)){if(typeof t=="object"){var d=t;for(var f in d)this.attributes[f]=d[f]}else this.attributes[t]=e;return this}if(!c){var p=!0;for(var f in l)if(this.attributes[f]!==l[f]){p=!1;break}if(p)return this._changing||(this._previousAttributes=Xa(this.attributes),this._changed={}),this}var g=null,y=this._changing;this._changing=!0,y||(this._previousAttributes=Xa(this.attributes),this._changed={});var m=this.attributes,v=(r=this._changed)!==null&&r!==void 0?r:this._changed={},x=(s=this._previousAttributes)!==null&&s!==void 0?s:{};for(var f in l){if(e=l[f],!c&&m[f]===e){x[f]===e||po(x[f],e)?delete v[f]:v[f]=e;continue}po(m[f],e)||(g||(g=[])).push(f),po(x[f],e)?delete v[f]:v[f]=e,c?delete m[f]:m[f]=e}if(!u&&(g&&(this._pending=i),g))for(var _=0;_<g.length;_++)(o=this._events)===null||o===void 0||o.attrChanged.dispatch({object:this,attrName:g[_],attrValue:m[g[_]],options:i});if(y)return this;if(!u)for(;this._pending;)i=this._pending,this._pending=!1,(a=this._events)===null||a===void 0||a.modelChanged.dispatch({object:this,options:i});return this._pending=!1,this._changing=!1,this},n.prototype.has=function(t){return this.get(t)!=null},n.prototype.hasChanged=function(t){return t==null?!P2(this._changed):this._changed?I2(this._changed,t):!1},n.prototype.changedAttributes=function(t){var e;if(!t)return this.hasChanged()?Xa((e=this._changed)!==null&&e!==void 0?e:{}):{};var i=this._changing?this._previousAttributes:this.attributes,r={};for(var s in t){var o=t[s];po(i==null?void 0:i[s],o)||(r[s]=o)}return r},n.prototype.previous=function(t){var e;return t==null?null:(e=this._previousAttributes)===null||e===void 0?void 0:e[t]},n.prototype.previousAttributes=function(){var t;return Xa((t=this._previousAttributes)!==null&&t!==void 0?t:{})},n.prototype.clone=function(){var t=Xa(this.attributes);return new n(t)},n})(),kn;(function(n){n[n.ByLayer=0]="ByLayer",n[n.ByBlock=1]="ByBlock",n[n.ByAlpha=2]="ByAlpha",n[n.ErrorValue=3]="ErrorValue"})(kn||(kn={}));var _c=(function(){function n(t){t!==void 0?(this._method=kn.ByAlpha,this._alpha=n.clampAlpha(t)):(this._method=kn.ByLayer,this._alpha=255)}return Object.defineProperty(n.prototype,"method",{get:function(){return this._method},set:function(t){this._method=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"alpha",{get:function(){return this._alpha},set:function(t){this._alpha=n.clampAlpha(t),this._method=kn.ByAlpha},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"percentage",{get:function(){if(this._method===kn.ByAlpha)return Math.round((1-this._alpha/255)*100)},set:function(t){var e=Math.max(0,Math.min(100,t)),i=Math.round(255*(1-e/100));this.alpha=i},enumerable:!1,configurable:!0}),n.clampAlpha=function(t){return Math.max(0,Math.min(255,Math.floor(t)))},Object.defineProperty(n.prototype,"isByAlpha",{get:function(){return this._method===kn.ByAlpha},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isByBlock",{get:function(){return this._method===kn.ByBlock},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isByLayer",{get:function(){return this._method===kn.ByLayer},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isClear",{get:function(){return this.isByAlpha&&this._alpha===0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isSolid",{get:function(){return this.isByAlpha&&this._alpha===255},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isInvalid",{get:function(){return this._method===kn.ErrorValue},enumerable:!1,configurable:!0}),n.prototype.serialize=function(){var t=this._method;return t<<24|this._alpha},n.prototype.clone=function(){var t=new n;return t._method=this._method,t._alpha=this._alpha,t},n.prototype.equals=function(t){return this._method===t._method&&this._alpha===t._alpha},n.prototype.toString=function(){return this.isByLayer?"ByLayer":this.isByBlock?"ByBlock":this._alpha.toString()},n.fromString=function(t){var e=t.trim(),i=e.toLowerCase();if(i===""||i==="."||i==="use current"||i==="bylayer"){var r=new n;return r._method=kn.ByLayer,r}if(i==="byblock"){var s=new n;return s._method=kn.ByBlock,s}var o=Number(e);if(Number.isInteger(o)&&o>=0&&o<=255){var a=new n;return o<=90?a.percentage=o:a.alpha=o,a}var l=new n;return l._method=kn.ErrorValue,l},n.deserialize=function(t){var e=t>>>24&255,i=t&255,r=e>=kn.ByLayer&&e<=kn.ErrorValue?e:kn.ErrorValue,s=new n;return s._method=r,s._alpha=n.clampAlpha(i),s},n})(),R2=function(n,t,e,i){function r(s){return s instanceof e?s:new e(function(o){o(s)})}return new(e||(e=Promise))(function(s,o){function a(u){try{c(i.next(u))}catch(h){o(h)}}function l(u){try{c(i.throw(u))}catch(h){o(h)}}function c(u){u.done?s(u.value):r(u.value).then(a,l)}c((i=i.apply(n,t||[])).next())})},k2=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(c){return function(u){return l([c,u])}}function l(c){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(e=0)),e;)try{if(i=1,r&&(s=c[0]&2?r.return:c[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,c[1])).done)return s;switch(r=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return e.label++,{value:c[1],done:!1};case 5:e.label++,r=c[1],c=[0];continue;case 7:c=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){e=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){e.label=c[1];break}if(c[0]===6&&e.label<s[1]){e.label=s[1],s=c;break}if(s&&e.label<s[2]){e.label=s[2],e.ops.push(c);break}s[2]&&e.ops.pop(),e.trys.pop();continue}c=t.call(n,e)}catch(u){c=[6,u],r=0}finally{i=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},O2=50;function Wy(){return new Promise(function(n){typeof globalThis<"u"&&typeof globalThis.requestAnimationFrame=="function"?globalThis.requestAnimationFrame(function(){return n()}):setTimeout(n,0)})}function ja(){return new Promise(function(n){if(typeof globalThis<"u"&&typeof globalThis.requestAnimationFrame=="function"){var t=globalThis.requestAnimationFrame;t(function(){return t(function(){return n()})})}else setTimeout(n,0)})}var B2=(function(){function n(t){t===void 0&&(t=O2),this._budgetMs=t,this._lastYieldCompletedAt=n.now()}return Object.defineProperty(n.prototype,"budgetMs",{get:function(){return this._budgetMs},enumerable:!1,configurable:!0}),n.prototype.maybeYield=function(){return R2(this,arguments,void 0,function(t){var e;return t===void 0&&(t=Wy),k2(this,function(i){switch(i.label){case 0:return e=n.now(),e-this._lastYieldCompletedAt<this._budgetMs?[2,!1]:[4,t()];case 1:return i.sent(),this._lastYieldCompletedAt=n.now(),[2,!0]}})})},n.prototype.mark=function(){this._lastYieldCompletedAt=n.now()},n.now=function(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()},n})(),On=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],Xy=1234567,jy=Math.PI/180,$y=180/Math.PI;function N2(){var n=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,i=Math.random()*4294967295|0,r=On[n&255]+On[n>>8&255]+On[n>>16&255]+On[n>>24&255]+"-"+On[t&255]+On[t>>8&255]+"-"+On[t>>16&15|64]+On[t>>24&255]+"-"+On[e&63|128]+On[e>>8&255]+"-"+On[e>>16&255]+On[e>>24&255]+On[i&255]+On[i>>8&255]+On[i>>16&255]+On[i>>24&255];return r.toLowerCase()}function $a(n,t,e){return Math.max(t,Math.min(e,n))}function Yy(n,t){return(n%t+t)%t}function D2(n,t,e,i,r){return i+(n-t)*(r-i)/(e-t)}function U2(n,t,e){return n!==t?(e-n)/(t-n):0}function qy(n,t,e){return(1-e)*n+e*t}function z2(n,t,e,i){return qy(n,t,1-Math.exp(-e*i))}function F2(n,t){return t===void 0&&(t=1),t-Math.abs(Yy(n,t*2)-t)}function H2(n,t,e){return n<=t?0:n>=e?1:(n=(n-t)/(e-t),n*n*(3-2*n))}function G2(n,t,e){return n<=t?0:n>=e?1:(n=(n-t)/(e-t),n*n*n*(n*(n*6-15)+10))}function V2(n,t){return n+Math.floor(Math.random()*(t-n+1))}function W2(n,t){return n+Math.random()*(t-n)}function X2(n){return n*(.5-Math.random())}function j2(n){n!==void 0&&(Xy=n);var t=Xy+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function $2(n){return n*jy}function Y2(n){return n*$y}function q2(n){return(n&n-1)===0&&n!==0}function K2(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function Z2(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function mo(n){var t=Math.PI*2;return(n%t+t)%t}function J2(n,t,e){return n>t&&n<e||n>e&&n<t}function Q2(n,t,e,i){return i===void 0&&(i=!1),n=mo(n),t=mo(t),e=mo(e),i?t>e?n<=t&&n>=e:n<=t||n>=e:t<e?n>=t&&n<=e:n>=t||n<=e}function tE(n,t,e){var i=mo(e-n),r=mo(t-n);return r<=i+1e-7}function Ky(n){return n=Math.abs(n),n<1?0:Math.ceil(Math.log10(Math.abs(n)+1))}function eE(n,t){t===void 0&&(t=1e-7);var e=Ky(n);return Math.max(Math.pow(10,e)*t,t)}var ne={DEG2RAD:jy,RAD2DEG:$y,generateUUID:N2,clamp:$a,euclideanModulo:Yy,mapLinear:D2,inverseLerp:U2,lerp:qy,damp:z2,pingpong:F2,smoothstep:H2,smootherstep:G2,randInt:V2,randFloat:W2,randFloatSpread:X2,seededRandom:j2,degToRad:$2,radToDeg:Y2,isPowerOfTwo:q2,ceilPowerOfTwo:K2,floorPowerOfTwo:Z2,normalizeAngle:mo,isBetween:J2,isBetweenAngle:Q2,isAngleOnCcwSweep:tE,intPartLength:Ky,relativeEps:eE},nE=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(c){return function(u){return l([c,u])}}function l(c){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(e=0)),e;)try{if(i=1,r&&(s=c[0]&2?r.return:c[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,c[1])).done)return s;switch(r=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return e.label++,{value:c[1],done:!1};case 5:e.label++,r=c[1],c=[0];continue;case 7:c=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){e=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){e.label=c[1];break}if(c[0]===6&&e.label<s[1]){e.label=s[1],s=c;break}if(s&&e.label<s[2]){e.label=s[2],e.ops.push(c);break}s[2]&&e.ops.pop(),e.trys.pop();continue}c=t.call(n,e)}catch(u){c=[6,u],r=0}finally{i=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},mn=(function(){function n(t,e){this.x=0,this.y=0;var i=+(t!==void 0)+ +(e!==void 0);if(i!==0){if(i===1&&t instanceof Array){this.x=t[0],this.y=t[1];return}if(i===1){var r=t,s=r.x,o=r.y;this.x=s,this.y=o;return}if(i===2){this.x=t,this.y=e;return}throw Lr.ILLEGAL_PARAMETERS}}return Object.defineProperty(n.prototype,"width",{get:function(){return this.x},set:function(t){this.x=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"height",{get:function(){return this.y},set:function(t){this.y=t},enumerable:!1,configurable:!0}),n.prototype.set=function(t,e){return this.x=t,this.y=e,this},n.prototype.setScalar=function(t){return this.x=t,this.y=t,this},n.prototype.setX=function(t){return this.x=t,this},n.prototype.setY=function(t){return this.y=t,this},n.prototype.setComponent=function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this},n.prototype.getComponent=function(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}},n.prototype.clone=function(){return new n(this.x,this.y)},n.prototype.copy=function(t){return this.x=t.x,this.y=t.y,this},n.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this},n.prototype.addScalar=function(t){return this.x+=t,this.y+=t,this},n.prototype.addVectors=function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},n.prototype.addScaledVector=function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this},n.prototype.sub=function(t){return this.x-=t.x,this.y-=t.y,this},n.prototype.subScalar=function(t){return this.x-=t,this.y-=t,this},n.prototype.subVectors=function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},n.prototype.multiply=function(t){return this.x*=t.x,this.y*=t.y,this},n.prototype.multiplyScalar=function(t){return this.x*=t,this.y*=t,this},n.prototype.divide=function(t){return this.x/=t.x,this.y/=t.y,this},n.prototype.divideScalar=function(t){return this.multiplyScalar(1/t)},n.prototype.applyMatrix2d=function(t){var e=this.x,i=this.y,r=t.elements;return this.x=r[0]*e+r[3]*i+r[6],this.y=r[1]*e+r[4]*i+r[7],this},n.prototype.min=function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this},n.prototype.max=function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this},n.prototype.clamp=function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this},n.prototype.clampScalar=function(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this},n.prototype.clampLength=function(t,e){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))},n.prototype.floor=function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},n.prototype.ceil=function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},n.prototype.round=function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},n.prototype.roundToZero=function(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this},n.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this},n.prototype.dot=function(t){return this.x*t.x+this.y*t.y},n.prototype.cross=function(t){return this.x*t.y-this.y*t.x},n.prototype.lengthSq=function(){return this.x*this.x+this.y*this.y},n.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},n.prototype.manhattanLength=function(){return Math.abs(this.x)+Math.abs(this.y)},n.prototype.normalize=function(){return this.divideScalar(this.length()||1)},n.prototype.angle=function(){var t=Math.atan2(-this.y,-this.x)+Math.PI;return t},n.prototype.angleTo=function(t){var e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;var i=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,i)))},n.prototype.distanceTo=function(t){return Math.sqrt(this.distanceToSquared(t))},n.prototype.distanceToSquared=function(t){var e=this.x-t.x,i=this.y-t.y;return e*e+i*i},n.prototype.manhattanDistanceTo=function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)},n.prototype.setLength=function(t){return this.normalize().multiplyScalar(t)},n.prototype.lerp=function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},n.prototype.lerpVectors=function(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this},n.prototype.equals=function(t){return t.x===this.x&&t.y===this.y},n.prototype.fromArray=function(t,e){return e===void 0&&(e=0),this.x=t[e],this.y=t[e+1],this},n.prototype.toArray=function(t,e){return t===void 0&&(t=[]),e===void 0&&(e=0),t[e]=this.x,t[e+1]=this.y,t},n.prototype.rotateAround=function(t,e){var i=Math.cos(e),r=Math.sin(e),s=this.x-t.x,o=this.y-t.y;return this.x=s*i-o*r+t.x,this.y=s*r+o*i+t.y,this},n.prototype.random=function(){return this.x=Math.random(),this.y=Math.random(),this},n.prototype.relativeEps=function(t){return t===void 0&&(t=1e-7),Math.min(ne.relativeEps(this.x,t),ne.relativeEps(this.y,t))},n.prototype[Symbol.iterator]=function(){return nE(this,function(t){switch(t.label){case 0:return[4,this.x];case 1:return t.sent(),[4,this.y];case 2:return t.sent(),[2]}})},n.EMPTY=Object.freeze(new n(0,0)),n})(),kd=(function(){function n(t,e,i,r,s,o,a,l,c){this.elements=[1,0,0,0,1,0,0,0,1],t!=null&&e!=null&&i!=null&&r!=null&&s!=null&&o!=null&&a!=null&&l!=null&&c!=null&&this.set(t,e,i,r,s,o,a,l,c)}return n.prototype.set=function(t,e,i,r,s,o,a,l,c){var u=this.elements;return u[0]=t,u[1]=r,u[2]=a,u[3]=e,u[4]=s,u[5]=l,u[6]=i,u[7]=o,u[8]=c,this},n.prototype.identity=function(){return this.set(1,0,0,0,1,0,0,0,1),this},n.prototype.copy=function(t){var e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this},n.prototype.extractBasis=function(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this},n.prototype.setFromMatrix4=function(t){var e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this},n.prototype.multiply=function(t){return this.multiplyMatrices(this,t)},n.prototype.premultiply=function(t){return this.multiplyMatrices(t,this)},n.prototype.multiplyMatrices=function(t,e){var i=t.elements,r=e.elements,s=this.elements,o=i[0],a=i[3],l=i[6],c=i[1],u=i[4],h=i[7],d=i[2],f=i[5],p=i[8],g=r[0],y=r[3],m=r[6],v=r[1],x=r[4],_=r[7],b=r[2],w=r[5],C=r[8];return s[0]=o*g+a*v+l*b,s[3]=o*y+a*x+l*w,s[6]=o*m+a*_+l*C,s[1]=c*g+u*v+h*b,s[4]=c*y+u*x+h*w,s[7]=c*m+u*_+h*C,s[2]=d*g+f*v+p*b,s[5]=d*y+f*x+p*w,s[8]=d*m+f*_+p*C,this},n.prototype.multiplyScalar=function(t){var e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this},n.prototype.determinant=function(){var t=this.elements,e=t[0],i=t[1],r=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],u=t[8];return e*o*u-e*a*c-i*s*u+i*a*l+r*s*c-r*o*l},n.prototype.invert=function(){var t=this.elements,e=t[0],i=t[1],r=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=u*o-a*c,d=a*l-u*s,f=c*s-o*l,p=e*h+i*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);var g=1/p;return t[0]=h*g,t[1]=(r*c-u*i)*g,t[2]=(a*i-r*o)*g,t[3]=d*g,t[4]=(u*e-r*l)*g,t[5]=(r*s-a*e)*g,t[6]=f*g,t[7]=(i*l-c*e)*g,t[8]=(o*e-i*s)*g,this},n.prototype.transpose=function(){var t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this},n.prototype.getNormalMatrix=function(t){return this.setFromMatrix4(t).invert().transpose()},n.prototype.transposeIntoArray=function(t){var e=this.elements;return t.elements[0]=e[0],t.elements[1]=e[3],t.elements[2]=e[6],t.elements[3]=e[1],t.elements[4]=e[4],t.elements[5]=e[7],t.elements[6]=e[2],t.elements[7]=e[5],t.elements[8]=e[8],this},n.prototype.setUvTransform=function(t,e,i,r,s,o,a){var l=Math.cos(s),c=Math.sin(s);return this.set(i*l,i*c,-i*(l*o+c*a)+o+t,-r*c,r*l,-r*(-c*o+l*a)+a+e,0,0,1),this},n.prototype.scale=function(t,e){return this.premultiply(Od.makeScale(t,e)),this},n.prototype.rotate=function(t){return this.premultiply(Od.makeRotation(-t)),this},n.prototype.translate=function(t,e){return this.premultiply(Od.makeTranslation(t,e)),this},n.prototype.makeTranslation=function(t,e){return t instanceof mn?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this},n.prototype.makeRotation=function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,i,e,0,0,0,1),this},n.prototype.makeScale=function(t,e){return this.set(t,0,0,0,e,0,0,0,1),this},n.prototype.equals=function(t){for(var e=this.elements,i=t.elements,r=0;r<9;r++)if(e[r]!==i[r])return!1;return!0},n.prototype.fromArray=function(t,e){e===void 0&&(e=0);for(var i=0;i<9;i++)this.elements[i]=t[i+e];return this},n.prototype.toArray=function(t,e){t===void 0&&(t=[]),e===void 0&&(e=0);var i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t},n.prototype.clone=function(){return new n().fromArray(this.elements)},n.IDENTITY=Object.freeze(new n),n})(),Od=new kd,Oe=1e-6,ue=2*Math.PI,Zy={x:0,y:0,z:0},Ae=(function(){function n(){this.equalPointTol=Oe,this.equalVectorTol=Oe}return n.prototype.clone=function(){var t=new n;return t.equalPointTol=this.equalPointTol,t.equalVectorTol=this.equalVectorTol,t},n.prototype.equalPoint2d=function(t,e){return new mn(t).sub(e).length()<this.equalPointTol},n.prototype.equalPoint3d=function(t,e){return new _t(t).sub(e).length()<this.equalPointTol},n.equalToZero=function(t,e){return e===void 0&&(e=Oe),t<e&&t>-e},n.equal=function(t,e,i){return i===void 0&&(i=Oe),Math.abs(t-e)<i},n.great=function(t,e,i){return i===void 0&&(i=Oe),t-e>i},n.less=function(t,e,i){return i===void 0&&(i=Oe),t-e<i},n.isPositive=function(t,e){return e===void 0&&(e=Oe),t>e},n.isNonPositive=function(t,e){return e===void 0&&(e=Oe),t<=e},n})(),Jy=new Ae,iE=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(c){return function(u){return l([c,u])}}function l(c){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(e=0)),e;)try{if(i=1,r&&(s=c[0]&2?r.return:c[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,c[1])).done)return s;switch(r=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return e.label++,{value:c[1],done:!1};case 5:e.label++,r=c[1],c=[0];continue;case 7:c=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){e=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){e.label=c[1];break}if(c[0]===6&&e.label<s[1]){e.label=s[1],s=c;break}if(s&&e.label<s[2]){e.label=s[2],e.ops.push(c);break}s[2]&&e.ops.pop(),e.trys.pop();continue}c=t.call(n,e)}catch(u){c=[6,u],r=0}finally{i=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},rE=(function(){function n(t,e,i,r){t===void 0&&(t=0),e===void 0&&(e=0),i===void 0&&(i=0),r===void 0&&(r=1),this._x=t,this._y=e,this._z=i,this._w=r}return n.slerpFlat=function(t,e,i,r,s,o,a){var l=i[r+0],c=i[r+1],u=i[r+2],h=i[r+3],d=s[o+0],f=s[o+1],p=s[o+2],g=s[o+3];if(a===0){t[e+0]=l,t[e+1]=c,t[e+2]=u,t[e+3]=h;return}if(a===1){t[e+0]=d,t[e+1]=f,t[e+2]=p,t[e+3]=g;return}if(h!==g||l!==d||c!==f||u!==p){var y=1-a,m=l*d+c*f+u*p+h*g,v=m>=0?1:-1,x=1-m*m;if(x>Number.EPSILON){var _=Math.sqrt(x),b=Math.atan2(_,m*v);y=Math.sin(y*b)/_,a=Math.sin(a*b)/_}var w=a*v;if(l=l*y+d*w,c=c*y+f*w,u=u*y+p*w,h=h*y+g*w,y===1-a){var C=1/Math.sqrt(l*l+c*c+u*u+h*h);l*=C,c*=C,u*=C,h*=C}}t[e]=l,t[e+1]=c,t[e+2]=u,t[e+3]=h},n.multiplyQuaternionsFlat=function(t,e,i,r,s,o){var a=i[r],l=i[r+1],c=i[r+2],u=i[r+3],h=s[o],d=s[o+1],f=s[o+2],p=s[o+3];return t[e]=a*p+u*h+l*f-c*d,t[e+1]=l*p+u*d+c*h-a*f,t[e+2]=c*p+u*f+a*d-l*h,t[e+3]=u*p-a*h-l*d-c*f,t},Object.defineProperty(n.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._onChangeCallback()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._onChangeCallback()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"z",{get:function(){return this._z},set:function(t){this._z=t,this._onChangeCallback()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"w",{get:function(){return this._w},set:function(t){this._w=t,this._onChangeCallback()},enumerable:!1,configurable:!0}),n.prototype.set=function(t,e,i,r){return this._x=t,this._y=e,this._z=i,this._w=r,this._onChangeCallback(),this},n.prototype.clone=function(){return new n(this._x,this._y,this._z,this._w)},n.prototype.copy=function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this},n.prototype.setFromEuler=function(t,e){e===void 0&&(e=!0);var i=t.x,r=t.y,s=t.z,o=t.order,a=Math.cos,l=Math.sin,c=a(i/2),u=a(r/2),h=a(s/2),d=l(i/2),f=l(r/2),p=l(s/2);switch(o){case"XYZ":this._x=d*u*h+c*f*p,this._y=c*f*h-d*u*p,this._z=c*u*p+d*f*h,this._w=c*u*h-d*f*p;break;case"YXZ":this._x=d*u*h+c*f*p,this._y=c*f*h-d*u*p,this._z=c*u*p-d*f*h,this._w=c*u*h+d*f*p;break;case"ZXY":this._x=d*u*h-c*f*p,this._y=c*f*h+d*u*p,this._z=c*u*p+d*f*h,this._w=c*u*h-d*f*p;break;case"ZYX":this._x=d*u*h-c*f*p,this._y=c*f*h+d*u*p,this._z=c*u*p-d*f*h,this._w=c*u*h+d*f*p;break;case"YZX":this._x=d*u*h+c*f*p,this._y=c*f*h+d*u*p,this._z=c*u*p-d*f*h,this._w=c*u*h-d*f*p;break;case"XZY":this._x=d*u*h-c*f*p,this._y=c*f*h-d*u*p,this._z=c*u*p+d*f*h,this._w=c*u*h+d*f*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e===!0&&this._onChangeCallback(),this},n.prototype.setFromAxisAngle=function(t,e){var i=e/2,r=Math.sin(i);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(i),this._onChangeCallback(),this},n.prototype.setFromRotationMatrix=function(t){var e=t.elements,i=e[0],r=e[4],s=e[8],o=e[1],a=e[5],l=e[9],c=e[2],u=e[6],h=e[10],d=i+a+h;if(d>0){var f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(u-l)*f,this._y=(s-c)*f,this._z=(o-r)*f}else if(i>a&&i>h){var f=2*Math.sqrt(1+i-a-h);this._w=(u-l)/f,this._x=.25*f,this._y=(r+o)/f,this._z=(s+c)/f}else if(a>h){var f=2*Math.sqrt(1+a-i-h);this._w=(s-c)/f,this._x=(r+o)/f,this._y=.25*f,this._z=(l+u)/f}else{var f=2*Math.sqrt(1+h-i-a);this._w=(o-r)/f,this._x=(s+c)/f,this._y=(l+u)/f,this._z=.25*f}return this._onChangeCallback(),this},n.prototype.setFromUnitVectors=function(t,e){var i=t.dot(e)+1;return i<Number.EPSILON?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=i),this.normalize()},n.prototype.angleTo=function(t){return 2*Math.acos(Math.abs($a(this.dot(t),-1,1)))},n.prototype.rotateTowards=function(t,e){var i=this.angleTo(t);if(i===0)return this;var r=Math.min(1,e/i);return this.slerp(t,r),this},n.prototype.identity=function(){return this.set(0,0,0,1)},n.prototype.invert=function(){return this.conjugate()},n.prototype.conjugate=function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this},n.prototype.dot=function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w},n.prototype.lengthSq=function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},n.prototype.length=function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},n.prototype.normalize=function(){var t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this},n.prototype.multiply=function(t){return this.multiplyQuaternions(this,t)},n.prototype.premultiply=function(t){return this.multiplyQuaternions(t,this)},n.prototype.multiplyQuaternions=function(t,e){var i=t._x,r=t._y,s=t._z,o=t._w,a=e._x,l=e._y,c=e._z,u=e._w;return this._x=i*u+o*a+r*c-s*l,this._y=r*u+o*l+s*a-i*c,this._z=s*u+o*c+i*l-r*a,this._w=o*u-i*a-r*l-s*c,this._onChangeCallback(),this},n.prototype.slerp=function(t,e){if(e===0)return this;if(e===1)return this.copy(t);var i=this._x,r=this._y,s=this._z,o=this._w,a=o*t._w+i*t._x+r*t._y+s*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=i,this._y=r,this._z=s,this;var l=1-a*a;if(l<=Number.EPSILON){var c=1-e;return this._w=c*o+e*this._w,this._x=c*i+e*this._x,this._y=c*r+e*this._y,this._z=c*s+e*this._z,this.normalize(),this}var u=Math.sqrt(l),h=Math.atan2(u,a),d=Math.sin((1-e)*h)/u,f=Math.sin(e*h)/u;return this._w=o*d+this._w*f,this._x=i*d+this._x*f,this._y=r*d+this._y*f,this._z=s*d+this._z*f,this._onChangeCallback(),this},n.prototype.slerpQuaternions=function(t,e,i){return this.copy(t).slerp(e,i)},n.prototype.random=function(){var t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(r*Math.sin(t),r*Math.cos(t),s*Math.sin(e),s*Math.cos(e))},n.prototype.equals=function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w},n.prototype.fromArray=function(t,e){return e===void 0&&(e=0),this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this},n.prototype.toArray=function(t,e){return t===void 0&&(t=[]),e===void 0&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t},n.prototype.toJSON=function(){return this.toArray()},n.prototype._onChange=function(t){return this._onChangeCallback=t,this},n.prototype._onChangeCallback=function(){},n.prototype[Symbol.iterator]=function(){return iE(this,function(t){switch(t.label){case 0:return[4,this._x];case 1:return t.sent(),[4,this._y];case 2:return t.sent(),[4,this._z];case 3:return t.sent(),[4,this._w];case 4:return t.sent(),[2]}})},n})(),sE=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(c){return function(u){return l([c,u])}}function l(c){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(e=0)),e;)try{if(i=1,r&&(s=c[0]&2?r.return:c[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,c[1])).done)return s;switch(r=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return e.label++,{value:c[1],done:!1};case 5:e.label++,r=c[1],c=[0];continue;case 7:c=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){e=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){e.label=c[1];break}if(c[0]===6&&e.label<s[1]){e.label=s[1],s=c;break}if(s&&e.label<s[2]){e.label=s[2],e.ops.push(c);break}s[2]&&e.ops.pop(),e.trys.pop();continue}c=t.call(n,e)}catch(u){c=[6,u],r=0}finally{i=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},_t=(function(){function n(t,e,i){this.x=0,this.y=0,this.z=0;var r=+(t!==void 0)+ +(e!==void 0)+ +(i!==void 0);if(r!==0){if(r===1&&t instanceof Array){this.x=t[0],this.y=t[1],this.z=t[2];return}if(r===1){var s=t,o=s.x,a=s.y,l=s.z;this.x=o,this.y=a,this.z=l||0;return}if(r===3){this.x=t,this.y=e,this.z=i;return}throw Lr.ILLEGAL_PARAMETERS}}return n.prototype.set=function(t,e,i){return i===void 0&&(i=this.z),this.x=t,this.y=e,this.z=i,this},n.prototype.setScalar=function(t){return this.x=t,this.y=t,this.z=t,this},n.prototype.setX=function(t){return this.x=t,this},n.prototype.setY=function(t){return this.y=t,this},n.prototype.setZ=function(t){return this.z=t,this},n.prototype.setComponent=function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this},n.prototype.getComponent=function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}},n.prototype.clone=function(){return new n(this.x,this.y,this.z)},n.prototype.copy=function(t){return this.x=t.x,this.y=t.y,this.z=t.z||0,this},n.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z||0,this},n.prototype.addScalar=function(t){return this.x+=t,this.y+=t,this.z+=t,this},n.prototype.addVectors=function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},n.prototype.addScaledVector=function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},n.prototype.sub=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this},n.prototype.subScalar=function(t){return this.x-=t,this.y-=t,this.z-=t,this},n.prototype.subVectors=function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},n.prototype.multiply=function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this},n.prototype.multiplyScalar=function(t){return this.x*=t,this.y*=t,this.z*=t,this},n.prototype.multiplyVectors=function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this},n.prototype.applyEuler=function(t){return this.applyQuaternion(Qy.setFromEuler(t))},n.prototype.applyAxisAngle=function(t,e){return this.applyQuaternion(Qy.setFromAxisAngle(t,e))},n.prototype.applyMatrix3=function(t){var e=this.x,i=this.y,r=this.z,s=t.elements;return this.x=s[0]*e+s[3]*i+s[6]*r,this.y=s[1]*e+s[4]*i+s[7]*r,this.z=s[2]*e+s[5]*i+s[8]*r,this},n.prototype.applyNormalMatrix=function(t){return this.applyMatrix3(t).normalize()},n.prototype.applyMatrix4=function(t){var e=this.x,i=this.y,r=this.z,s=t.elements,o=1/(s[3]*e+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*e+s[4]*i+s[8]*r+s[12])*o,this.y=(s[1]*e+s[5]*i+s[9]*r+s[13])*o,this.z=(s[2]*e+s[6]*i+s[10]*r+s[14])*o,this},n.prototype.applyQuaternion=function(t){var e=this.x,i=this.y,r=this.z,s=t.x,o=t.y,a=t.z,l=t.w,c=2*(o*r-a*i),u=2*(a*e-s*r),h=2*(s*i-o*e);return this.x=e+l*c+o*h-a*u,this.y=i+l*u+a*c-s*h,this.z=r+l*h+s*u-o*c,this},n.prototype.transformDirection=function(t){var e=this.x,i=this.y,r=this.z,s=t.elements;return this.x=s[0]*e+s[4]*i+s[8]*r,this.y=s[1]*e+s[5]*i+s[9]*r,this.z=s[2]*e+s[6]*i+s[10]*r,this.normalize()},n.prototype.divide=function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},n.prototype.divideScalar=function(t){return this.multiplyScalar(1/t)},n.prototype.min=function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this},n.prototype.max=function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this},n.prototype.clamp=function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this},n.prototype.clampScalar=function(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this},n.prototype.clampLength=function(t,e){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))},n.prototype.floor=function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},n.prototype.ceil=function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},n.prototype.round=function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},n.prototype.roundToZero=function(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this},n.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},n.prototype.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z},n.prototype.isParallelTo=function(t){var e=this.dot(t),i=this.length(),r=t.length();return Math.abs(e)===i*r},n.prototype.lengthSq=function(){return this.x*this.x+this.y*this.y+this.z*this.z},n.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},n.prototype.manhattanLength=function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},n.prototype.normalize=function(){return this.divideScalar(this.length()||1)},n.prototype.setLength=function(t){return this.normalize().multiplyScalar(t)},n.prototype.lerp=function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this},n.prototype.lerpVectors=function(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this},n.prototype.cross=function(t){return this.crossVectors(this,t)},n.prototype.crossVectors=function(t,e){var i=t.x,r=t.y,s=t.z,o=e.x,a=e.y,l=e.z;return this.x=r*l-s*a,this.y=s*o-i*l,this.z=i*a-r*o,this},n.prototype.projectOnVector=function(t){var e=t.lengthSq();if(e===0)return this.set(0,0,0);var i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)},n.prototype.projectOnPlane=function(t){return Bd.copy(this).projectOnVector(t),this.sub(Bd)},n.prototype.reflect=function(t){return this.sub(Bd.copy(t).multiplyScalar(2*this.dot(t)))},n.prototype.angleTo=function(t){var e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;var i=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,i)))},n.prototype.distanceTo=function(t){return Math.sqrt(this.distanceToSquared(t))},n.prototype.distanceToSquared=function(t){var e=this.x-t.x,i=this.y-t.y,r=this.z-t.z;return e*e+i*i+r*r},n.prototype.manhattanDistanceTo=function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)},n.prototype.setFromMatrixPosition=function(t){var e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this},n.prototype.setFromMatrixScale=function(t){var e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=r,this},n.prototype.setFromMatrixColumn=function(t,e){return this.fromArray(t.elements,e*4)},n.prototype.setFromMatrix3Column=function(t,e){return this.fromArray(t.elements,e*3)},n.prototype.equals=function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},n.prototype.fromArray=function(t,e){return e===void 0&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},n.prototype.toArray=function(t,e){return t===void 0&&(t=[]),e===void 0&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t},n.prototype.random=function(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this},n.prototype.randomDirection=function(){var t=Math.random()*Math.PI*2,e=Math.random()*2-1,i=Math.sqrt(1-e*e);return this.x=i*Math.cos(t),this.y=e,this.z=i*Math.sin(t),this},n.prototype[Symbol.iterator]=function(){return sE(this,function(t){switch(t.label){case 0:return[4,this.x];case 1:return t.sent(),[4,this.y];case 2:return t.sent(),[4,this.z];case 3:return t.sent(),[2]}})},n.ORIGIN=Object.freeze(new n(0,0,0)),n.X_AXIS=Object.freeze(new n(1,0,0)),n.NEGATIVE_X_AXIS=Object.freeze(new n(-1,0,0)),n.Y_AXIS=Object.freeze(new n(0,1,0)),n.NEGATIVE_Y_AXIS=Object.freeze(new n(0,-1,0)),n.Z_AXIS=Object.freeze(new n(0,0,1)),n.NEGATIVE_Z_AXIS=Object.freeze(new n(0,0,-1)),n})(),Bd=new _t,Qy=new rE,Ya=(function(){function n(t,e,i,r,s,o,a,l,c,u,h,d,f,p,g,y){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!=null&&e!=null&&i!=null&&r!=null&&s!=null&&o!=null&&a!=null&&l!=null&&c!=null&&u!=null&&h!=null&&d!=null&&f!=null&&p!=null&&g!=null&&y!=null&&this.set(t,e,i,r,s,o,a,l,c,u,h,d,f,p,g,y)}return n.makeTranslation=function(t,e,i){return new n().makeTranslation(t,e,i)},n.prototype.set=function(t,e,i,r,s,o,a,l,c,u,h,d,f,p,g,y){var m=this.elements;return m[0]=t,m[4]=e,m[8]=i,m[12]=r,m[1]=s,m[5]=o,m[9]=a,m[13]=l,m[2]=c,m[6]=u,m[10]=h,m[14]=d,m[3]=f,m[7]=p,m[11]=g,m[15]=y,this},n.prototype.identity=function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},n.prototype.clone=function(){return new n().fromArray(this.elements)},n.prototype.copy=function(t){var e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this},n.prototype.copyPosition=function(t){var e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this},n.prototype.setFromMatrix3=function(t){var e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this},n.prototype.setFromExtrusionDirection=function(t){var e=Math.hypot(t.x,t.y,t.z);if(!Number.isFinite(e)||e<1e-12)return this.identity(),this;var i=Math.abs(e-1)>1e-6?t.clone().multiplyScalar(1/e):t;if(Jy.equalPoint3d(i,_t.Z_AXIS))this.identity();else{var r=new _t(1,0,0);Math.abs(i.x)<1/64&&Math.abs(i.y)<1/64?r.crossVectors(_t.Y_AXIS,i).normalize():r.crossVectors(_t.Z_AXIS,i).normalize();var s=i.clone().cross(r).normalize();this.makeBasis(r,s,i)}return this},n.prototype.extractBasis=function(t,e,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this},n.prototype.makeBasis=function(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this},n.prototype.extractRotation=function(t){var e=this.elements,i=t.elements,r=1/go.setFromMatrixColumn(t,0).length(),s=1/go.setFromMatrixColumn(t,1).length(),o=1/go.setFromMatrixColumn(t,2).length();return e[0]=i[0]*r,e[1]=i[1]*r,e[2]=i[2]*r,e[3]=0,e[4]=i[4]*s,e[5]=i[5]*s,e[6]=i[6]*s,e[7]=0,e[8]=i[8]*o,e[9]=i[9]*o,e[10]=i[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},n.prototype.makeRotationFromQuaternion=function(t){return this.compose(oE,t,aE)},n.prototype.lookAt=function(t,e,i){var r=this.elements;return ui.subVectors(t,e),ui.lengthSq()===0&&(ui.z=1),ui.normalize(),ss.crossVectors(i,ui),ss.lengthSq()===0&&(Math.abs(i.z)===1?ui.x+=1e-4:ui.z+=1e-4,ui.normalize(),ss.crossVectors(i,ui)),ss.normalize(),xc.crossVectors(ui,ss),r[0]=ss.x,r[4]=xc.x,r[8]=ui.x,r[1]=ss.y,r[5]=xc.y,r[9]=ui.y,r[2]=ss.z,r[6]=xc.z,r[10]=ui.z,this},n.prototype.multiply=function(t){return this.multiplyMatrices(this,t)},n.prototype.premultiply=function(t){return this.multiplyMatrices(t,this)},n.prototype.multiplyMatrices=function(t,e){var i=t.elements,r=e.elements,s=this.elements,o=i[0],a=i[4],l=i[8],c=i[12],u=i[1],h=i[5],d=i[9],f=i[13],p=i[2],g=i[6],y=i[10],m=i[14],v=i[3],x=i[7],_=i[11],b=i[15],w=r[0],C=r[4],E=r[8],T=r[12],k=r[1],O=r[5],U=r[9],z=r[13],L=r[2],N=r[6],F=r[10],G=r[14],V=r[3],D=r[7],Y=r[11],Z=r[15];return s[0]=o*w+a*k+l*L+c*V,s[4]=o*C+a*O+l*N+c*D,s[8]=o*E+a*U+l*F+c*Y,s[12]=o*T+a*z+l*G+c*Z,s[1]=u*w+h*k+d*L+f*V,s[5]=u*C+h*O+d*N+f*D,s[9]=u*E+h*U+d*F+f*Y,s[13]=u*T+h*z+d*G+f*Z,s[2]=p*w+g*k+y*L+m*V,s[6]=p*C+g*O+y*N+m*D,s[10]=p*E+g*U+y*F+m*Y,s[14]=p*T+g*z+y*G+m*Z,s[3]=v*w+x*k+_*L+b*V,s[7]=v*C+x*O+_*N+b*D,s[11]=v*E+x*U+_*F+b*Y,s[15]=v*T+x*z+_*G+b*Z,this},n.prototype.multiplyScalar=function(t){var e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this},n.prototype.determinant=function(){var t=this.elements,e=t[0],i=t[4],r=t[8],s=t[12],o=t[1],a=t[5],l=t[9],c=t[13],u=t[2],h=t[6],d=t[10],f=t[14],p=t[3],g=t[7],y=t[11],m=t[15];return p*(+s*l*h-r*c*h-s*a*d+i*c*d+r*a*f-i*l*f)+g*(+e*l*f-e*c*d+s*o*d-r*o*f+r*c*u-s*l*u)+y*(+e*c*h-e*a*f-s*o*h+i*o*f+s*a*u-i*c*u)+m*(-r*a*u-e*l*h+e*a*d+r*o*h-i*o*d+i*l*u)},n.prototype.transpose=function(){var t=this.elements,e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this},n.prototype.setPosition=function(t,e,i){var r=this.elements;return t instanceof _t?(r[12]=t.x,r[13]=t.y,r[14]=t.z):(r[12]=t,r[13]=e,r[14]=i),this},n.prototype.invert=function(){var t=this.elements,e=t[0],i=t[1],r=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=t[9],d=t[10],f=t[11],p=t[12],g=t[13],y=t[14],m=t[15],v=h*y*c-g*d*c+g*l*f-a*y*f-h*l*m+a*d*m,x=p*d*c-u*y*c-p*l*f+o*y*f+u*l*m-o*d*m,_=u*g*c-p*h*c+p*a*f-o*g*f-u*a*m+o*h*m,b=p*h*l-u*g*l-p*a*d+o*g*d+u*a*y-o*h*y,w=e*v+i*x+r*_+s*b;if(w===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);var C=1/w;return t[0]=v*C,t[1]=(g*d*s-h*y*s-g*r*f+i*y*f+h*r*m-i*d*m)*C,t[2]=(a*y*s-g*l*s+g*r*c-i*y*c-a*r*m+i*l*m)*C,t[3]=(h*l*s-a*d*s-h*r*c+i*d*c+a*r*f-i*l*f)*C,t[4]=x*C,t[5]=(u*y*s-p*d*s+p*r*f-e*y*f-u*r*m+e*d*m)*C,t[6]=(p*l*s-o*y*s-p*r*c+e*y*c+o*r*m-e*l*m)*C,t[7]=(o*d*s-u*l*s+u*r*c-e*d*c-o*r*f+e*l*f)*C,t[8]=_*C,t[9]=(p*h*s-u*g*s-p*i*f+e*g*f+u*i*m-e*h*m)*C,t[10]=(o*g*s-p*a*s+p*i*c-e*g*c-o*i*m+e*a*m)*C,t[11]=(u*a*s-o*h*s-u*i*c+e*h*c+o*i*f-e*a*f)*C,t[12]=b*C,t[13]=(u*g*r-p*h*r+p*i*d-e*g*d-u*i*y+e*h*y)*C,t[14]=(p*a*r-o*g*r-p*i*l+e*g*l+o*i*y-e*a*y)*C,t[15]=(o*h*r-u*a*r+u*i*l-e*h*l-o*i*d+e*a*d)*C,this},n.prototype.scale=function(t){var e=this.elements,i=t.x,r=t.y,s=t.z;return e[0]*=i,e[4]*=r,e[8]*=s,e[1]*=i,e[5]*=r,e[9]*=s,e[2]*=i,e[6]*=r,e[10]*=s,e[3]*=i,e[7]*=r,e[11]*=s,this},n.prototype.getMaxScaleOnAxis=function(){var t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],r=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,r))},n.prototype.makeTranslation=function(t,e,i){var r;return typeof t=="object"?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,(r=t.z)!==null&&r!==void 0?r:0,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this},n.prototype.makeRotationX=function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this},n.prototype.makeRotationY=function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this},n.prototype.makeRotationZ=function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this},n.prototype.makeRotationAxis=function(t,e){var i=Math.cos(e),r=Math.sin(e),s=1-i,o=t.x,a=t.y,l=t.z,c=s*o,u=s*a;return this.set(c*o+i,c*a-r*l,c*l+r*a,0,c*a+r*l,u*a+i,u*l-r*o,0,c*l-r*a,u*l+r*o,s*l*l+i,0,0,0,0,1),this},n.prototype.makeScale=function(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this},n.prototype.makeShear=function(t,e,i,r,s,o){return this.set(1,i,s,0,t,1,o,0,e,r,1,0,0,0,0,1),this},n.prototype.compose=function(t,e,i){var r=this.elements,s=e.x,o=e.y,a=e.z,l=e.w,c=s+s,u=o+o,h=a+a,d=s*c,f=s*u,p=s*h,g=o*u,y=o*h,m=a*h,v=l*c,x=l*u,_=l*h,b=i.x,w=i.y,C=i.z;return r[0]=(1-(g+m))*b,r[1]=(f+_)*b,r[2]=(p-x)*b,r[3]=0,r[4]=(f-_)*w,r[5]=(1-(d+m))*w,r[6]=(y+v)*w,r[7]=0,r[8]=(p+x)*C,r[9]=(y-v)*C,r[10]=(1-(d+g))*C,r[11]=0,r[12]=t.x,r[13]=t.y,r[14]=t.z,r[15]=1,this},n.prototype.decompose=function(t,e,i){var r=this.elements,s=go.set(r[0],r[1],r[2]).length(),o=go.set(r[4],r[5],r[6]).length(),a=go.set(r[8],r[9],r[10]).length(),l=this.determinant();l<0&&(s=-s),t.x=r[12],t.y=r[13],t.z=r[14],Hi.copy(this);var c=1/s,u=1/o,h=1/a;return Hi.elements[0]*=c,Hi.elements[1]*=c,Hi.elements[2]*=c,Hi.elements[4]*=u,Hi.elements[5]*=u,Hi.elements[6]*=u,Hi.elements[8]*=h,Hi.elements[9]*=h,Hi.elements[10]*=h,e.setFromRotationMatrix(Hi),i.x=s,i.y=o,i.z=a,this},n.prototype.equals=function(t){for(var e=this.elements,i=t.elements,r=0;r<16;r++)if(e[r]!==i[r])return!1;return!0},n.prototype.fromArray=function(t,e){e===void 0&&(e=0);for(var i=0;i<16;i++)this.elements[i]=t[i+e];return this},n.prototype.toArray=function(t,e){t===void 0&&(t=[]),e===void 0&&(e=0);var i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t},n.IDENTITY=Object.freeze(new n),n})(),go=new _t,Hi=new Ya,oE=new _t(0,0,0),aE=new _t(1,1,1),ss=new _t,xc=new _t,ui=new _t,Rs=(function(){function n(t,e){t===void 0&&(t=void 0),e===void 0&&(e=void 0),this.min=t==null?new _t(1/0,1/0,1/0):new _t(t.x,t.y,t.z),this.max=e==null?new _t(-1/0,-1/0,-1/0):new _t(e.x,e.y,e.z)}return n.prototype.set=function(t,e){return this.min.copy(t),this.max.copy(e),this},n.prototype.setFromArray=function(t){this.makeEmpty();for(var e=0,i=t.length;e<i;e+=3)this.expandByPoint(Nd.fromArray(t,e));return this},n.prototype.setFromPoints=function(t){this.makeEmpty();for(var e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this},n.prototype.setFromCenterAndSize=function(t,e){var i=Nd.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this},n.prototype.clone=function(){return new n().copy(this)},n.prototype.copy=function(t){return this.min.copy(t.min),this.max.copy(t.max),this},n.prototype.makeEmpty=function(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this},n.prototype.isEmpty=function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},n.prototype.getCenter=function(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)},n.prototype.getSize=function(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)},Object.defineProperty(n.prototype,"center",{get:function(){return this.isEmpty()?new _t(0,0,0):new _t(0,0,0).addVectors(this.min,this.max).multiplyScalar(.5)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"size",{get:function(){return this.isEmpty()?new _t(0,0,0):new _t(0,0,0).subVectors(this.max,this.min)},enumerable:!1,configurable:!0}),n.prototype.expandByPoint=function(t){return!Number.isFinite(t.x)||!Number.isFinite(t.y)||!Number.isFinite(t.z)?this:(this.min.min(t),this.max.max(t),this)},n.prototype.expandByVector=function(t){return this.min.sub(t),this.max.add(t),this},n.prototype.expandByScalar=function(t){return this.min.addScalar(-t),this.max.addScalar(t),this},n.prototype.containsPoint=function(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)},n.prototype.containsBox=function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z},n.prototype.getParameter=function(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))},n.prototype.intersectsBox=function(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)},n.prototype.intersectsPlane=function(t){var e,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=-t.constant&&i>=-t.constant},n.prototype.clampPoint=function(t,e){return e.copy(t).clamp(this.min,this.max)},n.prototype.distanceToPoint=function(t){return this.clampPoint(t,Nd).distanceTo(t)},n.prototype.intersect=function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},n.prototype.union=function(t){return this.min.min(t.min),this.max.max(t.max),this},n.prototype.applyMatrix4=function(t){return this.isEmpty()?this:(Ir[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Ir[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Ir[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Ir[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Ir[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Ir[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Ir[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Ir[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Ir),this)},n.prototype.translate=function(t){return this.min.add(t),this.max.add(t),this},n.prototype.equals=function(t){return t.min.equals(this.min)&&t.max.equals(this.max)},n})(),Ir=[new _t,new _t,new _t,new _t,new _t,new _t,new _t,new _t],Nd=new _t,t0=new mn,Dd=(function(){function n(t,e){t===void 0&&(t=void 0),e===void 0&&(e=void 0),this.min=t==null?new mn(1/0,1/0):new mn(t.x,t.y),this.max=e==null?new mn(-1/0,-1/0):new mn(e.x,e.y)}return n.prototype.set=function(t,e){return this.min.copy(t),this.max.copy(e),this},n.prototype.setFromPoints=function(t){this.makeEmpty();for(var e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this},n.prototype.setFromCenterAndSize=function(t,e){var i=t0.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this},n.prototype.clone=function(){return new n().copy(this)},n.prototype.copy=function(t){return this.min.copy(t.min),this.max.copy(t.max),this},n.prototype.makeEmpty=function(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this},n.prototype.isEmpty=function(){return this.max.x<this.min.x||this.max.y<this.min.y},n.prototype.getCenter=function(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)},n.prototype.getSize=function(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)},Object.defineProperty(n.prototype,"center",{get:function(){return this.isEmpty()?new mn(0,0):new mn(0,0).addVectors(this.min,this.max).multiplyScalar(.5)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"size",{get:function(){return this.isEmpty()?new mn(0,0):new mn(0,0).subVectors(this.max,this.min)},enumerable:!1,configurable:!0}),n.prototype.expandByPoint=function(t){return!Number.isFinite(t.x)||!Number.isFinite(t.y)?this:(this.min.min(t),this.max.max(t),this)},n.prototype.expandByVector=function(t){return this.min.sub(t),this.max.add(t),this},n.prototype.expandByScalar=function(t){return this.min.addScalar(-t),this.max.addScalar(t),this},n.prototype.containsPoint=function(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)},n.prototype.containsBox=function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y},n.prototype.getParameter=function(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))},n.prototype.intersectsBox=function(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)},n.prototype.clampPoint=function(t,e){return e.copy(t).clamp(this.min,this.max)},n.prototype.distanceToPoint=function(t){return this.clampPoint(t,t0).distanceTo(t)},n.prototype.intersect=function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},n.prototype.union=function(t){return this.min.min(t.min),this.max.max(t.max),this},n.prototype.translate=function(t){return this.min.add(t),this.max.add(t),this},n.prototype.equals=function(t){return t.min.equals(this.min)&&t.max.equals(this.max)},n})(),e0=new _t,lE=new _t,cE=new kd,Ud=(function(){function n(t,e){t===void 0&&(t=new _t(1,0,0)),e===void 0&&(e=0),this.normal=t,this.constant=e}return n.prototype.set=function(t,e){return this.normal.copy(t),this.constant=e,this},n.prototype.setComponents=function(t,e,i,r){return this.normal.set(t,e,i),this.constant=r,this},n.prototype.setFromNormalAndCoplanarPoint=function(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this},n.prototype.setFromCoplanarPoints=function(t,e,i){var r=e0.subVectors(i,e).cross(lE.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(r,t),this},n.prototype.copy=function(t){return this.normal.copy(t.normal),this.constant=t.constant,this},n.prototype.normalize=function(){var t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this},n.prototype.negate=function(){return this.constant*=-1,this.normal.negate(),this},n.prototype.distanceToPoint=function(t){return this.normal.dot(t)+this.constant},n.prototype.projectPoint=function(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))},n.prototype.intersectsBox=function(t){return t.intersectsPlane(this)},n.prototype.coplanarPoint=function(t){return t.copy(this.normal).multiplyScalar(-this.constant)},n.prototype.applyMatrix4=function(t,e){var i=e||cE.getNormalMatrix(t),r=this.coplanarPoint(e0).applyMatrix4(t),s=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(s),this},n.prototype.translate=function(t){return this.constant-=t.dot(this.normal),this},n.prototype.equals=function(t){return t.normal.equals(this.normal)&&t.constant===this.constant},n.prototype.clone=function(){return new n().copy(this)},n})(),uE=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),Ie=(function(n){uE(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.clone=function(){return new t(this.x,this.y)},t.pointArrayToNumberArray=function(e){var i=new Array(e.length*2);return e.forEach(function(r,s){r.toArray(i,s*2)}),i},t})(mn),hE=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),Be=(function(n){hE(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.clone=function(){return new t(this.x,this.y,this.z)},t.pointArrayToNumberArray=function(e,i){i===void 0&&(i=!0);var r=i?3:2,s=new Array(e.length*r);return e.forEach(function(o,a){o.toArray(s,a*r)}),s},t})(_t),yo=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},qa=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},bc=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))};function dE(n,t){t===void 0&&(t="Uniform");var e=n.length;if(e===0)return[];if(e===1)return[0];var i=e-1;if(t==="Uniform")return new Array(e).fill(0).map(function(d,f){return f/i});for(var r=[0],s=0,o=1;o<=i;o++){var a=n[o][0]-n[o-1][0],l=n[o][1]-n[o-1][1],c=n[o][2]-n[o-1][2],u=Math.sqrt(a*a+l*l+c*c),h=t==="SqrtChord"?Math.sqrt(u):u;s+=h,r.push(s)}return s<1e-12?new Array(e).fill(0).map(function(d,f){return f/i}):r.map(function(d){return d/s})}function fE(n,t){for(var e=t.length-1,i=n,r=e+i+1,s=new Array(r+1).fill(0),o=t[t.length-1],a=r-i;a<=r;a++)s[a]=o;for(var l=1;l<=e-i;l++){for(var c=0,a=l;a<l+i;a++)c+=t[a];s[l+i]=c/i}return s}function Sc(n,t){var e,i;try{for(var r=yo(n),s=r.next();!s.done;s=r.next()){var o=s.value;if(o.col===t)return o.value}}catch(a){e={error:a}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(e)throw e.error}}return 0}function n0(n,t){for(var e=0;e<n.length;e++)if(n[e].col===t)return e;return-1}function pE(n,t){for(var e,i,r,s,o,a,l,c,u,h,d=n.length,f=n.map(function(Xt){return Xt.map(function(it){return{col:it.col,value:it.value}})}),p=t.map(function(Xt){return Xt.slice()}),g=0;g<d;g++){for(var y=-1,m=1e-12,v=g;v<d;v++){var x=Math.abs(Sc(f[v],g));x>m&&(m=x,y=v)}if(y<0)throw new Error("Interpolation matrix is singular.");if(y!==g){var _=f[g];f[g]=f[y],f[y]=_;try{for(var b=(e=void 0,yo(p)),w=b.next();!w.done;w=b.next()){var C=w.value,E=C[g];C[g]=C[y],C[y]=E}}catch(Xt){e={error:Xt}}finally{try{w&&!w.done&&(i=b.return)&&i.call(b)}finally{if(e)throw e.error}}}for(var T=Sc(f[g],g),v=g+1;v<d;v++){var k=n0(f[v],g);if(!(k<0)){var O=f[v][k].value/T;if(!(Math.abs(O)<1e-14)){try{for(var U=(r=void 0,yo(f[v])),z=U.next();!z.done;z=U.next()){var L=z.value;L.col>g&&(L.value-=O*Sc(f[g],L.col))}}catch(it){r={error:it}}finally{try{z&&!z.done&&(s=U.return)&&s.call(U)}finally{if(r)throw r.error}}try{for(var N=(o=void 0,yo(f[g])),F=N.next();!F.done;F=N.next()){var G=F.value;G.col<=g||G.value===0||n0(f[v],G.col)<0&&f[v].push({col:G.col,value:-O*G.value})}}catch(it){o={error:it}}finally{try{F&&!F.done&&(a=N.return)&&a.call(N)}finally{if(o)throw o.error}}f[v][k].value=0;try{for(var V=(l=void 0,yo(p)),D=V.next();!D.done;D=V.next()){var C=D.value;C[v]-=O*C[g]}}catch(it){l={error:it}}finally{try{D&&!D.done&&(c=V.return)&&c.call(V)}finally{if(l)throw l.error}}}}}}for(var Y=p.map(function(){return new Array(d).fill(0)}),v=d-1;v>=0;v--)for(var Z=Sc(f[v],v),ft=0;ft<p.length;ft++){var gt=p[ft][v];try{for(var qt=(u=void 0,yo(f[v])),Vt=qt.next();!Vt.done;Vt=qt.next()){var L=Vt.value;L.col>v&&(gt-=L.value*Y[ft][L.col])}}catch(it){u={error:it}}finally{try{Vt&&!Vt.done&&(h=qt.return)&&h.call(qt)}finally{if(u)throw u.error}}Y[ft][v]=gt/Z}return Y}function mE(n,t,e){var i=e.length-t-2;if(n>=e[i+1])return i;for(var r=t,s=e.length-t-2;r<=s;){var o=r+s>>1;if(n<e[o])s=o-1;else if(n>=e[o+1])r=o+1;else return o}return t}function gE(n,t,e,i,r){var s,o,a,l,c,u;if(e===void 0&&(e="Uniform"),n.length===0)return{controlPoints:[],knots:[],weights:[]};var h=n.map(function(Vt){var Xt;return[Vt[0],Vt[1],(Xt=Vt[2])!==null&&Xt!==void 0?Xt:0]}),d=!!i,f=!!r,p=(d?1:0)+(f?1:0),g=h.length-1,y=g+p;if(y<t)throw new Error("Not enough points to interpolate a curve of this degree.");var m=dE(h,e),v=m.slice();d&&v.unshift(m[0]),f&&v.push(m[m.length-1]);var x=fE(t,v),_=y+1,b=[],w=[],C=[],E=[];if(d){var T=x[t+1]-x[0],k=T!==0?t/T:0;b.push([{col:0,value:-k},{col:1,value:k}]),w.push((s=i==null?void 0:i[0])!==null&&s!==void 0?s:0),C.push((o=i==null?void 0:i[1])!==null&&o!==void 0?o:0),E.push((a=i==null?void 0:i[2])!==null&&a!==void 0?a:0)}b.push([{col:0,value:1}]),w.push(h[0][0]),C.push(h[0][1]),E.push(h[0][2]);for(var O=1;O<=g-1;O++){for(var U=m[O],z=[],L=mE(U,t,x),N=Math.max(0,L-t),F=Math.min(y,L),G=N;G<=F;G++){var V=ks(G,t,U,x);V!==0&&z.push({col:G,value:V})}b.push(z),w.push(h[O][0]),C.push(h[O][1]),E.push(h[O][2])}if(b.push([{col:y,value:1}]),w.push(h[g][0]),C.push(h[g][1]),E.push(h[g][2]),f){var T=x[y+t+1]-x[y],k=T!==0?t/T:0;b.push([{col:y-1,value:-k},{col:y,value:k}]),w.push((l=r==null?void 0:r[0])!==null&&l!==void 0?l:0),C.push((c=r==null?void 0:r[1])!==null&&c!==void 0?c:0),E.push((u=r==null?void 0:r[2])!==null&&u!==void 0?u:0)}for(var D=qa(pE(b,[w,C,E]),3),Y=D[0],Z=D[1],ft=D[2],gt=new Array(_),O=0;O<_;O++)gt[O]=[Y[O],Z[O],ft[O]];var qt=new Array(_).fill(1);return{controlPoints:gt,knots:x,weights:qt}}function ks(n,t,e,i){if(t===0)return e>=i[n]&&e<i[n+1]?1:0;var r=i[n+t]-i[n],s=i[n+t+1]-i[n+1],o=r>1e-10?(e-i[n])/r:0,a=s>1e-10?(i[n+t+1]-e)/s:0;return o*ks(n,t-1,e,i)+a*ks(n+1,t-1,e,i)}function wc(n,t,e,i,r){var s=i.length-1,o=t;if(n=Math.max(e[o],Math.min(e[s+1],n)),Math.abs(n-e[s+1])<1e-8)return bc([],qa(i[s]),!1);if(Math.abs(n-e[o])<1e-8)return bc([],qa(i[0]),!1);for(var a=[0,0,0],l=0,c=0;c<=s;c++){var u=ks(c,o,n,e),h=r[c]*u;a[0]+=i[c][0]*h,a[1]+=i[c][1]*h,a[2]+=i[c][2]*h,l+=h}if(Math.abs(l)<1e-10){var d=e[e.length-o-1];if(Math.abs(n-d)<1e-8)return bc([],qa(i[s]),!1);if(Math.abs(n-e[o])<1e-8)return bc([],qa(i[0]),!1)}return Math.abs(l)>=1e-10&&(a[0]/=l,a[1]/=l,a[2]/=l),a}function zd(n,t,e,i){if(t===0)return 0;var r=i[n+t]-i[n],s=i[n+t+1]-i[n+1],o=0;return r>1e-10&&(o+=t/r*ks(n,t-1,e,i)),s>1e-10&&(o-=t/s*ks(n+1,t-1,e,i)),o}function yE(n,t,e,i){if(t<=1)return 0;var r=i[n+t]-i[n],s=i[n+t+1]-i[n+1],o=0;return r>1e-10&&(o+=t/r*zd(n,t-1,e,i)),s>1e-10&&(o-=t/s*zd(n+1,t-1,e,i)),o}function vE(n,t,e,i,r){var s=i.length-1,o=t,a=e[o],l=e[s+1];n=Math.max(a,Math.min(l,n));for(var c=[0,0,0],u=[0,0,0],h=[0,0,0],d=0,f=0,p=0,g=0;g<=s;g++){var y=ks(g,o,n,e),m=zd(g,o,n,e),v=yE(g,o,n,e),x=r[g],_=x*y,b=x*m,w=x*v,C=i[g];c[0]+=_*C[0],c[1]+=_*C[1],c[2]+=_*C[2],u[0]+=b*C[0],u[1]+=b*C[1],u[2]+=b*C[2],h[0]+=w*C[0],h[1]+=w*C[1],h[2]+=w*C[2],d+=_,f+=b,p+=w}if(Math.abs(d)<1e-10){var E=wc(n,t,e,i,r);return{point:E,deriv1:[0,0,0],deriv2:[0,0,0]}}var T=d*d,k=[c[0]/d,c[1]/d,c[2]/d],O=[(u[0]*d-c[0]*f)/T,(u[1]*d-c[1]*f)/T,(u[2]*d-c[2]*f)/T],U=h[0]*d-c[0]*p,z=h[1]*d-c[1]*p,L=h[2]*d-c[2]*p,N=[U/T-2*f*O[0]/d,z/T-2*f*O[1]/d,L/T-2*f*O[2]/d];return{point:k,deriv1:O,deriv2:N}}function _E(n,t){var e=n[0],i=n[1],r=t[0],s=t[1],o=e*e+i*i;return o<1e-20?0:(e*s-i*r)/Math.pow(o,1.5)}function xE(n,t,e,i){for(var r=n,s=t[r],o=t[t.length-r-1],a=0,l=1e3,c=(o-s)/l,u=wc(s,n,t,e,i),h=1;h<=l;h++){var d=s+h*c,f=wc(d,n,t,e,i),p=f[0]-u[0],g=f[1]-u[1],y=f[2]-u[2];a+=Math.sqrt(p*p+g*g+y*y),u=f}var m=wc(o,n,t,e,i),v=m[0]-u[0],x=m[1]-u[1],_=m[2]-u[2];return a+=Math.sqrt(v*v+x*x+_*_),a}function Fd(n,t,e){var i=n.x,r=n.y,s=t.x,o=t.y,a=e.x,l=e.y,c=2*(i*(o-l)+s*(l-r)+a*(r-o));if(Ae.equalToZero(c))return null;var u=((i*i+r*r)*(o-l)+(s*s+o*o)*(l-r)+(a*a+l*l)*(r-o))/c,h=((i*i+r*r)*(a-s)+(s*s+o*o)*(i-a)+(a*a+l*l)*(s-i))/c,d=Math.hypot(u-i,h-r);return!Number.isFinite(d)||Ae.isNonPositive(d)?null:{center:new Ie(u,h),radius:d}}function i0(n,t,e){var i,r,s,o=n.x,a=n.y,l=(i=n.z)!==null&&i!==void 0?i:0,c=new _t(t.x-o,t.y-a,((r=t.z)!==null&&r!==void 0?r:0)-l),u=new _t(e.x-o,e.y-a,((s=e.z)!==null&&s!==void 0?s:0)-l),h=new _t().crossVectors(c,u),d=h.lengthSq();if(d<Oe*Oe)return null;var f=c.lengthSq(),p=u.lengthSq(),g=new _t().crossVectors(h,c).multiplyScalar(p).add(new _t().crossVectors(u,h).multiplyScalar(f)).multiplyScalar(1/(2*d)),y=new Be(o+g.x,a+g.y,l+g.z),m=Math.hypot(y.x-o,y.y-a,y.z-l);return!Number.isFinite(m)||Ae.isNonPositive(m)?null:{center:y,radius:m}}function os(n,t){return Math.atan2(t.y-n.y,t.x-n.x)}function nr(n,t){return Math.hypot(t.x-n.x,t.y-n.y)}function r0(n,t,e){if(Ae.isNonPositive(t))return null;var i=e.x-n.x,r=e.y-n.y,s=Math.hypot(i,r);if(Ae.isNonPositive(s))return null;var o=t/s;return new Ie(n.x+i*o,n.y+r*o)}var bE=1e-8;function SE(n,t,e,i){var r=Math.abs(nr(n,t)-e);return r<=(i??Math.max(Oe,e*1e-5))}function wE(n,t,e,i,r){return r===void 0&&(r=bE),Math.abs(n.x-e.x)<=r&&Math.abs(n.y-e.y)<=r&&Math.abs(t-i)<=r}function ME(n,t,e,i){var r=Math.max(1e-18,Math.abs(e)*1e-9);return n<e-r?!0:n>e+r?!1:t>i}function s0(n,t,e,i){i===void 0&&(i=!1);var r=Fd(n,t,e);if(!r)return null;var s=os(r.center,n),o=os(r.center,t),a=os(r.center,e),l=!ne.isAngleOnCcwSweep(s,o,a);return i&&(l=!l),fn.fromMathAngles(r.center,r.radius,s,a,l)}function Hd(n,t){return!Number.isFinite(t)||Ae.isNonPositive(t)?null:new fn(n,t,0,ue,!1)}function EE(n,t){var e=nr(n,t);return Ae.isNonPositive(e)?null:Hd({x:(n.x+t.x)/2,y:(n.y+t.y)/2},e/2)}function AE(n,t,e){var i=Fd(n,t,e);return i?Hd(i.center,i.radius):null}function CE(n,t,e){var i=nr(e,n);if(Ae.isNonPositive(i))return null;var r=os(e,n),s=os(e,t),o=ne.normalizeAngle(s-r);return fn.fromMathAngles(e,i,r,s,o>Math.PI)}function Ka(n,t,e,i){var r=nr(n,t),s=nr(n,e);if(Ae.isNonPositive(r)||Ae.isNonPositive(s))return null;var o=Math.max(Oe,r*Oe);return Math.abs(r-s)>o?null:fn.fromMathAngles(n,r,os(n,t),os(n,e),i)}function TE(n,t,e,i){var r=nr(n,t);if(Ae.isNonPositive(r))return null;var s=r0(n,r,e);return s?Ka(n,t,s,i):null}function o0(n,t,e){var i=nr(n,t),r=Math.abs(e);if(Ae.isNonPositive(i)||Ae.isNonPositive(r)||!Ae.great(ue-r,0))return null;var s=e<0,o=os(n,t),a=s?o-r:o+r;return fn.fromMathAngles(n,i,o,a,s)}function LE(n,t,e){var i=nr(n,t),r=Math.abs(e);if(Ae.isNonPositive(i)||Ae.isNonPositive(r)||Ae.great(r,2*i))return null;var s=Math.max(-1,Math.min(1,r/(2*i))),o=2*Math.asin(s);return o0(n,t,e>=0?o:-o)}function IE(n,t,e){var i=nr(n,t),r=Math.abs(e);if(Ae.isNonPositive(i)||Ae.isNonPositive(r)||!Ae.great(ue-r,0))return null;var s=Math.sin(r/2);if(Ae.equalToZero(s))return null;var o=i/(2*s),a=o*o-i*i/4;if(Ae.less(a,0))return null;var l=Math.sqrt(Math.max(0,a)),c=(n.x+t.x)/2,u=(n.y+t.y)/2,h=t.x-n.x,d=t.y-n.y,f=-d/i,p=h/i,g=e>=0,y=g&&r<=Math.PI||!g&&r>Math.PI,m=y?1:-1,v={x:c+f*l*m,y:u+p*l*m};return Ka(v,n,t,!g)}function PE(n,t,e){var i=Math.cos(e),r=Math.sin(e),s=t.x-n.x,o=t.y-n.y,a=-r,l=i,c=2*(s*a+o*l);if(Ae.equalToZero(c))return null;var u=(s*s+o*o)/c;if(!Number.isFinite(u))return null;var h={x:n.x+a*u,y:n.y+l*u},d=n.x-h.x,f=n.y-h.y,p=d*r-f*i;return Ae.equalToZero(p)?null:Ka(h,n,t,p<0)}function RE(n,t,e){var i=Math.abs(e),r=nr(n,t);if(Ae.isNonPositive(i)||Ae.isNonPositive(r)||Ae.great(r,2*i))return null;var s=(n.x+t.x)/2,o=(n.y+t.y)/2,a=t.x-n.x,l=t.y-n.y,c=-l/r,u=a/r,h=Math.sqrt(Math.max(0,i*i-r*r/4)),d=e>=0?1:-1,f={x:s+c*h*d,y:o+u*h*d};return Ka(f,n,t,e<0)}var a0=(function(){function n(){this._boundingBoxNeedsUpdate=!1}return Object.defineProperty(n.prototype,"boundingBoxNeedUpdate",{get:function(){return this._boundingBoxNeedsUpdate},enumerable:!1,configurable:!0}),n})(),kE=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),OE=(function(n){kE(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.translate=function(e){return this.transform(new kd().makeTranslation(e.x,e.y))},Object.defineProperty(t.prototype,"box",{get:function(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box},enumerable:!1,configurable:!0}),t})(a0),BE=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),Gd=(function(n){BE(t,n);function t(){var e=n.call(this)||this;return e.arcLengthDivisions=100,e}return Object.defineProperty(t.prototype,"startPoint",{get:function(){return this.getPoint(0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){return this.getPoint(1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){return this.getLength()},enumerable:!1,configurable:!0}),t.prototype.getPoint=function(e){throw new Error("AcGeCurve2d: .getPoint() not implemented.")},t.prototype.getPointAt=function(e){var i=this.getUtoTmapping(e);return this.getPoint(i)},t.prototype.getPoints=function(e){e===void 0&&(e=5);for(var i=[],r=0;r<=e;r++)i.push(this.getPoint(r/e));return i},t.prototype.getSpacedPoints=function(e){e===void 0&&(e=5);for(var i=[],r=0;r<=e;r++)i.push(this.getPointAt(r/e));return i},t.prototype.getLength=function(){var e=this.getLengths();return e[e.length-1]},t.prototype.getLengths=function(e){e===void 0&&(e=this.arcLengthDivisions);var i=[],r,s=this.getPoint(0),o=0;i.push(0);for(var a=1;a<=e;a++)r=this.getPoint(a/e),o+=r.distanceTo(s),i.push(o),s=r;return i},t.prototype.getUtoTmapping=function(e,i){var r=this.getLengths(),s=0,o=r.length,a;i?a=i:a=e*r[o-1];for(var l=0,c=o-1,u;l<=c;)if(s=Math.floor(l+(c-l)/2),u=r[s]-a,u<0)l=s+1;else if(u>0)c=s-1;else{c=s;break}if(s=c,r[s]===a)return s/(o-1);var h=r[s],d=r[s+1],f=d-h,p=(a-h)/f,g=(s+p)/(o-1);return g},t.prototype.getTangent=function(e){var i=1e-4,r=e-i,s=e+i;r<0&&(r=0),s>1&&(s=1);var o=this.getPoint(r),a=this.getPoint(s),l=new Ie;return l.copy(a).sub(o).normalize(),l},t.prototype.getTangentAt=function(e){var i=this.getUtoTmapping(e);return this.getTangent(i)},t})(OE),NE=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),Mc=function(){return Mc=Object.assign||function(n){for(var t,e=1,i=arguments.length;e<i;e++){t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},Mc.apply(this,arguments)},Ec=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Ac=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},Cc=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))},fn=(function(n){NE(t,n);function t(e,i,r,s,o){var a=n.call(this)||this,l=+(e!==void 0)+ +(i!==void 0)+ +(r!==void 0)+ +(s!==void 0)+ +(o!==void 0);if(l==3)typeof e=="object"&&typeof i=="object"&&typeof r=="object"?a.createByThreePoints(e,i,r):a.createByStartEndPointsAndBulge(e,i,r);else if(l==5){var c=e;a.center=new Ie(c.x,c.y),a.radius=i,a._clockwise=o,a._startAngle=a._clockwise?a._mirrorAngle(ne.normalizeAngle(r)):ne.normalizeAngle(r),a._endAngle=a._clockwise?a._mirrorAngle(ne.normalizeAngle(s)):ne.normalizeAngle(s)}else throw Lr.ILLEGAL_PARAMETERS;return a}return t.fromMathAngles=function(e,i,r,s,o){var a=new t(e,i,ne.normalizeAngle(r),ne.normalizeAngle(s),!1);return a._clockwise=o,a._boundingBoxNeedsUpdate=!0,a},t.computeCircumcircle=function(e,i,r){return Fd(e,i,r)},t.projectPoint=function(e,i,r){return r0(e,i,r)},t.pointLiesOnCircle=function(e,i,r,s){return SE(e,i,r,s)},t.sameCircle=function(e,i,r,s,o){return wE(e,i,r,s,o)},t.isBetterDistanceAlign=function(e,i,r,s){return ME(e,i,r,s)},t.tryCreateByThreePoints=function(e,i,r,s){return s===void 0&&(s=!1),s0(e,i,r,s)},t.tryCreateCircle=function(e,i){return Hd(e,i)},t.tryCreateCircleByDiameter=function(e,i){return EE(e,i)},t.tryCreateCircleByThreePoints=function(e,i,r){return AE(e,i,r)},t.tryCreateShorterArc=function(e,i,r){return CE(e,i,r)},t.tryCreateByCenterStartEnd=function(e,i,r,s){return Ka(e,i,r,s)},t.tryCreateByCenterStartProjectedEnd=function(e,i,r,s){return TE(e,i,r,s)},t.tryCreateByCenterStartSweep=function(e,i,r){return o0(e,i,r)},t.tryCreateByCenterStartChord=function(e,i,r){return LE(e,i,r)},t.tryCreateByStartEndAngle=function(e,i,r){return IE(e,i,r)},t.tryCreateByStartEndDirection=function(e,i,r){return PE(e,i,r)},t.tryCreateByStartEndRadius=function(e,i,r){return RE(e,i,r)},t.prototype.createByThreePoints=function(e,i,r){var s=s0(e,i,r);if(!s)throw Lr.ILLEGAL_PARAMETERS;this.center=s.center,this.radius=s.radius,this._clockwise=s._clockwise,this._startAngle=s._startAngle,this._endAngle=s._endAngle,this._boundingBoxNeedsUpdate=!0},t.prototype.createByStartEndPointsAndBulge=function(e,i,r){var s,o,a;r<0?(s=Math.atan(-r)*4,o=new mn(e),a=new mn(i)):(s=Math.atan(r)*4,o=new mn(i),a=new mn(e));var l=new mn().subVectors(a,o),c=l.length(),u=new mn().addVectors(o,l.multiplyScalar(.5)),h=Math.abs(c/2/Math.tan(s/2)),d=l.normalize(),f=r<0?-Math.PI/2:Math.PI/2,p=new mn(d.x*Math.cos(f)-d.y*Math.sin(f),d.y*Math.cos(f)+d.x*Math.sin(f)),g;s<Math.PI?r<0?g=u.add(p.multiplyScalar(h)):g=u.add(p.multiplyScalar(-h)):r<0?g=u.add(p.multiplyScalar(-h)):g=u.add(p.multiplyScalar(h)),r<0?(this._startAngle=Math.atan2(o.y-g.y,o.x-g.x),this._endAngle=Math.atan2(a.y-g.y,a.x-g.x)):(this._startAngle=Math.atan2(a.y-g.y,a.x-g.x),this._endAngle=Math.atan2(o.y-g.y,o.x-g.x)),this._clockwise=r<0,this.center=g,this.radius=a.sub(g).length()},Object.defineProperty(t.prototype,"center",{get:function(){return this._center},set:function(e){this._center=new Ie(e.x,e.y),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"radius",{get:function(){return this._radius},set:function(e){this._radius=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startAngle",{get:function(){return this._clockwise?this._mirrorAngle(this._startAngle):this._startAngle},set:function(e){this._startAngle=this._clockwise?this._mirrorAngle(ne.normalizeAngle(e)):ne.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endAngle",{get:function(){return this._clockwise?this._mirrorAngle(this._endAngle):this._endAngle},set:function(e){var i=this.startAngle==0&&e==ue?e:ne.normalizeAngle(e);this._endAngle=this._clockwise?this._mirrorAngle(i):i,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),t.prototype._mirrorAngle=function(e){var i=e*180/Math.PI,r=(360-i)%360;return r*Math.PI/180},t.prototype._getInternalAngle=function(e){return this._clockwise?this._mirrorAngle(e):e},Object.defineProperty(t.prototype,"deltaAngle",{get:function(){var e=this._getInternalAngle(this.startAngle),i=this._getInternalAngle(this.endAngle);return this.clockwise?ne.normalizeAngle(e-i):ne.normalizeAngle(i-e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"clockwise",{get:function(){return this._clockwise},set:function(e){this._clockwise=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startPoint",{get:function(){return this.getPointAtAngle(this.startAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){return this.getPointAtAngle(this.endAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"midPoint",{get:function(){var e=this._getInternalAngle(this.startAngle),i=this._clockwise?ne.normalizeAngle(e-this.deltaAngle/2):ne.normalizeAngle(e+this.deltaAngle/2),r=this._clockwise?this._mirrorAngle(i):i;return this.getPointAtAngle(r)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"closed",{get:function(){var e=this._getInternalAngle(this.startAngle),i=this._getInternalAngle(this.endAngle);return Math.abs(i-e)/Math.PI%2==0},enumerable:!1,configurable:!0}),t.prototype.calculateBoundingBox=function(){var e,i,r=[this.startPoint,this.endPoint],s=[0,Math.PI/2,Math.PI,3*Math.PI/2];try{for(var o=Ec(s),a=o.next();!a.done;a=o.next()){var l=a.value,c=this._getInternalAngle(l);ne.isBetweenAngle(c,this._getInternalAngle(this.startAngle),this._getInternalAngle(this.endAngle),this.clockwise)&&r.push(this.getPointAtAngle(l))}}catch(d){e={error:d}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(e)throw e.error}}var u=r.map(function(d){return d.x}),h=r.map(function(d){return d.y});return new Dd(new Ie(Math.min.apply(Math,Cc([],Ac(u),!1)),Math.min.apply(Math,Cc([],Ac(h),!1))),new Ie(Math.max.apply(Math,Cc([],Ac(u),!1)),Math.max.apply(Math,Cc([],Ac(h),!1))))},Object.defineProperty(t.prototype,"length",{get:function(){return Math.abs(this.deltaAngle*this.radius)},enumerable:!1,configurable:!0}),t.prototype.transform=function(e){var i=this,r=e,s=this.center.clone().applyMatrix2d(r),o=this.startPoint.clone().applyMatrix2d(r);if(this.closed)return this.center=s,this.radius=s.distanceTo(o),this._startAngle=Math.atan2(o.y-s.y,o.x-s.x),this._endAngle=this._startAngle,this._clockwise=r.determinant()<0?!this._clockwise:this._clockwise,this._boundingBoxNeedsUpdate=!0,this;var a=this.midPoint.clone().applyMatrix2d(r),l=this.endPoint.clone().applyMatrix2d(r),c=new t(o,a,l),u=r.determinant()<0?!this.clockwise:this.clockwise,h=function(d){var f=ne.normalizeAngle(d);return u?i._mirrorAngle(f):f};return this.center=c.center,this.radius=c.radius,this.clockwise=u,this.startAngle=h(Math.atan2(o.y-c.center.y,o.x-c.center.x)),this.endAngle=h(Math.atan2(l.y-c.center.y,l.x-c.center.x)),this._boundingBoxNeedsUpdate=!0,this},t.prototype.clone=function(){return new t(this.center.clone(),this.radius,this._startAngle,this._endAngle,this.clockwise)},t.prototype.getPointAtAngle=function(e){var i=this._getInternalAngle(e),r=this.center.x+this.radius*Math.cos(i),s=this.center.y+this.radius*Math.sin(i);return new Ie(r,s)},t.prototype.getQuadrantPoints=function(){var e,i,r=[],s=this._getInternalAngle(this.startAngle),o=this._getInternalAngle(this.endAngle),a=[0,Math.PI/2,Math.PI,3*Math.PI/2];try{for(var l=Ec(a),c=l.next();!c.done;c=l.next()){var u=c.value,h=this._getInternalAngle(u);ne.isBetweenAngle(h,s,o,this.clockwise)&&r.push(this.getPointAtAngle(u))}}catch(d){e={error:d}}finally{try{c&&!c.done&&(i=l.return)&&i.call(l)}finally{if(e)throw e.error}}return r},t.prototype.nearestPoint=function(e){var i=new Ie(e.x,e.y),r=i.x-this.center.x,s=i.y-this.center.y,o=Math.hypot(r,s);if(o<1e-12)return this.startPoint.clone();var a=Math.atan2(s,r),l=this.clockwise?this._mirrorAngle(ne.normalizeAngle(a)):ne.normalizeAngle(a),c=this._getInternalAngle(l),u=this._getInternalAngle(this.startAngle),h=this._getInternalAngle(this.endAngle);if(ne.isBetweenAngle(c,u,h,this.clockwise))return this.getPointAtAngle(l);var d=i.distanceToSquared(this.startPoint),f=i.distanceToSquared(this.endPoint);return d<=f?this.startPoint.clone():this.endPoint.clone()},t.prototype.inwardAlignment=function(e,i){var r=i.x-e.x,s=i.y-e.y;if(r*r+s*s<1e-24)return 0;var o=this.radius>0?this.radius:1,a=Math.max(1e-16,1e-12*o*o),l=this.startPoint.distanceToSquared(e)<=a,c=this.endPoint.distanceToSquared(e)<=a;if(!l&&!c)return 0;var u=this.getPoints(8);if(u.length<3)return 0;var h=l&&!c?u[1]:u[u.length-2],d=h.x-e.x,f=h.y-e.y,p=Math.hypot(d,f);return p>1e-18?(r*d+s*f)/p:0},t.prototype.perpendicularPoints=function(e){var i,r,s=new Ie(e.x,e.y),o=s.x-this.center.x,a=s.y-this.center.y,l=Math.hypot(o,a);if(l<1e-12)return[];var c=o/l,u=a/l,h=[new Ie(this.center.x+c*this.radius,this.center.y+u*this.radius),new Ie(this.center.x-c*this.radius,this.center.y-u*this.radius)],d=[],f=this._getInternalAngle(this.startAngle),p=this._getInternalAngle(this.endAngle);try{for(var g=Ec(h),y=g.next();!y.done;y=g.next()){var m=y.value,v=Math.atan2(m.y-this.center.y,m.x-this.center.x),x=this.clockwise?this._mirrorAngle(ne.normalizeAngle(v)):ne.normalizeAngle(v),_=this._getInternalAngle(x);(this.closed||ne.isBetweenAngle(_,f,p,this.clockwise))&&d.push(m)}}catch(b){i={error:b}}finally{try{y&&!y.done&&(r=g.return)&&r.call(g)}finally{if(i)throw i.error}}return d},t.prototype.tangentPoints=function(e){var i,r,s=[],o=e.x-this.center.x,a=e.y-this.center.y,l=Math.hypot(o,a),c=this.radius;if(l<c)return s;var u=Math.acos(c/l),h=Math.atan2(a,o),d=[h+u,h-u],f=this._getInternalAngle(this.startAngle),p=this._getInternalAngle(this.endAngle);try{for(var g=Ec(d),y=g.next();!y.done;y=g.next()){var m=y.value,v=this.clockwise?this._mirrorAngle(ne.normalizeAngle(m)):ne.normalizeAngle(m),x=this._getInternalAngle(v);(this.closed||ne.isBetweenAngle(x,f,p,this.clockwise))&&s.push(this.getPointAtAngle(v))}}catch(_){i={error:_}}finally{try{y&&!y.done&&(r=g.return)&&r.call(g)}finally{if(i)throw i.error}}return s},t.prototype.getPoints=function(e){e===void 0&&(e=100);var i=[],r=this.deltaAngle,s=this._getInternalAngle(this.startAngle);if(this.closed&&(r=ue,s=0),this.clockwise)for(var o=0;o<=e;o++){var a=s-r*(o/e),l=this._clockwise?this._mirrorAngle(a):a,c=this.getPointAtAngle(l);i.push(new Ie(c.x,c.y))}else for(var o=0;o<=e;o++){var a=s+r*(o/e),l=this._clockwise?this._mirrorAngle(a):a,c=this.getPointAtAngle(l);i.push(new Ie(c.x,c.y))}return i},t.prototype.tessellate=function(e){var i,r=this.closed?ue:this.deltaAngle,s=t.segmentCount(this.radius,r,Mc(Mc({},e),{minSegments:(i=e==null?void 0:e.minSegments)!==null&&i!==void 0?i:this.closed?8:3}));return this.getPoints(s)},t.resolveCircleSides=function(e){return e==null||!Number.isFinite(e)?t.DEFAULT_CIRCLE_SIDES:$a(Math.round(e),t.MIN_CIRCLE_SIDES,t.MAX_CIRCLE_SIDES)},t.resolveTessellateOptions=function(e){var i,r=t.resolveCircleSides(e==null?void 0:e.circleSides),s=Math.max(1,Math.round((i=e==null?void 0:e.maxSegments)!==null&&i!==void 0?i:r));return{deviation:e==null?void 0:e.deviation,circleSides:r,minSegments:e==null?void 0:e.minSegments,maxSegments:s}},t.chordDeviationFromRadius=function(e,i){i===void 0&&(i=t.DEFAULT_CIRCLE_SIDES);var r=Math.abs(e),s=t.resolveCircleSides(i);return r<=Oe?Oe:Math.max(Oe,r*(1-Math.cos(Math.PI/s)))},t.segmentCount=function(e,i,r){var s,o,a=t.resolveTessellateOptions(r),l=Math.abs(i),c=l>=ue-1e-8,u=Math.max(1,Math.round((s=a.minSegments)!==null&&s!==void 0?s:c?8:3)),h=Math.max(u,a.maxSegments),d=Math.abs(e);if(d<=Oe||l<=Oe)return u;var f=(o=a.deviation)!==null&&o!==void 0?o:t.chordDeviationFromRadius(d,a.circleSides),p=1-f/d;if(!Number.isFinite(p)||p>=1)return h;if(p<=-1)return u;var g=2*Math.acos(p);return g<=Oe?h:$a(Math.ceil(l/g),u,h)},t.DEFAULT_CIRCLE_SIDES=100,t.MIN_CIRCLE_SIDES=8,t.MAX_CIRCLE_SIDES=2e4,t})(Gd),DE=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),UE=(function(n){DE(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.translate=function(e){return this.transform(new Ya().makeTranslation(e.x,e.y,e.z))},Object.defineProperty(t.prototype,"box",{get:function(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box},enumerable:!1,configurable:!0}),t})(a0),zE=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),Tc=(function(n){zE(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.tessellateParametricCurve=function(e,i,r,s){var o=Math.max(2,Math.round(s.maxSegments)),a=Math.max(1,Math.round(s.minSegments)),l=Math.max(0,s.deviation)*Math.max(0,s.deviation);if(!Number.isFinite(e)||!Number.isFinite(i))return[r(0)];if(Math.abs(i-e)<=Oe)return[r(e)];for(var c=Math.min(o,Math.max(2,a+1)),u=Math.min(o,Math.max(c,8)),h=HE(e,i,u),d=[],f=0;f<h.length;f++)d.push(r(h[f]));for(var p=d.length,g=0;g<8&&p<o;g++){for(var y=[],f=0;f<h.length-1&&!(p>=o);f++){var m=(h[f]+h[f+1])/2,v=r(m);p++,FE(v,d[f],d[f+1])>l&&y.push({index:f,t:m,point:v})}if(y.length===0)break;var x=GE(h,d,y);h=x.params,d.length=0;for(var f=0;f<x.points.length;f++)d.push(x.points[f])}return d},t})(UE);function FE(n,t,e){var i=e.x-t.x,r=e.y-t.y,s=e.z-t.z,o=n.x-t.x,a=n.y-t.y,l=n.z-t.z,c=i*i+r*r+s*s;if(c<=Oe*Oe)return o*o+a*a+l*l;var u=$a((o*i+a*r+l*s)/c,0,1),h=o-i*u,d=a-r*u,f=l-s*u;return h*h+d*d+f*f}function HE(n,t,e){if(e<=1)return[n];for(var i=[],r=0;r<e;r++)i.push(r===e-1?t:n+(t-n)*r/(e-1));return i}function GE(n,t,e){for(var i=[],r=[],s=0,o=0;o<n.length;o++)for(i.push(n[o]),r.push(t[o]);s<e.length&&e[s].index===o;)i.push(e[s].t),r.push(e[s].point),s++;return{params:i,points:r}}var VE=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),Lc=function(){return Lc=Object.assign||function(n){for(var t,e=1,i=arguments.length;e<i;e++){t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},Lc.apply(this,arguments)},Vd=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Za=(function(n){VE(t,n);function t(e,i,r,s,o,a){a===void 0&&(a=_t.X_AXIS);var l=n.call(this)||this;return l.center=e,l.radius=i,l.startAngle=r,l.endAngle=s,l.normal=o,l.refVec=a,(s-r)%ue==0?(l.startAngle=0,l.endAngle=ue):(l.startAngle=r,l.endAngle=s),l}return t.computeCenterPoint=function(e,i,r){var s,o;return(o=(s=i0(e,r,i))===null||s===void 0?void 0:s.center)!==null&&o!==void 0?o:null},t.tryCreateByThreePoints=function(e,i,r){var s,o,a,l=i0(e,r,i);if(!l)return null;var c=l.center,u=l.radius,h=new _t(e.x-c.x,e.y-c.y,((s=e.z)!==null&&s!==void 0?s:0)-c.z),d=new _t(r.x-c.x,r.y-c.y,((o=r.z)!==null&&o!==void 0?o:0)-c.z),f=new _t(i.x-c.x,i.y-c.y,((a=i.z)!==null&&a!==void 0?a:0)-c.z);if(h.lengthSq()===0||f.lengthSq()===0)return null;var p=new _t().crossVectors(h,f);if(p.lengthSq()===0&&(p.crossVectors(h,d),p.lengthSq()===0))return null;p.normalize();var g=h.clone().normalize(),y=new _t().crossVectors(p,g),m=function(x){return ne.normalizeAngle(Math.atan2(x.dot(y),x.dot(g)))};ne.isAngleOnCcwSweep(0,m(d),m(f))||(p.negate(),y.negate());var v=m(f);return Ae.equalToZero(v)&&(v=ue),new t(c,u,0,v,p,g)},t.createByThreePoints=function(e,i,r){return t.tryCreateByThreePoints(e,i,r)},Object.defineProperty(t.prototype,"center",{get:function(){return this._center},set:function(e){this._center=new Be(e.x,e.y,e.z||0),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"radius",{get:function(){return this._radius},set:function(e){if(e<0)throw Lr.ILLEGAL_PARAMETERS;this._radius=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startAngle",{get:function(){return this._startAngle},set:function(e){this._startAngle=ne.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endAngle",{get:function(){return this._endAngle},set:function(e){this._endAngle=this.startAngle==0&&e==ue?e:ne.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"deltaAngle",{get:function(){return ne.normalizeAngle(this.endAngle-this.startAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isLargeArc",{get:function(){return Math.abs(this.deltaAngle)>Math.PI?1:0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"clockwise",{get:function(){return this.deltaAngle<=0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normal",{get:function(){return this._normal},set:function(e){this._normal=new _t(e.x,e.y,e.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"refVec",{get:function(){return this._refVec},set:function(e){this._refVec=new _t(e.x,e.y,e.z),this._refVec.normalize(),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startPoint",{get:function(){return this.getPointAtAngle(this._startAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){return this.getPointAtAngle(this._endAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"midPoint",{get:function(){var e=this.startAngle,i=this.deltaAngle;this.closed&&(e=0,i=ue);var r=e+i*.5;return this.getPointAtAngle(r)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){return this.closed?2*Math.PI*this.radius:Math.abs(this.deltaAngle*this.radius)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"area",{get:function(){return this.closed?Math.PI*this.radius*this.radius:0},enumerable:!1,configurable:!0}),t.prototype.nearestPoint=function(e){var i=new _t(e.x,e.y,e.z||0),r=this.center,s=this.normal,o=i.clone().sub(r),a=o.dot(s),l=i.clone().sub(s.clone().multiplyScalar(a)),c=l.clone().sub(r);if(c.lengthSq()===0)return this.startPoint.clone();c.normalize().multiplyScalar(this.radius);var u=r.clone().add(c),h=this.getAngle(u.clone()),d=this.startAngle,f=this.deltaAngle,p=ne.normalizeAngle(h-d);p<0&&(p=0),p>f&&(p=f);var g=this.getPointAtAngle(d+p),y=g.distanceTo(i),m=this.startPoint.distanceTo(i),v=this.endPoint.distanceTo(i);return m<y&&m<=v?this.startPoint.clone():v<y&&v<m?this.endPoint.clone():g},t.prototype.tangentPoints=function(e){var i,r,s=[],o=new _t(e.x,e.y,e.z||0),a=this.center,l=this.normal,c=this.radius,u=o.clone().sub(a),h=u.dot(l),d=o.clone().sub(l.clone().multiplyScalar(h)),f=a.clone(),p=d.clone().sub(f),g=p.length();if(g<c)return s;var y=Math.acos(c/g),m=this.getAngle(d.clone()),v=[m+y,m-y];try{for(var x=Vd(v),_=x.next();!_.done;_=x.next()){var b=_.value,w=ne.normalizeAngle(b-this.startAngle);w>=0&&w<=this.deltaAngle&&s.push(this.getPointAtAngle(this.startAngle+w))}}catch(C){i={error:C}}finally{try{_&&!_.done&&(r=x.return)&&r.call(x)}finally{if(i)throw i.error}}return s},t.prototype.perpendicularPoints=function(e){var i,r,s=[],o=new _t(e.x,e.y,e.z||0),a=this.center,l=this.normal,c=this.radius,u=o.clone().sub(a),h=u.dot(l),d=o.clone().sub(l.clone().multiplyScalar(h)),f=d.clone().sub(a);if(f.lengthSq()<1e-24)return s;f.normalize();var p=[a.clone().add(f.clone().multiplyScalar(c)),a.clone().sub(f.clone().multiplyScalar(c))];try{for(var g=Vd(p),y=g.next();!y.done;y=g.next()){var m=y.value,v=this.getAngle(m.clone()),x=ne.normalizeAngle(v-this.startAngle);x>=0&&x<=this.deltaAngle&&s.push(new Be(m.x,m.y,m.z||0))}}catch(_){i={error:_}}finally{try{y&&!y.done&&(r=g.return)&&r.call(g)}finally{if(i)throw i.error}}return s},t.prototype.nearestTangentPoint=function(e){var i=this.tangentPoints(e);if(i.length===0)return null;var r=new Be(e.x,e.y,e.z||0);return i.length===1||i[0].distanceTo(r)<i[1].distanceTo(r)?i[0]:i[1]},t.prototype.calculateBoundingBox=function(){for(var e,i,r=[this.startAngle,this.endAngle],s=0;s<2*Math.PI;s+=Math.PI/2)ne.isBetweenAngle(s,this.startAngle,this.endAngle)&&r.push(s);var o=1/0,a=1/0,l=1/0,c=-1/0,u=-1/0,h=-1/0;try{for(var d=Vd(r),f=d.next();!f.done;f=d.next()){var p=f.value,g=this.getPointAtAngle(p);g.x<o&&(o=g.x),g.y<a&&(a=g.y),g.z<l&&(l=g.z),g.x>c&&(c=g.x),g.y>u&&(u=g.y),g.z>h&&(h=g.z)}}catch(y){e={error:y}}finally{try{f&&!f.done&&(i=d.return)&&i.call(d)}finally{if(e)throw e.error}}return new Rs({x:o,y:a,z:l},{x:c,y:u,z:h})},Object.defineProperty(t.prototype,"closed",{get:function(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0},enumerable:!1,configurable:!0}),t.prototype.getPoints=function(e){var i=[],r=this.deltaAngle,s=this.startAngle;this.closed&&(r=ue,s=0);for(var o=0;o<=e;o++){var a=s+r*(o/e),l=this.getPointAtAngle(a);i.push(l)}return i},t.prototype.tessellate=function(e){var i,r=this.closed?ue:this.deltaAngle,s=t.segmentCount(this.radius,r,Lc(Lc({},e),{minSegments:(i=e==null?void 0:e.minSegments)!==null&&i!==void 0?i:this.closed?8:3}));return this.getPoints(s)},t.segmentCount=function(e,i,r){return fn.segmentCount(e,i,r)},t.prototype.transform=function(e){var i=this.center.clone().applyMatrix4(e),r=this.startPoint.clone().applyMatrix4(e),s=this.endPoint.clone().applyMatrix4(e),o=this.getPointAtAngle(this.closed?Math.PI/2:this.startAngle+this.deltaAngle/2).clone().applyMatrix4(e),a=new _t(r).sub(i).normalize(),l=i.distanceTo(r),c=new _t().crossVectors(new _t(r).sub(i),new _t(o).sub(i)).normalize();c.lengthSq()===0&&(c=this.normal.clone().transformDirection(e));var u=function(h){var d=new _t(h).sub(i);return Math.atan2(d.dot(l0.crossVectors(c,a)),d.dot(a))};return this.center=i,this.radius=l,this.normal=c,this.refVec=a,this.startAngle=0,this.endAngle=this.closed?ue:u(s),this._boundingBoxNeedsUpdate=!0,this},t.prototype.copy=function(e){return this.center=e.center,this.radius=e.radius,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.normal=e.normal,this.refVec=e.refVec,this._boundingBoxNeedsUpdate=!0,this},t.prototype.clone=function(){return new t(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)},t.prototype.getAngle=function(e){return e.sub(this.center),Math.atan2(e.dot(l0.crossVectors(this.refVec,this.normal)),e.dot(this.refVec))},t.prototype.getPointAtAngle=function(e){var i=this.normal,r=this.refVec,s={x:i.y*r.z-i.z*r.y,y:i.z*r.x-i.x*r.z,z:i.x*r.y-i.y*r.x},o=this.center,a=this.radius;return new Be(o.x+a*(r.x*Math.cos(e)+s.x*Math.sin(e)),o.y+a*(r.y*Math.cos(e)+s.y*Math.sin(e)),o.z+a*(r.z*Math.cos(e)+s.z*Math.sin(e)))},Object.defineProperty(t.prototype,"plane",{get:function(){var e=new _t(this.center).distanceTo(Zy);return new Ud(this.normal,e)},enumerable:!1,configurable:!0}),t.prototype.offset=function(e){var i=this.radius+e;return i<=0?null:new t(this.center,i,this.startAngle,this.endAngle,this.normal,this.refVec)},t})(Tc),l0=new _t,WE=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),XE=(function(n){WE(t,n);function t(e,i,r,s,o,a,l){s===void 0&&(s=0),o===void 0&&(o=ue),a===void 0&&(a=!1),l===void 0&&(l=0);var c=n.call(this)||this;return c.center=e,c.majorAxisRadius=i,c.minorAxisRadius=r,(o-s)%ue==0?(c.startAngle=0,c.endAngle=ue):(c.startAngle=s,c.endAngle=o),c.clockwise=a,c.rotation=l,c}return Object.defineProperty(t.prototype,"center",{get:function(){return this._center},set:function(e){this._center=new Be(e.x,e.y,e.z||0),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"majorAxisRadius",{get:function(){return this._majorAxisRadius},set:function(e){if(e<0)throw Lr.ILLEGAL_PARAMETERS;this._majorAxisRadius=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"minorAxisRadius",{get:function(){return this._minorAxisRadius},set:function(e){if(e<0)throw Lr.ILLEGAL_PARAMETERS;this._minorAxisRadius=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startAngle",{get:function(){return this._startAngle},set:function(e){this._startAngle=ne.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endAngle",{get:function(){return this._endAngle},set:function(e){this._endAngle=this.startAngle==0&&e==ue?e:ne.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"clockwise",{get:function(){return this._clockwise},set:function(e){this._clockwise=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotation",{get:function(){return this._rotation},set:function(e){this._rotation=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"deltaAngle",{get:function(){return ne.normalizeAngle(this.endAngle-this.startAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isLargeArc",{get:function(){return Math.abs(this.deltaAngle)>Math.PI?1:0},enumerable:!1,configurable:!0}),t.prototype.calculateBoundingBox=function(){for(var e=100,i=1/0,r=1/0,s=-1/0,o=-1/0,a=0;a<=e;a++){var l=this.getPoint(a/e);i=Math.min(i,l.x),r=Math.min(r,l.y),s=Math.max(s,l.x),o=Math.max(o,l.y)}return new Dd({x:i,y:r},{x:s,y:o})},Object.defineProperty(t.prototype,"closed",{get:function(){return this.deltaAngle==0},enumerable:!1,configurable:!0}),t.prototype.getPoint=function(e){for(var i=Math.PI*2,r=this.endAngle-this.startAngle,s=Math.abs(r)<Number.EPSILON;r<0;)r+=i;for(;r>i;)r-=i;r<Number.EPSILON&&(s?r=0:r=i),this.clockwise===!0&&!s&&(r===i?r=-i:r=r-i);var o=this.startAngle+e*r,a=this.center.x+this.majorAxisRadius*Math.cos(o),l=this.center.y+this.minorAxisRadius*Math.sin(o);if(this.rotation!==0){var c=Math.cos(this.rotation),u=Math.sin(this.rotation),h=a-this.center.x,d=l-this.center.y;a=h*c-d*u+this.center.x,l=h*u+d*c+this.center.y}return new Ie(a,l)},t.prototype.transform=function(e){var i=e,r=new Ie(this.center).applyMatrix2d(i),s=new Be(r.x,r.y,this.center.z),o=this.getPointAtAngle(0).clone().applyMatrix2d(i),a=this.getPointAtAngle(Math.PI/2).clone().applyMatrix2d(i),l=new Ie(o).sub(r),c=new Ie(a).sub(r),u=l.length(),h=c.length(),d=Math.atan2(l.y,l.x),f=l.clone().normalize(),p=c.clone().normalize(),g=function(v){var x=new Ie(v).sub(r),_=x.dot(f),b=x.dot(p);return ne.normalizeAngle(Math.atan2(b/h,_/u))},y=i.determinant()<0?!this.clockwise:this.clockwise,m=this.closed?new t(s,u,h,0,ue,y,d):new t(s,u,h,g(this.startPoint.clone().applyMatrix2d(i)),g(this.endPoint.clone().applyMatrix2d(i)),y,d);return this.center=m.center,this.majorAxisRadius=m.majorAxisRadius,this.minorAxisRadius=m.minorAxisRadius,this._startAngle=m._startAngle,this._endAngle=m._endAngle,this._clockwise=m._clockwise,this.rotation=m.rotation,this._boundingBoxNeedsUpdate=!0,this},t.prototype.getPointAtAngle=function(e){return this.getPoint(this.closed?e/ue:ne.normalizeAngle(e-this.startAngle)/this.deltaAngle)},t.prototype.copy=function(e){return this.center=e.center,this.majorAxisRadius=e.majorAxisRadius,this.minorAxisRadius=e.minorAxisRadius,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.clockwise=e.clockwise,this.rotation=e.rotation,this},t.prototype.clone=function(){return new t(this.center,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle,this.clockwise,this.rotation)},t.prototype.getFocusPoints=function(){var e=Math.max(this.majorAxisRadius,this.minorAxisRadius),i=Math.min(this.majorAxisRadius,this.minorAxisRadius);if(e-i<1e-9)return[];var r=Math.sqrt(e*e-i*i),s=Math.cos(this.rotation),o=Math.sin(this.rotation),a=this.majorAxisRadius>=this.minorAxisRadius,l=a?s:-o,c=a?o:s;return[new Ie(this.center.x-r*l,this.center.y-r*c),new Ie(this.center.x+r*l,this.center.y+r*c)]},t.prototype.getQuadrantPoints=function(){return this.closed?[this.getPoint(0),this.getPoint(.25),this.getPoint(.5),this.getPoint(.75)]:[]},t.prototype.nearestPoint=function(e){for(var i=new Ie(e.x,e.y),r=this.getPoint(0),s=i.distanceToSquared(r),o=72,a=1;a<=o;a++){var l=this.getPoint(a/o),c=i.distanceToSquared(l);c<s&&(s=c,r=l)}return r},t.prototype.tangentPoints=function(e){var i=this,r=this._projectPointToLocal(e),s=this._findSnapAngles(r,function(o,a,l,c){var u=-i.majorAxisRadius*c,h=i.minorAxisRadius*l;return(o-r.x)*h-(a-r.y)*u});return s.map(function(o){return i.getPointAtAngle(o)})},t.prototype.perpendicularPoints=function(e){var i=this,r=this._projectPointToLocal(e),s=this._findSnapAngles(r,function(o,a,l,c){var u=i.minorAxisRadius*l,h=i.majorAxisRadius*c;return(o-r.x)*h-(a-r.y)*u});return s.map(function(o){return i.getPointAtAngle(o)})},t.prototype._projectPointToLocal=function(e){var i=e.x-this.center.x,r=e.y-this.center.y,s=Math.cos(-this.rotation),o=Math.sin(-this.rotation);return{x:i*s-r*o,y:i*o+r*s}},t.prototype._findSnapAngles=function(e,i,r){r===void 0&&(r=144);for(var s=this.majorAxisRadius,o=this.minorAxisRadius,a=this.startAngle,l=this.deltaAngle,c=[],u=function(_){var b=Math.cos(_),w=Math.sin(_);return i(s*b,o*w,b,w)},h=a,d=u(h),f=1;f<=r;f++){var p=a+l*f/r,g=u(p);if(Math.abs(d)<1e-10&&c.push(h),d*g<0){for(var y=h,m=p,v=0;v<32;v++){var x=(y+m)/2;u(y)*u(x)<=0?m=x:y=x}c.push((y+m)/2)}h=p,d=g}return c},t})(Gd),jE=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),Ic=function(){return Ic=Object.assign||function(n){for(var t,e=1,i=arguments.length;e<i;e++){t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},Ic.apply(this,arguments)},$E=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Ja=(function(n){jE(t,n);function t(e,i,r,s,o,a,l){a===void 0&&(a=0),l===void 0&&(l=ue);var c=n.call(this)||this;c.center=e,c.normal=i,c.majorAxis=r,c.majorAxisRadius=s,c.minorAxisRadius=o;var u=Math.abs(l-a);return Math.abs(u-ue)<1e-10||Math.abs(u-2*ue)<1e-10?(c.startAngle=0,c.endAngle=ue):(c.startAngle=a,c.endAngle=l),c}return Object.defineProperty(t.prototype,"center",{get:function(){return this._center},set:function(e){this._center=new Be(e.x,e.y,e.z||0),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"majorAxisRadius",{get:function(){return this._majorAxisRadius},set:function(e){if(e<0)throw Lr.ILLEGAL_PARAMETERS;this._majorAxisRadius=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"minorAxisRadius",{get:function(){return this._minorAxisRadius},set:function(e){if(e<0)throw Lr.ILLEGAL_PARAMETERS;this._minorAxisRadius=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startAngle",{get:function(){return this._startAngle},set:function(e){this._startAngle=ne.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endAngle",{get:function(){return this._endAngle},set:function(e){this._endAngle=this.startAngle==0&&e==ue?e:ne.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"deltaAngle",{get:function(){var e=this.endAngle-this.startAngle;return Math.abs(e-ue)<1e-10?ue:ne.normalizeAngle(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isLargeArc",{get:function(){return Math.abs(this.deltaAngle)>Math.PI?1:0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"clockwise",{get:function(){return this.deltaAngle<=0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normal",{get:function(){return this._normal},set:function(e){this._normal=new _t(e.x,e.y,e.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"majorAxis",{get:function(){return this._majorAxis},set:function(e){this._majorAxis=new _t(e.x,e.y,e.z),this._majorAxis.normalize(),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"minorAxis",{get:function(){return new _t().crossVectors(this.normal,this.majorAxis).normalize()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startPoint",{get:function(){return this.getPointAtAngle(this._startAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){return this.getPointAtAngle(this._endAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"midPoint",{get:function(){var e=this.startAngle,i=this.deltaAngle;(this.closed||Math.abs(i-ue)<1e-10)&&(e=0,i=ue);var r=e+i/2;return this.getPointAtAngle(r)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isCircular",{get:function(){return Ae.equal(this.majorAxisRadius,this.minorAxisRadius)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){if(this.isCircular)return this.majorAxisRadius*Math.abs(this.deltaAngle);for(var e=1e3,i=this.deltaAngle/e,r=0,s=this.getPointAtAngle(this.startAngle),o=1;o<=e;o++){var a=this.startAngle+o*i,l=this.getPointAtAngle(a),c=l.x-s.x,u=l.y-s.y,h=l.z-s.z;r+=Math.sqrt(c*c+u*u+h*h),s=l}return r},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"area",{get:function(){return Math.abs(this.deltaAngle-ue)>=1e-10?0:Math.PI*this.majorAxisRadius*this.minorAxisRadius},enumerable:!1,configurable:!0}),t.prototype.calculateBoundingBox=function(){var e,i;if(this.majorAxis.equals(_t.X_AXIS)||this.majorAxis.equals(_t.Y_AXIS)||this.majorAxis.isParallelTo(_t.X_AXIS)||this.majorAxis.isParallelTo(_t.Y_AXIS)){for(var r=[this.startAngle,this.endAngle],s=0;s<2*Math.PI;s+=Math.PI/2)ne.isBetweenAngle(s,this.startAngle,this.endAngle)&&r.push(s);var o=1/0,a=1/0,l=1/0,c=-1/0,u=-1/0,h=-1/0;try{for(var d=$E(r),f=d.next();!f.done;f=d.next()){var p=f.value,g=this.getPointAtAngle(p);g.x<o&&(o=g.x),g.y<a&&(a=g.y),g.z<l&&(l=g.z),g.x>c&&(c=g.x),g.y>u&&(u=g.y),g.z>h&&(h=g.z)}}catch(m){e={error:m}}finally{try{f&&!f.done&&(i=d.return)&&i.call(d)}finally{if(e)throw e.error}}return new Rs({x:o,y:a,z:l},{x:c,y:u,z:h})}else{for(var y=100,o=1/0,a=1/0,l=1/0,c=-1/0,u=-1/0,h=-1/0,s=0;s<=y;s++){var p=this.startAngle+this.deltaAngle*(s/y),g=this.getPointAtAngle(p);o=Math.min(o,g.x),a=Math.min(a,g.y),l=Math.min(l,g.z),c=Math.max(c,g.x),u=Math.max(u,g.y),h=Math.max(h,g.z)}return new Rs({x:o,y:a,z:l},{x:c,y:u,z:h})}},Object.defineProperty(t.prototype,"closed",{get:function(){return this.deltaAngle==0},enumerable:!1,configurable:!0}),t.prototype.getPoints=function(e){e===void 0&&(e=100);var i=[],r=this.deltaAngle,s=this.startAngle;this.closed&&(r=ue,s=0);for(var o=0;o<=e;o++){var a=s+r*(o/e),l=this.getPointAtAngle(a);i.push(l)}return i},t.prototype.tessellate=function(e){var i=this,r,s,o=fn.resolveTessellateOptions(e),a=this.closed?ue:this.deltaAngle,l=Math.max(this.majorAxisRadius,this.minorAxisRadius),c=Math.abs(a)>=ue-1e-8,u=(r=o.minSegments)!==null&&r!==void 0?r:c?8:3;if(this.isCircular){var h=Za.segmentCount(l,a,Ic(Ic({},e),{minSegments:u}));return this.getPoints(h)}var d=(s=o.deviation)!==null&&s!==void 0?s:fn.chordDeviationFromRadius(l,o.circleSides),f=this.closed?0:this.startAngle;return Tc.tessellateParametricCurve(f,f+a,function(p){return i.getPointAtAngle(p)},{deviation:Math.max(Oe,d),minSegments:u,maxSegments:o.maxSegments})},t.prototype.getPointAtAngle=function(e){var i=Math.cos(e),r=Math.sin(e),s=this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(r),o=this.majorAxis.clone().multiplyScalar(i*this.majorAxisRadius).add(s);return new Be(this.center.x+o.x,this.center.y+o.y,this.center.z+o.z)},t.prototype.nearestPoint=function(e,i){i===void 0&&(i=72);for(var r=new Be(e.x,e.y,e.z||0),s=this.getPointAtAngle(this.startAngle),o=r.distanceToSquared(s),a=1;a<=i;a++){var l=this.startAngle+this.deltaAngle*a/i,c=this.getPointAtAngle(l),u=r.distanceToSquared(c);u<o&&(o=u,s=c)}var h=r.distanceToSquared(this.startPoint),d=r.distanceToSquared(this.endPoint);return h<o&&h<=d?this.startPoint.clone():d<o&&d<h?this.endPoint.clone():s.clone()},t.prototype.tangentPoints=function(e){var i=this,r=this._projectPointToLocalPlane(e),s=this._findSnapParameterAngles(function(o,a,l,c){var u=-i.majorAxisRadius*c,h=i.minorAxisRadius*l;return(o-r.x)*h-(a-r.y)*u});return s.map(function(o){return i.getPointAtAngle(o)})},t.prototype.perpendicularPoints=function(e){var i=this,r=this._projectPointToLocalPlane(e),s=this._findSnapParameterAngles(function(o,a,l,c){var u=i.minorAxisRadius*l,h=i.majorAxisRadius*c;return(o-r.x)*h-(a-r.y)*u});return s.map(function(o){return i.getPointAtAngle(o)})},t.prototype._projectPointToLocalPlane=function(e){var i=new Be(e.x,e.y,e.z||0),r=new _t(i).sub(this.center),s=r.dot(this.normal);return r.sub(this.normal.clone().multiplyScalar(s)),{x:r.dot(this.majorAxis),y:r.dot(this.minorAxis)}},t.prototype._findSnapParameterAngles=function(e,i){i===void 0&&(i=144);for(var r=this.majorAxisRadius,s=this.minorAxisRadius,o=this.startAngle,a=this.deltaAngle,l=[],c=function(x){var _=Math.cos(x),b=Math.sin(x);return e(r*_,s*b,_,b)},u=o,h=c(u),d=1;d<=i;d++){var f=o+a*d/i,p=c(f);if(Math.abs(h)<1e-10&&l.push(u),h*p<0){for(var g=u,y=f,m=0;m<32;m++){var v=(g+y)/2;c(g)*c(v)<=0?y=v:g=v}l.push((g+y)/2)}u=f,h=p}return l},t.prototype.contains=function(e){var i=new _t(e).sub(this.center),r=i.dot(this.majorAxis),s=i.dot(this.minorAxis),o=r/this.majorAxisRadius,a=s/this.minorAxisRadius;return o*o+a*a<=1},t.prototype.transform=function(e){var i=e,r=this.center.clone().applyMatrix4(i),s=this.getPointAtAngle(0).clone().applyMatrix4(i),o=this.getPointAtAngle(Math.PI/2).clone().applyMatrix4(i),a=new _t(s).sub(r),l=new _t(o).sub(r),c=a.length(),u=l.length(),h=a.clone().normalize(),d=new _t().crossVectors(a,l).normalize(),f=new _t().crossVectors(d,h).normalize();f.dot(l)<0&&(d.negate(),f=new _t().crossVectors(d,h).normalize());var p=function(y){var m=new _t(y).sub(r),v=m.dot(h),x=m.dot(f);return ne.normalizeAngle(Math.atan2(x/u,v/c))},g=this.closed?new t(r,d,h,c,u,0,ue):new t(r,d,h,c,u,p(this.startPoint.clone().applyMatrix4(i)),p(this.endPoint.clone().applyMatrix4(i)));return this.center=g.center,this.normal=g.normal,this.majorAxis=g.majorAxis,this.majorAxisRadius=g.majorAxisRadius,this.minorAxisRadius=g.minorAxisRadius,this._startAngle=g._startAngle,this._endAngle=g._endAngle,this._boundingBoxNeedsUpdate=!0,this},t.prototype.copy=function(e){return this.center=e.center,this.normal=e.normal,this.majorAxis=e.majorAxis,this.majorAxisRadius=e.majorAxisRadius,this.minorAxisRadius=e.minorAxisRadius,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this._boundingBoxNeedsUpdate=!0,this},t.prototype.clone=function(){return new t(this.center,this.normal,this.majorAxis,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle)},Object.defineProperty(t.prototype,"plane",{get:function(){var e=new _t(this.center).distanceTo(Zy);return new Ud(this.normal,e)},enumerable:!1,configurable:!0}),t.prototype.offset=function(e){var i=this.majorAxisRadius+e,r=this.minorAxisRadius+e;return i<=0||r<=0?null:new t(this.center,this.normal,this.majorAxis,i,r,this.startAngle,this.endAngle)},t})(Tc),YE=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),qE=(function(n){YE(t,n);function t(e,i){var r=n.call(this)||this;return r._start=new Ie(e),r._end=new Ie(i),r}return Object.defineProperty(t.prototype,"startPoint",{get:function(){return this._start},set:function(e){this._start.copy(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){return this._end},set:function(e){this._end.copy(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),t.prototype.getPoints=function(){return[this.startPoint,this.endPoint]},Object.defineProperty(t.prototype,"length",{get:function(){return this.startPoint.distanceTo(this.endPoint)},enumerable:!1,configurable:!0}),t.prototype.calculateBoundingBox=function(){var e=new Ie(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y)),i=new Ie(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y));return new Dd(e,i)},t.prototype.transform=function(e){return this._start.applyMatrix2d(e),this._end.applyMatrix2d(e),this._boundingBoxNeedsUpdate=!0,this},Object.defineProperty(t.prototype,"closed",{get:function(){return!1},enumerable:!1,configurable:!0}),t.prototype.copy=function(e){return this.startPoint=e.startPoint,this.endPoint=e.endPoint,this._boundingBoxNeedsUpdate=!0,this},t.prototype.clone=function(){return new t(this._start.clone(),this._end.clone())},t.prototype.project=function(e){var i=this._end.x-this._start.x,r=this._end.y-this._start.y,s=i*i+r*r;if(s<1e-18)return this._start.clone();var o=((e.x-this._start.x)*i+(e.y-this._start.y)*r)/s;return o=Math.max(0,Math.min(1,o)),new Ie(this._start.x+o*i,this._start.y+o*r)},t.prototype.nearestPoint=function(e){return this.project(e)},t})(Gd),KE=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),Wd=(function(){function n(){this.c0=0,this.c1=0,this.c2=0,this.c3=0}return n.prototype.init=function(t,e,i,r){this.c0=t,this.c1=i,this.c2=-3*t+3*e-2*i-r,this.c3=2*t-2*e+i+r},n.prototype.initCatmullRom=function(t,e,i,r,s){this.init(e,i,s*(i-t),s*(r-e))},n.prototype.initNonuniformCatmullRom=function(t,e,i,r,s,o,a){var l=(e-t)/s-(i-t)/(s+o)+(i-e)/o,c=(i-e)/o-(r-e)/(o+a)+(r-i)/a;l*=o,c*=o,this.init(e,i,l,c)},n.prototype.calc=function(t){var e=t*t,i=e*t;return this.c0+this.c1*t+this.c2*e+this.c3*i},n})(),ZE=(function(n){KE(t,n);function t(e,i,r,s){e===void 0&&(e=[]),i===void 0&&(i=!1),r===void 0&&(r="centripetal"),s===void 0&&(s=.5);var o=n.call(this)||this;return o.isCatmullRomCurve3d=!0,o.type="CatmullRomCurve3d",o._tmp=new _t,o._px=new Wd,o._py=new Wd,o._pz=new Wd,o._points=e.map(function(a){return new Be(a)}),o._closed=i,o._curveType=r,o._tension=s,o}return Object.defineProperty(t.prototype,"points",{get:function(){return this._points},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"closed",{get:function(){return this._closed},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"curveType",{get:function(){return this._curveType},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tension",{get:function(){return this._tension},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startPoint",{get:function(){return this._points.length>0?this._points[0]:new Be},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){return this._points.length>0?this._points[this._points.length-1]:new Be},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){if(this._points.length<2)return 0;for(var e=0,i=1;i<this._points.length;i++)e+=this._points[i-1].distanceTo(this._points[i]);return this._closed&&this._points.length>2&&(e+=this._points[this._points.length-1].distanceTo(this._points[0])),e},enumerable:!1,configurable:!0}),t.prototype.getPoint=function(e,i){i===void 0&&(i=new Be);var r=i,s=this._points,o=s.length;if(o===0)return r.set(0,0,0);if(o===1)return r.copy(s[0]);var a=(o-(this._closed?0:1))*e,l=Math.floor(a),c=a-l;this._closed?l+=l>0?0:(Math.floor(Math.abs(l)/o)+1)*o:c===0&&l===o-1&&(l=o-2,c=1);var u,h;this._closed||l>0?u=s[(l-1)%o]:(this._tmp.subVectors(s[0],s[1]).add(s[0]),u=new Be(this._tmp.x,this._tmp.y,this._tmp.z));var d=s[l%o],f=s[(l+1)%o];if(this._closed||l+2<o?h=s[(l+2)%o]:(this._tmp.subVectors(s[o-1],s[o-2]).add(s[o-1]),h=new Be(this._tmp.x,this._tmp.y,this._tmp.z)),this._curveType==="centripetal"||this._curveType==="chordal"){var p=this._curveType==="chordal"?.5:.25,g=Math.pow(u.distanceToSquared(d),p),y=Math.pow(d.distanceToSquared(f),p),m=Math.pow(f.distanceToSquared(h),p);y<1e-4&&(y=1),g<1e-4&&(g=y),m<1e-4&&(m=y),this._px.initNonuniformCatmullRom(u.x,d.x,f.x,h.x,g,y,m),this._py.initNonuniformCatmullRom(u.y,d.y,f.y,h.y,g,y,m),this._pz.initNonuniformCatmullRom(u.z,d.z,f.z,h.z,g,y,m)}else this._curveType==="catmullrom"&&(this._px.initCatmullRom(u.x,d.x,f.x,h.x,this._tension),this._py.initCatmullRom(u.y,d.y,f.y,h.y,this._tension),this._pz.initCatmullRom(u.z,d.z,f.z,h.z,this._tension));return r.set(this._px.calc(c),this._py.calc(c),this._pz.calc(c)),r},t.prototype.getPoints=function(e){for(var i=[],r=0;r<=e;r++)i.push(this.getPoint(r/e));return i},t.prototype.setPoints=function(e){this._points=e.map(function(i){return new Be(i)}),this._boundingBoxNeedsUpdate=!0},t.prototype.setClosed=function(e){this._closed!==e&&(this._closed=e,this._boundingBoxNeedsUpdate=!0)},t.prototype.setCurveType=function(e){this._curveType=e},t.prototype.setTension=function(e){this._tension=e},t.prototype.clone=function(){return new t(this._points.map(function(e){return e.clone()}),this._closed,this._curveType,this._tension)},t.prototype.transform=function(e){return this._points=this._points.map(function(i){var r=new Be;return r.copy(i),r.applyMatrix4(e),r}),this._boundingBoxNeedsUpdate=!0,this},t.prototype.calculateBoundingBox=function(){if(this._points.length===0)return new Rs;var e=new Rs;return this._points.forEach(function(i){e.expandByPoint(i)}),e},t})(Tc),vo=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},_o=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))};function c0(n,t){var e,i,r=n.x-t[0],s=n.y-t[1],o=((e=n.z)!==null&&e!==void 0?e:0)-((i=t[2])!==null&&i!==void 0?i:0);return r*r+s*s+o*o}var JE=(function(){function n(t,e,i,r){this._degree=t,this._knots=_o([],vo(e),!1),this._controlPoints=i.map(function(s){return{x:s.x,y:s.y,z:s.z}}),this._weights=r?_o([],vo(r),!1):new Array(i.length).fill(1)}return n.prototype.degree=function(){return this._degree},n.prototype.knots=function(){return _o([],vo(this._knots),!1)},n.prototype.controlPoints=function(){return this._controlPoints.map(function(t){return{x:t.x,y:t.y,z:t.z}})},n.prototype.weights=function(){return _o([],vo(this._weights),!1)},n.prototype.clone=function(){return new n(this._degree,this._knots,this._controlPoints,this._weights)},n.prototype.point=function(t){return this.evaluate(t).point},n.prototype.evaluate=function(t){var e=this._controlPoints.map(function(i){return[i.x,i.y,i.z]});return vE(t,this._degree,this._knots,e,this._weights)},n.prototype.signedPlanarCurvatureAt=function(t){var e=this.evaluate(t);return _E(e.deriv1,e.deriv2)},n.prototype.getOffsetSamplePath2d=function(t,e){var i=this;e===void 0&&(e=512);for(var r=Math.abs(t),s=this.getParameterRange(),o=s.start,a=s.end,l=this.length(),c=Math.max(64,Math.ceil(l/Math.max(r*.2,1e-6))),u=QE(o,a,Math.min(c,e)),h=0;h<8&&u.length<e;h++){for(var d=[],f=0;f<u.length-1;f++){var p=u[f],g=u[f+1],y=(p+g)/2,m=Math.max(Math.abs(this.signedPlanarCurvatureAt(p)),Math.abs(this.signedPlanarCurvatureAt(g)),Math.abs(this.signedPlanarCurvatureAt(y)));r*m>.85&&d.push(y)}if(d.length===0)break;if(u=tA(u,d),u.length>e){u=u.slice(0,e);break}}var v=[],x=[];return u.forEach(function(_){var b=i.evaluate(_);v.push(new Ie(b.point[0],b.point[1]));var w=b.deriv1[0],C=b.deriv1[1],E=Math.hypot(w,C);x.push(E>1e-10?new Ie(w/E,C/E):new Ie(1,0))}),{points:v,tangents:x}},n.prototype.length=function(){var t=this._controlPoints.map(function(e){return[e.x,e.y,e.z]});return xE(this._degree,this._knots,t,this._weights)},n.byKnotsControlPointsWeights=function(t,e,i,r){return new n(t,e,i,r)},n.byPoints=function(t,e,i,r,s){i===void 0&&(i="Uniform");var o=gE(t,e,i,r,s),a=o.controlPoints.map(function(l){return{x:l[0],y:l[1],z:l[2]}});return new n(e,o.knots,a,o.weights)},n.prototype.getParameterRange=function(){var t=this._knots[this._degree],e=this._knots[this._knots.length-this._degree-1];return{start:t,end:e}},n.prototype.getPoints=function(t){for(var e=[],i=this.getParameterRange(),r=i.start,s=i.end,o=0;o<=t;o++){var a=r+(s-r)*(o/t);e.push(this.point(a))}return e},n.prototype.isClosed=function(t){t===void 0&&(t=1e-6);var e=this.getParameterRange(),i=e.start,r=e.end,s=this.point(i),o=this.point(r),a=s[0]-o[0],l=s[1]-o[1],c=s[2]-o[2];return Math.sqrt(a*a+l*l+c*c)<t},n.createFitPointsForClosedCurve=function(t){if(t.length<4)throw new Error("At least 4 points are required for a closed NURBS curve");var e=new ZE(t,!0,"centripetal"),i=Math.max(50,t.length*2);return e.getPoints(i)},n.prototype.nearestPoint=function(t,e){var i;e===void 0&&(e=64);for(var r=this.getParameterRange(),s=r.start,o=r.end,a=this.point(s),l=c0(t,a),c=0;c<=e;c++){var u=s+(o-s)*c/e,h=this.point(u),d=c0(t,h);d<l&&(l=d,a=h)}return{x:a[0],y:a[1],z:(i=a[2])!==null&&i!==void 0?i:0}},n.createClosedCurve=function(t,e,i){i===void 0&&(i="Chord");var r=this.createFitPointsForClosedCurve(t),s=r.map(function(o){return[o.x,o.y,o.z]});return n.byPoints(s,e,i)},n})();function QE(n,t,e){if(e<2)return[n,t];for(var i=[],r=0;r<e;r++)i.push(r===e-1?t:n+(t-n)*r/(e-1));return i}function tA(n,t){var e=_o(_o([],vo(n),!1),vo(t),!1).sort(function(r,s){return r-s}),i=[];return e.forEach(function(r){var s=i[i.length-1];(s===void 0||Math.abs(s-r)>1e-10)&&i.push(r)}),i}var hi=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Qa=128,Pc=96,Kt=Jy.equalPointTol,Xd=Kt*8;function eA(n,t,e,i,r){var s,o,a,l;e===void 0&&(e=!1),i===void 0&&(i=!1);var c=u0(n,e,r),u=u0(t,i,r),h=[];try{for(var d=hi(c),f=d.next();!f.done;f=d.next()){var p=f.value;try{for(var g=(a=void 0,hi(u)),y=g.next();!y.done;y=g.next()){var m=y.value;$d(p,m)&&Qd(h,m0(p,m))}}catch(v){a={error:v}}finally{try{y&&!y.done&&(l=g.return)&&l.call(g)}finally{if(a)throw a.error}}}}catch(v){s={error:v}}finally{try{f&&!f.done&&(o=d.return)&&o.call(d)}finally{if(s)throw s.error}}return vA(h)}function u0(n,t,e){var i,r,s=[];try{for(var o=hi(n),a=o.next();!a.done;a=o.next()){var l=a.value,c=t&&l.extendable!==!1;switch(l.kind){case"line":{var u=sA(l.line,e);if(!u)break;var h=c?"unbounded":l.extent;s.push(xo(u.start,u.end,h));break}case"circArc":{var d=iA(l.arc,c);if(e&&!tl(d.normal,e.normal)){var f=aA(d,e);(f==null?void 0:f.kind)==="circArc"?s.push(h0(f.arc,ir(f.arc))):(f==null?void 0:f.kind)==="ellipseArc"?s.push(d0(f.arc,Rr(f.arc))):jd(s,f0(d,ir(d)),ir(d),e)}else{var f=oA(d,e);f&&s.push(h0(f,ir(f)))}break}case"ellipseArc":{var d=rA(l.arc,c);if(e&&!tl(d.normal,e.normal))jd(s,p0(d,Rr(d)),Rr(d),e);else{var f=lA(d,e);f&&s.push(d0(f,Rr(f)))}break}case"spline":{e?jd(s,l.spline.getPoints(Qa),l.spline.closed,e):s.push(nA(l.spline));break}}}}catch(p){i={error:p}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s}function xo(n,t,e){var i=new _t().subVectors(t,n);return{kind:"line",start:n,dir:i,extent:e,box:e==="bounded"?new Rs().setFromPoints([n,t]):void 0}}function h0(n,t){return{kind:"circArc",arc:n,full:t||ir(n),box:n.box}}function d0(n,t){return{kind:"ellipseArc",arc:n,full:t||Rr(n),box:n.box}}function nA(n){var t,e,i=[],r=n.getPoints(Qa);if(r.length>=2)for(var s=n.closed?r.length:r.length-1,o=0;o<s;o++){var a=r[o],l=r[(o+1)%r.length];a.distanceToSquared(l)<Kt*Kt||i.push(xo(a.clone(),l.clone(),"bounded"))}var c=new Rs;try{for(var u=hi(i),h=u.next();!h.done;h=u.next()){var d=h.value;d.box&&c.union(d.box)}}catch(f){t={error:f}}finally{try{h&&!h.done&&(e=u.return)&&e.call(u)}finally{if(t)throw t.error}}return{kind:"spline",spline:n,samples:i,box:i.length>0?c:void 0}}function iA(n,t){return!t||ir(n)?n:new Za(n.center,n.radius,0,ue,n.normal,n.refVec)}function rA(n,t){return!t||Rr(n)?n:new Ja(n.center,n.normal,n.majorAxis,n.majorAxisRadius,n.minorAxisRadius,0,ue)}function sA(n,t){if(!t)return{start:n.startPoint.clone(),end:n.endPoint.clone()};var e=Pr(n.startPoint,t),i=Pr(n.endPoint,t);return e.distanceToSquared(i)<Kt*Kt?null:{start:e,end:i}}function oA(n,t){if(!t)return n;var e=Pr(n.center,t);return new Za(e,n.radius,n.startAngle,n.endAngle,t.normal.clone(),Kd(n.refVec,t.normal))}function aA(n,t){var e=Pr(n.center,t),i=n.normal.clone();if(i.lengthSq()<Kt*Kt)return null;i.normalize();var r=t.normal.clone();if(r.lengthSq()<Kt*Kt)return null;r.normalize();var s=i.dot(r),o=Math.abs(s);if(o>1-1e-8)return{kind:"circArc",arc:new Za(e,n.radius,n.startAngle,n.endAngle,r,Kd(n.refVec,r))};if(o<1e-8)return null;var a=new _t().crossVectors(i,r);if(a.lengthSq()<Kt*Kt)return null;a.normalize();var l=new Ja(e,r,a,n.radius,n.radius*o,0,ue);if(ir(n))return{kind:"ellipseArc",arc:l};var c=Pr(n.startPoint,t),u=Pr(n.endPoint,t),h=Pr(n.midPoint,t),d=wo(l,c),f=wo(l,u),p=wo(l,h),g=ne.normalizeAngle(p-d),y=ne.normalizeAngle(f-d),m=g<=y||y<1e-8?d+y:d+y+ue;return{kind:"ellipseArc",arc:new Ja(e,r,a,n.radius,n.radius*o,d,m)}}function lA(n,t){if(!t)return n;var e=Pr(n.center,t),i=Kd(n.majorAxis,t.normal);return i.lengthSq()<Kt*Kt?null:new Ja(e,t.normal.clone(),i,n.majorAxisRadius,n.minorAxisRadius,n.startAngle,n.endAngle)}function jd(n,t,e,i){if(!(t.length<2))for(var r=i?t.map(function(c){return Pr(c,i)}):t,s=e?r.length:r.length-1,o=0;o<s;o++){var a=r[o],l=r[(o+1)%r.length];a.distanceToSquared(l)<Kt*Kt||n.push(xo(a.clone(),l.clone(),"bounded"))}}function f0(n,t){return t||ir(n)?new Za(n.center,n.radius,0,ue,n.normal,n.refVec).getPoints(Pc):n.getPoints(Pc)}function p0(n,t){return t||Rr(n)?new Ja(n.center,n.normal,n.majorAxis,n.majorAxisRadius,n.minorAxisRadius,0,ue).getPoints(Pc):n.getPoints(Pc)}function $d(n,t){return!n.box||!t.box?!0:n.box.intersectsBox(t.box)}function m0(n,t){return n.kind==="spline"&&t.kind==="spline"?cA(n,t):n.kind==="spline"?g0(n,t):t.kind==="spline"?g0(t,n):n.kind==="line"&&t.kind==="line"?y0(n,t):n.kind==="line"&&t.kind==="circArc"?Rc(n,t.arc,t.full):t.kind==="line"&&n.kind==="circArc"?Rc(t,n.arc,n.full):n.kind==="line"&&t.kind==="ellipseArc"?Yd(n,t.arc,t.full):t.kind==="line"&&n.kind==="ellipseArc"?Yd(t,n.arc,n.full):n.kind==="circArc"&&t.kind==="circArc"?pA(n.arc,n.full,t.arc,t.full):n.kind==="circArc"&&t.kind==="ellipseArc"?v0(n.arc,n.full,t.arc,t.full):n.kind==="ellipseArc"&&t.kind==="circArc"?v0(t.arc,t.full,n.arc,n.full):n.kind==="ellipseArc"&&t.kind==="ellipseArc"?gA(n.arc,n.full,t.arc,t.full):[]}function g0(n,t){var e,i,r=[];try{for(var s=hi(n.samples),o=s.next();!o.done;o=s.next()){var a=o.value;$d(a,t)&&Qd(r,m0(a,t))}}catch(l){e={error:l}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(e)throw e.error}}return uA(n.spline,r,t)}function cA(n,t){var e,i,r,s,o,a,l=[];try{for(var c=hi(n.samples),u=c.next();!u.done;u=c.next()){var h=u.value;try{for(var d=(r=void 0,hi(t.samples)),f=d.next();!f.done;f=d.next()){var p=f.value;$d(h,p)&&Qd(l,y0(h,p))}}catch(b){r={error:b}}finally{try{f&&!f.done&&(s=d.return)&&s.call(d)}finally{if(r)throw r.error}}}}catch(b){e={error:b}}finally{try{u&&!u.done&&(i=c.return)&&i.call(c)}finally{if(e)throw e.error}}var g=[];try{for(var y=hi(l),m=y.next();!m.done;m=y.next()){var v=m.value,x=n.spline.nearestPoint(v,Qa),_=t.spline.nearestPoint(v,Qa);x.distanceTo(_)<=Xd&&g.push(x)}}catch(b){o={error:b}}finally{try{m&&!m.done&&(a=y.return)&&a.call(y)}finally{if(o)throw o.error}}return g}function uA(n,t,e){var i,r,s=[];try{for(var o=hi(t),a=o.next();!a.done;a=o.next()){var l=a.value,c=n.nearestPoint(l,Qa);hA(e,c)<=Xd&&s.push(c)}}catch(u){i={error:u}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s}function hA(n,t){if(n.kind==="line"){var e=n.dir.lengthSq();if(e<Kt*Kt)return Number.POSITIVE_INFINITY;var i=new _t().subVectors(t,n.start).dot(n.dir)/e;return bo(i,n.extent)?So(n.start,n.dir,i).distanceTo(t):Number.POSITIVE_INFINITY}if(n.kind==="circArc"){if(!Jd(t,n.arc)){var r=Mi(n.arc.normal,n.arc.center),s=Math.abs(r.distanceToPoint(t)),o=Math.abs(t.distanceTo(n.arc.center)-n.arc.radius),a=Math.hypot(s,o);if(a>Xd)return a}return Bs(n.arc,Os(n.arc,t),n.full)?0:Number.POSITIVE_INFINITY}return n.kind==="ellipseArc"?Mo(t,n.arc,n.full)?0:Math.abs(kc(n.arc,t)):Number.POSITIVE_INFINITY}function y0(n,t){var e=n.dir,i=t.dir,r=e.lengthSq(),s=i.lengthSq();if(r<Kt*Kt||s<Kt*Kt)return[];var o=new _t().subVectors(n.start,t.start),a=e.dot(e),l=e.dot(i),c=i.dot(i),u=e.dot(o),h=i.dot(o),d=a*c-l*l;if(Math.abs(d)<Oe*Oe*a*c)return[];var f=(l*h-c*u)/d,p=(a*h-l*u)/d;if(!bo(f,n.extent)||!bo(p,t.extent))return[];var g=So(n.start,e,f),y=So(t.start,i,p);return g.distanceTo(y)>Kt?[]:[g]}function Rc(n,t,e){var i=Mi(t.normal,t.center),r=x0(n,i);return r==="coplanar"?dA(n,t,e):r?Jd(r,t)?Bs(t,Os(t,r),e)?[r]:[]:[]:[]}function dA(n,t,e){var i,r,s=new _t().subVectors(n.start,t.center),o=n.dir.dot(n.dir);if(o<Kt*Kt)return[];var a=2*n.dir.dot(s),l=s.dot(s)-t.radius*t.radius,c=[];try{for(var u=hi(S0(o,a,l)),h=u.next();!h.done;h=u.next()){var d=h.value;if(bo(d,n.extent)){var f=So(n.start,n.dir,d);Bs(t,Os(t,f),e)&&c.push(f)}}}catch(p){i={error:p}}finally{try{h&&!h.done&&(r=u.return)&&r.call(u)}finally{if(i)throw i.error}}return c}function Yd(n,t,e){var i=Mi(t.normal,t.center),r=x0(n,i);return r==="coplanar"?fA(n,t,e):r?Mo(r,t,e)?[r]:[]:[]}function fA(n,t,e){var i,r,s=t.majorAxis,o=t.minorAxis,a=t.majorAxisRadius,l=t.minorAxisRadius;if(a<Kt||l<Kt)return[];var c=new _t().subVectors(n.start,t.center),u=c.dot(s),h=c.dot(o),d=n.dir.dot(s),f=n.dir.dot(o),p=d*d/(a*a)+f*f/(l*l),g=2*u*d/(a*a)+2*h*f/(l*l),y=u*u/(a*a)+h*h/(l*l)-1,m=[];try{for(var v=hi(S0(p,g,y)),x=v.next();!x.done;x=v.next()){var _=x.value;if(bo(_,n.extent)){var b=So(n.start,n.dir,_);Zd(t,wo(t,b),e)&&m.push(b)}}}catch(w){i={error:w}}finally{try{x&&!x.done&&(r=v.return)&&r.call(v)}finally{if(i)throw i.error}}return m}function pA(n,t,e,i){if(tl(n.normal,e.normal)){var r=Mi(n.normal,n.center);return Math.abs(r.distanceToPoint(e.center))>Kt?[]:yA(mA(n,e),n,t,e,i)}var s=qd(Mi(n.normal,n.center),Mi(e.normal,e.center));if(!s)return[];var o=xo(s.point.clone(),new Be().addVectors(s.point,s.dir),"unbounded"),a=Rc(o,n,t);return a.filter(function(l){return Jd(l,e)?Bs(e,Os(e,l),i):!1})}function mA(n,t){var e=new _t().subVectors(t.center,n.center),i=e.length(),r=n.radius,s=t.radius;if(i<Kt&&Ae.equal(r,s,Kt))return[];if(i>r+s+Kt)return[];if(i+Math.min(r,s)+Kt<Math.max(r,s))return[];var o=i<Kt?b0(n.normal):e.clone().normalize(),a=(r*r-s*s+i*i)/(2*Math.max(i,Kt)),l=r*r-a*a,c=new Be().copy(n.center).addScaledVector(o,a);if(l<-Kt*Kt)return[];if(l<Kt*Kt)return[c];var u=Math.sqrt(Math.max(0,l)),h=new _t().crossVectors(n.normal,o).normalize();return[new Be().copy(c).addScaledVector(h,u),new Be().copy(c).addScaledVector(h,-u)]}function v0(n,t,e,i){if(!tl(n.normal,e.normal)){var r=qd(Mi(n.normal,n.center),Mi(e.normal,e.center));if(!r)return[];var s=xo(r.point.clone(),new Be().addVectors(r.point,r.dir),"unbounded");return Rc(s,n,t).filter(function(o){return Mo(o,e,i)})}return _0(f0(n,t),ir(n)||t,function(o){return kc(e,o)},function(o){return Bs(n,Os(n,o),t)&&Mo(o,e,i)})}function gA(n,t,e,i){if(!tl(n.normal,e.normal)){var r=qd(Mi(n.normal,n.center),Mi(e.normal,e.center));if(!r)return[];var s=xo(r.point.clone(),new Be().addVectors(r.point,r.dir),"unbounded");return Yd(s,n,t).filter(function(o){return Mo(o,e,i)})}return _0(p0(n,t),Rr(n)||t,function(o){return kc(e,o)},function(o){return Zd(n,wo(n,o),t)&&Mo(o,e,i)})}function _0(n,t,e,i){for(var r=[],s=t?n.length:n.length-1,o=0;o<s;o++){var a=n[o],l=n[(o+1)%n.length],c=e(a),u=e(l);if(Math.abs(c)<=Kt){i(a)&&r.push(a.clone());continue}if(!(c*u>0)){for(var h=0,d=1,f=c,p=0;p<40;p++){var g=(h+d)/2,y=new Be().lerpVectors(a,l,g),m=e(y);f*m<=0?d=g:(h=g,f=m)}var v=new Be().lerpVectors(a,l,(h+d)/2);i(v)&&r.push(v)}}return r}function x0(n,t){var e=t.normal.dot(n.dir),i=t.distanceToPoint(n.start);if(Ae.equalToZero(e,Kt*Math.max(1,n.dir.length())))return Ae.equalToZero(i,Kt)?"coplanar":null;var r=-i/e;return bo(r,n.extent)?So(n.start,n.dir,r):null}function qd(n,t){var e=new _t().crossVectors(n.normal,t.normal);if(e.lengthSq()<Kt*Kt)return null;e.normalize();var i=n.normal,r=t.normal,s=i.dot(i)*r.dot(r)-Math.pow(i.dot(r),2);if(Math.abs(s)<Oe)return null;var o=-n.constant,a=-t.constant,l=(r.dot(r)*o-i.dot(r)*a)/s,c=(i.dot(i)*a-i.dot(r)*o)/s,u=new Be().addScaledVector(i,l).addScaledVector(r,c);return{point:u,dir:e}}function bo(n,t){return t==="unbounded"?!0:t==="ray"?n>=-Kt:n>=-Kt&&n<=1+Kt}function So(n,t,e){return new Be().copy(n).addScaledVector(t,e)}function Pr(n,t){var e=new Be;return t.projectPoint(n,e),e}function Kd(n,t){var e=n.clone().addScaledVector(t,-n.dot(t));return e.lengthSq()<Kt*Kt?b0(t):e.normalize()}function Mi(n,t){return new Ud().setFromNormalAndCoplanarPoint(n,t)}function tl(n,t){return new _t().crossVectors(n,t).lengthSq()<Kt*Kt}function Os(n,t){var e=new _t().subVectors(t,n.center),i=new _t().crossVectors(n.normal,n.refVec);return Math.atan2(e.dot(i),e.dot(n.refVec))}function wo(n,t){var e=new _t().subVectors(t,n.center),i=e.dot(n.majorAxis)/n.majorAxisRadius,r=e.dot(n.minorAxis)/n.minorAxisRadius;return Math.atan2(r,i)}function ir(n){return n.closed||Math.abs(n.deltaAngle-ue)<1e-10}function Rr(n){return n.closed||Math.abs(n.endAngle-n.startAngle)<1e-10||Math.abs(n.deltaAngle-ue)<1e-10}function Bs(n,t,e){if(e||ir(n))return!0;var i=ne.normalizeAngle(t-n.startAngle);return i<=n.deltaAngle+1e-8}function Zd(n,t,e){if(e||Rr(n))return!0;var i=ne.normalizeAngle(t-n.startAngle);return i<=n.deltaAngle+1e-8}function Jd(n,t){var e=Mi(t.normal,t.center);return Math.abs(e.distanceToPoint(n))>Kt?!1:Math.abs(n.distanceTo(t.center)-t.radius)<=Kt}function kc(n,t){var e=new _t().subVectors(t,n.center),i=e.dot(n.majorAxis)/n.majorAxisRadius,r=e.dot(n.minorAxis)/n.minorAxisRadius;return i*i+r*r-1}function Mo(n,t,e){var i=Mi(t.normal,t.center);return Math.abs(i.distanceToPoint(n))>Kt||Math.abs(kc(t,n))>1e-4?!1:Zd(t,wo(t,n),e)}function yA(n,t,e,i,r){return n.filter(function(s){return Bs(t,Os(t,s),e)&&Bs(i,Os(i,s),r)})}function b0(n){var t=Math.abs(n.x)<.9?_t.X_AXIS:_t.Y_AXIS,e=new _t().crossVectors(n,t);return e.lengthSq()<Kt*Kt&&e.crossVectors(n,_t.Z_AXIS),e.normalize()}function S0(n,t,e){if(Math.abs(n)<Oe)return Math.abs(t)<Oe?[]:[-e/t];var i=t*t-4*n*e;if(i<-Kt)return[];if(i<Kt)return[-t/(2*n)];var r=Math.sqrt(Math.max(0,i));return[(-t-r)/(2*n),(-t+r)/(2*n)]}function Qd(n,t){var e,i;try{for(var r=hi(t),s=r.next();!s.done;s=r.next()){var o=s.value;n.push(o)}}catch(a){e={error:a}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(e)throw e.error}}}function vA(n){var t,e,i=[],r=function(l){if(i.some(function(c){return c.distanceTo(l)<=Kt}))return"continue";i.push(l)};try{for(var s=hi(n),o=s.next();!o.done;o=s.next()){var a=o.value;r(a)}}catch(l){t={error:l}}finally{try{o&&!o.done&&(e=s.return)&&e.call(s)}finally{if(t)throw t.error}}return i}for(var Ns=256,w0=[],M0=256,Oc;Ns--;)w0[Ns]=(Ns+256).toString(16).substring(1);function _A(n){var t=0,e=11;if(!Oc||Ns+e>M0*2)for(Oc="",Ns=0;t<M0;t++)Oc+=w0[Math.random()*256|0];return Oc.substring(Ns,Ns+++e)}var Bc=function(){return Bc=Object.assign||function(n){for(var t,e=1,i=arguments.length;e<i;e++){t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},Bc.apply(this,arguments)},E0=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Nc=(function(){function n(t){var e,i;if(this._values=[],t)try{for(var r=E0(t),s=r.next();!s.done;s=r.next()){var o=s.value;this._values.push(Bc({},o))}}catch(a){e={error:a}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(e)throw e.error}}}return Object.defineProperty(n.prototype,"length",{get:function(){return this._values.length},enumerable:!1,configurable:!0}),n.prototype.at=function(t){return this._values[t]},n.prototype.add=function(t){this._values.push(t)},n.prototype.addRange=function(t){var e,i;try{for(var r=E0(t),s=r.next();!s.done;s=r.next()){var o=s.value;this._values.push(o)}}catch(a){e={error:a}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(e)throw e.error}}},n.prototype.clear=function(){this._values.length=0},n.prototype.toArray=function(){return this._values.map(function(t){return Bc({},t)})},n.prototype.clone=function(){return new n(this._values)},n.prototype[Symbol.iterator]=function(){return this._values[Symbol.iterator]()},n})(),A0=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(c){return function(u){return l([c,u])}}function l(c){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(e=0)),e;)try{if(i=1,r&&(s=c[0]&2?r.return:c[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,c[1])).done)return s;switch(r=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return e.label++,{value:c[1],done:!1};case 5:e.label++,r=c[1],c=[0];continue;case 7:c=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){e=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){e.label=c[1];break}if(c[0]===6&&e.label<s[1]){e.label=s[1],s=c;break}if(s&&e.label<s[2]){e.label=s[2],e.ops.push(c);break}s[2]&&e.ops.pop(),e.trys.pop();continue}c=t.call(n,e)}catch(u){c=[6,u],r=0}finally{i=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},Cn=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},tf=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},ef="TEMP_",el=(function(){function n(t,e){t=t||{},this._attrs=new Vy(t,e),this._attrs.get("objectId")||(this._database?this._attrs.set("objectId",this._database.generateHandle()):this._attrs.set("objectId",this.generateTemporaryHandle()))}return n.prototype.generateTemporaryHandle=function(){return ef+_A()},Object.defineProperty(n.prototype,"attrs",{get:function(){return this._attrs},enumerable:!1,configurable:!0}),n.prototype.getAttr=function(t){var e=this._attrs.get(t);if(e===void 0)throw new Error("[AcDbObject] Attribute name '".concat(t,"' does't exist in this object!"));return e},n.prototype.getAttrWithoutException=function(t){return this._attrs.get(t)},n.prototype.setAttr=function(t,e){this._attrs.set(t,e)},Object.defineProperty(n.prototype,"objectId",{get:function(){return this.getAttr("objectId")},set:function(t){this._attrs.set("objectId",t),t&&!t.startsWith(ef)&&this._database&&this._database.updateMaxHandle(t)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isTemp",{get:function(){var t=this.getAttrWithoutException("objectId");return!!t&&t.startsWith(ef)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"ownerId",{get:function(){return this.getAttr("ownerId")},set:function(t){this._attrs.set("ownerId",t)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"extensionDictionary",{get:function(){return this.getAttrWithoutException("extensionDictionary")},set:function(t){this._attrs.set("extensionDictionary",t)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"database",{get:function(){if(this._database)return this._database;throw new Error("The current working database must be set before using it!")},set:function(t){this.assignDatabase(t)},enumerable:!1,configurable:!0}),n.prototype.assignDatabase=function(t){this._database!==t&&(this._database=t,this.onDatabaseChanged(t))},n.prototype.onDatabaseChanged=function(t){},n.prototype.findImportedXDataRange=function(t){var e,i=this._importedXData;if(i)for(var r=0;r<i.length;){if(Number(i[r])!==ci.ExtendedDataRegAppName){r+=2;continue}for(var s=String((e=i[r+1])!==null&&e!==void 0?e:""),o=r+2;o<i.length&&Number(i[o])!==ci.ExtendedDataRegAppName;)o+=2;if(s===t)return[r,o];r=o}},n.prototype.removeImportedXData=function(t){var e=this._importedXData,i=this.findImportedXDataRange(t);!e||!i||(e.splice(i[0],i[1]-i[0]),e.length===0&&(this._importedXData=void 0))},n.prototype.rememberXDataApp=function(t){var e;if(t){var i=(e=this._xDataOrder)!==null&&e!==void 0?e:this._xDataOrder=[];i.indexOf(t)===-1&&i.push(t)}},n.prototype.forgetXDataApp=function(t){var e=this._xDataOrder;if(e){var i=e.indexOf(t);i>=0&&e.splice(i,1),e.length===0&&(this._xDataOrder=void 0)}},n.prototype.clearMaterializedXData=function(t){var e=this._xDataMap;e&&(e.delete(t),e.size===0&&(this._xDataMap=void 0))},n.prototype.onXDataChanged=function(t){},n.prototype.notifyXDataChanged=function(t){this.onXDataChanged(t)},n.prototype.importedXDataValues=function(t,e){var i,r;return A0(this,function(s){switch(s.label){case 0:if(i=this._importedXData,!i)return[2];r=t,s.label=1;case 1:return r<e?[4,{code:Number(i[r]),value:i[r+1]}]:[3,4];case 2:s.sent(),s.label=3;case 3:return r+=2,[3,1];case 4:return[2]}})},n.prototype.setImportedXData=function(t){var e,i,r,s,o,a,l,c=[],u,h;try{for(var d=Cn(t),f=d.next();!f.done;f=d.next()){var p=f.value,g=Number(p.code);if(g===ci.ExtendedDataRegAppName){u&&h&&c.push({appId:u,flat:h}),u=String(p.value),h=[g,p.value];continue}!u||!h||h.push(g,p.value)}}catch(C){e={error:C}}finally{try{f&&!f.done&&(i=d.return)&&i.call(d)}finally{if(e)throw e.error}}if(u&&h&&c.push({appId:u,flat:h}),c.length!==0)try{for(var y=Cn(c),m=y.next();!m.done;m=y.next()){var v=m.value;if(v.appId){this.removeImportedXData(v.appId),this.clearMaterializedXData(v.appId);var x=(l=this._importedXData)!==null&&l!==void 0?l:this._importedXData=[];try{for(var _=(o=void 0,Cn(v.flat)),b=_.next();!b.done;b=_.next()){var w=b.value;x.push(w)}}catch(C){o={error:C}}finally{try{b&&!b.done&&(a=_.return)&&a.call(_)}finally{if(o)throw o.error}}this.rememberXDataApp(v.appId),this.notifyXDataChanged(v.appId)}}}catch(C){r={error:C}}finally{try{m&&!m.done&&(s=y.return)&&s.call(y)}finally{if(r)throw r.error}}},n.prototype.getXData=function(t){var e,i,r,s,o=(r=this._xDataMap)===null||r===void 0?void 0:r.get(t);if(o)return o;var a=this.findImportedXDataRange(t);if(a){var l=new Nc;try{for(var c=Cn(this.importedXDataValues(a[0],a[1])),u=c.next();!u.done;u=c.next()){var h=u.value;l.add(h)}}catch(d){e={error:d}}finally{try{u&&!u.done&&(i=c.return)&&i.call(c)}finally{if(e)throw e.error}}return this.removeImportedXData(t),((s=this._xDataMap)!==null&&s!==void 0?s:this._xDataMap=new Map).set(t,l),l}},n.prototype.iterateXData=function(t){var e,i,r;return A0(this,function(s){switch(s.label){case 0:return e=(r=this._xDataMap)===null||r===void 0?void 0:r.get(t),e?[5,Cn(e)]:[3,2];case 1:return s.sent(),[2];case 2:return i=this.findImportedXDataRange(t),i?[5,Cn(this.importedXDataValues(i[0],i[1]))]:[2];case 3:return s.sent(),[2]}})},n.prototype.setXData=function(t){var e,i,r;try{for(var s=Cn(t),o=s.next();!o.done;o=s.next()){var a=o.value;if(a.code===ci.ExtendedDataRegAppName){var l=a.value;this.removeImportedXData(l),((r=this._xDataMap)!==null&&r!==void 0?r:this._xDataMap=new Map).set(l,t),this.rememberXDataApp(l),this.notifyXDataChanged(l)}}}catch(c){e={error:c}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(e)throw e.error}}},n.prototype.removeXData=function(t){this.removeImportedXData(t),this.clearMaterializedXData(t),this.forgetXDataApp(t),this.notifyXDataChanged(t)},n.prototype.createExtensionDictionary=function(){var t=this.extensionDictionary;if(t)return t;var e=this.database;if(e)return e.createExtensionDictionaryFor(this)},n.prototype.close=function(){},n.prototype.getOwnSnapshotKeys=function(){return Reflect.ownKeys(this).filter(function(t){return typeof t=="string"&&!n.SNAPSHOT_EXCLUDED_KEYS.has(t)})},n.prototype.cloneAttrs=function(t){var e=this.cloneValue(t.attributes);return new Vy(e)},n.prototype.restoreAttrsFrom=function(t){var e,i,r=this.cloneValue(t.attributes),s=this._attrs.attributes;try{for(var o=Cn(Object.keys(s)),a=o.next();!a.done;a=o.next()){var l=a.value;l in r||this._attrs.set(l,void 0,{unset:!0,silent:!0})}}catch(c){e={error:c}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(e)throw e.error}}this._attrs.set(r,{silent:!0})},n.prototype.restoreXDataMapFrom=function(t){var e,i;if(!t||t.size===0){this._xDataMap=void 0;return}var r=new Map;try{for(var s=Cn(t.entries()),o=s.next();!o.done;o=s.next()){var a=tf(o.value,2),l=a[0],c=a[1];r.set(l,this.cloneValue(c))}}catch(u){e={error:u}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(e)throw e.error}}this._xDataMap=r},n.prototype.copySnapshotStateTo=function(t){var e,i;t._attrs=this.cloneAttrs(this._attrs),t._xDataMap=this._xDataMap?this.cloneValue(this._xDataMap):void 0;var r=this,s=t;try{for(var o=Cn(this.getOwnSnapshotKeys()),a=o.next();!a.done;a=o.next()){var l=a.value;n.SNAPSHOT_INTERNAL_KEYS.has(l)||(s[l]=this.cloneValue(r[l]))}}catch(c){e={error:c}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(e)throw e.error}}},n.prototype.clone=function(){var t=Object.create(Object.getPrototypeOf(this));return this.copySnapshotStateTo(t),t.objectId=this.generateTemporaryHandle(),t},n.prototype.clonePreservingIdentity=function(){var t=this.clone(),e=this.getAttrWithoutException("objectId");e&&t._attrs.set("objectId",e);var i=this.getAttrWithoutException("ownerId");return i!==void 0&&t._attrs.set("ownerId",i),this._database&&(t._database=this._database),t},n.prototype.restoreFrom=function(t){var e,i,r,s,o=this.objectId,a=this._database;this.restoreAttrsFrom(t._attrs),this.restoreXDataMapFrom(t._xDataMap);var l=t,c=this,u=new Set(t.getOwnSnapshotKeys());try{for(var h=Cn(u),d=h.next();!d.done;d=h.next()){var f=d.value;n.SNAPSHOT_INTERNAL_KEYS.has(f)||n.SNAPSHOT_EXCLUDED_KEYS.has(f)||(c[f]=this.cloneValue(l[f]))}}catch(y){e={error:y}}finally{try{d&&!d.done&&(i=h.return)&&i.call(h)}finally{if(e)throw e.error}}try{for(var p=Cn(this.getOwnSnapshotKeys()),g=p.next();!g.done;g=p.next()){var f=g.value;n.SNAPSHOT_INTERNAL_KEYS.has(f)||n.SNAPSHOT_EXCLUDED_KEYS.has(f)||u.has(f)||delete c[f]}}catch(y){r={error:y}}finally{try{g&&!g.done&&(s=p.return)&&s.call(p)}finally{if(r)throw r.error}}this.objectId=o,a&&(this.database=a)},n.prototype.cloneValue=function(t){var e,i,r,s,o,a,l=this;if(t==null||typeof t!="object")return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp)return new RegExp(t.source,t.flags);if(Array.isArray(t))return t.map(function(C){return l.cloneValue(C)});if(t instanceof Map){var c=new Map;try{for(var u=Cn(t.entries()),h=u.next();!h.done;h=u.next()){var d=tf(h.value,2),f=d[0],p=d[1];c.set(this.cloneValue(f),this.cloneValue(p))}}catch(C){e={error:C}}finally{try{h&&!h.done&&(i=u.return)&&i.call(u)}finally{if(e)throw e.error}}return c}if(t instanceof Set){var g=new Set;try{for(var y=Cn(t.values()),m=y.next();!m.done;m=y.next()){var p=m.value;g.add(this.cloneValue(p))}}catch(C){r={error:C}}finally{try{m&&!m.done&&(s=y.return)&&s.call(y)}finally{if(r)throw r.error}}return g}if(ArrayBuffer.isView(t)){if(t instanceof DataView)return new DataView(t.buffer.slice(0));var v=t.constructor;return new v(t)}if(t instanceof ArrayBuffer)return t.slice(0);if(typeof Blob<"u"&&t instanceof Blob||t&&typeof t=="object"&&"tables"in t&&"transactionManager"in t)return t;if("clone"in t&&typeof t.clone=="function")return t.clone();var x=Object.create(Object.getPrototypeOf(t)),_=t;try{for(var b=Cn(Object.keys(_)),w=b.next();!w.done;w=b.next()){var f=w.value;x[f]=this.cloneValue(_[f])}}catch(C){o={error:C}}finally{try{w&&!w.done&&(a=b.return)&&a.call(b)}finally{if(o)throw o.error}}return x},n.prototype.dxfOut=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i=tf(t,2),r=i[0],s=i[1],o=s===void 0?!1:s;return r.writeHandle(5,this.objectId),r.writeObjectId(330,this.ownerId),r.writeObjectId(360,this.extensionDictionary),this.dxfOutFields(r),o&&this.dxfOutXData(r),this},n.prototype.dxfOutXData=function(t){var e,i,r,s,o,a=this._xDataOrder;if(a){try{for(var l=Cn(a),c=l.next();!c.done;c=l.next()){var u=c.value,h=(o=this._xDataMap)===null||o===void 0?void 0:o.get(u);if(h){t.writeResultBuffer(h);continue}var d=this.findImportedXDataRange(u);d&&t.writeTypedValues(this.importedXDataValues(d[0],d[1]))}}catch(_){e={error:_}}finally{try{c&&!c.done&&(i=l.return)&&i.call(l)}finally{if(e)throw e.error}}return}var f=this._importedXData;if(f)for(var p=0;p<f.length;){for(var g=p+2;g<f.length&&Number(f[g])!==ci.ExtendedDataRegAppName;)g+=2;t.writeTypedValues(this.importedXDataValues(p,g)),p=g}var y=this._xDataMap;if(y)try{for(var m=Cn(y.values()),v=m.next();!v.done;v=m.next()){var x=v.value;t.writeResultBuffer(x)}}catch(_){r={error:_}}finally{try{v&&!v.done&&(s=m.return)&&s.call(m)}finally{if(r)throw r.error}}},n.prototype.dxfOutFields=function(t){return this},n.prototype.dxfIn=function(t){for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){var e=t.readItem();if(!e)break;var i=Number(e.code);if(i===5||i===105)this.objectId=String(e.value);else if(i===330)this.ownerId=String(e.value);else if(i===360)this.extensionDictionary=String(e.value);else if(i===102)this.dxfInControlString(t,String(e.value));else if(i===100){t.pushBackItem(e);break}else{t.pushBackItem(e);break}}return this.dxfInFields(t),t.atExtendedData&&this.dxfInXData(t),this},n.prototype.dxfInControlString=function(t,e){for(var i=e==="{ACAD_XDICTIONARY"||e==="ACAD_XDICTIONARY";!t.atEndOfObject&&!t.atEof;){var r=t.readItem();if(!r)break;var s=Number(r.code);if(s===102){var o=String(r.value);if(o==="}"||o==="")break;this.dxfInControlString(t,o);continue}i&&s===360&&!this.extensionDictionary&&(this.extensionDictionary=String(r.value))}},n.prototype.dxfInFields=function(t){return this},n.prototype.dxfInXData=function(t){for(var e=this,i,r=function(){i&&i.length>0&&e.setXData(i),i=void 0};!t.atEndOfObject&&!t.atEof;){var s=t.readItem();if(!s)break;var o=Number(s.code);if(o===1001)r(),i=new Nc([{code:s.code,value:s.value}]);else if(o>=1e3&&o<=1071)i||(i=new Nc),i.add({code:s.code,value:s.value});else{t.pushBackItem(s);break}}r()},n.SNAPSHOT_EXCLUDED_KEYS=new Set(["_database","transactionManager"]),n.SNAPSHOT_INTERNAL_KEYS=new Set(["_attrs","_xDataMap"]),n})(),Eo;(function(n){n[n.ByBlock=-2]="ByBlock",n[n.ByDIPs=-4]="ByDIPs",n[n.ByLayer=-1]="ByLayer",n[n.ByLineWeightDefault=-3]="ByLineWeightDefault",n[n.LineWeight000=0]="LineWeight000",n[n.LineWeight005=5]="LineWeight005",n[n.LineWeight009=9]="LineWeight009",n[n.LineWeight013=13]="LineWeight013",n[n.LineWeight015=15]="LineWeight015",n[n.LineWeight018=18]="LineWeight018",n[n.LineWeight020=20]="LineWeight020",n[n.LineWeight025=25]="LineWeight025",n[n.LineWeight030=30]="LineWeight030",n[n.LineWeight035=35]="LineWeight035",n[n.LineWeight040=40]="LineWeight040",n[n.LineWeight050=50]="LineWeight050",n[n.LineWeight053=53]="LineWeight053",n[n.LineWeight060=60]="LineWeight060",n[n.LineWeight070=70]="LineWeight070",n[n.LineWeight080=80]="LineWeight080",n[n.LineWeight090=90]="LineWeight090",n[n.LineWeight100=100]="LineWeight100",n[n.LineWeight106=106]="LineWeight106",n[n.LineWeight120=120]="LineWeight120",n[n.LineWeight140=140]="LineWeight140",n[n.LineWeight158=158]="LineWeight158",n[n.LineWeight200=200]="LineWeight200",n[n.LineWeight211=211]="LineWeight211"})(Eo||(Eo={}));var Dc=(function(){function n(t){t===void 0&&(t={});var e,i,r,s;this.database=t.database,this.foregroundOnDark=(e=t.foregroundOnDark)!==null&&e!==void 0?e:nf,this.foregroundOnLight=(i=t.foregroundOnLight)!==null&&i!==void 0?i:rf,this.backgroundIsDark=(r=t.backgroundIsDark)!==null&&r!==void 0?r:!0,this.fallbackRgb=(s=t.fallbackRgb)!==null&&s!==void 0?s:16777215}return n.prototype.resolveSubEntityTraitsRgb=function(t){var e,i,r,s=t.color;return s.isForeground?this.backgroundIsDark?this.foregroundOnDark:this.foregroundOnLight:s.isByLayer||s.isByBlock?(e=this.fallbackRgb)!==null&&e!==void 0?e:16777215:(r=(i=s.RGB)!==null&&i!==void 0?i:this.fallbackRgb)!==null&&r!==void 0?r:16777215},n.fromBackgroundColor=function(t,e){return t===void 0&&(t=xA),new n({database:e,foregroundOnDark:nf,foregroundOnLight:rf,backgroundIsDark:!SA(t),fallbackRgb:16777215})},n})(),xA=0,nf=16777215,rf=0,Uc=16777215,bA=128;new Dc({database:void 0,foregroundOnDark:nf,foregroundOnLight:rf,backgroundIsDark:!0,fallbackRgb:16777215});function SA(n){var t=n>>16&255,e=n>>8&255,i=n&255;return .299*t+.587*e+.114*i>bA}function zc(n){var t=Dc.fromBackgroundColor(n);return t.backgroundIsDark?t.foregroundOnDark:t.foregroundOnLight}var C0="Continuous",nl="ByLayer",T0="ByBlock",Ds;(function(n){n[n.OnBothOperands=0]="OnBothOperands",n[n.ExtendThis=1]="ExtendThis",n[n.ExtendArg=2]="ExtendArg",n[n.ExtendBoth=3]="ExtendBoth"})(Ds||(Ds={}));var wA=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),sf=function(){return sf=Object.assign||function(n){for(var t,e=1,i=arguments.length;e<i;e++){t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},sf.apply(this,arguments)},MA=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},EA=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))},AA=(function(n){wA(t,n);function t(){var e=n.apply(this,EA([],MA(arguments),!1))||this;return e._colorIsByLayerDefault=!1,e._visibility=!0,e._transparencySet=!1,e._dxfPaperSpace=!1,e}return Object.defineProperty(t.prototype,"type",{get:function(){return this.constructor.typeName},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"layer",{get:function(){var e;return this._layer==null&&(this._layer=(e=this.database.clayer)!==null&&e!==void 0?e:"0"),this._layer},set:function(e){this._layer=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"color",{get:function(){return this.getEntityColor()},set:function(e){this.setEntityColor(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"resolvedColor",{get:function(){return this.resolveStandardColor()},enumerable:!1,configurable:!0}),t.prototype.resolveStandardColor=function(){var e=this.color;if(e.isByLayer){var i=this.getLayerColor();i&&i.RGB!=null&&(e=i)}else e.isByBlock&&(e=new rn().setForeground());return e},Object.defineProperty(t.prototype,"lineType",{get:function(){var e,i;return this._lineType==null&&(this._lineType=(i=(e=this.database)===null||e===void 0?void 0:e.celtype)!==null&&i!==void 0?i:nl),this._lineType},set:function(e){e?e.toUpperCase()==="BYLAYER"?this._lineType=nl:e.toUpperCase()==="BYBLOCK"?this._lineType=T0:this._lineType=e:this._lineType=nl},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lineWeight",{get:function(){var e;return this._lineWeight==null&&(this._lineWeight=(e=this.database.celweight)!==null&&e!==void 0?e:Eo.ByLayer),this._lineWeight},set:function(e){this._lineWeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"linetypeScale",{get:function(){var e;return this._linetypeScale==null&&(this._linetypeScale=(e=this.database.celtscale)!==null&&e!==void 0?e:-1),this._linetypeScale},set:function(e){this._linetypeScale=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"visibility",{get:function(){return this._visibility},set:function(e){this._visibility=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"transparency",{get:function(){var e;return(e=this._transparency)!==null&&e!==void 0?e:this._transparency=new _c},set:function(e){this._transparency=e.clone(),this._transparencySet=!0},enumerable:!1,configurable:!0}),t.prototype.hasExplicitLayer=function(){return this._layer!=null},t.prototype.hasExplicitColor=function(){return this._color!=null||this._colorIsByLayerDefault},t.prototype.getEntityColor=function(){return this._color==null&&(this._colorIsByLayerDefault?this._color=new rn().setByLayer():(this._color=new rn,this.database.cecolor&&this._color.copy(this.database.cecolor))),this._color},t.prototype.setEntityColor=function(e){this._colorIsByLayerDefault=!1,this._color==null&&(this._color=new rn),this._color.copy(e)},t.prototype.shouldResolveColorFromCecolor=function(){return!this._colorIsByLayerDefault},t.prototype.applyDxfFileDefaults=function(){this._color==null&&(this._colorIsByLayerDefault=!0)},t.prototype.hasExplicitTransparency=function(){return this._transparencySet},t.prototype.dxfOutFields=function(e){e.writeSubclassMarker("AcDbEntity"),e.writeString(8,this.layer),e.writeString(6,this.lineType),e.writeDouble(48,this.linetypeScale),e.writeInt16(60,this.visibility?0:1),e.writeCmColor(this.color),e.writeLineWeight(370,this.lineWeight),e.writeTransparency(this.transparency);var i=this.database.tables.blockTable.getIdAt(this.ownerId);return i!=null&&i.isPaperSapce&&e.writeInt16(67,1),this},t.prototype.dxfInFields=function(e){n.prototype.dxfInFields.call(this,e);var i=e.atSubclassData("AcDbEntity");if(!i){var r=e.peekItem();if(r&&Number(r.code)===100)return this}for(var s;!e.atEndOfObject&&!e.atEof&&!e.atExtendedData;){var o=e.readItem();if(!o)break;var a=Number(o.code);if(a===100){e.pushBackItem(o);break}switch(a){case 8:this.layer=String(o.value);break;case 6:this.lineType=String(o.value);break;case 48:this.linetypeScale=Number(o.value);break;case 60:this.visibility=Number(o.value)===0;break;case 62:s==null&&(s=new rn),s.colorIndex=Number(o.value);break;case 420:s==null&&(s=new rn),s.setRGBValue(Number(o.value));break;case 370:this.lineWeight=Number(o.value);break;case 440:this.transparency=_c.deserialize(Number(o.value));break;case 67:this._dxfPaperSpace=Number(o.value)!==0;break;case 410:break;case 92:case 160:case 310:break;case 284:case 347:case 380:case 390:case 430:break;default:if(!i)return e.pushBackItem(o),s!=null&&(this.color=s),this.applyDxfFileDefaults(),this;break}}return s!=null&&(this.color=s),this.applyDxfFileDefaults(),this},Object.defineProperty(t.prototype,"dxfPaperSpace",{get:function(){return this._dxfPaperSpace},enumerable:!1,configurable:!0}),t.prototype.resolveEffectiveProperties=function(){var e,i,r,s;this._layer==null&&(this._layer=(e=this.database.clayer)!==null&&e!==void 0?e:"0"),this._color==null&&this.shouldResolveColorFromCecolor()&&(this._color=new rn,this.database.cecolor&&this._color.copy(this.database.cecolor)),this._lineType==null&&(this._lineType=(i=this.database.celtype)!==null&&i!==void 0?i:nl),this._linetypeScale==null&&(this._linetypeScale=(r=this.database.celtscale)!==null&&r!==void 0?r:-1),this._lineWeight==null&&(this._lineWeight=(s=this.database.celweight)!==null&&s!==void 0?s:Eo.ByLayer)},Object.defineProperty(t.prototype,"properties",{get:function(){return{type:this.type,groups:[this.getGeneralProperties()]}},enumerable:!1,configurable:!0}),t.prototype.subGetGripPoints=function(){var e=new Array;return e},t.prototype.subMoveGripPointsAt=function(e,i){return this},t.prototype.subGetOsnapPoints=function(e,i,r,s,o,a){},t.prototype.intersectWith=function(e,i,r){i===void 0&&(i=Ds.OnBothOperands);var s=this.subGetIntersectCurves(),o=e.subGetIntersectCurves();if(s.length===0||o.length===0)return[];var a=i===Ds.ExtendThis||i===Ds.ExtendBoth,l=i===Ds.ExtendArg||i===Ds.ExtendBoth;return eA(s,o,a,l,r)},t.prototype.subGetIntersectCurves=function(){return[]},t.prototype.transformBy=function(e){return this},t.prototype.erase=function(){return this.database.tables.blockTable.removeEntity(this.objectId)},Object.defineProperty(t.prototype,"directBatchPrimitive",{get:function(){return null},enumerable:!1,configurable:!0}),t.prototype.worldDraw=function(e,i){if(this.database.isLayerDrawable(this.layer)){var r=e.subEntityTraits;r.isColorByLayer=this.color.isByLayer,r.color=this.resolvedColor,r.lineType=this.lineStyle,r.lineTypeScale=this.linetypeScale,r.lineWeight=this.lineWeight,r.transparency=this.transparency,r.layer=this.layer,r.drawOrder=0,r.isBackgroundFill=!1,"thickness"in this&&(r.thickness=this.thickness),e.context.database=this.database;var s=this.subWorldDraw(e,i);return this.attachEntityInfo(s),s}},t.prototype.getGeneralProperties=function(){var e=this;return{groupName:"general",properties:[{name:"handle",type:"int",editable:!1,accessor:{get:function(){return e.objectId}}},{name:"color",type:"color",editable:!0,accessor:{get:function(){return e.color},set:function(i){e.color=i}}},{name:"layer",type:"string",editable:!0,accessor:{get:function(){return e.layer},set:function(i){e.layer=i}}},{name:"linetype",type:"linetype",editable:!0,accessor:{get:function(){return e.lineType},set:function(i){e.lineType=i}}},{name:"linetypeScale",type:"float",editable:!0,accessor:{get:function(){return e.linetypeScale},set:function(i){e.linetypeScale=i}}},{name:"lineWeight",type:"lineweight",editable:!0,accessor:{get:function(){return e.lineWeight},set:function(i){e.lineWeight=i}}},{name:"transparency",type:"transparency",editable:!0,accessor:{get:function(){return e.transparency},set:function(i){e.transparency=i}}}]}},Object.defineProperty(t.prototype,"lineStyle",{get:function(){var e,i=this.getLineType(),r=i.type,s=i.name,o=(e=this.database)===null||e===void 0?void 0:e.tables.linetypeTable.getAt(s);return o?sf({type:r},o.linetype):{type:r,name:s,standardFlag:0,description:"",totalPatternLength:0}},enumerable:!1,configurable:!0}),t.prototype.getLineType=function(){if(this.lineType==nl){var e=this.database.tables.layerTable.getAt(this.layer);if(e&&e.linetype)return{type:"ByLayer",name:e.linetype}}else return this.lineType==T0?{type:"ByBlock",name:C0}:{type:"UserSpecified",name:this.lineType};return{type:"UserSpecified",name:C0}},t.prototype.getLayerColor=function(){var e=this.database.tables.layerTable.getAt(this.layer);if(e==null)console.error("The layer with name '".concat(this.layer,"' not found in drawing database!"));else return e.color;return null},t.prototype.attachEntityInfo=function(e){e&&(e.objectId=this.objectId,this.attrs.has("ownerId")&&(e.ownerId=this.ownerId),e.layerName=this.layer,e.visible=this.visibility)},t.typeName="Entity",t})(el),CA=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),TA=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},LA=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))},IA=(function(n){CA(t,n);function t(){var e=n.apply(this,LA([],TA(arguments),!1))||this;return e._classVersion=4,e._isDefault=!1,e}return Object.defineProperty(t.prototype,"classVersion",{get:function(){return this._classVersion},set:function(e){this._classVersion=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isDefault",{get:function(){return this._isDefault},set:function(e){this._isDefault=e},enumerable:!1,configurable:!0}),t.prototype.dxfOutFields=function(e){return n.prototype.dxfOutFields.call(this,e),e.writeSubclassMarker("AcDbObjectContextData"),e.writeInt16(70,this._classVersion),e.writeBoolean(290,this._isDefault),this},t.prototype.dxfInObjectContextData=function(e){for(e.atSubclassData("AcDbObjectContextData");!e.atEndOfObject&&!e.atEof&&!e.atExtendedData;){var i=e.readItem();if(!i)break;var r=Number(i.code);if(r===100)return String(i.value);switch(r){case 70:this._classVersion=Number(i.value);break;case 290:this._isDefault=!!Number(i.value);break}}},t})(el),PA=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),RA=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},kA=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))},OA=(function(n){PA(t,n);function t(){var e=n.apply(this,kA([],RA(arguments),!1))||this;return e._scaleId="",e}return Object.defineProperty(t.prototype,"scaleId",{get:function(){return this._scaleId},set:function(e){this._scaleId=e},enumerable:!1,configurable:!0}),t.prototype.dxfOutFields=function(e){return n.prototype.dxfOutFields.call(this,e),e.writeSubclassMarker("AcDbAnnotScaleObjectContextData"),e.writeObjectId(340,this._scaleId),this},t})(IA),BA=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},NA=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))},L0=(function(){function n(t){this.i=0,t instanceof Map?(this._records=t,this._array=null,this._keys=Array.from(t.keys())):(this._records=null,this._array=t,this._keys=[])}return Object.defineProperty(n.prototype,"count",{get:function(){var t,e;return(e=(t=this._records)===null||t===void 0?void 0:t.size)!==null&&e!==void 0?e:this._array.length},enumerable:!1,configurable:!0}),n.prototype.toArray=function(){return this._records?Array.from(this._records.values()):NA([],BA(this._array),!1)},n.prototype[Symbol.iterator]=function(){return this},n.prototype.next=function(){if(this._array){if(this.i<this._array.length){var t=this._array[this.i];return this.i+=1,{value:t,done:!1}}return{value:null,done:!0}}for(;this.i<this._keys.length;){var t=this._records.get(this._keys[this.i]);return this.i+=1,{value:t,done:!1}}return{value:null,done:!0}},n})(),DA=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),UA=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},zA=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},Ao=(function(n){DA(t,n);function t(e){var i=n.call(this)||this;return i.database=e,i.objectId=e.generateHandle(),i._recordsByName=new Map,i}return Object.defineProperty(t.prototype,"numEntries",{get:function(){return this._recordsByName.size},enumerable:!1,configurable:!0}),t.prototype.setAt=function(e,i){var r=this,s=this.database.transactionManager;if(s.strictMode&&!s.isRecording()&&!s.isApplyingUndoRedo())throw new Error("Cannot modify dictionary entries outside an active transaction.");var o=this.getAt(e);o&&(s.isRecording()&&s.recordRemove({type:"dictionary",dictionaryId:this.objectId,key:e},o),this.database.releaseObjectHandle(o)),i.database=this.database,this.database.commitObjectHandle(i,function(a){return r.hasId(a)}),i.ownerId=this.objectId,this._recordsByName.set(e,i),s.isRecording()&&s.recordAppend({type:"dictionary",dictionaryId:this.objectId,key:e},i),!s.isRecording()&&!s.isApplyingUndoRedo()&&this.database.notifyDictObjectSet(i,e)},t.prototype.remove=function(e){var i=this.getAt(e);return i?(this.removeStoredObject(i,e),!0):!1},t.prototype.removeId=function(e){var i=this.getIdAt(e);if(i){var r="";return this._recordsByName.forEach(function(s,o){s===i&&(r=o)}),this.removeStoredObject(i,r),!0}return!1},t.prototype.removeStoredObject=function(e,i){var r=this,s=this.database.transactionManager;if(s.strictMode&&!s.isRecording()&&!s.isApplyingUndoRedo())throw new Error("Cannot remove dictionary entries outside an active transaction.");s.isRecording()&&s.recordRemove({type:"dictionary",dictionaryId:this.objectId,key:i},e),this._recordsByName.forEach(function(o,a){o===e&&r._recordsByName.delete(a)}),this.database.releaseObjectHandle(e),i&&!s.isRecording()&&!s.isApplyingUndoRedo()&&this.database.notifyDictObjectErased(e,i)},t.prototype.removeAll=function(){var e=this;this._recordsByName.forEach(function(i,r){e.database.releaseObjectHandle(i),e.database.events.dictObjectErased.dispatch({database:e.database,object:i,key:r})}),this._recordsByName.clear()},t.prototype.has=function(e){return this._recordsByName.has(e.toUpperCase())},t.prototype.hasId=function(e){return this.getIdAt(e)!==void 0},t.prototype.getAt=function(e){return this._recordsByName.get(e)},t.prototype.getIdAt=function(e){var i=this.database.getObjectById(e);if(i){var r=i.getAttrWithoutException("ownerId");if(r===this.objectId)return i}},t.prototype.newIterator=function(){return new L0(this._recordsByName)},t.prototype.entries=function(){return this._recordsByName.entries()},t.prototype.dxfOutFields=function(e){var i,r;n.prototype.dxfOutFields.call(this,e),e.writeSubclassMarker("AcDbDictionary"),e.writeInt16(280,1),e.writeInt16(281,1);try{for(var s=UA(this._recordsByName),o=s.next();!o.done;o=s.next()){var a=zA(o.value,2),l=a[0],c=a[1];e.writeString(3,l),e.writeObjectId(350,c.objectId)}}catch(u){i={error:u}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}return this},t.prototype.dxfInFields=function(e){for(n.prototype.dxfInFields.call(this,e),e.atSubclassData("AcDbDictionary");!e.atEndOfObject&&!e.atEof&&!e.atExtendedData;){var i=e.readItem();if(!i)break;var r=Number(i.code);if(r===100){e.pushBackItem(i);break}}return this},t})(el),FA=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),HA=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},GA=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))},I0=(function(n){FA(t,n);function t(){var e=n.apply(this,GA([],HA(arguments),!1))||this;return e._classVersion=0,e._scaleName="",e._paperUnits=1,e._drawingUnits=1,e._isUnitScale=!1,e}return Object.defineProperty(t.prototype,"classVersion",{get:function(){return this._classVersion},set:function(e){this._classVersion=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaleName",{get:function(){return this._scaleName},set:function(e){this._scaleName=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"paperUnits",{get:function(){return this._paperUnits},set:function(e){this._paperUnits=e>0?e:1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"drawingUnits",{get:function(){return this._drawingUnits},set:function(e){this._drawingUnits=e>0?e:1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isUnitScale",{get:function(){return this._isUnitScale},set:function(e){this._isUnitScale=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaleFactor",{get:function(){return this._drawingUnits/this._paperUnits},enumerable:!1,configurable:!0}),t.prototype.dxfOutFields=function(e){return n.prototype.dxfOutFields.call(this,e),e.writeSubclassMarker("AcDbScale"),e.writeInt16(70,this._classVersion),e.writeString(300,this._scaleName),e.writeDouble(140,this._paperUnits),e.writeDouble(141,this._drawingUnits),e.writeBoolean(290,this._isUnitScale),this},t.prototype.dxfInFields=function(e){for(n.prototype.dxfInFields.call(this,e),e.atSubclassData("AcDbScale");!e.atEndOfObject&&!e.atEof&&!e.atExtendedData;){var i=e.readItem();if(!i)break;var r=Number(i.code);if(r===100){e.pushBackItem(i);break}switch(r){case 70:this._classVersion=Number(i.value);break;case 300:this._scaleName=String(i.value);break;case 140:this.paperUnits=Number(i.value);break;case 141:this.drawingUnits=Number(i.value);break;case 290:this._isUnitScale=!!Number(i.value);break}}return this},t})(el),il=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Co=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},P0=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))},rl=function(n){return n?n.trim().toUpperCase():""},of="AcadAnnotative";function R0(n){var t,e,i=n.getXData(of);if(!i)return!1;var r=i.toArray();try{for(var s=il(r),o=s.next();!o.done;o=s.next()){var a=o.value;if(Number(a.code)===1070&&Number(a.value)===1)return!0}}catch(l){t={error:l}}finally{try{o&&!o.done&&(e=s.return)&&e.call(s)}finally{if(t)throw t.error}}return!1}function VA(n){return R0(n)||jA(n).length>0}function WA(n,t){if(!t){n.removeXData(of),KA(n);return}if(!R0(n)){var e=new Nc([{code:ci.ExtendedDataRegAppName,value:of},{code:ci.ExtendedDataAsciiString,value:"AnnotativeData"},{code:ci.ExtendedDataControlString,value:"{"},{code:ci.ExtendedDataInteger16,value:1},{code:ci.ExtendedDataInteger16,value:1},{code:ci.ExtendedDataControlString,value:"}"}]);n.setXData(e)}}function XA(n,t){var e,i;if(t){var r=rl(t),s=n.getObjectById(r);if(s instanceof I0)return s;var o=n.objects.scale,a=o.getAt(t);if(a instanceof I0)return a;try{for(var l=il(o.entries()),c=l.next();!c.done;c=l.next()){var u=Co(c.value,2),h=u[1];if(h.scaleName===t)return h}}catch(d){e={error:d}}finally{try{c&&!c.done&&(i=l.return)&&i.call(l)}finally{if(e)throw e.error}}}}function jA(n){var t,e,i=n.extensionDictionary;if(!i)return[];var r;try{r=n.database}catch{return[]}if(!r)return[];var s=r.getObjectById(rl(i));if(!(s instanceof Ao))return[];var o=s.getAt("AcDbContextDataManager");if(!(o instanceof Ao))return[];var a=o.getAt("ACDB_ANNOTATIONSCALES");if(!(a instanceof Ao))return[];var l=[];try{for(var c=il(a.entries()),u=c.next();!u.done;u=c.next()){var h=Co(u.value,2),d=h[1],f=void 0,p=void 0,g=!1;d instanceof OA?(f=d,p=d.scaleId,g=d.isDefault):p=d.objectId;var y=p?XA(r,p):void 0;y&&l.push({scale:y,contextData:f,isDefault:g})}}catch(m){t={error:m}}finally{try{u&&!u.done&&(e=c.return)&&e.call(c)}finally{if(t)throw t.error}}return l}function $A(n){try{return n.database}catch{return}}function YA(n,t){var e=t.extensionDictionary;if(e){var i=n.getObjectById(rl(e));if(i instanceof Ao){var r=i.getAt("AcDbContextDataManager");if(r instanceof Ao){var s=r.getAt("ACDB_ANNOTATIONSCALES");return s instanceof Ao?s:void 0}}}}function qA(n,t){var e,i,r=rl(t.objectId);if(r){if(n.objects.objectContextData.getIdAt(r)){n.objects.objectContextData.removeId(r);return}try{for(var s=il(P0([],Co(n.objects.objectContextData.entries()),!1)),o=s.next();!o.done;o=s.next()){var a=Co(o.value,2),l=a[0],c=a[1];(c===t||rl(c.objectId)===r)&&n.objects.objectContextData.remove(l)}}catch(u){e={error:u}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(e)throw e.error}}}}function KA(n){var t,e,i=$A(n);if(i){var r=YA(i,n);if(r)try{for(var s=il(P0([],Co(r.entries()),!1)),o=s.next();!o.done;o=s.next()){var a=Co(o.value,2),l=a[0],c=a[1];r.remove(l),qA(i,c)}}catch(u){t={error:u}}finally{try{o&&!o.done&&(e=s.return)&&e.call(s)}finally{if(t)throw t.error}}}}var ZA=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),k0=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Us=(function(n){ZA(t,n);function t(e){e===void 0&&(e="Unexpected end of buffer.");var i=n.call(this,e)||this;return i.name="AcDbProxyGraphicEndOfBufferError",i}return t})(Error);function O0(n){return n instanceof ArrayBuffer?new Uint8Array(n):n}(function(){function n(t,e){e===void 0&&(e=4),this._index=0,this._buffer=O0(t),this._align=e}return Object.defineProperty(n.prototype,"index",{get:function(){return this._index},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"hasData",{get:function(){return this._index<this._buffer.length},enumerable:!1,configurable:!0}),n.prototype.alignIndex=function(t){var e=t%this._align;return e?t+this._align-e:t},n.prototype.readStruct=function(t){var e,i;if(!this.hasData)throw new Us;var r=[],s=0;try{for(var o=k0(t),a=o.next();!a.done;a=o.next()){var l=a.value,c=new DataView(this._buffer.buffer,this._buffer.byteOffset+this._index+s,l);if(l===8)r.push(c.getFloat64(0,!0));else if(l===4)r.push(c.getUint32(0,!0));else throw new Error("Unsupported struct size: ".concat(l));s+=l}}catch(u){e={error:u}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(e)throw e.error}}return this._index=this.alignIndex(this._index+s),r},n.prototype.readFloat=function(){return this.readStruct([8])[0]},n.prototype.readLong=function(){return this.readStruct([4])[0]},n.prototype.readSignedLong=function(){if(!this.hasData)throw new Us;var t=new DataView(this._buffer.buffer,this._buffer.byteOffset+this._index,4),e=t.getInt32(0,!0);return this._index=this.alignIndex(this._index+4),e},n.prototype.readVertex=function(){return this.readStruct([8,8,8])},n.prototype.readPaddedString=function(t){t===void 0&&(t="utf-8");for(var e=this._buffer,i=this._index;i<e.length;i++)if(e[i]===0){var r=this._index;this._index=this.alignIndex(i+1);var s=e.subarray(r,i);return new TextDecoder(t).decode(s)}throw new Us("Did not detect terminating zero byte.")},n.prototype.readPaddedUnicodeString=function(){for(var t=this._buffer,e=this._index;e<t.length;e+=2)if(e+1<t.length&&t[e]===0&&t[e+1]===0){var i=this._index;this._index=this.alignIndex(e+2);var r=t.subarray(i,e);return new TextDecoder("utf-16le").decode(r)}throw new Us("Did not detect terminating zero bytes.")},n})(),(function(){function n(t,e,i){e===void 0&&(e="AC1015"),i===void 0&&(i="cp1252"),this._bitIndex=0,this._buffer=O0(t),this.dxfversion=e,this.encoding=i}return Object.defineProperty(n.prototype,"hasData",{get:function(){return this._bitIndex>>3<this._buffer.length},enumerable:!1,configurable:!0}),n.prototype.readBit=function(){var t=this._bitIndex;this._bitIndex+=1;var e=t>>3;if(e>=this._buffer.length)throw new Us;return this._buffer[e]&128>>(t&7)?1:0},n.prototype.readBits=function(t){var e=this._bitIndex,i=e+t;if(i-1>>3>=this._buffer.length)throw new Us;this._bitIndex=i;for(var r=128>>(e&7),s=e>>3,o=0,a=this._buffer[s];t>0;)o<<=1,a&r&&(o|=1),t-=1,r>>=1,!r&&t&&(r=128,s+=1,a=this._buffer[s]);return o},n.prototype.readUnsignedByte=function(){return this.readBits(8)},n.prototype.readSignedByte=function(){var t=this.readBits(8);return t&128?-((~t&255)+1):t},n.prototype.readAlignedBytes=function(t){var e=this._bitIndex>>3,i=e+t;if(i>this._buffer.length)throw new Us;return this._bitIndex+=t<<3,this._buffer.subarray(e,i)},n.prototype.readUnsignedShort=function(){if(this._bitIndex&7){var t=this.readBits(8),e=this.readBits(8);return(e<<8)+t}var i=this.readAlignedBytes(2);return i[1]<<8|i[0]},n.prototype.readSignedShort=function(){var t=this.readUnsignedShort();return t&32768?-((~t&65535)+1):t},n.prototype.readUnsignedLong=function(){if(this._bitIndex&7){var t=this.readBits(8),e=this.readBits(8),i=this.readBits(8),r=this.readBits(8);return(r<<24)+(i<<16)+(e<<8)+t}var s=this.readAlignedBytes(4);return(s[3]<<24)+(s[2]<<16)+(s[1]<<8)+s[0]},n.prototype.readSignedLong=function(){var t=this.readUnsignedLong();return t&2147483648?-((~t&4294967295)+1):t},n.prototype.readFloat=function(){if(this._bitIndex&7){for(var t=new Uint8Array(8),e=0;e<8;e++)t[e]=this.readBits(8);return new DataView(t.buffer).getFloat64(0,!0)}var i=this.readAlignedBytes(8),r=new Uint8Array(i);return new DataView(r.buffer).getFloat64(0,!0)},n.prototype.readRawDouble=function(t){var e=this;return t===void 0&&(t=1),t===1?this.readFloat():Array.from({length:t},function(){return e.readFloat()})},n.prototype.readBitShort=function(t){var e=this;t===void 0&&(t=1);var i=function(){var r=e.readBits(2);return r===0?e.readSignedShort():r===1?e.readUnsignedByte():r===2?0:256};return t===1?i():Array.from({length:t},function(){return i()})},n.prototype.readBitLong=function(t){var e=this;t===void 0&&(t=1);var i=function(){var r=e.readBits(2);return r===0?e.readSignedLong():r===1?e.readUnsignedByte():r===2?0:256};return t===1?i():Array.from({length:t},function(){return i()})},n.prototype.readBitDouble=function(t){var e=this;t===void 0&&(t=1);var i=function(){var r=e.readBits(2);return r===0?e.readFloat():r===1?1:0};return t===1?i():Array.from({length:t},function(){return i()})},n.prototype.readBitDoubleDefault=function(t,e){var i=this;t===void 0&&(t=1),e===void 0&&(e=0);var r=new Uint8Array(8);new DataView(r.buffer).setFloat64(0,e,!0);var s=function(){var o=i.readBits(2);if(o===0)return e;if(o===1){var a=new Uint8Array(r);return a[0]=i.readUnsignedByte(),a[1]=i.readUnsignedByte(),a[2]=i.readUnsignedByte(),a[3]=i.readUnsignedByte(),new DataView(a.buffer).getFloat64(0,!0)}if(o===2){var a=new Uint8Array(r);return a[4]=i.readUnsignedByte(),a[5]=i.readUnsignedByte(),a[0]=i.readUnsignedByte(),a[1]=i.readUnsignedByte(),a[2]=i.readUnsignedByte(),a[3]=i.readUnsignedByte(),new DataView(a.buffer).getFloat64(0,!0)}return i.readFloat()};return t===1?s():Array.from({length:t},function(){return s()})},n})();function JA(n){var t,e,i=n.reduce(function(u,h){return u+Math.floor(h.length/2)},0),r=new Uint8Array(i),s=0;try{for(var o=k0(n),a=o.next();!a.done;a=o.next())for(var l=a.value,c=0;c<l.length;c+=2)r[s++]=parseInt(l.slice(c,c+2),16)}catch(u){t={error:u}}finally{try{a&&!a.done&&(e=o.return)&&e.call(o)}finally{if(t)throw t.error}}return r}var QA=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),tC=(function(n){QA(t,n);function t(e,i){return e=e||{},Rd(e,{name:""}),n.call(this,e,i)||this}return Object.defineProperty(t.prototype,"name",{get:function(){return this.getAttr("name")},set:function(e){this.setAttr("name",e)},enumerable:!1,configurable:!0}),t.prototype.setAttr=function(e,i){this.assertOpenForWrite(),n.prototype.setAttr.call(this,e,i)},t.prototype.assertOpenForWrite=function(){if(!this.isTemp){var e=this.database;if(e){var i=e.transactionManager;if(!i.isApplyingUndoRedo()){if(i.strictMode&&!i.isRecording())throw new Error("Cannot modify symbol table records outside an active transaction.");if(i.isRecording()&&!i.isOpenedForWriteInTransaction(this.objectId))throw new Error('Symbol table record "'.concat(this.name||this.objectId,'" is not open for write. Use openObjectForWrite().'))}}}},t.prototype.dxfOutFields=function(e){return n.prototype.dxfOutFields.call(this,e),e.writeSubclassMarker("AcDbSymbolTableRecord"),this},t})(el),eC=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),af=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},lf;(function(n){n[n.Any=0]="Any",n[n.Uniform=1]="Uniform"})(lf||(lf={}));var kr;(function(n){n[n.None=0]="None",n[n.Anonymous=1]="Anonymous",n[n.HasNonConstantAttributes=2]="HasNonConstantAttributes",n[n.Xref=4]="Xref",n[n.XrefOverlay=8]="XrefOverlay",n[n.ExternallyDependent=16]="ExternallyDependent",n[n.Resolved=32]="Resolved",n[n.Referenced=64]="Referenced"})(kr||(kr={}));var B0=(function(n){eC(t,n);function t(e,i){var r=this;return e=e||{},Rd(e,{origin:new Be,layoutId:"",flags:kr.None,pathName:"",blockInsertUnits:0,explodability:1,blockScaling:lf.Uniform,previewIcon:void 0}),r=n.call(this,e,i)||this,r._entities=[],r}return t.isModelSapceName=function(e){return e.toLowerCase()==t.MODEL_SPACE_NAME.toLowerCase()},t.isPaperSapceName=function(e){return e.toLowerCase().startsWith(t.PAPER_SPACE_NAME_PREFIX.toLowerCase())},t.sanitizeImportedFlags=function(e){return e&~(kr.Resolved|kr.Referenced)},Object.defineProperty(t.prototype,"isModelSapce",{get:function(){return t.isModelSapceName(this.name)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isPaperSapce",{get:function(){return t.isPaperSapceName(this.name)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"origin",{get:function(){return this.getAttr("origin")},set:function(e){this.getAttr("origin").copy(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"layoutId",{get:function(){return this.getAttr("layoutId")},set:function(e){this.setAttr("layoutId",e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"flags",{get:function(){return this.getAttr("flags")},set:function(e){this.setAttr("flags",e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"annotative",{get:function(){return VA(this)},set:function(e){WA(this,e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pathName",{get:function(){return this.getAttr("pathName")},set:function(e){this.setAttr("pathName",e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isXref",{get:function(){return(this.flags&(kr.Xref|kr.XrefOverlay))!==0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isOverlayReference",{get:function(){return(this.flags&kr.XrefOverlay)!==0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isUnresolvedXref",{get:function(){return!this.isXref||(this.flags&kr.Resolved)!==0?!1:this._entities.length===0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blockInsertUnits",{get:function(){return this.getAttr("blockInsertUnits")},set:function(e){this.setAttr("blockInsertUnits",e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"explodability",{get:function(){return this.getAttr("explodability")},set:function(e){this.setAttr("explodability",e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blockScaling",{get:function(){return this.getAttr("blockScaling")},set:function(e){this.setAttr("blockScaling",e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"previewIcon",{get:function(){return this.getAttrWithoutException("previewIcon")},set:function(e){if(!e||e.length===0){this.setAttr("previewIcon",void 0);return}this.setAttr("previewIcon",e)},enumerable:!1,configurable:!0}),t.prototype.appendEntity=function(e){var i,r,s,o,a=this,l=this.database.transactionManager;if(l.strictMode&&!l.isRecording()&&!l.isApplyingUndoRedo())throw new Error("Cannot append entities outside an active transaction.");var c=function(y){y.database=a.database,a.database.ensureEntityStyleDefaults(y),a.database.commitObjectHandle(y,function(m){return a.hasEntityId(m)}),y.ownerId=a.objectId,y.resolveEffectiveProperties(),a._entities.push(y),y.dxfTypeName==="INSERT"&&"syncAttributeDatabases"in y&&typeof y.syncAttributeDatabases=="function"&&y.syncAttributeDatabases()},u=Array.isArray(e)?e:[e];try{for(var h=af(u),d=h.next();!d.done;d=h.next()){var f=d.value;c(f)}}catch(y){i={error:y}}finally{try{d&&!d.done&&(r=h.return)&&r.call(h)}finally{if(i)throw i.error}}if(l.isRecording())try{for(var p=af(u),g=p.next();!g.done;g=p.next()){var f=g.value;l.recordAppend({type:"blockTableRecord",ownerId:this.objectId},f)}}catch(y){s={error:y}}finally{try{g&&!g.done&&(o=p.return)&&o.call(p)}finally{if(s)throw s.error}}(this.isModelSapce||this.isPaperSapce)&&!l.isRecording()&&!l.isApplyingUndoRedo()&&this.database.notifyEntityAppended(e)},t.prototype.removeEntity=function(e){var i,r,s=this.database.transactionManager;if(s.strictMode&&!s.isRecording()&&!s.isApplyingUndoRedo())throw new Error("Cannot remove entities outside an active transaction.");var o=Array.isArray(e)?e:[e];if(o.length===0)return!1;var a=new Set(o),l=[],c=0;try{for(var u=af(this._entities),h=u.next();!h.done;h=u.next()){var d=h.value;a.has(d.objectId)?(s.isRecording()&&s.recordRemove({type:"blockTableRecord",ownerId:this.objectId},d),l.push(d),this.database.releaseObjectHandle(d)):this._entities[c++]=d}}catch(f){i={error:f}}finally{try{h&&!h.done&&(r=u.return)&&r.call(u)}finally{if(i)throw i.error}}return this._entities.length=c,l.length>0&&!s.isRecording()&&!s.isApplyingUndoRedo()&&this.database.notifyEntityErased(l),l.length>0},t.prototype.newIterator=function(){return new L0(this._entities)},t.prototype.getIdAt=function(e){var i=this.database.getObjectById(e);if(i instanceof AA){var r=i.getAttrWithoutException("ownerId");if(r===this.objectId)return i}},t.prototype.hasEntityId=function(e){return this.getIdAt(e)!==void 0},t.prototype.dxfOutBlockRecord=function(e){return e.writeStart("BLOCK_RECORD"),this.dxfOut(e),this},t.prototype.dxfOutBlockBegin=function(e){return e.writeStart("BLOCK"),e.writeHandle(5,this.database.generateHandle()),e.writeObjectId(330,this.objectId),e.writeSubclassMarker("AcDbEntity"),e.writeString(8,"0"),e.writeSubclassMarker("AcDbBlockBegin"),e.writeString(2,this.name),e.writeInt16(70,this.flags),e.writePoint3d(10,this.origin),e.writeString(3,this.name),this.pathName&&e.writeString(1,this.pathName),this},t.prototype.dxfOutBlockEnd=function(e){return e.writeStart("ENDBLK"),e.writeHandle(5,this.database.generateHandle()),e.writeObjectId(330,this.objectId),e.writeSubclassMarker("AcDbEntity"),e.writeSubclassMarker("AcDbBlockEnd"),this},t.prototype.dxfOutFields=function(e){return n.prototype.dxfOutFields.call(this,e),e.writeSubclassMarker("AcDbBlockTableRecord"),e.writeString(2,this.name),e.capabilities.supportsBlockRecordUnitsFlags&&(e.writeInt16(70,this.blockInsertUnits),e.writeInt16(280,this.explodability),e.writeInt16(281,this.blockScaling)),(this.isModelSapce||this.isPaperSapce)&&e.writeObjectId(340,this.layoutId),this},t.prototype.dxfInFields=function(e){n.prototype.dxfInFields.call(this,e),e.atSubclassData("AcDbSymbolTableRecord"),e.atSubclassData("AcDbBlockTableRecord");for(var i=[];!e.atEndOfObject&&!e.atEof&&!e.atExtendedData;){var r=e.readItem();if(!r)break;var s=Number(r.code);if(s===100){e.pushBackItem(r);break}switch(s){case 2:this.name=String(r.value);break;case 70:this.blockInsertUnits=Number(r.value);break;case 280:this.explodability=Number(r.value);break;case 281:this.blockScaling=Number(r.value);break;case 340:this.layoutId=String(r.value);break;case 310:{var o=String(r.value).replace(/\s+/g,"");o&&i.push(o);break}}}return i.length>0&&(this.previewIcon=JA(i)),this},t.MODEL_SPACE_NAME="*Model_Space",t.PAPER_SPACE_NAME_PREFIX="*Paper_Space",t})(tC),nC=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},as;(function(n){n[n.EndPoint=1]="EndPoint",n[n.MidPoint=2]="MidPoint",n[n.Center=3]="Center",n[n.Node=4]="Node",n[n.Quadrant=5]="Quadrant",n[n.Intersection=6]="Intersection",n[n.Insertion=7]="Insertion",n[n.Perpendicular=8]="Perpendicular",n[n.Tangent=9]="Tangent",n[n.Nearest=10]="Nearest",n[n.Centroid=11]="Centroid"})(as||(as={}));function iC(n){var t,e,i=0;try{for(var r=nC(n),s=r.next();!s.done;s=r.next()){var o=s.value;i|=1<<o-1}}catch(a){t={error:a}}finally{try{s&&!s.done&&(e=r.return)&&e.call(r)}finally{if(t)throw t.error}}return i}var rC=function(n,t,e,i){function r(s){return s instanceof e?s:new e(function(o){o(s)})}return new(e||(e=Promise))(function(s,o){function a(u){try{c(i.next(u))}catch(h){o(h)}}function l(u){try{c(i.throw(u))}catch(h){o(h)}}function c(u){u.done?s(u.value):r(u.value).then(a,l)}c((i=i.apply(n,t||[])).next())})},sC=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(c){return function(u){return l([c,u])}}function l(c){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(e=0)),e;)try{if(i=1,r&&(s=c[0]&2?r.return:c[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,c[1])).done)return s;switch(r=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return e.label++,{value:c[1],done:!1};case 5:e.label++,r=c[1],c=[0];continue;case 7:c=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){e=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){e.label=c[1];break}if(c[0]===6&&e.label<s[1]){e.label=s[1],s=c;break}if(s&&e.label<s[2]){e.label=s[2],e.ops.push(c);break}s[2]&&e.ops.pop(),e.trys.pop();continue}c=t.call(n,e)}catch(u){c=[6,u],r=0}finally{i=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},sl=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},oC=function(){return{hits:0,misses:0,hitMs:0,missBuildMs:0,missCompactMs:0,cloneMs:0,setCloneMs:0,applyMs:0}},N0=function(){return{hits:0,misses:0,hitMs:0,missBuildMs:0,missCompactMs:0,cloneMs:0,setCloneMs:0,applyMs:0,topLevel:oC(),blockMisses:[]}},aC=(function(){function n(){this._lruTotalBytes=0,this._retiredCompactedTemplates=[],this._blocks=new Map,this._lruBytes=new Map}return Object.defineProperty(n,"profileStats",{get:function(){return this._profileStats},enumerable:!1,configurable:!0}),n.resetProfile=function(){this._profileStats=N0(),this._drawDepth=0},Object.defineProperty(n,"instance",{get:function(){return this._instance||(this._instance=new n),this._instance},enumerable:!1,configurable:!0}),n.prototype.createKey=function(t,e){var i=e.toString();return!i&&e.isByColor&&(i="RGB:".concat(e.red,",").concat(e.green,",").concat(e.blue)),"".concat(t,"_").concat(i)},n.prototype.createCacheKey=function(t,e,i){return i?this.createKey(t,e):t},n.prototype.set=function(t,e){var i;if(this._blocks.set(t,e),n.lruEnabled){var r=(i=this._lruBytes.get(t))!==null&&i!==void 0?i:0,s=this.estimateTemplateBytes(e);this._lruBytes.set(t,s),this._lruTotalBytes+=s-r,this.enforceLruBudget()}return e},n.prototype.enforceLruBudget=function(){for(var t=n.lruMaxEntries;t>0&&this._blocks.size>t;)this.evictOldest();for(var e=n.lruMaxEstimatedBytes;e>0&&this._lruTotalBytes>e&&this._blocks.size>1;)this.evictOldest()},n.prototype.evictOldest=function(){var t,e,i=this._blocks.keys().next();if(!(i.done||i.value===void 0)){var r=i.value,s=this._blocks.get(r);this._blocks.delete(r),this._lruTotalBytes-=(t=this._lruBytes.get(r))!==null&&t!==void 0?t:0,this._lruBytes.delete(r),s&&(U0(s)?this._retiredCompactedTemplates.push(s):(e=s.dispose)===null||e===void 0||e.call(s))}},n.prototype.estimateTemplateBytes=function(t){for(var e,i,r=0,s=[t];s.length>0;){var o=s.pop();if(o!=null){if(o.geometry){var a=o.geometry.attributes;if(a)for(var l in a){var c=(e=a[l])===null||e===void 0?void 0:e.array;c&&(r+=c.byteLength)}var u=(i=o.geometry.index)===null||i===void 0?void 0:i.array;u&&(r+=u.byteLength)}var h=o.children;if(h)for(var d=0;d<h.length;d++)s.push(h[d])}}return r},n.prototype.peek=function(t){return this._blocks.get(t)},n.prototype.get=function(t){var e=this._blocks.get(t);if(e){if(n.lruEnabled&&(this._blocks.delete(t),this._blocks.set(t,e)),n.profiling){var i=performance.now(),r=this.maybeCompactTemplate(e,!0);if(r){var s=performance.now()-i;n._profileStats.missCompactMs+=s,n._drawDepth===1&&(n._profileStats.topLevel.missCompactMs+=s)}var o=performance.now(),a=e.fastDeepClone(),l=performance.now()-o;return n._profileStats.cloneMs+=l,n._drawDepth===1&&(n._profileStats.topLevel.cloneMs+=l),uf(a,t),a}this.maybeCompactTemplate(e,!0);var c=e.fastDeepClone();return uf(c,t),c}},n.prototype.has=function(t){return this._blocks.has(t)},n.prototype.clear=function(){var t;this._blocks.forEach(function(e){var i;(i=e.dispose)===null||i===void 0||i.call(e)}),this._blocks.clear(),this._lruBytes.clear(),this._lruTotalBytes=0,this._retiredCompactedTemplates.forEach(function(e){var i;(i=e.dispose)===null||i===void 0||i.call(e)}),this._retiredCompactedTemplates.length=0,(t=n.onCleared)===null||t===void 0||t.call(n)},n.prototype.prebuildAll=function(t,e,i){return rC(this,void 0,void 0,function(){var r,s,o,f,a,l,c,u,h,d,f,p,g,y,m,v,x;return sC(this,function(_){switch(_.label){case 0:r=[];try{for(s=sl(e),o=s.next();!o.done;o=s.next())f=o.value,!(!f||!f.name)&&(this.shouldSkipPrebuild(f)||r.push(f))}catch(b){y={error:b}}finally{try{o&&!o.done&&(m=s.return)&&m.call(s)}finally{if(y)throw y.error}}a=r.length,l=0,c=new rn().setForeground(),u=new B2,_.label=1;case 1:_.trys.push([1,8,9,10]),h=sl(r),d=h.next(),_.label=2;case 2:return d.done?[3,7]:(f=d.value,p=this.createCacheKey(f.name,c,!1),this.has(p)||this.draw(t,f,c,[],!0),l++,i?[4,i(l,a,f.name)]:[3,4]);case 3:_.sent(),_.label=4;case 4:return[4,u.maybeYield(Wy)];case 5:_.sent(),_.label=6;case 6:return d=h.next(),[3,2];case 7:return[3,10];case 8:return g=_.sent(),v={error:g},[3,10];case 9:try{d&&!d.done&&(x=h.return)&&x.call(h)}finally{if(v)throw v.error}return[7];case 10:return[2]}})})},n.prototype.draw=function(t,e,i,r,s,o,a){var l,c,u;r===void 0&&(r=[]),s===void 0&&(s=!0);var h=n.profiling;h&&n._drawDepth++;var d=h&&n._drawDepth===1,f=n._profileStats,p=[];try{if(e!=null){var g=(u=i.RGB)!==null&&u!==void 0?u:0,y=e.name,m=void 0;if(y&&this.has(y))m=y;else if(y){var v=this.createKey(y,i);this.has(v)&&(m=v)}var x;if(m!==void 0){var _=h?performance.now():0;if(x=this.get(m),h){var b=performance.now()-_;f.hits++,f.hitMs+=b,d&&(f.topLevel.hits++,f.topLevel.hitMs+=b)}}else{var w=h?performance.now():0,C=!1,E=e.newIterator();try{for(var T=sl(E),k=T.next();!k.done;k=T.next()){var O=k.value;if(O.visibility)if(O.color.isByBlock){C=!0;var U=pC(O.color);try{i.isForeground?O.color.setForeground():O.color.setRGBValue(g),this.addEntity(O,p,t)}finally{O.color.copy(U),mC(U)}}else this.addEntity(O,p,t)}}catch(ft){l={error:ft}}finally{try{k&&!k.done&&(c=T.return)&&c.call(T)}finally{if(l)throw l.error}}x=t.group(p);var z=0;h&&(z=performance.now()-w,f.missBuildMs+=z,d&&(f.topLevel.missBuildMs+=z));var L=0,N=!!s&&!!y&&!y.startsWith("*U");if(x&&N){var F=h?performance.now():0,G=this.maybeCompactTemplate(x,!1);h&&G&&(L=performance.now()-F,f.missCompactMs+=L,d&&(f.topLevel.missCompactMs+=L))}m=this.createCacheKey(y,i,C);var V=h?f.setCloneMs:0;if(x&&N){if(fC(x),this.set(m,x),h){var D=performance.now();x=x.fastDeepClone();var b=performance.now()-D;f.setCloneMs+=b,d&&(f.topLevel.setCloneMs+=b)}else x=x.fastDeepClone();uf(x,m)}h&&(f.misses++,d&&f.topLevel.misses++,f.blockMisses.push({blockName:y||"(unnamed)",buildMs:z,compactMs:L,setCloneMs:f.setCloneMs-V}))}var Y=h?performance.now():0;if(x&&o&&(Fc.copy(o),x.applyMatrix(Fc),a&&(a.x!=0||a.y!=0||a.z!=1)&&(cf.setFromExtrusionDirection(a),x.applyMatrix(cf),Fc.premultiply(cf))),x&&r&&r.length>0){var Z=o!=null?lC.copy(Fc).invert():void 0;r.forEach(function(ft){Z&&ft.applyMatrix(Z),x.addChild(ft)})}if(h){var b=performance.now()-Y;f.applyMs+=b,d&&(f.topLevel.applyMs+=b)}return x}else return t.group(p)}finally{h&&n._drawDepth--}},n.prototype.shouldSkipPrebuild=function(t){var e,i,r=t.name;if(B0.isModelSapceName(r)||B0.isPaperSapceName(r)||r.startsWith("*U")||this.blockHasByBlockColor(t))return!0;try{for(var s=sl(t.newIterator()),o=s.next();!o.done;o=s.next()){var a=o.value;if(a.visibility)return!1}}catch(l){e={error:l}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(e)throw e.error}}return!0},n.prototype.blockHasByBlockColor=function(t){var e,i;try{for(var r=sl(t.newIterator()),s=r.next();!s.done;s=r.next()){var o=s.value;if(o.visibility&&o.color.isByBlock)return!0}}catch(a){e={error:a}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(e)throw e.error}}return!1},n.prototype.addEntity=function(t,e,i){if(t.visibility){var r=t.worldDraw(i);r&&(this.attachEntityInfo(r,t),e.push(r))}},n.prototype.attachEntityInfo=function(t,e){t.objectId=e.objectId,t.ownerId=e.ownerId,t.layerName=e.layer,t.visible=e.visibility},n.prototype.maybeCompactTemplate=function(t,e){return!t.compactForInstancing||U0(t)||!dC(t,e)?!1:(t.compactForInstancing(),!0)},n.profiling=!1,n.lruEnabled=!0,n.lruMaxEntries=512,n.lruMaxEstimatedBytes=64*1024*1024,n._profileStats=N0(),n._drawDepth=0,n})(),Fc=new Ya,cf=new Ya,lC=new Ya,cC=8,uC=32,D0=[];function hC(n){var t=n.childCount;return typeof t=="number"?t:Number.POSITIVE_INFINITY}function U0(n){var t=n.isCompacted;return t===!0}function dC(n,t){var e=hC(n);return e<cC?!1:e>=uC?!0:t}function fC(n){var t=n.prepareCacheTemplate;typeof t=="function"&&t.call(n)}function uf(n,t){var e=n.userData;e.blockCacheKey=t}function pC(n){var t,e=(t=D0.pop())!==null&&t!==void 0?t:new rn;return e.copy(n),e}function mC(n){D0.push(n)}/**
|
|
1
|
+
(function(){"use strict";var li=Uint8Array,ho=Uint16Array,vM=Int32Array,Ay=new li([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Cy=new li([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),_M=new li([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ty=function(n,t){for(var e=new ho(31),i=0;i<31;++i)e[i]=t+=1<<n[i-1];for(var r=new vM(e[30]),i=1;i<30;++i)for(var s=e[i];s<e[i+1];++s)r[s]=s-e[i]<<5|i;return{b:e,r}},Ly=Ty(Ay,2),Iy=Ly.b,xM=Ly.r;Iy[28]=258,xM[258]=28;for(var bM=Ty(Cy,0),SM=bM.b,_d=new ho(32768),tn=0;tn<32768;++tn){var is=(tn&43690)>>1|(tn&21845)<<1;is=(is&52428)>>2|(is&13107)<<2,is=(is&61680)>>4|(is&3855)<<4,_d[tn]=((is&65280)>>8|(is&255)<<8)>>1}for(var Ha=(function(n,t,e){for(var i=n.length,r=0,s=new ho(t);r<i;++r)n[r]&&++s[n[r]-1];var o=new ho(t);for(r=1;r<t;++r)o[r]=o[r-1]+s[r-1]<<1;var a;if(e){a=new ho(1<<t);var l=15-t;for(r=0;r<i;++r)if(n[r])for(var c=r<<4|n[r],u=t-n[r],h=o[n[r]-1]++<<u,d=h|(1<<u)-1;h<=d;++h)a[_d[h]>>l]=c}else for(a=new ho(i),r=0;r<i;++r)n[r]&&(a[r]=_d[o[n[r]-1]++]>>15-n[r]);return a}),Ga=new li(288),tn=0;tn<144;++tn)Ga[tn]=8;for(var tn=144;tn<256;++tn)Ga[tn]=9;for(var tn=256;tn<280;++tn)Ga[tn]=7;for(var tn=280;tn<288;++tn)Ga[tn]=8;for(var Py=new li(32),tn=0;tn<32;++tn)Py[tn]=5;var wM=Ha(Ga,9,1),MM=Ha(Py,5,1),xd=function(n){for(var t=n[0],e=1;e<n.length;++e)n[e]>t&&(t=n[e]);return t},Fi=function(n,t,e){var i=t/8|0;return(n[i]|n[i+1]<<8)>>(t&7)&e},bd=function(n,t){var e=t/8|0;return(n[e]|n[e+1]<<8|n[e+2]<<16)>>(t&7)},EM=function(n){return(n+7)/8|0},Ry=function(n,t,e){return(t==null||t<0)&&(t=0),(e==null||e>n.length)&&(e=n.length),new li(n.subarray(t,e))},AM=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],wi=function(n,t,e){var i=new Error(t||AM[n]);if(i.code=n,Error.captureStackTrace&&Error.captureStackTrace(i,wi),!e)throw i;return i},CM=function(n,t,e,i){var r=n.length,s=0;if(!r||t.f&&!t.l)return e||new li(0);var o=!e,a=o||t.i!=2,l=t.i;o&&(e=new li(r*3));var c=function(Lt){var oe=e.length;if(Lt>oe){var Me=new li(Math.max(oe*2,Lt));Me.set(e),e=Me}},u=t.f||0,h=t.p||0,d=t.b||0,f=t.l,p=t.d,g=t.m,y=t.n,m=r*8;do{if(!f){u=Fi(n,h,1);var v=Fi(n,h+1,3);if(h+=3,v)if(v==1)f=wM,p=MM,g=9,y=5;else if(v==2){var w=Fi(n,h,31)+257,C=Fi(n,h+10,15)+4,E=w+Fi(n,h+5,31)+1;h+=14;for(var T=new li(E),k=new li(19),O=0;O<C;++O)k[_M[O]]=Fi(n,h+O*3,7);h+=C*3;for(var U=xd(k),z=(1<<U)-1,L=Ha(k,U,1),O=0;O<E;){var N=L[Fi(n,h,z)];h+=N&15;var x=N>>4;if(x<16)T[O++]=x;else{var F=0,G=0;for(x==16?(G=3+Fi(n,h,3),h+=2,F=T[O-1]):x==17?(G=3+Fi(n,h,7),h+=3):x==18&&(G=11+Fi(n,h,127),h+=7);G--;)T[O++]=F}}var V=T.subarray(0,w),D=T.subarray(w);g=xd(V),y=xd(D),f=Ha(V,g,1),p=Ha(D,y,1)}else wi(1);else{var x=EM(h)+4,_=n[x-4]|n[x-3]<<8,b=x+_;if(b>r){l&&wi(0);break}a&&c(d+_),e.set(n.subarray(x,b),d),t.b=d+=_,t.p=h=b*8,t.f=u;continue}if(h>m){l&&wi(0);break}}a&&c(d+131072);for(var Y=(1<<g)-1,Z=(1<<y)-1,ft=h;;ft=h){var F=f[bd(n,h)&Y],gt=F>>4;if(h+=F&15,h>m){l&&wi(0);break}if(F||wi(2),gt<256)e[d++]=gt;else if(gt==256){ft=h,f=null;break}else{var qt=gt-254;if(gt>264){var O=gt-257,Vt=Ay[O];qt=Fi(n,h,(1<<Vt)-1)+Iy[O],h+=Vt}var Xt=p[bd(n,h)&Z],it=Xt>>4;Xt||wi(3),h+=Xt&15;var D=SM[it];if(it>3){var Vt=Cy[it];D+=bd(n,h)&(1<<Vt)-1,h+=Vt}if(h>m){l&&wi(0);break}a&&c(d+131072);var ct=d+qt;if(d<D){var kt=s-D,ce=Math.min(D,ct);for(kt+d<0&&wi(3);d<ce;++d)e[d]=i[kt+d]}for(;d<ct;++d)e[d]=e[d-D]}}t.l=f,t.p=ft,t.b=d,t.f=u,f&&(u=1,t.m=g,t.d=p,t.n=y)}while(!u);return d!=e.length&&o?Ry(e,0,d):e.subarray(0,d)},TM=new li(0),LM=function(n){(n[0]!=31||n[1]!=139||n[2]!=8)&&wi(6,"invalid gzip data");var t=n[3],e=10;t&4&&(e+=(n[10]|n[11]<<8)+2);for(var i=(t>>3&1)+(t>>4&1);i>0;i-=!n[e++]);return e+(t&2)},IM=function(n){var t=n.length;return(n[t-4]|n[t-3]<<8|n[t-2]<<16|n[t-1]<<24)>>>0};function PM(n,t){var e=LM(n);return e+8>n.length&&wi(6,"invalid gzip data"),CM(n.subarray(e,-8),{i:2},new li(IM(n)),t)}var Sd=typeof TextDecoder<"u"&&new TextDecoder,RM=0;try{Sd.decode(TM,{stream:!0}),RM=1}catch{}var kM=function(n){for(var t="",e=0;;){var i=n[e++],r=(i>127)+(i>223)+(i>239);if(e+r>n.length)return{s:t,r:Ry(n,e-1)};r?r==3?(i=((i&15)<<18|(n[e++]&63)<<12|(n[e++]&63)<<6|n[e++]&63)-65536,t+=String.fromCharCode(55296|i>>10,56320|i&1023)):r&1?t+=String.fromCharCode((i&31)<<6|n[e++]&63):t+=String.fromCharCode((i&15)<<12|(n[e++]&63)<<6|n[e++]&63):t+=String.fromCharCode(i)}};function ky(n,t){var e;if(Sd)return Sd.decode(n);var i=kM(n),r=i.s,e=i.r;return e.length&&wi(8),r}const OM=512*1024*1024,Oy=512*1024*1024;class wd{constructor(t){this.bytes=t,this.offset=0}ensureAvailable(t){if(t<0||!Number.isFinite(t))throw new Error("Invalid binary length");if(this.offset+t>this.bytes.length)throw new Error("Unexpected end of binary buffer")}readU8(){return this.ensureAvailable(1),this.bytes[this.offset++]}readU32(){this.ensureAvailable(4);const e=new DataView(this.bytes.buffer,this.bytes.byteOffset+this.offset,4).getUint32(0,!0);return this.offset+=4,e}readI32(){this.ensureAvailable(4);const e=new DataView(this.bytes.buffer,this.bytes.byteOffset+this.offset,4).getInt32(0,!0);return this.offset+=4,e}readF32(){this.ensureAvailable(4);const e=new DataView(this.bytes.buffer,this.bytes.byteOffset+this.offset,4).getFloat32(0,!0);return this.offset+=4,e}readF64(){this.ensureAvailable(8);const e=new DataView(this.bytes.buffer,this.bytes.byteOffset+this.offset,8).getFloat64(0,!0);return this.offset+=8,e}readBytes(t){this.ensureAvailable(t);const e=this.bytes.subarray(this.offset,this.offset+t);return this.offset+=t,e}readString(){const t=this.readU32();if(t===0)return"";if(t>OM)throw new Error("Binary string exceeds size limit");return ky(this.readBytes(t))}readJson(){const t=this.readString();if(t.length===0)throw new Error("Expected JSON payload");return JSON.parse(t)}alignTo(t){const e=this.offset%t;if(e===0)return;const i=t-e;this.ensureAvailable(i),this.offset+=i}readFloat32Array(){this.alignTo(4);const t=this.readU32();if(t===0)return new Float32Array(0);if(t%4!==0)throw new Error("Invalid float32 buffer length");if(t>Oy)throw new Error("Float32 buffer exceeds size limit");const e=this.readBytes(t);if(e.byteOffset%4===0)return new Float32Array(e.buffer,e.byteOffset,t/4);const i=new ArrayBuffer(t);return new Uint8Array(i).set(e),new Float32Array(i)}readUint32Array(){this.alignTo(4);const t=this.readU32();if(t===0)return new Uint32Array(0);if(t%4!==0)throw new Error("Invalid uint32 buffer length");if(t>Oy)throw new Error("Uint32 buffer exceeds size limit");const e=this.readBytes(t);if(e.byteOffset%4===0)return new Uint32Array(e.buffer,e.byteOffset,t/4);const i=new ArrayBuffer(t);return new Uint8Array(i).set(e),new Uint32Array(i)}}const fo=4,BM=512*1024*1024,Va=256*1024*1024;function By(n){return n.byteLength>=2&&n[0]===31&&n[1]===139}function Md(n){if(n.byteLength>Va)throw new Error("Compressed payload exceeds size limit");const t=PM(n);if(t.byteLength>BM)throw new Error("Decompressed payload exceeds size limit");return t}const yc="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%()*+,-.;=?@[]^_{|}~",Ed=new Int16Array(128).fill(-1);for(let n=0;n<yc.length;n++)Ed[yc.charCodeAt(n)]=n;function Ad(n){const t=(n==null?void 0:n.toLowerCase())??"";return t.includes(";base85")||t.endsWith("base85")?"base85":"base64"}function NM(n,t){return t==="base85"?DM(n):FM(n)}function Cd(n,t){const e=n.length>0&&(n.charCodeAt(0)<=32||n.charCodeAt(n.length-1)<=32)?n.trim():n;return t==="base85"?UM(e):HM(e)}function DM(n){const t=n.length;if(t===0)return"";const e=(4-t%4)%4,i=t+e,r=[];for(let o=0;o<i;o+=4){const a=n[o]??0,l=o+1<t?n[o+1]:0,c=o+2<t?n[o+2]:0,u=o+3<t?n[o+3]:0;let h=(a<<24>>>0)+(l<<16)+(c<<8)+u;const d=new Array(5);for(let f=4;f>=0;f--)d[f]=h%85,h=h/85|0;for(let f=0;f<5;f++)r.push(yc[d[f]])}const s=Math.ceil(t*5/4);return r.slice(0,s).join("")}function UM(n){const t=n.replace(/\s+/g,""),e=t.length;if(e===0)return new Uint8Array(0);const i=Math.floor(e*4/5),r=(5-e%5)%5,s=e+r,o=new Uint8Array(s/5*4),a=yc.length-1;let l=0;for(let c=0;c<s;c+=5){let u=0;for(let h=0;h<5;h++){const d=c+h<e?zM(t.charCodeAt(c+h)):a;u=u*85+d}o[l++]=u>>>24&255,o[l++]=u>>>16&255,o[l++]=u>>>8&255,o[l++]=u&255}return o.subarray(0,i)}function zM(n){if(n<0||n>=Ed.length)throw new Error("Invalid base85 character");const t=Ed[n];if(t<0)throw new Error("Invalid base85 character");return t}function FM(n){let t="";for(let e=0;e<n.length;e++)t+=String.fromCharCode(n[e]);return btoa(t)}function HM(n){const t=atob(n),e=new Uint8Array(t.length);for(let i=0;i<t.length;i++)e[i]=t.charCodeAt(i);return e}const GM=1,VM=2,WM=4,XM=8,jM=16,$M=32,YM=1,qM=2,KM=4,ZM=8,JM=16,QM=32,t2=64,e2=128;function Ny(n){const t=n.readString(),e=n.readU32(),i=[n.readF64(),n.readF64(),n.readF64()],r=n.readFloat32Array(),s=n.readU8(),o={layer:t,color:e,offset:i,positions:r};return s&GM&&(o.indices=n.readUint32Array()),s&VM&&(o.linePattern=n.readJson()),s&WM&&(o.lineDistances=n.readFloat32Array()),s&XM&&(o.lineWidth=n.readF32()),s&jM&&(o.renderOrder=n.readI32()),s&$M&&(o.excludeFromOsnap=!0),o}function Dy(n){const t=n.readString(),e=n.readU32(),i=[n.readF64(),n.readF64(),n.readF64()],r=n.readFloat32Array(),s=n.readU8(),o={layer:t,color:e,offset:i,positions:r};if(s&YM&&(o.indices=n.readUint32Array()),s&qM&&(o.hatchPattern=n.readJson()),s&KM&&(o.gradientFill=n.readJson()),s&ZM&&(o.gradientPositions=n.readFloat32Array()),s&JM&&(o.side=n.readU8()),s&QM&&(o.points=!0),s&t2&&(o.renderOrder=n.readI32()),s&e2){o.uvs=n.readFloat32Array();const a=n.readString()||"image/png",l=n.readU32();o.texture={mimeType:a,bytes:n.readBytes(l)}}return o}const Uy=1329939265,n2=1,zy=5e5,i2=1e5,r2=1,s2=2,o2=3,a2=4,l2=5,c2=6,u2=7;function Td(n){const t=new wd(n);if(t.readU32()!==Uy)throw new Error("Invalid osnap catalog magic");const i=t.readU8();if(t.readU8(),t.readU8(),t.readU8(),i!==n2)throw new Error(`Unsupported osnap catalog version: ${i}`);const r=t.readU32();if(r>i2)throw new Error("Osnap layer count exceeds limit");const s=[];for(let l=0;l<r;l++)s.push(t.readString());const o=t.readU32();if(o>zy)throw new Error("Osnap primitive count exceeds limit");const a=[];for(let l=0;l<o;l++)a.push(f2(t,s));return{primitives:a}}function h2(n){return Td(Md(n))}function d2(n){return By(n)?h2(n):Td(n)}function Ld(n){return n.readU8()===0?-1:1}function Wa(n){const t=n.readU32();if(t>zy)throw new Error("Float64 array count exceeds limit");const e=[];for(let i=0;i<t;i++)e.push(n.readF64());return e}function f2(n,t){const e=n.readU8(),i=n.readU32(),r=t[i];if(r==null)throw new Error(`Invalid osnap layer index: ${i}`);switch(e){case r2:return{kind:"line",layer:r,x0:n.readF64(),y0:n.readF64(),x1:n.readF64(),y1:n.readF64()};case s2:return{kind:"circle",layer:r,cx:n.readF64(),cy:n.readF64(),r:n.readF64(),normalSign:Ld(n)};case o2:return{kind:"arc",layer:r,cx:n.readF64(),cy:n.readF64(),r:n.readF64(),startAngle:n.readF64(),endAngle:n.readF64(),normalSign:Ld(n)};case a2:return{kind:"ellipse",layer:r,cx:n.readF64(),cy:n.readF64(),majorX:n.readF64(),majorY:n.readF64(),majorR:n.readF64(),minorR:n.readF64(),startAngle:n.readF64(),endAngle:n.readF64(),closed:n.readU8()!==0,normalSign:Ld(n)};case l2:{const s=Wa(n),o=n.readU32(),a=Wa(n),l=Wa(n),c=n.readU8()!==0,u=Wa(n);return{kind:"spline",layer:r,controlPoints:s,degree:o,knots:a,weights:l,closed:c,...u.length>0?{fitPoints:u}:{}}}case c2:return{kind:"point",layer:r,x:n.readF64(),y:n.readF64()};case u2:{const s=n.readU8()!==0,o=Wa(n);return{kind:"path",layer:r,closed:s,vertices:o}}default:throw new Error(`Unsupported osnap primitive kind: ${e}`)}}const p2=1480934209;function m2(n){const t=new wd(n);if(t.readU32()!==p2)throw new Error("Invalid snapshot magic");const i=t.readU8();if(t.readU8(),t.readU8(),t.readU8(),i!==fo)throw new Error(`Unsupported snapshot version: ${i}`);const r=t.readJson(),s=t.readJson(),o=t.readString(),a=t.readU32(),l=[];for(let c=0;c<a;c++)l.push(y2(t));return g2(l,r.savedViews,r.fitExtents),{version:fo,meta:r,layers:s,layouts:l,activeLayoutBtrId:o}}function g2(n,t,e){if(!(!t&&!e))for(const i of n){if(!i.savedView){const r=t==null?void 0:t[i.btrId];r&&(i.savedView=r)}if(!i.fitExtents){const r=e==null?void 0:e[i.btrId];r&&(i.fitExtents=r)}}}function y2(n){const t=n.readString(),e=n.readString(),i=n.readU8()!==0,r=_2(n),s=v2(n.readJson()),o=n.readU32(),a=[];for(let u=0;u<o;u++)a.push(Ny(n));const l=n.readU32(),c=[];for(let u=0;u<l;u++)c.push(Dy(n));return{btrId:t,name:e,isModelSpace:i,lineBatches:a,meshBatches:c,osnap:r,viewports:s}}function v2(n){if(n!=null){if(Array.isArray(n))return n;if(typeof n=="object")return n.viewports??void 0}}function _2(n){const t=n.readU32();if(t===0)return;const e=n.readBytes(t);if(x2(e))return Td(e);const i=ky(e);if(!(i.length===0||i==="null"))return JSON.parse(i)}function x2(n){return n.length<4?!1:(n[0]|n[1]<<8|n[2]<<16|n[3]<<24)>>>0===Uy}function Fy(n){const t=Md(n);return m2(t)}function b2(n,t="base85"){const e=t==="base64"||t==="base85"?t:Ad(t);return Cd(n,e)}var ci;(function(n){n[n.Invalid=-9999]="Invalid",n[n.Start=0]="Start",n[n.Text=1]="Text",n[n.AttributeTag=2]="AttributeTag",n[n.BlockName=2]="BlockName",n[n.ShapeName=2]="ShapeName",n[n.SymbolTableName=2]="SymbolTableName",n[n.SymbolTableRecordName=2]="SymbolTableRecordName",n[n.MlineStyleName=2]="MlineStyleName",n[n.AttributePrompt=3]="AttributePrompt",n[n.Description=3]="Description",n[n.DimPostString=3]="DimPostString",n[n.DimStyleName=3]="DimStyleName",n[n.LinetypeProse=3]="LinetypeProse",n[n.TextFontFile=3]="TextFontFile",n[n.CLShapeName=4]="CLShapeName",n[n.DimensionAlternativePrefixSuffix=4]="DimensionAlternativePrefixSuffix",n[n.SymbolTableRecordComments=4]="SymbolTableRecordComments",n[n.TextBigFontFile=4]="TextBigFontFile",n[n.Handle=5]="Handle",n[n.DimensionBlock=5]="DimensionBlock",n[n.LinetypeName=6]="LinetypeName",n[n.DimBlk1=6]="DimBlk1",n[n.TextStyleName=7]="TextStyleName",n[n.DimBlk2=7]="DimBlk2",n[n.LayerName=8]="LayerName",n[n.CLShapeText=9]="CLShapeText",n[n.XCoordinate=10]="XCoordinate",n[n.YCoordinate=20]="YCoordinate",n[n.ZCoordinate=30]="ZCoordinate",n[n.Real=40]="Real",n[n.TxtSize=40]="TxtSize",n[n.ViewportHeight=40]="ViewportHeight",n[n.Angle=50]="Angle",n[n.ViewportSnapAngle=50]="ViewportSnapAngle",n[n.Visibility=60]="Visibility",n[n.Int16=70]="Int16",n[n.Int32=90]="Int32",n[n.Int64=160]="Int64",n[n.Int8=280]="Int8",n[n.Thickness=39]="Thickness",n[n.Elevation=38]="Elevation",n[n.LinetypeScale=48]="LinetypeScale",n[n.DashLength=49]="DashLength",n[n.MlineOffset=49]="MlineOffset",n[n.LinetypeElement=49]="LinetypeElement",n[n.NormalX=210]="NormalX",n[n.NormalY=220]="NormalY",n[n.NormalZ=230]="NormalZ",n[n.UcsOrg=110]="UcsOrg",n[n.UcsOrientationX=111]="UcsOrientationX",n[n.UcsOrientationY=112]="UcsOrientationY",n[n.ViewHeight=45]="ViewHeight",n[n.ViewWidth=41]="ViewWidth",n[n.ViewLensLength=42]="ViewLensLength",n[n.ViewFrontClip=43]="ViewFrontClip",n[n.ViewBackClip=44]="ViewBackClip",n[n.ViewBrightness=141]="ViewBrightness",n[n.ViewContrast=142]="ViewContrast",n[n.ViewMode=71]="ViewMode",n[n.ViewportActive=68]="ViewportActive",n[n.ViewportAspect=41]="ViewportAspect",n[n.ViewportGrid=76]="ViewportGrid",n[n.ViewportIcon=74]="ViewportIcon",n[n.ViewportNumber=69]="ViewportNumber",n[n.ViewportSnap=75]="ViewportSnap",n[n.ViewportSnapPair=78]="ViewportSnapPair",n[n.ViewportSnapStyle=77]="ViewportSnapStyle",n[n.ViewportTwist=51]="ViewportTwist",n[n.ViewportVisibility=67]="ViewportVisibility",n[n.ViewportZoom=73]="ViewportZoom",n[n.Color=62]="Color",n[n.ColorRgb=420]="ColorRgb",n[n.ColorName=430]="ColorName",n[n.LineWeight=370]="LineWeight",n[n.PlotStyleNameType=380]="PlotStyleNameType",n[n.PlotStyleNameId=390]="PlotStyleNameId",n[n.GradientObjType=450]="GradientObjType",n[n.GradientAngle=460]="GradientAngle",n[n.GradientName=470]="GradientName",n[n.GradientColCount=453]="GradientColCount",n[n.GradientPatType=451]="GradientPatType",n[n.GradientTintType=452]="GradientTintType",n[n.GradientShift=461]="GradientShift",n[n.GradientColVal=463]="GradientColVal",n[n.GradientTintVal=462]="GradientTintVal",n[n.SoftPointerId=330]="SoftPointerId",n[n.HardPointerId=340]="HardPointerId",n[n.SoftOwnershipId=350]="SoftOwnershipId",n[n.HardOwnershipId=360]="HardOwnershipId",n[n.ArbitraryHandle=320]="ArbitraryHandle",n[n.ExtendedDataAsciiString=1e3]="ExtendedDataAsciiString",n[n.ExtendedDataRegAppName=1001]="ExtendedDataRegAppName",n[n.ExtendedDataControlString=1002]="ExtendedDataControlString",n[n.ExtendedDataLayerName=1003]="ExtendedDataLayerName",n[n.ExtendedDataBinaryChunk=1004]="ExtendedDataBinaryChunk",n[n.ExtendedDataHandle=1005]="ExtendedDataHandle",n[n.ExtendedDataXCoordinate=1010]="ExtendedDataXCoordinate",n[n.ExtendedDataWorldXCoordinate=1011]="ExtendedDataWorldXCoordinate",n[n.ExtendedDataWorldXDisp=1012]="ExtendedDataWorldXDisp",n[n.ExtendedDataWorldXDir=1013]="ExtendedDataWorldXDir",n[n.ExtendedDataYCoordinate=1020]="ExtendedDataYCoordinate",n[n.ExtendedDataWorldYCoordinate=1021]="ExtendedDataWorldYCoordinate",n[n.ExtendedDataWorldYDisp=1022]="ExtendedDataWorldYDisp",n[n.ExtendedDataWorldYDir=1023]="ExtendedDataWorldYDir",n[n.ExtendedDataZCoordinate=1030]="ExtendedDataZCoordinate",n[n.ExtendedDataWorldZCoordinate=1031]="ExtendedDataWorldZCoordinate",n[n.ExtendedDataWorldZDisp=1032]="ExtendedDataWorldZDisp",n[n.ExtendedDataWorldZDir=1033]="ExtendedDataWorldZDir",n[n.ExtendedDataReal=1040]="ExtendedDataReal",n[n.ExtendedDataDist=1041]="ExtendedDataDist",n[n.ExtendedDataScale=1042]="ExtendedDataScale",n[n.ExtendedDataInteger16=1070]="ExtendedDataInteger16",n[n.ExtendedDataInteger32=1071]="ExtendedDataInteger32",n[n.XTextString=300]="XTextString",n[n.XReal=140]="XReal",n[n.XInt16=170]="XInt16",n[n.XXInt16=270]="XXInt16",n[n.Subclass=100]="Subclass",n[n.ControlString=102]="ControlString",n[n.EmbeddedObjectStart=101]="EmbeddedObjectStart",n[n.End=-1]="End",n[n.FirstEntityId=-2]="FirstEntityId",n[n.HeaderId=-2]="HeaderId",n[n.XDataStart=-3]="XDataStart",n[n.Operator=-4]="Operator",n[n.PReactors=-5]="PReactors",n[n.XDictionary=-6]="XDictionary"})(ci||(ci={}));var fe;(function(n){n[n.ByColor=1]="ByColor",n[n.ByACI=2]="ByACI",n[n.ByLayer=3]="ByLayer",n[n.ByBlock=4]="ByBlock",n[n.None=0]="None"})(fe||(fe={}));var S2=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},w2=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},Hy={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Id=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215,0],rs=(function(){function n(){}return n.getColorByIndex=function(t){return Id[t]},n.getIndexByColor=function(t){for(var e=Id.length-1,i=1;i<e;++i)if(Id[i]===t)return i},n.getColorByName=function(t){return Hy[t.toLowerCase()]},n.getNameByColor=function(t){var e,i;try{for(var r=S2(Object.entries(Hy)),s=r.next();!s.done;s=r.next()){var o=w2(s.value,2),a=o[0],l=o[1];if(l===t)return a}}catch(c){e={error:c}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(e)throw e.error}}},n.getNameByIndex=function(t){var e=this.getColorByIndex(t);return this.getNameByColor(e)},n})(),M2=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},rn=(function(){function n(t,e){if(t===void 0&&(t=fe.ByLayer),this._colorMethod=t,this._colorMethod==fe.ByColor&&e==null)this._value=16777215;else if(this._colorMethod==fe.ByACI)if(e==null)this._value=8;else if(e===0)this._colorMethod=fe.ByBlock;else if(e===256)this._colorMethod=fe.ByLayer;else{var i=Math.max(0,Math.min(256,Math.round(Number(e))));!Number.isFinite(i)||i===0?(this._colorMethod=fe.ByBlock,this._value=void 0):i===256?(this._colorMethod=fe.ByLayer,this._value=void 0):this._value=i}else this._value=e}return Object.defineProperty(n.prototype,"colorMethod",{get:function(){return this._colorMethod},set:function(t){this._colorMethod=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"red",{get:function(){var t=this.RGB;return t!=null?t>>16&255:void 0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"green",{get:function(){var t=this.RGB;return t!=null?t>>8&255:void 0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"blue",{get:function(){var t=this.RGB;return t!=null?t&255:void 0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"RGB",{get:function(){switch(this._colorMethod){case fe.ByColor:case fe.ByBlock:case fe.ByLayer:return this._value;case fe.ByACI:return this._value?rs.getColorByIndex(this._value):this._value;default:return}},enumerable:!1,configurable:!0}),n.prototype.setRGB=function(t,e,i){var r=Math.max(0,Math.min(255,Math.round(t))),s=Math.max(0,Math.min(255,Math.round(e))),o=Math.max(0,Math.min(255,Math.round(i)));return this._value=r<<16|s<<8|o,this._colorMethod=fe.ByColor,this},n.prototype.setRGBValue=function(t){return t==null||!Number.isFinite(t)?(console.warn("Invalid RGB value:",t),this):(this._value=t&16777215,this._colorMethod=fe.ByColor,this)},n.prototype.setRGBFromCss=function(t){if(!t)return this;var e=t.trim().toLowerCase();if(e.startsWith("#")){var i=0,r=0,s=0;if(e.length===7)i=parseInt(e.substr(1,2),16),r=parseInt(e.substr(3,2),16),s=parseInt(e.substr(5,2),16);else if(e.length===4)i=parseInt(e[1]+e[1],16),r=parseInt(e[2]+e[2],16),s=parseInt(e[3]+e[3],16);else return console.warn("Invalid hex color:",t),this;return this.setRGB(i,r,s)}var o=e.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);if(o){var i=parseInt(o[1],10),r=parseInt(o[2],10),s=parseInt(o[3],10);return this.setRGB(i,r,s)}var a=rs.getColorByName(t);return a!==void 0?this.setRGBValue(a):(console.warn("Unknown CSS color string:",t),this)},n.prototype.setScalar=function(t){return this.setRGB(t,t,t)},Object.defineProperty(n.prototype,"hexColor",{get:function(){var t=this.RGB;if(t!=null){var e=t.toString(16).padStart(6,"0").toUpperCase();return"0x"+e}},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"cssColor",{get:function(){var t=this.RGB;if(t!=null)return"rgb(".concat(t>>16&255,",").concat(t>>8&255,",").concat(t&255,")")},enumerable:!1,configurable:!0}),n.prototype.cssColorAlpha=function(t){var e=this.RGB;if(e!=null)return"rgba(".concat(e>>16&255,",").concat(e>>8&255,",").concat(e&255,",").concat(t,")")},Object.defineProperty(n.prototype,"colorIndex",{get:function(){return this._colorMethod===fe.ByACI?this._value:this._colorMethod===fe.ByLayer?256:this._colorMethod===fe.ByBlock?0:void 0},set:function(t){if(t!=null){var e=Math.max(0,Math.min(256,Math.round(Number(t))));if(!Number.isFinite(e)){this._colorMethod=fe.ByBlock,this._value=void 0;return}e===0?(this._colorMethod=fe.ByBlock,this._value=void 0):e===256?(this._colorMethod=fe.ByLayer,this._value=void 0):(this._colorMethod=fe.ByACI,this._value=e)}},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isByColor",{get:function(){return this._colorMethod===fe.ByColor},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isByACI",{get:function(){return this._colorMethod===fe.ByACI},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isForeground",{get:function(){return this._colorMethod===fe.ByACI&&this._value===7},enumerable:!1,configurable:!0}),n.prototype.setForeground=function(){return this._colorMethod=fe.ByACI,this._value=7,this},Object.defineProperty(n.prototype,"isByLayer",{get:function(){return this._colorMethod===fe.ByLayer},enumerable:!1,configurable:!0}),n.prototype.setByLayer=function(t){return this._colorMethod=fe.ByLayer,t==null?this._value=256:this._value=t,this},Object.defineProperty(n.prototype,"isByBlock",{get:function(){return this._colorMethod===fe.ByBlock},enumerable:!1,configurable:!0}),n.prototype.setByBlock=function(t){return this._colorMethod=fe.ByBlock,t==null?this._value=0:this._value=t,this},Object.defineProperty(n.prototype,"colorName",{get:function(){switch(this._colorMethod){case fe.ByLayer:return"ByLayer";case fe.ByBlock:return"ByBlock";case fe.ByColor:return this._value?rs.getNameByColor(this._value):"";case fe.ByACI:return this._value?rs.getNameByIndex(this._value):"";default:return}},set:function(t){if(t){var e=rs.getColorByName(t);e!==void 0?(this._value=e,this._colorMethod=fe.ByColor):console.warn("Unknown color name:",t)}},enumerable:!1,configurable:!0}),n.prototype.clone=function(){var t=new n;return t._colorMethod=this._colorMethod,t._value=this._value,t},n.prototype.copy=function(t){return this._colorMethod=t._colorMethod,this._value=t._value,this},n.prototype.equals=function(t){return this._colorMethod===t._colorMethod&&this._value===t._value},n.prototype.toString=function(){switch(this._colorMethod){case fe.None:return"None";case fe.ByLayer:return"ByLayer";case fe.ByBlock:return"ByBlock";case fe.ByACI:return this._value!==void 0?String(this._value):"";case fe.ByColor:return this._value?"RGB:".concat(this.red,",").concat(this.green,",").concat(this.blue):"";default:return""}},n.fromString=function(t){if(t){var e=t.trim();if(/^none$/i.test(e))return new n(fe.None);if(/^bylayer$/i.test(e))return new n(fe.ByLayer);if(/^byblock$/i.test(e))return new n(fe.ByBlock);var i=e.match(/^rgb\s*:\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})$/i);if(i){var r=Number(i[1]),s=Number(i[2]),o=Number(i[3]),a=new n(fe.ByColor);return a.setRGB(r,s,o),a}if(/^\d{1,3},\d{1,3},\d{1,3}$/.test(e)){var l=M2(e.split(",").map(Number),3),r=l[0],s=l[1],o=l[2],a=new n(fe.ByColor);return a.setRGB(r,s,o),a}if(/^\d+$/.test(e)){var c=parseInt(e,10);return new n(fe.ByACI,c)}if(/^book\$/i.test(e)){var u=e.substring(e.indexOf("$")+1),h=rs.getColorByName(u);if(h!=null)return new n(fe.ByColor,h);console.warn("Unknown color book entry:",t);return}var d=rs.getColorByName(e);if(d!=null)return new n(fe.ByColor,d);console.warn("Unknown color name:",t)}},n})(),Lr={get ILLEGAL_PARAMETERS(){return new ReferenceError("Illegal Parameters")}},E2=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},A2=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},C2=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))},vc=(function(){function n(){this.listeners=[]}return Object.defineProperty(n.prototype,"listenerCount",{get:function(){return this.listeners.length},enumerable:!1,configurable:!0}),n.prototype.addEventListener=function(t){this.listeners.push(t)},n.prototype.removeEventListener=function(t){this.listeners=this.listeners.filter(function(e){return e!==t})},n.prototype.replaceEventListener=function(t){this.removeEventListener(t),this.addEventListener(t)},n.prototype.dispatch=function(t){for(var e,i,r=[],s=1;s<arguments.length;s++)r[s-1]=arguments[s];try{for(var o=E2(this.listeners),a=o.next();!a.done;a=o.next()){var l=a.value,c=l;c.call.apply(c,C2([null,t],A2(r),!1))}}catch(u){e={error:u}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(e)throw e.error}}},n})(),Pd=function(){return Pd=Object.assign||function(n){for(var t,e=1,i=arguments.length;e<i;e++){t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},Pd.apply(this,arguments)},T2=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},L2=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))},Gy=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function Xa(n){return n===null||typeof n!="object"?n:Array.isArray(n)?L2([],T2(n),!1):Pd({},n)}function Rd(n){for(var t,e,i=[],r=1;r<arguments.length;r++)i[r-1]=arguments[r];try{for(var s=Gy(i),o=s.next();!o.done;o=s.next()){var a=o.value;if(a)for(var l in a)Object.prototype.hasOwnProperty.call(a,l)&&n[l]===void 0&&(n[l]=a[l])}}catch(c){t={error:c}}finally{try{o&&!o.done&&(e=s.return)&&e.call(s)}finally{if(t)throw t.error}}return n}function I2(n,t){return n!=null&&Object.prototype.hasOwnProperty.call(n,t)}function P2(n){return n==null?!0:Array.isArray(n)||typeof n=="string"?n.length===0:n instanceof Map||n instanceof Set?n.size===0:typeof n=="object"?Object.keys(n).length===0:!1}function po(n,t){var e,i;if(n===t)return!0;if(n==null||t==null)return n===t;if(typeof n!=typeof t)return!1;if(typeof n!="object")return n===t;if(Array.isArray(n)!==Array.isArray(t))return!1;if(Array.isArray(n)){if(n.length!==t.length)return!1;for(var r=0;r<n.length;r++)if(!po(n[r],t[r]))return!1;return!0}var s=Object.keys(n),o=Object.keys(t);if(s.length!==o.length)return!1;try{for(var a=Gy(s),l=a.next();!l.done;l=a.next()){var c=l.value;if(!Object.prototype.hasOwnProperty.call(t,c)||!po(n[c],t[c]))return!1}}catch(u){e={error:u}}finally{try{l&&!l.done&&(i=a.return)&&i.call(a)}finally{if(e)throw e.error}}return!0}var Vy=(function(){function n(t,e){this._changing=!1,this._pending=!1;var i=t||{};e&&Rd(i,e),this.attributes=i}return Object.defineProperty(n.prototype,"events",{get:function(){var t;return(t=this._events)!==null&&t!==void 0?t:this._events={attrChanged:new vc,modelChanged:new vc}},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"changed",{get:function(){var t;return(t=this._changed)!==null&&t!==void 0?t:this._changed={}},enumerable:!1,configurable:!0}),n.prototype.get=function(t){return this.attributes[t]},n.prototype.set=function(t,e,i){var r,s,o,a;if(t==null)return this;var l;typeof t=="object"?(l=t,i=e):(l={},l[t]=e),i||(i={});var c=i.unset,u=i.silent,h=this._events;if(!c&&!this._changing&&(h===void 0||h.attrChanged.listenerCount===0&&h.modelChanged.listenerCount===0)){if(typeof t=="object"){var d=t;for(var f in d)this.attributes[f]=d[f]}else this.attributes[t]=e;return this}if(!c){var p=!0;for(var f in l)if(this.attributes[f]!==l[f]){p=!1;break}if(p)return this._changing||(this._previousAttributes=Xa(this.attributes),this._changed={}),this}var g=null,y=this._changing;this._changing=!0,y||(this._previousAttributes=Xa(this.attributes),this._changed={});var m=this.attributes,v=(r=this._changed)!==null&&r!==void 0?r:this._changed={},x=(s=this._previousAttributes)!==null&&s!==void 0?s:{};for(var f in l){if(e=l[f],!c&&m[f]===e){x[f]===e||po(x[f],e)?delete v[f]:v[f]=e;continue}po(m[f],e)||(g||(g=[])).push(f),po(x[f],e)?delete v[f]:v[f]=e,c?delete m[f]:m[f]=e}if(!u&&(g&&(this._pending=i),g))for(var _=0;_<g.length;_++)(o=this._events)===null||o===void 0||o.attrChanged.dispatch({object:this,attrName:g[_],attrValue:m[g[_]],options:i});if(y)return this;if(!u)for(;this._pending;)i=this._pending,this._pending=!1,(a=this._events)===null||a===void 0||a.modelChanged.dispatch({object:this,options:i});return this._pending=!1,this._changing=!1,this},n.prototype.has=function(t){return this.get(t)!=null},n.prototype.hasChanged=function(t){return t==null?!P2(this._changed):this._changed?I2(this._changed,t):!1},n.prototype.changedAttributes=function(t){var e;if(!t)return this.hasChanged()?Xa((e=this._changed)!==null&&e!==void 0?e:{}):{};var i=this._changing?this._previousAttributes:this.attributes,r={};for(var s in t){var o=t[s];po(i==null?void 0:i[s],o)||(r[s]=o)}return r},n.prototype.previous=function(t){var e;return t==null?null:(e=this._previousAttributes)===null||e===void 0?void 0:e[t]},n.prototype.previousAttributes=function(){var t;return Xa((t=this._previousAttributes)!==null&&t!==void 0?t:{})},n.prototype.clone=function(){var t=Xa(this.attributes);return new n(t)},n})(),kn;(function(n){n[n.ByLayer=0]="ByLayer",n[n.ByBlock=1]="ByBlock",n[n.ByAlpha=2]="ByAlpha",n[n.ErrorValue=3]="ErrorValue"})(kn||(kn={}));var _c=(function(){function n(t){t!==void 0?(this._method=kn.ByAlpha,this._alpha=n.clampAlpha(t)):(this._method=kn.ByLayer,this._alpha=255)}return Object.defineProperty(n.prototype,"method",{get:function(){return this._method},set:function(t){this._method=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"alpha",{get:function(){return this._alpha},set:function(t){this._alpha=n.clampAlpha(t),this._method=kn.ByAlpha},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"percentage",{get:function(){if(this._method===kn.ByAlpha)return Math.round((1-this._alpha/255)*100)},set:function(t){var e=Math.max(0,Math.min(100,t)),i=Math.round(255*(1-e/100));this.alpha=i},enumerable:!1,configurable:!0}),n.clampAlpha=function(t){return Math.max(0,Math.min(255,Math.floor(t)))},Object.defineProperty(n.prototype,"isByAlpha",{get:function(){return this._method===kn.ByAlpha},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isByBlock",{get:function(){return this._method===kn.ByBlock},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isByLayer",{get:function(){return this._method===kn.ByLayer},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isClear",{get:function(){return this.isByAlpha&&this._alpha===0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isSolid",{get:function(){return this.isByAlpha&&this._alpha===255},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isInvalid",{get:function(){return this._method===kn.ErrorValue},enumerable:!1,configurable:!0}),n.prototype.serialize=function(){var t=this._method;return t<<24|this._alpha},n.prototype.clone=function(){var t=new n;return t._method=this._method,t._alpha=this._alpha,t},n.prototype.equals=function(t){return this._method===t._method&&this._alpha===t._alpha},n.prototype.toString=function(){return this.isByLayer?"ByLayer":this.isByBlock?"ByBlock":this._alpha.toString()},n.fromString=function(t){var e=t.trim(),i=e.toLowerCase();if(i===""||i==="."||i==="use current"||i==="bylayer"){var r=new n;return r._method=kn.ByLayer,r}if(i==="byblock"){var s=new n;return s._method=kn.ByBlock,s}var o=Number(e);if(Number.isInteger(o)&&o>=0&&o<=255){var a=new n;return o<=90?a.percentage=o:a.alpha=o,a}var l=new n;return l._method=kn.ErrorValue,l},n.deserialize=function(t){var e=t>>>24&255,i=t&255,r=e>=kn.ByLayer&&e<=kn.ErrorValue?e:kn.ErrorValue,s=new n;return s._method=r,s._alpha=n.clampAlpha(i),s},n})(),R2=function(n,t,e,i){function r(s){return s instanceof e?s:new e(function(o){o(s)})}return new(e||(e=Promise))(function(s,o){function a(u){try{c(i.next(u))}catch(h){o(h)}}function l(u){try{c(i.throw(u))}catch(h){o(h)}}function c(u){u.done?s(u.value):r(u.value).then(a,l)}c((i=i.apply(n,t||[])).next())})},k2=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(c){return function(u){return l([c,u])}}function l(c){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(e=0)),e;)try{if(i=1,r&&(s=c[0]&2?r.return:c[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,c[1])).done)return s;switch(r=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return e.label++,{value:c[1],done:!1};case 5:e.label++,r=c[1],c=[0];continue;case 7:c=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){e=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){e.label=c[1];break}if(c[0]===6&&e.label<s[1]){e.label=s[1],s=c;break}if(s&&e.label<s[2]){e.label=s[2],e.ops.push(c);break}s[2]&&e.ops.pop(),e.trys.pop();continue}c=t.call(n,e)}catch(u){c=[6,u],r=0}finally{i=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},O2=50;function Wy(){return new Promise(function(n){typeof globalThis<"u"&&typeof globalThis.requestAnimationFrame=="function"?globalThis.requestAnimationFrame(function(){return n()}):setTimeout(n,0)})}function ja(){return new Promise(function(n){if(typeof globalThis<"u"&&typeof globalThis.requestAnimationFrame=="function"){var t=globalThis.requestAnimationFrame;t(function(){return t(function(){return n()})})}else setTimeout(n,0)})}var B2=(function(){function n(t){t===void 0&&(t=O2),this._budgetMs=t,this._lastYieldCompletedAt=n.now()}return Object.defineProperty(n.prototype,"budgetMs",{get:function(){return this._budgetMs},enumerable:!1,configurable:!0}),n.prototype.maybeYield=function(){return R2(this,arguments,void 0,function(t){var e;return t===void 0&&(t=Wy),k2(this,function(i){switch(i.label){case 0:return e=n.now(),e-this._lastYieldCompletedAt<this._budgetMs?[2,!1]:[4,t()];case 1:return i.sent(),this._lastYieldCompletedAt=n.now(),[2,!0]}})})},n.prototype.mark=function(){this._lastYieldCompletedAt=n.now()},n.now=function(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()},n})(),On=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],Xy=1234567,jy=Math.PI/180,$y=180/Math.PI;function N2(){var n=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,i=Math.random()*4294967295|0,r=On[n&255]+On[n>>8&255]+On[n>>16&255]+On[n>>24&255]+"-"+On[t&255]+On[t>>8&255]+"-"+On[t>>16&15|64]+On[t>>24&255]+"-"+On[e&63|128]+On[e>>8&255]+"-"+On[e>>16&255]+On[e>>24&255]+On[i&255]+On[i>>8&255]+On[i>>16&255]+On[i>>24&255];return r.toLowerCase()}function $a(n,t,e){return Math.max(t,Math.min(e,n))}function Yy(n,t){return(n%t+t)%t}function D2(n,t,e,i,r){return i+(n-t)*(r-i)/(e-t)}function U2(n,t,e){return n!==t?(e-n)/(t-n):0}function qy(n,t,e){return(1-e)*n+e*t}function z2(n,t,e,i){return qy(n,t,1-Math.exp(-e*i))}function F2(n,t){return t===void 0&&(t=1),t-Math.abs(Yy(n,t*2)-t)}function H2(n,t,e){return n<=t?0:n>=e?1:(n=(n-t)/(e-t),n*n*(3-2*n))}function G2(n,t,e){return n<=t?0:n>=e?1:(n=(n-t)/(e-t),n*n*n*(n*(n*6-15)+10))}function V2(n,t){return n+Math.floor(Math.random()*(t-n+1))}function W2(n,t){return n+Math.random()*(t-n)}function X2(n){return n*(.5-Math.random())}function j2(n){n!==void 0&&(Xy=n);var t=Xy+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function $2(n){return n*jy}function Y2(n){return n*$y}function q2(n){return(n&n-1)===0&&n!==0}function K2(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function Z2(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function mo(n){var t=Math.PI*2;return(n%t+t)%t}function J2(n,t,e){return n>t&&n<e||n>e&&n<t}function Q2(n,t,e,i){return i===void 0&&(i=!1),n=mo(n),t=mo(t),e=mo(e),i?t>e?n<=t&&n>=e:n<=t||n>=e:t<e?n>=t&&n<=e:n>=t||n<=e}function tE(n,t,e){var i=mo(e-n),r=mo(t-n);return r<=i+1e-7}function Ky(n){return n=Math.abs(n),n<1?0:Math.ceil(Math.log10(Math.abs(n)+1))}function eE(n,t){t===void 0&&(t=1e-7);var e=Ky(n);return Math.max(Math.pow(10,e)*t,t)}var ne={DEG2RAD:jy,RAD2DEG:$y,generateUUID:N2,clamp:$a,euclideanModulo:Yy,mapLinear:D2,inverseLerp:U2,lerp:qy,damp:z2,pingpong:F2,smoothstep:H2,smootherstep:G2,randInt:V2,randFloat:W2,randFloatSpread:X2,seededRandom:j2,degToRad:$2,radToDeg:Y2,isPowerOfTwo:q2,ceilPowerOfTwo:K2,floorPowerOfTwo:Z2,normalizeAngle:mo,isBetween:J2,isBetweenAngle:Q2,isAngleOnCcwSweep:tE,intPartLength:Ky,relativeEps:eE},nE=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(c){return function(u){return l([c,u])}}function l(c){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(e=0)),e;)try{if(i=1,r&&(s=c[0]&2?r.return:c[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,c[1])).done)return s;switch(r=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return e.label++,{value:c[1],done:!1};case 5:e.label++,r=c[1],c=[0];continue;case 7:c=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){e=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){e.label=c[1];break}if(c[0]===6&&e.label<s[1]){e.label=s[1],s=c;break}if(s&&e.label<s[2]){e.label=s[2],e.ops.push(c);break}s[2]&&e.ops.pop(),e.trys.pop();continue}c=t.call(n,e)}catch(u){c=[6,u],r=0}finally{i=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},mn=(function(){function n(t,e){this.x=0,this.y=0;var i=+(t!==void 0)+ +(e!==void 0);if(i!==0){if(i===1&&t instanceof Array){this.x=t[0],this.y=t[1];return}if(i===1){var r=t,s=r.x,o=r.y;this.x=s,this.y=o;return}if(i===2){this.x=t,this.y=e;return}throw Lr.ILLEGAL_PARAMETERS}}return Object.defineProperty(n.prototype,"width",{get:function(){return this.x},set:function(t){this.x=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"height",{get:function(){return this.y},set:function(t){this.y=t},enumerable:!1,configurable:!0}),n.prototype.set=function(t,e){return this.x=t,this.y=e,this},n.prototype.setScalar=function(t){return this.x=t,this.y=t,this},n.prototype.setX=function(t){return this.x=t,this},n.prototype.setY=function(t){return this.y=t,this},n.prototype.setComponent=function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this},n.prototype.getComponent=function(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}},n.prototype.clone=function(){return new n(this.x,this.y)},n.prototype.copy=function(t){return this.x=t.x,this.y=t.y,this},n.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this},n.prototype.addScalar=function(t){return this.x+=t,this.y+=t,this},n.prototype.addVectors=function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},n.prototype.addScaledVector=function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this},n.prototype.sub=function(t){return this.x-=t.x,this.y-=t.y,this},n.prototype.subScalar=function(t){return this.x-=t,this.y-=t,this},n.prototype.subVectors=function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},n.prototype.multiply=function(t){return this.x*=t.x,this.y*=t.y,this},n.prototype.multiplyScalar=function(t){return this.x*=t,this.y*=t,this},n.prototype.divide=function(t){return this.x/=t.x,this.y/=t.y,this},n.prototype.divideScalar=function(t){return this.multiplyScalar(1/t)},n.prototype.applyMatrix2d=function(t){var e=this.x,i=this.y,r=t.elements;return this.x=r[0]*e+r[3]*i+r[6],this.y=r[1]*e+r[4]*i+r[7],this},n.prototype.min=function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this},n.prototype.max=function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this},n.prototype.clamp=function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this},n.prototype.clampScalar=function(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this},n.prototype.clampLength=function(t,e){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))},n.prototype.floor=function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},n.prototype.ceil=function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},n.prototype.round=function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},n.prototype.roundToZero=function(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this},n.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this},n.prototype.dot=function(t){return this.x*t.x+this.y*t.y},n.prototype.cross=function(t){return this.x*t.y-this.y*t.x},n.prototype.lengthSq=function(){return this.x*this.x+this.y*this.y},n.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},n.prototype.manhattanLength=function(){return Math.abs(this.x)+Math.abs(this.y)},n.prototype.normalize=function(){return this.divideScalar(this.length()||1)},n.prototype.angle=function(){var t=Math.atan2(-this.y,-this.x)+Math.PI;return t},n.prototype.angleTo=function(t){var e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;var i=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,i)))},n.prototype.distanceTo=function(t){return Math.sqrt(this.distanceToSquared(t))},n.prototype.distanceToSquared=function(t){var e=this.x-t.x,i=this.y-t.y;return e*e+i*i},n.prototype.manhattanDistanceTo=function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)},n.prototype.setLength=function(t){return this.normalize().multiplyScalar(t)},n.prototype.lerp=function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},n.prototype.lerpVectors=function(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this},n.prototype.equals=function(t){return t.x===this.x&&t.y===this.y},n.prototype.fromArray=function(t,e){return e===void 0&&(e=0),this.x=t[e],this.y=t[e+1],this},n.prototype.toArray=function(t,e){return t===void 0&&(t=[]),e===void 0&&(e=0),t[e]=this.x,t[e+1]=this.y,t},n.prototype.rotateAround=function(t,e){var i=Math.cos(e),r=Math.sin(e),s=this.x-t.x,o=this.y-t.y;return this.x=s*i-o*r+t.x,this.y=s*r+o*i+t.y,this},n.prototype.random=function(){return this.x=Math.random(),this.y=Math.random(),this},n.prototype.relativeEps=function(t){return t===void 0&&(t=1e-7),Math.min(ne.relativeEps(this.x,t),ne.relativeEps(this.y,t))},n.prototype[Symbol.iterator]=function(){return nE(this,function(t){switch(t.label){case 0:return[4,this.x];case 1:return t.sent(),[4,this.y];case 2:return t.sent(),[2]}})},n.EMPTY=Object.freeze(new n(0,0)),n})(),kd=(function(){function n(t,e,i,r,s,o,a,l,c){this.elements=[1,0,0,0,1,0,0,0,1],t!=null&&e!=null&&i!=null&&r!=null&&s!=null&&o!=null&&a!=null&&l!=null&&c!=null&&this.set(t,e,i,r,s,o,a,l,c)}return n.prototype.set=function(t,e,i,r,s,o,a,l,c){var u=this.elements;return u[0]=t,u[1]=r,u[2]=a,u[3]=e,u[4]=s,u[5]=l,u[6]=i,u[7]=o,u[8]=c,this},n.prototype.identity=function(){return this.set(1,0,0,0,1,0,0,0,1),this},n.prototype.copy=function(t){var e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this},n.prototype.extractBasis=function(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this},n.prototype.setFromMatrix4=function(t){var e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this},n.prototype.multiply=function(t){return this.multiplyMatrices(this,t)},n.prototype.premultiply=function(t){return this.multiplyMatrices(t,this)},n.prototype.multiplyMatrices=function(t,e){var i=t.elements,r=e.elements,s=this.elements,o=i[0],a=i[3],l=i[6],c=i[1],u=i[4],h=i[7],d=i[2],f=i[5],p=i[8],g=r[0],y=r[3],m=r[6],v=r[1],x=r[4],_=r[7],b=r[2],w=r[5],C=r[8];return s[0]=o*g+a*v+l*b,s[3]=o*y+a*x+l*w,s[6]=o*m+a*_+l*C,s[1]=c*g+u*v+h*b,s[4]=c*y+u*x+h*w,s[7]=c*m+u*_+h*C,s[2]=d*g+f*v+p*b,s[5]=d*y+f*x+p*w,s[8]=d*m+f*_+p*C,this},n.prototype.multiplyScalar=function(t){var e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this},n.prototype.determinant=function(){var t=this.elements,e=t[0],i=t[1],r=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],u=t[8];return e*o*u-e*a*c-i*s*u+i*a*l+r*s*c-r*o*l},n.prototype.invert=function(){var t=this.elements,e=t[0],i=t[1],r=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=u*o-a*c,d=a*l-u*s,f=c*s-o*l,p=e*h+i*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);var g=1/p;return t[0]=h*g,t[1]=(r*c-u*i)*g,t[2]=(a*i-r*o)*g,t[3]=d*g,t[4]=(u*e-r*l)*g,t[5]=(r*s-a*e)*g,t[6]=f*g,t[7]=(i*l-c*e)*g,t[8]=(o*e-i*s)*g,this},n.prototype.transpose=function(){var t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this},n.prototype.getNormalMatrix=function(t){return this.setFromMatrix4(t).invert().transpose()},n.prototype.transposeIntoArray=function(t){var e=this.elements;return t.elements[0]=e[0],t.elements[1]=e[3],t.elements[2]=e[6],t.elements[3]=e[1],t.elements[4]=e[4],t.elements[5]=e[7],t.elements[6]=e[2],t.elements[7]=e[5],t.elements[8]=e[8],this},n.prototype.setUvTransform=function(t,e,i,r,s,o,a){var l=Math.cos(s),c=Math.sin(s);return this.set(i*l,i*c,-i*(l*o+c*a)+o+t,-r*c,r*l,-r*(-c*o+l*a)+a+e,0,0,1),this},n.prototype.scale=function(t,e){return this.premultiply(Od.makeScale(t,e)),this},n.prototype.rotate=function(t){return this.premultiply(Od.makeRotation(-t)),this},n.prototype.translate=function(t,e){return this.premultiply(Od.makeTranslation(t,e)),this},n.prototype.makeTranslation=function(t,e){return t instanceof mn?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this},n.prototype.makeRotation=function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,i,e,0,0,0,1),this},n.prototype.makeScale=function(t,e){return this.set(t,0,0,0,e,0,0,0,1),this},n.prototype.equals=function(t){for(var e=this.elements,i=t.elements,r=0;r<9;r++)if(e[r]!==i[r])return!1;return!0},n.prototype.fromArray=function(t,e){e===void 0&&(e=0);for(var i=0;i<9;i++)this.elements[i]=t[i+e];return this},n.prototype.toArray=function(t,e){t===void 0&&(t=[]),e===void 0&&(e=0);var i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t},n.prototype.clone=function(){return new n().fromArray(this.elements)},n.IDENTITY=Object.freeze(new n),n})(),Od=new kd,Oe=1e-6,ue=2*Math.PI,Zy={x:0,y:0,z:0},Ae=(function(){function n(){this.equalPointTol=Oe,this.equalVectorTol=Oe}return n.prototype.clone=function(){var t=new n;return t.equalPointTol=this.equalPointTol,t.equalVectorTol=this.equalVectorTol,t},n.prototype.equalPoint2d=function(t,e){return new mn(t).sub(e).length()<this.equalPointTol},n.prototype.equalPoint3d=function(t,e){return new _t(t).sub(e).length()<this.equalPointTol},n.equalToZero=function(t,e){return e===void 0&&(e=Oe),t<e&&t>-e},n.equal=function(t,e,i){return i===void 0&&(i=Oe),Math.abs(t-e)<i},n.great=function(t,e,i){return i===void 0&&(i=Oe),t-e>i},n.less=function(t,e,i){return i===void 0&&(i=Oe),t-e<i},n.isPositive=function(t,e){return e===void 0&&(e=Oe),t>e},n.isNonPositive=function(t,e){return e===void 0&&(e=Oe),t<=e},n})(),Jy=new Ae,iE=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(c){return function(u){return l([c,u])}}function l(c){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(e=0)),e;)try{if(i=1,r&&(s=c[0]&2?r.return:c[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,c[1])).done)return s;switch(r=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return e.label++,{value:c[1],done:!1};case 5:e.label++,r=c[1],c=[0];continue;case 7:c=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){e=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){e.label=c[1];break}if(c[0]===6&&e.label<s[1]){e.label=s[1],s=c;break}if(s&&e.label<s[2]){e.label=s[2],e.ops.push(c);break}s[2]&&e.ops.pop(),e.trys.pop();continue}c=t.call(n,e)}catch(u){c=[6,u],r=0}finally{i=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},rE=(function(){function n(t,e,i,r){t===void 0&&(t=0),e===void 0&&(e=0),i===void 0&&(i=0),r===void 0&&(r=1),this._x=t,this._y=e,this._z=i,this._w=r}return n.slerpFlat=function(t,e,i,r,s,o,a){var l=i[r+0],c=i[r+1],u=i[r+2],h=i[r+3],d=s[o+0],f=s[o+1],p=s[o+2],g=s[o+3];if(a===0){t[e+0]=l,t[e+1]=c,t[e+2]=u,t[e+3]=h;return}if(a===1){t[e+0]=d,t[e+1]=f,t[e+2]=p,t[e+3]=g;return}if(h!==g||l!==d||c!==f||u!==p){var y=1-a,m=l*d+c*f+u*p+h*g,v=m>=0?1:-1,x=1-m*m;if(x>Number.EPSILON){var _=Math.sqrt(x),b=Math.atan2(_,m*v);y=Math.sin(y*b)/_,a=Math.sin(a*b)/_}var w=a*v;if(l=l*y+d*w,c=c*y+f*w,u=u*y+p*w,h=h*y+g*w,y===1-a){var C=1/Math.sqrt(l*l+c*c+u*u+h*h);l*=C,c*=C,u*=C,h*=C}}t[e]=l,t[e+1]=c,t[e+2]=u,t[e+3]=h},n.multiplyQuaternionsFlat=function(t,e,i,r,s,o){var a=i[r],l=i[r+1],c=i[r+2],u=i[r+3],h=s[o],d=s[o+1],f=s[o+2],p=s[o+3];return t[e]=a*p+u*h+l*f-c*d,t[e+1]=l*p+u*d+c*h-a*f,t[e+2]=c*p+u*f+a*d-l*h,t[e+3]=u*p-a*h-l*d-c*f,t},Object.defineProperty(n.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._onChangeCallback()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._onChangeCallback()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"z",{get:function(){return this._z},set:function(t){this._z=t,this._onChangeCallback()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"w",{get:function(){return this._w},set:function(t){this._w=t,this._onChangeCallback()},enumerable:!1,configurable:!0}),n.prototype.set=function(t,e,i,r){return this._x=t,this._y=e,this._z=i,this._w=r,this._onChangeCallback(),this},n.prototype.clone=function(){return new n(this._x,this._y,this._z,this._w)},n.prototype.copy=function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this},n.prototype.setFromEuler=function(t,e){e===void 0&&(e=!0);var i=t.x,r=t.y,s=t.z,o=t.order,a=Math.cos,l=Math.sin,c=a(i/2),u=a(r/2),h=a(s/2),d=l(i/2),f=l(r/2),p=l(s/2);switch(o){case"XYZ":this._x=d*u*h+c*f*p,this._y=c*f*h-d*u*p,this._z=c*u*p+d*f*h,this._w=c*u*h-d*f*p;break;case"YXZ":this._x=d*u*h+c*f*p,this._y=c*f*h-d*u*p,this._z=c*u*p-d*f*h,this._w=c*u*h+d*f*p;break;case"ZXY":this._x=d*u*h-c*f*p,this._y=c*f*h+d*u*p,this._z=c*u*p+d*f*h,this._w=c*u*h-d*f*p;break;case"ZYX":this._x=d*u*h-c*f*p,this._y=c*f*h+d*u*p,this._z=c*u*p-d*f*h,this._w=c*u*h+d*f*p;break;case"YZX":this._x=d*u*h+c*f*p,this._y=c*f*h+d*u*p,this._z=c*u*p-d*f*h,this._w=c*u*h-d*f*p;break;case"XZY":this._x=d*u*h-c*f*p,this._y=c*f*h-d*u*p,this._z=c*u*p+d*f*h,this._w=c*u*h+d*f*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e===!0&&this._onChangeCallback(),this},n.prototype.setFromAxisAngle=function(t,e){var i=e/2,r=Math.sin(i);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(i),this._onChangeCallback(),this},n.prototype.setFromRotationMatrix=function(t){var e=t.elements,i=e[0],r=e[4],s=e[8],o=e[1],a=e[5],l=e[9],c=e[2],u=e[6],h=e[10],d=i+a+h;if(d>0){var f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(u-l)*f,this._y=(s-c)*f,this._z=(o-r)*f}else if(i>a&&i>h){var f=2*Math.sqrt(1+i-a-h);this._w=(u-l)/f,this._x=.25*f,this._y=(r+o)/f,this._z=(s+c)/f}else if(a>h){var f=2*Math.sqrt(1+a-i-h);this._w=(s-c)/f,this._x=(r+o)/f,this._y=.25*f,this._z=(l+u)/f}else{var f=2*Math.sqrt(1+h-i-a);this._w=(o-r)/f,this._x=(s+c)/f,this._y=(l+u)/f,this._z=.25*f}return this._onChangeCallback(),this},n.prototype.setFromUnitVectors=function(t,e){var i=t.dot(e)+1;return i<Number.EPSILON?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=i),this.normalize()},n.prototype.angleTo=function(t){return 2*Math.acos(Math.abs($a(this.dot(t),-1,1)))},n.prototype.rotateTowards=function(t,e){var i=this.angleTo(t);if(i===0)return this;var r=Math.min(1,e/i);return this.slerp(t,r),this},n.prototype.identity=function(){return this.set(0,0,0,1)},n.prototype.invert=function(){return this.conjugate()},n.prototype.conjugate=function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this},n.prototype.dot=function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w},n.prototype.lengthSq=function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},n.prototype.length=function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},n.prototype.normalize=function(){var t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this},n.prototype.multiply=function(t){return this.multiplyQuaternions(this,t)},n.prototype.premultiply=function(t){return this.multiplyQuaternions(t,this)},n.prototype.multiplyQuaternions=function(t,e){var i=t._x,r=t._y,s=t._z,o=t._w,a=e._x,l=e._y,c=e._z,u=e._w;return this._x=i*u+o*a+r*c-s*l,this._y=r*u+o*l+s*a-i*c,this._z=s*u+o*c+i*l-r*a,this._w=o*u-i*a-r*l-s*c,this._onChangeCallback(),this},n.prototype.slerp=function(t,e){if(e===0)return this;if(e===1)return this.copy(t);var i=this._x,r=this._y,s=this._z,o=this._w,a=o*t._w+i*t._x+r*t._y+s*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=i,this._y=r,this._z=s,this;var l=1-a*a;if(l<=Number.EPSILON){var c=1-e;return this._w=c*o+e*this._w,this._x=c*i+e*this._x,this._y=c*r+e*this._y,this._z=c*s+e*this._z,this.normalize(),this}var u=Math.sqrt(l),h=Math.atan2(u,a),d=Math.sin((1-e)*h)/u,f=Math.sin(e*h)/u;return this._w=o*d+this._w*f,this._x=i*d+this._x*f,this._y=r*d+this._y*f,this._z=s*d+this._z*f,this._onChangeCallback(),this},n.prototype.slerpQuaternions=function(t,e,i){return this.copy(t).slerp(e,i)},n.prototype.random=function(){var t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(r*Math.sin(t),r*Math.cos(t),s*Math.sin(e),s*Math.cos(e))},n.prototype.equals=function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w},n.prototype.fromArray=function(t,e){return e===void 0&&(e=0),this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this},n.prototype.toArray=function(t,e){return t===void 0&&(t=[]),e===void 0&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t},n.prototype.toJSON=function(){return this.toArray()},n.prototype._onChange=function(t){return this._onChangeCallback=t,this},n.prototype._onChangeCallback=function(){},n.prototype[Symbol.iterator]=function(){return iE(this,function(t){switch(t.label){case 0:return[4,this._x];case 1:return t.sent(),[4,this._y];case 2:return t.sent(),[4,this._z];case 3:return t.sent(),[4,this._w];case 4:return t.sent(),[2]}})},n})(),sE=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(c){return function(u){return l([c,u])}}function l(c){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(e=0)),e;)try{if(i=1,r&&(s=c[0]&2?r.return:c[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,c[1])).done)return s;switch(r=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return e.label++,{value:c[1],done:!1};case 5:e.label++,r=c[1],c=[0];continue;case 7:c=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){e=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){e.label=c[1];break}if(c[0]===6&&e.label<s[1]){e.label=s[1],s=c;break}if(s&&e.label<s[2]){e.label=s[2],e.ops.push(c);break}s[2]&&e.ops.pop(),e.trys.pop();continue}c=t.call(n,e)}catch(u){c=[6,u],r=0}finally{i=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},_t=(function(){function n(t,e,i){this.x=0,this.y=0,this.z=0;var r=+(t!==void 0)+ +(e!==void 0)+ +(i!==void 0);if(r!==0){if(r===1&&t instanceof Array){this.x=t[0],this.y=t[1],this.z=t[2];return}if(r===1){var s=t,o=s.x,a=s.y,l=s.z;this.x=o,this.y=a,this.z=l||0;return}if(r===3){this.x=t,this.y=e,this.z=i;return}throw Lr.ILLEGAL_PARAMETERS}}return n.prototype.set=function(t,e,i){return i===void 0&&(i=this.z),this.x=t,this.y=e,this.z=i,this},n.prototype.setScalar=function(t){return this.x=t,this.y=t,this.z=t,this},n.prototype.setX=function(t){return this.x=t,this},n.prototype.setY=function(t){return this.y=t,this},n.prototype.setZ=function(t){return this.z=t,this},n.prototype.setComponent=function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this},n.prototype.getComponent=function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}},n.prototype.clone=function(){return new n(this.x,this.y,this.z)},n.prototype.copy=function(t){return this.x=t.x,this.y=t.y,this.z=t.z||0,this},n.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z||0,this},n.prototype.addScalar=function(t){return this.x+=t,this.y+=t,this.z+=t,this},n.prototype.addVectors=function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},n.prototype.addScaledVector=function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},n.prototype.sub=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this},n.prototype.subScalar=function(t){return this.x-=t,this.y-=t,this.z-=t,this},n.prototype.subVectors=function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},n.prototype.multiply=function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this},n.prototype.multiplyScalar=function(t){return this.x*=t,this.y*=t,this.z*=t,this},n.prototype.multiplyVectors=function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this},n.prototype.applyEuler=function(t){return this.applyQuaternion(Qy.setFromEuler(t))},n.prototype.applyAxisAngle=function(t,e){return this.applyQuaternion(Qy.setFromAxisAngle(t,e))},n.prototype.applyMatrix3=function(t){var e=this.x,i=this.y,r=this.z,s=t.elements;return this.x=s[0]*e+s[3]*i+s[6]*r,this.y=s[1]*e+s[4]*i+s[7]*r,this.z=s[2]*e+s[5]*i+s[8]*r,this},n.prototype.applyNormalMatrix=function(t){return this.applyMatrix3(t).normalize()},n.prototype.applyMatrix4=function(t){var e=this.x,i=this.y,r=this.z,s=t.elements,o=1/(s[3]*e+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*e+s[4]*i+s[8]*r+s[12])*o,this.y=(s[1]*e+s[5]*i+s[9]*r+s[13])*o,this.z=(s[2]*e+s[6]*i+s[10]*r+s[14])*o,this},n.prototype.applyQuaternion=function(t){var e=this.x,i=this.y,r=this.z,s=t.x,o=t.y,a=t.z,l=t.w,c=2*(o*r-a*i),u=2*(a*e-s*r),h=2*(s*i-o*e);return this.x=e+l*c+o*h-a*u,this.y=i+l*u+a*c-s*h,this.z=r+l*h+s*u-o*c,this},n.prototype.transformDirection=function(t){var e=this.x,i=this.y,r=this.z,s=t.elements;return this.x=s[0]*e+s[4]*i+s[8]*r,this.y=s[1]*e+s[5]*i+s[9]*r,this.z=s[2]*e+s[6]*i+s[10]*r,this.normalize()},n.prototype.divide=function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},n.prototype.divideScalar=function(t){return this.multiplyScalar(1/t)},n.prototype.min=function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this},n.prototype.max=function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this},n.prototype.clamp=function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this},n.prototype.clampScalar=function(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this},n.prototype.clampLength=function(t,e){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))},n.prototype.floor=function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},n.prototype.ceil=function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},n.prototype.round=function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},n.prototype.roundToZero=function(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this},n.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},n.prototype.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z},n.prototype.isParallelTo=function(t){var e=this.dot(t),i=this.length(),r=t.length();return Math.abs(e)===i*r},n.prototype.lengthSq=function(){return this.x*this.x+this.y*this.y+this.z*this.z},n.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},n.prototype.manhattanLength=function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},n.prototype.normalize=function(){return this.divideScalar(this.length()||1)},n.prototype.setLength=function(t){return this.normalize().multiplyScalar(t)},n.prototype.lerp=function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this},n.prototype.lerpVectors=function(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this},n.prototype.cross=function(t){return this.crossVectors(this,t)},n.prototype.crossVectors=function(t,e){var i=t.x,r=t.y,s=t.z,o=e.x,a=e.y,l=e.z;return this.x=r*l-s*a,this.y=s*o-i*l,this.z=i*a-r*o,this},n.prototype.projectOnVector=function(t){var e=t.lengthSq();if(e===0)return this.set(0,0,0);var i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)},n.prototype.projectOnPlane=function(t){return Bd.copy(this).projectOnVector(t),this.sub(Bd)},n.prototype.reflect=function(t){return this.sub(Bd.copy(t).multiplyScalar(2*this.dot(t)))},n.prototype.angleTo=function(t){var e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;var i=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,i)))},n.prototype.distanceTo=function(t){return Math.sqrt(this.distanceToSquared(t))},n.prototype.distanceToSquared=function(t){var e=this.x-t.x,i=this.y-t.y,r=this.z-t.z;return e*e+i*i+r*r},n.prototype.manhattanDistanceTo=function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)},n.prototype.setFromMatrixPosition=function(t){var e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this},n.prototype.setFromMatrixScale=function(t){var e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=r,this},n.prototype.setFromMatrixColumn=function(t,e){return this.fromArray(t.elements,e*4)},n.prototype.setFromMatrix3Column=function(t,e){return this.fromArray(t.elements,e*3)},n.prototype.equals=function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},n.prototype.fromArray=function(t,e){return e===void 0&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},n.prototype.toArray=function(t,e){return t===void 0&&(t=[]),e===void 0&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t},n.prototype.random=function(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this},n.prototype.randomDirection=function(){var t=Math.random()*Math.PI*2,e=Math.random()*2-1,i=Math.sqrt(1-e*e);return this.x=i*Math.cos(t),this.y=e,this.z=i*Math.sin(t),this},n.prototype[Symbol.iterator]=function(){return sE(this,function(t){switch(t.label){case 0:return[4,this.x];case 1:return t.sent(),[4,this.y];case 2:return t.sent(),[4,this.z];case 3:return t.sent(),[2]}})},n.ORIGIN=Object.freeze(new n(0,0,0)),n.X_AXIS=Object.freeze(new n(1,0,0)),n.NEGATIVE_X_AXIS=Object.freeze(new n(-1,0,0)),n.Y_AXIS=Object.freeze(new n(0,1,0)),n.NEGATIVE_Y_AXIS=Object.freeze(new n(0,-1,0)),n.Z_AXIS=Object.freeze(new n(0,0,1)),n.NEGATIVE_Z_AXIS=Object.freeze(new n(0,0,-1)),n})(),Bd=new _t,Qy=new rE,Ya=(function(){function n(t,e,i,r,s,o,a,l,c,u,h,d,f,p,g,y){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!=null&&e!=null&&i!=null&&r!=null&&s!=null&&o!=null&&a!=null&&l!=null&&c!=null&&u!=null&&h!=null&&d!=null&&f!=null&&p!=null&&g!=null&&y!=null&&this.set(t,e,i,r,s,o,a,l,c,u,h,d,f,p,g,y)}return n.makeTranslation=function(t,e,i){return new n().makeTranslation(t,e,i)},n.prototype.set=function(t,e,i,r,s,o,a,l,c,u,h,d,f,p,g,y){var m=this.elements;return m[0]=t,m[4]=e,m[8]=i,m[12]=r,m[1]=s,m[5]=o,m[9]=a,m[13]=l,m[2]=c,m[6]=u,m[10]=h,m[14]=d,m[3]=f,m[7]=p,m[11]=g,m[15]=y,this},n.prototype.identity=function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},n.prototype.clone=function(){return new n().fromArray(this.elements)},n.prototype.copy=function(t){var e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this},n.prototype.copyPosition=function(t){var e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this},n.prototype.setFromMatrix3=function(t){var e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this},n.prototype.setFromExtrusionDirection=function(t){var e=Math.hypot(t.x,t.y,t.z);if(!Number.isFinite(e)||e<1e-12)return this.identity(),this;var i=Math.abs(e-1)>1e-6?t.clone().multiplyScalar(1/e):t;if(Jy.equalPoint3d(i,_t.Z_AXIS))this.identity();else{var r=new _t(1,0,0);Math.abs(i.x)<1/64&&Math.abs(i.y)<1/64?r.crossVectors(_t.Y_AXIS,i).normalize():r.crossVectors(_t.Z_AXIS,i).normalize();var s=i.clone().cross(r).normalize();this.makeBasis(r,s,i)}return this},n.prototype.extractBasis=function(t,e,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this},n.prototype.makeBasis=function(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this},n.prototype.extractRotation=function(t){var e=this.elements,i=t.elements,r=1/go.setFromMatrixColumn(t,0).length(),s=1/go.setFromMatrixColumn(t,1).length(),o=1/go.setFromMatrixColumn(t,2).length();return e[0]=i[0]*r,e[1]=i[1]*r,e[2]=i[2]*r,e[3]=0,e[4]=i[4]*s,e[5]=i[5]*s,e[6]=i[6]*s,e[7]=0,e[8]=i[8]*o,e[9]=i[9]*o,e[10]=i[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},n.prototype.makeRotationFromQuaternion=function(t){return this.compose(oE,t,aE)},n.prototype.lookAt=function(t,e,i){var r=this.elements;return ui.subVectors(t,e),ui.lengthSq()===0&&(ui.z=1),ui.normalize(),ss.crossVectors(i,ui),ss.lengthSq()===0&&(Math.abs(i.z)===1?ui.x+=1e-4:ui.z+=1e-4,ui.normalize(),ss.crossVectors(i,ui)),ss.normalize(),xc.crossVectors(ui,ss),r[0]=ss.x,r[4]=xc.x,r[8]=ui.x,r[1]=ss.y,r[5]=xc.y,r[9]=ui.y,r[2]=ss.z,r[6]=xc.z,r[10]=ui.z,this},n.prototype.multiply=function(t){return this.multiplyMatrices(this,t)},n.prototype.premultiply=function(t){return this.multiplyMatrices(t,this)},n.prototype.multiplyMatrices=function(t,e){var i=t.elements,r=e.elements,s=this.elements,o=i[0],a=i[4],l=i[8],c=i[12],u=i[1],h=i[5],d=i[9],f=i[13],p=i[2],g=i[6],y=i[10],m=i[14],v=i[3],x=i[7],_=i[11],b=i[15],w=r[0],C=r[4],E=r[8],T=r[12],k=r[1],O=r[5],U=r[9],z=r[13],L=r[2],N=r[6],F=r[10],G=r[14],V=r[3],D=r[7],Y=r[11],Z=r[15];return s[0]=o*w+a*k+l*L+c*V,s[4]=o*C+a*O+l*N+c*D,s[8]=o*E+a*U+l*F+c*Y,s[12]=o*T+a*z+l*G+c*Z,s[1]=u*w+h*k+d*L+f*V,s[5]=u*C+h*O+d*N+f*D,s[9]=u*E+h*U+d*F+f*Y,s[13]=u*T+h*z+d*G+f*Z,s[2]=p*w+g*k+y*L+m*V,s[6]=p*C+g*O+y*N+m*D,s[10]=p*E+g*U+y*F+m*Y,s[14]=p*T+g*z+y*G+m*Z,s[3]=v*w+x*k+_*L+b*V,s[7]=v*C+x*O+_*N+b*D,s[11]=v*E+x*U+_*F+b*Y,s[15]=v*T+x*z+_*G+b*Z,this},n.prototype.multiplyScalar=function(t){var e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this},n.prototype.determinant=function(){var t=this.elements,e=t[0],i=t[4],r=t[8],s=t[12],o=t[1],a=t[5],l=t[9],c=t[13],u=t[2],h=t[6],d=t[10],f=t[14],p=t[3],g=t[7],y=t[11],m=t[15];return p*(+s*l*h-r*c*h-s*a*d+i*c*d+r*a*f-i*l*f)+g*(+e*l*f-e*c*d+s*o*d-r*o*f+r*c*u-s*l*u)+y*(+e*c*h-e*a*f-s*o*h+i*o*f+s*a*u-i*c*u)+m*(-r*a*u-e*l*h+e*a*d+r*o*h-i*o*d+i*l*u)},n.prototype.transpose=function(){var t=this.elements,e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this},n.prototype.setPosition=function(t,e,i){var r=this.elements;return t instanceof _t?(r[12]=t.x,r[13]=t.y,r[14]=t.z):(r[12]=t,r[13]=e,r[14]=i),this},n.prototype.invert=function(){var t=this.elements,e=t[0],i=t[1],r=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=t[9],d=t[10],f=t[11],p=t[12],g=t[13],y=t[14],m=t[15],v=h*y*c-g*d*c+g*l*f-a*y*f-h*l*m+a*d*m,x=p*d*c-u*y*c-p*l*f+o*y*f+u*l*m-o*d*m,_=u*g*c-p*h*c+p*a*f-o*g*f-u*a*m+o*h*m,b=p*h*l-u*g*l-p*a*d+o*g*d+u*a*y-o*h*y,w=e*v+i*x+r*_+s*b;if(w===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);var C=1/w;return t[0]=v*C,t[1]=(g*d*s-h*y*s-g*r*f+i*y*f+h*r*m-i*d*m)*C,t[2]=(a*y*s-g*l*s+g*r*c-i*y*c-a*r*m+i*l*m)*C,t[3]=(h*l*s-a*d*s-h*r*c+i*d*c+a*r*f-i*l*f)*C,t[4]=x*C,t[5]=(u*y*s-p*d*s+p*r*f-e*y*f-u*r*m+e*d*m)*C,t[6]=(p*l*s-o*y*s-p*r*c+e*y*c+o*r*m-e*l*m)*C,t[7]=(o*d*s-u*l*s+u*r*c-e*d*c-o*r*f+e*l*f)*C,t[8]=_*C,t[9]=(p*h*s-u*g*s-p*i*f+e*g*f+u*i*m-e*h*m)*C,t[10]=(o*g*s-p*a*s+p*i*c-e*g*c-o*i*m+e*a*m)*C,t[11]=(u*a*s-o*h*s-u*i*c+e*h*c+o*i*f-e*a*f)*C,t[12]=b*C,t[13]=(u*g*r-p*h*r+p*i*d-e*g*d-u*i*y+e*h*y)*C,t[14]=(p*a*r-o*g*r-p*i*l+e*g*l+o*i*y-e*a*y)*C,t[15]=(o*h*r-u*a*r+u*i*l-e*h*l-o*i*d+e*a*d)*C,this},n.prototype.scale=function(t){var e=this.elements,i=t.x,r=t.y,s=t.z;return e[0]*=i,e[4]*=r,e[8]*=s,e[1]*=i,e[5]*=r,e[9]*=s,e[2]*=i,e[6]*=r,e[10]*=s,e[3]*=i,e[7]*=r,e[11]*=s,this},n.prototype.getMaxScaleOnAxis=function(){var t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],r=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,r))},n.prototype.makeTranslation=function(t,e,i){var r;return typeof t=="object"?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,(r=t.z)!==null&&r!==void 0?r:0,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this},n.prototype.makeRotationX=function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this},n.prototype.makeRotationY=function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this},n.prototype.makeRotationZ=function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this},n.prototype.makeRotationAxis=function(t,e){var i=Math.cos(e),r=Math.sin(e),s=1-i,o=t.x,a=t.y,l=t.z,c=s*o,u=s*a;return this.set(c*o+i,c*a-r*l,c*l+r*a,0,c*a+r*l,u*a+i,u*l-r*o,0,c*l-r*a,u*l+r*o,s*l*l+i,0,0,0,0,1),this},n.prototype.makeScale=function(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this},n.prototype.makeShear=function(t,e,i,r,s,o){return this.set(1,i,s,0,t,1,o,0,e,r,1,0,0,0,0,1),this},n.prototype.compose=function(t,e,i){var r=this.elements,s=e.x,o=e.y,a=e.z,l=e.w,c=s+s,u=o+o,h=a+a,d=s*c,f=s*u,p=s*h,g=o*u,y=o*h,m=a*h,v=l*c,x=l*u,_=l*h,b=i.x,w=i.y,C=i.z;return r[0]=(1-(g+m))*b,r[1]=(f+_)*b,r[2]=(p-x)*b,r[3]=0,r[4]=(f-_)*w,r[5]=(1-(d+m))*w,r[6]=(y+v)*w,r[7]=0,r[8]=(p+x)*C,r[9]=(y-v)*C,r[10]=(1-(d+g))*C,r[11]=0,r[12]=t.x,r[13]=t.y,r[14]=t.z,r[15]=1,this},n.prototype.decompose=function(t,e,i){var r=this.elements,s=go.set(r[0],r[1],r[2]).length(),o=go.set(r[4],r[5],r[6]).length(),a=go.set(r[8],r[9],r[10]).length(),l=this.determinant();l<0&&(s=-s),t.x=r[12],t.y=r[13],t.z=r[14],Hi.copy(this);var c=1/s,u=1/o,h=1/a;return Hi.elements[0]*=c,Hi.elements[1]*=c,Hi.elements[2]*=c,Hi.elements[4]*=u,Hi.elements[5]*=u,Hi.elements[6]*=u,Hi.elements[8]*=h,Hi.elements[9]*=h,Hi.elements[10]*=h,e.setFromRotationMatrix(Hi),i.x=s,i.y=o,i.z=a,this},n.prototype.equals=function(t){for(var e=this.elements,i=t.elements,r=0;r<16;r++)if(e[r]!==i[r])return!1;return!0},n.prototype.fromArray=function(t,e){e===void 0&&(e=0);for(var i=0;i<16;i++)this.elements[i]=t[i+e];return this},n.prototype.toArray=function(t,e){t===void 0&&(t=[]),e===void 0&&(e=0);var i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t},n.IDENTITY=Object.freeze(new n),n})(),go=new _t,Hi=new Ya,oE=new _t(0,0,0),aE=new _t(1,1,1),ss=new _t,xc=new _t,ui=new _t,Rs=(function(){function n(t,e){t===void 0&&(t=void 0),e===void 0&&(e=void 0),this.min=t==null?new _t(1/0,1/0,1/0):new _t(t.x,t.y,t.z),this.max=e==null?new _t(-1/0,-1/0,-1/0):new _t(e.x,e.y,e.z)}return n.prototype.set=function(t,e){return this.min.copy(t),this.max.copy(e),this},n.prototype.setFromArray=function(t){this.makeEmpty();for(var e=0,i=t.length;e<i;e+=3)this.expandByPoint(Nd.fromArray(t,e));return this},n.prototype.setFromPoints=function(t){this.makeEmpty();for(var e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this},n.prototype.setFromCenterAndSize=function(t,e){var i=Nd.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this},n.prototype.clone=function(){return new n().copy(this)},n.prototype.copy=function(t){return this.min.copy(t.min),this.max.copy(t.max),this},n.prototype.makeEmpty=function(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this},n.prototype.isEmpty=function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},n.prototype.getCenter=function(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)},n.prototype.getSize=function(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)},Object.defineProperty(n.prototype,"center",{get:function(){return this.isEmpty()?new _t(0,0,0):new _t(0,0,0).addVectors(this.min,this.max).multiplyScalar(.5)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"size",{get:function(){return this.isEmpty()?new _t(0,0,0):new _t(0,0,0).subVectors(this.max,this.min)},enumerable:!1,configurable:!0}),n.prototype.expandByPoint=function(t){return!Number.isFinite(t.x)||!Number.isFinite(t.y)||!Number.isFinite(t.z)?this:(this.min.min(t),this.max.max(t),this)},n.prototype.expandByVector=function(t){return this.min.sub(t),this.max.add(t),this},n.prototype.expandByScalar=function(t){return this.min.addScalar(-t),this.max.addScalar(t),this},n.prototype.containsPoint=function(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)},n.prototype.containsBox=function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z},n.prototype.getParameter=function(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))},n.prototype.intersectsBox=function(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)},n.prototype.intersectsPlane=function(t){var e,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=-t.constant&&i>=-t.constant},n.prototype.clampPoint=function(t,e){return e.copy(t).clamp(this.min,this.max)},n.prototype.distanceToPoint=function(t){return this.clampPoint(t,Nd).distanceTo(t)},n.prototype.intersect=function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},n.prototype.union=function(t){return this.min.min(t.min),this.max.max(t.max),this},n.prototype.applyMatrix4=function(t){return this.isEmpty()?this:(Ir[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Ir[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Ir[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Ir[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Ir[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Ir[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Ir[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Ir[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Ir),this)},n.prototype.translate=function(t){return this.min.add(t),this.max.add(t),this},n.prototype.equals=function(t){return t.min.equals(this.min)&&t.max.equals(this.max)},n})(),Ir=[new _t,new _t,new _t,new _t,new _t,new _t,new _t,new _t],Nd=new _t,t0=new mn,Dd=(function(){function n(t,e){t===void 0&&(t=void 0),e===void 0&&(e=void 0),this.min=t==null?new mn(1/0,1/0):new mn(t.x,t.y),this.max=e==null?new mn(-1/0,-1/0):new mn(e.x,e.y)}return n.prototype.set=function(t,e){return this.min.copy(t),this.max.copy(e),this},n.prototype.setFromPoints=function(t){this.makeEmpty();for(var e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this},n.prototype.setFromCenterAndSize=function(t,e){var i=t0.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this},n.prototype.clone=function(){return new n().copy(this)},n.prototype.copy=function(t){return this.min.copy(t.min),this.max.copy(t.max),this},n.prototype.makeEmpty=function(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this},n.prototype.isEmpty=function(){return this.max.x<this.min.x||this.max.y<this.min.y},n.prototype.getCenter=function(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)},n.prototype.getSize=function(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)},Object.defineProperty(n.prototype,"center",{get:function(){return this.isEmpty()?new mn(0,0):new mn(0,0).addVectors(this.min,this.max).multiplyScalar(.5)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"size",{get:function(){return this.isEmpty()?new mn(0,0):new mn(0,0).subVectors(this.max,this.min)},enumerable:!1,configurable:!0}),n.prototype.expandByPoint=function(t){return!Number.isFinite(t.x)||!Number.isFinite(t.y)?this:(this.min.min(t),this.max.max(t),this)},n.prototype.expandByVector=function(t){return this.min.sub(t),this.max.add(t),this},n.prototype.expandByScalar=function(t){return this.min.addScalar(-t),this.max.addScalar(t),this},n.prototype.containsPoint=function(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)},n.prototype.containsBox=function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y},n.prototype.getParameter=function(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))},n.prototype.intersectsBox=function(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)},n.prototype.clampPoint=function(t,e){return e.copy(t).clamp(this.min,this.max)},n.prototype.distanceToPoint=function(t){return this.clampPoint(t,t0).distanceTo(t)},n.prototype.intersect=function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},n.prototype.union=function(t){return this.min.min(t.min),this.max.max(t.max),this},n.prototype.translate=function(t){return this.min.add(t),this.max.add(t),this},n.prototype.equals=function(t){return t.min.equals(this.min)&&t.max.equals(this.max)},n})(),e0=new _t,lE=new _t,cE=new kd,Ud=(function(){function n(t,e){t===void 0&&(t=new _t(1,0,0)),e===void 0&&(e=0),this.normal=t,this.constant=e}return n.prototype.set=function(t,e){return this.normal.copy(t),this.constant=e,this},n.prototype.setComponents=function(t,e,i,r){return this.normal.set(t,e,i),this.constant=r,this},n.prototype.setFromNormalAndCoplanarPoint=function(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this},n.prototype.setFromCoplanarPoints=function(t,e,i){var r=e0.subVectors(i,e).cross(lE.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(r,t),this},n.prototype.copy=function(t){return this.normal.copy(t.normal),this.constant=t.constant,this},n.prototype.normalize=function(){var t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this},n.prototype.negate=function(){return this.constant*=-1,this.normal.negate(),this},n.prototype.distanceToPoint=function(t){return this.normal.dot(t)+this.constant},n.prototype.projectPoint=function(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))},n.prototype.intersectsBox=function(t){return t.intersectsPlane(this)},n.prototype.coplanarPoint=function(t){return t.copy(this.normal).multiplyScalar(-this.constant)},n.prototype.applyMatrix4=function(t,e){var i=e||cE.getNormalMatrix(t),r=this.coplanarPoint(e0).applyMatrix4(t),s=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(s),this},n.prototype.translate=function(t){return this.constant-=t.dot(this.normal),this},n.prototype.equals=function(t){return t.normal.equals(this.normal)&&t.constant===this.constant},n.prototype.clone=function(){return new n().copy(this)},n})(),uE=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),Ie=(function(n){uE(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.clone=function(){return new t(this.x,this.y)},t.pointArrayToNumberArray=function(e){var i=new Array(e.length*2);return e.forEach(function(r,s){r.toArray(i,s*2)}),i},t})(mn),hE=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),Be=(function(n){hE(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.clone=function(){return new t(this.x,this.y,this.z)},t.pointArrayToNumberArray=function(e,i){i===void 0&&(i=!0);var r=i?3:2,s=new Array(e.length*r);return e.forEach(function(o,a){o.toArray(s,a*r)}),s},t})(_t),yo=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},qa=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},bc=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))};function dE(n,t){t===void 0&&(t="Uniform");var e=n.length;if(e===0)return[];if(e===1)return[0];var i=e-1;if(t==="Uniform")return new Array(e).fill(0).map(function(d,f){return f/i});for(var r=[0],s=0,o=1;o<=i;o++){var a=n[o][0]-n[o-1][0],l=n[o][1]-n[o-1][1],c=n[o][2]-n[o-1][2],u=Math.sqrt(a*a+l*l+c*c),h=t==="SqrtChord"?Math.sqrt(u):u;s+=h,r.push(s)}return s<1e-12?new Array(e).fill(0).map(function(d,f){return f/i}):r.map(function(d){return d/s})}function fE(n,t){for(var e=t.length-1,i=n,r=e+i+1,s=new Array(r+1).fill(0),o=t[t.length-1],a=r-i;a<=r;a++)s[a]=o;for(var l=1;l<=e-i;l++){for(var c=0,a=l;a<l+i;a++)c+=t[a];s[l+i]=c/i}return s}function Sc(n,t){var e,i;try{for(var r=yo(n),s=r.next();!s.done;s=r.next()){var o=s.value;if(o.col===t)return o.value}}catch(a){e={error:a}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(e)throw e.error}}return 0}function n0(n,t){for(var e=0;e<n.length;e++)if(n[e].col===t)return e;return-1}function pE(n,t){for(var e,i,r,s,o,a,l,c,u,h,d=n.length,f=n.map(function(Xt){return Xt.map(function(it){return{col:it.col,value:it.value}})}),p=t.map(function(Xt){return Xt.slice()}),g=0;g<d;g++){for(var y=-1,m=1e-12,v=g;v<d;v++){var x=Math.abs(Sc(f[v],g));x>m&&(m=x,y=v)}if(y<0)throw new Error("Interpolation matrix is singular.");if(y!==g){var _=f[g];f[g]=f[y],f[y]=_;try{for(var b=(e=void 0,yo(p)),w=b.next();!w.done;w=b.next()){var C=w.value,E=C[g];C[g]=C[y],C[y]=E}}catch(Xt){e={error:Xt}}finally{try{w&&!w.done&&(i=b.return)&&i.call(b)}finally{if(e)throw e.error}}}for(var T=Sc(f[g],g),v=g+1;v<d;v++){var k=n0(f[v],g);if(!(k<0)){var O=f[v][k].value/T;if(!(Math.abs(O)<1e-14)){try{for(var U=(r=void 0,yo(f[v])),z=U.next();!z.done;z=U.next()){var L=z.value;L.col>g&&(L.value-=O*Sc(f[g],L.col))}}catch(it){r={error:it}}finally{try{z&&!z.done&&(s=U.return)&&s.call(U)}finally{if(r)throw r.error}}try{for(var N=(o=void 0,yo(f[g])),F=N.next();!F.done;F=N.next()){var G=F.value;G.col<=g||G.value===0||n0(f[v],G.col)<0&&f[v].push({col:G.col,value:-O*G.value})}}catch(it){o={error:it}}finally{try{F&&!F.done&&(a=N.return)&&a.call(N)}finally{if(o)throw o.error}}f[v][k].value=0;try{for(var V=(l=void 0,yo(p)),D=V.next();!D.done;D=V.next()){var C=D.value;C[v]-=O*C[g]}}catch(it){l={error:it}}finally{try{D&&!D.done&&(c=V.return)&&c.call(V)}finally{if(l)throw l.error}}}}}}for(var Y=p.map(function(){return new Array(d).fill(0)}),v=d-1;v>=0;v--)for(var Z=Sc(f[v],v),ft=0;ft<p.length;ft++){var gt=p[ft][v];try{for(var qt=(u=void 0,yo(f[v])),Vt=qt.next();!Vt.done;Vt=qt.next()){var L=Vt.value;L.col>v&&(gt-=L.value*Y[ft][L.col])}}catch(it){u={error:it}}finally{try{Vt&&!Vt.done&&(h=qt.return)&&h.call(qt)}finally{if(u)throw u.error}}Y[ft][v]=gt/Z}return Y}function mE(n,t,e){var i=e.length-t-2;if(n>=e[i+1])return i;for(var r=t,s=e.length-t-2;r<=s;){var o=r+s>>1;if(n<e[o])s=o-1;else if(n>=e[o+1])r=o+1;else return o}return t}function gE(n,t,e,i,r){var s,o,a,l,c,u;if(e===void 0&&(e="Uniform"),n.length===0)return{controlPoints:[],knots:[],weights:[]};var h=n.map(function(Vt){var Xt;return[Vt[0],Vt[1],(Xt=Vt[2])!==null&&Xt!==void 0?Xt:0]}),d=!!i,f=!!r,p=(d?1:0)+(f?1:0),g=h.length-1,y=g+p;if(y<t)throw new Error("Not enough points to interpolate a curve of this degree.");var m=dE(h,e),v=m.slice();d&&v.unshift(m[0]),f&&v.push(m[m.length-1]);var x=fE(t,v),_=y+1,b=[],w=[],C=[],E=[];if(d){var T=x[t+1]-x[0],k=T!==0?t/T:0;b.push([{col:0,value:-k},{col:1,value:k}]),w.push((s=i==null?void 0:i[0])!==null&&s!==void 0?s:0),C.push((o=i==null?void 0:i[1])!==null&&o!==void 0?o:0),E.push((a=i==null?void 0:i[2])!==null&&a!==void 0?a:0)}b.push([{col:0,value:1}]),w.push(h[0][0]),C.push(h[0][1]),E.push(h[0][2]);for(var O=1;O<=g-1;O++){for(var U=m[O],z=[],L=mE(U,t,x),N=Math.max(0,L-t),F=Math.min(y,L),G=N;G<=F;G++){var V=ks(G,t,U,x);V!==0&&z.push({col:G,value:V})}b.push(z),w.push(h[O][0]),C.push(h[O][1]),E.push(h[O][2])}if(b.push([{col:y,value:1}]),w.push(h[g][0]),C.push(h[g][1]),E.push(h[g][2]),f){var T=x[y+t+1]-x[y],k=T!==0?t/T:0;b.push([{col:y-1,value:-k},{col:y,value:k}]),w.push((l=r==null?void 0:r[0])!==null&&l!==void 0?l:0),C.push((c=r==null?void 0:r[1])!==null&&c!==void 0?c:0),E.push((u=r==null?void 0:r[2])!==null&&u!==void 0?u:0)}for(var D=qa(pE(b,[w,C,E]),3),Y=D[0],Z=D[1],ft=D[2],gt=new Array(_),O=0;O<_;O++)gt[O]=[Y[O],Z[O],ft[O]];var qt=new Array(_).fill(1);return{controlPoints:gt,knots:x,weights:qt}}function ks(n,t,e,i){if(t===0)return e>=i[n]&&e<i[n+1]?1:0;var r=i[n+t]-i[n],s=i[n+t+1]-i[n+1],o=r>1e-10?(e-i[n])/r:0,a=s>1e-10?(i[n+t+1]-e)/s:0;return o*ks(n,t-1,e,i)+a*ks(n+1,t-1,e,i)}function wc(n,t,e,i,r){var s=i.length-1,o=t;if(n=Math.max(e[o],Math.min(e[s+1],n)),Math.abs(n-e[s+1])<1e-8)return bc([],qa(i[s]),!1);if(Math.abs(n-e[o])<1e-8)return bc([],qa(i[0]),!1);for(var a=[0,0,0],l=0,c=0;c<=s;c++){var u=ks(c,o,n,e),h=r[c]*u;a[0]+=i[c][0]*h,a[1]+=i[c][1]*h,a[2]+=i[c][2]*h,l+=h}if(Math.abs(l)<1e-10){var d=e[e.length-o-1];if(Math.abs(n-d)<1e-8)return bc([],qa(i[s]),!1);if(Math.abs(n-e[o])<1e-8)return bc([],qa(i[0]),!1)}return Math.abs(l)>=1e-10&&(a[0]/=l,a[1]/=l,a[2]/=l),a}function zd(n,t,e,i){if(t===0)return 0;var r=i[n+t]-i[n],s=i[n+t+1]-i[n+1],o=0;return r>1e-10&&(o+=t/r*ks(n,t-1,e,i)),s>1e-10&&(o-=t/s*ks(n+1,t-1,e,i)),o}function yE(n,t,e,i){if(t<=1)return 0;var r=i[n+t]-i[n],s=i[n+t+1]-i[n+1],o=0;return r>1e-10&&(o+=t/r*zd(n,t-1,e,i)),s>1e-10&&(o-=t/s*zd(n+1,t-1,e,i)),o}function vE(n,t,e,i,r){var s=i.length-1,o=t,a=e[o],l=e[s+1];n=Math.max(a,Math.min(l,n));for(var c=[0,0,0],u=[0,0,0],h=[0,0,0],d=0,f=0,p=0,g=0;g<=s;g++){var y=ks(g,o,n,e),m=zd(g,o,n,e),v=yE(g,o,n,e),x=r[g],_=x*y,b=x*m,w=x*v,C=i[g];c[0]+=_*C[0],c[1]+=_*C[1],c[2]+=_*C[2],u[0]+=b*C[0],u[1]+=b*C[1],u[2]+=b*C[2],h[0]+=w*C[0],h[1]+=w*C[1],h[2]+=w*C[2],d+=_,f+=b,p+=w}if(Math.abs(d)<1e-10){var E=wc(n,t,e,i,r);return{point:E,deriv1:[0,0,0],deriv2:[0,0,0]}}var T=d*d,k=[c[0]/d,c[1]/d,c[2]/d],O=[(u[0]*d-c[0]*f)/T,(u[1]*d-c[1]*f)/T,(u[2]*d-c[2]*f)/T],U=h[0]*d-c[0]*p,z=h[1]*d-c[1]*p,L=h[2]*d-c[2]*p,N=[U/T-2*f*O[0]/d,z/T-2*f*O[1]/d,L/T-2*f*O[2]/d];return{point:k,deriv1:O,deriv2:N}}function _E(n,t){var e=n[0],i=n[1],r=t[0],s=t[1],o=e*e+i*i;return o<1e-20?0:(e*s-i*r)/Math.pow(o,1.5)}function xE(n,t,e,i){for(var r=n,s=t[r],o=t[t.length-r-1],a=0,l=1e3,c=(o-s)/l,u=wc(s,n,t,e,i),h=1;h<=l;h++){var d=s+h*c,f=wc(d,n,t,e,i),p=f[0]-u[0],g=f[1]-u[1],y=f[2]-u[2];a+=Math.sqrt(p*p+g*g+y*y),u=f}var m=wc(o,n,t,e,i),v=m[0]-u[0],x=m[1]-u[1],_=m[2]-u[2];return a+=Math.sqrt(v*v+x*x+_*_),a}function Fd(n,t,e){var i=n.x,r=n.y,s=t.x,o=t.y,a=e.x,l=e.y,c=2*(i*(o-l)+s*(l-r)+a*(r-o));if(Ae.equalToZero(c))return null;var u=((i*i+r*r)*(o-l)+(s*s+o*o)*(l-r)+(a*a+l*l)*(r-o))/c,h=((i*i+r*r)*(a-s)+(s*s+o*o)*(i-a)+(a*a+l*l)*(s-i))/c,d=Math.hypot(u-i,h-r);return!Number.isFinite(d)||Ae.isNonPositive(d)?null:{center:new Ie(u,h),radius:d}}function i0(n,t,e){var i,r,s,o=n.x,a=n.y,l=(i=n.z)!==null&&i!==void 0?i:0,c=new _t(t.x-o,t.y-a,((r=t.z)!==null&&r!==void 0?r:0)-l),u=new _t(e.x-o,e.y-a,((s=e.z)!==null&&s!==void 0?s:0)-l),h=new _t().crossVectors(c,u),d=h.lengthSq();if(d<Oe*Oe)return null;var f=c.lengthSq(),p=u.lengthSq(),g=new _t().crossVectors(h,c).multiplyScalar(p).add(new _t().crossVectors(u,h).multiplyScalar(f)).multiplyScalar(1/(2*d)),y=new Be(o+g.x,a+g.y,l+g.z),m=Math.hypot(y.x-o,y.y-a,y.z-l);return!Number.isFinite(m)||Ae.isNonPositive(m)?null:{center:y,radius:m}}function os(n,t){return Math.atan2(t.y-n.y,t.x-n.x)}function nr(n,t){return Math.hypot(t.x-n.x,t.y-n.y)}function r0(n,t,e){if(Ae.isNonPositive(t))return null;var i=e.x-n.x,r=e.y-n.y,s=Math.hypot(i,r);if(Ae.isNonPositive(s))return null;var o=t/s;return new Ie(n.x+i*o,n.y+r*o)}var bE=1e-8;function SE(n,t,e,i){var r=Math.abs(nr(n,t)-e);return r<=(i??Math.max(Oe,e*1e-5))}function wE(n,t,e,i,r){return r===void 0&&(r=bE),Math.abs(n.x-e.x)<=r&&Math.abs(n.y-e.y)<=r&&Math.abs(t-i)<=r}function ME(n,t,e,i){var r=Math.max(1e-18,Math.abs(e)*1e-9);return n<e-r?!0:n>e+r?!1:t>i}function s0(n,t,e,i){i===void 0&&(i=!1);var r=Fd(n,t,e);if(!r)return null;var s=os(r.center,n),o=os(r.center,t),a=os(r.center,e),l=!ne.isAngleOnCcwSweep(s,o,a);return i&&(l=!l),fn.fromMathAngles(r.center,r.radius,s,a,l)}function Hd(n,t){return!Number.isFinite(t)||Ae.isNonPositive(t)?null:new fn(n,t,0,ue,!1)}function EE(n,t){var e=nr(n,t);return Ae.isNonPositive(e)?null:Hd({x:(n.x+t.x)/2,y:(n.y+t.y)/2},e/2)}function AE(n,t,e){var i=Fd(n,t,e);return i?Hd(i.center,i.radius):null}function CE(n,t,e){var i=nr(e,n);if(Ae.isNonPositive(i))return null;var r=os(e,n),s=os(e,t),o=ne.normalizeAngle(s-r);return fn.fromMathAngles(e,i,r,s,o>Math.PI)}function Ka(n,t,e,i){var r=nr(n,t),s=nr(n,e);if(Ae.isNonPositive(r)||Ae.isNonPositive(s))return null;var o=Math.max(Oe,r*Oe);return Math.abs(r-s)>o?null:fn.fromMathAngles(n,r,os(n,t),os(n,e),i)}function TE(n,t,e,i){var r=nr(n,t);if(Ae.isNonPositive(r))return null;var s=r0(n,r,e);return s?Ka(n,t,s,i):null}function o0(n,t,e){var i=nr(n,t),r=Math.abs(e);if(Ae.isNonPositive(i)||Ae.isNonPositive(r)||!Ae.great(ue-r,0))return null;var s=e<0,o=os(n,t),a=s?o-r:o+r;return fn.fromMathAngles(n,i,o,a,s)}function LE(n,t,e){var i=nr(n,t),r=Math.abs(e);if(Ae.isNonPositive(i)||Ae.isNonPositive(r)||Ae.great(r,2*i))return null;var s=Math.max(-1,Math.min(1,r/(2*i))),o=2*Math.asin(s);return o0(n,t,e>=0?o:-o)}function IE(n,t,e){var i=nr(n,t),r=Math.abs(e);if(Ae.isNonPositive(i)||Ae.isNonPositive(r)||!Ae.great(ue-r,0))return null;var s=Math.sin(r/2);if(Ae.equalToZero(s))return null;var o=i/(2*s),a=o*o-i*i/4;if(Ae.less(a,0))return null;var l=Math.sqrt(Math.max(0,a)),c=(n.x+t.x)/2,u=(n.y+t.y)/2,h=t.x-n.x,d=t.y-n.y,f=-d/i,p=h/i,g=e>=0,y=g&&r<=Math.PI||!g&&r>Math.PI,m=y?1:-1,v={x:c+f*l*m,y:u+p*l*m};return Ka(v,n,t,!g)}function PE(n,t,e){var i=Math.cos(e),r=Math.sin(e),s=t.x-n.x,o=t.y-n.y,a=-r,l=i,c=2*(s*a+o*l);if(Ae.equalToZero(c))return null;var u=(s*s+o*o)/c;if(!Number.isFinite(u))return null;var h={x:n.x+a*u,y:n.y+l*u},d=n.x-h.x,f=n.y-h.y,p=d*r-f*i;return Ae.equalToZero(p)?null:Ka(h,n,t,p<0)}function RE(n,t,e){var i=Math.abs(e),r=nr(n,t);if(Ae.isNonPositive(i)||Ae.isNonPositive(r)||Ae.great(r,2*i))return null;var s=(n.x+t.x)/2,o=(n.y+t.y)/2,a=t.x-n.x,l=t.y-n.y,c=-l/r,u=a/r,h=Math.sqrt(Math.max(0,i*i-r*r/4)),d=e>=0?1:-1,f={x:s+c*h*d,y:o+u*h*d};return Ka(f,n,t,e<0)}var a0=(function(){function n(){this._boundingBoxNeedsUpdate=!1}return Object.defineProperty(n.prototype,"boundingBoxNeedUpdate",{get:function(){return this._boundingBoxNeedsUpdate},enumerable:!1,configurable:!0}),n})(),kE=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),OE=(function(n){kE(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.translate=function(e){return this.transform(new kd().makeTranslation(e.x,e.y))},Object.defineProperty(t.prototype,"box",{get:function(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box},enumerable:!1,configurable:!0}),t})(a0),BE=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),Gd=(function(n){BE(t,n);function t(){var e=n.call(this)||this;return e.arcLengthDivisions=100,e}return Object.defineProperty(t.prototype,"startPoint",{get:function(){return this.getPoint(0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){return this.getPoint(1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){return this.getLength()},enumerable:!1,configurable:!0}),t.prototype.getPoint=function(e){throw new Error("AcGeCurve2d: .getPoint() not implemented.")},t.prototype.getPointAt=function(e){var i=this.getUtoTmapping(e);return this.getPoint(i)},t.prototype.getPoints=function(e){e===void 0&&(e=5);for(var i=[],r=0;r<=e;r++)i.push(this.getPoint(r/e));return i},t.prototype.getSpacedPoints=function(e){e===void 0&&(e=5);for(var i=[],r=0;r<=e;r++)i.push(this.getPointAt(r/e));return i},t.prototype.getLength=function(){var e=this.getLengths();return e[e.length-1]},t.prototype.getLengths=function(e){e===void 0&&(e=this.arcLengthDivisions);var i=[],r,s=this.getPoint(0),o=0;i.push(0);for(var a=1;a<=e;a++)r=this.getPoint(a/e),o+=r.distanceTo(s),i.push(o),s=r;return i},t.prototype.getUtoTmapping=function(e,i){var r=this.getLengths(),s=0,o=r.length,a;i?a=i:a=e*r[o-1];for(var l=0,c=o-1,u;l<=c;)if(s=Math.floor(l+(c-l)/2),u=r[s]-a,u<0)l=s+1;else if(u>0)c=s-1;else{c=s;break}if(s=c,r[s]===a)return s/(o-1);var h=r[s],d=r[s+1],f=d-h,p=(a-h)/f,g=(s+p)/(o-1);return g},t.prototype.getTangent=function(e){var i=1e-4,r=e-i,s=e+i;r<0&&(r=0),s>1&&(s=1);var o=this.getPoint(r),a=this.getPoint(s),l=new Ie;return l.copy(a).sub(o).normalize(),l},t.prototype.getTangentAt=function(e){var i=this.getUtoTmapping(e);return this.getTangent(i)},t})(OE),NE=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),Mc=function(){return Mc=Object.assign||function(n){for(var t,e=1,i=arguments.length;e<i;e++){t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},Mc.apply(this,arguments)},Ec=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Ac=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},Cc=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))},fn=(function(n){NE(t,n);function t(e,i,r,s,o){var a=n.call(this)||this,l=+(e!==void 0)+ +(i!==void 0)+ +(r!==void 0)+ +(s!==void 0)+ +(o!==void 0);if(l==3)typeof e=="object"&&typeof i=="object"&&typeof r=="object"?a.createByThreePoints(e,i,r):a.createByStartEndPointsAndBulge(e,i,r);else if(l==5){var c=e;a.center=new Ie(c.x,c.y),a.radius=i,a._clockwise=o,a._startAngle=a._clockwise?a._mirrorAngle(ne.normalizeAngle(r)):ne.normalizeAngle(r),a._endAngle=a._clockwise?a._mirrorAngle(ne.normalizeAngle(s)):ne.normalizeAngle(s)}else throw Lr.ILLEGAL_PARAMETERS;return a}return t.fromMathAngles=function(e,i,r,s,o){var a=new t(e,i,ne.normalizeAngle(r),ne.normalizeAngle(s),!1);return a._clockwise=o,a._boundingBoxNeedsUpdate=!0,a},t.computeCircumcircle=function(e,i,r){return Fd(e,i,r)},t.projectPoint=function(e,i,r){return r0(e,i,r)},t.pointLiesOnCircle=function(e,i,r,s){return SE(e,i,r,s)},t.sameCircle=function(e,i,r,s,o){return wE(e,i,r,s,o)},t.isBetterDistanceAlign=function(e,i,r,s){return ME(e,i,r,s)},t.tryCreateByThreePoints=function(e,i,r,s){return s===void 0&&(s=!1),s0(e,i,r,s)},t.tryCreateCircle=function(e,i){return Hd(e,i)},t.tryCreateCircleByDiameter=function(e,i){return EE(e,i)},t.tryCreateCircleByThreePoints=function(e,i,r){return AE(e,i,r)},t.tryCreateShorterArc=function(e,i,r){return CE(e,i,r)},t.tryCreateByCenterStartEnd=function(e,i,r,s){return Ka(e,i,r,s)},t.tryCreateByCenterStartProjectedEnd=function(e,i,r,s){return TE(e,i,r,s)},t.tryCreateByCenterStartSweep=function(e,i,r){return o0(e,i,r)},t.tryCreateByCenterStartChord=function(e,i,r){return LE(e,i,r)},t.tryCreateByStartEndAngle=function(e,i,r){return IE(e,i,r)},t.tryCreateByStartEndDirection=function(e,i,r){return PE(e,i,r)},t.tryCreateByStartEndRadius=function(e,i,r){return RE(e,i,r)},t.prototype.createByThreePoints=function(e,i,r){var s=s0(e,i,r);if(!s)throw Lr.ILLEGAL_PARAMETERS;this.center=s.center,this.radius=s.radius,this._clockwise=s._clockwise,this._startAngle=s._startAngle,this._endAngle=s._endAngle,this._boundingBoxNeedsUpdate=!0},t.prototype.createByStartEndPointsAndBulge=function(e,i,r){var s,o,a;r<0?(s=Math.atan(-r)*4,o=new mn(e),a=new mn(i)):(s=Math.atan(r)*4,o=new mn(i),a=new mn(e));var l=new mn().subVectors(a,o),c=l.length(),u=new mn().addVectors(o,l.multiplyScalar(.5)),h=Math.abs(c/2/Math.tan(s/2)),d=l.normalize(),f=r<0?-Math.PI/2:Math.PI/2,p=new mn(d.x*Math.cos(f)-d.y*Math.sin(f),d.y*Math.cos(f)+d.x*Math.sin(f)),g;s<Math.PI?r<0?g=u.add(p.multiplyScalar(h)):g=u.add(p.multiplyScalar(-h)):r<0?g=u.add(p.multiplyScalar(-h)):g=u.add(p.multiplyScalar(h)),r<0?(this._startAngle=Math.atan2(o.y-g.y,o.x-g.x),this._endAngle=Math.atan2(a.y-g.y,a.x-g.x)):(this._startAngle=Math.atan2(a.y-g.y,a.x-g.x),this._endAngle=Math.atan2(o.y-g.y,o.x-g.x)),this._clockwise=r<0,this.center=g,this.radius=a.sub(g).length()},Object.defineProperty(t.prototype,"center",{get:function(){return this._center},set:function(e){this._center=new Ie(e.x,e.y),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"radius",{get:function(){return this._radius},set:function(e){this._radius=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startAngle",{get:function(){return this._clockwise?this._mirrorAngle(this._startAngle):this._startAngle},set:function(e){this._startAngle=this._clockwise?this._mirrorAngle(ne.normalizeAngle(e)):ne.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endAngle",{get:function(){return this._clockwise?this._mirrorAngle(this._endAngle):this._endAngle},set:function(e){var i=this.startAngle==0&&e==ue?e:ne.normalizeAngle(e);this._endAngle=this._clockwise?this._mirrorAngle(i):i,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),t.prototype._mirrorAngle=function(e){var i=e*180/Math.PI,r=(360-i)%360;return r*Math.PI/180},t.prototype._getInternalAngle=function(e){return this._clockwise?this._mirrorAngle(e):e},Object.defineProperty(t.prototype,"deltaAngle",{get:function(){var e=this._getInternalAngle(this.startAngle),i=this._getInternalAngle(this.endAngle);return this.clockwise?ne.normalizeAngle(e-i):ne.normalizeAngle(i-e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"clockwise",{get:function(){return this._clockwise},set:function(e){this._clockwise=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startPoint",{get:function(){return this.getPointAtAngle(this.startAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){return this.getPointAtAngle(this.endAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"midPoint",{get:function(){var e=this._getInternalAngle(this.startAngle),i=this._clockwise?ne.normalizeAngle(e-this.deltaAngle/2):ne.normalizeAngle(e+this.deltaAngle/2),r=this._clockwise?this._mirrorAngle(i):i;return this.getPointAtAngle(r)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"closed",{get:function(){var e=this._getInternalAngle(this.startAngle),i=this._getInternalAngle(this.endAngle);return Math.abs(i-e)/Math.PI%2==0},enumerable:!1,configurable:!0}),t.prototype.calculateBoundingBox=function(){var e,i,r=[this.startPoint,this.endPoint],s=[0,Math.PI/2,Math.PI,3*Math.PI/2];try{for(var o=Ec(s),a=o.next();!a.done;a=o.next()){var l=a.value,c=this._getInternalAngle(l);ne.isBetweenAngle(c,this._getInternalAngle(this.startAngle),this._getInternalAngle(this.endAngle),this.clockwise)&&r.push(this.getPointAtAngle(l))}}catch(d){e={error:d}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(e)throw e.error}}var u=r.map(function(d){return d.x}),h=r.map(function(d){return d.y});return new Dd(new Ie(Math.min.apply(Math,Cc([],Ac(u),!1)),Math.min.apply(Math,Cc([],Ac(h),!1))),new Ie(Math.max.apply(Math,Cc([],Ac(u),!1)),Math.max.apply(Math,Cc([],Ac(h),!1))))},Object.defineProperty(t.prototype,"length",{get:function(){return Math.abs(this.deltaAngle*this.radius)},enumerable:!1,configurable:!0}),t.prototype.transform=function(e){var i=this,r=e,s=this.center.clone().applyMatrix2d(r),o=this.startPoint.clone().applyMatrix2d(r);if(this.closed)return this.center=s,this.radius=s.distanceTo(o),this._startAngle=Math.atan2(o.y-s.y,o.x-s.x),this._endAngle=this._startAngle,this._clockwise=r.determinant()<0?!this._clockwise:this._clockwise,this._boundingBoxNeedsUpdate=!0,this;var a=this.midPoint.clone().applyMatrix2d(r),l=this.endPoint.clone().applyMatrix2d(r),c=new t(o,a,l),u=r.determinant()<0?!this.clockwise:this.clockwise,h=function(d){var f=ne.normalizeAngle(d);return u?i._mirrorAngle(f):f};return this.center=c.center,this.radius=c.radius,this.clockwise=u,this.startAngle=h(Math.atan2(o.y-c.center.y,o.x-c.center.x)),this.endAngle=h(Math.atan2(l.y-c.center.y,l.x-c.center.x)),this._boundingBoxNeedsUpdate=!0,this},t.prototype.clone=function(){return new t(this.center.clone(),this.radius,this._startAngle,this._endAngle,this.clockwise)},t.prototype.getPointAtAngle=function(e){var i=this._getInternalAngle(e),r=this.center.x+this.radius*Math.cos(i),s=this.center.y+this.radius*Math.sin(i);return new Ie(r,s)},t.prototype.getQuadrantPoints=function(){var e,i,r=[],s=this._getInternalAngle(this.startAngle),o=this._getInternalAngle(this.endAngle),a=[0,Math.PI/2,Math.PI,3*Math.PI/2];try{for(var l=Ec(a),c=l.next();!c.done;c=l.next()){var u=c.value,h=this._getInternalAngle(u);ne.isBetweenAngle(h,s,o,this.clockwise)&&r.push(this.getPointAtAngle(u))}}catch(d){e={error:d}}finally{try{c&&!c.done&&(i=l.return)&&i.call(l)}finally{if(e)throw e.error}}return r},t.prototype.nearestPoint=function(e){var i=new Ie(e.x,e.y),r=i.x-this.center.x,s=i.y-this.center.y,o=Math.hypot(r,s);if(o<1e-12)return this.startPoint.clone();var a=Math.atan2(s,r),l=this.clockwise?this._mirrorAngle(ne.normalizeAngle(a)):ne.normalizeAngle(a),c=this._getInternalAngle(l),u=this._getInternalAngle(this.startAngle),h=this._getInternalAngle(this.endAngle);if(ne.isBetweenAngle(c,u,h,this.clockwise))return this.getPointAtAngle(l);var d=i.distanceToSquared(this.startPoint),f=i.distanceToSquared(this.endPoint);return d<=f?this.startPoint.clone():this.endPoint.clone()},t.prototype.inwardAlignment=function(e,i){var r=i.x-e.x,s=i.y-e.y;if(r*r+s*s<1e-24)return 0;var o=this.radius>0?this.radius:1,a=Math.max(1e-16,1e-12*o*o),l=this.startPoint.distanceToSquared(e)<=a,c=this.endPoint.distanceToSquared(e)<=a;if(!l&&!c)return 0;var u=this.getPoints(8);if(u.length<3)return 0;var h=l&&!c?u[1]:u[u.length-2],d=h.x-e.x,f=h.y-e.y,p=Math.hypot(d,f);return p>1e-18?(r*d+s*f)/p:0},t.prototype.perpendicularPoints=function(e){var i,r,s=new Ie(e.x,e.y),o=s.x-this.center.x,a=s.y-this.center.y,l=Math.hypot(o,a);if(l<1e-12)return[];var c=o/l,u=a/l,h=[new Ie(this.center.x+c*this.radius,this.center.y+u*this.radius),new Ie(this.center.x-c*this.radius,this.center.y-u*this.radius)],d=[],f=this._getInternalAngle(this.startAngle),p=this._getInternalAngle(this.endAngle);try{for(var g=Ec(h),y=g.next();!y.done;y=g.next()){var m=y.value,v=Math.atan2(m.y-this.center.y,m.x-this.center.x),x=this.clockwise?this._mirrorAngle(ne.normalizeAngle(v)):ne.normalizeAngle(v),_=this._getInternalAngle(x);(this.closed||ne.isBetweenAngle(_,f,p,this.clockwise))&&d.push(m)}}catch(b){i={error:b}}finally{try{y&&!y.done&&(r=g.return)&&r.call(g)}finally{if(i)throw i.error}}return d},t.prototype.tangentPoints=function(e){var i,r,s=[],o=e.x-this.center.x,a=e.y-this.center.y,l=Math.hypot(o,a),c=this.radius;if(l<c)return s;var u=Math.acos(c/l),h=Math.atan2(a,o),d=[h+u,h-u],f=this._getInternalAngle(this.startAngle),p=this._getInternalAngle(this.endAngle);try{for(var g=Ec(d),y=g.next();!y.done;y=g.next()){var m=y.value,v=this.clockwise?this._mirrorAngle(ne.normalizeAngle(m)):ne.normalizeAngle(m),x=this._getInternalAngle(v);(this.closed||ne.isBetweenAngle(x,f,p,this.clockwise))&&s.push(this.getPointAtAngle(v))}}catch(_){i={error:_}}finally{try{y&&!y.done&&(r=g.return)&&r.call(g)}finally{if(i)throw i.error}}return s},t.prototype.getPoints=function(e){e===void 0&&(e=100);var i=[],r=this.deltaAngle,s=this._getInternalAngle(this.startAngle);if(this.closed&&(r=ue,s=0),this.clockwise)for(var o=0;o<=e;o++){var a=s-r*(o/e),l=this._clockwise?this._mirrorAngle(a):a,c=this.getPointAtAngle(l);i.push(new Ie(c.x,c.y))}else for(var o=0;o<=e;o++){var a=s+r*(o/e),l=this._clockwise?this._mirrorAngle(a):a,c=this.getPointAtAngle(l);i.push(new Ie(c.x,c.y))}return i},t.prototype.tessellate=function(e){var i,r=this.closed?ue:this.deltaAngle,s=t.segmentCount(this.radius,r,Mc(Mc({},e),{minSegments:(i=e==null?void 0:e.minSegments)!==null&&i!==void 0?i:this.closed?8:3}));return this.getPoints(s)},t.resolveCircleSides=function(e){return e==null||!Number.isFinite(e)?t.DEFAULT_CIRCLE_SIDES:$a(Math.round(e),t.MIN_CIRCLE_SIDES,t.MAX_CIRCLE_SIDES)},t.resolveTessellateOptions=function(e){var i,r=t.resolveCircleSides(e==null?void 0:e.circleSides),s=Math.max(1,Math.round((i=e==null?void 0:e.maxSegments)!==null&&i!==void 0?i:r));return{deviation:e==null?void 0:e.deviation,circleSides:r,minSegments:e==null?void 0:e.minSegments,maxSegments:s}},t.chordDeviationFromRadius=function(e,i){i===void 0&&(i=t.DEFAULT_CIRCLE_SIDES);var r=Math.abs(e),s=t.resolveCircleSides(i);return r<=Oe?Oe:Math.max(Oe,r*(1-Math.cos(Math.PI/s)))},t.segmentCount=function(e,i,r){var s,o,a=t.resolveTessellateOptions(r),l=Math.abs(i),c=l>=ue-1e-8,u=Math.max(1,Math.round((s=a.minSegments)!==null&&s!==void 0?s:c?8:3)),h=Math.max(u,a.maxSegments),d=Math.abs(e);if(d<=Oe||l<=Oe)return u;var f=(o=a.deviation)!==null&&o!==void 0?o:t.chordDeviationFromRadius(d,a.circleSides),p=1-f/d;if(!Number.isFinite(p)||p>=1)return h;if(p<=-1)return u;var g=2*Math.acos(p);return g<=Oe?h:$a(Math.ceil(l/g),u,h)},t.DEFAULT_CIRCLE_SIDES=100,t.MIN_CIRCLE_SIDES=8,t.MAX_CIRCLE_SIDES=2e4,t})(Gd),DE=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),UE=(function(n){DE(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.translate=function(e){return this.transform(new Ya().makeTranslation(e.x,e.y,e.z))},Object.defineProperty(t.prototype,"box",{get:function(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box},enumerable:!1,configurable:!0}),t})(a0),zE=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),Tc=(function(n){zE(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.tessellateParametricCurve=function(e,i,r,s){var o=Math.max(2,Math.round(s.maxSegments)),a=Math.max(1,Math.round(s.minSegments)),l=Math.max(0,s.deviation)*Math.max(0,s.deviation);if(!Number.isFinite(e)||!Number.isFinite(i))return[r(0)];if(Math.abs(i-e)<=Oe)return[r(e)];for(var c=Math.min(o,Math.max(2,a+1)),u=Math.min(o,Math.max(c,8)),h=HE(e,i,u),d=[],f=0;f<h.length;f++)d.push(r(h[f]));for(var p=d.length,g=0;g<8&&p<o;g++){for(var y=[],f=0;f<h.length-1&&!(p>=o);f++){var m=(h[f]+h[f+1])/2,v=r(m);p++,FE(v,d[f],d[f+1])>l&&y.push({index:f,t:m,point:v})}if(y.length===0)break;var x=GE(h,d,y);h=x.params,d.length=0;for(var f=0;f<x.points.length;f++)d.push(x.points[f])}return d},t})(UE);function FE(n,t,e){var i=e.x-t.x,r=e.y-t.y,s=e.z-t.z,o=n.x-t.x,a=n.y-t.y,l=n.z-t.z,c=i*i+r*r+s*s;if(c<=Oe*Oe)return o*o+a*a+l*l;var u=$a((o*i+a*r+l*s)/c,0,1),h=o-i*u,d=a-r*u,f=l-s*u;return h*h+d*d+f*f}function HE(n,t,e){if(e<=1)return[n];for(var i=[],r=0;r<e;r++)i.push(r===e-1?t:n+(t-n)*r/(e-1));return i}function GE(n,t,e){for(var i=[],r=[],s=0,o=0;o<n.length;o++)for(i.push(n[o]),r.push(t[o]);s<e.length&&e[s].index===o;)i.push(e[s].t),r.push(e[s].point),s++;return{params:i,points:r}}var VE=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),Lc=function(){return Lc=Object.assign||function(n){for(var t,e=1,i=arguments.length;e<i;e++){t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},Lc.apply(this,arguments)},Vd=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Za=(function(n){VE(t,n);function t(e,i,r,s,o,a){a===void 0&&(a=_t.X_AXIS);var l=n.call(this)||this;return l.center=e,l.radius=i,l.startAngle=r,l.endAngle=s,l.normal=o,l.refVec=a,(s-r)%ue==0?(l.startAngle=0,l.endAngle=ue):(l.startAngle=r,l.endAngle=s),l}return t.computeCenterPoint=function(e,i,r){var s,o;return(o=(s=i0(e,r,i))===null||s===void 0?void 0:s.center)!==null&&o!==void 0?o:null},t.tryCreateByThreePoints=function(e,i,r){var s,o,a,l=i0(e,r,i);if(!l)return null;var c=l.center,u=l.radius,h=new _t(e.x-c.x,e.y-c.y,((s=e.z)!==null&&s!==void 0?s:0)-c.z),d=new _t(r.x-c.x,r.y-c.y,((o=r.z)!==null&&o!==void 0?o:0)-c.z),f=new _t(i.x-c.x,i.y-c.y,((a=i.z)!==null&&a!==void 0?a:0)-c.z);if(h.lengthSq()===0||f.lengthSq()===0)return null;var p=new _t().crossVectors(h,f);if(p.lengthSq()===0&&(p.crossVectors(h,d),p.lengthSq()===0))return null;p.normalize();var g=h.clone().normalize(),y=new _t().crossVectors(p,g),m=function(x){return ne.normalizeAngle(Math.atan2(x.dot(y),x.dot(g)))};ne.isAngleOnCcwSweep(0,m(d),m(f))||(p.negate(),y.negate());var v=m(f);return Ae.equalToZero(v)&&(v=ue),new t(c,u,0,v,p,g)},t.createByThreePoints=function(e,i,r){return t.tryCreateByThreePoints(e,i,r)},Object.defineProperty(t.prototype,"center",{get:function(){return this._center},set:function(e){this._center=new Be(e.x,e.y,e.z||0),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"radius",{get:function(){return this._radius},set:function(e){if(e<0)throw Lr.ILLEGAL_PARAMETERS;this._radius=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startAngle",{get:function(){return this._startAngle},set:function(e){this._startAngle=ne.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endAngle",{get:function(){return this._endAngle},set:function(e){this._endAngle=this.startAngle==0&&e==ue?e:ne.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"deltaAngle",{get:function(){return ne.normalizeAngle(this.endAngle-this.startAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isLargeArc",{get:function(){return Math.abs(this.deltaAngle)>Math.PI?1:0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"clockwise",{get:function(){return this.deltaAngle<=0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normal",{get:function(){return this._normal},set:function(e){this._normal=new _t(e.x,e.y,e.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"refVec",{get:function(){return this._refVec},set:function(e){this._refVec=new _t(e.x,e.y,e.z),this._refVec.normalize(),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startPoint",{get:function(){return this.getPointAtAngle(this._startAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){return this.getPointAtAngle(this._endAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"midPoint",{get:function(){var e=this.startAngle,i=this.deltaAngle;this.closed&&(e=0,i=ue);var r=e+i*.5;return this.getPointAtAngle(r)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){return this.closed?2*Math.PI*this.radius:Math.abs(this.deltaAngle*this.radius)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"area",{get:function(){return this.closed?Math.PI*this.radius*this.radius:0},enumerable:!1,configurable:!0}),t.prototype.nearestPoint=function(e){var i=new _t(e.x,e.y,e.z||0),r=this.center,s=this.normal,o=i.clone().sub(r),a=o.dot(s),l=i.clone().sub(s.clone().multiplyScalar(a)),c=l.clone().sub(r);if(c.lengthSq()===0)return this.startPoint.clone();c.normalize().multiplyScalar(this.radius);var u=r.clone().add(c),h=this.getAngle(u.clone()),d=this.startAngle,f=this.deltaAngle,p=ne.normalizeAngle(h-d);p<0&&(p=0),p>f&&(p=f);var g=this.getPointAtAngle(d+p),y=g.distanceTo(i),m=this.startPoint.distanceTo(i),v=this.endPoint.distanceTo(i);return m<y&&m<=v?this.startPoint.clone():v<y&&v<m?this.endPoint.clone():g},t.prototype.tangentPoints=function(e){var i,r,s=[],o=new _t(e.x,e.y,e.z||0),a=this.center,l=this.normal,c=this.radius,u=o.clone().sub(a),h=u.dot(l),d=o.clone().sub(l.clone().multiplyScalar(h)),f=a.clone(),p=d.clone().sub(f),g=p.length();if(g<c)return s;var y=Math.acos(c/g),m=this.getAngle(d.clone()),v=[m+y,m-y];try{for(var x=Vd(v),_=x.next();!_.done;_=x.next()){var b=_.value,w=ne.normalizeAngle(b-this.startAngle);w>=0&&w<=this.deltaAngle&&s.push(this.getPointAtAngle(this.startAngle+w))}}catch(C){i={error:C}}finally{try{_&&!_.done&&(r=x.return)&&r.call(x)}finally{if(i)throw i.error}}return s},t.prototype.perpendicularPoints=function(e){var i,r,s=[],o=new _t(e.x,e.y,e.z||0),a=this.center,l=this.normal,c=this.radius,u=o.clone().sub(a),h=u.dot(l),d=o.clone().sub(l.clone().multiplyScalar(h)),f=d.clone().sub(a);if(f.lengthSq()<1e-24)return s;f.normalize();var p=[a.clone().add(f.clone().multiplyScalar(c)),a.clone().sub(f.clone().multiplyScalar(c))];try{for(var g=Vd(p),y=g.next();!y.done;y=g.next()){var m=y.value,v=this.getAngle(m.clone()),x=ne.normalizeAngle(v-this.startAngle);x>=0&&x<=this.deltaAngle&&s.push(new Be(m.x,m.y,m.z||0))}}catch(_){i={error:_}}finally{try{y&&!y.done&&(r=g.return)&&r.call(g)}finally{if(i)throw i.error}}return s},t.prototype.nearestTangentPoint=function(e){var i=this.tangentPoints(e);if(i.length===0)return null;var r=new Be(e.x,e.y,e.z||0);return i.length===1||i[0].distanceTo(r)<i[1].distanceTo(r)?i[0]:i[1]},t.prototype.calculateBoundingBox=function(){for(var e,i,r=[this.startAngle,this.endAngle],s=0;s<2*Math.PI;s+=Math.PI/2)ne.isBetweenAngle(s,this.startAngle,this.endAngle)&&r.push(s);var o=1/0,a=1/0,l=1/0,c=-1/0,u=-1/0,h=-1/0;try{for(var d=Vd(r),f=d.next();!f.done;f=d.next()){var p=f.value,g=this.getPointAtAngle(p);g.x<o&&(o=g.x),g.y<a&&(a=g.y),g.z<l&&(l=g.z),g.x>c&&(c=g.x),g.y>u&&(u=g.y),g.z>h&&(h=g.z)}}catch(y){e={error:y}}finally{try{f&&!f.done&&(i=d.return)&&i.call(d)}finally{if(e)throw e.error}}return new Rs({x:o,y:a,z:l},{x:c,y:u,z:h})},Object.defineProperty(t.prototype,"closed",{get:function(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0},enumerable:!1,configurable:!0}),t.prototype.getPoints=function(e){var i=[],r=this.deltaAngle,s=this.startAngle;this.closed&&(r=ue,s=0);for(var o=0;o<=e;o++){var a=s+r*(o/e),l=this.getPointAtAngle(a);i.push(l)}return i},t.prototype.tessellate=function(e){var i,r=this.closed?ue:this.deltaAngle,s=t.segmentCount(this.radius,r,Lc(Lc({},e),{minSegments:(i=e==null?void 0:e.minSegments)!==null&&i!==void 0?i:this.closed?8:3}));return this.getPoints(s)},t.segmentCount=function(e,i,r){return fn.segmentCount(e,i,r)},t.prototype.transform=function(e){var i=this.center.clone().applyMatrix4(e),r=this.startPoint.clone().applyMatrix4(e),s=this.endPoint.clone().applyMatrix4(e),o=this.getPointAtAngle(this.closed?Math.PI/2:this.startAngle+this.deltaAngle/2).clone().applyMatrix4(e),a=new _t(r).sub(i).normalize(),l=i.distanceTo(r),c=new _t().crossVectors(new _t(r).sub(i),new _t(o).sub(i)).normalize();c.lengthSq()===0&&(c=this.normal.clone().transformDirection(e));var u=function(h){var d=new _t(h).sub(i);return Math.atan2(d.dot(l0.crossVectors(c,a)),d.dot(a))};return this.center=i,this.radius=l,this.normal=c,this.refVec=a,this.startAngle=0,this.endAngle=this.closed?ue:u(s),this._boundingBoxNeedsUpdate=!0,this},t.prototype.copy=function(e){return this.center=e.center,this.radius=e.radius,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.normal=e.normal,this.refVec=e.refVec,this._boundingBoxNeedsUpdate=!0,this},t.prototype.clone=function(){return new t(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)},t.prototype.getAngle=function(e){return e.sub(this.center),Math.atan2(e.dot(l0.crossVectors(this.refVec,this.normal)),e.dot(this.refVec))},t.prototype.getPointAtAngle=function(e){var i=this.normal,r=this.refVec,s={x:i.y*r.z-i.z*r.y,y:i.z*r.x-i.x*r.z,z:i.x*r.y-i.y*r.x},o=this.center,a=this.radius;return new Be(o.x+a*(r.x*Math.cos(e)+s.x*Math.sin(e)),o.y+a*(r.y*Math.cos(e)+s.y*Math.sin(e)),o.z+a*(r.z*Math.cos(e)+s.z*Math.sin(e)))},Object.defineProperty(t.prototype,"plane",{get:function(){var e=new _t(this.center).distanceTo(Zy);return new Ud(this.normal,e)},enumerable:!1,configurable:!0}),t.prototype.offset=function(e){var i=this.radius+e;return i<=0?null:new t(this.center,i,this.startAngle,this.endAngle,this.normal,this.refVec)},t})(Tc),l0=new _t,WE=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),XE=(function(n){WE(t,n);function t(e,i,r,s,o,a,l){s===void 0&&(s=0),o===void 0&&(o=ue),a===void 0&&(a=!1),l===void 0&&(l=0);var c=n.call(this)||this;return c.center=e,c.majorAxisRadius=i,c.minorAxisRadius=r,(o-s)%ue==0?(c.startAngle=0,c.endAngle=ue):(c.startAngle=s,c.endAngle=o),c.clockwise=a,c.rotation=l,c}return Object.defineProperty(t.prototype,"center",{get:function(){return this._center},set:function(e){this._center=new Be(e.x,e.y,e.z||0),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"majorAxisRadius",{get:function(){return this._majorAxisRadius},set:function(e){if(e<0)throw Lr.ILLEGAL_PARAMETERS;this._majorAxisRadius=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"minorAxisRadius",{get:function(){return this._minorAxisRadius},set:function(e){if(e<0)throw Lr.ILLEGAL_PARAMETERS;this._minorAxisRadius=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startAngle",{get:function(){return this._startAngle},set:function(e){this._startAngle=ne.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endAngle",{get:function(){return this._endAngle},set:function(e){this._endAngle=this.startAngle==0&&e==ue?e:ne.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"clockwise",{get:function(){return this._clockwise},set:function(e){this._clockwise=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotation",{get:function(){return this._rotation},set:function(e){this._rotation=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"deltaAngle",{get:function(){return ne.normalizeAngle(this.endAngle-this.startAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isLargeArc",{get:function(){return Math.abs(this.deltaAngle)>Math.PI?1:0},enumerable:!1,configurable:!0}),t.prototype.calculateBoundingBox=function(){for(var e=100,i=1/0,r=1/0,s=-1/0,o=-1/0,a=0;a<=e;a++){var l=this.getPoint(a/e);i=Math.min(i,l.x),r=Math.min(r,l.y),s=Math.max(s,l.x),o=Math.max(o,l.y)}return new Dd({x:i,y:r},{x:s,y:o})},Object.defineProperty(t.prototype,"closed",{get:function(){return this.deltaAngle==0},enumerable:!1,configurable:!0}),t.prototype.getPoint=function(e){for(var i=Math.PI*2,r=this.endAngle-this.startAngle,s=Math.abs(r)<Number.EPSILON;r<0;)r+=i;for(;r>i;)r-=i;r<Number.EPSILON&&(s?r=0:r=i),this.clockwise===!0&&!s&&(r===i?r=-i:r=r-i);var o=this.startAngle+e*r,a=this.center.x+this.majorAxisRadius*Math.cos(o),l=this.center.y+this.minorAxisRadius*Math.sin(o);if(this.rotation!==0){var c=Math.cos(this.rotation),u=Math.sin(this.rotation),h=a-this.center.x,d=l-this.center.y;a=h*c-d*u+this.center.x,l=h*u+d*c+this.center.y}return new Ie(a,l)},t.prototype.transform=function(e){var i=e,r=new Ie(this.center).applyMatrix2d(i),s=new Be(r.x,r.y,this.center.z),o=this.getPointAtAngle(0).clone().applyMatrix2d(i),a=this.getPointAtAngle(Math.PI/2).clone().applyMatrix2d(i),l=new Ie(o).sub(r),c=new Ie(a).sub(r),u=l.length(),h=c.length(),d=Math.atan2(l.y,l.x),f=l.clone().normalize(),p=c.clone().normalize(),g=function(v){var x=new Ie(v).sub(r),_=x.dot(f),b=x.dot(p);return ne.normalizeAngle(Math.atan2(b/h,_/u))},y=i.determinant()<0?!this.clockwise:this.clockwise,m=this.closed?new t(s,u,h,0,ue,y,d):new t(s,u,h,g(this.startPoint.clone().applyMatrix2d(i)),g(this.endPoint.clone().applyMatrix2d(i)),y,d);return this.center=m.center,this.majorAxisRadius=m.majorAxisRadius,this.minorAxisRadius=m.minorAxisRadius,this._startAngle=m._startAngle,this._endAngle=m._endAngle,this._clockwise=m._clockwise,this.rotation=m.rotation,this._boundingBoxNeedsUpdate=!0,this},t.prototype.getPointAtAngle=function(e){return this.getPoint(this.closed?e/ue:ne.normalizeAngle(e-this.startAngle)/this.deltaAngle)},t.prototype.copy=function(e){return this.center=e.center,this.majorAxisRadius=e.majorAxisRadius,this.minorAxisRadius=e.minorAxisRadius,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.clockwise=e.clockwise,this.rotation=e.rotation,this},t.prototype.clone=function(){return new t(this.center,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle,this.clockwise,this.rotation)},t.prototype.getFocusPoints=function(){var e=Math.max(this.majorAxisRadius,this.minorAxisRadius),i=Math.min(this.majorAxisRadius,this.minorAxisRadius);if(e-i<1e-9)return[];var r=Math.sqrt(e*e-i*i),s=Math.cos(this.rotation),o=Math.sin(this.rotation),a=this.majorAxisRadius>=this.minorAxisRadius,l=a?s:-o,c=a?o:s;return[new Ie(this.center.x-r*l,this.center.y-r*c),new Ie(this.center.x+r*l,this.center.y+r*c)]},t.prototype.getQuadrantPoints=function(){return this.closed?[this.getPoint(0),this.getPoint(.25),this.getPoint(.5),this.getPoint(.75)]:[]},t.prototype.nearestPoint=function(e){for(var i=new Ie(e.x,e.y),r=this.getPoint(0),s=i.distanceToSquared(r),o=72,a=1;a<=o;a++){var l=this.getPoint(a/o),c=i.distanceToSquared(l);c<s&&(s=c,r=l)}return r},t.prototype.tangentPoints=function(e){var i=this,r=this._projectPointToLocal(e),s=this._findSnapAngles(r,function(o,a,l,c){var u=-i.majorAxisRadius*c,h=i.minorAxisRadius*l;return(o-r.x)*h-(a-r.y)*u});return s.map(function(o){return i.getPointAtAngle(o)})},t.prototype.perpendicularPoints=function(e){var i=this,r=this._projectPointToLocal(e),s=this._findSnapAngles(r,function(o,a,l,c){var u=i.minorAxisRadius*l,h=i.majorAxisRadius*c;return(o-r.x)*h-(a-r.y)*u});return s.map(function(o){return i.getPointAtAngle(o)})},t.prototype._projectPointToLocal=function(e){var i=e.x-this.center.x,r=e.y-this.center.y,s=Math.cos(-this.rotation),o=Math.sin(-this.rotation);return{x:i*s-r*o,y:i*o+r*s}},t.prototype._findSnapAngles=function(e,i,r){r===void 0&&(r=144);for(var s=this.majorAxisRadius,o=this.minorAxisRadius,a=this.startAngle,l=this.deltaAngle,c=[],u=function(_){var b=Math.cos(_),w=Math.sin(_);return i(s*b,o*w,b,w)},h=a,d=u(h),f=1;f<=r;f++){var p=a+l*f/r,g=u(p);if(Math.abs(d)<1e-10&&c.push(h),d*g<0){for(var y=h,m=p,v=0;v<32;v++){var x=(y+m)/2;u(y)*u(x)<=0?m=x:y=x}c.push((y+m)/2)}h=p,d=g}return c},t})(Gd),jE=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),Ic=function(){return Ic=Object.assign||function(n){for(var t,e=1,i=arguments.length;e<i;e++){t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},Ic.apply(this,arguments)},$E=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Ja=(function(n){jE(t,n);function t(e,i,r,s,o,a,l){a===void 0&&(a=0),l===void 0&&(l=ue);var c=n.call(this)||this;c.center=e,c.normal=i,c.majorAxis=r,c.majorAxisRadius=s,c.minorAxisRadius=o;var u=Math.abs(l-a);return Math.abs(u-ue)<1e-10||Math.abs(u-2*ue)<1e-10?(c.startAngle=0,c.endAngle=ue):(c.startAngle=a,c.endAngle=l),c}return Object.defineProperty(t.prototype,"center",{get:function(){return this._center},set:function(e){this._center=new Be(e.x,e.y,e.z||0),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"majorAxisRadius",{get:function(){return this._majorAxisRadius},set:function(e){if(e<0)throw Lr.ILLEGAL_PARAMETERS;this._majorAxisRadius=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"minorAxisRadius",{get:function(){return this._minorAxisRadius},set:function(e){if(e<0)throw Lr.ILLEGAL_PARAMETERS;this._minorAxisRadius=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startAngle",{get:function(){return this._startAngle},set:function(e){this._startAngle=ne.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endAngle",{get:function(){return this._endAngle},set:function(e){this._endAngle=this.startAngle==0&&e==ue?e:ne.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"deltaAngle",{get:function(){var e=this.endAngle-this.startAngle;return Math.abs(e-ue)<1e-10?ue:ne.normalizeAngle(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isLargeArc",{get:function(){return Math.abs(this.deltaAngle)>Math.PI?1:0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"clockwise",{get:function(){return this.deltaAngle<=0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normal",{get:function(){return this._normal},set:function(e){this._normal=new _t(e.x,e.y,e.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"majorAxis",{get:function(){return this._majorAxis},set:function(e){this._majorAxis=new _t(e.x,e.y,e.z),this._majorAxis.normalize(),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"minorAxis",{get:function(){return new _t().crossVectors(this.normal,this.majorAxis).normalize()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startPoint",{get:function(){return this.getPointAtAngle(this._startAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){return this.getPointAtAngle(this._endAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"midPoint",{get:function(){var e=this.startAngle,i=this.deltaAngle;(this.closed||Math.abs(i-ue)<1e-10)&&(e=0,i=ue);var r=e+i/2;return this.getPointAtAngle(r)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isCircular",{get:function(){return Ae.equal(this.majorAxisRadius,this.minorAxisRadius)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){if(this.isCircular)return this.majorAxisRadius*Math.abs(this.deltaAngle);for(var e=1e3,i=this.deltaAngle/e,r=0,s=this.getPointAtAngle(this.startAngle),o=1;o<=e;o++){var a=this.startAngle+o*i,l=this.getPointAtAngle(a),c=l.x-s.x,u=l.y-s.y,h=l.z-s.z;r+=Math.sqrt(c*c+u*u+h*h),s=l}return r},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"area",{get:function(){return Math.abs(this.deltaAngle-ue)>=1e-10?0:Math.PI*this.majorAxisRadius*this.minorAxisRadius},enumerable:!1,configurable:!0}),t.prototype.calculateBoundingBox=function(){var e,i;if(this.majorAxis.equals(_t.X_AXIS)||this.majorAxis.equals(_t.Y_AXIS)||this.majorAxis.isParallelTo(_t.X_AXIS)||this.majorAxis.isParallelTo(_t.Y_AXIS)){for(var r=[this.startAngle,this.endAngle],s=0;s<2*Math.PI;s+=Math.PI/2)ne.isBetweenAngle(s,this.startAngle,this.endAngle)&&r.push(s);var o=1/0,a=1/0,l=1/0,c=-1/0,u=-1/0,h=-1/0;try{for(var d=$E(r),f=d.next();!f.done;f=d.next()){var p=f.value,g=this.getPointAtAngle(p);g.x<o&&(o=g.x),g.y<a&&(a=g.y),g.z<l&&(l=g.z),g.x>c&&(c=g.x),g.y>u&&(u=g.y),g.z>h&&(h=g.z)}}catch(m){e={error:m}}finally{try{f&&!f.done&&(i=d.return)&&i.call(d)}finally{if(e)throw e.error}}return new Rs({x:o,y:a,z:l},{x:c,y:u,z:h})}else{for(var y=100,o=1/0,a=1/0,l=1/0,c=-1/0,u=-1/0,h=-1/0,s=0;s<=y;s++){var p=this.startAngle+this.deltaAngle*(s/y),g=this.getPointAtAngle(p);o=Math.min(o,g.x),a=Math.min(a,g.y),l=Math.min(l,g.z),c=Math.max(c,g.x),u=Math.max(u,g.y),h=Math.max(h,g.z)}return new Rs({x:o,y:a,z:l},{x:c,y:u,z:h})}},Object.defineProperty(t.prototype,"closed",{get:function(){return this.deltaAngle==0},enumerable:!1,configurable:!0}),t.prototype.getPoints=function(e){e===void 0&&(e=100);var i=[],r=this.deltaAngle,s=this.startAngle;this.closed&&(r=ue,s=0);for(var o=0;o<=e;o++){var a=s+r*(o/e),l=this.getPointAtAngle(a);i.push(l)}return i},t.prototype.tessellate=function(e){var i=this,r,s,o=fn.resolveTessellateOptions(e),a=this.closed?ue:this.deltaAngle,l=Math.max(this.majorAxisRadius,this.minorAxisRadius),c=Math.abs(a)>=ue-1e-8,u=(r=o.minSegments)!==null&&r!==void 0?r:c?8:3;if(this.isCircular){var h=Za.segmentCount(l,a,Ic(Ic({},e),{minSegments:u}));return this.getPoints(h)}var d=(s=o.deviation)!==null&&s!==void 0?s:fn.chordDeviationFromRadius(l,o.circleSides),f=this.closed?0:this.startAngle;return Tc.tessellateParametricCurve(f,f+a,function(p){return i.getPointAtAngle(p)},{deviation:Math.max(Oe,d),minSegments:u,maxSegments:o.maxSegments})},t.prototype.getPointAtAngle=function(e){var i=Math.cos(e),r=Math.sin(e),s=this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(r),o=this.majorAxis.clone().multiplyScalar(i*this.majorAxisRadius).add(s);return new Be(this.center.x+o.x,this.center.y+o.y,this.center.z+o.z)},t.prototype.nearestPoint=function(e,i){i===void 0&&(i=72);for(var r=new Be(e.x,e.y,e.z||0),s=this.getPointAtAngle(this.startAngle),o=r.distanceToSquared(s),a=1;a<=i;a++){var l=this.startAngle+this.deltaAngle*a/i,c=this.getPointAtAngle(l),u=r.distanceToSquared(c);u<o&&(o=u,s=c)}var h=r.distanceToSquared(this.startPoint),d=r.distanceToSquared(this.endPoint);return h<o&&h<=d?this.startPoint.clone():d<o&&d<h?this.endPoint.clone():s.clone()},t.prototype.tangentPoints=function(e){var i=this,r=this._projectPointToLocalPlane(e),s=this._findSnapParameterAngles(function(o,a,l,c){var u=-i.majorAxisRadius*c,h=i.minorAxisRadius*l;return(o-r.x)*h-(a-r.y)*u});return s.map(function(o){return i.getPointAtAngle(o)})},t.prototype.perpendicularPoints=function(e){var i=this,r=this._projectPointToLocalPlane(e),s=this._findSnapParameterAngles(function(o,a,l,c){var u=i.minorAxisRadius*l,h=i.majorAxisRadius*c;return(o-r.x)*h-(a-r.y)*u});return s.map(function(o){return i.getPointAtAngle(o)})},t.prototype._projectPointToLocalPlane=function(e){var i=new Be(e.x,e.y,e.z||0),r=new _t(i).sub(this.center),s=r.dot(this.normal);return r.sub(this.normal.clone().multiplyScalar(s)),{x:r.dot(this.majorAxis),y:r.dot(this.minorAxis)}},t.prototype._findSnapParameterAngles=function(e,i){i===void 0&&(i=144);for(var r=this.majorAxisRadius,s=this.minorAxisRadius,o=this.startAngle,a=this.deltaAngle,l=[],c=function(x){var _=Math.cos(x),b=Math.sin(x);return e(r*_,s*b,_,b)},u=o,h=c(u),d=1;d<=i;d++){var f=o+a*d/i,p=c(f);if(Math.abs(h)<1e-10&&l.push(u),h*p<0){for(var g=u,y=f,m=0;m<32;m++){var v=(g+y)/2;c(g)*c(v)<=0?y=v:g=v}l.push((g+y)/2)}u=f,h=p}return l},t.prototype.contains=function(e){var i=new _t(e).sub(this.center),r=i.dot(this.majorAxis),s=i.dot(this.minorAxis),o=r/this.majorAxisRadius,a=s/this.minorAxisRadius;return o*o+a*a<=1},t.prototype.transform=function(e){var i=e,r=this.center.clone().applyMatrix4(i),s=this.getPointAtAngle(0).clone().applyMatrix4(i),o=this.getPointAtAngle(Math.PI/2).clone().applyMatrix4(i),a=new _t(s).sub(r),l=new _t(o).sub(r),c=a.length(),u=l.length(),h=a.clone().normalize(),d=new _t().crossVectors(a,l).normalize(),f=new _t().crossVectors(d,h).normalize();f.dot(l)<0&&(d.negate(),f=new _t().crossVectors(d,h).normalize());var p=function(y){var m=new _t(y).sub(r),v=m.dot(h),x=m.dot(f);return ne.normalizeAngle(Math.atan2(x/u,v/c))},g=this.closed?new t(r,d,h,c,u,0,ue):new t(r,d,h,c,u,p(this.startPoint.clone().applyMatrix4(i)),p(this.endPoint.clone().applyMatrix4(i)));return this.center=g.center,this.normal=g.normal,this.majorAxis=g.majorAxis,this.majorAxisRadius=g.majorAxisRadius,this.minorAxisRadius=g.minorAxisRadius,this._startAngle=g._startAngle,this._endAngle=g._endAngle,this._boundingBoxNeedsUpdate=!0,this},t.prototype.copy=function(e){return this.center=e.center,this.normal=e.normal,this.majorAxis=e.majorAxis,this.majorAxisRadius=e.majorAxisRadius,this.minorAxisRadius=e.minorAxisRadius,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this._boundingBoxNeedsUpdate=!0,this},t.prototype.clone=function(){return new t(this.center,this.normal,this.majorAxis,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle)},Object.defineProperty(t.prototype,"plane",{get:function(){var e=new _t(this.center).distanceTo(Zy);return new Ud(this.normal,e)},enumerable:!1,configurable:!0}),t.prototype.offset=function(e){var i=this.majorAxisRadius+e,r=this.minorAxisRadius+e;return i<=0||r<=0?null:new t(this.center,this.normal,this.majorAxis,i,r,this.startAngle,this.endAngle)},t})(Tc),YE=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),qE=(function(n){YE(t,n);function t(e,i){var r=n.call(this)||this;return r._start=new Ie(e),r._end=new Ie(i),r}return Object.defineProperty(t.prototype,"startPoint",{get:function(){return this._start},set:function(e){this._start.copy(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){return this._end},set:function(e){this._end.copy(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),t.prototype.getPoints=function(){return[this.startPoint,this.endPoint]},Object.defineProperty(t.prototype,"length",{get:function(){return this.startPoint.distanceTo(this.endPoint)},enumerable:!1,configurable:!0}),t.prototype.calculateBoundingBox=function(){var e=new Ie(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y)),i=new Ie(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y));return new Dd(e,i)},t.prototype.transform=function(e){return this._start.applyMatrix2d(e),this._end.applyMatrix2d(e),this._boundingBoxNeedsUpdate=!0,this},Object.defineProperty(t.prototype,"closed",{get:function(){return!1},enumerable:!1,configurable:!0}),t.prototype.copy=function(e){return this.startPoint=e.startPoint,this.endPoint=e.endPoint,this._boundingBoxNeedsUpdate=!0,this},t.prototype.clone=function(){return new t(this._start.clone(),this._end.clone())},t.prototype.project=function(e){var i=this._end.x-this._start.x,r=this._end.y-this._start.y,s=i*i+r*r;if(s<1e-18)return this._start.clone();var o=((e.x-this._start.x)*i+(e.y-this._start.y)*r)/s;return o=Math.max(0,Math.min(1,o)),new Ie(this._start.x+o*i,this._start.y+o*r)},t.prototype.nearestPoint=function(e){return this.project(e)},t})(Gd),KE=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),Wd=(function(){function n(){this.c0=0,this.c1=0,this.c2=0,this.c3=0}return n.prototype.init=function(t,e,i,r){this.c0=t,this.c1=i,this.c2=-3*t+3*e-2*i-r,this.c3=2*t-2*e+i+r},n.prototype.initCatmullRom=function(t,e,i,r,s){this.init(e,i,s*(i-t),s*(r-e))},n.prototype.initNonuniformCatmullRom=function(t,e,i,r,s,o,a){var l=(e-t)/s-(i-t)/(s+o)+(i-e)/o,c=(i-e)/o-(r-e)/(o+a)+(r-i)/a;l*=o,c*=o,this.init(e,i,l,c)},n.prototype.calc=function(t){var e=t*t,i=e*t;return this.c0+this.c1*t+this.c2*e+this.c3*i},n})(),ZE=(function(n){KE(t,n);function t(e,i,r,s){e===void 0&&(e=[]),i===void 0&&(i=!1),r===void 0&&(r="centripetal"),s===void 0&&(s=.5);var o=n.call(this)||this;return o.isCatmullRomCurve3d=!0,o.type="CatmullRomCurve3d",o._tmp=new _t,o._px=new Wd,o._py=new Wd,o._pz=new Wd,o._points=e.map(function(a){return new Be(a)}),o._closed=i,o._curveType=r,o._tension=s,o}return Object.defineProperty(t.prototype,"points",{get:function(){return this._points},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"closed",{get:function(){return this._closed},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"curveType",{get:function(){return this._curveType},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tension",{get:function(){return this._tension},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startPoint",{get:function(){return this._points.length>0?this._points[0]:new Be},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){return this._points.length>0?this._points[this._points.length-1]:new Be},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){if(this._points.length<2)return 0;for(var e=0,i=1;i<this._points.length;i++)e+=this._points[i-1].distanceTo(this._points[i]);return this._closed&&this._points.length>2&&(e+=this._points[this._points.length-1].distanceTo(this._points[0])),e},enumerable:!1,configurable:!0}),t.prototype.getPoint=function(e,i){i===void 0&&(i=new Be);var r=i,s=this._points,o=s.length;if(o===0)return r.set(0,0,0);if(o===1)return r.copy(s[0]);var a=(o-(this._closed?0:1))*e,l=Math.floor(a),c=a-l;this._closed?l+=l>0?0:(Math.floor(Math.abs(l)/o)+1)*o:c===0&&l===o-1&&(l=o-2,c=1);var u,h;this._closed||l>0?u=s[(l-1)%o]:(this._tmp.subVectors(s[0],s[1]).add(s[0]),u=new Be(this._tmp.x,this._tmp.y,this._tmp.z));var d=s[l%o],f=s[(l+1)%o];if(this._closed||l+2<o?h=s[(l+2)%o]:(this._tmp.subVectors(s[o-1],s[o-2]).add(s[o-1]),h=new Be(this._tmp.x,this._tmp.y,this._tmp.z)),this._curveType==="centripetal"||this._curveType==="chordal"){var p=this._curveType==="chordal"?.5:.25,g=Math.pow(u.distanceToSquared(d),p),y=Math.pow(d.distanceToSquared(f),p),m=Math.pow(f.distanceToSquared(h),p);y<1e-4&&(y=1),g<1e-4&&(g=y),m<1e-4&&(m=y),this._px.initNonuniformCatmullRom(u.x,d.x,f.x,h.x,g,y,m),this._py.initNonuniformCatmullRom(u.y,d.y,f.y,h.y,g,y,m),this._pz.initNonuniformCatmullRom(u.z,d.z,f.z,h.z,g,y,m)}else this._curveType==="catmullrom"&&(this._px.initCatmullRom(u.x,d.x,f.x,h.x,this._tension),this._py.initCatmullRom(u.y,d.y,f.y,h.y,this._tension),this._pz.initCatmullRom(u.z,d.z,f.z,h.z,this._tension));return r.set(this._px.calc(c),this._py.calc(c),this._pz.calc(c)),r},t.prototype.getPoints=function(e){for(var i=[],r=0;r<=e;r++)i.push(this.getPoint(r/e));return i},t.prototype.setPoints=function(e){this._points=e.map(function(i){return new Be(i)}),this._boundingBoxNeedsUpdate=!0},t.prototype.setClosed=function(e){this._closed!==e&&(this._closed=e,this._boundingBoxNeedsUpdate=!0)},t.prototype.setCurveType=function(e){this._curveType=e},t.prototype.setTension=function(e){this._tension=e},t.prototype.clone=function(){return new t(this._points.map(function(e){return e.clone()}),this._closed,this._curveType,this._tension)},t.prototype.transform=function(e){return this._points=this._points.map(function(i){var r=new Be;return r.copy(i),r.applyMatrix4(e),r}),this._boundingBoxNeedsUpdate=!0,this},t.prototype.calculateBoundingBox=function(){if(this._points.length===0)return new Rs;var e=new Rs;return this._points.forEach(function(i){e.expandByPoint(i)}),e},t})(Tc),vo=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},_o=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))};function c0(n,t){var e,i,r=n.x-t[0],s=n.y-t[1],o=((e=n.z)!==null&&e!==void 0?e:0)-((i=t[2])!==null&&i!==void 0?i:0);return r*r+s*s+o*o}var JE=(function(){function n(t,e,i,r){this._degree=t,this._knots=_o([],vo(e),!1),this._controlPoints=i.map(function(s){return{x:s.x,y:s.y,z:s.z}}),this._weights=r?_o([],vo(r),!1):new Array(i.length).fill(1)}return n.prototype.degree=function(){return this._degree},n.prototype.knots=function(){return _o([],vo(this._knots),!1)},n.prototype.controlPoints=function(){return this._controlPoints.map(function(t){return{x:t.x,y:t.y,z:t.z}})},n.prototype.weights=function(){return _o([],vo(this._weights),!1)},n.prototype.clone=function(){return new n(this._degree,this._knots,this._controlPoints,this._weights)},n.prototype.point=function(t){return this.evaluate(t).point},n.prototype.evaluate=function(t){var e=this._controlPoints.map(function(i){return[i.x,i.y,i.z]});return vE(t,this._degree,this._knots,e,this._weights)},n.prototype.signedPlanarCurvatureAt=function(t){var e=this.evaluate(t);return _E(e.deriv1,e.deriv2)},n.prototype.getOffsetSamplePath2d=function(t,e){var i=this;e===void 0&&(e=512);for(var r=Math.abs(t),s=this.getParameterRange(),o=s.start,a=s.end,l=this.length(),c=Math.max(64,Math.ceil(l/Math.max(r*.2,1e-6))),u=QE(o,a,Math.min(c,e)),h=0;h<8&&u.length<e;h++){for(var d=[],f=0;f<u.length-1;f++){var p=u[f],g=u[f+1],y=(p+g)/2,m=Math.max(Math.abs(this.signedPlanarCurvatureAt(p)),Math.abs(this.signedPlanarCurvatureAt(g)),Math.abs(this.signedPlanarCurvatureAt(y)));r*m>.85&&d.push(y)}if(d.length===0)break;if(u=tA(u,d),u.length>e){u=u.slice(0,e);break}}var v=[],x=[];return u.forEach(function(_){var b=i.evaluate(_);v.push(new Ie(b.point[0],b.point[1]));var w=b.deriv1[0],C=b.deriv1[1],E=Math.hypot(w,C);x.push(E>1e-10?new Ie(w/E,C/E):new Ie(1,0))}),{points:v,tangents:x}},n.prototype.length=function(){var t=this._controlPoints.map(function(e){return[e.x,e.y,e.z]});return xE(this._degree,this._knots,t,this._weights)},n.byKnotsControlPointsWeights=function(t,e,i,r){return new n(t,e,i,r)},n.byPoints=function(t,e,i,r,s){i===void 0&&(i="Uniform");var o=gE(t,e,i,r,s),a=o.controlPoints.map(function(l){return{x:l[0],y:l[1],z:l[2]}});return new n(e,o.knots,a,o.weights)},n.prototype.getParameterRange=function(){var t=this._knots[this._degree],e=this._knots[this._knots.length-this._degree-1];return{start:t,end:e}},n.prototype.getPoints=function(t){for(var e=[],i=this.getParameterRange(),r=i.start,s=i.end,o=0;o<=t;o++){var a=r+(s-r)*(o/t);e.push(this.point(a))}return e},n.prototype.isClosed=function(t){t===void 0&&(t=1e-6);var e=this.getParameterRange(),i=e.start,r=e.end,s=this.point(i),o=this.point(r),a=s[0]-o[0],l=s[1]-o[1],c=s[2]-o[2];return Math.sqrt(a*a+l*l+c*c)<t},n.createFitPointsForClosedCurve=function(t){if(t.length<4)throw new Error("At least 4 points are required for a closed NURBS curve");var e=new ZE(t,!0,"centripetal"),i=Math.max(50,t.length*2);return e.getPoints(i)},n.prototype.nearestPoint=function(t,e){var i;e===void 0&&(e=64);for(var r=this.getParameterRange(),s=r.start,o=r.end,a=this.point(s),l=c0(t,a),c=0;c<=e;c++){var u=s+(o-s)*c/e,h=this.point(u),d=c0(t,h);d<l&&(l=d,a=h)}return{x:a[0],y:a[1],z:(i=a[2])!==null&&i!==void 0?i:0}},n.createClosedCurve=function(t,e,i){i===void 0&&(i="Chord");var r=this.createFitPointsForClosedCurve(t),s=r.map(function(o){return[o.x,o.y,o.z]});return n.byPoints(s,e,i)},n})();function QE(n,t,e){if(e<2)return[n,t];for(var i=[],r=0;r<e;r++)i.push(r===e-1?t:n+(t-n)*r/(e-1));return i}function tA(n,t){var e=_o(_o([],vo(n),!1),vo(t),!1).sort(function(r,s){return r-s}),i=[];return e.forEach(function(r){var s=i[i.length-1];(s===void 0||Math.abs(s-r)>1e-10)&&i.push(r)}),i}var hi=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Qa=128,Pc=96,Kt=Jy.equalPointTol,Xd=Kt*8;function eA(n,t,e,i,r){var s,o,a,l;e===void 0&&(e=!1),i===void 0&&(i=!1);var c=u0(n,e,r),u=u0(t,i,r),h=[];try{for(var d=hi(c),f=d.next();!f.done;f=d.next()){var p=f.value;try{for(var g=(a=void 0,hi(u)),y=g.next();!y.done;y=g.next()){var m=y.value;$d(p,m)&&Qd(h,m0(p,m))}}catch(v){a={error:v}}finally{try{y&&!y.done&&(l=g.return)&&l.call(g)}finally{if(a)throw a.error}}}}catch(v){s={error:v}}finally{try{f&&!f.done&&(o=d.return)&&o.call(d)}finally{if(s)throw s.error}}return vA(h)}function u0(n,t,e){var i,r,s=[];try{for(var o=hi(n),a=o.next();!a.done;a=o.next()){var l=a.value,c=t&&l.extendable!==!1;switch(l.kind){case"line":{var u=sA(l.line,e);if(!u)break;var h=c?"unbounded":l.extent;s.push(xo(u.start,u.end,h));break}case"circArc":{var d=iA(l.arc,c);if(e&&!tl(d.normal,e.normal)){var f=aA(d,e);(f==null?void 0:f.kind)==="circArc"?s.push(h0(f.arc,ir(f.arc))):(f==null?void 0:f.kind)==="ellipseArc"?s.push(d0(f.arc,Rr(f.arc))):jd(s,f0(d,ir(d)),ir(d),e)}else{var f=oA(d,e);f&&s.push(h0(f,ir(f)))}break}case"ellipseArc":{var d=rA(l.arc,c);if(e&&!tl(d.normal,e.normal))jd(s,p0(d,Rr(d)),Rr(d),e);else{var f=lA(d,e);f&&s.push(d0(f,Rr(f)))}break}case"spline":{e?jd(s,l.spline.getPoints(Qa),l.spline.closed,e):s.push(nA(l.spline));break}}}}catch(p){i={error:p}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s}function xo(n,t,e){var i=new _t().subVectors(t,n);return{kind:"line",start:n,dir:i,extent:e,box:e==="bounded"?new Rs().setFromPoints([n,t]):void 0}}function h0(n,t){return{kind:"circArc",arc:n,full:t||ir(n),box:n.box}}function d0(n,t){return{kind:"ellipseArc",arc:n,full:t||Rr(n),box:n.box}}function nA(n){var t,e,i=[],r=n.getPoints(Qa);if(r.length>=2)for(var s=n.closed?r.length:r.length-1,o=0;o<s;o++){var a=r[o],l=r[(o+1)%r.length];a.distanceToSquared(l)<Kt*Kt||i.push(xo(a.clone(),l.clone(),"bounded"))}var c=new Rs;try{for(var u=hi(i),h=u.next();!h.done;h=u.next()){var d=h.value;d.box&&c.union(d.box)}}catch(f){t={error:f}}finally{try{h&&!h.done&&(e=u.return)&&e.call(u)}finally{if(t)throw t.error}}return{kind:"spline",spline:n,samples:i,box:i.length>0?c:void 0}}function iA(n,t){return!t||ir(n)?n:new Za(n.center,n.radius,0,ue,n.normal,n.refVec)}function rA(n,t){return!t||Rr(n)?n:new Ja(n.center,n.normal,n.majorAxis,n.majorAxisRadius,n.minorAxisRadius,0,ue)}function sA(n,t){if(!t)return{start:n.startPoint.clone(),end:n.endPoint.clone()};var e=Pr(n.startPoint,t),i=Pr(n.endPoint,t);return e.distanceToSquared(i)<Kt*Kt?null:{start:e,end:i}}function oA(n,t){if(!t)return n;var e=Pr(n.center,t);return new Za(e,n.radius,n.startAngle,n.endAngle,t.normal.clone(),Kd(n.refVec,t.normal))}function aA(n,t){var e=Pr(n.center,t),i=n.normal.clone();if(i.lengthSq()<Kt*Kt)return null;i.normalize();var r=t.normal.clone();if(r.lengthSq()<Kt*Kt)return null;r.normalize();var s=i.dot(r),o=Math.abs(s);if(o>1-1e-8)return{kind:"circArc",arc:new Za(e,n.radius,n.startAngle,n.endAngle,r,Kd(n.refVec,r))};if(o<1e-8)return null;var a=new _t().crossVectors(i,r);if(a.lengthSq()<Kt*Kt)return null;a.normalize();var l=new Ja(e,r,a,n.radius,n.radius*o,0,ue);if(ir(n))return{kind:"ellipseArc",arc:l};var c=Pr(n.startPoint,t),u=Pr(n.endPoint,t),h=Pr(n.midPoint,t),d=wo(l,c),f=wo(l,u),p=wo(l,h),g=ne.normalizeAngle(p-d),y=ne.normalizeAngle(f-d),m=g<=y||y<1e-8?d+y:d+y+ue;return{kind:"ellipseArc",arc:new Ja(e,r,a,n.radius,n.radius*o,d,m)}}function lA(n,t){if(!t)return n;var e=Pr(n.center,t),i=Kd(n.majorAxis,t.normal);return i.lengthSq()<Kt*Kt?null:new Ja(e,t.normal.clone(),i,n.majorAxisRadius,n.minorAxisRadius,n.startAngle,n.endAngle)}function jd(n,t,e,i){if(!(t.length<2))for(var r=i?t.map(function(c){return Pr(c,i)}):t,s=e?r.length:r.length-1,o=0;o<s;o++){var a=r[o],l=r[(o+1)%r.length];a.distanceToSquared(l)<Kt*Kt||n.push(xo(a.clone(),l.clone(),"bounded"))}}function f0(n,t){return t||ir(n)?new Za(n.center,n.radius,0,ue,n.normal,n.refVec).getPoints(Pc):n.getPoints(Pc)}function p0(n,t){return t||Rr(n)?new Ja(n.center,n.normal,n.majorAxis,n.majorAxisRadius,n.minorAxisRadius,0,ue).getPoints(Pc):n.getPoints(Pc)}function $d(n,t){return!n.box||!t.box?!0:n.box.intersectsBox(t.box)}function m0(n,t){return n.kind==="spline"&&t.kind==="spline"?cA(n,t):n.kind==="spline"?g0(n,t):t.kind==="spline"?g0(t,n):n.kind==="line"&&t.kind==="line"?y0(n,t):n.kind==="line"&&t.kind==="circArc"?Rc(n,t.arc,t.full):t.kind==="line"&&n.kind==="circArc"?Rc(t,n.arc,n.full):n.kind==="line"&&t.kind==="ellipseArc"?Yd(n,t.arc,t.full):t.kind==="line"&&n.kind==="ellipseArc"?Yd(t,n.arc,n.full):n.kind==="circArc"&&t.kind==="circArc"?pA(n.arc,n.full,t.arc,t.full):n.kind==="circArc"&&t.kind==="ellipseArc"?v0(n.arc,n.full,t.arc,t.full):n.kind==="ellipseArc"&&t.kind==="circArc"?v0(t.arc,t.full,n.arc,n.full):n.kind==="ellipseArc"&&t.kind==="ellipseArc"?gA(n.arc,n.full,t.arc,t.full):[]}function g0(n,t){var e,i,r=[];try{for(var s=hi(n.samples),o=s.next();!o.done;o=s.next()){var a=o.value;$d(a,t)&&Qd(r,m0(a,t))}}catch(l){e={error:l}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(e)throw e.error}}return uA(n.spline,r,t)}function cA(n,t){var e,i,r,s,o,a,l=[];try{for(var c=hi(n.samples),u=c.next();!u.done;u=c.next()){var h=u.value;try{for(var d=(r=void 0,hi(t.samples)),f=d.next();!f.done;f=d.next()){var p=f.value;$d(h,p)&&Qd(l,y0(h,p))}}catch(b){r={error:b}}finally{try{f&&!f.done&&(s=d.return)&&s.call(d)}finally{if(r)throw r.error}}}}catch(b){e={error:b}}finally{try{u&&!u.done&&(i=c.return)&&i.call(c)}finally{if(e)throw e.error}}var g=[];try{for(var y=hi(l),m=y.next();!m.done;m=y.next()){var v=m.value,x=n.spline.nearestPoint(v,Qa),_=t.spline.nearestPoint(v,Qa);x.distanceTo(_)<=Xd&&g.push(x)}}catch(b){o={error:b}}finally{try{m&&!m.done&&(a=y.return)&&a.call(y)}finally{if(o)throw o.error}}return g}function uA(n,t,e){var i,r,s=[];try{for(var o=hi(t),a=o.next();!a.done;a=o.next()){var l=a.value,c=n.nearestPoint(l,Qa);hA(e,c)<=Xd&&s.push(c)}}catch(u){i={error:u}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s}function hA(n,t){if(n.kind==="line"){var e=n.dir.lengthSq();if(e<Kt*Kt)return Number.POSITIVE_INFINITY;var i=new _t().subVectors(t,n.start).dot(n.dir)/e;return bo(i,n.extent)?So(n.start,n.dir,i).distanceTo(t):Number.POSITIVE_INFINITY}if(n.kind==="circArc"){if(!Jd(t,n.arc)){var r=Mi(n.arc.normal,n.arc.center),s=Math.abs(r.distanceToPoint(t)),o=Math.abs(t.distanceTo(n.arc.center)-n.arc.radius),a=Math.hypot(s,o);if(a>Xd)return a}return Bs(n.arc,Os(n.arc,t),n.full)?0:Number.POSITIVE_INFINITY}return n.kind==="ellipseArc"?Mo(t,n.arc,n.full)?0:Math.abs(kc(n.arc,t)):Number.POSITIVE_INFINITY}function y0(n,t){var e=n.dir,i=t.dir,r=e.lengthSq(),s=i.lengthSq();if(r<Kt*Kt||s<Kt*Kt)return[];var o=new _t().subVectors(n.start,t.start),a=e.dot(e),l=e.dot(i),c=i.dot(i),u=e.dot(o),h=i.dot(o),d=a*c-l*l;if(Math.abs(d)<Oe*Oe*a*c)return[];var f=(l*h-c*u)/d,p=(a*h-l*u)/d;if(!bo(f,n.extent)||!bo(p,t.extent))return[];var g=So(n.start,e,f),y=So(t.start,i,p);return g.distanceTo(y)>Kt?[]:[g]}function Rc(n,t,e){var i=Mi(t.normal,t.center),r=x0(n,i);return r==="coplanar"?dA(n,t,e):r?Jd(r,t)?Bs(t,Os(t,r),e)?[r]:[]:[]:[]}function dA(n,t,e){var i,r,s=new _t().subVectors(n.start,t.center),o=n.dir.dot(n.dir);if(o<Kt*Kt)return[];var a=2*n.dir.dot(s),l=s.dot(s)-t.radius*t.radius,c=[];try{for(var u=hi(S0(o,a,l)),h=u.next();!h.done;h=u.next()){var d=h.value;if(bo(d,n.extent)){var f=So(n.start,n.dir,d);Bs(t,Os(t,f),e)&&c.push(f)}}}catch(p){i={error:p}}finally{try{h&&!h.done&&(r=u.return)&&r.call(u)}finally{if(i)throw i.error}}return c}function Yd(n,t,e){var i=Mi(t.normal,t.center),r=x0(n,i);return r==="coplanar"?fA(n,t,e):r?Mo(r,t,e)?[r]:[]:[]}function fA(n,t,e){var i,r,s=t.majorAxis,o=t.minorAxis,a=t.majorAxisRadius,l=t.minorAxisRadius;if(a<Kt||l<Kt)return[];var c=new _t().subVectors(n.start,t.center),u=c.dot(s),h=c.dot(o),d=n.dir.dot(s),f=n.dir.dot(o),p=d*d/(a*a)+f*f/(l*l),g=2*u*d/(a*a)+2*h*f/(l*l),y=u*u/(a*a)+h*h/(l*l)-1,m=[];try{for(var v=hi(S0(p,g,y)),x=v.next();!x.done;x=v.next()){var _=x.value;if(bo(_,n.extent)){var b=So(n.start,n.dir,_);Zd(t,wo(t,b),e)&&m.push(b)}}}catch(w){i={error:w}}finally{try{x&&!x.done&&(r=v.return)&&r.call(v)}finally{if(i)throw i.error}}return m}function pA(n,t,e,i){if(tl(n.normal,e.normal)){var r=Mi(n.normal,n.center);return Math.abs(r.distanceToPoint(e.center))>Kt?[]:yA(mA(n,e),n,t,e,i)}var s=qd(Mi(n.normal,n.center),Mi(e.normal,e.center));if(!s)return[];var o=xo(s.point.clone(),new Be().addVectors(s.point,s.dir),"unbounded"),a=Rc(o,n,t);return a.filter(function(l){return Jd(l,e)?Bs(e,Os(e,l),i):!1})}function mA(n,t){var e=new _t().subVectors(t.center,n.center),i=e.length(),r=n.radius,s=t.radius;if(i<Kt&&Ae.equal(r,s,Kt))return[];if(i>r+s+Kt)return[];if(i+Math.min(r,s)+Kt<Math.max(r,s))return[];var o=i<Kt?b0(n.normal):e.clone().normalize(),a=(r*r-s*s+i*i)/(2*Math.max(i,Kt)),l=r*r-a*a,c=new Be().copy(n.center).addScaledVector(o,a);if(l<-Kt*Kt)return[];if(l<Kt*Kt)return[c];var u=Math.sqrt(Math.max(0,l)),h=new _t().crossVectors(n.normal,o).normalize();return[new Be().copy(c).addScaledVector(h,u),new Be().copy(c).addScaledVector(h,-u)]}function v0(n,t,e,i){if(!tl(n.normal,e.normal)){var r=qd(Mi(n.normal,n.center),Mi(e.normal,e.center));if(!r)return[];var s=xo(r.point.clone(),new Be().addVectors(r.point,r.dir),"unbounded");return Rc(s,n,t).filter(function(o){return Mo(o,e,i)})}return _0(f0(n,t),ir(n)||t,function(o){return kc(e,o)},function(o){return Bs(n,Os(n,o),t)&&Mo(o,e,i)})}function gA(n,t,e,i){if(!tl(n.normal,e.normal)){var r=qd(Mi(n.normal,n.center),Mi(e.normal,e.center));if(!r)return[];var s=xo(r.point.clone(),new Be().addVectors(r.point,r.dir),"unbounded");return Yd(s,n,t).filter(function(o){return Mo(o,e,i)})}return _0(p0(n,t),Rr(n)||t,function(o){return kc(e,o)},function(o){return Zd(n,wo(n,o),t)&&Mo(o,e,i)})}function _0(n,t,e,i){for(var r=[],s=t?n.length:n.length-1,o=0;o<s;o++){var a=n[o],l=n[(o+1)%n.length],c=e(a),u=e(l);if(Math.abs(c)<=Kt){i(a)&&r.push(a.clone());continue}if(!(c*u>0)){for(var h=0,d=1,f=c,p=0;p<40;p++){var g=(h+d)/2,y=new Be().lerpVectors(a,l,g),m=e(y);f*m<=0?d=g:(h=g,f=m)}var v=new Be().lerpVectors(a,l,(h+d)/2);i(v)&&r.push(v)}}return r}function x0(n,t){var e=t.normal.dot(n.dir),i=t.distanceToPoint(n.start);if(Ae.equalToZero(e,Kt*Math.max(1,n.dir.length())))return Ae.equalToZero(i,Kt)?"coplanar":null;var r=-i/e;return bo(r,n.extent)?So(n.start,n.dir,r):null}function qd(n,t){var e=new _t().crossVectors(n.normal,t.normal);if(e.lengthSq()<Kt*Kt)return null;e.normalize();var i=n.normal,r=t.normal,s=i.dot(i)*r.dot(r)-Math.pow(i.dot(r),2);if(Math.abs(s)<Oe)return null;var o=-n.constant,a=-t.constant,l=(r.dot(r)*o-i.dot(r)*a)/s,c=(i.dot(i)*a-i.dot(r)*o)/s,u=new Be().addScaledVector(i,l).addScaledVector(r,c);return{point:u,dir:e}}function bo(n,t){return t==="unbounded"?!0:t==="ray"?n>=-Kt:n>=-Kt&&n<=1+Kt}function So(n,t,e){return new Be().copy(n).addScaledVector(t,e)}function Pr(n,t){var e=new Be;return t.projectPoint(n,e),e}function Kd(n,t){var e=n.clone().addScaledVector(t,-n.dot(t));return e.lengthSq()<Kt*Kt?b0(t):e.normalize()}function Mi(n,t){return new Ud().setFromNormalAndCoplanarPoint(n,t)}function tl(n,t){return new _t().crossVectors(n,t).lengthSq()<Kt*Kt}function Os(n,t){var e=new _t().subVectors(t,n.center),i=new _t().crossVectors(n.normal,n.refVec);return Math.atan2(e.dot(i),e.dot(n.refVec))}function wo(n,t){var e=new _t().subVectors(t,n.center),i=e.dot(n.majorAxis)/n.majorAxisRadius,r=e.dot(n.minorAxis)/n.minorAxisRadius;return Math.atan2(r,i)}function ir(n){return n.closed||Math.abs(n.deltaAngle-ue)<1e-10}function Rr(n){return n.closed||Math.abs(n.endAngle-n.startAngle)<1e-10||Math.abs(n.deltaAngle-ue)<1e-10}function Bs(n,t,e){if(e||ir(n))return!0;var i=ne.normalizeAngle(t-n.startAngle);return i<=n.deltaAngle+1e-8}function Zd(n,t,e){if(e||Rr(n))return!0;var i=ne.normalizeAngle(t-n.startAngle);return i<=n.deltaAngle+1e-8}function Jd(n,t){var e=Mi(t.normal,t.center);return Math.abs(e.distanceToPoint(n))>Kt?!1:Math.abs(n.distanceTo(t.center)-t.radius)<=Kt}function kc(n,t){var e=new _t().subVectors(t,n.center),i=e.dot(n.majorAxis)/n.majorAxisRadius,r=e.dot(n.minorAxis)/n.minorAxisRadius;return i*i+r*r-1}function Mo(n,t,e){var i=Mi(t.normal,t.center);return Math.abs(i.distanceToPoint(n))>Kt||Math.abs(kc(t,n))>1e-4?!1:Zd(t,wo(t,n),e)}function yA(n,t,e,i,r){return n.filter(function(s){return Bs(t,Os(t,s),e)&&Bs(i,Os(i,s),r)})}function b0(n){var t=Math.abs(n.x)<.9?_t.X_AXIS:_t.Y_AXIS,e=new _t().crossVectors(n,t);return e.lengthSq()<Kt*Kt&&e.crossVectors(n,_t.Z_AXIS),e.normalize()}function S0(n,t,e){if(Math.abs(n)<Oe)return Math.abs(t)<Oe?[]:[-e/t];var i=t*t-4*n*e;if(i<-Kt)return[];if(i<Kt)return[-t/(2*n)];var r=Math.sqrt(Math.max(0,i));return[(-t-r)/(2*n),(-t+r)/(2*n)]}function Qd(n,t){var e,i;try{for(var r=hi(t),s=r.next();!s.done;s=r.next()){var o=s.value;n.push(o)}}catch(a){e={error:a}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(e)throw e.error}}}function vA(n){var t,e,i=[],r=function(l){if(i.some(function(c){return c.distanceTo(l)<=Kt}))return"continue";i.push(l)};try{for(var s=hi(n),o=s.next();!o.done;o=s.next()){var a=o.value;r(a)}}catch(l){t={error:l}}finally{try{o&&!o.done&&(e=s.return)&&e.call(s)}finally{if(t)throw t.error}}return i}for(var Ns=256,w0=[],M0=256,Oc;Ns--;)w0[Ns]=(Ns+256).toString(16).substring(1);function _A(n){var t=0,e=11;if(!Oc||Ns+e>M0*2)for(Oc="",Ns=0;t<M0;t++)Oc+=w0[Math.random()*256|0];return Oc.substring(Ns,Ns+++e)}var Bc=function(){return Bc=Object.assign||function(n){for(var t,e=1,i=arguments.length;e<i;e++){t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},Bc.apply(this,arguments)},E0=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Nc=(function(){function n(t){var e,i;if(this._values=[],t)try{for(var r=E0(t),s=r.next();!s.done;s=r.next()){var o=s.value;this._values.push(Bc({},o))}}catch(a){e={error:a}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(e)throw e.error}}}return Object.defineProperty(n.prototype,"length",{get:function(){return this._values.length},enumerable:!1,configurable:!0}),n.prototype.at=function(t){return this._values[t]},n.prototype.add=function(t){this._values.push(t)},n.prototype.addRange=function(t){var e,i;try{for(var r=E0(t),s=r.next();!s.done;s=r.next()){var o=s.value;this._values.push(o)}}catch(a){e={error:a}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(e)throw e.error}}},n.prototype.clear=function(){this._values.length=0},n.prototype.toArray=function(){return this._values.map(function(t){return Bc({},t)})},n.prototype.clone=function(){return new n(this._values)},n.prototype[Symbol.iterator]=function(){return this._values[Symbol.iterator]()},n})(),A0=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(c){return function(u){return l([c,u])}}function l(c){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(e=0)),e;)try{if(i=1,r&&(s=c[0]&2?r.return:c[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,c[1])).done)return s;switch(r=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return e.label++,{value:c[1],done:!1};case 5:e.label++,r=c[1],c=[0];continue;case 7:c=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){e=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){e.label=c[1];break}if(c[0]===6&&e.label<s[1]){e.label=s[1],s=c;break}if(s&&e.label<s[2]){e.label=s[2],e.ops.push(c);break}s[2]&&e.ops.pop(),e.trys.pop();continue}c=t.call(n,e)}catch(u){c=[6,u],r=0}finally{i=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},Cn=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},tf=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},ef="TEMP_",el=(function(){function n(t,e){t=t||{},this._attrs=new Vy(t,e),this._attrs.get("objectId")||(this._database?this._attrs.set("objectId",this._database.generateHandle()):this._attrs.set("objectId",this.generateTemporaryHandle()))}return n.prototype.generateTemporaryHandle=function(){return ef+_A()},Object.defineProperty(n.prototype,"attrs",{get:function(){return this._attrs},enumerable:!1,configurable:!0}),n.prototype.getAttr=function(t){var e=this._attrs.get(t);if(e===void 0)throw new Error("[AcDbObject] Attribute name '".concat(t,"' does't exist in this object!"));return e},n.prototype.getAttrWithoutException=function(t){return this._attrs.get(t)},n.prototype.setAttr=function(t,e){this._attrs.set(t,e)},Object.defineProperty(n.prototype,"objectId",{get:function(){return this.getAttr("objectId")},set:function(t){this._attrs.set("objectId",t),t&&!t.startsWith(ef)&&this._database&&this._database.updateMaxHandle(t)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isTemp",{get:function(){var t=this.getAttrWithoutException("objectId");return!!t&&t.startsWith(ef)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"ownerId",{get:function(){return this.getAttr("ownerId")},set:function(t){this._attrs.set("ownerId",t)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"extensionDictionary",{get:function(){return this.getAttrWithoutException("extensionDictionary")},set:function(t){this._attrs.set("extensionDictionary",t)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"database",{get:function(){if(this._database)return this._database;throw new Error("The current working database must be set before using it!")},set:function(t){this.assignDatabase(t)},enumerable:!1,configurable:!0}),n.prototype.assignDatabase=function(t){this._database!==t&&(this._database=t,this.onDatabaseChanged(t))},n.prototype.onDatabaseChanged=function(t){},n.prototype.findImportedXDataRange=function(t){var e,i=this._importedXData;if(i)for(var r=0;r<i.length;){if(Number(i[r])!==ci.ExtendedDataRegAppName){r+=2;continue}for(var s=String((e=i[r+1])!==null&&e!==void 0?e:""),o=r+2;o<i.length&&Number(i[o])!==ci.ExtendedDataRegAppName;)o+=2;if(s===t)return[r,o];r=o}},n.prototype.removeImportedXData=function(t){var e=this._importedXData,i=this.findImportedXDataRange(t);!e||!i||(e.splice(i[0],i[1]-i[0]),e.length===0&&(this._importedXData=void 0))},n.prototype.rememberXDataApp=function(t){var e;if(t){var i=(e=this._xDataOrder)!==null&&e!==void 0?e:this._xDataOrder=[];i.indexOf(t)===-1&&i.push(t)}},n.prototype.forgetXDataApp=function(t){var e=this._xDataOrder;if(e){var i=e.indexOf(t);i>=0&&e.splice(i,1),e.length===0&&(this._xDataOrder=void 0)}},n.prototype.clearMaterializedXData=function(t){var e=this._xDataMap;e&&(e.delete(t),e.size===0&&(this._xDataMap=void 0))},n.prototype.onXDataChanged=function(t){},n.prototype.notifyXDataChanged=function(t){this.onXDataChanged(t)},n.prototype.importedXDataValues=function(t,e){var i,r;return A0(this,function(s){switch(s.label){case 0:if(i=this._importedXData,!i)return[2];r=t,s.label=1;case 1:return r<e?[4,{code:Number(i[r]),value:i[r+1]}]:[3,4];case 2:s.sent(),s.label=3;case 3:return r+=2,[3,1];case 4:return[2]}})},n.prototype.setImportedXData=function(t){var e,i,r,s,o,a,l,c=[],u,h;try{for(var d=Cn(t),f=d.next();!f.done;f=d.next()){var p=f.value,g=Number(p.code);if(g===ci.ExtendedDataRegAppName){u&&h&&c.push({appId:u,flat:h}),u=String(p.value),h=[g,p.value];continue}!u||!h||h.push(g,p.value)}}catch(C){e={error:C}}finally{try{f&&!f.done&&(i=d.return)&&i.call(d)}finally{if(e)throw e.error}}if(u&&h&&c.push({appId:u,flat:h}),c.length!==0)try{for(var y=Cn(c),m=y.next();!m.done;m=y.next()){var v=m.value;if(v.appId){this.removeImportedXData(v.appId),this.clearMaterializedXData(v.appId);var x=(l=this._importedXData)!==null&&l!==void 0?l:this._importedXData=[];try{for(var _=(o=void 0,Cn(v.flat)),b=_.next();!b.done;b=_.next()){var w=b.value;x.push(w)}}catch(C){o={error:C}}finally{try{b&&!b.done&&(a=_.return)&&a.call(_)}finally{if(o)throw o.error}}this.rememberXDataApp(v.appId),this.notifyXDataChanged(v.appId)}}}catch(C){r={error:C}}finally{try{m&&!m.done&&(s=y.return)&&s.call(y)}finally{if(r)throw r.error}}},n.prototype.getXData=function(t){var e,i,r,s,o=(r=this._xDataMap)===null||r===void 0?void 0:r.get(t);if(o)return o;var a=this.findImportedXDataRange(t);if(a){var l=new Nc;try{for(var c=Cn(this.importedXDataValues(a[0],a[1])),u=c.next();!u.done;u=c.next()){var h=u.value;l.add(h)}}catch(d){e={error:d}}finally{try{u&&!u.done&&(i=c.return)&&i.call(c)}finally{if(e)throw e.error}}return this.removeImportedXData(t),((s=this._xDataMap)!==null&&s!==void 0?s:this._xDataMap=new Map).set(t,l),l}},n.prototype.iterateXData=function(t){var e,i,r;return A0(this,function(s){switch(s.label){case 0:return e=(r=this._xDataMap)===null||r===void 0?void 0:r.get(t),e?[5,Cn(e)]:[3,2];case 1:return s.sent(),[2];case 2:return i=this.findImportedXDataRange(t),i?[5,Cn(this.importedXDataValues(i[0],i[1]))]:[2];case 3:return s.sent(),[2]}})},n.prototype.setXData=function(t){var e,i,r;try{for(var s=Cn(t),o=s.next();!o.done;o=s.next()){var a=o.value;if(a.code===ci.ExtendedDataRegAppName){var l=a.value;this.removeImportedXData(l),((r=this._xDataMap)!==null&&r!==void 0?r:this._xDataMap=new Map).set(l,t),this.rememberXDataApp(l),this.notifyXDataChanged(l)}}}catch(c){e={error:c}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(e)throw e.error}}},n.prototype.removeXData=function(t){this.removeImportedXData(t),this.clearMaterializedXData(t),this.forgetXDataApp(t),this.notifyXDataChanged(t)},n.prototype.createExtensionDictionary=function(){var t=this.extensionDictionary;if(t)return t;var e=this.database;if(e)return e.createExtensionDictionaryFor(this)},n.prototype.close=function(){},n.prototype.getOwnSnapshotKeys=function(){return Reflect.ownKeys(this).filter(function(t){return typeof t=="string"&&!n.SNAPSHOT_EXCLUDED_KEYS.has(t)})},n.prototype.cloneAttrs=function(t){var e=this.cloneValue(t.attributes);return new Vy(e)},n.prototype.restoreAttrsFrom=function(t){var e,i,r=this.cloneValue(t.attributes),s=this._attrs.attributes;try{for(var o=Cn(Object.keys(s)),a=o.next();!a.done;a=o.next()){var l=a.value;l in r||this._attrs.set(l,void 0,{unset:!0,silent:!0})}}catch(c){e={error:c}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(e)throw e.error}}this._attrs.set(r,{silent:!0})},n.prototype.restoreXDataMapFrom=function(t){var e,i;if(!t||t.size===0){this._xDataMap=void 0;return}var r=new Map;try{for(var s=Cn(t.entries()),o=s.next();!o.done;o=s.next()){var a=tf(o.value,2),l=a[0],c=a[1];r.set(l,this.cloneValue(c))}}catch(u){e={error:u}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(e)throw e.error}}this._xDataMap=r},n.prototype.copySnapshotStateTo=function(t){var e,i;t._attrs=this.cloneAttrs(this._attrs),t._xDataMap=this._xDataMap?this.cloneValue(this._xDataMap):void 0;var r=this,s=t;try{for(var o=Cn(this.getOwnSnapshotKeys()),a=o.next();!a.done;a=o.next()){var l=a.value;n.SNAPSHOT_INTERNAL_KEYS.has(l)||(s[l]=this.cloneValue(r[l]))}}catch(c){e={error:c}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(e)throw e.error}}},n.prototype.clone=function(){var t=Object.create(Object.getPrototypeOf(this));return this.copySnapshotStateTo(t),t.objectId=this.generateTemporaryHandle(),t},n.prototype.clonePreservingIdentity=function(){var t=this.clone(),e=this.getAttrWithoutException("objectId");e&&t._attrs.set("objectId",e);var i=this.getAttrWithoutException("ownerId");return i!==void 0&&t._attrs.set("ownerId",i),this._database&&(t._database=this._database),t},n.prototype.restoreFrom=function(t){var e,i,r,s,o=this.objectId,a=this._database;this.restoreAttrsFrom(t._attrs),this.restoreXDataMapFrom(t._xDataMap);var l=t,c=this,u=new Set(t.getOwnSnapshotKeys());try{for(var h=Cn(u),d=h.next();!d.done;d=h.next()){var f=d.value;n.SNAPSHOT_INTERNAL_KEYS.has(f)||n.SNAPSHOT_EXCLUDED_KEYS.has(f)||(c[f]=this.cloneValue(l[f]))}}catch(y){e={error:y}}finally{try{d&&!d.done&&(i=h.return)&&i.call(h)}finally{if(e)throw e.error}}try{for(var p=Cn(this.getOwnSnapshotKeys()),g=p.next();!g.done;g=p.next()){var f=g.value;n.SNAPSHOT_INTERNAL_KEYS.has(f)||n.SNAPSHOT_EXCLUDED_KEYS.has(f)||u.has(f)||delete c[f]}}catch(y){r={error:y}}finally{try{g&&!g.done&&(s=p.return)&&s.call(p)}finally{if(r)throw r.error}}this.objectId=o,a&&(this.database=a)},n.prototype.cloneValue=function(t){var e,i,r,s,o,a,l=this;if(t==null||typeof t!="object")return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp)return new RegExp(t.source,t.flags);if(Array.isArray(t))return t.map(function(C){return l.cloneValue(C)});if(t instanceof Map){var c=new Map;try{for(var u=Cn(t.entries()),h=u.next();!h.done;h=u.next()){var d=tf(h.value,2),f=d[0],p=d[1];c.set(this.cloneValue(f),this.cloneValue(p))}}catch(C){e={error:C}}finally{try{h&&!h.done&&(i=u.return)&&i.call(u)}finally{if(e)throw e.error}}return c}if(t instanceof Set){var g=new Set;try{for(var y=Cn(t.values()),m=y.next();!m.done;m=y.next()){var p=m.value;g.add(this.cloneValue(p))}}catch(C){r={error:C}}finally{try{m&&!m.done&&(s=y.return)&&s.call(y)}finally{if(r)throw r.error}}return g}if(ArrayBuffer.isView(t)){if(t instanceof DataView)return new DataView(t.buffer.slice(0));var v=t.constructor;return new v(t)}if(t instanceof ArrayBuffer)return t.slice(0);if(typeof Blob<"u"&&t instanceof Blob||t&&typeof t=="object"&&"tables"in t&&"transactionManager"in t)return t;if("clone"in t&&typeof t.clone=="function")return t.clone();var x=Object.create(Object.getPrototypeOf(t)),_=t;try{for(var b=Cn(Object.keys(_)),w=b.next();!w.done;w=b.next()){var f=w.value;x[f]=this.cloneValue(_[f])}}catch(C){o={error:C}}finally{try{w&&!w.done&&(a=b.return)&&a.call(b)}finally{if(o)throw o.error}}return x},n.prototype.dxfOut=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i=tf(t,2),r=i[0],s=i[1],o=s===void 0?!1:s;return r.writeHandle(5,this.objectId),r.writeObjectId(330,this.ownerId),r.writeObjectId(360,this.extensionDictionary),this.dxfOutFields(r),o&&this.dxfOutXData(r),this},n.prototype.dxfOutXData=function(t){var e,i,r,s,o,a=this._xDataOrder;if(a){try{for(var l=Cn(a),c=l.next();!c.done;c=l.next()){var u=c.value,h=(o=this._xDataMap)===null||o===void 0?void 0:o.get(u);if(h){t.writeResultBuffer(h);continue}var d=this.findImportedXDataRange(u);d&&t.writeTypedValues(this.importedXDataValues(d[0],d[1]))}}catch(_){e={error:_}}finally{try{c&&!c.done&&(i=l.return)&&i.call(l)}finally{if(e)throw e.error}}return}var f=this._importedXData;if(f)for(var p=0;p<f.length;){for(var g=p+2;g<f.length&&Number(f[g])!==ci.ExtendedDataRegAppName;)g+=2;t.writeTypedValues(this.importedXDataValues(p,g)),p=g}var y=this._xDataMap;if(y)try{for(var m=Cn(y.values()),v=m.next();!v.done;v=m.next()){var x=v.value;t.writeResultBuffer(x)}}catch(_){r={error:_}}finally{try{v&&!v.done&&(s=m.return)&&s.call(m)}finally{if(r)throw r.error}}},n.prototype.dxfOutFields=function(t){return this},n.prototype.dxfIn=function(t){for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){var e=t.readItem();if(!e)break;var i=Number(e.code);if(i===5||i===105)this.objectId=String(e.value);else if(i===330)this.ownerId=String(e.value);else if(i===360)this.extensionDictionary=String(e.value);else if(i===102)this.dxfInControlString(t,String(e.value));else if(i===100){t.pushBackItem(e);break}else{t.pushBackItem(e);break}}return this.dxfInFields(t),t.atExtendedData&&this.dxfInXData(t),this},n.prototype.dxfInControlString=function(t,e){for(var i=e==="{ACAD_XDICTIONARY"||e==="ACAD_XDICTIONARY";!t.atEndOfObject&&!t.atEof;){var r=t.readItem();if(!r)break;var s=Number(r.code);if(s===102){var o=String(r.value);if(o==="}"||o==="")break;this.dxfInControlString(t,o);continue}i&&s===360&&!this.extensionDictionary&&(this.extensionDictionary=String(r.value))}},n.prototype.dxfInFields=function(t){return this},n.prototype.dxfInXData=function(t){for(var e=this,i,r=function(){i&&i.length>0&&e.setXData(i),i=void 0};!t.atEndOfObject&&!t.atEof;){var s=t.readItem();if(!s)break;var o=Number(s.code);if(o===1001)r(),i=new Nc([{code:s.code,value:s.value}]);else if(o>=1e3&&o<=1071)i||(i=new Nc),i.add({code:s.code,value:s.value});else{t.pushBackItem(s);break}}r()},n.SNAPSHOT_EXCLUDED_KEYS=new Set(["_database","transactionManager"]),n.SNAPSHOT_INTERNAL_KEYS=new Set(["_attrs","_xDataMap"]),n})(),Eo;(function(n){n[n.ByBlock=-2]="ByBlock",n[n.ByDIPs=-4]="ByDIPs",n[n.ByLayer=-1]="ByLayer",n[n.ByLineWeightDefault=-3]="ByLineWeightDefault",n[n.LineWeight000=0]="LineWeight000",n[n.LineWeight005=5]="LineWeight005",n[n.LineWeight009=9]="LineWeight009",n[n.LineWeight013=13]="LineWeight013",n[n.LineWeight015=15]="LineWeight015",n[n.LineWeight018=18]="LineWeight018",n[n.LineWeight020=20]="LineWeight020",n[n.LineWeight025=25]="LineWeight025",n[n.LineWeight030=30]="LineWeight030",n[n.LineWeight035=35]="LineWeight035",n[n.LineWeight040=40]="LineWeight040",n[n.LineWeight050=50]="LineWeight050",n[n.LineWeight053=53]="LineWeight053",n[n.LineWeight060=60]="LineWeight060",n[n.LineWeight070=70]="LineWeight070",n[n.LineWeight080=80]="LineWeight080",n[n.LineWeight090=90]="LineWeight090",n[n.LineWeight100=100]="LineWeight100",n[n.LineWeight106=106]="LineWeight106",n[n.LineWeight120=120]="LineWeight120",n[n.LineWeight140=140]="LineWeight140",n[n.LineWeight158=158]="LineWeight158",n[n.LineWeight200=200]="LineWeight200",n[n.LineWeight211=211]="LineWeight211"})(Eo||(Eo={}));var Dc=(function(){function n(t){t===void 0&&(t={});var e,i,r,s;this.database=t.database,this.foregroundOnDark=(e=t.foregroundOnDark)!==null&&e!==void 0?e:nf,this.foregroundOnLight=(i=t.foregroundOnLight)!==null&&i!==void 0?i:rf,this.backgroundIsDark=(r=t.backgroundIsDark)!==null&&r!==void 0?r:!0,this.fallbackRgb=(s=t.fallbackRgb)!==null&&s!==void 0?s:16777215}return n.prototype.resolveSubEntityTraitsRgb=function(t){var e,i,r,s=t.color;return s.isForeground?this.backgroundIsDark?this.foregroundOnDark:this.foregroundOnLight:s.isByLayer||s.isByBlock?(e=this.fallbackRgb)!==null&&e!==void 0?e:16777215:(r=(i=s.RGB)!==null&&i!==void 0?i:this.fallbackRgb)!==null&&r!==void 0?r:16777215},n.fromBackgroundColor=function(t,e){return t===void 0&&(t=xA),new n({database:e,foregroundOnDark:nf,foregroundOnLight:rf,backgroundIsDark:!SA(t),fallbackRgb:16777215})},n})(),xA=0,nf=16777215,rf=0,Uc=16777215,bA=128;new Dc({database:void 0,foregroundOnDark:nf,foregroundOnLight:rf,backgroundIsDark:!0,fallbackRgb:16777215});function SA(n){var t=n>>16&255,e=n>>8&255,i=n&255;return .299*t+.587*e+.114*i>bA}function zc(n){var t=Dc.fromBackgroundColor(n);return t.backgroundIsDark?t.foregroundOnDark:t.foregroundOnLight}var C0="Continuous",nl="ByLayer",T0="ByBlock",Ds;(function(n){n[n.OnBothOperands=0]="OnBothOperands",n[n.ExtendThis=1]="ExtendThis",n[n.ExtendArg=2]="ExtendArg",n[n.ExtendBoth=3]="ExtendBoth"})(Ds||(Ds={}));var wA=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),sf=function(){return sf=Object.assign||function(n){for(var t,e=1,i=arguments.length;e<i;e++){t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},sf.apply(this,arguments)},MA=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},EA=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))},AA=(function(n){wA(t,n);function t(){var e=n.apply(this,EA([],MA(arguments),!1))||this;return e._colorIsByLayerDefault=!1,e._visibility=!0,e._transparencySet=!1,e._dxfPaperSpace=!1,e}return Object.defineProperty(t.prototype,"type",{get:function(){return this.constructor.typeName},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"layer",{get:function(){var e;return this._layer==null&&(this._layer=(e=this.database.clayer)!==null&&e!==void 0?e:"0"),this._layer},set:function(e){this._layer=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"color",{get:function(){return this.getEntityColor()},set:function(e){this.setEntityColor(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"resolvedColor",{get:function(){return this.resolveStandardColor()},enumerable:!1,configurable:!0}),t.prototype.resolveStandardColor=function(){var e=this.color;if(e.isByLayer){var i=this.getLayerColor();i&&i.RGB!=null&&(e=i)}else e.isByBlock&&(e=new rn().setForeground());return e},Object.defineProperty(t.prototype,"lineType",{get:function(){var e,i;return this._lineType==null&&(this._lineType=(i=(e=this.database)===null||e===void 0?void 0:e.celtype)!==null&&i!==void 0?i:nl),this._lineType},set:function(e){e?e.toUpperCase()==="BYLAYER"?this._lineType=nl:e.toUpperCase()==="BYBLOCK"?this._lineType=T0:this._lineType=e:this._lineType=nl},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lineWeight",{get:function(){var e;return this._lineWeight==null&&(this._lineWeight=(e=this.database.celweight)!==null&&e!==void 0?e:Eo.ByLayer),this._lineWeight},set:function(e){this._lineWeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"linetypeScale",{get:function(){var e;return this._linetypeScale==null&&(this._linetypeScale=(e=this.database.celtscale)!==null&&e!==void 0?e:-1),this._linetypeScale},set:function(e){this._linetypeScale=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"visibility",{get:function(){return this._visibility},set:function(e){this._visibility=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"transparency",{get:function(){var e;return(e=this._transparency)!==null&&e!==void 0?e:this._transparency=new _c},set:function(e){this._transparency=e.clone(),this._transparencySet=!0},enumerable:!1,configurable:!0}),t.prototype.hasExplicitLayer=function(){return this._layer!=null},t.prototype.hasExplicitColor=function(){return this._color!=null||this._colorIsByLayerDefault},t.prototype.getEntityColor=function(){return this._color==null&&(this._colorIsByLayerDefault?this._color=new rn().setByLayer():(this._color=new rn,this.database.cecolor&&this._color.copy(this.database.cecolor))),this._color},t.prototype.setEntityColor=function(e){this._colorIsByLayerDefault=!1,this._color==null&&(this._color=new rn),this._color.copy(e)},t.prototype.shouldResolveColorFromCecolor=function(){return!this._colorIsByLayerDefault},t.prototype.applyDxfFileDefaults=function(){this._color==null&&(this._colorIsByLayerDefault=!0)},t.prototype.hasExplicitTransparency=function(){return this._transparencySet},t.prototype.dxfOutFields=function(e){e.writeSubclassMarker("AcDbEntity"),e.writeString(8,this.layer),e.writeString(6,this.lineType),e.writeDouble(48,this.linetypeScale),e.writeInt16(60,this.visibility?0:1),e.writeCmColor(this.color),e.writeLineWeight(370,this.lineWeight),e.writeTransparency(this.transparency);var i=this.database.tables.blockTable.getIdAt(this.ownerId);return i!=null&&i.isPaperSapce&&e.writeInt16(67,1),this},t.prototype.dxfInFields=function(e){n.prototype.dxfInFields.call(this,e);var i=e.atSubclassData("AcDbEntity");if(!i){var r=e.peekItem();if(r&&Number(r.code)===100)return this}for(var s;!e.atEndOfObject&&!e.atEof&&!e.atExtendedData;){var o=e.readItem();if(!o)break;var a=Number(o.code);if(a===100){e.pushBackItem(o);break}switch(a){case 8:this.layer=String(o.value);break;case 6:this.lineType=String(o.value);break;case 48:this.linetypeScale=Number(o.value);break;case 60:this.visibility=Number(o.value)===0;break;case 62:s==null&&(s=new rn),s.colorIndex=Number(o.value);break;case 420:s==null&&(s=new rn),s.setRGBValue(Number(o.value));break;case 370:this.lineWeight=Number(o.value);break;case 440:this.transparency=_c.deserialize(Number(o.value));break;case 67:this._dxfPaperSpace=Number(o.value)!==0;break;case 410:break;case 92:case 160:case 310:break;case 284:case 347:case 380:case 390:case 430:break;default:if(!i)return e.pushBackItem(o),s!=null&&(this.color=s),this.applyDxfFileDefaults(),this;break}}return s!=null&&(this.color=s),this.applyDxfFileDefaults(),this},Object.defineProperty(t.prototype,"dxfPaperSpace",{get:function(){return this._dxfPaperSpace},enumerable:!1,configurable:!0}),t.prototype.resolveEffectiveProperties=function(){var e,i,r,s;this._layer==null&&(this._layer=(e=this.database.clayer)!==null&&e!==void 0?e:"0"),this._color==null&&this.shouldResolveColorFromCecolor()&&(this._color=new rn,this.database.cecolor&&this._color.copy(this.database.cecolor)),this._lineType==null&&(this._lineType=(i=this.database.celtype)!==null&&i!==void 0?i:nl),this._linetypeScale==null&&(this._linetypeScale=(r=this.database.celtscale)!==null&&r!==void 0?r:-1),this._lineWeight==null&&(this._lineWeight=(s=this.database.celweight)!==null&&s!==void 0?s:Eo.ByLayer)},Object.defineProperty(t.prototype,"properties",{get:function(){return{type:this.type,groups:[this.getGeneralProperties()]}},enumerable:!1,configurable:!0}),t.prototype.subGetGripPoints=function(){var e=new Array;return e},t.prototype.subMoveGripPointsAt=function(e,i){return this},t.prototype.subGetOsnapPoints=function(e,i,r,s,o,a){},t.prototype.intersectWith=function(e,i,r){i===void 0&&(i=Ds.OnBothOperands);var s=this.subGetIntersectCurves(),o=e.subGetIntersectCurves();if(s.length===0||o.length===0)return[];var a=i===Ds.ExtendThis||i===Ds.ExtendBoth,l=i===Ds.ExtendArg||i===Ds.ExtendBoth;return eA(s,o,a,l,r)},t.prototype.subGetIntersectCurves=function(){return[]},t.prototype.transformBy=function(e){return this},t.prototype.erase=function(){return this.database.tables.blockTable.removeEntity(this.objectId)},Object.defineProperty(t.prototype,"directBatchPrimitive",{get:function(){return null},enumerable:!1,configurable:!0}),t.prototype.worldDraw=function(e,i){if(this.database.isLayerDrawable(this.layer)){var r=e.subEntityTraits;r.isColorByLayer=this.color.isByLayer,r.color=this.resolvedColor,r.lineType=this.lineStyle,r.lineTypeScale=this.linetypeScale,r.lineWeight=this.lineWeight,r.transparency=this.transparency,r.layer=this.layer,r.drawOrder=0,r.isBackgroundFill=!1,"thickness"in this&&(r.thickness=this.thickness),e.context.database=this.database;var s=this.subWorldDraw(e,i);return this.attachEntityInfo(s),s}},t.prototype.applyTraitsColor=function(e,i,r){r===void 0&&(r=i.isByLayer);var s=e.color,o=e.isColorByLayer;return e.color=i,e.isColorByLayer=r,function(){e.color=s,e.isColorByLayer=o}},t.prototype.getGeneralProperties=function(){var e=this;return{groupName:"general",properties:[{name:"handle",type:"int",editable:!1,accessor:{get:function(){return e.objectId}}},{name:"color",type:"color",editable:!0,accessor:{get:function(){return e.color},set:function(i){e.color=i}}},{name:"layer",type:"string",editable:!0,accessor:{get:function(){return e.layer},set:function(i){e.layer=i}}},{name:"linetype",type:"linetype",editable:!0,accessor:{get:function(){return e.lineType},set:function(i){e.lineType=i}}},{name:"linetypeScale",type:"float",editable:!0,accessor:{get:function(){return e.linetypeScale},set:function(i){e.linetypeScale=i}}},{name:"lineWeight",type:"lineweight",editable:!0,accessor:{get:function(){return e.lineWeight},set:function(i){e.lineWeight=i}}},{name:"transparency",type:"transparency",editable:!0,accessor:{get:function(){return e.transparency},set:function(i){e.transparency=i}}}]}},Object.defineProperty(t.prototype,"lineStyle",{get:function(){var e,i=this.getLineType(),r=i.type,s=i.name,o=(e=this.database)===null||e===void 0?void 0:e.tables.linetypeTable.getAt(s);return o?sf({type:r},o.linetype):{type:r,name:s,standardFlag:0,description:"",totalPatternLength:0}},enumerable:!1,configurable:!0}),t.prototype.getLineType=function(){if(this.lineType==nl){var e=this.database.tables.layerTable.getAt(this.layer);if(e&&e.linetype)return{type:"ByLayer",name:e.linetype}}else return this.lineType==T0?{type:"ByBlock",name:C0}:{type:"UserSpecified",name:this.lineType};return{type:"UserSpecified",name:C0}},t.prototype.getLayerColor=function(){var e=this.database.tables.layerTable.getAt(this.layer);if(e==null)console.error("The layer with name '".concat(this.layer,"' not found in drawing database!"));else return e.color;return null},t.prototype.attachEntityInfo=function(e){e&&(e.objectId=this.objectId,this.attrs.has("ownerId")&&(e.ownerId=this.ownerId),e.layerName=this.layer,e.visible=this.visibility)},t.typeName="Entity",t})(el),CA=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),TA=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},LA=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))},IA=(function(n){CA(t,n);function t(){var e=n.apply(this,LA([],TA(arguments),!1))||this;return e._classVersion=4,e._isDefault=!1,e}return Object.defineProperty(t.prototype,"classVersion",{get:function(){return this._classVersion},set:function(e){this._classVersion=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isDefault",{get:function(){return this._isDefault},set:function(e){this._isDefault=e},enumerable:!1,configurable:!0}),t.prototype.dxfOutFields=function(e){return n.prototype.dxfOutFields.call(this,e),e.writeSubclassMarker("AcDbObjectContextData"),e.writeInt16(70,this._classVersion),e.writeBoolean(290,this._isDefault),this},t.prototype.dxfInObjectContextData=function(e){for(e.atSubclassData("AcDbObjectContextData");!e.atEndOfObject&&!e.atEof&&!e.atExtendedData;){var i=e.readItem();if(!i)break;var r=Number(i.code);if(r===100)return String(i.value);switch(r){case 70:this._classVersion=Number(i.value);break;case 290:this._isDefault=!!Number(i.value);break}}},t})(el),PA=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),RA=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},kA=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))},OA=(function(n){PA(t,n);function t(){var e=n.apply(this,kA([],RA(arguments),!1))||this;return e._scaleId="",e}return Object.defineProperty(t.prototype,"scaleId",{get:function(){return this._scaleId},set:function(e){this._scaleId=e},enumerable:!1,configurable:!0}),t.prototype.dxfOutFields=function(e){return n.prototype.dxfOutFields.call(this,e),e.writeSubclassMarker("AcDbAnnotScaleObjectContextData"),e.writeObjectId(340,this._scaleId),this},t})(IA),BA=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},NA=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))},L0=(function(){function n(t){this.i=0,t instanceof Map?(this._records=t,this._array=null,this._keys=Array.from(t.keys())):(this._records=null,this._array=t,this._keys=[])}return Object.defineProperty(n.prototype,"count",{get:function(){var t,e;return(e=(t=this._records)===null||t===void 0?void 0:t.size)!==null&&e!==void 0?e:this._array.length},enumerable:!1,configurable:!0}),n.prototype.toArray=function(){return this._records?Array.from(this._records.values()):NA([],BA(this._array),!1)},n.prototype[Symbol.iterator]=function(){return this},n.prototype.next=function(){if(this._array){if(this.i<this._array.length){var t=this._array[this.i];return this.i+=1,{value:t,done:!1}}return{value:null,done:!0}}for(;this.i<this._keys.length;){var t=this._records.get(this._keys[this.i]);return this.i+=1,{value:t,done:!1}}return{value:null,done:!0}},n})(),DA=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),UA=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},zA=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},Ao=(function(n){DA(t,n);function t(e){var i=n.call(this)||this;return i.database=e,i.objectId=e.generateHandle(),i._recordsByName=new Map,i}return Object.defineProperty(t.prototype,"numEntries",{get:function(){return this._recordsByName.size},enumerable:!1,configurable:!0}),t.prototype.setAt=function(e,i){var r=this,s=this.database.transactionManager;if(s.strictMode&&!s.isRecording()&&!s.isApplyingUndoRedo())throw new Error("Cannot modify dictionary entries outside an active transaction.");var o=this.getAt(e);o&&(s.isRecording()&&s.recordRemove({type:"dictionary",dictionaryId:this.objectId,key:e},o),this.database.releaseObjectHandle(o)),i.database=this.database,this.database.commitObjectHandle(i,function(a){return r.hasId(a)}),i.ownerId=this.objectId,this._recordsByName.set(e,i),s.isRecording()&&s.recordAppend({type:"dictionary",dictionaryId:this.objectId,key:e},i),!s.isRecording()&&!s.isApplyingUndoRedo()&&this.database.notifyDictObjectSet(i,e)},t.prototype.remove=function(e){var i=this.getAt(e);return i?(this.removeStoredObject(i,e),!0):!1},t.prototype.removeId=function(e){var i=this.getIdAt(e);if(i){var r="";return this._recordsByName.forEach(function(s,o){s===i&&(r=o)}),this.removeStoredObject(i,r),!0}return!1},t.prototype.removeStoredObject=function(e,i){var r=this,s=this.database.transactionManager;if(s.strictMode&&!s.isRecording()&&!s.isApplyingUndoRedo())throw new Error("Cannot remove dictionary entries outside an active transaction.");s.isRecording()&&s.recordRemove({type:"dictionary",dictionaryId:this.objectId,key:i},e),this._recordsByName.forEach(function(o,a){o===e&&r._recordsByName.delete(a)}),this.database.releaseObjectHandle(e),i&&!s.isRecording()&&!s.isApplyingUndoRedo()&&this.database.notifyDictObjectErased(e,i)},t.prototype.removeAll=function(){var e=this;this._recordsByName.forEach(function(i,r){e.database.releaseObjectHandle(i),e.database.events.dictObjectErased.dispatch({database:e.database,object:i,key:r})}),this._recordsByName.clear()},t.prototype.has=function(e){return this._recordsByName.has(e.toUpperCase())},t.prototype.hasId=function(e){return this.getIdAt(e)!==void 0},t.prototype.getAt=function(e){return this._recordsByName.get(e)},t.prototype.getIdAt=function(e){var i=this.database.getObjectById(e);if(i){var r=i.getAttrWithoutException("ownerId");if(r===this.objectId)return i}},t.prototype.newIterator=function(){return new L0(this._recordsByName)},t.prototype.entries=function(){return this._recordsByName.entries()},t.prototype.dxfOutFields=function(e){var i,r;n.prototype.dxfOutFields.call(this,e),e.writeSubclassMarker("AcDbDictionary"),e.writeInt16(280,1),e.writeInt16(281,1);try{for(var s=UA(this._recordsByName),o=s.next();!o.done;o=s.next()){var a=zA(o.value,2),l=a[0],c=a[1];e.writeString(3,l),e.writeObjectId(350,c.objectId)}}catch(u){i={error:u}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}return this},t.prototype.dxfInFields=function(e){for(n.prototype.dxfInFields.call(this,e),e.atSubclassData("AcDbDictionary");!e.atEndOfObject&&!e.atEof&&!e.atExtendedData;){var i=e.readItem();if(!i)break;var r=Number(i.code);if(r===100){e.pushBackItem(i);break}}return this},t})(el),FA=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),HA=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},GA=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))},I0=(function(n){FA(t,n);function t(){var e=n.apply(this,GA([],HA(arguments),!1))||this;return e._classVersion=0,e._scaleName="",e._paperUnits=1,e._drawingUnits=1,e._isUnitScale=!1,e}return Object.defineProperty(t.prototype,"classVersion",{get:function(){return this._classVersion},set:function(e){this._classVersion=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaleName",{get:function(){return this._scaleName},set:function(e){this._scaleName=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"paperUnits",{get:function(){return this._paperUnits},set:function(e){this._paperUnits=e>0?e:1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"drawingUnits",{get:function(){return this._drawingUnits},set:function(e){this._drawingUnits=e>0?e:1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isUnitScale",{get:function(){return this._isUnitScale},set:function(e){this._isUnitScale=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaleFactor",{get:function(){return this._drawingUnits/this._paperUnits},enumerable:!1,configurable:!0}),t.prototype.dxfOutFields=function(e){return n.prototype.dxfOutFields.call(this,e),e.writeSubclassMarker("AcDbScale"),e.writeInt16(70,this._classVersion),e.writeString(300,this._scaleName),e.writeDouble(140,this._paperUnits),e.writeDouble(141,this._drawingUnits),e.writeBoolean(290,this._isUnitScale),this},t.prototype.dxfInFields=function(e){for(n.prototype.dxfInFields.call(this,e),e.atSubclassData("AcDbScale");!e.atEndOfObject&&!e.atEof&&!e.atExtendedData;){var i=e.readItem();if(!i)break;var r=Number(i.code);if(r===100){e.pushBackItem(i);break}switch(r){case 70:this._classVersion=Number(i.value);break;case 300:this._scaleName=String(i.value);break;case 140:this.paperUnits=Number(i.value);break;case 141:this.drawingUnits=Number(i.value);break;case 290:this._isUnitScale=!!Number(i.value);break}}return this},t})(el),il=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Co=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},P0=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))},rl=function(n){return n?n.trim().toUpperCase():""},of="AcadAnnotative";function R0(n){var t,e,i=n.getXData(of);if(!i)return!1;var r=i.toArray();try{for(var s=il(r),o=s.next();!o.done;o=s.next()){var a=o.value;if(Number(a.code)===1070&&Number(a.value)===1)return!0}}catch(l){t={error:l}}finally{try{o&&!o.done&&(e=s.return)&&e.call(s)}finally{if(t)throw t.error}}return!1}function VA(n){return R0(n)||jA(n).length>0}function WA(n,t){if(!t){n.removeXData(of),KA(n);return}if(!R0(n)){var e=new Nc([{code:ci.ExtendedDataRegAppName,value:of},{code:ci.ExtendedDataAsciiString,value:"AnnotativeData"},{code:ci.ExtendedDataControlString,value:"{"},{code:ci.ExtendedDataInteger16,value:1},{code:ci.ExtendedDataInteger16,value:1},{code:ci.ExtendedDataControlString,value:"}"}]);n.setXData(e)}}function XA(n,t){var e,i;if(t){var r=rl(t),s=n.getObjectById(r);if(s instanceof I0)return s;var o=n.objects.scale,a=o.getAt(t);if(a instanceof I0)return a;try{for(var l=il(o.entries()),c=l.next();!c.done;c=l.next()){var u=Co(c.value,2),h=u[1];if(h.scaleName===t)return h}}catch(d){e={error:d}}finally{try{c&&!c.done&&(i=l.return)&&i.call(l)}finally{if(e)throw e.error}}}}function jA(n){var t,e,i=n.extensionDictionary;if(!i)return[];var r;try{r=n.database}catch{return[]}if(!r)return[];var s=r.getObjectById(rl(i));if(!(s instanceof Ao))return[];var o=s.getAt("AcDbContextDataManager");if(!(o instanceof Ao))return[];var a=o.getAt("ACDB_ANNOTATIONSCALES");if(!(a instanceof Ao))return[];var l=[];try{for(var c=il(a.entries()),u=c.next();!u.done;u=c.next()){var h=Co(u.value,2),d=h[1],f=void 0,p=void 0,g=!1;d instanceof OA?(f=d,p=d.scaleId,g=d.isDefault):p=d.objectId;var y=p?XA(r,p):void 0;y&&l.push({scale:y,contextData:f,isDefault:g})}}catch(m){t={error:m}}finally{try{u&&!u.done&&(e=c.return)&&e.call(c)}finally{if(t)throw t.error}}return l}function $A(n){try{return n.database}catch{return}}function YA(n,t){var e=t.extensionDictionary;if(e){var i=n.getObjectById(rl(e));if(i instanceof Ao){var r=i.getAt("AcDbContextDataManager");if(r instanceof Ao){var s=r.getAt("ACDB_ANNOTATIONSCALES");return s instanceof Ao?s:void 0}}}}function qA(n,t){var e,i,r=rl(t.objectId);if(r){if(n.objects.objectContextData.getIdAt(r)){n.objects.objectContextData.removeId(r);return}try{for(var s=il(P0([],Co(n.objects.objectContextData.entries()),!1)),o=s.next();!o.done;o=s.next()){var a=Co(o.value,2),l=a[0],c=a[1];(c===t||rl(c.objectId)===r)&&n.objects.objectContextData.remove(l)}}catch(u){e={error:u}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(e)throw e.error}}}}function KA(n){var t,e,i=$A(n);if(i){var r=YA(i,n);if(r)try{for(var s=il(P0([],Co(r.entries()),!1)),o=s.next();!o.done;o=s.next()){var a=Co(o.value,2),l=a[0],c=a[1];r.remove(l),qA(i,c)}}catch(u){t={error:u}}finally{try{o&&!o.done&&(e=s.return)&&e.call(s)}finally{if(t)throw t.error}}}}var ZA=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),k0=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Us=(function(n){ZA(t,n);function t(e){e===void 0&&(e="Unexpected end of buffer.");var i=n.call(this,e)||this;return i.name="AcDbProxyGraphicEndOfBufferError",i}return t})(Error);function O0(n){return n instanceof ArrayBuffer?new Uint8Array(n):n}(function(){function n(t,e){e===void 0&&(e=4),this._index=0,this._buffer=O0(t),this._align=e}return Object.defineProperty(n.prototype,"index",{get:function(){return this._index},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"hasData",{get:function(){return this._index<this._buffer.length},enumerable:!1,configurable:!0}),n.prototype.alignIndex=function(t){var e=t%this._align;return e?t+this._align-e:t},n.prototype.readStruct=function(t){var e,i;if(!this.hasData)throw new Us;var r=[],s=0;try{for(var o=k0(t),a=o.next();!a.done;a=o.next()){var l=a.value,c=new DataView(this._buffer.buffer,this._buffer.byteOffset+this._index+s,l);if(l===8)r.push(c.getFloat64(0,!0));else if(l===4)r.push(c.getUint32(0,!0));else throw new Error("Unsupported struct size: ".concat(l));s+=l}}catch(u){e={error:u}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(e)throw e.error}}return this._index=this.alignIndex(this._index+s),r},n.prototype.readFloat=function(){return this.readStruct([8])[0]},n.prototype.readLong=function(){return this.readStruct([4])[0]},n.prototype.readSignedLong=function(){if(!this.hasData)throw new Us;var t=new DataView(this._buffer.buffer,this._buffer.byteOffset+this._index,4),e=t.getInt32(0,!0);return this._index=this.alignIndex(this._index+4),e},n.prototype.readVertex=function(){return this.readStruct([8,8,8])},n.prototype.readPaddedString=function(t){t===void 0&&(t="utf-8");for(var e=this._buffer,i=this._index;i<e.length;i++)if(e[i]===0){var r=this._index;this._index=this.alignIndex(i+1);var s=e.subarray(r,i);return new TextDecoder(t).decode(s)}throw new Us("Did not detect terminating zero byte.")},n.prototype.readPaddedUnicodeString=function(){for(var t=this._buffer,e=this._index;e<t.length;e+=2)if(e+1<t.length&&t[e]===0&&t[e+1]===0){var i=this._index;this._index=this.alignIndex(e+2);var r=t.subarray(i,e);return new TextDecoder("utf-16le").decode(r)}throw new Us("Did not detect terminating zero bytes.")},n})(),(function(){function n(t,e,i){e===void 0&&(e="AC1015"),i===void 0&&(i="cp1252"),this._bitIndex=0,this._buffer=O0(t),this.dxfversion=e,this.encoding=i}return Object.defineProperty(n.prototype,"hasData",{get:function(){return this._bitIndex>>3<this._buffer.length},enumerable:!1,configurable:!0}),n.prototype.readBit=function(){var t=this._bitIndex;this._bitIndex+=1;var e=t>>3;if(e>=this._buffer.length)throw new Us;return this._buffer[e]&128>>(t&7)?1:0},n.prototype.readBits=function(t){var e=this._bitIndex,i=e+t;if(i-1>>3>=this._buffer.length)throw new Us;this._bitIndex=i;for(var r=128>>(e&7),s=e>>3,o=0,a=this._buffer[s];t>0;)o<<=1,a&r&&(o|=1),t-=1,r>>=1,!r&&t&&(r=128,s+=1,a=this._buffer[s]);return o},n.prototype.readUnsignedByte=function(){return this.readBits(8)},n.prototype.readSignedByte=function(){var t=this.readBits(8);return t&128?-((~t&255)+1):t},n.prototype.readAlignedBytes=function(t){var e=this._bitIndex>>3,i=e+t;if(i>this._buffer.length)throw new Us;return this._bitIndex+=t<<3,this._buffer.subarray(e,i)},n.prototype.readUnsignedShort=function(){if(this._bitIndex&7){var t=this.readBits(8),e=this.readBits(8);return(e<<8)+t}var i=this.readAlignedBytes(2);return i[1]<<8|i[0]},n.prototype.readSignedShort=function(){var t=this.readUnsignedShort();return t&32768?-((~t&65535)+1):t},n.prototype.readUnsignedLong=function(){if(this._bitIndex&7){var t=this.readBits(8),e=this.readBits(8),i=this.readBits(8),r=this.readBits(8);return(r<<24)+(i<<16)+(e<<8)+t}var s=this.readAlignedBytes(4);return(s[3]<<24)+(s[2]<<16)+(s[1]<<8)+s[0]},n.prototype.readSignedLong=function(){var t=this.readUnsignedLong();return t&2147483648?-((~t&4294967295)+1):t},n.prototype.readFloat=function(){if(this._bitIndex&7){for(var t=new Uint8Array(8),e=0;e<8;e++)t[e]=this.readBits(8);return new DataView(t.buffer).getFloat64(0,!0)}var i=this.readAlignedBytes(8),r=new Uint8Array(i);return new DataView(r.buffer).getFloat64(0,!0)},n.prototype.readRawDouble=function(t){var e=this;return t===void 0&&(t=1),t===1?this.readFloat():Array.from({length:t},function(){return e.readFloat()})},n.prototype.readBitShort=function(t){var e=this;t===void 0&&(t=1);var i=function(){var r=e.readBits(2);return r===0?e.readSignedShort():r===1?e.readUnsignedByte():r===2?0:256};return t===1?i():Array.from({length:t},function(){return i()})},n.prototype.readBitLong=function(t){var e=this;t===void 0&&(t=1);var i=function(){var r=e.readBits(2);return r===0?e.readSignedLong():r===1?e.readUnsignedByte():r===2?0:256};return t===1?i():Array.from({length:t},function(){return i()})},n.prototype.readBitDouble=function(t){var e=this;t===void 0&&(t=1);var i=function(){var r=e.readBits(2);return r===0?e.readFloat():r===1?1:0};return t===1?i():Array.from({length:t},function(){return i()})},n.prototype.readBitDoubleDefault=function(t,e){var i=this;t===void 0&&(t=1),e===void 0&&(e=0);var r=new Uint8Array(8);new DataView(r.buffer).setFloat64(0,e,!0);var s=function(){var o=i.readBits(2);if(o===0)return e;if(o===1){var a=new Uint8Array(r);return a[0]=i.readUnsignedByte(),a[1]=i.readUnsignedByte(),a[2]=i.readUnsignedByte(),a[3]=i.readUnsignedByte(),new DataView(a.buffer).getFloat64(0,!0)}if(o===2){var a=new Uint8Array(r);return a[4]=i.readUnsignedByte(),a[5]=i.readUnsignedByte(),a[0]=i.readUnsignedByte(),a[1]=i.readUnsignedByte(),a[2]=i.readUnsignedByte(),a[3]=i.readUnsignedByte(),new DataView(a.buffer).getFloat64(0,!0)}return i.readFloat()};return t===1?s():Array.from({length:t},function(){return s()})},n})();function JA(n){var t,e,i=n.reduce(function(u,h){return u+Math.floor(h.length/2)},0),r=new Uint8Array(i),s=0;try{for(var o=k0(n),a=o.next();!a.done;a=o.next())for(var l=a.value,c=0;c<l.length;c+=2)r[s++]=parseInt(l.slice(c,c+2),16)}catch(u){t={error:u}}finally{try{a&&!a.done&&(e=o.return)&&e.call(o)}finally{if(t)throw t.error}}return r}var QA=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),tC=(function(n){QA(t,n);function t(e,i){return e=e||{},Rd(e,{name:""}),n.call(this,e,i)||this}return Object.defineProperty(t.prototype,"name",{get:function(){return this.getAttr("name")},set:function(e){this.setAttr("name",e)},enumerable:!1,configurable:!0}),t.prototype.setAttr=function(e,i){this.assertOpenForWrite(),n.prototype.setAttr.call(this,e,i)},t.prototype.assertOpenForWrite=function(){if(!this.isTemp){var e=this.database;if(e){var i=e.transactionManager;if(!i.isApplyingUndoRedo()){if(i.strictMode&&!i.isRecording())throw new Error("Cannot modify symbol table records outside an active transaction.");if(i.isRecording()&&!i.isOpenedForWriteInTransaction(this.objectId))throw new Error('Symbol table record "'.concat(this.name||this.objectId,'" is not open for write. Use openObjectForWrite().'))}}}},t.prototype.dxfOutFields=function(e){return n.prototype.dxfOutFields.call(this,e),e.writeSubclassMarker("AcDbSymbolTableRecord"),this},t})(el),eC=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),af=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},lf;(function(n){n[n.Any=0]="Any",n[n.Uniform=1]="Uniform"})(lf||(lf={}));var kr;(function(n){n[n.None=0]="None",n[n.Anonymous=1]="Anonymous",n[n.HasNonConstantAttributes=2]="HasNonConstantAttributes",n[n.Xref=4]="Xref",n[n.XrefOverlay=8]="XrefOverlay",n[n.ExternallyDependent=16]="ExternallyDependent",n[n.Resolved=32]="Resolved",n[n.Referenced=64]="Referenced"})(kr||(kr={}));var B0=(function(n){eC(t,n);function t(e,i){var r=this;return e=e||{},Rd(e,{origin:new Be,layoutId:"",flags:kr.None,pathName:"",blockInsertUnits:0,explodability:1,blockScaling:lf.Uniform,previewIcon:void 0}),r=n.call(this,e,i)||this,r._entities=[],r}return t.isModelSapceName=function(e){return e.toLowerCase()==t.MODEL_SPACE_NAME.toLowerCase()},t.isPaperSapceName=function(e){return e.toLowerCase().startsWith(t.PAPER_SPACE_NAME_PREFIX.toLowerCase())},t.sanitizeImportedFlags=function(e){return e&~(kr.Resolved|kr.Referenced)},Object.defineProperty(t.prototype,"isModelSapce",{get:function(){return t.isModelSapceName(this.name)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isPaperSapce",{get:function(){return t.isPaperSapceName(this.name)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"origin",{get:function(){return this.getAttr("origin")},set:function(e){this.getAttr("origin").copy(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"layoutId",{get:function(){return this.getAttr("layoutId")},set:function(e){this.setAttr("layoutId",e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"flags",{get:function(){return this.getAttr("flags")},set:function(e){this.setAttr("flags",e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"annotative",{get:function(){return VA(this)},set:function(e){WA(this,e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pathName",{get:function(){return this.getAttr("pathName")},set:function(e){this.setAttr("pathName",e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isXref",{get:function(){return(this.flags&(kr.Xref|kr.XrefOverlay))!==0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isOverlayReference",{get:function(){return(this.flags&kr.XrefOverlay)!==0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isUnresolvedXref",{get:function(){return!this.isXref||(this.flags&kr.Resolved)!==0?!1:this._entities.length===0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blockInsertUnits",{get:function(){return this.getAttr("blockInsertUnits")},set:function(e){this.setAttr("blockInsertUnits",e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"explodability",{get:function(){return this.getAttr("explodability")},set:function(e){this.setAttr("explodability",e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blockScaling",{get:function(){return this.getAttr("blockScaling")},set:function(e){this.setAttr("blockScaling",e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"previewIcon",{get:function(){return this.getAttrWithoutException("previewIcon")},set:function(e){if(!e||e.length===0){this.setAttr("previewIcon",void 0);return}this.setAttr("previewIcon",e)},enumerable:!1,configurable:!0}),t.prototype.appendEntity=function(e){var i,r,s,o,a=this,l=this.database.transactionManager;if(l.strictMode&&!l.isRecording()&&!l.isApplyingUndoRedo())throw new Error("Cannot append entities outside an active transaction.");var c=function(y){y.database=a.database,a.database.ensureEntityStyleDefaults(y),a.database.commitObjectHandle(y,function(m){return a.hasEntityId(m)}),y.ownerId=a.objectId,y.resolveEffectiveProperties(),a._entities.push(y),y.dxfTypeName==="INSERT"&&"syncAttributeDatabases"in y&&typeof y.syncAttributeDatabases=="function"&&y.syncAttributeDatabases()},u=Array.isArray(e)?e:[e];try{for(var h=af(u),d=h.next();!d.done;d=h.next()){var f=d.value;c(f)}}catch(y){i={error:y}}finally{try{d&&!d.done&&(r=h.return)&&r.call(h)}finally{if(i)throw i.error}}if(l.isRecording())try{for(var p=af(u),g=p.next();!g.done;g=p.next()){var f=g.value;l.recordAppend({type:"blockTableRecord",ownerId:this.objectId},f)}}catch(y){s={error:y}}finally{try{g&&!g.done&&(o=p.return)&&o.call(p)}finally{if(s)throw s.error}}(this.isModelSapce||this.isPaperSapce)&&!l.isRecording()&&!l.isApplyingUndoRedo()&&this.database.notifyEntityAppended(e)},t.prototype.removeEntity=function(e){var i,r,s=this.database.transactionManager;if(s.strictMode&&!s.isRecording()&&!s.isApplyingUndoRedo())throw new Error("Cannot remove entities outside an active transaction.");var o=Array.isArray(e)?e:[e];if(o.length===0)return!1;var a=new Set(o),l=[],c=0;try{for(var u=af(this._entities),h=u.next();!h.done;h=u.next()){var d=h.value;a.has(d.objectId)?(s.isRecording()&&s.recordRemove({type:"blockTableRecord",ownerId:this.objectId},d),l.push(d),this.database.releaseObjectHandle(d)):this._entities[c++]=d}}catch(f){i={error:f}}finally{try{h&&!h.done&&(r=u.return)&&r.call(u)}finally{if(i)throw i.error}}return this._entities.length=c,l.length>0&&!s.isRecording()&&!s.isApplyingUndoRedo()&&this.database.notifyEntityErased(l),l.length>0},t.prototype.newIterator=function(){return new L0(this._entities)},t.prototype.getIdAt=function(e){var i=this.database.getObjectById(e);if(i instanceof AA){var r=i.getAttrWithoutException("ownerId");if(r===this.objectId)return i}},t.prototype.hasEntityId=function(e){return this.getIdAt(e)!==void 0},t.prototype.dxfOutBlockRecord=function(e){return e.writeStart("BLOCK_RECORD"),this.dxfOut(e),this},t.prototype.dxfOutBlockBegin=function(e){return e.writeStart("BLOCK"),e.writeHandle(5,this.database.generateHandle()),e.writeObjectId(330,this.objectId),e.writeSubclassMarker("AcDbEntity"),e.writeString(8,"0"),e.writeSubclassMarker("AcDbBlockBegin"),e.writeString(2,this.name),e.writeInt16(70,this.flags),e.writePoint3d(10,this.origin),e.writeString(3,this.name),this.pathName&&e.writeString(1,this.pathName),this},t.prototype.dxfOutBlockEnd=function(e){return e.writeStart("ENDBLK"),e.writeHandle(5,this.database.generateHandle()),e.writeObjectId(330,this.objectId),e.writeSubclassMarker("AcDbEntity"),e.writeSubclassMarker("AcDbBlockEnd"),this},t.prototype.dxfOutFields=function(e){return n.prototype.dxfOutFields.call(this,e),e.writeSubclassMarker("AcDbBlockTableRecord"),e.writeString(2,this.name),e.capabilities.supportsBlockRecordUnitsFlags&&(e.writeInt16(70,this.blockInsertUnits),e.writeInt16(280,this.explodability),e.writeInt16(281,this.blockScaling)),(this.isModelSapce||this.isPaperSapce)&&e.writeObjectId(340,this.layoutId),this},t.prototype.dxfInFields=function(e){n.prototype.dxfInFields.call(this,e),e.atSubclassData("AcDbSymbolTableRecord"),e.atSubclassData("AcDbBlockTableRecord");for(var i=[];!e.atEndOfObject&&!e.atEof&&!e.atExtendedData;){var r=e.readItem();if(!r)break;var s=Number(r.code);if(s===100){e.pushBackItem(r);break}switch(s){case 2:this.name=String(r.value);break;case 70:this.blockInsertUnits=Number(r.value);break;case 280:this.explodability=Number(r.value);break;case 281:this.blockScaling=Number(r.value);break;case 340:this.layoutId=String(r.value);break;case 310:{var o=String(r.value).replace(/\s+/g,"");o&&i.push(o);break}}}return i.length>0&&(this.previewIcon=JA(i)),this},t.MODEL_SPACE_NAME="*Model_Space",t.PAPER_SPACE_NAME_PREFIX="*Paper_Space",t})(tC),nC=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},as;(function(n){n[n.EndPoint=1]="EndPoint",n[n.MidPoint=2]="MidPoint",n[n.Center=3]="Center",n[n.Node=4]="Node",n[n.Quadrant=5]="Quadrant",n[n.Intersection=6]="Intersection",n[n.Insertion=7]="Insertion",n[n.Perpendicular=8]="Perpendicular",n[n.Tangent=9]="Tangent",n[n.Nearest=10]="Nearest",n[n.Centroid=11]="Centroid"})(as||(as={}));function iC(n){var t,e,i=0;try{for(var r=nC(n),s=r.next();!s.done;s=r.next()){var o=s.value;i|=1<<o-1}}catch(a){t={error:a}}finally{try{s&&!s.done&&(e=r.return)&&e.call(r)}finally{if(t)throw t.error}}return i}var rC=function(n,t,e,i){function r(s){return s instanceof e?s:new e(function(o){o(s)})}return new(e||(e=Promise))(function(s,o){function a(u){try{c(i.next(u))}catch(h){o(h)}}function l(u){try{c(i.throw(u))}catch(h){o(h)}}function c(u){u.done?s(u.value):r(u.value).then(a,l)}c((i=i.apply(n,t||[])).next())})},sC=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(c){return function(u){return l([c,u])}}function l(c){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(e=0)),e;)try{if(i=1,r&&(s=c[0]&2?r.return:c[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,c[1])).done)return s;switch(r=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return e.label++,{value:c[1],done:!1};case 5:e.label++,r=c[1],c=[0];continue;case 7:c=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){e=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){e.label=c[1];break}if(c[0]===6&&e.label<s[1]){e.label=s[1],s=c;break}if(s&&e.label<s[2]){e.label=s[2],e.ops.push(c);break}s[2]&&e.ops.pop(),e.trys.pop();continue}c=t.call(n,e)}catch(u){c=[6,u],r=0}finally{i=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},sl=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},oC=function(){return{hits:0,misses:0,hitMs:0,missBuildMs:0,missCompactMs:0,cloneMs:0,setCloneMs:0,applyMs:0}},N0=function(){return{hits:0,misses:0,hitMs:0,missBuildMs:0,missCompactMs:0,cloneMs:0,setCloneMs:0,applyMs:0,topLevel:oC(),blockMisses:[]}},aC=(function(){function n(){this._lruTotalBytes=0,this._retiredCompactedTemplates=[],this._blocks=new Map,this._lruBytes=new Map}return Object.defineProperty(n,"profileStats",{get:function(){return this._profileStats},enumerable:!1,configurable:!0}),n.resetProfile=function(){this._profileStats=N0(),this._drawDepth=0},Object.defineProperty(n,"instance",{get:function(){return this._instance||(this._instance=new n),this._instance},enumerable:!1,configurable:!0}),n.prototype.createKey=function(t,e){var i=e.toString();return!i&&e.isByColor&&(i="RGB:".concat(e.red,",").concat(e.green,",").concat(e.blue)),"".concat(t,"_").concat(i)},n.prototype.createCacheKey=function(t,e,i){return i?this.createKey(t,e):t},n.prototype.set=function(t,e){var i;if(this._blocks.set(t,e),n.lruEnabled){var r=(i=this._lruBytes.get(t))!==null&&i!==void 0?i:0,s=this.estimateTemplateBytes(e);this._lruBytes.set(t,s),this._lruTotalBytes+=s-r,this.enforceLruBudget()}return e},n.prototype.enforceLruBudget=function(){for(var t=n.lruMaxEntries;t>0&&this._blocks.size>t;)this.evictOldest();for(var e=n.lruMaxEstimatedBytes;e>0&&this._lruTotalBytes>e&&this._blocks.size>1;)this.evictOldest()},n.prototype.evictOldest=function(){var t,e,i=this._blocks.keys().next();if(!(i.done||i.value===void 0)){var r=i.value,s=this._blocks.get(r);this._blocks.delete(r),this._lruTotalBytes-=(t=this._lruBytes.get(r))!==null&&t!==void 0?t:0,this._lruBytes.delete(r),s&&(U0(s)?this._retiredCompactedTemplates.push(s):(e=s.dispose)===null||e===void 0||e.call(s))}},n.prototype.estimateTemplateBytes=function(t){for(var e,i,r=0,s=[t];s.length>0;){var o=s.pop();if(o!=null){if(o.geometry){var a=o.geometry.attributes;if(a)for(var l in a){var c=(e=a[l])===null||e===void 0?void 0:e.array;c&&(r+=c.byteLength)}var u=(i=o.geometry.index)===null||i===void 0?void 0:i.array;u&&(r+=u.byteLength)}var h=o.children;if(h)for(var d=0;d<h.length;d++)s.push(h[d])}}return r},n.prototype.peek=function(t){return this._blocks.get(t)},n.prototype.get=function(t){var e=this._blocks.get(t);if(e){if(n.lruEnabled&&(this._blocks.delete(t),this._blocks.set(t,e)),n.profiling){var i=performance.now(),r=this.maybeCompactTemplate(e,!0);if(r){var s=performance.now()-i;n._profileStats.missCompactMs+=s,n._drawDepth===1&&(n._profileStats.topLevel.missCompactMs+=s)}var o=performance.now(),a=e.fastDeepClone(),l=performance.now()-o;return n._profileStats.cloneMs+=l,n._drawDepth===1&&(n._profileStats.topLevel.cloneMs+=l),uf(a,t),a}this.maybeCompactTemplate(e,!0);var c=e.fastDeepClone();return uf(c,t),c}},n.prototype.has=function(t){return this._blocks.has(t)},n.prototype.clear=function(){var t;this._blocks.forEach(function(e){var i;(i=e.dispose)===null||i===void 0||i.call(e)}),this._blocks.clear(),this._lruBytes.clear(),this._lruTotalBytes=0,this._retiredCompactedTemplates.forEach(function(e){var i;(i=e.dispose)===null||i===void 0||i.call(e)}),this._retiredCompactedTemplates.length=0,(t=n.onCleared)===null||t===void 0||t.call(n)},n.prototype.prebuildAll=function(t,e,i){return rC(this,void 0,void 0,function(){var r,s,o,f,a,l,c,u,h,d,f,p,g,y,m,v,x;return sC(this,function(_){switch(_.label){case 0:r=[];try{for(s=sl(e),o=s.next();!o.done;o=s.next())f=o.value,!(!f||!f.name)&&(this.shouldSkipPrebuild(f)||r.push(f))}catch(b){y={error:b}}finally{try{o&&!o.done&&(m=s.return)&&m.call(s)}finally{if(y)throw y.error}}a=r.length,l=0,c=new rn().setForeground(),u=new B2,_.label=1;case 1:_.trys.push([1,8,9,10]),h=sl(r),d=h.next(),_.label=2;case 2:return d.done?[3,7]:(f=d.value,p=this.createCacheKey(f.name,c,!1),this.has(p)||this.draw(t,f,c,[],!0),l++,i?[4,i(l,a,f.name)]:[3,4]);case 3:_.sent(),_.label=4;case 4:return[4,u.maybeYield(Wy)];case 5:_.sent(),_.label=6;case 6:return d=h.next(),[3,2];case 7:return[3,10];case 8:return g=_.sent(),v={error:g},[3,10];case 9:try{d&&!d.done&&(x=h.return)&&x.call(h)}finally{if(v)throw v.error}return[7];case 10:return[2]}})})},n.prototype.draw=function(t,e,i,r,s,o,a){var l,c,u;r===void 0&&(r=[]),s===void 0&&(s=!0);var h=n.profiling;h&&n._drawDepth++;var d=h&&n._drawDepth===1,f=n._profileStats,p=[];try{if(e!=null){var g=(u=i.RGB)!==null&&u!==void 0?u:0,y=e.name,m=void 0;if(y&&this.has(y))m=y;else if(y){var v=this.createKey(y,i);this.has(v)&&(m=v)}var x;if(m!==void 0){var _=h?performance.now():0;if(x=this.get(m),h){var b=performance.now()-_;f.hits++,f.hitMs+=b,d&&(f.topLevel.hits++,f.topLevel.hitMs+=b)}}else{var w=h?performance.now():0,C=!1,E=e.newIterator();try{for(var T=sl(E),k=T.next();!k.done;k=T.next()){var O=k.value;if(O.visibility)if(O.color.isByBlock){C=!0;var U=pC(O.color);try{i.isForeground?O.color.setForeground():O.color.setRGBValue(g),this.addEntity(O,p,t)}finally{O.color.copy(U),mC(U)}}else this.addEntity(O,p,t)}}catch(ft){l={error:ft}}finally{try{k&&!k.done&&(c=T.return)&&c.call(T)}finally{if(l)throw l.error}}x=t.group(p);var z=0;h&&(z=performance.now()-w,f.missBuildMs+=z,d&&(f.topLevel.missBuildMs+=z));var L=0,N=!!s&&!!y&&!y.startsWith("*U");if(x&&N){var F=h?performance.now():0,G=this.maybeCompactTemplate(x,!1);h&&G&&(L=performance.now()-F,f.missCompactMs+=L,d&&(f.topLevel.missCompactMs+=L))}m=this.createCacheKey(y,i,C);var V=h?f.setCloneMs:0;if(x&&N){if(fC(x),this.set(m,x),h){var D=performance.now();x=x.fastDeepClone();var b=performance.now()-D;f.setCloneMs+=b,d&&(f.topLevel.setCloneMs+=b)}else x=x.fastDeepClone();uf(x,m)}h&&(f.misses++,d&&f.topLevel.misses++,f.blockMisses.push({blockName:y||"(unnamed)",buildMs:z,compactMs:L,setCloneMs:f.setCloneMs-V}))}var Y=h?performance.now():0;if(x&&o&&(Fc.copy(o),x.applyMatrix(Fc),a&&(a.x!=0||a.y!=0||a.z!=1)&&(cf.setFromExtrusionDirection(a),x.applyMatrix(cf),Fc.premultiply(cf))),x&&r&&r.length>0){var Z=o!=null?lC.copy(Fc).invert():void 0;r.forEach(function(ft){Z&&ft.applyMatrix(Z),x.addChild(ft)})}if(h){var b=performance.now()-Y;f.applyMs+=b,d&&(f.topLevel.applyMs+=b)}return x}else return t.group(p)}finally{h&&n._drawDepth--}},n.prototype.shouldSkipPrebuild=function(t){var e,i,r=t.name;if(B0.isModelSapceName(r)||B0.isPaperSapceName(r)||r.startsWith("*U")||this.blockHasByBlockColor(t))return!0;try{for(var s=sl(t.newIterator()),o=s.next();!o.done;o=s.next()){var a=o.value;if(a.visibility)return!1}}catch(l){e={error:l}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(e)throw e.error}}return!0},n.prototype.blockHasByBlockColor=function(t){var e,i;try{for(var r=sl(t.newIterator()),s=r.next();!s.done;s=r.next()){var o=s.value;if(o.visibility&&o.color.isByBlock)return!0}}catch(a){e={error:a}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(e)throw e.error}}return!1},n.prototype.addEntity=function(t,e,i){if(t.visibility){var r=t.worldDraw(i);r&&(this.attachEntityInfo(r,t),e.push(r))}},n.prototype.attachEntityInfo=function(t,e){t.objectId=e.objectId,t.ownerId=e.ownerId,t.layerName=e.layer,t.visible=e.visibility},n.prototype.maybeCompactTemplate=function(t,e){return!t.compactForInstancing||U0(t)||!dC(t,e)?!1:(t.compactForInstancing(),!0)},n.profiling=!1,n.lruEnabled=!0,n.lruMaxEntries=512,n.lruMaxEstimatedBytes=64*1024*1024,n._profileStats=N0(),n._drawDepth=0,n})(),Fc=new Ya,cf=new Ya,lC=new Ya,cC=8,uC=32,D0=[];function hC(n){var t=n.childCount;return typeof t=="number"?t:Number.POSITIVE_INFINITY}function U0(n){var t=n.isCompacted;return t===!0}function dC(n,t){var e=hC(n);return e<cC?!1:e>=uC?!0:t}function fC(n){var t=n.prepareCacheTemplate;typeof t=="function"&&t.call(n)}function uf(n,t){var e=n.userData;e.blockCacheKey=t}function pC(n){var t,e=(t=D0.pop())!==null&&t!==void 0?t:new rn;return e.copy(n),e}function mC(n){D0.push(n)}/**
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2010-2026 Three.js Authors
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
@@ -4680,7 +4680,7 @@ vBatchSlotId = slotId;`):t.includes("void main() {")?t.replace("void main() {",`
|
|
|
4680
4680
|
vBatchSlotId = slotId;`):t}function xb(n){if(n.includes("applyBatchHighlight(gl_FragColor.rgb)")||n.includes("applyBatchHighlight(diffuseColor.rgb)"))return{source:n,injected:!0};const t=n.includes("applyBatchHighlight")?n:ok+n,e="gl_FragColor.rgb = applyBatchHighlight(gl_FragColor.rgb);";return t.includes("#include <dithering_fragment>")?{source:t.replace("#include <dithering_fragment>",`${e}
|
|
4681
4681
|
#include <dithering_fragment>`),injected:!0}:t.includes("#include <colorspace_fragment>")?{source:t.split("#include <colorspace_fragment>").join(`${e}
|
|
4682
4682
|
#include <colorspace_fragment>`),injected:!0}:t.includes("#include <tonemapping_fragment>")?{source:t.replace("#include <tonemapping_fragment>",`${e}
|
|
4683
|
-
#include <tonemapping_fragment>`),injected:!0}:t.includes("gl_FragColor = vec4( diffuseColor.rgb, alpha );")?{source:t.replace("gl_FragColor = vec4( diffuseColor.rgb, alpha );","gl_FragColor = vec4( applyBatchHighlight(diffuseColor.rgb), alpha );"),injected:!0}:t.includes("gl_FragColor = vec4( diffuseColor.rgb, opacity );")?{source:t.replace("gl_FragColor = vec4( diffuseColor.rgb, opacity );","gl_FragColor = vec4( applyBatchHighlight(diffuseColor.rgb), opacity );"),injected:!0}:{source:n,injected:!1}}function bb(n){var t;if(typeof process<"u"&&((t=process.env)==null?void 0:t.NODE_ENV)==="production")return;const e=n.type;yb.has(e)||(yb.add(e),console.warn(`[AcTrBatchHighlight] Could not inject highlight shader for material type "${e}". Highlight tinting may be skipped.`))}function ck(n,t){n.uniforms.u_highlightMask=t.u_highlightMask,n.uniforms.u_highlightMaskSize=t.u_highlightMaskSize,n.uniforms.u_highlightSelectColor=t.u_highlightSelectColor,n.uniforms.u_highlightHoverColor=t.u_highlightHoverColor,n.uniforms.u_compareEnabled=t.u_compareEnabled,n.uniforms.u_compareBaseColor=t.u_compareBaseColor,n.uniforms.u_compareDeletedColor=t.u_compareDeletedColor,n.uniforms.u_compareAddedColor=t.u_compareAddedColor,n.uniforms.u_compareModifiedColor=t.u_compareModifiedColor}function Sb(n,t){n instanceof un&&(n.uniforms.u_highlightMask=t.u_highlightMask,n.uniforms.u_highlightMaskSize=t.u_highlightMaskSize,n.uniforms.u_highlightSelectColor=t.u_highlightSelectColor,n.uniforms.u_highlightHoverColor=t.u_highlightHoverColor,n.uniforms.u_compareEnabled=t.u_compareEnabled,n.uniforms.u_compareBaseColor=t.u_compareBaseColor,n.uniforms.u_compareDeletedColor=t.u_compareDeletedColor,n.uniforms.u_compareAddedColor=t.u_compareAddedColor,n.uniforms.u_compareModifiedColor=t.u_compareModifiedColor)}function uk(n){n.needsUpdate=!0,n instanceof un&&(n.uniformsNeedUpdate=!0)}function hk(n){const t=ch(n),e=vb(n);if(!t.batchHighlightPatched){if(t.batchHighlightPatched=!0,n instanceof un){n.vertexShader=_b(n.vertexShader);const i=xb(n.fragmentShader);n.fragmentShader=i.source,i.injected||bb(n)}else{const i=n.onBeforeCompile;n.onBeforeCompile=(s,o)=>{i==null||i.call(n,s,o),ck(s,e),s.vertexShader=_b(s.vertexShader);const a=xb(s.fragmentShader);s.fragmentShader=a.source,a.injected||bb(n)};const r=n.customProgramCacheKey;n.customProgramCacheKey=()=>`${r.call(n)}|batchHighlightCompare`}Sb(n,e),uk(n);return}Sb(n,e)}function wb(n,t){const e=Array.isArray(n)?n:[n],i=t.uploadMaskTexture();for(const r of e){hk(r);const s=vb(r);s.u_highlightMask.value=i;const o=t.getMaskTextureDimensions();s.u_highlightMaskSize.value.set(o.width,o.height),s.u_highlightSelectColor.value.copy(zl),s.u_highlightHoverColor.value.copy(hh),s.u_compareEnabled.value=t.compareEnabled?1:0,s.u_compareBaseColor.value.copy(t.compareBaseColor),s.u_compareDeletedColor.value.copy(t.compareDeletedColor),s.u_compareAddedColor.value.copy(t.compareAddedColor),s.u_compareModifiedColor.value.copy(t.compareModifiedColor),r instanceof un&&(r.uniformsNeedUpdate=!0)}}function ca(n,t){const e=n.userData;if(e.batchHighlightRendererInstalled)return;e.batchHighlightRendererInstalled=!0;const i=n.onBeforeRender;n.onBeforeRender=(r,s,o,a,l,c)=>{i==null||i.call(n,r,s,o,a,l,c),l&&wb(l,t)}}function dk(n){return(Array.isArray(n)?n:[n]).some(t=>ch(t).batchHighlightPatched)}function fk(n){const t=n.length;let e=0;return t>0&&(e=Cm.estimateObjectSize(n[0])),{count:t,size:t*e}}function Um(n,t,e,i){for(const r in t.attributes){if(r===la)continue;const s=t.getAttribute(r),{array:o,itemSize:a,normalized:l}=s,c=new o.constructor(e*a),u=new We(c,a,l);n.setAttribute(r,u)}if(fh(n,e),i!=null&&t.getIndex()!==null){const r=e>65535?new Uint32Array(i):new Uint16Array(i);n.setIndex(new We(r,1))}}function zm(n,t,e,i){if(i&&!!t.getIndex()!=!!n.getIndex())throw new Error(`${e}: All geometries must consistently have "index".`);for(const r in n.attributes){if(r===la)continue;if(!t.hasAttribute(r))throw new Error(`${e}: Added geometry missing "${r}". All geometries must have consistent attributes.`);const s=t.getAttribute(r),o=n.getAttribute(r);if(s.itemSize!==o.itemSize||s.normalized!==o.normalized)throw new Error(`${e}: All attributes must have a consistent itemSize and normalized value.`)}}function ph(n,t,e,i){let r,s=e;return n.length>0?(n.sort(Y8),r=n.shift(),t[r]=i):(r=e,s++,t.push(i)),{geometryId:r,geometryCount:s}}function ua(n,t){return n===-1?t:n}function mh(){return{boundingBox:null,flags:j8}}function gh(n){const{typeName:t,maxVertexCount:e,vertexStart:i,reservedVertexCount:r,maxIndexCount:s,indexStart:o=-1,reservedIndexCount:a=0}=n;if(s!=null&&o!==-1&&o+a>s||i+r>e)throw new Error(`${t}: Reserved space request exceeds the maximum buffer size.`)}function ha(n){const{currentMaxCount:t,nextStart:e,requiredCount:i,growthFactor:r}=n,s=e+i;return s<=t?t:Math.ceil(s*r)}function pk(n,t,e){return n>=t.length||!En(t[n].flags)?!1:(t[n].flags=fb.None,e.push(n),!0)}function mk(n,t,e){if(n<0||n>=t.length||!En(t[n].flags))throw new Error(`${e}: Invalid geometryId ${n}. Geometry is either out of range or has been deleted.`)}function gk(n,t,e,i){for(const r in n.attributes){if(r===la)continue;const s=t.getAttribute(r),o=n.getAttribute(r);Rm(s,o,e);const a=s.itemSize;for(let l=s.count,c=i;l<c;l++){const u=e+l;for(let h=0;h<a;h++)o.setComponent(u,h,0)}o.needsUpdate=!0,o.addUpdateRange(e*a,i*a)}}function yk(n,t,e,i,r){const s=n.getIndex(),o=t.getIndex();if(!(!s||!o)){for(let a=0;a<o.count;a++)s.setX(i+a,e+o.getX(a));for(let a=o.count,l=r;a<l;a++)s.setX(i+a,e);s.needsUpdate=!0,s.addUpdateRange(i,r)}}function Fm(n,t,e,i,r,s){const o=t.getIndex()!==null,a=e.getIndex();if(o&&a&&a.count>n.reservedIndexCount||e.attributes.position.count>n.reservedVertexCount)throw new Error(`${i}: Reserved space not large enough for provided geometry.`);const l=n.vertexStart,c=n.reservedVertexCount;if(n.vertexCount=e.getAttribute("position").count,gk(t,e,l,c),o&&a){const d=n;d.indexCount=a.count,yk(t,e,l,d.indexStart,d.reservedIndexCount)}let u=!0;const h=s??n.boundingBox;return h!=null&&(e.computeBoundingBox(),e.boundingBox!=null&&e.boundingBox.equals(h)&&(u=!1)),u&&(n.boundingBox=null),En(n.flags)&&(delete n.hiddenDrawSnapshot,Js(n.flags)||Bm(t,n,!1)),gb(t,l,c,r),u}const vk=new Re;function _k(n,t,e){const i=n??new Re;i.makeEmpty();const r=new Re;for(let s=0,o=t.length;s<o;s++){if(!En(t[s].flags))continue;const a=e(s,r);a&&i.union(a)}return i}function xk(n,t,e){const i=n??new zn;i.makeEmpty();const r=new zn;for(let s=0,o=t.length;s<o;s++)En(t[s].flags)&&(e(s,r),i.union(r));return i}function bk(n,t,e){n.material=e,n.geometry.index=t.index,n.geometry.attributes=t.attributes,n.geometry.boundingBox===null&&(n.geometry.boundingBox=new Re),n.geometry.boundingSphere===null&&(n.geometry.boundingSphere=new zn)}function Sk(n,t,e,i,r){n.geometry.setDrawRange(t,e),n.geometry.boundingBox.copy(i),n.geometry.boundingSphere.copy(r)}function wk(n){n.geometry.index=null,n.geometry.attributes={},n.geometry.setDrawRange(0,1/0)}function yh(n,t){return class extends n{constructor(){super(...arguments),this.boundingBox=null,this.boundingSphere=null,this._geometryInfo=[],this._availableGeometryIds=[],this._geometryCount=0,this._raycastObject=t.createObject(),this._batchIntersects=[],this._box=new Re,this._sphere=new zn,this._vector=new H,this._typedBatchIntersects=this._batchIntersects,this._highlightState=new sk}get mappingStats(){return fk(this._geometryInfo)}validateGeometryId(e){mk(e,this._geometryInfo,t.typeName)}getGeometryRangeAt(e){return this.validateGeometryId(e),this._geometryInfo[e]}computeBoundingBox(){this.boundingBox=_k(this.boundingBox,this._geometryInfo,(e,i)=>this.computeBoundingBoxAt(e,i))}computeBoundingBoxAt(e,i){return this.getBoundingBoxAt(e,i)}computeBoundingSphereAt(e,i){const r=this.computeBoundingBoxAt(e,vk);return r===null?null:r.getBoundingSphere(i)}unionActiveVisibleBoundingBoxInto(e,i){const r=this;r.updateMatrixWorld(!0);for(let s=0;s<this._geometryCount;s++){const o=this._geometryInfo[s];!En(o.flags)||!Js(o.flags)||i!=null&&i.excludeObjectIds&&o.objectId&&i.excludeObjectIds.has(o.objectId)||i!=null&&i.includeObjectIds&&o.objectId&&!i.includeObjectIds.has(o.objectId)||this.computeBoundingBoxAt(s,this._box)&&(this._box.applyMatrix4(r.matrixWorld),e.union(this._box))}}computeAggregateBoundingSphere(e){return xk(e,this._geometryInfo,(i,r)=>this.computeBoundingSphereAt(i,r))}computeBoundingSphere(){const e=this.boundingSphere??new zn;e.makeEmpty(),this.boundingSphere=this.computeAggregateBoundingSphere(e)??e}setVisibleAt(e,i){if(this.validateGeometryId(e),Js(this._geometryInfo[e].flags)===i)return this;const r=this._geometryInfo[e];return Bm(this.geometry,r,i)&&(r.flags=$8(r.flags,i),r.boundingBox=null),this}getVisibleAt(e){return this.validateGeometryId(e),Js(this._geometryInfo[e].flags)}setHighlightAt(e,i,r){try{this.validateGeometryId(e)}catch{return!1}const s=this._highlightState.setHighlight(e,i,r);return s&&ca(this,this._highlightState),s}setCompareRoleAt(e,i){try{this.validateGeometryId(e)}catch{return!1}const r=this._highlightState.setCompareRole(e,i);return(r||this._highlightState.compareEnabled)&&ca(this,this._highlightState),r}applyPackedCompareRoles(e){for(let i=0;i<this._geometryInfo.length;i++){const r=this._geometryInfo[i];if(!En(r.flags))continue;const s=r.objectId,o=s!=null&&s!==""?e.get(String(s))??null:null;this.setCompareRoleAt(i,o)}return this.flushHighlightMask(),this}setCompareDisplayColors(e){return this._highlightState.compareEnabled=e.enabled,e.baseColor!=null&&this._highlightState.compareBaseColor.setHex(e.baseColor),e.deletedColor!=null&&this._highlightState.compareDeletedColor.setHex(e.deletedColor),e.addedColor!=null&&this._highlightState.compareAddedColor.setHex(e.addedColor),e.modifiedColor!=null&&this._highlightState.compareModifiedColor.setHex(e.modifiedColor),this._highlightState.dirty=!0,ca(this,this._highlightState),this.flushHighlightMask(),this}flushHighlightMask(){this._highlightState.setAddressableSlotCount(this._geometryInfo.length);const e=this._highlightState.dirty;return e&&this._highlightState.uploadMaskTexture(),this.material&&(this._highlightState.hasAnyHighlight()||this._highlightState.needsCompareUniforms()||e&&dk(this.material))&&wb(this.material,this._highlightState),this}clearHighlightSlot(e){return this._highlightState.clearSlot(e)&&ca(this,this._highlightState),this}clearHighlightState(){return this._highlightState.clearAll()&&ca(this,this._highlightState),this}deleteGeometry(e){return pk(e,this._geometryInfo,this._availableGeometryIds)?(this.clearHighlightSlot(e),this):this}getObjectAt(e){const i=t.createObject();this._initializeRaycastObject(i);const r=this._geometryInfo[e],{start:s,count:o}=t.getDrawRange(this,r);return this._setRaycastObjectInfo(i,e,s,o),i}intersectWith(e,i,r){this._initializeRaycastObject(this._raycastObject),this._intersectWith(e,i,r),this._resetRaycastObjectInfo(this._raycastObject)}raycast(e,i){this._initializeRaycastObject(this._raycastObject);for(let r=0,s=this._geometryInfo.length;r<s;r++)this._intersectWith(r,e,i);this._resetRaycastObjectInfo(this._raycastObject)}dispose(){return this.geometry.dispose(),this}_initializeRaycastObject(e){bk(e,this.geometry,this.material),e.position.copy(this.position),e.quaternion.copy(this.quaternion),e.scale.copy(this.scale),e.updateMatrix(),e.updateMatrixWorld(!0)}_setRaycastObjectInfo(e,i,r,s){this.computeBoundingBoxAt(i,this._box),this._box.getBoundingSphere(this._sphere),Sk(e,r,s,this._box,this._sphere)}_resetRaycastObjectInfo(e){wk(e)}_intersectWith(e,i,r){const s=this._geometryInfo[e];if(Js(s.flags))if(s.bboxIntersectionCheck){if(this.computeBoundingBoxAt(e,this._box),this._box.applyMatrix4(this.matrixWorld),i.ray.intersectBox(this._box,this._vector)){const o=i.ray.origin.distanceTo(this._vector);r.push({distance:o,point:this._vector.clone(),object:this,face:null,faceIndex:void 0,uv:void 0,batchId:e,objectId:s.objectId})}}else{const{start:o,count:a}=t.getDrawRange(this,s);this._setRaycastObjectInfo(this._raycastObject,e,o,a),this._raycastObject.raycast(i,this._batchIntersects);for(let l=0,c=this._typedBatchIntersects.length;l<c;l++){const u=this._typedBatchIntersects[l];u.object=this,u.batchId=e,u.objectId=s.objectId,r.push(u)}this._batchIntersects.length=0}}}}const Fl=new Re,Hn=new H,Mk=new Re,Ek=yh(Ys,{typeName:"AcTrBatchedLine",createObject:()=>new Ys,getDrawRange:(n,t)=>n.geometry.index!=null?{start:t.indexStart,count:t.indexCount}:{start:t.vertexStart,count:t.vertexCount}}),Mb=class My extends Ek{constructor(t=1e3,e=t*2,i){super(new Xe,i),this._nextIndexStart=0,this._nextVertexStart=0,this._geometryInitialized=!1,this.frustumCulled=!1,this._maxVertexCount=t,this._maxIndexCount=e}get geometryCount(){return this._geometryCount}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}get origin(){return this._origin}_initializeGeometry(t){this._geometryInitialized===!1&&(Um(this.geometry,t,this._maxVertexCount,this._maxIndexCount),this._geometryInitialized=!0)}_validateGeometry(t){zm(this.geometry,t,"AcTrBatchedLine",!0)}_resizeSpaceIfNeeded(t){const e=t.getIndex(),i=e==null?this._maxIndexCount:ha({currentMaxCount:this._maxIndexCount,nextStart:this._nextIndexStart,requiredCount:e.count,growthFactor:My.GROWTH_FACTOR}),r=t.getAttribute("position"),s=r==null?this._maxVertexCount:ha({currentMaxCount:this._maxVertexCount,nextStart:this._nextVertexStart,requiredCount:r.count,growthFactor:My.GROWTH_FACTOR});(i>this._maxIndexCount||s>this._maxVertexCount)&&this.setGeometrySize(s,i)}reset(){this.boundingBox=null,this.boundingSphere=null,this._geometryInfo=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._geometryInfo.length=0,this._origin=void 0,this.position.set(0,0,0),this._geometryInitialized=!1,this.geometry.dispose()}getUserData(){const t=[];return this._geometryInfo.forEach(e=>{t.push({position:e.position,objectId:e.objectId,bboxIntersectionCheck:e.bboxIntersectionCheck})}),t}resetGeometry(t,e=0){const i=this.getUserData();this.reset();const r=_s.instance;i.forEach(s=>{if(s.position){const o=r.create(t,s.position,e);if(o.line){const a=new H(s.position.x,s.position.y,s.position.z??0),l=this.addGeometry(o.line,-1,-1,a);this.setGeometryInfo(l,s)}}})}addGeometry(t,e=-1,i=-1,r=new H){this.rebaseGeometryInPlace(t,r),this._initializeGeometry(t),this._validateGeometry(t),this._resizeSpaceIfNeeded(t);const s=t.getAttribute("position").count,o=t.getIndex(),a={vertexStart:this._nextVertexStart,vertexCount:-1,reservedVertexCount:ua(e,s),indexStart:o?this._nextIndexStart:-1,indexCount:-1,reservedIndexCount:o?ua(i,o.count):0,...mh()};gh({typeName:"AcTrBatchedLine",maxVertexCount:this._maxVertexCount,vertexStart:a.vertexStart,reservedVertexCount:a.reservedVertexCount,maxIndexCount:this._maxIndexCount,indexStart:a.indexStart,reservedIndexCount:a.reservedIndexCount});const{geometryId:l,geometryCount:c}=ph(this._availableGeometryIds,this._geometryInfo,this._geometryCount,a);return this._geometryCount=c,this.setGeometryAt(l,t,null),this._nextIndexStart=a.indexStart+a.reservedIndexCount,this._nextVertexStart=a.vertexStart+a.reservedVertexCount,this._syncDrawRange(),l}rebaseGeometryInPlace(t,e){const i=t.getAttribute("position");if(!i)return;if(!this._origin){He.safeComputeBoundingBox(t);const o=t.boundingBox?t.boundingBox.getCenter(new H):new H;this._origin=o.add(e.clone()),this.position.copy(this._origin)}const r=this._origin;if(!r)return;const s=i.array;if(s instanceof Float32Array){for(let o=0;o<s.length;o+=3)s[o]=s[o]+e.x-r.x,s[o+1]=s[o+1]+e.y-r.y,s[o+2]=s[o+2]+e.z-r.z;i.needsUpdate=!0;return}for(let o=0;o<i.count;o++)i.setXYZ(o,i.getX(o)+e.x-r.x,i.getY(o)+e.y-r.y,i.getZ(o)+e.z-r.z);i.needsUpdate=!0}setGeometryInfo(t,e){if(t>=this._geometryCount)throw new Error("AcTrBatchedLine: Maximum geometry count reached.");const i=this._geometryInfo[t],r=e.position;r&&(i.position={...r}),i.objectId=e.objectId,i.bboxIntersectionCheck=e.bboxIntersectionCheck}setGeometryAt(t,e,i=this.computeBoundingBoxAt(t,Mk)){if(t>=this._geometryCount)throw new Error("AcTrBatchedLine: Maximum geometry count reached.");this._validateGeometry(e);const r=this.geometry,s=this._geometryInfo[t];return Fm(s,r,e,"AcTrBatchedLine",t,i),t}ensureLineDistanceAttribute(){const t=this.geometry;if(t.hasAttribute("lineDistance"))return;const e=Array.isArray(this.material)?this.material[0]:this.material;if(e==null||!He.hasPatternLineShader(e))return;const i=t.getAttribute("position");if(!i)return;const r=t.getIndex();let s=2,o=2;for(let f=0;f<this._geometryCount;f++){const p=this._geometryInfo[f];En(p.flags)&&(s=Math.max(s,p.vertexCount),o=Math.max(o,p.indexCount))}const a=i.itemSize,l=new Float32Array(i.count),c=new Xe,u=new Float32Array(s*a),h=r?new Uint32Array(o):void 0;for(let f=0;f<this._geometryCount;f++){const p=this._geometryInfo[f];if(!En(p.flags))continue;const g=p.vertexCount;if(g<2)continue;if(u.set(i.array.subarray(p.vertexStart*a,(p.vertexStart+g)*a),0),c.setAttribute("position",new We(u.subarray(0,g*a),a)),h&&r){for(let m=0;m<p.indexCount;m++)h[m]=r.array[p.indexStart+m]-p.vertexStart;c.setIndex(new We(h.subarray(0,p.indexCount),1))}He.computeSegmentLineDistances(c);const y=c.getAttribute("lineDistance");l.set(y.array,p.vertexStart)}const d=new an(l,1);d.needsUpdate=!0,t.setAttribute("lineDistance",d)}optimize(){const t=this.geometry,e=t.index!==null,i=t.attributes,r=t.index;let s=0,o=0;const a=this._geometryInfo.map((l,c)=>({info:l,id:c})).filter(l=>En(l.info.flags)).sort((l,c)=>l.info.vertexStart-c.info.vertexStart);for(const{info:l}of a){const c=l.vertexCount,u=e?l.indexCount:0,h=l.vertexStart,d=s,f=d-h;if(f!==0&&c>0)for(const p in i){const g=i[p],{array:y,itemSize:m}=g;y.copyWithin(d*m,h*m,(h+c)*m),g.addUpdateRange(d*m,c*m),g.needsUpdate=!0}if(e&&r&&u>0){const p=l.indexStart,g=o,y=r.array;if(f!==0)for(let m=p;m<p+u;m++)y[m]+=f;p!==g&&y.copyWithin(g,p,p+u),r.addUpdateRange(g,u),r.needsUpdate=!0,l.indexStart=g}l.vertexStart=d,s+=l.reservedVertexCount,o+=l.reservedIndexCount}if(e&&r){const l=r.array;for(let c=o;c<l.length;c++)l[c]=0;r.needsUpdate=!0}return e?t.setDrawRange(0,o):t.setDrawRange(0,s),this._nextVertexStart=s,this._nextIndexStart=o,this._syncDrawRange(),this._availableGeometryIds.length=0,dh(t,this._geometryInfo),this}getBoundingBoxAt(t,e){if(t>=this._geometryCount)return null;const i=this.geometry,r=this._geometryInfo[t];if(r.boundingBox===null){const s=new Re,o=i.index,a=i.attributes.position,{start:l,count:c}=o!=null?{start:r.indexStart,count:r.indexCount}:{start:r.vertexStart,count:r.vertexCount};for(let u=l,h=l+c;u<h;u++){let d=u;o&&(d=o.getX(d)),s.expandByPoint(Hn.fromBufferAttribute(a,d))}r.boundingBox=s}return e.copy(r.boundingBox),e}getBoundingSphereAt(t,e){return t>=this._geometryCount?null:(this.getBoundingBoxAt(t,Fl),Fl.getBoundingSphere(e),e)}computeBoundingBoxAt(t,e){if(t>=this._geometryCount)return null;const i=this.geometry,r=this._geometryInfo[t],s=i.index,o=i.attributes.position,{start:a,count:l}=s!=null?{start:r.indexStart,count:r.indexCount}:{start:r.vertexStart,count:r.vertexCount};if(e.makeEmpty(),o.itemSize===3&&!o.normalized&&(s==null||s.itemSize===1&&!s.normalized)){const c=o.array,u=s==null?void 0:s.array;for(let h=a,d=a+l;h<d;h++){const f=(u==null?h:u[h])*3;e.expandByPoint(Hn.set(c[f],c[f+1],c[f+2]))}return e}for(let c=a,u=a+l;c<u;c++){let h=c;s&&(h=s.getX(h)),e.expandByPoint(Hn.fromBufferAttribute(o,h))}return e}computeAggregateBoundingSphere(t){const e=this.geometry,i=e.index,r=e.attributes.position;if(!r)return null;let s=1/0,o=1/0,a=1/0,l=-1/0,c=-1/0,u=-1/0;const h=r.itemSize===3&&!r.normalized&&(i==null||i.itemSize===1&&!i.normalized),d=r.array,f=i==null?void 0:i.array;for(let p=0;p<this._geometryCount;p++){const g=this._geometryInfo[p];if(!En(g.flags))continue;const{start:y,count:m}=i!=null?{start:g.indexStart,count:g.indexCount}:{start:g.vertexStart,count:g.vertexCount};if(h)for(let v=y,x=y+m;v<x;v++){const _=(f==null?v:f[v])*3,b=d[_],w=d[_+1],C=d[_+2];b<s&&(s=b),w<o&&(o=w),C<a&&(a=C),b>l&&(l=b),w>c&&(c=w),C>u&&(u=C)}else for(let v=y,x=y+m;v<x;v++){let _=v;i&&(_=i.getX(_)),Hn.fromBufferAttribute(r,_),Hn.x<s&&(s=Hn.x),Hn.y<o&&(o=Hn.y),Hn.z<a&&(a=Hn.z),Hn.x>l&&(l=Hn.x),Hn.y>c&&(c=Hn.y),Hn.z>u&&(u=Hn.z)}}return s>l?(t.makeEmpty(),t):(Fl.min.set(s,o,a),Fl.max.set(l,c,u),Fl.getBoundingSphere(t))}getGeometryAt(t){return this.validateGeometryId(t),this._geometryInfo[t]}setGeometrySize(t,e){const i=this.geometry;i.dispose(),this._maxVertexCount=t,this._maxIndexCount=e,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Xe,this._initializeGeometry(i));const r=this.geometry;i.index&&Qs(i.index.array,r.index.array);for(const s in i.attributes)Qs(i.attributes[s].array,r.attributes[s].array);this._syncDrawRange()}getObjectAt(t){const e=super.getObjectAt(t);return e.position.copy(this.position),e}_initializeRaycastObject(t){super._initializeRaycastObject(t),t.position.copy(this.position),t.updateMatrixWorld(!0)}_syncDrawRange(){const t=this.geometry;t.index?t.setDrawRange(0,this._nextIndexStart):t.setDrawRange(0,this._nextVertexStart)}copy(t){var e;return super.copy(t),this.geometry=t.geometry.clone(),this.boundingBox=t.boundingBox!==null?t.boundingBox.clone():null,this.boundingSphere=t.boundingSphere!==null?t.boundingSphere.clone():null,this._geometryInfo=t._geometryInfo.map(i=>({...i,boundingBox:i.boundingBox!==null?i.boundingBox.clone():null})),this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._geometryCount=t._geometryCount,this._origin=(e=t._origin)==null?void 0:e.clone(),this}};Mb.GROWTH_FACTOR=1.25;let Hm=Mb;const bs=new Re,_n=new H,Gn=new H,vh=new H,_h=new H,Eb=new H,Ab=new H,Hl=[],Ss=new gr(new ms),Ak=yh(gr,{typeName:"AcTrBatchedLine2",createObject:()=>new gr(new ms),getDrawRange:(n,t)=>({start:t.vertexStart,count:t.vertexCount})}),Cb=class gM extends Ak{constructor(t=1e3,e){super(new ms,e),this._nextSegmentStart=0,this._geometryInitialized=!1,this.frustumCulled=!1,this._maxSegmentCount=t}get geometryCount(){return this._geometryCount}get unusedSegmentCount(){return this._maxSegmentCount-this._nextSegmentStart}get origin(){return this._origin}_initializeGeometry(t){this._geometryInitialized||(this.geometry.setPositions(new Float32Array(this._maxSegmentCount*6)),fh(this.geometry,this._maxSegmentCount),this._copyStaticAttributes(t),this._isDashedMaterial()&&this._ensureDistanceAttributes(),this._geometryInitialized=!0)}_copyStaticAttributes(t,e=this.geometry){const i=e,r=t.getIndex();r&&i.setIndex(r.clone());for(const s in t.attributes)s==="instanceStart"||s==="instanceEnd"||s==="slotId"||s==="instanceDistanceStart"||s==="instanceDistanceEnd"||i.setAttribute(s,t.getAttribute(s).clone())}_isDashedMaterial(){var t;return((t=this.material)==null?void 0:t.dashed)===!0}_ensureDistanceAttributes(){const t=this.geometry;if(t.getAttribute("instanceDistanceStart"))return;const e=new Float32Array(this._maxSegmentCount*2),i=new Lu(e,2,1);t.setAttribute("instanceDistanceStart",new jn(i,1,0)),t.setAttribute("instanceDistanceEnd",new jn(i,1,1))}ensureDashDistances(){if(!(!this._isDashedMaterial()||!this._geometryInitialized)){this._ensureDistanceAttributes();for(let t=0;t<this._geometryCount;t++){const e=this._geometryInfo[t];!e||!En(e.flags)||e.vertexCount<1||this._writeSlotDistances(e.vertexStart,e.vertexCount,e.reservedVertexCount)}}}_writeSlotDistances(t,e,i){const r=this.geometry.getAttribute("instanceDistanceStart"),s=this.geometry.getAttribute("instanceDistanceEnd");if(!r||!s)return;const o=this.geometry.getAttribute("instanceStart"),a=this.geometry.getAttribute("instanceEnd");let l=0;for(let c=0;c<e;c++){const u=t+c;vh.fromBufferAttribute(o,u),_h.fromBufferAttribute(a,u),r.setX(u,l),l+=vh.distanceTo(_h),s.setX(u,l)}for(let c=e;c<i;c++){const u=t+c;r.setX(u,0),s.setX(u,0)}r.data.needsUpdate=!0,s.data.needsUpdate=!0}_validateGeometry(t){const e=t.getAttribute("instanceStart"),i=t.getAttribute("instanceEnd");if(!e||!i)throw new Error('AcTrBatchedLine2: Geometry must have "instanceStart" and "instanceEnd" attributes.');if(e.itemSize!==3||i.itemSize!==3||e.count!==i.count)throw new Error("AcTrBatchedLine2: Invalid line segment attributes. Expected matching vec3 instanceStart/instanceEnd.")}_resizeSpaceIfNeeded(t){const e=t.getAttribute("instanceStart").count,i=ha({currentMaxCount:this._maxSegmentCount,nextStart:this._nextSegmentStart,requiredCount:e,growthFactor:gM.GROWTH_FACTOR});i>this._maxSegmentCount&&this.setGeometrySize(i)}reset(){this.boundingBox=null,this.boundingSphere=null,this._geometryInfo=[],this._availableGeometryIds=[],this._nextSegmentStart=0,this._geometryCount=0,this._origin=void 0,this.position.set(0,0,0),this._geometryInitialized=!1,this.geometry.dispose()}addGeometry(t,e=-1,i=new H){this.rebaseGeometryInPlace(t,i),this._initializeGeometry(t),this._validateGeometry(t),this._resizeSpaceIfNeeded(t);const r=t.getAttribute("instanceStart").count,s={vertexStart:this._nextSegmentStart,vertexCount:-1,reservedVertexCount:ua(e,r),...mh()};gh({typeName:"AcTrBatchedLine2",maxVertexCount:this._maxSegmentCount,vertexStart:s.vertexStart,reservedVertexCount:s.reservedVertexCount});const{geometryId:o,geometryCount:a}=ph(this._availableGeometryIds,this._geometryInfo,this._geometryCount,s);return this._geometryCount=a,this.setGeometryAt(o,t),this._nextSegmentStart=s.vertexStart+s.reservedVertexCount,this._syncDrawRange(),o}rebaseGeometryInPlace(t,e){const i=t.getAttribute("instanceStart"),r=t.getAttribute("instanceEnd");if(!i||!r)return;if(!this._origin){He.safeComputeBoundingBox(t);const o=t.boundingBox?t.boundingBox.getCenter(new H):new H;this._origin=o.add(e.clone()),this.position.copy(this._origin)}const s=this._origin;if(s){for(let o=0;o<i.count;o++)i.setXYZ(o,i.getX(o)+e.x-s.x,i.getY(o)+e.y-s.y,i.getZ(o)+e.z-s.z),r.setXYZ(o,r.getX(o)+e.x-s.x,r.getY(o)+e.y-s.y,r.getZ(o)+e.z-s.z);i.needsUpdate=!0,r.needsUpdate=!0}}setGeometryInfo(t,e){if(t>=this._geometryCount)throw new Error("AcTrBatchedLine2: Maximum geometry count reached.");const i=this._geometryInfo[t];i.objectId=e.objectId,i.bboxIntersectionCheck=e.bboxIntersectionCheck}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("AcTrBatchedLine2: Maximum geometry count reached.");this._validateGeometry(e);const i=this._geometryInfo[t],r=e.getAttribute("instanceStart").count;if(r>i.reservedVertexCount)throw new Error("AcTrBatchedLine2: Reserved space not large enough for provided geometry.");const s=this.geometry.getAttribute("instanceStart"),o=this.geometry.getAttribute("instanceEnd"),a=e.getAttribute("instanceStart"),l=e.getAttribute("instanceEnd"),c=i.vertexStart;Rm(a,s,c),Rm(l,o,c);for(let u=r,h=i.reservedVertexCount;u<h;u++){const d=c+u;for(let f=0;f<3;f++)s.setComponent(d,f,0),o.setComponent(d,f,0)}return s.needsUpdate=!0,o.needsUpdate=!0,i.vertexCount=r,i.boundingBox=null,gb(this.geometry,c,i.reservedVertexCount,t),this._isDashedMaterial()&&this._writeSlotDistances(c,r,i.reservedVertexCount),t}optimize(){const t=this._getPackedSegmentArray();let e=0;const i=this._geometryInfo.map((o,a)=>({info:o,id:a})).filter(o=>En(o.info.flags)).sort((o,a)=>o.info.vertexStart-a.info.vertexStart);for(const{info:o}of i){const a=o.vertexStart,l=o.reservedVertexCount;if(a!==e){t.copyWithin(e*6,a*6,(a+l)*6);const c=this.geometry.getAttribute("slotId");c&&(c.array.copyWithin(e,a,a+l),c.addUpdateRange(e,l),c.needsUpdate=!0)}o.vertexStart=e,e+=l}for(let o=e*6,a=t.length;o<a;o++)t[o]=0;this._nextSegmentStart=e,this._syncDrawRange(),this._availableGeometryIds.length=0;const r=this.geometry.getAttribute("instanceStart"),s=this.geometry.getAttribute("instanceEnd");if(r.needsUpdate=!0,s.needsUpdate=!0,this._isDashedMaterial())for(const{info:o}of i)this._writeSlotDistances(o.vertexStart,o.vertexCount,o.reservedVertexCount);return dh(this.geometry,this._geometryInfo),this}getBoundingBoxAt(t,e){if(t>=this._geometryCount)return null;const i=this._geometryInfo[t];if(i.boundingBox===null){const r=new Re,s=this.geometry.getAttribute("instanceStart"),o=this.geometry.getAttribute("instanceEnd");for(let a=i.vertexStart,l=i.vertexStart+i.vertexCount;a<l;a++)r.expandByPoint(_n.fromBufferAttribute(s,a)),r.expandByPoint(Gn.fromBufferAttribute(o,a));i.boundingBox=r}return e.copy(i.boundingBox),e}getBoundingSphereAt(t,e){return t>=this._geometryCount?null:(this.getBoundingBoxAt(t,bs),bs.getBoundingSphere(e),e)}computeBoundingBoxAt(t,e){if(t>=this._geometryCount)return null;const i=this._geometryInfo[t],r=this.geometry.getAttribute("instanceStart"),s=this.geometry.getAttribute("instanceEnd"),o=i.vertexStart,a=o+i.vertexCount;e.makeEmpty();const l=r instanceof jn?r:null,c=s instanceof jn?s:null;if(l!==null&&c!==null&&c.data===l.data&&l.itemSize===3&&c.itemSize===3&&l.offset===0&&c.offset===3&&l.data.stride===6){const u=l.data.array;for(let h=o;h<a;h++){const d=h*6;e.expandByPoint(_n.set(u[d],u[d+1],u[d+2])),e.expandByPoint(Gn.set(u[d+3],u[d+4],u[d+5]))}return e}for(let u=o;u<a;u++)e.expandByPoint(_n.fromBufferAttribute(r,u)),e.expandByPoint(Gn.fromBufferAttribute(s,u));return e}computeAggregateBoundingSphere(t){const e=this.geometry.getAttribute("instanceStart"),i=this.geometry.getAttribute("instanceEnd");if(!e||!i)return null;let r=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,c=-1/0;const u=e instanceof jn?e:null,h=i instanceof jn?i:null,d=u!==null&&h!==null&&h.data===u.data&&u.itemSize===3&&h.itemSize===3&&u.offset===0&&h.offset===3&&u.data.stride===6?u.data.array:null;for(let f=0;f<this._geometryCount;f++){const p=this._geometryInfo[f];if(!En(p.flags))continue;const g=p.vertexStart,y=g+p.vertexCount;if(d!==null)for(let m=g;m<y;m++){const v=m*6,x=d[v],_=d[v+1],b=d[v+2],w=d[v+3],C=d[v+4],E=d[v+5];x<r&&(r=x),_<s&&(s=_),b<o&&(o=b),x>a&&(a=x),_>l&&(l=_),b>c&&(c=b),w<r&&(r=w),C<s&&(s=C),E<o&&(o=E),w>a&&(a=w),C>l&&(l=C),E>c&&(c=E)}else for(let m=g;m<y;m++)_n.fromBufferAttribute(e,m),Gn.fromBufferAttribute(i,m),_n.x<r&&(r=_n.x),_n.y<s&&(s=_n.y),_n.z<o&&(o=_n.z),_n.x>a&&(a=_n.x),_n.y>l&&(l=_n.y),_n.z>c&&(c=_n.z),Gn.x<r&&(r=Gn.x),Gn.y<s&&(s=Gn.y),Gn.z<o&&(o=Gn.z),Gn.x>a&&(a=Gn.x),Gn.y>l&&(l=Gn.y),Gn.z>c&&(c=Gn.z)}return r>a?(t.makeEmpty(),t):(bs.min.set(r,s,o),bs.max.set(a,l,c),bs.getBoundingSphere(t))}getGeometryAt(t){return this.validateGeometryId(t),this._geometryInfo[t]}setGeometrySize(t){var e;const i=this.geometry,r=this._getPackedSegmentArray(),s=i.getAttribute("slotId"),o=s?s.array.slice(0,Math.min(s.count,this._maxSegmentCount)):void 0;this._maxSegmentCount=t,this.geometry=new ms,this.geometry.setPositions(new Float32Array(t*6));const a=this._getPackedSegmentArray();if(Qs(r,a),this._copyStaticAttributes(i),this._isDashedMaterial()){const c=i.getAttribute("instanceDistanceStart");if(this._ensureDistanceAttributes(),c&&(e=c.data)!=null&&e.array){const u=this.geometry.getAttribute("instanceDistanceStart"),h=u.data.array,d=c.data.array;h.set(d.subarray(0,Math.min(d.length,h.length))),u.data.needsUpdate=!0}}const l=fh(this.geometry,t);o&&(l.array.set(o.subarray(0,Math.min(o.length,l.count))),l.needsUpdate=!0),this._geometryInitialized=!0,this._syncDrawRange(),i.dispose()}getObjectAt(t){const e=this._geometryInfo[t],i=this._createSubGeometry(e.vertexStart,e.vertexCount,!0),r=new gr(i,this.material);this._isDashedMaterial()&&r.computeLineDistances(),r.position.copy(this.position),r.updateMatrix(),r.updateMatrixWorld(!0);const s=r.geometry.boundingBox??new Re;this.computeBoundingBoxAt(t,s),r.geometry.boundingBox=s;const o=r.geometry.boundingSphere??new zn;return s.getBoundingSphere(o),r.geometry.boundingSphere=o,r}intersectWith(t,e,i){this._intersectWith(t,e,i)}raycast(t,e){for(let i=0,r=this._geometryInfo.length;i<r;i++)this._intersectWith(i,t,e)}copy(t){var e;return super.copy(t),this.geometry=t.geometry.clone(),this.boundingBox=t.boundingBox?t.boundingBox.clone():null,this.boundingSphere=t.boundingSphere?t.boundingSphere.clone():null,this._geometryInfo=t._geometryInfo.map(i=>({...i,boundingBox:i.boundingBox?i.boundingBox.clone():null})),this._maxSegmentCount=t._maxSegmentCount,this._geometryCount=t._geometryCount,this._nextSegmentStart=t._nextSegmentStart,this._geometryInitialized=t._geometryInitialized,this._origin=(e=t._origin)==null?void 0:e.clone(),this}dispose(){return this.geometry.dispose(),this}_intersectWith(t,e,i){const r=this._geometryInfo[t];if(!Js(r.flags))return;if(r.bboxIntersectionCheck){if(this.computeBoundingBoxAt(t,bs),bs.applyMatrix4(this.matrixWorld),e.ray.intersectBox(bs,_n)){const o=e.ray.origin.distanceTo(_n);i.push({distance:o,point:_n.clone(),object:this,face:null,faceIndex:void 0,uv:void 0,batchId:t,objectId:r.objectId})}return}const s=this._createSubGeometry(r.vertexStart,r.vertexCount,!1);if(Ss.geometry=s,Ss.material=this.material,Ss.position.copy(this.position),Ss.quaternion.copy(this.quaternion),Ss.scale.copy(this.scale),Ss.updateMatrix(),Ss.updateMatrixWorld(!0),Ss.raycast(e,Hl),Hl.length===0){this._intersectSegmentsWithLineThreshold(s,this.matrixWorld,e,t,r.objectId,i),s.dispose();return}for(let o=0,a=Hl.length;o<a;o++){const l=Hl[o];l.batchId=t,l.objectId=r.objectId,l.object=this,i.push(l)}Hl.length=0,s.dispose()}_intersectSegmentsWithLineThreshold(t,e,i,r,s,o){var a;const l=((a=i.params.Line)==null?void 0:a.threshold)??0;if(!(l>0))return;const c=t.getAttribute("instanceStart"),u=t.getAttribute("instanceEnd");if(!c||!u)return;const h=l*l,d=o;for(let f=0,p=c.count;f<p;f++){if(vh.fromBufferAttribute(c,f).applyMatrix4(e),_h.fromBufferAttribute(u,f).applyMatrix4(e),i.ray.distanceSqToSegment(vh,_h,Eb,Ab)>h)continue;const g=i.ray.origin.distanceTo(Eb);g<i.near||g>i.far||d.push({distance:g,point:Ab.clone(),object:this,face:null,faceIndex:f,uv:void 0,batchId:r,objectId:s})}}_createSubGeometry(t,e,i){const r=this._getPackedSegmentArray(),s=i?r.slice(t*6,(t+e)*6):r.subarray(t*6,(t+e)*6),o=new ms;return o.setPositions(s),this._copyStaticAttributes(this.geometry,o),o}_getPackedSegmentArray(){var t;const e=this.geometry.getAttribute("instanceStart");if("data"in e&&(t=e.data)!=null&&t.array)return e.data.array;const i=this.geometry.getAttribute("instanceEnd"),r=e.count,s=new Float32Array(r*6);for(let o=0,a=0;o<r;o++)s[a++]=e.getComponent(o,0),s[a++]=e.getComponent(o,1),s[a++]=e.getComponent(o,2),s[a++]=i.getComponent(o,0),s[a++]=i.getComponent(o,1),s[a++]=i.getComponent(o,2);return s}_syncDrawRange(){this.geometry.instanceCount=this._nextSegmentStart}};Cb.GROWTH_FACTOR=1.25;let xh=Cb;const Tb=new Re,Ck=new H,Tk=yh(cn,{typeName:"AcTrBatchedMesh",createObject:()=>new cn,getDrawRange:(n,t)=>n.geometry.index!=null?{start:t.indexStart,count:t.indexCount}:{start:t.vertexStart,count:t.vertexCount}}),Lb=class Ey extends Tk{constructor(t=1e3,e=t*2,i){super(new Xe,i),this._nextIndexStart=0,this._nextVertexStart=0,this._geometryInitialized=!1,this.frustumCulled=!1,this._maxVertexCount=t,this._maxIndexCount=e}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}get origin(){return this._origin}_initializeGeometry(t){this._geometryInitialized===!1&&(Um(this.geometry,t,this._maxVertexCount,this._maxIndexCount),this._geometryInitialized=!0)}_validateGeometry(t){zm(this.geometry,t,"AcTrBatchedMesh",!0)}_resizeSpaceIfNeeded(t){const e=t.getIndex(),i=e==null?this._maxIndexCount:ha({currentMaxCount:this._maxIndexCount,nextStart:this._nextIndexStart,requiredCount:e.count,growthFactor:Ey.GROWTH_FACTOR}),r=t.getAttribute("position"),s=r==null?this._maxVertexCount:ha({currentMaxCount:this._maxVertexCount,nextStart:this._nextVertexStart,requiredCount:r.count,growthFactor:Ey.GROWTH_FACTOR});(i>this._maxIndexCount||s>this._maxVertexCount)&&this.setGeometrySize(s,i)}addGeometry(t,e=-1,i=-1,r=new H){this.rebaseGeometryInPlace(t,r),t.hasAttribute("uv")&&t.deleteAttribute("uv"),t.hasAttribute("normal")&&t.deleteAttribute("normal"),this._initializeGeometry(t),this._validateGeometry(t),this._resizeSpaceIfNeeded(t);const s=t.getAttribute("position").count,o=t.getIndex(),a={vertexStart:this._nextVertexStart,vertexCount:-1,reservedVertexCount:ua(e,s),indexStart:o?this._nextIndexStart:-1,indexCount:-1,reservedIndexCount:o?ua(i,o.count):0,...mh()};gh({typeName:"AcTrBatchedMesh",maxVertexCount:this._maxVertexCount,vertexStart:a.vertexStart,reservedVertexCount:a.reservedVertexCount,maxIndexCount:this._maxIndexCount,indexStart:a.indexStart,reservedIndexCount:a.reservedIndexCount});const{geometryId:l,geometryCount:c}=ph(this._availableGeometryIds,this._geometryInfo,this._geometryCount,a);return this._geometryCount=c,this.setGeometryAt(l,t),this._nextIndexStart=a.indexStart+a.reservedIndexCount,this._nextVertexStart=a.vertexStart+a.reservedVertexCount,this._syncDrawRange(),l}rebaseGeometryInPlace(t,e){const i=t.getAttribute("position");if(!i)return;if(!this._origin){He.safeComputeBoundingBox(t);const o=t.boundingBox?t.boundingBox.getCenter(new H):new H;this._origin=o.add(e.clone()),this.position.copy(this._origin)}const r=this._origin;if(!r)return;const s=i.array;if(s instanceof Float32Array){for(let o=0;o<s.length;o+=3)s[o]=s[o]+e.x-r.x,s[o+1]=s[o+1]+e.y-r.y,s[o+2]=s[o+2]+e.z-r.z;i.needsUpdate=!0;return}for(let o=0;o<i.count;o++)i.setXYZ(o,i.getX(o)+e.x-r.x,i.getY(o)+e.y-r.y,i.getZ(o)+e.z-r.z);i.needsUpdate=!0}setGeometryInfo(t,e){if(t>=this._geometryCount)throw new Error("AcTrBatchedMesh: Maximum geometry count reached.");const i=this._geometryInfo[t];i.objectId=e.objectId,i.bboxIntersectionCheck=e.bboxIntersectionCheck}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("AcTrBatchedMesh: Maximum geometry count reached.");this._validateGeometry(e);const i=this.geometry,r=this._geometryInfo[t];return Fm(r,i,e,"AcTrBatchedMesh",t),t}optimize(){const t=this.geometry,e=t.index!==null,i=t.attributes,r=t.index;let s=0,o=0;const a=this._geometryInfo.map((l,c)=>({info:l,i:c})).filter(l=>En(l.info.flags)).sort((l,c)=>l.info.vertexStart-c.info.vertexStart);for(const{info:l}of a){const c=l.vertexCount,u=e?l.indexCount:0,h=l.vertexStart,d=l.indexStart;if(h!==s){for(const f in i){const p=i[f],{array:g,itemSize:y}=p;g.copyWithin(s*y,h*y,(h+c)*y),p.addUpdateRange(s*y,c*y),p.needsUpdate=!0}l.vertexStart=s}if(e&&r&&d!==o){const f=r.array,p=s-h;for(let g=0;g<u;g++)f[o+g]=f[d+g]+p;r.addUpdateRange(o,u),r.needsUpdate=!0,l.indexStart=o}s+=c,o+=u}if(e&&r){const l=r.array;for(let c=o,u=l.length;c<u;c++)l[c]=0;r.needsUpdate=!0}return this._nextVertexStart=s,this._nextIndexStart=o,this._syncDrawRange(),this._availableGeometryIds.length=0,dh(t,this._geometryInfo),this}getBoundingBoxAt(t,e){if(t>=this._geometryCount)return null;const i=this.geometry,r=this._geometryInfo[t];if(r.boundingBox===null){const s=new Re,o=i.index,a=i.attributes.position,{start:l,count:c}=o!=null?{start:r.indexStart,count:r.indexCount}:{start:r.vertexStart,count:r.vertexCount};for(let u=l,h=l+c;u<h;u++){let d=u;o&&(d=o.getX(d)),s.expandByPoint(Ck.fromBufferAttribute(a,d))}r.boundingBox=s}return e.copy(r.boundingBox),e}getBoundingSphereAt(t,e){return t>=this._geometryCount?null:(this.getBoundingBoxAt(t,Tb),Tb.getBoundingSphere(e),e)}setGeometrySize(t,e){const i=this.geometry;i.dispose(),this._maxVertexCount=t,this._maxIndexCount=e,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Xe,this._initializeGeometry(i));const r=this.geometry;i.index&&Qs(i.index.array,r.index.array);for(const s in i.attributes)Qs(i.attributes[s].array,r.attributes[s].array);this._syncDrawRange()}_syncDrawRange(){const t=this.geometry;t.index?t.setDrawRange(0,this._nextIndexStart):t.setDrawRange(0,this._nextVertexStart)}copy(t){var e;return super.copy(t),this.geometry=t.geometry.clone(),this.boundingBox=t.boundingBox!==null?t.boundingBox.clone():null,this.boundingSphere=t.boundingSphere!==null?t.boundingSphere.clone():null,this._geometryInfo=t._geometryInfo.map(i=>({...i,boundingBox:i.boundingBox!==null?i.boundingBox.clone():null})),this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._geometryCount=t._geometryCount,this._origin=(e=t._origin)==null?void 0:e.clone(),this}};Lb.GROWTH_FACTOR=1.25;let Ib=Lb;const Pb=new Re,Lk=new H,Ik=yh(ur,{typeName:"AcTrBatchedPoint",createObject:()=>new ur,getDrawRange:(n,t)=>({start:t.vertexStart,count:t.vertexCount})}),Rb=class yM extends Ik{constructor(t=1e3,e){super(new Xe,e),this._nextVertexStart=0,this._geometryInitialized=!1,this.frustumCulled=!1,this._maxVertexCount=t}get geometryCount(){return this._geometryCount}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get origin(){return this._origin}_initializeGeometry(t){this._geometryInitialized===!1&&(Um(this.geometry,t,this._maxVertexCount,null),this._geometryInitialized=!0)}_validateGeometry(t){zm(this.geometry,t,"AcTrBatchedPoint",!1)}_resizeSpaceIfNeeded(t){const e=t.getAttribute("position"),i=e==null?this._maxVertexCount:ha({currentMaxCount:this._maxVertexCount,nextStart:this._nextVertexStart,requiredCount:e.count,growthFactor:yM.GROWTH_FACTOR});i>this._maxVertexCount&&this.setGeometrySize(i)}reset(){this.boundingBox=null,this.boundingSphere=null,this._geometryInfo=[],this._availableGeometryIds=[],this._nextVertexStart=0,this._geometryCount=0,this._geometryInfo.length=0,this._origin=void 0,this.position.set(0,0,0),this._geometryInitialized=!1,this.geometry.dispose()}addGeometry(t,e=-1,i=new H){this.rebaseGeometryInPlace(t,i),this._initializeGeometry(t),this._validateGeometry(t),this._resizeSpaceIfNeeded(t);const r=t.getAttribute("position").count,s={vertexStart:this._nextVertexStart,vertexCount:-1,reservedVertexCount:ua(e,r),...mh()};gh({typeName:"AcTrBatchedPoint",maxVertexCount:this._maxVertexCount,vertexStart:s.vertexStart,reservedVertexCount:s.reservedVertexCount});const{geometryId:o,geometryCount:a}=ph(this._availableGeometryIds,this._geometryInfo,this._geometryCount,s);return this._geometryCount=a,this.setGeometryAt(o,t),this._nextVertexStart=s.vertexStart+s.reservedVertexCount,this.geometry.setDrawRange(0,this._nextVertexStart),this._syncDrawRange(),o}rebaseGeometryInPlace(t,e){const i=t.getAttribute("position");if(!i)return;if(!this._origin){He.safeComputeBoundingBox(t);const o=t.boundingBox?t.boundingBox.getCenter(new H):new H;this._origin=o.add(e.clone()),this.position.copy(this._origin)}const r=this._origin;if(!r)return;const s=i.array;if(s instanceof Float32Array){for(let o=0;o<s.length;o+=3)s[o]=s[o]+e.x-r.x,s[o+1]=s[o+1]+e.y-r.y,s[o+2]=s[o+2]+e.z-r.z;i.needsUpdate=!0;return}for(let o=0;o<i.count;o++)i.setXYZ(o,i.getX(o)+e.x-r.x,i.getY(o)+e.y-r.y,i.getZ(o)+e.z-r.z);i.needsUpdate=!0}setGeometryInfo(t,e){if(t>=this._geometryCount)throw new Error("AcTrBatchedPoint: Maximum geometry count reached.");const i=this._geometryInfo[t],r=e.position;r&&(i.position={...r}),i.objectId=e.objectId,i.bboxIntersectionCheck=e.bboxIntersectionCheck}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("AcTrBatchedPoint: Maximum geometry count reached.");this._validateGeometry(e);const i=this.geometry,r=this._geometryInfo[t];return Fm(r,i,e,"AcTrBatchedPoint",t),t}optimize(){let t=0;const e=this.geometry,i=this._geometryInfo,r=i.map((s,o)=>o).filter(s=>En(i[s].flags)).sort((s,o)=>i[s].vertexStart-i[o].vertexStart);for(let s=0;s<r.length;s++){const o=r[s],a=i[o],l=a.vertexStart,c=a.reservedVertexCount;if(l!==t){for(const u in e.attributes){const h=e.attributes[u],{array:d,itemSize:f}=h;d.copyWithin(t*f,l*f,(l+c)*f),h.addUpdateRange(t*f,c*f),h.needsUpdate=!0}a.vertexStart=t}t+=c}return this._nextVertexStart=t,this._syncDrawRange(),this._availableGeometryIds.length=0,dh(e,i),this}getBoundingBoxAt(t,e){if(t>=this._geometryCount)return null;const i=this.geometry,r=this._geometryInfo[t];if(r.boundingBox===null){const s=new Re,o=i.index,a=i.attributes.position;for(let l=r.vertexStart,c=r.vertexStart+r.vertexCount;l<c;l++){let u=l;o&&(u=o.getX(u)),s.expandByPoint(Lk.fromBufferAttribute(a,u))}r.boundingBox=s}return e.copy(r.boundingBox),e}getBoundingSphereAt(t,e){return t>=this._geometryCount?null:(this.getBoundingBoxAt(t,Pb),Pb.getBoundingSphere(e),e)}getGeometryAt(t){return this.validateGeometryId(t),this._geometryInfo[t]}setGeometrySize(t){const e=this.geometry;e.dispose(),this._maxVertexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Xe,this._initializeGeometry(e));const i=this.geometry;e.index&&Qs(e.index.array,i.index.array);for(const r in e.attributes)Qs(e.attributes[r].array,i.attributes[r].array);this._syncDrawRange()}_syncDrawRange(){this.geometry.setDrawRange(0,this._nextVertexStart)}copy(t){var e;return super.copy(t),this.geometry=t.geometry.clone(),this.boundingBox=t.boundingBox!==null?t.boundingBox.clone():null,this.boundingSphere=t.boundingSphere!==null?t.boundingSphere.clone():null,this._geometryInfo=t._geometryInfo.map(i=>({...i,boundingBox:i.boundingBox!==null?i.boundingBox.clone():null})),this._maxVertexCount=t._maxVertexCount,this._geometryInitialized=t._geometryInitialized,this._geometryCount=t._geometryCount,this._origin=(e=t._origin)==null?void 0:e.clone(),this}};Rb.GROWTH_FACTOR=1.25;let kb=Rb;const da=32,to=new Pe,yi=new Pe,Ob=new Pe,Bb=new Pe,Nb=new Pe,bh=new Re,Pk=new Pe().makeScale(0,0,0);class Gm extends wn{constructor(t,e,i,r,s){super(),this._localBox=new Re,this._drawable=null,this._line2Objects=[],this._capacity=0,this._count=0,this._objectIds=[],this._hiddenMatrices=new Map,this._cpuRelative=null,this._selected=new Set,this._hovered=new Set,this._highlights=new Map,this._compareEnabled=!1,this._compareBaseColor=10265519,this._compareMaterial=null,this._geometry=t,this._material=e,this._origin=i.clone(),this.kind=r,this.sourceUuid=s,this.matrixAutoUpdate=!1,He.safeComputeBoundingBox(t),t.boundingBox&&this._localBox.copy(t.boundingBox),this._raycastScratch=this.createDrawable(t,e),this._raycastScratch.matrixAutoUpdate=!1,this._raycastScratch.frustumCulled=!1,r!=="line2"&&(this._drawable=this.createInstanced(t,e,da),this._capacity=da,this._alive=new Uint8Array(da),this._bboxOnly=new Uint8Array(da),this._drawable.position.copy(this._origin),this._drawable.matrixAutoUpdate=!1,this._drawable.updateMatrix(),this._drawable.frustumCulled=!1,this._drawable.raycast=()=>{},this.add(this._drawable))}get origin(){return this._origin}get materialId(){return this._material.id}get material(){return this._material}set material(t){if(this._material=t,this._compareEnabled){this.syncCompareMaterial();return}this.applyMaterialToDrawables(t)}get instanceCount(){let t=0;for(let e=0;e<this._count;e++)this._alive[e]&&t++;return t}addInstance(t,e,i){const r=this._count;if(this.ensureCapacity(r+1),this._count++,this._alive[r]=1,this._bboxOnly[r]=i?1:0,this._objectIds[r]=e,this.writeRelative(r,t),this.kind==="line2"?this._line2Objects[r]=this.createLine2(r):this._drawable&&(this._drawable.count=this._count),i){const s=this._line2Objects[r]??this._drawable;s&&(en(s).bboxIntersectionCheck=!0)}return r}setVisibleAt(t,e){var i;if(!this.isAlive(t))return this;const r=(i=this._drawable)==null?void 0:i.instanceMatrix;if(!r){const a=this._line2Objects[t];return a&&(a.visible=e),e||this.removeHighlight(t),this}const s=t*16,o=r.array;if(e){const a=this._hiddenMatrices.get(t);a&&(o.set(a,s),this._hiddenMatrices.delete(t))}else if(!this._hiddenMatrices.has(t)){const a=new Float32Array(16);a.set(o.subarray(s,s+16)),this._hiddenMatrices.set(t,a),Pk.toArray(o,s),this.removeHighlight(t)}return r.needsUpdate=!0,this}getVisibleAt(t){var e;return this.isAlive(t)?this.kind==="line2"?((e=this._line2Objects[t])==null?void 0:e.visible)!==!1:!this._hiddenMatrices.has(t):!1}deleteGeometry(t){if(!this.isAlive(t))return;this.setVisibleAt(t,!1),this._alive[t]=0,this._selected.delete(t),this._hovered.delete(t),this.removeHighlight(t);const e=this._line2Objects[t];e&&(e.geometry=null,e.removeFromParent(),this._line2Objects[t]=null)}optimize(){}setHighlightAt(t,e,i){if(!this.isAlive(t))return!1;const r=e==="select"?this._selected:this._hovered,s=r.has(t);return i?r.add(t):r.delete(t),s===i&&this._highlights.has(t)===i?!1:(this.syncHighlight(t),!0)}flushHighlightMask(){}setCompareRoleAt(t,e){return!1}setCompareDisplayColors(t){this._compareEnabled=t.enabled,t.baseColor!=null&&(this._compareBaseColor=t.baseColor),this.syncCompareMaterial()}applyPackedCompareRoles(t){return this}intersectWith(t,e,i){if(!this.isAlive(t)||!this.getVisibleAt(t))return;if(this.composeFullMatrix(t,yi),this._bboxOnly[t]){bh.copy(this._localBox).applyMatrix4(yi);const o=e.ray.intersectBox(bh,Rk);if(!o)return;i.push({distance:e.ray.origin.distanceTo(o),point:o.clone(),object:this});return}if(this.kind==="line2"){const o=this._line2Objects[t];if(!o)return;o.updateWorldMatrix(!0,!1);const a=e.intersectObject(o,!1);for(let l=0;l<a.length;l++)i.push(a[l]);return}const r=this._raycastScratch;kk(yi,r.scale),r.matrixWorld.copy(yi),r.matrixWorldNeedsUpdate=!1;const s=e.intersectObject(r,!1);for(let o=0;o<s.length;o++)i.push(s[o])}getObjectAt(t){this.composeLocalMatrix(t,yi);const e=this.createDrawable(this._geometry.clone(),this._material);return e.matrix.copy(yi),e.matrixAutoUpdate=!1,e.matrixWorld.copy(yi),e.matrixWorldNeedsUpdate=!1,e.frustumCulled=!1,e}unionActiveVisibleBoundingBoxInto(t,e){var i;this._drawable&&this._drawable.updateWorldMatrix(!0,!1);for(let r=0;r<this._count;r++){if(!this._alive[r]||!this.getVisibleAt(r))continue;const s=this._objectIds[r];s&&(i=e==null?void 0:e.excludeObjectIds)!=null&&i.has(s)||e!=null&&e.includeObjectIds&&(!s||!e.includeObjectIds.has(s))||(this.composeFullMatrix(r,yi),bh.copy(this._localBox).applyMatrix4(yi),t.union(bh))}}disposeSharedInstances(){for(const t of this._highlights.values())this.disposeOverlay(t);this._highlights.clear();for(const t of this._line2Objects)t&&(t.geometry=null,t.removeFromParent());if(this._line2Objects=[],this._drawable){this._drawable.removeFromParent();const t=this._drawable;t.dispose?t.dispose():t.dispatchEvent({type:"dispose"}),this._drawable=null}this.disposeCompareMaterial(),this.removeFromParent()}get displayMaterial(){return this._compareMaterial??this._material}syncCompareMaterial(){const t=this._compareMaterial;if(this._compareMaterial=null,!this._compareEnabled){this.applyMaterialToDrawables(this._material),t==null||t.dispose();return}const e=this.createCompareMaterial(this._material,this._compareBaseColor);this._compareMaterial=e,this.applyMaterialToDrawables(e),t==null||t.dispose()}createCompareMaterial(t,e){if(t instanceof Pl){const r=new Pl({color:e,linewidth:t.linewidth,worldUnits:t.worldUnits,dashed:t.dashed,dashSize:t.dashSize,gapSize:t.gapSize});return r.resolution=t.resolution,r.depthTest=t.depthTest,r.transparent=t.transparent,r.opacity=t.opacity,r}const i=Pn.cloneMaterial(t);return Pn.setMaterialColor(i,new Zt(e)),i}disposeCompareMaterial(){this._compareMaterial&&(this._compareMaterial.dispose(),this._compareMaterial=null)}applyMaterialToDrawables(t){this._drawable&&(this._drawable.material=t),this._raycastScratch.material=t;for(const e of this._line2Objects)e&&(e.material=t)}isAlive(t){return t>=0&&t<this._count&&this._alive[t]===1}ensureCapacity(t){if(this.kind==="line2"&&this._alive==null&&(this._capacity=da,this._alive=new Uint8Array(this._capacity),this._bboxOnly=new Uint8Array(this._capacity),this._cpuRelative=new Float32Array(this._capacity*16)),t<=this._capacity)return;let e=Math.max(this._capacity,da);for(;e<t;)e*=2;const i=new Uint8Array(e),r=new Uint8Array(e);if(i.set(this._alive),r.set(this._bboxOnly),this._alive=i,this._bboxOnly=r,this._cpuRelative){const a=new Float32Array(e*16);a.set(this._cpuRelative),this._cpuRelative=a}if(this._capacity=e,!this._drawable)return;const s=this._drawable.instanceMatrix,o=new xl(new Float32Array(e*16),16);o.setUsage(lv),o.array.set(s.array),this._drawable.instanceMatrix=o}writeRelative(t,e){var i;Ob.makeTranslation(-this._origin.x,-this._origin.y,-this._origin.z),to.multiplyMatrices(Ob,e),this._cpuRelative&&to.toArray(this._cpuRelative,t*16);const r=(i=this._drawable)==null?void 0:i.instanceMatrix;r&&(to.toArray(r.array,t*16),r.needsUpdate=!0)}readRelative(t,e){var i;const r=this._hiddenMatrices.get(t);if(r)return e.fromArray(r);if(this._cpuRelative)return e.fromArray(this._cpuRelative,t*16);const s=(i=this._drawable)==null?void 0:i.instanceMatrix;return s&&e.fromArray(s.array,t*16),e}composeLocalMatrix(t,e){return this.readRelative(t,to),Bb.makeTranslation(this._origin.x,this._origin.y,this._origin.z),e.multiplyMatrices(Bb,to)}composeFullMatrix(t,e){return this.readRelative(t,to),this._drawable?(this._drawable.updateWorldMatrix(!0,!1),e.multiplyMatrices(this._drawable.matrixWorld,to)):(this.composeLocalMatrix(t,Nb),this.updateWorldMatrix(!0,!1),e.multiplyMatrices(this.matrixWorld,Nb))}createLine2(t){this.composeLocalMatrix(t,yi);const e=new gr(this._geometry,this.displayMaterial);return e.matrix.copy(yi),e.matrixAutoUpdate=!1,e.matrixWorldNeedsUpdate=!0,e.frustumCulled=!1,en(e).sharesTemplateGeometry=!0,this.add(e),e}syncHighlight(t){if(this.removeHighlight(t),!this.getVisibleAt(t))return;const e=this._selected.has(t),i=this._hovered.has(t);if(!e&&!i)return;this.composeLocalMatrix(t,yi);const r=this.createDrawable(this._geometry.clone(),this._material);r.matrix.copy(yi),r.matrixAutoUpdate=!1,r.frustumCulled=!1,r.renderOrder=1e4,r.raycast=()=>{};const s=r.material;s&&!Array.isArray(s)&&(r.material=Pn.cloneMaterial(s),Pn.setMaterialColor(r.material,e?zl:hh)),this.add(r),this._highlights.set(t,r)}removeHighlight(t){const e=this._highlights.get(t);e&&(this.disposeOverlay(e),this._highlights.delete(t))}disposeOverlay(t){if("material"in t&&t.material instanceof cr&&t.material.dispose(),"geometry"in t){const e=t;e.geometry&&e.geometry!==this._geometry&&e.geometry.dispose(),e.geometry=null}t.removeFromParent()}createInstanced(t,e,i){if(this.kind==="mesh"){const s=new DT(t,e,i);return s.count=0,s.frustumCulled=!1,s}const r=this.kind==="points"?new ur(t,e):new Ys(t,e);return r.isInstancedMesh=!0,r.instanceMatrix=new xl(new Float32Array(i*16),16),r.instanceMatrix.setUsage(lv),r.instanceColor=null,r.morphTexture=null,r.count=0,r.frustumCulled=!1,r}createDrawable(t,e){return this.kind==="mesh"?new cn(t,e):this.kind==="points"?new ur(t,e):this.kind==="line2"?new gr(t,e):new Ys(t,e)}}const Rk=new H;function kk(n,t){const e=n.elements,i=Math.hypot(e[0],e[1],e[2]),r=Math.hypot(e[4],e[5],e[6]),s=Math.hypot(e[8],e[9],e[10]);if(i+r+s===0){t.set(1,1,1);return}t.set(i,r,s)}let Db=()=>0;function ws(n,t){(gi(t).drawOrder??0)>=0&&(n.z+=Db())}const Ms=class dn extends pi{constructor(){super(),this._unbatchedSelectedIds=new Set,this._unbatchedHoveredIds=new Set,this._compareRoles=new Map,this._compareEnabled=!1,this._compareBaseColor=10265519,this._compareDeletedColor=14753096,this._compareAddedColor=2278750,this._compareModifiedColor=16096779,this._pointBatches=new Map,this._pointSymbolBatches=new Map,this._lineBatches=new Map,this._lineWithIndexBatches=new Map,this._line2Batches=new Map,this._meshBatches=new Map,this._meshWithIndexBatches=new Map,this._entitiesMap=new Map,this._originBatchById=new Map,this._sharedBatchById=new Map,this._sharedGeometryBatches=new Map,this._ownedSharedGeometries=new Map,this._unbatchedEntities=new Map,this._unbatchedObjects=new pi,this._selectedObjects=Tm(new pi),this._hoverObjects=Tm(new pi),this._compareOverlay=Tm(new pi),this._compareOverlay.name="CompareOverlay",this._compareOverlay.renderOrder=1e4,this.add(this._unbatchedObjects),this.add(this._selectedObjects),this.add(this._hoverObjects),this.add(this._compareOverlay)}get entityCount(){return this._entitiesMap.size}get stats(){const t=this.getUnbatchedStats(),e={summary:{entityCount:this._entitiesMap.size,totalGeometrySize:0,totalMappingSize:0},mesh:{indexed:{count:this.countBatchContainers(this._meshWithIndexBatches),geometrySize:this.getBatchedGeometrySize(this._meshWithIndexBatches),mappingSize:this.getBatchedGeometryMappingSize(this._meshWithIndexBatches)},nonIndexed:{count:this.countBatchContainers(this._meshBatches),geometrySize:this.getBatchedGeometrySize(this._meshBatches),mappingSize:this.getBatchedGeometryMappingSize(this._meshBatches)}},line:{indexed:{count:this.countBatchContainers(this._lineWithIndexBatches),geometrySize:this.getBatchedGeometrySize(this._lineWithIndexBatches),mappingSize:this.getBatchedGeometryMappingSize(this._lineWithIndexBatches)},nonIndexed:{count:this.countBatchContainers(this._lineBatches)+this.countBatchContainers(this._line2Batches),geometrySize:this.getBatchedGeometrySize(this._lineBatches)+this.getBatchedGeometrySize(this._line2Batches),mappingSize:this.getBatchedGeometryMappingSize(this._lineBatches)+this.getBatchedGeometryMappingSize(this._line2Batches)}},point:{indexed:{count:this.countBatchContainers(this._pointSymbolBatches),geometrySize:this.getBatchedGeometrySize(this._pointSymbolBatches),mappingSize:this.getBatchedGeometryMappingSize(this._pointSymbolBatches)},nonIndexed:{count:this.countBatchContainers(this._pointBatches),geometrySize:this.getBatchedGeometrySize(this._pointBatches),mappingSize:this.getBatchedGeometryMappingSize(this._pointBatches)}},unbatched:t};return e.summary.totalGeometrySize=e.line.indexed.geometrySize+e.line.nonIndexed.geometrySize+e.mesh.indexed.geometrySize+e.mesh.nonIndexed.geometrySize+e.point.indexed.geometrySize+e.point.nonIndexed.geometrySize+e.unbatched.geometrySize,e.summary.totalMappingSize=e.line.indexed.mappingSize+e.line.nonIndexed.mappingSize+e.mesh.indexed.mappingSize+e.mesh.nonIndexed.mappingSize+e.point.indexed.mappingSize+e.point.nonIndexed.mappingSize,e}rerenderPoints(t,e=0){const i=_s.instance.create(t,{x:0,y:0,z:0},e);i.line&&this._pointSymbolBatches.forEach(s=>{s.forEach(o=>{o.resetGeometry(t,e)})});const r=i.point!=null;this._pointBatches.forEach(s=>{s.forEach(o=>{o.visible=r})})}collectPointObjectWorldBoxes(t=new Map){const e=new Re,i=r=>{r.updateMatrixWorld(!0);for(let s=0;s<r.geometryCount;s++){let o;try{o=r.getGeometryAt(s)}catch{continue}if(!o.objectId||o.vertexCount<=0||!r.getBoundingBoxAt(s,e))continue;e.applyMatrix4(r.matrixWorld);const a=t.get(o.objectId);a?a.union(e):t.set(o.objectId,e.clone())}};return this._pointSymbolBatches.forEach(r=>{r.forEach(i)}),this._pointBatches.forEach(r=>{r.forEach(i)}),t}computeBoundingBox(t=new Re,e){t.makeEmpty();const i=new Re,r=s=>{s.forEach(o=>{o.forEach(a=>{a.unionActiveVisibleBoundingBoxInto(t,e)})})};return r(this._lineBatches),r(this._lineWithIndexBatches),r(this._line2Batches),r(this._meshBatches),r(this._meshWithIndexBatches),r(this._pointBatches),r(this._pointSymbolBatches),this._sharedGeometryBatches.forEach(s=>{s.forEach(o=>o.unionActiveVisibleBoundingBoxInto(t,e))}),this._unbatchedEntities.forEach((s,o)=>{var a;if(!((a=e==null?void 0:e.excludeObjectIds)!=null&&a.has(o))&&!(e!=null&&e.includeObjectIds&&!e.includeObjectIds.has(o)))for(const l of s)l.visible!==!1&&this.unionUnbatchedObjectBounds(l,t,i)}),t}clear(){return this.groups.forEach(t=>{t.forEach(e=>{e.forEach(i=>{i.dispose(),i.removeFromParent()})}),t.clear()}),this.clearHighlightGroup(this._selectedObjects),this.clearHighlightGroup(this._hoverObjects),this.clearHighlightGroup(this._compareOverlay),this._sharedGeometryBatches.forEach(t=>{t.forEach(e=>e.disposeSharedInstances())}),this._sharedGeometryBatches.clear(),this._sharedBatchById.clear(),this._ownedSharedGeometries.forEach(t=>t.dispose()),this._ownedSharedGeometries.clear(),this._originBatchById.clear(),this._unbatchedObjects.children.forEach(t=>{this.disposeObject(t)}),this._unbatchedObjects.clear(),this._unbatchedEntities.clear(),this._unbatchedSelectedIds.clear(),this._unbatchedHoveredIds.clear(),this._entitiesMap.clear(),this}updateMaterial(t,e){for(const i of this.groups){const r=i.get(t);if(r){for(const s of r)s.material=this.createOwnedBatchMaterial(e),s instanceof Hm?s.ensureLineDistanceAttribute():s instanceof xh&&s.ensureDashDistances();if(e.id!==t){i.delete(t);const s=i.get(e.id);s?s.push(...r):i.set(e.id,r)}}}this.rebindSharedGeometryMaterial(t,e),this._unbatchedObjects.traverse(i=>{if(!("material"in i))return;const r=en(i);if(r.styleMaterialId===t){const s=i;s.material=e,r.styleMaterialId=e.id,this.ensureUnbatchedLineDistance(s,e)}})}syncAppearanceFromRecord(t,e,i,r,s,o){this.rebindBatchedMaterialsForLayer(t,e,s,o),this._unbatchedObjects.traverse(a=>{const l=a.refreshTextMaterials;if(typeof l=="function"&&l.call(a,e),!("material"in a))return;const c=a;r&&D8(c,i),this.rebindUnbatchedDrawableMaterial(c,t,e,s,o)}),o&&this.rematerializeLayerTextDrawables(t,o,e)}rebindMaterialsForLayer(t,e,i,r){this.rebindBatchedMaterialsForLayer(t,e,i,r),this._unbatchedObjects.traverse(s=>{"material"in s&&this.rebindUnbatchedDrawableMaterial(s,t,e,i,r)})}rebindBatchedMaterialsForLayer(t,e,i,r){var s;const o=new Map;for(const a of this.groups)for(const l of[...a.keys()]){const c=a.get(l),u=(s=c==null?void 0:c[0])==null?void 0:s.material;if(!u||o.has(l)||!lh(u,t,t))continue;const h=this.resolveLayerBoundMaterial(u,t,e,i,r,t);if(h){if(h===u){for(const d of c)this.refreshLayerBoundMaterialColor(d.material,e,r);continue}o.set(l,h),this.updateMaterial(l,h)}}}rebindUnbatchedDrawableMaterial(t,e,i,r,s){const o=t.userData.layerName??e,a=en(t),l=h=>{if(!lh(h,e,o))return h;const d=this.resolveLayerBoundMaterial(h,e,i,r,s,o);return d?d===h?(this.refreshLayerBoundMaterialColor(h,i,s),h):d:h},c=t.material;if(Array.isArray(c)){t.material=c.map(l),uh(a,t.material),this.ensureUnbatchedLineDistance(t,t.material);return}const u=l(c);u!==c&&(t.material=u,uh(a,u)),this.ensureUnbatchedLineDistance(t,t.material)}ensureUnbatchedLineDistance(t,e){if(Im(t)){He.ensureLineDistance(t.geometry,e);return}if(!Pm(t))return;const i=Array.isArray(e)?e[0]:e;i&&i.dashed===!0&&!t.geometry.getAttribute("instanceDistanceStart")&&t.computeLineDistances()}rematerializeLayerTextDrawables(t,e,i){var r;for(const s of this._unbatchedObjects.children){const o=en(s).textEntityTraits;o==null||o.layer!==t||ki.rematerializeTextHierarchy(s,ki.cloneEntityTraits(o),e)}if(i!=null&&i.color)for(const s of this.groups)for(const o of[...s.keys()]){const a=s.get(o),l=(r=a==null?void 0:a[0])==null?void 0:r.material;!l||!lh(l,t,t)||this.refreshLayerBoundMaterialColor(l,i,e)}}resolveLayerBoundMaterial(t,e,i,r,s,o){const a=r(t,e,i);if(a)return a;if(s)return this.resolveLayerBoundReplacement(t,e,s,o??e)}resolveLayerBoundReplacement(t,e,i,r){if(!lh(t,e,r))return;const s=gi(t),o=Lm.createDefaultTraits();return o.layer=e,o.color.setByLayer(),o.drawOrder=s.drawOrder??0,s.drawOrder===0&&s.isForeground!==!0?i.getMTextFillMaterial(o):i.getLineMaterial(o,!0)}refreshLayerBoundMaterialColor(t,e,i){var r,s;if(gi(t).isByLayerColor!==!0)return;const o=((r=e.color)==null?void 0:r.isForeground)===!0;if(ab(t,{isForeground:o}),o&&!i)return;const a=o&&i?zc(i.currentBackgroundColor):(s=e.color)==null?void 0:s.RGB;typeof a!="number"||this.getMaterialDisplayRgb(t)===a||Pn.setMaterialColor(t,new Zt(a))}getMaterialDisplayRgb(t){var e,i;if(t instanceof Xs||t instanceof wl)return t.color.getHex();const r=(i=(e=t.uniforms)==null?void 0:e.u_color)==null?void 0:i.value;if(r instanceof Zt)return r.getHex()}hasEntity(t){return this._entitiesMap.has(t)||this._unbatchedEntities.has(t)}forEachEntitySlot(t,e){const i=this._entitiesMap.get(t);if(i!=null){if(!Array.isArray(i)){e(i);return}for(let r=0,s=i.length;r<s;r++)if(e(i[r])===!0)return}}appendEntitySlot(t,e){const i=this._entitiesMap.get(t);i==null?this._entitiesMap.set(t,e):Array.isArray(i)?i.push(e):this._entitiesMap.set(t,[i,e])}setEntityVisible(t,e){const i=this._unbatchedEntities.get(t);return!this._entitiesMap.has(t)&&!i?!1:(this.forEachEntitySlot(t,r=>{const s=this.getOriginBatch(r.batchedObjectId);s==null||s.setVisibleAt(r.batchId,e)}),i==null||i.forEach(r=>{r.visible=e}),e||(this.unselect(t),this.unhover(t)),!0)}getEntityVisible(t){const e=this._unbatchedEntities.get(t),i=this._entitiesMap.has(t);if(!i&&!e)return;let r,s=0;if(i){let o=!0;this.forEachEntitySlot(t,a=>(s++,this.getBatchItemVisible(a)?!1:(o=!1,!0))),s>0&&(r=o)}if(e&&e.length>0){const o=e.some(a=>a.visible);r=(r===void 0||r)&&o}return r}addEntity(t){if(t.visible===!1)return;const e=String(t.objectId??""),i=t.visible,r=[],s=this._unbatchedEntities.get(e)??[];let o=!1;const a=t.styleManager;if(t.updateMatrixWorld(!0),t.userData.annotationScale){const c=this.cloneEntityAsPlainShell(t);c.visible=i,this._unbatchedObjects.add(c),s.push(c),this._entitiesMap.has(e)||this._entitiesMap.set(e,null),this._unbatchedEntities.set(e,s),this.syncCompareRoleForEntity(e);return}const l=c=>{if(!ub(c))return;const u=en(c),h=!!u.bboxIntersectionCheck;if(u.noBatch){const f=this.cloneUnbatchedObject(c);f.visible=i&&c.visible;const p=f.material,g=Array.isArray(p)?p[0]:p;g&&(gi(g).drawOrder??0)>=0,en(f).bboxIntersectionCheck=h,this._unbatchedObjects.add(f),s.push(f),o=!0;return}const d=this.tryAddSharedDrawable(c,e,h);if(d)r.push(d),this.applyBatchSlotVisibility(d,i&&c.visible);else if(Pm(c)){const f=this.addLine2(c,{objectId:e,bboxIntersectionCheck:h});f&&(r.push(f),this.applyBatchSlotVisibility(f,i&&c.visible));return}else if(Im(c)){const f=this.addLine(c,{position:u.position,objectId:e,bboxIntersectionCheck:h});f&&(r.push(f),this.applyBatchSlotVisibility(f,i&&c.visible))}else if(hb(c)){const f=this.addMesh(c,{objectId:e,bboxIntersectionCheck:h},a);f&&(r.push(f),this.applyBatchSlotVisibility(f,i&&c.visible))}else if(db(c)){const f=this.addPoint(c,{objectId:e,bboxIntersectionCheck:h});f&&(r.push(f),this.applyBatchSlotVisibility(f,i&&c.visible))}for(const f of c.children)l(f)};if(l(t),r.length===0)this._entitiesMap.has(e)||this._entitiesMap.set(e,null);else for(let c=0;c<r.length;c++)this.appendEntitySlot(e,r[c]);o&&this._unbatchedEntities.set(e,s),this.syncCompareRoleForEntity(e)}syncCompareRoleForEntity(t){if(!this._compareEnabled)return;const e=this._compareRoles.get(t)??null;this.applyCompareRoleToEntity(t,e),this.refreshUnbatchedCompareMaterial(t),this.rebindCompareOverlaySharedBuffers(),this.syncCompareOverlayForEntity(t)}appendLineGeometry(t,e,i,r){if(r.visible===!1)return!1;ws(i,e);const s=t.getIndex()!==null?this._lineWithIndexBatches:this._lineBatches,o=this.resolveOriginBatch(s,e.id,i,()=>new Hm(dn.INITIAL_LINE_VERTEX_CAPACITY,dn.INITIAL_LINE_INDEX_CAPACITY,this.createOwnedBatchMaterial(e)));t.hasAttribute("lineDistance")&&He.recomputeLineDistanceForLineSegments(t);const a=o.addGeometry(t,-1,-1,i);o.setGeometryInfo(a,{objectId:r.objectId});const l={batchedObjectId:o.id,batchId:a};return this.registerDirectAppend(r.objectId,l,!0),!0}appendLine2Geometry(t,e,i,r){if(r.visible===!1)return!1;ws(i,e);const s=this.resolveOriginBatch(this._line2Batches,e.id,i,()=>new xh(dn.INITIAL_LINE_VERTEX_CAPACITY,this.createOwnedBatchMaterial(e))),o=s.addGeometry(t,-1,i);s.setGeometryInfo(o,{objectId:r.objectId});const a={batchedObjectId:s.id,batchId:o};return this.registerDirectAppend(r.objectId,a,!0),!0}appendPointGeometry(t,e,i,r){if(r.visible===!1)return!1;ws(i,e);const s=this.resolveOriginBatch(this._pointBatches,e.id,i,()=>new kb(dn.INITIAL_POINT_VERTEX_CAPACITY,this.createOwnedBatchMaterial(e))),o=s.addGeometry(t,-1,i);s.setGeometryInfo(o,{objectId:r.objectId,bboxIntersectionCheck:!0,position:r.position});const a={batchedObjectId:s.id,batchId:o};return this.registerDirectAppend(r.objectId,a,!0),!0}appendMeshGeometry(t,e,i,r){if(r.visible===!1)return!1;ws(i,e);const s=t.getIndex()!==null?this._meshWithIndexBatches:this._meshBatches,o=this.resolveOriginBatch(s,e.id,i,()=>{const c=gi(e).drawOrder??0,u=new Ib(dn.INITIAL_MESH_VERTEX_CAPACITY,dn.INITIAL_MESH_INDEX_CAPACITY,this.createOwnedBatchMaterial(e));return u.renderOrder=c,u}),a=o.addGeometry(t,-1,-1,i);o.setGeometryInfo(a,{objectId:r.objectId});const l={batchedObjectId:o.id,batchId:a};return this.registerDirectAppend(r.objectId,l,!0),!0}registerDirectAppend(t,e,i){t=String(t),this.appendEntitySlot(t,e),this.applyBatchSlotVisibility(e,i),this.syncCompareRoleForEntity(t)}removeEntity(t){let e=!1,i=!1;if(this._entitiesMap.has(t)){const s=new Map;this.forEachEntitySlot(t,o=>{const a=this.getOriginBatch(o.batchedObjectId);a&&(a.deleteGeometry(o.batchId),s.set(o.batchedObjectId,a),e=!0)}),s.forEach(o=>o.optimize()),i=s.size>0,this.unselect(t),this.unhover(t),this._entitiesMap.delete(t)}const r=this._unbatchedEntities.get(t);return r&&(this.unselect(t),this.unhover(t),r.forEach(s=>{this.disposeObject(s),this._unbatchedObjects.remove(s)}),this._unbatchedEntities.delete(t),e=!0),this._compareEnabled&&(i?this.refreshCompareOverlay():this.removeCompareOverlayForEntity(t)),e}isIntersectWith(t,e){const i=[];let r=!1;if(this.forEachEntitySlot(t,o=>{const a=this.getOriginBatch(o.batchedObjectId);return a&&(a.intersectWith(o.batchId,e,i),i.length>0)?(r=!0,!0):!1}),r)return!0;const s=this._unbatchedEntities.get(t);if(s){for(let o=0;o<s.length;o++)if(this.isUnbatchedDrawableIntersecting(s[o],e))return!0}return!1}hover(t){this.setEntityHighlight([t],"hover",!0)}unhover(t){this.setEntityHighlight([t],"hover",!1)}select(t){this.setEntityHighlight([t],"select",!0)}unselect(t){this.setEntityHighlight([t],"select",!1)}hoverMany(t){this.setEntityHighlight(t,"hover",!0)}unhoverMany(t){this.setEntityHighlight(t,"hover",!1)}selectMany(t){this.setEntityHighlight(t,"select",!0)}unselectMany(t){this.setEntityHighlight(t,"select",!1)}setCompareDisplay(t){var e,i,r;if(this._compareEnabled=t.enabled,t.baseColor!=null&&(this._compareBaseColor=t.baseColor),((e=t.colors)==null?void 0:e.deleted)!=null&&(this._compareDeletedColor=t.colors.deleted),((i=t.colors)==null?void 0:i.added)!=null&&(this._compareAddedColor=t.colors.added),((r=t.colors)==null?void 0:r.modified)!=null&&(this._compareModifiedColor=t.colors.modified),t.overrides){this._compareRoles.clear();for(const s of t.overrides)s.role!=null&&this._compareRoles.set(String(s.objectId),s.role)}t.enabled||this._compareRoles.clear(),this.applyCompareDisplayToBatches(),this.refreshCompareOverlay(),this.refreshAllUnbatchedCompareMaterials()}clearCompareDisplay(){this.setCompareDisplay({enabled:!1,overrides:[]})}setEntityCompareRole(t,e){const i=String(t);e==null?this._compareRoles.delete(i):this._compareRoles.set(i,e),this.applyCompareRoleToEntity(i,e),this.refreshUnbatchedCompareMaterial(i),this.syncCompareOverlayForEntity(i)}applyCompareDisplayToBatches(){const t={enabled:this._compareEnabled,baseColor:this._compareBaseColor,deletedColor:this._compareDeletedColor,addedColor:this._compareAddedColor,modifiedColor:this._compareModifiedColor};for(const e of this.groups)e.forEach(i=>{i.forEach(r=>{r.setCompareDisplayColors(t),r.applyPackedCompareRoles(this._compareRoles)})});this._sharedGeometryBatches.forEach(e=>{e.forEach(i=>i.setCompareDisplayColors(t))})}applyCompareRoleToEntity(t,e){const i=new Set;this.forEachEntitySlot(t,r=>{const s=this.getOriginBatch(r.batchedObjectId);s!=null&&s.setCompareRoleAt(r.batchId,e)&&i.add(s)}),i.forEach(r=>r.flushHighlightMask())}refreshAllUnbatchedCompareMaterials(){this._unbatchedEntities.forEach((t,e)=>{this.refreshUnbatchedCompareMaterial(e)})}refreshUnbatchedCompareMaterial(t){const e=this._unbatchedEntities.get(t);if(e){if(this._unbatchedSelectedIds.has(t)||this._unbatchedHoveredIds.has(t)){this.refreshUnbatchedHighlight(e[0],t);for(const i of e)this.refreshUnbatchedHighlight(i,t);return}for(const i of e){if(!this._compareEnabled){this.unhighlightUnbatchedObject(i);continue}const r=this._compareRoles.get(t),s=this.resolveCompareColor(r);this.applyUnbatchedCompareMaterial(i,s)}}}resolveCompareColor(t){return t==="deleted"?this._compareDeletedColor:t==="added"?this._compareAddedColor:t==="modified"?this._compareModifiedColor:this._compareBaseColor}applyUnbatchedCompareMaterial(t,e){if("material"in t){const i=t.material,r=xr(t);r.originalMaterial==null&&(r.originalMaterial=i);const s=r.originalMaterial??i;t.material=this.getSharedCompareMaterial(s,e);return}for(const i of t.children)this.applyUnbatchedCompareMaterial(i,e)}getSharedCompareMaterial(t,e){if(Array.isArray(t))return t.map(a=>this.getSharedCompareMaterial(a,e));const i=`compare-${e}`;let r=dn.sharedHighlightMaterialsBySource.get(t);r||(r=new Map,dn.sharedHighlightMaterialsBySource.set(t,r),t.addEventListener("dispose",dn.onSourceMaterialDisposed));const s=r.get(i);if(s)return s;const o=Pn.cloneMaterial(t);return Array.isArray(o)||(Pn.setMaterialColor(o,new Zt(e)),r.set(i,o)),o}setEntityHighlight(t,e,i){if(t.length===0)return;const r=new Set;for(const s of t){this.forEachEntitySlot(s,a=>{const l=this.getOriginBatch(a.batchedObjectId);l&&l.setHighlightAt(a.batchId,e,i)&&r.add(l)});const o=this._unbatchedEntities.get(s);if(o){e==="select"?i?this._unbatchedSelectedIds.add(s):this._unbatchedSelectedIds.delete(s):i?this._unbatchedHoveredIds.add(s):this._unbatchedHoveredIds.delete(s);for(const a of o)this.refreshUnbatchedHighlight(a,s);i||this.refreshUnbatchedCompareMaterial(s)}}r.forEach(s=>s.flushHighlightMask())}refreshUnbatchedHighlight(t,e){if(this._unbatchedSelectedIds.has(e)){this.applyUnbatchedHighlightMaterial(t,"select");return}if(this._unbatchedHoveredIds.has(e)){this.applyUnbatchedHighlightMaterial(t,"hover");return}this.unhighlightUnbatchedObject(t)}applyUnbatchedHighlightMaterial(t,e){if("material"in t){const i=t.material,r=xr(t);r.originalMaterial==null&&(r.originalMaterial=i),t.material=this.getSharedHighlightMaterial(i,e);return}for(const i of t.children)this.applyUnbatchedHighlightMaterial(i,e)}unhighlightUnbatchedObject(t){if("material"in t){const e=xr(t);e.originalMaterial!=null&&(t.material=e.originalMaterial,delete e.originalMaterial);return}for(const e of t.children)this.unhighlightUnbatchedObject(e)}getSharedHighlightMaterial(t,e){if(Array.isArray(t))return t.map(o=>this.getSharedHighlightMaterial(o,e));let i=dn.sharedHighlightMaterialsBySource.get(t);i||(i=new Map,dn.sharedHighlightMaterialsBySource.set(t,i),t.addEventListener("dispose",dn.onSourceMaterialDisposed));const r=i.get(e);if(r)return r;const s=Pn.cloneMaterial(t);return Array.isArray(s)||(Pn.setMaterialColor(s,e==="hover"?hh:zl),i.set(e,s)),s}static releaseSharedHighlightMaterials(t){const e=dn.sharedHighlightMaterialsBySource.get(t);e&&(e.forEach(i=>i.dispose()),dn.sharedHighlightMaterialsBySource.delete(t))}createPreviewSubset(t,e){if(t.length===0)return null;const i=(e==null?void 0:e.maxSlots)??1e4,r=(e==null?void 0:e.missingEntity)??"fail",s=new pi;s.name="PreviewSubset",s.userData.previewSubsetGroup=!0;let o=0;for(const a of t){if(o>=i)return Ub(s),null;const l=this.appendEntityOverlayDrawables(a,s,{maxSlots:i-o,mode:"preview",previewStyle:(e==null?void 0:e.style)??"normal"});if(l===0){if(r==="skip")continue;return Ub(s),null}o+=l}return o>0?s:null}get groups(){return[this._lineBatches,this._lineWithIndexBatches,this._line2Batches,this._meshBatches,this._meshWithIndexBatches,this._pointBatches,this._pointSymbolBatches]}unhighlight(t,e){if(e===this._selectedObjects){this.unselect(t);return}e===this._hoverObjects&&this.unhover(t)}appendEntityOverlayDrawables(t,e,i){let r=0;const s=a=>{if(i.mode==="highlight"){this.applyHighlightMaterial(a);return}if(i.mode==="compare"){this.applyCompareOverlayMaterial(a,i.compareColor??2278750);return}this.applyPreviewMaterial(a,i.previewStyle??"normal")};r<i.maxSlots&&this.forEachEntitySlot(t,a=>{if(r>=i.maxSlots)return!0;const l=this.getOriginBatch(a.batchedObjectId);if(!l||!this.hasBatchObjectAt(l))return!1;const c=l.getObjectAt(a.batchId);this.copyHighlightMetadata(l,c),s(c);const u=Ul(c);return u.objectId=t,u.batchedObjectId=a.batchedObjectId,u.disposeGeometryOnRemove=l instanceof xh||l instanceof Gm,u.previewDrawable=i.mode==="preview",c.renderOrder=e.renderOrder,e.add(c),r++,!1});const o=this._unbatchedEntities.get(t);if(o&&r<i.maxSlots){const a=Math.min(o.length,i.maxSlots-r);for(let l=0;l<a;l++){const c=o[l],u=c.clone();this.copyHighlightMetadata(c,u),s(u);const h=Ul(u);h.objectId=t,h.previewDrawable=i.mode==="preview",u.renderOrder=e.renderOrder,e.add(u),r++}}return r}hasBatchObjectAt(t){return typeof t.getObjectAt=="function"}applyPreviewMaterial(t,e){this.hasMaterial(t)&&(t.material=Pn.cloneMaterial(t.material)),t.children.forEach(i=>this.applyPreviewMaterial(i,e))}applyHighlightMaterial(t){if(this.hasMaterial(t)){const e=Pn.cloneMaterial(t.material);Pn.setMaterialColor(e),t.material=e}t.children.forEach(e=>this.applyHighlightMaterial(e))}applyCompareOverlayMaterial(t,e){const i=r=>{if(r instanceof gr){const s=r.material,o=new Pl({color:e,linewidth:s.linewidth,worldUnits:s.worldUnits,dashed:!1});o.resolution.copy(s.resolution),o.depthTest=!0,o.polygonOffset=!0,o.polygonOffsetFactor=-2,o.polygonOffsetUnits=-2,r.material=o}else if(r instanceof Ys||r instanceof Vo)r.material=new wl({color:e,depthTest:!0,polygonOffset:!0,polygonOffsetFactor:-2,polygonOffsetUnits:-2});else if(r instanceof cn)r.material=new Xs({color:e,side:Ei,depthTest:!0,polygonOffset:!0,polygonOffsetFactor:-2,polygonOffsetUnits:-2});else if(r instanceof ur){const s=r.material;r.material=new Op({color:e,size:s.size,sizeAttenuation:s.sizeAttenuation,depthTest:!0})}r.children.forEach(s=>i(s))};i(t)}rebindCompareOverlaySharedBuffers(){if(this._compareOverlay.children.length!==0)for(const t of this._compareOverlay.children){const e=Ul(t);if(e.batchedObjectId==null||e.disposeGeometryOnRemove)continue;const i=this.getOriginBatch(e.batchedObjectId),r=this.getDrawableGeometry(t);i==null||r==null||i instanceof Gm||r.attributes!==i.geometry.attributes&&(r.index=i.geometry.index,r.attributes=i.geometry.attributes)}}refreshCompareOverlay(){this.clearHighlightGroup(this._compareOverlay),this._compareEnabled&&this._compareRoles.forEach((t,e)=>{this.appendEntityOverlayDrawables(e,this._compareOverlay,{maxSlots:1e4,mode:"compare",compareColor:this.resolveCompareColor(t)})})}syncCompareOverlayForEntity(t){if(this.removeCompareOverlayForEntity(t),!this._compareEnabled)return;const e=this._compareRoles.get(t);e!=null&&this.appendEntityOverlayDrawables(t,this._compareOverlay,{maxSlots:1e4,mode:"compare",compareColor:this.resolveCompareColor(e)})}removeCompareOverlayForEntity(t){const e=this._compareOverlay.children.filter(i=>Ul(i).objectId===t);e.forEach(i=>this.disposeHighlightObject(i)),e.forEach(i=>i.removeFromParent())}getOriginBatch(t){return this._originBatchById.get(t)??this._sharedBatchById.get(t)}copyHighlightMetadata(t,e){cb(t,e)}applyBatchSlotVisibility(t,e){const i=this.getOriginBatch(t.batchedObjectId);i==null||i.setVisibleAt(t.batchId,e)}getBatchItemVisible(t){const e=this.getOriginBatch(t.batchedObjectId);return(e==null?void 0:e.getVisibleAt(t.batchId))??!1}tryAddSharedDrawable(t,e,i){var r;if(en(t).sharesTemplateGeometry!==!0||!this.hasGeometry(t)||!this.hasMaterial(t))return null;const s=t.material;if(Array.isArray(s))return null;const o=this.sharedGeometryKind(t);if(!o)return null;const a=t.geometry;if(!((r=a.getAttribute("position"))!=null&&r.count)||(t.updateWorldMatrix(!0,!1),this.mustBakeSharedDrawable(t,o,a)))return null;const l=t.matrixWorld.clone();(gi(s).drawOrder??0)>=0&&(l.elements[14]+=Db());const c=new H().setFromMatrixPosition(l),u=this.resolveSharedGeometryBatch(a,s,o,c),h=u.addInstance(l,e,i);return{batchedObjectId:u.id,batchId:h}}mustBakeSharedDrawable(t,e,i){const r=t.material;if(Array.isArray(r)||e==="mesh"&&t.matrixWorld.determinant()<0)return!0;if(!(e==="line2"?r.dashed===!0:i.getAttribute("lineDistance")!=null))return!1;const s=Dk(t.matrixWorld);return s==null||Math.abs(s-1)>1e-4}sharedGeometryKind(t){return Pm(t)?"line2":Im(t)?"line":hb(t)?"mesh":db(t)?"points":null}resolveSharedGeometryBatch(t,e,i,r){const s=`${i}:${t.uuid}:${e.id}`;let o=this._sharedGeometryBatches.get(s);o||(o=[],this._sharedGeometryBatches.set(s,o));let a,l=1/0;for(const h of o){if(!sb(h.origin,r))continue;const d=Am(h.origin,r);d<l&&(l=d,a=h)}if(a)return a;let c=this._ownedSharedGeometries.get(t.uuid);c||(c=t.clone(),this._ownedSharedGeometries.set(t.uuid,c));const u=new Gm(c,e,r,i,t.uuid);return this._compareEnabled&&u.setCompareDisplayColors({enabled:!0,baseColor:this._compareBaseColor,deletedColor:this._compareDeletedColor,addedColor:this._compareAddedColor,modifiedColor:this._compareModifiedColor}),o.push(u),this._sharedBatchById.set(u.id,u),this.add(u),u}rebindSharedGeometryMaterial(t,e){const i=[];for(const[r,s]of this._sharedGeometryBatches){const o=[];for(const a of s){if(a.materialId!==t){o.push(a);continue}a.material=e,i.push(a)}o.length===0?this._sharedGeometryBatches.delete(r):o.length!==s.length&&this._sharedGeometryBatches.set(r,o)}for(const r of i){const s=`${r.kind}:${r.sourceUuid}:${e.id}`,o=this._sharedGeometryBatches.get(s);o?o.push(r):this._sharedGeometryBatches.set(s,[r])}}addLine(t,e){const i=t.material,r=this.getMatchedLineBatches(t),s=new H().setFromMatrixPosition(t.matrixWorld);ws(s,i);const o=this.resolveOriginBatch(r,i.id,s,()=>new Hm(dn.INITIAL_LINE_VERTEX_CAPACITY,dn.INITIAL_LINE_INDEX_CAPACITY,this.createOwnedBatchMaterial(i))),a=t.geometry.clone(),l=t.matrixWorld.clone();if(l.setPosition(0,0,0),!He.safeApplyMatrix4(a,l,2))return a.dispose(),null;a.hasAttribute("lineDistance")&&He.recomputeLineDistanceForLineSegments(a);const c=o.addGeometry(a,-1,-1,s);return o.setGeometryInfo(c,e),a.dispose(),{batchedObjectId:o.id,batchId:c}}addLine2(t,e){const i=t.material,r=new H().setFromMatrixPosition(t.matrixWorld);ws(r,i);const s=this.resolveOriginBatch(this._line2Batches,i.id,r,()=>new xh(dn.INITIAL_LINE_VERTEX_CAPACITY,this.createOwnedBatchMaterial(i))),o=t.matrixWorld.clone();o.setPosition(0,0,0);const a=this.cloneLineSegments2Geometry(t,o);if(!a)return null;const l=s.addGeometry(a,-1,r);return s.setGeometryInfo(l,e),a.dispose(),{batchedObjectId:s.id,batchId:l}}addMesh(t,e,i){let r=t.material;t.matrixWorld.determinant()<0&&(r=i.getBackSideVariant(r),t.material=r);const s=this.getMatchedMeshBatches(t),o=new H().setFromMatrixPosition(t.matrixWorld);ws(o,r);const a=this.resolveOriginBatch(s,r.id,o,()=>{const h=gi(r).drawOrder??0,d=new Ib(dn.INITIAL_MESH_VERTEX_CAPACITY,dn.INITIAL_MESH_INDEX_CAPACITY,this.createOwnedBatchMaterial(r));return d.renderOrder=h,d}),l=t.geometry.clone(),c=t.matrixWorld.clone();if(c.setPosition(0,0,0),!He.safeApplyMatrix4(l,c,3))return l.dispose(),null;const u=a.addGeometry(l,-1,-1,o);return a.setGeometryInfo(u,e),l.dispose(),{batchedObjectId:a.id,batchId:u}}addPoint(t,e){const i=t.material,r=new H().setFromMatrixPosition(t.matrixWorld);ws(r,i);const s=this.resolveOriginBatch(this._pointBatches,i.id,r,()=>{const c=new kb(dn.INITIAL_POINT_VERTEX_CAPACITY,this.createOwnedBatchMaterial(i));return c.visible=t.visible,c}),o=t.geometry.clone(),a=t.matrixWorld.clone();if(a.setPosition(0,0,0),!He.safeApplyMatrix4(o,a,2))return o.dispose(),null;const l=s.addGeometry(o,-1,r);return s.setGeometryInfo(l,e),o.dispose(),{batchedObjectId:s.id,batchId:l}}resolveOriginBatch(t,e,i,r){let s=t.get(e);s==null&&(s=[],t.set(e,s));let o,a=1/0;for(const c of s){if(!sb(c.origin,i))continue;const u=c.origin;if(u==null)return c;const h=Am(u,i);h<a&&(a=h,o=c)}if(o)return this.ensureBatchHighlightRenderer(o),o;const l=r();return this._compareEnabled&&l.setCompareDisplayColors({enabled:!0,baseColor:this._compareBaseColor,deletedColor:this._compareDeletedColor,addedColor:this._compareAddedColor,modifiedColor:this._compareModifiedColor}),s.push(l),this._originBatchById.set(l.id,l),this.add(l),this.ensureBatchHighlightRenderer(l),l}repaintForegroundMaterials(t){const e=new Zt(t),i=r=>{gi(r).isForeground===!0&&Pn.setMaterialColor(r,e)};for(const r of this.groups)r.forEach(s=>{s.forEach(o=>{const a=o.material;Array.isArray(a)?a.forEach(i):a&&i(a)})});this._unbatchedObjects.traverse(r=>{if(!("material"in r))return;const s=r.material;Array.isArray(s)?s.forEach(i):s&&i(s)})}repaintBackgroundMaterials(t){const e=new Zt(t),i=r=>{gi(r).isBackgroundFill===!0&&Pn.setMaterialColor(r,e)};for(const r of this.groups)r.forEach(s=>{s.forEach(o=>{const a=o.material;Array.isArray(a)?a.forEach(i):a&&i(a)})});this._unbatchedObjects.traverse(r=>{if(!("material"in r))return;const s=r.material;Array.isArray(s)?s.forEach(i):s&&i(s)})}createOwnedBatchMaterial(t){const e=Pn.cloneMaterial(t);return ab(e,{...gi(t)}),e}ensureBatchHighlightRenderer(t){const e=t._highlightState;e&&ca(t,e)}countBatchContainers(t){let e=0;return t.forEach(i=>{e+=i.length}),e}getBatchedGeometrySize(t){let e=0;return t.forEach(i=>{i.forEach(r=>{e+=this.getGeometrySize(r)})}),e}getBatchedGeometryMappingSize(t){let e=0;return t.forEach(i=>{i.forEach(r=>{e+=r.mappingStats.size})}),e}getMatchedLineBatches(t){if(en(t).isPoint)return this._pointSymbolBatches;{const e=t.geometry.getIndex()!==null;let i=this._lineBatches;return e&&(i=this._lineWithIndexBatches),i}}getMatchedMeshBatches(t){const e=t.geometry.getIndex()!==null;let i=this._meshBatches;return e&&(i=this._meshWithIndexBatches),i}getGeometrySize(t){const e=new Set;let i=0;if(this.hasGeometry(t)){const r=t.geometry;if(Object.keys(r.attributes).forEach(s=>{const o=r.attributes[s],a=this.getAttributeArray(o);a&&!e.has(a.buffer)&&(i+=a.byteLength,e.add(a.buffer))}),r.index){const s=r.index.array;e.has(s.buffer)||(i+=s.byteLength,e.add(s.buffer))}}return i}getUnbatchedStats(){const t={count:0,geometrySize:0,byType:{line:0,mesh:0,point:0,other:0}};return this._unbatchedObjects.children.forEach(e=>{t.count+=1,t.geometrySize+=this.getGeometrySize(e),this.isLineObject(e)?t.byType.line+=1:e instanceof cn?t.byType.mesh+=1:e instanceof ur?t.byType.point+=1:t.byType.other+=1}),t}cloneUnbatchedObject(t){if(this.shouldCloneUnbatchedSubtree(t))return this.cloneUnbatchedSubtree(t);const e=t.clone();if(this.copyWorldMatrixOntoClone(t,e),this.hasMaterial(t)&&this.hasMaterial(e)){const i=t.material,r=this.materialHasTextureMap(i);r?(e.material=this.cloneUnbatchedTexturedMaterial(i),this.hasGeometry(t)&&this.hasGeometry(e)&&(e.geometry=t.geometry.clone())):e.material=i;const s=en(t),o=en(e);o.styleMaterialId=s.styleMaterialId??this.getMaterialId(t.material),o.bboxIntersectionCheck=s.bboxIntersectionCheck,o.sharesTemplateGeometry=r?!1:s.sharesTemplateGeometry,o.bakedWorldMatrix=t.matrixWorld.toArray(new Array(16)),s.textEntityTraits&&(o.textEntityTraits=ki.cloneEntityTraits(s.textEntityTraits))}return this.finalizeUnbatchedLineClone(e),e}materialHasTextureMap(t){return Array.isArray(t)?t.some(e=>this.materialHasTextureMap(e)):!!t.map}cloneUnbatchedTexturedMaterial(t){if(Array.isArray(t))return t.map(r=>this.cloneUnbatchedTexturedMaterial(r));const e=t.clone(),i=t.map;if(i){const r=i.clone();r.needsUpdate=!0,e.map=r}return e}finalizeUnbatchedLineClone(t){if(!this.isLineObject(t))return;t.frustumCulled=!1;const e=this.getDrawableGeometry(t);e&&(He.safeComputeBoundingBox(e),He.safeComputeBoundingSphere(e))}getDrawableGeometry(t){if(t instanceof gr||t instanceof cn||t instanceof Ys||t instanceof Vo||t instanceof ur)return t.geometry}shouldCloneUnbatchedSubtree(t){return t.children.length===0?!1:t instanceof xs?!0:!this.hasGeometry(t)}cloneEntityAsPlainShell(t){const e=new wn;this.copyWorldMatrixOntoClone(t,e),e.userData={...t.userData};const i=en(t),r=en(e);r.noBatch=!0,r.bboxIntersectionCheck=i.bboxIntersectionCheck,r.bakedWorldMatrix=t.matrixWorld.toArray(new Array(16)),i.textEntityTraits&&(r.textEntityTraits=ki.cloneEntityTraits(i.textEntityTraits));for(const s of t.children)if(s instanceof xs)for(const o of s.children)e.add(o.clone(!0));else e.add(s.clone(!0));return e.traverse(s=>{if(!this.hasMaterial(s))return;const o=en(s);o.styleMaterialId==null&&(o.styleMaterialId=this.getMaterialId(s.material))}),e}cloneUnbatchedSubtree(t){if(t instanceof xs)return this.cloneEntityAsPlainShell(t);const e=t.clone(!0);this.copyWorldMatrixOntoClone(t,e);const i=en(t),r=en(e);return r.bboxIntersectionCheck=i.bboxIntersectionCheck,r.bakedWorldMatrix=t.matrixWorld.toArray(new Array(16)),i.textEntityTraits&&(r.textEntityTraits=ki.cloneEntityTraits(i.textEntityTraits)),e.traverse(s=>{if(!this.hasMaterial(s))return;const o=en(s);o.styleMaterialId==null&&(o.styleMaterialId=this.getMaterialId(s.material))}),e}copyWorldMatrixOntoClone(t,e){t.updateMatrixWorld(!0),e.matrixAutoUpdate=!1,e.matrix.copy(t.matrixWorld),e.matrixWorld.copy(t.matrixWorld),e.matrixWorldNeedsUpdate=!1}cloneLineSegments2Geometry(t,e){const i=t.geometry,r=i.getAttribute("instanceStart"),s=i.getAttribute("instanceEnd"),o=r.count,a=[];for(let c=0;c<o;c++)Es.fromBufferAttribute(r,c).applyMatrix4(e),eo.fromBufferAttribute(s,c).applyMatrix4(e),!(!Number.isFinite(Es.x)||!Number.isFinite(Es.y)||!Number.isFinite(Es.z)||!Number.isFinite(eo.x)||!Number.isFinite(eo.y)||!Number.isFinite(eo.z))&&a.push(Es.x,Es.y,Es.z,eo.x,eo.y,eo.z);if(a.length<6)return null;const l=new ms;return l.setPositions(new Float32Array(a)),i.hasAttribute("instanceColorStart")&&(l.setAttribute("instanceColorStart",i.getAttribute("instanceColorStart").clone()),l.setAttribute("instanceColorEnd",i.getAttribute("instanceColorEnd").clone())),He.safeComputeBoundingBox(l),He.safeComputeBoundingSphere(l),l}disposeObject(t){t.removeFromParent(),this.hasGeometry(t)&&!en(t).sharesTemplateGeometry&&t.geometry.dispose(),t.children.forEach(e=>this.disposeObject(e))}clearHighlightGroup(t){[...t.children].forEach(e=>this.disposeHighlightObject(e)),t.clear()}disposeHighlightObject(t){Vm(t)}unionUnbatchedObjectBounds(t,e,i){const r=this.getDrawableGeometry(t);if(r){if(He.safeComputeBoundingBox(r),!r.boundingBox)return;i.copy(r.boundingBox).applyMatrix4(t.matrixWorld),e.union(i);return}for(const s of t.children)s.visible!==!1&&this.unionUnbatchedObjectBounds(s,e,i)}isUnbatchedDrawableIntersecting(t,e){return en(t).bboxIntersectionCheck?this.isUnbatchedBboxIntersecting(t,e):e.intersectObject(t,!0).length>0}isUnbatchedBboxIntersecting(t,e){t.updateMatrixWorld(!0),Gl.makeEmpty();const i=this.getDrawableGeometry(t);if(i){if(He.safeComputeBoundingBox(i),!i.boundingBox)return!1;Gl.copy(i.boundingBox).applyMatrix4(t.matrixWorld)}else if(this.unionUnbatchedObjectBounds(t,Gl,Uk),Gl.isEmpty())return!1;return e.ray.intersectBox(Gl,Es)!==null}hasMaterial(t){return"material"in t}hasGeometry(t){return"geometry"in t}getAttributeArray(t){return"array"in t&&t.array?t.array:"data"in t&&t.data&&t.data.array?t.data.array:null}isLineObject(t){return t instanceof Vo?!0:!!t.isLineSegments2}getMaterialId(t){var e;return Array.isArray(t)?((e=t[0])==null?void 0:e.id)??-1:t.id}};Ms.INITIAL_LINE_VERTEX_CAPACITY=128,Ms.INITIAL_LINE_INDEX_CAPACITY=256,Ms.INITIAL_MESH_VERTEX_CAPACITY=128,Ms.INITIAL_MESH_INDEX_CAPACITY=256,Ms.INITIAL_POINT_VERTEX_CAPACITY=16,Ms.sharedHighlightMaterialsBySource=new WeakMap,Ms.onSourceMaterialDisposed=n=>{Ms.releaseSharedHighlightMaterials(n.target)};function Ub(n){Vm(n)}function Vm(n){for(const t of[...n.children])Vm(t);Ok(n)}function Ok(n){if(Bk(n)){const t=n.material;Array.isArray(t)?t.forEach(e=>e.dispose()):t.dispose()}Nk(n)&&Ul(n).disposeGeometryOnRemove&&n.geometry.dispose()}function Bk(n){return"material"in n&&n.material!=null}function Nk(n){return"geometry"in n&&n.geometry!=null}function Dk(n){const t=n.elements,e=Math.hypot(t[0],t[1],t[2]),i=Math.hypot(t[4],t[5],t[6]),r=Math.hypot(t[8],t[9],t[10]),s=Math.max(e,i,r),o=Math.min(e,i,r);return s===0||(s-o)/s>1e-4?null:e}const Es=new H,eo=new H,Gl=new Re,Uk=new Re;function zk(n,t=Gi){const e={u_startColor:{value:new Zt(n.startColor)},u_endColor:{value:new Zt(n.endColor)},u_angle:{value:n.angle},u_shift:{value:n.shift},u_gradientType:{value:n.gradientType}},i=`
|
|
4683
|
+
#include <tonemapping_fragment>`),injected:!0}:t.includes("gl_FragColor = vec4( diffuseColor.rgb, alpha );")?{source:t.replace("gl_FragColor = vec4( diffuseColor.rgb, alpha );","gl_FragColor = vec4( applyBatchHighlight(diffuseColor.rgb), alpha );"),injected:!0}:t.includes("gl_FragColor = vec4( diffuseColor.rgb, opacity );")?{source:t.replace("gl_FragColor = vec4( diffuseColor.rgb, opacity );","gl_FragColor = vec4( applyBatchHighlight(diffuseColor.rgb), opacity );"),injected:!0}:{source:n,injected:!1}}function bb(n){var t;if(typeof process<"u"&&((t=process.env)==null?void 0:t.NODE_ENV)==="production")return;const e=n.type;yb.has(e)||(yb.add(e),console.warn(`[AcTrBatchHighlight] Could not inject highlight shader for material type "${e}". Highlight tinting may be skipped.`))}function ck(n,t){n.uniforms.u_highlightMask=t.u_highlightMask,n.uniforms.u_highlightMaskSize=t.u_highlightMaskSize,n.uniforms.u_highlightSelectColor=t.u_highlightSelectColor,n.uniforms.u_highlightHoverColor=t.u_highlightHoverColor,n.uniforms.u_compareEnabled=t.u_compareEnabled,n.uniforms.u_compareBaseColor=t.u_compareBaseColor,n.uniforms.u_compareDeletedColor=t.u_compareDeletedColor,n.uniforms.u_compareAddedColor=t.u_compareAddedColor,n.uniforms.u_compareModifiedColor=t.u_compareModifiedColor}function Sb(n,t){n instanceof un&&(n.uniforms.u_highlightMask=t.u_highlightMask,n.uniforms.u_highlightMaskSize=t.u_highlightMaskSize,n.uniforms.u_highlightSelectColor=t.u_highlightSelectColor,n.uniforms.u_highlightHoverColor=t.u_highlightHoverColor,n.uniforms.u_compareEnabled=t.u_compareEnabled,n.uniforms.u_compareBaseColor=t.u_compareBaseColor,n.uniforms.u_compareDeletedColor=t.u_compareDeletedColor,n.uniforms.u_compareAddedColor=t.u_compareAddedColor,n.uniforms.u_compareModifiedColor=t.u_compareModifiedColor)}function uk(n){n.needsUpdate=!0,n instanceof un&&(n.uniformsNeedUpdate=!0)}function hk(n){const t=ch(n),e=vb(n);if(!t.batchHighlightPatched){if(t.batchHighlightPatched=!0,n instanceof un){n.vertexShader=_b(n.vertexShader);const i=xb(n.fragmentShader);n.fragmentShader=i.source,i.injected||bb(n)}else{const i=n.onBeforeCompile;n.onBeforeCompile=(s,o)=>{i==null||i.call(n,s,o),ck(s,e),s.vertexShader=_b(s.vertexShader);const a=xb(s.fragmentShader);s.fragmentShader=a.source,a.injected||bb(n)};const r=n.customProgramCacheKey;n.customProgramCacheKey=()=>`${r.call(n)}|batchHighlightCompare`}Sb(n,e),uk(n);return}Sb(n,e)}function wb(n,t){const e=Array.isArray(n)?n:[n],i=t.uploadMaskTexture();for(const r of e){hk(r);const s=vb(r);s.u_highlightMask.value=i;const o=t.getMaskTextureDimensions();s.u_highlightMaskSize.value.set(o.width,o.height),s.u_highlightSelectColor.value.copy(zl),s.u_highlightHoverColor.value.copy(hh),s.u_compareEnabled.value=t.compareEnabled?1:0,s.u_compareBaseColor.value.copy(t.compareBaseColor),s.u_compareDeletedColor.value.copy(t.compareDeletedColor),s.u_compareAddedColor.value.copy(t.compareAddedColor),s.u_compareModifiedColor.value.copy(t.compareModifiedColor),r instanceof un&&(r.uniformsNeedUpdate=!0)}}function ca(n,t){const e=n.userData;if(e.batchHighlightRendererInstalled)return;e.batchHighlightRendererInstalled=!0;const i=n.onBeforeRender;n.onBeforeRender=(r,s,o,a,l,c)=>{i==null||i.call(n,r,s,o,a,l,c),l&&wb(l,t)}}function dk(n){return(Array.isArray(n)?n:[n]).some(t=>ch(t).batchHighlightPatched)}function fk(n){const t=n.length;let e=0;return t>0&&(e=Cm.estimateObjectSize(n[0])),{count:t,size:t*e}}function Um(n,t,e,i){for(const r in t.attributes){if(r===la)continue;const s=t.getAttribute(r),{array:o,itemSize:a,normalized:l}=s,c=new o.constructor(e*a),u=new We(c,a,l);n.setAttribute(r,u)}if(fh(n,e),i!=null&&t.getIndex()!==null){const r=e>65535?new Uint32Array(i):new Uint16Array(i);n.setIndex(new We(r,1))}}function zm(n,t,e,i){if(i&&!!t.getIndex()!=!!n.getIndex())throw new Error(`${e}: All geometries must consistently have "index".`);for(const r in n.attributes){if(r===la)continue;if(!t.hasAttribute(r))throw new Error(`${e}: Added geometry missing "${r}". All geometries must have consistent attributes.`);const s=t.getAttribute(r),o=n.getAttribute(r);if(s.itemSize!==o.itemSize||s.normalized!==o.normalized)throw new Error(`${e}: All attributes must have a consistent itemSize and normalized value.`)}}function ph(n,t,e,i){let r,s=e;return n.length>0?(n.sort(Y8),r=n.shift(),t[r]=i):(r=e,s++,t.push(i)),{geometryId:r,geometryCount:s}}function ua(n,t){return n===-1?t:n}function mh(){return{boundingBox:null,flags:j8}}function gh(n){const{typeName:t,maxVertexCount:e,vertexStart:i,reservedVertexCount:r,maxIndexCount:s,indexStart:o=-1,reservedIndexCount:a=0}=n;if(s!=null&&o!==-1&&o+a>s||i+r>e)throw new Error(`${t}: Reserved space request exceeds the maximum buffer size.`)}function ha(n){const{currentMaxCount:t,nextStart:e,requiredCount:i,growthFactor:r}=n,s=e+i;return s<=t?t:Math.ceil(s*r)}function pk(n,t,e){return n>=t.length||!En(t[n].flags)?!1:(t[n].flags=fb.None,e.push(n),!0)}function mk(n,t,e){if(n<0||n>=t.length||!En(t[n].flags))throw new Error(`${e}: Invalid geometryId ${n}. Geometry is either out of range or has been deleted.`)}function gk(n,t,e,i){for(const r in n.attributes){if(r===la)continue;const s=t.getAttribute(r),o=n.getAttribute(r);Rm(s,o,e);const a=s.itemSize;for(let l=s.count,c=i;l<c;l++){const u=e+l;for(let h=0;h<a;h++)o.setComponent(u,h,0)}o.needsUpdate=!0,o.addUpdateRange(e*a,i*a)}}function yk(n,t,e,i,r){const s=n.getIndex(),o=t.getIndex();if(!(!s||!o)){for(let a=0;a<o.count;a++)s.setX(i+a,e+o.getX(a));for(let a=o.count,l=r;a<l;a++)s.setX(i+a,e);s.needsUpdate=!0,s.addUpdateRange(i,r)}}function Fm(n,t,e,i,r,s){const o=t.getIndex()!==null,a=e.getIndex();if(o&&a&&a.count>n.reservedIndexCount||e.attributes.position.count>n.reservedVertexCount)throw new Error(`${i}: Reserved space not large enough for provided geometry.`);const l=n.vertexStart,c=n.reservedVertexCount;if(n.vertexCount=e.getAttribute("position").count,gk(t,e,l,c),o&&a){const d=n;d.indexCount=a.count,yk(t,e,l,d.indexStart,d.reservedIndexCount)}let u=!0;const h=s??n.boundingBox;return h!=null&&(e.computeBoundingBox(),e.boundingBox!=null&&e.boundingBox.equals(h)&&(u=!1)),u&&(n.boundingBox=null),En(n.flags)&&(delete n.hiddenDrawSnapshot,Js(n.flags)||Bm(t,n,!1)),gb(t,l,c,r),u}const vk=new Re;function _k(n,t,e){const i=n??new Re;i.makeEmpty();const r=new Re;for(let s=0,o=t.length;s<o;s++){if(!En(t[s].flags))continue;const a=e(s,r);a&&i.union(a)}return i}function xk(n,t,e){const i=n??new zn;i.makeEmpty();const r=new zn;for(let s=0,o=t.length;s<o;s++)En(t[s].flags)&&(e(s,r),i.union(r));return i}function bk(n,t,e){n.material=e,n.geometry.index=t.index,n.geometry.attributes=t.attributes,n.geometry.boundingBox===null&&(n.geometry.boundingBox=new Re),n.geometry.boundingSphere===null&&(n.geometry.boundingSphere=new zn)}function Sk(n,t,e,i,r){n.geometry.setDrawRange(t,e),n.geometry.boundingBox.copy(i),n.geometry.boundingSphere.copy(r)}function wk(n){n.geometry.index=null,n.geometry.attributes={},n.geometry.setDrawRange(0,1/0)}function yh(n,t){return class extends n{constructor(){super(...arguments),this.boundingBox=null,this.boundingSphere=null,this._geometryInfo=[],this._availableGeometryIds=[],this._geometryCount=0,this._raycastObject=t.createObject(),this._batchIntersects=[],this._box=new Re,this._sphere=new zn,this._vector=new H,this._typedBatchIntersects=this._batchIntersects,this._highlightState=new sk}get mappingStats(){return fk(this._geometryInfo)}validateGeometryId(e){mk(e,this._geometryInfo,t.typeName)}getGeometryRangeAt(e){return this.validateGeometryId(e),this._geometryInfo[e]}computeBoundingBox(){this.boundingBox=_k(this.boundingBox,this._geometryInfo,(e,i)=>this.computeBoundingBoxAt(e,i))}computeBoundingBoxAt(e,i){return this.getBoundingBoxAt(e,i)}computeBoundingSphereAt(e,i){const r=this.computeBoundingBoxAt(e,vk);return r===null?null:r.getBoundingSphere(i)}unionActiveVisibleBoundingBoxInto(e,i){const r=this;r.updateMatrixWorld(!0);for(let s=0;s<this._geometryCount;s++){const o=this._geometryInfo[s];!En(o.flags)||!Js(o.flags)||i!=null&&i.excludeObjectIds&&o.objectId&&i.excludeObjectIds.has(o.objectId)||i!=null&&i.includeObjectIds&&o.objectId&&!i.includeObjectIds.has(o.objectId)||this.computeBoundingBoxAt(s,this._box)&&(this._box.applyMatrix4(r.matrixWorld),e.union(this._box))}}computeAggregateBoundingSphere(e){return xk(e,this._geometryInfo,(i,r)=>this.computeBoundingSphereAt(i,r))}computeBoundingSphere(){const e=this.boundingSphere??new zn;e.makeEmpty(),this.boundingSphere=this.computeAggregateBoundingSphere(e)??e}setVisibleAt(e,i){if(this.validateGeometryId(e),Js(this._geometryInfo[e].flags)===i)return this;const r=this._geometryInfo[e];return Bm(this.geometry,r,i)&&(r.flags=$8(r.flags,i),r.boundingBox=null),this}getVisibleAt(e){return this.validateGeometryId(e),Js(this._geometryInfo[e].flags)}setHighlightAt(e,i,r){try{this.validateGeometryId(e)}catch{return!1}const s=this._highlightState.setHighlight(e,i,r);return s&&ca(this,this._highlightState),s}setCompareRoleAt(e,i){try{this.validateGeometryId(e)}catch{return!1}const r=this._highlightState.setCompareRole(e,i);return(r||this._highlightState.compareEnabled)&&ca(this,this._highlightState),r}applyPackedCompareRoles(e){for(let i=0;i<this._geometryInfo.length;i++){const r=this._geometryInfo[i];if(!En(r.flags))continue;const s=r.objectId,o=s!=null&&s!==""?e.get(String(s))??null:null;this.setCompareRoleAt(i,o)}return this.flushHighlightMask(),this}setCompareDisplayColors(e){return this._highlightState.compareEnabled=e.enabled,e.baseColor!=null&&this._highlightState.compareBaseColor.setHex(e.baseColor),e.deletedColor!=null&&this._highlightState.compareDeletedColor.setHex(e.deletedColor),e.addedColor!=null&&this._highlightState.compareAddedColor.setHex(e.addedColor),e.modifiedColor!=null&&this._highlightState.compareModifiedColor.setHex(e.modifiedColor),this._highlightState.dirty=!0,ca(this,this._highlightState),this.flushHighlightMask(),this}flushHighlightMask(){this._highlightState.setAddressableSlotCount(this._geometryInfo.length);const e=this._highlightState.dirty;return e&&this._highlightState.uploadMaskTexture(),this.material&&(this._highlightState.hasAnyHighlight()||this._highlightState.needsCompareUniforms()||e&&dk(this.material))&&wb(this.material,this._highlightState),this}clearHighlightSlot(e){return this._highlightState.clearSlot(e)&&ca(this,this._highlightState),this}clearHighlightState(){return this._highlightState.clearAll()&&ca(this,this._highlightState),this}deleteGeometry(e){return pk(e,this._geometryInfo,this._availableGeometryIds)?(this.clearHighlightSlot(e),this):this}getObjectAt(e){const i=t.createObject();this._initializeRaycastObject(i);const r=this._geometryInfo[e],{start:s,count:o}=t.getDrawRange(this,r);return this._setRaycastObjectInfo(i,e,s,o),i}intersectWith(e,i,r){this._initializeRaycastObject(this._raycastObject),this._intersectWith(e,i,r),this._resetRaycastObjectInfo(this._raycastObject)}raycast(e,i){this._initializeRaycastObject(this._raycastObject);for(let r=0,s=this._geometryInfo.length;r<s;r++)this._intersectWith(r,e,i);this._resetRaycastObjectInfo(this._raycastObject)}dispose(){return this.geometry.dispose(),this}_initializeRaycastObject(e){bk(e,this.geometry,this.material),e.position.copy(this.position),e.quaternion.copy(this.quaternion),e.scale.copy(this.scale),e.updateMatrix(),e.updateMatrixWorld(!0)}_setRaycastObjectInfo(e,i,r,s){this.computeBoundingBoxAt(i,this._box),this._box.getBoundingSphere(this._sphere),Sk(e,r,s,this._box,this._sphere)}_resetRaycastObjectInfo(e){wk(e)}_intersectWith(e,i,r){const s=this._geometryInfo[e];if(Js(s.flags))if(s.bboxIntersectionCheck){if(this.computeBoundingBoxAt(e,this._box),this._box.applyMatrix4(this.matrixWorld),i.ray.intersectBox(this._box,this._vector)){const o=i.ray.origin.distanceTo(this._vector);r.push({distance:o,point:this._vector.clone(),object:this,face:null,faceIndex:void 0,uv:void 0,batchId:e,objectId:s.objectId})}}else{const{start:o,count:a}=t.getDrawRange(this,s);this._setRaycastObjectInfo(this._raycastObject,e,o,a),this._raycastObject.raycast(i,this._batchIntersects);for(let l=0,c=this._typedBatchIntersects.length;l<c;l++){const u=this._typedBatchIntersects[l];u.object=this,u.batchId=e,u.objectId=s.objectId,r.push(u)}this._batchIntersects.length=0}}}}const Fl=new Re,Hn=new H,Mk=new Re,Ek=yh(Ys,{typeName:"AcTrBatchedLine",createObject:()=>new Ys,getDrawRange:(n,t)=>n.geometry.index!=null?{start:t.indexStart,count:t.indexCount}:{start:t.vertexStart,count:t.vertexCount}}),Mb=class My extends Ek{constructor(t=1e3,e=t*2,i){super(new Xe,i),this._nextIndexStart=0,this._nextVertexStart=0,this._geometryInitialized=!1,this.frustumCulled=!1,this._maxVertexCount=t,this._maxIndexCount=e}get geometryCount(){return this._geometryCount}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}get origin(){return this._origin}_initializeGeometry(t){this._geometryInitialized===!1&&(Um(this.geometry,t,this._maxVertexCount,this._maxIndexCount),this._geometryInitialized=!0)}_validateGeometry(t){zm(this.geometry,t,"AcTrBatchedLine",!0)}_resizeSpaceIfNeeded(t){const e=t.getIndex(),i=e==null?this._maxIndexCount:ha({currentMaxCount:this._maxIndexCount,nextStart:this._nextIndexStart,requiredCount:e.count,growthFactor:My.GROWTH_FACTOR}),r=t.getAttribute("position"),s=r==null?this._maxVertexCount:ha({currentMaxCount:this._maxVertexCount,nextStart:this._nextVertexStart,requiredCount:r.count,growthFactor:My.GROWTH_FACTOR});(i>this._maxIndexCount||s>this._maxVertexCount)&&this.setGeometrySize(s,i)}reset(){this.boundingBox=null,this.boundingSphere=null,this._geometryInfo=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._geometryInfo.length=0,this._origin=void 0,this.position.set(0,0,0),this._geometryInitialized=!1,this.geometry.dispose()}getUserData(){const t=[];return this._geometryInfo.forEach(e=>{t.push({position:e.position,objectId:e.objectId,bboxIntersectionCheck:e.bboxIntersectionCheck})}),t}resetGeometry(t,e=0){const i=this.getUserData();this.reset();const r=_s.instance;i.forEach(s=>{if(s.position){const o=r.create(t,s.position,e);if(o.line){const a=new H(s.position.x,s.position.y,s.position.z??0),l=this.addGeometry(o.line,-1,-1,a);this.setGeometryInfo(l,s)}}})}addGeometry(t,e=-1,i=-1,r=new H){this.rebaseGeometryInPlace(t,r),this._initializeGeometry(t),this._validateGeometry(t),this._resizeSpaceIfNeeded(t);const s=t.getAttribute("position").count,o=t.getIndex(),a={vertexStart:this._nextVertexStart,vertexCount:-1,reservedVertexCount:ua(e,s),indexStart:o?this._nextIndexStart:-1,indexCount:-1,reservedIndexCount:o?ua(i,o.count):0,...mh()};gh({typeName:"AcTrBatchedLine",maxVertexCount:this._maxVertexCount,vertexStart:a.vertexStart,reservedVertexCount:a.reservedVertexCount,maxIndexCount:this._maxIndexCount,indexStart:a.indexStart,reservedIndexCount:a.reservedIndexCount});const{geometryId:l,geometryCount:c}=ph(this._availableGeometryIds,this._geometryInfo,this._geometryCount,a);return this._geometryCount=c,this.setGeometryAt(l,t,null),this._nextIndexStart=a.indexStart+a.reservedIndexCount,this._nextVertexStart=a.vertexStart+a.reservedVertexCount,this._syncDrawRange(),l}rebaseGeometryInPlace(t,e){const i=t.getAttribute("position");if(!i)return;if(!this._origin){He.safeComputeBoundingBox(t);const o=t.boundingBox?t.boundingBox.getCenter(new H):new H;this._origin=o.add(e.clone()),this.position.copy(this._origin)}const r=this._origin;if(!r)return;const s=i.array;if(s instanceof Float32Array){for(let o=0;o<s.length;o+=3)s[o]=s[o]+e.x-r.x,s[o+1]=s[o+1]+e.y-r.y,s[o+2]=s[o+2]+e.z-r.z;i.needsUpdate=!0;return}for(let o=0;o<i.count;o++)i.setXYZ(o,i.getX(o)+e.x-r.x,i.getY(o)+e.y-r.y,i.getZ(o)+e.z-r.z);i.needsUpdate=!0}setGeometryInfo(t,e){if(t>=this._geometryCount)throw new Error("AcTrBatchedLine: Maximum geometry count reached.");const i=this._geometryInfo[t],r=e.position;r&&(i.position={...r}),i.objectId=e.objectId,i.bboxIntersectionCheck=e.bboxIntersectionCheck}setGeometryAt(t,e,i=this.computeBoundingBoxAt(t,Mk)){if(t>=this._geometryCount)throw new Error("AcTrBatchedLine: Maximum geometry count reached.");this._validateGeometry(e);const r=this.geometry,s=this._geometryInfo[t];return Fm(s,r,e,"AcTrBatchedLine",t,i),t}ensureLineDistanceAttribute(){const t=this.geometry;if(t.hasAttribute("lineDistance"))return;const e=Array.isArray(this.material)?this.material[0]:this.material;if(e==null||!He.hasPatternLineShader(e))return;const i=t.getAttribute("position");if(!i)return;const r=t.getIndex();let s=2,o=2;for(let f=0;f<this._geometryCount;f++){const p=this._geometryInfo[f];En(p.flags)&&(s=Math.max(s,p.vertexCount),o=Math.max(o,p.indexCount))}const a=i.itemSize,l=new Float32Array(i.count),c=new Xe,u=new Float32Array(s*a),h=r?new Uint32Array(o):void 0;for(let f=0;f<this._geometryCount;f++){const p=this._geometryInfo[f];if(!En(p.flags))continue;const g=p.vertexCount;if(g<2)continue;if(u.set(i.array.subarray(p.vertexStart*a,(p.vertexStart+g)*a),0),c.setAttribute("position",new We(u.subarray(0,g*a),a)),h&&r){for(let m=0;m<p.indexCount;m++)h[m]=r.array[p.indexStart+m]-p.vertexStart;c.setIndex(new We(h.subarray(0,p.indexCount),1))}He.computeSegmentLineDistances(c);const y=c.getAttribute("lineDistance");l.set(y.array,p.vertexStart)}const d=new an(l,1);d.needsUpdate=!0,t.setAttribute("lineDistance",d)}optimize(){const t=this.geometry,e=t.index!==null,i=t.attributes,r=t.index;let s=0,o=0;const a=this._geometryInfo.map((l,c)=>({info:l,id:c})).filter(l=>En(l.info.flags)).sort((l,c)=>l.info.vertexStart-c.info.vertexStart);for(const{info:l}of a){const c=l.vertexCount,u=e?l.indexCount:0,h=l.vertexStart,d=s,f=d-h;if(f!==0&&c>0)for(const p in i){const g=i[p],{array:y,itemSize:m}=g;y.copyWithin(d*m,h*m,(h+c)*m),g.addUpdateRange(d*m,c*m),g.needsUpdate=!0}if(e&&r&&u>0){const p=l.indexStart,g=o,y=r.array;if(f!==0)for(let m=p;m<p+u;m++)y[m]+=f;p!==g&&y.copyWithin(g,p,p+u),r.addUpdateRange(g,u),r.needsUpdate=!0,l.indexStart=g}l.vertexStart=d,s+=l.reservedVertexCount,o+=l.reservedIndexCount}if(e&&r){const l=r.array;for(let c=o;c<l.length;c++)l[c]=0;r.needsUpdate=!0}return e?t.setDrawRange(0,o):t.setDrawRange(0,s),this._nextVertexStart=s,this._nextIndexStart=o,this._syncDrawRange(),this._availableGeometryIds.length=0,dh(t,this._geometryInfo),this}getBoundingBoxAt(t,e){if(t>=this._geometryCount)return null;const i=this.geometry,r=this._geometryInfo[t];if(r.boundingBox===null){const s=new Re,o=i.index,a=i.attributes.position,{start:l,count:c}=o!=null?{start:r.indexStart,count:r.indexCount}:{start:r.vertexStart,count:r.vertexCount};for(let u=l,h=l+c;u<h;u++){let d=u;o&&(d=o.getX(d)),s.expandByPoint(Hn.fromBufferAttribute(a,d))}r.boundingBox=s}return e.copy(r.boundingBox),e}getBoundingSphereAt(t,e){return t>=this._geometryCount?null:(this.getBoundingBoxAt(t,Fl),Fl.getBoundingSphere(e),e)}computeBoundingBoxAt(t,e){if(t>=this._geometryCount)return null;const i=this.geometry,r=this._geometryInfo[t],s=i.index,o=i.attributes.position,{start:a,count:l}=s!=null?{start:r.indexStart,count:r.indexCount}:{start:r.vertexStart,count:r.vertexCount};if(e.makeEmpty(),o.itemSize===3&&!o.normalized&&(s==null||s.itemSize===1&&!s.normalized)){const c=o.array,u=s==null?void 0:s.array;for(let h=a,d=a+l;h<d;h++){const f=(u==null?h:u[h])*3;e.expandByPoint(Hn.set(c[f],c[f+1],c[f+2]))}return e}for(let c=a,u=a+l;c<u;c++){let h=c;s&&(h=s.getX(h)),e.expandByPoint(Hn.fromBufferAttribute(o,h))}return e}computeAggregateBoundingSphere(t){const e=this.geometry,i=e.index,r=e.attributes.position;if(!r)return null;let s=1/0,o=1/0,a=1/0,l=-1/0,c=-1/0,u=-1/0;const h=r.itemSize===3&&!r.normalized&&(i==null||i.itemSize===1&&!i.normalized),d=r.array,f=i==null?void 0:i.array;for(let p=0;p<this._geometryCount;p++){const g=this._geometryInfo[p];if(!En(g.flags))continue;const{start:y,count:m}=i!=null?{start:g.indexStart,count:g.indexCount}:{start:g.vertexStart,count:g.vertexCount};if(h)for(let v=y,x=y+m;v<x;v++){const _=(f==null?v:f[v])*3,b=d[_],w=d[_+1],C=d[_+2];b<s&&(s=b),w<o&&(o=w),C<a&&(a=C),b>l&&(l=b),w>c&&(c=w),C>u&&(u=C)}else for(let v=y,x=y+m;v<x;v++){let _=v;i&&(_=i.getX(_)),Hn.fromBufferAttribute(r,_),Hn.x<s&&(s=Hn.x),Hn.y<o&&(o=Hn.y),Hn.z<a&&(a=Hn.z),Hn.x>l&&(l=Hn.x),Hn.y>c&&(c=Hn.y),Hn.z>u&&(u=Hn.z)}}return s>l?(t.makeEmpty(),t):(Fl.min.set(s,o,a),Fl.max.set(l,c,u),Fl.getBoundingSphere(t))}getGeometryAt(t){return this.validateGeometryId(t),this._geometryInfo[t]}setGeometrySize(t,e){const i=this.geometry;i.dispose(),this._maxVertexCount=t,this._maxIndexCount=e,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Xe,this._initializeGeometry(i));const r=this.geometry;i.index&&Qs(i.index.array,r.index.array);for(const s in i.attributes)Qs(i.attributes[s].array,r.attributes[s].array);this._syncDrawRange()}getObjectAt(t){const e=super.getObjectAt(t);return e.position.copy(this.position),e}_initializeRaycastObject(t){super._initializeRaycastObject(t),t.position.copy(this.position),t.updateMatrixWorld(!0)}_syncDrawRange(){const t=this.geometry;t.index?t.setDrawRange(0,this._nextIndexStart):t.setDrawRange(0,this._nextVertexStart)}copy(t){var e;return super.copy(t),this.geometry=t.geometry.clone(),this.boundingBox=t.boundingBox!==null?t.boundingBox.clone():null,this.boundingSphere=t.boundingSphere!==null?t.boundingSphere.clone():null,this._geometryInfo=t._geometryInfo.map(i=>({...i,boundingBox:i.boundingBox!==null?i.boundingBox.clone():null})),this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._geometryCount=t._geometryCount,this._origin=(e=t._origin)==null?void 0:e.clone(),this}};Mb.GROWTH_FACTOR=1.25;let Hm=Mb;const bs=new Re,_n=new H,Gn=new H,vh=new H,_h=new H,Eb=new H,Ab=new H,Hl=[],Ss=new gr(new ms),Ak=yh(gr,{typeName:"AcTrBatchedLine2",createObject:()=>new gr(new ms),getDrawRange:(n,t)=>({start:t.vertexStart,count:t.vertexCount})}),Cb=class gM extends Ak{constructor(t=1e3,e){super(new ms,e),this._nextSegmentStart=0,this._geometryInitialized=!1,this.frustumCulled=!1,this._maxSegmentCount=t}get geometryCount(){return this._geometryCount}get unusedSegmentCount(){return this._maxSegmentCount-this._nextSegmentStart}get origin(){return this._origin}_initializeGeometry(t){this._geometryInitialized||(this.geometry.setPositions(new Float32Array(this._maxSegmentCount*6)),fh(this.geometry,this._maxSegmentCount),this._copyStaticAttributes(t),this._isDashedMaterial()&&this._ensureDistanceAttributes(),this._geometryInitialized=!0)}_copyStaticAttributes(t,e=this.geometry){const i=e,r=t.getIndex();r&&i.setIndex(r.clone());for(const s in t.attributes)s==="instanceStart"||s==="instanceEnd"||s==="slotId"||s==="instanceDistanceStart"||s==="instanceDistanceEnd"||i.setAttribute(s,t.getAttribute(s).clone())}_isDashedMaterial(){var t;return((t=this.material)==null?void 0:t.dashed)===!0}_ensureDistanceAttributes(){const t=this.geometry;if(t.getAttribute("instanceDistanceStart"))return;const e=new Float32Array(this._maxSegmentCount*2),i=new Lu(e,2,1);t.setAttribute("instanceDistanceStart",new jn(i,1,0)),t.setAttribute("instanceDistanceEnd",new jn(i,1,1))}ensureDashDistances(){if(!(!this._isDashedMaterial()||!this._geometryInitialized)){this._ensureDistanceAttributes();for(let t=0;t<this._geometryCount;t++){const e=this._geometryInfo[t];!e||!En(e.flags)||e.vertexCount<1||this._writeSlotDistances(e.vertexStart,e.vertexCount,e.reservedVertexCount)}}}_writeSlotDistances(t,e,i){const r=this.geometry.getAttribute("instanceDistanceStart"),s=this.geometry.getAttribute("instanceDistanceEnd");if(!r||!s)return;const o=this.geometry.getAttribute("instanceStart"),a=this.geometry.getAttribute("instanceEnd");let l=0;for(let c=0;c<e;c++){const u=t+c;vh.fromBufferAttribute(o,u),_h.fromBufferAttribute(a,u),r.setX(u,l),l+=vh.distanceTo(_h),s.setX(u,l)}for(let c=e;c<i;c++){const u=t+c;r.setX(u,0),s.setX(u,0)}r.data.needsUpdate=!0,s.data.needsUpdate=!0}_validateGeometry(t){const e=t.getAttribute("instanceStart"),i=t.getAttribute("instanceEnd");if(!e||!i)throw new Error('AcTrBatchedLine2: Geometry must have "instanceStart" and "instanceEnd" attributes.');if(e.itemSize!==3||i.itemSize!==3||e.count!==i.count)throw new Error("AcTrBatchedLine2: Invalid line segment attributes. Expected matching vec3 instanceStart/instanceEnd.")}_resizeSpaceIfNeeded(t){const e=t.getAttribute("instanceStart").count,i=ha({currentMaxCount:this._maxSegmentCount,nextStart:this._nextSegmentStart,requiredCount:e,growthFactor:gM.GROWTH_FACTOR});i>this._maxSegmentCount&&this.setGeometrySize(i)}reset(){this.boundingBox=null,this.boundingSphere=null,this._geometryInfo=[],this._availableGeometryIds=[],this._nextSegmentStart=0,this._geometryCount=0,this._origin=void 0,this.position.set(0,0,0),this._geometryInitialized=!1,this.geometry.dispose()}addGeometry(t,e=-1,i=new H){this.rebaseGeometryInPlace(t,i),this._initializeGeometry(t),this._validateGeometry(t),this._resizeSpaceIfNeeded(t);const r=t.getAttribute("instanceStart").count,s={vertexStart:this._nextSegmentStart,vertexCount:-1,reservedVertexCount:ua(e,r),...mh()};gh({typeName:"AcTrBatchedLine2",maxVertexCount:this._maxSegmentCount,vertexStart:s.vertexStart,reservedVertexCount:s.reservedVertexCount});const{geometryId:o,geometryCount:a}=ph(this._availableGeometryIds,this._geometryInfo,this._geometryCount,s);return this._geometryCount=a,this.setGeometryAt(o,t),this._nextSegmentStart=s.vertexStart+s.reservedVertexCount,this._syncDrawRange(),o}rebaseGeometryInPlace(t,e){const i=t.getAttribute("instanceStart"),r=t.getAttribute("instanceEnd");if(!i||!r)return;if(!this._origin){He.safeComputeBoundingBox(t);const o=t.boundingBox?t.boundingBox.getCenter(new H):new H;this._origin=o.add(e.clone()),this.position.copy(this._origin)}const s=this._origin;if(s){for(let o=0;o<i.count;o++)i.setXYZ(o,i.getX(o)+e.x-s.x,i.getY(o)+e.y-s.y,i.getZ(o)+e.z-s.z),r.setXYZ(o,r.getX(o)+e.x-s.x,r.getY(o)+e.y-s.y,r.getZ(o)+e.z-s.z);i.needsUpdate=!0,r.needsUpdate=!0}}setGeometryInfo(t,e){if(t>=this._geometryCount)throw new Error("AcTrBatchedLine2: Maximum geometry count reached.");const i=this._geometryInfo[t];i.objectId=e.objectId,i.bboxIntersectionCheck=e.bboxIntersectionCheck}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("AcTrBatchedLine2: Maximum geometry count reached.");this._validateGeometry(e);const i=this._geometryInfo[t],r=e.getAttribute("instanceStart").count;if(r>i.reservedVertexCount)throw new Error("AcTrBatchedLine2: Reserved space not large enough for provided geometry.");const s=this.geometry.getAttribute("instanceStart"),o=this.geometry.getAttribute("instanceEnd"),a=e.getAttribute("instanceStart"),l=e.getAttribute("instanceEnd"),c=i.vertexStart;Rm(a,s,c),Rm(l,o,c);for(let u=r,h=i.reservedVertexCount;u<h;u++){const d=c+u;for(let f=0;f<3;f++)s.setComponent(d,f,0),o.setComponent(d,f,0)}return s.needsUpdate=!0,o.needsUpdate=!0,i.vertexCount=r,i.boundingBox=null,gb(this.geometry,c,i.reservedVertexCount,t),this._isDashedMaterial()&&this._writeSlotDistances(c,r,i.reservedVertexCount),t}optimize(){const t=this._getPackedSegmentArray();let e=0;const i=this._geometryInfo.map((o,a)=>({info:o,id:a})).filter(o=>En(o.info.flags)).sort((o,a)=>o.info.vertexStart-a.info.vertexStart);for(const{info:o}of i){const a=o.vertexStart,l=o.reservedVertexCount;if(a!==e){t.copyWithin(e*6,a*6,(a+l)*6);const c=this.geometry.getAttribute("slotId");c&&(c.array.copyWithin(e,a,a+l),c.addUpdateRange(e,l),c.needsUpdate=!0)}o.vertexStart=e,e+=l}for(let o=e*6,a=t.length;o<a;o++)t[o]=0;this._nextSegmentStart=e,this._syncDrawRange(),this._availableGeometryIds.length=0;const r=this.geometry.getAttribute("instanceStart"),s=this.geometry.getAttribute("instanceEnd");if(r.needsUpdate=!0,s.needsUpdate=!0,this._isDashedMaterial())for(const{info:o}of i)this._writeSlotDistances(o.vertexStart,o.vertexCount,o.reservedVertexCount);return dh(this.geometry,this._geometryInfo),this}getBoundingBoxAt(t,e){if(t>=this._geometryCount)return null;const i=this._geometryInfo[t];if(i.boundingBox===null){const r=new Re,s=this.geometry.getAttribute("instanceStart"),o=this.geometry.getAttribute("instanceEnd");for(let a=i.vertexStart,l=i.vertexStart+i.vertexCount;a<l;a++)r.expandByPoint(_n.fromBufferAttribute(s,a)),r.expandByPoint(Gn.fromBufferAttribute(o,a));i.boundingBox=r}return e.copy(i.boundingBox),e}getBoundingSphereAt(t,e){return t>=this._geometryCount?null:(this.getBoundingBoxAt(t,bs),bs.getBoundingSphere(e),e)}computeBoundingBoxAt(t,e){if(t>=this._geometryCount)return null;const i=this._geometryInfo[t],r=this.geometry.getAttribute("instanceStart"),s=this.geometry.getAttribute("instanceEnd"),o=i.vertexStart,a=o+i.vertexCount;e.makeEmpty();const l=r instanceof jn?r:null,c=s instanceof jn?s:null;if(l!==null&&c!==null&&c.data===l.data&&l.itemSize===3&&c.itemSize===3&&l.offset===0&&c.offset===3&&l.data.stride===6){const u=l.data.array;for(let h=o;h<a;h++){const d=h*6;e.expandByPoint(_n.set(u[d],u[d+1],u[d+2])),e.expandByPoint(Gn.set(u[d+3],u[d+4],u[d+5]))}return e}for(let u=o;u<a;u++)e.expandByPoint(_n.fromBufferAttribute(r,u)),e.expandByPoint(Gn.fromBufferAttribute(s,u));return e}computeAggregateBoundingSphere(t){const e=this.geometry.getAttribute("instanceStart"),i=this.geometry.getAttribute("instanceEnd");if(!e||!i)return null;let r=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,c=-1/0;const u=e instanceof jn?e:null,h=i instanceof jn?i:null,d=u!==null&&h!==null&&h.data===u.data&&u.itemSize===3&&h.itemSize===3&&u.offset===0&&h.offset===3&&u.data.stride===6?u.data.array:null;for(let f=0;f<this._geometryCount;f++){const p=this._geometryInfo[f];if(!En(p.flags))continue;const g=p.vertexStart,y=g+p.vertexCount;if(d!==null)for(let m=g;m<y;m++){const v=m*6,x=d[v],_=d[v+1],b=d[v+2],w=d[v+3],C=d[v+4],E=d[v+5];x<r&&(r=x),_<s&&(s=_),b<o&&(o=b),x>a&&(a=x),_>l&&(l=_),b>c&&(c=b),w<r&&(r=w),C<s&&(s=C),E<o&&(o=E),w>a&&(a=w),C>l&&(l=C),E>c&&(c=E)}else for(let m=g;m<y;m++)_n.fromBufferAttribute(e,m),Gn.fromBufferAttribute(i,m),_n.x<r&&(r=_n.x),_n.y<s&&(s=_n.y),_n.z<o&&(o=_n.z),_n.x>a&&(a=_n.x),_n.y>l&&(l=_n.y),_n.z>c&&(c=_n.z),Gn.x<r&&(r=Gn.x),Gn.y<s&&(s=Gn.y),Gn.z<o&&(o=Gn.z),Gn.x>a&&(a=Gn.x),Gn.y>l&&(l=Gn.y),Gn.z>c&&(c=Gn.z)}return r>a?(t.makeEmpty(),t):(bs.min.set(r,s,o),bs.max.set(a,l,c),bs.getBoundingSphere(t))}getGeometryAt(t){return this.validateGeometryId(t),this._geometryInfo[t]}setGeometrySize(t){var e;const i=this.geometry,r=this._getPackedSegmentArray(),s=i.getAttribute("slotId"),o=s?s.array.slice(0,Math.min(s.count,this._maxSegmentCount)):void 0;this._maxSegmentCount=t,this.geometry=new ms,this.geometry.setPositions(new Float32Array(t*6));const a=this._getPackedSegmentArray();if(Qs(r,a),this._copyStaticAttributes(i),this._isDashedMaterial()){const c=i.getAttribute("instanceDistanceStart");if(this._ensureDistanceAttributes(),c&&(e=c.data)!=null&&e.array){const u=this.geometry.getAttribute("instanceDistanceStart"),h=u.data.array,d=c.data.array;h.set(d.subarray(0,Math.min(d.length,h.length))),u.data.needsUpdate=!0}}const l=fh(this.geometry,t);o&&(l.array.set(o.subarray(0,Math.min(o.length,l.count))),l.needsUpdate=!0),this._geometryInitialized=!0,this._syncDrawRange(),i.dispose()}getObjectAt(t){const e=this._geometryInfo[t],i=this._createSubGeometry(e.vertexStart,e.vertexCount,!0),r=new gr(i,this.material);this._isDashedMaterial()&&r.computeLineDistances(),r.position.copy(this.position),r.updateMatrix(),r.updateMatrixWorld(!0);const s=r.geometry.boundingBox??new Re;this.computeBoundingBoxAt(t,s),r.geometry.boundingBox=s;const o=r.geometry.boundingSphere??new zn;return s.getBoundingSphere(o),r.geometry.boundingSphere=o,r}intersectWith(t,e,i){this._intersectWith(t,e,i)}raycast(t,e){for(let i=0,r=this._geometryInfo.length;i<r;i++)this._intersectWith(i,t,e)}copy(t){var e;return super.copy(t),this.geometry=t.geometry.clone(),this.boundingBox=t.boundingBox?t.boundingBox.clone():null,this.boundingSphere=t.boundingSphere?t.boundingSphere.clone():null,this._geometryInfo=t._geometryInfo.map(i=>({...i,boundingBox:i.boundingBox?i.boundingBox.clone():null})),this._maxSegmentCount=t._maxSegmentCount,this._geometryCount=t._geometryCount,this._nextSegmentStart=t._nextSegmentStart,this._geometryInitialized=t._geometryInitialized,this._origin=(e=t._origin)==null?void 0:e.clone(),this}dispose(){return this.geometry.dispose(),this}_intersectWith(t,e,i){const r=this._geometryInfo[t];if(!Js(r.flags))return;if(r.bboxIntersectionCheck){if(this.computeBoundingBoxAt(t,bs),bs.applyMatrix4(this.matrixWorld),e.ray.intersectBox(bs,_n)){const o=e.ray.origin.distanceTo(_n);i.push({distance:o,point:_n.clone(),object:this,face:null,faceIndex:void 0,uv:void 0,batchId:t,objectId:r.objectId})}return}const s=this._createSubGeometry(r.vertexStart,r.vertexCount,!1);if(Ss.geometry=s,Ss.material=this.material,Ss.position.copy(this.position),Ss.quaternion.copy(this.quaternion),Ss.scale.copy(this.scale),Ss.updateMatrix(),Ss.updateMatrixWorld(!0),Ss.raycast(e,Hl),Hl.length===0){this._intersectSegmentsWithLineThreshold(s,this.matrixWorld,e,t,r.objectId,i),s.dispose();return}for(let o=0,a=Hl.length;o<a;o++){const l=Hl[o];l.batchId=t,l.objectId=r.objectId,l.object=this,i.push(l)}Hl.length=0,s.dispose()}_intersectSegmentsWithLineThreshold(t,e,i,r,s,o){var a;const l=((a=i.params.Line)==null?void 0:a.threshold)??0;if(!(l>0))return;const c=t.getAttribute("instanceStart"),u=t.getAttribute("instanceEnd");if(!c||!u)return;const h=l*l,d=o;for(let f=0,p=c.count;f<p;f++){if(vh.fromBufferAttribute(c,f).applyMatrix4(e),_h.fromBufferAttribute(u,f).applyMatrix4(e),i.ray.distanceSqToSegment(vh,_h,Eb,Ab)>h)continue;const g=i.ray.origin.distanceTo(Eb);g<i.near||g>i.far||d.push({distance:g,point:Ab.clone(),object:this,face:null,faceIndex:f,uv:void 0,batchId:r,objectId:s})}}_createSubGeometry(t,e,i){const r=this._getPackedSegmentArray(),s=i?r.slice(t*6,(t+e)*6):r.subarray(t*6,(t+e)*6),o=new ms;return o.setPositions(s),this._copyStaticAttributes(this.geometry,o),o}_getPackedSegmentArray(){var t;const e=this.geometry.getAttribute("instanceStart");if("data"in e&&(t=e.data)!=null&&t.array)return e.data.array;const i=this.geometry.getAttribute("instanceEnd"),r=e.count,s=new Float32Array(r*6);for(let o=0,a=0;o<r;o++)s[a++]=e.getComponent(o,0),s[a++]=e.getComponent(o,1),s[a++]=e.getComponent(o,2),s[a++]=i.getComponent(o,0),s[a++]=i.getComponent(o,1),s[a++]=i.getComponent(o,2);return s}_syncDrawRange(){this.geometry.instanceCount=this._nextSegmentStart}};Cb.GROWTH_FACTOR=1.25;let xh=Cb;const Tb=new Re,Ck=new H,Tk=yh(cn,{typeName:"AcTrBatchedMesh",createObject:()=>new cn,getDrawRange:(n,t)=>n.geometry.index!=null?{start:t.indexStart,count:t.indexCount}:{start:t.vertexStart,count:t.vertexCount}}),Lb=class Ey extends Tk{constructor(t=1e3,e=t*2,i){super(new Xe,i),this._nextIndexStart=0,this._nextVertexStart=0,this._geometryInitialized=!1,this.frustumCulled=!1,this._maxVertexCount=t,this._maxIndexCount=e}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}get origin(){return this._origin}_initializeGeometry(t){this._geometryInitialized===!1&&(Um(this.geometry,t,this._maxVertexCount,this._maxIndexCount),this._geometryInitialized=!0)}_validateGeometry(t){zm(this.geometry,t,"AcTrBatchedMesh",!0)}_resizeSpaceIfNeeded(t){const e=t.getIndex(),i=e==null?this._maxIndexCount:ha({currentMaxCount:this._maxIndexCount,nextStart:this._nextIndexStart,requiredCount:e.count,growthFactor:Ey.GROWTH_FACTOR}),r=t.getAttribute("position"),s=r==null?this._maxVertexCount:ha({currentMaxCount:this._maxVertexCount,nextStart:this._nextVertexStart,requiredCount:r.count,growthFactor:Ey.GROWTH_FACTOR});(i>this._maxIndexCount||s>this._maxVertexCount)&&this.setGeometrySize(s,i)}addGeometry(t,e=-1,i=-1,r=new H){this.rebaseGeometryInPlace(t,r),t.hasAttribute("uv")&&t.deleteAttribute("uv"),t.hasAttribute("normal")&&t.deleteAttribute("normal"),this._initializeGeometry(t),this._validateGeometry(t),this._resizeSpaceIfNeeded(t);const s=t.getAttribute("position").count,o=t.getIndex(),a={vertexStart:this._nextVertexStart,vertexCount:-1,reservedVertexCount:ua(e,s),indexStart:o?this._nextIndexStart:-1,indexCount:-1,reservedIndexCount:o?ua(i,o.count):0,...mh()};gh({typeName:"AcTrBatchedMesh",maxVertexCount:this._maxVertexCount,vertexStart:a.vertexStart,reservedVertexCount:a.reservedVertexCount,maxIndexCount:this._maxIndexCount,indexStart:a.indexStart,reservedIndexCount:a.reservedIndexCount});const{geometryId:l,geometryCount:c}=ph(this._availableGeometryIds,this._geometryInfo,this._geometryCount,a);return this._geometryCount=c,this.setGeometryAt(l,t),this._nextIndexStart=a.indexStart+a.reservedIndexCount,this._nextVertexStart=a.vertexStart+a.reservedVertexCount,this._syncDrawRange(),l}rebaseGeometryInPlace(t,e){const i=t.getAttribute("position");if(!i)return;if(!this._origin){He.safeComputeBoundingBox(t);const o=t.boundingBox?t.boundingBox.getCenter(new H):new H;this._origin=o.add(e.clone()),this.position.copy(this._origin)}const r=this._origin;if(!r)return;const s=i.array;if(s instanceof Float32Array){for(let o=0;o<s.length;o+=3)s[o]=s[o]+e.x-r.x,s[o+1]=s[o+1]+e.y-r.y,s[o+2]=s[o+2]+e.z-r.z;i.needsUpdate=!0;return}for(let o=0;o<i.count;o++)i.setXYZ(o,i.getX(o)+e.x-r.x,i.getY(o)+e.y-r.y,i.getZ(o)+e.z-r.z);i.needsUpdate=!0}setGeometryInfo(t,e){if(t>=this._geometryCount)throw new Error("AcTrBatchedMesh: Maximum geometry count reached.");const i=this._geometryInfo[t];i.objectId=e.objectId,i.bboxIntersectionCheck=e.bboxIntersectionCheck}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("AcTrBatchedMesh: Maximum geometry count reached.");this._validateGeometry(e);const i=this.geometry,r=this._geometryInfo[t];return Fm(r,i,e,"AcTrBatchedMesh",t),t}optimize(){const t=this.geometry,e=t.index!==null,i=t.attributes,r=t.index;let s=0,o=0;const a=this._geometryInfo.map((l,c)=>({info:l,i:c})).filter(l=>En(l.info.flags)).sort((l,c)=>l.info.vertexStart-c.info.vertexStart);for(const{info:l}of a){const c=l.vertexCount,u=e?l.indexCount:0,h=l.vertexStart,d=l.indexStart;if(h!==s){for(const f in i){const p=i[f],{array:g,itemSize:y}=p;g.copyWithin(s*y,h*y,(h+c)*y),p.addUpdateRange(s*y,c*y),p.needsUpdate=!0}l.vertexStart=s}if(e&&r&&d!==o){const f=r.array,p=s-h;for(let g=0;g<u;g++)f[o+g]=f[d+g]+p;r.addUpdateRange(o,u),r.needsUpdate=!0,l.indexStart=o}s+=c,o+=u}if(e&&r){const l=r.array;for(let c=o,u=l.length;c<u;c++)l[c]=0;r.needsUpdate=!0}return this._nextVertexStart=s,this._nextIndexStart=o,this._syncDrawRange(),this._availableGeometryIds.length=0,dh(t,this._geometryInfo),this}getBoundingBoxAt(t,e){if(t>=this._geometryCount)return null;const i=this.geometry,r=this._geometryInfo[t];if(r.boundingBox===null){const s=new Re,o=i.index,a=i.attributes.position,{start:l,count:c}=o!=null?{start:r.indexStart,count:r.indexCount}:{start:r.vertexStart,count:r.vertexCount};for(let u=l,h=l+c;u<h;u++){let d=u;o&&(d=o.getX(d)),s.expandByPoint(Ck.fromBufferAttribute(a,d))}r.boundingBox=s}return e.copy(r.boundingBox),e}getBoundingSphereAt(t,e){return t>=this._geometryCount?null:(this.getBoundingBoxAt(t,Tb),Tb.getBoundingSphere(e),e)}setGeometrySize(t,e){const i=this.geometry;i.dispose(),this._maxVertexCount=t,this._maxIndexCount=e,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Xe,this._initializeGeometry(i));const r=this.geometry;i.index&&Qs(i.index.array,r.index.array);for(const s in i.attributes)Qs(i.attributes[s].array,r.attributes[s].array);this._syncDrawRange()}_syncDrawRange(){const t=this.geometry;t.index?t.setDrawRange(0,this._nextIndexStart):t.setDrawRange(0,this._nextVertexStart)}copy(t){var e;return super.copy(t),this.geometry=t.geometry.clone(),this.boundingBox=t.boundingBox!==null?t.boundingBox.clone():null,this.boundingSphere=t.boundingSphere!==null?t.boundingSphere.clone():null,this._geometryInfo=t._geometryInfo.map(i=>({...i,boundingBox:i.boundingBox!==null?i.boundingBox.clone():null})),this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._geometryCount=t._geometryCount,this._origin=(e=t._origin)==null?void 0:e.clone(),this}};Lb.GROWTH_FACTOR=1.25;let Ib=Lb;const Pb=new Re,Lk=new H,Ik=yh(ur,{typeName:"AcTrBatchedPoint",createObject:()=>new ur,getDrawRange:(n,t)=>({start:t.vertexStart,count:t.vertexCount})}),Rb=class yM extends Ik{constructor(t=1e3,e){super(new Xe,e),this._nextVertexStart=0,this._geometryInitialized=!1,this.frustumCulled=!1,this._maxVertexCount=t}get geometryCount(){return this._geometryCount}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get origin(){return this._origin}_initializeGeometry(t){this._geometryInitialized===!1&&(Um(this.geometry,t,this._maxVertexCount,null),this._geometryInitialized=!0)}_validateGeometry(t){zm(this.geometry,t,"AcTrBatchedPoint",!1)}_resizeSpaceIfNeeded(t){const e=t.getAttribute("position"),i=e==null?this._maxVertexCount:ha({currentMaxCount:this._maxVertexCount,nextStart:this._nextVertexStart,requiredCount:e.count,growthFactor:yM.GROWTH_FACTOR});i>this._maxVertexCount&&this.setGeometrySize(i)}reset(){this.boundingBox=null,this.boundingSphere=null,this._geometryInfo=[],this._availableGeometryIds=[],this._nextVertexStart=0,this._geometryCount=0,this._geometryInfo.length=0,this._origin=void 0,this.position.set(0,0,0),this._geometryInitialized=!1,this.geometry.dispose()}addGeometry(t,e=-1,i=new H){this.rebaseGeometryInPlace(t,i),this._initializeGeometry(t),this._validateGeometry(t),this._resizeSpaceIfNeeded(t);const r=t.getAttribute("position").count,s={vertexStart:this._nextVertexStart,vertexCount:-1,reservedVertexCount:ua(e,r),...mh()};gh({typeName:"AcTrBatchedPoint",maxVertexCount:this._maxVertexCount,vertexStart:s.vertexStart,reservedVertexCount:s.reservedVertexCount});const{geometryId:o,geometryCount:a}=ph(this._availableGeometryIds,this._geometryInfo,this._geometryCount,s);return this._geometryCount=a,this.setGeometryAt(o,t),this._nextVertexStart=s.vertexStart+s.reservedVertexCount,this.geometry.setDrawRange(0,this._nextVertexStart),this._syncDrawRange(),o}rebaseGeometryInPlace(t,e){const i=t.getAttribute("position");if(!i)return;if(!this._origin){He.safeComputeBoundingBox(t);const o=t.boundingBox?t.boundingBox.getCenter(new H):new H;this._origin=o.add(e.clone()),this.position.copy(this._origin)}const r=this._origin;if(!r)return;const s=i.array;if(s instanceof Float32Array){for(let o=0;o<s.length;o+=3)s[o]=s[o]+e.x-r.x,s[o+1]=s[o+1]+e.y-r.y,s[o+2]=s[o+2]+e.z-r.z;i.needsUpdate=!0;return}for(let o=0;o<i.count;o++)i.setXYZ(o,i.getX(o)+e.x-r.x,i.getY(o)+e.y-r.y,i.getZ(o)+e.z-r.z);i.needsUpdate=!0}setGeometryInfo(t,e){if(t>=this._geometryCount)throw new Error("AcTrBatchedPoint: Maximum geometry count reached.");const i=this._geometryInfo[t],r=e.position;r&&(i.position={...r}),i.objectId=e.objectId,i.bboxIntersectionCheck=e.bboxIntersectionCheck}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("AcTrBatchedPoint: Maximum geometry count reached.");this._validateGeometry(e);const i=this.geometry,r=this._geometryInfo[t];return Fm(r,i,e,"AcTrBatchedPoint",t),t}optimize(){let t=0;const e=this.geometry,i=this._geometryInfo,r=i.map((s,o)=>o).filter(s=>En(i[s].flags)).sort((s,o)=>i[s].vertexStart-i[o].vertexStart);for(let s=0;s<r.length;s++){const o=r[s],a=i[o],l=a.vertexStart,c=a.reservedVertexCount;if(l!==t){for(const u in e.attributes){const h=e.attributes[u],{array:d,itemSize:f}=h;d.copyWithin(t*f,l*f,(l+c)*f),h.addUpdateRange(t*f,c*f),h.needsUpdate=!0}a.vertexStart=t}t+=c}return this._nextVertexStart=t,this._syncDrawRange(),this._availableGeometryIds.length=0,dh(e,i),this}getBoundingBoxAt(t,e){if(t>=this._geometryCount)return null;const i=this.geometry,r=this._geometryInfo[t];if(r.boundingBox===null){const s=new Re,o=i.index,a=i.attributes.position;for(let l=r.vertexStart,c=r.vertexStart+r.vertexCount;l<c;l++){let u=l;o&&(u=o.getX(u)),s.expandByPoint(Lk.fromBufferAttribute(a,u))}r.boundingBox=s}return e.copy(r.boundingBox),e}getBoundingSphereAt(t,e){return t>=this._geometryCount?null:(this.getBoundingBoxAt(t,Pb),Pb.getBoundingSphere(e),e)}getGeometryAt(t){return this.validateGeometryId(t),this._geometryInfo[t]}setGeometrySize(t){const e=this.geometry;e.dispose(),this._maxVertexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Xe,this._initializeGeometry(e));const i=this.geometry;e.index&&Qs(e.index.array,i.index.array);for(const r in e.attributes)Qs(e.attributes[r].array,i.attributes[r].array);this._syncDrawRange()}_syncDrawRange(){this.geometry.setDrawRange(0,this._nextVertexStart)}copy(t){var e;return super.copy(t),this.geometry=t.geometry.clone(),this.boundingBox=t.boundingBox!==null?t.boundingBox.clone():null,this.boundingSphere=t.boundingSphere!==null?t.boundingSphere.clone():null,this._geometryInfo=t._geometryInfo.map(i=>({...i,boundingBox:i.boundingBox!==null?i.boundingBox.clone():null})),this._maxVertexCount=t._maxVertexCount,this._geometryInitialized=t._geometryInitialized,this._geometryCount=t._geometryCount,this._origin=(e=t._origin)==null?void 0:e.clone(),this}};Rb.GROWTH_FACTOR=1.25;let kb=Rb;const da=32,to=new Pe,yi=new Pe,Ob=new Pe,Bb=new Pe,Nb=new Pe,bh=new Re,Pk=new Pe().makeScale(0,0,0);class Gm extends wn{constructor(t,e,i,r,s){super(),this._localBox=new Re,this._drawable=null,this._line2Objects=[],this._capacity=0,this._count=0,this._objectIds=[],this._hiddenMatrices=new Map,this._cpuRelative=null,this._selected=new Set,this._hovered=new Set,this._highlights=new Map,this._compareEnabled=!1,this._compareBaseColor=10265519,this._compareMaterial=null,this._geometry=t,this._material=e,this._origin=i.clone(),this.kind=r,this.sourceUuid=s,this.matrixAutoUpdate=!1,He.safeComputeBoundingBox(t),t.boundingBox&&this._localBox.copy(t.boundingBox),this._raycastScratch=this.createDrawable(t,e),this._raycastScratch.matrixAutoUpdate=!1,this._raycastScratch.frustumCulled=!1,r!=="line2"&&(this._drawable=this.createInstanced(t,e,da),this._capacity=da,this._alive=new Uint8Array(da),this._bboxOnly=new Uint8Array(da),this._drawable.position.copy(this._origin),this._drawable.matrixAutoUpdate=!1,this._drawable.updateMatrix(),this._drawable.frustumCulled=!1,this._drawable.raycast=()=>{},this.add(this._drawable))}get origin(){return this._origin}get materialId(){return this._material.id}get material(){return this._material}set material(t){if(this._material=t,this._compareEnabled){this.syncCompareMaterial();return}this.applyMaterialToDrawables(t)}get instanceCount(){let t=0;for(let e=0;e<this._count;e++)this._alive[e]&&t++;return t}addInstance(t,e,i){const r=this._count;if(this.ensureCapacity(r+1),this._count++,this._alive[r]=1,this._bboxOnly[r]=i?1:0,this._objectIds[r]=e,this.writeRelative(r,t),this.kind==="line2"?this._line2Objects[r]=this.createLine2(r):this._drawable&&(this._drawable.count=this._count),i){const s=this._line2Objects[r]??this._drawable;s&&(en(s).bboxIntersectionCheck=!0)}return r}setVisibleAt(t,e){var i;if(!this.isAlive(t))return this;const r=(i=this._drawable)==null?void 0:i.instanceMatrix;if(!r){const a=this._line2Objects[t];return a&&(a.visible=e),e||this.removeHighlight(t),this}const s=t*16,o=r.array;if(e){const a=this._hiddenMatrices.get(t);a&&(o.set(a,s),this._hiddenMatrices.delete(t))}else if(!this._hiddenMatrices.has(t)){const a=new Float32Array(16);a.set(o.subarray(s,s+16)),this._hiddenMatrices.set(t,a),Pk.toArray(o,s),this.removeHighlight(t)}return r.needsUpdate=!0,this}getVisibleAt(t){var e;return this.isAlive(t)?this.kind==="line2"?((e=this._line2Objects[t])==null?void 0:e.visible)!==!1:!this._hiddenMatrices.has(t):!1}deleteGeometry(t){if(!this.isAlive(t))return;this.setVisibleAt(t,!1),this._alive[t]=0,this._selected.delete(t),this._hovered.delete(t),this.removeHighlight(t);const e=this._line2Objects[t];e&&(e.geometry=null,e.removeFromParent(),this._line2Objects[t]=null)}optimize(){}setHighlightAt(t,e,i){if(!this.isAlive(t))return!1;const r=e==="select"?this._selected:this._hovered,s=r.has(t);return i?r.add(t):r.delete(t),s===i&&this._highlights.has(t)===i?!1:(this.syncHighlight(t),!0)}flushHighlightMask(){}setCompareRoleAt(t,e){return!1}setCompareDisplayColors(t){this._compareEnabled=t.enabled,t.baseColor!=null&&(this._compareBaseColor=t.baseColor),this.syncCompareMaterial()}applyPackedCompareRoles(t){return this}intersectWith(t,e,i){if(!this.isAlive(t)||!this.getVisibleAt(t))return;if(this.composeFullMatrix(t,yi),this._bboxOnly[t]){bh.copy(this._localBox).applyMatrix4(yi);const o=e.ray.intersectBox(bh,Rk);if(!o)return;i.push({distance:e.ray.origin.distanceTo(o),point:o.clone(),object:this});return}if(this.kind==="line2"){const o=this._line2Objects[t];if(!o)return;o.updateWorldMatrix(!0,!1);const a=e.intersectObject(o,!1);for(let l=0;l<a.length;l++)i.push(a[l]);return}const r=this._raycastScratch;kk(yi,r.scale),r.matrixWorld.copy(yi),r.matrixWorldNeedsUpdate=!1;const s=e.intersectObject(r,!1);for(let o=0;o<s.length;o++)i.push(s[o])}getObjectAt(t){this.composeLocalMatrix(t,yi);const e=this.createDrawable(this._geometry.clone(),this._material);return e.matrix.copy(yi),e.matrixAutoUpdate=!1,e.matrixWorld.copy(yi),e.matrixWorldNeedsUpdate=!1,e.frustumCulled=!1,e}unionActiveVisibleBoundingBoxInto(t,e){var i;this._drawable&&this._drawable.updateWorldMatrix(!0,!1);for(let r=0;r<this._count;r++){if(!this._alive[r]||!this.getVisibleAt(r))continue;const s=this._objectIds[r];s&&(i=e==null?void 0:e.excludeObjectIds)!=null&&i.has(s)||e!=null&&e.includeObjectIds&&(!s||!e.includeObjectIds.has(s))||(this.composeFullMatrix(r,yi),bh.copy(this._localBox).applyMatrix4(yi),t.union(bh))}}disposeSharedInstances(){for(const t of this._highlights.values())this.disposeOverlay(t);this._highlights.clear();for(const t of this._line2Objects)t&&(t.geometry=null,t.removeFromParent());if(this._line2Objects=[],this._drawable){this._drawable.removeFromParent();const t=this._drawable;t.dispose?t.dispose():t.dispatchEvent({type:"dispose"}),this._drawable=null}this.disposeCompareMaterial(),this.removeFromParent()}get displayMaterial(){return this._compareMaterial??this._material}syncCompareMaterial(){const t=this._compareMaterial;if(this._compareMaterial=null,!this._compareEnabled){this.applyMaterialToDrawables(this._material),t==null||t.dispose();return}const e=this.createCompareMaterial(this._material,this._compareBaseColor);this._compareMaterial=e,this.applyMaterialToDrawables(e),t==null||t.dispose()}createCompareMaterial(t,e){if(t instanceof Pl){const r=new Pl({color:e,linewidth:t.linewidth,worldUnits:t.worldUnits,dashed:t.dashed,dashSize:t.dashSize,gapSize:t.gapSize});return r.resolution=t.resolution,r.depthTest=t.depthTest,r.transparent=t.transparent,r.opacity=t.opacity,r}const i=Pn.cloneMaterial(t);return Pn.setMaterialColor(i,new Zt(e)),i}disposeCompareMaterial(){this._compareMaterial&&(this._compareMaterial.dispose(),this._compareMaterial=null)}applyMaterialToDrawables(t){this._drawable&&(this._drawable.material=t),this._raycastScratch.material=t;for(const e of this._line2Objects)e&&(e.material=t)}isAlive(t){return t>=0&&t<this._count&&this._alive[t]===1}ensureCapacity(t){if(this.kind==="line2"&&this._alive==null&&(this._capacity=da,this._alive=new Uint8Array(this._capacity),this._bboxOnly=new Uint8Array(this._capacity),this._cpuRelative=new Float32Array(this._capacity*16)),t<=this._capacity)return;let e=Math.max(this._capacity,da);for(;e<t;)e*=2;const i=new Uint8Array(e),r=new Uint8Array(e);if(i.set(this._alive),r.set(this._bboxOnly),this._alive=i,this._bboxOnly=r,this._cpuRelative){const a=new Float32Array(e*16);a.set(this._cpuRelative),this._cpuRelative=a}if(this._capacity=e,!this._drawable)return;const s=this._drawable.instanceMatrix,o=new xl(new Float32Array(e*16),16);o.setUsage(lv),o.array.set(s.array),this._drawable.instanceMatrix=o}writeRelative(t,e){var i;Ob.makeTranslation(-this._origin.x,-this._origin.y,-this._origin.z),to.multiplyMatrices(Ob,e),this._cpuRelative&&to.toArray(this._cpuRelative,t*16);const r=(i=this._drawable)==null?void 0:i.instanceMatrix;r&&(to.toArray(r.array,t*16),r.needsUpdate=!0)}readRelative(t,e){var i;const r=this._hiddenMatrices.get(t);if(r)return e.fromArray(r);if(this._cpuRelative)return e.fromArray(this._cpuRelative,t*16);const s=(i=this._drawable)==null?void 0:i.instanceMatrix;return s&&e.fromArray(s.array,t*16),e}composeLocalMatrix(t,e){return this.readRelative(t,to),Bb.makeTranslation(this._origin.x,this._origin.y,this._origin.z),e.multiplyMatrices(Bb,to)}composeFullMatrix(t,e){return this.readRelative(t,to),this._drawable?(this._drawable.updateWorldMatrix(!0,!1),e.multiplyMatrices(this._drawable.matrixWorld,to)):(this.composeLocalMatrix(t,Nb),this.updateWorldMatrix(!0,!1),e.multiplyMatrices(this.matrixWorld,Nb))}createLine2(t){this.composeLocalMatrix(t,yi);const e=new gr(this._geometry,this.displayMaterial);return e.matrix.copy(yi),e.matrixAutoUpdate=!1,e.matrixWorldNeedsUpdate=!0,e.frustumCulled=!1,en(e).sharesTemplateGeometry=!0,this.add(e),e}syncHighlight(t){if(this.removeHighlight(t),!this.getVisibleAt(t))return;const e=this._selected.has(t),i=this._hovered.has(t);if(!e&&!i)return;this.composeLocalMatrix(t,yi);const r=this.createDrawable(this._geometry.clone(),this._material);r.matrix.copy(yi),r.matrixAutoUpdate=!1,r.frustumCulled=!1,r.renderOrder=1e4,r.raycast=()=>{};const s=r.material;if(s&&!Array.isArray(s)){const o=Pn.cloneMaterial(s);Pn.setMaterialColor(o,e?zl:hh),o.depthTest=!1,o.depthWrite=!1,r.material=o}this.add(r),this._highlights.set(t,r)}removeHighlight(t){const e=this._highlights.get(t);e&&(this.disposeOverlay(e),this._highlights.delete(t))}disposeOverlay(t){if("material"in t&&t.material instanceof cr&&t.material.dispose(),"geometry"in t){const e=t;e.geometry&&e.geometry!==this._geometry&&e.geometry.dispose(),e.geometry=null}t.removeFromParent()}createInstanced(t,e,i){if(this.kind==="mesh"){const s=new DT(t,e,i);return s.count=0,s.frustumCulled=!1,s}const r=this.kind==="points"?new ur(t,e):new Ys(t,e);return r.isInstancedMesh=!0,r.instanceMatrix=new xl(new Float32Array(i*16),16),r.instanceMatrix.setUsage(lv),r.instanceColor=null,r.morphTexture=null,r.count=0,r.frustumCulled=!1,r}createDrawable(t,e){return this.kind==="mesh"?new cn(t,e):this.kind==="points"?new ur(t,e):this.kind==="line2"?new gr(t,e):new Ys(t,e)}}const Rk=new H;function kk(n,t){const e=n.elements,i=Math.hypot(e[0],e[1],e[2]),r=Math.hypot(e[4],e[5],e[6]),s=Math.hypot(e[8],e[9],e[10]);if(i+r+s===0){t.set(1,1,1);return}t.set(i,r,s)}let Db=()=>0;function ws(n,t){(gi(t).drawOrder??0)>=0&&(n.z+=Db())}const Ms=class dn extends pi{constructor(){super(),this._unbatchedSelectedIds=new Set,this._unbatchedHoveredIds=new Set,this._compareRoles=new Map,this._compareEnabled=!1,this._compareBaseColor=10265519,this._compareDeletedColor=14753096,this._compareAddedColor=2278750,this._compareModifiedColor=16096779,this._pointBatches=new Map,this._pointSymbolBatches=new Map,this._lineBatches=new Map,this._lineWithIndexBatches=new Map,this._line2Batches=new Map,this._meshBatches=new Map,this._meshWithIndexBatches=new Map,this._entitiesMap=new Map,this._originBatchById=new Map,this._sharedBatchById=new Map,this._sharedGeometryBatches=new Map,this._ownedSharedGeometries=new Map,this._unbatchedEntities=new Map,this._unbatchedObjects=new pi,this._selectedObjects=Tm(new pi),this._hoverObjects=Tm(new pi),this._compareOverlay=Tm(new pi),this._compareOverlay.name="CompareOverlay",this._compareOverlay.renderOrder=1e4,this.add(this._unbatchedObjects),this.add(this._selectedObjects),this.add(this._hoverObjects),this.add(this._compareOverlay)}get entityCount(){return this._entitiesMap.size}get stats(){const t=this.getUnbatchedStats(),e={summary:{entityCount:this._entitiesMap.size,totalGeometrySize:0,totalMappingSize:0},mesh:{indexed:{count:this.countBatchContainers(this._meshWithIndexBatches),geometrySize:this.getBatchedGeometrySize(this._meshWithIndexBatches),mappingSize:this.getBatchedGeometryMappingSize(this._meshWithIndexBatches)},nonIndexed:{count:this.countBatchContainers(this._meshBatches),geometrySize:this.getBatchedGeometrySize(this._meshBatches),mappingSize:this.getBatchedGeometryMappingSize(this._meshBatches)}},line:{indexed:{count:this.countBatchContainers(this._lineWithIndexBatches),geometrySize:this.getBatchedGeometrySize(this._lineWithIndexBatches),mappingSize:this.getBatchedGeometryMappingSize(this._lineWithIndexBatches)},nonIndexed:{count:this.countBatchContainers(this._lineBatches)+this.countBatchContainers(this._line2Batches),geometrySize:this.getBatchedGeometrySize(this._lineBatches)+this.getBatchedGeometrySize(this._line2Batches),mappingSize:this.getBatchedGeometryMappingSize(this._lineBatches)+this.getBatchedGeometryMappingSize(this._line2Batches)}},point:{indexed:{count:this.countBatchContainers(this._pointSymbolBatches),geometrySize:this.getBatchedGeometrySize(this._pointSymbolBatches),mappingSize:this.getBatchedGeometryMappingSize(this._pointSymbolBatches)},nonIndexed:{count:this.countBatchContainers(this._pointBatches),geometrySize:this.getBatchedGeometrySize(this._pointBatches),mappingSize:this.getBatchedGeometryMappingSize(this._pointBatches)}},unbatched:t};return e.summary.totalGeometrySize=e.line.indexed.geometrySize+e.line.nonIndexed.geometrySize+e.mesh.indexed.geometrySize+e.mesh.nonIndexed.geometrySize+e.point.indexed.geometrySize+e.point.nonIndexed.geometrySize+e.unbatched.geometrySize,e.summary.totalMappingSize=e.line.indexed.mappingSize+e.line.nonIndexed.mappingSize+e.mesh.indexed.mappingSize+e.mesh.nonIndexed.mappingSize+e.point.indexed.mappingSize+e.point.nonIndexed.mappingSize,e}rerenderPoints(t,e=0){const i=_s.instance.create(t,{x:0,y:0,z:0},e);i.line&&this._pointSymbolBatches.forEach(s=>{s.forEach(o=>{o.resetGeometry(t,e)})});const r=i.point!=null;this._pointBatches.forEach(s=>{s.forEach(o=>{o.visible=r})})}collectPointObjectWorldBoxes(t=new Map){const e=new Re,i=r=>{r.updateMatrixWorld(!0);for(let s=0;s<r.geometryCount;s++){let o;try{o=r.getGeometryAt(s)}catch{continue}if(!o.objectId||o.vertexCount<=0||!r.getBoundingBoxAt(s,e))continue;e.applyMatrix4(r.matrixWorld);const a=t.get(o.objectId);a?a.union(e):t.set(o.objectId,e.clone())}};return this._pointSymbolBatches.forEach(r=>{r.forEach(i)}),this._pointBatches.forEach(r=>{r.forEach(i)}),t}computeBoundingBox(t=new Re,e){t.makeEmpty();const i=new Re,r=s=>{s.forEach(o=>{o.forEach(a=>{a.unionActiveVisibleBoundingBoxInto(t,e)})})};return r(this._lineBatches),r(this._lineWithIndexBatches),r(this._line2Batches),r(this._meshBatches),r(this._meshWithIndexBatches),r(this._pointBatches),r(this._pointSymbolBatches),this._sharedGeometryBatches.forEach(s=>{s.forEach(o=>o.unionActiveVisibleBoundingBoxInto(t,e))}),this._unbatchedEntities.forEach((s,o)=>{var a;if(!((a=e==null?void 0:e.excludeObjectIds)!=null&&a.has(o))&&!(e!=null&&e.includeObjectIds&&!e.includeObjectIds.has(o)))for(const l of s)l.visible!==!1&&this.unionUnbatchedObjectBounds(l,t,i)}),t}clear(){return this.groups.forEach(t=>{t.forEach(e=>{e.forEach(i=>{i.dispose(),i.removeFromParent()})}),t.clear()}),this.clearHighlightGroup(this._selectedObjects),this.clearHighlightGroup(this._hoverObjects),this.clearHighlightGroup(this._compareOverlay),this._sharedGeometryBatches.forEach(t=>{t.forEach(e=>e.disposeSharedInstances())}),this._sharedGeometryBatches.clear(),this._sharedBatchById.clear(),this._ownedSharedGeometries.forEach(t=>t.dispose()),this._ownedSharedGeometries.clear(),this._originBatchById.clear(),this._unbatchedObjects.children.forEach(t=>{this.disposeObject(t)}),this._unbatchedObjects.clear(),this._unbatchedEntities.clear(),this._unbatchedSelectedIds.clear(),this._unbatchedHoveredIds.clear(),this._entitiesMap.clear(),this}updateMaterial(t,e){for(const i of this.groups){const r=i.get(t);if(r){for(const s of r)s.material=this.createOwnedBatchMaterial(e),s instanceof Hm?s.ensureLineDistanceAttribute():s instanceof xh&&s.ensureDashDistances();if(e.id!==t){i.delete(t);const s=i.get(e.id);s?s.push(...r):i.set(e.id,r)}}}this.rebindSharedGeometryMaterial(t,e),this._unbatchedObjects.traverse(i=>{if(!("material"in i))return;const r=en(i);if(r.styleMaterialId===t){const s=i;s.material=e,r.styleMaterialId=e.id,this.ensureUnbatchedLineDistance(s,e)}})}syncAppearanceFromRecord(t,e,i,r,s,o){this.rebindBatchedMaterialsForLayer(t,e,s,o),this._unbatchedObjects.traverse(a=>{const l=a.refreshTextMaterials;if(typeof l=="function"&&l.call(a,e),!("material"in a))return;const c=a;r&&D8(c,i),this.rebindUnbatchedDrawableMaterial(c,t,e,s,o)}),o&&this.rematerializeLayerTextDrawables(t,o,e)}rebindMaterialsForLayer(t,e,i,r){this.rebindBatchedMaterialsForLayer(t,e,i,r),this._unbatchedObjects.traverse(s=>{"material"in s&&this.rebindUnbatchedDrawableMaterial(s,t,e,i,r)})}rebindBatchedMaterialsForLayer(t,e,i,r){var s;const o=new Map;for(const a of this.groups)for(const l of[...a.keys()]){const c=a.get(l),u=(s=c==null?void 0:c[0])==null?void 0:s.material;if(!u||o.has(l)||!lh(u,t,t))continue;const h=this.resolveLayerBoundMaterial(u,t,e,i,r,t);if(h){if(h===u){for(const d of c)this.refreshLayerBoundMaterialColor(d.material,e,r);continue}o.set(l,h),this.updateMaterial(l,h)}}}rebindUnbatchedDrawableMaterial(t,e,i,r,s){const o=t.userData.layerName??e,a=en(t),l=h=>{if(!lh(h,e,o))return h;const d=this.resolveLayerBoundMaterial(h,e,i,r,s,o);return d?d===h?(this.refreshLayerBoundMaterialColor(h,i,s),h):d:h},c=t.material;if(Array.isArray(c)){t.material=c.map(l),uh(a,t.material),this.ensureUnbatchedLineDistance(t,t.material);return}const u=l(c);u!==c&&(t.material=u,uh(a,u)),this.ensureUnbatchedLineDistance(t,t.material)}ensureUnbatchedLineDistance(t,e){if(Im(t)){He.ensureLineDistance(t.geometry,e);return}if(!Pm(t))return;const i=Array.isArray(e)?e[0]:e;i&&i.dashed===!0&&!t.geometry.getAttribute("instanceDistanceStart")&&t.computeLineDistances()}rematerializeLayerTextDrawables(t,e,i){var r;for(const s of this._unbatchedObjects.children){const o=en(s).textEntityTraits;o==null||o.layer!==t||ki.rematerializeTextHierarchy(s,ki.cloneEntityTraits(o),e)}if(i!=null&&i.color)for(const s of this.groups)for(const o of[...s.keys()]){const a=s.get(o),l=(r=a==null?void 0:a[0])==null?void 0:r.material;!l||!lh(l,t,t)||this.refreshLayerBoundMaterialColor(l,i,e)}}resolveLayerBoundMaterial(t,e,i,r,s,o){const a=r(t,e,i);if(a)return a;if(s)return this.resolveLayerBoundReplacement(t,e,s,o??e)}resolveLayerBoundReplacement(t,e,i,r){if(!lh(t,e,r))return;const s=gi(t),o=Lm.createDefaultTraits();return o.layer=e,o.color.setByLayer(),o.drawOrder=s.drawOrder??0,s.drawOrder===0&&s.isForeground!==!0?i.getMTextFillMaterial(o):i.getLineMaterial(o,!0)}refreshLayerBoundMaterialColor(t,e,i){var r,s;if(gi(t).isByLayerColor!==!0)return;const o=((r=e.color)==null?void 0:r.isForeground)===!0;if(ab(t,{isForeground:o}),o&&!i)return;const a=o&&i?zc(i.currentBackgroundColor):(s=e.color)==null?void 0:s.RGB;typeof a!="number"||this.getMaterialDisplayRgb(t)===a||Pn.setMaterialColor(t,new Zt(a))}getMaterialDisplayRgb(t){var e,i;if(t instanceof Xs||t instanceof wl)return t.color.getHex();const r=(i=(e=t.uniforms)==null?void 0:e.u_color)==null?void 0:i.value;if(r instanceof Zt)return r.getHex()}hasEntity(t){return this._entitiesMap.has(t)||this._unbatchedEntities.has(t)}forEachEntitySlot(t,e){const i=this._entitiesMap.get(t);if(i!=null){if(!Array.isArray(i)){e(i);return}for(let r=0,s=i.length;r<s;r++)if(e(i[r])===!0)return}}appendEntitySlot(t,e){const i=this._entitiesMap.get(t);i==null?this._entitiesMap.set(t,e):Array.isArray(i)?i.push(e):this._entitiesMap.set(t,[i,e])}setEntityVisible(t,e){const i=this._unbatchedEntities.get(t);return!this._entitiesMap.has(t)&&!i?!1:(this.forEachEntitySlot(t,r=>{const s=this.getOriginBatch(r.batchedObjectId);s==null||s.setVisibleAt(r.batchId,e)}),i==null||i.forEach(r=>{r.visible=e}),e||(this.unselect(t),this.unhover(t)),!0)}getEntityVisible(t){const e=this._unbatchedEntities.get(t),i=this._entitiesMap.has(t);if(!i&&!e)return;let r,s=0;if(i){let o=!0;this.forEachEntitySlot(t,a=>(s++,this.getBatchItemVisible(a)?!1:(o=!1,!0))),s>0&&(r=o)}if(e&&e.length>0){const o=e.some(a=>a.visible);r=(r===void 0||r)&&o}return r}addEntity(t){if(t.visible===!1)return;const e=String(t.objectId??""),i=t.visible,r=[],s=this._unbatchedEntities.get(e)??[];let o=!1;const a=t.styleManager;if(t.updateMatrixWorld(!0),t.userData.annotationScale){const c=this.cloneEntityAsPlainShell(t);c.visible=i,this._unbatchedObjects.add(c),s.push(c),this._entitiesMap.has(e)||this._entitiesMap.set(e,null),this._unbatchedEntities.set(e,s),this.syncCompareRoleForEntity(e);return}const l=c=>{if(!ub(c))return;const u=en(c),h=!!u.bboxIntersectionCheck;if(u.noBatch){const f=this.cloneUnbatchedObject(c);f.visible=i&&c.visible;const p=f.material,g=Array.isArray(p)?p[0]:p;g&&(gi(g).drawOrder??0)>=0,en(f).bboxIntersectionCheck=h,this._unbatchedObjects.add(f),s.push(f),o=!0;return}const d=this.tryAddSharedDrawable(c,e,h);if(d)r.push(d),this.applyBatchSlotVisibility(d,i&&c.visible);else if(Pm(c)){const f=this.addLine2(c,{objectId:e,bboxIntersectionCheck:h});f&&(r.push(f),this.applyBatchSlotVisibility(f,i&&c.visible));return}else if(Im(c)){const f=this.addLine(c,{position:u.position,objectId:e,bboxIntersectionCheck:h});f&&(r.push(f),this.applyBatchSlotVisibility(f,i&&c.visible))}else if(hb(c)){const f=this.addMesh(c,{objectId:e,bboxIntersectionCheck:h},a);f&&(r.push(f),this.applyBatchSlotVisibility(f,i&&c.visible))}else if(db(c)){const f=this.addPoint(c,{objectId:e,bboxIntersectionCheck:h});f&&(r.push(f),this.applyBatchSlotVisibility(f,i&&c.visible))}for(const f of c.children)l(f)};if(l(t),r.length===0)this._entitiesMap.has(e)||this._entitiesMap.set(e,null);else for(let c=0;c<r.length;c++)this.appendEntitySlot(e,r[c]);o&&this._unbatchedEntities.set(e,s),this.syncCompareRoleForEntity(e)}syncCompareRoleForEntity(t){if(!this._compareEnabled)return;const e=this._compareRoles.get(t)??null;this.applyCompareRoleToEntity(t,e),this.refreshUnbatchedCompareMaterial(t),this.rebindCompareOverlaySharedBuffers(),this.syncCompareOverlayForEntity(t)}appendLineGeometry(t,e,i,r){if(r.visible===!1)return!1;ws(i,e);const s=t.getIndex()!==null?this._lineWithIndexBatches:this._lineBatches,o=this.resolveOriginBatch(s,e.id,i,()=>new Hm(dn.INITIAL_LINE_VERTEX_CAPACITY,dn.INITIAL_LINE_INDEX_CAPACITY,this.createOwnedBatchMaterial(e)));t.hasAttribute("lineDistance")&&He.recomputeLineDistanceForLineSegments(t);const a=o.addGeometry(t,-1,-1,i);o.setGeometryInfo(a,{objectId:r.objectId});const l={batchedObjectId:o.id,batchId:a};return this.registerDirectAppend(r.objectId,l,!0),!0}appendLine2Geometry(t,e,i,r){if(r.visible===!1)return!1;ws(i,e);const s=this.resolveOriginBatch(this._line2Batches,e.id,i,()=>new xh(dn.INITIAL_LINE_VERTEX_CAPACITY,this.createOwnedBatchMaterial(e))),o=s.addGeometry(t,-1,i);s.setGeometryInfo(o,{objectId:r.objectId});const a={batchedObjectId:s.id,batchId:o};return this.registerDirectAppend(r.objectId,a,!0),!0}appendPointGeometry(t,e,i,r){if(r.visible===!1)return!1;ws(i,e);const s=this.resolveOriginBatch(this._pointBatches,e.id,i,()=>new kb(dn.INITIAL_POINT_VERTEX_CAPACITY,this.createOwnedBatchMaterial(e))),o=s.addGeometry(t,-1,i);s.setGeometryInfo(o,{objectId:r.objectId,bboxIntersectionCheck:!0,position:r.position});const a={batchedObjectId:s.id,batchId:o};return this.registerDirectAppend(r.objectId,a,!0),!0}appendMeshGeometry(t,e,i,r){if(r.visible===!1)return!1;ws(i,e);const s=t.getIndex()!==null?this._meshWithIndexBatches:this._meshBatches,o=this.resolveOriginBatch(s,e.id,i,()=>{const c=gi(e).drawOrder??0,u=new Ib(dn.INITIAL_MESH_VERTEX_CAPACITY,dn.INITIAL_MESH_INDEX_CAPACITY,this.createOwnedBatchMaterial(e));return u.renderOrder=c,u}),a=o.addGeometry(t,-1,-1,i);o.setGeometryInfo(a,{objectId:r.objectId});const l={batchedObjectId:o.id,batchId:a};return this.registerDirectAppend(r.objectId,l,!0),!0}registerDirectAppend(t,e,i){t=String(t),this.appendEntitySlot(t,e),this.applyBatchSlotVisibility(e,i),this.syncCompareRoleForEntity(t)}removeEntity(t){let e=!1,i=!1;if(this._entitiesMap.has(t)){const s=new Map;this.forEachEntitySlot(t,o=>{const a=this.getOriginBatch(o.batchedObjectId);a&&(a.deleteGeometry(o.batchId),s.set(o.batchedObjectId,a),e=!0)}),s.forEach(o=>o.optimize()),i=s.size>0,this.unselect(t),this.unhover(t),this._entitiesMap.delete(t)}const r=this._unbatchedEntities.get(t);return r&&(this.unselect(t),this.unhover(t),r.forEach(s=>{this.disposeObject(s),this._unbatchedObjects.remove(s)}),this._unbatchedEntities.delete(t),e=!0),this._compareEnabled&&(i?this.refreshCompareOverlay():this.removeCompareOverlayForEntity(t)),e}isIntersectWith(t,e){const i=[];let r=!1;if(this.forEachEntitySlot(t,o=>{const a=this.getOriginBatch(o.batchedObjectId);return a&&(a.intersectWith(o.batchId,e,i),i.length>0)?(r=!0,!0):!1}),r)return!0;const s=this._unbatchedEntities.get(t);if(s){for(let o=0;o<s.length;o++)if(this.isUnbatchedDrawableIntersecting(s[o],e))return!0}return!1}hover(t){this.setEntityHighlight([t],"hover",!0)}unhover(t){this.setEntityHighlight([t],"hover",!1)}select(t){this.setEntityHighlight([t],"select",!0)}unselect(t){this.setEntityHighlight([t],"select",!1)}hoverMany(t){this.setEntityHighlight(t,"hover",!0)}unhoverMany(t){this.setEntityHighlight(t,"hover",!1)}selectMany(t){this.setEntityHighlight(t,"select",!0)}unselectMany(t){this.setEntityHighlight(t,"select",!1)}setCompareDisplay(t){var e,i,r;if(this._compareEnabled=t.enabled,t.baseColor!=null&&(this._compareBaseColor=t.baseColor),((e=t.colors)==null?void 0:e.deleted)!=null&&(this._compareDeletedColor=t.colors.deleted),((i=t.colors)==null?void 0:i.added)!=null&&(this._compareAddedColor=t.colors.added),((r=t.colors)==null?void 0:r.modified)!=null&&(this._compareModifiedColor=t.colors.modified),t.overrides){this._compareRoles.clear();for(const s of t.overrides)s.role!=null&&this._compareRoles.set(String(s.objectId),s.role)}t.enabled||this._compareRoles.clear(),this.applyCompareDisplayToBatches(),this.refreshCompareOverlay(),this.refreshAllUnbatchedCompareMaterials()}clearCompareDisplay(){this.setCompareDisplay({enabled:!1,overrides:[]})}setEntityCompareRole(t,e){const i=String(t);e==null?this._compareRoles.delete(i):this._compareRoles.set(i,e),this.applyCompareRoleToEntity(i,e),this.refreshUnbatchedCompareMaterial(i),this.syncCompareOverlayForEntity(i)}applyCompareDisplayToBatches(){const t={enabled:this._compareEnabled,baseColor:this._compareBaseColor,deletedColor:this._compareDeletedColor,addedColor:this._compareAddedColor,modifiedColor:this._compareModifiedColor};for(const e of this.groups)e.forEach(i=>{i.forEach(r=>{r.setCompareDisplayColors(t),r.applyPackedCompareRoles(this._compareRoles)})});this._sharedGeometryBatches.forEach(e=>{e.forEach(i=>i.setCompareDisplayColors(t))})}applyCompareRoleToEntity(t,e){const i=new Set;this.forEachEntitySlot(t,r=>{const s=this.getOriginBatch(r.batchedObjectId);s!=null&&s.setCompareRoleAt(r.batchId,e)&&i.add(s)}),i.forEach(r=>r.flushHighlightMask())}refreshAllUnbatchedCompareMaterials(){this._unbatchedEntities.forEach((t,e)=>{this.refreshUnbatchedCompareMaterial(e)})}refreshUnbatchedCompareMaterial(t){const e=this._unbatchedEntities.get(t);if(e){if(this._unbatchedSelectedIds.has(t)||this._unbatchedHoveredIds.has(t)){this.refreshUnbatchedHighlight(e[0],t);for(const i of e)this.refreshUnbatchedHighlight(i,t);return}for(const i of e){if(!this._compareEnabled){this.unhighlightUnbatchedObject(i);continue}const r=this._compareRoles.get(t),s=this.resolveCompareColor(r);this.applyUnbatchedCompareMaterial(i,s)}}}resolveCompareColor(t){return t==="deleted"?this._compareDeletedColor:t==="added"?this._compareAddedColor:t==="modified"?this._compareModifiedColor:this._compareBaseColor}applyUnbatchedCompareMaterial(t,e){if("material"in t){const i=t.material,r=xr(t);r.originalMaterial==null&&(r.originalMaterial=i);const s=r.originalMaterial??i;t.material=this.getSharedCompareMaterial(s,e);return}for(const i of t.children)this.applyUnbatchedCompareMaterial(i,e)}getSharedCompareMaterial(t,e){if(Array.isArray(t))return t.map(a=>this.getSharedCompareMaterial(a,e));const i=`compare-${e}`;let r=dn.sharedHighlightMaterialsBySource.get(t);r||(r=new Map,dn.sharedHighlightMaterialsBySource.set(t,r),t.addEventListener("dispose",dn.onSourceMaterialDisposed));const s=r.get(i);if(s)return s;const o=Pn.cloneMaterial(t);return Array.isArray(o)||(Pn.setMaterialColor(o,new Zt(e)),r.set(i,o)),o}setEntityHighlight(t,e,i){if(t.length===0)return;const r=new Set;for(const s of t){this.forEachEntitySlot(s,a=>{const l=this.getOriginBatch(a.batchedObjectId);l&&l.setHighlightAt(a.batchId,e,i)&&r.add(l)});const o=this._unbatchedEntities.get(s);if(o){e==="select"?i?this._unbatchedSelectedIds.add(s):this._unbatchedSelectedIds.delete(s):i?this._unbatchedHoveredIds.add(s):this._unbatchedHoveredIds.delete(s);for(const a of o)this.refreshUnbatchedHighlight(a,s);i||this.refreshUnbatchedCompareMaterial(s)}}r.forEach(s=>s.flushHighlightMask())}refreshUnbatchedHighlight(t,e){if(this._unbatchedSelectedIds.has(e)){this.applyUnbatchedHighlightMaterial(t,"select");return}if(this._unbatchedHoveredIds.has(e)){this.applyUnbatchedHighlightMaterial(t,"hover");return}this.unhighlightUnbatchedObject(t)}applyUnbatchedHighlightMaterial(t,e){if("material"in t){const i=t.material,r=xr(t);r.originalMaterial==null&&(r.originalMaterial=i),t.material=this.getSharedHighlightMaterial(i,e);return}for(const i of t.children)this.applyUnbatchedHighlightMaterial(i,e)}unhighlightUnbatchedObject(t){if("material"in t){const e=xr(t);e.originalMaterial!=null&&(t.material=e.originalMaterial,delete e.originalMaterial);return}for(const e of t.children)this.unhighlightUnbatchedObject(e)}getSharedHighlightMaterial(t,e){if(Array.isArray(t))return t.map(o=>this.getSharedHighlightMaterial(o,e));let i=dn.sharedHighlightMaterialsBySource.get(t);i||(i=new Map,dn.sharedHighlightMaterialsBySource.set(t,i),t.addEventListener("dispose",dn.onSourceMaterialDisposed));const r=i.get(e);if(r)return r;const s=Pn.cloneMaterial(t);return Array.isArray(s)||(Pn.setMaterialColor(s,e==="hover"?hh:zl),i.set(e,s)),s}static releaseSharedHighlightMaterials(t){const e=dn.sharedHighlightMaterialsBySource.get(t);e&&(e.forEach(i=>i.dispose()),dn.sharedHighlightMaterialsBySource.delete(t))}createPreviewSubset(t,e){if(t.length===0)return null;const i=(e==null?void 0:e.maxSlots)??1e4,r=(e==null?void 0:e.missingEntity)??"fail",s=new pi;s.name="PreviewSubset",s.userData.previewSubsetGroup=!0;let o=0;for(const a of t){if(o>=i)return Ub(s),null;const l=this.appendEntityOverlayDrawables(a,s,{maxSlots:i-o,mode:"preview",previewStyle:(e==null?void 0:e.style)??"normal"});if(l===0){if(r==="skip")continue;return Ub(s),null}o+=l}return o>0?s:null}get groups(){return[this._lineBatches,this._lineWithIndexBatches,this._line2Batches,this._meshBatches,this._meshWithIndexBatches,this._pointBatches,this._pointSymbolBatches]}unhighlight(t,e){if(e===this._selectedObjects){this.unselect(t);return}e===this._hoverObjects&&this.unhover(t)}appendEntityOverlayDrawables(t,e,i){let r=0;const s=a=>{if(i.mode==="highlight"){this.applyHighlightMaterial(a);return}if(i.mode==="compare"){this.applyCompareOverlayMaterial(a,i.compareColor??2278750);return}this.applyPreviewMaterial(a,i.previewStyle??"normal")};r<i.maxSlots&&this.forEachEntitySlot(t,a=>{if(r>=i.maxSlots)return!0;const l=this.getOriginBatch(a.batchedObjectId);if(!l||!this.hasBatchObjectAt(l))return!1;const c=l.getObjectAt(a.batchId);this.copyHighlightMetadata(l,c),s(c);const u=Ul(c);return u.objectId=t,u.batchedObjectId=a.batchedObjectId,u.disposeGeometryOnRemove=l instanceof xh||l instanceof Gm,u.previewDrawable=i.mode==="preview",c.renderOrder=e.renderOrder,e.add(c),r++,!1});const o=this._unbatchedEntities.get(t);if(o&&r<i.maxSlots){const a=Math.min(o.length,i.maxSlots-r);for(let l=0;l<a;l++){const c=o[l],u=c.clone();this.copyHighlightMetadata(c,u),s(u);const h=Ul(u);h.objectId=t,h.previewDrawable=i.mode==="preview",u.renderOrder=e.renderOrder,e.add(u),r++}}return r}hasBatchObjectAt(t){return typeof t.getObjectAt=="function"}applyPreviewMaterial(t,e){this.hasMaterial(t)&&(t.material=Pn.cloneMaterial(t.material)),t.children.forEach(i=>this.applyPreviewMaterial(i,e))}applyHighlightMaterial(t){if(this.hasMaterial(t)){const e=Pn.cloneMaterial(t.material);Pn.setMaterialColor(e),t.material=e}t.children.forEach(e=>this.applyHighlightMaterial(e))}applyCompareOverlayMaterial(t,e){const i=r=>{if(r instanceof gr){const s=r.material,o=new Pl({color:e,linewidth:s.linewidth,worldUnits:s.worldUnits,dashed:!1});o.resolution.copy(s.resolution),o.depthTest=!0,o.polygonOffset=!0,o.polygonOffsetFactor=-2,o.polygonOffsetUnits=-2,r.material=o}else if(r instanceof Ys||r instanceof Vo)r.material=new wl({color:e,depthTest:!0,polygonOffset:!0,polygonOffsetFactor:-2,polygonOffsetUnits:-2});else if(r instanceof cn)r.material=new Xs({color:e,side:Ei,depthTest:!0,polygonOffset:!0,polygonOffsetFactor:-2,polygonOffsetUnits:-2});else if(r instanceof ur){const s=r.material;r.material=new Op({color:e,size:s.size,sizeAttenuation:s.sizeAttenuation,depthTest:!0})}r.children.forEach(s=>i(s))};i(t)}rebindCompareOverlaySharedBuffers(){if(this._compareOverlay.children.length!==0)for(const t of this._compareOverlay.children){const e=Ul(t);if(e.batchedObjectId==null||e.disposeGeometryOnRemove)continue;const i=this.getOriginBatch(e.batchedObjectId),r=this.getDrawableGeometry(t);i==null||r==null||i instanceof Gm||r.attributes!==i.geometry.attributes&&(r.index=i.geometry.index,r.attributes=i.geometry.attributes)}}refreshCompareOverlay(){this.clearHighlightGroup(this._compareOverlay),this._compareEnabled&&this._compareRoles.forEach((t,e)=>{this.appendEntityOverlayDrawables(e,this._compareOverlay,{maxSlots:1e4,mode:"compare",compareColor:this.resolveCompareColor(t)})})}syncCompareOverlayForEntity(t){if(this.removeCompareOverlayForEntity(t),!this._compareEnabled)return;const e=this._compareRoles.get(t);e!=null&&this.appendEntityOverlayDrawables(t,this._compareOverlay,{maxSlots:1e4,mode:"compare",compareColor:this.resolveCompareColor(e)})}removeCompareOverlayForEntity(t){const e=this._compareOverlay.children.filter(i=>Ul(i).objectId===t);e.forEach(i=>this.disposeHighlightObject(i)),e.forEach(i=>i.removeFromParent())}getOriginBatch(t){return this._originBatchById.get(t)??this._sharedBatchById.get(t)}copyHighlightMetadata(t,e){cb(t,e)}applyBatchSlotVisibility(t,e){const i=this.getOriginBatch(t.batchedObjectId);i==null||i.setVisibleAt(t.batchId,e)}getBatchItemVisible(t){const e=this.getOriginBatch(t.batchedObjectId);return(e==null?void 0:e.getVisibleAt(t.batchId))??!1}tryAddSharedDrawable(t,e,i){var r;if(en(t).sharesTemplateGeometry!==!0||!this.hasGeometry(t)||!this.hasMaterial(t))return null;const s=t.material;if(Array.isArray(s))return null;const o=this.sharedGeometryKind(t);if(!o)return null;const a=t.geometry;if(!((r=a.getAttribute("position"))!=null&&r.count)||(t.updateWorldMatrix(!0,!1),this.mustBakeSharedDrawable(t,o,a)))return null;const l=t.matrixWorld.clone();(gi(s).drawOrder??0)>=0&&(l.elements[14]+=Db());const c=new H().setFromMatrixPosition(l),u=this.resolveSharedGeometryBatch(a,s,o,c),h=u.addInstance(l,e,i);return{batchedObjectId:u.id,batchId:h}}mustBakeSharedDrawable(t,e,i){const r=t.material;if(Array.isArray(r)||e==="mesh"&&t.matrixWorld.determinant()<0)return!0;if(!(e==="line2"?r.dashed===!0:i.getAttribute("lineDistance")!=null))return!1;const s=Dk(t.matrixWorld);return s==null||Math.abs(s-1)>1e-4}sharedGeometryKind(t){return Pm(t)?"line2":Im(t)?"line":hb(t)?"mesh":db(t)?"points":null}resolveSharedGeometryBatch(t,e,i,r){const s=`${i}:${t.uuid}:${e.id}`;let o=this._sharedGeometryBatches.get(s);o||(o=[],this._sharedGeometryBatches.set(s,o));let a,l=1/0;for(const h of o){if(!sb(h.origin,r))continue;const d=Am(h.origin,r);d<l&&(l=d,a=h)}if(a)return a;let c=this._ownedSharedGeometries.get(t.uuid);c||(c=t.clone(),this._ownedSharedGeometries.set(t.uuid,c));const u=new Gm(c,e,r,i,t.uuid);return this._compareEnabled&&u.setCompareDisplayColors({enabled:!0,baseColor:this._compareBaseColor,deletedColor:this._compareDeletedColor,addedColor:this._compareAddedColor,modifiedColor:this._compareModifiedColor}),o.push(u),this._sharedBatchById.set(u.id,u),this.add(u),u}rebindSharedGeometryMaterial(t,e){const i=[];for(const[r,s]of this._sharedGeometryBatches){const o=[];for(const a of s){if(a.materialId!==t){o.push(a);continue}a.material=e,i.push(a)}o.length===0?this._sharedGeometryBatches.delete(r):o.length!==s.length&&this._sharedGeometryBatches.set(r,o)}for(const r of i){const s=`${r.kind}:${r.sourceUuid}:${e.id}`,o=this._sharedGeometryBatches.get(s);o?o.push(r):this._sharedGeometryBatches.set(s,[r])}}addLine(t,e){const i=t.material,r=this.getMatchedLineBatches(t),s=new H().setFromMatrixPosition(t.matrixWorld);ws(s,i);const o=this.resolveOriginBatch(r,i.id,s,()=>new Hm(dn.INITIAL_LINE_VERTEX_CAPACITY,dn.INITIAL_LINE_INDEX_CAPACITY,this.createOwnedBatchMaterial(i))),a=t.geometry.clone(),l=t.matrixWorld.clone();if(l.setPosition(0,0,0),!He.safeApplyMatrix4(a,l,2))return a.dispose(),null;a.hasAttribute("lineDistance")&&He.recomputeLineDistanceForLineSegments(a);const c=o.addGeometry(a,-1,-1,s);return o.setGeometryInfo(c,e),a.dispose(),{batchedObjectId:o.id,batchId:c}}addLine2(t,e){const i=t.material,r=new H().setFromMatrixPosition(t.matrixWorld);ws(r,i);const s=this.resolveOriginBatch(this._line2Batches,i.id,r,()=>new xh(dn.INITIAL_LINE_VERTEX_CAPACITY,this.createOwnedBatchMaterial(i))),o=t.matrixWorld.clone();o.setPosition(0,0,0);const a=this.cloneLineSegments2Geometry(t,o);if(!a)return null;const l=s.addGeometry(a,-1,r);return s.setGeometryInfo(l,e),a.dispose(),{batchedObjectId:s.id,batchId:l}}addMesh(t,e,i){let r=t.material;t.matrixWorld.determinant()<0&&(r=i.getBackSideVariant(r),t.material=r);const s=this.getMatchedMeshBatches(t),o=new H().setFromMatrixPosition(t.matrixWorld);ws(o,r);const a=this.resolveOriginBatch(s,r.id,o,()=>{const h=gi(r).drawOrder??0,d=new Ib(dn.INITIAL_MESH_VERTEX_CAPACITY,dn.INITIAL_MESH_INDEX_CAPACITY,this.createOwnedBatchMaterial(r));return d.renderOrder=h,d}),l=t.geometry.clone(),c=t.matrixWorld.clone();if(c.setPosition(0,0,0),!He.safeApplyMatrix4(l,c,3))return l.dispose(),null;const u=a.addGeometry(l,-1,-1,o);return a.setGeometryInfo(u,e),l.dispose(),{batchedObjectId:a.id,batchId:u}}addPoint(t,e){const i=t.material,r=new H().setFromMatrixPosition(t.matrixWorld);ws(r,i);const s=this.resolveOriginBatch(this._pointBatches,i.id,r,()=>{const c=new kb(dn.INITIAL_POINT_VERTEX_CAPACITY,this.createOwnedBatchMaterial(i));return c.visible=t.visible,c}),o=t.geometry.clone(),a=t.matrixWorld.clone();if(a.setPosition(0,0,0),!He.safeApplyMatrix4(o,a,2))return o.dispose(),null;const l=s.addGeometry(o,-1,r);return s.setGeometryInfo(l,e),o.dispose(),{batchedObjectId:s.id,batchId:l}}resolveOriginBatch(t,e,i,r){let s=t.get(e);s==null&&(s=[],t.set(e,s));let o,a=1/0;for(const c of s){if(!sb(c.origin,i))continue;const u=c.origin;if(u==null)return c;const h=Am(u,i);h<a&&(a=h,o=c)}if(o)return this.ensureBatchHighlightRenderer(o),o;const l=r();return this._compareEnabled&&l.setCompareDisplayColors({enabled:!0,baseColor:this._compareBaseColor,deletedColor:this._compareDeletedColor,addedColor:this._compareAddedColor,modifiedColor:this._compareModifiedColor}),s.push(l),this._originBatchById.set(l.id,l),this.add(l),this.ensureBatchHighlightRenderer(l),l}repaintForegroundMaterials(t){const e=new Zt(t),i=r=>{gi(r).isForeground===!0&&Pn.setMaterialColor(r,e)};for(const r of this.groups)r.forEach(s=>{s.forEach(o=>{const a=o.material;Array.isArray(a)?a.forEach(i):a&&i(a)})});this._unbatchedObjects.traverse(r=>{if(!("material"in r))return;const s=r.material;Array.isArray(s)?s.forEach(i):s&&i(s)})}repaintBackgroundMaterials(t){const e=new Zt(t),i=r=>{gi(r).isBackgroundFill===!0&&Pn.setMaterialColor(r,e)};for(const r of this.groups)r.forEach(s=>{s.forEach(o=>{const a=o.material;Array.isArray(a)?a.forEach(i):a&&i(a)})});this._unbatchedObjects.traverse(r=>{if(!("material"in r))return;const s=r.material;Array.isArray(s)?s.forEach(i):s&&i(s)})}createOwnedBatchMaterial(t){const e=Pn.cloneMaterial(t);return ab(e,{...gi(t)}),e}ensureBatchHighlightRenderer(t){const e=t._highlightState;e&&ca(t,e)}countBatchContainers(t){let e=0;return t.forEach(i=>{e+=i.length}),e}getBatchedGeometrySize(t){let e=0;return t.forEach(i=>{i.forEach(r=>{e+=this.getGeometrySize(r)})}),e}getBatchedGeometryMappingSize(t){let e=0;return t.forEach(i=>{i.forEach(r=>{e+=r.mappingStats.size})}),e}getMatchedLineBatches(t){if(en(t).isPoint)return this._pointSymbolBatches;{const e=t.geometry.getIndex()!==null;let i=this._lineBatches;return e&&(i=this._lineWithIndexBatches),i}}getMatchedMeshBatches(t){const e=t.geometry.getIndex()!==null;let i=this._meshBatches;return e&&(i=this._meshWithIndexBatches),i}getGeometrySize(t){const e=new Set;let i=0;if(this.hasGeometry(t)){const r=t.geometry;if(Object.keys(r.attributes).forEach(s=>{const o=r.attributes[s],a=this.getAttributeArray(o);a&&!e.has(a.buffer)&&(i+=a.byteLength,e.add(a.buffer))}),r.index){const s=r.index.array;e.has(s.buffer)||(i+=s.byteLength,e.add(s.buffer))}}return i}getUnbatchedStats(){const t={count:0,geometrySize:0,byType:{line:0,mesh:0,point:0,other:0}};return this._unbatchedObjects.children.forEach(e=>{t.count+=1,t.geometrySize+=this.getGeometrySize(e),this.isLineObject(e)?t.byType.line+=1:e instanceof cn?t.byType.mesh+=1:e instanceof ur?t.byType.point+=1:t.byType.other+=1}),t}cloneUnbatchedObject(t){if(this.shouldCloneUnbatchedSubtree(t))return this.cloneUnbatchedSubtree(t);const e=t.clone();if(this.copyWorldMatrixOntoClone(t,e),this.hasMaterial(t)&&this.hasMaterial(e)){const i=t.material,r=this.materialHasTextureMap(i);r?(e.material=this.cloneUnbatchedTexturedMaterial(i),this.hasGeometry(t)&&this.hasGeometry(e)&&(e.geometry=t.geometry.clone())):e.material=i;const s=en(t),o=en(e);o.styleMaterialId=s.styleMaterialId??this.getMaterialId(t.material),o.bboxIntersectionCheck=s.bboxIntersectionCheck,o.sharesTemplateGeometry=r?!1:s.sharesTemplateGeometry,o.bakedWorldMatrix=t.matrixWorld.toArray(new Array(16)),s.textEntityTraits&&(o.textEntityTraits=ki.cloneEntityTraits(s.textEntityTraits))}return this.finalizeUnbatchedLineClone(e),e}materialHasTextureMap(t){return Array.isArray(t)?t.some(e=>this.materialHasTextureMap(e)):!!t.map}cloneUnbatchedTexturedMaterial(t){if(Array.isArray(t))return t.map(r=>this.cloneUnbatchedTexturedMaterial(r));const e=t.clone(),i=t.map;if(i){const r=i.clone();r.needsUpdate=!0,e.map=r}return e}finalizeUnbatchedLineClone(t){if(!this.isLineObject(t))return;t.frustumCulled=!1;const e=this.getDrawableGeometry(t);e&&(He.safeComputeBoundingBox(e),He.safeComputeBoundingSphere(e))}getDrawableGeometry(t){if(t instanceof gr||t instanceof cn||t instanceof Ys||t instanceof Vo||t instanceof ur)return t.geometry}shouldCloneUnbatchedSubtree(t){return t.children.length===0?!1:t instanceof xs?!0:!this.hasGeometry(t)}cloneEntityAsPlainShell(t){const e=new wn;this.copyWorldMatrixOntoClone(t,e),e.userData={...t.userData};const i=en(t),r=en(e);r.noBatch=!0,r.bboxIntersectionCheck=i.bboxIntersectionCheck,r.bakedWorldMatrix=t.matrixWorld.toArray(new Array(16)),i.textEntityTraits&&(r.textEntityTraits=ki.cloneEntityTraits(i.textEntityTraits));for(const s of t.children)if(s instanceof xs)for(const o of s.children)e.add(o.clone(!0));else e.add(s.clone(!0));return e.traverse(s=>{if(!this.hasMaterial(s))return;const o=en(s);o.styleMaterialId==null&&(o.styleMaterialId=this.getMaterialId(s.material))}),e}cloneUnbatchedSubtree(t){if(t instanceof xs)return this.cloneEntityAsPlainShell(t);const e=t.clone(!0);this.copyWorldMatrixOntoClone(t,e);const i=en(t),r=en(e);return r.bboxIntersectionCheck=i.bboxIntersectionCheck,r.bakedWorldMatrix=t.matrixWorld.toArray(new Array(16)),i.textEntityTraits&&(r.textEntityTraits=ki.cloneEntityTraits(i.textEntityTraits)),e.traverse(s=>{if(!this.hasMaterial(s))return;const o=en(s);o.styleMaterialId==null&&(o.styleMaterialId=this.getMaterialId(s.material))}),e}copyWorldMatrixOntoClone(t,e){t.updateMatrixWorld(!0),e.matrixAutoUpdate=!1,e.matrix.copy(t.matrixWorld),e.matrixWorld.copy(t.matrixWorld),e.matrixWorldNeedsUpdate=!1}cloneLineSegments2Geometry(t,e){const i=t.geometry,r=i.getAttribute("instanceStart"),s=i.getAttribute("instanceEnd"),o=r.count,a=[];for(let c=0;c<o;c++)Es.fromBufferAttribute(r,c).applyMatrix4(e),eo.fromBufferAttribute(s,c).applyMatrix4(e),!(!Number.isFinite(Es.x)||!Number.isFinite(Es.y)||!Number.isFinite(Es.z)||!Number.isFinite(eo.x)||!Number.isFinite(eo.y)||!Number.isFinite(eo.z))&&a.push(Es.x,Es.y,Es.z,eo.x,eo.y,eo.z);if(a.length<6)return null;const l=new ms;return l.setPositions(new Float32Array(a)),i.hasAttribute("instanceColorStart")&&(l.setAttribute("instanceColorStart",i.getAttribute("instanceColorStart").clone()),l.setAttribute("instanceColorEnd",i.getAttribute("instanceColorEnd").clone())),He.safeComputeBoundingBox(l),He.safeComputeBoundingSphere(l),l}disposeObject(t){t.removeFromParent(),this.hasGeometry(t)&&!en(t).sharesTemplateGeometry&&t.geometry.dispose(),t.children.forEach(e=>this.disposeObject(e))}clearHighlightGroup(t){[...t.children].forEach(e=>this.disposeHighlightObject(e)),t.clear()}disposeHighlightObject(t){Vm(t)}unionUnbatchedObjectBounds(t,e,i){const r=this.getDrawableGeometry(t);if(r){if(He.safeComputeBoundingBox(r),!r.boundingBox)return;i.copy(r.boundingBox).applyMatrix4(t.matrixWorld),e.union(i);return}for(const s of t.children)s.visible!==!1&&this.unionUnbatchedObjectBounds(s,e,i)}isUnbatchedDrawableIntersecting(t,e){return en(t).bboxIntersectionCheck?this.isUnbatchedBboxIntersecting(t,e):e.intersectObject(t,!0).length>0}isUnbatchedBboxIntersecting(t,e){t.updateMatrixWorld(!0),Gl.makeEmpty();const i=this.getDrawableGeometry(t);if(i){if(He.safeComputeBoundingBox(i),!i.boundingBox)return!1;Gl.copy(i.boundingBox).applyMatrix4(t.matrixWorld)}else if(this.unionUnbatchedObjectBounds(t,Gl,Uk),Gl.isEmpty())return!1;return e.ray.intersectBox(Gl,Es)!==null}hasMaterial(t){return"material"in t}hasGeometry(t){return"geometry"in t}getAttributeArray(t){return"array"in t&&t.array?t.array:"data"in t&&t.data&&t.data.array?t.data.array:null}isLineObject(t){return t instanceof Vo?!0:!!t.isLineSegments2}getMaterialId(t){var e;return Array.isArray(t)?((e=t[0])==null?void 0:e.id)??-1:t.id}};Ms.INITIAL_LINE_VERTEX_CAPACITY=128,Ms.INITIAL_LINE_INDEX_CAPACITY=256,Ms.INITIAL_MESH_VERTEX_CAPACITY=128,Ms.INITIAL_MESH_INDEX_CAPACITY=256,Ms.INITIAL_POINT_VERTEX_CAPACITY=16,Ms.sharedHighlightMaterialsBySource=new WeakMap,Ms.onSourceMaterialDisposed=n=>{Ms.releaseSharedHighlightMaterials(n.target)};function Ub(n){Vm(n)}function Vm(n){for(const t of[...n.children])Vm(t);Ok(n)}function Ok(n){if(Bk(n)){const t=n.material;Array.isArray(t)?t.forEach(e=>e.dispose()):t.dispose()}Nk(n)&&Ul(n).disposeGeometryOnRemove&&n.geometry.dispose()}function Bk(n){return"material"in n&&n.material!=null}function Nk(n){return"geometry"in n&&n.geometry!=null}function Dk(n){const t=n.elements,e=Math.hypot(t[0],t[1],t[2]),i=Math.hypot(t[4],t[5],t[6]),r=Math.hypot(t[8],t[9],t[10]),s=Math.max(e,i,r),o=Math.min(e,i,r);return s===0||(s-o)/s>1e-4?null:e}const Es=new H,eo=new H,Gl=new Re,Uk=new Re;function zk(n,t=Gi){const e={u_startColor:{value:new Zt(n.startColor)},u_endColor:{value:new Zt(n.endColor)},u_angle:{value:n.angle},u_shift:{value:n.shift},u_gradientType:{value:n.gradientType}},i=`
|
|
4684
4684
|
attribute vec2 gradientPosition;
|
|
4685
4685
|
|
|
4686
4686
|
varying vec2 v_gradientPosition;
|