@mlightcad/data-model 1.2.21 → 1.2.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function jc(i,e){for(var t=0;t<e.length;t++){const s=e[t];if(typeof s!="string"&&!Array.isArray(s)){for(const o in s)if(o!=="default"&&!(o in i)){const h=Object.getOwnPropertyDescriptor(s,o);h&&Object.defineProperty(i,o,h.get?h:{enumerable:!0,get:()=>s[o]})}}}return Object.freeze(Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}))}const Ys={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},qi=[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 hs(i,e,t){return Math.max(e,Math.min(t,i))}const Ho=class qo{constructor(){this._colorIndex=256,this._color=null,this._colorName=null}get color(){return this._color}set color(e){e==null?this._color=null:(this._color=Math.round(hs(e,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 e=this._color.toString(16).toUpperCase();for(;e.length<6;)e="0"+e;return`0x${e}`}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(e){e==null?this._colorIndex=null:(this._colorIndex=hs(e,0,256),this._colorIndex>0&&this._colorIndex<256?(this._color=qi[e],this._colorName=this.getColorNameByValue(this._color)):(this._color=null,this._colorName=null))}get colorName(){return this._colorName}set colorName(e){if(e){const t=Ys[e.toLowerCase()];t!==void 0?(this._colorName=e,this._color=t,this._colorIndex=this.getColorIndexByValue(this._color)):console.warn("Unknown color: "+e)}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(e){return this.setRGB(e,e,e),this}setRGB(e,t,s){const o=Math.round(hs(e,0,255)),h=Math.round(hs(t,0,255)),u=Math.round(hs(s,0,255));return this.color=(o<<16)+(h<<8)+u,this}setColorName(e){const t=Ys[e.toLowerCase()];return t!==void 0?this.color=t:console.warn("Unknown color "+e),this}clone(){const e=new qo;return e.colorIndex=this.colorIndex,e.color=this.color,e._colorName=this._colorName,this}copy(e){return this.colorIndex=e.colorIndex,this.color=e.color,this._colorName=e._colorName,this}equals(e){return e.color==this.color&&e.colorIndex==this.colorIndex&&e._colorName==this._colorName}toString(){return this.isByLayer?"ByLayer":this.isByBlock?"ByBlock":this.colorName?this.colorName:this.hexColor}getColorNameByValue(e){for(const[t,s]of Object.entries(Ys))if(s===e)return t;return null}getColorIndexByValue(e){const t=qi.length-1;for(let s=1;s<t;++s)if(qi[s]===e)return s;return null}};Ho.NAMES=Ys;let Wr=Ho;const Ut={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")}};let Gc=class{constructor(){this._listeners={}}addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const s=this._listeners;s[e]===void 0&&(s[e]=[]),s[e].indexOf(t)===-1&&s[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const s=this._listeners;return s[e]!==void 0&&s[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const s=this._listeners[e];if(s!==void 0){const o=s.indexOf(t);o!==-1&&s.splice(o,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const t=this._listeners[e.type];if(t!==void 0){e.target=this;const s=t.slice(0);for(let o=0,h=s.length;o<h;o++)s[o].call(this,e)}}},it=class{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}removeEventListener(e){this.listeners=this.listeners.filter(t=>t!==e)}replaceEventListener(e){this.removeEventListener(e),this.addEventListener(e)}dispatch(e,...t){for(const s of this.listeners)s.call(null,e,...t)}};var Wc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Hc(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Yo={exports:{}};(function(i){(function(e,t){i.exports?i.exports=t():e.log=t()})(Wc,function(){var e=function(){},t="undefined",s=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),o=["trace","debug","info","warn","error"],h={},u=null;function g(D,U){var B=D[U];if(typeof B.bind=="function")return B.bind(D);try{return Function.prototype.bind.call(B,D)}catch{return function(){return Function.prototype.apply.apply(B,[D,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 f(D){return D==="debug"&&(D="log"),typeof console===t?!1:D==="trace"&&s?b:console[D]!==void 0?g(console,D):console.log!==void 0?g(console,"log"):e}function S(){for(var D=this.getLevel(),U=0;U<o.length;U++){var B=o[U];this[B]=U<D?e:this.methodFactory(B,D,this.name)}if(this.log=this.debug,typeof console===t&&D<this.levels.SILENT)return"No console available for logging"}function x(D){return function(){typeof console!==t&&(S.call(this),this[D].apply(this,arguments))}}function E(D,U,B){return f(D)||x.apply(this,arguments)}function M(D,U){var B=this,ge,be,oe,W="loglevel";typeof D=="string"?W+=":"+D:typeof D=="symbol"&&(W=void 0);function ce(xe){var Le=(o[xe]||"silent").toUpperCase();if(!(typeof window===t||!W)){try{window.localStorage[W]=Le;return}catch{}try{window.document.cookie=encodeURIComponent(W)+"="+Le+";"}catch{}}}function se(){var xe;if(!(typeof window===t||!W)){try{xe=window.localStorage[W]}catch{}if(typeof xe===t)try{var Le=window.document.cookie,dt=encodeURIComponent(W),mt=Le.indexOf(dt+"=");mt!==-1&&(xe=/^([^;]+)/.exec(Le.slice(mt+dt.length+1))[1])}catch{}return B.levels[xe]===void 0&&(xe=void 0),xe}}function Ve(){if(!(typeof window===t||!W)){try{window.localStorage.removeItem(W)}catch{}try{window.document.cookie=encodeURIComponent(W)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function Ye(xe){var Le=xe;if(typeof Le=="string"&&B.levels[Le.toUpperCase()]!==void 0&&(Le=B.levels[Le.toUpperCase()]),typeof Le=="number"&&Le>=0&&Le<=B.levels.SILENT)return Le;throw new TypeError("log.setLevel() called with invalid level: "+xe)}B.name=D,B.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},B.methodFactory=U||E,B.getLevel=function(){return oe??be??ge},B.setLevel=function(xe,Le){return oe=Ye(xe),Le!==!1&&ce(oe),S.call(B)},B.setDefaultLevel=function(xe){be=Ye(xe),se()||B.setLevel(xe,!1)},B.resetLevel=function(){oe=null,Ve(),S.call(B)},B.enableAll=function(xe){B.setLevel(B.levels.TRACE,xe)},B.disableAll=function(xe){B.setLevel(B.levels.SILENT,xe)},B.rebuild=function(){if(u!==B&&(ge=Ye(u.getLevel())),S.call(B),u===B)for(var xe in h)h[xe].rebuild()},ge=Ye(u?u.getLevel():"WARN");var We=se();We!=null&&(oe=Ye(We)),S.call(B)}u=new M,u.getLogger=function(D){if(typeof D!="symbol"&&typeof D!="string"||D==="")throw new TypeError("You must supply a name when creating a logger.");var U=h[D];return U||(U=h[D]=new M(D,u.methodFactory)),U};var z=typeof window!==t?window.log:void 0;return u.noConflict=function(){return typeof window!==t&&window.log===u&&(window.log=z),u},u.getLoggers=function(){return h},u.default=u,u})})(Yo);var Xo=Yo.exports;const qc=Hc(Xo),Yc=jc({__proto__:null,default:qc},[Xo]),Xc=!0,ks=Yc;ks.setLevel("debug");const Kc=i=>{try{ks.setLevel(i)}catch(e){ks.setLevel("error"),ks.error(e)}};function Is(i){return i===null||typeof i!="object"?i:Array.isArray(i)?[...i]:{...i}}function Fn(i,...e){for(const t of e)if(t)for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&i[s]===void 0&&(i[s]=t[s]);return i}function Ko(i,e){return i!=null&&Object.prototype.hasOwnProperty.call(i,e)}function $o(i){return i==null?!0:Array.isArray(i)||typeof i=="string"?i.length===0:i instanceof Map||i instanceof Set?i.size===0:typeof i=="object"?Object.keys(i).length===0:!1}function zn(i,e){if(i===e)return!0;if(i==null||e==null)return i===e;if(typeof i!=typeof e)return!1;if(typeof i!="object")return i===e;if(Array.isArray(i)!==Array.isArray(e))return!1;if(Array.isArray(i)){if(i.length!==e.length)return!1;for(let o=0;o<i.length;o++)if(!zn(i[o],e[o]))return!1;return!0}const t=Object.keys(i),s=Object.keys(e);if(t.length!==s.length)return!1;for(const o of t)if(!Object.prototype.hasOwnProperty.call(e,o)||!zn(i[o],e[o]))return!1;return!0}let Zo=class Qo{constructor(e,t){this.events={attrChanged:new it,modelChanged:new it},this._changing=!1,this._previousAttributes={},this._pending=!1;const s=e||{};t&&Fn(s,t),this.attributes=s,this.changed={}}get(e){return this.attributes[e]}set(e,t,s){if(e==null)return this;let o;typeof e=="object"?(o=e,s=t):(o={},o[e]=t),s||(s={});const h=s.unset,u=s.silent,g=[],b=this._changing;this._changing=!0,b||(this._previousAttributes=Is(this.attributes),this.changed={});const f=this.attributes,S=this.changed,x=this._previousAttributes;for(const E in o)t=o[E],zn(f[E],t)||g.push(E),zn(x[E],t)?delete S[E]:S[E]=t,h?delete f[E]:f[E]=t;if(!u){g.length&&(this._pending=s);for(let E=0;E<g.length;E++)this.events.attrChanged.dispatch({object:this,attrName:g[E],attrValue:f[g[E]],options:s})}if(b)return this;if(!u)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(e){return this.get(e)!=null}hasChanged(e){return e==null?!$o(this.changed):Ko(this.changed,e)}changedAttributes(e){if(!e)return this.hasChanged()?Is(this.changed):{};const t=this._changing?this._previousAttributes:this.attributes,s={};for(const o in e){const h=e[o];zn(t[o],h)||(s[o]=h)}return s}previous(e){return e==null||!this._previousAttributes?null:this._previousAttributes[e]}previousAttributes(){return Is(this._previousAttributes)}clone(){const e=Is(this.attributes);return new Qo(e)}},ma=class Es{constructor(){this.entries=new Map}static getInstance(){return Es.instance||(Es.instance=new Es),Es.instance}collect(e){this.entries.set(e.name,e)}printAll(){for(const[e,t]of this.entries)console.log(`${e}:`),console.log(t.format())}clear(){this.entries.clear()}getAll(){return Array.from(this.entries.values())}getEntry(e){return this.entries.get(e)}remove(e){return this.entries.delete(e)}};class $c{static formatBytes(e,t=2){if(e===0)return"0 B";const s=1024,o=Math.max(0,t),h=["B","KB","MB","GB","TB"],u=Math.floor(Math.log(e)/Math.log(s)),g=e/Math.pow(s,u);return`${parseFloat(g.toFixed(o))} ${h[u]}`}}class Jo{constructor(e){this.name=e}run(e){throw new Error("run() must be implemented by subclass")}}class el{constructor(){this.tasks=[],this.onProgress=()=>{},this.onComplete=()=>{},this.onError=()=>{}}scheduleTask(e){return new Promise((t,s)=>{const o=()=>{Promise.resolve(e()).then(t).catch(s)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(o):setTimeout(o,0)})}addTask(e){this.tasks.push(e)}setProgressCallback(e){this.onProgress=e}setCompleteCallback(e){this.onComplete=e}setErrorCallback(e){this.onError=e}async run(e){const t=this.tasks.length;let s=e;for(let o=0;o<t;o++){const h=this.tasks[o];try{s=await this.scheduleTask(async()=>{const u=await h.run(s);return this.onProgress((o+1)/t,h),u})}catch(u){this.onError({error:u,taskIndex:o,task:h});return}}this.onComplete(s)}}let tl=class{constructor(e,t,s){this.isLoading=!1,this.itemsLoaded=0,this.itemsTotal=0,this.urlModifier=void 0,this.handlers=[],this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=s}itemStart(e){this.itemsTotal++,this.isLoading===!1&&this.onStart!==void 0&&this.onStart(e,this.itemsLoaded,this.itemsTotal),this.isLoading=!0}itemEnd(e){this.itemsLoaded++,this.onProgress!==void 0&&this.onProgress(e,this.itemsLoaded,this.itemsTotal),this.itemsLoaded===this.itemsTotal&&(this.isLoading=!1,this.onLoad!==void 0&&this.onLoad())}itemError(e){this.onError!==void 0&&this.onError(e)}resolveURL(e){return this.urlModifier?this.urlModifier(e):e}setURLModifier(e){return this.urlModifier=e,this}addHandler(e,t){return this.handlers.push(e,t),this}removeHandler(e){const t=this.handlers.indexOf(e);return t!==-1&&this.handlers.splice(t,2),this}getHandler(e){for(let t=0,s=this.handlers.length;t<s;t+=2){const o=this.handlers[t],h=this.handlers[t+1];if(o.global&&(o.lastIndex=0),o.test(e))return h}return null}};const rl=new tl;let Zc=class{constructor(e){this.manager=e!==void 0?e:rl,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}loadAsync(e,t){return new Promise((s,o)=>{this.load(e,s,t,o)})}parse(e){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}};class nl{constructor(e,t,s){this._chunkSize=-1,this._minimumChunkSize=50,this._count=e,this._numerOfChunk=t<1?1:t,this._minimumChunkSize=s,this.calculateChunkSize()}get count(){return this._count}get numerOfChunk(){return this._numerOfChunk}get minimumChunkSize(){return this._minimumChunkSize}set minimumChunkSize(e){this._minimumChunkSize=e,this.calculateChunkSize()}get chunkSize(){return this._chunkSize}calculateChunkSize(){let e=this._count/this._numerOfChunk;e<this._minimumChunkSize&&(e=Math.min(this._minimumChunkSize,this._count)),this._chunkSize=e<1?this._count:Math.floor(e)}scheduleTask(e){return new Promise((t,s)=>{const o=()=>{Promise.resolve(e()).then(t).catch(s)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(o):setTimeout(o,0)})}async processChunk(e){let t=0;const s=async()=>{const o=t,h=Math.min(t+this._chunkSize,this._count);await e(o,h),t=h,t<this._count&&await this.scheduleTask(s)};await s()}}var ht,cs,Qe,st,us,Jt,yt,pr,er,en,ds,ms,tn,rn,ps,gs,fs,Nt,gr,qe,nn,_s,_e,bt,vs,xt,ys,fr,_r,tr,bs,sn,Ct,vr,an,Yi,Xi,yr,br,xs,ws,xr,As,Ki,$i,ct,wr,ut,Lt,Zi,Qi,Ji,ea,Ar,Ot,on,Ss,ln,zt,Sr,Dt,Pr;(ht={})[ht.None=0]="None",ht[ht.Anonymous=1]="Anonymous",ht[ht.NonConstant=2]="NonConstant",ht[ht.Xref=4]="Xref",ht[ht.XrefOverlay=8]="XrefOverlay",ht[ht.ExternallyDependent=16]="ExternallyDependent",ht[ht.ResolvedOrDependent=32]="ResolvedOrDependent",ht[ht.ReferencedXref=64]="ReferencedXref";(cs={})[cs.BYBLOCK=0]="BYBLOCK",cs[cs.BYLAYER=256]="BYLAYER";(Qe={})[Qe.Rotated=0]="Rotated",Qe[Qe.Aligned=1]="Aligned",Qe[Qe.Angular=2]="Angular",Qe[Qe.Diameter=3]="Diameter",Qe[Qe.Radius=4]="Radius",Qe[Qe.Angular3Point=5]="Angular3Point",Qe[Qe.Ordinate=6]="Ordinate",Qe[Qe.ReferenceIsExclusive=32]="ReferenceIsExclusive",Qe[Qe.IsOrdinateXTypeFlag=64]="IsOrdinateXTypeFlag",Qe[Qe.IsCustomTextPositionFlag=128]="IsCustomTextPositionFlag";(st={})[st.TopLeft=1]="TopLeft",st[st.TopCenter=2]="TopCenter",st[st.TopRight=3]="TopRight",st[st.MiddleLeft=4]="MiddleLeft",st[st.MiddleCenter=5]="MiddleCenter",st[st.MiddleRight=6]="MiddleRight",st[st.BottomLeft=7]="BottomLeft",st[st.BottomCenter=8]="BottomCenter",st[st.BottomRight=9]="BottomRight";(us={})[us.AtLeast=1]="AtLeast",us[us.Exact=2]="Exact";var ko=((Jt={})[Jt.Center=0]="Center",Jt[Jt.Above=1]="Above",Jt[Jt.Outside=2]="Outside",Jt[Jt.JIS=3]="JIS",Jt[Jt.Below=4]="Below",Jt),Cn=((yt={})[yt.Feet=0]="Feet",yt[yt.None=1]="None",yt[yt.Inch=2]="Inch",yt[yt.FeetAndInch=3]="FeetAndInch",yt[yt.Leading=4]="Leading",yt[yt.Trailing=8]="Trailing",yt[yt.LeadingAndTrailing=12]="LeadingAndTrailing",yt),Qc=((pr={})[pr.None=0]="None",pr[pr.Leading=1]="Leading",pr[pr.Trailing=2]="Trailing",pr[pr.LeadingAndTrailing=3]="LeadingAndTrailing",pr),Jc=((er={})[er.Center=0]="Center",er[er.Left=1]="Left",er[er.Right=2]="Right",er[er.OverFirst=3]="OverFirst",er[er.OverSecond=4]="OverSecond",er),eu=((en={})[en.Bottom=0]="Bottom",en[en.Center=1]="Center",en[en.Top=2]="Top",en);(ds={})[ds.PatternFill=0]="PatternFill",ds[ds.SolidFill=1]="SolidFill";(ms={})[ms.NonAssociative=0]="NonAssociative",ms[ms.Associative=1]="Associative";(tn={})[tn.Normal=0]="Normal",tn[tn.Outer=1]="Outer",tn[tn.Ignore=2]="Ignore";(rn={})[rn.UserDefined=0]="UserDefined",rn[rn.Predefined=1]="Predefined",rn[rn.Custom=2]="Custom";(ps={})[ps.NotAnnotated=0]="NotAnnotated",ps[ps.Annotated=1]="Annotated";(gs={})[gs.Solid=0]="Solid",gs[gs.Gradient=1]="Gradient";(fs={})[fs.TwoColor=0]="TwoColor",fs[fs.OneColor=1]="OneColor";var tu=((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),js=((gr={})[gr.Line=1]="Line",gr[gr.Circular=2]="Circular",gr[gr.Elliptic=3]="Elliptic",gr[gr.Spline=4]="Spline",gr),ru=((qe={})[qe.Off=0]="Off",qe[qe.Solid=1]="Solid",qe[qe.Dashed=2]="Dashed",qe[qe.Dotted=3]="Dotted",qe[qe.ShotDash=4]="ShotDash",qe[qe.MediumDash=5]="MediumDash",qe[qe.LongDash=6]="LongDash",qe[qe.DoubleShortDash=7]="DoubleShortDash",qe[qe.DoubleMediumDash=8]="DoubleMediumDash",qe[qe.DoubleLongDash=9]="DoubleLongDash",qe[qe.DoubleMediumLongDash=10]="DoubleMediumLongDash",qe[qe.SparseDot=11]="SparseDot",qe);ru.Off;(nn={})[nn.Standard=-3]="Standard",nn[nn.ByLayer=-2]="ByLayer",nn[nn.ByBlock=-1]="ByBlock";(_s={})[_s.English=0]="English",_s[_s.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";(bt={})[bt.OPTIMIZED_2D=0]="OPTIMIZED_2D",bt[bt.WIREFRAME=1]="WIREFRAME",bt[bt.HIDDEN_LINE=2]="HIDDEN_LINE",bt[bt.FLAT_SHADED=3]="FLAT_SHADED",bt[bt.GOURAUD_SHADED=4]="GOURAUD_SHADED",bt[bt.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",bt[bt.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME";(vs={})[vs.UCS_UNCHANGED=0]="UCS_UNCHANGED",vs[vs.HAS_OWN_UCS=1]="HAS_OWN_UCS";(xt={})[xt.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",xt[xt.TOP=1]="TOP",xt[xt.BOTTOM=2]="BOTTOM",xt[xt.FRONT=3]="FRONT",xt[xt.BACK=4]="BACK",xt[xt.LEFT=5]="LEFT",xt[xt.RIGHT=6]="RIGHT";(ys={})[ys.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",ys[ys.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS";(fr={})[fr.ByLayer=0]="ByLayer",fr[fr.ByBlock=1]="ByBlock",fr[fr.ByDictionaryDefault=2]="ByDictionaryDefault",fr[fr.ByObject=3]="ByObject";function Ae(i,e,t){return i.code===e&&(t==null||i.value===t)}function ze(i){let e={};i.rewind();let t=i.next(),s=t.code;if(e.x=t.value,(t=i.next()).code!==s+10)throw Error("Expected code for point value to be 20 but got "+t.code+".");return e.y=t.value,(t=i.next()).code!==s+20?i.rewind():e.z=t.value,e}let pa=Symbol();function ye(i,e){return(t,s,o)=>{let h=function(b,f=!1){return b.reduce((S,x)=>{x.pushContext&&S.push({});let E=S[S.length-1];for(let M of typeof x.code=="number"?[x.code]:x.code){let z=E[M]??(E[M]=[]);x.isMultiple&&z.length&&f&&console.warn(`Snippet ${z[z.length-1].name} for code(${M}) is shadowed by ${x.name}`),z.push(x)}return S},[{}])}(i,s.debug),u=!1,g=h.length-1;for(;!Ae(t,0,"EOF");){let b=function(U,B,ge){return U.find((be,oe)=>{var W;return oe>=ge&&((W=be[B])==null?void 0:W.length)})}(h,t.code,g),f=b==null?void 0:b[t.code],S=f==null?void 0:f[f.length-1];if(!b||!S){s.rewind();break}S.isMultiple||b[t.code].pop();let{name:x,parser:E,isMultiple:M,isReducible:z}=S,D=E==null?void 0:E(t,s,o);if(D===pa){s.rewind();break}if(x){let[U,B]=function(ge,be){let oe=be.split(".");if(!oe.length)throw Error("[parserGenerator::getObjectByPath] Invalid empty path");let W=ge;for(let ce=0;ce<oe.length-1;++ce){let se=ta(oe[ce]),Ve=ta(oe[ce+1]);Object.prototype.hasOwnProperty.call(W,se)||(typeof Ve=="number"?W[se]=[]:W[se]={}),W=W[se]}return[W,ta(oe[oe.length-1])]}(o,x);M&&!z?(Object.prototype.hasOwnProperty.call(U,B)||(U[B]=[]),U[B].push(D)):U[B]=D}S.pushContext&&(g-=1),u=!0,t=s.next()}return e&&Object.setPrototypeOf(o,e),u}}function ta(i){let e=Number.parseInt(i);return Number.isNaN(e)?i:e}function y({value:i}){return i}function G(i,e){return ze(e)}function Be({value:i}){return!!i}let nu=[{code:1001,name:"xdata",parser:sl}];function sl(i,e){var o;if(!Ae(i,1001))throw Error("XData must starts with code 1001");let t={appName:i.value,value:[]};i=e.next();let s=[t.value];for(;!Ae(i,0,"EOF")&&i.code>=1e3;){let h=s[s.length-1];switch(i.code){case 1002:i.value==="{"?s.push([]):(s.pop(),(o=s[s.length-1])==null||o.push(h));break;case 1e3:case 1004:case 1040:case 1070:case 1071:h.push({type:Ir(i.code),value:i.value});break;case 1003:h.push({name:"layer",type:Ir(i.code),value:i.value});break;case 1005:h.push({name:"handle",type:Ir(i.code),value:i.value});break;case 1010:h.push({type:Ir(i.code),value:ze(e)});break;case 1011:h.push({name:"worldSpacePosition",type:Ir(i.code),value:ze(e)});break;case 1012:h.push({name:"worldSpaceDisplacement",type:Ir(i.code),value:ze(e)});break;case 1013:h.push({name:"worldSpaceDirection",type:Ir(i.code),value:ze(e)});break;case 1041:h.push({name:"distance",type:Ir(i.code),value:i.value});break;case 1042:h.push({name:"scale",type:Ir(i.code),value:i.value})}i=e.next()}return e.rewind(),t}function Ir(i){switch(i){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 mn(i,e,t){for(;Ae(i,102);){var s;let o=i.value;if(i=e.next(),!o.startsWith("{")){e.debug&&console.warn(`Invalid application group, expected to start with "{" but received: ${o}`),function(u,g){for(;!Ae(u,102)&&!Ae(u,0,"EOF");)u=g.next()}(i,e),i=e.next();continue}let h=o.slice(1).trim();t.extensions??(t.extensions={}),(s=t.extensions)[h]??(s[h]=[]),function(u,g,b){for(;!Ae(u,102,"}")&&!Ae(u,0,"EOF");)b.push(u),u=g.next()}(i,e,t.extensions[h]),i=e.next()}e.rewind()}let su=0;function il(i){if(!i)throw TypeError("entity cannot be undefined or null");i.handle||(i.handle=su++)}var iu=[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 al(i){return iu[i]}(_r={})[_r.CAST_AND_RECEIVE=0]="CAST_AND_RECEIVE",_r[_r.CAST=1]="CAST",_r[_r.RECEIVE=2]="RECEIVE",_r[_r.IGNORE=3]="IGNORE";let Ue=[...nu,{code:284,name:"shadowMode",parser:y},{code:390,name:"plotStyleHardId",parser:y},{code:380,name:"plotStyleType",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:Be},{code:48,name:"lineTypeScale",parser:y},{code:370,name:"lineweight",parser:y},{code:62,name:"colorIndex",parser(i,e,t){let s=i.value;return s>0&&s<256&&(t.color=al(Math.abs(s))),s}},{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:Be},{code:100},{code:160},{code:330,name:"ownerBlockRecordSoftId",parser:y},{code:102,parser:mn},{code:102,parser:mn},{code:102,parser:mn},{code:5,name:"handle",parser:y}];function Ei(i){return[{code:3,name:i,parser:(e,t,s)=>(s._code3text=(s._code3text??"")+e.value,s._code3text+(s._code1text??"")),isMultiple:!0,isReducible:!0},{code:1,name:i,parser:(e,t,s)=>(s._code1text=e.value,(s._code3text??"")+s._code1text)}]}function ol(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}let au={extrusionDirection:{x:0,y:0,z:1}},ou=[{code:210,name:"extrusionDirection",parser:G},{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:G},{code:39,name:"thickness",parser:y},{code:100},...Ue];class ll{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){ol(this,"parser",ye(ou,au))}}ol(ll,"ForEntityName","ARC");(tr={})[tr.NONE=0]="NONE",tr[tr.INVISIBLE=1]="INVISIBLE",tr[tr.CONSTANT=2]="CONSTANT",tr[tr.VERIFICATION_REQUIRED=4]="VERIFICATION_REQUIRED",tr[tr.PRESET=8]="PRESET";(bs={})[bs.MULTILINE=2]="MULTILINE",bs[bs.CONSTANT_MULTILINE=4]="CONSTANT_MULTILINE";(sn={})[sn.NONE=0]="NONE",sn[sn.MIRRORED_X=2]="MIRRORED_X",sn[sn.MIRRORED_Y=4]="MIRRORED_Y";var lu=((Ct={})[Ct.LEFT=0]="LEFT",Ct[Ct.CENTER=1]="CENTER",Ct[Ct.RIGHT=2]="RIGHT",Ct[Ct.ALIGNED=3]="ALIGNED",Ct[Ct.MIDDLE=4]="MIDDLE",Ct[Ct.FIT=5]="FIT",Ct),hu=((vr={})[vr.BASELINE=0]="BASELINE",vr[vr.BOTTOM=1]="BOTTOM",vr[vr.MIDDLE=2]="MIDDLE",vr[vr.TOP=3]="TOP",vr);function hl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}let cl={thickness:0,rotation:0,xScale:1,obliqueAngle:0,styleName:"STANDARD",generationFlag:0,halign:lu.LEFT,valign:hu.BASELINE,extrusionDirection:{x:0,y:0,z:1}},ul=[{code:73,name:"valign",parser:y},{code:100},{code:210,name:"extrusionDirection",parser:G},{code:11,name:"endPoint",parser:G},{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:G},{code:39,name:"thickness",parser:y},{code:100,name:"subclassMarker",parser:y},...Ue];class dl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){hl(this,"parser",ye(ul,cl))}}function ml(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}hl(dl,"ForEntityName","TEXT");let cu={...cl},uu=[{code:2},{code:40,name:"annotationScale",parser:y},{code:10,name:"alignmentPoint",parser:G},{code:340,name:"secondaryAttributesHardIds",isMultiple:!0,parser:y},{code:70,name:"numberOfSecondaryAttributes",parser:y},{code:70,name:"isReallyLocked",parser:Be},{code:70,name:"mtextFlag",parser:y},{code:280,name:"isDuplicatedRecord",parser:Be},{code:100},{code:280,name:"isLocked",parser:Be},{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},...ul.slice(2)];class pl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){ml(this,"parser",ye(uu,cu))}}ml(pl,"ForEntityName","ATTDEF");(an={})[an.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",an[an.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",an[an.BY_STYLE=5]="BY_STYLE";function du(i,e){let t={};for(let s of i){let o=e(s);o!=null&&(t[o]??(t[o]=[]),t[o].push(s))}return t}function*ei(i,e=1/0,t=1){for(let s=i;s!==e;s+=t)yield s}function Vr(i){return{x:i.x??0,y:i.y??0,z:i.z??0}}function ga(i,e,t){if(Ae(e,102))return mn(e,t,i),!0;switch(e.code){case 0:i.type=e.value;break;case 5:i.handle=e.value;break;case 330:i.ownerBlockRecordSoftId=e.value;break;case 67:i.isInPaperSpace=!!e.value;break;case 8:i.layer=e.value;break;case 6:i.lineType=e.value;break;case 347:i.materialObjectHardId=e.value;break;case 62:i.colorIndex=e.value,i.color=al(Math.abs(e.value));break;case 370:i.lineweight=e.value;break;case 48:i.lineTypeScale=e.value;break;case 60:i.isVisible=!!e.value;break;case 92:i.proxyByte=e.value;break;case 310:i.proxyEntity=e.value;break;case 100:break;case 420:i.color=e.value;break;case 430:i.transparency=e.value;break;case 390:i.plotStyleHardId=e.value;break;case 284:i.shadowMode=e.value;break;case 1001:i.xdata=sl(e,t);break;default:return!1}return!0}function gl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}let mu={textStyle:"STANDARD",extrusionDirection:{x:0,y:0,z:1},rotation:0},Xs=[{code:46,name:"annotationHeight",parser:y},{code:101,parser(i,e){(function(t){t.rewind();let s=t.next();if(s.code!==101)throw Error("Bad call for skipEmbeddedObject()");do s=t.next();while(s.code!==0);t.rewind()})(e)}},{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:[...ei(430,440)],name:"backgroundColor",parser:y},{code:[...ei(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:G},{code:210,name:"extrusionDirection",parser:G},{code:7,name:"styleName",parser:y},...Ei("text"),{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:G},{code:100,name:"subclassMarker",parser:y},...Ue];class fl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){gl(this,"parser",ye(Xs,mu))}}function _l(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}gl(fl,"ForEntityName","MTEXT");let pu={thickness:0,rotation:0,scale:1,obliqueAngle:0,textStyle:"STANDARD",textGenerationFlag:0,horizontalJustification:0,verticalJustification:0,extrusionDirection:{x:0,y:0,z:1}},gu=[...Xs.slice(Xs.findIndex(({name:i})=>i==="columnType"),Xs.findIndex(({name:i})=>i==="subclassMarker")+1),{code:100},{code:0,parser(i){if(!Ae(i,0,"MTEXT"))return pa}},{code:2,name:"definitionTag",parser:y},{code:40,name:"annotationScale",parser:y},{code:10,name:"alignmentPoint",parser:G},{code:340,name:"secondaryAttributesHardId",parser:y},{code:70,name:"numberOfSecondaryAttributes",parser:y},{code:70,name:"isReallyLocked",parser:Be},{code:70,name:"mtextFlag",parser:y},{code:280,name:"isDuplicatedEntriesKeep",parser:Be},{code:100},{code:280,name:"lockPositionFlag",parser:Be},{code:210,name:"extrusionDirection",parser:G},{code:11,name:"alignmentPoint",parser:G},{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:G},{code:39,name:"thickness",parser:y},{code:100},...Ue];class vl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){_l(this,"parser",ye(gu,pu))}}function yl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}_l(vl,"ForEntityName","ATTRIB");let fu=[...Ei("data"),{code:70,name:"version",parser:y},{code:100,name:"subclassMarker",parser:y},...Ue];class bl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){yl(this,"parser",ye(fu))}}function xl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}yl(bl,"ForEntityName","BODY");let _u={thickness:0,extrusionDirection:{x:0,y:0,z:1}},vu=[{code:210,name:"extrusionDirection",parser:G},{code:40,name:"radius",parser:y},{code:10,name:"center",parser:G},{code:39,name:"thickness",parser:y},{code:100,name:"subclassMarker",parser:y},...Ue];class wl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){xl(this,"parser",ye(vu,_u))}}xl(wl,"ForEntityName","CIRCLE");class Ks{parseEntity(e,t){let s={};for(;!Ae(t,0,"EOF");){if(t.code===0){e.rewind();break}(function(o,h,u){switch(h.code){case 100:o.subclassMarker=h.value;break;case 280:o.version=h.value;break;case 2:o.name=h.value;break;case 10:o.definitionPoint=ze(u);break;case 11:o.textPoint=ze(u);break;case 12:o.insertionPoint=ze(u);break;case 13:o.subDefinitionPoint1=ze(u);break;case 14:o.subDefinitionPoint2=ze(u);break;case 15:o.centerPoint=ze(u);break;case 16:o.arcPoint=ze(u);break;case 70:o.dimensionType=h.value;break;case 71:o.attachmentPoint=h.value;break;case 72:o.textLineSpacingStyle=h.value;break;case 40:o.leaderLength=h.value;break;case 41:o.textLineSpacingFactor=h.value;break;case 42:o.measurement=h.value;break;case 1:o.text=h.value;break;case 50:o.rotationAngle=h.value;break;case 52:o.obliqueAngle=h.value;break;case 53:o.textRotation=h.value;break;case 51:o.ocsRotation=h.value;break;case 210:o.extrusionDirection=ze(u);break;case 3:o.styleName=h.value;break;default:ga(o,h,u)}})(s,t,e),t=e.next()}return s}}function Al(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}Xi="DIMENSION",(Yi="ForEntityName")in Ks?Object.defineProperty(Ks,Yi,{value:Xi,enumerable:!0,configurable:!0,writable:!0}):Ks[Yi]=Xi;let yu={extrusionDirection:{x:0,y:0,z:1}},bu=[{code:42,name:"endAngle",parser:y},{code:41,name:"startAngle",parser:y},{code:40,name:"axisRatio",parser:y},{code:210,name:"extrusionDirection",parser:G},{code:11,name:"majorAxisEndPoint",parser:G},{code:10,name:"center",parser:G},{code:100,name:"subclassMarker",parser:y},...Ue];class Sl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Al(this,"parser",ye(bu,yu))}}Al(Sl,"ForEntityName","ELLIPSE");(yr={})[yr.First=1]="First",yr[yr.Second=2]="Second",yr[yr.Third=4]="Third",yr[yr.Fourth=8]="Fourth";function Pl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}let xu=[{code:13,name:"vertices.3",parser:G},{code:12,name:"vertices.2",parser:G},{code:11,name:"vertices.1",parser:G},{code:10,name:"vertices.0",parser:G},{code:100,name:"subclassMarker",parser:y},...Ue];class Il{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Pl(this,"parser",ye(xu))}}Pl(Il,"ForEntityName","3DFACE");let El=[{code:330,name:"sourceBoundaryObjects",parser:y,isMultiple:!0},{code:97,name:"numberOfSourceBoundaryObjects",parser:y}],wu=[{code:11,name:"end",parser:G},{code:10,name:"start",parser:G}],Au=[{code:73,name:"isCCW",parser:Be},{code:51,name:"endAngle",parser:y},{code:50,name:"startAngle",parser:y},{code:40,name:"radius",parser:y},{code:10,name:"center",parser:G}],Su=[{code:73,name:"isCCW",parser:Be},{code:51,name:"endAngle",parser:y},{code:50,name:"startAngle",parser:y},{code:40,name:"lengthOfMinorAxis",parser:y},{code:11,name:"end",parser:G},{code:10,name:"center",parser:G}],Pu=[{code:13,name:"endTangent",parser:G},{code:12,name:"startTangent",parser:G},{code:11,name:"fitDatum",isMultiple:!0,parser:G},{code:97,name:"numberOfFitData",parser:y},{code:10,name:"controlPoints",isMultiple:!0,parser(i,e){let t={...ze(e),weight:1};return(i=e.next()).code===42?t.weight=i.value:e.rewind(),t}},{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:Be},{code:73,name:"splineFlag",parser:y},{code:94,name:"degree",parser:y}],Iu={[js.Line]:wu,[js.Circular]:Au,[js.Elliptic]:Su,[js.Spline]:Pu},Eu=[...El,{code:72,name:"edges",parser(i,e){let t={type:i.value},s=ye(Iu[t.type]);if(!s)throw Error(`Invalid edge type ${t.type}`);return s(i=e.next(),e,t),t},isMultiple:!0},{code:93,name:"numberOfEdges",parser:y}],ku=[...El,{code:10,name:"vertices",parser(i,e){let t={...ze(e),bulge:0};return(i=e.next()).code===42?t.bulge=i.value:e.rewind(),t},isMultiple:!0},{code:93,name:"numberOfVertices",parser:y},{code:73,name:"isClosed",parser:Be},{code:72,name:"hasBulge",parser:Be}],Mu=[{code:49,name:"dashLengths",parser:y,isMultiple:!0},{code:79,name:"numberOfDashLengths",parser:y},{code:45,name:"offset",parser:Mo},{code:43,name:"base",parser:Mo},{code:53,name:"angle",parser:y}];function Mo(i,e){let t=i.code+1,s={x:i.value,y:1};return(i=e.next()).code===t?s.y=i.value:e.rewind(),s}function kl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}let Tu={extrusionDirection:{x:0,y:0,z:1},gradientRotation:0,colorTint:0},Nu=[{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:G,isMultiple:!0},{code:99},{code:11,name:"offsetVector",parser:G},{code:98,name:"numberOfSeedPoints",parser:y},{code:47,name:"pixelSize",parser:y},{code:53,name:"definitionLines",parser:function(i,e){let t={};return ye(Mu)(i,e,t),t},isMultiple:!0},{code:78,name:"numberOfDefinitionLines",parser:y},{code:77,name:"isDouble",parser:Be},{code:73,name:"isAnnotated",parser:Be},{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(i,e){let t={boundaryPathTypeFlag:i.value},s=t.boundaryPathTypeFlag&tu.Polyline;return i=e.next(),s?ye(ku)(i,e,t):ye(Eu)(i,e,t),t},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:G},{code:10,name:"elevationPoint",parser:G},{code:100,name:"subclassMarker",parser:y,pushContext:!0},...Ue];class Ml{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){kl(this,"parser",ye(Nu,Tu))}}kl(Ml,"ForEntityName","HATCH");(br={})[br.ShowImage=1]="ShowImage",br[br.ShowImageWhenNotAlignedWithScreen=2]="ShowImageWhenNotAlignedWithScreen",br[br.UseClippingBoundary=4]="UseClippingBoundary",br[br.TransparencyIsOn=8]="TransparencyIsOn";(xs={})[xs.Rectangular=1]="Rectangular",xs[xs.Polygonal=2]="Polygonal";(ws={})[ws.Outside=0]="Outside",ws[ws.Inside=1]="Inside";function Tl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}let Cu={brightness:50,contrast:50,fade:0,clippingBoundaryPath:[]},Lu=[{code:290,name:"clipMode",parser:y},{code:14,name:"clippingBoundaryPath",isMultiple:!0,parser:G},{code:91,name:"countBoundaryPoints",parser:y},{code:71,name:"clippingBoundaryType",parser:y},{code:360,name:"imageDefReactorHandle",parser:y},{code:283,name:"fade",parser:y},{code:282,name:"contrast",parser:y},{code:281,name:"brightness",parser:y},{code:280,name:"isClipped",parser:Be},{code:70,name:"flags",parser:y},{code:340,name:"imageDefHandle",parser:y},{code:13,name:"imageSize",parser:G},{code:12,name:"vPixel",parser:G},{code:11,name:"uPixel",parser:G},{code:10,name:"position",parser:G},{code:90,name:"version",parser:y},{code:100,name:"subclassMarker",parser:y},...Ue];class Nl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Tl(this,"parser",ye(Lu,Cu))}}function Cl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}Tl(Nl,"ForEntityName","IMAGE");let Ou={xScale:1,yScale:1,zScale:1,rotation:0,columnCount:0,rowCount:0,columnSpacing:0,rowSpacing:0,extrusionDirection:{x:0,y:0,z:1}},zu=[{code:210,name:"extrusionDirection",parser:G},{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:G},{code:2,name:"name",parser:y},{code:66,name:"isVariableAttributes",parser:Be},{code:100,name:"subclassMarker",parser:y},...Ue];class Ll{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Cl(this,"parser",ye(zu,Ou))}}function Ol(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}Cl(Ll,"ForEntityName","INSERT");let Du={isArrowheadEnabled:!0},Ru=[{code:213,name:"offsetFromAnnotation",parser:G},{code:212,name:"offsetFromBlock",parser:G},{code:211,name:"horizontalDirection",parser:G},{code:210,name:"normal",parser:G},{code:340,name:"associatedAnnotation",parser:y},{code:77,name:"byBlockColor",parser:y},{code:10,name:"vertices",parser:G,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:Be},{code:74,name:"isHooklineSameDirection",parser:Be},{code:73,name:"leaderCreationFlag",parser:y},{code:72,name:"isSpline",parser:Be},{code:71,name:"isArrowheadEnabled",parser:Be},{code:3,name:"styleName",parser:y},{code:100,name:"subclassMarker",parser:y},...Ue],zl=class{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Ol(this,"parser",ye(Ru,Du))}};Ol(zl,"ForEntityName","LEADER");(xr={})[xr.TextAnnotation=0]="TextAnnotation",xr[xr.ToleranceAnnotation=1]="ToleranceAnnotation",xr[xr.BlockReferenceAnnotation=2]="BlockReferenceAnnotation",xr[xr.NoAnnotation=3]="NoAnnotation";function Dl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}let Bu={thickness:0,extrusionDirection:{x:0,y:0,z:1}},Fu=[{code:210,name:"extrusionDirection",parser:G},{code:11,name:"endPoint",parser:G},{code:10,name:"startPoint",parser:G},{code:39,name:"thickness",parser:y},{code:100,name:"subclassMarker",parser:y},...Ue];class Rl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Dl(this,"parser",ye(Fu,Bu))}}Dl(Rl,"ForEntityName","LINE");(As={})[As.IS_CLOSED=1]="IS_CLOSED",As[As.PLINE_GEN=128]="PLINE_GEN";let Uu={flag:0,elevation:0,thickness:0,extrusionDirection:{x:0,y:0,z:1},vertices:[]},Vu={bulge:0},ju=[{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}],Gu=[{code:210,name:"extrusionDirection",parser:G},{code:10,name:"vertices",isMultiple:!0,parser(i,e){let t={};return ye(ju,Vu)(i,e,t),t}},{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},...Ue];class $s{parseEntity(e,t){let s={};return ye(Gu,Uu)(t,e,s),s}}function Bl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}$i="LWPOLYLINE",(Ki="ForEntityName")in $s?Object.defineProperty($s,Ki,{value:$i,enumerable:!0,configurable:!0,writable:!0}):$s[Ki]=$i;let Wu=[{code:90,name:"overridenSubEntityCount",parser:y},{code:140,name:"edgeCreaseWeights",parser:y,isMultiple:!0},{code:95,name:"edgeCreaseCount",parser:y},{code:94,parser(i,e,t){t.edgeCount=i.value,t.edgeIndices=[];for(let s=0;s<t.edgeCount;++s){let o=[];i=e.next(),o[0]=i.value,i=e.next(),o[1]=i.value,t.edgeIndices.push(o)}}},{code:93,parser(i,e,t){t.totalFaceIndices=i.value,t.faceIndices=[];let s=[];for(let h=0;h<t.totalFaceIndices&&!Ae(i,0);++h)i=e.next(),s.push(i.value);let o=0;for(;o<s.length;){let h=s[o++],u=[];for(let g=0;g<h;++g)u.push(s[o++]);t.faceIndices.push(u)}}},{code:10,name:"vertices",parser:G,isMultiple:!0},{code:92,name:"verticesCount",parser:y},{code:91,name:"subdivisionLevel",parser:y},{code:40,name:"blendCrease",parser:y},{code:72,name:"isBlendCreased",parser:Be},{code:71,name:"version",parser:y},{code:100,name:"subclassMarker",parser:function({value:i}){return i.trim()},pushContext:!0},...Ue];class Fl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Bl(this,"parser",ye(Wu))}}function Ul(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}Bl(Fl,"ForEntityName","MESH");let Hu={thickness:0,extrusionDirection:{x:0,y:0,z:1},angle:0},qu=[{code:50,name:"angle",parser:y},{code:210,name:"extrusionDirection",parser:G},{code:39,name:"thickness",parser:y},{code:10,name:"position",parser:G},{code:100,name:"subclassMarker",parser:y},...Ue];class Vl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Ul(this,"parser",ye(qu,Hu))}}Ul(Vl,"ForEntityName","POINT");(ct={})[ct.CLOSED_POLYLINE=1]="CLOSED_POLYLINE",ct[ct.CURVE_FIT=2]="CURVE_FIT",ct[ct.SPLINE_FIT=4]="SPLINE_FIT",ct[ct.POLYLINE_3D=8]="POLYLINE_3D",ct[ct.POLYGON_3D=16]="POLYGON_3D",ct[ct.CLOSED_POLYGON=32]="CLOSED_POLYGON",ct[ct.POLYFACE=64]="POLYFACE",ct[ct.CONTINUOUS=128]="CONTINUOUS";(wr={})[wr.NONE=0]="NONE",wr[wr.QUADRATIC=5]="QUADRATIC",wr[wr.CUBIC=6]="CUBIC",wr[wr.BEZIER=8]="BEZIER";(ut={})[ut.CREATED_BY_CURVE_FIT=1]="CREATED_BY_CURVE_FIT",ut[ut.TANGENT_DEFINED=2]="TANGENT_DEFINED",ut[ut.NOT_USED=4]="NOT_USED",ut[ut.CREATED_BY_SPLINE_FIT=8]="CREATED_BY_SPLINE_FIT",ut[ut.SPLINE_CONTROL_POINT=16]="SPLINE_CONTROL_POINT",ut[ut.FOR_POLYLINE=32]="FOR_POLYLINE",ut[ut.FOR_POLYGON=64]="FOR_POLYGON",ut[ut.POLYFACE=128]="POLYFACE";function jl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}let Yu={startWidth:0,endWidth:0,bulge:0},Xu=[{code:91,name:"id",parser:y},{code:[...ei(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},...Ue];class fa{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){jl(this,"parser",ye(Xu,Yu))}}function Gl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}jl(fa,"ForEntityName","VERTEX");let Ku={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:[]},$u=[{code:0,name:"vertices",isMultiple:!0,parser:(i,e)=>Ae(i,0,"VERTEX")?(i=e.next(),new fa().parseEntity(e,i)):pa},{code:210,name:"extrusionDirection",parser:G},{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},...Ue];class Wl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Gl(this,"parser",ye($u,Ku))}}function Hl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}Gl(Wl,"ForEntityName","POLYLINE");let Zu=[{code:11,name:"direction",parser:G},{code:10,name:"position",parser:G},{code:100,name:"subclassMarker",parser:y},...Ue];class ql{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Hl(this,"parser",ye(Zu))}}function Yl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}Hl(ql,"ForEntityName","RAY");let Qu=[...Ei("data"),{code:70,name:"version",parser:y},{code:100,name:"subclassMarker",parser:y},...Ue];class Xl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Yl(this,"parser",ye(Qu))}}function Kl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}Yl(Xl,"ForEntityName","REGION");let Ju={vertices:[],backLineVertices:[]},ed=[{code:360,name:"geometrySettingHardId",parser:y},{code:12,name:"backLineVertices",isMultiple:!0,parser:G},{code:93,name:"numberOfBackLineVertices",parser:y},{code:11,name:"vertices",isMultiple:!0,parser:G},{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:G},{code:1,name:"name",parser:y},{code:91,name:"flag",parser:y},{code:90,name:"state",parser:y},{code:100,name:"subclassMarker",parser:y},...Ue];class $l{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Kl(this,"parser",ye(ed,Ju))}}function Zl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}Kl($l,"ForEntityName","SECTION");let td={points:[],thickness:0,extrusionDirection:{x:0,y:0,z:1}},rd=[{code:210,name:"extrusionDirection",parser:G},{code:39,name:"thickness",parser:y},{code:[...ei(10,14)],name:"points",isMultiple:!0,parser:G},{code:100,name:"subclassMarker",parser:y},...Ue];class Ql{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Zl(this,"parser",ye(rd,td))}}function Jl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}Zl(Ql,"ForEntityName","SOLID");let nd=[{code:350,name:"historyObjectSoftId",parser:y},{code:100,name:"subclassMarker",parser:y},...Ei("data"),{code:70,name:"version",parser:y},{code:100},...Ue];class eh{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Jl(this,"parser",ye(nd))}}Jl(eh,"ForEntityName","3DSOLID");(Lt={})[Lt.NONE=0]="NONE",Lt[Lt.CLOSED=1]="CLOSED",Lt[Lt.PERIODIC=2]="PERIODIC",Lt[Lt.RATIONAL=4]="RATIONAL",Lt[Lt.PLANAR=8]="PLANAR",Lt[Lt.LINEAR=16]="LINEAR";function th(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}let sd={knotTolerance:1e-6,controlTolerance:1e-6,fitTolerance:1e-9,knotValues:[],controlPoints:[],fitPoints:[]},id=[{code:11,name:"fitPoints",isMultiple:!0,parser:G},{code:10,name:"controlPoints",isMultiple:!0,parser:G},{code:41,name:"weights",isMultiple:!0,parser:y},{code:40,name:"knots",isMultiple:!0,parser:y},{code:13,name:"endTangent",parser:G},{code:12,name:"startTangent",parser:G},{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:G},{code:100,name:"subclassMarker",parser:y},...Ue];class rh{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){th(this,"parser",ye(id,sd))}}th(rh,"ForEntityName","SPLINE");class Zs{parseEntity(e,t){let s={};for(;!e.isEOF();){if(t.code===0){e.rewind();break}switch(t.code){case 100:s.subclassMarker=t.value,t=e.next();break;case 2:s.name=t.value,t=e.next();break;case 5:s.handle=t.value,t=e.next();break;case 10:s.startPoint=Vr(ze(e)),t=e.lastReadGroup;break;case 11:s.directionVector=Vr(ze(e)),t=e.lastReadGroup;break;case 90:s.tableValue=t.value,t=e.next();break;case 91:s.rowCount=t.value,t=e.next();break;case 92:s.columnCount=t.value,t=e.next();break;case 93:s.overrideFlag=t.value,t=e.next();break;case 94:s.borderColorOverrideFlag=t.value,t=e.next();break;case 95:s.borderLineWeightOverrideFlag=t.value,t=e.next();break;case 96:s.borderVisibilityOverrideFlag=t.value,t=e.next();break;case 141:s.rowHeightArr??(s.rowHeightArr=[]),s.rowHeightArr.push(t.value),t=e.next();break;case 142:s.columnWidthArr??(s.columnWidthArr=[]),s.columnWidthArr.push(t.value),t=e.next();break;case 280:s.version=t.value,t=e.next();break;case 310:s.bmpPreview??(s.bmpPreview=""),s.bmpPreview+=t.value,t=e.next();break;case 330:s.ownerDictionaryId=t.value,t=e.next();break;case 342:s.tableStyleId=t.value,t=e.next();break;case 343:s.blockRecordHandle=t.value,t=e.next();break;case 170:s.attachmentPoint=t.value,t=e.next();break;case 171:s.cells??(s.cells=[]),s.cells.push(function(o,h){let u=!1,g=!1,b={};for(;!o.isEOF()&&h.code!==0&&!g;)switch(h.code){case 171:if(u){g=!0;continue}b.cellType=h.value,u=!0,h=o.next();break;case 172:b.flagValue=h.value,h=o.next();break;case 173:b.mergedValue=h.value,h=o.next();break;case 174:b.autoFit=h.value,h=o.next();break;case 175:b.borderWidth=h.value,h=o.next();break;case 176:b.borderHeight=h.value,h=o.next();break;case 91:b.overrideFlag=h.value,h=o.next();break;case 178:b.virtualEdgeFlag=h.value,h=o.next();break;case 145:b.rotation=h.value,h=o.next();break;case 345:b.fieldObjetId=h.value,h=o.next();break;case 340:b.blockTableRecordId=h.value,h=o.next();break;case 146:b.blockScale=h.value,h=o.next();break;case 177:b.blockAttrNum=h.value,h=o.next();break;case 7:b.textStyle=h.value,h=o.next();break;case 140:b.textHeight=h.value,h=o.next();break;case 170:b.attachmentPoint=h.value,h=o.next();break;case 92:b.extendedCellFlags=h.value,h=o.next();break;case 285:b.rightBorderVisibility=!!(h.value??!0),h=o.next();break;case 286:b.bottomBorderVisibility=!!(h.value??!0),h=o.next();break;case 288:b.leftBorderVisibility=!!(h.value??!0),h=o.next();break;case 289:b.topBorderVisibility=!!(h.value??!0),h=o.next();break;case 301:(function(f,S,x){for(;x.code!==304;)switch(x.code){case 301:case 93:case 90:case 94:x=S.next();break;case 1:f.text=x.value,x=S.next();break;case 300:f.attrText=x.value,x=S.next();break;case 302:f.text=x.value?x.value:f.text,x=S.next();break;default:console.log(`Ignore code: ${x.code}, value: ${x.value}`),x=S.next()}})(b,o,h),h=o.next();break;default:return b}return u=!1,g=!1,b}(e,t)),t=e.lastReadGroup;break;default:ga(s,t,e),t=e.next()}}return s}}function nh(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}Qi="ACAD_TABLE",(Zi="ForEntityName")in Zs?Object.defineProperty(Zs,Zi,{value:Qi,enumerable:!0,configurable:!0,writable:!0}):Zs[Zi]=Qi;let ad=[{code:11,name:"xAxisDirection",parser:G},{code:210,name:"extrusionDirection",parser:G},{code:1,name:"text",parser:y},{code:10,name:"position",parser:G},{code:3,name:"styleName",parser:y},{code:100,name:"subclassMarker",parser:y},...Ue];class sh{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){nh(this,"parser",ye(ad))}}nh(sh,"ForEntityName","TOLERANCE");let Qs=class{parseEntity(e,t){let s={};for(;t!=="EOF";){if(t.code===0){e.rewind();break}!function(o,h,u){if(u==="EOF")return!1;switch(u.code){case 0:return!1;case 8:o.layer=u.value;break;case 100:o.subclassMarker=u.value;break;case 10:o.viewportCenter=Vr(ze(h));break;case 40:o.width=u.value;break;case 41:o.height=u.value;break;case 68:o.status=u.value;break;case 69:o.viewportId=u.value;break;case 12:o.displayCenter=ze(h);break;case 13:o.snapBase=ze(h);break;case 14:o.snapSpacing=ze(h);break;case 15:o.gridSpacing=ze(h);break;case 16:o.viewDirection=Vr(ze(h));break;case 17:o.targetPoint=Vr(ze(h));break;case 42:o.perspectiveLensLength=u.value;break;case 43:o.frontClipZ=u.value;break;case 44:o.backClipZ=u.value;break;case 45:o.viewHeight=u.value;break;case 50:o.snapAngle=u.value;break;case 51:o.viewTwistAngle=u.value;break;case 72:o.circleZoomPercent=u.value;break;case 331:o.frozenLayerIds??(o.frozenLayerIds=[]),o.frozenLayerIds.push(u.value);break;case 90:o.statusBitFlags=u.value;break;case 340:o.clippingBoundaryId=u.value;break;case 1:o.sheetName=u.value;break;case 281:o.renderMode=u.value;break;case 71:o.ucsPerViewport=u.value;break;case 110:o.ucsOrigin=Vr(ze(h));break;case 111:o.ucsXAxis=Vr(ze(h));break;case 112:o.ucsYAxis=Vr(ze(h));break;case 345:o.ucsId=u.value;break;case 346:o.ucsBaseId=u.value;break;case 79:o.orthographicType=u.value;break;case 146:o.elevation=u.value;break;case 170:o.shadePlotMode=u.value;break;case 61:o.majorGridFrequency=u.value;break;case 332:o.backgroundId=u.value;break;case 333:o.shadePlotId=u.value;break;case 348:o.visualStyleId=u.value;break;case 292:o.isDefaultLighting=!!u.value;break;case 282:o.defaultLightingType=u.value;break;case 141:o.brightness=u.value;break;case 142:o.contrast=u.value;break;case 63:case 421:case 431:o.ambientLightColor=u.value;break;case 361:o.sunId=u.value;break;case 335:case 343:case 344:case 91:o.softPointer=u.value}return!0}(s,e,t)&&ga(s,t,e),t=e.next()}return s}};ea="VIEWPORT",(Ji="ForEntityName")in Qs?Object.defineProperty(Qs,Ji,{value:ea,enumerable:!0,configurable:!0,writable:!0}):Qs[Ji]=ea;(Ar={})[Ar.ShowImage=1]="ShowImage",Ar[Ar.ShowImageWhenNotAligned=2]="ShowImageWhenNotAligned",Ar[Ar.UseClippingBoundary=4]="UseClippingBoundary",Ar[Ar.Transparency=8]="Transparency";function ih(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}let od={brightness:50,constrast:50,fade:0},ld=[{code:14,name:"boundary",isMultiple:!0,parser:G},{code:91,name:"numberOfVertices",parser:y},{code:71,name:"boundaryType",parser:y},{code:360,name:"imageDefReactorHardId",parser:y},{code:283,name:"fade",parser:y},{code:282,name:"contrast",parser:y},{code:281,name:"brightness",parser:y},{code:280,name:"isClipping",parser:Be},{code:70,name:"displayFlag",parser:y},{code:340,name:"imageDefHardId",parser:y},{code:13,name:"imageSize",parser:G},{code:12,name:"vDirection",parser:G},{code:11,name:"uDirection",parser:G},{code:10,name:"position",parser:G},{code:90,name:"classVersion",parser:y},{code:100,name:"subclassMarker",parser:y},...Ue];class ah{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){ih(this,"parser",ye(ld,od))}}function oh(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}ih(ah,"ForEntityName","WIPEOUT");let hd=[{code:11,name:"direction",parser:G},{code:10,name:"position",parser:G},{code:100,name:"subclassMarker",parser:y},...Ue],lh=class{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){oh(this,"parser",ye(hd))}};function hh(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}oh(lh,"ForEntityName","XLINE");let cd={},ud=[{code:170,name:"multileaderType",parser:y},{code:291,name:"doglegEnabled",parser:Be},{code:40,name:"doglegLength",parser:y},{code:172,name:"contentType",parser:y},{code:3,name:"textContent",parser:y},{code:12,name:"textAnchor",parser:G},{code:344,name:"blockHandle",parser:y},{code:15,name:"blockPosition",parser:G},{code:302,name:"leaderSections",parser:function(i,e,t){let s,o={leaderLines:[]};for(;e.hasNext()&&(s=e.next()).code!==303;)switch(s.code){case 10:o.landingPoint=(s.value,ze(e));break;case 11:o.doglegVector=(s.value,ze(e));break;case 40:o.doglegLength=s.value;break;case 304:o.leaderLines.push(function(h,u,g){let b,f={vertices:[]};for(;u.hasNext()&&(b=u.next()).code!==305;)b.code===10&&f.vertices.push((b.value,ze(u)));return f}(0,e))}return o},isMultiple:!0},...Ue];class ch{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){hh(this,"parser",ye(ud,cd))}}hh(ch,"ForEntityName","MULTILEADER");let dd=Object.fromEntries([ll,pl,vl,bl,wl,Ks,Sl,Il,Nl,Ll,zl,Rl,$s,Fl,fl,ch,Vl,Wl,ql,Xl,$l,Ql,eh,rh,Zs,dl,sh,Ml,fa,Qs,ah,lh].map(i=>[i.ForEntityName,new i]));function uh(i,e){let t=[];for(;!Ae(i,0,"EOF");){if(i.code===0){if(i.value==="ENDBLK"||i.value==="ENDSEC"){e.rewind();break}let s=dd[i.value];if(s){let o=i.value;i=e.next();let h=s.parseEntity(e,i);h.type=o,il(h),t.push(h)}else e.debug&&console.warn(`Unsupported ENTITY type: ${i.value}`)}i=e.next()}return t}function md(i,e){let t={};for(;!Ae(i,0,"EOF")&&!Ae(i,0,"ENDSEC");){if(Ae(i,0,"BLOCK")){let s=pd(i=e.next(),e);il(s),s.name&&(t[s.name]=s)}i=e.next()}return t}function pd(i,e){let t={};for(;!Ae(i,0,"EOF");){if(Ae(i,0,"ENDBLK")){for(i=e.next();!Ae(i,0,"EOF");){if(Ae(i,100,"AcDbBlockEnd"))return t;i=e.next()}break}switch(i.code){case 1:t.xrefPath=i.value;break;case 2:t.name=i.value;break;case 3:t.name2=i.value;break;case 5:t.handle=i.value;break;case 8:t.layer=i.value;break;case 10:t.position=ze(e);break;case 67:t.paperSpace=!!i.value&&i.value==1;break;case 70:i.value!==0&&(t.type=i.value);break;case 100:break;case 330:t.ownerHandle=i.value;break;case 0:t.entities=uh(i,e)}i=e.next()}return t}function gd(i,e){let t=null,s={};for(;!Ae(i,0,"EOF")&&!Ae(i,0,"ENDSEC");)i.code===9?t=i.value:i.code===10?s[t]=ze(e):s[t]=i.value,i=e.next();return s}(Ot={})[Ot.NOT_APPLICABLE=0]="NOT_APPLICABLE",Ot[Ot.KEEP_EXISTING=1]="KEEP_EXISTING",Ot[Ot.USE_CLONE=2]="USE_CLONE",Ot[Ot.XREF_VALUE_NAME=3]="XREF_VALUE_NAME",Ot[Ot.VALUE_NAME=4]="VALUE_NAME",Ot[Ot.UNMANGLE_NAME=5]="UNMANGLE_NAME";let _a=[{code:330,name:"ownerObjectId",parser:y},{code:102,parser:mn},{code:102,parser:mn},{code:102,parser:mn},{code:5,name:"handle",parser:y}],fd=[{code:3,name:"entries",parser:(i,e)=>{let t={name:i.value};return(i=e.next()).code===350?t.objectSoftId=i.value:i.code===360?t.objectHardId=i.value:e.rewind(),t},isMultiple:!0},{code:281,name:"recordCloneFlag",parser:y},{code:280,name:"isHardOwned",parser:Be},{code:100,name:"subclassMarker",parser:y},..._a],_d=[{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:G},{code:11,name:"sizeOfOnePixel",parser:G},{code:280,name:"isLoaded",parser:y},{code:281,name:"resolutionUnits",parser:y},{code:100,name:"subclassMarker",parser:y}];(on={})[on.NOUNIT=0]="NOUNIT",on[on.CENTIMETERS=2]="CENTIMETERS",on[on.INCH=5]="INCH";(Ss={})[Ss.PSLTSCALE=1]="PSLTSCALE",Ss[Ss.LIMCHECK=2]="LIMCHECK";(ln={})[ln.INCHES=0]="INCHES",ln[ln.MILLIMETERS=1]="MILLIMETERS",ln[ln.PIXELS=2]="PIXELS";(zt={})[zt.LAST_SCREEN_DISPLAY=0]="LAST_SCREEN_DISPLAY",zt[zt.DRAWING_EXTENTS=1]="DRAWING_EXTENTS",zt[zt.DRAWING_LIMITS=2]="DRAWING_LIMITS",zt[zt.VIEW_SPECIFIED=3]="VIEW_SPECIFIED",zt[zt.WINDOW_SPECIFIED=4]="WINDOW_SPECIFIED",zt[zt.LAYOUT_INFORMATION=5]="LAYOUT_INFORMATION";(Sr={})[Sr.AS_DISPLAYED=0]="AS_DISPLAYED",Sr[Sr.WIREFRAME=1]="WIREFRAME",Sr[Sr.HIDDEN=2]="HIDDEN",Sr[Sr.RENDERED=3]="RENDERED";(Dt={})[Dt.DRAFT=0]="DRAFT",Dt[Dt.PREVIEW=1]="PREVIEW",Dt[Dt.NORMAL=2]="NORMAL",Dt[Dt.PRESENTATION=3]="PRESENTATION",Dt[Dt.MAXIMUM=4]="MAXIMUM",Dt[Dt.CUSTOM=5]="CUSTOM";let dh=[{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:"plotPaperUnit",parser:y},{code:70,name:"layoutFlag",parser:y},{code:143,name:"printScaleDenominator",parser:y},{code:142,name:"printScaleNumerator",parser:y},{code:141,name:"windowAreaYMax",parser:y},{code:140,name:"windowAreaXMax",parser:y},{code:49,name:"windowAreaYMin",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},..._a],vd=[{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:G},{code:16,name:"ucsXAxis",parser:G},{code:13,name:"ucsOrigin",parser:G},{code:146,name:"elevation",parser:y},{code:15,name:"maxExtent",parser:G},{code:14,name:"minExtent",parser:G},{code:12,name:"insertionPoint",parser:G},{code:11,name:"maxLimit",parser:G},{code:10,name:"minLimit",parser:G},{code:71,name:"tabOrder",parser:y},{code:70,name:"controlFlag",parser:y},{code:1,name:"layoutName",parser:y},{code:100,name:"subclassMarker",parser:y},...dh],yd=[{code:40,name:"wcsToOCSTransform",parser:To},{code:40,name:"ocsToWCSTransform",parser:To},{code:41,name:"backClippingDistance",parser:y},{code:73,name:"isBackClipping",parser:Be,pushContext:!0},{code:40,name:"frontClippingDistance",parser:y},{code:72,name:"isFrontClipping",parser:Be,pushContext:!0},{code:71,name:"isClipBoundaryDisplayed",parser:Be},{code:11,name:"position",parser:G},{code:210,name:"normal",parser:G},{code:10,name:"boundaryVertices",parser:G,isMultiple:!0},{code:70,name:"boundaryCount",parser:y},{code:100,name:"subclassMarker",parser:y},{code:100},..._a];function To(i,e){let t=[];for(let s=0;s<3&&Ae(i,40);++s){let o=[];for(let h=0;h<4&&Ae(i,40);++h)o.push(i.value),i=e.next();t.push(o)}return e.rewind(),t}let bd={LAYOUT:vd,PLOTSETTINGS:dh,DICTIONARY:fd,SPATIAL_FILTER:yd,IMAGEDEF:_d};function xd(i,e){let t=[];for(;i.code!==0||!["EOF","ENDSEC"].includes(i.value);){let s=i.value,o=bd[s];if(i.code===0&&(o!=null&&o.length)){let h=ye(o),u={name:s};h(i=e.next(),e,u)?(t.push(u),i=e.peek()):i=e.next()}else i=e.next()}return{byName:du(t,({name:s})=>s)}}let Un=[{code:100,name:"subclassMarker",parser:y},{code:330,name:"ownerObjectId",parser:y},{code:102,parser(i,e){for(;!Ae(i,0,"EOF")&&!Ae(i,102,"}");)i=e.next()}},{code:5,name:"handle",parser:y}],wd=ye([{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},...Un]),Ad=[{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:ko.Above,defaultValueImperial:ko.Center},{name:"DIMZIN",code:78,defaultValue:Cn.Trailing,defaultValueImperial:Cn.Feet},{name:"DIMAZIN",code:79,defaultValue:Qc.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:Jc.Center},{name:"DIMSD1",code:281,defaultValue:0},{name:"DIMSD2",code:282,defaultValue:0},{name:"DIMTOLJ",code:283,defaultValue:eu.Center},{name:"DIMTZIN",code:284,defaultValue:Cn.Trailing,defaultValueImperial:Cn.Feet},{name:"DIMALTZ",code:285,defaultValue:Cn.Trailing},{name:"DIMALTTZ",code:286,defaultValue:Cn.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}],Sd=ye([...Ad.map(i=>({...i,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},...Un.filter(i=>i.code!==5)]),Pd=ye([{code:347,name:"materialObjectId",parser:y},{code:390,name:"plotStyleNameObjectId",parser:y},{code:370,name:"lineweight",parser:y},{code:290,name:"isPlotting",parser:Be},{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},...Un]);(Pr={})[Pr.NONE=0]="NONE",Pr[Pr.AbsoluteRotation=1]="AbsoluteRotation",Pr[Pr.TextEmbedded=2]="TextEmbedded",Pr[Pr.ShapeEmbedded=4]="ShapeEmbedded";let Id=ye([{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}),Ed=ye([{code:49,name:"pattern",parser(i,e){let t={};return Id(i,e,t),t},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},...Un]),kd=ye([{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},...Un]),Md=ye([{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:Be},{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:G},{code:111,name:"ucsXAxis",parser:G},{code:110,name:"ucsOrigin",parser:G},{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:G},{code:16,name:"viewDirectionFromTarget",parser:G},{code:15,name:"gridSpacing",parser:G},{code:14,name:"snapSpacing",parser:G},{code:13,name:"snapBasePoint",parser:G},{code:12,name:"center",parser:G},{code:11,name:"upperRightCorner",parser:G},{code:10,name:"lowerLeftCorner",parser:G},{code:70,name:"standardFlag",parser:y},{code:2,name:"name",parser:y},{code:100,name:"subclassMarker",parser:y},...Un]),Td={BLOCK_RECORD:wd,DIMSTYLE:Sd,LAYER:Pd,LTYPE:Ed,STYLE:kd,VPORT:Md},Nd=ye([{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 Cd(i,e){var s;let t={};for(;!Ae(i,0,"EOF")&&!Ae(i,0,"ENDSEC");){if(Ae(i,0,"TABLE")){i=e.next();let o={entries:[]};Nd(i,e,o),t[o.name]=o}if(Ae(i,0)&&!Ae(i,0,"ENDTAB")){let o=i.value;i=e.next();let h=Td[o];if(!h){e.debug&&console.warn(`parseTable: Invalid table name '${o}'`),i=e.next();continue}let u={};h(i,e,u),(s=t[o])==null||s.entries.push(u)}i=e.next()}return t}function Ps(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}class No{next(){if(!this.hasNext())return this._eof?this.debug&&console.warn("Cannot call 'next' after EOF group has been read"):this.debug&&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 e=parseInt(this._data[this._pointer++],10),t=Co(e,this._data[this._pointer++],this.debug),s={code:e,value:t};return Ae(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 e={code:parseInt(this._data[this._pointer]),value:0};return e.value=Co(e.code,this._data[this._pointer+1],this.debug),e}rewind(e){e=e||1,this._pointer=this._pointer-2*e}hasNext(){return!this._eof&&!(this._pointer>this._data.length-2)}isEOF(){return this._eof}constructor(e,t=!1){Ps(this,"_data",void 0),Ps(this,"debug",void 0),Ps(this,"_pointer",void 0),Ps(this,"_eof",void 0),Ps(this,"lastReadGroup",void 0),this._data=e,this.debug=t,this.lastReadGroup={code:0,value:0},this._pointer=0,this._eof=!1}}function Co(i,e,t=!1){return i<=9?e:i>=10&&i<=59?parseFloat(e.trim()):i>=60&&i<=99?parseInt(e.trim()):i>=100&&i<=109?e:i>=110&&i<=149?parseFloat(e.trim()):i>=160&&i<=179?parseInt(e.trim()):i>=210&&i<=239?parseFloat(e.trim()):i>=270&&i<=289?parseInt(e.trim()):i>=290&&i<=299?function(s){if(s==="0")return!1;if(s==="1")return!0;throw TypeError("String '"+s+"' cannot be cast to Boolean type")}(e.trim()):i>=300&&i<=369?e:i>=370&&i<=389?parseInt(e.trim()):i>=390&&i<=399?e:i>=400&&i<=409?parseInt(e.trim()):i>=410&&i<=419?e:i>=420&&i<=429?parseInt(e.trim()):i>=430&&i<=439?e:i>=440&&i<=459?parseInt(e.trim()):i>=460&&i<=469?parseFloat(e.trim()):i>=470&&i<=481||i===999||i>=1e3&&i<=1009?e:i>=1010&&i<=1059?parseFloat(e.trim()):i>=1060&&i<=1071?parseInt(e.trim()):(t&&console.warn("WARNING: Group code does not have a defined type: %j",{code:i,value:e}),e)}function oa(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}class Ld{constructor(){oa(this,"encoding","utf-8"),oa(this,"encodingFailureFatal",!1)}}class Od extends EventTarget{parseSync(e,t=!1){let s=new No(e.split(/\r\n|\r|\n/g),t);if(!s.hasNext())throw Error("Empty file");return this.parseAll(s)}parseStream(e){let t="",s=this;return new Promise((o,h)=>{e.on("data",u=>{t+=u}),e.on("end",()=>{try{let u=t.split(/\r\n|\r|\n/g),g=new No(u);if(!g.hasNext())throw Error("Empty file");o(s.parseAll(g))}catch(u){h(u)}}),e.on("error",u=>{h(u)})})}async parseFromUrl(e,t){let s=await fetch(e,t);if(!s.body)return null;let o=s.body.getReader(),h="";for(;;){let{done:u,value:g}=await o.read();if(u){h+=this._decoder.decode(new ArrayBuffer(0),{stream:!1});break}h+=this._decoder.decode(g,{stream:!0})}return this.parseSync(h)}parseAll(e){let t={header:{},blocks:{},entities:[],tables:{},objects:{byName:{},byTree:void 0}},s=e.next();for(;!Ae(s,0,"EOF");)Ae(s,0,"SECTION")&&(Ae(s=e.next(),2,"HEADER")?(s=e.next(),t.header=gd(s,e)):Ae(s,2,"BLOCKS")?(s=e.next(),t.blocks=md(s,e)):Ae(s,2,"ENTITIES")?(s=e.next(),t.entities=uh(s,e)):Ae(s,2,"TABLES")?(s=e.next(),t.tables=Cd(s,e)):Ae(s,2,"OBJECTS")&&(s=e.next(),t.objects=xd(s,e))),s=e.next();return t}constructor(e=new Ld){super(),oa(this,"_decoder",void 0),this._decoder=new TextDecoder(e.encoding,{fatal:e.encodingFailureFatal})}}var va=(i=>(i[i.DecimalDegrees=0]="DecimalDegrees",i[i.DegreesMinutesSeconds=1]="DegreesMinutesSeconds",i[i.Gradians=2]="Gradians",i[i.Radians=3]="Radians",i[i.SurveyorsUnits=4]="SurveyorsUnits",i))(va||{});class Gr{static get instance(){return this._instance||(this._instance=new Gr),this._instance}constructor(){this._blocks=new Map}createKey(e,t){return`${e}_${t}`}set(e,t){return t=t.fastDeepClone(),this._blocks.set(e,t),t}get(e){let t=this._blocks.get(e);return t&&(t=t.fastDeepClone()),t}has(e){return this._blocks.has(e)}clear(){this._blocks.clear()}draw(e,t,s,o=!0,h,u){const g=[];if(t!=null){const b=this.createKey(t.name,s);let f;if(this.has(b))f=this.get(b);else{const S=t.newIterator();for(const x of S)x.color.isByBlock&&s?(Lo.copy(x.color),x.color.color=s,this.addEntity(x,g,e),x.color.copy(Lo)):this.addEntity(x,g,e);f=e.group(g),f&&o&&this.set(b,f)}return f&&h&&(f.applyMatrix(h),u&&(u.x!=0||u.y!=0||u.z!=1)&&(h.setFromExtrusionDirection(u),f.applyMatrix(h))),f}else return e.group(g)}addEntity(e,t,s){const o=e.draw(s);o&&(this.attachEntityInfo(o,e),t.push(o))}attachEntityInfo(e,t){e.objectId=t.objectId,e.ownerId=t.ownerId,e.layerName=t.layer,e.visible=t.visibility}}const Lo=new Wr,ti="Continuous",Js="ByLayer",mh="ByBlock";var un=(i=>(i[i.EndPoint=1]="EndPoint",i[i.MidPoint=2]="MidPoint",i[i.Center=3]="Center",i[i.Node=4]="Node",i[i.Quadrant=5]="Quadrant",i[i.Insertion=7]="Insertion",i[i.Perpendicular=8]="Perpendicular",i[i.Tangent=9]="Tangent",i[i.Nearest=10]="Nearest",i[i.Centroid=11]="Centroid",i))(un||{}),ya=(i=>(i[i.Undefined=0]="Undefined",i[i.Inches=1]="Inches",i[i.Feet=2]="Feet",i[i.Miles=3]="Miles",i[i.Millimeters=4]="Millimeters",i[i.Centimeters=5]="Centimeters",i[i.Meters=6]="Meters",i[i.Kilometers=7]="Kilometers",i[i.Microinches=8]="Microinches",i[i.Mils=9]="Mils",i[i.Yards=10]="Yards",i[i.Angstroms=11]="Angstroms",i[i.Nanometers=12]="Nanometers",i[i.Microns=13]="Microns",i[i.Decimeters=14]="Decimeters",i[i.Dekameters=15]="Dekameters",i[i.Hectometers=16]="Hectometers",i[i.Gigameters=17]="Gigameters",i[i.Astronomical=18]="Astronomical",i[i.LightYears=19]="LightYears",i[i.Parsecs=20]="Parsecs",i[i.USSurveyFeet=21]="USSurveyFeet",i[i.USSurveyInch=22]="USSurveyInch",i[i.USSurveyYard=23]="USSurveyYard",i[i.USSurveyMile=24]="USSurveyMile",i[i.Max=24]="Max",i))(ya||{});function zd(i){return i==4||i==5||i==6||i==7||i==12||i==13||i==14||i==15||i==16||i==17}function Dd(i){return i==1||i==2||i==3||i==8||i==9||i==10||i==21}var ph=(i=>(i.ClosedFilled="",i.Dot="_DOT",i.DotSmall="_DOTSMALL",i.DotBlank="_DOTBLANK",i.Origin="_ORIGIN",i.Origin2="_ORIGIN2",i.Open="_OPEN",i.Open90="_OPEN90",i.Open30="_OPEN30",i.Closed="_CLOSED",i.Small="_SMALL",i.None="_NONE",i.Oblique="_OBLIQUE",i.BoxFilled="_BOXFILLED",i.Box="_BOXBLANK",i.ClosedBlank="_CLOSEDBLANK",i.DatumBlank="_DATUMBLANK",i.DatumFilled="_DATUMFILLED",i.Integral="_INTEGRAL",i.ArchTick="_ARCHTICK",i))(ph||{});class ki{constructor(e){this.i=0,this._records=e,this._keys=Array.from(e.keys())}[Symbol.iterator](){return this}next(){for(;this.i<this._keys.length;){const e=this._records.get(this._keys[this.i]);return this.i+=1,{value:e,done:!1}}return{value:null,done:!0}}}const gh="Load Database";class Pt extends Jo{constructor(e,t){super(e.stage),this.data=e,this.progress=t}async run(e){const t=ma.getInstance().getEntry(gh),s=Date.now();this.progress&&await this.progress(this.data.progress.value,this.data.stage,"START");const o=await this.data.task(e);if(this.progress){const h=o.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 t&&(t.data[this.name]=Date.now()-s),o}}class fh{constructor(e={}){this.config=e}async read(e,t,s,o){const h={name:gh,data:{total:0},format(){let f="";return Object.keys(this.data).forEach(S=>{S!=="total"&&(f+=`- ${S}: ${this.data[S]} ms
2
- `)}),f+=`- total: ${this.data.total} ms`,f}};ma.getInstance().collect(h),this.progress=o;const u={value:0},g=new el;g.setCompleteCallback(()=>this.onFinished()),g.setErrorCallback(f=>this.onError(f)),g.addTask(new Pt({stage:"START",step:1,progress:u,task:async f=>f},o)),g.addTask(new Pt({stage:"PARSE",step:5,progress:u,task:async f=>await this.parse(f)},o)),g.addTask(new Pt({stage:"FONT",step:5,progress:u,task:async f=>{const S=this.getFonts(f.model);return{model:f.model,data:S}}},o)),g.addTask(new Pt({stage:"LTYPE",step:1,progress:u,task:async f=>(this.processLineTypes(f.model,t),f)},o)),g.addTask(new Pt({stage:"STYLE",step:1,progress:u,task:async f=>(this.processTextStyles(f.model,t),f)},o)),g.addTask(new Pt({stage:"DIMSTYLE",step:1,progress:u,task:async f=>(this.processDimStyles(f.model,t),f)},o)),g.addTask(new Pt({stage:"LAYER",step:1,progress:u,task:async f=>(this.processLayers(f.model,t),f)},o)),g.addTask(new Pt({stage:"VPORT",step:1,progress:u,task:async f=>(this.processViewports(f.model,t),f)},o)),g.addTask(new Pt({stage:"HEADER",step:1,progress:u,task:async f=>(this.processHeader(f.model,t),f)},o)),g.addTask(new Pt({stage:"BLOCK_RECORD",step:5,progress:u,task:async f=>(this.processBlockTables(f.model,t),f)},o)),g.addTask(new Pt({stage:"OBJECT",step:5,progress:u,task:async f=>(this.processObjects(f.model,t),t.dictionaries.layouts.numEntries===0&&t.createDefaultData({layout:!0}),f)},o)),g.addTask(new Pt({stage:"BLOCK",step:5,progress:u,task:async f=>(await this.processBlocks(f.model,t),f)},o)),g.addTask(new Pt({stage:"ENTITY",step:100,progress:u,task:async f=>(await this.processEntities(f.model,t,s,u,o),f)},o)),g.addTask(new Pt({stage:"END",step:0,progress:u,task:async f=>f},o));const b=Date.now();await g.run(e),h.data.total=Date.now()-b}onError(e){if(this.progress){const t=e.task;this.progress(t.data.progress.value,t.data.stage,"ERROR",void 0,e)}console.error(`Error occurred in conversion stage '${e.task.name}': `,e.error),e.task.name!="ENTITY"&&this.onFinished()}onFinished(){this.progress&&(this.progress(100,"END","END"),Gr.instance.clear())}async parse(e,t){throw new Error("Not impelemented yet!")}getFonts(e){throw new Error("Not impelemented yet!")}processLineTypes(e,t){throw new Error("Not impelemented yet!")}processTextStyles(e,t){throw new Error("Not impelemented yet!")}processDimStyles(e,t){throw new Error("Not impelemented yet!")}processLayers(e,t){throw new Error("Not impelemented yet!")}processViewports(e,t){throw new Error("Not impelemented yet!")}processHeader(e,t){throw new Error("Not impelemented yet!")}processBlockTables(e,t){throw new Error("Not impelemented yet!")}processObjects(e,t){throw new Error("Not impelemented yet!")}processBlocks(e,t){throw new Error("Not impelemented yet!")}processEntities(e,t,s,o,h){throw new Error("Not impelemented yet!")}}const ft=["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 Oo=1234567;const ba=Math.PI/180,xa=180/Math.PI;function _h(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(ft[i&255]+ft[i>>8&255]+ft[i>>16&255]+ft[i>>24&255]+"-"+ft[e&255]+ft[e>>8&255]+"-"+ft[e>>16&15|64]+ft[e>>24&255]+"-"+ft[t&63|128]+ft[t>>8&255]+"-"+ft[t>>16&255]+ft[t>>24&255]+ft[s&255]+ft[s>>8&255]+ft[s>>16&255]+ft[s>>24&255]).toLowerCase()}function kr(i,e,t){return Math.max(e,Math.min(t,i))}function wa(i,e){return(i%e+e)%e}function vh(i,e,t,s,o){return s+(i-e)*(o-s)/(t-e)}function yh(i,e,t){return i!==e?(t-i)/(e-i):0}function Aa(i,e,t){return(1-t)*i+t*e}function bh(i,e,t,s){return Aa(i,e,1-Math.exp(-t*s))}function xh(i,e=1){return e-Math.abs(wa(i,e*2)-e)}function wh(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function Ah(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function Sh(i,e){return i+Math.floor(Math.random()*(e-i+1))}function Ph(i,e){return i+Math.random()*(e-i)}function Ih(i){return i*(.5-Math.random())}function Eh(i){i!==void 0&&(Oo=i);let e=Oo+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function kh(i){return i*ba}function Mh(i){return i*xa}function Th(i){return(i&i-1)===0&&i!==0}function Nh(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Ch(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Ms(i){const e=Math.PI*2;return(i%e+e)%e}function Lh(i,e,t){return i>e&&i<t||i>t&&i<e}function Oh(i,e,t,s=!1){return i=Ms(i),e=Ms(e),t=Ms(t),s?e>t?i<=e&&i>=t:i<=e||i>=t:e<t?i>=e&&i<=t:i>=e||i<=t}function Sa(i){return i=Math.abs(i),i<1?0:Math.ceil(Math.log10(Math.abs(i)+1))}function zh(i,e=1e-7){const t=Sa(i);return Math.max(Math.pow(10,t)*e,e)}const Ee={DEG2RAD:ba,RAD2DEG:xa,generateUUID:_h,clamp:kr,euclideanModulo:wa,mapLinear:vh,inverseLerp:yh,lerp:Aa,damp:bh,pingpong:xh,smoothstep:wh,smootherstep:Ah,randInt:Sh,randFloat:Ph,randFloatSpread:Ih,seededRandom:Eh,degToRad:kh,radToDeg:Mh,isPowerOfTwo:Th,ceilPowerOfTwo:Nh,floorPowerOfTwo:Ch,normalizeAngle:Ms,isBetween:Lh,isBetweenAngle:Oh,intPartLength:Sa,relativeEps:zh},la=class Dh{constructor(e,t){this.x=0,this.y=0;const s=+(e!==void 0)+ +(t!==void 0);if(s!==0){if(s===1&&e instanceof Array){this.x=e[0],this.y=e[1];return}if(s===1){const{x:o,y:h}=e;this.x=o,this.y=h;return}if(s===2){this.x=e,this.y=t;return}throw Ut.ILLEGAL_PARAMETERS}}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new Dh(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix2d(e){const t=this.x,s=this.y,o=e.elements;return this.x=o[0]*t+o[3]*s+o[6],this.y=o[1]*t+o[4]*s+o[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(e,Math.min(t,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(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.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(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const s=this.dot(e)/t;return Math.acos(Math.max(-1,Math.min(1,s)))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,s=this.y-e.y;return t*t+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,s){return this.x=e.x+(t.x-e.x)*s,this.y=e.y+(t.y-e.y)*s,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}rotateAround(e,t){const s=Math.cos(t),o=Math.sin(t),h=this.x-e.x,u=this.y-e.y;return this.x=h*s-u*o+e.x,this.y=h*o+u*s+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}relativeEps(e=1e-7){return Math.min(Ee.relativeEps(this.x,e),Ee.relativeEps(this.y,e))}*[Symbol.iterator](){yield this.x,yield this.y}};la.EMPTY=Object.freeze(new la(0,0));let $e=la;const ha=class Rh{constructor(e,t,s,o,h,u,g,b,f){this.elements=[1,0,0,0,1,0,0,0,1],e!=null&&t!=null&&s!=null&&o!=null&&h!=null&&u!=null&&g!=null&&b!=null&&f!=null&&this.set(e,t,s,o,h,u,g,b,f)}set(e,t,s,o,h,u,g,b,f){const S=this.elements;return S[0]=e,S[1]=o,S[2]=g,S[3]=t,S[4]=h,S[5]=b,S[6]=s,S[7]=u,S[8]=f,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,s=e.elements;return t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t[4]=s[4],t[5]=s[5],t[6]=s[6],t[7]=s[7],t[8]=s[8],this}extractBasis(e,t,s){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const s=e.elements,o=t.elements,h=this.elements,u=s[0],g=s[3],b=s[6],f=s[1],S=s[4],x=s[7],E=s[2],M=s[5],z=s[8],D=o[0],U=o[3],B=o[6],ge=o[1],be=o[4],oe=o[7],W=o[2],ce=o[5],se=o[8];return h[0]=u*D+g*ge+b*W,h[3]=u*U+g*be+b*ce,h[6]=u*B+g*oe+b*se,h[1]=f*D+S*ge+x*W,h[4]=f*U+S*be+x*ce,h[7]=f*B+S*oe+x*se,h[2]=E*D+M*ge+z*W,h[5]=E*U+M*be+z*ce,h[8]=E*B+M*oe+z*se,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],s=e[1],o=e[2],h=e[3],u=e[4],g=e[5],b=e[6],f=e[7],S=e[8];return t*u*S-t*g*f-s*h*S+s*g*b+o*h*f-o*u*b}invert(){const e=this.elements,t=e[0],s=e[1],o=e[2],h=e[3],u=e[4],g=e[5],b=e[6],f=e[7],S=e[8],x=S*u-g*f,E=g*b-S*h,M=f*h-u*b,z=t*x+s*E+o*M;if(z===0)return this.set(0,0,0,0,0,0,0,0,0);const D=1/z;return e[0]=x*D,e[1]=(o*f-S*s)*D,e[2]=(g*s-o*u)*D,e[3]=E*D,e[4]=(S*t-o*b)*D,e[5]=(o*h-g*t)*D,e[6]=M*D,e[7]=(s*b-f*t)*D,e[8]=(u*t-s*h)*D,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e.elements[0]=t[0],e.elements[1]=t[3],e.elements[2]=t[6],e.elements[3]=t[1],e.elements[4]=t[4],e.elements[5]=t[7],e.elements[6]=t[2],e.elements[7]=t[5],e.elements[8]=t[8],this}setUvTransform(e,t,s,o,h,u,g){const b=Math.cos(h),f=Math.sin(h);return this.set(s*b,s*f,-s*(b*u+f*g)+u+e,-o*f,o*b,-o*(-f*u+b*g)+g+t,0,0,1),this}scale(e,t){return this.premultiply(ra.makeScale(e,t)),this}rotate(e){return this.premultiply(ra.makeRotation(-e)),this}translate(e,t){return this.premultiply(ra.makeTranslation(e,t)),this}makeTranslation(e,t){return e instanceof $e?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,-s,0,s,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,s=e.elements;for(let o=0;o<9;o++)if(t[o]!==s[o])return!1;return!0}fromArray(e,t=0){for(let s=0;s<9;s++)this.elements[s]=e[s+t];return this}toArray(e=[],t=0){const s=this.elements;return e[t]=s[0],e[t+1]=s[1],e[t+2]=s[2],e[t+3]=s[3],e[t+4]=s[4],e[t+5]=s[5],e[t+6]=s[6],e[t+7]=s[7],e[t+8]=s[8],e}clone(){return new Rh().fromArray(this.elements)}};ha.IDENTITY=Object.freeze(new ha);let Mi=ha;const ra=new Mi,cn=1e-6,nt=2*Math.PI,Rd={x:0,y:0},Pa={x:0,y:0,z:0};class Ia{constructor(){this.equalPointTol=cn,this.equalVectorTol=cn}equalPoint2d(e,t){return new $e(e).sub(t).length()<this.equalPointTol}equalPoint3d(e,t){return new Z(e).sub(t).length()<this.equalPointTol}static equalToZero(e,t=cn){return e<t&&e>-t}static equal(e,t,s=cn){return Math.abs(e-t)<s}static great(e,t,s=cn){return e-t>s}static less(e,t,s=cn){return e-t<s}}const Ea=new Ia;function ka(i,e,t=!1){const s=i.x,o=i.y;let h=!1;const u=e.length;for(let g=0,b=u-1;g<u;b=g++){const f=e[g].x,S=e[g].y,x=e[b].x,E=e[b].y;let M=S>o!=E>o;t&&(M=S>=o!=E>=o),M&&s<(x-f)*(o-S)/(E-S)+f&&(h=!h)}return h}function Bh(i,e){if(i.length===0||e.length===0)return!1;const t=new _t().setFromPoints(i),s=new _t().setFromPoints(e);if(!t.intersectsBox(s))return!1;for(let o=0;o<i.length;){if(ka(i[o],e,!0))return!0;o<i.length-1&&Ea.equalPoint2d(i[o+1],i[o])&&++o,++o}return!1}const Fh={isPointInPolygon:ka,isPolygonIntersect:Bh};function Uh(i,e){const t=[],s=e-1,o=i;for(let h=0;h<=o;h++)t.push(0);for(let h=1;h<=s-o;h++)t.push(h);for(let h=0;h<=o;h++)t.push(s-o+1);return t}function Vh(i,e){const t=e.length-1,s=i,o=[0];let h=0;for(let g=1;g<=t;g++){const b=e[g][0]-e[g-1][0],f=e[g][1]-e[g-1][1],S=e[g][2]-e[g-1][2],x=Math.sqrt(b*b+f*f+S*S);h+=x,o.push(h)}const u=[];for(let g=0;g<=s;g++)u.push(0);for(let g=1;g<=t-s;g++){const b=o[g]/h;u.push(b*(t-s+1))}for(let g=0;g<=s;g++)u.push(t-s+1);return u}function jh(i,e){const t=e.length-1,s=i,o=[0];let h=0;for(let g=1;g<=t;g++){const b=e[g][0]-e[g-1][0],f=e[g][1]-e[g-1][1],S=e[g][2]-e[g-1][2],x=Math.sqrt(b*b+f*f+S*S),E=Math.sqrt(x);h+=E,o.push(h)}const u=[];for(let g=0;g<=s;g++)u.push(0);for(let g=1;g<=t-s;g++){const b=o[g]/h;u.push(b*(t-s+1))}for(let g=0;g<=s;g++)u.push(t-s+1);return u}function ri(i,e,t,s){if(e===0)return t>=s[i]&&t<s[i+1]?1:0;const o=s[i+e]-s[i],h=s[i+e+1]-s[i+1],u=o>1e-10?(t-s[i])/o:0,g=h>1e-10?(s[i+e+1]-t)/h:0;return u*ri(i,e-1,t,s)+g*ri(i+1,e-1,t,s)}function Ts(i,e,t,s,o){const h=s.length-1,u=e;if(i=Math.max(t[u],Math.min(t[h+1],i)),Math.abs(i-t[h+1])<1e-8)return[...s[h]];if(Math.abs(i-t[u])<1e-8)return[...s[0]];const g=[0,0,0];let b=0;for(let f=0;f<=h;f++){const S=ri(f,u,i,t),x=o[f]*S;g[0]+=s[f][0]*x,g[1]+=s[f][1]*x,g[2]+=s[f][2]*x,b+=x}if(b<1e-10){const f=t[t.length-u-1];if(Math.abs(i-f)<1e-8)return[...s[h]];if(Math.abs(i-t[u])<1e-8)return[...s[0]]}return b>1e-10&&(g[0]/=b,g[1]/=b,g[2]/=b),g}function Gh(i,e,t,s){const o=i,h=e[o],u=e[e.length-o-1];let g=0;const b=1e3,f=(u-h)/b;let S=Ts(h,i,e,t,s);for(let D=1;D<=b;D++){const U=h+D*f,B=Ts(U,i,e,t,s),ge=B[0]-S[0],be=B[1]-S[1],oe=B[2]-S[2];g+=Math.sqrt(ge*ge+be*be+oe*oe),S=B}const x=Ts(u,i,e,t,s),E=x[0]-S[0],M=x[1]-S[1],z=x[2]-S[2];return g+=Math.sqrt(E*E+M*M+z*z),g}function Bd(i){return i.map(e=>[...e])}class Hr{constructor(e=0,t=0,s=0,o=1){this._x=e,this._y=t,this._z=s,this._w=o}static slerpFlat(e,t,s,o,h,u,g){let b=s[o+0],f=s[o+1],S=s[o+2],x=s[o+3];const E=h[u+0],M=h[u+1],z=h[u+2],D=h[u+3];if(g===0){e[t+0]=b,e[t+1]=f,e[t+2]=S,e[t+3]=x;return}if(g===1){e[t+0]=E,e[t+1]=M,e[t+2]=z,e[t+3]=D;return}if(x!==D||b!==E||f!==M||S!==z){let U=1-g;const B=b*E+f*M+S*z+x*D,ge=B>=0?1:-1,be=1-B*B;if(be>Number.EPSILON){const W=Math.sqrt(be),ce=Math.atan2(W,B*ge);U=Math.sin(U*ce)/W,g=Math.sin(g*ce)/W}const oe=g*ge;if(b=b*U+E*oe,f=f*U+M*oe,S=S*U+z*oe,x=x*U+D*oe,U===1-g){const W=1/Math.sqrt(b*b+f*f+S*S+x*x);b*=W,f*=W,S*=W,x*=W}}e[t]=b,e[t+1]=f,e[t+2]=S,e[t+3]=x}static multiplyQuaternionsFlat(e,t,s,o,h,u){const g=s[o],b=s[o+1],f=s[o+2],S=s[o+3],x=h[u],E=h[u+1],M=h[u+2],z=h[u+3];return e[t]=g*z+S*x+b*M-f*E,e[t+1]=b*z+S*E+f*x-g*M,e[t+2]=f*z+S*M+g*E-b*x,e[t+3]=S*z-g*x-b*E-f*M,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,s,o){return this._x=e,this._y=t,this._z=s,this._w=o,this._onChangeCallback(),this}clone(){return new Hr(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const s=e.x,o=e.y,h=e.z,u=e.order,g=Math.cos,b=Math.sin,f=g(s/2),S=g(o/2),x=g(h/2),E=b(s/2),M=b(o/2),z=b(h/2);switch(u){case"XYZ":this._x=E*S*x+f*M*z,this._y=f*M*x-E*S*z,this._z=f*S*z+E*M*x,this._w=f*S*x-E*M*z;break;case"YXZ":this._x=E*S*x+f*M*z,this._y=f*M*x-E*S*z,this._z=f*S*z-E*M*x,this._w=f*S*x+E*M*z;break;case"ZXY":this._x=E*S*x-f*M*z,this._y=f*M*x+E*S*z,this._z=f*S*z+E*M*x,this._w=f*S*x-E*M*z;break;case"ZYX":this._x=E*S*x-f*M*z,this._y=f*M*x+E*S*z,this._z=f*S*z-E*M*x,this._w=f*S*x+E*M*z;break;case"YZX":this._x=E*S*x+f*M*z,this._y=f*M*x+E*S*z,this._z=f*S*z-E*M*x,this._w=f*S*x-E*M*z;break;case"XZY":this._x=E*S*x-f*M*z,this._y=f*M*x-E*S*z,this._z=f*S*z+E*M*x,this._w=f*S*x+E*M*z;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+u)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const s=t/2,o=Math.sin(s);return this._x=e.x*o,this._y=e.y*o,this._z=e.z*o,this._w=Math.cos(s),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,s=t[0],o=t[4],h=t[8],u=t[1],g=t[5],b=t[9],f=t[2],S=t[6],x=t[10],E=s+g+x;if(E>0){const M=.5/Math.sqrt(E+1);this._w=.25/M,this._x=(S-b)*M,this._y=(h-f)*M,this._z=(u-o)*M}else if(s>g&&s>x){const M=2*Math.sqrt(1+s-g-x);this._w=(S-b)/M,this._x=.25*M,this._y=(o+u)/M,this._z=(h+f)/M}else if(g>x){const M=2*Math.sqrt(1+g-s-x);this._w=(h-f)/M,this._x=(o+u)/M,this._y=.25*M,this._z=(b+S)/M}else{const M=2*Math.sqrt(1+x-s-g);this._w=(u-o)/M,this._x=(h+f)/M,this._y=(b+S)/M,this._z=.25*M}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let s=e.dot(t)+1;return s<Number.EPSILON?(s=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=s):(this._x=0,this._y=-e.z,this._z=e.y,this._w=s)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=s),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(kr(this.dot(e),-1,1)))}rotateTowards(e,t){const s=this.angleTo(e);if(s===0)return this;const o=Math.min(1,t/s);return this.slerp(e,o),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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._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 e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const s=e._x,o=e._y,h=e._z,u=e._w,g=t._x,b=t._y,f=t._z,S=t._w;return this._x=s*S+u*g+o*f-h*b,this._y=o*S+u*b+h*g-s*f,this._z=h*S+u*f+s*b-o*g,this._w=u*S-s*g-o*b-h*f,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const s=this._x,o=this._y,h=this._z,u=this._w;let g=u*e._w+s*e._x+o*e._y+h*e._z;if(g<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,g=-g):this.copy(e),g>=1)return this._w=u,this._x=s,this._y=o,this._z=h,this;const b=1-g*g;if(b<=Number.EPSILON){const M=1-t;return this._w=M*u+t*this._w,this._x=M*s+t*this._x,this._y=M*o+t*this._y,this._z=M*h+t*this._z,this.normalize(),this}const f=Math.sqrt(b),S=Math.atan2(f,g),x=Math.sin((1-t)*S)/f,E=Math.sin(t*S)/f;return this._w=u*x+this._w*E,this._x=s*x+this._x*E,this._y=o*x+this._y*E,this._z=h*x+this._z*E,this._onChangeCallback(),this}slerpQuaternions(e,t,s){return this.copy(e).slerp(t,s)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),s=Math.random(),o=Math.sqrt(1-s),h=Math.sqrt(s);return this.set(o*Math.sin(e),o*Math.cos(e),h*Math.sin(t),h*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const Bt=class Wh{constructor(e,t,s){this.x=0,this.y=0,this.z=0;const o=+(e!==void 0)+ +(t!==void 0)+ +(s!==void 0);if(o!==0){if(o===1&&e instanceof Array){this.x=e[0],this.y=e[1],this.z=e[2];return}if(o===1){const{x:h,y:u,z:g}=e;this.x=h,this.y=u,this.z=g||0;return}if(o===3){this.x=e,this.y=t,this.z=s;return}throw Ut.ILLEGAL_PARAMETERS}}set(e,t,s){return s===void 0&&(s=this.z),this.x=e,this.y=t,this.z=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new Wh(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z||0,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z||0,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(zo.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(zo.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,s=this.y,o=this.z,h=e.elements;return this.x=h[0]*t+h[3]*s+h[6]*o,this.y=h[1]*t+h[4]*s+h[7]*o,this.z=h[2]*t+h[5]*s+h[8]*o,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix3d(e){const t=this.x,s=this.y,o=this.z,h=e.elements,u=1/(h[3]*t+h[7]*s+h[11]*o+h[15]);return this.x=(h[0]*t+h[4]*s+h[8]*o+h[12])*u,this.y=(h[1]*t+h[5]*s+h[9]*o+h[13])*u,this.z=(h[2]*t+h[6]*s+h[10]*o+h[14])*u,this}applyQuaternion(e){const t=this.x,s=this.y,o=this.z,h=e.x,u=e.y,g=e.z,b=e.w,f=2*(u*o-g*s),S=2*(g*t-h*o),x=2*(h*s-u*t);return this.x=t+b*f+u*x-g*S,this.y=s+b*S+g*f-h*x,this.z=o+b*x+h*S-u*f,this}transformDirection(e){const t=this.x,s=this.y,o=this.z,h=e.elements;return this.x=h[0]*t+h[4]*s+h[8]*o,this.y=h[1]*t+h[5]*s+h[9]*o,this.z=h[2]*t+h[6]*s+h[10]*o,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(e,Math.min(t,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(e){return this.x*e.x+this.y*e.y+this.z*e.z}isParallelTo(e){const t=this.dot(e),s=this.length(),o=e.length();return Math.abs(t)===s*o}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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,s){return this.x=e.x+(t.x-e.x)*s,this.y=e.y+(t.y-e.y)*s,this.z=e.z+(t.z-e.z)*s,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const s=e.x,o=e.y,h=e.z,u=t.x,g=t.y,b=t.z;return this.x=o*b-h*g,this.y=h*u-s*b,this.z=s*g-o*u,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const s=e.dot(this)/t;return this.copy(e).multiplyScalar(s)}projectOnPlane(e){return na.copy(this).projectOnVector(e),this.sub(na)}reflect(e){return this.sub(na.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const s=this.dot(e)/t;return Math.acos(Math.max(-1,Math.min(1,s)))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,s=this.y-e.y,o=this.z-e.z;return t*t+s*s+o*o}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),s=this.setFromMatrixColumn(e,1).length(),o=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=s,this.z=o,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,s=Math.sqrt(1-t*t);return this.x=s*Math.cos(e),this.y=t,this.z=s*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};Bt.X_AXIS=Object.freeze(new Bt(1,0,0)),Bt.NEGATIVE_X_AXIS=Object.freeze(new Bt(-1,0,0)),Bt.Y_AXIS=Object.freeze(new Bt(0,1,0)),Bt.NEGATIVE_Y_AXIS=Object.freeze(new Bt(0,-1,0)),Bt.Z_AXIS=Object.freeze(new Bt(0,0,1)),Bt.NEGATIVE_Z_AXIS=Object.freeze(new Bt(0,0,-1));let Z=Bt;const na=new Z,zo=new Hr,ca=class Hh{constructor(e,t,s,o,h,u,g,b,f,S,x,E,M,z,D,U){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!=null&&t!=null&&s!=null&&o!=null&&h!=null&&u!=null&&g!=null&&b!=null&&f!=null&&S!=null&&x!=null&&E!=null&&M!=null&&z!=null&&D!=null&&U!=null&&this.set(e,t,s,o,h,u,g,b,f,S,x,E,M,z,D,U)}set(e,t,s,o,h,u,g,b,f,S,x,E,M,z,D,U){const B=this.elements;return B[0]=e,B[4]=t,B[8]=s,B[12]=o,B[1]=h,B[5]=u,B[9]=g,B[13]=b,B[2]=f,B[6]=S,B[10]=x,B[14]=E,B[3]=M,B[7]=z,B[11]=D,B[15]=U,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 Hh().fromArray(this.elements)}copy(e){const t=this.elements,s=e.elements;return t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t[4]=s[4],t[5]=s[5],t[6]=s[6],t[7]=s[7],t[8]=s[8],t[9]=s[9],t[10]=s[10],t[11]=s[11],t[12]=s[12],t[13]=s[13],t[14]=s[14],t[15]=s[15],this}copyPosition(e){const t=this.elements,s=e.elements;return t[12]=s[12],t[13]=s[13],t[14]=s[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}setFromExtrusionDirection(e){if(Ea.equalPoint3d(e,Z.Z_AXIS))this.identity();else{const t=new Z(1,0,0);Math.abs(e.x)<1/64&&Math.abs(e.y)<1/64?t.crossVectors(Z.Y_AXIS,e).normalize():t.crossVectors(Z.Z_AXIS,e).normalize();const s=e.clone().cross(t).normalize();this.set(t.x,t.y,t.z,0,s.x,s.y,s.z,0,e.x,e.y,e.z,0,0,0,0,1)}return this}extractBasis(e,t,s){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this}makeBasis(e,t,s){return this.set(e.x,t.x,s.x,0,e.y,t.y,s.y,0,e.z,t.z,s.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,s=e.elements,o=1/Ln.setFromMatrixColumn(e,0).length(),h=1/Ln.setFromMatrixColumn(e,1).length(),u=1/Ln.setFromMatrixColumn(e,2).length();return t[0]=s[0]*o,t[1]=s[1]*o,t[2]=s[2]*o,t[3]=0,t[4]=s[4]*h,t[5]=s[5]*h,t[6]=s[6]*h,t[7]=0,t[8]=s[8]*u,t[9]=s[9]*u,t[10]=s[10]*u,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Fd,e,Ud)}lookAt(e,t,s){const o=this.elements;return Rt.subVectors(e,t),Rt.lengthSq()===0&&(Rt.z=1),Rt.normalize(),Ur.crossVectors(s,Rt),Ur.lengthSq()===0&&(Math.abs(s.z)===1?Rt.x+=1e-4:Rt.z+=1e-4,Rt.normalize(),Ur.crossVectors(s,Rt)),Ur.normalize(),Gs.crossVectors(Rt,Ur),o[0]=Ur.x,o[4]=Gs.x,o[8]=Rt.x,o[1]=Ur.y,o[5]=Gs.y,o[9]=Rt.y,o[2]=Ur.z,o[6]=Gs.z,o[10]=Rt.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const s=e.elements,o=t.elements,h=this.elements,u=s[0],g=s[4],b=s[8],f=s[12],S=s[1],x=s[5],E=s[9],M=s[13],z=s[2],D=s[6],U=s[10],B=s[14],ge=s[3],be=s[7],oe=s[11],W=s[15],ce=o[0],se=o[4],Ve=o[8],Ye=o[12],We=o[1],xe=o[5],Le=o[9],dt=o[13],mt=o[2],It=o[6],Je=o[10],at=o[14],Q=o[3],Te=o[7],ot=o[11],hr=o[15];return h[0]=u*ce+g*We+b*mt+f*Q,h[4]=u*se+g*xe+b*It+f*Te,h[8]=u*Ve+g*Le+b*Je+f*ot,h[12]=u*Ye+g*dt+b*at+f*hr,h[1]=S*ce+x*We+E*mt+M*Q,h[5]=S*se+x*xe+E*It+M*Te,h[9]=S*Ve+x*Le+E*Je+M*ot,h[13]=S*Ye+x*dt+E*at+M*hr,h[2]=z*ce+D*We+U*mt+B*Q,h[6]=z*se+D*xe+U*It+B*Te,h[10]=z*Ve+D*Le+U*Je+B*ot,h[14]=z*Ye+D*dt+U*at+B*hr,h[3]=ge*ce+be*We+oe*mt+W*Q,h[7]=ge*se+be*xe+oe*It+W*Te,h[11]=ge*Ve+be*Le+oe*Je+W*ot,h[15]=ge*Ye+be*dt+oe*at+W*hr,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],s=e[4],o=e[8],h=e[12],u=e[1],g=e[5],b=e[9],f=e[13],S=e[2],x=e[6],E=e[10],M=e[14],z=e[3],D=e[7],U=e[11],B=e[15];return z*(+h*b*x-o*f*x-h*g*E+s*f*E+o*g*M-s*b*M)+D*(+t*b*M-t*f*E+h*u*E-o*u*M+o*f*S-h*b*S)+U*(+t*f*x-t*g*M-h*u*x+s*u*M+h*g*S-s*f*S)+B*(-o*g*S-t*b*x+t*g*E+o*u*x-s*u*E+s*b*S)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,s){const o=this.elements;return e instanceof Z?(o[12]=e.x,o[13]=e.y,o[14]=e.z):(o[12]=e,o[13]=t,o[14]=s),this}invert(){const e=this.elements,t=e[0],s=e[1],o=e[2],h=e[3],u=e[4],g=e[5],b=e[6],f=e[7],S=e[8],x=e[9],E=e[10],M=e[11],z=e[12],D=e[13],U=e[14],B=e[15],ge=x*U*f-D*E*f+D*b*M-g*U*M-x*b*B+g*E*B,be=z*E*f-S*U*f-z*b*M+u*U*M+S*b*B-u*E*B,oe=S*D*f-z*x*f+z*g*M-u*D*M-S*g*B+u*x*B,W=z*x*b-S*D*b-z*g*E+u*D*E+S*g*U-u*x*U,ce=t*ge+s*be+o*oe+h*W;if(ce===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const se=1/ce;return e[0]=ge*se,e[1]=(D*E*h-x*U*h-D*o*M+s*U*M+x*o*B-s*E*B)*se,e[2]=(g*U*h-D*b*h+D*o*f-s*U*f-g*o*B+s*b*B)*se,e[3]=(x*b*h-g*E*h-x*o*f+s*E*f+g*o*M-s*b*M)*se,e[4]=be*se,e[5]=(S*U*h-z*E*h+z*o*M-t*U*M-S*o*B+t*E*B)*se,e[6]=(z*b*h-u*U*h-z*o*f+t*U*f+u*o*B-t*b*B)*se,e[7]=(u*E*h-S*b*h+S*o*f-t*E*f-u*o*M+t*b*M)*se,e[8]=oe*se,e[9]=(z*x*h-S*D*h-z*s*M+t*D*M+S*s*B-t*x*B)*se,e[10]=(u*D*h-z*g*h+z*s*f-t*D*f-u*s*B+t*g*B)*se,e[11]=(S*g*h-u*x*h-S*s*f+t*x*f+u*s*M-t*g*M)*se,e[12]=W*se,e[13]=(S*D*o-z*x*o+z*s*E-t*D*E-S*s*U+t*x*U)*se,e[14]=(z*g*o-u*D*o-z*s*b+t*D*b+u*s*U-t*g*U)*se,e[15]=(u*x*o-S*g*o+S*s*b-t*x*b-u*s*E+t*g*E)*se,this}scale(e){const t=this.elements,s=e.x,o=e.y,h=e.z;return t[0]*=s,t[4]*=o,t[8]*=h,t[1]*=s,t[5]*=o,t[9]*=h,t[2]*=s,t[6]*=o,t[10]*=h,t[3]*=s,t[7]*=o,t[11]*=h,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],s=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],o=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,s,o))}makeTranslation(e,t,s){return e instanceof Z?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,s,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),s=Math.sin(e);return this.set(1,0,0,0,0,t,-s,0,0,s,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,0,s,0,0,1,0,0,-s,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,-s,0,0,s,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const s=Math.cos(t),o=Math.sin(t),h=1-s,u=e.x,g=e.y,b=e.z,f=h*u,S=h*g;return this.set(f*u+s,f*g-o*b,f*b+o*g,0,f*g+o*b,S*g+s,S*b-o*u,0,f*b-o*g,S*b+o*u,h*b*b+s,0,0,0,0,1),this}makeScale(e,t,s){return this.set(e,0,0,0,0,t,0,0,0,0,s,0,0,0,0,1),this}makeShear(e,t,s,o,h,u){return this.set(1,s,h,0,e,1,u,0,t,o,1,0,0,0,0,1),this}compose(e,t,s){const o=this.elements,h=t.x,u=t.y,g=t.z,b=t.w,f=h+h,S=u+u,x=g+g,E=h*f,M=h*S,z=h*x,D=u*S,U=u*x,B=g*x,ge=b*f,be=b*S,oe=b*x,W=s.x,ce=s.y,se=s.z;return o[0]=(1-(D+B))*W,o[1]=(M+oe)*W,o[2]=(z-be)*W,o[3]=0,o[4]=(M-oe)*ce,o[5]=(1-(E+B))*ce,o[6]=(U+ge)*ce,o[7]=0,o[8]=(z+be)*se,o[9]=(U-ge)*se,o[10]=(1-(E+D))*se,o[11]=0,o[12]=e.x,o[13]=e.y,o[14]=e.z,o[15]=1,this}decompose(e,t,s){const o=this.elements;let h=Ln.set(o[0],o[1],o[2]).length();const u=Ln.set(o[4],o[5],o[6]).length(),g=Ln.set(o[8],o[9],o[10]).length();this.determinant()<0&&(h=-h),e.x=o[12],e.y=o[13],e.z=o[14],rr.copy(this);const b=1/h,f=1/u,S=1/g;return rr.elements[0]*=b,rr.elements[1]*=b,rr.elements[2]*=b,rr.elements[4]*=f,rr.elements[5]*=f,rr.elements[6]*=f,rr.elements[8]*=S,rr.elements[9]*=S,rr.elements[10]*=S,t.setFromRotationMatrix(rr),s.x=h,s.y=u,s.z=g,this}equals(e){const t=this.elements,s=e.elements;for(let o=0;o<16;o++)if(t[o]!==s[o])return!1;return!0}fromArray(e,t=0){for(let s=0;s<16;s++)this.elements[s]=e[s+t];return this}toArray(e=[],t=0){const s=this.elements;return e[t]=s[0],e[t+1]=s[1],e[t+2]=s[2],e[t+3]=s[3],e[t+4]=s[4],e[t+5]=s[5],e[t+6]=s[6],e[t+7]=s[7],e[t+8]=s[8],e[t+9]=s[9],e[t+10]=s[10],e[t+11]=s[11],e[t+12]=s[12],e[t+13]=s[13],e[t+14]=s[14],e[t+15]=s[15],e}};ca.IDENTITY=Object.freeze(new ca);let fn=ca;const Ln=new Z,rr=new fn,Fd=new Z(0,0,0),Ud=new Z(1,1,1),Ur=new Z,Gs=new Z,Rt=new Z;class Re{constructor(e=void 0,t=void 0){this.min=e==null?new Z(1/0,1/0,1/0):new Z(e.x,e.y,e.z),this.max=t==null?new Z(-1/0,-1/0,-1/0):new Z(t.x,t.y,t.z)}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,s=e.length;t<s;t+=3)this.expandByPoint(sa.fromArray(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,s=e.length;t<s;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const s=sa.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(s),this.max.copy(e).add(s),this}clone(){return new Re().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.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(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.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(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsPlane(e){let t,s;return e.normal.x>0?(t=e.normal.x*this.min.x,s=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,s=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,s+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,s+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,s+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,s+=e.normal.z*this.min.z),t<=-e.constant&&s>=-e.constant}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,sa).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Er[0].set(this.min.x,this.min.y,this.min.z).applyMatrix3d(e),Er[1].set(this.min.x,this.min.y,this.max.z).applyMatrix3d(e),Er[2].set(this.min.x,this.max.y,this.min.z).applyMatrix3d(e),Er[3].set(this.min.x,this.max.y,this.max.z).applyMatrix3d(e),Er[4].set(this.max.x,this.min.y,this.min.z).applyMatrix3d(e),Er[5].set(this.max.x,this.min.y,this.max.z).applyMatrix3d(e),Er[6].set(this.max.x,this.max.y,this.min.z).applyMatrix3d(e),Er[7].set(this.max.x,this.max.y,this.max.z).applyMatrix3d(e),this.setFromPoints(Er),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Er=[new Z,new Z,new Z,new Z,new Z,new Z,new Z,new Z],sa=new Z,Do=new $e;class _t{constructor(e=void 0,t=void 0){this.min=e==null?new $e(1/0,1/0):new $e(e.x,e.y),this.max=t==null?new $e(-1/0,-1/0):new $e(t.x,t.y)}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,s=e.length;t<s;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const s=Do.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(s),this.max.copy(e).add(s),this}clone(){return new _t().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.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(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new $e(0,0):new $e(0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new $e(0,0):new $e(0,0).subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Do).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Ro=new Z,Vd=new Z,jd=new Mi;class Ds{constructor(e=new Z(1,0,0),t=0){this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,s,o){return this.normal.set(e,t,s),this.constant=o,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,s){const o=Ro.subVectors(s,t).cross(Vd.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(o,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectsBox(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const s=t||jd.getNormalMatrix(e),o=this.coplanarPoint(Ro).applyMatrix3d(e),h=this.normal.applyMatrix3(s).normalize();return this.constant=-o.dot(h),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new Ds().copy(this)}}class Me extends $e{static pointArrayToNumberArray(e){const t=new Array(e.length*2);return e.forEach((s,o)=>{s.toArray(t,o*2)}),t}}class $ extends Z{static pointArrayToNumberArray(e,t=!0){const s=t?3:2,o=new Array(e.length*s);return e.forEach((h,u)=>{h.toArray(o,u*s)}),o}}const Bo=new fn,Fo=new Hr,qh=class ua{constructor(e=0,t=0,s=0,o=ua.DEFAULT_ORDER){this._x=e,this._y=t,this._z=s,this._order=o}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,s,o=this._order){return this._x=e,this._y=t,this._z=s,this._order=o,this._onChangeCallback(),this}clone(){return new ua(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,s=!0){const o=e.elements,h=o[0],u=o[4],g=o[8],b=o[1],f=o[5],S=o[9],x=o[2],E=o[6],M=o[10];switch(t){case"XYZ":this._y=Math.asin(kr(g,-1,1)),Math.abs(g)<.9999999?(this._x=Math.atan2(-S,M),this._z=Math.atan2(-u,h)):(this._x=Math.atan2(E,f),this._z=0);break;case"YXZ":this._x=Math.asin(-kr(S,-1,1)),Math.abs(S)<.9999999?(this._y=Math.atan2(g,M),this._z=Math.atan2(b,f)):(this._y=Math.atan2(-x,h),this._z=0);break;case"ZXY":this._x=Math.asin(kr(E,-1,1)),Math.abs(E)<.9999999?(this._y=Math.atan2(-x,M),this._z=Math.atan2(-u,f)):(this._y=0,this._z=Math.atan2(b,h));break;case"ZYX":this._y=Math.asin(-kr(x,-1,1)),Math.abs(x)<.9999999?(this._x=Math.atan2(E,M),this._z=Math.atan2(b,h)):(this._x=0,this._z=Math.atan2(-u,f));break;case"YZX":this._z=Math.asin(kr(b,-1,1)),Math.abs(b)<.9999999?(this._x=Math.atan2(-S,f),this._y=Math.atan2(-x,h)):(this._x=0,this._y=Math.atan2(g,M));break;case"XZY":this._z=Math.asin(-kr(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(E,f),this._y=Math.atan2(g,h)):(this._x=Math.atan2(-S,M),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,s===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,s=!0){return Bo.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Bo,t,s)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Fo.setFromEuler(this),this.setFromQuaternion(Fo,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};qh.DEFAULT_ORDER="XYZ";let Yh=qh;class Xh{constructor(){this._boundingBoxNeedsUpdate=!1}get boundingBoxNeedUpdate(){return this._boundingBoxNeedsUpdate}}class Ma extends Xh{translate(e){return this.transform(new Mi().makeTranslation(e.x,e.y))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}class Ti extends Ma{constructor(){super(),this._loops=[]}add(e){this._loops.push(e),this._boundingBoxNeedsUpdate=!0}get loops(){return this._loops}get outter(){if(this._loops.length>0)return this._loops[0]}calculateBoundingBox(){const e=this.outter;return e?e.box:new _t}transform(e){return this._boundingBoxNeedsUpdate=!0,this}getPoints(e){const t=[];for(let s=0;s<this.loops.length;++s){const o=this.loops[s].getPoints(e);t.push(o)}return t}buildHierarchy(){var e;const t=this.getPoints(100),s=this.calculateBoundaryBoxes(t),o=this.sortBoundaryBoxesByAreas(s),h=new Map,u=o.length;for(let b=0;b<u;b++)h.set(o[b],{index:o[b],children:[]});const g={index:-1,children:[]};for(let b=0;b<u;b++){const f=o[b],S=t[f],x=s[f];let E=b+1;for(;E<u;E++){const M=o[E],z=t[M];if(s[M].containsBox(x)&&Fh.isPointInPolygon(S[Ee.randInt(0,S.length-1)],z)){(e=h.get(M))==null||e.children.push(h.get(f));break}}E===u&&g.children.push(h.get(f))}return g}calculateBoundaryBoxes(e){const t=[];return e.forEach(s=>{t.push(new _t().setFromPoints(s))}),t}sortBoundaryBoxesByAreas(e){const t=[];e.forEach((o,h)=>{const u=o.size,g=u.width*u.height;t.push({area:g,index:h})}),t.sort((o,h)=>o.area-h.area);const s=[];return t.forEach(o=>{s.push(o.index)}),s}}class Vn extends Ma{constructor(){super(),this.arcLengthDivisions=100}get startPoint(){return this.getPoint(0)}get endPoint(){return this.getPoint(1)}get length(){return this.getLength()}getPoint(e){throw new Error("AcGeCurve2d: .getPoint() not implemented.")}getPointAt(e){const t=this.getUtoTmapping(e);return this.getPoint(t)}getPoints(e=5){const t=[];for(let s=0;s<=e;s++)t.push(this.getPoint(s/e));return t}getSpacedPoints(e=5){const t=[];for(let s=0;s<=e;s++)t.push(this.getPointAt(s/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){const t=[];let s,o=this.getPoint(0),h=0;t.push(0);for(let u=1;u<=e;u++)s=this.getPoint(u/e),h+=s.distanceTo(o),t.push(h),o=s;return t}getUtoTmapping(e,t){const s=this.getLengths();let o=0;const h=s.length;let u;t?u=t:u=e*s[h-1];let g=0,b=h-1,f;for(;g<=b;)if(o=Math.floor(g+(b-g)/2),f=s[o]-u,f<0)g=o+1;else if(f>0)b=o-1;else{b=o;break}if(o=b,s[o]===u)return o/(h-1);const S=s[o],x=s[o+1]-S,E=(u-S)/x;return(o+E)/(h-1)}getTangent(e){let t=e-1e-4,s=e+1e-4;t<0&&(t=0),s>1&&(s=1);const o=this.getPoint(t),h=this.getPoint(s),u=new Me;return u.copy(h).sub(o).normalize(),u}getTangentAt(e){const t=this.getUtoTmapping(e);return this.getTangent(t)}}class Dn extends Vn{constructor(e,t,s,o,h){super();const u=+(e!==void 0)+ +(t!==void 0)+ +(s!==void 0)+ +(o!==void 0)+ +(h!==void 0);if(u==3)typeof e=="object"&&typeof t=="object"&&typeof s=="object"?this.createByThreePoints(e,t,s):this.createByStartEndPointsAndBulge(e,t,s);else if(u==5){const g=e;this.center=new Me(g.x,g.y),this.radius=t,this._clockwise=h,this._startAngle=this._clockwise?this._mirrorAngle(Ee.normalizeAngle(s)):Ee.normalizeAngle(s),this._endAngle=this._clockwise?this._mirrorAngle(Ee.normalizeAngle(o)):Ee.normalizeAngle(o)}else throw Ut.ILLEGAL_PARAMETERS}createByThreePoints(e,t,s){const o=(se,Ve)=>({x:(se.x+Ve.x)/2,y:(se.y+Ve.y)/2}),h=(se,Ve)=>(Ve.y-se.y)/(Ve.x-se.x),u=se=>-1/se,g=o(e,t),b=o(t,s),f=h(e,t),S=h(t,s),x=u(f),E=u(S),M=(se,Ve,Ye,We)=>{const xe=(We-Ve)/(se-Ye),Le=se*xe+Ve;return{x:xe,y:Le}},z=g.y-x*g.x,D=b.y-E*b.x,U=M(x,z,E,D),B=Math.sqrt(Math.pow(e.x-U.x,2)+Math.pow(e.y-U.y,2)),ge=(se,Ve)=>Math.atan2(se.y-Ve.y,se.x-Ve.x),be=ge(e,U),oe=ge(t,U),W=ge(s,U),ce=W>be&&W<oe||be>W&&be<oe||oe>W&&oe<be;this.center=U,this.radius=B,this._clockwise=!ce,this._startAngle=be,this._endAngle=W}createByStartEndPointsAndBulge(e,t,s){let o,h,u;s<0?(o=Math.atan(-s)*4,h=new $e(e),u=new $e(t)):(o=Math.atan(s)*4,h=new $e(t),u=new $e(e));const g=new $e().subVectors(u,h),b=g.length(),f=new $e().addVectors(h,g.multiplyScalar(.5)),S=Math.abs(b/2/Math.tan(o/2)),x=g.normalize();let E;if(o<Math.PI){const M=new $e(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=f.add(M.multiplyScalar(-S))}else{const M=new $e(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=f.add(M.multiplyScalar(S))}s<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=s<0,this.center=E,this.radius=u.sub(E).length()}get center(){return this._center}set center(e){this._center=new Me(e.x,e.y),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(e){this._radius=e,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._clockwise?this._mirrorAngle(this._startAngle):this._startAngle}set startAngle(e){this._startAngle=this._clockwise?this._mirrorAngle(Ee.normalizeAngle(e)):Ee.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._clockwise?this._mirrorAngle(this._endAngle):this._endAngle}set endAngle(e){const t=this.startAngle==0&&e==nt?e:Ee.normalizeAngle(e);this._endAngle=this._clockwise?this._mirrorAngle(t):t,this._boundingBoxNeedsUpdate=!0}_mirrorAngle(e){return(360-e*180/Math.PI)%360*Math.PI/180}_getInternalAngle(e){return this._clockwise?this._mirrorAngle(e):e}get deltaAngle(){const e=this._getInternalAngle(this.startAngle),t=this._getInternalAngle(this.endAngle);return this.clockwise?Ee.normalizeAngle(e-t):Ee.normalizeAngle(t-e)}get clockwise(){return this._clockwise}set clockwise(e){this._clockwise=e,this._boundingBoxNeedsUpdate=!0}get startPoint(){return this.getPointAtAngle(this.startAngle)}get endPoint(){return this.getPointAtAngle(this.endAngle)}get midPoint(){const e=this._getInternalAngle(this.startAngle),t=this._getInternalAngle(this.endAngle),s=Ee.normalizeAngle((e+t)/2),o=this._clockwise?this._mirrorAngle(s):s;return this.getPointAtAngle(o)}get closed(){const e=this._getInternalAngle(this.startAngle),t=this._getInternalAngle(this.endAngle);return Math.abs(t-e)/Math.PI%2==0}calculateBoundingBox(){const e=[this.startPoint,this.endPoint],t=[0,Math.PI/2,Math.PI,3*Math.PI/2];for(const h of t){const u=this._getInternalAngle(h);Ee.isBetweenAngle(u,this._getInternalAngle(this.startAngle),this._getInternalAngle(this.endAngle),this.clockwise)&&e.push(this.getPointAtAngle(h))}const s=e.map(h=>h.x),o=e.map(h=>h.y);return new _t(new Me(Math.min(...s),Math.min(...o)),new Me(Math.max(...s),Math.max(...o)))}get length(){return Math.abs(this.deltaAngle*this.radius)}transform(e){return this._boundingBoxNeedsUpdate=!0,this}clone(){return new Dn(this.center.clone(),this.radius,this._startAngle,this._endAngle,this.clockwise)}getPointAtAngle(e){const t=this._getInternalAngle(e),s=this.center.x+this.radius*Math.cos(t),o=this.center.y+this.radius*Math.sin(t);return new Me(s,o)}getPoints(e=100){const t=[];let s=this.deltaAngle,o=this._getInternalAngle(this.startAngle);if(this.closed&&(s=nt,o=0),this.clockwise)for(let h=0;h<=e;h++){const u=o-s*(h/e),g=this._clockwise?this._mirrorAngle(u):u,b=this.getPointAtAngle(g);t.push(new Me(b.x,b.y))}else for(let h=0;h<=e;h++){const u=o+s*(h/e),g=this._clockwise?this._mirrorAngle(u):u,b=this.getPointAtAngle(g);t.push(new Me(b.x,b.y))}return t}}class Gd extends Xh{translate(e){return this.transform(new fn().makeTranslation(e.x,e.y,e.z))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}class Rs extends Gd{}class qr extends Rs{constructor(e,t){super(),this._start=new $(e),this._end=new $(t)}get startPoint(){return this._start}set startPoint(e){this._start.copy(e),this._boundingBoxNeedsUpdate=!0}get endPoint(){return this._end}set endPoint(e){this._end.copy(e),this._boundingBoxNeedsUpdate=!0}get direction(){return new Z().subVectors(this.endPoint,this.startPoint).normalize()}get midPoint(){return new $((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(e){return this.project(e).distanceTo(e)<1e-6}at(e,t){return this.delta(t).multiplyScalar(e).add(this._start)}atLength(e,t=!1){if(t){const s=this.delta(hn).normalize();return new $(this._start).addScaledVector(s,e)}else{const s=this.delta(hn).normalize();return new $(this._end).addScaledVector(s,e)}}extend(e,t=!1){if(t){const s=hn.subVectors(this._start,this._end).normalize();this._start=new $(this._start).addScaledVector(s,e)}else{const s=this.delta(hn).normalize();this._end=new $(this._end).addScaledVector(s,e)}return this._boundingBoxNeedsUpdate=!0,this}closestPointToPointParameter(e,t){Uo.subVectors(e,this._start),Ws.subVectors(this.endPoint,this.startPoint);const s=Ws.dot(Ws);let o=Ws.dot(Uo)/s;return t&&(o=Ee.clamp(o,0,1)),o}closestPointToPoint(e,t,s){const o=this.closestPointToPointParameter(e,t);return this.delta(s).multiplyScalar(o).add(this._start)}delta(e){return e.subVectors(this._end,this._start)}distanceSq(){return this._start.distanceToSquared(this._end)}distance(){return this._start.distanceTo(this._end)}project(e){const t=this.direction,s=hn.subVectors(e,this.startPoint).dot(t);return new $().copy(t).multiplyScalar(s).add(this.startPoint)}perpPoint(e){const t=this.direction,s=this.startPoint,o=hn.subVectors(e,s).dot(t),h=hn.copy(t).multiplyScalar(o);return new $().addVectors(s,h)}calculateBoundingBox(){const e=new $(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y),Math.min(this._start.z,this._end.z)),t=new $(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 Re(e,t)}transform(e){return this._start.applyMatrix3d(e),this._end.applyMatrix3d(e),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(e){return this.startPoint=e.startPoint,this.endPoint=e.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new qr(this._start.clone(),this._end.clone())}}const hn=new Z,Uo=new Z,Ws=new Z;class pn extends Rs{static computeCenterPoint(e,t,s){const o=new Z().addVectors(e,t).multiplyScalar(.5),h=new Z().addVectors(e,s).multiplyScalar(.5),u=new Z().subVectors(t,e),g=new Z().subVectors(s,e),b=new Z().crossVectors(u,g).normalize();if(b.lengthSq()===0)return console.error("Points are collinear and cannot form a valid arc."),null;const f=new Z().crossVectors(u,b).normalize(),S=new Z().crossVectors(g,b).normalize(),x=f.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),E=S.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),M=new qr(o,o.clone().add(x)),z=new qr(h,h.clone().add(E)),D=new Z;return M.closestPointToPoint(z.startPoint,!0,D)?D:(console.error("Cannot find a valid center for the arc."),null)}static createByThreePoints(e,t,s){const o=pn.computeCenterPoint(e,t,s);if(o){const h=o.distanceTo(e),u=new Z().subVectors(e,o),g=new Z().subVectors(t,o),b=Math.atan2(u.y,u.x),f=Math.atan2(g.y,g.x);return new pn(o,h,b,f,Z.Z_AXIS)}}constructor(e,t,s,o,h,u=Z.X_AXIS){super(),this.center=e,this.radius=t,this.startAngle=s,this.endAngle=o,this.normal=h,this.refVec=u,(o-s)%nt==0?(this.startAngle=0,this.endAngle=nt):(this.startAngle=s,this.endAngle=o)}get center(){return this._center}set center(e){this._center=new $(e.x,e.y,e.z||0),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(e){if(e<0)throw Ut.ILLEGAL_PARAMETERS;this._radius=e,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(e){this._startAngle=Ee.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(e){this._endAngle=this.startAngle==0&&e==nt?e:Ee.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return Ee.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(e){this._normal=new Z(e.x,e.y,e.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get refVec(){return this._refVec}set refVec(e){this._refVec=new Z(e.x,e.y,e.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 e=[this.startAngle,this.endAngle];for(let b=0;b<2*Math.PI;b+=Math.PI/2)Ee.isBetweenAngle(b,this.startAngle,this.endAngle)&&e.push(b);let t=1/0,s=1/0,o=1/0,h=-1/0,u=-1/0,g=-1/0;for(const b of e){const f=this.getPointAtAngle(b);f.x<t&&(t=f.x),f.y<s&&(s=f.y),f.z<o&&(o=f.z),f.x>h&&(h=f.x),f.y>u&&(u=f.y),f.z>g&&(g=f.z)}return new Re({x:t,y:s,z:o},{x:h,y:u,z:g})}get closed(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0}getPoints(e){const t=[];let s=this.deltaAngle,o=this.startAngle;this.closed&&(s=nt,o=0);for(let h=0;h<=e;h++){const u=o+s*(h/e),g=this.getPointAtAngle(u);t.push(g)}return t}transform(e){const t=ia.copy(this.refVec).applyAxisAngle(this.normal,this.startAngle).multiplyScalar(this.radius),s=ia.copy(this.refVec).applyAxisAngle(this.normal,this.endAngle).multiplyScalar(this.radius);return this.center.applyMatrix3d(e),t.applyMatrix3d(e),s.applyMatrix3d(e),this.normal.applyMatrix3d(e).normalize(),this.refVec.applyMatrix3d(e).normalize(),this.startAngle=this.getAngle(t),this.endAngle=this.getAngle(s),this._boundingBoxNeedsUpdate=!0,this}copy(e){return this.center=e.center,this.radius=e.radius,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.normal=e.normal,this.refVec=e.refVec,this._boundingBoxNeedsUpdate=!0,this}clone(){return new pn(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)}getAngle(e){return e.sub(this.center),Math.atan2(e.dot(ia.crossVectors(this.refVec,this.normal)),e.dot(this.refVec))}getPointAtAngle(e){const t=this.normal,s=this.refVec,o={x:t.y*s.z-t.z*s.y,y:t.z*s.x-t.x*s.z,z:t.x*s.y-t.y*s.x},h=this.center,u=this.radius;return new $(h.x+u*(s.x*Math.cos(e)+o.x*Math.sin(e)),h.y+u*(s.y*Math.cos(e)+o.y*Math.sin(e)),h.z+u*(s.z*Math.cos(e)+o.z*Math.sin(e)))}get plane(){const e=new Z(this.center).distanceTo(Pa);return new Ds(this.normal,e)}}const ia=new Z;class Ni extends Vn{constructor(e,t,s,o=0,h=nt,u=!1,g=0){super(),this.center=e,this.majorAxisRadius=t,this.minorAxisRadius=s,(h-o)%nt==0?(this.startAngle=0,this.endAngle=nt):(this.startAngle=o,this.endAngle=h),this.clockwise=u,this.rotation=g}get center(){return this._center}set center(e){this._center=new $(e.x,e.y,e.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(e){if(e<0)throw Ut.ILLEGAL_PARAMETERS;this._majorAxisRadius=e,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(e){if(e<0)throw Ut.ILLEGAL_PARAMETERS;this._minorAxisRadius=e,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(e){this._startAngle=Ee.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(e){this._endAngle=this.startAngle==0&&e==nt?e:Ee.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0}get clockwise(){return this._clockwise}set clockwise(e){this._clockwise=e,this._boundingBoxNeedsUpdate=!0}get rotation(){return this._rotation}set rotation(e){this._rotation=e,this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return Ee.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}calculateBoundingBox(){let e=1/0,t=1/0,s=-1/0,o=-1/0;for(let h=0;h<=100;h++){const u=this.getPoint(h/100);e=Math.min(e,u.x),t=Math.min(t,u.y),s=Math.max(s,u.x),o=Math.max(o,u.y)}return new _t({x:e,y:t},{x:s,y:o})}get closed(){return this.deltaAngle==0}getPoint(e){const t=Math.PI*2;let s=this.endAngle-this.startAngle;const o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=t;for(;s>t;)s-=t;s<Number.EPSILON&&(o?s=0:s=t),this.clockwise===!0&&!o&&(s===t?s=-t:s=s-t);const h=this.startAngle+e*s;let u=this.center.x+this.majorAxisRadius*Math.cos(h),g=this.center.y+this.minorAxisRadius*Math.sin(h);if(this.rotation!==0){const b=Math.cos(this.rotation),f=Math.sin(this.rotation),S=u-this.center.x,x=g-this.center.y;u=S*b-x*f+this.center.x,g=S*f+x*b+this.center.y}return new Me(u,g)}transform(e){return this._boundingBoxNeedsUpdate=!0,this}copy(e){return this.center=e.center,this.majorAxisRadius=e.majorAxisRadius,this.minorAxisRadius=e.minorAxisRadius,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.clockwise=e.clockwise,this.rotation=e.rotation,this}clone(){return new Ni(this.center,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle,this.clockwise,this.rotation)}}class Ci extends Rs{constructor(e,t,s,o,h,u=0,g=nt){super(),this.center=e,this.normal=t,this.majorAxis=s,this.majorAxisRadius=o,this.minorAxisRadius=h;const b=Math.abs(g-u);Math.abs(b-nt)<1e-10||Math.abs(b-2*nt)<1e-10?(this.startAngle=0,this.endAngle=nt):(this.startAngle=u,this.endAngle=g)}get center(){return this._center}set center(e){this._center=new $(e.x,e.y,e.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(e){if(e<0)throw Ut.ILLEGAL_PARAMETERS;this._majorAxisRadius=e,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(e){if(e<0)throw Ut.ILLEGAL_PARAMETERS;this._minorAxisRadius=e,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(e){this._startAngle=Ee.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(e){this._endAngle=this.startAngle==0&&e==nt?e:Ee.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){const e=this.endAngle-this.startAngle;return Math.abs(e-nt)<1e-10?nt:Ee.normalizeAngle(e)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}get clockwise(){return this.deltaAngle<=0}get normal(){return this._normal}set normal(e){this._normal=new Z(e.x,e.y,e.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get majorAxis(){return this._majorAxis}set majorAxis(e){this._majorAxis=new Z(e.x,e.y,e.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 Ia.equal(this.majorAxisRadius,this.minorAxisRadius)}get length(){if(this.isCircular)return this.majorAxisRadius*Math.abs(this.deltaAngle);const e=1e3,t=this.deltaAngle/e;let s=0,o=this.getPointAtAngle(this.startAngle);for(let h=1;h<=e;h++){const u=this.startAngle+h*t,g=this.getPointAtAngle(u),b=g.x-o.x,f=g.y-o.y,S=g.z-o.z;s+=Math.sqrt(b*b+f*f+S*S),o=g}return s}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 e=[this.startAngle,this.endAngle];for(let b=0;b<2*Math.PI;b+=Math.PI/2)Ee.isBetweenAngle(b,this.startAngle,this.endAngle)&&e.push(b);let t=1/0,s=1/0,o=1/0,h=-1/0,u=-1/0,g=-1/0;for(const b of e){const f=this.getPointAtAngle(b);f.x<t&&(t=f.x),f.y<s&&(s=f.y),f.z<o&&(o=f.z),f.x>h&&(h=f.x),f.y>u&&(u=f.y),f.z>g&&(g=f.z)}return new Re({x:t,y:s,z:o},{x:h,y:u,z:g})}else{let e=1/0,t=1/0,s=1/0,o=-1/0,h=-1/0,u=-1/0;for(let g=0;g<=100;g++){const b=this.startAngle+this.deltaAngle*(g/100),f=this.getPointAtAngle(b);e=Math.min(e,f.x),t=Math.min(t,f.y),s=Math.min(s,f.z),o=Math.max(o,f.x),h=Math.max(h,f.y),u=Math.max(u,f.z)}return new Re({x:e,y:t,z:s},{x:o,y:h,z:u})}}get closed(){return this.deltaAngle==0}getPoints(e=100){const t=[];let s=this.deltaAngle,o=this.startAngle;this.closed&&(s=nt,o=0);for(let h=0;h<=e;h++){const u=o+s*(h/e),g=this.getPointAtAngle(u);t.push(g)}return t}getPointAtAngle(e){const t=Math.cos(e),s=Math.sin(e),o=this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(s),h=this.majorAxis.clone().multiplyScalar(t*this.majorAxisRadius).add(o);return new $(this.center.x+h.x,this.center.y+h.y,this.center.z+h.z)}contains(e){const t=new Z(e).sub(this.center),s=t.dot(this.majorAxis),o=t.dot(this.minorAxis),h=s/this.majorAxisRadius,u=o/this.minorAxisRadius;return h*h+u*u<=1}transform(e){return this._boundingBoxNeedsUpdate=!0,this}copy(e){return this.center=e.center,this.normal=e.normal,this.majorAxis=e.majorAxis,this.majorAxisRadius=e.majorAxisRadius,this.minorAxisRadius=e.minorAxisRadius,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this._boundingBoxNeedsUpdate=!0,this}clone(){return new Ci(this.center,this.normal,this.majorAxis,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle)}get plane(){const e=new Z(this.center).distanceTo(Pa);return new Ds(this.normal,e)}}class Bs extends Vn{constructor(e=null,t=!1){super(),this._vertices=e||new Array,this._closed=t}get numberOfVertices(){return this._vertices.length}get closed(){return this._closed}get startPoint(){if(this.numberOfVertices>0){const e=this._vertices[0];return new Me(e.x,e.y)}throw new Error("Start point does not exist in an empty polyline.")}get endPoint(){const e=this.numberOfVertices;if(e>0)if(this.closed){const t=this._vertices[0];return new Me(t.x,t.y)}else{const t=this._vertices[e-1];return new Me(t.x,t.y)}throw new Error("End point does not exist in an empty polyline.")}get length(){let e=0;const t=this._vertices.length;for(let s=0;s<t;++s){const o=this._vertices[s];let h=null;if(s<t-1?h=this._vertices[s+1]:s==t-1&&this.closed&&(h=this._vertices[0]),h)if(o.bulge){const u=new Dn(o,h,o.bulge);e+=u.length}else e+=new Me(o.x,o.y).distanceTo(h)}return e}set closed(e){this._closed=e,this._boundingBoxNeedsUpdate=!0}addVertexAt(e,t){e<=0?this._vertices.unshift(t):this._vertices.splice(e,0,t),this._boundingBoxNeedsUpdate=!0}getPointAt(e){const t=this._vertices[e];return new Me(t.x,t.y)}calculateBoundingBox(){const e=this.getPoints(100);return new _t().setFromPoints(e)}transform(e){return this._boundingBoxNeedsUpdate=!0,this}getPoints3d(e,t){const s=[];return this.getPoints(e).forEach(o=>s.push(new $().set(o.x,o.y,t))),s}getPoints(e){const t=[],s=this._vertices.length;for(let o=0;o<s;++o){const h=this._vertices[o];if(h.bulge){let u=null;if(o<s-1?u=this._vertices[o+1]:o==s-1&&this.closed&&(u=this._vertices[0]),u){const g=new Dn(h,u,h.bulge).getPoints(e),b=g.length;for(let f=0;f<b;++f){const S=g[f];t.push(new Me(S.x,S.y))}}}else t.push(new Me(h.x,h.y)),o==s-1&&this.closed&&t.push(t[0])}return t}}class Li extends Vn{constructor(e,t){super(),this._start=new Me(e),this._end=new Me(t)}get startPoint(){return this._start}set startPoint(e){this._start.copy(e),this._boundingBoxNeedsUpdate=!0}get endPoint(){return this._end}set endPoint(e){this._end.copy(e),this._boundingBoxNeedsUpdate=!0}getPoints(){return[this.startPoint,this.endPoint]}get length(){return this.startPoint.distanceTo(this.endPoint)}calculateBoundingBox(){const e=new Me(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y)),t=new Me(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y));return new _t(e,t)}transform(e){return this._start.applyMatrix2d(e),this._end.applyMatrix2d(e),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(e){return this.startPoint=e.startPoint,this.endPoint=e.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new Li(this._start.clone(),this._end.clone())}}class Kh extends Vn{constructor(e=[]){super(),this._curves=e}get curves(){return this._curves}add(e){this._curves.push(e),this._boundingBoxNeedsUpdate=!0}get numberOfEdges(){return this._curves.length}get startPoint(){if(this._curves.length>0){const e=this._curves[0].startPoint;return new Me(e.x,e.y)}throw new Error("Start point does not exist in an empty loop.")}get endPoint(){return this.startPoint}get length(){let e=0;return this._curves.forEach(t=>{e+=t.length}),e}calculateBoundingBox(){const e=this.getPoints(100),t=new _t;return t.setFromPoints(e),t}transform(e){return this._boundingBoxNeedsUpdate=!0,this}get closed(){return!0}getPoints(e){const t=[];return this.curves.forEach(s=>{s.getPoints(e).forEach(o=>{t.push(new Me(o.x,o.y))})}),t}}function Wd(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var $h={exports:{}};(function(i,e){(function(t){i.exports=t()})(function(){var t={},s=this;new Function("try {return this===window;}catch(e){ return false;}");var o=new Function("try {return this===global;}catch(e){return false;}"),h=new Function("try {return typeof importScripts === 'function';}catch(e){return false;}");if(o()&&h(),o()||h()){var u=s;if(h()){var g=function(b,f){var S=s;return b.split(".").forEach(function(x){S&&(S=S[x])}),S?S[f]:null};onmessage=function(b){if(!(!b.data.className||!b.data.methodName)){var f=g(b.data.className,b.data.methodName);if(!f)return console.error("could not find "+b.data.className+"."+b.data.methodName);postMessage({result:f.apply(null,b.data.args),id:b.data.id})}}}}return function(b,f,S){f.geom=f.geom||{},f.exe=f.exe||{},f.eval=f.eval||{},f.core=f.core||{},f.promhx=f.promhx||{};var x={},E=function(){return Te.__string_rec(this,"")};function M(r,n){function a(){}a.prototype=r;var l=new a;for(var c in n)l[c]=n[c];return n.toString!==Object.prototype.toString&&(l.toString=n.toString),l}var z=function(){};x.HxOverrides=z,z.__name__=["HxOverrides"],z.strDate=function(r){var n=r.length;switch(n){case 8:var a=r.split(":"),l=new Date;return l.setTime(0),l.setUTCHours(a[0]),l.setUTCMinutes(a[1]),l.setUTCSeconds(a[2]),l;case 10:var c=r.split("-");return new Date(c[0],c[1]-1,c[2],0,0,0);case 19:var d=r.split(" "),p=d[0].split("-"),_=d[1].split(":");return new Date(p[0],p[1]-1,p[2],_[0],_[1],_[2]);default:throw new Q("Invalid date format : "+r)}},z.cca=function(r,n){var a=r.charCodeAt(n);if(a==a)return a},z.substr=function(r,n,a){return n!=null&&n!=0&&a!=null&&a<0?"":(a==null&&(a=r.length),n<0?(n=r.length+n,n<0&&(n=0)):a<0&&(a=r.length+a-n),r.substr(n,a))},z.iter=function(r){return{cur:0,arr:r,hasNext:function(){return this.cur<this.arr.length},next:function(){return this.arr[this.cur++]}}};var D=function(){};x.Lambda=D,D.__name__=["Lambda"],D.fold=function(r,n,a){for(var l=Xt(r)();l.hasNext();){var c=l.next();a=n(c,a)}return a};var U=function(){this.length=0};x.List=U,U.__name__=["List"],U.prototype={add:function(r){var n=[r];this.h==null?this.h=n:this.q[1]=n,this.q=n,this.length++},pop:function(){if(this.h==null)return null;var r=this.h[0];return this.h=this.h[1],this.h==null&&(this.q=null),this.length--,r},isEmpty:function(){return this.h==null},__class__:U},Math.__name__=["Math"];var B=function(){};x.Reflect=B,B.__name__=["Reflect"],B.field=function(r,n){try{return r[n]}catch(a){return a instanceof Q&&(a=a.val),null}},B.callMethod=function(r,n,a){return n.apply(r,a)},B.fields=function(r){var n=[];if(r!=null){var a=Object.prototype.hasOwnProperty;for(var l in r)l!="__id__"&&l!="hx__closures__"&&a.call(r,l)&&n.push(l)}return n},B.isFunction=function(r){return typeof r=="function"&&!(r.__name__||r.__ename__)},B.deleteField=function(r,n){return Object.prototype.hasOwnProperty.call(r,n)?(delete r[n],!0):!1};var ge=function(){};x.Std=ge,ge.__name__=["Std"],ge.string=function(r){return Te.__string_rec(r,"")},ge.parseFloat=function(r){return parseFloat(r)};var be=function(){this.b=""};x.StringBuf=be,be.__name__=["StringBuf"],be.prototype={add:function(r){this.b+=ge.string(r)},__class__:be};var oe=function(){};x.StringTools=oe,oe.__name__=["StringTools"],oe.fastCodeAt=function(r,n){return r.charCodeAt(n)};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(r){var n=["TClass",6,r];return n.__enum__=W,n.toString=E,n},W.TEnum=function(r){var n=["TEnum",7,r];return n.__enum__=W,n.toString=E,n},W.TUnknown=["TUnknown",8],W.TUnknown.toString=E,W.TUnknown.__enum__=W;var ce=function(){};x.Type=ce,ce.__name__=["Type"],ce.getClassName=function(r){var n=r.__name__;return n==null?null:n.join(".")},ce.getEnumName=function(r){var n=r.__ename__;return n.join(".")},ce.resolveClass=function(r){var n=x[r];return n==null||!n.__name__?null:n},ce.resolveEnum=function(r){var n=x[r];return n==null||!n.__ename__?null:n},ce.createEmptyInstance=function(r){function n(){}return n.prototype=r.prototype,new n},ce.createEnum=function(r,n,a){var l=B.field(r,n);if(l==null)throw new Q("No such constructor "+n);if(B.isFunction(l)){if(a==null)throw new Q("Constructor "+n+" need parameters");return B.callMethod(r,l,a)}if(a!=null&&a.length!=0)throw new Q("Constructor "+n+" does not need parameters");return l},ce.getEnumConstructs=function(r){var n=r.__constructs__;return n.slice()},ce.typeof=function(r){var n=typeof r;switch(n){case"boolean":return W.TBool;case"string":return W.TClass(String);case"number":return Math.ceil(r)==r%2147483648?W.TInt:W.TFloat;case"object":if(r==null)return W.TNull;var a=r.__enum__;if(a!=null)return W.TEnum(a);var l=Te.getClass(r);return l!=null?W.TClass(l):W.TObject;case"function":return r.__name__||r.__ename__?W.TObject:W.TFunction;case"undefined":return W.TNull;default:return W.TUnknown}};var se=function(){};x["haxe.IMap"]=se,se.__name__=["haxe","IMap"];var Ve=function(r,n){this.high=r,this.low=n};x["haxe._Int64.___Int64"]=Ve,Ve.__name__=["haxe","_Int64","___Int64"],Ve.prototype={__class__:Ve};var Ye=function(){this.buf=new be,this.cache=[],this.useCache=Ye.USE_CACHE,this.useEnumIndex=Ye.USE_ENUM_INDEX,this.shash=new mt,this.scount=0};x["haxe.Serializer"]=Ye,Ye.__name__=["haxe","Serializer"],Ye.prototype={toString:function(){return this.buf.b},serializeString:function(r){var n=this.shash.get(r);if(n!=null){this.buf.b+="R",n==null?this.buf.b+="null":this.buf.b+=""+n;return}this.shash.set(r,this.scount++),this.buf.b+="y",r=encodeURIComponent(r),r.length==null?this.buf.b+="null":this.buf.b+=""+r.length,this.buf.b+=":",r==null?this.buf.b+="null":this.buf.b+=""+r},serializeRef:function(r){for(var n=typeof r,a=0,l=this.cache.length;a<l;){var c=a++,d=this.cache[c];if(typeof d==n&&d==r)return this.buf.b+="r",c==null?this.buf.b+="null":this.buf.b+=""+c,!0}return this.cache.push(r),!1},serializeFields:function(r){for(var n=0,a=B.fields(r);n<a.length;){var l=a[n];++n,this.serializeString(l),this.serialize(B.field(r,l))}this.buf.b+="g"},serialize:function(r){{var n=ce.typeof(r);switch(n[1]){case 0:this.buf.b+="n";break;case 1:var a=r;if(a==0){this.buf.b+="z";return}this.buf.b+="i",a==null?this.buf.b+="null":this.buf.b+=""+a;break;case 2:var l=r;isNaN(l)?this.buf.b+="k":isFinite(l)?(this.buf.b+="d",l==null?this.buf.b+="null":this.buf.b+=""+l):l<0?this.buf.b+="m":this.buf.b+="p";break;case 3:r?this.buf.b+="t":this.buf.b+="f";break;case 6:var c=n[2];if(c==String){this.serializeString(r);return}if(this.useCache&&this.serializeRef(r))return;switch(c){case Array:var d=0;this.buf.b+="a";for(var p=r.length,_=0;_<p;){var v=_++;r[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(r[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 U:this.buf.b+="l";for(var w=r,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 k=r;this.buf.b+="v",this.buf.add(k.getTime());break;case mt:this.buf.b+="b";for(var T=r,L=T.keys();L.hasNext();){var C=L.next();this.serializeString(C),this.serialize(Ui[C]!=null?T.getReserved(C):T.h[C])}this.buf.b+="h";break;case xe:this.buf.b+="q";for(var R=r,O=R.keys();O.hasNext();){var F=O.next();this.buf.b+=":",F==null?this.buf.b+="null":this.buf.b+=""+F,this.serialize(R.h[F])}this.buf.b+="h";break;case Le:this.buf.b+="M";for(var V=r,q=V.keys();q.hasNext();){var J=q.next(),H=B.field(J,"__id__");B.deleteField(J,"__id__"),this.serialize(J),J.__id__=H,this.serialize(V.h[J.__id__])}this.buf.b+="h";break;case It:for(var j=r,X=0,ee=j.length-2,te=new be,ie=Ye.BASE64;X<ee;){var he=j.get(X++),ae=j.get(X++),ue=j.get(X++);te.add(ie.charAt(he>>2)),te.add(ie.charAt((he<<4|ae>>4)&63)),te.add(ie.charAt((ae<<2|ue>>6)&63)),te.add(ie.charAt(ue&63))}if(X==ee){var ne=j.get(X++),de=j.get(X++);te.add(ie.charAt(ne>>2)),te.add(ie.charAt((ne<<4|de>>4)&63)),te.add(ie.charAt(de<<2&63))}else if(X==ee+1){var Y=j.get(X++);te.add(ie.charAt(Y>>2)),te.add(ie.charAt(Y<<4&63))}var pe=te.b;this.buf.b+="s",pe.length==null?this.buf.b+="null":this.buf.b+=""+pe.length,this.buf.b+=":",pe==null?this.buf.b+="null":this.buf.b+=""+pe;break;default:this.useCache&&this.cache.pop(),r.hxSerialize!=null?(this.buf.b+="C",this.serializeString(ce.getClassName(c)),this.useCache&&this.cache.push(r),r.hxSerialize(this),this.buf.b+="g"):(this.buf.b+="c",this.serializeString(ce.getClassName(c)),this.useCache&&this.cache.push(r),this.serializeFields(r))}break;case 4:if(Te.__instanceof(r,po)){var Pe=ce.getClassName(r);this.buf.b+="A",this.serializeString(Pe)}else if(Te.__instanceof(r,go))this.buf.b+="B",this.serializeString(ce.getEnumName(r));else{if(this.useCache&&this.serializeRef(r))return;this.buf.b+="o",this.serializeFields(r)}break;case 7:var Ge=n[2];if(this.useCache){if(this.serializeRef(r))return;this.cache.pop()}this.useEnumIndex?this.buf.b+="j":this.buf.b+="w",this.serializeString(ce.getEnumName(Ge)),this.useEnumIndex?(this.buf.b+=":",this.buf.b+=ge.string(r[1])):this.serializeString(r[0]),this.buf.b+=":";var Xe=r.length;this.buf.b+=ge.string(Xe-2);for(var Fe=2;Fe<Xe;){var Ke=Fe++;this.serialize(r[Ke])}this.useCache&&this.cache.push(r);break;case 5:throw new Q("Cannot serialize function");default:throw new Q("Cannot serialize "+ge.string(r))}}},__class__:Ye};var We=function(r){this.buf=r,this.length=r.length,this.pos=0,this.scache=[],this.cache=[];var n=We.DEFAULT_RESOLVER;n==null&&(n=ce,We.DEFAULT_RESOLVER=n),this.setResolver(n)};x["haxe.Unserializer"]=We,We.__name__=["haxe","Unserializer"],We.initCodes=function(){for(var r=[],n=0,a=We.BASE64.length;n<a;){var l=n++;r[We.BASE64.charCodeAt(l)]=l}return r},We.prototype={setResolver:function(r){r==null?this.resolver={resolveClass:function(n){return null},resolveEnum:function(n){return null}}:this.resolver=r},get:function(r){return this.buf.charCodeAt(r)},readDigits:function(){for(var r=0,n=!1,a=this.pos;;){var l=this.buf.charCodeAt(this.pos);if(l!=l)break;if(l==45){if(this.pos!=a)break;n=!0,this.pos++;continue}if(l<48||l>57)break;r=r*10+(l-48),this.pos++}return n&&(r*=-1),r},readFloat:function(){for(var r=this.pos;;){var n=this.buf.charCodeAt(this.pos);if(n>=43&&n<58||n==101||n==69)this.pos++;else break}return ge.parseFloat(z.substr(this.buf,r,this.pos-r))},unserializeObject:function(r){for(;;){if(this.pos>=this.length)throw new Q("Invalid object");if(this.buf.charCodeAt(this.pos)==103)break;var n=this.unserialize();if(typeof n!="string")throw new Q("Invalid object key");var a=this.unserialize();r[n]=a}this.pos++},unserializeEnum:function(r,n){if(this.get(this.pos++)!=58)throw new Q("Invalid enum format");var a=this.readDigits();if(a==0)return ce.createEnum(r,n);for(var l=[];a-- >0;)l.push(this.unserialize());return ce.createEnum(r,n,l)},unserialize:function(){var r=this.get(this.pos++);switch(r){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 n=this.readDigits();if(this.get(this.pos++)!=58||this.length-this.pos<n)throw new Q("Invalid string length");var a=z.substr(this.buf,this.pos,n);return this.pos+=n,a=decodeURIComponent(a.split("+").join(" ")),this.scache.push(a),a;case 107:return NaN;case 109:return-1/0;case 112:return 1/0;case 97:this.buf;var l=[];for(this.cache.push(l);;){var c=this.buf.charCodeAt(this.pos);if(c==104){this.pos++;break}if(c==117){this.pos++;var d=this.readDigits();l[l.length+d-1]=null}else l.push(this.unserialize())}return l;case 111:var p={};return this.cache.push(p),this.unserializeObject(p),p;case 114:var _=this.readDigits();if(_<0||_>=this.cache.length)throw new Q("Invalid reference");return this.cache[_];case 82:var v=this.readDigits();if(v<0||v>=this.scache.length)throw new Q("Invalid string reference");return this.scache[v];case 120:throw new Q(this.unserialize());case 99:var w=this.unserialize(),P=this.resolver.resolveClass(w);if(P==null)throw new Q("Class not found "+w);var A=ce.createEmptyInstance(P);return this.cache.push(A),this.unserializeObject(A),A;case 119:var I=this.unserialize(),k=this.resolver.resolveEnum(I);if(k==null)throw new Q("Enum not found "+I);var T=this.unserializeEnum(k,this.unserialize());return this.cache.push(T),T;case 106:var L=this.unserialize(),C=this.resolver.resolveEnum(L);if(C==null)throw new Q("Enum not found "+L);this.pos++;var R=this.readDigits(),O=ce.getEnumConstructs(C)[R];if(O==null)throw new Q("Unknown enum index "+L+"@"+R);var F=this.unserializeEnum(C,O);return this.cache.push(F),F;case 108:var V=new U;for(this.cache.push(V),this.buf;this.buf.charCodeAt(this.pos)!=104;)V.add(this.unserialize());return this.pos++,V;case 98:var q=new mt;for(this.cache.push(q),this.buf;this.buf.charCodeAt(this.pos)!=104;){var J=this.unserialize();q.set(J,this.unserialize())}return this.pos++,q;case 113:var H=new xe;this.cache.push(H),this.buf;for(var j=this.get(this.pos++);j==58;){var X=this.readDigits();H.set(X,this.unserialize()),j=this.get(this.pos++)}if(j!=104)throw new Q("Invalid IntMap format");return H;case 77:var ee=new Le;for(this.cache.push(ee),this.buf;this.buf.charCodeAt(this.pos)!=104;){var te=this.unserialize();ee.set(te,this.unserialize())}return this.pos++,ee;case 118:var ie;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 he=z.substr(this.buf,this.pos,19);ie=z.strDate(he),this.pos+=19}else{var ae=this.readFloat(),ue=new Date;ue.setTime(ae),ie=ue}return this.cache.push(ie),ie;case 115:var ne=this.readDigits(),de=this.buf;if(this.get(this.pos++)!=58||this.length-this.pos<ne)throw new Q("Invalid bytes length");var Y=We.CODES;Y==null&&(Y=We.initCodes(),We.CODES=Y);var pe=this.pos,Pe=ne&3,Ge;Ge=(ne>>2)*3+(Pe>=2?Pe-1:0);for(var Xe=pe+(ne-Pe),Fe=It.alloc(Ge),Ke=0;pe<Xe;){var At=Y[oe.fastCodeAt(de,pe++)],Wt=Y[oe.fastCodeAt(de,pe++)];Fe.set(Ke++,At<<2|Wt>>4);var vt=Y[oe.fastCodeAt(de,pe++)];Fe.set(Ke++,Wt<<4|vt>>2);var gt=Y[oe.fastCodeAt(de,pe++)];Fe.set(Ke++,vt<<6|gt)}if(Pe>=2){var St=Y[oe.fastCodeAt(de,pe++)],Tt=Y[oe.fastCodeAt(de,pe++)];if(Fe.set(Ke++,St<<2|Tt>>4),Pe==3){var Kt=Y[oe.fastCodeAt(de,pe++)];Fe.set(Ke++,Tt<<4|Kt>>2)}}return this.pos+=ne,this.cache.push(Fe),Fe;case 67:var or=this.unserialize(),$t=this.resolver.resolveClass(or);if($t==null)throw new Q("Class not found "+or);var Zt=ce.createEmptyInstance($t);if(this.cache.push(Zt),Zt.hxUnserialize(this),this.get(this.pos++)!=103)throw new Q("Invalid custom data");return Zt;case 65:var Qt=this.unserialize(),dr=this.resolver.resolveClass(Qt);if(dr==null)throw new Q("Class not found "+Qt);return dr;case 66:var Tn=this.unserialize(),Zr=this.resolver.resolveEnum(Tn);if(Zr==null)throw new Q("Enum not found "+Tn);return Zr}throw this.pos--,new Q("Invalid char "+this.buf.charAt(this.pos)+" at position "+this.pos)},__class__:We};var xe=function(){this.h={}};x["haxe.ds.IntMap"]=xe,xe.__name__=["haxe","ds","IntMap"],xe.__interfaces__=[se],xe.prototype={set:function(r,n){this.h[r]=n},remove:function(r){return this.h.hasOwnProperty(r)?(delete this.h[r],!0):!1},keys:function(){var r=[];for(var n in this.h)this.h.hasOwnProperty(n)&&r.push(n|0);return z.iter(r)},__class__:xe};var Le=function(){this.h={},this.h.__keys__={}};x["haxe.ds.ObjectMap"]=Le,Le.__name__=["haxe","ds","ObjectMap"],Le.__interfaces__=[se],Le.prototype={set:function(r,n){var a=r.__id__||(r.__id__=++Le.count);this.h[a]=n,this.h.__keys__[a]=r},keys:function(){var r=[];for(var n in this.h.__keys__)this.h.hasOwnProperty(n)&&r.push(this.h.__keys__[n]);return z.iter(r)},__class__:Le};var dt=x["haxe.ds.Option"]={__ename__:["haxe","ds","Option"],__constructs__:["Some","None"]};dt.Some=function(r){var n=["Some",0,r];return n.__enum__=dt,n.toString=E,n},dt.None=["None",1],dt.None.toString=E,dt.None.__enum__=dt;var mt=function(){this.h={}};x["haxe.ds.StringMap"]=mt,mt.__name__=["haxe","ds","StringMap"],mt.__interfaces__=[se],mt.prototype={set:function(r,n){Ui[r]!=null?this.setReserved(r,n):this.h[r]=n},get:function(r){return Ui[r]!=null?this.getReserved(r):this.h[r]},setReserved:function(r,n){this.rh==null&&(this.rh={}),this.rh["$"+r]=n},getReserved:function(r){return this.rh==null?null:this.rh["$"+r]},keys:function(){var r=this.arrayKeys();return z.iter(r)},arrayKeys:function(){var r=[];for(var n in this.h)this.h.hasOwnProperty(n)&&r.push(n);if(this.rh!=null)for(var n in this.rh)n.charCodeAt(0)==36&&r.push(n.substr(1));return r},__class__:mt};var It=function(r){this.length=r.byteLength,this.b=new Vi(r),this.b.bufferValue=r,r.hxBytes=this,r.bytes=this.b};x["haxe.io.Bytes"]=It,It.__name__=["haxe","io","Bytes"],It.alloc=function(r){return new It(new Vs(r))},It.prototype={get:function(r){return this.b[r]},set:function(r,n){this.b[r]=n&255},__class__:It};var Je=x["haxe.io.Error"]={__ename__:["haxe","io","Error"],__constructs__:["Blocked","Overflow","OutsideBounds","Custom"]};Je.Blocked=["Blocked",0],Je.Blocked.toString=E,Je.Blocked.__enum__=Je,Je.Overflow=["Overflow",1],Je.Overflow.toString=E,Je.Overflow.__enum__=Je,Je.OutsideBounds=["OutsideBounds",2],Je.OutsideBounds.toString=E,Je.OutsideBounds.__enum__=Je,Je.Custom=function(r){var n=["Custom",3,r];return n.__enum__=Je,n.toString=E,n};var at=function(){};x["haxe.io.FPHelper"]=at,at.__name__=["haxe","io","FPHelper"],at.i32ToFloat=function(r){var n=1-(r>>>31<<1),a=r>>>23&255,l=r&8388607;return l==0&&a==0?0:n*(1+Math.pow(2,-23)*l)*Math.pow(2,a-127)},at.floatToI32=function(r){if(r==0)return 0;var n;r<0?n=-r:n=r;var a=Math.floor(Math.log(n)/.6931471805599453);a<-127?a=-127:a>128&&(a=128);var l=Math.round((n/Math.pow(2,a)-1)*8388608)&8388607;return(r<0?-2147483648:0)|a+127<<23|l},at.i64ToDouble=function(r,n){var a=1-(n>>>31<<1),l=(n>>20&2047)-1023,c=(n&1048575)*4294967296+(r>>>31)*2147483648+(r&2147483647);return c==0&&l==-1023?0:a*(1+Math.pow(2,-52)*c)*Math.pow(2,l)},at.doubleToI64=function(r){var n=at.i64tmp;if(r==0)n.low=0,n.high=0;else{var a;r<0?a=-r:a=r;var l=Math.floor(Math.log(a)/.6931471805599453),c,d=(a/Math.pow(2,l)-1)*4503599627370496;c=Math.round(d);var p=c|0,_=c/4294967296|0;n.low=p,n.high=(r<0?-2147483648:0)|l+1023<<20|_}return n};var Q=function(r){Error.call(this),this.val=r,this.message=String(r),Error.captureStackTrace&&Error.captureStackTrace(this,Q)};x["js._Boot.HaxeError"]=Q,Q.__name__=["js","_Boot","HaxeError"],Q.__super__=Error,Q.prototype=M(Error.prototype,{__class__:Q});var Te=function(){};x["js.Boot"]=Te,Te.__name__=["js","Boot"],Te.getClass=function(r){if(r instanceof Array&&r.__enum__==null)return Array;var n=r.__class__;if(n!=null)return n;var a=Te.__nativeClassName(r);return a!=null?Te.__resolveNativeClass(a):null},Te.__string_rec=function(r,n){if(r==null)return"null";if(n.length>=5)return"<...>";var a=typeof r;switch(a=="function"&&(r.__name__||r.__ename__)&&(a="object"),a){case"object":if(r instanceof Array){if(r.__enum__){if(r.length==2)return r[0];var l=r[0]+"(";n+=" ";for(var c=2,d=r.length;c<d;){var p=c++;p!=2?l+=","+Te.__string_rec(r[p],n):l+=Te.__string_rec(r[p],n)}return l+")"}var _=r.length,v="[";n+=" ";for(var w=0;w<_;){var P=w++;v+=(P>0?",":"")+Te.__string_rec(r[P],n)}return v+="]",v}var A;try{A=r.toString}catch(C){return C instanceof Q&&(C=C.val),"???"}if(A!=null&&A!=Object.toString&&typeof A=="function"){var I=r.toString();if(I!="[object Object]")return I}var k=null,T=`{
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function Wc(i,e){for(var t=0;t<e.length;t++){const s=e[t];if(typeof s!="string"&&!Array.isArray(s)){for(const o in s)if(o!=="default"&&!(o in i)){const h=Object.getOwnPropertyDescriptor(s,o);h&&Object.defineProperty(i,o,h.get?h:{enumerable:!0,get:()=>s[o]})}}}return Object.freeze(Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}))}const Ys={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},Yi=[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 hs(i,e,t){return Math.max(e,Math.min(t,i))}const Yo=class Xo{constructor(){this._colorIndex=256,this._color=null,this._colorName=null}get color(){return this._color}set color(e){e==null?this._color=null:(this._color=Math.round(hs(e,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 e=this._color.toString(16).toUpperCase();for(;e.length<6;)e="0"+e;return`0x${e}`}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(e){e==null?this._colorIndex=null:(this._colorIndex=hs(e,0,256),this._colorIndex>0&&this._colorIndex<256?(this._color=Yi[e],this._colorName=this.getColorNameByValue(this._color)):(this._color=null,this._colorName=null))}get colorName(){return this._colorName}set colorName(e){if(e){const t=Ys[e.toLowerCase()];t!==void 0?(this._colorName=e,this._color=t,this._colorIndex=this.getColorIndexByValue(this._color)):console.warn("Unknown color: "+e)}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(e){return this.setRGB(e,e,e),this}setRGB(e,t,s){const o=Math.round(hs(e,0,255)),h=Math.round(hs(t,0,255)),u=Math.round(hs(s,0,255));return this.color=(o<<16)+(h<<8)+u,this}setColorName(e){const t=Ys[e.toLowerCase()];return t!==void 0?this.color=t:console.warn("Unknown color "+e),this}clone(){const e=new Xo;return e.colorIndex=this.colorIndex,e.color=this.color,e._colorName=this._colorName,this}copy(e){return this.colorIndex=e.colorIndex,this.color=e.color,this._colorName=e._colorName,this}equals(e){return e.color==this.color&&e.colorIndex==this.colorIndex&&e._colorName==this._colorName}toString(){return this.isByLayer?"ByLayer":this.isByBlock?"ByBlock":this.colorName?this.colorName:this.hexColor}getColorNameByValue(e){for(const[t,s]of Object.entries(Ys))if(s===e)return t;return null}getColorIndexByValue(e){const t=Yi.length-1;for(let s=1;s<t;++s)if(Yi[s]===e)return s;return null}};Yo.NAMES=Ys;let Wr=Yo;const Ut={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")}};let Hc=class{constructor(){this._listeners={}}addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const s=this._listeners;s[e]===void 0&&(s[e]=[]),s[e].indexOf(t)===-1&&s[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const s=this._listeners;return s[e]!==void 0&&s[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const s=this._listeners[e];if(s!==void 0){const o=s.indexOf(t);o!==-1&&s.splice(o,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const t=this._listeners[e.type];if(t!==void 0){e.target=this;const s=t.slice(0);for(let o=0,h=s.length;o<h;o++)s[o].call(this,e)}}},it=class{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}removeEventListener(e){this.listeners=this.listeners.filter(t=>t!==e)}replaceEventListener(e){this.removeEventListener(e),this.addEventListener(e)}dispatch(e,...t){for(const s of this.listeners)s.call(null,e,...t)}};var qc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Yc(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Ko={exports:{}};(function(i){(function(e,t){i.exports?i.exports=t():e.log=t()})(qc,function(){var e=function(){},t="undefined",s=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),o=["trace","debug","info","warn","error"],h={},u=null;function g(D,U){var B=D[U];if(typeof B.bind=="function")return B.bind(D);try{return Function.prototype.bind.call(B,D)}catch{return function(){return Function.prototype.apply.apply(B,[D,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 f(D){return D==="debug"&&(D="log"),typeof console===t?!1:D==="trace"&&s?b:console[D]!==void 0?g(console,D):console.log!==void 0?g(console,"log"):e}function S(){for(var D=this.getLevel(),U=0;U<o.length;U++){var B=o[U];this[B]=U<D?e:this.methodFactory(B,D,this.name)}if(this.log=this.debug,typeof console===t&&D<this.levels.SILENT)return"No console available for logging"}function x(D){return function(){typeof console!==t&&(S.call(this),this[D].apply(this,arguments))}}function E(D,U,B){return f(D)||x.apply(this,arguments)}function M(D,U){var B=this,ge,be,oe,W="loglevel";typeof D=="string"?W+=":"+D:typeof D=="symbol"&&(W=void 0);function ce(xe){var Le=(o[xe]||"silent").toUpperCase();if(!(typeof window===t||!W)){try{window.localStorage[W]=Le;return}catch{}try{window.document.cookie=encodeURIComponent(W)+"="+Le+";"}catch{}}}function se(){var xe;if(!(typeof window===t||!W)){try{xe=window.localStorage[W]}catch{}if(typeof xe===t)try{var Le=window.document.cookie,dt=encodeURIComponent(W),mt=Le.indexOf(dt+"=");mt!==-1&&(xe=/^([^;]+)/.exec(Le.slice(mt+dt.length+1))[1])}catch{}return B.levels[xe]===void 0&&(xe=void 0),xe}}function Ve(){if(!(typeof window===t||!W)){try{window.localStorage.removeItem(W)}catch{}try{window.document.cookie=encodeURIComponent(W)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function Ye(xe){var Le=xe;if(typeof Le=="string"&&B.levels[Le.toUpperCase()]!==void 0&&(Le=B.levels[Le.toUpperCase()]),typeof Le=="number"&&Le>=0&&Le<=B.levels.SILENT)return Le;throw new TypeError("log.setLevel() called with invalid level: "+xe)}B.name=D,B.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},B.methodFactory=U||E,B.getLevel=function(){return oe??be??ge},B.setLevel=function(xe,Le){return oe=Ye(xe),Le!==!1&&ce(oe),S.call(B)},B.setDefaultLevel=function(xe){be=Ye(xe),se()||B.setLevel(xe,!1)},B.resetLevel=function(){oe=null,Ve(),S.call(B)},B.enableAll=function(xe){B.setLevel(B.levels.TRACE,xe)},B.disableAll=function(xe){B.setLevel(B.levels.SILENT,xe)},B.rebuild=function(){if(u!==B&&(ge=Ye(u.getLevel())),S.call(B),u===B)for(var xe in h)h[xe].rebuild()},ge=Ye(u?u.getLevel():"WARN");var We=se();We!=null&&(oe=Ye(We)),S.call(B)}u=new M,u.getLogger=function(D){if(typeof D!="symbol"&&typeof D!="string"||D==="")throw new TypeError("You must supply a name when creating a logger.");var U=h[D];return U||(U=h[D]=new M(D,u.methodFactory)),U};var z=typeof window!==t?window.log:void 0;return u.noConflict=function(){return typeof window!==t&&window.log===u&&(window.log=z),u},u.getLoggers=function(){return h},u.default=u,u})})(Ko);var $o=Ko.exports;const Xc=Yc($o),Kc=Wc({__proto__:null,default:Xc},[$o]),$c=!0,ks=Kc;ks.setLevel("debug");const Zc=i=>{try{ks.setLevel(i)}catch(e){ks.setLevel("error"),ks.error(e)}};function Is(i){return i===null||typeof i!="object"?i:Array.isArray(i)?[...i]:{...i}}function Fn(i,...e){for(const t of e)if(t)for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&i[s]===void 0&&(i[s]=t[s]);return i}function Zo(i,e){return i!=null&&Object.prototype.hasOwnProperty.call(i,e)}function Qo(i){return i==null?!0:Array.isArray(i)||typeof i=="string"?i.length===0:i instanceof Map||i instanceof Set?i.size===0:typeof i=="object"?Object.keys(i).length===0:!1}function zn(i,e){if(i===e)return!0;if(i==null||e==null)return i===e;if(typeof i!=typeof e)return!1;if(typeof i!="object")return i===e;if(Array.isArray(i)!==Array.isArray(e))return!1;if(Array.isArray(i)){if(i.length!==e.length)return!1;for(let o=0;o<i.length;o++)if(!zn(i[o],e[o]))return!1;return!0}const t=Object.keys(i),s=Object.keys(e);if(t.length!==s.length)return!1;for(const o of t)if(!Object.prototype.hasOwnProperty.call(e,o)||!zn(i[o],e[o]))return!1;return!0}let Jo=class el{constructor(e,t){this.events={attrChanged:new it,modelChanged:new it},this._changing=!1,this._previousAttributes={},this._pending=!1;const s=e||{};t&&Fn(s,t),this.attributes=s,this.changed={}}get(e){return this.attributes[e]}set(e,t,s){if(e==null)return this;let o;typeof e=="object"?(o=e,s=t):(o={},o[e]=t),s||(s={});const h=s.unset,u=s.silent,g=[],b=this._changing;this._changing=!0,b||(this._previousAttributes=Is(this.attributes),this.changed={});const f=this.attributes,S=this.changed,x=this._previousAttributes;for(const E in o)t=o[E],zn(f[E],t)||g.push(E),zn(x[E],t)?delete S[E]:S[E]=t,h?delete f[E]:f[E]=t;if(!u){g.length&&(this._pending=s);for(let E=0;E<g.length;E++)this.events.attrChanged.dispatch({object:this,attrName:g[E],attrValue:f[g[E]],options:s})}if(b)return this;if(!u)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(e){return this.get(e)!=null}hasChanged(e){return e==null?!Qo(this.changed):Zo(this.changed,e)}changedAttributes(e){if(!e)return this.hasChanged()?Is(this.changed):{};const t=this._changing?this._previousAttributes:this.attributes,s={};for(const o in e){const h=e[o];zn(t[o],h)||(s[o]=h)}return s}previous(e){return e==null||!this._previousAttributes?null:this._previousAttributes[e]}previousAttributes(){return Is(this._previousAttributes)}clone(){const e=Is(this.attributes);return new el(e)}},pa=class Es{constructor(){this.entries=new Map}static getInstance(){return Es.instance||(Es.instance=new Es),Es.instance}collect(e){this.entries.set(e.name,e)}printAll(){for(const[e,t]of this.entries)console.log(`${e}:`),console.log(t.format())}clear(){this.entries.clear()}getAll(){return Array.from(this.entries.values())}getEntry(e){return this.entries.get(e)}remove(e){return this.entries.delete(e)}};class Qc{static formatBytes(e,t=2){if(e===0)return"0 B";const s=1024,o=Math.max(0,t),h=["B","KB","MB","GB","TB"],u=Math.floor(Math.log(e)/Math.log(s)),g=e/Math.pow(s,u);return`${parseFloat(g.toFixed(o))} ${h[u]}`}}class tl{constructor(e){this.name=e}run(e){throw new Error("run() must be implemented by subclass")}}class rl{constructor(){this.tasks=[],this.onProgress=()=>{},this.onComplete=()=>{},this.onError=()=>{}}scheduleTask(e){return new Promise((t,s)=>{const o=()=>{Promise.resolve(e()).then(t).catch(s)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(o):setTimeout(o,0)})}addTask(e){this.tasks.push(e)}setProgressCallback(e){this.onProgress=e}setCompleteCallback(e){this.onComplete=e}setErrorCallback(e){this.onError=e}async run(e){const t=this.tasks.length;let s=e;for(let o=0;o<t;o++){const h=this.tasks[o];try{s=await this.scheduleTask(async()=>{const u=await h.run(s);return this.onProgress((o+1)/t,h),u})}catch(u){this.onError({error:u,taskIndex:o,task:h});return}}this.onComplete(s)}}let nl=class{constructor(e,t,s){this.isLoading=!1,this.itemsLoaded=0,this.itemsTotal=0,this.urlModifier=void 0,this.handlers=[],this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=s}itemStart(e){this.itemsTotal++,this.isLoading===!1&&this.onStart!==void 0&&this.onStart(e,this.itemsLoaded,this.itemsTotal),this.isLoading=!0}itemEnd(e){this.itemsLoaded++,this.onProgress!==void 0&&this.onProgress(e,this.itemsLoaded,this.itemsTotal),this.itemsLoaded===this.itemsTotal&&(this.isLoading=!1,this.onLoad!==void 0&&this.onLoad())}itemError(e){this.onError!==void 0&&this.onError(e)}resolveURL(e){return this.urlModifier?this.urlModifier(e):e}setURLModifier(e){return this.urlModifier=e,this}addHandler(e,t){return this.handlers.push(e,t),this}removeHandler(e){const t=this.handlers.indexOf(e);return t!==-1&&this.handlers.splice(t,2),this}getHandler(e){for(let t=0,s=this.handlers.length;t<s;t+=2){const o=this.handlers[t],h=this.handlers[t+1];if(o.global&&(o.lastIndex=0),o.test(e))return h}return null}};const sl=new nl;let Jc=class{constructor(e){this.manager=e!==void 0?e:sl,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}loadAsync(e,t){return new Promise((s,o)=>{this.load(e,s,t,o)})}parse(e){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}};class il{constructor(e,t,s){this._chunkSize=-1,this._minimumChunkSize=50,this._count=e,this._numerOfChunk=t<1?1:t,this._minimumChunkSize=s,this.calculateChunkSize()}get count(){return this._count}get numerOfChunk(){return this._numerOfChunk}get minimumChunkSize(){return this._minimumChunkSize}set minimumChunkSize(e){this._minimumChunkSize=e,this.calculateChunkSize()}get chunkSize(){return this._chunkSize}calculateChunkSize(){let e=this._count/this._numerOfChunk;e<this._minimumChunkSize&&(e=Math.min(this._minimumChunkSize,this._count)),this._chunkSize=e<1?this._count:Math.floor(e)}scheduleTask(e){return new Promise((t,s)=>{const o=()=>{Promise.resolve(e()).then(t).catch(s)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(o):setTimeout(o,0)})}async processChunk(e){let t=0;const s=async()=>{const o=t,h=Math.min(t+this._chunkSize,this._count);await e(o,h),t=h,t<this._count&&await this.scheduleTask(s)};await s()}}var ht,cs,Qe,st,us,Jt,yt,pr,er,en,ds,ms,tn,rn,ps,gs,fs,Nt,gr,qe,nn,_s,_e,bt,vs,xt,ys,fr,_r,tr,bs,sn,Ct,vr,an,Xi,Ki,yr,br,xs,ws,xr,As,$i,Zi,ct,wr,ut,Lt,Qi,Ji,ea,ta,Ar,Ot,on,Ss,ln,zt,Sr,Dt,Pr;(ht={})[ht.None=0]="None",ht[ht.Anonymous=1]="Anonymous",ht[ht.NonConstant=2]="NonConstant",ht[ht.Xref=4]="Xref",ht[ht.XrefOverlay=8]="XrefOverlay",ht[ht.ExternallyDependent=16]="ExternallyDependent",ht[ht.ResolvedOrDependent=32]="ResolvedOrDependent",ht[ht.ReferencedXref=64]="ReferencedXref";(cs={})[cs.BYBLOCK=0]="BYBLOCK",cs[cs.BYLAYER=256]="BYLAYER";(Qe={})[Qe.Rotated=0]="Rotated",Qe[Qe.Aligned=1]="Aligned",Qe[Qe.Angular=2]="Angular",Qe[Qe.Diameter=3]="Diameter",Qe[Qe.Radius=4]="Radius",Qe[Qe.Angular3Point=5]="Angular3Point",Qe[Qe.Ordinate=6]="Ordinate",Qe[Qe.ReferenceIsExclusive=32]="ReferenceIsExclusive",Qe[Qe.IsOrdinateXTypeFlag=64]="IsOrdinateXTypeFlag",Qe[Qe.IsCustomTextPositionFlag=128]="IsCustomTextPositionFlag";(st={})[st.TopLeft=1]="TopLeft",st[st.TopCenter=2]="TopCenter",st[st.TopRight=3]="TopRight",st[st.MiddleLeft=4]="MiddleLeft",st[st.MiddleCenter=5]="MiddleCenter",st[st.MiddleRight=6]="MiddleRight",st[st.BottomLeft=7]="BottomLeft",st[st.BottomCenter=8]="BottomCenter",st[st.BottomRight=9]="BottomRight";(us={})[us.AtLeast=1]="AtLeast",us[us.Exact=2]="Exact";var To=((Jt={})[Jt.Center=0]="Center",Jt[Jt.Above=1]="Above",Jt[Jt.Outside=2]="Outside",Jt[Jt.JIS=3]="JIS",Jt[Jt.Below=4]="Below",Jt),Cn=((yt={})[yt.Feet=0]="Feet",yt[yt.None=1]="None",yt[yt.Inch=2]="Inch",yt[yt.FeetAndInch=3]="FeetAndInch",yt[yt.Leading=4]="Leading",yt[yt.Trailing=8]="Trailing",yt[yt.LeadingAndTrailing=12]="LeadingAndTrailing",yt),eu=((pr={})[pr.None=0]="None",pr[pr.Leading=1]="Leading",pr[pr.Trailing=2]="Trailing",pr[pr.LeadingAndTrailing=3]="LeadingAndTrailing",pr),tu=((er={})[er.Center=0]="Center",er[er.Left=1]="Left",er[er.Right=2]="Right",er[er.OverFirst=3]="OverFirst",er[er.OverSecond=4]="OverSecond",er),ru=((en={})[en.Bottom=0]="Bottom",en[en.Center=1]="Center",en[en.Top=2]="Top",en);(ds={})[ds.PatternFill=0]="PatternFill",ds[ds.SolidFill=1]="SolidFill";(ms={})[ms.NonAssociative=0]="NonAssociative",ms[ms.Associative=1]="Associative";(tn={})[tn.Normal=0]="Normal",tn[tn.Outer=1]="Outer",tn[tn.Ignore=2]="Ignore";(rn={})[rn.UserDefined=0]="UserDefined",rn[rn.Predefined=1]="Predefined",rn[rn.Custom=2]="Custom";(ps={})[ps.NotAnnotated=0]="NotAnnotated",ps[ps.Annotated=1]="Annotated";(gs={})[gs.Solid=0]="Solid",gs[gs.Gradient=1]="Gradient";(fs={})[fs.TwoColor=0]="TwoColor",fs[fs.OneColor=1]="OneColor";var nu=((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),js=((gr={})[gr.Line=1]="Line",gr[gr.Circular=2]="Circular",gr[gr.Elliptic=3]="Elliptic",gr[gr.Spline=4]="Spline",gr),su=((qe={})[qe.Off=0]="Off",qe[qe.Solid=1]="Solid",qe[qe.Dashed=2]="Dashed",qe[qe.Dotted=3]="Dotted",qe[qe.ShotDash=4]="ShotDash",qe[qe.MediumDash=5]="MediumDash",qe[qe.LongDash=6]="LongDash",qe[qe.DoubleShortDash=7]="DoubleShortDash",qe[qe.DoubleMediumDash=8]="DoubleMediumDash",qe[qe.DoubleLongDash=9]="DoubleLongDash",qe[qe.DoubleMediumLongDash=10]="DoubleMediumLongDash",qe[qe.SparseDot=11]="SparseDot",qe);su.Off;(nn={})[nn.Standard=-3]="Standard",nn[nn.ByLayer=-2]="ByLayer",nn[nn.ByBlock=-1]="ByBlock";(_s={})[_s.English=0]="English",_s[_s.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";(bt={})[bt.OPTIMIZED_2D=0]="OPTIMIZED_2D",bt[bt.WIREFRAME=1]="WIREFRAME",bt[bt.HIDDEN_LINE=2]="HIDDEN_LINE",bt[bt.FLAT_SHADED=3]="FLAT_SHADED",bt[bt.GOURAUD_SHADED=4]="GOURAUD_SHADED",bt[bt.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",bt[bt.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME";(vs={})[vs.UCS_UNCHANGED=0]="UCS_UNCHANGED",vs[vs.HAS_OWN_UCS=1]="HAS_OWN_UCS";(xt={})[xt.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",xt[xt.TOP=1]="TOP",xt[xt.BOTTOM=2]="BOTTOM",xt[xt.FRONT=3]="FRONT",xt[xt.BACK=4]="BACK",xt[xt.LEFT=5]="LEFT",xt[xt.RIGHT=6]="RIGHT";(ys={})[ys.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",ys[ys.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS";(fr={})[fr.ByLayer=0]="ByLayer",fr[fr.ByBlock=1]="ByBlock",fr[fr.ByDictionaryDefault=2]="ByDictionaryDefault",fr[fr.ByObject=3]="ByObject";function Ae(i,e,t){return i.code===e&&(t==null||i.value===t)}function ze(i){let e={};i.rewind();let t=i.next(),s=t.code;if(e.x=t.value,(t=i.next()).code!==s+10)throw Error("Expected code for point value to be 20 but got "+t.code+".");return e.y=t.value,(t=i.next()).code!==s+20?i.rewind():e.z=t.value,e}let ga=Symbol();function ye(i,e){return(t,s,o)=>{let h=function(b,f=!1){return b.reduce((S,x)=>{x.pushContext&&S.push({});let E=S[S.length-1];for(let M of typeof x.code=="number"?[x.code]:x.code){let z=E[M]??(E[M]=[]);x.isMultiple&&z.length&&f&&console.warn(`Snippet ${z[z.length-1].name} for code(${M}) is shadowed by ${x.name}`),z.push(x)}return S},[{}])}(i,s.debug),u=!1,g=h.length-1;for(;!Ae(t,0,"EOF");){let b=function(U,B,ge){return U.find((be,oe)=>{var W;return oe>=ge&&((W=be[B])==null?void 0:W.length)})}(h,t.code,g),f=b==null?void 0:b[t.code],S=f==null?void 0:f[f.length-1];if(!b||!S){s.rewind();break}S.isMultiple||b[t.code].pop();let{name:x,parser:E,isMultiple:M,isReducible:z}=S,D=E==null?void 0:E(t,s,o);if(D===ga){s.rewind();break}if(x){let[U,B]=function(ge,be){let oe=be.split(".");if(!oe.length)throw Error("[parserGenerator::getObjectByPath] Invalid empty path");let W=ge;for(let ce=0;ce<oe.length-1;++ce){let se=ra(oe[ce]),Ve=ra(oe[ce+1]);Object.prototype.hasOwnProperty.call(W,se)||(typeof Ve=="number"?W[se]=[]:W[se]={}),W=W[se]}return[W,ra(oe[oe.length-1])]}(o,x);M&&!z?(Object.prototype.hasOwnProperty.call(U,B)||(U[B]=[]),U[B].push(D)):U[B]=D}S.pushContext&&(g-=1),u=!0,t=s.next()}return e&&Object.setPrototypeOf(o,e),u}}function ra(i){let e=Number.parseInt(i);return Number.isNaN(e)?i:e}function y({value:i}){return i}function G(i,e){return ze(e)}function Be({value:i}){return!!i}let iu=[{code:1001,name:"xdata",parser:al}];function al(i,e){var o;if(!Ae(i,1001))throw Error("XData must starts with code 1001");let t={appName:i.value,value:[]};i=e.next();let s=[t.value];for(;!Ae(i,0,"EOF")&&i.code>=1e3;){let h=s[s.length-1];switch(i.code){case 1002:i.value==="{"?s.push([]):(s.pop(),(o=s[s.length-1])==null||o.push(h));break;case 1e3:case 1004:case 1040:case 1070:case 1071:h.push({type:Ir(i.code),value:i.value});break;case 1003:h.push({name:"layer",type:Ir(i.code),value:i.value});break;case 1005:h.push({name:"handle",type:Ir(i.code),value:i.value});break;case 1010:h.push({type:Ir(i.code),value:ze(e)});break;case 1011:h.push({name:"worldSpacePosition",type:Ir(i.code),value:ze(e)});break;case 1012:h.push({name:"worldSpaceDisplacement",type:Ir(i.code),value:ze(e)});break;case 1013:h.push({name:"worldSpaceDirection",type:Ir(i.code),value:ze(e)});break;case 1041:h.push({name:"distance",type:Ir(i.code),value:i.value});break;case 1042:h.push({name:"scale",type:Ir(i.code),value:i.value})}i=e.next()}return e.rewind(),t}function Ir(i){switch(i){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 mn(i,e,t){for(;Ae(i,102);){var s;let o=i.value;if(i=e.next(),!o.startsWith("{")){e.debug&&console.warn(`Invalid application group, expected to start with "{" but received: ${o}`),function(u,g){for(;!Ae(u,102)&&!Ae(u,0,"EOF");)u=g.next()}(i,e),i=e.next();continue}let h=o.slice(1).trim();t.extensions??(t.extensions={}),(s=t.extensions)[h]??(s[h]=[]),function(u,g,b){for(;!Ae(u,102,"}")&&!Ae(u,0,"EOF");)b.push(u),u=g.next()}(i,e,t.extensions[h]),i=e.next()}e.rewind()}let au=0;function ol(i){if(!i)throw TypeError("entity cannot be undefined or null");i.handle||(i.handle=au++)}var ou=[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 ll(i){return ou[i]}(_r={})[_r.CAST_AND_RECEIVE=0]="CAST_AND_RECEIVE",_r[_r.CAST=1]="CAST",_r[_r.RECEIVE=2]="RECEIVE",_r[_r.IGNORE=3]="IGNORE";let Ue=[...iu,{code:284,name:"shadowMode",parser:y},{code:390,name:"plotStyleHardId",parser:y},{code:380,name:"plotStyleType",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:Be},{code:48,name:"lineTypeScale",parser:y},{code:370,name:"lineweight",parser:y},{code:62,name:"colorIndex",parser(i,e,t){let s=i.value;return s>0&&s<256&&(t.color=ll(Math.abs(s))),s}},{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:Be},{code:100},{code:160},{code:330,name:"ownerBlockRecordSoftId",parser:y},{code:102,parser:mn},{code:102,parser:mn},{code:102,parser:mn},{code:5,name:"handle",parser:y}];function ki(i){return[{code:3,name:i,parser:(e,t,s)=>(s._code3text=(s._code3text??"")+e.value,s._code3text+(s._code1text??"")),isMultiple:!0,isReducible:!0},{code:1,name:i,parser:(e,t,s)=>(s._code1text=e.value,(s._code3text??"")+s._code1text)}]}function hl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}let lu={extrusionDirection:{x:0,y:0,z:1}},hu=[{code:210,name:"extrusionDirection",parser:G},{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:G},{code:39,name:"thickness",parser:y},{code:100},...Ue];class cl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){hl(this,"parser",ye(hu,lu))}}hl(cl,"ForEntityName","ARC");(tr={})[tr.NONE=0]="NONE",tr[tr.INVISIBLE=1]="INVISIBLE",tr[tr.CONSTANT=2]="CONSTANT",tr[tr.VERIFICATION_REQUIRED=4]="VERIFICATION_REQUIRED",tr[tr.PRESET=8]="PRESET";(bs={})[bs.MULTILINE=2]="MULTILINE",bs[bs.CONSTANT_MULTILINE=4]="CONSTANT_MULTILINE";(sn={})[sn.NONE=0]="NONE",sn[sn.MIRRORED_X=2]="MIRRORED_X",sn[sn.MIRRORED_Y=4]="MIRRORED_Y";var cu=((Ct={})[Ct.LEFT=0]="LEFT",Ct[Ct.CENTER=1]="CENTER",Ct[Ct.RIGHT=2]="RIGHT",Ct[Ct.ALIGNED=3]="ALIGNED",Ct[Ct.MIDDLE=4]="MIDDLE",Ct[Ct.FIT=5]="FIT",Ct),uu=((vr={})[vr.BASELINE=0]="BASELINE",vr[vr.BOTTOM=1]="BOTTOM",vr[vr.MIDDLE=2]="MIDDLE",vr[vr.TOP=3]="TOP",vr);function ul(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}let dl={thickness:0,rotation:0,xScale:1,obliqueAngle:0,styleName:"STANDARD",generationFlag:0,halign:cu.LEFT,valign:uu.BASELINE,extrusionDirection:{x:0,y:0,z:1}},ml=[{code:73,name:"valign",parser:y},{code:100},{code:210,name:"extrusionDirection",parser:G},{code:11,name:"endPoint",parser:G},{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:G},{code:39,name:"thickness",parser:y},{code:100,name:"subclassMarker",parser:y},...Ue];class pl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){ul(this,"parser",ye(ml,dl))}}function gl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}ul(pl,"ForEntityName","TEXT");let du={...dl},mu=[{code:2},{code:40,name:"annotationScale",parser:y},{code:10,name:"alignmentPoint",parser:G},{code:340,name:"secondaryAttributesHardIds",isMultiple:!0,parser:y},{code:70,name:"numberOfSecondaryAttributes",parser:y},{code:70,name:"isReallyLocked",parser:Be},{code:70,name:"mtextFlag",parser:y},{code:280,name:"isDuplicatedRecord",parser:Be},{code:100},{code:280,name:"isLocked",parser:Be},{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},...ml.slice(2)];class fl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){gl(this,"parser",ye(mu,du))}}gl(fl,"ForEntityName","ATTDEF");(an={})[an.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",an[an.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",an[an.BY_STYLE=5]="BY_STYLE";function pu(i,e){let t={};for(let s of i){let o=e(s);o!=null&&(t[o]??(t[o]=[]),t[o].push(s))}return t}function*ei(i,e=1/0,t=1){for(let s=i;s!==e;s+=t)yield s}function Vr(i){return{x:i.x??0,y:i.y??0,z:i.z??0}}function fa(i,e,t){if(Ae(e,102))return mn(e,t,i),!0;switch(e.code){case 0:i.type=e.value;break;case 5:i.handle=e.value;break;case 330:i.ownerBlockRecordSoftId=e.value;break;case 67:i.isInPaperSpace=!!e.value;break;case 8:i.layer=e.value;break;case 6:i.lineType=e.value;break;case 347:i.materialObjectHardId=e.value;break;case 62:i.colorIndex=e.value,i.color=ll(Math.abs(e.value));break;case 370:i.lineweight=e.value;break;case 48:i.lineTypeScale=e.value;break;case 60:i.isVisible=!!e.value;break;case 92:i.proxyByte=e.value;break;case 310:i.proxyEntity=e.value;break;case 100:break;case 420:i.color=e.value;break;case 430:i.transparency=e.value;break;case 390:i.plotStyleHardId=e.value;break;case 284:i.shadowMode=e.value;break;case 1001:i.xdata=al(e,t);break;default:return!1}return!0}function _l(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}let gu={textStyle:"STANDARD",extrusionDirection:{x:0,y:0,z:1},rotation:0},Xs=[{code:46,name:"annotationHeight",parser:y},{code:101,parser(i,e){(function(t){t.rewind();let s=t.next();if(s.code!==101)throw Error("Bad call for skipEmbeddedObject()");do s=t.next();while(s.code!==0);t.rewind()})(e)}},{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:[...ei(430,440)],name:"backgroundColor",parser:y},{code:[...ei(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:G},{code:210,name:"extrusionDirection",parser:G},{code:7,name:"styleName",parser:y},...ki("text"),{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:G},{code:100,name:"subclassMarker",parser:y},...Ue];class vl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){_l(this,"parser",ye(Xs,gu))}}function yl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}_l(vl,"ForEntityName","MTEXT");let fu={thickness:0,rotation:0,scale:1,obliqueAngle:0,textStyle:"STANDARD",textGenerationFlag:0,horizontalJustification:0,verticalJustification:0,extrusionDirection:{x:0,y:0,z:1}},_u=[...Xs.slice(Xs.findIndex(({name:i})=>i==="columnType"),Xs.findIndex(({name:i})=>i==="subclassMarker")+1),{code:100},{code:0,parser(i){if(!Ae(i,0,"MTEXT"))return ga}},{code:2,name:"definitionTag",parser:y},{code:40,name:"annotationScale",parser:y},{code:10,name:"alignmentPoint",parser:G},{code:340,name:"secondaryAttributesHardId",parser:y},{code:70,name:"numberOfSecondaryAttributes",parser:y},{code:70,name:"isReallyLocked",parser:Be},{code:70,name:"mtextFlag",parser:y},{code:280,name:"isDuplicatedEntriesKeep",parser:Be},{code:100},{code:280,name:"lockPositionFlag",parser:Be},{code:210,name:"extrusionDirection",parser:G},{code:11,name:"alignmentPoint",parser:G},{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:G},{code:39,name:"thickness",parser:y},{code:100},...Ue];class bl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){yl(this,"parser",ye(_u,fu))}}function xl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}yl(bl,"ForEntityName","ATTRIB");let vu=[...ki("data"),{code:70,name:"version",parser:y},{code:100,name:"subclassMarker",parser:y},...Ue];class wl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){xl(this,"parser",ye(vu))}}function Al(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}xl(wl,"ForEntityName","BODY");let yu={thickness:0,extrusionDirection:{x:0,y:0,z:1}},bu=[{code:210,name:"extrusionDirection",parser:G},{code:40,name:"radius",parser:y},{code:10,name:"center",parser:G},{code:39,name:"thickness",parser:y},{code:100,name:"subclassMarker",parser:y},...Ue];class Sl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Al(this,"parser",ye(bu,yu))}}Al(Sl,"ForEntityName","CIRCLE");class Ks{parseEntity(e,t){let s={};for(;!Ae(t,0,"EOF");){if(t.code===0){e.rewind();break}(function(o,h,u){switch(h.code){case 100:o.subclassMarker=h.value;break;case 280:o.version=h.value;break;case 2:o.name=h.value;break;case 10:o.definitionPoint=ze(u);break;case 11:o.textPoint=ze(u);break;case 12:o.insertionPoint=ze(u);break;case 13:o.subDefinitionPoint1=ze(u);break;case 14:o.subDefinitionPoint2=ze(u);break;case 15:o.centerPoint=ze(u);break;case 16:o.arcPoint=ze(u);break;case 70:o.dimensionType=h.value;break;case 71:o.attachmentPoint=h.value;break;case 72:o.textLineSpacingStyle=h.value;break;case 40:o.leaderLength=h.value;break;case 41:o.textLineSpacingFactor=h.value;break;case 42:o.measurement=h.value;break;case 1:o.text=h.value;break;case 50:o.rotationAngle=h.value;break;case 52:o.obliqueAngle=h.value;break;case 53:o.textRotation=h.value;break;case 51:o.ocsRotation=h.value;break;case 210:o.extrusionDirection=ze(u);break;case 3:o.styleName=h.value;break;default:fa(o,h,u)}})(s,t,e),t=e.next()}return s}}function Pl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}Ki="DIMENSION",(Xi="ForEntityName")in Ks?Object.defineProperty(Ks,Xi,{value:Ki,enumerable:!0,configurable:!0,writable:!0}):Ks[Xi]=Ki;let xu={extrusionDirection:{x:0,y:0,z:1}},wu=[{code:42,name:"endAngle",parser:y},{code:41,name:"startAngle",parser:y},{code:40,name:"axisRatio",parser:y},{code:210,name:"extrusionDirection",parser:G},{code:11,name:"majorAxisEndPoint",parser:G},{code:10,name:"center",parser:G},{code:100,name:"subclassMarker",parser:y},...Ue];class Il{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Pl(this,"parser",ye(wu,xu))}}Pl(Il,"ForEntityName","ELLIPSE");(yr={})[yr.First=1]="First",yr[yr.Second=2]="Second",yr[yr.Third=4]="Third",yr[yr.Fourth=8]="Fourth";function El(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}let Au=[{code:13,name:"vertices.3",parser:G},{code:12,name:"vertices.2",parser:G},{code:11,name:"vertices.1",parser:G},{code:10,name:"vertices.0",parser:G},{code:100,name:"subclassMarker",parser:y},...Ue];class kl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){El(this,"parser",ye(Au))}}El(kl,"ForEntityName","3DFACE");let Ml=[{code:330,name:"sourceBoundaryObjects",parser:y,isMultiple:!0},{code:97,name:"numberOfSourceBoundaryObjects",parser:y}],Su=[{code:11,name:"end",parser:G},{code:10,name:"start",parser:G}],Pu=[{code:73,name:"isCCW",parser:Be},{code:51,name:"endAngle",parser:y},{code:50,name:"startAngle",parser:y},{code:40,name:"radius",parser:y},{code:10,name:"center",parser:G}],Iu=[{code:73,name:"isCCW",parser:Be},{code:51,name:"endAngle",parser:y},{code:50,name:"startAngle",parser:y},{code:40,name:"lengthOfMinorAxis",parser:y},{code:11,name:"end",parser:G},{code:10,name:"center",parser:G}],Eu=[{code:13,name:"endTangent",parser:G},{code:12,name:"startTangent",parser:G},{code:11,name:"fitDatum",isMultiple:!0,parser:G},{code:97,name:"numberOfFitData",parser:y},{code:10,name:"controlPoints",isMultiple:!0,parser(i,e){let t={...ze(e),weight:1};return(i=e.next()).code===42?t.weight=i.value:e.rewind(),t}},{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:Be},{code:73,name:"splineFlag",parser:y},{code:94,name:"degree",parser:y}],ku={[js.Line]:Su,[js.Circular]:Pu,[js.Elliptic]:Iu,[js.Spline]:Eu},Mu=[...Ml,{code:72,name:"edges",parser(i,e){let t={type:i.value},s=ye(ku[t.type]);if(!s)throw Error(`Invalid edge type ${t.type}`);return s(i=e.next(),e,t),t},isMultiple:!0},{code:93,name:"numberOfEdges",parser:y}],Tu=[...Ml,{code:10,name:"vertices",parser(i,e){let t={...ze(e),bulge:0};return(i=e.next()).code===42?t.bulge=i.value:e.rewind(),t},isMultiple:!0},{code:93,name:"numberOfVertices",parser:y},{code:73,name:"isClosed",parser:Be},{code:72,name:"hasBulge",parser:Be}],Nu=[{code:49,name:"dashLengths",parser:y,isMultiple:!0},{code:79,name:"numberOfDashLengths",parser:y},{code:45,name:"offset",parser:No},{code:43,name:"base",parser:No},{code:53,name:"angle",parser:y}];function No(i,e){let t=i.code+1,s={x:i.value,y:1};return(i=e.next()).code===t?s.y=i.value:e.rewind(),s}function Tl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}let Cu={extrusionDirection:{x:0,y:0,z:1},gradientRotation:0,colorTint:0},Lu=[{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:G,isMultiple:!0},{code:99},{code:11,name:"offsetVector",parser:G},{code:98,name:"numberOfSeedPoints",parser:y},{code:47,name:"pixelSize",parser:y},{code:53,name:"definitionLines",parser:function(i,e){let t={};return ye(Nu)(i,e,t),t},isMultiple:!0},{code:78,name:"numberOfDefinitionLines",parser:y},{code:77,name:"isDouble",parser:Be},{code:73,name:"isAnnotated",parser:Be},{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(i,e){let t={boundaryPathTypeFlag:i.value},s=t.boundaryPathTypeFlag&nu.Polyline;return i=e.next(),s?ye(Tu)(i,e,t):ye(Mu)(i,e,t),t},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:G},{code:10,name:"elevationPoint",parser:G},{code:100,name:"subclassMarker",parser:y,pushContext:!0},...Ue];class Nl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Tl(this,"parser",ye(Lu,Cu))}}Tl(Nl,"ForEntityName","HATCH");(br={})[br.ShowImage=1]="ShowImage",br[br.ShowImageWhenNotAlignedWithScreen=2]="ShowImageWhenNotAlignedWithScreen",br[br.UseClippingBoundary=4]="UseClippingBoundary",br[br.TransparencyIsOn=8]="TransparencyIsOn";(xs={})[xs.Rectangular=1]="Rectangular",xs[xs.Polygonal=2]="Polygonal";(ws={})[ws.Outside=0]="Outside",ws[ws.Inside=1]="Inside";function Cl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}let Ou={brightness:50,contrast:50,fade:0,clippingBoundaryPath:[]},zu=[{code:290,name:"clipMode",parser:y},{code:14,name:"clippingBoundaryPath",isMultiple:!0,parser:G},{code:91,name:"countBoundaryPoints",parser:y},{code:71,name:"clippingBoundaryType",parser:y},{code:360,name:"imageDefReactorHandle",parser:y},{code:283,name:"fade",parser:y},{code:282,name:"contrast",parser:y},{code:281,name:"brightness",parser:y},{code:280,name:"isClipped",parser:Be},{code:70,name:"flags",parser:y},{code:340,name:"imageDefHandle",parser:y},{code:13,name:"imageSize",parser:G},{code:12,name:"vPixel",parser:G},{code:11,name:"uPixel",parser:G},{code:10,name:"position",parser:G},{code:90,name:"version",parser:y},{code:100,name:"subclassMarker",parser:y},...Ue];class Ll{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Cl(this,"parser",ye(zu,Ou))}}function Ol(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}Cl(Ll,"ForEntityName","IMAGE");let Du={xScale:1,yScale:1,zScale:1,rotation:0,columnCount:0,rowCount:0,columnSpacing:0,rowSpacing:0,extrusionDirection:{x:0,y:0,z:1}},Ru=[{code:210,name:"extrusionDirection",parser:G},{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:G},{code:2,name:"name",parser:y},{code:66,name:"isVariableAttributes",parser:Be},{code:100,name:"subclassMarker",parser:y},...Ue];class zl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Ol(this,"parser",ye(Ru,Du))}}function Dl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}Ol(zl,"ForEntityName","INSERT");let Bu={isArrowheadEnabled:!0},Fu=[{code:213,name:"offsetFromAnnotation",parser:G},{code:212,name:"offsetFromBlock",parser:G},{code:211,name:"horizontalDirection",parser:G},{code:210,name:"normal",parser:G},{code:340,name:"associatedAnnotation",parser:y},{code:77,name:"byBlockColor",parser:y},{code:10,name:"vertices",parser:G,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:Be},{code:74,name:"isHooklineSameDirection",parser:Be},{code:73,name:"leaderCreationFlag",parser:y},{code:72,name:"isSpline",parser:Be},{code:71,name:"isArrowheadEnabled",parser:Be},{code:3,name:"styleName",parser:y},{code:100,name:"subclassMarker",parser:y},...Ue],Rl=class{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Dl(this,"parser",ye(Fu,Bu))}};Dl(Rl,"ForEntityName","LEADER");(xr={})[xr.TextAnnotation=0]="TextAnnotation",xr[xr.ToleranceAnnotation=1]="ToleranceAnnotation",xr[xr.BlockReferenceAnnotation=2]="BlockReferenceAnnotation",xr[xr.NoAnnotation=3]="NoAnnotation";function Bl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}let Uu={thickness:0,extrusionDirection:{x:0,y:0,z:1}},Vu=[{code:210,name:"extrusionDirection",parser:G},{code:11,name:"endPoint",parser:G},{code:10,name:"startPoint",parser:G},{code:39,name:"thickness",parser:y},{code:100,name:"subclassMarker",parser:y},...Ue];class Fl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Bl(this,"parser",ye(Vu,Uu))}}Bl(Fl,"ForEntityName","LINE");(As={})[As.IS_CLOSED=1]="IS_CLOSED",As[As.PLINE_GEN=128]="PLINE_GEN";let ju={flag:0,elevation:0,thickness:0,extrusionDirection:{x:0,y:0,z:1},vertices:[]},Gu={bulge:0},Wu=[{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}],Hu=[{code:210,name:"extrusionDirection",parser:G},{code:10,name:"vertices",isMultiple:!0,parser(i,e){let t={};return ye(Wu,Gu)(i,e,t),t}},{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},...Ue];class $s{parseEntity(e,t){let s={};return ye(Hu,ju)(t,e,s),s}}function Ul(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}Zi="LWPOLYLINE",($i="ForEntityName")in $s?Object.defineProperty($s,$i,{value:Zi,enumerable:!0,configurable:!0,writable:!0}):$s[$i]=Zi;let qu=[{code:90,name:"overridenSubEntityCount",parser:y},{code:140,name:"edgeCreaseWeights",parser:y,isMultiple:!0},{code:95,name:"edgeCreaseCount",parser:y},{code:94,parser(i,e,t){t.edgeCount=i.value,t.edgeIndices=[];for(let s=0;s<t.edgeCount;++s){let o=[];i=e.next(),o[0]=i.value,i=e.next(),o[1]=i.value,t.edgeIndices.push(o)}}},{code:93,parser(i,e,t){t.totalFaceIndices=i.value,t.faceIndices=[];let s=[];for(let h=0;h<t.totalFaceIndices&&!Ae(i,0);++h)i=e.next(),s.push(i.value);let o=0;for(;o<s.length;){let h=s[o++],u=[];for(let g=0;g<h;++g)u.push(s[o++]);t.faceIndices.push(u)}}},{code:10,name:"vertices",parser:G,isMultiple:!0},{code:92,name:"verticesCount",parser:y},{code:91,name:"subdivisionLevel",parser:y},{code:40,name:"blendCrease",parser:y},{code:72,name:"isBlendCreased",parser:Be},{code:71,name:"version",parser:y},{code:100,name:"subclassMarker",parser:function({value:i}){return i.trim()},pushContext:!0},...Ue];class Vl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Ul(this,"parser",ye(qu))}}function jl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}Ul(Vl,"ForEntityName","MESH");let Yu={thickness:0,extrusionDirection:{x:0,y:0,z:1},angle:0},Xu=[{code:50,name:"angle",parser:y},{code:210,name:"extrusionDirection",parser:G},{code:39,name:"thickness",parser:y},{code:10,name:"position",parser:G},{code:100,name:"subclassMarker",parser:y},...Ue];class Gl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){jl(this,"parser",ye(Xu,Yu))}}jl(Gl,"ForEntityName","POINT");(ct={})[ct.CLOSED_POLYLINE=1]="CLOSED_POLYLINE",ct[ct.CURVE_FIT=2]="CURVE_FIT",ct[ct.SPLINE_FIT=4]="SPLINE_FIT",ct[ct.POLYLINE_3D=8]="POLYLINE_3D",ct[ct.POLYGON_3D=16]="POLYGON_3D",ct[ct.CLOSED_POLYGON=32]="CLOSED_POLYGON",ct[ct.POLYFACE=64]="POLYFACE",ct[ct.CONTINUOUS=128]="CONTINUOUS";(wr={})[wr.NONE=0]="NONE",wr[wr.QUADRATIC=5]="QUADRATIC",wr[wr.CUBIC=6]="CUBIC",wr[wr.BEZIER=8]="BEZIER";(ut={})[ut.CREATED_BY_CURVE_FIT=1]="CREATED_BY_CURVE_FIT",ut[ut.TANGENT_DEFINED=2]="TANGENT_DEFINED",ut[ut.NOT_USED=4]="NOT_USED",ut[ut.CREATED_BY_SPLINE_FIT=8]="CREATED_BY_SPLINE_FIT",ut[ut.SPLINE_CONTROL_POINT=16]="SPLINE_CONTROL_POINT",ut[ut.FOR_POLYLINE=32]="FOR_POLYLINE",ut[ut.FOR_POLYGON=64]="FOR_POLYGON",ut[ut.POLYFACE=128]="POLYFACE";function Wl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}let Ku={startWidth:0,endWidth:0,bulge:0},$u=[{code:91,name:"id",parser:y},{code:[...ei(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},...Ue];class _a{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Wl(this,"parser",ye($u,Ku))}}function Hl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}Wl(_a,"ForEntityName","VERTEX");let Zu={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:[]},Qu=[{code:0,name:"vertices",isMultiple:!0,parser:(i,e)=>Ae(i,0,"VERTEX")?(i=e.next(),new _a().parseEntity(e,i)):ga},{code:210,name:"extrusionDirection",parser:G},{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},...Ue];class ql{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Hl(this,"parser",ye(Qu,Zu))}}function Yl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}Hl(ql,"ForEntityName","POLYLINE");let Ju=[{code:11,name:"direction",parser:G},{code:10,name:"position",parser:G},{code:100,name:"subclassMarker",parser:y},...Ue];class Xl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Yl(this,"parser",ye(Ju))}}function Kl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}Yl(Xl,"ForEntityName","RAY");let ed=[...ki("data"),{code:70,name:"version",parser:y},{code:100,name:"subclassMarker",parser:y},...Ue];class $l{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Kl(this,"parser",ye(ed))}}function Zl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}Kl($l,"ForEntityName","REGION");let td={vertices:[],backLineVertices:[]},rd=[{code:360,name:"geometrySettingHardId",parser:y},{code:12,name:"backLineVertices",isMultiple:!0,parser:G},{code:93,name:"numberOfBackLineVertices",parser:y},{code:11,name:"vertices",isMultiple:!0,parser:G},{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:G},{code:1,name:"name",parser:y},{code:91,name:"flag",parser:y},{code:90,name:"state",parser:y},{code:100,name:"subclassMarker",parser:y},...Ue];class Ql{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Zl(this,"parser",ye(rd,td))}}function Jl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}Zl(Ql,"ForEntityName","SECTION");let nd={points:[],thickness:0,extrusionDirection:{x:0,y:0,z:1}},sd=[{code:210,name:"extrusionDirection",parser:G},{code:39,name:"thickness",parser:y},{code:[...ei(10,14)],name:"points",isMultiple:!0,parser:G},{code:100,name:"subclassMarker",parser:y},...Ue];class eh{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Jl(this,"parser",ye(sd,nd))}}function th(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}Jl(eh,"ForEntityName","SOLID");let id=[{code:350,name:"historyObjectSoftId",parser:y},{code:100,name:"subclassMarker",parser:y},...ki("data"),{code:70,name:"version",parser:y},{code:100},...Ue];class rh{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){th(this,"parser",ye(id))}}th(rh,"ForEntityName","3DSOLID");(Lt={})[Lt.NONE=0]="NONE",Lt[Lt.CLOSED=1]="CLOSED",Lt[Lt.PERIODIC=2]="PERIODIC",Lt[Lt.RATIONAL=4]="RATIONAL",Lt[Lt.PLANAR=8]="PLANAR",Lt[Lt.LINEAR=16]="LINEAR";function nh(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}let ad={knotTolerance:1e-6,controlTolerance:1e-6,fitTolerance:1e-9,knotValues:[],controlPoints:[],fitPoints:[]},od=[{code:11,name:"fitPoints",isMultiple:!0,parser:G},{code:10,name:"controlPoints",isMultiple:!0,parser:G},{code:41,name:"weights",isMultiple:!0,parser:y},{code:40,name:"knots",isMultiple:!0,parser:y},{code:13,name:"endTangent",parser:G},{code:12,name:"startTangent",parser:G},{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:G},{code:100,name:"subclassMarker",parser:y},...Ue];class sh{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){nh(this,"parser",ye(od,ad))}}nh(sh,"ForEntityName","SPLINE");class Zs{parseEntity(e,t){let s={};for(;!e.isEOF();){if(t.code===0){e.rewind();break}switch(t.code){case 100:s.subclassMarker=t.value,t=e.next();break;case 2:s.name=t.value,t=e.next();break;case 5:s.handle=t.value,t=e.next();break;case 10:s.startPoint=Vr(ze(e)),t=e.lastReadGroup;break;case 11:s.directionVector=Vr(ze(e)),t=e.lastReadGroup;break;case 90:s.tableValue=t.value,t=e.next();break;case 91:s.rowCount=t.value,t=e.next();break;case 92:s.columnCount=t.value,t=e.next();break;case 93:s.overrideFlag=t.value,t=e.next();break;case 94:s.borderColorOverrideFlag=t.value,t=e.next();break;case 95:s.borderLineWeightOverrideFlag=t.value,t=e.next();break;case 96:s.borderVisibilityOverrideFlag=t.value,t=e.next();break;case 141:s.rowHeightArr??(s.rowHeightArr=[]),s.rowHeightArr.push(t.value),t=e.next();break;case 142:s.columnWidthArr??(s.columnWidthArr=[]),s.columnWidthArr.push(t.value),t=e.next();break;case 280:s.version=t.value,t=e.next();break;case 310:s.bmpPreview??(s.bmpPreview=""),s.bmpPreview+=t.value,t=e.next();break;case 330:s.ownerDictionaryId=t.value,t=e.next();break;case 342:s.tableStyleId=t.value,t=e.next();break;case 343:s.blockRecordHandle=t.value,t=e.next();break;case 170:s.attachmentPoint=t.value,t=e.next();break;case 171:s.cells??(s.cells=[]),s.cells.push(function(o,h){let u=!1,g=!1,b={};for(;!o.isEOF()&&h.code!==0&&!g;)switch(h.code){case 171:if(u){g=!0;continue}b.cellType=h.value,u=!0,h=o.next();break;case 172:b.flagValue=h.value,h=o.next();break;case 173:b.mergedValue=h.value,h=o.next();break;case 174:b.autoFit=h.value,h=o.next();break;case 175:b.borderWidth=h.value,h=o.next();break;case 176:b.borderHeight=h.value,h=o.next();break;case 91:b.overrideFlag=h.value,h=o.next();break;case 178:b.virtualEdgeFlag=h.value,h=o.next();break;case 145:b.rotation=h.value,h=o.next();break;case 345:b.fieldObjetId=h.value,h=o.next();break;case 340:b.blockTableRecordId=h.value,h=o.next();break;case 146:b.blockScale=h.value,h=o.next();break;case 177:b.blockAttrNum=h.value,h=o.next();break;case 7:b.textStyle=h.value,h=o.next();break;case 140:b.textHeight=h.value,h=o.next();break;case 170:b.attachmentPoint=h.value,h=o.next();break;case 92:b.extendedCellFlags=h.value,h=o.next();break;case 285:b.rightBorderVisibility=!!(h.value??!0),h=o.next();break;case 286:b.bottomBorderVisibility=!!(h.value??!0),h=o.next();break;case 288:b.leftBorderVisibility=!!(h.value??!0),h=o.next();break;case 289:b.topBorderVisibility=!!(h.value??!0),h=o.next();break;case 301:(function(f,S,x){for(;x.code!==304;)switch(x.code){case 301:case 93:case 90:case 94:x=S.next();break;case 1:f.text=x.value,x=S.next();break;case 300:f.attrText=x.value,x=S.next();break;case 302:f.text=x.value?x.value:f.text,x=S.next();break;default:console.log(`Ignore code: ${x.code}, value: ${x.value}`),x=S.next()}})(b,o,h),h=o.next();break;default:return b}return u=!1,g=!1,b}(e,t)),t=e.lastReadGroup;break;default:fa(s,t,e),t=e.next()}}return s}}function ih(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}Ji="ACAD_TABLE",(Qi="ForEntityName")in Zs?Object.defineProperty(Zs,Qi,{value:Ji,enumerable:!0,configurable:!0,writable:!0}):Zs[Qi]=Ji;let ld=[{code:11,name:"xAxisDirection",parser:G},{code:210,name:"extrusionDirection",parser:G},{code:1,name:"text",parser:y},{code:10,name:"position",parser:G},{code:3,name:"styleName",parser:y},{code:100,name:"subclassMarker",parser:y},...Ue];class ah{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){ih(this,"parser",ye(ld))}}ih(ah,"ForEntityName","TOLERANCE");let Qs=class{parseEntity(e,t){let s={};for(;t!=="EOF";){if(t.code===0){e.rewind();break}!function(o,h,u){if(u==="EOF")return!1;switch(u.code){case 0:return!1;case 8:o.layer=u.value;break;case 100:o.subclassMarker=u.value;break;case 10:o.viewportCenter=Vr(ze(h));break;case 40:o.width=u.value;break;case 41:o.height=u.value;break;case 68:o.status=u.value;break;case 69:o.viewportId=u.value;break;case 12:o.displayCenter=ze(h);break;case 13:o.snapBase=ze(h);break;case 14:o.snapSpacing=ze(h);break;case 15:o.gridSpacing=ze(h);break;case 16:o.viewDirection=Vr(ze(h));break;case 17:o.targetPoint=Vr(ze(h));break;case 42:o.perspectiveLensLength=u.value;break;case 43:o.frontClipZ=u.value;break;case 44:o.backClipZ=u.value;break;case 45:o.viewHeight=u.value;break;case 50:o.snapAngle=u.value;break;case 51:o.viewTwistAngle=u.value;break;case 72:o.circleZoomPercent=u.value;break;case 331:o.frozenLayerIds??(o.frozenLayerIds=[]),o.frozenLayerIds.push(u.value);break;case 90:o.statusBitFlags=u.value;break;case 340:o.clippingBoundaryId=u.value;break;case 1:o.sheetName=u.value;break;case 281:o.renderMode=u.value;break;case 71:o.ucsPerViewport=u.value;break;case 110:o.ucsOrigin=Vr(ze(h));break;case 111:o.ucsXAxis=Vr(ze(h));break;case 112:o.ucsYAxis=Vr(ze(h));break;case 345:o.ucsId=u.value;break;case 346:o.ucsBaseId=u.value;break;case 79:o.orthographicType=u.value;break;case 146:o.elevation=u.value;break;case 170:o.shadePlotMode=u.value;break;case 61:o.majorGridFrequency=u.value;break;case 332:o.backgroundId=u.value;break;case 333:o.shadePlotId=u.value;break;case 348:o.visualStyleId=u.value;break;case 292:o.isDefaultLighting=!!u.value;break;case 282:o.defaultLightingType=u.value;break;case 141:o.brightness=u.value;break;case 142:o.contrast=u.value;break;case 63:case 421:case 431:o.ambientLightColor=u.value;break;case 361:o.sunId=u.value;break;case 335:case 343:case 344:case 91:o.softPointer=u.value}return!0}(s,e,t)&&fa(s,t,e),t=e.next()}return s}};ta="VIEWPORT",(ea="ForEntityName")in Qs?Object.defineProperty(Qs,ea,{value:ta,enumerable:!0,configurable:!0,writable:!0}):Qs[ea]=ta;(Ar={})[Ar.ShowImage=1]="ShowImage",Ar[Ar.ShowImageWhenNotAligned=2]="ShowImageWhenNotAligned",Ar[Ar.UseClippingBoundary=4]="UseClippingBoundary",Ar[Ar.Transparency=8]="Transparency";function oh(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}let hd={brightness:50,constrast:50,fade:0},cd=[{code:14,name:"boundary",isMultiple:!0,parser:G},{code:91,name:"numberOfVertices",parser:y},{code:71,name:"boundaryType",parser:y},{code:360,name:"imageDefReactorHardId",parser:y},{code:283,name:"fade",parser:y},{code:282,name:"contrast",parser:y},{code:281,name:"brightness",parser:y},{code:280,name:"isClipping",parser:Be},{code:70,name:"displayFlag",parser:y},{code:340,name:"imageDefHardId",parser:y},{code:13,name:"imageSize",parser:G},{code:12,name:"vDirection",parser:G},{code:11,name:"uDirection",parser:G},{code:10,name:"position",parser:G},{code:90,name:"classVersion",parser:y},{code:100,name:"subclassMarker",parser:y},...Ue];class lh{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){oh(this,"parser",ye(cd,hd))}}function hh(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}oh(lh,"ForEntityName","WIPEOUT");let ud=[{code:11,name:"direction",parser:G},{code:10,name:"position",parser:G},{code:100,name:"subclassMarker",parser:y},...Ue],ch=class{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){hh(this,"parser",ye(ud))}};function uh(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}hh(ch,"ForEntityName","XLINE");let dd={},md=[{code:170,name:"multileaderType",parser:y},{code:291,name:"doglegEnabled",parser:Be},{code:40,name:"doglegLength",parser:y},{code:172,name:"contentType",parser:y},{code:3,name:"textContent",parser:y},{code:12,name:"textAnchor",parser:G},{code:344,name:"blockHandle",parser:y},{code:15,name:"blockPosition",parser:G},{code:302,name:"leaderSections",parser:function(i,e,t){let s,o={leaderLines:[]};for(;e.hasNext()&&(s=e.next()).code!==303;)switch(s.code){case 10:o.landingPoint=(s.value,ze(e));break;case 11:o.doglegVector=(s.value,ze(e));break;case 40:o.doglegLength=s.value;break;case 304:o.leaderLines.push(function(h,u,g){let b,f={vertices:[]};for(;u.hasNext()&&(b=u.next()).code!==305;)b.code===10&&f.vertices.push((b.value,ze(u)));return f}(0,e))}return o},isMultiple:!0},...Ue];class dh{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){uh(this,"parser",ye(md,dd))}}uh(dh,"ForEntityName","MULTILEADER");let pd=Object.fromEntries([cl,fl,bl,wl,Sl,Ks,Il,kl,Ll,zl,Rl,Fl,$s,Vl,vl,dh,Gl,ql,Xl,$l,Ql,eh,rh,sh,Zs,pl,ah,Nl,_a,Qs,lh,ch].map(i=>[i.ForEntityName,new i]));function mh(i,e){let t=[];for(;!Ae(i,0,"EOF");){if(i.code===0){if(i.value==="ENDBLK"||i.value==="ENDSEC"){e.rewind();break}let s=pd[i.value];if(s){let o=i.value;i=e.next();let h=s.parseEntity(e,i);h.type=o,ol(h),t.push(h)}else e.debug&&console.warn(`Unsupported ENTITY type: ${i.value}`)}i=e.next()}return t}function gd(i,e){let t={};for(;!Ae(i,0,"EOF")&&!Ae(i,0,"ENDSEC");){if(Ae(i,0,"BLOCK")){let s=fd(i=e.next(),e);ol(s),s.name&&(t[s.name]=s)}i=e.next()}return t}function fd(i,e){let t={};for(;!Ae(i,0,"EOF");){if(Ae(i,0,"ENDBLK")){for(i=e.next();!Ae(i,0,"EOF");){if(Ae(i,100,"AcDbBlockEnd"))return t;i=e.next()}break}switch(i.code){case 1:t.xrefPath=i.value;break;case 2:t.name=i.value;break;case 3:t.name2=i.value;break;case 5:t.handle=i.value;break;case 8:t.layer=i.value;break;case 10:t.position=ze(e);break;case 67:t.paperSpace=!!i.value&&i.value==1;break;case 70:i.value!==0&&(t.type=i.value);break;case 100:break;case 330:t.ownerHandle=i.value;break;case 0:t.entities=mh(i,e)}i=e.next()}return t}function _d(i,e){let t=null,s={};for(;!Ae(i,0,"EOF")&&!Ae(i,0,"ENDSEC");)i.code===9?t=i.value:i.code===10?s[t]=ze(e):s[t]=i.value,i=e.next();return s}(Ot={})[Ot.NOT_APPLICABLE=0]="NOT_APPLICABLE",Ot[Ot.KEEP_EXISTING=1]="KEEP_EXISTING",Ot[Ot.USE_CLONE=2]="USE_CLONE",Ot[Ot.XREF_VALUE_NAME=3]="XREF_VALUE_NAME",Ot[Ot.VALUE_NAME=4]="VALUE_NAME",Ot[Ot.UNMANGLE_NAME=5]="UNMANGLE_NAME";let va=[{code:330,name:"ownerObjectId",parser:y},{code:102,parser:mn},{code:102,parser:mn},{code:102,parser:mn},{code:5,name:"handle",parser:y}],vd=[{code:3,name:"entries",parser:(i,e)=>{let t={name:i.value};return(i=e.next()).code===350?t.objectSoftId=i.value:i.code===360?t.objectHardId=i.value:e.rewind(),t},isMultiple:!0},{code:281,name:"recordCloneFlag",parser:y},{code:280,name:"isHardOwned",parser:Be},{code:100,name:"subclassMarker",parser:y},...va],yd=[{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:G},{code:11,name:"sizeOfOnePixel",parser:G},{code:280,name:"isLoaded",parser:y},{code:281,name:"resolutionUnits",parser:y},{code:100,name:"subclassMarker",parser:y}];(on={})[on.NOUNIT=0]="NOUNIT",on[on.CENTIMETERS=2]="CENTIMETERS",on[on.INCH=5]="INCH";(Ss={})[Ss.PSLTSCALE=1]="PSLTSCALE",Ss[Ss.LIMCHECK=2]="LIMCHECK";(ln={})[ln.INCHES=0]="INCHES",ln[ln.MILLIMETERS=1]="MILLIMETERS",ln[ln.PIXELS=2]="PIXELS";(zt={})[zt.LAST_SCREEN_DISPLAY=0]="LAST_SCREEN_DISPLAY",zt[zt.DRAWING_EXTENTS=1]="DRAWING_EXTENTS",zt[zt.DRAWING_LIMITS=2]="DRAWING_LIMITS",zt[zt.VIEW_SPECIFIED=3]="VIEW_SPECIFIED",zt[zt.WINDOW_SPECIFIED=4]="WINDOW_SPECIFIED",zt[zt.LAYOUT_INFORMATION=5]="LAYOUT_INFORMATION";(Sr={})[Sr.AS_DISPLAYED=0]="AS_DISPLAYED",Sr[Sr.WIREFRAME=1]="WIREFRAME",Sr[Sr.HIDDEN=2]="HIDDEN",Sr[Sr.RENDERED=3]="RENDERED";(Dt={})[Dt.DRAFT=0]="DRAFT",Dt[Dt.PREVIEW=1]="PREVIEW",Dt[Dt.NORMAL=2]="NORMAL",Dt[Dt.PRESENTATION=3]="PRESENTATION",Dt[Dt.MAXIMUM=4]="MAXIMUM",Dt[Dt.CUSTOM=5]="CUSTOM";let ph=[{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:"plotPaperUnit",parser:y},{code:70,name:"layoutFlag",parser:y},{code:143,name:"printScaleDenominator",parser:y},{code:142,name:"printScaleNumerator",parser:y},{code:141,name:"windowAreaYMax",parser:y},{code:140,name:"windowAreaXMax",parser:y},{code:49,name:"windowAreaYMin",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},...va],bd=[{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:G},{code:16,name:"ucsXAxis",parser:G},{code:13,name:"ucsOrigin",parser:G},{code:146,name:"elevation",parser:y},{code:15,name:"maxExtent",parser:G},{code:14,name:"minExtent",parser:G},{code:12,name:"insertionPoint",parser:G},{code:11,name:"maxLimit",parser:G},{code:10,name:"minLimit",parser:G},{code:71,name:"tabOrder",parser:y},{code:70,name:"controlFlag",parser:y},{code:1,name:"layoutName",parser:y},{code:100,name:"subclassMarker",parser:y},...ph],xd=[{code:40,name:"wcsToOCSTransform",parser:Co},{code:40,name:"ocsToWCSTransform",parser:Co},{code:41,name:"backClippingDistance",parser:y},{code:73,name:"isBackClipping",parser:Be,pushContext:!0},{code:40,name:"frontClippingDistance",parser:y},{code:72,name:"isFrontClipping",parser:Be,pushContext:!0},{code:71,name:"isClipBoundaryDisplayed",parser:Be},{code:11,name:"position",parser:G},{code:210,name:"normal",parser:G},{code:10,name:"boundaryVertices",parser:G,isMultiple:!0},{code:70,name:"boundaryCount",parser:y},{code:100,name:"subclassMarker",parser:y},{code:100},...va];function Co(i,e){let t=[];for(let s=0;s<3&&Ae(i,40);++s){let o=[];for(let h=0;h<4&&Ae(i,40);++h)o.push(i.value),i=e.next();t.push(o)}return e.rewind(),t}let wd={LAYOUT:bd,PLOTSETTINGS:ph,DICTIONARY:vd,SPATIAL_FILTER:xd,IMAGEDEF:yd};function Ad(i,e){let t=[];for(;i.code!==0||!["EOF","ENDSEC"].includes(i.value);){let s=i.value,o=wd[s];if(i.code===0&&(o!=null&&o.length)){let h=ye(o),u={name:s};h(i=e.next(),e,u)?(t.push(u),i=e.peek()):i=e.next()}else i=e.next()}return{byName:pu(t,({name:s})=>s)}}let Un=[{code:100,name:"subclassMarker",parser:y},{code:330,name:"ownerObjectId",parser:y},{code:102,parser(i,e){for(;!Ae(i,0,"EOF")&&!Ae(i,102,"}");)i=e.next()}},{code:5,name:"handle",parser:y}],Sd=ye([{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},...Un]),Pd=[{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:To.Above,defaultValueImperial:To.Center},{name:"DIMZIN",code:78,defaultValue:Cn.Trailing,defaultValueImperial:Cn.Feet},{name:"DIMAZIN",code:79,defaultValue:eu.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:tu.Center},{name:"DIMSD1",code:281,defaultValue:0},{name:"DIMSD2",code:282,defaultValue:0},{name:"DIMTOLJ",code:283,defaultValue:ru.Center},{name:"DIMTZIN",code:284,defaultValue:Cn.Trailing,defaultValueImperial:Cn.Feet},{name:"DIMALTZ",code:285,defaultValue:Cn.Trailing},{name:"DIMALTTZ",code:286,defaultValue:Cn.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}],Id=ye([...Pd.map(i=>({...i,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},...Un.filter(i=>i.code!==5)]),Ed=ye([{code:347,name:"materialObjectId",parser:y},{code:390,name:"plotStyleNameObjectId",parser:y},{code:370,name:"lineweight",parser:y},{code:290,name:"isPlotting",parser:Be},{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},...Un]);(Pr={})[Pr.NONE=0]="NONE",Pr[Pr.AbsoluteRotation=1]="AbsoluteRotation",Pr[Pr.TextEmbedded=2]="TextEmbedded",Pr[Pr.ShapeEmbedded=4]="ShapeEmbedded";let kd=ye([{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}),Md=ye([{code:49,name:"pattern",parser(i,e){let t={};return kd(i,e,t),t},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},...Un]),Td=ye([{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},...Un]),Nd=ye([{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:Be},{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:G},{code:111,name:"ucsXAxis",parser:G},{code:110,name:"ucsOrigin",parser:G},{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:G},{code:16,name:"viewDirectionFromTarget",parser:G},{code:15,name:"gridSpacing",parser:G},{code:14,name:"snapSpacing",parser:G},{code:13,name:"snapBasePoint",parser:G},{code:12,name:"center",parser:G},{code:11,name:"upperRightCorner",parser:G},{code:10,name:"lowerLeftCorner",parser:G},{code:70,name:"standardFlag",parser:y},{code:2,name:"name",parser:y},{code:100,name:"subclassMarker",parser:y},...Un]),Cd={BLOCK_RECORD:Sd,DIMSTYLE:Id,LAYER:Ed,LTYPE:Md,STYLE:Td,VPORT:Nd},Ld=ye([{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 Od(i,e){var s;let t={};for(;!Ae(i,0,"EOF")&&!Ae(i,0,"ENDSEC");){if(Ae(i,0,"TABLE")){i=e.next();let o={entries:[]};Ld(i,e,o),t[o.name]=o}if(Ae(i,0)&&!Ae(i,0,"ENDTAB")){let o=i.value;i=e.next();let h=Cd[o];if(!h){e.debug&&console.warn(`parseTable: Invalid table name '${o}'`),i=e.next();continue}let u={};h(i,e,u),(s=t[o])==null||s.entries.push(u)}i=e.next()}return t}function Ps(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}class Lo{next(){if(!this.hasNext())return this._eof?this.debug&&console.warn("Cannot call 'next' after EOF group has been read"):this.debug&&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 e=parseInt(this._data[this._pointer++],10),t=Oo(e,this._data[this._pointer++],this.debug),s={code:e,value:t};return Ae(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 e={code:parseInt(this._data[this._pointer]),value:0};return e.value=Oo(e.code,this._data[this._pointer+1],this.debug),e}rewind(e){e=e||1,this._pointer=this._pointer-2*e}hasNext(){return!this._eof&&!(this._pointer>this._data.length-2)}isEOF(){return this._eof}constructor(e,t=!1){Ps(this,"_data",void 0),Ps(this,"debug",void 0),Ps(this,"_pointer",void 0),Ps(this,"_eof",void 0),Ps(this,"lastReadGroup",void 0),this._data=e,this.debug=t,this.lastReadGroup={code:0,value:0},this._pointer=0,this._eof=!1}}function Oo(i,e,t=!1){return i<=9?e:i>=10&&i<=59?parseFloat(e.trim()):i>=60&&i<=99?parseInt(e.trim()):i>=100&&i<=109?e:i>=110&&i<=149?parseFloat(e.trim()):i>=160&&i<=179?parseInt(e.trim()):i>=210&&i<=239?parseFloat(e.trim()):i>=270&&i<=289?parseInt(e.trim()):i>=290&&i<=299?function(s){if(s==="0")return!1;if(s==="1")return!0;throw TypeError("String '"+s+"' cannot be cast to Boolean type")}(e.trim()):i>=300&&i<=369?e:i>=370&&i<=389?parseInt(e.trim()):i>=390&&i<=399?e:i>=400&&i<=409?parseInt(e.trim()):i>=410&&i<=419?e:i>=420&&i<=429?parseInt(e.trim()):i>=430&&i<=439?e:i>=440&&i<=459?parseInt(e.trim()):i>=460&&i<=469?parseFloat(e.trim()):i>=470&&i<=481||i===999||i>=1e3&&i<=1009?e:i>=1010&&i<=1059?parseFloat(e.trim()):i>=1060&&i<=1071?parseInt(e.trim()):(t&&console.warn("WARNING: Group code does not have a defined type: %j",{code:i,value:e}),e)}function la(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}class zd{constructor(){la(this,"encoding","utf-8"),la(this,"encodingFailureFatal",!1)}}class Dd extends EventTarget{parseSync(e,t=!1){let s=new Lo(e.split(/\r\n|\r|\n/g),t);if(!s.hasNext())throw Error("Empty file");return this.parseAll(s)}parseStream(e){let t="",s=this;return new Promise((o,h)=>{e.on("data",u=>{t+=u}),e.on("end",()=>{try{let u=t.split(/\r\n|\r|\n/g),g=new Lo(u);if(!g.hasNext())throw Error("Empty file");o(s.parseAll(g))}catch(u){h(u)}}),e.on("error",u=>{h(u)})})}async parseFromUrl(e,t){let s=await fetch(e,t);if(!s.body)return null;let o=s.body.getReader(),h="";for(;;){let{done:u,value:g}=await o.read();if(u){h+=this._decoder.decode(new ArrayBuffer(0),{stream:!1});break}h+=this._decoder.decode(g,{stream:!0})}return this.parseSync(h)}parseAll(e){let t={header:{},blocks:{},entities:[],tables:{},objects:{byName:{},byTree:void 0}},s=e.next();for(;!Ae(s,0,"EOF");)Ae(s,0,"SECTION")&&(Ae(s=e.next(),2,"HEADER")?(s=e.next(),t.header=_d(s,e)):Ae(s,2,"BLOCKS")?(s=e.next(),t.blocks=gd(s,e)):Ae(s,2,"ENTITIES")?(s=e.next(),t.entities=mh(s,e)):Ae(s,2,"TABLES")?(s=e.next(),t.tables=Od(s,e)):Ae(s,2,"OBJECTS")&&(s=e.next(),t.objects=Ad(s,e))),s=e.next();return t}constructor(e=new zd){super(),la(this,"_decoder",void 0),this._decoder=new TextDecoder(e.encoding,{fatal:e.encodingFailureFatal})}}var ya=(i=>(i[i.DecimalDegrees=0]="DecimalDegrees",i[i.DegreesMinutesSeconds=1]="DegreesMinutesSeconds",i[i.Gradians=2]="Gradians",i[i.Radians=3]="Radians",i[i.SurveyorsUnits=4]="SurveyorsUnits",i))(ya||{});class Gr{static get instance(){return this._instance||(this._instance=new Gr),this._instance}constructor(){this._blocks=new Map}createKey(e,t){return`${e}_${t}`}set(e,t){return t=t.fastDeepClone(),this._blocks.set(e,t),t}get(e){let t=this._blocks.get(e);return t&&(t=t.fastDeepClone()),t}has(e){return this._blocks.has(e)}clear(){this._blocks.clear()}draw(e,t,s,o=!0,h,u){const g=[];if(t!=null){const b=this.createKey(t.name,s);let f;if(this.has(b))f=this.get(b);else{const S=t.newIterator();for(const x of S)x.color.isByBlock&&s?(zo.copy(x.color),x.color.color=s,this.addEntity(x,g,e),x.color.copy(zo)):this.addEntity(x,g,e);f=e.group(g),f&&o&&this.set(b,f)}return f&&h&&(f.applyMatrix(h),u&&(u.x!=0||u.y!=0||u.z!=1)&&(h.setFromExtrusionDirection(u),f.applyMatrix(h))),f}else return e.group(g)}addEntity(e,t,s){const o=e.draw(s);o&&(this.attachEntityInfo(o,e),t.push(o))}attachEntityInfo(e,t){e.objectId=t.objectId,e.ownerId=t.ownerId,e.layerName=t.layer,e.visible=t.visibility}}const zo=new Wr,ti="Continuous",Js="ByLayer",gh="ByBlock";var un=(i=>(i[i.EndPoint=1]="EndPoint",i[i.MidPoint=2]="MidPoint",i[i.Center=3]="Center",i[i.Node=4]="Node",i[i.Quadrant=5]="Quadrant",i[i.Insertion=7]="Insertion",i[i.Perpendicular=8]="Perpendicular",i[i.Tangent=9]="Tangent",i[i.Nearest=10]="Nearest",i[i.Centroid=11]="Centroid",i))(un||{}),ba=(i=>(i[i.Undefined=0]="Undefined",i[i.Inches=1]="Inches",i[i.Feet=2]="Feet",i[i.Miles=3]="Miles",i[i.Millimeters=4]="Millimeters",i[i.Centimeters=5]="Centimeters",i[i.Meters=6]="Meters",i[i.Kilometers=7]="Kilometers",i[i.Microinches=8]="Microinches",i[i.Mils=9]="Mils",i[i.Yards=10]="Yards",i[i.Angstroms=11]="Angstroms",i[i.Nanometers=12]="Nanometers",i[i.Microns=13]="Microns",i[i.Decimeters=14]="Decimeters",i[i.Dekameters=15]="Dekameters",i[i.Hectometers=16]="Hectometers",i[i.Gigameters=17]="Gigameters",i[i.Astronomical=18]="Astronomical",i[i.LightYears=19]="LightYears",i[i.Parsecs=20]="Parsecs",i[i.USSurveyFeet=21]="USSurveyFeet",i[i.USSurveyInch=22]="USSurveyInch",i[i.USSurveyYard=23]="USSurveyYard",i[i.USSurveyMile=24]="USSurveyMile",i[i.Max=24]="Max",i))(ba||{});function Rd(i){return i==4||i==5||i==6||i==7||i==12||i==13||i==14||i==15||i==16||i==17}function Bd(i){return i==1||i==2||i==3||i==8||i==9||i==10||i==21}var fh=(i=>(i.ClosedFilled="",i.Dot="_DOT",i.DotSmall="_DOTSMALL",i.DotBlank="_DOTBLANK",i.Origin="_ORIGIN",i.Origin2="_ORIGIN2",i.Open="_OPEN",i.Open90="_OPEN90",i.Open30="_OPEN30",i.Closed="_CLOSED",i.Small="_SMALL",i.None="_NONE",i.Oblique="_OBLIQUE",i.BoxFilled="_BOXFILLED",i.Box="_BOXBLANK",i.ClosedBlank="_CLOSEDBLANK",i.DatumBlank="_DATUMBLANK",i.DatumFilled="_DATUMFILLED",i.Integral="_INTEGRAL",i.ArchTick="_ARCHTICK",i))(fh||{});class Mi{constructor(e){this.i=0,this._records=e,this._keys=Array.from(e.keys())}[Symbol.iterator](){return this}next(){for(;this.i<this._keys.length;){const e=this._records.get(this._keys[this.i]);return this.i+=1,{value:e,done:!1}}return{value:null,done:!0}}}const _h="Load Database";class Pt extends tl{constructor(e,t){super(e.stage),this.data=e,this.progress=t}async run(e){const t=pa.getInstance().getEntry(_h),s=Date.now();this.progress&&await this.progress(this.data.progress.value,this.data.stage,"START");const o=await this.data.task(e);if(this.progress){const h=o.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 t&&(t.data[this.name]=Date.now()-s),o}}class vh{constructor(e={}){this.config=e}async read(e,t,s,o){const h={name:_h,data:{total:0},format(){let f="";return Object.keys(this.data).forEach(S=>{S!=="total"&&(f+=`- ${S}: ${this.data[S]} ms
2
+ `)}),f+=`- total: ${this.data.total} ms`,f}};pa.getInstance().collect(h),this.progress=o;const u={value:0},g=new rl;g.setCompleteCallback(()=>this.onFinished()),g.setErrorCallback(f=>this.onError(f)),g.addTask(new Pt({stage:"START",step:1,progress:u,task:async f=>f},o)),g.addTask(new Pt({stage:"PARSE",step:5,progress:u,task:async f=>await this.parse(f)},o)),g.addTask(new Pt({stage:"FONT",step:5,progress:u,task:async f=>{const S=this.getFonts(f.model);return{model:f.model,data:S}}},o)),g.addTask(new Pt({stage:"LTYPE",step:1,progress:u,task:async f=>(this.processLineTypes(f.model,t),f)},o)),g.addTask(new Pt({stage:"STYLE",step:1,progress:u,task:async f=>(this.processTextStyles(f.model,t),f)},o)),g.addTask(new Pt({stage:"DIMSTYLE",step:1,progress:u,task:async f=>(this.processDimStyles(f.model,t),f)},o)),g.addTask(new Pt({stage:"LAYER",step:1,progress:u,task:async f=>(this.processLayers(f.model,t),t.tables.layerTable.numEntries===0&&t.createDefaultData({layer:!0}),f)},o)),g.addTask(new Pt({stage:"VPORT",step:1,progress:u,task:async f=>(this.processViewports(f.model,t),f)},o)),g.addTask(new Pt({stage:"HEADER",step:1,progress:u,task:async f=>(this.processHeader(f.model,t),f)},o)),g.addTask(new Pt({stage:"BLOCK_RECORD",step:5,progress:u,task:async f=>(this.processBlockTables(f.model,t),f)},o)),g.addTask(new Pt({stage:"OBJECT",step:5,progress:u,task:async f=>(this.processObjects(f.model,t),t.dictionaries.layouts.numEntries===0&&t.createDefaultData({layout:!0}),f)},o)),g.addTask(new Pt({stage:"BLOCK",step:5,progress:u,task:async f=>(await this.processBlocks(f.model,t),f)},o)),g.addTask(new Pt({stage:"ENTITY",step:100,progress:u,task:async f=>(await this.processEntities(f.model,t,s,u,o),f)},o)),g.addTask(new Pt({stage:"END",step:0,progress:u,task:async f=>f},o));const b=Date.now();await g.run(e),h.data.total=Date.now()-b}onError(e){if(this.progress){const t=e.task;this.progress(t.data.progress.value,t.data.stage,"ERROR",void 0,e)}console.error(`Error occurred in conversion stage '${e.task.name}': `,e.error),e.task.name!="ENTITY"&&this.onFinished()}onFinished(){this.progress&&(this.progress(100,"END","END"),Gr.instance.clear())}async parse(e,t){throw new Error("Not impelemented yet!")}getFonts(e){throw new Error("Not impelemented yet!")}processLineTypes(e,t){throw new Error("Not impelemented yet!")}processTextStyles(e,t){throw new Error("Not impelemented yet!")}processDimStyles(e,t){throw new Error("Not impelemented yet!")}processLayers(e,t){throw new Error("Not impelemented yet!")}processViewports(e,t){throw new Error("Not impelemented yet!")}processHeader(e,t){throw new Error("Not impelemented yet!")}processBlockTables(e,t){throw new Error("Not impelemented yet!")}processObjects(e,t){throw new Error("Not impelemented yet!")}processBlocks(e,t){throw new Error("Not impelemented yet!")}processEntities(e,t,s,o,h){throw new Error("Not impelemented yet!")}}const ft=["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 Do=1234567;const xa=Math.PI/180,wa=180/Math.PI;function yh(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(ft[i&255]+ft[i>>8&255]+ft[i>>16&255]+ft[i>>24&255]+"-"+ft[e&255]+ft[e>>8&255]+"-"+ft[e>>16&15|64]+ft[e>>24&255]+"-"+ft[t&63|128]+ft[t>>8&255]+"-"+ft[t>>16&255]+ft[t>>24&255]+ft[s&255]+ft[s>>8&255]+ft[s>>16&255]+ft[s>>24&255]).toLowerCase()}function kr(i,e,t){return Math.max(e,Math.min(t,i))}function Aa(i,e){return(i%e+e)%e}function bh(i,e,t,s,o){return s+(i-e)*(o-s)/(t-e)}function xh(i,e,t){return i!==e?(t-i)/(e-i):0}function Sa(i,e,t){return(1-t)*i+t*e}function wh(i,e,t,s){return Sa(i,e,1-Math.exp(-t*s))}function Ah(i,e=1){return e-Math.abs(Aa(i,e*2)-e)}function Sh(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function Ph(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function Ih(i,e){return i+Math.floor(Math.random()*(e-i+1))}function Eh(i,e){return i+Math.random()*(e-i)}function kh(i){return i*(.5-Math.random())}function Mh(i){i!==void 0&&(Do=i);let e=Do+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function Th(i){return i*xa}function Nh(i){return i*wa}function Ch(i){return(i&i-1)===0&&i!==0}function Lh(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Oh(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Ms(i){const e=Math.PI*2;return(i%e+e)%e}function zh(i,e,t){return i>e&&i<t||i>t&&i<e}function Dh(i,e,t,s=!1){return i=Ms(i),e=Ms(e),t=Ms(t),s?e>t?i<=e&&i>=t:i<=e||i>=t:e<t?i>=e&&i<=t:i>=e||i<=t}function Pa(i){return i=Math.abs(i),i<1?0:Math.ceil(Math.log10(Math.abs(i)+1))}function Rh(i,e=1e-7){const t=Pa(i);return Math.max(Math.pow(10,t)*e,e)}const Ee={DEG2RAD:xa,RAD2DEG:wa,generateUUID:yh,clamp:kr,euclideanModulo:Aa,mapLinear:bh,inverseLerp:xh,lerp:Sa,damp:wh,pingpong:Ah,smoothstep:Sh,smootherstep:Ph,randInt:Ih,randFloat:Eh,randFloatSpread:kh,seededRandom:Mh,degToRad:Th,radToDeg:Nh,isPowerOfTwo:Ch,ceilPowerOfTwo:Lh,floorPowerOfTwo:Oh,normalizeAngle:Ms,isBetween:zh,isBetweenAngle:Dh,intPartLength:Pa,relativeEps:Rh},ha=class Bh{constructor(e,t){this.x=0,this.y=0;const s=+(e!==void 0)+ +(t!==void 0);if(s!==0){if(s===1&&e instanceof Array){this.x=e[0],this.y=e[1];return}if(s===1){const{x:o,y:h}=e;this.x=o,this.y=h;return}if(s===2){this.x=e,this.y=t;return}throw Ut.ILLEGAL_PARAMETERS}}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new Bh(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix2d(e){const t=this.x,s=this.y,o=e.elements;return this.x=o[0]*t+o[3]*s+o[6],this.y=o[1]*t+o[4]*s+o[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(e,Math.min(t,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(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.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(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const s=this.dot(e)/t;return Math.acos(Math.max(-1,Math.min(1,s)))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,s=this.y-e.y;return t*t+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,s){return this.x=e.x+(t.x-e.x)*s,this.y=e.y+(t.y-e.y)*s,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}rotateAround(e,t){const s=Math.cos(t),o=Math.sin(t),h=this.x-e.x,u=this.y-e.y;return this.x=h*s-u*o+e.x,this.y=h*o+u*s+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}relativeEps(e=1e-7){return Math.min(Ee.relativeEps(this.x,e),Ee.relativeEps(this.y,e))}*[Symbol.iterator](){yield this.x,yield this.y}};ha.EMPTY=Object.freeze(new ha(0,0));let $e=ha;const ca=class Fh{constructor(e,t,s,o,h,u,g,b,f){this.elements=[1,0,0,0,1,0,0,0,1],e!=null&&t!=null&&s!=null&&o!=null&&h!=null&&u!=null&&g!=null&&b!=null&&f!=null&&this.set(e,t,s,o,h,u,g,b,f)}set(e,t,s,o,h,u,g,b,f){const S=this.elements;return S[0]=e,S[1]=o,S[2]=g,S[3]=t,S[4]=h,S[5]=b,S[6]=s,S[7]=u,S[8]=f,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,s=e.elements;return t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t[4]=s[4],t[5]=s[5],t[6]=s[6],t[7]=s[7],t[8]=s[8],this}extractBasis(e,t,s){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const s=e.elements,o=t.elements,h=this.elements,u=s[0],g=s[3],b=s[6],f=s[1],S=s[4],x=s[7],E=s[2],M=s[5],z=s[8],D=o[0],U=o[3],B=o[6],ge=o[1],be=o[4],oe=o[7],W=o[2],ce=o[5],se=o[8];return h[0]=u*D+g*ge+b*W,h[3]=u*U+g*be+b*ce,h[6]=u*B+g*oe+b*se,h[1]=f*D+S*ge+x*W,h[4]=f*U+S*be+x*ce,h[7]=f*B+S*oe+x*se,h[2]=E*D+M*ge+z*W,h[5]=E*U+M*be+z*ce,h[8]=E*B+M*oe+z*se,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],s=e[1],o=e[2],h=e[3],u=e[4],g=e[5],b=e[6],f=e[7],S=e[8];return t*u*S-t*g*f-s*h*S+s*g*b+o*h*f-o*u*b}invert(){const e=this.elements,t=e[0],s=e[1],o=e[2],h=e[3],u=e[4],g=e[5],b=e[6],f=e[7],S=e[8],x=S*u-g*f,E=g*b-S*h,M=f*h-u*b,z=t*x+s*E+o*M;if(z===0)return this.set(0,0,0,0,0,0,0,0,0);const D=1/z;return e[0]=x*D,e[1]=(o*f-S*s)*D,e[2]=(g*s-o*u)*D,e[3]=E*D,e[4]=(S*t-o*b)*D,e[5]=(o*h-g*t)*D,e[6]=M*D,e[7]=(s*b-f*t)*D,e[8]=(u*t-s*h)*D,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e.elements[0]=t[0],e.elements[1]=t[3],e.elements[2]=t[6],e.elements[3]=t[1],e.elements[4]=t[4],e.elements[5]=t[7],e.elements[6]=t[2],e.elements[7]=t[5],e.elements[8]=t[8],this}setUvTransform(e,t,s,o,h,u,g){const b=Math.cos(h),f=Math.sin(h);return this.set(s*b,s*f,-s*(b*u+f*g)+u+e,-o*f,o*b,-o*(-f*u+b*g)+g+t,0,0,1),this}scale(e,t){return this.premultiply(na.makeScale(e,t)),this}rotate(e){return this.premultiply(na.makeRotation(-e)),this}translate(e,t){return this.premultiply(na.makeTranslation(e,t)),this}makeTranslation(e,t){return e instanceof $e?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,-s,0,s,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,s=e.elements;for(let o=0;o<9;o++)if(t[o]!==s[o])return!1;return!0}fromArray(e,t=0){for(let s=0;s<9;s++)this.elements[s]=e[s+t];return this}toArray(e=[],t=0){const s=this.elements;return e[t]=s[0],e[t+1]=s[1],e[t+2]=s[2],e[t+3]=s[3],e[t+4]=s[4],e[t+5]=s[5],e[t+6]=s[6],e[t+7]=s[7],e[t+8]=s[8],e}clone(){return new Fh().fromArray(this.elements)}};ca.IDENTITY=Object.freeze(new ca);let Ti=ca;const na=new Ti,cn=1e-6,nt=2*Math.PI,Fd={x:0,y:0},Ia={x:0,y:0,z:0};class Ea{constructor(){this.equalPointTol=cn,this.equalVectorTol=cn}equalPoint2d(e,t){return new $e(e).sub(t).length()<this.equalPointTol}equalPoint3d(e,t){return new Z(e).sub(t).length()<this.equalPointTol}static equalToZero(e,t=cn){return e<t&&e>-t}static equal(e,t,s=cn){return Math.abs(e-t)<s}static great(e,t,s=cn){return e-t>s}static less(e,t,s=cn){return e-t<s}}const ka=new Ea;function Ma(i,e,t=!1){const s=i.x,o=i.y;let h=!1;const u=e.length;for(let g=0,b=u-1;g<u;b=g++){const f=e[g].x,S=e[g].y,x=e[b].x,E=e[b].y;let M=S>o!=E>o;t&&(M=S>=o!=E>=o),M&&s<(x-f)*(o-S)/(E-S)+f&&(h=!h)}return h}function Uh(i,e){if(i.length===0||e.length===0)return!1;const t=new _t().setFromPoints(i),s=new _t().setFromPoints(e);if(!t.intersectsBox(s))return!1;for(let o=0;o<i.length;){if(Ma(i[o],e,!0))return!0;o<i.length-1&&ka.equalPoint2d(i[o+1],i[o])&&++o,++o}return!1}const Vh={isPointInPolygon:Ma,isPolygonIntersect:Uh};function jh(i,e){const t=[],s=e-1,o=i;for(let h=0;h<=o;h++)t.push(0);for(let h=1;h<=s-o;h++)t.push(h);for(let h=0;h<=o;h++)t.push(s-o+1);return t}function Gh(i,e){const t=e.length-1,s=i,o=[0];let h=0;for(let g=1;g<=t;g++){const b=e[g][0]-e[g-1][0],f=e[g][1]-e[g-1][1],S=e[g][2]-e[g-1][2],x=Math.sqrt(b*b+f*f+S*S);h+=x,o.push(h)}const u=[];for(let g=0;g<=s;g++)u.push(0);for(let g=1;g<=t-s;g++){const b=o[g]/h;u.push(b*(t-s+1))}for(let g=0;g<=s;g++)u.push(t-s+1);return u}function Wh(i,e){const t=e.length-1,s=i,o=[0];let h=0;for(let g=1;g<=t;g++){const b=e[g][0]-e[g-1][0],f=e[g][1]-e[g-1][1],S=e[g][2]-e[g-1][2],x=Math.sqrt(b*b+f*f+S*S),E=Math.sqrt(x);h+=E,o.push(h)}const u=[];for(let g=0;g<=s;g++)u.push(0);for(let g=1;g<=t-s;g++){const b=o[g]/h;u.push(b*(t-s+1))}for(let g=0;g<=s;g++)u.push(t-s+1);return u}function ri(i,e,t,s){if(e===0)return t>=s[i]&&t<s[i+1]?1:0;const o=s[i+e]-s[i],h=s[i+e+1]-s[i+1],u=o>1e-10?(t-s[i])/o:0,g=h>1e-10?(s[i+e+1]-t)/h:0;return u*ri(i,e-1,t,s)+g*ri(i+1,e-1,t,s)}function Ts(i,e,t,s,o){const h=s.length-1,u=e;if(i=Math.max(t[u],Math.min(t[h+1],i)),Math.abs(i-t[h+1])<1e-8)return[...s[h]];if(Math.abs(i-t[u])<1e-8)return[...s[0]];const g=[0,0,0];let b=0;for(let f=0;f<=h;f++){const S=ri(f,u,i,t),x=o[f]*S;g[0]+=s[f][0]*x,g[1]+=s[f][1]*x,g[2]+=s[f][2]*x,b+=x}if(b<1e-10){const f=t[t.length-u-1];if(Math.abs(i-f)<1e-8)return[...s[h]];if(Math.abs(i-t[u])<1e-8)return[...s[0]]}return b>1e-10&&(g[0]/=b,g[1]/=b,g[2]/=b),g}function Hh(i,e,t,s){const o=i,h=e[o],u=e[e.length-o-1];let g=0;const b=1e3,f=(u-h)/b;let S=Ts(h,i,e,t,s);for(let D=1;D<=b;D++){const U=h+D*f,B=Ts(U,i,e,t,s),ge=B[0]-S[0],be=B[1]-S[1],oe=B[2]-S[2];g+=Math.sqrt(ge*ge+be*be+oe*oe),S=B}const x=Ts(u,i,e,t,s),E=x[0]-S[0],M=x[1]-S[1],z=x[2]-S[2];return g+=Math.sqrt(E*E+M*M+z*z),g}function Ud(i){return i.map(e=>[...e])}class Hr{constructor(e=0,t=0,s=0,o=1){this._x=e,this._y=t,this._z=s,this._w=o}static slerpFlat(e,t,s,o,h,u,g){let b=s[o+0],f=s[o+1],S=s[o+2],x=s[o+3];const E=h[u+0],M=h[u+1],z=h[u+2],D=h[u+3];if(g===0){e[t+0]=b,e[t+1]=f,e[t+2]=S,e[t+3]=x;return}if(g===1){e[t+0]=E,e[t+1]=M,e[t+2]=z,e[t+3]=D;return}if(x!==D||b!==E||f!==M||S!==z){let U=1-g;const B=b*E+f*M+S*z+x*D,ge=B>=0?1:-1,be=1-B*B;if(be>Number.EPSILON){const W=Math.sqrt(be),ce=Math.atan2(W,B*ge);U=Math.sin(U*ce)/W,g=Math.sin(g*ce)/W}const oe=g*ge;if(b=b*U+E*oe,f=f*U+M*oe,S=S*U+z*oe,x=x*U+D*oe,U===1-g){const W=1/Math.sqrt(b*b+f*f+S*S+x*x);b*=W,f*=W,S*=W,x*=W}}e[t]=b,e[t+1]=f,e[t+2]=S,e[t+3]=x}static multiplyQuaternionsFlat(e,t,s,o,h,u){const g=s[o],b=s[o+1],f=s[o+2],S=s[o+3],x=h[u],E=h[u+1],M=h[u+2],z=h[u+3];return e[t]=g*z+S*x+b*M-f*E,e[t+1]=b*z+S*E+f*x-g*M,e[t+2]=f*z+S*M+g*E-b*x,e[t+3]=S*z-g*x-b*E-f*M,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,s,o){return this._x=e,this._y=t,this._z=s,this._w=o,this._onChangeCallback(),this}clone(){return new Hr(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const s=e.x,o=e.y,h=e.z,u=e.order,g=Math.cos,b=Math.sin,f=g(s/2),S=g(o/2),x=g(h/2),E=b(s/2),M=b(o/2),z=b(h/2);switch(u){case"XYZ":this._x=E*S*x+f*M*z,this._y=f*M*x-E*S*z,this._z=f*S*z+E*M*x,this._w=f*S*x-E*M*z;break;case"YXZ":this._x=E*S*x+f*M*z,this._y=f*M*x-E*S*z,this._z=f*S*z-E*M*x,this._w=f*S*x+E*M*z;break;case"ZXY":this._x=E*S*x-f*M*z,this._y=f*M*x+E*S*z,this._z=f*S*z+E*M*x,this._w=f*S*x-E*M*z;break;case"ZYX":this._x=E*S*x-f*M*z,this._y=f*M*x+E*S*z,this._z=f*S*z-E*M*x,this._w=f*S*x+E*M*z;break;case"YZX":this._x=E*S*x+f*M*z,this._y=f*M*x+E*S*z,this._z=f*S*z-E*M*x,this._w=f*S*x-E*M*z;break;case"XZY":this._x=E*S*x-f*M*z,this._y=f*M*x-E*S*z,this._z=f*S*z+E*M*x,this._w=f*S*x+E*M*z;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+u)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const s=t/2,o=Math.sin(s);return this._x=e.x*o,this._y=e.y*o,this._z=e.z*o,this._w=Math.cos(s),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,s=t[0],o=t[4],h=t[8],u=t[1],g=t[5],b=t[9],f=t[2],S=t[6],x=t[10],E=s+g+x;if(E>0){const M=.5/Math.sqrt(E+1);this._w=.25/M,this._x=(S-b)*M,this._y=(h-f)*M,this._z=(u-o)*M}else if(s>g&&s>x){const M=2*Math.sqrt(1+s-g-x);this._w=(S-b)/M,this._x=.25*M,this._y=(o+u)/M,this._z=(h+f)/M}else if(g>x){const M=2*Math.sqrt(1+g-s-x);this._w=(h-f)/M,this._x=(o+u)/M,this._y=.25*M,this._z=(b+S)/M}else{const M=2*Math.sqrt(1+x-s-g);this._w=(u-o)/M,this._x=(h+f)/M,this._y=(b+S)/M,this._z=.25*M}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let s=e.dot(t)+1;return s<Number.EPSILON?(s=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=s):(this._x=0,this._y=-e.z,this._z=e.y,this._w=s)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=s),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(kr(this.dot(e),-1,1)))}rotateTowards(e,t){const s=this.angleTo(e);if(s===0)return this;const o=Math.min(1,t/s);return this.slerp(e,o),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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._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 e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const s=e._x,o=e._y,h=e._z,u=e._w,g=t._x,b=t._y,f=t._z,S=t._w;return this._x=s*S+u*g+o*f-h*b,this._y=o*S+u*b+h*g-s*f,this._z=h*S+u*f+s*b-o*g,this._w=u*S-s*g-o*b-h*f,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const s=this._x,o=this._y,h=this._z,u=this._w;let g=u*e._w+s*e._x+o*e._y+h*e._z;if(g<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,g=-g):this.copy(e),g>=1)return this._w=u,this._x=s,this._y=o,this._z=h,this;const b=1-g*g;if(b<=Number.EPSILON){const M=1-t;return this._w=M*u+t*this._w,this._x=M*s+t*this._x,this._y=M*o+t*this._y,this._z=M*h+t*this._z,this.normalize(),this}const f=Math.sqrt(b),S=Math.atan2(f,g),x=Math.sin((1-t)*S)/f,E=Math.sin(t*S)/f;return this._w=u*x+this._w*E,this._x=s*x+this._x*E,this._y=o*x+this._y*E,this._z=h*x+this._z*E,this._onChangeCallback(),this}slerpQuaternions(e,t,s){return this.copy(e).slerp(t,s)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),s=Math.random(),o=Math.sqrt(1-s),h=Math.sqrt(s);return this.set(o*Math.sin(e),o*Math.cos(e),h*Math.sin(t),h*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const Bt=class qh{constructor(e,t,s){this.x=0,this.y=0,this.z=0;const o=+(e!==void 0)+ +(t!==void 0)+ +(s!==void 0);if(o!==0){if(o===1&&e instanceof Array){this.x=e[0],this.y=e[1],this.z=e[2];return}if(o===1){const{x:h,y:u,z:g}=e;this.x=h,this.y=u,this.z=g||0;return}if(o===3){this.x=e,this.y=t,this.z=s;return}throw Ut.ILLEGAL_PARAMETERS}}set(e,t,s){return s===void 0&&(s=this.z),this.x=e,this.y=t,this.z=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new qh(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z||0,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z||0,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Ro.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Ro.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,s=this.y,o=this.z,h=e.elements;return this.x=h[0]*t+h[3]*s+h[6]*o,this.y=h[1]*t+h[4]*s+h[7]*o,this.z=h[2]*t+h[5]*s+h[8]*o,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix3d(e){const t=this.x,s=this.y,o=this.z,h=e.elements,u=1/(h[3]*t+h[7]*s+h[11]*o+h[15]);return this.x=(h[0]*t+h[4]*s+h[8]*o+h[12])*u,this.y=(h[1]*t+h[5]*s+h[9]*o+h[13])*u,this.z=(h[2]*t+h[6]*s+h[10]*o+h[14])*u,this}applyQuaternion(e){const t=this.x,s=this.y,o=this.z,h=e.x,u=e.y,g=e.z,b=e.w,f=2*(u*o-g*s),S=2*(g*t-h*o),x=2*(h*s-u*t);return this.x=t+b*f+u*x-g*S,this.y=s+b*S+g*f-h*x,this.z=o+b*x+h*S-u*f,this}transformDirection(e){const t=this.x,s=this.y,o=this.z,h=e.elements;return this.x=h[0]*t+h[4]*s+h[8]*o,this.y=h[1]*t+h[5]*s+h[9]*o,this.z=h[2]*t+h[6]*s+h[10]*o,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(e,Math.min(t,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(e){return this.x*e.x+this.y*e.y+this.z*e.z}isParallelTo(e){const t=this.dot(e),s=this.length(),o=e.length();return Math.abs(t)===s*o}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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,s){return this.x=e.x+(t.x-e.x)*s,this.y=e.y+(t.y-e.y)*s,this.z=e.z+(t.z-e.z)*s,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const s=e.x,o=e.y,h=e.z,u=t.x,g=t.y,b=t.z;return this.x=o*b-h*g,this.y=h*u-s*b,this.z=s*g-o*u,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const s=e.dot(this)/t;return this.copy(e).multiplyScalar(s)}projectOnPlane(e){return sa.copy(this).projectOnVector(e),this.sub(sa)}reflect(e){return this.sub(sa.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const s=this.dot(e)/t;return Math.acos(Math.max(-1,Math.min(1,s)))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,s=this.y-e.y,o=this.z-e.z;return t*t+s*s+o*o}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),s=this.setFromMatrixColumn(e,1).length(),o=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=s,this.z=o,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,s=Math.sqrt(1-t*t);return this.x=s*Math.cos(e),this.y=t,this.z=s*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};Bt.X_AXIS=Object.freeze(new Bt(1,0,0)),Bt.NEGATIVE_X_AXIS=Object.freeze(new Bt(-1,0,0)),Bt.Y_AXIS=Object.freeze(new Bt(0,1,0)),Bt.NEGATIVE_Y_AXIS=Object.freeze(new Bt(0,-1,0)),Bt.Z_AXIS=Object.freeze(new Bt(0,0,1)),Bt.NEGATIVE_Z_AXIS=Object.freeze(new Bt(0,0,-1));let Z=Bt;const sa=new Z,Ro=new Hr,ua=class Yh{constructor(e,t,s,o,h,u,g,b,f,S,x,E,M,z,D,U){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!=null&&t!=null&&s!=null&&o!=null&&h!=null&&u!=null&&g!=null&&b!=null&&f!=null&&S!=null&&x!=null&&E!=null&&M!=null&&z!=null&&D!=null&&U!=null&&this.set(e,t,s,o,h,u,g,b,f,S,x,E,M,z,D,U)}set(e,t,s,o,h,u,g,b,f,S,x,E,M,z,D,U){const B=this.elements;return B[0]=e,B[4]=t,B[8]=s,B[12]=o,B[1]=h,B[5]=u,B[9]=g,B[13]=b,B[2]=f,B[6]=S,B[10]=x,B[14]=E,B[3]=M,B[7]=z,B[11]=D,B[15]=U,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 Yh().fromArray(this.elements)}copy(e){const t=this.elements,s=e.elements;return t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t[4]=s[4],t[5]=s[5],t[6]=s[6],t[7]=s[7],t[8]=s[8],t[9]=s[9],t[10]=s[10],t[11]=s[11],t[12]=s[12],t[13]=s[13],t[14]=s[14],t[15]=s[15],this}copyPosition(e){const t=this.elements,s=e.elements;return t[12]=s[12],t[13]=s[13],t[14]=s[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}setFromExtrusionDirection(e){if(ka.equalPoint3d(e,Z.Z_AXIS))this.identity();else{const t=new Z(1,0,0);Math.abs(e.x)<1/64&&Math.abs(e.y)<1/64?t.crossVectors(Z.Y_AXIS,e).normalize():t.crossVectors(Z.Z_AXIS,e).normalize();const s=e.clone().cross(t).normalize();this.set(t.x,t.y,t.z,0,s.x,s.y,s.z,0,e.x,e.y,e.z,0,0,0,0,1)}return this}extractBasis(e,t,s){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this}makeBasis(e,t,s){return this.set(e.x,t.x,s.x,0,e.y,t.y,s.y,0,e.z,t.z,s.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,s=e.elements,o=1/Ln.setFromMatrixColumn(e,0).length(),h=1/Ln.setFromMatrixColumn(e,1).length(),u=1/Ln.setFromMatrixColumn(e,2).length();return t[0]=s[0]*o,t[1]=s[1]*o,t[2]=s[2]*o,t[3]=0,t[4]=s[4]*h,t[5]=s[5]*h,t[6]=s[6]*h,t[7]=0,t[8]=s[8]*u,t[9]=s[9]*u,t[10]=s[10]*u,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Vd,e,jd)}lookAt(e,t,s){const o=this.elements;return Rt.subVectors(e,t),Rt.lengthSq()===0&&(Rt.z=1),Rt.normalize(),Ur.crossVectors(s,Rt),Ur.lengthSq()===0&&(Math.abs(s.z)===1?Rt.x+=1e-4:Rt.z+=1e-4,Rt.normalize(),Ur.crossVectors(s,Rt)),Ur.normalize(),Gs.crossVectors(Rt,Ur),o[0]=Ur.x,o[4]=Gs.x,o[8]=Rt.x,o[1]=Ur.y,o[5]=Gs.y,o[9]=Rt.y,o[2]=Ur.z,o[6]=Gs.z,o[10]=Rt.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const s=e.elements,o=t.elements,h=this.elements,u=s[0],g=s[4],b=s[8],f=s[12],S=s[1],x=s[5],E=s[9],M=s[13],z=s[2],D=s[6],U=s[10],B=s[14],ge=s[3],be=s[7],oe=s[11],W=s[15],ce=o[0],se=o[4],Ve=o[8],Ye=o[12],We=o[1],xe=o[5],Le=o[9],dt=o[13],mt=o[2],It=o[6],Je=o[10],at=o[14],Q=o[3],Te=o[7],ot=o[11],hr=o[15];return h[0]=u*ce+g*We+b*mt+f*Q,h[4]=u*se+g*xe+b*It+f*Te,h[8]=u*Ve+g*Le+b*Je+f*ot,h[12]=u*Ye+g*dt+b*at+f*hr,h[1]=S*ce+x*We+E*mt+M*Q,h[5]=S*se+x*xe+E*It+M*Te,h[9]=S*Ve+x*Le+E*Je+M*ot,h[13]=S*Ye+x*dt+E*at+M*hr,h[2]=z*ce+D*We+U*mt+B*Q,h[6]=z*se+D*xe+U*It+B*Te,h[10]=z*Ve+D*Le+U*Je+B*ot,h[14]=z*Ye+D*dt+U*at+B*hr,h[3]=ge*ce+be*We+oe*mt+W*Q,h[7]=ge*se+be*xe+oe*It+W*Te,h[11]=ge*Ve+be*Le+oe*Je+W*ot,h[15]=ge*Ye+be*dt+oe*at+W*hr,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],s=e[4],o=e[8],h=e[12],u=e[1],g=e[5],b=e[9],f=e[13],S=e[2],x=e[6],E=e[10],M=e[14],z=e[3],D=e[7],U=e[11],B=e[15];return z*(+h*b*x-o*f*x-h*g*E+s*f*E+o*g*M-s*b*M)+D*(+t*b*M-t*f*E+h*u*E-o*u*M+o*f*S-h*b*S)+U*(+t*f*x-t*g*M-h*u*x+s*u*M+h*g*S-s*f*S)+B*(-o*g*S-t*b*x+t*g*E+o*u*x-s*u*E+s*b*S)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,s){const o=this.elements;return e instanceof Z?(o[12]=e.x,o[13]=e.y,o[14]=e.z):(o[12]=e,o[13]=t,o[14]=s),this}invert(){const e=this.elements,t=e[0],s=e[1],o=e[2],h=e[3],u=e[4],g=e[5],b=e[6],f=e[7],S=e[8],x=e[9],E=e[10],M=e[11],z=e[12],D=e[13],U=e[14],B=e[15],ge=x*U*f-D*E*f+D*b*M-g*U*M-x*b*B+g*E*B,be=z*E*f-S*U*f-z*b*M+u*U*M+S*b*B-u*E*B,oe=S*D*f-z*x*f+z*g*M-u*D*M-S*g*B+u*x*B,W=z*x*b-S*D*b-z*g*E+u*D*E+S*g*U-u*x*U,ce=t*ge+s*be+o*oe+h*W;if(ce===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const se=1/ce;return e[0]=ge*se,e[1]=(D*E*h-x*U*h-D*o*M+s*U*M+x*o*B-s*E*B)*se,e[2]=(g*U*h-D*b*h+D*o*f-s*U*f-g*o*B+s*b*B)*se,e[3]=(x*b*h-g*E*h-x*o*f+s*E*f+g*o*M-s*b*M)*se,e[4]=be*se,e[5]=(S*U*h-z*E*h+z*o*M-t*U*M-S*o*B+t*E*B)*se,e[6]=(z*b*h-u*U*h-z*o*f+t*U*f+u*o*B-t*b*B)*se,e[7]=(u*E*h-S*b*h+S*o*f-t*E*f-u*o*M+t*b*M)*se,e[8]=oe*se,e[9]=(z*x*h-S*D*h-z*s*M+t*D*M+S*s*B-t*x*B)*se,e[10]=(u*D*h-z*g*h+z*s*f-t*D*f-u*s*B+t*g*B)*se,e[11]=(S*g*h-u*x*h-S*s*f+t*x*f+u*s*M-t*g*M)*se,e[12]=W*se,e[13]=(S*D*o-z*x*o+z*s*E-t*D*E-S*s*U+t*x*U)*se,e[14]=(z*g*o-u*D*o-z*s*b+t*D*b+u*s*U-t*g*U)*se,e[15]=(u*x*o-S*g*o+S*s*b-t*x*b-u*s*E+t*g*E)*se,this}scale(e){const t=this.elements,s=e.x,o=e.y,h=e.z;return t[0]*=s,t[4]*=o,t[8]*=h,t[1]*=s,t[5]*=o,t[9]*=h,t[2]*=s,t[6]*=o,t[10]*=h,t[3]*=s,t[7]*=o,t[11]*=h,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],s=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],o=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,s,o))}makeTranslation(e,t,s){return e instanceof Z?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,s,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),s=Math.sin(e);return this.set(1,0,0,0,0,t,-s,0,0,s,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,0,s,0,0,1,0,0,-s,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,-s,0,0,s,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const s=Math.cos(t),o=Math.sin(t),h=1-s,u=e.x,g=e.y,b=e.z,f=h*u,S=h*g;return this.set(f*u+s,f*g-o*b,f*b+o*g,0,f*g+o*b,S*g+s,S*b-o*u,0,f*b-o*g,S*b+o*u,h*b*b+s,0,0,0,0,1),this}makeScale(e,t,s){return this.set(e,0,0,0,0,t,0,0,0,0,s,0,0,0,0,1),this}makeShear(e,t,s,o,h,u){return this.set(1,s,h,0,e,1,u,0,t,o,1,0,0,0,0,1),this}compose(e,t,s){const o=this.elements,h=t.x,u=t.y,g=t.z,b=t.w,f=h+h,S=u+u,x=g+g,E=h*f,M=h*S,z=h*x,D=u*S,U=u*x,B=g*x,ge=b*f,be=b*S,oe=b*x,W=s.x,ce=s.y,se=s.z;return o[0]=(1-(D+B))*W,o[1]=(M+oe)*W,o[2]=(z-be)*W,o[3]=0,o[4]=(M-oe)*ce,o[5]=(1-(E+B))*ce,o[6]=(U+ge)*ce,o[7]=0,o[8]=(z+be)*se,o[9]=(U-ge)*se,o[10]=(1-(E+D))*se,o[11]=0,o[12]=e.x,o[13]=e.y,o[14]=e.z,o[15]=1,this}decompose(e,t,s){const o=this.elements;let h=Ln.set(o[0],o[1],o[2]).length();const u=Ln.set(o[4],o[5],o[6]).length(),g=Ln.set(o[8],o[9],o[10]).length();this.determinant()<0&&(h=-h),e.x=o[12],e.y=o[13],e.z=o[14],rr.copy(this);const b=1/h,f=1/u,S=1/g;return rr.elements[0]*=b,rr.elements[1]*=b,rr.elements[2]*=b,rr.elements[4]*=f,rr.elements[5]*=f,rr.elements[6]*=f,rr.elements[8]*=S,rr.elements[9]*=S,rr.elements[10]*=S,t.setFromRotationMatrix(rr),s.x=h,s.y=u,s.z=g,this}equals(e){const t=this.elements,s=e.elements;for(let o=0;o<16;o++)if(t[o]!==s[o])return!1;return!0}fromArray(e,t=0){for(let s=0;s<16;s++)this.elements[s]=e[s+t];return this}toArray(e=[],t=0){const s=this.elements;return e[t]=s[0],e[t+1]=s[1],e[t+2]=s[2],e[t+3]=s[3],e[t+4]=s[4],e[t+5]=s[5],e[t+6]=s[6],e[t+7]=s[7],e[t+8]=s[8],e[t+9]=s[9],e[t+10]=s[10],e[t+11]=s[11],e[t+12]=s[12],e[t+13]=s[13],e[t+14]=s[14],e[t+15]=s[15],e}};ua.IDENTITY=Object.freeze(new ua);let fn=ua;const Ln=new Z,rr=new fn,Vd=new Z(0,0,0),jd=new Z(1,1,1),Ur=new Z,Gs=new Z,Rt=new Z;class De{constructor(e=void 0,t=void 0){this.min=e==null?new Z(1/0,1/0,1/0):new Z(e.x,e.y,e.z),this.max=t==null?new Z(-1/0,-1/0,-1/0):new Z(t.x,t.y,t.z)}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,s=e.length;t<s;t+=3)this.expandByPoint(ia.fromArray(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,s=e.length;t<s;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const s=ia.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(s),this.max.copy(e).add(s),this}clone(){return new De().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.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(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.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(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsPlane(e){let t,s;return e.normal.x>0?(t=e.normal.x*this.min.x,s=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,s=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,s+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,s+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,s+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,s+=e.normal.z*this.min.z),t<=-e.constant&&s>=-e.constant}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,ia).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Er[0].set(this.min.x,this.min.y,this.min.z).applyMatrix3d(e),Er[1].set(this.min.x,this.min.y,this.max.z).applyMatrix3d(e),Er[2].set(this.min.x,this.max.y,this.min.z).applyMatrix3d(e),Er[3].set(this.min.x,this.max.y,this.max.z).applyMatrix3d(e),Er[4].set(this.max.x,this.min.y,this.min.z).applyMatrix3d(e),Er[5].set(this.max.x,this.min.y,this.max.z).applyMatrix3d(e),Er[6].set(this.max.x,this.max.y,this.min.z).applyMatrix3d(e),Er[7].set(this.max.x,this.max.y,this.max.z).applyMatrix3d(e),this.setFromPoints(Er),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Er=[new Z,new Z,new Z,new Z,new Z,new Z,new Z,new Z],ia=new Z,Bo=new $e;class _t{constructor(e=void 0,t=void 0){this.min=e==null?new $e(1/0,1/0):new $e(e.x,e.y),this.max=t==null?new $e(-1/0,-1/0):new $e(t.x,t.y)}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,s=e.length;t<s;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const s=Bo.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(s),this.max.copy(e).add(s),this}clone(){return new _t().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.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(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new $e(0,0):new $e(0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new $e(0,0):new $e(0,0).subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Bo).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Fo=new Z,Gd=new Z,Wd=new Ti;class Ds{constructor(e=new Z(1,0,0),t=0){this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,s,o){return this.normal.set(e,t,s),this.constant=o,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,s){const o=Fo.subVectors(s,t).cross(Gd.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(o,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectsBox(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const s=t||Wd.getNormalMatrix(e),o=this.coplanarPoint(Fo).applyMatrix3d(e),h=this.normal.applyMatrix3(s).normalize();return this.constant=-o.dot(h),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new Ds().copy(this)}}class Me extends $e{static pointArrayToNumberArray(e){const t=new Array(e.length*2);return e.forEach((s,o)=>{s.toArray(t,o*2)}),t}}class Y extends Z{static pointArrayToNumberArray(e,t=!0){const s=t?3:2,o=new Array(e.length*s);return e.forEach((h,u)=>{h.toArray(o,u*s)}),o}}const Uo=new fn,Vo=new Hr,Xh=class da{constructor(e=0,t=0,s=0,o=da.DEFAULT_ORDER){this._x=e,this._y=t,this._z=s,this._order=o}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,s,o=this._order){return this._x=e,this._y=t,this._z=s,this._order=o,this._onChangeCallback(),this}clone(){return new da(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,s=!0){const o=e.elements,h=o[0],u=o[4],g=o[8],b=o[1],f=o[5],S=o[9],x=o[2],E=o[6],M=o[10];switch(t){case"XYZ":this._y=Math.asin(kr(g,-1,1)),Math.abs(g)<.9999999?(this._x=Math.atan2(-S,M),this._z=Math.atan2(-u,h)):(this._x=Math.atan2(E,f),this._z=0);break;case"YXZ":this._x=Math.asin(-kr(S,-1,1)),Math.abs(S)<.9999999?(this._y=Math.atan2(g,M),this._z=Math.atan2(b,f)):(this._y=Math.atan2(-x,h),this._z=0);break;case"ZXY":this._x=Math.asin(kr(E,-1,1)),Math.abs(E)<.9999999?(this._y=Math.atan2(-x,M),this._z=Math.atan2(-u,f)):(this._y=0,this._z=Math.atan2(b,h));break;case"ZYX":this._y=Math.asin(-kr(x,-1,1)),Math.abs(x)<.9999999?(this._x=Math.atan2(E,M),this._z=Math.atan2(b,h)):(this._x=0,this._z=Math.atan2(-u,f));break;case"YZX":this._z=Math.asin(kr(b,-1,1)),Math.abs(b)<.9999999?(this._x=Math.atan2(-S,f),this._y=Math.atan2(-x,h)):(this._x=0,this._y=Math.atan2(g,M));break;case"XZY":this._z=Math.asin(-kr(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(E,f),this._y=Math.atan2(g,h)):(this._x=Math.atan2(-S,M),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,s===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,s=!0){return Uo.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Uo,t,s)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Vo.setFromEuler(this),this.setFromQuaternion(Vo,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Xh.DEFAULT_ORDER="XYZ";let Kh=Xh;class $h{constructor(){this._boundingBoxNeedsUpdate=!1}get boundingBoxNeedUpdate(){return this._boundingBoxNeedsUpdate}}class Ta extends $h{translate(e){return this.transform(new Ti().makeTranslation(e.x,e.y))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}class Ni extends Ta{constructor(){super(),this._loops=[]}add(e){this._loops.push(e),this._boundingBoxNeedsUpdate=!0}get loops(){return this._loops}get outter(){if(this._loops.length>0)return this._loops[0]}calculateBoundingBox(){const e=this.outter;return e?e.box:new _t}transform(e){return this._boundingBoxNeedsUpdate=!0,this}getPoints(e){const t=[];for(let s=0;s<this.loops.length;++s){const o=this.loops[s].getPoints(e);t.push(o)}return t}buildHierarchy(){var e;const t=this.getPoints(100),s=this.calculateBoundaryBoxes(t),o=this.sortBoundaryBoxesByAreas(s),h=new Map,u=o.length;for(let b=0;b<u;b++)h.set(o[b],{index:o[b],children:[]});const g={index:-1,children:[]};for(let b=0;b<u;b++){const f=o[b],S=t[f],x=s[f];let E=b+1;for(;E<u;E++){const M=o[E],z=t[M];if(s[M].containsBox(x)&&Vh.isPointInPolygon(S[Ee.randInt(0,S.length-1)],z)){(e=h.get(M))==null||e.children.push(h.get(f));break}}E===u&&g.children.push(h.get(f))}return g}calculateBoundaryBoxes(e){const t=[];return e.forEach(s=>{t.push(new _t().setFromPoints(s))}),t}sortBoundaryBoxesByAreas(e){const t=[];e.forEach((o,h)=>{const u=o.size,g=u.width*u.height;t.push({area:g,index:h})}),t.sort((o,h)=>o.area-h.area);const s=[];return t.forEach(o=>{s.push(o.index)}),s}}class Vn extends Ta{constructor(){super(),this.arcLengthDivisions=100}get startPoint(){return this.getPoint(0)}get endPoint(){return this.getPoint(1)}get length(){return this.getLength()}getPoint(e){throw new Error("AcGeCurve2d: .getPoint() not implemented.")}getPointAt(e){const t=this.getUtoTmapping(e);return this.getPoint(t)}getPoints(e=5){const t=[];for(let s=0;s<=e;s++)t.push(this.getPoint(s/e));return t}getSpacedPoints(e=5){const t=[];for(let s=0;s<=e;s++)t.push(this.getPointAt(s/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){const t=[];let s,o=this.getPoint(0),h=0;t.push(0);for(let u=1;u<=e;u++)s=this.getPoint(u/e),h+=s.distanceTo(o),t.push(h),o=s;return t}getUtoTmapping(e,t){const s=this.getLengths();let o=0;const h=s.length;let u;t?u=t:u=e*s[h-1];let g=0,b=h-1,f;for(;g<=b;)if(o=Math.floor(g+(b-g)/2),f=s[o]-u,f<0)g=o+1;else if(f>0)b=o-1;else{b=o;break}if(o=b,s[o]===u)return o/(h-1);const S=s[o],x=s[o+1]-S,E=(u-S)/x;return(o+E)/(h-1)}getTangent(e){let t=e-1e-4,s=e+1e-4;t<0&&(t=0),s>1&&(s=1);const o=this.getPoint(t),h=this.getPoint(s),u=new Me;return u.copy(h).sub(o).normalize(),u}getTangentAt(e){const t=this.getUtoTmapping(e);return this.getTangent(t)}}class Dn extends Vn{constructor(e,t,s,o,h){super();const u=+(e!==void 0)+ +(t!==void 0)+ +(s!==void 0)+ +(o!==void 0)+ +(h!==void 0);if(u==3)typeof e=="object"&&typeof t=="object"&&typeof s=="object"?this.createByThreePoints(e,t,s):this.createByStartEndPointsAndBulge(e,t,s);else if(u==5){const g=e;this.center=new Me(g.x,g.y),this.radius=t,this._clockwise=h,this._startAngle=this._clockwise?this._mirrorAngle(Ee.normalizeAngle(s)):Ee.normalizeAngle(s),this._endAngle=this._clockwise?this._mirrorAngle(Ee.normalizeAngle(o)):Ee.normalizeAngle(o)}else throw Ut.ILLEGAL_PARAMETERS}createByThreePoints(e,t,s){const o=(se,Ve)=>({x:(se.x+Ve.x)/2,y:(se.y+Ve.y)/2}),h=(se,Ve)=>(Ve.y-se.y)/(Ve.x-se.x),u=se=>-1/se,g=o(e,t),b=o(t,s),f=h(e,t),S=h(t,s),x=u(f),E=u(S),M=(se,Ve,Ye,We)=>{const xe=(We-Ve)/(se-Ye),Le=se*xe+Ve;return{x:xe,y:Le}},z=g.y-x*g.x,D=b.y-E*b.x,U=M(x,z,E,D),B=Math.sqrt(Math.pow(e.x-U.x,2)+Math.pow(e.y-U.y,2)),ge=(se,Ve)=>Math.atan2(se.y-Ve.y,se.x-Ve.x),be=ge(e,U),oe=ge(t,U),W=ge(s,U),ce=W>be&&W<oe||be>W&&be<oe||oe>W&&oe<be;this.center=U,this.radius=B,this._clockwise=!ce,this._startAngle=be,this._endAngle=W}createByStartEndPointsAndBulge(e,t,s){let o,h,u;s<0?(o=Math.atan(-s)*4,h=new $e(e),u=new $e(t)):(o=Math.atan(s)*4,h=new $e(t),u=new $e(e));const g=new $e().subVectors(u,h),b=g.length(),f=new $e().addVectors(h,g.multiplyScalar(.5)),S=Math.abs(b/2/Math.tan(o/2)),x=g.normalize();let E;if(o<Math.PI){const M=new $e(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=f.add(M.multiplyScalar(-S))}else{const M=new $e(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=f.add(M.multiplyScalar(S))}s<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=s<0,this.center=E,this.radius=u.sub(E).length()}get center(){return this._center}set center(e){this._center=new Me(e.x,e.y),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(e){this._radius=e,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._clockwise?this._mirrorAngle(this._startAngle):this._startAngle}set startAngle(e){this._startAngle=this._clockwise?this._mirrorAngle(Ee.normalizeAngle(e)):Ee.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._clockwise?this._mirrorAngle(this._endAngle):this._endAngle}set endAngle(e){const t=this.startAngle==0&&e==nt?e:Ee.normalizeAngle(e);this._endAngle=this._clockwise?this._mirrorAngle(t):t,this._boundingBoxNeedsUpdate=!0}_mirrorAngle(e){return(360-e*180/Math.PI)%360*Math.PI/180}_getInternalAngle(e){return this._clockwise?this._mirrorAngle(e):e}get deltaAngle(){const e=this._getInternalAngle(this.startAngle),t=this._getInternalAngle(this.endAngle);return this.clockwise?Ee.normalizeAngle(e-t):Ee.normalizeAngle(t-e)}get clockwise(){return this._clockwise}set clockwise(e){this._clockwise=e,this._boundingBoxNeedsUpdate=!0}get startPoint(){return this.getPointAtAngle(this.startAngle)}get endPoint(){return this.getPointAtAngle(this.endAngle)}get midPoint(){const e=this._getInternalAngle(this.startAngle),t=this._getInternalAngle(this.endAngle),s=Ee.normalizeAngle((e+t)/2),o=this._clockwise?this._mirrorAngle(s):s;return this.getPointAtAngle(o)}get closed(){const e=this._getInternalAngle(this.startAngle),t=this._getInternalAngle(this.endAngle);return Math.abs(t-e)/Math.PI%2==0}calculateBoundingBox(){const e=[this.startPoint,this.endPoint],t=[0,Math.PI/2,Math.PI,3*Math.PI/2];for(const h of t){const u=this._getInternalAngle(h);Ee.isBetweenAngle(u,this._getInternalAngle(this.startAngle),this._getInternalAngle(this.endAngle),this.clockwise)&&e.push(this.getPointAtAngle(h))}const s=e.map(h=>h.x),o=e.map(h=>h.y);return new _t(new Me(Math.min(...s),Math.min(...o)),new Me(Math.max(...s),Math.max(...o)))}get length(){return Math.abs(this.deltaAngle*this.radius)}transform(e){return this._boundingBoxNeedsUpdate=!0,this}clone(){return new Dn(this.center.clone(),this.radius,this._startAngle,this._endAngle,this.clockwise)}getPointAtAngle(e){const t=this._getInternalAngle(e),s=this.center.x+this.radius*Math.cos(t),o=this.center.y+this.radius*Math.sin(t);return new Me(s,o)}getPoints(e=100){const t=[];let s=this.deltaAngle,o=this._getInternalAngle(this.startAngle);if(this.closed&&(s=nt,o=0),this.clockwise)for(let h=0;h<=e;h++){const u=o-s*(h/e),g=this._clockwise?this._mirrorAngle(u):u,b=this.getPointAtAngle(g);t.push(new Me(b.x,b.y))}else for(let h=0;h<=e;h++){const u=o+s*(h/e),g=this._clockwise?this._mirrorAngle(u):u,b=this.getPointAtAngle(g);t.push(new Me(b.x,b.y))}return t}}class Hd extends $h{translate(e){return this.transform(new fn().makeTranslation(e.x,e.y,e.z))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}class Rs extends Hd{}class qr extends Rs{constructor(e,t){super(),this._start=new Y(e),this._end=new Y(t)}get startPoint(){return this._start}set startPoint(e){this._start.copy(e),this._boundingBoxNeedsUpdate=!0}get endPoint(){return this._end}set endPoint(e){this._end.copy(e),this._boundingBoxNeedsUpdate=!0}get direction(){return new Z().subVectors(this.endPoint,this.startPoint).normalize()}get midPoint(){return new Y((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(e){return this.project(e).distanceTo(e)<1e-6}at(e,t){return this.delta(t).multiplyScalar(e).add(this._start)}atLength(e,t=!1){if(t){const s=this.delta(hn).normalize();return new Y(this._start).addScaledVector(s,e)}else{const s=this.delta(hn).normalize();return new Y(this._end).addScaledVector(s,e)}}extend(e,t=!1){if(t){const s=hn.subVectors(this._start,this._end).normalize();this._start=new Y(this._start).addScaledVector(s,e)}else{const s=this.delta(hn).normalize();this._end=new Y(this._end).addScaledVector(s,e)}return this._boundingBoxNeedsUpdate=!0,this}closestPointToPointParameter(e,t){jo.subVectors(e,this._start),Ws.subVectors(this.endPoint,this.startPoint);const s=Ws.dot(Ws);let o=Ws.dot(jo)/s;return t&&(o=Ee.clamp(o,0,1)),o}closestPointToPoint(e,t,s){const o=this.closestPointToPointParameter(e,t);return this.delta(s).multiplyScalar(o).add(this._start)}delta(e){return e.subVectors(this._end,this._start)}distanceSq(){return this._start.distanceToSquared(this._end)}distance(){return this._start.distanceTo(this._end)}project(e){const t=this.direction,s=hn.subVectors(e,this.startPoint).dot(t);return new Y().copy(t).multiplyScalar(s).add(this.startPoint)}perpPoint(e){const t=this.direction,s=this.startPoint,o=hn.subVectors(e,s).dot(t),h=hn.copy(t).multiplyScalar(o);return new Y().addVectors(s,h)}calculateBoundingBox(){const e=new Y(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y),Math.min(this._start.z,this._end.z)),t=new Y(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 De(e,t)}transform(e){return this._start.applyMatrix3d(e),this._end.applyMatrix3d(e),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(e){return this.startPoint=e.startPoint,this.endPoint=e.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new qr(this._start.clone(),this._end.clone())}}const hn=new Z,jo=new Z,Ws=new Z;class pn extends Rs{static computeCenterPoint(e,t,s){const o=new Z().addVectors(e,t).multiplyScalar(.5),h=new Z().addVectors(e,s).multiplyScalar(.5),u=new Z().subVectors(t,e),g=new Z().subVectors(s,e),b=new Z().crossVectors(u,g).normalize();if(b.lengthSq()===0)return console.error("Points are collinear and cannot form a valid arc."),null;const f=new Z().crossVectors(u,b).normalize(),S=new Z().crossVectors(g,b).normalize(),x=f.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),E=S.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),M=new qr(o,o.clone().add(x)),z=new qr(h,h.clone().add(E)),D=new Z;return M.closestPointToPoint(z.startPoint,!0,D)?D:(console.error("Cannot find a valid center for the arc."),null)}static createByThreePoints(e,t,s){const o=pn.computeCenterPoint(e,t,s);if(o){const h=o.distanceTo(e),u=new Z().subVectors(e,o),g=new Z().subVectors(t,o),b=Math.atan2(u.y,u.x),f=Math.atan2(g.y,g.x);return new pn(o,h,b,f,Z.Z_AXIS)}}constructor(e,t,s,o,h,u=Z.X_AXIS){super(),this.center=e,this.radius=t,this.startAngle=s,this.endAngle=o,this.normal=h,this.refVec=u,(o-s)%nt==0?(this.startAngle=0,this.endAngle=nt):(this.startAngle=s,this.endAngle=o)}get center(){return this._center}set center(e){this._center=new Y(e.x,e.y,e.z||0),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(e){if(e<0)throw Ut.ILLEGAL_PARAMETERS;this._radius=e,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(e){this._startAngle=Ee.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(e){this._endAngle=this.startAngle==0&&e==nt?e:Ee.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return Ee.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(e){this._normal=new Z(e.x,e.y,e.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get refVec(){return this._refVec}set refVec(e){this._refVec=new Z(e.x,e.y,e.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 e=[this.startAngle,this.endAngle];for(let b=0;b<2*Math.PI;b+=Math.PI/2)Ee.isBetweenAngle(b,this.startAngle,this.endAngle)&&e.push(b);let t=1/0,s=1/0,o=1/0,h=-1/0,u=-1/0,g=-1/0;for(const b of e){const f=this.getPointAtAngle(b);f.x<t&&(t=f.x),f.y<s&&(s=f.y),f.z<o&&(o=f.z),f.x>h&&(h=f.x),f.y>u&&(u=f.y),f.z>g&&(g=f.z)}return new De({x:t,y:s,z:o},{x:h,y:u,z:g})}get closed(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0}getPoints(e){const t=[];let s=this.deltaAngle,o=this.startAngle;this.closed&&(s=nt,o=0);for(let h=0;h<=e;h++){const u=o+s*(h/e),g=this.getPointAtAngle(u);t.push(g)}return t}transform(e){const t=aa.copy(this.refVec).applyAxisAngle(this.normal,this.startAngle).multiplyScalar(this.radius),s=aa.copy(this.refVec).applyAxisAngle(this.normal,this.endAngle).multiplyScalar(this.radius);return this.center.applyMatrix3d(e),t.applyMatrix3d(e),s.applyMatrix3d(e),this.normal.applyMatrix3d(e).normalize(),this.refVec.applyMatrix3d(e).normalize(),this.startAngle=this.getAngle(t),this.endAngle=this.getAngle(s),this._boundingBoxNeedsUpdate=!0,this}copy(e){return this.center=e.center,this.radius=e.radius,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.normal=e.normal,this.refVec=e.refVec,this._boundingBoxNeedsUpdate=!0,this}clone(){return new pn(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)}getAngle(e){return e.sub(this.center),Math.atan2(e.dot(aa.crossVectors(this.refVec,this.normal)),e.dot(this.refVec))}getPointAtAngle(e){const t=this.normal,s=this.refVec,o={x:t.y*s.z-t.z*s.y,y:t.z*s.x-t.x*s.z,z:t.x*s.y-t.y*s.x},h=this.center,u=this.radius;return new Y(h.x+u*(s.x*Math.cos(e)+o.x*Math.sin(e)),h.y+u*(s.y*Math.cos(e)+o.y*Math.sin(e)),h.z+u*(s.z*Math.cos(e)+o.z*Math.sin(e)))}get plane(){const e=new Z(this.center).distanceTo(Ia);return new Ds(this.normal,e)}}const aa=new Z;class Ci extends Vn{constructor(e,t,s,o=0,h=nt,u=!1,g=0){super(),this.center=e,this.majorAxisRadius=t,this.minorAxisRadius=s,(h-o)%nt==0?(this.startAngle=0,this.endAngle=nt):(this.startAngle=o,this.endAngle=h),this.clockwise=u,this.rotation=g}get center(){return this._center}set center(e){this._center=new Y(e.x,e.y,e.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(e){if(e<0)throw Ut.ILLEGAL_PARAMETERS;this._majorAxisRadius=e,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(e){if(e<0)throw Ut.ILLEGAL_PARAMETERS;this._minorAxisRadius=e,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(e){this._startAngle=Ee.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(e){this._endAngle=this.startAngle==0&&e==nt?e:Ee.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0}get clockwise(){return this._clockwise}set clockwise(e){this._clockwise=e,this._boundingBoxNeedsUpdate=!0}get rotation(){return this._rotation}set rotation(e){this._rotation=e,this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return Ee.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}calculateBoundingBox(){let e=1/0,t=1/0,s=-1/0,o=-1/0;for(let h=0;h<=100;h++){const u=this.getPoint(h/100);e=Math.min(e,u.x),t=Math.min(t,u.y),s=Math.max(s,u.x),o=Math.max(o,u.y)}return new _t({x:e,y:t},{x:s,y:o})}get closed(){return this.deltaAngle==0}getPoint(e){const t=Math.PI*2;let s=this.endAngle-this.startAngle;const o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=t;for(;s>t;)s-=t;s<Number.EPSILON&&(o?s=0:s=t),this.clockwise===!0&&!o&&(s===t?s=-t:s=s-t);const h=this.startAngle+e*s;let u=this.center.x+this.majorAxisRadius*Math.cos(h),g=this.center.y+this.minorAxisRadius*Math.sin(h);if(this.rotation!==0){const b=Math.cos(this.rotation),f=Math.sin(this.rotation),S=u-this.center.x,x=g-this.center.y;u=S*b-x*f+this.center.x,g=S*f+x*b+this.center.y}return new Me(u,g)}transform(e){return this._boundingBoxNeedsUpdate=!0,this}copy(e){return this.center=e.center,this.majorAxisRadius=e.majorAxisRadius,this.minorAxisRadius=e.minorAxisRadius,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.clockwise=e.clockwise,this.rotation=e.rotation,this}clone(){return new Ci(this.center,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle,this.clockwise,this.rotation)}}class Li extends Rs{constructor(e,t,s,o,h,u=0,g=nt){super(),this.center=e,this.normal=t,this.majorAxis=s,this.majorAxisRadius=o,this.minorAxisRadius=h;const b=Math.abs(g-u);Math.abs(b-nt)<1e-10||Math.abs(b-2*nt)<1e-10?(this.startAngle=0,this.endAngle=nt):(this.startAngle=u,this.endAngle=g)}get center(){return this._center}set center(e){this._center=new Y(e.x,e.y,e.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(e){if(e<0)throw Ut.ILLEGAL_PARAMETERS;this._majorAxisRadius=e,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(e){if(e<0)throw Ut.ILLEGAL_PARAMETERS;this._minorAxisRadius=e,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(e){this._startAngle=Ee.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(e){this._endAngle=this.startAngle==0&&e==nt?e:Ee.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){const e=this.endAngle-this.startAngle;return Math.abs(e-nt)<1e-10?nt:Ee.normalizeAngle(e)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}get clockwise(){return this.deltaAngle<=0}get normal(){return this._normal}set normal(e){this._normal=new Z(e.x,e.y,e.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get majorAxis(){return this._majorAxis}set majorAxis(e){this._majorAxis=new Z(e.x,e.y,e.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 Ea.equal(this.majorAxisRadius,this.minorAxisRadius)}get length(){if(this.isCircular)return this.majorAxisRadius*Math.abs(this.deltaAngle);const e=1e3,t=this.deltaAngle/e;let s=0,o=this.getPointAtAngle(this.startAngle);for(let h=1;h<=e;h++){const u=this.startAngle+h*t,g=this.getPointAtAngle(u),b=g.x-o.x,f=g.y-o.y,S=g.z-o.z;s+=Math.sqrt(b*b+f*f+S*S),o=g}return s}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 e=[this.startAngle,this.endAngle];for(let b=0;b<2*Math.PI;b+=Math.PI/2)Ee.isBetweenAngle(b,this.startAngle,this.endAngle)&&e.push(b);let t=1/0,s=1/0,o=1/0,h=-1/0,u=-1/0,g=-1/0;for(const b of e){const f=this.getPointAtAngle(b);f.x<t&&(t=f.x),f.y<s&&(s=f.y),f.z<o&&(o=f.z),f.x>h&&(h=f.x),f.y>u&&(u=f.y),f.z>g&&(g=f.z)}return new De({x:t,y:s,z:o},{x:h,y:u,z:g})}else{let e=1/0,t=1/0,s=1/0,o=-1/0,h=-1/0,u=-1/0;for(let g=0;g<=100;g++){const b=this.startAngle+this.deltaAngle*(g/100),f=this.getPointAtAngle(b);e=Math.min(e,f.x),t=Math.min(t,f.y),s=Math.min(s,f.z),o=Math.max(o,f.x),h=Math.max(h,f.y),u=Math.max(u,f.z)}return new De({x:e,y:t,z:s},{x:o,y:h,z:u})}}get closed(){return this.deltaAngle==0}getPoints(e=100){const t=[];let s=this.deltaAngle,o=this.startAngle;this.closed&&(s=nt,o=0);for(let h=0;h<=e;h++){const u=o+s*(h/e),g=this.getPointAtAngle(u);t.push(g)}return t}getPointAtAngle(e){const t=Math.cos(e),s=Math.sin(e),o=this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(s),h=this.majorAxis.clone().multiplyScalar(t*this.majorAxisRadius).add(o);return new Y(this.center.x+h.x,this.center.y+h.y,this.center.z+h.z)}contains(e){const t=new Z(e).sub(this.center),s=t.dot(this.majorAxis),o=t.dot(this.minorAxis),h=s/this.majorAxisRadius,u=o/this.minorAxisRadius;return h*h+u*u<=1}transform(e){return this._boundingBoxNeedsUpdate=!0,this}copy(e){return this.center=e.center,this.normal=e.normal,this.majorAxis=e.majorAxis,this.majorAxisRadius=e.majorAxisRadius,this.minorAxisRadius=e.minorAxisRadius,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this._boundingBoxNeedsUpdate=!0,this}clone(){return new Li(this.center,this.normal,this.majorAxis,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle)}get plane(){const e=new Z(this.center).distanceTo(Ia);return new Ds(this.normal,e)}}class Bs extends Vn{constructor(e=null,t=!1){super(),this._vertices=e||new Array,this._closed=t}get numberOfVertices(){return this._vertices.length}get closed(){return this._closed}get startPoint(){if(this.numberOfVertices>0){const e=this._vertices[0];return new Me(e.x,e.y)}throw new Error("Start point does not exist in an empty polyline.")}get endPoint(){const e=this.numberOfVertices;if(e>0)if(this.closed){const t=this._vertices[0];return new Me(t.x,t.y)}else{const t=this._vertices[e-1];return new Me(t.x,t.y)}throw new Error("End point does not exist in an empty polyline.")}get length(){let e=0;const t=this._vertices.length;for(let s=0;s<t;++s){const o=this._vertices[s];let h=null;if(s<t-1?h=this._vertices[s+1]:s==t-1&&this.closed&&(h=this._vertices[0]),h)if(o.bulge){const u=new Dn(o,h,o.bulge);e+=u.length}else e+=new Me(o.x,o.y).distanceTo(h)}return e}set closed(e){this._closed=e,this._boundingBoxNeedsUpdate=!0}addVertexAt(e,t){e<=0?this._vertices.unshift(t):this._vertices.splice(e,0,t),this._boundingBoxNeedsUpdate=!0}getPointAt(e){const t=this._vertices[e];return new Me(t.x,t.y)}calculateBoundingBox(){const e=this.getPoints(100);return new _t().setFromPoints(e)}transform(e){return this._boundingBoxNeedsUpdate=!0,this}getPoints3d(e,t){const s=[];return this.getPoints(e).forEach(o=>s.push(new Y().set(o.x,o.y,t))),s}getPoints(e){const t=[],s=this._vertices.length;for(let o=0;o<s;++o){const h=this._vertices[o];if(h.bulge){let u=null;if(o<s-1?u=this._vertices[o+1]:o==s-1&&this.closed&&(u=this._vertices[0]),u){const g=new Dn(h,u,h.bulge).getPoints(e),b=g.length;for(let f=0;f<b;++f){const S=g[f];t.push(new Me(S.x,S.y))}}}else t.push(new Me(h.x,h.y)),o==s-1&&this.closed&&t.push(t[0])}return t}}class Oi extends Vn{constructor(e,t){super(),this._start=new Me(e),this._end=new Me(t)}get startPoint(){return this._start}set startPoint(e){this._start.copy(e),this._boundingBoxNeedsUpdate=!0}get endPoint(){return this._end}set endPoint(e){this._end.copy(e),this._boundingBoxNeedsUpdate=!0}getPoints(){return[this.startPoint,this.endPoint]}get length(){return this.startPoint.distanceTo(this.endPoint)}calculateBoundingBox(){const e=new Me(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y)),t=new Me(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y));return new _t(e,t)}transform(e){return this._start.applyMatrix2d(e),this._end.applyMatrix2d(e),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(e){return this.startPoint=e.startPoint,this.endPoint=e.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new Oi(this._start.clone(),this._end.clone())}}class Zh extends Vn{constructor(e=[]){super(),this._curves=e}get curves(){return this._curves}add(e){this._curves.push(e),this._boundingBoxNeedsUpdate=!0}get numberOfEdges(){return this._curves.length}get startPoint(){if(this._curves.length>0){const e=this._curves[0].startPoint;return new Me(e.x,e.y)}throw new Error("Start point does not exist in an empty loop.")}get endPoint(){return this.startPoint}get length(){let e=0;return this._curves.forEach(t=>{e+=t.length}),e}calculateBoundingBox(){const e=this.getPoints(100),t=new _t;return t.setFromPoints(e),t}transform(e){return this._boundingBoxNeedsUpdate=!0,this}get closed(){return!0}getPoints(e){const t=[];return this.curves.forEach(s=>{s.getPoints(e).forEach(o=>{t.push(new Me(o.x,o.y))})}),t}}function qd(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Qh={exports:{}};(function(i,e){(function(t){i.exports=t()})(function(){var t={},s=this;new Function("try {return this===window;}catch(e){ return false;}");var o=new Function("try {return this===global;}catch(e){return false;}"),h=new Function("try {return typeof importScripts === 'function';}catch(e){return false;}");if(o()&&h(),o()||h()){var u=s;if(h()){var g=function(b,f){var S=s;return b.split(".").forEach(function(x){S&&(S=S[x])}),S?S[f]:null};onmessage=function(b){if(!(!b.data.className||!b.data.methodName)){var f=g(b.data.className,b.data.methodName);if(!f)return console.error("could not find "+b.data.className+"."+b.data.methodName);postMessage({result:f.apply(null,b.data.args),id:b.data.id})}}}}return function(b,f,S){f.geom=f.geom||{},f.exe=f.exe||{},f.eval=f.eval||{},f.core=f.core||{},f.promhx=f.promhx||{};var x={},E=function(){return Te.__string_rec(this,"")};function M(r,n){function a(){}a.prototype=r;var l=new a;for(var c in n)l[c]=n[c];return n.toString!==Object.prototype.toString&&(l.toString=n.toString),l}var z=function(){};x.HxOverrides=z,z.__name__=["HxOverrides"],z.strDate=function(r){var n=r.length;switch(n){case 8:var a=r.split(":"),l=new Date;return l.setTime(0),l.setUTCHours(a[0]),l.setUTCMinutes(a[1]),l.setUTCSeconds(a[2]),l;case 10:var c=r.split("-");return new Date(c[0],c[1]-1,c[2],0,0,0);case 19:var d=r.split(" "),p=d[0].split("-"),_=d[1].split(":");return new Date(p[0],p[1]-1,p[2],_[0],_[1],_[2]);default:throw new Q("Invalid date format : "+r)}},z.cca=function(r,n){var a=r.charCodeAt(n);if(a==a)return a},z.substr=function(r,n,a){return n!=null&&n!=0&&a!=null&&a<0?"":(a==null&&(a=r.length),n<0?(n=r.length+n,n<0&&(n=0)):a<0&&(a=r.length+a-n),r.substr(n,a))},z.iter=function(r){return{cur:0,arr:r,hasNext:function(){return this.cur<this.arr.length},next:function(){return this.arr[this.cur++]}}};var D=function(){};x.Lambda=D,D.__name__=["Lambda"],D.fold=function(r,n,a){for(var l=Xt(r)();l.hasNext();){var c=l.next();a=n(c,a)}return a};var U=function(){this.length=0};x.List=U,U.__name__=["List"],U.prototype={add:function(r){var n=[r];this.h==null?this.h=n:this.q[1]=n,this.q=n,this.length++},pop:function(){if(this.h==null)return null;var r=this.h[0];return this.h=this.h[1],this.h==null&&(this.q=null),this.length--,r},isEmpty:function(){return this.h==null},__class__:U},Math.__name__=["Math"];var B=function(){};x.Reflect=B,B.__name__=["Reflect"],B.field=function(r,n){try{return r[n]}catch(a){return a instanceof Q&&(a=a.val),null}},B.callMethod=function(r,n,a){return n.apply(r,a)},B.fields=function(r){var n=[];if(r!=null){var a=Object.prototype.hasOwnProperty;for(var l in r)l!="__id__"&&l!="hx__closures__"&&a.call(r,l)&&n.push(l)}return n},B.isFunction=function(r){return typeof r=="function"&&!(r.__name__||r.__ename__)},B.deleteField=function(r,n){return Object.prototype.hasOwnProperty.call(r,n)?(delete r[n],!0):!1};var ge=function(){};x.Std=ge,ge.__name__=["Std"],ge.string=function(r){return Te.__string_rec(r,"")},ge.parseFloat=function(r){return parseFloat(r)};var be=function(){this.b=""};x.StringBuf=be,be.__name__=["StringBuf"],be.prototype={add:function(r){this.b+=ge.string(r)},__class__:be};var oe=function(){};x.StringTools=oe,oe.__name__=["StringTools"],oe.fastCodeAt=function(r,n){return r.charCodeAt(n)};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(r){var n=["TClass",6,r];return n.__enum__=W,n.toString=E,n},W.TEnum=function(r){var n=["TEnum",7,r];return n.__enum__=W,n.toString=E,n},W.TUnknown=["TUnknown",8],W.TUnknown.toString=E,W.TUnknown.__enum__=W;var ce=function(){};x.Type=ce,ce.__name__=["Type"],ce.getClassName=function(r){var n=r.__name__;return n==null?null:n.join(".")},ce.getEnumName=function(r){var n=r.__ename__;return n.join(".")},ce.resolveClass=function(r){var n=x[r];return n==null||!n.__name__?null:n},ce.resolveEnum=function(r){var n=x[r];return n==null||!n.__ename__?null:n},ce.createEmptyInstance=function(r){function n(){}return n.prototype=r.prototype,new n},ce.createEnum=function(r,n,a){var l=B.field(r,n);if(l==null)throw new Q("No such constructor "+n);if(B.isFunction(l)){if(a==null)throw new Q("Constructor "+n+" need parameters");return B.callMethod(r,l,a)}if(a!=null&&a.length!=0)throw new Q("Constructor "+n+" does not need parameters");return l},ce.getEnumConstructs=function(r){var n=r.__constructs__;return n.slice()},ce.typeof=function(r){var n=typeof r;switch(n){case"boolean":return W.TBool;case"string":return W.TClass(String);case"number":return Math.ceil(r)==r%2147483648?W.TInt:W.TFloat;case"object":if(r==null)return W.TNull;var a=r.__enum__;if(a!=null)return W.TEnum(a);var l=Te.getClass(r);return l!=null?W.TClass(l):W.TObject;case"function":return r.__name__||r.__ename__?W.TObject:W.TFunction;case"undefined":return W.TNull;default:return W.TUnknown}};var se=function(){};x["haxe.IMap"]=se,se.__name__=["haxe","IMap"];var Ve=function(r,n){this.high=r,this.low=n};x["haxe._Int64.___Int64"]=Ve,Ve.__name__=["haxe","_Int64","___Int64"],Ve.prototype={__class__:Ve};var Ye=function(){this.buf=new be,this.cache=[],this.useCache=Ye.USE_CACHE,this.useEnumIndex=Ye.USE_ENUM_INDEX,this.shash=new mt,this.scount=0};x["haxe.Serializer"]=Ye,Ye.__name__=["haxe","Serializer"],Ye.prototype={toString:function(){return this.buf.b},serializeString:function(r){var n=this.shash.get(r);if(n!=null){this.buf.b+="R",n==null?this.buf.b+="null":this.buf.b+=""+n;return}this.shash.set(r,this.scount++),this.buf.b+="y",r=encodeURIComponent(r),r.length==null?this.buf.b+="null":this.buf.b+=""+r.length,this.buf.b+=":",r==null?this.buf.b+="null":this.buf.b+=""+r},serializeRef:function(r){for(var n=typeof r,a=0,l=this.cache.length;a<l;){var c=a++,d=this.cache[c];if(typeof d==n&&d==r)return this.buf.b+="r",c==null?this.buf.b+="null":this.buf.b+=""+c,!0}return this.cache.push(r),!1},serializeFields:function(r){for(var n=0,a=B.fields(r);n<a.length;){var l=a[n];++n,this.serializeString(l),this.serialize(B.field(r,l))}this.buf.b+="g"},serialize:function(r){{var n=ce.typeof(r);switch(n[1]){case 0:this.buf.b+="n";break;case 1:var a=r;if(a==0){this.buf.b+="z";return}this.buf.b+="i",a==null?this.buf.b+="null":this.buf.b+=""+a;break;case 2:var l=r;isNaN(l)?this.buf.b+="k":isFinite(l)?(this.buf.b+="d",l==null?this.buf.b+="null":this.buf.b+=""+l):l<0?this.buf.b+="m":this.buf.b+="p";break;case 3:r?this.buf.b+="t":this.buf.b+="f";break;case 6:var c=n[2];if(c==String){this.serializeString(r);return}if(this.useCache&&this.serializeRef(r))return;switch(c){case Array:var d=0;this.buf.b+="a";for(var p=r.length,_=0;_<p;){var v=_++;r[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(r[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 U:this.buf.b+="l";for(var w=r,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 k=r;this.buf.b+="v",this.buf.add(k.getTime());break;case mt:this.buf.b+="b";for(var T=r,L=T.keys();L.hasNext();){var C=L.next();this.serializeString(C),this.serialize(Vi[C]!=null?T.getReserved(C):T.h[C])}this.buf.b+="h";break;case xe:this.buf.b+="q";for(var R=r,O=R.keys();O.hasNext();){var F=O.next();this.buf.b+=":",F==null?this.buf.b+="null":this.buf.b+=""+F,this.serialize(R.h[F])}this.buf.b+="h";break;case Le:this.buf.b+="M";for(var V=r,q=V.keys();q.hasNext();){var J=q.next(),H=B.field(J,"__id__");B.deleteField(J,"__id__"),this.serialize(J),J.__id__=H,this.serialize(V.h[J.__id__])}this.buf.b+="h";break;case It:for(var j=r,K=0,ee=j.length-2,te=new be,ie=Ye.BASE64;K<ee;){var he=j.get(K++),ae=j.get(K++),ue=j.get(K++);te.add(ie.charAt(he>>2)),te.add(ie.charAt((he<<4|ae>>4)&63)),te.add(ie.charAt((ae<<2|ue>>6)&63)),te.add(ie.charAt(ue&63))}if(K==ee){var ne=j.get(K++),de=j.get(K++);te.add(ie.charAt(ne>>2)),te.add(ie.charAt((ne<<4|de>>4)&63)),te.add(ie.charAt(de<<2&63))}else if(K==ee+1){var X=j.get(K++);te.add(ie.charAt(X>>2)),te.add(ie.charAt(X<<4&63))}var pe=te.b;this.buf.b+="s",pe.length==null?this.buf.b+="null":this.buf.b+=""+pe.length,this.buf.b+=":",pe==null?this.buf.b+="null":this.buf.b+=""+pe;break;default:this.useCache&&this.cache.pop(),r.hxSerialize!=null?(this.buf.b+="C",this.serializeString(ce.getClassName(c)),this.useCache&&this.cache.push(r),r.hxSerialize(this),this.buf.b+="g"):(this.buf.b+="c",this.serializeString(ce.getClassName(c)),this.useCache&&this.cache.push(r),this.serializeFields(r))}break;case 4:if(Te.__instanceof(r,fo)){var Pe=ce.getClassName(r);this.buf.b+="A",this.serializeString(Pe)}else if(Te.__instanceof(r,_o))this.buf.b+="B",this.serializeString(ce.getEnumName(r));else{if(this.useCache&&this.serializeRef(r))return;this.buf.b+="o",this.serializeFields(r)}break;case 7:var Ge=n[2];if(this.useCache){if(this.serializeRef(r))return;this.cache.pop()}this.useEnumIndex?this.buf.b+="j":this.buf.b+="w",this.serializeString(ce.getEnumName(Ge)),this.useEnumIndex?(this.buf.b+=":",this.buf.b+=ge.string(r[1])):this.serializeString(r[0]),this.buf.b+=":";var Xe=r.length;this.buf.b+=ge.string(Xe-2);for(var Fe=2;Fe<Xe;){var Ke=Fe++;this.serialize(r[Ke])}this.useCache&&this.cache.push(r);break;case 5:throw new Q("Cannot serialize function");default:throw new Q("Cannot serialize "+ge.string(r))}}},__class__:Ye};var We=function(r){this.buf=r,this.length=r.length,this.pos=0,this.scache=[],this.cache=[];var n=We.DEFAULT_RESOLVER;n==null&&(n=ce,We.DEFAULT_RESOLVER=n),this.setResolver(n)};x["haxe.Unserializer"]=We,We.__name__=["haxe","Unserializer"],We.initCodes=function(){for(var r=[],n=0,a=We.BASE64.length;n<a;){var l=n++;r[We.BASE64.charCodeAt(l)]=l}return r},We.prototype={setResolver:function(r){r==null?this.resolver={resolveClass:function(n){return null},resolveEnum:function(n){return null}}:this.resolver=r},get:function(r){return this.buf.charCodeAt(r)},readDigits:function(){for(var r=0,n=!1,a=this.pos;;){var l=this.buf.charCodeAt(this.pos);if(l!=l)break;if(l==45){if(this.pos!=a)break;n=!0,this.pos++;continue}if(l<48||l>57)break;r=r*10+(l-48),this.pos++}return n&&(r*=-1),r},readFloat:function(){for(var r=this.pos;;){var n=this.buf.charCodeAt(this.pos);if(n>=43&&n<58||n==101||n==69)this.pos++;else break}return ge.parseFloat(z.substr(this.buf,r,this.pos-r))},unserializeObject:function(r){for(;;){if(this.pos>=this.length)throw new Q("Invalid object");if(this.buf.charCodeAt(this.pos)==103)break;var n=this.unserialize();if(typeof n!="string")throw new Q("Invalid object key");var a=this.unserialize();r[n]=a}this.pos++},unserializeEnum:function(r,n){if(this.get(this.pos++)!=58)throw new Q("Invalid enum format");var a=this.readDigits();if(a==0)return ce.createEnum(r,n);for(var l=[];a-- >0;)l.push(this.unserialize());return ce.createEnum(r,n,l)},unserialize:function(){var r=this.get(this.pos++);switch(r){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 n=this.readDigits();if(this.get(this.pos++)!=58||this.length-this.pos<n)throw new Q("Invalid string length");var a=z.substr(this.buf,this.pos,n);return this.pos+=n,a=decodeURIComponent(a.split("+").join(" ")),this.scache.push(a),a;case 107:return NaN;case 109:return-1/0;case 112:return 1/0;case 97:this.buf;var l=[];for(this.cache.push(l);;){var c=this.buf.charCodeAt(this.pos);if(c==104){this.pos++;break}if(c==117){this.pos++;var d=this.readDigits();l[l.length+d-1]=null}else l.push(this.unserialize())}return l;case 111:var p={};return this.cache.push(p),this.unserializeObject(p),p;case 114:var _=this.readDigits();if(_<0||_>=this.cache.length)throw new Q("Invalid reference");return this.cache[_];case 82:var v=this.readDigits();if(v<0||v>=this.scache.length)throw new Q("Invalid string reference");return this.scache[v];case 120:throw new Q(this.unserialize());case 99:var w=this.unserialize(),P=this.resolver.resolveClass(w);if(P==null)throw new Q("Class not found "+w);var A=ce.createEmptyInstance(P);return this.cache.push(A),this.unserializeObject(A),A;case 119:var I=this.unserialize(),k=this.resolver.resolveEnum(I);if(k==null)throw new Q("Enum not found "+I);var T=this.unserializeEnum(k,this.unserialize());return this.cache.push(T),T;case 106:var L=this.unserialize(),C=this.resolver.resolveEnum(L);if(C==null)throw new Q("Enum not found "+L);this.pos++;var R=this.readDigits(),O=ce.getEnumConstructs(C)[R];if(O==null)throw new Q("Unknown enum index "+L+"@"+R);var F=this.unserializeEnum(C,O);return this.cache.push(F),F;case 108:var V=new U;for(this.cache.push(V),this.buf;this.buf.charCodeAt(this.pos)!=104;)V.add(this.unserialize());return this.pos++,V;case 98:var q=new mt;for(this.cache.push(q),this.buf;this.buf.charCodeAt(this.pos)!=104;){var J=this.unserialize();q.set(J,this.unserialize())}return this.pos++,q;case 113:var H=new xe;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 Q("Invalid IntMap format");return H;case 77:var ee=new Le;for(this.cache.push(ee),this.buf;this.buf.charCodeAt(this.pos)!=104;){var te=this.unserialize();ee.set(te,this.unserialize())}return this.pos++,ee;case 118:var ie;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 he=z.substr(this.buf,this.pos,19);ie=z.strDate(he),this.pos+=19}else{var ae=this.readFloat(),ue=new Date;ue.setTime(ae),ie=ue}return this.cache.push(ie),ie;case 115:var ne=this.readDigits(),de=this.buf;if(this.get(this.pos++)!=58||this.length-this.pos<ne)throw new Q("Invalid bytes length");var X=We.CODES;X==null&&(X=We.initCodes(),We.CODES=X);var pe=this.pos,Pe=ne&3,Ge;Ge=(ne>>2)*3+(Pe>=2?Pe-1:0);for(var Xe=pe+(ne-Pe),Fe=It.alloc(Ge),Ke=0;pe<Xe;){var At=X[oe.fastCodeAt(de,pe++)],Ht=X[oe.fastCodeAt(de,pe++)];Fe.set(Ke++,At<<2|Ht>>4);var vt=X[oe.fastCodeAt(de,pe++)];Fe.set(Ke++,Ht<<4|vt>>2);var gt=X[oe.fastCodeAt(de,pe++)];Fe.set(Ke++,vt<<6|gt)}if(Pe>=2){var St=X[oe.fastCodeAt(de,pe++)],Tt=X[oe.fastCodeAt(de,pe++)];if(Fe.set(Ke++,St<<2|Tt>>4),Pe==3){var Kt=X[oe.fastCodeAt(de,pe++)];Fe.set(Ke++,Tt<<4|Kt>>2)}}return this.pos+=ne,this.cache.push(Fe),Fe;case 67:var or=this.unserialize(),$t=this.resolver.resolveClass(or);if($t==null)throw new Q("Class not found "+or);var Zt=ce.createEmptyInstance($t);if(this.cache.push(Zt),Zt.hxUnserialize(this),this.get(this.pos++)!=103)throw new Q("Invalid custom data");return Zt;case 65:var Qt=this.unserialize(),dr=this.resolver.resolveClass(Qt);if(dr==null)throw new Q("Class not found "+Qt);return dr;case 66:var Tn=this.unserialize(),Zr=this.resolver.resolveEnum(Tn);if(Zr==null)throw new Q("Enum not found "+Tn);return Zr}throw this.pos--,new Q("Invalid char "+this.buf.charAt(this.pos)+" at position "+this.pos)},__class__:We};var xe=function(){this.h={}};x["haxe.ds.IntMap"]=xe,xe.__name__=["haxe","ds","IntMap"],xe.__interfaces__=[se],xe.prototype={set:function(r,n){this.h[r]=n},remove:function(r){return this.h.hasOwnProperty(r)?(delete this.h[r],!0):!1},keys:function(){var r=[];for(var n in this.h)this.h.hasOwnProperty(n)&&r.push(n|0);return z.iter(r)},__class__:xe};var Le=function(){this.h={},this.h.__keys__={}};x["haxe.ds.ObjectMap"]=Le,Le.__name__=["haxe","ds","ObjectMap"],Le.__interfaces__=[se],Le.prototype={set:function(r,n){var a=r.__id__||(r.__id__=++Le.count);this.h[a]=n,this.h.__keys__[a]=r},keys:function(){var r=[];for(var n in this.h.__keys__)this.h.hasOwnProperty(n)&&r.push(this.h.__keys__[n]);return z.iter(r)},__class__:Le};var dt=x["haxe.ds.Option"]={__ename__:["haxe","ds","Option"],__constructs__:["Some","None"]};dt.Some=function(r){var n=["Some",0,r];return n.__enum__=dt,n.toString=E,n},dt.None=["None",1],dt.None.toString=E,dt.None.__enum__=dt;var mt=function(){this.h={}};x["haxe.ds.StringMap"]=mt,mt.__name__=["haxe","ds","StringMap"],mt.__interfaces__=[se],mt.prototype={set:function(r,n){Vi[r]!=null?this.setReserved(r,n):this.h[r]=n},get:function(r){return Vi[r]!=null?this.getReserved(r):this.h[r]},setReserved:function(r,n){this.rh==null&&(this.rh={}),this.rh["$"+r]=n},getReserved:function(r){return this.rh==null?null:this.rh["$"+r]},keys:function(){var r=this.arrayKeys();return z.iter(r)},arrayKeys:function(){var r=[];for(var n in this.h)this.h.hasOwnProperty(n)&&r.push(n);if(this.rh!=null)for(var n in this.rh)n.charCodeAt(0)==36&&r.push(n.substr(1));return r},__class__:mt};var It=function(r){this.length=r.byteLength,this.b=new ji(r),this.b.bufferValue=r,r.hxBytes=this,r.bytes=this.b};x["haxe.io.Bytes"]=It,It.__name__=["haxe","io","Bytes"],It.alloc=function(r){return new It(new Vs(r))},It.prototype={get:function(r){return this.b[r]},set:function(r,n){this.b[r]=n&255},__class__:It};var Je=x["haxe.io.Error"]={__ename__:["haxe","io","Error"],__constructs__:["Blocked","Overflow","OutsideBounds","Custom"]};Je.Blocked=["Blocked",0],Je.Blocked.toString=E,Je.Blocked.__enum__=Je,Je.Overflow=["Overflow",1],Je.Overflow.toString=E,Je.Overflow.__enum__=Je,Je.OutsideBounds=["OutsideBounds",2],Je.OutsideBounds.toString=E,Je.OutsideBounds.__enum__=Je,Je.Custom=function(r){var n=["Custom",3,r];return n.__enum__=Je,n.toString=E,n};var at=function(){};x["haxe.io.FPHelper"]=at,at.__name__=["haxe","io","FPHelper"],at.i32ToFloat=function(r){var n=1-(r>>>31<<1),a=r>>>23&255,l=r&8388607;return l==0&&a==0?0:n*(1+Math.pow(2,-23)*l)*Math.pow(2,a-127)},at.floatToI32=function(r){if(r==0)return 0;var n;r<0?n=-r:n=r;var a=Math.floor(Math.log(n)/.6931471805599453);a<-127?a=-127:a>128&&(a=128);var l=Math.round((n/Math.pow(2,a)-1)*8388608)&8388607;return(r<0?-2147483648:0)|a+127<<23|l},at.i64ToDouble=function(r,n){var a=1-(n>>>31<<1),l=(n>>20&2047)-1023,c=(n&1048575)*4294967296+(r>>>31)*2147483648+(r&2147483647);return c==0&&l==-1023?0:a*(1+Math.pow(2,-52)*c)*Math.pow(2,l)},at.doubleToI64=function(r){var n=at.i64tmp;if(r==0)n.low=0,n.high=0;else{var a;r<0?a=-r:a=r;var l=Math.floor(Math.log(a)/.6931471805599453),c,d=(a/Math.pow(2,l)-1)*4503599627370496;c=Math.round(d);var p=c|0,_=c/4294967296|0;n.low=p,n.high=(r<0?-2147483648:0)|l+1023<<20|_}return n};var Q=function(r){Error.call(this),this.val=r,this.message=String(r),Error.captureStackTrace&&Error.captureStackTrace(this,Q)};x["js._Boot.HaxeError"]=Q,Q.__name__=["js","_Boot","HaxeError"],Q.__super__=Error,Q.prototype=M(Error.prototype,{__class__:Q});var Te=function(){};x["js.Boot"]=Te,Te.__name__=["js","Boot"],Te.getClass=function(r){if(r instanceof Array&&r.__enum__==null)return Array;var n=r.__class__;if(n!=null)return n;var a=Te.__nativeClassName(r);return a!=null?Te.__resolveNativeClass(a):null},Te.__string_rec=function(r,n){if(r==null)return"null";if(n.length>=5)return"<...>";var a=typeof r;switch(a=="function"&&(r.__name__||r.__ename__)&&(a="object"),a){case"object":if(r instanceof Array){if(r.__enum__){if(r.length==2)return r[0];var l=r[0]+"(";n+=" ";for(var c=2,d=r.length;c<d;){var p=c++;p!=2?l+=","+Te.__string_rec(r[p],n):l+=Te.__string_rec(r[p],n)}return l+")"}var _=r.length,v="[";n+=" ";for(var w=0;w<_;){var P=w++;v+=(P>0?",":"")+Te.__string_rec(r[P],n)}return v+="]",v}var A;try{A=r.toString}catch(C){return C instanceof Q&&(C=C.val),"???"}if(A!=null&&A!=Object.toString&&typeof A=="function"){var I=r.toString();if(I!="[object Object]")return I}var k=null,T=`{
3
3
  `;n+=" ";var L=r.hasOwnProperty!=null;for(var k in r)L&&!r.hasOwnProperty(k)||k=="prototype"||k=="__class__"||k=="__super__"||k=="__interfaces__"||k=="__properties__"||(T.length!=2&&(T+=`,
4
4
  `),T+=n+k+" : "+Te.__string_rec(r[k],n));return n=n.substring(1),T+=`
5
- `+n+"}",T;case"function":return"<function>";case"string":return r;default:return String(r)}},Te.__interfLoop=function(r,n){if(r==null)return!1;if(r==n)return!0;var a=r.__interfaces__;if(a!=null)for(var l=0,c=a.length;l<c;){var d=l++,p=a[d];if(p==n||Te.__interfLoop(p,n))return!0}return Te.__interfLoop(r.__super__,n)},Te.__instanceof=function(r,n){if(n==null)return!1;switch(n){case Ec:return(r|0)===r;case uo:return typeof r=="number";case mo:return typeof r=="boolean";case String:return typeof r=="string";case Array:return r instanceof Array&&r.__enum__==null;case kc:return!0;default:if(r!=null){if(typeof n=="function"){if(r instanceof n||Te.__interfLoop(Te.getClass(r),n))return!0}else if(typeof n=="object"&&Te.__isNativeObj(n)&&r instanceof n)return!0}else return!1;return n==po&&r.__name__!=null||n==go&&r.__ename__!=null?!0:r.__enum__==n}},Te.__nativeClassName=function(r){var n=Te.__toStr.call(r).slice(8,-1);return n=="Object"||n=="Function"||n=="Math"||n=="JSON"?null:n},Te.__isNativeObj=function(r){return Te.__nativeClassName(r)!=null},Te.__resolveNativeClass=function(r){return S[r]};var ot=function(r){if(r instanceof Array&&r.__enum__==null)this.a=r,this.byteLength=r.length;else{var n=r;this.a=[];for(var a=0;a<n;){var l=a++;this.a[l]=0}this.byteLength=n}};x["js.html.compat.ArrayBuffer"]=ot,ot.__name__=["js","html","compat","ArrayBuffer"],ot.sliceImpl=function(r,n){var a=new Vi(this,r,n==null?null:n-r),l=new Vs(a.byteLength),c=new Vi(l);return c.set(a),l},ot.prototype={slice:function(r,n){return new ot(this.a.slice(r,n))},__class__:ot};var hr=function(r,n,a){if(this.buf=r,n==null?this.offset=0:this.offset=n,a==null?this.length=r.byteLength-this.offset:this.length=a,this.offset<0||this.length<0||this.offset+this.length>r.byteLength)throw new Q(Je.OutsideBounds)};x["js.html.compat.DataView"]=hr,hr.__name__=["js","html","compat","DataView"],hr.prototype={getInt8:function(r){var n=this.buf.a[this.offset+r];return n>=128?n-256:n},getUint8:function(r){return this.buf.a[this.offset+r]},getInt16:function(r,n){var a=this.getUint16(r,n);return a>=32768?a-65536:a},getUint16:function(r,n){return n?this.buf.a[this.offset+r]|this.buf.a[this.offset+r+1]<<8:this.buf.a[this.offset+r]<<8|this.buf.a[this.offset+r+1]},getInt32:function(r,n){var a=this.offset+r,l=this.buf.a[a++],c=this.buf.a[a++],d=this.buf.a[a++],p=this.buf.a[a++];return n?l|c<<8|d<<16|p<<24:p|d<<8|c<<16|l<<24},getUint32:function(r,n){var a=this.getInt32(r,n);return a<0?a+4294967296:a},getFloat32:function(r,n){return at.i32ToFloat(this.getInt32(r,n))},getFloat64:function(r,n){var a=this.getInt32(r,n),l=this.getInt32(r+4,n);return at.i64ToDouble(n?a:l,n?l:a)},setInt8:function(r,n){n<0?this.buf.a[r+this.offset]=n+128&255:this.buf.a[r+this.offset]=n&255},setUint8:function(r,n){this.buf.a[r+this.offset]=n&255},setInt16:function(r,n,a){this.setUint16(r,n<0?n+65536:n,a)},setUint16:function(r,n,a){var l=r+this.offset;a?(this.buf.a[l]=n&255,this.buf.a[l++]=n>>8&255):(this.buf.a[l++]=n>>8&255,this.buf.a[l]=n&255)},setInt32:function(r,n,a){this.setUint32(r,n,a)},setUint32:function(r,n,a){var l=r+this.offset;a?(this.buf.a[l++]=n&255,this.buf.a[l++]=n>>8&255,this.buf.a[l++]=n>>16&255,this.buf.a[l++]=n>>>24):(this.buf.a[l++]=n>>>24,this.buf.a[l++]=n>>16&255,this.buf.a[l++]=n>>8&255,this.buf.a[l++]=n&255)},setFloat32:function(r,n,a){this.setUint32(r,at.floatToI32(n),a)},setFloat64:function(r,n,a){var l=at.doubleToI64(n);a?(this.setUint32(r,l.low),this.setUint32(r,l.high)):(this.setUint32(r,l.high),this.setUint32(r,l.low))},__class__:hr};var nr=function(){};x["js.html.compat.Uint8Array"]=nr,nr.__name__=["js","html","compat","Uint8Array"],nr._new=function(r,n,a){var l;if(typeof r=="number"){l=[];for(var c=0;c<r;){var d=c++;l[d]=0}l.byteLength=l.length,l.byteOffset=0,l.buffer=new ot(l)}else if(Te.__instanceof(r,ot)){var p=r;n==null&&(n=0),a==null&&(a=p.byteLength-n),n==0?l=p.a:l=p.a.slice(n,n+a),l.byteLength=l.length,l.byteOffset=n,l.buffer=p}else if(r instanceof Array&&r.__enum__==null)l=r.slice(),l.byteLength=l.length,l.byteOffset=0,l.buffer=new ot(l);else throw new Q("TODO "+ge.string(r));return l.subarray=nr._subarray,l.set=nr._set,l},nr._set=function(r,n){var a=this;if(Te.__instanceof(r.buffer,ot)){var l=r;if(r.byteLength+n>a.byteLength)throw new Q("set() outside of range");for(var c=0,d=r.byteLength;c<d;){var p=c++;a[p+n]=l[p]}}else if(r instanceof Array&&r.__enum__==null){var _=r;if(_.length+n>a.byteLength)throw new Q("set() outside of range");for(var v=0,w=_.length;v<w;){var P=v++;a[P+n]=_[P]}}else throw new Q("TODO")},nr._subarray=function(r,n){var a=this,l=nr._new(a.slice(r,n));return l.byteOffset=r,l};var ke=function(r){this._resolved=!1,this._pending=!1,this._errorPending=!1,this._fulfilled=!1,this._update=[],this._error=[],this._errored=!1,r!=null&&ke.link(r,this,function(n){return n})};x["promhx.base.AsyncBase"]=ke,ke.__name__=["promhx","base","AsyncBase"],ke.link=function(r,n,a){r._update.push({async:n,linkf:function(l){n.handleResolve(a(l))}}),ke.immediateLinkUpdate(r,n,a)},ke.immediateLinkUpdate=function(r,n,a){if(r._errored&&!r._errorPending&&!(r._error.length>0)&&n.handleError(r._errorVal),r._resolved&&!r._pending)try{n.handleResolve(a(r._val))}catch(l){l instanceof Q&&(l=l.val),n.handleError(l)}},ke.linkAll=function(r,n){for(var a=function(d,p,_){if(d.length==0||ke.allFulfilled(d)){for(var v,w=[],P=Xt(r)();P.hasNext();){var A=P.next();w.push(A==p?_:A._val)}v=w,n.handleResolve(v)}},l=Xt(r)();l.hasNext();){var c=l.next();c._update.push({async:n,linkf:function(d,p,_){return function(v){d(p,_,v)}}(a,function(d){for(var p,_=[],v=Xt(r)();v.hasNext();){var w=v.next();w!=c&&_.push(w)}return p=_,p}(),c)})}ke.allFulfilled(r)&&n.handleResolve(function(d){for(var p,_=[],v=Xt(r)();v.hasNext();){var w=v.next();_.push(w._val)}return p=_,p}())},ke.pipeLink=function(r,n,a){var l=!1,c=function(d){if(!l){l=!0;var p=a(d);p._update.push({async:n,linkf:Mt(n,n.handleResolve)}),ke.immediateLinkUpdate(p,n,function(_){return _})}};if(r._update.push({async:n,linkf:c}),r._resolved&&!r._pending)try{c(r._val)}catch(d){d instanceof Q&&(d=d.val),n.handleError(d)}},ke.allResolved=function(r){for(var n=Xt(r)();n.hasNext();){var a=n.next();if(!a._resolved)return!1}return!0},ke.allFulfilled=function(r){for(var n=Xt(r)();n.hasNext();){var a=n.next();if(!a._fulfilled)return!1}return!0},ke.prototype={catchError:function(r){return this._error.push(r),this},errorThen:function(r){return this._errorMap=r,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(r){this._resolve(r)},_resolve:function(r){var n=this;this._pending?Se.enqueue(function(a,l){return function(){a(l)}}(Mt(this,this._resolve),r)):(this._resolved=!0,this._pending=!0,Se.queue.add(function(){n._val=r;for(var a=0,l=n._update;a<l.length;){var c=l[a];++a;try{c.linkf(r)}catch(d){d instanceof Q&&(d=d.val),c.async.handleError(d)}}n._fulfilled=!0,n._pending=!1}),Se.continueOnNextLoop())},handleError:function(r){this._handleError(r)},_handleError:function(r){var n=this,a=function(l){if(n._error.length>0)for(var c=0,d=n._error;c<d.length;){var p=d[c];++c,p(l)}else if(n._update.length>0)for(var _=0,v=n._update;_<v.length;){var w=v[_];++_,w.async.handleError(l)}else throw new Q(l);n._errorPending=!1};this._errorPending||(this._errorPending=!0,this._errored=!0,this._errorVal=r,Se.queue.add(function(){if(n._errorMap!=null)try{n._resolve(n._errorMap(r))}catch(l){l instanceof Q&&(l=l.val),a(l)}else a(r)}),Se.continueOnNextLoop())},then:function(r){var n=new ke(null);return ke.link(this,n,r),n},unlink:function(r){var n=this;Se.queue.add(function(){n._update=n._update.filter(function(a){return a.async!=r})}),Se.continueOnNextLoop()},isLinked:function(r){for(var n=!1,a=0,l=this._update;a<l.length;){var c=l[a];if(++a,c.async==r)return!0}return n},__class__:ke};var yn=f.promhx.Deferred=function(){ke.call(this)};x["promhx.Deferred"]=yn,yn.__name__=["promhx","Deferred"],yn.__super__=ke,yn.prototype=M(ke.prototype,{resolve:function(r){this.handleResolve(r)},throwError:function(r){this.handleError(r)},promise:function(){return new pt(this)},stream:function(){return new He(this)},publicStream:function(){return new Tr(this)},__class__:yn});var pt=f.promhx.Promise=function(r){ke.call(this,r),this._rejected=!1};x["promhx.Promise"]=pt,pt.__name__=["promhx","Promise"],pt.whenAll=function(r){var n=new pt(null);return ke.linkAll(r,n),n},pt.promise=function(r){var n=new pt;return n.handleResolve(r),n},pt.__super__=ke,pt.prototype=M(ke.prototype,{isRejected:function(){return this._rejected},reject:function(r){this._rejected=!0,this.handleError(r)},handleResolve:function(r){if(this._resolved){var n="Promise has already been resolved";throw new Q(bn.AlreadyResolved(n))}this._resolve(r)},then:function(r){var n=new pt(null);return ke.link(this,n,r),n},unlink:function(r){var n=this;Se.queue.add(function(){if(n._fulfilled)n._update=n._update.filter(function(l){return l.async!=r});else{var a="Downstream Promise is not fullfilled";n.handleError(bn.DownstreamNotFullfilled(a))}}),Se.continueOnNextLoop()},handleError:function(r){this._rejected=!0,this._handleError(r)},pipe:function(r){var n=new pt(null);return ke.pipeLink(this,n,r),n},errorPipe:function(r){var n=new pt;return this.catchError(function(a){var l=r(a);l.then(Mt(n,n._resolve))}),this.then(Mt(n,n._resolve)),n},__class__:pt});var He=f.promhx.Stream=function(r){ke.call(this,r),this._end_promise=new pt};x["promhx.Stream"]=He,He.__name__=["promhx","Stream"],He.foreach=function(r){for(var n=new He(null),a=Xt(r)();a.hasNext();){var l=a.next();n.handleResolve(l)}return n.end(),n},He.wheneverAll=function(r){var n=new He(null);return ke.linkAll(r,n),n},He.concatAll=function(r){for(var n=new He(null),a=Xt(r)();a.hasNext();){var l=a.next();n.concat(l)}return n},He.mergeAll=function(r){for(var n=new He(null),a=Xt(r)();a.hasNext();){var l=a.next();n.merge(l)}return n},He.stream=function(r){var n=new He(null);return n.handleResolve(r),n},He.__super__=ke,He.prototype=M(ke.prototype,{then:function(r){var n=new He(null);return ke.link(this,n,r),this._end_promise._update.push({async:n._end_promise,linkf:function(a){n.end()}}),n},detachStream:function(r){for(var n=[],a=!1,l=0,c=this._update;l<c.length;){var d=c[l];++l,d.async==r?(this._end_promise._update=this._end_promise._update.filter(function(p){return p.async!=r._end_promise}),a=!0):n.push(d)}return this._update=n,a},first:function(){var r=new pt(null);return this.then(function(n){r._resolved||r.handleResolve(n)}),r},handleResolve:function(r){!this._end&&!this._pause&&this._resolve(r)},pause:function(r){r==null&&(r=!this._pause),this._pause=r},pipe:function(r){var n=new He(null);return ke.pipeLink(this,n,r),this._end_promise.then(function(a){n.end()}),n},errorPipe:function(r){var n=new He(null);return this.catchError(function(a){var l=r(a);l.then(Mt(n,n._resolve)),l._end_promise.then((Fi=n._end_promise,Mt(Fi,Fi._resolve)))}),this.then(Mt(n,n._resolve)),this._end_promise.then(function(a){n.end()}),n},handleEnd:function(){if(this._pending)Se.queue.add(Mt(this,this.handleEnd)),Se.continueOnNextLoop();else{if(this._end_promise._resolved)return;this._end=!0;var r;this._resolved?r=dt.Some(this._val):r=dt.None,this._end_promise.handleResolve(r),this._update=[],this._error=[]}},end:function(){return Se.queue.add(Mt(this,this.handleEnd)),Se.continueOnNextLoop(),this},endThen:function(r){return this._end_promise.then(r)},filter:function(r){var n=new He(null);return this._update.push({async:n,linkf:function(a){r(a)&&n.handleResolve(a)}}),ke.immediateLinkUpdate(this,n,function(a){return a}),n},concat:function(r){var n=new He(null);return this._update.push({async:n,linkf:Mt(n,n.handleResolve)}),ke.immediateLinkUpdate(this,n,function(a){return a}),this._end_promise.then(function(a){r.pipe(function(l){return n.handleResolve(l),n}),r._end_promise.then(function(l){n.end()})}),n},merge:function(r){var n=new He(null);return this._update.push({async:n,linkf:Mt(n,n.handleResolve)}),r._update.push({async:n,linkf:Mt(n,n.handleResolve)}),ke.immediateLinkUpdate(this,n,function(a){return a}),ke.immediateLinkUpdate(r,n,function(a){return a}),n},__class__:He});var Tr=f.promhx.PublicStream=function(r){He.call(this,r)};x["promhx.PublicStream"]=Tr,Tr.__name__=["promhx","PublicStream"],Tr.publicstream=function(r){var n=new Tr(null);return n.handleResolve(r),n},Tr.__super__=He,Tr.prototype=M(He.prototype,{resolve:function(r){this.handleResolve(r)},throwError:function(r){this.handleError(r)},update:function(r){this.handleResolve(r)},__class__:Tr});var Se=function(){};x["promhx.base.EventLoop"]=Se,Se.__name__=["promhx","base","EventLoop"],Se.enqueue=function(r){Se.queue.add(r),Se.continueOnNextLoop()},Se.set_nextLoop=function(r){if(Se.nextLoop!=null)throw new Q("nextLoop has already been set");return Se.nextLoop=r,Se.nextLoop},Se.queueEmpty=function(){return Se.queue.isEmpty()},Se.finish=function(r){r==null&&(r=1e3);for(var n=null;r-- >0&&(n=Se.queue.pop())!=null;)n();return Se.queue.isEmpty()},Se.clear=function(){Se.queue=new U},Se.f=function(){var r=Se.queue.pop();r!=null&&r(),Se.queue.isEmpty()||Se.continueOnNextLoop()},Se.continueOnNextLoop=function(){Se.nextLoop!=null?Se.nextLoop(Se.f):setImmediate(Se.f)};var bn=x["promhx.error.PromiseError"]={__ename__:["promhx","error","PromiseError"],__constructs__:["AlreadyResolved","DownstreamNotFullfilled"]};bn.AlreadyResolved=function(r){var n=["AlreadyResolved",0,r];return n.__enum__=bn,n.toString=E,n},bn.DownstreamNotFullfilled=function(r){var n=["DownstreamNotFullfilled",1,r];return n.__enum__=bn,n.toString=E,n};var Fs=function(){};x["verb.Verb"]=Fs,Fs.__name__=["verb","Verb"],Fs.main=function(){b.log("verb 2.1.0")};var K=function(){};x["verb.core.ArrayExtensions"]=K,K.__name__=["verb","core","ArrayExtensions"],K.alloc=function(r,n){if(!(n<0))for(;r.length<n;)r.push(null)},K.reversed=function(r){var n=r.slice();return n.reverse(),n},K.last=function(r){return r[r.length-1]},K.first=function(r){return r[0]},K.spliceAndInsert=function(r,n,a,l){r.splice(n,a),r.splice(n,0,l)},K.left=function(r){if(r.length==0)return[];var n=Math.ceil(r.length/2);return r.slice(0,n)},K.right=function(r){if(r.length==0)return[];var n=Math.ceil(r.length/2);return r.slice(n)},K.rightWithPivot=function(r){if(r.length==0)return[];var n=Math.ceil(r.length/2);return r.slice(n-1)},K.unique=function(r,n){if(r.length==0)return[];for(var a=[r.pop()];r.length>0;){for(var l=r.pop(),c=!0,d=0;d<a.length;){var p=a[d];if(++d,n(l,p)){c=!1;break}}c&&a.push(l)}return a};var De=function(){};x["verb.core.Binomial"]=De,De.__name__=["verb","core","Binomial"],De.get=function(r,n){if(n==0)return 1;if(r==0||n>r)return 0;if(n>r-n&&(n=r-n),De.memo_exists(r,n))return De.get_memo(r,n);for(var a=1,l=r,c=1,d=n+1;c<d;){var p=c++;if(De.memo_exists(l,p)){r--,a=De.get_memo(l,p);continue}a*=r--,a/=p,De.memoize(l,p,a)}return a},De.get_no_memo=function(r,n){if(n==0)return 1;if(r==0||n>r)return 0;n>r-n&&(n=r-n);for(var a=1,l=1,c=n+1;l<c;){var d=l++;a*=r--,a/=d}return a},De.memo_exists=function(r,n){return De.memo.h.hasOwnProperty(r)&&De.memo.h[r].h.hasOwnProperty(n)},De.get_memo=function(r,n){return De.memo.h[r].h[n]},De.memoize=function(r,n,a){De.memo.h.hasOwnProperty(r)||De.memo.set(r,new xe),De.memo.h[r].h[n]=a};var Et=f.core.BoundingBox=function(r){this.max=null,this.min=null,this.dim=3,this.initialized=!1,r!=null&&this.addRange(r)};x["verb.core.BoundingBox"]=Et,Et.__name__=["verb","core","BoundingBox"],Et.intervalsOverlap=function(r,n,a,l,c){c==null&&(c=-1);var d;c<-.5?d=re.TOLERANCE:d=c;var p=Math.min(r,n)-d,_=Math.max(r,n)+d,v=Math.min(a,l)-d,w=Math.max(a,l)+d;return p>=v&&p<=w||_>=v&&_<=w||v>=p&&v<=_||w>=p&&w<=_},Et.prototype={fromPoint:function(r){return new Et([r])},add:function(r){if(!this.initialized)return this.dim=r.length,this.min=r.slice(0),this.max=r.slice(0),this.initialized=!0,this;for(var n=0,a=this.dim;n<a;){var l=n++;r[l]>this.max[l]&&(this.max[l]=r[l]),r[l]<this.min[l]&&(this.min[l]=r[l])}return this},addRange:function(r){for(var n=r.length,a=0;a<n;){var l=a++;this.add(r[l])}return this},contains:function(r,n){return n==null&&(n=-1),this.initialized?this.intersects(new Et([r]),n):!1},intersects:function(r,n){if(n==null&&(n=-1),!this.initialized||!r.initialized)return!1;for(var a=this.min,l=this.max,c=r.min,d=r.max,p=0,_=this.dim;p<_;){var v=p++;if(!Et.intervalsOverlap(a[v],l[v],c[v],d[v],n))return!1}return!0},clear:function(){return this.initialized=!1,this},getLongestAxis:function(){for(var r=0,n=0,a=0,l=this.dim;a<l;){var c=a++,d=this.getAxisLength(c);d>r&&(r=d,n=c)}return n},getAxisLength:function(r){return r<0||r>this.dim-1?0:Math.abs(this.min[r]-this.max[r])},intersect:function(r,n){if(!this.initialized)return null;var a=this.min,l=this.max,c=r.min,d=r.max;if(!this.intersects(r,n))return null;for(var p=[],_=[],v=0,w=this.dim;v<w;){var P=v++;p.push(Math.min(l[P],d[P])),_.push(Math.max(a[P],c[P]))}return new Et([_,p])},__class__:Et};var re=f.core.Constants=function(){};x["verb.core.Constants"]=re,re.__name__=["verb","core","Constants"];var Ze=f.core.SerializableBase=function(){};x["verb.core.SerializableBase"]=Ze,Ze.__name__=["verb","core","SerializableBase"],Ze.prototype={serialize:function(){var r=new Ye;return r.serialize(this),r.toString()},__class__:Ze};var jn=f.core.Plane=function(r,n){this.origin=r,this.normal=n};x["verb.core.Plane"]=jn,jn.__name__=["verb","core","Plane"],jn.__super__=Ze,jn.prototype=M(Ze.prototype,{__class__:jn});var xn=f.core.Ray=function(r,n){this.origin=r,this.dir=n};x["verb.core.Ray"]=xn,xn.__name__=["verb","core","Ray"],xn.__super__=Ze,xn.prototype=M(Ze.prototype,{__class__:xn});var je=f.core.NurbsCurveData=function(r,n,a){this.degree=r,this.controlPoints=a,this.knots=n};x["verb.core.NurbsCurveData"]=je,je.__name__=["verb","core","NurbsCurveData"],je.__super__=Ze,je.prototype=M(Ze.prototype,{__class__:je});var et=f.core.NurbsSurfaceData=function(r,n,a,l,c){this.degreeU=r,this.degreeV=n,this.knotsU=a,this.knotsV=l,this.controlPoints=c};x["verb.core.NurbsSurfaceData"]=et,et.__name__=["verb","core","NurbsSurfaceData"],et.__super__=Ze,et.prototype=M(Ze.prototype,{__class__:et});var qt=f.core.MeshData=function(r,n,a,l){this.faces=r,this.points=n,this.normals=a,this.uvs=l};x["verb.core.MeshData"]=qt,qt.__name__=["verb","core","MeshData"],qt.empty=function(){return new qt([],[],[],[])},qt.__super__=Ze,qt.prototype=M(Ze.prototype,{__class__:qt});var Gn=f.core.PolylineData=function(r,n){this.points=r,this.params=n};x["verb.core.PolylineData"]=Gn,Gn.__name__=["verb","core","PolylineData"],Gn.__super__=Ze,Gn.prototype=M(Ze.prototype,{__class__:Gn});var Wn=f.core.VolumeData=function(r,n,a,l,c,d,p){this.degreeU=r,this.degreeV=n,this.degreeW=a,this.knotsU=l,this.knotsV=c,this.knotsW=d,this.controlPoints=p};x["verb.core.VolumeData"]=Wn,Wn.__name__=["verb","core","VolumeData"],Wn.__super__=Ze,Wn.prototype=M(Ze.prototype,{__class__:Wn});var tt=f.core.Pair=function(r,n){this.item0=r,this.item1=n};x["verb.core.Pair"]=tt,tt.__name__=["verb","core","Pair"],tt.prototype={__class__:tt};var wt=f.core.Interval=function(r,n){this.min=r,this.max=n};x["verb.core.Interval"]=wt,wt.__name__=["verb","core","Interval"],wt.prototype={__class__:wt};var Kr=f.core.CurveCurveIntersection=function(r,n,a,l){this.point0=r,this.point1=n,this.u0=a,this.u1=l};x["verb.core.CurveCurveIntersection"]=Kr,Kr.__name__=["verb","core","CurveCurveIntersection"],Kr.prototype={__class__:Kr};var Hn=f.core.CurveSurfaceIntersection=function(r,n,a,l){this.u=r,this.uv=n,this.curvePoint=a,this.surfacePoint=l};x["verb.core.CurveSurfaceIntersection"]=Hn,Hn.__name__=["verb","core","CurveSurfaceIntersection"],Hn.prototype={__class__:Hn};var Nr=f.core.MeshIntersectionPoint=function(r,n,a,l,c){this.visited=!1,this.adj=null,this.opp=null,this.uv0=r,this.uv1=n,this.point=a,this.faceIndex0,this.faceIndex1};x["verb.core.MeshIntersectionPoint"]=Nr,Nr.__name__=["verb","core","MeshIntersectionPoint"],Nr.prototype={__class__:Nr};var qn=f.core.PolylineMeshIntersection=function(r,n,a,l,c){this.point=r,this.u=n,this.uv=a,this.polylineIndex=l,this.faceIndex=c};x["verb.core.PolylineMeshIntersection"]=qn,qn.__name__=["verb","core","PolylineMeshIntersection"],qn.prototype={__class__:qn};var Yn=f.core.SurfaceSurfaceIntersectionPoint=function(r,n,a,l){this.uv0=r,this.uv1=n,this.point=a,this.dist=l};x["verb.core.SurfaceSurfaceIntersectionPoint"]=Yn,Yn.__name__=["verb","core","SurfaceSurfaceIntersectionPoint"],Yn.prototype={__class__:Yn};var Xn=f.core.TriSegmentIntersection=function(r,n,a,l){this.point=r,this.s=n,this.t=a,this.p=l};x["verb.core.TriSegmentIntersection"]=Xn,Xn.__name__=["verb","core","TriSegmentIntersection"],Xn.prototype={__class__:Xn};var wn=f.core.CurveTriPoint=function(r,n,a){this.u=r,this.point=n,this.uv=a};x["verb.core.CurveTriPoint"]=wn,wn.__name__=["verb","core","CurveTriPoint"],wn.prototype={__class__:wn};var jt=function(r,n,a,l,c){c==null&&(c=!1),l==null&&(l=-1),this.uv=a,this.point=r,this.normal=n,this.id=l,this.degen=c};x["verb.core.SurfacePoint"]=jt,jt.__name__=["verb","core","SurfacePoint"],jt.fromUv=function(r,n){return new jt(null,null,[r,n])},jt.prototype={__class__:jt};var Us=f.core.CurvePoint=function(r,n){this.u=r,this.pt=n};x["verb.core.CurvePoint"]=Us,Us.__name__=["verb","core","CurvePoint"],Us.prototype={__class__:Us};var Kn=f.core.KdTree=function(r,n){this.dim=3,this.points=r,this.distanceFunction=n,this.dim=r[0].point.length,this.root=this.buildTree(r,0,null)};x["verb.core.KdTree"]=Kn,Kn.__name__=["verb","core","KdTree"],Kn.prototype={buildTree:function(r,n,a){var l=n%this.dim,c,d;return r.length==0?null:r.length==1?new Sn(r[0],l,a):(r.sort(function(p,_){var v=p.point[l]-_.point[l];return v==0?0:v>0?1:-1}),c=Math.floor(r.length/2),d=new Sn(r[c],l,a),d.left=this.buildTree(r.slice(0,c),n+1,d),d.right=this.buildTree(r.slice(c+1),n+1,d),d)},nearest:function(r,n,a){var l=this,c=new $n(function(A){return-A.item1}),d,p=null;p=function(A){for(var I,k=A.dimension,T=l.distanceFunction(r,A.kdPoint.point),L,C=[],R=0,O=l.dim;R<O;)R++,C.push(0);L=C;for(var F,V,q=function(X,ee){c.push(new tt(X,ee)),c.size()>n&&c.pop()},J=0,H=l.dim;J<H;){var j=J++;j==A.dimension?L[j]=r[j]:L[j]=A.kdPoint.point[j]}if(F=l.distanceFunction(L,A.kdPoint.point),A.right==null&&A.left==null){(c.size()<n||T<c.peek().item1)&&q(A,T);return}A.right==null?I=A.left:A.left==null?I=A.right:r[k]<A.kdPoint.point[k]?I=A.left:I=A.right,p(I),(c.size()<n||T<c.peek().item1)&&q(A,T),(c.size()<n||Math.abs(F)<c.peek().item1)&&(I==A.left?V=A.right:V=A.left,V!=null&&p(V))},d=p;for(var _=0;_<n;)_++,c.push(new tt(null,a));d(this.root);for(var v=[],w=0;w<n;){var P=w++;c.content[P].item0!=null&&v.push(new tt(c.content[P].item0.kdPoint,c.content[P].item1))}return v},__class__:Kn};var $n=function(r){this.content=[],this.scoreFunction=r};x["verb.core.BinaryHeap"]=$n,$n.__name__=["verb","core","BinaryHeap"],$n.prototype={push:function(r){this.content.push(r),this.bubbleUp(this.content.length-1)},pop:function(){var r=this.content[0],n=this.content.pop();return this.content.length>0&&(this.content[0]=n,this.sinkDown(0)),r},peek:function(){return this.content[0]},remove:function(r){for(var n=this.content.length,a=0;a<n;){var l=a++;if(this.content[l]==r){var c=this.content.pop();l!=n-1&&(this.content[l]=c,this.scoreFunction(c)<this.scoreFunction(r)?this.bubbleUp(l):this.sinkDown(l));return}}throw new Q("Node not found.")},size:function(){return this.content.length},bubbleUp:function(r){for(var n=this.content[r];r>0;){var a=Math.floor((r+1)/2)-1,l=this.content[a];if(this.scoreFunction(n)<this.scoreFunction(l))this.content[a]=n,this.content[r]=l,r=a;else break}},sinkDown:function(r){for(var n=this.content.length,a=this.content[r],l=this.scoreFunction(a);;){var c=(r+1)*2,d=c-1,p=-1,_=0;if(d<n){var v=this.content[d];_=this.scoreFunction(v),_<l&&(p=d)}if(c<n){var w=this.content[c],P=this.scoreFunction(w);P<(p==-1?l:_)&&(p=c)}if(p!=-1)this.content[r]=this.content[p],this.content[p]=a,r=p;else break}},__class__:$n};var An=f.core.KdPoint=function(r,n){this.point=r,this.obj=n};x["verb.core.KdPoint"]=An,An.__name__=["verb","core","KdPoint"],An.prototype={__class__:An};var Sn=f.core.KdNode=function(r,n,a){this.kdPoint=r,this.left=null,this.right=null,this.parent=a,this.dimension=n};x["verb.core.KdNode"]=Sn,Sn.__name__=["verb","core","KdNode"],Sn.prototype={__class__:Sn};var cr=function(){};x["verb.eval.IBoundingBoxTree"]=cr,cr.__name__=["verb","eval","IBoundingBoxTree"],cr.prototype={__class__:cr};var sr=function(r,n){this._boundingBox=null,this._curve=r,n==null&&(n=m.domain(this._curve.knots)/64),this._knotTol=n};x["verb.core.LazyCurveBoundingBoxTree"]=sr,sr.__name__=["verb","core","LazyCurveBoundingBoxTree"],sr.__interfaces__=[cr],sr.prototype={split:function(){var r=K.first(this._curve.knots),n=K.last(this._curve.knots),a=n-r,l=lt.curveSplit(this._curve,(n+r)/2+a*.1*Math.random());return new tt(new sr(l[0],this._knotTol),new sr(l[1],this._knotTol))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=new Et(N.dehomogenize1d(this._curve.controlPoints))),this._boundingBox},yield:function(){return this._curve},indivisible:function(r){return m.domain(this._curve.knots)<this._knotTol},empty:function(){return!1},__class__:sr};var ir=function(r,n){if(this._boundingBox=null,this._mesh=r,n==null){for(var a=[],l=0,c=r.faces.length;l<c;){var d=l++;a.push(d)}n=a}this._faceIndices=n};x["verb.core.LazyMeshBoundingBoxTree"]=ir,ir.__name__=["verb","core","LazyMeshBoundingBoxTree"],ir.__interfaces__=[cr],ir.prototype={split:function(){var r=rt.sortTrianglesOnLongestAxis(this.boundingBox(),this._mesh,this._faceIndices),n=K.left(r),a=K.right(r);return new tt(new ir(this._mesh,n),new ir(this._mesh,a))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=rt.makeMeshAabb(this._mesh,this._faceIndices)),this._boundingBox},yield:function(){return this._faceIndices[0]},indivisible:function(r){return this._faceIndices.length==1},empty:function(){return this._faceIndices.length==0},__class__:ir};var ar=function(r,n){this._boundingBox=null,this._polyline=r,n==null&&(n=new wt(0,r.points.length!=0?r.points.length-1:0)),this._interval=n};x["verb.core.LazyPolylineBoundingBoxTree"]=ar,ar.__name__=["verb","core","LazyPolylineBoundingBoxTree"],ar.__interfaces__=[cr],ar.prototype={split:function(){var r=this._interval.min,n=this._interval.max,a=r+Math.ceil((n-r)/2),l=new wt(r,a),c=new wt(a,n);return new tt(new ar(this._polyline,l),new ar(this._polyline,c))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=new Et(this._polyline.points)),this._boundingBox},yield:function(){return this._interval.min},indivisible:function(r){return this._interval.max-this._interval.min==1},empty:function(){return this._interval.max-this._interval.min==0},__class__:ar};var Cr=function(r,n,a,l){n==null&&(n=!1),this._boundingBox=null,this._surface=r,this._splitV=n,a==null&&(a=m.domain(r.knotsU)/16),l==null&&(l=m.domain(r.knotsV)/16),this._knotTolU=a,this._knotTolV=l};x["verb.core.LazySurfaceBoundingBoxTree"]=Cr,Cr.__name__=["verb","core","LazySurfaceBoundingBoxTree"],Cr.__interfaces__=[cr],Cr.prototype={split:function(){var r,n;this._splitV?(r=K.first(this._surface.knotsV),n=K.last(this._surface.knotsV)):(r=K.first(this._surface.knotsU),n=K.last(this._surface.knotsU));var a=(r+n)/2,l=lt.surfaceSplit(this._surface,a,this._splitV);return new tt(new Cr(l[0],!this._splitV,this._knotTolU,this._knotTolV),new Cr(l[1],!this._splitV,this._knotTolU,this._knotTolV))},boundingBox:function(){if(this._boundingBox==null){this._boundingBox=new Et;for(var r=0,n=this._surface.controlPoints;r<n.length;){var a=n[r];++r,this._boundingBox.addRange(N.dehomogenize1d(a))}}return this._boundingBox},yield:function(){return this._surface},indivisible:function(r){return m.domain(this._surface.knotsV)<this._knotTolV&&m.domain(this._surface.knotsU)<this._knotTolU},empty:function(){return!1},__class__:Cr};var Ce=f.core.Mat=function(){};x["verb.core.Mat"]=Ce,Ce.__name__=["verb","core","Mat"],Ce.mul=function(r,n){for(var a=[],l=0,c=n.length;l<c;){var d=l++;a.push(m.mul(r,n[d]))}return a},Ce.mult=function(r,n){var a,l,c,d,p,_,v,w;a=r.length,l=n.length,c=n[0].length,d=[];for(var P=a-1,A=0,I=0;P>=0;){for(p=[],_=r[P],I=c-1;I>=0;){for(v=_[l-1]*n[l-1][I],A=l-2;A>=1;)w=A-1,v+=_[A]*n[A][I]+_[w]*n[w][I],A-=2;A==0&&(v+=_[0]*n[0][I]),p[I]=v,I--}d[P]=p,P--}return d},Ce.add=function(r,n){for(var a=[],l=0,c=r.length;l<c;){var d=l++;a.push(m.add(r[d],n[d]))}return a},Ce.div=function(r,n){for(var a=[],l=0,c=r.length;l<c;){var d=l++;a.push(m.div(r[d],n))}return a},Ce.sub=function(r,n){for(var a=[],l=0,c=r.length;l<c;){var d=l++;a.push(m.sub(r[d],n[d]))}return a},Ce.dot=function(r,n){for(var a=[],l=0,c=r.length;l<c;){var d=l++;a.push(m.dot(r[d],n))}return a},Ce.identity=function(r){for(var n=m.zeros2d(r,r),a=0;a<r;){var l=a++;n[l][l]=1}return n},Ce.transpose=function(r){if(r.length==0)return[];for(var n=[],a=0,l=r[0].length;a<l;){var c=a++;n.push(function(d){for(var p,_=[],v=0,w=r.length;v<w;){var P=v++;_.push(r[P][c])}return p=_,p}())}return n},Ce.solve=function(r,n){return Ce.LUsolve(Ce.LU(r),n)},Ce.LUsolve=function(r,n){var a,l,c=r.LU,d=c.length,p=n.slice(),_=r.P,v,w,P;for(a=d-1;a!=-1;)p[a]=n[a],--a;for(a=0;a<d;){for(v=_[a],_[a]!=a&&(P=p[a],p[a]=p[v],p[v]=P),w=c[a],l=0;l<a;)p[a]-=p[l]*w[l],++l;++a}for(a=d-1;a>=0;){for(w=c[a],l=a+1;l<d;)p[a]-=p[l]*w[l],++l;p[a]/=w[a],--a}return p},Ce.LU=function(r){for(var n,a,l,c,d,p,_,v,w,P=[],A=0,I=r.length;A<I;){var k=A++;P.push(r[k].slice())}r=P;var T=r.length,L=T-1,C=[];for(l=0;l<T;){for(_=l,p=r[l],w=Math.abs(p[l]),a=l+1;a<T;)c=Math.abs(r[a][l]),w<c&&(w=c,_=a),++a;for(C[l]=_,_!=l&&(r[l]=r[_],r[_]=p,p=r[l]),d=p[l],n=l+1;n<T;)r[n][l]/=d,++n;for(n=l+1;n<T;){for(v=r[n],a=l+1;a<L;)v[a]-=v[l]*p[a],++a,v[a]-=v[l]*p[a],++a;a==L&&(v[a]-=v[l]*p[a]),++n}++l}return new Zn(r,C)};var Zn=function(r,n){this.LU=r,this.P=n};x["verb.core._Mat.LUDecomp"]=Zn,Zn.__name__=["verb","core","_Mat","LUDecomp"],Zn.prototype={__class__:Zn};var rt=f.core.Mesh=function(){};x["verb.core.Mesh"]=rt,rt.__name__=["verb","core","Mesh"],rt.getTriangleNorm=function(r,n){var a=r[n[0]],l=r[n[1]],c=r[n[2]],d=m.sub(l,a),p=m.sub(c,a),_=m.cross(d,p);return m.mul(1/m.norm(_),_)},rt.makeMeshAabb=function(r,n){for(var a=new Et,l=0;l<n.length;){var c=n[l];++l,a.add(r.points[r.faces[c][0]]),a.add(r.points[r.faces[c][1]]),a.add(r.points[r.faces[c][2]])}return a},rt.sortTrianglesOnLongestAxis=function(r,n,a){for(var l=r.getLongestAxis(),c=[],d=0;d<a.length;){var p=a[d];++d;var _=rt.getMinCoordOnAxis(n.points,n.faces[p],l);c.push(new tt(_,p))}c.sort(function(I,k){var T=I.item0,L=k.item0;return T==L?0:T>L?1:-1});for(var v=[],w=0,P=c.length;w<P;){var A=w++;v.push(c[A].item1)}return v},rt.getMinCoordOnAxis=function(r,n,a){for(var l=1/0,c=0;c<3;){var d=c++,p=r[n[d]][a];p<l&&(l=p)}return l},rt.getTriangleCentroid=function(r,n){for(var a=[0,0,0],l=0;l<3;)for(var c=l++,d=0;d<3;){var p=d++;a[p]+=r[n[c]][p]}for(var _=0;_<3;){var v=_++;a[v]/=3}return a},rt.triangleUVFromPoint=function(r,n,a){var l=r.faces[n],c=r.points[l[0]],d=r.points[l[1]],p=r.points[l[2]],_=r.uvs[l[0]],v=r.uvs[l[1]],w=r.uvs[l[2]],P=m.sub(c,a),A=m.sub(d,a),I=m.sub(p,a),k=m.norm(m.cross(m.sub(c,d),m.sub(c,p))),T=m.norm(m.cross(A,I))/k,L=m.norm(m.cross(I,P))/k,C=m.norm(m.cross(P,A))/k;return m.add(m.mul(T,_),m.add(m.mul(L,v),m.mul(C,w)))};var Lr=function(r,n){if(this._empty=!1,this._face=-1,n==null){for(var a=[],l=0,c=r.faces.length;l<c;){var d=l++;a.push(d)}n=a}if(this._boundingBox=rt.makeMeshAabb(r,n),n.length<1){this._empty=!0;return}else if(n.length<2){this._face=n[0];return}var p=rt.sortTrianglesOnLongestAxis(this._boundingBox,r,n),_=K.left(p),v=K.right(p);this._children=new tt(new Lr(r,_),new Lr(r,v))};x["verb.core.MeshBoundingBoxTree"]=Lr,Lr.__name__=["verb","core","MeshBoundingBoxTree"],Lr.__interfaces__=[cr],Lr.prototype={split:function(){return this._children},boundingBox:function(){return this._boundingBox},yield:function(){return this._face},indivisible:function(r){return this._children==null},empty:function(){return this._empty},__class__:Lr};var Yt=f.core.Minimizer=function(){};x["verb.core.Minimizer"]=Yt,Yt.__name__=["verb","core","Minimizer"],Yt.uncmin=function(r,n,a,l,c){a==null&&(a=1e-8),l==null&&(l=function(J){return Yt.numericalGradient(r,J)}),c==null&&(c=1e3),n=n.slice(0);var d=n.length,p=r(n),_=p,v;if(isNaN(p))throw new Q("uncmin: f(x0) is a NaN!");a=Math.max(a,re.EPSILON);var w,P,A,I=Ce.identity(d),k=0,T=[],L,C,R,O,F,V,q="";for(P=l(n);k<c;){if(!m.all(m.finite(P))){q="Gradient has Infinity or NaN";break}if(w=m.neg(Ce.dot(I,P)),!m.all(m.finite(w))){q="Search direction has Infinity or NaN";break}if(V=m.norm(w),V<a){q="Newton step smaller than tol";break}for(F=1,v=m.dot(P,w),L=n;k<c&&!(F*V<a);){if(T=m.mul(F,w),L=m.add(n,T),_=r(L),_-p>=.1*F*v||isNaN(_)){F*=.5,++k;continue}break}if(F*V<a){q="Line search step size smaller than tol";break}if(k==c){q="maxit reached during line search";break}A=l(L),C=m.sub(A,P),O=m.dot(C,T),R=Ce.dot(I,C),I=Ce.sub(Ce.add(I,Ce.mul((O+m.dot(C,R))/(O*O),Yt.tensor(T,T))),Ce.div(Ce.add(Yt.tensor(R,T),Yt.tensor(T,R)),O)),n=L,p=_,P=A,++k}return new Qn(n,p,P,I,k,q)},Yt.numericalGradient=function(r,n){var a=n.length,l=r(n);if(l==NaN)throw new Q("gradient: f(x) is a NaN!");for(var c=n.slice(0),d,p,_=[],v,w=.001,P,A,I,k=0,T,L,C,R=0;R<a;)for(var O=R++,F=Math.max(1e-6*l,1e-8);;){if(++k,k>20)throw new Q("Numerical gradient fails");if(c[O]=n[O]+F,d=r(c),c[O]=n[O]-F,p=r(c),c[O]=n[O],isNaN(d)||isNaN(p)){F/=16;continue}if(_[O]=(d-p)/(2*F),P=n[O]-F,A=n[O],I=n[O]+F,T=(d-l)/F,L=(l-p)/F,C=m.max([Math.abs(_[O]),Math.abs(l),Math.abs(d),Math.abs(p),Math.abs(P),Math.abs(A),Math.abs(I),1e-8]),v=Math.min(m.max([Math.abs(T-_[O]),Math.abs(L-_[O]),Math.abs(T-L)])/C,F/C),v>w)F/=16;else break}return _},Yt.tensor=function(r,n){for(var a=r.length,l=n.length,c=[],d,p,_=a-1;_>=0;){d=[],p=r[_];for(var v=l-1;v>=3;)d[v]=p*n[v],--v,d[v]=p*n[v],--v,d[v]=p*n[v],--v,d[v]=p*n[v],--v;for(;v>=0;)d[v]=p*n[v],--v;c[_]=d,_--}return c};var Qn=function(r,n,a,l,c,d){this.solution=r,this.value=n,this.gradient=a,this.invHessian=l,this.iterations=c,this.message=d};x["verb.core.MinimizationResult"]=Qn,Qn.__name__=["verb","core","MinimizationResult"],Qn.prototype={__class__:Qn};var Pn=function(){};x["verb.core.ISerializable"]=Pn,Pn.__name__=["verb","core","ISerializable"],Pn.prototype={__class__:Pn};var Bi=f.core.Deserializer=function(){};x["verb.core.Deserializer"]=Bi,Bi.__name__=["verb","core","Deserializer"],Bi.deserialize=function(r){var n=new We(r),a=n.unserialize();return a};var kt=f.core.Trig=function(){};x["verb.core.Trig"]=kt,kt.__name__=["verb","core","Trig"],kt.isPointInPlane=function(r,n,a){return Math.abs(m.dot(m.sub(r,n.origin),n.normal))<a},kt.distToSegment=function(r,n,a){var l=kt.segmentClosestPoint(n,r,a,0,1);return m.dist(n,l.pt)},kt.rayClosestPoint=function(r,n,a){var l=m.sub(r,n),c=m.dot(l,a),d=m.add(n,m.mul(c,a));return d},kt.distToRay=function(r,n,a){var l=kt.rayClosestPoint(r,n,a),c=m.sub(l,r);return m.norm(c)},kt.threePointsAreFlat=function(r,n,a,l){var c=m.sub(n,r),d=m.sub(a,r),p=m.cross(c,d),_=m.dot(p,p);return _<l},kt.segmentClosestPoint=function(r,n,a,l,c){var d=m.sub(a,n),p=m.norm(d);if(p<re.EPSILON)return{u:l,pt:n};var _=n,v=m.mul(1/p,d),w=m.sub(r,_),P=m.dot(w,v);return P<0?{u:l,pt:n}:P>p?{u:c,pt:a}:{u:l+(c-l)*P/p,pt:m.add(_,m.mul(P,v))}};var m=f.core.Vec=function(){};x["verb.core.Vec"]=m,m.__name__=["verb","core","Vec"],m.angleBetween=function(r,n){return Math.acos(m.dot(r,n)/(m.norm(r)*m.norm(n)))},m.positiveAngleBetween=function(r,n,a){var l=m.cross(r,n),c=m.norm(r),d=m.norm(n),p=c*d,_=m.dot(r,n),v=m.norm(l)/p,w=_/p,P=Math.atan2(v,w),A=m.dot(a,l);return Math.abs(A)<re.EPSILON||A>0?P:-P},m.signedAngleBetween=function(r,n,a){var l=m.cross(r,n),c=m.norm(r),d=m.norm(n),p=c*d,_=m.dot(r,n),v=m.norm(l)/p,w=_/p,P=Math.atan2(v,w),A=m.dot(a,l);return A>0?P:2*Math.PI-P},m.angleBetweenNormalized2d=function(r,n){var a=r[0]*n[1]-r[1]*n[0];return Math.atan2(a,m.dot(r,n))},m.domain=function(r){return K.last(r)-K.first(r)},m.range=function(r){for(var n=[],a=0,l=0;l<r;)l++,n.push(a),a+=1;return n},m.span=function(r,n,a){if(a==null)return[];if(a<re.EPSILON)return[];if(r>n&&a>0)return[];if(n>r&&a<0)return[];for(var l=[],c=r;c<=n;)l.push(c),c+=a;return l},m.neg=function(r){return r.map(function(n){return-n})},m.min=function(r){return D.fold(r,function(n,a){return Math.min(n,a)},1/0)},m.max=function(r){return D.fold(r,function(n,a){return Math.max(n,a)},-1/0)},m.all=function(r){return D.fold(r,function(n,a){return a&&n},!0)},m.finite=function(r){return r.map(function(n){return isFinite(n)})},m.onRay=function(r,n,a){return m.add(r,m.mul(a,n))},m.lerp=function(r,n,a){return m.add(m.mul(r,n),m.mul(1-r,a))},m.normalized=function(r){return m.div(r,m.norm(r))},m.cross=function(r,n){return[r[1]*n[2]-r[2]*n[1],r[2]*n[0]-r[0]*n[2],r[0]*n[1]-r[1]*n[0]]},m.dist=function(r,n){return m.norm(m.sub(r,n))},m.distSquared=function(r,n){return m.normSquared(m.sub(r,n))},m.sum=function(r){return D.fold(r,function(n,a){return a+n},0)},m.addAll=function(r){var n=Xt(r)();if(!n.hasNext())return null;var a=n.next().length;return D.fold(r,function(l,c){return m.add(c,l)},m.rep(a,0))},m.addAllMutate=function(r){for(var n=r[0],a=1,l=r.length;a<l;){var c=a++;m.addMutate(n,r[c])}},m.addMulMutate=function(r,n,a){for(var l=0,c=r.length;l<c;){var d=l++;r[d]=r[d]+n*a[d]}},m.subMulMutate=function(r,n,a){for(var l=0,c=r.length;l<c;){var d=l++;r[d]=r[d]-n*a[d]}},m.addMutate=function(r,n){for(var a=0,l=r.length;a<l;){var c=a++;r[c]=r[c]+n[c]}},m.subMutate=function(r,n){for(var a=0,l=r.length;a<l;){var c=a++;r[c]=r[c]-n[c]}},m.mulMutate=function(r,n){for(var a=0,l=n.length;a<l;){var c=a++;n[c]=n[c]*r}},m.norm=function(r){var n=m.normSquared(r);return n!=0?Math.sqrt(n):n},m.normSquared=function(r){return D.fold(r,function(n,a){return a+n*n},0)},m.rep=function(r,n){for(var a=[],l=0;l<r;)l++,a.push(n);return a},m.zeros1d=function(r){for(var n=[],a=0;a<r;)a++,n.push(0);return n},m.zeros2d=function(r,n){for(var a=[],l=0;l<r;)l++,a.push(m.zeros1d(n));return a},m.zeros3d=function(r,n,a){for(var l=[],c=0;c<r;)c++,l.push(m.zeros2d(n,a));return l},m.dot=function(r,n){for(var a=0,l=0,c=r.length;l<c;){var d=l++;a+=r[d]*n[d]}return a},m.add=function(r,n){for(var a=[],l=0,c=r.length;l<c;){var d=l++;a.push(r[d]+n[d])}return a},m.mul=function(r,n){for(var a=[],l=0,c=n.length;l<c;){var d=l++;a.push(r*n[d])}return a},m.div=function(r,n){for(var a=[],l=0,c=r.length;l<c;){var d=l++;a.push(r[d]/n)}return a},m.sub=function(r,n){for(var a=[],l=0,c=r.length;l<c;){var d=l++;a.push(r[d]-n[d])}return a},m.isZero=function(r){for(var n=0,a=r.length;n<a;){var l=n++;if(Math.abs(r[l])>re.TOLERANCE)return!1}return!0},m.sortedSetUnion=function(r,n){for(var a=[],l=0,c=0;l<r.length||c<n.length;){if(l>=r.length){a.push(n[c]),c++;continue}else if(c>=n.length){a.push(r[l]),l++;continue}var d=r[l]-n[c];if(Math.abs(d)<re.EPSILON){a.push(r[l]),l++,c++;continue}if(d>0){a.push(n[c]),c++;continue}a.push(r[l]),l++}return a},m.sortedSetSub=function(r,n){for(var a=[],l=0,c=0;l<r.length;){if(c>=n.length){a.push(r[l]),l++;continue}if(Math.abs(r[l]-n[c])<re.EPSILON){l++,c++;continue}a.push(r[l]),l++}return a};var ve=f.eval.Analyze=function(){};x["verb.eval.Analyze"]=ve,ve.__name__=["verb","eval","Analyze"],ve.knotMultiplicities=function(r){for(var n=[new In(r[0],0)],a=n[0],l=0;l<r.length;){var c=r[l];++l,Math.abs(c-a.knot)>re.EPSILON&&(a=new In(c,0),n.push(a)),a.inc()}return n},ve.isRationalSurfaceClosed=function(r,n){n==null&&(n=!0);var a;n?a=r.controlPoints:a=Ce.transpose(r.controlPoints);for(var l=0,c=a[0].length;l<c;){var d=l++,p=m.dist(K.first(a)[d],K.last(a)[d])<re.EPSILON;if(!p)return!1}return!0},ve.rationalSurfaceClosestPoint=function(r,n){var a=ve.rationalSurfaceClosestParam(r,n);return N.rationalSurfacePoint(r,a[0],a[1])},ve.rationalSurfaceClosestParam=function(r,n){for(var a=5,l=0,c,d=1e-4,p=5e-4,_,v=r.knotsU[0],w=K.last(r.knotsU),P=r.knotsV[0],A=K.last(r.knotsV),I=ve.isRationalSurfaceClosed(r),k=ve.isRationalSurfaceClosed(r,!1),T,L=Oe.rationalSurfaceAdaptive(r,new Or),C=1/0,R=0,O=L.points.length;R<O;){var F=R++,V=L.points[F],q=m.normSquared(m.sub(n,V));q<C&&(C=q,T=L.uvs[F])}for(var J=function(Ge){return N.rationalSurfaceDerivatives(r,Ge[0],Ge[1],2)},H=function(Ge,Xe,Fe){var Ke=Xe[1][0],At=Xe[0][1],Wt=Xe[2][0],vt=Xe[0][2],gt=Xe[1][1],St=Xe[1][1],Tt=m.dot(Ke,Fe),Kt=m.dot(At,Fe),or=[-Tt,-Kt],$t=m.dot(Ke,Ke)+m.dot(Wt,Fe),Zt=m.dot(Ke,At)+m.dot(gt,Fe),Qt=m.dot(Ke,At)+m.dot(St,Fe),dr=m.dot(At,At)+m.dot(vt,Fe),Tn=[[$t,Zt],[Qt,dr]],Zr=Ce.solve(Tn,or);return m.add(Zr,Ge)};l<a;){c=J(T),_=m.sub(c[0][0],n);var j=m.norm(_),X=m.dot(c[1][0],_),ee=m.norm(c[1][0])*j,te=m.dot(c[0][1],_),ie=m.norm(c[0][1])*j,he=X/ee,ae=te/ie,ue=j<d,ne=he<p,de=ae<p;if(ue&&ne&&de)return T;var Y=H(T,c,_);Y[0]<v?I?Y=[w-(Y[0]-v),Y[1]]:Y=[v+re.EPSILON,Y[1]]:Y[0]>w&&(I?Y=[v+(Y[0]-w),Y[1]]:Y=[w-re.EPSILON,Y[1]]),Y[1]<P?k?Y=[Y[0],A-(Y[1]-P)]:Y=[Y[0],P+re.EPSILON]:Y[1]>A&&(k?Y=[Y[0],P+(Y[0]-A)]:Y=[Y[0],A-re.EPSILON]);var pe=m.norm(m.mul(Y[0]-T[0],c[1][0])),Pe=m.norm(m.mul(Y[1]-T[1],c[0][1]));if(pe+Pe<d)return T;T=Y,l++}return T},ve.rationalCurveClosestPoint=function(r,n){return N.rationalCurvePoint(r,ve.rationalCurveClosestParam(r,n))},ve.rationalCurveClosestParam=function(r,n){for(var a=1/0,l=0,c=Oe.rationalCurveRegularSample(r,r.controlPoints.length*r.degree,!0),d=0,p=c.length-1;d<p;){var _=d++,v=c[_][0],w=c[_+1][0],P=c[_].slice(1),A=c[_+1].slice(1),I=kt.segmentClosestPoint(n,P,A,v,w),k=m.norm(m.sub(n,I.pt));k<a&&(a=k,l=I.u)}for(var T=5,L=0,C,R=1e-4,O=5e-4,F,V=r.knots[0],q=K.last(r.knots),J=m.normSquared(m.sub(r.controlPoints[0],K.last(r.controlPoints)))<re.EPSILON,H=l,j=function(Y){return N.rationalCurveDerivatives(r,Y,2)},X=function(Y,pe,Pe){var Ge=m.dot(pe[1],Pe),Xe=m.dot(pe[2],Pe),Fe=m.dot(pe[1],pe[1]),Ke=Xe+Fe;return Y-Ge/Ke};L<T;){C=j(H),F=m.sub(C[0],n);var ee=m.norm(F),te=m.dot(C[1],F),ie=m.norm(C[1])*ee,he=te/ie,ae=ee<R,ue=Math.abs(he)<O;if(ae&&ue)return H;var ne=X(H,C,F);ne<V?J?ne=q-(ne-V):ne=V:ne>q&&(J?ne=V+(ne-q):ne=q);var de=m.norm(m.mul(ne-H,C[1]));if(de<R)return H;H=ne,L++}return H},ve.rationalCurveParamAtArcLength=function(r,n,a,l,c){if(a==null&&(a=.001),n<re.EPSILON)return r.knots[0];var d;l!=null?d=l:d=fe.decomposeCurveIntoBeziers(r);var p=0;d[p];var _=-re.EPSILON,v;for(c!=null?v=c:v=[];_<n&&p<d.length;){if(p<v.length?v[p]=v[p]:v[p]=ve.rationalBezierCurveArcLength(r),_+=v[p],n<_+re.EPSILON)return ve.rationalBezierCurveParamAtArcLength(r,n,a,v[p]);p++}return-1},ve.rationalBezierCurveParamAtArcLength=function(r,n,a,l){if(n<0)return r.knots[0];var c;if(l!=null?c=l:c=ve.rationalBezierCurveArcLength(r),n>c)return K.last(r.knots);var d=r.knots[0],p=0,_=K.last(r.knots),v=c,w=0,P=0,A;for(a!=null?A=a:A=re.TOLERANCE*2;v-p>A;)w=(d+_)/2,P=ve.rationalBezierCurveArcLength(r,w),P>n?(_=w,v=P):(d=w,p=P);return(d+_)/2},ve.rationalCurveArcLength=function(r,n,a){a==null&&(a=16),n==null?n=K.last(r.knots):n=n;for(var l=fe.decomposeCurveIntoBeziers(r),c=0,d=l[0],p=0;c<l.length&&d.knots[0]+re.EPSILON<n;){var _=Math.min(K.last(d.knots),n);p+=ve.rationalBezierCurveArcLength(d,_,a),d=l[++c]}return p},ve.rationalBezierCurveArcLength=function(r,n,a){a==null&&(a=16);var l;n==null?l=K.last(r.knots):l=n;for(var c=(l-r.knots[0])/2,d=0,p=r.degree+a,_,v,w=0;w<p;){var P=w++;_=c*ve.Tvalues[p][P]+c+r.knots[0],v=N.rationalCurveDerivatives(r,_,1),d+=ve.Cvalues[p][P]*m.norm(v[1])}return c*d};var In=f.eval.KnotMultiplicity=function(r,n){this.knot=r,this.mult=n};x["verb.eval.KnotMultiplicity"]=In,In.__name__=["verb","eval","KnotMultiplicity"],In.prototype={inc:function(){this.mult++},__class__:In};var Gt=f.eval.Check=function(){};x["verb.eval.Check"]=Gt,Gt.__name__=["verb","eval","Check"],Gt.isValidKnotVector=function(r,n){if(r.length==0||r.length<(n+1)*2)return!1;for(var a=K.first(r),l=0,c=n+1;l<c;){var d=l++;if(Math.abs(r[d]-a)>re.EPSILON)return!1}a=K.last(r);for(var p=r.length-n-1,_=r.length;p<_;){var v=p++;if(Math.abs(r[v]-a)>re.EPSILON)return!1}return Gt.isNonDecreasing(r)},Gt.isNonDecreasing=function(r){for(var n=K.first(r),a=0,l=r.length;a<l;){var c=a++;if(r[c]<n-re.EPSILON)return!1;n=r[c]}return!0},Gt.isValidNurbsCurveData=function(r){if(r.controlPoints==null)throw new Q("Control points array cannot be null!");if(r.degree==null)throw new Q("Degree cannot be null!");if(r.degree<1)throw new Q("Degree must be greater than 1!");if(r.knots==null)throw new Q("Knots cannot be null!");if(r.knots.length!=r.controlPoints.length+r.degree+1)throw new Q("controlPoints.length + degree + 1 must equal knots.length!");if(!Gt.isValidKnotVector(r.knots,r.degree))throw new Q("Invalid knot vector format! Should begin with degree + 1 repeats and end with degree + 1 repeats!");return r},Gt.isValidNurbsSurfaceData=function(r){if(r.controlPoints==null)throw new Q("Control points array cannot be null!");if(r.degreeU==null)throw new Q("DegreeU cannot be null!");if(r.degreeV==null)throw new Q("DegreeV cannot be null!");if(r.degreeU<1)throw new Q("DegreeU must be greater than 1!");if(r.degreeV<1)throw new Q("DegreeV must be greater than 1!");if(r.knotsU==null)throw new Q("KnotsU cannot be null!");if(r.knotsV==null)throw new Q("KnotsV cannot be null!");if(r.knotsU.length!=r.controlPoints.length+r.degreeU+1)throw new Q("controlPointsU.length + degreeU + 1 must equal knotsU.length!");if(r.knotsV.length!=r.controlPoints[0].length+r.degreeV+1)throw new Q("controlPointsV.length + degreeV + 1 must equal knotsV.length!");if(!Gt.isValidKnotVector(r.knotsU,r.degreeU)||!Gt.isValidKnotVector(r.knotsV,r.degreeV))throw new Q("Invalid knot vector format! Should begin with degree + 1 repeats and end with degree + 1 repeats!");return r};var lt=f.eval.Divide=function(){};x["verb.eval.Divide"]=lt,lt.__name__=["verb","eval","Divide"],lt.surfaceSplit=function(r,n,a){a==null&&(a=!1);var l,c,d;a?(d=r.controlPoints,l=r.knotsV,c=r.degreeV):(d=Ce.transpose(r.controlPoints),l=r.knotsU,c=r.degreeU);for(var p,_=[],v=0,w=c+1;v<w;)v++,_.push(n);p=_;for(var P=[],A=[],I=N.knotSpan(c,n,l),k=null,T=0;T<d.length;){var L=d[T];++T,k=fe.curveKnotRefine(new je(c,l,L),p),P.push(k.controlPoints.slice(0,I+1)),A.push(k.controlPoints.slice(I+1))}var C=k.knots.slice(0,I+c+2),R=k.knots.slice(I+1);return a?[new et(r.degreeU,c,r.knotsU.slice(),C,P),new et(r.degreeU,c,r.knotsU.slice(),R,A)]:(P=Ce.transpose(P),A=Ce.transpose(A),[new et(c,r.degreeV,C,r.knotsV.slice(),P),new et(c,r.degreeV,R,r.knotsV.slice(),A)])},lt.curveSplit=function(r,n){var a=r.degree;r.controlPoints;for(var l=r.knots,c,d=[],p=0,_=a+1;p<_;)p++,d.push(n);c=d;var v=fe.curveKnotRefine(r,c),w=N.knotSpan(a,n,l),P=v.knots.slice(0,w+a+2),A=v.knots.slice(w+1),I=v.controlPoints.slice(0,w+1),k=v.controlPoints.slice(w+1);return[new je(a,P,I),new je(a,A,k)]},lt.rationalCurveByEqualArcLength=function(r,n){var a=ve.rationalCurveArcLength(r),l=a/n;return lt.rationalCurveByArcLength(r,l)},lt.rationalCurveByArcLength=function(r,n){var a=fe.decomposeCurveIntoBeziers(r),l=a.map(function(I){return ve.rationalBezierCurveArcLength(I)}),c=m.sum(l),d=[new En(r.knots[0],0)];if(n>c)return d;for(var p=n,_=0,v=p,w=0,P=0,A;_<a.length;){for(w+=l[_];v<w+re.EPSILON;)A=ve.rationalBezierCurveParamAtArcLength(a[_],v-P,re.TOLERANCE,l[_]),d.push(new En(A,v)),v+=p;P+=l[_],_++}return d};var En=f.eval.CurveLengthSample=function(r,n){this.u=r,this.len=n};x["verb.eval.CurveLengthSample"]=En,En.__name__=["verb","eval","CurveLengthSample"],En.prototype={__class__:En};var N=f.eval.Eval=function(){};x["verb.eval.Eval"]=N,N.__name__=["verb","eval","Eval"],N.rationalCurveTangent=function(r,n){var a=N.rationalCurveDerivatives(r,n,1);return a[1]},N.rationalSurfaceNormal=function(r,n,a){var l=N.rationalSurfaceDerivatives(r,n,a,1);return m.cross(l[1][0],l[0][1])},N.rationalSurfaceDerivatives=function(r,n,a,l){l==null&&(l=1);for(var c=N.surfaceDerivatives(r,n,a,l),d=N.rational2d(c),p=N.weight2d(c),_=[],v=d[0][0].length,w=0,P=l+1;w<P;){var A=w++;_.push([]);for(var I=0,k=l-A+1;I<k;){for(var T=I++,L=d[A][T],C=1,R=T+1;C<R;){var O=C++;m.subMulMutate(L,De.get(T,O)*p[0][O],_[A][T-O])}for(var F=1,V=A+1;F<V;){var q=F++;m.subMulMutate(L,De.get(A,q)*p[q][0],_[A-q][T]);for(var J=m.zeros1d(v),H=1,j=T+1;H<j;){var X=H++;m.addMulMutate(J,De.get(T,X)*p[q][X],_[A-q][T-X])}m.subMulMutate(L,De.get(A,q),J)}m.mulMutate(1/p[0][0],L),_[A].push(L)}}return _},N.rationalSurfacePoint=function(r,n,a){return N.dehomogenize(N.surfacePoint(r,n,a))},N.rationalCurveDerivatives=function(r,n,a){a==null&&(a=1);for(var l=N.curveDerivatives(r,n,a),c=N.rational1d(l),d=N.weight1d(l),p=[],_=0,v=a+1;_<v;){for(var w=_++,P=c[w],A=1,I=w+1;A<I;){var k=A++;m.subMulMutate(P,De.get(w,k)*d[k],p[w-k])}m.mulMutate(1/d[0],P),p.push(P)}return p},N.rationalCurvePoint=function(r,n){return N.dehomogenize(N.curvePoint(r,n))},N.surfaceDerivatives=function(r,n,a,l){var c=r.knotsU.length-r.degreeU-2,d=r.knotsV.length-r.degreeV-2;return N.surfaceDerivativesGivenNM(c,d,r,n,a,l)},N.surfaceDerivativesGivenNM=function(r,n,a,l,c,d){var p=a.degreeU,_=a.degreeV,v=a.controlPoints,w=a.knotsU,P=a.knotsV;if(!N.areValidRelations(p,v.length,w.length)||!N.areValidRelations(_,v[0].length,P.length))throw new Q("Invalid relations between control points, knot vector, and n");var A=v[0][0].length,I;d<p?I=d:I=p;var k;d<_?k=d:k=_;for(var T=m.zeros3d(d+1,d+1,A),L=N.knotSpanGivenN(r,p,l,w),C=N.knotSpanGivenN(n,_,c,P),R=N.derivativeBasisFunctionsGivenNI(L,l,p,r,w),O=N.derivativeBasisFunctionsGivenNI(C,c,_,n,P),F=m.zeros2d(_+1,A),V=0,q=0,J=I+1;q<J;){for(var H=q++,j=0,X=_+1;j<X;){var ee=j++;F[ee]=m.zeros1d(A);for(var te=0,ie=p+1;te<ie;){var he=te++;m.addMulMutate(F[ee],R[H][he],v[L-p+he][C-_+ee])}}var ae=d-H;ae<k?V=ae:V=k;for(var ue=0,ne=V+1;ue<ne;){var de=ue++;T[H][de]=m.zeros1d(A);for(var Y=0,pe=_+1;Y<pe;){var Pe=Y++;m.addMulMutate(T[H][de],O[de][Pe],F[Pe])}}}return T},N.surfacePoint=function(r,n,a){var l=r.knotsU.length-r.degreeU-2,c=r.knotsV.length-r.degreeV-2;return N.surfacePointGivenNM(l,c,r,n,a)},N.surfacePointGivenNM=function(r,n,a,l,c){var d=a.degreeU,p=a.degreeV,_=a.controlPoints,v=a.knotsU,w=a.knotsV;if(!N.areValidRelations(d,_.length,v.length)||!N.areValidRelations(p,_[0].length,w.length))throw new Q("Invalid relations between control points, knot vector, and n");for(var P=_[0][0].length,A=N.knotSpanGivenN(r,d,l,v),I=N.knotSpanGivenN(n,p,c,w),k=N.basisFunctionsGivenKnotSpanIndex(A,l,d,v),T=N.basisFunctionsGivenKnotSpanIndex(I,c,p,w),L=A-d,C=I,R=m.zeros1d(P),O=m.zeros1d(P),F=0,V=p+1;F<V;){var q=F++;O=m.zeros1d(P),C=I-p+q;for(var J=0,H=d+1;J<H;){var j=J++;m.addMulMutate(O,k[j],_[L+j][C])}m.addMulMutate(R,T[q],O)}return R},N.curveRegularSamplePoints=function(r,n){for(var a=N.curveDerivatives(r,r.knots[0],r.degree),l=1/n,c=l*l,d=a[0],p=m.mul(l,a[1]),_=m.mul(c*.5,a[2]),v=m.mul(c*l*.5,a[3]),w=m.add(_,_),P=m.add(v,v),A=m.mul(.3333333333333333,v),I=[],k=0,T=n+1;k<T;)k++,I.push(N.dehomogenize(d)),m.addAllMutate([d,p,_,A]),m.addAllMutate([p,w,v]),m.addAllMutate([w,P]),m.addAllMutate([_,v]);return I},N.curveRegularSamplePoints2=function(r,n){for(var a=N.curveDerivatives(r,r.knots[0],r.degree),l=1/n,c=l*l,d=a[0],p=m.mul(l,a[1]),_=m.mul(c*.5,a[2]),v=m.mul(c*l*.5,a[3]),w=m.add(_,_),P=m.add(v,v),A=m.mul(.3333333333333333,v),I=[],k=0,T=n+1;k<T;)k++,I.push(N.dehomogenize(d)),m.addAllMutate([d,p,_,A]),m.addAllMutate([p,w,v]),m.addAllMutate([w,P]),m.addAllMutate([_,v]);return I},N.rationalSurfaceRegularSampleDerivatives=function(r,n,a,l){for(var c=N.surfaceRegularSampleDerivatives(r,n,a,l),d=[],p=n+1,_=a+1,v=l+1,w=0;w<p;){var P=w++,A=[];d.push(A);for(var I=0;I<_;){for(var k=I++,T=c[P][k],L=N.rational2d(T),C=N.weight2d(T),R=[],O=L[0][0].length,F=0;F<v;){var V=F++;R.push([]);for(var q=0,J=v-V;q<J;){for(var H=q++,j=L[V][H],X=1,ee=H+1;X<ee;){var te=X++;m.subMulMutate(j,De.get(H,te)*C[0][te],R[V][H-te])}for(var ie=1,he=V+1;ie<he;){var ae=ie++;m.subMulMutate(j,De.get(V,ae)*C[ae][0],R[V-ae][H]);for(var ue=m.zeros1d(O),ne=1,de=H+1;ne<de;){var Y=ne++;m.addMulMutate(ue,De.get(H,Y)*C[ae][Y],R[V-ae][H-Y])}m.subMulMutate(j,De.get(V,ae),ue)}m.mulMutate(1/C[0][0],j),R[V].push(j)}}A.push(R)}}return d},N.surfaceRegularSampleDerivatives=function(r,n,a,l){var c=r.degreeU,d=r.degreeV,p=r.controlPoints,_=r.knotsU,v=r.knotsV,w=p[0][0].length;(K.last(_)-_[0])/n,(K.last(v)-v[0])/a;for(var P=N.regularlySpacedDerivativeBasisFunctions(c,_,n),A=P.item0,I=P.item1,k=N.regularlySpacedDerivativeBasisFunctions(d,v,a),T=k.item0,L=k.item1,C=[],R=n+1,O=a+1,F=0;F<R;){var V=F++,q=[];C.push(q);for(var J=0;J<O;){var H=J++;q.push(N.surfaceDerivativesGivenBasesKnotSpans(c,d,p,A[V],T[H],I[V],L[H],w,l))}}return C},N.rationalSurfaceRegularSamplePoints=function(r,n,a){return N.dehomogenize2d(N.surfaceRegularSamplePoints(r,n,a))},N.surfaceRegularSamplePoints=function(r,n,a){var l=r.degreeU,c=r.degreeV,d=r.controlPoints,p=r.knotsU,_=r.knotsV,v=d[0][0].length;(K.last(p)-p[0])/n,(K.last(_)-_[0])/a;for(var w=N.regularlySpacedBasisFunctions(l,p,n),P=w.item0,A=w.item1,I=N.regularlySpacedBasisFunctions(c,_,a),k=I.item0,T=I.item1,L=[],C=n+1,R=a+1,O=0;O<C;){var F=O++,V=[];L.push(V);for(var q=0;q<R;){var J=q++;V.push(N.surfacePointGivenBasesKnotSpans(l,c,d,P[F],k[J],A[F],T[J],v))}}return L},N.regularlySpacedBasisFunctions=function(r,n,a){for(var l=n.length-r-2,c=(K.last(n)-n[0])/a,d=[],p=[],_=n[0],v=N.knotSpanGivenN(l,r,_,n),w=a+1,P=0;P<w;){for(P++;_>=n[v+1];)v++;p.push(v),d.push(N.basisFunctionsGivenKnotSpanIndex(v,_,r,n)),_+=c}return new tt(p,d)},N.regularlySpacedDerivativeBasisFunctions=function(r,n,a){for(var l=n.length-r-2,c=(K.last(n)-n[0])/a,d=[],p=[],_=n[0],v=N.knotSpanGivenN(l,r,_,n),w=a+1,P=0;P<w;){for(P++;_>=n[v+1];)v++;p.push(v),d.push(N.derivativeBasisFunctionsGivenNI(v,_,r,l,n)),_+=c}return new tt(p,d)},N.surfacePointGivenBasesKnotSpans=function(r,n,a,l,c,d,p,_){for(var v=m.zeros1d(_),w,P=l-r,A=c-n,I=0,k=n+1;I<k;){var T=I++;w=m.zeros1d(_);for(var L=0,C=r+1;L<C;){var R=L++;m.addMulMutate(w,d[R],a[P+R][A])}A++,m.addMulMutate(v,p[T],w)}return v},N.surfaceDerivativesGivenBasesKnotSpans=function(r,n,a,l,c,d,p,_,v){var w=a[0][0].length,P;v<r?P=v:P=r;var A;v<n?A=v:A=n;for(var I=m.zeros3d(P+1,A+1,w),k=m.zeros2d(n+1,w),T=0,L=0,C=P+1;L<C;){for(var R=L++,O=0,F=n+1;O<F;){var V=O++;k[V]=m.zeros1d(w);for(var q=0,J=r+1;q<J;){var H=q++;m.addMulMutate(k[V],d[R][H],a[l-r+H][c-n+V])}}var j=v-R;j<A?T=j:T=A;for(var X=0,ee=T+1;X<ee;){var te=X++;I[R][te]=m.zeros1d(w);for(var ie=0,he=n+1;ie<he;){var ae=ie++;m.addMulMutate(I[R][te],p[te][ae],k[ae])}}}return I},N.curveDerivatives=function(r,n,a){var l=r.knots.length-r.degree-2;return N.curveDerivativesGivenN(l,r,n,a)},N.curveDerivativesGivenN=function(r,n,a,l){var c=n.degree,d=n.controlPoints,p=n.knots;if(!N.areValidRelations(c,d.length,p.length))throw new Q("Invalid relations between control points, knot vector, and n");var _=d[0].length,v;l<c?v=l:v=c;for(var w=m.zeros2d(l+1,_),P=N.knotSpanGivenN(r,c,a,p),A=N.derivativeBasisFunctionsGivenNI(P,a,c,v,p),I=0,k=v+1;I<k;)for(var T=I++,L=0,C=c+1;L<C;){var R=L++;m.addMulMutate(w[T],A[T][R],d[P-c+R])}return w},N.curvePoint=function(r,n){var a=r.knots.length-r.degree-2;return N.curvePointGivenN(a,r,n)},N.areValidRelations=function(r,n,a){return n+r+1-a==0},N.curvePointGivenN=function(r,n,a){var l=n.degree,c=n.controlPoints,d=n.knots;if(!N.areValidRelations(l,c.length,d.length))throw new Q("Invalid relations between control points, knot Array, and n");for(var p=N.knotSpanGivenN(r,l,a,d),_=N.basisFunctionsGivenKnotSpanIndex(p,a,l,d),v=m.zeros1d(c[0].length),w=0,P=l+1;w<P;){var A=w++;m.addMulMutate(v,_[A],c[p-l+A])}return v},N.volumePoint=function(r,n,a,l){var c=r.knotsU.length-r.degreeU-2,d=r.knotsV.length-r.degreeV-2,p=r.knotsW.length-r.degreeW-2;return N.volumePointGivenNML(r,c,d,p,n,a,l)},N.volumePointGivenNML=function(r,n,a,l,c,d,p){if(!N.areValidRelations(r.degreeU,r.controlPoints.length,r.knotsU.length)||!N.areValidRelations(r.degreeV,r.controlPoints[0].length,r.knotsV.length)||!N.areValidRelations(r.degreeW,r.controlPoints[0][0].length,r.knotsW.length))throw new Q("Invalid relations between control points and knot vector");for(var _=r.controlPoints,v=r.degreeU,w=r.degreeV,P=r.degreeW,A=r.knotsU,I=r.knotsV,k=r.knotsW,T=_[0][0][0].length,L=N.knotSpanGivenN(n,v,c,A),C=N.knotSpanGivenN(a,w,d,I),R=N.knotSpanGivenN(l,P,p,k),O=N.basisFunctionsGivenKnotSpanIndex(L,c,v,A),F=N.basisFunctionsGivenKnotSpanIndex(C,d,w,I),V=N.basisFunctionsGivenKnotSpanIndex(R,p,P,k),q=L-v,J=m.zeros1d(T),H=m.zeros1d(T),j=m.zeros1d(T),X=0,ee=P+1;X<ee;){var te=X++;j=m.zeros1d(T);for(var ie=R-P+te,he=0,ae=w+1;he<ae;){var ue=he++;H=m.zeros1d(T);for(var ne=C-w+ue,de=0,Y=v+1;de<Y;){var pe=de++;m.addMulMutate(H,O[pe],_[q+pe][ne][ie])}m.addMulMutate(j,F[ue],H)}m.addMulMutate(J,V[te],j)}return J},N.derivativeBasisFunctions=function(r,n,a){var l=N.knotSpan(n,r,a),c=a.length-1,d=c-n-1;return N.derivativeBasisFunctionsGivenNI(l,r,n,d,a)},N.derivativeBasisFunctionsGivenNI=function(r,n,a,l,c){var d=m.zeros2d(a+1,a+1),p=m.zeros1d(a+1),_=m.zeros1d(a+1),v=0,w=0;d[0][0]=1;for(var P=1,A=a+1;P<A;){var I=P++;p[I]=n-c[r+1-I],_[I]=c[r+I]-n,v=0;for(var k=0;k<I;){var T=k++;d[I][T]=_[T+1]+p[I-T],w=d[T][I-1]/d[I][T],d[T][I]=v+_[T+1]*w,v=p[I-T]*w}d[I][I]=v}for(var L=m.zeros2d(l+1,a+1),C=m.zeros2d(2,a+1),R=0,O=1,F=0,V=0,q=0,J=0,H=0,j=0,X=a+1;j<X;){var ee=j++;L[0][ee]=d[ee][a]}for(var te=0,ie=a+1;te<ie;){var he=te++;R=0,O=1,C[0][0]=1;for(var ae=1,ue=l+1;ae<ue;){var ne=ae++;F=0,V=he-ne,q=a-ne,he>=ne&&(C[O][0]=C[R][0]/d[q+1][V],F=C[O][0]*d[V][q]),V>=-1?J=1:J=-V,he-1<=q?H=ne-1:H=a-he;for(var de=J,Y=H+1;de<Y;){var pe=de++;C[O][pe]=(C[R][pe]-C[R][pe-1])/d[q+1][V+pe],F+=C[O][pe]*d[V+pe][q]}he<=q&&(C[O][ne]=-C[R][ne-1]/d[q+1][he],F+=C[O][ne]*d[he][q]),L[ne][he]=F;var Pe=R;R=O,O=Pe}}for(var Ge=a,Xe=1,Fe=l+1;Xe<Fe;){for(var Ke=Xe++,At=0,Wt=a+1;At<Wt;){var vt=At++;L[Ke][vt]*=Ge}Ge*=a-Ke}return L},N.basisFunctions=function(r,n,a){var l=N.knotSpan(n,r,a);return N.basisFunctionsGivenKnotSpanIndex(l,r,n,a)},N.basisFunctionsGivenKnotSpanIndex=function(r,n,a,l){var c=m.zeros1d(a+1),d=m.zeros1d(a+1),p=m.zeros1d(a+1),_=0,v=0;c[0]=1;for(var w=1,P=a+1;w<P;){var A=w++;d[A]=n-l[r+1-A],p[A]=l[r+A]-n,_=0;for(var I=0;I<A;){var k=I++;v=c[k]/(p[k+1]+d[A-k]),c[k]=_+p[k+1]*v,_=d[A-k]*v}c[A]=_}return c},N.knotSpan=function(r,n,a){return N.knotSpanGivenN(a.length-r-2,r,n,a)},N.knotSpanGivenN=function(r,n,a,l){if(a>l[r+1]-re.EPSILON)return r;if(a<l[n]+re.EPSILON)return n;for(var c=n,d=r+1,p=Math.floor((c+d)/2);a<l[p]||a>=l[p+1];)a<l[p]?d=p:c=p,p=Math.floor((c+d)/2);return p},N.dehomogenize=function(r){for(var n=r.length,a=[],l=r[n-1],c=r.length-1,d=0;d<c;){var p=d++;a.push(r[p]/l)}return a},N.rational1d=function(r){var n=r[0].length-1;return r.map(function(a){return a.slice(0,n)})},N.rational2d=function(r){return r.map(N.rational1d)},N.weight1d=function(r){var n=r[0].length-1;return r.map(function(a){return a[n]})},N.weight2d=function(r){return r.map(N.weight1d)},N.dehomogenize1d=function(r){return r.map(N.dehomogenize)},N.dehomogenize2d=function(r){return r.map(N.dehomogenize1d)},N.homogenize1d=function(r,n){var a=r.length,l=r[0].length,c=[],d=0,p=[],_;n!=null?_=n:_=m.rep(r.length,1);for(var v=0;v<a;){var w=v++,P=[];p=r[w],d=_[w];for(var A=0;A<l;){var I=A++;P.push(p[I]*d)}P.push(d),c.push(P)}return c},N.homogenize2d=function(r,n){var a=r.length,l=[],c;if(n!=null)c=n;else{for(var d=[],p=0;p<a;)p++,d.push(m.rep(r[0].length,1));c=d}for(var _=0;_<a;){var v=_++;l.push(N.homogenize1d(r[v],c[v]))}return l};var le=f.eval.Intersect=function(){};x["verb.eval.Intersect"]=le,le.__name__=["verb","eval","Intersect"],le.surfaces=function(r,n,a){var l=Oe.rationalSurfaceAdaptive(r),c=Oe.rationalSurfaceAdaptive(n),d=le.meshes(l,c),p=d.map(function(_){return _.map(function(v){return le.surfacesAtPointWithEstimate(r,n,v.uv0,v.uv1,a)})});return p.map(function(_){return me.rationalInterpCurve(_.map(function(v){return v.point}),3)})},le.surfacesAtPointWithEstimate=function(r,n,a,l,c){var d,p,_,v,w,P,A,I,k,T,L,C,R,O=5,F=0;do{if(d=N.rationalSurfaceDerivatives(r,a[0],a[1],1),p=d[0][0],v=d[1][0],w=d[0][1],_=m.normalized(m.cross(v,w)),P=m.dot(_,p),A=N.rationalSurfaceDerivatives(n,l[0],l[1],1),I=A[0][0],T=A[1][0],L=A[0][1],k=m.normalized(m.cross(T,L)),C=m.dot(k,I),R=m.distSquared(p,I),R<c*c)break;var V=m.normalized(m.cross(_,k)),q=m.dot(V,p),J=le.threePlanes(_,P,k,C,V,q);if(J==null)throw new Q("panic!");var H=m.sub(J,p),j=m.sub(J,I),X=m.cross(v,_),ee=m.cross(w,_),te=m.cross(T,k),ie=m.cross(L,k),he=m.dot(ee,H)/m.dot(ee,v),ae=m.dot(X,H)/m.dot(X,w),ue=m.dot(ie,j)/m.dot(ie,T),ne=m.dot(te,j)/m.dot(te,L);a=m.add([he,ae],a),l=m.add([ue,ne],l),F++}while(F<O);return new Yn(a,l,p,R)},le.meshes=function(r,n,a,l){a==null&&(a=new ir(r)),l==null&&(l=new ir(n));var c=le.boundingBoxTrees(a,l,0),d=K.unique(c.map(function(p){return le.triangles(r,p.item0,n,p.item1)}).filter(function(p){return p!=null}).filter(function(p){return m.distSquared(p.min.point,p.max.point)>re.EPSILON}),function(p,_){var v=m.sub(p.min.uv0,_.min.uv0),w=m.dot(v,v),P=m.sub(p.max.uv0,_.max.uv0),A=m.dot(P,P),I=m.sub(p.min.uv0,_.max.uv0),k=m.dot(I,I),T=m.sub(p.max.uv0,_.min.uv0),L=m.dot(T,T);return w<re.EPSILON&&A<re.EPSILON||k<re.EPSILON&&L<re.EPSILON});return le.makeMeshIntersectionPolylines(d)},le.meshSlices=function(r,n,a,l){for(var c=new Lr(r),d=c.boundingBox(),p=d.min[0],_=d.min[1],v=d.max[0],w=d.max[1],P=m.span(n,a,l),A=[],I=0;I<P.length;){var k=P[I];++I;var T=[[p,_,k],[v,_,k],[v,w,k],[p,w,k]],L=[[0,0],[1,0],[1,1],[0,1]],C=[[0,1,2],[0,2,3]],R=new qt(C,T,null,L);A.push(le.meshes(r,R,c))}return A},le.makeMeshIntersectionPolylines=function(r){if(r.length==0)return[];for(var n=0;n<r.length;){var a=r[n];++n,a.max.opp=a.min,a.min.opp=a.max}for(var l=le.kdTreeFromSegments(r),c=[],d=0;d<r.length;){var p=r[d];++d,c.push(p.min),c.push(p.max)}for(var _=0;_<c.length;){var v=c[_];if(++_,v.adj==null){var w=le.lookupAdjacentSegment(v,l,r.length);w!=null&&w.adj==null&&(v.adj=w,w.adj=v)}}var P=c.filter(function(O){return O.adj==null});P.length==0&&(P=c);for(var A=[],I=0,k=!1;P.length!=0;){var T=P.pop();if(!T.visited){for(var L=[],C=T;C!=null&&!(C.visited||(C.visited=!0,C.opp.visited=!0,L.push(C),I+=2,C=C.opp.adj,C==T)););L.length>0&&(L.push(L[L.length-1].opp),A.push(L))}if(P.length==0&&c.length>0&&(k||I<c.length)){k=!0;var R=c.pop();P.push(R)}}return A},le.kdTreeFromSegments=function(r){for(var n=[],a=0;a<r.length;){var l=r[a];++a,n.push(new An(l.min.point,l.min)),n.push(new An(l.max.point,l.max))}return new Kn(n,m.distSquared)},le.lookupAdjacentSegment=function(r,n,a){var l=n.nearest(r.point,a,re.EPSILON).filter(function(c){return r!=c.item0.obj}).map(function(c){return c.item0.obj});return l.length==1?l[0]:null},le.curveAndSurface=function(r,n,a,l,c){a==null&&(a=.001),l!=null?l=l:l=new sr(r),c!=null?c=c:c=new Cr(n);var d=le.boundingBoxTrees(l,c,a);return K.unique(d.map(function(p){var _=p.item0,v=p.item1,w=K.first(_.knots),P=K.last(_.knots),A=(w+P)/2,I=K.first(v.knotsU),k=K.last(v.knotsU),T=K.first(v.knotsV),L=K.last(v.knotsV),C=[(I+k)/2,(T+L)/2];return le.curveAndSurfaceWithEstimate(_,v,[A].concat(C),a)}).filter(function(p){return m.distSquared(p.curvePoint,p.surfacePoint)<a*a}),function(p,_){return Math.abs(p.u-_.u)<.5*a})},le.curveAndSurfaceWithEstimate=function(r,n,a,l){l==null&&(l=.001);var c=function(v){var w=N.rationalCurvePoint(r,v[0]),P=N.rationalSurfacePoint(n,v[1],v[2]),A=m.sub(w,P);return m.dot(A,A)},d=function(v){var w=N.rationalCurveDerivatives(r,v[0],1),P=N.rationalSurfaceDerivatives(n,v[1],v[2],1),A=m.sub(P[0][0],w[0]),I=m.mul(-1,w[1]),k=P[1][0],T=P[0][1];return[2*m.dot(I,A),2*m.dot(k,A),2*m.dot(T,A)]},p=Yt.uncmin(c,a,l*l,d),_=p.solution;return new Hn(_[0],[_[1],_[2]],N.rationalCurvePoint(r,_[0]),N.rationalSurfacePoint(n,_[1],_[2]))},le.polylineAndMesh=function(r,n,a){for(var l=le.boundingBoxTrees(new ar(r),new ir(n),a),c=[],d=0;d<l.length;){var p=l[d];++d;var _=p.item0,v=p.item1,w=le.segmentWithTriangle(r.points[_],r.points[_+1],n.points,n.faces[v]);if(w!=null){var P=w.point,A=m.lerp(w.p,[r.params[_]],[r.params[_+1]])[0],I=rt.triangleUVFromPoint(n,v,P);c.push(new qn(P,A,I,_,v))}}return c},le.boundingBoxTrees=function(r,n,a){a==null&&(a=1e-9);var l=[],c=[];l.push(r),c.push(n);for(var d=[];l.length>0;){var p=l.pop(),_=c.pop();if(!(p.empty()||_.empty())&&p.boundingBox().intersects(_.boundingBox(),a)){var v=p.indivisible(a),w=_.indivisible(a);if(v&&w){d.push(new tt(p.yield(),_.yield()));continue}else if(v&&!w){var P=_.split();l.push(p),c.push(P.item1),l.push(p),c.push(P.item0);continue}else if(!v&&w){var A=p.split();l.push(A.item1),c.push(_),l.push(A.item0),c.push(_);continue}var I=p.split(),k=_.split();l.push(I.item1),c.push(k.item1),l.push(I.item1),c.push(k.item0),l.push(I.item0),c.push(k.item1),l.push(I.item0),c.push(k.item0)}}return d},le.curves=function(r,n,a){var l=le.boundingBoxTrees(new sr(r),new sr(n),0);return K.unique(l.map(function(c){return le.curvesWithEstimate(r,n,K.first(c.item0.knots),K.first(c.item1.knots),a)}).filter(function(c){return m.distSquared(c.point0,c.point1)<a}),function(c,d){return Math.abs(c.u0-d.u0)<a*5})},le.curvesWithEstimate=function(r,n,a,l,c){var d=function(I){var k=N.rationalCurvePoint(r,I[0]),T=N.rationalCurvePoint(n,I[1]),L=m.sub(k,T);return m.dot(L,L)},p=function(I){var k=N.rationalCurveDerivatives(r,I[0],1),T=N.rationalCurveDerivatives(n,I[1],1),L=m.sub(k[0],T[0]),C=k[1],R=m.mul(-1,T[1]);return[2*m.dot(C,L),2*m.dot(R,L)]},_=Yt.uncmin(d,[a,l],c*c,p),v=_.solution[0],w=_.solution[1],P=N.rationalCurvePoint(r,v),A=N.rationalCurvePoint(n,w);return new Kr(P,A,v,w)},le.triangles=function(r,n,a,l){var c=r.faces[n],d=a.faces[l],p=rt.getTriangleNorm(r.points,c),_=rt.getTriangleNorm(a.points,d),v=r.points[c[0]],w=a.points[d[0]],P=le.planes(v,p,w,_);if(P==null)return null;var A=le.clipRayInCoplanarTriangle(P,r,n);if(A==null)return null;var I=le.clipRayInCoplanarTriangle(P,a,l);if(I==null)return null;var k=le.mergeTriangleClipIntervals(A,I,r,n,a,l);return k==null?null:new wt(new Nr(k.min.uv0,k.min.uv1,k.min.point,n,l),new Nr(k.max.uv0,k.max.uv1,k.max.point,n,l))},le.clipRayInCoplanarTriangle=function(r,n,a){for(var l=n.faces[a],c=[n.points[l[0]],n.points[l[1]],n.points[l[2]]],d=[n.uvs[l[0]],n.uvs[l[1]],n.uvs[l[2]]],p=[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 k=I++,T=c[k],L=v[k],C=le.rays(T,L,r.origin,r.dir);if(C!=null){var R=C.u0,O=C.u1;R<-re.EPSILON||R>w[k]+re.EPSILON||((P==null||O<P.u)&&(P=new wn(O,m.onRay(r.origin,r.dir,O),m.onRay(d[k],p[k],R/w[k]))),(A==null||O>A.u)&&(A=new wn(O,m.onRay(r.origin,r.dir,O),m.onRay(d[k],p[k],R/w[k]))))}}return A==null||P==null?null:new wt(P,A)},le.mergeTriangleClipIntervals=function(r,n,a,l,c,d){if(n.min.u>r.max.u+re.EPSILON||r.min.u>n.max.u+re.EPSILON)return null;var p;r.min.u>n.min.u?p=new tt(r.min,0):p=new tt(n.min,1);var _;r.max.u<n.max.u?_=new tt(r.max,0):_=new tt(n.max,1);var v=new wt(new Nr(null,null,p.item0.point,l,d),new Nr(null,null,_.item0.point,l,d));return p.item1==0?(v.min.uv0=p.item0.uv,v.min.uv1=rt.triangleUVFromPoint(c,d,p.item0.point)):(v.min.uv0=rt.triangleUVFromPoint(a,l,p.item0.point),v.min.uv1=p.item0.uv),_.item1==0?(v.max.uv0=_.item0.uv,v.max.uv1=rt.triangleUVFromPoint(c,d,_.item0.point)):(v.max.uv0=rt.triangleUVFromPoint(a,l,_.item0.point),v.max.uv1=_.item0.uv),v},le.planes=function(r,n,a,l){var c=m.cross(n,l);if(m.dot(c,c)<re.EPSILON)return null;var d=0,p=Math.abs(c[0]),_=Math.abs(c[1]),v=Math.abs(c[2]);_>p&&(d=1,p=_),v>p&&(d=2,p=v);var w,P,A,I;d==0?(w=n[1],P=n[2],A=l[1],I=l[2]):d==1?(w=n[0],P=n[2],A=l[0],I=l[2]):(w=n[0],P=n[1],A=l[0],I=l[1]);var k=-m.dot(r,n),T=-m.dot(a,l),L=w*I-P*A,C=(P*T-k*I)/L,R=(k*A-w*T)/L,O;return d==0?O=[0,C,R]:d==1?O=[C,0,R]:O=[C,R,0],new xn(O,m.normalized(c))},le.threePlanes=function(r,n,a,l,c,d){var p=m.cross(a,c),_=m.dot(r,p);if(Math.abs(_)<re.EPSILON)return null;var v=m.sub(m.mul(d,a),m.mul(l,c)),w=m.add(m.mul(n,p),m.cross(r,v));return m.mul(1/_,w)},le.polylines=function(r,n,a){for(var l=le.boundingBoxTrees(new ar(r),new ar(n),a),c=[],d=0;d<l.length;){var p=l[d];++d;var _=p.item0,v=p.item1,w=le.segments(r.points[_],r.points[_+1],n.points[v],n.points[v+1],a);w!=null&&(w.u0=m.lerp(w.u0,[r.params[_]],[r.params[_+1]])[0],w.u1=m.lerp(w.u1,[n.params[v]],[n.params[v+1]])[0],c.push(w))}return c},le.segments=function(r,n,a,l,c){var d=m.sub(n,r),p=Math.sqrt(m.dot(d,d)),_=m.mul(1/p,d),v=m.sub(l,a),w=Math.sqrt(m.dot(v,v)),P=m.mul(1/w,v),A=le.rays(r,_,a,P);if(A!=null){var I=Math.min(Math.max(0,A.u0/p),1),k=Math.min(Math.max(0,A.u1/w),1),T=m.onRay(r,d,I),L=m.onRay(a,v,k),C=m.distSquared(T,L);if(C<c*c)return new Kr(T,L,I,k)}return null},le.rays=function(r,n,a,l){var c=m.dot(n,l),d=m.dot(n,a),p=m.dot(n,r),_=m.dot(l,a),v=m.dot(l,r),w=m.dot(n,n),P=m.dot(l,l),A=w*P-c*c;if(Math.abs(A)<re.EPSILON)return null;var I=c*(d-p)-w*(_-v),k=I/A,T=(d-p+k*c)/w,L=m.onRay(r,n,T),C=m.onRay(a,l,k);return new Kr(L,C,T,k)},le.segmentWithTriangle=function(r,n,a,l){var c=a[l[0]],d=a[l[1]],p=a[l[2]],_=m.sub(d,c),v=m.sub(p,c),w=m.cross(_,v),P=m.sub(n,r),A=m.sub(r,c),I=-m.dot(w,A),k=m.dot(w,P);if(Math.abs(k)<re.EPSILON)return null;var T=I/k;if(T<0||T>1)return null;var L=m.add(r,m.mul(T,P)),C=m.dot(_,v),R=m.dot(_,_),O=m.dot(v,v),F=m.sub(L,c),V=m.dot(F,_),q=m.dot(F,v),J=C*C-R*O;if(Math.abs(J)<re.EPSILON)return null;var H=(C*q-O*V)/J,j=(C*V-R*q)/J;return H>1+re.EPSILON||j>1+re.EPSILON||j<-re.EPSILON||H<-re.EPSILON||H+j>1+re.EPSILON?null:new Xn(L,H,j,T)},le.segmentAndPlane=function(r,n,a,l){var c=m.dot(l,m.sub(n,r));if(Math.abs(c)<re.EPSILON)return null;var d=m.dot(l,m.sub(a,r)),p=d/c;return p>1+re.EPSILON||p<-re.EPSILON?null:{p}};var me=f.eval.Make=function(){};x["verb.eval.Make"]=me,me.__name__=["verb","eval","Make"],me.rationalTranslationalSurface=function(r,n){for(var a=N.rationalCurvePoint(n,K.first(n.knots)),l=K.first(n.knots),c=K.last(n.knots),d=2*n.controlPoints.length,p=(c-l)/(d-1),_=[],v=0;v<d;){var w=v++,P=m.sub(N.rationalCurvePoint(n,l+w*p),a),A=fe.rationalCurveTransform(r,[[1,0,0,P[0]],[0,1,0,P[1]],[0,0,1,P[2]],[0,0,0,1]]);_.push(A)}return me.loftedSurface(_)},me.surfaceBoundaryCurves=function(r){var n=me.surfaceIsocurve(r,K.first(r.knotsU),!1),a=me.surfaceIsocurve(r,K.last(r.knotsU),!1),l=me.surfaceIsocurve(r,K.first(r.knotsV),!0),c=me.surfaceIsocurve(r,K.last(r.knotsV),!0);return[n,a,l,c]},me.surfaceIsocurve=function(r,n,a){a==null&&(a=!1);var l;a?l=r.knotsV:l=r.knotsU;var c;a?c=r.degreeV:c=r.degreeU;for(var d=ve.knotMultiplicities(l),p=-1,_=0,v=d.length;_<v;){var w=_++;if(Math.abs(n-d[w].knot)<re.EPSILON){p=w;break}}var P=c+1;p>=0&&(P=P-d[p].mult);var A;P>0?A=fe.surfaceKnotRefine(r,m.rep(P,n),a):A=r;var I=N.knotSpan(c,n,l);return Math.abs(n-K.first(l))<re.EPSILON?I=0:Math.abs(n-K.last(l))<re.EPSILON&&(I=(a?A.controlPoints[0].length:A.controlPoints.length)-1),a?new je(A.degreeU,A.knotsU,function(k){for(var T,L=[],C=0,R=A.controlPoints;C<R.length;){var O=R[C];++C,L.push(O[I])}return T=L,T}()):new je(A.degreeV,A.knotsV,A.controlPoints[I])},me.loftedSurface=function(r,n){r=fe.unifyCurveKnotVectors(r);var a=r[0].degree;n==null&&(n=3),n>r.length-1&&(n=r.length-1);for(var l=r[0].knots,c=[],d=[],p=0,_=r[0].controlPoints.length;p<_;){var v=[p++],w=r.map(function(A){return function(I){return I.controlPoints[A[0]]}}(v)),P=me.rationalInterpCurve(w,n,!0);d.push(P.controlPoints),c=P.knots}return new et(a,n,l,c,d)},me.clonedCurve=function(r){return new je(r.degree,r.knots.slice(),r.controlPoints.map(function(n){return n.slice()}))},me.rationalBezierCurve=function(r,n){for(var a=r.length-1,l=[],c=0,d=a+1;c<d;)c++,l.push(0);for(var p=0,_=a+1;p<_;)p++,l.push(1);return n==null&&(n=m.rep(r.length,1)),new je(a,l,N.homogenize1d(r,n))},me.fourPointSurface=function(r,n,a,l,c){c==null&&(c=3);for(var d=c,p=[],_=0,v=c+1;_<v;){for(var w=_++,P=[],A=0,I=c+1;A<I;){var k=A++,T=1-w/d,L=m.lerp(T,r,n),C=m.lerp(T,l,a),R=m.lerp(1-k/d,L,C);R.push(1),P.push(R)}p.push(P)}var O=m.rep(c+1,0),F=m.rep(c+1,1);return new et(c,c,O.concat(F),O.concat(F),p)},me.ellipseArc=function(r,n,a,l,c){var d=m.norm(n),p=m.norm(a);n=m.normalized(n),a=m.normalized(a),c<l&&(c=2*Math.PI+l);var _=c-l,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(r,m.add(m.mul(d*Math.cos(l),n),m.mul(p*Math.sin(l),a))),I=m.sub(m.mul(Math.cos(l),a),m.mul(Math.sin(l),n)),k=[],T=m.zeros1d(2*v+3),L=0,C=l,R=m.zeros1d(v*2);k[0]=A,R[0]=1;for(var O=1,F=v+1;O<F;){var V=O++;C+=w;var q=m.add(r,m.add(m.mul(d*Math.cos(C),n),m.mul(p*Math.sin(C),a)));R[L+2]=1,k[L+2]=q;var J=m.sub(m.mul(Math.cos(C),a),m.mul(Math.sin(C),n)),H=le.rays(A,m.mul(1/m.norm(I),I),q,m.mul(1/m.norm(J),J)),j=m.add(A,m.mul(H.u0,I));R[L+1]=P,k[L+1]=j,L+=2,V<v&&(A=q,I=J)}for(var X=2*v+1,ee=0;ee<3;){var te=ee++;T[te]=0,T[te+X]=1}switch(v){case 2:T[3]=T[4]=.5;break;case 3:T[3]=T[4]=.3333333333333333,T[5]=T[6]=.6666666666666666;break;case 4:T[3]=T[4]=.25,T[5]=T[6]=.5,T[7]=T[8]=.75;break}return new je(2,T,N.homogenize1d(k,R))},me.arc=function(r,n,a,l,c,d){return me.ellipseArc(r,m.mul(l,m.normalized(n)),m.mul(l,m.normalized(a)),c,d)},me.polyline=function(r){for(var n=[0,0],a=0,l=0,c=r.length-1;l<c;){var d=l++;a+=m.dist(r[d],r[d+1]),n.push(a)}n.push(a),n=m.mul(1/a,n);for(var p,_=[],v=0,w=r.length;v<w;)v++,_.push(1);return p=_,new je(1,n,N.homogenize1d(r.slice(0),p))},me.extrudedSurface=function(r,n,a){for(var l=[[],[],[]],c=[[],[],[]],d=N.dehomogenize1d(a.controlPoints),p=N.weight1d(a.controlPoints),_=m.mul(n,r),v=m.mul(.5*n,r),w=0,P=d.length;w<P;){var A=w++;l[2][A]=d[A],l[1][A]=m.add(v,d[A]),l[0][A]=m.add(_,d[A]),c[0][A]=p[A],c[1][A]=p[A],c[2][A]=p[A]}return new et(2,a.degree,[0,0,0,1,1,1],a.knots,N.homogenize2d(l,c))},me.cylindricalSurface=function(r,n,a,l,c){var d=m.cross(r,n),p=me.arc(a,n,d,c,0,2*Math.PI);return me.extrudedSurface(r,l,p)},me.revolvedSurface=function(r,n,a,l){var c=N.dehomogenize1d(r.controlPoints),d=N.weight1d(r.controlPoints),p,_;l<=Math.PI/2?(p=1,_=m.zeros1d(6+2*(p-1))):l<=Math.PI?(p=2,_=m.zeros1d(6+2*(p-1)),_[3]=_[4]=.5):l<=3*Math.PI/2?(p=3,_=m.zeros1d(6+2*(p-1)),_[3]=_[4]=.3333333333333333,_[5]=_[6]=.6666666666666666):(p=4,_=m.zeros1d(6+2*(p-1)),_[3]=_[4]=.25,_[5]=_[6]=.5,_[7]=_[8]=.75);for(var v=l/p,w=3+2*(p-1),P=0;P<3;){var A=P++;_[A]=0,_[w+A]=1}for(var I=Math.cos(v/2),k=0,T=m.zeros1d(p+1),L=m.zeros1d(p+1),C=m.zeros3d(2*p+1,c.length,3),R=m.zeros2d(2*p+1,c.length),O=1,F=p+1;O<F;){var V=O++;k+=v,L[V]=Math.cos(k),T[V]=Math.sin(k)}for(var q=0,J=c.length;q<J;){var H=q++,j=kt.rayClosestPoint(c[H],n,a),X=m.sub(c[H],j),ee=m.norm(X),te=m.cross(a,X);ee>re.EPSILON&&(X=m.mul(1/ee,X),te=m.mul(1/ee,te)),C[0][H]=c[H];var ie=c[H];R[0][H]=d[H];for(var he=te,ae=0,ue=1,ne=p+1;ue<ne;){var de=ue++,Y;ee==0?Y=j:Y=m.add(j,m.add(m.mul(ee*L[de],X),m.mul(ee*T[de],te))),C[ae+2][H]=Y,R[ae+2][H]=d[H];var pe=m.sub(m.mul(L[de],te),m.mul(T[de],X));if(ee==0)C[ae+1][H]=j;else{var Pe=le.rays(ie,m.mul(1/m.norm(he),he),Y,m.mul(1/m.norm(pe),pe)),Ge=m.add(ie,m.mul(Pe.u0,he));C[ae+1][H]=Ge}R[ae+1][H]=I*d[H],ae+=2,de<p&&(ie=Y,he=pe)}}return new et(2,r.degree,_,r.knots,N.homogenize2d(C,R))},me.sphericalSurface=function(r,n,a,l){var c=me.arc(r,m.mul(-1,n),a,l,0,Math.PI);return me.revolvedSurface(c,r,n,2*Math.PI)},me.conicalSurface=function(r,n,a,l,c){var d=2*Math.PI,p=1,_=[m.add(a,m.mul(l,r)),m.add(a,m.mul(c,n))],v=[0,0,1,1],w=[1,1],P=new je(p,v,N.homogenize1d(_,w));return me.revolvedSurface(P,a,r,d)},me.rationalInterpCurve=function(r,n,a,l,c){if(a==null&&(a=!1),n==null&&(n=3),r.length<n+1)throw new Q("You need to supply at least degree + 1 points! You only supplied "+r.length+" points.");for(var d=[0],p=1,_=r.length;p<_;){var v=p++,w=m.norm(m.sub(r[v],r[v-1])),P=d[d.length-1];d.push(P+w)}for(var A=d[d.length-1],I=0,k=d.length;I<k;){var T=I++;d[T]=d[T]/A}var L=m.rep(n+1,0),C=l!=null&&c!=null,R;C?R=0:R=1;var O;C?O=d.length-n+1:O=d.length-n;for(var F=R;F<O;){for(var V=F++,q=0,J=0;J<n;){var H=J++;q+=d[V+H]}L.push(1/n*q)}var j=L.concat(m.rep(n+1,1)),X=[],ee;C?ee=r.length+1:ee=r.length-1;var te;C?te=r.length-(n-1):te=r.length-(n+1);for(var ie=0;ie<d.length;){var he=d[ie];++ie;var ae=N.knotSpanGivenN(ee,n,he,j),ue=N.basisFunctionsGivenKnotSpanIndex(ae,he,n,j),ne=ae-n,de=m.zeros1d(ne),Y=m.zeros1d(te-ne);X.push(de.concat(ue).concat(Y))}if(C){var pe=X[0].length-2,Pe=[-1,1].concat(m.zeros1d(pe)),Ge=m.zeros1d(pe).concat([-1,1]);K.spliceAndInsert(X,1,0,Pe),K.spliceAndInsert(X,X.length-1,0,Ge)}for(var Xe=r[0].length,Fe=[],Ke=(1-j[j.length-n-2])/n,At=j[n+1]/n,Wt=0;Wt<Xe;){var vt=[Wt++],gt;if(!C)gt=r.map(function(Qt){return function(dr){return dr[Qt[0]]}}(vt));else{gt=[r[0][vt[0]]],gt.push(At*l[vt[0]]);for(var St=1,Tt=r.length-1;St<Tt;){var Kt=St++;gt.push(r[Kt][vt[0]])}gt.push(Ke*c[vt[0]]),gt.push(K.last(r)[vt[0]])}var or=Ce.solve(X,gt);Fe.push(or)}var $t=Ce.transpose(Fe);if(!a){var Zt=m.rep($t.length,1);$t=N.homogenize1d($t,Zt)}return new je(n,j,$t)};var fe=f.eval.Modify=function(){};x["verb.eval.Modify"]=fe,fe.__name__=["verb","eval","Modify"],fe.curveReverse=function(r){return new je(r.degree,fe.knotsReverse(r.knots),K.reversed(r.controlPoints))},fe.surfaceReverse=function(r,n){return n==null&&(n=!1),n?new et(r.degreeU,r.degreeV,r.knotsU,fe.knotsReverse(r.knotsV),function(a){for(var l,c=[],d=0,p=r.controlPoints;d<p.length;){var _=p[d];++d,c.push(K.reversed(_))}return l=c,l}()):new et(r.degreeU,r.degreeV,fe.knotsReverse(r.knotsU),r.knotsV,K.reversed(r.controlPoints))},fe.knotsReverse=function(r){var n=K.first(r);K.last(r);for(var a=[n],l=r.length,c=1;c<l;){var d=c++;a.push(a[d-1]+(r[l-d]-r[l-d-1]))}return a},fe.unifyCurveKnotVectors=function(r){r=r.map(me.clonedCurve);for(var n=D.fold(r,function(j,X){return fe.imax(j.degree,X)},0),a=0,l=r.length;a<l;){var c=a++;r[c].degree<n&&(r[c]=fe.curveElevateDegree(r[c],n))}for(var d,p=[],_=0;_<r.length;){var v=r[_];++_,p.push(new wt(K.first(v.knots),K.last(v.knots)))}d=p;for(var w=0,P=r.length;w<P;){var A=w++,I=[d[A].min];r[A].knots=r[A].knots.map(function(j){return function(X){return X-j[0]}}(I))}for(var k=d.map(function(j){return j.max-j.min}),T=D.fold(k,function(j,X){return Math.max(j,X)},0),L=0,C=r.length;L<C;){var R=L++,O=[T/k[R]];r[R].knots=r[R].knots.map(function(j){return function(X){return X*j[0]}}(O))}for(var F=D.fold(r,function(j,X){return m.sortedSetUnion(j.knots,X)},[]),V=0,q=r.length;V<q;){var J=V++,H=m.sortedSetSub(F,r[J].knots);H.length==0&&(r[J]=r[J]),r[J]=fe.curveKnotRefine(r[J],H)}return r},fe.imin=function(r,n){return r<n?r:n},fe.imax=function(r,n){return r>n?r:n},fe.curveElevateDegree=function(r,n){if(n<=r.degree)return r;var a=r.knots.length-r.degree-2,l=r.degree,c=r.knots,d=r.controlPoints,p=n-r.degree,_=r.controlPoints[0].length,v=m.zeros2d(l+p+1,l+1),w=[],P=[],A=[],I=a+l+1,k=n,T=Math.floor(k/2),L=[],C=[];v[0][0]=1,v[k][l]=1;for(var R=1,O=T+1;R<O;)for(var F=R++,V=1/De.get(k,F),q=fe.imin(l,F),J=fe.imax(0,F-p),H=q+1;J<H;){var j=J++;v[F][j]=V*De.get(l,j)*De.get(p,F-j)}for(var X=T+1;X<k;)for(var ee=X++,te=fe.imin(l,ee),ie=fe.imax(0,ee-p),he=te+1;ie<he;){var ae=ie++;v[ee][ae]=v[k-ee][l-ae]}var ue=k+1,ne=-1,de=l,Y=l+1,pe=1,Pe=c[0];L[0]=d[0];for(var Ge=0,Xe=k+1;Ge<Xe;){var Fe=Ge++;C[Fe]=Pe}for(var Ke=0,At=l+1;Ke<At;){var Wt=Ke++;w[Wt]=d[Wt]}for(;Y<I;){for(var vt=Y;Y<I&&c[Y]==c[Y+1];)Y=Y+1;var gt=Y-vt+1,St=c[Y],Tt=ne;ne=l-gt;var Kt;Tt>0?Kt=Math.floor((Tt+2)/2):Kt=1;var or;if(ne>0?or=Math.floor(k-(ne+1)/2):or=k,ne>0){for(var $t=St-Pe,Zt=[],Qt=l;Qt>gt;)Zt[Qt-gt-1]=$t/(c[de+Qt]-Pe),Qt--;for(var dr=1,Tn=ne+1;dr<Tn;){for(var Zr=dr++,Mc=ne-Zr,ji=gt+Zr,Qr=l;Qr>=ji;)w[Qr]=m.add(m.mul(Zt[Qr-ji],w[Qr]),m.mul(1-Zt[Qr-ji],w[Qr-1])),Qr--;A[Mc]=w[l]}}for(var fo=Kt,Tc=k+1;fo<Tc;){var Nn=fo++;P[Nn]=m.zeros1d(_);for(var Nc=fe.imin(l,Nn),_o=fe.imax(0,Nn-p),Cc=Nc+1;_o<Cc;){var vo=_o++;P[Nn]=m.add(P[Nn],m.mul(v[Nn][vo],w[vo]))}}if(Tt>1)for(var Gi=ue-2,Wi=ue,yo=St-Pe,Lc=(St-C[ue-1])/yo,bo=1;bo<Tt;){for(var Hi=bo++,mr=Gi,Jr=Wi,Fr=Jr-ue+1;Jr-mr>Hi;){if(mr<pe){var Oc=(St-C[mr])/(Pe-C[mr]);L[mr]=m.lerp(Oc,L[mr],L[mr-1])}if(Jr>=Kt){if(Jr-Hi<=ue-k+Tt){var zc=(St-C[Jr-Hi])/yo;P[Fr]=m.lerp(zc,P[Fr],P[Fr+1])}}else P[Fr]=m.lerp(Lc,P[Fr],P[Fr+1]);mr=mr+1,Jr=Jr-1,Fr=Fr-1}Gi=Gi-1,Wi=Wi+1}if(de!=l)for(var xo=0,Dc=k-Tt;xo<Dc;)xo++,C[ue]=Pe,ue=ue+1;for(var wo=Kt,Rc=or+1;wo<Rc;){var Bc=wo++;L[pe]=P[Bc],pe=pe+1}if(Y<I){for(var Ao=0;Ao<ne;){var So=Ao++;w[So]=A[So]}for(var Po=ne,Fc=l+1;Po<Fc;){var Io=Po++;w[Io]=d[Y-l+Io]}de=Y,Y=Y+1,Pe=St}else for(var Eo=0,Uc=k+1;Eo<Uc;){var Vc=Eo++;C[ue+Vc]=St}}return new je(n,C,L)},fe.rationalSurfaceTransform=function(r,n){for(var a=N.dehomogenize2d(r.controlPoints),l=0,c=a.length;l<c;)for(var d=l++,p=0,_=a[d].length;p<_;){var v=p++,w=a[d][v];w.push(1),a[d][v]=Ce.dot(n,w).slice(0,w.length-1)}return new et(r.degreeU,r.degreeV,r.knotsU.slice(),r.knotsV.slice(),N.homogenize2d(a,N.weight2d(r.controlPoints)))},fe.rationalCurveTransform=function(r,n){for(var a=N.dehomogenize1d(r.controlPoints),l=0,c=a.length;l<c;){var d=l++,p=a[d];p.push(1),a[d]=Ce.dot(n,p).slice(0,p.length-1)}return new je(r.degree,r.knots.slice(),N.homogenize1d(a,N.weight1d(r.controlPoints)))},fe.surfaceKnotRefine=function(r,n,a){var l=[],c,d,p;a?(p=r.controlPoints,c=r.knotsV,d=r.degreeV):(p=Ce.transpose(r.controlPoints),c=r.knotsU,d=r.degreeU);for(var _=null,v=0;v<p.length;){var w=p[v];++v,_=fe.curveKnotRefine(new je(d,c,w),n),l.push(_.controlPoints)}var P=_.knots;return a?new et(r.degreeU,r.degreeV,r.knotsU.slice(),P,l):(l=Ce.transpose(l),new et(r.degreeU,r.degreeV,P,r.knotsV.slice(),l))},fe.decomposeCurveIntoBeziers=function(r){for(var n=r.degree,a=r.controlPoints,l=r.knots,c=ve.knotMultiplicities(l),d=n+1,p=0;p<c.length;){var _=c[p];if(++p,_.mult<d){var v=m.rep(d-_.mult,_.knot),w=fe.curveKnotRefine(new je(n,l,a),v);l=w.knots,a=w.controlPoints}}l.length/d-1;for(var P=d*2,A=[],I=0;I<a.length;){var k=l.slice(I,I+P),T=a.slice(I,I+d);A.push(new je(n,k,T)),I+=d}return A},fe.curveKnotRefine=function(r,n){if(n.length==0)return me.clonedCurve(r);for(var a=r.degree,l=r.controlPoints,c=r.knots,d=l.length-1,p=d+a+1,_=n.length-1,v=N.knotSpan(a,n[0],c),w=N.knotSpan(a,n[_],c),P=[],A=[],I=0,k=v-a+1;I<k;){var T=I++;P[T]=l[T]}for(var L=w-1,C=d+1;L<C;){var R=L++;P[R+_+1]=l[R]}for(var O=0,F=v+1;O<F;){var V=O++;A[V]=c[V]}for(var q=w+a,J=p+1;q<J;){var H=q++;A[H+_+1]=c[H]}for(var j=w+a-1,X=w+a+_,ee=_;ee>=0;){for(;n[ee]<=c[j]&&j>v;)P[X-a-1]=l[j-a-1],A[X]=c[j],X=X-1,j=j-1;P[X-a-1]=P[X-a];for(var te=1,ie=a+1;te<ie;){var he=te++,ae=X-a+he,ue=A[X+he]-n[ee];Math.abs(ue)<re.EPSILON?P[ae-1]=P[ae]:(ue=ue/(A[X+he]-c[j-a+he]),P[ae-1]=m.add(m.mul(ue,P[ae-1]),m.mul(1-ue,P[ae])))}A[X]=n[ee],X=X-1,ee--}return new je(a,A,P)},fe.curveKnotInsert=function(r,n,a){for(var l=r.degree,c=r.controlPoints,d=r.knots,p=0,_=c.length,v=N.knotSpan(l,n,d),w=[],P=[],A=[],I=1,k=v+1;I<k;){var T=I++;P[T]=d[T]}for(var L=1,C=a+1;L<C;){var R=L++;P[v+R]=n}for(var O=v+1,F=d.length;O<F;){var V=O++;P[V+a]=d[V]}for(var q=0,J=v-l+1;q<J;){var H=q++;A[H]=c[H]}for(var j=v-p;j<_;){var X=j++;A[X+a]=c[X]}for(var ee=0,te=l-p+1;ee<te;){var ie=ee++;w[ie]=c[v-l+ie]}for(var he=0,ae=0,ue=1,ne=a+1;ue<ne;){var de=ue++;he=v-l+de;for(var Y=0,pe=l-de-p+1;Y<pe;){var Pe=Y++;ae=(n-d[he+Pe])/(d[Pe+v+1]-d[he+Pe]),w[Pe]=m.add(m.mul(ae,w[Pe+1]),m.mul(1-ae,w[Pe]))}A[he]=w[0],A[v+a-de-p]=w[l-de-p]}for(var Ge=he+1,Xe=v-p;Ge<Xe;){var Fe=Ge++;A[Fe]=w[Fe-he]}return new je(l,P,A)};var Oe=f.eval.Tess=function(){};x["verb.eval.Tess"]=Oe,Oe.__name__=["verb","eval","Tess"],Oe.rationalCurveRegularSample=function(r,n,a){return Oe.rationalCurveRegularSampleRange(r,r.knots[0],K.last(r.knots),n,a)},Oe.rationalCurveRegularSampleRange=function(r,n,a,l,c){l<1&&(l=2);for(var d=[],p=(a-n)/(l-1),_=0,v=0;v<l;){var w=v++;_=n+p*w,c?d.push([_].concat(N.rationalCurvePoint(r,_))):d.push(N.rationalCurvePoint(r,_))}return d},Oe.rationalCurveAdaptiveSample=function(r,n,a){if(a==null&&(a=!1),n==null&&(n=1e-6),r.degree==1)if(a){for(var l=[],c=0,d=r.controlPoints.length;c<d;){var p=c++;l.push([r.knots[p+1]].concat(N.dehomogenize(r.controlPoints[p])))}return l}else return r.controlPoints.map(N.dehomogenize);return Oe.rationalCurveAdaptiveSampleRange(r,r.knots[0],K.last(r.knots),n,a)},Oe.rationalCurveAdaptiveSampleRange=function(r,n,a,l,c){var d=N.rationalCurvePoint(r,n),p=N.rationalCurvePoint(r,a),_=.5+.2*Math.random(),v=n+(a-n)*_,w=N.rationalCurvePoint(r,v),P=m.sub(d,p),A=m.sub(d,w);if(m.dot(P,P)<l&&m.dot(A,A)>l||!kt.threePointsAreFlat(d,w,p,l)){var I=n+(a-n)*.5,k=Oe.rationalCurveAdaptiveSampleRange(r,n,I,l,c),T=Oe.rationalCurveAdaptiveSampleRange(r,I,a,l,c);return k.slice(0,-1).concat(T)}else return c?[[n].concat(d),[a].concat(p)]:[d,p]},Oe.rationalSurfaceNaive=function(r,n,a){n<1&&(n=1),a<1&&(a=1),r.degreeU,r.degreeV,r.controlPoints;for(var l=r.knotsU,c=r.knotsV,d=K.last(l)-l[0],p=K.last(c)-c[0],_=d/n,v=p/a,w=[],P=[],A=[],I=0,k=n+1;I<k;)for(var T=I++,L=0,C=a+1;L<C;){var R=L++,O=T*_,F=R*v;P.push([O,F]);var V=N.rationalSurfaceDerivatives(r,O,F,1),q=V[0][0];w.push(q);var J=m.normalized(m.cross(V[1][0],V[0][1]));A.push(J)}for(var H=[],j=0;j<n;)for(var X=j++,ee=0;ee<a;){var te=ee++,ie=X*(a+1)+te,he=(X+1)*(a+1)+te,ae=he+1,ue=ie+1,ne=[ie,he,ae],de=[ie,ae,ue];H.push(ne),H.push(de)}return new qt(H,w,A,P)},Oe.divideRationalSurfaceAdaptive=function(r,n){n==null&&(n=new Or),n.minDivsU!=null?n.minDivsU=n.minDivsU:n.minDivsU=1,n.minDivsV!=null?n.minDivsU=n.minDivsV:n.minDivsU=1,n.refine!=null?n.refine=n.refine:n.refine=!0;var a=(r.controlPoints.length-1)*2,l=(r.controlPoints[0].length-1)*2,c;n.minDivsU>a?c=n.minDivsU=n.minDivsU:c=n.minDivsU=a;var d;n.minDivsV>l?d=n.minDivsV=n.minDivsV:d=n.minDivsV=l;for(var p=K.last(r.knotsU),_=r.knotsU[0],v=K.last(r.knotsV),w=r.knotsV[0],P=(p-_)/c,A=(v-w)/d,I=[],k=[],T=0,L=d+1;T<L;){for(var C=T++,R=[],O=0,F=c+1;O<F;){var V=O++,q=_+P*V,J=w+A*C,H=N.rationalSurfaceDerivatives(r,q,J,1),j=m.normalized(m.cross(H[0][1],H[1][0]));R.push(new jt(H[0][0],j,[q,J],-1,m.isZero(j)))}k.push(R)}for(var X=0;X<d;)for(var ee=X++,te=0;te<c;){var ie=te++,he=[k[d-ee-1][ie],k[d-ee-1][ie+1],k[d-ee][ie+1],k[d-ee][ie]];I.push(new ur(r,he))}if(!n.refine)return I;for(var ae=0;ae<d;)for(var ue=ae++,ne=0;ne<c;){var de=ne++,Y=ue*c+de,pe=Oe.north(Y,ue,de,c,d,I),Pe=Oe.east(Y,ue,de,c,d,I),Ge=Oe.south(Y,ue,de,c,d,I),Xe=Oe.west(Y,ue,de,c,d,I);I[Y].neighbors=[Ge,Pe,pe,Xe],I[Y].divide(n)}return I},Oe.north=function(r,n,a,l,c,d){return n==0?null:d[r-l]},Oe.south=function(r,n,a,l,c,d){return n==c-1?null:d[r+l]},Oe.east=function(r,n,a,l,c,d){return a==l-1?null:d[r+1]},Oe.west=function(r,n,a,l,c,d){return a==0?null:d[r-1]},Oe.triangulateAdaptiveRefinementNodeTree=function(r){for(var n=qt.empty(),a=0;a<r.length;){var l=r[a];++a,l.triangulate(n)}return n},Oe.rationalSurfaceAdaptive=function(r,n){n!=null?n=n:n=new Or;var a=Oe.divideRationalSurfaceAdaptive(r,n);return Oe.triangulateAdaptiveRefinementNodeTree(a)};var Or=f.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"]=Or,Or.__name__=["verb","eval","AdaptiveRefinementOptions"],Or.prototype={__class__:Or};var ur=f.core.AdaptiveRefinementNode=function(r,n,a){if(this.srf=r,a==null?this.neighbors=[null,null,null,null]:this.neighbors=a,this.corners=n,this.corners==null){var l=r.knotsU[0],c=K.last(r.knotsU),d=r.knotsV[0],p=K.last(r.knotsV);this.corners=[jt.fromUv(l,d),jt.fromUv(c,d),jt.fromUv(c,p),jt.fromUv(l,p)]}};x["verb.eval.AdaptiveRefinementNode"]=ur,ur.__name__=["verb","eval","AdaptiveRefinementNode"],ur.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 r=0;r<4;){var n=r++;if(this.corners[n].point==null){var a=this.corners[n];this.evalSrf(a.uv[0],a.uv[1],a)}}},evalSrf:function(r,n,a){var l=N.rationalSurfaceDerivatives(this.srf,r,n,1),c=l[0][0],d=m.cross(l[0][1],l[1][0]),p=m.isZero(d);return p||(d=m.normalized(d)),a!=null?(a.degen=p,a.point=c,a.normal=d,a):new jt(c,d,[r,n],-1,p)},getEdgeCorners:function(r){if(this.isLeaf())return[this.corners[r]];if(this.horizontal)switch(r){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(r){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(r){var n=[this.corners[r]];if(this.neighbors[r]==null)return n;var a=this.neighbors[r].getEdgeCorners((r+2)%4),l=r%2,c=re.EPSILON,d=this,p=[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}],_=a.filter(p[l]);return _.reverse(),n.concat(_)},midpoint:function(r){if(this.midPoints==null&&(this.midPoints=[null,null,null,null]),this.midPoints[r]!=null)return this.midPoints[r];switch(r){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[r]},hasBadNormals:function(){return this.corners[0].degen||this.corners[1].degen||this.corners[2].degen||this.corners[3].degen},fixNormals:function(){for(var r=this.corners.length,n=0;n<r;){var a=n++;if(this.corners[a],this.corners[a].degen){var l=this.corners[(a+1)%r],c=this.corners[(a+3)%r];l.degen?this.corners[a].normal=c.normal:this.corners[a].normal=l.normal}}},shouldDivide:function(r,n){if(n<r.minDepth)return!0;if(n>=r.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))>r.normTol||m.normSquared(m.sub(this.corners[2].normal,this.corners[3].normal))>r.normTol,this.splitHoriz=m.normSquared(m.sub(this.corners[1].normal,this.corners[2].normal))>r.normTol||m.normSquared(m.sub(this.corners[3].normal,this.corners[0].normal))>r.normTol,this.splitVert||this.splitHoriz)return!0;var a=this.center();return m.normSquared(m.sub(a.normal,this.corners[0].normal))>r.normTol||m.normSquared(m.sub(a.normal,this.corners[1].normal))>r.normTol||m.normSquared(m.sub(a.normal,this.corners[2].normal))>r.normTol||m.normSquared(m.sub(a.normal,this.corners[3].normal))>r.normTol},divide:function(r){r==null&&(r=new Or),r.normTol==null&&(r.normTol=.085),r.minDepth==null&&(r.minDepth=0),r.maxDepth==null&&(r.maxDepth=10),this._divide(r,0,!0)},_divide:function(r,n,a){if(this.evalCorners(),!!this.shouldDivide(r,n)){if(n++,this.splitVert&&!this.splitHoriz?a=!1:!this.splitVert&&this.splitHoriz&&(a=!0),this.horizontal=a,this.horizontal){var l=[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 ur(this.srf,l),new ur(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]],p=[this.midpoint(0),this.corners[1],this.corners[2],this.midpoint(2)];this.children=[new ur(this.srf,d),new ur(this.srf,p)],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(r,n,!a)}}},triangulate:function(r){if(r==null&&(r=qt.empty()),this.isLeaf())return this.triangulateLeaf(r);for(var n=0,a=this.children;n<a.length;){var l=a[n];if(++n,l==null)break;l.triangulate(r)}return r},triangulateLeaf:function(r){for(var n=r.points.length,a=[],l=[],c=0,d=0;d<4;){var p=d++,_=this.getAllCorners(p);_.length==2&&(c=p+1);for(var v=0,w=_.length;v<w;){var P=v++;a.push(_[P])}}for(var A=0;A<a.length;){var I=a[A];if(++A,I.id!=-1){l.push(I.id);continue}r.uvs.push(I.uv),r.points.push(I.point),r.normals.push(I.normal),I.id=n,l.push(n),n++}if(a.length==4)return r.faces.push([l[0],l[3],l[1]]),r.faces.push([l[3],l[2],l[1]]),r;if(a.length==5){var k=l.length;return r.faces.push([l[c],l[(c+2)%k],l[(c+1)%k]]),r.faces.push([l[(c+4)%k],l[(c+3)%k],l[c]]),r.faces.push([l[c],l[(c+3)%k],l[(c+2)%k]]),r}var T=this.center();r.uvs.push(T.uv),r.points.push(T.point),r.normals.push(T.normal);for(var L=r.points.length-1,C=0,R=a.length-1;C<a.length;)r.faces.push([L,l[C],l[R]]),R=C++;return r},__class__:ur};var we=f.exe.Dispatcher=function(){};x["verb.exe.Dispatcher"]=we,we.__name__=["verb","exe","Dispatcher"],we.init=function(){we._init||(we._workerPool=new zr(we.THREADS),we._init=!0)},we.dispatchMethod=function(r,n,a){we.init();var l=new yn,c=function(d){l.resolve(d)};return we._workerPool.addWork(ce.getClassName(r),n,a,c),new pt(l)};var zr=f.exe.WorkerPool=function(r,n){n==null&&(n="verb.js"),r==null&&(r=1),this._callbacks=new xe,this._working=new xe,this._pool=[],this._queue=[];for(var a=0;a<r;){a++;var l;try{l=new Worker(zr.basePath+n)}catch(c){c instanceof Q&&(c=c.val),l=new Worker(zr.basePath+n.substring(0,-3)+".min.js")}this._pool.push(l)}};x["verb.exe.WorkerPool"]=zr,zr.__name__=["verb","exe","WorkerPool"],zr.prototype={addWork:function(r,n,a,l){var c=new $r(r,n,a);this._callbacks.set(c.id,l),this._queue.push(c),this.processQueue()},processQueue:function(){for(var r=this;this._queue.length>0&&this._pool.length>0;){var n=this._queue.shift(),a=[n.id],l=[this._pool.shift()];this._working.h[a[0]]=l[0],l[0].onmessage=function(c,d){return function(p){r._working.remove(d[0]),r._pool.push(c[0]);try{r._callbacks.h.hasOwnProperty(d[0])&&(r._callbacks.h[d[0]](p.data.result),r._callbacks.remove(d[0]))}catch(_){_ instanceof Q&&(_=_.val),b.log(_)}r.processQueue()}}(l,a),l[0].postMessage(n)}},__class__:zr};var $r=function(r,n,a){this.className=r,this.methodName=n,this.args=a,this.id=$r.uuid++};x["verb.exe._WorkerPool.Work"]=$r,$r.__name__=["verb","exe","_WorkerPool","Work"],$r.prototype={__class__:$r};var kn=function(){};x["verb.geom.ICurve"]=kn,kn.__name__=["verb","geom","ICurve"],kn.__interfaces__=[Pn],kn.prototype={__class__:kn};var Ne=f.geom.NurbsCurve=function(r){this._data=Gt.isValidNurbsCurveData(r)};x["verb.geom.NurbsCurve"]=Ne,Ne.__name__=["verb","geom","NurbsCurve"],Ne.__interfaces__=[kn],Ne.byKnotsControlPointsWeights=function(r,n,a,l){return new Ne(new je(r,n.slice(),N.homogenize1d(a,l)))},Ne.byPoints=function(r,n){return n==null&&(n=3),new Ne(me.rationalInterpCurve(r,n))},Ne.__super__=Ze,Ne.prototype=M(Ze.prototype,{degree:function(){return this._data.degree},knots:function(){return this._data.knots.slice(0)},controlPoints:function(){return N.dehomogenize1d(this._data.controlPoints)},weights:function(){return N.weight1d(this._data.controlPoints)},asNurbs:function(){return new je(this.degree(),this.knots(),N.homogenize1d(this.controlPoints(),this.weights()))},clone:function(){return new Ne(this._data)},domain:function(){return new wt(K.first(this._data.knots),K.last(this._data.knots))},transform:function(r){return new Ne(fe.rationalCurveTransform(this._data,r))},transformAsync:function(r){return we.dispatchMethod(fe,"rationalCurveTransform",[this._data,r]).then(function(n){return new Ne(n)})},point:function(r){return N.rationalCurvePoint(this._data,r)},pointAsync:function(r){return we.dispatchMethod(N,"rationalCurvePoint",[this._data,r])},tangent:function(r){return N.rationalCurveTangent(this._data,r)},tangentAsync:function(r){return we.dispatchMethod(N,"rationalCurveTangent",[this._data,r])},derivatives:function(r,n){return n==null&&(n=1),N.rationalCurveDerivatives(this._data,r,n)},derivativesAsync:function(r,n){return n==null&&(n=1),we.dispatchMethod(N,"rationalCurveDerivatives",[this._data,r,n])},closestPoint:function(r){return ve.rationalCurveClosestPoint(this._data,r)},closestPointAsync:function(r){return we.dispatchMethod(ve,"rationalCurveClosestPoint",[this._data,r])},closestParam:function(r){return ve.rationalCurveClosestParam(this._data,r)},closestParamAsync:function(r){return we.dispatchMethod(ve,"rationalCurveClosestParam",[this._data,r])},length:function(){return ve.rationalCurveArcLength(this._data)},lengthAsync:function(){return we.dispatchMethod(ve,"rationalCurveArcLength",[this._data])},lengthAtParam:function(r){return ve.rationalCurveArcLength(this._data,r)},lengthAtParamAsync:function(){return we.dispatchMethod(ve,"rationalCurveArcLength",[this._data])},paramAtLength:function(r,n){return ve.rationalCurveParamAtArcLength(this._data,r,n)},paramAtLengthAsync:function(r,n){return we.dispatchMethod(ve,"rationalCurveParamAtArcLength",[this._data,r,n])},divideByEqualArcLength:function(r){return lt.rationalCurveByEqualArcLength(this._data,r)},divideByEqualArcLengthAsync:function(r){return we.dispatchMethod(lt,"rationalCurveByEqualArcLength",[this._data,r])},divideByArcLength:function(r){return lt.rationalCurveByArcLength(this._data,r)},divideByArcLengthAsync:function(r){return we.dispatchMethod(lt,"rationalCurveByArcLength",[this._data,r])},split:function(r){return lt.curveSplit(this._data,r).map(function(n){return new Ne(n)})},splitAsync:function(r){return we.dispatchMethod(lt,"curveSplit",[this._data,r]).then(function(n){return n.map(function(a){return new Ne(a)})})},reverse:function(){return new Ne(fe.curveReverse(this._data))},reverseAsync:function(){return we.dispatchMethod(fe,"curveReverse",[this._data]).then(function(r){return new Ne(r)})},tessellate:function(r){return Oe.rationalCurveAdaptiveSample(this._data,r,!1)},tessellateAsync:function(r){return we.dispatchMethod(Oe,"rationalCurveAdaptiveSample",[this._data,r,!1])},__class__:Ne});var Dr=f.geom.Arc=function(r,n,a,l,c,d){Ne.call(this,me.arc(r,n,a,l,c,d)),this._center=r,this._xaxis=n,this._yaxis=a,this._radius=l,this._minAngle=c,this._maxAngle=d};x["verb.geom.Arc"]=Dr,Dr.__name__=["verb","geom","Arc"],Dr.__super__=Ne,Dr.prototype=M(Ne.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__:Dr});var Jn=f.geom.BezierCurve=function(r,n){Ne.call(this,me.rationalBezierCurve(r,n))};x["verb.geom.BezierCurve"]=Jn,Jn.__name__=["verb","geom","BezierCurve"],Jn.__super__=Ne,Jn.prototype=M(Ne.prototype,{__class__:Jn});var es=f.geom.Circle=function(r,n,a,l){Dr.call(this,r,n,a,l,0,Math.PI*2)};x["verb.geom.Circle"]=es,es.__name__=["verb","geom","Circle"],es.__super__=Dr,es.prototype=M(Dr.prototype,{__class__:es});var Mn=function(){};x["verb.geom.ISurface"]=Mn,Mn.__name__=["verb","geom","ISurface"],Mn.__interfaces__=[Pn],Mn.prototype={__class__:Mn};var Ie=f.geom.NurbsSurface=function(r){this._data=Gt.isValidNurbsSurfaceData(r)};x["verb.geom.NurbsSurface"]=Ie,Ie.__name__=["verb","geom","NurbsSurface"],Ie.__interfaces__=[Mn],Ie.byKnotsControlPointsWeights=function(r,n,a,l,c,d){return new Ie(new et(r,n,a,l,N.homogenize2d(c,d)))},Ie.byCorners=function(r,n,a,l){return new Ie(me.fourPointSurface(r,n,a,l))},Ie.byLoftingCurves=function(r,n){return new Ie(me.loftedSurface(function(a){for(var l,c=[],d=0;d<r.length;){var p=r[d];++d,c.push(p.asNurbs())}return l=c,l}(),n))},Ie.__super__=Ze,Ie.prototype=M(Ze.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 N.dehomogenize2d(this._data.controlPoints)},weights:function(){return N.weight2d(this._data.controlPoints)},asNurbs:function(){return new et(this.degreeU(),this.degreeV(),this.knotsU(),this.knotsV(),N.homogenize2d(this.controlPoints(),this.weights()))},clone:function(){return new Ie(this.asNurbs())},domainU:function(){return new wt(K.first(this._data.knotsU),K.last(this._data.knotsU))},domainV:function(){return new wt(K.first(this._data.knotsV),K.last(this._data.knotsV))},point:function(r,n){return N.rationalSurfacePoint(this._data,r,n)},pointAsync:function(r,n){return we.dispatchMethod(N,"rationalSurfacePoint",[this._data,r,n])},normal:function(r,n){return N.rationalSurfaceNormal(this._data,r,n)},normalAsync:function(r,n){return we.dispatchMethod(N,"rationalSurfaceNormal",[this._data,r,n])},derivatives:function(r,n,a){return a==null&&(a=1),N.rationalSurfaceDerivatives(this._data,r,n,a)},derivativesAsync:function(r,n,a){return a==null&&(a=1),we.dispatchMethod(N,"rationalSurfaceDerivatives",[this._data,r,n,a])},closestParam:function(r){return ve.rationalSurfaceClosestParam(this._data,r)},closestParamAsync:function(r){return we.dispatchMethod(ve,"rationalSurfaceClosestParam",[this._data,r])},closestPoint:function(r){return ve.rationalSurfaceClosestPoint(this._data,r)},closestPointAsync:function(r){return we.dispatchMethod(ve,"rationalSurfaceClosestPoint",[this._data,r])},split:function(r,n){return n==null&&(n=!1),lt.surfaceSplit(this._data,r,n).map(function(a){return new Ie(a)})},splitAsync:function(r,n){return n==null&&(n=!1),we.dispatchMethod(lt,"surfaceSplit",[this._data,r,n]).then(function(a){return a.map(function(l){return new Ie(l)})})},reverse:function(r){return r==null&&(r=!1),new Ie(fe.surfaceReverse(this._data,r))},reverseAsync:function(r){return r==null&&(r=!1),we.dispatchMethod(fe,"surfaceReverse",[this._data,r]).then(function(n){return new Ie(n)})},isocurve:function(r,n){return n==null&&(n=!1),new Ne(me.surfaceIsocurve(this._data,r,n))},isocurveAsync:function(r,n){return n==null&&(n=!1),we.dispatchMethod(me,"surfaceIsocurve",[this._data,r,n]).then(function(a){return new Ne(a)})},boundaries:function(r){return me.surfaceBoundaryCurves(this._data).map(function(n){return new Ne(n)})},boundariesAsync:function(r){return we.dispatchMethod(me,"surfaceBoundaryCurves",[this._data]).then(function(n){return n.map(function(a){return new Ne(a)})})},tessellate:function(r){return Oe.rationalSurfaceAdaptive(this._data,r)},tessellateAsync:function(r){return we.dispatchMethod(Oe,"rationalSurfaceAdaptive",[this._data,r])},transform:function(r){return new Ie(fe.rationalSurfaceTransform(this._data,r))},transformAsync:function(r){return we.dispatchMethod(fe,"rationalSurfaceTransform",[this._data,r]).then(function(n){return new Ie(n)})},__class__:Ie});var ts=f.geom.ConicalSurface=function(r,n,a,l,c){Ie.call(this,me.conicalSurface(r,n,a,l,c)),this._axis=r,this._xaxis=n,this._base=a,this._height=l,this._radius=c};x["verb.geom.ConicalSurface"]=ts,ts.__name__=["verb","geom","ConicalSurface"],ts.__super__=Ie,ts.prototype=M(Ie.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__:ts});var rs=f.geom.CylindricalSurface=function(r,n,a,l,c){Ie.call(this,me.cylindricalSurface(r,n,a,l,c)),this._axis=r,this._xaxis=n,this._base=a,this._height=l,this._radius=c};x["verb.geom.CylindricalSurface"]=rs,rs.__name__=["verb","geom","CylindricalSurface"],rs.__super__=Ie,rs.prototype=M(Ie.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__:rs});var Rr=f.geom.EllipseArc=function(r,n,a,l,c){Ne.call(this,me.ellipseArc(r,n,a,l,c)),this._center=r,this._xaxis=n,this._yaxis=a,this._minAngle=l,this._maxAngle=c};x["verb.geom.EllipseArc"]=Rr,Rr.__name__=["verb","geom","EllipseArc"],Rr.__super__=Ne,Rr.prototype=M(Ne.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__:Rr});var ns=f.geom.Ellipse=function(r,n,a){Rr.call(this,r,n,a,0,Math.PI*2)};x["verb.geom.Ellipse"]=ns,ns.__name__=["verb","geom","Ellipse"],ns.__super__=Rr,ns.prototype=M(Rr.prototype,{__class__:ns});var ss=f.geom.ExtrudedSurface=function(r,n){Ie.call(this,me.extrudedSurface(m.normalized(n),m.norm(n),r.asNurbs())),this._profile=r,this._direction=n};x["verb.geom.ExtrudedSurface"]=ss,ss.__name__=["verb","geom","ExtrudedSurface"],ss.__super__=Ie,ss.prototype=M(Ie.prototype,{profile:function(){return this._profile},direction:function(){return this._direction},__class__:ss});var Br=f.geom.Intersect=function(){};x["verb.geom.Intersect"]=Br,Br.__name__=["verb","geom","Intersect"],Br.curves=function(r,n,a){return a==null&&(a=.001),le.curves(r.asNurbs(),n.asNurbs(),a)},Br.curvesAsync=function(r,n,a){return a==null&&(a=.001),we.dispatchMethod(le,"curves",[r.asNurbs(),n.asNurbs(),a])},Br.curveAndSurface=function(r,n,a){return a==null&&(a=.001),le.curveAndSurface(r.asNurbs(),n.asNurbs(),a)},Br.curveAndSurfaceAsync=function(r,n,a){return a==null&&(a=.001),we.dispatchMethod(le,"curveAndSurface",[r.asNurbs(),n.asNurbs(),a])},Br.surfaces=function(r,n,a){return a==null&&(a=.001),le.surfaces(r.asNurbs(),n.asNurbs(),a).map(function(l){return new Ne(l)})},Br.surfacesAsync=function(r,n,a){return a==null&&(a=.001),we.dispatchMethod(le,"surfaces",[r.asNurbs(),n.asNurbs(),a]).then(function(l){return l.map(function(c){return new Ne(c)})})};var is=f.geom.Line=function(r,n){Ne.call(this,me.polyline([r,n])),this._start=r,this._end=n};x["verb.geom.Line"]=is,is.__name__=["verb","geom","Line"],is.__super__=Ne,is.prototype=M(Ne.prototype,{start:function(){return this._start},end:function(){return this._end},__class__:is});var as=f.geom.RevolvedSurface=function(r,n,a,l){Ie.call(this,me.revolvedSurface(r.asNurbs(),n,a,l)),this._profile=r,this._center=n,this._axis=a,this._angle=l};x["verb.geom.RevolvedSurface"]=as,as.__name__=["verb","geom","RevolvedSurface"],as.__super__=Ie,as.prototype=M(Ie.prototype,{profile:function(){return this._profile},center:function(){return this._center},axis:function(){return this._center},angle:function(){return this._angle},__class__:as});var os=f.geom.SphericalSurface=function(r,n){Ie.call(this,me.sphericalSurface(r,[0,0,1],[1,0,0],n)),this._center=r,this._radius=n};x["verb.geom.SphericalSurface"]=os,os.__name__=["verb","geom","SphericalSurface"],os.__super__=Ie,os.prototype=M(Ie.prototype,{center:function(){return this._center},radius:function(){return this._radius},__class__:os});var ls=f.geom.SweptSurface=function(r,n){Ie.call(this,me.rationalTranslationalSurface(r.asNurbs(),n.asNurbs())),this._profile=r,this._rail=n};x["verb.geom.SweptSurface"]=ls,ls.__name__=["verb","geom","SweptSurface"],ls.__super__=Ie,ls.prototype=M(Ie.prototype,{profile:function(){return this._profile},rail:function(){return this._rail},__class__:ls});function Xt(r){return r instanceof Array?function(){return z.iter(r)}:typeof r.iterator=="function"?Mt(r,r.iterator):r.iterator}var Fi,Ic=0;function Mt(r,n){if(n==null)return null;n.__id__==null&&(n.__id__=Ic++);var a;return r.hx__closures__==null?r.hx__closures__={}:a=r.hx__closures__[n.__id__],a==null&&(a=function(){return a.method.apply(a.scope,arguments)},a.scope=r,a.method=n,r.hx__closures__[n.__id__]=a),a}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 Ec=x.Int={__name__:["Int"]},kc=x.Dynamic={__name__:["Dynamic"]},uo=x.Float=Number;uo.__name__=["Float"];var mo=x.Bool=Boolean;mo.__ename__=["Bool"];var po=x.Class={__name__:["Class"]},go={};Array.prototype.map==null&&(Array.prototype.map=function(r){for(var n=[],a=0,l=this.length;a<l;){var c=a++;n[c]=r(this[c])}return n}),Array.prototype.filter==null&&(Array.prototype.filter=function(r){for(var n=[],a=0,l=this.length;a<l;){var c=a++,d=this[c];r(d)&&n.push(d)}return n});var Ui={},Vs=S.ArrayBuffer||ot;Vs.prototype.slice==null&&(Vs.prototype.slice=ot.sliceImpl),S.DataView;var Vi=S.Uint8Array||nr._new;(function(r,n){if(r.setImmediate)return;var a=1,l={},c=!1,d=r.document,p;function _(O){return l[a]=v.apply(n,O),a++}function v(O){var F=[].slice.call(arguments,1);return function(){typeof O=="function"?O.apply(n,F):new Function(""+O)()}}function w(O){if(c)setTimeout(v(w,O),0);else{var F=l[O];if(F){c=!0;try{F()}finally{P(O),c=!1}}}}function P(O){delete l[O]}function A(){p=function(){var O=_(arguments);return process.nextTick(v(w,O)),O}}function I(){if(r.postMessage&&!r.importScripts){var O=!0,F=r.onmessage;return r.onmessage=function(){O=!1},r.postMessage("","*"),r.onmessage=F,O}}function k(){var O="setImmediate$"+Math.random()+"$",F=function(V){V.source===r&&typeof V.data=="string"&&V.data.indexOf(O)===0&&w(+V.data.slice(O.length))};r.addEventListener?r.addEventListener("message",F,!1):r.attachEvent("onmessage",F),p=function(){var V=_(arguments);return r.postMessage(O+V,"*"),V}}function T(){var O=new MessageChannel;O.port1.onmessage=function(F){var V=F.data;w(V)},p=function(){var F=_(arguments);return O.port2.postMessage(F),F}}function L(){var O=d.documentElement;p=function(){var F=_(arguments),V=d.createElement("script");return V.onreadystatechange=function(){w(F),V.onreadystatechange=null,O.removeChild(V),V=null},O.appendChild(V),F}}function C(){p=function(){var O=_(arguments);return setTimeout(v(w,O),0),O}}var R=Object.getPrototypeOf&&Object.getPrototypeOf(r);R=R&&R.setTimeout?R:r,{}.toString.call(r.process)==="[object process]"?A():I()?k():r.MessageChannel?T():d&&"onreadystatechange"in d.createElement("script")?L():C(),R.setImmediate=p,R.clearImmediate=P})(new Function("return this")()),Ye.USE_CACHE=!1,Ye.USE_ENUM_INDEX=!1,Ye.BASE64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:",We.DEFAULT_RESOLVER=ce,We.BASE64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:",Le.count=0,at.i64tmp=function(r){var n,a=new Ve(0,0);return n=a,n}(),Te.__toStr={}.toString,nr.BYTES_PER_ELEMENT=1,Se.queue=new U,De.memo=new xe,re.TOLERANCE=1e-6,re.EPSILON=1e-10,re.VERSION="2.0.0",ve.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]],ve.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]],we.THREADS=1,we._init=!1,zr.basePath="",$r.uuid=0,Fs.main()}(typeof console<"u"?console:{log:function(){}},t,typeof u<"u"?u:typeof s<"u"?s:typeof self<"u"?self:this),t})})($h);var Hd=$h.exports;const On=Wd(Hd);class aa{constructor(){this.c0=0,this.c1=0,this.c2=0,this.c3=0}init(e,t,s,o){this.c0=e,this.c1=s,this.c2=-3*e+3*t-2*s-o,this.c3=2*e-2*t+s+o}initCatmullRom(e,t,s,o,h){this.init(t,s,h*(s-e),h*(o-t))}initNonuniformCatmullRom(e,t,s,o,h,u,g){let b=(t-e)/h-(s-e)/(h+u)+(s-t)/u,f=(s-t)/u-(o-t)/(u+g)+(o-s)/g;b*=u,f*=u,this.init(t,s,b,f)}calc(e){const t=e*e,s=t*e;return this.c0+this.c1*e+this.c2*t+this.c3*s}}class Zh extends Rs{constructor(e=[],t=!1,s="centripetal",o=.5){super(),this.isCatmullRomCurve3d=!0,this.type="CatmullRomCurve3d",this._tmp=new Z,this._px=new aa,this._py=new aa,this._pz=new aa,this._points=e.map(h=>new $(h)),this._closed=t,this._curveType=s,this._tension=o}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 $}get endPoint(){return this._points.length>0?this._points[this._points.length-1]:new $}get length(){if(this._points.length<2)return 0;let e=0;for(let t=1;t<this._points.length;t++)e+=this._points[t-1].distanceTo(this._points[t]);return this._closed&&this._points.length>2&&(e+=this._points[this._points.length-1].distanceTo(this._points[0])),e}getPoint(e,t=new $){const s=t,o=this._points,h=o.length;if(h===0)return s.set(0,0,0);if(h===1)return s.copy(o[0]);const u=(h-(this._closed?0:1))*e;let g=Math.floor(u),b=u-g;this._closed?g+=g>0?0:(Math.floor(Math.abs(g)/h)+1)*h:b===0&&g===h-1&&(g=h-2,b=1);let f,S;this._closed||g>0?f=o[(g-1)%h]:(this._tmp.subVectors(o[0],o[1]).add(o[0]),f=new $(this._tmp.x,this._tmp.y,this._tmp.z));const x=o[g%h],E=o[(g+1)%h];if(this._closed||g+2<h?S=o[(g+2)%h]:(this._tmp.subVectors(o[h-1],o[h-2]).add(o[h-1]),S=new $(this._tmp.x,this._tmp.y,this._tmp.z)),this._curveType==="centripetal"||this._curveType==="chordal"){const M=this._curveType==="chordal"?.5:.25;let z=Math.pow(f.distanceToSquared(x),M),D=Math.pow(x.distanceToSquared(E),M),U=Math.pow(E.distanceToSquared(S),M);D<1e-4&&(D=1),z<1e-4&&(z=D),U<1e-4&&(U=D),this._px.initNonuniformCatmullRom(f.x,x.x,E.x,S.x,z,D,U),this._py.initNonuniformCatmullRom(f.y,x.y,E.y,S.y,z,D,U),this._pz.initNonuniformCatmullRom(f.z,x.z,E.z,S.z,z,D,U)}else this._curveType==="catmullrom"&&(this._px.initCatmullRom(f.x,x.x,E.x,S.x,this._tension),this._py.initCatmullRom(f.y,x.y,E.y,S.y,this._tension),this._pz.initCatmullRom(f.z,x.z,E.z,S.z,this._tension));return s.set(this._px.calc(b),this._py.calc(b),this._pz.calc(b)),s}getPoints(e){const t=[];for(let s=0;s<=e;s++)t.push(this.getPoint(s/e));return t}setPoints(e){this._points=e.map(t=>new $(t)),this._boundingBoxNeedsUpdate=!0}setClosed(e){this._closed!==e&&(this._closed=e,this._boundingBoxNeedsUpdate=!0)}setCurveType(e){this._curveType=e}setTension(e){this._tension=e}transform(e){return this._points=this._points.map(t=>{const s=new $;return s.copy(t),s.applyMatrix3d(e),s}),this._boundingBoxNeedsUpdate=!0,this}calculateBoundingBox(){if(this._points.length===0)return new Re;const e=new Re;return this._points.forEach(t=>{e.expandByPoint(t)}),e}}class gn{constructor(e,t,s,o){this._degree=e,this._knots=[...t],this._controlPoints=s.map(h=>({x:h.x,y:h.y,z:h.z})),this._weights=o?[...o]:new Array(s.length).fill(1)}degree(){return this._degree}knots(){return[...this._knots]}controlPoints(){return this._controlPoints.map(e=>({x:e.x,y:e.y,z:e.z}))}weights(){return[...this._weights]}point(e){const t=this._controlPoints.map(s=>[s.x,s.y,s.z]);return Ts(e,this._degree,this._knots,t,this._weights)}length(){const e=this._controlPoints.map(t=>[t.x,t.y,t.z]);return Gh(this._degree,this._knots,e,this._weights)}static byKnotsControlPointsWeights(e,t,s,o){return new gn(e,t,s,o)}static byPoints(e,t,s="Uniform"){let o;switch(s){case"Chord":o=Vh(t,e);break;case"SqrtChord":o=jh(t,e);break;case"Uniform":default:o=Uh(t,e.length);break}const h=e.map(g=>({x:g[0],y:g[1],z:g[2]})),u=new Array(h.length).fill(1);return new gn(t,o,h,u)}getParameterRange(){const e=this._knots[this._degree],t=this._knots[this._knots.length-this._degree-1];return{start:e,end:t}}getPoints(e){const t=[],{start:s,end:o}=this.getParameterRange();for(let h=0;h<=e;h++){const u=s+(o-s)*(h/e);t.push(this.point(u))}return t}isClosed(e=1e-6){const{start:t,end:s}=this.getParameterRange(),o=this.point(t),h=this.point(s),u=o[0]-h[0],g=o[1]-h[1],b=o[2]-h[2];return Math.sqrt(u*u+g*g+b*b)<e}static createFitPointsForClosedCurve(e){if(e.length<4)throw new Error("At least 4 points are required for a closed NURBS curve");const t=new Zh(e,!0,"centripetal"),s=Math.max(50,e.length*2);return t.getPoints(s)}static createClosedCurve(e,t,s="Chord"){const o=this.createFitPointsForClosedCurve(e).map(h=>[h.x,h.y,h.z]);return gn.byPoints(o,t,s)}}class Yr extends Rs{constructor(e,t,s,o,h){super();const u=arguments.length;if(u<2||u>5)throw Ut.ILLEGAL_PARAMETERS;if(this._degree=3,this._closed=!1,Array.isArray(t)){this._controlPoints=e;let g,b=3,f=!1;if(u>=3&&(Array.isArray(s)?(g=s,u>=4&&(b=o||3),u>=5&&(f=h)):s!==void 0&&(b=s||3,u>=4&&(f=o))),s===void 0&&u>=4&&(b=o||3,u>=5&&(f=h)),this._degree=b,this._closed=f,this._controlPoints.length<this._degree+1)throw Ut.ILLEGAL_PARAMETERS;const S=this.toVerbPoints(this._controlPoints);this._nurbsCurve=On.geom.NurbsCurve.byKnotsControlPointsWeights(this._degree,t,S,g)}else{if(this._fitPoints=e,this._knotParameterization=t,u>=3&&(this._degree=s||3),u>=4&&(this._closed=o),this._fitPoints.length<this._degree+1)throw Ut.ILLEGAL_PARAMETERS;const g=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=On.geom.NurbsCurve.byPoints(g,this._degree),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}}buildCurve(){if(this._fitPoints&&this._knotParameterization){if(this._closed){const e=gn.createFitPointsForClosedCurve(this._fitPoints),t=this.toNurbsPoints(e);this._nurbsCurve=On.geom.NurbsCurve.byPoints(t,this._degree)}else{const e=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=On.geom.NurbsCurve.byPoints(e,this._degree)}this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}else if(this._controlPoints)if(this._closed){const e=gn.createFitPointsForClosedCurve(this._controlPoints),t=this.toNurbsPoints(e);this._nurbsCurve=On.geom.NurbsCurve.byPoints(t,this._degree),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}else{const e=this._nurbsCurve.knots(),t=this._nurbsCurve.weights(),s=this.toVerbPoints(this._controlPoints);this._nurbsCurve=On.geom.NurbsCurve.byKnotsControlPointsWeights(this._degree,e,s,t)}}setClosed(e){this._closed!==e&&(this._closed=e,this._boundingBoxNeedsUpdate=!0,this.buildCurve())}get degree(){return this._degree}get knotParameterization(){return this._knotParameterization}get startPoint(){const e=this._nurbsCurve.knots(),t=this._nurbsCurve.degree(),s=e[t],o=this._nurbsCurve.point(s);return new $(o[0],o[1],o[2])}get endPoint(){const e=this._nurbsCurve.knots(),t=this._nurbsCurve.degree(),s=e[e.length-t-1],o=this._nurbsCurve.point(s);return new $(o[0],o[1],o[2])}get length(){return this._nurbsCurve.length()}getFitPointAt(e){if(!this._fitPoints)throw new Error("No fit points in this spline");const t=this._fitPoints.length,s=e<0||e>=t?t-1:e,o=this._fitPoints[s];return{x:o.x,y:o.y,z:o.z||0}}getControlPointAt(e){const t=this._controlPoints.length,s=e<0||e>=t?t-1:e;return this._controlPoints[s]}getPoints(e=100){const t=this._nurbsCurve,s=[],o=t.knots(),h=this._nurbsCurve.degree(),u=o[h],g=o[o.length-h-1],b=(g-u)/(e-1);for(let f=0;f<e;f++){const S=f===e-1?g:u+f*b,x=t.point(S);s.push(new $(x[0],x[1],x[2]))}return s}getCurvePoints(e,t){const s=[],o=e.knots(),h=o[3],u=(o[o.length-4]-h)/(t-1);for(let g=0;g<t;g++){const b=h+g*u;s.push(e.point(b))}return s}calculateBoundingBox(){const e=this.getPoints(100);return new Re().setFromPoints(e)}get closed(){return this._closed}set closed(e){this.setClosed(e)}transform(e){return this._boundingBoxNeedsUpdate=!0,this}toNurbsPoints(e){const t=new Array(e.length);return e.forEach((s,o)=>{t[o]=[s.x,s.y,s.z||0]}),t}toVerbPoints(e){const t=new Array(e.length);return e.forEach((s,o)=>{t[o]=[s.x,s.y,s.z||0]}),t}toGePoints(e){const t=new Array(e.length);return e.forEach((s,o)=>{t[o]={x:s[0],y:s[1],z:s[2]}}),t}static createClosedSpline(e,t="Uniform",s=3){if(e.length<s+1)throw new Error(`At least ${s+1} points are required for a degree ${s} closed spline`);return new Yr(e,t,s,!0)}}var dn=256,Qh=[],Vo=256,Hs;for(;dn--;)Qh[dn]=(dn+256).toString(16).substring(1);function qd(i){var e=0,t=11;if(!Hs||dn+t>Vo*2)for(Hs="",dn=0;e<Vo;e++)Hs+=Qh[Math.random()*256|0];return Hs.substring(dn,dn+++t)}class Xr{constructor(e,t){e=e||{},Fn(e,{objectId:qd()}),this._attrs=new Zo(e,t)}get attrs(){return this._attrs}getAttr(e){const t=this._attrs.get(e);if(t===void 0)throw new Error(`[AcDbObject] Attribute name '${e}' does't exist in this object!`);return t}getAttrWithoutException(e){return this._attrs.get(e)}setAttr(e,t){this._attrs.set(e,t)}get objectId(){return this.getAttr("objectId")}set objectId(e){this._attrs.set("objectId",e)}get ownerId(){return this.getAttr("ownerId")}set ownerId(e){this._attrs.set("ownerId",e)}get database(){return this._database?this._database:Da().workingDatabase}set database(e){this._database=e}close(){}}const Ra=class Ra extends Xr{constructor(){super(...arguments),this._layer="0",this._color=new Wr,this._lineType=Js,this._lineWeight=1,this._linetypeScale=-1,this._visibility=!0,this._transparency=0}get type(){return this.constructor.typeName}get layer(){return this._layer}set layer(e){this._layer=e}get color(){return this._color}set color(e){this._color.copy(e)}get rgbColor(){let e=this.database.cecolor;if(this.color.isByLayer){const t=this.getLayerColor();t&&t.color&&(e=t)}else this.color.isByBlock||this.color.color!=null&&(e=this.color);return e.color==null?16777215:e.color}get lineType(){return this._lineType}set lineType(e){this._lineType=e||Js}get lineWeight(){return this._lineWeight}set lineWeight(e){this._lineWeight=e}get linetypeScale(){return this._linetypeScale}set linetypeScale(e){this._linetypeScale=e}get visibility(){return this._visibility}set visibility(e){this._visibility=e}get transparency(){return this._transparency}set transparency(e){this._transparency=e}subGetGripPoints(){return new Array}subGetOsnapPoints(e,t,s,o,h){}transformBy(e){return this}triggerModifiedEvent(){this.database.events.entityModified.dispatch({database:this.database,entity:this})}get lineStyle(){var s;const e=this.getLineType(),t=(s=this.database)==null?void 0:s.tables.linetypeTable.getAt(e);return t?{...t.linetype,color:this.rgbColor}:{name:e,standardFlag:0,color:this.rgbColor,description:"",totalPatternLength:0}}getLineType(){if(this.lineType==Js){const e=this.database.tables.layerTable.getAt(this.layer);if(e&&e.linetype)return e.linetype}else return this.lineType==mh?ti:this.lineType;return ti}getLayerColor(){const e=this.database.tables.layerTable.getAt(this.layer);if(e==null)console.error(`The layer with name '${this.layer}' not found in drawing database!`);else return e.color;return null}attachEntityInfo(e){e&&(e.objectId=this.objectId,e.ownerId=this.ownerId,e.layerName=this.layer,e.visible=this.visibility)}};Ra.typeName="Entity";let Ht=Ra;const Ba=class Ba extends Ht{constructor(e){super(),this._blockName=e,this._position=new $,this._rotation=0,this._normal=new Z(0,0,1),this._scaleFactors=new $(1,1,1)}get position(){return this._position}set position(e){this._position.copy(e)}get rotation(){return this._rotation}set rotation(e){this._rotation=e}get scaleFactors(){return this._scaleFactors}set scaleFactors(e){this._scaleFactors.copy(e)}get normal(){return this._normal}set normal(e){this._normal.copy(e).normalize()}get blockTableRecord(){return this.database.tables.blockTable.getAt(this._blockName)}get geometricExtents(){const e=new Re,t=this.blockTableRecord;if(t!=null){const h=t.newIterator();for(const u of h)e.union(u.geometricExtents)}const s=new Hr().setFromEuler(new Yh(this.rotation,0,0)),o=new fn;return o.compose(this.position,s,this.scaleFactors),e.applyMatrix4(o),e}draw(e){const t=[],s=this.blockTableRecord;if(s!=null){const o=this.computeTransformMatrix(),h=Gr.instance.draw(e,s,this.rgbColor,!0,o,this.normal);return this.attachEntityInfo(h),h}else{const o=e.group(t);return this.attachEntityInfo(o),o}}computeTransformMatrix(){const e=new Hr;return e.setFromAxisAngle(Z.Z_AXIS,this.rotation),new fn().compose(this._position,e,this._scaleFactors)}};Ba.typeName="BlockReference";let Ls=Ba;const Fa=class Fa extends Ht{};Fa.typeName="Curve";let Vt=Fa;const Ua=class Ua extends Vt{constructor(e,t,s,o,h,u,g){super(),this._geo=new Ci(e,t,s,o,h,u,g)}get center(){return this._geo.center}set center(e){this._geo.center=e}get majorAxisRadius(){return this._geo.majorAxisRadius}set majorAxisRadius(e){this._geo.majorAxisRadius=e}get minorAxisRadius(){return this._geo.minorAxisRadius}set minorAxisRadius(e){this._geo.minorAxisRadius=e}get normal(){return this._geo.normal}set normal(e){this._geo.normal=e}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}draw(e){return e.ellipticalArc(this._geo,this.lineStyle)}};Ua.typeName="Ellipse";let ni=Ua;const Va=class Va extends Vt{constructor(e,t,s,o){super(),this._geo=new pn(e,t,s,o,Z.Z_AXIS,Z.X_AXIS)}get center(){return this._geo.center}set center(e){this._geo.center=e}get radius(){return this._geo.radius}set radius(e){this._geo.radius=e}get startAngle(){return this._geo.startAngle}set startAngle(e){this._geo.startAngle=e}get endAngle(){return this._geo.endAngle}set endAngle(e){this._geo.endAngle=e}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 e=new Array;return e.push(this.center),e.push(this.startPoint),e.push(this.endPoint),e}transformBy(e){return this._geo.transform(e),this}draw(e){return e.circularArc(this._geo,this.lineStyle)}};Va.typeName="Arc";let si=Va;const ja=class ja extends Vt{constructor(e,t,s=Z.Z_AXIS){super(),this._geo=new pn(e,t,0,nt,s,Z.X_AXIS)}get center(){return this._geo.center}set center(e){this._geo.center=e}get radius(){return this._geo.radius}set radius(e){this._geo.radius=e}get normal(){return this._geo.normal}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}subGetGripPoints(){const e=new Array;return e.push(this.center),e}transformBy(e){return this._geo.transform(e),this}draw(e){return e.circularArc(this._geo,this.lineStyle)}};ja.typeName="Circle";let ii=ja;var Jh=(i=>(i[i.UserDefined=0]="UserDefined",i[i.Predefined=1]="Predefined",i[i.Custom=2]="Custom",i))(Jh||{}),ec=(i=>(i[i.Normal=0]="Normal",i[i.Outer=1]="Outer",i[i.Ignore=2]="Ignore",i))(ec||{});const Ga=class Ga extends Ht{constructor(){super(),this._elevation=0,this._geo=new Ti,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(e){this._patternName=e}get patternType(){return this._patternType}set patternType(e){this._patternType=e}get patternAngle(){return this._patternAngle}set patternAngle(e){this._patternAngle=e}get patternScale(){return this._patternScale}set patternScale(e){this._patternScale=e}get hatchStyle(){return this._hatchStyle}set hatchStyle(e){this._hatchStyle=e}add(e){this._geo.add(e)}get geometricExtents(){const e=this._geo.box;return new Re({x:e.min.x,y:e.min.y,z:this._elevation},{x:e.max.x,y:e.max.y,z:this._elevation})}draw(e){return e.area(this._geo,{color:this.rgbColor,solidFill:!1,patternAngle:this.patternAngle,patternLines:this.definitionLines})}};Ga.typeName="Hatch";let ai=Ga;var tc=(i=>(i[i.MText=0]="MText",i[i.Fcf=1]="Fcf",i[i.BlockReference=2]="BlockReference",i[i.NoAnnotation=3]="NoAnnotation",i))(tc||{});const Wa=class Wa extends Vt{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(e){this._isSplined=e}get hasArrowHead(){return this._hasArrowHead}set hasArrowHead(e){this._hasArrowHead=e}get hasHookLine(){return this._hasHookLine}set hasHookLine(e){this._hasHookLine=e}get numVertices(){return this._vertices.length}get dimensionStyle(){return this._dimensionStyle}set dimensionStyle(e){this._dimensionStyle=e}get annoType(){return this._annoType}set annoType(e){this._annoType=e}appendVertex(e){this._vertices.push(new $().copy(e)),this._updated=!0}setVertexAt(e,t){throw(e<0||e>=this._vertices.length)&&(this._vertices[e].copy(t),this._updated=!0),new Error("The vertex index is out of range!")}vertexAt(e){throw(e<0||e>=this._vertices.length)&&this._vertices[e],new Error("The vertex index is out of range!")}get geometricExtents(){return this._isSplined&&this.splineGeo?this.splineGeo.calculateBoundingBox():new Re().setFromPoints(this._vertices)}get closed(){return!1}set closed(e){}draw(e){if(this.isSplined&&this.splineGeo){const t=this.splineGeo.getPoints(100);return e.lines(t,this.lineStyle)}else return e.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 Yr(this._vertices,"Uniform"),this._updated=!1)}};Wa.typeName="Leader";let oi=Wa;const Ha=class Ha extends Vt{constructor(e,t){super(),this._geo=new qr(e,t)}get startPoint(){return this._geo.startPoint}set startPoint(e){this._geo.startPoint=e}get endPoint(){return this._geo.endPoint}set endPoint(e){this._geo.endPoint=e}get midPoint(){return this._geo.midPoint}get geometricExtents(){return this._geo.box}get closed(){return!1}subGetGripPoints(){const e=new Array;return e.push(this.midPoint),e.push(this.startPoint),e.push(this.endPoint),e}subGetOsnapPoints(e,t,s,o,h){const u=this.startPoint,g=this.endPoint;switch(e){case un.EndPoint:h.push(u),h.push(g);break;case un.MidPoint:h.push(this.midPoint);break;case un.Nearest:{const b=this._geo.project(s);h.push(b)}break;case un.Perpendicular:{const b=this._geo.perpPoint(s);h.push(b)}break;case un.Tangent:h.push(u);break}}transformBy(e){return this._geo.transform(e),this}draw(e){const t=this.startPoint,s=this.endPoint,o=[new $(t.x,t.y,0),new $(s.x,s.y,0)];return e.lines(o,this.lineStyle)}};Ha.typeName="Line";let li=Ha;var Ta=(i=>(i.ClosedFilled="",i.Dot="_DOT",i.DotSmall="_DOTSMALL",i.DotBlank="_DOTBLANK",i.Origin="_ORIGIN",i.Origin2="_ORIGIN2",i.Open="_OPEN",i.Open90="_OPEN90",i.Open30="_OPEN30",i.Closed="_CLOSED",i.Small="_SMALL",i.None="_NONE",i.Oblique="_OBLIQUE",i.BoxFilled="_BOXFILLED",i.Box="_BOXBLANK",i.ClosedBlank="_CLOSEDBLANK",i.DatumBlank="_DATUMBLANK",i.DatumFilled="_DATUMFILLED",i.Integral="_INTEGRAL",i.ArchTick="_ARCHTICK",i))(Ta||{}),Oi=(i=>(i[i.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",i[i.RIGHT_TO_LEFT=2]="RIGHT_TO_LEFT",i[i.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",i[i.BOTTOM_TO_TOP=4]="BOTTOM_TO_TOP",i[i.BY_STYLE=5]="BY_STYLE",i))(Oi||{}),Rn=(i=>(i[i.TopLeft=1]="TopLeft",i[i.TopCenter=2]="TopCenter",i[i.TopRight=3]="TopRight",i[i.MiddleLeft=4]="MiddleLeft",i[i.MiddleCenter=5]="MiddleCenter",i[i.MiddleRight=6]="MiddleRight",i[i.BottomLeft=7]="BottomLeft",i[i.BottomCenter=8]="BottomCenter",i[i.BottomRight=9]="BottomRight",i))(Rn||{}),Na=(i=>(i[i.OPTIMIZED_2D=0]="OPTIMIZED_2D",i[i.WIREFRAME=1]="WIREFRAME",i[i.HIDDEN_LINE=2]="HIDDEN_LINE",i[i.FLAT_SHADED=3]="FLAT_SHADED",i[i.GOURAUD_SHADED=4]="GOURAUD_SHADED",i[i.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",i[i.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME",i))(Na||{}),Ca=(i=>(i[i.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",i[i.TOP=1]="TOP",i[i.BOTTOM=2]="BOTTOM",i[i.FRONT=3]="FRONT",i[i.BACK=4]="BACK",i[i.LEFT=5]="LEFT",i[i.RIGHT=6]="RIGHT",i))(Ca||{}),La=(i=>(i[i.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",i[i.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS",i))(La||{});class zi{constructor(){this._number=-1,this._id="",this._groupId="",this._centerPoint=new $,this._height=0,this._width=0,this._viewCenter=new $,this._viewHeight=0}get number(){return this._number}set number(e){this._number=e}get id(){return this._id}set id(e){this._id=e}get groupId(){return this._groupId}set groupId(e){this._groupId=e}get centerPoint(){return this._centerPoint}set centerPoint(e){this._centerPoint.copy(e)}get height(){return this._height}set height(e){this._height=e}get width(){return this._width}set width(e){this._width=e}get box(){const e=new _t;return e.setFromCenterAndSize(this.centerPoint,{x:this.width,y:this.height}),e}get viewCenter(){return this._viewCenter}set viewCenter(e){this._viewCenter.copy(e)}get viewHeight(){return this._viewHeight}set viewHeight(e){this._viewHeight=e}get viewWidth(){return this.viewHeight*(this.width/this.height)}get viewBox(){const e=new _t;return e.setFromCenterAndSize(this.viewCenter,{x:this.viewWidth,y:this.viewHeight}),e}clone(){const e=new zi;return e.id=this.id,e.groupId=this.groupId,e.number=this.number,e.centerPoint.copy(this.centerPoint),e.height=this.height,e.width=this.width,e.viewCenter.copy(this.viewCenter),e.viewHeight=this.viewHeight,e}copy(e){return this.id=e.id,this.groupId=e.groupId,this.number=e.number,this.centerPoint.copy(e.centerPoint),this.height=e.height,this.width=e.width,this.viewCenter.copy(e.viewCenter),this.viewHeight=e.viewHeight,this}}const qa=class qa extends Ht{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 $,this._attachmentPoint=Rn.TopLeft,this._direction=new Z(1,0,0),this._drawingDirection=Oi.LEFT_TO_RIGHT}get contents(){return this._contents}set contents(e){this._contents=e}get height(){return this._height}set height(e){this._height=e}get width(){return this._width}set width(e){this._width=e}get rotation(){return this._rotation}set rotation(e){this._rotation=e}get lineSpacingFactor(){return this._lineSpacingFactor}set lineSpacingFactor(e){this._lineSpacingFactor=e}get lineSpacingStyle(){return this._lineSpacingStyle}set lineSpacingStyle(e){this._lineSpacingStyle=e}get backgroundFill(){return this._backgroundFill}set backgroundFill(e){this._backgroundFill=e,this._backgroundFillColor=13158600}get backgroundFillColor(){return this._backgroundFillColor}set backgroundFillColor(e){this._backgroundFillColor=e}get backgroundFillTransparency(){return this._backgroundFillTransparency}set backgroundFillTransparency(e){this._backgroundFillTransparency=e}get backgroundScaleFactor(){return this._backgroundScaleFactor}set backgroundScaleFactor(e){this._backgroundScaleFactor=e}get styleName(){return this._styleName}set styleName(e){this._styleName=e}get location(){return this._location}set location(e){this._location.copy(e)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(e){this._attachmentPoint=e}get direction(){return this._direction}set direction(e){this._direction.copy(e)}get drawingDirection(){return this._drawingDirection}set drawingDirection(e){this._drawingDirection=e}get geometricExtents(){return new Re}getTextStyle(){const e=this.database.tables.textStyleTable;let t=e.getAt(this.styleName);return t||(t=e.getAt("STANDARD")||e.getAt("Standard")),t.textStyle}draw(e,t){const s={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},o={...this.getTextStyle(),color:this.rgbColor};return e.mtext(s,o,t)}};qa.typeName="MText";let hi=qa;const Ya=class Ya extends Vt{constructor(e,t,s,o,h){super();const u=+(e!==void 0)+ +(t!==void 0)+ +(s!==void 0)+ +(o!==void 0)+ +(h!==void 0);if(u<2||u>5)throw Ut.ILLEGAL_PARAMETERS;!Array.isArray(t)?this._geo=new Yr(e,t,s,o):this._geo=new Yr(e,t,s,o,h)}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}set closed(e){this._geo.closed=e}draw(e){const t=this._geo.getPoints(100);return e.lines(t,this.lineStyle)}};Ya.typeName="Spline";let Os=Ya;const Yd=new Z,Xa=class Xa extends Ls{constructor(e,t,s){super(e),this._attachmentPoint=Rn.TopLeft,this._numColumns=s,this._numRows=t,this._columnWidth=new Array(s),this._rowHeight=new Array(t),this._cells=new Array(t*s)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(e){this._attachmentPoint=e}get numRows(){return this._numRows}set numRows(e){this._numRows=e}get numColumns(){return this._numColumns}set numColumns(e){this._numColumns=e}numContents(e,t){return 1}rowHeight(e){return this._rowHeight[e]}setRowHeight(e,t){this._rowHeight[e]=t}setUniformRowHeight(e){this._rowHeight.fill(e)}columnWidth(e){return this._columnWidth[e]}setUniformColumnWidth(e){this._columnWidth.fill(e)}setColumnWidth(e,t){this._columnWidth[e]=t}cell(e){if(!(e<0||e>=this._cells.length))return this._cells[e]}setCell(e,t){this._cells[e]=t}textString(e,t,s){return this._cells[e*t].text}setTextString(e,t,s){this._cells[e*t].text=s}isEmpty(e,t){return!this._cells[e*t].text}get geometricExtents(){return new Re}draw(e){let t=0,s=0;const o=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++){t-=E>0?this.rowHeight(E-1):0,s=0;for(let M=0;M<=this.numColumns;M++)s+=M>0?this.columnWidth(M-1):0,h[u++]=s,h[u++]=t,h[u++]=0}const g=[],b=new Array(this.numRows*this.numColumns).fill(!1);s=0,u=0;let f=0;for(let E=0;E<this.numColumns;E++){s+=E>0?this.columnWidth(E-1):0,t=0;for(let M=0;M<this.numRows;M++){t+=M>0?this.rowHeight(M-1):0;const z=this.cell(M*this.numColumns+E);if(f=M*this.numColumns+E,z&&!b[f]){const D=z.borderWidth??1,U=z.borderHeight??1;this.fillVisited(b,f,this.numColumns,D,U),o[u++]=E+M*(this.numColumns+1),o[u++]=E+M*(this.numColumns+1)+D;const B=h[o[u-1]*3]-s,ge=E+(M+U)*(this.numColumns+1)+D;E+D==this.numColumns&&(o[u++]=E+M*(this.numColumns+1)+D,o[u++]=ge);const be=-h[ge*3+1]-t;if(M+U==this.numRows&&(o[u++]=E+(M+U)*(this.numColumns+1)+U,o[u++]=E+(M+U)*(this.numColumns+1)),o[u++]=E+(M+U)*(this.numColumns+1),o[u++]=E+M*(this.numColumns+1),z.text){const oe=z.attachmentPoint||this.attachmentPoint||Rn.MiddleCenter,W=this.getTableTextOffset(oe,B,be),ce={text:z.text,height:z.textHeight,width:B,position:Yd.set(s,-t,0).clone().add(W),rotation:this.rotation,attachmentPoint:oe},se={...this.getTextStyle(z),color:this.color.color};g.push(e.mtext(ce,se))}}}}g.push(e.lineSegments(h,3,o,this.lineStyle));const S=e.group(g),x=new Hr;return x.setFromAxisAngle(Z.Z_AXIS,this.rotation),jo.compose(this.position,x,this.scaleFactors),S.applyMatrix(jo),this.attachEntityInfo(S),S}fillVisited(e,t,s,o,h){if(h==1&&o==1)e[t]=!0;else for(let u=0;u<o;++u)for(let g=0;g<h;++g)e[t+u+g*s]=!0}getTextStyle(e){const t=this.database.tables.textStyleTable;let s;return e.textStyle&&(s=t.getAt(e.textStyle)),s||(s=t.getAt("STANDARD")||t.getAt("Standard")),s.textStyle}getTableTextOffset(e,t,s){const o=new Z;switch(e){case 1:break;case 2:o.setX(t/2);break;case 3:o.setX(t);break;case 4:o.setY(-s/2);break;case 5:o.set(t/2,-s/2,0);break;case 6:o.set(t,-s/2,0);break;case 7:o.setY(-s);break;case 8:o.set(t/2,-s,0);break;case 9:o.set(t,-s,0);break}return o}};Xa.typeName="Table";let ci=Xa;const jo=new fn;var rc=(i=>(i[i.LEFT=0]="LEFT",i[i.CENTER=1]="CENTER",i[i.RIGHT=2]="RIGHT",i[i.ALIGNED=3]="ALIGNED",i[i.MIDDLE=4]="MIDDLE",i[i.FIT=5]="FIT",i))(rc||{}),nc=(i=>(i[i.BASELINE=0]="BASELINE",i[i.BOTTOM=1]="BOTTOM",i[i.MIDDLE=2]="MIDDLE",i[i.TOP=3]="TOP",i))(nc||{});const Ka=class Ka extends Ht{constructor(){super(),this._textString="",this._height=0,this._thickness=1,this._position=new $,this._rotation=0,this._oblique=0,this._horizontalMode=0,this._verticalModel=2,this._styleName="",this._widthFactor=1}get textString(){return this._textString}set textString(e){this._textString=e}get thickness(){return this._thickness}set thickness(e){this._thickness=e}get height(){return this._height}set height(e){this._height=e}get position(){return this._position}set position(e){this._position.copy(e)}get rotation(){return this._rotation}set rotation(e){this._rotation=e}get oblique(){return this._oblique}set oblique(e){this._oblique=e}get horizontalMode(){return this._horizontalMode}set horizontalMode(e){this._horizontalMode=e}get verticalMode(){return this._verticalModel}set verticalMode(e){this._verticalModel=e}get styleName(){return this._styleName}set styleName(e){this._styleName=e}get widthFactor(){return this._widthFactor}set widthFactor(e){this._widthFactor=e}get geometricExtents(){return new Re}getTextStyle(){const e=this.database.tables.textStyleTable;let t=e.getAt(this.styleName);return t||(t=e.getAt("STANDARD")||e.getAt("Standard")),t.textStyle}draw(e,t){const s={text:this.textString,height:this.height,width:1/0,widthFactor:this.widthFactor,position:this.position,rotation:this.rotation,drawingDirection:Oi.BOTTOM_TO_TOP,attachmentPoint:Rn.BottomLeft},o={...this.getTextStyle(),color:this.rgbColor};return e.mtext(s,o,t)}};Ka.typeName="Text";let ui=Ka;const $a=class $a extends Vt{constructor(){super(),this._elevation=0,this._thickness=1,this._vertices=[new $,new $,new $,new $]}get elevation(){return this._elevation}set elevation(e){this._elevation=e}get closed(){return!0}get thickness(){return this._thickness}set thickness(e){this._thickness=e}getPointAt(e){return e<0?this._vertices[0]:e>3?this._vertices[3]:this._vertices[e]}setPointAt(e,t){if(e<0&&this._vertices[0].copy(t),e>3)return this._vertices[3].copy(t);this._vertices[e].copy(t)}get geometricExtents(){return new Re().setFromPoints(this._vertices)}subGetGripPoints(){const e=new Array;for(let t=0;t<4;++t)e.push(this.getPointAt(t));return e}draw(e){const t=new Bs(this._vertices,!0),s=new Ti;return s.add(t),e.area(s,{color:this.rgbColor,solidFill:!0,patternAngle:0,patternLines:[]})}};$a.typeName="Trace";let di=$a;const Za=class Za extends Vt{constructor(){super(),this._elevation=0,this._geo=new Bs}get numberOfVertices(){return this._geo.numberOfVertices}get elevation(){return this._elevation}set elevation(e){this._elevation=e}get closed(){return this._geo.closed}set closed(e){this._geo.closed=e}addVertexAt(e,t,s=0,o=-1,h=-1){const u=o<0?void 0:o,g=h<0?void 0:h,b={x:t.x,y:t.y,bulge:s,startWidth:u,endWidth:g};this._geo.addVertexAt(e,b)}getPoint2dAt(e){return this._geo.getPointAt(e)}getPoint3dAt(e){const t=this.getPoint2dAt(e);return new $(t.x,t.y,this._elevation)}get geometricExtents(){const e=this._geo.box;return new Re({x:e.min.x,y:e.min.y,z:this._elevation},{x:e.max.x,y:e.max.y,z:this._elevation})}subGetGripPoints(){const e=new Array;for(let t=0;t<this.numberOfVertices;++t)e.push(this.getPoint3dAt(t));return e}draw(e){const t=[];return this._geo.getPoints(100).forEach(o=>t.push(new $().set(o.x,o.y,this.elevation))),e.lines(t,this.lineStyle)}};Za.typeName="Polyline";let mi=Za;const Qa=class Qa extends Ht{constructor(){super(),this._geo=new $}get position(){return this._geo}set position(e){this._geo.set(e.x,e.y,e.z||0)}get geometricExtents(){return new Re().expandByPoint(this._geo)}transformBy(e){return this._geo.applyMatrix3d(e),this}draw(e){return e.point(this._geo,{displayMode:this.database.pdmode,displaySize:this.database.pdsize,color:this.rgbColor})}};Qa.typeName="Point";let pi=Qa;var sc=(i=>(i[i.Invalid=0]="Invalid",i[i.Rect=1]="Rect",i[i.Poly=2]="Poly",i))(sc||{}),ic=(i=>(i[i.Show=1]="Show",i[i.ShowUnAligned=2]="ShowUnAligned",i[i.Clip=4]="Clip",i[i.Transparent=8]="Transparent",i))(ic||{});const Ja=class Ja extends Ht{constructor(){super(),this._brightness=50,this._contrast=50,this._fade=0,this._width=0,this._height=0,this._position=new $,this._scale=new $e(1,1),this._rotation=0,this._clipBoundaryType=1,this._clipBoundary=[],this._isClipped=!1,this._isShownClipped=!1,this._isImageShown=!0,this._isImageTransparent=!1,this._imageDefId=""}get brightness(){return this._brightness}set brightness(e){this._brightness=e}get contrast(){return this._contrast}set contrast(e){this._contrast=e}get fade(){return this._fade}set fade(e){this._fade=e}get height(){return this._height}set height(e){this._height=e}get width(){return this._width}set width(e){this._width=e}get position(){return this._position}set position(e){this._position=e}get rotation(){return this._rotation}set rotation(e){this._rotation=e}get scale(){return this._scale}set scale(e){this._scale.copy(e)}get clipBoundaryType(){return this._clipBoundaryType}set clipBoundaryType(e){this._clipBoundaryType=e}get clipBoundary(){return this._clipBoundary}set clipBoundary(e){this._clipBoundary=[],this._clipBoundary.push(...e)}get isClipped(){return this._isClipped}set isClipped(e){this._isClipped=e}get isShownClipped(){return this._isShownClipped}set isShownClipped(e){this._isShownClipped=e}get isImageShown(){return this._isImageShown}set isImageShown(e){this._isImageShown=e}get isImageTransparent(){return this._isImageTransparent}set isImageTransparent(e){this._isImageTransparent=e}get image(){return this._image}set image(e){this._image=e}get imageDefId(){return this._imageDefId}set imageDefId(e){this._imageDefId=e}get imageFileName(){if(this._imageDefId){const e=this.database.dictionaries.imageDefs.getIdAt(this._imageDefId);if(e)return e.sourceFileName}return""}get geometricExtents(){const e=new Re;return e.min.copy(this._position),e.max.set(this._position.x+this._width,this._position.y+this._height,0),e}subGetGripPoints(){return this.boundaryPath()}draw(e){const t=this.boundaryPath();return this._image?e.image(this._image,{boundary:t,roation:this._rotation}):e.lines(t,this.lineStyle)}boundaryPath(){const e=[];if(this.isClipped&&this._clipBoundary.length>3){const t=this._width,s=this._height,o=new _t;o.setFromPoints(this._clipBoundary);const h=new Me;h.setX(this._position.x-o.min.x*t),h.setY(this._position.y-o.min.y*s),this._clipBoundary.forEach(u=>{const g=u.x*t+h.x,b=u.y*s+h.y;e.push(new $(g,b,this._position.z))})}else{if(e.push(this._position),e.push(this._position.clone().setX(this._position.x+this._width)),e.push(this._position.clone().set(this._position.x+this._width,this._position.y+this._height,this._position.z)),e.push(this._position.clone().setY(this._position.y+this._height)),this._rotation>0){Go.copy(e[1]);for(let t=1;t<4;t++)qs.copy(e[t]),qs.rotateAround(Go,this._rotation),e[t].setX(qs.x),e[t].setY(qs.y)}e.push(e[0])}return e}};Ja.typeName="RasterImage";let zs=Ja;const Go=new Me,qs=new Me,eo=class eo extends Vt{constructor(){super(),this._basePoint=new $,this._unitDir=new Z}get basePoint(){return this._basePoint}set basePoint(e){this._basePoint.copy(e)}get unitDir(){return this._unitDir}set unitDir(e){this._unitDir.copy(e)}get closed(){return!1}get geometricExtents(){const e=new Re;return e.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),e.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),e}subGetGripPoints(){const e=new Array;return e.push(this.basePoint),e}draw(e){const t=[];return t.push(this.basePoint),t.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),e.lines(t,this.lineStyle)}};eo.typeName="Ray";let gi=eo;const to=class to extends Ht{constructor(){super(),this._centerPoint=new $,this._height=0,this._width=0,this._viewCenter=new $,this._viewHeight=0,this._number=-1}get number(){return this._number}set number(e){this._number=e}get centerPoint(){return this._centerPoint}set centerPoint(e){this._centerPoint=e}get height(){return this._height}set height(e){this._height=e}get width(){return this._width}set width(e){this._width=e}get viewCenter(){return this._viewCenter}set viewCenter(e){this._viewCenter=e}get viewHeight(){return this._viewHeight}set viewHeight(e){this._viewHeight=e}get geometricExtents(){return new Re}draw(e){if(this._number>1&&this.ownerId!=this.database.tables.blockTable.modelSpace.objectId){const t=this.toGiViewport(),s=e.group(this.createViewportRect(t,e));return this.attachEntityInfo(s),s}}toGiViewport(){const e=new zi;return e.id=this.objectId,e.groupId=this.ownerId,e.number=this.number,e.centerPoint=this.centerPoint,e.width=this.width,e.height=this.height,e.viewHeight=this.viewHeight,e.viewCenter=this.viewCenter,e}createViewportRect(e,t){const s=[];return s.push(t.lines([new $(e.centerPoint.x-e.width/2,e.centerPoint.y-e.height/2,0),new $(e.centerPoint.x+e.width/2,e.centerPoint.y-e.height/2,0)],this.lineStyle)),s.push(t.lines([new $(e.centerPoint.x+e.width/2,e.centerPoint.y-e.height/2,0),new $(e.centerPoint.x+e.width/2,e.centerPoint.y+e.height/2,0)],this.lineStyle)),s.push(t.lines([new $(e.centerPoint.x+e.width/2,e.centerPoint.y+e.height/2,0),new $(e.centerPoint.x-e.width/2,e.centerPoint.y+e.height/2,0)],this.lineStyle)),s.push(t.lines([new $(e.centerPoint.x-e.width/2,e.centerPoint.y+e.height/2,0),new $(e.centerPoint.x-e.width/2,e.centerPoint.y-e.height/2,0)],this.lineStyle)),s}};to.typeName="Viewport";let fi=to;const ro=class ro extends zs{draw(e){const t=this.boundaryPath(),s=new Ti;return s.add(new Bs(t)),e.area(s,{color:0,solidFill:!0,patternAngle:0,patternLines:[]})}};ro.typeName="Wipeout";let _i=ro;const no=class no extends Vt{constructor(){super(),this._basePoint=new $,this._unitDir=new Z}get basePoint(){return this._basePoint}set basePoint(e){this._basePoint.copy(e)}get unitDir(){return this._unitDir}set unitDir(e){this._unitDir.copy(e)}get closed(){return!1}get geometricExtents(){const e=new Re;return e.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),e.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),e}subGetGripPoints(){const e=new Array;return e.push(this.basePoint),e}draw(e){const t=[];return t.push(this._unitDir.clone().multiplyScalar(-1e6).add(this._basePoint)),t.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),e.lines(t,this.lineStyle)}};no.typeName="Xline";let vi=no;var ac=(i=>(i[i.AtLeast=1]="AtLeast",i[i.Exactly=2]="Exactly",i))(ac||{});const so=class so extends Ht{constructor(){super(),this._dimBlockId=null,this._dimensionStyleName=null,this._dimensionText=null,this._textLineSpacingFactor=1,this._textLineSpacingStyle=1,this._textPosition=new $,this._textRotation=0}get dimBlockId(){return this._dimBlockId}set dimBlockId(e){this._dimBlockId=e}get dimensionStyleName(){return this._dimensionStyleName}set dimensionStyleName(e){this._dimensionStyleName=e}get dimensionStyle(){if(this._dimStyle==null){let e;this.dimensionStyleName&&(e=this.database.tables.dimStyleTable.getAt(this.dimensionStyleName)),e==null&&(e=new Bn),this._dimStyle=e}return this._dimStyle}get dimensionText(){return this._dimensionText}set dimensionText(e){this._dimensionText=e}get measurement(){return this._measurement}set measurement(e){this._measurement=e}get textLineSpacingFactor(){return this._textLineSpacingFactor}set textLineSpacingFactor(e){this._textLineSpacingFactor=e}get textLineSpacingStyle(){return this._textLineSpacingStyle}set textLineSpacingStyle(e){this._textLineSpacingStyle=e}get textPosition(){return this._textPosition}set textPosition(e){this._textPosition.copy(e)}get textRotation(){return this._textRotation}set textRotation(e){this._textRotation=e}draw(e){if(this.dimBlockId){const s=this.database.tables.blockTable.getAt(this.dimBlockId);if(s){const o=Gr.instance.draw(e,s,this.rgbColor,!1);return this.attachEntityInfo(o),o}}const t=e.group([]);return this.attachEntityInfo(t),t}drawFirstArrow(e){const t=this.database.tables.blockTable.getAt(this.firstArrowType);if(t)return Gr.instance.draw(e,t,this.rgbColor,!1)}drawSecondArrow(e){const t=this.database.tables.blockTable.getAt(this.secondArrowType);if(t)return Gr.instance.draw(e,t,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 e=this.dimensionStyle;return e.dimsah==0?e.dimblk:e.dimblk1}get firstArrowType(){const e=this.firstArrowTypeBtrId;return this.getArrowName(e)}get secondArrowTypeBtrId(){const e=this.dimensionStyle;return e.dimsah==0?e.dimblk:e.dimblk2}get secondArrowType(){const e=this.secondArrowTypeBtrId;return this.getArrowName(e)}get arrowLineCount(){return 1}getLineArrowStyle(e){}findPointOnLine1(e,t,s){const o=new $().subVectors(t,e).normalize();return new $(t).addScaledVector(o,s)}findPointOnLine2(e,t,s){const o=e.x+s*Math.cos(t),h=e.y+s*Math.sin(t);return{x:o,y:h}}adjustExtensionLine(e){const t=this.dimensionStyle;e.extend(t.dimexe),e.extend(-t.dimexo,!0)}getArrowName(e){const t=this.database.tables.blockTable.getIdAt(e);return t?t.name.toUpperCase():Ta.Closed}};so.typeName="Dimension";let Mr=so;const io=class io extends Mr{constructor(e,t,s,o,h=null,u=null){super(),this._centerPoint=new $().copy(e),this._xLine1Point=new $().copy(t),this._xLine2Point=new $().copy(s),this._arcPoint=new $().copy(o),this.dimensionText=h,this.dimensionStyleName=u}get arcPoint(){return this._arcPoint}set arcPoint(e){this._arcPoint.copy(e)}get centerPoint(){return this._centerPoint}set centerPoint(e){this._centerPoint.copy(e)}get xLine1Point(){return this._xLine1Point}set xLine1Point(e){this._xLine1Point.copy(e)}get xLine2Point(){return this._xLine2Point}set xLine2Point(e){this._xLine2Point.copy(e)}get geometricExtents(){return new Re}};io.typeName="3PointAngularDimension";let yi=io;const ao=class ao extends Mr{constructor(e,t,s,o=null,h=null){super(),this._dimLinePoint=new $().copy(s),this._xLine1Point=new $().copy(e),this._xLine2Point=new $().copy(t),this._oblique=0,this._rotation=0,this.dimensionText=o,this.dimensionStyleName=h}get dimLinePoint(){return this._dimLinePoint}set dimLinePoint(e){this._dimLinePoint.copy(e)}get xLine1Point(){return this._xLine1Point}set xLine1Point(e){this._xLine1Point.copy(e)}get xLine2Point(){return this._xLine2Point}set xLine2Point(e){this._xLine2Point.copy(e)}get rotation(){return this._rotation}set rotation(e){this._rotation=e}get oblique(){return this._oblique}set oblique(e){this._oblique=e}get geometricExtents(){return new Re}get isAppendArrow(){return!1}calculateLines(){const e=[],t=this.createExtensionLine(this._xLine1Point),s=this.createExtensionLine(this._xLine2Point),o=this.findIntersectionPoint(t,this._dimLinePoint),h=this.findIntersectionPoint(s,this._dimLinePoint),u=new qr(o,h);return e.push(u),t.endPoint=o,this.adjustExtensionLine(t),e.push(t),s.endPoint=h,this.adjustExtensionLine(s),e.push(s),e}createExtensionLine(e){const t=this.rotation+Math.PI/2,s=this.findPointOnLine2(e,t,100);return new qr(e,{...s,z:e.z})}findIntersectionPoint(e,t){const s=e.startPoint,o=e.endPoint,h=new Z().subVectors(o,s).normalize(),g=new Z().subVectors(t,s).dot(h),b=new Z().copy(h).multiplyScalar(g);return new Z().addVectors(s,b)}};ao.typeName="AlignedDimension";let bi=ao;const oo=class oo extends Mr{constructor(e,t,s,o,h=null,u=null){super(),this._arcPoint=new $().copy(o),this._xLine1Point=new $().copy(t),this._xLine2Point=new $().copy(s),this._centerPoint=new $().copy(e),this.dimensionText=h,this.dimensionStyleName=u}get arcPoint(){return this._arcPoint}set arcPoint(e){this._arcPoint.copy(e)}get centerPoint(){return this._centerPoint}set centerPoint(e){this._centerPoint.copy(e)}get xLine1Point(){return this._xLine1Point}set xLine1Point(e){this._xLine1Point.copy(e)}get xLine2Point(){return this._xLine2Point}set xLine2Point(e){this._xLine2Point.copy(e)}get geometricExtents(){return new Re}};oo.typeName="ArcDimension";let da=oo;const lo=class lo extends Mr{constructor(e,t,s=0,o=null,h=null){super(),this._chordPoint=new $().copy(e),this._farChordPoint=new $().copy(t),this._extArcStartAngle=0,this._extArcEndAngle=0,this._leaderLength=s,this.dimensionText=o,this.dimensionStyleName=h}get chordPoint(){return this._chordPoint}set chordPoint(e){this._chordPoint.copy(e)}get farChordPoint(){return this._farChordPoint}set farChordPoint(e){this._farChordPoint.copy(e)}get extArcStartAngle(){return this._extArcStartAngle}set extArcStartAngle(e){this._extArcStartAngle=e}get extArcEndAngle(){return this._extArcEndAngle}set extArcEndAngle(e){this._extArcEndAngle=e}get leaderLength(){return this._leaderLength}get geometricExtents(){return new Re}drawLines(e,t){const s=[],o=t.length;return o==1?s.push(this.drawLine(e,t[0],{firstArrow:this.firstArrowStyle})):o==3?(this.sortLines(t),s.push(this.drawLine(e,t[0],{firstArrow:this.firstArrowStyle})),s.push(this.drawLine(e,t[1])),s.push(this.drawLine(e,t[2],{firstArrow:this.firstArrowStyle}))):t.forEach(h=>{s.push(this.drawLine(e,h))}),s}drawLine(e,t,s){if(s){const o=[t.startPoint,t.endPoint];return e.lines(o,{...this.lineStyle,arrows:s})}else return t.draw(e)}sortLines(e){const t=(s,o)=>s.x!==o.x?s.x-o.x:s.y!==o.y?s.y-o.y:s.z-o.z;e.sort((s,o)=>{const h=t(s.startPoint,o.startPoint);return h!==0?h:t(s.endPoint,o.endPoint)})}};lo.typeName="DiametricDimension";let xi=lo;const ho=class ho extends Mr{constructor(e,t,s=null,o=null){super(),this._definingPoint=new $().copy(e),this._leaderEndPoint=new $().copy(t),this.dimensionText=s,this.dimensionStyleName=o}get definingPoint(){return this._definingPoint}set definingPoint(e){this._definingPoint.copy(e)}get leaderEndPoint(){return this._leaderEndPoint}set leaderEndPoint(e){this._leaderEndPoint.copy(e)}get geometricExtents(){return new Re}get arrowLineCount(){return 0}};ho.typeName="OrdinateDimension";let wi=ho;const co=class co extends Mr{constructor(e,t,s,o=null,h=null){super(),this._center=new $().copy(e),this._chordPoint=new $().copy(t),this._leaderLength=s,this._extArcStartAngle=0,this._extArcEndAngle=0,this.dimensionText=o,this.dimensionStyleName=h}get center(){return this._center}set center(e){this._center.copy(e)}get chordPoint(){return this._chordPoint}set chordPoint(e){this._chordPoint.copy(e)}get extArcStartAngle(){return this._extArcStartAngle}set extArcStartAngle(e){this._extArcStartAngle=e}get extArcEndAngle(){return this._extArcEndAngle}set extArcEndAngle(e){this._extArcEndAngle=e}get leaderLength(){return this._leaderLength}set leaderLenght(e){this._leaderLength=e}get geometricExtents(){return new Re}getLineArrowStyle(e){return{secondArrow:this.secondArrowStyle}}};co.typeName="RadialDimension";let Ai=co;class Wo{convert(e){const t=this.createEntity(e);return t&&this.processCommonAttrs(e,t),t}createEntity(e){return e.type=="ARC"?this.convertArc(e):e.type=="CIRCLE"?this.convertCirle(e):e.type=="DIMENSION"?this.convertDimension(e):e.type=="ELLIPSE"?this.convertEllipse(e):e.type=="HATCH"?this.convertHatch(e):e.type=="IMAGE"?this.convertImage(e):e.type=="LEADER"?this.convertLeader(e):e.type=="LINE"?this.convertLine(e):e.type=="MTEXT"?this.convertMText(e):e.type=="POLYLINE"||e.type=="LWPOLYLINE"?this.convertPolyline(e):e.type=="POINT"?this.convertPoint(e):e.type=="RAY"?this.convertRay(e):e.type=="SPLINE"?this.convertSpline(e):e.type=="ACAD_TABLE"?this.convertTable(e):e.type=="TEXT"?this.convertText(e):e.type=="SOLID"?this.convertSolid(e):e.type=="VIEWPORT"?this.convertViewport(e):e.type=="WIPEOUT"?this.convertWipeout(e):e.type=="XLINE"?this.convertXline(e):e.type=="INSERT"?this.convertBlockReference(e):null}convertArc(e){return new si(e.center,e.radius,Ee.degToRad(e.startAngle),Ee.degToRad(e.endAngle))}convertCirle(e){return new ii(e.center,e.radius)}convertEllipse(e){const t=new Z(e.majorAxisEndPoint),s=t.length();return new ni(e.center,e.extrusionDirection??Z.Z_AXIS,t,s,s*e.axisRatio,e.startAngle,e.endAngle)}convertLine(e){const t=e.startPoint,s=e.endPoint;return new li(new $(t.x,t.y,t.z||0),new $(s.x,s.y,s.z||0))}convertSpline(e){if(e.numberOfControlPoints>0&&e.numberOfKnots>0)return new Os(e.controlPoints,e.knots,e.weights,e.degree,!!(e.flag&1));if(e.numberOfFitPoints>0){const t=this.numberArrayToPointArray(e.fitPoints,e.numberOfFitPoints);if(t!=null)return new Os(t,"Uniform",e.degree,!!(e.flag&1))}return null}convertPoint(e){const t=new pi;return t.position=e.position,t}convertSolid(e){const t=new di;return e.points.forEach((s,o)=>t.setPointAt(o,s)),t.thickness=e.thickness,t}convertPolyline(e){const t=new mi;return t.closed=!!(e.flag&1),e.vertices.forEach((s,o)=>{t.addVertexAt(o,new Me(s.x,s.y),s.bulge,s.startWidth,s.endWidth)}),t}convertHatch(e){var o;const t=new ai;return(o=e.definitionLines)==null||o.forEach(h=>{t.definitionLines.push({angle:h.angle,origin:h.base,delta:h.offset,dashPattern:h.numberOfDashLengths>0?h.dashLengths:[]})}),t.hatchStyle=e.hatchStyle,t.patternName=e.patternName,t.patternType=e.patternType,t.patternAngle=e.patternAngle==null?0:e.patternAngle,t.patternScale=e.patternScale==null?0:e.patternScale,e.boundaryPaths.forEach(h=>{if(h.boundaryPathTypeFlag&2){const g=h,b=new Bs;b.closed=g.isClosed,g.vertices.forEach((f,S)=>{b.addVertexAt(S,{x:f.x,y:f.y,bulge:f.bulge})}),t.add(b)}else{const g=h,b=new Kh;g.edges.forEach(f=>{if(f.type==1){const S=f;b.add(new Li(S.start,S.end))}else if(f.type==2){const S=f;b.add(new Dn(S.center,S.radius,Ee.degToRad(S.startAngle||0),Ee.degToRad(S.endAngle||0),!S.isCCW))}else if(f.type==3){const S=f;new $e().subVectors(S.end,S.center);const E=Math.sqrt(Math.pow(S.end.x,2)+Math.pow(S.end.y,2)),M=E*S.lengthOfMinorAxis;let z=Ee.degToRad(S.startAngle||0),D=Ee.degToRad(S.endAngle||0);const U=Math.atan2(S.end.y,S.end.x);S.isCCW||(z=Math.PI*2-z,D=Math.PI*2-D),b.add(new Ni({...S.center,z:0},E,M,z,D,!S.isCCW,U))}else if(f.type==4){const S=f;if(S.numberOfControlPoints>0&&S.numberOfKnots>0){const x=S.controlPoints.map(z=>({x:z.x,y:z.y,z:0}));let E=!0;const M=S.controlPoints.map(z=>(z.weight==null&&(E=!1),z.weight||1));b.add(new Yr(x,S.knots,E?M:void 0))}else if(S.numberOfFitData>0){const x=S.fitDatum.map(E=>({x:E.x,y:E.y,z:0}));b.add(new Yr(x,"Uniform"))}}}),t.add(b)}}),t}convertTable(e){const t=new ci(e.name,e.rowCount,e.columnCount);return t.attachmentPoint=e.attachmentPoint,t.position.copy(e.startPoint),e.columnWidthArr.forEach((s,o)=>t.setColumnWidth(o,s)),e.rowHeightArr.forEach((s,o)=>t.setRowHeight(o,s)),e.cells.forEach((s,o)=>{t.setCell(o,s)}),t}convertText(e){const t=new ui;return t.textString=e.text,t.styleName=e.styleName,t.height=e.textHeight,t.position.copy(e.startPoint),t.rotation=Ee.degToRad(e.rotation||0),t.oblique=e.obliqueAngle??0,t.thickness=e.thickness,t.horizontalMode=e.halign,t.verticalMode=e.valign,t.widthFactor=e.xScale??1,t}convertMText(e){const t=new hi;return t.contents=e.text,e.styleName!=null&&(t.styleName=e.styleName),t.height=e.height,t.width=e.width,t.rotation=Ee.degToRad(e.rotation||0),t.location=e.insertionPoint,t.attachmentPoint=e.attachmentPoint,e.direction&&(t.direction=new Z(e.direction)),t.drawingDirection=e.drawingDirection,t}convertLeader(e){const t=new oi;return e.vertices.forEach(s=>{t.appendVertex(s)}),t.hasArrowHead=e.isArrowheadEnabled,t.hasHookLine=e.isHooklineExists,t.isSplined=e.isSpline,t.dimensionStyle=e.styleName,t.annoType=e.leaderCreationFlag,t}convertDimension(e){if(e.subclassMarker=="AcDbAlignedDimension"||e.subclassMarker=="AcDbRotatedDimension"){const t=e,s=new bi(t.subDefinitionPoint1,t.subDefinitionPoint2,t.definitionPoint);return s.rotation=Ee.degToRad(t.rotationAngle||0),this.processDimensionCommonAttrs(e,s),s}else if(e.subclassMarker=="AcDb3PointAngularDimension"){const t=e,s=new yi(t.centerPoint,t.subDefinitionPoint1,t.subDefinitionPoint2,t.definitionPoint);return this.processDimensionCommonAttrs(e,s),s}else if(e.subclassMarker=="AcDbOrdinateDimension"){const t=e,s=new wi(t.subDefinitionPoint1,t.subDefinitionPoint2);return this.processDimensionCommonAttrs(e,s),s}else if(e.subclassMarker=="AcDbRadialDimension"){const t=e,s=new Ai(t.definitionPoint,t.centerPoint,t.leaderLength);return this.processDimensionCommonAttrs(e,s),s}else if(e.subclassMarker=="AcDbDiametricDimension"){const t=e,s=new xi(t.definitionPoint,t.centerPoint,t.leaderLength);return this.processDimensionCommonAttrs(e,s),s}return null}processImage(e,t){t.position.copy(e.position),t.brightness=e.brightness,t.contrast=e.contrast,t.fade=e.fade,t.isShownClipped=(e.flags|4)>0,t.isImageShown=(e.flags|3)>0,t.isImageTransparent=(e.flags|8)>0,t.imageDefId=e.imageDefHandle,t.isClipped=e.isClipped,e.clippingBoundaryPath.forEach(s=>{t.clipBoundary.push(new Me(s))}),t.width=Math.sqrt(e.uPixel.x**2+e.uPixel.y**2+e.uPixel.z**2)*e.imageSize.x,t.height=Math.sqrt(e.vPixel.x**2+e.vPixel.y**2+e.vPixel.z**2)*e.imageSize.y,t.rotation=Math.atan2(e.uPixel.y,e.uPixel.x)}convertImage(e){const t=new zs;return this.processImage(e,t),t.clipBoundaryType=e.clippingBoundaryType,t}processWipeout(e,t){t.position.copy(e.position),t.brightness=e.brightness,t.contrast=e.contrast,t.fade=e.fade,t.isShownClipped=(e.displayFlag|4)>0,t.isImageShown=(e.displayFlag|3)>0,t.isImageTransparent=(e.displayFlag|8)>0,t.imageDefId=e.imageDefHardId,t.isClipped=e.isClipping,e.boundary.forEach(s=>{t.clipBoundary.push(new Me(s))}),t.clipBoundaryType=e.boundaryType,t.width=Math.sqrt(e.uDirection.x**2+e.uDirection.y**2+e.uDirection.z**2)*e.imageSize.x,t.height=Math.sqrt(e.vDirection.x**2+e.vDirection.y**2+e.vDirection.z**2)*e.imageSize.y,t.rotation=Math.atan2(e.uDirection.y,e.uDirection.x)}convertWipeout(e){const t=new _i;return this.processWipeout(e,t),t}convertViewport(e){const t=new fi;return t.number=e.viewportId,t.centerPoint.copy(e.viewportCenter),t.height=e.height,t.width=e.width,t.viewCenter.copy(e.displayCenter),t.viewHeight=e.viewHeight,t}convertRay(e){const t=new gi;return t.basePoint.copy(e.position),t.unitDir.copy(e.direction),t}convertXline(e){const t=new vi;return t.basePoint.copy(e.position),t.unitDir.copy(e.direction),t}convertBlockReference(e){const t=new Ls(e.name);return e.insertionPoint&&t.position.copy(e.insertionPoint),t.scaleFactors.x=e.xScale||1,t.scaleFactors.y=e.yScale||1,t.scaleFactors.z=e.zScale||1,t.rotation=e.rotation!=null?Ee.degToRad(e.rotation):0,t.normal.copy(e.extrusionDirection??{x:0,y:0,z:1}),t}processDimensionCommonAttrs(e,t){t.dimBlockId=e.name,t.textPosition.copy(e.textPoint),t.textRotation=e.textRotation||0,e.textLineSpacingFactor&&(t.textLineSpacingFactor=e.textLineSpacingFactor),e.textLineSpacingStyle&&(t.textLineSpacingStyle=e.textLineSpacingStyle),t.dimensionStyleName=e.styleName,t.dimensionText=e.text||"",t.measurement=e.measurement}processCommonAttrs(e,t){t.layer=e.layer,t.objectId=e.handle,t.ownerId=e.ownerBlockRecordSoftId||"",e.lineType!=null&&(t.lineType=e.lineType),e.lineweight!=null&&(t.lineWeight=e.lineweight),e.lineTypeScale!=null&&(t.linetypeScale=e.lineTypeScale),e.color!=null&&(t.color.color=e.color),e.colorIndex!=null&&(t.color.colorIndex=e.colorIndex),e.colorName!=null&&(t.color.colorName=e.colorName),e.isVisible!=null&&(t.visibility=e.isVisible),e.transparency!=null&&(t.transparency=e.transparency)}numberArrayToPointArray(e,t){const s=e.length;let o=0;if(s/2==t?o=2:s/3==t&&(o=3),o==0)return;const h=[];for(let u=0,g=s/o;u<g;++u)h.push({x:e[u*o],y:e[u*o+1],z:o==3?e[u*o+2]:0});return h}}class Di extends Xr{constructor(){super(),this._tabOrder=-1,this._tabSelected=!1,this._blockTableRecordId="",this._layoutName="",this._limits=new _t,this._extents=new Re}get layoutName(){return this._layoutName}set layoutName(e){this._layoutName=e.length>256?e.slice(0,256):e}get tabOrder(){return this._tabOrder}set tabOrder(e){this._tabOrder=e}get tabSelected(){return this._tabSelected}set tabSelected(e){this._tabSelected=e}get blockTableRecordId(){return this._blockTableRecordId}set blockTableRecordId(e){this._blockTableRecordId=e}get limits(){return this._limits}set limits(e){this._limits.copy(e)}get extents(){return this._extents}set extents(e){this._extents.copy(e)}}class Oa extends Xr{constructor(e){super(),this.database=e,this._recordsByName=new Map,this._recordsById=new Map}get numEntries(){return this._recordsByName.size}setAt(e,t){t.database=this.database,this._recordsByName.set(e,t),this._recordsById.set(t.objectId,t),this.database.events.dictObjetSet.dispatch({database:this.database,object:t,key:e})}remove(e){const t=this.getAt(e);return t?(this._recordsByName.delete(e.toUpperCase()),this._recordsById.delete(this.objectId),this.database.events.dictObjectErased.dispatch({database:this.database,object:t,key:e}),!0):!1}removeId(e){const t=this.getIdAt(e);return t?(this._recordsById.delete(this.objectId),this._recordsByName.forEach((s,o)=>{s===t&&(this._recordsByName.delete(o),this.database.events.dictObjectErased.dispatch({database:this.database,object:t,key:o}))}),!0):!1}removeAll(){this._recordsByName.forEach((e,t)=>{this.database.events.dictObjectErased.dispatch({database:this.database,object:e,key:t})}),this._recordsByName.clear(),this._recordsById.clear()}has(e){return this._recordsByName.has(e.toUpperCase())}hasId(e){return this._recordsById.has(e)}getAt(e){return this._recordsByName.get(e)}getIdAt(e){return this._recordsById.get(e)}newIterator(){return new ki(this._recordsByName)}}class oc extends Oa{getBtrIdAt(e){for(const[t,s]of this._recordsByName)if(s.blockTableRecordId==e)return s}get maxTabOrder(){let e=-1;return this._recordsByName.forEach(t=>{t.tabOrder>e&&(e=t.tabOrder)}),e}}class lc extends Xr{constructor(){super(),this._sourceFileName=""}get sourceFileName(){return this._sourceFileName}set sourceFileName(e){this._sourceFileName=e}}class Xd{convertLayout(e,t){var o;const s=new Di;return s.layoutName=e.layoutName,s.tabOrder=e.tabOrder,(o=t.tables.BLOCK_RECORD)==null||o.entries.some(h=>h.layoutObjects===e.handle?(s.blockTableRecordId=h.handle,!0):!1),s.limits.min.copy(e.minLimit),s.limits.max.copy(e.maxLimit),s.extents.min.copy(e.minExtent),s.extents.max.copy(e.maxExtent),this.processCommonAttrs(e,s),s}convertImageDef(e){const t=new lc;return t.sourceFileName=e.fileName,this.processCommonAttrs(e,t),t}processCommonAttrs(e,t){t.objectId=e.handle,t.ownerId=e.ownerObjectId}}class hc{constructor(e){this.taskId=0,this.workers=new Map,this.pendingTasks=new Map,this.config={workerUrl:e.workerUrl,timeout:e.timeout??3e4,maxConcurrentWorkers:e.maxConcurrentWorkers??4}}async execute(e,t){const s=Date.now(),o=this.generateTaskId();try{return await this.executeInWorker(o,e,t||this.config.workerUrl)}catch(h){const u=Date.now()-s;return{success:!1,error:h instanceof Error?h.message:String(h),duration:u}}}async executeInWorker(e,t,s){const o=Date.now();return new Promise((h,u)=>{const g=this.getAvailableWorker(s),b=setTimeout(()=>{this.cleanupTask(e),this.releaseWorker(g),u(new Error(`Worker operation timed out after ${this.config.timeout}ms`))},this.config.timeout);this.pendingTasks.set(e,{resolve:x=>{clearTimeout(b),this.releaseWorker(g),h(x)},reject:x=>{clearTimeout(b),this.releaseWorker(g),u(x)},timeout:b});const f=x=>{const{id:E,success:M,data:z,error:D}=x.data;if(E!==e)return;this.cleanupTask(e);const U=Date.now()-o;h(M?{success:!0,data:z,duration:U}:{success:!1,error:D,duration:U})},S=x=>{this.cleanupTask(e),u(new Error(`Worker error: ${x.message}`))};g.addEventListener("message",f),g.addEventListener("error",S),g.postMessage({id:e,input:t})})}cleanupTask(e){const t=this.pendingTasks.get(e);t&&(clearTimeout(t.timeout),this.pendingTasks.delete(e))}generateTaskId(){return`task_${++this.taskId}_${Date.now()}`}detectWorkerSupport(){return typeof Worker<"u"}getAvailableWorker(e){for(const[s,o]of this.workers)if(!o.isBusy)return o.isBusy=!0,o.worker;if(this.workers.size<this.config.maxConcurrentWorkers){const s=new Worker(e,{type:"module"}),o=this.generateWorkerId(),h={worker:s,isBusy:!0,id:o,createdAt:new Date};return this.workers.set(o,h),s}const t=Array.from(this.workers.values()).sort((s,o)=>s.createdAt.getTime()-o.createdAt.getTime())[0];return t.isBusy=!0,t.worker}releaseWorker(e){for(const[t,s]of this.workers)if(s.worker===e){s.isBusy=!1;break}}generateWorkerId(){return`worker_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}getStats(){return{totalWorkers:this.workers.size,busyWorkers:Array.from(this.workers.values()).filter(e=>e.isBusy).length,pendingTasks:this.pendingTasks.size,config:this.config}}destroy(){for(const[e,t]of this.pendingTasks)clearTimeout(t.timeout),t.reject(new Error("Framework destroyed"));this.pendingTasks.clear();for(const[e,t]of this.workers)t.worker.terminate();this.workers.clear()}}class cc{constructor(e){this.framework=new hc(e)}async execute(e,t){return this.framework.execute(e,t)}getStats(){return this.framework.getStats()}destroy(){this.framework.destroy()}}function uc(i){return new cc(i)}class Kd{constructor(){this.setupMessageHandler()}setupMessageHandler(){self.onmessage=async e=>{const{id:t,input:s}=e.data;try{const o=await this.executeTask(s);this.sendResponse(t,!0,o)}catch(o){this.sendResponse(t,!1,void 0,o instanceof Error?o.message:String(o))}}}sendResponse(e,t,s,o){const h={id:e,success:t,data:s,error:o};self.postMessage(h)}}class dc extends fh{constructor(e={}){super(e),e.parserWorkerUrl||(e.parserWorkerUrl="/assets/dxf-parser-worker.js")}async parse(e){if(this.config.useWorker&&this.config.parserWorkerUrl){const t=uc({workerUrl:this.config.parserWorkerUrl,maxConcurrentWorkers:1}),s=await t.execute(e);return t.destroy(),{model:s.data,data:{unknownEntityCount:0}}}else return{model:new Od().parseSync(e),data:{unknownEntityCount:0}}}getFonts(e){var h;const t=new Map,s=u=>{if(u){const g=u.lastIndexOf(".");return g>=0?u.substring(0,g).toLowerCase():u.toLowerCase()}};(h=e.tables.STYLE)==null||h.entries.forEach(u=>{const g=[];let b=s(u.font);b&&g.push(b),b=s(u.bigFont),b&&g.push(b),t.set(u.name,g)});const o=new Set;return this.getFontsInBlock(e.entities,e.blocks,t,o),Array.from(o)}getFontsInBlock(e,t,s,o){const h=/\\f(.*?)\|/g;e.forEach(u=>{if(u.type=="MTEXT"){const g=u;[...g.text.matchAll(h)].forEach(S=>{o.add(S[1].toLowerCase())});const f=s.get(g.styleName);f==null||f.forEach(S=>o.add(S))}else if(u.type=="TEXT"){const g=u,b=s.get(g.styleName);b==null||b.forEach(f=>o.add(f))}else if(u.type=="INSERT"){const b=t[u.name];b&&b.entities&&this.getFontsInBlock(b.entities,t,s,o)}})}async processEntities(e,t,s,o,h){const u=new Wo;let g=e.entities;const b=g.length,f=new nl(b,100-o.value,s);this.config.convertByEntityType&&(g=this.groupAndFlattenByType(g));const S=t.tables.blockTable.modelSpace;await f.processChunk(async(x,E)=>{let M=[],z=x<E?g[x].type:"";for(let D=x;D<E;D++){const U=g[D],B=u.convert(U);B&&(this.config.convertByEntityType&&U.type!==z&&(S.appendEntity(M),M=[],z=U.type),M.push(B))}if(S.appendEntity(M),h){let D=o.value+E/b*(100-o.value);D>100&&(D=100),await h(D,"ENTITY","IN-PROGRESS")}})}async processEntitiesInBlock(e,t){const s=new Wo,o=e.length,h=[];for(let u=0;u<o;u++){const g=e[u],b=s.convert(g);b&&h.push(b)}t.appendEntity(h)}processBlocks(e,t){const s=e.blocks;for(const[o,h]of Object.entries(s)){let u=t.tables.blockTable.getAt(h.name);u||(u=new Ft,u.objectId=h.handle,u.name=o,u.origin.copy(h.position),t.tables.blockTable.add(u)),h.entities&&this.processEntitiesInBlock(h.entities,u)}}processHeader(e,t){const s=e.header;t.cecolor.colorIndex=s.$CECOLOR||256,t.angBase=s.$ANGBASE||0,t.angDir=s.$ANGDIR||0,s.$AUNITS!=null&&(t.aunits=s.$AUNITS),s.$EXTMAX&&(t.extmax=s.$EXTMAX),s.$EXTMIN&&(t.extmin=s.$EXTMIN),s.$INSUNITS!=null&&(t.insunits=s.$INSUNITS),t.pdmode=s.$PDMODE||0,t.pdsize=s.$PDSIZE||0}processBlockTables(e,t){var o;const s=(o=e.tables.BLOCK_RECORD)==null?void 0:o.entries;s&&s.length>0&&(t.tables.blockTable.removeAll(),s.forEach(h=>{const u=new Ft;u.objectId=h.handle,u.name=h.name,u.layoutId=h.layoutObjects,t.tables.blockTable.add(u)}))}processObjects(e,t){const s=e.objects.byName,o=new Xd;if("LAYOUT"in s){const h=t.dictionaries.layouts;s.LAYOUT.forEach(u=>{const g=o.convertLayout(u,e);h.setAt(g.layoutName,g)})}if("IMAGEDEF"in s){const h=t.dictionaries.imageDefs;s.IMAGEDEF.forEach(u=>{const g=o.convertImageDef(u);h.setAt(g.objectId,g)})}}processViewports(e,t){var o,h;const s=(h=(o=e.tables)==null?void 0:o.VPORT)==null?void 0:h.entries;s&&s.length>0&&s.forEach(u=>{const g=new Sc;this.processCommonTableEntryAttrs(u,g),u.circleSides&&(g.circleSides=u.circleSides),g.standardFlag=u.standardFlag,g.center.copy(u.center),g.lowerLeftCorner.copy(u.lowerLeftCorner),g.upperRightCorner.copy(u.upperRightCorner),u.snapBasePoint&&g.snapBase.copy(u.snapBasePoint),u.snapRotationAngle&&(g.snapAngle=u.snapRotationAngle),u.snapSpacing&&g.snapIncrements.copy(u.snapSpacing),u.majorGridLines&&(g.gridMajor=u.majorGridLines),u.gridSpacing&&g.gridIncrements.copy(u.gridSpacing),u.backgroundObjectId&&(g.backgroundObjectId=u.backgroundObjectId),g.gsView.center.copy(u.center),g.gsView.viewDirectionFromTarget.copy(u.viewDirectionFromTarget),g.gsView.viewTarget.copy(u.viewTarget),u.lensLength&&(g.gsView.lensLength=u.lensLength),u.frontClippingPlane&&(g.gsView.frontClippingPlane=u.frontClippingPlane),u.backClippingPlane&&(g.gsView.backClippingPlane=u.backClippingPlane),u.viewHeight&&(g.gsView.viewHeight=u.viewHeight),u.viewTwistAngle&&(g.gsView.viewTwistAngle=u.viewTwistAngle),u.frozenLayers&&(g.gsView.frozenLayers=u.frozenLayers),u.styleSheet&&(g.gsView.styleSheet=u.styleSheet),u.renderMode&&(g.gsView.renderMode=u.renderMode),u.viewMode&&(g.gsView.viewMode=u.viewMode),u.ucsIconSetting&&(g.gsView.ucsIconSetting=u.ucsIconSetting),u.ucsOrigin&&g.gsView.ucsOrigin.copy(u.ucsOrigin),u.ucsXAxis&&g.gsView.ucsXAxis.copy(u.ucsXAxis),u.ucsYAxis&&g.gsView.ucsYAxis.copy(u.ucsYAxis),u.orthographicType&&(g.gsView.orthographicType=u.orthographicType),u.shadePlotSetting&&(g.gsView.shadePlotSetting=u.shadePlotSetting),u.shadePlotObjectId&&(g.gsView.shadePlotObjectId=u.shadePlotObjectId),u.visualStyleObjectId&&(g.gsView.visualStyleObjectId=u.visualStyleObjectId),u.isDefaultLightingOn&&(g.gsView.isDefaultLightingOn=u.isDefaultLightingOn),u.defaultLightingType&&(g.gsView.defaultLightingType=u.defaultLightingType),u.brightness&&(g.gsView.brightness=u.brightness),u.contrast&&(g.gsView.contrast=u.contrast),u.ambientColor&&(g.gsView.ambientColor=u.ambientColor),t.tables.viewportTable.add(g)})}processLayers(e,t){var o,h;const s=(h=(o=e.tables)==null?void 0:o.LAYER)==null?void 0:h.entries;s&&s.length>0&&s.forEach(u=>{const g=new Wr;g.colorIndex=u.colorIndex;const b=new Ri({name:u.name,standardFlags:u.standardFlag,linetype:u.lineType,lineWeight:u.lineweight,isOff:u.colorIndex<0,color:g,isPlottable:u.isPlotting});this.processCommonTableEntryAttrs(u,b),t.tables.layerTable.add(b)})}processLineTypes(e,t){var o,h;const s=(h=(o=e.tables)==null?void 0:o.LTYPE)==null?void 0:h.entries;s&&s.length>0&&s.forEach(u=>{const g=new Cs(u);this.processCommonTableEntryAttrs(u,g),g.name=u.name,t.tables.linetypeTable.add(g)})}processTextStyles(e,t){var o;const s=(o=e.tables.STYLE)==null?void 0:o.entries;s&&s.length>0&&s.forEach(h=>{const u=new za(h);this.processCommonTableEntryAttrs(h,u),t.tables.textStyleTable.add(u)})}processDimStyles(e,t){var o;const s=(o=e.tables.DIMSTYLE)==null?void 0:o.entries;s&&s.length>0&&s.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},g=new Bn(u);this.processCommonTableEntryAttrs(h,g),t.tables.dimStyleTable.add(g)})}processCommonTableEntryAttrs(e,t){t.name=e.name,t.objectId=e.handle,t.ownerId=e.ownerObjectId}groupAndFlattenByType(e){const t={},s=[];for(const o of e)t[o.type]||(t[o.type]=[],s.push(o.type)),t[o.type].push(o);return s.flatMap(o=>t[o])}}var Ns=(i=>(i.DXF="dxf",i.DWG="dwg",i))(Ns||{});class lr{constructor(){this.events={registered:new it,unregistered:new it},this._converters=new Map,this.register("dxf",new dc)}static createInstance(){return lr._instance==null&&(lr._instance=new lr),this._instance}static get instance(){return lr._instance||(lr._instance=new lr),lr._instance}get fileTypes(){return this._converters.keys()}register(e,t){this._converters.set(e,t),this.events.registered.dispatch({fileType:e,converter:t})}get(e){return this._converters.get(e)}unregister(e){const t=this._converters.get(e);t&&(this._converters.delete(e),this.events.unregistered.dispatch({fileType:e,converter:t}))}}class _n extends Xr{constructor(e,t){e=e||{},Fn(e,{name:""}),super(e,t)}get name(){return this.getAttr("name")}set name(e){this.setAttr("name",e)}}const jr=class jr extends _n{static isModelSapceName(e){return e.toLowerCase()==jr.MODEL_SPACE_NAME.toLowerCase()}static isPaperSapceName(e){return e.toLowerCase().startsWith(jr.PAPER_SPACE_NAME_PREFIX.toLowerCase())}constructor(){super(),this._origin=new $,this._layoutId="",this._entities=new Map}get isModelSapce(){return jr.isModelSapceName(this.name)}get isPaperSapce(){return jr.isPaperSapceName(this.name)}get origin(){return this._origin}set origin(e){this._origin.copy(e)}get layoutId(){return this._layoutId}set layoutId(e){this._layoutId=e}appendEntity(e){if(Array.isArray(e))for(let t=0;t<e.length;++t){const s=e[t];s.database=this.database,s.ownerId=this.objectId,this._entities.set(s.objectId,s)}else e.database=this.database,e.ownerId=this.objectId,this._entities.set(e.objectId,e);(this.isModelSapce||this.isPaperSapce)&&this.database.events.entityAppended.dispatch({database:this.database,entity:e})}newIterator(){return new ki(this._entities)}getIdAt(e){return this._entities.get(e)}};jr.MODEL_SPACE_NAME="*MODEL_SPACE",jr.PAPER_SPACE_NAME_PREFIX="*PAPER_SPACE";let Ft=jr;class vn extends Xr{constructor(e){super(),this.database=e,this._recordsByName=new Map,this._recordsById=new Map}add(e){e.database=this.database;const t=this.normalizeName(e.name);this._recordsByName.set(t,e),this._recordsById.set(e.objectId,e)}remove(e){const t=this.normalizeName(e),s=this._recordsByName.get(t);return s?(this._recordsById.delete(s.objectId),this._recordsByName.delete(e),!0):!1}removeId(e){const t=this._recordsById.get(e);return t?(this._recordsByName.delete(t.name),this._recordsById.delete(e),!0):!1}removeAll(){this._recordsByName.clear(),this._recordsById.clear()}has(e){const t=this.normalizeName(e);return this._recordsByName.has(t)}hasId(e){return this._recordsById.has(e)}getAt(e){const t=this.normalizeName(e);return this._recordsByName.get(t)}getIdAt(e){return this._recordsById.get(e)}getOwnerIdAt(e){return this._recordsById.get(e)}newIterator(){return new ki(this._recordsByName)}normalizeName(e){return e}}class mc extends vn{constructor(e){super(e)}get modelSpace(){let e=this.getAt(Ft.MODEL_SPACE_NAME);return e||(e=new Ft,e.name=Ft.MODEL_SPACE_NAME,this.add(e)),e}normalizeName(e){let t=e;if(Ft.isModelSapceName(e))t=Ft.MODEL_SPACE_NAME;else if(Ft.isPaperSapceName(e)){const s=Ft.PAPER_SPACE_NAME_PREFIX,o=e.substring(s.length);t=s+o}return t}}class pc extends vn{constructor(e){super(e)}}class Ri extends _n{constructor(e,t){e=e||{},Fn(e,{color:new Wr,description:"",standardFlags:0,isHidden:!1,isInUse:!0,isOff:!1,isPlottable:!0,transparency:0,linetype:"",lineWeight:1,materialId:-1}),super(e,t),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(e){this.setAttr("color",e.clone())}get description(){return this.getAttr("description")}set description(e){this.setAttr("description",e)}get standardFlags(){return this.getAttr("standardFlags")}set standardFlags(e){this.setAttr("standardFlags",e)}get isFrozen(){return(this.standardFlags&1)==1}set isFrozen(e){const t=e?1:0;this.standardFlags=this.standardFlags|t}get isHidden(){return this.getAttr("isHidden")}set isHidden(e){this.setAttr("isHidden",e)}get isInUse(){return this.getAttr("isInUse")}set isInUse(e){this.setAttr("isInUse",e)}get isLocked(){return(this.standardFlags&4)==4}set isLocked(e){const t=e?4:0;this.standardFlags=this.standardFlags|t}get isOff(){return this.getAttr("isOff")}set isOff(e){this.setAttr("isOff",e)}get isPlottable(){return this.getAttr("isPlottable")}set isPlottable(e){this.setAttr("isPlottable",e)}get transparency(){return this.getAttr("transparency")}set transparency(e){this.setAttr("transparency",e)}get linetype(){return this.getAttr("linetype")}set linetype(e){this.setAttr("linetype",e)}get lineWeight(){return this.getAttr("lineWeight")}set lineWeight(e){this.setAttr("lineWeight",e)}get materialId(){return this.getAttr("materialId")}set materialId(e){this.setAttr("materialId",e)}}class gc extends vn{constructor(e){super(e);const t=new Wr;t.color=16777215;const s=new Ri({name:"0",standardFlags:0,linetype:ti,lineWeight:1,isOff:!1,color:t,isPlottable:!0});this.add(s)}add(e){super.add(e),this.database.events.layerAppended.dispatch({database:this.database,layer:e})}}class fc extends vn{constructor(e){super(e)}}class _c extends vn{constructor(e){super(e)}get fonts(){const e=new Set,t=o=>{if(o){const h=o.lastIndexOf(".");if(h>=0){const u=o.substring(0,h).toLowerCase();e.add(u)}else e.add(o.toLowerCase())}},s=this.newIterator();for(const o of s)t(o.fileName),t(o.bigFontFileName);return Array.from(e)}}class vc extends vn{constructor(e){super(e)}}class Cs extends _n{constructor(e){super(),this.name=e.name,this._linetype=e}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(e){if(e<0||e>=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[e].elementLength}}class za extends _n{constructor(e){super(),this.name=e.name,this._textStyle=e,this._textStyle.font=this.getFileNameWithoutExtension(this._textStyle.font||this._textStyle.extendedFont||this.name),this._isVertical=!1}get obliquingAngle(){return this._textStyle.obliqueAngle}set obliquingAngle(e){this._textStyle.obliqueAngle=e}get priorSize(){return this._textStyle.lastHeight}set priorSize(e){this._textStyle.lastHeight=e}get textSize(){return this._textStyle.fixedTextHeight}set textSize(e){this._textStyle.fixedTextHeight=e}get xScale(){return this._textStyle.widthFactor}set xScale(e){this._textStyle.widthFactor=e}get isVertical(){return this._isVertical}set isVertical(e){this._isVertical=e}get fileName(){return this._textStyle.font}set fileName(e){this._textStyle.font=e}get bigFontFileName(){return this._textStyle.bigFont}set bigFontFileName(e){this._textStyle.bigFont=e}get textStyle(){return this._textStyle}getFileNameWithoutExtension(e){const t=e.split("/").pop();if(t){const s=t.lastIndexOf(".");return s===-1?t:t.substring(0,s)}return e}}var yc=(i=>(i[i.Center=0]="Center",i[i.Left=1]="Left",i[i.Right=2]="Right",i[i.OverFirst=3]="OverFirst",i[i.OverSecond=4]="OverSecond",i))(yc||{}),bc=(i=>(i[i.Center=0]="Center",i[i.Above=1]="Above",i[i.Outside=2]="Outside",i[i.JIS=3]="JIS",i[i.Below=4]="Below",i))(bc||{}),xc=(i=>(i[i.Feet=0]="Feet",i[i.None=1]="None",i[i.Inch=2]="Inch",i[i.FeetAndInch=3]="FeetAndInch",i[i.Leading=4]="Leading",i[i.Trailing=8]="Trailing",i[i.LeadingAndTrailing=12]="LeadingAndTrailing",i))(xc||{}),wc=(i=>(i[i.None=0]="None",i[i.Leading=1]="Leading",i[i.Trailing=2]="Trailing",i[i.LeadingAndTrailing=3]="LeadingAndTrailing",i))(wc||{}),Ac=(i=>(i[i.Bottom=0]="Bottom",i[i.Middle=1]="Middle",i[i.Top=2]="Top",i))(Ac||{});const Pi=class Pi extends _n{constructor(e,t){e=e||{},Fn(e,Pi.DEFAULT_DIM_VALUES),super(e,t)}get dimpost(){return this.getAttr("dimpost")}set dimpost(e){this.setAttr("dimpost",e)}get dimapost(){return this.getAttr("dimapost")}set dimapost(e){this.setAttr("dimapost",e)}get dimscale(){return this.getAttr("dimscale")}set dimscale(e){this.setAttr("dimscale",e)}get dimasz(){return this.getAttr("dimasz")}set dimasz(e){this.setAttr("dimasz",e)}get dimexo(){return this.getAttr("dimexo")}set dimexo(e){this.setAttr("dimexo",e)}get dimdli(){return this.getAttr("dimdli")}set dimdli(e){this.setAttr("dimdli",e)}get dimexe(){return this.getAttr("dimexe")}set dimexe(e){this.setAttr("dimexe",e)}get dimrnd(){return this.getAttr("dimrnd")}set dimrnd(e){this.setAttr("dimrnd",e)}get dimdle(){return this.getAttr("dimdle")}set dimdle(e){this.setAttr("dimdle",e)}get dimtp(){return this.getAttr("dimtp")}set dimtp(e){this.setAttr("dimtp",e)}get dimtm(){return this.getAttr("dimtm")}set dimtm(e){this.setAttr("dimtm",e)}get dimtxt(){return this.getAttr("dimtxt")}set dimtxt(e){this.setAttr("dimtxt",e)}get dimcen(){return this.getAttr("dimcen")}set dimcen(e){this.setAttr("dimcen",e)}get dimtsz(){return this.getAttr("dimtsz")}set dimtsz(e){this.setAttr("dimtsz",e)}get dimaltf(){return this.getAttr("dimaltf")}set dimaltf(e){this.setAttr("dimaltf",e)}get dimlfac(){return this.getAttr("dimlfac")}set dimlfac(e){this.setAttr("dimlfac",e)}get dimtvp(){return this.getAttr("dimtvp")}set dimtvp(e){this.setAttr("dimtvp",e)}get dimtfac(){return this.getAttr("dimtfac")}set dimtfac(e){this.setAttr("dimtfac",e)}get dimgap(){return this.getAttr("dimgap")}set dimgap(e){this.setAttr("dimgap",e)}get dimaltrnd(){return this.getAttr("dimaltrnd")}set dimaltrnd(e){this.setAttr("dimaltrnd",e)}get dimtol(){return this.getAttr("dimtol")}set dimtol(e){this.setAttr("dimtol",e)}get dimlim(){return this.getAttr("dimlim")}set dimlim(e){this.setAttr("dimlim",e)}get dimtih(){return this.getAttr("dimtih")}set dimtih(e){this.setAttr("dimtih",e)}get dimtoh(){return this.getAttr("dimtoh")}set dimtoh(e){this.setAttr("dimtoh",e)}get dimse1(){return this.getAttr("dimse1")}set dimse1(e){this.setAttr("dimse1",e)}get dimse2(){return this.getAttr("dimse2")}set dimse2(e){this.setAttr("dimse2",e)}get dimtad(){return this.getAttr("dimtad")}set dimtad(e){this.setAttr("dimtad",e)}get dimzin(){return this.getAttr("dimzin")}set dimzin(e){this.setAttr("dimzin",e)}get dimazin(){return this.getAttr("dimazin")}set dimazin(e){this.setAttr("dimazin",e)}get dimalt(){return this.getAttr("dimalt")}set dimalt(e){this.setAttr("dimalt",e)}get dimaltd(){return this.getAttr("dimaltd")}set dimaltd(e){this.setAttr("dimaltd",e)}get dimtofl(){return this.getAttr("dimtofl")}set dimtofl(e){this.setAttr("dimtofl",e)}get dimsah(){return this.getAttr("dimsah")}set dimsah(e){this.setAttr("dimsah",e)}get dimtix(){return this.getAttr("dimtix")}set dimtix(e){this.setAttr("dimtix",e)}get dimsoxd(){return this.getAttr("dimsoxd")}set dimsoxd(e){this.setAttr("dimsoxd",e)}get dimclrd(){return this.getAttr("dimclrd")}set dimclrd(e){this.setAttr("dimclrd",e)}get dimclre(){return this.getAttr("dimclre")}set dimclre(e){this.setAttr("dimclre",e)}get dimclrt(){return this.getAttr("dimclrt")}set dimclrt(e){this.setAttr("dimclrt",e)}get dimadec(){return this.getAttr("dimadec")}set dimadec(e){this.setAttr("dimadec",e)}get dimunit(){return this.getAttr("dimunit")}set dimunit(e){this.setAttr("dimunit",e)}get dimdec(){return this.getAttr("dimdec")}set dimdec(e){this.setAttr("dimdec",e)}get dimtdec(){return this.getAttr("dimtdec")}set dimtdec(e){this.setAttr("dimtdec",e)}get dimaltu(){return this.getAttr("dimaltu")}set dimaltu(e){this.setAttr("dimaltu",e)}get dimalttd(){return this.getAttr("dimalttd")}set dimalttd(e){this.setAttr("dimalttd",e)}get dimaunit(){return this.getAttr("dimaunit")}set dimaunit(e){this.setAttr("dimaunit",e)}get dimfrac(){return this.getAttr("dimfrac")}set dimfrac(e){this.setAttr("dimfrac",e)}get dimlunit(){return this.getAttr("dimlunit")}set dimlunit(e){this.setAttr("dimlunit",e)}get dimdsep(){return this.getAttr("dimdsep")}set dimdsep(e){this.setAttr("dimdsep",e)}get dimtmove(){return this.getAttr("dimtmove")}set dimtmove(e){this.setAttr("dimtmove",e)}get dimjust(){return this.getAttr("dimjust")}set dimjust(e){this.setAttr("dimjust",e)}get dimsd1(){return this.getAttr("dimsd1")}set dimsd1(e){this.setAttr("dimsd1",e)}get dimsd2(){return this.getAttr("dimsd2")}set dimsd2(e){this.setAttr("dimsd2",e)}get dimtolj(){return this.getAttr("dimtolj")}set dimtolj(e){this.setAttr("dimtolj",e)}get dimtzin(){return this.getAttr("dimtzin")}set dimtzin(e){this.setAttr("dimtzin",e)}get dimaltz(){return this.getAttr("dimaltz")}set dimaltz(e){this.setAttr("dimaltz",e)}get dimalttz(){return this.getAttr("dimalttz")}set dimalttz(e){this.setAttr("dimalttz",e)}get dimfit(){return this.getAttr("dimfit")}set dimfit(e){this.setAttr("dimfit",e)}get dimupt(){return this.getAttr("dimupt")}set dimupt(e){this.setAttr("dimupt",e)}get dimatfit(){return this.getAttr("dimatfit")}set dimatfit(e){this.setAttr("dimatfit",e)}get dimtxsty(){return this.getAttr("dimtxsty")}set dimtxsty(e){this.setAttr("dimtxsty",e)}get dimldrblk(){return this.getAttr("dimldrblk")}set dimldrblk(e){this.setAttr("dimldrblk",e)}get dimblk(){return this.getAttr("dimblk")}set dimblk(e){this.setAttr("dimblk",e)}get dimblk1(){return this.getAttr("dimblk1")}set dimblk1(e){this.setAttr("dimblk1",e)}get dimblk2(){return this.getAttr("dimblk2")}set dimblk2(e){this.setAttr("dimblk2",e)}get dimlwd(){return this.getAttr("dimlwd")}set dimlwd(e){this.setAttr("dimlwd",e)}get dimlwe(){return this.getAttr("dimlwe")}set dimlwe(e){this.setAttr("dimlwe",e)}};Pi.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 Bn=Pi;class $d extends Xr{constructor(){super(),this.events={dictObjetSet:new it,dictObjectErased:new it,entityAppended:new it,entityModified:new it,layerAppended:new it,layerModified:new it,layerErased:new it,openProgress:new it,headerSysVarChanged:new it},this._angBase=0,this._angDir=0,this._aunits=va.DecimalDegrees,this._celtscale=1,this._cecolor=new Wr,this._extents=new Re,this._insunits=ya.Millimeters,this._ltscale=1,this._pdmode=0,this._pdsize=0,this._tables={blockTable:new mc(this),dimStyleTable:new pc(this),linetypeTable:new fc(this),textStyleTable:new _c(this),layerTable:new gc(this),viewportTable:new vc(this)},this._dictionaries={layouts:new oc(this),imageDefs:new Oa(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(e){const t=this.tables.blockTable.getIdAt(e);if(t==null)throw new Error(`[AcDbDatabase] The specified block table record id '${e}' doesn't exist in the drawing database!`);this._currentSpace=t}get aunits(){return this._aunits}set aunits(e){this._aunits=e||0,this.triggerHeaderSysVarChangedEvent("aunits")}get insunits(){return this._insunits}set insunits(e){this._insunits=e||4,this.triggerHeaderSysVarChangedEvent("insunits")}get ltscale(){return this._ltscale}set ltscale(e){this._ltscale=e||1,this.triggerHeaderSysVarChangedEvent("ltscale")}get cecolor(){return this._cecolor}set cecolor(e){this._cecolor=e||0,this.triggerHeaderSysVarChangedEvent("cecolor")}get celtscale(){return this._celtscale}set celtscale(e){this._celtscale=e||1,this.triggerHeaderSysVarChangedEvent("celtscale")}get angBase(){return this._angBase}set angBase(e){this._angBase=e||0,this.triggerHeaderSysVarChangedEvent("angbase")}get angDir(){return this._angDir}set angDir(e){this._angDir=e||0,this.triggerHeaderSysVarChangedEvent("angdir")}get extmax(){return this._extents.max}set extmax(e){e&&(this._extents.expandByPoint(e),this.triggerHeaderSysVarChangedEvent("extmax"))}get extmin(){return this._extents.min}set extmin(e){e&&(this._extents.expandByPoint(e),this.triggerHeaderSysVarChangedEvent("extmin"))}get extents(){return this._extents}get pdmode(){return this._pdmode}set pdmode(e){this._pdmode=e||0,this.triggerHeaderSysVarChangedEvent("pdmode")}get pdsize(){return this._pdsize}set pdsize(e){this._pdsize=e||0,this.triggerHeaderSysVarChangedEvent("pdsize")}async read(e,t,s=Ns.DXF){const o=lr.instance.get(s);if(o==null)throw new Error(`Database converter for file type '${s}' isn't registered and can can't read this file!`);this.clear(),await o.read(e,this,t&&t.minimumChunkSize||10,async(h,u,g,b)=>{if(this.events.openProgress.dispatch({database:this,percentage:h,stage:"CONVERSION",subStage:u,subStageStatus:g,data:b}),t&&t.fontLoader&&u=="FONT"&&g=="END"){const f=b||this.tables.textStyleTable.fonts;await t.fontLoader.load(f)}})}async openUri(e,t){var E;this.events.openProgress.dispatch({database:this,percentage:0,stage:"FETCH_FILE",subStageStatus:"START"});const s=await fetch(e);if(!s.ok)throw this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",subStageStatus:"ERROR"}),new Error(`Failed to fetch file '${e}' with HTTP status code '${s.status}'!`);const o=s.headers.get("content-length"),h=o?parseInt(o,10):null;let u=0;const g=(E=s.body)==null?void 0:E.getReader();if(!g)throw new Error("Failed to get response reader");const b=[];for(;;){const{done:M,value:z}=await g.read();if(M)break;if(b.push(z),u+=z.length,h!==null){const D=Math.round(u/h*100);this.events.openProgress.dispatch({database:this,percentage:D,stage:"FETCH_FILE",subStageStatus:"IN-PROGRESS"})}}const f=new Uint8Array(u);let S=0;for(const M of b)f.set(M,S),S+=M.length;if(e.toLowerCase().split(".").pop()==="dwg")await this.read(f.buffer,t,Ns.DWG);else{const M=new TextDecoder().decode(f);await this.read(M,t,Ns.DXF)}this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",subStageStatus:"END"})}createDefaultData(e={layer:!0,lineType:!0,textStyle:!0,dimStyle:!0,layout:!0}){if(e.layer){const t=new Wr;t.colorIndex=7,this._tables.layerTable.add(new Ri({name:"0",standardFlags:0,linetype:"Continuous",lineWeight:0,isOff:!1,color:t,isPlottable:!0}))}if(e.lineType&&(this._tables.linetypeTable.add(new Cs({name:"ByBlock",standardFlag:0,description:"",totalPatternLength:0})),this._tables.linetypeTable.add(new Cs({name:"ByLayer",standardFlag:0,description:"",totalPatternLength:0})),this._tables.linetypeTable.add(new Cs({name:"Continuous",standardFlag:0,description:"Solid line",totalPatternLength:0}))),e.textStyle&&this._tables.textStyleTable.add(new za({name:"Standard",standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:.2,font:"SimKai",bigFont:"",extendedFont:"SimKai"})),e.dimStyle&&this._tables.dimStyleTable.add(new Bn({name:"Standard",dimtxsty:"Standard"})),e.layout){const t=new Di;t.layoutName="Model",t.tabOrder=0,t.blockTableRecordId=this._tables.blockTable.modelSpace.objectId,t.limits.min.copy({x:0,y:0}),t.limits.max.copy({x:1e6,y:1e6}),t.extents.min.copy({x:0,y:0,z:0}),t.extents.max.copy({x:1e6,y:1e6,z:0}),this._dictionaries.layouts.setAt(t.layoutName,t),this._tables.blockTable.modelSpace.layoutId=t.objectId}}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,this._extents.makeEmpty()}triggerHeaderSysVarChangedEvent(e){this.events.headerSysVarChanged.dispatch({database:this,name:e})}}const Zd={center:new Me,viewDirectionFromTarget:new $(0,0,1),viewTarget:new $(0,0,0),lensLength:500,frontClippingPlane:0,backClippingPlane:0,viewHeight:1e3,viewTwistAngle:0,frozenLayers:[],styleSheet:"",renderMode:Na.OPTIMIZED_2D,viewMode:0,ucsIconSetting:0,ucsOrigin:new $(0,0,0),ucsXAxis:new $(1,0,0),ucsYAxis:new $(0,1,0),orthographicType:Ca.TOP,shadePlotSetting:0,shadePlotObjectId:void 0,visualStyleObjectId:void 0,isDefaultLightingOn:!1,defaultLightingType:La.ONE_DISTANT_LIGHT,brightness:0,contrast:0,ambientColor:void 0};class Sc extends _n{constructor(){super(),this._circleSides=100,this._center=new Me,this._lowerLeftCorner=new Me(0,0),this._upperRightCorner=new Me(1,1),this._snapBase=new Me(0,0),this._snapAngle=0,this._snapSpacing=new Me(0,0),this._standardFlag=0,this._gridSpacing=new Me,this._gridMajor=10,this._gsView=Zd}get circleSides(){return this._circleSides}set circleSides(e){this._circleSides=e}get center(){return this._center}get lowerLeftCorner(){return this._lowerLeftCorner}set lowerLeftCorner(e){this._lowerLeftCorner.copy(e)}get upperRightCorner(){return this._upperRightCorner}set upperRightCorner(e){this._upperRightCorner.copy(e)}get snapBase(){return this._snapBase}set snapBase(e){this._snapBase.copy(e)}get snapAngle(){return this._snapAngle}set snapAngle(e){this._snapAngle=e}get snapIncrements(){return this._snapSpacing}set snapIncrements(e){this._snapSpacing.copy(e)}get gridMajor(){return this._gridMajor}set gridMajor(e){this._gridMajor=e}get gridIncrements(){return this._gridSpacing}set gridIncrements(e){this._gridSpacing.copy(e)}get standardFlag(){return this._standardFlag}set standardFlag(e){this._standardFlag=e}get snapEnabled(){return!!(this._standardFlag&256)}get backgroundObjectId(){return this._backgroundObjectId}set backgroundObjectId(e){this._backgroundObjectId=e}get gsView(){return this._gsView}}class Pc{constructor(){this.events={layoutCreated:new it,layoutRemoved:new it,layoutRenamed:new it,layoutSwitched:new it}}countLayouts(e){return this.getWorkingDatabase(e).dictionaries.layouts.numEntries}findLayoutNamed(e,t){return this.getWorkingDatabase(t).dictionaries.layouts.getAt(e)}findActiveLayout(){const e=this.getActiveLayout();return e?e.layoutName:"Model"}setCurrentLayoutId(e,t){const s=this.getWorkingDatabase(t),o=s.dictionaries.layouts.getIdAt(e);return this.setCurrentLayoutInternal(o,s)}setCurrentLayoutBtrId(e,t){const s=this.getWorkingDatabase(t),o=s.dictionaries.layouts.getBtrIdAt(e);return this.setCurrentLayoutInternal(o,s)}setCurrentLayout(e,t){const s=this.getWorkingDatabase(t),o=s.dictionaries.layouts.getAt(e);return this.setCurrentLayoutInternal(o,s)}renameLayout(e,t,s){const h=this.getWorkingDatabase(s).dictionaries.layouts.getAt(e);return h?(h.layoutName=t,this.events.layoutRenamed.dispatch({layout:h,oldName:e,newName:t}),!0):!1}layoutExists(e,t){return this.getWorkingDatabase(t).dictionaries.layouts.has(e)}deleteLayout(e,t){const s=this.getWorkingDatabase(t).dictionaries.layouts,o=s.getAt(e);let h=!1;return o&&(h=s.remove(e),h&&this.events.layoutRemoved.dispatch({layout:o})),h}createLayout(e,t){const s=this.getWorkingDatabase(t),o=new Di;o.layoutName=e,o.tabOrder=s.dictionaries.layouts.maxTabOrder;const h=new Ft;return h.name=`*Paper_Space${o.tabOrder}`,s.tables.blockTable.add(h),s.dictionaries.layouts.setAt(e,o),this.events.layoutCreated.dispatch({layout:o}),{layout:o,btr:h}}getActiveLayout(e){const t=this.getWorkingDatabase(e);return t.dictionaries.layouts.getBtrIdAt(t.currentSpaceId)}getWorkingDatabase(e){return e||Da().workingDatabase}setCurrentLayoutInternal(e,t){return e?(this.events.layoutSwitched.dispatch({layout:e}),t.currentSpaceId=e.blockTableRecordId,!0):!1}}function Da(){return Si.instance}const Ii=class Ii{constructor(){this._workingDatabase=null,this._layoutManager=new Pc}get workingDatabase(){if(this._workingDatabase==null)throw new Error("The current working database must be set before using it!");return this._workingDatabase}set workingDatabase(e){this._workingDatabase=e}get layoutManager(){return this._layoutManager}};Ii.instance=new Ii;let Si=Ii;exports.AcCmColor=Wr;exports.AcCmErrors=Ut;exports.AcCmEventDispatcher=Gc;exports.AcCmEventManager=it;exports.AcCmLoader=Zc;exports.AcCmLoadingManager=tl;exports.AcCmObject=Zo;exports.AcCmPerformanceCollector=ma;exports.AcCmTask=Jo;exports.AcCmTaskScheduler=el;exports.AcDb3PointAngularDimension=yi;exports.AcDbAlignedDimension=bi;exports.AcDbAngleUnits=va;exports.AcDbArc=si;exports.AcDbArcDimension=da;exports.AcDbBaseWorker=Kd;exports.AcDbBatchProcessing=nl;exports.AcDbBlockReference=Ls;exports.AcDbBlockTable=mc;exports.AcDbBlockTableRecord=Ft;exports.AcDbCircle=ii;exports.AcDbCurve=Vt;exports.AcDbDatabase=$d;exports.AcDbDatabaseConverter=fh;exports.AcDbDatabaseConverterManager=lr;exports.AcDbDiametricDimension=xi;exports.AcDbDictionary=Oa;exports.AcDbDimArrowType=ph;exports.AcDbDimStyleTable=pc;exports.AcDbDimStyleTableRecord=Bn;exports.AcDbDimTextHorizontal=yc;exports.AcDbDimTextVertical=bc;exports.AcDbDimVerticalJustification=Ac;exports.AcDbDimZeroSuppression=xc;exports.AcDbDimZeroSuppressionAngular=wc;exports.AcDbDimension=Mr;exports.AcDbDxfConverter=dc;exports.AcDbEllipse=ni;exports.AcDbEntity=Ht;exports.AcDbFileType=Ns;exports.AcDbHatch=ai;exports.AcDbHatchPatternType=Jh;exports.AcDbHatchStyle=ec;exports.AcDbHostApplicationServices=Si;exports.AcDbLayerTable=gc;exports.AcDbLayerTableRecord=Ri;exports.AcDbLayout=Di;exports.AcDbLayoutDictionary=oc;exports.AcDbLayoutManager=Pc;exports.AcDbLeader=oi;exports.AcDbLeaderAnnotationType=tc;exports.AcDbLine=li;exports.AcDbLineSpacingStyle=ac;exports.AcDbLinetypeTable=fc;exports.AcDbLinetypeTableRecord=Cs;exports.AcDbMText=hi;exports.AcDbObject=Xr;exports.AcDbObjectIterator=ki;exports.AcDbOrdinateDimension=wi;exports.AcDbOsnapMode=un;exports.AcDbPoint=pi;exports.AcDbPolyline=mi;exports.AcDbRadialDimension=Ai;exports.AcDbRasterImage=zs;exports.AcDbRasterImageClipBoundaryType=sc;exports.AcDbRasterImageDef=lc;exports.AcDbRasterImageImageDisplayOpt=ic;exports.AcDbRay=gi;exports.AcDbRenderingCache=Gr;exports.AcDbSpline=Os;exports.AcDbSymbolTable=vn;exports.AcDbSymbolTableRecord=_n;exports.AcDbTable=ci;exports.AcDbText=ui;exports.AcDbTextHorizontalMode=rc;exports.AcDbTextStyleTable=_c;exports.AcDbTextStyleTableRecord=za;exports.AcDbTextVerticalMode=nc;exports.AcDbTrace=di;exports.AcDbUnitsValue=ya;exports.AcDbViewport=fi;exports.AcDbViewportTable=vc;exports.AcDbViewportTableRecord=Sc;exports.AcDbWipeout=_i;exports.AcDbWorkerApi=cc;exports.AcDbWorkerManager=hc;exports.AcDbXline=vi;exports.AcGeArea2d=Ti;exports.AcGeBox2d=_t;exports.AcGeBox3d=Re;exports.AcGeCatmullRomCurve3d=Zh;exports.AcGeCircArc2d=Dn;exports.AcGeCircArc3d=pn;exports.AcGeCurve2d=Vn;exports.AcGeEllipseArc2d=Ni;exports.AcGeEllipseArc3d=Ci;exports.AcGeEuler=Yh;exports.AcGeGeometryUtil=Fh;exports.AcGeLine2d=Li;exports.AcGeLine3d=qr;exports.AcGeLoop2d=Kh;exports.AcGeMathUtil=Ee;exports.AcGeMatrix2d=Mi;exports.AcGeMatrix3d=fn;exports.AcGeNurbsCurve=gn;exports.AcGePlane=Ds;exports.AcGePoint2d=Me;exports.AcGePoint3d=$;exports.AcGePolyline2d=Bs;exports.AcGeQuaternion=Hr;exports.AcGeShape2d=Ma;exports.AcGeSpline3d=Yr;exports.AcGeTol=Ia;exports.AcGeVector2d=$e;exports.AcGeVector3d=Z;exports.AcGiArrowType=Ta;exports.AcGiDefaultLightingType=La;exports.AcGiMTextAttachmentPoint=Rn;exports.AcGiMTextFlowDirection=Oi;exports.AcGiOrthographicType=Ca;exports.AcGiRenderMode=Na;exports.AcGiViewport=zi;exports.AcTrStringUtil=$c;exports.ByBlock=mh;exports.ByLayer=Js;exports.DEBUG_MODE=Xc;exports.DEFAULT_LINE_TYPE=ti;exports.DEFAULT_TOL=Ea;exports.DEG2RAD=ba;exports.DefaultLoadingManager=rl;exports.FLOAT_TOL=cn;exports.ORIGIN_POINT_2D=Rd;exports.ORIGIN_POINT_3D=Pa;exports.RAD2DEG=xa;exports.TAU=nt;exports.acdbHostApplicationServices=Da;exports.basisFunction=ri;exports.calculateCurveLength=Gh;exports.ceilPowerOfTwo=Nh;exports.clamp=kr;exports.clone=Is;exports.createWorkerApi=uc;exports.damp=bh;exports.defaults=Fn;exports.degToRad=kh;exports.euclideanModulo=wa;exports.evaluateNurbsPoint=Ts;exports.floorPowerOfTwo=Ch;exports.generateChordKnots=Vh;exports.generateSqrtChordKnots=jh;exports.generateUUID=_h;exports.generateUniformKnots=Uh;exports.has=Ko;exports.intPartLength=Sa;exports.interpolateControlPoints=Bd;exports.inverseLerp=yh;exports.isBetween=Lh;exports.isBetweenAngle=Oh;exports.isEmpty=$o;exports.isEqual=zn;exports.isImperialUnits=Dd;exports.isMetricUnits=zd;exports.isPointInPolygon=ka;exports.isPolygonIntersect=Bh;exports.isPowerOfTwo=Th;exports.lerp=Aa;exports.log=ks;exports.mapLinear=vh;exports.normalizeAngle=Ms;exports.pingpong=xh;exports.radToDeg=Mh;exports.randFloat=Ph;exports.randFloatSpread=Ih;exports.randInt=Sh;exports.relativeEps=zh;exports.seededRandom=Eh;exports.setLogLevel=Kc;exports.smootherstep=Ah;exports.smoothstep=wh;
5
+ `+n+"}",T;case"function":return"<function>";case"string":return r;default:return String(r)}},Te.__interfLoop=function(r,n){if(r==null)return!1;if(r==n)return!0;var a=r.__interfaces__;if(a!=null)for(var l=0,c=a.length;l<c;){var d=l++,p=a[d];if(p==n||Te.__interfLoop(p,n))return!0}return Te.__interfLoop(r.__super__,n)},Te.__instanceof=function(r,n){if(n==null)return!1;switch(n){case Mc:return(r|0)===r;case po:return typeof r=="number";case go:return typeof r=="boolean";case String:return typeof r=="string";case Array:return r instanceof Array&&r.__enum__==null;case Tc:return!0;default:if(r!=null){if(typeof n=="function"){if(r instanceof n||Te.__interfLoop(Te.getClass(r),n))return!0}else if(typeof n=="object"&&Te.__isNativeObj(n)&&r instanceof n)return!0}else return!1;return n==fo&&r.__name__!=null||n==_o&&r.__ename__!=null?!0:r.__enum__==n}},Te.__nativeClassName=function(r){var n=Te.__toStr.call(r).slice(8,-1);return n=="Object"||n=="Function"||n=="Math"||n=="JSON"?null:n},Te.__isNativeObj=function(r){return Te.__nativeClassName(r)!=null},Te.__resolveNativeClass=function(r){return S[r]};var ot=function(r){if(r instanceof Array&&r.__enum__==null)this.a=r,this.byteLength=r.length;else{var n=r;this.a=[];for(var a=0;a<n;){var l=a++;this.a[l]=0}this.byteLength=n}};x["js.html.compat.ArrayBuffer"]=ot,ot.__name__=["js","html","compat","ArrayBuffer"],ot.sliceImpl=function(r,n){var a=new ji(this,r,n==null?null:n-r),l=new Vs(a.byteLength),c=new ji(l);return c.set(a),l},ot.prototype={slice:function(r,n){return new ot(this.a.slice(r,n))},__class__:ot};var hr=function(r,n,a){if(this.buf=r,n==null?this.offset=0:this.offset=n,a==null?this.length=r.byteLength-this.offset:this.length=a,this.offset<0||this.length<0||this.offset+this.length>r.byteLength)throw new Q(Je.OutsideBounds)};x["js.html.compat.DataView"]=hr,hr.__name__=["js","html","compat","DataView"],hr.prototype={getInt8:function(r){var n=this.buf.a[this.offset+r];return n>=128?n-256:n},getUint8:function(r){return this.buf.a[this.offset+r]},getInt16:function(r,n){var a=this.getUint16(r,n);return a>=32768?a-65536:a},getUint16:function(r,n){return n?this.buf.a[this.offset+r]|this.buf.a[this.offset+r+1]<<8:this.buf.a[this.offset+r]<<8|this.buf.a[this.offset+r+1]},getInt32:function(r,n){var a=this.offset+r,l=this.buf.a[a++],c=this.buf.a[a++],d=this.buf.a[a++],p=this.buf.a[a++];return n?l|c<<8|d<<16|p<<24:p|d<<8|c<<16|l<<24},getUint32:function(r,n){var a=this.getInt32(r,n);return a<0?a+4294967296:a},getFloat32:function(r,n){return at.i32ToFloat(this.getInt32(r,n))},getFloat64:function(r,n){var a=this.getInt32(r,n),l=this.getInt32(r+4,n);return at.i64ToDouble(n?a:l,n?l:a)},setInt8:function(r,n){n<0?this.buf.a[r+this.offset]=n+128&255:this.buf.a[r+this.offset]=n&255},setUint8:function(r,n){this.buf.a[r+this.offset]=n&255},setInt16:function(r,n,a){this.setUint16(r,n<0?n+65536:n,a)},setUint16:function(r,n,a){var l=r+this.offset;a?(this.buf.a[l]=n&255,this.buf.a[l++]=n>>8&255):(this.buf.a[l++]=n>>8&255,this.buf.a[l]=n&255)},setInt32:function(r,n,a){this.setUint32(r,n,a)},setUint32:function(r,n,a){var l=r+this.offset;a?(this.buf.a[l++]=n&255,this.buf.a[l++]=n>>8&255,this.buf.a[l++]=n>>16&255,this.buf.a[l++]=n>>>24):(this.buf.a[l++]=n>>>24,this.buf.a[l++]=n>>16&255,this.buf.a[l++]=n>>8&255,this.buf.a[l++]=n&255)},setFloat32:function(r,n,a){this.setUint32(r,at.floatToI32(n),a)},setFloat64:function(r,n,a){var l=at.doubleToI64(n);a?(this.setUint32(r,l.low),this.setUint32(r,l.high)):(this.setUint32(r,l.high),this.setUint32(r,l.low))},__class__:hr};var nr=function(){};x["js.html.compat.Uint8Array"]=nr,nr.__name__=["js","html","compat","Uint8Array"],nr._new=function(r,n,a){var l;if(typeof r=="number"){l=[];for(var c=0;c<r;){var d=c++;l[d]=0}l.byteLength=l.length,l.byteOffset=0,l.buffer=new ot(l)}else if(Te.__instanceof(r,ot)){var p=r;n==null&&(n=0),a==null&&(a=p.byteLength-n),n==0?l=p.a:l=p.a.slice(n,n+a),l.byteLength=l.length,l.byteOffset=n,l.buffer=p}else if(r instanceof Array&&r.__enum__==null)l=r.slice(),l.byteLength=l.length,l.byteOffset=0,l.buffer=new ot(l);else throw new Q("TODO "+ge.string(r));return l.subarray=nr._subarray,l.set=nr._set,l},nr._set=function(r,n){var a=this;if(Te.__instanceof(r.buffer,ot)){var l=r;if(r.byteLength+n>a.byteLength)throw new Q("set() outside of range");for(var c=0,d=r.byteLength;c<d;){var p=c++;a[p+n]=l[p]}}else if(r instanceof Array&&r.__enum__==null){var _=r;if(_.length+n>a.byteLength)throw new Q("set() outside of range");for(var v=0,w=_.length;v<w;){var P=v++;a[P+n]=_[P]}}else throw new Q("TODO")},nr._subarray=function(r,n){var a=this,l=nr._new(a.slice(r,n));return l.byteOffset=r,l};var ke=function(r){this._resolved=!1,this._pending=!1,this._errorPending=!1,this._fulfilled=!1,this._update=[],this._error=[],this._errored=!1,r!=null&&ke.link(r,this,function(n){return n})};x["promhx.base.AsyncBase"]=ke,ke.__name__=["promhx","base","AsyncBase"],ke.link=function(r,n,a){r._update.push({async:n,linkf:function(l){n.handleResolve(a(l))}}),ke.immediateLinkUpdate(r,n,a)},ke.immediateLinkUpdate=function(r,n,a){if(r._errored&&!r._errorPending&&!(r._error.length>0)&&n.handleError(r._errorVal),r._resolved&&!r._pending)try{n.handleResolve(a(r._val))}catch(l){l instanceof Q&&(l=l.val),n.handleError(l)}},ke.linkAll=function(r,n){for(var a=function(d,p,_){if(d.length==0||ke.allFulfilled(d)){for(var v,w=[],P=Xt(r)();P.hasNext();){var A=P.next();w.push(A==p?_:A._val)}v=w,n.handleResolve(v)}},l=Xt(r)();l.hasNext();){var c=l.next();c._update.push({async:n,linkf:function(d,p,_){return function(v){d(p,_,v)}}(a,function(d){for(var p,_=[],v=Xt(r)();v.hasNext();){var w=v.next();w!=c&&_.push(w)}return p=_,p}(),c)})}ke.allFulfilled(r)&&n.handleResolve(function(d){for(var p,_=[],v=Xt(r)();v.hasNext();){var w=v.next();_.push(w._val)}return p=_,p}())},ke.pipeLink=function(r,n,a){var l=!1,c=function(d){if(!l){l=!0;var p=a(d);p._update.push({async:n,linkf:Mt(n,n.handleResolve)}),ke.immediateLinkUpdate(p,n,function(_){return _})}};if(r._update.push({async:n,linkf:c}),r._resolved&&!r._pending)try{c(r._val)}catch(d){d instanceof Q&&(d=d.val),n.handleError(d)}},ke.allResolved=function(r){for(var n=Xt(r)();n.hasNext();){var a=n.next();if(!a._resolved)return!1}return!0},ke.allFulfilled=function(r){for(var n=Xt(r)();n.hasNext();){var a=n.next();if(!a._fulfilled)return!1}return!0},ke.prototype={catchError:function(r){return this._error.push(r),this},errorThen:function(r){return this._errorMap=r,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(r){this._resolve(r)},_resolve:function(r){var n=this;this._pending?Se.enqueue(function(a,l){return function(){a(l)}}(Mt(this,this._resolve),r)):(this._resolved=!0,this._pending=!0,Se.queue.add(function(){n._val=r;for(var a=0,l=n._update;a<l.length;){var c=l[a];++a;try{c.linkf(r)}catch(d){d instanceof Q&&(d=d.val),c.async.handleError(d)}}n._fulfilled=!0,n._pending=!1}),Se.continueOnNextLoop())},handleError:function(r){this._handleError(r)},_handleError:function(r){var n=this,a=function(l){if(n._error.length>0)for(var c=0,d=n._error;c<d.length;){var p=d[c];++c,p(l)}else if(n._update.length>0)for(var _=0,v=n._update;_<v.length;){var w=v[_];++_,w.async.handleError(l)}else throw new Q(l);n._errorPending=!1};this._errorPending||(this._errorPending=!0,this._errored=!0,this._errorVal=r,Se.queue.add(function(){if(n._errorMap!=null)try{n._resolve(n._errorMap(r))}catch(l){l instanceof Q&&(l=l.val),a(l)}else a(r)}),Se.continueOnNextLoop())},then:function(r){var n=new ke(null);return ke.link(this,n,r),n},unlink:function(r){var n=this;Se.queue.add(function(){n._update=n._update.filter(function(a){return a.async!=r})}),Se.continueOnNextLoop()},isLinked:function(r){for(var n=!1,a=0,l=this._update;a<l.length;){var c=l[a];if(++a,c.async==r)return!0}return n},__class__:ke};var yn=f.promhx.Deferred=function(){ke.call(this)};x["promhx.Deferred"]=yn,yn.__name__=["promhx","Deferred"],yn.__super__=ke,yn.prototype=M(ke.prototype,{resolve:function(r){this.handleResolve(r)},throwError:function(r){this.handleError(r)},promise:function(){return new pt(this)},stream:function(){return new He(this)},publicStream:function(){return new Tr(this)},__class__:yn});var pt=f.promhx.Promise=function(r){ke.call(this,r),this._rejected=!1};x["promhx.Promise"]=pt,pt.__name__=["promhx","Promise"],pt.whenAll=function(r){var n=new pt(null);return ke.linkAll(r,n),n},pt.promise=function(r){var n=new pt;return n.handleResolve(r),n},pt.__super__=ke,pt.prototype=M(ke.prototype,{isRejected:function(){return this._rejected},reject:function(r){this._rejected=!0,this.handleError(r)},handleResolve:function(r){if(this._resolved){var n="Promise has already been resolved";throw new Q(bn.AlreadyResolved(n))}this._resolve(r)},then:function(r){var n=new pt(null);return ke.link(this,n,r),n},unlink:function(r){var n=this;Se.queue.add(function(){if(n._fulfilled)n._update=n._update.filter(function(l){return l.async!=r});else{var a="Downstream Promise is not fullfilled";n.handleError(bn.DownstreamNotFullfilled(a))}}),Se.continueOnNextLoop()},handleError:function(r){this._rejected=!0,this._handleError(r)},pipe:function(r){var n=new pt(null);return ke.pipeLink(this,n,r),n},errorPipe:function(r){var n=new pt;return this.catchError(function(a){var l=r(a);l.then(Mt(n,n._resolve))}),this.then(Mt(n,n._resolve)),n},__class__:pt});var He=f.promhx.Stream=function(r){ke.call(this,r),this._end_promise=new pt};x["promhx.Stream"]=He,He.__name__=["promhx","Stream"],He.foreach=function(r){for(var n=new He(null),a=Xt(r)();a.hasNext();){var l=a.next();n.handleResolve(l)}return n.end(),n},He.wheneverAll=function(r){var n=new He(null);return ke.linkAll(r,n),n},He.concatAll=function(r){for(var n=new He(null),a=Xt(r)();a.hasNext();){var l=a.next();n.concat(l)}return n},He.mergeAll=function(r){for(var n=new He(null),a=Xt(r)();a.hasNext();){var l=a.next();n.merge(l)}return n},He.stream=function(r){var n=new He(null);return n.handleResolve(r),n},He.__super__=ke,He.prototype=M(ke.prototype,{then:function(r){var n=new He(null);return ke.link(this,n,r),this._end_promise._update.push({async:n._end_promise,linkf:function(a){n.end()}}),n},detachStream:function(r){for(var n=[],a=!1,l=0,c=this._update;l<c.length;){var d=c[l];++l,d.async==r?(this._end_promise._update=this._end_promise._update.filter(function(p){return p.async!=r._end_promise}),a=!0):n.push(d)}return this._update=n,a},first:function(){var r=new pt(null);return this.then(function(n){r._resolved||r.handleResolve(n)}),r},handleResolve:function(r){!this._end&&!this._pause&&this._resolve(r)},pause:function(r){r==null&&(r=!this._pause),this._pause=r},pipe:function(r){var n=new He(null);return ke.pipeLink(this,n,r),this._end_promise.then(function(a){n.end()}),n},errorPipe:function(r){var n=new He(null);return this.catchError(function(a){var l=r(a);l.then(Mt(n,n._resolve)),l._end_promise.then((Ui=n._end_promise,Mt(Ui,Ui._resolve)))}),this.then(Mt(n,n._resolve)),this._end_promise.then(function(a){n.end()}),n},handleEnd:function(){if(this._pending)Se.queue.add(Mt(this,this.handleEnd)),Se.continueOnNextLoop();else{if(this._end_promise._resolved)return;this._end=!0;var r;this._resolved?r=dt.Some(this._val):r=dt.None,this._end_promise.handleResolve(r),this._update=[],this._error=[]}},end:function(){return Se.queue.add(Mt(this,this.handleEnd)),Se.continueOnNextLoop(),this},endThen:function(r){return this._end_promise.then(r)},filter:function(r){var n=new He(null);return this._update.push({async:n,linkf:function(a){r(a)&&n.handleResolve(a)}}),ke.immediateLinkUpdate(this,n,function(a){return a}),n},concat:function(r){var n=new He(null);return this._update.push({async:n,linkf:Mt(n,n.handleResolve)}),ke.immediateLinkUpdate(this,n,function(a){return a}),this._end_promise.then(function(a){r.pipe(function(l){return n.handleResolve(l),n}),r._end_promise.then(function(l){n.end()})}),n},merge:function(r){var n=new He(null);return this._update.push({async:n,linkf:Mt(n,n.handleResolve)}),r._update.push({async:n,linkf:Mt(n,n.handleResolve)}),ke.immediateLinkUpdate(this,n,function(a){return a}),ke.immediateLinkUpdate(r,n,function(a){return a}),n},__class__:He});var Tr=f.promhx.PublicStream=function(r){He.call(this,r)};x["promhx.PublicStream"]=Tr,Tr.__name__=["promhx","PublicStream"],Tr.publicstream=function(r){var n=new Tr(null);return n.handleResolve(r),n},Tr.__super__=He,Tr.prototype=M(He.prototype,{resolve:function(r){this.handleResolve(r)},throwError:function(r){this.handleError(r)},update:function(r){this.handleResolve(r)},__class__:Tr});var Se=function(){};x["promhx.base.EventLoop"]=Se,Se.__name__=["promhx","base","EventLoop"],Se.enqueue=function(r){Se.queue.add(r),Se.continueOnNextLoop()},Se.set_nextLoop=function(r){if(Se.nextLoop!=null)throw new Q("nextLoop has already been set");return Se.nextLoop=r,Se.nextLoop},Se.queueEmpty=function(){return Se.queue.isEmpty()},Se.finish=function(r){r==null&&(r=1e3);for(var n=null;r-- >0&&(n=Se.queue.pop())!=null;)n();return Se.queue.isEmpty()},Se.clear=function(){Se.queue=new U},Se.f=function(){var r=Se.queue.pop();r!=null&&r(),Se.queue.isEmpty()||Se.continueOnNextLoop()},Se.continueOnNextLoop=function(){Se.nextLoop!=null?Se.nextLoop(Se.f):setImmediate(Se.f)};var bn=x["promhx.error.PromiseError"]={__ename__:["promhx","error","PromiseError"],__constructs__:["AlreadyResolved","DownstreamNotFullfilled"]};bn.AlreadyResolved=function(r){var n=["AlreadyResolved",0,r];return n.__enum__=bn,n.toString=E,n},bn.DownstreamNotFullfilled=function(r){var n=["DownstreamNotFullfilled",1,r];return n.__enum__=bn,n.toString=E,n};var Fs=function(){};x["verb.Verb"]=Fs,Fs.__name__=["verb","Verb"],Fs.main=function(){b.log("verb 2.1.0")};var $=function(){};x["verb.core.ArrayExtensions"]=$,$.__name__=["verb","core","ArrayExtensions"],$.alloc=function(r,n){if(!(n<0))for(;r.length<n;)r.push(null)},$.reversed=function(r){var n=r.slice();return n.reverse(),n},$.last=function(r){return r[r.length-1]},$.first=function(r){return r[0]},$.spliceAndInsert=function(r,n,a,l){r.splice(n,a),r.splice(n,0,l)},$.left=function(r){if(r.length==0)return[];var n=Math.ceil(r.length/2);return r.slice(0,n)},$.right=function(r){if(r.length==0)return[];var n=Math.ceil(r.length/2);return r.slice(n)},$.rightWithPivot=function(r){if(r.length==0)return[];var n=Math.ceil(r.length/2);return r.slice(n-1)},$.unique=function(r,n){if(r.length==0)return[];for(var a=[r.pop()];r.length>0;){for(var l=r.pop(),c=!0,d=0;d<a.length;){var p=a[d];if(++d,n(l,p)){c=!1;break}}c&&a.push(l)}return a};var Re=function(){};x["verb.core.Binomial"]=Re,Re.__name__=["verb","core","Binomial"],Re.get=function(r,n){if(n==0)return 1;if(r==0||n>r)return 0;if(n>r-n&&(n=r-n),Re.memo_exists(r,n))return Re.get_memo(r,n);for(var a=1,l=r,c=1,d=n+1;c<d;){var p=c++;if(Re.memo_exists(l,p)){r--,a=Re.get_memo(l,p);continue}a*=r--,a/=p,Re.memoize(l,p,a)}return a},Re.get_no_memo=function(r,n){if(n==0)return 1;if(r==0||n>r)return 0;n>r-n&&(n=r-n);for(var a=1,l=1,c=n+1;l<c;){var d=l++;a*=r--,a/=d}return a},Re.memo_exists=function(r,n){return Re.memo.h.hasOwnProperty(r)&&Re.memo.h[r].h.hasOwnProperty(n)},Re.get_memo=function(r,n){return Re.memo.h[r].h[n]},Re.memoize=function(r,n,a){Re.memo.h.hasOwnProperty(r)||Re.memo.set(r,new xe),Re.memo.h[r].h[n]=a};var Et=f.core.BoundingBox=function(r){this.max=null,this.min=null,this.dim=3,this.initialized=!1,r!=null&&this.addRange(r)};x["verb.core.BoundingBox"]=Et,Et.__name__=["verb","core","BoundingBox"],Et.intervalsOverlap=function(r,n,a,l,c){c==null&&(c=-1);var d;c<-.5?d=re.TOLERANCE:d=c;var p=Math.min(r,n)-d,_=Math.max(r,n)+d,v=Math.min(a,l)-d,w=Math.max(a,l)+d;return p>=v&&p<=w||_>=v&&_<=w||v>=p&&v<=_||w>=p&&w<=_},Et.prototype={fromPoint:function(r){return new Et([r])},add:function(r){if(!this.initialized)return this.dim=r.length,this.min=r.slice(0),this.max=r.slice(0),this.initialized=!0,this;for(var n=0,a=this.dim;n<a;){var l=n++;r[l]>this.max[l]&&(this.max[l]=r[l]),r[l]<this.min[l]&&(this.min[l]=r[l])}return this},addRange:function(r){for(var n=r.length,a=0;a<n;){var l=a++;this.add(r[l])}return this},contains:function(r,n){return n==null&&(n=-1),this.initialized?this.intersects(new Et([r]),n):!1},intersects:function(r,n){if(n==null&&(n=-1),!this.initialized||!r.initialized)return!1;for(var a=this.min,l=this.max,c=r.min,d=r.max,p=0,_=this.dim;p<_;){var v=p++;if(!Et.intervalsOverlap(a[v],l[v],c[v],d[v],n))return!1}return!0},clear:function(){return this.initialized=!1,this},getLongestAxis:function(){for(var r=0,n=0,a=0,l=this.dim;a<l;){var c=a++,d=this.getAxisLength(c);d>r&&(r=d,n=c)}return n},getAxisLength:function(r){return r<0||r>this.dim-1?0:Math.abs(this.min[r]-this.max[r])},intersect:function(r,n){if(!this.initialized)return null;var a=this.min,l=this.max,c=r.min,d=r.max;if(!this.intersects(r,n))return null;for(var p=[],_=[],v=0,w=this.dim;v<w;){var P=v++;p.push(Math.min(l[P],d[P])),_.push(Math.max(a[P],c[P]))}return new Et([_,p])},__class__:Et};var re=f.core.Constants=function(){};x["verb.core.Constants"]=re,re.__name__=["verb","core","Constants"];var Ze=f.core.SerializableBase=function(){};x["verb.core.SerializableBase"]=Ze,Ze.__name__=["verb","core","SerializableBase"],Ze.prototype={serialize:function(){var r=new Ye;return r.serialize(this),r.toString()},__class__:Ze};var jn=f.core.Plane=function(r,n){this.origin=r,this.normal=n};x["verb.core.Plane"]=jn,jn.__name__=["verb","core","Plane"],jn.__super__=Ze,jn.prototype=M(Ze.prototype,{__class__:jn});var xn=f.core.Ray=function(r,n){this.origin=r,this.dir=n};x["verb.core.Ray"]=xn,xn.__name__=["verb","core","Ray"],xn.__super__=Ze,xn.prototype=M(Ze.prototype,{__class__:xn});var je=f.core.NurbsCurveData=function(r,n,a){this.degree=r,this.controlPoints=a,this.knots=n};x["verb.core.NurbsCurveData"]=je,je.__name__=["verb","core","NurbsCurveData"],je.__super__=Ze,je.prototype=M(Ze.prototype,{__class__:je});var et=f.core.NurbsSurfaceData=function(r,n,a,l,c){this.degreeU=r,this.degreeV=n,this.knotsU=a,this.knotsV=l,this.controlPoints=c};x["verb.core.NurbsSurfaceData"]=et,et.__name__=["verb","core","NurbsSurfaceData"],et.__super__=Ze,et.prototype=M(Ze.prototype,{__class__:et});var qt=f.core.MeshData=function(r,n,a,l){this.faces=r,this.points=n,this.normals=a,this.uvs=l};x["verb.core.MeshData"]=qt,qt.__name__=["verb","core","MeshData"],qt.empty=function(){return new qt([],[],[],[])},qt.__super__=Ze,qt.prototype=M(Ze.prototype,{__class__:qt});var Gn=f.core.PolylineData=function(r,n){this.points=r,this.params=n};x["verb.core.PolylineData"]=Gn,Gn.__name__=["verb","core","PolylineData"],Gn.__super__=Ze,Gn.prototype=M(Ze.prototype,{__class__:Gn});var Wn=f.core.VolumeData=function(r,n,a,l,c,d,p){this.degreeU=r,this.degreeV=n,this.degreeW=a,this.knotsU=l,this.knotsV=c,this.knotsW=d,this.controlPoints=p};x["verb.core.VolumeData"]=Wn,Wn.__name__=["verb","core","VolumeData"],Wn.__super__=Ze,Wn.prototype=M(Ze.prototype,{__class__:Wn});var tt=f.core.Pair=function(r,n){this.item0=r,this.item1=n};x["verb.core.Pair"]=tt,tt.__name__=["verb","core","Pair"],tt.prototype={__class__:tt};var wt=f.core.Interval=function(r,n){this.min=r,this.max=n};x["verb.core.Interval"]=wt,wt.__name__=["verb","core","Interval"],wt.prototype={__class__:wt};var Kr=f.core.CurveCurveIntersection=function(r,n,a,l){this.point0=r,this.point1=n,this.u0=a,this.u1=l};x["verb.core.CurveCurveIntersection"]=Kr,Kr.__name__=["verb","core","CurveCurveIntersection"],Kr.prototype={__class__:Kr};var Hn=f.core.CurveSurfaceIntersection=function(r,n,a,l){this.u=r,this.uv=n,this.curvePoint=a,this.surfacePoint=l};x["verb.core.CurveSurfaceIntersection"]=Hn,Hn.__name__=["verb","core","CurveSurfaceIntersection"],Hn.prototype={__class__:Hn};var Nr=f.core.MeshIntersectionPoint=function(r,n,a,l,c){this.visited=!1,this.adj=null,this.opp=null,this.uv0=r,this.uv1=n,this.point=a,this.faceIndex0,this.faceIndex1};x["verb.core.MeshIntersectionPoint"]=Nr,Nr.__name__=["verb","core","MeshIntersectionPoint"],Nr.prototype={__class__:Nr};var qn=f.core.PolylineMeshIntersection=function(r,n,a,l,c){this.point=r,this.u=n,this.uv=a,this.polylineIndex=l,this.faceIndex=c};x["verb.core.PolylineMeshIntersection"]=qn,qn.__name__=["verb","core","PolylineMeshIntersection"],qn.prototype={__class__:qn};var Yn=f.core.SurfaceSurfaceIntersectionPoint=function(r,n,a,l){this.uv0=r,this.uv1=n,this.point=a,this.dist=l};x["verb.core.SurfaceSurfaceIntersectionPoint"]=Yn,Yn.__name__=["verb","core","SurfaceSurfaceIntersectionPoint"],Yn.prototype={__class__:Yn};var Xn=f.core.TriSegmentIntersection=function(r,n,a,l){this.point=r,this.s=n,this.t=a,this.p=l};x["verb.core.TriSegmentIntersection"]=Xn,Xn.__name__=["verb","core","TriSegmentIntersection"],Xn.prototype={__class__:Xn};var wn=f.core.CurveTriPoint=function(r,n,a){this.u=r,this.point=n,this.uv=a};x["verb.core.CurveTriPoint"]=wn,wn.__name__=["verb","core","CurveTriPoint"],wn.prototype={__class__:wn};var Gt=function(r,n,a,l,c){c==null&&(c=!1),l==null&&(l=-1),this.uv=a,this.point=r,this.normal=n,this.id=l,this.degen=c};x["verb.core.SurfacePoint"]=Gt,Gt.__name__=["verb","core","SurfacePoint"],Gt.fromUv=function(r,n){return new Gt(null,null,[r,n])},Gt.prototype={__class__:Gt};var Us=f.core.CurvePoint=function(r,n){this.u=r,this.pt=n};x["verb.core.CurvePoint"]=Us,Us.__name__=["verb","core","CurvePoint"],Us.prototype={__class__:Us};var Kn=f.core.KdTree=function(r,n){this.dim=3,this.points=r,this.distanceFunction=n,this.dim=r[0].point.length,this.root=this.buildTree(r,0,null)};x["verb.core.KdTree"]=Kn,Kn.__name__=["verb","core","KdTree"],Kn.prototype={buildTree:function(r,n,a){var l=n%this.dim,c,d;return r.length==0?null:r.length==1?new Sn(r[0],l,a):(r.sort(function(p,_){var v=p.point[l]-_.point[l];return v==0?0:v>0?1:-1}),c=Math.floor(r.length/2),d=new Sn(r[c],l,a),d.left=this.buildTree(r.slice(0,c),n+1,d),d.right=this.buildTree(r.slice(c+1),n+1,d),d)},nearest:function(r,n,a){var l=this,c=new $n(function(A){return-A.item1}),d,p=null;p=function(A){for(var I,k=A.dimension,T=l.distanceFunction(r,A.kdPoint.point),L,C=[],R=0,O=l.dim;R<O;)R++,C.push(0);L=C;for(var F,V,q=function(K,ee){c.push(new tt(K,ee)),c.size()>n&&c.pop()},J=0,H=l.dim;J<H;){var j=J++;j==A.dimension?L[j]=r[j]:L[j]=A.kdPoint.point[j]}if(F=l.distanceFunction(L,A.kdPoint.point),A.right==null&&A.left==null){(c.size()<n||T<c.peek().item1)&&q(A,T);return}A.right==null?I=A.left:A.left==null?I=A.right:r[k]<A.kdPoint.point[k]?I=A.left:I=A.right,p(I),(c.size()<n||T<c.peek().item1)&&q(A,T),(c.size()<n||Math.abs(F)<c.peek().item1)&&(I==A.left?V=A.right:V=A.left,V!=null&&p(V))},d=p;for(var _=0;_<n;)_++,c.push(new tt(null,a));d(this.root);for(var v=[],w=0;w<n;){var P=w++;c.content[P].item0!=null&&v.push(new tt(c.content[P].item0.kdPoint,c.content[P].item1))}return v},__class__:Kn};var $n=function(r){this.content=[],this.scoreFunction=r};x["verb.core.BinaryHeap"]=$n,$n.__name__=["verb","core","BinaryHeap"],$n.prototype={push:function(r){this.content.push(r),this.bubbleUp(this.content.length-1)},pop:function(){var r=this.content[0],n=this.content.pop();return this.content.length>0&&(this.content[0]=n,this.sinkDown(0)),r},peek:function(){return this.content[0]},remove:function(r){for(var n=this.content.length,a=0;a<n;){var l=a++;if(this.content[l]==r){var c=this.content.pop();l!=n-1&&(this.content[l]=c,this.scoreFunction(c)<this.scoreFunction(r)?this.bubbleUp(l):this.sinkDown(l));return}}throw new Q("Node not found.")},size:function(){return this.content.length},bubbleUp:function(r){for(var n=this.content[r];r>0;){var a=Math.floor((r+1)/2)-1,l=this.content[a];if(this.scoreFunction(n)<this.scoreFunction(l))this.content[a]=n,this.content[r]=l,r=a;else break}},sinkDown:function(r){for(var n=this.content.length,a=this.content[r],l=this.scoreFunction(a);;){var c=(r+1)*2,d=c-1,p=-1,_=0;if(d<n){var v=this.content[d];_=this.scoreFunction(v),_<l&&(p=d)}if(c<n){var w=this.content[c],P=this.scoreFunction(w);P<(p==-1?l:_)&&(p=c)}if(p!=-1)this.content[r]=this.content[p],this.content[p]=a,r=p;else break}},__class__:$n};var An=f.core.KdPoint=function(r,n){this.point=r,this.obj=n};x["verb.core.KdPoint"]=An,An.__name__=["verb","core","KdPoint"],An.prototype={__class__:An};var Sn=f.core.KdNode=function(r,n,a){this.kdPoint=r,this.left=null,this.right=null,this.parent=a,this.dimension=n};x["verb.core.KdNode"]=Sn,Sn.__name__=["verb","core","KdNode"],Sn.prototype={__class__:Sn};var cr=function(){};x["verb.eval.IBoundingBoxTree"]=cr,cr.__name__=["verb","eval","IBoundingBoxTree"],cr.prototype={__class__:cr};var sr=function(r,n){this._boundingBox=null,this._curve=r,n==null&&(n=m.domain(this._curve.knots)/64),this._knotTol=n};x["verb.core.LazyCurveBoundingBoxTree"]=sr,sr.__name__=["verb","core","LazyCurveBoundingBoxTree"],sr.__interfaces__=[cr],sr.prototype={split:function(){var r=$.first(this._curve.knots),n=$.last(this._curve.knots),a=n-r,l=lt.curveSplit(this._curve,(n+r)/2+a*.1*Math.random());return new tt(new sr(l[0],this._knotTol),new sr(l[1],this._knotTol))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=new Et(N.dehomogenize1d(this._curve.controlPoints))),this._boundingBox},yield:function(){return this._curve},indivisible:function(r){return m.domain(this._curve.knots)<this._knotTol},empty:function(){return!1},__class__:sr};var ir=function(r,n){if(this._boundingBox=null,this._mesh=r,n==null){for(var a=[],l=0,c=r.faces.length;l<c;){var d=l++;a.push(d)}n=a}this._faceIndices=n};x["verb.core.LazyMeshBoundingBoxTree"]=ir,ir.__name__=["verb","core","LazyMeshBoundingBoxTree"],ir.__interfaces__=[cr],ir.prototype={split:function(){var r=rt.sortTrianglesOnLongestAxis(this.boundingBox(),this._mesh,this._faceIndices),n=$.left(r),a=$.right(r);return new tt(new ir(this._mesh,n),new ir(this._mesh,a))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=rt.makeMeshAabb(this._mesh,this._faceIndices)),this._boundingBox},yield:function(){return this._faceIndices[0]},indivisible:function(r){return this._faceIndices.length==1},empty:function(){return this._faceIndices.length==0},__class__:ir};var ar=function(r,n){this._boundingBox=null,this._polyline=r,n==null&&(n=new wt(0,r.points.length!=0?r.points.length-1:0)),this._interval=n};x["verb.core.LazyPolylineBoundingBoxTree"]=ar,ar.__name__=["verb","core","LazyPolylineBoundingBoxTree"],ar.__interfaces__=[cr],ar.prototype={split:function(){var r=this._interval.min,n=this._interval.max,a=r+Math.ceil((n-r)/2),l=new wt(r,a),c=new wt(a,n);return new tt(new ar(this._polyline,l),new ar(this._polyline,c))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=new Et(this._polyline.points)),this._boundingBox},yield:function(){return this._interval.min},indivisible:function(r){return this._interval.max-this._interval.min==1},empty:function(){return this._interval.max-this._interval.min==0},__class__:ar};var Cr=function(r,n,a,l){n==null&&(n=!1),this._boundingBox=null,this._surface=r,this._splitV=n,a==null&&(a=m.domain(r.knotsU)/16),l==null&&(l=m.domain(r.knotsV)/16),this._knotTolU=a,this._knotTolV=l};x["verb.core.LazySurfaceBoundingBoxTree"]=Cr,Cr.__name__=["verb","core","LazySurfaceBoundingBoxTree"],Cr.__interfaces__=[cr],Cr.prototype={split:function(){var r,n;this._splitV?(r=$.first(this._surface.knotsV),n=$.last(this._surface.knotsV)):(r=$.first(this._surface.knotsU),n=$.last(this._surface.knotsU));var a=(r+n)/2,l=lt.surfaceSplit(this._surface,a,this._splitV);return new tt(new Cr(l[0],!this._splitV,this._knotTolU,this._knotTolV),new Cr(l[1],!this._splitV,this._knotTolU,this._knotTolV))},boundingBox:function(){if(this._boundingBox==null){this._boundingBox=new Et;for(var r=0,n=this._surface.controlPoints;r<n.length;){var a=n[r];++r,this._boundingBox.addRange(N.dehomogenize1d(a))}}return this._boundingBox},yield:function(){return this._surface},indivisible:function(r){return m.domain(this._surface.knotsV)<this._knotTolV&&m.domain(this._surface.knotsU)<this._knotTolU},empty:function(){return!1},__class__:Cr};var Ce=f.core.Mat=function(){};x["verb.core.Mat"]=Ce,Ce.__name__=["verb","core","Mat"],Ce.mul=function(r,n){for(var a=[],l=0,c=n.length;l<c;){var d=l++;a.push(m.mul(r,n[d]))}return a},Ce.mult=function(r,n){var a,l,c,d,p,_,v,w;a=r.length,l=n.length,c=n[0].length,d=[];for(var P=a-1,A=0,I=0;P>=0;){for(p=[],_=r[P],I=c-1;I>=0;){for(v=_[l-1]*n[l-1][I],A=l-2;A>=1;)w=A-1,v+=_[A]*n[A][I]+_[w]*n[w][I],A-=2;A==0&&(v+=_[0]*n[0][I]),p[I]=v,I--}d[P]=p,P--}return d},Ce.add=function(r,n){for(var a=[],l=0,c=r.length;l<c;){var d=l++;a.push(m.add(r[d],n[d]))}return a},Ce.div=function(r,n){for(var a=[],l=0,c=r.length;l<c;){var d=l++;a.push(m.div(r[d],n))}return a},Ce.sub=function(r,n){for(var a=[],l=0,c=r.length;l<c;){var d=l++;a.push(m.sub(r[d],n[d]))}return a},Ce.dot=function(r,n){for(var a=[],l=0,c=r.length;l<c;){var d=l++;a.push(m.dot(r[d],n))}return a},Ce.identity=function(r){for(var n=m.zeros2d(r,r),a=0;a<r;){var l=a++;n[l][l]=1}return n},Ce.transpose=function(r){if(r.length==0)return[];for(var n=[],a=0,l=r[0].length;a<l;){var c=a++;n.push(function(d){for(var p,_=[],v=0,w=r.length;v<w;){var P=v++;_.push(r[P][c])}return p=_,p}())}return n},Ce.solve=function(r,n){return Ce.LUsolve(Ce.LU(r),n)},Ce.LUsolve=function(r,n){var a,l,c=r.LU,d=c.length,p=n.slice(),_=r.P,v,w,P;for(a=d-1;a!=-1;)p[a]=n[a],--a;for(a=0;a<d;){for(v=_[a],_[a]!=a&&(P=p[a],p[a]=p[v],p[v]=P),w=c[a],l=0;l<a;)p[a]-=p[l]*w[l],++l;++a}for(a=d-1;a>=0;){for(w=c[a],l=a+1;l<d;)p[a]-=p[l]*w[l],++l;p[a]/=w[a],--a}return p},Ce.LU=function(r){for(var n,a,l,c,d,p,_,v,w,P=[],A=0,I=r.length;A<I;){var k=A++;P.push(r[k].slice())}r=P;var T=r.length,L=T-1,C=[];for(l=0;l<T;){for(_=l,p=r[l],w=Math.abs(p[l]),a=l+1;a<T;)c=Math.abs(r[a][l]),w<c&&(w=c,_=a),++a;for(C[l]=_,_!=l&&(r[l]=r[_],r[_]=p,p=r[l]),d=p[l],n=l+1;n<T;)r[n][l]/=d,++n;for(n=l+1;n<T;){for(v=r[n],a=l+1;a<L;)v[a]-=v[l]*p[a],++a,v[a]-=v[l]*p[a],++a;a==L&&(v[a]-=v[l]*p[a]),++n}++l}return new Zn(r,C)};var Zn=function(r,n){this.LU=r,this.P=n};x["verb.core._Mat.LUDecomp"]=Zn,Zn.__name__=["verb","core","_Mat","LUDecomp"],Zn.prototype={__class__:Zn};var rt=f.core.Mesh=function(){};x["verb.core.Mesh"]=rt,rt.__name__=["verb","core","Mesh"],rt.getTriangleNorm=function(r,n){var a=r[n[0]],l=r[n[1]],c=r[n[2]],d=m.sub(l,a),p=m.sub(c,a),_=m.cross(d,p);return m.mul(1/m.norm(_),_)},rt.makeMeshAabb=function(r,n){for(var a=new Et,l=0;l<n.length;){var c=n[l];++l,a.add(r.points[r.faces[c][0]]),a.add(r.points[r.faces[c][1]]),a.add(r.points[r.faces[c][2]])}return a},rt.sortTrianglesOnLongestAxis=function(r,n,a){for(var l=r.getLongestAxis(),c=[],d=0;d<a.length;){var p=a[d];++d;var _=rt.getMinCoordOnAxis(n.points,n.faces[p],l);c.push(new tt(_,p))}c.sort(function(I,k){var T=I.item0,L=k.item0;return T==L?0:T>L?1:-1});for(var v=[],w=0,P=c.length;w<P;){var A=w++;v.push(c[A].item1)}return v},rt.getMinCoordOnAxis=function(r,n,a){for(var l=1/0,c=0;c<3;){var d=c++,p=r[n[d]][a];p<l&&(l=p)}return l},rt.getTriangleCentroid=function(r,n){for(var a=[0,0,0],l=0;l<3;)for(var c=l++,d=0;d<3;){var p=d++;a[p]+=r[n[c]][p]}for(var _=0;_<3;){var v=_++;a[v]/=3}return a},rt.triangleUVFromPoint=function(r,n,a){var l=r.faces[n],c=r.points[l[0]],d=r.points[l[1]],p=r.points[l[2]],_=r.uvs[l[0]],v=r.uvs[l[1]],w=r.uvs[l[2]],P=m.sub(c,a),A=m.sub(d,a),I=m.sub(p,a),k=m.norm(m.cross(m.sub(c,d),m.sub(c,p))),T=m.norm(m.cross(A,I))/k,L=m.norm(m.cross(I,P))/k,C=m.norm(m.cross(P,A))/k;return m.add(m.mul(T,_),m.add(m.mul(L,v),m.mul(C,w)))};var Lr=function(r,n){if(this._empty=!1,this._face=-1,n==null){for(var a=[],l=0,c=r.faces.length;l<c;){var d=l++;a.push(d)}n=a}if(this._boundingBox=rt.makeMeshAabb(r,n),n.length<1){this._empty=!0;return}else if(n.length<2){this._face=n[0];return}var p=rt.sortTrianglesOnLongestAxis(this._boundingBox,r,n),_=$.left(p),v=$.right(p);this._children=new tt(new Lr(r,_),new Lr(r,v))};x["verb.core.MeshBoundingBoxTree"]=Lr,Lr.__name__=["verb","core","MeshBoundingBoxTree"],Lr.__interfaces__=[cr],Lr.prototype={split:function(){return this._children},boundingBox:function(){return this._boundingBox},yield:function(){return this._face},indivisible:function(r){return this._children==null},empty:function(){return this._empty},__class__:Lr};var Yt=f.core.Minimizer=function(){};x["verb.core.Minimizer"]=Yt,Yt.__name__=["verb","core","Minimizer"],Yt.uncmin=function(r,n,a,l,c){a==null&&(a=1e-8),l==null&&(l=function(J){return Yt.numericalGradient(r,J)}),c==null&&(c=1e3),n=n.slice(0);var d=n.length,p=r(n),_=p,v;if(isNaN(p))throw new Q("uncmin: f(x0) is a NaN!");a=Math.max(a,re.EPSILON);var w,P,A,I=Ce.identity(d),k=0,T=[],L,C,R,O,F,V,q="";for(P=l(n);k<c;){if(!m.all(m.finite(P))){q="Gradient has Infinity or NaN";break}if(w=m.neg(Ce.dot(I,P)),!m.all(m.finite(w))){q="Search direction has Infinity or NaN";break}if(V=m.norm(w),V<a){q="Newton step smaller than tol";break}for(F=1,v=m.dot(P,w),L=n;k<c&&!(F*V<a);){if(T=m.mul(F,w),L=m.add(n,T),_=r(L),_-p>=.1*F*v||isNaN(_)){F*=.5,++k;continue}break}if(F*V<a){q="Line search step size smaller than tol";break}if(k==c){q="maxit reached during line search";break}A=l(L),C=m.sub(A,P),O=m.dot(C,T),R=Ce.dot(I,C),I=Ce.sub(Ce.add(I,Ce.mul((O+m.dot(C,R))/(O*O),Yt.tensor(T,T))),Ce.div(Ce.add(Yt.tensor(R,T),Yt.tensor(T,R)),O)),n=L,p=_,P=A,++k}return new Qn(n,p,P,I,k,q)},Yt.numericalGradient=function(r,n){var a=n.length,l=r(n);if(l==NaN)throw new Q("gradient: f(x) is a NaN!");for(var c=n.slice(0),d,p,_=[],v,w=.001,P,A,I,k=0,T,L,C,R=0;R<a;)for(var O=R++,F=Math.max(1e-6*l,1e-8);;){if(++k,k>20)throw new Q("Numerical gradient fails");if(c[O]=n[O]+F,d=r(c),c[O]=n[O]-F,p=r(c),c[O]=n[O],isNaN(d)||isNaN(p)){F/=16;continue}if(_[O]=(d-p)/(2*F),P=n[O]-F,A=n[O],I=n[O]+F,T=(d-l)/F,L=(l-p)/F,C=m.max([Math.abs(_[O]),Math.abs(l),Math.abs(d),Math.abs(p),Math.abs(P),Math.abs(A),Math.abs(I),1e-8]),v=Math.min(m.max([Math.abs(T-_[O]),Math.abs(L-_[O]),Math.abs(T-L)])/C,F/C),v>w)F/=16;else break}return _},Yt.tensor=function(r,n){for(var a=r.length,l=n.length,c=[],d,p,_=a-1;_>=0;){d=[],p=r[_];for(var v=l-1;v>=3;)d[v]=p*n[v],--v,d[v]=p*n[v],--v,d[v]=p*n[v],--v,d[v]=p*n[v],--v;for(;v>=0;)d[v]=p*n[v],--v;c[_]=d,_--}return c};var Qn=function(r,n,a,l,c,d){this.solution=r,this.value=n,this.gradient=a,this.invHessian=l,this.iterations=c,this.message=d};x["verb.core.MinimizationResult"]=Qn,Qn.__name__=["verb","core","MinimizationResult"],Qn.prototype={__class__:Qn};var Pn=function(){};x["verb.core.ISerializable"]=Pn,Pn.__name__=["verb","core","ISerializable"],Pn.prototype={__class__:Pn};var Fi=f.core.Deserializer=function(){};x["verb.core.Deserializer"]=Fi,Fi.__name__=["verb","core","Deserializer"],Fi.deserialize=function(r){var n=new We(r),a=n.unserialize();return a};var kt=f.core.Trig=function(){};x["verb.core.Trig"]=kt,kt.__name__=["verb","core","Trig"],kt.isPointInPlane=function(r,n,a){return Math.abs(m.dot(m.sub(r,n.origin),n.normal))<a},kt.distToSegment=function(r,n,a){var l=kt.segmentClosestPoint(n,r,a,0,1);return m.dist(n,l.pt)},kt.rayClosestPoint=function(r,n,a){var l=m.sub(r,n),c=m.dot(l,a),d=m.add(n,m.mul(c,a));return d},kt.distToRay=function(r,n,a){var l=kt.rayClosestPoint(r,n,a),c=m.sub(l,r);return m.norm(c)},kt.threePointsAreFlat=function(r,n,a,l){var c=m.sub(n,r),d=m.sub(a,r),p=m.cross(c,d),_=m.dot(p,p);return _<l},kt.segmentClosestPoint=function(r,n,a,l,c){var d=m.sub(a,n),p=m.norm(d);if(p<re.EPSILON)return{u:l,pt:n};var _=n,v=m.mul(1/p,d),w=m.sub(r,_),P=m.dot(w,v);return P<0?{u:l,pt:n}:P>p?{u:c,pt:a}:{u:l+(c-l)*P/p,pt:m.add(_,m.mul(P,v))}};var m=f.core.Vec=function(){};x["verb.core.Vec"]=m,m.__name__=["verb","core","Vec"],m.angleBetween=function(r,n){return Math.acos(m.dot(r,n)/(m.norm(r)*m.norm(n)))},m.positiveAngleBetween=function(r,n,a){var l=m.cross(r,n),c=m.norm(r),d=m.norm(n),p=c*d,_=m.dot(r,n),v=m.norm(l)/p,w=_/p,P=Math.atan2(v,w),A=m.dot(a,l);return Math.abs(A)<re.EPSILON||A>0?P:-P},m.signedAngleBetween=function(r,n,a){var l=m.cross(r,n),c=m.norm(r),d=m.norm(n),p=c*d,_=m.dot(r,n),v=m.norm(l)/p,w=_/p,P=Math.atan2(v,w),A=m.dot(a,l);return A>0?P:2*Math.PI-P},m.angleBetweenNormalized2d=function(r,n){var a=r[0]*n[1]-r[1]*n[0];return Math.atan2(a,m.dot(r,n))},m.domain=function(r){return $.last(r)-$.first(r)},m.range=function(r){for(var n=[],a=0,l=0;l<r;)l++,n.push(a),a+=1;return n},m.span=function(r,n,a){if(a==null)return[];if(a<re.EPSILON)return[];if(r>n&&a>0)return[];if(n>r&&a<0)return[];for(var l=[],c=r;c<=n;)l.push(c),c+=a;return l},m.neg=function(r){return r.map(function(n){return-n})},m.min=function(r){return D.fold(r,function(n,a){return Math.min(n,a)},1/0)},m.max=function(r){return D.fold(r,function(n,a){return Math.max(n,a)},-1/0)},m.all=function(r){return D.fold(r,function(n,a){return a&&n},!0)},m.finite=function(r){return r.map(function(n){return isFinite(n)})},m.onRay=function(r,n,a){return m.add(r,m.mul(a,n))},m.lerp=function(r,n,a){return m.add(m.mul(r,n),m.mul(1-r,a))},m.normalized=function(r){return m.div(r,m.norm(r))},m.cross=function(r,n){return[r[1]*n[2]-r[2]*n[1],r[2]*n[0]-r[0]*n[2],r[0]*n[1]-r[1]*n[0]]},m.dist=function(r,n){return m.norm(m.sub(r,n))},m.distSquared=function(r,n){return m.normSquared(m.sub(r,n))},m.sum=function(r){return D.fold(r,function(n,a){return a+n},0)},m.addAll=function(r){var n=Xt(r)();if(!n.hasNext())return null;var a=n.next().length;return D.fold(r,function(l,c){return m.add(c,l)},m.rep(a,0))},m.addAllMutate=function(r){for(var n=r[0],a=1,l=r.length;a<l;){var c=a++;m.addMutate(n,r[c])}},m.addMulMutate=function(r,n,a){for(var l=0,c=r.length;l<c;){var d=l++;r[d]=r[d]+n*a[d]}},m.subMulMutate=function(r,n,a){for(var l=0,c=r.length;l<c;){var d=l++;r[d]=r[d]-n*a[d]}},m.addMutate=function(r,n){for(var a=0,l=r.length;a<l;){var c=a++;r[c]=r[c]+n[c]}},m.subMutate=function(r,n){for(var a=0,l=r.length;a<l;){var c=a++;r[c]=r[c]-n[c]}},m.mulMutate=function(r,n){for(var a=0,l=n.length;a<l;){var c=a++;n[c]=n[c]*r}},m.norm=function(r){var n=m.normSquared(r);return n!=0?Math.sqrt(n):n},m.normSquared=function(r){return D.fold(r,function(n,a){return a+n*n},0)},m.rep=function(r,n){for(var a=[],l=0;l<r;)l++,a.push(n);return a},m.zeros1d=function(r){for(var n=[],a=0;a<r;)a++,n.push(0);return n},m.zeros2d=function(r,n){for(var a=[],l=0;l<r;)l++,a.push(m.zeros1d(n));return a},m.zeros3d=function(r,n,a){for(var l=[],c=0;c<r;)c++,l.push(m.zeros2d(n,a));return l},m.dot=function(r,n){for(var a=0,l=0,c=r.length;l<c;){var d=l++;a+=r[d]*n[d]}return a},m.add=function(r,n){for(var a=[],l=0,c=r.length;l<c;){var d=l++;a.push(r[d]+n[d])}return a},m.mul=function(r,n){for(var a=[],l=0,c=n.length;l<c;){var d=l++;a.push(r*n[d])}return a},m.div=function(r,n){for(var a=[],l=0,c=r.length;l<c;){var d=l++;a.push(r[d]/n)}return a},m.sub=function(r,n){for(var a=[],l=0,c=r.length;l<c;){var d=l++;a.push(r[d]-n[d])}return a},m.isZero=function(r){for(var n=0,a=r.length;n<a;){var l=n++;if(Math.abs(r[l])>re.TOLERANCE)return!1}return!0},m.sortedSetUnion=function(r,n){for(var a=[],l=0,c=0;l<r.length||c<n.length;){if(l>=r.length){a.push(n[c]),c++;continue}else if(c>=n.length){a.push(r[l]),l++;continue}var d=r[l]-n[c];if(Math.abs(d)<re.EPSILON){a.push(r[l]),l++,c++;continue}if(d>0){a.push(n[c]),c++;continue}a.push(r[l]),l++}return a},m.sortedSetSub=function(r,n){for(var a=[],l=0,c=0;l<r.length;){if(c>=n.length){a.push(r[l]),l++;continue}if(Math.abs(r[l]-n[c])<re.EPSILON){l++,c++;continue}a.push(r[l]),l++}return a};var ve=f.eval.Analyze=function(){};x["verb.eval.Analyze"]=ve,ve.__name__=["verb","eval","Analyze"],ve.knotMultiplicities=function(r){for(var n=[new In(r[0],0)],a=n[0],l=0;l<r.length;){var c=r[l];++l,Math.abs(c-a.knot)>re.EPSILON&&(a=new In(c,0),n.push(a)),a.inc()}return n},ve.isRationalSurfaceClosed=function(r,n){n==null&&(n=!0);var a;n?a=r.controlPoints:a=Ce.transpose(r.controlPoints);for(var l=0,c=a[0].length;l<c;){var d=l++,p=m.dist($.first(a)[d],$.last(a)[d])<re.EPSILON;if(!p)return!1}return!0},ve.rationalSurfaceClosestPoint=function(r,n){var a=ve.rationalSurfaceClosestParam(r,n);return N.rationalSurfacePoint(r,a[0],a[1])},ve.rationalSurfaceClosestParam=function(r,n){for(var a=5,l=0,c,d=1e-4,p=5e-4,_,v=r.knotsU[0],w=$.last(r.knotsU),P=r.knotsV[0],A=$.last(r.knotsV),I=ve.isRationalSurfaceClosed(r),k=ve.isRationalSurfaceClosed(r,!1),T,L=Oe.rationalSurfaceAdaptive(r,new Or),C=1/0,R=0,O=L.points.length;R<O;){var F=R++,V=L.points[F],q=m.normSquared(m.sub(n,V));q<C&&(C=q,T=L.uvs[F])}for(var J=function(Ge){return N.rationalSurfaceDerivatives(r,Ge[0],Ge[1],2)},H=function(Ge,Xe,Fe){var Ke=Xe[1][0],At=Xe[0][1],Ht=Xe[2][0],vt=Xe[0][2],gt=Xe[1][1],St=Xe[1][1],Tt=m.dot(Ke,Fe),Kt=m.dot(At,Fe),or=[-Tt,-Kt],$t=m.dot(Ke,Ke)+m.dot(Ht,Fe),Zt=m.dot(Ke,At)+m.dot(gt,Fe),Qt=m.dot(Ke,At)+m.dot(St,Fe),dr=m.dot(At,At)+m.dot(vt,Fe),Tn=[[$t,Zt],[Qt,dr]],Zr=Ce.solve(Tn,or);return m.add(Zr,Ge)};l<a;){c=J(T),_=m.sub(c[0][0],n);var j=m.norm(_),K=m.dot(c[1][0],_),ee=m.norm(c[1][0])*j,te=m.dot(c[0][1],_),ie=m.norm(c[0][1])*j,he=K/ee,ae=te/ie,ue=j<d,ne=he<p,de=ae<p;if(ue&&ne&&de)return T;var X=H(T,c,_);X[0]<v?I?X=[w-(X[0]-v),X[1]]:X=[v+re.EPSILON,X[1]]:X[0]>w&&(I?X=[v+(X[0]-w),X[1]]:X=[w-re.EPSILON,X[1]]),X[1]<P?k?X=[X[0],A-(X[1]-P)]:X=[X[0],P+re.EPSILON]:X[1]>A&&(k?X=[X[0],P+(X[0]-A)]:X=[X[0],A-re.EPSILON]);var pe=m.norm(m.mul(X[0]-T[0],c[1][0])),Pe=m.norm(m.mul(X[1]-T[1],c[0][1]));if(pe+Pe<d)return T;T=X,l++}return T},ve.rationalCurveClosestPoint=function(r,n){return N.rationalCurvePoint(r,ve.rationalCurveClosestParam(r,n))},ve.rationalCurveClosestParam=function(r,n){for(var a=1/0,l=0,c=Oe.rationalCurveRegularSample(r,r.controlPoints.length*r.degree,!0),d=0,p=c.length-1;d<p;){var _=d++,v=c[_][0],w=c[_+1][0],P=c[_].slice(1),A=c[_+1].slice(1),I=kt.segmentClosestPoint(n,P,A,v,w),k=m.norm(m.sub(n,I.pt));k<a&&(a=k,l=I.u)}for(var T=5,L=0,C,R=1e-4,O=5e-4,F,V=r.knots[0],q=$.last(r.knots),J=m.normSquared(m.sub(r.controlPoints[0],$.last(r.controlPoints)))<re.EPSILON,H=l,j=function(X){return N.rationalCurveDerivatives(r,X,2)},K=function(X,pe,Pe){var Ge=m.dot(pe[1],Pe),Xe=m.dot(pe[2],Pe),Fe=m.dot(pe[1],pe[1]),Ke=Xe+Fe;return X-Ge/Ke};L<T;){C=j(H),F=m.sub(C[0],n);var ee=m.norm(F),te=m.dot(C[1],F),ie=m.norm(C[1])*ee,he=te/ie,ae=ee<R,ue=Math.abs(he)<O;if(ae&&ue)return H;var ne=K(H,C,F);ne<V?J?ne=q-(ne-V):ne=V:ne>q&&(J?ne=V+(ne-q):ne=q);var de=m.norm(m.mul(ne-H,C[1]));if(de<R)return H;H=ne,L++}return H},ve.rationalCurveParamAtArcLength=function(r,n,a,l,c){if(a==null&&(a=.001),n<re.EPSILON)return r.knots[0];var d;l!=null?d=l:d=fe.decomposeCurveIntoBeziers(r);var p=0;d[p];var _=-re.EPSILON,v;for(c!=null?v=c:v=[];_<n&&p<d.length;){if(p<v.length?v[p]=v[p]:v[p]=ve.rationalBezierCurveArcLength(r),_+=v[p],n<_+re.EPSILON)return ve.rationalBezierCurveParamAtArcLength(r,n,a,v[p]);p++}return-1},ve.rationalBezierCurveParamAtArcLength=function(r,n,a,l){if(n<0)return r.knots[0];var c;if(l!=null?c=l:c=ve.rationalBezierCurveArcLength(r),n>c)return $.last(r.knots);var d=r.knots[0],p=0,_=$.last(r.knots),v=c,w=0,P=0,A;for(a!=null?A=a:A=re.TOLERANCE*2;v-p>A;)w=(d+_)/2,P=ve.rationalBezierCurveArcLength(r,w),P>n?(_=w,v=P):(d=w,p=P);return(d+_)/2},ve.rationalCurveArcLength=function(r,n,a){a==null&&(a=16),n==null?n=$.last(r.knots):n=n;for(var l=fe.decomposeCurveIntoBeziers(r),c=0,d=l[0],p=0;c<l.length&&d.knots[0]+re.EPSILON<n;){var _=Math.min($.last(d.knots),n);p+=ve.rationalBezierCurveArcLength(d,_,a),d=l[++c]}return p},ve.rationalBezierCurveArcLength=function(r,n,a){a==null&&(a=16);var l;n==null?l=$.last(r.knots):l=n;for(var c=(l-r.knots[0])/2,d=0,p=r.degree+a,_,v,w=0;w<p;){var P=w++;_=c*ve.Tvalues[p][P]+c+r.knots[0],v=N.rationalCurveDerivatives(r,_,1),d+=ve.Cvalues[p][P]*m.norm(v[1])}return c*d};var In=f.eval.KnotMultiplicity=function(r,n){this.knot=r,this.mult=n};x["verb.eval.KnotMultiplicity"]=In,In.__name__=["verb","eval","KnotMultiplicity"],In.prototype={inc:function(){this.mult++},__class__:In};var Wt=f.eval.Check=function(){};x["verb.eval.Check"]=Wt,Wt.__name__=["verb","eval","Check"],Wt.isValidKnotVector=function(r,n){if(r.length==0||r.length<(n+1)*2)return!1;for(var a=$.first(r),l=0,c=n+1;l<c;){var d=l++;if(Math.abs(r[d]-a)>re.EPSILON)return!1}a=$.last(r);for(var p=r.length-n-1,_=r.length;p<_;){var v=p++;if(Math.abs(r[v]-a)>re.EPSILON)return!1}return Wt.isNonDecreasing(r)},Wt.isNonDecreasing=function(r){for(var n=$.first(r),a=0,l=r.length;a<l;){var c=a++;if(r[c]<n-re.EPSILON)return!1;n=r[c]}return!0},Wt.isValidNurbsCurveData=function(r){if(r.controlPoints==null)throw new Q("Control points array cannot be null!");if(r.degree==null)throw new Q("Degree cannot be null!");if(r.degree<1)throw new Q("Degree must be greater than 1!");if(r.knots==null)throw new Q("Knots cannot be null!");if(r.knots.length!=r.controlPoints.length+r.degree+1)throw new Q("controlPoints.length + degree + 1 must equal knots.length!");if(!Wt.isValidKnotVector(r.knots,r.degree))throw new Q("Invalid knot vector format! Should begin with degree + 1 repeats and end with degree + 1 repeats!");return r},Wt.isValidNurbsSurfaceData=function(r){if(r.controlPoints==null)throw new Q("Control points array cannot be null!");if(r.degreeU==null)throw new Q("DegreeU cannot be null!");if(r.degreeV==null)throw new Q("DegreeV cannot be null!");if(r.degreeU<1)throw new Q("DegreeU must be greater than 1!");if(r.degreeV<1)throw new Q("DegreeV must be greater than 1!");if(r.knotsU==null)throw new Q("KnotsU cannot be null!");if(r.knotsV==null)throw new Q("KnotsV cannot be null!");if(r.knotsU.length!=r.controlPoints.length+r.degreeU+1)throw new Q("controlPointsU.length + degreeU + 1 must equal knotsU.length!");if(r.knotsV.length!=r.controlPoints[0].length+r.degreeV+1)throw new Q("controlPointsV.length + degreeV + 1 must equal knotsV.length!");if(!Wt.isValidKnotVector(r.knotsU,r.degreeU)||!Wt.isValidKnotVector(r.knotsV,r.degreeV))throw new Q("Invalid knot vector format! Should begin with degree + 1 repeats and end with degree + 1 repeats!");return r};var lt=f.eval.Divide=function(){};x["verb.eval.Divide"]=lt,lt.__name__=["verb","eval","Divide"],lt.surfaceSplit=function(r,n,a){a==null&&(a=!1);var l,c,d;a?(d=r.controlPoints,l=r.knotsV,c=r.degreeV):(d=Ce.transpose(r.controlPoints),l=r.knotsU,c=r.degreeU);for(var p,_=[],v=0,w=c+1;v<w;)v++,_.push(n);p=_;for(var P=[],A=[],I=N.knotSpan(c,n,l),k=null,T=0;T<d.length;){var L=d[T];++T,k=fe.curveKnotRefine(new je(c,l,L),p),P.push(k.controlPoints.slice(0,I+1)),A.push(k.controlPoints.slice(I+1))}var C=k.knots.slice(0,I+c+2),R=k.knots.slice(I+1);return a?[new et(r.degreeU,c,r.knotsU.slice(),C,P),new et(r.degreeU,c,r.knotsU.slice(),R,A)]:(P=Ce.transpose(P),A=Ce.transpose(A),[new et(c,r.degreeV,C,r.knotsV.slice(),P),new et(c,r.degreeV,R,r.knotsV.slice(),A)])},lt.curveSplit=function(r,n){var a=r.degree;r.controlPoints;for(var l=r.knots,c,d=[],p=0,_=a+1;p<_;)p++,d.push(n);c=d;var v=fe.curveKnotRefine(r,c),w=N.knotSpan(a,n,l),P=v.knots.slice(0,w+a+2),A=v.knots.slice(w+1),I=v.controlPoints.slice(0,w+1),k=v.controlPoints.slice(w+1);return[new je(a,P,I),new je(a,A,k)]},lt.rationalCurveByEqualArcLength=function(r,n){var a=ve.rationalCurveArcLength(r),l=a/n;return lt.rationalCurveByArcLength(r,l)},lt.rationalCurveByArcLength=function(r,n){var a=fe.decomposeCurveIntoBeziers(r),l=a.map(function(I){return ve.rationalBezierCurveArcLength(I)}),c=m.sum(l),d=[new En(r.knots[0],0)];if(n>c)return d;for(var p=n,_=0,v=p,w=0,P=0,A;_<a.length;){for(w+=l[_];v<w+re.EPSILON;)A=ve.rationalBezierCurveParamAtArcLength(a[_],v-P,re.TOLERANCE,l[_]),d.push(new En(A,v)),v+=p;P+=l[_],_++}return d};var En=f.eval.CurveLengthSample=function(r,n){this.u=r,this.len=n};x["verb.eval.CurveLengthSample"]=En,En.__name__=["verb","eval","CurveLengthSample"],En.prototype={__class__:En};var N=f.eval.Eval=function(){};x["verb.eval.Eval"]=N,N.__name__=["verb","eval","Eval"],N.rationalCurveTangent=function(r,n){var a=N.rationalCurveDerivatives(r,n,1);return a[1]},N.rationalSurfaceNormal=function(r,n,a){var l=N.rationalSurfaceDerivatives(r,n,a,1);return m.cross(l[1][0],l[0][1])},N.rationalSurfaceDerivatives=function(r,n,a,l){l==null&&(l=1);for(var c=N.surfaceDerivatives(r,n,a,l),d=N.rational2d(c),p=N.weight2d(c),_=[],v=d[0][0].length,w=0,P=l+1;w<P;){var A=w++;_.push([]);for(var I=0,k=l-A+1;I<k;){for(var T=I++,L=d[A][T],C=1,R=T+1;C<R;){var O=C++;m.subMulMutate(L,Re.get(T,O)*p[0][O],_[A][T-O])}for(var F=1,V=A+1;F<V;){var q=F++;m.subMulMutate(L,Re.get(A,q)*p[q][0],_[A-q][T]);for(var J=m.zeros1d(v),H=1,j=T+1;H<j;){var K=H++;m.addMulMutate(J,Re.get(T,K)*p[q][K],_[A-q][T-K])}m.subMulMutate(L,Re.get(A,q),J)}m.mulMutate(1/p[0][0],L),_[A].push(L)}}return _},N.rationalSurfacePoint=function(r,n,a){return N.dehomogenize(N.surfacePoint(r,n,a))},N.rationalCurveDerivatives=function(r,n,a){a==null&&(a=1);for(var l=N.curveDerivatives(r,n,a),c=N.rational1d(l),d=N.weight1d(l),p=[],_=0,v=a+1;_<v;){for(var w=_++,P=c[w],A=1,I=w+1;A<I;){var k=A++;m.subMulMutate(P,Re.get(w,k)*d[k],p[w-k])}m.mulMutate(1/d[0],P),p.push(P)}return p},N.rationalCurvePoint=function(r,n){return N.dehomogenize(N.curvePoint(r,n))},N.surfaceDerivatives=function(r,n,a,l){var c=r.knotsU.length-r.degreeU-2,d=r.knotsV.length-r.degreeV-2;return N.surfaceDerivativesGivenNM(c,d,r,n,a,l)},N.surfaceDerivativesGivenNM=function(r,n,a,l,c,d){var p=a.degreeU,_=a.degreeV,v=a.controlPoints,w=a.knotsU,P=a.knotsV;if(!N.areValidRelations(p,v.length,w.length)||!N.areValidRelations(_,v[0].length,P.length))throw new Q("Invalid relations between control points, knot vector, and n");var A=v[0][0].length,I;d<p?I=d:I=p;var k;d<_?k=d:k=_;for(var T=m.zeros3d(d+1,d+1,A),L=N.knotSpanGivenN(r,p,l,w),C=N.knotSpanGivenN(n,_,c,P),R=N.derivativeBasisFunctionsGivenNI(L,l,p,r,w),O=N.derivativeBasisFunctionsGivenNI(C,c,_,n,P),F=m.zeros2d(_+1,A),V=0,q=0,J=I+1;q<J;){for(var H=q++,j=0,K=_+1;j<K;){var ee=j++;F[ee]=m.zeros1d(A);for(var te=0,ie=p+1;te<ie;){var he=te++;m.addMulMutate(F[ee],R[H][he],v[L-p+he][C-_+ee])}}var ae=d-H;ae<k?V=ae:V=k;for(var ue=0,ne=V+1;ue<ne;){var de=ue++;T[H][de]=m.zeros1d(A);for(var X=0,pe=_+1;X<pe;){var Pe=X++;m.addMulMutate(T[H][de],O[de][Pe],F[Pe])}}}return T},N.surfacePoint=function(r,n,a){var l=r.knotsU.length-r.degreeU-2,c=r.knotsV.length-r.degreeV-2;return N.surfacePointGivenNM(l,c,r,n,a)},N.surfacePointGivenNM=function(r,n,a,l,c){var d=a.degreeU,p=a.degreeV,_=a.controlPoints,v=a.knotsU,w=a.knotsV;if(!N.areValidRelations(d,_.length,v.length)||!N.areValidRelations(p,_[0].length,w.length))throw new Q("Invalid relations between control points, knot vector, and n");for(var P=_[0][0].length,A=N.knotSpanGivenN(r,d,l,v),I=N.knotSpanGivenN(n,p,c,w),k=N.basisFunctionsGivenKnotSpanIndex(A,l,d,v),T=N.basisFunctionsGivenKnotSpanIndex(I,c,p,w),L=A-d,C=I,R=m.zeros1d(P),O=m.zeros1d(P),F=0,V=p+1;F<V;){var q=F++;O=m.zeros1d(P),C=I-p+q;for(var J=0,H=d+1;J<H;){var j=J++;m.addMulMutate(O,k[j],_[L+j][C])}m.addMulMutate(R,T[q],O)}return R},N.curveRegularSamplePoints=function(r,n){for(var a=N.curveDerivatives(r,r.knots[0],r.degree),l=1/n,c=l*l,d=a[0],p=m.mul(l,a[1]),_=m.mul(c*.5,a[2]),v=m.mul(c*l*.5,a[3]),w=m.add(_,_),P=m.add(v,v),A=m.mul(.3333333333333333,v),I=[],k=0,T=n+1;k<T;)k++,I.push(N.dehomogenize(d)),m.addAllMutate([d,p,_,A]),m.addAllMutate([p,w,v]),m.addAllMutate([w,P]),m.addAllMutate([_,v]);return I},N.curveRegularSamplePoints2=function(r,n){for(var a=N.curveDerivatives(r,r.knots[0],r.degree),l=1/n,c=l*l,d=a[0],p=m.mul(l,a[1]),_=m.mul(c*.5,a[2]),v=m.mul(c*l*.5,a[3]),w=m.add(_,_),P=m.add(v,v),A=m.mul(.3333333333333333,v),I=[],k=0,T=n+1;k<T;)k++,I.push(N.dehomogenize(d)),m.addAllMutate([d,p,_,A]),m.addAllMutate([p,w,v]),m.addAllMutate([w,P]),m.addAllMutate([_,v]);return I},N.rationalSurfaceRegularSampleDerivatives=function(r,n,a,l){for(var c=N.surfaceRegularSampleDerivatives(r,n,a,l),d=[],p=n+1,_=a+1,v=l+1,w=0;w<p;){var P=w++,A=[];d.push(A);for(var I=0;I<_;){for(var k=I++,T=c[P][k],L=N.rational2d(T),C=N.weight2d(T),R=[],O=L[0][0].length,F=0;F<v;){var V=F++;R.push([]);for(var q=0,J=v-V;q<J;){for(var H=q++,j=L[V][H],K=1,ee=H+1;K<ee;){var te=K++;m.subMulMutate(j,Re.get(H,te)*C[0][te],R[V][H-te])}for(var ie=1,he=V+1;ie<he;){var ae=ie++;m.subMulMutate(j,Re.get(V,ae)*C[ae][0],R[V-ae][H]);for(var ue=m.zeros1d(O),ne=1,de=H+1;ne<de;){var X=ne++;m.addMulMutate(ue,Re.get(H,X)*C[ae][X],R[V-ae][H-X])}m.subMulMutate(j,Re.get(V,ae),ue)}m.mulMutate(1/C[0][0],j),R[V].push(j)}}A.push(R)}}return d},N.surfaceRegularSampleDerivatives=function(r,n,a,l){var c=r.degreeU,d=r.degreeV,p=r.controlPoints,_=r.knotsU,v=r.knotsV,w=p[0][0].length;($.last(_)-_[0])/n,($.last(v)-v[0])/a;for(var P=N.regularlySpacedDerivativeBasisFunctions(c,_,n),A=P.item0,I=P.item1,k=N.regularlySpacedDerivativeBasisFunctions(d,v,a),T=k.item0,L=k.item1,C=[],R=n+1,O=a+1,F=0;F<R;){var V=F++,q=[];C.push(q);for(var J=0;J<O;){var H=J++;q.push(N.surfaceDerivativesGivenBasesKnotSpans(c,d,p,A[V],T[H],I[V],L[H],w,l))}}return C},N.rationalSurfaceRegularSamplePoints=function(r,n,a){return N.dehomogenize2d(N.surfaceRegularSamplePoints(r,n,a))},N.surfaceRegularSamplePoints=function(r,n,a){var l=r.degreeU,c=r.degreeV,d=r.controlPoints,p=r.knotsU,_=r.knotsV,v=d[0][0].length;($.last(p)-p[0])/n,($.last(_)-_[0])/a;for(var w=N.regularlySpacedBasisFunctions(l,p,n),P=w.item0,A=w.item1,I=N.regularlySpacedBasisFunctions(c,_,a),k=I.item0,T=I.item1,L=[],C=n+1,R=a+1,O=0;O<C;){var F=O++,V=[];L.push(V);for(var q=0;q<R;){var J=q++;V.push(N.surfacePointGivenBasesKnotSpans(l,c,d,P[F],k[J],A[F],T[J],v))}}return L},N.regularlySpacedBasisFunctions=function(r,n,a){for(var l=n.length-r-2,c=($.last(n)-n[0])/a,d=[],p=[],_=n[0],v=N.knotSpanGivenN(l,r,_,n),w=a+1,P=0;P<w;){for(P++;_>=n[v+1];)v++;p.push(v),d.push(N.basisFunctionsGivenKnotSpanIndex(v,_,r,n)),_+=c}return new tt(p,d)},N.regularlySpacedDerivativeBasisFunctions=function(r,n,a){for(var l=n.length-r-2,c=($.last(n)-n[0])/a,d=[],p=[],_=n[0],v=N.knotSpanGivenN(l,r,_,n),w=a+1,P=0;P<w;){for(P++;_>=n[v+1];)v++;p.push(v),d.push(N.derivativeBasisFunctionsGivenNI(v,_,r,l,n)),_+=c}return new tt(p,d)},N.surfacePointGivenBasesKnotSpans=function(r,n,a,l,c,d,p,_){for(var v=m.zeros1d(_),w,P=l-r,A=c-n,I=0,k=n+1;I<k;){var T=I++;w=m.zeros1d(_);for(var L=0,C=r+1;L<C;){var R=L++;m.addMulMutate(w,d[R],a[P+R][A])}A++,m.addMulMutate(v,p[T],w)}return v},N.surfaceDerivativesGivenBasesKnotSpans=function(r,n,a,l,c,d,p,_,v){var w=a[0][0].length,P;v<r?P=v:P=r;var A;v<n?A=v:A=n;for(var I=m.zeros3d(P+1,A+1,w),k=m.zeros2d(n+1,w),T=0,L=0,C=P+1;L<C;){for(var R=L++,O=0,F=n+1;O<F;){var V=O++;k[V]=m.zeros1d(w);for(var q=0,J=r+1;q<J;){var H=q++;m.addMulMutate(k[V],d[R][H],a[l-r+H][c-n+V])}}var j=v-R;j<A?T=j:T=A;for(var K=0,ee=T+1;K<ee;){var te=K++;I[R][te]=m.zeros1d(w);for(var ie=0,he=n+1;ie<he;){var ae=ie++;m.addMulMutate(I[R][te],p[te][ae],k[ae])}}}return I},N.curveDerivatives=function(r,n,a){var l=r.knots.length-r.degree-2;return N.curveDerivativesGivenN(l,r,n,a)},N.curveDerivativesGivenN=function(r,n,a,l){var c=n.degree,d=n.controlPoints,p=n.knots;if(!N.areValidRelations(c,d.length,p.length))throw new Q("Invalid relations between control points, knot vector, and n");var _=d[0].length,v;l<c?v=l:v=c;for(var w=m.zeros2d(l+1,_),P=N.knotSpanGivenN(r,c,a,p),A=N.derivativeBasisFunctionsGivenNI(P,a,c,v,p),I=0,k=v+1;I<k;)for(var T=I++,L=0,C=c+1;L<C;){var R=L++;m.addMulMutate(w[T],A[T][R],d[P-c+R])}return w},N.curvePoint=function(r,n){var a=r.knots.length-r.degree-2;return N.curvePointGivenN(a,r,n)},N.areValidRelations=function(r,n,a){return n+r+1-a==0},N.curvePointGivenN=function(r,n,a){var l=n.degree,c=n.controlPoints,d=n.knots;if(!N.areValidRelations(l,c.length,d.length))throw new Q("Invalid relations between control points, knot Array, and n");for(var p=N.knotSpanGivenN(r,l,a,d),_=N.basisFunctionsGivenKnotSpanIndex(p,a,l,d),v=m.zeros1d(c[0].length),w=0,P=l+1;w<P;){var A=w++;m.addMulMutate(v,_[A],c[p-l+A])}return v},N.volumePoint=function(r,n,a,l){var c=r.knotsU.length-r.degreeU-2,d=r.knotsV.length-r.degreeV-2,p=r.knotsW.length-r.degreeW-2;return N.volumePointGivenNML(r,c,d,p,n,a,l)},N.volumePointGivenNML=function(r,n,a,l,c,d,p){if(!N.areValidRelations(r.degreeU,r.controlPoints.length,r.knotsU.length)||!N.areValidRelations(r.degreeV,r.controlPoints[0].length,r.knotsV.length)||!N.areValidRelations(r.degreeW,r.controlPoints[0][0].length,r.knotsW.length))throw new Q("Invalid relations between control points and knot vector");for(var _=r.controlPoints,v=r.degreeU,w=r.degreeV,P=r.degreeW,A=r.knotsU,I=r.knotsV,k=r.knotsW,T=_[0][0][0].length,L=N.knotSpanGivenN(n,v,c,A),C=N.knotSpanGivenN(a,w,d,I),R=N.knotSpanGivenN(l,P,p,k),O=N.basisFunctionsGivenKnotSpanIndex(L,c,v,A),F=N.basisFunctionsGivenKnotSpanIndex(C,d,w,I),V=N.basisFunctionsGivenKnotSpanIndex(R,p,P,k),q=L-v,J=m.zeros1d(T),H=m.zeros1d(T),j=m.zeros1d(T),K=0,ee=P+1;K<ee;){var te=K++;j=m.zeros1d(T);for(var ie=R-P+te,he=0,ae=w+1;he<ae;){var ue=he++;H=m.zeros1d(T);for(var ne=C-w+ue,de=0,X=v+1;de<X;){var pe=de++;m.addMulMutate(H,O[pe],_[q+pe][ne][ie])}m.addMulMutate(j,F[ue],H)}m.addMulMutate(J,V[te],j)}return J},N.derivativeBasisFunctions=function(r,n,a){var l=N.knotSpan(n,r,a),c=a.length-1,d=c-n-1;return N.derivativeBasisFunctionsGivenNI(l,r,n,d,a)},N.derivativeBasisFunctionsGivenNI=function(r,n,a,l,c){var d=m.zeros2d(a+1,a+1),p=m.zeros1d(a+1),_=m.zeros1d(a+1),v=0,w=0;d[0][0]=1;for(var P=1,A=a+1;P<A;){var I=P++;p[I]=n-c[r+1-I],_[I]=c[r+I]-n,v=0;for(var k=0;k<I;){var T=k++;d[I][T]=_[T+1]+p[I-T],w=d[T][I-1]/d[I][T],d[T][I]=v+_[T+1]*w,v=p[I-T]*w}d[I][I]=v}for(var L=m.zeros2d(l+1,a+1),C=m.zeros2d(2,a+1),R=0,O=1,F=0,V=0,q=0,J=0,H=0,j=0,K=a+1;j<K;){var ee=j++;L[0][ee]=d[ee][a]}for(var te=0,ie=a+1;te<ie;){var he=te++;R=0,O=1,C[0][0]=1;for(var ae=1,ue=l+1;ae<ue;){var ne=ae++;F=0,V=he-ne,q=a-ne,he>=ne&&(C[O][0]=C[R][0]/d[q+1][V],F=C[O][0]*d[V][q]),V>=-1?J=1:J=-V,he-1<=q?H=ne-1:H=a-he;for(var de=J,X=H+1;de<X;){var pe=de++;C[O][pe]=(C[R][pe]-C[R][pe-1])/d[q+1][V+pe],F+=C[O][pe]*d[V+pe][q]}he<=q&&(C[O][ne]=-C[R][ne-1]/d[q+1][he],F+=C[O][ne]*d[he][q]),L[ne][he]=F;var Pe=R;R=O,O=Pe}}for(var Ge=a,Xe=1,Fe=l+1;Xe<Fe;){for(var Ke=Xe++,At=0,Ht=a+1;At<Ht;){var vt=At++;L[Ke][vt]*=Ge}Ge*=a-Ke}return L},N.basisFunctions=function(r,n,a){var l=N.knotSpan(n,r,a);return N.basisFunctionsGivenKnotSpanIndex(l,r,n,a)},N.basisFunctionsGivenKnotSpanIndex=function(r,n,a,l){var c=m.zeros1d(a+1),d=m.zeros1d(a+1),p=m.zeros1d(a+1),_=0,v=0;c[0]=1;for(var w=1,P=a+1;w<P;){var A=w++;d[A]=n-l[r+1-A],p[A]=l[r+A]-n,_=0;for(var I=0;I<A;){var k=I++;v=c[k]/(p[k+1]+d[A-k]),c[k]=_+p[k+1]*v,_=d[A-k]*v}c[A]=_}return c},N.knotSpan=function(r,n,a){return N.knotSpanGivenN(a.length-r-2,r,n,a)},N.knotSpanGivenN=function(r,n,a,l){if(a>l[r+1]-re.EPSILON)return r;if(a<l[n]+re.EPSILON)return n;for(var c=n,d=r+1,p=Math.floor((c+d)/2);a<l[p]||a>=l[p+1];)a<l[p]?d=p:c=p,p=Math.floor((c+d)/2);return p},N.dehomogenize=function(r){for(var n=r.length,a=[],l=r[n-1],c=r.length-1,d=0;d<c;){var p=d++;a.push(r[p]/l)}return a},N.rational1d=function(r){var n=r[0].length-1;return r.map(function(a){return a.slice(0,n)})},N.rational2d=function(r){return r.map(N.rational1d)},N.weight1d=function(r){var n=r[0].length-1;return r.map(function(a){return a[n]})},N.weight2d=function(r){return r.map(N.weight1d)},N.dehomogenize1d=function(r){return r.map(N.dehomogenize)},N.dehomogenize2d=function(r){return r.map(N.dehomogenize1d)},N.homogenize1d=function(r,n){var a=r.length,l=r[0].length,c=[],d=0,p=[],_;n!=null?_=n:_=m.rep(r.length,1);for(var v=0;v<a;){var w=v++,P=[];p=r[w],d=_[w];for(var A=0;A<l;){var I=A++;P.push(p[I]*d)}P.push(d),c.push(P)}return c},N.homogenize2d=function(r,n){var a=r.length,l=[],c;if(n!=null)c=n;else{for(var d=[],p=0;p<a;)p++,d.push(m.rep(r[0].length,1));c=d}for(var _=0;_<a;){var v=_++;l.push(N.homogenize1d(r[v],c[v]))}return l};var le=f.eval.Intersect=function(){};x["verb.eval.Intersect"]=le,le.__name__=["verb","eval","Intersect"],le.surfaces=function(r,n,a){var l=Oe.rationalSurfaceAdaptive(r),c=Oe.rationalSurfaceAdaptive(n),d=le.meshes(l,c),p=d.map(function(_){return _.map(function(v){return le.surfacesAtPointWithEstimate(r,n,v.uv0,v.uv1,a)})});return p.map(function(_){return me.rationalInterpCurve(_.map(function(v){return v.point}),3)})},le.surfacesAtPointWithEstimate=function(r,n,a,l,c){var d,p,_,v,w,P,A,I,k,T,L,C,R,O=5,F=0;do{if(d=N.rationalSurfaceDerivatives(r,a[0],a[1],1),p=d[0][0],v=d[1][0],w=d[0][1],_=m.normalized(m.cross(v,w)),P=m.dot(_,p),A=N.rationalSurfaceDerivatives(n,l[0],l[1],1),I=A[0][0],T=A[1][0],L=A[0][1],k=m.normalized(m.cross(T,L)),C=m.dot(k,I),R=m.distSquared(p,I),R<c*c)break;var V=m.normalized(m.cross(_,k)),q=m.dot(V,p),J=le.threePlanes(_,P,k,C,V,q);if(J==null)throw new Q("panic!");var H=m.sub(J,p),j=m.sub(J,I),K=m.cross(v,_),ee=m.cross(w,_),te=m.cross(T,k),ie=m.cross(L,k),he=m.dot(ee,H)/m.dot(ee,v),ae=m.dot(K,H)/m.dot(K,w),ue=m.dot(ie,j)/m.dot(ie,T),ne=m.dot(te,j)/m.dot(te,L);a=m.add([he,ae],a),l=m.add([ue,ne],l),F++}while(F<O);return new Yn(a,l,p,R)},le.meshes=function(r,n,a,l){a==null&&(a=new ir(r)),l==null&&(l=new ir(n));var c=le.boundingBoxTrees(a,l,0),d=$.unique(c.map(function(p){return le.triangles(r,p.item0,n,p.item1)}).filter(function(p){return p!=null}).filter(function(p){return m.distSquared(p.min.point,p.max.point)>re.EPSILON}),function(p,_){var v=m.sub(p.min.uv0,_.min.uv0),w=m.dot(v,v),P=m.sub(p.max.uv0,_.max.uv0),A=m.dot(P,P),I=m.sub(p.min.uv0,_.max.uv0),k=m.dot(I,I),T=m.sub(p.max.uv0,_.min.uv0),L=m.dot(T,T);return w<re.EPSILON&&A<re.EPSILON||k<re.EPSILON&&L<re.EPSILON});return le.makeMeshIntersectionPolylines(d)},le.meshSlices=function(r,n,a,l){for(var c=new Lr(r),d=c.boundingBox(),p=d.min[0],_=d.min[1],v=d.max[0],w=d.max[1],P=m.span(n,a,l),A=[],I=0;I<P.length;){var k=P[I];++I;var T=[[p,_,k],[v,_,k],[v,w,k],[p,w,k]],L=[[0,0],[1,0],[1,1],[0,1]],C=[[0,1,2],[0,2,3]],R=new qt(C,T,null,L);A.push(le.meshes(r,R,c))}return A},le.makeMeshIntersectionPolylines=function(r){if(r.length==0)return[];for(var n=0;n<r.length;){var a=r[n];++n,a.max.opp=a.min,a.min.opp=a.max}for(var l=le.kdTreeFromSegments(r),c=[],d=0;d<r.length;){var p=r[d];++d,c.push(p.min),c.push(p.max)}for(var _=0;_<c.length;){var v=c[_];if(++_,v.adj==null){var w=le.lookupAdjacentSegment(v,l,r.length);w!=null&&w.adj==null&&(v.adj=w,w.adj=v)}}var P=c.filter(function(O){return O.adj==null});P.length==0&&(P=c);for(var A=[],I=0,k=!1;P.length!=0;){var T=P.pop();if(!T.visited){for(var L=[],C=T;C!=null&&!(C.visited||(C.visited=!0,C.opp.visited=!0,L.push(C),I+=2,C=C.opp.adj,C==T)););L.length>0&&(L.push(L[L.length-1].opp),A.push(L))}if(P.length==0&&c.length>0&&(k||I<c.length)){k=!0;var R=c.pop();P.push(R)}}return A},le.kdTreeFromSegments=function(r){for(var n=[],a=0;a<r.length;){var l=r[a];++a,n.push(new An(l.min.point,l.min)),n.push(new An(l.max.point,l.max))}return new Kn(n,m.distSquared)},le.lookupAdjacentSegment=function(r,n,a){var l=n.nearest(r.point,a,re.EPSILON).filter(function(c){return r!=c.item0.obj}).map(function(c){return c.item0.obj});return l.length==1?l[0]:null},le.curveAndSurface=function(r,n,a,l,c){a==null&&(a=.001),l!=null?l=l:l=new sr(r),c!=null?c=c:c=new Cr(n);var d=le.boundingBoxTrees(l,c,a);return $.unique(d.map(function(p){var _=p.item0,v=p.item1,w=$.first(_.knots),P=$.last(_.knots),A=(w+P)/2,I=$.first(v.knotsU),k=$.last(v.knotsU),T=$.first(v.knotsV),L=$.last(v.knotsV),C=[(I+k)/2,(T+L)/2];return le.curveAndSurfaceWithEstimate(_,v,[A].concat(C),a)}).filter(function(p){return m.distSquared(p.curvePoint,p.surfacePoint)<a*a}),function(p,_){return Math.abs(p.u-_.u)<.5*a})},le.curveAndSurfaceWithEstimate=function(r,n,a,l){l==null&&(l=.001);var c=function(v){var w=N.rationalCurvePoint(r,v[0]),P=N.rationalSurfacePoint(n,v[1],v[2]),A=m.sub(w,P);return m.dot(A,A)},d=function(v){var w=N.rationalCurveDerivatives(r,v[0],1),P=N.rationalSurfaceDerivatives(n,v[1],v[2],1),A=m.sub(P[0][0],w[0]),I=m.mul(-1,w[1]),k=P[1][0],T=P[0][1];return[2*m.dot(I,A),2*m.dot(k,A),2*m.dot(T,A)]},p=Yt.uncmin(c,a,l*l,d),_=p.solution;return new Hn(_[0],[_[1],_[2]],N.rationalCurvePoint(r,_[0]),N.rationalSurfacePoint(n,_[1],_[2]))},le.polylineAndMesh=function(r,n,a){for(var l=le.boundingBoxTrees(new ar(r),new ir(n),a),c=[],d=0;d<l.length;){var p=l[d];++d;var _=p.item0,v=p.item1,w=le.segmentWithTriangle(r.points[_],r.points[_+1],n.points,n.faces[v]);if(w!=null){var P=w.point,A=m.lerp(w.p,[r.params[_]],[r.params[_+1]])[0],I=rt.triangleUVFromPoint(n,v,P);c.push(new qn(P,A,I,_,v))}}return c},le.boundingBoxTrees=function(r,n,a){a==null&&(a=1e-9);var l=[],c=[];l.push(r),c.push(n);for(var d=[];l.length>0;){var p=l.pop(),_=c.pop();if(!(p.empty()||_.empty())&&p.boundingBox().intersects(_.boundingBox(),a)){var v=p.indivisible(a),w=_.indivisible(a);if(v&&w){d.push(new tt(p.yield(),_.yield()));continue}else if(v&&!w){var P=_.split();l.push(p),c.push(P.item1),l.push(p),c.push(P.item0);continue}else if(!v&&w){var A=p.split();l.push(A.item1),c.push(_),l.push(A.item0),c.push(_);continue}var I=p.split(),k=_.split();l.push(I.item1),c.push(k.item1),l.push(I.item1),c.push(k.item0),l.push(I.item0),c.push(k.item1),l.push(I.item0),c.push(k.item0)}}return d},le.curves=function(r,n,a){var l=le.boundingBoxTrees(new sr(r),new sr(n),0);return $.unique(l.map(function(c){return le.curvesWithEstimate(r,n,$.first(c.item0.knots),$.first(c.item1.knots),a)}).filter(function(c){return m.distSquared(c.point0,c.point1)<a}),function(c,d){return Math.abs(c.u0-d.u0)<a*5})},le.curvesWithEstimate=function(r,n,a,l,c){var d=function(I){var k=N.rationalCurvePoint(r,I[0]),T=N.rationalCurvePoint(n,I[1]),L=m.sub(k,T);return m.dot(L,L)},p=function(I){var k=N.rationalCurveDerivatives(r,I[0],1),T=N.rationalCurveDerivatives(n,I[1],1),L=m.sub(k[0],T[0]),C=k[1],R=m.mul(-1,T[1]);return[2*m.dot(C,L),2*m.dot(R,L)]},_=Yt.uncmin(d,[a,l],c*c,p),v=_.solution[0],w=_.solution[1],P=N.rationalCurvePoint(r,v),A=N.rationalCurvePoint(n,w);return new Kr(P,A,v,w)},le.triangles=function(r,n,a,l){var c=r.faces[n],d=a.faces[l],p=rt.getTriangleNorm(r.points,c),_=rt.getTriangleNorm(a.points,d),v=r.points[c[0]],w=a.points[d[0]],P=le.planes(v,p,w,_);if(P==null)return null;var A=le.clipRayInCoplanarTriangle(P,r,n);if(A==null)return null;var I=le.clipRayInCoplanarTriangle(P,a,l);if(I==null)return null;var k=le.mergeTriangleClipIntervals(A,I,r,n,a,l);return k==null?null:new wt(new Nr(k.min.uv0,k.min.uv1,k.min.point,n,l),new Nr(k.max.uv0,k.max.uv1,k.max.point,n,l))},le.clipRayInCoplanarTriangle=function(r,n,a){for(var l=n.faces[a],c=[n.points[l[0]],n.points[l[1]],n.points[l[2]]],d=[n.uvs[l[0]],n.uvs[l[1]],n.uvs[l[2]]],p=[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 k=I++,T=c[k],L=v[k],C=le.rays(T,L,r.origin,r.dir);if(C!=null){var R=C.u0,O=C.u1;R<-re.EPSILON||R>w[k]+re.EPSILON||((P==null||O<P.u)&&(P=new wn(O,m.onRay(r.origin,r.dir,O),m.onRay(d[k],p[k],R/w[k]))),(A==null||O>A.u)&&(A=new wn(O,m.onRay(r.origin,r.dir,O),m.onRay(d[k],p[k],R/w[k]))))}}return A==null||P==null?null:new wt(P,A)},le.mergeTriangleClipIntervals=function(r,n,a,l,c,d){if(n.min.u>r.max.u+re.EPSILON||r.min.u>n.max.u+re.EPSILON)return null;var p;r.min.u>n.min.u?p=new tt(r.min,0):p=new tt(n.min,1);var _;r.max.u<n.max.u?_=new tt(r.max,0):_=new tt(n.max,1);var v=new wt(new Nr(null,null,p.item0.point,l,d),new Nr(null,null,_.item0.point,l,d));return p.item1==0?(v.min.uv0=p.item0.uv,v.min.uv1=rt.triangleUVFromPoint(c,d,p.item0.point)):(v.min.uv0=rt.triangleUVFromPoint(a,l,p.item0.point),v.min.uv1=p.item0.uv),_.item1==0?(v.max.uv0=_.item0.uv,v.max.uv1=rt.triangleUVFromPoint(c,d,_.item0.point)):(v.max.uv0=rt.triangleUVFromPoint(a,l,_.item0.point),v.max.uv1=_.item0.uv),v},le.planes=function(r,n,a,l){var c=m.cross(n,l);if(m.dot(c,c)<re.EPSILON)return null;var d=0,p=Math.abs(c[0]),_=Math.abs(c[1]),v=Math.abs(c[2]);_>p&&(d=1,p=_),v>p&&(d=2,p=v);var w,P,A,I;d==0?(w=n[1],P=n[2],A=l[1],I=l[2]):d==1?(w=n[0],P=n[2],A=l[0],I=l[2]):(w=n[0],P=n[1],A=l[0],I=l[1]);var k=-m.dot(r,n),T=-m.dot(a,l),L=w*I-P*A,C=(P*T-k*I)/L,R=(k*A-w*T)/L,O;return d==0?O=[0,C,R]:d==1?O=[C,0,R]:O=[C,R,0],new xn(O,m.normalized(c))},le.threePlanes=function(r,n,a,l,c,d){var p=m.cross(a,c),_=m.dot(r,p);if(Math.abs(_)<re.EPSILON)return null;var v=m.sub(m.mul(d,a),m.mul(l,c)),w=m.add(m.mul(n,p),m.cross(r,v));return m.mul(1/_,w)},le.polylines=function(r,n,a){for(var l=le.boundingBoxTrees(new ar(r),new ar(n),a),c=[],d=0;d<l.length;){var p=l[d];++d;var _=p.item0,v=p.item1,w=le.segments(r.points[_],r.points[_+1],n.points[v],n.points[v+1],a);w!=null&&(w.u0=m.lerp(w.u0,[r.params[_]],[r.params[_+1]])[0],w.u1=m.lerp(w.u1,[n.params[v]],[n.params[v+1]])[0],c.push(w))}return c},le.segments=function(r,n,a,l,c){var d=m.sub(n,r),p=Math.sqrt(m.dot(d,d)),_=m.mul(1/p,d),v=m.sub(l,a),w=Math.sqrt(m.dot(v,v)),P=m.mul(1/w,v),A=le.rays(r,_,a,P);if(A!=null){var I=Math.min(Math.max(0,A.u0/p),1),k=Math.min(Math.max(0,A.u1/w),1),T=m.onRay(r,d,I),L=m.onRay(a,v,k),C=m.distSquared(T,L);if(C<c*c)return new Kr(T,L,I,k)}return null},le.rays=function(r,n,a,l){var c=m.dot(n,l),d=m.dot(n,a),p=m.dot(n,r),_=m.dot(l,a),v=m.dot(l,r),w=m.dot(n,n),P=m.dot(l,l),A=w*P-c*c;if(Math.abs(A)<re.EPSILON)return null;var I=c*(d-p)-w*(_-v),k=I/A,T=(d-p+k*c)/w,L=m.onRay(r,n,T),C=m.onRay(a,l,k);return new Kr(L,C,T,k)},le.segmentWithTriangle=function(r,n,a,l){var c=a[l[0]],d=a[l[1]],p=a[l[2]],_=m.sub(d,c),v=m.sub(p,c),w=m.cross(_,v),P=m.sub(n,r),A=m.sub(r,c),I=-m.dot(w,A),k=m.dot(w,P);if(Math.abs(k)<re.EPSILON)return null;var T=I/k;if(T<0||T>1)return null;var L=m.add(r,m.mul(T,P)),C=m.dot(_,v),R=m.dot(_,_),O=m.dot(v,v),F=m.sub(L,c),V=m.dot(F,_),q=m.dot(F,v),J=C*C-R*O;if(Math.abs(J)<re.EPSILON)return null;var H=(C*q-O*V)/J,j=(C*V-R*q)/J;return H>1+re.EPSILON||j>1+re.EPSILON||j<-re.EPSILON||H<-re.EPSILON||H+j>1+re.EPSILON?null:new Xn(L,H,j,T)},le.segmentAndPlane=function(r,n,a,l){var c=m.dot(l,m.sub(n,r));if(Math.abs(c)<re.EPSILON)return null;var d=m.dot(l,m.sub(a,r)),p=d/c;return p>1+re.EPSILON||p<-re.EPSILON?null:{p}};var me=f.eval.Make=function(){};x["verb.eval.Make"]=me,me.__name__=["verb","eval","Make"],me.rationalTranslationalSurface=function(r,n){for(var a=N.rationalCurvePoint(n,$.first(n.knots)),l=$.first(n.knots),c=$.last(n.knots),d=2*n.controlPoints.length,p=(c-l)/(d-1),_=[],v=0;v<d;){var w=v++,P=m.sub(N.rationalCurvePoint(n,l+w*p),a),A=fe.rationalCurveTransform(r,[[1,0,0,P[0]],[0,1,0,P[1]],[0,0,1,P[2]],[0,0,0,1]]);_.push(A)}return me.loftedSurface(_)},me.surfaceBoundaryCurves=function(r){var n=me.surfaceIsocurve(r,$.first(r.knotsU),!1),a=me.surfaceIsocurve(r,$.last(r.knotsU),!1),l=me.surfaceIsocurve(r,$.first(r.knotsV),!0),c=me.surfaceIsocurve(r,$.last(r.knotsV),!0);return[n,a,l,c]},me.surfaceIsocurve=function(r,n,a){a==null&&(a=!1);var l;a?l=r.knotsV:l=r.knotsU;var c;a?c=r.degreeV:c=r.degreeU;for(var d=ve.knotMultiplicities(l),p=-1,_=0,v=d.length;_<v;){var w=_++;if(Math.abs(n-d[w].knot)<re.EPSILON){p=w;break}}var P=c+1;p>=0&&(P=P-d[p].mult);var A;P>0?A=fe.surfaceKnotRefine(r,m.rep(P,n),a):A=r;var I=N.knotSpan(c,n,l);return Math.abs(n-$.first(l))<re.EPSILON?I=0:Math.abs(n-$.last(l))<re.EPSILON&&(I=(a?A.controlPoints[0].length:A.controlPoints.length)-1),a?new je(A.degreeU,A.knotsU,function(k){for(var T,L=[],C=0,R=A.controlPoints;C<R.length;){var O=R[C];++C,L.push(O[I])}return T=L,T}()):new je(A.degreeV,A.knotsV,A.controlPoints[I])},me.loftedSurface=function(r,n){r=fe.unifyCurveKnotVectors(r);var a=r[0].degree;n==null&&(n=3),n>r.length-1&&(n=r.length-1);for(var l=r[0].knots,c=[],d=[],p=0,_=r[0].controlPoints.length;p<_;){var v=[p++],w=r.map(function(A){return function(I){return I.controlPoints[A[0]]}}(v)),P=me.rationalInterpCurve(w,n,!0);d.push(P.controlPoints),c=P.knots}return new et(a,n,l,c,d)},me.clonedCurve=function(r){return new je(r.degree,r.knots.slice(),r.controlPoints.map(function(n){return n.slice()}))},me.rationalBezierCurve=function(r,n){for(var a=r.length-1,l=[],c=0,d=a+1;c<d;)c++,l.push(0);for(var p=0,_=a+1;p<_;)p++,l.push(1);return n==null&&(n=m.rep(r.length,1)),new je(a,l,N.homogenize1d(r,n))},me.fourPointSurface=function(r,n,a,l,c){c==null&&(c=3);for(var d=c,p=[],_=0,v=c+1;_<v;){for(var w=_++,P=[],A=0,I=c+1;A<I;){var k=A++,T=1-w/d,L=m.lerp(T,r,n),C=m.lerp(T,l,a),R=m.lerp(1-k/d,L,C);R.push(1),P.push(R)}p.push(P)}var O=m.rep(c+1,0),F=m.rep(c+1,1);return new et(c,c,O.concat(F),O.concat(F),p)},me.ellipseArc=function(r,n,a,l,c){var d=m.norm(n),p=m.norm(a);n=m.normalized(n),a=m.normalized(a),c<l&&(c=2*Math.PI+l);var _=c-l,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(r,m.add(m.mul(d*Math.cos(l),n),m.mul(p*Math.sin(l),a))),I=m.sub(m.mul(Math.cos(l),a),m.mul(Math.sin(l),n)),k=[],T=m.zeros1d(2*v+3),L=0,C=l,R=m.zeros1d(v*2);k[0]=A,R[0]=1;for(var O=1,F=v+1;O<F;){var V=O++;C+=w;var q=m.add(r,m.add(m.mul(d*Math.cos(C),n),m.mul(p*Math.sin(C),a)));R[L+2]=1,k[L+2]=q;var J=m.sub(m.mul(Math.cos(C),a),m.mul(Math.sin(C),n)),H=le.rays(A,m.mul(1/m.norm(I),I),q,m.mul(1/m.norm(J),J)),j=m.add(A,m.mul(H.u0,I));R[L+1]=P,k[L+1]=j,L+=2,V<v&&(A=q,I=J)}for(var K=2*v+1,ee=0;ee<3;){var te=ee++;T[te]=0,T[te+K]=1}switch(v){case 2:T[3]=T[4]=.5;break;case 3:T[3]=T[4]=.3333333333333333,T[5]=T[6]=.6666666666666666;break;case 4:T[3]=T[4]=.25,T[5]=T[6]=.5,T[7]=T[8]=.75;break}return new je(2,T,N.homogenize1d(k,R))},me.arc=function(r,n,a,l,c,d){return me.ellipseArc(r,m.mul(l,m.normalized(n)),m.mul(l,m.normalized(a)),c,d)},me.polyline=function(r){for(var n=[0,0],a=0,l=0,c=r.length-1;l<c;){var d=l++;a+=m.dist(r[d],r[d+1]),n.push(a)}n.push(a),n=m.mul(1/a,n);for(var p,_=[],v=0,w=r.length;v<w;)v++,_.push(1);return p=_,new je(1,n,N.homogenize1d(r.slice(0),p))},me.extrudedSurface=function(r,n,a){for(var l=[[],[],[]],c=[[],[],[]],d=N.dehomogenize1d(a.controlPoints),p=N.weight1d(a.controlPoints),_=m.mul(n,r),v=m.mul(.5*n,r),w=0,P=d.length;w<P;){var A=w++;l[2][A]=d[A],l[1][A]=m.add(v,d[A]),l[0][A]=m.add(_,d[A]),c[0][A]=p[A],c[1][A]=p[A],c[2][A]=p[A]}return new et(2,a.degree,[0,0,0,1,1,1],a.knots,N.homogenize2d(l,c))},me.cylindricalSurface=function(r,n,a,l,c){var d=m.cross(r,n),p=me.arc(a,n,d,c,0,2*Math.PI);return me.extrudedSurface(r,l,p)},me.revolvedSurface=function(r,n,a,l){var c=N.dehomogenize1d(r.controlPoints),d=N.weight1d(r.controlPoints),p,_;l<=Math.PI/2?(p=1,_=m.zeros1d(6+2*(p-1))):l<=Math.PI?(p=2,_=m.zeros1d(6+2*(p-1)),_[3]=_[4]=.5):l<=3*Math.PI/2?(p=3,_=m.zeros1d(6+2*(p-1)),_[3]=_[4]=.3333333333333333,_[5]=_[6]=.6666666666666666):(p=4,_=m.zeros1d(6+2*(p-1)),_[3]=_[4]=.25,_[5]=_[6]=.5,_[7]=_[8]=.75);for(var v=l/p,w=3+2*(p-1),P=0;P<3;){var A=P++;_[A]=0,_[w+A]=1}for(var I=Math.cos(v/2),k=0,T=m.zeros1d(p+1),L=m.zeros1d(p+1),C=m.zeros3d(2*p+1,c.length,3),R=m.zeros2d(2*p+1,c.length),O=1,F=p+1;O<F;){var V=O++;k+=v,L[V]=Math.cos(k),T[V]=Math.sin(k)}for(var q=0,J=c.length;q<J;){var H=q++,j=kt.rayClosestPoint(c[H],n,a),K=m.sub(c[H],j),ee=m.norm(K),te=m.cross(a,K);ee>re.EPSILON&&(K=m.mul(1/ee,K),te=m.mul(1/ee,te)),C[0][H]=c[H];var ie=c[H];R[0][H]=d[H];for(var he=te,ae=0,ue=1,ne=p+1;ue<ne;){var de=ue++,X;ee==0?X=j:X=m.add(j,m.add(m.mul(ee*L[de],K),m.mul(ee*T[de],te))),C[ae+2][H]=X,R[ae+2][H]=d[H];var pe=m.sub(m.mul(L[de],te),m.mul(T[de],K));if(ee==0)C[ae+1][H]=j;else{var Pe=le.rays(ie,m.mul(1/m.norm(he),he),X,m.mul(1/m.norm(pe),pe)),Ge=m.add(ie,m.mul(Pe.u0,he));C[ae+1][H]=Ge}R[ae+1][H]=I*d[H],ae+=2,de<p&&(ie=X,he=pe)}}return new et(2,r.degree,_,r.knots,N.homogenize2d(C,R))},me.sphericalSurface=function(r,n,a,l){var c=me.arc(r,m.mul(-1,n),a,l,0,Math.PI);return me.revolvedSurface(c,r,n,2*Math.PI)},me.conicalSurface=function(r,n,a,l,c){var d=2*Math.PI,p=1,_=[m.add(a,m.mul(l,r)),m.add(a,m.mul(c,n))],v=[0,0,1,1],w=[1,1],P=new je(p,v,N.homogenize1d(_,w));return me.revolvedSurface(P,a,r,d)},me.rationalInterpCurve=function(r,n,a,l,c){if(a==null&&(a=!1),n==null&&(n=3),r.length<n+1)throw new Q("You need to supply at least degree + 1 points! You only supplied "+r.length+" points.");for(var d=[0],p=1,_=r.length;p<_;){var v=p++,w=m.norm(m.sub(r[v],r[v-1])),P=d[d.length-1];d.push(P+w)}for(var A=d[d.length-1],I=0,k=d.length;I<k;){var T=I++;d[T]=d[T]/A}var L=m.rep(n+1,0),C=l!=null&&c!=null,R;C?R=0:R=1;var O;C?O=d.length-n+1:O=d.length-n;for(var F=R;F<O;){for(var V=F++,q=0,J=0;J<n;){var H=J++;q+=d[V+H]}L.push(1/n*q)}var j=L.concat(m.rep(n+1,1)),K=[],ee;C?ee=r.length+1:ee=r.length-1;var te;C?te=r.length-(n-1):te=r.length-(n+1);for(var ie=0;ie<d.length;){var he=d[ie];++ie;var ae=N.knotSpanGivenN(ee,n,he,j),ue=N.basisFunctionsGivenKnotSpanIndex(ae,he,n,j),ne=ae-n,de=m.zeros1d(ne),X=m.zeros1d(te-ne);K.push(de.concat(ue).concat(X))}if(C){var pe=K[0].length-2,Pe=[-1,1].concat(m.zeros1d(pe)),Ge=m.zeros1d(pe).concat([-1,1]);$.spliceAndInsert(K,1,0,Pe),$.spliceAndInsert(K,K.length-1,0,Ge)}for(var Xe=r[0].length,Fe=[],Ke=(1-j[j.length-n-2])/n,At=j[n+1]/n,Ht=0;Ht<Xe;){var vt=[Ht++],gt;if(!C)gt=r.map(function(Qt){return function(dr){return dr[Qt[0]]}}(vt));else{gt=[r[0][vt[0]]],gt.push(At*l[vt[0]]);for(var St=1,Tt=r.length-1;St<Tt;){var Kt=St++;gt.push(r[Kt][vt[0]])}gt.push(Ke*c[vt[0]]),gt.push($.last(r)[vt[0]])}var or=Ce.solve(K,gt);Fe.push(or)}var $t=Ce.transpose(Fe);if(!a){var Zt=m.rep($t.length,1);$t=N.homogenize1d($t,Zt)}return new je(n,j,$t)};var fe=f.eval.Modify=function(){};x["verb.eval.Modify"]=fe,fe.__name__=["verb","eval","Modify"],fe.curveReverse=function(r){return new je(r.degree,fe.knotsReverse(r.knots),$.reversed(r.controlPoints))},fe.surfaceReverse=function(r,n){return n==null&&(n=!1),n?new et(r.degreeU,r.degreeV,r.knotsU,fe.knotsReverse(r.knotsV),function(a){for(var l,c=[],d=0,p=r.controlPoints;d<p.length;){var _=p[d];++d,c.push($.reversed(_))}return l=c,l}()):new et(r.degreeU,r.degreeV,fe.knotsReverse(r.knotsU),r.knotsV,$.reversed(r.controlPoints))},fe.knotsReverse=function(r){var n=$.first(r);$.last(r);for(var a=[n],l=r.length,c=1;c<l;){var d=c++;a.push(a[d-1]+(r[l-d]-r[l-d-1]))}return a},fe.unifyCurveKnotVectors=function(r){r=r.map(me.clonedCurve);for(var n=D.fold(r,function(j,K){return fe.imax(j.degree,K)},0),a=0,l=r.length;a<l;){var c=a++;r[c].degree<n&&(r[c]=fe.curveElevateDegree(r[c],n))}for(var d,p=[],_=0;_<r.length;){var v=r[_];++_,p.push(new wt($.first(v.knots),$.last(v.knots)))}d=p;for(var w=0,P=r.length;w<P;){var A=w++,I=[d[A].min];r[A].knots=r[A].knots.map(function(j){return function(K){return K-j[0]}}(I))}for(var k=d.map(function(j){return j.max-j.min}),T=D.fold(k,function(j,K){return Math.max(j,K)},0),L=0,C=r.length;L<C;){var R=L++,O=[T/k[R]];r[R].knots=r[R].knots.map(function(j){return function(K){return K*j[0]}}(O))}for(var F=D.fold(r,function(j,K){return m.sortedSetUnion(j.knots,K)},[]),V=0,q=r.length;V<q;){var J=V++,H=m.sortedSetSub(F,r[J].knots);H.length==0&&(r[J]=r[J]),r[J]=fe.curveKnotRefine(r[J],H)}return r},fe.imin=function(r,n){return r<n?r:n},fe.imax=function(r,n){return r>n?r:n},fe.curveElevateDegree=function(r,n){if(n<=r.degree)return r;var a=r.knots.length-r.degree-2,l=r.degree,c=r.knots,d=r.controlPoints,p=n-r.degree,_=r.controlPoints[0].length,v=m.zeros2d(l+p+1,l+1),w=[],P=[],A=[],I=a+l+1,k=n,T=Math.floor(k/2),L=[],C=[];v[0][0]=1,v[k][l]=1;for(var R=1,O=T+1;R<O;)for(var F=R++,V=1/Re.get(k,F),q=fe.imin(l,F),J=fe.imax(0,F-p),H=q+1;J<H;){var j=J++;v[F][j]=V*Re.get(l,j)*Re.get(p,F-j)}for(var K=T+1;K<k;)for(var ee=K++,te=fe.imin(l,ee),ie=fe.imax(0,ee-p),he=te+1;ie<he;){var ae=ie++;v[ee][ae]=v[k-ee][l-ae]}var ue=k+1,ne=-1,de=l,X=l+1,pe=1,Pe=c[0];L[0]=d[0];for(var Ge=0,Xe=k+1;Ge<Xe;){var Fe=Ge++;C[Fe]=Pe}for(var Ke=0,At=l+1;Ke<At;){var Ht=Ke++;w[Ht]=d[Ht]}for(;X<I;){for(var vt=X;X<I&&c[X]==c[X+1];)X=X+1;var gt=X-vt+1,St=c[X],Tt=ne;ne=l-gt;var Kt;Tt>0?Kt=Math.floor((Tt+2)/2):Kt=1;var or;if(ne>0?or=Math.floor(k-(ne+1)/2):or=k,ne>0){for(var $t=St-Pe,Zt=[],Qt=l;Qt>gt;)Zt[Qt-gt-1]=$t/(c[de+Qt]-Pe),Qt--;for(var dr=1,Tn=ne+1;dr<Tn;){for(var Zr=dr++,Nc=ne-Zr,Gi=gt+Zr,Qr=l;Qr>=Gi;)w[Qr]=m.add(m.mul(Zt[Qr-Gi],w[Qr]),m.mul(1-Zt[Qr-Gi],w[Qr-1])),Qr--;A[Nc]=w[l]}}for(var vo=Kt,Cc=k+1;vo<Cc;){var Nn=vo++;P[Nn]=m.zeros1d(_);for(var Lc=fe.imin(l,Nn),yo=fe.imax(0,Nn-p),Oc=Lc+1;yo<Oc;){var bo=yo++;P[Nn]=m.add(P[Nn],m.mul(v[Nn][bo],w[bo]))}}if(Tt>1)for(var Wi=ue-2,Hi=ue,xo=St-Pe,zc=(St-C[ue-1])/xo,wo=1;wo<Tt;){for(var qi=wo++,mr=Wi,Jr=Hi,Fr=Jr-ue+1;Jr-mr>qi;){if(mr<pe){var Dc=(St-C[mr])/(Pe-C[mr]);L[mr]=m.lerp(Dc,L[mr],L[mr-1])}if(Jr>=Kt){if(Jr-qi<=ue-k+Tt){var Rc=(St-C[Jr-qi])/xo;P[Fr]=m.lerp(Rc,P[Fr],P[Fr+1])}}else P[Fr]=m.lerp(zc,P[Fr],P[Fr+1]);mr=mr+1,Jr=Jr-1,Fr=Fr-1}Wi=Wi-1,Hi=Hi+1}if(de!=l)for(var Ao=0,Bc=k-Tt;Ao<Bc;)Ao++,C[ue]=Pe,ue=ue+1;for(var So=Kt,Fc=or+1;So<Fc;){var Uc=So++;L[pe]=P[Uc],pe=pe+1}if(X<I){for(var Po=0;Po<ne;){var Io=Po++;w[Io]=A[Io]}for(var Eo=ne,Vc=l+1;Eo<Vc;){var ko=Eo++;w[ko]=d[X-l+ko]}de=X,X=X+1,Pe=St}else for(var Mo=0,jc=k+1;Mo<jc;){var Gc=Mo++;C[ue+Gc]=St}}return new je(n,C,L)},fe.rationalSurfaceTransform=function(r,n){for(var a=N.dehomogenize2d(r.controlPoints),l=0,c=a.length;l<c;)for(var d=l++,p=0,_=a[d].length;p<_;){var v=p++,w=a[d][v];w.push(1),a[d][v]=Ce.dot(n,w).slice(0,w.length-1)}return new et(r.degreeU,r.degreeV,r.knotsU.slice(),r.knotsV.slice(),N.homogenize2d(a,N.weight2d(r.controlPoints)))},fe.rationalCurveTransform=function(r,n){for(var a=N.dehomogenize1d(r.controlPoints),l=0,c=a.length;l<c;){var d=l++,p=a[d];p.push(1),a[d]=Ce.dot(n,p).slice(0,p.length-1)}return new je(r.degree,r.knots.slice(),N.homogenize1d(a,N.weight1d(r.controlPoints)))},fe.surfaceKnotRefine=function(r,n,a){var l=[],c,d,p;a?(p=r.controlPoints,c=r.knotsV,d=r.degreeV):(p=Ce.transpose(r.controlPoints),c=r.knotsU,d=r.degreeU);for(var _=null,v=0;v<p.length;){var w=p[v];++v,_=fe.curveKnotRefine(new je(d,c,w),n),l.push(_.controlPoints)}var P=_.knots;return a?new et(r.degreeU,r.degreeV,r.knotsU.slice(),P,l):(l=Ce.transpose(l),new et(r.degreeU,r.degreeV,P,r.knotsV.slice(),l))},fe.decomposeCurveIntoBeziers=function(r){for(var n=r.degree,a=r.controlPoints,l=r.knots,c=ve.knotMultiplicities(l),d=n+1,p=0;p<c.length;){var _=c[p];if(++p,_.mult<d){var v=m.rep(d-_.mult,_.knot),w=fe.curveKnotRefine(new je(n,l,a),v);l=w.knots,a=w.controlPoints}}l.length/d-1;for(var P=d*2,A=[],I=0;I<a.length;){var k=l.slice(I,I+P),T=a.slice(I,I+d);A.push(new je(n,k,T)),I+=d}return A},fe.curveKnotRefine=function(r,n){if(n.length==0)return me.clonedCurve(r);for(var a=r.degree,l=r.controlPoints,c=r.knots,d=l.length-1,p=d+a+1,_=n.length-1,v=N.knotSpan(a,n[0],c),w=N.knotSpan(a,n[_],c),P=[],A=[],I=0,k=v-a+1;I<k;){var T=I++;P[T]=l[T]}for(var L=w-1,C=d+1;L<C;){var R=L++;P[R+_+1]=l[R]}for(var O=0,F=v+1;O<F;){var V=O++;A[V]=c[V]}for(var q=w+a,J=p+1;q<J;){var H=q++;A[H+_+1]=c[H]}for(var j=w+a-1,K=w+a+_,ee=_;ee>=0;){for(;n[ee]<=c[j]&&j>v;)P[K-a-1]=l[j-a-1],A[K]=c[j],K=K-1,j=j-1;P[K-a-1]=P[K-a];for(var te=1,ie=a+1;te<ie;){var he=te++,ae=K-a+he,ue=A[K+he]-n[ee];Math.abs(ue)<re.EPSILON?P[ae-1]=P[ae]:(ue=ue/(A[K+he]-c[j-a+he]),P[ae-1]=m.add(m.mul(ue,P[ae-1]),m.mul(1-ue,P[ae])))}A[K]=n[ee],K=K-1,ee--}return new je(a,A,P)},fe.curveKnotInsert=function(r,n,a){for(var l=r.degree,c=r.controlPoints,d=r.knots,p=0,_=c.length,v=N.knotSpan(l,n,d),w=[],P=[],A=[],I=1,k=v+1;I<k;){var T=I++;P[T]=d[T]}for(var L=1,C=a+1;L<C;){var R=L++;P[v+R]=n}for(var O=v+1,F=d.length;O<F;){var V=O++;P[V+a]=d[V]}for(var q=0,J=v-l+1;q<J;){var H=q++;A[H]=c[H]}for(var j=v-p;j<_;){var K=j++;A[K+a]=c[K]}for(var ee=0,te=l-p+1;ee<te;){var ie=ee++;w[ie]=c[v-l+ie]}for(var he=0,ae=0,ue=1,ne=a+1;ue<ne;){var de=ue++;he=v-l+de;for(var X=0,pe=l-de-p+1;X<pe;){var Pe=X++;ae=(n-d[he+Pe])/(d[Pe+v+1]-d[he+Pe]),w[Pe]=m.add(m.mul(ae,w[Pe+1]),m.mul(1-ae,w[Pe]))}A[he]=w[0],A[v+a-de-p]=w[l-de-p]}for(var Ge=he+1,Xe=v-p;Ge<Xe;){var Fe=Ge++;A[Fe]=w[Fe-he]}return new je(l,P,A)};var Oe=f.eval.Tess=function(){};x["verb.eval.Tess"]=Oe,Oe.__name__=["verb","eval","Tess"],Oe.rationalCurveRegularSample=function(r,n,a){return Oe.rationalCurveRegularSampleRange(r,r.knots[0],$.last(r.knots),n,a)},Oe.rationalCurveRegularSampleRange=function(r,n,a,l,c){l<1&&(l=2);for(var d=[],p=(a-n)/(l-1),_=0,v=0;v<l;){var w=v++;_=n+p*w,c?d.push([_].concat(N.rationalCurvePoint(r,_))):d.push(N.rationalCurvePoint(r,_))}return d},Oe.rationalCurveAdaptiveSample=function(r,n,a){if(a==null&&(a=!1),n==null&&(n=1e-6),r.degree==1)if(a){for(var l=[],c=0,d=r.controlPoints.length;c<d;){var p=c++;l.push([r.knots[p+1]].concat(N.dehomogenize(r.controlPoints[p])))}return l}else return r.controlPoints.map(N.dehomogenize);return Oe.rationalCurveAdaptiveSampleRange(r,r.knots[0],$.last(r.knots),n,a)},Oe.rationalCurveAdaptiveSampleRange=function(r,n,a,l,c){var d=N.rationalCurvePoint(r,n),p=N.rationalCurvePoint(r,a),_=.5+.2*Math.random(),v=n+(a-n)*_,w=N.rationalCurvePoint(r,v),P=m.sub(d,p),A=m.sub(d,w);if(m.dot(P,P)<l&&m.dot(A,A)>l||!kt.threePointsAreFlat(d,w,p,l)){var I=n+(a-n)*.5,k=Oe.rationalCurveAdaptiveSampleRange(r,n,I,l,c),T=Oe.rationalCurveAdaptiveSampleRange(r,I,a,l,c);return k.slice(0,-1).concat(T)}else return c?[[n].concat(d),[a].concat(p)]:[d,p]},Oe.rationalSurfaceNaive=function(r,n,a){n<1&&(n=1),a<1&&(a=1),r.degreeU,r.degreeV,r.controlPoints;for(var l=r.knotsU,c=r.knotsV,d=$.last(l)-l[0],p=$.last(c)-c[0],_=d/n,v=p/a,w=[],P=[],A=[],I=0,k=n+1;I<k;)for(var T=I++,L=0,C=a+1;L<C;){var R=L++,O=T*_,F=R*v;P.push([O,F]);var V=N.rationalSurfaceDerivatives(r,O,F,1),q=V[0][0];w.push(q);var J=m.normalized(m.cross(V[1][0],V[0][1]));A.push(J)}for(var H=[],j=0;j<n;)for(var K=j++,ee=0;ee<a;){var te=ee++,ie=K*(a+1)+te,he=(K+1)*(a+1)+te,ae=he+1,ue=ie+1,ne=[ie,he,ae],de=[ie,ae,ue];H.push(ne),H.push(de)}return new qt(H,w,A,P)},Oe.divideRationalSurfaceAdaptive=function(r,n){n==null&&(n=new Or),n.minDivsU!=null?n.minDivsU=n.minDivsU:n.minDivsU=1,n.minDivsV!=null?n.minDivsU=n.minDivsV:n.minDivsU=1,n.refine!=null?n.refine=n.refine:n.refine=!0;var a=(r.controlPoints.length-1)*2,l=(r.controlPoints[0].length-1)*2,c;n.minDivsU>a?c=n.minDivsU=n.minDivsU:c=n.minDivsU=a;var d;n.minDivsV>l?d=n.minDivsV=n.minDivsV:d=n.minDivsV=l;for(var p=$.last(r.knotsU),_=r.knotsU[0],v=$.last(r.knotsV),w=r.knotsV[0],P=(p-_)/c,A=(v-w)/d,I=[],k=[],T=0,L=d+1;T<L;){for(var C=T++,R=[],O=0,F=c+1;O<F;){var V=O++,q=_+P*V,J=w+A*C,H=N.rationalSurfaceDerivatives(r,q,J,1),j=m.normalized(m.cross(H[0][1],H[1][0]));R.push(new Gt(H[0][0],j,[q,J],-1,m.isZero(j)))}k.push(R)}for(var K=0;K<d;)for(var ee=K++,te=0;te<c;){var ie=te++,he=[k[d-ee-1][ie],k[d-ee-1][ie+1],k[d-ee][ie+1],k[d-ee][ie]];I.push(new ur(r,he))}if(!n.refine)return I;for(var ae=0;ae<d;)for(var ue=ae++,ne=0;ne<c;){var de=ne++,X=ue*c+de,pe=Oe.north(X,ue,de,c,d,I),Pe=Oe.east(X,ue,de,c,d,I),Ge=Oe.south(X,ue,de,c,d,I),Xe=Oe.west(X,ue,de,c,d,I);I[X].neighbors=[Ge,Pe,pe,Xe],I[X].divide(n)}return I},Oe.north=function(r,n,a,l,c,d){return n==0?null:d[r-l]},Oe.south=function(r,n,a,l,c,d){return n==c-1?null:d[r+l]},Oe.east=function(r,n,a,l,c,d){return a==l-1?null:d[r+1]},Oe.west=function(r,n,a,l,c,d){return a==0?null:d[r-1]},Oe.triangulateAdaptiveRefinementNodeTree=function(r){for(var n=qt.empty(),a=0;a<r.length;){var l=r[a];++a,l.triangulate(n)}return n},Oe.rationalSurfaceAdaptive=function(r,n){n!=null?n=n:n=new Or;var a=Oe.divideRationalSurfaceAdaptive(r,n);return Oe.triangulateAdaptiveRefinementNodeTree(a)};var Or=f.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"]=Or,Or.__name__=["verb","eval","AdaptiveRefinementOptions"],Or.prototype={__class__:Or};var ur=f.core.AdaptiveRefinementNode=function(r,n,a){if(this.srf=r,a==null?this.neighbors=[null,null,null,null]:this.neighbors=a,this.corners=n,this.corners==null){var l=r.knotsU[0],c=$.last(r.knotsU),d=r.knotsV[0],p=$.last(r.knotsV);this.corners=[Gt.fromUv(l,d),Gt.fromUv(c,d),Gt.fromUv(c,p),Gt.fromUv(l,p)]}};x["verb.eval.AdaptiveRefinementNode"]=ur,ur.__name__=["verb","eval","AdaptiveRefinementNode"],ur.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 r=0;r<4;){var n=r++;if(this.corners[n].point==null){var a=this.corners[n];this.evalSrf(a.uv[0],a.uv[1],a)}}},evalSrf:function(r,n,a){var l=N.rationalSurfaceDerivatives(this.srf,r,n,1),c=l[0][0],d=m.cross(l[0][1],l[1][0]),p=m.isZero(d);return p||(d=m.normalized(d)),a!=null?(a.degen=p,a.point=c,a.normal=d,a):new Gt(c,d,[r,n],-1,p)},getEdgeCorners:function(r){if(this.isLeaf())return[this.corners[r]];if(this.horizontal)switch(r){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(r){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(r){var n=[this.corners[r]];if(this.neighbors[r]==null)return n;var a=this.neighbors[r].getEdgeCorners((r+2)%4),l=r%2,c=re.EPSILON,d=this,p=[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}],_=a.filter(p[l]);return _.reverse(),n.concat(_)},midpoint:function(r){if(this.midPoints==null&&(this.midPoints=[null,null,null,null]),this.midPoints[r]!=null)return this.midPoints[r];switch(r){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[r]},hasBadNormals:function(){return this.corners[0].degen||this.corners[1].degen||this.corners[2].degen||this.corners[3].degen},fixNormals:function(){for(var r=this.corners.length,n=0;n<r;){var a=n++;if(this.corners[a],this.corners[a].degen){var l=this.corners[(a+1)%r],c=this.corners[(a+3)%r];l.degen?this.corners[a].normal=c.normal:this.corners[a].normal=l.normal}}},shouldDivide:function(r,n){if(n<r.minDepth)return!0;if(n>=r.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))>r.normTol||m.normSquared(m.sub(this.corners[2].normal,this.corners[3].normal))>r.normTol,this.splitHoriz=m.normSquared(m.sub(this.corners[1].normal,this.corners[2].normal))>r.normTol||m.normSquared(m.sub(this.corners[3].normal,this.corners[0].normal))>r.normTol,this.splitVert||this.splitHoriz)return!0;var a=this.center();return m.normSquared(m.sub(a.normal,this.corners[0].normal))>r.normTol||m.normSquared(m.sub(a.normal,this.corners[1].normal))>r.normTol||m.normSquared(m.sub(a.normal,this.corners[2].normal))>r.normTol||m.normSquared(m.sub(a.normal,this.corners[3].normal))>r.normTol},divide:function(r){r==null&&(r=new Or),r.normTol==null&&(r.normTol=.085),r.minDepth==null&&(r.minDepth=0),r.maxDepth==null&&(r.maxDepth=10),this._divide(r,0,!0)},_divide:function(r,n,a){if(this.evalCorners(),!!this.shouldDivide(r,n)){if(n++,this.splitVert&&!this.splitHoriz?a=!1:!this.splitVert&&this.splitHoriz&&(a=!0),this.horizontal=a,this.horizontal){var l=[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 ur(this.srf,l),new ur(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]],p=[this.midpoint(0),this.corners[1],this.corners[2],this.midpoint(2)];this.children=[new ur(this.srf,d),new ur(this.srf,p)],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(r,n,!a)}}},triangulate:function(r){if(r==null&&(r=qt.empty()),this.isLeaf())return this.triangulateLeaf(r);for(var n=0,a=this.children;n<a.length;){var l=a[n];if(++n,l==null)break;l.triangulate(r)}return r},triangulateLeaf:function(r){for(var n=r.points.length,a=[],l=[],c=0,d=0;d<4;){var p=d++,_=this.getAllCorners(p);_.length==2&&(c=p+1);for(var v=0,w=_.length;v<w;){var P=v++;a.push(_[P])}}for(var A=0;A<a.length;){var I=a[A];if(++A,I.id!=-1){l.push(I.id);continue}r.uvs.push(I.uv),r.points.push(I.point),r.normals.push(I.normal),I.id=n,l.push(n),n++}if(a.length==4)return r.faces.push([l[0],l[3],l[1]]),r.faces.push([l[3],l[2],l[1]]),r;if(a.length==5){var k=l.length;return r.faces.push([l[c],l[(c+2)%k],l[(c+1)%k]]),r.faces.push([l[(c+4)%k],l[(c+3)%k],l[c]]),r.faces.push([l[c],l[(c+3)%k],l[(c+2)%k]]),r}var T=this.center();r.uvs.push(T.uv),r.points.push(T.point),r.normals.push(T.normal);for(var L=r.points.length-1,C=0,R=a.length-1;C<a.length;)r.faces.push([L,l[C],l[R]]),R=C++;return r},__class__:ur};var we=f.exe.Dispatcher=function(){};x["verb.exe.Dispatcher"]=we,we.__name__=["verb","exe","Dispatcher"],we.init=function(){we._init||(we._workerPool=new zr(we.THREADS),we._init=!0)},we.dispatchMethod=function(r,n,a){we.init();var l=new yn,c=function(d){l.resolve(d)};return we._workerPool.addWork(ce.getClassName(r),n,a,c),new pt(l)};var zr=f.exe.WorkerPool=function(r,n){n==null&&(n="verb.js"),r==null&&(r=1),this._callbacks=new xe,this._working=new xe,this._pool=[],this._queue=[];for(var a=0;a<r;){a++;var l;try{l=new Worker(zr.basePath+n)}catch(c){c instanceof Q&&(c=c.val),l=new Worker(zr.basePath+n.substring(0,-3)+".min.js")}this._pool.push(l)}};x["verb.exe.WorkerPool"]=zr,zr.__name__=["verb","exe","WorkerPool"],zr.prototype={addWork:function(r,n,a,l){var c=new $r(r,n,a);this._callbacks.set(c.id,l),this._queue.push(c),this.processQueue()},processQueue:function(){for(var r=this;this._queue.length>0&&this._pool.length>0;){var n=this._queue.shift(),a=[n.id],l=[this._pool.shift()];this._working.h[a[0]]=l[0],l[0].onmessage=function(c,d){return function(p){r._working.remove(d[0]),r._pool.push(c[0]);try{r._callbacks.h.hasOwnProperty(d[0])&&(r._callbacks.h[d[0]](p.data.result),r._callbacks.remove(d[0]))}catch(_){_ instanceof Q&&(_=_.val),b.log(_)}r.processQueue()}}(l,a),l[0].postMessage(n)}},__class__:zr};var $r=function(r,n,a){this.className=r,this.methodName=n,this.args=a,this.id=$r.uuid++};x["verb.exe._WorkerPool.Work"]=$r,$r.__name__=["verb","exe","_WorkerPool","Work"],$r.prototype={__class__:$r};var kn=function(){};x["verb.geom.ICurve"]=kn,kn.__name__=["verb","geom","ICurve"],kn.__interfaces__=[Pn],kn.prototype={__class__:kn};var Ne=f.geom.NurbsCurve=function(r){this._data=Wt.isValidNurbsCurveData(r)};x["verb.geom.NurbsCurve"]=Ne,Ne.__name__=["verb","geom","NurbsCurve"],Ne.__interfaces__=[kn],Ne.byKnotsControlPointsWeights=function(r,n,a,l){return new Ne(new je(r,n.slice(),N.homogenize1d(a,l)))},Ne.byPoints=function(r,n){return n==null&&(n=3),new Ne(me.rationalInterpCurve(r,n))},Ne.__super__=Ze,Ne.prototype=M(Ze.prototype,{degree:function(){return this._data.degree},knots:function(){return this._data.knots.slice(0)},controlPoints:function(){return N.dehomogenize1d(this._data.controlPoints)},weights:function(){return N.weight1d(this._data.controlPoints)},asNurbs:function(){return new je(this.degree(),this.knots(),N.homogenize1d(this.controlPoints(),this.weights()))},clone:function(){return new Ne(this._data)},domain:function(){return new wt($.first(this._data.knots),$.last(this._data.knots))},transform:function(r){return new Ne(fe.rationalCurveTransform(this._data,r))},transformAsync:function(r){return we.dispatchMethod(fe,"rationalCurveTransform",[this._data,r]).then(function(n){return new Ne(n)})},point:function(r){return N.rationalCurvePoint(this._data,r)},pointAsync:function(r){return we.dispatchMethod(N,"rationalCurvePoint",[this._data,r])},tangent:function(r){return N.rationalCurveTangent(this._data,r)},tangentAsync:function(r){return we.dispatchMethod(N,"rationalCurveTangent",[this._data,r])},derivatives:function(r,n){return n==null&&(n=1),N.rationalCurveDerivatives(this._data,r,n)},derivativesAsync:function(r,n){return n==null&&(n=1),we.dispatchMethod(N,"rationalCurveDerivatives",[this._data,r,n])},closestPoint:function(r){return ve.rationalCurveClosestPoint(this._data,r)},closestPointAsync:function(r){return we.dispatchMethod(ve,"rationalCurveClosestPoint",[this._data,r])},closestParam:function(r){return ve.rationalCurveClosestParam(this._data,r)},closestParamAsync:function(r){return we.dispatchMethod(ve,"rationalCurveClosestParam",[this._data,r])},length:function(){return ve.rationalCurveArcLength(this._data)},lengthAsync:function(){return we.dispatchMethod(ve,"rationalCurveArcLength",[this._data])},lengthAtParam:function(r){return ve.rationalCurveArcLength(this._data,r)},lengthAtParamAsync:function(){return we.dispatchMethod(ve,"rationalCurveArcLength",[this._data])},paramAtLength:function(r,n){return ve.rationalCurveParamAtArcLength(this._data,r,n)},paramAtLengthAsync:function(r,n){return we.dispatchMethod(ve,"rationalCurveParamAtArcLength",[this._data,r,n])},divideByEqualArcLength:function(r){return lt.rationalCurveByEqualArcLength(this._data,r)},divideByEqualArcLengthAsync:function(r){return we.dispatchMethod(lt,"rationalCurveByEqualArcLength",[this._data,r])},divideByArcLength:function(r){return lt.rationalCurveByArcLength(this._data,r)},divideByArcLengthAsync:function(r){return we.dispatchMethod(lt,"rationalCurveByArcLength",[this._data,r])},split:function(r){return lt.curveSplit(this._data,r).map(function(n){return new Ne(n)})},splitAsync:function(r){return we.dispatchMethod(lt,"curveSplit",[this._data,r]).then(function(n){return n.map(function(a){return new Ne(a)})})},reverse:function(){return new Ne(fe.curveReverse(this._data))},reverseAsync:function(){return we.dispatchMethod(fe,"curveReverse",[this._data]).then(function(r){return new Ne(r)})},tessellate:function(r){return Oe.rationalCurveAdaptiveSample(this._data,r,!1)},tessellateAsync:function(r){return we.dispatchMethod(Oe,"rationalCurveAdaptiveSample",[this._data,r,!1])},__class__:Ne});var Dr=f.geom.Arc=function(r,n,a,l,c,d){Ne.call(this,me.arc(r,n,a,l,c,d)),this._center=r,this._xaxis=n,this._yaxis=a,this._radius=l,this._minAngle=c,this._maxAngle=d};x["verb.geom.Arc"]=Dr,Dr.__name__=["verb","geom","Arc"],Dr.__super__=Ne,Dr.prototype=M(Ne.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__:Dr});var Jn=f.geom.BezierCurve=function(r,n){Ne.call(this,me.rationalBezierCurve(r,n))};x["verb.geom.BezierCurve"]=Jn,Jn.__name__=["verb","geom","BezierCurve"],Jn.__super__=Ne,Jn.prototype=M(Ne.prototype,{__class__:Jn});var es=f.geom.Circle=function(r,n,a,l){Dr.call(this,r,n,a,l,0,Math.PI*2)};x["verb.geom.Circle"]=es,es.__name__=["verb","geom","Circle"],es.__super__=Dr,es.prototype=M(Dr.prototype,{__class__:es});var Mn=function(){};x["verb.geom.ISurface"]=Mn,Mn.__name__=["verb","geom","ISurface"],Mn.__interfaces__=[Pn],Mn.prototype={__class__:Mn};var Ie=f.geom.NurbsSurface=function(r){this._data=Wt.isValidNurbsSurfaceData(r)};x["verb.geom.NurbsSurface"]=Ie,Ie.__name__=["verb","geom","NurbsSurface"],Ie.__interfaces__=[Mn],Ie.byKnotsControlPointsWeights=function(r,n,a,l,c,d){return new Ie(new et(r,n,a,l,N.homogenize2d(c,d)))},Ie.byCorners=function(r,n,a,l){return new Ie(me.fourPointSurface(r,n,a,l))},Ie.byLoftingCurves=function(r,n){return new Ie(me.loftedSurface(function(a){for(var l,c=[],d=0;d<r.length;){var p=r[d];++d,c.push(p.asNurbs())}return l=c,l}(),n))},Ie.__super__=Ze,Ie.prototype=M(Ze.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 N.dehomogenize2d(this._data.controlPoints)},weights:function(){return N.weight2d(this._data.controlPoints)},asNurbs:function(){return new et(this.degreeU(),this.degreeV(),this.knotsU(),this.knotsV(),N.homogenize2d(this.controlPoints(),this.weights()))},clone:function(){return new Ie(this.asNurbs())},domainU:function(){return new wt($.first(this._data.knotsU),$.last(this._data.knotsU))},domainV:function(){return new wt($.first(this._data.knotsV),$.last(this._data.knotsV))},point:function(r,n){return N.rationalSurfacePoint(this._data,r,n)},pointAsync:function(r,n){return we.dispatchMethod(N,"rationalSurfacePoint",[this._data,r,n])},normal:function(r,n){return N.rationalSurfaceNormal(this._data,r,n)},normalAsync:function(r,n){return we.dispatchMethod(N,"rationalSurfaceNormal",[this._data,r,n])},derivatives:function(r,n,a){return a==null&&(a=1),N.rationalSurfaceDerivatives(this._data,r,n,a)},derivativesAsync:function(r,n,a){return a==null&&(a=1),we.dispatchMethod(N,"rationalSurfaceDerivatives",[this._data,r,n,a])},closestParam:function(r){return ve.rationalSurfaceClosestParam(this._data,r)},closestParamAsync:function(r){return we.dispatchMethod(ve,"rationalSurfaceClosestParam",[this._data,r])},closestPoint:function(r){return ve.rationalSurfaceClosestPoint(this._data,r)},closestPointAsync:function(r){return we.dispatchMethod(ve,"rationalSurfaceClosestPoint",[this._data,r])},split:function(r,n){return n==null&&(n=!1),lt.surfaceSplit(this._data,r,n).map(function(a){return new Ie(a)})},splitAsync:function(r,n){return n==null&&(n=!1),we.dispatchMethod(lt,"surfaceSplit",[this._data,r,n]).then(function(a){return a.map(function(l){return new Ie(l)})})},reverse:function(r){return r==null&&(r=!1),new Ie(fe.surfaceReverse(this._data,r))},reverseAsync:function(r){return r==null&&(r=!1),we.dispatchMethod(fe,"surfaceReverse",[this._data,r]).then(function(n){return new Ie(n)})},isocurve:function(r,n){return n==null&&(n=!1),new Ne(me.surfaceIsocurve(this._data,r,n))},isocurveAsync:function(r,n){return n==null&&(n=!1),we.dispatchMethod(me,"surfaceIsocurve",[this._data,r,n]).then(function(a){return new Ne(a)})},boundaries:function(r){return me.surfaceBoundaryCurves(this._data).map(function(n){return new Ne(n)})},boundariesAsync:function(r){return we.dispatchMethod(me,"surfaceBoundaryCurves",[this._data]).then(function(n){return n.map(function(a){return new Ne(a)})})},tessellate:function(r){return Oe.rationalSurfaceAdaptive(this._data,r)},tessellateAsync:function(r){return we.dispatchMethod(Oe,"rationalSurfaceAdaptive",[this._data,r])},transform:function(r){return new Ie(fe.rationalSurfaceTransform(this._data,r))},transformAsync:function(r){return we.dispatchMethod(fe,"rationalSurfaceTransform",[this._data,r]).then(function(n){return new Ie(n)})},__class__:Ie});var ts=f.geom.ConicalSurface=function(r,n,a,l,c){Ie.call(this,me.conicalSurface(r,n,a,l,c)),this._axis=r,this._xaxis=n,this._base=a,this._height=l,this._radius=c};x["verb.geom.ConicalSurface"]=ts,ts.__name__=["verb","geom","ConicalSurface"],ts.__super__=Ie,ts.prototype=M(Ie.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__:ts});var rs=f.geom.CylindricalSurface=function(r,n,a,l,c){Ie.call(this,me.cylindricalSurface(r,n,a,l,c)),this._axis=r,this._xaxis=n,this._base=a,this._height=l,this._radius=c};x["verb.geom.CylindricalSurface"]=rs,rs.__name__=["verb","geom","CylindricalSurface"],rs.__super__=Ie,rs.prototype=M(Ie.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__:rs});var Rr=f.geom.EllipseArc=function(r,n,a,l,c){Ne.call(this,me.ellipseArc(r,n,a,l,c)),this._center=r,this._xaxis=n,this._yaxis=a,this._minAngle=l,this._maxAngle=c};x["verb.geom.EllipseArc"]=Rr,Rr.__name__=["verb","geom","EllipseArc"],Rr.__super__=Ne,Rr.prototype=M(Ne.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__:Rr});var ns=f.geom.Ellipse=function(r,n,a){Rr.call(this,r,n,a,0,Math.PI*2)};x["verb.geom.Ellipse"]=ns,ns.__name__=["verb","geom","Ellipse"],ns.__super__=Rr,ns.prototype=M(Rr.prototype,{__class__:ns});var ss=f.geom.ExtrudedSurface=function(r,n){Ie.call(this,me.extrudedSurface(m.normalized(n),m.norm(n),r.asNurbs())),this._profile=r,this._direction=n};x["verb.geom.ExtrudedSurface"]=ss,ss.__name__=["verb","geom","ExtrudedSurface"],ss.__super__=Ie,ss.prototype=M(Ie.prototype,{profile:function(){return this._profile},direction:function(){return this._direction},__class__:ss});var Br=f.geom.Intersect=function(){};x["verb.geom.Intersect"]=Br,Br.__name__=["verb","geom","Intersect"],Br.curves=function(r,n,a){return a==null&&(a=.001),le.curves(r.asNurbs(),n.asNurbs(),a)},Br.curvesAsync=function(r,n,a){return a==null&&(a=.001),we.dispatchMethod(le,"curves",[r.asNurbs(),n.asNurbs(),a])},Br.curveAndSurface=function(r,n,a){return a==null&&(a=.001),le.curveAndSurface(r.asNurbs(),n.asNurbs(),a)},Br.curveAndSurfaceAsync=function(r,n,a){return a==null&&(a=.001),we.dispatchMethod(le,"curveAndSurface",[r.asNurbs(),n.asNurbs(),a])},Br.surfaces=function(r,n,a){return a==null&&(a=.001),le.surfaces(r.asNurbs(),n.asNurbs(),a).map(function(l){return new Ne(l)})},Br.surfacesAsync=function(r,n,a){return a==null&&(a=.001),we.dispatchMethod(le,"surfaces",[r.asNurbs(),n.asNurbs(),a]).then(function(l){return l.map(function(c){return new Ne(c)})})};var is=f.geom.Line=function(r,n){Ne.call(this,me.polyline([r,n])),this._start=r,this._end=n};x["verb.geom.Line"]=is,is.__name__=["verb","geom","Line"],is.__super__=Ne,is.prototype=M(Ne.prototype,{start:function(){return this._start},end:function(){return this._end},__class__:is});var as=f.geom.RevolvedSurface=function(r,n,a,l){Ie.call(this,me.revolvedSurface(r.asNurbs(),n,a,l)),this._profile=r,this._center=n,this._axis=a,this._angle=l};x["verb.geom.RevolvedSurface"]=as,as.__name__=["verb","geom","RevolvedSurface"],as.__super__=Ie,as.prototype=M(Ie.prototype,{profile:function(){return this._profile},center:function(){return this._center},axis:function(){return this._center},angle:function(){return this._angle},__class__:as});var os=f.geom.SphericalSurface=function(r,n){Ie.call(this,me.sphericalSurface(r,[0,0,1],[1,0,0],n)),this._center=r,this._radius=n};x["verb.geom.SphericalSurface"]=os,os.__name__=["verb","geom","SphericalSurface"],os.__super__=Ie,os.prototype=M(Ie.prototype,{center:function(){return this._center},radius:function(){return this._radius},__class__:os});var ls=f.geom.SweptSurface=function(r,n){Ie.call(this,me.rationalTranslationalSurface(r.asNurbs(),n.asNurbs())),this._profile=r,this._rail=n};x["verb.geom.SweptSurface"]=ls,ls.__name__=["verb","geom","SweptSurface"],ls.__super__=Ie,ls.prototype=M(Ie.prototype,{profile:function(){return this._profile},rail:function(){return this._rail},__class__:ls});function Xt(r){return r instanceof Array?function(){return z.iter(r)}:typeof r.iterator=="function"?Mt(r,r.iterator):r.iterator}var Ui,kc=0;function Mt(r,n){if(n==null)return null;n.__id__==null&&(n.__id__=kc++);var a;return r.hx__closures__==null?r.hx__closures__={}:a=r.hx__closures__[n.__id__],a==null&&(a=function(){return a.method.apply(a.scope,arguments)},a.scope=r,a.method=n,r.hx__closures__[n.__id__]=a),a}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 Mc=x.Int={__name__:["Int"]},Tc=x.Dynamic={__name__:["Dynamic"]},po=x.Float=Number;po.__name__=["Float"];var go=x.Bool=Boolean;go.__ename__=["Bool"];var fo=x.Class={__name__:["Class"]},_o={};Array.prototype.map==null&&(Array.prototype.map=function(r){for(var n=[],a=0,l=this.length;a<l;){var c=a++;n[c]=r(this[c])}return n}),Array.prototype.filter==null&&(Array.prototype.filter=function(r){for(var n=[],a=0,l=this.length;a<l;){var c=a++,d=this[c];r(d)&&n.push(d)}return n});var Vi={},Vs=S.ArrayBuffer||ot;Vs.prototype.slice==null&&(Vs.prototype.slice=ot.sliceImpl),S.DataView;var ji=S.Uint8Array||nr._new;(function(r,n){if(r.setImmediate)return;var a=1,l={},c=!1,d=r.document,p;function _(O){return l[a]=v.apply(n,O),a++}function v(O){var F=[].slice.call(arguments,1);return function(){typeof O=="function"?O.apply(n,F):new Function(""+O)()}}function w(O){if(c)setTimeout(v(w,O),0);else{var F=l[O];if(F){c=!0;try{F()}finally{P(O),c=!1}}}}function P(O){delete l[O]}function A(){p=function(){var O=_(arguments);return process.nextTick(v(w,O)),O}}function I(){if(r.postMessage&&!r.importScripts){var O=!0,F=r.onmessage;return r.onmessage=function(){O=!1},r.postMessage("","*"),r.onmessage=F,O}}function k(){var O="setImmediate$"+Math.random()+"$",F=function(V){V.source===r&&typeof V.data=="string"&&V.data.indexOf(O)===0&&w(+V.data.slice(O.length))};r.addEventListener?r.addEventListener("message",F,!1):r.attachEvent("onmessage",F),p=function(){var V=_(arguments);return r.postMessage(O+V,"*"),V}}function T(){var O=new MessageChannel;O.port1.onmessage=function(F){var V=F.data;w(V)},p=function(){var F=_(arguments);return O.port2.postMessage(F),F}}function L(){var O=d.documentElement;p=function(){var F=_(arguments),V=d.createElement("script");return V.onreadystatechange=function(){w(F),V.onreadystatechange=null,O.removeChild(V),V=null},O.appendChild(V),F}}function C(){p=function(){var O=_(arguments);return setTimeout(v(w,O),0),O}}var R=Object.getPrototypeOf&&Object.getPrototypeOf(r);R=R&&R.setTimeout?R:r,{}.toString.call(r.process)==="[object process]"?A():I()?k():r.MessageChannel?T():d&&"onreadystatechange"in d.createElement("script")?L():C(),R.setImmediate=p,R.clearImmediate=P})(new Function("return this")()),Ye.USE_CACHE=!1,Ye.USE_ENUM_INDEX=!1,Ye.BASE64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:",We.DEFAULT_RESOLVER=ce,We.BASE64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:",Le.count=0,at.i64tmp=function(r){var n,a=new Ve(0,0);return n=a,n}(),Te.__toStr={}.toString,nr.BYTES_PER_ELEMENT=1,Se.queue=new U,Re.memo=new xe,re.TOLERANCE=1e-6,re.EPSILON=1e-10,re.VERSION="2.0.0",ve.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]],ve.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]],we.THREADS=1,we._init=!1,zr.basePath="",$r.uuid=0,Fs.main()}(typeof console<"u"?console:{log:function(){}},t,typeof u<"u"?u:typeof s<"u"?s:typeof self<"u"?self:this),t})})(Qh);var Yd=Qh.exports;const On=qd(Yd);class oa{constructor(){this.c0=0,this.c1=0,this.c2=0,this.c3=0}init(e,t,s,o){this.c0=e,this.c1=s,this.c2=-3*e+3*t-2*s-o,this.c3=2*e-2*t+s+o}initCatmullRom(e,t,s,o,h){this.init(t,s,h*(s-e),h*(o-t))}initNonuniformCatmullRom(e,t,s,o,h,u,g){let b=(t-e)/h-(s-e)/(h+u)+(s-t)/u,f=(s-t)/u-(o-t)/(u+g)+(o-s)/g;b*=u,f*=u,this.init(t,s,b,f)}calc(e){const t=e*e,s=t*e;return this.c0+this.c1*e+this.c2*t+this.c3*s}}class Jh extends Rs{constructor(e=[],t=!1,s="centripetal",o=.5){super(),this.isCatmullRomCurve3d=!0,this.type="CatmullRomCurve3d",this._tmp=new Z,this._px=new oa,this._py=new oa,this._pz=new oa,this._points=e.map(h=>new Y(h)),this._closed=t,this._curveType=s,this._tension=o}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 Y}get endPoint(){return this._points.length>0?this._points[this._points.length-1]:new Y}get length(){if(this._points.length<2)return 0;let e=0;for(let t=1;t<this._points.length;t++)e+=this._points[t-1].distanceTo(this._points[t]);return this._closed&&this._points.length>2&&(e+=this._points[this._points.length-1].distanceTo(this._points[0])),e}getPoint(e,t=new Y){const s=t,o=this._points,h=o.length;if(h===0)return s.set(0,0,0);if(h===1)return s.copy(o[0]);const u=(h-(this._closed?0:1))*e;let g=Math.floor(u),b=u-g;this._closed?g+=g>0?0:(Math.floor(Math.abs(g)/h)+1)*h:b===0&&g===h-1&&(g=h-2,b=1);let f,S;this._closed||g>0?f=o[(g-1)%h]:(this._tmp.subVectors(o[0],o[1]).add(o[0]),f=new Y(this._tmp.x,this._tmp.y,this._tmp.z));const x=o[g%h],E=o[(g+1)%h];if(this._closed||g+2<h?S=o[(g+2)%h]:(this._tmp.subVectors(o[h-1],o[h-2]).add(o[h-1]),S=new Y(this._tmp.x,this._tmp.y,this._tmp.z)),this._curveType==="centripetal"||this._curveType==="chordal"){const M=this._curveType==="chordal"?.5:.25;let z=Math.pow(f.distanceToSquared(x),M),D=Math.pow(x.distanceToSquared(E),M),U=Math.pow(E.distanceToSquared(S),M);D<1e-4&&(D=1),z<1e-4&&(z=D),U<1e-4&&(U=D),this._px.initNonuniformCatmullRom(f.x,x.x,E.x,S.x,z,D,U),this._py.initNonuniformCatmullRom(f.y,x.y,E.y,S.y,z,D,U),this._pz.initNonuniformCatmullRom(f.z,x.z,E.z,S.z,z,D,U)}else this._curveType==="catmullrom"&&(this._px.initCatmullRom(f.x,x.x,E.x,S.x,this._tension),this._py.initCatmullRom(f.y,x.y,E.y,S.y,this._tension),this._pz.initCatmullRom(f.z,x.z,E.z,S.z,this._tension));return s.set(this._px.calc(b),this._py.calc(b),this._pz.calc(b)),s}getPoints(e){const t=[];for(let s=0;s<=e;s++)t.push(this.getPoint(s/e));return t}setPoints(e){this._points=e.map(t=>new Y(t)),this._boundingBoxNeedsUpdate=!0}setClosed(e){this._closed!==e&&(this._closed=e,this._boundingBoxNeedsUpdate=!0)}setCurveType(e){this._curveType=e}setTension(e){this._tension=e}transform(e){return this._points=this._points.map(t=>{const s=new Y;return s.copy(t),s.applyMatrix3d(e),s}),this._boundingBoxNeedsUpdate=!0,this}calculateBoundingBox(){if(this._points.length===0)return new De;const e=new De;return this._points.forEach(t=>{e.expandByPoint(t)}),e}}class gn{constructor(e,t,s,o){this._degree=e,this._knots=[...t],this._controlPoints=s.map(h=>({x:h.x,y:h.y,z:h.z})),this._weights=o?[...o]:new Array(s.length).fill(1)}degree(){return this._degree}knots(){return[...this._knots]}controlPoints(){return this._controlPoints.map(e=>({x:e.x,y:e.y,z:e.z}))}weights(){return[...this._weights]}point(e){const t=this._controlPoints.map(s=>[s.x,s.y,s.z]);return Ts(e,this._degree,this._knots,t,this._weights)}length(){const e=this._controlPoints.map(t=>[t.x,t.y,t.z]);return Hh(this._degree,this._knots,e,this._weights)}static byKnotsControlPointsWeights(e,t,s,o){return new gn(e,t,s,o)}static byPoints(e,t,s="Uniform"){let o;switch(s){case"Chord":o=Gh(t,e);break;case"SqrtChord":o=Wh(t,e);break;case"Uniform":default:o=jh(t,e.length);break}const h=e.map(g=>({x:g[0],y:g[1],z:g[2]})),u=new Array(h.length).fill(1);return new gn(t,o,h,u)}getParameterRange(){const e=this._knots[this._degree],t=this._knots[this._knots.length-this._degree-1];return{start:e,end:t}}getPoints(e){const t=[],{start:s,end:o}=this.getParameterRange();for(let h=0;h<=e;h++){const u=s+(o-s)*(h/e);t.push(this.point(u))}return t}isClosed(e=1e-6){const{start:t,end:s}=this.getParameterRange(),o=this.point(t),h=this.point(s),u=o[0]-h[0],g=o[1]-h[1],b=o[2]-h[2];return Math.sqrt(u*u+g*g+b*b)<e}static createFitPointsForClosedCurve(e){if(e.length<4)throw new Error("At least 4 points are required for a closed NURBS curve");const t=new Jh(e,!0,"centripetal"),s=Math.max(50,e.length*2);return t.getPoints(s)}static createClosedCurve(e,t,s="Chord"){const o=this.createFitPointsForClosedCurve(e).map(h=>[h.x,h.y,h.z]);return gn.byPoints(o,t,s)}}class Yr extends Rs{constructor(e,t,s,o,h){super();const u=arguments.length;if(u<2||u>5)throw Ut.ILLEGAL_PARAMETERS;if(this._degree=3,this._closed=!1,Array.isArray(t)){this._controlPoints=e;let g,b=3,f=!1;if(u>=3&&(Array.isArray(s)?(g=s,u>=4&&(b=o||3),u>=5&&(f=h)):s!==void 0&&(b=s||3,u>=4&&(f=o))),s===void 0&&u>=4&&(b=o||3,u>=5&&(f=h)),this._degree=b,this._closed=f,this._controlPoints.length<this._degree+1)throw Ut.ILLEGAL_PARAMETERS;const S=this.toVerbPoints(this._controlPoints);this._nurbsCurve=On.geom.NurbsCurve.byKnotsControlPointsWeights(this._degree,t,S,g)}else{if(this._fitPoints=e,this._knotParameterization=t,u>=3&&(this._degree=s||3),u>=4&&(this._closed=o),this._fitPoints.length<this._degree+1)throw Ut.ILLEGAL_PARAMETERS;const g=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=On.geom.NurbsCurve.byPoints(g,this._degree),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}}buildCurve(){if(this._fitPoints&&this._knotParameterization){if(this._closed){const e=gn.createFitPointsForClosedCurve(this._fitPoints),t=this.toNurbsPoints(e);this._nurbsCurve=On.geom.NurbsCurve.byPoints(t,this._degree)}else{const e=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=On.geom.NurbsCurve.byPoints(e,this._degree)}this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}else if(this._controlPoints)if(this._closed){const e=gn.createFitPointsForClosedCurve(this._controlPoints),t=this.toNurbsPoints(e);this._nurbsCurve=On.geom.NurbsCurve.byPoints(t,this._degree),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}else{const e=this._nurbsCurve.knots(),t=this._nurbsCurve.weights(),s=this.toVerbPoints(this._controlPoints);this._nurbsCurve=On.geom.NurbsCurve.byKnotsControlPointsWeights(this._degree,e,s,t)}}setClosed(e){this._closed!==e&&(this._closed=e,this._boundingBoxNeedsUpdate=!0,this.buildCurve())}get degree(){return this._degree}get knotParameterization(){return this._knotParameterization}get startPoint(){const e=this._nurbsCurve.knots(),t=this._nurbsCurve.degree(),s=e[t],o=this._nurbsCurve.point(s);return new Y(o[0],o[1],o[2])}get endPoint(){const e=this._nurbsCurve.knots(),t=this._nurbsCurve.degree(),s=e[e.length-t-1],o=this._nurbsCurve.point(s);return new Y(o[0],o[1],o[2])}get length(){return this._nurbsCurve.length()}getFitPointAt(e){if(!this._fitPoints)throw new Error("No fit points in this spline");const t=this._fitPoints.length,s=e<0||e>=t?t-1:e,o=this._fitPoints[s];return{x:o.x,y:o.y,z:o.z||0}}getControlPointAt(e){const t=this._controlPoints.length,s=e<0||e>=t?t-1:e;return this._controlPoints[s]}getPoints(e=100){const t=this._nurbsCurve,s=[],o=t.knots(),h=this._nurbsCurve.degree(),u=o[h],g=o[o.length-h-1],b=(g-u)/(e-1);for(let f=0;f<e;f++){const S=f===e-1?g:u+f*b,x=t.point(S);s.push(new Y(x[0],x[1],x[2]))}return s}getCurvePoints(e,t){const s=[],o=e.knots(),h=o[3],u=(o[o.length-4]-h)/(t-1);for(let g=0;g<t;g++){const b=h+g*u;s.push(e.point(b))}return s}calculateBoundingBox(){const e=this.getPoints(100);return new De().setFromPoints(e)}get closed(){return this._closed}set closed(e){this.setClosed(e)}transform(e){return this._boundingBoxNeedsUpdate=!0,this}toNurbsPoints(e){const t=new Array(e.length);return e.forEach((s,o)=>{t[o]=[s.x,s.y,s.z||0]}),t}toVerbPoints(e){const t=new Array(e.length);return e.forEach((s,o)=>{t[o]=[s.x,s.y,s.z||0]}),t}toGePoints(e){const t=new Array(e.length);return e.forEach((s,o)=>{t[o]={x:s[0],y:s[1],z:s[2]}}),t}static createClosedSpline(e,t="Uniform",s=3){if(e.length<s+1)throw new Error(`At least ${s+1} points are required for a degree ${s} closed spline`);return new Yr(e,t,s,!0)}}var dn=256,ec=[],Go=256,Hs;for(;dn--;)ec[dn]=(dn+256).toString(16).substring(1);function Xd(i){var e=0,t=11;if(!Hs||dn+t>Go*2)for(Hs="",dn=0;e<Go;e++)Hs+=ec[Math.random()*256|0];return Hs.substring(dn,dn+++t)}class Xr{constructor(e,t){e=e||{},Fn(e,{objectId:Xd()}),this._attrs=new Jo(e,t)}get attrs(){return this._attrs}getAttr(e){const t=this._attrs.get(e);if(t===void 0)throw new Error(`[AcDbObject] Attribute name '${e}' does't exist in this object!`);return t}getAttrWithoutException(e){return this._attrs.get(e)}setAttr(e,t){this._attrs.set(e,t)}get objectId(){return this.getAttr("objectId")}set objectId(e){this._attrs.set("objectId",e)}get ownerId(){return this.getAttr("ownerId")}set ownerId(e){this._attrs.set("ownerId",e)}get database(){return this._database?this._database:Ra().workingDatabase}set database(e){this._database=e}close(){}}const Ba=class Ba extends Xr{constructor(){super(...arguments),this._layer="0",this._color=new Wr,this._lineType=Js,this._lineWeight=1,this._linetypeScale=-1,this._visibility=!0,this._transparency=0}get type(){return this.constructor.typeName}get layer(){return this._layer}set layer(e){this._layer=e}get color(){return this._color}set color(e){this._color.copy(e)}get rgbColor(){let e=this.database.cecolor;if(this.color.isByLayer){const t=this.getLayerColor();t&&t.color&&(e=t)}else this.color.isByBlock||this.color.color!=null&&(e=this.color);return e.color==null?16777215:e.color}get lineType(){return this._lineType}set lineType(e){this._lineType=e||Js}get lineWeight(){return this._lineWeight}set lineWeight(e){this._lineWeight=e}get linetypeScale(){return this._linetypeScale}set linetypeScale(e){this._linetypeScale=e}get visibility(){return this._visibility}set visibility(e){this._visibility=e}get transparency(){return this._transparency}set transparency(e){this._transparency=e}subGetGripPoints(){return new Array}subGetOsnapPoints(e,t,s,o,h){}transformBy(e){return this}triggerModifiedEvent(){this.database.events.entityModified.dispatch({database:this.database,entity:this})}get lineStyle(){var s;const e=this.getLineType(),t=(s=this.database)==null?void 0:s.tables.linetypeTable.getAt(e);return t?{...t.linetype,color:this.rgbColor}:{name:e,standardFlag:0,color:this.rgbColor,description:"",totalPatternLength:0}}getLineType(){if(this.lineType==Js){const e=this.database.tables.layerTable.getAt(this.layer);if(e&&e.linetype)return e.linetype}else return this.lineType==gh?ti:this.lineType;return ti}getLayerColor(){const e=this.database.tables.layerTable.getAt(this.layer);if(e==null)console.error(`The layer with name '${this.layer}' not found in drawing database!`);else return e.color;return null}attachEntityInfo(e){e&&(e.objectId=this.objectId,e.ownerId=this.ownerId,e.layerName=this.layer,e.visible=this.visibility)}};Ba.typeName="Entity";let Vt=Ba;const Fa=class Fa extends Vt{};Fa.typeName="Curve";let jt=Fa;const Ua=class Ua extends jt{constructor(e,t,s,o){super(),this._geo=new pn(e,t,s,o,Z.Z_AXIS,Z.X_AXIS)}get center(){return this._geo.center}set center(e){this._geo.center=e}get radius(){return this._geo.radius}set radius(e){this._geo.radius=e}get startAngle(){return this._geo.startAngle}set startAngle(e){this._geo.startAngle=e}get endAngle(){return this._geo.endAngle}set endAngle(e){this._geo.endAngle=e}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 e=new Array;return e.push(this.center),e.push(this.startPoint),e.push(this.endPoint),e}transformBy(e){return this._geo.transform(e),this}draw(e){return e.circularArc(this._geo,this.lineStyle)}};Ua.typeName="Arc";let ni=Ua;const Va=class Va extends Vt{constructor(e){super(),this._blockName=e,this._position=new Y,this._rotation=0,this._normal=new Z(0,0,1),this._scaleFactors=new Y(1,1,1)}get position(){return this._position}set position(e){this._position.copy(e)}get rotation(){return this._rotation}set rotation(e){this._rotation=e}get scaleFactors(){return this._scaleFactors}set scaleFactors(e){this._scaleFactors.copy(e)}get normal(){return this._normal}set normal(e){this._normal.copy(e).normalize()}get blockTableRecord(){return this.database.tables.blockTable.getAt(this._blockName)}get geometricExtents(){const e=new De,t=this.blockTableRecord;if(t!=null){const h=t.newIterator();for(const u of h)e.union(u.geometricExtents)}const s=new Hr().setFromEuler(new Kh(this.rotation,0,0)),o=new fn;return o.compose(this.position,s,this.scaleFactors),e.applyMatrix4(o),e}draw(e){const t=[],s=this.blockTableRecord;if(s!=null){const o=this.computeTransformMatrix(),h=Gr.instance.draw(e,s,this.rgbColor,!0,o,this.normal);return this.attachEntityInfo(h),h}else{const o=e.group(t);return this.attachEntityInfo(o),o}}computeTransformMatrix(){const e=new Hr;return e.setFromAxisAngle(Z.Z_AXIS,this.rotation),new fn().compose(this._position,e,this._scaleFactors)}};Va.typeName="BlockReference";let Ls=Va;const ja=class ja extends jt{constructor(e,t,s=Z.Z_AXIS){super(),this._geo=new pn(e,t,0,nt,s,Z.X_AXIS)}get center(){return this._geo.center}set center(e){this._geo.center=e}get radius(){return this._geo.radius}set radius(e){this._geo.radius=e}get normal(){return this._geo.normal}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}subGetGripPoints(){const e=new Array;return e.push(this.center),e}transformBy(e){return this._geo.transform(e),this}draw(e){return e.circularArc(this._geo,this.lineStyle)}};ja.typeName="Circle";let si=ja;const Ga=class Ga extends jt{constructor(e,t,s,o,h,u,g){super(),this._geo=new Li(e,t,s,o,h,u,g)}get center(){return this._geo.center}set center(e){this._geo.center=e}get majorAxisRadius(){return this._geo.majorAxisRadius}set majorAxisRadius(e){this._geo.majorAxisRadius=e}get minorAxisRadius(){return this._geo.minorAxisRadius}set minorAxisRadius(e){this._geo.minorAxisRadius=e}get normal(){return this._geo.normal}set normal(e){this._geo.normal=e}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}draw(e){return e.ellipticalArc(this._geo,this.lineStyle)}};Ga.typeName="Ellipse";let ii=Ga;const Wa=class Wa extends Vt{constructor(){super(),this._vertices=[new Y,new Y,new Y,new Y],this._edgeInvisibilities=0}getVertexAt(e){return e<0?this._vertices[0]:e>3?this._vertices[3]:this._vertices[e]}setVertexAt(e,t){if(e<0&&this._vertices[0].copy(t),e>3)return this._vertices[3].copy(t);this._vertices[e].copy(t)}setEdgeInvisibilities(e){this._edgeInvisibilities=e}isEdgeVisibleAt(e){if(e<0||e>3)throw new Error("Index out of range");return(this._edgeInvisibilities&1<<e)===0}makeEdgeInvisibleAt(e){if(e<0||e>3)throw new Error("Index out of range");this._edgeInvisibilities=this._edgeInvisibilities|1<<e}get geometricExtents(){return new De().setFromPoints(this._vertices)}subGetGripPoints(){const e=new Array;for(let t=0;t<this._vertices.length;++t)e.push(this.getVertexAt(t));return e}draw(e){const t=new Float32Array(12),s=new Uint16Array(8);for(let o=0;o<4;o++)t[o*3]=this._vertices[o].x,t[o*3+1]=this._vertices[o].y,t[o*3+2]=this._vertices[o].z,this.isEdgeVisibleAt(o)&&(s[o*2]=o,s[o*2+1]=(o+1)%4);return e.lineSegments(t,3,s,this.lineStyle)}};Wa.typeName="Face";let ai=Wa;var tc=(i=>(i[i.UserDefined=0]="UserDefined",i[i.Predefined=1]="Predefined",i[i.Custom=2]="Custom",i))(tc||{}),rc=(i=>(i[i.Normal=0]="Normal",i[i.Outer=1]="Outer",i[i.Ignore=2]="Ignore",i))(rc||{});const Ha=class Ha extends Vt{constructor(){super(),this._elevation=0,this._geo=new Ni,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(e){this._patternName=e}get patternType(){return this._patternType}set patternType(e){this._patternType=e}get patternAngle(){return this._patternAngle}set patternAngle(e){this._patternAngle=e}get patternScale(){return this._patternScale}set patternScale(e){this._patternScale=e}get hatchStyle(){return this._hatchStyle}set hatchStyle(e){this._hatchStyle=e}add(e){this._geo.add(e)}get geometricExtents(){const e=this._geo.box;return new De({x:e.min.x,y:e.min.y,z:this._elevation},{x:e.max.x,y:e.max.y,z:this._elevation})}draw(e){return e.area(this._geo,{color:this.rgbColor,solidFill:!1,patternAngle:this.patternAngle,patternLines:this.definitionLines})}};Ha.typeName="Hatch";let oi=Ha;var nc=(i=>(i[i.MText=0]="MText",i[i.Fcf=1]="Fcf",i[i.BlockReference=2]="BlockReference",i[i.NoAnnotation=3]="NoAnnotation",i))(nc||{});const qa=class qa extends jt{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(e){this._isSplined=e}get hasArrowHead(){return this._hasArrowHead}set hasArrowHead(e){this._hasArrowHead=e}get hasHookLine(){return this._hasHookLine}set hasHookLine(e){this._hasHookLine=e}get numVertices(){return this._vertices.length}get dimensionStyle(){return this._dimensionStyle}set dimensionStyle(e){this._dimensionStyle=e}get annoType(){return this._annoType}set annoType(e){this._annoType=e}appendVertex(e){this._vertices.push(new Y().copy(e)),this._updated=!0}setVertexAt(e,t){throw(e<0||e>=this._vertices.length)&&(this._vertices[e].copy(t),this._updated=!0),new Error("The vertex index is out of range!")}vertexAt(e){throw(e<0||e>=this._vertices.length)&&this._vertices[e],new Error("The vertex index is out of range!")}get geometricExtents(){return this._isSplined&&this.splineGeo?this.splineGeo.calculateBoundingBox():new De().setFromPoints(this._vertices)}get closed(){return!1}set closed(e){}draw(e){if(this.isSplined&&this.splineGeo){const t=this.splineGeo.getPoints(100);return e.lines(t,this.lineStyle)}else return e.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 Yr(this._vertices,"Uniform"),this._updated=!1)}};qa.typeName="Leader";let li=qa;const Ya=class Ya extends jt{constructor(e,t){super(),this._geo=new qr(e,t)}get startPoint(){return this._geo.startPoint}set startPoint(e){this._geo.startPoint=e}get endPoint(){return this._geo.endPoint}set endPoint(e){this._geo.endPoint=e}get midPoint(){return this._geo.midPoint}get geometricExtents(){return this._geo.box}get closed(){return!1}subGetGripPoints(){const e=new Array;return e.push(this.midPoint),e.push(this.startPoint),e.push(this.endPoint),e}subGetOsnapPoints(e,t,s,o,h){const u=this.startPoint,g=this.endPoint;switch(e){case un.EndPoint:h.push(u),h.push(g);break;case un.MidPoint:h.push(this.midPoint);break;case un.Nearest:{const b=this._geo.project(s);h.push(b)}break;case un.Perpendicular:{const b=this._geo.perpPoint(s);h.push(b)}break;case un.Tangent:h.push(u);break}}transformBy(e){return this._geo.transform(e),this}draw(e){const t=this.startPoint,s=this.endPoint,o=[new Y(t.x,t.y,0),new Y(s.x,s.y,0)];return e.lines(o,this.lineStyle)}};Ya.typeName="Line";let hi=Ya;var Na=(i=>(i.ClosedFilled="",i.Dot="_DOT",i.DotSmall="_DOTSMALL",i.DotBlank="_DOTBLANK",i.Origin="_ORIGIN",i.Origin2="_ORIGIN2",i.Open="_OPEN",i.Open90="_OPEN90",i.Open30="_OPEN30",i.Closed="_CLOSED",i.Small="_SMALL",i.None="_NONE",i.Oblique="_OBLIQUE",i.BoxFilled="_BOXFILLED",i.Box="_BOXBLANK",i.ClosedBlank="_CLOSEDBLANK",i.DatumBlank="_DATUMBLANK",i.DatumFilled="_DATUMFILLED",i.Integral="_INTEGRAL",i.ArchTick="_ARCHTICK",i))(Na||{}),zi=(i=>(i[i.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",i[i.RIGHT_TO_LEFT=2]="RIGHT_TO_LEFT",i[i.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",i[i.BOTTOM_TO_TOP=4]="BOTTOM_TO_TOP",i[i.BY_STYLE=5]="BY_STYLE",i))(zi||{}),Rn=(i=>(i[i.TopLeft=1]="TopLeft",i[i.TopCenter=2]="TopCenter",i[i.TopRight=3]="TopRight",i[i.MiddleLeft=4]="MiddleLeft",i[i.MiddleCenter=5]="MiddleCenter",i[i.MiddleRight=6]="MiddleRight",i[i.BottomLeft=7]="BottomLeft",i[i.BottomCenter=8]="BottomCenter",i[i.BottomRight=9]="BottomRight",i))(Rn||{}),Ca=(i=>(i[i.OPTIMIZED_2D=0]="OPTIMIZED_2D",i[i.WIREFRAME=1]="WIREFRAME",i[i.HIDDEN_LINE=2]="HIDDEN_LINE",i[i.FLAT_SHADED=3]="FLAT_SHADED",i[i.GOURAUD_SHADED=4]="GOURAUD_SHADED",i[i.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",i[i.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME",i))(Ca||{}),La=(i=>(i[i.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",i[i.TOP=1]="TOP",i[i.BOTTOM=2]="BOTTOM",i[i.FRONT=3]="FRONT",i[i.BACK=4]="BACK",i[i.LEFT=5]="LEFT",i[i.RIGHT=6]="RIGHT",i))(La||{}),Oa=(i=>(i[i.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",i[i.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS",i))(Oa||{});class Di{constructor(){this._number=-1,this._id="",this._groupId="",this._centerPoint=new Y,this._height=0,this._width=0,this._viewCenter=new Y,this._viewHeight=0}get number(){return this._number}set number(e){this._number=e}get id(){return this._id}set id(e){this._id=e}get groupId(){return this._groupId}set groupId(e){this._groupId=e}get centerPoint(){return this._centerPoint}set centerPoint(e){this._centerPoint.copy(e)}get height(){return this._height}set height(e){this._height=e}get width(){return this._width}set width(e){this._width=e}get box(){const e=new _t;return e.setFromCenterAndSize(this.centerPoint,{x:this.width,y:this.height}),e}get viewCenter(){return this._viewCenter}set viewCenter(e){this._viewCenter.copy(e)}get viewHeight(){return this._viewHeight}set viewHeight(e){this._viewHeight=e}get viewWidth(){return this.viewHeight*(this.width/this.height)}get viewBox(){const e=new _t;return e.setFromCenterAndSize(this.viewCenter,{x:this.viewWidth,y:this.viewHeight}),e}clone(){const e=new Di;return e.id=this.id,e.groupId=this.groupId,e.number=this.number,e.centerPoint.copy(this.centerPoint),e.height=this.height,e.width=this.width,e.viewCenter.copy(this.viewCenter),e.viewHeight=this.viewHeight,e}copy(e){return this.id=e.id,this.groupId=e.groupId,this.number=e.number,this.centerPoint.copy(e.centerPoint),this.height=e.height,this.width=e.width,this.viewCenter.copy(e.viewCenter),this.viewHeight=e.viewHeight,this}}const Xa=class Xa extends Vt{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 Y,this._attachmentPoint=Rn.TopLeft,this._direction=new Z(1,0,0),this._drawingDirection=zi.LEFT_TO_RIGHT}get contents(){return this._contents}set contents(e){this._contents=e}get height(){return this._height}set height(e){this._height=e}get width(){return this._width}set width(e){this._width=e}get rotation(){return this._rotation}set rotation(e){this._rotation=e}get lineSpacingFactor(){return this._lineSpacingFactor}set lineSpacingFactor(e){this._lineSpacingFactor=e}get lineSpacingStyle(){return this._lineSpacingStyle}set lineSpacingStyle(e){this._lineSpacingStyle=e}get backgroundFill(){return this._backgroundFill}set backgroundFill(e){this._backgroundFill=e,this._backgroundFillColor=13158600}get backgroundFillColor(){return this._backgroundFillColor}set backgroundFillColor(e){this._backgroundFillColor=e}get backgroundFillTransparency(){return this._backgroundFillTransparency}set backgroundFillTransparency(e){this._backgroundFillTransparency=e}get backgroundScaleFactor(){return this._backgroundScaleFactor}set backgroundScaleFactor(e){this._backgroundScaleFactor=e}get styleName(){return this._styleName}set styleName(e){this._styleName=e}get location(){return this._location}set location(e){this._location.copy(e)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(e){this._attachmentPoint=e}get direction(){return this._direction}set direction(e){this._direction.copy(e)}get drawingDirection(){return this._drawingDirection}set drawingDirection(e){this._drawingDirection=e}get geometricExtents(){return new De}getTextStyle(){const e=this.database.tables.textStyleTable;let t=e.getAt(this.styleName);return t||(t=e.getAt("STANDARD")||e.getAt("Standard")),t.textStyle}draw(e,t){const s={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},o={...this.getTextStyle(),color:this.rgbColor};return e.mtext(s,o,t)}};Xa.typeName="MText";let ci=Xa;const Ka=class Ka extends jt{constructor(e,t,s,o,h){super();const u=+(e!==void 0)+ +(t!==void 0)+ +(s!==void 0)+ +(o!==void 0)+ +(h!==void 0);if(u<2||u>5)throw Ut.ILLEGAL_PARAMETERS;!Array.isArray(t)?this._geo=new Yr(e,t,s,o):this._geo=new Yr(e,t,s,o,h)}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}set closed(e){this._geo.closed=e}draw(e){const t=this._geo.getPoints(100);return e.lines(t,this.lineStyle)}};Ka.typeName="Spline";let Os=Ka;const Kd=new Z,$a=class $a extends Ls{constructor(e,t,s){super(e),this._attachmentPoint=Rn.TopLeft,this._numColumns=s,this._numRows=t,this._columnWidth=new Array(s),this._rowHeight=new Array(t),this._cells=new Array(t*s)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(e){this._attachmentPoint=e}get numRows(){return this._numRows}set numRows(e){this._numRows=e}get numColumns(){return this._numColumns}set numColumns(e){this._numColumns=e}numContents(e,t){return 1}rowHeight(e){return this._rowHeight[e]}setRowHeight(e,t){this._rowHeight[e]=t}setUniformRowHeight(e){this._rowHeight.fill(e)}columnWidth(e){return this._columnWidth[e]}setUniformColumnWidth(e){this._columnWidth.fill(e)}setColumnWidth(e,t){this._columnWidth[e]=t}cell(e){if(!(e<0||e>=this._cells.length))return this._cells[e]}setCell(e,t){this._cells[e]=t}textString(e,t,s){return this._cells[e*t].text}setTextString(e,t,s){this._cells[e*t].text=s}isEmpty(e,t){return!this._cells[e*t].text}get geometricExtents(){return new De}draw(e){let t=0,s=0;const o=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++){t-=E>0?this.rowHeight(E-1):0,s=0;for(let M=0;M<=this.numColumns;M++)s+=M>0?this.columnWidth(M-1):0,h[u++]=s,h[u++]=t,h[u++]=0}const g=[],b=new Array(this.numRows*this.numColumns).fill(!1);s=0,u=0;let f=0;for(let E=0;E<this.numColumns;E++){s+=E>0?this.columnWidth(E-1):0,t=0;for(let M=0;M<this.numRows;M++){t+=M>0?this.rowHeight(M-1):0;const z=this.cell(M*this.numColumns+E);if(f=M*this.numColumns+E,z&&!b[f]){const D=z.borderWidth??1,U=z.borderHeight??1;this.fillVisited(b,f,this.numColumns,D,U),o[u++]=E+M*(this.numColumns+1),o[u++]=E+M*(this.numColumns+1)+D;const B=h[o[u-1]*3]-s,ge=E+(M+U)*(this.numColumns+1)+D;E+D==this.numColumns&&(o[u++]=E+M*(this.numColumns+1)+D,o[u++]=ge);const be=-h[ge*3+1]-t;if(M+U==this.numRows&&(o[u++]=E+(M+U)*(this.numColumns+1)+U,o[u++]=E+(M+U)*(this.numColumns+1)),o[u++]=E+(M+U)*(this.numColumns+1),o[u++]=E+M*(this.numColumns+1),z.text){const oe=z.attachmentPoint||this.attachmentPoint||Rn.MiddleCenter,W=this.getTableTextOffset(oe,B,be),ce={text:z.text,height:z.textHeight,width:B,position:Kd.set(s,-t,0).clone().add(W),rotation:this.rotation,attachmentPoint:oe},se={...this.getTextStyle(z),color:this.color.color};g.push(e.mtext(ce,se))}}}}g.push(e.lineSegments(h,3,o,this.lineStyle));const S=e.group(g),x=new Hr;return x.setFromAxisAngle(Z.Z_AXIS,this.rotation),Wo.compose(this.position,x,this.scaleFactors),S.applyMatrix(Wo),this.attachEntityInfo(S),S}fillVisited(e,t,s,o,h){if(h==1&&o==1)e[t]=!0;else for(let u=0;u<o;++u)for(let g=0;g<h;++g)e[t+u+g*s]=!0}getTextStyle(e){const t=this.database.tables.textStyleTable;let s;return e.textStyle&&(s=t.getAt(e.textStyle)),s||(s=t.getAt("STANDARD")||t.getAt("Standard")),s.textStyle}getTableTextOffset(e,t,s){const o=new Z;switch(e){case 1:break;case 2:o.setX(t/2);break;case 3:o.setX(t);break;case 4:o.setY(-s/2);break;case 5:o.set(t/2,-s/2,0);break;case 6:o.set(t,-s/2,0);break;case 7:o.setY(-s);break;case 8:o.set(t/2,-s,0);break;case 9:o.set(t,-s,0);break}return o}};$a.typeName="Table";let ui=$a;const Wo=new fn;var sc=(i=>(i[i.LEFT=0]="LEFT",i[i.CENTER=1]="CENTER",i[i.RIGHT=2]="RIGHT",i[i.ALIGNED=3]="ALIGNED",i[i.MIDDLE=4]="MIDDLE",i[i.FIT=5]="FIT",i))(sc||{}),ic=(i=>(i[i.BASELINE=0]="BASELINE",i[i.BOTTOM=1]="BOTTOM",i[i.MIDDLE=2]="MIDDLE",i[i.TOP=3]="TOP",i))(ic||{});const Za=class Za extends Vt{constructor(){super(),this._textString="",this._height=0,this._thickness=1,this._position=new Y,this._rotation=0,this._oblique=0,this._horizontalMode=0,this._verticalModel=2,this._styleName="",this._widthFactor=1}get textString(){return this._textString}set textString(e){this._textString=e}get thickness(){return this._thickness}set thickness(e){this._thickness=e}get height(){return this._height}set height(e){this._height=e}get position(){return this._position}set position(e){this._position.copy(e)}get rotation(){return this._rotation}set rotation(e){this._rotation=e}get oblique(){return this._oblique}set oblique(e){this._oblique=e}get horizontalMode(){return this._horizontalMode}set horizontalMode(e){this._horizontalMode=e}get verticalMode(){return this._verticalModel}set verticalMode(e){this._verticalModel=e}get styleName(){return this._styleName}set styleName(e){this._styleName=e}get widthFactor(){return this._widthFactor}set widthFactor(e){this._widthFactor=e}get geometricExtents(){return new De}getTextStyle(){const e=this.database.tables.textStyleTable;let t=e.getAt(this.styleName);return t||(t=e.getAt("STANDARD")||e.getAt("Standard")),t.textStyle}draw(e,t){const s={text:this.textString,height:this.height,width:1/0,widthFactor:this.widthFactor,position:this.position,rotation:this.rotation,drawingDirection:zi.BOTTOM_TO_TOP,attachmentPoint:Rn.BottomLeft},o={...this.getTextStyle(),color:this.rgbColor};return e.mtext(s,o,t)}};Za.typeName="Text";let di=Za;const Qa=class Qa extends jt{constructor(){super(),this._elevation=0,this._thickness=1,this._vertices=[new Y,new Y,new Y,new Y]}get elevation(){return this._elevation}set elevation(e){this._elevation=e}get closed(){return!0}get thickness(){return this._thickness}set thickness(e){this._thickness=e}getPointAt(e){return e<0?this._vertices[0]:e>3?this._vertices[3]:this._vertices[e]}setPointAt(e,t){if(e<0&&this._vertices[0].copy(t),e>3)return this._vertices[3].copy(t);this._vertices[e].copy(t)}get geometricExtents(){return new De().setFromPoints(this._vertices)}subGetGripPoints(){const e=new Array;for(let t=0;t<4;++t)e.push(this.getPointAt(t));return e}draw(e){const t=new Bs(this._vertices,!0),s=new Ni;return s.add(t),e.area(s,{color:this.rgbColor,solidFill:!0,patternAngle:0,patternLines:[]})}};Qa.typeName="Trace";let mi=Qa;const Ja=class Ja extends jt{constructor(){super(),this._elevation=0,this._geo=new Bs}get numberOfVertices(){return this._geo.numberOfVertices}get elevation(){return this._elevation}set elevation(e){this._elevation=e}get closed(){return this._geo.closed}set closed(e){this._geo.closed=e}addVertexAt(e,t,s=0,o=-1,h=-1){const u=o<0?void 0:o,g=h<0?void 0:h,b={x:t.x,y:t.y,bulge:s,startWidth:u,endWidth:g};this._geo.addVertexAt(e,b)}getPoint2dAt(e){return this._geo.getPointAt(e)}getPoint3dAt(e){const t=this.getPoint2dAt(e);return new Y(t.x,t.y,this._elevation)}get geometricExtents(){const e=this._geo.box;return new De({x:e.min.x,y:e.min.y,z:this._elevation},{x:e.max.x,y:e.max.y,z:this._elevation})}subGetGripPoints(){const e=new Array;for(let t=0;t<this.numberOfVertices;++t)e.push(this.getPoint3dAt(t));return e}draw(e){const t=[];return this._geo.getPoints(100).forEach(o=>t.push(new Y().set(o.x,o.y,this.elevation))),e.lines(t,this.lineStyle)}};Ja.typeName="Polyline";let pi=Ja;const eo=class eo extends Vt{constructor(){super(),this._geo=new Y}get position(){return this._geo}set position(e){this._geo.set(e.x,e.y,e.z||0)}get geometricExtents(){return new De().expandByPoint(this._geo)}transformBy(e){return this._geo.applyMatrix3d(e),this}draw(e){return e.point(this._geo,{displayMode:this.database.pdmode,displaySize:this.database.pdsize,color:this.rgbColor})}};eo.typeName="Point";let gi=eo;var ac=(i=>(i[i.Invalid=0]="Invalid",i[i.Rect=1]="Rect",i[i.Poly=2]="Poly",i))(ac||{}),oc=(i=>(i[i.Show=1]="Show",i[i.ShowUnAligned=2]="ShowUnAligned",i[i.Clip=4]="Clip",i[i.Transparent=8]="Transparent",i))(oc||{});const to=class to extends Vt{constructor(){super(),this._brightness=50,this._contrast=50,this._fade=0,this._width=0,this._height=0,this._position=new Y,this._scale=new $e(1,1),this._rotation=0,this._clipBoundaryType=1,this._clipBoundary=[],this._isClipped=!1,this._isShownClipped=!1,this._isImageShown=!0,this._isImageTransparent=!1,this._imageDefId=""}get brightness(){return this._brightness}set brightness(e){this._brightness=e}get contrast(){return this._contrast}set contrast(e){this._contrast=e}get fade(){return this._fade}set fade(e){this._fade=e}get height(){return this._height}set height(e){this._height=e}get width(){return this._width}set width(e){this._width=e}get position(){return this._position}set position(e){this._position=e}get rotation(){return this._rotation}set rotation(e){this._rotation=e}get scale(){return this._scale}set scale(e){this._scale.copy(e)}get clipBoundaryType(){return this._clipBoundaryType}set clipBoundaryType(e){this._clipBoundaryType=e}get clipBoundary(){return this._clipBoundary}set clipBoundary(e){this._clipBoundary=[],this._clipBoundary.push(...e)}get isClipped(){return this._isClipped}set isClipped(e){this._isClipped=e}get isShownClipped(){return this._isShownClipped}set isShownClipped(e){this._isShownClipped=e}get isImageShown(){return this._isImageShown}set isImageShown(e){this._isImageShown=e}get isImageTransparent(){return this._isImageTransparent}set isImageTransparent(e){this._isImageTransparent=e}get image(){return this._image}set image(e){this._image=e}get imageDefId(){return this._imageDefId}set imageDefId(e){this._imageDefId=e}get imageFileName(){if(this._imageDefId){const e=this.database.dictionaries.imageDefs.getIdAt(this._imageDefId);if(e)return e.sourceFileName}return""}get geometricExtents(){const e=new De;return e.min.copy(this._position),e.max.set(this._position.x+this._width,this._position.y+this._height,0),e}subGetGripPoints(){return this.boundaryPath()}draw(e){const t=this.boundaryPath();return this._image?e.image(this._image,{boundary:t,roation:this._rotation}):e.lines(t,this.lineStyle)}boundaryPath(){const e=[];if(this.isClipped&&this._clipBoundary.length>3){const t=this._width,s=this._height,o=new _t;o.setFromPoints(this._clipBoundary);const h=new Me;h.setX(this._position.x-o.min.x*t),h.setY(this._position.y-o.min.y*s),this._clipBoundary.forEach(u=>{const g=u.x*t+h.x,b=u.y*s+h.y;e.push(new Y(g,b,this._position.z))})}else{if(e.push(this._position),e.push(this._position.clone().setX(this._position.x+this._width)),e.push(this._position.clone().set(this._position.x+this._width,this._position.y+this._height,this._position.z)),e.push(this._position.clone().setY(this._position.y+this._height)),this._rotation>0){Ho.copy(e[1]);for(let t=1;t<4;t++)qs.copy(e[t]),qs.rotateAround(Ho,this._rotation),e[t].setX(qs.x),e[t].setY(qs.y)}e.push(e[0])}return e}};to.typeName="RasterImage";let zs=to;const Ho=new Me,qs=new Me,ro=class ro extends jt{constructor(){super(),this._basePoint=new Y,this._unitDir=new Z}get basePoint(){return this._basePoint}set basePoint(e){this._basePoint.copy(e)}get unitDir(){return this._unitDir}set unitDir(e){this._unitDir.copy(e)}get closed(){return!1}get geometricExtents(){const e=new De;return e.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),e.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),e}subGetGripPoints(){const e=new Array;return e.push(this.basePoint),e}draw(e){const t=[];return t.push(this.basePoint),t.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),e.lines(t,this.lineStyle)}};ro.typeName="Ray";let fi=ro;const no=class no extends Vt{constructor(){super(),this._centerPoint=new Y,this._height=0,this._width=0,this._viewCenter=new Y,this._viewHeight=0,this._number=-1}get number(){return this._number}set number(e){this._number=e}get centerPoint(){return this._centerPoint}set centerPoint(e){this._centerPoint=e}get height(){return this._height}set height(e){this._height=e}get width(){return this._width}set width(e){this._width=e}get viewCenter(){return this._viewCenter}set viewCenter(e){this._viewCenter=e}get viewHeight(){return this._viewHeight}set viewHeight(e){this._viewHeight=e}get geometricExtents(){return new De}draw(e){if(this._number>1&&this.ownerId!=this.database.tables.blockTable.modelSpace.objectId){const t=this.toGiViewport(),s=e.group(this.createViewportRect(t,e));return this.attachEntityInfo(s),s}}toGiViewport(){const e=new Di;return e.id=this.objectId,e.groupId=this.ownerId,e.number=this.number,e.centerPoint=this.centerPoint,e.width=this.width,e.height=this.height,e.viewHeight=this.viewHeight,e.viewCenter=this.viewCenter,e}createViewportRect(e,t){const s=[];return s.push(t.lines([new Y(e.centerPoint.x-e.width/2,e.centerPoint.y-e.height/2,0),new Y(e.centerPoint.x+e.width/2,e.centerPoint.y-e.height/2,0)],this.lineStyle)),s.push(t.lines([new Y(e.centerPoint.x+e.width/2,e.centerPoint.y-e.height/2,0),new Y(e.centerPoint.x+e.width/2,e.centerPoint.y+e.height/2,0)],this.lineStyle)),s.push(t.lines([new Y(e.centerPoint.x+e.width/2,e.centerPoint.y+e.height/2,0),new Y(e.centerPoint.x-e.width/2,e.centerPoint.y+e.height/2,0)],this.lineStyle)),s.push(t.lines([new Y(e.centerPoint.x-e.width/2,e.centerPoint.y+e.height/2,0),new Y(e.centerPoint.x-e.width/2,e.centerPoint.y-e.height/2,0)],this.lineStyle)),s}};no.typeName="Viewport";let _i=no;const so=class so extends zs{draw(e){const t=this.boundaryPath(),s=new Ni;return s.add(new Bs(t)),e.area(s,{color:0,solidFill:!0,patternAngle:0,patternLines:[]})}};so.typeName="Wipeout";let vi=so;const io=class io extends jt{constructor(){super(),this._basePoint=new Y,this._unitDir=new Z}get basePoint(){return this._basePoint}set basePoint(e){this._basePoint.copy(e)}get unitDir(){return this._unitDir}set unitDir(e){this._unitDir.copy(e)}get closed(){return!1}get geometricExtents(){const e=new De;return e.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),e.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),e}subGetGripPoints(){const e=new Array;return e.push(this.basePoint),e}draw(e){const t=[];return t.push(this._unitDir.clone().multiplyScalar(-1e6).add(this._basePoint)),t.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),e.lines(t,this.lineStyle)}};io.typeName="Xline";let yi=io;var lc=(i=>(i[i.AtLeast=1]="AtLeast",i[i.Exactly=2]="Exactly",i))(lc||{});const ao=class ao extends Vt{constructor(){super(),this._dimBlockId=null,this._dimensionStyleName=null,this._dimensionText=null,this._textLineSpacingFactor=1,this._textLineSpacingStyle=1,this._textPosition=new Y,this._textRotation=0}get dimBlockId(){return this._dimBlockId}set dimBlockId(e){this._dimBlockId=e}get dimensionStyleName(){return this._dimensionStyleName}set dimensionStyleName(e){this._dimensionStyleName=e}get dimensionStyle(){if(this._dimStyle==null){let e;this.dimensionStyleName&&(e=this.database.tables.dimStyleTable.getAt(this.dimensionStyleName)),e==null&&(e=new Bn),this._dimStyle=e}return this._dimStyle}get dimensionText(){return this._dimensionText}set dimensionText(e){this._dimensionText=e}get measurement(){return this._measurement}set measurement(e){this._measurement=e}get textLineSpacingFactor(){return this._textLineSpacingFactor}set textLineSpacingFactor(e){this._textLineSpacingFactor=e}get textLineSpacingStyle(){return this._textLineSpacingStyle}set textLineSpacingStyle(e){this._textLineSpacingStyle=e}get textPosition(){return this._textPosition}set textPosition(e){this._textPosition.copy(e)}get textRotation(){return this._textRotation}set textRotation(e){this._textRotation=e}draw(e){if(this.dimBlockId){const s=this.database.tables.blockTable.getAt(this.dimBlockId);if(s){const o=Gr.instance.draw(e,s,this.rgbColor,!1);return this.attachEntityInfo(o),o}}const t=e.group([]);return this.attachEntityInfo(t),t}drawFirstArrow(e){const t=this.database.tables.blockTable.getAt(this.firstArrowType);if(t)return Gr.instance.draw(e,t,this.rgbColor,!1)}drawSecondArrow(e){const t=this.database.tables.blockTable.getAt(this.secondArrowType);if(t)return Gr.instance.draw(e,t,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 e=this.dimensionStyle;return e.dimsah==0?e.dimblk:e.dimblk1}get firstArrowType(){const e=this.firstArrowTypeBtrId;return this.getArrowName(e)}get secondArrowTypeBtrId(){const e=this.dimensionStyle;return e.dimsah==0?e.dimblk:e.dimblk2}get secondArrowType(){const e=this.secondArrowTypeBtrId;return this.getArrowName(e)}get arrowLineCount(){return 1}getLineArrowStyle(e){}findPointOnLine1(e,t,s){const o=new Y().subVectors(t,e).normalize();return new Y(t).addScaledVector(o,s)}findPointOnLine2(e,t,s){const o=e.x+s*Math.cos(t),h=e.y+s*Math.sin(t);return{x:o,y:h}}adjustExtensionLine(e){const t=this.dimensionStyle;e.extend(t.dimexe),e.extend(-t.dimexo,!0)}getArrowName(e){const t=this.database.tables.blockTable.getIdAt(e);return t?t.name.toUpperCase():Na.Closed}};ao.typeName="Dimension";let Mr=ao;const oo=class oo extends Mr{constructor(e,t,s,o,h=null,u=null){super(),this._centerPoint=new Y().copy(e),this._xLine1Point=new Y().copy(t),this._xLine2Point=new Y().copy(s),this._arcPoint=new Y().copy(o),this.dimensionText=h,this.dimensionStyleName=u}get arcPoint(){return this._arcPoint}set arcPoint(e){this._arcPoint.copy(e)}get centerPoint(){return this._centerPoint}set centerPoint(e){this._centerPoint.copy(e)}get xLine1Point(){return this._xLine1Point}set xLine1Point(e){this._xLine1Point.copy(e)}get xLine2Point(){return this._xLine2Point}set xLine2Point(e){this._xLine2Point.copy(e)}get geometricExtents(){return new De}};oo.typeName="3PointAngularDimension";let bi=oo;const lo=class lo extends Mr{constructor(e,t,s,o=null,h=null){super(),this._dimLinePoint=new Y().copy(s),this._xLine1Point=new Y().copy(e),this._xLine2Point=new Y().copy(t),this._oblique=0,this._rotation=0,this.dimensionText=o,this.dimensionStyleName=h}get dimLinePoint(){return this._dimLinePoint}set dimLinePoint(e){this._dimLinePoint.copy(e)}get xLine1Point(){return this._xLine1Point}set xLine1Point(e){this._xLine1Point.copy(e)}get xLine2Point(){return this._xLine2Point}set xLine2Point(e){this._xLine2Point.copy(e)}get rotation(){return this._rotation}set rotation(e){this._rotation=e}get oblique(){return this._oblique}set oblique(e){this._oblique=e}get geometricExtents(){return new De}get isAppendArrow(){return!1}calculateLines(){const e=[],t=this.createExtensionLine(this._xLine1Point),s=this.createExtensionLine(this._xLine2Point),o=this.findIntersectionPoint(t,this._dimLinePoint),h=this.findIntersectionPoint(s,this._dimLinePoint),u=new qr(o,h);return e.push(u),t.endPoint=o,this.adjustExtensionLine(t),e.push(t),s.endPoint=h,this.adjustExtensionLine(s),e.push(s),e}createExtensionLine(e){const t=this.rotation+Math.PI/2,s=this.findPointOnLine2(e,t,100);return new qr(e,{...s,z:e.z})}findIntersectionPoint(e,t){const s=e.startPoint,o=e.endPoint,h=new Z().subVectors(o,s).normalize(),g=new Z().subVectors(t,s).dot(h),b=new Z().copy(h).multiplyScalar(g);return new Z().addVectors(s,b)}};lo.typeName="AlignedDimension";let xi=lo;const ho=class ho extends Mr{constructor(e,t,s,o,h=null,u=null){super(),this._arcPoint=new Y().copy(o),this._xLine1Point=new Y().copy(t),this._xLine2Point=new Y().copy(s),this._centerPoint=new Y().copy(e),this.dimensionText=h,this.dimensionStyleName=u}get arcPoint(){return this._arcPoint}set arcPoint(e){this._arcPoint.copy(e)}get centerPoint(){return this._centerPoint}set centerPoint(e){this._centerPoint.copy(e)}get xLine1Point(){return this._xLine1Point}set xLine1Point(e){this._xLine1Point.copy(e)}get xLine2Point(){return this._xLine2Point}set xLine2Point(e){this._xLine2Point.copy(e)}get geometricExtents(){return new De}};ho.typeName="ArcDimension";let ma=ho;const co=class co extends Mr{constructor(e,t,s=0,o=null,h=null){super(),this._chordPoint=new Y().copy(e),this._farChordPoint=new Y().copy(t),this._extArcStartAngle=0,this._extArcEndAngle=0,this._leaderLength=s,this.dimensionText=o,this.dimensionStyleName=h}get chordPoint(){return this._chordPoint}set chordPoint(e){this._chordPoint.copy(e)}get farChordPoint(){return this._farChordPoint}set farChordPoint(e){this._farChordPoint.copy(e)}get extArcStartAngle(){return this._extArcStartAngle}set extArcStartAngle(e){this._extArcStartAngle=e}get extArcEndAngle(){return this._extArcEndAngle}set extArcEndAngle(e){this._extArcEndAngle=e}get leaderLength(){return this._leaderLength}get geometricExtents(){return new De}drawLines(e,t){const s=[],o=t.length;return o==1?s.push(this.drawLine(e,t[0],{firstArrow:this.firstArrowStyle})):o==3?(this.sortLines(t),s.push(this.drawLine(e,t[0],{firstArrow:this.firstArrowStyle})),s.push(this.drawLine(e,t[1])),s.push(this.drawLine(e,t[2],{firstArrow:this.firstArrowStyle}))):t.forEach(h=>{s.push(this.drawLine(e,h))}),s}drawLine(e,t,s){if(s){const o=[t.startPoint,t.endPoint];return e.lines(o,{...this.lineStyle,arrows:s})}else return t.draw(e)}sortLines(e){const t=(s,o)=>s.x!==o.x?s.x-o.x:s.y!==o.y?s.y-o.y:s.z-o.z;e.sort((s,o)=>{const h=t(s.startPoint,o.startPoint);return h!==0?h:t(s.endPoint,o.endPoint)})}};co.typeName="DiametricDimension";let wi=co;const uo=class uo extends Mr{constructor(e,t,s=null,o=null){super(),this._definingPoint=new Y().copy(e),this._leaderEndPoint=new Y().copy(t),this.dimensionText=s,this.dimensionStyleName=o}get definingPoint(){return this._definingPoint}set definingPoint(e){this._definingPoint.copy(e)}get leaderEndPoint(){return this._leaderEndPoint}set leaderEndPoint(e){this._leaderEndPoint.copy(e)}get geometricExtents(){return new De}get arrowLineCount(){return 0}};uo.typeName="OrdinateDimension";let Ai=uo;const mo=class mo extends Mr{constructor(e,t,s,o=null,h=null){super(),this._center=new Y().copy(e),this._chordPoint=new Y().copy(t),this._leaderLength=s,this._extArcStartAngle=0,this._extArcEndAngle=0,this.dimensionText=o,this.dimensionStyleName=h}get center(){return this._center}set center(e){this._center.copy(e)}get chordPoint(){return this._chordPoint}set chordPoint(e){this._chordPoint.copy(e)}get extArcStartAngle(){return this._extArcStartAngle}set extArcStartAngle(e){this._extArcStartAngle=e}get extArcEndAngle(){return this._extArcEndAngle}set extArcEndAngle(e){this._extArcEndAngle=e}get leaderLength(){return this._leaderLength}set leaderLenght(e){this._leaderLength=e}get geometricExtents(){return new De}getLineArrowStyle(e){return{secondArrow:this.secondArrowStyle}}};mo.typeName="RadialDimension";let Si=mo;class qo{convert(e){const t=this.createEntity(e);return t&&this.processCommonAttrs(e,t),t}createEntity(e){return e.type=="3DFACE"?this.convertFace(e):e.type=="ARC"?this.convertArc(e):e.type=="CIRCLE"?this.convertCirle(e):e.type=="DIMENSION"?this.convertDimension(e):e.type=="ELLIPSE"?this.convertEllipse(e):e.type=="HATCH"?this.convertHatch(e):e.type=="IMAGE"?this.convertImage(e):e.type=="LEADER"?this.convertLeader(e):e.type=="LINE"?this.convertLine(e):e.type=="MTEXT"?this.convertMText(e):e.type=="POLYLINE"||e.type=="LWPOLYLINE"?this.convertPolyline(e):e.type=="POINT"?this.convertPoint(e):e.type=="RAY"?this.convertRay(e):e.type=="SPLINE"?this.convertSpline(e):e.type=="ACAD_TABLE"?this.convertTable(e):e.type=="TEXT"?this.convertText(e):e.type=="SOLID"?this.convertSolid(e):e.type=="VIEWPORT"?this.convertViewport(e):e.type=="WIPEOUT"?this.convertWipeout(e):e.type=="XLINE"?this.convertXline(e):e.type=="INSERT"?this.convertBlockReference(e):null}convertFace(e){const t=new ai;return e.vertices.forEach((s,o)=>t.setVertexAt(o,s)),t}convertArc(e){return new ni(e.center,e.radius,Ee.degToRad(e.startAngle),Ee.degToRad(e.endAngle))}convertCirle(e){return new si(e.center,e.radius)}convertEllipse(e){const t=new Z(e.majorAxisEndPoint),s=t.length();return new ii(e.center,e.extrusionDirection??Z.Z_AXIS,t,s,s*e.axisRatio,e.startAngle,e.endAngle)}convertLine(e){const t=e.startPoint,s=e.endPoint;return new hi(new Y(t.x,t.y,t.z||0),new Y(s.x,s.y,s.z||0))}convertSpline(e){if(e.numberOfControlPoints>0&&e.numberOfKnots>0)return new Os(e.controlPoints,e.knots,e.weights,e.degree,!!(e.flag&1));if(e.numberOfFitPoints>0){const t=this.numberArrayToPointArray(e.fitPoints,e.numberOfFitPoints);if(t!=null)return new Os(t,"Uniform",e.degree,!!(e.flag&1))}return null}convertPoint(e){const t=new gi;return t.position=e.position,t}convertSolid(e){const t=new mi;return e.points.forEach((s,o)=>t.setPointAt(o,s)),t.thickness=e.thickness,t}convertPolyline(e){const t=new pi;return t.closed=!!(e.flag&1),e.vertices.forEach((s,o)=>{t.addVertexAt(o,new Me(s.x,s.y),s.bulge,s.startWidth,s.endWidth)}),t}convertHatch(e){var o;const t=new oi;return(o=e.definitionLines)==null||o.forEach(h=>{t.definitionLines.push({angle:h.angle,origin:h.base,delta:h.offset,dashPattern:h.numberOfDashLengths>0?h.dashLengths:[]})}),t.hatchStyle=e.hatchStyle,t.patternName=e.patternName,t.patternType=e.patternType,t.patternAngle=e.patternAngle==null?0:e.patternAngle,t.patternScale=e.patternScale==null?0:e.patternScale,e.boundaryPaths.forEach(h=>{if(h.boundaryPathTypeFlag&2){const g=h,b=new Bs;b.closed=g.isClosed,g.vertices.forEach((f,S)=>{b.addVertexAt(S,{x:f.x,y:f.y,bulge:f.bulge})}),t.add(b)}else{const g=h,b=new Zh;g.edges.forEach(f=>{if(f.type==1){const S=f;b.add(new Oi(S.start,S.end))}else if(f.type==2){const S=f;b.add(new Dn(S.center,S.radius,Ee.degToRad(S.startAngle||0),Ee.degToRad(S.endAngle||0),!S.isCCW))}else if(f.type==3){const S=f;new $e().subVectors(S.end,S.center);const E=Math.sqrt(Math.pow(S.end.x,2)+Math.pow(S.end.y,2)),M=E*S.lengthOfMinorAxis;let z=Ee.degToRad(S.startAngle||0),D=Ee.degToRad(S.endAngle||0);const U=Math.atan2(S.end.y,S.end.x);S.isCCW||(z=Math.PI*2-z,D=Math.PI*2-D),b.add(new Ci({...S.center,z:0},E,M,z,D,!S.isCCW,U))}else if(f.type==4){const S=f;if(S.numberOfControlPoints>0&&S.numberOfKnots>0){const x=S.controlPoints.map(z=>({x:z.x,y:z.y,z:0}));let E=!0;const M=S.controlPoints.map(z=>(z.weight==null&&(E=!1),z.weight||1));b.add(new Yr(x,S.knots,E?M:void 0))}else if(S.numberOfFitData>0){const x=S.fitDatum.map(E=>({x:E.x,y:E.y,z:0}));b.add(new Yr(x,"Uniform"))}}}),t.add(b)}}),t}convertTable(e){const t=new ui(e.name,e.rowCount,e.columnCount);return t.attachmentPoint=e.attachmentPoint,t.position.copy(e.startPoint),e.columnWidthArr.forEach((s,o)=>t.setColumnWidth(o,s)),e.rowHeightArr.forEach((s,o)=>t.setRowHeight(o,s)),e.cells.forEach((s,o)=>{t.setCell(o,s)}),t}convertText(e){const t=new di;return t.textString=e.text,t.styleName=e.styleName,t.height=e.textHeight,t.position.copy(e.startPoint),t.rotation=Ee.degToRad(e.rotation||0),t.oblique=e.obliqueAngle??0,t.thickness=e.thickness,t.horizontalMode=e.halign,t.verticalMode=e.valign,t.widthFactor=e.xScale??1,t}convertMText(e){const t=new ci;return t.contents=e.text,e.styleName!=null&&(t.styleName=e.styleName),t.height=e.height,t.width=e.width,t.rotation=Ee.degToRad(e.rotation||0),t.location=e.insertionPoint,t.attachmentPoint=e.attachmentPoint,e.direction&&(t.direction=new Z(e.direction)),t.drawingDirection=e.drawingDirection,t}convertLeader(e){const t=new li;return e.vertices.forEach(s=>{t.appendVertex(s)}),t.hasArrowHead=e.isArrowheadEnabled,t.hasHookLine=e.isHooklineExists,t.isSplined=e.isSpline,t.dimensionStyle=e.styleName,t.annoType=e.leaderCreationFlag,t}convertDimension(e){if(e.subclassMarker=="AcDbAlignedDimension"||e.subclassMarker=="AcDbRotatedDimension"){const t=e,s=new xi(t.subDefinitionPoint1,t.subDefinitionPoint2,t.definitionPoint);return s.rotation=Ee.degToRad(t.rotationAngle||0),this.processDimensionCommonAttrs(e,s),s}else if(e.subclassMarker=="AcDb3PointAngularDimension"){const t=e,s=new bi(t.centerPoint,t.subDefinitionPoint1,t.subDefinitionPoint2,t.definitionPoint);return this.processDimensionCommonAttrs(e,s),s}else if(e.subclassMarker=="AcDbOrdinateDimension"){const t=e,s=new Ai(t.subDefinitionPoint1,t.subDefinitionPoint2);return this.processDimensionCommonAttrs(e,s),s}else if(e.subclassMarker=="AcDbRadialDimension"){const t=e,s=new Si(t.definitionPoint,t.centerPoint,t.leaderLength);return this.processDimensionCommonAttrs(e,s),s}else if(e.subclassMarker=="AcDbDiametricDimension"){const t=e,s=new wi(t.definitionPoint,t.centerPoint,t.leaderLength);return this.processDimensionCommonAttrs(e,s),s}return null}processImage(e,t){t.position.copy(e.position),t.brightness=e.brightness,t.contrast=e.contrast,t.fade=e.fade,t.isShownClipped=(e.flags|4)>0,t.isImageShown=(e.flags|3)>0,t.isImageTransparent=(e.flags|8)>0,t.imageDefId=e.imageDefHandle,t.isClipped=e.isClipped,e.clippingBoundaryPath.forEach(s=>{t.clipBoundary.push(new Me(s))}),t.width=Math.sqrt(e.uPixel.x**2+e.uPixel.y**2+e.uPixel.z**2)*e.imageSize.x,t.height=Math.sqrt(e.vPixel.x**2+e.vPixel.y**2+e.vPixel.z**2)*e.imageSize.y,t.rotation=Math.atan2(e.uPixel.y,e.uPixel.x)}convertImage(e){const t=new zs;return this.processImage(e,t),t.clipBoundaryType=e.clippingBoundaryType,t}processWipeout(e,t){t.position.copy(e.position),t.brightness=e.brightness,t.contrast=e.contrast,t.fade=e.fade,t.isShownClipped=(e.displayFlag|4)>0,t.isImageShown=(e.displayFlag|3)>0,t.isImageTransparent=(e.displayFlag|8)>0,t.imageDefId=e.imageDefHardId,t.isClipped=e.isClipping,e.boundary.forEach(s=>{t.clipBoundary.push(new Me(s))}),t.clipBoundaryType=e.boundaryType,t.width=Math.sqrt(e.uDirection.x**2+e.uDirection.y**2+e.uDirection.z**2)*e.imageSize.x,t.height=Math.sqrt(e.vDirection.x**2+e.vDirection.y**2+e.vDirection.z**2)*e.imageSize.y,t.rotation=Math.atan2(e.uDirection.y,e.uDirection.x)}convertWipeout(e){const t=new vi;return this.processWipeout(e,t),t}convertViewport(e){const t=new _i;return t.number=e.viewportId,t.centerPoint.copy(e.viewportCenter),t.height=e.height,t.width=e.width,t.viewCenter.copy(e.displayCenter),t.viewHeight=e.viewHeight,t}convertRay(e){const t=new fi;return t.basePoint.copy(e.position),t.unitDir.copy(e.direction),t}convertXline(e){const t=new yi;return t.basePoint.copy(e.position),t.unitDir.copy(e.direction),t}convertBlockReference(e){const t=new Ls(e.name);return e.insertionPoint&&t.position.copy(e.insertionPoint),t.scaleFactors.x=e.xScale||1,t.scaleFactors.y=e.yScale||1,t.scaleFactors.z=e.zScale||1,t.rotation=e.rotation!=null?Ee.degToRad(e.rotation):0,t.normal.copy(e.extrusionDirection??{x:0,y:0,z:1}),t}processDimensionCommonAttrs(e,t){t.dimBlockId=e.name,t.textPosition.copy(e.textPoint),t.textRotation=e.textRotation||0,e.textLineSpacingFactor&&(t.textLineSpacingFactor=e.textLineSpacingFactor),e.textLineSpacingStyle&&(t.textLineSpacingStyle=e.textLineSpacingStyle),t.dimensionStyleName=e.styleName,t.dimensionText=e.text||"",t.measurement=e.measurement}processCommonAttrs(e,t){t.layer=e.layer||"0",e.handle&&(t.objectId=e.handle),t.ownerId=e.ownerBlockRecordSoftId||"",e.lineType!=null&&(t.lineType=e.lineType),e.lineweight!=null&&(t.lineWeight=e.lineweight),e.lineTypeScale!=null&&(t.linetypeScale=e.lineTypeScale),e.color!=null&&(t.color.color=e.color),e.colorIndex!=null&&(t.color.colorIndex=e.colorIndex),e.colorName!=null&&(t.color.colorName=e.colorName),e.isVisible!=null&&(t.visibility=e.isVisible),e.transparency!=null&&(t.transparency=e.transparency)}numberArrayToPointArray(e,t){const s=e.length;let o=0;if(s/2==t?o=2:s/3==t&&(o=3),o==0)return;const h=[];for(let u=0,g=s/o;u<g;++u)h.push({x:e[u*o],y:e[u*o+1],z:o==3?e[u*o+2]:0});return h}}class Ri extends Xr{constructor(){super(),this._tabOrder=-1,this._tabSelected=!1,this._blockTableRecordId="",this._layoutName="",this._limits=new _t,this._extents=new De}get layoutName(){return this._layoutName}set layoutName(e){this._layoutName=e.length>256?e.slice(0,256):e}get tabOrder(){return this._tabOrder}set tabOrder(e){this._tabOrder=e}get tabSelected(){return this._tabSelected}set tabSelected(e){this._tabSelected=e}get blockTableRecordId(){return this._blockTableRecordId}set blockTableRecordId(e){this._blockTableRecordId=e}get limits(){return this._limits}set limits(e){this._limits.copy(e)}get extents(){return this._extents}set extents(e){this._extents.copy(e)}}class za extends Xr{constructor(e){super(),this.database=e,this._recordsByName=new Map,this._recordsById=new Map}get numEntries(){return this._recordsByName.size}setAt(e,t){t.database=this.database,this._recordsByName.set(e,t),this._recordsById.set(t.objectId,t),this.database.events.dictObjetSet.dispatch({database:this.database,object:t,key:e})}remove(e){const t=this.getAt(e);return t?(this._recordsByName.delete(e.toUpperCase()),this._recordsById.delete(this.objectId),this.database.events.dictObjectErased.dispatch({database:this.database,object:t,key:e}),!0):!1}removeId(e){const t=this.getIdAt(e);return t?(this._recordsById.delete(this.objectId),this._recordsByName.forEach((s,o)=>{s===t&&(this._recordsByName.delete(o),this.database.events.dictObjectErased.dispatch({database:this.database,object:t,key:o}))}),!0):!1}removeAll(){this._recordsByName.forEach((e,t)=>{this.database.events.dictObjectErased.dispatch({database:this.database,object:e,key:t})}),this._recordsByName.clear(),this._recordsById.clear()}has(e){return this._recordsByName.has(e.toUpperCase())}hasId(e){return this._recordsById.has(e)}getAt(e){return this._recordsByName.get(e)}getIdAt(e){return this._recordsById.get(e)}newIterator(){return new Mi(this._recordsByName)}}class hc extends za{getBtrIdAt(e){for(const[t,s]of this._recordsByName)if(s.blockTableRecordId==e)return s}get maxTabOrder(){let e=-1;return this._recordsByName.forEach(t=>{t.tabOrder>e&&(e=t.tabOrder)}),e}}class cc extends Xr{constructor(){super(),this._sourceFileName=""}get sourceFileName(){return this._sourceFileName}set sourceFileName(e){this._sourceFileName=e}}class $d{convertLayout(e,t){var o;const s=new Ri;return s.layoutName=e.layoutName,s.tabOrder=e.tabOrder,(o=t.tables.BLOCK_RECORD)==null||o.entries.some(h=>h.layoutObjects===e.handle?(s.blockTableRecordId=h.handle,!0):!1),s.limits.min.copy(e.minLimit),s.limits.max.copy(e.maxLimit),s.extents.min.copy(e.minExtent),s.extents.max.copy(e.maxExtent),this.processCommonAttrs(e,s),s}convertImageDef(e){const t=new cc;return t.sourceFileName=e.fileName,this.processCommonAttrs(e,t),t}processCommonAttrs(e,t){t.objectId=e.handle,t.ownerId=e.ownerObjectId}}class uc{constructor(e){this.taskId=0,this.workers=new Map,this.pendingTasks=new Map,this.config={workerUrl:e.workerUrl,timeout:e.timeout??3e4,maxConcurrentWorkers:e.maxConcurrentWorkers??4}}async execute(e,t){const s=Date.now(),o=this.generateTaskId();try{return await this.executeInWorker(o,e,t||this.config.workerUrl)}catch(h){const u=Date.now()-s;return{success:!1,error:h instanceof Error?h.message:String(h),duration:u}}}async executeInWorker(e,t,s){const o=Date.now();return new Promise((h,u)=>{const g=this.getAvailableWorker(s),b=setTimeout(()=>{this.cleanupTask(e),this.releaseWorker(g),u(new Error(`Worker operation timed out after ${this.config.timeout}ms`))},this.config.timeout);this.pendingTasks.set(e,{resolve:x=>{clearTimeout(b),this.releaseWorker(g),h(x)},reject:x=>{clearTimeout(b),this.releaseWorker(g),u(x)},timeout:b});const f=x=>{const{id:E,success:M,data:z,error:D}=x.data;if(E!==e)return;this.cleanupTask(e);const U=Date.now()-o;h(M?{success:!0,data:z,duration:U}:{success:!1,error:D,duration:U})},S=x=>{this.cleanupTask(e),u(new Error(`Worker error: ${x.message}`))};g.addEventListener("message",f),g.addEventListener("error",S),g.postMessage({id:e,input:t})})}cleanupTask(e){const t=this.pendingTasks.get(e);t&&(clearTimeout(t.timeout),this.pendingTasks.delete(e))}generateTaskId(){return`task_${++this.taskId}_${Date.now()}`}detectWorkerSupport(){return typeof Worker<"u"}getAvailableWorker(e){for(const[s,o]of this.workers)if(!o.isBusy)return o.isBusy=!0,o.worker;if(this.workers.size<this.config.maxConcurrentWorkers){const s=new Worker(e,{type:"module"}),o=this.generateWorkerId(),h={worker:s,isBusy:!0,id:o,createdAt:new Date};return this.workers.set(o,h),s}const t=Array.from(this.workers.values()).sort((s,o)=>s.createdAt.getTime()-o.createdAt.getTime())[0];return t.isBusy=!0,t.worker}releaseWorker(e){for(const[t,s]of this.workers)if(s.worker===e){s.isBusy=!1;break}}generateWorkerId(){return`worker_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}getStats(){return{totalWorkers:this.workers.size,busyWorkers:Array.from(this.workers.values()).filter(e=>e.isBusy).length,pendingTasks:this.pendingTasks.size,config:this.config}}destroy(){for(const[e,t]of this.pendingTasks)clearTimeout(t.timeout),t.reject(new Error("Framework destroyed"));this.pendingTasks.clear();for(const[e,t]of this.workers)t.worker.terminate();this.workers.clear()}}class dc{constructor(e){this.framework=new uc(e)}async execute(e,t){return this.framework.execute(e,t)}getStats(){return this.framework.getStats()}destroy(){this.framework.destroy()}}function mc(i){return new dc(i)}class Zd{constructor(){this.setupMessageHandler()}setupMessageHandler(){self.onmessage=async e=>{const{id:t,input:s}=e.data;try{const o=await this.executeTask(s);this.sendResponse(t,!0,o)}catch(o){this.sendResponse(t,!1,void 0,o instanceof Error?o.message:String(o))}}}sendResponse(e,t,s,o){const h={id:e,success:t,data:s,error:o};self.postMessage(h)}}class pc extends vh{constructor(e={}){super(e),e.parserWorkerUrl||(e.parserWorkerUrl="/assets/dxf-parser-worker.js")}async parse(e){if(this.config.useWorker&&this.config.parserWorkerUrl){const t=mc({workerUrl:this.config.parserWorkerUrl,maxConcurrentWorkers:1}),s=await t.execute(e);return t.destroy(),{model:s.data,data:{unknownEntityCount:0}}}else return{model:new Dd().parseSync(e),data:{unknownEntityCount:0}}}getFonts(e){var h;const t=new Map,s=u=>{if(u){const g=u.lastIndexOf(".");return g>=0?u.substring(0,g).toLowerCase():u.toLowerCase()}};(h=e.tables.STYLE)==null||h.entries.forEach(u=>{const g=[];let b=s(u.font);b&&g.push(b),b=s(u.bigFont),b&&g.push(b),t.set(u.name,g)});const o=new Set;return this.getFontsInBlock(e.entities,e.blocks,t,o),Array.from(o)}getFontsInBlock(e,t,s,o){const h=/\\f(.*?)\|/g;e.forEach(u=>{if(u.type=="MTEXT"){const g=u;[...g.text.matchAll(h)].forEach(S=>{o.add(S[1].toLowerCase())});const f=s.get(g.styleName);f==null||f.forEach(S=>o.add(S))}else if(u.type=="TEXT"){const g=u,b=s.get(g.styleName);b==null||b.forEach(f=>o.add(f))}else if(u.type=="INSERT"){const b=t[u.name];b&&b.entities&&this.getFontsInBlock(b.entities,t,s,o)}})}async processEntities(e,t,s,o,h){const u=new qo;let g=e.entities;const b=g.length,f=new il(b,100-o.value,s);this.config.convertByEntityType&&(g=this.groupAndFlattenByType(g));const S=t.tables.blockTable.modelSpace;await f.processChunk(async(x,E)=>{let M=[],z=x<E?g[x].type:"";for(let D=x;D<E;D++){const U=g[D],B=u.convert(U);B&&(this.config.convertByEntityType&&U.type!==z&&(S.appendEntity(M),M=[],z=U.type),M.push(B))}if(S.appendEntity(M),h){let D=o.value+E/b*(100-o.value);D>100&&(D=100),await h(D,"ENTITY","IN-PROGRESS")}})}async processEntitiesInBlock(e,t){const s=new qo,o=e.length,h=[];for(let u=0;u<o;u++){const g=e[u],b=s.convert(g);b&&h.push(b)}t.appendEntity(h)}processBlocks(e,t){const s=e.blocks;for(const[o,h]of Object.entries(s)){let u=t.tables.blockTable.getAt(h.name);u||(u=new Ft,u.objectId=h.handle,u.name=o,u.origin.copy(h.position),t.tables.blockTable.add(u)),h.entities&&this.processEntitiesInBlock(h.entities,u)}}processHeader(e,t){const s=e.header;t.cecolor.colorIndex=s.$CECOLOR||256,t.angBase=s.$ANGBASE||0,t.angDir=s.$ANGDIR||0,s.$AUNITS!=null&&(t.aunits=s.$AUNITS),s.$EXTMAX&&(t.extmax=s.$EXTMAX),s.$EXTMIN&&(t.extmin=s.$EXTMIN),s.$INSUNITS!=null&&(t.insunits=s.$INSUNITS),t.pdmode=s.$PDMODE||0,t.pdsize=s.$PDSIZE||0}processBlockTables(e,t){var o;const s=(o=e.tables.BLOCK_RECORD)==null?void 0:o.entries;s&&s.length>0&&(t.tables.blockTable.removeAll(),s.forEach(h=>{const u=new Ft;u.objectId=h.handle,u.name=h.name,u.layoutId=h.layoutObjects,t.tables.blockTable.add(u)}))}processObjects(e,t){const s=e.objects.byName,o=new $d;if("LAYOUT"in s){const h=t.dictionaries.layouts;s.LAYOUT.forEach(u=>{const g=o.convertLayout(u,e);h.setAt(g.layoutName,g)})}if("IMAGEDEF"in s){const h=t.dictionaries.imageDefs;s.IMAGEDEF.forEach(u=>{const g=o.convertImageDef(u);h.setAt(g.objectId,g)})}}processViewports(e,t){var o,h;const s=(h=(o=e.tables)==null?void 0:o.VPORT)==null?void 0:h.entries;s&&s.length>0&&s.forEach(u=>{const g=new Ic;this.processCommonTableEntryAttrs(u,g),u.circleSides&&(g.circleSides=u.circleSides),g.standardFlag=u.standardFlag,g.center.copy(u.center),g.lowerLeftCorner.copy(u.lowerLeftCorner),g.upperRightCorner.copy(u.upperRightCorner),u.snapBasePoint&&g.snapBase.copy(u.snapBasePoint),u.snapRotationAngle&&(g.snapAngle=u.snapRotationAngle),u.snapSpacing&&g.snapIncrements.copy(u.snapSpacing),u.majorGridLines&&(g.gridMajor=u.majorGridLines),u.gridSpacing&&g.gridIncrements.copy(u.gridSpacing),u.backgroundObjectId&&(g.backgroundObjectId=u.backgroundObjectId),g.gsView.center.copy(u.center),g.gsView.viewDirectionFromTarget.copy(u.viewDirectionFromTarget),g.gsView.viewTarget.copy(u.viewTarget),u.lensLength&&(g.gsView.lensLength=u.lensLength),u.frontClippingPlane&&(g.gsView.frontClippingPlane=u.frontClippingPlane),u.backClippingPlane&&(g.gsView.backClippingPlane=u.backClippingPlane),u.viewHeight&&(g.gsView.viewHeight=u.viewHeight),u.viewTwistAngle&&(g.gsView.viewTwistAngle=u.viewTwistAngle),u.frozenLayers&&(g.gsView.frozenLayers=u.frozenLayers),u.styleSheet&&(g.gsView.styleSheet=u.styleSheet),u.renderMode&&(g.gsView.renderMode=u.renderMode),u.viewMode&&(g.gsView.viewMode=u.viewMode),u.ucsIconSetting&&(g.gsView.ucsIconSetting=u.ucsIconSetting),u.ucsOrigin&&g.gsView.ucsOrigin.copy(u.ucsOrigin),u.ucsXAxis&&g.gsView.ucsXAxis.copy(u.ucsXAxis),u.ucsYAxis&&g.gsView.ucsYAxis.copy(u.ucsYAxis),u.orthographicType&&(g.gsView.orthographicType=u.orthographicType),u.shadePlotSetting&&(g.gsView.shadePlotSetting=u.shadePlotSetting),u.shadePlotObjectId&&(g.gsView.shadePlotObjectId=u.shadePlotObjectId),u.visualStyleObjectId&&(g.gsView.visualStyleObjectId=u.visualStyleObjectId),u.isDefaultLightingOn&&(g.gsView.isDefaultLightingOn=u.isDefaultLightingOn),u.defaultLightingType&&(g.gsView.defaultLightingType=u.defaultLightingType),u.brightness&&(g.gsView.brightness=u.brightness),u.contrast&&(g.gsView.contrast=u.contrast),u.ambientColor&&(g.gsView.ambientColor=u.ambientColor),t.tables.viewportTable.add(g)})}processLayers(e,t){var o,h;const s=(h=(o=e.tables)==null?void 0:o.LAYER)==null?void 0:h.entries;s&&s.length>0&&s.forEach(u=>{const g=new Wr;g.colorIndex=u.colorIndex;const b=new Bi({name:u.name,standardFlags:u.standardFlag,linetype:u.lineType,lineWeight:u.lineweight,isOff:u.colorIndex<0,color:g,isPlottable:u.isPlotting});this.processCommonTableEntryAttrs(u,b),t.tables.layerTable.add(b)})}processLineTypes(e,t){var o,h;const s=(h=(o=e.tables)==null?void 0:o.LTYPE)==null?void 0:h.entries;s&&s.length>0&&s.forEach(u=>{const g=new Cs(u);this.processCommonTableEntryAttrs(u,g),g.name=u.name,t.tables.linetypeTable.add(g)})}processTextStyles(e,t){var o;const s=(o=e.tables.STYLE)==null?void 0:o.entries;s&&s.length>0&&s.forEach(h=>{const u=new Da(h);this.processCommonTableEntryAttrs(h,u),t.tables.textStyleTable.add(u)})}processDimStyles(e,t){var o;const s=(o=e.tables.DIMSTYLE)==null?void 0:o.entries;s&&s.length>0&&s.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},g=new Bn(u);this.processCommonTableEntryAttrs(h,g),t.tables.dimStyleTable.add(g)})}processCommonTableEntryAttrs(e,t){t.name=e.name,t.objectId=e.handle,t.ownerId=e.ownerObjectId}groupAndFlattenByType(e){const t={},s=[];for(const o of e)t[o.type]||(t[o.type]=[],s.push(o.type)),t[o.type].push(o);return s.flatMap(o=>t[o])}}var Ns=(i=>(i.DXF="dxf",i.DWG="dwg",i))(Ns||{});class lr{constructor(){this.events={registered:new it,unregistered:new it},this._converters=new Map,this.register("dxf",new pc)}static createInstance(){return lr._instance==null&&(lr._instance=new lr),this._instance}static get instance(){return lr._instance||(lr._instance=new lr),lr._instance}get fileTypes(){return this._converters.keys()}register(e,t){this._converters.set(e,t),this.events.registered.dispatch({fileType:e,converter:t})}get(e){return this._converters.get(e)}unregister(e){const t=this._converters.get(e);t&&(this._converters.delete(e),this.events.unregistered.dispatch({fileType:e,converter:t}))}}class _n extends Xr{constructor(e,t){e=e||{},Fn(e,{name:""}),super(e,t)}get name(){return this.getAttr("name")}set name(e){this.setAttr("name",e)}}const jr=class jr extends _n{static isModelSapceName(e){return e.toLowerCase()==jr.MODEL_SPACE_NAME.toLowerCase()}static isPaperSapceName(e){return e.toLowerCase().startsWith(jr.PAPER_SPACE_NAME_PREFIX.toLowerCase())}constructor(){super(),this._origin=new Y,this._layoutId="",this._entities=new Map}get isModelSapce(){return jr.isModelSapceName(this.name)}get isPaperSapce(){return jr.isPaperSapceName(this.name)}get origin(){return this._origin}set origin(e){this._origin.copy(e)}get layoutId(){return this._layoutId}set layoutId(e){this._layoutId=e}appendEntity(e){if(Array.isArray(e))for(let t=0;t<e.length;++t){const s=e[t];s.database=this.database,s.ownerId=this.objectId,this._entities.set(s.objectId,s)}else e.database=this.database,e.ownerId=this.objectId,this._entities.set(e.objectId,e);(this.isModelSapce||this.isPaperSapce)&&this.database.events.entityAppended.dispatch({database:this.database,entity:e})}newIterator(){return new Mi(this._entities)}getIdAt(e){return this._entities.get(e)}};jr.MODEL_SPACE_NAME="*MODEL_SPACE",jr.PAPER_SPACE_NAME_PREFIX="*PAPER_SPACE";let Ft=jr;class vn extends Xr{constructor(e){super(),this.database=e,this._recordsByName=new Map,this._recordsById=new Map}get numEntries(){return this._recordsByName.size}add(e){e.database=this.database;const t=this.normalizeName(e.name);this._recordsByName.set(t,e),this._recordsById.set(e.objectId,e)}remove(e){const t=this.normalizeName(e),s=this._recordsByName.get(t);return s?(this._recordsById.delete(s.objectId),this._recordsByName.delete(e),!0):!1}removeId(e){const t=this._recordsById.get(e);return t?(this._recordsByName.delete(t.name),this._recordsById.delete(e),!0):!1}removeAll(){this._recordsByName.clear(),this._recordsById.clear()}has(e){const t=this.normalizeName(e);return this._recordsByName.has(t)}hasId(e){return this._recordsById.has(e)}getAt(e){const t=this.normalizeName(e);return this._recordsByName.get(t)}getIdAt(e){return this._recordsById.get(e)}getOwnerIdAt(e){return this._recordsById.get(e)}newIterator(){return new Mi(this._recordsByName)}normalizeName(e){return e}}class gc extends vn{constructor(e){super(e)}get modelSpace(){let e=this.getAt(Ft.MODEL_SPACE_NAME);return e||(e=new Ft,e.name=Ft.MODEL_SPACE_NAME,this.add(e)),e}normalizeName(e){let t=e;if(Ft.isModelSapceName(e))t=Ft.MODEL_SPACE_NAME;else if(Ft.isPaperSapceName(e)){const s=Ft.PAPER_SPACE_NAME_PREFIX,o=e.substring(s.length);t=s+o}return t}}class fc extends vn{constructor(e){super(e)}}class Bi extends _n{constructor(e,t){e=e||{},Fn(e,{color:new Wr,description:"",standardFlags:0,isHidden:!1,isInUse:!0,isOff:!1,isPlottable:!0,transparency:0,linetype:"",lineWeight:1,materialId:-1}),super(e,t),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(e){this.setAttr("color",e.clone())}get description(){return this.getAttr("description")}set description(e){this.setAttr("description",e)}get standardFlags(){return this.getAttr("standardFlags")}set standardFlags(e){this.setAttr("standardFlags",e)}get isFrozen(){return(this.standardFlags&1)==1}set isFrozen(e){const t=e?1:0;this.standardFlags=this.standardFlags|t}get isHidden(){return this.getAttr("isHidden")}set isHidden(e){this.setAttr("isHidden",e)}get isInUse(){return this.getAttr("isInUse")}set isInUse(e){this.setAttr("isInUse",e)}get isLocked(){return(this.standardFlags&4)==4}set isLocked(e){const t=e?4:0;this.standardFlags=this.standardFlags|t}get isOff(){return this.getAttr("isOff")}set isOff(e){this.setAttr("isOff",e)}get isPlottable(){return this.getAttr("isPlottable")}set isPlottable(e){this.setAttr("isPlottable",e)}get transparency(){return this.getAttr("transparency")}set transparency(e){this.setAttr("transparency",e)}get linetype(){return this.getAttr("linetype")}set linetype(e){this.setAttr("linetype",e)}get lineWeight(){return this.getAttr("lineWeight")}set lineWeight(e){this.setAttr("lineWeight",e)}get materialId(){return this.getAttr("materialId")}set materialId(e){this.setAttr("materialId",e)}}class _c extends vn{constructor(e){super(e);const t=new Wr;t.color=16777215;const s=new Bi({name:"0",standardFlags:0,linetype:ti,lineWeight:1,isOff:!1,color:t,isPlottable:!0});this.add(s)}add(e){super.add(e),this.database.events.layerAppended.dispatch({database:this.database,layer:e})}}class vc extends vn{constructor(e){super(e)}}class yc extends vn{constructor(e){super(e)}get fonts(){const e=new Set,t=o=>{if(o){const h=o.lastIndexOf(".");if(h>=0){const u=o.substring(0,h).toLowerCase();e.add(u)}else e.add(o.toLowerCase())}},s=this.newIterator();for(const o of s)t(o.fileName),t(o.bigFontFileName);return Array.from(e)}}class bc extends vn{constructor(e){super(e)}}class Cs extends _n{constructor(e){super(),this.name=e.name,this._linetype=e}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(e){if(e<0||e>=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[e].elementLength}}class Da extends _n{constructor(e){super(),this.name=e.name,this._textStyle=e,this._textStyle.font=this.getFileNameWithoutExtension(this._textStyle.font||this._textStyle.extendedFont||this.name),this._isVertical=!1}get obliquingAngle(){return this._textStyle.obliqueAngle}set obliquingAngle(e){this._textStyle.obliqueAngle=e}get priorSize(){return this._textStyle.lastHeight}set priorSize(e){this._textStyle.lastHeight=e}get textSize(){return this._textStyle.fixedTextHeight}set textSize(e){this._textStyle.fixedTextHeight=e}get xScale(){return this._textStyle.widthFactor}set xScale(e){this._textStyle.widthFactor=e}get isVertical(){return this._isVertical}set isVertical(e){this._isVertical=e}get fileName(){return this._textStyle.font}set fileName(e){this._textStyle.font=e}get bigFontFileName(){return this._textStyle.bigFont}set bigFontFileName(e){this._textStyle.bigFont=e}get textStyle(){return this._textStyle}getFileNameWithoutExtension(e){const t=e.split("/").pop();if(t){const s=t.lastIndexOf(".");return s===-1?t:t.substring(0,s)}return e}}var xc=(i=>(i[i.Center=0]="Center",i[i.Left=1]="Left",i[i.Right=2]="Right",i[i.OverFirst=3]="OverFirst",i[i.OverSecond=4]="OverSecond",i))(xc||{}),wc=(i=>(i[i.Center=0]="Center",i[i.Above=1]="Above",i[i.Outside=2]="Outside",i[i.JIS=3]="JIS",i[i.Below=4]="Below",i))(wc||{}),Ac=(i=>(i[i.Feet=0]="Feet",i[i.None=1]="None",i[i.Inch=2]="Inch",i[i.FeetAndInch=3]="FeetAndInch",i[i.Leading=4]="Leading",i[i.Trailing=8]="Trailing",i[i.LeadingAndTrailing=12]="LeadingAndTrailing",i))(Ac||{}),Sc=(i=>(i[i.None=0]="None",i[i.Leading=1]="Leading",i[i.Trailing=2]="Trailing",i[i.LeadingAndTrailing=3]="LeadingAndTrailing",i))(Sc||{}),Pc=(i=>(i[i.Bottom=0]="Bottom",i[i.Middle=1]="Middle",i[i.Top=2]="Top",i))(Pc||{});const Ii=class Ii extends _n{constructor(e,t){e=e||{},Fn(e,Ii.DEFAULT_DIM_VALUES),super(e,t)}get dimpost(){return this.getAttr("dimpost")}set dimpost(e){this.setAttr("dimpost",e)}get dimapost(){return this.getAttr("dimapost")}set dimapost(e){this.setAttr("dimapost",e)}get dimscale(){return this.getAttr("dimscale")}set dimscale(e){this.setAttr("dimscale",e)}get dimasz(){return this.getAttr("dimasz")}set dimasz(e){this.setAttr("dimasz",e)}get dimexo(){return this.getAttr("dimexo")}set dimexo(e){this.setAttr("dimexo",e)}get dimdli(){return this.getAttr("dimdli")}set dimdli(e){this.setAttr("dimdli",e)}get dimexe(){return this.getAttr("dimexe")}set dimexe(e){this.setAttr("dimexe",e)}get dimrnd(){return this.getAttr("dimrnd")}set dimrnd(e){this.setAttr("dimrnd",e)}get dimdle(){return this.getAttr("dimdle")}set dimdle(e){this.setAttr("dimdle",e)}get dimtp(){return this.getAttr("dimtp")}set dimtp(e){this.setAttr("dimtp",e)}get dimtm(){return this.getAttr("dimtm")}set dimtm(e){this.setAttr("dimtm",e)}get dimtxt(){return this.getAttr("dimtxt")}set dimtxt(e){this.setAttr("dimtxt",e)}get dimcen(){return this.getAttr("dimcen")}set dimcen(e){this.setAttr("dimcen",e)}get dimtsz(){return this.getAttr("dimtsz")}set dimtsz(e){this.setAttr("dimtsz",e)}get dimaltf(){return this.getAttr("dimaltf")}set dimaltf(e){this.setAttr("dimaltf",e)}get dimlfac(){return this.getAttr("dimlfac")}set dimlfac(e){this.setAttr("dimlfac",e)}get dimtvp(){return this.getAttr("dimtvp")}set dimtvp(e){this.setAttr("dimtvp",e)}get dimtfac(){return this.getAttr("dimtfac")}set dimtfac(e){this.setAttr("dimtfac",e)}get dimgap(){return this.getAttr("dimgap")}set dimgap(e){this.setAttr("dimgap",e)}get dimaltrnd(){return this.getAttr("dimaltrnd")}set dimaltrnd(e){this.setAttr("dimaltrnd",e)}get dimtol(){return this.getAttr("dimtol")}set dimtol(e){this.setAttr("dimtol",e)}get dimlim(){return this.getAttr("dimlim")}set dimlim(e){this.setAttr("dimlim",e)}get dimtih(){return this.getAttr("dimtih")}set dimtih(e){this.setAttr("dimtih",e)}get dimtoh(){return this.getAttr("dimtoh")}set dimtoh(e){this.setAttr("dimtoh",e)}get dimse1(){return this.getAttr("dimse1")}set dimse1(e){this.setAttr("dimse1",e)}get dimse2(){return this.getAttr("dimse2")}set dimse2(e){this.setAttr("dimse2",e)}get dimtad(){return this.getAttr("dimtad")}set dimtad(e){this.setAttr("dimtad",e)}get dimzin(){return this.getAttr("dimzin")}set dimzin(e){this.setAttr("dimzin",e)}get dimazin(){return this.getAttr("dimazin")}set dimazin(e){this.setAttr("dimazin",e)}get dimalt(){return this.getAttr("dimalt")}set dimalt(e){this.setAttr("dimalt",e)}get dimaltd(){return this.getAttr("dimaltd")}set dimaltd(e){this.setAttr("dimaltd",e)}get dimtofl(){return this.getAttr("dimtofl")}set dimtofl(e){this.setAttr("dimtofl",e)}get dimsah(){return this.getAttr("dimsah")}set dimsah(e){this.setAttr("dimsah",e)}get dimtix(){return this.getAttr("dimtix")}set dimtix(e){this.setAttr("dimtix",e)}get dimsoxd(){return this.getAttr("dimsoxd")}set dimsoxd(e){this.setAttr("dimsoxd",e)}get dimclrd(){return this.getAttr("dimclrd")}set dimclrd(e){this.setAttr("dimclrd",e)}get dimclre(){return this.getAttr("dimclre")}set dimclre(e){this.setAttr("dimclre",e)}get dimclrt(){return this.getAttr("dimclrt")}set dimclrt(e){this.setAttr("dimclrt",e)}get dimadec(){return this.getAttr("dimadec")}set dimadec(e){this.setAttr("dimadec",e)}get dimunit(){return this.getAttr("dimunit")}set dimunit(e){this.setAttr("dimunit",e)}get dimdec(){return this.getAttr("dimdec")}set dimdec(e){this.setAttr("dimdec",e)}get dimtdec(){return this.getAttr("dimtdec")}set dimtdec(e){this.setAttr("dimtdec",e)}get dimaltu(){return this.getAttr("dimaltu")}set dimaltu(e){this.setAttr("dimaltu",e)}get dimalttd(){return this.getAttr("dimalttd")}set dimalttd(e){this.setAttr("dimalttd",e)}get dimaunit(){return this.getAttr("dimaunit")}set dimaunit(e){this.setAttr("dimaunit",e)}get dimfrac(){return this.getAttr("dimfrac")}set dimfrac(e){this.setAttr("dimfrac",e)}get dimlunit(){return this.getAttr("dimlunit")}set dimlunit(e){this.setAttr("dimlunit",e)}get dimdsep(){return this.getAttr("dimdsep")}set dimdsep(e){this.setAttr("dimdsep",e)}get dimtmove(){return this.getAttr("dimtmove")}set dimtmove(e){this.setAttr("dimtmove",e)}get dimjust(){return this.getAttr("dimjust")}set dimjust(e){this.setAttr("dimjust",e)}get dimsd1(){return this.getAttr("dimsd1")}set dimsd1(e){this.setAttr("dimsd1",e)}get dimsd2(){return this.getAttr("dimsd2")}set dimsd2(e){this.setAttr("dimsd2",e)}get dimtolj(){return this.getAttr("dimtolj")}set dimtolj(e){this.setAttr("dimtolj",e)}get dimtzin(){return this.getAttr("dimtzin")}set dimtzin(e){this.setAttr("dimtzin",e)}get dimaltz(){return this.getAttr("dimaltz")}set dimaltz(e){this.setAttr("dimaltz",e)}get dimalttz(){return this.getAttr("dimalttz")}set dimalttz(e){this.setAttr("dimalttz",e)}get dimfit(){return this.getAttr("dimfit")}set dimfit(e){this.setAttr("dimfit",e)}get dimupt(){return this.getAttr("dimupt")}set dimupt(e){this.setAttr("dimupt",e)}get dimatfit(){return this.getAttr("dimatfit")}set dimatfit(e){this.setAttr("dimatfit",e)}get dimtxsty(){return this.getAttr("dimtxsty")}set dimtxsty(e){this.setAttr("dimtxsty",e)}get dimldrblk(){return this.getAttr("dimldrblk")}set dimldrblk(e){this.setAttr("dimldrblk",e)}get dimblk(){return this.getAttr("dimblk")}set dimblk(e){this.setAttr("dimblk",e)}get dimblk1(){return this.getAttr("dimblk1")}set dimblk1(e){this.setAttr("dimblk1",e)}get dimblk2(){return this.getAttr("dimblk2")}set dimblk2(e){this.setAttr("dimblk2",e)}get dimlwd(){return this.getAttr("dimlwd")}set dimlwd(e){this.setAttr("dimlwd",e)}get dimlwe(){return this.getAttr("dimlwe")}set dimlwe(e){this.setAttr("dimlwe",e)}};Ii.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 Bn=Ii;class Qd extends Xr{constructor(){super(),this.events={dictObjetSet:new it,dictObjectErased:new it,entityAppended:new it,entityModified:new it,layerAppended:new it,layerModified:new it,layerErased:new it,openProgress:new it,headerSysVarChanged:new it},this._angBase=0,this._angDir=0,this._aunits=ya.DecimalDegrees,this._celtscale=1,this._cecolor=new Wr,this._extents=new De,this._insunits=ba.Millimeters,this._ltscale=1,this._pdmode=0,this._pdsize=0,this._tables={blockTable:new gc(this),dimStyleTable:new fc(this),linetypeTable:new vc(this),textStyleTable:new yc(this),layerTable:new _c(this),viewportTable:new bc(this)},this._dictionaries={layouts:new hc(this),imageDefs:new za(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(e){const t=this.tables.blockTable.getIdAt(e);if(t==null)throw new Error(`[AcDbDatabase] The specified block table record id '${e}' doesn't exist in the drawing database!`);this._currentSpace=t}get aunits(){return this._aunits}set aunits(e){this._aunits=e||0,this.triggerHeaderSysVarChangedEvent("aunits")}get insunits(){return this._insunits}set insunits(e){this._insunits=e||4,this.triggerHeaderSysVarChangedEvent("insunits")}get ltscale(){return this._ltscale}set ltscale(e){this._ltscale=e||1,this.triggerHeaderSysVarChangedEvent("ltscale")}get cecolor(){return this._cecolor}set cecolor(e){this._cecolor=e||0,this.triggerHeaderSysVarChangedEvent("cecolor")}get celtscale(){return this._celtscale}set celtscale(e){this._celtscale=e||1,this.triggerHeaderSysVarChangedEvent("celtscale")}get angBase(){return this._angBase}set angBase(e){this._angBase=e||0,this.triggerHeaderSysVarChangedEvent("angbase")}get angDir(){return this._angDir}set angDir(e){this._angDir=e||0,this.triggerHeaderSysVarChangedEvent("angdir")}get extmax(){return this._extents.max}set extmax(e){e&&(this._extents.expandByPoint(e),this.triggerHeaderSysVarChangedEvent("extmax"))}get extmin(){return this._extents.min}set extmin(e){e&&(this._extents.expandByPoint(e),this.triggerHeaderSysVarChangedEvent("extmin"))}get extents(){return this._extents}get pdmode(){return this._pdmode}set pdmode(e){this._pdmode=e||0,this.triggerHeaderSysVarChangedEvent("pdmode")}get pdsize(){return this._pdsize}set pdsize(e){this._pdsize=e||0,this.triggerHeaderSysVarChangedEvent("pdsize")}async read(e,t,s=Ns.DXF){const o=lr.instance.get(s);if(o==null)throw new Error(`Database converter for file type '${s}' isn't registered and can can't read this file!`);this.clear(),await o.read(e,this,t&&t.minimumChunkSize||10,async(h,u,g,b)=>{if(this.events.openProgress.dispatch({database:this,percentage:h,stage:"CONVERSION",subStage:u,subStageStatus:g,data:b}),t&&t.fontLoader&&u=="FONT"&&g=="END"){const f=b||this.tables.textStyleTable.fonts;await t.fontLoader.load(f)}})}async openUri(e,t){var E;this.events.openProgress.dispatch({database:this,percentage:0,stage:"FETCH_FILE",subStageStatus:"START"});const s=await fetch(e);if(!s.ok)throw this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",subStageStatus:"ERROR"}),new Error(`Failed to fetch file '${e}' with HTTP status code '${s.status}'!`);const o=s.headers.get("content-length"),h=o?parseInt(o,10):null;let u=0;const g=(E=s.body)==null?void 0:E.getReader();if(!g)throw new Error("Failed to get response reader");const b=[];for(;;){const{done:M,value:z}=await g.read();if(M)break;if(b.push(z),u+=z.length,h!==null){const D=Math.round(u/h*100);this.events.openProgress.dispatch({database:this,percentage:D,stage:"FETCH_FILE",subStageStatus:"IN-PROGRESS"})}}const f=new Uint8Array(u);let S=0;for(const M of b)f.set(M,S),S+=M.length;if(e.toLowerCase().split(".").pop()==="dwg")await this.read(f.buffer,t,Ns.DWG);else{const M=new TextDecoder().decode(f);await this.read(M,t,Ns.DXF)}this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",subStageStatus:"END"})}createDefaultData(e={layer:!0,lineType:!0,textStyle:!0,dimStyle:!0,layout:!0}){if(e.layer){const t=new Wr;t.colorIndex=7,this._tables.layerTable.add(new Bi({name:"0",standardFlags:0,linetype:"Continuous",lineWeight:0,isOff:!1,color:t,isPlottable:!0}))}if(e.lineType&&(this._tables.linetypeTable.add(new Cs({name:"ByBlock",standardFlag:0,description:"",totalPatternLength:0})),this._tables.linetypeTable.add(new Cs({name:"ByLayer",standardFlag:0,description:"",totalPatternLength:0})),this._tables.linetypeTable.add(new Cs({name:"Continuous",standardFlag:0,description:"Solid line",totalPatternLength:0}))),e.textStyle&&this._tables.textStyleTable.add(new Da({name:"Standard",standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:.2,font:"SimKai",bigFont:"",extendedFont:"SimKai"})),e.dimStyle&&this._tables.dimStyleTable.add(new Bn({name:"Standard",dimtxsty:"Standard"})),e.layout){const t=new Ri;t.layoutName="Model",t.tabOrder=0,t.blockTableRecordId=this._tables.blockTable.modelSpace.objectId,t.limits.min.copy({x:0,y:0}),t.limits.max.copy({x:1e6,y:1e6}),t.extents.min.copy({x:0,y:0,z:0}),t.extents.max.copy({x:1e6,y:1e6,z:0}),this._dictionaries.layouts.setAt(t.layoutName,t),this._tables.blockTable.modelSpace.layoutId=t.objectId}}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,this._extents.makeEmpty()}triggerHeaderSysVarChangedEvent(e){this.events.headerSysVarChanged.dispatch({database:this,name:e})}}const Jd={center:new Me,viewDirectionFromTarget:new Y(0,0,1),viewTarget:new Y(0,0,0),lensLength:500,frontClippingPlane:0,backClippingPlane:0,viewHeight:1e3,viewTwistAngle:0,frozenLayers:[],styleSheet:"",renderMode:Ca.OPTIMIZED_2D,viewMode:0,ucsIconSetting:0,ucsOrigin:new Y(0,0,0),ucsXAxis:new Y(1,0,0),ucsYAxis:new Y(0,1,0),orthographicType:La.TOP,shadePlotSetting:0,shadePlotObjectId:void 0,visualStyleObjectId:void 0,isDefaultLightingOn:!1,defaultLightingType:Oa.ONE_DISTANT_LIGHT,brightness:0,contrast:0,ambientColor:void 0};class Ic extends _n{constructor(){super(),this._circleSides=100,this._center=new Me,this._lowerLeftCorner=new Me(0,0),this._upperRightCorner=new Me(1,1),this._snapBase=new Me(0,0),this._snapAngle=0,this._snapSpacing=new Me(0,0),this._standardFlag=0,this._gridSpacing=new Me,this._gridMajor=10,this._gsView=Jd}get circleSides(){return this._circleSides}set circleSides(e){this._circleSides=e}get center(){return this._center}get lowerLeftCorner(){return this._lowerLeftCorner}set lowerLeftCorner(e){this._lowerLeftCorner.copy(e)}get upperRightCorner(){return this._upperRightCorner}set upperRightCorner(e){this._upperRightCorner.copy(e)}get snapBase(){return this._snapBase}set snapBase(e){this._snapBase.copy(e)}get snapAngle(){return this._snapAngle}set snapAngle(e){this._snapAngle=e}get snapIncrements(){return this._snapSpacing}set snapIncrements(e){this._snapSpacing.copy(e)}get gridMajor(){return this._gridMajor}set gridMajor(e){this._gridMajor=e}get gridIncrements(){return this._gridSpacing}set gridIncrements(e){this._gridSpacing.copy(e)}get standardFlag(){return this._standardFlag}set standardFlag(e){this._standardFlag=e}get snapEnabled(){return!!(this._standardFlag&256)}get backgroundObjectId(){return this._backgroundObjectId}set backgroundObjectId(e){this._backgroundObjectId=e}get gsView(){return this._gsView}}class Ec{constructor(){this.events={layoutCreated:new it,layoutRemoved:new it,layoutRenamed:new it,layoutSwitched:new it}}countLayouts(e){return this.getWorkingDatabase(e).dictionaries.layouts.numEntries}findLayoutNamed(e,t){return this.getWorkingDatabase(t).dictionaries.layouts.getAt(e)}findActiveLayout(){const e=this.getActiveLayout();return e?e.layoutName:"Model"}setCurrentLayoutId(e,t){const s=this.getWorkingDatabase(t),o=s.dictionaries.layouts.getIdAt(e);return this.setCurrentLayoutInternal(o,s)}setCurrentLayoutBtrId(e,t){const s=this.getWorkingDatabase(t),o=s.dictionaries.layouts.getBtrIdAt(e);return this.setCurrentLayoutInternal(o,s)}setCurrentLayout(e,t){const s=this.getWorkingDatabase(t),o=s.dictionaries.layouts.getAt(e);return this.setCurrentLayoutInternal(o,s)}renameLayout(e,t,s){const h=this.getWorkingDatabase(s).dictionaries.layouts.getAt(e);return h?(h.layoutName=t,this.events.layoutRenamed.dispatch({layout:h,oldName:e,newName:t}),!0):!1}layoutExists(e,t){return this.getWorkingDatabase(t).dictionaries.layouts.has(e)}deleteLayout(e,t){const s=this.getWorkingDatabase(t).dictionaries.layouts,o=s.getAt(e);let h=!1;return o&&(h=s.remove(e),h&&this.events.layoutRemoved.dispatch({layout:o})),h}createLayout(e,t){const s=this.getWorkingDatabase(t),o=new Ri;o.layoutName=e,o.tabOrder=s.dictionaries.layouts.maxTabOrder;const h=new Ft;return h.name=`*Paper_Space${o.tabOrder}`,s.tables.blockTable.add(h),s.dictionaries.layouts.setAt(e,o),this.events.layoutCreated.dispatch({layout:o}),{layout:o,btr:h}}getActiveLayout(e){const t=this.getWorkingDatabase(e);return t.dictionaries.layouts.getBtrIdAt(t.currentSpaceId)}getWorkingDatabase(e){return e||Ra().workingDatabase}setCurrentLayoutInternal(e,t){return e?(this.events.layoutSwitched.dispatch({layout:e}),t.currentSpaceId=e.blockTableRecordId,!0):!1}}function Ra(){return Pi.instance}const Ei=class Ei{constructor(){this._workingDatabase=null,this._layoutManager=new Ec}get workingDatabase(){if(this._workingDatabase==null)throw new Error("The current working database must be set before using it!");return this._workingDatabase}set workingDatabase(e){this._workingDatabase=e}get layoutManager(){return this._layoutManager}};Ei.instance=new Ei;let Pi=Ei;exports.AcCmColor=Wr;exports.AcCmErrors=Ut;exports.AcCmEventDispatcher=Hc;exports.AcCmEventManager=it;exports.AcCmLoader=Jc;exports.AcCmLoadingManager=nl;exports.AcCmObject=Jo;exports.AcCmPerformanceCollector=pa;exports.AcCmTask=tl;exports.AcCmTaskScheduler=rl;exports.AcDb3PointAngularDimension=bi;exports.AcDbAlignedDimension=xi;exports.AcDbAngleUnits=ya;exports.AcDbArc=ni;exports.AcDbArcDimension=ma;exports.AcDbBaseWorker=Zd;exports.AcDbBatchProcessing=il;exports.AcDbBlockReference=Ls;exports.AcDbBlockTable=gc;exports.AcDbBlockTableRecord=Ft;exports.AcDbCircle=si;exports.AcDbCurve=jt;exports.AcDbDatabase=Qd;exports.AcDbDatabaseConverter=vh;exports.AcDbDatabaseConverterManager=lr;exports.AcDbDiametricDimension=wi;exports.AcDbDictionary=za;exports.AcDbDimArrowType=fh;exports.AcDbDimStyleTable=fc;exports.AcDbDimStyleTableRecord=Bn;exports.AcDbDimTextHorizontal=xc;exports.AcDbDimTextVertical=wc;exports.AcDbDimVerticalJustification=Pc;exports.AcDbDimZeroSuppression=Ac;exports.AcDbDimZeroSuppressionAngular=Sc;exports.AcDbDimension=Mr;exports.AcDbDxfConverter=pc;exports.AcDbEllipse=ii;exports.AcDbEntity=Vt;exports.AcDbFace=ai;exports.AcDbFileType=Ns;exports.AcDbHatch=oi;exports.AcDbHatchPatternType=tc;exports.AcDbHatchStyle=rc;exports.AcDbHostApplicationServices=Pi;exports.AcDbLayerTable=_c;exports.AcDbLayerTableRecord=Bi;exports.AcDbLayout=Ri;exports.AcDbLayoutDictionary=hc;exports.AcDbLayoutManager=Ec;exports.AcDbLeader=li;exports.AcDbLeaderAnnotationType=nc;exports.AcDbLine=hi;exports.AcDbLineSpacingStyle=lc;exports.AcDbLinetypeTable=vc;exports.AcDbLinetypeTableRecord=Cs;exports.AcDbMText=ci;exports.AcDbObject=Xr;exports.AcDbObjectIterator=Mi;exports.AcDbOrdinateDimension=Ai;exports.AcDbOsnapMode=un;exports.AcDbPoint=gi;exports.AcDbPolyline=pi;exports.AcDbRadialDimension=Si;exports.AcDbRasterImage=zs;exports.AcDbRasterImageClipBoundaryType=ac;exports.AcDbRasterImageDef=cc;exports.AcDbRasterImageImageDisplayOpt=oc;exports.AcDbRay=fi;exports.AcDbRenderingCache=Gr;exports.AcDbSpline=Os;exports.AcDbSymbolTable=vn;exports.AcDbSymbolTableRecord=_n;exports.AcDbTable=ui;exports.AcDbText=di;exports.AcDbTextHorizontalMode=sc;exports.AcDbTextStyleTable=yc;exports.AcDbTextStyleTableRecord=Da;exports.AcDbTextVerticalMode=ic;exports.AcDbTrace=mi;exports.AcDbUnitsValue=ba;exports.AcDbViewport=_i;exports.AcDbViewportTable=bc;exports.AcDbViewportTableRecord=Ic;exports.AcDbWipeout=vi;exports.AcDbWorkerApi=dc;exports.AcDbWorkerManager=uc;exports.AcDbXline=yi;exports.AcGeArea2d=Ni;exports.AcGeBox2d=_t;exports.AcGeBox3d=De;exports.AcGeCatmullRomCurve3d=Jh;exports.AcGeCircArc2d=Dn;exports.AcGeCircArc3d=pn;exports.AcGeCurve2d=Vn;exports.AcGeEllipseArc2d=Ci;exports.AcGeEllipseArc3d=Li;exports.AcGeEuler=Kh;exports.AcGeGeometryUtil=Vh;exports.AcGeLine2d=Oi;exports.AcGeLine3d=qr;exports.AcGeLoop2d=Zh;exports.AcGeMathUtil=Ee;exports.AcGeMatrix2d=Ti;exports.AcGeMatrix3d=fn;exports.AcGeNurbsCurve=gn;exports.AcGePlane=Ds;exports.AcGePoint2d=Me;exports.AcGePoint3d=Y;exports.AcGePolyline2d=Bs;exports.AcGeQuaternion=Hr;exports.AcGeShape2d=Ta;exports.AcGeSpline3d=Yr;exports.AcGeTol=Ea;exports.AcGeVector2d=$e;exports.AcGeVector3d=Z;exports.AcGiArrowType=Na;exports.AcGiDefaultLightingType=Oa;exports.AcGiMTextAttachmentPoint=Rn;exports.AcGiMTextFlowDirection=zi;exports.AcGiOrthographicType=La;exports.AcGiRenderMode=Ca;exports.AcGiViewport=Di;exports.AcTrStringUtil=Qc;exports.ByBlock=gh;exports.ByLayer=Js;exports.DEBUG_MODE=$c;exports.DEFAULT_LINE_TYPE=ti;exports.DEFAULT_TOL=ka;exports.DEG2RAD=xa;exports.DefaultLoadingManager=sl;exports.FLOAT_TOL=cn;exports.ORIGIN_POINT_2D=Fd;exports.ORIGIN_POINT_3D=Ia;exports.RAD2DEG=wa;exports.TAU=nt;exports.acdbHostApplicationServices=Ra;exports.basisFunction=ri;exports.calculateCurveLength=Hh;exports.ceilPowerOfTwo=Lh;exports.clamp=kr;exports.clone=Is;exports.createWorkerApi=mc;exports.damp=wh;exports.defaults=Fn;exports.degToRad=Th;exports.euclideanModulo=Aa;exports.evaluateNurbsPoint=Ts;exports.floorPowerOfTwo=Oh;exports.generateChordKnots=Gh;exports.generateSqrtChordKnots=Wh;exports.generateUUID=yh;exports.generateUniformKnots=jh;exports.has=Zo;exports.intPartLength=Pa;exports.interpolateControlPoints=Ud;exports.inverseLerp=xh;exports.isBetween=zh;exports.isBetweenAngle=Dh;exports.isEmpty=Qo;exports.isEqual=zn;exports.isImperialUnits=Bd;exports.isMetricUnits=Rd;exports.isPointInPolygon=Ma;exports.isPolygonIntersect=Uh;exports.isPowerOfTwo=Ch;exports.lerp=Sa;exports.log=ks;exports.mapLinear=bh;exports.normalizeAngle=Ms;exports.pingpong=Ah;exports.radToDeg=Nh;exports.randFloat=Eh;exports.randFloatSpread=kh;exports.randInt=Ih;exports.relativeEps=Rh;exports.seededRandom=Mh;exports.setLogLevel=Zc;exports.smootherstep=Ph;exports.smoothstep=Sh;