@mlightcad/data-model 1.2.10 → 1.2.12

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 fu(a,t){for(var e=0;e<t.length;e++){const s=t[e];if(typeof s!="string"&&!Array.isArray(s)){for(const o in s)if(o!=="default"&&!(o in a)){const h=Object.getOwnPropertyDescriptor(s,o);h&&Object.defineProperty(a,o,h.get?h:{enumerable:!0,get:()=>s[o]})}}}return Object.freeze(Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}))}const zs={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},Li=[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 Qn(a,t,e){return Math.max(t,Math.min(e,a))}const Lo=class Oo{constructor(){this._colorIndex=256,this._color=null,this._colorName=null}get color(){return this._color}set color(t){t==null?this._color=null:(this._color=Math.round(Qn(t,0,256*256*256-1)),this._colorIndex=this.getColorIndexByValue(this._color),this._colorName=this.getColorNameByValue(this._color))}get hexColor(){if(this._color&&this._color>0&&this._color<=16777215){let t=this._color.toString(16).toUpperCase();for(;t.length<6;)t="0"+t;return`0x${t}`}return""}get cssColor(){return`rgb(${this.red},${this.green},${this.blue})`}get red(){return this.color?this.color>>16&255:null}get green(){return this.color?this.color>>8&255:null}get blue(){return this.color?this.color&255:null}get colorIndex(){return this._colorIndex}set colorIndex(t){t==null?this._colorIndex=null:(this._colorIndex=Qn(t,0,256),this._color=Li[t],this._colorName=this.getColorNameByValue(this._color))}get colorName(){return this._colorName}set colorName(t){if(t){const e=zs[t.toLowerCase()];e!==void 0?(this._colorName=t,this._color=e,this._colorIndex=this.getColorIndexByValue(this._color)):console.warn("Unknown color: "+t)}else this._colorName=null}get hasColorName(){return this._colorName==null}get hasColorIndex(){return this._colorIndex==null}get isByLayer(){return this.colorIndex==256}setByLayer(){return this.colorIndex=256,this}get isByBlock(){return this.colorIndex==0}setByBlock(){return this.colorIndex=0,this}setScalar(t){return this.setRGB(t,t,t),this}setRGB(t,e,s){const o=Math.round(Qn(t,0,255)),h=Math.round(Qn(e,0,255)),c=Math.round(Qn(s,0,255));return this.color=(o<<16)+(h<<8)+c,this}setColorName(t){const e=zs[t.toLowerCase()];return e!==void 0?this.color=e:console.warn("Unknown color "+t),this}clone(){const t=new Oo;return t.colorIndex=this.colorIndex,t.color=this.color,t._colorName=this._colorName,this}copy(t){return this.colorIndex=t.colorIndex,this.color=t.color,this._colorName=t._colorName,this}equals(t){return t.color==this.color&&t.colorIndex==this.colorIndex&&t._colorName==this._colorName}toString(){return this.isByLayer?"ByLayer":this.isByBlock?"ByBlock":this.colorName?this.colorName:this.hexColor}getColorNameByValue(t){for(const[e,s]of Object.entries(zs))if(s===t)return e;return null}getColorIndexByValue(t){const e=Li.length-1;for(let s=1;s<e;++s)if(Li[s]===t)return s;return null}};Lo.NAMES=zs;let an=Lo;const Re={get ILLEGAL_PARAMETERS(){return new ReferenceError("Illegal Parameters")},get ZERO_DIVISION(){return new Error("Zero division")},get UNRESOLVED_BOUNDARY_CONFLICT(){return new Error("Unresolved boundary conflict in boolean operation")},get INFINITE_LOOP(){return new Error("Infinite loop")},get CANNOT_INVOKE_ABSTRACT_METHOD(){return new Error("Abstract method cannot be invoked")},get OPERATION_IS_NOT_SUPPORTED(){return new Error("Operation is not supported")},get NOT_IMPLEMENTED(){return new Error("Not implemented yet")}};class _u{constructor(){this._listeners={}}addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const s=this._listeners;s[t]===void 0&&(s[t]=[]),s[t].indexOf(e)===-1&&s[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const s=this._listeners;return s[t]!==void 0&&s[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const s=this._listeners[t];if(s!==void 0){const o=s.indexOf(e);o!==-1&&s.splice(o,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const e=this._listeners[t.type];if(e!==void 0){t.target=this;const s=e.slice(0);for(let o=0,h=s.length;o<h;o++)s[o].call(this,t)}}}let ie=class{constructor(){this.listeners=[]}addEventListener(t){this.listeners.push(t)}removeEventListener(t){this.listeners=this.listeners.filter(e=>e!==t)}replaceEventListener(t){this.removeEventListener(t),this.addEventListener(t)}dispatch(t,...e){for(const s of this.listeners)s.call(null,t,...e)}};var vu=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function yu(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var zo={exports:{}};(function(a){(function(t,e){a.exports?a.exports=e():t.log=e()})(vu,function(){var t=function(){},e="undefined",s=typeof window!==e&&typeof window.navigator!==e&&/Trident\/|MSIE /.test(window.navigator.userAgent),o=["trace","debug","info","warn","error"],h={},c=null;function g(z,U){var B=z[U];if(typeof B.bind=="function")return B.bind(z);try{return Function.prototype.bind.call(B,z)}catch{return function(){return Function.prototype.apply.apply(B,[z,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(z){return z==="debug"&&(z="log"),typeof console===e?!1:z==="trace"&&s?b:console[z]!==void 0?g(console,z):console.log!==void 0?g(console,"log"):t}function S(){for(var z=this.getLevel(),U=0;U<o.length;U++){var B=o[U];this[B]=U<z?t:this.methodFactory(B,z,this.name)}if(this.log=this.debug,typeof console===e&&z<this.levels.SILENT)return"No console available for logging"}function x(z){return function(){typeof console!==e&&(S.call(this),this[z].apply(this,arguments))}}function k(z,U,B){return f(z)||x.apply(this,arguments)}function M(z,U){var B=this,gt,ft,ut,W="loglevel";typeof z=="string"?W+=":"+z:typeof z=="symbol"&&(W=void 0);function mt(bt){var Lt=(o[bt]||"silent").toUpperCase();if(!(typeof window===e||!W)){try{window.localStorage[W]=Lt;return}catch{}try{window.document.cookie=encodeURIComponent(W)+"="+Lt+";"}catch{}}}function lt(){var bt;if(!(typeof window===e||!W)){try{bt=window.localStorage[W]}catch{}if(typeof bt===e)try{var Lt=window.document.cookie,de=encodeURIComponent(W),me=Lt.indexOf(de+"=");me!==-1&&(bt=/^([^;]+)/.exec(Lt.slice(me+de.length+1))[1])}catch{}return B.levels[bt]===void 0&&(bt=void 0),bt}}function Wt(){if(!(typeof window===e||!W)){try{window.localStorage.removeItem(W)}catch{}try{window.document.cookie=encodeURIComponent(W)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function Ht(bt){var Lt=bt;if(typeof Lt=="string"&&B.levels[Lt.toUpperCase()]!==void 0&&(Lt=B.levels[Lt.toUpperCase()]),typeof Lt=="number"&&Lt>=0&&Lt<=B.levels.SILENT)return Lt;throw new TypeError("log.setLevel() called with invalid level: "+bt)}B.name=z,B.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},B.methodFactory=U||k,B.getLevel=function(){return ut??ft??gt},B.setLevel=function(bt,Lt){return ut=Ht(bt),Lt!==!1&&mt(ut),S.call(B)},B.setDefaultLevel=function(bt){ft=Ht(bt),lt()||B.setLevel(bt,!1)},B.resetLevel=function(){ut=null,Wt(),S.call(B)},B.enableAll=function(bt){B.setLevel(B.levels.TRACE,bt)},B.disableAll=function(bt){B.setLevel(B.levels.SILENT,bt)},B.rebuild=function(){if(c!==B&&(gt=Ht(c.getLevel())),S.call(B),c===B)for(var bt in h)h[bt].rebuild()},gt=Ht(c?c.getLevel():"WARN");var Ut=lt();Ut!=null&&(ut=Ht(Ut)),S.call(B)}c=new M,c.getLogger=function(z){if(typeof z!="symbol"&&typeof z!="string"||z==="")throw new TypeError("You must supply a name when creating a logger.");var U=h[z];return U||(U=h[z]=new M(z,c.methodFactory)),U};var D=typeof window!==e?window.log:void 0;return c.noConflict=function(){return typeof window!==e&&window.log===c&&(window.log=D),c},c.getLoggers=function(){return h},c.default=c,c})})(zo);var Do=zo.exports;const bu=yu(Do),xu=fu({__proto__:null,default:bu},[Do]),wu=!0,gs=xu;gs.setLevel("debug");const Au=a=>{try{gs.setLevel(a)}catch(t){gs.setLevel("error"),gs.error(t)}};function ms(a){return a===null||typeof a!="object"?a:Array.isArray(a)?[...a]:{...a}}function Mn(a,...t){for(const e of t)if(e)for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&a[s]===void 0&&(a[s]=e[s]);return a}function Ro(a,t){return a!=null&&Object.prototype.hasOwnProperty.call(a,t)}function Bo(a){return a==null?!0:Array.isArray(a)||typeof a=="string"?a.length===0:a instanceof Map||a instanceof Set?a.size===0:typeof a=="object"?Object.keys(a).length===0:!1}function Sn(a,t){if(a===t)return!0;if(a==null||t==null)return a===t;if(typeof a!=typeof t)return!1;if(typeof a!="object")return a===t;if(Array.isArray(a)!==Array.isArray(t))return!1;if(Array.isArray(a)){if(a.length!==t.length)return!1;for(let o=0;o<a.length;o++)if(!Sn(a[o],t[o]))return!1;return!0}const e=Object.keys(a),s=Object.keys(t);if(e.length!==s.length)return!1;for(const o of e)if(!Object.prototype.hasOwnProperty.call(t,o)||!Sn(a[o],t[o]))return!1;return!0}let Fo=class Vo{constructor(t,e){this.events={attrChanged:new ie,modelChanged:new ie},this._changing=!1,this._previousAttributes={},this._pending=!1;const s=t||{};e&&Mn(s,e),this.attributes=s,this.changed={}}get(t){return this.attributes[t]}set(t,e,s){if(t==null)return this;let o;typeof t=="object"?(o=t,s=e):(o={},o[t]=e),s||(s={});const h=s.unset,c=s.silent,g=[],b=this._changing;this._changing=!0,b||(this._previousAttributes=ms(this.attributes),this.changed={});const f=this.attributes,S=this.changed,x=this._previousAttributes;for(const k in o)e=o[k],Sn(f[k],e)||g.push(k),Sn(x[k],e)?delete S[k]:S[k]=e,h?delete f[k]:f[k]=e;if(!c){g.length&&(this._pending=s);for(let k=0;k<g.length;k++)this.events.attrChanged.dispatch({object:this,attrName:g[k],attrValue:f[g[k]],options:s})}if(b)return this;if(!c)for(;this._pending;)s=this._pending,this._pending=!1,this.events.modelChanged.dispatch({object:this,options:s});return this._pending=!1,this._changing=!1,this}has(t){return this.get(t)!=null}hasChanged(t){return t==null?!Bo(this.changed):Ro(this.changed,t)}changedAttributes(t){if(!t)return this.hasChanged()?ms(this.changed):{};const e=this._changing?this._previousAttributes:this.attributes,s={};for(const o in t){const h=t[o];Sn(e[o],h)||(s[o]=h)}return s}previous(t){return t==null||!this._previousAttributes?null:this._previousAttributes[t]}previousAttributes(){return ms(this._previousAttributes)}clone(){const t=ms(this.attributes);return new Vo(t)}},ea=class ps{constructor(){this.entries=new Map}static getInstance(){return ps.instance||(ps.instance=new ps),ps.instance}collect(t){this.entries.set(t.name,t)}printAll(){for(const[t,e]of this.entries)console.log(`${t}:`),console.log(e.format())}clear(){this.entries.clear()}getAll(){return Array.from(this.entries.values())}getEntry(t){return this.entries.get(t)}remove(t){return this.entries.delete(t)}};class Pu{static formatBytes(t,e=2){if(t===0)return"0 B";const s=1024,o=Math.max(0,e),h=["B","KB","MB","GB","TB"],c=Math.floor(Math.log(t)/Math.log(s)),g=t/Math.pow(s,c);return`${parseFloat(g.toFixed(o))} ${h[c]}`}}class Uo{constructor(t){this.name=t}run(t){throw new Error("run() must be implemented by subclass")}}class jo{constructor(){this.tasks=[],this.onProgress=()=>{},this.onComplete=()=>{},this.onError=()=>{}}scheduleTask(t){return new Promise((e,s)=>{const o=()=>{Promise.resolve(t()).then(e).catch(s)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(o):setTimeout(o,0)})}addTask(t){this.tasks.push(t)}setProgressCallback(t){this.onProgress=t}setCompleteCallback(t){this.onComplete=t}setErrorCallback(t){this.onError=t}async run(t){const e=this.tasks.length;let s=t;for(let o=0;o<e;o++){const h=this.tasks[o];try{s=await this.scheduleTask(async()=>{const c=await h.run(s);return this.onProgress((o+1)/e,h),c})}catch(c){this.onError({error:c,taskIndex:o,task:h});return}}this.onComplete(s)}}let Go=class{constructor(t,e,s){this.isLoading=!1,this.itemsLoaded=0,this.itemsTotal=0,this.urlModifier=void 0,this.handlers=[],this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=s}itemStart(t){this.itemsTotal++,this.isLoading===!1&&this.onStart!==void 0&&this.onStart(t,this.itemsLoaded,this.itemsTotal),this.isLoading=!0}itemEnd(t){this.itemsLoaded++,this.onProgress!==void 0&&this.onProgress(t,this.itemsLoaded,this.itemsTotal),this.itemsLoaded===this.itemsTotal&&(this.isLoading=!1,this.onLoad!==void 0&&this.onLoad())}itemError(t){this.onError!==void 0&&this.onError(t)}resolveURL(t){return this.urlModifier?this.urlModifier(t):t}setURLModifier(t){return this.urlModifier=t,this}addHandler(t,e){return this.handlers.push(t,e),this}removeHandler(t){const e=this.handlers.indexOf(t);return e!==-1&&this.handlers.splice(e,2),this}getHandler(t){for(let e=0,s=this.handlers.length;e<s;e+=2){const o=this.handlers[e],h=this.handlers[e+1];if(o.global&&(o.lastIndex=0),o.test(t))return h}return null}};const Wo=new Go;let Su=class{constructor(t){this.manager=t!==void 0?t:Wo,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}loadAsync(t,e){return new Promise((s,o)=>{this.load(t,s,e,o)})}parse(t){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}};class Ho{constructor(t,e,s){this._chunkSize=-1,this._minimumChunkSize=50,this._count=t,this._numerOfChunk=e<1?1:e,this._minimumChunkSize=s,this.calculateChunkSize()}get count(){return this._count}get numerOfChunk(){return this._numerOfChunk}get minimumChunkSize(){return this._minimumChunkSize}set minimumChunkSize(t){this._minimumChunkSize=t,this.calculateChunkSize()}get chunkSize(){return this._chunkSize}calculateChunkSize(){let t=this._count/this._numerOfChunk;t<this._minimumChunkSize&&(t=Math.min(this._minimumChunkSize,this._count)),this._chunkSize=t<1?this._count:Math.floor(t)}scheduleTask(t){return new Promise((e,s)=>{const o=()=>{Promise.resolve(t()).then(e).catch(s)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(o):setTimeout(o,0)})}async processChunk(t){let e=0;const s=async()=>{const o=e,h=Math.min(e+this._chunkSize,this._count);await t(o,h),e=h,e<this._count&&await this.scheduleTask(s)};await s()}}var he,Jn,Zt,se,ts,$e,ye,cr,Ze,qr,es,rs,Yr,Kr,ns,ss,is,Ce,dr,Gt,Xr,as,vt,be,os,xe,mr,ls,pr,Qe,hs,$r,Ne,gr,Oi,zi,fr,us,cs,_r,ds,Di,Ri,Zr,ue,vr,ce,Le,Bi,Fi,Vi,Ui,ji,Gi;(he={})[he.None=0]="None",he[he.Anonymous=1]="Anonymous",he[he.NonConstant=2]="NonConstant",he[he.Xref=4]="Xref",he[he.XrefOverlay=8]="XrefOverlay",he[he.ExternallyDependent=16]="ExternallyDependent",he[he.ResolvedOrDependent=32]="ResolvedOrDependent",he[he.ReferencedXref=64]="ReferencedXref";(Jn={})[Jn.BYBLOCK=0]="BYBLOCK",Jn[Jn.BYLAYER=256]="BYLAYER";(Zt={})[Zt.Rotated=0]="Rotated",Zt[Zt.Aligned=1]="Aligned",Zt[Zt.Angular=2]="Angular",Zt[Zt.Diameter=3]="Diameter",Zt[Zt.Radius=4]="Radius",Zt[Zt.Angular3Point=5]="Angular3Point",Zt[Zt.Ordinate=6]="Ordinate",Zt[Zt.ReferenceIsExclusive=32]="ReferenceIsExclusive",Zt[Zt.IsOrdinateXTypeFlag=64]="IsOrdinateXTypeFlag",Zt[Zt.IsCustomTextPositionFlag=128]="IsCustomTextPositionFlag";(se={})[se.TopLeft=1]="TopLeft",se[se.TopCenter=2]="TopCenter",se[se.TopRight=3]="TopRight",se[se.MiddleLeft=4]="MiddleLeft",se[se.MiddleCenter=5]="MiddleCenter",se[se.MiddleRight=6]="MiddleRight",se[se.BottomLeft=7]="BottomLeft",se[se.BottomCenter=8]="BottomCenter",se[se.BottomRight=9]="BottomRight";(ts={})[ts.AtLeast=1]="AtLeast",ts[ts.Exact=2]="Exact";var fo=(($e={})[$e.Center=0]="Center",$e[$e.Above=1]="Above",$e[$e.Outside=2]="Outside",$e[$e.JIS=3]="JIS",$e[$e.Below=4]="Below",$e),wn=((ye={})[ye.Feet=0]="Feet",ye[ye.None=1]="None",ye[ye.Inch=2]="Inch",ye[ye.FeetAndInch=3]="FeetAndInch",ye[ye.Leading=4]="Leading",ye[ye.Trailing=8]="Trailing",ye[ye.LeadingAndTrailing=12]="LeadingAndTrailing",ye),Iu=((cr={})[cr.None=0]="None",cr[cr.Leading=1]="Leading",cr[cr.Trailing=2]="Trailing",cr[cr.LeadingAndTrailing=3]="LeadingAndTrailing",cr),ku=((Ze={})[Ze.Center=0]="Center",Ze[Ze.Left=1]="Left",Ze[Ze.Right=2]="Right",Ze[Ze.OverFirst=3]="OverFirst",Ze[Ze.OverSecond=4]="OverSecond",Ze),Eu=((qr={})[qr.Bottom=0]="Bottom",qr[qr.Center=1]="Center",qr[qr.Top=2]="Top",qr);(es={})[es.PatternFill=0]="PatternFill",es[es.SolidFill=1]="SolidFill";(rs={})[rs.NonAssociative=0]="NonAssociative",rs[rs.Associative=1]="Associative";(Yr={})[Yr.Normal=0]="Normal",Yr[Yr.Outer=1]="Outer",Yr[Yr.Ignore=2]="Ignore";(Kr={})[Kr.UserDefined=0]="UserDefined",Kr[Kr.Predefined=1]="Predefined",Kr[Kr.Custom=2]="Custom";(ns={})[ns.NotAnnotated=0]="NotAnnotated",ns[ns.Annotated=1]="Annotated";(ss={})[ss.Solid=0]="Solid",ss[ss.Gradient=1]="Gradient";(is={})[is.TwoColor=0]="TwoColor",is[is.OneColor=1]="OneColor";var Mu=((Ce={})[Ce.Default=0]="Default",Ce[Ce.External=1]="External",Ce[Ce.Polyline=2]="Polyline",Ce[Ce.Derived=4]="Derived",Ce[Ce.Textbox=8]="Textbox",Ce[Ce.Outermost=16]="Outermost",Ce),Ms=((dr={})[dr.Line=1]="Line",dr[dr.Circular=2]="Circular",dr[dr.Elliptic=3]="Elliptic",dr[dr.Spline=4]="Spline",dr),Tu=((Gt={})[Gt.Off=0]="Off",Gt[Gt.Solid=1]="Solid",Gt[Gt.Dashed=2]="Dashed",Gt[Gt.Dotted=3]="Dotted",Gt[Gt.ShotDash=4]="ShotDash",Gt[Gt.MediumDash=5]="MediumDash",Gt[Gt.LongDash=6]="LongDash",Gt[Gt.DoubleShortDash=7]="DoubleShortDash",Gt[Gt.DoubleMediumDash=8]="DoubleMediumDash",Gt[Gt.DoubleLongDash=9]="DoubleLongDash",Gt[Gt.DoubleMediumLongDash=10]="DoubleMediumLongDash",Gt[Gt.SparseDot=11]="SparseDot",Gt);Tu.Off;(Xr={})[Xr.Standard=-3]="Standard",Xr[Xr.ByLayer=-2]="ByLayer",Xr[Xr.ByBlock=-1]="ByBlock";(as={})[as.English=0]="English",as[as.Metric=1]="Metric";(vt={})[vt.PERSPECTIVE_MODE=1]="PERSPECTIVE_MODE",vt[vt.FRONT_CLIPPING=2]="FRONT_CLIPPING",vt[vt.BACK_CLIPPING=4]="BACK_CLIPPING",vt[vt.UCS_FOLLOW=8]="UCS_FOLLOW",vt[vt.FRONT_CLIP_NOT_AT_EYE=16]="FRONT_CLIP_NOT_AT_EYE",vt[vt.UCS_ICON_VISIBILITY=32]="UCS_ICON_VISIBILITY",vt[vt.UCS_ICON_AT_ORIGIN=64]="UCS_ICON_AT_ORIGIN",vt[vt.FAST_ZOOM=128]="FAST_ZOOM",vt[vt.SNAP_MODE=256]="SNAP_MODE",vt[vt.GRID_MODE=512]="GRID_MODE",vt[vt.ISOMETRIC_SNAP_STYLE=1024]="ISOMETRIC_SNAP_STYLE",vt[vt.HIDE_PLOT_MODE=2048]="HIDE_PLOT_MODE",vt[vt.K_ISO_PAIR_TOP=4096]="K_ISO_PAIR_TOP",vt[vt.K_ISO_PAIR_RIGHT=8192]="K_ISO_PAIR_RIGHT",vt[vt.VIEWPORT_ZOOM_LOCKING=16384]="VIEWPORT_ZOOM_LOCKING",vt[vt.UNUSED=32768]="UNUSED",vt[vt.NON_RECTANGULAR_CLIPPING=65536]="NON_RECTANGULAR_CLIPPING",vt[vt.VIEWPORT_OFF=131072]="VIEWPORT_OFF",vt[vt.GRID_BEYOND_DRAWING_LIMITS=262144]="GRID_BEYOND_DRAWING_LIMITS",vt[vt.ADAPTIVE_GRID_DISPLAY=524288]="ADAPTIVE_GRID_DISPLAY",vt[vt.SUBDIVISION_BELOW_SPACING=1048576]="SUBDIVISION_BELOW_SPACING",vt[vt.GRID_FOLLOWS_WORKPLANE=2097152]="GRID_FOLLOWS_WORKPLANE";(be={})[be.OPTIMIZED_2D=0]="OPTIMIZED_2D",be[be.WIREFRAME=1]="WIREFRAME",be[be.HIDDEN_LINE=2]="HIDDEN_LINE",be[be.FLAT_SHADED=3]="FLAT_SHADED",be[be.GOURAUD_SHADED=4]="GOURAUD_SHADED",be[be.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",be[be.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME";(os={})[os.UCS_UNCHANGED=0]="UCS_UNCHANGED",os[os.HAS_OWN_UCS=1]="HAS_OWN_UCS";(xe={})[xe.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",xe[xe.TOP=1]="TOP",xe[xe.BOTTOM=2]="BOTTOM",xe[xe.FRONT=3]="FRONT",xe[xe.BACK=4]="BACK",xe[xe.LEFT=5]="LEFT",xe[xe.RIGHT=6]="RIGHT";(mr={})[mr.AS_DISPLAYED=0]="AS_DISPLAYED",mr[mr.WIREFRAME=1]="WIREFRAME",mr[mr.HIDDEN=2]="HIDDEN",mr[mr.RENDERED=3]="RENDERED";(ls={})[ls.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",ls[ls.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS";function Nt(a,t,e){return a.code===t&&(e==null||a.value===e)}function Bt(a){let t={};a.rewind();let e=a.next(),s=e.code;if(t.x=e.value,(e=a.next()).code!==s+10)throw Error("Expected code for point value to be 20 but got "+e.code+".");return t.y=e.value,(e=a.next()).code!==s+20?a.rewind():t.z=e.value,t}let ra=Symbol();function Tt(a,t){return(e,s,o)=>{let h=a.reduce((b,f)=>{f.pushContext&&b.push({});let S=b[b.length-1];for(let x of typeof f.code=="number"?[f.code]:f.code){let k=S[x]??(S[x]=[]);f.isMultiple&&k.length&&console.warn(`Snippet ${k.at(-1).name} for code(${x}) is shadowed by ${f.name}`),k.push(f)}return b},[{}]),c=!1,g=h.length-1;for(;!Nt(e,0,"EOF");){let b=function(D,z,U){return D.find((B,gt)=>{var ft;return gt>=U&&((ft=B[z])==null?void 0:ft.length)})}(h,e.code,g),f=b==null?void 0:b[e.code].at(-1);if(!b||!f){s.rewind();break}f.isMultiple||b[e.code].pop();let{name:S,parser:x,isMultiple:k}=f,M=x==null?void 0:x(e,s,o);if(M===ra){s.rewind();break}if(S){let[D,z]=function(U,B){let gt=B.split("."),ft=U;for(let ut=0;ut<gt.length-1;++ut){let W=gt[ut];Object.hasOwn(ft,W)||(ft[W]={}),ft=ft[W]}return[ft,gt.at(-1)]}(o,S);k?(Object.hasOwn(D,z)||(D[z]=[]),D[z].push(M)):D[z]=M}f.pushContext&&(g-=1),c=!0,e=s.next()}return t&&Object.setPrototypeOf(o,t),c}}function y({value:a}){return a}function Z(a,t){return Bt(t)}function Xt({value:a}){return!!a}var qo=[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 Yo(a,t){var o;if(!Nt(a,1001))throw Error("XData must starts with code 1001");let e={appName:a.value,value:[]};a=t.next();let s=[e.value];for(;!Nt(a,0,"EOF")&&a.code>=1e3;){let h=s.at(-1);switch(a.code){case 1002:a.value==="{"?s.push([]):(s.pop(),(o=s.at(-1))==null||o.push(h));break;case 1e3:case 1004:case 1040:case 1070:case 1071:h.push({type:yr(a.code),value:a.value});break;case 1003:h.push({name:"layer",type:yr(a.code),value:a.value});break;case 1005:h.push({name:"handle",type:yr(a.code),value:a.value});break;case 1010:h.push({type:yr(a.code),value:Bt(t)});break;case 1011:h.push({name:"worldSpacePosition",type:yr(a.code),value:Bt(t)});break;case 1012:h.push({name:"worldSpaceDisplacement",type:yr(a.code),value:Bt(t)});break;case 1013:h.push({name:"worldSpaceDirection",type:yr(a.code),value:Bt(t)});break;case 1041:h.push({name:"distance",type:yr(a.code),value:a.value});break;case 1042:h.push({name:"scale",type:yr(a.code),value:a.value})}a=t.next()}return t.rewind(),e}function yr(a){switch(a){case 1e3:case 1003:case 1005:return"string";case 1004:return"hex";case 1040:case 1041:case 1042:return"real";case 1070:return"integer";case 1071:return"long";case 1010:case 1011:case 1012:case 1013:return"point";default:return""}}function na(a,t,e){if(Nt(t,102))return Ds(t,e),!0;switch(t.code){case 0:a.type=t.value;break;case 5:a.handle=t.value;break;case 330:a.ownerDictionarySoftId?a.ownerBlockRecordSoftId=t.value:a.ownerDictionarySoftId=t.value;break;case 360:a.ownerdictionaryHardId=t.value;break;case 67:a.isInPaperSpace=!!t.value;break;case 8:a.layer=t.value;break;case 6:a.lineType=t.value;break;case 347:a.materialObjectHardId=t.value;break;case 62:a.colorIndex=t.value,a.color=qo[Math.abs(t.value)];break;case 370:a.lineweight=t.value;break;case 48:a.lineTypeScale=t.value;break;case 60:a.isVisible=!!t.value;break;case 92:a.proxyByte=t.value;break;case 310:a.proxyEntity=t.value;break;case 100:break;case 420:a.color=t.value;break;case 430:a.transparency=t.value;break;case 390:a.plotStyleHardId=t.value;break;case 284:a.shadowMode=t.value;break;case 1001:a.xdata=Yo(t,e);break;default:return!1}return!0}let Cu=0;function Ko(a){if(!a)throw TypeError("entity cannot be undefined or null");a.handle||(a.handle=Cu++)}(pr={})[pr.CAST_AND_RECEIVE=0]="CAST_AND_RECEIVE",pr[pr.CAST=1]="CAST",pr[pr.RECEIVE=2]="RECEIVE",pr[pr.IGNORE=3]="IGNORE";let ne=[{code:1001,name:"xdata",parser:Yo},{code:284,name:"shadowMode",parser:y},{code:390,name:"plotStyleHardId",parser:y},{code:440,name:"transparency",parser:y},{code:430,name:"colorName",parser:y},{code:420,name:"color",parser:y},{code:310,name:"proxyEntity",isMultiple:!0,parser:y},{code:92,name:"proxyByte",parser:y},{code:60,name:"isVisible",parser:Xt},{code:48,name:"lineTypeScale",parser:y},{code:370,name:"lineweight",parser:y},{code:62,name:"colorIndex",parser(a,t,e){let s=a.value;return e.color=qo[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:Xt},{code:100},{code:160},{code:330,name:"ownerBlockRecordSoftId",parser:y},{code:102,parser:Ds},{code:102,parser:Ds},{code:102,parser:Ds},{code:5,name:"handle",parser:y}];function Ds(a,t){for(a=t.next();!Nt(a,102)&&!Nt(a,0,"EOF");)a=t.next()}function Xo(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}let Nu={extrusionDirection:{x:0,y:0,z:1}},Lu=[{code:210,name:"extrusionDirection",parser:Z},{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:Z},{code:39,name:"thickness",parser:y},{code:100},...ne];class $o{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Xo(this,"parser",Tt(Lu,Nu))}}Xo($o,"ForEntityName","ARC");(Qe={})[Qe.NONE=0]="NONE",Qe[Qe.INVISIBLE=1]="INVISIBLE",Qe[Qe.CONSTANT=2]="CONSTANT",Qe[Qe.VERIFICATION_REQUIRED=4]="VERIFICATION_REQUIRED",Qe[Qe.PRESET=8]="PRESET";(hs={})[hs.MULTILINE=2]="MULTILINE",hs[hs.CONSTANT_MULTILINE=4]="CONSTANT_MULTILINE";($r={})[$r.NONE=0]="NONE",$r[$r.MIRRORED_X=2]="MIRRORED_X",$r[$r.MIRRORED_Y=4]="MIRRORED_Y";var Ou=((Ne={})[Ne.LEFT=0]="LEFT",Ne[Ne.CENTER=1]="CENTER",Ne[Ne.RIGHT=2]="RIGHT",Ne[Ne.ALIGNED=3]="ALIGNED",Ne[Ne.MIDDLE=4]="MIDDLE",Ne[Ne.FIT=5]="FIT",Ne),zu=((gr={})[gr.BASELINE=0]="BASELINE",gr[gr.BOTTOM=1]="BOTTOM",gr[gr.MIDDLE=2]="MIDDLE",gr[gr.TOP=3]="TOP",gr);function Zo(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}let Qo={thickness:0,rotation:0,xScale:1,obliqueAngle:0,styleName:"STANDARD",generationFlag:0,halign:Ou.LEFT,valign:zu.BASELINE,extrusionDirection:{x:0,y:0,z:1}},Jo=[{code:73,name:"valign",parser:y},{code:100},{code:210,name:"extrusionDirection",parser:Z},{code:11,name:"endPoint",parser:Z},{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:Z},{code:39,name:"thickness",parser:y},{code:100,name:"subclassMarker",parser:y},...ne];class tl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Zo(this,"parser",Tt(Jo,Qo))}}function el(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}Zo(tl,"ForEntityName","TEXT");let Du={...Qo},Ru=[{code:2},{code:40,name:"annotationScale",parser:y},{code:10,name:"alignmentPoint",parser:Z},{code:340,name:"secondaryAttributesHardIds",isMultiple:!0,parser:y},{code:70,name:"numberOfSecondaryAttributes",parser:y},{code:70,name:"isReallyLocked",parser:Xt},{code:70,name:"mtextFlag",parser:y},{code:280,name:"isDuplicatedRecord",parser:Xt},{code:100},{code:280,name:"isLocked",parser:Xt},{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},...Jo.slice(2)];class rl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){el(this,"parser",Tt(Ru,Du))}}function nl(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}el(rl,"ForEntityName","ATTDEF");let Bu={thickness:0,extrusionDirection:{x:0,y:0,z:1}},Fu=[{code:210,name:"extrusionDirection",parser:Z},{code:40,name:"radius",parser:y},{code:10,name:"center",parser:Z},{code:39,name:"thickness",parser:y},{code:100,name:"subclassMarker",parser:y},...ne];class sl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){nl(this,"parser",Tt(Fu,Bu))}}nl(sl,"ForEntityName","CIRCLE");let Rs=class{parseEntity(t,e){let s={};for(;!Nt(e,0,"EOF");){if(e.code===0){t.rewind();break}(function(o,h,c){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=Bt(c);break;case 11:o.textPoint=Bt(c);break;case 12:o.insertionPoint=Bt(c);break;case 13:o.subDefinitionPoint1=Bt(c);break;case 14:o.subDefinitionPoint2=Bt(c);break;case 15:o.centerPoint=Bt(c);break;case 16:o.arcPoint=Bt(c);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=Bt(c);break;case 3:o.styleName=h.value;break;default:na(o,h,c)}})(s,e,t),e=t.next()}return s}};function il(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}zi="DIMENSION",(Oi="ForEntityName")in Rs?Object.defineProperty(Rs,Oi,{value:zi,enumerable:!0,configurable:!0,writable:!0}):Rs[Oi]=zi;let Vu={extrusionDirection:{x:0,y:0,z:1}},Uu=[{code:42,name:"endAngle",parser:y},{code:41,name:"startAngle",parser:y},{code:40,name:"axisRatio",parser:y},{code:210,name:"extrusionDirection",parser:Z},{code:11,name:"majorAxisEndPoint",parser:Z},{code:10,name:"center",parser:Z},{code:100,name:"subclassMarker",parser:y},...ne];class al{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){il(this,"parser",Tt(Uu,Vu))}}il(al,"ForEntityName","ELLIPSE");let ol=[{code:330,name:"sourceBoundaryObjects",parser:y,isMultiple:!0},{code:97,name:"numberOfSourceBoundaryObjects",parser:y}],ju=[{code:11,name:"end",parser:Z},{code:10,name:"start",parser:Z}],Gu=[{code:73,name:"isCCW",parser:Xt},{code:51,name:"endAngle",parser:y},{code:50,name:"startAngle",parser:y},{code:40,name:"radius",parser:y},{code:10,name:"center",parser:Z}],Wu=[{code:73,name:"isCCW",parser:Xt},{code:51,name:"endAngle",parser:y},{code:50,name:"startAngle",parser:y},{code:40,name:"lengthOfMinorAxis",parser:y},{code:11,name:"end",parser:Z},{code:10,name:"center",parser:Z}],Hu=[{code:13,name:"endTangent",parser:Z},{code:12,name:"startTangent",parser:Z},{code:11,name:"fitDatum",isMultiple:!0,parser:Z},{code:97,name:"numberOfFitData",parser:y},{code:10,name:"controlPoints",isMultiple:!0,parser(a,t){let e={...Bt(t),weight:1};return(a=t.next()).code===42?e.weight=a.value:t.rewind(),e}},{code:40,name:"knots",isMultiple:!0,parser:y},{code:96,name:"numberOfControlPoints",parser:y},{code:95,name:"numberOfKnots",parser:y},{code:74,name:"isPeriodic",parser:Xt},{code:73,name:"splineFlag",parser:y},{code:94,name:"degree",parser:y}],qu={[Ms.Line]:ju,[Ms.Circular]:Gu,[Ms.Elliptic]:Wu,[Ms.Spline]:Hu},Yu=[...ol,{code:72,name:"edges",parser(a,t){let e={type:a.value},s=Tt(qu[e.type]);if(!s)throw Error(`Invalid edge type ${e.type}`);return s(a=t.next(),t,e),e},isMultiple:!0},{code:93,name:"numberOfEdges",parser:y}],Ku=[...ol,{code:10,name:"vertices",parser(a,t){let e={...Bt(t),bulge:0};return(a=t.next()).code===42?e.bulge=a.value:t.rewind(),e},isMultiple:!0},{code:93,name:"numberOfVertices",parser:y},{code:73,name:"isClosed",parser:Xt},{code:72,name:"hasBulge",parser:Xt}],Xu=[{code:49,name:"dashLengths",parser:y,isMultiple:!0},{code:79,name:"numberOfDashLengths",parser:y},{code:45,name:"offset",parser:_o},{code:43,name:"base",parser:_o},{code:53,name:"angle",parser:y}];function _o(a,t){let e=a.code+1,s={x:a.value,y:1};return(a=t.next()).code===e?s.y=a.value:t.rewind(),s}function ll(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}let $u={extrusionDirection:{x:0,y:0,z:1},gradientRotation:0,colorTint:0},Zu=[{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:Z,isMultiple:!0},{code:99},{code:11,name:"offsetVector",parser:Z},{code:98,name:"numberOfSeedPoints",parser:y},{code:47,name:"pixelSize",parser:y},{code:53,name:"definitionLines",parser:function(a,t){let e={};return Tt(Xu)(a,t,e),e},isMultiple:!0},{code:78,name:"numberOfDefinitionLines",parser:y},{code:77,name:"isDouble",parser:Xt},{code:73,name:"isAnnotated",parser:Xt},{code:41,name:"patternScale",parser:y},{code:52,name:"patternAngle",parser:y},{code:76,name:"patternType",parser:y},{code:75,name:"hatchStyle",parser:y},{code:92,name:"boundaryPaths",parser:function(a,t){let e={boundaryPathTypeFlag:a.value},s=e.boundaryPathTypeFlag&Mu.Polyline;return a=t.next(),s?Tt(Ku)(a,t,e):Tt(Yu)(a,t,e),e},isMultiple:!0},{code:91,name:"numberOfBoundaryPaths",parser:y},{code:71,name:"associativity",parser:y},{code:63,name:"patternFillColor",parser:y},{code:70,name:"solidFill",parser:y},{code:2,name:"patternName",parser:y},{code:210,name:"extrusionDirection",parser:Z},{code:10,name:"elevationPoint",parser:Z},{code:100,name:"subclassMarker",parser:y,pushContext:!0},...ne];class hl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){ll(this,"parser",Tt(Zu,$u))}}ll(hl,"ForEntityName","HATCH");(fr={})[fr.ShowImage=1]="ShowImage",fr[fr.ShowImageWhenNotAlignedWithScreen=2]="ShowImageWhenNotAlignedWithScreen",fr[fr.UseClippingBoundary=4]="UseClippingBoundary",fr[fr.TransparencyIsOn=8]="TransparencyIsOn";(us={})[us.Rectangular=1]="Rectangular",us[us.Polygonal=2]="Polygonal";(cs={})[cs.Outside=0]="Outside",cs[cs.Inside=1]="Inside";function ul(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}let Qu={clippingBoundaryPath:[]},Ju=[{code:90,name:"version",parser:y},{code:10,name:"position",parser:Z},{code:11,name:"uPixel",parser:Z},{code:12,name:"vPixel",parser:Z},{code:13,name:"imageSize",parser:Z},{code:340,name:"imageDefHandle",parser:y},{code:70,name:"flags",parser:y},{code:280,name:"clipping",parser:y},{code:281,name:"brightness",parser:y},{code:282,name:"contrast",parser:y},{code:283,name:"fade",parser:y},{code:360,name:"imageDefReactorHandle",parser:y},{code:71,name:"clippingBoundaryType",parser:y},{code:91,name:"countBoundaryPoints",parser:y},{code:14,name:"clippingBoundaryPath",isMultiple:!0,parser:Z},{code:290,name:"clipMode",parser:y},{code:100,name:"subclassMarker",parser:y},...ne];class sa{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){ul(this,"parser",Tt(Ju,Qu))}}function cl(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}ul(sa,"ForEntityName","IMAGE");let tc={xScale:1,yScale:1,zScale:1,rotation:0,columnCount:0,rowCount:0,columnSpacing:0,rowSpacing:0,extrusionDirection:{x:0,y:0,z:1}},ec=[{code:210,name:"extrusionDirection",parser:Z},{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:Z},{code:2,name:"name",parser:y},{code:66,name:"isVariableAttributes",parser:Xt},{code:100,name:"subclassMarker",parser:y},...ne];class dl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){cl(this,"parser",Tt(ec,tc))}}function ml(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}cl(dl,"ForEntityName","INSERT");let rc={isArrowheadEnabled:!0},nc=[{code:213,name:"offsetFromAnnotation",parser:Z},{code:212,name:"offsetFromBlock",parser:Z},{code:211,name:"horizontalDirection",parser:Z},{code:210,name:"normal",parser:Z},{code:340,name:"associatedAnnotation",parser:y},{code:77,name:"byBlockColor",parser:y},{code:10,name:"vertices",parser:Z,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:Xt},{code:74,name:"isHooklineSameDirection",parser:Xt},{code:73,name:"leaderCreationFlag",parser:y},{code:72,name:"isSpline",parser:Xt},{code:71,name:"isArrowheadEnabled",parser:Xt},{code:3,name:"styleName",parser:y},{code:100,name:"subclassMarker",parser:y},...ne];class pl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){ml(this,"parser",Tt(nc,rc))}}ml(pl,"ForEntityName","LEADER");(_r={})[_r.TextAnnotation=0]="TextAnnotation",_r[_r.ToleranceAnnotation=1]="ToleranceAnnotation",_r[_r.BlockReferenceAnnotation=2]="BlockReferenceAnnotation",_r[_r.NoAnnotation=3]="NoAnnotation";function gl(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}let sc={thickness:0,extrusionDirection:{x:0,y:0,z:1}},ic=[{code:210,name:"extrusionDirection",parser:Z},{code:11,name:"endPoint",parser:Z},{code:10,name:"startPoint",parser:Z},{code:39,name:"thickness",parser:y},{code:100,name:"subclassMarker",parser:y},...ne];class fl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){gl(this,"parser",Tt(ic,sc))}}gl(fl,"ForEntityName","LINE");(ds={})[ds.IS_CLOSED=1]="IS_CLOSED",ds[ds.PLINE_GEN=128]="PLINE_GEN";let ac={flag:0,elevation:0,thickness:0,extrusionDirection:{x:0,y:0,z:1},vertices:[]},oc={bulge:0},lc=[{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}],hc=[{code:210,name:"extrusionDirection",parser:Z},{code:10,name:"vertices",isMultiple:!0,parser(a,t){let e={};return Tt(lc,oc)(a,t,e),e}},{code:39,name:"thickness",parser:y},{code:38,name:"elevation",parser:y},{code:43,name:"constantWidth",parser:y},{code:70,name:"flag",parser:y},{code:90,name:"numberOfVertices",parser:y},{code:100,name:"subclassMarker",parser:y},...ne];class Bs{parseEntity(t,e){let s={};return Tt(hc,ac)(e,t,s),s}}Ri="LWPOLYLINE",(Di="ForEntityName")in Bs?Object.defineProperty(Bs,Di,{value:Ri,enumerable:!0,configurable:!0,writable:!0}):Bs[Di]=Ri;(Zr={})[Zr.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",Zr[Zr.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",Zr[Zr.BY_STYLE=5]="BY_STYLE";function uc(a,t){let e={};for(let s of a){let o=t(s);o!=null&&(e[o]??(e[o]=[]),e[o].push(s))}return e}function*Ws(a,t=1/0,e=1){for(let s=a;s!==t;s+=e)yield s}function Or(a){return{x:a.x??0,y:a.y??0,z:a.z??0}}function _l(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}let cc={textStyle:"STANDARD",extrusionDirection:{x:0,y:0,z:1},rotation:0},Fs=[{code:46,name:"annotationHeight",parser:y},{code:101,parser(a,t){(function(e){e.rewind();let s=e.next();if(s.code!==101)throw Error("Bad call for skipEmbeddedObject()");do s=e.next();while(s.code!==0);e.rewind()})(t)}},{code:50,name:"columnHeight",parser: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:[...Ws(430,440)],name:"backgroundColor",parser:y},{code:[...Ws(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:Z},{code:210,name:"extrusionDirection",parser:Z},{code:7,name:"styleName",parser:y},{code:3,name:"text",isMultiple:!0,parser:y},{code:1,name:"text",isMultiple:!0,parser:y},{code:72,name:"drawingDirection",parser:y},{code:71,name:"attachmentPoint",parser:y},{code:41,name:"width",parser:y},{code:40,name:"height",parser:y},{code:10,name:"insertionPoint",parser:Z},{code:100,name:"subclassMarker",parser:y},...ne];class vl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){_l(this,"parser",Tt(Fs,cc))}}function yl(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}_l(vl,"ForEntityName","MTEXT");let dc={thickness:0,extrusionDirection:{x:0,y:0,z:1},angle:0},mc=[{code:50,name:"angle",parser:y},{code:210,name:"extrusionDirection",parser:Z},{code:39,name:"thickness",parser:y},{code:10,name:"position",parser:Z},{code:100,name:"subclassMarker",parser:y},...ne];class bl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){yl(this,"parser",Tt(mc,dc))}}yl(bl,"ForEntityName","POINT");(ue={})[ue.CLOSED_POLYLINE=1]="CLOSED_POLYLINE",ue[ue.CURVE_FIT=2]="CURVE_FIT",ue[ue.SPLINE_FIT=4]="SPLINE_FIT",ue[ue.POLYLINE_3D=8]="POLYLINE_3D",ue[ue.POLYGON_3D=16]="POLYGON_3D",ue[ue.CLOSED_POLYGON=32]="CLOSED_POLYGON",ue[ue.POLYFACE=64]="POLYFACE",ue[ue.CONTINUOUS=128]="CONTINUOUS";(vr={})[vr.NONE=0]="NONE",vr[vr.QUADRATIC=5]="QUADRATIC",vr[vr.CUBIC=6]="CUBIC",vr[vr.BEZIER=8]="BEZIER";(ce={})[ce.CREATED_BY_CURVE_FIT=1]="CREATED_BY_CURVE_FIT",ce[ce.TANGENT_DEFINED=2]="TANGENT_DEFINED",ce[ce.NOT_USED=4]="NOT_USED",ce[ce.CREATED_BY_SPLINE_FIT=8]="CREATED_BY_SPLINE_FIT",ce[ce.SPLINE_CONTROL_POINT=16]="SPLINE_CONTROL_POINT",ce[ce.FOR_POLYLINE=32]="FOR_POLYLINE",ce[ce.FOR_POLYGON=64]="FOR_POLYGON",ce[ce.POLYFACE=128]="POLYFACE";function xl(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}let pc={startWidth:0,endWidth:0,bulge:0},gc=[{code:91,name:"id",parser:y},{code:[...Ws(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},...ne],wl=class{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){xl(this,"parser",Tt(gc,pc))}};function Al(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}xl(wl,"ForEntityName","VERTEX");let fc={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:[]},_c=[{code:0,name:"vertices",isMultiple:!0,parser:(a,t)=>Nt(a,0,"VERTEX")?(a=t.next(),new wl().parseEntity(t,a)):ra},{code:210,name:"extrusionDirection",parser:Z},{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},...ne];class Pl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Al(this,"parser",Tt(_c,fc))}}function Sl(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}Al(Pl,"ForEntityName","POLYLINE");let vc={firstPoint:{x:0,y:0,z:1},extrusionDirection:{x:0,y:0,z:1}},yc=[{code:10,name:"firstPoint",parser:Z},{code:11,name:"unitDirection",parser:Z},{code:100,name:"subclassMarker",parser:y},...ne];class Il{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Sl(this,"parser",Tt(yc,vc))}}function kl(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}Sl(Il,"ForEntityName","RAY");let bc={vertices:[],backLineVertices:[]},xc=[{code:360,name:"geometrySettingHardId",parser:y},{code:12,name:"backLineVertices",isMultiple:!0,parser:Z},{code:93,name:"numberOfBackLineVertices",parser:y},{code:11,name:"vertices",isMultiple:!0,parser:Z},{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:Z},{code:1,name:"name",parser:y},{code:91,name:"flag",parser:y},{code:90,name:"state",parser:y},{code:100,name:"subclassMarker",parser:y},...ne];class El{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){kl(this,"parser",Tt(xc,bc))}}function Ml(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}kl(El,"ForEntityName","SECTION");let wc={points:[],thickness:0,extrusionDirection:{x:0,y:0,z:1}},Ac=[{code:210,name:"extrusionDirection",parser:Z},{code:39,name:"thickness",parser:y},{code:[...Ws(10,14)],name:"points",isMultiple:!0,parser:Z},{code:100,name:"subclassMarker",parser:y},...ne];class Tl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Ml(this,"parser",Tt(Ac,wc))}}Ml(Tl,"ForEntityName","SOLID");(Le={})[Le.NONE=0]="NONE",Le[Le.CLOSED=1]="CLOSED",Le[Le.PERIODIC=2]="PERIODIC",Le[Le.RATIONAL=4]="RATIONAL",Le[Le.PLANAR=8]="PLANAR",Le[Le.LINEAR=16]="LINEAR";function Cl(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}let Pc={knotTolerance:1e-6,controlTolerance:1e-6,fitTolerance:1e-9,knotValues:[],controlPoints:[],fitPoints:[]},Sc=[{code:11,name:"fitPoints",isMultiple:!0,parser:Z},{code:10,name:"controlPoints",isMultiple:!0,parser:Z},{code:41,name:"weights",isMultiple:!0,parser:y},{code:40,name:"knots",isMultiple:!0,parser:y},{code:13,name:"endTangent",parser:Z},{code:12,name:"startTangent",parser:Z},{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:Z},{code:100,name:"subclassMarker",parser:y},...ne];class Nl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Cl(this,"parser",Tt(Sc,Pc))}}Cl(Nl,"ForEntityName","SPLINE");class Vs{parseEntity(t,e){let s={};for(;!t.isEOF();){if(e.code===0){t.rewind();break}switch(e.code){case 100:s.subclassMarker=e.value,e=t.next();break;case 2:s.name=e.value,e=t.next();break;case 5:s.handle=e.value,e=t.next();break;case 10:s.startPoint=Or(Bt(t)),e=t.lastReadGroup;break;case 11:s.directionVector=Or(Bt(t)),e=t.lastReadGroup;break;case 90:s.tableValue=e.value,e=t.next();break;case 91:s.rowCount=e.value,e=t.next();break;case 92:s.columnCount=e.value,e=t.next();break;case 93:s.overrideFlag=e.value,e=t.next();break;case 94:s.borderColorOverrideFlag=e.value,e=t.next();break;case 95:s.borderLineWeightOverrideFlag=e.value,e=t.next();break;case 96:s.borderVisibilityOverrideFlag=e.value,e=t.next();break;case 141:s.rowHeightArr??(s.rowHeightArr=[]),s.rowHeightArr.push(e.value),e=t.next();break;case 142:s.columnWidthArr??(s.columnWidthArr=[]),s.columnWidthArr.push(e.value),e=t.next();break;case 280:s.version=e.value,e=t.next();break;case 310:s.bmpPreview??(s.bmpPreview=""),s.bmpPreview+=e.value,e=t.next();break;case 330:s.ownerDictionaryId=e.value,e=t.next();break;case 342:s.tableStyleId=e.value,e=t.next();break;case 343:s.blockRecordHandle=e.value,e=t.next();break;case 170:s.attachmentPoint=e.value,e=t.next();break;case 171:s.cells??(s.cells=[]),s.cells.push(function(o,h){let c=!1,g=!1,b={};for(;!o.isEOF()&&h.code!==0&&!g;)switch(h.code){case 171:if(c){g=!0;continue}b.cellType=h.value,c=!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 c=!1,g=!1,b}(t,e)),e=t.lastReadGroup;break;default:na(s,e,t),e=t.next()}}return s}}Fi="ACAD_TABLE",(Bi="ForEntityName")in Vs?Object.defineProperty(Vs,Bi,{value:Fi,enumerable:!0,configurable:!0,writable:!0}):Vs[Bi]=Fi;class Us{parseEntity(t,e){let s={};for(;e!=="EOF";){if(e.code===0){t.rewind();break}!function(o,h,c){if(c==="EOF")return!1;switch(c.code){case 0:default:return!1;case 100:o.subclassMarker=c.value;break;case 10:o.viewportCenter=Or(Bt(h));break;case 40:o.width=c.value;break;case 41:o.height=c.value;break;case 68:o.status=c.value;break;case 69:o.viewportId=c.value;break;case 12:o.displayCenter=Bt(h);break;case 13:o.snapBase=Bt(h);break;case 14:o.snapSpacing=Bt(h);break;case 15:o.gridSpacing=Bt(h);break;case 16:o.viewDirection=Or(Bt(h));break;case 17:o.targetPoint=Or(Bt(h));break;case 42:o.perspectiveLensLength=c.value;break;case 43:o.frontClipZ=c.value;break;case 44:o.backClipZ=c.value;break;case 45:o.viewHeight=c.value;break;case 50:o.snapAngle=c.value;break;case 51:o.viewTwistAngle=c.value;break;case 72:o.circleZoomPercent=c.value;break;case 331:o.frozenLayerIds??(o.frozenLayerIds=[]),o.frozenLayerIds.push(c.value);break;case 90:o.statusBitFlags=c.value;break;case 330:o.ownerBlockRecordSoftId=c.value;break;case 340:o.clippingBoundaryId=c.value;break;case 1:o.sheetName=c.value;break;case 281:o.renderMode=c.value;break;case 71:o.ucsPerViewport=c.value;break;case 110:o.ucsOrigin=Or(Bt(h));break;case 111:o.ucsXAxis=Or(Bt(h));break;case 112:o.ucsYAxis=Or(Bt(h));break;case 345:o.ucsId=c.value;break;case 346:o.ucsBaseId=c.value;break;case 79:o.orthographicType=c.value;break;case 146:o.elevation=c.value;break;case 170:o.shadePlotMode=c.value;break;case 61:o.majorGridFrequency=c.value;break;case 332:o.backgroundId=c.value;break;case 333:o.shadePlotId=c.value;break;case 348:o.visualStyleId=c.value;break;case 292:o.isDefaultLighting=!!c.value;break;case 282:o.defaultLightingType=c.value;break;case 141:o.brightness=c.value;break;case 142:o.contrast=c.value;break;case 63:case 421:case 431:o.ambientLightColor=c.value;break;case 361:o.sunId=c.value;break;case 335:case 343:case 344:case 91:o.softPointer=c.value}return!0}(s,t,e)&&na(s,e,t),e=t.next()}return s}}Ui="VIEWPORT",(Vi="ForEntityName")in Us?Object.defineProperty(Us,Vi,{value:Ui,enumerable:!0,configurable:!0,writable:!0}):Us[Vi]=Ui;class js extends sa{parseEntity(t,e){return super.parseEntity(t,e)}}function Ll(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}Gi="WIPEOUT",(ji="ForEntityName")in js?Object.defineProperty(js,ji,{value:Gi,enumerable:!0,configurable:!0,writable:!0}):js[ji]=Gi;let Ic={firstPoint:{x:0,y:0,z:1},extrusionDirection:{x:0,y:0,z:1}},kc=[{code:10,name:"firstPoint",parser:Z},{code:11,name:"unitDirection",parser:Z},{code:100,name:"subclassMarker",parser:y},...ne];class Ol{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Ll(this,"parser",Tt(kc,Ic))}}function zl(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}Ll(Ol,"ForEntityName","XLINE");let Ec={thickness:0,rotation:0,scale:1,obliqueAngle:0,textStyle:"STANDARD",textGenerationFlag:0,horizontalJustification:0,verticalJustification:0,extrusionDirection:{x:0,y:0,z:1}},Mc=[...Fs.slice(Fs.findIndex(({name:a})=>a==="columnType"),Fs.findIndex(({name:a})=>a==="subclassMarker")+1),{code:100},{code:0,parser(a){if(!Nt(a,0,"MTEXT"))return ra}},{code:2,name:"definitionTag",parser:y},{code:40,name:"annotationScale",parser:y},{code:10,name:"alignmentPoint",parser:Z},{code:340,name:"secondaryAttributesHardId",parser:y},{code:70,name:"numberOfSecondaryAttributes",parser:y},{code:70,name:"isReallyLocked",parser:Xt},{code:70,name:"mtextFlag",parser:y},{code:280,name:"isDuplicatedEntriesKeep",parser:Xt},{code:100},{code:280,name:"lockPositionFlag",parser:Xt},{code:210,name:"extrusionDirection",parser:Z},{code:11,name:"alignmentPoint",parser:Z},{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:Z},{code:39,name:"thickness",parser:y},{code:100},...ne];class Dl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){zl(this,"parser",Tt(Mc,Ec))}}zl(Dl,"ForEntityName","ATTRIB");let Tc=Object.fromEntries([$o,rl,Dl,sl,Rs,al,sa,dl,pl,fl,Bs,vl,bl,Pl,Il,El,Tl,Nl,Vs,tl,hl,Us,js,Ol].map(a=>[a.ForEntityName,new a]));function Rl(a,t){let e=[];for(;!Nt(a,0,"EOF");){if(a.code===0){if(a.value==="ENDBLK"||a.value==="ENDSEC"){t.rewind();break}let s=Tc[a.value];if(s){let o=a.value;a=t.next();let h=s.parseEntity(t,a);h.type=o,Ko(h),e.push(h)}else console.warn(`Unsupported ENTITY type: ${a.value}`)}a=t.next()}return e}function Cc(a,t){let e={};for(;!Nt(a,0,"EOF")&&!Nt(a,0,"ENDSEC");){if(Nt(a,0,"BLOCK")){let s=Nc(a=t.next(),t);Ko(s),s.name&&(e[s.name]=s)}a=t.next()}return e}function Nc(a,t){let e={};for(;!Nt(a,0,"EOF");){if(Nt(a,0,"ENDBLK")){for(a=t.next();!Nt(a,0,"EOF");){if(Nt(a,100,"AcDbBlockEnd"))return e;a=t.next()}break}switch(a.code){case 1:e.xrefPath=a.value;break;case 2:e.name=a.value;break;case 3:e.name2=a.value;break;case 5:e.handle=a.value;break;case 8:e.layer=a.value;break;case 10:e.position=Bt(t);break;case 67:e.paperSpace=!!a.value&&a.value==1;break;case 70:a.value!==0&&(e.type=a.value);break;case 100:break;case 330:e.ownerHandle=a.value;break;case 0:e.entities=Rl(a,t)}a=t.next()}return e}function Lc(a,t){let e=null,s={};for(;!Nt(a,0,"EOF")&&!Nt(a,0,"ENDSEC");)a.code===9?e=a.value:a.code===10?s[e]=Bt(t):s[e]=a.value,a=t.next();return s}let Oc=[{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:Z},{code:11,name:"sizeOfOnePixel",parser:Z},{code:280,name:"isLoaded",parser:y},{code:281,name:"resolutionUnits",parser:y},{code:100,name:"subclassMarker",parser:y}],Bl=[{code:333,name:"shadePlotId",parser:y},{code:149,name:"imageOriginY",parser:y},{code:148,name:"imageOriginX",parser:y},{code:147,name:"scaleFactor",parser:y},{code:78,name:"shadePlotCustomDPI",parser:y},{code:77,name:"shadePlotResolution",parser:y},{code:76,name:"shadePlotMode",parser:y},{code:75,name:"standardScaleType",parser:y},{code:7,name:"currentStyleSheet",parser:y},{code:74,name:"plotType",parser:y},{code:73,name:"plotRotation",parser:y},{code:72,name:"paperUnit",parser:y},{code:70,name:"layoutFlag",parser:y},{code:143,name:"printScaleDenominator",parser:y},{code:142,name:"printScaleNominator",parser:y},{code:141,name:"windowAreaYMax",parser:y},{code:140,name:"windowAreaYMin",parser:y},{code:49,name:"windowAreaXMax",parser:y},{code:48,name:"windowAreaXMin",parser:y},{code:47,name:"plotOriginY",parser:y},{code:46,name:"plotOriginX",parser:y},{code:45,name:"paperHeight",parser:y},{code:44,name:"paperWidth",parser:y},{code:43,name:"marginTop",parser:y},{code:42,name:"marginRight",parser:y},{code:41,name:"marginBottom",parser:y},{code:40,name:"marginLeft",parser:y},{code:6,name:"plotViewName",parser:y},{code:4,name:"paperSize",parser:y},{code:2,name:"configName",parser:y},{code:1,name:"pageSetupName",parser:y},{code:100,name:"subclassMarker",parser:y}],zc=[{code:333,name:"shadePlotId",parser:y},{code:346,name:"orthographicUcsId",parser:y},{code:345,name:"namedUcsId",parser:y},{code:331,name:"viewportId",parser:y},{code:330,name:"paperSpaceTableId",parser:y},{code:76,name:"orthographicType",parser:y},{code:17,name:"ucsYAxis",parser:Z},{code:16,name:"ucsXAxis",parser:Z},{code:13,name:"ucsOrigin",parser:Z},{code:146,name:"elevation",parser:y},{code:15,name:"maxExtent",parser:Z},{code:14,name:"minExtent",parser:Z},{code:12,name:"insertionBase",parser:Z},{code:11,name:"maxLimit",parser:Z},{code:10,name:"minLimit",parser:Z},{code:71,name:"tabOrder",parser:y},{code:70,name:"controlFlag",parser:y},{code:1,name:"layoutName",parser:y},{code:100,name:"subclassMarker",parser:y},...Bl],Dc=[{code:330,name:"ownerObjectId",parser:y},{code:102},{code:360,name:"ownerDictionaryIdHard",parser:y},{code:102},{code:102},{code:330,name:"ownerDictionaryIdSoft",parser:y},{code:102},{code:102},{code:102},{code:5,name:"handle",parser:y}];function vo(a){return a.subclassMarker==="AcDbDictionary"}let Rc={LAYOUT:zc,PLOTSETTINGS:Bl,DICTIONARY:[{code:3,name:"entries",parser:(a,t)=>{let e={name:a.value};return(a=t.next()).code===350?e.objectId=a.value:t.rewind(),e},isMultiple:!0},{code:281,name:"recordCloneFlag",parser:y},{code:280,name:"isHardOwned",parser:Xt},{code:100,name:"subclassMarker",parser:y}],IMAGEDEF:Oc};function Bc(a,t){let e=[];for(;a.code!==0||!["EOF","ENDSEC"].includes(a.value);){let s=a.value,o=Rc[s];if(a.code===0&&(o!=null&&o.length)){let h=Tt([...Dc,...o]),c={name:s};h(a=t.next(),t,c)?(e.push(c),a=t.peek()):a=t.next()}else a=t.next()}return{byName:uc(e,({name:s})=>s),byTree:function(s){let o=Object.fromEntries(s.map(h=>[h.handle,h]));for(let h of s)(!vo(h)||h.ownerDictionaryIdSoft!=="0")&&(h.ownerDictionaryIdSoft&&(h.ownerDictionarySoft=o[h.ownerDictionaryIdSoft]),h.ownerDictionaryIdHard&&(h.ownerDictionaryHard=o[h.ownerDictionaryIdHard]),h.ownerObjectId&&(h.ownerObject=o[h.ownerObjectId])),function(c,g){vo(c)&&c.entries&&(c.entries=Object.fromEntries(c.entries.map(({name:b,objectId:f})=>[b,g[f]])))}(h,o);return s[0]}(e)}}let In=[{code:100,name:"subclassMarker",parser:y},{code:330,name:"ownerObjectId",parser:y},{code:102,parser(a,t){for(;!Nt(a,0,"EOF")&&!Nt(a,102,"}");)a=t.next()}},{code:5,name:"handle",parser:y}],Fc=Tt([{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},...In]),Vc=Tt([...[{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:fo.Above,defaultValueImperial:fo.Center},{name:"DIMZIN",code:78,defaultValue:wn.Trailing,defaultValueImperial:wn.Feet},{name:"DIMAZIN",code:79,defaultValue:Iu.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:ku.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:wn.Trailing,defaultValueImperial:wn.Feet},{name:"DIMALTZ",code:285,defaultValue:wn.Trailing},{name:"DIMALTTZ",code:286,defaultValue:wn.Trailing},{name:"DIMFIT",code:287},{name:"DIMUPT",code:288,defaultValue:0},{name:"DIMATFIT",code:289,defaultValue:3},{name:"DIMTXSTY",code:340},{name:"DIMLDRBLK",code:341},{name:"DIMBLK",code:342},{name:"DIMBLK1",code:343},{name:"DIMBLK2",code:344},{name:"DIMLWD",code:371,defaultValue:-2},{name:"DIMLWD",code:372,defaultValue:-2}].map(a=>({...a,parser:y})),{code:70,name:"standardFlag",parser:y},{code:2,name:"name",parser:y},{code:100,name:"subclassMarker",parser:y},{code:105,name:"handle",parser:y},...In.filter(a=>a.code!==5)]),Uc=Tt([{code:347,name:"materialObjectId",parser:y},{code:390,name:"plotStyleNameObjectId",parser:y},{code:370,name:"lineweight",parser:y},{code:290,name:"isPlotting",parser:Xt},{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},...In]),jc=Tt([{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}),Gc={BLOCK_RECORD:Fc,DIMSTYLE:Vc,LAYER:Uc,LTYPE:Tt([{code:49,name:"pattern",parser(a,t){let e={};return jc(a,t,e),e},isMultiple:!0},{code:40,name:"totalPatternLength",parser:y},{code:73,name:"numberOfLineTypes",parser:y},{code:72,parser:y},{code:3,name:"description",parser:y},{code:70,name:"standardFlag",parser:y},{code:2,name:"name",parser:y},{code:100,name:"subclassMarker",parser:y},...In]),STYLE:Tt([{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},...In]),VPORT:Tt([{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:Xt},{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:Z},{code:111,name:"ucsXAxis",parser:Z},{code:110,name:"ucsOrigin",parser:Z},{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:Z},{code:16,name:"viewDirectionFromTarget",parser:Z},{code:15,name:"gridSpacing",parser:Z},{code:14,name:"snapSpacing",parser:Z},{code:13,name:"snapBasePoint",parser:Z},{code:12,name:"center",parser:Z},{code:11,name:"upperRightCorner",parser:Z},{code:10,name:"lowerLeftCorner",parser:Z},{code:70,name:"standardFlag",parser:y},{code:2,name:"name",parser:y},{code:100,name:"subclassMarker",parser:y},...In])},Wc=Tt([{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 Hc(a,t){var s;let e={};for(;!Nt(a,0,"EOF")&&!Nt(a,0,"ENDSEC");){if(Nt(a,0,"TABLE")){a=t.next();let o={entries:[]};Wc(a,t,o),e[o.name]=o}if(Nt(a,0)&&!Nt(a,0,"ENDTAB")){let o=a.value;a=t.next();let h=Gc[o];if(!h){console.warn(`parseTable: Invalid table name '${o}'`),a=t.next();continue}let c={};h(a,t,c),(s=e[o])==null||s.entries.push(c)}a=t.next()}return e}function Ts(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}class yo{next(){if(!this.hasNext())return this._eof?console.warn("Cannot call 'next' after EOF group has been read"):console.warn("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]),{code:0,value:"EOF"};let t=parseInt(this._data[this._pointer++],10),e=bo(t,this._data[this._pointer++]),s={code:t,value:e};return Nt(s,0,"EOF")&&(this._eof=!0),this.lastReadGroup=s,s}peek(){if(!this.hasNext())throw this._eof?Error("Cannot call 'next' after EOF group has been read"):Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);let t={code:parseInt(this._data[this._pointer]),value:0};return t.value=bo(t.code,this._data[this._pointer+1]),t}rewind(t){t=t||1,this._pointer=this._pointer-2*t}hasNext(){return!this._eof&&!(this._pointer>this._data.length-2)}isEOF(){return this._eof}constructor(t){Ts(this,"_pointer",void 0),Ts(this,"_data",void 0),Ts(this,"_eof",void 0),Ts(this,"lastReadGroup",{code:0,value:0}),this._pointer=0,this._data=t,this._eof=!1}}function bo(a,t){return a<=9?t:a>=10&&a<=59?parseFloat(t.trim()):a>=60&&a<=99?parseInt(t.trim()):a>=100&&a<=109?t:a>=110&&a<=149?parseFloat(t.trim()):a>=160&&a<=179?parseInt(t.trim()):a>=210&&a<=239?parseFloat(t.trim()):a>=270&&a<=289?parseInt(t.trim()):a>=290&&a<=299?function(e){if(e==="0")return!1;if(e==="1")return!0;throw TypeError("String '"+e+"' cannot be cast to Boolean type")}(t.trim()):a>=300&&a<=369?t:a>=370&&a<=389?parseInt(t.trim()):a>=390&&a<=399?t:a>=400&&a<=409?parseInt(t.trim()):a>=410&&a<=419?t:a>=420&&a<=429?parseInt(t.trim()):a>=430&&a<=439?t:a>=440&&a<=459?parseInt(t.trim()):a>=460&&a<=469?parseFloat(t.trim()):a>=470&&a<=481||a===999||a>=1e3&&a<=1009?t:a>=1010&&a<=1059?parseFloat(t.trim()):a>=1060&&a<=1071?parseInt(t.trim()):(console.log("WARNING: Group code does not have a defined type: %j",{code:a,value:t}),t)}function Xi(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}let qc=class{constructor(){Xi(this,"encoding","utf-8"),Xi(this,"encodingFailureFatal",!1)}};class Yc extends EventTarget{parseSync(t){let e=new yo(t.split(/\r\n|\r|\n/g));if(!e.hasNext())throw Error("Empty file");return this.parseAll(e)}parseStream(t){let e="",s=this;return new Promise((o,h)=>{t.on("data",c=>{e+=c}),t.on("end",()=>{try{let c=e.split(/\r\n|\r|\n/g),g=new yo(c);if(!g.hasNext())throw Error("Empty file");o(s.parseAll(g))}catch(c){h(c)}}),t.on("error",c=>{h(c)})})}async parseFromUrl(t,e){let s=await fetch(t,e);if(!s.body)return null;let o=s.body.getReader(),h="";for(;;){let{done:c,value:g}=await o.read();if(c){h+=this._decoder.decode(new ArrayBuffer(0),{stream:!1});break}h+=this._decoder.decode(g,{stream:!0})}return this.parseSync(h)}parseAll(t){let e={header:{},blocks:{},entities:[],tables:{},objects:{byName:{},byTree:void 0}},s=t.next();for(;!Nt(s,0,"EOF");)Nt(s,0,"SECTION")&&(Nt(s=t.next(),2,"HEADER")?(s=t.next(),e.header=Lc(s,t)):Nt(s,2,"BLOCKS")?(s=t.next(),e.blocks=Cc(s,t)):Nt(s,2,"ENTITIES")?(s=t.next(),e.entities=Rl(s,t)):Nt(s,2,"TABLES")?(s=t.next(),e.tables=Hc(s,t)):Nt(s,2,"OBJECTS")&&(s=t.next(),e.objects=Bc(s,t))),s=t.next();return e}constructor(t=new qc){super(),Xi(this,"_decoder",void 0),this._decoder=new TextDecoder(t.encoding,{fatal:t.encodingFailureFatal})}}var ia=(a=>(a[a.DecimalDegrees=0]="DecimalDegrees",a[a.DegreesMinutesSeconds=1]="DegreesMinutesSeconds",a[a.Gradians=2]="Gradians",a[a.Radians=3]="Radians",a[a.SurveyorsUnits=4]="SurveyorsUnits",a))(ia||{});class Dr{static get instance(){return this._instance||(this._instance=new Dr),this._instance}constructor(){this._blocks=new Map}createKey(t,e){return`${t}_${e}`}set(t,e){return e=e.fastDeepClone(),this._blocks.set(t,e),e}get(t){let e=this._blocks.get(t);return e&&(e=e.fastDeepClone()),e}has(t){return this._blocks.has(t)}clear(){this._blocks.clear()}draw(t,e,s,o=!0,h,c){const g=[];if(e!=null){const b=this.createKey(e.name,s);let f;if(this.has(b))f=this.get(b);else{const S=e.newIterator();for(const x of S)if(x.color.isByBlock&&s){xo.copy(x.color),x.color.color=s;const k=x.draw(t);k&&g.push(k),x.color.copy(xo)}else{const k=x.draw(t);k&&g.push(k)}f=t.group(g),f&&o&&this.set(b,f)}return f&&h&&(f.applyMatrix(h),c&&(c.x!=0||c.y!=0||c.z!=1)&&(h.setFromExtrusionDirection(c),f.applyMatrix(h))),f}else return t.group(g)}}const xo=new an,Hs="Continuous",Gs="ByLayer",Fl="ByBlock";var tn=(a=>(a[a.EndPoint=1]="EndPoint",a[a.MidPoint=2]="MidPoint",a[a.Center=3]="Center",a[a.Node=4]="Node",a[a.Quadrant=5]="Quadrant",a[a.Insertion=7]="Insertion",a[a.Perpendicular=8]="Perpendicular",a[a.Tangent=9]="Tangent",a[a.Nearest=10]="Nearest",a[a.Centroid=11]="Centroid",a))(tn||{}),aa=(a=>(a[a.Undefined=0]="Undefined",a[a.Inches=1]="Inches",a[a.Feet=2]="Feet",a[a.Miles=3]="Miles",a[a.Millimeters=4]="Millimeters",a[a.Centimeters=5]="Centimeters",a[a.Meters=6]="Meters",a[a.Kilometers=7]="Kilometers",a[a.Microinches=8]="Microinches",a[a.Mils=9]="Mils",a[a.Yards=10]="Yards",a[a.Angstroms=11]="Angstroms",a[a.Nanometers=12]="Nanometers",a[a.Microns=13]="Microns",a[a.Decimeters=14]="Decimeters",a[a.Dekameters=15]="Dekameters",a[a.Hectometers=16]="Hectometers",a[a.Gigameters=17]="Gigameters",a[a.Astronomical=18]="Astronomical",a[a.LightYears=19]="LightYears",a[a.Parsecs=20]="Parsecs",a[a.USSurveyFeet=21]="USSurveyFeet",a[a.USSurveyInch=22]="USSurveyInch",a[a.USSurveyYard=23]="USSurveyYard",a[a.USSurveyMile=24]="USSurveyMile",a[a.Max=24]="Max",a))(aa||{});function Kc(a){return a==4||a==5||a==6||a==7||a==12||a==13||a==14||a==15||a==16||a==17}function Xc(a){return a==1||a==2||a==3||a==8||a==9||a==10||a==21}var Vl=(a=>(a.ClosedFilled="",a.Dot="_DOT",a.DotSmall="_DOTSMALL",a.DotBlank="_DOTBLANK",a.Origin="_ORIGIN",a.Origin2="_ORIGIN2",a.Open="_OPEN",a.Open90="_OPEN90",a.Open30="_OPEN30",a.Closed="_CLOSED",a.Small="_SMALL",a.None="_NONE",a.Oblique="_OBLIQUE",a.BoxFilled="_BOXFILLED",a.Box="_BOXBLANK",a.ClosedBlank="_CLOSEDBLANK",a.DatumBlank="_DATUMBLANK",a.DatumFilled="_DATUMFILLED",a.Integral="_INTEGRAL",a.ArchTick="_ARCHTICK",a))(Vl||{});class _i{constructor(t){this.i=0,this._records=t,this._keys=Array.from(t.keys())}[Symbol.iterator](){return this}next(){for(;this.i<this._keys.length;){const t=this._records.get(this._keys[this.i]);return this.i+=1,{value:t,done:!1}}return{value:null,done:!0}}}const Ul="Load Database";class Se extends Uo{constructor(t,e){super(t.stage),this.data=t,this.progress=e}async run(t){const e=ea.getInstance().getEntry(Ul),s=Date.now();this.progress&&await this.progress(this.data.progress.value,this.data.stage,"START");const o=await this.data.task(t);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 e&&(e.data[this.name]=Date.now()-s),o}}class jl{constructor(t={}){this.config=t}async read(t,e,s,o){const h={name:Ul,data:{total:0},format(){let f="";return Object.keys(this.data).forEach(S=>{S!=="total"&&(f+=`- ${S}: ${this.data[S]} ms
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function fu(a,t){for(var e=0;e<t.length;e++){const s=t[e];if(typeof s!="string"&&!Array.isArray(s)){for(const o in s)if(o!=="default"&&!(o in a)){const h=Object.getOwnPropertyDescriptor(s,o);h&&Object.defineProperty(a,o,h.get?h:{enumerable:!0,get:()=>s[o]})}}}return Object.freeze(Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}))}const zs={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},Li=[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 Qn(a,t,e){return Math.max(t,Math.min(e,a))}const Lo=class Oo{constructor(){this._colorIndex=256,this._color=null,this._colorName=null}get color(){return this._color}set color(t){t==null?this._color=null:(this._color=Math.round(Qn(t,0,256*256*256-1)),this._colorIndex=this.getColorIndexByValue(this._color),this._colorName=this.getColorNameByValue(this._color))}get hexColor(){if(this._color&&this._color>0&&this._color<=16777215){let t=this._color.toString(16).toUpperCase();for(;t.length<6;)t="0"+t;return`0x${t}`}return""}get cssColor(){return`rgb(${this.red},${this.green},${this.blue})`}get red(){return this.color?this.color>>16&255:null}get green(){return this.color?this.color>>8&255:null}get blue(){return this.color?this.color&255:null}get colorIndex(){return this._colorIndex}set colorIndex(t){t==null?this._colorIndex=null:(this._colorIndex=Qn(t,0,256),this._color=Li[t],this._colorName=this.getColorNameByValue(this._color))}get colorName(){return this._colorName}set colorName(t){if(t){const e=zs[t.toLowerCase()];e!==void 0?(this._colorName=t,this._color=e,this._colorIndex=this.getColorIndexByValue(this._color)):console.warn("Unknown color: "+t)}else this._colorName=null}get hasColorName(){return this._colorName==null}get hasColorIndex(){return this._colorIndex==null}get isByLayer(){return this.colorIndex==256}setByLayer(){return this.colorIndex=256,this}get isByBlock(){return this.colorIndex==0}setByBlock(){return this.colorIndex=0,this}setScalar(t){return this.setRGB(t,t,t),this}setRGB(t,e,s){const o=Math.round(Qn(t,0,255)),h=Math.round(Qn(e,0,255)),c=Math.round(Qn(s,0,255));return this.color=(o<<16)+(h<<8)+c,this}setColorName(t){const e=zs[t.toLowerCase()];return e!==void 0?this.color=e:console.warn("Unknown color "+t),this}clone(){const t=new Oo;return t.colorIndex=this.colorIndex,t.color=this.color,t._colorName=this._colorName,this}copy(t){return this.colorIndex=t.colorIndex,this.color=t.color,this._colorName=t._colorName,this}equals(t){return t.color==this.color&&t.colorIndex==this.colorIndex&&t._colorName==this._colorName}toString(){return this.isByLayer?"ByLayer":this.isByBlock?"ByBlock":this.colorName?this.colorName:this.hexColor}getColorNameByValue(t){for(const[e,s]of Object.entries(zs))if(s===t)return e;return null}getColorIndexByValue(t){const e=Li.length-1;for(let s=1;s<e;++s)if(Li[s]===t)return s;return null}};Lo.NAMES=zs;let an=Lo;const Re={get ILLEGAL_PARAMETERS(){return new ReferenceError("Illegal Parameters")},get ZERO_DIVISION(){return new Error("Zero division")},get UNRESOLVED_BOUNDARY_CONFLICT(){return new Error("Unresolved boundary conflict in boolean operation")},get INFINITE_LOOP(){return new Error("Infinite loop")},get CANNOT_INVOKE_ABSTRACT_METHOD(){return new Error("Abstract method cannot be invoked")},get OPERATION_IS_NOT_SUPPORTED(){return new Error("Operation is not supported")},get NOT_IMPLEMENTED(){return new Error("Not implemented yet")}};class _u{constructor(){this._listeners={}}addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const s=this._listeners;s[t]===void 0&&(s[t]=[]),s[t].indexOf(e)===-1&&s[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const s=this._listeners;return s[t]!==void 0&&s[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const s=this._listeners[t];if(s!==void 0){const o=s.indexOf(e);o!==-1&&s.splice(o,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const e=this._listeners[t.type];if(e!==void 0){t.target=this;const s=e.slice(0);for(let o=0,h=s.length;o<h;o++)s[o].call(this,t)}}}let ie=class{constructor(){this.listeners=[]}addEventListener(t){this.listeners.push(t)}removeEventListener(t){this.listeners=this.listeners.filter(e=>e!==t)}replaceEventListener(t){this.removeEventListener(t),this.addEventListener(t)}dispatch(t,...e){for(const s of this.listeners)s.call(null,t,...e)}};var vu=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function yu(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var zo={exports:{}};(function(a){(function(t,e){a.exports?a.exports=e():t.log=e()})(vu,function(){var t=function(){},e="undefined",s=typeof window!==e&&typeof window.navigator!==e&&/Trident\/|MSIE /.test(window.navigator.userAgent),o=["trace","debug","info","warn","error"],h={},c=null;function g(z,U){var B=z[U];if(typeof B.bind=="function")return B.bind(z);try{return Function.prototype.bind.call(B,z)}catch{return function(){return Function.prototype.apply.apply(B,[z,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(z){return z==="debug"&&(z="log"),typeof console===e?!1:z==="trace"&&s?b:console[z]!==void 0?g(console,z):console.log!==void 0?g(console,"log"):t}function S(){for(var z=this.getLevel(),U=0;U<o.length;U++){var B=o[U];this[B]=U<z?t:this.methodFactory(B,z,this.name)}if(this.log=this.debug,typeof console===e&&z<this.levels.SILENT)return"No console available for logging"}function x(z){return function(){typeof console!==e&&(S.call(this),this[z].apply(this,arguments))}}function k(z,U,B){return f(z)||x.apply(this,arguments)}function M(z,U){var B=this,gt,ft,ut,W="loglevel";typeof z=="string"?W+=":"+z:typeof z=="symbol"&&(W=void 0);function mt(bt){var Lt=(o[bt]||"silent").toUpperCase();if(!(typeof window===e||!W)){try{window.localStorage[W]=Lt;return}catch{}try{window.document.cookie=encodeURIComponent(W)+"="+Lt+";"}catch{}}}function lt(){var bt;if(!(typeof window===e||!W)){try{bt=window.localStorage[W]}catch{}if(typeof bt===e)try{var Lt=window.document.cookie,de=encodeURIComponent(W),me=Lt.indexOf(de+"=");me!==-1&&(bt=/^([^;]+)/.exec(Lt.slice(me+de.length+1))[1])}catch{}return B.levels[bt]===void 0&&(bt=void 0),bt}}function Wt(){if(!(typeof window===e||!W)){try{window.localStorage.removeItem(W)}catch{}try{window.document.cookie=encodeURIComponent(W)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function Ht(bt){var Lt=bt;if(typeof Lt=="string"&&B.levels[Lt.toUpperCase()]!==void 0&&(Lt=B.levels[Lt.toUpperCase()]),typeof Lt=="number"&&Lt>=0&&Lt<=B.levels.SILENT)return Lt;throw new TypeError("log.setLevel() called with invalid level: "+bt)}B.name=z,B.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},B.methodFactory=U||k,B.getLevel=function(){return ut??ft??gt},B.setLevel=function(bt,Lt){return ut=Ht(bt),Lt!==!1&&mt(ut),S.call(B)},B.setDefaultLevel=function(bt){ft=Ht(bt),lt()||B.setLevel(bt,!1)},B.resetLevel=function(){ut=null,Wt(),S.call(B)},B.enableAll=function(bt){B.setLevel(B.levels.TRACE,bt)},B.disableAll=function(bt){B.setLevel(B.levels.SILENT,bt)},B.rebuild=function(){if(c!==B&&(gt=Ht(c.getLevel())),S.call(B),c===B)for(var bt in h)h[bt].rebuild()},gt=Ht(c?c.getLevel():"WARN");var Ut=lt();Ut!=null&&(ut=Ht(Ut)),S.call(B)}c=new M,c.getLogger=function(z){if(typeof z!="symbol"&&typeof z!="string"||z==="")throw new TypeError("You must supply a name when creating a logger.");var U=h[z];return U||(U=h[z]=new M(z,c.methodFactory)),U};var D=typeof window!==e?window.log:void 0;return c.noConflict=function(){return typeof window!==e&&window.log===c&&(window.log=D),c},c.getLoggers=function(){return h},c.default=c,c})})(zo);var Do=zo.exports;const bu=yu(Do),xu=fu({__proto__:null,default:bu},[Do]),wu=!0,gs=xu;gs.setLevel("debug");const Au=a=>{try{gs.setLevel(a)}catch(t){gs.setLevel("error"),gs.error(t)}};function ms(a){return a===null||typeof a!="object"?a:Array.isArray(a)?[...a]:{...a}}function Mn(a,...t){for(const e of t)if(e)for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&a[s]===void 0&&(a[s]=e[s]);return a}function Ro(a,t){return a!=null&&Object.prototype.hasOwnProperty.call(a,t)}function Bo(a){return a==null?!0:Array.isArray(a)||typeof a=="string"?a.length===0:a instanceof Map||a instanceof Set?a.size===0:typeof a=="object"?Object.keys(a).length===0:!1}function Sn(a,t){if(a===t)return!0;if(a==null||t==null)return a===t;if(typeof a!=typeof t)return!1;if(typeof a!="object")return a===t;if(Array.isArray(a)!==Array.isArray(t))return!1;if(Array.isArray(a)){if(a.length!==t.length)return!1;for(let o=0;o<a.length;o++)if(!Sn(a[o],t[o]))return!1;return!0}const e=Object.keys(a),s=Object.keys(t);if(e.length!==s.length)return!1;for(const o of e)if(!Object.prototype.hasOwnProperty.call(t,o)||!Sn(a[o],t[o]))return!1;return!0}let Fo=class Vo{constructor(t,e){this.events={attrChanged:new ie,modelChanged:new ie},this._changing=!1,this._previousAttributes={},this._pending=!1;const s=t||{};e&&Mn(s,e),this.attributes=s,this.changed={}}get(t){return this.attributes[t]}set(t,e,s){if(t==null)return this;let o;typeof t=="object"?(o=t,s=e):(o={},o[t]=e),s||(s={});const h=s.unset,c=s.silent,g=[],b=this._changing;this._changing=!0,b||(this._previousAttributes=ms(this.attributes),this.changed={});const f=this.attributes,S=this.changed,x=this._previousAttributes;for(const k in o)e=o[k],Sn(f[k],e)||g.push(k),Sn(x[k],e)?delete S[k]:S[k]=e,h?delete f[k]:f[k]=e;if(!c){g.length&&(this._pending=s);for(let k=0;k<g.length;k++)this.events.attrChanged.dispatch({object:this,attrName:g[k],attrValue:f[g[k]],options:s})}if(b)return this;if(!c)for(;this._pending;)s=this._pending,this._pending=!1,this.events.modelChanged.dispatch({object:this,options:s});return this._pending=!1,this._changing=!1,this}has(t){return this.get(t)!=null}hasChanged(t){return t==null?!Bo(this.changed):Ro(this.changed,t)}changedAttributes(t){if(!t)return this.hasChanged()?ms(this.changed):{};const e=this._changing?this._previousAttributes:this.attributes,s={};for(const o in t){const h=t[o];Sn(e[o],h)||(s[o]=h)}return s}previous(t){return t==null||!this._previousAttributes?null:this._previousAttributes[t]}previousAttributes(){return ms(this._previousAttributes)}clone(){const t=ms(this.attributes);return new Vo(t)}},ea=class ps{constructor(){this.entries=new Map}static getInstance(){return ps.instance||(ps.instance=new ps),ps.instance}collect(t){this.entries.set(t.name,t)}printAll(){for(const[t,e]of this.entries)console.log(`${t}:`),console.log(e.format())}clear(){this.entries.clear()}getAll(){return Array.from(this.entries.values())}getEntry(t){return this.entries.get(t)}remove(t){return this.entries.delete(t)}};class Pu{static formatBytes(t,e=2){if(t===0)return"0 B";const s=1024,o=Math.max(0,e),h=["B","KB","MB","GB","TB"],c=Math.floor(Math.log(t)/Math.log(s)),g=t/Math.pow(s,c);return`${parseFloat(g.toFixed(o))} ${h[c]}`}}class Uo{constructor(t){this.name=t}run(t){throw new Error("run() must be implemented by subclass")}}class jo{constructor(){this.tasks=[],this.onProgress=()=>{},this.onComplete=()=>{},this.onError=()=>{}}scheduleTask(t){return new Promise((e,s)=>{const o=()=>{Promise.resolve(t()).then(e).catch(s)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(o):setTimeout(o,0)})}addTask(t){this.tasks.push(t)}setProgressCallback(t){this.onProgress=t}setCompleteCallback(t){this.onComplete=t}setErrorCallback(t){this.onError=t}async run(t){const e=this.tasks.length;let s=t;for(let o=0;o<e;o++){const h=this.tasks[o];try{s=await this.scheduleTask(async()=>{const c=await h.run(s);return this.onProgress((o+1)/e,h),c})}catch(c){this.onError({error:c,taskIndex:o,task:h});return}}this.onComplete(s)}}let Go=class{constructor(t,e,s){this.isLoading=!1,this.itemsLoaded=0,this.itemsTotal=0,this.urlModifier=void 0,this.handlers=[],this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=s}itemStart(t){this.itemsTotal++,this.isLoading===!1&&this.onStart!==void 0&&this.onStart(t,this.itemsLoaded,this.itemsTotal),this.isLoading=!0}itemEnd(t){this.itemsLoaded++,this.onProgress!==void 0&&this.onProgress(t,this.itemsLoaded,this.itemsTotal),this.itemsLoaded===this.itemsTotal&&(this.isLoading=!1,this.onLoad!==void 0&&this.onLoad())}itemError(t){this.onError!==void 0&&this.onError(t)}resolveURL(t){return this.urlModifier?this.urlModifier(t):t}setURLModifier(t){return this.urlModifier=t,this}addHandler(t,e){return this.handlers.push(t,e),this}removeHandler(t){const e=this.handlers.indexOf(t);return e!==-1&&this.handlers.splice(e,2),this}getHandler(t){for(let e=0,s=this.handlers.length;e<s;e+=2){const o=this.handlers[e],h=this.handlers[e+1];if(o.global&&(o.lastIndex=0),o.test(t))return h}return null}};const Wo=new Go;let Su=class{constructor(t){this.manager=t!==void 0?t:Wo,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}loadAsync(t,e){return new Promise((s,o)=>{this.load(t,s,e,o)})}parse(t){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}};class Ho{constructor(t,e,s){this._chunkSize=-1,this._minimumChunkSize=50,this._count=t,this._numerOfChunk=e<1?1:e,this._minimumChunkSize=s,this.calculateChunkSize()}get count(){return this._count}get numerOfChunk(){return this._numerOfChunk}get minimumChunkSize(){return this._minimumChunkSize}set minimumChunkSize(t){this._minimumChunkSize=t,this.calculateChunkSize()}get chunkSize(){return this._chunkSize}calculateChunkSize(){let t=this._count/this._numerOfChunk;t<this._minimumChunkSize&&(t=Math.min(this._minimumChunkSize,this._count)),this._chunkSize=t<1?this._count:Math.floor(t)}scheduleTask(t){return new Promise((e,s)=>{const o=()=>{Promise.resolve(t()).then(e).catch(s)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(o):setTimeout(o,0)})}async processChunk(t){let e=0;const s=async()=>{const o=e,h=Math.min(e+this._chunkSize,this._count);await t(o,h),e=h,e<this._count&&await this.scheduleTask(s)};await s()}}var he,Jn,Zt,se,ts,$e,ye,cr,Ze,qr,es,rs,Yr,Kr,ns,ss,is,Ce,dr,Gt,Xr,as,vt,be,os,xe,mr,ls,pr,Qe,hs,$r,Ne,gr,Oi,zi,fr,us,cs,_r,ds,Di,Ri,Zr,ue,vr,ce,Le,Bi,Fi,Vi,Ui,ji,Gi;(he={})[he.None=0]="None",he[he.Anonymous=1]="Anonymous",he[he.NonConstant=2]="NonConstant",he[he.Xref=4]="Xref",he[he.XrefOverlay=8]="XrefOverlay",he[he.ExternallyDependent=16]="ExternallyDependent",he[he.ResolvedOrDependent=32]="ResolvedOrDependent",he[he.ReferencedXref=64]="ReferencedXref";(Jn={})[Jn.BYBLOCK=0]="BYBLOCK",Jn[Jn.BYLAYER=256]="BYLAYER";(Zt={})[Zt.Rotated=0]="Rotated",Zt[Zt.Aligned=1]="Aligned",Zt[Zt.Angular=2]="Angular",Zt[Zt.Diameter=3]="Diameter",Zt[Zt.Radius=4]="Radius",Zt[Zt.Angular3Point=5]="Angular3Point",Zt[Zt.Ordinate=6]="Ordinate",Zt[Zt.ReferenceIsExclusive=32]="ReferenceIsExclusive",Zt[Zt.IsOrdinateXTypeFlag=64]="IsOrdinateXTypeFlag",Zt[Zt.IsCustomTextPositionFlag=128]="IsCustomTextPositionFlag";(se={})[se.TopLeft=1]="TopLeft",se[se.TopCenter=2]="TopCenter",se[se.TopRight=3]="TopRight",se[se.MiddleLeft=4]="MiddleLeft",se[se.MiddleCenter=5]="MiddleCenter",se[se.MiddleRight=6]="MiddleRight",se[se.BottomLeft=7]="BottomLeft",se[se.BottomCenter=8]="BottomCenter",se[se.BottomRight=9]="BottomRight";(ts={})[ts.AtLeast=1]="AtLeast",ts[ts.Exact=2]="Exact";var fo=(($e={})[$e.Center=0]="Center",$e[$e.Above=1]="Above",$e[$e.Outside=2]="Outside",$e[$e.JIS=3]="JIS",$e[$e.Below=4]="Below",$e),wn=((ye={})[ye.Feet=0]="Feet",ye[ye.None=1]="None",ye[ye.Inch=2]="Inch",ye[ye.FeetAndInch=3]="FeetAndInch",ye[ye.Leading=4]="Leading",ye[ye.Trailing=8]="Trailing",ye[ye.LeadingAndTrailing=12]="LeadingAndTrailing",ye),Iu=((cr={})[cr.None=0]="None",cr[cr.Leading=1]="Leading",cr[cr.Trailing=2]="Trailing",cr[cr.LeadingAndTrailing=3]="LeadingAndTrailing",cr),ku=((Ze={})[Ze.Center=0]="Center",Ze[Ze.Left=1]="Left",Ze[Ze.Right=2]="Right",Ze[Ze.OverFirst=3]="OverFirst",Ze[Ze.OverSecond=4]="OverSecond",Ze),Eu=((qr={})[qr.Bottom=0]="Bottom",qr[qr.Center=1]="Center",qr[qr.Top=2]="Top",qr);(es={})[es.PatternFill=0]="PatternFill",es[es.SolidFill=1]="SolidFill";(rs={})[rs.NonAssociative=0]="NonAssociative",rs[rs.Associative=1]="Associative";(Yr={})[Yr.Normal=0]="Normal",Yr[Yr.Outer=1]="Outer",Yr[Yr.Ignore=2]="Ignore";(Kr={})[Kr.UserDefined=0]="UserDefined",Kr[Kr.Predefined=1]="Predefined",Kr[Kr.Custom=2]="Custom";(ns={})[ns.NotAnnotated=0]="NotAnnotated",ns[ns.Annotated=1]="Annotated";(ss={})[ss.Solid=0]="Solid",ss[ss.Gradient=1]="Gradient";(is={})[is.TwoColor=0]="TwoColor",is[is.OneColor=1]="OneColor";var Mu=((Ce={})[Ce.Default=0]="Default",Ce[Ce.External=1]="External",Ce[Ce.Polyline=2]="Polyline",Ce[Ce.Derived=4]="Derived",Ce[Ce.Textbox=8]="Textbox",Ce[Ce.Outermost=16]="Outermost",Ce),Ms=((dr={})[dr.Line=1]="Line",dr[dr.Circular=2]="Circular",dr[dr.Elliptic=3]="Elliptic",dr[dr.Spline=4]="Spline",dr),Tu=((Gt={})[Gt.Off=0]="Off",Gt[Gt.Solid=1]="Solid",Gt[Gt.Dashed=2]="Dashed",Gt[Gt.Dotted=3]="Dotted",Gt[Gt.ShotDash=4]="ShotDash",Gt[Gt.MediumDash=5]="MediumDash",Gt[Gt.LongDash=6]="LongDash",Gt[Gt.DoubleShortDash=7]="DoubleShortDash",Gt[Gt.DoubleMediumDash=8]="DoubleMediumDash",Gt[Gt.DoubleLongDash=9]="DoubleLongDash",Gt[Gt.DoubleMediumLongDash=10]="DoubleMediumLongDash",Gt[Gt.SparseDot=11]="SparseDot",Gt);Tu.Off;(Xr={})[Xr.Standard=-3]="Standard",Xr[Xr.ByLayer=-2]="ByLayer",Xr[Xr.ByBlock=-1]="ByBlock";(as={})[as.English=0]="English",as[as.Metric=1]="Metric";(vt={})[vt.PERSPECTIVE_MODE=1]="PERSPECTIVE_MODE",vt[vt.FRONT_CLIPPING=2]="FRONT_CLIPPING",vt[vt.BACK_CLIPPING=4]="BACK_CLIPPING",vt[vt.UCS_FOLLOW=8]="UCS_FOLLOW",vt[vt.FRONT_CLIP_NOT_AT_EYE=16]="FRONT_CLIP_NOT_AT_EYE",vt[vt.UCS_ICON_VISIBILITY=32]="UCS_ICON_VISIBILITY",vt[vt.UCS_ICON_AT_ORIGIN=64]="UCS_ICON_AT_ORIGIN",vt[vt.FAST_ZOOM=128]="FAST_ZOOM",vt[vt.SNAP_MODE=256]="SNAP_MODE",vt[vt.GRID_MODE=512]="GRID_MODE",vt[vt.ISOMETRIC_SNAP_STYLE=1024]="ISOMETRIC_SNAP_STYLE",vt[vt.HIDE_PLOT_MODE=2048]="HIDE_PLOT_MODE",vt[vt.K_ISO_PAIR_TOP=4096]="K_ISO_PAIR_TOP",vt[vt.K_ISO_PAIR_RIGHT=8192]="K_ISO_PAIR_RIGHT",vt[vt.VIEWPORT_ZOOM_LOCKING=16384]="VIEWPORT_ZOOM_LOCKING",vt[vt.UNUSED=32768]="UNUSED",vt[vt.NON_RECTANGULAR_CLIPPING=65536]="NON_RECTANGULAR_CLIPPING",vt[vt.VIEWPORT_OFF=131072]="VIEWPORT_OFF",vt[vt.GRID_BEYOND_DRAWING_LIMITS=262144]="GRID_BEYOND_DRAWING_LIMITS",vt[vt.ADAPTIVE_GRID_DISPLAY=524288]="ADAPTIVE_GRID_DISPLAY",vt[vt.SUBDIVISION_BELOW_SPACING=1048576]="SUBDIVISION_BELOW_SPACING",vt[vt.GRID_FOLLOWS_WORKPLANE=2097152]="GRID_FOLLOWS_WORKPLANE";(be={})[be.OPTIMIZED_2D=0]="OPTIMIZED_2D",be[be.WIREFRAME=1]="WIREFRAME",be[be.HIDDEN_LINE=2]="HIDDEN_LINE",be[be.FLAT_SHADED=3]="FLAT_SHADED",be[be.GOURAUD_SHADED=4]="GOURAUD_SHADED",be[be.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",be[be.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME";(os={})[os.UCS_UNCHANGED=0]="UCS_UNCHANGED",os[os.HAS_OWN_UCS=1]="HAS_OWN_UCS";(xe={})[xe.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",xe[xe.TOP=1]="TOP",xe[xe.BOTTOM=2]="BOTTOM",xe[xe.FRONT=3]="FRONT",xe[xe.BACK=4]="BACK",xe[xe.LEFT=5]="LEFT",xe[xe.RIGHT=6]="RIGHT";(mr={})[mr.AS_DISPLAYED=0]="AS_DISPLAYED",mr[mr.WIREFRAME=1]="WIREFRAME",mr[mr.HIDDEN=2]="HIDDEN",mr[mr.RENDERED=3]="RENDERED";(ls={})[ls.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",ls[ls.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS";function Nt(a,t,e){return a.code===t&&(e==null||a.value===e)}function Bt(a){let t={};a.rewind();let e=a.next(),s=e.code;if(t.x=e.value,(e=a.next()).code!==s+10)throw Error("Expected code for point value to be 20 but got "+e.code+".");return t.y=e.value,(e=a.next()).code!==s+20?a.rewind():t.z=e.value,t}let ra=Symbol();function Tt(a,t){return(e,s,o)=>{let h=a.reduce((b,f)=>{f.pushContext&&b.push({});let S=b[b.length-1];for(let x of typeof f.code=="number"?[f.code]:f.code){let k=S[x]??(S[x]=[]);f.isMultiple&&k.length&&console.warn(`Snippet ${k.at(-1).name} for code(${x}) is shadowed by ${f.name}`),k.push(f)}return b},[{}]),c=!1,g=h.length-1;for(;!Nt(e,0,"EOF");){let b=function(D,z,U){return D.find((B,gt)=>{var ft;return gt>=U&&((ft=B[z])==null?void 0:ft.length)})}(h,e.code,g),f=b==null?void 0:b[e.code].at(-1);if(!b||!f){s.rewind();break}f.isMultiple||b[e.code].pop();let{name:S,parser:x,isMultiple:k}=f,M=x==null?void 0:x(e,s,o);if(M===ra){s.rewind();break}if(S){let[D,z]=function(U,B){let gt=B.split("."),ft=U;for(let ut=0;ut<gt.length-1;++ut){let W=gt[ut];Object.hasOwn(ft,W)||(ft[W]={}),ft=ft[W]}return[ft,gt.at(-1)]}(o,S);k?(Object.hasOwn(D,z)||(D[z]=[]),D[z].push(M)):D[z]=M}f.pushContext&&(g-=1),c=!0,e=s.next()}return t&&Object.setPrototypeOf(o,t),c}}function y({value:a}){return a}function Z(a,t){return Bt(t)}function Xt({value:a}){return!!a}var qo=[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 Yo(a,t){var o;if(!Nt(a,1001))throw Error("XData must starts with code 1001");let e={appName:a.value,value:[]};a=t.next();let s=[e.value];for(;!Nt(a,0,"EOF")&&a.code>=1e3;){let h=s.at(-1);switch(a.code){case 1002:a.value==="{"?s.push([]):(s.pop(),(o=s.at(-1))==null||o.push(h));break;case 1e3:case 1004:case 1040:case 1070:case 1071:h.push({type:yr(a.code),value:a.value});break;case 1003:h.push({name:"layer",type:yr(a.code),value:a.value});break;case 1005:h.push({name:"handle",type:yr(a.code),value:a.value});break;case 1010:h.push({type:yr(a.code),value:Bt(t)});break;case 1011:h.push({name:"worldSpacePosition",type:yr(a.code),value:Bt(t)});break;case 1012:h.push({name:"worldSpaceDisplacement",type:yr(a.code),value:Bt(t)});break;case 1013:h.push({name:"worldSpaceDirection",type:yr(a.code),value:Bt(t)});break;case 1041:h.push({name:"distance",type:yr(a.code),value:a.value});break;case 1042:h.push({name:"scale",type:yr(a.code),value:a.value})}a=t.next()}return t.rewind(),e}function yr(a){switch(a){case 1e3:case 1003:case 1005:return"string";case 1004:return"hex";case 1040:case 1041:case 1042:return"real";case 1070:return"integer";case 1071:return"long";case 1010:case 1011:case 1012:case 1013:return"point";default:return""}}function na(a,t,e){if(Nt(t,102))return Ds(t,e),!0;switch(t.code){case 0:a.type=t.value;break;case 5:a.handle=t.value;break;case 330:a.ownerDictionarySoftId?a.ownerBlockRecordSoftId=t.value:a.ownerDictionarySoftId=t.value;break;case 360:a.ownerdictionaryHardId=t.value;break;case 67:a.isInPaperSpace=!!t.value;break;case 8:a.layer=t.value;break;case 6:a.lineType=t.value;break;case 347:a.materialObjectHardId=t.value;break;case 62:a.colorIndex=t.value,a.color=qo[Math.abs(t.value)];break;case 370:a.lineweight=t.value;break;case 48:a.lineTypeScale=t.value;break;case 60:a.isVisible=!!t.value;break;case 92:a.proxyByte=t.value;break;case 310:a.proxyEntity=t.value;break;case 100:break;case 420:a.color=t.value;break;case 430:a.transparency=t.value;break;case 390:a.plotStyleHardId=t.value;break;case 284:a.shadowMode=t.value;break;case 1001:a.xdata=Yo(t,e);break;default:return!1}return!0}let Cu=0;function Ko(a){if(!a)throw TypeError("entity cannot be undefined or null");a.handle||(a.handle=Cu++)}(pr={})[pr.CAST_AND_RECEIVE=0]="CAST_AND_RECEIVE",pr[pr.CAST=1]="CAST",pr[pr.RECEIVE=2]="RECEIVE",pr[pr.IGNORE=3]="IGNORE";let ne=[{code:1001,name:"xdata",parser:Yo},{code:284,name:"shadowMode",parser:y},{code:390,name:"plotStyleHardId",parser:y},{code:440,name:"transparency",parser:y},{code:430,name:"colorName",parser:y},{code:420,name:"color",parser:y},{code:310,name:"proxyEntity",isMultiple:!0,parser:y},{code:92,name:"proxyByte",parser:y},{code:60,name:"isVisible",parser:Xt},{code:48,name:"lineTypeScale",parser:y},{code:370,name:"lineweight",parser:y},{code:62,name:"colorIndex",parser(a,t,e){let s=a.value;return e.color=qo[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:Xt},{code:100},{code:160},{code:330,name:"ownerBlockRecordSoftId",parser:y},{code:102,parser:Ds},{code:102,parser:Ds},{code:102,parser:Ds},{code:5,name:"handle",parser:y}];function Ds(a,t){for(a=t.next();!Nt(a,102)&&!Nt(a,0,"EOF");)a=t.next()}function Xo(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}let Nu={extrusionDirection:{x:0,y:0,z:1}},Lu=[{code:210,name:"extrusionDirection",parser:Z},{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:Z},{code:39,name:"thickness",parser:y},{code:100},...ne];class $o{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Xo(this,"parser",Tt(Lu,Nu))}}Xo($o,"ForEntityName","ARC");(Qe={})[Qe.NONE=0]="NONE",Qe[Qe.INVISIBLE=1]="INVISIBLE",Qe[Qe.CONSTANT=2]="CONSTANT",Qe[Qe.VERIFICATION_REQUIRED=4]="VERIFICATION_REQUIRED",Qe[Qe.PRESET=8]="PRESET";(hs={})[hs.MULTILINE=2]="MULTILINE",hs[hs.CONSTANT_MULTILINE=4]="CONSTANT_MULTILINE";($r={})[$r.NONE=0]="NONE",$r[$r.MIRRORED_X=2]="MIRRORED_X",$r[$r.MIRRORED_Y=4]="MIRRORED_Y";var Ou=((Ne={})[Ne.LEFT=0]="LEFT",Ne[Ne.CENTER=1]="CENTER",Ne[Ne.RIGHT=2]="RIGHT",Ne[Ne.ALIGNED=3]="ALIGNED",Ne[Ne.MIDDLE=4]="MIDDLE",Ne[Ne.FIT=5]="FIT",Ne),zu=((gr={})[gr.BASELINE=0]="BASELINE",gr[gr.BOTTOM=1]="BOTTOM",gr[gr.MIDDLE=2]="MIDDLE",gr[gr.TOP=3]="TOP",gr);function Zo(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}let Qo={thickness:0,rotation:0,xScale:1,obliqueAngle:0,styleName:"STANDARD",generationFlag:0,halign:Ou.LEFT,valign:zu.BASELINE,extrusionDirection:{x:0,y:0,z:1}},Jo=[{code:73,name:"valign",parser:y},{code:100},{code:210,name:"extrusionDirection",parser:Z},{code:11,name:"endPoint",parser:Z},{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:Z},{code:39,name:"thickness",parser:y},{code:100,name:"subclassMarker",parser:y},...ne];class tl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Zo(this,"parser",Tt(Jo,Qo))}}function el(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}Zo(tl,"ForEntityName","TEXT");let Du={...Qo},Ru=[{code:2},{code:40,name:"annotationScale",parser:y},{code:10,name:"alignmentPoint",parser:Z},{code:340,name:"secondaryAttributesHardIds",isMultiple:!0,parser:y},{code:70,name:"numberOfSecondaryAttributes",parser:y},{code:70,name:"isReallyLocked",parser:Xt},{code:70,name:"mtextFlag",parser:y},{code:280,name:"isDuplicatedRecord",parser:Xt},{code:100},{code:280,name:"isLocked",parser:Xt},{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},...Jo.slice(2)];class rl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){el(this,"parser",Tt(Ru,Du))}}function nl(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}el(rl,"ForEntityName","ATTDEF");let Bu={thickness:0,extrusionDirection:{x:0,y:0,z:1}},Fu=[{code:210,name:"extrusionDirection",parser:Z},{code:40,name:"radius",parser:y},{code:10,name:"center",parser:Z},{code:39,name:"thickness",parser:y},{code:100,name:"subclassMarker",parser:y},...ne];class sl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){nl(this,"parser",Tt(Fu,Bu))}}nl(sl,"ForEntityName","CIRCLE");let Rs=class{parseEntity(t,e){let s={};for(;!Nt(e,0,"EOF");){if(e.code===0){t.rewind();break}(function(o,h,c){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=Bt(c);break;case 11:o.textPoint=Bt(c);break;case 12:o.insertionPoint=Bt(c);break;case 13:o.subDefinitionPoint1=Bt(c);break;case 14:o.subDefinitionPoint2=Bt(c);break;case 15:o.centerPoint=Bt(c);break;case 16:o.arcPoint=Bt(c);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=Bt(c);break;case 3:o.styleName=h.value;break;default:na(o,h,c)}})(s,e,t),e=t.next()}return s}};function il(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}zi="DIMENSION",(Oi="ForEntityName")in Rs?Object.defineProperty(Rs,Oi,{value:zi,enumerable:!0,configurable:!0,writable:!0}):Rs[Oi]=zi;let Vu={extrusionDirection:{x:0,y:0,z:1}},Uu=[{code:42,name:"endAngle",parser:y},{code:41,name:"startAngle",parser:y},{code:40,name:"axisRatio",parser:y},{code:210,name:"extrusionDirection",parser:Z},{code:11,name:"majorAxisEndPoint",parser:Z},{code:10,name:"center",parser:Z},{code:100,name:"subclassMarker",parser:y},...ne];class al{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){il(this,"parser",Tt(Uu,Vu))}}il(al,"ForEntityName","ELLIPSE");let ol=[{code:330,name:"sourceBoundaryObjects",parser:y,isMultiple:!0},{code:97,name:"numberOfSourceBoundaryObjects",parser:y}],ju=[{code:11,name:"end",parser:Z},{code:10,name:"start",parser:Z}],Gu=[{code:73,name:"isCCW",parser:Xt},{code:51,name:"endAngle",parser:y},{code:50,name:"startAngle",parser:y},{code:40,name:"radius",parser:y},{code:10,name:"center",parser:Z}],Wu=[{code:73,name:"isCCW",parser:Xt},{code:51,name:"endAngle",parser:y},{code:50,name:"startAngle",parser:y},{code:40,name:"lengthOfMinorAxis",parser:y},{code:11,name:"end",parser:Z},{code:10,name:"center",parser:Z}],Hu=[{code:13,name:"endTangent",parser:Z},{code:12,name:"startTangent",parser:Z},{code:11,name:"fitDatum",isMultiple:!0,parser:Z},{code:97,name:"numberOfFitData",parser:y},{code:10,name:"controlPoints",isMultiple:!0,parser(a,t){let e={...Bt(t),weight:1};return(a=t.next()).code===42?e.weight=a.value:t.rewind(),e}},{code:40,name:"knots",isMultiple:!0,parser:y},{code:96,name:"numberOfControlPoints",parser:y},{code:95,name:"numberOfKnots",parser:y},{code:74,name:"isPeriodic",parser:Xt},{code:73,name:"splineFlag",parser:y},{code:94,name:"degree",parser:y}],qu={[Ms.Line]:ju,[Ms.Circular]:Gu,[Ms.Elliptic]:Wu,[Ms.Spline]:Hu},Yu=[...ol,{code:72,name:"edges",parser(a,t){let e={type:a.value},s=Tt(qu[e.type]);if(!s)throw Error(`Invalid edge type ${e.type}`);return s(a=t.next(),t,e),e},isMultiple:!0},{code:93,name:"numberOfEdges",parser:y}],Ku=[...ol,{code:10,name:"vertices",parser(a,t){let e={...Bt(t),bulge:0};return(a=t.next()).code===42?e.bulge=a.value:t.rewind(),e},isMultiple:!0},{code:93,name:"numberOfVertices",parser:y},{code:73,name:"isClosed",parser:Xt},{code:72,name:"hasBulge",parser:Xt}],Xu=[{code:49,name:"dashLengths",parser:y,isMultiple:!0},{code:79,name:"numberOfDashLengths",parser:y},{code:45,name:"offset",parser:_o},{code:43,name:"base",parser:_o},{code:53,name:"angle",parser:y}];function _o(a,t){let e=a.code+1,s={x:a.value,y:1};return(a=t.next()).code===e?s.y=a.value:t.rewind(),s}function ll(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}let $u={extrusionDirection:{x:0,y:0,z:1},gradientRotation:0,colorTint:0},Zu=[{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:Z,isMultiple:!0},{code:99},{code:11,name:"offsetVector",parser:Z},{code:98,name:"numberOfSeedPoints",parser:y},{code:47,name:"pixelSize",parser:y},{code:53,name:"definitionLines",parser:function(a,t){let e={};return Tt(Xu)(a,t,e),e},isMultiple:!0},{code:78,name:"numberOfDefinitionLines",parser:y},{code:77,name:"isDouble",parser:Xt},{code:73,name:"isAnnotated",parser:Xt},{code:41,name:"patternScale",parser:y},{code:52,name:"patternAngle",parser:y},{code:76,name:"patternType",parser:y},{code:75,name:"hatchStyle",parser:y},{code:92,name:"boundaryPaths",parser:function(a,t){let e={boundaryPathTypeFlag:a.value},s=e.boundaryPathTypeFlag&Mu.Polyline;return a=t.next(),s?Tt(Ku)(a,t,e):Tt(Yu)(a,t,e),e},isMultiple:!0},{code:91,name:"numberOfBoundaryPaths",parser:y},{code:71,name:"associativity",parser:y},{code:63,name:"patternFillColor",parser:y},{code:70,name:"solidFill",parser:y},{code:2,name:"patternName",parser:y},{code:210,name:"extrusionDirection",parser:Z},{code:10,name:"elevationPoint",parser:Z},{code:100,name:"subclassMarker",parser:y,pushContext:!0},...ne];class hl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){ll(this,"parser",Tt(Zu,$u))}}ll(hl,"ForEntityName","HATCH");(fr={})[fr.ShowImage=1]="ShowImage",fr[fr.ShowImageWhenNotAlignedWithScreen=2]="ShowImageWhenNotAlignedWithScreen",fr[fr.UseClippingBoundary=4]="UseClippingBoundary",fr[fr.TransparencyIsOn=8]="TransparencyIsOn";(us={})[us.Rectangular=1]="Rectangular",us[us.Polygonal=2]="Polygonal";(cs={})[cs.Outside=0]="Outside",cs[cs.Inside=1]="Inside";function ul(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}let Qu={clippingBoundaryPath:[]},Ju=[{code:90,name:"version",parser:y},{code:10,name:"position",parser:Z},{code:11,name:"uPixel",parser:Z},{code:12,name:"vPixel",parser:Z},{code:13,name:"imageSize",parser:Z},{code:340,name:"imageDefHandle",parser:y},{code:70,name:"flags",parser:y},{code:280,name:"clipping",parser:y},{code:281,name:"brightness",parser:y},{code:282,name:"contrast",parser:y},{code:283,name:"fade",parser:y},{code:360,name:"imageDefReactorHandle",parser:y},{code:71,name:"clippingBoundaryType",parser:y},{code:91,name:"countBoundaryPoints",parser:y},{code:14,name:"clippingBoundaryPath",isMultiple:!0,parser:Z},{code:290,name:"clipMode",parser:y},{code:100,name:"subclassMarker",parser:y},...ne];class sa{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){ul(this,"parser",Tt(Ju,Qu))}}function cl(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}ul(sa,"ForEntityName","IMAGE");let tc={xScale:1,yScale:1,zScale:1,rotation:0,columnCount:0,rowCount:0,columnSpacing:0,rowSpacing:0,extrusionDirection:{x:0,y:0,z:1}},ec=[{code:210,name:"extrusionDirection",parser:Z},{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:Z},{code:2,name:"name",parser:y},{code:66,name:"isVariableAttributes",parser:Xt},{code:100,name:"subclassMarker",parser:y},...ne];class dl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){cl(this,"parser",Tt(ec,tc))}}function ml(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}cl(dl,"ForEntityName","INSERT");let rc={isArrowheadEnabled:!0},nc=[{code:213,name:"offsetFromAnnotation",parser:Z},{code:212,name:"offsetFromBlock",parser:Z},{code:211,name:"horizontalDirection",parser:Z},{code:210,name:"normal",parser:Z},{code:340,name:"associatedAnnotation",parser:y},{code:77,name:"byBlockColor",parser:y},{code:10,name:"vertices",parser:Z,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:Xt},{code:74,name:"isHooklineSameDirection",parser:Xt},{code:73,name:"leaderCreationFlag",parser:y},{code:72,name:"isSpline",parser:Xt},{code:71,name:"isArrowheadEnabled",parser:Xt},{code:3,name:"styleName",parser:y},{code:100,name:"subclassMarker",parser:y},...ne];class pl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){ml(this,"parser",Tt(nc,rc))}}ml(pl,"ForEntityName","LEADER");(_r={})[_r.TextAnnotation=0]="TextAnnotation",_r[_r.ToleranceAnnotation=1]="ToleranceAnnotation",_r[_r.BlockReferenceAnnotation=2]="BlockReferenceAnnotation",_r[_r.NoAnnotation=3]="NoAnnotation";function gl(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}let sc={thickness:0,extrusionDirection:{x:0,y:0,z:1}},ic=[{code:210,name:"extrusionDirection",parser:Z},{code:11,name:"endPoint",parser:Z},{code:10,name:"startPoint",parser:Z},{code:39,name:"thickness",parser:y},{code:100,name:"subclassMarker",parser:y},...ne];class fl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){gl(this,"parser",Tt(ic,sc))}}gl(fl,"ForEntityName","LINE");(ds={})[ds.IS_CLOSED=1]="IS_CLOSED",ds[ds.PLINE_GEN=128]="PLINE_GEN";let ac={flag:0,elevation:0,thickness:0,extrusionDirection:{x:0,y:0,z:1},vertices:[]},oc={bulge:0},lc=[{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}],hc=[{code:210,name:"extrusionDirection",parser:Z},{code:10,name:"vertices",isMultiple:!0,parser(a,t){let e={};return Tt(lc,oc)(a,t,e),e}},{code:39,name:"thickness",parser:y},{code:38,name:"elevation",parser:y},{code:43,name:"constantWidth",parser:y},{code:70,name:"flag",parser:y},{code:90,name:"numberOfVertices",parser:y},{code:100,name:"subclassMarker",parser:y},...ne];class Bs{parseEntity(t,e){let s={};return Tt(hc,ac)(e,t,s),s}}Ri="LWPOLYLINE",(Di="ForEntityName")in Bs?Object.defineProperty(Bs,Di,{value:Ri,enumerable:!0,configurable:!0,writable:!0}):Bs[Di]=Ri;(Zr={})[Zr.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",Zr[Zr.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",Zr[Zr.BY_STYLE=5]="BY_STYLE";function uc(a,t){let e={};for(let s of a){let o=t(s);o!=null&&(e[o]??(e[o]=[]),e[o].push(s))}return e}function*Ws(a,t=1/0,e=1){for(let s=a;s!==t;s+=e)yield s}function Or(a){return{x:a.x??0,y:a.y??0,z:a.z??0}}function _l(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}let cc={textStyle:"STANDARD",extrusionDirection:{x:0,y:0,z:1},rotation:0},Fs=[{code:46,name:"annotationHeight",parser:y},{code:101,parser(a,t){(function(e){e.rewind();let s=e.next();if(s.code!==101)throw Error("Bad call for skipEmbeddedObject()");do s=e.next();while(s.code!==0);e.rewind()})(t)}},{code:50,name:"columnHeight",parser: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:[...Ws(430,440)],name:"backgroundColor",parser:y},{code:[...Ws(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:Z},{code:210,name:"extrusionDirection",parser:Z},{code:7,name:"styleName",parser:y},{code:3,name:"text",isMultiple:!0,parser:y},{code:1,name:"text",isMultiple:!0,parser:y},{code:72,name:"drawingDirection",parser:y},{code:71,name:"attachmentPoint",parser:y},{code:41,name:"width",parser:y},{code:40,name:"height",parser:y},{code:10,name:"insertionPoint",parser:Z},{code:100,name:"subclassMarker",parser:y},...ne];class vl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){_l(this,"parser",Tt(Fs,cc))}}function yl(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}_l(vl,"ForEntityName","MTEXT");let dc={thickness:0,extrusionDirection:{x:0,y:0,z:1},angle:0},mc=[{code:50,name:"angle",parser:y},{code:210,name:"extrusionDirection",parser:Z},{code:39,name:"thickness",parser:y},{code:10,name:"position",parser:Z},{code:100,name:"subclassMarker",parser:y},...ne];class bl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){yl(this,"parser",Tt(mc,dc))}}yl(bl,"ForEntityName","POINT");(ue={})[ue.CLOSED_POLYLINE=1]="CLOSED_POLYLINE",ue[ue.CURVE_FIT=2]="CURVE_FIT",ue[ue.SPLINE_FIT=4]="SPLINE_FIT",ue[ue.POLYLINE_3D=8]="POLYLINE_3D",ue[ue.POLYGON_3D=16]="POLYGON_3D",ue[ue.CLOSED_POLYGON=32]="CLOSED_POLYGON",ue[ue.POLYFACE=64]="POLYFACE",ue[ue.CONTINUOUS=128]="CONTINUOUS";(vr={})[vr.NONE=0]="NONE",vr[vr.QUADRATIC=5]="QUADRATIC",vr[vr.CUBIC=6]="CUBIC",vr[vr.BEZIER=8]="BEZIER";(ce={})[ce.CREATED_BY_CURVE_FIT=1]="CREATED_BY_CURVE_FIT",ce[ce.TANGENT_DEFINED=2]="TANGENT_DEFINED",ce[ce.NOT_USED=4]="NOT_USED",ce[ce.CREATED_BY_SPLINE_FIT=8]="CREATED_BY_SPLINE_FIT",ce[ce.SPLINE_CONTROL_POINT=16]="SPLINE_CONTROL_POINT",ce[ce.FOR_POLYLINE=32]="FOR_POLYLINE",ce[ce.FOR_POLYGON=64]="FOR_POLYGON",ce[ce.POLYFACE=128]="POLYFACE";function xl(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}let pc={startWidth:0,endWidth:0,bulge:0},gc=[{code:91,name:"id",parser:y},{code:[...Ws(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},...ne],wl=class{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){xl(this,"parser",Tt(gc,pc))}};function Al(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}xl(wl,"ForEntityName","VERTEX");let fc={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:[]},_c=[{code:0,name:"vertices",isMultiple:!0,parser:(a,t)=>Nt(a,0,"VERTEX")?(a=t.next(),new wl().parseEntity(t,a)):ra},{code:210,name:"extrusionDirection",parser:Z},{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},...ne];class Pl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Al(this,"parser",Tt(_c,fc))}}function Sl(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}Al(Pl,"ForEntityName","POLYLINE");let vc={firstPoint:{x:0,y:0,z:1},extrusionDirection:{x:0,y:0,z:1}},yc=[{code:10,name:"firstPoint",parser:Z},{code:11,name:"unitDirection",parser:Z},{code:100,name:"subclassMarker",parser:y},...ne];class Il{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Sl(this,"parser",Tt(yc,vc))}}function kl(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}Sl(Il,"ForEntityName","RAY");let bc={vertices:[],backLineVertices:[]},xc=[{code:360,name:"geometrySettingHardId",parser:y},{code:12,name:"backLineVertices",isMultiple:!0,parser:Z},{code:93,name:"numberOfBackLineVertices",parser:y},{code:11,name:"vertices",isMultiple:!0,parser:Z},{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:Z},{code:1,name:"name",parser:y},{code:91,name:"flag",parser:y},{code:90,name:"state",parser:y},{code:100,name:"subclassMarker",parser:y},...ne];class El{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){kl(this,"parser",Tt(xc,bc))}}function Ml(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}kl(El,"ForEntityName","SECTION");let wc={points:[],thickness:0,extrusionDirection:{x:0,y:0,z:1}},Ac=[{code:210,name:"extrusionDirection",parser:Z},{code:39,name:"thickness",parser:y},{code:[...Ws(10,14)],name:"points",isMultiple:!0,parser:Z},{code:100,name:"subclassMarker",parser:y},...ne];class Tl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Ml(this,"parser",Tt(Ac,wc))}}Ml(Tl,"ForEntityName","SOLID");(Le={})[Le.NONE=0]="NONE",Le[Le.CLOSED=1]="CLOSED",Le[Le.PERIODIC=2]="PERIODIC",Le[Le.RATIONAL=4]="RATIONAL",Le[Le.PLANAR=8]="PLANAR",Le[Le.LINEAR=16]="LINEAR";function Cl(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}let Pc={knotTolerance:1e-6,controlTolerance:1e-6,fitTolerance:1e-9,knotValues:[],controlPoints:[],fitPoints:[]},Sc=[{code:11,name:"fitPoints",isMultiple:!0,parser:Z},{code:10,name:"controlPoints",isMultiple:!0,parser:Z},{code:41,name:"weights",isMultiple:!0,parser:y},{code:40,name:"knots",isMultiple:!0,parser:y},{code:13,name:"endTangent",parser:Z},{code:12,name:"startTangent",parser:Z},{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:Z},{code:100,name:"subclassMarker",parser:y},...ne];class Nl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Cl(this,"parser",Tt(Sc,Pc))}}Cl(Nl,"ForEntityName","SPLINE");class Vs{parseEntity(t,e){let s={};for(;!t.isEOF();){if(e.code===0){t.rewind();break}switch(e.code){case 100:s.subclassMarker=e.value,e=t.next();break;case 2:s.name=e.value,e=t.next();break;case 5:s.handle=e.value,e=t.next();break;case 10:s.startPoint=Or(Bt(t)),e=t.lastReadGroup;break;case 11:s.directionVector=Or(Bt(t)),e=t.lastReadGroup;break;case 90:s.tableValue=e.value,e=t.next();break;case 91:s.rowCount=e.value,e=t.next();break;case 92:s.columnCount=e.value,e=t.next();break;case 93:s.overrideFlag=e.value,e=t.next();break;case 94:s.borderColorOverrideFlag=e.value,e=t.next();break;case 95:s.borderLineWeightOverrideFlag=e.value,e=t.next();break;case 96:s.borderVisibilityOverrideFlag=e.value,e=t.next();break;case 141:s.rowHeightArr??(s.rowHeightArr=[]),s.rowHeightArr.push(e.value),e=t.next();break;case 142:s.columnWidthArr??(s.columnWidthArr=[]),s.columnWidthArr.push(e.value),e=t.next();break;case 280:s.version=e.value,e=t.next();break;case 310:s.bmpPreview??(s.bmpPreview=""),s.bmpPreview+=e.value,e=t.next();break;case 330:s.ownerDictionaryId=e.value,e=t.next();break;case 342:s.tableStyleId=e.value,e=t.next();break;case 343:s.blockRecordHandle=e.value,e=t.next();break;case 170:s.attachmentPoint=e.value,e=t.next();break;case 171:s.cells??(s.cells=[]),s.cells.push(function(o,h){let c=!1,g=!1,b={};for(;!o.isEOF()&&h.code!==0&&!g;)switch(h.code){case 171:if(c){g=!0;continue}b.cellType=h.value,c=!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 c=!1,g=!1,b}(t,e)),e=t.lastReadGroup;break;default:na(s,e,t),e=t.next()}}return s}}Fi="ACAD_TABLE",(Bi="ForEntityName")in Vs?Object.defineProperty(Vs,Bi,{value:Fi,enumerable:!0,configurable:!0,writable:!0}):Vs[Bi]=Fi;class Us{parseEntity(t,e){let s={};for(;e!=="EOF";){if(e.code===0){t.rewind();break}!function(o,h,c){if(c==="EOF")return!1;switch(c.code){case 0:default:return!1;case 100:o.subclassMarker=c.value;break;case 10:o.viewportCenter=Or(Bt(h));break;case 40:o.width=c.value;break;case 41:o.height=c.value;break;case 68:o.status=c.value;break;case 69:o.viewportId=c.value;break;case 12:o.displayCenter=Bt(h);break;case 13:o.snapBase=Bt(h);break;case 14:o.snapSpacing=Bt(h);break;case 15:o.gridSpacing=Bt(h);break;case 16:o.viewDirection=Or(Bt(h));break;case 17:o.targetPoint=Or(Bt(h));break;case 42:o.perspectiveLensLength=c.value;break;case 43:o.frontClipZ=c.value;break;case 44:o.backClipZ=c.value;break;case 45:o.viewHeight=c.value;break;case 50:o.snapAngle=c.value;break;case 51:o.viewTwistAngle=c.value;break;case 72:o.circleZoomPercent=c.value;break;case 331:o.frozenLayerIds??(o.frozenLayerIds=[]),o.frozenLayerIds.push(c.value);break;case 90:o.statusBitFlags=c.value;break;case 330:o.ownerBlockRecordSoftId=c.value;break;case 340:o.clippingBoundaryId=c.value;break;case 1:o.sheetName=c.value;break;case 281:o.renderMode=c.value;break;case 71:o.ucsPerViewport=c.value;break;case 110:o.ucsOrigin=Or(Bt(h));break;case 111:o.ucsXAxis=Or(Bt(h));break;case 112:o.ucsYAxis=Or(Bt(h));break;case 345:o.ucsId=c.value;break;case 346:o.ucsBaseId=c.value;break;case 79:o.orthographicType=c.value;break;case 146:o.elevation=c.value;break;case 170:o.shadePlotMode=c.value;break;case 61:o.majorGridFrequency=c.value;break;case 332:o.backgroundId=c.value;break;case 333:o.shadePlotId=c.value;break;case 348:o.visualStyleId=c.value;break;case 292:o.isDefaultLighting=!!c.value;break;case 282:o.defaultLightingType=c.value;break;case 141:o.brightness=c.value;break;case 142:o.contrast=c.value;break;case 63:case 421:case 431:o.ambientLightColor=c.value;break;case 361:o.sunId=c.value;break;case 335:case 343:case 344:case 91:o.softPointer=c.value}return!0}(s,t,e)&&na(s,e,t),e=t.next()}return s}}Ui="VIEWPORT",(Vi="ForEntityName")in Us?Object.defineProperty(Us,Vi,{value:Ui,enumerable:!0,configurable:!0,writable:!0}):Us[Vi]=Ui;class js extends sa{parseEntity(t,e){return super.parseEntity(t,e)}}function Ll(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}Gi="WIPEOUT",(ji="ForEntityName")in js?Object.defineProperty(js,ji,{value:Gi,enumerable:!0,configurable:!0,writable:!0}):js[ji]=Gi;let Ic={firstPoint:{x:0,y:0,z:1},extrusionDirection:{x:0,y:0,z:1}},kc=[{code:10,name:"firstPoint",parser:Z},{code:11,name:"unitDirection",parser:Z},{code:100,name:"subclassMarker",parser:y},...ne];class Ol{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Ll(this,"parser",Tt(kc,Ic))}}function zl(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}Ll(Ol,"ForEntityName","XLINE");let Ec={thickness:0,rotation:0,scale:1,obliqueAngle:0,textStyle:"STANDARD",textGenerationFlag:0,horizontalJustification:0,verticalJustification:0,extrusionDirection:{x:0,y:0,z:1}},Mc=[...Fs.slice(Fs.findIndex(({name:a})=>a==="columnType"),Fs.findIndex(({name:a})=>a==="subclassMarker")+1),{code:100},{code:0,parser(a){if(!Nt(a,0,"MTEXT"))return ra}},{code:2,name:"definitionTag",parser:y},{code:40,name:"annotationScale",parser:y},{code:10,name:"alignmentPoint",parser:Z},{code:340,name:"secondaryAttributesHardId",parser:y},{code:70,name:"numberOfSecondaryAttributes",parser:y},{code:70,name:"isReallyLocked",parser:Xt},{code:70,name:"mtextFlag",parser:y},{code:280,name:"isDuplicatedEntriesKeep",parser:Xt},{code:100},{code:280,name:"lockPositionFlag",parser:Xt},{code:210,name:"extrusionDirection",parser:Z},{code:11,name:"alignmentPoint",parser:Z},{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:Z},{code:39,name:"thickness",parser:y},{code:100},...ne];class Dl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){zl(this,"parser",Tt(Mc,Ec))}}zl(Dl,"ForEntityName","ATTRIB");let Tc=Object.fromEntries([$o,rl,Dl,sl,Rs,al,sa,dl,pl,fl,Bs,vl,bl,Pl,Il,El,Tl,Nl,Vs,tl,hl,Us,js,Ol].map(a=>[a.ForEntityName,new a]));function Rl(a,t){let e=[];for(;!Nt(a,0,"EOF");){if(a.code===0){if(a.value==="ENDBLK"||a.value==="ENDSEC"){t.rewind();break}let s=Tc[a.value];if(s){let o=a.value;a=t.next();let h=s.parseEntity(t,a);h.type=o,Ko(h),e.push(h)}else console.warn(`Unsupported ENTITY type: ${a.value}`)}a=t.next()}return e}function Cc(a,t){let e={};for(;!Nt(a,0,"EOF")&&!Nt(a,0,"ENDSEC");){if(Nt(a,0,"BLOCK")){let s=Nc(a=t.next(),t);Ko(s),s.name&&(e[s.name]=s)}a=t.next()}return e}function Nc(a,t){let e={};for(;!Nt(a,0,"EOF");){if(Nt(a,0,"ENDBLK")){for(a=t.next();!Nt(a,0,"EOF");){if(Nt(a,100,"AcDbBlockEnd"))return e;a=t.next()}break}switch(a.code){case 1:e.xrefPath=a.value;break;case 2:e.name=a.value;break;case 3:e.name2=a.value;break;case 5:e.handle=a.value;break;case 8:e.layer=a.value;break;case 10:e.position=Bt(t);break;case 67:e.paperSpace=!!a.value&&a.value==1;break;case 70:a.value!==0&&(e.type=a.value);break;case 100:break;case 330:e.ownerHandle=a.value;break;case 0:e.entities=Rl(a,t)}a=t.next()}return e}function Lc(a,t){let e=null,s={};for(;!Nt(a,0,"EOF")&&!Nt(a,0,"ENDSEC");)a.code===9?e=a.value:a.code===10?s[e]=Bt(t):s[e]=a.value,a=t.next();return s}let Oc=[{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:Z},{code:11,name:"sizeOfOnePixel",parser:Z},{code:280,name:"isLoaded",parser:y},{code:281,name:"resolutionUnits",parser:y},{code:100,name:"subclassMarker",parser:y}],Bl=[{code:333,name:"shadePlotId",parser:y},{code:149,name:"imageOriginY",parser:y},{code:148,name:"imageOriginX",parser:y},{code:147,name:"scaleFactor",parser:y},{code:78,name:"shadePlotCustomDPI",parser:y},{code:77,name:"shadePlotResolution",parser:y},{code:76,name:"shadePlotMode",parser:y},{code:75,name:"standardScaleType",parser:y},{code:7,name:"currentStyleSheet",parser:y},{code:74,name:"plotType",parser:y},{code:73,name:"plotRotation",parser:y},{code:72,name:"paperUnit",parser:y},{code:70,name:"layoutFlag",parser:y},{code:143,name:"printScaleDenominator",parser:y},{code:142,name:"printScaleNominator",parser:y},{code:141,name:"windowAreaYMax",parser:y},{code:140,name:"windowAreaYMin",parser:y},{code:49,name:"windowAreaXMax",parser:y},{code:48,name:"windowAreaXMin",parser:y},{code:47,name:"plotOriginY",parser:y},{code:46,name:"plotOriginX",parser:y},{code:45,name:"paperHeight",parser:y},{code:44,name:"paperWidth",parser:y},{code:43,name:"marginTop",parser:y},{code:42,name:"marginRight",parser:y},{code:41,name:"marginBottom",parser:y},{code:40,name:"marginLeft",parser:y},{code:6,name:"plotViewName",parser:y},{code:4,name:"paperSize",parser:y},{code:2,name:"configName",parser:y},{code:1,name:"pageSetupName",parser:y},{code:100,name:"subclassMarker",parser:y}],zc=[{code:333,name:"shadePlotId",parser:y},{code:346,name:"orthographicUcsId",parser:y},{code:345,name:"namedUcsId",parser:y},{code:331,name:"viewportId",parser:y},{code:330,name:"paperSpaceTableId",parser:y},{code:76,name:"orthographicType",parser:y},{code:17,name:"ucsYAxis",parser:Z},{code:16,name:"ucsXAxis",parser:Z},{code:13,name:"ucsOrigin",parser:Z},{code:146,name:"elevation",parser:y},{code:15,name:"maxExtent",parser:Z},{code:14,name:"minExtent",parser:Z},{code:12,name:"insertionBase",parser:Z},{code:11,name:"maxLimit",parser:Z},{code:10,name:"minLimit",parser:Z},{code:71,name:"tabOrder",parser:y},{code:70,name:"controlFlag",parser:y},{code:1,name:"layoutName",parser:y},{code:100,name:"subclassMarker",parser:y},...Bl],Dc=[{code:330,name:"ownerObjectId",parser:y},{code:102},{code:360,name:"ownerDictionaryIdHard",parser:y},{code:102},{code:102},{code:330,name:"ownerDictionaryIdSoft",parser:y},{code:102},{code:102},{code:102},{code:5,name:"handle",parser:y}];function vo(a){return a.subclassMarker==="AcDbDictionary"}let Rc={LAYOUT:zc,PLOTSETTINGS:Bl,DICTIONARY:[{code:3,name:"entries",parser:(a,t)=>{let e={name:a.value};return(a=t.next()).code===350?e.objectId=a.value:t.rewind(),e},isMultiple:!0},{code:281,name:"recordCloneFlag",parser:y},{code:280,name:"isHardOwned",parser:Xt},{code:100,name:"subclassMarker",parser:y}],IMAGEDEF:Oc};function Bc(a,t){let e=[];for(;a.code!==0||!["EOF","ENDSEC"].includes(a.value);){let s=a.value,o=Rc[s];if(a.code===0&&(o!=null&&o.length)){let h=Tt([...Dc,...o]),c={name:s};h(a=t.next(),t,c)?(e.push(c),a=t.peek()):a=t.next()}else a=t.next()}return{byName:uc(e,({name:s})=>s),byTree:function(s){let o=Object.fromEntries(s.map(h=>[h.handle,h]));for(let h of s)(!vo(h)||h.ownerDictionaryIdSoft!=="0")&&(h.ownerDictionaryIdSoft&&(h.ownerDictionarySoft=o[h.ownerDictionaryIdSoft]),h.ownerDictionaryIdHard&&(h.ownerDictionaryHard=o[h.ownerDictionaryIdHard]),h.ownerObjectId&&(h.ownerObject=o[h.ownerObjectId])),function(c,g){vo(c)&&c.entries&&(c.entries=Object.fromEntries(c.entries.map(({name:b,objectId:f})=>[b,g[f]])))}(h,o);return s[0]}(e)}}let In=[{code:100,name:"subclassMarker",parser:y},{code:330,name:"ownerObjectId",parser:y},{code:102,parser(a,t){for(;!Nt(a,0,"EOF")&&!Nt(a,102,"}");)a=t.next()}},{code:5,name:"handle",parser:y}],Fc=Tt([{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},...In]),Vc=Tt([...[{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:fo.Above,defaultValueImperial:fo.Center},{name:"DIMZIN",code:78,defaultValue:wn.Trailing,defaultValueImperial:wn.Feet},{name:"DIMAZIN",code:79,defaultValue:Iu.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:ku.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:wn.Trailing,defaultValueImperial:wn.Feet},{name:"DIMALTZ",code:285,defaultValue:wn.Trailing},{name:"DIMALTTZ",code:286,defaultValue:wn.Trailing},{name:"DIMFIT",code:287},{name:"DIMUPT",code:288,defaultValue:0},{name:"DIMATFIT",code:289,defaultValue:3},{name:"DIMTXSTY",code:340},{name:"DIMLDRBLK",code:341},{name:"DIMBLK",code:342},{name:"DIMBLK1",code:343},{name:"DIMBLK2",code:344},{name:"DIMLWD",code:371,defaultValue:-2},{name:"DIMLWD",code:372,defaultValue:-2}].map(a=>({...a,parser:y})),{code:70,name:"standardFlag",parser:y},{code:2,name:"name",parser:y},{code:100,name:"subclassMarker",parser:y},{code:105,name:"handle",parser:y},...In.filter(a=>a.code!==5)]),Uc=Tt([{code:347,name:"materialObjectId",parser:y},{code:390,name:"plotStyleNameObjectId",parser:y},{code:370,name:"lineweight",parser:y},{code:290,name:"isPlotting",parser:Xt},{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},...In]),jc=Tt([{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}),Gc={BLOCK_RECORD:Fc,DIMSTYLE:Vc,LAYER:Uc,LTYPE:Tt([{code:49,name:"pattern",parser(a,t){let e={};return jc(a,t,e),e},isMultiple:!0},{code:40,name:"totalPatternLength",parser:y},{code:73,name:"numberOfLineTypes",parser:y},{code:72,parser:y},{code:3,name:"description",parser:y},{code:70,name:"standardFlag",parser:y},{code:2,name:"name",parser:y},{code:100,name:"subclassMarker",parser:y},...In]),STYLE:Tt([{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},...In]),VPORT:Tt([{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:Xt},{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:Z},{code:111,name:"ucsXAxis",parser:Z},{code:110,name:"ucsOrigin",parser:Z},{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:Z},{code:16,name:"viewDirectionFromTarget",parser:Z},{code:15,name:"gridSpacing",parser:Z},{code:14,name:"snapSpacing",parser:Z},{code:13,name:"snapBasePoint",parser:Z},{code:12,name:"center",parser:Z},{code:11,name:"upperRightCorner",parser:Z},{code:10,name:"lowerLeftCorner",parser:Z},{code:70,name:"standardFlag",parser:y},{code:2,name:"name",parser:y},{code:100,name:"subclassMarker",parser:y},...In])},Wc=Tt([{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 Hc(a,t){var s;let e={};for(;!Nt(a,0,"EOF")&&!Nt(a,0,"ENDSEC");){if(Nt(a,0,"TABLE")){a=t.next();let o={entries:[]};Wc(a,t,o),e[o.name]=o}if(Nt(a,0)&&!Nt(a,0,"ENDTAB")){let o=a.value;a=t.next();let h=Gc[o];if(!h){console.warn(`parseTable: Invalid table name '${o}'`),a=t.next();continue}let c={};h(a,t,c),(s=e[o])==null||s.entries.push(c)}a=t.next()}return e}function Ts(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}class yo{next(){if(!this.hasNext())return this._eof?console.warn("Cannot call 'next' after EOF group has been read"):console.warn("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]),{code:0,value:"EOF"};let t=parseInt(this._data[this._pointer++],10),e=bo(t,this._data[this._pointer++]),s={code:t,value:e};return Nt(s,0,"EOF")&&(this._eof=!0),this.lastReadGroup=s,s}peek(){if(!this.hasNext())throw this._eof?Error("Cannot call 'next' after EOF group has been read"):Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);let t={code:parseInt(this._data[this._pointer]),value:0};return t.value=bo(t.code,this._data[this._pointer+1]),t}rewind(t){t=t||1,this._pointer=this._pointer-2*t}hasNext(){return!this._eof&&!(this._pointer>this._data.length-2)}isEOF(){return this._eof}constructor(t){Ts(this,"_pointer",void 0),Ts(this,"_data",void 0),Ts(this,"_eof",void 0),Ts(this,"lastReadGroup",{code:0,value:0}),this._pointer=0,this._data=t,this._eof=!1}}function bo(a,t){return a<=9?t:a>=10&&a<=59?parseFloat(t.trim()):a>=60&&a<=99?parseInt(t.trim()):a>=100&&a<=109?t:a>=110&&a<=149?parseFloat(t.trim()):a>=160&&a<=179?parseInt(t.trim()):a>=210&&a<=239?parseFloat(t.trim()):a>=270&&a<=289?parseInt(t.trim()):a>=290&&a<=299?function(e){if(e==="0")return!1;if(e==="1")return!0;throw TypeError("String '"+e+"' cannot be cast to Boolean type")}(t.trim()):a>=300&&a<=369?t:a>=370&&a<=389?parseInt(t.trim()):a>=390&&a<=399?t:a>=400&&a<=409?parseInt(t.trim()):a>=410&&a<=419?t:a>=420&&a<=429?parseInt(t.trim()):a>=430&&a<=439?t:a>=440&&a<=459?parseInt(t.trim()):a>=460&&a<=469?parseFloat(t.trim()):a>=470&&a<=481||a===999||a>=1e3&&a<=1009?t:a>=1010&&a<=1059?parseFloat(t.trim()):a>=1060&&a<=1071?parseInt(t.trim()):(console.log("WARNING: Group code does not have a defined type: %j",{code:a,value:t}),t)}function Xi(a,t,e){return t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}let qc=class{constructor(){Xi(this,"encoding","utf-8"),Xi(this,"encodingFailureFatal",!1)}};class Yc extends EventTarget{parseSync(t){let e=new yo(t.split(/\r\n|\r|\n/g));if(!e.hasNext())throw Error("Empty file");return this.parseAll(e)}parseStream(t){let e="",s=this;return new Promise((o,h)=>{t.on("data",c=>{e+=c}),t.on("end",()=>{try{let c=e.split(/\r\n|\r|\n/g),g=new yo(c);if(!g.hasNext())throw Error("Empty file");o(s.parseAll(g))}catch(c){h(c)}}),t.on("error",c=>{h(c)})})}async parseFromUrl(t,e){let s=await fetch(t,e);if(!s.body)return null;let o=s.body.getReader(),h="";for(;;){let{done:c,value:g}=await o.read();if(c){h+=this._decoder.decode(new ArrayBuffer(0),{stream:!1});break}h+=this._decoder.decode(g,{stream:!0})}return this.parseSync(h)}parseAll(t){let e={header:{},blocks:{},entities:[],tables:{},objects:{byName:{},byTree:void 0}},s=t.next();for(;!Nt(s,0,"EOF");)Nt(s,0,"SECTION")&&(Nt(s=t.next(),2,"HEADER")?(s=t.next(),e.header=Lc(s,t)):Nt(s,2,"BLOCKS")?(s=t.next(),e.blocks=Cc(s,t)):Nt(s,2,"ENTITIES")?(s=t.next(),e.entities=Rl(s,t)):Nt(s,2,"TABLES")?(s=t.next(),e.tables=Hc(s,t)):Nt(s,2,"OBJECTS")&&(s=t.next(),e.objects=Bc(s,t))),s=t.next();return e}constructor(t=new qc){super(),Xi(this,"_decoder",void 0),this._decoder=new TextDecoder(t.encoding,{fatal:t.encodingFailureFatal})}}var ia=(a=>(a[a.DecimalDegrees=0]="DecimalDegrees",a[a.DegreesMinutesSeconds=1]="DegreesMinutesSeconds",a[a.Gradians=2]="Gradians",a[a.Radians=3]="Radians",a[a.SurveyorsUnits=4]="SurveyorsUnits",a))(ia||{});class Dr{static get instance(){return this._instance||(this._instance=new Dr),this._instance}constructor(){this._blocks=new Map}createKey(t,e){return`${t}_${e}`}set(t,e){return e=e.fastDeepClone(),this._blocks.set(t,e),e}get(t){let e=this._blocks.get(t);return e&&(e=e.fastDeepClone()),e}has(t){return this._blocks.has(t)}clear(){this._blocks.clear()}draw(t,e,s,o=!0,h,c){const g=[];if(e!=null){const b=this.createKey(e.name,s);let f;if(this.has(b))f=this.get(b);else{const S=e.newIterator();for(const x of S)x.color.isByBlock&&s?(xo.copy(x.color),x.color.color=s,this.addEntity(x,g,t),x.color.copy(xo)):this.addEntity(x,g,t);f=t.group(g),f&&o&&this.set(b,f)}return f&&h&&(f.applyMatrix(h),c&&(c.x!=0||c.y!=0||c.z!=1)&&(h.setFromExtrusionDirection(c),f.applyMatrix(h))),f}else return t.group(g)}addEntity(t,e,s){const o=t.draw(s);o&&(this.attachEntityInfo(o,t),e.push(o))}attachEntityInfo(t,e){t.objectId=e.objectId,t.ownerId=e.ownerId,t.layerName=e.layer,t.visible=e.visibility}}const xo=new an,Hs="Continuous",Gs="ByLayer",Fl="ByBlock";var tn=(a=>(a[a.EndPoint=1]="EndPoint",a[a.MidPoint=2]="MidPoint",a[a.Center=3]="Center",a[a.Node=4]="Node",a[a.Quadrant=5]="Quadrant",a[a.Insertion=7]="Insertion",a[a.Perpendicular=8]="Perpendicular",a[a.Tangent=9]="Tangent",a[a.Nearest=10]="Nearest",a[a.Centroid=11]="Centroid",a))(tn||{}),aa=(a=>(a[a.Undefined=0]="Undefined",a[a.Inches=1]="Inches",a[a.Feet=2]="Feet",a[a.Miles=3]="Miles",a[a.Millimeters=4]="Millimeters",a[a.Centimeters=5]="Centimeters",a[a.Meters=6]="Meters",a[a.Kilometers=7]="Kilometers",a[a.Microinches=8]="Microinches",a[a.Mils=9]="Mils",a[a.Yards=10]="Yards",a[a.Angstroms=11]="Angstroms",a[a.Nanometers=12]="Nanometers",a[a.Microns=13]="Microns",a[a.Decimeters=14]="Decimeters",a[a.Dekameters=15]="Dekameters",a[a.Hectometers=16]="Hectometers",a[a.Gigameters=17]="Gigameters",a[a.Astronomical=18]="Astronomical",a[a.LightYears=19]="LightYears",a[a.Parsecs=20]="Parsecs",a[a.USSurveyFeet=21]="USSurveyFeet",a[a.USSurveyInch=22]="USSurveyInch",a[a.USSurveyYard=23]="USSurveyYard",a[a.USSurveyMile=24]="USSurveyMile",a[a.Max=24]="Max",a))(aa||{});function Kc(a){return a==4||a==5||a==6||a==7||a==12||a==13||a==14||a==15||a==16||a==17}function Xc(a){return a==1||a==2||a==3||a==8||a==9||a==10||a==21}var Vl=(a=>(a.ClosedFilled="",a.Dot="_DOT",a.DotSmall="_DOTSMALL",a.DotBlank="_DOTBLANK",a.Origin="_ORIGIN",a.Origin2="_ORIGIN2",a.Open="_OPEN",a.Open90="_OPEN90",a.Open30="_OPEN30",a.Closed="_CLOSED",a.Small="_SMALL",a.None="_NONE",a.Oblique="_OBLIQUE",a.BoxFilled="_BOXFILLED",a.Box="_BOXBLANK",a.ClosedBlank="_CLOSEDBLANK",a.DatumBlank="_DATUMBLANK",a.DatumFilled="_DATUMFILLED",a.Integral="_INTEGRAL",a.ArchTick="_ARCHTICK",a))(Vl||{});class _i{constructor(t){this.i=0,this._records=t,this._keys=Array.from(t.keys())}[Symbol.iterator](){return this}next(){for(;this.i<this._keys.length;){const t=this._records.get(this._keys[this.i]);return this.i+=1,{value:t,done:!1}}return{value:null,done:!0}}}const Ul="Load Database";class Se extends Uo{constructor(t,e){super(t.stage),this.data=t,this.progress=e}async run(t){const e=ea.getInstance().getEntry(Ul),s=Date.now();this.progress&&await this.progress(this.data.progress.value,this.data.stage,"START");const o=await this.data.task(t);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 e&&(e.data[this.name]=Date.now()-s),o}}class jl{constructor(t={}){this.config=t}async read(t,e,s,o){const h={name:Ul,data:{total:0},format(){let f="";return Object.keys(this.data).forEach(S=>{S!=="total"&&(f+=`- ${S}: ${this.data[S]} ms
2
2
  `)}),f+=`- total: ${this.data.total} ms`,f}};ea.getInstance().collect(h),this.progress=o;const c={value:0},g=new jo;g.setCompleteCallback(()=>this.onFinished()),g.setErrorCallback(f=>this.onError(f)),g.addTask(new Se({stage:"START",step:1,progress:c,task:async f=>f},o)),g.addTask(new Se({stage:"PARSE",step:5,progress:c,task:async f=>({model:await this.parse(f)})},o)),g.addTask(new Se({stage:"FONT",step:5,progress:c,task:async f=>{const S=this.getFonts(f.model);return{model:f.model,data:S}}},o)),g.addTask(new Se({stage:"LTYPE",step:1,progress:c,task:async f=>(this.processLineTypes(f.model,e),f)},o)),g.addTask(new Se({stage:"STYLE",step:1,progress:c,task:async f=>(this.processTextStyles(f.model,e),f)},o)),g.addTask(new Se({stage:"DIMSTYLE",step:1,progress:c,task:async f=>(this.processDimStyles(f.model,e),f)},o)),g.addTask(new Se({stage:"LAYER",step:1,progress:c,task:async f=>(this.processLayers(f.model,e),f)},o)),g.addTask(new Se({stage:"VPORT",step:1,progress:c,task:async f=>(this.processViewports(f.model,e),f)},o)),g.addTask(new Se({stage:"HEADER",step:1,progress:c,task:async f=>(this.processHeader(f.model,e),f)},o)),g.addTask(new Se({stage:"BLOCK_RECORD",step:5,progress:c,task:async f=>(this.processBlockTables(f.model,e),f)},o)),g.addTask(new Se({stage:"OBJECT",step:5,progress:c,task:async f=>(this.processObjects(f.model,e),f)},o)),g.addTask(new Se({stage:"BLOCK",step:5,progress:c,task:async f=>(await this.processBlocks(f.model,e),f)},o)),g.addTask(new Se({stage:"ENTITY",step:100,progress:c,task:async f=>(await this.processEntities(f.model,e,s,c,o),f)},o)),g.addTask(new Se({stage:"END",step:0,progress:c,task:async f=>f},o));const b=Date.now();await g.run(t),h.data.total=Date.now()-b}onError(t){if(this.progress){const e=t.task;this.progress(e.data.progress.value,e.data.stage,"ERROR",void 0,t)}console.error(`Error occurred in conversion stage '${t.task.name}': `,t.error),t.task.name!="ENTITY"&&this.onFinished()}onFinished(){this.progress&&(this.progress(100,"END","END"),Dr.instance.clear())}async parse(t,e){throw new Error("Not impelemented yet!")}getFonts(t){throw new Error("Not impelemented yet!")}processLineTypes(t,e){throw new Error("Not impelemented yet!")}processTextStyles(t,e){throw new Error("Not impelemented yet!")}processDimStyles(t,e){throw new Error("Not impelemented yet!")}processLayers(t,e){throw new Error("Not impelemented yet!")}processViewports(t,e){throw new Error("Not impelemented yet!")}processHeader(t,e){throw new Error("Not impelemented yet!")}processBlockTables(t,e){throw new Error("Not impelemented yet!")}processObjects(t,e){throw new Error("Not impelemented yet!")}processBlocks(t,e){throw new Error("Not impelemented yet!")}processEntities(t,e,s,o,h){throw new Error("Not impelemented yet!")}}const fe=["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 wo=1234567;const oa=Math.PI/180,la=180/Math.PI;function Gl(){const a=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(fe[a&255]+fe[a>>8&255]+fe[a>>16&255]+fe[a>>24&255]+"-"+fe[t&255]+fe[t>>8&255]+"-"+fe[t>>16&15|64]+fe[t>>24&255]+"-"+fe[e&63|128]+fe[e>>8&255]+"-"+fe[e>>16&255]+fe[e>>24&255]+fe[s&255]+fe[s>>8&255]+fe[s>>16&255]+fe[s>>24&255]).toLowerCase()}function xr(a,t,e){return Math.max(t,Math.min(e,a))}function ha(a,t){return(a%t+t)%t}function Wl(a,t,e,s,o){return s+(a-t)*(o-s)/(e-t)}function Hl(a,t,e){return a!==t?(e-a)/(t-a):0}function ua(a,t,e){return(1-e)*a+e*t}function ql(a,t,e,s){return ua(a,t,1-Math.exp(-e*s))}function Yl(a,t=1){return t-Math.abs(ha(a,t*2)-t)}function Kl(a,t,e){return a<=t?0:a>=e?1:(a=(a-t)/(e-t),a*a*(3-2*a))}function Xl(a,t,e){return a<=t?0:a>=e?1:(a=(a-t)/(e-t),a*a*a*(a*(a*6-15)+10))}function $l(a,t){return a+Math.floor(Math.random()*(t-a+1))}function Zl(a,t){return a+Math.random()*(t-a)}function Ql(a){return a*(.5-Math.random())}function Jl(a){a!==void 0&&(wo=a);let t=wo+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function th(a){return a*oa}function eh(a){return a*la}function rh(a){return(a&a-1)===0&&a!==0}function nh(a){return Math.pow(2,Math.ceil(Math.log(a)/Math.LN2))}function sh(a){return Math.pow(2,Math.floor(Math.log(a)/Math.LN2))}function fs(a){const t=Math.PI*2;return(a%t+t)%t}function ih(a,t,e){return a>t&&a<e||a>e&&a<t}function ah(a,t,e,s=!1){return a=fs(a),t=fs(t),e=fs(e),s?t>e?a<=t&&a>=e:a<=t||a>=e:t<e?a>=t&&a<=e:a>=t||a<=e}function ca(a){return a=Math.abs(a),a<1?0:Math.ceil(Math.log10(Math.abs(a)+1))}function oh(a,t=1e-7){const e=ca(a);return Math.max(Math.pow(10,e)*t,t)}const St={DEG2RAD:oa,RAD2DEG:la,generateUUID:Gl,clamp:xr,euclideanModulo:ha,mapLinear:Wl,inverseLerp:Hl,lerp:ua,damp:ql,pingpong:Yl,smoothstep:Kl,smootherstep:Xl,randInt:$l,randFloat:Zl,randFloatSpread:Ql,seededRandom:Jl,degToRad:th,radToDeg:eh,isPowerOfTwo:rh,ceilPowerOfTwo:nh,floorPowerOfTwo:sh,normalizeAngle:fs,isBetween:ih,isBetweenAngle:ah,intPartLength:ca,relativeEps:oh},$i=class lh{constructor(t,e){this.x=0,this.y=0;const s=+(t!==void 0)+ +(e!==void 0);if(s!==0){if(s===1&&t instanceof Array){this.x=t[0],this.y=t[1];return}if(s===1){const{x:o,y:h}=t;this.x=o,this.y=h;return}if(s===2){this.x=t,this.y=e;return}throw Re.ILLEGAL_PARAMETERS}}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new lh(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix2d(t){const e=this.x,s=this.y,o=t.elements;return this.x=o[0]*e+o[3]*s+o[6],this.y=o[1]*e+o[4]*s+o[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(t,Math.min(e,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const s=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,s)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y;return e*e+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}rotateAround(t,e){const s=Math.cos(e),o=Math.sin(e),h=this.x-t.x,c=this.y-t.y;return this.x=h*s-c*o+t.x,this.y=h*o+c*s+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}relativeEps(t=1e-7){return Math.min(St.relativeEps(this.x,t),St.relativeEps(this.y,t))}*[Symbol.iterator](){yield this.x,yield this.y}};$i.EMPTY=Object.freeze(new $i(0,0));let Kt=$i;const Zi=class hh{constructor(t,e,s,o,h,c,g,b,f){this.elements=[1,0,0,0,1,0,0,0,1],t!=null&&e!=null&&s!=null&&o!=null&&h!=null&&c!=null&&g!=null&&b!=null&&f!=null&&this.set(t,e,s,o,h,c,g,b,f)}set(t,e,s,o,h,c,g,b,f){const S=this.elements;return S[0]=t,S[1]=o,S[2]=g,S[3]=e,S[4]=h,S[5]=b,S[6]=s,S[7]=c,S[8]=f,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],this}extractBasis(t,e,s){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,o=e.elements,h=this.elements,c=s[0],g=s[3],b=s[6],f=s[1],S=s[4],x=s[7],k=s[2],M=s[5],D=s[8],z=o[0],U=o[3],B=o[6],gt=o[1],ft=o[4],ut=o[7],W=o[2],mt=o[5],lt=o[8];return h[0]=c*z+g*gt+b*W,h[3]=c*U+g*ft+b*mt,h[6]=c*B+g*ut+b*lt,h[1]=f*z+S*gt+x*W,h[4]=f*U+S*ft+x*mt,h[7]=f*B+S*ut+x*lt,h[2]=k*z+M*gt+D*W,h[5]=k*U+M*ft+D*mt,h[8]=k*B+M*ut+D*lt,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],s=t[1],o=t[2],h=t[3],c=t[4],g=t[5],b=t[6],f=t[7],S=t[8];return e*c*S-e*g*f-s*h*S+s*g*b+o*h*f-o*c*b}invert(){const t=this.elements,e=t[0],s=t[1],o=t[2],h=t[3],c=t[4],g=t[5],b=t[6],f=t[7],S=t[8],x=S*c-g*f,k=g*b-S*h,M=f*h-c*b,D=e*x+s*k+o*M;if(D===0)return this.set(0,0,0,0,0,0,0,0,0);const z=1/D;return t[0]=x*z,t[1]=(o*f-S*s)*z,t[2]=(g*s-o*c)*z,t[3]=k*z,t[4]=(S*e-o*b)*z,t[5]=(o*h-g*e)*z,t[6]=M*z,t[7]=(s*b-f*e)*z,t[8]=(c*e-s*h)*z,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t.elements[0]=e[0],t.elements[1]=e[3],t.elements[2]=e[6],t.elements[3]=e[1],t.elements[4]=e[4],t.elements[5]=e[7],t.elements[6]=e[2],t.elements[7]=e[5],t.elements[8]=e[8],this}setUvTransform(t,e,s,o,h,c,g){const b=Math.cos(h),f=Math.sin(h);return this.set(s*b,s*f,-s*(b*c+f*g)+c+t,-o*f,o*b,-o*(-f*c+b*g)+g+e,0,0,1),this}scale(t,e){return this.premultiply(Wi.makeScale(t,e)),this}rotate(t){return this.premultiply(Wi.makeRotation(-t)),this}translate(t,e){return this.premultiply(Wi.makeTranslation(t,e)),this}makeTranslation(t,e){return t instanceof Kt?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,s,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,s=t.elements;for(let o=0;o<9;o++)if(e[o]!==s[o])return!1;return!0}fromArray(t,e=0){for(let s=0;s<9;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t}clone(){return new hh().fromArray(this.elements)}};Zi.IDENTITY=Object.freeze(new Zi);let vi=Zi;const Wi=new vi,Jr=1e-6,re=2*Math.PI,$c={x:0,y:0},da={x:0,y:0,z:0};class ma{constructor(){this.equalPointTol=Jr,this.equalVectorTol=Jr}equalPoint2d(t,e){return new Kt(t).sub(e).length()<this.equalPointTol}equalPoint3d(t,e){return new $(t).sub(e).length()<this.equalPointTol}static equalToZero(t,e=Jr){return t<e&&t>-e}static equal(t,e,s=Jr){return Math.abs(t-e)<s}static great(t,e,s=Jr){return t-e>s}static less(t,e,s=Jr){return t-e<s}}const pa=new ma;function ga(a,t,e=!1){const s=a.x,o=a.y;let h=!1;const c=t.length;for(let g=0,b=c-1;g<c;b=g++){const f=t[g].x,S=t[g].y,x=t[b].x,k=t[b].y;let M=S>o!=k>o;e&&(M=S>=o!=k>=o),M&&s<(x-f)*(o-S)/(k-S)+f&&(h=!h)}return h}function uh(a,t){if(a.length===0||t.length===0)return!1;const e=new _e().setFromPoints(a),s=new _e().setFromPoints(t);if(!e.intersectsBox(s))return!1;for(let o=0;o<a.length;){if(ga(a[o],t,!0))return!0;o<a.length-1&&pa.equalPoint2d(a[o+1],a[o])&&++o,++o}return!1}const ch={isPointInPolygon:ga,isPolygonIntersect:uh};function dh(a,t){const e=[],s=t-1,o=a;for(let h=0;h<=o;h++)e.push(0);for(let h=1;h<=s-o;h++)e.push(h);for(let h=0;h<=o;h++)e.push(s-o+1);return e}function mh(a,t){const e=t.length-1,s=a,o=[0];let h=0;for(let g=1;g<=e;g++){const b=t[g][0]-t[g-1][0],f=t[g][1]-t[g-1][1],S=t[g][2]-t[g-1][2],x=Math.sqrt(b*b+f*f+S*S);h+=x,o.push(h)}const c=[];for(let g=0;g<=s;g++)c.push(0);for(let g=1;g<=e-s;g++){const b=o[g]/h;c.push(b*(e-s+1))}for(let g=0;g<=s;g++)c.push(e-s+1);return c}function ph(a,t){const e=t.length-1,s=a,o=[0];let h=0;for(let g=1;g<=e;g++){const b=t[g][0]-t[g-1][0],f=t[g][1]-t[g-1][1],S=t[g][2]-t[g-1][2],x=Math.sqrt(b*b+f*f+S*S),k=Math.sqrt(x);h+=k,o.push(h)}const c=[];for(let g=0;g<=s;g++)c.push(0);for(let g=1;g<=e-s;g++){const b=o[g]/h;c.push(b*(e-s+1))}for(let g=0;g<=s;g++)c.push(e-s+1);return c}function qs(a,t,e,s){if(t===0)return e>=s[a]&&e<s[a+1]?1:0;const o=s[a+t]-s[a],h=s[a+t+1]-s[a+1],c=o>1e-10?(e-s[a])/o:0,g=h>1e-10?(s[a+t+1]-e)/h:0;return c*qs(a,t-1,e,s)+g*qs(a+1,t-1,e,s)}function _s(a,t,e,s,o){const h=s.length-1,c=t;if(a=Math.max(e[c],Math.min(e[h+1],a)),Math.abs(a-e[h+1])<1e-8)return[...s[h]];if(Math.abs(a-e[c])<1e-8)return[...s[0]];const g=[0,0,0];let b=0;for(let f=0;f<=h;f++){const S=qs(f,c,a,e),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=e[e.length-c-1];if(Math.abs(a-f)<1e-8)return[...s[h]];if(Math.abs(a-e[c])<1e-8)return[...s[0]]}return b>1e-10&&(g[0]/=b,g[1]/=b,g[2]/=b),g}function gh(a,t,e,s){const o=a,h=t[o],c=t[t.length-o-1];let g=0;const b=1e3,f=(c-h)/b;let S=_s(h,a,t,e,s);for(let z=1;z<=b;z++){const U=h+z*f,B=_s(U,a,t,e,s),gt=B[0]-S[0],ft=B[1]-S[1],ut=B[2]-S[2];g+=Math.sqrt(gt*gt+ft*ft+ut*ut),S=B}const x=_s(c,a,t,e,s),k=x[0]-S[0],M=x[1]-S[1],D=x[2]-S[2];return g+=Math.sqrt(k*k+M*M+D*D),g}function Zc(a){return a.map(t=>[...t])}class Rr{constructor(t=0,e=0,s=0,o=1){this._x=t,this._y=e,this._z=s,this._w=o}static slerpFlat(t,e,s,o,h,c,g){let b=s[o+0],f=s[o+1],S=s[o+2],x=s[o+3];const k=h[c+0],M=h[c+1],D=h[c+2],z=h[c+3];if(g===0){t[e+0]=b,t[e+1]=f,t[e+2]=S,t[e+3]=x;return}if(g===1){t[e+0]=k,t[e+1]=M,t[e+2]=D,t[e+3]=z;return}if(x!==z||b!==k||f!==M||S!==D){let U=1-g;const B=b*k+f*M+S*D+x*z,gt=B>=0?1:-1,ft=1-B*B;if(ft>Number.EPSILON){const W=Math.sqrt(ft),mt=Math.atan2(W,B*gt);U=Math.sin(U*mt)/W,g=Math.sin(g*mt)/W}const ut=g*gt;if(b=b*U+k*ut,f=f*U+M*ut,S=S*U+D*ut,x=x*U+z*ut,U===1-g){const W=1/Math.sqrt(b*b+f*f+S*S+x*x);b*=W,f*=W,S*=W,x*=W}}t[e]=b,t[e+1]=f,t[e+2]=S,t[e+3]=x}static multiplyQuaternionsFlat(t,e,s,o,h,c){const g=s[o],b=s[o+1],f=s[o+2],S=s[o+3],x=h[c],k=h[c+1],M=h[c+2],D=h[c+3];return t[e]=g*D+S*x+b*M-f*k,t[e+1]=b*D+S*k+f*x-g*M,t[e+2]=f*D+S*M+g*k-b*x,t[e+3]=S*D-g*x-b*k-f*M,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,s,o){return this._x=t,this._y=e,this._z=s,this._w=o,this._onChangeCallback(),this}clone(){return new Rr(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const s=t.x,o=t.y,h=t.z,c=t.order,g=Math.cos,b=Math.sin,f=g(s/2),S=g(o/2),x=g(h/2),k=b(s/2),M=b(o/2),D=b(h/2);switch(c){case"XYZ":this._x=k*S*x+f*M*D,this._y=f*M*x-k*S*D,this._z=f*S*D+k*M*x,this._w=f*S*x-k*M*D;break;case"YXZ":this._x=k*S*x+f*M*D,this._y=f*M*x-k*S*D,this._z=f*S*D-k*M*x,this._w=f*S*x+k*M*D;break;case"ZXY":this._x=k*S*x-f*M*D,this._y=f*M*x+k*S*D,this._z=f*S*D+k*M*x,this._w=f*S*x-k*M*D;break;case"ZYX":this._x=k*S*x-f*M*D,this._y=f*M*x+k*S*D,this._z=f*S*D-k*M*x,this._w=f*S*x+k*M*D;break;case"YZX":this._x=k*S*x+f*M*D,this._y=f*M*x+k*S*D,this._z=f*S*D-k*M*x,this._w=f*S*x-k*M*D;break;case"XZY":this._x=k*S*x-f*M*D,this._y=f*M*x-k*S*D,this._z=f*S*D+k*M*x,this._w=f*S*x+k*M*D;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+c)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const s=e/2,o=Math.sin(s);return this._x=t.x*o,this._y=t.y*o,this._z=t.z*o,this._w=Math.cos(s),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,s=e[0],o=e[4],h=e[8],c=e[1],g=e[5],b=e[9],f=e[2],S=e[6],x=e[10],k=s+g+x;if(k>0){const M=.5/Math.sqrt(k+1);this._w=.25/M,this._x=(S-b)*M,this._y=(h-f)*M,this._z=(c-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+c)/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+c)/M,this._y=.25*M,this._z=(b+S)/M}else{const M=2*Math.sqrt(1+x-s-g);this._w=(c-o)/M,this._x=(h+f)/M,this._y=(b+S)/M,this._z=.25*M}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let s=t.dot(e)+1;return s<Number.EPSILON?(s=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=s):(this._x=0,this._y=-t.z,this._z=t.y,this._w=s)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=s),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(xr(this.dot(t),-1,1)))}rotateTowards(t,e){const s=this.angleTo(t);if(s===0)return this;const o=Math.min(1,e/s);return this.slerp(t,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(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const s=t._x,o=t._y,h=t._z,c=t._w,g=e._x,b=e._y,f=e._z,S=e._w;return this._x=s*S+c*g+o*f-h*b,this._y=o*S+c*b+h*g-s*f,this._z=h*S+c*f+s*b-o*g,this._w=c*S-s*g-o*b-h*f,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const s=this._x,o=this._y,h=this._z,c=this._w;let g=c*t._w+s*t._x+o*t._y+h*t._z;if(g<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,g=-g):this.copy(t),g>=1)return this._w=c,this._x=s,this._y=o,this._z=h,this;const b=1-g*g;if(b<=Number.EPSILON){const M=1-e;return this._w=M*c+e*this._w,this._x=M*s+e*this._x,this._y=M*o+e*this._y,this._z=M*h+e*this._z,this.normalize(),this}const f=Math.sqrt(b),S=Math.atan2(f,g),x=Math.sin((1-e)*S)/f,k=Math.sin(e*S)/f;return this._w=c*x+this._w*k,this._x=s*x+this._x*k,this._y=o*x+this._y*k,this._z=h*x+this._z*k,this._onChangeCallback(),this}slerpQuaternions(t,e,s){return this.copy(t).slerp(e,s)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),s=Math.random(),o=Math.sqrt(1-s),h=Math.sqrt(s);return this.set(o*Math.sin(t),o*Math.cos(t),h*Math.sin(e),h*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const ze=class fh{constructor(t,e,s){this.x=0,this.y=0,this.z=0;const o=+(t!==void 0)+ +(e!==void 0)+ +(s!==void 0);if(o!==0){if(o===1&&t instanceof Array){this.x=t[0],this.y=t[1],this.z=t[2];return}if(o===1){const{x:h,y:c,z:g}=t;this.x=h,this.y=c,this.z=g||0;return}if(o===3){this.x=t,this.y=e,this.z=s;return}throw Re.ILLEGAL_PARAMETERS}}set(t,e,s){return s===void 0&&(s=this.z),this.x=t,this.y=e,this.z=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new fh(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z||0,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z||0,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Ao.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Ao.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,s=this.y,o=this.z,h=t.elements;return this.x=h[0]*e+h[3]*s+h[6]*o,this.y=h[1]*e+h[4]*s+h[7]*o,this.z=h[2]*e+h[5]*s+h[8]*o,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix3d(t){const e=this.x,s=this.y,o=this.z,h=t.elements,c=1/(h[3]*e+h[7]*s+h[11]*o+h[15]);return this.x=(h[0]*e+h[4]*s+h[8]*o+h[12])*c,this.y=(h[1]*e+h[5]*s+h[9]*o+h[13])*c,this.z=(h[2]*e+h[6]*s+h[10]*o+h[14])*c,this}applyQuaternion(t){const e=this.x,s=this.y,o=this.z,h=t.x,c=t.y,g=t.z,b=t.w,f=2*(c*o-g*s),S=2*(g*e-h*o),x=2*(h*s-c*e);return this.x=e+b*f+c*x-g*S,this.y=s+b*S+g*f-h*x,this.z=o+b*x+h*S-c*f,this}transformDirection(t){const e=this.x,s=this.y,o=this.z,h=t.elements;return this.x=h[0]*e+h[4]*s+h[8]*o,this.y=h[1]*e+h[5]*s+h[9]*o,this.z=h[2]*e+h[6]*s+h[10]*o,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(t,Math.min(e,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}isParallelTo(t){const e=this.dot(t),s=this.length(),o=t.length();return Math.abs(e)===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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const s=t.x,o=t.y,h=t.z,c=e.x,g=e.y,b=e.z;return this.x=o*b-h*g,this.y=h*c-s*b,this.z=s*g-o*c,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const s=t.dot(this)/e;return this.copy(t).multiplyScalar(s)}projectOnPlane(t){return Hi.copy(this).projectOnVector(t),this.sub(Hi)}reflect(t){return this.sub(Hi.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const s=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,s)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y,o=this.z-t.z;return e*e+s*s+o*o}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),s=this.setFromMatrixColumn(t,1).length(),o=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=s,this.z=o,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,s=Math.sqrt(1-e*e);return this.x=s*Math.cos(t),this.y=e,this.z=s*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};ze.X_AXIS=Object.freeze(new ze(1,0,0)),ze.NEGATIVE_X_AXIS=Object.freeze(new ze(-1,0,0)),ze.Y_AXIS=Object.freeze(new ze(0,1,0)),ze.NEGATIVE_Y_AXIS=Object.freeze(new ze(0,-1,0)),ze.Z_AXIS=Object.freeze(new ze(0,0,1)),ze.NEGATIVE_Z_AXIS=Object.freeze(new ze(0,0,-1));let $=ze;const Hi=new $,Ao=new Rr,Qi=class _h{constructor(t,e,s,o,h,c,g,b,f,S,x,k,M,D,z,U){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!=null&&e!=null&&s!=null&&o!=null&&h!=null&&c!=null&&g!=null&&b!=null&&f!=null&&S!=null&&x!=null&&k!=null&&M!=null&&D!=null&&z!=null&&U!=null&&this.set(t,e,s,o,h,c,g,b,f,S,x,k,M,D,z,U)}set(t,e,s,o,h,c,g,b,f,S,x,k,M,D,z,U){const B=this.elements;return B[0]=t,B[4]=e,B[8]=s,B[12]=o,B[1]=h,B[5]=c,B[9]=g,B[13]=b,B[2]=f,B[6]=S,B[10]=x,B[14]=k,B[3]=M,B[7]=D,B[11]=z,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 _h().fromArray(this.elements)}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],e[9]=s[9],e[10]=s[10],e[11]=s[11],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],this}copyPosition(t){const e=this.elements,s=t.elements;return e[12]=s[12],e[13]=s[13],e[14]=s[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}setFromExtrusionDirection(t){if(pa.equalPoint3d(t,$.Z_AXIS))this.identity();else{const e=new $(1,0,0);Math.abs(t.x)<1/64&&Math.abs(t.y)<1/64?e.crossVectors($.Y_AXIS,t).normalize():e.crossVectors($.Z_AXIS,t).normalize();const s=t.clone().cross(e).normalize();this.set(e.x,e.y,e.z,0,s.x,s.y,s.z,0,t.x,t.y,t.z,0,0,0,0,1)}return this}extractBasis(t,e,s){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this}makeBasis(t,e,s){return this.set(t.x,e.x,s.x,0,t.y,e.y,s.y,0,t.z,e.z,s.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,s=t.elements,o=1/An.setFromMatrixColumn(t,0).length(),h=1/An.setFromMatrixColumn(t,1).length(),c=1/An.setFromMatrixColumn(t,2).length();return e[0]=s[0]*o,e[1]=s[1]*o,e[2]=s[2]*o,e[3]=0,e[4]=s[4]*h,e[5]=s[5]*h,e[6]=s[6]*h,e[7]=0,e[8]=s[8]*c,e[9]=s[9]*c,e[10]=s[10]*c,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(Qc,t,Jc)}lookAt(t,e,s){const o=this.elements;return Oe.subVectors(t,e),Oe.lengthSq()===0&&(Oe.z=1),Oe.normalize(),Lr.crossVectors(s,Oe),Lr.lengthSq()===0&&(Math.abs(s.z)===1?Oe.x+=1e-4:Oe.z+=1e-4,Oe.normalize(),Lr.crossVectors(s,Oe)),Lr.normalize(),Cs.crossVectors(Oe,Lr),o[0]=Lr.x,o[4]=Cs.x,o[8]=Oe.x,o[1]=Lr.y,o[5]=Cs.y,o[9]=Oe.y,o[2]=Lr.z,o[6]=Cs.z,o[10]=Oe.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,o=e.elements,h=this.elements,c=s[0],g=s[4],b=s[8],f=s[12],S=s[1],x=s[5],k=s[9],M=s[13],D=s[2],z=s[6],U=s[10],B=s[14],gt=s[3],ft=s[7],ut=s[11],W=s[15],mt=o[0],lt=o[4],Wt=o[8],Ht=o[12],Ut=o[1],bt=o[5],Lt=o[9],de=o[13],me=o[2],Ie=o[6],Qt=o[10],ae=o[14],Q=o[3],kt=o[7],oe=o[11],ar=o[15];return h[0]=c*mt+g*Ut+b*me+f*Q,h[4]=c*lt+g*bt+b*Ie+f*kt,h[8]=c*Wt+g*Lt+b*Qt+f*oe,h[12]=c*Ht+g*de+b*ae+f*ar,h[1]=S*mt+x*Ut+k*me+M*Q,h[5]=S*lt+x*bt+k*Ie+M*kt,h[9]=S*Wt+x*Lt+k*Qt+M*oe,h[13]=S*Ht+x*de+k*ae+M*ar,h[2]=D*mt+z*Ut+U*me+B*Q,h[6]=D*lt+z*bt+U*Ie+B*kt,h[10]=D*Wt+z*Lt+U*Qt+B*oe,h[14]=D*Ht+z*de+U*ae+B*ar,h[3]=gt*mt+ft*Ut+ut*me+W*Q,h[7]=gt*lt+ft*bt+ut*Ie+W*kt,h[11]=gt*Wt+ft*Lt+ut*Qt+W*oe,h[15]=gt*Ht+ft*de+ut*ae+W*ar,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],s=t[4],o=t[8],h=t[12],c=t[1],g=t[5],b=t[9],f=t[13],S=t[2],x=t[6],k=t[10],M=t[14],D=t[3],z=t[7],U=t[11],B=t[15];return D*(+h*b*x-o*f*x-h*g*k+s*f*k+o*g*M-s*b*M)+z*(+e*b*M-e*f*k+h*c*k-o*c*M+o*f*S-h*b*S)+U*(+e*f*x-e*g*M-h*c*x+s*c*M+h*g*S-s*f*S)+B*(-o*g*S-e*b*x+e*g*k+o*c*x-s*c*k+s*b*S)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,s){const o=this.elements;return t instanceof $?(o[12]=t.x,o[13]=t.y,o[14]=t.z):(o[12]=t,o[13]=e,o[14]=s),this}invert(){const t=this.elements,e=t[0],s=t[1],o=t[2],h=t[3],c=t[4],g=t[5],b=t[6],f=t[7],S=t[8],x=t[9],k=t[10],M=t[11],D=t[12],z=t[13],U=t[14],B=t[15],gt=x*U*f-z*k*f+z*b*M-g*U*M-x*b*B+g*k*B,ft=D*k*f-S*U*f-D*b*M+c*U*M+S*b*B-c*k*B,ut=S*z*f-D*x*f+D*g*M-c*z*M-S*g*B+c*x*B,W=D*x*b-S*z*b-D*g*k+c*z*k+S*g*U-c*x*U,mt=e*gt+s*ft+o*ut+h*W;if(mt===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const lt=1/mt;return t[0]=gt*lt,t[1]=(z*k*h-x*U*h-z*o*M+s*U*M+x*o*B-s*k*B)*lt,t[2]=(g*U*h-z*b*h+z*o*f-s*U*f-g*o*B+s*b*B)*lt,t[3]=(x*b*h-g*k*h-x*o*f+s*k*f+g*o*M-s*b*M)*lt,t[4]=ft*lt,t[5]=(S*U*h-D*k*h+D*o*M-e*U*M-S*o*B+e*k*B)*lt,t[6]=(D*b*h-c*U*h-D*o*f+e*U*f+c*o*B-e*b*B)*lt,t[7]=(c*k*h-S*b*h+S*o*f-e*k*f-c*o*M+e*b*M)*lt,t[8]=ut*lt,t[9]=(D*x*h-S*z*h-D*s*M+e*z*M+S*s*B-e*x*B)*lt,t[10]=(c*z*h-D*g*h+D*s*f-e*z*f-c*s*B+e*g*B)*lt,t[11]=(S*g*h-c*x*h-S*s*f+e*x*f+c*s*M-e*g*M)*lt,t[12]=W*lt,t[13]=(S*z*o-D*x*o+D*s*k-e*z*k-S*s*U+e*x*U)*lt,t[14]=(D*g*o-c*z*o-D*s*b+e*z*b+c*s*U-e*g*U)*lt,t[15]=(c*x*o-S*g*o+S*s*b-e*x*b-c*s*k+e*g*k)*lt,this}scale(t){const e=this.elements,s=t.x,o=t.y,h=t.z;return e[0]*=s,e[4]*=o,e[8]*=h,e[1]*=s,e[5]*=o,e[9]*=h,e[2]*=s,e[6]*=o,e[10]*=h,e[3]*=s,e[7]*=o,e[11]*=h,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],s=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],o=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,s,o))}makeTranslation(t,e,s){return t instanceof $?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,s,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),s=Math.sin(t);return this.set(1,0,0,0,0,e,-s,0,0,s,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,0,s,0,0,1,0,0,-s,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,0,s,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const s=Math.cos(e),o=Math.sin(e),h=1-s,c=t.x,g=t.y,b=t.z,f=h*c,S=h*g;return this.set(f*c+s,f*g-o*b,f*b+o*g,0,f*g+o*b,S*g+s,S*b-o*c,0,f*b-o*g,S*b+o*c,h*b*b+s,0,0,0,0,1),this}makeScale(t,e,s){return this.set(t,0,0,0,0,e,0,0,0,0,s,0,0,0,0,1),this}makeShear(t,e,s,o,h,c){return this.set(1,s,h,0,t,1,c,0,e,o,1,0,0,0,0,1),this}compose(t,e,s){const o=this.elements,h=e.x,c=e.y,g=e.z,b=e.w,f=h+h,S=c+c,x=g+g,k=h*f,M=h*S,D=h*x,z=c*S,U=c*x,B=g*x,gt=b*f,ft=b*S,ut=b*x,W=s.x,mt=s.y,lt=s.z;return o[0]=(1-(z+B))*W,o[1]=(M+ut)*W,o[2]=(D-ft)*W,o[3]=0,o[4]=(M-ut)*mt,o[5]=(1-(k+B))*mt,o[6]=(U+gt)*mt,o[7]=0,o[8]=(D+ft)*lt,o[9]=(U-gt)*lt,o[10]=(1-(k+z))*lt,o[11]=0,o[12]=t.x,o[13]=t.y,o[14]=t.z,o[15]=1,this}decompose(t,e,s){const o=this.elements;let h=An.set(o[0],o[1],o[2]).length();const c=An.set(o[4],o[5],o[6]).length(),g=An.set(o[8],o[9],o[10]).length();this.determinant()<0&&(h=-h),t.x=o[12],t.y=o[13],t.z=o[14],Je.copy(this);const b=1/h,f=1/c,S=1/g;return Je.elements[0]*=b,Je.elements[1]*=b,Je.elements[2]*=b,Je.elements[4]*=f,Je.elements[5]*=f,Je.elements[6]*=f,Je.elements[8]*=S,Je.elements[9]*=S,Je.elements[10]*=S,e.setFromRotationMatrix(Je),s.x=h,s.y=c,s.z=g,this}equals(t){const e=this.elements,s=t.elements;for(let o=0;o<16;o++)if(e[o]!==s[o])return!1;return!0}fromArray(t,e=0){for(let s=0;s<16;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t[e+9]=s[9],t[e+10]=s[10],t[e+11]=s[11],t[e+12]=s[12],t[e+13]=s[13],t[e+14]=s[14],t[e+15]=s[15],t}};Qi.IDENTITY=Object.freeze(new Qi);let sn=Qi;const An=new $,Je=new sn,Qc=new $(0,0,0),Jc=new $(1,1,1),Lr=new $,Cs=new $,Oe=new $;class Dt{constructor(t=void 0,e=void 0){this.min=t==null?new $(1/0,1/0,1/0):new $(t.x,t.y,t.z),this.max=e==null?new $(-1/0,-1/0,-1/0):new $(e.x,e.y,e.z)}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e+=3)this.expandByPoint(qi.fromArray(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const s=qi.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(s),this.max.copy(t).add(s),this}clone(){return new Dt().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new $(0,0,0):new $(0,0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new $(0,0,0):new $(0,0,0).subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)}intersectsPlane(t){let e,s;return t.normal.x>0?(e=t.normal.x*this.min.x,s=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,s=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,s+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,s+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,s+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,s+=t.normal.z*this.min.z),e<=-t.constant&&s>=-t.constant}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,qi).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(br[0].set(this.min.x,this.min.y,this.min.z).applyMatrix3d(t),br[1].set(this.min.x,this.min.y,this.max.z).applyMatrix3d(t),br[2].set(this.min.x,this.max.y,this.min.z).applyMatrix3d(t),br[3].set(this.min.x,this.max.y,this.max.z).applyMatrix3d(t),br[4].set(this.max.x,this.min.y,this.min.z).applyMatrix3d(t),br[5].set(this.max.x,this.min.y,this.max.z).applyMatrix3d(t),br[6].set(this.max.x,this.max.y,this.min.z).applyMatrix3d(t),br[7].set(this.max.x,this.max.y,this.max.z).applyMatrix3d(t),this.setFromPoints(br),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const br=[new $,new $,new $,new $,new $,new $,new $,new $],qi=new $,Po=new Kt;class _e{constructor(t=void 0,e=void 0){this.min=t==null?new Kt(1/0,1/0):new Kt(t.x,t.y),this.max=e==null?new Kt(-1/0,-1/0):new Kt(e.x,e.y)}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const s=Po.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(s),this.max.copy(t).add(s),this}clone(){return new _e().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new Kt(0,0):new Kt(0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new Kt(0,0):new Kt(0,0).subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Po).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const So=new $,td=new $,ed=new vi;class As{constructor(t=new $(1,0,0),e=0){this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,s,o){return this.normal.set(t,e,s),this.constant=o,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,s){const o=So.subVectors(s,e).cross(td.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(o,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectsBox(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const s=e||ed.getNormalMatrix(t),o=this.coplanarPoint(So).applyMatrix3d(t),h=this.normal.applyMatrix3(s).normalize();return this.constant=-o.dot(h),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new As().copy(this)}}class Mt extends Kt{static pointArrayToNumberArray(t){const e=new Array(t.length*2);return t.forEach((s,o)=>{s.toArray(e,o*2)}),e}}class X extends ${static pointArrayToNumberArray(t,e=!0){const s=e?3:2,o=new Array(t.length*s);return t.forEach((h,c)=>{h.toArray(o,c*s)}),o}}const Io=new sn,ko=new Rr,vh=class Ji{constructor(t=0,e=0,s=0,o=Ji.DEFAULT_ORDER){this._x=t,this._y=e,this._z=s,this._order=o}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,s,o=this._order){return this._x=t,this._y=e,this._z=s,this._order=o,this._onChangeCallback(),this}clone(){return new Ji(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,s=!0){const o=t.elements,h=o[0],c=o[4],g=o[8],b=o[1],f=o[5],S=o[9],x=o[2],k=o[6],M=o[10];switch(e){case"XYZ":this._y=Math.asin(xr(g,-1,1)),Math.abs(g)<.9999999?(this._x=Math.atan2(-S,M),this._z=Math.atan2(-c,h)):(this._x=Math.atan2(k,f),this._z=0);break;case"YXZ":this._x=Math.asin(-xr(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(xr(k,-1,1)),Math.abs(k)<.9999999?(this._y=Math.atan2(-x,M),this._z=Math.atan2(-c,f)):(this._y=0,this._z=Math.atan2(b,h));break;case"ZYX":this._y=Math.asin(-xr(x,-1,1)),Math.abs(x)<.9999999?(this._x=Math.atan2(k,M),this._z=Math.atan2(b,h)):(this._x=0,this._z=Math.atan2(-c,f));break;case"YZX":this._z=Math.asin(xr(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(-xr(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(k,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: "+e)}return this._order=e,s===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,s=!0){return Io.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Io,e,s)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return ko.setFromEuler(this),this.setFromQuaternion(ko,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};vh.DEFAULT_ORDER="XYZ";let yh=vh;class bh{constructor(){this._boundingBoxNeedsUpdate=!1}get boundingBoxNeedUpdate(){return this._boundingBoxNeedsUpdate}}class fa extends bh{translate(t){return this.transform(new vi().makeTranslation(t.x,t.y))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}class yi extends fa{constructor(){super(),this._loops=[]}add(t){this._loops.push(t),this._boundingBoxNeedsUpdate=!0}get loops(){return this._loops}get outter(){if(this._loops.length>0)return this._loops[0]}calculateBoundingBox(){const t=this.outter;return t?t.box:new _e}transform(t){return this._boundingBoxNeedsUpdate=!0,this}getPoints(t){const e=[];for(let s=0;s<this.loops.length;++s){const o=this.loops[s].getPoints(t);e.push(o)}return e}buildHierarchy(){var t;const e=this.getPoints(100),s=this.calculateBoundaryBoxes(e),o=this.sortBoundaryBoxesByAreas(s),h=new Map,c=o.length;for(let b=0;b<c;b++)h.set(o[b],{index:o[b],children:[]});const g={index:-1,children:[]};for(let b=0;b<c;b++){const f=o[b],S=e[f],x=s[f];let k=b+1;for(;k<c;k++){const M=o[k],D=e[M];if(s[M].containsBox(x)&&ch.isPointInPolygon(S[St.randInt(0,S.length-1)],D)){(t=h.get(M))==null||t.children.push(h.get(f));break}}k===c&&g.children.push(h.get(f))}return g}calculateBoundaryBoxes(t){const e=[];return t.forEach(s=>{e.push(new _e().setFromPoints(s))}),e}sortBoundaryBoxesByAreas(t){const e=[];t.forEach((o,h)=>{const c=o.size,g=c.width*c.height;e.push({area:g,index:h})}),e.sort((o,h)=>o.area-h.area);const s=[];return e.forEach(o=>{s.push(o.index)}),s}}class Tn extends fa{constructor(){super(),this.arcLengthDivisions=100}get startPoint(){return this.getPoint(0)}get endPoint(){return this.getPoint(1)}get length(){return this.getLength()}getPoint(t){throw new Error("AcGeCurve2d: .getPoint() not implemented.")}getPointAt(t){const e=this.getUtoTmapping(t);return this.getPoint(e)}getPoints(t=5){const e=[];for(let s=0;s<=t;s++)e.push(this.getPoint(s/t));return e}getSpacedPoints(t=5){const e=[];for(let s=0;s<=t;s++)e.push(this.getPointAt(s/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){const e=[];let s,o=this.getPoint(0),h=0;e.push(0);for(let c=1;c<=t;c++)s=this.getPoint(c/t),h+=s.distanceTo(o),e.push(h),o=s;return e}getUtoTmapping(t,e){const s=this.getLengths();let o=0;const h=s.length;let c;e?c=e:c=t*s[h-1];let g=0,b=h-1,f;for(;g<=b;)if(o=Math.floor(g+(b-g)/2),f=s[o]-c,f<0)g=o+1;else if(f>0)b=o-1;else{b=o;break}if(o=b,s[o]===c)return o/(h-1);const S=s[o],x=s[o+1]-S,k=(c-S)/x;return(o+k)/(h-1)}getTangent(t){let e=t-1e-4,s=t+1e-4;e<0&&(e=0),s>1&&(s=1);const o=this.getPoint(e),h=this.getPoint(s),c=new Mt;return c.copy(h).sub(o).normalize(),c}getTangentAt(t){const e=this.getUtoTmapping(t);return this.getTangent(e)}}class kn extends Tn{constructor(t,e,s,o,h){super();const c=+(t!==void 0)+ +(e!==void 0)+ +(s!==void 0)+ +(o!==void 0)+ +(h!==void 0);if(c==3)typeof t=="object"&&typeof e=="object"&&typeof s=="object"?this.createByThreePoints(t,e,s):this.createByStartEndPointsAndBulge(t,e,s);else if(c==5){const g=t;this.center=new Mt(g.x,g.y),this.radius=e,this._clockwise=h,this._startAngle=this._clockwise?this._mirrorAngle(St.normalizeAngle(s)):St.normalizeAngle(s),this._endAngle=this._clockwise?this._mirrorAngle(St.normalizeAngle(o)):St.normalizeAngle(o)}else throw Re.ILLEGAL_PARAMETERS}createByThreePoints(t,e,s){const o=(lt,Wt)=>({x:(lt.x+Wt.x)/2,y:(lt.y+Wt.y)/2}),h=(lt,Wt)=>(Wt.y-lt.y)/(Wt.x-lt.x),c=lt=>-1/lt,g=o(t,e),b=o(e,s),f=h(t,e),S=h(e,s),x=c(f),k=c(S),M=(lt,Wt,Ht,Ut)=>{const bt=(Ut-Wt)/(lt-Ht),Lt=lt*bt+Wt;return{x:bt,y:Lt}},D=g.y-x*g.x,z=b.y-k*b.x,U=M(x,D,k,z),B=Math.sqrt(Math.pow(t.x-U.x,2)+Math.pow(t.y-U.y,2)),gt=(lt,Wt)=>Math.atan2(lt.y-Wt.y,lt.x-Wt.x),ft=gt(t,U),ut=gt(e,U),W=gt(s,U),mt=W>ft&&W<ut||ft>W&&ft<ut||ut>W&&ut<ft;this.center=U,this.radius=B,this._clockwise=!mt,this._startAngle=ft,this._endAngle=W}createByStartEndPointsAndBulge(t,e,s){let o,h,c;s<0?(o=Math.atan(-s)*4,h=new Kt(t),c=new Kt(e)):(o=Math.atan(s)*4,h=new Kt(e),c=new Kt(t));const g=new Kt().subVectors(c,h),b=g.length(),f=new Kt().addVectors(h,g.multiplyScalar(.5)),S=Math.abs(b/2/Math.tan(o/2)),x=g.normalize();let k;if(o<Math.PI){const M=new Kt(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));k=f.add(M.multiplyScalar(-S))}else{const M=new Kt(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));k=f.add(M.multiplyScalar(S))}s<0?(this._startAngle=Math.atan2(h.y-k.y,h.x-k.x),this._endAngle=Math.atan2(c.y-k.y,c.x-k.x)):(this._startAngle=Math.atan2(c.y-k.y,c.x-k.x),this._endAngle=Math.atan2(h.y-k.y,h.x-k.x)),this._clockwise=s<0,this.center=k,this.radius=c.sub(k).length()}get center(){return this._center}set center(t){this._center=new Mt(t.x,t.y),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._clockwise?this._mirrorAngle(this._startAngle):this._startAngle}set startAngle(t){this._startAngle=this._clockwise?this._mirrorAngle(St.normalizeAngle(t)):St.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._clockwise?this._mirrorAngle(this._endAngle):this._endAngle}set endAngle(t){const e=this.startAngle==0&&t==re?t:St.normalizeAngle(t);this._endAngle=this._clockwise?this._mirrorAngle(e):e,this._boundingBoxNeedsUpdate=!0}_mirrorAngle(t){return(360-t*180/Math.PI)%360*Math.PI/180}_getInternalAngle(t){return this._clockwise?this._mirrorAngle(t):t}get deltaAngle(){const t=this._getInternalAngle(this.startAngle),e=this._getInternalAngle(this.endAngle);return this.clockwise?St.normalizeAngle(t-e):St.normalizeAngle(e-t)}get clockwise(){return this._clockwise}set clockwise(t){this._clockwise=t,this._boundingBoxNeedsUpdate=!0}get startPoint(){return this.getPointAtAngle(this.startAngle)}get endPoint(){return this.getPointAtAngle(this.endAngle)}get midPoint(){const t=this._getInternalAngle(this.startAngle),e=this._getInternalAngle(this.endAngle),s=St.normalizeAngle((t+e)/2),o=this._clockwise?this._mirrorAngle(s):s;return this.getPointAtAngle(o)}get closed(){const t=this._getInternalAngle(this.startAngle),e=this._getInternalAngle(this.endAngle);return Math.abs(e-t)/Math.PI%2==0}calculateBoundingBox(){const t=[this.startPoint,this.endPoint],e=[0,Math.PI/2,Math.PI,3*Math.PI/2];for(const h of e){const c=this._getInternalAngle(h);St.isBetweenAngle(c,this._getInternalAngle(this.startAngle),this._getInternalAngle(this.endAngle),this.clockwise)&&t.push(this.getPointAtAngle(h))}const s=t.map(h=>h.x),o=t.map(h=>h.y);return new _e(new Mt(Math.min(...s),Math.min(...o)),new Mt(Math.max(...s),Math.max(...o)))}get length(){return Math.abs(this.deltaAngle*this.radius)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}clone(){return new kn(this.center.clone(),this.radius,this._startAngle,this._endAngle,this.clockwise)}getPointAtAngle(t){const e=this._getInternalAngle(t),s=this.center.x+this.radius*Math.cos(e),o=this.center.y+this.radius*Math.sin(e);return new Mt(s,o)}getPoints(t=100){const e=[];let s=this.deltaAngle,o=this._getInternalAngle(this.startAngle);if(this.closed&&(s=re,o=0),this.clockwise)for(let h=0;h<=t;h++){const c=o-s*(h/t),g=this._clockwise?this._mirrorAngle(c):c,b=this.getPointAtAngle(g);e.push(new Mt(b.x,b.y))}else for(let h=0;h<=t;h++){const c=o+s*(h/t),g=this._clockwise?this._mirrorAngle(c):c,b=this.getPointAtAngle(g);e.push(new Mt(b.x,b.y))}return e}}class rd extends bh{translate(t){return this.transform(new sn().makeTranslation(t.x,t.y,t.z))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}class Ps extends rd{}class Br extends Ps{constructor(t,e){super(),this._start=new X(t),this._end=new X(e)}get startPoint(){return this._start}set startPoint(t){this._start.copy(t),this._boundingBoxNeedsUpdate=!0}get endPoint(){return this._end}set endPoint(t){this._end.copy(t),this._boundingBoxNeedsUpdate=!0}get direction(){return new $().subVectors(this.endPoint,this.startPoint).normalize()}get midPoint(){return new X((this._start.x+this._end.x)/2,(this._start.y+this._end.y)/2,(this._start.z+this._end.z)/2)}get length(){return this.startPoint.distanceTo(this.endPoint)}isPointOnLine(t){return this.project(t).distanceTo(t)<1e-6}at(t,e){return this.delta(e).multiplyScalar(t).add(this._start)}atLength(t,e=!1){if(e){const s=this.delta(Qr).normalize();return new X(this._start).addScaledVector(s,t)}else{const s=this.delta(Qr).normalize();return new X(this._end).addScaledVector(s,t)}}extend(t,e=!1){if(e){const s=Qr.subVectors(this._start,this._end).normalize();this._start=new X(this._start).addScaledVector(s,t)}else{const s=this.delta(Qr).normalize();this._end=new X(this._end).addScaledVector(s,t)}return this._boundingBoxNeedsUpdate=!0,this}closestPointToPointParameter(t,e){Eo.subVectors(t,this._start),Ns.subVectors(this.endPoint,this.startPoint);const s=Ns.dot(Ns);let o=Ns.dot(Eo)/s;return e&&(o=St.clamp(o,0,1)),o}closestPointToPoint(t,e,s){const o=this.closestPointToPointParameter(t,e);return this.delta(s).multiplyScalar(o).add(this._start)}delta(t){return t.subVectors(this._end,this._start)}distanceSq(){return this._start.distanceToSquared(this._end)}distance(){return this._start.distanceTo(this._end)}project(t){const e=this.direction,s=Qr.subVectors(t,this.startPoint).dot(e);return new X().copy(e).multiplyScalar(s).add(this.startPoint)}perpPoint(t){const e=this.direction,s=this.startPoint,o=Qr.subVectors(t,s).dot(e),h=Qr.copy(e).multiplyScalar(o);return new X().addVectors(s,h)}calculateBoundingBox(){const t=new X(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y),Math.min(this._start.z,this._end.z)),e=new X(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y),Math.max(this._start.z,this._end.z));return new Dt(t,e)}transform(t){return this._start.applyMatrix3d(t),this._end.applyMatrix3d(t),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new Br(this._start.clone(),this._end.clone())}}const Qr=new $,Eo=new $,Ns=new $;class rn extends Ps{static computeCenterPoint(t,e,s){const o=new $().addVectors(t,e).multiplyScalar(.5),h=new $().addVectors(t,s).multiplyScalar(.5),c=new $().subVectors(e,t),g=new $().subVectors(s,t),b=new $().crossVectors(c,g).normalize();if(b.lengthSq()===0)return console.error("Points are collinear and cannot form a valid arc."),null;const f=new $().crossVectors(c,b).normalize(),S=new $().crossVectors(g,b).normalize(),x=f.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),k=S.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),M=new Br(o,o.clone().add(x)),D=new Br(h,h.clone().add(k)),z=new $;return M.closestPointToPoint(D.startPoint,!0,z)?z:(console.error("Cannot find a valid center for the arc."),null)}static createByThreePoints(t,e,s){const o=rn.computeCenterPoint(t,e,s);if(o){const h=o.distanceTo(t),c=new $().subVectors(t,o),g=new $().subVectors(e,o),b=Math.atan2(c.y,c.x),f=Math.atan2(g.y,g.x);return new rn(o,h,b,f,$.Z_AXIS)}}constructor(t,e,s,o,h,c=$.X_AXIS){super(),this.center=t,this.radius=e,this.startAngle=s,this.endAngle=o,this.normal=h,this.refVec=c,(o-s)%re==0?(this.startAngle=0,this.endAngle=re):(this.startAngle=s,this.endAngle=o)}get center(){return this._center}set center(t){this._center=new X(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){if(t<0)throw Re.ILLEGAL_PARAMETERS;this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=St.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==re?t:St.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return St.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}get clockwise(){return this.deltaAngle<=0}get normal(){return this._normal}set normal(t){this._normal=new $(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get refVec(){return this._refVec}set refVec(t){this._refVec=new $(t.x,t.y,t.z),this._refVec.normalize(),this._boundingBoxNeedsUpdate=!0}get startPoint(){return this.getPointAtAngle(this._startAngle)}get endPoint(){return this.getPointAtAngle(this._endAngle)}get length(){return Math.abs(this.deltaAngle*this.radius)}calculateBoundingBox(){const t=[this.startAngle,this.endAngle];for(let b=0;b<2*Math.PI;b+=Math.PI/2)St.isBetweenAngle(b,this.startAngle,this.endAngle)&&t.push(b);let e=1/0,s=1/0,o=1/0,h=-1/0,c=-1/0,g=-1/0;for(const b of t){const f=this.getPointAtAngle(b);f.x<e&&(e=f.x),f.y<s&&(s=f.y),f.z<o&&(o=f.z),f.x>h&&(h=f.x),f.y>c&&(c=f.y),f.z>g&&(g=f.z)}return new Dt({x:e,y:s,z:o},{x:h,y:c,z:g})}get closed(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0}getPoints(t){const e=[];let s=this.deltaAngle,o=this.startAngle;this.closed&&(s=re,o=0);for(let h=0;h<=t;h++){const c=o+s*(h/t),g=this.getPointAtAngle(c);e.push(g)}return e}transform(t){const e=Yi.copy(this.refVec).applyAxisAngle(this.normal,this.startAngle).multiplyScalar(this.radius),s=Yi.copy(this.refVec).applyAxisAngle(this.normal,this.endAngle).multiplyScalar(this.radius);return this.center.applyMatrix3d(t),e.applyMatrix3d(t),s.applyMatrix3d(t),this.normal.applyMatrix3d(t).normalize(),this.refVec.applyMatrix3d(t).normalize(),this.startAngle=this.getAngle(e),this.endAngle=this.getAngle(s),this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.radius=t.radius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.normal=t.normal,this.refVec=t.refVec,this._boundingBoxNeedsUpdate=!0,this}clone(){return new rn(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)}getAngle(t){return t.sub(this.center),Math.atan2(t.dot(Yi.crossVectors(this.refVec,this.normal)),t.dot(this.refVec))}getPointAtAngle(t){const e=this.normal,s=this.refVec,o={x:e.y*s.z-e.z*s.y,y:e.z*s.x-e.x*s.z,z:e.x*s.y-e.y*s.x},h=this.center,c=this.radius;return new X(h.x+c*(s.x*Math.cos(t)+o.x*Math.sin(t)),h.y+c*(s.y*Math.cos(t)+o.y*Math.sin(t)),h.z+c*(s.z*Math.cos(t)+o.z*Math.sin(t)))}get plane(){const t=new $(this.center).distanceTo(da);return new As(this.normal,t)}}const Yi=new $;class bi extends Tn{constructor(t,e,s,o=0,h=re,c=!1,g=0){super(),this.center=t,this.majorAxisRadius=e,this.minorAxisRadius=s,(h-o)%re==0?(this.startAngle=0,this.endAngle=re):(this.startAngle=o,this.endAngle=h),this.clockwise=c,this.rotation=g}get center(){return this._center}set center(t){this._center=new X(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw Re.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw Re.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=St.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==re?t:St.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get clockwise(){return this._clockwise}set clockwise(t){this._clockwise=t,this._boundingBoxNeedsUpdate=!0}get rotation(){return this._rotation}set rotation(t){this._rotation=t,this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return St.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}calculateBoundingBox(){let t=1/0,e=1/0,s=-1/0,o=-1/0;for(let h=0;h<=100;h++){const c=this.getPoint(h/100);t=Math.min(t,c.x),e=Math.min(e,c.y),s=Math.max(s,c.x),o=Math.max(o,c.y)}return new _e({x:t,y:e},{x:s,y:o})}get closed(){return this.deltaAngle==0}getPoint(t){const e=Math.PI*2;let s=this.endAngle-this.startAngle;const o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=e;for(;s>e;)s-=e;s<Number.EPSILON&&(o?s=0:s=e),this.clockwise===!0&&!o&&(s===e?s=-e:s=s-e);const h=this.startAngle+t*s;let c=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=c-this.center.x,x=g-this.center.y;c=S*b-x*f+this.center.x,g=S*f+x*b+this.center.y}return new Mt(c,g)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.majorAxisRadius=t.majorAxisRadius,this.minorAxisRadius=t.minorAxisRadius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.clockwise=t.clockwise,this.rotation=t.rotation,this}clone(){return new bi(this.center,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle,this.clockwise,this.rotation)}}class xi extends Ps{constructor(t,e,s,o,h,c=0,g=re){super(),this.center=t,this.normal=e,this.majorAxis=s,this.majorAxisRadius=o,this.minorAxisRadius=h;const b=Math.abs(g-c);Math.abs(b-re)<1e-10||Math.abs(b-2*re)<1e-10?(this.startAngle=0,this.endAngle=re):(this.startAngle=c,this.endAngle=g)}get center(){return this._center}set center(t){this._center=new X(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw Re.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw Re.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=St.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==re?t:St.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){const t=this.endAngle-this.startAngle;return Math.abs(t-re)<1e-10?re:St.normalizeAngle(t)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}get clockwise(){return this.deltaAngle<=0}get normal(){return this._normal}set normal(t){this._normal=new $(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get majorAxis(){return this._majorAxis}set majorAxis(t){this._majorAxis=new $(t.x,t.y,t.z),this._majorAxis.normalize(),this._boundingBoxNeedsUpdate=!0}get minorAxis(){return new $().crossVectors(this.normal,this.majorAxis).normalize()}get startPoint(){return this.getPointAtAngle(this._startAngle)}get endPoint(){return this.getPointAtAngle(this._endAngle)}get isCircular(){return ma.equal(this.majorAxisRadius,this.minorAxisRadius)}get length(){if(this.isCircular)return this.majorAxisRadius*Math.abs(this.deltaAngle);const t=1e3,e=this.deltaAngle/t;let s=0,o=this.getPointAtAngle(this.startAngle);for(let h=1;h<=t;h++){const c=this.startAngle+h*e,g=this.getPointAtAngle(c),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($.X_AXIS)||this.majorAxis.equals($.Y_AXIS)||this.majorAxis.isParallelTo($.X_AXIS)||this.majorAxis.isParallelTo($.Y_AXIS)){const t=[this.startAngle,this.endAngle];for(let b=0;b<2*Math.PI;b+=Math.PI/2)St.isBetweenAngle(b,this.startAngle,this.endAngle)&&t.push(b);let e=1/0,s=1/0,o=1/0,h=-1/0,c=-1/0,g=-1/0;for(const b of t){const f=this.getPointAtAngle(b);f.x<e&&(e=f.x),f.y<s&&(s=f.y),f.z<o&&(o=f.z),f.x>h&&(h=f.x),f.y>c&&(c=f.y),f.z>g&&(g=f.z)}return new Dt({x:e,y:s,z:o},{x:h,y:c,z:g})}else{let t=1/0,e=1/0,s=1/0,o=-1/0,h=-1/0,c=-1/0;for(let g=0;g<=100;g++){const b=this.startAngle+this.deltaAngle*(g/100),f=this.getPointAtAngle(b);t=Math.min(t,f.x),e=Math.min(e,f.y),s=Math.min(s,f.z),o=Math.max(o,f.x),h=Math.max(h,f.y),c=Math.max(c,f.z)}return new Dt({x:t,y:e,z:s},{x:o,y:h,z:c})}}get closed(){return this.deltaAngle==0}getPoints(t=100){const e=[];let s=this.deltaAngle,o=this.startAngle;this.closed&&(s=re,o=0);for(let h=0;h<=t;h++){const c=o+s*(h/t),g=this.getPointAtAngle(c);e.push(g)}return e}getPointAtAngle(t){const e=Math.cos(t),s=Math.sin(t),o=this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(s),h=this.majorAxis.clone().multiplyScalar(e*this.majorAxisRadius).add(o);return new X(this.center.x+h.x,this.center.y+h.y,this.center.z+h.z)}contains(t){const e=new $(t).sub(this.center),s=e.dot(this.majorAxis),o=e.dot(this.minorAxis),h=s/this.majorAxisRadius,c=o/this.minorAxisRadius;return h*h+c*c<=1}transform(t){return this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.normal=t.normal,this.majorAxis=t.majorAxis,this.majorAxisRadius=t.majorAxisRadius,this.minorAxisRadius=t.minorAxisRadius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this._boundingBoxNeedsUpdate=!0,this}clone(){return new xi(this.center,this.normal,this.majorAxis,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle)}get plane(){const t=new $(this.center).distanceTo(da);return new As(this.normal,t)}}class Ss extends Tn{constructor(t=null,e=!1){super(),this._vertices=t||new Array,this._closed=e}get numberOfVertices(){return this._vertices.length}get closed(){return this._closed}get startPoint(){if(this.numberOfVertices>0){const t=this._vertices[0];return new Mt(t.x,t.y)}throw new Error("Start point does not exist in an empty polyline.")}get endPoint(){const t=this.numberOfVertices;if(t>0)if(this.closed){const e=this._vertices[0];return new Mt(e.x,e.y)}else{const e=this._vertices[t-1];return new Mt(e.x,e.y)}throw new Error("End point does not exist in an empty polyline.")}get length(){let t=0;const e=this._vertices.length;for(let s=0;s<e;++s){const o=this._vertices[s];let h=null;if(s<e-1?h=this._vertices[s+1]:s==e-1&&this.closed&&(h=this._vertices[0]),h)if(o.bulge){const c=new kn(o,h,o.bulge);t+=c.length}else t+=new Mt(o.x,o.y).distanceTo(h)}return t}set closed(t){this._closed=t,this._boundingBoxNeedsUpdate=!0}addVertexAt(t,e){t<=0?this._vertices.unshift(e):this._vertices.splice(t,0,e),this._boundingBoxNeedsUpdate=!0}getPointAt(t){const e=this._vertices[t];return new Mt(e.x,e.y)}calculateBoundingBox(){const t=this.getPoints(100);return new _e().setFromPoints(t)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}getPoints3d(t,e){const s=[];return this.getPoints(t).forEach(o=>s.push(new X().set(o.x,o.y,e))),s}getPoints(t){const e=[],s=this._vertices.length;for(let o=0;o<s;++o){const h=this._vertices[o];if(h.bulge){let c=null;if(o<s-1?c=this._vertices[o+1]:o==s-1&&this.closed&&(c=this._vertices[0]),c){const g=new kn(h,c,h.bulge).getPoints(t),b=g.length;for(let f=0;f<b;++f){const S=g[f];e.push(new Mt(S.x,S.y))}}}else e.push(new Mt(h.x,h.y)),o==s-1&&this.closed&&e.push(e[0])}return e}}class wi extends Tn{constructor(t,e){super(),this._start=new Mt(t),this._end=new Mt(e)}get startPoint(){return this._start}set startPoint(t){this._start.copy(t),this._boundingBoxNeedsUpdate=!0}get endPoint(){return this._end}set endPoint(t){this._end.copy(t),this._boundingBoxNeedsUpdate=!0}getPoints(){return[this.startPoint,this.endPoint]}get length(){return this.startPoint.distanceTo(this.endPoint)}calculateBoundingBox(){const t=new Mt(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y)),e=new Mt(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y));return new _e(t,e)}transform(t){return this._start.applyMatrix2d(t),this._end.applyMatrix2d(t),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new wi(this._start.clone(),this._end.clone())}}class xh extends Tn{constructor(t=[]){super(),this._curves=t}get curves(){return this._curves}add(t){this._curves.push(t),this._boundingBoxNeedsUpdate=!0}get numberOfEdges(){return this._curves.length}get startPoint(){if(this._curves.length>0){const t=this._curves[0].startPoint;return new Mt(t.x,t.y)}throw new Error("Start point does not exist in an empty loop.")}get endPoint(){return this.startPoint}get length(){let t=0;return this._curves.forEach(e=>{t+=e.length}),t}calculateBoundingBox(){const t=this.getPoints(100),e=new _e;return e.setFromPoints(t),e}transform(t){return this._boundingBoxNeedsUpdate=!0,this}get closed(){return!0}getPoints(t){const e=[];return this.curves.forEach(s=>{s.getPoints(t).forEach(o=>{e.push(new Mt(o.x,o.y))})}),e}}function nd(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var wh={exports:{}};(function(a,t){(function(e){a.exports=e()})(function(){var e={},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 c=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={},k=function(){return kt.__string_rec(this,"")};function M(r,n){function i(){}i.prototype=r;var l=new i;for(var u in n)l[u]=n[u];return n.toString!==Object.prototype.toString&&(l.toString=n.toString),l}var D=function(){};x.HxOverrides=D,D.__name__=["HxOverrides"],D.strDate=function(r){var n=r.length;switch(n){case 8:var i=r.split(":"),l=new Date;return l.setTime(0),l.setUTCHours(i[0]),l.setUTCMinutes(i[1]),l.setUTCSeconds(i[2]),l;case 10:var u=r.split("-");return new Date(u[0],u[1]-1,u[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)}},D.cca=function(r,n){var i=r.charCodeAt(n);if(i==i)return i},D.substr=function(r,n,i){return n!=null&&n!=0&&i!=null&&i<0?"":(i==null&&(i=r.length),n<0?(n=r.length+n,n<0&&(n=0)):i<0&&(i=r.length+i-n),r.substr(n,i))},D.iter=function(r){return{cur:0,arr:r,hasNext:function(){return this.cur<this.arr.length},next:function(){return this.arr[this.cur++]}}};var z=function(){};x.Lambda=z,z.__name__=["Lambda"],z.fold=function(r,n,i){for(var l=He(r)();l.hasNext();){var u=l.next();i=n(u,i)}return i};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(i){return i instanceof Q&&(i=i.val),null}},B.callMethod=function(r,n,i){return n.apply(r,i)},B.fields=function(r){var n=[];if(r!=null){var i=Object.prototype.hasOwnProperty;for(var l in r)l!="__id__"&&l!="hx__closures__"&&i.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 gt=function(){};x.Std=gt,gt.__name__=["Std"],gt.string=function(r){return kt.__string_rec(r,"")},gt.parseFloat=function(r){return parseFloat(r)};var ft=function(){this.b=""};x.StringBuf=ft,ft.__name__=["StringBuf"],ft.prototype={add:function(r){this.b+=gt.string(r)},__class__:ft};var ut=function(){};x.StringTools=ut,ut.__name__=["StringTools"],ut.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=k,W.TNull.__enum__=W,W.TInt=["TInt",1],W.TInt.toString=k,W.TInt.__enum__=W,W.TFloat=["TFloat",2],W.TFloat.toString=k,W.TFloat.__enum__=W,W.TBool=["TBool",3],W.TBool.toString=k,W.TBool.__enum__=W,W.TObject=["TObject",4],W.TObject.toString=k,W.TObject.__enum__=W,W.TFunction=["TFunction",5],W.TFunction.toString=k,W.TFunction.__enum__=W,W.TClass=function(r){var n=["TClass",6,r];return n.__enum__=W,n.toString=k,n},W.TEnum=function(r){var n=["TEnum",7,r];return n.__enum__=W,n.toString=k,n},W.TUnknown=["TUnknown",8],W.TUnknown.toString=k,W.TUnknown.__enum__=W;var mt=function(){};x.Type=mt,mt.__name__=["Type"],mt.getClassName=function(r){var n=r.__name__;return n==null?null:n.join(".")},mt.getEnumName=function(r){var n=r.__ename__;return n.join(".")},mt.resolveClass=function(r){var n=x[r];return n==null||!n.__name__?null:n},mt.resolveEnum=function(r){var n=x[r];return n==null||!n.__ename__?null:n},mt.createEmptyInstance=function(r){function n(){}return n.prototype=r.prototype,new n},mt.createEnum=function(r,n,i){var l=B.field(r,n);if(l==null)throw new Q("No such constructor "+n);if(B.isFunction(l)){if(i==null)throw new Q("Constructor "+n+" need parameters");return B.callMethod(r,l,i)}if(i!=null&&i.length!=0)throw new Q("Constructor "+n+" does not need parameters");return l},mt.getEnumConstructs=function(r){var n=r.__constructs__;return n.slice()},mt.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 i=r.__enum__;if(i!=null)return W.TEnum(i);var l=kt.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 lt=function(){};x["haxe.IMap"]=lt,lt.__name__=["haxe","IMap"];var Wt=function(r,n){this.high=r,this.low=n};x["haxe._Int64.___Int64"]=Wt,Wt.__name__=["haxe","_Int64","___Int64"],Wt.prototype={__class__:Wt};var Ht=function(){this.buf=new ft,this.cache=[],this.useCache=Ht.USE_CACHE,this.useEnumIndex=Ht.USE_ENUM_INDEX,this.shash=new me,this.scount=0};x["haxe.Serializer"]=Ht,Ht.__name__=["haxe","Serializer"],Ht.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,i=0,l=this.cache.length;i<l;){var u=i++,d=this.cache[u];if(typeof d==n&&d==r)return this.buf.b+="r",u==null?this.buf.b+="null":this.buf.b+=""+u,!0}return this.cache.push(r),!1},serializeFields:function(r){for(var n=0,i=B.fields(r);n<i.length;){var l=i[n];++n,this.serializeString(l),this.serialize(B.field(r,l))}this.buf.b+="g"},serialize:function(r){{var n=mt.typeof(r);switch(n[1]){case 0:this.buf.b+="n";break;case 1:var i=r;if(i==0){this.buf.b+="z";return}this.buf.b+="i",i==null?this.buf.b+="null":this.buf.b+=""+i;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 u=n[2];if(u==String){this.serializeString(r);return}if(this.useCache&&this.serializeRef(r))return;switch(u){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 E=r;this.buf.b+="v",this.buf.add(E.getTime());break;case me:this.buf.b+="b";for(var T=r,L=T.keys();L.hasNext();){var N=L.next();this.serializeString(N),this.serialize(ki[N]!=null?T.getReserved(N):T.h[N])}this.buf.b+="h";break;case bt: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 Lt:this.buf.b+="M";for(var V=r,H=V.keys();H.hasNext();){var J=H.next(),G=B.field(J,"__id__");B.deleteField(J,"__id__"),this.serialize(J),J.__id__=G,this.serialize(V.h[J.__id__])}this.buf.b+="h";break;case Ie:for(var j=r,Y=0,tt=j.length-2,et=new ft,st=Ht.BASE64;Y<tt;){var ot=j.get(Y++),it=j.get(Y++),ht=j.get(Y++);et.add(st.charAt(ot>>2)),et.add(st.charAt((ot<<4|it>>4)&63)),et.add(st.charAt((it<<2|ht>>6)&63)),et.add(st.charAt(ht&63))}if(Y==tt){var nt=j.get(Y++),ct=j.get(Y++);et.add(st.charAt(nt>>2)),et.add(st.charAt((nt<<4|ct>>4)&63)),et.add(st.charAt(ct<<2&63))}else if(Y==tt+1){var q=j.get(Y++);et.add(st.charAt(q>>2)),et.add(st.charAt(q<<4&63))}var pt=et.b;this.buf.b+="s",pt.length==null?this.buf.b+="null":this.buf.b+=""+pt.length,this.buf.b+=":",pt==null?this.buf.b+="null":this.buf.b+=""+pt;break;default:this.useCache&&this.cache.pop(),r.hxSerialize!=null?(this.buf.b+="C",this.serializeString(mt.getClassName(u)),this.useCache&&this.cache.push(r),r.hxSerialize(this),this.buf.b+="g"):(this.buf.b+="c",this.serializeString(mt.getClassName(u)),this.useCache&&this.cache.push(r),this.serializeFields(r))}break;case 4:if(kt.__instanceof(r,eo)){var At=mt.getClassName(r);this.buf.b+="A",this.serializeString(At)}else if(kt.__instanceof(r,ro))this.buf.b+="B",this.serializeString(mt.getEnumName(r));else{if(this.useCache&&this.serializeRef(r))return;this.buf.b+="o",this.serializeFields(r)}break;case 7:var Vt=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(mt.getEnumName(Vt)),this.useEnumIndex?(this.buf.b+=":",this.buf.b+=gt.string(r[1])):this.serializeString(r[0]),this.buf.b+=":";var qt=r.length;this.buf.b+=gt.string(qt-2);for(var Rt=2;Rt<qt;){var Yt=Rt++;this.serialize(r[Yt])}this.useCache&&this.cache.push(r);break;case 5:throw new Q("Cannot serialize function");default:throw new Q("Cannot serialize "+gt.string(r))}}},__class__:Ht};var Ut=function(r){this.buf=r,this.length=r.length,this.pos=0,this.scache=[],this.cache=[];var n=Ut.DEFAULT_RESOLVER;n==null&&(n=mt,Ut.DEFAULT_RESOLVER=n),this.setResolver(n)};x["haxe.Unserializer"]=Ut,Ut.__name__=["haxe","Unserializer"],Ut.initCodes=function(){for(var r=[],n=0,i=Ut.BASE64.length;n<i;){var l=n++;r[Ut.BASE64.charCodeAt(l)]=l}return r},Ut.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,i=this.pos;;){var l=this.buf.charCodeAt(this.pos);if(l!=l)break;if(l==45){if(this.pos!=i)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 gt.parseFloat(D.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 i=this.unserialize();r[n]=i}this.pos++},unserializeEnum:function(r,n){if(this.get(this.pos++)!=58)throw new Q("Invalid enum format");var i=this.readDigits();if(i==0)return mt.createEnum(r,n);for(var l=[];i-- >0;)l.push(this.unserialize());return mt.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 i=D.substr(this.buf,this.pos,n);return this.pos+=n,i=decodeURIComponent(i.split("+").join(" ")),this.scache.push(i),i;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 u=this.buf.charCodeAt(this.pos);if(u==104){this.pos++;break}if(u==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=mt.createEmptyInstance(P);return this.cache.push(A),this.unserializeObject(A),A;case 119:var I=this.unserialize(),E=this.resolver.resolveEnum(I);if(E==null)throw new Q("Enum not found "+I);var T=this.unserializeEnum(E,this.unserialize());return this.cache.push(T),T;case 106:var L=this.unserialize(),N=this.resolver.resolveEnum(L);if(N==null)throw new Q("Enum not found "+L);this.pos++;var R=this.readDigits(),O=mt.getEnumConstructs(N)[R];if(O==null)throw new Q("Unknown enum index "+L+"@"+R);var F=this.unserializeEnum(N,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 H=new me;for(this.cache.push(H),this.buf;this.buf.charCodeAt(this.pos)!=104;){var J=this.unserialize();H.set(J,this.unserialize())}return this.pos++,H;case 113:var G=new bt;this.cache.push(G),this.buf;for(var j=this.get(this.pos++);j==58;){var Y=this.readDigits();G.set(Y,this.unserialize()),j=this.get(this.pos++)}if(j!=104)throw new Q("Invalid IntMap format");return G;case 77:var tt=new Lt;for(this.cache.push(tt),this.buf;this.buf.charCodeAt(this.pos)!=104;){var et=this.unserialize();tt.set(et,this.unserialize())}return this.pos++,tt;case 118:var st;if(this.buf.charCodeAt(this.pos)>=48&&this.buf.charCodeAt(this.pos)<=57&&this.buf.charCodeAt(this.pos+1)>=48&&this.buf.charCodeAt(this.pos+1)<=57&&this.buf.charCodeAt(this.pos+2)>=48&&this.buf.charCodeAt(this.pos+2)<=57&&this.buf.charCodeAt(this.pos+3)>=48&&this.buf.charCodeAt(this.pos+3)<=57&&this.buf.charCodeAt(this.pos+4)==45){var ot=D.substr(this.buf,this.pos,19);st=D.strDate(ot),this.pos+=19}else{var it=this.readFloat(),ht=new Date;ht.setTime(it),st=ht}return this.cache.push(st),st;case 115:var nt=this.readDigits(),ct=this.buf;if(this.get(this.pos++)!=58||this.length-this.pos<nt)throw new Q("Invalid bytes length");var q=Ut.CODES;q==null&&(q=Ut.initCodes(),Ut.CODES=q);var pt=this.pos,At=nt&3,Vt;Vt=(nt>>2)*3+(At>=2?At-1:0);for(var qt=pt+(nt-At),Rt=Ie.alloc(Vt),Yt=0;pt<qt;){var Ae=q[ut.fastCodeAt(ct,pt++)],Ue=q[ut.fastCodeAt(ct,pt++)];Rt.set(Yt++,Ae<<2|Ue>>4);var ve=q[ut.fastCodeAt(ct,pt++)];Rt.set(Yt++,Ue<<4|ve>>2);var ge=q[ut.fastCodeAt(ct,pt++)];Rt.set(Yt++,ve<<6|ge)}if(At>=2){var Pe=q[ut.fastCodeAt(ct,pt++)],Te=q[ut.fastCodeAt(ct,pt++)];if(Rt.set(Yt++,Pe<<2|Te>>4),At==3){var qe=q[ut.fastCodeAt(ct,pt++)];Rt.set(Yt++,Te<<4|qe>>2)}}return this.pos+=nt,this.cache.push(Rt),Rt;case 67:var sr=this.unserialize(),Ye=this.resolver.resolveClass(sr);if(Ye==null)throw new Q("Class not found "+sr);var Ke=mt.createEmptyInstance(Ye);if(this.cache.push(Ke),Ke.hxUnserialize(this),this.get(this.pos++)!=103)throw new Q("Invalid custom data");return Ke;case 65:var Xe=this.unserialize(),hr=this.resolver.resolveClass(Xe);if(hr==null)throw new Q("Class not found "+Xe);return hr;case 66:var bn=this.unserialize(),Gr=this.resolver.resolveEnum(bn);if(Gr==null)throw new Q("Enum not found "+bn);return Gr}throw this.pos--,new Q("Invalid char "+this.buf.charAt(this.pos)+" at position "+this.pos)},__class__:Ut};var bt=function(){this.h={}};x["haxe.ds.IntMap"]=bt,bt.__name__=["haxe","ds","IntMap"],bt.__interfaces__=[lt],bt.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 D.iter(r)},__class__:bt};var Lt=function(){this.h={},this.h.__keys__={}};x["haxe.ds.ObjectMap"]=Lt,Lt.__name__=["haxe","ds","ObjectMap"],Lt.__interfaces__=[lt],Lt.prototype={set:function(r,n){var i=r.__id__||(r.__id__=++Lt.count);this.h[i]=n,this.h.__keys__[i]=r},keys:function(){var r=[];for(var n in this.h.__keys__)this.h.hasOwnProperty(n)&&r.push(this.h.__keys__[n]);return D.iter(r)},__class__:Lt};var de=x["haxe.ds.Option"]={__ename__:["haxe","ds","Option"],__constructs__:["Some","None"]};de.Some=function(r){var n=["Some",0,r];return n.__enum__=de,n.toString=k,n},de.None=["None",1],de.None.toString=k,de.None.__enum__=de;var me=function(){this.h={}};x["haxe.ds.StringMap"]=me,me.__name__=["haxe","ds","StringMap"],me.__interfaces__=[lt],me.prototype={set:function(r,n){ki[r]!=null?this.setReserved(r,n):this.h[r]=n},get:function(r){return ki[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 D.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__:me};var Ie=function(r){this.length=r.byteLength,this.b=new Ei(r),this.b.bufferValue=r,r.hxBytes=this,r.bytes=this.b};x["haxe.io.Bytes"]=Ie,Ie.__name__=["haxe","io","Bytes"],Ie.alloc=function(r){return new Ie(new Es(r))},Ie.prototype={get:function(r){return this.b[r]},set:function(r,n){this.b[r]=n&255},__class__:Ie};var Qt=x["haxe.io.Error"]={__ename__:["haxe","io","Error"],__constructs__:["Blocked","Overflow","OutsideBounds","Custom"]};Qt.Blocked=["Blocked",0],Qt.Blocked.toString=k,Qt.Blocked.__enum__=Qt,Qt.Overflow=["Overflow",1],Qt.Overflow.toString=k,Qt.Overflow.__enum__=Qt,Qt.OutsideBounds=["OutsideBounds",2],Qt.OutsideBounds.toString=k,Qt.OutsideBounds.__enum__=Qt,Qt.Custom=function(r){var n=["Custom",3,r];return n.__enum__=Qt,n.toString=k,n};var ae=function(){};x["haxe.io.FPHelper"]=ae,ae.__name__=["haxe","io","FPHelper"],ae.i32ToFloat=function(r){var n=1-(r>>>31<<1),i=r>>>23&255,l=r&8388607;return l==0&&i==0?0:n*(1+Math.pow(2,-23)*l)*Math.pow(2,i-127)},ae.floatToI32=function(r){if(r==0)return 0;var n;r<0?n=-r:n=r;var i=Math.floor(Math.log(n)/.6931471805599453);i<-127?i=-127:i>128&&(i=128);var l=Math.round((n/Math.pow(2,i)-1)*8388608)&8388607;return(r<0?-2147483648:0)|i+127<<23|l},ae.i64ToDouble=function(r,n){var i=1-(n>>>31<<1),l=(n>>20&2047)-1023,u=(n&1048575)*4294967296+(r>>>31)*2147483648+(r&2147483647);return u==0&&l==-1023?0:i*(1+Math.pow(2,-52)*u)*Math.pow(2,l)},ae.doubleToI64=function(r){var n=ae.i64tmp;if(r==0)n.low=0,n.high=0;else{var i;r<0?i=-r:i=r;var l=Math.floor(Math.log(i)/.6931471805599453),u,d=(i/Math.pow(2,l)-1)*4503599627370496;u=Math.round(d);var p=u|0,_=u/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 kt=function(){};x["js.Boot"]=kt,kt.__name__=["js","Boot"],kt.getClass=function(r){if(r instanceof Array&&r.__enum__==null)return Array;var n=r.__class__;if(n!=null)return n;var i=kt.__nativeClassName(r);return i!=null?kt.__resolveNativeClass(i):null},kt.__string_rec=function(r,n){if(r==null)return"null";if(n.length>=5)return"<...>";var i=typeof r;switch(i=="function"&&(r.__name__||r.__ename__)&&(i="object"),i){case"object":if(r instanceof Array){if(r.__enum__){if(r.length==2)return r[0];var l=r[0]+"(";n+=" ";for(var u=2,d=r.length;u<d;){var p=u++;p!=2?l+=","+kt.__string_rec(r[p],n):l+=kt.__string_rec(r[p],n)}return l+")"}var _=r.length,v="[";n+=" ";for(var w=0;w<_;){var P=w++;v+=(P>0?",":"")+kt.__string_rec(r[P],n)}return v+="]",v}var A;try{A=r.toString}catch(N){return N instanceof Q&&(N=N.val),"???"}if(A!=null&&A!=Object.toString&&typeof A=="function"){var I=r.toString();if(I!="[object Object]")return I}var E=null,T=`{
3
3
  `;n+=" ";var L=r.hasOwnProperty!=null;for(var E in r)L&&!r.hasOwnProperty(E)||E=="prototype"||E=="__class__"||E=="__super__"||E=="__interfaces__"||E=="__properties__"||(T.length!=2&&(T+=`,
4
4
  `),T+=n+E+" : "+kt.__string_rec(r[E],n));return n=n.substring(1),T+=`
5
- `+n+"}",T;case"function":return"<function>";case"string":return r;default:return String(r)}},kt.__interfLoop=function(r,n){if(r==null)return!1;if(r==n)return!0;var i=r.__interfaces__;if(i!=null)for(var l=0,u=i.length;l<u;){var d=l++,p=i[d];if(p==n||kt.__interfLoop(p,n))return!0}return kt.__interfLoop(r.__super__,n)},kt.__instanceof=function(r,n){if(n==null)return!1;switch(n){case eu:return(r|0)===r;case Ja:return typeof r=="number";case to:return typeof r=="boolean";case String:return typeof r=="string";case Array:return r instanceof Array&&r.__enum__==null;case ru:return!0;default:if(r!=null){if(typeof n=="function"){if(r instanceof n||kt.__interfLoop(kt.getClass(r),n))return!0}else if(typeof n=="object"&&kt.__isNativeObj(n)&&r instanceof n)return!0}else return!1;return n==eo&&r.__name__!=null||n==ro&&r.__ename__!=null?!0:r.__enum__==n}},kt.__nativeClassName=function(r){var n=kt.__toStr.call(r).slice(8,-1);return n=="Object"||n=="Function"||n=="Math"||n=="JSON"?null:n},kt.__isNativeObj=function(r){return kt.__nativeClassName(r)!=null},kt.__resolveNativeClass=function(r){return S[r]};var oe=function(r){if(r instanceof Array&&r.__enum__==null)this.a=r,this.byteLength=r.length;else{var n=r;this.a=[];for(var i=0;i<n;){var l=i++;this.a[l]=0}this.byteLength=n}};x["js.html.compat.ArrayBuffer"]=oe,oe.__name__=["js","html","compat","ArrayBuffer"],oe.sliceImpl=function(r,n){var i=new Ei(this,r,n==null?null:n-r),l=new Es(i.byteLength),u=new Ei(l);return u.set(i),l},oe.prototype={slice:function(r,n){return new oe(this.a.slice(r,n))},__class__:oe};var ar=function(r,n,i){if(this.buf=r,n==null?this.offset=0:this.offset=n,i==null?this.length=r.byteLength-this.offset:this.length=i,this.offset<0||this.length<0||this.offset+this.length>r.byteLength)throw new Q(Qt.OutsideBounds)};x["js.html.compat.DataView"]=ar,ar.__name__=["js","html","compat","DataView"],ar.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 i=this.getUint16(r,n);return i>=32768?i-65536:i},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 i=this.offset+r,l=this.buf.a[i++],u=this.buf.a[i++],d=this.buf.a[i++],p=this.buf.a[i++];return n?l|u<<8|d<<16|p<<24:p|d<<8|u<<16|l<<24},getUint32:function(r,n){var i=this.getInt32(r,n);return i<0?i+4294967296:i},getFloat32:function(r,n){return ae.i32ToFloat(this.getInt32(r,n))},getFloat64:function(r,n){var i=this.getInt32(r,n),l=this.getInt32(r+4,n);return ae.i64ToDouble(n?i:l,n?l:i)},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,i){this.setUint16(r,n<0?n+65536:n,i)},setUint16:function(r,n,i){var l=r+this.offset;i?(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,i){this.setUint32(r,n,i)},setUint32:function(r,n,i){var l=r+this.offset;i?(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,i){this.setUint32(r,ae.floatToI32(n),i)},setFloat64:function(r,n,i){var l=ae.doubleToI64(n);i?(this.setUint32(r,l.low),this.setUint32(r,l.high)):(this.setUint32(r,l.high),this.setUint32(r,l.low))},__class__:ar};var tr=function(){};x["js.html.compat.Uint8Array"]=tr,tr.__name__=["js","html","compat","Uint8Array"],tr._new=function(r,n,i){var l;if(typeof r=="number"){l=[];for(var u=0;u<r;){var d=u++;l[d]=0}l.byteLength=l.length,l.byteOffset=0,l.buffer=new oe(l)}else if(kt.__instanceof(r,oe)){var p=r;n==null&&(n=0),i==null&&(i=p.byteLength-n),n==0?l=p.a:l=p.a.slice(n,n+i),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 oe(l);else throw new Q("TODO "+gt.string(r));return l.subarray=tr._subarray,l.set=tr._set,l},tr._set=function(r,n){var i=this;if(kt.__instanceof(r.buffer,oe)){var l=r;if(r.byteLength+n>i.byteLength)throw new Q("set() outside of range");for(var u=0,d=r.byteLength;u<d;){var p=u++;i[p+n]=l[p]}}else if(r instanceof Array&&r.__enum__==null){var _=r;if(_.length+n>i.byteLength)throw new Q("set() outside of range");for(var v=0,w=_.length;v<w;){var P=v++;i[P+n]=_[P]}}else throw new Q("TODO")},tr._subarray=function(r,n){var i=this,l=tr._new(i.slice(r,n));return l.byteOffset=r,l};var It=function(r){this._resolved=!1,this._pending=!1,this._errorPending=!1,this._fulfilled=!1,this._update=[],this._error=[],this._errored=!1,r!=null&&It.link(r,this,function(n){return n})};x["promhx.base.AsyncBase"]=It,It.__name__=["promhx","base","AsyncBase"],It.link=function(r,n,i){r._update.push({async:n,linkf:function(l){n.handleResolve(i(l))}}),It.immediateLinkUpdate(r,n,i)},It.immediateLinkUpdate=function(r,n,i){if(r._errored&&!r._errorPending&&!(r._error.length>0)&&n.handleError(r._errorVal),r._resolved&&!r._pending)try{n.handleResolve(i(r._val))}catch(l){l instanceof Q&&(l=l.val),n.handleError(l)}},It.linkAll=function(r,n){for(var i=function(d,p,_){if(d.length==0||It.allFulfilled(d)){for(var v,w=[],P=He(r)();P.hasNext();){var A=P.next();w.push(A==p?_:A._val)}v=w,n.handleResolve(v)}},l=He(r)();l.hasNext();){var u=l.next();u._update.push({async:n,linkf:function(d,p,_){return function(v){d(p,_,v)}}(i,function(d){for(var p,_=[],v=He(r)();v.hasNext();){var w=v.next();w!=u&&_.push(w)}return p=_,p}(),u)})}It.allFulfilled(r)&&n.handleResolve(function(d){for(var p,_=[],v=He(r)();v.hasNext();){var w=v.next();_.push(w._val)}return p=_,p}())},It.pipeLink=function(r,n,i){var l=!1,u=function(d){if(!l){l=!0;var p=i(d);p._update.push({async:n,linkf:Me(n,n.handleResolve)}),It.immediateLinkUpdate(p,n,function(_){return _})}};if(r._update.push({async:n,linkf:u}),r._resolved&&!r._pending)try{u(r._val)}catch(d){d instanceof Q&&(d=d.val),n.handleError(d)}},It.allResolved=function(r){for(var n=He(r)();n.hasNext();){var i=n.next();if(!i._resolved)return!1}return!0},It.allFulfilled=function(r){for(var n=He(r)();n.hasNext();){var i=n.next();if(!i._fulfilled)return!1}return!0},It.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?wt.enqueue(function(i,l){return function(){i(l)}}(Me(this,this._resolve),r)):(this._resolved=!0,this._pending=!0,wt.queue.add(function(){n._val=r;for(var i=0,l=n._update;i<l.length;){var u=l[i];++i;try{u.linkf(r)}catch(d){d instanceof Q&&(d=d.val),u.async.handleError(d)}}n._fulfilled=!0,n._pending=!1}),wt.continueOnNextLoop())},handleError:function(r){this._handleError(r)},_handleError:function(r){var n=this,i=function(l){if(n._error.length>0)for(var u=0,d=n._error;u<d.length;){var p=d[u];++u,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,wt.queue.add(function(){if(n._errorMap!=null)try{n._resolve(n._errorMap(r))}catch(l){l instanceof Q&&(l=l.val),i(l)}else i(r)}),wt.continueOnNextLoop())},then:function(r){var n=new It(null);return It.link(this,n,r),n},unlink:function(r){var n=this;wt.queue.add(function(){n._update=n._update.filter(function(i){return i.async!=r})}),wt.continueOnNextLoop()},isLinked:function(r){for(var n=!1,i=0,l=this._update;i<l.length;){var u=l[i];if(++i,u.async==r)return!0}return n},__class__:It};var hn=f.promhx.Deferred=function(){It.call(this)};x["promhx.Deferred"]=hn,hn.__name__=["promhx","Deferred"],hn.__super__=It,hn.prototype=M(It.prototype,{resolve:function(r){this.handleResolve(r)},throwError:function(r){this.handleError(r)},promise:function(){return new pe(this)},stream:function(){return new jt(this)},publicStream:function(){return new Ar(this)},__class__:hn});var pe=f.promhx.Promise=function(r){It.call(this,r),this._rejected=!1};x["promhx.Promise"]=pe,pe.__name__=["promhx","Promise"],pe.whenAll=function(r){var n=new pe(null);return It.linkAll(r,n),n},pe.promise=function(r){var n=new pe;return n.handleResolve(r),n},pe.__super__=It,pe.prototype=M(It.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(un.AlreadyResolved(n))}this._resolve(r)},then:function(r){var n=new pe(null);return It.link(this,n,r),n},unlink:function(r){var n=this;wt.queue.add(function(){if(n._fulfilled)n._update=n._update.filter(function(l){return l.async!=r});else{var i="Downstream Promise is not fullfilled";n.handleError(un.DownstreamNotFullfilled(i))}}),wt.continueOnNextLoop()},handleError:function(r){this._rejected=!0,this._handleError(r)},pipe:function(r){var n=new pe(null);return It.pipeLink(this,n,r),n},errorPipe:function(r){var n=new pe;return this.catchError(function(i){var l=r(i);l.then(Me(n,n._resolve))}),this.then(Me(n,n._resolve)),n},__class__:pe});var jt=f.promhx.Stream=function(r){It.call(this,r),this._end_promise=new pe};x["promhx.Stream"]=jt,jt.__name__=["promhx","Stream"],jt.foreach=function(r){for(var n=new jt(null),i=He(r)();i.hasNext();){var l=i.next();n.handleResolve(l)}return n.end(),n},jt.wheneverAll=function(r){var n=new jt(null);return It.linkAll(r,n),n},jt.concatAll=function(r){for(var n=new jt(null),i=He(r)();i.hasNext();){var l=i.next();n.concat(l)}return n},jt.mergeAll=function(r){for(var n=new jt(null),i=He(r)();i.hasNext();){var l=i.next();n.merge(l)}return n},jt.stream=function(r){var n=new jt(null);return n.handleResolve(r),n},jt.__super__=It,jt.prototype=M(It.prototype,{then:function(r){var n=new jt(null);return It.link(this,n,r),this._end_promise._update.push({async:n._end_promise,linkf:function(i){n.end()}}),n},detachStream:function(r){for(var n=[],i=!1,l=0,u=this._update;l<u.length;){var d=u[l];++l,d.async==r?(this._end_promise._update=this._end_promise._update.filter(function(p){return p.async!=r._end_promise}),i=!0):n.push(d)}return this._update=n,i},first:function(){var r=new pe(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 jt(null);return It.pipeLink(this,n,r),this._end_promise.then(function(i){n.end()}),n},errorPipe:function(r){var n=new jt(null);return this.catchError(function(i){var l=r(i);l.then(Me(n,n._resolve)),l._end_promise.then((Ii=n._end_promise,Me(Ii,Ii._resolve)))}),this.then(Me(n,n._resolve)),this._end_promise.then(function(i){n.end()}),n},handleEnd:function(){if(this._pending)wt.queue.add(Me(this,this.handleEnd)),wt.continueOnNextLoop();else{if(this._end_promise._resolved)return;this._end=!0;var r;this._resolved?r=de.Some(this._val):r=de.None,this._end_promise.handleResolve(r),this._update=[],this._error=[]}},end:function(){return wt.queue.add(Me(this,this.handleEnd)),wt.continueOnNextLoop(),this},endThen:function(r){return this._end_promise.then(r)},filter:function(r){var n=new jt(null);return this._update.push({async:n,linkf:function(i){r(i)&&n.handleResolve(i)}}),It.immediateLinkUpdate(this,n,function(i){return i}),n},concat:function(r){var n=new jt(null);return this._update.push({async:n,linkf:Me(n,n.handleResolve)}),It.immediateLinkUpdate(this,n,function(i){return i}),this._end_promise.then(function(i){r.pipe(function(l){return n.handleResolve(l),n}),r._end_promise.then(function(l){n.end()})}),n},merge:function(r){var n=new jt(null);return this._update.push({async:n,linkf:Me(n,n.handleResolve)}),r._update.push({async:n,linkf:Me(n,n.handleResolve)}),It.immediateLinkUpdate(this,n,function(i){return i}),It.immediateLinkUpdate(r,n,function(i){return i}),n},__class__:jt});var Ar=f.promhx.PublicStream=function(r){jt.call(this,r)};x["promhx.PublicStream"]=Ar,Ar.__name__=["promhx","PublicStream"],Ar.publicstream=function(r){var n=new Ar(null);return n.handleResolve(r),n},Ar.__super__=jt,Ar.prototype=M(jt.prototype,{resolve:function(r){this.handleResolve(r)},throwError:function(r){this.handleError(r)},update:function(r){this.handleResolve(r)},__class__:Ar});var wt=function(){};x["promhx.base.EventLoop"]=wt,wt.__name__=["promhx","base","EventLoop"],wt.enqueue=function(r){wt.queue.add(r),wt.continueOnNextLoop()},wt.set_nextLoop=function(r){if(wt.nextLoop!=null)throw new Q("nextLoop has already been set");return wt.nextLoop=r,wt.nextLoop},wt.queueEmpty=function(){return wt.queue.isEmpty()},wt.finish=function(r){r==null&&(r=1e3);for(var n=null;r-- >0&&(n=wt.queue.pop())!=null;)n();return wt.queue.isEmpty()},wt.clear=function(){wt.queue=new U},wt.f=function(){var r=wt.queue.pop();r!=null&&r(),wt.queue.isEmpty()||wt.continueOnNextLoop()},wt.continueOnNextLoop=function(){wt.nextLoop!=null?wt.nextLoop(wt.f):setImmediate(wt.f)};var un=x["promhx.error.PromiseError"]={__ename__:["promhx","error","PromiseError"],__constructs__:["AlreadyResolved","DownstreamNotFullfilled"]};un.AlreadyResolved=function(r){var n=["AlreadyResolved",0,r];return n.__enum__=un,n.toString=k,n},un.DownstreamNotFullfilled=function(r){var n=["DownstreamNotFullfilled",1,r];return n.__enum__=un,n.toString=k,n};var Is=function(){};x["verb.Verb"]=Is,Is.__name__=["verb","Verb"],Is.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,i,l){r.splice(n,i),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 i=[r.pop()];r.length>0;){for(var l=r.pop(),u=!0,d=0;d<i.length;){var p=i[d];if(++d,n(l,p)){u=!1;break}}u&&i.push(l)}return i};var zt=function(){};x["verb.core.Binomial"]=zt,zt.__name__=["verb","core","Binomial"],zt.get=function(r,n){if(n==0)return 1;if(r==0||n>r)return 0;if(n>r-n&&(n=r-n),zt.memo_exists(r,n))return zt.get_memo(r,n);for(var i=1,l=r,u=1,d=n+1;u<d;){var p=u++;if(zt.memo_exists(l,p)){r--,i=zt.get_memo(l,p);continue}i*=r--,i/=p,zt.memoize(l,p,i)}return i},zt.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 i=1,l=1,u=n+1;l<u;){var d=l++;i*=r--,i/=d}return i},zt.memo_exists=function(r,n){return zt.memo.h.hasOwnProperty(r)&&zt.memo.h[r].h.hasOwnProperty(n)},zt.get_memo=function(r,n){return zt.memo.h[r].h[n]},zt.memoize=function(r,n,i){zt.memo.h.hasOwnProperty(r)||zt.memo.set(r,new bt),zt.memo.h[r].h[n]=i};var ke=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"]=ke,ke.__name__=["verb","core","BoundingBox"],ke.intervalsOverlap=function(r,n,i,l,u){u==null&&(u=-1);var d;u<-.5?d=rt.TOLERANCE:d=u;var p=Math.min(r,n)-d,_=Math.max(r,n)+d,v=Math.min(i,l)-d,w=Math.max(i,l)+d;return p>=v&&p<=w||_>=v&&_<=w||v>=p&&v<=_||w>=p&&w<=_},ke.prototype={fromPoint:function(r){return new ke([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,i=this.dim;n<i;){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,i=0;i<n;){var l=i++;this.add(r[l])}return this},contains:function(r,n){return n==null&&(n=-1),this.initialized?this.intersects(new ke([r]),n):!1},intersects:function(r,n){if(n==null&&(n=-1),!this.initialized||!r.initialized)return!1;for(var i=this.min,l=this.max,u=r.min,d=r.max,p=0,_=this.dim;p<_;){var v=p++;if(!ke.intervalsOverlap(i[v],l[v],u[v],d[v],n))return!1}return!0},clear:function(){return this.initialized=!1,this},getLongestAxis:function(){for(var r=0,n=0,i=0,l=this.dim;i<l;){var u=i++,d=this.getAxisLength(u);d>r&&(r=d,n=u)}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 i=this.min,l=this.max,u=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(i[P],u[P]))}return new ke([_,p])},__class__:ke};var rt=f.core.Constants=function(){};x["verb.core.Constants"]=rt,rt.__name__=["verb","core","Constants"];var $t=f.core.SerializableBase=function(){};x["verb.core.SerializableBase"]=$t,$t.__name__=["verb","core","SerializableBase"],$t.prototype={serialize:function(){var r=new Ht;return r.serialize(this),r.toString()},__class__:$t};var Cn=f.core.Plane=function(r,n){this.origin=r,this.normal=n};x["verb.core.Plane"]=Cn,Cn.__name__=["verb","core","Plane"],Cn.__super__=$t,Cn.prototype=M($t.prototype,{__class__:Cn});var cn=f.core.Ray=function(r,n){this.origin=r,this.dir=n};x["verb.core.Ray"]=cn,cn.__name__=["verb","core","Ray"],cn.__super__=$t,cn.prototype=M($t.prototype,{__class__:cn});var Ft=f.core.NurbsCurveData=function(r,n,i){this.degree=r,this.controlPoints=i,this.knots=n};x["verb.core.NurbsCurveData"]=Ft,Ft.__name__=["verb","core","NurbsCurveData"],Ft.__super__=$t,Ft.prototype=M($t.prototype,{__class__:Ft});var Jt=f.core.NurbsSurfaceData=function(r,n,i,l,u){this.degreeU=r,this.degreeV=n,this.knotsU=i,this.knotsV=l,this.controlPoints=u};x["verb.core.NurbsSurfaceData"]=Jt,Jt.__name__=["verb","core","NurbsSurfaceData"],Jt.__super__=$t,Jt.prototype=M($t.prototype,{__class__:Jt});var Ge=f.core.MeshData=function(r,n,i,l){this.faces=r,this.points=n,this.normals=i,this.uvs=l};x["verb.core.MeshData"]=Ge,Ge.__name__=["verb","core","MeshData"],Ge.empty=function(){return new Ge([],[],[],[])},Ge.__super__=$t,Ge.prototype=M($t.prototype,{__class__:Ge});var Nn=f.core.PolylineData=function(r,n){this.points=r,this.params=n};x["verb.core.PolylineData"]=Nn,Nn.__name__=["verb","core","PolylineData"],Nn.__super__=$t,Nn.prototype=M($t.prototype,{__class__:Nn});var Ln=f.core.VolumeData=function(r,n,i,l,u,d,p){this.degreeU=r,this.degreeV=n,this.degreeW=i,this.knotsU=l,this.knotsV=u,this.knotsW=d,this.controlPoints=p};x["verb.core.VolumeData"]=Ln,Ln.__name__=["verb","core","VolumeData"],Ln.__super__=$t,Ln.prototype=M($t.prototype,{__class__:Ln});var te=f.core.Pair=function(r,n){this.item0=r,this.item1=n};x["verb.core.Pair"]=te,te.__name__=["verb","core","Pair"],te.prototype={__class__:te};var we=f.core.Interval=function(r,n){this.min=r,this.max=n};x["verb.core.Interval"]=we,we.__name__=["verb","core","Interval"],we.prototype={__class__:we};var Ur=f.core.CurveCurveIntersection=function(r,n,i,l){this.point0=r,this.point1=n,this.u0=i,this.u1=l};x["verb.core.CurveCurveIntersection"]=Ur,Ur.__name__=["verb","core","CurveCurveIntersection"],Ur.prototype={__class__:Ur};var On=f.core.CurveSurfaceIntersection=function(r,n,i,l){this.u=r,this.uv=n,this.curvePoint=i,this.surfacePoint=l};x["verb.core.CurveSurfaceIntersection"]=On,On.__name__=["verb","core","CurveSurfaceIntersection"],On.prototype={__class__:On};var Pr=f.core.MeshIntersectionPoint=function(r,n,i,l,u){this.visited=!1,this.adj=null,this.opp=null,this.uv0=r,this.uv1=n,this.point=i,this.faceIndex0,this.faceIndex1};x["verb.core.MeshIntersectionPoint"]=Pr,Pr.__name__=["verb","core","MeshIntersectionPoint"],Pr.prototype={__class__:Pr};var zn=f.core.PolylineMeshIntersection=function(r,n,i,l,u){this.point=r,this.u=n,this.uv=i,this.polylineIndex=l,this.faceIndex=u};x["verb.core.PolylineMeshIntersection"]=zn,zn.__name__=["verb","core","PolylineMeshIntersection"],zn.prototype={__class__:zn};var Dn=f.core.SurfaceSurfaceIntersectionPoint=function(r,n,i,l){this.uv0=r,this.uv1=n,this.point=i,this.dist=l};x["verb.core.SurfaceSurfaceIntersectionPoint"]=Dn,Dn.__name__=["verb","core","SurfaceSurfaceIntersectionPoint"],Dn.prototype={__class__:Dn};var Rn=f.core.TriSegmentIntersection=function(r,n,i,l){this.point=r,this.s=n,this.t=i,this.p=l};x["verb.core.TriSegmentIntersection"]=Rn,Rn.__name__=["verb","core","TriSegmentIntersection"],Rn.prototype={__class__:Rn};var dn=f.core.CurveTriPoint=function(r,n,i){this.u=r,this.point=n,this.uv=i};x["verb.core.CurveTriPoint"]=dn,dn.__name__=["verb","core","CurveTriPoint"],dn.prototype={__class__:dn};var Fe=function(r,n,i,l,u){u==null&&(u=!1),l==null&&(l=-1),this.uv=i,this.point=r,this.normal=n,this.id=l,this.degen=u};x["verb.core.SurfacePoint"]=Fe,Fe.__name__=["verb","core","SurfacePoint"],Fe.fromUv=function(r,n){return new Fe(null,null,[r,n])},Fe.prototype={__class__:Fe};var ks=f.core.CurvePoint=function(r,n){this.u=r,this.pt=n};x["verb.core.CurvePoint"]=ks,ks.__name__=["verb","core","CurvePoint"],ks.prototype={__class__:ks};var Bn=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"]=Bn,Bn.__name__=["verb","core","KdTree"],Bn.prototype={buildTree:function(r,n,i){var l=n%this.dim,u,d;return r.length==0?null:r.length==1?new pn(r[0],l,i):(r.sort(function(p,_){var v=p.point[l]-_.point[l];return v==0?0:v>0?1:-1}),u=Math.floor(r.length/2),d=new pn(r[u],l,i),d.left=this.buildTree(r.slice(0,u),n+1,d),d.right=this.buildTree(r.slice(u+1),n+1,d),d)},nearest:function(r,n,i){var l=this,u=new Fn(function(A){return-A.item1}),d,p=null;p=function(A){for(var I,E=A.dimension,T=l.distanceFunction(r,A.kdPoint.point),L,N=[],R=0,O=l.dim;R<O;)R++,N.push(0);L=N;for(var F,V,H=function(Y,tt){u.push(new te(Y,tt)),u.size()>n&&u.pop()},J=0,G=l.dim;J<G;){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){(u.size()<n||T<u.peek().item1)&&H(A,T);return}A.right==null?I=A.left:A.left==null?I=A.right:r[E]<A.kdPoint.point[E]?I=A.left:I=A.right,p(I),(u.size()<n||T<u.peek().item1)&&H(A,T),(u.size()<n||Math.abs(F)<u.peek().item1)&&(I==A.left?V=A.right:V=A.left,V!=null&&p(V))},d=p;for(var _=0;_<n;)_++,u.push(new te(null,i));d(this.root);for(var v=[],w=0;w<n;){var P=w++;u.content[P].item0!=null&&v.push(new te(u.content[P].item0.kdPoint,u.content[P].item1))}return v},__class__:Bn};var Fn=function(r){this.content=[],this.scoreFunction=r};x["verb.core.BinaryHeap"]=Fn,Fn.__name__=["verb","core","BinaryHeap"],Fn.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,i=0;i<n;){var l=i++;if(this.content[l]==r){var u=this.content.pop();l!=n-1&&(this.content[l]=u,this.scoreFunction(u)<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 i=Math.floor((r+1)/2)-1,l=this.content[i];if(this.scoreFunction(n)<this.scoreFunction(l))this.content[i]=n,this.content[r]=l,r=i;else break}},sinkDown:function(r){for(var n=this.content.length,i=this.content[r],l=this.scoreFunction(i);;){var u=(r+1)*2,d=u-1,p=-1,_=0;if(d<n){var v=this.content[d];_=this.scoreFunction(v),_<l&&(p=d)}if(u<n){var w=this.content[u],P=this.scoreFunction(w);P<(p==-1?l:_)&&(p=u)}if(p!=-1)this.content[r]=this.content[p],this.content[p]=i,r=p;else break}},__class__:Fn};var mn=f.core.KdPoint=function(r,n){this.point=r,this.obj=n};x["verb.core.KdPoint"]=mn,mn.__name__=["verb","core","KdPoint"],mn.prototype={__class__:mn};var pn=f.core.KdNode=function(r,n,i){this.kdPoint=r,this.left=null,this.right=null,this.parent=i,this.dimension=n};x["verb.core.KdNode"]=pn,pn.__name__=["verb","core","KdNode"],pn.prototype={__class__:pn};var or=function(){};x["verb.eval.IBoundingBoxTree"]=or,or.__name__=["verb","eval","IBoundingBoxTree"],or.prototype={__class__:or};var er=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"]=er,er.__name__=["verb","core","LazyCurveBoundingBoxTree"],er.__interfaces__=[or],er.prototype={split:function(){var r=K.first(this._curve.knots),n=K.last(this._curve.knots),i=n-r,l=le.curveSplit(this._curve,(n+r)/2+i*.1*Math.random());return new te(new er(l[0],this._knotTol),new er(l[1],this._knotTol))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=new ke(C.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__:er};var rr=function(r,n){if(this._boundingBox=null,this._mesh=r,n==null){for(var i=[],l=0,u=r.faces.length;l<u;){var d=l++;i.push(d)}n=i}this._faceIndices=n};x["verb.core.LazyMeshBoundingBoxTree"]=rr,rr.__name__=["verb","core","LazyMeshBoundingBoxTree"],rr.__interfaces__=[or],rr.prototype={split:function(){var r=ee.sortTrianglesOnLongestAxis(this.boundingBox(),this._mesh,this._faceIndices),n=K.left(r),i=K.right(r);return new te(new rr(this._mesh,n),new rr(this._mesh,i))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=ee.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__:rr};var nr=function(r,n){this._boundingBox=null,this._polyline=r,n==null&&(n=new we(0,r.points.length!=0?r.points.length-1:0)),this._interval=n};x["verb.core.LazyPolylineBoundingBoxTree"]=nr,nr.__name__=["verb","core","LazyPolylineBoundingBoxTree"],nr.__interfaces__=[or],nr.prototype={split:function(){var r=this._interval.min,n=this._interval.max,i=r+Math.ceil((n-r)/2),l=new we(r,i),u=new we(i,n);return new te(new nr(this._polyline,l),new nr(this._polyline,u))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=new ke(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__:nr};var Sr=function(r,n,i,l){n==null&&(n=!1),this._boundingBox=null,this._surface=r,this._splitV=n,i==null&&(i=m.domain(r.knotsU)/16),l==null&&(l=m.domain(r.knotsV)/16),this._knotTolU=i,this._knotTolV=l};x["verb.core.LazySurfaceBoundingBoxTree"]=Sr,Sr.__name__=["verb","core","LazySurfaceBoundingBoxTree"],Sr.__interfaces__=[or],Sr.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 i=(r+n)/2,l=le.surfaceSplit(this._surface,i,this._splitV);return new te(new Sr(l[0],!this._splitV,this._knotTolU,this._knotTolV),new Sr(l[1],!this._splitV,this._knotTolU,this._knotTolV))},boundingBox:function(){if(this._boundingBox==null){this._boundingBox=new ke;for(var r=0,n=this._surface.controlPoints;r<n.length;){var i=n[r];++r,this._boundingBox.addRange(C.dehomogenize1d(i))}}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__:Sr};var Ct=f.core.Mat=function(){};x["verb.core.Mat"]=Ct,Ct.__name__=["verb","core","Mat"],Ct.mul=function(r,n){for(var i=[],l=0,u=n.length;l<u;){var d=l++;i.push(m.mul(r,n[d]))}return i},Ct.mult=function(r,n){var i,l,u,d,p,_,v,w;i=r.length,l=n.length,u=n[0].length,d=[];for(var P=i-1,A=0,I=0;P>=0;){for(p=[],_=r[P],I=u-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},Ct.add=function(r,n){for(var i=[],l=0,u=r.length;l<u;){var d=l++;i.push(m.add(r[d],n[d]))}return i},Ct.div=function(r,n){for(var i=[],l=0,u=r.length;l<u;){var d=l++;i.push(m.div(r[d],n))}return i},Ct.sub=function(r,n){for(var i=[],l=0,u=r.length;l<u;){var d=l++;i.push(m.sub(r[d],n[d]))}return i},Ct.dot=function(r,n){for(var i=[],l=0,u=r.length;l<u;){var d=l++;i.push(m.dot(r[d],n))}return i},Ct.identity=function(r){for(var n=m.zeros2d(r,r),i=0;i<r;){var l=i++;n[l][l]=1}return n},Ct.transpose=function(r){if(r.length==0)return[];for(var n=[],i=0,l=r[0].length;i<l;){var u=i++;n.push(function(d){for(var p,_=[],v=0,w=r.length;v<w;){var P=v++;_.push(r[P][u])}return p=_,p}())}return n},Ct.solve=function(r,n){return Ct.LUsolve(Ct.LU(r),n)},Ct.LUsolve=function(r,n){var i,l,u=r.LU,d=u.length,p=n.slice(),_=r.P,v,w,P;for(i=d-1;i!=-1;)p[i]=n[i],--i;for(i=0;i<d;){for(v=_[i],_[i]!=i&&(P=p[i],p[i]=p[v],p[v]=P),w=u[i],l=0;l<i;)p[i]-=p[l]*w[l],++l;++i}for(i=d-1;i>=0;){for(w=u[i],l=i+1;l<d;)p[i]-=p[l]*w[l],++l;p[i]/=w[i],--i}return p},Ct.LU=function(r){for(var n,i,l,u,d,p,_,v,w,P=[],A=0,I=r.length;A<I;){var E=A++;P.push(r[E].slice())}r=P;var T=r.length,L=T-1,N=[];for(l=0;l<T;){for(_=l,p=r[l],w=Math.abs(p[l]),i=l+1;i<T;)u=Math.abs(r[i][l]),w<u&&(w=u,_=i),++i;for(N[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],i=l+1;i<L;)v[i]-=v[l]*p[i],++i,v[i]-=v[l]*p[i],++i;i==L&&(v[i]-=v[l]*p[i]),++n}++l}return new Vn(r,N)};var Vn=function(r,n){this.LU=r,this.P=n};x["verb.core._Mat.LUDecomp"]=Vn,Vn.__name__=["verb","core","_Mat","LUDecomp"],Vn.prototype={__class__:Vn};var ee=f.core.Mesh=function(){};x["verb.core.Mesh"]=ee,ee.__name__=["verb","core","Mesh"],ee.getTriangleNorm=function(r,n){var i=r[n[0]],l=r[n[1]],u=r[n[2]],d=m.sub(l,i),p=m.sub(u,i),_=m.cross(d,p);return m.mul(1/m.norm(_),_)},ee.makeMeshAabb=function(r,n){for(var i=new ke,l=0;l<n.length;){var u=n[l];++l,i.add(r.points[r.faces[u][0]]),i.add(r.points[r.faces[u][1]]),i.add(r.points[r.faces[u][2]])}return i},ee.sortTrianglesOnLongestAxis=function(r,n,i){for(var l=r.getLongestAxis(),u=[],d=0;d<i.length;){var p=i[d];++d;var _=ee.getMinCoordOnAxis(n.points,n.faces[p],l);u.push(new te(_,p))}u.sort(function(I,E){var T=I.item0,L=E.item0;return T==L?0:T>L?1:-1});for(var v=[],w=0,P=u.length;w<P;){var A=w++;v.push(u[A].item1)}return v},ee.getMinCoordOnAxis=function(r,n,i){for(var l=1/0,u=0;u<3;){var d=u++,p=r[n[d]][i];p<l&&(l=p)}return l},ee.getTriangleCentroid=function(r,n){for(var i=[0,0,0],l=0;l<3;)for(var u=l++,d=0;d<3;){var p=d++;i[p]+=r[n[u]][p]}for(var _=0;_<3;){var v=_++;i[v]/=3}return i},ee.triangleUVFromPoint=function(r,n,i){var l=r.faces[n],u=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(u,i),A=m.sub(d,i),I=m.sub(p,i),E=m.norm(m.cross(m.sub(u,d),m.sub(u,p))),T=m.norm(m.cross(A,I))/E,L=m.norm(m.cross(I,P))/E,N=m.norm(m.cross(P,A))/E;return m.add(m.mul(T,_),m.add(m.mul(L,v),m.mul(N,w)))};var Ir=function(r,n){if(this._empty=!1,this._face=-1,n==null){for(var i=[],l=0,u=r.faces.length;l<u;){var d=l++;i.push(d)}n=i}if(this._boundingBox=ee.makeMeshAabb(r,n),n.length<1){this._empty=!0;return}else if(n.length<2){this._face=n[0];return}var p=ee.sortTrianglesOnLongestAxis(this._boundingBox,r,n),_=K.left(p),v=K.right(p);this._children=new te(new Ir(r,_),new Ir(r,v))};x["verb.core.MeshBoundingBoxTree"]=Ir,Ir.__name__=["verb","core","MeshBoundingBoxTree"],Ir.__interfaces__=[or],Ir.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__:Ir};var We=f.core.Minimizer=function(){};x["verb.core.Minimizer"]=We,We.__name__=["verb","core","Minimizer"],We.uncmin=function(r,n,i,l,u){i==null&&(i=1e-8),l==null&&(l=function(J){return We.numericalGradient(r,J)}),u==null&&(u=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!");i=Math.max(i,rt.EPSILON);var w,P,A,I=Ct.identity(d),E=0,T=[],L,N,R,O,F,V,H="";for(P=l(n);E<u;){if(!m.all(m.finite(P))){H="Gradient has Infinity or NaN";break}if(w=m.neg(Ct.dot(I,P)),!m.all(m.finite(w))){H="Search direction has Infinity or NaN";break}if(V=m.norm(w),V<i){H="Newton step smaller than tol";break}for(F=1,v=m.dot(P,w),L=n;E<u&&!(F*V<i);){if(T=m.mul(F,w),L=m.add(n,T),_=r(L),_-p>=.1*F*v||isNaN(_)){F*=.5,++E;continue}break}if(F*V<i){H="Line search step size smaller than tol";break}if(E==u){H="maxit reached during line search";break}A=l(L),N=m.sub(A,P),O=m.dot(N,T),R=Ct.dot(I,N),I=Ct.sub(Ct.add(I,Ct.mul((O+m.dot(N,R))/(O*O),We.tensor(T,T))),Ct.div(Ct.add(We.tensor(R,T),We.tensor(T,R)),O)),n=L,p=_,P=A,++E}return new Un(n,p,P,I,E,H)},We.numericalGradient=function(r,n){var i=n.length,l=r(n);if(l==NaN)throw new Q("gradient: f(x) is a NaN!");for(var u=n.slice(0),d,p,_=[],v,w=.001,P,A,I,E=0,T,L,N,R=0;R<i;)for(var O=R++,F=Math.max(1e-6*l,1e-8);;){if(++E,E>20)throw new Q("Numerical gradient fails");if(u[O]=n[O]+F,d=r(u),u[O]=n[O]-F,p=r(u),u[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,N=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)])/N,F/N),v>w)F/=16;else break}return _},We.tensor=function(r,n){for(var i=r.length,l=n.length,u=[],d,p,_=i-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;u[_]=d,_--}return u};var Un=function(r,n,i,l,u,d){this.solution=r,this.value=n,this.gradient=i,this.invHessian=l,this.iterations=u,this.message=d};x["verb.core.MinimizationResult"]=Un,Un.__name__=["verb","core","MinimizationResult"],Un.prototype={__class__:Un};var gn=function(){};x["verb.core.ISerializable"]=gn,gn.__name__=["verb","core","ISerializable"],gn.prototype={__class__:gn};var Si=f.core.Deserializer=function(){};x["verb.core.Deserializer"]=Si,Si.__name__=["verb","core","Deserializer"],Si.deserialize=function(r){var n=new Ut(r),i=n.unserialize();return i};var Ee=f.core.Trig=function(){};x["verb.core.Trig"]=Ee,Ee.__name__=["verb","core","Trig"],Ee.isPointInPlane=function(r,n,i){return Math.abs(m.dot(m.sub(r,n.origin),n.normal))<i},Ee.distToSegment=function(r,n,i){var l=Ee.segmentClosestPoint(n,r,i,0,1);return m.dist(n,l.pt)},Ee.rayClosestPoint=function(r,n,i){var l=m.sub(r,n),u=m.dot(l,i),d=m.add(n,m.mul(u,i));return d},Ee.distToRay=function(r,n,i){var l=Ee.rayClosestPoint(r,n,i),u=m.sub(l,r);return m.norm(u)},Ee.threePointsAreFlat=function(r,n,i,l){var u=m.sub(n,r),d=m.sub(i,r),p=m.cross(u,d),_=m.dot(p,p);return _<l},Ee.segmentClosestPoint=function(r,n,i,l,u){var d=m.sub(i,n),p=m.norm(d);if(p<rt.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,pt:i}:{u:l+(u-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,i){var l=m.cross(r,n),u=m.norm(r),d=m.norm(n),p=u*d,_=m.dot(r,n),v=m.norm(l)/p,w=_/p,P=Math.atan2(v,w),A=m.dot(i,l);return Math.abs(A)<rt.EPSILON||A>0?P:-P},m.signedAngleBetween=function(r,n,i){var l=m.cross(r,n),u=m.norm(r),d=m.norm(n),p=u*d,_=m.dot(r,n),v=m.norm(l)/p,w=_/p,P=Math.atan2(v,w),A=m.dot(i,l);return A>0?P:2*Math.PI-P},m.angleBetweenNormalized2d=function(r,n){var i=r[0]*n[1]-r[1]*n[0];return Math.atan2(i,m.dot(r,n))},m.domain=function(r){return K.last(r)-K.first(r)},m.range=function(r){for(var n=[],i=0,l=0;l<r;)l++,n.push(i),i+=1;return n},m.span=function(r,n,i){if(i==null)return[];if(i<rt.EPSILON)return[];if(r>n&&i>0)return[];if(n>r&&i<0)return[];for(var l=[],u=r;u<=n;)l.push(u),u+=i;return l},m.neg=function(r){return r.map(function(n){return-n})},m.min=function(r){return z.fold(r,function(n,i){return Math.min(n,i)},1/0)},m.max=function(r){return z.fold(r,function(n,i){return Math.max(n,i)},-1/0)},m.all=function(r){return z.fold(r,function(n,i){return i&&n},!0)},m.finite=function(r){return r.map(function(n){return isFinite(n)})},m.onRay=function(r,n,i){return m.add(r,m.mul(i,n))},m.lerp=function(r,n,i){return m.add(m.mul(r,n),m.mul(1-r,i))},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 z.fold(r,function(n,i){return i+n},0)},m.addAll=function(r){var n=He(r)();if(!n.hasNext())return null;var i=n.next().length;return z.fold(r,function(l,u){return m.add(u,l)},m.rep(i,0))},m.addAllMutate=function(r){for(var n=r[0],i=1,l=r.length;i<l;){var u=i++;m.addMutate(n,r[u])}},m.addMulMutate=function(r,n,i){for(var l=0,u=r.length;l<u;){var d=l++;r[d]=r[d]+n*i[d]}},m.subMulMutate=function(r,n,i){for(var l=0,u=r.length;l<u;){var d=l++;r[d]=r[d]-n*i[d]}},m.addMutate=function(r,n){for(var i=0,l=r.length;i<l;){var u=i++;r[u]=r[u]+n[u]}},m.subMutate=function(r,n){for(var i=0,l=r.length;i<l;){var u=i++;r[u]=r[u]-n[u]}},m.mulMutate=function(r,n){for(var i=0,l=n.length;i<l;){var u=i++;n[u]=n[u]*r}},m.norm=function(r){var n=m.normSquared(r);return n!=0?Math.sqrt(n):n},m.normSquared=function(r){return z.fold(r,function(n,i){return i+n*n},0)},m.rep=function(r,n){for(var i=[],l=0;l<r;)l++,i.push(n);return i},m.zeros1d=function(r){for(var n=[],i=0;i<r;)i++,n.push(0);return n},m.zeros2d=function(r,n){for(var i=[],l=0;l<r;)l++,i.push(m.zeros1d(n));return i},m.zeros3d=function(r,n,i){for(var l=[],u=0;u<r;)u++,l.push(m.zeros2d(n,i));return l},m.dot=function(r,n){for(var i=0,l=0,u=r.length;l<u;){var d=l++;i+=r[d]*n[d]}return i},m.add=function(r,n){for(var i=[],l=0,u=r.length;l<u;){var d=l++;i.push(r[d]+n[d])}return i},m.mul=function(r,n){for(var i=[],l=0,u=n.length;l<u;){var d=l++;i.push(r*n[d])}return i},m.div=function(r,n){for(var i=[],l=0,u=r.length;l<u;){var d=l++;i.push(r[d]/n)}return i},m.sub=function(r,n){for(var i=[],l=0,u=r.length;l<u;){var d=l++;i.push(r[d]-n[d])}return i},m.isZero=function(r){for(var n=0,i=r.length;n<i;){var l=n++;if(Math.abs(r[l])>rt.TOLERANCE)return!1}return!0},m.sortedSetUnion=function(r,n){for(var i=[],l=0,u=0;l<r.length||u<n.length;){if(l>=r.length){i.push(n[u]),u++;continue}else if(u>=n.length){i.push(r[l]),l++;continue}var d=r[l]-n[u];if(Math.abs(d)<rt.EPSILON){i.push(r[l]),l++,u++;continue}if(d>0){i.push(n[u]),u++;continue}i.push(r[l]),l++}return i},m.sortedSetSub=function(r,n){for(var i=[],l=0,u=0;l<r.length;){if(u>=n.length){i.push(r[l]),l++;continue}if(Math.abs(r[l]-n[u])<rt.EPSILON){l++,u++;continue}i.push(r[l]),l++}return i};var yt=f.eval.Analyze=function(){};x["verb.eval.Analyze"]=yt,yt.__name__=["verb","eval","Analyze"],yt.knotMultiplicities=function(r){for(var n=[new fn(r[0],0)],i=n[0],l=0;l<r.length;){var u=r[l];++l,Math.abs(u-i.knot)>rt.EPSILON&&(i=new fn(u,0),n.push(i)),i.inc()}return n},yt.isRationalSurfaceClosed=function(r,n){n==null&&(n=!0);var i;n?i=r.controlPoints:i=Ct.transpose(r.controlPoints);for(var l=0,u=i[0].length;l<u;){var d=l++,p=m.dist(K.first(i)[d],K.last(i)[d])<rt.EPSILON;if(!p)return!1}return!0},yt.rationalSurfaceClosestPoint=function(r,n){var i=yt.rationalSurfaceClosestParam(r,n);return C.rationalSurfacePoint(r,i[0],i[1])},yt.rationalSurfaceClosestParam=function(r,n){for(var i=5,l=0,u,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=yt.isRationalSurfaceClosed(r),E=yt.isRationalSurfaceClosed(r,!1),T,L=Ot.rationalSurfaceAdaptive(r,new kr),N=1/0,R=0,O=L.points.length;R<O;){var F=R++,V=L.points[F],H=m.normSquared(m.sub(n,V));H<N&&(N=H,T=L.uvs[F])}for(var J=function(Vt){return C.rationalSurfaceDerivatives(r,Vt[0],Vt[1],2)},G=function(Vt,qt,Rt){var Yt=qt[1][0],Ae=qt[0][1],Ue=qt[2][0],ve=qt[0][2],ge=qt[1][1],Pe=qt[1][1],Te=m.dot(Yt,Rt),qe=m.dot(Ae,Rt),sr=[-Te,-qe],Ye=m.dot(Yt,Yt)+m.dot(Ue,Rt),Ke=m.dot(Yt,Ae)+m.dot(ge,Rt),Xe=m.dot(Yt,Ae)+m.dot(Pe,Rt),hr=m.dot(Ae,Ae)+m.dot(ve,Rt),bn=[[Ye,Ke],[Xe,hr]],Gr=Ct.solve(bn,sr);return m.add(Gr,Vt)};l<i;){u=J(T),_=m.sub(u[0][0],n);var j=m.norm(_),Y=m.dot(u[1][0],_),tt=m.norm(u[1][0])*j,et=m.dot(u[0][1],_),st=m.norm(u[0][1])*j,ot=Y/tt,it=et/st,ht=j<d,nt=ot<p,ct=it<p;if(ht&&nt&&ct)return T;var q=G(T,u,_);q[0]<v?I?q=[w-(q[0]-v),q[1]]:q=[v+rt.EPSILON,q[1]]:q[0]>w&&(I?q=[v+(q[0]-w),q[1]]:q=[w-rt.EPSILON,q[1]]),q[1]<P?E?q=[q[0],A-(q[1]-P)]:q=[q[0],P+rt.EPSILON]:q[1]>A&&(E?q=[q[0],P+(q[0]-A)]:q=[q[0],A-rt.EPSILON]);var pt=m.norm(m.mul(q[0]-T[0],u[1][0])),At=m.norm(m.mul(q[1]-T[1],u[0][1]));if(pt+At<d)return T;T=q,l++}return T},yt.rationalCurveClosestPoint=function(r,n){return C.rationalCurvePoint(r,yt.rationalCurveClosestParam(r,n))},yt.rationalCurveClosestParam=function(r,n){for(var i=1/0,l=0,u=Ot.rationalCurveRegularSample(r,r.controlPoints.length*r.degree,!0),d=0,p=u.length-1;d<p;){var _=d++,v=u[_][0],w=u[_+1][0],P=u[_].slice(1),A=u[_+1].slice(1),I=Ee.segmentClosestPoint(n,P,A,v,w),E=m.norm(m.sub(n,I.pt));E<i&&(i=E,l=I.u)}for(var T=5,L=0,N,R=1e-4,O=5e-4,F,V=r.knots[0],H=K.last(r.knots),J=m.normSquared(m.sub(r.controlPoints[0],K.last(r.controlPoints)))<rt.EPSILON,G=l,j=function(q){return C.rationalCurveDerivatives(r,q,2)},Y=function(q,pt,At){var Vt=m.dot(pt[1],At),qt=m.dot(pt[2],At),Rt=m.dot(pt[1],pt[1]),Yt=qt+Rt;return q-Vt/Yt};L<T;){N=j(G),F=m.sub(N[0],n);var tt=m.norm(F),et=m.dot(N[1],F),st=m.norm(N[1])*tt,ot=et/st,it=tt<R,ht=Math.abs(ot)<O;if(it&&ht)return G;var nt=Y(G,N,F);nt<V?J?nt=H-(nt-V):nt=V:nt>H&&(J?nt=V+(nt-H):nt=H);var ct=m.norm(m.mul(nt-G,N[1]));if(ct<R)return G;G=nt,L++}return G},yt.rationalCurveParamAtArcLength=function(r,n,i,l,u){if(i==null&&(i=.001),n<rt.EPSILON)return r.knots[0];var d;l!=null?d=l:d=_t.decomposeCurveIntoBeziers(r);var p=0;d[p];var _=-rt.EPSILON,v;for(u!=null?v=u:v=[];_<n&&p<d.length;){if(p<v.length?v[p]=v[p]:v[p]=yt.rationalBezierCurveArcLength(r),_+=v[p],n<_+rt.EPSILON)return yt.rationalBezierCurveParamAtArcLength(r,n,i,v[p]);p++}return-1},yt.rationalBezierCurveParamAtArcLength=function(r,n,i,l){if(n<0)return r.knots[0];var u;if(l!=null?u=l:u=yt.rationalBezierCurveArcLength(r),n>u)return K.last(r.knots);var d=r.knots[0],p=0,_=K.last(r.knots),v=u,w=0,P=0,A;for(i!=null?A=i:A=rt.TOLERANCE*2;v-p>A;)w=(d+_)/2,P=yt.rationalBezierCurveArcLength(r,w),P>n?(_=w,v=P):(d=w,p=P);return(d+_)/2},yt.rationalCurveArcLength=function(r,n,i){i==null&&(i=16),n==null?n=K.last(r.knots):n=n;for(var l=_t.decomposeCurveIntoBeziers(r),u=0,d=l[0],p=0;u<l.length&&d.knots[0]+rt.EPSILON<n;){var _=Math.min(K.last(d.knots),n);p+=yt.rationalBezierCurveArcLength(d,_,i),d=l[++u]}return p},yt.rationalBezierCurveArcLength=function(r,n,i){i==null&&(i=16);var l;n==null?l=K.last(r.knots):l=n;for(var u=(l-r.knots[0])/2,d=0,p=r.degree+i,_,v,w=0;w<p;){var P=w++;_=u*yt.Tvalues[p][P]+u+r.knots[0],v=C.rationalCurveDerivatives(r,_,1),d+=yt.Cvalues[p][P]*m.norm(v[1])}return u*d};var fn=f.eval.KnotMultiplicity=function(r,n){this.knot=r,this.mult=n};x["verb.eval.KnotMultiplicity"]=fn,fn.__name__=["verb","eval","KnotMultiplicity"],fn.prototype={inc:function(){this.mult++},__class__:fn};var Ve=f.eval.Check=function(){};x["verb.eval.Check"]=Ve,Ve.__name__=["verb","eval","Check"],Ve.isValidKnotVector=function(r,n){if(r.length==0||r.length<(n+1)*2)return!1;for(var i=K.first(r),l=0,u=n+1;l<u;){var d=l++;if(Math.abs(r[d]-i)>rt.EPSILON)return!1}i=K.last(r);for(var p=r.length-n-1,_=r.length;p<_;){var v=p++;if(Math.abs(r[v]-i)>rt.EPSILON)return!1}return Ve.isNonDecreasing(r)},Ve.isNonDecreasing=function(r){for(var n=K.first(r),i=0,l=r.length;i<l;){var u=i++;if(r[u]<n-rt.EPSILON)return!1;n=r[u]}return!0},Ve.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(!Ve.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},Ve.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(!Ve.isValidKnotVector(r.knotsU,r.degreeU)||!Ve.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 le=f.eval.Divide=function(){};x["verb.eval.Divide"]=le,le.__name__=["verb","eval","Divide"],le.surfaceSplit=function(r,n,i){i==null&&(i=!1);var l,u,d;i?(d=r.controlPoints,l=r.knotsV,u=r.degreeV):(d=Ct.transpose(r.controlPoints),l=r.knotsU,u=r.degreeU);for(var p,_=[],v=0,w=u+1;v<w;)v++,_.push(n);p=_;for(var P=[],A=[],I=C.knotSpan(u,n,l),E=null,T=0;T<d.length;){var L=d[T];++T,E=_t.curveKnotRefine(new Ft(u,l,L),p),P.push(E.controlPoints.slice(0,I+1)),A.push(E.controlPoints.slice(I+1))}var N=E.knots.slice(0,I+u+2),R=E.knots.slice(I+1);return i?[new Jt(r.degreeU,u,r.knotsU.slice(),N,P),new Jt(r.degreeU,u,r.knotsU.slice(),R,A)]:(P=Ct.transpose(P),A=Ct.transpose(A),[new Jt(u,r.degreeV,N,r.knotsV.slice(),P),new Jt(u,r.degreeV,R,r.knotsV.slice(),A)])},le.curveSplit=function(r,n){var i=r.degree;r.controlPoints;for(var l=r.knots,u,d=[],p=0,_=i+1;p<_;)p++,d.push(n);u=d;var v=_t.curveKnotRefine(r,u),w=C.knotSpan(i,n,l),P=v.knots.slice(0,w+i+2),A=v.knots.slice(w+1),I=v.controlPoints.slice(0,w+1),E=v.controlPoints.slice(w+1);return[new Ft(i,P,I),new Ft(i,A,E)]},le.rationalCurveByEqualArcLength=function(r,n){var i=yt.rationalCurveArcLength(r),l=i/n;return le.rationalCurveByArcLength(r,l)},le.rationalCurveByArcLength=function(r,n){var i=_t.decomposeCurveIntoBeziers(r),l=i.map(function(I){return yt.rationalBezierCurveArcLength(I)}),u=m.sum(l),d=[new _n(r.knots[0],0)];if(n>u)return d;for(var p=n,_=0,v=p,w=0,P=0,A;_<i.length;){for(w+=l[_];v<w+rt.EPSILON;)A=yt.rationalBezierCurveParamAtArcLength(i[_],v-P,rt.TOLERANCE,l[_]),d.push(new _n(A,v)),v+=p;P+=l[_],_++}return d};var _n=f.eval.CurveLengthSample=function(r,n){this.u=r,this.len=n};x["verb.eval.CurveLengthSample"]=_n,_n.__name__=["verb","eval","CurveLengthSample"],_n.prototype={__class__:_n};var C=f.eval.Eval=function(){};x["verb.eval.Eval"]=C,C.__name__=["verb","eval","Eval"],C.rationalCurveTangent=function(r,n){var i=C.rationalCurveDerivatives(r,n,1);return i[1]},C.rationalSurfaceNormal=function(r,n,i){var l=C.rationalSurfaceDerivatives(r,n,i,1);return m.cross(l[1][0],l[0][1])},C.rationalSurfaceDerivatives=function(r,n,i,l){l==null&&(l=1);for(var u=C.surfaceDerivatives(r,n,i,l),d=C.rational2d(u),p=C.weight2d(u),_=[],v=d[0][0].length,w=0,P=l+1;w<P;){var A=w++;_.push([]);for(var I=0,E=l-A+1;I<E;){for(var T=I++,L=d[A][T],N=1,R=T+1;N<R;){var O=N++;m.subMulMutate(L,zt.get(T,O)*p[0][O],_[A][T-O])}for(var F=1,V=A+1;F<V;){var H=F++;m.subMulMutate(L,zt.get(A,H)*p[H][0],_[A-H][T]);for(var J=m.zeros1d(v),G=1,j=T+1;G<j;){var Y=G++;m.addMulMutate(J,zt.get(T,Y)*p[H][Y],_[A-H][T-Y])}m.subMulMutate(L,zt.get(A,H),J)}m.mulMutate(1/p[0][0],L),_[A].push(L)}}return _},C.rationalSurfacePoint=function(r,n,i){return C.dehomogenize(C.surfacePoint(r,n,i))},C.rationalCurveDerivatives=function(r,n,i){i==null&&(i=1);for(var l=C.curveDerivatives(r,n,i),u=C.rational1d(l),d=C.weight1d(l),p=[],_=0,v=i+1;_<v;){for(var w=_++,P=u[w],A=1,I=w+1;A<I;){var E=A++;m.subMulMutate(P,zt.get(w,E)*d[E],p[w-E])}m.mulMutate(1/d[0],P),p.push(P)}return p},C.rationalCurvePoint=function(r,n){return C.dehomogenize(C.curvePoint(r,n))},C.surfaceDerivatives=function(r,n,i,l){var u=r.knotsU.length-r.degreeU-2,d=r.knotsV.length-r.degreeV-2;return C.surfaceDerivativesGivenNM(u,d,r,n,i,l)},C.surfaceDerivativesGivenNM=function(r,n,i,l,u,d){var p=i.degreeU,_=i.degreeV,v=i.controlPoints,w=i.knotsU,P=i.knotsV;if(!C.areValidRelations(p,v.length,w.length)||!C.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 E;d<_?E=d:E=_;for(var T=m.zeros3d(d+1,d+1,A),L=C.knotSpanGivenN(r,p,l,w),N=C.knotSpanGivenN(n,_,u,P),R=C.derivativeBasisFunctionsGivenNI(L,l,p,r,w),O=C.derivativeBasisFunctionsGivenNI(N,u,_,n,P),F=m.zeros2d(_+1,A),V=0,H=0,J=I+1;H<J;){for(var G=H++,j=0,Y=_+1;j<Y;){var tt=j++;F[tt]=m.zeros1d(A);for(var et=0,st=p+1;et<st;){var ot=et++;m.addMulMutate(F[tt],R[G][ot],v[L-p+ot][N-_+tt])}}var it=d-G;it<E?V=it:V=E;for(var ht=0,nt=V+1;ht<nt;){var ct=ht++;T[G][ct]=m.zeros1d(A);for(var q=0,pt=_+1;q<pt;){var At=q++;m.addMulMutate(T[G][ct],O[ct][At],F[At])}}}return T},C.surfacePoint=function(r,n,i){var l=r.knotsU.length-r.degreeU-2,u=r.knotsV.length-r.degreeV-2;return C.surfacePointGivenNM(l,u,r,n,i)},C.surfacePointGivenNM=function(r,n,i,l,u){var d=i.degreeU,p=i.degreeV,_=i.controlPoints,v=i.knotsU,w=i.knotsV;if(!C.areValidRelations(d,_.length,v.length)||!C.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=C.knotSpanGivenN(r,d,l,v),I=C.knotSpanGivenN(n,p,u,w),E=C.basisFunctionsGivenKnotSpanIndex(A,l,d,v),T=C.basisFunctionsGivenKnotSpanIndex(I,u,p,w),L=A-d,N=I,R=m.zeros1d(P),O=m.zeros1d(P),F=0,V=p+1;F<V;){var H=F++;O=m.zeros1d(P),N=I-p+H;for(var J=0,G=d+1;J<G;){var j=J++;m.addMulMutate(O,E[j],_[L+j][N])}m.addMulMutate(R,T[H],O)}return R},C.curveRegularSamplePoints=function(r,n){for(var i=C.curveDerivatives(r,r.knots[0],r.degree),l=1/n,u=l*l,d=i[0],p=m.mul(l,i[1]),_=m.mul(u*.5,i[2]),v=m.mul(u*l*.5,i[3]),w=m.add(_,_),P=m.add(v,v),A=m.mul(.3333333333333333,v),I=[],E=0,T=n+1;E<T;)E++,I.push(C.dehomogenize(d)),m.addAllMutate([d,p,_,A]),m.addAllMutate([p,w,v]),m.addAllMutate([w,P]),m.addAllMutate([_,v]);return I},C.curveRegularSamplePoints2=function(r,n){for(var i=C.curveDerivatives(r,r.knots[0],r.degree),l=1/n,u=l*l,d=i[0],p=m.mul(l,i[1]),_=m.mul(u*.5,i[2]),v=m.mul(u*l*.5,i[3]),w=m.add(_,_),P=m.add(v,v),A=m.mul(.3333333333333333,v),I=[],E=0,T=n+1;E<T;)E++,I.push(C.dehomogenize(d)),m.addAllMutate([d,p,_,A]),m.addAllMutate([p,w,v]),m.addAllMutate([w,P]),m.addAllMutate([_,v]);return I},C.rationalSurfaceRegularSampleDerivatives=function(r,n,i,l){for(var u=C.surfaceRegularSampleDerivatives(r,n,i,l),d=[],p=n+1,_=i+1,v=l+1,w=0;w<p;){var P=w++,A=[];d.push(A);for(var I=0;I<_;){for(var E=I++,T=u[P][E],L=C.rational2d(T),N=C.weight2d(T),R=[],O=L[0][0].length,F=0;F<v;){var V=F++;R.push([]);for(var H=0,J=v-V;H<J;){for(var G=H++,j=L[V][G],Y=1,tt=G+1;Y<tt;){var et=Y++;m.subMulMutate(j,zt.get(G,et)*N[0][et],R[V][G-et])}for(var st=1,ot=V+1;st<ot;){var it=st++;m.subMulMutate(j,zt.get(V,it)*N[it][0],R[V-it][G]);for(var ht=m.zeros1d(O),nt=1,ct=G+1;nt<ct;){var q=nt++;m.addMulMutate(ht,zt.get(G,q)*N[it][q],R[V-it][G-q])}m.subMulMutate(j,zt.get(V,it),ht)}m.mulMutate(1/N[0][0],j),R[V].push(j)}}A.push(R)}}return d},C.surfaceRegularSampleDerivatives=function(r,n,i,l){var u=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])/i;for(var P=C.regularlySpacedDerivativeBasisFunctions(u,_,n),A=P.item0,I=P.item1,E=C.regularlySpacedDerivativeBasisFunctions(d,v,i),T=E.item0,L=E.item1,N=[],R=n+1,O=i+1,F=0;F<R;){var V=F++,H=[];N.push(H);for(var J=0;J<O;){var G=J++;H.push(C.surfaceDerivativesGivenBasesKnotSpans(u,d,p,A[V],T[G],I[V],L[G],w,l))}}return N},C.rationalSurfaceRegularSamplePoints=function(r,n,i){return C.dehomogenize2d(C.surfaceRegularSamplePoints(r,n,i))},C.surfaceRegularSamplePoints=function(r,n,i){var l=r.degreeU,u=r.degreeV,d=r.controlPoints,p=r.knotsU,_=r.knotsV,v=d[0][0].length;(K.last(p)-p[0])/n,(K.last(_)-_[0])/i;for(var w=C.regularlySpacedBasisFunctions(l,p,n),P=w.item0,A=w.item1,I=C.regularlySpacedBasisFunctions(u,_,i),E=I.item0,T=I.item1,L=[],N=n+1,R=i+1,O=0;O<N;){var F=O++,V=[];L.push(V);for(var H=0;H<R;){var J=H++;V.push(C.surfacePointGivenBasesKnotSpans(l,u,d,P[F],E[J],A[F],T[J],v))}}return L},C.regularlySpacedBasisFunctions=function(r,n,i){for(var l=n.length-r-2,u=(K.last(n)-n[0])/i,d=[],p=[],_=n[0],v=C.knotSpanGivenN(l,r,_,n),w=i+1,P=0;P<w;){for(P++;_>=n[v+1];)v++;p.push(v),d.push(C.basisFunctionsGivenKnotSpanIndex(v,_,r,n)),_+=u}return new te(p,d)},C.regularlySpacedDerivativeBasisFunctions=function(r,n,i){for(var l=n.length-r-2,u=(K.last(n)-n[0])/i,d=[],p=[],_=n[0],v=C.knotSpanGivenN(l,r,_,n),w=i+1,P=0;P<w;){for(P++;_>=n[v+1];)v++;p.push(v),d.push(C.derivativeBasisFunctionsGivenNI(v,_,r,l,n)),_+=u}return new te(p,d)},C.surfacePointGivenBasesKnotSpans=function(r,n,i,l,u,d,p,_){for(var v=m.zeros1d(_),w,P=l-r,A=u-n,I=0,E=n+1;I<E;){var T=I++;w=m.zeros1d(_);for(var L=0,N=r+1;L<N;){var R=L++;m.addMulMutate(w,d[R],i[P+R][A])}A++,m.addMulMutate(v,p[T],w)}return v},C.surfaceDerivativesGivenBasesKnotSpans=function(r,n,i,l,u,d,p,_,v){var w=i[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),E=m.zeros2d(n+1,w),T=0,L=0,N=P+1;L<N;){for(var R=L++,O=0,F=n+1;O<F;){var V=O++;E[V]=m.zeros1d(w);for(var H=0,J=r+1;H<J;){var G=H++;m.addMulMutate(E[V],d[R][G],i[l-r+G][u-n+V])}}var j=v-R;j<A?T=j:T=A;for(var Y=0,tt=T+1;Y<tt;){var et=Y++;I[R][et]=m.zeros1d(w);for(var st=0,ot=n+1;st<ot;){var it=st++;m.addMulMutate(I[R][et],p[et][it],E[it])}}}return I},C.curveDerivatives=function(r,n,i){var l=r.knots.length-r.degree-2;return C.curveDerivativesGivenN(l,r,n,i)},C.curveDerivativesGivenN=function(r,n,i,l){var u=n.degree,d=n.controlPoints,p=n.knots;if(!C.areValidRelations(u,d.length,p.length))throw new Q("Invalid relations between control points, knot vector, and n");var _=d[0].length,v;l<u?v=l:v=u;for(var w=m.zeros2d(l+1,_),P=C.knotSpanGivenN(r,u,i,p),A=C.derivativeBasisFunctionsGivenNI(P,i,u,v,p),I=0,E=v+1;I<E;)for(var T=I++,L=0,N=u+1;L<N;){var R=L++;m.addMulMutate(w[T],A[T][R],d[P-u+R])}return w},C.curvePoint=function(r,n){var i=r.knots.length-r.degree-2;return C.curvePointGivenN(i,r,n)},C.areValidRelations=function(r,n,i){return n+r+1-i==0},C.curvePointGivenN=function(r,n,i){var l=n.degree,u=n.controlPoints,d=n.knots;if(!C.areValidRelations(l,u.length,d.length))throw new Q("Invalid relations between control points, knot Array, and n");for(var p=C.knotSpanGivenN(r,l,i,d),_=C.basisFunctionsGivenKnotSpanIndex(p,i,l,d),v=m.zeros1d(u[0].length),w=0,P=l+1;w<P;){var A=w++;m.addMulMutate(v,_[A],u[p-l+A])}return v},C.volumePoint=function(r,n,i,l){var u=r.knotsU.length-r.degreeU-2,d=r.knotsV.length-r.degreeV-2,p=r.knotsW.length-r.degreeW-2;return C.volumePointGivenNML(r,u,d,p,n,i,l)},C.volumePointGivenNML=function(r,n,i,l,u,d,p){if(!C.areValidRelations(r.degreeU,r.controlPoints.length,r.knotsU.length)||!C.areValidRelations(r.degreeV,r.controlPoints[0].length,r.knotsV.length)||!C.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,E=r.knotsW,T=_[0][0][0].length,L=C.knotSpanGivenN(n,v,u,A),N=C.knotSpanGivenN(i,w,d,I),R=C.knotSpanGivenN(l,P,p,E),O=C.basisFunctionsGivenKnotSpanIndex(L,u,v,A),F=C.basisFunctionsGivenKnotSpanIndex(N,d,w,I),V=C.basisFunctionsGivenKnotSpanIndex(R,p,P,E),H=L-v,J=m.zeros1d(T),G=m.zeros1d(T),j=m.zeros1d(T),Y=0,tt=P+1;Y<tt;){var et=Y++;j=m.zeros1d(T);for(var st=R-P+et,ot=0,it=w+1;ot<it;){var ht=ot++;G=m.zeros1d(T);for(var nt=N-w+ht,ct=0,q=v+1;ct<q;){var pt=ct++;m.addMulMutate(G,O[pt],_[H+pt][nt][st])}m.addMulMutate(j,F[ht],G)}m.addMulMutate(J,V[et],j)}return J},C.derivativeBasisFunctions=function(r,n,i){var l=C.knotSpan(n,r,i),u=i.length-1,d=u-n-1;return C.derivativeBasisFunctionsGivenNI(l,r,n,d,i)},C.derivativeBasisFunctionsGivenNI=function(r,n,i,l,u){var d=m.zeros2d(i+1,i+1),p=m.zeros1d(i+1),_=m.zeros1d(i+1),v=0,w=0;d[0][0]=1;for(var P=1,A=i+1;P<A;){var I=P++;p[I]=n-u[r+1-I],_[I]=u[r+I]-n,v=0;for(var E=0;E<I;){var T=E++;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,i+1),N=m.zeros2d(2,i+1),R=0,O=1,F=0,V=0,H=0,J=0,G=0,j=0,Y=i+1;j<Y;){var tt=j++;L[0][tt]=d[tt][i]}for(var et=0,st=i+1;et<st;){var ot=et++;R=0,O=1,N[0][0]=1;for(var it=1,ht=l+1;it<ht;){var nt=it++;F=0,V=ot-nt,H=i-nt,ot>=nt&&(N[O][0]=N[R][0]/d[H+1][V],F=N[O][0]*d[V][H]),V>=-1?J=1:J=-V,ot-1<=H?G=nt-1:G=i-ot;for(var ct=J,q=G+1;ct<q;){var pt=ct++;N[O][pt]=(N[R][pt]-N[R][pt-1])/d[H+1][V+pt],F+=N[O][pt]*d[V+pt][H]}ot<=H&&(N[O][nt]=-N[R][nt-1]/d[H+1][ot],F+=N[O][nt]*d[ot][H]),L[nt][ot]=F;var At=R;R=O,O=At}}for(var Vt=i,qt=1,Rt=l+1;qt<Rt;){for(var Yt=qt++,Ae=0,Ue=i+1;Ae<Ue;){var ve=Ae++;L[Yt][ve]*=Vt}Vt*=i-Yt}return L},C.basisFunctions=function(r,n,i){var l=C.knotSpan(n,r,i);return C.basisFunctionsGivenKnotSpanIndex(l,r,n,i)},C.basisFunctionsGivenKnotSpanIndex=function(r,n,i,l){var u=m.zeros1d(i+1),d=m.zeros1d(i+1),p=m.zeros1d(i+1),_=0,v=0;u[0]=1;for(var w=1,P=i+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 E=I++;v=u[E]/(p[E+1]+d[A-E]),u[E]=_+p[E+1]*v,_=d[A-E]*v}u[A]=_}return u},C.knotSpan=function(r,n,i){return C.knotSpanGivenN(i.length-r-2,r,n,i)},C.knotSpanGivenN=function(r,n,i,l){if(i>l[r+1]-rt.EPSILON)return r;if(i<l[n]+rt.EPSILON)return n;for(var u=n,d=r+1,p=Math.floor((u+d)/2);i<l[p]||i>=l[p+1];)i<l[p]?d=p:u=p,p=Math.floor((u+d)/2);return p},C.dehomogenize=function(r){for(var n=r.length,i=[],l=r[n-1],u=r.length-1,d=0;d<u;){var p=d++;i.push(r[p]/l)}return i},C.rational1d=function(r){var n=r[0].length-1;return r.map(function(i){return i.slice(0,n)})},C.rational2d=function(r){return r.map(C.rational1d)},C.weight1d=function(r){var n=r[0].length-1;return r.map(function(i){return i[n]})},C.weight2d=function(r){return r.map(C.weight1d)},C.dehomogenize1d=function(r){return r.map(C.dehomogenize)},C.dehomogenize2d=function(r){return r.map(C.dehomogenize1d)},C.homogenize1d=function(r,n){var i=r.length,l=r[0].length,u=[],d=0,p=[],_;n!=null?_=n:_=m.rep(r.length,1);for(var v=0;v<i;){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),u.push(P)}return u},C.homogenize2d=function(r,n){var i=r.length,l=[],u;if(n!=null)u=n;else{for(var d=[],p=0;p<i;)p++,d.push(m.rep(r[0].length,1));u=d}for(var _=0;_<i;){var v=_++;l.push(C.homogenize1d(r[v],u[v]))}return l};var at=f.eval.Intersect=function(){};x["verb.eval.Intersect"]=at,at.__name__=["verb","eval","Intersect"],at.surfaces=function(r,n,i){var l=Ot.rationalSurfaceAdaptive(r),u=Ot.rationalSurfaceAdaptive(n),d=at.meshes(l,u),p=d.map(function(_){return _.map(function(v){return at.surfacesAtPointWithEstimate(r,n,v.uv0,v.uv1,i)})});return p.map(function(_){return dt.rationalInterpCurve(_.map(function(v){return v.point}),3)})},at.surfacesAtPointWithEstimate=function(r,n,i,l,u){var d,p,_,v,w,P,A,I,E,T,L,N,R,O=5,F=0;do{if(d=C.rationalSurfaceDerivatives(r,i[0],i[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=C.rationalSurfaceDerivatives(n,l[0],l[1],1),I=A[0][0],T=A[1][0],L=A[0][1],E=m.normalized(m.cross(T,L)),N=m.dot(E,I),R=m.distSquared(p,I),R<u*u)break;var V=m.normalized(m.cross(_,E)),H=m.dot(V,p),J=at.threePlanes(_,P,E,N,V,H);if(J==null)throw new Q("panic!");var G=m.sub(J,p),j=m.sub(J,I),Y=m.cross(v,_),tt=m.cross(w,_),et=m.cross(T,E),st=m.cross(L,E),ot=m.dot(tt,G)/m.dot(tt,v),it=m.dot(Y,G)/m.dot(Y,w),ht=m.dot(st,j)/m.dot(st,T),nt=m.dot(et,j)/m.dot(et,L);i=m.add([ot,it],i),l=m.add([ht,nt],l),F++}while(F<O);return new Dn(i,l,p,R)},at.meshes=function(r,n,i,l){i==null&&(i=new rr(r)),l==null&&(l=new rr(n));var u=at.boundingBoxTrees(i,l,0),d=K.unique(u.map(function(p){return at.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)>rt.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),E=m.dot(I,I),T=m.sub(p.max.uv0,_.min.uv0),L=m.dot(T,T);return w<rt.EPSILON&&A<rt.EPSILON||E<rt.EPSILON&&L<rt.EPSILON});return at.makeMeshIntersectionPolylines(d)},at.meshSlices=function(r,n,i,l){for(var u=new Ir(r),d=u.boundingBox(),p=d.min[0],_=d.min[1],v=d.max[0],w=d.max[1],P=m.span(n,i,l),A=[],I=0;I<P.length;){var E=P[I];++I;var T=[[p,_,E],[v,_,E],[v,w,E],[p,w,E]],L=[[0,0],[1,0],[1,1],[0,1]],N=[[0,1,2],[0,2,3]],R=new Ge(N,T,null,L);A.push(at.meshes(r,R,u))}return A},at.makeMeshIntersectionPolylines=function(r){if(r.length==0)return[];for(var n=0;n<r.length;){var i=r[n];++n,i.max.opp=i.min,i.min.opp=i.max}for(var l=at.kdTreeFromSegments(r),u=[],d=0;d<r.length;){var p=r[d];++d,u.push(p.min),u.push(p.max)}for(var _=0;_<u.length;){var v=u[_];if(++_,v.adj==null){var w=at.lookupAdjacentSegment(v,l,r.length);w!=null&&w.adj==null&&(v.adj=w,w.adj=v)}}var P=u.filter(function(O){return O.adj==null});P.length==0&&(P=u);for(var A=[],I=0,E=!1;P.length!=0;){var T=P.pop();if(!T.visited){for(var L=[],N=T;N!=null&&!(N.visited||(N.visited=!0,N.opp.visited=!0,L.push(N),I+=2,N=N.opp.adj,N==T)););L.length>0&&(L.push(L[L.length-1].opp),A.push(L))}if(P.length==0&&u.length>0&&(E||I<u.length)){E=!0;var R=u.pop();P.push(R)}}return A},at.kdTreeFromSegments=function(r){for(var n=[],i=0;i<r.length;){var l=r[i];++i,n.push(new mn(l.min.point,l.min)),n.push(new mn(l.max.point,l.max))}return new Bn(n,m.distSquared)},at.lookupAdjacentSegment=function(r,n,i){var l=n.nearest(r.point,i,rt.EPSILON).filter(function(u){return r!=u.item0.obj}).map(function(u){return u.item0.obj});return l.length==1?l[0]:null},at.curveAndSurface=function(r,n,i,l,u){i==null&&(i=.001),l!=null?l=l:l=new er(r),u!=null?u=u:u=new Sr(n);var d=at.boundingBoxTrees(l,u,i);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),E=K.last(v.knotsU),T=K.first(v.knotsV),L=K.last(v.knotsV),N=[(I+E)/2,(T+L)/2];return at.curveAndSurfaceWithEstimate(_,v,[A].concat(N),i)}).filter(function(p){return m.distSquared(p.curvePoint,p.surfacePoint)<i*i}),function(p,_){return Math.abs(p.u-_.u)<.5*i})},at.curveAndSurfaceWithEstimate=function(r,n,i,l){l==null&&(l=.001);var u=function(v){var w=C.rationalCurvePoint(r,v[0]),P=C.rationalSurfacePoint(n,v[1],v[2]),A=m.sub(w,P);return m.dot(A,A)},d=function(v){var w=C.rationalCurveDerivatives(r,v[0],1),P=C.rationalSurfaceDerivatives(n,v[1],v[2],1),A=m.sub(P[0][0],w[0]),I=m.mul(-1,w[1]),E=P[1][0],T=P[0][1];return[2*m.dot(I,A),2*m.dot(E,A),2*m.dot(T,A)]},p=We.uncmin(u,i,l*l,d),_=p.solution;return new On(_[0],[_[1],_[2]],C.rationalCurvePoint(r,_[0]),C.rationalSurfacePoint(n,_[1],_[2]))},at.polylineAndMesh=function(r,n,i){for(var l=at.boundingBoxTrees(new nr(r),new rr(n),i),u=[],d=0;d<l.length;){var p=l[d];++d;var _=p.item0,v=p.item1,w=at.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=ee.triangleUVFromPoint(n,v,P);u.push(new zn(P,A,I,_,v))}}return u},at.boundingBoxTrees=function(r,n,i){i==null&&(i=1e-9);var l=[],u=[];l.push(r),u.push(n);for(var d=[];l.length>0;){var p=l.pop(),_=u.pop();if(!(p.empty()||_.empty())&&p.boundingBox().intersects(_.boundingBox(),i)){var v=p.indivisible(i),w=_.indivisible(i);if(v&&w){d.push(new te(p.yield(),_.yield()));continue}else if(v&&!w){var P=_.split();l.push(p),u.push(P.item1),l.push(p),u.push(P.item0);continue}else if(!v&&w){var A=p.split();l.push(A.item1),u.push(_),l.push(A.item0),u.push(_);continue}var I=p.split(),E=_.split();l.push(I.item1),u.push(E.item1),l.push(I.item1),u.push(E.item0),l.push(I.item0),u.push(E.item1),l.push(I.item0),u.push(E.item0)}}return d},at.curves=function(r,n,i){var l=at.boundingBoxTrees(new er(r),new er(n),0);return K.unique(l.map(function(u){return at.curvesWithEstimate(r,n,K.first(u.item0.knots),K.first(u.item1.knots),i)}).filter(function(u){return m.distSquared(u.point0,u.point1)<i}),function(u,d){return Math.abs(u.u0-d.u0)<i*5})},at.curvesWithEstimate=function(r,n,i,l,u){var d=function(I){var E=C.rationalCurvePoint(r,I[0]),T=C.rationalCurvePoint(n,I[1]),L=m.sub(E,T);return m.dot(L,L)},p=function(I){var E=C.rationalCurveDerivatives(r,I[0],1),T=C.rationalCurveDerivatives(n,I[1],1),L=m.sub(E[0],T[0]),N=E[1],R=m.mul(-1,T[1]);return[2*m.dot(N,L),2*m.dot(R,L)]},_=We.uncmin(d,[i,l],u*u,p),v=_.solution[0],w=_.solution[1],P=C.rationalCurvePoint(r,v),A=C.rationalCurvePoint(n,w);return new Ur(P,A,v,w)},at.triangles=function(r,n,i,l){var u=r.faces[n],d=i.faces[l],p=ee.getTriangleNorm(r.points,u),_=ee.getTriangleNorm(i.points,d),v=r.points[u[0]],w=i.points[d[0]],P=at.planes(v,p,w,_);if(P==null)return null;var A=at.clipRayInCoplanarTriangle(P,r,n);if(A==null)return null;var I=at.clipRayInCoplanarTriangle(P,i,l);if(I==null)return null;var E=at.mergeTriangleClipIntervals(A,I,r,n,i,l);return E==null?null:new we(new Pr(E.min.uv0,E.min.uv1,E.min.point,n,l),new Pr(E.max.uv0,E.max.uv1,E.max.point,n,l))},at.clipRayInCoplanarTriangle=function(r,n,i){for(var l=n.faces[i],u=[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(u[1],u[0]),m.sub(u[2],u[1]),m.sub(u[0],u[2])],v=_.map(m.normalized),w=_.map(m.norm),P=null,A=null,I=0;I<3;){var E=I++,T=u[E],L=v[E],N=at.rays(T,L,r.origin,r.dir);if(N!=null){var R=N.u0,O=N.u1;R<-rt.EPSILON||R>w[E]+rt.EPSILON||((P==null||O<P.u)&&(P=new dn(O,m.onRay(r.origin,r.dir,O),m.onRay(d[E],p[E],R/w[E]))),(A==null||O>A.u)&&(A=new dn(O,m.onRay(r.origin,r.dir,O),m.onRay(d[E],p[E],R/w[E]))))}}return A==null||P==null?null:new we(P,A)},at.mergeTriangleClipIntervals=function(r,n,i,l,u,d){if(n.min.u>r.max.u+rt.EPSILON||r.min.u>n.max.u+rt.EPSILON)return null;var p;r.min.u>n.min.u?p=new te(r.min,0):p=new te(n.min,1);var _;r.max.u<n.max.u?_=new te(r.max,0):_=new te(n.max,1);var v=new we(new Pr(null,null,p.item0.point,l,d),new Pr(null,null,_.item0.point,l,d));return p.item1==0?(v.min.uv0=p.item0.uv,v.min.uv1=ee.triangleUVFromPoint(u,d,p.item0.point)):(v.min.uv0=ee.triangleUVFromPoint(i,l,p.item0.point),v.min.uv1=p.item0.uv),_.item1==0?(v.max.uv0=_.item0.uv,v.max.uv1=ee.triangleUVFromPoint(u,d,_.item0.point)):(v.max.uv0=ee.triangleUVFromPoint(i,l,_.item0.point),v.max.uv1=_.item0.uv),v},at.planes=function(r,n,i,l){var u=m.cross(n,l);if(m.dot(u,u)<rt.EPSILON)return null;var d=0,p=Math.abs(u[0]),_=Math.abs(u[1]),v=Math.abs(u[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 E=-m.dot(r,n),T=-m.dot(i,l),L=w*I-P*A,N=(P*T-E*I)/L,R=(E*A-w*T)/L,O;return d==0?O=[0,N,R]:d==1?O=[N,0,R]:O=[N,R,0],new cn(O,m.normalized(u))},at.threePlanes=function(r,n,i,l,u,d){var p=m.cross(i,u),_=m.dot(r,p);if(Math.abs(_)<rt.EPSILON)return null;var v=m.sub(m.mul(d,i),m.mul(l,u)),w=m.add(m.mul(n,p),m.cross(r,v));return m.mul(1/_,w)},at.polylines=function(r,n,i){for(var l=at.boundingBoxTrees(new nr(r),new nr(n),i),u=[],d=0;d<l.length;){var p=l[d];++d;var _=p.item0,v=p.item1,w=at.segments(r.points[_],r.points[_+1],n.points[v],n.points[v+1],i);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],u.push(w))}return u},at.segments=function(r,n,i,l,u){var d=m.sub(n,r),p=Math.sqrt(m.dot(d,d)),_=m.mul(1/p,d),v=m.sub(l,i),w=Math.sqrt(m.dot(v,v)),P=m.mul(1/w,v),A=at.rays(r,_,i,P);if(A!=null){var I=Math.min(Math.max(0,A.u0/p),1),E=Math.min(Math.max(0,A.u1/w),1),T=m.onRay(r,d,I),L=m.onRay(i,v,E),N=m.distSquared(T,L);if(N<u*u)return new Ur(T,L,I,E)}return null},at.rays=function(r,n,i,l){var u=m.dot(n,l),d=m.dot(n,i),p=m.dot(n,r),_=m.dot(l,i),v=m.dot(l,r),w=m.dot(n,n),P=m.dot(l,l),A=w*P-u*u;if(Math.abs(A)<rt.EPSILON)return null;var I=u*(d-p)-w*(_-v),E=I/A,T=(d-p+E*u)/w,L=m.onRay(r,n,T),N=m.onRay(i,l,E);return new Ur(L,N,T,E)},at.segmentWithTriangle=function(r,n,i,l){var u=i[l[0]],d=i[l[1]],p=i[l[2]],_=m.sub(d,u),v=m.sub(p,u),w=m.cross(_,v),P=m.sub(n,r),A=m.sub(r,u),I=-m.dot(w,A),E=m.dot(w,P);if(Math.abs(E)<rt.EPSILON)return null;var T=I/E;if(T<0||T>1)return null;var L=m.add(r,m.mul(T,P)),N=m.dot(_,v),R=m.dot(_,_),O=m.dot(v,v),F=m.sub(L,u),V=m.dot(F,_),H=m.dot(F,v),J=N*N-R*O;if(Math.abs(J)<rt.EPSILON)return null;var G=(N*H-O*V)/J,j=(N*V-R*H)/J;return G>1+rt.EPSILON||j>1+rt.EPSILON||j<-rt.EPSILON||G<-rt.EPSILON||G+j>1+rt.EPSILON?null:new Rn(L,G,j,T)},at.segmentAndPlane=function(r,n,i,l){var u=m.dot(l,m.sub(n,r));if(Math.abs(u)<rt.EPSILON)return null;var d=m.dot(l,m.sub(i,r)),p=d/u;return p>1+rt.EPSILON||p<-rt.EPSILON?null:{p}};var dt=f.eval.Make=function(){};x["verb.eval.Make"]=dt,dt.__name__=["verb","eval","Make"],dt.rationalTranslationalSurface=function(r,n){for(var i=C.rationalCurvePoint(n,K.first(n.knots)),l=K.first(n.knots),u=K.last(n.knots),d=2*n.controlPoints.length,p=(u-l)/(d-1),_=[],v=0;v<d;){var w=v++,P=m.sub(C.rationalCurvePoint(n,l+w*p),i),A=_t.rationalCurveTransform(r,[[1,0,0,P[0]],[0,1,0,P[1]],[0,0,1,P[2]],[0,0,0,1]]);_.push(A)}return dt.loftedSurface(_)},dt.surfaceBoundaryCurves=function(r){var n=dt.surfaceIsocurve(r,K.first(r.knotsU),!1),i=dt.surfaceIsocurve(r,K.last(r.knotsU),!1),l=dt.surfaceIsocurve(r,K.first(r.knotsV),!0),u=dt.surfaceIsocurve(r,K.last(r.knotsV),!0);return[n,i,l,u]},dt.surfaceIsocurve=function(r,n,i){i==null&&(i=!1);var l;i?l=r.knotsV:l=r.knotsU;var u;i?u=r.degreeV:u=r.degreeU;for(var d=yt.knotMultiplicities(l),p=-1,_=0,v=d.length;_<v;){var w=_++;if(Math.abs(n-d[w].knot)<rt.EPSILON){p=w;break}}var P=u+1;p>=0&&(P=P-d[p].mult);var A;P>0?A=_t.surfaceKnotRefine(r,m.rep(P,n),i):A=r;var I=C.knotSpan(u,n,l);return Math.abs(n-K.first(l))<rt.EPSILON?I=0:Math.abs(n-K.last(l))<rt.EPSILON&&(I=(i?A.controlPoints[0].length:A.controlPoints.length)-1),i?new Ft(A.degreeU,A.knotsU,function(E){for(var T,L=[],N=0,R=A.controlPoints;N<R.length;){var O=R[N];++N,L.push(O[I])}return T=L,T}()):new Ft(A.degreeV,A.knotsV,A.controlPoints[I])},dt.loftedSurface=function(r,n){r=_t.unifyCurveKnotVectors(r);var i=r[0].degree;n==null&&(n=3),n>r.length-1&&(n=r.length-1);for(var l=r[0].knots,u=[],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=dt.rationalInterpCurve(w,n,!0);d.push(P.controlPoints),u=P.knots}return new Jt(i,n,l,u,d)},dt.clonedCurve=function(r){return new Ft(r.degree,r.knots.slice(),r.controlPoints.map(function(n){return n.slice()}))},dt.rationalBezierCurve=function(r,n){for(var i=r.length-1,l=[],u=0,d=i+1;u<d;)u++,l.push(0);for(var p=0,_=i+1;p<_;)p++,l.push(1);return n==null&&(n=m.rep(r.length,1)),new Ft(i,l,C.homogenize1d(r,n))},dt.fourPointSurface=function(r,n,i,l,u){u==null&&(u=3);for(var d=u,p=[],_=0,v=u+1;_<v;){for(var w=_++,P=[],A=0,I=u+1;A<I;){var E=A++,T=1-w/d,L=m.lerp(T,r,n),N=m.lerp(T,l,i),R=m.lerp(1-E/d,L,N);R.push(1),P.push(R)}p.push(P)}var O=m.rep(u+1,0),F=m.rep(u+1,1);return new Jt(u,u,O.concat(F),O.concat(F),p)},dt.ellipseArc=function(r,n,i,l,u){var d=m.norm(n),p=m.norm(i);n=m.normalized(n),i=m.normalized(i),u<l&&(u=2*Math.PI+l);var _=u-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),i))),I=m.sub(m.mul(Math.cos(l),i),m.mul(Math.sin(l),n)),E=[],T=m.zeros1d(2*v+3),L=0,N=l,R=m.zeros1d(v*2);E[0]=A,R[0]=1;for(var O=1,F=v+1;O<F;){var V=O++;N+=w;var H=m.add(r,m.add(m.mul(d*Math.cos(N),n),m.mul(p*Math.sin(N),i)));R[L+2]=1,E[L+2]=H;var J=m.sub(m.mul(Math.cos(N),i),m.mul(Math.sin(N),n)),G=at.rays(A,m.mul(1/m.norm(I),I),H,m.mul(1/m.norm(J),J)),j=m.add(A,m.mul(G.u0,I));R[L+1]=P,E[L+1]=j,L+=2,V<v&&(A=H,I=J)}for(var Y=2*v+1,tt=0;tt<3;){var et=tt++;T[et]=0,T[et+Y]=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 Ft(2,T,C.homogenize1d(E,R))},dt.arc=function(r,n,i,l,u,d){return dt.ellipseArc(r,m.mul(l,m.normalized(n)),m.mul(l,m.normalized(i)),u,d)},dt.polyline=function(r){for(var n=[0,0],i=0,l=0,u=r.length-1;l<u;){var d=l++;i+=m.dist(r[d],r[d+1]),n.push(i)}n.push(i),n=m.mul(1/i,n);for(var p,_=[],v=0,w=r.length;v<w;)v++,_.push(1);return p=_,new Ft(1,n,C.homogenize1d(r.slice(0),p))},dt.extrudedSurface=function(r,n,i){for(var l=[[],[],[]],u=[[],[],[]],d=C.dehomogenize1d(i.controlPoints),p=C.weight1d(i.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]),u[0][A]=p[A],u[1][A]=p[A],u[2][A]=p[A]}return new Jt(2,i.degree,[0,0,0,1,1,1],i.knots,C.homogenize2d(l,u))},dt.cylindricalSurface=function(r,n,i,l,u){var d=m.cross(r,n),p=dt.arc(i,n,d,u,0,2*Math.PI);return dt.extrudedSurface(r,l,p)},dt.revolvedSurface=function(r,n,i,l){var u=C.dehomogenize1d(r.controlPoints),d=C.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),E=0,T=m.zeros1d(p+1),L=m.zeros1d(p+1),N=m.zeros3d(2*p+1,u.length,3),R=m.zeros2d(2*p+1,u.length),O=1,F=p+1;O<F;){var V=O++;E+=v,L[V]=Math.cos(E),T[V]=Math.sin(E)}for(var H=0,J=u.length;H<J;){var G=H++,j=Ee.rayClosestPoint(u[G],n,i),Y=m.sub(u[G],j),tt=m.norm(Y),et=m.cross(i,Y);tt>rt.EPSILON&&(Y=m.mul(1/tt,Y),et=m.mul(1/tt,et)),N[0][G]=u[G];var st=u[G];R[0][G]=d[G];for(var ot=et,it=0,ht=1,nt=p+1;ht<nt;){var ct=ht++,q;tt==0?q=j:q=m.add(j,m.add(m.mul(tt*L[ct],Y),m.mul(tt*T[ct],et))),N[it+2][G]=q,R[it+2][G]=d[G];var pt=m.sub(m.mul(L[ct],et),m.mul(T[ct],Y));if(tt==0)N[it+1][G]=j;else{var At=at.rays(st,m.mul(1/m.norm(ot),ot),q,m.mul(1/m.norm(pt),pt)),Vt=m.add(st,m.mul(At.u0,ot));N[it+1][G]=Vt}R[it+1][G]=I*d[G],it+=2,ct<p&&(st=q,ot=pt)}}return new Jt(2,r.degree,_,r.knots,C.homogenize2d(N,R))},dt.sphericalSurface=function(r,n,i,l){var u=dt.arc(r,m.mul(-1,n),i,l,0,Math.PI);return dt.revolvedSurface(u,r,n,2*Math.PI)},dt.conicalSurface=function(r,n,i,l,u){var d=2*Math.PI,p=1,_=[m.add(i,m.mul(l,r)),m.add(i,m.mul(u,n))],v=[0,0,1,1],w=[1,1],P=new Ft(p,v,C.homogenize1d(_,w));return dt.revolvedSurface(P,i,r,d)},dt.rationalInterpCurve=function(r,n,i,l,u){if(i==null&&(i=!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,E=d.length;I<E;){var T=I++;d[T]=d[T]/A}var L=m.rep(n+1,0),N=l!=null&&u!=null,R;N?R=0:R=1;var O;N?O=d.length-n+1:O=d.length-n;for(var F=R;F<O;){for(var V=F++,H=0,J=0;J<n;){var G=J++;H+=d[V+G]}L.push(1/n*H)}var j=L.concat(m.rep(n+1,1)),Y=[],tt;N?tt=r.length+1:tt=r.length-1;var et;N?et=r.length-(n-1):et=r.length-(n+1);for(var st=0;st<d.length;){var ot=d[st];++st;var it=C.knotSpanGivenN(tt,n,ot,j),ht=C.basisFunctionsGivenKnotSpanIndex(it,ot,n,j),nt=it-n,ct=m.zeros1d(nt),q=m.zeros1d(et-nt);Y.push(ct.concat(ht).concat(q))}if(N){var pt=Y[0].length-2,At=[-1,1].concat(m.zeros1d(pt)),Vt=m.zeros1d(pt).concat([-1,1]);K.spliceAndInsert(Y,1,0,At),K.spliceAndInsert(Y,Y.length-1,0,Vt)}for(var qt=r[0].length,Rt=[],Yt=(1-j[j.length-n-2])/n,Ae=j[n+1]/n,Ue=0;Ue<qt;){var ve=[Ue++],ge;if(!N)ge=r.map(function(Xe){return function(hr){return hr[Xe[0]]}}(ve));else{ge=[r[0][ve[0]]],ge.push(Ae*l[ve[0]]);for(var Pe=1,Te=r.length-1;Pe<Te;){var qe=Pe++;ge.push(r[qe][ve[0]])}ge.push(Yt*u[ve[0]]),ge.push(K.last(r)[ve[0]])}var sr=Ct.solve(Y,ge);Rt.push(sr)}var Ye=Ct.transpose(Rt);if(!i){var Ke=m.rep(Ye.length,1);Ye=C.homogenize1d(Ye,Ke)}return new Ft(n,j,Ye)};var _t=f.eval.Modify=function(){};x["verb.eval.Modify"]=_t,_t.__name__=["verb","eval","Modify"],_t.curveReverse=function(r){return new Ft(r.degree,_t.knotsReverse(r.knots),K.reversed(r.controlPoints))},_t.surfaceReverse=function(r,n){return n==null&&(n=!1),n?new Jt(r.degreeU,r.degreeV,r.knotsU,_t.knotsReverse(r.knotsV),function(i){for(var l,u=[],d=0,p=r.controlPoints;d<p.length;){var _=p[d];++d,u.push(K.reversed(_))}return l=u,l}()):new Jt(r.degreeU,r.degreeV,_t.knotsReverse(r.knotsU),r.knotsV,K.reversed(r.controlPoints))},_t.knotsReverse=function(r){var n=K.first(r);K.last(r);for(var i=[n],l=r.length,u=1;u<l;){var d=u++;i.push(i[d-1]+(r[l-d]-r[l-d-1]))}return i},_t.unifyCurveKnotVectors=function(r){r=r.map(dt.clonedCurve);for(var n=z.fold(r,function(j,Y){return _t.imax(j.degree,Y)},0),i=0,l=r.length;i<l;){var u=i++;r[u].degree<n&&(r[u]=_t.curveElevateDegree(r[u],n))}for(var d,p=[],_=0;_<r.length;){var v=r[_];++_,p.push(new we(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(Y){return Y-j[0]}}(I))}for(var E=d.map(function(j){return j.max-j.min}),T=z.fold(E,function(j,Y){return Math.max(j,Y)},0),L=0,N=r.length;L<N;){var R=L++,O=[T/E[R]];r[R].knots=r[R].knots.map(function(j){return function(Y){return Y*j[0]}}(O))}for(var F=z.fold(r,function(j,Y){return m.sortedSetUnion(j.knots,Y)},[]),V=0,H=r.length;V<H;){var J=V++,G=m.sortedSetSub(F,r[J].knots);G.length==0&&(r[J]=r[J]),r[J]=_t.curveKnotRefine(r[J],G)}return r},_t.imin=function(r,n){return r<n?r:n},_t.imax=function(r,n){return r>n?r:n},_t.curveElevateDegree=function(r,n){if(n<=r.degree)return r;var i=r.knots.length-r.degree-2,l=r.degree,u=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=i+l+1,E=n,T=Math.floor(E/2),L=[],N=[];v[0][0]=1,v[E][l]=1;for(var R=1,O=T+1;R<O;)for(var F=R++,V=1/zt.get(E,F),H=_t.imin(l,F),J=_t.imax(0,F-p),G=H+1;J<G;){var j=J++;v[F][j]=V*zt.get(l,j)*zt.get(p,F-j)}for(var Y=T+1;Y<E;)for(var tt=Y++,et=_t.imin(l,tt),st=_t.imax(0,tt-p),ot=et+1;st<ot;){var it=st++;v[tt][it]=v[E-tt][l-it]}var ht=E+1,nt=-1,ct=l,q=l+1,pt=1,At=u[0];L[0]=d[0];for(var Vt=0,qt=E+1;Vt<qt;){var Rt=Vt++;N[Rt]=At}for(var Yt=0,Ae=l+1;Yt<Ae;){var Ue=Yt++;w[Ue]=d[Ue]}for(;q<I;){for(var ve=q;q<I&&u[q]==u[q+1];)q=q+1;var ge=q-ve+1,Pe=u[q],Te=nt;nt=l-ge;var qe;Te>0?qe=Math.floor((Te+2)/2):qe=1;var sr;if(nt>0?sr=Math.floor(E-(nt+1)/2):sr=E,nt>0){for(var Ye=Pe-At,Ke=[],Xe=l;Xe>ge;)Ke[Xe-ge-1]=Ye/(u[ct+Xe]-At),Xe--;for(var hr=1,bn=nt+1;hr<bn;){for(var Gr=hr++,nu=nt-Gr,Mi=ge+Gr,Wr=l;Wr>=Mi;)w[Wr]=m.add(m.mul(Ke[Wr-Mi],w[Wr]),m.mul(1-Ke[Wr-Mi],w[Wr-1])),Wr--;A[nu]=w[l]}}for(var no=qe,su=E+1;no<su;){var xn=no++;P[xn]=m.zeros1d(_);for(var iu=_t.imin(l,xn),so=_t.imax(0,xn-p),au=iu+1;so<au;){var io=so++;P[xn]=m.add(P[xn],m.mul(v[xn][io],w[io]))}}if(Te>1)for(var Ti=ht-2,Ci=ht,ao=Pe-At,ou=(Pe-N[ht-1])/ao,oo=1;oo<Te;){for(var Ni=oo++,ur=Ti,Hr=Ci,Nr=Hr-ht+1;Hr-ur>Ni;){if(ur<pt){var lu=(Pe-N[ur])/(At-N[ur]);L[ur]=m.lerp(lu,L[ur],L[ur-1])}if(Hr>=qe){if(Hr-Ni<=ht-E+Te){var hu=(Pe-N[Hr-Ni])/ao;P[Nr]=m.lerp(hu,P[Nr],P[Nr+1])}}else P[Nr]=m.lerp(ou,P[Nr],P[Nr+1]);ur=ur+1,Hr=Hr-1,Nr=Nr-1}Ti=Ti-1,Ci=Ci+1}if(ct!=l)for(var lo=0,uu=E-Te;lo<uu;)lo++,N[ht]=At,ht=ht+1;for(var ho=qe,cu=sr+1;ho<cu;){var du=ho++;L[pt]=P[du],pt=pt+1}if(q<I){for(var uo=0;uo<nt;){var co=uo++;w[co]=A[co]}for(var mo=nt,mu=l+1;mo<mu;){var po=mo++;w[po]=d[q-l+po]}ct=q,q=q+1,At=Pe}else for(var go=0,pu=E+1;go<pu;){var gu=go++;N[ht+gu]=Pe}}return new Ft(n,N,L)},_t.rationalSurfaceTransform=function(r,n){for(var i=C.dehomogenize2d(r.controlPoints),l=0,u=i.length;l<u;)for(var d=l++,p=0,_=i[d].length;p<_;){var v=p++,w=i[d][v];w.push(1),i[d][v]=Ct.dot(n,w).slice(0,w.length-1)}return new Jt(r.degreeU,r.degreeV,r.knotsU.slice(),r.knotsV.slice(),C.homogenize2d(i,C.weight2d(r.controlPoints)))},_t.rationalCurveTransform=function(r,n){for(var i=C.dehomogenize1d(r.controlPoints),l=0,u=i.length;l<u;){var d=l++,p=i[d];p.push(1),i[d]=Ct.dot(n,p).slice(0,p.length-1)}return new Ft(r.degree,r.knots.slice(),C.homogenize1d(i,C.weight1d(r.controlPoints)))},_t.surfaceKnotRefine=function(r,n,i){var l=[],u,d,p;i?(p=r.controlPoints,u=r.knotsV,d=r.degreeV):(p=Ct.transpose(r.controlPoints),u=r.knotsU,d=r.degreeU);for(var _=null,v=0;v<p.length;){var w=p[v];++v,_=_t.curveKnotRefine(new Ft(d,u,w),n),l.push(_.controlPoints)}var P=_.knots;return i?new Jt(r.degreeU,r.degreeV,r.knotsU.slice(),P,l):(l=Ct.transpose(l),new Jt(r.degreeU,r.degreeV,P,r.knotsV.slice(),l))},_t.decomposeCurveIntoBeziers=function(r){for(var n=r.degree,i=r.controlPoints,l=r.knots,u=yt.knotMultiplicities(l),d=n+1,p=0;p<u.length;){var _=u[p];if(++p,_.mult<d){var v=m.rep(d-_.mult,_.knot),w=_t.curveKnotRefine(new Ft(n,l,i),v);l=w.knots,i=w.controlPoints}}l.length/d-1;for(var P=d*2,A=[],I=0;I<i.length;){var E=l.slice(I,I+P),T=i.slice(I,I+d);A.push(new Ft(n,E,T)),I+=d}return A},_t.curveKnotRefine=function(r,n){if(n.length==0)return dt.clonedCurve(r);for(var i=r.degree,l=r.controlPoints,u=r.knots,d=l.length-1,p=d+i+1,_=n.length-1,v=C.knotSpan(i,n[0],u),w=C.knotSpan(i,n[_],u),P=[],A=[],I=0,E=v-i+1;I<E;){var T=I++;P[T]=l[T]}for(var L=w-1,N=d+1;L<N;){var R=L++;P[R+_+1]=l[R]}for(var O=0,F=v+1;O<F;){var V=O++;A[V]=u[V]}for(var H=w+i,J=p+1;H<J;){var G=H++;A[G+_+1]=u[G]}for(var j=w+i-1,Y=w+i+_,tt=_;tt>=0;){for(;n[tt]<=u[j]&&j>v;)P[Y-i-1]=l[j-i-1],A[Y]=u[j],Y=Y-1,j=j-1;P[Y-i-1]=P[Y-i];for(var et=1,st=i+1;et<st;){var ot=et++,it=Y-i+ot,ht=A[Y+ot]-n[tt];Math.abs(ht)<rt.EPSILON?P[it-1]=P[it]:(ht=ht/(A[Y+ot]-u[j-i+ot]),P[it-1]=m.add(m.mul(ht,P[it-1]),m.mul(1-ht,P[it])))}A[Y]=n[tt],Y=Y-1,tt--}return new Ft(i,A,P)},_t.curveKnotInsert=function(r,n,i){for(var l=r.degree,u=r.controlPoints,d=r.knots,p=0,_=u.length,v=C.knotSpan(l,n,d),w=[],P=[],A=[],I=1,E=v+1;I<E;){var T=I++;P[T]=d[T]}for(var L=1,N=i+1;L<N;){var R=L++;P[v+R]=n}for(var O=v+1,F=d.length;O<F;){var V=O++;P[V+i]=d[V]}for(var H=0,J=v-l+1;H<J;){var G=H++;A[G]=u[G]}for(var j=v-p;j<_;){var Y=j++;A[Y+i]=u[Y]}for(var tt=0,et=l-p+1;tt<et;){var st=tt++;w[st]=u[v-l+st]}for(var ot=0,it=0,ht=1,nt=i+1;ht<nt;){var ct=ht++;ot=v-l+ct;for(var q=0,pt=l-ct-p+1;q<pt;){var At=q++;it=(n-d[ot+At])/(d[At+v+1]-d[ot+At]),w[At]=m.add(m.mul(it,w[At+1]),m.mul(1-it,w[At]))}A[ot]=w[0],A[v+i-ct-p]=w[l-ct-p]}for(var Vt=ot+1,qt=v-p;Vt<qt;){var Rt=Vt++;A[Rt]=w[Rt-ot]}return new Ft(l,P,A)};var Ot=f.eval.Tess=function(){};x["verb.eval.Tess"]=Ot,Ot.__name__=["verb","eval","Tess"],Ot.rationalCurveRegularSample=function(r,n,i){return Ot.rationalCurveRegularSampleRange(r,r.knots[0],K.last(r.knots),n,i)},Ot.rationalCurveRegularSampleRange=function(r,n,i,l,u){l<1&&(l=2);for(var d=[],p=(i-n)/(l-1),_=0,v=0;v<l;){var w=v++;_=n+p*w,u?d.push([_].concat(C.rationalCurvePoint(r,_))):d.push(C.rationalCurvePoint(r,_))}return d},Ot.rationalCurveAdaptiveSample=function(r,n,i){if(i==null&&(i=!1),n==null&&(n=1e-6),r.degree==1)if(i){for(var l=[],u=0,d=r.controlPoints.length;u<d;){var p=u++;l.push([r.knots[p+1]].concat(C.dehomogenize(r.controlPoints[p])))}return l}else return r.controlPoints.map(C.dehomogenize);return Ot.rationalCurveAdaptiveSampleRange(r,r.knots[0],K.last(r.knots),n,i)},Ot.rationalCurveAdaptiveSampleRange=function(r,n,i,l,u){var d=C.rationalCurvePoint(r,n),p=C.rationalCurvePoint(r,i),_=.5+.2*Math.random(),v=n+(i-n)*_,w=C.rationalCurvePoint(r,v),P=m.sub(d,p),A=m.sub(d,w);if(m.dot(P,P)<l&&m.dot(A,A)>l||!Ee.threePointsAreFlat(d,w,p,l)){var I=n+(i-n)*.5,E=Ot.rationalCurveAdaptiveSampleRange(r,n,I,l,u),T=Ot.rationalCurveAdaptiveSampleRange(r,I,i,l,u);return E.slice(0,-1).concat(T)}else return u?[[n].concat(d),[i].concat(p)]:[d,p]},Ot.rationalSurfaceNaive=function(r,n,i){n<1&&(n=1),i<1&&(i=1),r.degreeU,r.degreeV,r.controlPoints;for(var l=r.knotsU,u=r.knotsV,d=K.last(l)-l[0],p=K.last(u)-u[0],_=d/n,v=p/i,w=[],P=[],A=[],I=0,E=n+1;I<E;)for(var T=I++,L=0,N=i+1;L<N;){var R=L++,O=T*_,F=R*v;P.push([O,F]);var V=C.rationalSurfaceDerivatives(r,O,F,1),H=V[0][0];w.push(H);var J=m.normalized(m.cross(V[1][0],V[0][1]));A.push(J)}for(var G=[],j=0;j<n;)for(var Y=j++,tt=0;tt<i;){var et=tt++,st=Y*(i+1)+et,ot=(Y+1)*(i+1)+et,it=ot+1,ht=st+1,nt=[st,ot,it],ct=[st,it,ht];G.push(nt),G.push(ct)}return new Ge(G,w,A,P)},Ot.divideRationalSurfaceAdaptive=function(r,n){n==null&&(n=new kr),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 i=(r.controlPoints.length-1)*2,l=(r.controlPoints[0].length-1)*2,u;n.minDivsU>i?u=n.minDivsU=n.minDivsU:u=n.minDivsU=i;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-_)/u,A=(v-w)/d,I=[],E=[],T=0,L=d+1;T<L;){for(var N=T++,R=[],O=0,F=u+1;O<F;){var V=O++,H=_+P*V,J=w+A*N,G=C.rationalSurfaceDerivatives(r,H,J,1),j=m.normalized(m.cross(G[0][1],G[1][0]));R.push(new Fe(G[0][0],j,[H,J],-1,m.isZero(j)))}E.push(R)}for(var Y=0;Y<d;)for(var tt=Y++,et=0;et<u;){var st=et++,ot=[E[d-tt-1][st],E[d-tt-1][st+1],E[d-tt][st+1],E[d-tt][st]];I.push(new lr(r,ot))}if(!n.refine)return I;for(var it=0;it<d;)for(var ht=it++,nt=0;nt<u;){var ct=nt++,q=ht*u+ct,pt=Ot.north(q,ht,ct,u,d,I),At=Ot.east(q,ht,ct,u,d,I),Vt=Ot.south(q,ht,ct,u,d,I),qt=Ot.west(q,ht,ct,u,d,I);I[q].neighbors=[Vt,At,pt,qt],I[q].divide(n)}return I},Ot.north=function(r,n,i,l,u,d){return n==0?null:d[r-l]},Ot.south=function(r,n,i,l,u,d){return n==u-1?null:d[r+l]},Ot.east=function(r,n,i,l,u,d){return i==l-1?null:d[r+1]},Ot.west=function(r,n,i,l,u,d){return i==0?null:d[r-1]},Ot.triangulateAdaptiveRefinementNodeTree=function(r){for(var n=Ge.empty(),i=0;i<r.length;){var l=r[i];++i,l.triangulate(n)}return n},Ot.rationalSurfaceAdaptive=function(r,n){n!=null?n=n:n=new kr;var i=Ot.divideRationalSurfaceAdaptive(r,n);return Ot.triangulateAdaptiveRefinementNodeTree(i)};var kr=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"]=kr,kr.__name__=["verb","eval","AdaptiveRefinementOptions"],kr.prototype={__class__:kr};var lr=f.core.AdaptiveRefinementNode=function(r,n,i){if(this.srf=r,i==null?this.neighbors=[null,null,null,null]:this.neighbors=i,this.corners=n,this.corners==null){var l=r.knotsU[0],u=K.last(r.knotsU),d=r.knotsV[0],p=K.last(r.knotsV);this.corners=[Fe.fromUv(l,d),Fe.fromUv(u,d),Fe.fromUv(u,p),Fe.fromUv(l,p)]}};x["verb.eval.AdaptiveRefinementNode"]=lr,lr.__name__=["verb","eval","AdaptiveRefinementNode"],lr.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 i=this.corners[n];this.evalSrf(i.uv[0],i.uv[1],i)}}},evalSrf:function(r,n,i){var l=C.rationalSurfaceDerivatives(this.srf,r,n,1),u=l[0][0],d=m.cross(l[0][1],l[1][0]),p=m.isZero(d);return p||(d=m.normalized(d)),i!=null?(i.degen=p,i.point=u,i.normal=d,i):new Fe(u,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 i=this.neighbors[r].getEdgeCorners((r+2)%4),l=r%2,u=rt.EPSILON,d=this,p=[function(v){return v.uv[0]>d.corners[0].uv[0]+u&&v.uv[0]<d.corners[2].uv[0]-u},function(v){return v.uv[1]>d.corners[0].uv[1]+u&&v.uv[1]<d.corners[2].uv[1]-u}],_=i.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 i=n++;if(this.corners[i],this.corners[i].degen){var l=this.corners[(i+1)%r],u=this.corners[(i+3)%r];l.degen?this.corners[i].normal=u.normal:this.corners[i].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 i=this.center();return m.normSquared(m.sub(i.normal,this.corners[0].normal))>r.normTol||m.normSquared(m.sub(i.normal,this.corners[1].normal))>r.normTol||m.normSquared(m.sub(i.normal,this.corners[2].normal))>r.normTol||m.normSquared(m.sub(i.normal,this.corners[3].normal))>r.normTol},divide:function(r){r==null&&(r=new kr),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,i){if(this.evalCorners(),!!this.shouldDivide(r,n)){if(n++,this.splitVert&&!this.splitHoriz?i=!1:!this.splitVert&&this.splitHoriz&&(i=!0),this.horizontal=i,this.horizontal){var l=[this.corners[0],this.corners[1],this.midpoint(1),this.midpoint(3)],u=[this.midpoint(3),this.midpoint(1),this.corners[2],this.corners[3]];this.children=[new lr(this.srf,l),new lr(this.srf,u)],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 lr(this.srf,d),new lr(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,!i)}}},triangulate:function(r){if(r==null&&(r=Ge.empty()),this.isLeaf())return this.triangulateLeaf(r);for(var n=0,i=this.children;n<i.length;){var l=i[n];if(++n,l==null)break;l.triangulate(r)}return r},triangulateLeaf:function(r){for(var n=r.points.length,i=[],l=[],u=0,d=0;d<4;){var p=d++,_=this.getAllCorners(p);_.length==2&&(u=p+1);for(var v=0,w=_.length;v<w;){var P=v++;i.push(_[P])}}for(var A=0;A<i.length;){var I=i[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(i.length==4)return r.faces.push([l[0],l[3],l[1]]),r.faces.push([l[3],l[2],l[1]]),r;if(i.length==5){var E=l.length;return r.faces.push([l[u],l[(u+2)%E],l[(u+1)%E]]),r.faces.push([l[(u+4)%E],l[(u+3)%E],l[u]]),r.faces.push([l[u],l[(u+3)%E],l[(u+2)%E]]),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,N=0,R=i.length-1;N<i.length;)r.faces.push([L,l[N],l[R]]),R=N++;return r},__class__:lr};var xt=f.exe.Dispatcher=function(){};x["verb.exe.Dispatcher"]=xt,xt.__name__=["verb","exe","Dispatcher"],xt.init=function(){xt._init||(xt._workerPool=new Er(xt.THREADS),xt._init=!0)},xt.dispatchMethod=function(r,n,i){xt.init();var l=new hn,u=function(d){l.resolve(d)};return xt._workerPool.addWork(mt.getClassName(r),n,i,u),new pe(l)};var Er=f.exe.WorkerPool=function(r,n){n==null&&(n="verb.js"),r==null&&(r=1),this._callbacks=new bt,this._working=new bt,this._pool=[],this._queue=[];for(var i=0;i<r;){i++;var l;try{l=new Worker(Er.basePath+n)}catch(u){u instanceof Q&&(u=u.val),l=new Worker(Er.basePath+n.substring(0,-3)+".min.js")}this._pool.push(l)}};x["verb.exe.WorkerPool"]=Er,Er.__name__=["verb","exe","WorkerPool"],Er.prototype={addWork:function(r,n,i,l){var u=new jr(r,n,i);this._callbacks.set(u.id,l),this._queue.push(u),this.processQueue()},processQueue:function(){for(var r=this;this._queue.length>0&&this._pool.length>0;){var n=this._queue.shift(),i=[n.id],l=[this._pool.shift()];this._working.h[i[0]]=l[0],l[0].onmessage=function(u,d){return function(p){r._working.remove(d[0]),r._pool.push(u[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,i),l[0].postMessage(n)}},__class__:Er};var jr=function(r,n,i){this.className=r,this.methodName=n,this.args=i,this.id=jr.uuid++};x["verb.exe._WorkerPool.Work"]=jr,jr.__name__=["verb","exe","_WorkerPool","Work"],jr.prototype={__class__:jr};var vn=function(){};x["verb.geom.ICurve"]=vn,vn.__name__=["verb","geom","ICurve"],vn.__interfaces__=[gn],vn.prototype={__class__:vn};var Et=f.geom.NurbsCurve=function(r){this._data=Ve.isValidNurbsCurveData(r)};x["verb.geom.NurbsCurve"]=Et,Et.__name__=["verb","geom","NurbsCurve"],Et.__interfaces__=[vn],Et.byKnotsControlPointsWeights=function(r,n,i,l){return new Et(new Ft(r,n.slice(),C.homogenize1d(i,l)))},Et.byPoints=function(r,n){return n==null&&(n=3),new Et(dt.rationalInterpCurve(r,n))},Et.__super__=$t,Et.prototype=M($t.prototype,{degree:function(){return this._data.degree},knots:function(){return this._data.knots.slice(0)},controlPoints:function(){return C.dehomogenize1d(this._data.controlPoints)},weights:function(){return C.weight1d(this._data.controlPoints)},asNurbs:function(){return new Ft(this.degree(),this.knots(),C.homogenize1d(this.controlPoints(),this.weights()))},clone:function(){return new Et(this._data)},domain:function(){return new we(K.first(this._data.knots),K.last(this._data.knots))},transform:function(r){return new Et(_t.rationalCurveTransform(this._data,r))},transformAsync:function(r){return xt.dispatchMethod(_t,"rationalCurveTransform",[this._data,r]).then(function(n){return new Et(n)})},point:function(r){return C.rationalCurvePoint(this._data,r)},pointAsync:function(r){return xt.dispatchMethod(C,"rationalCurvePoint",[this._data,r])},tangent:function(r){return C.rationalCurveTangent(this._data,r)},tangentAsync:function(r){return xt.dispatchMethod(C,"rationalCurveTangent",[this._data,r])},derivatives:function(r,n){return n==null&&(n=1),C.rationalCurveDerivatives(this._data,r,n)},derivativesAsync:function(r,n){return n==null&&(n=1),xt.dispatchMethod(C,"rationalCurveDerivatives",[this._data,r,n])},closestPoint:function(r){return yt.rationalCurveClosestPoint(this._data,r)},closestPointAsync:function(r){return xt.dispatchMethod(yt,"rationalCurveClosestPoint",[this._data,r])},closestParam:function(r){return yt.rationalCurveClosestParam(this._data,r)},closestParamAsync:function(r){return xt.dispatchMethod(yt,"rationalCurveClosestParam",[this._data,r])},length:function(){return yt.rationalCurveArcLength(this._data)},lengthAsync:function(){return xt.dispatchMethod(yt,"rationalCurveArcLength",[this._data])},lengthAtParam:function(r){return yt.rationalCurveArcLength(this._data,r)},lengthAtParamAsync:function(){return xt.dispatchMethod(yt,"rationalCurveArcLength",[this._data])},paramAtLength:function(r,n){return yt.rationalCurveParamAtArcLength(this._data,r,n)},paramAtLengthAsync:function(r,n){return xt.dispatchMethod(yt,"rationalCurveParamAtArcLength",[this._data,r,n])},divideByEqualArcLength:function(r){return le.rationalCurveByEqualArcLength(this._data,r)},divideByEqualArcLengthAsync:function(r){return xt.dispatchMethod(le,"rationalCurveByEqualArcLength",[this._data,r])},divideByArcLength:function(r){return le.rationalCurveByArcLength(this._data,r)},divideByArcLengthAsync:function(r){return xt.dispatchMethod(le,"rationalCurveByArcLength",[this._data,r])},split:function(r){return le.curveSplit(this._data,r).map(function(n){return new Et(n)})},splitAsync:function(r){return xt.dispatchMethod(le,"curveSplit",[this._data,r]).then(function(n){return n.map(function(i){return new Et(i)})})},reverse:function(){return new Et(_t.curveReverse(this._data))},reverseAsync:function(){return xt.dispatchMethod(_t,"curveReverse",[this._data]).then(function(r){return new Et(r)})},tessellate:function(r){return Ot.rationalCurveAdaptiveSample(this._data,r,!1)},tessellateAsync:function(r){return xt.dispatchMethod(Ot,"rationalCurveAdaptiveSample",[this._data,r,!1])},__class__:Et});var Mr=f.geom.Arc=function(r,n,i,l,u,d){Et.call(this,dt.arc(r,n,i,l,u,d)),this._center=r,this._xaxis=n,this._yaxis=i,this._radius=l,this._minAngle=u,this._maxAngle=d};x["verb.geom.Arc"]=Mr,Mr.__name__=["verb","geom","Arc"],Mr.__super__=Et,Mr.prototype=M(Et.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__:Mr});var jn=f.geom.BezierCurve=function(r,n){Et.call(this,dt.rationalBezierCurve(r,n))};x["verb.geom.BezierCurve"]=jn,jn.__name__=["verb","geom","BezierCurve"],jn.__super__=Et,jn.prototype=M(Et.prototype,{__class__:jn});var Gn=f.geom.Circle=function(r,n,i,l){Mr.call(this,r,n,i,l,0,Math.PI*2)};x["verb.geom.Circle"]=Gn,Gn.__name__=["verb","geom","Circle"],Gn.__super__=Mr,Gn.prototype=M(Mr.prototype,{__class__:Gn});var yn=function(){};x["verb.geom.ISurface"]=yn,yn.__name__=["verb","geom","ISurface"],yn.__interfaces__=[gn],yn.prototype={__class__:yn};var Pt=f.geom.NurbsSurface=function(r){this._data=Ve.isValidNurbsSurfaceData(r)};x["verb.geom.NurbsSurface"]=Pt,Pt.__name__=["verb","geom","NurbsSurface"],Pt.__interfaces__=[yn],Pt.byKnotsControlPointsWeights=function(r,n,i,l,u,d){return new Pt(new Jt(r,n,i,l,C.homogenize2d(u,d)))},Pt.byCorners=function(r,n,i,l){return new Pt(dt.fourPointSurface(r,n,i,l))},Pt.byLoftingCurves=function(r,n){return new Pt(dt.loftedSurface(function(i){for(var l,u=[],d=0;d<r.length;){var p=r[d];++d,u.push(p.asNurbs())}return l=u,l}(),n))},Pt.__super__=$t,Pt.prototype=M($t.prototype,{degreeU:function(){return this._data.degreeU},degreeV:function(){return this._data.degreeV},knotsU:function(){return this._data.knotsU.slice(0)},knotsV:function(){return this._data.knotsV.slice(0)},controlPoints:function(){return C.dehomogenize2d(this._data.controlPoints)},weights:function(){return C.weight2d(this._data.controlPoints)},asNurbs:function(){return new Jt(this.degreeU(),this.degreeV(),this.knotsU(),this.knotsV(),C.homogenize2d(this.controlPoints(),this.weights()))},clone:function(){return new Pt(this.asNurbs())},domainU:function(){return new we(K.first(this._data.knotsU),K.last(this._data.knotsU))},domainV:function(){return new we(K.first(this._data.knotsV),K.last(this._data.knotsV))},point:function(r,n){return C.rationalSurfacePoint(this._data,r,n)},pointAsync:function(r,n){return xt.dispatchMethod(C,"rationalSurfacePoint",[this._data,r,n])},normal:function(r,n){return C.rationalSurfaceNormal(this._data,r,n)},normalAsync:function(r,n){return xt.dispatchMethod(C,"rationalSurfaceNormal",[this._data,r,n])},derivatives:function(r,n,i){return i==null&&(i=1),C.rationalSurfaceDerivatives(this._data,r,n,i)},derivativesAsync:function(r,n,i){return i==null&&(i=1),xt.dispatchMethod(C,"rationalSurfaceDerivatives",[this._data,r,n,i])},closestParam:function(r){return yt.rationalSurfaceClosestParam(this._data,r)},closestParamAsync:function(r){return xt.dispatchMethod(yt,"rationalSurfaceClosestParam",[this._data,r])},closestPoint:function(r){return yt.rationalSurfaceClosestPoint(this._data,r)},closestPointAsync:function(r){return xt.dispatchMethod(yt,"rationalSurfaceClosestPoint",[this._data,r])},split:function(r,n){return n==null&&(n=!1),le.surfaceSplit(this._data,r,n).map(function(i){return new Pt(i)})},splitAsync:function(r,n){return n==null&&(n=!1),xt.dispatchMethod(le,"surfaceSplit",[this._data,r,n]).then(function(i){return i.map(function(l){return new Pt(l)})})},reverse:function(r){return r==null&&(r=!1),new Pt(_t.surfaceReverse(this._data,r))},reverseAsync:function(r){return r==null&&(r=!1),xt.dispatchMethod(_t,"surfaceReverse",[this._data,r]).then(function(n){return new Pt(n)})},isocurve:function(r,n){return n==null&&(n=!1),new Et(dt.surfaceIsocurve(this._data,r,n))},isocurveAsync:function(r,n){return n==null&&(n=!1),xt.dispatchMethod(dt,"surfaceIsocurve",[this._data,r,n]).then(function(i){return new Et(i)})},boundaries:function(r){return dt.surfaceBoundaryCurves(this._data).map(function(n){return new Et(n)})},boundariesAsync:function(r){return xt.dispatchMethod(dt,"surfaceBoundaryCurves",[this._data]).then(function(n){return n.map(function(i){return new Et(i)})})},tessellate:function(r){return Ot.rationalSurfaceAdaptive(this._data,r)},tessellateAsync:function(r){return xt.dispatchMethod(Ot,"rationalSurfaceAdaptive",[this._data,r])},transform:function(r){return new Pt(_t.rationalSurfaceTransform(this._data,r))},transformAsync:function(r){return xt.dispatchMethod(_t,"rationalSurfaceTransform",[this._data,r]).then(function(n){return new Pt(n)})},__class__:Pt});var Wn=f.geom.ConicalSurface=function(r,n,i,l,u){Pt.call(this,dt.conicalSurface(r,n,i,l,u)),this._axis=r,this._xaxis=n,this._base=i,this._height=l,this._radius=u};x["verb.geom.ConicalSurface"]=Wn,Wn.__name__=["verb","geom","ConicalSurface"],Wn.__super__=Pt,Wn.prototype=M(Pt.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__:Wn});var Hn=f.geom.CylindricalSurface=function(r,n,i,l,u){Pt.call(this,dt.cylindricalSurface(r,n,i,l,u)),this._axis=r,this._xaxis=n,this._base=i,this._height=l,this._radius=u};x["verb.geom.CylindricalSurface"]=Hn,Hn.__name__=["verb","geom","CylindricalSurface"],Hn.__super__=Pt,Hn.prototype=M(Pt.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__:Hn});var Tr=f.geom.EllipseArc=function(r,n,i,l,u){Et.call(this,dt.ellipseArc(r,n,i,l,u)),this._center=r,this._xaxis=n,this._yaxis=i,this._minAngle=l,this._maxAngle=u};x["verb.geom.EllipseArc"]=Tr,Tr.__name__=["verb","geom","EllipseArc"],Tr.__super__=Et,Tr.prototype=M(Et.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__:Tr});var qn=f.geom.Ellipse=function(r,n,i){Tr.call(this,r,n,i,0,Math.PI*2)};x["verb.geom.Ellipse"]=qn,qn.__name__=["verb","geom","Ellipse"],qn.__super__=Tr,qn.prototype=M(Tr.prototype,{__class__:qn});var Yn=f.geom.ExtrudedSurface=function(r,n){Pt.call(this,dt.extrudedSurface(m.normalized(n),m.norm(n),r.asNurbs())),this._profile=r,this._direction=n};x["verb.geom.ExtrudedSurface"]=Yn,Yn.__name__=["verb","geom","ExtrudedSurface"],Yn.__super__=Pt,Yn.prototype=M(Pt.prototype,{profile:function(){return this._profile},direction:function(){return this._direction},__class__:Yn});var Cr=f.geom.Intersect=function(){};x["verb.geom.Intersect"]=Cr,Cr.__name__=["verb","geom","Intersect"],Cr.curves=function(r,n,i){return i==null&&(i=.001),at.curves(r.asNurbs(),n.asNurbs(),i)},Cr.curvesAsync=function(r,n,i){return i==null&&(i=.001),xt.dispatchMethod(at,"curves",[r.asNurbs(),n.asNurbs(),i])},Cr.curveAndSurface=function(r,n,i){return i==null&&(i=.001),at.curveAndSurface(r.asNurbs(),n.asNurbs(),i)},Cr.curveAndSurfaceAsync=function(r,n,i){return i==null&&(i=.001),xt.dispatchMethod(at,"curveAndSurface",[r.asNurbs(),n.asNurbs(),i])},Cr.surfaces=function(r,n,i){return i==null&&(i=.001),at.surfaces(r.asNurbs(),n.asNurbs(),i).map(function(l){return new Et(l)})},Cr.surfacesAsync=function(r,n,i){return i==null&&(i=.001),xt.dispatchMethod(at,"surfaces",[r.asNurbs(),n.asNurbs(),i]).then(function(l){return l.map(function(u){return new Et(u)})})};var Kn=f.geom.Line=function(r,n){Et.call(this,dt.polyline([r,n])),this._start=r,this._end=n};x["verb.geom.Line"]=Kn,Kn.__name__=["verb","geom","Line"],Kn.__super__=Et,Kn.prototype=M(Et.prototype,{start:function(){return this._start},end:function(){return this._end},__class__:Kn});var Xn=f.geom.RevolvedSurface=function(r,n,i,l){Pt.call(this,dt.revolvedSurface(r.asNurbs(),n,i,l)),this._profile=r,this._center=n,this._axis=i,this._angle=l};x["verb.geom.RevolvedSurface"]=Xn,Xn.__name__=["verb","geom","RevolvedSurface"],Xn.__super__=Pt,Xn.prototype=M(Pt.prototype,{profile:function(){return this._profile},center:function(){return this._center},axis:function(){return this._center},angle:function(){return this._angle},__class__:Xn});var $n=f.geom.SphericalSurface=function(r,n){Pt.call(this,dt.sphericalSurface(r,[0,0,1],[1,0,0],n)),this._center=r,this._radius=n};x["verb.geom.SphericalSurface"]=$n,$n.__name__=["verb","geom","SphericalSurface"],$n.__super__=Pt,$n.prototype=M(Pt.prototype,{center:function(){return this._center},radius:function(){return this._radius},__class__:$n});var Zn=f.geom.SweptSurface=function(r,n){Pt.call(this,dt.rationalTranslationalSurface(r.asNurbs(),n.asNurbs())),this._profile=r,this._rail=n};x["verb.geom.SweptSurface"]=Zn,Zn.__name__=["verb","geom","SweptSurface"],Zn.__super__=Pt,Zn.prototype=M(Pt.prototype,{profile:function(){return this._profile},rail:function(){return this._rail},__class__:Zn});function He(r){return r instanceof Array?function(){return D.iter(r)}:typeof r.iterator=="function"?Me(r,r.iterator):r.iterator}var Ii,tu=0;function Me(r,n){if(n==null)return null;n.__id__==null&&(n.__id__=tu++);var i;return r.hx__closures__==null?r.hx__closures__={}:i=r.hx__closures__[n.__id__],i==null&&(i=function(){return i.method.apply(i.scope,arguments)},i.scope=r,i.method=n,r.hx__closures__[n.__id__]=i),i}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 eu=x.Int={__name__:["Int"]},ru=x.Dynamic={__name__:["Dynamic"]},Ja=x.Float=Number;Ja.__name__=["Float"];var to=x.Bool=Boolean;to.__ename__=["Bool"];var eo=x.Class={__name__:["Class"]},ro={};Array.prototype.map==null&&(Array.prototype.map=function(r){for(var n=[],i=0,l=this.length;i<l;){var u=i++;n[u]=r(this[u])}return n}),Array.prototype.filter==null&&(Array.prototype.filter=function(r){for(var n=[],i=0,l=this.length;i<l;){var u=i++,d=this[u];r(d)&&n.push(d)}return n});var ki={},Es=S.ArrayBuffer||oe;Es.prototype.slice==null&&(Es.prototype.slice=oe.sliceImpl),S.DataView;var Ei=S.Uint8Array||tr._new;(function(r,n){if(r.setImmediate)return;var i=1,l={},u=!1,d=r.document,p;function _(O){return l[i]=v.apply(n,O),i++}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(u)setTimeout(v(w,O),0);else{var F=l[O];if(F){u=!0;try{F()}finally{P(O),u=!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 E(){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 N(){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()?E():r.MessageChannel?T():d&&"onreadystatechange"in d.createElement("script")?L():N(),R.setImmediate=p,R.clearImmediate=P})(new Function("return this")()),Ht.USE_CACHE=!1,Ht.USE_ENUM_INDEX=!1,Ht.BASE64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:",Ut.DEFAULT_RESOLVER=mt,Ut.BASE64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:",Lt.count=0,ae.i64tmp=function(r){var n,i=new Wt(0,0);return n=i,n}(),kt.__toStr={}.toString,tr.BYTES_PER_ELEMENT=1,wt.queue=new U,zt.memo=new bt,rt.TOLERANCE=1e-6,rt.EPSILON=1e-10,rt.VERSION="2.0.0",yt.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]],yt.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]],xt.THREADS=1,xt._init=!1,Er.basePath="",jr.uuid=0,Is.main()}(typeof console<"u"?console:{log:function(){}},e,typeof c<"u"?c:typeof s<"u"?s:typeof self<"u"?self:this),e})})(wh);var sd=wh.exports;const Pn=nd(sd);class Ki{constructor(){this.c0=0,this.c1=0,this.c2=0,this.c3=0}init(t,e,s,o){this.c0=t,this.c1=s,this.c2=-3*t+3*e-2*s-o,this.c3=2*t-2*e+s+o}initCatmullRom(t,e,s,o,h){this.init(e,s,h*(s-t),h*(o-e))}initNonuniformCatmullRom(t,e,s,o,h,c,g){let b=(e-t)/h-(s-t)/(h+c)+(s-e)/c,f=(s-e)/c-(o-e)/(c+g)+(o-s)/g;b*=c,f*=c,this.init(e,s,b,f)}calc(t){const e=t*t,s=e*t;return this.c0+this.c1*t+this.c2*e+this.c3*s}}class Ah extends Ps{constructor(t=[],e=!1,s="centripetal",o=.5){super(),this.isCatmullRomCurve3d=!0,this.type="CatmullRomCurve3d",this._tmp=new $,this._px=new Ki,this._py=new Ki,this._pz=new Ki,this._points=t.map(h=>new X(h)),this._closed=e,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 X}get endPoint(){return this._points.length>0?this._points[this._points.length-1]:new X}get length(){if(this._points.length<2)return 0;let t=0;for(let e=1;e<this._points.length;e++)t+=this._points[e-1].distanceTo(this._points[e]);return this._closed&&this._points.length>2&&(t+=this._points[this._points.length-1].distanceTo(this._points[0])),t}getPoint(t,e=new X){const s=e,o=this._points,h=o.length;if(h===0)return s.set(0,0,0);if(h===1)return s.copy(o[0]);const c=(h-(this._closed?0:1))*t;let g=Math.floor(c),b=c-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 X(this._tmp.x,this._tmp.y,this._tmp.z));const x=o[g%h],k=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 X(this._tmp.x,this._tmp.y,this._tmp.z)),this._curveType==="centripetal"||this._curveType==="chordal"){const M=this._curveType==="chordal"?.5:.25;let D=Math.pow(f.distanceToSquared(x),M),z=Math.pow(x.distanceToSquared(k),M),U=Math.pow(k.distanceToSquared(S),M);z<1e-4&&(z=1),D<1e-4&&(D=z),U<1e-4&&(U=z),this._px.initNonuniformCatmullRom(f.x,x.x,k.x,S.x,D,z,U),this._py.initNonuniformCatmullRom(f.y,x.y,k.y,S.y,D,z,U),this._pz.initNonuniformCatmullRom(f.z,x.z,k.z,S.z,D,z,U)}else this._curveType==="catmullrom"&&(this._px.initCatmullRom(f.x,x.x,k.x,S.x,this._tension),this._py.initCatmullRom(f.y,x.y,k.y,S.y,this._tension),this._pz.initCatmullRom(f.z,x.z,k.z,S.z,this._tension));return s.set(this._px.calc(b),this._py.calc(b),this._pz.calc(b)),s}getPoints(t){const e=[];for(let s=0;s<=t;s++)e.push(this.getPoint(s/t));return e}setPoints(t){this._points=t.map(e=>new X(e)),this._boundingBoxNeedsUpdate=!0}setClosed(t){this._closed!==t&&(this._closed=t,this._boundingBoxNeedsUpdate=!0)}setCurveType(t){this._curveType=t}setTension(t){this._tension=t}transform(t){return this._points=this._points.map(e=>{const s=new X;return s.copy(e),s.applyMatrix3d(t),s}),this._boundingBoxNeedsUpdate=!0,this}calculateBoundingBox(){if(this._points.length===0)return new Dt;const t=new Dt;return this._points.forEach(e=>{t.expandByPoint(e)}),t}}class nn{constructor(t,e,s,o){this._degree=t,this._knots=[...e],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(t=>({x:t.x,y:t.y,z:t.z}))}weights(){return[...this._weights]}point(t){const e=this._controlPoints.map(s=>[s.x,s.y,s.z]);return _s(t,this._degree,this._knots,e,this._weights)}length(){const t=this._controlPoints.map(e=>[e.x,e.y,e.z]);return gh(this._degree,this._knots,t,this._weights)}static byKnotsControlPointsWeights(t,e,s,o){return new nn(t,e,s,o)}static byPoints(t,e,s="Uniform"){let o;switch(s){case"Chord":o=mh(e,t);break;case"SqrtChord":o=ph(e,t);break;case"Uniform":default:o=dh(e,t.length);break}const h=t.map(g=>({x:g[0],y:g[1],z:g[2]})),c=new Array(h.length).fill(1);return new nn(e,o,h,c)}getParameterRange(){const t=this._knots[this._degree],e=this._knots[this._knots.length-this._degree-1];return{start:t,end:e}}getPoints(t){const e=[],{start:s,end:o}=this.getParameterRange();for(let h=0;h<=t;h++){const c=s+(o-s)*(h/t);e.push(this.point(c))}return e}isClosed(t=1e-6){const{start:e,end:s}=this.getParameterRange(),o=this.point(e),h=this.point(s),c=o[0]-h[0],g=o[1]-h[1],b=o[2]-h[2];return Math.sqrt(c*c+g*g+b*b)<t}static createFitPointsForClosedCurve(t){if(t.length<4)throw new Error("At least 4 points are required for a closed NURBS curve");const e=new Ah(t,!0,"centripetal"),s=Math.max(50,t.length*2);return e.getPoints(s)}static createClosedCurve(t,e,s="Chord"){const o=this.createFitPointsForClosedCurve(t).map(h=>[h.x,h.y,h.z]);return nn.byPoints(o,e,s)}}class Fr extends Ps{constructor(t,e,s,o,h){super();const c=arguments.length;if(c<2||c>5)throw Re.ILLEGAL_PARAMETERS;if(this._degree=3,this._closed=!1,Array.isArray(e)){this._controlPoints=t;let g,b=3,f=!1;if(c>=3&&(Array.isArray(s)?(g=s,c>=4&&(b=o||3),c>=5&&(f=h)):s!==void 0&&(b=s||3,c>=4&&(f=o))),s===void 0&&c>=4&&(b=o||3,c>=5&&(f=h)),this._degree=b,this._closed=f,this._controlPoints.length<this._degree+1)throw Re.ILLEGAL_PARAMETERS;const S=this.toVerbPoints(this._controlPoints);this._nurbsCurve=Pn.geom.NurbsCurve.byKnotsControlPointsWeights(this._degree,e,S,g)}else{if(this._fitPoints=t,this._knotParameterization=e,c>=3&&(this._degree=s||3),c>=4&&(this._closed=o),this._fitPoints.length<this._degree+1)throw Re.ILLEGAL_PARAMETERS;const g=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=Pn.geom.NurbsCurve.byPoints(g,this._degree),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}}buildCurve(){if(this._fitPoints&&this._knotParameterization){if(this._closed){const t=nn.createFitPointsForClosedCurve(this._fitPoints),e=this.toNurbsPoints(t);this._nurbsCurve=Pn.geom.NurbsCurve.byPoints(e,this._degree)}else{const t=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=Pn.geom.NurbsCurve.byPoints(t,this._degree)}this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}else if(this._controlPoints)if(this._closed){const t=nn.createFitPointsForClosedCurve(this._controlPoints),e=this.toNurbsPoints(t);this._nurbsCurve=Pn.geom.NurbsCurve.byPoints(e,this._degree),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}else{const t=this._nurbsCurve.knots(),e=this._nurbsCurve.weights(),s=this.toVerbPoints(this._controlPoints);this._nurbsCurve=Pn.geom.NurbsCurve.byKnotsControlPointsWeights(this._degree,t,s,e)}}setClosed(t){this._closed!==t&&(this._closed=t,this._boundingBoxNeedsUpdate=!0,this.buildCurve())}get degree(){return this._degree}get knotParameterization(){return this._knotParameterization}get startPoint(){const t=this._nurbsCurve.knots(),e=this._nurbsCurve.degree(),s=t[e],o=this._nurbsCurve.point(s);return new X(o[0],o[1],o[2])}get endPoint(){const t=this._nurbsCurve.knots(),e=this._nurbsCurve.degree(),s=t[t.length-e-1],o=this._nurbsCurve.point(s);return new X(o[0],o[1],o[2])}get length(){return this._nurbsCurve.length()}getFitPointAt(t){if(!this._fitPoints)throw new Error("No fit points in this spline");const e=this._fitPoints.length,s=t<0||t>=e?e-1:t,o=this._fitPoints[s];return{x:o.x,y:o.y,z:o.z||0}}getControlPointAt(t){const e=this._controlPoints.length,s=t<0||t>=e?e-1:t;return this._controlPoints[s]}getPoints(t=100){const e=this._nurbsCurve,s=[],o=e.knots(),h=this._nurbsCurve.degree(),c=o[h],g=o[o.length-h-1],b=(g-c)/(t-1);for(let f=0;f<t;f++){const S=f===t-1?g:c+f*b,x=e.point(S);s.push(new X(x[0],x[1],x[2]))}return s}getCurvePoints(t,e){const s=[],o=t.knots(),h=o[3],c=(o[o.length-4]-h)/(e-1);for(let g=0;g<e;g++){const b=h+g*c;s.push(t.point(b))}return s}calculateBoundingBox(){const t=this.getPoints(100);return new Dt().setFromPoints(t)}get closed(){return this._closed}set closed(t){this.setClosed(t)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}toNurbsPoints(t){const e=new Array(t.length);return t.forEach((s,o)=>{e[o]=[s.x,s.y,s.z||0]}),e}toVerbPoints(t){const e=new Array(t.length);return t.forEach((s,o)=>{e[o]=[s.x,s.y,s.z||0]}),e}toGePoints(t){const e=new Array(t.length);return t.forEach((s,o)=>{e[o]={x:s[0],y:s[1],z:s[2]}}),e}static createClosedSpline(t,e="Uniform",s=3){if(t.length<s+1)throw new Error(`At least ${s+1} points are required for a degree ${s} closed spline`);return new Fr(t,e,s,!0)}}var en=256,Ph=[],Mo=256,Ls;for(;en--;)Ph[en]=(en+256).toString(16).substring(1);function id(a){var t=0,e=11;if(!Ls||en+e>Mo*2)for(Ls="",en=0;t<Mo;t++)Ls+=Ph[Math.random()*256|0];return Ls.substring(en,en+++e)}class Vr{constructor(t,e){t=t||{},Mn(t,{objectId:id()}),this._attrs=new Fo(t,e)}get attrs(){return this._attrs}getAttr(t){const e=this._attrs.get(t);if(e===void 0)throw new Error(`[AcDbObject] Attribute name '${t}' does't exist in this object!`);return e}getAttrWithoutException(t){return this._attrs.get(t)}setAttr(t,e){this._attrs.set(t,e)}get objectId(){return this.getAttr("objectId")}set objectId(t){this._attrs.set("objectId",t)}get ownerId(){return this.getAttr("ownerId")}set ownerId(t){this._attrs.set("ownerId",t)}get database(){return this._database?this._database:Pa().workingDatabase}set database(t){this._database=t}close(){}}const Sa=class Sa extends Vr{constructor(){super(...arguments),this._layer="0",this._color=new an,this._lineType=Gs,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(t){this._layer=t}get color(){return this._color}set color(t){this._color.copy(t)}get rgbColor(){let t=this.database.cecolor;if(this.color.isByLayer){const e=this.getLayerColor();e&&e.color&&(t=e)}else this.color.isByBlock||this.color.color!=null&&(t=this.color);return t.color==null?16777215:t.color}get lineType(){return this._lineType}set lineType(t){this._lineType=t||Gs}get lineWeight(){return this._lineWeight}set lineWeight(t){this._lineWeight=t}get linetypeScale(){return this._linetypeScale}set linetypeScale(t){this._linetypeScale=t}get visibility(){return this._visibility}set visibility(t){this._visibility=t}get transparency(){return this._transparency}set transparency(t){this._transparency=t}subGetGripPoints(){return new Array}subGetOsnapPoints(t,e,s,o,h){}transformBy(t){return this}triggerModifiedEvent(){this.database.events.entityModified.dispatch({database:this.database,entity:this})}get lineStyle(){var s;const t=this.getLineType(),e=(s=this.database)==null?void 0:s.tables.linetypeTable.getAt(t);return e?{...e.linetype,color:this.rgbColor}:{name:t,standardFlag:0,color:this.rgbColor,description:"",totalPatternLength:0}}getLineType(){if(this.lineType==Gs){const t=this.database.tables.layerTable.getAt(this.layer);if(t&&t.linetype)return t.linetype}else return this.lineType==Fl?Hs:this.lineType;return Hs}getLayerColor(){const t=this.database.tables.layerTable.getAt(this.layer);if(t==null)console.error(`The layer with name '${this.layer}' not found in drawing database!`);else return t.color;return null}};Sa.typeName="Entity";let je=Sa;const Ia=class Ia extends je{constructor(t){super(),this._blockName=t,this._position=new X,this._rotation=0,this._normal=new $(0,0,1),this._scaleFactors=new X(1,1,1)}get position(){return this._position}set position(t){this._position.copy(t)}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get scaleFactors(){return this._scaleFactors}set scaleFactors(t){this._scaleFactors.copy(t)}get normal(){return this._normal}set normal(t){this._normal.copy(t).normalize()}get blockTableRecord(){return this.database.tables.blockTable.getAt(this._blockName)}get geometricExtents(){const t=new Dt,e=this.blockTableRecord;if(e!=null){const h=e.newIterator();for(const c of h)t.union(c.geometricExtents)}const s=new Rr().setFromEuler(new yh(this.rotation,0,0)),o=new sn;return o.compose(this.position,s,this.scaleFactors),t.applyMatrix4(o),t}draw(t){const e=[],s=this.blockTableRecord;if(s!=null){const o=this.computeTransformMatrix();return Dr.instance.draw(t,s,this.rgbColor,!0,o,this.normal)}else return t.group(e)}computeTransformMatrix(){const t=new Rr;return t.setFromAxisAngle($.Z_AXIS,this.rotation),new sn().compose(this._position,t,this._scaleFactors)}};Ia.typeName="BlockReference";let ys=Ia;const ka=class ka extends je{};ka.typeName="Curve";let Be=ka;const Ea=class Ea extends Be{constructor(t,e,s,o,h,c,g){super(),this._geo=new xi(t,e,s,o,h,c,g)}get center(){return this._geo.center}set center(t){this._geo.center=t}get majorAxisRadius(){return this._geo.majorAxisRadius}set majorAxisRadius(t){this._geo.majorAxisRadius=t}get minorAxisRadius(){return this._geo.minorAxisRadius}set minorAxisRadius(t){this._geo.minorAxisRadius=t}get normal(){return this._geo.normal}set normal(t){this._geo.normal=t}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}draw(t){return t.ellipticalArc(this._geo,this.lineStyle)}};Ea.typeName="Ellipse";let Ys=Ea;const Ma=class Ma extends Be{constructor(t,e,s,o){super(),this._geo=new rn(t,e,s,o,$.Z_AXIS,$.X_AXIS)}get center(){return this._geo.center}set center(t){this._geo.center=t}get radius(){return this._geo.radius}set radius(t){this._geo.radius=t}get startAngle(){return this._geo.startAngle}set startAngle(t){this._geo.startAngle=t}get endAngle(){return this._geo.endAngle}set endAngle(t){this._geo.endAngle=t}get startPoint(){return this._geo.startPoint}get endPoint(){return this._geo.endPoint}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}subGetGripPoints(){const t=new Array;return t.push(this.center),t.push(this.startPoint),t.push(this.endPoint),t}transformBy(t){return this._geo.transform(t),this}draw(t){return t.circularArc(this._geo,this.lineStyle)}};Ma.typeName="Arc";let Ks=Ma;const Ta=class Ta extends Be{constructor(t,e,s=$.Z_AXIS){super(),this._geo=new rn(t,e,0,re,s,$.X_AXIS)}get center(){return this._geo.center}set center(t){this._geo.center=t}get radius(){return this._geo.radius}set radius(t){this._geo.radius=t}get normal(){return this._geo.normal}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}subGetGripPoints(){const t=new Array;return t.push(this.center),t}transformBy(t){return this._geo.transform(t),this}draw(t){return t.circularArc(this._geo,this.lineStyle)}};Ta.typeName="Circle";let Xs=Ta;var Sh=(a=>(a[a.UserDefined=0]="UserDefined",a[a.Predefined=1]="Predefined",a[a.Custom=2]="Custom",a))(Sh||{}),Ih=(a=>(a[a.Normal=0]="Normal",a[a.Outer=1]="Outer",a[a.Ignore=2]="Ignore",a))(Ih||{});const Ca=class Ca extends je{constructor(){super(),this._elevation=0,this._geo=new yi,this._definitionLines=[],this._patternName="",this._patternType=1,this._patternAngle=0,this._patternScale=1,this._hatchStyle=0}get definitionLines(){return this._definitionLines}get patternName(){return this._patternName}set patternName(t){this._patternName=t}get patternType(){return this._patternType}set patternType(t){this._patternType=t}get patternAngle(){return this._patternAngle}set patternAngle(t){this._patternAngle=t}get patternScale(){return this._patternScale}set patternScale(t){this._patternScale=t}get hatchStyle(){return this._hatchStyle}set hatchStyle(t){this._hatchStyle=t}add(t){this._geo.add(t)}get geometricExtents(){const t=this._geo.box;return new Dt({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}draw(t){return t.area(this._geo,{color:this.rgbColor,solidFill:!1,patternAngle:this.patternAngle,patternLines:this.definitionLines})}};Ca.typeName="Hatch";let $s=Ca;var kh=(a=>(a[a.MText=0]="MText",a[a.Fcf=1]="Fcf",a[a.BlockReference=2]="BlockReference",a[a.NoAnnotation=3]="NoAnnotation",a))(kh||{});const Na=class Na extends Be{constructor(){super(),this._isSplined=!1,this._updated=!1,this._hasArrowHead=!1,this._vertices=[],this._dimensionStyle="",this._hasHookLine=!1,this._annoType=3}get isSplined(){return this._isSplined}set isSplined(t){this._isSplined=t}get hasArrowHead(){return this._hasArrowHead}set hasArrowHead(t){this._hasArrowHead=t}get hasHookLine(){return this._hasHookLine}set hasHookLine(t){this._hasHookLine=t}get numVertices(){return this._vertices.length}get dimensionStyle(){return this._dimensionStyle}set dimensionStyle(t){this._dimensionStyle=t}get annoType(){return this._annoType}set annoType(t){this._annoType=t}appendVertex(t){this._vertices.push(new X().copy(t)),this._updated=!0}setVertexAt(t,e){throw(t<0||t>=this._vertices.length)&&(this._vertices[t].copy(e),this._updated=!0),new Error("The vertex index is out of range!")}vertexAt(t){throw(t<0||t>=this._vertices.length)&&this._vertices[t],new Error("The vertex index is out of range!")}get geometricExtents(){return this._isSplined&&this.splineGeo?this.splineGeo.calculateBoundingBox():new Dt().setFromPoints(this._vertices)}get closed(){return!1}set closed(t){}draw(t){if(this.isSplined&&this.splineGeo){const e=this.splineGeo.getPoints(100);return t.lines(e,this.lineStyle)}else return t.lines(this._vertices,this.lineStyle)}get splineGeo(){return this.createSplineIfNeeded(),this._splineGeo}createSplineIfNeeded(){this.isSplined&&this.numVertices>=2&&(this._splineGeo==null||this._updated)&&(this._splineGeo=new Fr(this._vertices,"Uniform"),this._updated=!1)}};Na.typeName="Leader";let Zs=Na;const La=class La extends Be{constructor(t,e){super(),this._geo=new Br(t,e)}get startPoint(){return this._geo.startPoint}set startPoint(t){this._geo.startPoint=t}get endPoint(){return this._geo.endPoint}set endPoint(t){this._geo.endPoint=t}get midPoint(){return this._geo.midPoint}get geometricExtents(){return this._geo.box}get closed(){return!1}subGetGripPoints(){const t=new Array;return t.push(this.midPoint),t.push(this.startPoint),t.push(this.endPoint),t}subGetOsnapPoints(t,e,s,o,h){const c=this.startPoint,g=this.endPoint;switch(t){case tn.EndPoint:h.push(c),h.push(g);break;case tn.MidPoint:h.push(this.midPoint);break;case tn.Nearest:{const b=this._geo.project(s);h.push(b)}break;case tn.Perpendicular:{const b=this._geo.perpPoint(s);h.push(b)}break;case tn.Tangent:h.push(c);break}}transformBy(t){return this._geo.transform(t),this}draw(t){const e=this.startPoint,s=this.endPoint,o=[new X(e.x,e.y,0),new X(s.x,s.y,0)];return t.lines(o,this.lineStyle)}};La.typeName="Line";let Qs=La;var _a=(a=>(a.ClosedFilled="",a.Dot="_DOT",a.DotSmall="_DOTSMALL",a.DotBlank="_DOTBLANK",a.Origin="_ORIGIN",a.Origin2="_ORIGIN2",a.Open="_OPEN",a.Open90="_OPEN90",a.Open30="_OPEN30",a.Closed="_CLOSED",a.Small="_SMALL",a.None="_NONE",a.Oblique="_OBLIQUE",a.BoxFilled="_BOXFILLED",a.Box="_BOXBLANK",a.ClosedBlank="_CLOSEDBLANK",a.DatumBlank="_DATUMBLANK",a.DatumFilled="_DATUMFILLED",a.Integral="_INTEGRAL",a.ArchTick="_ARCHTICK",a))(_a||{}),Ai=(a=>(a[a.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",a[a.RIGHT_TO_LEFT=2]="RIGHT_TO_LEFT",a[a.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",a[a.BOTTOM_TO_TOP=4]="BOTTOM_TO_TOP",a[a.BY_STYLE=5]="BY_STYLE",a))(Ai||{}),En=(a=>(a[a.TopLeft=1]="TopLeft",a[a.TopCenter=2]="TopCenter",a[a.TopRight=3]="TopRight",a[a.MiddleLeft=4]="MiddleLeft",a[a.MiddleCenter=5]="MiddleCenter",a[a.MiddleRight=6]="MiddleRight",a[a.BottomLeft=7]="BottomLeft",a[a.BottomCenter=8]="BottomCenter",a[a.BottomRight=9]="BottomRight",a))(En||{}),va=(a=>(a[a.OPTIMIZED_2D=0]="OPTIMIZED_2D",a[a.WIREFRAME=1]="WIREFRAME",a[a.HIDDEN_LINE=2]="HIDDEN_LINE",a[a.FLAT_SHADED=3]="FLAT_SHADED",a[a.GOURAUD_SHADED=4]="GOURAUD_SHADED",a[a.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",a[a.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME",a))(va||{}),ya=(a=>(a[a.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",a[a.TOP=1]="TOP",a[a.BOTTOM=2]="BOTTOM",a[a.FRONT=3]="FRONT",a[a.BACK=4]="BACK",a[a.LEFT=5]="LEFT",a[a.RIGHT=6]="RIGHT",a))(ya||{}),ba=(a=>(a[a.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",a[a.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS",a))(ba||{});class Pi{constructor(){this._number=-1,this._id="",this._groupId="",this._centerPoint=new X,this._height=0,this._width=0,this._viewCenter=new X,this._viewHeight=0}get number(){return this._number}set number(t){this._number=t}get id(){return this._id}set id(t){this._id=t}get groupId(){return this._groupId}set groupId(t){this._groupId=t}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get box(){const t=new _e;return t.setFromCenterAndSize(this.centerPoint,{x:this.width,y:this.height}),t}get viewCenter(){return this._viewCenter}set viewCenter(t){this._viewCenter.copy(t)}get viewHeight(){return this._viewHeight}set viewHeight(t){this._viewHeight=t}get viewWidth(){return this.viewHeight*(this.width/this.height)}get viewBox(){const t=new _e;return t.setFromCenterAndSize(this.viewCenter,{x:this.viewWidth,y:this.viewHeight}),t}clone(){const t=new Pi;return t.id=this.id,t.groupId=this.groupId,t.number=this.number,t.centerPoint.copy(this.centerPoint),t.height=this.height,t.width=this.width,t.viewCenter.copy(this.viewCenter),t.viewHeight=this.viewHeight,t}copy(t){return this.id=t.id,this.groupId=t.groupId,this.number=t.number,this.centerPoint.copy(t.centerPoint),this.height=t.height,this.width=t.width,this.viewCenter.copy(t.viewCenter),this.viewHeight=t.viewHeight,this}}const Oa=class Oa extends je{constructor(){super(),this._contents="",this._height=0,this._width=0,this._lineSpacingFactor=.25,this._lineSpacingStyle=0,this._backgroundFill=!1,this._backgroundFillColor=13158600,this._backgroundFillTransparency=1,this._backgroundScaleFactor=1,this._rotation=0,this._styleName="",this._location=new X,this._attachmentPoint=En.TopLeft,this._direction=new $(1,0,0),this._drawingDirection=Ai.LEFT_TO_RIGHT}get contents(){return this._contents}set contents(t){this._contents=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get lineSpacingFactor(){return this._lineSpacingFactor}set lineSpacingFactor(t){this._lineSpacingFactor=t}get lineSpacingStyle(){return this._lineSpacingStyle}set lineSpacingStyle(t){this._lineSpacingStyle=t}get backgroundFill(){return this._backgroundFill}set backgroundFill(t){this._backgroundFill=t,this._backgroundFillColor=13158600}get backgroundFillColor(){return this._backgroundFillColor}set backgroundFillColor(t){this._backgroundFillColor=t}get backgroundFillTransparency(){return this._backgroundFillTransparency}set backgroundFillTransparency(t){this._backgroundFillTransparency=t}get backgroundScaleFactor(){return this._backgroundScaleFactor}set backgroundScaleFactor(t){this._backgroundScaleFactor=t}get styleName(){return this._styleName}set styleName(t){this._styleName=t}get location(){return this._location}set location(t){this._location.copy(t)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(t){this._attachmentPoint=t}get direction(){return this._direction}set direction(t){this._direction.copy(t)}get drawingDirection(){return this._drawingDirection}set drawingDirection(t){this._drawingDirection=t}get geometricExtents(){return new Dt}getTextStyle(){const t=this.database.tables.textStyleTable;let e=t.getAt(this.styleName);return e||(e=t.getAt("STANDARD")||t.getAt("Standard")),e.textStyle}draw(t){const e={text:this.contents,height:this.height,width:this.width,position:this.location,rotation:this.rotation,directionVector:this.direction,attachmentPoint:this.attachmentPoint,drawingDirection:this.drawingDirection,lineSpaceFactor:this.lineSpacingFactor},s={...this.getTextStyle(),color:this.rgbColor};return t.mtext(e,s)}};Oa.typeName="MText";let Js=Oa;const za=class za extends Be{constructor(t,e,s,o,h){super();const c=+(t!==void 0)+ +(e!==void 0)+ +(s!==void 0)+ +(o!==void 0)+ +(h!==void 0);if(c<2||c>5)throw Re.ILLEGAL_PARAMETERS;!Array.isArray(e)?this._geo=new Fr(t,e,s,o):this._geo=new Fr(t,e,s,o,h)}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}draw(t){const e=this._geo.getPoints(100);return t.lines(e,this.lineStyle)}};za.typeName="Spline";let bs=za;const ad=new $,Da=class Da extends ys{constructor(t,e,s){super(t),this._attachmentPoint=En.TopLeft,this._numColumns=s,this._numRows=e,this._columnWidth=new Array(s),this._rowHeight=new Array(e),this._cells=new Array(e*s)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(t){this._attachmentPoint=t}get numRows(){return this._numRows}set numRows(t){this._numRows=t}get numColumns(){return this._numColumns}set numColumns(t){this._numColumns=t}numContents(t,e){return 1}rowHeight(t){return this._rowHeight[t]}setRowHeight(t,e){this._rowHeight[t]=e}setUniformRowHeight(t){this._rowHeight.fill(t)}columnWidth(t){return this._columnWidth[t]}setUniformColumnWidth(t){this._columnWidth.fill(t)}setColumnWidth(t,e){this._columnWidth[t]=e}cell(t){if(!(t<0||t>=this._cells.length))return this._cells[t]}setCell(t,e){this._cells[t]=e}textString(t,e,s){return this._cells[t*e].text}setTextString(t,e,s){this._cells[t*e].text=s}isEmpty(t,e){return!this._cells[t*e].text}get geometricExtents(){return new Dt}draw(t){let e=0,s=0;const o=new Uint16Array(this.numColumns*this.numRows*8),h=new Float32Array((this.numColumns+1)*(this.numRows+1)*3);let c=0;for(let k=0;k<=this.numRows;k++){e-=k>0?this.rowHeight(k-1):0,s=0;for(let M=0;M<=this.numColumns;M++)s+=M>0?this.columnWidth(M-1):0,h[c++]=s,h[c++]=e,h[c++]=0}const g=[],b=new Array(this.numRows*this.numColumns).fill(!1);s=0,c=0;let f=0;for(let k=0;k<this.numColumns;k++){s+=k>0?this.columnWidth(k-1):0,e=0;for(let M=0;M<this.numRows;M++){e+=M>0?this.rowHeight(M-1):0;const D=this.cell(M*this.numColumns+k);if(f=M*this.numColumns+k,D&&!b[f]){const z=D.borderWidth??1,U=D.borderHeight??1;this.fillVisited(b,f,this.numColumns,z,U),o[c++]=k+M*(this.numColumns+1),o[c++]=k+M*(this.numColumns+1)+z;const B=h[o[c-1]*3]-s,gt=k+(M+U)*(this.numColumns+1)+z;k+z==this.numColumns&&(o[c++]=k+M*(this.numColumns+1)+z,o[c++]=gt);const ft=-h[gt*3+1]-e;if(M+U==this.numRows&&(o[c++]=k+(M+U)*(this.numColumns+1)+U,o[c++]=k+(M+U)*(this.numColumns+1)),o[c++]=k+(M+U)*(this.numColumns+1),o[c++]=k+M*(this.numColumns+1),D.text){const ut=D.attachmentPoint||this.attachmentPoint||En.MiddleCenter,W=this.getTableTextOffset(ut,B,ft),mt={text:D.text,height:D.textHeight,width:B,position:ad.set(s,-e,0).clone().add(W),rotation:this.rotation,attachmentPoint:ut},lt={...this.getTextStyle(D),color:this.color.color};g.push(t.mtext(mt,lt))}}}}g.push(t.lineSegments(h,3,o,this.lineStyle));const S=t.group(g),x=new Rr;return x.setFromAxisAngle($.Z_AXIS,this.rotation),To.compose(this.position,x,this.scaleFactors),S.applyMatrix(To),S}fillVisited(t,e,s,o,h){if(h==1&&o==1)t[e]=!0;else for(let c=0;c<o;++c)for(let g=0;g<h;++g)t[e+c+g*s]=!0}getTextStyle(t){const e=this.database.tables.textStyleTable;let s;return t.textStyle&&(s=e.getAt(t.textStyle)),s||(s=e.getAt("STANDARD")||e.getAt("Standard")),s.textStyle}getTableTextOffset(t,e,s){const o=new $;switch(t){case 1:break;case 2:o.setX(e/2);break;case 3:o.setX(e);break;case 4:o.setY(-s/2);break;case 5:o.set(e/2,-s/2,0);break;case 6:o.set(e,-s/2,0);break;case 7:o.setY(-s);break;case 8:o.set(e/2,-s,0);break;case 9:o.set(e,-s,0);break}return o}};Da.typeName="Table";let ti=Da;const To=new sn;var Eh=(a=>(a[a.LEFT=0]="LEFT",a[a.CENTER=1]="CENTER",a[a.RIGHT=2]="RIGHT",a[a.ALIGNED=3]="ALIGNED",a[a.MIDDLE=4]="MIDDLE",a[a.FIT=5]="FIT",a))(Eh||{}),Mh=(a=>(a[a.BASELINE=0]="BASELINE",a[a.BOTTOM=1]="BOTTOM",a[a.MIDDLE=2]="MIDDLE",a[a.TOP=3]="TOP",a))(Mh||{});const Ra=class Ra extends je{constructor(){super(),this._textString="",this._height=0,this._thickness=1,this._position=new X,this._rotation=0,this._oblique=0,this._horizontalMode=0,this._verticalModel=2,this._styleName="",this._widthFactor=1}get textString(){return this._textString}set textString(t){this._textString=t}get thickness(){return this._thickness}set thickness(t){this._thickness=t}get height(){return this._height}set height(t){this._height=t}get position(){return this._position}set position(t){this._position.copy(t)}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get oblique(){return this._oblique}set oblique(t){this._oblique=t}get horizontalMode(){return this._horizontalMode}set horizontalMode(t){this._horizontalMode=t}get verticalMode(){return this._verticalModel}set verticalMode(t){this._verticalModel=t}get styleName(){return this._styleName}set styleName(t){this._styleName=t}get widthFactor(){return this._widthFactor}set widthFactor(t){this._widthFactor=t}get geometricExtents(){return new Dt}getTextStyle(){const t=this.database.tables.textStyleTable;let e=t.getAt(this.styleName);return e||(e=t.getAt("STANDARD")||t.getAt("Standard")),e.textStyle}draw(t){const e={text:this.textString,height:this.height,width:1/0,widthFactor:this.widthFactor,position:this.position,rotation:this.rotation,drawingDirection:Ai.BOTTOM_TO_TOP,attachmentPoint:En.BottomLeft},s={...this.getTextStyle(),color:this.rgbColor};return t.mtext(e,s)}};Ra.typeName="Text";let ei=Ra;const Ba=class Ba extends Be{constructor(){super(),this._elevation=0,this._thickness=1,this._vertices=[new X,new X,new X,new X]}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get closed(){return!0}get thickness(){return this._thickness}set thickness(t){this._thickness=t}getPointAt(t){return t<0?this._vertices[0]:t>3?this._vertices[3]:this._vertices[t]}setPointAt(t,e){if(t<0&&this._vertices[0].copy(e),t>3)return this._vertices[3].copy(e);this._vertices[t].copy(e)}get geometricExtents(){return new Dt().setFromPoints(this._vertices)}subGetGripPoints(){const t=new Array;for(let e=0;e<4;++e)t.push(this.getPointAt(e));return t}draw(t){const e=new Ss(this._vertices,!0),s=new yi;return s.add(e),t.area(s,{color:this.rgbColor,solidFill:!0,patternAngle:0,patternLines:[]})}};Ba.typeName="Trace";let ri=Ba;const Fa=class Fa extends Be{constructor(){super(),this._elevation=0,this._geo=new Ss}get numberOfVertices(){return this._geo.numberOfVertices}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}addVertexAt(t,e,s=0,o=-1,h=-1){const c=o<0?void 0:o,g=h<0?void 0:h,b={x:e.x,y:e.y,bulge:s,startWidth:c,endWidth:g};this._geo.addVertexAt(t,b)}getPoint2dAt(t){return this._geo.getPointAt(t)}getPoint3dAt(t){const e=this.getPoint2dAt(t);return new X(e.x,e.y,this._elevation)}get geometricExtents(){const t=this._geo.box;return new Dt({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}subGetGripPoints(){const t=new Array;for(let e=0;e<this.numberOfVertices;++e)t.push(this.getPoint3dAt(e));return t}draw(t){const e=[];return this._geo.getPoints(100).forEach(o=>e.push(new X().set(o.x,o.y,this.elevation))),t.lines(e,this.lineStyle)}};Fa.typeName="Polyline";let ni=Fa;const Va=class Va extends je{constructor(){super(),this._geo=new X}get position(){return this._geo}set position(t){this._geo.set(t.x,t.y,t.z||0)}get geometricExtents(){return new Dt().expandByPoint(this._geo)}transformBy(t){return this._geo.applyMatrix3d(t),this}draw(t){return t.point(this._geo,{displayMode:this.database.pdmode,displaySize:this.database.pdsize,color:this.rgbColor})}};Va.typeName="Point";let si=Va;var Th=(a=>(a[a.Invalid=0]="Invalid",a[a.Rect=1]="Rect",a[a.Poly=2]="Poly",a))(Th||{}),Ch=(a=>(a[a.Show=1]="Show",a[a.ShowUnAligned=2]="ShowUnAligned",a[a.Clip=4]="Clip",a[a.Transparent=8]="Transparent",a))(Ch||{});const Ua=class Ua extends je{constructor(){super(),this._brightness=50,this._contrast=50,this._fade=0,this._width=0,this._height=0,this._position=new X,this._scale=new Kt(1,1),this._rotation=0,this._clipBoundaryType=1,this._clipBoundary=[],this._isClipped=!1,this._isImageShown=!0,this._isImageTransparent=!1,this._imageDefId=""}get brightness(){return this._brightness}set brightness(t){this._brightness=t}get contrast(){return this._contrast}set contrast(t){this._contrast=t}get fade(){return this._fade}set fade(t){this._fade=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get position(){return this._position}set position(t){this._position=t}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get scale(){return this._scale}set scale(t){this._scale.copy(t)}get clipBoundaryType(){return this._clipBoundaryType}set clipBoundaryType(t){this._clipBoundaryType=t}get clipBoundary(){return this._clipBoundary}set clipBoundary(t){this._clipBoundary=[],this._clipBoundary.push(...t)}get isClipped(){return this._isClipped}set isClipped(t){this._isClipped=t}get isImageShown(){return this._isImageShown}set isImageShown(t){this._isImageShown=t}get isImageTransparent(){return this._isImageTransparent}set isImageTransparent(t){this._isImageTransparent=t}get image(){return this._image}set image(t){this._image=t}get imageDefId(){return this._imageDefId}set imageDefId(t){this._imageDefId=t}get imageFileName(){if(this._imageDefId){const t=this.database.dictionaries.imageDefs.getIdAt(this._imageDefId);if(t)return t.sourceFileName}return""}get geometricExtents(){const t=new Dt;return t.min.copy(this._position),t.max.set(this._position.x+this._width,this._position.y+this._height,0),t}subGetGripPoints(){return this.boundaryPath()}draw(t){const e=this.boundaryPath();return this._image?t.image(this._image,{boundary:e,roation:this._rotation}):t.lines(e,this.lineStyle)}boundaryPath(){const t=[];if(this.isClipped&&this._clipBoundary.length>3){const e=this._width,s=this._height,o=new _e;o.setFromPoints(this._clipBoundary);const h=new Mt;h.setX(this._position.x-o.min.x*e),h.setY(this._position.y-o.min.y*s),this._clipBoundary.forEach(c=>{const g=c.x*e+h.x,b=c.y*s+h.y;t.push(new X(g,b,this._position.z))})}else{if(t.push(this._position),t.push(this._position.clone().setX(this._position.x+this._width)),t.push(this._position.clone().set(this._position.x+this._width,this._position.y+this._height,this._position.z)),t.push(this._position.clone().setY(this._position.y+this._height)),this._rotation>0){Co.copy(t[1]);for(let e=1;e<4;e++)Os.copy(t[e]),Os.rotateAround(Co,this._rotation),t[e].setX(Os.x),t[e].setY(Os.y)}t.push(t[0])}return t}};Ua.typeName="RasterImage";let xs=Ua;const Co=new Mt,Os=new Mt,ja=class ja extends Be{constructor(){super(),this._basePoint=new X,this._unitDir=new $}get basePoint(){return this._basePoint}set basePoint(t){this._basePoint.copy(t)}get unitDir(){return this._unitDir}set unitDir(t){this._unitDir.copy(t)}get closed(){return!1}get geometricExtents(){const t=new Dt;return t.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),t.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),t}subGetGripPoints(){const t=new Array;return t.push(this.basePoint),t}draw(t){const e=[];return e.push(this.basePoint),e.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),t.lines(e,this.lineStyle)}};ja.typeName="Ray";let ii=ja;const Ga=class Ga extends je{constructor(){super(),this._centerPoint=new X,this._height=0,this._width=0,this._viewCenter=new X,this._viewHeight=0,this._number=-1}get number(){return this._number}set number(t){this._number=t}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get viewCenter(){return this._viewCenter}set viewCenter(t){this._viewCenter=t}get viewHeight(){return this._viewHeight}set viewHeight(t){this._viewHeight=t}get geometricExtents(){return new Dt}draw(t){if(this._number>1&&this.ownerId!=this.database.tables.blockTable.modelSpace.objectId){const e=this.toGiViewport();return t.group(this.createViewportRect(e,t))}}toGiViewport(){const t=new Pi;return t.id=this.objectId,t.groupId=this.ownerId,t.number=this.number,t.centerPoint=this.centerPoint,t.width=this.width,t.height=this.height,t.viewHeight=this.viewHeight,t.viewCenter=this.viewCenter,t}createViewportRect(t,e){const s=[];return s.push(e.lines([new X(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0),new X(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0)],this.lineStyle)),s.push(e.lines([new X(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0),new X(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0)],this.lineStyle)),s.push(e.lines([new X(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0),new X(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0)],this.lineStyle)),s.push(e.lines([new X(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0),new X(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0)],this.lineStyle)),s}};Ga.typeName="Viewport";let ai=Ga;const Wa=class Wa extends xs{draw(t){const e=this.boundaryPath(),s=new yi;return s.add(new Ss(e)),t.area(s,{color:0,solidFill:!0,patternAngle:0,patternLines:[]})}};Wa.typeName="Wipeout";let oi=Wa;const Ha=class Ha extends Be{constructor(){super(),this._basePoint=new X,this._unitDir=new $}get basePoint(){return this._basePoint}set basePoint(t){this._basePoint.copy(t)}get unitDir(){return this._unitDir}set unitDir(t){this._unitDir.copy(t)}get closed(){return!1}get geometricExtents(){const t=new Dt;return t.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),t.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),t}subGetGripPoints(){const t=new Array;return t.push(this.basePoint),t}draw(t){const e=[];return e.push(this._unitDir.clone().multiplyScalar(-1e6).add(this._basePoint)),e.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),t.lines(e,this.lineStyle)}};Ha.typeName="Xline";let li=Ha;var Nh=(a=>(a[a.AtLeast=1]="AtLeast",a[a.Exactly=2]="Exactly",a))(Nh||{});const qa=class qa extends je{constructor(){super(),this._dimBlockId=null,this._dimensionStyleName=null,this._dimensionText=null,this._textLineSpacingFactor=1,this._textLineSpacingStyle=1,this._textPosition=new X,this._textRotation=0}get dimBlockId(){return this._dimBlockId}set dimBlockId(t){this._dimBlockId=t}get dimensionStyleName(){return this._dimensionStyleName}set dimensionStyleName(t){this._dimensionStyleName=t}get dimensionStyle(){if(this._dimStyle==null){let t;this.dimensionStyleName&&(t=this.database.tables.dimStyleTable.getAt(this.dimensionStyleName)),t==null&&(t=new ws),this._dimStyle=t}return this._dimStyle}get dimensionText(){return this._dimensionText}set dimensionText(t){this._dimensionText=t}get measurement(){return this._measurement}set measurement(t){this._measurement=t}get textLineSpacingFactor(){return this._textLineSpacingFactor}set textLineSpacingFactor(t){this._textLineSpacingFactor=t}get textLineSpacingStyle(){return this._textLineSpacingStyle}set textLineSpacingStyle(t){this._textLineSpacingStyle=t}get textPosition(){return this._textPosition}set textPosition(t){this._textPosition.copy(t)}get textRotation(){return this._textRotation}set textRotation(t){this._textRotation=t}draw(t){if(this.dimBlockId){const e=this.database.tables.blockTable.getAt(this.dimBlockId);if(e)return Dr.instance.draw(t,e,this.rgbColor,!1)}return t.group([])}drawFirstArrow(t){const e=this.database.tables.blockTable.getAt(this.firstArrowType);if(e)return Dr.instance.draw(t,e,this.rgbColor,!1)}drawSecondArrow(t){const e=this.database.tables.blockTable.getAt(this.secondArrowType);if(e)return Dr.instance.draw(t,e,this.rgbColor,!1)}get arrowScaleFactor(){return this.dimensionStyle.dimasz}get firstArrowStyle(){return{type:this.firstArrowType,scale:this.arrowScaleFactor,appended:this.isAppendArrow,visible:this.dimensionStyle.dimse1==0}}get secondArrowStyle(){return{type:this.secondArrowType,scale:this.arrowScaleFactor,appended:this.isAppendArrow,visible:this.dimensionStyle.dimse2==0}}get isAppendArrow(){return!0}get firstArrowTypeBtrId(){const t=this.dimensionStyle;return t.dimsah==0?t.dimblk:t.dimblk1}get firstArrowType(){const t=this.firstArrowTypeBtrId;return this.getArrowName(t)}get secondArrowTypeBtrId(){const t=this.dimensionStyle;return t.dimsah==0?t.dimblk:t.dimblk2}get secondArrowType(){const t=this.secondArrowTypeBtrId;return this.getArrowName(t)}get arrowLineCount(){return 1}getLineArrowStyle(t){}findPointOnLine1(t,e,s){const o=new X().subVectors(e,t).normalize();return new X(e).addScaledVector(o,s)}findPointOnLine2(t,e,s){const o=t.x+s*Math.cos(e),h=t.y+s*Math.sin(e);return{x:o,y:h}}adjustExtensionLine(t){const e=this.dimensionStyle;t.extend(e.dimexe),t.extend(-e.dimexo,!0)}getArrowName(t){const e=this.database.tables.blockTable.getIdAt(t);return e?e.name.toUpperCase():_a.Closed}};qa.typeName="Dimension";let wr=qa;const Ya=class Ya extends wr{constructor(t,e,s,o,h=null,c=null){super(),this._centerPoint=new X().copy(t),this._xLine1Point=new X().copy(e),this._xLine2Point=new X().copy(s),this._arcPoint=new X().copy(o),this.dimensionText=h,this.dimensionStyleName=c}get arcPoint(){return this._arcPoint}set arcPoint(t){this._arcPoint.copy(t)}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get geometricExtents(){return new Dt}};Ya.typeName="3PointAngularDimension";let hi=Ya;const Ka=class Ka extends wr{constructor(t,e,s,o=null,h=null){super(),this._dimLinePoint=new X().copy(s),this._xLine1Point=new X().copy(t),this._xLine2Point=new X().copy(e),this._oblique=0,this._rotation=0,this.dimensionText=o,this.dimensionStyleName=h}get dimLinePoint(){return this._dimLinePoint}set dimLinePoint(t){this._dimLinePoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get oblique(){return this._oblique}set oblique(t){this._oblique=t}get geometricExtents(){return new Dt}get isAppendArrow(){return!1}calculateLines(){const t=[],e=this.createExtensionLine(this._xLine1Point),s=this.createExtensionLine(this._xLine2Point),o=this.findIntersectionPoint(e,this._dimLinePoint),h=this.findIntersectionPoint(s,this._dimLinePoint),c=new Br(o,h);return t.push(c),e.endPoint=o,this.adjustExtensionLine(e),t.push(e),s.endPoint=h,this.adjustExtensionLine(s),t.push(s),t}createExtensionLine(t){const e=this.rotation+Math.PI/2,s=this.findPointOnLine2(t,e,100);return new Br(t,{...s,z:t.z})}findIntersectionPoint(t,e){const s=t.startPoint,o=t.endPoint,h=new $().subVectors(o,s).normalize(),g=new $().subVectors(e,s).dot(h),b=new $().copy(h).multiplyScalar(g);return new $().addVectors(s,b)}};Ka.typeName="AlignedDimension";let ui=Ka;const Xa=class Xa extends wr{constructor(t,e,s,o,h=null,c=null){super(),this._arcPoint=new X().copy(o),this._xLine1Point=new X().copy(e),this._xLine2Point=new X().copy(s),this._centerPoint=new X().copy(t),this.dimensionText=h,this.dimensionStyleName=c}get arcPoint(){return this._arcPoint}set arcPoint(t){this._arcPoint.copy(t)}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get geometricExtents(){return new Dt}};Xa.typeName="ArcDimension";let ta=Xa;const $a=class $a extends wr{constructor(t,e,s=0,o=null,h=null){super(),this._chordPoint=new X().copy(t),this._farChordPoint=new X().copy(e),this._extArcStartAngle=0,this._extArcEndAngle=0,this._leaderLength=s,this.dimensionText=o,this.dimensionStyleName=h}get chordPoint(){return this._chordPoint}set chordPoint(t){this._chordPoint.copy(t)}get farChordPoint(){return this._farChordPoint}set farChordPoint(t){this._farChordPoint.copy(t)}get extArcStartAngle(){return this._extArcStartAngle}set extArcStartAngle(t){this._extArcStartAngle=t}get extArcEndAngle(){return this._extArcEndAngle}set extArcEndAngle(t){this._extArcEndAngle=t}get leaderLength(){return this._leaderLength}get geometricExtents(){return new Dt}drawLines(t,e){const s=[],o=e.length;return o==1?s.push(this.drawLine(t,e[0],{firstArrow:this.firstArrowStyle})):o==3?(this.sortLines(e),s.push(this.drawLine(t,e[0],{firstArrow:this.firstArrowStyle})),s.push(this.drawLine(t,e[1])),s.push(this.drawLine(t,e[2],{firstArrow:this.firstArrowStyle}))):e.forEach(h=>{s.push(this.drawLine(t,h))}),s}drawLine(t,e,s){if(s){const o=[e.startPoint,e.endPoint];return t.lines(o,{...this.lineStyle,arrows:s})}else return e.draw(t)}sortLines(t){const e=(s,o)=>s.x!==o.x?s.x-o.x:s.y!==o.y?s.y-o.y:s.z-o.z;t.sort((s,o)=>{const h=e(s.startPoint,o.startPoint);return h!==0?h:e(s.endPoint,o.endPoint)})}};$a.typeName="DiametricDimension";let ci=$a;const Za=class Za extends wr{constructor(t,e,s=null,o=null){super(),this._definingPoint=new X().copy(t),this._leaderEndPoint=new X().copy(e),this.dimensionText=s,this.dimensionStyleName=o}get definingPoint(){return this._definingPoint}set definingPoint(t){this._definingPoint.copy(t)}get leaderEndPoint(){return this._leaderEndPoint}set leaderEndPoint(t){this._leaderEndPoint.copy(t)}get geometricExtents(){return new Dt}get arrowLineCount(){return 0}};Za.typeName="OrdinateDimension";let di=Za;const Qa=class Qa extends wr{constructor(t,e,s,o=null,h=null){super(),this._center=new X().copy(t),this._chordPoint=new X().copy(e),this._leaderLength=s,this._extArcStartAngle=0,this._extArcEndAngle=0,this.dimensionText=o,this.dimensionStyleName=h}get center(){return this._center}set center(t){this._center.copy(t)}get chordPoint(){return this._chordPoint}set chordPoint(t){this._chordPoint.copy(t)}get extArcStartAngle(){return this._extArcStartAngle}set extArcStartAngle(t){this._extArcStartAngle=t}get extArcEndAngle(){return this._extArcEndAngle}set extArcEndAngle(t){this._extArcEndAngle=t}get leaderLength(){return this._leaderLength}set leaderLenght(t){this._leaderLength=t}get geometricExtents(){return new Dt}getLineArrowStyle(t){return{secondArrow:this.secondArrowStyle}}};Qa.typeName="RadialDimension";let mi=Qa;class No{convert(t){const e=this.createEntity(t);return e&&this.processCommonAttrs(t,e),e}createEntity(t){return t.type=="ARC"?this.convertArc(t):t.type=="CIRCLE"?this.convertCirle(t):t.type=="DIMENSION"?this.convertDimension(t):t.type=="ELLIPSE"?this.convertEllipse(t):t.type=="HATCH"?this.convertHatch(t):t.type=="IMAGE"?this.convertImage(t):t.type=="LEADER"?this.convertLeader(t):t.type=="LINE"?this.convertLine(t):t.type=="MTEXT"?this.convertMText(t):t.type=="POLYLINE"||t.type=="LWPOLYLINE"?this.convertPolyline(t):t.type=="POINT"?this.convertPoint(t):t.type=="RAY"?this.convertRay(t):t.type=="SPLINE"?this.convertSpline(t):t.type=="ACAD_TABLE"?this.convertTable(t):t.type=="TEXT"?this.convertText(t):t.type=="SOLID"?this.convertSolid(t):t.type=="VIEWPORT"?this.convertViewport(t):t.type=="WIPEOUT"?this.convertWipeout(t):t.type=="XLINE"?this.convertXline(t):t.type=="INSERT"?this.convertBlockReference(t):null}convertArc(t){return new Ks(t.center,t.radius,St.degToRad(t.startAngle),St.degToRad(t.endAngle))}convertCirle(t){return new Xs(t.center,t.radius)}convertEllipse(t){const e=new $(t.majorAxisEndPoint),s=e.length();return new Ys(t.center,$.Z_AXIS,e,s,s*t.axisRatio,t.startAngle,t.endAngle)}convertLine(t){const e=t.startPoint,s=t.endPoint;return new Qs(new X(e.x,e.y,e.z||0),new X(s.x,s.y,s.z||0))}convertSpline(t){if(t.numberOfControlPoints>0&&t.numberOfKnots>0)return new bs(t.controlPoints,t.knots,t.weights,t.degree,!!(t.flag&1));if(t.numberOfFitPoints>0){const e=this.numberArrayToPointArray(t.fitPoints,t.numberOfFitPoints);if(e!=null)return new bs(e,"Uniform",t.degree,!!(t.flag&1))}return null}convertPoint(t){const e=new si;return e.position=t.position,e}convertSolid(t){const e=new ri;return t.points.forEach((s,o)=>e.setPointAt(o,s)),e.thickness=t.thickness,e}convertPolyline(t){const e=new ni;return e.closed=!!(t.flag&1),t.vertices.forEach((s,o)=>{e.addVertexAt(o,new Mt(s.x,s.y),s.bulge,s.startWidth,s.endWidth)}),e}convertHatch(t){var o;const e=new $s;return(o=t.definitionLines)==null||o.forEach(h=>{e.definitionLines.push({angle:h.angle,origin:h.base,delta:h.offset,dashPattern:h.numberOfDashLengths>0?h.dashLengths:[]})}),e.hatchStyle=t.hatchStyle,e.patternName=t.patternName,e.patternType=t.patternType,e.patternAngle=t.patternAngle==null?0:t.patternAngle,e.patternScale=t.patternScale==null?0:t.patternScale,t.boundaryPaths.forEach(h=>{if(h.boundaryPathTypeFlag&2){const g=h,b=new Ss;b.closed=g.isClosed,g.vertices.forEach((f,S)=>{b.addVertexAt(S,{x:f.x,y:f.y,bulge:f.bulge})}),e.add(b)}else{const g=h,b=new xh;g.edges.forEach(f=>{if(f.type==1){const S=f;b.add(new wi(S.start,S.end))}else if(f.type==2){const S=f;b.add(new kn(S.center,S.radius,St.degToRad(S.startAngle||0),St.degToRad(S.endAngle||0),!S.isCCW))}else if(f.type==3){const S=f;new Kt().subVectors(S.end,S.center);const k=Math.sqrt(Math.pow(S.end.x,2)+Math.pow(S.end.y,2)),M=k*S.lengthOfMinorAxis;let D=St.degToRad(S.startAngle||0),z=St.degToRad(S.endAngle||0);const U=Math.atan2(S.end.y,S.end.x);S.isCCW||(D=Math.PI*2-D,z=Math.PI*2-z),b.add(new bi({...S.center,z:0},k,M,D,z,!S.isCCW,U))}else if(f.type==4){const S=f;if(S.numberOfControlPoints>0&&S.numberOfKnots>0){const x=S.controlPoints.map(D=>({x:D.x,y:D.y,z:0}));let k=!0;const M=S.controlPoints.map(D=>(D.weight==null&&(k=!1),D.weight||1));b.add(new Fr(x,S.knots,k?M:void 0))}else if(S.numberOfFitData>0){const x=S.fitDatum.map(k=>({x:k.x,y:k.y,z:0}));b.add(new Fr(x,"Uniform"))}}}),e.add(b)}}),e}convertTable(t){const e=new ti(t.name,t.rowCount,t.columnCount);return e.attachmentPoint=t.attachmentPoint,e.position.copy(t.startPoint),t.columnWidthArr.forEach((s,o)=>e.setColumnWidth(o,s)),t.rowHeightArr.forEach((s,o)=>e.setRowHeight(o,s)),t.cells.forEach((s,o)=>{e.setCell(o,s)}),e}convertText(t){const e=new ei;return e.textString=t.text,e.styleName=t.styleName,e.height=t.textHeight,e.position.copy(t.startPoint),e.rotation=St.degToRad(t.rotation||0),e.oblique=t.obliqueAngle??0,e.thickness=t.thickness,e.horizontalMode=t.halign,e.verticalMode=t.valign,e.widthFactor=t.xScale??1,e}convertMText(t){const e=new Js;return e.contents=t.text.join(""),t.styleName!=null&&(e.styleName=t.styleName),e.height=t.height,e.width=t.width,e.rotation=St.degToRad(t.rotation||0),e.location=t.insertionPoint,e.attachmentPoint=t.attachmentPoint,t.direction&&(e.direction=new $(t.direction)),e.drawingDirection=t.drawingDirection,e}convertLeader(t){const e=new Zs;return t.vertices.forEach(s=>{e.appendVertex(s)}),e.hasArrowHead=t.isArrowheadEnabled,e.hasHookLine=t.isHooklineExists,e.isSplined=t.isSpline,e.dimensionStyle=t.styleName,e.annoType=t.leaderCreationFlag,e}convertDimension(t){if(t.subclassMarker=="AcDbAlignedDimension"||t.subclassMarker=="AcDbRotatedDimension"){const e=t,s=new ui(e.subDefinitionPoint1,e.subDefinitionPoint2,e.definitionPoint);return s.rotation=St.degToRad(e.rotationAngle||0),this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDb3PointAngularDimension"){const e=t,s=new hi(e.centerPoint,e.subDefinitionPoint1,e.subDefinitionPoint2,e.definitionPoint);return this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDbOrdinateDimension"){const e=t,s=new di(e.subDefinitionPoint1,e.subDefinitionPoint2);return this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDbRadialDimension"){const e=t,s=new mi(e.definitionPoint,e.centerPoint,e.leaderLength);return this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDbDiametricDimension"){const e=t,s=new ci(e.definitionPoint,e.centerPoint,e.leaderLength);return this.processDimensionCommonAttrs(t,s),s}return null}processImage(t,e){e.position.copy(t.position),e.brightness=t.brightness,e.contrast=t.contrast,e.fade=t.fade,e.imageDefId=t.imageDefHandle,e.isClipped=(t.flags|4)>0,e.isImageShown=(t.flags|3)>0,e.isImageTransparent=(t.flags|8)>0,t.clippingBoundaryPath.forEach(s=>{e.clipBoundary.push(new Mt(s))}),e.clipBoundaryType=t.clippingBoundaryType,e.width=Math.sqrt(t.uPixel.x**2+t.uPixel.y**2+t.uPixel.z**2)*t.imageSize.x,e.height=Math.sqrt(t.vPixel.x**2+t.vPixel.y**2+t.vPixel.z**2)*t.imageSize.y,e.rotation=Math.atan2(t.uPixel.y,t.uPixel.x)}convertImage(t){const e=new xs;return this.processImage(t,e),e}convertWipeout(t){const e=new oi;return this.processImage(t,e),e}convertViewport(t){const e=new ai;return e.number=t.viewportId,e.centerPoint.copy(t.viewportCenter),e.height=t.height,e.width=t.width,e.viewCenter.copy(t.displayCenter),e.viewHeight=t.viewHeight,e}convertRay(t){const e=new ii;return e.basePoint.copy(t.firstPoint),e.unitDir.copy(t.unitDirection),e}convertXline(t){const e=new li;return e.basePoint.copy(t.firstPoint),e.unitDir.copy(t.unitDirection),e}convertBlockReference(t){const e=new ys(t.name);return t.insertionPoint&&e.position.copy(t.insertionPoint),e.scaleFactors.x=t.xScale||1,e.scaleFactors.y=t.yScale||1,e.scaleFactors.z=t.zScale||1,e.rotation=t.rotation!=null?St.degToRad(t.rotation):0,e.normal.copy(t.extrusionDirection??{x:0,y:0,z:1}),e}processDimensionCommonAttrs(t,e){e.dimBlockId=t.name,e.textPosition.copy(t.textPoint),e.textRotation=t.textRotation||0,t.textLineSpacingFactor&&(e.textLineSpacingFactor=t.textLineSpacingFactor),t.textLineSpacingStyle&&(e.textLineSpacingStyle=t.textLineSpacingStyle),e.dimensionStyleName=t.styleName,e.dimensionText=t.text||"",e.measurement=t.measurement}processCommonAttrs(t,e){e.layer=t.layer,e.objectId=t.handle,e.ownerId=t.ownerBlockRecordSoftId||"",t.lineType!=null&&(e.lineType=t.lineType),t.lineweight!=null&&(e.lineWeight=t.lineweight),t.lineTypeScale!=null&&(e.linetypeScale=t.lineTypeScale),t.color!=null&&(e.color.color=t.color),t.colorIndex!=null&&(e.color.colorIndex=t.colorIndex),t.colorName!=null&&(e.color.colorName=t.colorName),t.isVisible!=null&&(e.visibility=t.isVisible),t.transparency!=null&&(e.transparency=t.transparency)}numberArrayToPointArray(t,e){const s=t.length;let o=0;if(s/2==e?o=2:s/3==e&&(o=3),o==0)return;const h=[];for(let c=0,g=s/o;c<g;++c)h.push({x:t[c*o],y:t[c*o+1],z:o==3?t[c*o+2]:0});return h}}class xa extends Vr{constructor(){super(),this._tabOrder=-1,this._tabSelected=!1,this._blockTableRecordId="",this._layoutName="",this._limits=new _e,this._extents=new Dt}get layoutName(){return this._layoutName}set layoutName(t){this._layoutName=t.length>256?t.slice(0,256):t}get tabOrder(){return this._tabOrder}set tabOrder(t){this._tabOrder=t}get tabSelected(){return this._tabSelected}set tabSelected(t){this._tabSelected=t}get blockTableRecordId(){return this._blockTableRecordId}set blockTableRecordId(t){this._blockTableRecordId=t}get limits(){return this._limits}set limits(t){this._limits.copy(t)}get extents(){return this._extents}set extents(t){this._extents.copy(t)}}class wa extends Vr{constructor(t){super(),this.database=t,this._recordsByName=new Map,this._recordsById=new Map}get numEntries(){return this._recordsByName.size}setAt(t,e){e.database=this.database,this._recordsByName.set(t,e),this._recordsById.set(e.objectId,e),this.database.events.dictObjetSet.dispatch({database:this.database,object:e,key:t})}remove(t){const e=this.getAt(t);return e?(this._recordsByName.delete(t.toUpperCase()),this._recordsById.delete(this.objectId),this.database.events.dictObjectErased.dispatch({database:this.database,object:e,key:t}),!0):!1}removeId(t){const e=this.getIdAt(t);return e?(this._recordsById.delete(this.objectId),this._recordsByName.forEach((s,o)=>{s===e&&(this._recordsByName.delete(o),this.database.events.dictObjectErased.dispatch({database:this.database,object:e,key:o}))}),!0):!1}removeAll(){this._recordsByName.forEach((t,e)=>{this.database.events.dictObjectErased.dispatch({database:this.database,object:t,key:e})}),this._recordsByName.clear(),this._recordsById.clear()}has(t){return this._recordsByName.has(t.toUpperCase())}hasId(t){return this._recordsById.has(t)}getAt(t){return this._recordsByName.get(t)}getIdAt(t){return this._recordsById.get(t)}newIterator(){return new _i(this._recordsByName)}}class Lh extends wa{getBtrIdAt(t){for(const[e,s]of this._recordsByName)if(s.blockTableRecordId==t)return s}get maxTabOrder(){let t=-1;return this._recordsByName.forEach(e=>{e.tabOrder>t&&(t=e.tabOrder)}),t}}class Oh extends Vr{constructor(){super(),this._sourceFileName=""}get sourceFileName(){return this._sourceFileName}set sourceFileName(t){this._sourceFileName=t}}class od{convertLayout(t,e){var o;const s=new xa;return s.layoutName=t.layoutName,s.tabOrder=t.tabOrder,(o=e.tables.BLOCK_RECORD)==null||o.entries.some(h=>h.layoutObjects===t.handle?(s.blockTableRecordId=h.handle,!0):!1),s.limits.min.copy(t.minLimit),s.limits.max.copy(t.maxLimit),s.extents.min.copy(t.minExtent),s.extents.max.copy(t.maxExtent),this.processCommonAttrs(t,s),s}convertImageDef(t){const e=new Oh;return e.sourceFileName=t.fileName,this.processCommonAttrs(t,e),e}processCommonAttrs(t,e){e.objectId=t.handle,e.ownerId=t.ownerObjectId}}class zh{constructor(t){this.taskId=0,this.workers=new Map,this.pendingTasks=new Map,this.config={workerUrl:t.workerUrl,timeout:t.timeout??3e4,maxConcurrentWorkers:t.maxConcurrentWorkers??4}}async execute(t,e){const s=Date.now(),o=this.generateTaskId();try{return await this.executeInWorker(o,t,e||this.config.workerUrl)}catch(h){const c=Date.now()-s;return{success:!1,error:h instanceof Error?h.message:String(h),duration:c}}}async executeInWorker(t,e,s){const o=Date.now();return new Promise((h,c)=>{const g=this.getAvailableWorker(s),b=setTimeout(()=>{this.cleanupTask(t),this.releaseWorker(g),c(new Error(`Worker operation timed out after ${this.config.timeout}ms`))},this.config.timeout);this.pendingTasks.set(t,{resolve:x=>{clearTimeout(b),this.releaseWorker(g),h(x)},reject:x=>{clearTimeout(b),this.releaseWorker(g),c(x)},timeout:b});const f=x=>{const{id:k,success:M,data:D,error:z}=x.data;if(k!==t)return;this.cleanupTask(t);const U=Date.now()-o;h(M?{success:!0,data:D,duration:U}:{success:!1,error:z,duration:U})},S=x=>{this.cleanupTask(t),c(new Error(`Worker error: ${x.message}`))};g.addEventListener("message",f),g.addEventListener("error",S),g.postMessage({id:t,input:e})})}cleanupTask(t){const e=this.pendingTasks.get(t);e&&(clearTimeout(e.timeout),this.pendingTasks.delete(t))}generateTaskId(){return`task_${++this.taskId}_${Date.now()}`}detectWorkerSupport(){return typeof Worker<"u"}getAvailableWorker(t){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(t,{type:"module"}),o=this.generateWorkerId(),h={worker:s,isBusy:!0,id:o,createdAt:new Date};return this.workers.set(o,h),s}const e=Array.from(this.workers.values()).sort((s,o)=>s.createdAt.getTime()-o.createdAt.getTime())[0];return e.isBusy=!0,e.worker}releaseWorker(t){for(const[e,s]of this.workers)if(s.worker===t){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(t=>t.isBusy).length,pendingTasks:this.pendingTasks.size,config:this.config}}destroy(){for(const[t,e]of this.pendingTasks)clearTimeout(e.timeout),e.reject(new Error("Framework destroyed"));this.pendingTasks.clear();for(const[t,e]of this.workers)e.worker.terminate();this.workers.clear()}}class Dh{constructor(t){this.framework=new zh(t)}async execute(t,e){return this.framework.execute(t,e)}getStats(){return this.framework.getStats()}destroy(){this.framework.destroy()}}function Rh(a){return new Dh(a)}class ld{constructor(){this.setupMessageHandler()}setupMessageHandler(){self.onmessage=async t=>{const{id:e,input:s}=t.data;try{const o=await this.executeTask(s);this.sendResponse(e,!0,o)}catch(o){this.sendResponse(e,!1,void 0,o instanceof Error?o.message:String(o))}}}sendResponse(t,e,s,o){const h={id:t,success:e,data:s,error:o};self.postMessage(h)}}class Bh extends jl{constructor(t={}){super(t),t.parserWorkerUrl||(t.parserWorkerUrl="/assets/dxf-parser-worker.js")}async parse(t){if(this.config.useWorker&&this.config.parserWorkerUrl){const e=Rh({workerUrl:this.config.parserWorkerUrl,maxConcurrentWorkers:1}),s=await e.execute(t);return e.destroy(),s.data}else return new Yc().parseSync(t)}getFonts(t){var h;const e=new Map,s=c=>{if(c){const g=c.lastIndexOf(".");return g>=0?c.substring(0,g).toLowerCase():c.toLowerCase()}};(h=t.tables.STYLE)==null||h.entries.forEach(c=>{const g=[];let b=s(c.font);b&&g.push(b),b=s(c.bigFont),b&&g.push(b),e.set(c.name,g)});const o=new Set;return this.getFontsInBlock(t.entities,t.blocks,e,o),Array.from(o)}getFontsInBlock(t,e,s,o){const h=/\\f(.*?)\|/g;t.forEach(c=>{if(c.type=="MTEXT"){const g=c;[...g.text.join("").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(c.type=="TEXT"){const g=c,b=s.get(g.styleName);b==null||b.forEach(f=>o.add(f))}else if(c.type=="INSERT"){const b=e[c.name];b&&b.entities&&this.getFontsInBlock(b.entities,e,s,o)}})}async processEntities(t,e,s,o,h){const c=new No;let g=t.entities;const b=g.length,f=new Ho(b,100-o.value,s);this.config.convertByEntityType&&(g=this.groupAndFlattenByType(g));const S=e.tables.blockTable.modelSpace;await f.processChunk(async(x,k)=>{let M=[],D=x<k?g[x].type:"";for(let z=x;z<k;z++){const U=g[z],B=c.convert(U);B&&(this.config.convertByEntityType&&U.type!==D&&(S.appendEntity(M),M=[],D=U.type),M.push(B))}if(S.appendEntity(M),h){let z=o.value+k/b*(100-o.value);z>100&&(z=100),await h(z,"ENTITY","IN-PROGRESS")}})}async processEntitiesInBlock(t,e){const s=new No,o=t.length,h=[];for(let c=0;c<o;c++){const g=t[c],b=s.convert(g);b&&h.push(b)}e.appendEntity(h)}processBlocks(t,e){const s=t.blocks;for(const[o,h]of Object.entries(s)){let c=e.tables.blockTable.getAt(h.name);c||(c=new De,c.objectId=h.handle,c.name=o,c.origin.copy(h.position),e.tables.blockTable.add(c)),h.entities&&this.processEntitiesInBlock(h.entities,c)}}processHeader(t,e){const s=t.header;e.cecolor.colorIndex=s.$CECOLOR||256,e.angBase=s.$ANGBASE||0,e.angDir=s.$ANGDIR||0,e.aunits=s.$AUNITS,e.extmax=s.$EXTMAX,e.extmin=s.$EXTMIN,e.insunits=s.$INSUNITS,e.pdmode=s.$PDMODE||0,e.pdsize=s.$PDSIZE||0}processBlockTables(t,e){var o;const s=(o=t.tables.BLOCK_RECORD)==null?void 0:o.entries;s&&s.length>0&&(e.tables.blockTable.removeAll(),s.forEach(h=>{const c=new De;c.objectId=h.handle,c.name=h.name,c.layoutId=h.layoutObjects,e.tables.blockTable.add(c)}))}processObjects(t,e){const s=t.objects.byName,o=new od;if("LAYOUT"in s){const h=e.dictionaries.layouts;s.LAYOUT.forEach(c=>{const g=o.convertLayout(c,t);h.setAt(g.layoutName,g)})}if("IMAGEDEF"in s){const h=e.dictionaries.imageDefs;s.IMAGEDEF.forEach(c=>{const g=o.convertImageDef(c);h.setAt(g.objectId,g)})}}processViewports(t,e){var o,h;const s=(h=(o=t.tables)==null?void 0:o.VPORT)==null?void 0:h.entries;s&&s.length>0&&s.forEach(c=>{const g=new Qh;this.processCommonTableEntryAttrs(c,g),c.circleSides&&(g.circleSides=c.circleSides),g.standardFlag=c.standardFlag,g.center.copy(c.center),g.lowerLeftCorner.copy(c.lowerLeftCorner),g.upperRightCorner.copy(c.upperRightCorner),c.snapBasePoint&&g.snapBase.copy(c.snapBasePoint),c.snapRotationAngle&&(g.snapAngle=c.snapRotationAngle),c.snapSpacing&&g.snapIncrements.copy(c.snapSpacing),c.majorGridLines&&(g.gridMajor=c.majorGridLines),c.gridSpacing&&g.gridIncrements.copy(c.gridSpacing),c.backgroundObjectId&&(g.backgroundObjectId=c.backgroundObjectId),g.gsView.center.copy(c.center),g.gsView.viewDirectionFromTarget.copy(c.viewDirectionFromTarget),g.gsView.viewTarget.copy(c.viewTarget),c.lensLength&&(g.gsView.lensLength=c.lensLength),c.frontClippingPlane&&(g.gsView.frontClippingPlane=c.frontClippingPlane),c.backClippingPlane&&(g.gsView.backClippingPlane=c.backClippingPlane),c.viewHeight&&(g.gsView.viewHeight=c.viewHeight),c.viewTwistAngle&&(g.gsView.viewTwistAngle=c.viewTwistAngle),c.frozenLayers&&(g.gsView.frozenLayers=c.frozenLayers),c.styleSheet&&(g.gsView.styleSheet=c.styleSheet),c.renderMode&&(g.gsView.renderMode=c.renderMode),c.viewMode&&(g.gsView.viewMode=c.viewMode),c.ucsIconSetting&&(g.gsView.ucsIconSetting=c.ucsIconSetting),c.ucsOrigin&&g.gsView.ucsOrigin.copy(c.ucsOrigin),c.ucsXAxis&&g.gsView.ucsXAxis.copy(c.ucsXAxis),c.ucsYAxis&&g.gsView.ucsYAxis.copy(c.ucsYAxis),c.orthographicType&&(g.gsView.orthographicType=c.orthographicType),c.shadePlotSetting&&(g.gsView.shadePlotSetting=c.shadePlotSetting),c.shadePlotObjectId&&(g.gsView.shadePlotObjectId=c.shadePlotObjectId),c.visualStyleObjectId&&(g.gsView.visualStyleObjectId=c.visualStyleObjectId),c.isDefaultLightingOn&&(g.gsView.isDefaultLightingOn=c.isDefaultLightingOn),c.defaultLightingType&&(g.gsView.defaultLightingType=c.defaultLightingType),c.brightness&&(g.gsView.brightness=c.brightness),c.contrast&&(g.gsView.contrast=c.contrast),c.ambientColor&&(g.gsView.ambientColor=c.ambientColor),e.tables.viewportTable.add(g)})}processLayers(t,e){var o,h;const s=(h=(o=t.tables)==null?void 0:o.LAYER)==null?void 0:h.entries;s&&s.length>0&&s.forEach(c=>{const g=new an;g.colorIndex=c.colorIndex;const b=new Aa({name:c.name,standardFlags:c.standardFlag,linetype:c.lineType,lineWeight:c.lineweight,isOff:c.colorIndex<0,color:g,isPlottable:c.isPlotting});this.processCommonTableEntryAttrs(c,b),e.tables.layerTable.add(b)})}processLineTypes(t,e){var o,h;const s=(h=(o=t.tables)==null?void 0:o.LTYPE)==null?void 0:h.entries;s&&s.length>0&&s.forEach(c=>{const g=new $h(c);this.processCommonTableEntryAttrs(c,g),g.name=c.name,e.tables.linetypeTable.add(g)})}processTextStyles(t,e){var o;const s=(o=t.tables.STYLE)==null?void 0:o.entries;s&&s.length>0&&s.forEach(h=>{const c=new Zh(h);this.processCommonTableEntryAttrs(h,c),e.tables.textStyleTable.add(c)})}processDimStyles(t,e){var o;const s=(o=t.tables.DIMSTYLE)==null?void 0:o.entries;s&&s.length>0&&s.forEach(h=>{const c={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 ws(c);this.processCommonTableEntryAttrs(h,g),e.tables.dimStyleTable.add(g)})}processCommonTableEntryAttrs(t,e){e.name=t.name,e.objectId=t.handle,e.ownerId=t.ownerObjectId}groupAndFlattenByType(t){const e={},s=[];for(const o of t)e[o.type]||(e[o.type]=[],s.push(o.type)),e[o.type].push(o);return s.flatMap(o=>e[o])}}var vs=(a=>(a.DXF="dxf",a.DWG="dwg",a))(vs||{});class ir{constructor(){this.events={registered:new ie,unregistered:new ie},this._converters=new Map,this.register("dxf",new Bh)}static createInstance(){return ir._instance==null&&(ir._instance=new ir),this._instance}static get instance(){return ir._instance||(ir._instance=new ir),ir._instance}get fileTypes(){return this._converters.keys()}register(t,e){this._converters.set(t,e),this.events.registered.dispatch({fileType:t,converter:e})}get(t){return this._converters.get(t)}unregister(t){const e=this._converters.get(t);e&&(this._converters.delete(t),this.events.unregistered.dispatch({fileType:t,converter:e}))}}class on extends Vr{constructor(t,e){t=t||{},Mn(t,{name:""}),super(t,e)}get name(){return this.getAttr("name")}set name(t){this.setAttr("name",t)}}const zr=class zr extends on{static isModelSapceName(t){return t.toLowerCase()==zr.MODEL_SPACE_NAME.toLowerCase()}static isPaperSapceName(t){return t.toLowerCase().startsWith(zr.PAPER_SPACE_NAME_PREFIX.toLowerCase())}constructor(){super(),this._origin=new X,this._layoutId="",this._entities=new Map}get isModelSapce(){return zr.isModelSapceName(this.name)}get isPaperSapce(){return zr.isPaperSapceName(this.name)}get origin(){return this._origin}set origin(t){this._origin.copy(t)}get layoutId(){return this._layoutId}set layoutId(t){this._layoutId=t}appendEntity(t){if(Array.isArray(t))for(let e=0;e<t.length;++e){const s=t[e];s.database=this.database,s.ownerId=this.objectId,this._entities.set(s.objectId,s)}else t.database=this.database,t.ownerId=this.objectId,this._entities.set(t.objectId,t);(this.isModelSapce||this.isPaperSapce)&&this.database.events.entityAppended.dispatch({database:this.database,entity:t})}newIterator(){return new _i(this._entities)}getIdAt(t){return this._entities.get(t)}};zr.MODEL_SPACE_NAME="*MODEL_SPACE",zr.PAPER_SPACE_NAME_PREFIX="*PAPER_SPACE";let De=zr;class ln extends Vr{constructor(t){super(),this.database=t,this._recordsByName=new Map,this._recordsById=new Map}add(t){t.database=this.database;const e=this.normalizeName(t.name);this._recordsByName.set(e,t),this._recordsById.set(t.objectId,t)}remove(t){const e=this.normalizeName(t),s=this._recordsByName.get(e);return s?(this._recordsById.delete(s.objectId),this._recordsByName.delete(t),!0):!1}removeId(t){const e=this._recordsById.get(t);return e?(this._recordsByName.delete(e.name),this._recordsById.delete(t),!0):!1}removeAll(){this._recordsByName.clear(),this._recordsById.clear()}has(t){const e=this.normalizeName(t);return this._recordsByName.has(e)}hasId(t){return this._recordsById.has(t)}getAt(t){const e=this.normalizeName(t);return this._recordsByName.get(e)}getIdAt(t){return this._recordsById.get(t)}getOwnerIdAt(t){return this._recordsById.get(t)}newIterator(){return new _i(this._recordsByName)}normalizeName(t){return t}}class Fh extends ln{constructor(t){super(t)}get modelSpace(){let t=this.getAt(De.MODEL_SPACE_NAME);return t||(t=new De,t.name=De.MODEL_SPACE_NAME,this.add(t)),t}normalizeName(t){let e=t;if(De.isModelSapceName(t))e=De.MODEL_SPACE_NAME;else if(De.isPaperSapceName(t)){const s=De.PAPER_SPACE_NAME_PREFIX,o=t.substring(s.length);e=s+o}return e}}class Vh extends ln{constructor(t){super(t)}}class Aa extends on{constructor(t,e){t=t||{},Mn(t,{color:new an,description:"",standardFlags:0,isHidden:!1,isInUse:!0,isOff:!1,isPlottable:!0,transparency:0,linetype:"",lineWeight:1,materialId:-1}),super(t,e),this.attrs.events.attrChanged.addEventListener(s=>{this.database.events.layerModified.dispatch({database:this.database,layer:this,changes:s.object.changedAttributes()})})}get color(){return this.getAttr("color")}set color(t){this.setAttr("color",t.clone())}get description(){return this.getAttr("description")}set description(t){this.setAttr("description",t)}get standardFlags(){return this.getAttr("standardFlags")}set standardFlags(t){this.setAttr("standardFlags",t)}get isFrozen(){return(this.standardFlags&1)==1}set isFrozen(t){const e=t?1:0;this.standardFlags=this.standardFlags|e}get isHidden(){return this.getAttr("isHidden")}set isHidden(t){this.setAttr("isHidden",t)}get isInUse(){return this.getAttr("isInUse")}set isInUse(t){this.setAttr("isInUse",t)}get isLocked(){return(this.standardFlags&4)==4}set isLocked(t){const e=t?4:0;this.standardFlags=this.standardFlags|e}get isOff(){return this.getAttr("isOff")}set isOff(t){this.setAttr("isOff",t)}get isPlottable(){return this.getAttr("isPlottable")}set isPlottable(t){this.setAttr("isPlottable",t)}get transparency(){return this.getAttr("transparency")}set transparency(t){this.setAttr("transparency",t)}get linetype(){return this.getAttr("linetype")}set linetype(t){this.setAttr("linetype",t)}get lineWeight(){return this.getAttr("lineWeight")}set lineWeight(t){this.setAttr("lineWeight",t)}get materialId(){return this.getAttr("materialId")}set materialId(t){this.setAttr("materialId",t)}}class Uh extends ln{constructor(t){super(t);const e=new an;e.color=16777215;const s=new Aa({name:"0",standardFlags:0,linetype:Hs,lineWeight:1,isOff:!1,color:e,isPlottable:!0});this.add(s)}add(t){super.add(t),this.database.events.layerAppended.dispatch({database:this.database,layer:t})}}class jh extends ln{constructor(t){super(t)}}class Gh extends ln{constructor(t){super(t)}get fonts(){const t=new Set,e=o=>{if(o){const h=o.lastIndexOf(".");if(h>=0){const c=o.substring(0,h).toLowerCase();t.add(c)}else t.add(o.toLowerCase())}},s=this.newIterator();for(const o of s)e(o.fileName),e(o.bigFontFileName);return Array.from(t)}}class Wh extends ln{constructor(t){super(t)}}class hd extends Vr{constructor(){super(),this.events={dictObjetSet:new ie,dictObjectErased:new ie,entityAppended:new ie,entityModified:new ie,layerAppended:new ie,layerModified:new ie,layerErased:new ie,openProgress:new ie,headerSysVarChanged:new ie},this._angBase=0,this._angDir=0,this._aunits=ia.DecimalDegrees,this._celtscale=1,this._cecolor=new an,this._extents=new Dt,this._insunits=aa.Millimeters,this._ltscale=1,this._pdmode=0,this._pdsize=0,this._tables={blockTable:new Fh(this),dimStyleTable:new Vh(this),linetypeTable:new jh(this),textStyleTable:new Gh(this),layerTable:new Uh(this),viewportTable:new Wh(this)},this._dictionaries={layouts:new Lh(this),imageDefs:new wa(this)}}get tables(){return this._tables}get dictionaries(){return this._dictionaries}get currentSpaceId(){return this._currentSpace||(this._currentSpace=this._tables.blockTable.modelSpace),this._currentSpace.objectId}set currentSpaceId(t){const e=this.tables.blockTable.getIdAt(t);if(e==null)throw new Error(`[AcDbDatabase] The specified block table record id '${t}' doesn't exist in the drawing database!`);this._currentSpace=e}get aunits(){return this._aunits}set aunits(t){this._aunits=t||0,this.triggerHeaderSysVarChangedEvent("aunits")}get insunits(){return this._insunits}set insunits(t){this._insunits=t||4,this.triggerHeaderSysVarChangedEvent("insunits")}get ltscale(){return this._ltscale}set ltscale(t){this._ltscale=t||1,this.triggerHeaderSysVarChangedEvent("ltscale")}get cecolor(){return this._cecolor}set cecolor(t){this._cecolor=t||0,this.triggerHeaderSysVarChangedEvent("cecolor")}get celtscale(){return this._celtscale}set celtscale(t){this._celtscale=t||1,this.triggerHeaderSysVarChangedEvent("celtscale")}get angBase(){return this._angBase}set angBase(t){this._angBase=t||0,this.triggerHeaderSysVarChangedEvent("angbase")}get angDir(){return this._angDir}set angDir(t){this._angDir=t||0,this.triggerHeaderSysVarChangedEvent("angdir")}get extmax(){return this._extents.max}set extmax(t){this._extents.expandByPoint(t),this.triggerHeaderSysVarChangedEvent("extmax")}get extmin(){return this._extents.min}set extmin(t){this._extents.expandByPoint(t),this.triggerHeaderSysVarChangedEvent("extmin")}get pdmode(){return this._pdmode}set pdmode(t){this._pdmode=t||0,this.triggerHeaderSysVarChangedEvent("pdmode")}get pdsize(){return this._pdsize}set pdsize(t){this._pdsize=t||0,this.triggerHeaderSysVarChangedEvent("pdsize")}async read(t,e,s=vs.DXF){const o=ir.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(t,this,e&&e.minimumChunkSize||10,async(h,c,g,b)=>{if(this.events.openProgress.dispatch({database:this,percentage:h,stage:"CONVERSION",subStage:c,stageStatus:g}),e&&e.fontLoader&&c=="FONT"&&g=="END"){const f=b||this.tables.textStyleTable.fonts;await e.fontLoader.load(f)}})}async openUri(t,e){var k;this.events.openProgress.dispatch({database:this,percentage:0,stage:"FETCH_FILE",stageStatus:"START"});const s=await fetch(t);if(!s.ok)throw this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",stageStatus:"ERROR"}),new Error(`Failed to fetch file '${t}' with HTTP status code '${s.status}'!`);const o=s.headers.get("content-length"),h=o?parseInt(o,10):null;let c=0;const g=(k=s.body)==null?void 0:k.getReader();if(!g)throw new Error("Failed to get response reader");const b=[];for(;;){const{done:M,value:D}=await g.read();if(M)break;if(b.push(D),c+=D.length,h!==null){const z=Math.round(c/h*100);this.events.openProgress.dispatch({database:this,percentage:z,stage:"FETCH_FILE",stageStatus:"IN-PROGRESS"})}}const f=new Uint8Array(c);let S=0;for(const M of b)f.set(M,S),S+=M.length;if(t.toLowerCase().split(".").pop()==="dwg")await this.read(f.buffer,e,vs.DWG);else{const M=new TextDecoder().decode(f);await this.read(M,e,vs.DXF)}this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",stageStatus:"END"})}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(t){this.events.headerSysVarChanged.dispatch({database:this,name:t})}}var Hh=(a=>(a[a.Center=0]="Center",a[a.Left=1]="Left",a[a.Right=2]="Right",a[a.OverFirst=3]="OverFirst",a[a.OverSecond=4]="OverSecond",a))(Hh||{}),qh=(a=>(a[a.Center=0]="Center",a[a.Above=1]="Above",a[a.Outside=2]="Outside",a[a.JIS=3]="JIS",a[a.Below=4]="Below",a))(qh||{}),Yh=(a=>(a[a.Feet=0]="Feet",a[a.None=1]="None",a[a.Inch=2]="Inch",a[a.FeetAndInch=3]="FeetAndInch",a[a.Leading=4]="Leading",a[a.Trailing=8]="Trailing",a[a.LeadingAndTrailing=12]="LeadingAndTrailing",a))(Yh||{}),Kh=(a=>(a[a.None=0]="None",a[a.Leading=1]="Leading",a[a.Trailing=2]="Trailing",a[a.LeadingAndTrailing=3]="LeadingAndTrailing",a))(Kh||{}),Xh=(a=>(a[a.Bottom=0]="Bottom",a[a.Middle=1]="Middle",a[a.Top=2]="Top",a))(Xh||{});const gi=class gi extends on{constructor(t,e){t=t||{},Mn(t,gi.DEFAULT_DIM_VALUES),super(t,e)}get dimpost(){return this.getAttr("dimpost")}set dimpost(t){this.setAttr("dimpost",t)}get dimapost(){return this.getAttr("dimapost")}set dimapost(t){this.setAttr("dimapost",t)}get dimscale(){return this.getAttr("dimscale")}set dimscale(t){this.setAttr("dimscale",t)}get dimasz(){return this.getAttr("dimasz")}set dimasz(t){this.setAttr("dimasz",t)}get dimexo(){return this.getAttr("dimexo")}set dimexo(t){this.setAttr("dimexo",t)}get dimdli(){return this.getAttr("dimdli")}set dimdli(t){this.setAttr("dimdli",t)}get dimexe(){return this.getAttr("dimexe")}set dimexe(t){this.setAttr("dimexe",t)}get dimrnd(){return this.getAttr("dimrnd")}set dimrnd(t){this.setAttr("dimrnd",t)}get dimdle(){return this.getAttr("dimdle")}set dimdle(t){this.setAttr("dimdle",t)}get dimtp(){return this.getAttr("dimtp")}set dimtp(t){this.setAttr("dimtp",t)}get dimtm(){return this.getAttr("dimtm")}set dimtm(t){this.setAttr("dimtm",t)}get dimtxt(){return this.getAttr("dimtxt")}set dimtxt(t){this.setAttr("dimtxt",t)}get dimcen(){return this.getAttr("dimcen")}set dimcen(t){this.setAttr("dimcen",t)}get dimtsz(){return this.getAttr("dimtsz")}set dimtsz(t){this.setAttr("dimtsz",t)}get dimaltf(){return this.getAttr("dimaltf")}set dimaltf(t){this.setAttr("dimaltf",t)}get dimlfac(){return this.getAttr("dimlfac")}set dimlfac(t){this.setAttr("dimlfac",t)}get dimtvp(){return this.getAttr("dimtvp")}set dimtvp(t){this.setAttr("dimtvp",t)}get dimtfac(){return this.getAttr("dimtfac")}set dimtfac(t){this.setAttr("dimtfac",t)}get dimgap(){return this.getAttr("dimgap")}set dimgap(t){this.setAttr("dimgap",t)}get dimaltrnd(){return this.getAttr("dimaltrnd")}set dimaltrnd(t){this.setAttr("dimaltrnd",t)}get dimtol(){return this.getAttr("dimtol")}set dimtol(t){this.setAttr("dimtol",t)}get dimlim(){return this.getAttr("dimlim")}set dimlim(t){this.setAttr("dimlim",t)}get dimtih(){return this.getAttr("dimtih")}set dimtih(t){this.setAttr("dimtih",t)}get dimtoh(){return this.getAttr("dimtoh")}set dimtoh(t){this.setAttr("dimtoh",t)}get dimse1(){return this.getAttr("dimse1")}set dimse1(t){this.setAttr("dimse1",t)}get dimse2(){return this.getAttr("dimse2")}set dimse2(t){this.setAttr("dimse2",t)}get dimtad(){return this.getAttr("dimtad")}set dimtad(t){this.setAttr("dimtad",t)}get dimzin(){return this.getAttr("dimzin")}set dimzin(t){this.setAttr("dimzin",t)}get dimazin(){return this.getAttr("dimazin")}set dimazin(t){this.setAttr("dimazin",t)}get dimalt(){return this.getAttr("dimalt")}set dimalt(t){this.setAttr("dimalt",t)}get dimaltd(){return this.getAttr("dimaltd")}set dimaltd(t){this.setAttr("dimaltd",t)}get dimtofl(){return this.getAttr("dimtofl")}set dimtofl(t){this.setAttr("dimtofl",t)}get dimsah(){return this.getAttr("dimsah")}set dimsah(t){this.setAttr("dimsah",t)}get dimtix(){return this.getAttr("dimtix")}set dimtix(t){this.setAttr("dimtix",t)}get dimsoxd(){return this.getAttr("dimsoxd")}set dimsoxd(t){this.setAttr("dimsoxd",t)}get dimclrd(){return this.getAttr("dimclrd")}set dimclrd(t){this.setAttr("dimclrd",t)}get dimclre(){return this.getAttr("dimclre")}set dimclre(t){this.setAttr("dimclre",t)}get dimclrt(){return this.getAttr("dimclrt")}set dimclrt(t){this.setAttr("dimclrt",t)}get dimadec(){return this.getAttr("dimadec")}set dimadec(t){this.setAttr("dimadec",t)}get dimunit(){return this.getAttr("dimunit")}set dimunit(t){this.setAttr("dimunit",t)}get dimdec(){return this.getAttr("dimdec")}set dimdec(t){this.setAttr("dimdec",t)}get dimtdec(){return this.getAttr("dimtdec")}set dimtdec(t){this.setAttr("dimtdec",t)}get dimaltu(){return this.getAttr("dimaltu")}set dimaltu(t){this.setAttr("dimaltu",t)}get dimalttd(){return this.getAttr("dimalttd")}set dimalttd(t){this.setAttr("dimalttd",t)}get dimaunit(){return this.getAttr("dimaunit")}set dimaunit(t){this.setAttr("dimaunit",t)}get dimfrac(){return this.getAttr("dimfrac")}set dimfrac(t){this.setAttr("dimfrac",t)}get dimlunit(){return this.getAttr("dimlunit")}set dimlunit(t){this.setAttr("dimlunit",t)}get dimdsep(){return this.getAttr("dimdsep")}set dimdsep(t){this.setAttr("dimdsep",t)}get dimtmove(){return this.getAttr("dimtmove")}set dimtmove(t){this.setAttr("dimtmove",t)}get dimjust(){return this.getAttr("dimjust")}set dimjust(t){this.setAttr("dimjust",t)}get dimsd1(){return this.getAttr("dimsd1")}set dimsd1(t){this.setAttr("dimsd1",t)}get dimsd2(){return this.getAttr("dimsd2")}set dimsd2(t){this.setAttr("dimsd2",t)}get dimtolj(){return this.getAttr("dimtolj")}set dimtolj(t){this.setAttr("dimtolj",t)}get dimtzin(){return this.getAttr("dimtzin")}set dimtzin(t){this.setAttr("dimtzin",t)}get dimaltz(){return this.getAttr("dimaltz")}set dimaltz(t){this.setAttr("dimaltz",t)}get dimalttz(){return this.getAttr("dimalttz")}set dimalttz(t){this.setAttr("dimalttz",t)}get dimfit(){return this.getAttr("dimfit")}set dimfit(t){this.setAttr("dimfit",t)}get dimupt(){return this.getAttr("dimupt")}set dimupt(t){this.setAttr("dimupt",t)}get dimatfit(){return this.getAttr("dimatfit")}set dimatfit(t){this.setAttr("dimatfit",t)}get dimtxsty(){return this.getAttr("dimtxsty")}set dimtxsty(t){this.setAttr("dimtxsty",t)}get dimldrblk(){return this.getAttr("dimldrblk")}set dimldrblk(t){this.setAttr("dimldrblk",t)}get dimblk(){return this.getAttr("dimblk")}set dimblk(t){this.setAttr("dimblk",t)}get dimblk1(){return this.getAttr("dimblk1")}set dimblk1(t){this.setAttr("dimblk1",t)}get dimblk2(){return this.getAttr("dimblk2")}set dimblk2(t){this.setAttr("dimblk2",t)}get dimlwd(){return this.getAttr("dimlwd")}set dimlwd(t){this.setAttr("dimlwd",t)}get dimlwe(){return this.getAttr("dimlwe")}set dimlwe(t){this.setAttr("dimlwe",t)}};gi.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 ws=gi;class $h extends on{constructor(t){super(),this.name=t.name,this._linetype=t}get numDashes(){return this._linetype.pattern?this._linetype.pattern.length:0}get patternLength(){return this._linetype.totalPatternLength}get comments(){return this._linetype.description}get linetype(){return this._linetype}dashLengthAt(t){if(t<0||t>=this.numDashes)throw new Error('Index must be greater than or equal to zero, but less than the value of property "numDashes".');return this._linetype.pattern[t].elementLength}}class Zh extends on{constructor(t){super(),this.name=t.name,this._textStyle=t,this._textStyle.font=this.getFileNameWithoutExtension(this._textStyle.font||this._textStyle.extendedFont||this.name),this._isVertical=!1}get obliquingAngle(){return this._textStyle.obliqueAngle}set obliquingAngle(t){this._textStyle.obliqueAngle=t}get priorSize(){return this._textStyle.lastHeight}set priorSize(t){this._textStyle.lastHeight=t}get textSize(){return this._textStyle.fixedTextHeight}set textSize(t){this._textStyle.fixedTextHeight=t}get xScale(){return this._textStyle.widthFactor}set xScale(t){this._textStyle.widthFactor=t}get isVertical(){return this._isVertical}set isVertical(t){this._isVertical=t}get fileName(){return this._textStyle.font}set fileName(t){this._textStyle.font=t}get bigFontFileName(){return this._textStyle.bigFont}set bigFontFileName(t){this._textStyle.bigFont=t}get textStyle(){return this._textStyle}getFileNameWithoutExtension(t){const e=t.split("/").pop();if(e){const s=e.lastIndexOf(".");return s===-1?e:e.substring(0,s)}return t}}const ud={center:new Mt,viewDirectionFromTarget:new X(0,0,1),viewTarget:new X(0,0,0),lensLength:500,frontClippingPlane:0,backClippingPlane:0,viewHeight:1e3,viewTwistAngle:0,frozenLayers:[],styleSheet:"",renderMode:va.OPTIMIZED_2D,viewMode:0,ucsIconSetting:0,ucsOrigin:new X(0,0,0),ucsXAxis:new X(1,0,0),ucsYAxis:new X(0,1,0),orthographicType:ya.TOP,shadePlotSetting:0,shadePlotObjectId:void 0,visualStyleObjectId:void 0,isDefaultLightingOn:!1,defaultLightingType:ba.ONE_DISTANT_LIGHT,brightness:0,contrast:0,ambientColor:void 0};class Qh extends on{constructor(){super(),this._circleSides=100,this._center=new Mt,this._lowerLeftCorner=new Mt(0,0),this._upperRightCorner=new Mt(1,1),this._snapBase=new Mt(0,0),this._snapAngle=0,this._snapSpacing=new Mt(0,0),this._standardFlag=0,this._gridSpacing=new Mt,this._gridMajor=10,this._gsView=ud}get circleSides(){return this._circleSides}set circleSides(t){this._circleSides=t}get center(){return this._center}get lowerLeftCorner(){return this._lowerLeftCorner}set lowerLeftCorner(t){this._lowerLeftCorner.copy(t)}get upperRightCorner(){return this._upperRightCorner}set upperRightCorner(t){this._upperRightCorner.copy(t)}get snapBase(){return this._snapBase}set snapBase(t){this._snapBase.copy(t)}get snapAngle(){return this._snapAngle}set snapAngle(t){this._snapAngle=t}get snapIncrements(){return this._snapSpacing}set snapIncrements(t){this._snapSpacing.copy(t)}get gridMajor(){return this._gridMajor}set gridMajor(t){this._gridMajor=t}get gridIncrements(){return this._gridSpacing}set gridIncrements(t){this._gridSpacing.copy(t)}get standardFlag(){return this._standardFlag}set standardFlag(t){this._standardFlag=t}get snapEnabled(){return!!(this._standardFlag&256)}get backgroundObjectId(){return this._backgroundObjectId}set backgroundObjectId(t){this._backgroundObjectId=t}get gsView(){return this._gsView}}class Jh{constructor(){this.events={layoutCreated:new ie,layoutRemoved:new ie,layoutRenamed:new ie,layoutSwitched:new ie}}countLayouts(t){return this.getWorkingDatabase(t).dictionaries.layouts.numEntries}findLayoutNamed(t,e){return this.getWorkingDatabase(e).dictionaries.layouts.getAt(t)}findActiveLayout(){const t=this.getActiveLayout();return t?t.layoutName:"Model"}setCurrentLayoutId(t,e){const s=this.getWorkingDatabase(e),o=s.dictionaries.layouts.getIdAt(t);return this.setCurrentLayoutInternal(o,s)}setCurrentLayoutBtrId(t,e){const s=this.getWorkingDatabase(e),o=s.dictionaries.layouts.getBtrIdAt(t);return this.setCurrentLayoutInternal(o,s)}setCurrentLayout(t,e){const s=this.getWorkingDatabase(e),o=s.dictionaries.layouts.getAt(t);return this.setCurrentLayoutInternal(o,s)}renameLayout(t,e,s){const h=this.getWorkingDatabase(s).dictionaries.layouts.getAt(t);return h?(h.layoutName=e,this.events.layoutRenamed.dispatch({layout:h,oldName:t,newName:e}),!0):!1}layoutExists(t,e){return this.getWorkingDatabase(e).dictionaries.layouts.has(t)}deleteLayout(t,e){const s=this.getWorkingDatabase(e).dictionaries.layouts,o=s.getAt(t);let h=!1;return o&&(h=s.remove(t),h&&this.events.layoutRemoved.dispatch({layout:o})),h}createLayout(t,e){const s=this.getWorkingDatabase(e),o=new xa;o.layoutName=t,o.tabOrder=s.dictionaries.layouts.maxTabOrder;const h=new De;return h.name=`*Paper_Space${o.tabOrder}`,s.tables.blockTable.add(h),s.dictionaries.layouts.setAt(t,o),this.events.layoutCreated.dispatch({layout:o}),{layout:o,btr:h}}getActiveLayout(t){const e=this.getWorkingDatabase(t);return e.dictionaries.layouts.getBtrIdAt(e.currentSpaceId)}getWorkingDatabase(t){return t||Pa().workingDatabase}setCurrentLayoutInternal(t,e){return t?(this.events.layoutSwitched.dispatch({layout:t}),e.currentSpaceId=t.blockTableRecordId,!0):!1}}function Pa(){return pi.instance}const fi=class fi{constructor(){this._workingDatabase=null,this._layoutManager=new Jh}get workingDatabase(){if(this._workingDatabase==null)throw new Error("The current working database must be set before using it!");return this._workingDatabase}set workingDatabase(t){this._workingDatabase=t}get layoutManager(){return this._layoutManager}};fi.instance=new fi;let pi=fi;exports.AcCmColor=an;exports.AcCmErrors=Re;exports.AcCmEventDispatcher=_u;exports.AcCmEventManager=ie;exports.AcCmLoader=Su;exports.AcCmLoadingManager=Go;exports.AcCmObject=Fo;exports.AcCmPerformanceCollector=ea;exports.AcCmTask=Uo;exports.AcCmTaskScheduler=jo;exports.AcDb3PointAngularDimension=hi;exports.AcDbAlignedDimension=ui;exports.AcDbAngleUnits=ia;exports.AcDbArc=Ks;exports.AcDbArcDimension=ta;exports.AcDbBaseWorker=ld;exports.AcDbBatchProcessing=Ho;exports.AcDbBlockReference=ys;exports.AcDbBlockTable=Fh;exports.AcDbBlockTableRecord=De;exports.AcDbCircle=Xs;exports.AcDbCurve=Be;exports.AcDbDatabase=hd;exports.AcDbDatabaseConverter=jl;exports.AcDbDatabaseConverterManager=ir;exports.AcDbDiametricDimension=ci;exports.AcDbDictionary=wa;exports.AcDbDimArrowType=Vl;exports.AcDbDimStyleTable=Vh;exports.AcDbDimStyleTableRecord=ws;exports.AcDbDimTextHorizontal=Hh;exports.AcDbDimTextVertical=qh;exports.AcDbDimVerticalJustification=Xh;exports.AcDbDimZeroSuppression=Yh;exports.AcDbDimZeroSuppressionAngular=Kh;exports.AcDbDimension=wr;exports.AcDbDxfConverter=Bh;exports.AcDbEllipse=Ys;exports.AcDbEntity=je;exports.AcDbFileType=vs;exports.AcDbHatch=$s;exports.AcDbHatchPatternType=Sh;exports.AcDbHatchStyle=Ih;exports.AcDbHostApplicationServices=pi;exports.AcDbLayerTable=Uh;exports.AcDbLayerTableRecord=Aa;exports.AcDbLayout=xa;exports.AcDbLayoutDictionary=Lh;exports.AcDbLayoutManager=Jh;exports.AcDbLeader=Zs;exports.AcDbLeaderAnnotationType=kh;exports.AcDbLine=Qs;exports.AcDbLineSpacingStyle=Nh;exports.AcDbLinetypeTable=jh;exports.AcDbLinetypeTableRecord=$h;exports.AcDbMText=Js;exports.AcDbObject=Vr;exports.AcDbObjectIterator=_i;exports.AcDbOrdinateDimension=di;exports.AcDbOsnapMode=tn;exports.AcDbPoint=si;exports.AcDbPolyline=ni;exports.AcDbRadialDimension=mi;exports.AcDbRasterImage=xs;exports.AcDbRasterImageClipBoundaryType=Th;exports.AcDbRasterImageDef=Oh;exports.AcDbRasterImageImageDisplayOpt=Ch;exports.AcDbRay=ii;exports.AcDbRenderingCache=Dr;exports.AcDbSpline=bs;exports.AcDbSymbolTable=ln;exports.AcDbSymbolTableRecord=on;exports.AcDbTable=ti;exports.AcDbText=ei;exports.AcDbTextHorizontalMode=Eh;exports.AcDbTextStyleTable=Gh;exports.AcDbTextStyleTableRecord=Zh;exports.AcDbTextVerticalMode=Mh;exports.AcDbTrace=ri;exports.AcDbUnitsValue=aa;exports.AcDbViewport=ai;exports.AcDbViewportTable=Wh;exports.AcDbViewportTableRecord=Qh;exports.AcDbWipeout=oi;exports.AcDbWorkerApi=Dh;exports.AcDbWorkerManager=zh;exports.AcDbXline=li;exports.AcGeArea2d=yi;exports.AcGeBox2d=_e;exports.AcGeBox3d=Dt;exports.AcGeCatmullRomCurve3d=Ah;exports.AcGeCircArc2d=kn;exports.AcGeCircArc3d=rn;exports.AcGeCurve2d=Tn;exports.AcGeEllipseArc2d=bi;exports.AcGeEllipseArc3d=xi;exports.AcGeEuler=yh;exports.AcGeGeometryUtil=ch;exports.AcGeLine2d=wi;exports.AcGeLine3d=Br;exports.AcGeLoop2d=xh;exports.AcGeMathUtil=St;exports.AcGeMatrix2d=vi;exports.AcGeMatrix3d=sn;exports.AcGeNurbsCurve=nn;exports.AcGePlane=As;exports.AcGePoint2d=Mt;exports.AcGePoint3d=X;exports.AcGePolyline2d=Ss;exports.AcGeQuaternion=Rr;exports.AcGeShape2d=fa;exports.AcGeSpline3d=Fr;exports.AcGeTol=ma;exports.AcGeVector2d=Kt;exports.AcGeVector3d=$;exports.AcGiArrowType=_a;exports.AcGiDefaultLightingType=ba;exports.AcGiMTextAttachmentPoint=En;exports.AcGiMTextFlowDirection=Ai;exports.AcGiOrthographicType=ya;exports.AcGiRenderMode=va;exports.AcGiViewport=Pi;exports.AcTrStringUtil=Pu;exports.ByBlock=Fl;exports.ByLayer=Gs;exports.DEBUG_MODE=wu;exports.DEFAULT_LINE_TYPE=Hs;exports.DEFAULT_TOL=pa;exports.DEG2RAD=oa;exports.DefaultLoadingManager=Wo;exports.FLOAT_TOL=Jr;exports.ORIGIN_POINT_2D=$c;exports.ORIGIN_POINT_3D=da;exports.RAD2DEG=la;exports.TAU=re;exports.acdbHostApplicationServices=Pa;exports.basisFunction=qs;exports.calculateCurveLength=gh;exports.ceilPowerOfTwo=nh;exports.clamp=xr;exports.clone=ms;exports.createWorkerApi=Rh;exports.damp=ql;exports.defaults=Mn;exports.degToRad=th;exports.euclideanModulo=ha;exports.evaluateNurbsPoint=_s;exports.floorPowerOfTwo=sh;exports.generateChordKnots=mh;exports.generateSqrtChordKnots=ph;exports.generateUUID=Gl;exports.generateUniformKnots=dh;exports.has=Ro;exports.intPartLength=ca;exports.interpolateControlPoints=Zc;exports.inverseLerp=Hl;exports.isBetween=ih;exports.isBetweenAngle=ah;exports.isEmpty=Bo;exports.isEqual=Sn;exports.isImperialUnits=Xc;exports.isMetricUnits=Kc;exports.isPointInPolygon=ga;exports.isPolygonIntersect=uh;exports.isPowerOfTwo=rh;exports.lerp=ua;exports.log=gs;exports.mapLinear=Wl;exports.normalizeAngle=fs;exports.pingpong=Yl;exports.radToDeg=eh;exports.randFloat=Zl;exports.randFloatSpread=Ql;exports.randInt=$l;exports.relativeEps=oh;exports.seededRandom=Jl;exports.setLogLevel=Au;exports.smootherstep=Xl;exports.smoothstep=Kl;
5
+ `+n+"}",T;case"function":return"<function>";case"string":return r;default:return String(r)}},kt.__interfLoop=function(r,n){if(r==null)return!1;if(r==n)return!0;var i=r.__interfaces__;if(i!=null)for(var l=0,u=i.length;l<u;){var d=l++,p=i[d];if(p==n||kt.__interfLoop(p,n))return!0}return kt.__interfLoop(r.__super__,n)},kt.__instanceof=function(r,n){if(n==null)return!1;switch(n){case eu:return(r|0)===r;case Ja:return typeof r=="number";case to:return typeof r=="boolean";case String:return typeof r=="string";case Array:return r instanceof Array&&r.__enum__==null;case ru:return!0;default:if(r!=null){if(typeof n=="function"){if(r instanceof n||kt.__interfLoop(kt.getClass(r),n))return!0}else if(typeof n=="object"&&kt.__isNativeObj(n)&&r instanceof n)return!0}else return!1;return n==eo&&r.__name__!=null||n==ro&&r.__ename__!=null?!0:r.__enum__==n}},kt.__nativeClassName=function(r){var n=kt.__toStr.call(r).slice(8,-1);return n=="Object"||n=="Function"||n=="Math"||n=="JSON"?null:n},kt.__isNativeObj=function(r){return kt.__nativeClassName(r)!=null},kt.__resolveNativeClass=function(r){return S[r]};var oe=function(r){if(r instanceof Array&&r.__enum__==null)this.a=r,this.byteLength=r.length;else{var n=r;this.a=[];for(var i=0;i<n;){var l=i++;this.a[l]=0}this.byteLength=n}};x["js.html.compat.ArrayBuffer"]=oe,oe.__name__=["js","html","compat","ArrayBuffer"],oe.sliceImpl=function(r,n){var i=new Ei(this,r,n==null?null:n-r),l=new Es(i.byteLength),u=new Ei(l);return u.set(i),l},oe.prototype={slice:function(r,n){return new oe(this.a.slice(r,n))},__class__:oe};var ar=function(r,n,i){if(this.buf=r,n==null?this.offset=0:this.offset=n,i==null?this.length=r.byteLength-this.offset:this.length=i,this.offset<0||this.length<0||this.offset+this.length>r.byteLength)throw new Q(Qt.OutsideBounds)};x["js.html.compat.DataView"]=ar,ar.__name__=["js","html","compat","DataView"],ar.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 i=this.getUint16(r,n);return i>=32768?i-65536:i},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 i=this.offset+r,l=this.buf.a[i++],u=this.buf.a[i++],d=this.buf.a[i++],p=this.buf.a[i++];return n?l|u<<8|d<<16|p<<24:p|d<<8|u<<16|l<<24},getUint32:function(r,n){var i=this.getInt32(r,n);return i<0?i+4294967296:i},getFloat32:function(r,n){return ae.i32ToFloat(this.getInt32(r,n))},getFloat64:function(r,n){var i=this.getInt32(r,n),l=this.getInt32(r+4,n);return ae.i64ToDouble(n?i:l,n?l:i)},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,i){this.setUint16(r,n<0?n+65536:n,i)},setUint16:function(r,n,i){var l=r+this.offset;i?(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,i){this.setUint32(r,n,i)},setUint32:function(r,n,i){var l=r+this.offset;i?(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,i){this.setUint32(r,ae.floatToI32(n),i)},setFloat64:function(r,n,i){var l=ae.doubleToI64(n);i?(this.setUint32(r,l.low),this.setUint32(r,l.high)):(this.setUint32(r,l.high),this.setUint32(r,l.low))},__class__:ar};var tr=function(){};x["js.html.compat.Uint8Array"]=tr,tr.__name__=["js","html","compat","Uint8Array"],tr._new=function(r,n,i){var l;if(typeof r=="number"){l=[];for(var u=0;u<r;){var d=u++;l[d]=0}l.byteLength=l.length,l.byteOffset=0,l.buffer=new oe(l)}else if(kt.__instanceof(r,oe)){var p=r;n==null&&(n=0),i==null&&(i=p.byteLength-n),n==0?l=p.a:l=p.a.slice(n,n+i),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 oe(l);else throw new Q("TODO "+gt.string(r));return l.subarray=tr._subarray,l.set=tr._set,l},tr._set=function(r,n){var i=this;if(kt.__instanceof(r.buffer,oe)){var l=r;if(r.byteLength+n>i.byteLength)throw new Q("set() outside of range");for(var u=0,d=r.byteLength;u<d;){var p=u++;i[p+n]=l[p]}}else if(r instanceof Array&&r.__enum__==null){var _=r;if(_.length+n>i.byteLength)throw new Q("set() outside of range");for(var v=0,w=_.length;v<w;){var P=v++;i[P+n]=_[P]}}else throw new Q("TODO")},tr._subarray=function(r,n){var i=this,l=tr._new(i.slice(r,n));return l.byteOffset=r,l};var It=function(r){this._resolved=!1,this._pending=!1,this._errorPending=!1,this._fulfilled=!1,this._update=[],this._error=[],this._errored=!1,r!=null&&It.link(r,this,function(n){return n})};x["promhx.base.AsyncBase"]=It,It.__name__=["promhx","base","AsyncBase"],It.link=function(r,n,i){r._update.push({async:n,linkf:function(l){n.handleResolve(i(l))}}),It.immediateLinkUpdate(r,n,i)},It.immediateLinkUpdate=function(r,n,i){if(r._errored&&!r._errorPending&&!(r._error.length>0)&&n.handleError(r._errorVal),r._resolved&&!r._pending)try{n.handleResolve(i(r._val))}catch(l){l instanceof Q&&(l=l.val),n.handleError(l)}},It.linkAll=function(r,n){for(var i=function(d,p,_){if(d.length==0||It.allFulfilled(d)){for(var v,w=[],P=He(r)();P.hasNext();){var A=P.next();w.push(A==p?_:A._val)}v=w,n.handleResolve(v)}},l=He(r)();l.hasNext();){var u=l.next();u._update.push({async:n,linkf:function(d,p,_){return function(v){d(p,_,v)}}(i,function(d){for(var p,_=[],v=He(r)();v.hasNext();){var w=v.next();w!=u&&_.push(w)}return p=_,p}(),u)})}It.allFulfilled(r)&&n.handleResolve(function(d){for(var p,_=[],v=He(r)();v.hasNext();){var w=v.next();_.push(w._val)}return p=_,p}())},It.pipeLink=function(r,n,i){var l=!1,u=function(d){if(!l){l=!0;var p=i(d);p._update.push({async:n,linkf:Me(n,n.handleResolve)}),It.immediateLinkUpdate(p,n,function(_){return _})}};if(r._update.push({async:n,linkf:u}),r._resolved&&!r._pending)try{u(r._val)}catch(d){d instanceof Q&&(d=d.val),n.handleError(d)}},It.allResolved=function(r){for(var n=He(r)();n.hasNext();){var i=n.next();if(!i._resolved)return!1}return!0},It.allFulfilled=function(r){for(var n=He(r)();n.hasNext();){var i=n.next();if(!i._fulfilled)return!1}return!0},It.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?wt.enqueue(function(i,l){return function(){i(l)}}(Me(this,this._resolve),r)):(this._resolved=!0,this._pending=!0,wt.queue.add(function(){n._val=r;for(var i=0,l=n._update;i<l.length;){var u=l[i];++i;try{u.linkf(r)}catch(d){d instanceof Q&&(d=d.val),u.async.handleError(d)}}n._fulfilled=!0,n._pending=!1}),wt.continueOnNextLoop())},handleError:function(r){this._handleError(r)},_handleError:function(r){var n=this,i=function(l){if(n._error.length>0)for(var u=0,d=n._error;u<d.length;){var p=d[u];++u,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,wt.queue.add(function(){if(n._errorMap!=null)try{n._resolve(n._errorMap(r))}catch(l){l instanceof Q&&(l=l.val),i(l)}else i(r)}),wt.continueOnNextLoop())},then:function(r){var n=new It(null);return It.link(this,n,r),n},unlink:function(r){var n=this;wt.queue.add(function(){n._update=n._update.filter(function(i){return i.async!=r})}),wt.continueOnNextLoop()},isLinked:function(r){for(var n=!1,i=0,l=this._update;i<l.length;){var u=l[i];if(++i,u.async==r)return!0}return n},__class__:It};var hn=f.promhx.Deferred=function(){It.call(this)};x["promhx.Deferred"]=hn,hn.__name__=["promhx","Deferred"],hn.__super__=It,hn.prototype=M(It.prototype,{resolve:function(r){this.handleResolve(r)},throwError:function(r){this.handleError(r)},promise:function(){return new pe(this)},stream:function(){return new jt(this)},publicStream:function(){return new Ar(this)},__class__:hn});var pe=f.promhx.Promise=function(r){It.call(this,r),this._rejected=!1};x["promhx.Promise"]=pe,pe.__name__=["promhx","Promise"],pe.whenAll=function(r){var n=new pe(null);return It.linkAll(r,n),n},pe.promise=function(r){var n=new pe;return n.handleResolve(r),n},pe.__super__=It,pe.prototype=M(It.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(un.AlreadyResolved(n))}this._resolve(r)},then:function(r){var n=new pe(null);return It.link(this,n,r),n},unlink:function(r){var n=this;wt.queue.add(function(){if(n._fulfilled)n._update=n._update.filter(function(l){return l.async!=r});else{var i="Downstream Promise is not fullfilled";n.handleError(un.DownstreamNotFullfilled(i))}}),wt.continueOnNextLoop()},handleError:function(r){this._rejected=!0,this._handleError(r)},pipe:function(r){var n=new pe(null);return It.pipeLink(this,n,r),n},errorPipe:function(r){var n=new pe;return this.catchError(function(i){var l=r(i);l.then(Me(n,n._resolve))}),this.then(Me(n,n._resolve)),n},__class__:pe});var jt=f.promhx.Stream=function(r){It.call(this,r),this._end_promise=new pe};x["promhx.Stream"]=jt,jt.__name__=["promhx","Stream"],jt.foreach=function(r){for(var n=new jt(null),i=He(r)();i.hasNext();){var l=i.next();n.handleResolve(l)}return n.end(),n},jt.wheneverAll=function(r){var n=new jt(null);return It.linkAll(r,n),n},jt.concatAll=function(r){for(var n=new jt(null),i=He(r)();i.hasNext();){var l=i.next();n.concat(l)}return n},jt.mergeAll=function(r){for(var n=new jt(null),i=He(r)();i.hasNext();){var l=i.next();n.merge(l)}return n},jt.stream=function(r){var n=new jt(null);return n.handleResolve(r),n},jt.__super__=It,jt.prototype=M(It.prototype,{then:function(r){var n=new jt(null);return It.link(this,n,r),this._end_promise._update.push({async:n._end_promise,linkf:function(i){n.end()}}),n},detachStream:function(r){for(var n=[],i=!1,l=0,u=this._update;l<u.length;){var d=u[l];++l,d.async==r?(this._end_promise._update=this._end_promise._update.filter(function(p){return p.async!=r._end_promise}),i=!0):n.push(d)}return this._update=n,i},first:function(){var r=new pe(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 jt(null);return It.pipeLink(this,n,r),this._end_promise.then(function(i){n.end()}),n},errorPipe:function(r){var n=new jt(null);return this.catchError(function(i){var l=r(i);l.then(Me(n,n._resolve)),l._end_promise.then((Ii=n._end_promise,Me(Ii,Ii._resolve)))}),this.then(Me(n,n._resolve)),this._end_promise.then(function(i){n.end()}),n},handleEnd:function(){if(this._pending)wt.queue.add(Me(this,this.handleEnd)),wt.continueOnNextLoop();else{if(this._end_promise._resolved)return;this._end=!0;var r;this._resolved?r=de.Some(this._val):r=de.None,this._end_promise.handleResolve(r),this._update=[],this._error=[]}},end:function(){return wt.queue.add(Me(this,this.handleEnd)),wt.continueOnNextLoop(),this},endThen:function(r){return this._end_promise.then(r)},filter:function(r){var n=new jt(null);return this._update.push({async:n,linkf:function(i){r(i)&&n.handleResolve(i)}}),It.immediateLinkUpdate(this,n,function(i){return i}),n},concat:function(r){var n=new jt(null);return this._update.push({async:n,linkf:Me(n,n.handleResolve)}),It.immediateLinkUpdate(this,n,function(i){return i}),this._end_promise.then(function(i){r.pipe(function(l){return n.handleResolve(l),n}),r._end_promise.then(function(l){n.end()})}),n},merge:function(r){var n=new jt(null);return this._update.push({async:n,linkf:Me(n,n.handleResolve)}),r._update.push({async:n,linkf:Me(n,n.handleResolve)}),It.immediateLinkUpdate(this,n,function(i){return i}),It.immediateLinkUpdate(r,n,function(i){return i}),n},__class__:jt});var Ar=f.promhx.PublicStream=function(r){jt.call(this,r)};x["promhx.PublicStream"]=Ar,Ar.__name__=["promhx","PublicStream"],Ar.publicstream=function(r){var n=new Ar(null);return n.handleResolve(r),n},Ar.__super__=jt,Ar.prototype=M(jt.prototype,{resolve:function(r){this.handleResolve(r)},throwError:function(r){this.handleError(r)},update:function(r){this.handleResolve(r)},__class__:Ar});var wt=function(){};x["promhx.base.EventLoop"]=wt,wt.__name__=["promhx","base","EventLoop"],wt.enqueue=function(r){wt.queue.add(r),wt.continueOnNextLoop()},wt.set_nextLoop=function(r){if(wt.nextLoop!=null)throw new Q("nextLoop has already been set");return wt.nextLoop=r,wt.nextLoop},wt.queueEmpty=function(){return wt.queue.isEmpty()},wt.finish=function(r){r==null&&(r=1e3);for(var n=null;r-- >0&&(n=wt.queue.pop())!=null;)n();return wt.queue.isEmpty()},wt.clear=function(){wt.queue=new U},wt.f=function(){var r=wt.queue.pop();r!=null&&r(),wt.queue.isEmpty()||wt.continueOnNextLoop()},wt.continueOnNextLoop=function(){wt.nextLoop!=null?wt.nextLoop(wt.f):setImmediate(wt.f)};var un=x["promhx.error.PromiseError"]={__ename__:["promhx","error","PromiseError"],__constructs__:["AlreadyResolved","DownstreamNotFullfilled"]};un.AlreadyResolved=function(r){var n=["AlreadyResolved",0,r];return n.__enum__=un,n.toString=k,n},un.DownstreamNotFullfilled=function(r){var n=["DownstreamNotFullfilled",1,r];return n.__enum__=un,n.toString=k,n};var Is=function(){};x["verb.Verb"]=Is,Is.__name__=["verb","Verb"],Is.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,i,l){r.splice(n,i),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 i=[r.pop()];r.length>0;){for(var l=r.pop(),u=!0,d=0;d<i.length;){var p=i[d];if(++d,n(l,p)){u=!1;break}}u&&i.push(l)}return i};var zt=function(){};x["verb.core.Binomial"]=zt,zt.__name__=["verb","core","Binomial"],zt.get=function(r,n){if(n==0)return 1;if(r==0||n>r)return 0;if(n>r-n&&(n=r-n),zt.memo_exists(r,n))return zt.get_memo(r,n);for(var i=1,l=r,u=1,d=n+1;u<d;){var p=u++;if(zt.memo_exists(l,p)){r--,i=zt.get_memo(l,p);continue}i*=r--,i/=p,zt.memoize(l,p,i)}return i},zt.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 i=1,l=1,u=n+1;l<u;){var d=l++;i*=r--,i/=d}return i},zt.memo_exists=function(r,n){return zt.memo.h.hasOwnProperty(r)&&zt.memo.h[r].h.hasOwnProperty(n)},zt.get_memo=function(r,n){return zt.memo.h[r].h[n]},zt.memoize=function(r,n,i){zt.memo.h.hasOwnProperty(r)||zt.memo.set(r,new bt),zt.memo.h[r].h[n]=i};var ke=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"]=ke,ke.__name__=["verb","core","BoundingBox"],ke.intervalsOverlap=function(r,n,i,l,u){u==null&&(u=-1);var d;u<-.5?d=rt.TOLERANCE:d=u;var p=Math.min(r,n)-d,_=Math.max(r,n)+d,v=Math.min(i,l)-d,w=Math.max(i,l)+d;return p>=v&&p<=w||_>=v&&_<=w||v>=p&&v<=_||w>=p&&w<=_},ke.prototype={fromPoint:function(r){return new ke([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,i=this.dim;n<i;){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,i=0;i<n;){var l=i++;this.add(r[l])}return this},contains:function(r,n){return n==null&&(n=-1),this.initialized?this.intersects(new ke([r]),n):!1},intersects:function(r,n){if(n==null&&(n=-1),!this.initialized||!r.initialized)return!1;for(var i=this.min,l=this.max,u=r.min,d=r.max,p=0,_=this.dim;p<_;){var v=p++;if(!ke.intervalsOverlap(i[v],l[v],u[v],d[v],n))return!1}return!0},clear:function(){return this.initialized=!1,this},getLongestAxis:function(){for(var r=0,n=0,i=0,l=this.dim;i<l;){var u=i++,d=this.getAxisLength(u);d>r&&(r=d,n=u)}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 i=this.min,l=this.max,u=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(i[P],u[P]))}return new ke([_,p])},__class__:ke};var rt=f.core.Constants=function(){};x["verb.core.Constants"]=rt,rt.__name__=["verb","core","Constants"];var $t=f.core.SerializableBase=function(){};x["verb.core.SerializableBase"]=$t,$t.__name__=["verb","core","SerializableBase"],$t.prototype={serialize:function(){var r=new Ht;return r.serialize(this),r.toString()},__class__:$t};var Cn=f.core.Plane=function(r,n){this.origin=r,this.normal=n};x["verb.core.Plane"]=Cn,Cn.__name__=["verb","core","Plane"],Cn.__super__=$t,Cn.prototype=M($t.prototype,{__class__:Cn});var cn=f.core.Ray=function(r,n){this.origin=r,this.dir=n};x["verb.core.Ray"]=cn,cn.__name__=["verb","core","Ray"],cn.__super__=$t,cn.prototype=M($t.prototype,{__class__:cn});var Ft=f.core.NurbsCurveData=function(r,n,i){this.degree=r,this.controlPoints=i,this.knots=n};x["verb.core.NurbsCurveData"]=Ft,Ft.__name__=["verb","core","NurbsCurveData"],Ft.__super__=$t,Ft.prototype=M($t.prototype,{__class__:Ft});var Jt=f.core.NurbsSurfaceData=function(r,n,i,l,u){this.degreeU=r,this.degreeV=n,this.knotsU=i,this.knotsV=l,this.controlPoints=u};x["verb.core.NurbsSurfaceData"]=Jt,Jt.__name__=["verb","core","NurbsSurfaceData"],Jt.__super__=$t,Jt.prototype=M($t.prototype,{__class__:Jt});var Ge=f.core.MeshData=function(r,n,i,l){this.faces=r,this.points=n,this.normals=i,this.uvs=l};x["verb.core.MeshData"]=Ge,Ge.__name__=["verb","core","MeshData"],Ge.empty=function(){return new Ge([],[],[],[])},Ge.__super__=$t,Ge.prototype=M($t.prototype,{__class__:Ge});var Nn=f.core.PolylineData=function(r,n){this.points=r,this.params=n};x["verb.core.PolylineData"]=Nn,Nn.__name__=["verb","core","PolylineData"],Nn.__super__=$t,Nn.prototype=M($t.prototype,{__class__:Nn});var Ln=f.core.VolumeData=function(r,n,i,l,u,d,p){this.degreeU=r,this.degreeV=n,this.degreeW=i,this.knotsU=l,this.knotsV=u,this.knotsW=d,this.controlPoints=p};x["verb.core.VolumeData"]=Ln,Ln.__name__=["verb","core","VolumeData"],Ln.__super__=$t,Ln.prototype=M($t.prototype,{__class__:Ln});var te=f.core.Pair=function(r,n){this.item0=r,this.item1=n};x["verb.core.Pair"]=te,te.__name__=["verb","core","Pair"],te.prototype={__class__:te};var we=f.core.Interval=function(r,n){this.min=r,this.max=n};x["verb.core.Interval"]=we,we.__name__=["verb","core","Interval"],we.prototype={__class__:we};var Ur=f.core.CurveCurveIntersection=function(r,n,i,l){this.point0=r,this.point1=n,this.u0=i,this.u1=l};x["verb.core.CurveCurveIntersection"]=Ur,Ur.__name__=["verb","core","CurveCurveIntersection"],Ur.prototype={__class__:Ur};var On=f.core.CurveSurfaceIntersection=function(r,n,i,l){this.u=r,this.uv=n,this.curvePoint=i,this.surfacePoint=l};x["verb.core.CurveSurfaceIntersection"]=On,On.__name__=["verb","core","CurveSurfaceIntersection"],On.prototype={__class__:On};var Pr=f.core.MeshIntersectionPoint=function(r,n,i,l,u){this.visited=!1,this.adj=null,this.opp=null,this.uv0=r,this.uv1=n,this.point=i,this.faceIndex0,this.faceIndex1};x["verb.core.MeshIntersectionPoint"]=Pr,Pr.__name__=["verb","core","MeshIntersectionPoint"],Pr.prototype={__class__:Pr};var zn=f.core.PolylineMeshIntersection=function(r,n,i,l,u){this.point=r,this.u=n,this.uv=i,this.polylineIndex=l,this.faceIndex=u};x["verb.core.PolylineMeshIntersection"]=zn,zn.__name__=["verb","core","PolylineMeshIntersection"],zn.prototype={__class__:zn};var Dn=f.core.SurfaceSurfaceIntersectionPoint=function(r,n,i,l){this.uv0=r,this.uv1=n,this.point=i,this.dist=l};x["verb.core.SurfaceSurfaceIntersectionPoint"]=Dn,Dn.__name__=["verb","core","SurfaceSurfaceIntersectionPoint"],Dn.prototype={__class__:Dn};var Rn=f.core.TriSegmentIntersection=function(r,n,i,l){this.point=r,this.s=n,this.t=i,this.p=l};x["verb.core.TriSegmentIntersection"]=Rn,Rn.__name__=["verb","core","TriSegmentIntersection"],Rn.prototype={__class__:Rn};var dn=f.core.CurveTriPoint=function(r,n,i){this.u=r,this.point=n,this.uv=i};x["verb.core.CurveTriPoint"]=dn,dn.__name__=["verb","core","CurveTriPoint"],dn.prototype={__class__:dn};var Fe=function(r,n,i,l,u){u==null&&(u=!1),l==null&&(l=-1),this.uv=i,this.point=r,this.normal=n,this.id=l,this.degen=u};x["verb.core.SurfacePoint"]=Fe,Fe.__name__=["verb","core","SurfacePoint"],Fe.fromUv=function(r,n){return new Fe(null,null,[r,n])},Fe.prototype={__class__:Fe};var ks=f.core.CurvePoint=function(r,n){this.u=r,this.pt=n};x["verb.core.CurvePoint"]=ks,ks.__name__=["verb","core","CurvePoint"],ks.prototype={__class__:ks};var Bn=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"]=Bn,Bn.__name__=["verb","core","KdTree"],Bn.prototype={buildTree:function(r,n,i){var l=n%this.dim,u,d;return r.length==0?null:r.length==1?new pn(r[0],l,i):(r.sort(function(p,_){var v=p.point[l]-_.point[l];return v==0?0:v>0?1:-1}),u=Math.floor(r.length/2),d=new pn(r[u],l,i),d.left=this.buildTree(r.slice(0,u),n+1,d),d.right=this.buildTree(r.slice(u+1),n+1,d),d)},nearest:function(r,n,i){var l=this,u=new Fn(function(A){return-A.item1}),d,p=null;p=function(A){for(var I,E=A.dimension,T=l.distanceFunction(r,A.kdPoint.point),L,N=[],R=0,O=l.dim;R<O;)R++,N.push(0);L=N;for(var F,V,H=function(Y,tt){u.push(new te(Y,tt)),u.size()>n&&u.pop()},J=0,G=l.dim;J<G;){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){(u.size()<n||T<u.peek().item1)&&H(A,T);return}A.right==null?I=A.left:A.left==null?I=A.right:r[E]<A.kdPoint.point[E]?I=A.left:I=A.right,p(I),(u.size()<n||T<u.peek().item1)&&H(A,T),(u.size()<n||Math.abs(F)<u.peek().item1)&&(I==A.left?V=A.right:V=A.left,V!=null&&p(V))},d=p;for(var _=0;_<n;)_++,u.push(new te(null,i));d(this.root);for(var v=[],w=0;w<n;){var P=w++;u.content[P].item0!=null&&v.push(new te(u.content[P].item0.kdPoint,u.content[P].item1))}return v},__class__:Bn};var Fn=function(r){this.content=[],this.scoreFunction=r};x["verb.core.BinaryHeap"]=Fn,Fn.__name__=["verb","core","BinaryHeap"],Fn.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,i=0;i<n;){var l=i++;if(this.content[l]==r){var u=this.content.pop();l!=n-1&&(this.content[l]=u,this.scoreFunction(u)<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 i=Math.floor((r+1)/2)-1,l=this.content[i];if(this.scoreFunction(n)<this.scoreFunction(l))this.content[i]=n,this.content[r]=l,r=i;else break}},sinkDown:function(r){for(var n=this.content.length,i=this.content[r],l=this.scoreFunction(i);;){var u=(r+1)*2,d=u-1,p=-1,_=0;if(d<n){var v=this.content[d];_=this.scoreFunction(v),_<l&&(p=d)}if(u<n){var w=this.content[u],P=this.scoreFunction(w);P<(p==-1?l:_)&&(p=u)}if(p!=-1)this.content[r]=this.content[p],this.content[p]=i,r=p;else break}},__class__:Fn};var mn=f.core.KdPoint=function(r,n){this.point=r,this.obj=n};x["verb.core.KdPoint"]=mn,mn.__name__=["verb","core","KdPoint"],mn.prototype={__class__:mn};var pn=f.core.KdNode=function(r,n,i){this.kdPoint=r,this.left=null,this.right=null,this.parent=i,this.dimension=n};x["verb.core.KdNode"]=pn,pn.__name__=["verb","core","KdNode"],pn.prototype={__class__:pn};var or=function(){};x["verb.eval.IBoundingBoxTree"]=or,or.__name__=["verb","eval","IBoundingBoxTree"],or.prototype={__class__:or};var er=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"]=er,er.__name__=["verb","core","LazyCurveBoundingBoxTree"],er.__interfaces__=[or],er.prototype={split:function(){var r=K.first(this._curve.knots),n=K.last(this._curve.knots),i=n-r,l=le.curveSplit(this._curve,(n+r)/2+i*.1*Math.random());return new te(new er(l[0],this._knotTol),new er(l[1],this._knotTol))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=new ke(C.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__:er};var rr=function(r,n){if(this._boundingBox=null,this._mesh=r,n==null){for(var i=[],l=0,u=r.faces.length;l<u;){var d=l++;i.push(d)}n=i}this._faceIndices=n};x["verb.core.LazyMeshBoundingBoxTree"]=rr,rr.__name__=["verb","core","LazyMeshBoundingBoxTree"],rr.__interfaces__=[or],rr.prototype={split:function(){var r=ee.sortTrianglesOnLongestAxis(this.boundingBox(),this._mesh,this._faceIndices),n=K.left(r),i=K.right(r);return new te(new rr(this._mesh,n),new rr(this._mesh,i))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=ee.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__:rr};var nr=function(r,n){this._boundingBox=null,this._polyline=r,n==null&&(n=new we(0,r.points.length!=0?r.points.length-1:0)),this._interval=n};x["verb.core.LazyPolylineBoundingBoxTree"]=nr,nr.__name__=["verb","core","LazyPolylineBoundingBoxTree"],nr.__interfaces__=[or],nr.prototype={split:function(){var r=this._interval.min,n=this._interval.max,i=r+Math.ceil((n-r)/2),l=new we(r,i),u=new we(i,n);return new te(new nr(this._polyline,l),new nr(this._polyline,u))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=new ke(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__:nr};var Sr=function(r,n,i,l){n==null&&(n=!1),this._boundingBox=null,this._surface=r,this._splitV=n,i==null&&(i=m.domain(r.knotsU)/16),l==null&&(l=m.domain(r.knotsV)/16),this._knotTolU=i,this._knotTolV=l};x["verb.core.LazySurfaceBoundingBoxTree"]=Sr,Sr.__name__=["verb","core","LazySurfaceBoundingBoxTree"],Sr.__interfaces__=[or],Sr.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 i=(r+n)/2,l=le.surfaceSplit(this._surface,i,this._splitV);return new te(new Sr(l[0],!this._splitV,this._knotTolU,this._knotTolV),new Sr(l[1],!this._splitV,this._knotTolU,this._knotTolV))},boundingBox:function(){if(this._boundingBox==null){this._boundingBox=new ke;for(var r=0,n=this._surface.controlPoints;r<n.length;){var i=n[r];++r,this._boundingBox.addRange(C.dehomogenize1d(i))}}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__:Sr};var Ct=f.core.Mat=function(){};x["verb.core.Mat"]=Ct,Ct.__name__=["verb","core","Mat"],Ct.mul=function(r,n){for(var i=[],l=0,u=n.length;l<u;){var d=l++;i.push(m.mul(r,n[d]))}return i},Ct.mult=function(r,n){var i,l,u,d,p,_,v,w;i=r.length,l=n.length,u=n[0].length,d=[];for(var P=i-1,A=0,I=0;P>=0;){for(p=[],_=r[P],I=u-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},Ct.add=function(r,n){for(var i=[],l=0,u=r.length;l<u;){var d=l++;i.push(m.add(r[d],n[d]))}return i},Ct.div=function(r,n){for(var i=[],l=0,u=r.length;l<u;){var d=l++;i.push(m.div(r[d],n))}return i},Ct.sub=function(r,n){for(var i=[],l=0,u=r.length;l<u;){var d=l++;i.push(m.sub(r[d],n[d]))}return i},Ct.dot=function(r,n){for(var i=[],l=0,u=r.length;l<u;){var d=l++;i.push(m.dot(r[d],n))}return i},Ct.identity=function(r){for(var n=m.zeros2d(r,r),i=0;i<r;){var l=i++;n[l][l]=1}return n},Ct.transpose=function(r){if(r.length==0)return[];for(var n=[],i=0,l=r[0].length;i<l;){var u=i++;n.push(function(d){for(var p,_=[],v=0,w=r.length;v<w;){var P=v++;_.push(r[P][u])}return p=_,p}())}return n},Ct.solve=function(r,n){return Ct.LUsolve(Ct.LU(r),n)},Ct.LUsolve=function(r,n){var i,l,u=r.LU,d=u.length,p=n.slice(),_=r.P,v,w,P;for(i=d-1;i!=-1;)p[i]=n[i],--i;for(i=0;i<d;){for(v=_[i],_[i]!=i&&(P=p[i],p[i]=p[v],p[v]=P),w=u[i],l=0;l<i;)p[i]-=p[l]*w[l],++l;++i}for(i=d-1;i>=0;){for(w=u[i],l=i+1;l<d;)p[i]-=p[l]*w[l],++l;p[i]/=w[i],--i}return p},Ct.LU=function(r){for(var n,i,l,u,d,p,_,v,w,P=[],A=0,I=r.length;A<I;){var E=A++;P.push(r[E].slice())}r=P;var T=r.length,L=T-1,N=[];for(l=0;l<T;){for(_=l,p=r[l],w=Math.abs(p[l]),i=l+1;i<T;)u=Math.abs(r[i][l]),w<u&&(w=u,_=i),++i;for(N[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],i=l+1;i<L;)v[i]-=v[l]*p[i],++i,v[i]-=v[l]*p[i],++i;i==L&&(v[i]-=v[l]*p[i]),++n}++l}return new Vn(r,N)};var Vn=function(r,n){this.LU=r,this.P=n};x["verb.core._Mat.LUDecomp"]=Vn,Vn.__name__=["verb","core","_Mat","LUDecomp"],Vn.prototype={__class__:Vn};var ee=f.core.Mesh=function(){};x["verb.core.Mesh"]=ee,ee.__name__=["verb","core","Mesh"],ee.getTriangleNorm=function(r,n){var i=r[n[0]],l=r[n[1]],u=r[n[2]],d=m.sub(l,i),p=m.sub(u,i),_=m.cross(d,p);return m.mul(1/m.norm(_),_)},ee.makeMeshAabb=function(r,n){for(var i=new ke,l=0;l<n.length;){var u=n[l];++l,i.add(r.points[r.faces[u][0]]),i.add(r.points[r.faces[u][1]]),i.add(r.points[r.faces[u][2]])}return i},ee.sortTrianglesOnLongestAxis=function(r,n,i){for(var l=r.getLongestAxis(),u=[],d=0;d<i.length;){var p=i[d];++d;var _=ee.getMinCoordOnAxis(n.points,n.faces[p],l);u.push(new te(_,p))}u.sort(function(I,E){var T=I.item0,L=E.item0;return T==L?0:T>L?1:-1});for(var v=[],w=0,P=u.length;w<P;){var A=w++;v.push(u[A].item1)}return v},ee.getMinCoordOnAxis=function(r,n,i){for(var l=1/0,u=0;u<3;){var d=u++,p=r[n[d]][i];p<l&&(l=p)}return l},ee.getTriangleCentroid=function(r,n){for(var i=[0,0,0],l=0;l<3;)for(var u=l++,d=0;d<3;){var p=d++;i[p]+=r[n[u]][p]}for(var _=0;_<3;){var v=_++;i[v]/=3}return i},ee.triangleUVFromPoint=function(r,n,i){var l=r.faces[n],u=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(u,i),A=m.sub(d,i),I=m.sub(p,i),E=m.norm(m.cross(m.sub(u,d),m.sub(u,p))),T=m.norm(m.cross(A,I))/E,L=m.norm(m.cross(I,P))/E,N=m.norm(m.cross(P,A))/E;return m.add(m.mul(T,_),m.add(m.mul(L,v),m.mul(N,w)))};var Ir=function(r,n){if(this._empty=!1,this._face=-1,n==null){for(var i=[],l=0,u=r.faces.length;l<u;){var d=l++;i.push(d)}n=i}if(this._boundingBox=ee.makeMeshAabb(r,n),n.length<1){this._empty=!0;return}else if(n.length<2){this._face=n[0];return}var p=ee.sortTrianglesOnLongestAxis(this._boundingBox,r,n),_=K.left(p),v=K.right(p);this._children=new te(new Ir(r,_),new Ir(r,v))};x["verb.core.MeshBoundingBoxTree"]=Ir,Ir.__name__=["verb","core","MeshBoundingBoxTree"],Ir.__interfaces__=[or],Ir.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__:Ir};var We=f.core.Minimizer=function(){};x["verb.core.Minimizer"]=We,We.__name__=["verb","core","Minimizer"],We.uncmin=function(r,n,i,l,u){i==null&&(i=1e-8),l==null&&(l=function(J){return We.numericalGradient(r,J)}),u==null&&(u=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!");i=Math.max(i,rt.EPSILON);var w,P,A,I=Ct.identity(d),E=0,T=[],L,N,R,O,F,V,H="";for(P=l(n);E<u;){if(!m.all(m.finite(P))){H="Gradient has Infinity or NaN";break}if(w=m.neg(Ct.dot(I,P)),!m.all(m.finite(w))){H="Search direction has Infinity or NaN";break}if(V=m.norm(w),V<i){H="Newton step smaller than tol";break}for(F=1,v=m.dot(P,w),L=n;E<u&&!(F*V<i);){if(T=m.mul(F,w),L=m.add(n,T),_=r(L),_-p>=.1*F*v||isNaN(_)){F*=.5,++E;continue}break}if(F*V<i){H="Line search step size smaller than tol";break}if(E==u){H="maxit reached during line search";break}A=l(L),N=m.sub(A,P),O=m.dot(N,T),R=Ct.dot(I,N),I=Ct.sub(Ct.add(I,Ct.mul((O+m.dot(N,R))/(O*O),We.tensor(T,T))),Ct.div(Ct.add(We.tensor(R,T),We.tensor(T,R)),O)),n=L,p=_,P=A,++E}return new Un(n,p,P,I,E,H)},We.numericalGradient=function(r,n){var i=n.length,l=r(n);if(l==NaN)throw new Q("gradient: f(x) is a NaN!");for(var u=n.slice(0),d,p,_=[],v,w=.001,P,A,I,E=0,T,L,N,R=0;R<i;)for(var O=R++,F=Math.max(1e-6*l,1e-8);;){if(++E,E>20)throw new Q("Numerical gradient fails");if(u[O]=n[O]+F,d=r(u),u[O]=n[O]-F,p=r(u),u[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,N=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)])/N,F/N),v>w)F/=16;else break}return _},We.tensor=function(r,n){for(var i=r.length,l=n.length,u=[],d,p,_=i-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;u[_]=d,_--}return u};var Un=function(r,n,i,l,u,d){this.solution=r,this.value=n,this.gradient=i,this.invHessian=l,this.iterations=u,this.message=d};x["verb.core.MinimizationResult"]=Un,Un.__name__=["verb","core","MinimizationResult"],Un.prototype={__class__:Un};var gn=function(){};x["verb.core.ISerializable"]=gn,gn.__name__=["verb","core","ISerializable"],gn.prototype={__class__:gn};var Si=f.core.Deserializer=function(){};x["verb.core.Deserializer"]=Si,Si.__name__=["verb","core","Deserializer"],Si.deserialize=function(r){var n=new Ut(r),i=n.unserialize();return i};var Ee=f.core.Trig=function(){};x["verb.core.Trig"]=Ee,Ee.__name__=["verb","core","Trig"],Ee.isPointInPlane=function(r,n,i){return Math.abs(m.dot(m.sub(r,n.origin),n.normal))<i},Ee.distToSegment=function(r,n,i){var l=Ee.segmentClosestPoint(n,r,i,0,1);return m.dist(n,l.pt)},Ee.rayClosestPoint=function(r,n,i){var l=m.sub(r,n),u=m.dot(l,i),d=m.add(n,m.mul(u,i));return d},Ee.distToRay=function(r,n,i){var l=Ee.rayClosestPoint(r,n,i),u=m.sub(l,r);return m.norm(u)},Ee.threePointsAreFlat=function(r,n,i,l){var u=m.sub(n,r),d=m.sub(i,r),p=m.cross(u,d),_=m.dot(p,p);return _<l},Ee.segmentClosestPoint=function(r,n,i,l,u){var d=m.sub(i,n),p=m.norm(d);if(p<rt.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,pt:i}:{u:l+(u-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,i){var l=m.cross(r,n),u=m.norm(r),d=m.norm(n),p=u*d,_=m.dot(r,n),v=m.norm(l)/p,w=_/p,P=Math.atan2(v,w),A=m.dot(i,l);return Math.abs(A)<rt.EPSILON||A>0?P:-P},m.signedAngleBetween=function(r,n,i){var l=m.cross(r,n),u=m.norm(r),d=m.norm(n),p=u*d,_=m.dot(r,n),v=m.norm(l)/p,w=_/p,P=Math.atan2(v,w),A=m.dot(i,l);return A>0?P:2*Math.PI-P},m.angleBetweenNormalized2d=function(r,n){var i=r[0]*n[1]-r[1]*n[0];return Math.atan2(i,m.dot(r,n))},m.domain=function(r){return K.last(r)-K.first(r)},m.range=function(r){for(var n=[],i=0,l=0;l<r;)l++,n.push(i),i+=1;return n},m.span=function(r,n,i){if(i==null)return[];if(i<rt.EPSILON)return[];if(r>n&&i>0)return[];if(n>r&&i<0)return[];for(var l=[],u=r;u<=n;)l.push(u),u+=i;return l},m.neg=function(r){return r.map(function(n){return-n})},m.min=function(r){return z.fold(r,function(n,i){return Math.min(n,i)},1/0)},m.max=function(r){return z.fold(r,function(n,i){return Math.max(n,i)},-1/0)},m.all=function(r){return z.fold(r,function(n,i){return i&&n},!0)},m.finite=function(r){return r.map(function(n){return isFinite(n)})},m.onRay=function(r,n,i){return m.add(r,m.mul(i,n))},m.lerp=function(r,n,i){return m.add(m.mul(r,n),m.mul(1-r,i))},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 z.fold(r,function(n,i){return i+n},0)},m.addAll=function(r){var n=He(r)();if(!n.hasNext())return null;var i=n.next().length;return z.fold(r,function(l,u){return m.add(u,l)},m.rep(i,0))},m.addAllMutate=function(r){for(var n=r[0],i=1,l=r.length;i<l;){var u=i++;m.addMutate(n,r[u])}},m.addMulMutate=function(r,n,i){for(var l=0,u=r.length;l<u;){var d=l++;r[d]=r[d]+n*i[d]}},m.subMulMutate=function(r,n,i){for(var l=0,u=r.length;l<u;){var d=l++;r[d]=r[d]-n*i[d]}},m.addMutate=function(r,n){for(var i=0,l=r.length;i<l;){var u=i++;r[u]=r[u]+n[u]}},m.subMutate=function(r,n){for(var i=0,l=r.length;i<l;){var u=i++;r[u]=r[u]-n[u]}},m.mulMutate=function(r,n){for(var i=0,l=n.length;i<l;){var u=i++;n[u]=n[u]*r}},m.norm=function(r){var n=m.normSquared(r);return n!=0?Math.sqrt(n):n},m.normSquared=function(r){return z.fold(r,function(n,i){return i+n*n},0)},m.rep=function(r,n){for(var i=[],l=0;l<r;)l++,i.push(n);return i},m.zeros1d=function(r){for(var n=[],i=0;i<r;)i++,n.push(0);return n},m.zeros2d=function(r,n){for(var i=[],l=0;l<r;)l++,i.push(m.zeros1d(n));return i},m.zeros3d=function(r,n,i){for(var l=[],u=0;u<r;)u++,l.push(m.zeros2d(n,i));return l},m.dot=function(r,n){for(var i=0,l=0,u=r.length;l<u;){var d=l++;i+=r[d]*n[d]}return i},m.add=function(r,n){for(var i=[],l=0,u=r.length;l<u;){var d=l++;i.push(r[d]+n[d])}return i},m.mul=function(r,n){for(var i=[],l=0,u=n.length;l<u;){var d=l++;i.push(r*n[d])}return i},m.div=function(r,n){for(var i=[],l=0,u=r.length;l<u;){var d=l++;i.push(r[d]/n)}return i},m.sub=function(r,n){for(var i=[],l=0,u=r.length;l<u;){var d=l++;i.push(r[d]-n[d])}return i},m.isZero=function(r){for(var n=0,i=r.length;n<i;){var l=n++;if(Math.abs(r[l])>rt.TOLERANCE)return!1}return!0},m.sortedSetUnion=function(r,n){for(var i=[],l=0,u=0;l<r.length||u<n.length;){if(l>=r.length){i.push(n[u]),u++;continue}else if(u>=n.length){i.push(r[l]),l++;continue}var d=r[l]-n[u];if(Math.abs(d)<rt.EPSILON){i.push(r[l]),l++,u++;continue}if(d>0){i.push(n[u]),u++;continue}i.push(r[l]),l++}return i},m.sortedSetSub=function(r,n){for(var i=[],l=0,u=0;l<r.length;){if(u>=n.length){i.push(r[l]),l++;continue}if(Math.abs(r[l]-n[u])<rt.EPSILON){l++,u++;continue}i.push(r[l]),l++}return i};var yt=f.eval.Analyze=function(){};x["verb.eval.Analyze"]=yt,yt.__name__=["verb","eval","Analyze"],yt.knotMultiplicities=function(r){for(var n=[new fn(r[0],0)],i=n[0],l=0;l<r.length;){var u=r[l];++l,Math.abs(u-i.knot)>rt.EPSILON&&(i=new fn(u,0),n.push(i)),i.inc()}return n},yt.isRationalSurfaceClosed=function(r,n){n==null&&(n=!0);var i;n?i=r.controlPoints:i=Ct.transpose(r.controlPoints);for(var l=0,u=i[0].length;l<u;){var d=l++,p=m.dist(K.first(i)[d],K.last(i)[d])<rt.EPSILON;if(!p)return!1}return!0},yt.rationalSurfaceClosestPoint=function(r,n){var i=yt.rationalSurfaceClosestParam(r,n);return C.rationalSurfacePoint(r,i[0],i[1])},yt.rationalSurfaceClosestParam=function(r,n){for(var i=5,l=0,u,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=yt.isRationalSurfaceClosed(r),E=yt.isRationalSurfaceClosed(r,!1),T,L=Ot.rationalSurfaceAdaptive(r,new kr),N=1/0,R=0,O=L.points.length;R<O;){var F=R++,V=L.points[F],H=m.normSquared(m.sub(n,V));H<N&&(N=H,T=L.uvs[F])}for(var J=function(Vt){return C.rationalSurfaceDerivatives(r,Vt[0],Vt[1],2)},G=function(Vt,qt,Rt){var Yt=qt[1][0],Ae=qt[0][1],Ue=qt[2][0],ve=qt[0][2],ge=qt[1][1],Pe=qt[1][1],Te=m.dot(Yt,Rt),qe=m.dot(Ae,Rt),sr=[-Te,-qe],Ye=m.dot(Yt,Yt)+m.dot(Ue,Rt),Ke=m.dot(Yt,Ae)+m.dot(ge,Rt),Xe=m.dot(Yt,Ae)+m.dot(Pe,Rt),hr=m.dot(Ae,Ae)+m.dot(ve,Rt),bn=[[Ye,Ke],[Xe,hr]],Gr=Ct.solve(bn,sr);return m.add(Gr,Vt)};l<i;){u=J(T),_=m.sub(u[0][0],n);var j=m.norm(_),Y=m.dot(u[1][0],_),tt=m.norm(u[1][0])*j,et=m.dot(u[0][1],_),st=m.norm(u[0][1])*j,ot=Y/tt,it=et/st,ht=j<d,nt=ot<p,ct=it<p;if(ht&&nt&&ct)return T;var q=G(T,u,_);q[0]<v?I?q=[w-(q[0]-v),q[1]]:q=[v+rt.EPSILON,q[1]]:q[0]>w&&(I?q=[v+(q[0]-w),q[1]]:q=[w-rt.EPSILON,q[1]]),q[1]<P?E?q=[q[0],A-(q[1]-P)]:q=[q[0],P+rt.EPSILON]:q[1]>A&&(E?q=[q[0],P+(q[0]-A)]:q=[q[0],A-rt.EPSILON]);var pt=m.norm(m.mul(q[0]-T[0],u[1][0])),At=m.norm(m.mul(q[1]-T[1],u[0][1]));if(pt+At<d)return T;T=q,l++}return T},yt.rationalCurveClosestPoint=function(r,n){return C.rationalCurvePoint(r,yt.rationalCurveClosestParam(r,n))},yt.rationalCurveClosestParam=function(r,n){for(var i=1/0,l=0,u=Ot.rationalCurveRegularSample(r,r.controlPoints.length*r.degree,!0),d=0,p=u.length-1;d<p;){var _=d++,v=u[_][0],w=u[_+1][0],P=u[_].slice(1),A=u[_+1].slice(1),I=Ee.segmentClosestPoint(n,P,A,v,w),E=m.norm(m.sub(n,I.pt));E<i&&(i=E,l=I.u)}for(var T=5,L=0,N,R=1e-4,O=5e-4,F,V=r.knots[0],H=K.last(r.knots),J=m.normSquared(m.sub(r.controlPoints[0],K.last(r.controlPoints)))<rt.EPSILON,G=l,j=function(q){return C.rationalCurveDerivatives(r,q,2)},Y=function(q,pt,At){var Vt=m.dot(pt[1],At),qt=m.dot(pt[2],At),Rt=m.dot(pt[1],pt[1]),Yt=qt+Rt;return q-Vt/Yt};L<T;){N=j(G),F=m.sub(N[0],n);var tt=m.norm(F),et=m.dot(N[1],F),st=m.norm(N[1])*tt,ot=et/st,it=tt<R,ht=Math.abs(ot)<O;if(it&&ht)return G;var nt=Y(G,N,F);nt<V?J?nt=H-(nt-V):nt=V:nt>H&&(J?nt=V+(nt-H):nt=H);var ct=m.norm(m.mul(nt-G,N[1]));if(ct<R)return G;G=nt,L++}return G},yt.rationalCurveParamAtArcLength=function(r,n,i,l,u){if(i==null&&(i=.001),n<rt.EPSILON)return r.knots[0];var d;l!=null?d=l:d=_t.decomposeCurveIntoBeziers(r);var p=0;d[p];var _=-rt.EPSILON,v;for(u!=null?v=u:v=[];_<n&&p<d.length;){if(p<v.length?v[p]=v[p]:v[p]=yt.rationalBezierCurveArcLength(r),_+=v[p],n<_+rt.EPSILON)return yt.rationalBezierCurveParamAtArcLength(r,n,i,v[p]);p++}return-1},yt.rationalBezierCurveParamAtArcLength=function(r,n,i,l){if(n<0)return r.knots[0];var u;if(l!=null?u=l:u=yt.rationalBezierCurveArcLength(r),n>u)return K.last(r.knots);var d=r.knots[0],p=0,_=K.last(r.knots),v=u,w=0,P=0,A;for(i!=null?A=i:A=rt.TOLERANCE*2;v-p>A;)w=(d+_)/2,P=yt.rationalBezierCurveArcLength(r,w),P>n?(_=w,v=P):(d=w,p=P);return(d+_)/2},yt.rationalCurveArcLength=function(r,n,i){i==null&&(i=16),n==null?n=K.last(r.knots):n=n;for(var l=_t.decomposeCurveIntoBeziers(r),u=0,d=l[0],p=0;u<l.length&&d.knots[0]+rt.EPSILON<n;){var _=Math.min(K.last(d.knots),n);p+=yt.rationalBezierCurveArcLength(d,_,i),d=l[++u]}return p},yt.rationalBezierCurveArcLength=function(r,n,i){i==null&&(i=16);var l;n==null?l=K.last(r.knots):l=n;for(var u=(l-r.knots[0])/2,d=0,p=r.degree+i,_,v,w=0;w<p;){var P=w++;_=u*yt.Tvalues[p][P]+u+r.knots[0],v=C.rationalCurveDerivatives(r,_,1),d+=yt.Cvalues[p][P]*m.norm(v[1])}return u*d};var fn=f.eval.KnotMultiplicity=function(r,n){this.knot=r,this.mult=n};x["verb.eval.KnotMultiplicity"]=fn,fn.__name__=["verb","eval","KnotMultiplicity"],fn.prototype={inc:function(){this.mult++},__class__:fn};var Ve=f.eval.Check=function(){};x["verb.eval.Check"]=Ve,Ve.__name__=["verb","eval","Check"],Ve.isValidKnotVector=function(r,n){if(r.length==0||r.length<(n+1)*2)return!1;for(var i=K.first(r),l=0,u=n+1;l<u;){var d=l++;if(Math.abs(r[d]-i)>rt.EPSILON)return!1}i=K.last(r);for(var p=r.length-n-1,_=r.length;p<_;){var v=p++;if(Math.abs(r[v]-i)>rt.EPSILON)return!1}return Ve.isNonDecreasing(r)},Ve.isNonDecreasing=function(r){for(var n=K.first(r),i=0,l=r.length;i<l;){var u=i++;if(r[u]<n-rt.EPSILON)return!1;n=r[u]}return!0},Ve.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(!Ve.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},Ve.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(!Ve.isValidKnotVector(r.knotsU,r.degreeU)||!Ve.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 le=f.eval.Divide=function(){};x["verb.eval.Divide"]=le,le.__name__=["verb","eval","Divide"],le.surfaceSplit=function(r,n,i){i==null&&(i=!1);var l,u,d;i?(d=r.controlPoints,l=r.knotsV,u=r.degreeV):(d=Ct.transpose(r.controlPoints),l=r.knotsU,u=r.degreeU);for(var p,_=[],v=0,w=u+1;v<w;)v++,_.push(n);p=_;for(var P=[],A=[],I=C.knotSpan(u,n,l),E=null,T=0;T<d.length;){var L=d[T];++T,E=_t.curveKnotRefine(new Ft(u,l,L),p),P.push(E.controlPoints.slice(0,I+1)),A.push(E.controlPoints.slice(I+1))}var N=E.knots.slice(0,I+u+2),R=E.knots.slice(I+1);return i?[new Jt(r.degreeU,u,r.knotsU.slice(),N,P),new Jt(r.degreeU,u,r.knotsU.slice(),R,A)]:(P=Ct.transpose(P),A=Ct.transpose(A),[new Jt(u,r.degreeV,N,r.knotsV.slice(),P),new Jt(u,r.degreeV,R,r.knotsV.slice(),A)])},le.curveSplit=function(r,n){var i=r.degree;r.controlPoints;for(var l=r.knots,u,d=[],p=0,_=i+1;p<_;)p++,d.push(n);u=d;var v=_t.curveKnotRefine(r,u),w=C.knotSpan(i,n,l),P=v.knots.slice(0,w+i+2),A=v.knots.slice(w+1),I=v.controlPoints.slice(0,w+1),E=v.controlPoints.slice(w+1);return[new Ft(i,P,I),new Ft(i,A,E)]},le.rationalCurveByEqualArcLength=function(r,n){var i=yt.rationalCurveArcLength(r),l=i/n;return le.rationalCurveByArcLength(r,l)},le.rationalCurveByArcLength=function(r,n){var i=_t.decomposeCurveIntoBeziers(r),l=i.map(function(I){return yt.rationalBezierCurveArcLength(I)}),u=m.sum(l),d=[new _n(r.knots[0],0)];if(n>u)return d;for(var p=n,_=0,v=p,w=0,P=0,A;_<i.length;){for(w+=l[_];v<w+rt.EPSILON;)A=yt.rationalBezierCurveParamAtArcLength(i[_],v-P,rt.TOLERANCE,l[_]),d.push(new _n(A,v)),v+=p;P+=l[_],_++}return d};var _n=f.eval.CurveLengthSample=function(r,n){this.u=r,this.len=n};x["verb.eval.CurveLengthSample"]=_n,_n.__name__=["verb","eval","CurveLengthSample"],_n.prototype={__class__:_n};var C=f.eval.Eval=function(){};x["verb.eval.Eval"]=C,C.__name__=["verb","eval","Eval"],C.rationalCurveTangent=function(r,n){var i=C.rationalCurveDerivatives(r,n,1);return i[1]},C.rationalSurfaceNormal=function(r,n,i){var l=C.rationalSurfaceDerivatives(r,n,i,1);return m.cross(l[1][0],l[0][1])},C.rationalSurfaceDerivatives=function(r,n,i,l){l==null&&(l=1);for(var u=C.surfaceDerivatives(r,n,i,l),d=C.rational2d(u),p=C.weight2d(u),_=[],v=d[0][0].length,w=0,P=l+1;w<P;){var A=w++;_.push([]);for(var I=0,E=l-A+1;I<E;){for(var T=I++,L=d[A][T],N=1,R=T+1;N<R;){var O=N++;m.subMulMutate(L,zt.get(T,O)*p[0][O],_[A][T-O])}for(var F=1,V=A+1;F<V;){var H=F++;m.subMulMutate(L,zt.get(A,H)*p[H][0],_[A-H][T]);for(var J=m.zeros1d(v),G=1,j=T+1;G<j;){var Y=G++;m.addMulMutate(J,zt.get(T,Y)*p[H][Y],_[A-H][T-Y])}m.subMulMutate(L,zt.get(A,H),J)}m.mulMutate(1/p[0][0],L),_[A].push(L)}}return _},C.rationalSurfacePoint=function(r,n,i){return C.dehomogenize(C.surfacePoint(r,n,i))},C.rationalCurveDerivatives=function(r,n,i){i==null&&(i=1);for(var l=C.curveDerivatives(r,n,i),u=C.rational1d(l),d=C.weight1d(l),p=[],_=0,v=i+1;_<v;){for(var w=_++,P=u[w],A=1,I=w+1;A<I;){var E=A++;m.subMulMutate(P,zt.get(w,E)*d[E],p[w-E])}m.mulMutate(1/d[0],P),p.push(P)}return p},C.rationalCurvePoint=function(r,n){return C.dehomogenize(C.curvePoint(r,n))},C.surfaceDerivatives=function(r,n,i,l){var u=r.knotsU.length-r.degreeU-2,d=r.knotsV.length-r.degreeV-2;return C.surfaceDerivativesGivenNM(u,d,r,n,i,l)},C.surfaceDerivativesGivenNM=function(r,n,i,l,u,d){var p=i.degreeU,_=i.degreeV,v=i.controlPoints,w=i.knotsU,P=i.knotsV;if(!C.areValidRelations(p,v.length,w.length)||!C.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 E;d<_?E=d:E=_;for(var T=m.zeros3d(d+1,d+1,A),L=C.knotSpanGivenN(r,p,l,w),N=C.knotSpanGivenN(n,_,u,P),R=C.derivativeBasisFunctionsGivenNI(L,l,p,r,w),O=C.derivativeBasisFunctionsGivenNI(N,u,_,n,P),F=m.zeros2d(_+1,A),V=0,H=0,J=I+1;H<J;){for(var G=H++,j=0,Y=_+1;j<Y;){var tt=j++;F[tt]=m.zeros1d(A);for(var et=0,st=p+1;et<st;){var ot=et++;m.addMulMutate(F[tt],R[G][ot],v[L-p+ot][N-_+tt])}}var it=d-G;it<E?V=it:V=E;for(var ht=0,nt=V+1;ht<nt;){var ct=ht++;T[G][ct]=m.zeros1d(A);for(var q=0,pt=_+1;q<pt;){var At=q++;m.addMulMutate(T[G][ct],O[ct][At],F[At])}}}return T},C.surfacePoint=function(r,n,i){var l=r.knotsU.length-r.degreeU-2,u=r.knotsV.length-r.degreeV-2;return C.surfacePointGivenNM(l,u,r,n,i)},C.surfacePointGivenNM=function(r,n,i,l,u){var d=i.degreeU,p=i.degreeV,_=i.controlPoints,v=i.knotsU,w=i.knotsV;if(!C.areValidRelations(d,_.length,v.length)||!C.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=C.knotSpanGivenN(r,d,l,v),I=C.knotSpanGivenN(n,p,u,w),E=C.basisFunctionsGivenKnotSpanIndex(A,l,d,v),T=C.basisFunctionsGivenKnotSpanIndex(I,u,p,w),L=A-d,N=I,R=m.zeros1d(P),O=m.zeros1d(P),F=0,V=p+1;F<V;){var H=F++;O=m.zeros1d(P),N=I-p+H;for(var J=0,G=d+1;J<G;){var j=J++;m.addMulMutate(O,E[j],_[L+j][N])}m.addMulMutate(R,T[H],O)}return R},C.curveRegularSamplePoints=function(r,n){for(var i=C.curveDerivatives(r,r.knots[0],r.degree),l=1/n,u=l*l,d=i[0],p=m.mul(l,i[1]),_=m.mul(u*.5,i[2]),v=m.mul(u*l*.5,i[3]),w=m.add(_,_),P=m.add(v,v),A=m.mul(.3333333333333333,v),I=[],E=0,T=n+1;E<T;)E++,I.push(C.dehomogenize(d)),m.addAllMutate([d,p,_,A]),m.addAllMutate([p,w,v]),m.addAllMutate([w,P]),m.addAllMutate([_,v]);return I},C.curveRegularSamplePoints2=function(r,n){for(var i=C.curveDerivatives(r,r.knots[0],r.degree),l=1/n,u=l*l,d=i[0],p=m.mul(l,i[1]),_=m.mul(u*.5,i[2]),v=m.mul(u*l*.5,i[3]),w=m.add(_,_),P=m.add(v,v),A=m.mul(.3333333333333333,v),I=[],E=0,T=n+1;E<T;)E++,I.push(C.dehomogenize(d)),m.addAllMutate([d,p,_,A]),m.addAllMutate([p,w,v]),m.addAllMutate([w,P]),m.addAllMutate([_,v]);return I},C.rationalSurfaceRegularSampleDerivatives=function(r,n,i,l){for(var u=C.surfaceRegularSampleDerivatives(r,n,i,l),d=[],p=n+1,_=i+1,v=l+1,w=0;w<p;){var P=w++,A=[];d.push(A);for(var I=0;I<_;){for(var E=I++,T=u[P][E],L=C.rational2d(T),N=C.weight2d(T),R=[],O=L[0][0].length,F=0;F<v;){var V=F++;R.push([]);for(var H=0,J=v-V;H<J;){for(var G=H++,j=L[V][G],Y=1,tt=G+1;Y<tt;){var et=Y++;m.subMulMutate(j,zt.get(G,et)*N[0][et],R[V][G-et])}for(var st=1,ot=V+1;st<ot;){var it=st++;m.subMulMutate(j,zt.get(V,it)*N[it][0],R[V-it][G]);for(var ht=m.zeros1d(O),nt=1,ct=G+1;nt<ct;){var q=nt++;m.addMulMutate(ht,zt.get(G,q)*N[it][q],R[V-it][G-q])}m.subMulMutate(j,zt.get(V,it),ht)}m.mulMutate(1/N[0][0],j),R[V].push(j)}}A.push(R)}}return d},C.surfaceRegularSampleDerivatives=function(r,n,i,l){var u=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])/i;for(var P=C.regularlySpacedDerivativeBasisFunctions(u,_,n),A=P.item0,I=P.item1,E=C.regularlySpacedDerivativeBasisFunctions(d,v,i),T=E.item0,L=E.item1,N=[],R=n+1,O=i+1,F=0;F<R;){var V=F++,H=[];N.push(H);for(var J=0;J<O;){var G=J++;H.push(C.surfaceDerivativesGivenBasesKnotSpans(u,d,p,A[V],T[G],I[V],L[G],w,l))}}return N},C.rationalSurfaceRegularSamplePoints=function(r,n,i){return C.dehomogenize2d(C.surfaceRegularSamplePoints(r,n,i))},C.surfaceRegularSamplePoints=function(r,n,i){var l=r.degreeU,u=r.degreeV,d=r.controlPoints,p=r.knotsU,_=r.knotsV,v=d[0][0].length;(K.last(p)-p[0])/n,(K.last(_)-_[0])/i;for(var w=C.regularlySpacedBasisFunctions(l,p,n),P=w.item0,A=w.item1,I=C.regularlySpacedBasisFunctions(u,_,i),E=I.item0,T=I.item1,L=[],N=n+1,R=i+1,O=0;O<N;){var F=O++,V=[];L.push(V);for(var H=0;H<R;){var J=H++;V.push(C.surfacePointGivenBasesKnotSpans(l,u,d,P[F],E[J],A[F],T[J],v))}}return L},C.regularlySpacedBasisFunctions=function(r,n,i){for(var l=n.length-r-2,u=(K.last(n)-n[0])/i,d=[],p=[],_=n[0],v=C.knotSpanGivenN(l,r,_,n),w=i+1,P=0;P<w;){for(P++;_>=n[v+1];)v++;p.push(v),d.push(C.basisFunctionsGivenKnotSpanIndex(v,_,r,n)),_+=u}return new te(p,d)},C.regularlySpacedDerivativeBasisFunctions=function(r,n,i){for(var l=n.length-r-2,u=(K.last(n)-n[0])/i,d=[],p=[],_=n[0],v=C.knotSpanGivenN(l,r,_,n),w=i+1,P=0;P<w;){for(P++;_>=n[v+1];)v++;p.push(v),d.push(C.derivativeBasisFunctionsGivenNI(v,_,r,l,n)),_+=u}return new te(p,d)},C.surfacePointGivenBasesKnotSpans=function(r,n,i,l,u,d,p,_){for(var v=m.zeros1d(_),w,P=l-r,A=u-n,I=0,E=n+1;I<E;){var T=I++;w=m.zeros1d(_);for(var L=0,N=r+1;L<N;){var R=L++;m.addMulMutate(w,d[R],i[P+R][A])}A++,m.addMulMutate(v,p[T],w)}return v},C.surfaceDerivativesGivenBasesKnotSpans=function(r,n,i,l,u,d,p,_,v){var w=i[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),E=m.zeros2d(n+1,w),T=0,L=0,N=P+1;L<N;){for(var R=L++,O=0,F=n+1;O<F;){var V=O++;E[V]=m.zeros1d(w);for(var H=0,J=r+1;H<J;){var G=H++;m.addMulMutate(E[V],d[R][G],i[l-r+G][u-n+V])}}var j=v-R;j<A?T=j:T=A;for(var Y=0,tt=T+1;Y<tt;){var et=Y++;I[R][et]=m.zeros1d(w);for(var st=0,ot=n+1;st<ot;){var it=st++;m.addMulMutate(I[R][et],p[et][it],E[it])}}}return I},C.curveDerivatives=function(r,n,i){var l=r.knots.length-r.degree-2;return C.curveDerivativesGivenN(l,r,n,i)},C.curveDerivativesGivenN=function(r,n,i,l){var u=n.degree,d=n.controlPoints,p=n.knots;if(!C.areValidRelations(u,d.length,p.length))throw new Q("Invalid relations between control points, knot vector, and n");var _=d[0].length,v;l<u?v=l:v=u;for(var w=m.zeros2d(l+1,_),P=C.knotSpanGivenN(r,u,i,p),A=C.derivativeBasisFunctionsGivenNI(P,i,u,v,p),I=0,E=v+1;I<E;)for(var T=I++,L=0,N=u+1;L<N;){var R=L++;m.addMulMutate(w[T],A[T][R],d[P-u+R])}return w},C.curvePoint=function(r,n){var i=r.knots.length-r.degree-2;return C.curvePointGivenN(i,r,n)},C.areValidRelations=function(r,n,i){return n+r+1-i==0},C.curvePointGivenN=function(r,n,i){var l=n.degree,u=n.controlPoints,d=n.knots;if(!C.areValidRelations(l,u.length,d.length))throw new Q("Invalid relations between control points, knot Array, and n");for(var p=C.knotSpanGivenN(r,l,i,d),_=C.basisFunctionsGivenKnotSpanIndex(p,i,l,d),v=m.zeros1d(u[0].length),w=0,P=l+1;w<P;){var A=w++;m.addMulMutate(v,_[A],u[p-l+A])}return v},C.volumePoint=function(r,n,i,l){var u=r.knotsU.length-r.degreeU-2,d=r.knotsV.length-r.degreeV-2,p=r.knotsW.length-r.degreeW-2;return C.volumePointGivenNML(r,u,d,p,n,i,l)},C.volumePointGivenNML=function(r,n,i,l,u,d,p){if(!C.areValidRelations(r.degreeU,r.controlPoints.length,r.knotsU.length)||!C.areValidRelations(r.degreeV,r.controlPoints[0].length,r.knotsV.length)||!C.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,E=r.knotsW,T=_[0][0][0].length,L=C.knotSpanGivenN(n,v,u,A),N=C.knotSpanGivenN(i,w,d,I),R=C.knotSpanGivenN(l,P,p,E),O=C.basisFunctionsGivenKnotSpanIndex(L,u,v,A),F=C.basisFunctionsGivenKnotSpanIndex(N,d,w,I),V=C.basisFunctionsGivenKnotSpanIndex(R,p,P,E),H=L-v,J=m.zeros1d(T),G=m.zeros1d(T),j=m.zeros1d(T),Y=0,tt=P+1;Y<tt;){var et=Y++;j=m.zeros1d(T);for(var st=R-P+et,ot=0,it=w+1;ot<it;){var ht=ot++;G=m.zeros1d(T);for(var nt=N-w+ht,ct=0,q=v+1;ct<q;){var pt=ct++;m.addMulMutate(G,O[pt],_[H+pt][nt][st])}m.addMulMutate(j,F[ht],G)}m.addMulMutate(J,V[et],j)}return J},C.derivativeBasisFunctions=function(r,n,i){var l=C.knotSpan(n,r,i),u=i.length-1,d=u-n-1;return C.derivativeBasisFunctionsGivenNI(l,r,n,d,i)},C.derivativeBasisFunctionsGivenNI=function(r,n,i,l,u){var d=m.zeros2d(i+1,i+1),p=m.zeros1d(i+1),_=m.zeros1d(i+1),v=0,w=0;d[0][0]=1;for(var P=1,A=i+1;P<A;){var I=P++;p[I]=n-u[r+1-I],_[I]=u[r+I]-n,v=0;for(var E=0;E<I;){var T=E++;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,i+1),N=m.zeros2d(2,i+1),R=0,O=1,F=0,V=0,H=0,J=0,G=0,j=0,Y=i+1;j<Y;){var tt=j++;L[0][tt]=d[tt][i]}for(var et=0,st=i+1;et<st;){var ot=et++;R=0,O=1,N[0][0]=1;for(var it=1,ht=l+1;it<ht;){var nt=it++;F=0,V=ot-nt,H=i-nt,ot>=nt&&(N[O][0]=N[R][0]/d[H+1][V],F=N[O][0]*d[V][H]),V>=-1?J=1:J=-V,ot-1<=H?G=nt-1:G=i-ot;for(var ct=J,q=G+1;ct<q;){var pt=ct++;N[O][pt]=(N[R][pt]-N[R][pt-1])/d[H+1][V+pt],F+=N[O][pt]*d[V+pt][H]}ot<=H&&(N[O][nt]=-N[R][nt-1]/d[H+1][ot],F+=N[O][nt]*d[ot][H]),L[nt][ot]=F;var At=R;R=O,O=At}}for(var Vt=i,qt=1,Rt=l+1;qt<Rt;){for(var Yt=qt++,Ae=0,Ue=i+1;Ae<Ue;){var ve=Ae++;L[Yt][ve]*=Vt}Vt*=i-Yt}return L},C.basisFunctions=function(r,n,i){var l=C.knotSpan(n,r,i);return C.basisFunctionsGivenKnotSpanIndex(l,r,n,i)},C.basisFunctionsGivenKnotSpanIndex=function(r,n,i,l){var u=m.zeros1d(i+1),d=m.zeros1d(i+1),p=m.zeros1d(i+1),_=0,v=0;u[0]=1;for(var w=1,P=i+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 E=I++;v=u[E]/(p[E+1]+d[A-E]),u[E]=_+p[E+1]*v,_=d[A-E]*v}u[A]=_}return u},C.knotSpan=function(r,n,i){return C.knotSpanGivenN(i.length-r-2,r,n,i)},C.knotSpanGivenN=function(r,n,i,l){if(i>l[r+1]-rt.EPSILON)return r;if(i<l[n]+rt.EPSILON)return n;for(var u=n,d=r+1,p=Math.floor((u+d)/2);i<l[p]||i>=l[p+1];)i<l[p]?d=p:u=p,p=Math.floor((u+d)/2);return p},C.dehomogenize=function(r){for(var n=r.length,i=[],l=r[n-1],u=r.length-1,d=0;d<u;){var p=d++;i.push(r[p]/l)}return i},C.rational1d=function(r){var n=r[0].length-1;return r.map(function(i){return i.slice(0,n)})},C.rational2d=function(r){return r.map(C.rational1d)},C.weight1d=function(r){var n=r[0].length-1;return r.map(function(i){return i[n]})},C.weight2d=function(r){return r.map(C.weight1d)},C.dehomogenize1d=function(r){return r.map(C.dehomogenize)},C.dehomogenize2d=function(r){return r.map(C.dehomogenize1d)},C.homogenize1d=function(r,n){var i=r.length,l=r[0].length,u=[],d=0,p=[],_;n!=null?_=n:_=m.rep(r.length,1);for(var v=0;v<i;){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),u.push(P)}return u},C.homogenize2d=function(r,n){var i=r.length,l=[],u;if(n!=null)u=n;else{for(var d=[],p=0;p<i;)p++,d.push(m.rep(r[0].length,1));u=d}for(var _=0;_<i;){var v=_++;l.push(C.homogenize1d(r[v],u[v]))}return l};var at=f.eval.Intersect=function(){};x["verb.eval.Intersect"]=at,at.__name__=["verb","eval","Intersect"],at.surfaces=function(r,n,i){var l=Ot.rationalSurfaceAdaptive(r),u=Ot.rationalSurfaceAdaptive(n),d=at.meshes(l,u),p=d.map(function(_){return _.map(function(v){return at.surfacesAtPointWithEstimate(r,n,v.uv0,v.uv1,i)})});return p.map(function(_){return dt.rationalInterpCurve(_.map(function(v){return v.point}),3)})},at.surfacesAtPointWithEstimate=function(r,n,i,l,u){var d,p,_,v,w,P,A,I,E,T,L,N,R,O=5,F=0;do{if(d=C.rationalSurfaceDerivatives(r,i[0],i[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=C.rationalSurfaceDerivatives(n,l[0],l[1],1),I=A[0][0],T=A[1][0],L=A[0][1],E=m.normalized(m.cross(T,L)),N=m.dot(E,I),R=m.distSquared(p,I),R<u*u)break;var V=m.normalized(m.cross(_,E)),H=m.dot(V,p),J=at.threePlanes(_,P,E,N,V,H);if(J==null)throw new Q("panic!");var G=m.sub(J,p),j=m.sub(J,I),Y=m.cross(v,_),tt=m.cross(w,_),et=m.cross(T,E),st=m.cross(L,E),ot=m.dot(tt,G)/m.dot(tt,v),it=m.dot(Y,G)/m.dot(Y,w),ht=m.dot(st,j)/m.dot(st,T),nt=m.dot(et,j)/m.dot(et,L);i=m.add([ot,it],i),l=m.add([ht,nt],l),F++}while(F<O);return new Dn(i,l,p,R)},at.meshes=function(r,n,i,l){i==null&&(i=new rr(r)),l==null&&(l=new rr(n));var u=at.boundingBoxTrees(i,l,0),d=K.unique(u.map(function(p){return at.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)>rt.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),E=m.dot(I,I),T=m.sub(p.max.uv0,_.min.uv0),L=m.dot(T,T);return w<rt.EPSILON&&A<rt.EPSILON||E<rt.EPSILON&&L<rt.EPSILON});return at.makeMeshIntersectionPolylines(d)},at.meshSlices=function(r,n,i,l){for(var u=new Ir(r),d=u.boundingBox(),p=d.min[0],_=d.min[1],v=d.max[0],w=d.max[1],P=m.span(n,i,l),A=[],I=0;I<P.length;){var E=P[I];++I;var T=[[p,_,E],[v,_,E],[v,w,E],[p,w,E]],L=[[0,0],[1,0],[1,1],[0,1]],N=[[0,1,2],[0,2,3]],R=new Ge(N,T,null,L);A.push(at.meshes(r,R,u))}return A},at.makeMeshIntersectionPolylines=function(r){if(r.length==0)return[];for(var n=0;n<r.length;){var i=r[n];++n,i.max.opp=i.min,i.min.opp=i.max}for(var l=at.kdTreeFromSegments(r),u=[],d=0;d<r.length;){var p=r[d];++d,u.push(p.min),u.push(p.max)}for(var _=0;_<u.length;){var v=u[_];if(++_,v.adj==null){var w=at.lookupAdjacentSegment(v,l,r.length);w!=null&&w.adj==null&&(v.adj=w,w.adj=v)}}var P=u.filter(function(O){return O.adj==null});P.length==0&&(P=u);for(var A=[],I=0,E=!1;P.length!=0;){var T=P.pop();if(!T.visited){for(var L=[],N=T;N!=null&&!(N.visited||(N.visited=!0,N.opp.visited=!0,L.push(N),I+=2,N=N.opp.adj,N==T)););L.length>0&&(L.push(L[L.length-1].opp),A.push(L))}if(P.length==0&&u.length>0&&(E||I<u.length)){E=!0;var R=u.pop();P.push(R)}}return A},at.kdTreeFromSegments=function(r){for(var n=[],i=0;i<r.length;){var l=r[i];++i,n.push(new mn(l.min.point,l.min)),n.push(new mn(l.max.point,l.max))}return new Bn(n,m.distSquared)},at.lookupAdjacentSegment=function(r,n,i){var l=n.nearest(r.point,i,rt.EPSILON).filter(function(u){return r!=u.item0.obj}).map(function(u){return u.item0.obj});return l.length==1?l[0]:null},at.curveAndSurface=function(r,n,i,l,u){i==null&&(i=.001),l!=null?l=l:l=new er(r),u!=null?u=u:u=new Sr(n);var d=at.boundingBoxTrees(l,u,i);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),E=K.last(v.knotsU),T=K.first(v.knotsV),L=K.last(v.knotsV),N=[(I+E)/2,(T+L)/2];return at.curveAndSurfaceWithEstimate(_,v,[A].concat(N),i)}).filter(function(p){return m.distSquared(p.curvePoint,p.surfacePoint)<i*i}),function(p,_){return Math.abs(p.u-_.u)<.5*i})},at.curveAndSurfaceWithEstimate=function(r,n,i,l){l==null&&(l=.001);var u=function(v){var w=C.rationalCurvePoint(r,v[0]),P=C.rationalSurfacePoint(n,v[1],v[2]),A=m.sub(w,P);return m.dot(A,A)},d=function(v){var w=C.rationalCurveDerivatives(r,v[0],1),P=C.rationalSurfaceDerivatives(n,v[1],v[2],1),A=m.sub(P[0][0],w[0]),I=m.mul(-1,w[1]),E=P[1][0],T=P[0][1];return[2*m.dot(I,A),2*m.dot(E,A),2*m.dot(T,A)]},p=We.uncmin(u,i,l*l,d),_=p.solution;return new On(_[0],[_[1],_[2]],C.rationalCurvePoint(r,_[0]),C.rationalSurfacePoint(n,_[1],_[2]))},at.polylineAndMesh=function(r,n,i){for(var l=at.boundingBoxTrees(new nr(r),new rr(n),i),u=[],d=0;d<l.length;){var p=l[d];++d;var _=p.item0,v=p.item1,w=at.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=ee.triangleUVFromPoint(n,v,P);u.push(new zn(P,A,I,_,v))}}return u},at.boundingBoxTrees=function(r,n,i){i==null&&(i=1e-9);var l=[],u=[];l.push(r),u.push(n);for(var d=[];l.length>0;){var p=l.pop(),_=u.pop();if(!(p.empty()||_.empty())&&p.boundingBox().intersects(_.boundingBox(),i)){var v=p.indivisible(i),w=_.indivisible(i);if(v&&w){d.push(new te(p.yield(),_.yield()));continue}else if(v&&!w){var P=_.split();l.push(p),u.push(P.item1),l.push(p),u.push(P.item0);continue}else if(!v&&w){var A=p.split();l.push(A.item1),u.push(_),l.push(A.item0),u.push(_);continue}var I=p.split(),E=_.split();l.push(I.item1),u.push(E.item1),l.push(I.item1),u.push(E.item0),l.push(I.item0),u.push(E.item1),l.push(I.item0),u.push(E.item0)}}return d},at.curves=function(r,n,i){var l=at.boundingBoxTrees(new er(r),new er(n),0);return K.unique(l.map(function(u){return at.curvesWithEstimate(r,n,K.first(u.item0.knots),K.first(u.item1.knots),i)}).filter(function(u){return m.distSquared(u.point0,u.point1)<i}),function(u,d){return Math.abs(u.u0-d.u0)<i*5})},at.curvesWithEstimate=function(r,n,i,l,u){var d=function(I){var E=C.rationalCurvePoint(r,I[0]),T=C.rationalCurvePoint(n,I[1]),L=m.sub(E,T);return m.dot(L,L)},p=function(I){var E=C.rationalCurveDerivatives(r,I[0],1),T=C.rationalCurveDerivatives(n,I[1],1),L=m.sub(E[0],T[0]),N=E[1],R=m.mul(-1,T[1]);return[2*m.dot(N,L),2*m.dot(R,L)]},_=We.uncmin(d,[i,l],u*u,p),v=_.solution[0],w=_.solution[1],P=C.rationalCurvePoint(r,v),A=C.rationalCurvePoint(n,w);return new Ur(P,A,v,w)},at.triangles=function(r,n,i,l){var u=r.faces[n],d=i.faces[l],p=ee.getTriangleNorm(r.points,u),_=ee.getTriangleNorm(i.points,d),v=r.points[u[0]],w=i.points[d[0]],P=at.planes(v,p,w,_);if(P==null)return null;var A=at.clipRayInCoplanarTriangle(P,r,n);if(A==null)return null;var I=at.clipRayInCoplanarTriangle(P,i,l);if(I==null)return null;var E=at.mergeTriangleClipIntervals(A,I,r,n,i,l);return E==null?null:new we(new Pr(E.min.uv0,E.min.uv1,E.min.point,n,l),new Pr(E.max.uv0,E.max.uv1,E.max.point,n,l))},at.clipRayInCoplanarTriangle=function(r,n,i){for(var l=n.faces[i],u=[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(u[1],u[0]),m.sub(u[2],u[1]),m.sub(u[0],u[2])],v=_.map(m.normalized),w=_.map(m.norm),P=null,A=null,I=0;I<3;){var E=I++,T=u[E],L=v[E],N=at.rays(T,L,r.origin,r.dir);if(N!=null){var R=N.u0,O=N.u1;R<-rt.EPSILON||R>w[E]+rt.EPSILON||((P==null||O<P.u)&&(P=new dn(O,m.onRay(r.origin,r.dir,O),m.onRay(d[E],p[E],R/w[E]))),(A==null||O>A.u)&&(A=new dn(O,m.onRay(r.origin,r.dir,O),m.onRay(d[E],p[E],R/w[E]))))}}return A==null||P==null?null:new we(P,A)},at.mergeTriangleClipIntervals=function(r,n,i,l,u,d){if(n.min.u>r.max.u+rt.EPSILON||r.min.u>n.max.u+rt.EPSILON)return null;var p;r.min.u>n.min.u?p=new te(r.min,0):p=new te(n.min,1);var _;r.max.u<n.max.u?_=new te(r.max,0):_=new te(n.max,1);var v=new we(new Pr(null,null,p.item0.point,l,d),new Pr(null,null,_.item0.point,l,d));return p.item1==0?(v.min.uv0=p.item0.uv,v.min.uv1=ee.triangleUVFromPoint(u,d,p.item0.point)):(v.min.uv0=ee.triangleUVFromPoint(i,l,p.item0.point),v.min.uv1=p.item0.uv),_.item1==0?(v.max.uv0=_.item0.uv,v.max.uv1=ee.triangleUVFromPoint(u,d,_.item0.point)):(v.max.uv0=ee.triangleUVFromPoint(i,l,_.item0.point),v.max.uv1=_.item0.uv),v},at.planes=function(r,n,i,l){var u=m.cross(n,l);if(m.dot(u,u)<rt.EPSILON)return null;var d=0,p=Math.abs(u[0]),_=Math.abs(u[1]),v=Math.abs(u[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 E=-m.dot(r,n),T=-m.dot(i,l),L=w*I-P*A,N=(P*T-E*I)/L,R=(E*A-w*T)/L,O;return d==0?O=[0,N,R]:d==1?O=[N,0,R]:O=[N,R,0],new cn(O,m.normalized(u))},at.threePlanes=function(r,n,i,l,u,d){var p=m.cross(i,u),_=m.dot(r,p);if(Math.abs(_)<rt.EPSILON)return null;var v=m.sub(m.mul(d,i),m.mul(l,u)),w=m.add(m.mul(n,p),m.cross(r,v));return m.mul(1/_,w)},at.polylines=function(r,n,i){for(var l=at.boundingBoxTrees(new nr(r),new nr(n),i),u=[],d=0;d<l.length;){var p=l[d];++d;var _=p.item0,v=p.item1,w=at.segments(r.points[_],r.points[_+1],n.points[v],n.points[v+1],i);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],u.push(w))}return u},at.segments=function(r,n,i,l,u){var d=m.sub(n,r),p=Math.sqrt(m.dot(d,d)),_=m.mul(1/p,d),v=m.sub(l,i),w=Math.sqrt(m.dot(v,v)),P=m.mul(1/w,v),A=at.rays(r,_,i,P);if(A!=null){var I=Math.min(Math.max(0,A.u0/p),1),E=Math.min(Math.max(0,A.u1/w),1),T=m.onRay(r,d,I),L=m.onRay(i,v,E),N=m.distSquared(T,L);if(N<u*u)return new Ur(T,L,I,E)}return null},at.rays=function(r,n,i,l){var u=m.dot(n,l),d=m.dot(n,i),p=m.dot(n,r),_=m.dot(l,i),v=m.dot(l,r),w=m.dot(n,n),P=m.dot(l,l),A=w*P-u*u;if(Math.abs(A)<rt.EPSILON)return null;var I=u*(d-p)-w*(_-v),E=I/A,T=(d-p+E*u)/w,L=m.onRay(r,n,T),N=m.onRay(i,l,E);return new Ur(L,N,T,E)},at.segmentWithTriangle=function(r,n,i,l){var u=i[l[0]],d=i[l[1]],p=i[l[2]],_=m.sub(d,u),v=m.sub(p,u),w=m.cross(_,v),P=m.sub(n,r),A=m.sub(r,u),I=-m.dot(w,A),E=m.dot(w,P);if(Math.abs(E)<rt.EPSILON)return null;var T=I/E;if(T<0||T>1)return null;var L=m.add(r,m.mul(T,P)),N=m.dot(_,v),R=m.dot(_,_),O=m.dot(v,v),F=m.sub(L,u),V=m.dot(F,_),H=m.dot(F,v),J=N*N-R*O;if(Math.abs(J)<rt.EPSILON)return null;var G=(N*H-O*V)/J,j=(N*V-R*H)/J;return G>1+rt.EPSILON||j>1+rt.EPSILON||j<-rt.EPSILON||G<-rt.EPSILON||G+j>1+rt.EPSILON?null:new Rn(L,G,j,T)},at.segmentAndPlane=function(r,n,i,l){var u=m.dot(l,m.sub(n,r));if(Math.abs(u)<rt.EPSILON)return null;var d=m.dot(l,m.sub(i,r)),p=d/u;return p>1+rt.EPSILON||p<-rt.EPSILON?null:{p}};var dt=f.eval.Make=function(){};x["verb.eval.Make"]=dt,dt.__name__=["verb","eval","Make"],dt.rationalTranslationalSurface=function(r,n){for(var i=C.rationalCurvePoint(n,K.first(n.knots)),l=K.first(n.knots),u=K.last(n.knots),d=2*n.controlPoints.length,p=(u-l)/(d-1),_=[],v=0;v<d;){var w=v++,P=m.sub(C.rationalCurvePoint(n,l+w*p),i),A=_t.rationalCurveTransform(r,[[1,0,0,P[0]],[0,1,0,P[1]],[0,0,1,P[2]],[0,0,0,1]]);_.push(A)}return dt.loftedSurface(_)},dt.surfaceBoundaryCurves=function(r){var n=dt.surfaceIsocurve(r,K.first(r.knotsU),!1),i=dt.surfaceIsocurve(r,K.last(r.knotsU),!1),l=dt.surfaceIsocurve(r,K.first(r.knotsV),!0),u=dt.surfaceIsocurve(r,K.last(r.knotsV),!0);return[n,i,l,u]},dt.surfaceIsocurve=function(r,n,i){i==null&&(i=!1);var l;i?l=r.knotsV:l=r.knotsU;var u;i?u=r.degreeV:u=r.degreeU;for(var d=yt.knotMultiplicities(l),p=-1,_=0,v=d.length;_<v;){var w=_++;if(Math.abs(n-d[w].knot)<rt.EPSILON){p=w;break}}var P=u+1;p>=0&&(P=P-d[p].mult);var A;P>0?A=_t.surfaceKnotRefine(r,m.rep(P,n),i):A=r;var I=C.knotSpan(u,n,l);return Math.abs(n-K.first(l))<rt.EPSILON?I=0:Math.abs(n-K.last(l))<rt.EPSILON&&(I=(i?A.controlPoints[0].length:A.controlPoints.length)-1),i?new Ft(A.degreeU,A.knotsU,function(E){for(var T,L=[],N=0,R=A.controlPoints;N<R.length;){var O=R[N];++N,L.push(O[I])}return T=L,T}()):new Ft(A.degreeV,A.knotsV,A.controlPoints[I])},dt.loftedSurface=function(r,n){r=_t.unifyCurveKnotVectors(r);var i=r[0].degree;n==null&&(n=3),n>r.length-1&&(n=r.length-1);for(var l=r[0].knots,u=[],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=dt.rationalInterpCurve(w,n,!0);d.push(P.controlPoints),u=P.knots}return new Jt(i,n,l,u,d)},dt.clonedCurve=function(r){return new Ft(r.degree,r.knots.slice(),r.controlPoints.map(function(n){return n.slice()}))},dt.rationalBezierCurve=function(r,n){for(var i=r.length-1,l=[],u=0,d=i+1;u<d;)u++,l.push(0);for(var p=0,_=i+1;p<_;)p++,l.push(1);return n==null&&(n=m.rep(r.length,1)),new Ft(i,l,C.homogenize1d(r,n))},dt.fourPointSurface=function(r,n,i,l,u){u==null&&(u=3);for(var d=u,p=[],_=0,v=u+1;_<v;){for(var w=_++,P=[],A=0,I=u+1;A<I;){var E=A++,T=1-w/d,L=m.lerp(T,r,n),N=m.lerp(T,l,i),R=m.lerp(1-E/d,L,N);R.push(1),P.push(R)}p.push(P)}var O=m.rep(u+1,0),F=m.rep(u+1,1);return new Jt(u,u,O.concat(F),O.concat(F),p)},dt.ellipseArc=function(r,n,i,l,u){var d=m.norm(n),p=m.norm(i);n=m.normalized(n),i=m.normalized(i),u<l&&(u=2*Math.PI+l);var _=u-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),i))),I=m.sub(m.mul(Math.cos(l),i),m.mul(Math.sin(l),n)),E=[],T=m.zeros1d(2*v+3),L=0,N=l,R=m.zeros1d(v*2);E[0]=A,R[0]=1;for(var O=1,F=v+1;O<F;){var V=O++;N+=w;var H=m.add(r,m.add(m.mul(d*Math.cos(N),n),m.mul(p*Math.sin(N),i)));R[L+2]=1,E[L+2]=H;var J=m.sub(m.mul(Math.cos(N),i),m.mul(Math.sin(N),n)),G=at.rays(A,m.mul(1/m.norm(I),I),H,m.mul(1/m.norm(J),J)),j=m.add(A,m.mul(G.u0,I));R[L+1]=P,E[L+1]=j,L+=2,V<v&&(A=H,I=J)}for(var Y=2*v+1,tt=0;tt<3;){var et=tt++;T[et]=0,T[et+Y]=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 Ft(2,T,C.homogenize1d(E,R))},dt.arc=function(r,n,i,l,u,d){return dt.ellipseArc(r,m.mul(l,m.normalized(n)),m.mul(l,m.normalized(i)),u,d)},dt.polyline=function(r){for(var n=[0,0],i=0,l=0,u=r.length-1;l<u;){var d=l++;i+=m.dist(r[d],r[d+1]),n.push(i)}n.push(i),n=m.mul(1/i,n);for(var p,_=[],v=0,w=r.length;v<w;)v++,_.push(1);return p=_,new Ft(1,n,C.homogenize1d(r.slice(0),p))},dt.extrudedSurface=function(r,n,i){for(var l=[[],[],[]],u=[[],[],[]],d=C.dehomogenize1d(i.controlPoints),p=C.weight1d(i.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]),u[0][A]=p[A],u[1][A]=p[A],u[2][A]=p[A]}return new Jt(2,i.degree,[0,0,0,1,1,1],i.knots,C.homogenize2d(l,u))},dt.cylindricalSurface=function(r,n,i,l,u){var d=m.cross(r,n),p=dt.arc(i,n,d,u,0,2*Math.PI);return dt.extrudedSurface(r,l,p)},dt.revolvedSurface=function(r,n,i,l){var u=C.dehomogenize1d(r.controlPoints),d=C.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),E=0,T=m.zeros1d(p+1),L=m.zeros1d(p+1),N=m.zeros3d(2*p+1,u.length,3),R=m.zeros2d(2*p+1,u.length),O=1,F=p+1;O<F;){var V=O++;E+=v,L[V]=Math.cos(E),T[V]=Math.sin(E)}for(var H=0,J=u.length;H<J;){var G=H++,j=Ee.rayClosestPoint(u[G],n,i),Y=m.sub(u[G],j),tt=m.norm(Y),et=m.cross(i,Y);tt>rt.EPSILON&&(Y=m.mul(1/tt,Y),et=m.mul(1/tt,et)),N[0][G]=u[G];var st=u[G];R[0][G]=d[G];for(var ot=et,it=0,ht=1,nt=p+1;ht<nt;){var ct=ht++,q;tt==0?q=j:q=m.add(j,m.add(m.mul(tt*L[ct],Y),m.mul(tt*T[ct],et))),N[it+2][G]=q,R[it+2][G]=d[G];var pt=m.sub(m.mul(L[ct],et),m.mul(T[ct],Y));if(tt==0)N[it+1][G]=j;else{var At=at.rays(st,m.mul(1/m.norm(ot),ot),q,m.mul(1/m.norm(pt),pt)),Vt=m.add(st,m.mul(At.u0,ot));N[it+1][G]=Vt}R[it+1][G]=I*d[G],it+=2,ct<p&&(st=q,ot=pt)}}return new Jt(2,r.degree,_,r.knots,C.homogenize2d(N,R))},dt.sphericalSurface=function(r,n,i,l){var u=dt.arc(r,m.mul(-1,n),i,l,0,Math.PI);return dt.revolvedSurface(u,r,n,2*Math.PI)},dt.conicalSurface=function(r,n,i,l,u){var d=2*Math.PI,p=1,_=[m.add(i,m.mul(l,r)),m.add(i,m.mul(u,n))],v=[0,0,1,1],w=[1,1],P=new Ft(p,v,C.homogenize1d(_,w));return dt.revolvedSurface(P,i,r,d)},dt.rationalInterpCurve=function(r,n,i,l,u){if(i==null&&(i=!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,E=d.length;I<E;){var T=I++;d[T]=d[T]/A}var L=m.rep(n+1,0),N=l!=null&&u!=null,R;N?R=0:R=1;var O;N?O=d.length-n+1:O=d.length-n;for(var F=R;F<O;){for(var V=F++,H=0,J=0;J<n;){var G=J++;H+=d[V+G]}L.push(1/n*H)}var j=L.concat(m.rep(n+1,1)),Y=[],tt;N?tt=r.length+1:tt=r.length-1;var et;N?et=r.length-(n-1):et=r.length-(n+1);for(var st=0;st<d.length;){var ot=d[st];++st;var it=C.knotSpanGivenN(tt,n,ot,j),ht=C.basisFunctionsGivenKnotSpanIndex(it,ot,n,j),nt=it-n,ct=m.zeros1d(nt),q=m.zeros1d(et-nt);Y.push(ct.concat(ht).concat(q))}if(N){var pt=Y[0].length-2,At=[-1,1].concat(m.zeros1d(pt)),Vt=m.zeros1d(pt).concat([-1,1]);K.spliceAndInsert(Y,1,0,At),K.spliceAndInsert(Y,Y.length-1,0,Vt)}for(var qt=r[0].length,Rt=[],Yt=(1-j[j.length-n-2])/n,Ae=j[n+1]/n,Ue=0;Ue<qt;){var ve=[Ue++],ge;if(!N)ge=r.map(function(Xe){return function(hr){return hr[Xe[0]]}}(ve));else{ge=[r[0][ve[0]]],ge.push(Ae*l[ve[0]]);for(var Pe=1,Te=r.length-1;Pe<Te;){var qe=Pe++;ge.push(r[qe][ve[0]])}ge.push(Yt*u[ve[0]]),ge.push(K.last(r)[ve[0]])}var sr=Ct.solve(Y,ge);Rt.push(sr)}var Ye=Ct.transpose(Rt);if(!i){var Ke=m.rep(Ye.length,1);Ye=C.homogenize1d(Ye,Ke)}return new Ft(n,j,Ye)};var _t=f.eval.Modify=function(){};x["verb.eval.Modify"]=_t,_t.__name__=["verb","eval","Modify"],_t.curveReverse=function(r){return new Ft(r.degree,_t.knotsReverse(r.knots),K.reversed(r.controlPoints))},_t.surfaceReverse=function(r,n){return n==null&&(n=!1),n?new Jt(r.degreeU,r.degreeV,r.knotsU,_t.knotsReverse(r.knotsV),function(i){for(var l,u=[],d=0,p=r.controlPoints;d<p.length;){var _=p[d];++d,u.push(K.reversed(_))}return l=u,l}()):new Jt(r.degreeU,r.degreeV,_t.knotsReverse(r.knotsU),r.knotsV,K.reversed(r.controlPoints))},_t.knotsReverse=function(r){var n=K.first(r);K.last(r);for(var i=[n],l=r.length,u=1;u<l;){var d=u++;i.push(i[d-1]+(r[l-d]-r[l-d-1]))}return i},_t.unifyCurveKnotVectors=function(r){r=r.map(dt.clonedCurve);for(var n=z.fold(r,function(j,Y){return _t.imax(j.degree,Y)},0),i=0,l=r.length;i<l;){var u=i++;r[u].degree<n&&(r[u]=_t.curveElevateDegree(r[u],n))}for(var d,p=[],_=0;_<r.length;){var v=r[_];++_,p.push(new we(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(Y){return Y-j[0]}}(I))}for(var E=d.map(function(j){return j.max-j.min}),T=z.fold(E,function(j,Y){return Math.max(j,Y)},0),L=0,N=r.length;L<N;){var R=L++,O=[T/E[R]];r[R].knots=r[R].knots.map(function(j){return function(Y){return Y*j[0]}}(O))}for(var F=z.fold(r,function(j,Y){return m.sortedSetUnion(j.knots,Y)},[]),V=0,H=r.length;V<H;){var J=V++,G=m.sortedSetSub(F,r[J].knots);G.length==0&&(r[J]=r[J]),r[J]=_t.curveKnotRefine(r[J],G)}return r},_t.imin=function(r,n){return r<n?r:n},_t.imax=function(r,n){return r>n?r:n},_t.curveElevateDegree=function(r,n){if(n<=r.degree)return r;var i=r.knots.length-r.degree-2,l=r.degree,u=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=i+l+1,E=n,T=Math.floor(E/2),L=[],N=[];v[0][0]=1,v[E][l]=1;for(var R=1,O=T+1;R<O;)for(var F=R++,V=1/zt.get(E,F),H=_t.imin(l,F),J=_t.imax(0,F-p),G=H+1;J<G;){var j=J++;v[F][j]=V*zt.get(l,j)*zt.get(p,F-j)}for(var Y=T+1;Y<E;)for(var tt=Y++,et=_t.imin(l,tt),st=_t.imax(0,tt-p),ot=et+1;st<ot;){var it=st++;v[tt][it]=v[E-tt][l-it]}var ht=E+1,nt=-1,ct=l,q=l+1,pt=1,At=u[0];L[0]=d[0];for(var Vt=0,qt=E+1;Vt<qt;){var Rt=Vt++;N[Rt]=At}for(var Yt=0,Ae=l+1;Yt<Ae;){var Ue=Yt++;w[Ue]=d[Ue]}for(;q<I;){for(var ve=q;q<I&&u[q]==u[q+1];)q=q+1;var ge=q-ve+1,Pe=u[q],Te=nt;nt=l-ge;var qe;Te>0?qe=Math.floor((Te+2)/2):qe=1;var sr;if(nt>0?sr=Math.floor(E-(nt+1)/2):sr=E,nt>0){for(var Ye=Pe-At,Ke=[],Xe=l;Xe>ge;)Ke[Xe-ge-1]=Ye/(u[ct+Xe]-At),Xe--;for(var hr=1,bn=nt+1;hr<bn;){for(var Gr=hr++,nu=nt-Gr,Mi=ge+Gr,Wr=l;Wr>=Mi;)w[Wr]=m.add(m.mul(Ke[Wr-Mi],w[Wr]),m.mul(1-Ke[Wr-Mi],w[Wr-1])),Wr--;A[nu]=w[l]}}for(var no=qe,su=E+1;no<su;){var xn=no++;P[xn]=m.zeros1d(_);for(var iu=_t.imin(l,xn),so=_t.imax(0,xn-p),au=iu+1;so<au;){var io=so++;P[xn]=m.add(P[xn],m.mul(v[xn][io],w[io]))}}if(Te>1)for(var Ti=ht-2,Ci=ht,ao=Pe-At,ou=(Pe-N[ht-1])/ao,oo=1;oo<Te;){for(var Ni=oo++,ur=Ti,Hr=Ci,Nr=Hr-ht+1;Hr-ur>Ni;){if(ur<pt){var lu=(Pe-N[ur])/(At-N[ur]);L[ur]=m.lerp(lu,L[ur],L[ur-1])}if(Hr>=qe){if(Hr-Ni<=ht-E+Te){var hu=(Pe-N[Hr-Ni])/ao;P[Nr]=m.lerp(hu,P[Nr],P[Nr+1])}}else P[Nr]=m.lerp(ou,P[Nr],P[Nr+1]);ur=ur+1,Hr=Hr-1,Nr=Nr-1}Ti=Ti-1,Ci=Ci+1}if(ct!=l)for(var lo=0,uu=E-Te;lo<uu;)lo++,N[ht]=At,ht=ht+1;for(var ho=qe,cu=sr+1;ho<cu;){var du=ho++;L[pt]=P[du],pt=pt+1}if(q<I){for(var uo=0;uo<nt;){var co=uo++;w[co]=A[co]}for(var mo=nt,mu=l+1;mo<mu;){var po=mo++;w[po]=d[q-l+po]}ct=q,q=q+1,At=Pe}else for(var go=0,pu=E+1;go<pu;){var gu=go++;N[ht+gu]=Pe}}return new Ft(n,N,L)},_t.rationalSurfaceTransform=function(r,n){for(var i=C.dehomogenize2d(r.controlPoints),l=0,u=i.length;l<u;)for(var d=l++,p=0,_=i[d].length;p<_;){var v=p++,w=i[d][v];w.push(1),i[d][v]=Ct.dot(n,w).slice(0,w.length-1)}return new Jt(r.degreeU,r.degreeV,r.knotsU.slice(),r.knotsV.slice(),C.homogenize2d(i,C.weight2d(r.controlPoints)))},_t.rationalCurveTransform=function(r,n){for(var i=C.dehomogenize1d(r.controlPoints),l=0,u=i.length;l<u;){var d=l++,p=i[d];p.push(1),i[d]=Ct.dot(n,p).slice(0,p.length-1)}return new Ft(r.degree,r.knots.slice(),C.homogenize1d(i,C.weight1d(r.controlPoints)))},_t.surfaceKnotRefine=function(r,n,i){var l=[],u,d,p;i?(p=r.controlPoints,u=r.knotsV,d=r.degreeV):(p=Ct.transpose(r.controlPoints),u=r.knotsU,d=r.degreeU);for(var _=null,v=0;v<p.length;){var w=p[v];++v,_=_t.curveKnotRefine(new Ft(d,u,w),n),l.push(_.controlPoints)}var P=_.knots;return i?new Jt(r.degreeU,r.degreeV,r.knotsU.slice(),P,l):(l=Ct.transpose(l),new Jt(r.degreeU,r.degreeV,P,r.knotsV.slice(),l))},_t.decomposeCurveIntoBeziers=function(r){for(var n=r.degree,i=r.controlPoints,l=r.knots,u=yt.knotMultiplicities(l),d=n+1,p=0;p<u.length;){var _=u[p];if(++p,_.mult<d){var v=m.rep(d-_.mult,_.knot),w=_t.curveKnotRefine(new Ft(n,l,i),v);l=w.knots,i=w.controlPoints}}l.length/d-1;for(var P=d*2,A=[],I=0;I<i.length;){var E=l.slice(I,I+P),T=i.slice(I,I+d);A.push(new Ft(n,E,T)),I+=d}return A},_t.curveKnotRefine=function(r,n){if(n.length==0)return dt.clonedCurve(r);for(var i=r.degree,l=r.controlPoints,u=r.knots,d=l.length-1,p=d+i+1,_=n.length-1,v=C.knotSpan(i,n[0],u),w=C.knotSpan(i,n[_],u),P=[],A=[],I=0,E=v-i+1;I<E;){var T=I++;P[T]=l[T]}for(var L=w-1,N=d+1;L<N;){var R=L++;P[R+_+1]=l[R]}for(var O=0,F=v+1;O<F;){var V=O++;A[V]=u[V]}for(var H=w+i,J=p+1;H<J;){var G=H++;A[G+_+1]=u[G]}for(var j=w+i-1,Y=w+i+_,tt=_;tt>=0;){for(;n[tt]<=u[j]&&j>v;)P[Y-i-1]=l[j-i-1],A[Y]=u[j],Y=Y-1,j=j-1;P[Y-i-1]=P[Y-i];for(var et=1,st=i+1;et<st;){var ot=et++,it=Y-i+ot,ht=A[Y+ot]-n[tt];Math.abs(ht)<rt.EPSILON?P[it-1]=P[it]:(ht=ht/(A[Y+ot]-u[j-i+ot]),P[it-1]=m.add(m.mul(ht,P[it-1]),m.mul(1-ht,P[it])))}A[Y]=n[tt],Y=Y-1,tt--}return new Ft(i,A,P)},_t.curveKnotInsert=function(r,n,i){for(var l=r.degree,u=r.controlPoints,d=r.knots,p=0,_=u.length,v=C.knotSpan(l,n,d),w=[],P=[],A=[],I=1,E=v+1;I<E;){var T=I++;P[T]=d[T]}for(var L=1,N=i+1;L<N;){var R=L++;P[v+R]=n}for(var O=v+1,F=d.length;O<F;){var V=O++;P[V+i]=d[V]}for(var H=0,J=v-l+1;H<J;){var G=H++;A[G]=u[G]}for(var j=v-p;j<_;){var Y=j++;A[Y+i]=u[Y]}for(var tt=0,et=l-p+1;tt<et;){var st=tt++;w[st]=u[v-l+st]}for(var ot=0,it=0,ht=1,nt=i+1;ht<nt;){var ct=ht++;ot=v-l+ct;for(var q=0,pt=l-ct-p+1;q<pt;){var At=q++;it=(n-d[ot+At])/(d[At+v+1]-d[ot+At]),w[At]=m.add(m.mul(it,w[At+1]),m.mul(1-it,w[At]))}A[ot]=w[0],A[v+i-ct-p]=w[l-ct-p]}for(var Vt=ot+1,qt=v-p;Vt<qt;){var Rt=Vt++;A[Rt]=w[Rt-ot]}return new Ft(l,P,A)};var Ot=f.eval.Tess=function(){};x["verb.eval.Tess"]=Ot,Ot.__name__=["verb","eval","Tess"],Ot.rationalCurveRegularSample=function(r,n,i){return Ot.rationalCurveRegularSampleRange(r,r.knots[0],K.last(r.knots),n,i)},Ot.rationalCurveRegularSampleRange=function(r,n,i,l,u){l<1&&(l=2);for(var d=[],p=(i-n)/(l-1),_=0,v=0;v<l;){var w=v++;_=n+p*w,u?d.push([_].concat(C.rationalCurvePoint(r,_))):d.push(C.rationalCurvePoint(r,_))}return d},Ot.rationalCurveAdaptiveSample=function(r,n,i){if(i==null&&(i=!1),n==null&&(n=1e-6),r.degree==1)if(i){for(var l=[],u=0,d=r.controlPoints.length;u<d;){var p=u++;l.push([r.knots[p+1]].concat(C.dehomogenize(r.controlPoints[p])))}return l}else return r.controlPoints.map(C.dehomogenize);return Ot.rationalCurveAdaptiveSampleRange(r,r.knots[0],K.last(r.knots),n,i)},Ot.rationalCurveAdaptiveSampleRange=function(r,n,i,l,u){var d=C.rationalCurvePoint(r,n),p=C.rationalCurvePoint(r,i),_=.5+.2*Math.random(),v=n+(i-n)*_,w=C.rationalCurvePoint(r,v),P=m.sub(d,p),A=m.sub(d,w);if(m.dot(P,P)<l&&m.dot(A,A)>l||!Ee.threePointsAreFlat(d,w,p,l)){var I=n+(i-n)*.5,E=Ot.rationalCurveAdaptiveSampleRange(r,n,I,l,u),T=Ot.rationalCurveAdaptiveSampleRange(r,I,i,l,u);return E.slice(0,-1).concat(T)}else return u?[[n].concat(d),[i].concat(p)]:[d,p]},Ot.rationalSurfaceNaive=function(r,n,i){n<1&&(n=1),i<1&&(i=1),r.degreeU,r.degreeV,r.controlPoints;for(var l=r.knotsU,u=r.knotsV,d=K.last(l)-l[0],p=K.last(u)-u[0],_=d/n,v=p/i,w=[],P=[],A=[],I=0,E=n+1;I<E;)for(var T=I++,L=0,N=i+1;L<N;){var R=L++,O=T*_,F=R*v;P.push([O,F]);var V=C.rationalSurfaceDerivatives(r,O,F,1),H=V[0][0];w.push(H);var J=m.normalized(m.cross(V[1][0],V[0][1]));A.push(J)}for(var G=[],j=0;j<n;)for(var Y=j++,tt=0;tt<i;){var et=tt++,st=Y*(i+1)+et,ot=(Y+1)*(i+1)+et,it=ot+1,ht=st+1,nt=[st,ot,it],ct=[st,it,ht];G.push(nt),G.push(ct)}return new Ge(G,w,A,P)},Ot.divideRationalSurfaceAdaptive=function(r,n){n==null&&(n=new kr),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 i=(r.controlPoints.length-1)*2,l=(r.controlPoints[0].length-1)*2,u;n.minDivsU>i?u=n.minDivsU=n.minDivsU:u=n.minDivsU=i;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-_)/u,A=(v-w)/d,I=[],E=[],T=0,L=d+1;T<L;){for(var N=T++,R=[],O=0,F=u+1;O<F;){var V=O++,H=_+P*V,J=w+A*N,G=C.rationalSurfaceDerivatives(r,H,J,1),j=m.normalized(m.cross(G[0][1],G[1][0]));R.push(new Fe(G[0][0],j,[H,J],-1,m.isZero(j)))}E.push(R)}for(var Y=0;Y<d;)for(var tt=Y++,et=0;et<u;){var st=et++,ot=[E[d-tt-1][st],E[d-tt-1][st+1],E[d-tt][st+1],E[d-tt][st]];I.push(new lr(r,ot))}if(!n.refine)return I;for(var it=0;it<d;)for(var ht=it++,nt=0;nt<u;){var ct=nt++,q=ht*u+ct,pt=Ot.north(q,ht,ct,u,d,I),At=Ot.east(q,ht,ct,u,d,I),Vt=Ot.south(q,ht,ct,u,d,I),qt=Ot.west(q,ht,ct,u,d,I);I[q].neighbors=[Vt,At,pt,qt],I[q].divide(n)}return I},Ot.north=function(r,n,i,l,u,d){return n==0?null:d[r-l]},Ot.south=function(r,n,i,l,u,d){return n==u-1?null:d[r+l]},Ot.east=function(r,n,i,l,u,d){return i==l-1?null:d[r+1]},Ot.west=function(r,n,i,l,u,d){return i==0?null:d[r-1]},Ot.triangulateAdaptiveRefinementNodeTree=function(r){for(var n=Ge.empty(),i=0;i<r.length;){var l=r[i];++i,l.triangulate(n)}return n},Ot.rationalSurfaceAdaptive=function(r,n){n!=null?n=n:n=new kr;var i=Ot.divideRationalSurfaceAdaptive(r,n);return Ot.triangulateAdaptiveRefinementNodeTree(i)};var kr=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"]=kr,kr.__name__=["verb","eval","AdaptiveRefinementOptions"],kr.prototype={__class__:kr};var lr=f.core.AdaptiveRefinementNode=function(r,n,i){if(this.srf=r,i==null?this.neighbors=[null,null,null,null]:this.neighbors=i,this.corners=n,this.corners==null){var l=r.knotsU[0],u=K.last(r.knotsU),d=r.knotsV[0],p=K.last(r.knotsV);this.corners=[Fe.fromUv(l,d),Fe.fromUv(u,d),Fe.fromUv(u,p),Fe.fromUv(l,p)]}};x["verb.eval.AdaptiveRefinementNode"]=lr,lr.__name__=["verb","eval","AdaptiveRefinementNode"],lr.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 i=this.corners[n];this.evalSrf(i.uv[0],i.uv[1],i)}}},evalSrf:function(r,n,i){var l=C.rationalSurfaceDerivatives(this.srf,r,n,1),u=l[0][0],d=m.cross(l[0][1],l[1][0]),p=m.isZero(d);return p||(d=m.normalized(d)),i!=null?(i.degen=p,i.point=u,i.normal=d,i):new Fe(u,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 i=this.neighbors[r].getEdgeCorners((r+2)%4),l=r%2,u=rt.EPSILON,d=this,p=[function(v){return v.uv[0]>d.corners[0].uv[0]+u&&v.uv[0]<d.corners[2].uv[0]-u},function(v){return v.uv[1]>d.corners[0].uv[1]+u&&v.uv[1]<d.corners[2].uv[1]-u}],_=i.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 i=n++;if(this.corners[i],this.corners[i].degen){var l=this.corners[(i+1)%r],u=this.corners[(i+3)%r];l.degen?this.corners[i].normal=u.normal:this.corners[i].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 i=this.center();return m.normSquared(m.sub(i.normal,this.corners[0].normal))>r.normTol||m.normSquared(m.sub(i.normal,this.corners[1].normal))>r.normTol||m.normSquared(m.sub(i.normal,this.corners[2].normal))>r.normTol||m.normSquared(m.sub(i.normal,this.corners[3].normal))>r.normTol},divide:function(r){r==null&&(r=new kr),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,i){if(this.evalCorners(),!!this.shouldDivide(r,n)){if(n++,this.splitVert&&!this.splitHoriz?i=!1:!this.splitVert&&this.splitHoriz&&(i=!0),this.horizontal=i,this.horizontal){var l=[this.corners[0],this.corners[1],this.midpoint(1),this.midpoint(3)],u=[this.midpoint(3),this.midpoint(1),this.corners[2],this.corners[3]];this.children=[new lr(this.srf,l),new lr(this.srf,u)],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 lr(this.srf,d),new lr(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,!i)}}},triangulate:function(r){if(r==null&&(r=Ge.empty()),this.isLeaf())return this.triangulateLeaf(r);for(var n=0,i=this.children;n<i.length;){var l=i[n];if(++n,l==null)break;l.triangulate(r)}return r},triangulateLeaf:function(r){for(var n=r.points.length,i=[],l=[],u=0,d=0;d<4;){var p=d++,_=this.getAllCorners(p);_.length==2&&(u=p+1);for(var v=0,w=_.length;v<w;){var P=v++;i.push(_[P])}}for(var A=0;A<i.length;){var I=i[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(i.length==4)return r.faces.push([l[0],l[3],l[1]]),r.faces.push([l[3],l[2],l[1]]),r;if(i.length==5){var E=l.length;return r.faces.push([l[u],l[(u+2)%E],l[(u+1)%E]]),r.faces.push([l[(u+4)%E],l[(u+3)%E],l[u]]),r.faces.push([l[u],l[(u+3)%E],l[(u+2)%E]]),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,N=0,R=i.length-1;N<i.length;)r.faces.push([L,l[N],l[R]]),R=N++;return r},__class__:lr};var xt=f.exe.Dispatcher=function(){};x["verb.exe.Dispatcher"]=xt,xt.__name__=["verb","exe","Dispatcher"],xt.init=function(){xt._init||(xt._workerPool=new Er(xt.THREADS),xt._init=!0)},xt.dispatchMethod=function(r,n,i){xt.init();var l=new hn,u=function(d){l.resolve(d)};return xt._workerPool.addWork(mt.getClassName(r),n,i,u),new pe(l)};var Er=f.exe.WorkerPool=function(r,n){n==null&&(n="verb.js"),r==null&&(r=1),this._callbacks=new bt,this._working=new bt,this._pool=[],this._queue=[];for(var i=0;i<r;){i++;var l;try{l=new Worker(Er.basePath+n)}catch(u){u instanceof Q&&(u=u.val),l=new Worker(Er.basePath+n.substring(0,-3)+".min.js")}this._pool.push(l)}};x["verb.exe.WorkerPool"]=Er,Er.__name__=["verb","exe","WorkerPool"],Er.prototype={addWork:function(r,n,i,l){var u=new jr(r,n,i);this._callbacks.set(u.id,l),this._queue.push(u),this.processQueue()},processQueue:function(){for(var r=this;this._queue.length>0&&this._pool.length>0;){var n=this._queue.shift(),i=[n.id],l=[this._pool.shift()];this._working.h[i[0]]=l[0],l[0].onmessage=function(u,d){return function(p){r._working.remove(d[0]),r._pool.push(u[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,i),l[0].postMessage(n)}},__class__:Er};var jr=function(r,n,i){this.className=r,this.methodName=n,this.args=i,this.id=jr.uuid++};x["verb.exe._WorkerPool.Work"]=jr,jr.__name__=["verb","exe","_WorkerPool","Work"],jr.prototype={__class__:jr};var vn=function(){};x["verb.geom.ICurve"]=vn,vn.__name__=["verb","geom","ICurve"],vn.__interfaces__=[gn],vn.prototype={__class__:vn};var Et=f.geom.NurbsCurve=function(r){this._data=Ve.isValidNurbsCurveData(r)};x["verb.geom.NurbsCurve"]=Et,Et.__name__=["verb","geom","NurbsCurve"],Et.__interfaces__=[vn],Et.byKnotsControlPointsWeights=function(r,n,i,l){return new Et(new Ft(r,n.slice(),C.homogenize1d(i,l)))},Et.byPoints=function(r,n){return n==null&&(n=3),new Et(dt.rationalInterpCurve(r,n))},Et.__super__=$t,Et.prototype=M($t.prototype,{degree:function(){return this._data.degree},knots:function(){return this._data.knots.slice(0)},controlPoints:function(){return C.dehomogenize1d(this._data.controlPoints)},weights:function(){return C.weight1d(this._data.controlPoints)},asNurbs:function(){return new Ft(this.degree(),this.knots(),C.homogenize1d(this.controlPoints(),this.weights()))},clone:function(){return new Et(this._data)},domain:function(){return new we(K.first(this._data.knots),K.last(this._data.knots))},transform:function(r){return new Et(_t.rationalCurveTransform(this._data,r))},transformAsync:function(r){return xt.dispatchMethod(_t,"rationalCurveTransform",[this._data,r]).then(function(n){return new Et(n)})},point:function(r){return C.rationalCurvePoint(this._data,r)},pointAsync:function(r){return xt.dispatchMethod(C,"rationalCurvePoint",[this._data,r])},tangent:function(r){return C.rationalCurveTangent(this._data,r)},tangentAsync:function(r){return xt.dispatchMethod(C,"rationalCurveTangent",[this._data,r])},derivatives:function(r,n){return n==null&&(n=1),C.rationalCurveDerivatives(this._data,r,n)},derivativesAsync:function(r,n){return n==null&&(n=1),xt.dispatchMethod(C,"rationalCurveDerivatives",[this._data,r,n])},closestPoint:function(r){return yt.rationalCurveClosestPoint(this._data,r)},closestPointAsync:function(r){return xt.dispatchMethod(yt,"rationalCurveClosestPoint",[this._data,r])},closestParam:function(r){return yt.rationalCurveClosestParam(this._data,r)},closestParamAsync:function(r){return xt.dispatchMethod(yt,"rationalCurveClosestParam",[this._data,r])},length:function(){return yt.rationalCurveArcLength(this._data)},lengthAsync:function(){return xt.dispatchMethod(yt,"rationalCurveArcLength",[this._data])},lengthAtParam:function(r){return yt.rationalCurveArcLength(this._data,r)},lengthAtParamAsync:function(){return xt.dispatchMethod(yt,"rationalCurveArcLength",[this._data])},paramAtLength:function(r,n){return yt.rationalCurveParamAtArcLength(this._data,r,n)},paramAtLengthAsync:function(r,n){return xt.dispatchMethod(yt,"rationalCurveParamAtArcLength",[this._data,r,n])},divideByEqualArcLength:function(r){return le.rationalCurveByEqualArcLength(this._data,r)},divideByEqualArcLengthAsync:function(r){return xt.dispatchMethod(le,"rationalCurveByEqualArcLength",[this._data,r])},divideByArcLength:function(r){return le.rationalCurveByArcLength(this._data,r)},divideByArcLengthAsync:function(r){return xt.dispatchMethod(le,"rationalCurveByArcLength",[this._data,r])},split:function(r){return le.curveSplit(this._data,r).map(function(n){return new Et(n)})},splitAsync:function(r){return xt.dispatchMethod(le,"curveSplit",[this._data,r]).then(function(n){return n.map(function(i){return new Et(i)})})},reverse:function(){return new Et(_t.curveReverse(this._data))},reverseAsync:function(){return xt.dispatchMethod(_t,"curveReverse",[this._data]).then(function(r){return new Et(r)})},tessellate:function(r){return Ot.rationalCurveAdaptiveSample(this._data,r,!1)},tessellateAsync:function(r){return xt.dispatchMethod(Ot,"rationalCurveAdaptiveSample",[this._data,r,!1])},__class__:Et});var Mr=f.geom.Arc=function(r,n,i,l,u,d){Et.call(this,dt.arc(r,n,i,l,u,d)),this._center=r,this._xaxis=n,this._yaxis=i,this._radius=l,this._minAngle=u,this._maxAngle=d};x["verb.geom.Arc"]=Mr,Mr.__name__=["verb","geom","Arc"],Mr.__super__=Et,Mr.prototype=M(Et.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__:Mr});var jn=f.geom.BezierCurve=function(r,n){Et.call(this,dt.rationalBezierCurve(r,n))};x["verb.geom.BezierCurve"]=jn,jn.__name__=["verb","geom","BezierCurve"],jn.__super__=Et,jn.prototype=M(Et.prototype,{__class__:jn});var Gn=f.geom.Circle=function(r,n,i,l){Mr.call(this,r,n,i,l,0,Math.PI*2)};x["verb.geom.Circle"]=Gn,Gn.__name__=["verb","geom","Circle"],Gn.__super__=Mr,Gn.prototype=M(Mr.prototype,{__class__:Gn});var yn=function(){};x["verb.geom.ISurface"]=yn,yn.__name__=["verb","geom","ISurface"],yn.__interfaces__=[gn],yn.prototype={__class__:yn};var Pt=f.geom.NurbsSurface=function(r){this._data=Ve.isValidNurbsSurfaceData(r)};x["verb.geom.NurbsSurface"]=Pt,Pt.__name__=["verb","geom","NurbsSurface"],Pt.__interfaces__=[yn],Pt.byKnotsControlPointsWeights=function(r,n,i,l,u,d){return new Pt(new Jt(r,n,i,l,C.homogenize2d(u,d)))},Pt.byCorners=function(r,n,i,l){return new Pt(dt.fourPointSurface(r,n,i,l))},Pt.byLoftingCurves=function(r,n){return new Pt(dt.loftedSurface(function(i){for(var l,u=[],d=0;d<r.length;){var p=r[d];++d,u.push(p.asNurbs())}return l=u,l}(),n))},Pt.__super__=$t,Pt.prototype=M($t.prototype,{degreeU:function(){return this._data.degreeU},degreeV:function(){return this._data.degreeV},knotsU:function(){return this._data.knotsU.slice(0)},knotsV:function(){return this._data.knotsV.slice(0)},controlPoints:function(){return C.dehomogenize2d(this._data.controlPoints)},weights:function(){return C.weight2d(this._data.controlPoints)},asNurbs:function(){return new Jt(this.degreeU(),this.degreeV(),this.knotsU(),this.knotsV(),C.homogenize2d(this.controlPoints(),this.weights()))},clone:function(){return new Pt(this.asNurbs())},domainU:function(){return new we(K.first(this._data.knotsU),K.last(this._data.knotsU))},domainV:function(){return new we(K.first(this._data.knotsV),K.last(this._data.knotsV))},point:function(r,n){return C.rationalSurfacePoint(this._data,r,n)},pointAsync:function(r,n){return xt.dispatchMethod(C,"rationalSurfacePoint",[this._data,r,n])},normal:function(r,n){return C.rationalSurfaceNormal(this._data,r,n)},normalAsync:function(r,n){return xt.dispatchMethod(C,"rationalSurfaceNormal",[this._data,r,n])},derivatives:function(r,n,i){return i==null&&(i=1),C.rationalSurfaceDerivatives(this._data,r,n,i)},derivativesAsync:function(r,n,i){return i==null&&(i=1),xt.dispatchMethod(C,"rationalSurfaceDerivatives",[this._data,r,n,i])},closestParam:function(r){return yt.rationalSurfaceClosestParam(this._data,r)},closestParamAsync:function(r){return xt.dispatchMethod(yt,"rationalSurfaceClosestParam",[this._data,r])},closestPoint:function(r){return yt.rationalSurfaceClosestPoint(this._data,r)},closestPointAsync:function(r){return xt.dispatchMethod(yt,"rationalSurfaceClosestPoint",[this._data,r])},split:function(r,n){return n==null&&(n=!1),le.surfaceSplit(this._data,r,n).map(function(i){return new Pt(i)})},splitAsync:function(r,n){return n==null&&(n=!1),xt.dispatchMethod(le,"surfaceSplit",[this._data,r,n]).then(function(i){return i.map(function(l){return new Pt(l)})})},reverse:function(r){return r==null&&(r=!1),new Pt(_t.surfaceReverse(this._data,r))},reverseAsync:function(r){return r==null&&(r=!1),xt.dispatchMethod(_t,"surfaceReverse",[this._data,r]).then(function(n){return new Pt(n)})},isocurve:function(r,n){return n==null&&(n=!1),new Et(dt.surfaceIsocurve(this._data,r,n))},isocurveAsync:function(r,n){return n==null&&(n=!1),xt.dispatchMethod(dt,"surfaceIsocurve",[this._data,r,n]).then(function(i){return new Et(i)})},boundaries:function(r){return dt.surfaceBoundaryCurves(this._data).map(function(n){return new Et(n)})},boundariesAsync:function(r){return xt.dispatchMethod(dt,"surfaceBoundaryCurves",[this._data]).then(function(n){return n.map(function(i){return new Et(i)})})},tessellate:function(r){return Ot.rationalSurfaceAdaptive(this._data,r)},tessellateAsync:function(r){return xt.dispatchMethod(Ot,"rationalSurfaceAdaptive",[this._data,r])},transform:function(r){return new Pt(_t.rationalSurfaceTransform(this._data,r))},transformAsync:function(r){return xt.dispatchMethod(_t,"rationalSurfaceTransform",[this._data,r]).then(function(n){return new Pt(n)})},__class__:Pt});var Wn=f.geom.ConicalSurface=function(r,n,i,l,u){Pt.call(this,dt.conicalSurface(r,n,i,l,u)),this._axis=r,this._xaxis=n,this._base=i,this._height=l,this._radius=u};x["verb.geom.ConicalSurface"]=Wn,Wn.__name__=["verb","geom","ConicalSurface"],Wn.__super__=Pt,Wn.prototype=M(Pt.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__:Wn});var Hn=f.geom.CylindricalSurface=function(r,n,i,l,u){Pt.call(this,dt.cylindricalSurface(r,n,i,l,u)),this._axis=r,this._xaxis=n,this._base=i,this._height=l,this._radius=u};x["verb.geom.CylindricalSurface"]=Hn,Hn.__name__=["verb","geom","CylindricalSurface"],Hn.__super__=Pt,Hn.prototype=M(Pt.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__:Hn});var Tr=f.geom.EllipseArc=function(r,n,i,l,u){Et.call(this,dt.ellipseArc(r,n,i,l,u)),this._center=r,this._xaxis=n,this._yaxis=i,this._minAngle=l,this._maxAngle=u};x["verb.geom.EllipseArc"]=Tr,Tr.__name__=["verb","geom","EllipseArc"],Tr.__super__=Et,Tr.prototype=M(Et.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__:Tr});var qn=f.geom.Ellipse=function(r,n,i){Tr.call(this,r,n,i,0,Math.PI*2)};x["verb.geom.Ellipse"]=qn,qn.__name__=["verb","geom","Ellipse"],qn.__super__=Tr,qn.prototype=M(Tr.prototype,{__class__:qn});var Yn=f.geom.ExtrudedSurface=function(r,n){Pt.call(this,dt.extrudedSurface(m.normalized(n),m.norm(n),r.asNurbs())),this._profile=r,this._direction=n};x["verb.geom.ExtrudedSurface"]=Yn,Yn.__name__=["verb","geom","ExtrudedSurface"],Yn.__super__=Pt,Yn.prototype=M(Pt.prototype,{profile:function(){return this._profile},direction:function(){return this._direction},__class__:Yn});var Cr=f.geom.Intersect=function(){};x["verb.geom.Intersect"]=Cr,Cr.__name__=["verb","geom","Intersect"],Cr.curves=function(r,n,i){return i==null&&(i=.001),at.curves(r.asNurbs(),n.asNurbs(),i)},Cr.curvesAsync=function(r,n,i){return i==null&&(i=.001),xt.dispatchMethod(at,"curves",[r.asNurbs(),n.asNurbs(),i])},Cr.curveAndSurface=function(r,n,i){return i==null&&(i=.001),at.curveAndSurface(r.asNurbs(),n.asNurbs(),i)},Cr.curveAndSurfaceAsync=function(r,n,i){return i==null&&(i=.001),xt.dispatchMethod(at,"curveAndSurface",[r.asNurbs(),n.asNurbs(),i])},Cr.surfaces=function(r,n,i){return i==null&&(i=.001),at.surfaces(r.asNurbs(),n.asNurbs(),i).map(function(l){return new Et(l)})},Cr.surfacesAsync=function(r,n,i){return i==null&&(i=.001),xt.dispatchMethod(at,"surfaces",[r.asNurbs(),n.asNurbs(),i]).then(function(l){return l.map(function(u){return new Et(u)})})};var Kn=f.geom.Line=function(r,n){Et.call(this,dt.polyline([r,n])),this._start=r,this._end=n};x["verb.geom.Line"]=Kn,Kn.__name__=["verb","geom","Line"],Kn.__super__=Et,Kn.prototype=M(Et.prototype,{start:function(){return this._start},end:function(){return this._end},__class__:Kn});var Xn=f.geom.RevolvedSurface=function(r,n,i,l){Pt.call(this,dt.revolvedSurface(r.asNurbs(),n,i,l)),this._profile=r,this._center=n,this._axis=i,this._angle=l};x["verb.geom.RevolvedSurface"]=Xn,Xn.__name__=["verb","geom","RevolvedSurface"],Xn.__super__=Pt,Xn.prototype=M(Pt.prototype,{profile:function(){return this._profile},center:function(){return this._center},axis:function(){return this._center},angle:function(){return this._angle},__class__:Xn});var $n=f.geom.SphericalSurface=function(r,n){Pt.call(this,dt.sphericalSurface(r,[0,0,1],[1,0,0],n)),this._center=r,this._radius=n};x["verb.geom.SphericalSurface"]=$n,$n.__name__=["verb","geom","SphericalSurface"],$n.__super__=Pt,$n.prototype=M(Pt.prototype,{center:function(){return this._center},radius:function(){return this._radius},__class__:$n});var Zn=f.geom.SweptSurface=function(r,n){Pt.call(this,dt.rationalTranslationalSurface(r.asNurbs(),n.asNurbs())),this._profile=r,this._rail=n};x["verb.geom.SweptSurface"]=Zn,Zn.__name__=["verb","geom","SweptSurface"],Zn.__super__=Pt,Zn.prototype=M(Pt.prototype,{profile:function(){return this._profile},rail:function(){return this._rail},__class__:Zn});function He(r){return r instanceof Array?function(){return D.iter(r)}:typeof r.iterator=="function"?Me(r,r.iterator):r.iterator}var Ii,tu=0;function Me(r,n){if(n==null)return null;n.__id__==null&&(n.__id__=tu++);var i;return r.hx__closures__==null?r.hx__closures__={}:i=r.hx__closures__[n.__id__],i==null&&(i=function(){return i.method.apply(i.scope,arguments)},i.scope=r,i.method=n,r.hx__closures__[n.__id__]=i),i}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 eu=x.Int={__name__:["Int"]},ru=x.Dynamic={__name__:["Dynamic"]},Ja=x.Float=Number;Ja.__name__=["Float"];var to=x.Bool=Boolean;to.__ename__=["Bool"];var eo=x.Class={__name__:["Class"]},ro={};Array.prototype.map==null&&(Array.prototype.map=function(r){for(var n=[],i=0,l=this.length;i<l;){var u=i++;n[u]=r(this[u])}return n}),Array.prototype.filter==null&&(Array.prototype.filter=function(r){for(var n=[],i=0,l=this.length;i<l;){var u=i++,d=this[u];r(d)&&n.push(d)}return n});var ki={},Es=S.ArrayBuffer||oe;Es.prototype.slice==null&&(Es.prototype.slice=oe.sliceImpl),S.DataView;var Ei=S.Uint8Array||tr._new;(function(r,n){if(r.setImmediate)return;var i=1,l={},u=!1,d=r.document,p;function _(O){return l[i]=v.apply(n,O),i++}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(u)setTimeout(v(w,O),0);else{var F=l[O];if(F){u=!0;try{F()}finally{P(O),u=!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 E(){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 N(){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()?E():r.MessageChannel?T():d&&"onreadystatechange"in d.createElement("script")?L():N(),R.setImmediate=p,R.clearImmediate=P})(new Function("return this")()),Ht.USE_CACHE=!1,Ht.USE_ENUM_INDEX=!1,Ht.BASE64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:",Ut.DEFAULT_RESOLVER=mt,Ut.BASE64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:",Lt.count=0,ae.i64tmp=function(r){var n,i=new Wt(0,0);return n=i,n}(),kt.__toStr={}.toString,tr.BYTES_PER_ELEMENT=1,wt.queue=new U,zt.memo=new bt,rt.TOLERANCE=1e-6,rt.EPSILON=1e-10,rt.VERSION="2.0.0",yt.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]],yt.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]],xt.THREADS=1,xt._init=!1,Er.basePath="",jr.uuid=0,Is.main()}(typeof console<"u"?console:{log:function(){}},e,typeof c<"u"?c:typeof s<"u"?s:typeof self<"u"?self:this),e})})(wh);var sd=wh.exports;const Pn=nd(sd);class Ki{constructor(){this.c0=0,this.c1=0,this.c2=0,this.c3=0}init(t,e,s,o){this.c0=t,this.c1=s,this.c2=-3*t+3*e-2*s-o,this.c3=2*t-2*e+s+o}initCatmullRom(t,e,s,o,h){this.init(e,s,h*(s-t),h*(o-e))}initNonuniformCatmullRom(t,e,s,o,h,c,g){let b=(e-t)/h-(s-t)/(h+c)+(s-e)/c,f=(s-e)/c-(o-e)/(c+g)+(o-s)/g;b*=c,f*=c,this.init(e,s,b,f)}calc(t){const e=t*t,s=e*t;return this.c0+this.c1*t+this.c2*e+this.c3*s}}class Ah extends Ps{constructor(t=[],e=!1,s="centripetal",o=.5){super(),this.isCatmullRomCurve3d=!0,this.type="CatmullRomCurve3d",this._tmp=new $,this._px=new Ki,this._py=new Ki,this._pz=new Ki,this._points=t.map(h=>new X(h)),this._closed=e,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 X}get endPoint(){return this._points.length>0?this._points[this._points.length-1]:new X}get length(){if(this._points.length<2)return 0;let t=0;for(let e=1;e<this._points.length;e++)t+=this._points[e-1].distanceTo(this._points[e]);return this._closed&&this._points.length>2&&(t+=this._points[this._points.length-1].distanceTo(this._points[0])),t}getPoint(t,e=new X){const s=e,o=this._points,h=o.length;if(h===0)return s.set(0,0,0);if(h===1)return s.copy(o[0]);const c=(h-(this._closed?0:1))*t;let g=Math.floor(c),b=c-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 X(this._tmp.x,this._tmp.y,this._tmp.z));const x=o[g%h],k=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 X(this._tmp.x,this._tmp.y,this._tmp.z)),this._curveType==="centripetal"||this._curveType==="chordal"){const M=this._curveType==="chordal"?.5:.25;let D=Math.pow(f.distanceToSquared(x),M),z=Math.pow(x.distanceToSquared(k),M),U=Math.pow(k.distanceToSquared(S),M);z<1e-4&&(z=1),D<1e-4&&(D=z),U<1e-4&&(U=z),this._px.initNonuniformCatmullRom(f.x,x.x,k.x,S.x,D,z,U),this._py.initNonuniformCatmullRom(f.y,x.y,k.y,S.y,D,z,U),this._pz.initNonuniformCatmullRom(f.z,x.z,k.z,S.z,D,z,U)}else this._curveType==="catmullrom"&&(this._px.initCatmullRom(f.x,x.x,k.x,S.x,this._tension),this._py.initCatmullRom(f.y,x.y,k.y,S.y,this._tension),this._pz.initCatmullRom(f.z,x.z,k.z,S.z,this._tension));return s.set(this._px.calc(b),this._py.calc(b),this._pz.calc(b)),s}getPoints(t){const e=[];for(let s=0;s<=t;s++)e.push(this.getPoint(s/t));return e}setPoints(t){this._points=t.map(e=>new X(e)),this._boundingBoxNeedsUpdate=!0}setClosed(t){this._closed!==t&&(this._closed=t,this._boundingBoxNeedsUpdate=!0)}setCurveType(t){this._curveType=t}setTension(t){this._tension=t}transform(t){return this._points=this._points.map(e=>{const s=new X;return s.copy(e),s.applyMatrix3d(t),s}),this._boundingBoxNeedsUpdate=!0,this}calculateBoundingBox(){if(this._points.length===0)return new Dt;const t=new Dt;return this._points.forEach(e=>{t.expandByPoint(e)}),t}}class nn{constructor(t,e,s,o){this._degree=t,this._knots=[...e],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(t=>({x:t.x,y:t.y,z:t.z}))}weights(){return[...this._weights]}point(t){const e=this._controlPoints.map(s=>[s.x,s.y,s.z]);return _s(t,this._degree,this._knots,e,this._weights)}length(){const t=this._controlPoints.map(e=>[e.x,e.y,e.z]);return gh(this._degree,this._knots,t,this._weights)}static byKnotsControlPointsWeights(t,e,s,o){return new nn(t,e,s,o)}static byPoints(t,e,s="Uniform"){let o;switch(s){case"Chord":o=mh(e,t);break;case"SqrtChord":o=ph(e,t);break;case"Uniform":default:o=dh(e,t.length);break}const h=t.map(g=>({x:g[0],y:g[1],z:g[2]})),c=new Array(h.length).fill(1);return new nn(e,o,h,c)}getParameterRange(){const t=this._knots[this._degree],e=this._knots[this._knots.length-this._degree-1];return{start:t,end:e}}getPoints(t){const e=[],{start:s,end:o}=this.getParameterRange();for(let h=0;h<=t;h++){const c=s+(o-s)*(h/t);e.push(this.point(c))}return e}isClosed(t=1e-6){const{start:e,end:s}=this.getParameterRange(),o=this.point(e),h=this.point(s),c=o[0]-h[0],g=o[1]-h[1],b=o[2]-h[2];return Math.sqrt(c*c+g*g+b*b)<t}static createFitPointsForClosedCurve(t){if(t.length<4)throw new Error("At least 4 points are required for a closed NURBS curve");const e=new Ah(t,!0,"centripetal"),s=Math.max(50,t.length*2);return e.getPoints(s)}static createClosedCurve(t,e,s="Chord"){const o=this.createFitPointsForClosedCurve(t).map(h=>[h.x,h.y,h.z]);return nn.byPoints(o,e,s)}}class Fr extends Ps{constructor(t,e,s,o,h){super();const c=arguments.length;if(c<2||c>5)throw Re.ILLEGAL_PARAMETERS;if(this._degree=3,this._closed=!1,Array.isArray(e)){this._controlPoints=t;let g,b=3,f=!1;if(c>=3&&(Array.isArray(s)?(g=s,c>=4&&(b=o||3),c>=5&&(f=h)):s!==void 0&&(b=s||3,c>=4&&(f=o))),s===void 0&&c>=4&&(b=o||3,c>=5&&(f=h)),this._degree=b,this._closed=f,this._controlPoints.length<this._degree+1)throw Re.ILLEGAL_PARAMETERS;const S=this.toVerbPoints(this._controlPoints);this._nurbsCurve=Pn.geom.NurbsCurve.byKnotsControlPointsWeights(this._degree,e,S,g)}else{if(this._fitPoints=t,this._knotParameterization=e,c>=3&&(this._degree=s||3),c>=4&&(this._closed=o),this._fitPoints.length<this._degree+1)throw Re.ILLEGAL_PARAMETERS;const g=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=Pn.geom.NurbsCurve.byPoints(g,this._degree),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}}buildCurve(){if(this._fitPoints&&this._knotParameterization){if(this._closed){const t=nn.createFitPointsForClosedCurve(this._fitPoints),e=this.toNurbsPoints(t);this._nurbsCurve=Pn.geom.NurbsCurve.byPoints(e,this._degree)}else{const t=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=Pn.geom.NurbsCurve.byPoints(t,this._degree)}this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}else if(this._controlPoints)if(this._closed){const t=nn.createFitPointsForClosedCurve(this._controlPoints),e=this.toNurbsPoints(t);this._nurbsCurve=Pn.geom.NurbsCurve.byPoints(e,this._degree),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}else{const t=this._nurbsCurve.knots(),e=this._nurbsCurve.weights(),s=this.toVerbPoints(this._controlPoints);this._nurbsCurve=Pn.geom.NurbsCurve.byKnotsControlPointsWeights(this._degree,t,s,e)}}setClosed(t){this._closed!==t&&(this._closed=t,this._boundingBoxNeedsUpdate=!0,this.buildCurve())}get degree(){return this._degree}get knotParameterization(){return this._knotParameterization}get startPoint(){const t=this._nurbsCurve.knots(),e=this._nurbsCurve.degree(),s=t[e],o=this._nurbsCurve.point(s);return new X(o[0],o[1],o[2])}get endPoint(){const t=this._nurbsCurve.knots(),e=this._nurbsCurve.degree(),s=t[t.length-e-1],o=this._nurbsCurve.point(s);return new X(o[0],o[1],o[2])}get length(){return this._nurbsCurve.length()}getFitPointAt(t){if(!this._fitPoints)throw new Error("No fit points in this spline");const e=this._fitPoints.length,s=t<0||t>=e?e-1:t,o=this._fitPoints[s];return{x:o.x,y:o.y,z:o.z||0}}getControlPointAt(t){const e=this._controlPoints.length,s=t<0||t>=e?e-1:t;return this._controlPoints[s]}getPoints(t=100){const e=this._nurbsCurve,s=[],o=e.knots(),h=this._nurbsCurve.degree(),c=o[h],g=o[o.length-h-1],b=(g-c)/(t-1);for(let f=0;f<t;f++){const S=f===t-1?g:c+f*b,x=e.point(S);s.push(new X(x[0],x[1],x[2]))}return s}getCurvePoints(t,e){const s=[],o=t.knots(),h=o[3],c=(o[o.length-4]-h)/(e-1);for(let g=0;g<e;g++){const b=h+g*c;s.push(t.point(b))}return s}calculateBoundingBox(){const t=this.getPoints(100);return new Dt().setFromPoints(t)}get closed(){return this._closed}set closed(t){this.setClosed(t)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}toNurbsPoints(t){const e=new Array(t.length);return t.forEach((s,o)=>{e[o]=[s.x,s.y,s.z||0]}),e}toVerbPoints(t){const e=new Array(t.length);return t.forEach((s,o)=>{e[o]=[s.x,s.y,s.z||0]}),e}toGePoints(t){const e=new Array(t.length);return t.forEach((s,o)=>{e[o]={x:s[0],y:s[1],z:s[2]}}),e}static createClosedSpline(t,e="Uniform",s=3){if(t.length<s+1)throw new Error(`At least ${s+1} points are required for a degree ${s} closed spline`);return new Fr(t,e,s,!0)}}var en=256,Ph=[],Mo=256,Ls;for(;en--;)Ph[en]=(en+256).toString(16).substring(1);function id(a){var t=0,e=11;if(!Ls||en+e>Mo*2)for(Ls="",en=0;t<Mo;t++)Ls+=Ph[Math.random()*256|0];return Ls.substring(en,en+++e)}class Vr{constructor(t,e){t=t||{},Mn(t,{objectId:id()}),this._attrs=new Fo(t,e)}get attrs(){return this._attrs}getAttr(t){const e=this._attrs.get(t);if(e===void 0)throw new Error(`[AcDbObject] Attribute name '${t}' does't exist in this object!`);return e}getAttrWithoutException(t){return this._attrs.get(t)}setAttr(t,e){this._attrs.set(t,e)}get objectId(){return this.getAttr("objectId")}set objectId(t){this._attrs.set("objectId",t)}get ownerId(){return this.getAttr("ownerId")}set ownerId(t){this._attrs.set("ownerId",t)}get database(){return this._database?this._database:Pa().workingDatabase}set database(t){this._database=t}close(){}}const Sa=class Sa extends Vr{constructor(){super(...arguments),this._layer="0",this._color=new an,this._lineType=Gs,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(t){this._layer=t}get color(){return this._color}set color(t){this._color.copy(t)}get rgbColor(){let t=this.database.cecolor;if(this.color.isByLayer){const e=this.getLayerColor();e&&e.color&&(t=e)}else this.color.isByBlock||this.color.color!=null&&(t=this.color);return t.color==null?16777215:t.color}get lineType(){return this._lineType}set lineType(t){this._lineType=t||Gs}get lineWeight(){return this._lineWeight}set lineWeight(t){this._lineWeight=t}get linetypeScale(){return this._linetypeScale}set linetypeScale(t){this._linetypeScale=t}get visibility(){return this._visibility}set visibility(t){this._visibility=t}get transparency(){return this._transparency}set transparency(t){this._transparency=t}subGetGripPoints(){return new Array}subGetOsnapPoints(t,e,s,o,h){}transformBy(t){return this}triggerModifiedEvent(){this.database.events.entityModified.dispatch({database:this.database,entity:this})}get lineStyle(){var s;const t=this.getLineType(),e=(s=this.database)==null?void 0:s.tables.linetypeTable.getAt(t);return e?{...e.linetype,color:this.rgbColor}:{name:t,standardFlag:0,color:this.rgbColor,description:"",totalPatternLength:0}}getLineType(){if(this.lineType==Gs){const t=this.database.tables.layerTable.getAt(this.layer);if(t&&t.linetype)return t.linetype}else return this.lineType==Fl?Hs:this.lineType;return Hs}getLayerColor(){const t=this.database.tables.layerTable.getAt(this.layer);if(t==null)console.error(`The layer with name '${this.layer}' not found in drawing database!`);else return t.color;return null}};Sa.typeName="Entity";let je=Sa;const Ia=class Ia extends je{constructor(t){super(),this._blockName=t,this._position=new X,this._rotation=0,this._normal=new $(0,0,1),this._scaleFactors=new X(1,1,1)}get position(){return this._position}set position(t){this._position.copy(t)}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get scaleFactors(){return this._scaleFactors}set scaleFactors(t){this._scaleFactors.copy(t)}get normal(){return this._normal}set normal(t){this._normal.copy(t).normalize()}get blockTableRecord(){return this.database.tables.blockTable.getAt(this._blockName)}get geometricExtents(){const t=new Dt,e=this.blockTableRecord;if(e!=null){const h=e.newIterator();for(const c of h)t.union(c.geometricExtents)}const s=new Rr().setFromEuler(new yh(this.rotation,0,0)),o=new sn;return o.compose(this.position,s,this.scaleFactors),t.applyMatrix4(o),t}draw(t){const e=[],s=this.blockTableRecord;if(s!=null){const o=this.computeTransformMatrix();return Dr.instance.draw(t,s,this.rgbColor,!0,o,this.normal)}else return t.group(e)}computeTransformMatrix(){const t=new Rr;return t.setFromAxisAngle($.Z_AXIS,this.rotation),new sn().compose(this._position,t,this._scaleFactors)}};Ia.typeName="BlockReference";let ys=Ia;const ka=class ka extends je{};ka.typeName="Curve";let Be=ka;const Ea=class Ea extends Be{constructor(t,e,s,o,h,c,g){super(),this._geo=new xi(t,e,s,o,h,c,g)}get center(){return this._geo.center}set center(t){this._geo.center=t}get majorAxisRadius(){return this._geo.majorAxisRadius}set majorAxisRadius(t){this._geo.majorAxisRadius=t}get minorAxisRadius(){return this._geo.minorAxisRadius}set minorAxisRadius(t){this._geo.minorAxisRadius=t}get normal(){return this._geo.normal}set normal(t){this._geo.normal=t}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}draw(t){return t.ellipticalArc(this._geo,this.lineStyle)}};Ea.typeName="Ellipse";let Ys=Ea;const Ma=class Ma extends Be{constructor(t,e,s,o){super(),this._geo=new rn(t,e,s,o,$.Z_AXIS,$.X_AXIS)}get center(){return this._geo.center}set center(t){this._geo.center=t}get radius(){return this._geo.radius}set radius(t){this._geo.radius=t}get startAngle(){return this._geo.startAngle}set startAngle(t){this._geo.startAngle=t}get endAngle(){return this._geo.endAngle}set endAngle(t){this._geo.endAngle=t}get startPoint(){return this._geo.startPoint}get endPoint(){return this._geo.endPoint}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}subGetGripPoints(){const t=new Array;return t.push(this.center),t.push(this.startPoint),t.push(this.endPoint),t}transformBy(t){return this._geo.transform(t),this}draw(t){return t.circularArc(this._geo,this.lineStyle)}};Ma.typeName="Arc";let Ks=Ma;const Ta=class Ta extends Be{constructor(t,e,s=$.Z_AXIS){super(),this._geo=new rn(t,e,0,re,s,$.X_AXIS)}get center(){return this._geo.center}set center(t){this._geo.center=t}get radius(){return this._geo.radius}set radius(t){this._geo.radius=t}get normal(){return this._geo.normal}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}subGetGripPoints(){const t=new Array;return t.push(this.center),t}transformBy(t){return this._geo.transform(t),this}draw(t){return t.circularArc(this._geo,this.lineStyle)}};Ta.typeName="Circle";let Xs=Ta;var Sh=(a=>(a[a.UserDefined=0]="UserDefined",a[a.Predefined=1]="Predefined",a[a.Custom=2]="Custom",a))(Sh||{}),Ih=(a=>(a[a.Normal=0]="Normal",a[a.Outer=1]="Outer",a[a.Ignore=2]="Ignore",a))(Ih||{});const Ca=class Ca extends je{constructor(){super(),this._elevation=0,this._geo=new yi,this._definitionLines=[],this._patternName="",this._patternType=1,this._patternAngle=0,this._patternScale=1,this._hatchStyle=0}get definitionLines(){return this._definitionLines}get patternName(){return this._patternName}set patternName(t){this._patternName=t}get patternType(){return this._patternType}set patternType(t){this._patternType=t}get patternAngle(){return this._patternAngle}set patternAngle(t){this._patternAngle=t}get patternScale(){return this._patternScale}set patternScale(t){this._patternScale=t}get hatchStyle(){return this._hatchStyle}set hatchStyle(t){this._hatchStyle=t}add(t){this._geo.add(t)}get geometricExtents(){const t=this._geo.box;return new Dt({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}draw(t){return t.area(this._geo,{color:this.rgbColor,solidFill:!1,patternAngle:this.patternAngle,patternLines:this.definitionLines})}};Ca.typeName="Hatch";let $s=Ca;var kh=(a=>(a[a.MText=0]="MText",a[a.Fcf=1]="Fcf",a[a.BlockReference=2]="BlockReference",a[a.NoAnnotation=3]="NoAnnotation",a))(kh||{});const Na=class Na extends Be{constructor(){super(),this._isSplined=!1,this._updated=!1,this._hasArrowHead=!1,this._vertices=[],this._dimensionStyle="",this._hasHookLine=!1,this._annoType=3}get isSplined(){return this._isSplined}set isSplined(t){this._isSplined=t}get hasArrowHead(){return this._hasArrowHead}set hasArrowHead(t){this._hasArrowHead=t}get hasHookLine(){return this._hasHookLine}set hasHookLine(t){this._hasHookLine=t}get numVertices(){return this._vertices.length}get dimensionStyle(){return this._dimensionStyle}set dimensionStyle(t){this._dimensionStyle=t}get annoType(){return this._annoType}set annoType(t){this._annoType=t}appendVertex(t){this._vertices.push(new X().copy(t)),this._updated=!0}setVertexAt(t,e){throw(t<0||t>=this._vertices.length)&&(this._vertices[t].copy(e),this._updated=!0),new Error("The vertex index is out of range!")}vertexAt(t){throw(t<0||t>=this._vertices.length)&&this._vertices[t],new Error("The vertex index is out of range!")}get geometricExtents(){return this._isSplined&&this.splineGeo?this.splineGeo.calculateBoundingBox():new Dt().setFromPoints(this._vertices)}get closed(){return!1}set closed(t){}draw(t){if(this.isSplined&&this.splineGeo){const e=this.splineGeo.getPoints(100);return t.lines(e,this.lineStyle)}else return t.lines(this._vertices,this.lineStyle)}get splineGeo(){return this.createSplineIfNeeded(),this._splineGeo}createSplineIfNeeded(){this.isSplined&&this.numVertices>=2&&(this._splineGeo==null||this._updated)&&(this._splineGeo=new Fr(this._vertices,"Uniform"),this._updated=!1)}};Na.typeName="Leader";let Zs=Na;const La=class La extends Be{constructor(t,e){super(),this._geo=new Br(t,e)}get startPoint(){return this._geo.startPoint}set startPoint(t){this._geo.startPoint=t}get endPoint(){return this._geo.endPoint}set endPoint(t){this._geo.endPoint=t}get midPoint(){return this._geo.midPoint}get geometricExtents(){return this._geo.box}get closed(){return!1}subGetGripPoints(){const t=new Array;return t.push(this.midPoint),t.push(this.startPoint),t.push(this.endPoint),t}subGetOsnapPoints(t,e,s,o,h){const c=this.startPoint,g=this.endPoint;switch(t){case tn.EndPoint:h.push(c),h.push(g);break;case tn.MidPoint:h.push(this.midPoint);break;case tn.Nearest:{const b=this._geo.project(s);h.push(b)}break;case tn.Perpendicular:{const b=this._geo.perpPoint(s);h.push(b)}break;case tn.Tangent:h.push(c);break}}transformBy(t){return this._geo.transform(t),this}draw(t){const e=this.startPoint,s=this.endPoint,o=[new X(e.x,e.y,0),new X(s.x,s.y,0)];return t.lines(o,this.lineStyle)}};La.typeName="Line";let Qs=La;var _a=(a=>(a.ClosedFilled="",a.Dot="_DOT",a.DotSmall="_DOTSMALL",a.DotBlank="_DOTBLANK",a.Origin="_ORIGIN",a.Origin2="_ORIGIN2",a.Open="_OPEN",a.Open90="_OPEN90",a.Open30="_OPEN30",a.Closed="_CLOSED",a.Small="_SMALL",a.None="_NONE",a.Oblique="_OBLIQUE",a.BoxFilled="_BOXFILLED",a.Box="_BOXBLANK",a.ClosedBlank="_CLOSEDBLANK",a.DatumBlank="_DATUMBLANK",a.DatumFilled="_DATUMFILLED",a.Integral="_INTEGRAL",a.ArchTick="_ARCHTICK",a))(_a||{}),Ai=(a=>(a[a.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",a[a.RIGHT_TO_LEFT=2]="RIGHT_TO_LEFT",a[a.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",a[a.BOTTOM_TO_TOP=4]="BOTTOM_TO_TOP",a[a.BY_STYLE=5]="BY_STYLE",a))(Ai||{}),En=(a=>(a[a.TopLeft=1]="TopLeft",a[a.TopCenter=2]="TopCenter",a[a.TopRight=3]="TopRight",a[a.MiddleLeft=4]="MiddleLeft",a[a.MiddleCenter=5]="MiddleCenter",a[a.MiddleRight=6]="MiddleRight",a[a.BottomLeft=7]="BottomLeft",a[a.BottomCenter=8]="BottomCenter",a[a.BottomRight=9]="BottomRight",a))(En||{}),va=(a=>(a[a.OPTIMIZED_2D=0]="OPTIMIZED_2D",a[a.WIREFRAME=1]="WIREFRAME",a[a.HIDDEN_LINE=2]="HIDDEN_LINE",a[a.FLAT_SHADED=3]="FLAT_SHADED",a[a.GOURAUD_SHADED=4]="GOURAUD_SHADED",a[a.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",a[a.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME",a))(va||{}),ya=(a=>(a[a.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",a[a.TOP=1]="TOP",a[a.BOTTOM=2]="BOTTOM",a[a.FRONT=3]="FRONT",a[a.BACK=4]="BACK",a[a.LEFT=5]="LEFT",a[a.RIGHT=6]="RIGHT",a))(ya||{}),ba=(a=>(a[a.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",a[a.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS",a))(ba||{});class Pi{constructor(){this._number=-1,this._id="",this._groupId="",this._centerPoint=new X,this._height=0,this._width=0,this._viewCenter=new X,this._viewHeight=0}get number(){return this._number}set number(t){this._number=t}get id(){return this._id}set id(t){this._id=t}get groupId(){return this._groupId}set groupId(t){this._groupId=t}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get box(){const t=new _e;return t.setFromCenterAndSize(this.centerPoint,{x:this.width,y:this.height}),t}get viewCenter(){return this._viewCenter}set viewCenter(t){this._viewCenter.copy(t)}get viewHeight(){return this._viewHeight}set viewHeight(t){this._viewHeight=t}get viewWidth(){return this.viewHeight*(this.width/this.height)}get viewBox(){const t=new _e;return t.setFromCenterAndSize(this.viewCenter,{x:this.viewWidth,y:this.viewHeight}),t}clone(){const t=new Pi;return t.id=this.id,t.groupId=this.groupId,t.number=this.number,t.centerPoint.copy(this.centerPoint),t.height=this.height,t.width=this.width,t.viewCenter.copy(this.viewCenter),t.viewHeight=this.viewHeight,t}copy(t){return this.id=t.id,this.groupId=t.groupId,this.number=t.number,this.centerPoint.copy(t.centerPoint),this.height=t.height,this.width=t.width,this.viewCenter.copy(t.viewCenter),this.viewHeight=t.viewHeight,this}}const Oa=class Oa extends je{constructor(){super(),this._contents="",this._height=0,this._width=0,this._lineSpacingFactor=.25,this._lineSpacingStyle=0,this._backgroundFill=!1,this._backgroundFillColor=13158600,this._backgroundFillTransparency=1,this._backgroundScaleFactor=1,this._rotation=0,this._styleName="",this._location=new X,this._attachmentPoint=En.TopLeft,this._direction=new $(1,0,0),this._drawingDirection=Ai.LEFT_TO_RIGHT}get contents(){return this._contents}set contents(t){this._contents=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get lineSpacingFactor(){return this._lineSpacingFactor}set lineSpacingFactor(t){this._lineSpacingFactor=t}get lineSpacingStyle(){return this._lineSpacingStyle}set lineSpacingStyle(t){this._lineSpacingStyle=t}get backgroundFill(){return this._backgroundFill}set backgroundFill(t){this._backgroundFill=t,this._backgroundFillColor=13158600}get backgroundFillColor(){return this._backgroundFillColor}set backgroundFillColor(t){this._backgroundFillColor=t}get backgroundFillTransparency(){return this._backgroundFillTransparency}set backgroundFillTransparency(t){this._backgroundFillTransparency=t}get backgroundScaleFactor(){return this._backgroundScaleFactor}set backgroundScaleFactor(t){this._backgroundScaleFactor=t}get styleName(){return this._styleName}set styleName(t){this._styleName=t}get location(){return this._location}set location(t){this._location.copy(t)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(t){this._attachmentPoint=t}get direction(){return this._direction}set direction(t){this._direction.copy(t)}get drawingDirection(){return this._drawingDirection}set drawingDirection(t){this._drawingDirection=t}get geometricExtents(){return new Dt}getTextStyle(){const t=this.database.tables.textStyleTable;let e=t.getAt(this.styleName);return e||(e=t.getAt("STANDARD")||t.getAt("Standard")),e.textStyle}draw(t,e){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 t.mtext(s,o,e)}};Oa.typeName="MText";let Js=Oa;const za=class za extends Be{constructor(t,e,s,o,h){super();const c=+(t!==void 0)+ +(e!==void 0)+ +(s!==void 0)+ +(o!==void 0)+ +(h!==void 0);if(c<2||c>5)throw Re.ILLEGAL_PARAMETERS;!Array.isArray(e)?this._geo=new Fr(t,e,s,o):this._geo=new Fr(t,e,s,o,h)}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}draw(t){const e=this._geo.getPoints(100);return t.lines(e,this.lineStyle)}};za.typeName="Spline";let bs=za;const ad=new $,Da=class Da extends ys{constructor(t,e,s){super(t),this._attachmentPoint=En.TopLeft,this._numColumns=s,this._numRows=e,this._columnWidth=new Array(s),this._rowHeight=new Array(e),this._cells=new Array(e*s)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(t){this._attachmentPoint=t}get numRows(){return this._numRows}set numRows(t){this._numRows=t}get numColumns(){return this._numColumns}set numColumns(t){this._numColumns=t}numContents(t,e){return 1}rowHeight(t){return this._rowHeight[t]}setRowHeight(t,e){this._rowHeight[t]=e}setUniformRowHeight(t){this._rowHeight.fill(t)}columnWidth(t){return this._columnWidth[t]}setUniformColumnWidth(t){this._columnWidth.fill(t)}setColumnWidth(t,e){this._columnWidth[t]=e}cell(t){if(!(t<0||t>=this._cells.length))return this._cells[t]}setCell(t,e){this._cells[t]=e}textString(t,e,s){return this._cells[t*e].text}setTextString(t,e,s){this._cells[t*e].text=s}isEmpty(t,e){return!this._cells[t*e].text}get geometricExtents(){return new Dt}draw(t){let e=0,s=0;const o=new Uint16Array(this.numColumns*this.numRows*8),h=new Float32Array((this.numColumns+1)*(this.numRows+1)*3);let c=0;for(let k=0;k<=this.numRows;k++){e-=k>0?this.rowHeight(k-1):0,s=0;for(let M=0;M<=this.numColumns;M++)s+=M>0?this.columnWidth(M-1):0,h[c++]=s,h[c++]=e,h[c++]=0}const g=[],b=new Array(this.numRows*this.numColumns).fill(!1);s=0,c=0;let f=0;for(let k=0;k<this.numColumns;k++){s+=k>0?this.columnWidth(k-1):0,e=0;for(let M=0;M<this.numRows;M++){e+=M>0?this.rowHeight(M-1):0;const D=this.cell(M*this.numColumns+k);if(f=M*this.numColumns+k,D&&!b[f]){const z=D.borderWidth??1,U=D.borderHeight??1;this.fillVisited(b,f,this.numColumns,z,U),o[c++]=k+M*(this.numColumns+1),o[c++]=k+M*(this.numColumns+1)+z;const B=h[o[c-1]*3]-s,gt=k+(M+U)*(this.numColumns+1)+z;k+z==this.numColumns&&(o[c++]=k+M*(this.numColumns+1)+z,o[c++]=gt);const ft=-h[gt*3+1]-e;if(M+U==this.numRows&&(o[c++]=k+(M+U)*(this.numColumns+1)+U,o[c++]=k+(M+U)*(this.numColumns+1)),o[c++]=k+(M+U)*(this.numColumns+1),o[c++]=k+M*(this.numColumns+1),D.text){const ut=D.attachmentPoint||this.attachmentPoint||En.MiddleCenter,W=this.getTableTextOffset(ut,B,ft),mt={text:D.text,height:D.textHeight,width:B,position:ad.set(s,-e,0).clone().add(W),rotation:this.rotation,attachmentPoint:ut},lt={...this.getTextStyle(D),color:this.color.color};g.push(t.mtext(mt,lt))}}}}g.push(t.lineSegments(h,3,o,this.lineStyle));const S=t.group(g),x=new Rr;return x.setFromAxisAngle($.Z_AXIS,this.rotation),To.compose(this.position,x,this.scaleFactors),S.applyMatrix(To),S}fillVisited(t,e,s,o,h){if(h==1&&o==1)t[e]=!0;else for(let c=0;c<o;++c)for(let g=0;g<h;++g)t[e+c+g*s]=!0}getTextStyle(t){const e=this.database.tables.textStyleTable;let s;return t.textStyle&&(s=e.getAt(t.textStyle)),s||(s=e.getAt("STANDARD")||e.getAt("Standard")),s.textStyle}getTableTextOffset(t,e,s){const o=new $;switch(t){case 1:break;case 2:o.setX(e/2);break;case 3:o.setX(e);break;case 4:o.setY(-s/2);break;case 5:o.set(e/2,-s/2,0);break;case 6:o.set(e,-s/2,0);break;case 7:o.setY(-s);break;case 8:o.set(e/2,-s,0);break;case 9:o.set(e,-s,0);break}return o}};Da.typeName="Table";let ti=Da;const To=new sn;var Eh=(a=>(a[a.LEFT=0]="LEFT",a[a.CENTER=1]="CENTER",a[a.RIGHT=2]="RIGHT",a[a.ALIGNED=3]="ALIGNED",a[a.MIDDLE=4]="MIDDLE",a[a.FIT=5]="FIT",a))(Eh||{}),Mh=(a=>(a[a.BASELINE=0]="BASELINE",a[a.BOTTOM=1]="BOTTOM",a[a.MIDDLE=2]="MIDDLE",a[a.TOP=3]="TOP",a))(Mh||{});const Ra=class Ra extends je{constructor(){super(),this._textString="",this._height=0,this._thickness=1,this._position=new X,this._rotation=0,this._oblique=0,this._horizontalMode=0,this._verticalModel=2,this._styleName="",this._widthFactor=1}get textString(){return this._textString}set textString(t){this._textString=t}get thickness(){return this._thickness}set thickness(t){this._thickness=t}get height(){return this._height}set height(t){this._height=t}get position(){return this._position}set position(t){this._position.copy(t)}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get oblique(){return this._oblique}set oblique(t){this._oblique=t}get horizontalMode(){return this._horizontalMode}set horizontalMode(t){this._horizontalMode=t}get verticalMode(){return this._verticalModel}set verticalMode(t){this._verticalModel=t}get styleName(){return this._styleName}set styleName(t){this._styleName=t}get widthFactor(){return this._widthFactor}set widthFactor(t){this._widthFactor=t}get geometricExtents(){return new Dt}getTextStyle(){const t=this.database.tables.textStyleTable;let e=t.getAt(this.styleName);return e||(e=t.getAt("STANDARD")||t.getAt("Standard")),e.textStyle}draw(t,e){const s={text:this.textString,height:this.height,width:1/0,widthFactor:this.widthFactor,position:this.position,rotation:this.rotation,drawingDirection:Ai.BOTTOM_TO_TOP,attachmentPoint:En.BottomLeft},o={...this.getTextStyle(),color:this.rgbColor};return t.mtext(s,o,e)}};Ra.typeName="Text";let ei=Ra;const Ba=class Ba extends Be{constructor(){super(),this._elevation=0,this._thickness=1,this._vertices=[new X,new X,new X,new X]}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get closed(){return!0}get thickness(){return this._thickness}set thickness(t){this._thickness=t}getPointAt(t){return t<0?this._vertices[0]:t>3?this._vertices[3]:this._vertices[t]}setPointAt(t,e){if(t<0&&this._vertices[0].copy(e),t>3)return this._vertices[3].copy(e);this._vertices[t].copy(e)}get geometricExtents(){return new Dt().setFromPoints(this._vertices)}subGetGripPoints(){const t=new Array;for(let e=0;e<4;++e)t.push(this.getPointAt(e));return t}draw(t){const e=new Ss(this._vertices,!0),s=new yi;return s.add(e),t.area(s,{color:this.rgbColor,solidFill:!0,patternAngle:0,patternLines:[]})}};Ba.typeName="Trace";let ri=Ba;const Fa=class Fa extends Be{constructor(){super(),this._elevation=0,this._geo=new Ss}get numberOfVertices(){return this._geo.numberOfVertices}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}addVertexAt(t,e,s=0,o=-1,h=-1){const c=o<0?void 0:o,g=h<0?void 0:h,b={x:e.x,y:e.y,bulge:s,startWidth:c,endWidth:g};this._geo.addVertexAt(t,b)}getPoint2dAt(t){return this._geo.getPointAt(t)}getPoint3dAt(t){const e=this.getPoint2dAt(t);return new X(e.x,e.y,this._elevation)}get geometricExtents(){const t=this._geo.box;return new Dt({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}subGetGripPoints(){const t=new Array;for(let e=0;e<this.numberOfVertices;++e)t.push(this.getPoint3dAt(e));return t}draw(t){const e=[];return this._geo.getPoints(100).forEach(o=>e.push(new X().set(o.x,o.y,this.elevation))),t.lines(e,this.lineStyle)}};Fa.typeName="Polyline";let ni=Fa;const Va=class Va extends je{constructor(){super(),this._geo=new X}get position(){return this._geo}set position(t){this._geo.set(t.x,t.y,t.z||0)}get geometricExtents(){return new Dt().expandByPoint(this._geo)}transformBy(t){return this._geo.applyMatrix3d(t),this}draw(t){return t.point(this._geo,{displayMode:this.database.pdmode,displaySize:this.database.pdsize,color:this.rgbColor})}};Va.typeName="Point";let si=Va;var Th=(a=>(a[a.Invalid=0]="Invalid",a[a.Rect=1]="Rect",a[a.Poly=2]="Poly",a))(Th||{}),Ch=(a=>(a[a.Show=1]="Show",a[a.ShowUnAligned=2]="ShowUnAligned",a[a.Clip=4]="Clip",a[a.Transparent=8]="Transparent",a))(Ch||{});const Ua=class Ua extends je{constructor(){super(),this._brightness=50,this._contrast=50,this._fade=0,this._width=0,this._height=0,this._position=new X,this._scale=new Kt(1,1),this._rotation=0,this._clipBoundaryType=1,this._clipBoundary=[],this._isClipped=!1,this._isImageShown=!0,this._isImageTransparent=!1,this._imageDefId=""}get brightness(){return this._brightness}set brightness(t){this._brightness=t}get contrast(){return this._contrast}set contrast(t){this._contrast=t}get fade(){return this._fade}set fade(t){this._fade=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get position(){return this._position}set position(t){this._position=t}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get scale(){return this._scale}set scale(t){this._scale.copy(t)}get clipBoundaryType(){return this._clipBoundaryType}set clipBoundaryType(t){this._clipBoundaryType=t}get clipBoundary(){return this._clipBoundary}set clipBoundary(t){this._clipBoundary=[],this._clipBoundary.push(...t)}get isClipped(){return this._isClipped}set isClipped(t){this._isClipped=t}get isImageShown(){return this._isImageShown}set isImageShown(t){this._isImageShown=t}get isImageTransparent(){return this._isImageTransparent}set isImageTransparent(t){this._isImageTransparent=t}get image(){return this._image}set image(t){this._image=t}get imageDefId(){return this._imageDefId}set imageDefId(t){this._imageDefId=t}get imageFileName(){if(this._imageDefId){const t=this.database.dictionaries.imageDefs.getIdAt(this._imageDefId);if(t)return t.sourceFileName}return""}get geometricExtents(){const t=new Dt;return t.min.copy(this._position),t.max.set(this._position.x+this._width,this._position.y+this._height,0),t}subGetGripPoints(){return this.boundaryPath()}draw(t){const e=this.boundaryPath();return this._image?t.image(this._image,{boundary:e,roation:this._rotation}):t.lines(e,this.lineStyle)}boundaryPath(){const t=[];if(this.isClipped&&this._clipBoundary.length>3){const e=this._width,s=this._height,o=new _e;o.setFromPoints(this._clipBoundary);const h=new Mt;h.setX(this._position.x-o.min.x*e),h.setY(this._position.y-o.min.y*s),this._clipBoundary.forEach(c=>{const g=c.x*e+h.x,b=c.y*s+h.y;t.push(new X(g,b,this._position.z))})}else{if(t.push(this._position),t.push(this._position.clone().setX(this._position.x+this._width)),t.push(this._position.clone().set(this._position.x+this._width,this._position.y+this._height,this._position.z)),t.push(this._position.clone().setY(this._position.y+this._height)),this._rotation>0){Co.copy(t[1]);for(let e=1;e<4;e++)Os.copy(t[e]),Os.rotateAround(Co,this._rotation),t[e].setX(Os.x),t[e].setY(Os.y)}t.push(t[0])}return t}};Ua.typeName="RasterImage";let xs=Ua;const Co=new Mt,Os=new Mt,ja=class ja extends Be{constructor(){super(),this._basePoint=new X,this._unitDir=new $}get basePoint(){return this._basePoint}set basePoint(t){this._basePoint.copy(t)}get unitDir(){return this._unitDir}set unitDir(t){this._unitDir.copy(t)}get closed(){return!1}get geometricExtents(){const t=new Dt;return t.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),t.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),t}subGetGripPoints(){const t=new Array;return t.push(this.basePoint),t}draw(t){const e=[];return e.push(this.basePoint),e.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),t.lines(e,this.lineStyle)}};ja.typeName="Ray";let ii=ja;const Ga=class Ga extends je{constructor(){super(),this._centerPoint=new X,this._height=0,this._width=0,this._viewCenter=new X,this._viewHeight=0,this._number=-1}get number(){return this._number}set number(t){this._number=t}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get viewCenter(){return this._viewCenter}set viewCenter(t){this._viewCenter=t}get viewHeight(){return this._viewHeight}set viewHeight(t){this._viewHeight=t}get geometricExtents(){return new Dt}draw(t){if(this._number>1&&this.ownerId!=this.database.tables.blockTable.modelSpace.objectId){const e=this.toGiViewport();return t.group(this.createViewportRect(e,t))}}toGiViewport(){const t=new Pi;return t.id=this.objectId,t.groupId=this.ownerId,t.number=this.number,t.centerPoint=this.centerPoint,t.width=this.width,t.height=this.height,t.viewHeight=this.viewHeight,t.viewCenter=this.viewCenter,t}createViewportRect(t,e){const s=[];return s.push(e.lines([new X(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0),new X(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0)],this.lineStyle)),s.push(e.lines([new X(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0),new X(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0)],this.lineStyle)),s.push(e.lines([new X(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0),new X(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0)],this.lineStyle)),s.push(e.lines([new X(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0),new X(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0)],this.lineStyle)),s}};Ga.typeName="Viewport";let ai=Ga;const Wa=class Wa extends xs{draw(t){const e=this.boundaryPath(),s=new yi;return s.add(new Ss(e)),t.area(s,{color:0,solidFill:!0,patternAngle:0,patternLines:[]})}};Wa.typeName="Wipeout";let oi=Wa;const Ha=class Ha extends Be{constructor(){super(),this._basePoint=new X,this._unitDir=new $}get basePoint(){return this._basePoint}set basePoint(t){this._basePoint.copy(t)}get unitDir(){return this._unitDir}set unitDir(t){this._unitDir.copy(t)}get closed(){return!1}get geometricExtents(){const t=new Dt;return t.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),t.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),t}subGetGripPoints(){const t=new Array;return t.push(this.basePoint),t}draw(t){const e=[];return e.push(this._unitDir.clone().multiplyScalar(-1e6).add(this._basePoint)),e.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),t.lines(e,this.lineStyle)}};Ha.typeName="Xline";let li=Ha;var Nh=(a=>(a[a.AtLeast=1]="AtLeast",a[a.Exactly=2]="Exactly",a))(Nh||{});const qa=class qa extends je{constructor(){super(),this._dimBlockId=null,this._dimensionStyleName=null,this._dimensionText=null,this._textLineSpacingFactor=1,this._textLineSpacingStyle=1,this._textPosition=new X,this._textRotation=0}get dimBlockId(){return this._dimBlockId}set dimBlockId(t){this._dimBlockId=t}get dimensionStyleName(){return this._dimensionStyleName}set dimensionStyleName(t){this._dimensionStyleName=t}get dimensionStyle(){if(this._dimStyle==null){let t;this.dimensionStyleName&&(t=this.database.tables.dimStyleTable.getAt(this.dimensionStyleName)),t==null&&(t=new ws),this._dimStyle=t}return this._dimStyle}get dimensionText(){return this._dimensionText}set dimensionText(t){this._dimensionText=t}get measurement(){return this._measurement}set measurement(t){this._measurement=t}get textLineSpacingFactor(){return this._textLineSpacingFactor}set textLineSpacingFactor(t){this._textLineSpacingFactor=t}get textLineSpacingStyle(){return this._textLineSpacingStyle}set textLineSpacingStyle(t){this._textLineSpacingStyle=t}get textPosition(){return this._textPosition}set textPosition(t){this._textPosition.copy(t)}get textRotation(){return this._textRotation}set textRotation(t){this._textRotation=t}draw(t){if(this.dimBlockId){const e=this.database.tables.blockTable.getAt(this.dimBlockId);if(e)return Dr.instance.draw(t,e,this.rgbColor,!1)}return t.group([])}drawFirstArrow(t){const e=this.database.tables.blockTable.getAt(this.firstArrowType);if(e)return Dr.instance.draw(t,e,this.rgbColor,!1)}drawSecondArrow(t){const e=this.database.tables.blockTable.getAt(this.secondArrowType);if(e)return Dr.instance.draw(t,e,this.rgbColor,!1)}get arrowScaleFactor(){return this.dimensionStyle.dimasz}get firstArrowStyle(){return{type:this.firstArrowType,scale:this.arrowScaleFactor,appended:this.isAppendArrow,visible:this.dimensionStyle.dimse1==0}}get secondArrowStyle(){return{type:this.secondArrowType,scale:this.arrowScaleFactor,appended:this.isAppendArrow,visible:this.dimensionStyle.dimse2==0}}get isAppendArrow(){return!0}get firstArrowTypeBtrId(){const t=this.dimensionStyle;return t.dimsah==0?t.dimblk:t.dimblk1}get firstArrowType(){const t=this.firstArrowTypeBtrId;return this.getArrowName(t)}get secondArrowTypeBtrId(){const t=this.dimensionStyle;return t.dimsah==0?t.dimblk:t.dimblk2}get secondArrowType(){const t=this.secondArrowTypeBtrId;return this.getArrowName(t)}get arrowLineCount(){return 1}getLineArrowStyle(t){}findPointOnLine1(t,e,s){const o=new X().subVectors(e,t).normalize();return new X(e).addScaledVector(o,s)}findPointOnLine2(t,e,s){const o=t.x+s*Math.cos(e),h=t.y+s*Math.sin(e);return{x:o,y:h}}adjustExtensionLine(t){const e=this.dimensionStyle;t.extend(e.dimexe),t.extend(-e.dimexo,!0)}getArrowName(t){const e=this.database.tables.blockTable.getIdAt(t);return e?e.name.toUpperCase():_a.Closed}};qa.typeName="Dimension";let wr=qa;const Ya=class Ya extends wr{constructor(t,e,s,o,h=null,c=null){super(),this._centerPoint=new X().copy(t),this._xLine1Point=new X().copy(e),this._xLine2Point=new X().copy(s),this._arcPoint=new X().copy(o),this.dimensionText=h,this.dimensionStyleName=c}get arcPoint(){return this._arcPoint}set arcPoint(t){this._arcPoint.copy(t)}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get geometricExtents(){return new Dt}};Ya.typeName="3PointAngularDimension";let hi=Ya;const Ka=class Ka extends wr{constructor(t,e,s,o=null,h=null){super(),this._dimLinePoint=new X().copy(s),this._xLine1Point=new X().copy(t),this._xLine2Point=new X().copy(e),this._oblique=0,this._rotation=0,this.dimensionText=o,this.dimensionStyleName=h}get dimLinePoint(){return this._dimLinePoint}set dimLinePoint(t){this._dimLinePoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get oblique(){return this._oblique}set oblique(t){this._oblique=t}get geometricExtents(){return new Dt}get isAppendArrow(){return!1}calculateLines(){const t=[],e=this.createExtensionLine(this._xLine1Point),s=this.createExtensionLine(this._xLine2Point),o=this.findIntersectionPoint(e,this._dimLinePoint),h=this.findIntersectionPoint(s,this._dimLinePoint),c=new Br(o,h);return t.push(c),e.endPoint=o,this.adjustExtensionLine(e),t.push(e),s.endPoint=h,this.adjustExtensionLine(s),t.push(s),t}createExtensionLine(t){const e=this.rotation+Math.PI/2,s=this.findPointOnLine2(t,e,100);return new Br(t,{...s,z:t.z})}findIntersectionPoint(t,e){const s=t.startPoint,o=t.endPoint,h=new $().subVectors(o,s).normalize(),g=new $().subVectors(e,s).dot(h),b=new $().copy(h).multiplyScalar(g);return new $().addVectors(s,b)}};Ka.typeName="AlignedDimension";let ui=Ka;const Xa=class Xa extends wr{constructor(t,e,s,o,h=null,c=null){super(),this._arcPoint=new X().copy(o),this._xLine1Point=new X().copy(e),this._xLine2Point=new X().copy(s),this._centerPoint=new X().copy(t),this.dimensionText=h,this.dimensionStyleName=c}get arcPoint(){return this._arcPoint}set arcPoint(t){this._arcPoint.copy(t)}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get geometricExtents(){return new Dt}};Xa.typeName="ArcDimension";let ta=Xa;const $a=class $a extends wr{constructor(t,e,s=0,o=null,h=null){super(),this._chordPoint=new X().copy(t),this._farChordPoint=new X().copy(e),this._extArcStartAngle=0,this._extArcEndAngle=0,this._leaderLength=s,this.dimensionText=o,this.dimensionStyleName=h}get chordPoint(){return this._chordPoint}set chordPoint(t){this._chordPoint.copy(t)}get farChordPoint(){return this._farChordPoint}set farChordPoint(t){this._farChordPoint.copy(t)}get extArcStartAngle(){return this._extArcStartAngle}set extArcStartAngle(t){this._extArcStartAngle=t}get extArcEndAngle(){return this._extArcEndAngle}set extArcEndAngle(t){this._extArcEndAngle=t}get leaderLength(){return this._leaderLength}get geometricExtents(){return new Dt}drawLines(t,e){const s=[],o=e.length;return o==1?s.push(this.drawLine(t,e[0],{firstArrow:this.firstArrowStyle})):o==3?(this.sortLines(e),s.push(this.drawLine(t,e[0],{firstArrow:this.firstArrowStyle})),s.push(this.drawLine(t,e[1])),s.push(this.drawLine(t,e[2],{firstArrow:this.firstArrowStyle}))):e.forEach(h=>{s.push(this.drawLine(t,h))}),s}drawLine(t,e,s){if(s){const o=[e.startPoint,e.endPoint];return t.lines(o,{...this.lineStyle,arrows:s})}else return e.draw(t)}sortLines(t){const e=(s,o)=>s.x!==o.x?s.x-o.x:s.y!==o.y?s.y-o.y:s.z-o.z;t.sort((s,o)=>{const h=e(s.startPoint,o.startPoint);return h!==0?h:e(s.endPoint,o.endPoint)})}};$a.typeName="DiametricDimension";let ci=$a;const Za=class Za extends wr{constructor(t,e,s=null,o=null){super(),this._definingPoint=new X().copy(t),this._leaderEndPoint=new X().copy(e),this.dimensionText=s,this.dimensionStyleName=o}get definingPoint(){return this._definingPoint}set definingPoint(t){this._definingPoint.copy(t)}get leaderEndPoint(){return this._leaderEndPoint}set leaderEndPoint(t){this._leaderEndPoint.copy(t)}get geometricExtents(){return new Dt}get arrowLineCount(){return 0}};Za.typeName="OrdinateDimension";let di=Za;const Qa=class Qa extends wr{constructor(t,e,s,o=null,h=null){super(),this._center=new X().copy(t),this._chordPoint=new X().copy(e),this._leaderLength=s,this._extArcStartAngle=0,this._extArcEndAngle=0,this.dimensionText=o,this.dimensionStyleName=h}get center(){return this._center}set center(t){this._center.copy(t)}get chordPoint(){return this._chordPoint}set chordPoint(t){this._chordPoint.copy(t)}get extArcStartAngle(){return this._extArcStartAngle}set extArcStartAngle(t){this._extArcStartAngle=t}get extArcEndAngle(){return this._extArcEndAngle}set extArcEndAngle(t){this._extArcEndAngle=t}get leaderLength(){return this._leaderLength}set leaderLenght(t){this._leaderLength=t}get geometricExtents(){return new Dt}getLineArrowStyle(t){return{secondArrow:this.secondArrowStyle}}};Qa.typeName="RadialDimension";let mi=Qa;class No{convert(t){const e=this.createEntity(t);return e&&this.processCommonAttrs(t,e),e}createEntity(t){return t.type=="ARC"?this.convertArc(t):t.type=="CIRCLE"?this.convertCirle(t):t.type=="DIMENSION"?this.convertDimension(t):t.type=="ELLIPSE"?this.convertEllipse(t):t.type=="HATCH"?this.convertHatch(t):t.type=="IMAGE"?this.convertImage(t):t.type=="LEADER"?this.convertLeader(t):t.type=="LINE"?this.convertLine(t):t.type=="MTEXT"?this.convertMText(t):t.type=="POLYLINE"||t.type=="LWPOLYLINE"?this.convertPolyline(t):t.type=="POINT"?this.convertPoint(t):t.type=="RAY"?this.convertRay(t):t.type=="SPLINE"?this.convertSpline(t):t.type=="ACAD_TABLE"?this.convertTable(t):t.type=="TEXT"?this.convertText(t):t.type=="SOLID"?this.convertSolid(t):t.type=="VIEWPORT"?this.convertViewport(t):t.type=="WIPEOUT"?this.convertWipeout(t):t.type=="XLINE"?this.convertXline(t):t.type=="INSERT"?this.convertBlockReference(t):null}convertArc(t){return new Ks(t.center,t.radius,St.degToRad(t.startAngle),St.degToRad(t.endAngle))}convertCirle(t){return new Xs(t.center,t.radius)}convertEllipse(t){const e=new $(t.majorAxisEndPoint),s=e.length();return new Ys(t.center,$.Z_AXIS,e,s,s*t.axisRatio,t.startAngle,t.endAngle)}convertLine(t){const e=t.startPoint,s=t.endPoint;return new Qs(new X(e.x,e.y,e.z||0),new X(s.x,s.y,s.z||0))}convertSpline(t){if(t.numberOfControlPoints>0&&t.numberOfKnots>0)return new bs(t.controlPoints,t.knots,t.weights,t.degree,!!(t.flag&1));if(t.numberOfFitPoints>0){const e=this.numberArrayToPointArray(t.fitPoints,t.numberOfFitPoints);if(e!=null)return new bs(e,"Uniform",t.degree,!!(t.flag&1))}return null}convertPoint(t){const e=new si;return e.position=t.position,e}convertSolid(t){const e=new ri;return t.points.forEach((s,o)=>e.setPointAt(o,s)),e.thickness=t.thickness,e}convertPolyline(t){const e=new ni;return e.closed=!!(t.flag&1),t.vertices.forEach((s,o)=>{e.addVertexAt(o,new Mt(s.x,s.y),s.bulge,s.startWidth,s.endWidth)}),e}convertHatch(t){var o;const e=new $s;return(o=t.definitionLines)==null||o.forEach(h=>{e.definitionLines.push({angle:h.angle,origin:h.base,delta:h.offset,dashPattern:h.numberOfDashLengths>0?h.dashLengths:[]})}),e.hatchStyle=t.hatchStyle,e.patternName=t.patternName,e.patternType=t.patternType,e.patternAngle=t.patternAngle==null?0:t.patternAngle,e.patternScale=t.patternScale==null?0:t.patternScale,t.boundaryPaths.forEach(h=>{if(h.boundaryPathTypeFlag&2){const g=h,b=new Ss;b.closed=g.isClosed,g.vertices.forEach((f,S)=>{b.addVertexAt(S,{x:f.x,y:f.y,bulge:f.bulge})}),e.add(b)}else{const g=h,b=new xh;g.edges.forEach(f=>{if(f.type==1){const S=f;b.add(new wi(S.start,S.end))}else if(f.type==2){const S=f;b.add(new kn(S.center,S.radius,St.degToRad(S.startAngle||0),St.degToRad(S.endAngle||0),!S.isCCW))}else if(f.type==3){const S=f;new Kt().subVectors(S.end,S.center);const k=Math.sqrt(Math.pow(S.end.x,2)+Math.pow(S.end.y,2)),M=k*S.lengthOfMinorAxis;let D=St.degToRad(S.startAngle||0),z=St.degToRad(S.endAngle||0);const U=Math.atan2(S.end.y,S.end.x);S.isCCW||(D=Math.PI*2-D,z=Math.PI*2-z),b.add(new bi({...S.center,z:0},k,M,D,z,!S.isCCW,U))}else if(f.type==4){const S=f;if(S.numberOfControlPoints>0&&S.numberOfKnots>0){const x=S.controlPoints.map(D=>({x:D.x,y:D.y,z:0}));let k=!0;const M=S.controlPoints.map(D=>(D.weight==null&&(k=!1),D.weight||1));b.add(new Fr(x,S.knots,k?M:void 0))}else if(S.numberOfFitData>0){const x=S.fitDatum.map(k=>({x:k.x,y:k.y,z:0}));b.add(new Fr(x,"Uniform"))}}}),e.add(b)}}),e}convertTable(t){const e=new ti(t.name,t.rowCount,t.columnCount);return e.attachmentPoint=t.attachmentPoint,e.position.copy(t.startPoint),t.columnWidthArr.forEach((s,o)=>e.setColumnWidth(o,s)),t.rowHeightArr.forEach((s,o)=>e.setRowHeight(o,s)),t.cells.forEach((s,o)=>{e.setCell(o,s)}),e}convertText(t){const e=new ei;return e.textString=t.text,e.styleName=t.styleName,e.height=t.textHeight,e.position.copy(t.startPoint),e.rotation=St.degToRad(t.rotation||0),e.oblique=t.obliqueAngle??0,e.thickness=t.thickness,e.horizontalMode=t.halign,e.verticalMode=t.valign,e.widthFactor=t.xScale??1,e}convertMText(t){const e=new Js;return e.contents=t.text.join(""),t.styleName!=null&&(e.styleName=t.styleName),e.height=t.height,e.width=t.width,e.rotation=St.degToRad(t.rotation||0),e.location=t.insertionPoint,e.attachmentPoint=t.attachmentPoint,t.direction&&(e.direction=new $(t.direction)),e.drawingDirection=t.drawingDirection,e}convertLeader(t){const e=new Zs;return t.vertices.forEach(s=>{e.appendVertex(s)}),e.hasArrowHead=t.isArrowheadEnabled,e.hasHookLine=t.isHooklineExists,e.isSplined=t.isSpline,e.dimensionStyle=t.styleName,e.annoType=t.leaderCreationFlag,e}convertDimension(t){if(t.subclassMarker=="AcDbAlignedDimension"||t.subclassMarker=="AcDbRotatedDimension"){const e=t,s=new ui(e.subDefinitionPoint1,e.subDefinitionPoint2,e.definitionPoint);return s.rotation=St.degToRad(e.rotationAngle||0),this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDb3PointAngularDimension"){const e=t,s=new hi(e.centerPoint,e.subDefinitionPoint1,e.subDefinitionPoint2,e.definitionPoint);return this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDbOrdinateDimension"){const e=t,s=new di(e.subDefinitionPoint1,e.subDefinitionPoint2);return this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDbRadialDimension"){const e=t,s=new mi(e.definitionPoint,e.centerPoint,e.leaderLength);return this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDbDiametricDimension"){const e=t,s=new ci(e.definitionPoint,e.centerPoint,e.leaderLength);return this.processDimensionCommonAttrs(t,s),s}return null}processImage(t,e){e.position.copy(t.position),e.brightness=t.brightness,e.contrast=t.contrast,e.fade=t.fade,e.imageDefId=t.imageDefHandle,e.isClipped=(t.flags|4)>0,e.isImageShown=(t.flags|3)>0,e.isImageTransparent=(t.flags|8)>0,t.clippingBoundaryPath.forEach(s=>{e.clipBoundary.push(new Mt(s))}),e.clipBoundaryType=t.clippingBoundaryType,e.width=Math.sqrt(t.uPixel.x**2+t.uPixel.y**2+t.uPixel.z**2)*t.imageSize.x,e.height=Math.sqrt(t.vPixel.x**2+t.vPixel.y**2+t.vPixel.z**2)*t.imageSize.y,e.rotation=Math.atan2(t.uPixel.y,t.uPixel.x)}convertImage(t){const e=new xs;return this.processImage(t,e),e}convertWipeout(t){const e=new oi;return this.processImage(t,e),e}convertViewport(t){const e=new ai;return e.number=t.viewportId,e.centerPoint.copy(t.viewportCenter),e.height=t.height,e.width=t.width,e.viewCenter.copy(t.displayCenter),e.viewHeight=t.viewHeight,e}convertRay(t){const e=new ii;return e.basePoint.copy(t.firstPoint),e.unitDir.copy(t.unitDirection),e}convertXline(t){const e=new li;return e.basePoint.copy(t.firstPoint),e.unitDir.copy(t.unitDirection),e}convertBlockReference(t){const e=new ys(t.name);return t.insertionPoint&&e.position.copy(t.insertionPoint),e.scaleFactors.x=t.xScale||1,e.scaleFactors.y=t.yScale||1,e.scaleFactors.z=t.zScale||1,e.rotation=t.rotation!=null?St.degToRad(t.rotation):0,e.normal.copy(t.extrusionDirection??{x:0,y:0,z:1}),e}processDimensionCommonAttrs(t,e){e.dimBlockId=t.name,e.textPosition.copy(t.textPoint),e.textRotation=t.textRotation||0,t.textLineSpacingFactor&&(e.textLineSpacingFactor=t.textLineSpacingFactor),t.textLineSpacingStyle&&(e.textLineSpacingStyle=t.textLineSpacingStyle),e.dimensionStyleName=t.styleName,e.dimensionText=t.text||"",e.measurement=t.measurement}processCommonAttrs(t,e){e.layer=t.layer,e.objectId=t.handle,e.ownerId=t.ownerBlockRecordSoftId||"",t.lineType!=null&&(e.lineType=t.lineType),t.lineweight!=null&&(e.lineWeight=t.lineweight),t.lineTypeScale!=null&&(e.linetypeScale=t.lineTypeScale),t.color!=null&&(e.color.color=t.color),t.colorIndex!=null&&(e.color.colorIndex=t.colorIndex),t.colorName!=null&&(e.color.colorName=t.colorName),t.isVisible!=null&&(e.visibility=t.isVisible),t.transparency!=null&&(e.transparency=t.transparency)}numberArrayToPointArray(t,e){const s=t.length;let o=0;if(s/2==e?o=2:s/3==e&&(o=3),o==0)return;const h=[];for(let c=0,g=s/o;c<g;++c)h.push({x:t[c*o],y:t[c*o+1],z:o==3?t[c*o+2]:0});return h}}class xa extends Vr{constructor(){super(),this._tabOrder=-1,this._tabSelected=!1,this._blockTableRecordId="",this._layoutName="",this._limits=new _e,this._extents=new Dt}get layoutName(){return this._layoutName}set layoutName(t){this._layoutName=t.length>256?t.slice(0,256):t}get tabOrder(){return this._tabOrder}set tabOrder(t){this._tabOrder=t}get tabSelected(){return this._tabSelected}set tabSelected(t){this._tabSelected=t}get blockTableRecordId(){return this._blockTableRecordId}set blockTableRecordId(t){this._blockTableRecordId=t}get limits(){return this._limits}set limits(t){this._limits.copy(t)}get extents(){return this._extents}set extents(t){this._extents.copy(t)}}class wa extends Vr{constructor(t){super(),this.database=t,this._recordsByName=new Map,this._recordsById=new Map}get numEntries(){return this._recordsByName.size}setAt(t,e){e.database=this.database,this._recordsByName.set(t,e),this._recordsById.set(e.objectId,e),this.database.events.dictObjetSet.dispatch({database:this.database,object:e,key:t})}remove(t){const e=this.getAt(t);return e?(this._recordsByName.delete(t.toUpperCase()),this._recordsById.delete(this.objectId),this.database.events.dictObjectErased.dispatch({database:this.database,object:e,key:t}),!0):!1}removeId(t){const e=this.getIdAt(t);return e?(this._recordsById.delete(this.objectId),this._recordsByName.forEach((s,o)=>{s===e&&(this._recordsByName.delete(o),this.database.events.dictObjectErased.dispatch({database:this.database,object:e,key:o}))}),!0):!1}removeAll(){this._recordsByName.forEach((t,e)=>{this.database.events.dictObjectErased.dispatch({database:this.database,object:t,key:e})}),this._recordsByName.clear(),this._recordsById.clear()}has(t){return this._recordsByName.has(t.toUpperCase())}hasId(t){return this._recordsById.has(t)}getAt(t){return this._recordsByName.get(t)}getIdAt(t){return this._recordsById.get(t)}newIterator(){return new _i(this._recordsByName)}}class Lh extends wa{getBtrIdAt(t){for(const[e,s]of this._recordsByName)if(s.blockTableRecordId==t)return s}get maxTabOrder(){let t=-1;return this._recordsByName.forEach(e=>{e.tabOrder>t&&(t=e.tabOrder)}),t}}class Oh extends Vr{constructor(){super(),this._sourceFileName=""}get sourceFileName(){return this._sourceFileName}set sourceFileName(t){this._sourceFileName=t}}class od{convertLayout(t,e){var o;const s=new xa;return s.layoutName=t.layoutName,s.tabOrder=t.tabOrder,(o=e.tables.BLOCK_RECORD)==null||o.entries.some(h=>h.layoutObjects===t.handle?(s.blockTableRecordId=h.handle,!0):!1),s.limits.min.copy(t.minLimit),s.limits.max.copy(t.maxLimit),s.extents.min.copy(t.minExtent),s.extents.max.copy(t.maxExtent),this.processCommonAttrs(t,s),s}convertImageDef(t){const e=new Oh;return e.sourceFileName=t.fileName,this.processCommonAttrs(t,e),e}processCommonAttrs(t,e){e.objectId=t.handle,e.ownerId=t.ownerObjectId}}class zh{constructor(t){this.taskId=0,this.workers=new Map,this.pendingTasks=new Map,this.config={workerUrl:t.workerUrl,timeout:t.timeout??3e4,maxConcurrentWorkers:t.maxConcurrentWorkers??4}}async execute(t,e){const s=Date.now(),o=this.generateTaskId();try{return await this.executeInWorker(o,t,e||this.config.workerUrl)}catch(h){const c=Date.now()-s;return{success:!1,error:h instanceof Error?h.message:String(h),duration:c}}}async executeInWorker(t,e,s){const o=Date.now();return new Promise((h,c)=>{const g=this.getAvailableWorker(s),b=setTimeout(()=>{this.cleanupTask(t),this.releaseWorker(g),c(new Error(`Worker operation timed out after ${this.config.timeout}ms`))},this.config.timeout);this.pendingTasks.set(t,{resolve:x=>{clearTimeout(b),this.releaseWorker(g),h(x)},reject:x=>{clearTimeout(b),this.releaseWorker(g),c(x)},timeout:b});const f=x=>{const{id:k,success:M,data:D,error:z}=x.data;if(k!==t)return;this.cleanupTask(t);const U=Date.now()-o;h(M?{success:!0,data:D,duration:U}:{success:!1,error:z,duration:U})},S=x=>{this.cleanupTask(t),c(new Error(`Worker error: ${x.message}`))};g.addEventListener("message",f),g.addEventListener("error",S),g.postMessage({id:t,input:e})})}cleanupTask(t){const e=this.pendingTasks.get(t);e&&(clearTimeout(e.timeout),this.pendingTasks.delete(t))}generateTaskId(){return`task_${++this.taskId}_${Date.now()}`}detectWorkerSupport(){return typeof Worker<"u"}getAvailableWorker(t){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(t,{type:"module"}),o=this.generateWorkerId(),h={worker:s,isBusy:!0,id:o,createdAt:new Date};return this.workers.set(o,h),s}const e=Array.from(this.workers.values()).sort((s,o)=>s.createdAt.getTime()-o.createdAt.getTime())[0];return e.isBusy=!0,e.worker}releaseWorker(t){for(const[e,s]of this.workers)if(s.worker===t){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(t=>t.isBusy).length,pendingTasks:this.pendingTasks.size,config:this.config}}destroy(){for(const[t,e]of this.pendingTasks)clearTimeout(e.timeout),e.reject(new Error("Framework destroyed"));this.pendingTasks.clear();for(const[t,e]of this.workers)e.worker.terminate();this.workers.clear()}}class Dh{constructor(t){this.framework=new zh(t)}async execute(t,e){return this.framework.execute(t,e)}getStats(){return this.framework.getStats()}destroy(){this.framework.destroy()}}function Rh(a){return new Dh(a)}class ld{constructor(){this.setupMessageHandler()}setupMessageHandler(){self.onmessage=async t=>{const{id:e,input:s}=t.data;try{const o=await this.executeTask(s);this.sendResponse(e,!0,o)}catch(o){this.sendResponse(e,!1,void 0,o instanceof Error?o.message:String(o))}}}sendResponse(t,e,s,o){const h={id:t,success:e,data:s,error:o};self.postMessage(h)}}class Bh extends jl{constructor(t={}){super(t),t.parserWorkerUrl||(t.parserWorkerUrl="/assets/dxf-parser-worker.js")}async parse(t){if(this.config.useWorker&&this.config.parserWorkerUrl){const e=Rh({workerUrl:this.config.parserWorkerUrl,maxConcurrentWorkers:1}),s=await e.execute(t);return e.destroy(),s.data}else return new Yc().parseSync(t)}getFonts(t){var h;const e=new Map,s=c=>{if(c){const g=c.lastIndexOf(".");return g>=0?c.substring(0,g).toLowerCase():c.toLowerCase()}};(h=t.tables.STYLE)==null||h.entries.forEach(c=>{const g=[];let b=s(c.font);b&&g.push(b),b=s(c.bigFont),b&&g.push(b),e.set(c.name,g)});const o=new Set;return this.getFontsInBlock(t.entities,t.blocks,e,o),Array.from(o)}getFontsInBlock(t,e,s,o){const h=/\\f(.*?)\|/g;t.forEach(c=>{if(c.type=="MTEXT"){const g=c;[...g.text.join("").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(c.type=="TEXT"){const g=c,b=s.get(g.styleName);b==null||b.forEach(f=>o.add(f))}else if(c.type=="INSERT"){const b=e[c.name];b&&b.entities&&this.getFontsInBlock(b.entities,e,s,o)}})}async processEntities(t,e,s,o,h){const c=new No;let g=t.entities;const b=g.length,f=new Ho(b,100-o.value,s);this.config.convertByEntityType&&(g=this.groupAndFlattenByType(g));const S=e.tables.blockTable.modelSpace;await f.processChunk(async(x,k)=>{let M=[],D=x<k?g[x].type:"";for(let z=x;z<k;z++){const U=g[z],B=c.convert(U);B&&(this.config.convertByEntityType&&U.type!==D&&(S.appendEntity(M),M=[],D=U.type),M.push(B))}if(S.appendEntity(M),h){let z=o.value+k/b*(100-o.value);z>100&&(z=100),await h(z,"ENTITY","IN-PROGRESS")}})}async processEntitiesInBlock(t,e){const s=new No,o=t.length,h=[];for(let c=0;c<o;c++){const g=t[c],b=s.convert(g);b&&h.push(b)}e.appendEntity(h)}processBlocks(t,e){const s=t.blocks;for(const[o,h]of Object.entries(s)){let c=e.tables.blockTable.getAt(h.name);c||(c=new De,c.objectId=h.handle,c.name=o,c.origin.copy(h.position),e.tables.blockTable.add(c)),h.entities&&this.processEntitiesInBlock(h.entities,c)}}processHeader(t,e){const s=t.header;e.cecolor.colorIndex=s.$CECOLOR||256,e.angBase=s.$ANGBASE||0,e.angDir=s.$ANGDIR||0,e.aunits=s.$AUNITS,e.extmax=s.$EXTMAX,e.extmin=s.$EXTMIN,e.insunits=s.$INSUNITS,e.pdmode=s.$PDMODE||0,e.pdsize=s.$PDSIZE||0}processBlockTables(t,e){var o;const s=(o=t.tables.BLOCK_RECORD)==null?void 0:o.entries;s&&s.length>0&&(e.tables.blockTable.removeAll(),s.forEach(h=>{const c=new De;c.objectId=h.handle,c.name=h.name,c.layoutId=h.layoutObjects,e.tables.blockTable.add(c)}))}processObjects(t,e){const s=t.objects.byName,o=new od;if("LAYOUT"in s){const h=e.dictionaries.layouts;s.LAYOUT.forEach(c=>{const g=o.convertLayout(c,t);h.setAt(g.layoutName,g)})}if("IMAGEDEF"in s){const h=e.dictionaries.imageDefs;s.IMAGEDEF.forEach(c=>{const g=o.convertImageDef(c);h.setAt(g.objectId,g)})}}processViewports(t,e){var o,h;const s=(h=(o=t.tables)==null?void 0:o.VPORT)==null?void 0:h.entries;s&&s.length>0&&s.forEach(c=>{const g=new Qh;this.processCommonTableEntryAttrs(c,g),c.circleSides&&(g.circleSides=c.circleSides),g.standardFlag=c.standardFlag,g.center.copy(c.center),g.lowerLeftCorner.copy(c.lowerLeftCorner),g.upperRightCorner.copy(c.upperRightCorner),c.snapBasePoint&&g.snapBase.copy(c.snapBasePoint),c.snapRotationAngle&&(g.snapAngle=c.snapRotationAngle),c.snapSpacing&&g.snapIncrements.copy(c.snapSpacing),c.majorGridLines&&(g.gridMajor=c.majorGridLines),c.gridSpacing&&g.gridIncrements.copy(c.gridSpacing),c.backgroundObjectId&&(g.backgroundObjectId=c.backgroundObjectId),g.gsView.center.copy(c.center),g.gsView.viewDirectionFromTarget.copy(c.viewDirectionFromTarget),g.gsView.viewTarget.copy(c.viewTarget),c.lensLength&&(g.gsView.lensLength=c.lensLength),c.frontClippingPlane&&(g.gsView.frontClippingPlane=c.frontClippingPlane),c.backClippingPlane&&(g.gsView.backClippingPlane=c.backClippingPlane),c.viewHeight&&(g.gsView.viewHeight=c.viewHeight),c.viewTwistAngle&&(g.gsView.viewTwistAngle=c.viewTwistAngle),c.frozenLayers&&(g.gsView.frozenLayers=c.frozenLayers),c.styleSheet&&(g.gsView.styleSheet=c.styleSheet),c.renderMode&&(g.gsView.renderMode=c.renderMode),c.viewMode&&(g.gsView.viewMode=c.viewMode),c.ucsIconSetting&&(g.gsView.ucsIconSetting=c.ucsIconSetting),c.ucsOrigin&&g.gsView.ucsOrigin.copy(c.ucsOrigin),c.ucsXAxis&&g.gsView.ucsXAxis.copy(c.ucsXAxis),c.ucsYAxis&&g.gsView.ucsYAxis.copy(c.ucsYAxis),c.orthographicType&&(g.gsView.orthographicType=c.orthographicType),c.shadePlotSetting&&(g.gsView.shadePlotSetting=c.shadePlotSetting),c.shadePlotObjectId&&(g.gsView.shadePlotObjectId=c.shadePlotObjectId),c.visualStyleObjectId&&(g.gsView.visualStyleObjectId=c.visualStyleObjectId),c.isDefaultLightingOn&&(g.gsView.isDefaultLightingOn=c.isDefaultLightingOn),c.defaultLightingType&&(g.gsView.defaultLightingType=c.defaultLightingType),c.brightness&&(g.gsView.brightness=c.brightness),c.contrast&&(g.gsView.contrast=c.contrast),c.ambientColor&&(g.gsView.ambientColor=c.ambientColor),e.tables.viewportTable.add(g)})}processLayers(t,e){var o,h;const s=(h=(o=t.tables)==null?void 0:o.LAYER)==null?void 0:h.entries;s&&s.length>0&&s.forEach(c=>{const g=new an;g.colorIndex=c.colorIndex;const b=new Aa({name:c.name,standardFlags:c.standardFlag,linetype:c.lineType,lineWeight:c.lineweight,isOff:c.colorIndex<0,color:g,isPlottable:c.isPlotting});this.processCommonTableEntryAttrs(c,b),e.tables.layerTable.add(b)})}processLineTypes(t,e){var o,h;const s=(h=(o=t.tables)==null?void 0:o.LTYPE)==null?void 0:h.entries;s&&s.length>0&&s.forEach(c=>{const g=new $h(c);this.processCommonTableEntryAttrs(c,g),g.name=c.name,e.tables.linetypeTable.add(g)})}processTextStyles(t,e){var o;const s=(o=t.tables.STYLE)==null?void 0:o.entries;s&&s.length>0&&s.forEach(h=>{const c=new Zh(h);this.processCommonTableEntryAttrs(h,c),e.tables.textStyleTable.add(c)})}processDimStyles(t,e){var o;const s=(o=t.tables.DIMSTYLE)==null?void 0:o.entries;s&&s.length>0&&s.forEach(h=>{const c={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 ws(c);this.processCommonTableEntryAttrs(h,g),e.tables.dimStyleTable.add(g)})}processCommonTableEntryAttrs(t,e){e.name=t.name,e.objectId=t.handle,e.ownerId=t.ownerObjectId}groupAndFlattenByType(t){const e={},s=[];for(const o of t)e[o.type]||(e[o.type]=[],s.push(o.type)),e[o.type].push(o);return s.flatMap(o=>e[o])}}var vs=(a=>(a.DXF="dxf",a.DWG="dwg",a))(vs||{});class ir{constructor(){this.events={registered:new ie,unregistered:new ie},this._converters=new Map,this.register("dxf",new Bh)}static createInstance(){return ir._instance==null&&(ir._instance=new ir),this._instance}static get instance(){return ir._instance||(ir._instance=new ir),ir._instance}get fileTypes(){return this._converters.keys()}register(t,e){this._converters.set(t,e),this.events.registered.dispatch({fileType:t,converter:e})}get(t){return this._converters.get(t)}unregister(t){const e=this._converters.get(t);e&&(this._converters.delete(t),this.events.unregistered.dispatch({fileType:t,converter:e}))}}class on extends Vr{constructor(t,e){t=t||{},Mn(t,{name:""}),super(t,e)}get name(){return this.getAttr("name")}set name(t){this.setAttr("name",t)}}const zr=class zr extends on{static isModelSapceName(t){return t.toLowerCase()==zr.MODEL_SPACE_NAME.toLowerCase()}static isPaperSapceName(t){return t.toLowerCase().startsWith(zr.PAPER_SPACE_NAME_PREFIX.toLowerCase())}constructor(){super(),this._origin=new X,this._layoutId="",this._entities=new Map}get isModelSapce(){return zr.isModelSapceName(this.name)}get isPaperSapce(){return zr.isPaperSapceName(this.name)}get origin(){return this._origin}set origin(t){this._origin.copy(t)}get layoutId(){return this._layoutId}set layoutId(t){this._layoutId=t}appendEntity(t){if(Array.isArray(t))for(let e=0;e<t.length;++e){const s=t[e];s.database=this.database,s.ownerId=this.objectId,this._entities.set(s.objectId,s)}else t.database=this.database,t.ownerId=this.objectId,this._entities.set(t.objectId,t);(this.isModelSapce||this.isPaperSapce)&&this.database.events.entityAppended.dispatch({database:this.database,entity:t})}newIterator(){return new _i(this._entities)}getIdAt(t){return this._entities.get(t)}};zr.MODEL_SPACE_NAME="*MODEL_SPACE",zr.PAPER_SPACE_NAME_PREFIX="*PAPER_SPACE";let De=zr;class ln extends Vr{constructor(t){super(),this.database=t,this._recordsByName=new Map,this._recordsById=new Map}add(t){t.database=this.database;const e=this.normalizeName(t.name);this._recordsByName.set(e,t),this._recordsById.set(t.objectId,t)}remove(t){const e=this.normalizeName(t),s=this._recordsByName.get(e);return s?(this._recordsById.delete(s.objectId),this._recordsByName.delete(t),!0):!1}removeId(t){const e=this._recordsById.get(t);return e?(this._recordsByName.delete(e.name),this._recordsById.delete(t),!0):!1}removeAll(){this._recordsByName.clear(),this._recordsById.clear()}has(t){const e=this.normalizeName(t);return this._recordsByName.has(e)}hasId(t){return this._recordsById.has(t)}getAt(t){const e=this.normalizeName(t);return this._recordsByName.get(e)}getIdAt(t){return this._recordsById.get(t)}getOwnerIdAt(t){return this._recordsById.get(t)}newIterator(){return new _i(this._recordsByName)}normalizeName(t){return t}}class Fh extends ln{constructor(t){super(t)}get modelSpace(){let t=this.getAt(De.MODEL_SPACE_NAME);return t||(t=new De,t.name=De.MODEL_SPACE_NAME,this.add(t)),t}normalizeName(t){let e=t;if(De.isModelSapceName(t))e=De.MODEL_SPACE_NAME;else if(De.isPaperSapceName(t)){const s=De.PAPER_SPACE_NAME_PREFIX,o=t.substring(s.length);e=s+o}return e}}class Vh extends ln{constructor(t){super(t)}}class Aa extends on{constructor(t,e){t=t||{},Mn(t,{color:new an,description:"",standardFlags:0,isHidden:!1,isInUse:!0,isOff:!1,isPlottable:!0,transparency:0,linetype:"",lineWeight:1,materialId:-1}),super(t,e),this.attrs.events.attrChanged.addEventListener(s=>{this.database.events.layerModified.dispatch({database:this.database,layer:this,changes:s.object.changedAttributes()})})}get color(){return this.getAttr("color")}set color(t){this.setAttr("color",t.clone())}get description(){return this.getAttr("description")}set description(t){this.setAttr("description",t)}get standardFlags(){return this.getAttr("standardFlags")}set standardFlags(t){this.setAttr("standardFlags",t)}get isFrozen(){return(this.standardFlags&1)==1}set isFrozen(t){const e=t?1:0;this.standardFlags=this.standardFlags|e}get isHidden(){return this.getAttr("isHidden")}set isHidden(t){this.setAttr("isHidden",t)}get isInUse(){return this.getAttr("isInUse")}set isInUse(t){this.setAttr("isInUse",t)}get isLocked(){return(this.standardFlags&4)==4}set isLocked(t){const e=t?4:0;this.standardFlags=this.standardFlags|e}get isOff(){return this.getAttr("isOff")}set isOff(t){this.setAttr("isOff",t)}get isPlottable(){return this.getAttr("isPlottable")}set isPlottable(t){this.setAttr("isPlottable",t)}get transparency(){return this.getAttr("transparency")}set transparency(t){this.setAttr("transparency",t)}get linetype(){return this.getAttr("linetype")}set linetype(t){this.setAttr("linetype",t)}get lineWeight(){return this.getAttr("lineWeight")}set lineWeight(t){this.setAttr("lineWeight",t)}get materialId(){return this.getAttr("materialId")}set materialId(t){this.setAttr("materialId",t)}}class Uh extends ln{constructor(t){super(t);const e=new an;e.color=16777215;const s=new Aa({name:"0",standardFlags:0,linetype:Hs,lineWeight:1,isOff:!1,color:e,isPlottable:!0});this.add(s)}add(t){super.add(t),this.database.events.layerAppended.dispatch({database:this.database,layer:t})}}class jh extends ln{constructor(t){super(t)}}class Gh extends ln{constructor(t){super(t)}get fonts(){const t=new Set,e=o=>{if(o){const h=o.lastIndexOf(".");if(h>=0){const c=o.substring(0,h).toLowerCase();t.add(c)}else t.add(o.toLowerCase())}},s=this.newIterator();for(const o of s)e(o.fileName),e(o.bigFontFileName);return Array.from(t)}}class Wh extends ln{constructor(t){super(t)}}class hd extends Vr{constructor(){super(),this.events={dictObjetSet:new ie,dictObjectErased:new ie,entityAppended:new ie,entityModified:new ie,layerAppended:new ie,layerModified:new ie,layerErased:new ie,openProgress:new ie,headerSysVarChanged:new ie},this._angBase=0,this._angDir=0,this._aunits=ia.DecimalDegrees,this._celtscale=1,this._cecolor=new an,this._extents=new Dt,this._insunits=aa.Millimeters,this._ltscale=1,this._pdmode=0,this._pdsize=0,this._tables={blockTable:new Fh(this),dimStyleTable:new Vh(this),linetypeTable:new jh(this),textStyleTable:new Gh(this),layerTable:new Uh(this),viewportTable:new Wh(this)},this._dictionaries={layouts:new Lh(this),imageDefs:new wa(this)}}get tables(){return this._tables}get dictionaries(){return this._dictionaries}get currentSpaceId(){return this._currentSpace||(this._currentSpace=this._tables.blockTable.modelSpace),this._currentSpace.objectId}set currentSpaceId(t){const e=this.tables.blockTable.getIdAt(t);if(e==null)throw new Error(`[AcDbDatabase] The specified block table record id '${t}' doesn't exist in the drawing database!`);this._currentSpace=e}get aunits(){return this._aunits}set aunits(t){this._aunits=t||0,this.triggerHeaderSysVarChangedEvent("aunits")}get insunits(){return this._insunits}set insunits(t){this._insunits=t||4,this.triggerHeaderSysVarChangedEvent("insunits")}get ltscale(){return this._ltscale}set ltscale(t){this._ltscale=t||1,this.triggerHeaderSysVarChangedEvent("ltscale")}get cecolor(){return this._cecolor}set cecolor(t){this._cecolor=t||0,this.triggerHeaderSysVarChangedEvent("cecolor")}get celtscale(){return this._celtscale}set celtscale(t){this._celtscale=t||1,this.triggerHeaderSysVarChangedEvent("celtscale")}get angBase(){return this._angBase}set angBase(t){this._angBase=t||0,this.triggerHeaderSysVarChangedEvent("angbase")}get angDir(){return this._angDir}set angDir(t){this._angDir=t||0,this.triggerHeaderSysVarChangedEvent("angdir")}get extmax(){return this._extents.max}set extmax(t){this._extents.expandByPoint(t),this.triggerHeaderSysVarChangedEvent("extmax")}get extmin(){return this._extents.min}set extmin(t){this._extents.expandByPoint(t),this.triggerHeaderSysVarChangedEvent("extmin")}get pdmode(){return this._pdmode}set pdmode(t){this._pdmode=t||0,this.triggerHeaderSysVarChangedEvent("pdmode")}get pdsize(){return this._pdsize}set pdsize(t){this._pdsize=t||0,this.triggerHeaderSysVarChangedEvent("pdsize")}async read(t,e,s=vs.DXF){const o=ir.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(t,this,e&&e.minimumChunkSize||10,async(h,c,g,b)=>{if(this.events.openProgress.dispatch({database:this,percentage:h,stage:"CONVERSION",subStage:c,stageStatus:g}),e&&e.fontLoader&&c=="FONT"&&g=="END"){const f=b||this.tables.textStyleTable.fonts;await e.fontLoader.load(f)}})}async openUri(t,e){var k;this.events.openProgress.dispatch({database:this,percentage:0,stage:"FETCH_FILE",stageStatus:"START"});const s=await fetch(t);if(!s.ok)throw this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",stageStatus:"ERROR"}),new Error(`Failed to fetch file '${t}' with HTTP status code '${s.status}'!`);const o=s.headers.get("content-length"),h=o?parseInt(o,10):null;let c=0;const g=(k=s.body)==null?void 0:k.getReader();if(!g)throw new Error("Failed to get response reader");const b=[];for(;;){const{done:M,value:D}=await g.read();if(M)break;if(b.push(D),c+=D.length,h!==null){const z=Math.round(c/h*100);this.events.openProgress.dispatch({database:this,percentage:z,stage:"FETCH_FILE",stageStatus:"IN-PROGRESS"})}}const f=new Uint8Array(c);let S=0;for(const M of b)f.set(M,S),S+=M.length;if(t.toLowerCase().split(".").pop()==="dwg")await this.read(f.buffer,e,vs.DWG);else{const M=new TextDecoder().decode(f);await this.read(M,e,vs.DXF)}this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",stageStatus:"END"})}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(t){this.events.headerSysVarChanged.dispatch({database:this,name:t})}}var Hh=(a=>(a[a.Center=0]="Center",a[a.Left=1]="Left",a[a.Right=2]="Right",a[a.OverFirst=3]="OverFirst",a[a.OverSecond=4]="OverSecond",a))(Hh||{}),qh=(a=>(a[a.Center=0]="Center",a[a.Above=1]="Above",a[a.Outside=2]="Outside",a[a.JIS=3]="JIS",a[a.Below=4]="Below",a))(qh||{}),Yh=(a=>(a[a.Feet=0]="Feet",a[a.None=1]="None",a[a.Inch=2]="Inch",a[a.FeetAndInch=3]="FeetAndInch",a[a.Leading=4]="Leading",a[a.Trailing=8]="Trailing",a[a.LeadingAndTrailing=12]="LeadingAndTrailing",a))(Yh||{}),Kh=(a=>(a[a.None=0]="None",a[a.Leading=1]="Leading",a[a.Trailing=2]="Trailing",a[a.LeadingAndTrailing=3]="LeadingAndTrailing",a))(Kh||{}),Xh=(a=>(a[a.Bottom=0]="Bottom",a[a.Middle=1]="Middle",a[a.Top=2]="Top",a))(Xh||{});const gi=class gi extends on{constructor(t,e){t=t||{},Mn(t,gi.DEFAULT_DIM_VALUES),super(t,e)}get dimpost(){return this.getAttr("dimpost")}set dimpost(t){this.setAttr("dimpost",t)}get dimapost(){return this.getAttr("dimapost")}set dimapost(t){this.setAttr("dimapost",t)}get dimscale(){return this.getAttr("dimscale")}set dimscale(t){this.setAttr("dimscale",t)}get dimasz(){return this.getAttr("dimasz")}set dimasz(t){this.setAttr("dimasz",t)}get dimexo(){return this.getAttr("dimexo")}set dimexo(t){this.setAttr("dimexo",t)}get dimdli(){return this.getAttr("dimdli")}set dimdli(t){this.setAttr("dimdli",t)}get dimexe(){return this.getAttr("dimexe")}set dimexe(t){this.setAttr("dimexe",t)}get dimrnd(){return this.getAttr("dimrnd")}set dimrnd(t){this.setAttr("dimrnd",t)}get dimdle(){return this.getAttr("dimdle")}set dimdle(t){this.setAttr("dimdle",t)}get dimtp(){return this.getAttr("dimtp")}set dimtp(t){this.setAttr("dimtp",t)}get dimtm(){return this.getAttr("dimtm")}set dimtm(t){this.setAttr("dimtm",t)}get dimtxt(){return this.getAttr("dimtxt")}set dimtxt(t){this.setAttr("dimtxt",t)}get dimcen(){return this.getAttr("dimcen")}set dimcen(t){this.setAttr("dimcen",t)}get dimtsz(){return this.getAttr("dimtsz")}set dimtsz(t){this.setAttr("dimtsz",t)}get dimaltf(){return this.getAttr("dimaltf")}set dimaltf(t){this.setAttr("dimaltf",t)}get dimlfac(){return this.getAttr("dimlfac")}set dimlfac(t){this.setAttr("dimlfac",t)}get dimtvp(){return this.getAttr("dimtvp")}set dimtvp(t){this.setAttr("dimtvp",t)}get dimtfac(){return this.getAttr("dimtfac")}set dimtfac(t){this.setAttr("dimtfac",t)}get dimgap(){return this.getAttr("dimgap")}set dimgap(t){this.setAttr("dimgap",t)}get dimaltrnd(){return this.getAttr("dimaltrnd")}set dimaltrnd(t){this.setAttr("dimaltrnd",t)}get dimtol(){return this.getAttr("dimtol")}set dimtol(t){this.setAttr("dimtol",t)}get dimlim(){return this.getAttr("dimlim")}set dimlim(t){this.setAttr("dimlim",t)}get dimtih(){return this.getAttr("dimtih")}set dimtih(t){this.setAttr("dimtih",t)}get dimtoh(){return this.getAttr("dimtoh")}set dimtoh(t){this.setAttr("dimtoh",t)}get dimse1(){return this.getAttr("dimse1")}set dimse1(t){this.setAttr("dimse1",t)}get dimse2(){return this.getAttr("dimse2")}set dimse2(t){this.setAttr("dimse2",t)}get dimtad(){return this.getAttr("dimtad")}set dimtad(t){this.setAttr("dimtad",t)}get dimzin(){return this.getAttr("dimzin")}set dimzin(t){this.setAttr("dimzin",t)}get dimazin(){return this.getAttr("dimazin")}set dimazin(t){this.setAttr("dimazin",t)}get dimalt(){return this.getAttr("dimalt")}set dimalt(t){this.setAttr("dimalt",t)}get dimaltd(){return this.getAttr("dimaltd")}set dimaltd(t){this.setAttr("dimaltd",t)}get dimtofl(){return this.getAttr("dimtofl")}set dimtofl(t){this.setAttr("dimtofl",t)}get dimsah(){return this.getAttr("dimsah")}set dimsah(t){this.setAttr("dimsah",t)}get dimtix(){return this.getAttr("dimtix")}set dimtix(t){this.setAttr("dimtix",t)}get dimsoxd(){return this.getAttr("dimsoxd")}set dimsoxd(t){this.setAttr("dimsoxd",t)}get dimclrd(){return this.getAttr("dimclrd")}set dimclrd(t){this.setAttr("dimclrd",t)}get dimclre(){return this.getAttr("dimclre")}set dimclre(t){this.setAttr("dimclre",t)}get dimclrt(){return this.getAttr("dimclrt")}set dimclrt(t){this.setAttr("dimclrt",t)}get dimadec(){return this.getAttr("dimadec")}set dimadec(t){this.setAttr("dimadec",t)}get dimunit(){return this.getAttr("dimunit")}set dimunit(t){this.setAttr("dimunit",t)}get dimdec(){return this.getAttr("dimdec")}set dimdec(t){this.setAttr("dimdec",t)}get dimtdec(){return this.getAttr("dimtdec")}set dimtdec(t){this.setAttr("dimtdec",t)}get dimaltu(){return this.getAttr("dimaltu")}set dimaltu(t){this.setAttr("dimaltu",t)}get dimalttd(){return this.getAttr("dimalttd")}set dimalttd(t){this.setAttr("dimalttd",t)}get dimaunit(){return this.getAttr("dimaunit")}set dimaunit(t){this.setAttr("dimaunit",t)}get dimfrac(){return this.getAttr("dimfrac")}set dimfrac(t){this.setAttr("dimfrac",t)}get dimlunit(){return this.getAttr("dimlunit")}set dimlunit(t){this.setAttr("dimlunit",t)}get dimdsep(){return this.getAttr("dimdsep")}set dimdsep(t){this.setAttr("dimdsep",t)}get dimtmove(){return this.getAttr("dimtmove")}set dimtmove(t){this.setAttr("dimtmove",t)}get dimjust(){return this.getAttr("dimjust")}set dimjust(t){this.setAttr("dimjust",t)}get dimsd1(){return this.getAttr("dimsd1")}set dimsd1(t){this.setAttr("dimsd1",t)}get dimsd2(){return this.getAttr("dimsd2")}set dimsd2(t){this.setAttr("dimsd2",t)}get dimtolj(){return this.getAttr("dimtolj")}set dimtolj(t){this.setAttr("dimtolj",t)}get dimtzin(){return this.getAttr("dimtzin")}set dimtzin(t){this.setAttr("dimtzin",t)}get dimaltz(){return this.getAttr("dimaltz")}set dimaltz(t){this.setAttr("dimaltz",t)}get dimalttz(){return this.getAttr("dimalttz")}set dimalttz(t){this.setAttr("dimalttz",t)}get dimfit(){return this.getAttr("dimfit")}set dimfit(t){this.setAttr("dimfit",t)}get dimupt(){return this.getAttr("dimupt")}set dimupt(t){this.setAttr("dimupt",t)}get dimatfit(){return this.getAttr("dimatfit")}set dimatfit(t){this.setAttr("dimatfit",t)}get dimtxsty(){return this.getAttr("dimtxsty")}set dimtxsty(t){this.setAttr("dimtxsty",t)}get dimldrblk(){return this.getAttr("dimldrblk")}set dimldrblk(t){this.setAttr("dimldrblk",t)}get dimblk(){return this.getAttr("dimblk")}set dimblk(t){this.setAttr("dimblk",t)}get dimblk1(){return this.getAttr("dimblk1")}set dimblk1(t){this.setAttr("dimblk1",t)}get dimblk2(){return this.getAttr("dimblk2")}set dimblk2(t){this.setAttr("dimblk2",t)}get dimlwd(){return this.getAttr("dimlwd")}set dimlwd(t){this.setAttr("dimlwd",t)}get dimlwe(){return this.getAttr("dimlwe")}set dimlwe(t){this.setAttr("dimlwe",t)}};gi.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 ws=gi;class $h extends on{constructor(t){super(),this.name=t.name,this._linetype=t}get numDashes(){return this._linetype.pattern?this._linetype.pattern.length:0}get patternLength(){return this._linetype.totalPatternLength}get comments(){return this._linetype.description}get linetype(){return this._linetype}dashLengthAt(t){if(t<0||t>=this.numDashes)throw new Error('Index must be greater than or equal to zero, but less than the value of property "numDashes".');return this._linetype.pattern[t].elementLength}}class Zh extends on{constructor(t){super(),this.name=t.name,this._textStyle=t,this._textStyle.font=this.getFileNameWithoutExtension(this._textStyle.font||this._textStyle.extendedFont||this.name),this._isVertical=!1}get obliquingAngle(){return this._textStyle.obliqueAngle}set obliquingAngle(t){this._textStyle.obliqueAngle=t}get priorSize(){return this._textStyle.lastHeight}set priorSize(t){this._textStyle.lastHeight=t}get textSize(){return this._textStyle.fixedTextHeight}set textSize(t){this._textStyle.fixedTextHeight=t}get xScale(){return this._textStyle.widthFactor}set xScale(t){this._textStyle.widthFactor=t}get isVertical(){return this._isVertical}set isVertical(t){this._isVertical=t}get fileName(){return this._textStyle.font}set fileName(t){this._textStyle.font=t}get bigFontFileName(){return this._textStyle.bigFont}set bigFontFileName(t){this._textStyle.bigFont=t}get textStyle(){return this._textStyle}getFileNameWithoutExtension(t){const e=t.split("/").pop();if(e){const s=e.lastIndexOf(".");return s===-1?e:e.substring(0,s)}return t}}const ud={center:new Mt,viewDirectionFromTarget:new X(0,0,1),viewTarget:new X(0,0,0),lensLength:500,frontClippingPlane:0,backClippingPlane:0,viewHeight:1e3,viewTwistAngle:0,frozenLayers:[],styleSheet:"",renderMode:va.OPTIMIZED_2D,viewMode:0,ucsIconSetting:0,ucsOrigin:new X(0,0,0),ucsXAxis:new X(1,0,0),ucsYAxis:new X(0,1,0),orthographicType:ya.TOP,shadePlotSetting:0,shadePlotObjectId:void 0,visualStyleObjectId:void 0,isDefaultLightingOn:!1,defaultLightingType:ba.ONE_DISTANT_LIGHT,brightness:0,contrast:0,ambientColor:void 0};class Qh extends on{constructor(){super(),this._circleSides=100,this._center=new Mt,this._lowerLeftCorner=new Mt(0,0),this._upperRightCorner=new Mt(1,1),this._snapBase=new Mt(0,0),this._snapAngle=0,this._snapSpacing=new Mt(0,0),this._standardFlag=0,this._gridSpacing=new Mt,this._gridMajor=10,this._gsView=ud}get circleSides(){return this._circleSides}set circleSides(t){this._circleSides=t}get center(){return this._center}get lowerLeftCorner(){return this._lowerLeftCorner}set lowerLeftCorner(t){this._lowerLeftCorner.copy(t)}get upperRightCorner(){return this._upperRightCorner}set upperRightCorner(t){this._upperRightCorner.copy(t)}get snapBase(){return this._snapBase}set snapBase(t){this._snapBase.copy(t)}get snapAngle(){return this._snapAngle}set snapAngle(t){this._snapAngle=t}get snapIncrements(){return this._snapSpacing}set snapIncrements(t){this._snapSpacing.copy(t)}get gridMajor(){return this._gridMajor}set gridMajor(t){this._gridMajor=t}get gridIncrements(){return this._gridSpacing}set gridIncrements(t){this._gridSpacing.copy(t)}get standardFlag(){return this._standardFlag}set standardFlag(t){this._standardFlag=t}get snapEnabled(){return!!(this._standardFlag&256)}get backgroundObjectId(){return this._backgroundObjectId}set backgroundObjectId(t){this._backgroundObjectId=t}get gsView(){return this._gsView}}class Jh{constructor(){this.events={layoutCreated:new ie,layoutRemoved:new ie,layoutRenamed:new ie,layoutSwitched:new ie}}countLayouts(t){return this.getWorkingDatabase(t).dictionaries.layouts.numEntries}findLayoutNamed(t,e){return this.getWorkingDatabase(e).dictionaries.layouts.getAt(t)}findActiveLayout(){const t=this.getActiveLayout();return t?t.layoutName:"Model"}setCurrentLayoutId(t,e){const s=this.getWorkingDatabase(e),o=s.dictionaries.layouts.getIdAt(t);return this.setCurrentLayoutInternal(o,s)}setCurrentLayoutBtrId(t,e){const s=this.getWorkingDatabase(e),o=s.dictionaries.layouts.getBtrIdAt(t);return this.setCurrentLayoutInternal(o,s)}setCurrentLayout(t,e){const s=this.getWorkingDatabase(e),o=s.dictionaries.layouts.getAt(t);return this.setCurrentLayoutInternal(o,s)}renameLayout(t,e,s){const h=this.getWorkingDatabase(s).dictionaries.layouts.getAt(t);return h?(h.layoutName=e,this.events.layoutRenamed.dispatch({layout:h,oldName:t,newName:e}),!0):!1}layoutExists(t,e){return this.getWorkingDatabase(e).dictionaries.layouts.has(t)}deleteLayout(t,e){const s=this.getWorkingDatabase(e).dictionaries.layouts,o=s.getAt(t);let h=!1;return o&&(h=s.remove(t),h&&this.events.layoutRemoved.dispatch({layout:o})),h}createLayout(t,e){const s=this.getWorkingDatabase(e),o=new xa;o.layoutName=t,o.tabOrder=s.dictionaries.layouts.maxTabOrder;const h=new De;return h.name=`*Paper_Space${o.tabOrder}`,s.tables.blockTable.add(h),s.dictionaries.layouts.setAt(t,o),this.events.layoutCreated.dispatch({layout:o}),{layout:o,btr:h}}getActiveLayout(t){const e=this.getWorkingDatabase(t);return e.dictionaries.layouts.getBtrIdAt(e.currentSpaceId)}getWorkingDatabase(t){return t||Pa().workingDatabase}setCurrentLayoutInternal(t,e){return t?(this.events.layoutSwitched.dispatch({layout:t}),e.currentSpaceId=t.blockTableRecordId,!0):!1}}function Pa(){return pi.instance}const fi=class fi{constructor(){this._workingDatabase=null,this._layoutManager=new Jh}get workingDatabase(){if(this._workingDatabase==null)throw new Error("The current working database must be set before using it!");return this._workingDatabase}set workingDatabase(t){this._workingDatabase=t}get layoutManager(){return this._layoutManager}};fi.instance=new fi;let pi=fi;exports.AcCmColor=an;exports.AcCmErrors=Re;exports.AcCmEventDispatcher=_u;exports.AcCmEventManager=ie;exports.AcCmLoader=Su;exports.AcCmLoadingManager=Go;exports.AcCmObject=Fo;exports.AcCmPerformanceCollector=ea;exports.AcCmTask=Uo;exports.AcCmTaskScheduler=jo;exports.AcDb3PointAngularDimension=hi;exports.AcDbAlignedDimension=ui;exports.AcDbAngleUnits=ia;exports.AcDbArc=Ks;exports.AcDbArcDimension=ta;exports.AcDbBaseWorker=ld;exports.AcDbBatchProcessing=Ho;exports.AcDbBlockReference=ys;exports.AcDbBlockTable=Fh;exports.AcDbBlockTableRecord=De;exports.AcDbCircle=Xs;exports.AcDbCurve=Be;exports.AcDbDatabase=hd;exports.AcDbDatabaseConverter=jl;exports.AcDbDatabaseConverterManager=ir;exports.AcDbDiametricDimension=ci;exports.AcDbDictionary=wa;exports.AcDbDimArrowType=Vl;exports.AcDbDimStyleTable=Vh;exports.AcDbDimStyleTableRecord=ws;exports.AcDbDimTextHorizontal=Hh;exports.AcDbDimTextVertical=qh;exports.AcDbDimVerticalJustification=Xh;exports.AcDbDimZeroSuppression=Yh;exports.AcDbDimZeroSuppressionAngular=Kh;exports.AcDbDimension=wr;exports.AcDbDxfConverter=Bh;exports.AcDbEllipse=Ys;exports.AcDbEntity=je;exports.AcDbFileType=vs;exports.AcDbHatch=$s;exports.AcDbHatchPatternType=Sh;exports.AcDbHatchStyle=Ih;exports.AcDbHostApplicationServices=pi;exports.AcDbLayerTable=Uh;exports.AcDbLayerTableRecord=Aa;exports.AcDbLayout=xa;exports.AcDbLayoutDictionary=Lh;exports.AcDbLayoutManager=Jh;exports.AcDbLeader=Zs;exports.AcDbLeaderAnnotationType=kh;exports.AcDbLine=Qs;exports.AcDbLineSpacingStyle=Nh;exports.AcDbLinetypeTable=jh;exports.AcDbLinetypeTableRecord=$h;exports.AcDbMText=Js;exports.AcDbObject=Vr;exports.AcDbObjectIterator=_i;exports.AcDbOrdinateDimension=di;exports.AcDbOsnapMode=tn;exports.AcDbPoint=si;exports.AcDbPolyline=ni;exports.AcDbRadialDimension=mi;exports.AcDbRasterImage=xs;exports.AcDbRasterImageClipBoundaryType=Th;exports.AcDbRasterImageDef=Oh;exports.AcDbRasterImageImageDisplayOpt=Ch;exports.AcDbRay=ii;exports.AcDbRenderingCache=Dr;exports.AcDbSpline=bs;exports.AcDbSymbolTable=ln;exports.AcDbSymbolTableRecord=on;exports.AcDbTable=ti;exports.AcDbText=ei;exports.AcDbTextHorizontalMode=Eh;exports.AcDbTextStyleTable=Gh;exports.AcDbTextStyleTableRecord=Zh;exports.AcDbTextVerticalMode=Mh;exports.AcDbTrace=ri;exports.AcDbUnitsValue=aa;exports.AcDbViewport=ai;exports.AcDbViewportTable=Wh;exports.AcDbViewportTableRecord=Qh;exports.AcDbWipeout=oi;exports.AcDbWorkerApi=Dh;exports.AcDbWorkerManager=zh;exports.AcDbXline=li;exports.AcGeArea2d=yi;exports.AcGeBox2d=_e;exports.AcGeBox3d=Dt;exports.AcGeCatmullRomCurve3d=Ah;exports.AcGeCircArc2d=kn;exports.AcGeCircArc3d=rn;exports.AcGeCurve2d=Tn;exports.AcGeEllipseArc2d=bi;exports.AcGeEllipseArc3d=xi;exports.AcGeEuler=yh;exports.AcGeGeometryUtil=ch;exports.AcGeLine2d=wi;exports.AcGeLine3d=Br;exports.AcGeLoop2d=xh;exports.AcGeMathUtil=St;exports.AcGeMatrix2d=vi;exports.AcGeMatrix3d=sn;exports.AcGeNurbsCurve=nn;exports.AcGePlane=As;exports.AcGePoint2d=Mt;exports.AcGePoint3d=X;exports.AcGePolyline2d=Ss;exports.AcGeQuaternion=Rr;exports.AcGeShape2d=fa;exports.AcGeSpline3d=Fr;exports.AcGeTol=ma;exports.AcGeVector2d=Kt;exports.AcGeVector3d=$;exports.AcGiArrowType=_a;exports.AcGiDefaultLightingType=ba;exports.AcGiMTextAttachmentPoint=En;exports.AcGiMTextFlowDirection=Ai;exports.AcGiOrthographicType=ya;exports.AcGiRenderMode=va;exports.AcGiViewport=Pi;exports.AcTrStringUtil=Pu;exports.ByBlock=Fl;exports.ByLayer=Gs;exports.DEBUG_MODE=wu;exports.DEFAULT_LINE_TYPE=Hs;exports.DEFAULT_TOL=pa;exports.DEG2RAD=oa;exports.DefaultLoadingManager=Wo;exports.FLOAT_TOL=Jr;exports.ORIGIN_POINT_2D=$c;exports.ORIGIN_POINT_3D=da;exports.RAD2DEG=la;exports.TAU=re;exports.acdbHostApplicationServices=Pa;exports.basisFunction=qs;exports.calculateCurveLength=gh;exports.ceilPowerOfTwo=nh;exports.clamp=xr;exports.clone=ms;exports.createWorkerApi=Rh;exports.damp=ql;exports.defaults=Mn;exports.degToRad=th;exports.euclideanModulo=ha;exports.evaluateNurbsPoint=_s;exports.floorPowerOfTwo=sh;exports.generateChordKnots=mh;exports.generateSqrtChordKnots=ph;exports.generateUUID=Gl;exports.generateUniformKnots=dh;exports.has=Ro;exports.intPartLength=ca;exports.interpolateControlPoints=Zc;exports.inverseLerp=Hl;exports.isBetween=ih;exports.isBetweenAngle=ah;exports.isEmpty=Bo;exports.isEqual=Sn;exports.isImperialUnits=Xc;exports.isMetricUnits=Kc;exports.isPointInPolygon=ga;exports.isPolygonIntersect=uh;exports.isPowerOfTwo=rh;exports.lerp=ua;exports.log=gs;exports.mapLinear=Wl;exports.normalizeAngle=fs;exports.pingpong=Yl;exports.radToDeg=eh;exports.randFloat=Zl;exports.randFloatSpread=Ql;exports.randInt=$l;exports.relativeEps=oh;exports.seededRandom=Jl;exports.setLogLevel=Au;exports.smootherstep=Xl;exports.smoothstep=Kl;