@mlightcad/data-model 1.1.6 → 1.1.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.
@@ -1,2 +1,5 @@
1
- (function(g,ce){typeof exports=="object"&&typeof module<"u"?ce(exports):typeof define=="function"&&define.amd?define(["exports"],ce):(g=typeof globalThis<"u"?globalThis:g||self,ce(g["data-model"]={}))})(this,function(g){"use strict";function ce(n,t){for(var e=0;e<t.length;e++){const s=t[e];if(typeof s!="string"&&!Array.isArray(s)){for(const r in s)if(r!=="default"&&!(r in n)){const i=Object.getOwnPropertyDescriptor(s,r);i&&Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:()=>s[r]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}const Re={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},fs=[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];function de(n,t,e){return Math.max(t,Math.min(e,n))}const mn=class ha{constructor(){this._colorIndex=256,this._color=null,this._colorName=null}get color(){return this._color}set color(t){t==null?this._color=null:(this._color=Math.round(de(t,0,256*256*256-1)),this._colorIndex=this.getColorIndexByValue(this._color),this._colorName=this.getColorNameByValue(this._color))}get hexColor(){if(this._color&&this._color>0&&this._color<=16777215){let t=this._color.toString(16).toUpperCase();for(;t.length<6;)t="0"+t;return`0x${t}`}return""}get cssColor(){return`rgb(${this.red},${this.green},${this.blue})`}get red(){return this.color?this.color>>16&255:null}get green(){return this.color?this.color>>8&255:null}get blue(){return this.color?this.color&255:null}get colorIndex(){return this._colorIndex}set colorIndex(t){t==null?this._colorIndex=null:(this._colorIndex=de(t,0,256),this._color=fs[t],this._colorName=this.getColorNameByValue(this._color))}get colorName(){return this._colorName}set colorName(t){if(t){const e=Re[t.toLowerCase()];e!==void 0?(this._colorName=t,this._color=e,this._colorIndex=this.getColorIndexByValue(this._color)):console.warn("Unknown color: "+t)}else this._colorName=null}get hasColorName(){return this._colorName==null}get hasColorIndex(){return this._colorIndex==null}get isByLayer(){return this.colorIndex==256}setByLayer(){return this.colorIndex=256,this}get isByBlock(){return this.colorIndex==0}setByBlock(){return this.colorIndex=0,this}setScalar(t){return this.setRGB(t,t,t),this}setRGB(t,e,s){const r=Math.round(de(t,0,255)),i=Math.round(de(e,0,255)),a=Math.round(de(s,0,255));return this.color=(r<<16)+(i<<8)+a,this}setColorName(t){const e=Re[t.toLowerCase()];return e!==void 0?this.color=e:console.warn("Unknown color "+t),this}clone(){const t=new ha;return t.colorIndex=this.colorIndex,t.color=this.color,t._colorName=this._colorName,this}copy(t){return this.colorIndex=t.colorIndex,this.color=t.color,this._colorName=t._colorName,this}equals(t){return t.color==this.color&&t.colorIndex==this.colorIndex&&t._colorName==this._colorName}toString(){return this.isByLayer?"ByLayer":this.isByBlock?"ByBlock":this.colorName?this.colorName:this.hexColor}getColorNameByValue(t){for(const[e,s]of Object.entries(Re))if(s===t)return e;return null}getColorIndexByValue(t){const e=fs.length-1;for(let s=1;s<e;++s)if(fs[s]===t)return s;return null}};mn.NAMES=Re;let zt=mn;const et={get ILLEGAL_PARAMETERS(){return new ReferenceError("Illegal Parameters")},get ZERO_DIVISION(){return new Error("Zero division")},get UNRESOLVED_BOUNDARY_CONFLICT(){return new Error("Unresolved boundary conflict in boolean operation")},get INFINITE_LOOP(){return new Error("Infinite loop")},get CANNOT_INVOKE_ABSTRACT_METHOD(){return new Error("Abstract method cannot be invoked")},get OPERATION_IS_NOT_SUPPORTED(){return new Error("Operation is not supported")},get NOT_IMPLEMENTED(){return new Error("Not implemented yet")}};class ga{constructor(){this._listeners={}}addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const s=this._listeners;s[t]===void 0&&(s[t]=[]),s[t].indexOf(e)===-1&&s[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const s=this._listeners;return s[t]!==void 0&&s[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const s=this._listeners[t];if(s!==void 0){const r=s.indexOf(e);r!==-1&&s.splice(r,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const e=this._listeners[t.type];if(e!==void 0){t.target=this;const s=e.slice(0);for(let r=0,i=s.length;r<i;r++)s[r].call(this,t)}}}let st=class{constructor(){this.listeners=[]}addEventListener(t){this.listeners.push(t)}removeEventListener(t){this.listeners=this.listeners.filter(e=>e!==t)}replaceEventListener(t){this.removeEventListener(t),this.addEventListener(t)}dispatch(t,...e){for(const s of this.listeners)s.call(null,t,...e)}};var pa=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ya(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var gn={exports:{}};(function(n){(function(t,e){n.exports?n.exports=e():t.log=e()})(pa,function(){var t=function(){},e="undefined",s=typeof window!==e&&typeof window.navigator!==e&&/Trident\/|MSIE /.test(window.navigator.userAgent),r=["trace","debug","info","warn","error"],i={},a=null;function o(_,x){var f=_[x];if(typeof f.bind=="function")return f.bind(_);try{return Function.prototype.bind.call(f,_)}catch{return function(){return Function.prototype.apply.apply(f,[_,arguments])}}}function c(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function l(_){return _==="debug"&&(_="log"),typeof console===e?!1:_==="trace"&&s?c:console[_]!==void 0?o(console,_):console.log!==void 0?o(console,"log"):t}function d(){for(var _=this.getLevel(),x=0;x<r.length;x++){var f=r[x];this[f]=x<_?t:this.methodFactory(f,_,this.name)}if(this.log=this.debug,typeof console===e&&_<this.levels.SILENT)return"No console available for logging"}function u(_){return function(){typeof console!==e&&(d.call(this),this[_].apply(this,arguments))}}function m(_,x,f){return l(_)||u.apply(this,arguments)}function p(_,x){var f=this,M,T,S,P="loglevel";typeof _=="string"?P+=":"+_:typeof _=="symbol"&&(P=void 0);function z(N){var V=(r[N]||"silent").toUpperCase();if(!(typeof window===e||!P)){try{window.localStorage[P]=V;return}catch{}try{window.document.cookie=encodeURIComponent(P)+"="+V+";"}catch{}}}function I(){var N;if(!(typeof window===e||!P)){try{N=window.localStorage[P]}catch{}if(typeof N===e)try{var V=window.document.cookie,Jt=encodeURIComponent(P),te=V.indexOf(Jt+"=");te!==-1&&(N=/^([^;]+)/.exec(V.slice(te+Jt.length+1))[1])}catch{}return f.levels[N]===void 0&&(N=void 0),N}}function W(){if(!(typeof window===e||!P)){try{window.localStorage.removeItem(P)}catch{}try{window.document.cookie=encodeURIComponent(P)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function ht(N){var V=N;if(typeof V=="string"&&f.levels[V.toUpperCase()]!==void 0&&(V=f.levels[V.toUpperCase()]),typeof V=="number"&&V>=0&&V<=f.levels.SILENT)return V;throw new TypeError("log.setLevel() called with invalid level: "+N)}f.name=_,f.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},f.methodFactory=x||m,f.getLevel=function(){return S??T??M},f.setLevel=function(N,V){return S=ht(N),V!==!1&&z(S),d.call(f)},f.setDefaultLevel=function(N){T=ht(N),I()||f.setLevel(N,!1)},f.resetLevel=function(){S=null,W(),d.call(f)},f.enableAll=function(N){f.setLevel(f.levels.TRACE,N)},f.disableAll=function(N){f.setLevel(f.levels.SILENT,N)},f.rebuild=function(){if(a!==f&&(M=ht(a.getLevel())),d.call(f),a===f)for(var N in i)i[N].rebuild()},M=ht(a?a.getLevel():"WARN");var vt=I();vt!=null&&(S=ht(vt)),d.call(f)}a=new p,a.getLogger=function(_){if(typeof _!="symbol"&&typeof _!="string"||_==="")throw new TypeError("You must supply a name when creating a logger.");var x=i[_];return x||(x=i[_]=new p(_,a.methodFactory)),x};var y=typeof window!==e?window.log:void 0;return a.noConflict=function(){return typeof window!==e&&window.log===a&&(window.log=y),a},a.getLoggers=function(){return i},a.default=a,a})})(gn);var pn=gn.exports;const _a=ya(pn),fa=ce({__proto__:null,default:_a},[pn]),xa=!0,ue=fa;ue.setLevel("debug");const ba=n=>{try{ue.setLevel(n)}catch(t){ue.setLevel("error"),ue.error(t)}};function me(n){return n===null||typeof n!="object"?n:Array.isArray(n)?[...n]:{...n}}function ee(n,...t){for(const e of t)if(e)for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&n[s]===void 0&&(n[s]=e[s]);return n}function yn(n,t){return n!=null&&Object.prototype.hasOwnProperty.call(n,t)}function _n(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 se(n,t){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(let r=0;r<n.length;r++)if(!se(n[r],t[r]))return!1;return!0}const e=Object.keys(n),s=Object.keys(t);if(e.length!==s.length)return!1;for(const r of e)if(!Object.prototype.hasOwnProperty.call(t,r)||!se(n[r],t[r]))return!1;return!0}let fn=class la{constructor(t,e){this.events={attrChanged:new st,modelChanged:new st},this._changing=!1,this._previousAttributes={},this._pending=!1;const s=t||{};e&&ee(s,e),this.attributes=s,this.changed={}}get(t){return this.attributes[t]}set(t,e,s){if(t==null)return this;let r;typeof t=="object"?(r=t,s=e):(r={},r[t]=e),s||(s={});const i=s.unset,a=s.silent,o=[],c=this._changing;this._changing=!0,c||(this._previousAttributes=me(this.attributes),this.changed={});const l=this.attributes,d=this.changed,u=this._previousAttributes;for(const m in r)e=r[m],se(l[m],e)||o.push(m),se(u[m],e)?delete d[m]:d[m]=e,i?delete l[m]:l[m]=e;if(!a){o.length&&(this._pending=s);for(let m=0;m<o.length;m++)this.events.attrChanged.dispatch({object:this,attrName:o[m],attrValue:l[o[m]],options:s})}if(c)return this;if(!a)for(;this._pending;)s=this._pending,this._pending=!1,this.events.modelChanged.dispatch({object:this,options:s});return this._pending=!1,this._changing=!1,this}has(t){return this.get(t)!=null}hasChanged(t){return t==null?!_n(this.changed):yn(this.changed,t)}changedAttributes(t){if(!t)return this.hasChanged()?me(this.changed):{};const e=this._changing?this._previousAttributes:this.attributes,s={};for(const r in t){const i=t[r];se(e[r],i)||(s[r]=i)}return s}previous(t){return t==null||!this._previousAttributes?null:this._previousAttributes[t]}previousAttributes(){return me(this._previousAttributes)}clone(){const t=me(this.attributes);return new la(t)}},xs=class De{constructor(){this.entries=new Map}static getInstance(){return De.instance||(De.instance=new De),De.instance}collect(t){this.entries.set(t.name,t)}printAll(){for(const[t,e]of this.entries)console.log(`${t}:`),console.log(e.format())}clear(){this.entries.clear()}getAll(){return Array.from(this.entries.values())}getEntry(t){return this.entries.get(t)}remove(t){return this.entries.delete(t)}};class wa{static formatBytes(t,e=2){if(t===0)return"0 B";const s=1024,r=Math.max(0,e),i=["B","KB","MB","GB","TB"],a=Math.floor(Math.log(t)/Math.log(s)),o=t/Math.pow(s,a);return`${parseFloat(o.toFixed(r))} ${i[a]}`}}class xn{constructor(t){this.name=t}run(t){throw new Error("run() must be implemented by subclass")}}class bn{constructor(){this.tasks=[],this.onProgress=()=>{},this.onComplete=()=>{},this.onError=()=>{}}scheduleTask(t){return new Promise((e,s)=>{const r=()=>{Promise.resolve(t()).then(e).catch(s)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(r):setTimeout(r,0)})}addTask(t){this.tasks.push(t)}setProgressCallback(t){this.onProgress=t}setCompleteCallback(t){this.onComplete=t}setErrorCallback(t){this.onError=t}async run(t){const e=this.tasks.length;let s=t;for(let r=0;r<e;r++){const i=this.tasks[r];try{s=await this.scheduleTask(async()=>{const a=await i.run(s);return this.onProgress((r+1)/e,i),a})}catch(a){this.onError(a,r,i);return}}this.onComplete(s)}}let wn=class{constructor(t,e,s){this.isLoading=!1,this.itemsLoaded=0,this.itemsTotal=0,this.urlModifier=void 0,this.handlers=[],this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=s}itemStart(t){this.itemsTotal++,this.isLoading===!1&&this.onStart!==void 0&&this.onStart(t,this.itemsLoaded,this.itemsTotal),this.isLoading=!0}itemEnd(t){this.itemsLoaded++,this.onProgress!==void 0&&this.onProgress(t,this.itemsLoaded,this.itemsTotal),this.itemsLoaded===this.itemsTotal&&(this.isLoading=!1,this.onLoad!==void 0&&this.onLoad())}itemError(t){this.onError!==void 0&&this.onError(t)}resolveURL(t){return this.urlModifier?this.urlModifier(t):t}setURLModifier(t){return this.urlModifier=t,this}addHandler(t,e){return this.handlers.push(t,e),this}removeHandler(t){const e=this.handlers.indexOf(t);return e!==-1&&this.handlers.splice(e,2),this}getHandler(t){for(let e=0,s=this.handlers.length;e<s;e+=2){const r=this.handlers[e],i=this.handlers[e+1];if(r.global&&(r.lastIndex=0),r.test(t))return i}return null}};const An=new wn;let Aa=class{constructor(t){this.manager=t!==void 0?t:An,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}loadAsync(t,e){return new Promise((s,r)=>{this.load(t,s,e,r)})}parse(t){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}};class Pn{constructor(t,e,s){this._chunkSize=-1,this._minimumChunkSize=50,this._count=t,this._numerOfChunk=e<1?1:e,this._minimumChunkSize=s,this.calculateChunkSize()}get count(){return this._count}get numerOfChunk(){return this._numerOfChunk}get minimumChunkSize(){return this._minimumChunkSize}set minimumChunkSize(t){this._minimumChunkSize=t,this.calculateChunkSize()}get chunkSize(){return this._chunkSize}calculateChunkSize(){let t=this._count/this._numerOfChunk;t<this._minimumChunkSize&&(t=Math.min(this._minimumChunkSize,this._count)),this._chunkSize=t<1?this._count:Math.floor(t)}scheduleTask(t){return new Promise((e,s)=>{const r=()=>{Promise.resolve(t()).then(e).catch(s)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(r):setTimeout(r,0)})}async processChunk(t){let e=0;const s=async()=>{const r=e,i=Math.min(e+this._chunkSize,this._count);await t(r,i),e=i,e<this._count&&await this.scheduleTask(s)};await s()}}var Y,ge,j,U,pe,lt,Z,_t,ct,Ft,ye,_e,Bt,Vt,fe,xe,be,nt,ft,R,jt,we,E,Q,Ae,J,xt,Pe,bt,dt,Ie,Gt,rt,wt,bs,ws,At,Ee,Te,Pt,Se,As,Ps,Ht,q,It,X,it,Is,Es,Ts,Ss,Ms,vs;(Y={})[Y.None=0]="None",Y[Y.Anonymous=1]="Anonymous",Y[Y.NonConstant=2]="NonConstant",Y[Y.Xref=4]="Xref",Y[Y.XrefOverlay=8]="XrefOverlay",Y[Y.ExternallyDependent=16]="ExternallyDependent",Y[Y.ResolvedOrDependent=32]="ResolvedOrDependent",Y[Y.ReferencedXref=64]="ReferencedXref",(ge={})[ge.BYBLOCK=0]="BYBLOCK",ge[ge.BYLAYER=256]="BYLAYER",(j={})[j.Rotated=0]="Rotated",j[j.Aligned=1]="Aligned",j[j.Angular=2]="Angular",j[j.Diameter=3]="Diameter",j[j.Radius=4]="Radius",j[j.Angular3Point=5]="Angular3Point",j[j.Ordinate=6]="Ordinate",j[j.ReferenceIsExclusive=32]="ReferenceIsExclusive",j[j.IsOrdinateXTypeFlag=64]="IsOrdinateXTypeFlag",j[j.IsCustomTextPositionFlag=128]="IsCustomTextPositionFlag",(U={})[U.TopLeft=1]="TopLeft",U[U.TopCenter=2]="TopCenter",U[U.TopRight=3]="TopRight",U[U.MiddleLeft=4]="MiddleLeft",U[U.MiddleCenter=5]="MiddleCenter",U[U.MiddleRight=6]="MiddleRight",U[U.BottomLeft=7]="BottomLeft",U[U.BottomCenter=8]="BottomCenter",U[U.BottomRight=9]="BottomRight",(pe={})[pe.AtLeast=1]="AtLeast",pe[pe.Exact=2]="Exact";var In=((lt={})[lt.Center=0]="Center",lt[lt.Above=1]="Above",lt[lt.Outside=2]="Outside",lt[lt.JIS=3]="JIS",lt[lt.Below=4]="Below",lt),ne=((Z={})[Z.Feet=0]="Feet",Z[Z.None=1]="None",Z[Z.Inch=2]="Inch",Z[Z.FeetAndInch=3]="FeetAndInch",Z[Z.Leading=4]="Leading",Z[Z.Trailing=8]="Trailing",Z[Z.LeadingAndTrailing=12]="LeadingAndTrailing",Z),Pa=((_t={})[_t.None=0]="None",_t[_t.Leading=1]="Leading",_t[_t.Trailing=2]="Trailing",_t[_t.LeadingAndTrailing=3]="LeadingAndTrailing",_t),Ia=((ct={})[ct.Center=0]="Center",ct[ct.Left=1]="Left",ct[ct.Right=2]="Right",ct[ct.OverFirst=3]="OverFirst",ct[ct.OverSecond=4]="OverSecond",ct),Ea=((Ft={})[Ft.Bottom=0]="Bottom",Ft[Ft.Center=1]="Center",Ft[Ft.Top=2]="Top",Ft);(ye={})[ye.PatternFill=0]="PatternFill",ye[ye.SolidFill=1]="SolidFill",(_e={})[_e.NonAssociative=0]="NonAssociative",_e[_e.Associative=1]="Associative",(Bt={})[Bt.Normal=0]="Normal",Bt[Bt.Outer=1]="Outer",Bt[Bt.Ignore=2]="Ignore",(Vt={})[Vt.UserDefined=0]="UserDefined",Vt[Vt.Predefined=1]="Predefined",Vt[Vt.Custom=2]="Custom",(fe={})[fe.NotAnnotated=0]="NotAnnotated",fe[fe.Annotated=1]="Annotated",(xe={})[xe.Solid=0]="Solid",xe[xe.Gradient=1]="Gradient",(be={})[be.TwoColor=0]="TwoColor",be[be.OneColor=1]="OneColor";var Ta=((nt={})[nt.Default=0]="Default",nt[nt.External=1]="External",nt[nt.Polyline=2]="Polyline",nt[nt.Derived=4]="Derived",nt[nt.Textbox=8]="Textbox",nt[nt.Outermost=16]="Outermost",nt),ze=((ft={})[ft.Line=1]="Line",ft[ft.Circular=2]="Circular",ft[ft.Elliptic=3]="Elliptic",ft[ft.Spline=4]="Spline",ft),Sa=((R={})[R.Off=0]="Off",R[R.Solid=1]="Solid",R[R.Dashed=2]="Dashed",R[R.Dotted=3]="Dotted",R[R.ShotDash=4]="ShotDash",R[R.MediumDash=5]="MediumDash",R[R.LongDash=6]="LongDash",R[R.DoubleShortDash=7]="DoubleShortDash",R[R.DoubleMediumDash=8]="DoubleMediumDash",R[R.DoubleLongDash=9]="DoubleLongDash",R[R.DoubleMediumLongDash=10]="DoubleMediumLongDash",R[R.SparseDot=11]="SparseDot",R);Sa.Off,(jt={})[jt.Standard=-3]="Standard",jt[jt.ByLayer=-2]="ByLayer",jt[jt.ByBlock=-1]="ByBlock",(we={})[we.English=0]="English",we[we.Metric=1]="Metric",(E={})[E.PERSPECTIVE_MODE=1]="PERSPECTIVE_MODE",E[E.FRONT_CLIPPING=2]="FRONT_CLIPPING",E[E.BACK_CLIPPING=4]="BACK_CLIPPING",E[E.UCS_FOLLOW=8]="UCS_FOLLOW",E[E.FRONT_CLIP_NOT_AT_EYE=16]="FRONT_CLIP_NOT_AT_EYE",E[E.UCS_ICON_VISIBILITY=32]="UCS_ICON_VISIBILITY",E[E.UCS_ICON_AT_ORIGIN=64]="UCS_ICON_AT_ORIGIN",E[E.FAST_ZOOM=128]="FAST_ZOOM",E[E.SNAP_MODE=256]="SNAP_MODE",E[E.GRID_MODE=512]="GRID_MODE",E[E.ISOMETRIC_SNAP_STYLE=1024]="ISOMETRIC_SNAP_STYLE",E[E.HIDE_PLOT_MODE=2048]="HIDE_PLOT_MODE",E[E.K_ISO_PAIR_TOP=4096]="K_ISO_PAIR_TOP",E[E.K_ISO_PAIR_RIGHT=8192]="K_ISO_PAIR_RIGHT",E[E.VIEWPORT_ZOOM_LOCKING=16384]="VIEWPORT_ZOOM_LOCKING",E[E.UNUSED=32768]="UNUSED",E[E.NON_RECTANGULAR_CLIPPING=65536]="NON_RECTANGULAR_CLIPPING",E[E.VIEWPORT_OFF=131072]="VIEWPORT_OFF",E[E.GRID_BEYOND_DRAWING_LIMITS=262144]="GRID_BEYOND_DRAWING_LIMITS",E[E.ADAPTIVE_GRID_DISPLAY=524288]="ADAPTIVE_GRID_DISPLAY",E[E.SUBDIVISION_BELOW_SPACING=1048576]="SUBDIVISION_BELOW_SPACING",E[E.GRID_FOLLOWS_WORKPLANE=2097152]="GRID_FOLLOWS_WORKPLANE",(Q={})[Q.OPTIMIZED_2D=0]="OPTIMIZED_2D",Q[Q.WIREFRAME=1]="WIREFRAME",Q[Q.HIDDEN_LINE=2]="HIDDEN_LINE",Q[Q.FLAT_SHADED=3]="FLAT_SHADED",Q[Q.GOURAUD_SHADED=4]="GOURAUD_SHADED",Q[Q.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",Q[Q.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME",(Ae={})[Ae.UCS_UNCHANGED=0]="UCS_UNCHANGED",Ae[Ae.HAS_OWN_UCS=1]="HAS_OWN_UCS",(J={})[J.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",J[J.TOP=1]="TOP",J[J.BOTTOM=2]="BOTTOM",J[J.FRONT=3]="FRONT",J[J.BACK=4]="BACK",J[J.LEFT=5]="LEFT",J[J.RIGHT=6]="RIGHT",(xt={})[xt.AS_DISPLAYED=0]="AS_DISPLAYED",xt[xt.WIREFRAME=1]="WIREFRAME",xt[xt.HIDDEN=2]="HIDDEN",xt[xt.RENDERED=3]="RENDERED",(Pe={})[Pe.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",Pe[Pe.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS";function k(n,t,e){return n.code===t&&(e==null||n.value===e)}function D(n){let t={};n.rewind();let e=n.next(),s=e.code;if(t.x=e.value,(e=n.next()).code!==s+10)throw Error("Expected code for point value to be 20 but got "+e.code+".");return t.y=e.value,(e=n.next()).code!==s+20?n.rewind():t.z=e.value,t}let Ls=Symbol();function v(n,t){return(e,s,r)=>{let i=n.reduce((c,l)=>{l.pushContext&&c.push({});let d=c[c.length-1];for(let u of typeof l.code=="number"?[l.code]:l.code){let m=d[u]??(d[u]=[]);l.isMultiple&&m.length&&console.warn(`Snippet ${m.at(-1).name} for code(${u}) is shadowed by ${l.name}`),m.push(l)}return c},[{}]),a=!1,o=i.length-1;for(;!k(e,0,"EOF");){let c=function(y,_,x){return y.find((f,M)=>{var T;return M>=x&&((T=f[_])==null?void 0:T.length)})}(i,e.code,o),l=c==null?void 0:c[e.code].at(-1);if(!c||!l){s.rewind();break}l.isMultiple||c[e.code].pop();let{name:d,parser:u,isMultiple:m}=l,p=u==null?void 0:u(e,s,r);if(p===Ls){s.rewind();break}if(d){let[y,_]=function(x,f){let M=f.split("."),T=x;for(let S=0;S<M.length-1;++S){let P=M[S];Object.hasOwn(T,P)||(T[P]={}),T=T[P]}return[T,M.at(-1)]}(r,d);m?(Object.hasOwn(y,_)||(y[_]=[]),y[_].push(p)):y[_]=p}l.pushContext&&(o-=1),a=!0,e=s.next()}return t&&Object.setPrototypeOf(r,t),a}}function h({value:n}){return n}function A(n,t){return D(t)}function F({value:n}){return!!n}var En=[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];function Tn(n,t){var r;if(!k(n,1001))throw Error("XData must starts with code 1001");let e={appName:n.value,value:[]};n=t.next();let s=[e.value];for(;!k(n,0,"EOF")&&n.code>=1e3;){let i=s.at(-1);switch(n.code){case 1002:n.value==="{"?s.push([]):(s.pop(),(r=s.at(-1))==null||r.push(i));break;case 1e3:case 1004:case 1040:case 1070:case 1071:i.push({type:Et(n.code),value:n.value});break;case 1003:i.push({name:"layer",type:Et(n.code),value:n.value});break;case 1005:i.push({name:"handle",type:Et(n.code),value:n.value});break;case 1010:i.push({type:Et(n.code),value:D(t)});break;case 1011:i.push({name:"worldSpacePosition",type:Et(n.code),value:D(t)});break;case 1012:i.push({name:"worldSpaceDisplacement",type:Et(n.code),value:D(t)});break;case 1013:i.push({name:"worldSpaceDirection",type:Et(n.code),value:D(t)});break;case 1041:i.push({name:"distance",type:Et(n.code),value:n.value});break;case 1042:i.push({name:"scale",type:Et(n.code),value:n.value})}n=t.next()}return t.rewind(),e}function Et(n){switch(n){case 1e3:case 1003:case 1005:return"string";case 1004:return"hex";case 1040:case 1041:case 1042:return"real";case 1070:return"integer";case 1071:return"long";case 1010:case 1011:case 1012:case 1013:return"point";default:return""}}function ks(n,t,e){if(k(t,102))return Fe(t,e),!0;switch(t.code){case 0:n.type=t.value;break;case 5:n.handle=t.value;break;case 330:n.ownerDictionarySoftId?n.ownerBlockRecordSoftId=t.value:n.ownerDictionarySoftId=t.value;break;case 360:n.ownerdictionaryHardId=t.value;break;case 67:n.isInPaperSpace=!!t.value;break;case 8:n.layer=t.value;break;case 6:n.lineType=t.value;break;case 347:n.materialObjectHardId=t.value;break;case 62:n.colorIndex=t.value,n.color=En[Math.abs(t.value)];break;case 370:n.lineweight=t.value;break;case 48:n.lineTypeScale=t.value;break;case 60:n.isVisible=!!t.value;break;case 92:n.proxyByte=t.value;break;case 310:n.proxyEntity=t.value;break;case 100:break;case 420:n.color=t.value;break;case 430:n.transparency=t.value;break;case 390:n.plotStyleHardId=t.value;break;case 284:n.shadowMode=t.value;break;case 1001:n.xdata=Tn(t,e);break;default:return!1}return!0}let Ma=0;function Sn(n){if(!n)throw TypeError("entity cannot be undefined or null");n.handle||(n.handle=Ma++)}(bt={})[bt.CAST_AND_RECEIVE=0]="CAST_AND_RECEIVE",bt[bt.CAST=1]="CAST",bt[bt.RECEIVE=2]="RECEIVE",bt[bt.IGNORE=3]="IGNORE";let G=[{code:1001,name:"xdata",parser:Tn},{code:284,name:"shadowMode",parser:h},{code:390,name:"plotStyleHardId",parser:h},{code:440,name:"transparency",parser:h},{code:430,name:"colorName",parser:h},{code:420,name:"color",parser:h},{code:310,name:"proxyEntity",isMultiple:!0,parser:h},{code:92,name:"proxyByte",parser:h},{code:60,name:"isVisible",parser:F},{code:48,name:"lineTypeScale",parser:h},{code:370,name:"lineweight",parser:h},{code:62,name:"colorIndex",parser(n,t,e){let s=n.value;return e.color=En[Math.abs(s)],s}},{code:347,name:"materialObjectHardId",parser:h},{code:6,name:"lineType",parser:h},{code:8,name:"layer",parser:h},{code:410,name:"layoutTabName",parser:h},{code:67,name:"isInPaperSpace",parser:F},{code:100},{code:160},{code:330,name:"ownerBlockRecordSoftId",parser:h},{code:102,parser:Fe},{code:102,parser:Fe},{code:102,parser:Fe},{code:5,name:"handle",parser:h}];function Fe(n,t){for(n=t.next();!k(n,102)&&!k(n,0,"EOF");)n=t.next()}function Mn(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let va={extrusionDirection:{x:0,y:0,z:1}},La=[{code:210,name:"extrusionDirection",parser:A},{code:51,name:"endAngle",parser:h},{code:50,name:"startAngle",parser:h},{code:100,name:"subclassMarker",parser:h},{code:40,name:"radius",parser:h},{code:10,name:"center",parser:A},{code:39,name:"thickness",parser:h},{code:100},...G];class vn{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Mn(this,"parser",v(La,va))}}Mn(vn,"ForEntityName","ARC"),(dt={})[dt.NONE=0]="NONE",dt[dt.INVISIBLE=1]="INVISIBLE",dt[dt.CONSTANT=2]="CONSTANT",dt[dt.VERIFICATION_REQUIRED=4]="VERIFICATION_REQUIRED",dt[dt.PRESET=8]="PRESET",(Ie={})[Ie.MULTILINE=2]="MULTILINE",Ie[Ie.CONSTANT_MULTILINE=4]="CONSTANT_MULTILINE",(Gt={})[Gt.NONE=0]="NONE",Gt[Gt.MIRRORED_X=2]="MIRRORED_X",Gt[Gt.MIRRORED_Y=4]="MIRRORED_Y";var ka=((rt={})[rt.LEFT=0]="LEFT",rt[rt.CENTER=1]="CENTER",rt[rt.RIGHT=2]="RIGHT",rt[rt.ALIGNED=3]="ALIGNED",rt[rt.MIDDLE=4]="MIDDLE",rt[rt.FIT=5]="FIT",rt),Ca=((wt={})[wt.BASELINE=0]="BASELINE",wt[wt.BOTTOM=1]="BOTTOM",wt[wt.MIDDLE=2]="MIDDLE",wt[wt.TOP=3]="TOP",wt);function Ln(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let kn={thickness:0,rotation:0,xScale:1,obliqueAngle:0,styleName:"STANDARD",generationFlag:0,halign:ka.LEFT,valign:Ca.BASELINE,extrusionDirection:{x:0,y:0,z:1}},Cn=[{code:73,name:"valign",parser:h},{code:100},{code:210,name:"extrusionDirection",parser:A},{code:11,name:"endPoint",parser:A},{code:72,name:"valign",parser:h},{code:72,name:"halign",parser:h},{code:71,name:"generationFlag",parser:h},{code:7,name:"styleName",parser:h},{code:51,name:"obliqueAngle",parser:h},{code:41,name:"xScale",parser:h},{code:50,name:"rotation",parser:h},{code:1,name:"text",parser:h},{code:40,name:"textHeight",parser:h},{code:10,name:"startPoint",parser:A},{code:39,name:"thickness",parser:h},{code:100,name:"subclassMarker",parser:h},...G];class On{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Ln(this,"parser",v(Cn,kn))}}function Nn(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Ln(On,"ForEntityName","TEXT");let Oa={...kn},Na=[{code:2},{code:40,name:"annotationScale",parser:h},{code:10,name:"alignmentPoint",parser:A},{code:340,name:"secondaryAttributesHardIds",isMultiple:!0,parser:h},{code:70,name:"numberOfSecondaryAttributes",parser:h},{code:70,name:"isReallyLocked",parser:F},{code:70,name:"mtextFlag",parser:h},{code:280,name:"isDuplicatedRecord",parser:F},{code:100},{code:280,name:"isLocked",parser:F},{code:74,name:"valign",parser:h},{code:73},{code:70,name:"attributeFlag",parser:h},{code:2,name:"tag",parser:h},{code:3,name:"prompt",parser:h},{code:280},{code:100,name:"subclassMarker",parser:h},...Cn.slice(2)];class Dn{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Nn(this,"parser",v(Na,Oa))}}function Rn(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Nn(Dn,"ForEntityName","ATTDEF");let Da={thickness:0,extrusionDirection:{x:0,y:0,z:1}},Ra=[{code:210,name:"extrusionDirection",parser:A},{code:40,name:"radius",parser:h},{code:10,name:"center",parser:A},{code:39,name:"thickness",parser:h},{code:100,name:"subclassMarker",parser:h},...G];class zn{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Rn(this,"parser",v(Ra,Da))}}Rn(zn,"ForEntityName","CIRCLE");let Be=class{parseEntity(t,e){let s={};for(;!k(e,0,"EOF");){if(e.code===0){t.rewind();break}(function(r,i,a){switch(i.code){case 100:r.subclassMarker=i.value;break;case 280:r.version=i.value;break;case 2:r.name=i.value;break;case 10:r.definitionPoint=D(a);break;case 11:r.textPoint=D(a);break;case 12:r.insertionPoint=D(a);break;case 13:r.subDefinitionPoint1=D(a);break;case 14:r.subDefinitionPoint2=D(a);break;case 15:r.centerPoint=D(a);break;case 16:r.arcPoint=D(a);break;case 70:r.dimensionType=i.value;break;case 71:r.attachmentPoint=i.value;break;case 72:r.textLineSpacingStyle=i.value;break;case 40:r.leaderLength=i.value;break;case 41:r.textLineSpacingFactor=i.value;break;case 42:r.measurement=i.value;break;case 1:r.text=i.value;break;case 50:r.rotationAngle=i.value;break;case 52:r.obliqueAngle=i.value;break;case 53:r.textRotation=i.value;break;case 51:r.ocsRotation=i.value;break;case 210:r.extrusionDirection=D(a);break;case 3:r.styleName=i.value;break;default:ks(r,i,a)}})(s,e,t),e=t.next()}return s}};function Fn(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}ws="DIMENSION",(bs="ForEntityName")in Be?Object.defineProperty(Be,bs,{value:ws,enumerable:!0,configurable:!0,writable:!0}):Be[bs]=ws;let za={extrusionDirection:{x:0,y:0,z:1}},Fa=[{code:42,name:"endAngle",parser:h},{code:41,name:"startAngle",parser:h},{code:40,name:"axisRatio",parser:h},{code:210,name:"extrusionDirection",parser:A},{code:11,name:"majorAxisEndPoint",parser:A},{code:10,name:"center",parser:A},{code:100,name:"subclassMarker",parser:h},...G];class Bn{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Fn(this,"parser",v(Fa,za))}}Fn(Bn,"ForEntityName","ELLIPSE");let Vn=[{code:330,name:"sourceBoundaryObjects",parser:h,isMultiple:!0},{code:97,name:"numberOfSourceBoundaryObjects",parser:h}],Ba=[{code:11,name:"end",parser:A},{code:10,name:"start",parser:A}],Va=[{code:73,name:"isCCW",parser:F},{code:51,name:"endAngle",parser:h},{code:50,name:"startAngle",parser:h},{code:40,name:"radius",parser:h},{code:10,name:"center",parser:A}],ja=[{code:73,name:"isCCW",parser:F},{code:51,name:"endAngle",parser:h},{code:50,name:"startAngle",parser:h},{code:40,name:"lengthOfMinorAxis",parser:h},{code:11,name:"end",parser:A},{code:10,name:"center",parser:A}],Ga=[{code:13,name:"endTangent",parser:A},{code:12,name:"startTangent",parser:A},{code:11,name:"fitDatum",isMultiple:!0,parser:A},{code:97,name:"numberOfFitData",parser:h},{code:10,name:"controlPoints",isMultiple:!0,parser(n,t){let e={...D(t),weight:1};return(n=t.next()).code===42?e.weight=n.value:t.rewind(),e}},{code:40,name:"knots",isMultiple:!0,parser:h},{code:96,name:"numberOfControlPoints",parser:h},{code:95,name:"numberOfKnots",parser:h},{code:74,name:"isPeriodic",parser:F},{code:73,name:"splineFlag",parser:h},{code:94,name:"degree",parser:h}],Ha={[ze.Line]:Ba,[ze.Circular]:Va,[ze.Elliptic]:ja,[ze.Spline]:Ga},Ua=[...Vn,{code:72,name:"edges",parser(n,t){let e={type:n.value},s=v(Ha[e.type]);if(!s)throw Error(`Invalid edge type ${e.type}`);return s(n=t.next(),t,e),e},isMultiple:!0},{code:93,name:"numberOfEdges",parser:h}],Wa=[...Vn,{code:10,name:"vertices",parser(n,t){let e={...D(t),bulge:0};return(n=t.next()).code===42?e.bulge=n.value:t.rewind(),e},isMultiple:!0},{code:93,name:"numberOfVertices",parser:h},{code:73,name:"isClosed",parser:F},{code:72,name:"hasBulge",parser:F}],Ya=[{code:49,name:"dashLengths",parser:h,isMultiple:!0},{code:79,name:"numberOfDashLengths",parser:h},{code:45,name:"offset",parser:jn},{code:43,name:"base",parser:jn},{code:53,name:"angle",parser:h}];function jn(n,t){let e=n.code+1,s={x:n.value,y:1};return(n=t.next()).code===e?s.y=n.value:t.rewind(),s}function Gn(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let qa={extrusionDirection:{x:0,y:0,z:1},gradientRotation:0,colorTint:0},Xa=[{code:470},{code:463},{code:462,name:"colorTint",parser:h},{code:461,name:"gradientDefinition",parser:h},{code:460,name:"gradientRotation",parser:h},{code:453,name:"numberOfColors",parser:h},{code:452,name:"gradientColorFlag",parser:h},{code:451},{code:450,name:"gradientFlag",parser:h},{code:10,name:"seedPoints",parser:A,isMultiple:!0},{code:99},{code:11,name:"offsetVector",parser:A},{code:98,name:"numberOfSeedPoints",parser:h},{code:47,name:"pixelSize",parser:h},{code:53,name:"definitionLines",parser:function(n,t){let e={};return v(Ya)(n,t,e),e},isMultiple:!0},{code:78,name:"numberOfDefinitionLines",parser:h},{code:77,name:"isDouble",parser:F},{code:73,name:"isAnnotated",parser:F},{code:41,name:"patternScale",parser:h},{code:52,name:"patternAngle",parser:h},{code:76,name:"patternType",parser:h},{code:75,name:"hatchStyle",parser:h},{code:92,name:"boundaryPaths",parser:function(n,t){let e={boundaryPathTypeFlag:n.value},s=e.boundaryPathTypeFlag&Ta.Polyline;return n=t.next(),s?v(Wa)(n,t,e):v(Ua)(n,t,e),e},isMultiple:!0},{code:91,name:"numberOfBoundaryPaths",parser:h},{code:71,name:"associativity",parser:h},{code:63,name:"patternFillColor",parser:h},{code:70,name:"solidFill",parser:h},{code:2,name:"patternName",parser:h},{code:210,name:"extrusionDirection",parser:A},{code:10,name:"elevationPoint",parser:A},{code:100,name:"subclassMarker",parser:h,pushContext:!0},...G];class Hn{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Gn(this,"parser",v(Xa,qa))}}Gn(Hn,"ForEntityName","HATCH"),(At={})[At.ShowImage=1]="ShowImage",At[At.ShowImageWhenNotAlignedWithScreen=2]="ShowImageWhenNotAlignedWithScreen",At[At.UseClippingBoundary=4]="UseClippingBoundary",At[At.TransparencyIsOn=8]="TransparencyIsOn",(Ee={})[Ee.Rectangular=1]="Rectangular",Ee[Ee.Polygonal=2]="Polygonal",(Te={})[Te.Outside=0]="Outside",Te[Te.Inside=1]="Inside";function Un(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let $a={clippingBoundaryPath:[]},Ka=[{code:90,name:"version",parser:h},{code:10,name:"position",parser:A},{code:11,name:"uPixel",parser:A},{code:12,name:"vPixel",parser:A},{code:13,name:"imageSize",parser:A},{code:340,name:"imageDefHandle",parser:h},{code:70,name:"flags",parser:h},{code:280,name:"clipping",parser:h},{code:281,name:"brightness",parser:h},{code:282,name:"contrast",parser:h},{code:283,name:"fade",parser:h},{code:360,name:"imageDefReactorHandle",parser:h},{code:71,name:"clippingBoundaryType",parser:h},{code:91,name:"countBoundaryPoints",parser:h},{code:14,name:"clippingBoundaryPath",isMultiple:!0,parser:A},{code:290,name:"clipMode",parser:h},{code:100,name:"subclassMarker",parser:h},...G];class Cs{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Un(this,"parser",v(Ka,$a))}}function Wn(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Un(Cs,"ForEntityName","IMAGE");let Za={xScale:1,yScale:1,zScale:1,rotation:0,columnCount:0,rowCount:0,columnSpacing:0,rowSpacing:0,extrusionDirection:{x:0,y:0,z:1}},Qa=[{code:210,name:"extrusionDirection",parser:A},{code:45,name:"rowSpacing",parser:h},{code:44,name:"columnSpacing",parser:h},{code:71,name:"rowCount",parser:h},{code:70,name:"columnCount",parser:h},{code:50,name:"rotation",parser:h},{code:43,name:"zScale",parser:h},{code:42,name:"yScale",parser:h},{code:41,name:"xScale",parser:h},{code:10,name:"insertionPoint",parser:A},{code:2,name:"name",parser:h},{code:66,name:"isVariableAttributes",parser:F},{code:100,name:"subclassMarker",parser:h},...G];class Yn{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Wn(this,"parser",v(Qa,Za))}}function qn(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Wn(Yn,"ForEntityName","INSERT");let Ja={isArrowheadEnabled:!0},to=[{code:213,name:"offsetFromAnnotation",parser:A},{code:212,name:"offsetFromBlock",parser:A},{code:211,name:"horizontalDirection",parser:A},{code:210,name:"normal",parser:A},{code:340,name:"associatedAnnotation",parser:h},{code:77,name:"byBlockColor",parser:h},{code:10,name:"vertices",parser:A,isMultiple:!0},{code:76,name:"numberOfVertices",parser:h},{code:41,name:"textWidth",parser:h},{code:40,name:"textHeight",parser:h},{code:75,name:"isHooklineExists",parser:F},{code:74,name:"isHooklineSameDirection",parser:F},{code:73,name:"leaderCreationFlag",parser:h},{code:72,name:"isSpline",parser:F},{code:71,name:"isArrowheadEnabled",parser:F},{code:3,name:"styleName",parser:h},{code:100,name:"subclassMarker",parser:h},...G];class Xn{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){qn(this,"parser",v(to,Ja))}}qn(Xn,"ForEntityName","LEADER"),(Pt={})[Pt.TextAnnotation=0]="TextAnnotation",Pt[Pt.ToleranceAnnotation=1]="ToleranceAnnotation",Pt[Pt.BlockReferenceAnnotation=2]="BlockReferenceAnnotation",Pt[Pt.NoAnnotation=3]="NoAnnotation";function $n(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let eo={thickness:0,extrusionDirection:{x:0,y:0,z:1}},so=[{code:210,name:"extrusionDirection",parser:A},{code:11,name:"endPoint",parser:A},{code:10,name:"startPoint",parser:A},{code:39,name:"thickness",parser:h},{code:100,name:"subclassMarker",parser:h},...G];class Kn{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){$n(this,"parser",v(so,eo))}}$n(Kn,"ForEntityName","LINE"),(Se={})[Se.IS_CLOSED=1]="IS_CLOSED",Se[Se.PLINE_GEN=128]="PLINE_GEN";let no={flag:0,elevation:0,thickness:0,extrusionDirection:{x:0,y:0,z:1},vertices:[]},ro={bulge:0},io=[{code:42,name:"bulge",parser:h},{code:41,name:"endWidth",parser:h},{code:40,name:"startWidth",parser:h},{code:91,name:"id",parser:h},{code:20,name:"y",parser:h},{code:10,name:"x",parser:h}],ao=[{code:210,name:"extrusionDirection",parser:A},{code:10,name:"vertices",isMultiple:!0,parser(n,t){let e={};return v(io,ro)(n,t,e),e}},{code:39,name:"thickness",parser:h},{code:38,name:"elevation",parser:h},{code:43,name:"constantWidth",parser:h},{code:70,name:"flag",parser:h},{code:90,name:"numberOfVertices",parser:h},{code:100,name:"subclassMarker",parser:h},...G];class Ve{parseEntity(t,e){let s={};return v(ao,no)(e,t,s),s}}Ps="LWPOLYLINE",(As="ForEntityName")in Ve?Object.defineProperty(Ve,As,{value:Ps,enumerable:!0,configurable:!0,writable:!0}):Ve[As]=Ps,(Ht={})[Ht.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",Ht[Ht.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",Ht[Ht.BY_STYLE=5]="BY_STYLE";function oo(n,t){let e={};for(let s of n){let r=t(s);r!=null&&(e[r]??(e[r]=[]),e[r].push(s))}return e}function*je(n,t=1/0,e=1){for(let s=n;s!==t;s+=e)yield s}function Lt(n){return{x:n.x??0,y:n.y??0,z:n.z??0}}function Zn(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let ho={textStyle:"STANDARD",extrusionDirection:{x:0,y:0,z:1},rotation:0},Ge=[{code:46,name:"annotationHeight",parser:h},{code:101,parser(n,t){(function(e){e.rewind();let s=e.next();if(s.code!==101)throw Error("Bad call for skipEmbeddedObject()");do s=e.next();while(s.code!==0);e.rewind()})(t)}},{code:50,name:"columnHeight",parser:h},{code:49,name:"columnGutter",parser:h},{code:48,name:"columnWidth",parser:h},{code:79,name:"columnAutoHeight",parser:h},{code:78,name:"columnFlowReversed",parser:h},{code:76,name:"columnCount",parser:h},{code:75,name:"columnType",parser:h},{code:441,name:"backgroundFillTransparency",parser:h},{code:63,name:"backgroundFillColor",parser:h},{code:45,name:"fillBoxScale",parser:h},{code:[...je(430,440)],name:"backgroundColor",parser:h},{code:[...je(420,430)],name:"backgroundColor",parser:h},{code:90,name:"backgroundFill",parser:h},{code:44,name:"lineSpacing",parser:h},{code:73,name:"lineSpacingStyle",parser:h},{code:50,name:"rotation",parser:h},{code:43},{code:42},{code:11,name:"direction",parser:A},{code:210,name:"extrusionDirection",parser:A},{code:7,name:"styleName",parser:h},{code:3,name:"text",isMultiple:!0,parser:h},{code:1,name:"text",isMultiple:!0,parser:h},{code:72,name:"drawingDirection",parser:h},{code:71,name:"attachmentPoint",parser:h},{code:41,name:"width",parser:h},{code:40,name:"height",parser:h},{code:10,name:"insertionPoint",parser:A},{code:100,name:"subclassMarker",parser:h},...G];class Qn{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Zn(this,"parser",v(Ge,ho))}}function Jn(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Zn(Qn,"ForEntityName","MTEXT");let lo={thickness:0,extrusionDirection:{x:0,y:0,z:1},angle:0},co=[{code:50,name:"angle",parser:h},{code:210,name:"extrusionDirection",parser:A},{code:39,name:"thickness",parser:h},{code:10,name:"position",parser:A},{code:100,name:"subclassMarker",parser:h},...G];class tr{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Jn(this,"parser",v(co,lo))}}Jn(tr,"ForEntityName","POINT"),(q={})[q.CLOSED_POLYLINE=1]="CLOSED_POLYLINE",q[q.CURVE_FIT=2]="CURVE_FIT",q[q.SPLINE_FIT=4]="SPLINE_FIT",q[q.POLYLINE_3D=8]="POLYLINE_3D",q[q.POLYGON_3D=16]="POLYGON_3D",q[q.CLOSED_POLYGON=32]="CLOSED_POLYGON",q[q.POLYFACE=64]="POLYFACE",q[q.CONTINUOUS=128]="CONTINUOUS",(It={})[It.NONE=0]="NONE",It[It.QUADRATIC=5]="QUADRATIC",It[It.CUBIC=6]="CUBIC",It[It.BEZIER=8]="BEZIER",(X={})[X.CREATED_BY_CURVE_FIT=1]="CREATED_BY_CURVE_FIT",X[X.TANGENT_DEFINED=2]="TANGENT_DEFINED",X[X.NOT_USED=4]="NOT_USED",X[X.CREATED_BY_SPLINE_FIT=8]="CREATED_BY_SPLINE_FIT",X[X.SPLINE_CONTROL_POINT=16]="SPLINE_CONTROL_POINT",X[X.FOR_POLYLINE=32]="FOR_POLYLINE",X[X.FOR_POLYGON=64]="FOR_POLYGON",X[X.POLYFACE=128]="POLYFACE";function er(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let uo={startWidth:0,endWidth:0,bulge:0},mo=[{code:91,name:"id",parser:h},{code:[...je(71,75)],name:"faces",isMultiple:!0,parser:h},{code:50,name:"tangentDirection",parser:h},{code:70,name:"flag",parser:h},{code:42,name:"bulge",parser:h},{code:41,name:"endWidth",parser:h},{code:40,name:"startWidth",parser:h},{code:30,name:"z",parser:h},{code:20,name:"y",parser:h},{code:10,name:"x",parser:h},{code:100,name:"subclassMarker",parser:h},{code:100},...G],sr=class{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){er(this,"parser",v(mo,uo))}};function nr(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}er(sr,"ForEntityName","VERTEX");let go={thickness:0,flag:0,startWidth:0,endWidth:0,meshMVertexCount:0,meshNVertexCount:0,surfaceMDensity:0,surfaceNDensity:0,smoothType:0,extrusionDirection:{x:0,y:0,z:1},vertices:[]},po=[{code:0,name:"vertices",isMultiple:!0,parser:(n,t)=>k(n,0,"VERTEX")?(n=t.next(),new sr().parseEntity(t,n)):Ls},{code:210,name:"extrusionDirection",parser:A},{code:75,name:"smoothType",parser:h},{code:74,name:"surfaceNDensity",parser:h},{code:73,name:"surfaceMDensity",parser:h},{code:72,name:"meshNVertexCount",parser:h},{code:71,name:"meshMVertexCount",parser:h},{code:41,name:"endWidth",parser:h},{code:40,name:"startWidth",parser:h},{code:70,name:"flag",parser:h},{code:39,name:"thickness",parser:h},{code:30,name:"elevation",parser:h},{code:20},{code:10},{code:66},{code:100,name:"subclassMarker",parser:h},...G];class rr{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){nr(this,"parser",v(po,go))}}function ir(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}nr(rr,"ForEntityName","POLYLINE");let yo={firstPoint:{x:0,y:0,z:1},extrusionDirection:{x:0,y:0,z:1}},_o=[{code:10,name:"firstPoint",parser:A},{code:11,name:"unitDirection",parser:A},{code:100,name:"subclassMarker",parser:h},...G];class ar{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){ir(this,"parser",v(_o,yo))}}function or(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}ir(ar,"ForEntityName","RAY");let fo={vertices:[],backLineVertices:[]},xo=[{code:360,name:"geometrySettingHardId",parser:h},{code:12,name:"backLineVertices",isMultiple:!0,parser:A},{code:93,name:"numberOfBackLineVertices",parser:h},{code:11,name:"vertices",isMultiple:!0,parser:A},{code:92,name:"verticesCount",parser:h},{code:[63,411],name:"indicatorColor",parser:h},{code:70,name:"indicatorTransparency",parser:h},{code:41,name:"bottomHeight",parser:h},{code:40,name:"topHeight",parser:h},{code:10,name:"verticalDirection",parser:A},{code:1,name:"name",parser:h},{code:91,name:"flag",parser:h},{code:90,name:"state",parser:h},{code:100,name:"subclassMarker",parser:h},...G];class hr{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){or(this,"parser",v(xo,fo))}}function lr(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}or(hr,"ForEntityName","SECTION");let bo={points:[],thickness:0,extrusionDirection:{x:0,y:0,z:1}},wo=[{code:210,name:"extrusionDirection",parser:A},{code:39,name:"thickness",parser:h},{code:[...je(10,14)],name:"points",isMultiple:!0,parser:A},{code:100,name:"subclassMarker",parser:h},...G];class cr{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){lr(this,"parser",v(wo,bo))}}lr(cr,"ForEntityName","SOLID"),(it={})[it.NONE=0]="NONE",it[it.CLOSED=1]="CLOSED",it[it.PERIODIC=2]="PERIODIC",it[it.RATIONAL=4]="RATIONAL",it[it.PLANAR=8]="PLANAR",it[it.LINEAR=16]="LINEAR";function dr(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let Ao={knotTolerance:1e-6,controlTolerance:1e-6,fitTolerance:1e-9,knotValues:[],controlPoints:[],fitPoints:[]},Po=[{code:11,name:"fitPoints",isMultiple:!0,parser:A},{code:10,name:"controlPoints",isMultiple:!0,parser:A},{code:41,name:"weights",isMultiple:!0,parser:h},{code:40,name:"knots",isMultiple:!0,parser:h},{code:13,name:"endTangent",parser:A},{code:12,name:"startTangent",parser:A},{code:44,name:"fitTolerance",parser:h},{code:43,name:"controlTolerance",parser:h},{code:42,name:"knotTolerance",parser:h},{code:74,name:"numberOfFitPoints",parser:h},{code:73,name:"numberOfControlPoints",parser:h},{code:72,name:"numberOfKnots",parser:h},{code:71,name:"degree",parser:h},{code:70,name:"flag",parser:h},{code:210,name:"normal",parser:A},{code:100,name:"subclassMarker",parser:h},...G];class ur{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){dr(this,"parser",v(Po,Ao))}}dr(ur,"ForEntityName","SPLINE");class He{parseEntity(t,e){let s={};for(;!t.isEOF();){if(e.code===0){t.rewind();break}switch(e.code){case 100:s.subclassMarker=e.value,e=t.next();break;case 2:s.name=e.value,e=t.next();break;case 5:s.handle=e.value,e=t.next();break;case 10:s.startPoint=Lt(D(t)),e=t.lastReadGroup;break;case 11:s.directionVector=Lt(D(t)),e=t.lastReadGroup;break;case 90:s.tableValue=e.value,e=t.next();break;case 91:s.rowCount=e.value,e=t.next();break;case 92:s.columnCount=e.value,e=t.next();break;case 93:s.overrideFlag=e.value,e=t.next();break;case 94:s.borderColorOverrideFlag=e.value,e=t.next();break;case 95:s.borderLineWeightOverrideFlag=e.value,e=t.next();break;case 96:s.borderVisibilityOverrideFlag=e.value,e=t.next();break;case 141:s.rowHeightArr??(s.rowHeightArr=[]),s.rowHeightArr.push(e.value),e=t.next();break;case 142:s.columnWidthArr??(s.columnWidthArr=[]),s.columnWidthArr.push(e.value),e=t.next();break;case 280:s.version=e.value,e=t.next();break;case 310:s.bmpPreview??(s.bmpPreview=""),s.bmpPreview+=e.value,e=t.next();break;case 330:s.ownerDictionaryId=e.value,e=t.next();break;case 342:s.tableStyleId=e.value,e=t.next();break;case 343:s.blockRecordHandle=e.value,e=t.next();break;case 170:s.attachmentPoint=e.value,e=t.next();break;case 171:s.cells??(s.cells=[]),s.cells.push(function(r,i){let a=!1,o=!1,c={};for(;!r.isEOF()&&i.code!==0&&!o;)switch(i.code){case 171:if(a){o=!0;continue}c.cellType=i.value,a=!0,i=r.next();break;case 172:c.flagValue=i.value,i=r.next();break;case 173:c.mergedValue=i.value,i=r.next();break;case 174:c.autoFit=i.value,i=r.next();break;case 175:c.borderWidth=i.value,i=r.next();break;case 176:c.borderHeight=i.value,i=r.next();break;case 91:c.overrideFlag=i.value,i=r.next();break;case 178:c.virtualEdgeFlag=i.value,i=r.next();break;case 145:c.rotation=i.value,i=r.next();break;case 345:c.fieldObjetId=i.value,i=r.next();break;case 340:c.blockTableRecordId=i.value,i=r.next();break;case 146:c.blockScale=i.value,i=r.next();break;case 177:c.blockAttrNum=i.value,i=r.next();break;case 7:c.textStyle=i.value,i=r.next();break;case 140:c.textHeight=i.value,i=r.next();break;case 170:c.attachmentPoint=i.value,i=r.next();break;case 92:c.extendedCellFlags=i.value,i=r.next();break;case 285:c.rightBorderVisibility=!!(i.value??!0),i=r.next();break;case 286:c.bottomBorderVisibility=!!(i.value??!0),i=r.next();break;case 288:c.leftBorderVisibility=!!(i.value??!0),i=r.next();break;case 289:c.topBorderVisibility=!!(i.value??!0),i=r.next();break;case 301:(function(l,d,u){for(;u.code!==304;)switch(u.code){case 301:case 93:case 90:case 94:u=d.next();break;case 1:l.text=u.value,u=d.next();break;case 300:l.attrText=u.value,u=d.next();break;case 302:l.text=u.value?u.value:l.text,u=d.next();break;default:console.log(`Ignore code: ${u.code}, value: ${u.value}`),u=d.next()}})(c,r,i),i=r.next();break;default:return c}return a=!1,o=!1,c}(t,e)),e=t.lastReadGroup;break;default:ks(s,e,t),e=t.next()}}return s}}Es="ACAD_TABLE",(Is="ForEntityName")in He?Object.defineProperty(He,Is,{value:Es,enumerable:!0,configurable:!0,writable:!0}):He[Is]=Es;class Ue{parseEntity(t,e){let s={};for(;e!=="EOF";){if(e.code===0){t.rewind();break}!function(r,i,a){if(a==="EOF")return!1;switch(a.code){case 0:default:return!1;case 100:r.subclassMarker=a.value;break;case 10:r.viewportCenter=Lt(D(i));break;case 40:r.width=a.value;break;case 41:r.height=a.value;break;case 68:r.status=a.value;break;case 69:r.viewportId=a.value;break;case 12:r.displayCenter=D(i);break;case 13:r.snapBase=D(i);break;case 14:r.snapSpacing=D(i);break;case 15:r.gridSpacing=D(i);break;case 16:r.viewDirection=Lt(D(i));break;case 17:r.targetPoint=Lt(D(i));break;case 42:r.perspectiveLensLength=a.value;break;case 43:r.frontClipZ=a.value;break;case 44:r.backClipZ=a.value;break;case 45:r.viewHeight=a.value;break;case 50:r.snapAngle=a.value;break;case 51:r.viewTwistAngle=a.value;break;case 72:r.circleZoomPercent=a.value;break;case 331:r.frozenLayerIds??(r.frozenLayerIds=[]),r.frozenLayerIds.push(a.value);break;case 90:r.statusBitFlags=a.value;break;case 330:r.ownerBlockRecordSoftId=a.value;break;case 340:r.clippingBoundaryId=a.value;break;case 1:r.sheetName=a.value;break;case 281:r.renderMode=a.value;break;case 71:r.ucsPerViewport=a.value;break;case 110:r.ucsOrigin=Lt(D(i));break;case 111:r.ucsXAxis=Lt(D(i));break;case 112:r.ucsYAxis=Lt(D(i));break;case 345:r.ucsId=a.value;break;case 346:r.ucsBaseId=a.value;break;case 79:r.orthographicType=a.value;break;case 146:r.elevation=a.value;break;case 170:r.shadePlotMode=a.value;break;case 61:r.majorGridFrequency=a.value;break;case 332:r.backgroundId=a.value;break;case 333:r.shadePlotId=a.value;break;case 348:r.visualStyleId=a.value;break;case 292:r.isDefaultLighting=!!a.value;break;case 282:r.defaultLightingType=a.value;break;case 141:r.brightness=a.value;break;case 142:r.contrast=a.value;break;case 63:case 421:case 431:r.ambientLightColor=a.value;break;case 361:r.sunId=a.value;break;case 335:case 343:case 344:case 91:r.softPointer=a.value}return!0}(s,t,e)&&ks(s,e,t),e=t.next()}return s}}Ss="VIEWPORT",(Ts="ForEntityName")in Ue?Object.defineProperty(Ue,Ts,{value:Ss,enumerable:!0,configurable:!0,writable:!0}):Ue[Ts]=Ss;class We extends Cs{parseEntity(t,e){return super.parseEntity(t,e)}}function mr(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}vs="WIPEOUT",(Ms="ForEntityName")in We?Object.defineProperty(We,Ms,{value:vs,enumerable:!0,configurable:!0,writable:!0}):We[Ms]=vs;let Io={firstPoint:{x:0,y:0,z:1},extrusionDirection:{x:0,y:0,z:1}},Eo=[{code:10,name:"firstPoint",parser:A},{code:11,name:"unitDirection",parser:A},{code:100,name:"subclassMarker",parser:h},...G];class gr{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){mr(this,"parser",v(Eo,Io))}}function pr(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}mr(gr,"ForEntityName","XLINE");let To={thickness:0,rotation:0,scale:1,obliqueAngle:0,textStyle:"STANDARD",textGenerationFlag:0,horizontalJustification:0,verticalJustification:0,extrusionDirection:{x:0,y:0,z:1}},So=[...Ge.slice(Ge.findIndex(({name:n})=>n==="columnType"),Ge.findIndex(({name:n})=>n==="subclassMarker")+1),{code:100},{code:0,parser(n){if(!k(n,0,"MTEXT"))return Ls}},{code:2,name:"definitionTag",parser:h},{code:40,name:"annotationScale",parser:h},{code:10,name:"alignmentPoint",parser:A},{code:340,name:"secondaryAttributesHardId",parser:h},{code:70,name:"numberOfSecondaryAttributes",parser:h},{code:70,name:"isReallyLocked",parser:F},{code:70,name:"mtextFlag",parser:h},{code:280,name:"isDuplicatedEntriesKeep",parser:F},{code:100},{code:280,name:"lockPositionFlag",parser:F},{code:210,name:"extrusionDirection",parser:A},{code:11,name:"alignmentPoint",parser:A},{code:74,name:"verticalJustification",parser:h},{code:72,name:"horizontalJustification",parser:h},{code:71,name:"textGenerationFlag",parser:h},{code:7,name:"textStyle",parser:h},{code:51,name:"obliqueAngle",parser:h},{code:41,name:"scale",parser:h},{code:50,name:"rotation",parser:h},{code:73},{code:70,name:"attributeFlag",parser:h},{code:2,name:"tag",parser:h},{code:280},{code:100,name:"subclassMarker",parser:h},{code:1,name:"text",parser:h},{code:40,name:"textHeight",parser:h},{code:10,name:"startPoint",parser:A},{code:39,name:"thickness",parser:h},{code:100},...G];class yr{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){pr(this,"parser",v(So,To))}}pr(yr,"ForEntityName","ATTRIB");let Mo=Object.fromEntries([vn,Dn,yr,zn,Be,Bn,Cs,Yn,Xn,Kn,Ve,Qn,tr,rr,ar,hr,cr,ur,He,On,Hn,Ue,We,gr].map(n=>[n.ForEntityName,new n]));function _r(n,t){let e=[];for(;!k(n,0,"EOF");){if(n.code===0){if(n.value==="ENDBLK"||n.value==="ENDSEC"){t.rewind();break}let s=Mo[n.value];if(s){let r=n.value;n=t.next();let i=s.parseEntity(t,n);i.type=r,Sn(i),e.push(i)}else console.warn(`Unsupported ENTITY type: ${n.value}`)}n=t.next()}return e}function vo(n,t){let e={};for(;!k(n,0,"EOF")&&!k(n,0,"ENDSEC");){if(k(n,0,"BLOCK")){let s=Lo(n=t.next(),t);Sn(s),s.name&&(e[s.name]=s)}n=t.next()}return e}function Lo(n,t){let e={};for(;!k(n,0,"EOF");){if(k(n,0,"ENDBLK")){for(n=t.next();!k(n,0,"EOF");){if(k(n,100,"AcDbBlockEnd"))return e;n=t.next()}break}switch(n.code){case 1:e.xrefPath=n.value;break;case 2:e.name=n.value;break;case 3:e.name2=n.value;break;case 5:e.handle=n.value;break;case 8:e.layer=n.value;break;case 10:e.position=D(t);break;case 67:e.paperSpace=!!n.value&&n.value==1;break;case 70:n.value!==0&&(e.type=n.value);break;case 100:break;case 330:e.ownerHandle=n.value;break;case 0:e.entities=_r(n,t)}n=t.next()}return e}function ko(n,t){let e=null,s={};for(;!k(n,0,"EOF")&&!k(n,0,"ENDSEC");)n.code===9?e=n.value:n.code===10?s[e]=D(t):s[e]=n.value,n=t.next();return s}let Co=[{code:330,name:"imageDefReactorIdSoft",isMultiple:!0,parser:h},{code:90,name:"version",parser:h},{code:1,name:"fileName",parser:h},{code:10,name:"size",parser:A},{code:11,name:"sizeOfOnePixel",parser:A},{code:280,name:"isLoaded",parser:h},{code:281,name:"resolutionUnits",parser:h},{code:100,name:"subclassMarker",parser:h}],fr=[{code:333,name:"shadePlotId",parser:h},{code:149,name:"imageOriginY",parser:h},{code:148,name:"imageOriginX",parser:h},{code:147,name:"scaleFactor",parser:h},{code:78,name:"shadePlotCustomDPI",parser:h},{code:77,name:"shadePlotResolution",parser:h},{code:76,name:"shadePlotMode",parser:h},{code:75,name:"standardScaleType",parser:h},{code:7,name:"currentStyleSheet",parser:h},{code:74,name:"plotType",parser:h},{code:73,name:"plotRotation",parser:h},{code:72,name:"paperUnit",parser:h},{code:70,name:"layoutFlag",parser:h},{code:143,name:"printScaleDenominator",parser:h},{code:142,name:"printScaleNominator",parser:h},{code:141,name:"windowAreaYMax",parser:h},{code:140,name:"windowAreaYMin",parser:h},{code:49,name:"windowAreaXMax",parser:h},{code:48,name:"windowAreaXMin",parser:h},{code:47,name:"plotOriginY",parser:h},{code:46,name:"plotOriginX",parser:h},{code:45,name:"paperHeight",parser:h},{code:44,name:"paperWidth",parser:h},{code:43,name:"marginTop",parser:h},{code:42,name:"marginRight",parser:h},{code:41,name:"marginBottom",parser:h},{code:40,name:"marginLeft",parser:h},{code:6,name:"plotViewName",parser:h},{code:4,name:"paperSize",parser:h},{code:2,name:"configName",parser:h},{code:1,name:"pageSetupName",parser:h},{code:100,name:"subclassMarker",parser:h}],Oo=[{code:333,name:"shadePlotId",parser:h},{code:346,name:"orthographicUcsId",parser:h},{code:345,name:"namedUcsId",parser:h},{code:331,name:"viewportId",parser:h},{code:330,name:"paperSpaceTableId",parser:h},{code:76,name:"orthographicType",parser:h},{code:17,name:"ucsYAxis",parser:A},{code:16,name:"ucsXAxis",parser:A},{code:13,name:"ucsOrigin",parser:A},{code:146,name:"elevation",parser:h},{code:15,name:"maxExtent",parser:A},{code:14,name:"minExtent",parser:A},{code:12,name:"insertionBase",parser:A},{code:11,name:"maxLimit",parser:A},{code:10,name:"minLimit",parser:A},{code:71,name:"tabOrder",parser:h},{code:70,name:"controlFlag",parser:h},{code:1,name:"layoutName",parser:h},{code:100,name:"subclassMarker",parser:h},...fr],No=[{code:330,name:"ownerObjectId",parser:h},{code:102},{code:360,name:"ownerDictionaryIdHard",parser:h},{code:102},{code:102},{code:330,name:"ownerDictionaryIdSoft",parser:h},{code:102},{code:102},{code:102},{code:5,name:"handle",parser:h}];function xr(n){return n.subclassMarker==="AcDbDictionary"}let Do={LAYOUT:Oo,PLOTSETTINGS:fr,DICTIONARY:[{code:3,name:"entries",parser:(n,t)=>{let e={name:n.value};return(n=t.next()).code===350?e.objectId=n.value:t.rewind(),e},isMultiple:!0},{code:281,name:"recordCloneFlag",parser:h},{code:280,name:"isHardOwned",parser:F},{code:100,name:"subclassMarker",parser:h}],IMAGEDEF:Co};function Ro(n,t){let e=[];for(;n.code!==0||!["EOF","ENDSEC"].includes(n.value);){let s=n.value,r=Do[s];if(n.code===0&&(r!=null&&r.length)){let i=v([...No,...r]),a={name:s};i(n=t.next(),t,a)?(e.push(a),n=t.peek()):n=t.next()}else n=t.next()}return{byName:oo(e,({name:s})=>s),byTree:function(s){let r=Object.fromEntries(s.map(i=>[i.handle,i]));for(let i of s)(!xr(i)||i.ownerDictionaryIdSoft!=="0")&&(i.ownerDictionaryIdSoft&&(i.ownerDictionarySoft=r[i.ownerDictionaryIdSoft]),i.ownerDictionaryIdHard&&(i.ownerDictionaryHard=r[i.ownerDictionaryIdHard]),i.ownerObjectId&&(i.ownerObject=r[i.ownerObjectId])),function(a,o){xr(a)&&a.entries&&(a.entries=Object.fromEntries(a.entries.map(({name:c,objectId:l})=>[c,o[l]])))}(i,r);return s[0]}(e)}}let re=[{code:100,name:"subclassMarker",parser:h},{code:330,name:"ownerObjectId",parser:h},{code:102,parser(n,t){for(;!k(n,0,"EOF")&&!k(n,102,"}");)n=t.next()}},{code:5,name:"handle",parser:h}],zo=v([{code:310,name:"bmpPreview",parser:h},{code:281,name:"scalability",parser:h},{code:280,name:"explodability",parser:h},{code:70,name:"insertionUnits",parser:h},{code:340,name:"layoutObjects",parser:h},{code:2,name:"name",parser:h},{code:100,name:"subclassMarker",parser:h},...re]),Fo=v([...[{name:"DIMPOST",code:3},{name:"DIMAPOST",code:4},{name:"DIMBLK_OBSOLETE",code:5},{name:"DIMBLK1_OBSOLETE",code:6},{name:"DIMBLK2_OBSOLETE",code:7},{name:"DIMSCALE",code:40,defaultValue:1},{name:"DIMASZ",code:41,defaultValue:.25},{name:"DIMEXO",code:42,defaultValue:.625,defaultValueImperial:.0625},{name:"DIMDLI",code:43,defaultValue:3.75,defaultValueImperial:.38},{name:"DIMEXE",code:44,defaultValue:2.25,defaultValueImperial:.28},{name:"DIMRND",code:45,defaultValue:0},{name:"DIMDLE",code:46,defaultValue:0},{name:"DIMTP",code:47,defaultValue:0},{name:"DIMTM",code:48,defaultValue:0},{name:"DIMTXT",code:140,defaultValue:2.5,defaultValueImperial:.28},{name:"DIMCEN",code:141,defaultValue:2.5,defaultValueImperial:.09},{name:"DIMTSZ",code:142,defaultValue:0},{name:"DIMALTF",code:143,defaultValue:25.4},{name:"DIMLFAC",code:144,defaultValue:1},{name:"DIMTVP",code:145,defaultValue:0},{name:"DIMTFAC",code:146,defaultValue:1},{name:"DIMGAP",code:147,defaultValue:.625,defaultValueImperial:.09},{name:"DIMALTRND",code:148,defaultValue:0},{name:"DIMTOL",code:71,defaultValue:0,defaultValueImperial:1},{name:"DIMLIM",code:72,defaultValue:0},{name:"DIMTIH",code:73,defaultValue:0,defaultValueImperial:1},{name:"DIMTOH",code:74,defaultValue:0,defaultValueImperial:1},{name:"DIMSE1",code:75,defaultValue:0},{name:"DIMSE2",code:76,defaultValue:0},{name:"DIMTAD",code:77,defaultValue:In.Above,defaultValueImperial:In.Center},{name:"DIMZIN",code:78,defaultValue:ne.Trailing,defaultValueImperial:ne.Feet},{name:"DIMAZIN",code:79,defaultValue:Pa.None},{name:"DIMALT",code:170,defaultValue:0},{name:"DIMALTD",code:171,defaultValue:3,defaultValueImperial:2},{name:"DIMTOFL",code:172,defaultValue:1,defaultValueImperial:0},{name:"DIMSAH",code:173,defaultValue:0},{name:"DIMTIX",code:174,defaultValue:0},{name:"DIMSOXD",code:175,defaultValue:0},{name:"DIMCLRD",code:176,defaultValue:0},{name:"DIMCLRE",code:177,defaultValue:0},{name:"DIMCLRT",code:178,defaultValue:0},{name:"DIMADEC",code:179},{name:"DIMUNIT",code:270},{name:"DIMDEC",code:271,defaultValue:2,defaultValueImperial:4},{name:"DIMTDEC",code:272,defaultValue:2,defaultValueImperial:4},{name:"DIMALTU",code:273,defaultValue:2},{name:"DIMALTTD",code:274,defaultValue:2,defaultValueImperial:4},{name:"DIMAUNIT",code:275,defaultValue:0},{name:"DIMFRAC",code:276,defaultValue:0},{name:"DIMLUNIT",code:277,defaultValue:2},{name:"DIMDSEP",code:278,defaultValue:",",defaultValueImperial:"."},{name:"DIMJUST",code:280,defaultValue:Ia.Center},{name:"DIMSD1",code:281,defaultValue:0},{name:"DIMSD2",code:282,defaultValue:0},{name:"DIMTOLJ",code:283,defaultValue:Ea.Center},{name:"DIMTZIN",code:284,defaultValue:ne.Trailing,defaultValueImperial:ne.Feet},{name:"DIMALTZ",code:285,defaultValue:ne.Trailing},{name:"DIMALTTZ",code:286,defaultValue:ne.Trailing},{name:"DIMFIT",code:287},{name:"DIMUPT",code:288,defaultValue:0},{name:"DIMATFIT",code:289,defaultValue:3},{name:"DIMTXSTY",code:340},{name:"DIMLDRBLK",code:341},{name:"DIMBLK",code:342},{name:"DIMBLK1",code:343},{name:"DIMBLK2",code:344},{name:"DIMLWD",code:371,defaultValue:-2},{name:"DIMLWD",code:372,defaultValue:-2}].map(n=>({...n,parser:h})),{code:70,name:"standardFlag",parser:h},{code:2,name:"name",parser:h},{code:100,name:"subclassMarker",parser:h},{code:105,name:"handle",parser:h},...re.filter(n=>n.code!==5)]),Bo=v([{code:347,name:"materialObjectId",parser:h},{code:390,name:"plotStyleNameObjectId",parser:h},{code:370,name:"lineweight",parser:h},{code:290,name:"isPlotting",parser:F},{code:6,name:"lineType",parser:h},{code:62,name:"colorIndex",parser:h},{code:70,name:"standardFlag",parser:h},{code:2,name:"name",parser:h},{code:100,name:"subclassMarker",parser:h},...re]),Vo=v([{code:9,name:"text",parser:h},{code:45,name:"offsetY",parser:h},{code:44,name:"offsetX",parser:h},{code:50,name:"rotation",parser:h},{code:46,name:"scale",parser:h},{code:340,name:"styleObjectId",parser:h},{code:75,name:"shapeNumber",parser:h},{code:74,name:"elementTypeFlag",parser:h},{code:49,name:"elementLength",parser:h}],{elementTypeFlag:0,elementLength:0}),jo={BLOCK_RECORD:zo,DIMSTYLE:Fo,LAYER:Bo,LTYPE:v([{code:49,name:"pattern",parser(n,t){let e={};return Vo(n,t,e),e},isMultiple:!0},{code:40,name:"totalPatternLength",parser:h},{code:73,name:"numberOfLineTypes",parser:h},{code:72,parser:h},{code:3,name:"description",parser:h},{code:70,name:"standardFlag",parser:h},{code:2,name:"name",parser:h},{code:100,name:"subclassMarker",parser:h},...re]),STYLE:v([{code:1e3,name:"extendedFont",parser:h},{code:1001},{code:4,name:"bigFont",parser:h},{code:3,name:"font",parser:h},{code:42,name:"lastHeight",parser:h},{code:71,name:"textGenerationFlag",parser:h},{code:50,name:"obliqueAngle",parser:h},{code:41,name:"widthFactor",parser:h},{code:40,name:"fixedTextHeight",parser:h},{code:70,name:"standardFlag",parser:h},{code:2,name:"name",parser:h},{code:100,name:"subclassMarker",parser:h},...re]),VPORT:v([{code:[63,421,431],name:"ambientColor",parser:h},{code:142,name:"contrast",parser:h},{code:141,name:"brightness",parser:h},{code:282,name:"defaultLightingType",parser:h},{code:292,name:"isDefaultLightingOn",parser:F},{code:348,name:"visualStyleObjectId",parser:h},{code:333,name:"shadePlotObjectId",parser:h},{code:332,name:"backgroundObjectId",parser:h},{code:61,name:"majorGridLines",parser:h},{code:170,name:"shadePlotSetting",parser:h},{code:146,name:"elevation",parser:h},{code:79,name:"orthographicType",parser:h},{code:112,name:"ucsYAxis",parser:A},{code:111,name:"ucsXAxis",parser:A},{code:110,name:"ucsOrigin",parser:A},{code:74,name:"ucsIconSetting",parser:h},{code:71,name:"viewMode",parser:h},{code:281,name:"renderMode",parser:h},{code:1,name:"styleSheet",parser:h},{code:[331,441],name:"frozenLayers",parser:h,isMultiple:!0},{code:72,name:"circleSides",parser:h},{code:51,name:"viewTwistAngle",parser:h},{code:50,name:"snapRotationAngle",parser:h},{code:45,name:"viewHeight",parser:h},{code:44,name:"backClippingPlane",parser:h},{code:43,name:"frontClippingPlane",parser:h},{code:42,name:"lensLength",parser:h},{code:17,name:"viewTarget",parser:A},{code:16,name:"viewDirectionFromTarget",parser:A},{code:15,name:"gridSpacing",parser:A},{code:14,name:"snapSpacing",parser:A},{code:13,name:"snapBasePoint",parser:A},{code:12,name:"center",parser:A},{code:11,name:"upperRightCorner",parser:A},{code:10,name:"lowerLeftCorner",parser:A},{code:70,name:"standardFlag",parser:h},{code:2,name:"name",parser:h},{code:100,name:"subclassMarker",parser:h},...re])},Go=v([{code:70,name:"maxNumberOfEntries",parser:h},{code:100,name:"subclassMarker",parser:h},{code:330,name:"ownerObjectId",parser:h},{code:102},{code:360,isMultiple:!0},{code:102},{code:5,name:"handle",parser:h},{code:2,name:"name",parser:h}]);function Ho(n,t){var s;let e={};for(;!k(n,0,"EOF")&&!k(n,0,"ENDSEC");){if(k(n,0,"TABLE")){n=t.next();let r={entries:[]};Go(n,t,r),e[r.name]=r}if(k(n,0)&&!k(n,0,"ENDTAB")){let r=n.value;n=t.next();let i=jo[r];if(!i){console.warn(`parseTable: Invalid table name '${r}'`),n=t.next();continue}let a={};i(n,t,a),(s=e[r])==null||s.entries.push(a)}n=t.next()}return e}function Ye(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}class br{next(){if(!this.hasNext())return this._eof?console.warn("Cannot call 'next' after EOF group has been read"):console.warn("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]),{code:0,value:"EOF"};let t=parseInt(this._data[this._pointer++],10),e=wr(t,this._data[this._pointer++]),s={code:t,value:e};return k(s,0,"EOF")&&(this._eof=!0),this.lastReadGroup=s,s}peek(){if(!this.hasNext())throw this._eof?Error("Cannot call 'next' after EOF group has been read"):Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);let t={code:parseInt(this._data[this._pointer]),value:0};return t.value=wr(t.code,this._data[this._pointer+1]),t}rewind(t){t=t||1,this._pointer=this._pointer-2*t}hasNext(){return!this._eof&&!(this._pointer>this._data.length-2)}isEOF(){return this._eof}constructor(t){Ye(this,"_pointer",void 0),Ye(this,"_data",void 0),Ye(this,"_eof",void 0),Ye(this,"lastReadGroup",{code:0,value:0}),this._pointer=0,this._data=t,this._eof=!1}}function wr(n,t){return n<=9?t:n>=10&&n<=59?parseFloat(t.trim()):n>=60&&n<=99?parseInt(t.trim()):n>=100&&n<=109?t:n>=110&&n<=149?parseFloat(t.trim()):n>=160&&n<=179?parseInt(t.trim()):n>=210&&n<=239?parseFloat(t.trim()):n>=270&&n<=289?parseInt(t.trim()):n>=290&&n<=299?function(e){if(e==="0")return!1;if(e==="1")return!0;throw TypeError("String '"+e+"' cannot be cast to Boolean type")}(t.trim()):n>=300&&n<=369?t:n>=370&&n<=389?parseInt(t.trim()):n>=390&&n<=399?t:n>=400&&n<=409?parseInt(t.trim()):n>=410&&n<=419?t:n>=420&&n<=429?parseInt(t.trim()):n>=430&&n<=439?t:n>=440&&n<=459?parseInt(t.trim()):n>=460&&n<=469?parseFloat(t.trim()):n>=470&&n<=481||n===999||n>=1e3&&n<=1009?t:n>=1010&&n<=1059?parseFloat(t.trim()):n>=1060&&n<=1071?parseInt(t.trim()):(console.log("WARNING: Group code does not have a defined type: %j",{code:n,value:t}),t)}function Os(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let Uo=class{constructor(){Os(this,"encoding","utf-8"),Os(this,"encodingFailureFatal",!1)}};class Wo extends EventTarget{parseSync(t){let e=new br(t.split(/\r\n|\r|\n/g));if(!e.hasNext())throw Error("Empty file");return this.parseAll(e)}parseStream(t){let e="",s=this;return new Promise((r,i)=>{t.on("data",a=>{e+=a}),t.on("end",()=>{try{let a=e.split(/\r\n|\r|\n/g),o=new br(a);if(!o.hasNext())throw Error("Empty file");r(s.parseAll(o))}catch(a){i(a)}}),t.on("error",a=>{i(a)})})}async parseFromUrl(t,e){let s=await fetch(t,e);if(!s.body)return null;let r=s.body.getReader(),i="";for(;;){let{done:a,value:o}=await r.read();if(a){i+=this._decoder.decode(new ArrayBuffer(0),{stream:!1});break}i+=this._decoder.decode(o,{stream:!0})}return this.parseSync(i)}parseAll(t){let e={header:{},blocks:{},entities:[],tables:{},objects:{byName:{},byTree:void 0}},s=t.next();for(;!k(s,0,"EOF");)k(s,0,"SECTION")&&(k(s=t.next(),2,"HEADER")?(s=t.next(),e.header=ko(s,t)):k(s,2,"BLOCKS")?(s=t.next(),e.blocks=vo(s,t)):k(s,2,"ENTITIES")?(s=t.next(),e.entities=_r(s,t)):k(s,2,"TABLES")?(s=t.next(),e.tables=Ho(s,t)):k(s,2,"OBJECTS")&&(s=t.next(),e.objects=Ro(s,t))),s=t.next();return e}constructor(t=new Uo){super(),Os(this,"_decoder",void 0),this._decoder=new TextDecoder(t.encoding,{fatal:t.encodingFailureFatal})}}var Ns=(n=>(n[n.DecimalDegrees=0]="DecimalDegrees",n[n.DegreesMinutesSeconds=1]="DegreesMinutesSeconds",n[n.Gradians=2]="Gradians",n[n.Radians=3]="Radians",n[n.SurveyorsUnits=4]="SurveyorsUnits",n))(Ns||{});class kt{static get instance(){return this._instance||(this._instance=new kt),this._instance}constructor(){this._blocks=new Map}createKey(t,e){return`${t}_${e}`}set(t,e){return e=e.fastDeepClone(),this._blocks.set(t,e),e}get(t){let e=this._blocks.get(t);return e&&(e=e.fastDeepClone()),e}has(t){return this._blocks.has(t)}clear(){this._blocks.clear()}draw(t,e,s,r=!0,i,a){const o=[];if(e!=null){const c=this.createKey(e.name,s);let l;if(this.has(c))l=this.get(c);else{const d=e.newIterator();for(const u of d)if(u.color.isByBlock&&s){Ar.copy(u.color),u.color.color=s;const m=u.draw(t);m&&o.push(m),u.color.copy(Ar)}else{const m=u.draw(t);m&&o.push(m)}l=t.group(o),l&&r&&this.set(c,l)}return l&&i&&(l.applyMatrix(i),a&&(a.x!=0||a.y!=0||a.z!=1)&&(i.setFromExtrusionDirection(a),l.applyMatrix(i))),l}else return t.group(o)}}const Ar=new zt,qe="Continuous",Xe="ByLayer",Pr="ByBlock";var Ut=(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.Insertion=7]="Insertion",n[n.Perpendicular=8]="Perpendicular",n[n.Tangent=9]="Tangent",n[n.Nearest=10]="Nearest",n[n.Centroid=11]="Centroid",n))(Ut||{}),Ds=(n=>(n[n.Undefined=0]="Undefined",n[n.Inches=1]="Inches",n[n.Feet=2]="Feet",n[n.Miles=3]="Miles",n[n.Millimeters=4]="Millimeters",n[n.Centimeters=5]="Centimeters",n[n.Meters=6]="Meters",n[n.Kilometers=7]="Kilometers",n[n.Microinches=8]="Microinches",n[n.Mils=9]="Mils",n[n.Yards=10]="Yards",n[n.Angstroms=11]="Angstroms",n[n.Nanometers=12]="Nanometers",n[n.Microns=13]="Microns",n[n.Decimeters=14]="Decimeters",n[n.Dekameters=15]="Dekameters",n[n.Hectometers=16]="Hectometers",n[n.Gigameters=17]="Gigameters",n[n.Astronomical=18]="Astronomical",n[n.LightYears=19]="LightYears",n[n.Parsecs=20]="Parsecs",n[n.USSurveyFeet=21]="USSurveyFeet",n[n.USSurveyInch=22]="USSurveyInch",n[n.USSurveyYard=23]="USSurveyYard",n[n.USSurveyMile=24]="USSurveyMile",n[n.Max=24]="Max",n))(Ds||{});function Yo(n){return n==4||n==5||n==6||n==7||n==12||n==13||n==14||n==15||n==16||n==17}function qo(n){return n==1||n==2||n==3||n==8||n==9||n==10||n==21}var Ir=(n=>(n.ClosedFilled="",n.Dot="_DOT",n.DotSmall="_DOTSMALL",n.DotBlank="_DOTBLANK",n.Origin="_ORIGIN",n.Origin2="_ORIGIN2",n.Open="_OPEN",n.Open90="_OPEN90",n.Open30="_OPEN30",n.Closed="_CLOSED",n.Small="_SMALL",n.None="_NONE",n.Oblique="_OBLIQUE",n.BoxFilled="_BOXFILLED",n.Box="_BOXBLANK",n.ClosedBlank="_CLOSEDBLANK",n.DatumBlank="_DATUMBLANK",n.DatumFilled="_DATUMFILLED",n.Integral="_INTEGRAL",n.ArchTick="_ARCHTICK",n))(Ir||{});class $e{constructor(t){this.i=0,this._records=t,this._keys=Array.from(t.keys())}[Symbol.iterator](){return this}next(){for(;this.i<this._keys.length;){const t=this._records.get(this._keys[this.i]);return this.i+=1,{value:t,done:!1}}return{value:null,done:!0}}}const Er="Load Database";class tt extends xn{constructor(t,e){super(t.stage),this.data=t,this.progress=e}async run(t){const e=xs.getInstance().getEntry(Er),s=Date.now();this.progress&&await this.progress(this.data.progress.value,this.data.stage,"START");const r=await this.data.task(t);if(this.progress){const i=r.data;await this.progress(this.data.progress.value,this.data.stage,"END",i),this.data.progress.value+=this.data.step,this.data.progress.value>100&&(this.data.progress.value=100)}return e&&(e.data[this.name]=Date.now()-s),r}}class Tr{async read(t,e,s,r){const i={name:Er,data:{total:0},format(){let l="";return Object.keys(this.data).forEach(d=>{d!=="total"&&(l+=`- ${d}: ${this.data[d]} ms
2
- `)}),l+=`- total: ${this.data.total} ms`,l}};xs.getInstance().collect(i),this.progress=r;const a={value:0},o=new bn;o.setCompleteCallback(()=>this.onFinished()),o.setErrorCallback(()=>this.onFinished()),o.addTask(new tt({stage:"START",step:1,progress:a,task:async l=>l},r)),o.addTask(new tt({stage:"PARSE",step:5,progress:a,task:async l=>({model:await this.parse(l)})},r)),o.addTask(new tt({stage:"FONT",step:5,progress:a,task:async l=>{const d=this.getFonts(l.model);return{model:l.model,data:d}}},r)),o.addTask(new tt({stage:"LTYPE",step:1,progress:a,task:async l=>(this.processLineTypes(l.model,e),l)},r)),o.addTask(new tt({stage:"STYLE",step:1,progress:a,task:async l=>(this.processTextStyles(l.model,e),l)},r)),o.addTask(new tt({stage:"DIMSTYLE",step:1,progress:a,task:async l=>(this.processDimStyles(l.model,e),l)},r)),o.addTask(new tt({stage:"LAYER",step:1,progress:a,task:async l=>(this.processLayers(l.model,e),l)},r)),o.addTask(new tt({stage:"VPORT",step:1,progress:a,task:async l=>(this.processViewports(l.model,e),l)},r)),o.addTask(new tt({stage:"HEADER",step:1,progress:a,task:async l=>(this.processHeader(l.model,e),l)},r)),o.addTask(new tt({stage:"BLOCK_RECORD",step:5,progress:a,task:async l=>(this.processBlockTables(l.model,e),l)},r)),o.addTask(new tt({stage:"OBJECT",step:5,progress:a,task:async l=>(this.processObjects(l.model,e),l)},r)),o.addTask(new tt({stage:"BLOCK",step:5,progress:a,task:async l=>(await this.processBlocks(l.model,e),l)},r)),o.addTask(new tt({stage:"ENTITY",step:100,progress:a,task:async l=>(await this.processEntities(l.model,e,s,a,r),l)},r)),o.addTask(new tt({stage:"END",step:0,progress:a,task:async l=>l},r));const c=Date.now();await o.run(t),i.data.total=Date.now()-c}onFinished(){this.progress&&(this.progress(100,"END","END"),kt.instance.clear())}parse(t){throw new Error("Not impelemented yet!")}getFonts(t){throw new Error("Not impelemented yet!")}processLineTypes(t,e){throw new Error("Not impelemented yet!")}processTextStyles(t,e){throw new Error("Not impelemented yet!")}processDimStyles(t,e){throw new Error("Not impelemented yet!")}processLayers(t,e){throw new Error("Not impelemented yet!")}processViewports(t,e){throw new Error("Not impelemented yet!")}processHeader(t,e){throw new Error("Not impelemented yet!")}processBlockTables(t,e){throw new Error("Not impelemented yet!")}processObjects(t,e){throw new Error("Not impelemented yet!")}processBlocks(t,e){throw new Error("Not impelemented yet!")}processEntities(t,e,s,r,i){throw new Error("Not impelemented yet!")}}const $=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Sr=1234567;const Rs=Math.PI/180,zs=180/Math.PI;function Mr(){const n=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return($[n&255]+$[n>>8&255]+$[n>>16&255]+$[n>>24&255]+"-"+$[t&255]+$[t>>8&255]+"-"+$[t>>16&15|64]+$[t>>24&255]+"-"+$[e&63|128]+$[e>>8&255]+"-"+$[e>>16&255]+$[e>>24&255]+$[s&255]+$[s>>8&255]+$[s>>16&255]+$[s>>24&255]).toLowerCase()}function Tt(n,t,e){return Math.max(t,Math.min(e,n))}function Fs(n,t){return(n%t+t)%t}function vr(n,t,e,s,r){return s+(n-t)*(r-s)/(e-t)}function Lr(n,t,e){return n!==t?(e-n)/(t-n):0}function Bs(n,t,e){return(1-e)*n+e*t}function kr(n,t,e,s){return Bs(n,t,1-Math.exp(-e*s))}function Cr(n,t=1){return t-Math.abs(Fs(n,t*2)-t)}function Or(n,t,e){return n<=t?0:n>=e?1:(n=(n-t)/(e-t),n*n*(3-2*n))}function Nr(n,t,e){return n<=t?0:n>=e?1:(n=(n-t)/(e-t),n*n*n*(n*(n*6-15)+10))}function Dr(n,t){return n+Math.floor(Math.random()*(t-n+1))}function Rr(n,t){return n+Math.random()*(t-n)}function zr(n){return n*(.5-Math.random())}function Fr(n){n!==void 0&&(Sr=n);let t=Sr+=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 Br(n){return n*Rs}function Vr(n){return n*zs}function jr(n){return(n&n-1)===0&&n!==0}function Gr(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function Hr(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function Me(n){const t=Math.PI*2;return(n%t+t)%t}function Ur(n,t,e){return n>t&&n<e||n>e&&n<t}function Wr(n,t,e,s=!1){return n=Me(n),t=Me(t),e=Me(e),s?t>e?n<=t&&n>=e:n<=t||n>=e:t<e?n>=t&&n<=e:n>=t||n<=e}function Vs(n){return n=Math.abs(n),n<1?0:Math.ceil(Math.log10(Math.abs(n)+1))}function Yr(n,t=1e-7){const e=Vs(n);return Math.max(Math.pow(10,e)*t,t)}const C={DEG2RAD:Rs,RAD2DEG:zs,generateUUID:Mr,clamp:Tt,euclideanModulo:Fs,mapLinear:vr,inverseLerp:Lr,lerp:Bs,damp:kr,pingpong:Cr,smoothstep:Or,smootherstep:Nr,randInt:Dr,randFloat:Rr,randFloatSpread:zr,seededRandom:Fr,degToRad:Br,radToDeg:Vr,isPowerOfTwo:jr,ceilPowerOfTwo:Gr,floorPowerOfTwo:Hr,normalizeAngle:Me,isBetween:Ur,isBetweenAngle:Wr,intPartLength:Vs,relativeEps:Yr},js=class ca{constructor(t,e){this.x=0,this.y=0;const s=+(t!==void 0)+ +(e!==void 0);if(s!==0){if(s===1&&t instanceof Array){this.x=t[0],this.y=t[1];return}if(s===1){const{x:r,y:i}=t;this.x=r,this.y=i;return}if(s===2){this.x=t,this.y=e;return}throw et.ILLEGAL_PARAMETERS}}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(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}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new ca(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix2d(t){const e=this.x,s=this.y,r=t.elements;return this.x=r[0]*e+r[3]*s+r[6],this.y=r[1]*e+r[4]*s+r[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(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}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(t,Math.min(e,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const s=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,s)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y;return e*e+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}rotateAround(t,e){const s=Math.cos(e),r=Math.sin(e),i=this.x-t.x,a=this.y-t.y;return this.x=i*s-a*r+t.x,this.y=i*r+a*s+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}relativeEps(t=1e-7){return Math.min(C.relativeEps(this.x,t),C.relativeEps(this.y,t))}*[Symbol.iterator](){yield this.x,yield this.y}};js.EMPTY=Object.freeze(new js(0,0));let B=js;const Gs=class da{constructor(t,e,s,r,i,a,o,c,l){this.elements=[1,0,0,0,1,0,0,0,1],t!=null&&e!=null&&s!=null&&r!=null&&i!=null&&a!=null&&o!=null&&c!=null&&l!=null&&this.set(t,e,s,r,i,a,o,c,l)}set(t,e,s,r,i,a,o,c,l){const d=this.elements;return d[0]=t,d[1]=r,d[2]=o,d[3]=e,d[4]=i,d[5]=c,d[6]=s,d[7]=a,d[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],this}extractBasis(t,e,s){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const 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}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,r=e.elements,i=this.elements,a=s[0],o=s[3],c=s[6],l=s[1],d=s[4],u=s[7],m=s[2],p=s[5],y=s[8],_=r[0],x=r[3],f=r[6],M=r[1],T=r[4],S=r[7],P=r[2],z=r[5],I=r[8];return i[0]=a*_+o*M+c*P,i[3]=a*x+o*T+c*z,i[6]=a*f+o*S+c*I,i[1]=l*_+d*M+u*P,i[4]=l*x+d*T+u*z,i[7]=l*f+d*S+u*I,i[2]=m*_+p*M+y*P,i[5]=m*x+p*T+y*z,i[8]=m*f+p*S+y*I,this}multiplyScalar(t){const 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}determinant(){const t=this.elements,e=t[0],s=t[1],r=t[2],i=t[3],a=t[4],o=t[5],c=t[6],l=t[7],d=t[8];return e*a*d-e*o*l-s*i*d+s*o*c+r*i*l-r*a*c}invert(){const t=this.elements,e=t[0],s=t[1],r=t[2],i=t[3],a=t[4],o=t[5],c=t[6],l=t[7],d=t[8],u=d*a-o*l,m=o*c-d*i,p=l*i-a*c,y=e*u+s*m+r*p;if(y===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/y;return t[0]=u*_,t[1]=(r*l-d*s)*_,t[2]=(o*s-r*a)*_,t[3]=m*_,t[4]=(d*e-r*c)*_,t[5]=(r*i-o*e)*_,t[6]=p*_,t[7]=(s*c-l*e)*_,t[8]=(a*e-s*i)*_,this}transpose(){let t;const 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}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const 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}setUvTransform(t,e,s,r,i,a,o){const c=Math.cos(i),l=Math.sin(i);return this.set(s*c,s*l,-s*(c*a+l*o)+a+t,-r*l,r*c,-r*(-l*a+c*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(Hs.makeScale(t,e)),this}rotate(t){return this.premultiply(Hs.makeRotation(-t)),this}translate(t,e){return this.premultiply(Hs.makeTranslation(t,e)),this}makeTranslation(t,e){return t instanceof B?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}makeRotation(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,s,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,s=t.elements;for(let r=0;r<9;r++)if(e[r]!==s[r])return!1;return!0}fromArray(t,e=0){for(let s=0;s<9;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t}clone(){return new da().fromArray(this.elements)}};Gs.IDENTITY=Object.freeze(new Gs);let Ke=Gs;const Hs=new Ke,Wt=1e-6,H=2*Math.PI,Xo={x:0,y:0},Us={x:0,y:0,z:0};class Ws{constructor(){this.equalPointTol=Wt,this.equalVectorTol=Wt}equalPoint2d(t,e){return new B(t).sub(e).length()<this.equalPointTol}equalPoint3d(t,e){return new w(t).sub(e).length()<this.equalPointTol}static equalToZero(t,e=Wt){return t<e&&t>-e}static equal(t,e,s=Wt){return Math.abs(t-e)<s}static great(t,e,s=Wt){return t-e>s}static less(t,e,s=Wt){return t-e<s}}const Ys=new Ws;function qs(n,t,e=!1){const s=n.x,r=n.y;let i=!1;const a=t.length;for(let o=0,c=a-1;o<a;c=o++){const l=t[o].x,d=t[o].y,u=t[c].x,m=t[c].y;let p=d>r!=m>r;e&&(p=d>=r!=m>=r),p&&s<(u-l)*(r-d)/(m-d)+l&&(i=!i)}return i}function qr(n,t){if(n.length===0||t.length===0)return!1;const e=new K().setFromPoints(n),s=new K().setFromPoints(t);if(!e.intersectsBox(s))return!1;for(let r=0;r<n.length;){if(qs(n[r],t,!0))return!0;r<n.length-1&&Ys.equalPoint2d(n[r+1],n[r])&&++r,++r}return!1}const Xr={isPointInPolygon:qs,isPolygonIntersect:qr};function $r(n,t){const e=[],s=t-1,r=n;for(let i=0;i<=r;i++)e.push(0);for(let i=1;i<=s-r;i++)e.push(i);for(let i=0;i<=r;i++)e.push(s-r+1);return e}function Kr(n,t){const e=t.length-1,s=n,r=[0];let i=0;for(let o=1;o<=e;o++){const c=t[o][0]-t[o-1][0],l=t[o][1]-t[o-1][1],d=t[o][2]-t[o-1][2],u=Math.sqrt(c*c+l*l+d*d);i+=u,r.push(i)}const a=[];for(let o=0;o<=s;o++)a.push(0);for(let o=1;o<=e-s;o++){const c=r[o]/i;a.push(c*(e-s+1))}for(let o=0;o<=s;o++)a.push(e-s+1);return a}function Zr(n,t){const e=t.length-1,s=n,r=[0];let i=0;for(let o=1;o<=e;o++){const c=t[o][0]-t[o-1][0],l=t[o][1]-t[o-1][1],d=t[o][2]-t[o-1][2],u=Math.sqrt(c*c+l*l+d*d),m=Math.sqrt(u);i+=m,r.push(i)}const a=[];for(let o=0;o<=s;o++)a.push(0);for(let o=1;o<=e-s;o++){const c=r[o]/i;a.push(c*(e-s+1))}for(let o=0;o<=s;o++)a.push(e-s+1);return a}function Ze(n,t,e,s){if(t===0)return e>=s[n]&&e<s[n+1]?1:0;const r=s[n+t]-s[n],i=s[n+t+1]-s[n+1],a=r>1e-10?(e-s[n])/r:0,o=i>1e-10?(s[n+t+1]-e)/i:0;return a*Ze(n,t-1,e,s)+o*Ze(n+1,t-1,e,s)}function ve(n,t,e,s,r){const i=s.length-1,a=t;if(n=Math.max(e[a],Math.min(e[i+1],n)),Math.abs(n-e[i+1])<1e-8)return[...s[i]];if(Math.abs(n-e[a])<1e-8)return[...s[0]];const o=[0,0,0];let c=0;for(let l=0;l<=i;l++){const d=Ze(l,a,n,e),u=r[l]*d;o[0]+=s[l][0]*u,o[1]+=s[l][1]*u,o[2]+=s[l][2]*u,c+=u}if(c<1e-10){const l=e[e.length-a-1];if(Math.abs(n-l)<1e-8)return[...s[i]];if(Math.abs(n-e[a])<1e-8)return[...s[0]]}return c>1e-10&&(o[0]/=c,o[1]/=c,o[2]/=c),o}function Qr(n,t,e,s){const r=n,i=t[r],a=t[t.length-r-1];let o=0;const c=1e3,l=(a-i)/c;let d=ve(i,n,t,e,s);for(let _=1;_<=c;_++){const x=i+_*l,f=ve(x,n,t,e,s),M=f[0]-d[0],T=f[1]-d[1],S=f[2]-d[2];o+=Math.sqrt(M*M+T*T+S*S),d=f}const u=ve(a,n,t,e,s),m=u[0]-d[0],p=u[1]-d[1],y=u[2]-d[2];return o+=Math.sqrt(m*m+p*p+y*y),o}function $o(n){return n.map(t=>[...t])}class Ct{constructor(t=0,e=0,s=0,r=1){this._x=t,this._y=e,this._z=s,this._w=r}static slerpFlat(t,e,s,r,i,a,o){let c=s[r+0],l=s[r+1],d=s[r+2],u=s[r+3];const m=i[a+0],p=i[a+1],y=i[a+2],_=i[a+3];if(o===0){t[e+0]=c,t[e+1]=l,t[e+2]=d,t[e+3]=u;return}if(o===1){t[e+0]=m,t[e+1]=p,t[e+2]=y,t[e+3]=_;return}if(u!==_||c!==m||l!==p||d!==y){let x=1-o;const f=c*m+l*p+d*y+u*_,M=f>=0?1:-1,T=1-f*f;if(T>Number.EPSILON){const P=Math.sqrt(T),z=Math.atan2(P,f*M);x=Math.sin(x*z)/P,o=Math.sin(o*z)/P}const S=o*M;if(c=c*x+m*S,l=l*x+p*S,d=d*x+y*S,u=u*x+_*S,x===1-o){const P=1/Math.sqrt(c*c+l*l+d*d+u*u);c*=P,l*=P,d*=P,u*=P}}t[e]=c,t[e+1]=l,t[e+2]=d,t[e+3]=u}static multiplyQuaternionsFlat(t,e,s,r,i,a){const o=s[r],c=s[r+1],l=s[r+2],d=s[r+3],u=i[a],m=i[a+1],p=i[a+2],y=i[a+3];return t[e]=o*y+d*u+c*p-l*m,t[e+1]=c*y+d*m+l*u-o*p,t[e+2]=l*y+d*p+o*m-c*u,t[e+3]=d*y-o*u-c*m-l*p,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,s,r){return this._x=t,this._y=e,this._z=s,this._w=r,this._onChangeCallback(),this}clone(){return new Ct(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const s=t.x,r=t.y,i=t.z,a=t.order,o=Math.cos,c=Math.sin,l=o(s/2),d=o(r/2),u=o(i/2),m=c(s/2),p=c(r/2),y=c(i/2);switch(a){case"XYZ":this._x=m*d*u+l*p*y,this._y=l*p*u-m*d*y,this._z=l*d*y+m*p*u,this._w=l*d*u-m*p*y;break;case"YXZ":this._x=m*d*u+l*p*y,this._y=l*p*u-m*d*y,this._z=l*d*y-m*p*u,this._w=l*d*u+m*p*y;break;case"ZXY":this._x=m*d*u-l*p*y,this._y=l*p*u+m*d*y,this._z=l*d*y+m*p*u,this._w=l*d*u-m*p*y;break;case"ZYX":this._x=m*d*u-l*p*y,this._y=l*p*u+m*d*y,this._z=l*d*y-m*p*u,this._w=l*d*u+m*p*y;break;case"YZX":this._x=m*d*u+l*p*y,this._y=l*p*u+m*d*y,this._z=l*d*y-m*p*u,this._w=l*d*u-m*p*y;break;case"XZY":this._x=m*d*u-l*p*y,this._y=l*p*u-m*d*y,this._z=l*d*y+m*p*u,this._w=l*d*u+m*p*y;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const s=e/2,r=Math.sin(s);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(s),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,s=e[0],r=e[4],i=e[8],a=e[1],o=e[5],c=e[9],l=e[2],d=e[6],u=e[10],m=s+o+u;if(m>0){const p=.5/Math.sqrt(m+1);this._w=.25/p,this._x=(d-c)*p,this._y=(i-l)*p,this._z=(a-r)*p}else if(s>o&&s>u){const p=2*Math.sqrt(1+s-o-u);this._w=(d-c)/p,this._x=.25*p,this._y=(r+a)/p,this._z=(i+l)/p}else if(o>u){const p=2*Math.sqrt(1+o-s-u);this._w=(i-l)/p,this._x=(r+a)/p,this._y=.25*p,this._z=(c+d)/p}else{const p=2*Math.sqrt(1+u-s-o);this._w=(a-r)/p,this._x=(i+l)/p,this._y=(c+d)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let s=t.dot(e)+1;return s<Number.EPSILON?(s=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=s):(this._x=0,this._y=-t.z,this._z=t.y,this._w=s)):(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=s),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Tt(this.dot(t),-1,1)))}rotateTowards(t,e){const s=this.angleTo(t);if(s===0)return this;const r=Math.min(1,e/s);return this.slerp(t,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let 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}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const s=t._x,r=t._y,i=t._z,a=t._w,o=e._x,c=e._y,l=e._z,d=e._w;return this._x=s*d+a*o+r*l-i*c,this._y=r*d+a*c+i*o-s*l,this._z=i*d+a*l+s*c-r*o,this._w=a*d-s*o-r*c-i*l,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const s=this._x,r=this._y,i=this._z,a=this._w;let o=a*t._w+s*t._x+r*t._y+i*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=s,this._y=r,this._z=i,this;const c=1-o*o;if(c<=Number.EPSILON){const p=1-e;return this._w=p*a+e*this._w,this._x=p*s+e*this._x,this._y=p*r+e*this._y,this._z=p*i+e*this._z,this.normalize(),this}const l=Math.sqrt(c),d=Math.atan2(l,o),u=Math.sin((1-e)*d)/l,m=Math.sin(e*d)/l;return this._w=a*u+this._w*m,this._x=s*u+this._x*m,this._y=r*u+this._y*m,this._z=i*u+this._z*m,this._onChangeCallback(),this}slerpQuaternions(t,e,s){return this.copy(t).slerp(e,s)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),s=Math.random(),r=Math.sqrt(1-s),i=Math.sqrt(s);return this.set(r*Math.sin(t),r*Math.cos(t),i*Math.sin(e),i*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const at=class ua{constructor(t,e,s){this.x=0,this.y=0,this.z=0;const r=+(t!==void 0)+ +(e!==void 0)+ +(s!==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){const{x:i,y:a,z:o}=t;this.x=i,this.y=a,this.z=o||0;return}if(r===3){this.x=t,this.y=e,this.z=s;return}throw et.ILLEGAL_PARAMETERS}}set(t,e,s){return s===void 0&&(s=this.z),this.x=t,this.y=e,this.z=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(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}getComponent(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)}}clone(){return new ua(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z||0,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z||0,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Jr.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Jr.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,s=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[3]*s+i[6]*r,this.y=i[1]*e+i[4]*s+i[7]*r,this.z=i[2]*e+i[5]*s+i[8]*r,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix3d(t){const e=this.x,s=this.y,r=this.z,i=t.elements,a=1/(i[3]*e+i[7]*s+i[11]*r+i[15]);return this.x=(i[0]*e+i[4]*s+i[8]*r+i[12])*a,this.y=(i[1]*e+i[5]*s+i[9]*r+i[13])*a,this.z=(i[2]*e+i[6]*s+i[10]*r+i[14])*a,this}applyQuaternion(t){const e=this.x,s=this.y,r=this.z,i=t.x,a=t.y,o=t.z,c=t.w,l=2*(a*r-o*s),d=2*(o*e-i*r),u=2*(i*s-a*e);return this.x=e+c*l+a*u-o*d,this.y=s+c*d+o*l-i*u,this.z=r+c*u+i*d-a*l,this}transformDirection(t){const e=this.x,s=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[4]*s+i[8]*r,this.y=i[1]*e+i[5]*s+i[9]*r,this.z=i[2]*e+i[6]*s+i[10]*r,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(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}max(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}clamp(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}clampScalar(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}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(t,Math.min(e,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}isParallelTo(t){const e=this.dot(t),s=this.length(),r=t.length();return Math.abs(e)===s*r}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(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}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const s=t.x,r=t.y,i=t.z,a=e.x,o=e.y,c=e.z;return this.x=r*c-i*o,this.y=i*a-s*c,this.z=s*o-r*a,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const s=t.dot(this)/e;return this.copy(t).multiplyScalar(s)}projectOnPlane(t){return Xs.copy(this).projectOnVector(t),this.sub(Xs)}reflect(t){return this.sub(Xs.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const s=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,s)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y,r=this.z-t.z;return e*e+s*s+r*r}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),s=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=s,this.z=r,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,s=Math.sqrt(1-e*e);return this.x=s*Math.cos(t),this.y=e,this.z=s*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};at.X_AXIS=Object.freeze(new at(1,0,0)),at.NEGATIVE_X_AXIS=Object.freeze(new at(-1,0,0)),at.Y_AXIS=Object.freeze(new at(0,1,0)),at.NEGATIVE_Y_AXIS=Object.freeze(new at(0,-1,0)),at.Z_AXIS=Object.freeze(new at(0,0,1)),at.NEGATIVE_Z_AXIS=Object.freeze(new at(0,0,-1));let w=at;const Xs=new w,Jr=new Ct,$s=class ma{constructor(t,e,s,r,i,a,o,c,l,d,u,m,p,y,_,x){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!=null&&e!=null&&s!=null&&r!=null&&i!=null&&a!=null&&o!=null&&c!=null&&l!=null&&d!=null&&u!=null&&m!=null&&p!=null&&y!=null&&_!=null&&x!=null&&this.set(t,e,s,r,i,a,o,c,l,d,u,m,p,y,_,x)}set(t,e,s,r,i,a,o,c,l,d,u,m,p,y,_,x){const f=this.elements;return f[0]=t,f[4]=e,f[8]=s,f[12]=r,f[1]=i,f[5]=a,f[9]=o,f[13]=c,f[2]=l,f[6]=d,f[10]=u,f[14]=m,f[3]=p,f[7]=y,f[11]=_,f[15]=x,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new ma().fromArray(this.elements)}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],e[9]=s[9],e[10]=s[10],e[11]=s[11],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],this}copyPosition(t){const e=this.elements,s=t.elements;return e[12]=s[12],e[13]=s[13],e[14]=s[14],this}setFromMatrix3(t){const 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}setFromExtrusionDirection(t){if(Ys.equalPoint3d(t,w.Z_AXIS))this.identity();else{const e=new w(1,0,0);Math.abs(t.x)<1/64&&Math.abs(t.y)<1/64?e.crossVectors(w.Y_AXIS,t).normalize():e.crossVectors(w.Z_AXIS,t).normalize();const s=t.clone().cross(e).normalize();this.set(e.x,e.y,e.z,0,s.x,s.y,s.z,0,t.x,t.y,t.z,0,0,0,0,1)}return this}extractBasis(t,e,s){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this}makeBasis(t,e,s){return this.set(t.x,e.x,s.x,0,t.y,e.y,s.y,0,t.z,e.z,s.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,s=t.elements,r=1/ie.setFromMatrixColumn(t,0).length(),i=1/ie.setFromMatrixColumn(t,1).length(),a=1/ie.setFromMatrixColumn(t,2).length();return e[0]=s[0]*r,e[1]=s[1]*r,e[2]=s[2]*r,e[3]=0,e[4]=s[4]*i,e[5]=s[5]*i,e[6]=s[6]*i,e[7]=0,e[8]=s[8]*a,e[9]=s[9]*a,e[10]=s[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(Ko,t,Zo)}lookAt(t,e,s){const r=this.elements;return ot.subVectors(t,e),ot.lengthSq()===0&&(ot.z=1),ot.normalize(),Ot.crossVectors(s,ot),Ot.lengthSq()===0&&(Math.abs(s.z)===1?ot.x+=1e-4:ot.z+=1e-4,ot.normalize(),Ot.crossVectors(s,ot)),Ot.normalize(),Qe.crossVectors(ot,Ot),r[0]=Ot.x,r[4]=Qe.x,r[8]=ot.x,r[1]=Ot.y,r[5]=Qe.y,r[9]=ot.y,r[2]=Ot.z,r[6]=Qe.z,r[10]=ot.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,r=e.elements,i=this.elements,a=s[0],o=s[4],c=s[8],l=s[12],d=s[1],u=s[5],m=s[9],p=s[13],y=s[2],_=s[6],x=s[10],f=s[14],M=s[3],T=s[7],S=s[11],P=s[15],z=r[0],I=r[4],W=r[8],ht=r[12],vt=r[1],N=r[5],V=r[9],Jt=r[13],te=r[2],ds=r[6],us=r[10],ms=r[14],gs=r[3],ps=r[7],ys=r[11],_s=r[15];return i[0]=a*z+o*vt+c*te+l*gs,i[4]=a*I+o*N+c*ds+l*ps,i[8]=a*W+o*V+c*us+l*ys,i[12]=a*ht+o*Jt+c*ms+l*_s,i[1]=d*z+u*vt+m*te+p*gs,i[5]=d*I+u*N+m*ds+p*ps,i[9]=d*W+u*V+m*us+p*ys,i[13]=d*ht+u*Jt+m*ms+p*_s,i[2]=y*z+_*vt+x*te+f*gs,i[6]=y*I+_*N+x*ds+f*ps,i[10]=y*W+_*V+x*us+f*ys,i[14]=y*ht+_*Jt+x*ms+f*_s,i[3]=M*z+T*vt+S*te+P*gs,i[7]=M*I+T*N+S*ds+P*ps,i[11]=M*W+T*V+S*us+P*ys,i[15]=M*ht+T*Jt+S*ms+P*_s,this}multiplyScalar(t){const 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}determinant(){const t=this.elements,e=t[0],s=t[4],r=t[8],i=t[12],a=t[1],o=t[5],c=t[9],l=t[13],d=t[2],u=t[6],m=t[10],p=t[14],y=t[3],_=t[7],x=t[11],f=t[15];return y*(+i*c*u-r*l*u-i*o*m+s*l*m+r*o*p-s*c*p)+_*(+e*c*p-e*l*m+i*a*m-r*a*p+r*l*d-i*c*d)+x*(+e*l*u-e*o*p-i*a*u+s*a*p+i*o*d-s*l*d)+f*(-r*o*d-e*c*u+e*o*m+r*a*u-s*a*m+s*c*d)}transpose(){const t=this.elements;let 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}setPosition(t,e,s){const r=this.elements;return t instanceof w?(r[12]=t.x,r[13]=t.y,r[14]=t.z):(r[12]=t,r[13]=e,r[14]=s),this}invert(){const t=this.elements,e=t[0],s=t[1],r=t[2],i=t[3],a=t[4],o=t[5],c=t[6],l=t[7],d=t[8],u=t[9],m=t[10],p=t[11],y=t[12],_=t[13],x=t[14],f=t[15],M=u*x*l-_*m*l+_*c*p-o*x*p-u*c*f+o*m*f,T=y*m*l-d*x*l-y*c*p+a*x*p+d*c*f-a*m*f,S=d*_*l-y*u*l+y*o*p-a*_*p-d*o*f+a*u*f,P=y*u*c-d*_*c-y*o*m+a*_*m+d*o*x-a*u*x,z=e*M+s*T+r*S+i*P;if(z===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const I=1/z;return t[0]=M*I,t[1]=(_*m*i-u*x*i-_*r*p+s*x*p+u*r*f-s*m*f)*I,t[2]=(o*x*i-_*c*i+_*r*l-s*x*l-o*r*f+s*c*f)*I,t[3]=(u*c*i-o*m*i-u*r*l+s*m*l+o*r*p-s*c*p)*I,t[4]=T*I,t[5]=(d*x*i-y*m*i+y*r*p-e*x*p-d*r*f+e*m*f)*I,t[6]=(y*c*i-a*x*i-y*r*l+e*x*l+a*r*f-e*c*f)*I,t[7]=(a*m*i-d*c*i+d*r*l-e*m*l-a*r*p+e*c*p)*I,t[8]=S*I,t[9]=(y*u*i-d*_*i-y*s*p+e*_*p+d*s*f-e*u*f)*I,t[10]=(a*_*i-y*o*i+y*s*l-e*_*l-a*s*f+e*o*f)*I,t[11]=(d*o*i-a*u*i-d*s*l+e*u*l+a*s*p-e*o*p)*I,t[12]=P*I,t[13]=(d*_*r-y*u*r+y*s*m-e*_*m-d*s*x+e*u*x)*I,t[14]=(y*o*r-a*_*r-y*s*c+e*_*c+a*s*x-e*o*x)*I,t[15]=(a*u*r-d*o*r+d*s*c-e*u*c-a*s*m+e*o*m)*I,this}scale(t){const e=this.elements,s=t.x,r=t.y,i=t.z;return e[0]*=s,e[4]*=r,e[8]*=i,e[1]*=s,e[5]*=r,e[9]*=i,e[2]*=s,e[6]*=r,e[10]*=i,e[3]*=s,e[7]*=r,e[11]*=i,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],s=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,s,r))}makeTranslation(t,e,s){return t instanceof w?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,s,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),s=Math.sin(t);return this.set(1,0,0,0,0,e,-s,0,0,s,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,0,s,0,0,1,0,0,-s,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,0,s,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const s=Math.cos(e),r=Math.sin(e),i=1-s,a=t.x,o=t.y,c=t.z,l=i*a,d=i*o;return this.set(l*a+s,l*o-r*c,l*c+r*o,0,l*o+r*c,d*o+s,d*c-r*a,0,l*c-r*o,d*c+r*a,i*c*c+s,0,0,0,0,1),this}makeScale(t,e,s){return this.set(t,0,0,0,0,e,0,0,0,0,s,0,0,0,0,1),this}makeShear(t,e,s,r,i,a){return this.set(1,s,i,0,t,1,a,0,e,r,1,0,0,0,0,1),this}compose(t,e,s){const r=this.elements,i=e.x,a=e.y,o=e.z,c=e.w,l=i+i,d=a+a,u=o+o,m=i*l,p=i*d,y=i*u,_=a*d,x=a*u,f=o*u,M=c*l,T=c*d,S=c*u,P=s.x,z=s.y,I=s.z;return r[0]=(1-(_+f))*P,r[1]=(p+S)*P,r[2]=(y-T)*P,r[3]=0,r[4]=(p-S)*z,r[5]=(1-(m+f))*z,r[6]=(x+M)*z,r[7]=0,r[8]=(y+T)*I,r[9]=(x-M)*I,r[10]=(1-(m+_))*I,r[11]=0,r[12]=t.x,r[13]=t.y,r[14]=t.z,r[15]=1,this}decompose(t,e,s){const r=this.elements;let i=ie.set(r[0],r[1],r[2]).length();const a=ie.set(r[4],r[5],r[6]).length(),o=ie.set(r[8],r[9],r[10]).length();this.determinant()<0&&(i=-i),t.x=r[12],t.y=r[13],t.z=r[14],ut.copy(this);const c=1/i,l=1/a,d=1/o;return ut.elements[0]*=c,ut.elements[1]*=c,ut.elements[2]*=c,ut.elements[4]*=l,ut.elements[5]*=l,ut.elements[6]*=l,ut.elements[8]*=d,ut.elements[9]*=d,ut.elements[10]*=d,e.setFromRotationMatrix(ut),s.x=i,s.y=a,s.z=o,this}equals(t){const e=this.elements,s=t.elements;for(let r=0;r<16;r++)if(e[r]!==s[r])return!1;return!0}fromArray(t,e=0){for(let s=0;s<16;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t[e+9]=s[9],t[e+10]=s[10],t[e+11]=s[11],t[e+12]=s[12],t[e+13]=s[13],t[e+14]=s[14],t[e+15]=s[15],t}};$s.IDENTITY=Object.freeze(new $s);let Yt=$s;const ie=new w,ut=new Yt,Ko=new w(0,0,0),Zo=new w(1,1,1),Ot=new w,Qe=new w,ot=new w;class O{constructor(t=void 0,e=void 0){this.min=t==null?new w(1/0,1/0,1/0):new w(t.x,t.y,t.z),this.max=e==null?new w(-1/0,-1/0,-1/0):new w(e.x,e.y,e.z)}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e+=3)this.expandByPoint(Ks.fromArray(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const s=Ks.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(s),this.max.copy(t).add(s),this}clone(){return new O().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new w(0,0,0):new w(0,0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new w(0,0,0):new w(0,0,0).subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(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)}containsBox(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}getParameter(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))}intersectsBox(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)}intersectsPlane(t){let e,s;return t.normal.x>0?(e=t.normal.x*this.min.x,s=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,s=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,s+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,s+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,s+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,s+=t.normal.z*this.min.z),e<=-t.constant&&s>=-t.constant}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Ks).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(St[0].set(this.min.x,this.min.y,this.min.z).applyMatrix3d(t),St[1].set(this.min.x,this.min.y,this.max.z).applyMatrix3d(t),St[2].set(this.min.x,this.max.y,this.min.z).applyMatrix3d(t),St[3].set(this.min.x,this.max.y,this.max.z).applyMatrix3d(t),St[4].set(this.max.x,this.min.y,this.min.z).applyMatrix3d(t),St[5].set(this.max.x,this.min.y,this.max.z).applyMatrix3d(t),St[6].set(this.max.x,this.max.y,this.min.z).applyMatrix3d(t),St[7].set(this.max.x,this.max.y,this.max.z).applyMatrix3d(t),this.setFromPoints(St),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const St=[new w,new w,new w,new w,new w,new w,new w,new w],Ks=new w,ti=new B;class K{constructor(t=void 0,e=void 0){this.min=t==null?new B(1/0,1/0):new B(t.x,t.y),this.max=e==null?new B(-1/0,-1/0):new B(e.x,e.y)}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const s=ti.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(s),this.max.copy(t).add(s),this}clone(){return new K().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new B(0,0):new B(0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new B(0,0):new B(0,0).subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(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}getParameter(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))}intersectsBox(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)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,ti).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const ei=new w,Qo=new w,Jo=new Ke;class Le{constructor(t=new w(1,0,0),e=0){this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,s,r){return this.normal.set(t,e,s),this.constant=r,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,s){const r=ei.subVectors(s,e).cross(Qo.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(r,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectsBox(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const s=e||Jo.getNormalMatrix(t),r=this.coplanarPoint(ei).applyMatrix3d(t),i=this.normal.applyMatrix3(s).normalize();return this.constant=-r.dot(i),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new Le().copy(this)}}class L extends B{static pointArrayToNumberArray(t){const e=new Array(t.length*2);return t.forEach((s,r)=>{s.toArray(e,r*2)}),e}}class b extends w{static pointArrayToNumberArray(t,e=!0){const s=e?3:2,r=new Array(t.length*s);return t.forEach((i,a)=>{i.toArray(r,a*s)}),r}}const si=new Yt,ni=new Ct,ri=class un{constructor(t=0,e=0,s=0,r=un.DEFAULT_ORDER){this._x=t,this._y=e,this._z=s,this._order=r}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,s,r=this._order){return this._x=t,this._y=e,this._z=s,this._order=r,this._onChangeCallback(),this}clone(){return new un(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,s=!0){const r=t.elements,i=r[0],a=r[4],o=r[8],c=r[1],l=r[5],d=r[9],u=r[2],m=r[6],p=r[10];switch(e){case"XYZ":this._y=Math.asin(Tt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-d,p),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(m,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Tt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,i),this._z=0);break;case"ZXY":this._x=Math.asin(Tt(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-u,p),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,i));break;case"ZYX":this._y=Math.asin(-Tt(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(m,p),this._z=Math.atan2(c,i)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(Tt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,l),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-Tt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(m,l),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-d,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,s===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,s=!0){return si.makeRotationFromQuaternion(t),this.setFromRotationMatrix(si,e,s)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return ni.setFromEuler(this),this.setFromQuaternion(ni,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};ri.DEFAULT_ORDER="XYZ";let ii=ri;class ai{constructor(){this._boundingBoxNeedsUpdate=!1}get boundingBoxNeedUpdate(){return this._boundingBoxNeedsUpdate}}class Zs extends ai{translate(t){return this.transform(new Ke().makeTranslation(t.x,t.y))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}class Je extends Zs{constructor(){super(),this._loops=[]}add(t){this._loops.push(t),this._boundingBoxNeedsUpdate=!0}get loops(){return this._loops}get outter(){if(this._loops.length>0)return this._loops[0]}calculateBoundingBox(){const t=this.outter;return t?t.box:new K}transform(t){return this._boundingBoxNeedsUpdate=!0,this}getPoints(t){const e=[];for(let s=0;s<this.loops.length;++s){const r=this.loops[s].getPoints(t);e.push(r)}return e}buildHierarchy(){var t;const e=this.getPoints(100),s=this.calculateBoundaryBoxes(e),r=this.sortBoundaryBoxesByAreas(s),i=new Map,a=r.length;for(let c=0;c<a;c++)i.set(r[c],{index:r[c],children:[]});const o={index:-1,children:[]};for(let c=0;c<a;c++){const l=r[c],d=e[l],u=s[l];let m=c+1;for(;m<a;m++){const p=r[m],y=e[p];if(s[p].containsBox(u)&&Xr.isPointInPolygon(d[C.randInt(0,d.length-1)],y)){(t=i.get(p))==null||t.children.push(i.get(l));break}}m===a&&o.children.push(i.get(l))}return o}calculateBoundaryBoxes(t){const e=[];return t.forEach(s=>{e.push(new K().setFromPoints(s))}),e}sortBoundaryBoxesByAreas(t){const e=[];t.forEach((r,i)=>{const a=r.size,o=a.width*a.height;e.push({area:o,index:i})}),e.sort((r,i)=>r.area-i.area);const s=[];return e.forEach(r=>{s.push(r.index)}),s}}class ae extends Zs{constructor(){super(),this.arcLengthDivisions=100}get startPoint(){return this.getPoint(0)}get endPoint(){return this.getPoint(1)}get length(){return this.getLength()}getPoint(t){throw new Error("AcGeCurve2d: .getPoint() not implemented.")}getPointAt(t){const e=this.getUtoTmapping(t);return this.getPoint(e)}getPoints(t=5){const e=[];for(let s=0;s<=t;s++)e.push(this.getPoint(s/t));return e}getSpacedPoints(t=5){const e=[];for(let s=0;s<=t;s++)e.push(this.getPointAt(s/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){const e=[];let s,r=this.getPoint(0),i=0;e.push(0);for(let a=1;a<=t;a++)s=this.getPoint(a/t),i+=s.distanceTo(r),e.push(i),r=s;return e}getUtoTmapping(t,e){const s=this.getLengths();let r=0;const i=s.length;let a;e?a=e:a=t*s[i-1];let o=0,c=i-1,l;for(;o<=c;)if(r=Math.floor(o+(c-o)/2),l=s[r]-a,l<0)o=r+1;else if(l>0)c=r-1;else{c=r;break}if(r=c,s[r]===a)return r/(i-1);const d=s[r],u=s[r+1]-d,m=(a-d)/u;return(r+m)/(i-1)}getTangent(t){let e=t-1e-4,s=t+1e-4;e<0&&(e=0),s>1&&(s=1);const r=this.getPoint(e),i=this.getPoint(s),a=new L;return a.copy(i).sub(r).normalize(),a}getTangentAt(t){const e=this.getUtoTmapping(t);return this.getTangent(e)}}class oe extends ae{constructor(t,e,s,r,i){super();const a=+(t!==void 0)+ +(e!==void 0)+ +(s!==void 0)+ +(r!==void 0)+ +(i!==void 0);if(a==3)typeof t=="object"&&typeof e=="object"&&typeof s=="object"?this.createByThreePoints(t,e,s):this.createByStartEndPointsAndBulge(t,e,s);else if(a==5){const o=t;this.center=new L(o.x,o.y),this.radius=e,this.startAngle=s,this.endAngle=r,this.clockwise=i}else throw et.ILLEGAL_PARAMETERS}createByThreePoints(t,e,s){const r=(I,W)=>({x:(I.x+W.x)/2,y:(I.y+W.y)/2}),i=(I,W)=>(W.y-I.y)/(W.x-I.x),a=I=>-1/I,o=r(t,e),c=r(e,s),l=i(t,e),d=i(e,s),u=a(l),m=a(d),p=(I,W,ht,vt)=>{const N=(vt-W)/(I-ht),V=I*N+W;return{x:N,y:V}},y=o.y-u*o.x,_=c.y-m*c.x,x=p(u,y,m,_),f=Math.sqrt(Math.pow(t.x-x.x,2)+Math.pow(t.y-x.y,2)),M=(I,W)=>Math.atan2(I.y-W.y,I.x-W.x),T=M(t,x),S=M(e,x),P=M(s,x),z=P>T&&P<S||T>P&&T<S||S>P&&S<T;this.center=x,this.radius=f,this.startAngle=T,this.endAngle=P,this.clockwise=!z}createByStartEndPointsAndBulge(t,e,s){let r,i,a;s<0?(r=Math.atan(-s)*4,i=new B(t),a=new B(e)):(r=Math.atan(s)*4,i=new B(e),a=new B(t));const o=new B().subVectors(a,i),c=o.length(),l=new B().addVectors(i,o.multiplyScalar(.5)),d=Math.abs(c/2/Math.tan(r/2)),u=o.normalize();let m;if(r<Math.PI){const p=new B(u.x*Math.cos(Math.PI/2)-u.y*Math.sin(Math.PI/2),u.y*Math.cos(Math.PI/2)+u.x*Math.sin(Math.PI/2));m=l.add(p.multiplyScalar(-d))}else{const p=new B(u.x*Math.cos(Math.PI/2)-u.y*Math.sin(Math.PI/2),u.y*Math.cos(Math.PI/2)+u.x*Math.sin(Math.PI/2));m=l.add(p.multiplyScalar(d))}s<0?(this.startAngle=Math.atan2(i.y-m.y,i.x-m.x),this.endAngle=Math.atan2(a.y-m.y,a.x-m.x)):(this.startAngle=Math.atan2(a.y-m.y,a.x-m.x),this.endAngle=Math.atan2(i.y-m.y,i.x-m.x)),this.clockwise=s<0,this.center=m,this.radius=a.sub(m).length()}get center(){return this._center}set center(t){this._center=new L(t.x,t.y),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=C.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==H?t:C.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return this.clockwise?C.normalizeAngle(this.startAngle-this.endAngle):C.normalizeAngle(this.endAngle-this.startAngle)}get clockwise(){return this._clockwise}set clockwise(t){this._clockwise=t,this._boundingBoxNeedsUpdate=!0}get startPoint(){return this.getPointAtAngle(this.startAngle)}get endPoint(){return this.getPointAtAngle(this.endAngle)}get midPoint(){const t=C.normalizeAngle((this.startAngle+this.endAngle)/2);return this.getPointAtAngle(t)}get closed(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0}calculateBoundingBox(){const t=[this.startPoint,this.endPoint],e=[0,Math.PI/2,Math.PI,3*Math.PI/2];for(const i of e)C.isBetweenAngle(i,this.startAngle,this.endAngle,this.clockwise)&&t.push(this.getPointAtAngle(i));const s=t.map(i=>i.x),r=t.map(i=>i.y);return new K(new L(Math.min(...s),Math.min(...r)),new L(Math.max(...s),Math.max(...r)))}get length(){return Math.abs(this.deltaAngle*this.radius)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}clone(){return new oe(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.clockwise)}getPointAtAngle(t){const e=this.center.x+this.radius*Math.cos(t),s=this.center.y+this.radius*Math.sin(t);return new L(e,s)}getPoints(t=100){const e=[];let s=this.deltaAngle,r=this.startAngle;if(this.closed&&(s=H,r=0),this.clockwise)for(let i=0;i<=t;i++){const a=r-s*(i/t),o=this.getPointAtAngle(a);e.push(new L(o.x,o.y))}else for(let i=0;i<=t;i++){const a=r+s*(i/t),o=this.getPointAtAngle(a);e.push(new L(o.x,o.y))}return e}}class th extends ai{translate(t){return this.transform(new Yt().makeTranslation(t.x,t.y,t.z))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}class ke extends th{}class Nt extends ke{constructor(t,e){super(),this._start=new b(t),this._end=new b(e)}get startPoint(){return this._start}set startPoint(t){this._start.copy(t),this._boundingBoxNeedsUpdate=!0}get endPoint(){return this._end}set endPoint(t){this._end.copy(t),this._boundingBoxNeedsUpdate=!0}get direction(){return new w().subVectors(this.endPoint,this.startPoint).normalize()}get midPoint(){return new b((this._start.x+this._end.x)/2,(this._start.y+this._end.y)/2,(this._start.z+this._end.z)/2)}get length(){return this.startPoint.distanceTo(this.endPoint)}isPointOnLine(t){return this.project(t).distanceTo(t)<1e-6}at(t,e){return this.delta(e).multiplyScalar(t).add(this._start)}atLength(t,e=!1){if(e){const s=this.delta(qt).normalize();return new b(this._start).addScaledVector(s,t)}else{const s=this.delta(qt).normalize();return new b(this._end).addScaledVector(s,t)}}extend(t,e=!1){if(e){const s=qt.subVectors(this._start,this._end).normalize();this._start=new b(this._start).addScaledVector(s,t)}else{const s=this.delta(qt).normalize();this._end=new b(this._end).addScaledVector(s,t)}return this._boundingBoxNeedsUpdate=!0,this}closestPointToPointParameter(t,e){oi.subVectors(t,this._start),ts.subVectors(this.endPoint,this.startPoint);const s=ts.dot(ts);let r=ts.dot(oi)/s;return e&&(r=C.clamp(r,0,1)),r}closestPointToPoint(t,e,s){const r=this.closestPointToPointParameter(t,e);return this.delta(s).multiplyScalar(r).add(this._start)}delta(t){return t.subVectors(this._end,this._start)}distanceSq(){return this._start.distanceToSquared(this._end)}distance(){return this._start.distanceTo(this._end)}project(t){const e=this.direction,s=qt.subVectors(t,this.startPoint).dot(e);return new b().copy(e).multiplyScalar(s).add(this.startPoint)}perpPoint(t){const e=this.direction,s=this.startPoint,r=qt.subVectors(t,s).dot(e),i=qt.copy(e).multiplyScalar(r);return new b().addVectors(s,i)}calculateBoundingBox(){const t=new b(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y),Math.min(this._start.z,this._end.z)),e=new b(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y),Math.max(this._start.z,this._end.z));return new O(t,e)}transform(t){return this._start.applyMatrix3d(t),this._end.applyMatrix3d(t),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new Nt(this._start.clone(),this._end.clone())}}const qt=new w,oi=new w,ts=new w;class Xt extends ke{static computeCenterPoint(t,e,s){const r=new w().addVectors(t,e).multiplyScalar(.5),i=new w().addVectors(t,s).multiplyScalar(.5),a=new w().subVectors(e,t),o=new w().subVectors(s,t),c=new w().crossVectors(a,o).normalize();if(c.lengthSq()===0)return console.error("Points are collinear and cannot form a valid arc."),null;const l=new w().crossVectors(a,c).normalize(),d=new w().crossVectors(o,c).normalize(),u=l.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),m=d.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),p=new Nt(r,r.clone().add(u)),y=new Nt(i,i.clone().add(m)),_=new w;return p.closestPointToPoint(y.startPoint,!0,_)?_:(console.error("Cannot find a valid center for the arc."),null)}static createByThreePoints(t,e,s){const r=Xt.computeCenterPoint(t,e,s);if(r){const i=r.distanceTo(t),a=new w().subVectors(t,r),o=new w().subVectors(e,r),c=Math.atan2(a.y,a.x),l=Math.atan2(o.y,o.x);return new Xt(r,i,c,l,w.Z_AXIS)}}constructor(t,e,s,r,i,a=w.X_AXIS){super(),this.center=t,this.radius=e,this.startAngle=s,this.endAngle=r,this.normal=i,this.refVec=a,(r-s)%H==0?(this.startAngle=0,this.endAngle=H):(this.startAngle=s,this.endAngle=r)}get center(){return this._center}set center(t){this._center=new b(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){if(t<0)throw et.ILLEGAL_PARAMETERS;this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=C.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==H?t:C.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return C.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}get clockwise(){return this.deltaAngle<=0}get normal(){return this._normal}set normal(t){this._normal=new w(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get refVec(){return this._refVec}set refVec(t){this._refVec=new w(t.x,t.y,t.z),this._refVec.normalize(),this._boundingBoxNeedsUpdate=!0}get startPoint(){return this.getPointAtAngle(this._startAngle)}get endPoint(){return this.getPointAtAngle(this._endAngle)}get length(){return Math.abs(this.deltaAngle*this.radius)}calculateBoundingBox(){const t=[this.startAngle,this.endAngle];for(let c=0;c<2*Math.PI;c+=Math.PI/2)C.isBetweenAngle(c,this.startAngle,this.endAngle)&&t.push(c);let e=1/0,s=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0;for(const c of t){const l=this.getPointAtAngle(c);l.x<e&&(e=l.x),l.y<s&&(s=l.y),l.z<r&&(r=l.z),l.x>i&&(i=l.x),l.y>a&&(a=l.y),l.z>o&&(o=l.z)}return new O({x:e,y:s,z:r},{x:i,y:a,z:o})}get closed(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0}getPoints(t){const e=[];let s=this.deltaAngle,r=this.startAngle;this.closed&&(s=H,r=0);for(let i=0;i<=t;i++){const a=r+s*(i/t),o=this.getPointAtAngle(a);e.push(o)}return e}transform(t){const e=Qs.copy(this.refVec).applyAxisAngle(this.normal,this.startAngle).multiplyScalar(this.radius),s=Qs.copy(this.refVec).applyAxisAngle(this.normal,this.endAngle).multiplyScalar(this.radius);return this.center.applyMatrix3d(t),e.applyMatrix3d(t),s.applyMatrix3d(t),this.normal.applyMatrix3d(t).normalize(),this.refVec.applyMatrix3d(t).normalize(),this.startAngle=this.getAngle(e),this.endAngle=this.getAngle(s),this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.radius=t.radius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.normal=t.normal,this.refVec=t.refVec,this._boundingBoxNeedsUpdate=!0,this}clone(){return new Xt(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)}getAngle(t){return t.sub(this.center),Math.atan2(t.dot(Qs.crossVectors(this.refVec,this.normal)),t.dot(this.refVec))}getPointAtAngle(t){const e=this.normal,s=this.refVec,r={x:e.y*s.z-e.z*s.y,y:e.z*s.x-e.x*s.z,z:e.x*s.y-e.y*s.x},i=this.center,a=this.radius;return new b(i.x+a*(s.x*Math.cos(t)+r.x*Math.sin(t)),i.y+a*(s.y*Math.cos(t)+r.y*Math.sin(t)),i.z+a*(s.z*Math.cos(t)+r.z*Math.sin(t)))}get plane(){const t=new w(this.center).distanceTo(Us);return new Le(this.normal,t)}}const Qs=new w;class es extends ae{constructor(t,e,s,r=0,i=H,a=!1,o=0){super(),this.center=t,this.majorAxisRadius=e,this.minorAxisRadius=s,(i-r)%H==0?(this.startAngle=0,this.endAngle=H):(this.startAngle=r,this.endAngle=i),this.clockwise=a,this.rotation=o}get center(){return this._center}set center(t){this._center=new b(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw et.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw et.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=C.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==H?t:C.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get clockwise(){return this._clockwise}set clockwise(t){this._clockwise=t,this._boundingBoxNeedsUpdate=!0}get rotation(){return this._rotation}set rotation(t){this._rotation=t,this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return C.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}calculateBoundingBox(){let t=1/0,e=1/0,s=-1/0,r=-1/0;for(let i=0;i<=100;i++){const a=this.getPoint(i/100);t=Math.min(t,a.x),e=Math.min(e,a.y),s=Math.max(s,a.x),r=Math.max(r,a.y)}return new K({x:t,y:e},{x:s,y:r})}get closed(){return this.deltaAngle==0}getPoint(t){const e=Math.PI*2;let s=this.endAngle-this.startAngle;const r=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=e;for(;s>e;)s-=e;s<Number.EPSILON&&(r?s=0:s=e),this.clockwise===!0&&!r&&(s===e?s=-e:s=s-e);const i=this.startAngle+t*s;let a=this.center.x+this.majorAxisRadius*Math.cos(i),o=this.center.y+this.minorAxisRadius*Math.sin(i);if(this.rotation!==0){const c=Math.cos(this.rotation),l=Math.sin(this.rotation),d=a-this.center.x,u=o-this.center.y;a=d*c-u*l+this.center.x,o=d*l+u*c+this.center.y}return new L(a,o)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.majorAxisRadius=t.majorAxisRadius,this.minorAxisRadius=t.minorAxisRadius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.clockwise=t.clockwise,this.rotation=t.rotation,this}clone(){return new es(this.center,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle,this.clockwise,this.rotation)}}class ss extends ke{constructor(t,e,s,r,i,a=0,o=H){super(),this.center=t,this.normal=e,this.majorAxis=s,this.majorAxisRadius=r,this.minorAxisRadius=i;const c=Math.abs(o-a);Math.abs(c-H)<1e-10||Math.abs(c-2*H)<1e-10?(this.startAngle=0,this.endAngle=H):(this.startAngle=a,this.endAngle=o)}get center(){return this._center}set center(t){this._center=new b(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw et.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw et.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=C.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==H?t:C.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){const t=this.endAngle-this.startAngle;return Math.abs(t-H)<1e-10?H:C.normalizeAngle(t)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}get clockwise(){return this.deltaAngle<=0}get normal(){return this._normal}set normal(t){this._normal=new w(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get majorAxis(){return this._majorAxis}set majorAxis(t){this._majorAxis=new w(t.x,t.y,t.z),this._majorAxis.normalize(),this._boundingBoxNeedsUpdate=!0}get minorAxis(){return new w().crossVectors(this.normal,this.majorAxis).normalize()}get startPoint(){return this.getPointAtAngle(this._startAngle)}get endPoint(){return this.getPointAtAngle(this._endAngle)}get isCircular(){return Ws.equal(this.majorAxisRadius,this.minorAxisRadius)}get length(){if(this.isCircular)return this.majorAxisRadius*Math.abs(this.deltaAngle);const t=1e3,e=this.deltaAngle/t;let s=0,r=this.getPointAtAngle(this.startAngle);for(let i=1;i<=t;i++){const a=this.startAngle+i*e,o=this.getPointAtAngle(a),c=o.x-r.x,l=o.y-r.y,d=o.z-r.z;s+=Math.sqrt(c*c+l*l+d*d),r=o}return s}calculateBoundingBox(){if(this.majorAxis.equals(w.X_AXIS)||this.majorAxis.equals(w.Y_AXIS)||this.majorAxis.isParallelTo(w.X_AXIS)||this.majorAxis.isParallelTo(w.Y_AXIS)){const t=[this.startAngle,this.endAngle];for(let c=0;c<2*Math.PI;c+=Math.PI/2)C.isBetweenAngle(c,this.startAngle,this.endAngle)&&t.push(c);let e=1/0,s=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0;for(const c of t){const l=this.getPointAtAngle(c);l.x<e&&(e=l.x),l.y<s&&(s=l.y),l.z<r&&(r=l.z),l.x>i&&(i=l.x),l.y>a&&(a=l.y),l.z>o&&(o=l.z)}return new O({x:e,y:s,z:r},{x:i,y:a,z:o})}else{let t=1/0,e=1/0,s=1/0,r=-1/0,i=-1/0,a=-1/0;for(let o=0;o<=100;o++){const c=this.startAngle+this.deltaAngle*(o/100),l=this.getPointAtAngle(c);t=Math.min(t,l.x),e=Math.min(e,l.y),s=Math.min(s,l.z),r=Math.max(r,l.x),i=Math.max(i,l.y),a=Math.max(a,l.z)}return new O({x:t,y:e,z:s},{x:r,y:i,z:a})}}get closed(){return this.deltaAngle==0}getPoints(t=100){const e=[];let s=this.deltaAngle,r=this.startAngle;this.closed&&(s=H,r=0);for(let i=0;i<=t;i++){const a=r+s*(i/t),o=this.getPointAtAngle(a);e.push(o)}return e}getPointAtAngle(t){const e=Math.cos(t),s=Math.sin(t),r=this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(s),i=this.majorAxis.clone().multiplyScalar(e*this.majorAxisRadius).add(r);return new b(this.center.x+i.x,this.center.y+i.y,this.center.z+i.z)}contains(t){const e=new w(t).sub(this.center),s=e.dot(this.majorAxis),r=e.dot(this.minorAxis),i=s/this.majorAxisRadius,a=r/this.minorAxisRadius;return i*i+a*a<=1}transform(t){return this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.normal=t.normal,this.majorAxis=t.majorAxis,this.majorAxisRadius=t.majorAxisRadius,this.minorAxisRadius=t.minorAxisRadius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this._boundingBoxNeedsUpdate=!0,this}clone(){return new ss(this.center,this.normal,this.majorAxis,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle)}get plane(){const t=new w(this.center).distanceTo(Us);return new Le(this.normal,t)}}class Ce extends ae{constructor(t=null,e=!1){super(),this._vertices=t||new Array,this._closed=e}get numberOfVertices(){return this._vertices.length}get closed(){return this._closed}get startPoint(){if(this.numberOfVertices>0){const t=this._vertices[0];return new L(t.x,t.y)}throw new Error("Start point does not exist in an empty polyline.")}get endPoint(){const t=this.numberOfVertices;if(t>0)if(this.closed){const e=this._vertices[0];return new L(e.x,e.y)}else{const e=this._vertices[t-1];return new L(e.x,e.y)}throw new Error("End point does not exist in an empty polyline.")}get length(){let t=0;const e=this._vertices.length;for(let s=0;s<e;++s){const r=this._vertices[s];let i=null;if(s<e-1?i=this._vertices[s+1]:s==e-1&&this.closed&&(i=this._vertices[0]),i)if(r.bulge){const a=new oe(r,i,r.bulge);t+=a.length}else t+=new L(r.x,r.y).distanceTo(i)}return t}set closed(t){this._closed=t,this._boundingBoxNeedsUpdate=!0}addVertexAt(t,e){t<=0?this._vertices.unshift(e):this._vertices.splice(t,0,e),this._boundingBoxNeedsUpdate=!0}getPointAt(t){const e=this._vertices[t];return new L(e.x,e.y)}calculateBoundingBox(){const t=this.getPoints(100);return new K().setFromPoints(t)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}getPoints3d(t,e){const s=[];return this.getPoints(t).forEach(r=>s.push(new b().set(r.x,r.y,e))),s}getPoints(t){const e=[],s=this._vertices.length;for(let r=0;r<s;++r){const i=this._vertices[r];if(i.bulge){let a=null;if(r<s-1?a=this._vertices[r+1]:r==s-1&&this.closed&&(a=this._vertices[0]),a){const o=new oe(i,a,i.bulge).getPoints(t),c=o.length;for(let l=0;l<c;++l){const d=o[l];e.push(new L(d.x,d.y))}}}else e.push(new L(i.x,i.y)),r==s-1&&this.closed&&e.push(e[0])}return e}}class ns extends ae{constructor(t,e){super(),this._start=new L(t),this._end=new L(e)}get startPoint(){return this._start}set startPoint(t){this._start.copy(t),this._boundingBoxNeedsUpdate=!0}get endPoint(){return this._end}set endPoint(t){this._end.copy(t),this._boundingBoxNeedsUpdate=!0}getPoints(){return[this.startPoint,this.endPoint]}get length(){return this.startPoint.distanceTo(this.endPoint)}calculateBoundingBox(){const t=new L(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y)),e=new L(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y));return new K(t,e)}transform(t){return this._start.applyMatrix2d(t),this._end.applyMatrix2d(t),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new ns(this._start.clone(),this._end.clone())}}class hi extends ae{constructor(t=[]){super(),this._curves=t}get curves(){return this._curves}add(t){this._curves.push(t),this._boundingBoxNeedsUpdate=!0}get numberOfEdges(){return this._curves.length}get startPoint(){if(this._curves.length>0){const t=this._curves[0].startPoint;return new L(t.x,t.y)}throw new Error("Start point does not exist in an empty loop.")}get endPoint(){return this.startPoint}get length(){let t=0;return this._curves.forEach(e=>{t+=e.length}),t}calculateBoundingBox(){const t=this.getPoints(100),e=new K;return e.setFromPoints(t),e}transform(t){return this._boundingBoxNeedsUpdate=!0,this}get closed(){return!0}getPoints(t){const e=[];return this.curves.forEach(s=>{s.getPoints(t).forEach(r=>{e.push(new L(r.x,r.y))})}),e}}class Js{constructor(){this.c0=0,this.c1=0,this.c2=0,this.c3=0}init(t,e,s,r){this.c0=t,this.c1=s,this.c2=-3*t+3*e-2*s-r,this.c3=2*t-2*e+s+r}initCatmullRom(t,e,s,r,i){this.init(e,s,i*(s-t),i*(r-e))}initNonuniformCatmullRom(t,e,s,r,i,a,o){let c=(e-t)/i-(s-t)/(i+a)+(s-e)/a,l=(s-e)/a-(r-e)/(a+o)+(r-s)/o;c*=a,l*=a,this.init(e,s,c,l)}calc(t){const e=t*t,s=e*t;return this.c0+this.c1*t+this.c2*e+this.c3*s}}class li extends ke{constructor(t=[],e=!1,s="centripetal",r=.5){super(),this.isCatmullRomCurve3d=!0,this.type="CatmullRomCurve3d",this._tmp=new w,this._px=new Js,this._py=new Js,this._pz=new Js,this._points=t.map(i=>new b(i)),this._closed=e,this._curveType=s,this._tension=r}get points(){return this._points}get closed(){return this._closed}get curveType(){return this._curveType}get tension(){return this._tension}get startPoint(){return this._points.length>0?this._points[0]:new b}get endPoint(){return this._points.length>0?this._points[this._points.length-1]:new b}get length(){if(this._points.length<2)return 0;let t=0;for(let e=1;e<this._points.length;e++)t+=this._points[e-1].distanceTo(this._points[e]);return this._closed&&this._points.length>2&&(t+=this._points[this._points.length-1].distanceTo(this._points[0])),t}getPoint(t,e=new b){const s=e,r=this._points,i=r.length;if(i===0)return s.set(0,0,0);if(i===1)return s.copy(r[0]);const a=(i-(this._closed?0:1))*t;let o=Math.floor(a),c=a-o;this._closed?o+=o>0?0:(Math.floor(Math.abs(o)/i)+1)*i:c===0&&o===i-1&&(o=i-2,c=1);let l,d;this._closed||o>0?l=r[(o-1)%i]:(this._tmp.subVectors(r[0],r[1]).add(r[0]),l=new b(this._tmp.x,this._tmp.y,this._tmp.z));const u=r[o%i],m=r[(o+1)%i];if(this._closed||o+2<i?d=r[(o+2)%i]:(this._tmp.subVectors(r[i-1],r[i-2]).add(r[i-1]),d=new b(this._tmp.x,this._tmp.y,this._tmp.z)),this._curveType==="centripetal"||this._curveType==="chordal"){const p=this._curveType==="chordal"?.5:.25;let y=Math.pow(l.distanceToSquared(u),p),_=Math.pow(u.distanceToSquared(m),p),x=Math.pow(m.distanceToSquared(d),p);_<1e-4&&(_=1),y<1e-4&&(y=_),x<1e-4&&(x=_),this._px.initNonuniformCatmullRom(l.x,u.x,m.x,d.x,y,_,x),this._py.initNonuniformCatmullRom(l.y,u.y,m.y,d.y,y,_,x),this._pz.initNonuniformCatmullRom(l.z,u.z,m.z,d.z,y,_,x)}else this._curveType==="catmullrom"&&(this._px.initCatmullRom(l.x,u.x,m.x,d.x,this._tension),this._py.initCatmullRom(l.y,u.y,m.y,d.y,this._tension),this._pz.initCatmullRom(l.z,u.z,m.z,d.z,this._tension));return s.set(this._px.calc(c),this._py.calc(c),this._pz.calc(c)),s}getPoints(t){const e=[];for(let s=0;s<=t;s++)e.push(this.getPoint(s/t));return e}setPoints(t){this._points=t.map(e=>new b(e)),this._boundingBoxNeedsUpdate=!0}setClosed(t){this._closed!==t&&(this._closed=t,this._boundingBoxNeedsUpdate=!0)}setCurveType(t){this._curveType=t}setTension(t){this._tension=t}transform(t){return this._points=this._points.map(e=>{const s=new b;return s.copy(e),s.applyMatrix3d(t),s}),this._boundingBoxNeedsUpdate=!0,this}calculateBoundingBox(){if(this._points.length===0)return new O;const t=new O;return this._points.forEach(e=>{t.expandByPoint(e)}),t}}class mt{constructor(t,e,s,r){this._degree=t,this._knots=[...e],this._controlPoints=s.map(i=>({x:i.x,y:i.y,z:i.z})),this._weights=r?[...r]:new Array(s.length).fill(1)}degree(){return this._degree}knots(){return[...this._knots]}controlPoints(){return this._controlPoints.map(t=>({x:t.x,y:t.y,z:t.z}))}weights(){return[...this._weights]}point(t){const e=this._controlPoints.map(s=>[s.x,s.y,s.z]);return ve(t,this._degree,this._knots,e,this._weights)}length(){const t=this._controlPoints.map(e=>[e.x,e.y,e.z]);return Qr(this._degree,this._knots,t,this._weights)}static byKnotsControlPointsWeights(t,e,s,r){return new mt(t,e,s,r)}static byPoints(t,e,s="Uniform"){let r;switch(s){case"Chord":r=Kr(e,t);break;case"SqrtChord":r=Zr(e,t);break;case"Uniform":default:r=$r(e,t.length);break}const i=t.map(o=>({x:o[0],y:o[1],z:o[2]})),a=new Array(i.length).fill(1);return new mt(e,r,i,a)}getParameterRange(){const t=this._knots[this._degree],e=this._knots[this._knots.length-this._degree-1];return{start:t,end:e}}getPoints(t){const e=[],{start:s,end:r}=this.getParameterRange();for(let i=0;i<=t;i++){const a=s+(r-s)*(i/t);e.push(this.point(a))}return e}isClosed(t=1e-6){const{start:e,end:s}=this.getParameterRange(),r=this.point(e),i=this.point(s),a=r[0]-i[0],o=r[1]-i[1],c=r[2]-i[2];return Math.sqrt(a*a+o*o+c*c)<t}static createClosedCurve(t,e,s="Chord"){if(t.length<4)throw new Error("At least 4 points are required for a closed NURBS curve");const r=new li(t,!0,"centripetal"),i=Math.max(50,t.length*2),a=r.getPoints(i).map(o=>[o.x,o.y,o.z]);return mt.byPoints(a,e,s)}}class Dt extends ke{constructor(t,e,s,r,i){super();const a=arguments.length;if(a<2||a>5)throw et.ILLEGAL_PARAMETERS;if(this._degree=3,this._closed=!1,Array.isArray(e)){this._controlPoints=t;let o,c=3,l=!1;if(a>=3&&(Array.isArray(s)?(o=s,a>=4&&(c=r||3),a>=5&&(l=i)):s!==void 0&&(c=s||3,a>=4&&(l=r))),s===void 0&&a>=4&&(c=r||3,a>=5&&(l=i)),this._degree=c,this._closed=l,this._controlPoints.length<this._degree+1)throw et.ILLEGAL_PARAMETERS;this._nurbsCurve=mt.byKnotsControlPointsWeights(this._degree,e,this._controlPoints,o)}else{if(this._fitPoints=t,this._knotParameterization=e,a>=3&&(this._degree=s||3),a>=4&&(this._closed=r),this._fitPoints.length<this._degree+1)throw et.ILLEGAL_PARAMETERS;const o=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=mt.byPoints(o,this._degree,this._knotParameterization),this._controlPoints=this._nurbsCurve.controlPoints()}this._closed&&this.buildCurve()}buildCurve(){if(this._fitPoints&&this._knotParameterization){if(this._closed)this._nurbsCurve=mt.createClosedCurve(this._fitPoints,this._degree,this._knotParameterization);else{const t=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=mt.byPoints(t,this._degree,this._knotParameterization)}this._controlPoints=this._nurbsCurve.controlPoints()}else if(this._controlPoints)if(this._closed){const t=this._knotParameterization||"Chord";this._nurbsCurve=mt.createClosedCurve(this._controlPoints,this._degree,t),this._controlPoints=this._nurbsCurve.controlPoints()}else{const t=this._nurbsCurve.knots(),e=this._nurbsCurve.weights();this._nurbsCurve=mt.byKnotsControlPointsWeights(this._degree,t,this._controlPoints,e)}}setClosed(t){this._closed!==t&&(this._closed=t,this._boundingBoxNeedsUpdate=!0,this.buildCurve())}get degree(){return this._degree}get knotParameterization(){return this._knotParameterization}get startPoint(){const t=this._nurbsCurve.knots(),e=this._nurbsCurve.degree(),s=t[e],r=this._nurbsCurve.point(s);return new b(r[0],r[1],r[2])}get endPoint(){const t=this._nurbsCurve.knots(),e=this._nurbsCurve.degree(),s=t[t.length-e-1],r=this._nurbsCurve.point(s);return new b(r[0],r[1],r[2])}get length(){return this._nurbsCurve.length()}getFitPointAt(t){if(!this._fitPoints)throw new Error("No fit points in this spline");const e=this._fitPoints.length,s=t<0||t>=e?e-1:t,r=this._fitPoints[s];return{x:r.x,y:r.y,z:r.z||0}}getControlPointAt(t){const e=this._controlPoints.length,s=t<0||t>=e?e-1:t;return this._controlPoints[s]}getPoints(t=100){const e=this._nurbsCurve,s=[],r=e.knots(),i=this._nurbsCurve.degree(),a=r[i],o=r[r.length-i-1],c=(o-a)/(t-1);for(let l=0;l<t;l++){const d=l===t-1?o:a+l*c,u=e.point(d);s.push(new b(u[0],u[1],u[2]))}return s}getCurvePoints(t,e){const s=[],r=t.knots(),i=r[3],a=(r[r.length-4]-i)/(e-1);for(let o=0;o<e;o++){const c=i+o*a;s.push(t.point(c))}return s}calculateBoundingBox(){const t=this.getPoints(100);return new O().setFromPoints(t)}get closed(){return this._closed}set closed(t){this.setClosed(t)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}toNurbsPoints(t){const e=new Array(t.length);return t.forEach((s,r)=>{e[r]=[s.x,s.y,s.z||0]}),e}static createClosedSpline(t,e="Uniform",s=3){if(t.length<s+1)throw new Error(`At least ${s+1} points are required for a degree ${s} closed spline`);return new Dt(t,e,s,!0)}}for(var $t=256,ci=[],di=256,rs;$t--;)ci[$t]=($t+256).toString(16).substring(1);function eh(n){var t=0,e=11;if(!rs||$t+e>di*2)for(rs="",$t=0;t<di;t++)rs+=ci[Math.random()*256|0];return rs.substring($t,$t+++e)}class Rt{constructor(t,e){t=t||{},ee(t,{objectId:eh()}),this._attrs=new fn(t,e)}get attrs(){return this._attrs}getAttr(t){const e=this._attrs.get(t);if(e===void 0)throw new Error(`[AcDbObject] Attribute name '${t}' does't exist in this object!`);return e}getAttrWithoutException(t){return this._attrs.get(t)}setAttr(t,e){this._attrs.set(t,e)}get objectId(){return this.getAttr("objectId")}set objectId(t){this._attrs.set("objectId",t)}get ownerId(){return this.getAttr("ownerId")}set ownerId(t){this._attrs.set("ownerId",t)}get database(){return this._database?this._database:dn().workingDatabase}set database(t){this._database=t}close(){}}class pt extends Rt{constructor(){super(...arguments),this._layer="0",this._color=new zt,this._lineType=Xe,this._lineWeight=1,this._linetypeScale=-1,this._visibility=!0,this._transparency=0}get type(){return this.constructor.name.substring(4)}get layer(){return this._layer}set layer(t){this._layer=t}get color(){return this._color}set color(t){this._color.copy(t)}get rgbColor(){let t=this.database.cecolor;if(this.color.isByLayer){const e=this.getLayerColor();e&&e.color&&(t=e)}else this.color.isByBlock||this.color.color!=null&&(t=this.color);return t.color==null?16777215:t.color}get lineType(){return this._lineType}set lineType(t){this._lineType=t||Xe}get lineWeight(){return this._lineWeight}set lineWeight(t){this._lineWeight=t}get linetypeScale(){return this._linetypeScale}set linetypeScale(t){this._linetypeScale=t}get visibility(){return this._visibility}set visibility(t){this._visibility=t}get transparency(){return this._transparency}set transparency(t){this._transparency=t}subGetGripPoints(){return new Array}subGetOsnapPoints(t,e,s,r,i){}transformBy(t){return this}triggerModifiedEvent(){this.database.events.entityModified.dispatch({database:this.database,entity:this})}get lineStyle(){var s;const t=this.getLineType(),e=(s=this.database)==null?void 0:s.tables.linetypeTable.getAt(t);return e?{...e.linetype,color:this.rgbColor}:{name:t,standardFlag:0,color:this.rgbColor,description:"",totalPatternLength:0}}getLineType(){if(this.lineType==Xe){const t=this.database.tables.layerTable.getAt(this.layer);if(t&&t.linetype)return t.linetype}else return this.lineType==Pr?qe:this.lineType;return qe}getLayerColor(){const t=this.database.tables.layerTable.getAt(this.layer);if(t==null)console.error(`The layer with name '${this.layer}' not found in drawing database!`);else return t.color;return null}}class tn extends pt{constructor(t){super(),this._blockName=t,this._position=new b,this._rotation=0,this._normal=new w(0,0,1),this._scaleFactors=new b(1,1,1)}get position(){return this._position}set position(t){this._position.copy(t)}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get scaleFactors(){return this._scaleFactors}set scaleFactors(t){this._scaleFactors.copy(t)}get normal(){return this._normal}set normal(t){this._normal.copy(t).normalize()}get blockTableRecord(){return this.database.tables.blockTable.getAt(this._blockName)}get geometricExtents(){const t=new O,e=this.blockTableRecord;if(e!=null){const i=e.newIterator();for(const a of i)t.union(a.geometricExtents)}const s=new Ct().setFromEuler(new ii(this.rotation,0,0)),r=new Yt;return r.compose(this.position,s,this.scaleFactors),t.applyMatrix4(r),t}draw(t){const e=[],s=this.blockTableRecord;if(s!=null){const r=this.computeTransformMatrix();return kt.instance.draw(t,s,this.rgbColor,!0,r,this.normal)}else return t.group(e)}computeTransformMatrix(){const t=new Ct;return t.setFromAxisAngle(w.Z_AXIS,this.rotation),new Yt().compose(this._position,t,this._scaleFactors)}}class gt extends pt{}class ui extends gt{constructor(t,e,s,r,i,a,o){super(),this._geo=new ss(t,e,s,r,i,a,o)}get center(){return this._geo.center}set center(t){this._geo.center=t}get majorAxisRadius(){return this._geo.majorAxisRadius}set majorAxisRadius(t){this._geo.majorAxisRadius=t}get minorAxisRadius(){return this._geo.minorAxisRadius}set minorAxisRadius(t){this._geo.minorAxisRadius=t}get normal(){return this._geo.normal}set normal(t){this._geo.normal=t}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}draw(t){return t.ellipticalArc(this._geo,this.lineStyle)}}class mi extends gt{constructor(t,e,s,r){super(),this._geo=new Xt(t,e,s,r,w.Z_AXIS,w.X_AXIS)}get center(){return this._geo.center}set center(t){this._geo.center=t}get radius(){return this._geo.radius}set radius(t){this._geo.radius=t}get startAngle(){return this._geo.startAngle}set startAngle(t){this._geo.startAngle=t}get endAngle(){return this._geo.endAngle}set endAngle(t){this._geo.endAngle=t}get startPoint(){return this._geo.startPoint}get endPoint(){return this._geo.endPoint}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}subGetGripPoints(){const t=new Array;return t.push(this.center),t.push(this.startPoint),t.push(this.endPoint),t}transformBy(t){return this._geo.transform(t),this}draw(t){return t.circularArc(this._geo,this.lineStyle)}}class gi extends gt{constructor(t,e,s=w.Z_AXIS){super(),this._geo=new Xt(t,e,0,H,s,w.X_AXIS)}get center(){return this._geo.center}set center(t){this._geo.center=t}get radius(){return this._geo.radius}set radius(t){this._geo.radius=t}get normal(){return this._geo.normal}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}subGetGripPoints(){const t=new Array;return t.push(this.center),t}transformBy(t){return this._geo.transform(t),this}draw(t){return t.circularArc(this._geo,this.lineStyle)}}var pi=(n=>(n[n.UserDefined=0]="UserDefined",n[n.Predefined=1]="Predefined",n[n.Custom=2]="Custom",n))(pi||{}),yi=(n=>(n[n.Normal=0]="Normal",n[n.Outer=1]="Outer",n[n.Ignore=2]="Ignore",n))(yi||{});class _i extends pt{constructor(){super(),this._elevation=0,this._geo=new Je,this._definitionLines=[],this._patternName="",this._patternType=1,this._patternAngle=0,this._patternScale=1,this._hatchStyle=0}get definitionLines(){return this._definitionLines}get patternName(){return this._patternName}set patternName(t){this._patternName=t}get patternType(){return this._patternType}set patternType(t){this._patternType=t}get patternAngle(){return this._patternAngle}set patternAngle(t){this._patternAngle=t}get patternScale(){return this._patternScale}set patternScale(t){this._patternScale=t}get hatchStyle(){return this._hatchStyle}set hatchStyle(t){this._hatchStyle=t}add(t){this._geo.add(t)}get geometricExtents(){const t=this._geo.box;return new O({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}draw(t){return t.area(this._geo,{color:this.rgbColor,solidFill:!1,patternAngle:this.patternAngle,patternLines:this.definitionLines})}}var fi=(n=>(n[n.MText=0]="MText",n[n.Fcf=1]="Fcf",n[n.BlockReference=2]="BlockReference",n[n.NoAnnotation=3]="NoAnnotation",n))(fi||{});class xi extends gt{constructor(){super(),this._isSplined=!1,this._updated=!1,this._hasArrowHead=!1,this._vertices=[],this._dimensionStyle="",this._hasHookLine=!1,this._annoType=3}get isSplined(){return this._isSplined}set isSplined(t){this._isSplined=t}get hasArrowHead(){return this._hasArrowHead}set hasArrowHead(t){this._hasArrowHead=t}get hasHookLine(){return this._hasHookLine}set hasHookLine(t){this._hasHookLine=t}get numVertices(){return this._vertices.length}get dimensionStyle(){return this._dimensionStyle}set dimensionStyle(t){this._dimensionStyle=t}get annoType(){return this._annoType}set annoType(t){this._annoType=t}appendVertex(t){this._vertices.push(new b().copy(t)),this._updated=!0}setVertexAt(t,e){throw(t<0||t>=this._vertices.length)&&(this._vertices[t].copy(e),this._updated=!0),new Error("The vertex index is out of range!")}vertexAt(t){throw(t<0||t>=this._vertices.length)&&this._vertices[t],new Error("The vertex index is out of range!")}get geometricExtents(){return this._isSplined&&this.splineGeo?this.splineGeo.calculateBoundingBox():new O().setFromPoints(this._vertices)}get closed(){return!1}set closed(t){}draw(t){if(this.isSplined&&this.splineGeo){const e=this.splineGeo.getPoints(100);return t.lines(e,this.lineStyle)}else return t.lines(this._vertices,this.lineStyle)}get splineGeo(){return this.createSplineIfNeeded(),this._splineGeo}createSplineIfNeeded(){this.isSplined&&this.numVertices>=2&&(this._splineGeo==null||this._updated)&&(this._splineGeo=new Dt(this._vertices,"Uniform"),this._updated=!1)}}class bi extends gt{constructor(t,e){super(),this._geo=new Nt(t,e)}get startPoint(){return this._geo.startPoint}set startPoint(t){this._geo.startPoint=t}get endPoint(){return this._geo.endPoint}set endPoint(t){this._geo.endPoint=t}get midPoint(){return this._geo.midPoint}get geometricExtents(){return this._geo.box}get closed(){return!1}subGetGripPoints(){const t=new Array;return t.push(this.midPoint),t.push(this.startPoint),t.push(this.endPoint),t}subGetOsnapPoints(t,e,s,r,i){const a=this.startPoint,o=this.endPoint;switch(t){case Ut.EndPoint:i.push(a),i.push(o);break;case Ut.MidPoint:i.push(this.midPoint);break;case Ut.Nearest:{const c=this._geo.project(s);i.push(c)}break;case Ut.Perpendicular:{const c=this._geo.perpPoint(s);i.push(c)}break;case Ut.Tangent:i.push(a);break}}transformBy(t){return this._geo.transform(t),this}draw(t){const e=this.startPoint,s=this.endPoint,r=[new b(e.x,e.y,0),new b(s.x,s.y,0)];return t.lines(r,this.lineStyle)}}var en=(n=>(n.ClosedFilled="",n.Dot="_DOT",n.DotSmall="_DOTSMALL",n.DotBlank="_DOTBLANK",n.Origin="_ORIGIN",n.Origin2="_ORIGIN2",n.Open="_OPEN",n.Open90="_OPEN90",n.Open30="_OPEN30",n.Closed="_CLOSED",n.Small="_SMALL",n.None="_NONE",n.Oblique="_OBLIQUE",n.BoxFilled="_BOXFILLED",n.Box="_BOXBLANK",n.ClosedBlank="_CLOSEDBLANK",n.DatumBlank="_DATUMBLANK",n.DatumFilled="_DATUMFILLED",n.Integral="_INTEGRAL",n.ArchTick="_ARCHTICK",n))(en||{}),is=(n=>(n[n.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",n[n.RIGHT_TO_LEFT=2]="RIGHT_TO_LEFT",n[n.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",n[n.BOTTOM_TO_TOP=4]="BOTTOM_TO_TOP",n[n.BY_STYLE=5]="BY_STYLE",n))(is||{}),he=(n=>(n[n.TopLeft=1]="TopLeft",n[n.TopCenter=2]="TopCenter",n[n.TopRight=3]="TopRight",n[n.MiddleLeft=4]="MiddleLeft",n[n.MiddleCenter=5]="MiddleCenter",n[n.MiddleRight=6]="MiddleRight",n[n.BottomLeft=7]="BottomLeft",n[n.BottomCenter=8]="BottomCenter",n[n.BottomRight=9]="BottomRight",n))(he||{}),sn=(n=>(n[n.OPTIMIZED_2D=0]="OPTIMIZED_2D",n[n.WIREFRAME=1]="WIREFRAME",n[n.HIDDEN_LINE=2]="HIDDEN_LINE",n[n.FLAT_SHADED=3]="FLAT_SHADED",n[n.GOURAUD_SHADED=4]="GOURAUD_SHADED",n[n.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",n[n.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME",n))(sn||{}),nn=(n=>(n[n.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",n[n.TOP=1]="TOP",n[n.BOTTOM=2]="BOTTOM",n[n.FRONT=3]="FRONT",n[n.BACK=4]="BACK",n[n.LEFT=5]="LEFT",n[n.RIGHT=6]="RIGHT",n))(nn||{}),rn=(n=>(n[n.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",n[n.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS",n))(rn||{});class as{constructor(){this._number=-1,this._id="",this._groupId="",this._centerPoint=new b,this._height=0,this._width=0,this._viewCenter=new b,this._viewHeight=0}get number(){return this._number}set number(t){this._number=t}get id(){return this._id}set id(t){this._id=t}get groupId(){return this._groupId}set groupId(t){this._groupId=t}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get box(){const t=new K;return t.setFromCenterAndSize(this.centerPoint,{x:this.width,y:this.height}),t}get viewCenter(){return this._viewCenter}set viewCenter(t){this._viewCenter.copy(t)}get viewHeight(){return this._viewHeight}set viewHeight(t){this._viewHeight=t}get viewWidth(){return this.viewHeight*(this.width/this.height)}get viewBox(){const t=new K;return t.setFromCenterAndSize(this.viewCenter,{x:this.viewWidth,y:this.viewHeight}),t}clone(){const t=new as;return t.id=this.id,t.groupId=this.groupId,t.number=this.number,t.centerPoint.copy(this.centerPoint),t.height=this.height,t.width=this.width,t.viewCenter.copy(this.viewCenter),t.viewHeight=this.viewHeight,t}copy(t){return this.id=t.id,this.groupId=t.groupId,this.number=t.number,this.centerPoint.copy(t.centerPoint),this.height=t.height,this.width=t.width,this.viewCenter.copy(t.viewCenter),this.viewHeight=t.viewHeight,this}}class wi extends pt{constructor(){super(),this._contents="",this._height=0,this._width=0,this._lineSpacingFactor=.25,this._lineSpacingStyle=0,this._backgroundFill=!1,this._backgroundFillColor=13158600,this._backgroundFillTransparency=1,this._backgroundScaleFactor=1,this._rotation=0,this._styleName="",this._location=new b,this._attachmentPoint=he.TopLeft,this._direction=new w(1,0,0),this._drawingDirection=is.LEFT_TO_RIGHT}get contents(){return this._contents}set contents(t){this._contents=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get lineSpacingFactor(){return this._lineSpacingFactor}set lineSpacingFactor(t){this._lineSpacingFactor=t}get lineSpacingStyle(){return this._lineSpacingStyle}set lineSpacingStyle(t){this._lineSpacingStyle=t}get backgroundFill(){return this._backgroundFill}set backgroundFill(t){this._backgroundFill=t,this._backgroundFillColor=13158600}get backgroundFillColor(){return this._backgroundFillColor}set backgroundFillColor(t){this._backgroundFillColor=t}get backgroundFillTransparency(){return this._backgroundFillTransparency}set backgroundFillTransparency(t){this._backgroundFillTransparency=t}get backgroundScaleFactor(){return this._backgroundScaleFactor}set backgroundScaleFactor(t){this._backgroundScaleFactor=t}get styleName(){return this._styleName}set styleName(t){this._styleName=t}get location(){return this._location}set location(t){this._location.copy(t)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(t){this._attachmentPoint=t}get direction(){return this._direction}set direction(t){this._direction.copy(t)}get drawingDirection(){return this._drawingDirection}set drawingDirection(t){this._drawingDirection=t}get geometricExtents(){return new O}getTextStyle(){const t=this.database.tables.textStyleTable;let e=t.getAt(this.styleName);return e||(e=t.getAt("STANDARD")||t.getAt("Standard")),e.textStyle}draw(t){const e={text:this.contents,height:this.height,width:this.width,position:this.location,rotation:this.rotation,directionVector:this.direction,attachmentPoint:this.attachmentPoint,drawingDirection:this.drawingDirection,lineSpaceFactor:this.lineSpacingFactor},s={...this.getTextStyle(),color:this.rgbColor};return t.mtext(e,s)}}class an extends gt{constructor(t,e,s,r,i){super();const a=+(t!==void 0)+ +(e!==void 0)+ +(s!==void 0)+ +(r!==void 0)+ +(i!==void 0);if(a<2||a>5)throw et.ILLEGAL_PARAMETERS;!Array.isArray(e)?this._geo=new Dt(t,e,s,r):this._geo=new Dt(t,e,s,r,i)}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}draw(t){const e=this._geo.getPoints(100);return t.lines(e,this.lineStyle)}}const sh=new w;class Ai extends tn{constructor(t,e,s){super(t),this._attachmentPoint=he.TopLeft,this._numColumns=s,this._numRows=e,this._columnWidth=new Array(s),this._rowHeight=new Array(e),this._cells=new Array(e*s)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(t){this._attachmentPoint=t}get numRows(){return this._numRows}set numRows(t){this._numRows=t}get numColumns(){return this._numColumns}set numColumns(t){this._numColumns=t}numContents(t,e){return 1}rowHeight(t){return this._rowHeight[t]}setRowHeight(t,e){this._rowHeight[t]=e}setUniformRowHeight(t){this._rowHeight.fill(t)}columnWidth(t){return this._columnWidth[t]}setUniformColumnWidth(t){this._columnWidth.fill(t)}setColumnWidth(t,e){this._columnWidth[t]=e}cell(t){if(!(t<0||t>=this._cells.length))return this._cells[t]}setCell(t,e){this._cells[t]=e}textString(t,e,s){return this._cells[t*e].text}setTextString(t,e,s){this._cells[t*e].text=s}isEmpty(t,e){return!this._cells[t*e].text}get geometricExtents(){return new O}draw(t){let e=0,s=0;const r=new Uint16Array(this.numColumns*this.numRows*8),i=new Float32Array((this.numColumns+1)*(this.numRows+1)*3);let a=0;for(let m=0;m<=this.numRows;m++){e-=m>0?this.rowHeight(m-1):0,s=0;for(let p=0;p<=this.numColumns;p++)s+=p>0?this.columnWidth(p-1):0,i[a++]=s,i[a++]=e,i[a++]=0}const o=[],c=new Array(this.numRows*this.numColumns).fill(!1);s=0,a=0;let l=0;for(let m=0;m<this.numColumns;m++){s+=m>0?this.columnWidth(m-1):0,e=0;for(let p=0;p<this.numRows;p++){e+=p>0?this.rowHeight(p-1):0;const y=this.cell(p*this.numColumns+m);if(l=p*this.numColumns+m,y&&!c[l]){const _=y.borderWidth??1,x=y.borderHeight??1;this.fillVisited(c,l,this.numColumns,_,x),r[a++]=m+p*(this.numColumns+1),r[a++]=m+p*(this.numColumns+1)+_;const f=i[r[a-1]*3]-s,M=m+(p+x)*(this.numColumns+1)+_;m+_==this.numColumns&&(r[a++]=m+p*(this.numColumns+1)+_,r[a++]=M);const T=-i[M*3+1]-e;if(p+x==this.numRows&&(r[a++]=m+(p+x)*(this.numColumns+1)+x,r[a++]=m+(p+x)*(this.numColumns+1)),r[a++]=m+(p+x)*(this.numColumns+1),r[a++]=m+p*(this.numColumns+1),y.text){const S=y.attachmentPoint||this.attachmentPoint||he.MiddleCenter,P=this.getTableTextOffset(S,f,T),z={text:y.text,height:y.textHeight,width:f,position:sh.set(s,-e,0).clone().add(P),rotation:this.rotation,attachmentPoint:S},I={...this.getTextStyle(y),color:this.color.color};o.push(t.mtext(z,I))}}}}o.push(t.lineSegments(i,3,r,this.lineStyle));const d=t.group(o),u=new Ct;return u.setFromAxisAngle(w.Z_AXIS,this.rotation),Pi.compose(this.position,u,this.scaleFactors),d.applyMatrix(Pi),d}fillVisited(t,e,s,r,i){if(i==1&&r==1)t[e]=!0;else for(let a=0;a<r;++a)for(let o=0;o<i;++o)t[e+a+o*s]=!0}getTextStyle(t){const e=this.database.tables.textStyleTable;let s;return t.textStyle&&(s=e.getAt(t.textStyle)),s||(s=e.getAt("STANDARD")||e.getAt("Standard")),s.textStyle}getTableTextOffset(t,e,s){const r=new w;switch(t){case 1:break;case 2:r.setX(e/2);break;case 3:r.setX(e);break;case 4:r.setY(-s/2);break;case 5:r.set(e/2,-s/2,0);break;case 6:r.set(e,-s/2,0);break;case 7:r.setY(-s);break;case 8:r.set(e/2,-s,0);break;case 9:r.set(e,-s,0);break}return r}}const Pi=new Yt;var Ii=(n=>(n[n.LEFT=0]="LEFT",n[n.CENTER=1]="CENTER",n[n.RIGHT=2]="RIGHT",n[n.ALIGNED=3]="ALIGNED",n[n.MIDDLE=4]="MIDDLE",n[n.FIT=5]="FIT",n))(Ii||{}),Ei=(n=>(n[n.BASELINE=0]="BASELINE",n[n.BOTTOM=1]="BOTTOM",n[n.MIDDLE=2]="MIDDLE",n[n.TOP=3]="TOP",n))(Ei||{});class Ti extends pt{constructor(){super(),this._textString="",this._height=0,this._thickness=1,this._position=new b,this._rotation=0,this._oblique=0,this._horizontalMode=0,this._verticalModel=2,this._styleName="",this._widthFactor=1}get textString(){return this._textString}set textString(t){this._textString=t}get thickness(){return this._thickness}set thickness(t){this._thickness=t}get height(){return this._height}set height(t){this._height=t}get position(){return this._position}set position(t){this._position.copy(t)}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get oblique(){return this._oblique}set oblique(t){this._oblique=t}get horizontalMode(){return this._horizontalMode}set horizontalMode(t){this._horizontalMode=t}get verticalMode(){return this._verticalModel}set verticalMode(t){this._verticalModel=t}get styleName(){return this._styleName}set styleName(t){this._styleName=t}get widthFactor(){return this._widthFactor}set widthFactor(t){this._widthFactor=t}get geometricExtents(){return new O}getTextStyle(){const t=this.database.tables.textStyleTable;let e=t.getAt(this.styleName);return e||(e=t.getAt("STANDARD")||t.getAt("Standard")),e.textStyle}draw(t){const e={text:this.textString,height:this.height,width:1/0,widthFactor:this.widthFactor,position:this.position,rotation:this.rotation,drawingDirection:is.BOTTOM_TO_TOP,attachmentPoint:he.BottomLeft},s={...this.getTextStyle(),color:this.rgbColor};return t.mtext(e,s)}}class Si extends gt{constructor(){super(),this._elevation=0,this._thickness=1,this._vertices=[new b,new b,new b,new b]}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get closed(){return!0}get thickness(){return this._thickness}set thickness(t){this._thickness=t}getPointAt(t){return t<0?this._vertices[0]:t>3?this._vertices[3]:this._vertices[t]}setPointAt(t,e){if(t<0&&this._vertices[0].copy(e),t>3)return this._vertices[3].copy(e);this._vertices[t].copy(e)}get geometricExtents(){return new O().setFromPoints(this._vertices)}subGetGripPoints(){const t=new Array;for(let e=0;e<4;++e)t.push(this.getPointAt(e));return t}draw(t){const e=new Ce(this._vertices,!0),s=new Je;return s.add(e),t.area(s,{color:this.rgbColor,solidFill:!0,patternAngle:0,patternLines:[]})}}class Mi extends gt{constructor(){super(),this._elevation=0,this._geo=new Ce}get numberOfVertices(){return this._geo.numberOfVertices}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}addVertexAt(t,e,s=0,r=-1,i=-1){const a=r<0?void 0:r,o=i<0?void 0:i,c={x:e.x,y:e.y,bulge:s,startWidth:a,endWidth:o};this._geo.addVertexAt(t,c)}getPoint2dAt(t){return this._geo.getPointAt(t)}getPoint3dAt(t){const e=this.getPoint2dAt(t);return new b(e.x,e.y,this._elevation)}get geometricExtents(){const t=this._geo.box;return new O({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}subGetGripPoints(){const t=new Array;for(let e=0;e<this.numberOfVertices;++e)t.push(this.getPoint3dAt(e));return t}draw(t){const e=[];return this._geo.getPoints(100).forEach(r=>e.push(new b().set(r.x,r.y,this.elevation))),t.lines(e,this.lineStyle)}}class vi extends pt{constructor(){super(),this._geo=new b}get position(){return this._geo}set position(t){this._geo.set(t.x,t.y,t.z||0)}get geometricExtents(){return new O().expandByPoint(this._geo)}transformBy(t){return this._geo.applyMatrix3d(t),this}draw(t){return t.point(this._geo,{displayMode:this.database.pdmode,displaySize:this.database.pdsize,color:this.rgbColor})}}var Li=(n=>(n[n.Invalid=0]="Invalid",n[n.Rect=1]="Rect",n[n.Poly=2]="Poly",n))(Li||{}),ki=(n=>(n[n.Show=1]="Show",n[n.ShowUnAligned=2]="ShowUnAligned",n[n.Clip=4]="Clip",n[n.Transparent=8]="Transparent",n))(ki||{});class on extends pt{constructor(){super(),this._brightness=50,this._contrast=50,this._fade=0,this._width=0,this._height=0,this._position=new b,this._scale=new B(1,1),this._rotation=0,this._clipBoundaryType=1,this._clipBoundary=[],this._isClipped=!1,this._isImageShown=!0,this._isImageTransparent=!1,this._imageDefId=""}get brightness(){return this._brightness}set brightness(t){this._brightness=t}get contrast(){return this._contrast}set contrast(t){this._contrast=t}get fade(){return this._fade}set fade(t){this._fade=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get position(){return this._position}set position(t){this._position=t}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get scale(){return this._scale}set scale(t){this._scale.copy(t)}get clipBoundaryType(){return this._clipBoundaryType}set clipBoundaryType(t){this._clipBoundaryType=t}get clipBoundary(){return this._clipBoundary}set clipBoundary(t){this._clipBoundary=[],this._clipBoundary.push(...t)}get isClipped(){return this._isClipped}set isClipped(t){this._isClipped=t}get isImageShown(){return this._isImageShown}set isImageShown(t){this._isImageShown=t}get isImageTransparent(){return this._isImageTransparent}set isImageTransparent(t){this._isImageTransparent=t}get image(){return this._image}set image(t){this._image=t}get imageDefId(){return this._imageDefId}set imageDefId(t){this._imageDefId=t}get imageFileName(){if(this._imageDefId){const t=this.database.dictionaries.imageDefs.getIdAt(this._imageDefId);if(t)return t.sourceFileName}return""}get geometricExtents(){const t=new O;return t.min.copy(this._position),t.max.set(this._position.x+this._width,this._position.y+this._height,0),t}subGetGripPoints(){return this.boundaryPath()}draw(t){const e=this.boundaryPath();return this._image?t.image(this._image,{boundary:e,roation:this._rotation}):t.lines(e,this.lineStyle)}boundaryPath(){const t=[];if(this.isClipped&&this._clipBoundary.length>3){const e=this._width,s=this._height,r=new K;r.setFromPoints(this._clipBoundary);const i=new L;i.setX(this._position.x-r.min.x*e),i.setY(this._position.y-r.min.y*s),this._clipBoundary.forEach(a=>{const o=a.x*e+i.x,c=a.y*s+i.y;t.push(new b(o,c,this._position.z))})}else{if(t.push(this._position),t.push(this._position.clone().setX(this._position.x+this._width)),t.push(this._position.clone().set(this._position.x+this._width,this._position.y+this._height,this._position.z)),t.push(this._position.clone().setY(this._position.y+this._height)),this._rotation>0){Ci.copy(t[1]);for(let e=1;e<4;e++)os.copy(t[e]),os.rotateAround(Ci,this._rotation),t[e].setX(os.x),t[e].setY(os.y)}t.push(t[0])}return t}}const Ci=new L,os=new L;class Oi extends gt{constructor(){super(),this._basePoint=new b,this._unitDir=new w}get basePoint(){return this._basePoint}set basePoint(t){this._basePoint.copy(t)}get unitDir(){return this._unitDir}set unitDir(t){this._unitDir.copy(t)}get closed(){return!1}get geometricExtents(){const t=new O;return t.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),t.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),t}subGetGripPoints(){const t=new Array;return t.push(this.basePoint),t}draw(t){const e=[];return e.push(this.basePoint),e.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),t.lines(e,this.lineStyle)}}class Ni extends pt{constructor(){super(),this._centerPoint=new b,this._height=0,this._width=0,this._viewCenter=new b,this._viewHeight=0,this._number=-1}get number(){return this._number}set number(t){this._number=t}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get viewCenter(){return this._viewCenter}set viewCenter(t){this._viewCenter=t}get viewHeight(){return this._viewHeight}set viewHeight(t){this._viewHeight=t}get geometricExtents(){return new O}draw(t){if(this._number>1&&this.ownerId!=this.database.tables.blockTable.modelSpace.objectId){const e=this.toGiViewport();return t.group(this.createViewportRect(e,t))}}toGiViewport(){const t=new as;return t.id=this.objectId,t.groupId=this.ownerId,t.number=this.number,t.centerPoint=this.centerPoint,t.width=this.width,t.height=this.height,t.viewHeight=this.viewHeight,t.viewCenter=this.viewCenter,t}createViewportRect(t,e){const s=[];return s.push(e.lines([new b(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0),new b(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0)],this.lineStyle)),s.push(e.lines([new b(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0),new b(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0)],this.lineStyle)),s.push(e.lines([new b(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0),new b(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0)],this.lineStyle)),s.push(e.lines([new b(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0),new b(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0)],this.lineStyle)),s}}class Di extends on{draw(t){const e=this.boundaryPath(),s=new Je;return s.add(new Ce(e)),t.area(s,{color:0,solidFill:!0,patternAngle:0,patternLines:[]})}}class Ri extends gt{constructor(){super(),this._basePoint=new b,this._unitDir=new w}get basePoint(){return this._basePoint}set basePoint(t){this._basePoint.copy(t)}get unitDir(){return this._unitDir}set unitDir(t){this._unitDir.copy(t)}get closed(){return!1}get geometricExtents(){const t=new O;return t.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),t.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),t}subGetGripPoints(){const t=new Array;return t.push(this.basePoint),t}draw(t){const e=[];return e.push(this._unitDir.clone().multiplyScalar(-1e6).add(this._basePoint)),e.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),t.lines(e,this.lineStyle)}}var zi=(n=>(n[n.AtLeast=1]="AtLeast",n[n.Exactly=2]="Exactly",n))(zi||{});class Kt extends pt{constructor(){super(),this._dimBlockId=null,this._dimensionStyleName=null,this._dimensionText=null,this._textLineSpacingFactor=1,this._textLineSpacingStyle=1,this._textPosition=new b,this._textRotation=0}get dimBlockId(){return this._dimBlockId}set dimBlockId(t){this._dimBlockId=t}get dimensionStyleName(){return this._dimensionStyleName}set dimensionStyleName(t){this._dimensionStyleName=t}get dimensionStyle(){if(this._dimStyle==null){let t;this.dimensionStyleName&&(t=this.database.tables.dimStyleTable.getAt(this.dimensionStyleName)),t==null&&(t=new Ne),this._dimStyle=t}return this._dimStyle}get dimensionText(){return this._dimensionText}set dimensionText(t){this._dimensionText=t}get measurement(){return this._measurement}set measurement(t){this._measurement=t}get textLineSpacingFactor(){return this._textLineSpacingFactor}set textLineSpacingFactor(t){this._textLineSpacingFactor=t}get textLineSpacingStyle(){return this._textLineSpacingStyle}set textLineSpacingStyle(t){this._textLineSpacingStyle=t}get textPosition(){return this._textPosition}set textPosition(t){this._textPosition.copy(t)}get textRotation(){return this._textRotation}set textRotation(t){this._textRotation=t}draw(t){if(this.dimBlockId){const e=this.database.tables.blockTable.getAt(this.dimBlockId);if(e)return kt.instance.draw(t,e,this.rgbColor,!1)}return t.group([])}drawFirstArrow(t){const e=this.database.tables.blockTable.getAt(this.firstArrowType);if(e)return kt.instance.draw(t,e,this.rgbColor,!1)}drawSecondArrow(t){const e=this.database.tables.blockTable.getAt(this.secondArrowType);if(e)return kt.instance.draw(t,e,this.rgbColor,!1)}get arrowScaleFactor(){return this.dimensionStyle.dimasz}get firstArrowStyle(){return{type:this.firstArrowType,scale:this.arrowScaleFactor,appended:this.isAppendArrow,visible:this.dimensionStyle.dimse1==0}}get secondArrowStyle(){return{type:this.secondArrowType,scale:this.arrowScaleFactor,appended:this.isAppendArrow,visible:this.dimensionStyle.dimse2==0}}get isAppendArrow(){return!0}get firstArrowTypeBtrId(){const t=this.dimensionStyle;return t.dimsah==0?t.dimblk:t.dimblk1}get firstArrowType(){const t=this.firstArrowTypeBtrId;return this.getArrowName(t)}get secondArrowTypeBtrId(){const t=this.dimensionStyle;return t.dimsah==0?t.dimblk:t.dimblk2}get secondArrowType(){const t=this.secondArrowTypeBtrId;return this.getArrowName(t)}get arrowLineCount(){return 1}getLineArrowStyle(t){}findPointOnLine1(t,e,s){const r=new b().subVectors(e,t).normalize();return new b(e).addScaledVector(r,s)}findPointOnLine2(t,e,s){const r=t.x+s*Math.cos(e),i=t.y+s*Math.sin(e);return{x:r,y:i}}adjustExtensionLine(t){const e=this.dimensionStyle;t.extend(e.dimexe),t.extend(-e.dimexo,!0)}getArrowName(t){const e=this.database.tables.blockTable.getIdAt(t);return e?e.name.toUpperCase():en.Closed}}class Fi extends Kt{constructor(t,e,s,r,i=null,a=null){super(),this._centerPoint=new b().copy(t),this._xLine1Point=new b().copy(e),this._xLine2Point=new b().copy(s),this._arcPoint=new b().copy(r),this.dimensionText=i,this.dimensionStyleName=a}get arcPoint(){return this._arcPoint}set arcPoint(t){this._arcPoint.copy(t)}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get geometricExtents(){return new O}}class Bi extends Kt{constructor(t,e,s,r=null,i=null){super(),this._dimLinePoint=new b().copy(s),this._xLine1Point=new b().copy(t),this._xLine2Point=new b().copy(e),this._oblique=0,this._rotation=0,this.dimensionText=r,this.dimensionStyleName=i}get dimLinePoint(){return this._dimLinePoint}set dimLinePoint(t){this._dimLinePoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get oblique(){return this._oblique}set oblique(t){this._oblique=t}get geometricExtents(){return new O}get isAppendArrow(){return!1}calculateLines(){const t=[],e=this.createExtensionLine(this._xLine1Point),s=this.createExtensionLine(this._xLine2Point),r=this.findIntersectionPoint(e,this._dimLinePoint),i=this.findIntersectionPoint(s,this._dimLinePoint),a=new Nt(r,i);return t.push(a),e.endPoint=r,this.adjustExtensionLine(e),t.push(e),s.endPoint=i,this.adjustExtensionLine(s),t.push(s),t}createExtensionLine(t){const e=this.rotation+Math.PI/2,s=this.findPointOnLine2(t,e,100);return new Nt(t,{...s,z:t.z})}findIntersectionPoint(t,e){const s=t.startPoint,r=t.endPoint,i=new w().subVectors(r,s).normalize(),o=new w().subVectors(e,s).dot(i),c=new w().copy(i).multiplyScalar(o);return new w().addVectors(s,c)}}class nh extends Kt{constructor(t,e,s,r,i=null,a=null){super(),this._arcPoint=new b().copy(r),this._xLine1Point=new b().copy(e),this._xLine2Point=new b().copy(s),this._centerPoint=new b().copy(t),this.dimensionText=i,this.dimensionStyleName=a}get arcPoint(){return this._arcPoint}set arcPoint(t){this._arcPoint.copy(t)}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get geometricExtents(){return new O}}class Vi extends Kt{constructor(t,e,s=0,r=null,i=null){super(),this._chordPoint=new b().copy(t),this._farChordPoint=new b().copy(e),this._extArcStartAngle=0,this._extArcEndAngle=0,this._leaderLength=s,this.dimensionText=r,this.dimensionStyleName=i}get chordPoint(){return this._chordPoint}set chordPoint(t){this._chordPoint.copy(t)}get farChordPoint(){return this._farChordPoint}set farChordPoint(t){this._farChordPoint.copy(t)}get extArcStartAngle(){return this._extArcStartAngle}set extArcStartAngle(t){this._extArcStartAngle=t}get extArcEndAngle(){return this._extArcEndAngle}set extArcEndAngle(t){this._extArcEndAngle=t}get leaderLength(){return this._leaderLength}get geometricExtents(){return new O}drawLines(t,e){const s=[],r=e.length;return r==1?s.push(this.drawLine(t,e[0],{firstArrow:this.firstArrowStyle})):r==3?(this.sortLines(e),s.push(this.drawLine(t,e[0],{firstArrow:this.firstArrowStyle})),s.push(this.drawLine(t,e[1])),s.push(this.drawLine(t,e[2],{firstArrow:this.firstArrowStyle}))):e.forEach(i=>{s.push(this.drawLine(t,i))}),s}drawLine(t,e,s){if(s){const r=[e.startPoint,e.endPoint];return t.lines(r,{...this.lineStyle,arrows:s})}else return e.draw(t)}sortLines(t){const e=(s,r)=>s.x!==r.x?s.x-r.x:s.y!==r.y?s.y-r.y:s.z-r.z;t.sort((s,r)=>{const i=e(s.startPoint,r.startPoint);return i!==0?i:e(s.endPoint,r.endPoint)})}}class ji extends Kt{constructor(t,e,s=null,r=null){super(),this._definingPoint=new b().copy(t),this._leaderEndPoint=new b().copy(e),this.dimensionText=s,this.dimensionStyleName=r}get definingPoint(){return this._definingPoint}set definingPoint(t){this._definingPoint.copy(t)}get leaderEndPoint(){return this._leaderEndPoint}set leaderEndPoint(t){this._leaderEndPoint.copy(t)}get geometricExtents(){return new O}get arrowLineCount(){return 0}}class Gi extends Kt{constructor(t,e,s,r=null,i=null){super(),this._center=new b().copy(t),this._chordPoint=new b().copy(e),this._leaderLength=s,this._extArcStartAngle=0,this._extArcEndAngle=0,this.dimensionText=r,this.dimensionStyleName=i}get center(){return this._center}set center(t){this._center.copy(t)}get chordPoint(){return this._chordPoint}set chordPoint(t){this._chordPoint.copy(t)}get extArcStartAngle(){return this._extArcStartAngle}set extArcStartAngle(t){this._extArcStartAngle=t}get extArcEndAngle(){return this._extArcEndAngle}set extArcEndAngle(t){this._extArcEndAngle=t}get leaderLength(){return this._leaderLength}set leaderLenght(t){this._leaderLength=t}get geometricExtents(){return new O}getLineArrowStyle(t){return{secondArrow:this.secondArrowStyle}}}class Hi{convert(t){const e=this.createEntity(t);return e&&this.processCommonAttrs(t,e),e}createEntity(t){return t.type=="ARC"?this.convertArc(t):t.type=="CIRCLE"?this.convertCirle(t):t.type=="DIMENSION"?this.convertDimension(t):t.type=="ELLIPSE"?this.convertEllipse(t):t.type=="HATCH"?this.convertHatch(t):t.type=="IMAGE"?this.convertImage(t):t.type=="LEADER"?this.convertLeader(t):t.type=="LINE"?this.convertLine(t):t.type=="MTEXT"?this.convertMText(t):t.type=="POLYLINE"||t.type=="LWPOLYLINE"?this.convertPolyline(t):t.type=="POINT"?this.convertPoint(t):t.type=="RAY"?this.convertRay(t):t.type=="SPLINE"?this.convertSpline(t):t.type=="ACAD_TABLE"?this.convertTable(t):t.type=="TEXT"?this.convertText(t):t.type=="SOLID"?this.convertSolid(t):t.type=="VIEWPORT"?this.convertViewport(t):t.type=="WIPEOUT"?this.convertWipeout(t):t.type=="XLINE"?this.convertXline(t):t.type=="INSERT"?this.convertBlockReference(t):null}convertArc(t){return new mi(t.center,t.radius,C.degToRad(t.startAngle),C.degToRad(t.endAngle))}convertCirle(t){return new gi(t.center,t.radius)}convertEllipse(t){const e=new w(t.majorAxisEndPoint),s=e.length();return new ui(t.center,w.Z_AXIS,e,s,s*t.axisRatio,t.startAngle,t.endAngle)}convertLine(t){const e=t.startPoint,s=t.endPoint;return new bi(new b(e.x,e.y,e.z||0),new b(s.x,s.y,s.z||0))}convertSpline(t){if(t.numberOfControlPoints>0&&t.numberOfKnots>0)return new an(t.controlPoints,t.knots,t.weights,t.degree,!!(t.flag&1));if(t.numberOfFitPoints>0){const e=this.numberArrayToPointArray(t.fitPoints,t.numberOfFitPoints);if(e!=null)return new an(e,"Uniform",t.degree,!!(t.flag&1))}return null}convertPoint(t){const e=new vi;return e.position=t.position,e}convertSolid(t){const e=new Si;return t.points.forEach((s,r)=>e.setPointAt(r,s)),e.thickness=t.thickness,e}convertPolyline(t){const e=new Mi;return e.closed=!!(t.flag&1),t.vertices.forEach((s,r)=>{e.addVertexAt(r,new L(s.x,s.y),s.bulge,s.startWidth,s.endWidth)}),e}convertHatch(t){var r;const e=new _i;return(r=t.definitionLines)==null||r.forEach(i=>{e.definitionLines.push({angle:i.angle,origin:i.base,delta:i.offset,dashPattern:i.numberOfDashLengths>0?i.dashLengths:[]})}),e.hatchStyle=t.hatchStyle,e.patternName=t.patternName,e.patternType=t.patternType,e.patternAngle=t.patternAngle==null?0:t.patternAngle,e.patternScale=t.patternScale==null?0:t.patternScale,t.boundaryPaths.forEach(i=>{if(i.boundaryPathTypeFlag&2){const o=i,c=new Ce;c.closed=o.isClosed,o.vertices.forEach((l,d)=>{c.addVertexAt(d,{x:l.x,y:l.y,bulge:l.bulge})}),e.add(c)}else{const o=i,c=new hi;o.edges.forEach(l=>{if(l.type==1){const d=l;c.add(new ns(d.start,d.end))}else if(l.type==2){const d=l;c.add(new oe(d.center,d.radius,C.degToRad(d.startAngle||0),C.degToRad(d.endAngle||0),!d.isCCW))}else if(l.type==3){const d=l;new B().subVectors(d.end,d.center);const m=Math.sqrt(Math.pow(d.end.x,2)+Math.pow(d.end.y,2)),p=m*d.lengthOfMinorAxis;let y=C.degToRad(d.startAngle||0),_=C.degToRad(d.endAngle||0);const x=Math.atan2(d.end.y,d.end.x);d.isCCW||(y=Math.PI*2-y,_=Math.PI*2-_),c.add(new es({...d.center,z:0},m,p,y,_,!d.isCCW,x))}else if(l.type==4){const d=l;if(d.numberOfControlPoints>0&&d.numberOfKnots>0){const u=d.controlPoints.map(y=>({x:y.x,y:y.y,z:0}));let m=!0;const p=d.controlPoints.map(y=>(y.weight==null&&(m=!1),y.weight||1));c.add(new Dt(u,d.knots,m?p:void 0))}else if(d.numberOfFitData>0){const u=d.fitDatum.map(m=>({x:m.x,y:m.y,z:0}));c.add(new Dt(u,"Uniform"))}}}),e.add(c)}}),e}convertTable(t){const e=new Ai(t.name,t.rowCount,t.columnCount);return e.attachmentPoint=t.attachmentPoint,e.position.copy(t.startPoint),t.columnWidthArr.forEach((s,r)=>e.setColumnWidth(r,s)),t.rowHeightArr.forEach((s,r)=>e.setRowHeight(r,s)),t.cells.forEach((s,r)=>{e.setCell(r,s)}),e}convertText(t){const e=new Ti;return e.textString=t.text,e.styleName=t.styleName,e.height=t.textHeight,e.position.copy(t.startPoint),e.rotation=C.degToRad(t.rotation||0),e.oblique=t.obliqueAngle??0,e.thickness=t.thickness,e.horizontalMode=t.halign,e.verticalMode=t.valign,e.widthFactor=t.xScale??1,e}convertMText(t){const e=new wi;return e.contents=t.text.join(""),t.styleName!=null&&(e.styleName=t.styleName),e.height=t.height,e.width=t.width,e.rotation=C.degToRad(t.rotation||0),e.location=t.insertionPoint,e.attachmentPoint=t.attachmentPoint,t.direction&&(e.direction=new w(t.direction)),e.drawingDirection=t.drawingDirection,e}convertLeader(t){const e=new xi;return t.vertices.forEach(s=>{e.appendVertex(s)}),e.hasArrowHead=t.isArrowheadEnabled,e.hasHookLine=t.isHooklineExists,e.isSplined=t.isSpline,e.dimensionStyle=t.styleName,e.annoType=t.leaderCreationFlag,e}convertDimension(t){if(t.subclassMarker=="AcDbAlignedDimension"||t.subclassMarker=="AcDbRotatedDimension"){const e=t,s=new Bi(e.subDefinitionPoint1,e.subDefinitionPoint2,e.definitionPoint);return s.rotation=C.degToRad(e.rotationAngle||0),this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDb3PointAngularDimension"){const e=t,s=new Fi(e.centerPoint,e.subDefinitionPoint1,e.subDefinitionPoint2,e.definitionPoint);return this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDbOrdinateDimension"){const e=t,s=new ji(e.subDefinitionPoint1,e.subDefinitionPoint2);return this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDbRadialDimension"){const e=t,s=new Gi(e.definitionPoint,e.centerPoint,e.leaderLength);return this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDbDiametricDimension"){const e=t,s=new Vi(e.definitionPoint,e.centerPoint,e.leaderLength);return this.processDimensionCommonAttrs(t,s),s}return null}processImage(t,e){e.position.copy(t.position),e.brightness=t.brightness,e.contrast=t.contrast,e.fade=t.fade,e.imageDefId=t.imageDefHandle,e.isClipped=(t.flags|4)>0,e.isImageShown=(t.flags|3)>0,e.isImageTransparent=(t.flags|8)>0,t.clippingBoundaryPath.forEach(s=>{e.clipBoundary.push(new L(s))}),e.clipBoundaryType=t.clippingBoundaryType,e.width=Math.sqrt(t.uPixel.x**2+t.uPixel.y**2+t.uPixel.z**2)*t.imageSize.x,e.height=Math.sqrt(t.vPixel.x**2+t.vPixel.y**2+t.vPixel.z**2)*t.imageSize.y,e.rotation=Math.atan2(t.uPixel.y,t.uPixel.x)}convertImage(t){const e=new on;return this.processImage(t,e),e}convertWipeout(t){const e=new Di;return this.processImage(t,e),e}convertViewport(t){const e=new Ni;return e.number=t.viewportId,e.centerPoint.copy(t.viewportCenter),e.height=t.height,e.width=t.width,e.viewCenter.copy(t.displayCenter),e.viewHeight=t.viewHeight,e}convertRay(t){const e=new Oi;return e.basePoint.copy(t.firstPoint),e.unitDir.copy(t.unitDirection),e}convertXline(t){const e=new Ri;return e.basePoint.copy(t.firstPoint),e.unitDir.copy(t.unitDirection),e}convertBlockReference(t){const e=new tn(t.name);return t.insertionPoint&&e.position.copy(t.insertionPoint),e.scaleFactors.x=t.xScale||1,e.scaleFactors.y=t.yScale||1,e.scaleFactors.z=t.zScale||1,e.rotation=t.rotation!=null?C.degToRad(t.rotation):0,e.normal.copy(t.extrusionDirection),e}processDimensionCommonAttrs(t,e){e.dimBlockId=t.name,e.textPosition.copy(t.textPoint),e.textRotation=t.textRotation||0,t.textLineSpacingFactor&&(e.textLineSpacingFactor=t.textLineSpacingFactor),t.textLineSpacingStyle&&(e.textLineSpacingStyle=t.textLineSpacingStyle),e.dimensionStyleName=t.styleName,e.dimensionText=t.text||"",e.measurement=t.measurement}processCommonAttrs(t,e){e.layer=t.layer,e.objectId=t.handle,e.ownerId=t.ownerBlockRecordSoftId||"",t.lineType!=null&&(e.lineType=t.lineType),t.lineweight!=null&&(e.lineWeight=t.lineweight),t.lineTypeScale!=null&&(e.linetypeScale=t.lineTypeScale),t.color!=null&&(e.color.color=t.color),t.colorIndex!=null&&(e.color.colorIndex=t.colorIndex),t.colorName!=null&&(e.color.colorName=t.colorName),t.isVisible!=null&&(e.visibility=t.isVisible),t.transparency!=null&&(e.transparency=t.transparency)}numberArrayToPointArray(t,e){const s=t.length;let r=0;if(s/2==e?r=2:s/3==e&&(r=3),r==0)return;const i=[];for(let a=0,o=s/r;a<o;++a)i.push({x:t[a*r],y:t[a*r+1],z:r==3?t[a*r+2]:0});return i}}class hn extends Rt{constructor(){super(),this._tabOrder=-1,this._tabSelected=!1,this._blockTableRecordId="",this._layoutName="",this._limits=new K,this._extents=new O}get layoutName(){return this._layoutName}set layoutName(t){this._layoutName=t.length>256?t.slice(0,256):t}get tabOrder(){return this._tabOrder}set tabOrder(t){this._tabOrder=t}get tabSelected(){return this._tabSelected}set tabSelected(t){this._tabSelected=t}get blockTableRecordId(){return this._blockTableRecordId}set blockTableRecordId(t){this._blockTableRecordId=t}get limits(){return this._limits}set limits(t){this._limits.copy(t)}get extents(){return this._extents}set extents(t){this._extents.copy(t)}}class ln extends Rt{constructor(t){super(),this.database=t,this._recordsByName=new Map,this._recordsById=new Map}get numEntries(){return this._recordsByName.size}setAt(t,e){e.database=this.database,this._recordsByName.set(t,e),this._recordsById.set(e.objectId,e)}remove(t){return this.getAt(t)?(this._recordsByName.delete(t.toUpperCase()),this._recordsById.delete(this.objectId),!0):!1}removeId(t){const e=this.getIdAt(t);return e?(this._recordsById.delete(this.objectId),this._recordsByName.forEach((s,r)=>{s===e&&this._recordsByName.delete(r)}),!0):!1}removeAll(){this._recordsByName.clear(),this._recordsById.clear()}has(t){return this._recordsByName.has(t.toUpperCase())}hasId(t){return this._recordsById.has(t)}getAt(t){return this._recordsByName.get(t)}getIdAt(t){return this._recordsById.get(t)}newIterator(){return new $e(this._recordsByName)}}class Ui extends ln{getBtrIdAt(t){for(const[e,s]of this._recordsByName)if(s.blockTableRecordId==t)return s}get maxTabOrder(){let t=-1;return this._recordsByName.forEach(e=>{e.tabOrder>t&&(t=e.tabOrder)}),t}}class Wi extends Rt{constructor(){super(),this._sourceFileName=""}get sourceFileName(){return this._sourceFileName}set sourceFileName(t){this._sourceFileName=t}}class rh{convertLayout(t){const e=new hn;return e.layoutName=t.layoutName,e.tabOrder=t.tabOrder,e.blockTableRecordId=t.ownerObjectId,e.limits.min.copy(t.minLimit),e.limits.max.copy(t.maxLimit),e.extents.min.copy(t.minExtent),e.extents.max.copy(t.maxExtent),this.processCommonAttrs(t,e),e}convertImageDef(t){const e=new Wi;return e.sourceFileName=t.fileName,this.processCommonAttrs(t,e),e}processCommonAttrs(t,e){e.objectId=t.handle,e.ownerId=t.ownerObjectId}}class Yi extends Tr{parse(t){return new Wo().parseSync(t)}getFonts(t){var i;const e=new Map,s=a=>{if(a){const o=a.lastIndexOf(".");return o>=0?a.substring(0,o).toLowerCase():a.toLowerCase()}};(i=t.tables.STYLE)==null||i.entries.forEach(a=>{const o=[];let c=s(a.font);c&&o.push(c),c=s(a.bigFont),c&&o.push(c),e.set(a.name,o)});const r=new Set;return this.getFontsInBlock(t.entities,t.blocks,e,r),Array.from(r)}getFontsInBlock(t,e,s,r){const i=/\\f(.*?)\|/g;t.forEach(a=>{if(a.type=="MTEXT"){const o=a;[...o.text.join("").matchAll(i)].forEach(d=>{r.add(d[1].toLowerCase())});const l=s.get(o.styleName);l==null||l.forEach(d=>r.add(d))}else if(a.type=="TEXT"){const o=a,c=s.get(o.styleName);c==null||c.forEach(l=>r.add(l))}else if(a.type=="INSERT"){const c=e[a.name];c&&c.entities&&this.getFontsInBlock(c.entities,e,s,r)}})}async processEntities(t,e,s,r,i){const a=new Hi,o=t.entities,c=o.length,l=new Pn(c,100-r.value,s),d=e.tables.blockTable.modelSpace,u=e.tables.blockTable;await l.processChunk(async(m,p)=>{for(let y=m;y<p;y++){const _=o[y],x=a.convert(_);if(x){let f=d;_.ownerBlockRecordSoftId!=null&&(f=u.getIdAt(_.ownerBlockRecordSoftId)||f),f.appendEntity(x)}}if(i){let y=r.value+p/c*(100-r.value);y>100&&(y=100),await i(y,"ENTITY","IN-PROGRESS")}})}async processEntitiesInBlock(t,e,s){const r=new Hi,i=t.length;for(let a=0;a<i;a++){const o=t[a],c=r.convert(o);if(c){let l=e;o.ownerBlockRecordSoftId!=null&&(l=s.getIdAt(o.ownerBlockRecordSoftId)||l),l.appendEntity(c)}}}processBlocks(t,e){const s=t.blocks;for(const[r,i]of Object.entries(s)){let a=e.tables.blockTable.getAt(i.name);a||(a=new Mt,a.objectId=i.handle,a.name=r,a.origin.copy(i.position),e.tables.blockTable.add(a)),i.entities&&this.processEntitiesInBlock(i.entities,a,e.tables.blockTable)}}processHeader(t,e){const s=t.header;e.cecolor.colorIndex=s.$CECOLOR||256,e.angBase=s.$ANGBASE||0,e.angDir=s.$ANGDIR||0,e.aunits=s.$AUNITS,e.insunits=s.$INSUNITS,e.pdmode=s.$PDMODE||0,e.pdsize=s.$PDSIZE||0}processBlockTables(t,e){var r;const s=(r=t.tables.BLOCK_RECORD)==null?void 0:r.entries;s&&s.length>0&&(e.tables.blockTable.removeAll(),s.forEach(i=>{const a=new Mt;a.objectId=i.handle,a.name=i.name,e.tables.blockTable.add(a)}))}processObjects(t,e){const s=t.objects.byName,r=new rh;if("LAYOUT"in s){const i=e.dictionaries.layouts;s.LAYOUT.forEach(a=>{const o=r.convertLayout(a);i.setAt(o.layoutName,o)})}if("IMAGEDEF"in s){const i=e.dictionaries.imageDefs;s.IMAGEDEF.forEach(a=>{const o=r.convertImageDef(a);i.setAt(o.objectId,o)})}}processViewports(t,e){var r,i;const s=(i=(r=t.tables)==null?void 0:r.VPORT)==null?void 0:i.entries;s&&s.length>0&&s.forEach(a=>{const o=new aa;this.processCommonTableEntryAttrs(a,o),a.circleSides&&(o.circleSides=a.circleSides),o.standardFlag=a.standardFlag,o.center.copy(a.center),o.lowerLeftCorner.copy(a.lowerLeftCorner),o.upperRightCorner.copy(a.upperRightCorner),a.snapBasePoint&&o.snapBase.copy(a.snapBasePoint),a.snapRotationAngle&&(o.snapAngle=a.snapRotationAngle),a.snapSpacing&&o.snapIncrements.copy(a.snapSpacing),a.majorGridLines&&(o.gridMajor=a.majorGridLines),a.gridSpacing&&o.gridIncrements.copy(a.gridSpacing),a.backgroundObjectId&&(o.backgroundObjectId=a.backgroundObjectId),o.gsView.center.copy(a.center),o.gsView.viewDirectionFromTarget.copy(a.viewDirectionFromTarget),o.gsView.viewTarget.copy(a.viewTarget),a.lensLength&&(o.gsView.lensLength=a.lensLength),a.frontClippingPlane&&(o.gsView.frontClippingPlane=a.frontClippingPlane),a.backClippingPlane&&(o.gsView.backClippingPlane=a.backClippingPlane),a.viewHeight&&(o.gsView.viewHeight=a.viewHeight),a.viewTwistAngle&&(o.gsView.viewTwistAngle=a.viewTwistAngle),a.frozenLayers&&(o.gsView.frozenLayers=a.frozenLayers),a.styleSheet&&(o.gsView.styleSheet=a.styleSheet),a.renderMode&&(o.gsView.renderMode=a.renderMode),a.viewMode&&(o.gsView.viewMode=a.viewMode),a.ucsIconSetting&&(o.gsView.ucsIconSetting=a.ucsIconSetting),a.ucsOrigin&&o.gsView.ucsOrigin.copy(a.ucsOrigin),a.ucsXAxis&&o.gsView.ucsXAxis.copy(a.ucsXAxis),a.ucsYAxis&&o.gsView.ucsYAxis.copy(a.ucsYAxis),a.orthographicType&&(o.gsView.orthographicType=a.orthographicType),a.shadePlotSetting&&(o.gsView.shadePlotSetting=a.shadePlotSetting),a.shadePlotObjectId&&(o.gsView.shadePlotObjectId=a.shadePlotObjectId),a.visualStyleObjectId&&(o.gsView.visualStyleObjectId=a.visualStyleObjectId),a.isDefaultLightingOn&&(o.gsView.isDefaultLightingOn=a.isDefaultLightingOn),a.defaultLightingType&&(o.gsView.defaultLightingType=a.defaultLightingType),a.brightness&&(o.gsView.brightness=a.brightness),a.contrast&&(o.gsView.contrast=a.contrast),a.ambientColor&&(o.gsView.ambientColor=a.ambientColor),e.tables.viewportTable.add(o)})}processLayers(t,e){var r,i;const s=(i=(r=t.tables)==null?void 0:r.LAYER)==null?void 0:i.entries;s&&s.length>0&&s.forEach(a=>{const o=new zt;o.colorIndex=a.colorIndex;const c=new cn({name:a.name,standardFlags:a.standardFlag,linetype:a.lineType,lineWeight:a.lineweight,isOff:a.colorIndex<0,color:o,isPlottable:a.isPlotting});this.processCommonTableEntryAttrs(a,c),e.tables.layerTable.add(c)})}processLineTypes(t,e){var r,i;const s=(i=(r=t.tables)==null?void 0:r.LTYPE)==null?void 0:i.entries;s&&s.length>0&&s.forEach(a=>{const o=new ra(a);this.processCommonTableEntryAttrs(a,o),o.name=a.name,e.tables.linetypeTable.add(o)})}processTextStyles(t,e){var r;const s=(r=t.tables.STYLE)==null?void 0:r.entries;s&&s.length>0&&s.forEach(i=>{const a=new ia(i);this.processCommonTableEntryAttrs(i,a),e.tables.textStyleTable.add(a)})}processDimStyles(t,e){var r;const s=(r=t.tables.DIMSTYLE)==null?void 0:r.entries;s&&s.length>0&&s.forEach(i=>{const a={name:i.name,ownerId:i.ownerObjectId,dimpost:i.DIMPOST||"",dimapost:i.DIMAPOST||"",dimscale:i.DIMSCALE,dimasz:i.DIMASZ,dimexo:i.DIMEXO,dimdli:i.DIMDLI,dimexe:i.DIMEXE,dimrnd:i.DIMRND,dimdle:i.DIMDLE,dimtp:i.DIMTP,dimtm:i.DIMTM,dimtxt:i.DIMTXT,dimcen:i.DIMCEN,dimtsz:i.DIMTSZ,dimaltf:i.DIMALTF,dimlfac:i.DIMLFAC,dimtvp:i.DIMTVP,dimtfac:i.DIMTFAC,dimgap:i.DIMGAP,dimaltrnd:i.DIMALTRND,dimtol:i.DIMTOL==null||i.DIMTOL==0?0:1,dimlim:i.DIMLIM==null||i.DIMLIM==0?0:1,dimtih:i.DIMTIH==null||i.DIMTIH==0?0:1,dimtoh:i.DIMTOH==null||i.DIMTOH==0?0:1,dimse1:i.DIMSE1==null||i.DIMSE1==0?0:1,dimse2:i.DIMSE2==null||i.DIMSE2==0?0:1,dimtad:i.DIMTAD,dimzin:i.DIMZIN,dimazin:i.DIMAZIN,dimalt:i.DIMALT,dimaltd:i.DIMALTD,dimtofl:i.DIMTOFL,dimsah:i.DIMSAH,dimtix:i.DIMTIX,dimsoxd:i.DIMSOXD,dimclrd:i.DIMCLRD,dimclre:i.DIMCLRE,dimclrt:i.DIMCLRT,dimadec:i.DIMADEC||0,dimunit:i.DIMUNIT||2,dimdec:i.DIMDEC,dimtdec:i.DIMTDEC,dimaltu:i.DIMALTU,dimalttd:i.DIMALTTD,dimaunit:i.DIMAUNIT,dimfrac:i.DIMFRAC,dimlunit:i.DIMLUNIT,dimdsep:i.DIMDSEP,dimtmove:i.DIMTMOVE||0,dimjust:i.DIMJUST,dimsd1:i.DIMSD1,dimsd2:i.DIMSD2,dimtolj:i.DIMTOLJ,dimtzin:i.DIMTZIN,dimaltz:i.DIMALTZ,dimalttz:i.DIMALTTZ,dimfit:i.DIMFIT||0,dimupt:i.DIMUPT,dimatfit:i.DIMATFIT,dimtxsty:i.DIMTXSTY||"Standard",dimldrblk:i.DIMLDRBLK||"",dimblk:i.DIMBLK||"",dimblk1:i.DIMBLK1||"",dimblk2:i.DIMBLK2||"",dimlwd:i.DIMLWD,dimlwe:i.DIMLWE},o=new Ne(a);this.processCommonTableEntryAttrs(i,o),e.tables.dimStyleTable.add(o)})}processCommonTableEntryAttrs(t,e){e.name=t.name,e.objectId=t.handle,e.ownerId=t.ownerObjectId}}var Oe=(n=>(n.DXF="dxf",n.DWG="dwg",n))(Oe||{});class yt{constructor(){this.events={registered:new st,unregistered:new st},this._converters=new Map,this.register("dxf",new Yi)}static createInstance(){return yt._instance==null&&(yt._instance=new yt),this._instance}static get instance(){return yt._instance||(yt._instance=new yt),yt._instance}get fileTypes(){return this._converters.keys()}register(t,e){this._converters.set(t,e),this.events.registered.dispatch({fileType:t,converter:e})}get(t){return this._converters.get(t)}unregister(t){const e=this._converters.get(t);e&&(this._converters.delete(t),this.events.unregistered.dispatch({fileType:t,converter:e}))}}class Zt extends Rt{constructor(t,e){t=t||{},ee(t,{name:""}),super(t,e)}get name(){return this.getAttr("name")}set name(t){this.setAttr("name",t)}}const le=class le extends Zt{constructor(){super(),this._origin=new b,this._entities=new Map}get isModelSapce(){return this.name.toLowerCase()==le.MODEL_SPACE_NAME.toLowerCase()}get isPaperSapce(){return this.name.toLowerCase().startsWith(le.PAPER_SPACE_NAME_PREFIX.toLowerCase())}get origin(){return this._origin}set origin(t){this._origin.copy(t)}appendEntity(t){t.database=this.database,t.ownerId=this.objectId,this._entities.set(t.objectId,t),(this.isModelSapce||this.isPaperSapce)&&this.database.events.entityAppended.dispatch({database:this.database,entity:t})}newIterator(){return new $e(this._entities)}getIdAt(t){return this._entities.get(t)}};le.MODEL_SPACE_NAME="*Model_Space",le.PAPER_SPACE_NAME_PREFIX="*Paper_Space";let Mt=le;class Qt extends Rt{constructor(t){super(),this.database=t,this._recordsByName=new Map,this._recordsById=new Map}add(t){t.database=this.database,this._recordsByName.set(t.name,t),this._recordsById.set(t.objectId,t)}remove(t){const e=this._recordsByName.get(t);return e?(this._recordsById.delete(e.objectId),this._recordsByName.delete(t),!0):!1}removeId(t){const e=this._recordsById.get(t);return e?(this._recordsByName.delete(e.name),this._recordsById.delete(t),!0):!1}removeAll(){this._recordsByName.clear(),this._recordsById.clear()}has(t){return this._recordsByName.has(t)}hasId(t){return this._recordsById.has(t)}getAt(t){return this._recordsByName.get(t)}getIdAt(t){return this._recordsById.get(t)}getOwnerIdAt(t){return this._recordsById.get(t)}newIterator(){return new $e(this._recordsByName)}}class qi extends Qt{constructor(t){super(t)}get modelSpace(){let t=this.getAt(Mt.MODEL_SPACE_NAME);return t||(t=new Mt,t.name=Mt.MODEL_SPACE_NAME,this.add(t)),t}}class Xi extends Qt{constructor(t){super(t)}}class cn extends Zt{constructor(t,e){t=t||{},ee(t,{color:new zt,description:"",standardFlags:0,isHidden:!1,isInUse:!0,isOff:!1,isPlottable:!0,transparency:0,linetype:"",lineWeight:1,materialId:-1}),super(t,e),this.attrs.events.attrChanged.addEventListener(s=>{this.database.events.layerModified.dispatch({database:this.database,layer:this,changes:s.object.changedAttributes()})})}get color(){return this.getAttr("color")}set color(t){this.setAttr("color",t.clone())}get description(){return this.getAttr("description")}set description(t){this.setAttr("description",t)}get standardFlags(){return this.getAttr("standardFlags")}set standardFlags(t){this.setAttr("standardFlags",t)}get isFrozen(){return(this.standardFlags&1)==1}set isFrozen(t){const e=t?1:0;this.standardFlags=this.standardFlags|e}get isHidden(){return this.getAttr("isHidden")}set isHidden(t){this.setAttr("isHidden",t)}get isInUse(){return this.getAttr("isInUse")}set isInUse(t){this.setAttr("isInUse",t)}get isLocked(){return(this.standardFlags&4)==4}set isLocked(t){const e=t?4:0;this.standardFlags=this.standardFlags|e}get isOff(){return this.getAttr("isOff")}set isOff(t){this.setAttr("isOff",t)}get isPlottable(){return this.getAttr("isPlottable")}set isPlottable(t){this.setAttr("isPlottable",t)}get transparency(){return this.getAttr("transparency")}set transparency(t){this.setAttr("transparency",t)}get linetype(){return this.getAttr("linetype")}set linetype(t){this.setAttr("linetype",t)}get lineWeight(){return this.getAttr("lineWeight")}set lineWeight(t){this.setAttr("lineWeight",t)}get materialId(){return this.getAttr("materialId")}set materialId(t){this.setAttr("materialId",t)}}class $i extends Qt{constructor(t){super(t);const e=new zt;e.color=16777215;const s=new cn({name:"0",standardFlags:0,linetype:qe,lineWeight:1,isOff:!1,color:e,isPlottable:!0});this.add(s)}add(t){super.add(t),this.database.events.layerAppended.dispatch({database:this.database,layer:t})}}class Ki extends Qt{constructor(t){super(t)}}class Zi extends Qt{constructor(t){super(t)}get fonts(){const t=new Set,e=r=>{if(r){const i=r.lastIndexOf(".");if(i>=0){const a=r.substring(0,i).toLowerCase();t.add(a)}else t.add(r.toLowerCase())}},s=this.newIterator();for(const r of s)e(r.fileName),e(r.bigFontFileName);return Array.from(t)}}class Qi extends Qt{constructor(t){super(t)}}class ih extends Rt{constructor(){super(),this.events={entityAppended:new st,entityModified:new st,layerAppended:new st,layerModified:new st,layerErased:new st,openProgress:new st,headerSysVarChanged:new st},this._angBase=0,this._angDir=0,this._aunits=Ns.DecimalDegrees,this._celtscale=1,this._cecolor=new zt,this._insunits=Ds.Millimeters,this._ltscale=1,this._pdmode=0,this._pdsize=0,this._tables={blockTable:new qi(this),dimStyleTable:new Xi(this),linetypeTable:new Ki(this),textStyleTable:new Zi(this),layerTable:new $i(this),viewportTable:new Qi(this)},this._dictionaries={layouts:new Ui(this),imageDefs:new ln(this)}}get tables(){return this._tables}get dictionaries(){return this._dictionaries}get currentSpaceId(){return this._currentSpace||(this._currentSpace=this._tables.blockTable.modelSpace),this._currentSpace.objectId}set currentSpaceId(t){const e=this.tables.blockTable.getIdAt(t);if(e==null)throw new Error(`[AcDbDatabase] The specified block table record id '${t}' doesn't exist in the drawing database!`);this._currentSpace=e}get aunits(){return this._aunits}set aunits(t){this._aunits=t||0,this.triggerHeaderSysVarChangedEvent("aunits")}get insunits(){return this._insunits}set insunits(t){this._insunits=t||4,this.triggerHeaderSysVarChangedEvent("insunits")}get ltscale(){return this._ltscale}set ltscale(t){this._ltscale=t||1,this.triggerHeaderSysVarChangedEvent("ltscale")}get cecolor(){return this._cecolor}set cecolor(t){this._cecolor=t||0,this.triggerHeaderSysVarChangedEvent("cecolor")}get celtscale(){return this._celtscale}set celtscale(t){this._celtscale=t||1,this.triggerHeaderSysVarChangedEvent("celtscale")}get angBase(){return this._angBase}set angBase(t){this._angBase=t||0,this.triggerHeaderSysVarChangedEvent("angbase")}get angDir(){return this._angDir}set angDir(t){this._angDir=t||0,this.triggerHeaderSysVarChangedEvent("angdir")}get pdmode(){return this._pdmode}set pdmode(t){this._pdmode=t||0,this.triggerHeaderSysVarChangedEvent("pdmode")}get pdsize(){return this._pdsize}set pdsize(t){this._pdsize=t||0,this.triggerHeaderSysVarChangedEvent("pdsize")}async read(t,e,s=Oe.DXF){const r=yt.instance.get(s);if(r==null)throw new Error(`Database converter for file type '${s}' isn't registered and can can't read this file!`);this.clear(),await r.read(t,this,e&&e.minimumChunkSize||10,async(i,a,o,c)=>{if(this.events.openProgress.dispatch({database:this,percentage:i,stage:"CONVERSION",subStage:a,stageStatus:o}),e&&e.fontLoader&&a=="FONT"&&o=="END"){const l=c||this.tables.textStyleTable.fonts;await e.fontLoader.load(l)}})}async openUri(t,e){this.events.openProgress.dispatch({database:this,percentage:0,stage:"FETCH_FILE",stageStatus:"START"});const s=await fetch(t);if(this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",stageStatus:"END"}),!s.ok)throw new Error(`Failed to fetch file '${t}' with HTTP status codee '${s.status}'!`);if(t.toLowerCase().split(".").pop()==="dwg"){const i=await s.arrayBuffer();await this.read(i,e,Oe.DWG)}else{const i=await s.text();await this.read(i,e,Oe.DXF)}}clear(){this._tables.blockTable.removeAll(),this._tables.dimStyleTable.removeAll(),this._tables.linetypeTable.removeAll(),this._tables.textStyleTable.removeAll(),this._tables.layerTable.removeAll(),this._tables.viewportTable.removeAll(),this._dictionaries.layouts.removeAll(),this._currentSpace=void 0}triggerHeaderSysVarChangedEvent(t){this.events.headerSysVarChanged.dispatch({database:this,name:t})}}var Ji=(n=>(n[n.Center=0]="Center",n[n.Left=1]="Left",n[n.Right=2]="Right",n[n.OverFirst=3]="OverFirst",n[n.OverSecond=4]="OverSecond",n))(Ji||{}),ta=(n=>(n[n.Center=0]="Center",n[n.Above=1]="Above",n[n.Outside=2]="Outside",n[n.JIS=3]="JIS",n[n.Below=4]="Below",n))(ta||{}),ea=(n=>(n[n.Feet=0]="Feet",n[n.None=1]="None",n[n.Inch=2]="Inch",n[n.FeetAndInch=3]="FeetAndInch",n[n.Leading=4]="Leading",n[n.Trailing=8]="Trailing",n[n.LeadingAndTrailing=12]="LeadingAndTrailing",n))(ea||{}),sa=(n=>(n[n.None=0]="None",n[n.Leading=1]="Leading",n[n.Trailing=2]="Trailing",n[n.LeadingAndTrailing=3]="LeadingAndTrailing",n))(sa||{}),na=(n=>(n[n.Bottom=0]="Bottom",n[n.Middle=1]="Middle",n[n.Top=2]="Top",n))(na||{});const ls=class ls extends Zt{constructor(t,e){t=t||{},ee(t,ls.DEFAULT_DIM_VALUES),super(t,e)}get dimpost(){return this.getAttr("dimpost")}set dimpost(t){this.setAttr("dimpost",t)}get dimapost(){return this.getAttr("dimapost")}set dimapost(t){this.setAttr("dimapost",t)}get dimscale(){return this.getAttr("dimscale")}set dimscale(t){this.setAttr("dimscale",t)}get dimasz(){return this.getAttr("dimasz")}set dimasz(t){this.setAttr("dimasz",t)}get dimexo(){return this.getAttr("dimexo")}set dimexo(t){this.setAttr("dimexo",t)}get dimdli(){return this.getAttr("dimdli")}set dimdli(t){this.setAttr("dimdli",t)}get dimexe(){return this.getAttr("dimexe")}set dimexe(t){this.setAttr("dimexe",t)}get dimrnd(){return this.getAttr("dimrnd")}set dimrnd(t){this.setAttr("dimrnd",t)}get dimdle(){return this.getAttr("dimdle")}set dimdle(t){this.setAttr("dimdle",t)}get dimtp(){return this.getAttr("dimtp")}set dimtp(t){this.setAttr("dimtp",t)}get dimtm(){return this.getAttr("dimtm")}set dimtm(t){this.setAttr("dimtm",t)}get dimtxt(){return this.getAttr("dimtxt")}set dimtxt(t){this.setAttr("dimtxt",t)}get dimcen(){return this.getAttr("dimcen")}set dimcen(t){this.setAttr("dimcen",t)}get dimtsz(){return this.getAttr("dimtsz")}set dimtsz(t){this.setAttr("dimtsz",t)}get dimaltf(){return this.getAttr("dimaltf")}set dimaltf(t){this.setAttr("dimaltf",t)}get dimlfac(){return this.getAttr("dimlfac")}set dimlfac(t){this.setAttr("dimlfac",t)}get dimtvp(){return this.getAttr("dimtvp")}set dimtvp(t){this.setAttr("dimtvp",t)}get dimtfac(){return this.getAttr("dimtfac")}set dimtfac(t){this.setAttr("dimtfac",t)}get dimgap(){return this.getAttr("dimgap")}set dimgap(t){this.setAttr("dimgap",t)}get dimaltrnd(){return this.getAttr("dimaltrnd")}set dimaltrnd(t){this.setAttr("dimaltrnd",t)}get dimtol(){return this.getAttr("dimtol")}set dimtol(t){this.setAttr("dimtol",t)}get dimlim(){return this.getAttr("dimlim")}set dimlim(t){this.setAttr("dimlim",t)}get dimtih(){return this.getAttr("dimtih")}set dimtih(t){this.setAttr("dimtih",t)}get dimtoh(){return this.getAttr("dimtoh")}set dimtoh(t){this.setAttr("dimtoh",t)}get dimse1(){return this.getAttr("dimse1")}set dimse1(t){this.setAttr("dimse1",t)}get dimse2(){return this.getAttr("dimse2")}set dimse2(t){this.setAttr("dimse2",t)}get dimtad(){return this.getAttr("dimtad")}set dimtad(t){this.setAttr("dimtad",t)}get dimzin(){return this.getAttr("dimzin")}set dimzin(t){this.setAttr("dimzin",t)}get dimazin(){return this.getAttr("dimazin")}set dimazin(t){this.setAttr("dimazin",t)}get dimalt(){return this.getAttr("dimalt")}set dimalt(t){this.setAttr("dimalt",t)}get dimaltd(){return this.getAttr("dimaltd")}set dimaltd(t){this.setAttr("dimaltd",t)}get dimtofl(){return this.getAttr("dimtofl")}set dimtofl(t){this.setAttr("dimtofl",t)}get dimsah(){return this.getAttr("dimsah")}set dimsah(t){this.setAttr("dimsah",t)}get dimtix(){return this.getAttr("dimtix")}set dimtix(t){this.setAttr("dimtix",t)}get dimsoxd(){return this.getAttr("dimsoxd")}set dimsoxd(t){this.setAttr("dimsoxd",t)}get dimclrd(){return this.getAttr("dimclrd")}set dimclrd(t){this.setAttr("dimclrd",t)}get dimclre(){return this.getAttr("dimclre")}set dimclre(t){this.setAttr("dimclre",t)}get dimclrt(){return this.getAttr("dimclrt")}set dimclrt(t){this.setAttr("dimclrt",t)}get dimadec(){return this.getAttr("dimadec")}set dimadec(t){this.setAttr("dimadec",t)}get dimunit(){return this.getAttr("dimunit")}set dimunit(t){this.setAttr("dimunit",t)}get dimdec(){return this.getAttr("dimdec")}set dimdec(t){this.setAttr("dimdec",t)}get dimtdec(){return this.getAttr("dimtdec")}set dimtdec(t){this.setAttr("dimtdec",t)}get dimaltu(){return this.getAttr("dimaltu")}set dimaltu(t){this.setAttr("dimaltu",t)}get dimalttd(){return this.getAttr("dimalttd")}set dimalttd(t){this.setAttr("dimalttd",t)}get dimaunit(){return this.getAttr("dimaunit")}set dimaunit(t){this.setAttr("dimaunit",t)}get dimfrac(){return this.getAttr("dimfrac")}set dimfrac(t){this.setAttr("dimfrac",t)}get dimlunit(){return this.getAttr("dimlunit")}set dimlunit(t){this.setAttr("dimlunit",t)}get dimdsep(){return this.getAttr("dimdsep")}set dimdsep(t){this.setAttr("dimdsep",t)}get dimtmove(){return this.getAttr("dimtmove")}set dimtmove(t){this.setAttr("dimtmove",t)}get dimjust(){return this.getAttr("dimjust")}set dimjust(t){this.setAttr("dimjust",t)}get dimsd1(){return this.getAttr("dimsd1")}set dimsd1(t){this.setAttr("dimsd1",t)}get dimsd2(){return this.getAttr("dimsd2")}set dimsd2(t){this.setAttr("dimsd2",t)}get dimtolj(){return this.getAttr("dimtolj")}set dimtolj(t){this.setAttr("dimtolj",t)}get dimtzin(){return this.getAttr("dimtzin")}set dimtzin(t){this.setAttr("dimtzin",t)}get dimaltz(){return this.getAttr("dimaltz")}set dimaltz(t){this.setAttr("dimaltz",t)}get dimalttz(){return this.getAttr("dimalttz")}set dimalttz(t){this.setAttr("dimalttz",t)}get dimfit(){return this.getAttr("dimfit")}set dimfit(t){this.setAttr("dimfit",t)}get dimupt(){return this.getAttr("dimupt")}set dimupt(t){this.setAttr("dimupt",t)}get dimatfit(){return this.getAttr("dimatfit")}set dimatfit(t){this.setAttr("dimatfit",t)}get dimtxsty(){return this.getAttr("dimtxsty")}set dimtxsty(t){this.setAttr("dimtxsty",t)}get dimldrblk(){return this.getAttr("dimldrblk")}set dimldrblk(t){this.setAttr("dimldrblk",t)}get dimblk(){return this.getAttr("dimblk")}set dimblk(t){this.setAttr("dimblk",t)}get dimblk1(){return this.getAttr("dimblk1")}set dimblk1(t){this.setAttr("dimblk1",t)}get dimblk2(){return this.getAttr("dimblk2")}set dimblk2(t){this.setAttr("dimblk2",t)}get dimlwd(){return this.getAttr("dimlwd")}set dimlwd(t){this.setAttr("dimlwd",t)}get dimlwe(){return this.getAttr("dimlwe")}set dimlwe(t){this.setAttr("dimlwe",t)}};ls.DEFAULT_DIM_VALUES={name:"",dimpost:"",dimapost:"",dimscale:1,dimasz:2.5,dimexo:.625,dimdli:.38,dimexe:.18,dimrnd:0,dimdle:0,dimtp:0,dimtm:0,dimtxt:2.5,dimcen:2.5,dimtsz:0,dimaltf:0,dimlfac:1,dimtvp:0,dimtfac:1,dimgap:1,dimaltrnd:0,dimtol:0,dimlim:0,dimtih:0,dimtoh:0,dimse1:0,dimse2:0,dimtad:0,dimzin:0,dimazin:0,dimalt:0,dimaltd:2,dimtofl:0,dimsah:0,dimtix:0,dimsoxd:0,dimclrd:0,dimclre:0,dimclrt:0,dimadec:0,dimunit:2,dimdec:4,dimtdec:4,dimaltu:2,dimalttd:2,dimaunit:0,dimfrac:0,dimlunit:2,dimdsep:".",dimtmove:0,dimjust:0,dimsd1:0,dimsd2:0,dimtolj:0,dimtzin:0,dimaltz:0,dimalttz:0,dimfit:0,dimupt:0,dimatfit:3,dimtxsty:"Standard",dimldrblk:"",dimblk:"",dimblk1:"",dimblk2:"",dimlwd:-2,dimlwe:-2};let Ne=ls;class ra extends Zt{constructor(t){super(),this.name=t.name,this._linetype=t}get numDashes(){return this._linetype.pattern?this._linetype.pattern.length:0}get patternLength(){return this._linetype.totalPatternLength}get comments(){return this._linetype.description}get linetype(){return this._linetype}dashLengthAt(t){if(t<0||t>=this.numDashes)throw new Error('Index must be greater than or equal to zero, but less than the value of property "numDashes".');return this._linetype.pattern[t].elementLength}}class ia extends Zt{constructor(t){super(),this.name=t.name,this._textStyle=t,this._textStyle.font=this.getFileNameWithoutExtension(this._textStyle.font||this._textStyle.extendedFont||this.name),this._isVertical=!1}get obliquingAngle(){return this._textStyle.obliqueAngle}set obliquingAngle(t){this._textStyle.obliqueAngle=t}get priorSize(){return this._textStyle.lastHeight}set priorSize(t){this._textStyle.lastHeight=t}get textSize(){return this._textStyle.fixedTextHeight}set textSize(t){this._textStyle.fixedTextHeight=t}get xScale(){return this._textStyle.widthFactor}set xScale(t){this._textStyle.widthFactor=t}get isVertical(){return this._isVertical}set isVertical(t){this._isVertical=t}get fileName(){return this._textStyle.font}set fileName(t){this._textStyle.font=t}get bigFontFileName(){return this._textStyle.bigFont}set bigFontFileName(t){this._textStyle.bigFont=t}get textStyle(){return this._textStyle}getFileNameWithoutExtension(t){const e=t.split("/").pop();if(e){const s=e.lastIndexOf(".");return s===-1?e:e.substring(0,s)}return t}}const ah={center:new L,viewDirectionFromTarget:new b(0,0,1),viewTarget:new b(0,0,0),lensLength:500,frontClippingPlane:0,backClippingPlane:0,viewHeight:1e3,viewTwistAngle:0,frozenLayers:[],styleSheet:"",renderMode:sn.OPTIMIZED_2D,viewMode:0,ucsIconSetting:0,ucsOrigin:new b(0,0,0),ucsXAxis:new b(1,0,0),ucsYAxis:new b(0,1,0),orthographicType:nn.TOP,shadePlotSetting:0,shadePlotObjectId:void 0,visualStyleObjectId:void 0,isDefaultLightingOn:!1,defaultLightingType:rn.ONE_DISTANT_LIGHT,brightness:0,contrast:0,ambientColor:void 0};class aa extends Zt{constructor(){super(),this._circleSides=100,this._center=new L,this._lowerLeftCorner=new L(0,0),this._upperRightCorner=new L(1,1),this._snapBase=new L(0,0),this._snapAngle=0,this._snapSpacing=new L(0,0),this._standardFlag=0,this._gridSpacing=new L,this._gridMajor=10,this._gsView=ah}get circleSides(){return this._circleSides}set circleSides(t){this._circleSides=t}get center(){return this._center}get lowerLeftCorner(){return this._lowerLeftCorner}set lowerLeftCorner(t){this._lowerLeftCorner.copy(t)}get upperRightCorner(){return this._upperRightCorner}set upperRightCorner(t){this._upperRightCorner.copy(t)}get snapBase(){return this._snapBase}set snapBase(t){this._snapBase.copy(t)}get snapAngle(){return this._snapAngle}set snapAngle(t){this._snapAngle=t}get snapIncrements(){return this._snapSpacing}set snapIncrements(t){this._snapSpacing.copy(t)}get gridMajor(){return this._gridMajor}set gridMajor(t){this._gridMajor=t}get gridIncrements(){return this._gridSpacing}set gridIncrements(t){this._gridSpacing.copy(t)}get standardFlag(){return this._standardFlag}set standardFlag(t){this._standardFlag=t}get snapEnabled(){return!!(this._standardFlag&256)}get backgroundObjectId(){return this._backgroundObjectId}set backgroundObjectId(t){this._backgroundObjectId=t}get gsView(){return this._gsView}}class oa{constructor(){this.events={layoutSwitched:new st}}countLayouts(t){return this.getWorkingDatabase(t).dictionaries.layouts.numEntries}findLayoutNamed(t,e){return this.getWorkingDatabase(e).dictionaries.layouts.getAt(t)}findActiveLayout(){const t=this.getActiveLayout();return t?t.layoutName:"Model"}setCurrentLayoutId(t,e){const s=this.getWorkingDatabase(e),r=s.dictionaries.layouts.getIdAt(t);return this.setCurrentLayoutInternal(r,s)}setCurrentLayoutBtrId(t,e){const s=this.getWorkingDatabase(e),r=s.dictionaries.layouts.getBtrIdAt(t);return this.setCurrentLayoutInternal(r,s)}setCurrentLayout(t,e){const s=this.getWorkingDatabase(e),r=s.dictionaries.layouts.getAt(t);return this.setCurrentLayoutInternal(r,s)}renameLayout(t,e,s){const i=this.getWorkingDatabase(s).dictionaries.layouts.getAt(t);return i?(i.layoutName=e,!0):!1}layoutExists(t,e){return this.getWorkingDatabase(e).dictionaries.layouts.has(t)}deleteLayout(t,e){return this.getWorkingDatabase(e).dictionaries.layouts.remove(t)}createLayout(t,e){const s=this.getWorkingDatabase(e),r=new hn;r.layoutName=t,r.tabOrder=s.dictionaries.layouts.maxTabOrder;const i=new Mt;return i.name=`*Paper_Space${r.tabOrder}`,s.tables.blockTable.add(i),s.dictionaries.layouts.setAt(t,r),{layout:r,btr:i}}getActiveLayout(t){const e=this.getWorkingDatabase(t);return e.dictionaries.layouts.getBtrIdAt(e.currentSpaceId)}getWorkingDatabase(t){return t||dn().workingDatabase}setCurrentLayoutInternal(t,e){return t?(this.events.layoutSwitched.dispatch({oldLayout:this.getActiveLayout(),newLayout:t}),e.currentSpaceId=t.blockTableRecordId,!0):!1}}function dn(){return hs.instance}const cs=class cs{constructor(){this._workingDatabase=null,this._layoutManager=new oa}get workingDatabase(){if(this._workingDatabase==null)throw new Error("The current working database must be set before using it!");return this._workingDatabase}set workingDatabase(t){this._workingDatabase=t}get layoutManager(){return this._layoutManager}};cs.instance=new cs;let hs=cs;g.AcCmColor=zt,g.AcCmErrors=et,g.AcCmEventDispatcher=ga,g.AcCmEventManager=st,g.AcCmLoader=Aa,g.AcCmLoadingManager=wn,g.AcCmObject=fn,g.AcCmPerformanceCollector=xs,g.AcCmTask=xn,g.AcCmTaskScheduler=bn,g.AcDb3PointAngularDimension=Fi,g.AcDbAlignedDimension=Bi,g.AcDbAngleUnits=Ns,g.AcDbArc=mi,g.AcDbArcDimension=nh,g.AcDbBatchProcessing=Pn,g.AcDbBlockReference=tn,g.AcDbBlockTable=qi,g.AcDbBlockTableRecord=Mt,g.AcDbCircle=gi,g.AcDbCurve=gt,g.AcDbDatabase=ih,g.AcDbDatabaseConverter=Tr,g.AcDbDatabaseConverterManager=yt,g.AcDbDiametricDimension=Vi,g.AcDbDictionary=ln,g.AcDbDimArrowType=Ir,g.AcDbDimStyleTable=Xi,g.AcDbDimStyleTableRecord=Ne,g.AcDbDimTextHorizontal=Ji,g.AcDbDimTextVertical=ta,g.AcDbDimVerticalJustification=na,g.AcDbDimZeroSuppression=ea,g.AcDbDimZeroSuppressionAngular=sa,g.AcDbDimension=Kt,g.AcDbDxfConverter=Yi,g.AcDbEllipse=ui,g.AcDbEntity=pt,g.AcDbFileType=Oe,g.AcDbHatch=_i,g.AcDbHatchPatternType=pi,g.AcDbHatchStyle=yi,g.AcDbHostApplicationServices=hs,g.AcDbLayerTable=$i,g.AcDbLayerTableRecord=cn,g.AcDbLayout=hn,g.AcDbLayoutDictionary=Ui,g.AcDbLayoutManager=oa,g.AcDbLeader=xi,g.AcDbLeaderAnnotationType=fi,g.AcDbLine=bi,g.AcDbLineSpacingStyle=zi,g.AcDbLinetypeTable=Ki,g.AcDbLinetypeTableRecord=ra,g.AcDbMText=wi,g.AcDbObject=Rt,g.AcDbObjectIterator=$e,g.AcDbOrdinateDimension=ji,g.AcDbOsnapMode=Ut,g.AcDbPoint=vi,g.AcDbPolyline=Mi,g.AcDbRadialDimension=Gi,g.AcDbRasterImage=on,g.AcDbRasterImageClipBoundaryType=Li,g.AcDbRasterImageDef=Wi,g.AcDbRasterImageImageDisplayOpt=ki,g.AcDbRay=Oi,g.AcDbRenderingCache=kt,g.AcDbSpline=an,g.AcDbSymbolTable=Qt,g.AcDbSymbolTableRecord=Zt,g.AcDbTable=Ai,g.AcDbText=Ti,g.AcDbTextHorizontalMode=Ii,g.AcDbTextStyleTable=Zi,g.AcDbTextStyleTableRecord=ia,g.AcDbTextVerticalMode=Ei,g.AcDbTrace=Si,g.AcDbUnitsValue=Ds,g.AcDbViewport=Ni,g.AcDbViewportTable=Qi,g.AcDbViewportTableRecord=aa,g.AcDbWipeout=Di,g.AcDbXline=Ri,g.AcGeArea2d=Je,g.AcGeBox2d=K,g.AcGeBox3d=O,g.AcGeCatmullRomCurve3d=li,g.AcGeCircArc2d=oe,g.AcGeCircArc3d=Xt,g.AcGeCurve2d=ae,g.AcGeEllipseArc2d=es,g.AcGeEllipseArc3d=ss,g.AcGeEuler=ii,g.AcGeGeometryUtil=Xr,g.AcGeLine2d=ns,g.AcGeLine3d=Nt,g.AcGeLoop2d=hi,g.AcGeMathUtil=C,g.AcGeMatrix2d=Ke,g.AcGeMatrix3d=Yt,g.AcGeNurbsCurve=mt,g.AcGePlane=Le,g.AcGePoint2d=L,g.AcGePoint3d=b,g.AcGePolyline2d=Ce,g.AcGeQuaternion=Ct,g.AcGeShape2d=Zs,g.AcGeSpline3d=Dt,g.AcGeTol=Ws,g.AcGeVector2d=B,g.AcGeVector3d=w,g.AcGiArrowType=en,g.AcGiDefaultLightingType=rn,g.AcGiMTextAttachmentPoint=he,g.AcGiMTextFlowDirection=is,g.AcGiOrthographicType=nn,g.AcGiRenderMode=sn,g.AcGiViewport=as,g.AcTrStringUtil=wa,g.ByBlock=Pr,g.ByLayer=Xe,g.DEBUG_MODE=xa,g.DEFAULT_LINE_TYPE=qe,g.DEFAULT_TOL=Ys,g.DEG2RAD=Rs,g.DefaultLoadingManager=An,g.FLOAT_TOL=Wt,g.ORIGIN_POINT_2D=Xo,g.ORIGIN_POINT_3D=Us,g.RAD2DEG=zs,g.TAU=H,g.acdbHostApplicationServices=dn,g.basisFunction=Ze,g.calculateCurveLength=Qr,g.ceilPowerOfTwo=Gr,g.clamp=Tt,g.clone=me,g.damp=kr,g.defaults=ee,g.degToRad=Br,g.euclideanModulo=Fs,g.evaluateNurbsPoint=ve,g.floorPowerOfTwo=Hr,g.generateChordKnots=Kr,g.generateSqrtChordKnots=Zr,g.generateUUID=Mr,g.generateUniformKnots=$r,g.has=yn,g.intPartLength=Vs,g.interpolateControlPoints=$o,g.inverseLerp=Lr,g.isBetween=Ur,g.isBetweenAngle=Wr,g.isEmpty=_n,g.isEqual=se,g.isImperialUnits=qo,g.isMetricUnits=Yo,g.isPointInPolygon=qs,g.isPolygonIntersect=qr,g.isPowerOfTwo=jr,g.lerp=Bs,g.log=ue,g.mapLinear=vr,g.normalizeAngle=Me,g.pingpong=Cr,g.radToDeg=Vr,g.randFloat=Rr,g.randFloatSpread=zr,g.randInt=Dr,g.relativeEps=Yr,g.seededRandom=Fr,g.setLogLevel=ba,g.smootherstep=Nr,g.smoothstep=Or,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
1
+ (function(L,Lr){typeof exports=="object"&&typeof module<"u"?Lr(exports):typeof define=="function"&&define.amd?define(["exports"],Lr):(L=typeof globalThis<"u"?globalThis:L||self,Lr(L["data-model"]={}))})(this,function(L){"use strict";function Lr(a,t){for(var e=0;e<t.length;e++){const i=t[e];if(typeof i!="string"&&!Array.isArray(i)){for(const l in i)if(l!=="default"&&!(l in a)){const h=Object.getOwnPropertyDescriptor(i,l);h&&Object.defineProperty(a,l,h.get?h:{enumerable:!0,get:()=>i[l]})}}}return Object.freeze(Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}))}const Si={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},rs=[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];function Nr(a,t,e){return Math.max(t,Math.min(e,a))}const sa=class vh{constructor(){this._colorIndex=256,this._color=null,this._colorName=null}get color(){return this._color}set color(t){t==null?this._color=null:(this._color=Math.round(Nr(t,0,256*256*256-1)),this._colorIndex=this.getColorIndexByValue(this._color),this._colorName=this.getColorNameByValue(this._color))}get hexColor(){if(this._color&&this._color>0&&this._color<=16777215){let t=this._color.toString(16).toUpperCase();for(;t.length<6;)t="0"+t;return`0x${t}`}return""}get cssColor(){return`rgb(${this.red},${this.green},${this.blue})`}get red(){return this.color?this.color>>16&255:null}get green(){return this.color?this.color>>8&255:null}get blue(){return this.color?this.color&255:null}get colorIndex(){return this._colorIndex}set colorIndex(t){t==null?this._colorIndex=null:(this._colorIndex=Nr(t,0,256),this._color=rs[t],this._colorName=this.getColorNameByValue(this._color))}get colorName(){return this._colorName}set colorName(t){if(t){const e=Si[t.toLowerCase()];e!==void 0?(this._colorName=t,this._color=e,this._colorIndex=this.getColorIndexByValue(this._color)):console.warn("Unknown color: "+t)}else this._colorName=null}get hasColorName(){return this._colorName==null}get hasColorIndex(){return this._colorIndex==null}get isByLayer(){return this.colorIndex==256}setByLayer(){return this.colorIndex=256,this}get isByBlock(){return this.colorIndex==0}setByBlock(){return this.colorIndex=0,this}setScalar(t){return this.setRGB(t,t,t),this}setRGB(t,e,i){const l=Math.round(Nr(t,0,255)),h=Math.round(Nr(e,0,255)),u=Math.round(Nr(i,0,255));return this.color=(l<<16)+(h<<8)+u,this}setColorName(t){const e=Si[t.toLowerCase()];return e!==void 0?this.color=e:console.warn("Unknown color "+t),this}clone(){const t=new vh;return t.colorIndex=this.colorIndex,t.color=this.color,t._colorName=this._colorName,this}copy(t){return this.colorIndex=t.colorIndex,this.color=t.color,this._colorName=t._colorName,this}equals(t){return t.color==this.color&&t.colorIndex==this.colorIndex&&t._colorName==this._colorName}toString(){return this.isByLayer?"ByLayer":this.isByBlock?"ByBlock":this.colorName?this.colorName:this.hexColor}getColorNameByValue(t){for(const[e,i]of Object.entries(Si))if(i===t)return e;return null}getColorIndexByValue(t){const e=rs.length-1;for(let i=1;i<e;++i)if(rs[i]===t)return i;return null}};sa.NAMES=Si;let jn=sa;const Ie={get ILLEGAL_PARAMETERS(){return new ReferenceError("Illegal Parameters")},get ZERO_DIVISION(){return new Error("Zero division")},get UNRESOLVED_BOUNDARY_CONFLICT(){return new Error("Unresolved boundary conflict in boolean operation")},get INFINITE_LOOP(){return new Error("Infinite loop")},get CANNOT_INVOKE_ABSTRACT_METHOD(){return new Error("Abstract method cannot be invoked")},get OPERATION_IS_NOT_SUPPORTED(){return new Error("Operation is not supported")},get NOT_IMPLEMENTED(){return new Error("Not implemented yet")}};class Ph{constructor(){this._listeners={}}addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[t]===void 0&&(i[t]=[]),i[t].indexOf(e)===-1&&i[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const i=this._listeners;return i[t]!==void 0&&i[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const i=this._listeners[t];if(i!==void 0){const l=i.indexOf(e);l!==-1&&i.splice(l,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const e=this._listeners[t.type];if(e!==void 0){t.target=this;const i=e.slice(0);for(let l=0,h=i.length;l<h;l++)i[l].call(this,t)}}}let Ee=class{constructor(){this.listeners=[]}addEventListener(t){this.listeners.push(t)}removeEventListener(t){this.listeners=this.listeners.filter(e=>e!==t)}replaceEventListener(t){this.removeEventListener(t),this.addEventListener(t)}dispatch(t,...e){for(const i of this.listeners)i.call(null,t,...e)}};var Sh=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ih(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var aa={exports:{}};(function(a){(function(t,e){a.exports?a.exports=e():t.log=e()})(Sh,function(){var t=function(){},e="undefined",i=typeof window!==e&&typeof window.navigator!==e&&/Trident\/|MSIE /.test(window.navigator.userAgent),l=["trace","debug","info","warn","error"],h={},u=null;function f(R,G){var F=R[G];if(typeof F.bind=="function")return F.bind(R);try{return Function.prototype.bind.call(F,R)}catch{return function(){return Function.prototype.apply.apply(F,[R,arguments])}}}function b(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function p(R){return R==="debug"&&(R="log"),typeof console===e?!1:R==="trace"&&i?b:console[R]!==void 0?f(console,R):console.log!==void 0?f(console,"log"):t}function S(){for(var R=this.getLevel(),G=0;G<l.length;G++){var F=l[G];this[F]=G<R?t:this.methodFactory(F,R,this.name)}if(this.log=this.debug,typeof console===e&&R<this.levels.SILENT)return"No console available for logging"}function x(R){return function(){typeof console!==e&&(S.call(this),this[R].apply(this,arguments))}}function E(R,G,F){return p(R)||x.apply(this,arguments)}function T(R,G){var F=this,pt,_t,ut,W="loglevel";typeof R=="string"?W+=":"+R:typeof R=="symbol"&&(W=void 0);function gt(xt){var Nt=(l[xt]||"silent").toUpperCase();if(!(typeof window===e||!W)){try{window.localStorage[W]=Nt;return}catch{}try{window.document.cookie=encodeURIComponent(W)+"="+Nt+";"}catch{}}}function ht(){var xt;if(!(typeof window===e||!W)){try{xt=window.localStorage[W]}catch{}if(typeof xt===e)try{var Nt=window.document.cookie,ge=encodeURIComponent(W),fe=Nt.indexOf(ge+"=");fe!==-1&&(xt=/^([^;]+)/.exec(Nt.slice(fe+ge.length+1))[1])}catch{}return F.levels[xt]===void 0&&(xt=void 0),xt}}function Wt(){if(!(typeof window===e||!W)){try{window.localStorage.removeItem(W)}catch{}try{window.document.cookie=encodeURIComponent(W)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function qt(xt){var Nt=xt;if(typeof Nt=="string"&&F.levels[Nt.toUpperCase()]!==void 0&&(Nt=F.levels[Nt.toUpperCase()]),typeof Nt=="number"&&Nt>=0&&Nt<=F.levels.SILENT)return Nt;throw new TypeError("log.setLevel() called with invalid level: "+xt)}F.name=R,F.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},F.methodFactory=G||E,F.getLevel=function(){return ut??_t??pt},F.setLevel=function(xt,Nt){return ut=qt(xt),Nt!==!1&&gt(ut),S.call(F)},F.setDefaultLevel=function(xt){_t=qt(xt),ht()||F.setLevel(xt,!1)},F.resetLevel=function(){ut=null,Wt(),S.call(F)},F.enableAll=function(xt){F.setLevel(F.levels.TRACE,xt)},F.disableAll=function(xt){F.setLevel(F.levels.SILENT,xt)},F.rebuild=function(){if(u!==F&&(pt=qt(u.getLevel())),S.call(F),u===F)for(var xt in h)h[xt].rebuild()},pt=qt(u?u.getLevel():"WARN");var Gt=ht();Gt!=null&&(ut=qt(Gt)),S.call(F)}u=new T,u.getLogger=function(R){if(typeof R!="symbol"&&typeof R!="string"||R==="")throw new TypeError("You must supply a name when creating a logger.");var G=h[R];return G||(G=h[R]=new T(R,u.methodFactory)),G};var O=typeof window!==e?window.log:void 0;return u.noConflict=function(){return typeof window!==e&&window.log===u&&(window.log=O),u},u.getLoggers=function(){return h},u.default=u,u})})(aa);var oa=aa.exports;const Eh=Ih(oa),Mh=Lr({__proto__:null,default:Eh},[oa]),kh=!0,zr=Mh;zr.setLevel("debug");const Th=a=>{try{zr.setLevel(a)}catch(t){zr.setLevel("error"),zr.error(t)}};function Dr(a){return a===null||typeof a!="object"?a:Array.isArray(a)?[...a]:{...a}}function cr(a,...t){for(const e of t)if(e)for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&a[i]===void 0&&(a[i]=e[i]);return a}function la(a,t){return a!=null&&Object.prototype.hasOwnProperty.call(a,t)}function ha(a){return a==null?!0:Array.isArray(a)||typeof a=="string"?a.length===0:a instanceof Map||a instanceof Set?a.size===0:typeof a=="object"?Object.keys(a).length===0:!1}function ur(a,t){if(a===t)return!0;if(a==null||t==null)return a===t;if(typeof a!=typeof t)return!1;if(typeof a!="object")return a===t;if(Array.isArray(a)!==Array.isArray(t))return!1;if(Array.isArray(a)){if(a.length!==t.length)return!1;for(let l=0;l<a.length;l++)if(!ur(a[l],t[l]))return!1;return!0}const e=Object.keys(a),i=Object.keys(t);if(e.length!==i.length)return!1;for(const l of e)if(!Object.prototype.hasOwnProperty.call(t,l)||!ur(a[l],t[l]))return!1;return!0}let ca=class yh{constructor(t,e){this.events={attrChanged:new Ee,modelChanged:new Ee},this._changing=!1,this._previousAttributes={},this._pending=!1;const i=t||{};e&&cr(i,e),this.attributes=i,this.changed={}}get(t){return this.attributes[t]}set(t,e,i){if(t==null)return this;let l;typeof t=="object"?(l=t,i=e):(l={},l[t]=e),i||(i={});const h=i.unset,u=i.silent,f=[],b=this._changing;this._changing=!0,b||(this._previousAttributes=Dr(this.attributes),this.changed={});const p=this.attributes,S=this.changed,x=this._previousAttributes;for(const E in l)e=l[E],ur(p[E],e)||f.push(E),ur(x[E],e)?delete S[E]:S[E]=e,h?delete p[E]:p[E]=e;if(!u){f.length&&(this._pending=i);for(let E=0;E<f.length;E++)this.events.attrChanged.dispatch({object:this,attrName:f[E],attrValue:p[f[E]],options:i})}if(b)return this;if(!u)for(;this._pending;)i=this._pending,this._pending=!1,this.events.modelChanged.dispatch({object:this,options:i});return this._pending=!1,this._changing=!1,this}has(t){return this.get(t)!=null}hasChanged(t){return t==null?!ha(this.changed):la(this.changed,t)}changedAttributes(t){if(!t)return this.hasChanged()?Dr(this.changed):{};const e=this._changing?this._previousAttributes:this.attributes,i={};for(const l in t){const h=t[l];ur(e[l],h)||(i[l]=h)}return i}previous(t){return t==null||!this._previousAttributes?null:this._previousAttributes[t]}previousAttributes(){return Dr(this._previousAttributes)}clone(){const t=Dr(this.attributes);return new yh(t)}},is=class Pi{constructor(){this.entries=new Map}static getInstance(){return Pi.instance||(Pi.instance=new Pi),Pi.instance}collect(t){this.entries.set(t.name,t)}printAll(){for(const[t,e]of this.entries)console.log(`${t}:`),console.log(e.format())}clear(){this.entries.clear()}getAll(){return Array.from(this.entries.values())}getEntry(t){return this.entries.get(t)}remove(t){return this.entries.delete(t)}};class Ch{static formatBytes(t,e=2){if(t===0)return"0 B";const i=1024,l=Math.max(0,e),h=["B","KB","MB","GB","TB"],u=Math.floor(Math.log(t)/Math.log(i)),f=t/Math.pow(i,u);return`${parseFloat(f.toFixed(l))} ${h[u]}`}}class ua{constructor(t){this.name=t}run(t){throw new Error("run() must be implemented by subclass")}}class da{constructor(){this.tasks=[],this.onProgress=()=>{},this.onComplete=()=>{},this.onError=()=>{}}scheduleTask(t){return new Promise((e,i)=>{const l=()=>{Promise.resolve(t()).then(e).catch(i)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(l):setTimeout(l,0)})}addTask(t){this.tasks.push(t)}setProgressCallback(t){this.onProgress=t}setCompleteCallback(t){this.onComplete=t}setErrorCallback(t){this.onError=t}async run(t){const e=this.tasks.length;let i=t;for(let l=0;l<e;l++){const h=this.tasks[l];try{i=await this.scheduleTask(async()=>{const u=await h.run(i);return this.onProgress((l+1)/e,h),u})}catch(u){this.onError(u,l,h);return}}this.onComplete(i)}}let ma=class{constructor(t,e,i){this.isLoading=!1,this.itemsLoaded=0,this.itemsTotal=0,this.urlModifier=void 0,this.handlers=[],this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=i}itemStart(t){this.itemsTotal++,this.isLoading===!1&&this.onStart!==void 0&&this.onStart(t,this.itemsLoaded,this.itemsTotal),this.isLoading=!0}itemEnd(t){this.itemsLoaded++,this.onProgress!==void 0&&this.onProgress(t,this.itemsLoaded,this.itemsTotal),this.itemsLoaded===this.itemsTotal&&(this.isLoading=!1,this.onLoad!==void 0&&this.onLoad())}itemError(t){this.onError!==void 0&&this.onError(t)}resolveURL(t){return this.urlModifier?this.urlModifier(t):t}setURLModifier(t){return this.urlModifier=t,this}addHandler(t,e){return this.handlers.push(t,e),this}removeHandler(t){const e=this.handlers.indexOf(t);return e!==-1&&this.handlers.splice(e,2),this}getHandler(t){for(let e=0,i=this.handlers.length;e<i;e+=2){const l=this.handlers[e],h=this.handlers[e+1];if(l.global&&(l.lastIndex=0),l.test(t))return h}return null}};const ga=new ma;let Lh=class{constructor(t){this.manager=t!==void 0?t:ga,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}loadAsync(t,e){return new Promise((i,l)=>{this.load(t,i,e,l)})}parse(t){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}};class fa{constructor(t,e,i){this._chunkSize=-1,this._minimumChunkSize=50,this._count=t,this._numerOfChunk=e<1?1:e,this._minimumChunkSize=i,this.calculateChunkSize()}get count(){return this._count}get numerOfChunk(){return this._numerOfChunk}get minimumChunkSize(){return this._minimumChunkSize}set minimumChunkSize(t){this._minimumChunkSize=t,this.calculateChunkSize()}get chunkSize(){return this._chunkSize}calculateChunkSize(){let t=this._count/this._numerOfChunk;t<this._minimumChunkSize&&(t=Math.min(this._minimumChunkSize,this._count)),this._chunkSize=t<1?this._count:Math.floor(t)}scheduleTask(t){return new Promise((e,i)=>{const l=()=>{Promise.resolve(t()).then(e).catch(i)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(l):setTimeout(l,0)})}async processChunk(t){let e=0;const i=async()=>{const l=e,h=Math.min(e+this._chunkSize,this._count);await t(l,h),e=h,e<this._count&&await this.scheduleTask(i)};await i()}}var ae,Or,Qt,se,Rr,je,ve,ln,Ge,Gn,Br,Fr,Hn,Wn,Vr,Ur,jr,Me,hn,jt,qn,Gr,vt,ye,Hr,be,cn,Wr,un,He,qr,Yn,ke,dn,ss,as,mn,Yr,Kr,gn,Xr,os,ls,Kn,oe,fn,le,Te,hs,cs,us,ds,ms,gs;(ae={})[ae.None=0]="None",ae[ae.Anonymous=1]="Anonymous",ae[ae.NonConstant=2]="NonConstant",ae[ae.Xref=4]="Xref",ae[ae.XrefOverlay=8]="XrefOverlay",ae[ae.ExternallyDependent=16]="ExternallyDependent",ae[ae.ResolvedOrDependent=32]="ResolvedOrDependent",ae[ae.ReferencedXref=64]="ReferencedXref",(Or={})[Or.BYBLOCK=0]="BYBLOCK",Or[Or.BYLAYER=256]="BYLAYER",(Qt={})[Qt.Rotated=0]="Rotated",Qt[Qt.Aligned=1]="Aligned",Qt[Qt.Angular=2]="Angular",Qt[Qt.Diameter=3]="Diameter",Qt[Qt.Radius=4]="Radius",Qt[Qt.Angular3Point=5]="Angular3Point",Qt[Qt.Ordinate=6]="Ordinate",Qt[Qt.ReferenceIsExclusive=32]="ReferenceIsExclusive",Qt[Qt.IsOrdinateXTypeFlag=64]="IsOrdinateXTypeFlag",Qt[Qt.IsCustomTextPositionFlag=128]="IsCustomTextPositionFlag",(se={})[se.TopLeft=1]="TopLeft",se[se.TopCenter=2]="TopCenter",se[se.TopRight=3]="TopRight",se[se.MiddleLeft=4]="MiddleLeft",se[se.MiddleCenter=5]="MiddleCenter",se[se.MiddleRight=6]="MiddleRight",se[se.BottomLeft=7]="BottomLeft",se[se.BottomCenter=8]="BottomCenter",se[se.BottomRight=9]="BottomRight",(Rr={})[Rr.AtLeast=1]="AtLeast",Rr[Rr.Exact=2]="Exact";var pa=((je={})[je.Center=0]="Center",je[je.Above=1]="Above",je[je.Outside=2]="Outside",je[je.JIS=3]="JIS",je[je.Below=4]="Below",je),dr=((ve={})[ve.Feet=0]="Feet",ve[ve.None=1]="None",ve[ve.Inch=2]="Inch",ve[ve.FeetAndInch=3]="FeetAndInch",ve[ve.Leading=4]="Leading",ve[ve.Trailing=8]="Trailing",ve[ve.LeadingAndTrailing=12]="LeadingAndTrailing",ve),Nh=((ln={})[ln.None=0]="None",ln[ln.Leading=1]="Leading",ln[ln.Trailing=2]="Trailing",ln[ln.LeadingAndTrailing=3]="LeadingAndTrailing",ln),zh=((Ge={})[Ge.Center=0]="Center",Ge[Ge.Left=1]="Left",Ge[Ge.Right=2]="Right",Ge[Ge.OverFirst=3]="OverFirst",Ge[Ge.OverSecond=4]="OverSecond",Ge),Dh=((Gn={})[Gn.Bottom=0]="Bottom",Gn[Gn.Center=1]="Center",Gn[Gn.Top=2]="Top",Gn);(Br={})[Br.PatternFill=0]="PatternFill",Br[Br.SolidFill=1]="SolidFill",(Fr={})[Fr.NonAssociative=0]="NonAssociative",Fr[Fr.Associative=1]="Associative",(Hn={})[Hn.Normal=0]="Normal",Hn[Hn.Outer=1]="Outer",Hn[Hn.Ignore=2]="Ignore",(Wn={})[Wn.UserDefined=0]="UserDefined",Wn[Wn.Predefined=1]="Predefined",Wn[Wn.Custom=2]="Custom",(Vr={})[Vr.NotAnnotated=0]="NotAnnotated",Vr[Vr.Annotated=1]="Annotated",(Ur={})[Ur.Solid=0]="Solid",Ur[Ur.Gradient=1]="Gradient",(jr={})[jr.TwoColor=0]="TwoColor",jr[jr.OneColor=1]="OneColor";var Oh=((Me={})[Me.Default=0]="Default",Me[Me.External=1]="External",Me[Me.Polyline=2]="Polyline",Me[Me.Derived=4]="Derived",Me[Me.Textbox=8]="Textbox",Me[Me.Outermost=16]="Outermost",Me),Ii=((hn={})[hn.Line=1]="Line",hn[hn.Circular=2]="Circular",hn[hn.Elliptic=3]="Elliptic",hn[hn.Spline=4]="Spline",hn),Rh=((jt={})[jt.Off=0]="Off",jt[jt.Solid=1]="Solid",jt[jt.Dashed=2]="Dashed",jt[jt.Dotted=3]="Dotted",jt[jt.ShotDash=4]="ShotDash",jt[jt.MediumDash=5]="MediumDash",jt[jt.LongDash=6]="LongDash",jt[jt.DoubleShortDash=7]="DoubleShortDash",jt[jt.DoubleMediumDash=8]="DoubleMediumDash",jt[jt.DoubleLongDash=9]="DoubleLongDash",jt[jt.DoubleMediumLongDash=10]="DoubleMediumLongDash",jt[jt.SparseDot=11]="SparseDot",jt);Rh.Off,(qn={})[qn.Standard=-3]="Standard",qn[qn.ByLayer=-2]="ByLayer",qn[qn.ByBlock=-1]="ByBlock",(Gr={})[Gr.English=0]="English",Gr[Gr.Metric=1]="Metric",(vt={})[vt.PERSPECTIVE_MODE=1]="PERSPECTIVE_MODE",vt[vt.FRONT_CLIPPING=2]="FRONT_CLIPPING",vt[vt.BACK_CLIPPING=4]="BACK_CLIPPING",vt[vt.UCS_FOLLOW=8]="UCS_FOLLOW",vt[vt.FRONT_CLIP_NOT_AT_EYE=16]="FRONT_CLIP_NOT_AT_EYE",vt[vt.UCS_ICON_VISIBILITY=32]="UCS_ICON_VISIBILITY",vt[vt.UCS_ICON_AT_ORIGIN=64]="UCS_ICON_AT_ORIGIN",vt[vt.FAST_ZOOM=128]="FAST_ZOOM",vt[vt.SNAP_MODE=256]="SNAP_MODE",vt[vt.GRID_MODE=512]="GRID_MODE",vt[vt.ISOMETRIC_SNAP_STYLE=1024]="ISOMETRIC_SNAP_STYLE",vt[vt.HIDE_PLOT_MODE=2048]="HIDE_PLOT_MODE",vt[vt.K_ISO_PAIR_TOP=4096]="K_ISO_PAIR_TOP",vt[vt.K_ISO_PAIR_RIGHT=8192]="K_ISO_PAIR_RIGHT",vt[vt.VIEWPORT_ZOOM_LOCKING=16384]="VIEWPORT_ZOOM_LOCKING",vt[vt.UNUSED=32768]="UNUSED",vt[vt.NON_RECTANGULAR_CLIPPING=65536]="NON_RECTANGULAR_CLIPPING",vt[vt.VIEWPORT_OFF=131072]="VIEWPORT_OFF",vt[vt.GRID_BEYOND_DRAWING_LIMITS=262144]="GRID_BEYOND_DRAWING_LIMITS",vt[vt.ADAPTIVE_GRID_DISPLAY=524288]="ADAPTIVE_GRID_DISPLAY",vt[vt.SUBDIVISION_BELOW_SPACING=1048576]="SUBDIVISION_BELOW_SPACING",vt[vt.GRID_FOLLOWS_WORKPLANE=2097152]="GRID_FOLLOWS_WORKPLANE",(ye={})[ye.OPTIMIZED_2D=0]="OPTIMIZED_2D",ye[ye.WIREFRAME=1]="WIREFRAME",ye[ye.HIDDEN_LINE=2]="HIDDEN_LINE",ye[ye.FLAT_SHADED=3]="FLAT_SHADED",ye[ye.GOURAUD_SHADED=4]="GOURAUD_SHADED",ye[ye.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",ye[ye.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME",(Hr={})[Hr.UCS_UNCHANGED=0]="UCS_UNCHANGED",Hr[Hr.HAS_OWN_UCS=1]="HAS_OWN_UCS",(be={})[be.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",be[be.TOP=1]="TOP",be[be.BOTTOM=2]="BOTTOM",be[be.FRONT=3]="FRONT",be[be.BACK=4]="BACK",be[be.LEFT=5]="LEFT",be[be.RIGHT=6]="RIGHT",(cn={})[cn.AS_DISPLAYED=0]="AS_DISPLAYED",cn[cn.WIREFRAME=1]="WIREFRAME",cn[cn.HIDDEN=2]="HIDDEN",cn[cn.RENDERED=3]="RENDERED",(Wr={})[Wr.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",Wr[Wr.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS";function Ct(a,t,e){return a.code===t&&(e==null||a.value===e)}function Bt(a){let t={};a.rewind();let e=a.next(),i=e.code;if(t.x=e.value,(e=a.next()).code!==i+10)throw Error("Expected code for point value to be 20 but got "+e.code+".");return t.y=e.value,(e=a.next()).code!==i+20?a.rewind():t.z=e.value,t}let fs=Symbol();function Et(a,t){return(e,i,l)=>{let h=a.reduce((b,p)=>{p.pushContext&&b.push({});let S=b[b.length-1];for(let x of typeof p.code=="number"?[p.code]:p.code){let E=S[x]??(S[x]=[]);p.isMultiple&&E.length&&console.warn(`Snippet ${E.at(-1).name} for code(${x}) is shadowed by ${p.name}`),E.push(p)}return b},[{}]),u=!1,f=h.length-1;for(;!Ct(e,0,"EOF");){let b=function(O,R,G){return O.find((F,pt)=>{var _t;return pt>=G&&((_t=F[R])==null?void 0:_t.length)})}(h,e.code,f),p=b==null?void 0:b[e.code].at(-1);if(!b||!p){i.rewind();break}p.isMultiple||b[e.code].pop();let{name:S,parser:x,isMultiple:E}=p,T=x==null?void 0:x(e,i,l);if(T===fs){i.rewind();break}if(S){let[O,R]=function(G,F){let pt=F.split("."),_t=G;for(let ut=0;ut<pt.length-1;++ut){let W=pt[ut];Object.hasOwn(_t,W)||(_t[W]={}),_t=_t[W]}return[_t,pt.at(-1)]}(l,S);E?(Object.hasOwn(O,R)||(O[R]=[]),O[R].push(T)):O[R]=T}p.pushContext&&(f-=1),u=!0,e=i.next()}return t&&Object.setPrototypeOf(l,t),u}}function y({value:a}){return a}function Q(a,t){return Bt(t)}function Kt({value:a}){return!!a}var _a=[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];function va(a,t){var l;if(!Ct(a,1001))throw Error("XData must starts with code 1001");let e={appName:a.value,value:[]};a=t.next();let i=[e.value];for(;!Ct(a,0,"EOF")&&a.code>=1e3;){let h=i.at(-1);switch(a.code){case 1002:a.value==="{"?i.push([]):(i.pop(),(l=i.at(-1))==null||l.push(h));break;case 1e3:case 1004:case 1040:case 1070:case 1071:h.push({type:pn(a.code),value:a.value});break;case 1003:h.push({name:"layer",type:pn(a.code),value:a.value});break;case 1005:h.push({name:"handle",type:pn(a.code),value:a.value});break;case 1010:h.push({type:pn(a.code),value:Bt(t)});break;case 1011:h.push({name:"worldSpacePosition",type:pn(a.code),value:Bt(t)});break;case 1012:h.push({name:"worldSpaceDisplacement",type:pn(a.code),value:Bt(t)});break;case 1013:h.push({name:"worldSpaceDirection",type:pn(a.code),value:Bt(t)});break;case 1041:h.push({name:"distance",type:pn(a.code),value:a.value});break;case 1042:h.push({name:"scale",type:pn(a.code),value:a.value})}a=t.next()}return t.rewind(),e}function pn(a){switch(a){case 1e3:case 1003:case 1005:return"string";case 1004:return"hex";case 1040:case 1041:case 1042:return"real";case 1070:return"integer";case 1071:return"long";case 1010:case 1011:case 1012:case 1013:return"point";default:return""}}function ps(a,t,e){if(Ct(t,102))return Ei(t,e),!0;switch(t.code){case 0:a.type=t.value;break;case 5:a.handle=t.value;break;case 330:a.ownerDictionarySoftId?a.ownerBlockRecordSoftId=t.value:a.ownerDictionarySoftId=t.value;break;case 360:a.ownerdictionaryHardId=t.value;break;case 67:a.isInPaperSpace=!!t.value;break;case 8:a.layer=t.value;break;case 6:a.lineType=t.value;break;case 347:a.materialObjectHardId=t.value;break;case 62:a.colorIndex=t.value,a.color=_a[Math.abs(t.value)];break;case 370:a.lineweight=t.value;break;case 48:a.lineTypeScale=t.value;break;case 60:a.isVisible=!!t.value;break;case 92:a.proxyByte=t.value;break;case 310:a.proxyEntity=t.value;break;case 100:break;case 420:a.color=t.value;break;case 430:a.transparency=t.value;break;case 390:a.plotStyleHardId=t.value;break;case 284:a.shadowMode=t.value;break;case 1001:a.xdata=va(t,e);break;default:return!1}return!0}let Bh=0;function ya(a){if(!a)throw TypeError("entity cannot be undefined or null");a.handle||(a.handle=Bh++)}(un={})[un.CAST_AND_RECEIVE=0]="CAST_AND_RECEIVE",un[un.CAST=1]="CAST",un[un.RECEIVE=2]="RECEIVE",un[un.IGNORE=3]="IGNORE";let Jt=[{code:1001,name:"xdata",parser:va},{code:284,name:"shadowMode",parser:y},{code:390,name:"plotStyleHardId",parser:y},{code:440,name:"transparency",parser:y},{code:430,name:"colorName",parser:y},{code:420,name:"color",parser:y},{code:310,name:"proxyEntity",isMultiple:!0,parser:y},{code:92,name:"proxyByte",parser:y},{code:60,name:"isVisible",parser:Kt},{code:48,name:"lineTypeScale",parser:y},{code:370,name:"lineweight",parser:y},{code:62,name:"colorIndex",parser(a,t,e){let i=a.value;return e.color=_a[Math.abs(i)],i}},{code:347,name:"materialObjectHardId",parser:y},{code:6,name:"lineType",parser:y},{code:8,name:"layer",parser:y},{code:410,name:"layoutTabName",parser:y},{code:67,name:"isInPaperSpace",parser:Kt},{code:100},{code:160},{code:330,name:"ownerBlockRecordSoftId",parser:y},{code:102,parser:Ei},{code:102,parser:Ei},{code:102,parser:Ei},{code:5,name:"handle",parser:y}];function Ei(a,t){for(a=t.next();!Ct(a,102)&&!Ct(a,0,"EOF");)a=t.next()}function ba(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}let Fh={extrusionDirection:{x:0,y:0,z:1}},Vh=[{code:210,name:"extrusionDirection",parser:Q},{code:51,name:"endAngle",parser:y},{code:50,name:"startAngle",parser:y},{code:100,name:"subclassMarker",parser:y},{code:40,name:"radius",parser:y},{code:10,name:"center",parser:Q},{code:39,name:"thickness",parser:y},{code:100},...Jt];class xa{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){ba(this,"parser",Et(Vh,Fh))}}ba(xa,"ForEntityName","ARC"),(He={})[He.NONE=0]="NONE",He[He.INVISIBLE=1]="INVISIBLE",He[He.CONSTANT=2]="CONSTANT",He[He.VERIFICATION_REQUIRED=4]="VERIFICATION_REQUIRED",He[He.PRESET=8]="PRESET",(qr={})[qr.MULTILINE=2]="MULTILINE",qr[qr.CONSTANT_MULTILINE=4]="CONSTANT_MULTILINE",(Yn={})[Yn.NONE=0]="NONE",Yn[Yn.MIRRORED_X=2]="MIRRORED_X",Yn[Yn.MIRRORED_Y=4]="MIRRORED_Y";var Uh=((ke={})[ke.LEFT=0]="LEFT",ke[ke.CENTER=1]="CENTER",ke[ke.RIGHT=2]="RIGHT",ke[ke.ALIGNED=3]="ALIGNED",ke[ke.MIDDLE=4]="MIDDLE",ke[ke.FIT=5]="FIT",ke),jh=((dn={})[dn.BASELINE=0]="BASELINE",dn[dn.BOTTOM=1]="BOTTOM",dn[dn.MIDDLE=2]="MIDDLE",dn[dn.TOP=3]="TOP",dn);function wa(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}let Aa={thickness:0,rotation:0,xScale:1,obliqueAngle:0,styleName:"STANDARD",generationFlag:0,halign:Uh.LEFT,valign:jh.BASELINE,extrusionDirection:{x:0,y:0,z:1}},Pa=[{code:73,name:"valign",parser:y},{code:100},{code:210,name:"extrusionDirection",parser:Q},{code:11,name:"endPoint",parser:Q},{code:72,name:"valign",parser:y},{code:72,name:"halign",parser:y},{code:71,name:"generationFlag",parser:y},{code:7,name:"styleName",parser:y},{code:51,name:"obliqueAngle",parser:y},{code:41,name:"xScale",parser:y},{code:50,name:"rotation",parser:y},{code:1,name:"text",parser:y},{code:40,name:"textHeight",parser:y},{code:10,name:"startPoint",parser:Q},{code:39,name:"thickness",parser:y},{code:100,name:"subclassMarker",parser:y},...Jt];class Sa{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){wa(this,"parser",Et(Pa,Aa))}}function Ia(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}wa(Sa,"ForEntityName","TEXT");let Gh={...Aa},Hh=[{code:2},{code:40,name:"annotationScale",parser:y},{code:10,name:"alignmentPoint",parser:Q},{code:340,name:"secondaryAttributesHardIds",isMultiple:!0,parser:y},{code:70,name:"numberOfSecondaryAttributes",parser:y},{code:70,name:"isReallyLocked",parser:Kt},{code:70,name:"mtextFlag",parser:y},{code:280,name:"isDuplicatedRecord",parser:Kt},{code:100},{code:280,name:"isLocked",parser:Kt},{code:74,name:"valign",parser:y},{code:73},{code:70,name:"attributeFlag",parser:y},{code:2,name:"tag",parser:y},{code:3,name:"prompt",parser:y},{code:280},{code:100,name:"subclassMarker",parser:y},...Pa.slice(2)];class Ea{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Ia(this,"parser",Et(Hh,Gh))}}function Ma(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}Ia(Ea,"ForEntityName","ATTDEF");let Wh={thickness:0,extrusionDirection:{x:0,y:0,z:1}},qh=[{code:210,name:"extrusionDirection",parser:Q},{code:40,name:"radius",parser:y},{code:10,name:"center",parser:Q},{code:39,name:"thickness",parser:y},{code:100,name:"subclassMarker",parser:y},...Jt];class ka{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Ma(this,"parser",Et(qh,Wh))}}Ma(ka,"ForEntityName","CIRCLE");let Mi=class{parseEntity(t,e){let i={};for(;!Ct(e,0,"EOF");){if(e.code===0){t.rewind();break}(function(l,h,u){switch(h.code){case 100:l.subclassMarker=h.value;break;case 280:l.version=h.value;break;case 2:l.name=h.value;break;case 10:l.definitionPoint=Bt(u);break;case 11:l.textPoint=Bt(u);break;case 12:l.insertionPoint=Bt(u);break;case 13:l.subDefinitionPoint1=Bt(u);break;case 14:l.subDefinitionPoint2=Bt(u);break;case 15:l.centerPoint=Bt(u);break;case 16:l.arcPoint=Bt(u);break;case 70:l.dimensionType=h.value;break;case 71:l.attachmentPoint=h.value;break;case 72:l.textLineSpacingStyle=h.value;break;case 40:l.leaderLength=h.value;break;case 41:l.textLineSpacingFactor=h.value;break;case 42:l.measurement=h.value;break;case 1:l.text=h.value;break;case 50:l.rotationAngle=h.value;break;case 52:l.obliqueAngle=h.value;break;case 53:l.textRotation=h.value;break;case 51:l.ocsRotation=h.value;break;case 210:l.extrusionDirection=Bt(u);break;case 3:l.styleName=h.value;break;default:ps(l,h,u)}})(i,e,t),e=t.next()}return i}};function Ta(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}as="DIMENSION",(ss="ForEntityName")in Mi?Object.defineProperty(Mi,ss,{value:as,enumerable:!0,configurable:!0,writable:!0}):Mi[ss]=as;let Yh={extrusionDirection:{x:0,y:0,z:1}},Kh=[{code:42,name:"endAngle",parser:y},{code:41,name:"startAngle",parser:y},{code:40,name:"axisRatio",parser:y},{code:210,name:"extrusionDirection",parser:Q},{code:11,name:"majorAxisEndPoint",parser:Q},{code:10,name:"center",parser:Q},{code:100,name:"subclassMarker",parser:y},...Jt];class Ca{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Ta(this,"parser",Et(Kh,Yh))}}Ta(Ca,"ForEntityName","ELLIPSE");let La=[{code:330,name:"sourceBoundaryObjects",parser:y,isMultiple:!0},{code:97,name:"numberOfSourceBoundaryObjects",parser:y}],Xh=[{code:11,name:"end",parser:Q},{code:10,name:"start",parser:Q}],$h=[{code:73,name:"isCCW",parser:Kt},{code:51,name:"endAngle",parser:y},{code:50,name:"startAngle",parser:y},{code:40,name:"radius",parser:y},{code:10,name:"center",parser:Q}],Zh=[{code:73,name:"isCCW",parser:Kt},{code:51,name:"endAngle",parser:y},{code:50,name:"startAngle",parser:y},{code:40,name:"lengthOfMinorAxis",parser:y},{code:11,name:"end",parser:Q},{code:10,name:"center",parser:Q}],Qh=[{code:13,name:"endTangent",parser:Q},{code:12,name:"startTangent",parser:Q},{code:11,name:"fitDatum",isMultiple:!0,parser:Q},{code:97,name:"numberOfFitData",parser:y},{code:10,name:"controlPoints",isMultiple:!0,parser(a,t){let e={...Bt(t),weight:1};return(a=t.next()).code===42?e.weight=a.value:t.rewind(),e}},{code:40,name:"knots",isMultiple:!0,parser:y},{code:96,name:"numberOfControlPoints",parser:y},{code:95,name:"numberOfKnots",parser:y},{code:74,name:"isPeriodic",parser:Kt},{code:73,name:"splineFlag",parser:y},{code:94,name:"degree",parser:y}],Jh={[Ii.Line]:Xh,[Ii.Circular]:$h,[Ii.Elliptic]:Zh,[Ii.Spline]:Qh},tc=[...La,{code:72,name:"edges",parser(a,t){let e={type:a.value},i=Et(Jh[e.type]);if(!i)throw Error(`Invalid edge type ${e.type}`);return i(a=t.next(),t,e),e},isMultiple:!0},{code:93,name:"numberOfEdges",parser:y}],ec=[...La,{code:10,name:"vertices",parser(a,t){let e={...Bt(t),bulge:0};return(a=t.next()).code===42?e.bulge=a.value:t.rewind(),e},isMultiple:!0},{code:93,name:"numberOfVertices",parser:y},{code:73,name:"isClosed",parser:Kt},{code:72,name:"hasBulge",parser:Kt}],nc=[{code:49,name:"dashLengths",parser:y,isMultiple:!0},{code:79,name:"numberOfDashLengths",parser:y},{code:45,name:"offset",parser:Na},{code:43,name:"base",parser:Na},{code:53,name:"angle",parser:y}];function Na(a,t){let e=a.code+1,i={x:a.value,y:1};return(a=t.next()).code===e?i.y=a.value:t.rewind(),i}function za(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}let rc={extrusionDirection:{x:0,y:0,z:1},gradientRotation:0,colorTint:0},ic=[{code:470},{code:463},{code:462,name:"colorTint",parser:y},{code:461,name:"gradientDefinition",parser:y},{code:460,name:"gradientRotation",parser:y},{code:453,name:"numberOfColors",parser:y},{code:452,name:"gradientColorFlag",parser:y},{code:451},{code:450,name:"gradientFlag",parser:y},{code:10,name:"seedPoints",parser:Q,isMultiple:!0},{code:99},{code:11,name:"offsetVector",parser:Q},{code:98,name:"numberOfSeedPoints",parser:y},{code:47,name:"pixelSize",parser:y},{code:53,name:"definitionLines",parser:function(a,t){let e={};return Et(nc)(a,t,e),e},isMultiple:!0},{code:78,name:"numberOfDefinitionLines",parser:y},{code:77,name:"isDouble",parser:Kt},{code:73,name:"isAnnotated",parser:Kt},{code:41,name:"patternScale",parser:y},{code:52,name:"patternAngle",parser:y},{code:76,name:"patternType",parser:y},{code:75,name:"hatchStyle",parser:y},{code:92,name:"boundaryPaths",parser:function(a,t){let e={boundaryPathTypeFlag:a.value},i=e.boundaryPathTypeFlag&Oh.Polyline;return a=t.next(),i?Et(ec)(a,t,e):Et(tc)(a,t,e),e},isMultiple:!0},{code:91,name:"numberOfBoundaryPaths",parser:y},{code:71,name:"associativity",parser:y},{code:63,name:"patternFillColor",parser:y},{code:70,name:"solidFill",parser:y},{code:2,name:"patternName",parser:y},{code:210,name:"extrusionDirection",parser:Q},{code:10,name:"elevationPoint",parser:Q},{code:100,name:"subclassMarker",parser:y,pushContext:!0},...Jt];class Da{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){za(this,"parser",Et(ic,rc))}}za(Da,"ForEntityName","HATCH"),(mn={})[mn.ShowImage=1]="ShowImage",mn[mn.ShowImageWhenNotAlignedWithScreen=2]="ShowImageWhenNotAlignedWithScreen",mn[mn.UseClippingBoundary=4]="UseClippingBoundary",mn[mn.TransparencyIsOn=8]="TransparencyIsOn",(Yr={})[Yr.Rectangular=1]="Rectangular",Yr[Yr.Polygonal=2]="Polygonal",(Kr={})[Kr.Outside=0]="Outside",Kr[Kr.Inside=1]="Inside";function Oa(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}let sc={clippingBoundaryPath:[]},ac=[{code:90,name:"version",parser:y},{code:10,name:"position",parser:Q},{code:11,name:"uPixel",parser:Q},{code:12,name:"vPixel",parser:Q},{code:13,name:"imageSize",parser:Q},{code:340,name:"imageDefHandle",parser:y},{code:70,name:"flags",parser:y},{code:280,name:"clipping",parser:y},{code:281,name:"brightness",parser:y},{code:282,name:"contrast",parser:y},{code:283,name:"fade",parser:y},{code:360,name:"imageDefReactorHandle",parser:y},{code:71,name:"clippingBoundaryType",parser:y},{code:91,name:"countBoundaryPoints",parser:y},{code:14,name:"clippingBoundaryPath",isMultiple:!0,parser:Q},{code:290,name:"clipMode",parser:y},{code:100,name:"subclassMarker",parser:y},...Jt];class _s{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Oa(this,"parser",Et(ac,sc))}}function Ra(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}Oa(_s,"ForEntityName","IMAGE");let oc={xScale:1,yScale:1,zScale:1,rotation:0,columnCount:0,rowCount:0,columnSpacing:0,rowSpacing:0,extrusionDirection:{x:0,y:0,z:1}},lc=[{code:210,name:"extrusionDirection",parser:Q},{code:45,name:"rowSpacing",parser:y},{code:44,name:"columnSpacing",parser:y},{code:71,name:"rowCount",parser:y},{code:70,name:"columnCount",parser:y},{code:50,name:"rotation",parser:y},{code:43,name:"zScale",parser:y},{code:42,name:"yScale",parser:y},{code:41,name:"xScale",parser:y},{code:10,name:"insertionPoint",parser:Q},{code:2,name:"name",parser:y},{code:66,name:"isVariableAttributes",parser:Kt},{code:100,name:"subclassMarker",parser:y},...Jt];class Ba{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Ra(this,"parser",Et(lc,oc))}}function Fa(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}Ra(Ba,"ForEntityName","INSERT");let hc={isArrowheadEnabled:!0},cc=[{code:213,name:"offsetFromAnnotation",parser:Q},{code:212,name:"offsetFromBlock",parser:Q},{code:211,name:"horizontalDirection",parser:Q},{code:210,name:"normal",parser:Q},{code:340,name:"associatedAnnotation",parser:y},{code:77,name:"byBlockColor",parser:y},{code:10,name:"vertices",parser:Q,isMultiple:!0},{code:76,name:"numberOfVertices",parser:y},{code:41,name:"textWidth",parser:y},{code:40,name:"textHeight",parser:y},{code:75,name:"isHooklineExists",parser:Kt},{code:74,name:"isHooklineSameDirection",parser:Kt},{code:73,name:"leaderCreationFlag",parser:y},{code:72,name:"isSpline",parser:Kt},{code:71,name:"isArrowheadEnabled",parser:Kt},{code:3,name:"styleName",parser:y},{code:100,name:"subclassMarker",parser:y},...Jt];class Va{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Fa(this,"parser",Et(cc,hc))}}Fa(Va,"ForEntityName","LEADER"),(gn={})[gn.TextAnnotation=0]="TextAnnotation",gn[gn.ToleranceAnnotation=1]="ToleranceAnnotation",gn[gn.BlockReferenceAnnotation=2]="BlockReferenceAnnotation",gn[gn.NoAnnotation=3]="NoAnnotation";function Ua(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}let uc={thickness:0,extrusionDirection:{x:0,y:0,z:1}},dc=[{code:210,name:"extrusionDirection",parser:Q},{code:11,name:"endPoint",parser:Q},{code:10,name:"startPoint",parser:Q},{code:39,name:"thickness",parser:y},{code:100,name:"subclassMarker",parser:y},...Jt];class ja{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Ua(this,"parser",Et(dc,uc))}}Ua(ja,"ForEntityName","LINE"),(Xr={})[Xr.IS_CLOSED=1]="IS_CLOSED",Xr[Xr.PLINE_GEN=128]="PLINE_GEN";let mc={flag:0,elevation:0,thickness:0,extrusionDirection:{x:0,y:0,z:1},vertices:[]},gc={bulge:0},fc=[{code:42,name:"bulge",parser:y},{code:41,name:"endWidth",parser:y},{code:40,name:"startWidth",parser:y},{code:91,name:"id",parser:y},{code:20,name:"y",parser:y},{code:10,name:"x",parser:y}],pc=[{code:210,name:"extrusionDirection",parser:Q},{code:10,name:"vertices",isMultiple:!0,parser(a,t){let e={};return Et(fc,gc)(a,t,e),e}},{code:39,name:"thickness",parser:y},{code:38,name:"elevation",parser:y},{code:43,name:"constantWidth",parser:y},{code:70,name:"flag",parser:y},{code:90,name:"numberOfVertices",parser:y},{code:100,name:"subclassMarker",parser:y},...Jt];class ki{parseEntity(t,e){let i={};return Et(pc,mc)(e,t,i),i}}ls="LWPOLYLINE",(os="ForEntityName")in ki?Object.defineProperty(ki,os,{value:ls,enumerable:!0,configurable:!0,writable:!0}):ki[os]=ls,(Kn={})[Kn.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",Kn[Kn.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",Kn[Kn.BY_STYLE=5]="BY_STYLE";function _c(a,t){let e={};for(let i of a){let l=t(i);l!=null&&(e[l]??(e[l]=[]),e[l].push(i))}return e}function*Ti(a,t=1/0,e=1){for(let i=a;i!==t;i+=e)yield i}function Pn(a){return{x:a.x??0,y:a.y??0,z:a.z??0}}function Ga(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}let vc={textStyle:"STANDARD",extrusionDirection:{x:0,y:0,z:1},rotation:0},Ci=[{code:46,name:"annotationHeight",parser:y},{code:101,parser(a,t){(function(e){e.rewind();let i=e.next();if(i.code!==101)throw Error("Bad call for skipEmbeddedObject()");do i=e.next();while(i.code!==0);e.rewind()})(t)}},{code:50,name:"columnHeight",parser:y},{code:49,name:"columnGutter",parser:y},{code:48,name:"columnWidth",parser:y},{code:79,name:"columnAutoHeight",parser:y},{code:78,name:"columnFlowReversed",parser:y},{code:76,name:"columnCount",parser:y},{code:75,name:"columnType",parser:y},{code:441,name:"backgroundFillTransparency",parser:y},{code:63,name:"backgroundFillColor",parser:y},{code:45,name:"fillBoxScale",parser:y},{code:[...Ti(430,440)],name:"backgroundColor",parser:y},{code:[...Ti(420,430)],name:"backgroundColor",parser:y},{code:90,name:"backgroundFill",parser:y},{code:44,name:"lineSpacing",parser:y},{code:73,name:"lineSpacingStyle",parser:y},{code:50,name:"rotation",parser:y},{code:43},{code:42},{code:11,name:"direction",parser:Q},{code:210,name:"extrusionDirection",parser:Q},{code:7,name:"styleName",parser:y},{code:3,name:"text",isMultiple:!0,parser:y},{code:1,name:"text",isMultiple:!0,parser:y},{code:72,name:"drawingDirection",parser:y},{code:71,name:"attachmentPoint",parser:y},{code:41,name:"width",parser:y},{code:40,name:"height",parser:y},{code:10,name:"insertionPoint",parser:Q},{code:100,name:"subclassMarker",parser:y},...Jt];class Ha{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Ga(this,"parser",Et(Ci,vc))}}function Wa(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}Ga(Ha,"ForEntityName","MTEXT");let yc={thickness:0,extrusionDirection:{x:0,y:0,z:1},angle:0},bc=[{code:50,name:"angle",parser:y},{code:210,name:"extrusionDirection",parser:Q},{code:39,name:"thickness",parser:y},{code:10,name:"position",parser:Q},{code:100,name:"subclassMarker",parser:y},...Jt];class qa{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Wa(this,"parser",Et(bc,yc))}}Wa(qa,"ForEntityName","POINT"),(oe={})[oe.CLOSED_POLYLINE=1]="CLOSED_POLYLINE",oe[oe.CURVE_FIT=2]="CURVE_FIT",oe[oe.SPLINE_FIT=4]="SPLINE_FIT",oe[oe.POLYLINE_3D=8]="POLYLINE_3D",oe[oe.POLYGON_3D=16]="POLYGON_3D",oe[oe.CLOSED_POLYGON=32]="CLOSED_POLYGON",oe[oe.POLYFACE=64]="POLYFACE",oe[oe.CONTINUOUS=128]="CONTINUOUS",(fn={})[fn.NONE=0]="NONE",fn[fn.QUADRATIC=5]="QUADRATIC",fn[fn.CUBIC=6]="CUBIC",fn[fn.BEZIER=8]="BEZIER",(le={})[le.CREATED_BY_CURVE_FIT=1]="CREATED_BY_CURVE_FIT",le[le.TANGENT_DEFINED=2]="TANGENT_DEFINED",le[le.NOT_USED=4]="NOT_USED",le[le.CREATED_BY_SPLINE_FIT=8]="CREATED_BY_SPLINE_FIT",le[le.SPLINE_CONTROL_POINT=16]="SPLINE_CONTROL_POINT",le[le.FOR_POLYLINE=32]="FOR_POLYLINE",le[le.FOR_POLYGON=64]="FOR_POLYGON",le[le.POLYFACE=128]="POLYFACE";function Ya(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}let xc={startWidth:0,endWidth:0,bulge:0},wc=[{code:91,name:"id",parser:y},{code:[...Ti(71,75)],name:"faces",isMultiple:!0,parser:y},{code:50,name:"tangentDirection",parser:y},{code:70,name:"flag",parser:y},{code:42,name:"bulge",parser:y},{code:41,name:"endWidth",parser:y},{code:40,name:"startWidth",parser:y},{code:30,name:"z",parser:y},{code:20,name:"y",parser:y},{code:10,name:"x",parser:y},{code:100,name:"subclassMarker",parser:y},{code:100},...Jt],Ka=class{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Ya(this,"parser",Et(wc,xc))}};function Xa(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}Ya(Ka,"ForEntityName","VERTEX");let Ac={thickness:0,flag:0,startWidth:0,endWidth:0,meshMVertexCount:0,meshNVertexCount:0,surfaceMDensity:0,surfaceNDensity:0,smoothType:0,extrusionDirection:{x:0,y:0,z:1},vertices:[]},Pc=[{code:0,name:"vertices",isMultiple:!0,parser:(a,t)=>Ct(a,0,"VERTEX")?(a=t.next(),new Ka().parseEntity(t,a)):fs},{code:210,name:"extrusionDirection",parser:Q},{code:75,name:"smoothType",parser:y},{code:74,name:"surfaceNDensity",parser:y},{code:73,name:"surfaceMDensity",parser:y},{code:72,name:"meshNVertexCount",parser:y},{code:71,name:"meshMVertexCount",parser:y},{code:41,name:"endWidth",parser:y},{code:40,name:"startWidth",parser:y},{code:70,name:"flag",parser:y},{code:39,name:"thickness",parser:y},{code:30,name:"elevation",parser:y},{code:20},{code:10},{code:66},{code:100,name:"subclassMarker",parser:y},...Jt];class $a{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Xa(this,"parser",Et(Pc,Ac))}}function Za(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}Xa($a,"ForEntityName","POLYLINE");let Sc={firstPoint:{x:0,y:0,z:1},extrusionDirection:{x:0,y:0,z:1}},Ic=[{code:10,name:"firstPoint",parser:Q},{code:11,name:"unitDirection",parser:Q},{code:100,name:"subclassMarker",parser:y},...Jt];class Qa{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Za(this,"parser",Et(Ic,Sc))}}function Ja(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}Za(Qa,"ForEntityName","RAY");let Ec={vertices:[],backLineVertices:[]},Mc=[{code:360,name:"geometrySettingHardId",parser:y},{code:12,name:"backLineVertices",isMultiple:!0,parser:Q},{code:93,name:"numberOfBackLineVertices",parser:y},{code:11,name:"vertices",isMultiple:!0,parser:Q},{code:92,name:"verticesCount",parser:y},{code:[63,411],name:"indicatorColor",parser:y},{code:70,name:"indicatorTransparency",parser:y},{code:41,name:"bottomHeight",parser:y},{code:40,name:"topHeight",parser:y},{code:10,name:"verticalDirection",parser:Q},{code:1,name:"name",parser:y},{code:91,name:"flag",parser:y},{code:90,name:"state",parser:y},{code:100,name:"subclassMarker",parser:y},...Jt];class to{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Ja(this,"parser",Et(Mc,Ec))}}function eo(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}Ja(to,"ForEntityName","SECTION");let kc={points:[],thickness:0,extrusionDirection:{x:0,y:0,z:1}},Tc=[{code:210,name:"extrusionDirection",parser:Q},{code:39,name:"thickness",parser:y},{code:[...Ti(10,14)],name:"points",isMultiple:!0,parser:Q},{code:100,name:"subclassMarker",parser:y},...Jt];class no{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){eo(this,"parser",Et(Tc,kc))}}eo(no,"ForEntityName","SOLID"),(Te={})[Te.NONE=0]="NONE",Te[Te.CLOSED=1]="CLOSED",Te[Te.PERIODIC=2]="PERIODIC",Te[Te.RATIONAL=4]="RATIONAL",Te[Te.PLANAR=8]="PLANAR",Te[Te.LINEAR=16]="LINEAR";function ro(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}let Cc={knotTolerance:1e-6,controlTolerance:1e-6,fitTolerance:1e-9,knotValues:[],controlPoints:[],fitPoints:[]},Lc=[{code:11,name:"fitPoints",isMultiple:!0,parser:Q},{code:10,name:"controlPoints",isMultiple:!0,parser:Q},{code:41,name:"weights",isMultiple:!0,parser:y},{code:40,name:"knots",isMultiple:!0,parser:y},{code:13,name:"endTangent",parser:Q},{code:12,name:"startTangent",parser:Q},{code:44,name:"fitTolerance",parser:y},{code:43,name:"controlTolerance",parser:y},{code:42,name:"knotTolerance",parser:y},{code:74,name:"numberOfFitPoints",parser:y},{code:73,name:"numberOfControlPoints",parser:y},{code:72,name:"numberOfKnots",parser:y},{code:71,name:"degree",parser:y},{code:70,name:"flag",parser:y},{code:210,name:"normal",parser:Q},{code:100,name:"subclassMarker",parser:y},...Jt];class io{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){ro(this,"parser",Et(Lc,Cc))}}ro(io,"ForEntityName","SPLINE");class Li{parseEntity(t,e){let i={};for(;!t.isEOF();){if(e.code===0){t.rewind();break}switch(e.code){case 100:i.subclassMarker=e.value,e=t.next();break;case 2:i.name=e.value,e=t.next();break;case 5:i.handle=e.value,e=t.next();break;case 10:i.startPoint=Pn(Bt(t)),e=t.lastReadGroup;break;case 11:i.directionVector=Pn(Bt(t)),e=t.lastReadGroup;break;case 90:i.tableValue=e.value,e=t.next();break;case 91:i.rowCount=e.value,e=t.next();break;case 92:i.columnCount=e.value,e=t.next();break;case 93:i.overrideFlag=e.value,e=t.next();break;case 94:i.borderColorOverrideFlag=e.value,e=t.next();break;case 95:i.borderLineWeightOverrideFlag=e.value,e=t.next();break;case 96:i.borderVisibilityOverrideFlag=e.value,e=t.next();break;case 141:i.rowHeightArr??(i.rowHeightArr=[]),i.rowHeightArr.push(e.value),e=t.next();break;case 142:i.columnWidthArr??(i.columnWidthArr=[]),i.columnWidthArr.push(e.value),e=t.next();break;case 280:i.version=e.value,e=t.next();break;case 310:i.bmpPreview??(i.bmpPreview=""),i.bmpPreview+=e.value,e=t.next();break;case 330:i.ownerDictionaryId=e.value,e=t.next();break;case 342:i.tableStyleId=e.value,e=t.next();break;case 343:i.blockRecordHandle=e.value,e=t.next();break;case 170:i.attachmentPoint=e.value,e=t.next();break;case 171:i.cells??(i.cells=[]),i.cells.push(function(l,h){let u=!1,f=!1,b={};for(;!l.isEOF()&&h.code!==0&&!f;)switch(h.code){case 171:if(u){f=!0;continue}b.cellType=h.value,u=!0,h=l.next();break;case 172:b.flagValue=h.value,h=l.next();break;case 173:b.mergedValue=h.value,h=l.next();break;case 174:b.autoFit=h.value,h=l.next();break;case 175:b.borderWidth=h.value,h=l.next();break;case 176:b.borderHeight=h.value,h=l.next();break;case 91:b.overrideFlag=h.value,h=l.next();break;case 178:b.virtualEdgeFlag=h.value,h=l.next();break;case 145:b.rotation=h.value,h=l.next();break;case 345:b.fieldObjetId=h.value,h=l.next();break;case 340:b.blockTableRecordId=h.value,h=l.next();break;case 146:b.blockScale=h.value,h=l.next();break;case 177:b.blockAttrNum=h.value,h=l.next();break;case 7:b.textStyle=h.value,h=l.next();break;case 140:b.textHeight=h.value,h=l.next();break;case 170:b.attachmentPoint=h.value,h=l.next();break;case 92:b.extendedCellFlags=h.value,h=l.next();break;case 285:b.rightBorderVisibility=!!(h.value??!0),h=l.next();break;case 286:b.bottomBorderVisibility=!!(h.value??!0),h=l.next();break;case 288:b.leftBorderVisibility=!!(h.value??!0),h=l.next();break;case 289:b.topBorderVisibility=!!(h.value??!0),h=l.next();break;case 301:(function(p,S,x){for(;x.code!==304;)switch(x.code){case 301:case 93:case 90:case 94:x=S.next();break;case 1:p.text=x.value,x=S.next();break;case 300:p.attrText=x.value,x=S.next();break;case 302:p.text=x.value?x.value:p.text,x=S.next();break;default:console.log(`Ignore code: ${x.code}, value: ${x.value}`),x=S.next()}})(b,l,h),h=l.next();break;default:return b}return u=!1,f=!1,b}(t,e)),e=t.lastReadGroup;break;default:ps(i,e,t),e=t.next()}}return i}}cs="ACAD_TABLE",(hs="ForEntityName")in Li?Object.defineProperty(Li,hs,{value:cs,enumerable:!0,configurable:!0,writable:!0}):Li[hs]=cs;class Ni{parseEntity(t,e){let i={};for(;e!=="EOF";){if(e.code===0){t.rewind();break}!function(l,h,u){if(u==="EOF")return!1;switch(u.code){case 0:default:return!1;case 100:l.subclassMarker=u.value;break;case 10:l.viewportCenter=Pn(Bt(h));break;case 40:l.width=u.value;break;case 41:l.height=u.value;break;case 68:l.status=u.value;break;case 69:l.viewportId=u.value;break;case 12:l.displayCenter=Bt(h);break;case 13:l.snapBase=Bt(h);break;case 14:l.snapSpacing=Bt(h);break;case 15:l.gridSpacing=Bt(h);break;case 16:l.viewDirection=Pn(Bt(h));break;case 17:l.targetPoint=Pn(Bt(h));break;case 42:l.perspectiveLensLength=u.value;break;case 43:l.frontClipZ=u.value;break;case 44:l.backClipZ=u.value;break;case 45:l.viewHeight=u.value;break;case 50:l.snapAngle=u.value;break;case 51:l.viewTwistAngle=u.value;break;case 72:l.circleZoomPercent=u.value;break;case 331:l.frozenLayerIds??(l.frozenLayerIds=[]),l.frozenLayerIds.push(u.value);break;case 90:l.statusBitFlags=u.value;break;case 330:l.ownerBlockRecordSoftId=u.value;break;case 340:l.clippingBoundaryId=u.value;break;case 1:l.sheetName=u.value;break;case 281:l.renderMode=u.value;break;case 71:l.ucsPerViewport=u.value;break;case 110:l.ucsOrigin=Pn(Bt(h));break;case 111:l.ucsXAxis=Pn(Bt(h));break;case 112:l.ucsYAxis=Pn(Bt(h));break;case 345:l.ucsId=u.value;break;case 346:l.ucsBaseId=u.value;break;case 79:l.orthographicType=u.value;break;case 146:l.elevation=u.value;break;case 170:l.shadePlotMode=u.value;break;case 61:l.majorGridFrequency=u.value;break;case 332:l.backgroundId=u.value;break;case 333:l.shadePlotId=u.value;break;case 348:l.visualStyleId=u.value;break;case 292:l.isDefaultLighting=!!u.value;break;case 282:l.defaultLightingType=u.value;break;case 141:l.brightness=u.value;break;case 142:l.contrast=u.value;break;case 63:case 421:case 431:l.ambientLightColor=u.value;break;case 361:l.sunId=u.value;break;case 335:case 343:case 344:case 91:l.softPointer=u.value}return!0}(i,t,e)&&ps(i,e,t),e=t.next()}return i}}ds="VIEWPORT",(us="ForEntityName")in Ni?Object.defineProperty(Ni,us,{value:ds,enumerable:!0,configurable:!0,writable:!0}):Ni[us]=ds;class zi extends _s{parseEntity(t,e){return super.parseEntity(t,e)}}function so(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}gs="WIPEOUT",(ms="ForEntityName")in zi?Object.defineProperty(zi,ms,{value:gs,enumerable:!0,configurable:!0,writable:!0}):zi[ms]=gs;let Nc={firstPoint:{x:0,y:0,z:1},extrusionDirection:{x:0,y:0,z:1}},zc=[{code:10,name:"firstPoint",parser:Q},{code:11,name:"unitDirection",parser:Q},{code:100,name:"subclassMarker",parser:y},...Jt];class ao{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){so(this,"parser",Et(zc,Nc))}}function oo(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}so(ao,"ForEntityName","XLINE");let Dc={thickness:0,rotation:0,scale:1,obliqueAngle:0,textStyle:"STANDARD",textGenerationFlag:0,horizontalJustification:0,verticalJustification:0,extrusionDirection:{x:0,y:0,z:1}},Oc=[...Ci.slice(Ci.findIndex(({name:a})=>a==="columnType"),Ci.findIndex(({name:a})=>a==="subclassMarker")+1),{code:100},{code:0,parser(a){if(!Ct(a,0,"MTEXT"))return fs}},{code:2,name:"definitionTag",parser:y},{code:40,name:"annotationScale",parser:y},{code:10,name:"alignmentPoint",parser:Q},{code:340,name:"secondaryAttributesHardId",parser:y},{code:70,name:"numberOfSecondaryAttributes",parser:y},{code:70,name:"isReallyLocked",parser:Kt},{code:70,name:"mtextFlag",parser:y},{code:280,name:"isDuplicatedEntriesKeep",parser:Kt},{code:100},{code:280,name:"lockPositionFlag",parser:Kt},{code:210,name:"extrusionDirection",parser:Q},{code:11,name:"alignmentPoint",parser:Q},{code:74,name:"verticalJustification",parser:y},{code:72,name:"horizontalJustification",parser:y},{code:71,name:"textGenerationFlag",parser:y},{code:7,name:"textStyle",parser:y},{code:51,name:"obliqueAngle",parser:y},{code:41,name:"scale",parser:y},{code:50,name:"rotation",parser:y},{code:73},{code:70,name:"attributeFlag",parser:y},{code:2,name:"tag",parser:y},{code:280},{code:100,name:"subclassMarker",parser:y},{code:1,name:"text",parser:y},{code:40,name:"textHeight",parser:y},{code:10,name:"startPoint",parser:Q},{code:39,name:"thickness",parser:y},{code:100},...Jt];class lo{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){oo(this,"parser",Et(Oc,Dc))}}oo(lo,"ForEntityName","ATTRIB");let Rc=Object.fromEntries([xa,Ea,lo,ka,Mi,Ca,_s,Ba,Va,ja,ki,Ha,qa,$a,Qa,to,no,io,Li,Sa,Da,Ni,zi,ao].map(a=>[a.ForEntityName,new a]));function ho(a,t){let e=[];for(;!Ct(a,0,"EOF");){if(a.code===0){if(a.value==="ENDBLK"||a.value==="ENDSEC"){t.rewind();break}let i=Rc[a.value];if(i){let l=a.value;a=t.next();let h=i.parseEntity(t,a);h.type=l,ya(h),e.push(h)}else console.warn(`Unsupported ENTITY type: ${a.value}`)}a=t.next()}return e}function Bc(a,t){let e={};for(;!Ct(a,0,"EOF")&&!Ct(a,0,"ENDSEC");){if(Ct(a,0,"BLOCK")){let i=Fc(a=t.next(),t);ya(i),i.name&&(e[i.name]=i)}a=t.next()}return e}function Fc(a,t){let e={};for(;!Ct(a,0,"EOF");){if(Ct(a,0,"ENDBLK")){for(a=t.next();!Ct(a,0,"EOF");){if(Ct(a,100,"AcDbBlockEnd"))return e;a=t.next()}break}switch(a.code){case 1:e.xrefPath=a.value;break;case 2:e.name=a.value;break;case 3:e.name2=a.value;break;case 5:e.handle=a.value;break;case 8:e.layer=a.value;break;case 10:e.position=Bt(t);break;case 67:e.paperSpace=!!a.value&&a.value==1;break;case 70:a.value!==0&&(e.type=a.value);break;case 100:break;case 330:e.ownerHandle=a.value;break;case 0:e.entities=ho(a,t)}a=t.next()}return e}function Vc(a,t){let e=null,i={};for(;!Ct(a,0,"EOF")&&!Ct(a,0,"ENDSEC");)a.code===9?e=a.value:a.code===10?i[e]=Bt(t):i[e]=a.value,a=t.next();return i}let Uc=[{code:330,name:"imageDefReactorIdSoft",isMultiple:!0,parser:y},{code:90,name:"version",parser:y},{code:1,name:"fileName",parser:y},{code:10,name:"size",parser:Q},{code:11,name:"sizeOfOnePixel",parser:Q},{code:280,name:"isLoaded",parser:y},{code:281,name:"resolutionUnits",parser:y},{code:100,name:"subclassMarker",parser:y}],co=[{code:333,name:"shadePlotId",parser:y},{code:149,name:"imageOriginY",parser:y},{code:148,name:"imageOriginX",parser:y},{code:147,name:"scaleFactor",parser:y},{code:78,name:"shadePlotCustomDPI",parser:y},{code:77,name:"shadePlotResolution",parser:y},{code:76,name:"shadePlotMode",parser:y},{code:75,name:"standardScaleType",parser:y},{code:7,name:"currentStyleSheet",parser:y},{code:74,name:"plotType",parser:y},{code:73,name:"plotRotation",parser:y},{code:72,name:"paperUnit",parser:y},{code:70,name:"layoutFlag",parser:y},{code:143,name:"printScaleDenominator",parser:y},{code:142,name:"printScaleNominator",parser:y},{code:141,name:"windowAreaYMax",parser:y},{code:140,name:"windowAreaYMin",parser:y},{code:49,name:"windowAreaXMax",parser:y},{code:48,name:"windowAreaXMin",parser:y},{code:47,name:"plotOriginY",parser:y},{code:46,name:"plotOriginX",parser:y},{code:45,name:"paperHeight",parser:y},{code:44,name:"paperWidth",parser:y},{code:43,name:"marginTop",parser:y},{code:42,name:"marginRight",parser:y},{code:41,name:"marginBottom",parser:y},{code:40,name:"marginLeft",parser:y},{code:6,name:"plotViewName",parser:y},{code:4,name:"paperSize",parser:y},{code:2,name:"configName",parser:y},{code:1,name:"pageSetupName",parser:y},{code:100,name:"subclassMarker",parser:y}],jc=[{code:333,name:"shadePlotId",parser:y},{code:346,name:"orthographicUcsId",parser:y},{code:345,name:"namedUcsId",parser:y},{code:331,name:"viewportId",parser:y},{code:330,name:"paperSpaceTableId",parser:y},{code:76,name:"orthographicType",parser:y},{code:17,name:"ucsYAxis",parser:Q},{code:16,name:"ucsXAxis",parser:Q},{code:13,name:"ucsOrigin",parser:Q},{code:146,name:"elevation",parser:y},{code:15,name:"maxExtent",parser:Q},{code:14,name:"minExtent",parser:Q},{code:12,name:"insertionBase",parser:Q},{code:11,name:"maxLimit",parser:Q},{code:10,name:"minLimit",parser:Q},{code:71,name:"tabOrder",parser:y},{code:70,name:"controlFlag",parser:y},{code:1,name:"layoutName",parser:y},{code:100,name:"subclassMarker",parser:y},...co],Gc=[{code:330,name:"ownerObjectId",parser:y},{code:102},{code:360,name:"ownerDictionaryIdHard",parser:y},{code:102},{code:102},{code:330,name:"ownerDictionaryIdSoft",parser:y},{code:102},{code:102},{code:102},{code:5,name:"handle",parser:y}];function uo(a){return a.subclassMarker==="AcDbDictionary"}let Hc={LAYOUT:jc,PLOTSETTINGS:co,DICTIONARY:[{code:3,name:"entries",parser:(a,t)=>{let e={name:a.value};return(a=t.next()).code===350?e.objectId=a.value:t.rewind(),e},isMultiple:!0},{code:281,name:"recordCloneFlag",parser:y},{code:280,name:"isHardOwned",parser:Kt},{code:100,name:"subclassMarker",parser:y}],IMAGEDEF:Uc};function Wc(a,t){let e=[];for(;a.code!==0||!["EOF","ENDSEC"].includes(a.value);){let i=a.value,l=Hc[i];if(a.code===0&&(l!=null&&l.length)){let h=Et([...Gc,...l]),u={name:i};h(a=t.next(),t,u)?(e.push(u),a=t.peek()):a=t.next()}else a=t.next()}return{byName:_c(e,({name:i})=>i),byTree:function(i){let l=Object.fromEntries(i.map(h=>[h.handle,h]));for(let h of i)(!uo(h)||h.ownerDictionaryIdSoft!=="0")&&(h.ownerDictionaryIdSoft&&(h.ownerDictionarySoft=l[h.ownerDictionaryIdSoft]),h.ownerDictionaryIdHard&&(h.ownerDictionaryHard=l[h.ownerDictionaryIdHard]),h.ownerObjectId&&(h.ownerObject=l[h.ownerObjectId])),function(u,f){uo(u)&&u.entries&&(u.entries=Object.fromEntries(u.entries.map(({name:b,objectId:p})=>[b,f[p]])))}(h,l);return i[0]}(e)}}let mr=[{code:100,name:"subclassMarker",parser:y},{code:330,name:"ownerObjectId",parser:y},{code:102,parser(a,t){for(;!Ct(a,0,"EOF")&&!Ct(a,102,"}");)a=t.next()}},{code:5,name:"handle",parser:y}],qc=Et([{code:310,name:"bmpPreview",parser:y},{code:281,name:"scalability",parser:y},{code:280,name:"explodability",parser:y},{code:70,name:"insertionUnits",parser:y},{code:340,name:"layoutObjects",parser:y},{code:2,name:"name",parser:y},{code:100,name:"subclassMarker",parser:y},...mr]),Yc=Et([...[{name:"DIMPOST",code:3},{name:"DIMAPOST",code:4},{name:"DIMBLK_OBSOLETE",code:5},{name:"DIMBLK1_OBSOLETE",code:6},{name:"DIMBLK2_OBSOLETE",code:7},{name:"DIMSCALE",code:40,defaultValue:1},{name:"DIMASZ",code:41,defaultValue:.25},{name:"DIMEXO",code:42,defaultValue:.625,defaultValueImperial:.0625},{name:"DIMDLI",code:43,defaultValue:3.75,defaultValueImperial:.38},{name:"DIMEXE",code:44,defaultValue:2.25,defaultValueImperial:.28},{name:"DIMRND",code:45,defaultValue:0},{name:"DIMDLE",code:46,defaultValue:0},{name:"DIMTP",code:47,defaultValue:0},{name:"DIMTM",code:48,defaultValue:0},{name:"DIMTXT",code:140,defaultValue:2.5,defaultValueImperial:.28},{name:"DIMCEN",code:141,defaultValue:2.5,defaultValueImperial:.09},{name:"DIMTSZ",code:142,defaultValue:0},{name:"DIMALTF",code:143,defaultValue:25.4},{name:"DIMLFAC",code:144,defaultValue:1},{name:"DIMTVP",code:145,defaultValue:0},{name:"DIMTFAC",code:146,defaultValue:1},{name:"DIMGAP",code:147,defaultValue:.625,defaultValueImperial:.09},{name:"DIMALTRND",code:148,defaultValue:0},{name:"DIMTOL",code:71,defaultValue:0,defaultValueImperial:1},{name:"DIMLIM",code:72,defaultValue:0},{name:"DIMTIH",code:73,defaultValue:0,defaultValueImperial:1},{name:"DIMTOH",code:74,defaultValue:0,defaultValueImperial:1},{name:"DIMSE1",code:75,defaultValue:0},{name:"DIMSE2",code:76,defaultValue:0},{name:"DIMTAD",code:77,defaultValue:pa.Above,defaultValueImperial:pa.Center},{name:"DIMZIN",code:78,defaultValue:dr.Trailing,defaultValueImperial:dr.Feet},{name:"DIMAZIN",code:79,defaultValue:Nh.None},{name:"DIMALT",code:170,defaultValue:0},{name:"DIMALTD",code:171,defaultValue:3,defaultValueImperial:2},{name:"DIMTOFL",code:172,defaultValue:1,defaultValueImperial:0},{name:"DIMSAH",code:173,defaultValue:0},{name:"DIMTIX",code:174,defaultValue:0},{name:"DIMSOXD",code:175,defaultValue:0},{name:"DIMCLRD",code:176,defaultValue:0},{name:"DIMCLRE",code:177,defaultValue:0},{name:"DIMCLRT",code:178,defaultValue:0},{name:"DIMADEC",code:179},{name:"DIMUNIT",code:270},{name:"DIMDEC",code:271,defaultValue:2,defaultValueImperial:4},{name:"DIMTDEC",code:272,defaultValue:2,defaultValueImperial:4},{name:"DIMALTU",code:273,defaultValue:2},{name:"DIMALTTD",code:274,defaultValue:2,defaultValueImperial:4},{name:"DIMAUNIT",code:275,defaultValue:0},{name:"DIMFRAC",code:276,defaultValue:0},{name:"DIMLUNIT",code:277,defaultValue:2},{name:"DIMDSEP",code:278,defaultValue:",",defaultValueImperial:"."},{name:"DIMJUST",code:280,defaultValue:zh.Center},{name:"DIMSD1",code:281,defaultValue:0},{name:"DIMSD2",code:282,defaultValue:0},{name:"DIMTOLJ",code:283,defaultValue:Dh.Center},{name:"DIMTZIN",code:284,defaultValue:dr.Trailing,defaultValueImperial:dr.Feet},{name:"DIMALTZ",code:285,defaultValue:dr.Trailing},{name:"DIMALTTZ",code:286,defaultValue:dr.Trailing},{name:"DIMFIT",code:287},{name:"DIMUPT",code:288,defaultValue:0},{name:"DIMATFIT",code:289,defaultValue:3},{name:"DIMTXSTY",code:340},{name:"DIMLDRBLK",code:341},{name:"DIMBLK",code:342},{name:"DIMBLK1",code:343},{name:"DIMBLK2",code:344},{name:"DIMLWD",code:371,defaultValue:-2},{name:"DIMLWD",code:372,defaultValue:-2}].map(a=>({...a,parser:y})),{code:70,name:"standardFlag",parser:y},{code:2,name:"name",parser:y},{code:100,name:"subclassMarker",parser:y},{code:105,name:"handle",parser:y},...mr.filter(a=>a.code!==5)]),Kc=Et([{code:347,name:"materialObjectId",parser:y},{code:390,name:"plotStyleNameObjectId",parser:y},{code:370,name:"lineweight",parser:y},{code:290,name:"isPlotting",parser:Kt},{code:6,name:"lineType",parser:y},{code:62,name:"colorIndex",parser:y},{code:70,name:"standardFlag",parser:y},{code:2,name:"name",parser:y},{code:100,name:"subclassMarker",parser:y},...mr]),Xc=Et([{code:9,name:"text",parser:y},{code:45,name:"offsetY",parser:y},{code:44,name:"offsetX",parser:y},{code:50,name:"rotation",parser:y},{code:46,name:"scale",parser:y},{code:340,name:"styleObjectId",parser:y},{code:75,name:"shapeNumber",parser:y},{code:74,name:"elementTypeFlag",parser:y},{code:49,name:"elementLength",parser:y}],{elementTypeFlag:0,elementLength:0}),$c={BLOCK_RECORD:qc,DIMSTYLE:Yc,LAYER:Kc,LTYPE:Et([{code:49,name:"pattern",parser(a,t){let e={};return Xc(a,t,e),e},isMultiple:!0},{code:40,name:"totalPatternLength",parser:y},{code:73,name:"numberOfLineTypes",parser:y},{code:72,parser:y},{code:3,name:"description",parser:y},{code:70,name:"standardFlag",parser:y},{code:2,name:"name",parser:y},{code:100,name:"subclassMarker",parser:y},...mr]),STYLE:Et([{code:1e3,name:"extendedFont",parser:y},{code:1001},{code:4,name:"bigFont",parser:y},{code:3,name:"font",parser:y},{code:42,name:"lastHeight",parser:y},{code:71,name:"textGenerationFlag",parser:y},{code:50,name:"obliqueAngle",parser:y},{code:41,name:"widthFactor",parser:y},{code:40,name:"fixedTextHeight",parser:y},{code:70,name:"standardFlag",parser:y},{code:2,name:"name",parser:y},{code:100,name:"subclassMarker",parser:y},...mr]),VPORT:Et([{code:[63,421,431],name:"ambientColor",parser:y},{code:142,name:"contrast",parser:y},{code:141,name:"brightness",parser:y},{code:282,name:"defaultLightingType",parser:y},{code:292,name:"isDefaultLightingOn",parser:Kt},{code:348,name:"visualStyleObjectId",parser:y},{code:333,name:"shadePlotObjectId",parser:y},{code:332,name:"backgroundObjectId",parser:y},{code:61,name:"majorGridLines",parser:y},{code:170,name:"shadePlotSetting",parser:y},{code:146,name:"elevation",parser:y},{code:79,name:"orthographicType",parser:y},{code:112,name:"ucsYAxis",parser:Q},{code:111,name:"ucsXAxis",parser:Q},{code:110,name:"ucsOrigin",parser:Q},{code:74,name:"ucsIconSetting",parser:y},{code:71,name:"viewMode",parser:y},{code:281,name:"renderMode",parser:y},{code:1,name:"styleSheet",parser:y},{code:[331,441],name:"frozenLayers",parser:y,isMultiple:!0},{code:72,name:"circleSides",parser:y},{code:51,name:"viewTwistAngle",parser:y},{code:50,name:"snapRotationAngle",parser:y},{code:45,name:"viewHeight",parser:y},{code:44,name:"backClippingPlane",parser:y},{code:43,name:"frontClippingPlane",parser:y},{code:42,name:"lensLength",parser:y},{code:17,name:"viewTarget",parser:Q},{code:16,name:"viewDirectionFromTarget",parser:Q},{code:15,name:"gridSpacing",parser:Q},{code:14,name:"snapSpacing",parser:Q},{code:13,name:"snapBasePoint",parser:Q},{code:12,name:"center",parser:Q},{code:11,name:"upperRightCorner",parser:Q},{code:10,name:"lowerLeftCorner",parser:Q},{code:70,name:"standardFlag",parser:y},{code:2,name:"name",parser:y},{code:100,name:"subclassMarker",parser:y},...mr])},Zc=Et([{code:70,name:"maxNumberOfEntries",parser:y},{code:100,name:"subclassMarker",parser:y},{code:330,name:"ownerObjectId",parser:y},{code:102},{code:360,isMultiple:!0},{code:102},{code:5,name:"handle",parser:y},{code:2,name:"name",parser:y}]);function Qc(a,t){var i;let e={};for(;!Ct(a,0,"EOF")&&!Ct(a,0,"ENDSEC");){if(Ct(a,0,"TABLE")){a=t.next();let l={entries:[]};Zc(a,t,l),e[l.name]=l}if(Ct(a,0)&&!Ct(a,0,"ENDTAB")){let l=a.value;a=t.next();let h=$c[l];if(!h){console.warn(`parseTable: Invalid table name '${l}'`),a=t.next();continue}let u={};h(a,t,u),(i=e[l])==null||i.entries.push(u)}a=t.next()}return e}function Di(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}class mo{next(){if(!this.hasNext())return this._eof?console.warn("Cannot call 'next' after EOF group has been read"):console.warn("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]),{code:0,value:"EOF"};let t=parseInt(this._data[this._pointer++],10),e=go(t,this._data[this._pointer++]),i={code:t,value:e};return Ct(i,0,"EOF")&&(this._eof=!0),this.lastReadGroup=i,i}peek(){if(!this.hasNext())throw this._eof?Error("Cannot call 'next' after EOF group has been read"):Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);let t={code:parseInt(this._data[this._pointer]),value:0};return t.value=go(t.code,this._data[this._pointer+1]),t}rewind(t){t=t||1,this._pointer=this._pointer-2*t}hasNext(){return!this._eof&&!(this._pointer>this._data.length-2)}isEOF(){return this._eof}constructor(t){Di(this,"_pointer",void 0),Di(this,"_data",void 0),Di(this,"_eof",void 0),Di(this,"lastReadGroup",{code:0,value:0}),this._pointer=0,this._data=t,this._eof=!1}}function go(a,t){return a<=9?t:a>=10&&a<=59?parseFloat(t.trim()):a>=60&&a<=99?parseInt(t.trim()):a>=100&&a<=109?t:a>=110&&a<=149?parseFloat(t.trim()):a>=160&&a<=179?parseInt(t.trim()):a>=210&&a<=239?parseFloat(t.trim()):a>=270&&a<=289?parseInt(t.trim()):a>=290&&a<=299?function(e){if(e==="0")return!1;if(e==="1")return!0;throw TypeError("String '"+e+"' cannot be cast to Boolean type")}(t.trim()):a>=300&&a<=369?t:a>=370&&a<=389?parseInt(t.trim()):a>=390&&a<=399?t:a>=400&&a<=409?parseInt(t.trim()):a>=410&&a<=419?t:a>=420&&a<=429?parseInt(t.trim()):a>=430&&a<=439?t:a>=440&&a<=459?parseInt(t.trim()):a>=460&&a<=469?parseFloat(t.trim()):a>=470&&a<=481||a===999||a>=1e3&&a<=1009?t:a>=1010&&a<=1059?parseFloat(t.trim()):a>=1060&&a<=1071?parseInt(t.trim()):(console.log("WARNING: Group code does not have a defined type: %j",{code:a,value:t}),t)}function vs(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}let Jc=class{constructor(){vs(this,"encoding","utf-8"),vs(this,"encodingFailureFatal",!1)}};class tu extends EventTarget{parseSync(t){let e=new mo(t.split(/\r\n|\r|\n/g));if(!e.hasNext())throw Error("Empty file");return this.parseAll(e)}parseStream(t){let e="",i=this;return new Promise((l,h)=>{t.on("data",u=>{e+=u}),t.on("end",()=>{try{let u=e.split(/\r\n|\r|\n/g),f=new mo(u);if(!f.hasNext())throw Error("Empty file");l(i.parseAll(f))}catch(u){h(u)}}),t.on("error",u=>{h(u)})})}async parseFromUrl(t,e){let i=await fetch(t,e);if(!i.body)return null;let l=i.body.getReader(),h="";for(;;){let{done:u,value:f}=await l.read();if(u){h+=this._decoder.decode(new ArrayBuffer(0),{stream:!1});break}h+=this._decoder.decode(f,{stream:!0})}return this.parseSync(h)}parseAll(t){let e={header:{},blocks:{},entities:[],tables:{},objects:{byName:{},byTree:void 0}},i=t.next();for(;!Ct(i,0,"EOF");)Ct(i,0,"SECTION")&&(Ct(i=t.next(),2,"HEADER")?(i=t.next(),e.header=Vc(i,t)):Ct(i,2,"BLOCKS")?(i=t.next(),e.blocks=Bc(i,t)):Ct(i,2,"ENTITIES")?(i=t.next(),e.entities=ho(i,t)):Ct(i,2,"TABLES")?(i=t.next(),e.tables=Qc(i,t)):Ct(i,2,"OBJECTS")&&(i=t.next(),e.objects=Wc(i,t))),i=t.next();return e}constructor(t=new Jc){super(),vs(this,"_decoder",void 0),this._decoder=new TextDecoder(t.encoding,{fatal:t.encodingFailureFatal})}}var ys=(a=>(a[a.DecimalDegrees=0]="DecimalDegrees",a[a.DegreesMinutesSeconds=1]="DegreesMinutesSeconds",a[a.Gradians=2]="Gradians",a[a.Radians=3]="Radians",a[a.SurveyorsUnits=4]="SurveyorsUnits",a))(ys||{});class Sn{static get instance(){return this._instance||(this._instance=new Sn),this._instance}constructor(){this._blocks=new Map}createKey(t,e){return`${t}_${e}`}set(t,e){return e=e.fastDeepClone(),this._blocks.set(t,e),e}get(t){let e=this._blocks.get(t);return e&&(e=e.fastDeepClone()),e}has(t){return this._blocks.has(t)}clear(){this._blocks.clear()}draw(t,e,i,l=!0,h,u){const f=[];if(e!=null){const b=this.createKey(e.name,i);let p;if(this.has(b))p=this.get(b);else{const S=e.newIterator();for(const x of S)if(x.color.isByBlock&&i){fo.copy(x.color),x.color.color=i;const E=x.draw(t);E&&f.push(E),x.color.copy(fo)}else{const E=x.draw(t);E&&f.push(E)}p=t.group(f),p&&l&&this.set(b,p)}return p&&h&&(p.applyMatrix(h),u&&(u.x!=0||u.y!=0||u.z!=1)&&(h.setFromExtrusionDirection(u),p.applyMatrix(h))),p}else return t.group(f)}}const fo=new jn,Oi="Continuous",Ri="ByLayer",po="ByBlock";var Xn=(a=>(a[a.EndPoint=1]="EndPoint",a[a.MidPoint=2]="MidPoint",a[a.Center=3]="Center",a[a.Node=4]="Node",a[a.Quadrant=5]="Quadrant",a[a.Insertion=7]="Insertion",a[a.Perpendicular=8]="Perpendicular",a[a.Tangent=9]="Tangent",a[a.Nearest=10]="Nearest",a[a.Centroid=11]="Centroid",a))(Xn||{}),bs=(a=>(a[a.Undefined=0]="Undefined",a[a.Inches=1]="Inches",a[a.Feet=2]="Feet",a[a.Miles=3]="Miles",a[a.Millimeters=4]="Millimeters",a[a.Centimeters=5]="Centimeters",a[a.Meters=6]="Meters",a[a.Kilometers=7]="Kilometers",a[a.Microinches=8]="Microinches",a[a.Mils=9]="Mils",a[a.Yards=10]="Yards",a[a.Angstroms=11]="Angstroms",a[a.Nanometers=12]="Nanometers",a[a.Microns=13]="Microns",a[a.Decimeters=14]="Decimeters",a[a.Dekameters=15]="Dekameters",a[a.Hectometers=16]="Hectometers",a[a.Gigameters=17]="Gigameters",a[a.Astronomical=18]="Astronomical",a[a.LightYears=19]="LightYears",a[a.Parsecs=20]="Parsecs",a[a.USSurveyFeet=21]="USSurveyFeet",a[a.USSurveyInch=22]="USSurveyInch",a[a.USSurveyYard=23]="USSurveyYard",a[a.USSurveyMile=24]="USSurveyMile",a[a.Max=24]="Max",a))(bs||{});function eu(a){return a==4||a==5||a==6||a==7||a==12||a==13||a==14||a==15||a==16||a==17}function nu(a){return a==1||a==2||a==3||a==8||a==9||a==10||a==21}var _o=(a=>(a.ClosedFilled="",a.Dot="_DOT",a.DotSmall="_DOTSMALL",a.DotBlank="_DOTBLANK",a.Origin="_ORIGIN",a.Origin2="_ORIGIN2",a.Open="_OPEN",a.Open90="_OPEN90",a.Open30="_OPEN30",a.Closed="_CLOSED",a.Small="_SMALL",a.None="_NONE",a.Oblique="_OBLIQUE",a.BoxFilled="_BOXFILLED",a.Box="_BOXBLANK",a.ClosedBlank="_CLOSEDBLANK",a.DatumBlank="_DATUMBLANK",a.DatumFilled="_DATUMFILLED",a.Integral="_INTEGRAL",a.ArchTick="_ARCHTICK",a))(_o||{});class Bi{constructor(t){this.i=0,this._records=t,this._keys=Array.from(t.keys())}[Symbol.iterator](){return this}next(){for(;this.i<this._keys.length;){const t=this._records.get(this._keys[this.i]);return this.i+=1,{value:t,done:!1}}return{value:null,done:!0}}}const vo="Load Database";class we extends ua{constructor(t,e){super(t.stage),this.data=t,this.progress=e}async run(t){const e=is.getInstance().getEntry(vo),i=Date.now();this.progress&&await this.progress(this.data.progress.value,this.data.stage,"START");const l=await this.data.task(t);if(this.progress){const h=l.data;await this.progress(this.data.progress.value,this.data.stage,"END",h),this.data.progress.value+=this.data.step,this.data.progress.value>100&&(this.data.progress.value=100)}return e&&(e.data[this.name]=Date.now()-i),l}}class yo{async read(t,e,i,l){const h={name:vo,data:{total:0},format(){let p="";return Object.keys(this.data).forEach(S=>{S!=="total"&&(p+=`- ${S}: ${this.data[S]} ms
2
+ `)}),p+=`- total: ${this.data.total} ms`,p}};is.getInstance().collect(h),this.progress=l;const u={value:0},f=new da;f.setCompleteCallback(()=>this.onFinished()),f.setErrorCallback(()=>this.onFinished()),f.addTask(new we({stage:"START",step:1,progress:u,task:async p=>p},l)),f.addTask(new we({stage:"PARSE",step:5,progress:u,task:async p=>({model:await this.parse(p)})},l)),f.addTask(new we({stage:"FONT",step:5,progress:u,task:async p=>{const S=this.getFonts(p.model);return{model:p.model,data:S}}},l)),f.addTask(new we({stage:"LTYPE",step:1,progress:u,task:async p=>(this.processLineTypes(p.model,e),p)},l)),f.addTask(new we({stage:"STYLE",step:1,progress:u,task:async p=>(this.processTextStyles(p.model,e),p)},l)),f.addTask(new we({stage:"DIMSTYLE",step:1,progress:u,task:async p=>(this.processDimStyles(p.model,e),p)},l)),f.addTask(new we({stage:"LAYER",step:1,progress:u,task:async p=>(this.processLayers(p.model,e),p)},l)),f.addTask(new we({stage:"VPORT",step:1,progress:u,task:async p=>(this.processViewports(p.model,e),p)},l)),f.addTask(new we({stage:"HEADER",step:1,progress:u,task:async p=>(this.processHeader(p.model,e),p)},l)),f.addTask(new we({stage:"BLOCK_RECORD",step:5,progress:u,task:async p=>(this.processBlockTables(p.model,e),p)},l)),f.addTask(new we({stage:"OBJECT",step:5,progress:u,task:async p=>(this.processObjects(p.model,e),p)},l)),f.addTask(new we({stage:"BLOCK",step:5,progress:u,task:async p=>(await this.processBlocks(p.model,e),p)},l)),f.addTask(new we({stage:"ENTITY",step:100,progress:u,task:async p=>(await this.processEntities(p.model,e,i,u,l),p)},l)),f.addTask(new we({stage:"END",step:0,progress:u,task:async p=>p},l));const b=Date.now();await f.run(t),h.data.total=Date.now()-b}onFinished(){this.progress&&(this.progress(100,"END","END"),Sn.instance.clear())}parse(t){throw new Error("Not impelemented yet!")}getFonts(t){throw new Error("Not impelemented yet!")}processLineTypes(t,e){throw new Error("Not impelemented yet!")}processTextStyles(t,e){throw new Error("Not impelemented yet!")}processDimStyles(t,e){throw new Error("Not impelemented yet!")}processLayers(t,e){throw new Error("Not impelemented yet!")}processViewports(t,e){throw new Error("Not impelemented yet!")}processHeader(t,e){throw new Error("Not impelemented yet!")}processBlockTables(t,e){throw new Error("Not impelemented yet!")}processObjects(t,e){throw new Error("Not impelemented yet!")}processBlocks(t,e){throw new Error("Not impelemented yet!")}processEntities(t,e,i,l,h){throw new Error("Not impelemented yet!")}}const de=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let bo=1234567;const xs=Math.PI/180,ws=180/Math.PI;function xo(){const a=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(de[a&255]+de[a>>8&255]+de[a>>16&255]+de[a>>24&255]+"-"+de[t&255]+de[t>>8&255]+"-"+de[t>>16&15|64]+de[t>>24&255]+"-"+de[e&63|128]+de[e>>8&255]+"-"+de[e>>16&255]+de[e>>24&255]+de[i&255]+de[i>>8&255]+de[i>>16&255]+de[i>>24&255]).toLowerCase()}function _n(a,t,e){return Math.max(t,Math.min(e,a))}function As(a,t){return(a%t+t)%t}function wo(a,t,e,i,l){return i+(a-t)*(l-i)/(e-t)}function Ao(a,t,e){return a!==t?(e-a)/(t-a):0}function Ps(a,t,e){return(1-e)*a+e*t}function Po(a,t,e,i){return Ps(a,t,1-Math.exp(-e*i))}function So(a,t=1){return t-Math.abs(As(a,t*2)-t)}function Io(a,t,e){return a<=t?0:a>=e?1:(a=(a-t)/(e-t),a*a*(3-2*a))}function Eo(a,t,e){return a<=t?0:a>=e?1:(a=(a-t)/(e-t),a*a*a*(a*(a*6-15)+10))}function Mo(a,t){return a+Math.floor(Math.random()*(t-a+1))}function ko(a,t){return a+Math.random()*(t-a)}function To(a){return a*(.5-Math.random())}function Co(a){a!==void 0&&(bo=a);let t=bo+=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 Lo(a){return a*xs}function No(a){return a*ws}function zo(a){return(a&a-1)===0&&a!==0}function Do(a){return Math.pow(2,Math.ceil(Math.log(a)/Math.LN2))}function Oo(a){return Math.pow(2,Math.floor(Math.log(a)/Math.LN2))}function $r(a){const t=Math.PI*2;return(a%t+t)%t}function Ro(a,t,e){return a>t&&a<e||a>e&&a<t}function Bo(a,t,e,i=!1){return a=$r(a),t=$r(t),e=$r(e),i?t>e?a<=t&&a>=e:a<=t||a>=e:t<e?a>=t&&a<=e:a>=t||a<=e}function Ss(a){return a=Math.abs(a),a<1?0:Math.ceil(Math.log10(Math.abs(a)+1))}function Fo(a,t=1e-7){const e=Ss(a);return Math.max(Math.pow(10,e)*t,t)}const zt={DEG2RAD:xs,RAD2DEG:ws,generateUUID:xo,clamp:_n,euclideanModulo:As,mapLinear:wo,inverseLerp:Ao,lerp:Ps,damp:Po,pingpong:So,smoothstep:Io,smootherstep:Eo,randInt:Mo,randFloat:ko,randFloatSpread:To,seededRandom:Co,degToRad:Lo,radToDeg:No,isPowerOfTwo:zo,ceilPowerOfTwo:Do,floorPowerOfTwo:Oo,normalizeAngle:$r,isBetween:Ro,isBetweenAngle:Bo,intPartLength:Ss,relativeEps:Fo},Is=class bh{constructor(t,e){this.x=0,this.y=0;const 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){const{x:l,y:h}=t;this.x=l,this.y=h;return}if(i===2){this.x=t,this.y=e;return}throw Ie.ILLEGAL_PARAMETERS}}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(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}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new bh(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix2d(t){const e=this.x,i=this.y,l=t.elements;return this.x=l[0]*e+l[3]*i+l[6],this.y=l[1]*e+l[4]*i+l[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(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}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,i)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y;return e*e+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}rotateAround(t,e){const i=Math.cos(e),l=Math.sin(e),h=this.x-t.x,u=this.y-t.y;return this.x=h*i-u*l+t.x,this.y=h*l+u*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}relativeEps(t=1e-7){return Math.min(zt.relativeEps(this.x,t),zt.relativeEps(this.y,t))}*[Symbol.iterator](){yield this.x,yield this.y}};Is.EMPTY=Object.freeze(new Is(0,0));let Xt=Is;const Es=class xh{constructor(t,e,i,l,h,u,f,b,p){this.elements=[1,0,0,0,1,0,0,0,1],t!=null&&e!=null&&i!=null&&l!=null&&h!=null&&u!=null&&f!=null&&b!=null&&p!=null&&this.set(t,e,i,l,h,u,f,b,p)}set(t,e,i,l,h,u,f,b,p){const S=this.elements;return S[0]=t,S[1]=l,S[2]=f,S[3]=e,S[4]=h,S[5]=b,S[6]=i,S[7]=u,S[8]=p,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const 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}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const 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}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,l=e.elements,h=this.elements,u=i[0],f=i[3],b=i[6],p=i[1],S=i[4],x=i[7],E=i[2],T=i[5],O=i[8],R=l[0],G=l[3],F=l[6],pt=l[1],_t=l[4],ut=l[7],W=l[2],gt=l[5],ht=l[8];return h[0]=u*R+f*pt+b*W,h[3]=u*G+f*_t+b*gt,h[6]=u*F+f*ut+b*ht,h[1]=p*R+S*pt+x*W,h[4]=p*G+S*_t+x*gt,h[7]=p*F+S*ut+x*ht,h[2]=E*R+T*pt+O*W,h[5]=E*G+T*_t+O*gt,h[8]=E*F+T*ut+O*ht,this}multiplyScalar(t){const 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}determinant(){const t=this.elements,e=t[0],i=t[1],l=t[2],h=t[3],u=t[4],f=t[5],b=t[6],p=t[7],S=t[8];return e*u*S-e*f*p-i*h*S+i*f*b+l*h*p-l*u*b}invert(){const t=this.elements,e=t[0],i=t[1],l=t[2],h=t[3],u=t[4],f=t[5],b=t[6],p=t[7],S=t[8],x=S*u-f*p,E=f*b-S*h,T=p*h-u*b,O=e*x+i*E+l*T;if(O===0)return this.set(0,0,0,0,0,0,0,0,0);const R=1/O;return t[0]=x*R,t[1]=(l*p-S*i)*R,t[2]=(f*i-l*u)*R,t[3]=E*R,t[4]=(S*e-l*b)*R,t[5]=(l*h-f*e)*R,t[6]=T*R,t[7]=(i*b-p*e)*R,t[8]=(u*e-i*h)*R,this}transpose(){let t;const 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}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const 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}setUvTransform(t,e,i,l,h,u,f){const b=Math.cos(h),p=Math.sin(h);return this.set(i*b,i*p,-i*(b*u+p*f)+u+t,-l*p,l*b,-l*(-p*u+b*f)+f+e,0,0,1),this}scale(t,e){return this.premultiply(Ms.makeScale(t,e)),this}rotate(t){return this.premultiply(Ms.makeRotation(-t)),this}translate(t,e){return this.premultiply(Ms.makeTranslation(t,e)),this}makeTranslation(t,e){return t instanceof Xt?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}makeRotation(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,i,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,i=t.elements;for(let l=0;l<9;l++)if(e[l]!==i[l])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const 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}clone(){return new xh().fromArray(this.elements)}};Es.IDENTITY=Object.freeze(new Es);let Fi=Es;const Ms=new Fi,$n=1e-6,te=2*Math.PI,ru={x:0,y:0},ks={x:0,y:0,z:0};class Ts{constructor(){this.equalPointTol=$n,this.equalVectorTol=$n}equalPoint2d(t,e){return new Xt(t).sub(e).length()<this.equalPointTol}equalPoint3d(t,e){return new Z(t).sub(e).length()<this.equalPointTol}static equalToZero(t,e=$n){return t<e&&t>-e}static equal(t,e,i=$n){return Math.abs(t-e)<i}static great(t,e,i=$n){return t-e>i}static less(t,e,i=$n){return t-e<i}}const Cs=new Ts;function Ls(a,t,e=!1){const i=a.x,l=a.y;let h=!1;const u=t.length;for(let f=0,b=u-1;f<u;b=f++){const p=t[f].x,S=t[f].y,x=t[b].x,E=t[b].y;let T=S>l!=E>l;e&&(T=S>=l!=E>=l),T&&i<(x-p)*(l-S)/(E-S)+p&&(h=!h)}return h}function Vo(a,t){if(a.length===0||t.length===0)return!1;const e=new me().setFromPoints(a),i=new me().setFromPoints(t);if(!e.intersectsBox(i))return!1;for(let l=0;l<a.length;){if(Ls(a[l],t,!0))return!0;l<a.length-1&&Cs.equalPoint2d(a[l+1],a[l])&&++l,++l}return!1}const Uo={isPointInPolygon:Ls,isPolygonIntersect:Vo};function jo(a,t){const e=[],i=t-1,l=a;for(let h=0;h<=l;h++)e.push(0);for(let h=1;h<=i-l;h++)e.push(h);for(let h=0;h<=l;h++)e.push(i-l+1);return e}function Go(a,t){const e=t.length-1,i=a,l=[0];let h=0;for(let f=1;f<=e;f++){const b=t[f][0]-t[f-1][0],p=t[f][1]-t[f-1][1],S=t[f][2]-t[f-1][2],x=Math.sqrt(b*b+p*p+S*S);h+=x,l.push(h)}const u=[];for(let f=0;f<=i;f++)u.push(0);for(let f=1;f<=e-i;f++){const b=l[f]/h;u.push(b*(e-i+1))}for(let f=0;f<=i;f++)u.push(e-i+1);return u}function Ho(a,t){const e=t.length-1,i=a,l=[0];let h=0;for(let f=1;f<=e;f++){const b=t[f][0]-t[f-1][0],p=t[f][1]-t[f-1][1],S=t[f][2]-t[f-1][2],x=Math.sqrt(b*b+p*p+S*S),E=Math.sqrt(x);h+=E,l.push(h)}const u=[];for(let f=0;f<=i;f++)u.push(0);for(let f=1;f<=e-i;f++){const b=l[f]/h;u.push(b*(e-i+1))}for(let f=0;f<=i;f++)u.push(e-i+1);return u}function Vi(a,t,e,i){if(t===0)return e>=i[a]&&e<i[a+1]?1:0;const l=i[a+t]-i[a],h=i[a+t+1]-i[a+1],u=l>1e-10?(e-i[a])/l:0,f=h>1e-10?(i[a+t+1]-e)/h:0;return u*Vi(a,t-1,e,i)+f*Vi(a+1,t-1,e,i)}function Zr(a,t,e,i,l){const h=i.length-1,u=t;if(a=Math.max(e[u],Math.min(e[h+1],a)),Math.abs(a-e[h+1])<1e-8)return[...i[h]];if(Math.abs(a-e[u])<1e-8)return[...i[0]];const f=[0,0,0];let b=0;for(let p=0;p<=h;p++){const S=Vi(p,u,a,e),x=l[p]*S;f[0]+=i[p][0]*x,f[1]+=i[p][1]*x,f[2]+=i[p][2]*x,b+=x}if(b<1e-10){const p=e[e.length-u-1];if(Math.abs(a-p)<1e-8)return[...i[h]];if(Math.abs(a-e[u])<1e-8)return[...i[0]]}return b>1e-10&&(f[0]/=b,f[1]/=b,f[2]/=b),f}function Wo(a,t,e,i){const l=a,h=t[l],u=t[t.length-l-1];let f=0;const b=1e3,p=(u-h)/b;let S=Zr(h,a,t,e,i);for(let R=1;R<=b;R++){const G=h+R*p,F=Zr(G,a,t,e,i),pt=F[0]-S[0],_t=F[1]-S[1],ut=F[2]-S[2];f+=Math.sqrt(pt*pt+_t*_t+ut*ut),S=F}const x=Zr(u,a,t,e,i),E=x[0]-S[0],T=x[1]-S[1],O=x[2]-S[2];return f+=Math.sqrt(E*E+T*T+O*O),f}function iu(a){return a.map(t=>[...t])}class In{constructor(t=0,e=0,i=0,l=1){this._x=t,this._y=e,this._z=i,this._w=l}static slerpFlat(t,e,i,l,h,u,f){let b=i[l+0],p=i[l+1],S=i[l+2],x=i[l+3];const E=h[u+0],T=h[u+1],O=h[u+2],R=h[u+3];if(f===0){t[e+0]=b,t[e+1]=p,t[e+2]=S,t[e+3]=x;return}if(f===1){t[e+0]=E,t[e+1]=T,t[e+2]=O,t[e+3]=R;return}if(x!==R||b!==E||p!==T||S!==O){let G=1-f;const F=b*E+p*T+S*O+x*R,pt=F>=0?1:-1,_t=1-F*F;if(_t>Number.EPSILON){const W=Math.sqrt(_t),gt=Math.atan2(W,F*pt);G=Math.sin(G*gt)/W,f=Math.sin(f*gt)/W}const ut=f*pt;if(b=b*G+E*ut,p=p*G+T*ut,S=S*G+O*ut,x=x*G+R*ut,G===1-f){const W=1/Math.sqrt(b*b+p*p+S*S+x*x);b*=W,p*=W,S*=W,x*=W}}t[e]=b,t[e+1]=p,t[e+2]=S,t[e+3]=x}static multiplyQuaternionsFlat(t,e,i,l,h,u){const f=i[l],b=i[l+1],p=i[l+2],S=i[l+3],x=h[u],E=h[u+1],T=h[u+2],O=h[u+3];return t[e]=f*O+S*x+b*T-p*E,t[e+1]=b*O+S*E+p*x-f*T,t[e+2]=p*O+S*T+f*E-b*x,t[e+3]=S*O-f*x-b*E-p*T,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,i,l){return this._x=t,this._y=e,this._z=i,this._w=l,this._onChangeCallback(),this}clone(){return new In(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const i=t.x,l=t.y,h=t.z,u=t.order,f=Math.cos,b=Math.sin,p=f(i/2),S=f(l/2),x=f(h/2),E=b(i/2),T=b(l/2),O=b(h/2);switch(u){case"XYZ":this._x=E*S*x+p*T*O,this._y=p*T*x-E*S*O,this._z=p*S*O+E*T*x,this._w=p*S*x-E*T*O;break;case"YXZ":this._x=E*S*x+p*T*O,this._y=p*T*x-E*S*O,this._z=p*S*O-E*T*x,this._w=p*S*x+E*T*O;break;case"ZXY":this._x=E*S*x-p*T*O,this._y=p*T*x+E*S*O,this._z=p*S*O+E*T*x,this._w=p*S*x-E*T*O;break;case"ZYX":this._x=E*S*x-p*T*O,this._y=p*T*x+E*S*O,this._z=p*S*O-E*T*x,this._w=p*S*x+E*T*O;break;case"YZX":this._x=E*S*x+p*T*O,this._y=p*T*x+E*S*O,this._z=p*S*O-E*T*x,this._w=p*S*x-E*T*O;break;case"XZY":this._x=E*S*x-p*T*O,this._y=p*T*x-E*S*O,this._z=p*S*O+E*T*x,this._w=p*S*x+E*T*O;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+u)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,l=Math.sin(i);return this._x=t.x*l,this._y=t.y*l,this._z=t.z*l,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],l=e[4],h=e[8],u=e[1],f=e[5],b=e[9],p=e[2],S=e[6],x=e[10],E=i+f+x;if(E>0){const T=.5/Math.sqrt(E+1);this._w=.25/T,this._x=(S-b)*T,this._y=(h-p)*T,this._z=(u-l)*T}else if(i>f&&i>x){const T=2*Math.sqrt(1+i-f-x);this._w=(S-b)/T,this._x=.25*T,this._y=(l+u)/T,this._z=(h+p)/T}else if(f>x){const T=2*Math.sqrt(1+f-i-x);this._w=(h-p)/T,this._x=(l+u)/T,this._y=.25*T,this._z=(b+S)/T}else{const T=2*Math.sqrt(1+x-i-f);this._w=(u-l)/T,this._x=(h+p)/T,this._y=(b+S)/T,this._z=.25*T}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let 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()}angleTo(t){return 2*Math.acos(Math.abs(_n(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(i===0)return this;const l=Math.min(1,e/i);return this.slerp(t,l),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let 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}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const i=t._x,l=t._y,h=t._z,u=t._w,f=e._x,b=e._y,p=e._z,S=e._w;return this._x=i*S+u*f+l*p-h*b,this._y=l*S+u*b+h*f-i*p,this._z=h*S+u*p+i*b-l*f,this._w=u*S-i*f-l*b-h*p,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const i=this._x,l=this._y,h=this._z,u=this._w;let f=u*t._w+i*t._x+l*t._y+h*t._z;if(f<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,f=-f):this.copy(t),f>=1)return this._w=u,this._x=i,this._y=l,this._z=h,this;const b=1-f*f;if(b<=Number.EPSILON){const T=1-e;return this._w=T*u+e*this._w,this._x=T*i+e*this._x,this._y=T*l+e*this._y,this._z=T*h+e*this._z,this.normalize(),this}const p=Math.sqrt(b),S=Math.atan2(p,f),x=Math.sin((1-e)*S)/p,E=Math.sin(e*S)/p;return this._w=u*x+this._w*E,this._x=i*x+this._x*E,this._y=l*x+this._y*E,this._z=h*x+this._z*E,this._onChangeCallback(),this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),i=Math.random(),l=Math.sqrt(1-i),h=Math.sqrt(i);return this.set(l*Math.sin(t),l*Math.cos(t),h*Math.sin(e),h*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const Ce=class wh{constructor(t,e,i){this.x=0,this.y=0,this.z=0;const l=+(t!==void 0)+ +(e!==void 0)+ +(i!==void 0);if(l!==0){if(l===1&&t instanceof Array){this.x=t[0],this.y=t[1],this.z=t[2];return}if(l===1){const{x:h,y:u,z:f}=t;this.x=h,this.y=u,this.z=f||0;return}if(l===3){this.x=t,this.y=e,this.z=i;return}throw Ie.ILLEGAL_PARAMETERS}}set(t,e,i){return i===void 0&&(i=this.z),this.x=t,this.y=e,this.z=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(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}getComponent(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)}}clone(){return new wh(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z||0,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z||0,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(qo.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(qo.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,l=this.z,h=t.elements;return this.x=h[0]*e+h[3]*i+h[6]*l,this.y=h[1]*e+h[4]*i+h[7]*l,this.z=h[2]*e+h[5]*i+h[8]*l,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix3d(t){const e=this.x,i=this.y,l=this.z,h=t.elements,u=1/(h[3]*e+h[7]*i+h[11]*l+h[15]);return this.x=(h[0]*e+h[4]*i+h[8]*l+h[12])*u,this.y=(h[1]*e+h[5]*i+h[9]*l+h[13])*u,this.z=(h[2]*e+h[6]*i+h[10]*l+h[14])*u,this}applyQuaternion(t){const e=this.x,i=this.y,l=this.z,h=t.x,u=t.y,f=t.z,b=t.w,p=2*(u*l-f*i),S=2*(f*e-h*l),x=2*(h*i-u*e);return this.x=e+b*p+u*x-f*S,this.y=i+b*S+f*p-h*x,this.z=l+b*x+h*S-u*p,this}transformDirection(t){const e=this.x,i=this.y,l=this.z,h=t.elements;return this.x=h[0]*e+h[4]*i+h[8]*l,this.y=h[1]*e+h[5]*i+h[9]*l,this.z=h[2]*e+h[6]*i+h[10]*l,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(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}max(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}clamp(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}clampScalar(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}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}isParallelTo(t){const e=this.dot(t),i=this.length(),l=t.length();return Math.abs(e)===i*l}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(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}lerpVectors(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}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const i=t.x,l=t.y,h=t.z,u=e.x,f=e.y,b=e.z;return this.x=l*b-h*f,this.y=h*u-i*b,this.z=i*f-l*u,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return Ns.copy(this).projectOnVector(t),this.sub(Ns)}reflect(t){return this.sub(Ns.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,i)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,l=this.z-t.z;return e*e+i*i+l*l}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),l=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=l,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const 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}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};Ce.X_AXIS=Object.freeze(new Ce(1,0,0)),Ce.NEGATIVE_X_AXIS=Object.freeze(new Ce(-1,0,0)),Ce.Y_AXIS=Object.freeze(new Ce(0,1,0)),Ce.NEGATIVE_Y_AXIS=Object.freeze(new Ce(0,-1,0)),Ce.Z_AXIS=Object.freeze(new Ce(0,0,1)),Ce.NEGATIVE_Z_AXIS=Object.freeze(new Ce(0,0,-1));let Z=Ce;const Ns=new Z,qo=new In,zs=class Ah{constructor(t,e,i,l,h,u,f,b,p,S,x,E,T,O,R,G){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!=null&&e!=null&&i!=null&&l!=null&&h!=null&&u!=null&&f!=null&&b!=null&&p!=null&&S!=null&&x!=null&&E!=null&&T!=null&&O!=null&&R!=null&&G!=null&&this.set(t,e,i,l,h,u,f,b,p,S,x,E,T,O,R,G)}set(t,e,i,l,h,u,f,b,p,S,x,E,T,O,R,G){const F=this.elements;return F[0]=t,F[4]=e,F[8]=i,F[12]=l,F[1]=h,F[5]=u,F[9]=f,F[13]=b,F[2]=p,F[6]=S,F[10]=x,F[14]=E,F[3]=T,F[7]=O,F[11]=R,F[15]=G,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Ah().fromArray(this.elements)}copy(t){const 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}copyPosition(t){const e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this}setFromMatrix3(t){const 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}setFromExtrusionDirection(t){if(Cs.equalPoint3d(t,Z.Z_AXIS))this.identity();else{const e=new Z(1,0,0);Math.abs(t.x)<1/64&&Math.abs(t.y)<1/64?e.crossVectors(Z.Y_AXIS,t).normalize():e.crossVectors(Z.Z_AXIS,t).normalize();const i=t.clone().cross(e).normalize();this.set(e.x,e.y,e.z,0,i.x,i.y,i.z,0,t.x,t.y,t.z,0,0,0,0,1)}return this}extractBasis(t,e,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(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}extractRotation(t){const e=this.elements,i=t.elements,l=1/gr.setFromMatrixColumn(t,0).length(),h=1/gr.setFromMatrixColumn(t,1).length(),u=1/gr.setFromMatrixColumn(t,2).length();return e[0]=i[0]*l,e[1]=i[1]*l,e[2]=i[2]*l,e[3]=0,e[4]=i[4]*h,e[5]=i[5]*h,e[6]=i[6]*h,e[7]=0,e[8]=i[8]*u,e[9]=i[9]*u,e[10]=i[10]*u,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(su,t,au)}lookAt(t,e,i){const l=this.elements;return Le.subVectors(t,e),Le.lengthSq()===0&&(Le.z=1),Le.normalize(),En.crossVectors(i,Le),En.lengthSq()===0&&(Math.abs(i.z)===1?Le.x+=1e-4:Le.z+=1e-4,Le.normalize(),En.crossVectors(i,Le)),En.normalize(),Ui.crossVectors(Le,En),l[0]=En.x,l[4]=Ui.x,l[8]=Le.x,l[1]=En.y,l[5]=Ui.y,l[9]=Le.y,l[2]=En.z,l[6]=Ui.z,l[10]=Le.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,l=e.elements,h=this.elements,u=i[0],f=i[4],b=i[8],p=i[12],S=i[1],x=i[5],E=i[9],T=i[13],O=i[2],R=i[6],G=i[10],F=i[14],pt=i[3],_t=i[7],ut=i[11],W=i[15],gt=l[0],ht=l[4],Wt=l[8],qt=l[12],Gt=l[1],xt=l[5],Nt=l[9],ge=l[13],fe=l[2],ze=l[6],ee=l[10],he=l[14],J=l[3],kt=l[7],ce=l[11],yn=l[15];return h[0]=u*gt+f*Gt+b*fe+p*J,h[4]=u*ht+f*xt+b*ze+p*kt,h[8]=u*Wt+f*Nt+b*ee+p*ce,h[12]=u*qt+f*ge+b*he+p*yn,h[1]=S*gt+x*Gt+E*fe+T*J,h[5]=S*ht+x*xt+E*ze+T*kt,h[9]=S*Wt+x*Nt+E*ee+T*ce,h[13]=S*qt+x*ge+E*he+T*yn,h[2]=O*gt+R*Gt+G*fe+F*J,h[6]=O*ht+R*xt+G*ze+F*kt,h[10]=O*Wt+R*Nt+G*ee+F*ce,h[14]=O*qt+R*ge+G*he+F*yn,h[3]=pt*gt+_t*Gt+ut*fe+W*J,h[7]=pt*ht+_t*xt+ut*ze+W*kt,h[11]=pt*Wt+_t*Nt+ut*ee+W*ce,h[15]=pt*qt+_t*ge+ut*he+W*yn,this}multiplyScalar(t){const 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}determinant(){const t=this.elements,e=t[0],i=t[4],l=t[8],h=t[12],u=t[1],f=t[5],b=t[9],p=t[13],S=t[2],x=t[6],E=t[10],T=t[14],O=t[3],R=t[7],G=t[11],F=t[15];return O*(+h*b*x-l*p*x-h*f*E+i*p*E+l*f*T-i*b*T)+R*(+e*b*T-e*p*E+h*u*E-l*u*T+l*p*S-h*b*S)+G*(+e*p*x-e*f*T-h*u*x+i*u*T+h*f*S-i*p*S)+F*(-l*f*S-e*b*x+e*f*E+l*u*x-i*u*E+i*b*S)}transpose(){const t=this.elements;let 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}setPosition(t,e,i){const l=this.elements;return t instanceof Z?(l[12]=t.x,l[13]=t.y,l[14]=t.z):(l[12]=t,l[13]=e,l[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],l=t[2],h=t[3],u=t[4],f=t[5],b=t[6],p=t[7],S=t[8],x=t[9],E=t[10],T=t[11],O=t[12],R=t[13],G=t[14],F=t[15],pt=x*G*p-R*E*p+R*b*T-f*G*T-x*b*F+f*E*F,_t=O*E*p-S*G*p-O*b*T+u*G*T+S*b*F-u*E*F,ut=S*R*p-O*x*p+O*f*T-u*R*T-S*f*F+u*x*F,W=O*x*b-S*R*b-O*f*E+u*R*E+S*f*G-u*x*G,gt=e*pt+i*_t+l*ut+h*W;if(gt===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const ht=1/gt;return t[0]=pt*ht,t[1]=(R*E*h-x*G*h-R*l*T+i*G*T+x*l*F-i*E*F)*ht,t[2]=(f*G*h-R*b*h+R*l*p-i*G*p-f*l*F+i*b*F)*ht,t[3]=(x*b*h-f*E*h-x*l*p+i*E*p+f*l*T-i*b*T)*ht,t[4]=_t*ht,t[5]=(S*G*h-O*E*h+O*l*T-e*G*T-S*l*F+e*E*F)*ht,t[6]=(O*b*h-u*G*h-O*l*p+e*G*p+u*l*F-e*b*F)*ht,t[7]=(u*E*h-S*b*h+S*l*p-e*E*p-u*l*T+e*b*T)*ht,t[8]=ut*ht,t[9]=(O*x*h-S*R*h-O*i*T+e*R*T+S*i*F-e*x*F)*ht,t[10]=(u*R*h-O*f*h+O*i*p-e*R*p-u*i*F+e*f*F)*ht,t[11]=(S*f*h-u*x*h-S*i*p+e*x*p+u*i*T-e*f*T)*ht,t[12]=W*ht,t[13]=(S*R*l-O*x*l+O*i*E-e*R*E-S*i*G+e*x*G)*ht,t[14]=(O*f*l-u*R*l-O*i*b+e*R*b+u*i*G-e*f*G)*ht,t[15]=(u*x*l-S*f*l+S*i*b-e*x*b-u*i*E+e*f*E)*ht,this}scale(t){const e=this.elements,i=t.x,l=t.y,h=t.z;return e[0]*=i,e[4]*=l,e[8]*=h,e[1]*=i,e[5]*=l,e[9]*=h,e[2]*=i,e[6]*=l,e[10]*=h,e[3]*=i,e[7]*=l,e[11]*=h,this}getMaxScaleOnAxis(){const 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],l=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,l))}makeTranslation(t,e,i){return t instanceof Z?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this}makeRotationX(t){const 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}makeRotationY(t){const 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}makeRotationZ(t){const 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}makeRotationAxis(t,e){const i=Math.cos(e),l=Math.sin(e),h=1-i,u=t.x,f=t.y,b=t.z,p=h*u,S=h*f;return this.set(p*u+i,p*f-l*b,p*b+l*f,0,p*f+l*b,S*f+i,S*b-l*u,0,p*b-l*f,S*b+l*u,h*b*b+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i,l,h,u){return this.set(1,i,h,0,t,1,u,0,e,l,1,0,0,0,0,1),this}compose(t,e,i){const l=this.elements,h=e.x,u=e.y,f=e.z,b=e.w,p=h+h,S=u+u,x=f+f,E=h*p,T=h*S,O=h*x,R=u*S,G=u*x,F=f*x,pt=b*p,_t=b*S,ut=b*x,W=i.x,gt=i.y,ht=i.z;return l[0]=(1-(R+F))*W,l[1]=(T+ut)*W,l[2]=(O-_t)*W,l[3]=0,l[4]=(T-ut)*gt,l[5]=(1-(E+F))*gt,l[6]=(G+pt)*gt,l[7]=0,l[8]=(O+_t)*ht,l[9]=(G-pt)*ht,l[10]=(1-(E+R))*ht,l[11]=0,l[12]=t.x,l[13]=t.y,l[14]=t.z,l[15]=1,this}decompose(t,e,i){const l=this.elements;let h=gr.set(l[0],l[1],l[2]).length();const u=gr.set(l[4],l[5],l[6]).length(),f=gr.set(l[8],l[9],l[10]).length();this.determinant()<0&&(h=-h),t.x=l[12],t.y=l[13],t.z=l[14],We.copy(this);const b=1/h,p=1/u,S=1/f;return We.elements[0]*=b,We.elements[1]*=b,We.elements[2]*=b,We.elements[4]*=p,We.elements[5]*=p,We.elements[6]*=p,We.elements[8]*=S,We.elements[9]*=S,We.elements[10]*=S,e.setFromRotationMatrix(We),i.x=h,i.y=u,i.z=f,this}equals(t){const e=this.elements,i=t.elements;for(let l=0;l<16;l++)if(e[l]!==i[l])return!1;return!0}fromArray(t,e=0){for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const 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}};zs.IDENTITY=Object.freeze(new zs);let Zn=zs;const gr=new Z,We=new Zn,su=new Z(0,0,0),au=new Z(1,1,1),En=new Z,Ui=new Z,Le=new Z;class Rt{constructor(t=void 0,e=void 0){this.min=t==null?new Z(1/0,1/0,1/0):new Z(t.x,t.y,t.z),this.max=e==null?new Z(-1/0,-1/0,-1/0):new Z(e.x,e.y,e.z)}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e+=3)this.expandByPoint(Ds.fromArray(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=Ds.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}clone(){return new Rt().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new Z(0,0,0):new Z(0,0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new Z(0,0,0):new Z(0,0,0).subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(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)}containsBox(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}getParameter(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))}intersectsBox(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)}intersectsPlane(t){let 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}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Ds).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(vn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix3d(t),vn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix3d(t),vn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix3d(t),vn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix3d(t),vn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix3d(t),vn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix3d(t),vn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix3d(t),vn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix3d(t),this.setFromPoints(vn),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const vn=[new Z,new Z,new Z,new Z,new Z,new Z,new Z,new Z],Ds=new Z,Yo=new Xt;class me{constructor(t=void 0,e=void 0){this.min=t==null?new Xt(1/0,1/0):new Xt(t.x,t.y),this.max=e==null?new Xt(-1/0,-1/0):new Xt(e.x,e.y)}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=Yo.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}clone(){return new me().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new Xt(0,0):new Xt(0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new Xt(0,0):new Xt(0,0).subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(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}getParameter(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))}intersectsBox(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)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Yo).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const Ko=new Z,ou=new Z,lu=new Fi;class Qr{constructor(t=new Z(1,0,0),e=0){this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,i,l){return this.normal.set(t,e,i),this.constant=l,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,i){const l=Ko.subVectors(i,e).cross(ou.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(l,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectsBox(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const i=e||lu.getNormalMatrix(t),l=this.coplanarPoint(Ko).applyMatrix3d(t),h=this.normal.applyMatrix3(i).normalize();return this.constant=-l.dot(h),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new Qr().copy(this)}}class Mt extends Xt{static pointArrayToNumberArray(t){const e=new Array(t.length*2);return t.forEach((i,l)=>{i.toArray(e,l*2)}),e}}class X extends Z{static pointArrayToNumberArray(t,e=!0){const i=e?3:2,l=new Array(t.length*i);return t.forEach((h,u)=>{h.toArray(l,u*i)}),l}}const Xo=new Zn,$o=new In,Zo=class ia{constructor(t=0,e=0,i=0,l=ia.DEFAULT_ORDER){this._x=t,this._y=e,this._z=i,this._order=l}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,i,l=this._order){return this._x=t,this._y=e,this._z=i,this._order=l,this._onChangeCallback(),this}clone(){return new ia(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,i=!0){const l=t.elements,h=l[0],u=l[4],f=l[8],b=l[1],p=l[5],S=l[9],x=l[2],E=l[6],T=l[10];switch(e){case"XYZ":this._y=Math.asin(_n(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(-S,T),this._z=Math.atan2(-u,h)):(this._x=Math.atan2(E,p),this._z=0);break;case"YXZ":this._x=Math.asin(-_n(S,-1,1)),Math.abs(S)<.9999999?(this._y=Math.atan2(f,T),this._z=Math.atan2(b,p)):(this._y=Math.atan2(-x,h),this._z=0);break;case"ZXY":this._x=Math.asin(_n(E,-1,1)),Math.abs(E)<.9999999?(this._y=Math.atan2(-x,T),this._z=Math.atan2(-u,p)):(this._y=0,this._z=Math.atan2(b,h));break;case"ZYX":this._y=Math.asin(-_n(x,-1,1)),Math.abs(x)<.9999999?(this._x=Math.atan2(E,T),this._z=Math.atan2(b,h)):(this._x=0,this._z=Math.atan2(-u,p));break;case"YZX":this._z=Math.asin(_n(b,-1,1)),Math.abs(b)<.9999999?(this._x=Math.atan2(-S,p),this._y=Math.atan2(-x,h)):(this._x=0,this._y=Math.atan2(f,T));break;case"XZY":this._z=Math.asin(-_n(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(E,p),this._y=Math.atan2(f,h)):(this._x=Math.atan2(-S,T),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,i===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,i=!0){return Xo.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Xo,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return $o.setFromEuler(this),this.setFromQuaternion($o,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Zo.DEFAULT_ORDER="XYZ";let Qo=Zo;class Jo{constructor(){this._boundingBoxNeedsUpdate=!1}get boundingBoxNeedUpdate(){return this._boundingBoxNeedsUpdate}}class Os extends Jo{translate(t){return this.transform(new Fi().makeTranslation(t.x,t.y))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}class ji extends Os{constructor(){super(),this._loops=[]}add(t){this._loops.push(t),this._boundingBoxNeedsUpdate=!0}get loops(){return this._loops}get outter(){if(this._loops.length>0)return this._loops[0]}calculateBoundingBox(){const t=this.outter;return t?t.box:new me}transform(t){return this._boundingBoxNeedsUpdate=!0,this}getPoints(t){const e=[];for(let i=0;i<this.loops.length;++i){const l=this.loops[i].getPoints(t);e.push(l)}return e}buildHierarchy(){var t;const e=this.getPoints(100),i=this.calculateBoundaryBoxes(e),l=this.sortBoundaryBoxesByAreas(i),h=new Map,u=l.length;for(let b=0;b<u;b++)h.set(l[b],{index:l[b],children:[]});const f={index:-1,children:[]};for(let b=0;b<u;b++){const p=l[b],S=e[p],x=i[p];let E=b+1;for(;E<u;E++){const T=l[E],O=e[T];if(i[T].containsBox(x)&&Uo.isPointInPolygon(S[zt.randInt(0,S.length-1)],O)){(t=h.get(T))==null||t.children.push(h.get(p));break}}E===u&&f.children.push(h.get(p))}return f}calculateBoundaryBoxes(t){const e=[];return t.forEach(i=>{e.push(new me().setFromPoints(i))}),e}sortBoundaryBoxesByAreas(t){const e=[];t.forEach((l,h)=>{const u=l.size,f=u.width*u.height;e.push({area:f,index:h})}),e.sort((l,h)=>l.area-h.area);const i=[];return e.forEach(l=>{i.push(l.index)}),i}}class fr extends Os{constructor(){super(),this.arcLengthDivisions=100}get startPoint(){return this.getPoint(0)}get endPoint(){return this.getPoint(1)}get length(){return this.getLength()}getPoint(t){throw new Error("AcGeCurve2d: .getPoint() not implemented.")}getPointAt(t){const e=this.getUtoTmapping(t);return this.getPoint(e)}getPoints(t=5){const e=[];for(let i=0;i<=t;i++)e.push(this.getPoint(i/t));return e}getSpacedPoints(t=5){const e=[];for(let i=0;i<=t;i++)e.push(this.getPointAt(i/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){const e=[];let i,l=this.getPoint(0),h=0;e.push(0);for(let u=1;u<=t;u++)i=this.getPoint(u/t),h+=i.distanceTo(l),e.push(h),l=i;return e}getUtoTmapping(t,e){const i=this.getLengths();let l=0;const h=i.length;let u;e?u=e:u=t*i[h-1];let f=0,b=h-1,p;for(;f<=b;)if(l=Math.floor(f+(b-f)/2),p=i[l]-u,p<0)f=l+1;else if(p>0)b=l-1;else{b=l;break}if(l=b,i[l]===u)return l/(h-1);const S=i[l],x=i[l+1]-S,E=(u-S)/x;return(l+E)/(h-1)}getTangent(t){let e=t-1e-4,i=t+1e-4;e<0&&(e=0),i>1&&(i=1);const l=this.getPoint(e),h=this.getPoint(i),u=new Mt;return u.copy(h).sub(l).normalize(),u}getTangentAt(t){const e=this.getUtoTmapping(t);return this.getTangent(e)}}class pr extends fr{constructor(t,e,i,l,h){super();const u=+(t!==void 0)+ +(e!==void 0)+ +(i!==void 0)+ +(l!==void 0)+ +(h!==void 0);if(u==3)typeof t=="object"&&typeof e=="object"&&typeof i=="object"?this.createByThreePoints(t,e,i):this.createByStartEndPointsAndBulge(t,e,i);else if(u==5){const f=t;this.center=new Mt(f.x,f.y),this.radius=e,this.startAngle=i,this.endAngle=l,this.clockwise=h}else throw Ie.ILLEGAL_PARAMETERS}createByThreePoints(t,e,i){const l=(ht,Wt)=>({x:(ht.x+Wt.x)/2,y:(ht.y+Wt.y)/2}),h=(ht,Wt)=>(Wt.y-ht.y)/(Wt.x-ht.x),u=ht=>-1/ht,f=l(t,e),b=l(e,i),p=h(t,e),S=h(e,i),x=u(p),E=u(S),T=(ht,Wt,qt,Gt)=>{const xt=(Gt-Wt)/(ht-qt),Nt=ht*xt+Wt;return{x:xt,y:Nt}},O=f.y-x*f.x,R=b.y-E*b.x,G=T(x,O,E,R),F=Math.sqrt(Math.pow(t.x-G.x,2)+Math.pow(t.y-G.y,2)),pt=(ht,Wt)=>Math.atan2(ht.y-Wt.y,ht.x-Wt.x),_t=pt(t,G),ut=pt(e,G),W=pt(i,G),gt=W>_t&&W<ut||_t>W&&_t<ut||ut>W&&ut<_t;this.center=G,this.radius=F,this.startAngle=_t,this.endAngle=W,this.clockwise=!gt}createByStartEndPointsAndBulge(t,e,i){let l,h,u;i<0?(l=Math.atan(-i)*4,h=new Xt(t),u=new Xt(e)):(l=Math.atan(i)*4,h=new Xt(e),u=new Xt(t));const f=new Xt().subVectors(u,h),b=f.length(),p=new Xt().addVectors(h,f.multiplyScalar(.5)),S=Math.abs(b/2/Math.tan(l/2)),x=f.normalize();let E;if(l<Math.PI){const T=new Xt(x.x*Math.cos(Math.PI/2)-x.y*Math.sin(Math.PI/2),x.y*Math.cos(Math.PI/2)+x.x*Math.sin(Math.PI/2));E=p.add(T.multiplyScalar(-S))}else{const T=new Xt(x.x*Math.cos(Math.PI/2)-x.y*Math.sin(Math.PI/2),x.y*Math.cos(Math.PI/2)+x.x*Math.sin(Math.PI/2));E=p.add(T.multiplyScalar(S))}i<0?(this.startAngle=Math.atan2(h.y-E.y,h.x-E.x),this.endAngle=Math.atan2(u.y-E.y,u.x-E.x)):(this.startAngle=Math.atan2(u.y-E.y,u.x-E.x),this.endAngle=Math.atan2(h.y-E.y,h.x-E.x)),this.clockwise=i<0,this.center=E,this.radius=u.sub(E).length()}get center(){return this._center}set center(t){this._center=new Mt(t.x,t.y),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=zt.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==te?t:zt.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return this.clockwise?zt.normalizeAngle(this.startAngle-this.endAngle):zt.normalizeAngle(this.endAngle-this.startAngle)}get clockwise(){return this._clockwise}set clockwise(t){this._clockwise=t,this._boundingBoxNeedsUpdate=!0}get startPoint(){return this.getPointAtAngle(this.startAngle)}get endPoint(){return this.getPointAtAngle(this.endAngle)}get midPoint(){const t=zt.normalizeAngle((this.startAngle+this.endAngle)/2);return this.getPointAtAngle(t)}get closed(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0}calculateBoundingBox(){const t=[this.startPoint,this.endPoint],e=[0,Math.PI/2,Math.PI,3*Math.PI/2];for(const h of e)zt.isBetweenAngle(h,this.startAngle,this.endAngle,this.clockwise)&&t.push(this.getPointAtAngle(h));const i=t.map(h=>h.x),l=t.map(h=>h.y);return new me(new Mt(Math.min(...i),Math.min(...l)),new Mt(Math.max(...i),Math.max(...l)))}get length(){return Math.abs(this.deltaAngle*this.radius)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}clone(){return new pr(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.clockwise)}getPointAtAngle(t){const e=this.center.x+this.radius*Math.cos(t),i=this.center.y+this.radius*Math.sin(t);return new Mt(e,i)}getPoints(t=100){const e=[];let i=this.deltaAngle,l=this.startAngle;if(this.closed&&(i=te,l=0),this.clockwise)for(let h=0;h<=t;h++){const u=l-i*(h/t),f=this.getPointAtAngle(u);e.push(new Mt(f.x,f.y))}else for(let h=0;h<=t;h++){const u=l+i*(h/t),f=this.getPointAtAngle(u);e.push(new Mt(f.x,f.y))}return e}}class hu extends Jo{translate(t){return this.transform(new Zn().makeTranslation(t.x,t.y,t.z))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}class Jr extends hu{}class Mn extends Jr{constructor(t,e){super(),this._start=new X(t),this._end=new X(e)}get startPoint(){return this._start}set startPoint(t){this._start.copy(t),this._boundingBoxNeedsUpdate=!0}get endPoint(){return this._end}set endPoint(t){this._end.copy(t),this._boundingBoxNeedsUpdate=!0}get direction(){return new Z().subVectors(this.endPoint,this.startPoint).normalize()}get midPoint(){return new X((this._start.x+this._end.x)/2,(this._start.y+this._end.y)/2,(this._start.z+this._end.z)/2)}get length(){return this.startPoint.distanceTo(this.endPoint)}isPointOnLine(t){return this.project(t).distanceTo(t)<1e-6}at(t,e){return this.delta(e).multiplyScalar(t).add(this._start)}atLength(t,e=!1){if(e){const i=this.delta(Qn).normalize();return new X(this._start).addScaledVector(i,t)}else{const i=this.delta(Qn).normalize();return new X(this._end).addScaledVector(i,t)}}extend(t,e=!1){if(e){const i=Qn.subVectors(this._start,this._end).normalize();this._start=new X(this._start).addScaledVector(i,t)}else{const i=this.delta(Qn).normalize();this._end=new X(this._end).addScaledVector(i,t)}return this._boundingBoxNeedsUpdate=!0,this}closestPointToPointParameter(t,e){tl.subVectors(t,this._start),Gi.subVectors(this.endPoint,this.startPoint);const i=Gi.dot(Gi);let l=Gi.dot(tl)/i;return e&&(l=zt.clamp(l,0,1)),l}closestPointToPoint(t,e,i){const l=this.closestPointToPointParameter(t,e);return this.delta(i).multiplyScalar(l).add(this._start)}delta(t){return t.subVectors(this._end,this._start)}distanceSq(){return this._start.distanceToSquared(this._end)}distance(){return this._start.distanceTo(this._end)}project(t){const e=this.direction,i=Qn.subVectors(t,this.startPoint).dot(e);return new X().copy(e).multiplyScalar(i).add(this.startPoint)}perpPoint(t){const e=this.direction,i=this.startPoint,l=Qn.subVectors(t,i).dot(e),h=Qn.copy(e).multiplyScalar(l);return new X().addVectors(i,h)}calculateBoundingBox(){const t=new X(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y),Math.min(this._start.z,this._end.z)),e=new X(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y),Math.max(this._start.z,this._end.z));return new Rt(t,e)}transform(t){return this._start.applyMatrix3d(t),this._end.applyMatrix3d(t),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new Mn(this._start.clone(),this._end.clone())}}const Qn=new Z,tl=new Z,Gi=new Z;class Jn extends Jr{static computeCenterPoint(t,e,i){const l=new Z().addVectors(t,e).multiplyScalar(.5),h=new Z().addVectors(t,i).multiplyScalar(.5),u=new Z().subVectors(e,t),f=new Z().subVectors(i,t),b=new Z().crossVectors(u,f).normalize();if(b.lengthSq()===0)return console.error("Points are collinear and cannot form a valid arc."),null;const p=new Z().crossVectors(u,b).normalize(),S=new Z().crossVectors(f,b).normalize(),x=p.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),E=S.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),T=new Mn(l,l.clone().add(x)),O=new Mn(h,h.clone().add(E)),R=new Z;return T.closestPointToPoint(O.startPoint,!0,R)?R:(console.error("Cannot find a valid center for the arc."),null)}static createByThreePoints(t,e,i){const l=Jn.computeCenterPoint(t,e,i);if(l){const h=l.distanceTo(t),u=new Z().subVectors(t,l),f=new Z().subVectors(e,l),b=Math.atan2(u.y,u.x),p=Math.atan2(f.y,f.x);return new Jn(l,h,b,p,Z.Z_AXIS)}}constructor(t,e,i,l,h,u=Z.X_AXIS){super(),this.center=t,this.radius=e,this.startAngle=i,this.endAngle=l,this.normal=h,this.refVec=u,(l-i)%te==0?(this.startAngle=0,this.endAngle=te):(this.startAngle=i,this.endAngle=l)}get center(){return this._center}set center(t){this._center=new X(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){if(t<0)throw Ie.ILLEGAL_PARAMETERS;this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=zt.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==te?t:zt.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return zt.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}get clockwise(){return this.deltaAngle<=0}get normal(){return this._normal}set normal(t){this._normal=new Z(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get refVec(){return this._refVec}set refVec(t){this._refVec=new Z(t.x,t.y,t.z),this._refVec.normalize(),this._boundingBoxNeedsUpdate=!0}get startPoint(){return this.getPointAtAngle(this._startAngle)}get endPoint(){return this.getPointAtAngle(this._endAngle)}get length(){return Math.abs(this.deltaAngle*this.radius)}calculateBoundingBox(){const t=[this.startAngle,this.endAngle];for(let b=0;b<2*Math.PI;b+=Math.PI/2)zt.isBetweenAngle(b,this.startAngle,this.endAngle)&&t.push(b);let e=1/0,i=1/0,l=1/0,h=-1/0,u=-1/0,f=-1/0;for(const b of t){const p=this.getPointAtAngle(b);p.x<e&&(e=p.x),p.y<i&&(i=p.y),p.z<l&&(l=p.z),p.x>h&&(h=p.x),p.y>u&&(u=p.y),p.z>f&&(f=p.z)}return new Rt({x:e,y:i,z:l},{x:h,y:u,z:f})}get closed(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0}getPoints(t){const e=[];let i=this.deltaAngle,l=this.startAngle;this.closed&&(i=te,l=0);for(let h=0;h<=t;h++){const u=l+i*(h/t),f=this.getPointAtAngle(u);e.push(f)}return e}transform(t){const e=Rs.copy(this.refVec).applyAxisAngle(this.normal,this.startAngle).multiplyScalar(this.radius),i=Rs.copy(this.refVec).applyAxisAngle(this.normal,this.endAngle).multiplyScalar(this.radius);return this.center.applyMatrix3d(t),e.applyMatrix3d(t),i.applyMatrix3d(t),this.normal.applyMatrix3d(t).normalize(),this.refVec.applyMatrix3d(t).normalize(),this.startAngle=this.getAngle(e),this.endAngle=this.getAngle(i),this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.radius=t.radius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.normal=t.normal,this.refVec=t.refVec,this._boundingBoxNeedsUpdate=!0,this}clone(){return new Jn(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)}getAngle(t){return t.sub(this.center),Math.atan2(t.dot(Rs.crossVectors(this.refVec,this.normal)),t.dot(this.refVec))}getPointAtAngle(t){const e=this.normal,i=this.refVec,l={x:e.y*i.z-e.z*i.y,y:e.z*i.x-e.x*i.z,z:e.x*i.y-e.y*i.x},h=this.center,u=this.radius;return new X(h.x+u*(i.x*Math.cos(t)+l.x*Math.sin(t)),h.y+u*(i.y*Math.cos(t)+l.y*Math.sin(t)),h.z+u*(i.z*Math.cos(t)+l.z*Math.sin(t)))}get plane(){const t=new Z(this.center).distanceTo(ks);return new Qr(this.normal,t)}}const Rs=new Z;class Hi extends fr{constructor(t,e,i,l=0,h=te,u=!1,f=0){super(),this.center=t,this.majorAxisRadius=e,this.minorAxisRadius=i,(h-l)%te==0?(this.startAngle=0,this.endAngle=te):(this.startAngle=l,this.endAngle=h),this.clockwise=u,this.rotation=f}get center(){return this._center}set center(t){this._center=new X(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw Ie.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw Ie.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=zt.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==te?t:zt.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get clockwise(){return this._clockwise}set clockwise(t){this._clockwise=t,this._boundingBoxNeedsUpdate=!0}get rotation(){return this._rotation}set rotation(t){this._rotation=t,this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return zt.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}calculateBoundingBox(){let t=1/0,e=1/0,i=-1/0,l=-1/0;for(let h=0;h<=100;h++){const u=this.getPoint(h/100);t=Math.min(t,u.x),e=Math.min(e,u.y),i=Math.max(i,u.x),l=Math.max(l,u.y)}return new me({x:t,y:e},{x:i,y:l})}get closed(){return this.deltaAngle==0}getPoint(t){const e=Math.PI*2;let i=this.endAngle-this.startAngle;const l=Math.abs(i)<Number.EPSILON;for(;i<0;)i+=e;for(;i>e;)i-=e;i<Number.EPSILON&&(l?i=0:i=e),this.clockwise===!0&&!l&&(i===e?i=-e:i=i-e);const h=this.startAngle+t*i;let u=this.center.x+this.majorAxisRadius*Math.cos(h),f=this.center.y+this.minorAxisRadius*Math.sin(h);if(this.rotation!==0){const b=Math.cos(this.rotation),p=Math.sin(this.rotation),S=u-this.center.x,x=f-this.center.y;u=S*b-x*p+this.center.x,f=S*p+x*b+this.center.y}return new Mt(u,f)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.majorAxisRadius=t.majorAxisRadius,this.minorAxisRadius=t.minorAxisRadius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.clockwise=t.clockwise,this.rotation=t.rotation,this}clone(){return new Hi(this.center,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle,this.clockwise,this.rotation)}}class Wi extends Jr{constructor(t,e,i,l,h,u=0,f=te){super(),this.center=t,this.normal=e,this.majorAxis=i,this.majorAxisRadius=l,this.minorAxisRadius=h;const b=Math.abs(f-u);Math.abs(b-te)<1e-10||Math.abs(b-2*te)<1e-10?(this.startAngle=0,this.endAngle=te):(this.startAngle=u,this.endAngle=f)}get center(){return this._center}set center(t){this._center=new X(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw Ie.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw Ie.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=zt.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==te?t:zt.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){const t=this.endAngle-this.startAngle;return Math.abs(t-te)<1e-10?te:zt.normalizeAngle(t)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}get clockwise(){return this.deltaAngle<=0}get normal(){return this._normal}set normal(t){this._normal=new Z(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get majorAxis(){return this._majorAxis}set majorAxis(t){this._majorAxis=new Z(t.x,t.y,t.z),this._majorAxis.normalize(),this._boundingBoxNeedsUpdate=!0}get minorAxis(){return new Z().crossVectors(this.normal,this.majorAxis).normalize()}get startPoint(){return this.getPointAtAngle(this._startAngle)}get endPoint(){return this.getPointAtAngle(this._endAngle)}get isCircular(){return Ts.equal(this.majorAxisRadius,this.minorAxisRadius)}get length(){if(this.isCircular)return this.majorAxisRadius*Math.abs(this.deltaAngle);const t=1e3,e=this.deltaAngle/t;let i=0,l=this.getPointAtAngle(this.startAngle);for(let h=1;h<=t;h++){const u=this.startAngle+h*e,f=this.getPointAtAngle(u),b=f.x-l.x,p=f.y-l.y,S=f.z-l.z;i+=Math.sqrt(b*b+p*p+S*S),l=f}return i}calculateBoundingBox(){if(this.majorAxis.equals(Z.X_AXIS)||this.majorAxis.equals(Z.Y_AXIS)||this.majorAxis.isParallelTo(Z.X_AXIS)||this.majorAxis.isParallelTo(Z.Y_AXIS)){const t=[this.startAngle,this.endAngle];for(let b=0;b<2*Math.PI;b+=Math.PI/2)zt.isBetweenAngle(b,this.startAngle,this.endAngle)&&t.push(b);let e=1/0,i=1/0,l=1/0,h=-1/0,u=-1/0,f=-1/0;for(const b of t){const p=this.getPointAtAngle(b);p.x<e&&(e=p.x),p.y<i&&(i=p.y),p.z<l&&(l=p.z),p.x>h&&(h=p.x),p.y>u&&(u=p.y),p.z>f&&(f=p.z)}return new Rt({x:e,y:i,z:l},{x:h,y:u,z:f})}else{let t=1/0,e=1/0,i=1/0,l=-1/0,h=-1/0,u=-1/0;for(let f=0;f<=100;f++){const b=this.startAngle+this.deltaAngle*(f/100),p=this.getPointAtAngle(b);t=Math.min(t,p.x),e=Math.min(e,p.y),i=Math.min(i,p.z),l=Math.max(l,p.x),h=Math.max(h,p.y),u=Math.max(u,p.z)}return new Rt({x:t,y:e,z:i},{x:l,y:h,z:u})}}get closed(){return this.deltaAngle==0}getPoints(t=100){const e=[];let i=this.deltaAngle,l=this.startAngle;this.closed&&(i=te,l=0);for(let h=0;h<=t;h++){const u=l+i*(h/t),f=this.getPointAtAngle(u);e.push(f)}return e}getPointAtAngle(t){const e=Math.cos(t),i=Math.sin(t),l=this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(i),h=this.majorAxis.clone().multiplyScalar(e*this.majorAxisRadius).add(l);return new X(this.center.x+h.x,this.center.y+h.y,this.center.z+h.z)}contains(t){const e=new Z(t).sub(this.center),i=e.dot(this.majorAxis),l=e.dot(this.minorAxis),h=i/this.majorAxisRadius,u=l/this.minorAxisRadius;return h*h+u*u<=1}transform(t){return this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.normal=t.normal,this.majorAxis=t.majorAxis,this.majorAxisRadius=t.majorAxisRadius,this.minorAxisRadius=t.minorAxisRadius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this._boundingBoxNeedsUpdate=!0,this}clone(){return new Wi(this.center,this.normal,this.majorAxis,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle)}get plane(){const t=new Z(this.center).distanceTo(ks);return new Qr(this.normal,t)}}class ti extends fr{constructor(t=null,e=!1){super(),this._vertices=t||new Array,this._closed=e}get numberOfVertices(){return this._vertices.length}get closed(){return this._closed}get startPoint(){if(this.numberOfVertices>0){const t=this._vertices[0];return new Mt(t.x,t.y)}throw new Error("Start point does not exist in an empty polyline.")}get endPoint(){const t=this.numberOfVertices;if(t>0)if(this.closed){const e=this._vertices[0];return new Mt(e.x,e.y)}else{const e=this._vertices[t-1];return new Mt(e.x,e.y)}throw new Error("End point does not exist in an empty polyline.")}get length(){let t=0;const e=this._vertices.length;for(let i=0;i<e;++i){const l=this._vertices[i];let h=null;if(i<e-1?h=this._vertices[i+1]:i==e-1&&this.closed&&(h=this._vertices[0]),h)if(l.bulge){const u=new pr(l,h,l.bulge);t+=u.length}else t+=new Mt(l.x,l.y).distanceTo(h)}return t}set closed(t){this._closed=t,this._boundingBoxNeedsUpdate=!0}addVertexAt(t,e){t<=0?this._vertices.unshift(e):this._vertices.splice(t,0,e),this._boundingBoxNeedsUpdate=!0}getPointAt(t){const e=this._vertices[t];return new Mt(e.x,e.y)}calculateBoundingBox(){const t=this.getPoints(100);return new me().setFromPoints(t)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}getPoints3d(t,e){const i=[];return this.getPoints(t).forEach(l=>i.push(new X().set(l.x,l.y,e))),i}getPoints(t){const e=[],i=this._vertices.length;for(let l=0;l<i;++l){const h=this._vertices[l];if(h.bulge){let u=null;if(l<i-1?u=this._vertices[l+1]:l==i-1&&this.closed&&(u=this._vertices[0]),u){const f=new pr(h,u,h.bulge).getPoints(t),b=f.length;for(let p=0;p<b;++p){const S=f[p];e.push(new Mt(S.x,S.y))}}}else e.push(new Mt(h.x,h.y)),l==i-1&&this.closed&&e.push(e[0])}return e}}class qi extends fr{constructor(t,e){super(),this._start=new Mt(t),this._end=new Mt(e)}get startPoint(){return this._start}set startPoint(t){this._start.copy(t),this._boundingBoxNeedsUpdate=!0}get endPoint(){return this._end}set endPoint(t){this._end.copy(t),this._boundingBoxNeedsUpdate=!0}getPoints(){return[this.startPoint,this.endPoint]}get length(){return this.startPoint.distanceTo(this.endPoint)}calculateBoundingBox(){const t=new Mt(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y)),e=new Mt(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y));return new me(t,e)}transform(t){return this._start.applyMatrix2d(t),this._end.applyMatrix2d(t),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new qi(this._start.clone(),this._end.clone())}}class el extends fr{constructor(t=[]){super(),this._curves=t}get curves(){return this._curves}add(t){this._curves.push(t),this._boundingBoxNeedsUpdate=!0}get numberOfEdges(){return this._curves.length}get startPoint(){if(this._curves.length>0){const t=this._curves[0].startPoint;return new Mt(t.x,t.y)}throw new Error("Start point does not exist in an empty loop.")}get endPoint(){return this.startPoint}get length(){let t=0;return this._curves.forEach(e=>{t+=e.length}),t}calculateBoundingBox(){const t=this.getPoints(100),e=new me;return e.setFromPoints(t),e}transform(t){return this._boundingBoxNeedsUpdate=!0,this}get closed(){return!0}getPoints(t){const e=[];return this.curves.forEach(i=>{i.getPoints(t).forEach(l=>{e.push(new Mt(l.x,l.y))})}),e}}function cu(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var nl={exports:{}};(function(a,t){(function(e){a.exports=e()})(function(){var e={},i=this;new Function("try {return this===window;}catch(e){ return false;}");var l=new Function("try {return this===global;}catch(e){return false;}"),h=new Function("try {return typeof importScripts === 'function';}catch(e){return false;}");if(l()&&h(),l()||h()){var u=i;if(h()){var f=function(b,p){var S=i;return b.split(".").forEach(function(x){S&&(S=S[x])}),S?S[p]:null};onmessage=function(b){if(!(!b.data.className||!b.data.methodName)){var p=f(b.data.className,b.data.methodName);if(!p)return console.error("could not find "+b.data.className+"."+b.data.methodName);postMessage({result:p.apply(null,b.data.args),id:b.data.id})}}}}return function(b,p,S){p.geom=p.geom||{},p.exe=p.exe||{},p.eval=p.eval||{},p.core=p.core||{},p.promhx=p.promhx||{};var x={},E=function(){return kt.__string_rec(this,"")};function T(n,r){function s(){}s.prototype=n;var o=new s;for(var c in r)o[c]=r[c];return r.toString!==Object.prototype.toString&&(o.toString=r.toString),o}var O=function(){};x.HxOverrides=O,O.__name__=["HxOverrides"],O.strDate=function(n){var r=n.length;switch(r){case 8:var s=n.split(":"),o=new Date;return o.setTime(0),o.setUTCHours(s[0]),o.setUTCMinutes(s[1]),o.setUTCSeconds(s[2]),o;case 10:var c=n.split("-");return new Date(c[0],c[1]-1,c[2],0,0,0);case 19:var d=n.split(" "),g=d[0].split("-"),_=d[1].split(":");return new Date(g[0],g[1]-1,g[2],_[0],_[1],_[2]);default:throw new J("Invalid date format : "+n)}},O.cca=function(n,r){var s=n.charCodeAt(r);if(s==s)return s},O.substr=function(n,r,s){return r!=null&&r!=0&&s!=null&&s<0?"":(s==null&&(s=n.length),r<0?(r=n.length+r,r<0&&(r=0)):s<0&&(s=n.length+s-r),n.substr(r,s))},O.iter=function(n){return{cur:0,arr:n,hasNext:function(){return this.cur<this.arr.length},next:function(){return this.arr[this.cur++]}}};var R=function(){};x.Lambda=R,R.__name__=["Lambda"],R.fold=function(n,r,s){for(var o=Xe(n)();o.hasNext();){var c=o.next();s=r(c,s)}return s};var G=function(){this.length=0};x.List=G,G.__name__=["List"],G.prototype={add:function(n){var r=[n];this.h==null?this.h=r:this.q[1]=r,this.q=r,this.length++},pop:function(){if(this.h==null)return null;var n=this.h[0];return this.h=this.h[1],this.h==null&&(this.q=null),this.length--,n},isEmpty:function(){return this.h==null},__class__:G},Math.__name__=["Math"];var F=function(){};x.Reflect=F,F.__name__=["Reflect"],F.field=function(n,r){try{return n[r]}catch(s){return s instanceof J&&(s=s.val),null}},F.callMethod=function(n,r,s){return r.apply(n,s)},F.fields=function(n){var r=[];if(n!=null){var s=Object.prototype.hasOwnProperty;for(var o in n)o!="__id__"&&o!="hx__closures__"&&s.call(n,o)&&r.push(o)}return r},F.isFunction=function(n){return typeof n=="function"&&!(n.__name__||n.__ename__)},F.deleteField=function(n,r){return Object.prototype.hasOwnProperty.call(n,r)?(delete n[r],!0):!1};var pt=function(){};x.Std=pt,pt.__name__=["Std"],pt.string=function(n){return kt.__string_rec(n,"")},pt.parseFloat=function(n){return parseFloat(n)};var _t=function(){this.b=""};x.StringBuf=_t,_t.__name__=["StringBuf"],_t.prototype={add:function(n){this.b+=pt.string(n)},__class__:_t};var ut=function(){};x.StringTools=ut,ut.__name__=["StringTools"],ut.fastCodeAt=function(n,r){return n.charCodeAt(r)};var W=x.ValueType={__ename__:["ValueType"],__constructs__:["TNull","TInt","TFloat","TBool","TObject","TFunction","TClass","TEnum","TUnknown"]};W.TNull=["TNull",0],W.TNull.toString=E,W.TNull.__enum__=W,W.TInt=["TInt",1],W.TInt.toString=E,W.TInt.__enum__=W,W.TFloat=["TFloat",2],W.TFloat.toString=E,W.TFloat.__enum__=W,W.TBool=["TBool",3],W.TBool.toString=E,W.TBool.__enum__=W,W.TObject=["TObject",4],W.TObject.toString=E,W.TObject.__enum__=W,W.TFunction=["TFunction",5],W.TFunction.toString=E,W.TFunction.__enum__=W,W.TClass=function(n){var r=["TClass",6,n];return r.__enum__=W,r.toString=E,r},W.TEnum=function(n){var r=["TEnum",7,n];return r.__enum__=W,r.toString=E,r},W.TUnknown=["TUnknown",8],W.TUnknown.toString=E,W.TUnknown.__enum__=W;var gt=function(){};x.Type=gt,gt.__name__=["Type"],gt.getClassName=function(n){var r=n.__name__;return r==null?null:r.join(".")},gt.getEnumName=function(n){var r=n.__ename__;return r.join(".")},gt.resolveClass=function(n){var r=x[n];return r==null||!r.__name__?null:r},gt.resolveEnum=function(n){var r=x[n];return r==null||!r.__ename__?null:r},gt.createEmptyInstance=function(n){function r(){}return r.prototype=n.prototype,new r},gt.createEnum=function(n,r,s){var o=F.field(n,r);if(o==null)throw new J("No such constructor "+r);if(F.isFunction(o)){if(s==null)throw new J("Constructor "+r+" need parameters");return F.callMethod(n,o,s)}if(s!=null&&s.length!=0)throw new J("Constructor "+r+" does not need parameters");return o},gt.getEnumConstructs=function(n){var r=n.__constructs__;return r.slice()},gt.typeof=function(n){var r=typeof n;switch(r){case"boolean":return W.TBool;case"string":return W.TClass(String);case"number":return Math.ceil(n)==n%2147483648?W.TInt:W.TFloat;case"object":if(n==null)return W.TNull;var s=n.__enum__;if(s!=null)return W.TEnum(s);var o=kt.getClass(n);return o!=null?W.TClass(o):W.TObject;case"function":return n.__name__||n.__ename__?W.TObject:W.TFunction;case"undefined":return W.TNull;default:return W.TUnknown}};var ht=function(){};x["haxe.IMap"]=ht,ht.__name__=["haxe","IMap"];var Wt=function(n,r){this.high=n,this.low=r};x["haxe._Int64.___Int64"]=Wt,Wt.__name__=["haxe","_Int64","___Int64"],Wt.prototype={__class__:Wt};var qt=function(){this.buf=new _t,this.cache=[],this.useCache=qt.USE_CACHE,this.useEnumIndex=qt.USE_ENUM_INDEX,this.shash=new fe,this.scount=0};x["haxe.Serializer"]=qt,qt.__name__=["haxe","Serializer"],qt.prototype={toString:function(){return this.buf.b},serializeString:function(n){var r=this.shash.get(n);if(r!=null){this.buf.b+="R",r==null?this.buf.b+="null":this.buf.b+=""+r;return}this.shash.set(n,this.scount++),this.buf.b+="y",n=encodeURIComponent(n),n.length==null?this.buf.b+="null":this.buf.b+=""+n.length,this.buf.b+=":",n==null?this.buf.b+="null":this.buf.b+=""+n},serializeRef:function(n){for(var r=typeof n,s=0,o=this.cache.length;s<o;){var c=s++,d=this.cache[c];if(typeof d==r&&d==n)return this.buf.b+="r",c==null?this.buf.b+="null":this.buf.b+=""+c,!0}return this.cache.push(n),!1},serializeFields:function(n){for(var r=0,s=F.fields(n);r<s.length;){var o=s[r];++r,this.serializeString(o),this.serialize(F.field(n,o))}this.buf.b+="g"},serialize:function(n){{var r=gt.typeof(n);switch(r[1]){case 0:this.buf.b+="n";break;case 1:var s=n;if(s==0){this.buf.b+="z";return}this.buf.b+="i",s==null?this.buf.b+="null":this.buf.b+=""+s;break;case 2:var o=n;isNaN(o)?this.buf.b+="k":isFinite(o)?(this.buf.b+="d",o==null?this.buf.b+="null":this.buf.b+=""+o):o<0?this.buf.b+="m":this.buf.b+="p";break;case 3:n?this.buf.b+="t":this.buf.b+="f";break;case 6:var c=r[2];if(c==String){this.serializeString(n);return}if(this.useCache&&this.serializeRef(n))return;switch(c){case Array:var d=0;this.buf.b+="a";for(var g=n.length,_=0;_<g;){var v=_++;n[v]==null?d++:(d>0&&(d==1?this.buf.b+="n":(this.buf.b+="u",d==null?this.buf.b+="null":this.buf.b+=""+d),d=0),this.serialize(n[v]))}d>0&&(d==1?this.buf.b+="n":(this.buf.b+="u",d==null?this.buf.b+="null":this.buf.b+=""+d)),this.buf.b+="h";break;case G:this.buf.b+="l";for(var w=n,P=w.h,A=null;P!=null;){var I;A=P[0],P=P[1],I=A,this.serialize(I)}this.buf.b+="h";break;case Date:var M=n;this.buf.b+="v",this.buf.add(M.getTime());break;case fe:this.buf.b+="b";for(var k=n,z=k.keys();z.hasNext();){var N=z.next();this.serializeString(N),this.serialize(Qs[N]!=null?k.getReserved(N):k.h[N])}this.buf.b+="h";break;case xt:this.buf.b+="q";for(var B=n,D=B.keys();D.hasNext();){var V=D.next();this.buf.b+=":",V==null?this.buf.b+="null":this.buf.b+=""+V,this.serialize(B.h[V])}this.buf.b+="h";break;case Nt:this.buf.b+="M";for(var U=n,q=U.keys();q.hasNext();){var tt=q.next(),H=F.field(tt,"__id__");F.deleteField(tt,"__id__"),this.serialize(tt),tt.__id__=H,this.serialize(U.h[tt.__id__])}this.buf.b+="h";break;case ze:for(var j=n,K=0,et=j.length-2,nt=new _t,st=qt.BASE64;K<et;){var lt=j.get(K++),at=j.get(K++),ct=j.get(K++);nt.add(st.charAt(lt>>2)),nt.add(st.charAt((lt<<4|at>>4)&63)),nt.add(st.charAt((at<<2|ct>>6)&63)),nt.add(st.charAt(ct&63))}if(K==et){var it=j.get(K++),dt=j.get(K++);nt.add(st.charAt(it>>2)),nt.add(st.charAt((it<<4|dt>>4)&63)),nt.add(st.charAt(dt<<2&63))}else if(K==et+1){var Y=j.get(K++);nt.add(st.charAt(Y>>2)),nt.add(st.charAt(Y<<4&63))}var ft=nt.b;this.buf.b+="s",ft.length==null?this.buf.b+="null":this.buf.b+=""+ft.length,this.buf.b+=":",ft==null?this.buf.b+="null":this.buf.b+=""+ft;break;default:this.useCache&&this.cache.pop(),n.hxSerialize!=null?(this.buf.b+="C",this.serializeString(gt.getClassName(c)),this.useCache&&this.cache.push(n),n.hxSerialize(this),this.buf.b+="g"):(this.buf.b+="c",this.serializeString(gt.getClassName(c)),this.useCache&&this.cache.push(n),this.serializeFields(n))}break;case 4:if(kt.__instanceof(n,ih)){var Pt=gt.getClassName(n);this.buf.b+="A",this.serializeString(Pt)}else if(kt.__instanceof(n,sh))this.buf.b+="B",this.serializeString(gt.getEnumName(n));else{if(this.useCache&&this.serializeRef(n))return;this.buf.b+="o",this.serializeFields(n)}break;case 7:var Ut=r[2];if(this.useCache){if(this.serializeRef(n))return;this.cache.pop()}this.useEnumIndex?this.buf.b+="j":this.buf.b+="w",this.serializeString(gt.getEnumName(Ut)),this.useEnumIndex?(this.buf.b+=":",this.buf.b+=pt.string(n[1])):this.serializeString(n[0]),this.buf.b+=":";var Yt=n.length;this.buf.b+=pt.string(Yt-2);for(var Ft=2;Ft<Yt;){var $t=Ft++;this.serialize(n[$t])}this.useCache&&this.cache.push(n);break;case 5:throw new J("Cannot serialize function");default:throw new J("Cannot serialize "+pt.string(n))}}},__class__:qt};var Gt=function(n){this.buf=n,this.length=n.length,this.pos=0,this.scache=[],this.cache=[];var r=Gt.DEFAULT_RESOLVER;r==null&&(r=gt,Gt.DEFAULT_RESOLVER=r),this.setResolver(r)};x["haxe.Unserializer"]=Gt,Gt.__name__=["haxe","Unserializer"],Gt.initCodes=function(){for(var n=[],r=0,s=Gt.BASE64.length;r<s;){var o=r++;n[Gt.BASE64.charCodeAt(o)]=o}return n},Gt.prototype={setResolver:function(n){n==null?this.resolver={resolveClass:function(r){return null},resolveEnum:function(r){return null}}:this.resolver=n},get:function(n){return this.buf.charCodeAt(n)},readDigits:function(){for(var n=0,r=!1,s=this.pos;;){var o=this.buf.charCodeAt(this.pos);if(o!=o)break;if(o==45){if(this.pos!=s)break;r=!0,this.pos++;continue}if(o<48||o>57)break;n=n*10+(o-48),this.pos++}return r&&(n*=-1),n},readFloat:function(){for(var n=this.pos;;){var r=this.buf.charCodeAt(this.pos);if(r>=43&&r<58||r==101||r==69)this.pos++;else break}return pt.parseFloat(O.substr(this.buf,n,this.pos-n))},unserializeObject:function(n){for(;;){if(this.pos>=this.length)throw new J("Invalid object");if(this.buf.charCodeAt(this.pos)==103)break;var r=this.unserialize();if(typeof r!="string")throw new J("Invalid object key");var s=this.unserialize();n[r]=s}this.pos++},unserializeEnum:function(n,r){if(this.get(this.pos++)!=58)throw new J("Invalid enum format");var s=this.readDigits();if(s==0)return gt.createEnum(n,r);for(var o=[];s-- >0;)o.push(this.unserialize());return gt.createEnum(n,r,o)},unserialize:function(){var n=this.get(this.pos++);switch(n){case 110:return null;case 116:return!0;case 102:return!1;case 122:return 0;case 105:return this.readDigits();case 100:return this.readFloat();case 121:var r=this.readDigits();if(this.get(this.pos++)!=58||this.length-this.pos<r)throw new J("Invalid string length");var s=O.substr(this.buf,this.pos,r);return this.pos+=r,s=decodeURIComponent(s.split("+").join(" ")),this.scache.push(s),s;case 107:return NaN;case 109:return-1/0;case 112:return 1/0;case 97:this.buf;var o=[];for(this.cache.push(o);;){var c=this.buf.charCodeAt(this.pos);if(c==104){this.pos++;break}if(c==117){this.pos++;var d=this.readDigits();o[o.length+d-1]=null}else o.push(this.unserialize())}return o;case 111:var g={};return this.cache.push(g),this.unserializeObject(g),g;case 114:var _=this.readDigits();if(_<0||_>=this.cache.length)throw new J("Invalid reference");return this.cache[_];case 82:var v=this.readDigits();if(v<0||v>=this.scache.length)throw new J("Invalid string reference");return this.scache[v];case 120:throw new J(this.unserialize());case 99:var w=this.unserialize(),P=this.resolver.resolveClass(w);if(P==null)throw new J("Class not found "+w);var A=gt.createEmptyInstance(P);return this.cache.push(A),this.unserializeObject(A),A;case 119:var I=this.unserialize(),M=this.resolver.resolveEnum(I);if(M==null)throw new J("Enum not found "+I);var k=this.unserializeEnum(M,this.unserialize());return this.cache.push(k),k;case 106:var z=this.unserialize(),N=this.resolver.resolveEnum(z);if(N==null)throw new J("Enum not found "+z);this.pos++;var B=this.readDigits(),D=gt.getEnumConstructs(N)[B];if(D==null)throw new J("Unknown enum index "+z+"@"+B);var V=this.unserializeEnum(N,D);return this.cache.push(V),V;case 108:var U=new G;for(this.cache.push(U),this.buf;this.buf.charCodeAt(this.pos)!=104;)U.add(this.unserialize());return this.pos++,U;case 98:var q=new fe;for(this.cache.push(q),this.buf;this.buf.charCodeAt(this.pos)!=104;){var tt=this.unserialize();q.set(tt,this.unserialize())}return this.pos++,q;case 113:var H=new xt;this.cache.push(H),this.buf;for(var j=this.get(this.pos++);j==58;){var K=this.readDigits();H.set(K,this.unserialize()),j=this.get(this.pos++)}if(j!=104)throw new J("Invalid IntMap format");return H;case 77:var et=new Nt;for(this.cache.push(et),this.buf;this.buf.charCodeAt(this.pos)!=104;){var nt=this.unserialize();et.set(nt,this.unserialize())}return this.pos++,et;case 118:var st;if(this.buf.charCodeAt(this.pos)>=48&&this.buf.charCodeAt(this.pos)<=57&&this.buf.charCodeAt(this.pos+1)>=48&&this.buf.charCodeAt(this.pos+1)<=57&&this.buf.charCodeAt(this.pos+2)>=48&&this.buf.charCodeAt(this.pos+2)<=57&&this.buf.charCodeAt(this.pos+3)>=48&&this.buf.charCodeAt(this.pos+3)<=57&&this.buf.charCodeAt(this.pos+4)==45){var lt=O.substr(this.buf,this.pos,19);st=O.strDate(lt),this.pos+=19}else{var at=this.readFloat(),ct=new Date;ct.setTime(at),st=ct}return this.cache.push(st),st;case 115:var it=this.readDigits(),dt=this.buf;if(this.get(this.pos++)!=58||this.length-this.pos<it)throw new J("Invalid bytes length");var Y=Gt.CODES;Y==null&&(Y=Gt.initCodes(),Gt.CODES=Y);var ft=this.pos,Pt=it&3,Ut;Ut=(it>>2)*3+(Pt>=2?Pt-1:0);for(var Yt=ft+(it-Pt),Ft=ze.alloc(Ut),$t=0;ft<Yt;){var Pe=Y[ut.fastCodeAt(dt,ft++)],Ue=Y[ut.fastCodeAt(dt,ft++)];Ft.set($t++,Pe<<2|Ue>>4);var xe=Y[ut.fastCodeAt(dt,ft++)];Ft.set($t++,Ue<<4|xe>>2);var _e=Y[ut.fastCodeAt(dt,ft++)];Ft.set($t++,xe<<6|_e)}if(Pt>=2){var Se=Y[ut.fastCodeAt(dt,ft++)],Be=Y[ut.fastCodeAt(dt,ft++)];if(Ft.set($t++,Se<<2|Be>>4),Pt==3){var $e=Y[ut.fastCodeAt(dt,ft++)];Ft.set($t++,Be<<4|$e>>2)}}return this.pos+=it,this.cache.push(Ft),Ft;case 67:var on=this.unserialize(),Ze=this.resolver.resolveClass(on);if(Ze==null)throw new J("Class not found "+on);var Qe=gt.createEmptyInstance(Ze);if(this.cache.push(Qe),Qe.hxUnserialize(this),this.get(this.pos++)!=103)throw new J("Invalid custom data");return Qe;case 65:var Je=this.unserialize(),wn=this.resolver.resolveClass(Je);if(wn==null)throw new J("Class not found "+Je);return wn;case 66:var Tr=this.unserialize(),or=this.resolver.resolveEnum(Tr);if(or==null)throw new J("Enum not found "+Tr);return or}throw this.pos--,new J("Invalid char "+this.buf.charAt(this.pos)+" at position "+this.pos)},__class__:Gt};var xt=function(){this.h={}};x["haxe.ds.IntMap"]=xt,xt.__name__=["haxe","ds","IntMap"],xt.__interfaces__=[ht],xt.prototype={set:function(n,r){this.h[n]=r},remove:function(n){return this.h.hasOwnProperty(n)?(delete this.h[n],!0):!1},keys:function(){var n=[];for(var r in this.h)this.h.hasOwnProperty(r)&&n.push(r|0);return O.iter(n)},__class__:xt};var Nt=function(){this.h={},this.h.__keys__={}};x["haxe.ds.ObjectMap"]=Nt,Nt.__name__=["haxe","ds","ObjectMap"],Nt.__interfaces__=[ht],Nt.prototype={set:function(n,r){var s=n.__id__||(n.__id__=++Nt.count);this.h[s]=r,this.h.__keys__[s]=n},keys:function(){var n=[];for(var r in this.h.__keys__)this.h.hasOwnProperty(r)&&n.push(this.h.__keys__[r]);return O.iter(n)},__class__:Nt};var ge=x["haxe.ds.Option"]={__ename__:["haxe","ds","Option"],__constructs__:["Some","None"]};ge.Some=function(n){var r=["Some",0,n];return r.__enum__=ge,r.toString=E,r},ge.None=["None",1],ge.None.toString=E,ge.None.__enum__=ge;var fe=function(){this.h={}};x["haxe.ds.StringMap"]=fe,fe.__name__=["haxe","ds","StringMap"],fe.__interfaces__=[ht],fe.prototype={set:function(n,r){Qs[n]!=null?this.setReserved(n,r):this.h[n]=r},get:function(n){return Qs[n]!=null?this.getReserved(n):this.h[n]},setReserved:function(n,r){this.rh==null&&(this.rh={}),this.rh["$"+n]=r},getReserved:function(n){return this.rh==null?null:this.rh["$"+n]},keys:function(){var n=this.arrayKeys();return O.iter(n)},arrayKeys:function(){var n=[];for(var r in this.h)this.h.hasOwnProperty(r)&&n.push(r);if(this.rh!=null)for(var r in this.rh)r.charCodeAt(0)==36&&n.push(r.substr(1));return n},__class__:fe};var ze=function(n){this.length=n.byteLength,this.b=new Js(n),this.b.bufferValue=n,n.hxBytes=this,n.bytes=this.b};x["haxe.io.Bytes"]=ze,ze.__name__=["haxe","io","Bytes"],ze.alloc=function(n){return new ze(new ns(n))},ze.prototype={get:function(n){return this.b[n]},set:function(n,r){this.b[n]=r&255},__class__:ze};var ee=x["haxe.io.Error"]={__ename__:["haxe","io","Error"],__constructs__:["Blocked","Overflow","OutsideBounds","Custom"]};ee.Blocked=["Blocked",0],ee.Blocked.toString=E,ee.Blocked.__enum__=ee,ee.Overflow=["Overflow",1],ee.Overflow.toString=E,ee.Overflow.__enum__=ee,ee.OutsideBounds=["OutsideBounds",2],ee.OutsideBounds.toString=E,ee.OutsideBounds.__enum__=ee,ee.Custom=function(n){var r=["Custom",3,n];return r.__enum__=ee,r.toString=E,r};var he=function(){};x["haxe.io.FPHelper"]=he,he.__name__=["haxe","io","FPHelper"],he.i32ToFloat=function(n){var r=1-(n>>>31<<1),s=n>>>23&255,o=n&8388607;return o==0&&s==0?0:r*(1+Math.pow(2,-23)*o)*Math.pow(2,s-127)},he.floatToI32=function(n){if(n==0)return 0;var r;n<0?r=-n:r=n;var s=Math.floor(Math.log(r)/.6931471805599453);s<-127?s=-127:s>128&&(s=128);var o=Math.round((r/Math.pow(2,s)-1)*8388608)&8388607;return(n<0?-2147483648:0)|s+127<<23|o},he.i64ToDouble=function(n,r){var s=1-(r>>>31<<1),o=(r>>20&2047)-1023,c=(r&1048575)*4294967296+(n>>>31)*2147483648+(n&2147483647);return c==0&&o==-1023?0:s*(1+Math.pow(2,-52)*c)*Math.pow(2,o)},he.doubleToI64=function(n){var r=he.i64tmp;if(n==0)r.low=0,r.high=0;else{var s;n<0?s=-n:s=n;var o=Math.floor(Math.log(s)/.6931471805599453),c,d=(s/Math.pow(2,o)-1)*4503599627370496;c=Math.round(d);var g=c|0,_=c/4294967296|0;r.low=g,r.high=(n<0?-2147483648:0)|o+1023<<20|_}return r};var J=function(n){Error.call(this),this.val=n,this.message=String(n),Error.captureStackTrace&&Error.captureStackTrace(this,J)};x["js._Boot.HaxeError"]=J,J.__name__=["js","_Boot","HaxeError"],J.__super__=Error,J.prototype=T(Error.prototype,{__class__:J});var kt=function(){};x["js.Boot"]=kt,kt.__name__=["js","Boot"],kt.getClass=function(n){if(n instanceof Array&&n.__enum__==null)return Array;var r=n.__class__;if(r!=null)return r;var s=kt.__nativeClassName(n);return s!=null?kt.__resolveNativeClass(s):null},kt.__string_rec=function(n,r){if(n==null)return"null";if(r.length>=5)return"<...>";var s=typeof n;switch(s=="function"&&(n.__name__||n.__ename__)&&(s="object"),s){case"object":if(n instanceof Array){if(n.__enum__){if(n.length==2)return n[0];var o=n[0]+"(";r+=" ";for(var c=2,d=n.length;c<d;){var g=c++;g!=2?o+=","+kt.__string_rec(n[g],r):o+=kt.__string_rec(n[g],r)}return o+")"}var _=n.length,v="[";r+=" ";for(var w=0;w<_;){var P=w++;v+=(P>0?",":"")+kt.__string_rec(n[P],r)}return v+="]",v}var A;try{A=n.toString}catch(N){return N instanceof J&&(N=N.val),"???"}if(A!=null&&A!=Object.toString&&typeof A=="function"){var I=n.toString();if(I!="[object Object]")return I}var M=null,k=`{
3
+ `;r+=" ";var z=n.hasOwnProperty!=null;for(var M in n)z&&!n.hasOwnProperty(M)||M=="prototype"||M=="__class__"||M=="__super__"||M=="__interfaces__"||M=="__properties__"||(k.length!=2&&(k+=`,
4
+ `),k+=r+M+" : "+kt.__string_rec(n[M],r));return r=r.substring(1),k+=`
5
+ `+r+"}",k;case"function":return"<function>";case"string":return n;default:return String(n)}},kt.__interfLoop=function(n,r){if(n==null)return!1;if(n==r)return!0;var s=n.__interfaces__;if(s!=null)for(var o=0,c=s.length;o<c;){var d=o++,g=s[d];if(g==r||kt.__interfLoop(g,r))return!0}return kt.__interfLoop(n.__super__,r)},kt.__instanceof=function(n,r){if(r==null)return!1;switch(r){case yu:return(n|0)===n;case nh:return typeof n=="number";case rh:return typeof n=="boolean";case String:return typeof n=="string";case Array:return n instanceof Array&&n.__enum__==null;case bu:return!0;default:if(n!=null){if(typeof r=="function"){if(n instanceof r||kt.__interfLoop(kt.getClass(n),r))return!0}else if(typeof r=="object"&&kt.__isNativeObj(r)&&n instanceof r)return!0}else return!1;return r==ih&&n.__name__!=null||r==sh&&n.__ename__!=null?!0:n.__enum__==r}},kt.__nativeClassName=function(n){var r=kt.__toStr.call(n).slice(8,-1);return r=="Object"||r=="Function"||r=="Math"||r=="JSON"?null:r},kt.__isNativeObj=function(n){return kt.__nativeClassName(n)!=null},kt.__resolveNativeClass=function(n){return S[n]};var ce=function(n){if(n instanceof Array&&n.__enum__==null)this.a=n,this.byteLength=n.length;else{var r=n;this.a=[];for(var s=0;s<r;){var o=s++;this.a[o]=0}this.byteLength=r}};x["js.html.compat.ArrayBuffer"]=ce,ce.__name__=["js","html","compat","ArrayBuffer"],ce.sliceImpl=function(n,r){var s=new Js(this,n,r==null?null:r-n),o=new ns(s.byteLength),c=new Js(o);return c.set(s),o},ce.prototype={slice:function(n,r){return new ce(this.a.slice(n,r))},__class__:ce};var yn=function(n,r,s){if(this.buf=n,r==null?this.offset=0:this.offset=r,s==null?this.length=n.byteLength-this.offset:this.length=s,this.offset<0||this.length<0||this.offset+this.length>n.byteLength)throw new J(ee.OutsideBounds)};x["js.html.compat.DataView"]=yn,yn.__name__=["js","html","compat","DataView"],yn.prototype={getInt8:function(n){var r=this.buf.a[this.offset+n];return r>=128?r-256:r},getUint8:function(n){return this.buf.a[this.offset+n]},getInt16:function(n,r){var s=this.getUint16(n,r);return s>=32768?s-65536:s},getUint16:function(n,r){return r?this.buf.a[this.offset+n]|this.buf.a[this.offset+n+1]<<8:this.buf.a[this.offset+n]<<8|this.buf.a[this.offset+n+1]},getInt32:function(n,r){var s=this.offset+n,o=this.buf.a[s++],c=this.buf.a[s++],d=this.buf.a[s++],g=this.buf.a[s++];return r?o|c<<8|d<<16|g<<24:g|d<<8|c<<16|o<<24},getUint32:function(n,r){var s=this.getInt32(n,r);return s<0?s+4294967296:s},getFloat32:function(n,r){return he.i32ToFloat(this.getInt32(n,r))},getFloat64:function(n,r){var s=this.getInt32(n,r),o=this.getInt32(n+4,r);return he.i64ToDouble(r?s:o,r?o:s)},setInt8:function(n,r){r<0?this.buf.a[n+this.offset]=r+128&255:this.buf.a[n+this.offset]=r&255},setUint8:function(n,r){this.buf.a[n+this.offset]=r&255},setInt16:function(n,r,s){this.setUint16(n,r<0?r+65536:r,s)},setUint16:function(n,r,s){var o=n+this.offset;s?(this.buf.a[o]=r&255,this.buf.a[o++]=r>>8&255):(this.buf.a[o++]=r>>8&255,this.buf.a[o]=r&255)},setInt32:function(n,r,s){this.setUint32(n,r,s)},setUint32:function(n,r,s){var o=n+this.offset;s?(this.buf.a[o++]=r&255,this.buf.a[o++]=r>>8&255,this.buf.a[o++]=r>>16&255,this.buf.a[o++]=r>>>24):(this.buf.a[o++]=r>>>24,this.buf.a[o++]=r>>16&255,this.buf.a[o++]=r>>8&255,this.buf.a[o++]=r&255)},setFloat32:function(n,r,s){this.setUint32(n,he.floatToI32(r),s)},setFloat64:function(n,r,s){var o=he.doubleToI64(r);s?(this.setUint32(n,o.low),this.setUint32(n,o.high)):(this.setUint32(n,o.high),this.setUint32(n,o.low))},__class__:yn};var nn=function(){};x["js.html.compat.Uint8Array"]=nn,nn.__name__=["js","html","compat","Uint8Array"],nn._new=function(n,r,s){var o;if(typeof n=="number"){o=[];for(var c=0;c<n;){var d=c++;o[d]=0}o.byteLength=o.length,o.byteOffset=0,o.buffer=new ce(o)}else if(kt.__instanceof(n,ce)){var g=n;r==null&&(r=0),s==null&&(s=g.byteLength-r),r==0?o=g.a:o=g.a.slice(r,r+s),o.byteLength=o.length,o.byteOffset=r,o.buffer=g}else if(n instanceof Array&&n.__enum__==null)o=n.slice(),o.byteLength=o.length,o.byteOffset=0,o.buffer=new ce(o);else throw new J("TODO "+pt.string(n));return o.subarray=nn._subarray,o.set=nn._set,o},nn._set=function(n,r){var s=this;if(kt.__instanceof(n.buffer,ce)){var o=n;if(n.byteLength+r>s.byteLength)throw new J("set() outside of range");for(var c=0,d=n.byteLength;c<d;){var g=c++;s[g+r]=o[g]}}else if(n instanceof Array&&n.__enum__==null){var _=n;if(_.length+r>s.byteLength)throw new J("set() outside of range");for(var v=0,w=_.length;v<w;){var P=v++;s[P+r]=_[P]}}else throw new J("TODO")},nn._subarray=function(n,r){var s=this,o=nn._new(s.slice(n,r));return o.byteOffset=n,o};var It=function(n){this._resolved=!1,this._pending=!1,this._errorPending=!1,this._fulfilled=!1,this._update=[],this._error=[],this._errored=!1,n!=null&&It.link(n,this,function(r){return r})};x["promhx.base.AsyncBase"]=It,It.__name__=["promhx","base","AsyncBase"],It.link=function(n,r,s){n._update.push({async:r,linkf:function(o){r.handleResolve(s(o))}}),It.immediateLinkUpdate(n,r,s)},It.immediateLinkUpdate=function(n,r,s){if(n._errored&&!n._errorPending&&!(n._error.length>0)&&r.handleError(n._errorVal),n._resolved&&!n._pending)try{r.handleResolve(s(n._val))}catch(o){o instanceof J&&(o=o.val),r.handleError(o)}},It.linkAll=function(n,r){for(var s=function(d,g,_){if(d.length==0||It.allFulfilled(d)){for(var v,w=[],P=Xe(n)();P.hasNext();){var A=P.next();w.push(A==g?_:A._val)}v=w,r.handleResolve(v)}},o=Xe(n)();o.hasNext();){var c=o.next();c._update.push({async:r,linkf:function(d,g,_){return function(v){d(g,_,v)}}(s,function(d){for(var g,_=[],v=Xe(n)();v.hasNext();){var w=v.next();w!=c&&_.push(w)}return g=_,g}(),c)})}It.allFulfilled(n)&&r.handleResolve(function(d){for(var g,_=[],v=Xe(n)();v.hasNext();){var w=v.next();_.push(w._val)}return g=_,g}())},It.pipeLink=function(n,r,s){var o=!1,c=function(d){if(!o){o=!0;var g=s(d);g._update.push({async:r,linkf:Re(r,r.handleResolve)}),It.immediateLinkUpdate(g,r,function(_){return _})}};if(n._update.push({async:r,linkf:c}),n._resolved&&!n._pending)try{c(n._val)}catch(d){d instanceof J&&(d=d.val),r.handleError(d)}},It.allResolved=function(n){for(var r=Xe(n)();r.hasNext();){var s=r.next();if(!s._resolved)return!1}return!0},It.allFulfilled=function(n){for(var r=Xe(n)();r.hasNext();){var s=r.next();if(!s._fulfilled)return!1}return!0},It.prototype={catchError:function(n){return this._error.push(n),this},errorThen:function(n){return this._errorMap=n,this},isResolved:function(){return this._resolved},isErrored:function(){return this._errored},isErrorHandled:function(){return this._error.length>0},isErrorPending:function(){return this._errorPending},isFulfilled:function(){return this._fulfilled},isPending:function(){return this._pending},handleResolve:function(n){this._resolve(n)},_resolve:function(n){var r=this;this._pending?At.enqueue(function(s,o){return function(){s(o)}}(Re(this,this._resolve),n)):(this._resolved=!0,this._pending=!0,At.queue.add(function(){r._val=n;for(var s=0,o=r._update;s<o.length;){var c=o[s];++s;try{c.linkf(n)}catch(d){d instanceof J&&(d=d.val),c.async.handleError(d)}}r._fulfilled=!0,r._pending=!1}),At.continueOnNextLoop())},handleError:function(n){this._handleError(n)},_handleError:function(n){var r=this,s=function(o){if(r._error.length>0)for(var c=0,d=r._error;c<d.length;){var g=d[c];++c,g(o)}else if(r._update.length>0)for(var _=0,v=r._update;_<v.length;){var w=v[_];++_,w.async.handleError(o)}else throw new J(o);r._errorPending=!1};this._errorPending||(this._errorPending=!0,this._errored=!0,this._errorVal=n,At.queue.add(function(){if(r._errorMap!=null)try{r._resolve(r._errorMap(n))}catch(o){o instanceof J&&(o=o.val),s(o)}else s(n)}),At.continueOnNextLoop())},then:function(n){var r=new It(null);return It.link(this,r,n),r},unlink:function(n){var r=this;At.queue.add(function(){r._update=r._update.filter(function(s){return s.async!=n})}),At.continueOnNextLoop()},isLinked:function(n){for(var r=!1,s=0,o=this._update;s<o.length;){var c=o[s];if(++s,c.async==n)return!0}return r},__class__:It};var yr=p.promhx.Deferred=function(){It.call(this)};x["promhx.Deferred"]=yr,yr.__name__=["promhx","Deferred"],yr.__super__=It,yr.prototype=T(It.prototype,{resolve:function(n){this.handleResolve(n)},throwError:function(n){this.handleError(n)},promise:function(){return new pe(this)},stream:function(){return new Ht(this)},publicStream:function(){return new Ln(this)},__class__:yr});var pe=p.promhx.Promise=function(n){It.call(this,n),this._rejected=!1};x["promhx.Promise"]=pe,pe.__name__=["promhx","Promise"],pe.whenAll=function(n){var r=new pe(null);return It.linkAll(n,r),r},pe.promise=function(n){var r=new pe;return r.handleResolve(n),r},pe.__super__=It,pe.prototype=T(It.prototype,{isRejected:function(){return this._rejected},reject:function(n){this._rejected=!0,this.handleError(n)},handleResolve:function(n){if(this._resolved){var r="Promise has already been resolved";throw new J(br.AlreadyResolved(r))}this._resolve(n)},then:function(n){var r=new pe(null);return It.link(this,r,n),r},unlink:function(n){var r=this;At.queue.add(function(){if(r._fulfilled)r._update=r._update.filter(function(o){return o.async!=n});else{var s="Downstream Promise is not fullfilled";r.handleError(br.DownstreamNotFullfilled(s))}}),At.continueOnNextLoop()},handleError:function(n){this._rejected=!0,this._handleError(n)},pipe:function(n){var r=new pe(null);return It.pipeLink(this,r,n),r},errorPipe:function(n){var r=new pe;return this.catchError(function(s){var o=n(s);o.then(Re(r,r._resolve))}),this.then(Re(r,r._resolve)),r},__class__:pe});var Ht=p.promhx.Stream=function(n){It.call(this,n),this._end_promise=new pe};x["promhx.Stream"]=Ht,Ht.__name__=["promhx","Stream"],Ht.foreach=function(n){for(var r=new Ht(null),s=Xe(n)();s.hasNext();){var o=s.next();r.handleResolve(o)}return r.end(),r},Ht.wheneverAll=function(n){var r=new Ht(null);return It.linkAll(n,r),r},Ht.concatAll=function(n){for(var r=new Ht(null),s=Xe(n)();s.hasNext();){var o=s.next();r.concat(o)}return r},Ht.mergeAll=function(n){for(var r=new Ht(null),s=Xe(n)();s.hasNext();){var o=s.next();r.merge(o)}return r},Ht.stream=function(n){var r=new Ht(null);return r.handleResolve(n),r},Ht.__super__=It,Ht.prototype=T(It.prototype,{then:function(n){var r=new Ht(null);return It.link(this,r,n),this._end_promise._update.push({async:r._end_promise,linkf:function(s){r.end()}}),r},detachStream:function(n){for(var r=[],s=!1,o=0,c=this._update;o<c.length;){var d=c[o];++o,d.async==n?(this._end_promise._update=this._end_promise._update.filter(function(g){return g.async!=n._end_promise}),s=!0):r.push(d)}return this._update=r,s},first:function(){var n=new pe(null);return this.then(function(r){n._resolved||n.handleResolve(r)}),n},handleResolve:function(n){!this._end&&!this._pause&&this._resolve(n)},pause:function(n){n==null&&(n=!this._pause),this._pause=n},pipe:function(n){var r=new Ht(null);return It.pipeLink(this,r,n),this._end_promise.then(function(s){r.end()}),r},errorPipe:function(n){var r=new Ht(null);return this.catchError(function(s){var o=n(s);o.then(Re(r,r._resolve)),o._end_promise.then((Zs=r._end_promise,Re(Zs,Zs._resolve)))}),this.then(Re(r,r._resolve)),this._end_promise.then(function(s){r.end()}),r},handleEnd:function(){if(this._pending)At.queue.add(Re(this,this.handleEnd)),At.continueOnNextLoop();else{if(this._end_promise._resolved)return;this._end=!0;var n;this._resolved?n=ge.Some(this._val):n=ge.None,this._end_promise.handleResolve(n),this._update=[],this._error=[]}},end:function(){return At.queue.add(Re(this,this.handleEnd)),At.continueOnNextLoop(),this},endThen:function(n){return this._end_promise.then(n)},filter:function(n){var r=new Ht(null);return this._update.push({async:r,linkf:function(s){n(s)&&r.handleResolve(s)}}),It.immediateLinkUpdate(this,r,function(s){return s}),r},concat:function(n){var r=new Ht(null);return this._update.push({async:r,linkf:Re(r,r.handleResolve)}),It.immediateLinkUpdate(this,r,function(s){return s}),this._end_promise.then(function(s){n.pipe(function(o){return r.handleResolve(o),r}),n._end_promise.then(function(o){r.end()})}),r},merge:function(n){var r=new Ht(null);return this._update.push({async:r,linkf:Re(r,r.handleResolve)}),n._update.push({async:r,linkf:Re(r,r.handleResolve)}),It.immediateLinkUpdate(this,r,function(s){return s}),It.immediateLinkUpdate(n,r,function(s){return s}),r},__class__:Ht});var Ln=p.promhx.PublicStream=function(n){Ht.call(this,n)};x["promhx.PublicStream"]=Ln,Ln.__name__=["promhx","PublicStream"],Ln.publicstream=function(n){var r=new Ln(null);return r.handleResolve(n),r},Ln.__super__=Ht,Ln.prototype=T(Ht.prototype,{resolve:function(n){this.handleResolve(n)},throwError:function(n){this.handleError(n)},update:function(n){this.handleResolve(n)},__class__:Ln});var At=function(){};x["promhx.base.EventLoop"]=At,At.__name__=["promhx","base","EventLoop"],At.enqueue=function(n){At.queue.add(n),At.continueOnNextLoop()},At.set_nextLoop=function(n){if(At.nextLoop!=null)throw new J("nextLoop has already been set");return At.nextLoop=n,At.nextLoop},At.queueEmpty=function(){return At.queue.isEmpty()},At.finish=function(n){n==null&&(n=1e3);for(var r=null;n-- >0&&(r=At.queue.pop())!=null;)r();return At.queue.isEmpty()},At.clear=function(){At.queue=new G},At.f=function(){var n=At.queue.pop();n!=null&&n(),At.queue.isEmpty()||At.continueOnNextLoop()},At.continueOnNextLoop=function(){At.nextLoop!=null?At.nextLoop(At.f):setImmediate(At.f)};var br=x["promhx.error.PromiseError"]={__ename__:["promhx","error","PromiseError"],__constructs__:["AlreadyResolved","DownstreamNotFullfilled"]};br.AlreadyResolved=function(n){var r=["AlreadyResolved",0,n];return r.__enum__=br,r.toString=E,r},br.DownstreamNotFullfilled=function(n){var r=["DownstreamNotFullfilled",1,n];return r.__enum__=br,r.toString=E,r};var ts=function(){};x["verb.Verb"]=ts,ts.__name__=["verb","Verb"],ts.main=function(){b.log("verb 2.1.0")};var $=function(){};x["verb.core.ArrayExtensions"]=$,$.__name__=["verb","core","ArrayExtensions"],$.alloc=function(n,r){if(!(r<0))for(;n.length<r;)n.push(null)},$.reversed=function(n){var r=n.slice();return r.reverse(),r},$.last=function(n){return n[n.length-1]},$.first=function(n){return n[0]},$.spliceAndInsert=function(n,r,s,o){n.splice(r,s),n.splice(r,0,o)},$.left=function(n){if(n.length==0)return[];var r=Math.ceil(n.length/2);return n.slice(0,r)},$.right=function(n){if(n.length==0)return[];var r=Math.ceil(n.length/2);return n.slice(r)},$.rightWithPivot=function(n){if(n.length==0)return[];var r=Math.ceil(n.length/2);return n.slice(r-1)},$.unique=function(n,r){if(n.length==0)return[];for(var s=[n.pop()];n.length>0;){for(var o=n.pop(),c=!0,d=0;d<s.length;){var g=s[d];if(++d,r(o,g)){c=!1;break}}c&&s.push(o)}return s};var Ot=function(){};x["verb.core.Binomial"]=Ot,Ot.__name__=["verb","core","Binomial"],Ot.get=function(n,r){if(r==0)return 1;if(n==0||r>n)return 0;if(r>n-r&&(r=n-r),Ot.memo_exists(n,r))return Ot.get_memo(n,r);for(var s=1,o=n,c=1,d=r+1;c<d;){var g=c++;if(Ot.memo_exists(o,g)){n--,s=Ot.get_memo(o,g);continue}s*=n--,s/=g,Ot.memoize(o,g,s)}return s},Ot.get_no_memo=function(n,r){if(r==0)return 1;if(n==0||r>n)return 0;r>n-r&&(r=n-r);for(var s=1,o=1,c=r+1;o<c;){var d=o++;s*=n--,s/=d}return s},Ot.memo_exists=function(n,r){return Ot.memo.h.hasOwnProperty(n)&&Ot.memo.h[n].h.hasOwnProperty(r)},Ot.get_memo=function(n,r){return Ot.memo.h[n].h[r]},Ot.memoize=function(n,r,s){Ot.memo.h.hasOwnProperty(n)||Ot.memo.set(n,new xt),Ot.memo.h[n].h[r]=s};var De=p.core.BoundingBox=function(n){this.max=null,this.min=null,this.dim=3,this.initialized=!1,n!=null&&this.addRange(n)};x["verb.core.BoundingBox"]=De,De.__name__=["verb","core","BoundingBox"],De.intervalsOverlap=function(n,r,s,o,c){c==null&&(c=-1);var d;c<-.5?d=rt.TOLERANCE:d=c;var g=Math.min(n,r)-d,_=Math.max(n,r)+d,v=Math.min(s,o)-d,w=Math.max(s,o)+d;return g>=v&&g<=w||_>=v&&_<=w||v>=g&&v<=_||w>=g&&w<=_},De.prototype={fromPoint:function(n){return new De([n])},add:function(n){if(!this.initialized)return this.dim=n.length,this.min=n.slice(0),this.max=n.slice(0),this.initialized=!0,this;for(var r=0,s=this.dim;r<s;){var o=r++;n[o]>this.max[o]&&(this.max[o]=n[o]),n[o]<this.min[o]&&(this.min[o]=n[o])}return this},addRange:function(n){for(var r=n.length,s=0;s<r;){var o=s++;this.add(n[o])}return this},contains:function(n,r){return r==null&&(r=-1),this.initialized?this.intersects(new De([n]),r):!1},intersects:function(n,r){if(r==null&&(r=-1),!this.initialized||!n.initialized)return!1;for(var s=this.min,o=this.max,c=n.min,d=n.max,g=0,_=this.dim;g<_;){var v=g++;if(!De.intervalsOverlap(s[v],o[v],c[v],d[v],r))return!1}return!0},clear:function(){return this.initialized=!1,this},getLongestAxis:function(){for(var n=0,r=0,s=0,o=this.dim;s<o;){var c=s++,d=this.getAxisLength(c);d>n&&(n=d,r=c)}return r},getAxisLength:function(n){return n<0||n>this.dim-1?0:Math.abs(this.min[n]-this.max[n])},intersect:function(n,r){if(!this.initialized)return null;var s=this.min,o=this.max,c=n.min,d=n.max;if(!this.intersects(n,r))return null;for(var g=[],_=[],v=0,w=this.dim;v<w;){var P=v++;g.push(Math.min(o[P],d[P])),_.push(Math.max(s[P],c[P]))}return new De([_,g])},__class__:De};var rt=p.core.Constants=function(){};x["verb.core.Constants"]=rt,rt.__name__=["verb","core","Constants"];var Zt=p.core.SerializableBase=function(){};x["verb.core.SerializableBase"]=Zt,Zt.__name__=["verb","core","SerializableBase"],Zt.prototype={serialize:function(){var n=new qt;return n.serialize(this),n.toString()},__class__:Zt};var ri=p.core.Plane=function(n,r){this.origin=n,this.normal=r};x["verb.core.Plane"]=ri,ri.__name__=["verb","core","Plane"],ri.__super__=Zt,ri.prototype=T(Zt.prototype,{__class__:ri});var xr=p.core.Ray=function(n,r){this.origin=n,this.dir=r};x["verb.core.Ray"]=xr,xr.__name__=["verb","core","Ray"],xr.__super__=Zt,xr.prototype=T(Zt.prototype,{__class__:xr});var Vt=p.core.NurbsCurveData=function(n,r,s){this.degree=n,this.controlPoints=s,this.knots=r};x["verb.core.NurbsCurveData"]=Vt,Vt.__name__=["verb","core","NurbsCurveData"],Vt.__super__=Zt,Vt.prototype=T(Zt.prototype,{__class__:Vt});var ne=p.core.NurbsSurfaceData=function(n,r,s,o,c){this.degreeU=n,this.degreeV=r,this.knotsU=s,this.knotsV=o,this.controlPoints=c};x["verb.core.NurbsSurfaceData"]=ne,ne.__name__=["verb","core","NurbsSurfaceData"],ne.__super__=Zt,ne.prototype=T(Zt.prototype,{__class__:ne});var Ye=p.core.MeshData=function(n,r,s,o){this.faces=n,this.points=r,this.normals=s,this.uvs=o};x["verb.core.MeshData"]=Ye,Ye.__name__=["verb","core","MeshData"],Ye.empty=function(){return new Ye([],[],[],[])},Ye.__super__=Zt,Ye.prototype=T(Zt.prototype,{__class__:Ye});var ii=p.core.PolylineData=function(n,r){this.points=n,this.params=r};x["verb.core.PolylineData"]=ii,ii.__name__=["verb","core","PolylineData"],ii.__super__=Zt,ii.prototype=T(Zt.prototype,{__class__:ii});var si=p.core.VolumeData=function(n,r,s,o,c,d,g){this.degreeU=n,this.degreeV=r,this.degreeW=s,this.knotsU=o,this.knotsV=c,this.knotsW=d,this.controlPoints=g};x["verb.core.VolumeData"]=si,si.__name__=["verb","core","VolumeData"],si.__super__=Zt,si.prototype=T(Zt.prototype,{__class__:si});var re=p.core.Pair=function(n,r){this.item0=n,this.item1=r};x["verb.core.Pair"]=re,re.__name__=["verb","core","Pair"],re.prototype={__class__:re};var Ae=p.core.Interval=function(n,r){this.min=n,this.max=r};x["verb.core.Interval"]=Ae,Ae.__name__=["verb","core","Interval"],Ae.prototype={__class__:Ae};var sr=p.core.CurveCurveIntersection=function(n,r,s,o){this.point0=n,this.point1=r,this.u0=s,this.u1=o};x["verb.core.CurveCurveIntersection"]=sr,sr.__name__=["verb","core","CurveCurveIntersection"],sr.prototype={__class__:sr};var ai=p.core.CurveSurfaceIntersection=function(n,r,s,o){this.u=n,this.uv=r,this.curvePoint=s,this.surfacePoint=o};x["verb.core.CurveSurfaceIntersection"]=ai,ai.__name__=["verb","core","CurveSurfaceIntersection"],ai.prototype={__class__:ai};var Nn=p.core.MeshIntersectionPoint=function(n,r,s,o,c){this.visited=!1,this.adj=null,this.opp=null,this.uv0=n,this.uv1=r,this.point=s,this.faceIndex0,this.faceIndex1};x["verb.core.MeshIntersectionPoint"]=Nn,Nn.__name__=["verb","core","MeshIntersectionPoint"],Nn.prototype={__class__:Nn};var oi=p.core.PolylineMeshIntersection=function(n,r,s,o,c){this.point=n,this.u=r,this.uv=s,this.polylineIndex=o,this.faceIndex=c};x["verb.core.PolylineMeshIntersection"]=oi,oi.__name__=["verb","core","PolylineMeshIntersection"],oi.prototype={__class__:oi};var li=p.core.SurfaceSurfaceIntersectionPoint=function(n,r,s,o){this.uv0=n,this.uv1=r,this.point=s,this.dist=o};x["verb.core.SurfaceSurfaceIntersectionPoint"]=li,li.__name__=["verb","core","SurfaceSurfaceIntersectionPoint"],li.prototype={__class__:li};var hi=p.core.TriSegmentIntersection=function(n,r,s,o){this.point=n,this.s=r,this.t=s,this.p=o};x["verb.core.TriSegmentIntersection"]=hi,hi.__name__=["verb","core","TriSegmentIntersection"],hi.prototype={__class__:hi};var wr=p.core.CurveTriPoint=function(n,r,s){this.u=n,this.point=r,this.uv=s};x["verb.core.CurveTriPoint"]=wr,wr.__name__=["verb","core","CurveTriPoint"],wr.prototype={__class__:wr};var Fe=function(n,r,s,o,c){c==null&&(c=!1),o==null&&(o=-1),this.uv=s,this.point=n,this.normal=r,this.id=o,this.degen=c};x["verb.core.SurfacePoint"]=Fe,Fe.__name__=["verb","core","SurfacePoint"],Fe.fromUv=function(n,r){return new Fe(null,null,[n,r])},Fe.prototype={__class__:Fe};var es=p.core.CurvePoint=function(n,r){this.u=n,this.pt=r};x["verb.core.CurvePoint"]=es,es.__name__=["verb","core","CurvePoint"],es.prototype={__class__:es};var ci=p.core.KdTree=function(n,r){this.dim=3,this.points=n,this.distanceFunction=r,this.dim=n[0].point.length,this.root=this.buildTree(n,0,null)};x["verb.core.KdTree"]=ci,ci.__name__=["verb","core","KdTree"],ci.prototype={buildTree:function(n,r,s){var o=r%this.dim,c,d;return n.length==0?null:n.length==1?new Pr(n[0],o,s):(n.sort(function(g,_){var v=g.point[o]-_.point[o];return v==0?0:v>0?1:-1}),c=Math.floor(n.length/2),d=new Pr(n[c],o,s),d.left=this.buildTree(n.slice(0,c),r+1,d),d.right=this.buildTree(n.slice(c+1),r+1,d),d)},nearest:function(n,r,s){var o=this,c=new ui(function(A){return-A.item1}),d,g=null;g=function(A){for(var I,M=A.dimension,k=o.distanceFunction(n,A.kdPoint.point),z,N=[],B=0,D=o.dim;B<D;)B++,N.push(0);z=N;for(var V,U,q=function(K,et){c.push(new re(K,et)),c.size()>r&&c.pop()},tt=0,H=o.dim;tt<H;){var j=tt++;j==A.dimension?z[j]=n[j]:z[j]=A.kdPoint.point[j]}if(V=o.distanceFunction(z,A.kdPoint.point),A.right==null&&A.left==null){(c.size()<r||k<c.peek().item1)&&q(A,k);return}A.right==null?I=A.left:A.left==null?I=A.right:n[M]<A.kdPoint.point[M]?I=A.left:I=A.right,g(I),(c.size()<r||k<c.peek().item1)&&q(A,k),(c.size()<r||Math.abs(V)<c.peek().item1)&&(I==A.left?U=A.right:U=A.left,U!=null&&g(U))},d=g;for(var _=0;_<r;)_++,c.push(new re(null,s));d(this.root);for(var v=[],w=0;w<r;){var P=w++;c.content[P].item0!=null&&v.push(new re(c.content[P].item0.kdPoint,c.content[P].item1))}return v},__class__:ci};var ui=function(n){this.content=[],this.scoreFunction=n};x["verb.core.BinaryHeap"]=ui,ui.__name__=["verb","core","BinaryHeap"],ui.prototype={push:function(n){this.content.push(n),this.bubbleUp(this.content.length-1)},pop:function(){var n=this.content[0],r=this.content.pop();return this.content.length>0&&(this.content[0]=r,this.sinkDown(0)),n},peek:function(){return this.content[0]},remove:function(n){for(var r=this.content.length,s=0;s<r;){var o=s++;if(this.content[o]==n){var c=this.content.pop();o!=r-1&&(this.content[o]=c,this.scoreFunction(c)<this.scoreFunction(n)?this.bubbleUp(o):this.sinkDown(o));return}}throw new J("Node not found.")},size:function(){return this.content.length},bubbleUp:function(n){for(var r=this.content[n];n>0;){var s=Math.floor((n+1)/2)-1,o=this.content[s];if(this.scoreFunction(r)<this.scoreFunction(o))this.content[s]=r,this.content[n]=o,n=s;else break}},sinkDown:function(n){for(var r=this.content.length,s=this.content[n],o=this.scoreFunction(s);;){var c=(n+1)*2,d=c-1,g=-1,_=0;if(d<r){var v=this.content[d];_=this.scoreFunction(v),_<o&&(g=d)}if(c<r){var w=this.content[c],P=this.scoreFunction(w);P<(g==-1?o:_)&&(g=c)}if(g!=-1)this.content[n]=this.content[g],this.content[g]=s,n=g;else break}},__class__:ui};var Ar=p.core.KdPoint=function(n,r){this.point=n,this.obj=r};x["verb.core.KdPoint"]=Ar,Ar.__name__=["verb","core","KdPoint"],Ar.prototype={__class__:Ar};var Pr=p.core.KdNode=function(n,r,s){this.kdPoint=n,this.left=null,this.right=null,this.parent=s,this.dimension=r};x["verb.core.KdNode"]=Pr,Pr.__name__=["verb","core","KdNode"],Pr.prototype={__class__:Pr};var bn=function(){};x["verb.eval.IBoundingBoxTree"]=bn,bn.__name__=["verb","eval","IBoundingBoxTree"],bn.prototype={__class__:bn};var rn=function(n,r){this._boundingBox=null,this._curve=n,r==null&&(r=m.domain(this._curve.knots)/64),this._knotTol=r};x["verb.core.LazyCurveBoundingBoxTree"]=rn,rn.__name__=["verb","core","LazyCurveBoundingBoxTree"],rn.__interfaces__=[bn],rn.prototype={split:function(){var n=$.first(this._curve.knots),r=$.last(this._curve.knots),s=r-n,o=ue.curveSplit(this._curve,(r+n)/2+s*.1*Math.random());return new re(new rn(o[0],this._knotTol),new rn(o[1],this._knotTol))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=new De(C.dehomogenize1d(this._curve.controlPoints))),this._boundingBox},yield:function(){return this._curve},indivisible:function(n){return m.domain(this._curve.knots)<this._knotTol},empty:function(){return!1},__class__:rn};var sn=function(n,r){if(this._boundingBox=null,this._mesh=n,r==null){for(var s=[],o=0,c=n.faces.length;o<c;){var d=o++;s.push(d)}r=s}this._faceIndices=r};x["verb.core.LazyMeshBoundingBoxTree"]=sn,sn.__name__=["verb","core","LazyMeshBoundingBoxTree"],sn.__interfaces__=[bn],sn.prototype={split:function(){var n=ie.sortTrianglesOnLongestAxis(this.boundingBox(),this._mesh,this._faceIndices),r=$.left(n),s=$.right(n);return new re(new sn(this._mesh,r),new sn(this._mesh,s))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=ie.makeMeshAabb(this._mesh,this._faceIndices)),this._boundingBox},yield:function(){return this._faceIndices[0]},indivisible:function(n){return this._faceIndices.length==1},empty:function(){return this._faceIndices.length==0},__class__:sn};var an=function(n,r){this._boundingBox=null,this._polyline=n,r==null&&(r=new Ae(0,n.points.length!=0?n.points.length-1:0)),this._interval=r};x["verb.core.LazyPolylineBoundingBoxTree"]=an,an.__name__=["verb","core","LazyPolylineBoundingBoxTree"],an.__interfaces__=[bn],an.prototype={split:function(){var n=this._interval.min,r=this._interval.max,s=n+Math.ceil((r-n)/2),o=new Ae(n,s),c=new Ae(s,r);return new re(new an(this._polyline,o),new an(this._polyline,c))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=new De(this._polyline.points)),this._boundingBox},yield:function(){return this._interval.min},indivisible:function(n){return this._interval.max-this._interval.min==1},empty:function(){return this._interval.max-this._interval.min==0},__class__:an};var zn=function(n,r,s,o){r==null&&(r=!1),this._boundingBox=null,this._surface=n,this._splitV=r,s==null&&(s=m.domain(n.knotsU)/16),o==null&&(o=m.domain(n.knotsV)/16),this._knotTolU=s,this._knotTolV=o};x["verb.core.LazySurfaceBoundingBoxTree"]=zn,zn.__name__=["verb","core","LazySurfaceBoundingBoxTree"],zn.__interfaces__=[bn],zn.prototype={split:function(){var n,r;this._splitV?(n=$.first(this._surface.knotsV),r=$.last(this._surface.knotsV)):(n=$.first(this._surface.knotsU),r=$.last(this._surface.knotsU));var s=(n+r)/2,o=ue.surfaceSplit(this._surface,s,this._splitV);return new re(new zn(o[0],!this._splitV,this._knotTolU,this._knotTolV),new zn(o[1],!this._splitV,this._knotTolU,this._knotTolV))},boundingBox:function(){if(this._boundingBox==null){this._boundingBox=new De;for(var n=0,r=this._surface.controlPoints;n<r.length;){var s=r[n];++n,this._boundingBox.addRange(C.dehomogenize1d(s))}}return this._boundingBox},yield:function(){return this._surface},indivisible:function(n){return m.domain(this._surface.knotsV)<this._knotTolV&&m.domain(this._surface.knotsU)<this._knotTolU},empty:function(){return!1},__class__:zn};var Lt=p.core.Mat=function(){};x["verb.core.Mat"]=Lt,Lt.__name__=["verb","core","Mat"],Lt.mul=function(n,r){for(var s=[],o=0,c=r.length;o<c;){var d=o++;s.push(m.mul(n,r[d]))}return s},Lt.mult=function(n,r){var s,o,c,d,g,_,v,w;s=n.length,o=r.length,c=r[0].length,d=[];for(var P=s-1,A=0,I=0;P>=0;){for(g=[],_=n[P],I=c-1;I>=0;){for(v=_[o-1]*r[o-1][I],A=o-2;A>=1;)w=A-1,v+=_[A]*r[A][I]+_[w]*r[w][I],A-=2;A==0&&(v+=_[0]*r[0][I]),g[I]=v,I--}d[P]=g,P--}return d},Lt.add=function(n,r){for(var s=[],o=0,c=n.length;o<c;){var d=o++;s.push(m.add(n[d],r[d]))}return s},Lt.div=function(n,r){for(var s=[],o=0,c=n.length;o<c;){var d=o++;s.push(m.div(n[d],r))}return s},Lt.sub=function(n,r){for(var s=[],o=0,c=n.length;o<c;){var d=o++;s.push(m.sub(n[d],r[d]))}return s},Lt.dot=function(n,r){for(var s=[],o=0,c=n.length;o<c;){var d=o++;s.push(m.dot(n[d],r))}return s},Lt.identity=function(n){for(var r=m.zeros2d(n,n),s=0;s<n;){var o=s++;r[o][o]=1}return r},Lt.transpose=function(n){if(n.length==0)return[];for(var r=[],s=0,o=n[0].length;s<o;){var c=s++;r.push(function(d){for(var g,_=[],v=0,w=n.length;v<w;){var P=v++;_.push(n[P][c])}return g=_,g}())}return r},Lt.solve=function(n,r){return Lt.LUsolve(Lt.LU(n),r)},Lt.LUsolve=function(n,r){var s,o,c=n.LU,d=c.length,g=r.slice(),_=n.P,v,w,P;for(s=d-1;s!=-1;)g[s]=r[s],--s;for(s=0;s<d;){for(v=_[s],_[s]!=s&&(P=g[s],g[s]=g[v],g[v]=P),w=c[s],o=0;o<s;)g[s]-=g[o]*w[o],++o;++s}for(s=d-1;s>=0;){for(w=c[s],o=s+1;o<d;)g[s]-=g[o]*w[o],++o;g[s]/=w[s],--s}return g},Lt.LU=function(n){for(var r,s,o,c,d,g,_,v,w,P=[],A=0,I=n.length;A<I;){var M=A++;P.push(n[M].slice())}n=P;var k=n.length,z=k-1,N=[];for(o=0;o<k;){for(_=o,g=n[o],w=Math.abs(g[o]),s=o+1;s<k;)c=Math.abs(n[s][o]),w<c&&(w=c,_=s),++s;for(N[o]=_,_!=o&&(n[o]=n[_],n[_]=g,g=n[o]),d=g[o],r=o+1;r<k;)n[r][o]/=d,++r;for(r=o+1;r<k;){for(v=n[r],s=o+1;s<z;)v[s]-=v[o]*g[s],++s,v[s]-=v[o]*g[s],++s;s==z&&(v[s]-=v[o]*g[s]),++r}++o}return new di(n,N)};var di=function(n,r){this.LU=n,this.P=r};x["verb.core._Mat.LUDecomp"]=di,di.__name__=["verb","core","_Mat","LUDecomp"],di.prototype={__class__:di};var ie=p.core.Mesh=function(){};x["verb.core.Mesh"]=ie,ie.__name__=["verb","core","Mesh"],ie.getTriangleNorm=function(n,r){var s=n[r[0]],o=n[r[1]],c=n[r[2]],d=m.sub(o,s),g=m.sub(c,s),_=m.cross(d,g);return m.mul(1/m.norm(_),_)},ie.makeMeshAabb=function(n,r){for(var s=new De,o=0;o<r.length;){var c=r[o];++o,s.add(n.points[n.faces[c][0]]),s.add(n.points[n.faces[c][1]]),s.add(n.points[n.faces[c][2]])}return s},ie.sortTrianglesOnLongestAxis=function(n,r,s){for(var o=n.getLongestAxis(),c=[],d=0;d<s.length;){var g=s[d];++d;var _=ie.getMinCoordOnAxis(r.points,r.faces[g],o);c.push(new re(_,g))}c.sort(function(I,M){var k=I.item0,z=M.item0;return k==z?0:k>z?1:-1});for(var v=[],w=0,P=c.length;w<P;){var A=w++;v.push(c[A].item1)}return v},ie.getMinCoordOnAxis=function(n,r,s){for(var o=1/0,c=0;c<3;){var d=c++,g=n[r[d]][s];g<o&&(o=g)}return o},ie.getTriangleCentroid=function(n,r){for(var s=[0,0,0],o=0;o<3;)for(var c=o++,d=0;d<3;){var g=d++;s[g]+=n[r[c]][g]}for(var _=0;_<3;){var v=_++;s[v]/=3}return s},ie.triangleUVFromPoint=function(n,r,s){var o=n.faces[r],c=n.points[o[0]],d=n.points[o[1]],g=n.points[o[2]],_=n.uvs[o[0]],v=n.uvs[o[1]],w=n.uvs[o[2]],P=m.sub(c,s),A=m.sub(d,s),I=m.sub(g,s),M=m.norm(m.cross(m.sub(c,d),m.sub(c,g))),k=m.norm(m.cross(A,I))/M,z=m.norm(m.cross(I,P))/M,N=m.norm(m.cross(P,A))/M;return m.add(m.mul(k,_),m.add(m.mul(z,v),m.mul(N,w)))};var Dn=function(n,r){if(this._empty=!1,this._face=-1,r==null){for(var s=[],o=0,c=n.faces.length;o<c;){var d=o++;s.push(d)}r=s}if(this._boundingBox=ie.makeMeshAabb(n,r),r.length<1){this._empty=!0;return}else if(r.length<2){this._face=r[0];return}var g=ie.sortTrianglesOnLongestAxis(this._boundingBox,n,r),_=$.left(g),v=$.right(g);this._children=new re(new Dn(n,_),new Dn(n,v))};x["verb.core.MeshBoundingBoxTree"]=Dn,Dn.__name__=["verb","core","MeshBoundingBoxTree"],Dn.__interfaces__=[bn],Dn.prototype={split:function(){return this._children},boundingBox:function(){return this._boundingBox},yield:function(){return this._face},indivisible:function(n){return this._children==null},empty:function(){return this._empty},__class__:Dn};var Ke=p.core.Minimizer=function(){};x["verb.core.Minimizer"]=Ke,Ke.__name__=["verb","core","Minimizer"],Ke.uncmin=function(n,r,s,o,c){s==null&&(s=1e-8),o==null&&(o=function(tt){return Ke.numericalGradient(n,tt)}),c==null&&(c=1e3),r=r.slice(0);var d=r.length,g=n(r),_=g,v;if(isNaN(g))throw new J("uncmin: f(x0) is a NaN!");s=Math.max(s,rt.EPSILON);var w,P,A,I=Lt.identity(d),M=0,k=[],z,N,B,D,V,U,q="";for(P=o(r);M<c;){if(!m.all(m.finite(P))){q="Gradient has Infinity or NaN";break}if(w=m.neg(Lt.dot(I,P)),!m.all(m.finite(w))){q="Search direction has Infinity or NaN";break}if(U=m.norm(w),U<s){q="Newton step smaller than tol";break}for(V=1,v=m.dot(P,w),z=r;M<c&&!(V*U<s);){if(k=m.mul(V,w),z=m.add(r,k),_=n(z),_-g>=.1*V*v||isNaN(_)){V*=.5,++M;continue}break}if(V*U<s){q="Line search step size smaller than tol";break}if(M==c){q="maxit reached during line search";break}A=o(z),N=m.sub(A,P),D=m.dot(N,k),B=Lt.dot(I,N),I=Lt.sub(Lt.add(I,Lt.mul((D+m.dot(N,B))/(D*D),Ke.tensor(k,k))),Lt.div(Lt.add(Ke.tensor(B,k),Ke.tensor(k,B)),D)),r=z,g=_,P=A,++M}return new mi(r,g,P,I,M,q)},Ke.numericalGradient=function(n,r){var s=r.length,o=n(r);if(o==NaN)throw new J("gradient: f(x) is a NaN!");for(var c=r.slice(0),d,g,_=[],v,w=.001,P,A,I,M=0,k,z,N,B=0;B<s;)for(var D=B++,V=Math.max(1e-6*o,1e-8);;){if(++M,M>20)throw new J("Numerical gradient fails");if(c[D]=r[D]+V,d=n(c),c[D]=r[D]-V,g=n(c),c[D]=r[D],isNaN(d)||isNaN(g)){V/=16;continue}if(_[D]=(d-g)/(2*V),P=r[D]-V,A=r[D],I=r[D]+V,k=(d-o)/V,z=(o-g)/V,N=m.max([Math.abs(_[D]),Math.abs(o),Math.abs(d),Math.abs(g),Math.abs(P),Math.abs(A),Math.abs(I),1e-8]),v=Math.min(m.max([Math.abs(k-_[D]),Math.abs(z-_[D]),Math.abs(k-z)])/N,V/N),v>w)V/=16;else break}return _},Ke.tensor=function(n,r){for(var s=n.length,o=r.length,c=[],d,g,_=s-1;_>=0;){d=[],g=n[_];for(var v=o-1;v>=3;)d[v]=g*r[v],--v,d[v]=g*r[v],--v,d[v]=g*r[v],--v,d[v]=g*r[v],--v;for(;v>=0;)d[v]=g*r[v],--v;c[_]=d,_--}return c};var mi=function(n,r,s,o,c,d){this.solution=n,this.value=r,this.gradient=s,this.invHessian=o,this.iterations=c,this.message=d};x["verb.core.MinimizationResult"]=mi,mi.__name__=["verb","core","MinimizationResult"],mi.prototype={__class__:mi};var Sr=function(){};x["verb.core.ISerializable"]=Sr,Sr.__name__=["verb","core","ISerializable"],Sr.prototype={__class__:Sr};var $s=p.core.Deserializer=function(){};x["verb.core.Deserializer"]=$s,$s.__name__=["verb","core","Deserializer"],$s.deserialize=function(n){var r=new Gt(n),s=r.unserialize();return s};var Oe=p.core.Trig=function(){};x["verb.core.Trig"]=Oe,Oe.__name__=["verb","core","Trig"],Oe.isPointInPlane=function(n,r,s){return Math.abs(m.dot(m.sub(n,r.origin),r.normal))<s},Oe.distToSegment=function(n,r,s){var o=Oe.segmentClosestPoint(r,n,s,0,1);return m.dist(r,o.pt)},Oe.rayClosestPoint=function(n,r,s){var o=m.sub(n,r),c=m.dot(o,s),d=m.add(r,m.mul(c,s));return d},Oe.distToRay=function(n,r,s){var o=Oe.rayClosestPoint(n,r,s),c=m.sub(o,n);return m.norm(c)},Oe.threePointsAreFlat=function(n,r,s,o){var c=m.sub(r,n),d=m.sub(s,n),g=m.cross(c,d),_=m.dot(g,g);return _<o},Oe.segmentClosestPoint=function(n,r,s,o,c){var d=m.sub(s,r),g=m.norm(d);if(g<rt.EPSILON)return{u:o,pt:r};var _=r,v=m.mul(1/g,d),w=m.sub(n,_),P=m.dot(w,v);return P<0?{u:o,pt:r}:P>g?{u:c,pt:s}:{u:o+(c-o)*P/g,pt:m.add(_,m.mul(P,v))}};var m=p.core.Vec=function(){};x["verb.core.Vec"]=m,m.__name__=["verb","core","Vec"],m.angleBetween=function(n,r){return Math.acos(m.dot(n,r)/(m.norm(n)*m.norm(r)))},m.positiveAngleBetween=function(n,r,s){var o=m.cross(n,r),c=m.norm(n),d=m.norm(r),g=c*d,_=m.dot(n,r),v=m.norm(o)/g,w=_/g,P=Math.atan2(v,w),A=m.dot(s,o);return Math.abs(A)<rt.EPSILON||A>0?P:-P},m.signedAngleBetween=function(n,r,s){var o=m.cross(n,r),c=m.norm(n),d=m.norm(r),g=c*d,_=m.dot(n,r),v=m.norm(o)/g,w=_/g,P=Math.atan2(v,w),A=m.dot(s,o);return A>0?P:2*Math.PI-P},m.angleBetweenNormalized2d=function(n,r){var s=n[0]*r[1]-n[1]*r[0];return Math.atan2(s,m.dot(n,r))},m.domain=function(n){return $.last(n)-$.first(n)},m.range=function(n){for(var r=[],s=0,o=0;o<n;)o++,r.push(s),s+=1;return r},m.span=function(n,r,s){if(s==null)return[];if(s<rt.EPSILON)return[];if(n>r&&s>0)return[];if(r>n&&s<0)return[];for(var o=[],c=n;c<=r;)o.push(c),c+=s;return o},m.neg=function(n){return n.map(function(r){return-r})},m.min=function(n){return R.fold(n,function(r,s){return Math.min(r,s)},1/0)},m.max=function(n){return R.fold(n,function(r,s){return Math.max(r,s)},-1/0)},m.all=function(n){return R.fold(n,function(r,s){return s&&r},!0)},m.finite=function(n){return n.map(function(r){return isFinite(r)})},m.onRay=function(n,r,s){return m.add(n,m.mul(s,r))},m.lerp=function(n,r,s){return m.add(m.mul(n,r),m.mul(1-n,s))},m.normalized=function(n){return m.div(n,m.norm(n))},m.cross=function(n,r){return[n[1]*r[2]-n[2]*r[1],n[2]*r[0]-n[0]*r[2],n[0]*r[1]-n[1]*r[0]]},m.dist=function(n,r){return m.norm(m.sub(n,r))},m.distSquared=function(n,r){return m.normSquared(m.sub(n,r))},m.sum=function(n){return R.fold(n,function(r,s){return s+r},0)},m.addAll=function(n){var r=Xe(n)();if(!r.hasNext())return null;var s=r.next().length;return R.fold(n,function(o,c){return m.add(c,o)},m.rep(s,0))},m.addAllMutate=function(n){for(var r=n[0],s=1,o=n.length;s<o;){var c=s++;m.addMutate(r,n[c])}},m.addMulMutate=function(n,r,s){for(var o=0,c=n.length;o<c;){var d=o++;n[d]=n[d]+r*s[d]}},m.subMulMutate=function(n,r,s){for(var o=0,c=n.length;o<c;){var d=o++;n[d]=n[d]-r*s[d]}},m.addMutate=function(n,r){for(var s=0,o=n.length;s<o;){var c=s++;n[c]=n[c]+r[c]}},m.subMutate=function(n,r){for(var s=0,o=n.length;s<o;){var c=s++;n[c]=n[c]-r[c]}},m.mulMutate=function(n,r){for(var s=0,o=r.length;s<o;){var c=s++;r[c]=r[c]*n}},m.norm=function(n){var r=m.normSquared(n);return r!=0?Math.sqrt(r):r},m.normSquared=function(n){return R.fold(n,function(r,s){return s+r*r},0)},m.rep=function(n,r){for(var s=[],o=0;o<n;)o++,s.push(r);return s},m.zeros1d=function(n){for(var r=[],s=0;s<n;)s++,r.push(0);return r},m.zeros2d=function(n,r){for(var s=[],o=0;o<n;)o++,s.push(m.zeros1d(r));return s},m.zeros3d=function(n,r,s){for(var o=[],c=0;c<n;)c++,o.push(m.zeros2d(r,s));return o},m.dot=function(n,r){for(var s=0,o=0,c=n.length;o<c;){var d=o++;s+=n[d]*r[d]}return s},m.add=function(n,r){for(var s=[],o=0,c=n.length;o<c;){var d=o++;s.push(n[d]+r[d])}return s},m.mul=function(n,r){for(var s=[],o=0,c=r.length;o<c;){var d=o++;s.push(n*r[d])}return s},m.div=function(n,r){for(var s=[],o=0,c=n.length;o<c;){var d=o++;s.push(n[d]/r)}return s},m.sub=function(n,r){for(var s=[],o=0,c=n.length;o<c;){var d=o++;s.push(n[d]-r[d])}return s},m.isZero=function(n){for(var r=0,s=n.length;r<s;){var o=r++;if(Math.abs(n[o])>rt.TOLERANCE)return!1}return!0},m.sortedSetUnion=function(n,r){for(var s=[],o=0,c=0;o<n.length||c<r.length;){if(o>=n.length){s.push(r[c]),c++;continue}else if(c>=r.length){s.push(n[o]),o++;continue}var d=n[o]-r[c];if(Math.abs(d)<rt.EPSILON){s.push(n[o]),o++,c++;continue}if(d>0){s.push(r[c]),c++;continue}s.push(n[o]),o++}return s},m.sortedSetSub=function(n,r){for(var s=[],o=0,c=0;o<n.length;){if(c>=r.length){s.push(n[o]),o++;continue}if(Math.abs(n[o]-r[c])<rt.EPSILON){o++,c++;continue}s.push(n[o]),o++}return s};var bt=p.eval.Analyze=function(){};x["verb.eval.Analyze"]=bt,bt.__name__=["verb","eval","Analyze"],bt.knotMultiplicities=function(n){for(var r=[new Ir(n[0],0)],s=r[0],o=0;o<n.length;){var c=n[o];++o,Math.abs(c-s.knot)>rt.EPSILON&&(s=new Ir(c,0),r.push(s)),s.inc()}return r},bt.isRationalSurfaceClosed=function(n,r){r==null&&(r=!0);var s;r?s=n.controlPoints:s=Lt.transpose(n.controlPoints);for(var o=0,c=s[0].length;o<c;){var d=o++,g=m.dist($.first(s)[d],$.last(s)[d])<rt.EPSILON;if(!g)return!1}return!0},bt.rationalSurfaceClosestPoint=function(n,r){var s=bt.rationalSurfaceClosestParam(n,r);return C.rationalSurfacePoint(n,s[0],s[1])},bt.rationalSurfaceClosestParam=function(n,r){for(var s=5,o=0,c,d=1e-4,g=5e-4,_,v=n.knotsU[0],w=$.last(n.knotsU),P=n.knotsV[0],A=$.last(n.knotsV),I=bt.isRationalSurfaceClosed(n),M=bt.isRationalSurfaceClosed(n,!1),k,z=Dt.rationalSurfaceAdaptive(n,new On),N=1/0,B=0,D=z.points.length;B<D;){var V=B++,U=z.points[V],q=m.normSquared(m.sub(r,U));q<N&&(N=q,k=z.uvs[V])}for(var tt=function(Ut){return C.rationalSurfaceDerivatives(n,Ut[0],Ut[1],2)},H=function(Ut,Yt,Ft){var $t=Yt[1][0],Pe=Yt[0][1],Ue=Yt[2][0],xe=Yt[0][2],_e=Yt[1][1],Se=Yt[1][1],Be=m.dot($t,Ft),$e=m.dot(Pe,Ft),on=[-Be,-$e],Ze=m.dot($t,$t)+m.dot(Ue,Ft),Qe=m.dot($t,Pe)+m.dot(_e,Ft),Je=m.dot($t,Pe)+m.dot(Se,Ft),wn=m.dot(Pe,Pe)+m.dot(xe,Ft),Tr=[[Ze,Qe],[Je,wn]],or=Lt.solve(Tr,on);return m.add(or,Ut)};o<s;){c=tt(k),_=m.sub(c[0][0],r);var j=m.norm(_),K=m.dot(c[1][0],_),et=m.norm(c[1][0])*j,nt=m.dot(c[0][1],_),st=m.norm(c[0][1])*j,lt=K/et,at=nt/st,ct=j<d,it=lt<g,dt=at<g;if(ct&&it&&dt)return k;var Y=H(k,c,_);Y[0]<v?I?Y=[w-(Y[0]-v),Y[1]]:Y=[v+rt.EPSILON,Y[1]]:Y[0]>w&&(I?Y=[v+(Y[0]-w),Y[1]]:Y=[w-rt.EPSILON,Y[1]]),Y[1]<P?M?Y=[Y[0],A-(Y[1]-P)]:Y=[Y[0],P+rt.EPSILON]:Y[1]>A&&(M?Y=[Y[0],P+(Y[0]-A)]:Y=[Y[0],A-rt.EPSILON]);var ft=m.norm(m.mul(Y[0]-k[0],c[1][0])),Pt=m.norm(m.mul(Y[1]-k[1],c[0][1]));if(ft+Pt<d)return k;k=Y,o++}return k},bt.rationalCurveClosestPoint=function(n,r){return C.rationalCurvePoint(n,bt.rationalCurveClosestParam(n,r))},bt.rationalCurveClosestParam=function(n,r){for(var s=1/0,o=0,c=Dt.rationalCurveRegularSample(n,n.controlPoints.length*n.degree,!0),d=0,g=c.length-1;d<g;){var _=d++,v=c[_][0],w=c[_+1][0],P=c[_].slice(1),A=c[_+1].slice(1),I=Oe.segmentClosestPoint(r,P,A,v,w),M=m.norm(m.sub(r,I.pt));M<s&&(s=M,o=I.u)}for(var k=5,z=0,N,B=1e-4,D=5e-4,V,U=n.knots[0],q=$.last(n.knots),tt=m.normSquared(m.sub(n.controlPoints[0],$.last(n.controlPoints)))<rt.EPSILON,H=o,j=function(Y){return C.rationalCurveDerivatives(n,Y,2)},K=function(Y,ft,Pt){var Ut=m.dot(ft[1],Pt),Yt=m.dot(ft[2],Pt),Ft=m.dot(ft[1],ft[1]),$t=Yt+Ft;return Y-Ut/$t};z<k;){N=j(H),V=m.sub(N[0],r);var et=m.norm(V),nt=m.dot(N[1],V),st=m.norm(N[1])*et,lt=nt/st,at=et<B,ct=Math.abs(lt)<D;if(at&&ct)return H;var it=K(H,N,V);it<U?tt?it=q-(it-U):it=U:it>q&&(tt?it=U+(it-q):it=q);var dt=m.norm(m.mul(it-H,N[1]));if(dt<B)return H;H=it,z++}return H},bt.rationalCurveParamAtArcLength=function(n,r,s,o,c){if(s==null&&(s=.001),r<rt.EPSILON)return n.knots[0];var d;o!=null?d=o:d=yt.decomposeCurveIntoBeziers(n);var g=0;d[g];var _=-rt.EPSILON,v;for(c!=null?v=c:v=[];_<r&&g<d.length;){if(g<v.length?v[g]=v[g]:v[g]=bt.rationalBezierCurveArcLength(n),_+=v[g],r<_+rt.EPSILON)return bt.rationalBezierCurveParamAtArcLength(n,r,s,v[g]);g++}return-1},bt.rationalBezierCurveParamAtArcLength=function(n,r,s,o){if(r<0)return n.knots[0];var c;if(o!=null?c=o:c=bt.rationalBezierCurveArcLength(n),r>c)return $.last(n.knots);var d=n.knots[0],g=0,_=$.last(n.knots),v=c,w=0,P=0,A;for(s!=null?A=s:A=rt.TOLERANCE*2;v-g>A;)w=(d+_)/2,P=bt.rationalBezierCurveArcLength(n,w),P>r?(_=w,v=P):(d=w,g=P);return(d+_)/2},bt.rationalCurveArcLength=function(n,r,s){s==null&&(s=16),r==null?r=$.last(n.knots):r=r;for(var o=yt.decomposeCurveIntoBeziers(n),c=0,d=o[0],g=0;c<o.length&&d.knots[0]+rt.EPSILON<r;){var _=Math.min($.last(d.knots),r);g+=bt.rationalBezierCurveArcLength(d,_,s),d=o[++c]}return g},bt.rationalBezierCurveArcLength=function(n,r,s){s==null&&(s=16);var o;r==null?o=$.last(n.knots):o=r;for(var c=(o-n.knots[0])/2,d=0,g=n.degree+s,_,v,w=0;w<g;){var P=w++;_=c*bt.Tvalues[g][P]+c+n.knots[0],v=C.rationalCurveDerivatives(n,_,1),d+=bt.Cvalues[g][P]*m.norm(v[1])}return c*d};var Ir=p.eval.KnotMultiplicity=function(n,r){this.knot=n,this.mult=r};x["verb.eval.KnotMultiplicity"]=Ir,Ir.__name__=["verb","eval","KnotMultiplicity"],Ir.prototype={inc:function(){this.mult++},__class__:Ir};var Ve=p.eval.Check=function(){};x["verb.eval.Check"]=Ve,Ve.__name__=["verb","eval","Check"],Ve.isValidKnotVector=function(n,r){if(n.length==0||n.length<(r+1)*2)return!1;for(var s=$.first(n),o=0,c=r+1;o<c;){var d=o++;if(Math.abs(n[d]-s)>rt.EPSILON)return!1}s=$.last(n);for(var g=n.length-r-1,_=n.length;g<_;){var v=g++;if(Math.abs(n[v]-s)>rt.EPSILON)return!1}return Ve.isNonDecreasing(n)},Ve.isNonDecreasing=function(n){for(var r=$.first(n),s=0,o=n.length;s<o;){var c=s++;if(n[c]<r-rt.EPSILON)return!1;r=n[c]}return!0},Ve.isValidNurbsCurveData=function(n){if(n.controlPoints==null)throw new J("Control points array cannot be null!");if(n.degree==null)throw new J("Degree cannot be null!");if(n.degree<1)throw new J("Degree must be greater than 1!");if(n.knots==null)throw new J("Knots cannot be null!");if(n.knots.length!=n.controlPoints.length+n.degree+1)throw new J("controlPoints.length + degree + 1 must equal knots.length!");if(!Ve.isValidKnotVector(n.knots,n.degree))throw new J("Invalid knot vector format! Should begin with degree + 1 repeats and end with degree + 1 repeats!");return n},Ve.isValidNurbsSurfaceData=function(n){if(n.controlPoints==null)throw new J("Control points array cannot be null!");if(n.degreeU==null)throw new J("DegreeU cannot be null!");if(n.degreeV==null)throw new J("DegreeV cannot be null!");if(n.degreeU<1)throw new J("DegreeU must be greater than 1!");if(n.degreeV<1)throw new J("DegreeV must be greater than 1!");if(n.knotsU==null)throw new J("KnotsU cannot be null!");if(n.knotsV==null)throw new J("KnotsV cannot be null!");if(n.knotsU.length!=n.controlPoints.length+n.degreeU+1)throw new J("controlPointsU.length + degreeU + 1 must equal knotsU.length!");if(n.knotsV.length!=n.controlPoints[0].length+n.degreeV+1)throw new J("controlPointsV.length + degreeV + 1 must equal knotsV.length!");if(!Ve.isValidKnotVector(n.knotsU,n.degreeU)||!Ve.isValidKnotVector(n.knotsV,n.degreeV))throw new J("Invalid knot vector format! Should begin with degree + 1 repeats and end with degree + 1 repeats!");return n};var ue=p.eval.Divide=function(){};x["verb.eval.Divide"]=ue,ue.__name__=["verb","eval","Divide"],ue.surfaceSplit=function(n,r,s){s==null&&(s=!1);var o,c,d;s?(d=n.controlPoints,o=n.knotsV,c=n.degreeV):(d=Lt.transpose(n.controlPoints),o=n.knotsU,c=n.degreeU);for(var g,_=[],v=0,w=c+1;v<w;)v++,_.push(r);g=_;for(var P=[],A=[],I=C.knotSpan(c,r,o),M=null,k=0;k<d.length;){var z=d[k];++k,M=yt.curveKnotRefine(new Vt(c,o,z),g),P.push(M.controlPoints.slice(0,I+1)),A.push(M.controlPoints.slice(I+1))}var N=M.knots.slice(0,I+c+2),B=M.knots.slice(I+1);return s?[new ne(n.degreeU,c,n.knotsU.slice(),N,P),new ne(n.degreeU,c,n.knotsU.slice(),B,A)]:(P=Lt.transpose(P),A=Lt.transpose(A),[new ne(c,n.degreeV,N,n.knotsV.slice(),P),new ne(c,n.degreeV,B,n.knotsV.slice(),A)])},ue.curveSplit=function(n,r){var s=n.degree;n.controlPoints;for(var o=n.knots,c,d=[],g=0,_=s+1;g<_;)g++,d.push(r);c=d;var v=yt.curveKnotRefine(n,c),w=C.knotSpan(s,r,o),P=v.knots.slice(0,w+s+2),A=v.knots.slice(w+1),I=v.controlPoints.slice(0,w+1),M=v.controlPoints.slice(w+1);return[new Vt(s,P,I),new Vt(s,A,M)]},ue.rationalCurveByEqualArcLength=function(n,r){var s=bt.rationalCurveArcLength(n),o=s/r;return ue.rationalCurveByArcLength(n,o)},ue.rationalCurveByArcLength=function(n,r){var s=yt.decomposeCurveIntoBeziers(n),o=s.map(function(I){return bt.rationalBezierCurveArcLength(I)}),c=m.sum(o),d=[new Er(n.knots[0],0)];if(r>c)return d;for(var g=r,_=0,v=g,w=0,P=0,A;_<s.length;){for(w+=o[_];v<w+rt.EPSILON;)A=bt.rationalBezierCurveParamAtArcLength(s[_],v-P,rt.TOLERANCE,o[_]),d.push(new Er(A,v)),v+=g;P+=o[_],_++}return d};var Er=p.eval.CurveLengthSample=function(n,r){this.u=n,this.len=r};x["verb.eval.CurveLengthSample"]=Er,Er.__name__=["verb","eval","CurveLengthSample"],Er.prototype={__class__:Er};var C=p.eval.Eval=function(){};x["verb.eval.Eval"]=C,C.__name__=["verb","eval","Eval"],C.rationalCurveTangent=function(n,r){var s=C.rationalCurveDerivatives(n,r,1);return s[1]},C.rationalSurfaceNormal=function(n,r,s){var o=C.rationalSurfaceDerivatives(n,r,s,1);return m.cross(o[1][0],o[0][1])},C.rationalSurfaceDerivatives=function(n,r,s,o){o==null&&(o=1);for(var c=C.surfaceDerivatives(n,r,s,o),d=C.rational2d(c),g=C.weight2d(c),_=[],v=d[0][0].length,w=0,P=o+1;w<P;){var A=w++;_.push([]);for(var I=0,M=o-A+1;I<M;){for(var k=I++,z=d[A][k],N=1,B=k+1;N<B;){var D=N++;m.subMulMutate(z,Ot.get(k,D)*g[0][D],_[A][k-D])}for(var V=1,U=A+1;V<U;){var q=V++;m.subMulMutate(z,Ot.get(A,q)*g[q][0],_[A-q][k]);for(var tt=m.zeros1d(v),H=1,j=k+1;H<j;){var K=H++;m.addMulMutate(tt,Ot.get(k,K)*g[q][K],_[A-q][k-K])}m.subMulMutate(z,Ot.get(A,q),tt)}m.mulMutate(1/g[0][0],z),_[A].push(z)}}return _},C.rationalSurfacePoint=function(n,r,s){return C.dehomogenize(C.surfacePoint(n,r,s))},C.rationalCurveDerivatives=function(n,r,s){s==null&&(s=1);for(var o=C.curveDerivatives(n,r,s),c=C.rational1d(o),d=C.weight1d(o),g=[],_=0,v=s+1;_<v;){for(var w=_++,P=c[w],A=1,I=w+1;A<I;){var M=A++;m.subMulMutate(P,Ot.get(w,M)*d[M],g[w-M])}m.mulMutate(1/d[0],P),g.push(P)}return g},C.rationalCurvePoint=function(n,r){return C.dehomogenize(C.curvePoint(n,r))},C.surfaceDerivatives=function(n,r,s,o){var c=n.knotsU.length-n.degreeU-2,d=n.knotsV.length-n.degreeV-2;return C.surfaceDerivativesGivenNM(c,d,n,r,s,o)},C.surfaceDerivativesGivenNM=function(n,r,s,o,c,d){var g=s.degreeU,_=s.degreeV,v=s.controlPoints,w=s.knotsU,P=s.knotsV;if(!C.areValidRelations(g,v.length,w.length)||!C.areValidRelations(_,v[0].length,P.length))throw new J("Invalid relations between control points, knot vector, and n");var A=v[0][0].length,I;d<g?I=d:I=g;var M;d<_?M=d:M=_;for(var k=m.zeros3d(d+1,d+1,A),z=C.knotSpanGivenN(n,g,o,w),N=C.knotSpanGivenN(r,_,c,P),B=C.derivativeBasisFunctionsGivenNI(z,o,g,n,w),D=C.derivativeBasisFunctionsGivenNI(N,c,_,r,P),V=m.zeros2d(_+1,A),U=0,q=0,tt=I+1;q<tt;){for(var H=q++,j=0,K=_+1;j<K;){var et=j++;V[et]=m.zeros1d(A);for(var nt=0,st=g+1;nt<st;){var lt=nt++;m.addMulMutate(V[et],B[H][lt],v[z-g+lt][N-_+et])}}var at=d-H;at<M?U=at:U=M;for(var ct=0,it=U+1;ct<it;){var dt=ct++;k[H][dt]=m.zeros1d(A);for(var Y=0,ft=_+1;Y<ft;){var Pt=Y++;m.addMulMutate(k[H][dt],D[dt][Pt],V[Pt])}}}return k},C.surfacePoint=function(n,r,s){var o=n.knotsU.length-n.degreeU-2,c=n.knotsV.length-n.degreeV-2;return C.surfacePointGivenNM(o,c,n,r,s)},C.surfacePointGivenNM=function(n,r,s,o,c){var d=s.degreeU,g=s.degreeV,_=s.controlPoints,v=s.knotsU,w=s.knotsV;if(!C.areValidRelations(d,_.length,v.length)||!C.areValidRelations(g,_[0].length,w.length))throw new J("Invalid relations between control points, knot vector, and n");for(var P=_[0][0].length,A=C.knotSpanGivenN(n,d,o,v),I=C.knotSpanGivenN(r,g,c,w),M=C.basisFunctionsGivenKnotSpanIndex(A,o,d,v),k=C.basisFunctionsGivenKnotSpanIndex(I,c,g,w),z=A-d,N=I,B=m.zeros1d(P),D=m.zeros1d(P),V=0,U=g+1;V<U;){var q=V++;D=m.zeros1d(P),N=I-g+q;for(var tt=0,H=d+1;tt<H;){var j=tt++;m.addMulMutate(D,M[j],_[z+j][N])}m.addMulMutate(B,k[q],D)}return B},C.curveRegularSamplePoints=function(n,r){for(var s=C.curveDerivatives(n,n.knots[0],n.degree),o=1/r,c=o*o,d=s[0],g=m.mul(o,s[1]),_=m.mul(c*.5,s[2]),v=m.mul(c*o*.5,s[3]),w=m.add(_,_),P=m.add(v,v),A=m.mul(.3333333333333333,v),I=[],M=0,k=r+1;M<k;)M++,I.push(C.dehomogenize(d)),m.addAllMutate([d,g,_,A]),m.addAllMutate([g,w,v]),m.addAllMutate([w,P]),m.addAllMutate([_,v]);return I},C.curveRegularSamplePoints2=function(n,r){for(var s=C.curveDerivatives(n,n.knots[0],n.degree),o=1/r,c=o*o,d=s[0],g=m.mul(o,s[1]),_=m.mul(c*.5,s[2]),v=m.mul(c*o*.5,s[3]),w=m.add(_,_),P=m.add(v,v),A=m.mul(.3333333333333333,v),I=[],M=0,k=r+1;M<k;)M++,I.push(C.dehomogenize(d)),m.addAllMutate([d,g,_,A]),m.addAllMutate([g,w,v]),m.addAllMutate([w,P]),m.addAllMutate([_,v]);return I},C.rationalSurfaceRegularSampleDerivatives=function(n,r,s,o){for(var c=C.surfaceRegularSampleDerivatives(n,r,s,o),d=[],g=r+1,_=s+1,v=o+1,w=0;w<g;){var P=w++,A=[];d.push(A);for(var I=0;I<_;){for(var M=I++,k=c[P][M],z=C.rational2d(k),N=C.weight2d(k),B=[],D=z[0][0].length,V=0;V<v;){var U=V++;B.push([]);for(var q=0,tt=v-U;q<tt;){for(var H=q++,j=z[U][H],K=1,et=H+1;K<et;){var nt=K++;m.subMulMutate(j,Ot.get(H,nt)*N[0][nt],B[U][H-nt])}for(var st=1,lt=U+1;st<lt;){var at=st++;m.subMulMutate(j,Ot.get(U,at)*N[at][0],B[U-at][H]);for(var ct=m.zeros1d(D),it=1,dt=H+1;it<dt;){var Y=it++;m.addMulMutate(ct,Ot.get(H,Y)*N[at][Y],B[U-at][H-Y])}m.subMulMutate(j,Ot.get(U,at),ct)}m.mulMutate(1/N[0][0],j),B[U].push(j)}}A.push(B)}}return d},C.surfaceRegularSampleDerivatives=function(n,r,s,o){var c=n.degreeU,d=n.degreeV,g=n.controlPoints,_=n.knotsU,v=n.knotsV,w=g[0][0].length;($.last(_)-_[0])/r,($.last(v)-v[0])/s;for(var P=C.regularlySpacedDerivativeBasisFunctions(c,_,r),A=P.item0,I=P.item1,M=C.regularlySpacedDerivativeBasisFunctions(d,v,s),k=M.item0,z=M.item1,N=[],B=r+1,D=s+1,V=0;V<B;){var U=V++,q=[];N.push(q);for(var tt=0;tt<D;){var H=tt++;q.push(C.surfaceDerivativesGivenBasesKnotSpans(c,d,g,A[U],k[H],I[U],z[H],w,o))}}return N},C.rationalSurfaceRegularSamplePoints=function(n,r,s){return C.dehomogenize2d(C.surfaceRegularSamplePoints(n,r,s))},C.surfaceRegularSamplePoints=function(n,r,s){var o=n.degreeU,c=n.degreeV,d=n.controlPoints,g=n.knotsU,_=n.knotsV,v=d[0][0].length;($.last(g)-g[0])/r,($.last(_)-_[0])/s;for(var w=C.regularlySpacedBasisFunctions(o,g,r),P=w.item0,A=w.item1,I=C.regularlySpacedBasisFunctions(c,_,s),M=I.item0,k=I.item1,z=[],N=r+1,B=s+1,D=0;D<N;){var V=D++,U=[];z.push(U);for(var q=0;q<B;){var tt=q++;U.push(C.surfacePointGivenBasesKnotSpans(o,c,d,P[V],M[tt],A[V],k[tt],v))}}return z},C.regularlySpacedBasisFunctions=function(n,r,s){for(var o=r.length-n-2,c=($.last(r)-r[0])/s,d=[],g=[],_=r[0],v=C.knotSpanGivenN(o,n,_,r),w=s+1,P=0;P<w;){for(P++;_>=r[v+1];)v++;g.push(v),d.push(C.basisFunctionsGivenKnotSpanIndex(v,_,n,r)),_+=c}return new re(g,d)},C.regularlySpacedDerivativeBasisFunctions=function(n,r,s){for(var o=r.length-n-2,c=($.last(r)-r[0])/s,d=[],g=[],_=r[0],v=C.knotSpanGivenN(o,n,_,r),w=s+1,P=0;P<w;){for(P++;_>=r[v+1];)v++;g.push(v),d.push(C.derivativeBasisFunctionsGivenNI(v,_,n,o,r)),_+=c}return new re(g,d)},C.surfacePointGivenBasesKnotSpans=function(n,r,s,o,c,d,g,_){for(var v=m.zeros1d(_),w,P=o-n,A=c-r,I=0,M=r+1;I<M;){var k=I++;w=m.zeros1d(_);for(var z=0,N=n+1;z<N;){var B=z++;m.addMulMutate(w,d[B],s[P+B][A])}A++,m.addMulMutate(v,g[k],w)}return v},C.surfaceDerivativesGivenBasesKnotSpans=function(n,r,s,o,c,d,g,_,v){var w=s[0][0].length,P;v<n?P=v:P=n;var A;v<r?A=v:A=r;for(var I=m.zeros3d(P+1,A+1,w),M=m.zeros2d(r+1,w),k=0,z=0,N=P+1;z<N;){for(var B=z++,D=0,V=r+1;D<V;){var U=D++;M[U]=m.zeros1d(w);for(var q=0,tt=n+1;q<tt;){var H=q++;m.addMulMutate(M[U],d[B][H],s[o-n+H][c-r+U])}}var j=v-B;j<A?k=j:k=A;for(var K=0,et=k+1;K<et;){var nt=K++;I[B][nt]=m.zeros1d(w);for(var st=0,lt=r+1;st<lt;){var at=st++;m.addMulMutate(I[B][nt],g[nt][at],M[at])}}}return I},C.curveDerivatives=function(n,r,s){var o=n.knots.length-n.degree-2;return C.curveDerivativesGivenN(o,n,r,s)},C.curveDerivativesGivenN=function(n,r,s,o){var c=r.degree,d=r.controlPoints,g=r.knots;if(!C.areValidRelations(c,d.length,g.length))throw new J("Invalid relations between control points, knot vector, and n");var _=d[0].length,v;o<c?v=o:v=c;for(var w=m.zeros2d(o+1,_),P=C.knotSpanGivenN(n,c,s,g),A=C.derivativeBasisFunctionsGivenNI(P,s,c,v,g),I=0,M=v+1;I<M;)for(var k=I++,z=0,N=c+1;z<N;){var B=z++;m.addMulMutate(w[k],A[k][B],d[P-c+B])}return w},C.curvePoint=function(n,r){var s=n.knots.length-n.degree-2;return C.curvePointGivenN(s,n,r)},C.areValidRelations=function(n,r,s){return r+n+1-s==0},C.curvePointGivenN=function(n,r,s){var o=r.degree,c=r.controlPoints,d=r.knots;if(!C.areValidRelations(o,c.length,d.length))throw new J("Invalid relations between control points, knot Array, and n");for(var g=C.knotSpanGivenN(n,o,s,d),_=C.basisFunctionsGivenKnotSpanIndex(g,s,o,d),v=m.zeros1d(c[0].length),w=0,P=o+1;w<P;){var A=w++;m.addMulMutate(v,_[A],c[g-o+A])}return v},C.volumePoint=function(n,r,s,o){var c=n.knotsU.length-n.degreeU-2,d=n.knotsV.length-n.degreeV-2,g=n.knotsW.length-n.degreeW-2;return C.volumePointGivenNML(n,c,d,g,r,s,o)},C.volumePointGivenNML=function(n,r,s,o,c,d,g){if(!C.areValidRelations(n.degreeU,n.controlPoints.length,n.knotsU.length)||!C.areValidRelations(n.degreeV,n.controlPoints[0].length,n.knotsV.length)||!C.areValidRelations(n.degreeW,n.controlPoints[0][0].length,n.knotsW.length))throw new J("Invalid relations between control points and knot vector");for(var _=n.controlPoints,v=n.degreeU,w=n.degreeV,P=n.degreeW,A=n.knotsU,I=n.knotsV,M=n.knotsW,k=_[0][0][0].length,z=C.knotSpanGivenN(r,v,c,A),N=C.knotSpanGivenN(s,w,d,I),B=C.knotSpanGivenN(o,P,g,M),D=C.basisFunctionsGivenKnotSpanIndex(z,c,v,A),V=C.basisFunctionsGivenKnotSpanIndex(N,d,w,I),U=C.basisFunctionsGivenKnotSpanIndex(B,g,P,M),q=z-v,tt=m.zeros1d(k),H=m.zeros1d(k),j=m.zeros1d(k),K=0,et=P+1;K<et;){var nt=K++;j=m.zeros1d(k);for(var st=B-P+nt,lt=0,at=w+1;lt<at;){var ct=lt++;H=m.zeros1d(k);for(var it=N-w+ct,dt=0,Y=v+1;dt<Y;){var ft=dt++;m.addMulMutate(H,D[ft],_[q+ft][it][st])}m.addMulMutate(j,V[ct],H)}m.addMulMutate(tt,U[nt],j)}return tt},C.derivativeBasisFunctions=function(n,r,s){var o=C.knotSpan(r,n,s),c=s.length-1,d=c-r-1;return C.derivativeBasisFunctionsGivenNI(o,n,r,d,s)},C.derivativeBasisFunctionsGivenNI=function(n,r,s,o,c){var d=m.zeros2d(s+1,s+1),g=m.zeros1d(s+1),_=m.zeros1d(s+1),v=0,w=0;d[0][0]=1;for(var P=1,A=s+1;P<A;){var I=P++;g[I]=r-c[n+1-I],_[I]=c[n+I]-r,v=0;for(var M=0;M<I;){var k=M++;d[I][k]=_[k+1]+g[I-k],w=d[k][I-1]/d[I][k],d[k][I]=v+_[k+1]*w,v=g[I-k]*w}d[I][I]=v}for(var z=m.zeros2d(o+1,s+1),N=m.zeros2d(2,s+1),B=0,D=1,V=0,U=0,q=0,tt=0,H=0,j=0,K=s+1;j<K;){var et=j++;z[0][et]=d[et][s]}for(var nt=0,st=s+1;nt<st;){var lt=nt++;B=0,D=1,N[0][0]=1;for(var at=1,ct=o+1;at<ct;){var it=at++;V=0,U=lt-it,q=s-it,lt>=it&&(N[D][0]=N[B][0]/d[q+1][U],V=N[D][0]*d[U][q]),U>=-1?tt=1:tt=-U,lt-1<=q?H=it-1:H=s-lt;for(var dt=tt,Y=H+1;dt<Y;){var ft=dt++;N[D][ft]=(N[B][ft]-N[B][ft-1])/d[q+1][U+ft],V+=N[D][ft]*d[U+ft][q]}lt<=q&&(N[D][it]=-N[B][it-1]/d[q+1][lt],V+=N[D][it]*d[lt][q]),z[it][lt]=V;var Pt=B;B=D,D=Pt}}for(var Ut=s,Yt=1,Ft=o+1;Yt<Ft;){for(var $t=Yt++,Pe=0,Ue=s+1;Pe<Ue;){var xe=Pe++;z[$t][xe]*=Ut}Ut*=s-$t}return z},C.basisFunctions=function(n,r,s){var o=C.knotSpan(r,n,s);return C.basisFunctionsGivenKnotSpanIndex(o,n,r,s)},C.basisFunctionsGivenKnotSpanIndex=function(n,r,s,o){var c=m.zeros1d(s+1),d=m.zeros1d(s+1),g=m.zeros1d(s+1),_=0,v=0;c[0]=1;for(var w=1,P=s+1;w<P;){var A=w++;d[A]=r-o[n+1-A],g[A]=o[n+A]-r,_=0;for(var I=0;I<A;){var M=I++;v=c[M]/(g[M+1]+d[A-M]),c[M]=_+g[M+1]*v,_=d[A-M]*v}c[A]=_}return c},C.knotSpan=function(n,r,s){return C.knotSpanGivenN(s.length-n-2,n,r,s)},C.knotSpanGivenN=function(n,r,s,o){if(s>o[n+1]-rt.EPSILON)return n;if(s<o[r]+rt.EPSILON)return r;for(var c=r,d=n+1,g=Math.floor((c+d)/2);s<o[g]||s>=o[g+1];)s<o[g]?d=g:c=g,g=Math.floor((c+d)/2);return g},C.dehomogenize=function(n){for(var r=n.length,s=[],o=n[r-1],c=n.length-1,d=0;d<c;){var g=d++;s.push(n[g]/o)}return s},C.rational1d=function(n){var r=n[0].length-1;return n.map(function(s){return s.slice(0,r)})},C.rational2d=function(n){return n.map(C.rational1d)},C.weight1d=function(n){var r=n[0].length-1;return n.map(function(s){return s[r]})},C.weight2d=function(n){return n.map(C.weight1d)},C.dehomogenize1d=function(n){return n.map(C.dehomogenize)},C.dehomogenize2d=function(n){return n.map(C.dehomogenize1d)},C.homogenize1d=function(n,r){var s=n.length,o=n[0].length,c=[],d=0,g=[],_;r!=null?_=r:_=m.rep(n.length,1);for(var v=0;v<s;){var w=v++,P=[];g=n[w],d=_[w];for(var A=0;A<o;){var I=A++;P.push(g[I]*d)}P.push(d),c.push(P)}return c},C.homogenize2d=function(n,r){var s=n.length,o=[],c;if(r!=null)c=r;else{for(var d=[],g=0;g<s;)g++,d.push(m.rep(n[0].length,1));c=d}for(var _=0;_<s;){var v=_++;o.push(C.homogenize1d(n[v],c[v]))}return o};var ot=p.eval.Intersect=function(){};x["verb.eval.Intersect"]=ot,ot.__name__=["verb","eval","Intersect"],ot.surfaces=function(n,r,s){var o=Dt.rationalSurfaceAdaptive(n),c=Dt.rationalSurfaceAdaptive(r),d=ot.meshes(o,c),g=d.map(function(_){return _.map(function(v){return ot.surfacesAtPointWithEstimate(n,r,v.uv0,v.uv1,s)})});return g.map(function(_){return mt.rationalInterpCurve(_.map(function(v){return v.point}),3)})},ot.surfacesAtPointWithEstimate=function(n,r,s,o,c){var d,g,_,v,w,P,A,I,M,k,z,N,B,D=5,V=0;do{if(d=C.rationalSurfaceDerivatives(n,s[0],s[1],1),g=d[0][0],v=d[1][0],w=d[0][1],_=m.normalized(m.cross(v,w)),P=m.dot(_,g),A=C.rationalSurfaceDerivatives(r,o[0],o[1],1),I=A[0][0],k=A[1][0],z=A[0][1],M=m.normalized(m.cross(k,z)),N=m.dot(M,I),B=m.distSquared(g,I),B<c*c)break;var U=m.normalized(m.cross(_,M)),q=m.dot(U,g),tt=ot.threePlanes(_,P,M,N,U,q);if(tt==null)throw new J("panic!");var H=m.sub(tt,g),j=m.sub(tt,I),K=m.cross(v,_),et=m.cross(w,_),nt=m.cross(k,M),st=m.cross(z,M),lt=m.dot(et,H)/m.dot(et,v),at=m.dot(K,H)/m.dot(K,w),ct=m.dot(st,j)/m.dot(st,k),it=m.dot(nt,j)/m.dot(nt,z);s=m.add([lt,at],s),o=m.add([ct,it],o),V++}while(V<D);return new li(s,o,g,B)},ot.meshes=function(n,r,s,o){s==null&&(s=new sn(n)),o==null&&(o=new sn(r));var c=ot.boundingBoxTrees(s,o,0),d=$.unique(c.map(function(g){return ot.triangles(n,g.item0,r,g.item1)}).filter(function(g){return g!=null}).filter(function(g){return m.distSquared(g.min.point,g.max.point)>rt.EPSILON}),function(g,_){var v=m.sub(g.min.uv0,_.min.uv0),w=m.dot(v,v),P=m.sub(g.max.uv0,_.max.uv0),A=m.dot(P,P),I=m.sub(g.min.uv0,_.max.uv0),M=m.dot(I,I),k=m.sub(g.max.uv0,_.min.uv0),z=m.dot(k,k);return w<rt.EPSILON&&A<rt.EPSILON||M<rt.EPSILON&&z<rt.EPSILON});return ot.makeMeshIntersectionPolylines(d)},ot.meshSlices=function(n,r,s,o){for(var c=new Dn(n),d=c.boundingBox(),g=d.min[0],_=d.min[1],v=d.max[0],w=d.max[1],P=m.span(r,s,o),A=[],I=0;I<P.length;){var M=P[I];++I;var k=[[g,_,M],[v,_,M],[v,w,M],[g,w,M]],z=[[0,0],[1,0],[1,1],[0,1]],N=[[0,1,2],[0,2,3]],B=new Ye(N,k,null,z);A.push(ot.meshes(n,B,c))}return A},ot.makeMeshIntersectionPolylines=function(n){if(n.length==0)return[];for(var r=0;r<n.length;){var s=n[r];++r,s.max.opp=s.min,s.min.opp=s.max}for(var o=ot.kdTreeFromSegments(n),c=[],d=0;d<n.length;){var g=n[d];++d,c.push(g.min),c.push(g.max)}for(var _=0;_<c.length;){var v=c[_];if(++_,v.adj==null){var w=ot.lookupAdjacentSegment(v,o,n.length);w!=null&&w.adj==null&&(v.adj=w,w.adj=v)}}var P=c.filter(function(D){return D.adj==null});P.length==0&&(P=c);for(var A=[],I=0,M=!1;P.length!=0;){var k=P.pop();if(!k.visited){for(var z=[],N=k;N!=null&&!(N.visited||(N.visited=!0,N.opp.visited=!0,z.push(N),I+=2,N=N.opp.adj,N==k)););z.length>0&&(z.push(z[z.length-1].opp),A.push(z))}if(P.length==0&&c.length>0&&(M||I<c.length)){M=!0;var B=c.pop();P.push(B)}}return A},ot.kdTreeFromSegments=function(n){for(var r=[],s=0;s<n.length;){var o=n[s];++s,r.push(new Ar(o.min.point,o.min)),r.push(new Ar(o.max.point,o.max))}return new ci(r,m.distSquared)},ot.lookupAdjacentSegment=function(n,r,s){var o=r.nearest(n.point,s,rt.EPSILON).filter(function(c){return n!=c.item0.obj}).map(function(c){return c.item0.obj});return o.length==1?o[0]:null},ot.curveAndSurface=function(n,r,s,o,c){s==null&&(s=.001),o!=null?o=o:o=new rn(n),c!=null?c=c:c=new zn(r);var d=ot.boundingBoxTrees(o,c,s);return $.unique(d.map(function(g){var _=g.item0,v=g.item1,w=$.first(_.knots),P=$.last(_.knots),A=(w+P)/2,I=$.first(v.knotsU),M=$.last(v.knotsU),k=$.first(v.knotsV),z=$.last(v.knotsV),N=[(I+M)/2,(k+z)/2];return ot.curveAndSurfaceWithEstimate(_,v,[A].concat(N),s)}).filter(function(g){return m.distSquared(g.curvePoint,g.surfacePoint)<s*s}),function(g,_){return Math.abs(g.u-_.u)<.5*s})},ot.curveAndSurfaceWithEstimate=function(n,r,s,o){o==null&&(o=.001);var c=function(v){var w=C.rationalCurvePoint(n,v[0]),P=C.rationalSurfacePoint(r,v[1],v[2]),A=m.sub(w,P);return m.dot(A,A)},d=function(v){var w=C.rationalCurveDerivatives(n,v[0],1),P=C.rationalSurfaceDerivatives(r,v[1],v[2],1),A=m.sub(P[0][0],w[0]),I=m.mul(-1,w[1]),M=P[1][0],k=P[0][1];return[2*m.dot(I,A),2*m.dot(M,A),2*m.dot(k,A)]},g=Ke.uncmin(c,s,o*o,d),_=g.solution;return new ai(_[0],[_[1],_[2]],C.rationalCurvePoint(n,_[0]),C.rationalSurfacePoint(r,_[1],_[2]))},ot.polylineAndMesh=function(n,r,s){for(var o=ot.boundingBoxTrees(new an(n),new sn(r),s),c=[],d=0;d<o.length;){var g=o[d];++d;var _=g.item0,v=g.item1,w=ot.segmentWithTriangle(n.points[_],n.points[_+1],r.points,r.faces[v]);if(w!=null){var P=w.point,A=m.lerp(w.p,[n.params[_]],[n.params[_+1]])[0],I=ie.triangleUVFromPoint(r,v,P);c.push(new oi(P,A,I,_,v))}}return c},ot.boundingBoxTrees=function(n,r,s){s==null&&(s=1e-9);var o=[],c=[];o.push(n),c.push(r);for(var d=[];o.length>0;){var g=o.pop(),_=c.pop();if(!(g.empty()||_.empty())&&g.boundingBox().intersects(_.boundingBox(),s)){var v=g.indivisible(s),w=_.indivisible(s);if(v&&w){d.push(new re(g.yield(),_.yield()));continue}else if(v&&!w){var P=_.split();o.push(g),c.push(P.item1),o.push(g),c.push(P.item0);continue}else if(!v&&w){var A=g.split();o.push(A.item1),c.push(_),o.push(A.item0),c.push(_);continue}var I=g.split(),M=_.split();o.push(I.item1),c.push(M.item1),o.push(I.item1),c.push(M.item0),o.push(I.item0),c.push(M.item1),o.push(I.item0),c.push(M.item0)}}return d},ot.curves=function(n,r,s){var o=ot.boundingBoxTrees(new rn(n),new rn(r),0);return $.unique(o.map(function(c){return ot.curvesWithEstimate(n,r,$.first(c.item0.knots),$.first(c.item1.knots),s)}).filter(function(c){return m.distSquared(c.point0,c.point1)<s}),function(c,d){return Math.abs(c.u0-d.u0)<s*5})},ot.curvesWithEstimate=function(n,r,s,o,c){var d=function(I){var M=C.rationalCurvePoint(n,I[0]),k=C.rationalCurvePoint(r,I[1]),z=m.sub(M,k);return m.dot(z,z)},g=function(I){var M=C.rationalCurveDerivatives(n,I[0],1),k=C.rationalCurveDerivatives(r,I[1],1),z=m.sub(M[0],k[0]),N=M[1],B=m.mul(-1,k[1]);return[2*m.dot(N,z),2*m.dot(B,z)]},_=Ke.uncmin(d,[s,o],c*c,g),v=_.solution[0],w=_.solution[1],P=C.rationalCurvePoint(n,v),A=C.rationalCurvePoint(r,w);return new sr(P,A,v,w)},ot.triangles=function(n,r,s,o){var c=n.faces[r],d=s.faces[o],g=ie.getTriangleNorm(n.points,c),_=ie.getTriangleNorm(s.points,d),v=n.points[c[0]],w=s.points[d[0]],P=ot.planes(v,g,w,_);if(P==null)return null;var A=ot.clipRayInCoplanarTriangle(P,n,r);if(A==null)return null;var I=ot.clipRayInCoplanarTriangle(P,s,o);if(I==null)return null;var M=ot.mergeTriangleClipIntervals(A,I,n,r,s,o);return M==null?null:new Ae(new Nn(M.min.uv0,M.min.uv1,M.min.point,r,o),new Nn(M.max.uv0,M.max.uv1,M.max.point,r,o))},ot.clipRayInCoplanarTriangle=function(n,r,s){for(var o=r.faces[s],c=[r.points[o[0]],r.points[o[1]],r.points[o[2]]],d=[r.uvs[o[0]],r.uvs[o[1]],r.uvs[o[2]]],g=[m.sub(d[1],d[0]),m.sub(d[2],d[1]),m.sub(d[0],d[2])],_=[m.sub(c[1],c[0]),m.sub(c[2],c[1]),m.sub(c[0],c[2])],v=_.map(m.normalized),w=_.map(m.norm),P=null,A=null,I=0;I<3;){var M=I++,k=c[M],z=v[M],N=ot.rays(k,z,n.origin,n.dir);if(N!=null){var B=N.u0,D=N.u1;B<-rt.EPSILON||B>w[M]+rt.EPSILON||((P==null||D<P.u)&&(P=new wr(D,m.onRay(n.origin,n.dir,D),m.onRay(d[M],g[M],B/w[M]))),(A==null||D>A.u)&&(A=new wr(D,m.onRay(n.origin,n.dir,D),m.onRay(d[M],g[M],B/w[M]))))}}return A==null||P==null?null:new Ae(P,A)},ot.mergeTriangleClipIntervals=function(n,r,s,o,c,d){if(r.min.u>n.max.u+rt.EPSILON||n.min.u>r.max.u+rt.EPSILON)return null;var g;n.min.u>r.min.u?g=new re(n.min,0):g=new re(r.min,1);var _;n.max.u<r.max.u?_=new re(n.max,0):_=new re(r.max,1);var v=new Ae(new Nn(null,null,g.item0.point,o,d),new Nn(null,null,_.item0.point,o,d));return g.item1==0?(v.min.uv0=g.item0.uv,v.min.uv1=ie.triangleUVFromPoint(c,d,g.item0.point)):(v.min.uv0=ie.triangleUVFromPoint(s,o,g.item0.point),v.min.uv1=g.item0.uv),_.item1==0?(v.max.uv0=_.item0.uv,v.max.uv1=ie.triangleUVFromPoint(c,d,_.item0.point)):(v.max.uv0=ie.triangleUVFromPoint(s,o,_.item0.point),v.max.uv1=_.item0.uv),v},ot.planes=function(n,r,s,o){var c=m.cross(r,o);if(m.dot(c,c)<rt.EPSILON)return null;var d=0,g=Math.abs(c[0]),_=Math.abs(c[1]),v=Math.abs(c[2]);_>g&&(d=1,g=_),v>g&&(d=2,g=v);var w,P,A,I;d==0?(w=r[1],P=r[2],A=o[1],I=o[2]):d==1?(w=r[0],P=r[2],A=o[0],I=o[2]):(w=r[0],P=r[1],A=o[0],I=o[1]);var M=-m.dot(n,r),k=-m.dot(s,o),z=w*I-P*A,N=(P*k-M*I)/z,B=(M*A-w*k)/z,D;return d==0?D=[0,N,B]:d==1?D=[N,0,B]:D=[N,B,0],new xr(D,m.normalized(c))},ot.threePlanes=function(n,r,s,o,c,d){var g=m.cross(s,c),_=m.dot(n,g);if(Math.abs(_)<rt.EPSILON)return null;var v=m.sub(m.mul(d,s),m.mul(o,c)),w=m.add(m.mul(r,g),m.cross(n,v));return m.mul(1/_,w)},ot.polylines=function(n,r,s){for(var o=ot.boundingBoxTrees(new an(n),new an(r),s),c=[],d=0;d<o.length;){var g=o[d];++d;var _=g.item0,v=g.item1,w=ot.segments(n.points[_],n.points[_+1],r.points[v],r.points[v+1],s);w!=null&&(w.u0=m.lerp(w.u0,[n.params[_]],[n.params[_+1]])[0],w.u1=m.lerp(w.u1,[r.params[v]],[r.params[v+1]])[0],c.push(w))}return c},ot.segments=function(n,r,s,o,c){var d=m.sub(r,n),g=Math.sqrt(m.dot(d,d)),_=m.mul(1/g,d),v=m.sub(o,s),w=Math.sqrt(m.dot(v,v)),P=m.mul(1/w,v),A=ot.rays(n,_,s,P);if(A!=null){var I=Math.min(Math.max(0,A.u0/g),1),M=Math.min(Math.max(0,A.u1/w),1),k=m.onRay(n,d,I),z=m.onRay(s,v,M),N=m.distSquared(k,z);if(N<c*c)return new sr(k,z,I,M)}return null},ot.rays=function(n,r,s,o){var c=m.dot(r,o),d=m.dot(r,s),g=m.dot(r,n),_=m.dot(o,s),v=m.dot(o,n),w=m.dot(r,r),P=m.dot(o,o),A=w*P-c*c;if(Math.abs(A)<rt.EPSILON)return null;var I=c*(d-g)-w*(_-v),M=I/A,k=(d-g+M*c)/w,z=m.onRay(n,r,k),N=m.onRay(s,o,M);return new sr(z,N,k,M)},ot.segmentWithTriangle=function(n,r,s,o){var c=s[o[0]],d=s[o[1]],g=s[o[2]],_=m.sub(d,c),v=m.sub(g,c),w=m.cross(_,v),P=m.sub(r,n),A=m.sub(n,c),I=-m.dot(w,A),M=m.dot(w,P);if(Math.abs(M)<rt.EPSILON)return null;var k=I/M;if(k<0||k>1)return null;var z=m.add(n,m.mul(k,P)),N=m.dot(_,v),B=m.dot(_,_),D=m.dot(v,v),V=m.sub(z,c),U=m.dot(V,_),q=m.dot(V,v),tt=N*N-B*D;if(Math.abs(tt)<rt.EPSILON)return null;var H=(N*q-D*U)/tt,j=(N*U-B*q)/tt;return H>1+rt.EPSILON||j>1+rt.EPSILON||j<-rt.EPSILON||H<-rt.EPSILON||H+j>1+rt.EPSILON?null:new hi(z,H,j,k)},ot.segmentAndPlane=function(n,r,s,o){var c=m.dot(o,m.sub(r,n));if(Math.abs(c)<rt.EPSILON)return null;var d=m.dot(o,m.sub(s,n)),g=d/c;return g>1+rt.EPSILON||g<-rt.EPSILON?null:{p:g}};var mt=p.eval.Make=function(){};x["verb.eval.Make"]=mt,mt.__name__=["verb","eval","Make"],mt.rationalTranslationalSurface=function(n,r){for(var s=C.rationalCurvePoint(r,$.first(r.knots)),o=$.first(r.knots),c=$.last(r.knots),d=2*r.controlPoints.length,g=(c-o)/(d-1),_=[],v=0;v<d;){var w=v++,P=m.sub(C.rationalCurvePoint(r,o+w*g),s),A=yt.rationalCurveTransform(n,[[1,0,0,P[0]],[0,1,0,P[1]],[0,0,1,P[2]],[0,0,0,1]]);_.push(A)}return mt.loftedSurface(_)},mt.surfaceBoundaryCurves=function(n){var r=mt.surfaceIsocurve(n,$.first(n.knotsU),!1),s=mt.surfaceIsocurve(n,$.last(n.knotsU),!1),o=mt.surfaceIsocurve(n,$.first(n.knotsV),!0),c=mt.surfaceIsocurve(n,$.last(n.knotsV),!0);return[r,s,o,c]},mt.surfaceIsocurve=function(n,r,s){s==null&&(s=!1);var o;s?o=n.knotsV:o=n.knotsU;var c;s?c=n.degreeV:c=n.degreeU;for(var d=bt.knotMultiplicities(o),g=-1,_=0,v=d.length;_<v;){var w=_++;if(Math.abs(r-d[w].knot)<rt.EPSILON){g=w;break}}var P=c+1;g>=0&&(P=P-d[g].mult);var A;P>0?A=yt.surfaceKnotRefine(n,m.rep(P,r),s):A=n;var I=C.knotSpan(c,r,o);return Math.abs(r-$.first(o))<rt.EPSILON?I=0:Math.abs(r-$.last(o))<rt.EPSILON&&(I=(s?A.controlPoints[0].length:A.controlPoints.length)-1),s?new Vt(A.degreeU,A.knotsU,function(M){for(var k,z=[],N=0,B=A.controlPoints;N<B.length;){var D=B[N];++N,z.push(D[I])}return k=z,k}()):new Vt(A.degreeV,A.knotsV,A.controlPoints[I])},mt.loftedSurface=function(n,r){n=yt.unifyCurveKnotVectors(n);var s=n[0].degree;r==null&&(r=3),r>n.length-1&&(r=n.length-1);for(var o=n[0].knots,c=[],d=[],g=0,_=n[0].controlPoints.length;g<_;){var v=[g++],w=n.map(function(A){return function(I){return I.controlPoints[A[0]]}}(v)),P=mt.rationalInterpCurve(w,r,!0);d.push(P.controlPoints),c=P.knots}return new ne(s,r,o,c,d)},mt.clonedCurve=function(n){return new Vt(n.degree,n.knots.slice(),n.controlPoints.map(function(r){return r.slice()}))},mt.rationalBezierCurve=function(n,r){for(var s=n.length-1,o=[],c=0,d=s+1;c<d;)c++,o.push(0);for(var g=0,_=s+1;g<_;)g++,o.push(1);return r==null&&(r=m.rep(n.length,1)),new Vt(s,o,C.homogenize1d(n,r))},mt.fourPointSurface=function(n,r,s,o,c){c==null&&(c=3);for(var d=c,g=[],_=0,v=c+1;_<v;){for(var w=_++,P=[],A=0,I=c+1;A<I;){var M=A++,k=1-w/d,z=m.lerp(k,n,r),N=m.lerp(k,o,s),B=m.lerp(1-M/d,z,N);B.push(1),P.push(B)}g.push(P)}var D=m.rep(c+1,0),V=m.rep(c+1,1);return new ne(c,c,D.concat(V),D.concat(V),g)},mt.ellipseArc=function(n,r,s,o,c){var d=m.norm(r),g=m.norm(s);r=m.normalized(r),s=m.normalized(s),c<o&&(c=2*Math.PI+o);var _=c-o,v=0;_<=Math.PI/2?v=1:_<=Math.PI?v=2:_<=3*Math.PI/2?v=3:v=4;var w=_/v,P=Math.cos(w/2),A=m.add(n,m.add(m.mul(d*Math.cos(o),r),m.mul(g*Math.sin(o),s))),I=m.sub(m.mul(Math.cos(o),s),m.mul(Math.sin(o),r)),M=[],k=m.zeros1d(2*v+3),z=0,N=o,B=m.zeros1d(v*2);M[0]=A,B[0]=1;for(var D=1,V=v+1;D<V;){var U=D++;N+=w;var q=m.add(n,m.add(m.mul(d*Math.cos(N),r),m.mul(g*Math.sin(N),s)));B[z+2]=1,M[z+2]=q;var tt=m.sub(m.mul(Math.cos(N),s),m.mul(Math.sin(N),r)),H=ot.rays(A,m.mul(1/m.norm(I),I),q,m.mul(1/m.norm(tt),tt)),j=m.add(A,m.mul(H.u0,I));B[z+1]=P,M[z+1]=j,z+=2,U<v&&(A=q,I=tt)}for(var K=2*v+1,et=0;et<3;){var nt=et++;k[nt]=0,k[nt+K]=1}switch(v){case 2:k[3]=k[4]=.5;break;case 3:k[3]=k[4]=.3333333333333333,k[5]=k[6]=.6666666666666666;break;case 4:k[3]=k[4]=.25,k[5]=k[6]=.5,k[7]=k[8]=.75;break}return new Vt(2,k,C.homogenize1d(M,B))},mt.arc=function(n,r,s,o,c,d){return mt.ellipseArc(n,m.mul(o,m.normalized(r)),m.mul(o,m.normalized(s)),c,d)},mt.polyline=function(n){for(var r=[0,0],s=0,o=0,c=n.length-1;o<c;){var d=o++;s+=m.dist(n[d],n[d+1]),r.push(s)}r.push(s),r=m.mul(1/s,r);for(var g,_=[],v=0,w=n.length;v<w;)v++,_.push(1);return g=_,new Vt(1,r,C.homogenize1d(n.slice(0),g))},mt.extrudedSurface=function(n,r,s){for(var o=[[],[],[]],c=[[],[],[]],d=C.dehomogenize1d(s.controlPoints),g=C.weight1d(s.controlPoints),_=m.mul(r,n),v=m.mul(.5*r,n),w=0,P=d.length;w<P;){var A=w++;o[2][A]=d[A],o[1][A]=m.add(v,d[A]),o[0][A]=m.add(_,d[A]),c[0][A]=g[A],c[1][A]=g[A],c[2][A]=g[A]}return new ne(2,s.degree,[0,0,0,1,1,1],s.knots,C.homogenize2d(o,c))},mt.cylindricalSurface=function(n,r,s,o,c){var d=m.cross(n,r),g=mt.arc(s,r,d,c,0,2*Math.PI);return mt.extrudedSurface(n,o,g)},mt.revolvedSurface=function(n,r,s,o){var c=C.dehomogenize1d(n.controlPoints),d=C.weight1d(n.controlPoints),g,_;o<=Math.PI/2?(g=1,_=m.zeros1d(6+2*(g-1))):o<=Math.PI?(g=2,_=m.zeros1d(6+2*(g-1)),_[3]=_[4]=.5):o<=3*Math.PI/2?(g=3,_=m.zeros1d(6+2*(g-1)),_[3]=_[4]=.3333333333333333,_[5]=_[6]=.6666666666666666):(g=4,_=m.zeros1d(6+2*(g-1)),_[3]=_[4]=.25,_[5]=_[6]=.5,_[7]=_[8]=.75);for(var v=o/g,w=3+2*(g-1),P=0;P<3;){var A=P++;_[A]=0,_[w+A]=1}for(var I=Math.cos(v/2),M=0,k=m.zeros1d(g+1),z=m.zeros1d(g+1),N=m.zeros3d(2*g+1,c.length,3),B=m.zeros2d(2*g+1,c.length),D=1,V=g+1;D<V;){var U=D++;M+=v,z[U]=Math.cos(M),k[U]=Math.sin(M)}for(var q=0,tt=c.length;q<tt;){var H=q++,j=Oe.rayClosestPoint(c[H],r,s),K=m.sub(c[H],j),et=m.norm(K),nt=m.cross(s,K);et>rt.EPSILON&&(K=m.mul(1/et,K),nt=m.mul(1/et,nt)),N[0][H]=c[H];var st=c[H];B[0][H]=d[H];for(var lt=nt,at=0,ct=1,it=g+1;ct<it;){var dt=ct++,Y;et==0?Y=j:Y=m.add(j,m.add(m.mul(et*z[dt],K),m.mul(et*k[dt],nt))),N[at+2][H]=Y,B[at+2][H]=d[H];var ft=m.sub(m.mul(z[dt],nt),m.mul(k[dt],K));if(et==0)N[at+1][H]=j;else{var Pt=ot.rays(st,m.mul(1/m.norm(lt),lt),Y,m.mul(1/m.norm(ft),ft)),Ut=m.add(st,m.mul(Pt.u0,lt));N[at+1][H]=Ut}B[at+1][H]=I*d[H],at+=2,dt<g&&(st=Y,lt=ft)}}return new ne(2,n.degree,_,n.knots,C.homogenize2d(N,B))},mt.sphericalSurface=function(n,r,s,o){var c=mt.arc(n,m.mul(-1,r),s,o,0,Math.PI);return mt.revolvedSurface(c,n,r,2*Math.PI)},mt.conicalSurface=function(n,r,s,o,c){var d=2*Math.PI,g=1,_=[m.add(s,m.mul(o,n)),m.add(s,m.mul(c,r))],v=[0,0,1,1],w=[1,1],P=new Vt(g,v,C.homogenize1d(_,w));return mt.revolvedSurface(P,s,n,d)},mt.rationalInterpCurve=function(n,r,s,o,c){if(s==null&&(s=!1),r==null&&(r=3),n.length<r+1)throw new J("You need to supply at least degree + 1 points! You only supplied "+n.length+" points.");for(var d=[0],g=1,_=n.length;g<_;){var v=g++,w=m.norm(m.sub(n[v],n[v-1])),P=d[d.length-1];d.push(P+w)}for(var A=d[d.length-1],I=0,M=d.length;I<M;){var k=I++;d[k]=d[k]/A}var z=m.rep(r+1,0),N=o!=null&&c!=null,B;N?B=0:B=1;var D;N?D=d.length-r+1:D=d.length-r;for(var V=B;V<D;){for(var U=V++,q=0,tt=0;tt<r;){var H=tt++;q+=d[U+H]}z.push(1/r*q)}var j=z.concat(m.rep(r+1,1)),K=[],et;N?et=n.length+1:et=n.length-1;var nt;N?nt=n.length-(r-1):nt=n.length-(r+1);for(var st=0;st<d.length;){var lt=d[st];++st;var at=C.knotSpanGivenN(et,r,lt,j),ct=C.basisFunctionsGivenKnotSpanIndex(at,lt,r,j),it=at-r,dt=m.zeros1d(it),Y=m.zeros1d(nt-it);K.push(dt.concat(ct).concat(Y))}if(N){var ft=K[0].length-2,Pt=[-1,1].concat(m.zeros1d(ft)),Ut=m.zeros1d(ft).concat([-1,1]);$.spliceAndInsert(K,1,0,Pt),$.spliceAndInsert(K,K.length-1,0,Ut)}for(var Yt=n[0].length,Ft=[],$t=(1-j[j.length-r-2])/r,Pe=j[r+1]/r,Ue=0;Ue<Yt;){var xe=[Ue++],_e;if(!N)_e=n.map(function(Je){return function(wn){return wn[Je[0]]}}(xe));else{_e=[n[0][xe[0]]],_e.push(Pe*o[xe[0]]);for(var Se=1,Be=n.length-1;Se<Be;){var $e=Se++;_e.push(n[$e][xe[0]])}_e.push($t*c[xe[0]]),_e.push($.last(n)[xe[0]])}var on=Lt.solve(K,_e);Ft.push(on)}var Ze=Lt.transpose(Ft);if(!s){var Qe=m.rep(Ze.length,1);Ze=C.homogenize1d(Ze,Qe)}return new Vt(r,j,Ze)};var yt=p.eval.Modify=function(){};x["verb.eval.Modify"]=yt,yt.__name__=["verb","eval","Modify"],yt.curveReverse=function(n){return new Vt(n.degree,yt.knotsReverse(n.knots),$.reversed(n.controlPoints))},yt.surfaceReverse=function(n,r){return r==null&&(r=!1),r?new ne(n.degreeU,n.degreeV,n.knotsU,yt.knotsReverse(n.knotsV),function(s){for(var o,c=[],d=0,g=n.controlPoints;d<g.length;){var _=g[d];++d,c.push($.reversed(_))}return o=c,o}()):new ne(n.degreeU,n.degreeV,yt.knotsReverse(n.knotsU),n.knotsV,$.reversed(n.controlPoints))},yt.knotsReverse=function(n){var r=$.first(n);$.last(n);for(var s=[r],o=n.length,c=1;c<o;){var d=c++;s.push(s[d-1]+(n[o-d]-n[o-d-1]))}return s},yt.unifyCurveKnotVectors=function(n){n=n.map(mt.clonedCurve);for(var r=R.fold(n,function(j,K){return yt.imax(j.degree,K)},0),s=0,o=n.length;s<o;){var c=s++;n[c].degree<r&&(n[c]=yt.curveElevateDegree(n[c],r))}for(var d,g=[],_=0;_<n.length;){var v=n[_];++_,g.push(new Ae($.first(v.knots),$.last(v.knots)))}d=g;for(var w=0,P=n.length;w<P;){var A=w++,I=[d[A].min];n[A].knots=n[A].knots.map(function(j){return function(K){return K-j[0]}}(I))}for(var M=d.map(function(j){return j.max-j.min}),k=R.fold(M,function(j,K){return Math.max(j,K)},0),z=0,N=n.length;z<N;){var B=z++,D=[k/M[B]];n[B].knots=n[B].knots.map(function(j){return function(K){return K*j[0]}}(D))}for(var V=R.fold(n,function(j,K){return m.sortedSetUnion(j.knots,K)},[]),U=0,q=n.length;U<q;){var tt=U++,H=m.sortedSetSub(V,n[tt].knots);H.length==0&&(n[tt]=n[tt]),n[tt]=yt.curveKnotRefine(n[tt],H)}return n},yt.imin=function(n,r){return n<r?n:r},yt.imax=function(n,r){return n>r?n:r},yt.curveElevateDegree=function(n,r){if(r<=n.degree)return n;var s=n.knots.length-n.degree-2,o=n.degree,c=n.knots,d=n.controlPoints,g=r-n.degree,_=n.controlPoints[0].length,v=m.zeros2d(o+g+1,o+1),w=[],P=[],A=[],I=s+o+1,M=r,k=Math.floor(M/2),z=[],N=[];v[0][0]=1,v[M][o]=1;for(var B=1,D=k+1;B<D;)for(var V=B++,U=1/Ot.get(M,V),q=yt.imin(o,V),tt=yt.imax(0,V-g),H=q+1;tt<H;){var j=tt++;v[V][j]=U*Ot.get(o,j)*Ot.get(g,V-j)}for(var K=k+1;K<M;)for(var et=K++,nt=yt.imin(o,et),st=yt.imax(0,et-g),lt=nt+1;st<lt;){var at=st++;v[et][at]=v[M-et][o-at]}var ct=M+1,it=-1,dt=o,Y=o+1,ft=1,Pt=c[0];z[0]=d[0];for(var Ut=0,Yt=M+1;Ut<Yt;){var Ft=Ut++;N[Ft]=Pt}for(var $t=0,Pe=o+1;$t<Pe;){var Ue=$t++;w[Ue]=d[Ue]}for(;Y<I;){for(var xe=Y;Y<I&&c[Y]==c[Y+1];)Y=Y+1;var _e=Y-xe+1,Se=c[Y],Be=it;it=o-_e;var $e;Be>0?$e=Math.floor((Be+2)/2):$e=1;var on;if(it>0?on=Math.floor(M-(it+1)/2):on=M,it>0){for(var Ze=Se-Pt,Qe=[],Je=o;Je>_e;)Qe[Je-_e-1]=Ze/(c[dt+Je]-Pt),Je--;for(var wn=1,Tr=it+1;wn<Tr;){for(var or=wn++,xu=it-or,ta=_e+or,lr=o;lr>=ta;)w[lr]=m.add(m.mul(Qe[lr-ta],w[lr]),m.mul(1-Qe[lr-ta],w[lr-1])),lr--;A[xu]=w[o]}}for(var ah=$e,wu=M+1;ah<wu;){var Cr=ah++;P[Cr]=m.zeros1d(_);for(var Au=yt.imin(o,Cr),oh=yt.imax(0,Cr-g),Pu=Au+1;oh<Pu;){var lh=oh++;P[Cr]=m.add(P[Cr],m.mul(v[Cr][lh],w[lh]))}}if(Be>1)for(var ea=ct-2,na=ct,hh=Se-Pt,Su=(Se-N[ct-1])/hh,ch=1;ch<Be;){for(var ra=ch++,An=ea,hr=na,Un=hr-ct+1;hr-An>ra;){if(An<ft){var Iu=(Se-N[An])/(Pt-N[An]);z[An]=m.lerp(Iu,z[An],z[An-1])}if(hr>=$e){if(hr-ra<=ct-M+Be){var Eu=(Se-N[hr-ra])/hh;P[Un]=m.lerp(Eu,P[Un],P[Un+1])}}else P[Un]=m.lerp(Su,P[Un],P[Un+1]);An=An+1,hr=hr-1,Un=Un-1}ea=ea-1,na=na+1}if(dt!=o)for(var uh=0,Mu=M-Be;uh<Mu;)uh++,N[ct]=Pt,ct=ct+1;for(var dh=$e,ku=on+1;dh<ku;){var Tu=dh++;z[ft]=P[Tu],ft=ft+1}if(Y<I){for(var mh=0;mh<it;){var gh=mh++;w[gh]=A[gh]}for(var fh=it,Cu=o+1;fh<Cu;){var ph=fh++;w[ph]=d[Y-o+ph]}dt=Y,Y=Y+1,Pt=Se}else for(var _h=0,Lu=M+1;_h<Lu;){var Nu=_h++;N[ct+Nu]=Se}}return new Vt(r,N,z)},yt.rationalSurfaceTransform=function(n,r){for(var s=C.dehomogenize2d(n.controlPoints),o=0,c=s.length;o<c;)for(var d=o++,g=0,_=s[d].length;g<_;){var v=g++,w=s[d][v];w.push(1),s[d][v]=Lt.dot(r,w).slice(0,w.length-1)}return new ne(n.degreeU,n.degreeV,n.knotsU.slice(),n.knotsV.slice(),C.homogenize2d(s,C.weight2d(n.controlPoints)))},yt.rationalCurveTransform=function(n,r){for(var s=C.dehomogenize1d(n.controlPoints),o=0,c=s.length;o<c;){var d=o++,g=s[d];g.push(1),s[d]=Lt.dot(r,g).slice(0,g.length-1)}return new Vt(n.degree,n.knots.slice(),C.homogenize1d(s,C.weight1d(n.controlPoints)))},yt.surfaceKnotRefine=function(n,r,s){var o=[],c,d,g;s?(g=n.controlPoints,c=n.knotsV,d=n.degreeV):(g=Lt.transpose(n.controlPoints),c=n.knotsU,d=n.degreeU);for(var _=null,v=0;v<g.length;){var w=g[v];++v,_=yt.curveKnotRefine(new Vt(d,c,w),r),o.push(_.controlPoints)}var P=_.knots;return s?new ne(n.degreeU,n.degreeV,n.knotsU.slice(),P,o):(o=Lt.transpose(o),new ne(n.degreeU,n.degreeV,P,n.knotsV.slice(),o))},yt.decomposeCurveIntoBeziers=function(n){for(var r=n.degree,s=n.controlPoints,o=n.knots,c=bt.knotMultiplicities(o),d=r+1,g=0;g<c.length;){var _=c[g];if(++g,_.mult<d){var v=m.rep(d-_.mult,_.knot),w=yt.curveKnotRefine(new Vt(r,o,s),v);o=w.knots,s=w.controlPoints}}o.length/d-1;for(var P=d*2,A=[],I=0;I<s.length;){var M=o.slice(I,I+P),k=s.slice(I,I+d);A.push(new Vt(r,M,k)),I+=d}return A},yt.curveKnotRefine=function(n,r){if(r.length==0)return mt.clonedCurve(n);for(var s=n.degree,o=n.controlPoints,c=n.knots,d=o.length-1,g=d+s+1,_=r.length-1,v=C.knotSpan(s,r[0],c),w=C.knotSpan(s,r[_],c),P=[],A=[],I=0,M=v-s+1;I<M;){var k=I++;P[k]=o[k]}for(var z=w-1,N=d+1;z<N;){var B=z++;P[B+_+1]=o[B]}for(var D=0,V=v+1;D<V;){var U=D++;A[U]=c[U]}for(var q=w+s,tt=g+1;q<tt;){var H=q++;A[H+_+1]=c[H]}for(var j=w+s-1,K=w+s+_,et=_;et>=0;){for(;r[et]<=c[j]&&j>v;)P[K-s-1]=o[j-s-1],A[K]=c[j],K=K-1,j=j-1;P[K-s-1]=P[K-s];for(var nt=1,st=s+1;nt<st;){var lt=nt++,at=K-s+lt,ct=A[K+lt]-r[et];Math.abs(ct)<rt.EPSILON?P[at-1]=P[at]:(ct=ct/(A[K+lt]-c[j-s+lt]),P[at-1]=m.add(m.mul(ct,P[at-1]),m.mul(1-ct,P[at])))}A[K]=r[et],K=K-1,et--}return new Vt(s,A,P)},yt.curveKnotInsert=function(n,r,s){for(var o=n.degree,c=n.controlPoints,d=n.knots,g=0,_=c.length,v=C.knotSpan(o,r,d),w=[],P=[],A=[],I=1,M=v+1;I<M;){var k=I++;P[k]=d[k]}for(var z=1,N=s+1;z<N;){var B=z++;P[v+B]=r}for(var D=v+1,V=d.length;D<V;){var U=D++;P[U+s]=d[U]}for(var q=0,tt=v-o+1;q<tt;){var H=q++;A[H]=c[H]}for(var j=v-g;j<_;){var K=j++;A[K+s]=c[K]}for(var et=0,nt=o-g+1;et<nt;){var st=et++;w[st]=c[v-o+st]}for(var lt=0,at=0,ct=1,it=s+1;ct<it;){var dt=ct++;lt=v-o+dt;for(var Y=0,ft=o-dt-g+1;Y<ft;){var Pt=Y++;at=(r-d[lt+Pt])/(d[Pt+v+1]-d[lt+Pt]),w[Pt]=m.add(m.mul(at,w[Pt+1]),m.mul(1-at,w[Pt]))}A[lt]=w[0],A[v+s-dt-g]=w[o-dt-g]}for(var Ut=lt+1,Yt=v-g;Ut<Yt;){var Ft=Ut++;A[Ft]=w[Ft-lt]}return new Vt(o,P,A)};var Dt=p.eval.Tess=function(){};x["verb.eval.Tess"]=Dt,Dt.__name__=["verb","eval","Tess"],Dt.rationalCurveRegularSample=function(n,r,s){return Dt.rationalCurveRegularSampleRange(n,n.knots[0],$.last(n.knots),r,s)},Dt.rationalCurveRegularSampleRange=function(n,r,s,o,c){o<1&&(o=2);for(var d=[],g=(s-r)/(o-1),_=0,v=0;v<o;){var w=v++;_=r+g*w,c?d.push([_].concat(C.rationalCurvePoint(n,_))):d.push(C.rationalCurvePoint(n,_))}return d},Dt.rationalCurveAdaptiveSample=function(n,r,s){if(s==null&&(s=!1),r==null&&(r=1e-6),n.degree==1)if(s){for(var o=[],c=0,d=n.controlPoints.length;c<d;){var g=c++;o.push([n.knots[g+1]].concat(C.dehomogenize(n.controlPoints[g])))}return o}else return n.controlPoints.map(C.dehomogenize);return Dt.rationalCurveAdaptiveSampleRange(n,n.knots[0],$.last(n.knots),r,s)},Dt.rationalCurveAdaptiveSampleRange=function(n,r,s,o,c){var d=C.rationalCurvePoint(n,r),g=C.rationalCurvePoint(n,s),_=.5+.2*Math.random(),v=r+(s-r)*_,w=C.rationalCurvePoint(n,v),P=m.sub(d,g),A=m.sub(d,w);if(m.dot(P,P)<o&&m.dot(A,A)>o||!Oe.threePointsAreFlat(d,w,g,o)){var I=r+(s-r)*.5,M=Dt.rationalCurveAdaptiveSampleRange(n,r,I,o,c),k=Dt.rationalCurveAdaptiveSampleRange(n,I,s,o,c);return M.slice(0,-1).concat(k)}else return c?[[r].concat(d),[s].concat(g)]:[d,g]},Dt.rationalSurfaceNaive=function(n,r,s){r<1&&(r=1),s<1&&(s=1),n.degreeU,n.degreeV,n.controlPoints;for(var o=n.knotsU,c=n.knotsV,d=$.last(o)-o[0],g=$.last(c)-c[0],_=d/r,v=g/s,w=[],P=[],A=[],I=0,M=r+1;I<M;)for(var k=I++,z=0,N=s+1;z<N;){var B=z++,D=k*_,V=B*v;P.push([D,V]);var U=C.rationalSurfaceDerivatives(n,D,V,1),q=U[0][0];w.push(q);var tt=m.normalized(m.cross(U[1][0],U[0][1]));A.push(tt)}for(var H=[],j=0;j<r;)for(var K=j++,et=0;et<s;){var nt=et++,st=K*(s+1)+nt,lt=(K+1)*(s+1)+nt,at=lt+1,ct=st+1,it=[st,lt,at],dt=[st,at,ct];H.push(it),H.push(dt)}return new Ye(H,w,A,P)},Dt.divideRationalSurfaceAdaptive=function(n,r){r==null&&(r=new On),r.minDivsU!=null?r.minDivsU=r.minDivsU:r.minDivsU=1,r.minDivsV!=null?r.minDivsU=r.minDivsV:r.minDivsU=1,r.refine!=null?r.refine=r.refine:r.refine=!0;var s=(n.controlPoints.length-1)*2,o=(n.controlPoints[0].length-1)*2,c;r.minDivsU>s?c=r.minDivsU=r.minDivsU:c=r.minDivsU=s;var d;r.minDivsV>o?d=r.minDivsV=r.minDivsV:d=r.minDivsV=o;for(var g=$.last(n.knotsU),_=n.knotsU[0],v=$.last(n.knotsV),w=n.knotsV[0],P=(g-_)/c,A=(v-w)/d,I=[],M=[],k=0,z=d+1;k<z;){for(var N=k++,B=[],D=0,V=c+1;D<V;){var U=D++,q=_+P*U,tt=w+A*N,H=C.rationalSurfaceDerivatives(n,q,tt,1),j=m.normalized(m.cross(H[0][1],H[1][0]));B.push(new Fe(H[0][0],j,[q,tt],-1,m.isZero(j)))}M.push(B)}for(var K=0;K<d;)for(var et=K++,nt=0;nt<c;){var st=nt++,lt=[M[d-et-1][st],M[d-et-1][st+1],M[d-et][st+1],M[d-et][st]];I.push(new xn(n,lt))}if(!r.refine)return I;for(var at=0;at<d;)for(var ct=at++,it=0;it<c;){var dt=it++,Y=ct*c+dt,ft=Dt.north(Y,ct,dt,c,d,I),Pt=Dt.east(Y,ct,dt,c,d,I),Ut=Dt.south(Y,ct,dt,c,d,I),Yt=Dt.west(Y,ct,dt,c,d,I);I[Y].neighbors=[Ut,Pt,ft,Yt],I[Y].divide(r)}return I},Dt.north=function(n,r,s,o,c,d){return r==0?null:d[n-o]},Dt.south=function(n,r,s,o,c,d){return r==c-1?null:d[n+o]},Dt.east=function(n,r,s,o,c,d){return s==o-1?null:d[n+1]},Dt.west=function(n,r,s,o,c,d){return s==0?null:d[n-1]},Dt.triangulateAdaptiveRefinementNodeTree=function(n){for(var r=Ye.empty(),s=0;s<n.length;){var o=n[s];++s,o.triangulate(r)}return r},Dt.rationalSurfaceAdaptive=function(n,r){r!=null?r=r:r=new On;var s=Dt.divideRationalSurfaceAdaptive(n,r);return Dt.triangulateAdaptiveRefinementNodeTree(s)};var On=p.core.AdaptiveRefinementOptions=function(){this.minDivsV=1,this.minDivsU=1,this.refine=!0,this.maxDepth=10,this.minDepth=0,this.normTol=.025};x["verb.eval.AdaptiveRefinementOptions"]=On,On.__name__=["verb","eval","AdaptiveRefinementOptions"],On.prototype={__class__:On};var xn=p.core.AdaptiveRefinementNode=function(n,r,s){if(this.srf=n,s==null?this.neighbors=[null,null,null,null]:this.neighbors=s,this.corners=r,this.corners==null){var o=n.knotsU[0],c=$.last(n.knotsU),d=n.knotsV[0],g=$.last(n.knotsV);this.corners=[Fe.fromUv(o,d),Fe.fromUv(c,d),Fe.fromUv(c,g),Fe.fromUv(o,g)]}};x["verb.eval.AdaptiveRefinementNode"]=xn,xn.__name__=["verb","eval","AdaptiveRefinementNode"],xn.prototype={isLeaf:function(){return this.children==null},center:function(){return this.centerPoint!=null?this.centerPoint:this.evalSrf(this.u05,this.v05)},evalCorners:function(){this.u05=(this.corners[0].uv[0]+this.corners[2].uv[0])/2,this.v05=(this.corners[0].uv[1]+this.corners[2].uv[1])/2;for(var n=0;n<4;){var r=n++;if(this.corners[r].point==null){var s=this.corners[r];this.evalSrf(s.uv[0],s.uv[1],s)}}},evalSrf:function(n,r,s){var o=C.rationalSurfaceDerivatives(this.srf,n,r,1),c=o[0][0],d=m.cross(o[0][1],o[1][0]),g=m.isZero(d);return g||(d=m.normalized(d)),s!=null?(s.degen=g,s.point=c,s.normal=d,s):new Fe(c,d,[n,r],-1,g)},getEdgeCorners:function(n){if(this.isLeaf())return[this.corners[n]];if(this.horizontal)switch(n){case 0:return this.children[0].getEdgeCorners(0);case 1:return this.children[0].getEdgeCorners(1).concat(this.children[1].getEdgeCorners(1));case 2:return this.children[1].getEdgeCorners(2);case 3:return this.children[1].getEdgeCorners(3).concat(this.children[0].getEdgeCorners(3))}switch(n){case 0:return this.children[0].getEdgeCorners(0).concat(this.children[1].getEdgeCorners(0));case 1:return this.children[1].getEdgeCorners(1);case 2:return this.children[1].getEdgeCorners(2).concat(this.children[0].getEdgeCorners(2));case 3:return this.children[0].getEdgeCorners(3)}return null},getAllCorners:function(n){var r=[this.corners[n]];if(this.neighbors[n]==null)return r;var s=this.neighbors[n].getEdgeCorners((n+2)%4),o=n%2,c=rt.EPSILON,d=this,g=[function(v){return v.uv[0]>d.corners[0].uv[0]+c&&v.uv[0]<d.corners[2].uv[0]-c},function(v){return v.uv[1]>d.corners[0].uv[1]+c&&v.uv[1]<d.corners[2].uv[1]-c}],_=s.filter(g[o]);return _.reverse(),r.concat(_)},midpoint:function(n){if(this.midPoints==null&&(this.midPoints=[null,null,null,null]),this.midPoints[n]!=null)return this.midPoints[n];switch(n){case 0:this.midPoints[0]=this.evalSrf(this.u05,this.corners[0].uv[1]);break;case 1:this.midPoints[1]=this.evalSrf(this.corners[1].uv[0],this.v05);break;case 2:this.midPoints[2]=this.evalSrf(this.u05,this.corners[2].uv[1]);break;case 3:this.midPoints[3]=this.evalSrf(this.corners[0].uv[0],this.v05);break}return this.midPoints[n]},hasBadNormals:function(){return this.corners[0].degen||this.corners[1].degen||this.corners[2].degen||this.corners[3].degen},fixNormals:function(){for(var n=this.corners.length,r=0;r<n;){var s=r++;if(this.corners[s],this.corners[s].degen){var o=this.corners[(s+1)%n],c=this.corners[(s+3)%n];o.degen?this.corners[s].normal=c.normal:this.corners[s].normal=o.normal}}},shouldDivide:function(n,r){if(r<n.minDepth)return!0;if(r>=n.maxDepth)return!1;if(this.hasBadNormals())return this.fixNormals(),!1;if(this.splitVert=m.normSquared(m.sub(this.corners[0].normal,this.corners[1].normal))>n.normTol||m.normSquared(m.sub(this.corners[2].normal,this.corners[3].normal))>n.normTol,this.splitHoriz=m.normSquared(m.sub(this.corners[1].normal,this.corners[2].normal))>n.normTol||m.normSquared(m.sub(this.corners[3].normal,this.corners[0].normal))>n.normTol,this.splitVert||this.splitHoriz)return!0;var s=this.center();return m.normSquared(m.sub(s.normal,this.corners[0].normal))>n.normTol||m.normSquared(m.sub(s.normal,this.corners[1].normal))>n.normTol||m.normSquared(m.sub(s.normal,this.corners[2].normal))>n.normTol||m.normSquared(m.sub(s.normal,this.corners[3].normal))>n.normTol},divide:function(n){n==null&&(n=new On),n.normTol==null&&(n.normTol=.085),n.minDepth==null&&(n.minDepth=0),n.maxDepth==null&&(n.maxDepth=10),this._divide(n,0,!0)},_divide:function(n,r,s){if(this.evalCorners(),!!this.shouldDivide(n,r)){if(r++,this.splitVert&&!this.splitHoriz?s=!1:!this.splitVert&&this.splitHoriz&&(s=!0),this.horizontal=s,this.horizontal){var o=[this.corners[0],this.corners[1],this.midpoint(1),this.midpoint(3)],c=[this.midpoint(3),this.midpoint(1),this.corners[2],this.corners[3]];this.children=[new xn(this.srf,o),new xn(this.srf,c)],this.children[0].neighbors=[this.neighbors[0],this.neighbors[1],this.children[1],this.neighbors[3]],this.children[1].neighbors=[this.children[0],this.neighbors[1],this.neighbors[2],this.neighbors[3]]}else{var d=[this.corners[0],this.midpoint(0),this.midpoint(2),this.corners[3]],g=[this.midpoint(0),this.corners[1],this.corners[2],this.midpoint(2)];this.children=[new xn(this.srf,d),new xn(this.srf,g)],this.children[0].neighbors=[this.neighbors[0],this.children[1],this.neighbors[2],this.neighbors[3]],this.children[1].neighbors=[this.neighbors[0],this.neighbors[1],this.neighbors[2],this.children[0]]}for(var _=0,v=this.children;_<v.length;){var w=v[_];++_,w._divide(n,r,!s)}}},triangulate:function(n){if(n==null&&(n=Ye.empty()),this.isLeaf())return this.triangulateLeaf(n);for(var r=0,s=this.children;r<s.length;){var o=s[r];if(++r,o==null)break;o.triangulate(n)}return n},triangulateLeaf:function(n){for(var r=n.points.length,s=[],o=[],c=0,d=0;d<4;){var g=d++,_=this.getAllCorners(g);_.length==2&&(c=g+1);for(var v=0,w=_.length;v<w;){var P=v++;s.push(_[P])}}for(var A=0;A<s.length;){var I=s[A];if(++A,I.id!=-1){o.push(I.id);continue}n.uvs.push(I.uv),n.points.push(I.point),n.normals.push(I.normal),I.id=r,o.push(r),r++}if(s.length==4)return n.faces.push([o[0],o[3],o[1]]),n.faces.push([o[3],o[2],o[1]]),n;if(s.length==5){var M=o.length;return n.faces.push([o[c],o[(c+2)%M],o[(c+1)%M]]),n.faces.push([o[(c+4)%M],o[(c+3)%M],o[c]]),n.faces.push([o[c],o[(c+3)%M],o[(c+2)%M]]),n}var k=this.center();n.uvs.push(k.uv),n.points.push(k.point),n.normals.push(k.normal);for(var z=n.points.length-1,N=0,B=s.length-1;N<s.length;)n.faces.push([z,o[N],o[B]]),B=N++;return n},__class__:xn};var wt=p.exe.Dispatcher=function(){};x["verb.exe.Dispatcher"]=wt,wt.__name__=["verb","exe","Dispatcher"],wt.init=function(){wt._init||(wt._workerPool=new Rn(wt.THREADS),wt._init=!0)},wt.dispatchMethod=function(n,r,s){wt.init();var o=new yr,c=function(d){o.resolve(d)};return wt._workerPool.addWork(gt.getClassName(n),r,s,c),new pe(o)};var Rn=p.exe.WorkerPool=function(n,r){r==null&&(r="verb.js"),n==null&&(n=1),this._callbacks=new xt,this._working=new xt,this._pool=[],this._queue=[];for(var s=0;s<n;){s++;var o;try{o=new Worker(Rn.basePath+r)}catch(c){c instanceof J&&(c=c.val),o=new Worker(Rn.basePath+r.substring(0,-3)+".min.js")}this._pool.push(o)}};x["verb.exe.WorkerPool"]=Rn,Rn.__name__=["verb","exe","WorkerPool"],Rn.prototype={addWork:function(n,r,s,o){var c=new ar(n,r,s);this._callbacks.set(c.id,o),this._queue.push(c),this.processQueue()},processQueue:function(){for(var n=this;this._queue.length>0&&this._pool.length>0;){var r=this._queue.shift(),s=[r.id],o=[this._pool.shift()];this._working.h[s[0]]=o[0],o[0].onmessage=function(c,d){return function(g){n._working.remove(d[0]),n._pool.push(c[0]);try{n._callbacks.h.hasOwnProperty(d[0])&&(n._callbacks.h[d[0]](g.data.result),n._callbacks.remove(d[0]))}catch(_){_ instanceof J&&(_=_.val),b.log(_)}n.processQueue()}}(o,s),o[0].postMessage(r)}},__class__:Rn};var ar=function(n,r,s){this.className=n,this.methodName=r,this.args=s,this.id=ar.uuid++};x["verb.exe._WorkerPool.Work"]=ar,ar.__name__=["verb","exe","_WorkerPool","Work"],ar.prototype={__class__:ar};var Mr=function(){};x["verb.geom.ICurve"]=Mr,Mr.__name__=["verb","geom","ICurve"],Mr.__interfaces__=[Sr],Mr.prototype={__class__:Mr};var Tt=p.geom.NurbsCurve=function(n){this._data=Ve.isValidNurbsCurveData(n)};x["verb.geom.NurbsCurve"]=Tt,Tt.__name__=["verb","geom","NurbsCurve"],Tt.__interfaces__=[Mr],Tt.byKnotsControlPointsWeights=function(n,r,s,o){return new Tt(new Vt(n,r.slice(),C.homogenize1d(s,o)))},Tt.byPoints=function(n,r){return r==null&&(r=3),new Tt(mt.rationalInterpCurve(n,r))},Tt.__super__=Zt,Tt.prototype=T(Zt.prototype,{degree:function(){return this._data.degree},knots:function(){return this._data.knots.slice(0)},controlPoints:function(){return C.dehomogenize1d(this._data.controlPoints)},weights:function(){return C.weight1d(this._data.controlPoints)},asNurbs:function(){return new Vt(this.degree(),this.knots(),C.homogenize1d(this.controlPoints(),this.weights()))},clone:function(){return new Tt(this._data)},domain:function(){return new Ae($.first(this._data.knots),$.last(this._data.knots))},transform:function(n){return new Tt(yt.rationalCurveTransform(this._data,n))},transformAsync:function(n){return wt.dispatchMethod(yt,"rationalCurveTransform",[this._data,n]).then(function(r){return new Tt(r)})},point:function(n){return C.rationalCurvePoint(this._data,n)},pointAsync:function(n){return wt.dispatchMethod(C,"rationalCurvePoint",[this._data,n])},tangent:function(n){return C.rationalCurveTangent(this._data,n)},tangentAsync:function(n){return wt.dispatchMethod(C,"rationalCurveTangent",[this._data,n])},derivatives:function(n,r){return r==null&&(r=1),C.rationalCurveDerivatives(this._data,n,r)},derivativesAsync:function(n,r){return r==null&&(r=1),wt.dispatchMethod(C,"rationalCurveDerivatives",[this._data,n,r])},closestPoint:function(n){return bt.rationalCurveClosestPoint(this._data,n)},closestPointAsync:function(n){return wt.dispatchMethod(bt,"rationalCurveClosestPoint",[this._data,n])},closestParam:function(n){return bt.rationalCurveClosestParam(this._data,n)},closestParamAsync:function(n){return wt.dispatchMethod(bt,"rationalCurveClosestParam",[this._data,n])},length:function(){return bt.rationalCurveArcLength(this._data)},lengthAsync:function(){return wt.dispatchMethod(bt,"rationalCurveArcLength",[this._data])},lengthAtParam:function(n){return bt.rationalCurveArcLength(this._data,n)},lengthAtParamAsync:function(){return wt.dispatchMethod(bt,"rationalCurveArcLength",[this._data])},paramAtLength:function(n,r){return bt.rationalCurveParamAtArcLength(this._data,n,r)},paramAtLengthAsync:function(n,r){return wt.dispatchMethod(bt,"rationalCurveParamAtArcLength",[this._data,n,r])},divideByEqualArcLength:function(n){return ue.rationalCurveByEqualArcLength(this._data,n)},divideByEqualArcLengthAsync:function(n){return wt.dispatchMethod(ue,"rationalCurveByEqualArcLength",[this._data,n])},divideByArcLength:function(n){return ue.rationalCurveByArcLength(this._data,n)},divideByArcLengthAsync:function(n){return wt.dispatchMethod(ue,"rationalCurveByArcLength",[this._data,n])},split:function(n){return ue.curveSplit(this._data,n).map(function(r){return new Tt(r)})},splitAsync:function(n){return wt.dispatchMethod(ue,"curveSplit",[this._data,n]).then(function(r){return r.map(function(s){return new Tt(s)})})},reverse:function(){return new Tt(yt.curveReverse(this._data))},reverseAsync:function(){return wt.dispatchMethod(yt,"curveReverse",[this._data]).then(function(n){return new Tt(n)})},tessellate:function(n){return Dt.rationalCurveAdaptiveSample(this._data,n,!1)},tessellateAsync:function(n){return wt.dispatchMethod(Dt,"rationalCurveAdaptiveSample",[this._data,n,!1])},__class__:Tt});var Bn=p.geom.Arc=function(n,r,s,o,c,d){Tt.call(this,mt.arc(n,r,s,o,c,d)),this._center=n,this._xaxis=r,this._yaxis=s,this._radius=o,this._minAngle=c,this._maxAngle=d};x["verb.geom.Arc"]=Bn,Bn.__name__=["verb","geom","Arc"],Bn.__super__=Tt,Bn.prototype=T(Tt.prototype,{center:function(){return this._center},xaxis:function(){return this._xaxis},yaxis:function(){return this._yaxis},radius:function(){return this._radius},minAngle:function(){return this._minAngle},maxAngle:function(){return this._maxAngle},__class__:Bn});var gi=p.geom.BezierCurve=function(n,r){Tt.call(this,mt.rationalBezierCurve(n,r))};x["verb.geom.BezierCurve"]=gi,gi.__name__=["verb","geom","BezierCurve"],gi.__super__=Tt,gi.prototype=T(Tt.prototype,{__class__:gi});var fi=p.geom.Circle=function(n,r,s,o){Bn.call(this,n,r,s,o,0,Math.PI*2)};x["verb.geom.Circle"]=fi,fi.__name__=["verb","geom","Circle"],fi.__super__=Bn,fi.prototype=T(Bn.prototype,{__class__:fi});var kr=function(){};x["verb.geom.ISurface"]=kr,kr.__name__=["verb","geom","ISurface"],kr.__interfaces__=[Sr],kr.prototype={__class__:kr};var St=p.geom.NurbsSurface=function(n){this._data=Ve.isValidNurbsSurfaceData(n)};x["verb.geom.NurbsSurface"]=St,St.__name__=["verb","geom","NurbsSurface"],St.__interfaces__=[kr],St.byKnotsControlPointsWeights=function(n,r,s,o,c,d){return new St(new ne(n,r,s,o,C.homogenize2d(c,d)))},St.byCorners=function(n,r,s,o){return new St(mt.fourPointSurface(n,r,s,o))},St.byLoftingCurves=function(n,r){return new St(mt.loftedSurface(function(s){for(var o,c=[],d=0;d<n.length;){var g=n[d];++d,c.push(g.asNurbs())}return o=c,o}(),r))},St.__super__=Zt,St.prototype=T(Zt.prototype,{degreeU:function(){return this._data.degreeU},degreeV:function(){return this._data.degreeV},knotsU:function(){return this._data.knotsU.slice(0)},knotsV:function(){return this._data.knotsV.slice(0)},controlPoints:function(){return C.dehomogenize2d(this._data.controlPoints)},weights:function(){return C.weight2d(this._data.controlPoints)},asNurbs:function(){return new ne(this.degreeU(),this.degreeV(),this.knotsU(),this.knotsV(),C.homogenize2d(this.controlPoints(),this.weights()))},clone:function(){return new St(this.asNurbs())},domainU:function(){return new Ae($.first(this._data.knotsU),$.last(this._data.knotsU))},domainV:function(){return new Ae($.first(this._data.knotsV),$.last(this._data.knotsV))},point:function(n,r){return C.rationalSurfacePoint(this._data,n,r)},pointAsync:function(n,r){return wt.dispatchMethod(C,"rationalSurfacePoint",[this._data,n,r])},normal:function(n,r){return C.rationalSurfaceNormal(this._data,n,r)},normalAsync:function(n,r){return wt.dispatchMethod(C,"rationalSurfaceNormal",[this._data,n,r])},derivatives:function(n,r,s){return s==null&&(s=1),C.rationalSurfaceDerivatives(this._data,n,r,s)},derivativesAsync:function(n,r,s){return s==null&&(s=1),wt.dispatchMethod(C,"rationalSurfaceDerivatives",[this._data,n,r,s])},closestParam:function(n){return bt.rationalSurfaceClosestParam(this._data,n)},closestParamAsync:function(n){return wt.dispatchMethod(bt,"rationalSurfaceClosestParam",[this._data,n])},closestPoint:function(n){return bt.rationalSurfaceClosestPoint(this._data,n)},closestPointAsync:function(n){return wt.dispatchMethod(bt,"rationalSurfaceClosestPoint",[this._data,n])},split:function(n,r){return r==null&&(r=!1),ue.surfaceSplit(this._data,n,r).map(function(s){return new St(s)})},splitAsync:function(n,r){return r==null&&(r=!1),wt.dispatchMethod(ue,"surfaceSplit",[this._data,n,r]).then(function(s){return s.map(function(o){return new St(o)})})},reverse:function(n){return n==null&&(n=!1),new St(yt.surfaceReverse(this._data,n))},reverseAsync:function(n){return n==null&&(n=!1),wt.dispatchMethod(yt,"surfaceReverse",[this._data,n]).then(function(r){return new St(r)})},isocurve:function(n,r){return r==null&&(r=!1),new Tt(mt.surfaceIsocurve(this._data,n,r))},isocurveAsync:function(n,r){return r==null&&(r=!1),wt.dispatchMethod(mt,"surfaceIsocurve",[this._data,n,r]).then(function(s){return new Tt(s)})},boundaries:function(n){return mt.surfaceBoundaryCurves(this._data).map(function(r){return new Tt(r)})},boundariesAsync:function(n){return wt.dispatchMethod(mt,"surfaceBoundaryCurves",[this._data]).then(function(r){return r.map(function(s){return new Tt(s)})})},tessellate:function(n){return Dt.rationalSurfaceAdaptive(this._data,n)},tessellateAsync:function(n){return wt.dispatchMethod(Dt,"rationalSurfaceAdaptive",[this._data,n])},transform:function(n){return new St(yt.rationalSurfaceTransform(this._data,n))},transformAsync:function(n){return wt.dispatchMethod(yt,"rationalSurfaceTransform",[this._data,n]).then(function(r){return new St(r)})},__class__:St});var pi=p.geom.ConicalSurface=function(n,r,s,o,c){St.call(this,mt.conicalSurface(n,r,s,o,c)),this._axis=n,this._xaxis=r,this._base=s,this._height=o,this._radius=c};x["verb.geom.ConicalSurface"]=pi,pi.__name__=["verb","geom","ConicalSurface"],pi.__super__=St,pi.prototype=T(St.prototype,{axis:function(){return this._axis},xaxis:function(){return this._xaxis},base:function(){return this._base},height:function(){return this._height},radius:function(){return this._radius},__class__:pi});var _i=p.geom.CylindricalSurface=function(n,r,s,o,c){St.call(this,mt.cylindricalSurface(n,r,s,o,c)),this._axis=n,this._xaxis=r,this._base=s,this._height=o,this._radius=c};x["verb.geom.CylindricalSurface"]=_i,_i.__name__=["verb","geom","CylindricalSurface"],_i.__super__=St,_i.prototype=T(St.prototype,{axis:function(){return this._axis},xaxis:function(){return this._xaxis},base:function(){return this._base},height:function(){return this._height},radius:function(){return this._radius},__class__:_i});var Fn=p.geom.EllipseArc=function(n,r,s,o,c){Tt.call(this,mt.ellipseArc(n,r,s,o,c)),this._center=n,this._xaxis=r,this._yaxis=s,this._minAngle=o,this._maxAngle=c};x["verb.geom.EllipseArc"]=Fn,Fn.__name__=["verb","geom","EllipseArc"],Fn.__super__=Tt,Fn.prototype=T(Tt.prototype,{center:function(){return this._center},xaxis:function(){return this._xaxis},yaxis:function(){return this._yaxis},minAngle:function(){return this._minAngle},maxAngle:function(){return this._maxAngle},__class__:Fn});var vi=p.geom.Ellipse=function(n,r,s){Fn.call(this,n,r,s,0,Math.PI*2)};x["verb.geom.Ellipse"]=vi,vi.__name__=["verb","geom","Ellipse"],vi.__super__=Fn,vi.prototype=T(Fn.prototype,{__class__:vi});var yi=p.geom.ExtrudedSurface=function(n,r){St.call(this,mt.extrudedSurface(m.normalized(r),m.norm(r),n.asNurbs())),this._profile=n,this._direction=r};x["verb.geom.ExtrudedSurface"]=yi,yi.__name__=["verb","geom","ExtrudedSurface"],yi.__super__=St,yi.prototype=T(St.prototype,{profile:function(){return this._profile},direction:function(){return this._direction},__class__:yi});var Vn=p.geom.Intersect=function(){};x["verb.geom.Intersect"]=Vn,Vn.__name__=["verb","geom","Intersect"],Vn.curves=function(n,r,s){return s==null&&(s=.001),ot.curves(n.asNurbs(),r.asNurbs(),s)},Vn.curvesAsync=function(n,r,s){return s==null&&(s=.001),wt.dispatchMethod(ot,"curves",[n.asNurbs(),r.asNurbs(),s])},Vn.curveAndSurface=function(n,r,s){return s==null&&(s=.001),ot.curveAndSurface(n.asNurbs(),r.asNurbs(),s)},Vn.curveAndSurfaceAsync=function(n,r,s){return s==null&&(s=.001),wt.dispatchMethod(ot,"curveAndSurface",[n.asNurbs(),r.asNurbs(),s])},Vn.surfaces=function(n,r,s){return s==null&&(s=.001),ot.surfaces(n.asNurbs(),r.asNurbs(),s).map(function(o){return new Tt(o)})},Vn.surfacesAsync=function(n,r,s){return s==null&&(s=.001),wt.dispatchMethod(ot,"surfaces",[n.asNurbs(),r.asNurbs(),s]).then(function(o){return o.map(function(c){return new Tt(c)})})};var bi=p.geom.Line=function(n,r){Tt.call(this,mt.polyline([n,r])),this._start=n,this._end=r};x["verb.geom.Line"]=bi,bi.__name__=["verb","geom","Line"],bi.__super__=Tt,bi.prototype=T(Tt.prototype,{start:function(){return this._start},end:function(){return this._end},__class__:bi});var xi=p.geom.RevolvedSurface=function(n,r,s,o){St.call(this,mt.revolvedSurface(n.asNurbs(),r,s,o)),this._profile=n,this._center=r,this._axis=s,this._angle=o};x["verb.geom.RevolvedSurface"]=xi,xi.__name__=["verb","geom","RevolvedSurface"],xi.__super__=St,xi.prototype=T(St.prototype,{profile:function(){return this._profile},center:function(){return this._center},axis:function(){return this._center},angle:function(){return this._angle},__class__:xi});var wi=p.geom.SphericalSurface=function(n,r){St.call(this,mt.sphericalSurface(n,[0,0,1],[1,0,0],r)),this._center=n,this._radius=r};x["verb.geom.SphericalSurface"]=wi,wi.__name__=["verb","geom","SphericalSurface"],wi.__super__=St,wi.prototype=T(St.prototype,{center:function(){return this._center},radius:function(){return this._radius},__class__:wi});var Ai=p.geom.SweptSurface=function(n,r){St.call(this,mt.rationalTranslationalSurface(n.asNurbs(),r.asNurbs())),this._profile=n,this._rail=r};x["verb.geom.SweptSurface"]=Ai,Ai.__name__=["verb","geom","SweptSurface"],Ai.__super__=St,Ai.prototype=T(St.prototype,{profile:function(){return this._profile},rail:function(){return this._rail},__class__:Ai});function Xe(n){return n instanceof Array?function(){return O.iter(n)}:typeof n.iterator=="function"?Re(n,n.iterator):n.iterator}var Zs,vu=0;function Re(n,r){if(r==null)return null;r.__id__==null&&(r.__id__=vu++);var s;return n.hx__closures__==null?n.hx__closures__={}:s=n.hx__closures__[r.__id__],s==null&&(s=function(){return s.method.apply(s.scope,arguments)},s.scope=n,s.method=r,n.hx__closures__[r.__id__]=s),s}x.Math=Math,String.prototype.__class__=x.String=String,String.__name__=["String"],x.Array=Array,Array.__name__=["Array"],Date.prototype.__class__=x.Date=Date,Date.__name__=["Date"];var yu=x.Int={__name__:["Int"]},bu=x.Dynamic={__name__:["Dynamic"]},nh=x.Float=Number;nh.__name__=["Float"];var rh=x.Bool=Boolean;rh.__ename__=["Bool"];var ih=x.Class={__name__:["Class"]},sh={};Array.prototype.map==null&&(Array.prototype.map=function(n){for(var r=[],s=0,o=this.length;s<o;){var c=s++;r[c]=n(this[c])}return r}),Array.prototype.filter==null&&(Array.prototype.filter=function(n){for(var r=[],s=0,o=this.length;s<o;){var c=s++,d=this[c];n(d)&&r.push(d)}return r});var Qs={},ns=S.ArrayBuffer||ce;ns.prototype.slice==null&&(ns.prototype.slice=ce.sliceImpl),S.DataView;var Js=S.Uint8Array||nn._new;(function(n,r){if(n.setImmediate)return;var s=1,o={},c=!1,d=n.document,g;function _(D){return o[s]=v.apply(r,D),s++}function v(D){var V=[].slice.call(arguments,1);return function(){typeof D=="function"?D.apply(r,V):new Function(""+D)()}}function w(D){if(c)setTimeout(v(w,D),0);else{var V=o[D];if(V){c=!0;try{V()}finally{P(D),c=!1}}}}function P(D){delete o[D]}function A(){g=function(){var D=_(arguments);return process.nextTick(v(w,D)),D}}function I(){if(n.postMessage&&!n.importScripts){var D=!0,V=n.onmessage;return n.onmessage=function(){D=!1},n.postMessage("","*"),n.onmessage=V,D}}function M(){var D="setImmediate$"+Math.random()+"$",V=function(U){U.source===n&&typeof U.data=="string"&&U.data.indexOf(D)===0&&w(+U.data.slice(D.length))};n.addEventListener?n.addEventListener("message",V,!1):n.attachEvent("onmessage",V),g=function(){var U=_(arguments);return n.postMessage(D+U,"*"),U}}function k(){var D=new MessageChannel;D.port1.onmessage=function(V){var U=V.data;w(U)},g=function(){var V=_(arguments);return D.port2.postMessage(V),V}}function z(){var D=d.documentElement;g=function(){var V=_(arguments),U=d.createElement("script");return U.onreadystatechange=function(){w(V),U.onreadystatechange=null,D.removeChild(U),U=null},D.appendChild(U),V}}function N(){g=function(){var D=_(arguments);return setTimeout(v(w,D),0),D}}var B=Object.getPrototypeOf&&Object.getPrototypeOf(n);B=B&&B.setTimeout?B:n,{}.toString.call(n.process)==="[object process]"?A():I()?M():n.MessageChannel?k():d&&"onreadystatechange"in d.createElement("script")?z():N(),B.setImmediate=g,B.clearImmediate=P})(new Function("return this")()),qt.USE_CACHE=!1,qt.USE_ENUM_INDEX=!1,qt.BASE64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:",Gt.DEFAULT_RESOLVER=gt,Gt.BASE64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:",Nt.count=0,he.i64tmp=function(n){var r,s=new Wt(0,0);return r=s,r}(),kt.__toStr={}.toString,nn.BYTES_PER_ELEMENT=1,At.queue=new G,Ot.memo=new xt,rt.TOLERANCE=1e-6,rt.EPSILON=1e-10,rt.VERSION="2.0.0",bt.Tvalues=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],bt.Cvalues=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],wt.THREADS=1,wt._init=!1,Rn.basePath="",ar.uuid=0,ts.main()}(typeof console<"u"?console:{log:function(){}},e,typeof u<"u"?u:typeof i<"u"?i:typeof self<"u"?self:this),e})})(nl);var uu=nl.exports;const _r=cu(uu);class Bs{constructor(){this.c0=0,this.c1=0,this.c2=0,this.c3=0}init(t,e,i,l){this.c0=t,this.c1=i,this.c2=-3*t+3*e-2*i-l,this.c3=2*t-2*e+i+l}initCatmullRom(t,e,i,l,h){this.init(e,i,h*(i-t),h*(l-e))}initNonuniformCatmullRom(t,e,i,l,h,u,f){let b=(e-t)/h-(i-t)/(h+u)+(i-e)/u,p=(i-e)/u-(l-e)/(u+f)+(l-i)/f;b*=u,p*=u,this.init(e,i,b,p)}calc(t){const e=t*t,i=e*t;return this.c0+this.c1*t+this.c2*e+this.c3*i}}class rl extends Jr{constructor(t=[],e=!1,i="centripetal",l=.5){super(),this.isCatmullRomCurve3d=!0,this.type="CatmullRomCurve3d",this._tmp=new Z,this._px=new Bs,this._py=new Bs,this._pz=new Bs,this._points=t.map(h=>new X(h)),this._closed=e,this._curveType=i,this._tension=l}get points(){return this._points}get closed(){return this._closed}get curveType(){return this._curveType}get tension(){return this._tension}get startPoint(){return this._points.length>0?this._points[0]:new X}get endPoint(){return this._points.length>0?this._points[this._points.length-1]:new X}get length(){if(this._points.length<2)return 0;let t=0;for(let e=1;e<this._points.length;e++)t+=this._points[e-1].distanceTo(this._points[e]);return this._closed&&this._points.length>2&&(t+=this._points[this._points.length-1].distanceTo(this._points[0])),t}getPoint(t,e=new X){const i=e,l=this._points,h=l.length;if(h===0)return i.set(0,0,0);if(h===1)return i.copy(l[0]);const u=(h-(this._closed?0:1))*t;let f=Math.floor(u),b=u-f;this._closed?f+=f>0?0:(Math.floor(Math.abs(f)/h)+1)*h:b===0&&f===h-1&&(f=h-2,b=1);let p,S;this._closed||f>0?p=l[(f-1)%h]:(this._tmp.subVectors(l[0],l[1]).add(l[0]),p=new X(this._tmp.x,this._tmp.y,this._tmp.z));const x=l[f%h],E=l[(f+1)%h];if(this._closed||f+2<h?S=l[(f+2)%h]:(this._tmp.subVectors(l[h-1],l[h-2]).add(l[h-1]),S=new X(this._tmp.x,this._tmp.y,this._tmp.z)),this._curveType==="centripetal"||this._curveType==="chordal"){const T=this._curveType==="chordal"?.5:.25;let O=Math.pow(p.distanceToSquared(x),T),R=Math.pow(x.distanceToSquared(E),T),G=Math.pow(E.distanceToSquared(S),T);R<1e-4&&(R=1),O<1e-4&&(O=R),G<1e-4&&(G=R),this._px.initNonuniformCatmullRom(p.x,x.x,E.x,S.x,O,R,G),this._py.initNonuniformCatmullRom(p.y,x.y,E.y,S.y,O,R,G),this._pz.initNonuniformCatmullRom(p.z,x.z,E.z,S.z,O,R,G)}else this._curveType==="catmullrom"&&(this._px.initCatmullRom(p.x,x.x,E.x,S.x,this._tension),this._py.initCatmullRom(p.y,x.y,E.y,S.y,this._tension),this._pz.initCatmullRom(p.z,x.z,E.z,S.z,this._tension));return i.set(this._px.calc(b),this._py.calc(b),this._pz.calc(b)),i}getPoints(t){const e=[];for(let i=0;i<=t;i++)e.push(this.getPoint(i/t));return e}setPoints(t){this._points=t.map(e=>new X(e)),this._boundingBoxNeedsUpdate=!0}setClosed(t){this._closed!==t&&(this._closed=t,this._boundingBoxNeedsUpdate=!0)}setCurveType(t){this._curveType=t}setTension(t){this._tension=t}transform(t){return this._points=this._points.map(e=>{const i=new X;return i.copy(e),i.applyMatrix3d(t),i}),this._boundingBoxNeedsUpdate=!0,this}calculateBoundingBox(){if(this._points.length===0)return new Rt;const t=new Rt;return this._points.forEach(e=>{t.expandByPoint(e)}),t}}class tr{constructor(t,e,i,l){this._degree=t,this._knots=[...e],this._controlPoints=i.map(h=>({x:h.x,y:h.y,z:h.z})),this._weights=l?[...l]:new Array(i.length).fill(1)}degree(){return this._degree}knots(){return[...this._knots]}controlPoints(){return this._controlPoints.map(t=>({x:t.x,y:t.y,z:t.z}))}weights(){return[...this._weights]}point(t){const e=this._controlPoints.map(i=>[i.x,i.y,i.z]);return Zr(t,this._degree,this._knots,e,this._weights)}length(){const t=this._controlPoints.map(e=>[e.x,e.y,e.z]);return Wo(this._degree,this._knots,t,this._weights)}static byKnotsControlPointsWeights(t,e,i,l){return new tr(t,e,i,l)}static byPoints(t,e,i="Uniform"){let l;switch(i){case"Chord":l=Go(e,t);break;case"SqrtChord":l=Ho(e,t);break;case"Uniform":default:l=jo(e,t.length);break}const h=t.map(f=>({x:f[0],y:f[1],z:f[2]})),u=new Array(h.length).fill(1);return new tr(e,l,h,u)}getParameterRange(){const t=this._knots[this._degree],e=this._knots[this._knots.length-this._degree-1];return{start:t,end:e}}getPoints(t){const e=[],{start:i,end:l}=this.getParameterRange();for(let h=0;h<=t;h++){const u=i+(l-i)*(h/t);e.push(this.point(u))}return e}isClosed(t=1e-6){const{start:e,end:i}=this.getParameterRange(),l=this.point(e),h=this.point(i),u=l[0]-h[0],f=l[1]-h[1],b=l[2]-h[2];return Math.sqrt(u*u+f*f+b*b)<t}static createFitPointsForClosedCurve(t){if(t.length<4)throw new Error("At least 4 points are required for a closed NURBS curve");const e=new rl(t,!0,"centripetal"),i=Math.max(50,t.length*2);return e.getPoints(i)}static createClosedCurve(t,e,i="Chord"){const l=this.createFitPointsForClosedCurve(t).map(h=>[h.x,h.y,h.z]);return tr.byPoints(l,e,i)}}class kn extends Jr{constructor(t,e,i,l,h){super();const u=arguments.length;if(u<2||u>5)throw Ie.ILLEGAL_PARAMETERS;if(this._degree=3,this._closed=!1,Array.isArray(e)){this._controlPoints=t;let f,b=3,p=!1;if(u>=3&&(Array.isArray(i)?(f=i,u>=4&&(b=l||3),u>=5&&(p=h)):i!==void 0&&(b=i||3,u>=4&&(p=l))),i===void 0&&u>=4&&(b=l||3,u>=5&&(p=h)),this._degree=b,this._closed=p,this._controlPoints.length<this._degree+1)throw Ie.ILLEGAL_PARAMETERS;const S=this.toVerbPoints(this._controlPoints);this._nurbsCurve=_r.geom.NurbsCurve.byKnotsControlPointsWeights(this._degree,e,S,f)}else{if(this._fitPoints=t,this._knotParameterization=e,u>=3&&(this._degree=i||3),u>=4&&(this._closed=l),this._fitPoints.length<this._degree+1)throw Ie.ILLEGAL_PARAMETERS;const f=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=_r.geom.NurbsCurve.byPoints(f,this._degree),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}}buildCurve(){if(this._fitPoints&&this._knotParameterization){if(this._closed){const t=tr.createFitPointsForClosedCurve(this._fitPoints),e=this.toNurbsPoints(t);this._nurbsCurve=_r.geom.NurbsCurve.byPoints(e,this._degree)}else{const t=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=_r.geom.NurbsCurve.byPoints(t,this._degree)}this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}else if(this._controlPoints)if(this._closed){const t=tr.createFitPointsForClosedCurve(this._controlPoints),e=this.toNurbsPoints(t);this._nurbsCurve=_r.geom.NurbsCurve.byPoints(e,this._degree),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}else{const t=this._nurbsCurve.knots(),e=this._nurbsCurve.weights(),i=this.toVerbPoints(this._controlPoints);this._nurbsCurve=_r.geom.NurbsCurve.byKnotsControlPointsWeights(this._degree,t,i,e)}}setClosed(t){this._closed!==t&&(this._closed=t,this._boundingBoxNeedsUpdate=!0,this.buildCurve())}get degree(){return this._degree}get knotParameterization(){return this._knotParameterization}get startPoint(){const t=this._nurbsCurve.knots(),e=this._nurbsCurve.degree(),i=t[e],l=this._nurbsCurve.point(i);return new X(l[0],l[1],l[2])}get endPoint(){const t=this._nurbsCurve.knots(),e=this._nurbsCurve.degree(),i=t[t.length-e-1],l=this._nurbsCurve.point(i);return new X(l[0],l[1],l[2])}get length(){return this._nurbsCurve.length()}getFitPointAt(t){if(!this._fitPoints)throw new Error("No fit points in this spline");const e=this._fitPoints.length,i=t<0||t>=e?e-1:t,l=this._fitPoints[i];return{x:l.x,y:l.y,z:l.z||0}}getControlPointAt(t){const e=this._controlPoints.length,i=t<0||t>=e?e-1:t;return this._controlPoints[i]}getPoints(t=100){const e=this._nurbsCurve,i=[],l=e.knots(),h=this._nurbsCurve.degree(),u=l[h],f=l[l.length-h-1],b=(f-u)/(t-1);for(let p=0;p<t;p++){const S=p===t-1?f:u+p*b,x=e.point(S);i.push(new X(x[0],x[1],x[2]))}return i}getCurvePoints(t,e){const i=[],l=t.knots(),h=l[3],u=(l[l.length-4]-h)/(e-1);for(let f=0;f<e;f++){const b=h+f*u;i.push(t.point(b))}return i}calculateBoundingBox(){const t=this.getPoints(100);return new Rt().setFromPoints(t)}get closed(){return this._closed}set closed(t){this.setClosed(t)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}toNurbsPoints(t){const e=new Array(t.length);return t.forEach((i,l)=>{e[l]=[i.x,i.y,i.z||0]}),e}toVerbPoints(t){const e=new Array(t.length);return t.forEach((i,l)=>{e[l]=[i.x,i.y,i.z||0]}),e}toGePoints(t){const e=new Array(t.length);return t.forEach((i,l)=>{e[l]={x:i[0],y:i[1],z:i[2]}}),e}static createClosedSpline(t,e="Uniform",i=3){if(t.length<i+1)throw new Error(`At least ${i+1} points are required for a degree ${i} closed spline`);return new kn(t,e,i,!0)}}for(var er=256,il=[],sl=256,Yi;er--;)il[er]=(er+256).toString(16).substring(1);function du(a){var t=0,e=11;if(!Yi||er+e>sl*2)for(Yi="",er=0;t<sl;t++)Yi+=il[Math.random()*256|0];return Yi.substring(er,er+++e)}class Tn{constructor(t,e){t=t||{},cr(t,{objectId:du()}),this._attrs=new ca(t,e)}get attrs(){return this._attrs}getAttr(t){const e=this._attrs.get(t);if(e===void 0)throw new Error(`[AcDbObject] Attribute name '${t}' does't exist in this object!`);return e}getAttrWithoutException(t){return this._attrs.get(t)}setAttr(t,e){this._attrs.set(t,e)}get objectId(){return this.getAttr("objectId")}set objectId(t){this._attrs.set("objectId",t)}get ownerId(){return this.getAttr("ownerId")}set ownerId(t){this._attrs.set("ownerId",t)}get database(){return this._database?this._database:Xs().workingDatabase}set database(t){this._database=t}close(){}}class tn extends Tn{constructor(){super(...arguments),this._layer="0",this._color=new jn,this._lineType=Ri,this._lineWeight=1,this._linetypeScale=-1,this._visibility=!0,this._transparency=0}get type(){return this.constructor.name.substring(4)}get layer(){return this._layer}set layer(t){this._layer=t}get color(){return this._color}set color(t){this._color.copy(t)}get rgbColor(){let t=this.database.cecolor;if(this.color.isByLayer){const e=this.getLayerColor();e&&e.color&&(t=e)}else this.color.isByBlock||this.color.color!=null&&(t=this.color);return t.color==null?16777215:t.color}get lineType(){return this._lineType}set lineType(t){this._lineType=t||Ri}get lineWeight(){return this._lineWeight}set lineWeight(t){this._lineWeight=t}get linetypeScale(){return this._linetypeScale}set linetypeScale(t){this._linetypeScale=t}get visibility(){return this._visibility}set visibility(t){this._visibility=t}get transparency(){return this._transparency}set transparency(t){this._transparency=t}subGetGripPoints(){return new Array}subGetOsnapPoints(t,e,i,l,h){}transformBy(t){return this}triggerModifiedEvent(){this.database.events.entityModified.dispatch({database:this.database,entity:this})}get lineStyle(){var i;const t=this.getLineType(),e=(i=this.database)==null?void 0:i.tables.linetypeTable.getAt(t);return e?{...e.linetype,color:this.rgbColor}:{name:t,standardFlag:0,color:this.rgbColor,description:"",totalPatternLength:0}}getLineType(){if(this.lineType==Ri){const t=this.database.tables.layerTable.getAt(this.layer);if(t&&t.linetype)return t.linetype}else return this.lineType==po?Oi:this.lineType;return Oi}getLayerColor(){const t=this.database.tables.layerTable.getAt(this.layer);if(t==null)console.error(`The layer with name '${this.layer}' not found in drawing database!`);else return t.color;return null}}class Fs extends tn{constructor(t){super(),this._blockName=t,this._position=new X,this._rotation=0,this._normal=new Z(0,0,1),this._scaleFactors=new X(1,1,1)}get position(){return this._position}set position(t){this._position.copy(t)}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get scaleFactors(){return this._scaleFactors}set scaleFactors(t){this._scaleFactors.copy(t)}get normal(){return this._normal}set normal(t){this._normal.copy(t).normalize()}get blockTableRecord(){return this.database.tables.blockTable.getAt(this._blockName)}get geometricExtents(){const t=new Rt,e=this.blockTableRecord;if(e!=null){const h=e.newIterator();for(const u of h)t.union(u.geometricExtents)}const i=new In().setFromEuler(new Qo(this.rotation,0,0)),l=new Zn;return l.compose(this.position,i,this.scaleFactors),t.applyMatrix4(l),t}draw(t){const e=[],i=this.blockTableRecord;if(i!=null){const l=this.computeTransformMatrix();return Sn.instance.draw(t,i,this.rgbColor,!0,l,this.normal)}else return t.group(e)}computeTransformMatrix(){const t=new In;return t.setFromAxisAngle(Z.Z_AXIS,this.rotation),new Zn().compose(this._position,t,this._scaleFactors)}}class qe extends tn{}class al extends qe{constructor(t,e,i,l,h,u,f){super(),this._geo=new Wi(t,e,i,l,h,u,f)}get center(){return this._geo.center}set center(t){this._geo.center=t}get majorAxisRadius(){return this._geo.majorAxisRadius}set majorAxisRadius(t){this._geo.majorAxisRadius=t}get minorAxisRadius(){return this._geo.minorAxisRadius}set minorAxisRadius(t){this._geo.minorAxisRadius=t}get normal(){return this._geo.normal}set normal(t){this._geo.normal=t}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}draw(t){return t.ellipticalArc(this._geo,this.lineStyle)}}class ol extends qe{constructor(t,e,i,l){super(),this._geo=new Jn(t,e,i,l,Z.Z_AXIS,Z.X_AXIS)}get center(){return this._geo.center}set center(t){this._geo.center=t}get radius(){return this._geo.radius}set radius(t){this._geo.radius=t}get startAngle(){return this._geo.startAngle}set startAngle(t){this._geo.startAngle=t}get endAngle(){return this._geo.endAngle}set endAngle(t){this._geo.endAngle=t}get startPoint(){return this._geo.startPoint}get endPoint(){return this._geo.endPoint}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}subGetGripPoints(){const t=new Array;return t.push(this.center),t.push(this.startPoint),t.push(this.endPoint),t}transformBy(t){return this._geo.transform(t),this}draw(t){return t.circularArc(this._geo,this.lineStyle)}}class ll extends qe{constructor(t,e,i=Z.Z_AXIS){super(),this._geo=new Jn(t,e,0,te,i,Z.X_AXIS)}get center(){return this._geo.center}set center(t){this._geo.center=t}get radius(){return this._geo.radius}set radius(t){this._geo.radius=t}get normal(){return this._geo.normal}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}subGetGripPoints(){const t=new Array;return t.push(this.center),t}transformBy(t){return this._geo.transform(t),this}draw(t){return t.circularArc(this._geo,this.lineStyle)}}var hl=(a=>(a[a.UserDefined=0]="UserDefined",a[a.Predefined=1]="Predefined",a[a.Custom=2]="Custom",a))(hl||{}),cl=(a=>(a[a.Normal=0]="Normal",a[a.Outer=1]="Outer",a[a.Ignore=2]="Ignore",a))(cl||{});class ul extends tn{constructor(){super(),this._elevation=0,this._geo=new ji,this._definitionLines=[],this._patternName="",this._patternType=1,this._patternAngle=0,this._patternScale=1,this._hatchStyle=0}get definitionLines(){return this._definitionLines}get patternName(){return this._patternName}set patternName(t){this._patternName=t}get patternType(){return this._patternType}set patternType(t){this._patternType=t}get patternAngle(){return this._patternAngle}set patternAngle(t){this._patternAngle=t}get patternScale(){return this._patternScale}set patternScale(t){this._patternScale=t}get hatchStyle(){return this._hatchStyle}set hatchStyle(t){this._hatchStyle=t}add(t){this._geo.add(t)}get geometricExtents(){const t=this._geo.box;return new Rt({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}draw(t){return t.area(this._geo,{color:this.rgbColor,solidFill:!1,patternAngle:this.patternAngle,patternLines:this.definitionLines})}}var dl=(a=>(a[a.MText=0]="MText",a[a.Fcf=1]="Fcf",a[a.BlockReference=2]="BlockReference",a[a.NoAnnotation=3]="NoAnnotation",a))(dl||{});class ml extends qe{constructor(){super(),this._isSplined=!1,this._updated=!1,this._hasArrowHead=!1,this._vertices=[],this._dimensionStyle="",this._hasHookLine=!1,this._annoType=3}get isSplined(){return this._isSplined}set isSplined(t){this._isSplined=t}get hasArrowHead(){return this._hasArrowHead}set hasArrowHead(t){this._hasArrowHead=t}get hasHookLine(){return this._hasHookLine}set hasHookLine(t){this._hasHookLine=t}get numVertices(){return this._vertices.length}get dimensionStyle(){return this._dimensionStyle}set dimensionStyle(t){this._dimensionStyle=t}get annoType(){return this._annoType}set annoType(t){this._annoType=t}appendVertex(t){this._vertices.push(new X().copy(t)),this._updated=!0}setVertexAt(t,e){throw(t<0||t>=this._vertices.length)&&(this._vertices[t].copy(e),this._updated=!0),new Error("The vertex index is out of range!")}vertexAt(t){throw(t<0||t>=this._vertices.length)&&this._vertices[t],new Error("The vertex index is out of range!")}get geometricExtents(){return this._isSplined&&this.splineGeo?this.splineGeo.calculateBoundingBox():new Rt().setFromPoints(this._vertices)}get closed(){return!1}set closed(t){}draw(t){if(this.isSplined&&this.splineGeo){const e=this.splineGeo.getPoints(100);return t.lines(e,this.lineStyle)}else return t.lines(this._vertices,this.lineStyle)}get splineGeo(){return this.createSplineIfNeeded(),this._splineGeo}createSplineIfNeeded(){this.isSplined&&this.numVertices>=2&&(this._splineGeo==null||this._updated)&&(this._splineGeo=new kn(this._vertices,"Uniform"),this._updated=!1)}}class gl extends qe{constructor(t,e){super(),this._geo=new Mn(t,e)}get startPoint(){return this._geo.startPoint}set startPoint(t){this._geo.startPoint=t}get endPoint(){return this._geo.endPoint}set endPoint(t){this._geo.endPoint=t}get midPoint(){return this._geo.midPoint}get geometricExtents(){return this._geo.box}get closed(){return!1}subGetGripPoints(){const t=new Array;return t.push(this.midPoint),t.push(this.startPoint),t.push(this.endPoint),t}subGetOsnapPoints(t,e,i,l,h){const u=this.startPoint,f=this.endPoint;switch(t){case Xn.EndPoint:h.push(u),h.push(f);break;case Xn.MidPoint:h.push(this.midPoint);break;case Xn.Nearest:{const b=this._geo.project(i);h.push(b)}break;case Xn.Perpendicular:{const b=this._geo.perpPoint(i);h.push(b)}break;case Xn.Tangent:h.push(u);break}}transformBy(t){return this._geo.transform(t),this}draw(t){const e=this.startPoint,i=this.endPoint,l=[new X(e.x,e.y,0),new X(i.x,i.y,0)];return t.lines(l,this.lineStyle)}}var Vs=(a=>(a.ClosedFilled="",a.Dot="_DOT",a.DotSmall="_DOTSMALL",a.DotBlank="_DOTBLANK",a.Origin="_ORIGIN",a.Origin2="_ORIGIN2",a.Open="_OPEN",a.Open90="_OPEN90",a.Open30="_OPEN30",a.Closed="_CLOSED",a.Small="_SMALL",a.None="_NONE",a.Oblique="_OBLIQUE",a.BoxFilled="_BOXFILLED",a.Box="_BOXBLANK",a.ClosedBlank="_CLOSEDBLANK",a.DatumBlank="_DATUMBLANK",a.DatumFilled="_DATUMFILLED",a.Integral="_INTEGRAL",a.ArchTick="_ARCHTICK",a))(Vs||{}),Ki=(a=>(a[a.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",a[a.RIGHT_TO_LEFT=2]="RIGHT_TO_LEFT",a[a.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",a[a.BOTTOM_TO_TOP=4]="BOTTOM_TO_TOP",a[a.BY_STYLE=5]="BY_STYLE",a))(Ki||{}),vr=(a=>(a[a.TopLeft=1]="TopLeft",a[a.TopCenter=2]="TopCenter",a[a.TopRight=3]="TopRight",a[a.MiddleLeft=4]="MiddleLeft",a[a.MiddleCenter=5]="MiddleCenter",a[a.MiddleRight=6]="MiddleRight",a[a.BottomLeft=7]="BottomLeft",a[a.BottomCenter=8]="BottomCenter",a[a.BottomRight=9]="BottomRight",a))(vr||{}),Us=(a=>(a[a.OPTIMIZED_2D=0]="OPTIMIZED_2D",a[a.WIREFRAME=1]="WIREFRAME",a[a.HIDDEN_LINE=2]="HIDDEN_LINE",a[a.FLAT_SHADED=3]="FLAT_SHADED",a[a.GOURAUD_SHADED=4]="GOURAUD_SHADED",a[a.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",a[a.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME",a))(Us||{}),js=(a=>(a[a.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",a[a.TOP=1]="TOP",a[a.BOTTOM=2]="BOTTOM",a[a.FRONT=3]="FRONT",a[a.BACK=4]="BACK",a[a.LEFT=5]="LEFT",a[a.RIGHT=6]="RIGHT",a))(js||{}),Gs=(a=>(a[a.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",a[a.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS",a))(Gs||{});class Xi{constructor(){this._number=-1,this._id="",this._groupId="",this._centerPoint=new X,this._height=0,this._width=0,this._viewCenter=new X,this._viewHeight=0}get number(){return this._number}set number(t){this._number=t}get id(){return this._id}set id(t){this._id=t}get groupId(){return this._groupId}set groupId(t){this._groupId=t}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get box(){const t=new me;return t.setFromCenterAndSize(this.centerPoint,{x:this.width,y:this.height}),t}get viewCenter(){return this._viewCenter}set viewCenter(t){this._viewCenter.copy(t)}get viewHeight(){return this._viewHeight}set viewHeight(t){this._viewHeight=t}get viewWidth(){return this.viewHeight*(this.width/this.height)}get viewBox(){const t=new me;return t.setFromCenterAndSize(this.viewCenter,{x:this.viewWidth,y:this.viewHeight}),t}clone(){const t=new Xi;return t.id=this.id,t.groupId=this.groupId,t.number=this.number,t.centerPoint.copy(this.centerPoint),t.height=this.height,t.width=this.width,t.viewCenter.copy(this.viewCenter),t.viewHeight=this.viewHeight,t}copy(t){return this.id=t.id,this.groupId=t.groupId,this.number=t.number,this.centerPoint.copy(t.centerPoint),this.height=t.height,this.width=t.width,this.viewCenter.copy(t.viewCenter),this.viewHeight=t.viewHeight,this}}class fl extends tn{constructor(){super(),this._contents="",this._height=0,this._width=0,this._lineSpacingFactor=.25,this._lineSpacingStyle=0,this._backgroundFill=!1,this._backgroundFillColor=13158600,this._backgroundFillTransparency=1,this._backgroundScaleFactor=1,this._rotation=0,this._styleName="",this._location=new X,this._attachmentPoint=vr.TopLeft,this._direction=new Z(1,0,0),this._drawingDirection=Ki.LEFT_TO_RIGHT}get contents(){return this._contents}set contents(t){this._contents=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get lineSpacingFactor(){return this._lineSpacingFactor}set lineSpacingFactor(t){this._lineSpacingFactor=t}get lineSpacingStyle(){return this._lineSpacingStyle}set lineSpacingStyle(t){this._lineSpacingStyle=t}get backgroundFill(){return this._backgroundFill}set backgroundFill(t){this._backgroundFill=t,this._backgroundFillColor=13158600}get backgroundFillColor(){return this._backgroundFillColor}set backgroundFillColor(t){this._backgroundFillColor=t}get backgroundFillTransparency(){return this._backgroundFillTransparency}set backgroundFillTransparency(t){this._backgroundFillTransparency=t}get backgroundScaleFactor(){return this._backgroundScaleFactor}set backgroundScaleFactor(t){this._backgroundScaleFactor=t}get styleName(){return this._styleName}set styleName(t){this._styleName=t}get location(){return this._location}set location(t){this._location.copy(t)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(t){this._attachmentPoint=t}get direction(){return this._direction}set direction(t){this._direction.copy(t)}get drawingDirection(){return this._drawingDirection}set drawingDirection(t){this._drawingDirection=t}get geometricExtents(){return new Rt}getTextStyle(){const t=this.database.tables.textStyleTable;let e=t.getAt(this.styleName);return e||(e=t.getAt("STANDARD")||t.getAt("Standard")),e.textStyle}draw(t){const e={text:this.contents,height:this.height,width:this.width,position:this.location,rotation:this.rotation,directionVector:this.direction,attachmentPoint:this.attachmentPoint,drawingDirection:this.drawingDirection,lineSpaceFactor:this.lineSpacingFactor},i={...this.getTextStyle(),color:this.rgbColor};return t.mtext(e,i)}}class Hs extends qe{constructor(t,e,i,l,h){super();const u=+(t!==void 0)+ +(e!==void 0)+ +(i!==void 0)+ +(l!==void 0)+ +(h!==void 0);if(u<2||u>5)throw Ie.ILLEGAL_PARAMETERS;!Array.isArray(e)?this._geo=new kn(t,e,i,l):this._geo=new kn(t,e,i,l,h)}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}draw(t){const e=this._geo.getPoints(100);return t.lines(e,this.lineStyle)}}const mu=new Z;class pl extends Fs{constructor(t,e,i){super(t),this._attachmentPoint=vr.TopLeft,this._numColumns=i,this._numRows=e,this._columnWidth=new Array(i),this._rowHeight=new Array(e),this._cells=new Array(e*i)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(t){this._attachmentPoint=t}get numRows(){return this._numRows}set numRows(t){this._numRows=t}get numColumns(){return this._numColumns}set numColumns(t){this._numColumns=t}numContents(t,e){return 1}rowHeight(t){return this._rowHeight[t]}setRowHeight(t,e){this._rowHeight[t]=e}setUniformRowHeight(t){this._rowHeight.fill(t)}columnWidth(t){return this._columnWidth[t]}setUniformColumnWidth(t){this._columnWidth.fill(t)}setColumnWidth(t,e){this._columnWidth[t]=e}cell(t){if(!(t<0||t>=this._cells.length))return this._cells[t]}setCell(t,e){this._cells[t]=e}textString(t,e,i){return this._cells[t*e].text}setTextString(t,e,i){this._cells[t*e].text=i}isEmpty(t,e){return!this._cells[t*e].text}get geometricExtents(){return new Rt}draw(t){let e=0,i=0;const l=new Uint16Array(this.numColumns*this.numRows*8),h=new Float32Array((this.numColumns+1)*(this.numRows+1)*3);let u=0;for(let E=0;E<=this.numRows;E++){e-=E>0?this.rowHeight(E-1):0,i=0;for(let T=0;T<=this.numColumns;T++)i+=T>0?this.columnWidth(T-1):0,h[u++]=i,h[u++]=e,h[u++]=0}const f=[],b=new Array(this.numRows*this.numColumns).fill(!1);i=0,u=0;let p=0;for(let E=0;E<this.numColumns;E++){i+=E>0?this.columnWidth(E-1):0,e=0;for(let T=0;T<this.numRows;T++){e+=T>0?this.rowHeight(T-1):0;const O=this.cell(T*this.numColumns+E);if(p=T*this.numColumns+E,O&&!b[p]){const R=O.borderWidth??1,G=O.borderHeight??1;this.fillVisited(b,p,this.numColumns,R,G),l[u++]=E+T*(this.numColumns+1),l[u++]=E+T*(this.numColumns+1)+R;const F=h[l[u-1]*3]-i,pt=E+(T+G)*(this.numColumns+1)+R;E+R==this.numColumns&&(l[u++]=E+T*(this.numColumns+1)+R,l[u++]=pt);const _t=-h[pt*3+1]-e;if(T+G==this.numRows&&(l[u++]=E+(T+G)*(this.numColumns+1)+G,l[u++]=E+(T+G)*(this.numColumns+1)),l[u++]=E+(T+G)*(this.numColumns+1),l[u++]=E+T*(this.numColumns+1),O.text){const ut=O.attachmentPoint||this.attachmentPoint||vr.MiddleCenter,W=this.getTableTextOffset(ut,F,_t),gt={text:O.text,height:O.textHeight,width:F,position:mu.set(i,-e,0).clone().add(W),rotation:this.rotation,attachmentPoint:ut},ht={...this.getTextStyle(O),color:this.color.color};f.push(t.mtext(gt,ht))}}}}f.push(t.lineSegments(h,3,l,this.lineStyle));const S=t.group(f),x=new In;return x.setFromAxisAngle(Z.Z_AXIS,this.rotation),_l.compose(this.position,x,this.scaleFactors),S.applyMatrix(_l),S}fillVisited(t,e,i,l,h){if(h==1&&l==1)t[e]=!0;else for(let u=0;u<l;++u)for(let f=0;f<h;++f)t[e+u+f*i]=!0}getTextStyle(t){const e=this.database.tables.textStyleTable;let i;return t.textStyle&&(i=e.getAt(t.textStyle)),i||(i=e.getAt("STANDARD")||e.getAt("Standard")),i.textStyle}getTableTextOffset(t,e,i){const l=new Z;switch(t){case 1:break;case 2:l.setX(e/2);break;case 3:l.setX(e);break;case 4:l.setY(-i/2);break;case 5:l.set(e/2,-i/2,0);break;case 6:l.set(e,-i/2,0);break;case 7:l.setY(-i);break;case 8:l.set(e/2,-i,0);break;case 9:l.set(e,-i,0);break}return l}}const _l=new Zn;var vl=(a=>(a[a.LEFT=0]="LEFT",a[a.CENTER=1]="CENTER",a[a.RIGHT=2]="RIGHT",a[a.ALIGNED=3]="ALIGNED",a[a.MIDDLE=4]="MIDDLE",a[a.FIT=5]="FIT",a))(vl||{}),yl=(a=>(a[a.BASELINE=0]="BASELINE",a[a.BOTTOM=1]="BOTTOM",a[a.MIDDLE=2]="MIDDLE",a[a.TOP=3]="TOP",a))(yl||{});class bl extends tn{constructor(){super(),this._textString="",this._height=0,this._thickness=1,this._position=new X,this._rotation=0,this._oblique=0,this._horizontalMode=0,this._verticalModel=2,this._styleName="",this._widthFactor=1}get textString(){return this._textString}set textString(t){this._textString=t}get thickness(){return this._thickness}set thickness(t){this._thickness=t}get height(){return this._height}set height(t){this._height=t}get position(){return this._position}set position(t){this._position.copy(t)}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get oblique(){return this._oblique}set oblique(t){this._oblique=t}get horizontalMode(){return this._horizontalMode}set horizontalMode(t){this._horizontalMode=t}get verticalMode(){return this._verticalModel}set verticalMode(t){this._verticalModel=t}get styleName(){return this._styleName}set styleName(t){this._styleName=t}get widthFactor(){return this._widthFactor}set widthFactor(t){this._widthFactor=t}get geometricExtents(){return new Rt}getTextStyle(){const t=this.database.tables.textStyleTable;let e=t.getAt(this.styleName);return e||(e=t.getAt("STANDARD")||t.getAt("Standard")),e.textStyle}draw(t){const e={text:this.textString,height:this.height,width:1/0,widthFactor:this.widthFactor,position:this.position,rotation:this.rotation,drawingDirection:Ki.BOTTOM_TO_TOP,attachmentPoint:vr.BottomLeft},i={...this.getTextStyle(),color:this.rgbColor};return t.mtext(e,i)}}class xl extends qe{constructor(){super(),this._elevation=0,this._thickness=1,this._vertices=[new X,new X,new X,new X]}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get closed(){return!0}get thickness(){return this._thickness}set thickness(t){this._thickness=t}getPointAt(t){return t<0?this._vertices[0]:t>3?this._vertices[3]:this._vertices[t]}setPointAt(t,e){if(t<0&&this._vertices[0].copy(e),t>3)return this._vertices[3].copy(e);this._vertices[t].copy(e)}get geometricExtents(){return new Rt().setFromPoints(this._vertices)}subGetGripPoints(){const t=new Array;for(let e=0;e<4;++e)t.push(this.getPointAt(e));return t}draw(t){const e=new ti(this._vertices,!0),i=new ji;return i.add(e),t.area(i,{color:this.rgbColor,solidFill:!0,patternAngle:0,patternLines:[]})}}class wl extends qe{constructor(){super(),this._elevation=0,this._geo=new ti}get numberOfVertices(){return this._geo.numberOfVertices}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}addVertexAt(t,e,i=0,l=-1,h=-1){const u=l<0?void 0:l,f=h<0?void 0:h,b={x:e.x,y:e.y,bulge:i,startWidth:u,endWidth:f};this._geo.addVertexAt(t,b)}getPoint2dAt(t){return this._geo.getPointAt(t)}getPoint3dAt(t){const e=this.getPoint2dAt(t);return new X(e.x,e.y,this._elevation)}get geometricExtents(){const t=this._geo.box;return new Rt({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}subGetGripPoints(){const t=new Array;for(let e=0;e<this.numberOfVertices;++e)t.push(this.getPoint3dAt(e));return t}draw(t){const e=[];return this._geo.getPoints(100).forEach(l=>e.push(new X().set(l.x,l.y,this.elevation))),t.lines(e,this.lineStyle)}}class Al extends tn{constructor(){super(),this._geo=new X}get position(){return this._geo}set position(t){this._geo.set(t.x,t.y,t.z||0)}get geometricExtents(){return new Rt().expandByPoint(this._geo)}transformBy(t){return this._geo.applyMatrix3d(t),this}draw(t){return t.point(this._geo,{displayMode:this.database.pdmode,displaySize:this.database.pdsize,color:this.rgbColor})}}var Pl=(a=>(a[a.Invalid=0]="Invalid",a[a.Rect=1]="Rect",a[a.Poly=2]="Poly",a))(Pl||{}),Sl=(a=>(a[a.Show=1]="Show",a[a.ShowUnAligned=2]="ShowUnAligned",a[a.Clip=4]="Clip",a[a.Transparent=8]="Transparent",a))(Sl||{});class Ws extends tn{constructor(){super(),this._brightness=50,this._contrast=50,this._fade=0,this._width=0,this._height=0,this._position=new X,this._scale=new Xt(1,1),this._rotation=0,this._clipBoundaryType=1,this._clipBoundary=[],this._isClipped=!1,this._isImageShown=!0,this._isImageTransparent=!1,this._imageDefId=""}get brightness(){return this._brightness}set brightness(t){this._brightness=t}get contrast(){return this._contrast}set contrast(t){this._contrast=t}get fade(){return this._fade}set fade(t){this._fade=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get position(){return this._position}set position(t){this._position=t}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get scale(){return this._scale}set scale(t){this._scale.copy(t)}get clipBoundaryType(){return this._clipBoundaryType}set clipBoundaryType(t){this._clipBoundaryType=t}get clipBoundary(){return this._clipBoundary}set clipBoundary(t){this._clipBoundary=[],this._clipBoundary.push(...t)}get isClipped(){return this._isClipped}set isClipped(t){this._isClipped=t}get isImageShown(){return this._isImageShown}set isImageShown(t){this._isImageShown=t}get isImageTransparent(){return this._isImageTransparent}set isImageTransparent(t){this._isImageTransparent=t}get image(){return this._image}set image(t){this._image=t}get imageDefId(){return this._imageDefId}set imageDefId(t){this._imageDefId=t}get imageFileName(){if(this._imageDefId){const t=this.database.dictionaries.imageDefs.getIdAt(this._imageDefId);if(t)return t.sourceFileName}return""}get geometricExtents(){const t=new Rt;return t.min.copy(this._position),t.max.set(this._position.x+this._width,this._position.y+this._height,0),t}subGetGripPoints(){return this.boundaryPath()}draw(t){const e=this.boundaryPath();return this._image?t.image(this._image,{boundary:e,roation:this._rotation}):t.lines(e,this.lineStyle)}boundaryPath(){const t=[];if(this.isClipped&&this._clipBoundary.length>3){const e=this._width,i=this._height,l=new me;l.setFromPoints(this._clipBoundary);const h=new Mt;h.setX(this._position.x-l.min.x*e),h.setY(this._position.y-l.min.y*i),this._clipBoundary.forEach(u=>{const f=u.x*e+h.x,b=u.y*i+h.y;t.push(new X(f,b,this._position.z))})}else{if(t.push(this._position),t.push(this._position.clone().setX(this._position.x+this._width)),t.push(this._position.clone().set(this._position.x+this._width,this._position.y+this._height,this._position.z)),t.push(this._position.clone().setY(this._position.y+this._height)),this._rotation>0){Il.copy(t[1]);for(let e=1;e<4;e++)$i.copy(t[e]),$i.rotateAround(Il,this._rotation),t[e].setX($i.x),t[e].setY($i.y)}t.push(t[0])}return t}}const Il=new Mt,$i=new Mt;class El extends qe{constructor(){super(),this._basePoint=new X,this._unitDir=new Z}get basePoint(){return this._basePoint}set basePoint(t){this._basePoint.copy(t)}get unitDir(){return this._unitDir}set unitDir(t){this._unitDir.copy(t)}get closed(){return!1}get geometricExtents(){const t=new Rt;return t.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),t.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),t}subGetGripPoints(){const t=new Array;return t.push(this.basePoint),t}draw(t){const e=[];return e.push(this.basePoint),e.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),t.lines(e,this.lineStyle)}}class Ml extends tn{constructor(){super(),this._centerPoint=new X,this._height=0,this._width=0,this._viewCenter=new X,this._viewHeight=0,this._number=-1}get number(){return this._number}set number(t){this._number=t}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get viewCenter(){return this._viewCenter}set viewCenter(t){this._viewCenter=t}get viewHeight(){return this._viewHeight}set viewHeight(t){this._viewHeight=t}get geometricExtents(){return new Rt}draw(t){if(this._number>1&&this.ownerId!=this.database.tables.blockTable.modelSpace.objectId){const e=this.toGiViewport();return t.group(this.createViewportRect(e,t))}}toGiViewport(){const t=new Xi;return t.id=this.objectId,t.groupId=this.ownerId,t.number=this.number,t.centerPoint=this.centerPoint,t.width=this.width,t.height=this.height,t.viewHeight=this.viewHeight,t.viewCenter=this.viewCenter,t}createViewportRect(t,e){const i=[];return i.push(e.lines([new X(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0),new X(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0)],this.lineStyle)),i.push(e.lines([new X(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0),new X(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0)],this.lineStyle)),i.push(e.lines([new X(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0),new X(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0)],this.lineStyle)),i.push(e.lines([new X(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0),new X(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0)],this.lineStyle)),i}}class kl extends Ws{draw(t){const e=this.boundaryPath(),i=new ji;return i.add(new ti(e)),t.area(i,{color:0,solidFill:!0,patternAngle:0,patternLines:[]})}}class Tl extends qe{constructor(){super(),this._basePoint=new X,this._unitDir=new Z}get basePoint(){return this._basePoint}set basePoint(t){this._basePoint.copy(t)}get unitDir(){return this._unitDir}set unitDir(t){this._unitDir.copy(t)}get closed(){return!1}get geometricExtents(){const t=new Rt;return t.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),t.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),t}subGetGripPoints(){const t=new Array;return t.push(this.basePoint),t}draw(t){const e=[];return e.push(this._unitDir.clone().multiplyScalar(-1e6).add(this._basePoint)),e.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),t.lines(e,this.lineStyle)}}var Cl=(a=>(a[a.AtLeast=1]="AtLeast",a[a.Exactly=2]="Exactly",a))(Cl||{});class nr extends tn{constructor(){super(),this._dimBlockId=null,this._dimensionStyleName=null,this._dimensionText=null,this._textLineSpacingFactor=1,this._textLineSpacingStyle=1,this._textPosition=new X,this._textRotation=0}get dimBlockId(){return this._dimBlockId}set dimBlockId(t){this._dimBlockId=t}get dimensionStyleName(){return this._dimensionStyleName}set dimensionStyleName(t){this._dimensionStyleName=t}get dimensionStyle(){if(this._dimStyle==null){let t;this.dimensionStyleName&&(t=this.database.tables.dimStyleTable.getAt(this.dimensionStyleName)),t==null&&(t=new ni),this._dimStyle=t}return this._dimStyle}get dimensionText(){return this._dimensionText}set dimensionText(t){this._dimensionText=t}get measurement(){return this._measurement}set measurement(t){this._measurement=t}get textLineSpacingFactor(){return this._textLineSpacingFactor}set textLineSpacingFactor(t){this._textLineSpacingFactor=t}get textLineSpacingStyle(){return this._textLineSpacingStyle}set textLineSpacingStyle(t){this._textLineSpacingStyle=t}get textPosition(){return this._textPosition}set textPosition(t){this._textPosition.copy(t)}get textRotation(){return this._textRotation}set textRotation(t){this._textRotation=t}draw(t){if(this.dimBlockId){const e=this.database.tables.blockTable.getAt(this.dimBlockId);if(e)return Sn.instance.draw(t,e,this.rgbColor,!1)}return t.group([])}drawFirstArrow(t){const e=this.database.tables.blockTable.getAt(this.firstArrowType);if(e)return Sn.instance.draw(t,e,this.rgbColor,!1)}drawSecondArrow(t){const e=this.database.tables.blockTable.getAt(this.secondArrowType);if(e)return Sn.instance.draw(t,e,this.rgbColor,!1)}get arrowScaleFactor(){return this.dimensionStyle.dimasz}get firstArrowStyle(){return{type:this.firstArrowType,scale:this.arrowScaleFactor,appended:this.isAppendArrow,visible:this.dimensionStyle.dimse1==0}}get secondArrowStyle(){return{type:this.secondArrowType,scale:this.arrowScaleFactor,appended:this.isAppendArrow,visible:this.dimensionStyle.dimse2==0}}get isAppendArrow(){return!0}get firstArrowTypeBtrId(){const t=this.dimensionStyle;return t.dimsah==0?t.dimblk:t.dimblk1}get firstArrowType(){const t=this.firstArrowTypeBtrId;return this.getArrowName(t)}get secondArrowTypeBtrId(){const t=this.dimensionStyle;return t.dimsah==0?t.dimblk:t.dimblk2}get secondArrowType(){const t=this.secondArrowTypeBtrId;return this.getArrowName(t)}get arrowLineCount(){return 1}getLineArrowStyle(t){}findPointOnLine1(t,e,i){const l=new X().subVectors(e,t).normalize();return new X(e).addScaledVector(l,i)}findPointOnLine2(t,e,i){const l=t.x+i*Math.cos(e),h=t.y+i*Math.sin(e);return{x:l,y:h}}adjustExtensionLine(t){const e=this.dimensionStyle;t.extend(e.dimexe),t.extend(-e.dimexo,!0)}getArrowName(t){const e=this.database.tables.blockTable.getIdAt(t);return e?e.name.toUpperCase():Vs.Closed}}class Ll extends nr{constructor(t,e,i,l,h=null,u=null){super(),this._centerPoint=new X().copy(t),this._xLine1Point=new X().copy(e),this._xLine2Point=new X().copy(i),this._arcPoint=new X().copy(l),this.dimensionText=h,this.dimensionStyleName=u}get arcPoint(){return this._arcPoint}set arcPoint(t){this._arcPoint.copy(t)}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get geometricExtents(){return new Rt}}class Nl extends nr{constructor(t,e,i,l=null,h=null){super(),this._dimLinePoint=new X().copy(i),this._xLine1Point=new X().copy(t),this._xLine2Point=new X().copy(e),this._oblique=0,this._rotation=0,this.dimensionText=l,this.dimensionStyleName=h}get dimLinePoint(){return this._dimLinePoint}set dimLinePoint(t){this._dimLinePoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get oblique(){return this._oblique}set oblique(t){this._oblique=t}get geometricExtents(){return new Rt}get isAppendArrow(){return!1}calculateLines(){const t=[],e=this.createExtensionLine(this._xLine1Point),i=this.createExtensionLine(this._xLine2Point),l=this.findIntersectionPoint(e,this._dimLinePoint),h=this.findIntersectionPoint(i,this._dimLinePoint),u=new Mn(l,h);return t.push(u),e.endPoint=l,this.adjustExtensionLine(e),t.push(e),i.endPoint=h,this.adjustExtensionLine(i),t.push(i),t}createExtensionLine(t){const e=this.rotation+Math.PI/2,i=this.findPointOnLine2(t,e,100);return new Mn(t,{...i,z:t.z})}findIntersectionPoint(t,e){const i=t.startPoint,l=t.endPoint,h=new Z().subVectors(l,i).normalize(),f=new Z().subVectors(e,i).dot(h),b=new Z().copy(h).multiplyScalar(f);return new Z().addVectors(i,b)}}class gu extends nr{constructor(t,e,i,l,h=null,u=null){super(),this._arcPoint=new X().copy(l),this._xLine1Point=new X().copy(e),this._xLine2Point=new X().copy(i),this._centerPoint=new X().copy(t),this.dimensionText=h,this.dimensionStyleName=u}get arcPoint(){return this._arcPoint}set arcPoint(t){this._arcPoint.copy(t)}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get geometricExtents(){return new Rt}}class zl extends nr{constructor(t,e,i=0,l=null,h=null){super(),this._chordPoint=new X().copy(t),this._farChordPoint=new X().copy(e),this._extArcStartAngle=0,this._extArcEndAngle=0,this._leaderLength=i,this.dimensionText=l,this.dimensionStyleName=h}get chordPoint(){return this._chordPoint}set chordPoint(t){this._chordPoint.copy(t)}get farChordPoint(){return this._farChordPoint}set farChordPoint(t){this._farChordPoint.copy(t)}get extArcStartAngle(){return this._extArcStartAngle}set extArcStartAngle(t){this._extArcStartAngle=t}get extArcEndAngle(){return this._extArcEndAngle}set extArcEndAngle(t){this._extArcEndAngle=t}get leaderLength(){return this._leaderLength}get geometricExtents(){return new Rt}drawLines(t,e){const i=[],l=e.length;return l==1?i.push(this.drawLine(t,e[0],{firstArrow:this.firstArrowStyle})):l==3?(this.sortLines(e),i.push(this.drawLine(t,e[0],{firstArrow:this.firstArrowStyle})),i.push(this.drawLine(t,e[1])),i.push(this.drawLine(t,e[2],{firstArrow:this.firstArrowStyle}))):e.forEach(h=>{i.push(this.drawLine(t,h))}),i}drawLine(t,e,i){if(i){const l=[e.startPoint,e.endPoint];return t.lines(l,{...this.lineStyle,arrows:i})}else return e.draw(t)}sortLines(t){const e=(i,l)=>i.x!==l.x?i.x-l.x:i.y!==l.y?i.y-l.y:i.z-l.z;t.sort((i,l)=>{const h=e(i.startPoint,l.startPoint);return h!==0?h:e(i.endPoint,l.endPoint)})}}class Dl extends nr{constructor(t,e,i=null,l=null){super(),this._definingPoint=new X().copy(t),this._leaderEndPoint=new X().copy(e),this.dimensionText=i,this.dimensionStyleName=l}get definingPoint(){return this._definingPoint}set definingPoint(t){this._definingPoint.copy(t)}get leaderEndPoint(){return this._leaderEndPoint}set leaderEndPoint(t){this._leaderEndPoint.copy(t)}get geometricExtents(){return new Rt}get arrowLineCount(){return 0}}class Ol extends nr{constructor(t,e,i,l=null,h=null){super(),this._center=new X().copy(t),this._chordPoint=new X().copy(e),this._leaderLength=i,this._extArcStartAngle=0,this._extArcEndAngle=0,this.dimensionText=l,this.dimensionStyleName=h}get center(){return this._center}set center(t){this._center.copy(t)}get chordPoint(){return this._chordPoint}set chordPoint(t){this._chordPoint.copy(t)}get extArcStartAngle(){return this._extArcStartAngle}set extArcStartAngle(t){this._extArcStartAngle=t}get extArcEndAngle(){return this._extArcEndAngle}set extArcEndAngle(t){this._extArcEndAngle=t}get leaderLength(){return this._leaderLength}set leaderLenght(t){this._leaderLength=t}get geometricExtents(){return new Rt}getLineArrowStyle(t){return{secondArrow:this.secondArrowStyle}}}class Rl{convert(t){const e=this.createEntity(t);return e&&this.processCommonAttrs(t,e),e}createEntity(t){return t.type=="ARC"?this.convertArc(t):t.type=="CIRCLE"?this.convertCirle(t):t.type=="DIMENSION"?this.convertDimension(t):t.type=="ELLIPSE"?this.convertEllipse(t):t.type=="HATCH"?this.convertHatch(t):t.type=="IMAGE"?this.convertImage(t):t.type=="LEADER"?this.convertLeader(t):t.type=="LINE"?this.convertLine(t):t.type=="MTEXT"?this.convertMText(t):t.type=="POLYLINE"||t.type=="LWPOLYLINE"?this.convertPolyline(t):t.type=="POINT"?this.convertPoint(t):t.type=="RAY"?this.convertRay(t):t.type=="SPLINE"?this.convertSpline(t):t.type=="ACAD_TABLE"?this.convertTable(t):t.type=="TEXT"?this.convertText(t):t.type=="SOLID"?this.convertSolid(t):t.type=="VIEWPORT"?this.convertViewport(t):t.type=="WIPEOUT"?this.convertWipeout(t):t.type=="XLINE"?this.convertXline(t):t.type=="INSERT"?this.convertBlockReference(t):null}convertArc(t){return new ol(t.center,t.radius,zt.degToRad(t.startAngle),zt.degToRad(t.endAngle))}convertCirle(t){return new ll(t.center,t.radius)}convertEllipse(t){const e=new Z(t.majorAxisEndPoint),i=e.length();return new al(t.center,Z.Z_AXIS,e,i,i*t.axisRatio,t.startAngle,t.endAngle)}convertLine(t){const e=t.startPoint,i=t.endPoint;return new gl(new X(e.x,e.y,e.z||0),new X(i.x,i.y,i.z||0))}convertSpline(t){if(t.numberOfControlPoints>0&&t.numberOfKnots>0)return new Hs(t.controlPoints,t.knots,t.weights,t.degree,!!(t.flag&1));if(t.numberOfFitPoints>0){const e=this.numberArrayToPointArray(t.fitPoints,t.numberOfFitPoints);if(e!=null)return new Hs(e,"Uniform",t.degree,!!(t.flag&1))}return null}convertPoint(t){const e=new Al;return e.position=t.position,e}convertSolid(t){const e=new xl;return t.points.forEach((i,l)=>e.setPointAt(l,i)),e.thickness=t.thickness,e}convertPolyline(t){const e=new wl;return e.closed=!!(t.flag&1),t.vertices.forEach((i,l)=>{e.addVertexAt(l,new Mt(i.x,i.y),i.bulge,i.startWidth,i.endWidth)}),e}convertHatch(t){var l;const e=new ul;return(l=t.definitionLines)==null||l.forEach(h=>{e.definitionLines.push({angle:h.angle,origin:h.base,delta:h.offset,dashPattern:h.numberOfDashLengths>0?h.dashLengths:[]})}),e.hatchStyle=t.hatchStyle,e.patternName=t.patternName,e.patternType=t.patternType,e.patternAngle=t.patternAngle==null?0:t.patternAngle,e.patternScale=t.patternScale==null?0:t.patternScale,t.boundaryPaths.forEach(h=>{if(h.boundaryPathTypeFlag&2){const f=h,b=new ti;b.closed=f.isClosed,f.vertices.forEach((p,S)=>{b.addVertexAt(S,{x:p.x,y:p.y,bulge:p.bulge})}),e.add(b)}else{const f=h,b=new el;f.edges.forEach(p=>{if(p.type==1){const S=p;b.add(new qi(S.start,S.end))}else if(p.type==2){const S=p;b.add(new pr(S.center,S.radius,zt.degToRad(S.startAngle||0),zt.degToRad(S.endAngle||0),!S.isCCW))}else if(p.type==3){const S=p;new Xt().subVectors(S.end,S.center);const E=Math.sqrt(Math.pow(S.end.x,2)+Math.pow(S.end.y,2)),T=E*S.lengthOfMinorAxis;let O=zt.degToRad(S.startAngle||0),R=zt.degToRad(S.endAngle||0);const G=Math.atan2(S.end.y,S.end.x);S.isCCW||(O=Math.PI*2-O,R=Math.PI*2-R),b.add(new Hi({...S.center,z:0},E,T,O,R,!S.isCCW,G))}else if(p.type==4){const S=p;if(S.numberOfControlPoints>0&&S.numberOfKnots>0){const x=S.controlPoints.map(O=>({x:O.x,y:O.y,z:0}));let E=!0;const T=S.controlPoints.map(O=>(O.weight==null&&(E=!1),O.weight||1));b.add(new kn(x,S.knots,E?T:void 0))}else if(S.numberOfFitData>0){const x=S.fitDatum.map(E=>({x:E.x,y:E.y,z:0}));b.add(new kn(x,"Uniform"))}}}),e.add(b)}}),e}convertTable(t){const e=new pl(t.name,t.rowCount,t.columnCount);return e.attachmentPoint=t.attachmentPoint,e.position.copy(t.startPoint),t.columnWidthArr.forEach((i,l)=>e.setColumnWidth(l,i)),t.rowHeightArr.forEach((i,l)=>e.setRowHeight(l,i)),t.cells.forEach((i,l)=>{e.setCell(l,i)}),e}convertText(t){const e=new bl;return e.textString=t.text,e.styleName=t.styleName,e.height=t.textHeight,e.position.copy(t.startPoint),e.rotation=zt.degToRad(t.rotation||0),e.oblique=t.obliqueAngle??0,e.thickness=t.thickness,e.horizontalMode=t.halign,e.verticalMode=t.valign,e.widthFactor=t.xScale??1,e}convertMText(t){const e=new fl;return e.contents=t.text.join(""),t.styleName!=null&&(e.styleName=t.styleName),e.height=t.height,e.width=t.width,e.rotation=zt.degToRad(t.rotation||0),e.location=t.insertionPoint,e.attachmentPoint=t.attachmentPoint,t.direction&&(e.direction=new Z(t.direction)),e.drawingDirection=t.drawingDirection,e}convertLeader(t){const e=new ml;return t.vertices.forEach(i=>{e.appendVertex(i)}),e.hasArrowHead=t.isArrowheadEnabled,e.hasHookLine=t.isHooklineExists,e.isSplined=t.isSpline,e.dimensionStyle=t.styleName,e.annoType=t.leaderCreationFlag,e}convertDimension(t){if(t.subclassMarker=="AcDbAlignedDimension"||t.subclassMarker=="AcDbRotatedDimension"){const e=t,i=new Nl(e.subDefinitionPoint1,e.subDefinitionPoint2,e.definitionPoint);return i.rotation=zt.degToRad(e.rotationAngle||0),this.processDimensionCommonAttrs(t,i),i}else if(t.subclassMarker=="AcDb3PointAngularDimension"){const e=t,i=new Ll(e.centerPoint,e.subDefinitionPoint1,e.subDefinitionPoint2,e.definitionPoint);return this.processDimensionCommonAttrs(t,i),i}else if(t.subclassMarker=="AcDbOrdinateDimension"){const e=t,i=new Dl(e.subDefinitionPoint1,e.subDefinitionPoint2);return this.processDimensionCommonAttrs(t,i),i}else if(t.subclassMarker=="AcDbRadialDimension"){const e=t,i=new Ol(e.definitionPoint,e.centerPoint,e.leaderLength);return this.processDimensionCommonAttrs(t,i),i}else if(t.subclassMarker=="AcDbDiametricDimension"){const e=t,i=new zl(e.definitionPoint,e.centerPoint,e.leaderLength);return this.processDimensionCommonAttrs(t,i),i}return null}processImage(t,e){e.position.copy(t.position),e.brightness=t.brightness,e.contrast=t.contrast,e.fade=t.fade,e.imageDefId=t.imageDefHandle,e.isClipped=(t.flags|4)>0,e.isImageShown=(t.flags|3)>0,e.isImageTransparent=(t.flags|8)>0,t.clippingBoundaryPath.forEach(i=>{e.clipBoundary.push(new Mt(i))}),e.clipBoundaryType=t.clippingBoundaryType,e.width=Math.sqrt(t.uPixel.x**2+t.uPixel.y**2+t.uPixel.z**2)*t.imageSize.x,e.height=Math.sqrt(t.vPixel.x**2+t.vPixel.y**2+t.vPixel.z**2)*t.imageSize.y,e.rotation=Math.atan2(t.uPixel.y,t.uPixel.x)}convertImage(t){const e=new Ws;return this.processImage(t,e),e}convertWipeout(t){const e=new kl;return this.processImage(t,e),e}convertViewport(t){const e=new Ml;return e.number=t.viewportId,e.centerPoint.copy(t.viewportCenter),e.height=t.height,e.width=t.width,e.viewCenter.copy(t.displayCenter),e.viewHeight=t.viewHeight,e}convertRay(t){const e=new El;return e.basePoint.copy(t.firstPoint),e.unitDir.copy(t.unitDirection),e}convertXline(t){const e=new Tl;return e.basePoint.copy(t.firstPoint),e.unitDir.copy(t.unitDirection),e}convertBlockReference(t){const e=new Fs(t.name);return t.insertionPoint&&e.position.copy(t.insertionPoint),e.scaleFactors.x=t.xScale||1,e.scaleFactors.y=t.yScale||1,e.scaleFactors.z=t.zScale||1,e.rotation=t.rotation!=null?zt.degToRad(t.rotation):0,e.normal.copy(t.extrusionDirection),e}processDimensionCommonAttrs(t,e){e.dimBlockId=t.name,e.textPosition.copy(t.textPoint),e.textRotation=t.textRotation||0,t.textLineSpacingFactor&&(e.textLineSpacingFactor=t.textLineSpacingFactor),t.textLineSpacingStyle&&(e.textLineSpacingStyle=t.textLineSpacingStyle),e.dimensionStyleName=t.styleName,e.dimensionText=t.text||"",e.measurement=t.measurement}processCommonAttrs(t,e){e.layer=t.layer,e.objectId=t.handle,e.ownerId=t.ownerBlockRecordSoftId||"",t.lineType!=null&&(e.lineType=t.lineType),t.lineweight!=null&&(e.lineWeight=t.lineweight),t.lineTypeScale!=null&&(e.linetypeScale=t.lineTypeScale),t.color!=null&&(e.color.color=t.color),t.colorIndex!=null&&(e.color.colorIndex=t.colorIndex),t.colorName!=null&&(e.color.colorName=t.colorName),t.isVisible!=null&&(e.visibility=t.isVisible),t.transparency!=null&&(e.transparency=t.transparency)}numberArrayToPointArray(t,e){const i=t.length;let l=0;if(i/2==e?l=2:i/3==e&&(l=3),l==0)return;const h=[];for(let u=0,f=i/l;u<f;++u)h.push({x:t[u*l],y:t[u*l+1],z:l==3?t[u*l+2]:0});return h}}class qs extends Tn{constructor(){super(),this._tabOrder=-1,this._tabSelected=!1,this._blockTableRecordId="",this._layoutName="",this._limits=new me,this._extents=new Rt}get layoutName(){return this._layoutName}set layoutName(t){this._layoutName=t.length>256?t.slice(0,256):t}get tabOrder(){return this._tabOrder}set tabOrder(t){this._tabOrder=t}get tabSelected(){return this._tabSelected}set tabSelected(t){this._tabSelected=t}get blockTableRecordId(){return this._blockTableRecordId}set blockTableRecordId(t){this._blockTableRecordId=t}get limits(){return this._limits}set limits(t){this._limits.copy(t)}get extents(){return this._extents}set extents(t){this._extents.copy(t)}}class Ys extends Tn{constructor(t){super(),this.database=t,this._recordsByName=new Map,this._recordsById=new Map}get numEntries(){return this._recordsByName.size}setAt(t,e){e.database=this.database,this._recordsByName.set(t,e),this._recordsById.set(e.objectId,e)}remove(t){return this.getAt(t)?(this._recordsByName.delete(t.toUpperCase()),this._recordsById.delete(this.objectId),!0):!1}removeId(t){const e=this.getIdAt(t);return e?(this._recordsById.delete(this.objectId),this._recordsByName.forEach((i,l)=>{i===e&&this._recordsByName.delete(l)}),!0):!1}removeAll(){this._recordsByName.clear(),this._recordsById.clear()}has(t){return this._recordsByName.has(t.toUpperCase())}hasId(t){return this._recordsById.has(t)}getAt(t){return this._recordsByName.get(t)}getIdAt(t){return this._recordsById.get(t)}newIterator(){return new Bi(this._recordsByName)}}class Bl extends Ys{getBtrIdAt(t){for(const[e,i]of this._recordsByName)if(i.blockTableRecordId==t)return i}get maxTabOrder(){let t=-1;return this._recordsByName.forEach(e=>{e.tabOrder>t&&(t=e.tabOrder)}),t}}class Fl extends Tn{constructor(){super(),this._sourceFileName=""}get sourceFileName(){return this._sourceFileName}set sourceFileName(t){this._sourceFileName=t}}class fu{convertLayout(t){const e=new qs;return e.layoutName=t.layoutName,e.tabOrder=t.tabOrder,e.blockTableRecordId=t.ownerObjectId,e.limits.min.copy(t.minLimit),e.limits.max.copy(t.maxLimit),e.extents.min.copy(t.minExtent),e.extents.max.copy(t.maxExtent),this.processCommonAttrs(t,e),e}convertImageDef(t){const e=new Fl;return e.sourceFileName=t.fileName,this.processCommonAttrs(t,e),e}processCommonAttrs(t,e){e.objectId=t.handle,e.ownerId=t.ownerObjectId}}class Vl extends yo{parse(t){return new tu().parseSync(t)}getFonts(t){var h;const e=new Map,i=u=>{if(u){const f=u.lastIndexOf(".");return f>=0?u.substring(0,f).toLowerCase():u.toLowerCase()}};(h=t.tables.STYLE)==null||h.entries.forEach(u=>{const f=[];let b=i(u.font);b&&f.push(b),b=i(u.bigFont),b&&f.push(b),e.set(u.name,f)});const l=new Set;return this.getFontsInBlock(t.entities,t.blocks,e,l),Array.from(l)}getFontsInBlock(t,e,i,l){const h=/\\f(.*?)\|/g;t.forEach(u=>{if(u.type=="MTEXT"){const f=u;[...f.text.join("").matchAll(h)].forEach(S=>{l.add(S[1].toLowerCase())});const p=i.get(f.styleName);p==null||p.forEach(S=>l.add(S))}else if(u.type=="TEXT"){const f=u,b=i.get(f.styleName);b==null||b.forEach(p=>l.add(p))}else if(u.type=="INSERT"){const b=e[u.name];b&&b.entities&&this.getFontsInBlock(b.entities,e,i,l)}})}async processEntities(t,e,i,l,h){const u=new Rl,f=t.entities,b=f.length,p=new fa(b,100-l.value,i),S=e.tables.blockTable.modelSpace,x=e.tables.blockTable;await p.processChunk(async(E,T)=>{for(let O=E;O<T;O++){const R=f[O],G=u.convert(R);if(G){let F=S;R.ownerBlockRecordSoftId!=null&&(F=x.getIdAt(R.ownerBlockRecordSoftId)||F),F.appendEntity(G)}}if(h){let O=l.value+T/b*(100-l.value);O>100&&(O=100),await h(O,"ENTITY","IN-PROGRESS")}})}async processEntitiesInBlock(t,e,i){const l=new Rl,h=t.length;for(let u=0;u<h;u++){const f=t[u],b=l.convert(f);if(b){let p=e;f.ownerBlockRecordSoftId!=null&&(p=i.getIdAt(f.ownerBlockRecordSoftId)||p),p.appendEntity(b)}}}processBlocks(t,e){const i=t.blocks;for(const[l,h]of Object.entries(i)){let u=e.tables.blockTable.getAt(h.name);u||(u=new Ne,u.objectId=h.handle,u.name=l,u.origin.copy(h.position),e.tables.blockTable.add(u)),h.entities&&this.processEntitiesInBlock(h.entities,u,e.tables.blockTable)}}processHeader(t,e){const i=t.header;e.cecolor.colorIndex=i.$CECOLOR||256,e.angBase=i.$ANGBASE||0,e.angDir=i.$ANGDIR||0,e.aunits=i.$AUNITS,e.insunits=i.$INSUNITS,e.pdmode=i.$PDMODE||0,e.pdsize=i.$PDSIZE||0}processBlockTables(t,e){var l;const i=(l=t.tables.BLOCK_RECORD)==null?void 0:l.entries;i&&i.length>0&&(e.tables.blockTable.removeAll(),i.forEach(h=>{const u=new Ne;u.objectId=h.handle,u.name=h.name,e.tables.blockTable.add(u)}))}processObjects(t,e){const i=t.objects.byName,l=new fu;if("LAYOUT"in i){const h=e.dictionaries.layouts;i.LAYOUT.forEach(u=>{const f=l.convertLayout(u);h.setAt(f.layoutName,f)})}if("IMAGEDEF"in i){const h=e.dictionaries.imageDefs;i.IMAGEDEF.forEach(u=>{const f=l.convertImageDef(u);h.setAt(f.objectId,f)})}}processViewports(t,e){var l,h;const i=(h=(l=t.tables)==null?void 0:l.VPORT)==null?void 0:h.entries;i&&i.length>0&&i.forEach(u=>{const f=new th;this.processCommonTableEntryAttrs(u,f),u.circleSides&&(f.circleSides=u.circleSides),f.standardFlag=u.standardFlag,f.center.copy(u.center),f.lowerLeftCorner.copy(u.lowerLeftCorner),f.upperRightCorner.copy(u.upperRightCorner),u.snapBasePoint&&f.snapBase.copy(u.snapBasePoint),u.snapRotationAngle&&(f.snapAngle=u.snapRotationAngle),u.snapSpacing&&f.snapIncrements.copy(u.snapSpacing),u.majorGridLines&&(f.gridMajor=u.majorGridLines),u.gridSpacing&&f.gridIncrements.copy(u.gridSpacing),u.backgroundObjectId&&(f.backgroundObjectId=u.backgroundObjectId),f.gsView.center.copy(u.center),f.gsView.viewDirectionFromTarget.copy(u.viewDirectionFromTarget),f.gsView.viewTarget.copy(u.viewTarget),u.lensLength&&(f.gsView.lensLength=u.lensLength),u.frontClippingPlane&&(f.gsView.frontClippingPlane=u.frontClippingPlane),u.backClippingPlane&&(f.gsView.backClippingPlane=u.backClippingPlane),u.viewHeight&&(f.gsView.viewHeight=u.viewHeight),u.viewTwistAngle&&(f.gsView.viewTwistAngle=u.viewTwistAngle),u.frozenLayers&&(f.gsView.frozenLayers=u.frozenLayers),u.styleSheet&&(f.gsView.styleSheet=u.styleSheet),u.renderMode&&(f.gsView.renderMode=u.renderMode),u.viewMode&&(f.gsView.viewMode=u.viewMode),u.ucsIconSetting&&(f.gsView.ucsIconSetting=u.ucsIconSetting),u.ucsOrigin&&f.gsView.ucsOrigin.copy(u.ucsOrigin),u.ucsXAxis&&f.gsView.ucsXAxis.copy(u.ucsXAxis),u.ucsYAxis&&f.gsView.ucsYAxis.copy(u.ucsYAxis),u.orthographicType&&(f.gsView.orthographicType=u.orthographicType),u.shadePlotSetting&&(f.gsView.shadePlotSetting=u.shadePlotSetting),u.shadePlotObjectId&&(f.gsView.shadePlotObjectId=u.shadePlotObjectId),u.visualStyleObjectId&&(f.gsView.visualStyleObjectId=u.visualStyleObjectId),u.isDefaultLightingOn&&(f.gsView.isDefaultLightingOn=u.isDefaultLightingOn),u.defaultLightingType&&(f.gsView.defaultLightingType=u.defaultLightingType),u.brightness&&(f.gsView.brightness=u.brightness),u.contrast&&(f.gsView.contrast=u.contrast),u.ambientColor&&(f.gsView.ambientColor=u.ambientColor),e.tables.viewportTable.add(f)})}processLayers(t,e){var l,h;const i=(h=(l=t.tables)==null?void 0:l.LAYER)==null?void 0:h.entries;i&&i.length>0&&i.forEach(u=>{const f=new jn;f.colorIndex=u.colorIndex;const b=new Ks({name:u.name,standardFlags:u.standardFlag,linetype:u.lineType,lineWeight:u.lineweight,isOff:u.colorIndex<0,color:f,isPlottable:u.isPlotting});this.processCommonTableEntryAttrs(u,b),e.tables.layerTable.add(b)})}processLineTypes(t,e){var l,h;const i=(h=(l=t.tables)==null?void 0:l.LTYPE)==null?void 0:h.entries;i&&i.length>0&&i.forEach(u=>{const f=new Ql(u);this.processCommonTableEntryAttrs(u,f),f.name=u.name,e.tables.linetypeTable.add(f)})}processTextStyles(t,e){var l;const i=(l=t.tables.STYLE)==null?void 0:l.entries;i&&i.length>0&&i.forEach(h=>{const u=new Jl(h);this.processCommonTableEntryAttrs(h,u),e.tables.textStyleTable.add(u)})}processDimStyles(t,e){var l;const i=(l=t.tables.DIMSTYLE)==null?void 0:l.entries;i&&i.length>0&&i.forEach(h=>{const u={name:h.name,ownerId:h.ownerObjectId,dimpost:h.DIMPOST||"",dimapost:h.DIMAPOST||"",dimscale:h.DIMSCALE,dimasz:h.DIMASZ,dimexo:h.DIMEXO,dimdli:h.DIMDLI,dimexe:h.DIMEXE,dimrnd:h.DIMRND,dimdle:h.DIMDLE,dimtp:h.DIMTP,dimtm:h.DIMTM,dimtxt:h.DIMTXT,dimcen:h.DIMCEN,dimtsz:h.DIMTSZ,dimaltf:h.DIMALTF,dimlfac:h.DIMLFAC,dimtvp:h.DIMTVP,dimtfac:h.DIMTFAC,dimgap:h.DIMGAP,dimaltrnd:h.DIMALTRND,dimtol:h.DIMTOL==null||h.DIMTOL==0?0:1,dimlim:h.DIMLIM==null||h.DIMLIM==0?0:1,dimtih:h.DIMTIH==null||h.DIMTIH==0?0:1,dimtoh:h.DIMTOH==null||h.DIMTOH==0?0:1,dimse1:h.DIMSE1==null||h.DIMSE1==0?0:1,dimse2:h.DIMSE2==null||h.DIMSE2==0?0:1,dimtad:h.DIMTAD,dimzin:h.DIMZIN,dimazin:h.DIMAZIN,dimalt:h.DIMALT,dimaltd:h.DIMALTD,dimtofl:h.DIMTOFL,dimsah:h.DIMSAH,dimtix:h.DIMTIX,dimsoxd:h.DIMSOXD,dimclrd:h.DIMCLRD,dimclre:h.DIMCLRE,dimclrt:h.DIMCLRT,dimadec:h.DIMADEC||0,dimunit:h.DIMUNIT||2,dimdec:h.DIMDEC,dimtdec:h.DIMTDEC,dimaltu:h.DIMALTU,dimalttd:h.DIMALTTD,dimaunit:h.DIMAUNIT,dimfrac:h.DIMFRAC,dimlunit:h.DIMLUNIT,dimdsep:h.DIMDSEP,dimtmove:h.DIMTMOVE||0,dimjust:h.DIMJUST,dimsd1:h.DIMSD1,dimsd2:h.DIMSD2,dimtolj:h.DIMTOLJ,dimtzin:h.DIMTZIN,dimaltz:h.DIMALTZ,dimalttz:h.DIMALTTZ,dimfit:h.DIMFIT||0,dimupt:h.DIMUPT,dimatfit:h.DIMATFIT,dimtxsty:h.DIMTXSTY||"Standard",dimldrblk:h.DIMLDRBLK||"",dimblk:h.DIMBLK||"",dimblk1:h.DIMBLK1||"",dimblk2:h.DIMBLK2||"",dimlwd:h.DIMLWD,dimlwe:h.DIMLWE},f=new ni(u);this.processCommonTableEntryAttrs(h,f),e.tables.dimStyleTable.add(f)})}processCommonTableEntryAttrs(t,e){e.name=t.name,e.objectId=t.handle,e.ownerId=t.ownerObjectId}}var ei=(a=>(a.DXF="dxf",a.DWG="dwg",a))(ei||{});class en{constructor(){this.events={registered:new Ee,unregistered:new Ee},this._converters=new Map,this.register("dxf",new Vl)}static createInstance(){return en._instance==null&&(en._instance=new en),this._instance}static get instance(){return en._instance||(en._instance=new en),en._instance}get fileTypes(){return this._converters.keys()}register(t,e){this._converters.set(t,e),this.events.registered.dispatch({fileType:t,converter:e})}get(t){return this._converters.get(t)}unregister(t){const e=this._converters.get(t);e&&(this._converters.delete(t),this.events.unregistered.dispatch({fileType:t,converter:e}))}}class rr extends Tn{constructor(t,e){t=t||{},cr(t,{name:""}),super(t,e)}get name(){return this.getAttr("name")}set name(t){this.setAttr("name",t)}}const Cn=class Cn extends rr{static isModelSapceName(t){return t.toLowerCase()==Cn.MODEL_SPACE_NAME.toLowerCase()}static isPaperSapceName(t){return t.toLowerCase().startsWith(Cn.PAPER_SPACE_NAME_PREFIX.toLowerCase())}constructor(){super(),this._origin=new X,this._entities=new Map}get isModelSapce(){return Cn.isModelSapceName(this.name)}get isPaperSapce(){return Cn.isPaperSapceName(this.name)}get origin(){return this._origin}set origin(t){this._origin.copy(t)}appendEntity(t){t.database=this.database,t.ownerId=this.objectId,this._entities.set(t.objectId,t),(this.isModelSapce||this.isPaperSapce)&&this.database.events.entityAppended.dispatch({database:this.database,entity:t})}newIterator(){return new Bi(this._entities)}getIdAt(t){return this._entities.get(t)}};Cn.MODEL_SPACE_NAME="*MODEL_SPACE",Cn.PAPER_SPACE_NAME_PREFIX="*PAPER_SPACE";let Ne=Cn;class ir extends Tn{constructor(t){super(),this.database=t,this._recordsByName=new Map,this._recordsById=new Map}add(t){t.database=this.database;const e=this.normalizeName(t.name);this._recordsByName.set(e,t),this._recordsById.set(t.objectId,t)}remove(t){const e=this.normalizeName(t),i=this._recordsByName.get(e);return i?(this._recordsById.delete(i.objectId),this._recordsByName.delete(t),!0):!1}removeId(t){const e=this._recordsById.get(t);return e?(this._recordsByName.delete(e.name),this._recordsById.delete(t),!0):!1}removeAll(){this._recordsByName.clear(),this._recordsById.clear()}has(t){const e=this.normalizeName(t);return this._recordsByName.has(e)}hasId(t){return this._recordsById.has(t)}getAt(t){const e=this.normalizeName(t);return this._recordsByName.get(e)}getIdAt(t){return this._recordsById.get(t)}getOwnerIdAt(t){return this._recordsById.get(t)}newIterator(){return new Bi(this._recordsByName)}normalizeName(t){return t}}class Ul extends ir{constructor(t){super(t)}get modelSpace(){let t=this.getAt(Ne.MODEL_SPACE_NAME);return t||(t=new Ne,t.name=Ne.MODEL_SPACE_NAME,this.add(t)),t}normalizeName(t){let e=t;if(Ne.isModelSapceName(t))e=Ne.MODEL_SPACE_NAME;else if(Ne.isPaperSapceName(t)){const i=Ne.PAPER_SPACE_NAME_PREFIX,l=t.substring(i.length);e=i+l}return e}}class jl extends ir{constructor(t){super(t)}}class Ks extends rr{constructor(t,e){t=t||{},cr(t,{color:new jn,description:"",standardFlags:0,isHidden:!1,isInUse:!0,isOff:!1,isPlottable:!0,transparency:0,linetype:"",lineWeight:1,materialId:-1}),super(t,e),this.attrs.events.attrChanged.addEventListener(i=>{this.database.events.layerModified.dispatch({database:this.database,layer:this,changes:i.object.changedAttributes()})})}get color(){return this.getAttr("color")}set color(t){this.setAttr("color",t.clone())}get description(){return this.getAttr("description")}set description(t){this.setAttr("description",t)}get standardFlags(){return this.getAttr("standardFlags")}set standardFlags(t){this.setAttr("standardFlags",t)}get isFrozen(){return(this.standardFlags&1)==1}set isFrozen(t){const e=t?1:0;this.standardFlags=this.standardFlags|e}get isHidden(){return this.getAttr("isHidden")}set isHidden(t){this.setAttr("isHidden",t)}get isInUse(){return this.getAttr("isInUse")}set isInUse(t){this.setAttr("isInUse",t)}get isLocked(){return(this.standardFlags&4)==4}set isLocked(t){const e=t?4:0;this.standardFlags=this.standardFlags|e}get isOff(){return this.getAttr("isOff")}set isOff(t){this.setAttr("isOff",t)}get isPlottable(){return this.getAttr("isPlottable")}set isPlottable(t){this.setAttr("isPlottable",t)}get transparency(){return this.getAttr("transparency")}set transparency(t){this.setAttr("transparency",t)}get linetype(){return this.getAttr("linetype")}set linetype(t){this.setAttr("linetype",t)}get lineWeight(){return this.getAttr("lineWeight")}set lineWeight(t){this.setAttr("lineWeight",t)}get materialId(){return this.getAttr("materialId")}set materialId(t){this.setAttr("materialId",t)}}class Gl extends ir{constructor(t){super(t);const e=new jn;e.color=16777215;const i=new Ks({name:"0",standardFlags:0,linetype:Oi,lineWeight:1,isOff:!1,color:e,isPlottable:!0});this.add(i)}add(t){super.add(t),this.database.events.layerAppended.dispatch({database:this.database,layer:t})}}class Hl extends ir{constructor(t){super(t)}}class Wl extends ir{constructor(t){super(t)}get fonts(){const t=new Set,e=l=>{if(l){const h=l.lastIndexOf(".");if(h>=0){const u=l.substring(0,h).toLowerCase();t.add(u)}else t.add(l.toLowerCase())}},i=this.newIterator();for(const l of i)e(l.fileName),e(l.bigFontFileName);return Array.from(t)}}class ql extends ir{constructor(t){super(t)}}class pu extends Tn{constructor(){super(),this.events={entityAppended:new Ee,entityModified:new Ee,layerAppended:new Ee,layerModified:new Ee,layerErased:new Ee,openProgress:new Ee,headerSysVarChanged:new Ee},this._angBase=0,this._angDir=0,this._aunits=ys.DecimalDegrees,this._celtscale=1,this._cecolor=new jn,this._insunits=bs.Millimeters,this._ltscale=1,this._pdmode=0,this._pdsize=0,this._tables={blockTable:new Ul(this),dimStyleTable:new jl(this),linetypeTable:new Hl(this),textStyleTable:new Wl(this),layerTable:new Gl(this),viewportTable:new ql(this)},this._dictionaries={layouts:new Bl(this),imageDefs:new Ys(this)}}get tables(){return this._tables}get dictionaries(){return this._dictionaries}get currentSpaceId(){return this._currentSpace||(this._currentSpace=this._tables.blockTable.modelSpace),this._currentSpace.objectId}set currentSpaceId(t){const e=this.tables.blockTable.getIdAt(t);if(e==null)throw new Error(`[AcDbDatabase] The specified block table record id '${t}' doesn't exist in the drawing database!`);this._currentSpace=e}get aunits(){return this._aunits}set aunits(t){this._aunits=t||0,this.triggerHeaderSysVarChangedEvent("aunits")}get insunits(){return this._insunits}set insunits(t){this._insunits=t||4,this.triggerHeaderSysVarChangedEvent("insunits")}get ltscale(){return this._ltscale}set ltscale(t){this._ltscale=t||1,this.triggerHeaderSysVarChangedEvent("ltscale")}get cecolor(){return this._cecolor}set cecolor(t){this._cecolor=t||0,this.triggerHeaderSysVarChangedEvent("cecolor")}get celtscale(){return this._celtscale}set celtscale(t){this._celtscale=t||1,this.triggerHeaderSysVarChangedEvent("celtscale")}get angBase(){return this._angBase}set angBase(t){this._angBase=t||0,this.triggerHeaderSysVarChangedEvent("angbase")}get angDir(){return this._angDir}set angDir(t){this._angDir=t||0,this.triggerHeaderSysVarChangedEvent("angdir")}get pdmode(){return this._pdmode}set pdmode(t){this._pdmode=t||0,this.triggerHeaderSysVarChangedEvent("pdmode")}get pdsize(){return this._pdsize}set pdsize(t){this._pdsize=t||0,this.triggerHeaderSysVarChangedEvent("pdsize")}async read(t,e,i=ei.DXF){const l=en.instance.get(i);if(l==null)throw new Error(`Database converter for file type '${i}' isn't registered and can can't read this file!`);this.clear(),await l.read(t,this,e&&e.minimumChunkSize||10,async(h,u,f,b)=>{if(this.events.openProgress.dispatch({database:this,percentage:h,stage:"CONVERSION",subStage:u,stageStatus:f}),e&&e.fontLoader&&u=="FONT"&&f=="END"){const p=b||this.tables.textStyleTable.fonts;await e.fontLoader.load(p)}})}async openUri(t,e){this.events.openProgress.dispatch({database:this,percentage:0,stage:"FETCH_FILE",stageStatus:"START"});const i=await fetch(t);if(this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",stageStatus:"END"}),!i.ok)throw new Error(`Failed to fetch file '${t}' with HTTP status codee '${i.status}'!`);if(t.toLowerCase().split(".").pop()==="dwg"){const h=await i.arrayBuffer();await this.read(h,e,ei.DWG)}else{const h=await i.text();await this.read(h,e,ei.DXF)}}clear(){this._tables.blockTable.removeAll(),this._tables.dimStyleTable.removeAll(),this._tables.linetypeTable.removeAll(),this._tables.textStyleTable.removeAll(),this._tables.layerTable.removeAll(),this._tables.viewportTable.removeAll(),this._dictionaries.layouts.removeAll(),this._currentSpace=void 0}triggerHeaderSysVarChangedEvent(t){this.events.headerSysVarChanged.dispatch({database:this,name:t})}}var Yl=(a=>(a[a.Center=0]="Center",a[a.Left=1]="Left",a[a.Right=2]="Right",a[a.OverFirst=3]="OverFirst",a[a.OverSecond=4]="OverSecond",a))(Yl||{}),Kl=(a=>(a[a.Center=0]="Center",a[a.Above=1]="Above",a[a.Outside=2]="Outside",a[a.JIS=3]="JIS",a[a.Below=4]="Below",a))(Kl||{}),Xl=(a=>(a[a.Feet=0]="Feet",a[a.None=1]="None",a[a.Inch=2]="Inch",a[a.FeetAndInch=3]="FeetAndInch",a[a.Leading=4]="Leading",a[a.Trailing=8]="Trailing",a[a.LeadingAndTrailing=12]="LeadingAndTrailing",a))(Xl||{}),$l=(a=>(a[a.None=0]="None",a[a.Leading=1]="Leading",a[a.Trailing=2]="Trailing",a[a.LeadingAndTrailing=3]="LeadingAndTrailing",a))($l||{}),Zl=(a=>(a[a.Bottom=0]="Bottom",a[a.Middle=1]="Middle",a[a.Top=2]="Top",a))(Zl||{});const Qi=class Qi extends rr{constructor(t,e){t=t||{},cr(t,Qi.DEFAULT_DIM_VALUES),super(t,e)}get dimpost(){return this.getAttr("dimpost")}set dimpost(t){this.setAttr("dimpost",t)}get dimapost(){return this.getAttr("dimapost")}set dimapost(t){this.setAttr("dimapost",t)}get dimscale(){return this.getAttr("dimscale")}set dimscale(t){this.setAttr("dimscale",t)}get dimasz(){return this.getAttr("dimasz")}set dimasz(t){this.setAttr("dimasz",t)}get dimexo(){return this.getAttr("dimexo")}set dimexo(t){this.setAttr("dimexo",t)}get dimdli(){return this.getAttr("dimdli")}set dimdli(t){this.setAttr("dimdli",t)}get dimexe(){return this.getAttr("dimexe")}set dimexe(t){this.setAttr("dimexe",t)}get dimrnd(){return this.getAttr("dimrnd")}set dimrnd(t){this.setAttr("dimrnd",t)}get dimdle(){return this.getAttr("dimdle")}set dimdle(t){this.setAttr("dimdle",t)}get dimtp(){return this.getAttr("dimtp")}set dimtp(t){this.setAttr("dimtp",t)}get dimtm(){return this.getAttr("dimtm")}set dimtm(t){this.setAttr("dimtm",t)}get dimtxt(){return this.getAttr("dimtxt")}set dimtxt(t){this.setAttr("dimtxt",t)}get dimcen(){return this.getAttr("dimcen")}set dimcen(t){this.setAttr("dimcen",t)}get dimtsz(){return this.getAttr("dimtsz")}set dimtsz(t){this.setAttr("dimtsz",t)}get dimaltf(){return this.getAttr("dimaltf")}set dimaltf(t){this.setAttr("dimaltf",t)}get dimlfac(){return this.getAttr("dimlfac")}set dimlfac(t){this.setAttr("dimlfac",t)}get dimtvp(){return this.getAttr("dimtvp")}set dimtvp(t){this.setAttr("dimtvp",t)}get dimtfac(){return this.getAttr("dimtfac")}set dimtfac(t){this.setAttr("dimtfac",t)}get dimgap(){return this.getAttr("dimgap")}set dimgap(t){this.setAttr("dimgap",t)}get dimaltrnd(){return this.getAttr("dimaltrnd")}set dimaltrnd(t){this.setAttr("dimaltrnd",t)}get dimtol(){return this.getAttr("dimtol")}set dimtol(t){this.setAttr("dimtol",t)}get dimlim(){return this.getAttr("dimlim")}set dimlim(t){this.setAttr("dimlim",t)}get dimtih(){return this.getAttr("dimtih")}set dimtih(t){this.setAttr("dimtih",t)}get dimtoh(){return this.getAttr("dimtoh")}set dimtoh(t){this.setAttr("dimtoh",t)}get dimse1(){return this.getAttr("dimse1")}set dimse1(t){this.setAttr("dimse1",t)}get dimse2(){return this.getAttr("dimse2")}set dimse2(t){this.setAttr("dimse2",t)}get dimtad(){return this.getAttr("dimtad")}set dimtad(t){this.setAttr("dimtad",t)}get dimzin(){return this.getAttr("dimzin")}set dimzin(t){this.setAttr("dimzin",t)}get dimazin(){return this.getAttr("dimazin")}set dimazin(t){this.setAttr("dimazin",t)}get dimalt(){return this.getAttr("dimalt")}set dimalt(t){this.setAttr("dimalt",t)}get dimaltd(){return this.getAttr("dimaltd")}set dimaltd(t){this.setAttr("dimaltd",t)}get dimtofl(){return this.getAttr("dimtofl")}set dimtofl(t){this.setAttr("dimtofl",t)}get dimsah(){return this.getAttr("dimsah")}set dimsah(t){this.setAttr("dimsah",t)}get dimtix(){return this.getAttr("dimtix")}set dimtix(t){this.setAttr("dimtix",t)}get dimsoxd(){return this.getAttr("dimsoxd")}set dimsoxd(t){this.setAttr("dimsoxd",t)}get dimclrd(){return this.getAttr("dimclrd")}set dimclrd(t){this.setAttr("dimclrd",t)}get dimclre(){return this.getAttr("dimclre")}set dimclre(t){this.setAttr("dimclre",t)}get dimclrt(){return this.getAttr("dimclrt")}set dimclrt(t){this.setAttr("dimclrt",t)}get dimadec(){return this.getAttr("dimadec")}set dimadec(t){this.setAttr("dimadec",t)}get dimunit(){return this.getAttr("dimunit")}set dimunit(t){this.setAttr("dimunit",t)}get dimdec(){return this.getAttr("dimdec")}set dimdec(t){this.setAttr("dimdec",t)}get dimtdec(){return this.getAttr("dimtdec")}set dimtdec(t){this.setAttr("dimtdec",t)}get dimaltu(){return this.getAttr("dimaltu")}set dimaltu(t){this.setAttr("dimaltu",t)}get dimalttd(){return this.getAttr("dimalttd")}set dimalttd(t){this.setAttr("dimalttd",t)}get dimaunit(){return this.getAttr("dimaunit")}set dimaunit(t){this.setAttr("dimaunit",t)}get dimfrac(){return this.getAttr("dimfrac")}set dimfrac(t){this.setAttr("dimfrac",t)}get dimlunit(){return this.getAttr("dimlunit")}set dimlunit(t){this.setAttr("dimlunit",t)}get dimdsep(){return this.getAttr("dimdsep")}set dimdsep(t){this.setAttr("dimdsep",t)}get dimtmove(){return this.getAttr("dimtmove")}set dimtmove(t){this.setAttr("dimtmove",t)}get dimjust(){return this.getAttr("dimjust")}set dimjust(t){this.setAttr("dimjust",t)}get dimsd1(){return this.getAttr("dimsd1")}set dimsd1(t){this.setAttr("dimsd1",t)}get dimsd2(){return this.getAttr("dimsd2")}set dimsd2(t){this.setAttr("dimsd2",t)}get dimtolj(){return this.getAttr("dimtolj")}set dimtolj(t){this.setAttr("dimtolj",t)}get dimtzin(){return this.getAttr("dimtzin")}set dimtzin(t){this.setAttr("dimtzin",t)}get dimaltz(){return this.getAttr("dimaltz")}set dimaltz(t){this.setAttr("dimaltz",t)}get dimalttz(){return this.getAttr("dimalttz")}set dimalttz(t){this.setAttr("dimalttz",t)}get dimfit(){return this.getAttr("dimfit")}set dimfit(t){this.setAttr("dimfit",t)}get dimupt(){return this.getAttr("dimupt")}set dimupt(t){this.setAttr("dimupt",t)}get dimatfit(){return this.getAttr("dimatfit")}set dimatfit(t){this.setAttr("dimatfit",t)}get dimtxsty(){return this.getAttr("dimtxsty")}set dimtxsty(t){this.setAttr("dimtxsty",t)}get dimldrblk(){return this.getAttr("dimldrblk")}set dimldrblk(t){this.setAttr("dimldrblk",t)}get dimblk(){return this.getAttr("dimblk")}set dimblk(t){this.setAttr("dimblk",t)}get dimblk1(){return this.getAttr("dimblk1")}set dimblk1(t){this.setAttr("dimblk1",t)}get dimblk2(){return this.getAttr("dimblk2")}set dimblk2(t){this.setAttr("dimblk2",t)}get dimlwd(){return this.getAttr("dimlwd")}set dimlwd(t){this.setAttr("dimlwd",t)}get dimlwe(){return this.getAttr("dimlwe")}set dimlwe(t){this.setAttr("dimlwe",t)}};Qi.DEFAULT_DIM_VALUES={name:"",dimpost:"",dimapost:"",dimscale:1,dimasz:2.5,dimexo:.625,dimdli:.38,dimexe:.18,dimrnd:0,dimdle:0,dimtp:0,dimtm:0,dimtxt:2.5,dimcen:2.5,dimtsz:0,dimaltf:0,dimlfac:1,dimtvp:0,dimtfac:1,dimgap:1,dimaltrnd:0,dimtol:0,dimlim:0,dimtih:0,dimtoh:0,dimse1:0,dimse2:0,dimtad:0,dimzin:0,dimazin:0,dimalt:0,dimaltd:2,dimtofl:0,dimsah:0,dimtix:0,dimsoxd:0,dimclrd:0,dimclre:0,dimclrt:0,dimadec:0,dimunit:2,dimdec:4,dimtdec:4,dimaltu:2,dimalttd:2,dimaunit:0,dimfrac:0,dimlunit:2,dimdsep:".",dimtmove:0,dimjust:0,dimsd1:0,dimsd2:0,dimtolj:0,dimtzin:0,dimaltz:0,dimalttz:0,dimfit:0,dimupt:0,dimatfit:3,dimtxsty:"Standard",dimldrblk:"",dimblk:"",dimblk1:"",dimblk2:"",dimlwd:-2,dimlwe:-2};let ni=Qi;class Ql extends rr{constructor(t){super(),this.name=t.name,this._linetype=t}get numDashes(){return this._linetype.pattern?this._linetype.pattern.length:0}get patternLength(){return this._linetype.totalPatternLength}get comments(){return this._linetype.description}get linetype(){return this._linetype}dashLengthAt(t){if(t<0||t>=this.numDashes)throw new Error('Index must be greater than or equal to zero, but less than the value of property "numDashes".');return this._linetype.pattern[t].elementLength}}class Jl extends rr{constructor(t){super(),this.name=t.name,this._textStyle=t,this._textStyle.font=this.getFileNameWithoutExtension(this._textStyle.font||this._textStyle.extendedFont||this.name),this._isVertical=!1}get obliquingAngle(){return this._textStyle.obliqueAngle}set obliquingAngle(t){this._textStyle.obliqueAngle=t}get priorSize(){return this._textStyle.lastHeight}set priorSize(t){this._textStyle.lastHeight=t}get textSize(){return this._textStyle.fixedTextHeight}set textSize(t){this._textStyle.fixedTextHeight=t}get xScale(){return this._textStyle.widthFactor}set xScale(t){this._textStyle.widthFactor=t}get isVertical(){return this._isVertical}set isVertical(t){this._isVertical=t}get fileName(){return this._textStyle.font}set fileName(t){this._textStyle.font=t}get bigFontFileName(){return this._textStyle.bigFont}set bigFontFileName(t){this._textStyle.bigFont=t}get textStyle(){return this._textStyle}getFileNameWithoutExtension(t){const e=t.split("/").pop();if(e){const i=e.lastIndexOf(".");return i===-1?e:e.substring(0,i)}return t}}const _u={center:new Mt,viewDirectionFromTarget:new X(0,0,1),viewTarget:new X(0,0,0),lensLength:500,frontClippingPlane:0,backClippingPlane:0,viewHeight:1e3,viewTwistAngle:0,frozenLayers:[],styleSheet:"",renderMode:Us.OPTIMIZED_2D,viewMode:0,ucsIconSetting:0,ucsOrigin:new X(0,0,0),ucsXAxis:new X(1,0,0),ucsYAxis:new X(0,1,0),orthographicType:js.TOP,shadePlotSetting:0,shadePlotObjectId:void 0,visualStyleObjectId:void 0,isDefaultLightingOn:!1,defaultLightingType:Gs.ONE_DISTANT_LIGHT,brightness:0,contrast:0,ambientColor:void 0};class th extends rr{constructor(){super(),this._circleSides=100,this._center=new Mt,this._lowerLeftCorner=new Mt(0,0),this._upperRightCorner=new Mt(1,1),this._snapBase=new Mt(0,0),this._snapAngle=0,this._snapSpacing=new Mt(0,0),this._standardFlag=0,this._gridSpacing=new Mt,this._gridMajor=10,this._gsView=_u}get circleSides(){return this._circleSides}set circleSides(t){this._circleSides=t}get center(){return this._center}get lowerLeftCorner(){return this._lowerLeftCorner}set lowerLeftCorner(t){this._lowerLeftCorner.copy(t)}get upperRightCorner(){return this._upperRightCorner}set upperRightCorner(t){this._upperRightCorner.copy(t)}get snapBase(){return this._snapBase}set snapBase(t){this._snapBase.copy(t)}get snapAngle(){return this._snapAngle}set snapAngle(t){this._snapAngle=t}get snapIncrements(){return this._snapSpacing}set snapIncrements(t){this._snapSpacing.copy(t)}get gridMajor(){return this._gridMajor}set gridMajor(t){this._gridMajor=t}get gridIncrements(){return this._gridSpacing}set gridIncrements(t){this._gridSpacing.copy(t)}get standardFlag(){return this._standardFlag}set standardFlag(t){this._standardFlag=t}get snapEnabled(){return!!(this._standardFlag&256)}get backgroundObjectId(){return this._backgroundObjectId}set backgroundObjectId(t){this._backgroundObjectId=t}get gsView(){return this._gsView}}class eh{constructor(){this.events={layoutSwitched:new Ee}}countLayouts(t){return this.getWorkingDatabase(t).dictionaries.layouts.numEntries}findLayoutNamed(t,e){return this.getWorkingDatabase(e).dictionaries.layouts.getAt(t)}findActiveLayout(){const t=this.getActiveLayout();return t?t.layoutName:"Model"}setCurrentLayoutId(t,e){const i=this.getWorkingDatabase(e),l=i.dictionaries.layouts.getIdAt(t);return this.setCurrentLayoutInternal(l,i)}setCurrentLayoutBtrId(t,e){const i=this.getWorkingDatabase(e),l=i.dictionaries.layouts.getBtrIdAt(t);return this.setCurrentLayoutInternal(l,i)}setCurrentLayout(t,e){const i=this.getWorkingDatabase(e),l=i.dictionaries.layouts.getAt(t);return this.setCurrentLayoutInternal(l,i)}renameLayout(t,e,i){const h=this.getWorkingDatabase(i).dictionaries.layouts.getAt(t);return h?(h.layoutName=e,!0):!1}layoutExists(t,e){return this.getWorkingDatabase(e).dictionaries.layouts.has(t)}deleteLayout(t,e){return this.getWorkingDatabase(e).dictionaries.layouts.remove(t)}createLayout(t,e){const i=this.getWorkingDatabase(e),l=new qs;l.layoutName=t,l.tabOrder=i.dictionaries.layouts.maxTabOrder;const h=new Ne;return h.name=`*Paper_Space${l.tabOrder}`,i.tables.blockTable.add(h),i.dictionaries.layouts.setAt(t,l),{layout:l,btr:h}}getActiveLayout(t){const e=this.getWorkingDatabase(t);return e.dictionaries.layouts.getBtrIdAt(e.currentSpaceId)}getWorkingDatabase(t){return t||Xs().workingDatabase}setCurrentLayoutInternal(t,e){return t?(this.events.layoutSwitched.dispatch({oldLayout:this.getActiveLayout(),newLayout:t}),e.currentSpaceId=t.blockTableRecordId,!0):!1}}function Xs(){return Zi.instance}const Ji=class Ji{constructor(){this._workingDatabase=null,this._layoutManager=new eh}get workingDatabase(){if(this._workingDatabase==null)throw new Error("The current working database must be set before using it!");return this._workingDatabase}set workingDatabase(t){this._workingDatabase=t}get layoutManager(){return this._layoutManager}};Ji.instance=new Ji;let Zi=Ji;L.AcCmColor=jn,L.AcCmErrors=Ie,L.AcCmEventDispatcher=Ph,L.AcCmEventManager=Ee,L.AcCmLoader=Lh,L.AcCmLoadingManager=ma,L.AcCmObject=ca,L.AcCmPerformanceCollector=is,L.AcCmTask=ua,L.AcCmTaskScheduler=da,L.AcDb3PointAngularDimension=Ll,L.AcDbAlignedDimension=Nl,L.AcDbAngleUnits=ys,L.AcDbArc=ol,L.AcDbArcDimension=gu,L.AcDbBatchProcessing=fa,L.AcDbBlockReference=Fs,L.AcDbBlockTable=Ul,L.AcDbBlockTableRecord=Ne,L.AcDbCircle=ll,L.AcDbCurve=qe,L.AcDbDatabase=pu,L.AcDbDatabaseConverter=yo,L.AcDbDatabaseConverterManager=en,L.AcDbDiametricDimension=zl,L.AcDbDictionary=Ys,L.AcDbDimArrowType=_o,L.AcDbDimStyleTable=jl,L.AcDbDimStyleTableRecord=ni,L.AcDbDimTextHorizontal=Yl,L.AcDbDimTextVertical=Kl,L.AcDbDimVerticalJustification=Zl,L.AcDbDimZeroSuppression=Xl,L.AcDbDimZeroSuppressionAngular=$l,L.AcDbDimension=nr,L.AcDbDxfConverter=Vl,L.AcDbEllipse=al,L.AcDbEntity=tn,L.AcDbFileType=ei,L.AcDbHatch=ul,L.AcDbHatchPatternType=hl,L.AcDbHatchStyle=cl,L.AcDbHostApplicationServices=Zi,L.AcDbLayerTable=Gl,L.AcDbLayerTableRecord=Ks,L.AcDbLayout=qs,L.AcDbLayoutDictionary=Bl,L.AcDbLayoutManager=eh,L.AcDbLeader=ml,L.AcDbLeaderAnnotationType=dl,L.AcDbLine=gl,L.AcDbLineSpacingStyle=Cl,L.AcDbLinetypeTable=Hl,L.AcDbLinetypeTableRecord=Ql,L.AcDbMText=fl,L.AcDbObject=Tn,L.AcDbObjectIterator=Bi,L.AcDbOrdinateDimension=Dl,L.AcDbOsnapMode=Xn,L.AcDbPoint=Al,L.AcDbPolyline=wl,L.AcDbRadialDimension=Ol,L.AcDbRasterImage=Ws,L.AcDbRasterImageClipBoundaryType=Pl,L.AcDbRasterImageDef=Fl,L.AcDbRasterImageImageDisplayOpt=Sl,L.AcDbRay=El,L.AcDbRenderingCache=Sn,L.AcDbSpline=Hs,L.AcDbSymbolTable=ir,L.AcDbSymbolTableRecord=rr,L.AcDbTable=pl,L.AcDbText=bl,L.AcDbTextHorizontalMode=vl,L.AcDbTextStyleTable=Wl,L.AcDbTextStyleTableRecord=Jl,L.AcDbTextVerticalMode=yl,L.AcDbTrace=xl,L.AcDbUnitsValue=bs,L.AcDbViewport=Ml,L.AcDbViewportTable=ql,L.AcDbViewportTableRecord=th,L.AcDbWipeout=kl,L.AcDbXline=Tl,L.AcGeArea2d=ji,L.AcGeBox2d=me,L.AcGeBox3d=Rt,L.AcGeCatmullRomCurve3d=rl,L.AcGeCircArc2d=pr,L.AcGeCircArc3d=Jn,L.AcGeCurve2d=fr,L.AcGeEllipseArc2d=Hi,L.AcGeEllipseArc3d=Wi,L.AcGeEuler=Qo,L.AcGeGeometryUtil=Uo,L.AcGeLine2d=qi,L.AcGeLine3d=Mn,L.AcGeLoop2d=el,L.AcGeMathUtil=zt,L.AcGeMatrix2d=Fi,L.AcGeMatrix3d=Zn,L.AcGeNurbsCurve=tr,L.AcGePlane=Qr,L.AcGePoint2d=Mt,L.AcGePoint3d=X,L.AcGePolyline2d=ti,L.AcGeQuaternion=In,L.AcGeShape2d=Os,L.AcGeSpline3d=kn,L.AcGeTol=Ts,L.AcGeVector2d=Xt,L.AcGeVector3d=Z,L.AcGiArrowType=Vs,L.AcGiDefaultLightingType=Gs,L.AcGiMTextAttachmentPoint=vr,L.AcGiMTextFlowDirection=Ki,L.AcGiOrthographicType=js,L.AcGiRenderMode=Us,L.AcGiViewport=Xi,L.AcTrStringUtil=Ch,L.ByBlock=po,L.ByLayer=Ri,L.DEBUG_MODE=kh,L.DEFAULT_LINE_TYPE=Oi,L.DEFAULT_TOL=Cs,L.DEG2RAD=xs,L.DefaultLoadingManager=ga,L.FLOAT_TOL=$n,L.ORIGIN_POINT_2D=ru,L.ORIGIN_POINT_3D=ks,L.RAD2DEG=ws,L.TAU=te,L.acdbHostApplicationServices=Xs,L.basisFunction=Vi,L.calculateCurveLength=Wo,L.ceilPowerOfTwo=Do,L.clamp=_n,L.clone=Dr,L.damp=Po,L.defaults=cr,L.degToRad=Lo,L.euclideanModulo=As,L.evaluateNurbsPoint=Zr,L.floorPowerOfTwo=Oo,L.generateChordKnots=Go,L.generateSqrtChordKnots=Ho,L.generateUUID=xo,L.generateUniformKnots=jo,L.has=la,L.intPartLength=Ss,L.interpolateControlPoints=iu,L.inverseLerp=Ao,L.isBetween=Ro,L.isBetweenAngle=Bo,L.isEmpty=ha,L.isEqual=ur,L.isImperialUnits=nu,L.isMetricUnits=eu,L.isPointInPolygon=Ls,L.isPolygonIntersect=Vo,L.isPowerOfTwo=zo,L.lerp=Ps,L.log=zr,L.mapLinear=wo,L.normalizeAngle=$r,L.pingpong=So,L.radToDeg=No,L.randFloat=ko,L.randFloatSpread=To,L.randInt=Mo,L.relativeEps=Fo,L.seededRandom=Co,L.setLogLevel=Th,L.smootherstep=Eo,L.smoothstep=Io,Object.defineProperty(L,Symbol.toStringTag,{value:"Module"})});