@mlightcad/data-model 1.6.6 → 1.6.7

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 Iu(i,t){for(var e=0;e<t.length;e++){const n=t[e];if(typeof n!="string"&&!Array.isArray(n)){for(const a in n)if(a!=="default"&&!(a in i)){const h=Object.getOwnPropertyDescriptor(n,a);h&&Object.defineProperty(i,a,h.get?h:{enumerable:!0,get:()=>n[a]})}}}return Object.freeze(Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}))}var pt=(i=>(i[i.ByColor=1]="ByColor",i[i.ByACI=2]="ByACI",i[i.ByLayer=3]="ByLayer",i[i.ByBlock=4]="ByBlock",i[i.None=0]="None",i))(pt||{});const ol={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},oa=[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];let fn=class{static getColorByIndex(t){return oa[t]}static getIndexByColor(t){const e=oa.length-1;for(let n=1;n<e;++n)if(oa[n]===t)return n}static getColorByName(t){return ol[t.toLowerCase()]}static getNameByColor(t){for(const[e,n]of Object.entries(ol))if(n===t)return e}static getNameByIndex(t){const e=this.getColorByIndex(t);return this.getNameByColor(e)}},Dr=class _n{constructor(t=pt.ByLayer,e){this._colorMethod=t,this._colorMethod==pt.ByColor&&e==null?this._value=16777215:this._colorMethod==pt.ByACI?e==null?this._value=8:e===0?this._colorMethod=pt.ByBlock:e===256?this._colorMethod=pt.ByLayer:this._value=Math.max(0,Math.min(e,256)):this._value=e}get colorMethod(){return this._colorMethod}set colorMethod(t){this._colorMethod=t}get red(){const t=this.RGB;return t!=null?t>>16&255:void 0}get green(){const t=this.RGB;return t!=null?t>>8&255:void 0}get blue(){const t=this.RGB;return t!=null?t&255:void 0}get RGB(){switch(this._colorMethod){case pt.ByColor:case pt.ByBlock:case pt.ByLayer:return this._value;case pt.ByACI:return this._value?fn.getColorByIndex(this._value):this._value;default:return}}setRGB(t,e,n){const a=Math.max(0,Math.min(255,Math.round(t))),h=Math.max(0,Math.min(255,Math.round(e))),c=Math.max(0,Math.min(255,Math.round(n)));return this._value=a<<16|h<<8|c,this._colorMethod=pt.ByColor,this}setRGBValue(t){return t==null||!Number.isFinite(t)?(console.warn("Invalid RGB value:",t),this):(this._value=t&16777215,this._colorMethod=pt.ByColor,this)}setRGBFromCss(t){if(!t)return this;const e=t.trim().toLowerCase();if(e.startsWith("#")){let h=0,c=0,m=0;if(e.length===7)h=parseInt(e.substr(1,2),16),c=parseInt(e.substr(3,2),16),m=parseInt(e.substr(5,2),16);else if(e.length===4)h=parseInt(e[1]+e[1],16),c=parseInt(e[2]+e[2],16),m=parseInt(e[3]+e[3],16);else return console.warn("Invalid hex color:",t),this;return this.setRGB(h,c,m)}const n=e.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);if(n){const h=parseInt(n[1],10),c=parseInt(n[2],10),m=parseInt(n[3],10);return this.setRGB(h,c,m)}const a=fn.getColorByName(t);return a!==void 0?this.setRGBValue(a):(console.warn("Unknown CSS color string:",t),this)}setScalar(t){return this.setRGB(t,t,t)}get hexColor(){const t=this.RGB;return t==null?void 0:"0x"+t.toString(16).padStart(6,"0").toUpperCase()}get cssColor(){const t=this.RGB;if(t!=null)return`rgb(${t>>16&255},${t>>8&255},${t&255})`}get colorIndex(){return this._colorMethod===pt.ByACI?this._value:this._colorMethod===pt.ByLayer?256:this._colorMethod===pt.ByBlock?0:void 0}set colorIndex(t){if(t==null)return;const e=Math.max(0,Math.min(256,Math.round(t)));e===0?(this._colorMethod=pt.ByBlock,this._value=void 0):e===256?(this._colorMethod=pt.ByLayer,this._value=void 0):(this._colorMethod=pt.ByACI,this._value=e)}get isByColor(){return this._colorMethod===pt.ByColor}get isByACI(){return this._colorMethod===pt.ByACI}get isByLayer(){return this._colorMethod===pt.ByLayer}setByLayer(t){return this._colorMethod=pt.ByLayer,t==null?this._value=256:this._value=t,this}get isByBlock(){return this._colorMethod===pt.ByBlock}setByBlock(t){return this._colorMethod=pt.ByBlock,t==null?this._value=0:this._value=t,this}get colorName(){switch(this._colorMethod){case pt.ByLayer:return"ByLayer";case pt.ByBlock:return"ByBlock";case pt.ByColor:return this._value?fn.getNameByColor(this._value):"";case pt.ByACI:return this._value?fn.getNameByIndex(this._value):"";default:return}}set colorName(t){if(!t)return;const e=fn.getColorByName(t);e!==void 0?(this._value=e,this._colorMethod=pt.ByColor):console.warn("Unknown color name:",t)}clone(){const t=new _n;return t._colorMethod=this._colorMethod,t._value=this._value,t}copy(t){return this._colorMethod=t._colorMethod,this._value=t._value,this}equals(t){return this._colorMethod===t._colorMethod&&this._value===t._value}toString(){switch(this._colorMethod){case pt.ByLayer:return"ByLayer";case pt.ByBlock:return"ByBlock";case pt.ByACI:return this._value!==void 0?String(this._value):"";case pt.ByColor:return this._value?`${this.red},${this.green},${this.blue}`:"";default:return""}}static fromString(t){if(!t)return;const e=t.trim();if(/^bylayer$/i.test(e))return new _n(pt.ByLayer);if(/^byblock$/i.test(e))return new _n(pt.ByBlock);if(/^\d{1,3},\d{1,3},\d{1,3}$/i.test(e)){const[a,h,c]=e.split(",").map(Number),m=new _n(pt.ByColor);return m.setRGB(a,h,c),m}if(/^\d+$/.test(e)){const a=parseInt(e,10);return new _n(pt.ByACI,a)}const n=fn.getColorByName(e);if(n!=null)return new _n(pt.ByColor,n);console.warn("Unknown color name:",t)}};class Eu{constructor(t=pt.ByColor,e=0){this._colorMethod=t,this._value=e}get colorMethd(){return this._colorMethod}get red(){return this._value>>16&255}set red(t){this._colorMethod=pt.ByColor,this._value=this._value&65535|(t&255)<<16}get green(){return this._value>>8&255}set green(t){this._colorMethod=pt.ByColor,this._value=this._value&16711935|(t&255)<<8}get blue(){return this._value&255}set blue(t){this._colorMethod=pt.ByColor,this._value=this._value&16776960|t&255}setRGB(t,e,n){this._colorMethod=pt.ByColor,this._value=(t&255)<<16|(e&255)<<8|n&255}get colorIndex(){return this._value}set colorIndex(t){this._colorMethod=pt.ByACI,this._value=t}get layerIndex(){return this._value}set layerIndex(t){this._colorMethod=pt.ByLayer,this._value=t}isByColor(){return this._colorMethod===pt.ByColor}isByLayer(){return this._colorMethod===pt.ByLayer}isByBlock(){return this._colorMethod===pt.ByBlock}isByACI(){return this._colorMethod===pt.ByACI}isNone(){return this._colorMethod===pt.None}get rawValue(){return this._value}set rawValue(t){this._value=t}}const Xe={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 Mu{constructor(){this._listeners={}}addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const n=this._listeners;return n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const n=this._listeners[t];if(n!==void 0){const a=n.indexOf(e);a!==-1&&n.splice(a,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const e=this._listeners[t.type];if(e!==void 0){t.target=this;const n=e.slice(0);for(let a=0,h=n.length;a<h;a++)n[a].call(this,t)}}}let ae=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 n of this.listeners)n.call(null,t,...e)}};function zs(i){return i===null||typeof i!="object"?i:Array.isArray(i)?[...i]:{...i}}function wa(i){if(i===null||typeof i!="object")return i;if(i instanceof Date)return new Date(i.getTime());if(i instanceof RegExp)return new RegExp(i.source,i.flags);if(Array.isArray(i))return i.map(wa);const t={};for(const e in i)Object.prototype.hasOwnProperty.call(i,e)&&(t[e]=wa(i[e]));return t}function Kn(i,...t){for(const e of t)if(e)for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&i[n]===void 0&&(i[n]=e[n]);return i}function Il(i,t){return i!=null&&Object.prototype.hasOwnProperty.call(i,t)}function El(i){return i==null?!0:Array.isArray(i)||typeof i=="string"?i.length===0:i instanceof Map||i instanceof Set?i.size===0:typeof i=="object"?Object.keys(i).length===0:!1}function Gn(i,t){if(i===t)return!0;if(i==null||t==null)return i===t;if(typeof i!=typeof t)return!1;if(typeof i!="object")return i===t;if(Array.isArray(i)!==Array.isArray(t))return!1;if(Array.isArray(i)){if(i.length!==t.length)return!1;for(let a=0;a<i.length;a++)if(!Gn(i[a],t[a]))return!1;return!0}const e=Object.keys(i),n=Object.keys(t);if(e.length!==n.length)return!1;for(const a of e)if(!Object.prototype.hasOwnProperty.call(t,a)||!Gn(i[a],t[a]))return!1;return!0}var ku=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Tu(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Ml={exports:{}};(function(i){(function(t,e){i.exports?i.exports=e():t.log=e()})(ku,function(){var t=function(){},e="undefined",n=typeof window!==e&&typeof window.navigator!==e&&/Trident\/|MSIE /.test(window.navigator.userAgent),a=["trace","debug","info","warn","error"],h={},c=null;function m(L,F){var D=L[F];if(typeof D.bind=="function")return D.bind(L);try{return Function.prototype.bind.call(D,L)}catch{return function(){return Function.prototype.apply.apply(D,[L,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(L){return L==="debug"&&(L="log"),typeof console===e?!1:L==="trace"&&n?b:console[L]!==void 0?m(console,L):console.log!==void 0?m(console,"log"):t}function w(){for(var L=this.getLevel(),F=0;F<a.length;F++){var D=a[F];this[D]=F<L?t:this.methodFactory(D,L,this.name)}if(this.log=this.debug,typeof console===e&&L<this.levels.SILENT)return"No console available for logging"}function x(L){return function(){typeof console!==e&&(w.call(this),this[L].apply(this,arguments))}}function I(L,F,D){return f(L)||x.apply(this,arguments)}function M(L,F){var D=this,dt,vt,ot,H="loglevel";typeof L=="string"?H+=":"+L:typeof L=="symbol"&&(H=void 0);function ct(wt){var Bt=(a[wt]||"silent").toUpperCase();if(!(typeof window===e||!H)){try{window.localStorage[H]=Bt;return}catch{}try{window.document.cookie=encodeURIComponent(H)+"="+Bt+";"}catch{}}}function st(){var wt;if(!(typeof window===e||!H)){try{wt=window.localStorage[H]}catch{}if(typeof wt===e)try{var Bt=window.document.cookie,ge=encodeURIComponent(H),fe=Bt.indexOf(ge+"=");fe!==-1&&(wt=/^([^;]+)/.exec(Bt.slice(fe+ge.length+1))[1])}catch{}return D.levels[wt]===void 0&&(wt=void 0),wt}}function Gt(){if(!(typeof window===e||!H)){try{window.localStorage.removeItem(H)}catch{}try{window.document.cookie=encodeURIComponent(H)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function Kt(wt){var Bt=wt;if(typeof Bt=="string"&&D.levels[Bt.toUpperCase()]!==void 0&&(Bt=D.levels[Bt.toUpperCase()]),typeof Bt=="number"&&Bt>=0&&Bt<=D.levels.SILENT)return Bt;throw new TypeError("log.setLevel() called with invalid level: "+wt)}D.name=L,D.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},D.methodFactory=F||I,D.getLevel=function(){return ot??vt??dt},D.setLevel=function(wt,Bt){return ot=Kt(wt),Bt!==!1&&ct(ot),w.call(D)},D.setDefaultLevel=function(wt){vt=Kt(wt),st()||D.setLevel(wt,!1)},D.resetLevel=function(){ot=null,Gt(),w.call(D)},D.enableAll=function(wt){D.setLevel(D.levels.TRACE,wt)},D.disableAll=function(wt){D.setLevel(D.levels.SILENT,wt)},D.rebuild=function(){if(c!==D&&(dt=Kt(c.getLevel())),w.call(D),c===D)for(var wt in h)h[wt].rebuild()},dt=Kt(c?c.getLevel():"WARN");var qt=st();qt!=null&&(ot=Kt(qt)),w.call(D)}c=new M,c.getLogger=function(L){if(typeof L!="symbol"&&typeof L!="string"||L==="")throw new TypeError("You must supply a name when creating a logger.");var F=h[L];return F||(F=h[L]=new M(L,c.methodFactory)),F};var O=typeof window!==e?window.log:void 0;return c.noConflict=function(){return typeof window!==e&&window.log===c&&(window.log=O),c},c.getLoggers=function(){return h},c.default=c,c})})(Ml);var kl=Ml.exports;const Cu=Tu(kl),Nu=Iu({__proto__:null,default:Cu},[kl]),Lu=!0,Ds=Nu;Ds.setLevel("debug");const Ou=i=>{try{Ds.setLevel(i)}catch(t){Ds.setLevel("error"),Ds.error(t)}};let Tl=class Cl{constructor(t,e){this.events={attrChanged:new ae,modelChanged:new ae},this._changing=!1,this._previousAttributes={},this._pending=!1;const n=t||{};e&&Kn(n,e),this.attributes=n,this.changed={}}get(t){return this.attributes[t]}set(t,e,n){if(t==null)return this;let a;typeof t=="object"?(a=t,n=e):(a={},a[t]=e),n||(n={});const h=n.unset,c=n.silent,m=[],b=this._changing;this._changing=!0,b||(this._previousAttributes=zs(this.attributes),this.changed={});const f=this.attributes,w=this.changed,x=this._previousAttributes;for(const I in a)e=a[I],Gn(f[I],e)||m.push(I),Gn(x[I],e)?delete w[I]:w[I]=e,h?delete f[I]:f[I]=e;if(!c){m.length&&(this._pending=n);for(let I=0;I<m.length;I++)this.events.attrChanged.dispatch({object:this,attrName:m[I],attrValue:f[m[I]],options:n})}if(b)return this;if(!c)for(;this._pending;)n=this._pending,this._pending=!1,this.events.modelChanged.dispatch({object:this,options:n});return this._pending=!1,this._changing=!1,this}has(t){return this.get(t)!=null}hasChanged(t){return t==null?!El(this.changed):Il(this.changed,t)}changedAttributes(t){if(!t)return this.hasChanged()?zs(this.changed):{};const e=this._changing?this._previousAttributes:this.attributes,n={};for(const a in t){const h=t[a];Gn(e[a],h)||(n[a]=h)}return n}previous(t){return t==null||!this._previousAttributes?null:this._previousAttributes[t]}previousAttributes(){return zs(this._previousAttributes)}clone(){const t=zs(this.attributes);return new Cl(t)}},Oa=class Rs{constructor(){this.entries=new Map}static getInstance(){return Rs.instance||(Rs.instance=new Rs),Rs.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 Bu{static formatBytes(t,e=2){if(t===0)return"0 B";const n=1024,a=Math.max(0,e),h=["B","KB","MB","GB","TB"],c=Math.floor(Math.log(t)/Math.log(n)),m=t/Math.pow(n,c);return`${parseFloat(m.toFixed(a))} ${h[c]}`}}var Ee=(i=>(i[i.ByLayer=0]="ByLayer",i[i.ByBlock=1]="ByBlock",i[i.ByAlpha=2]="ByAlpha",i[i.ErrorValue=3]="ErrorValue",i))(Ee||{});let Wi=class mr{constructor(t){t!==void 0?(this._method=Ee.ByAlpha,this._alpha=mr.clampAlpha(t)):(this._method=Ee.ByLayer,this._alpha=255)}get method(){return this._method}set method(t){this._method=t}get alpha(){return this._alpha}set alpha(t){this._alpha=mr.clampAlpha(t),this._method=Ee.ByAlpha}get percentage(){if(this._method===Ee.ByAlpha)return Math.round((1-this._alpha/255)*100)}set percentage(t){const e=Math.max(0,Math.min(100,t)),n=Math.round(255*(1-e/100));this.alpha=n}static clampAlpha(t){return Math.max(0,Math.min(255,Math.floor(t)))}get isByAlpha(){return this._method===Ee.ByAlpha}get isByBlock(){return this._method===Ee.ByBlock}get isByLayer(){return this._method===Ee.ByLayer}get isClear(){return this.isByAlpha&&this._alpha===0}get isSolid(){return this.isByAlpha&&this._alpha===255}get isInvalid(){return this._method===Ee.ErrorValue}serialize(){return this._method<<24|this._alpha}clone(){const t=new mr;return t._method=this._method,t._alpha=this._alpha,t}equals(t){return this._method===t._method&&this._alpha===t._alpha}toString(){return this.isByLayer?"ByLayer":this.isByBlock?"ByBlock":this._alpha.toString()}static fromString(t){const e=t.trim();if(/^bylayer$/i.test(e)){const h=new mr;return h._method=Ee.ByLayer,h}if(/^byblock$/i.test(e)){const h=new mr;return h._method=Ee.ByBlock,h}const n=Number(e);if(Number.isInteger(n)&&n>=0&&n<=255)return new mr(n);const a=new mr;return a._method=Ee.ErrorValue,a}static deserialize(t){const e=t>>>24&255,n=t&255,a=Object.values(Ee)[e]??Ee.ErrorValue,h=new mr;return h._method=a,h._alpha=mr.clampAlpha(n),h}};class Nl{constructor(t){this.name=t}run(t){throw new Error("run() must be implemented by subclass")}}let Ll=class{constructor(){this.tasks=[],this.onProgress=()=>{},this.onComplete=()=>{},this.onError=()=>!1}scheduleTask(t){return new Promise((e,n)=>{const a=()=>{Promise.resolve(t()).then(e).catch(n)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(a):setTimeout(a,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 n=t;for(let a=0;a<e;a++){const h=this.tasks[a];try{n=await this.scheduleTask(async()=>{const c=await h.run(n);return this.onProgress((a+1)/e,h),c})}catch(c){if(this.onError({error:c,taskIndex:a,task:h}))return Promise.reject(c)}}this.onComplete(n)}},Ol=class{constructor(t,e,n){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=n}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,n=this.handlers.length;e<n;e+=2){const a=this.handlers[e],h=this.handlers[e+1];if(a.global&&(a.lastIndex=0),a.test(t))return h}return null}};const Bl=new Ol;class zu{constructor(t){this.manager=t!==void 0?t:Bl,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}loadAsync(t,e){return new Promise((n,a)=>{this.load(t,n,e,a)})}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 Ba{constructor(t,e,n){this._chunkSize=-1,this._minimumChunkSize=50,this._count=t,this._numerOfChunk=e<1?1:e,this._minimumChunkSize=n,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,n)=>{const a=()=>{Promise.resolve(t()).then(e).catch(n)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(a):setTimeout(a,0)})}async processChunk(t){let e=0;const n=async()=>{const a=e,h=Math.min(e+this._chunkSize,this._count);await t(a,h),e=h,e<this._count&&await this.scheduleTask(n)};await n()}}var za=(i=>(i[i.DecimalDegrees=0]="DecimalDegrees",i[i.DegreesMinutesSeconds=1]="DegreesMinutesSeconds",i[i.Gradians=2]="Gradians",i[i.Radians=3]="Radians",i[i.SurveyorsUnits=4]="SurveyorsUnits",i))(za||{});class $n{static get instance(){return this._instance||(this._instance=new $n),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,n,a=[],h=!0,c,m){var f;const b=[];if(e!=null){const w=this.createKey(e.name,n);let x;if(this.has(w))x=this.get(w);else{const I=(f=t.basePoint)==null?void 0:f.clone();t.basePoint=void 0;const M=e.newIterator();let O=!0;for(const L of M)if(L.color.isByBlock&&n?(ll.copy(L.color),L.color.setRGBValue(n),this.addEntity(L,b,t),L.color.copy(ll)):this.addEntity(L,b,t),O){const F=b[0];t.basePoint=F.basePoint,O=!1}x=t.group(b),x&&h&&le.name&&!le.name.startsWith("*U")&&this.set(w,x),t.basePoint=I}return x&&c&&(x.applyMatrix(c),m&&(m.x!=0||m.y!=0||m.z!=1)&&(c.setFromExtrusionDirection(m),x.applyMatrix(c))),x&&a&&a.length>0&&(x.bakeTransformToChildren(),a.forEach(I=>x.addChild(I))),x}else return t.group(b)}addEntity(t,e,n){const a=t.worldDraw(n);a&&(this.attachEntityInfo(a,t),e.push(a))}attachEntityInfo(t,e){t.objectId=e.objectId,t.ownerId=e.ownerId,t.layerName=e.layer,t.visible=e.visibility}}const ll=new Dr;var Ra=(i=>(i[i.UTF8=0]="UTF8",i[i.US_ASCII=1]="US_ASCII",i[i.ISO_8859_1=2]="ISO_8859_1",i[i.ISO_8859_2=3]="ISO_8859_2",i[i.ISO_8859_3=4]="ISO_8859_3",i[i.ISO_8859_4=5]="ISO_8859_4",i[i.ISO_8859_5=6]="ISO_8859_5",i[i.ISO_8859_6=7]="ISO_8859_6",i[i.ISO_8859_7=8]="ISO_8859_7",i[i.ISO_8859_8=9]="ISO_8859_8",i[i.ISO_8859_9=10]="ISO_8859_9",i[i.CP437=11]="CP437",i[i.CP850=12]="CP850",i[i.CP852=13]="CP852",i[i.CP855=14]="CP855",i[i.CP857=15]="CP857",i[i.CP860=16]="CP860",i[i.CP861=17]="CP861",i[i.CP863=18]="CP863",i[i.CP864=19]="CP864",i[i.CP865=20]="CP865",i[i.CP869=21]="CP869",i[i.CP932=22]="CP932",i[i.MACINTOSH=23]="MACINTOSH",i[i.BIG5=24]="BIG5",i[i.CP949=25]="CP949",i[i.JOHAB=26]="JOHAB",i[i.CP866=27]="CP866",i[i.ANSI_1250=28]="ANSI_1250",i[i.ANSI_1251=29]="ANSI_1251",i[i.ANSI_1252=30]="ANSI_1252",i[i.GB2312=31]="GB2312",i[i.ANSI_1253=32]="ANSI_1253",i[i.ANSI_1254=33]="ANSI_1254",i[i.ANSI_1255=34]="ANSI_1255",i[i.ANSI_1256=35]="ANSI_1256",i[i.ANSI_1257=36]="ANSI_1257",i[i.ANSI_874=37]="ANSI_874",i[i.ANSI_932=38]="ANSI_932",i[i.ANSI_936=39]="ANSI_936",i[i.ANSI_949=40]="ANSI_949",i[i.ANSI_950=41]="ANSI_950",i[i.ANSI_1361=42]="ANSI_1361",i[i.UTF16=43]="UTF16",i[i.ANSI_1258=44]="ANSI_1258",i[i.UNDEFINED=255]="UNDEFINED",i))(Ra||{});const Ru=["utf-8","utf-8","iso-8859-1","iso-8859-2","iso-8859-3","iso-8859-4","iso-8859-5","iso-8859-6","iso-8859-7","iso-8859-8","iso-8859-9","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","shift-jis","macintosh","big5","utf-8","utf-8","ibm866","windows-1250","windows-1251","windows-1252","gbk","windows-1253","windows-1254","windows-1255","windows-1256","windows-1257","windows-874","shift-jis","gbk","euc-kr","big5","utf-8","utf-16le","windows-1258"],zl=i=>Ru[i],fi="Continuous",hi="ByLayer",Rl="ByBlock",ve=["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 hl=1234567;const Da=Math.PI/180,Fa=180/Math.PI;function Dl(){const i=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(ve[i&255]+ve[i>>8&255]+ve[i>>16&255]+ve[i>>24&255]+"-"+ve[t&255]+ve[t>>8&255]+"-"+ve[t>>16&15|64]+ve[t>>24&255]+"-"+ve[e&63|128]+ve[e>>8&255]+"-"+ve[e>>16&255]+ve[e>>24&255]+ve[n&255]+ve[n>>8&255]+ve[n>>16&255]+ve[n>>24&255]).toLowerCase()}function Br(i,t,e){return Math.max(t,Math.min(e,i))}function Va(i,t){return(i%t+t)%t}function Fl(i,t,e,n,a){return n+(i-t)*(a-n)/(e-t)}function Vl(i,t,e){return i!==t?(e-i)/(t-i):0}function Ua(i,t,e){return(1-e)*i+e*t}function Ul(i,t,e,n){return Ua(i,t,1-Math.exp(-e*n))}function jl(i,t=1){return t-Math.abs(Va(i,t*2)-t)}function Gl(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*(3-2*i))}function Wl(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*i*(i*(i*6-15)+10))}function Hl(i,t){return i+Math.floor(Math.random()*(t-i+1))}function ql(i,t){return i+Math.random()*(t-i)}function Yl(i){return i*(.5-Math.random())}function Xl(i){i!==void 0&&(hl=i);let t=hl+=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 Kl(i){return i*Da}function $l(i){return i*Fa}function Zl(i){return(i&i-1)===0&&i!==0}function Ql(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Jl(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Fs(i){const t=Math.PI*2;return(i%t+t)%t}function th(i,t,e){return i>t&&i<e||i>e&&i<t}function eh(i,t,e,n=!1){return i=Fs(i),t=Fs(t),e=Fs(e),n?t>e?i<=t&&i>=e:i<=t||i>=e:t<e?i>=t&&i<=e:i>=t||i<=e}function ja(i){return i=Math.abs(i),i<1?0:Math.ceil(Math.log10(Math.abs(i)+1))}function rh(i,t=1e-7){const e=ja(i);return Math.max(Math.pow(10,e)*t,t)}const Pt={DEG2RAD:Da,RAD2DEG:Fa,generateUUID:Dl,clamp:Br,euclideanModulo:Va,mapLinear:Fl,inverseLerp:Vl,lerp:Ua,damp:Ul,pingpong:jl,smoothstep:Gl,smootherstep:Wl,randInt:Hl,randFloat:ql,randFloatSpread:Yl,seededRandom:Xl,degToRad:Kl,radToDeg:$l,isPowerOfTwo:Zl,ceilPowerOfTwo:Ql,floorPowerOfTwo:Jl,normalizeAngle:Fs,isBetween:th,isBetweenAngle:eh,intPartLength:ja,relativeEps:rh},Aa=class nh{constructor(t,e){this.x=0,this.y=0;const n=+(t!==void 0)+ +(e!==void 0);if(n!==0){if(n===1&&t instanceof Array){this.x=t[0],this.y=t[1];return}if(n===1){const{x:a,y:h}=t;this.x=a,this.y=h;return}if(n===2){this.x=t,this.y=e;return}throw Xe.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 nh(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,n=this.y,a=t.elements;return this.x=a[0]*e+a[3]*n+a[6],this.y=a[1]*e+a[4]*n+a[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 n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}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 n=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,n)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}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,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,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 n=Math.cos(e),a=Math.sin(e),h=this.x-t.x,c=this.y-t.y;return this.x=h*n-c*a+t.x,this.y=h*a+c*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}relativeEps(t=1e-7){return Math.min(Pt.relativeEps(this.x,t),Pt.relativeEps(this.y,t))}*[Symbol.iterator](){yield this.x,yield this.y}};Aa.EMPTY=Object.freeze(new Aa(0,0));let Jt=Aa;const Pa=class sh{constructor(t,e,n,a,h,c,m,b,f){this.elements=[1,0,0,0,1,0,0,0,1],t!=null&&e!=null&&n!=null&&a!=null&&h!=null&&c!=null&&m!=null&&b!=null&&f!=null&&this.set(t,e,n,a,h,c,m,b,f)}set(t,e,n,a,h,c,m,b,f){const w=this.elements;return w[0]=t,w[1]=a,w[2]=m,w[3]=e,w[4]=h,w[5]=b,w[6]=n,w[7]=c,w[8]=f,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.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 n=t.elements,a=e.elements,h=this.elements,c=n[0],m=n[3],b=n[6],f=n[1],w=n[4],x=n[7],I=n[2],M=n[5],O=n[8],L=a[0],F=a[3],D=a[6],dt=a[1],vt=a[4],ot=a[7],H=a[2],ct=a[5],st=a[8];return h[0]=c*L+m*dt+b*H,h[3]=c*F+m*vt+b*ct,h[6]=c*D+m*ot+b*st,h[1]=f*L+w*dt+x*H,h[4]=f*F+w*vt+x*ct,h[7]=f*D+w*ot+x*st,h[2]=I*L+M*dt+O*H,h[5]=I*F+M*vt+O*ct,h[8]=I*D+M*ot+O*st,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],n=t[1],a=t[2],h=t[3],c=t[4],m=t[5],b=t[6],f=t[7],w=t[8];return e*c*w-e*m*f-n*h*w+n*m*b+a*h*f-a*c*b}invert(){const t=this.elements,e=t[0],n=t[1],a=t[2],h=t[3],c=t[4],m=t[5],b=t[6],f=t[7],w=t[8],x=w*c-m*f,I=m*b-w*h,M=f*h-c*b,O=e*x+n*I+a*M;if(O===0)return this.set(0,0,0,0,0,0,0,0,0);const L=1/O;return t[0]=x*L,t[1]=(a*f-w*n)*L,t[2]=(m*n-a*c)*L,t[3]=I*L,t[4]=(w*e-a*b)*L,t[5]=(a*h-m*e)*L,t[6]=M*L,t[7]=(n*b-f*e)*L,t[8]=(c*e-n*h)*L,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,n,a,h,c,m){const b=Math.cos(h),f=Math.sin(h);return this.set(n*b,n*f,-n*(b*c+f*m)+c+t,-a*f,a*b,-a*(-f*c+b*m)+m+e,0,0,1),this}scale(t,e){return this.premultiply(la.makeScale(t,e)),this}rotate(t){return this.premultiply(la.makeRotation(-t)),this}translate(t,e){return this.premultiply(la.makeTranslation(t,e)),this}makeTranslation(t,e){return t instanceof Jt?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),n=Math.sin(t);return this.set(e,-n,0,n,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,n=t.elements;for(let a=0;a<9;a++)if(e[a]!==n[a])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new sh().fromArray(this.elements)}};Pa.IDENTITY=Object.freeze(new Pa);let Hi=Pa;const la=new Hi,yn=1e-6,Zt=2*Math.PI,Du={x:0,y:0},Ga={x:0,y:0,z:0};class Wa{constructor(){this.equalPointTol=yn,this.equalVectorTol=yn}equalPoint2d(t,e){return new Jt(t).sub(e).length()<this.equalPointTol}equalPoint3d(t,e){return new X(t).sub(e).length()<this.equalPointTol}static equalToZero(t,e=yn){return t<e&&t>-e}static equal(t,e,n=yn){return Math.abs(t-e)<n}static great(t,e,n=yn){return t-e>n}static less(t,e,n=yn){return t-e<n}}const Ha=new Wa;function qa(i,t,e=!1){const n=i.x,a=i.y;let h=!1;const c=t.length;for(let m=0,b=c-1;m<c;b=m++){const f=t[m].x,w=t[m].y,x=t[b].x,I=t[b].y;let M=w>a!=I>a;e&&(M=w>=a!=I>=a),M&&n<(x-f)*(a-w)/(I-w)+f&&(h=!h)}return h}function ih(i,t){if(i.length===0||t.length===0)return!1;const e=new xe().setFromPoints(i),n=new xe().setFromPoints(t);if(!e.intersectsBox(n))return!1;for(let a=0;a<i.length;){if(qa(i[a],t,!0))return!0;a<i.length-1&&Ha.equalPoint2d(i[a+1],i[a])&&++a,++a}return!1}const ah={isPointInPolygon:qa,isPolygonIntersect:ih};function oh(i,t){const e=[],n=t-1,a=i;for(let h=0;h<=a;h++)e.push(0);for(let h=1;h<=n-a;h++)e.push(h);for(let h=0;h<=a;h++)e.push(n-a+1);return e}function lh(i,t){const e=t.length-1,n=i,a=[0];let h=0;for(let m=1;m<=e;m++){const b=t[m][0]-t[m-1][0],f=t[m][1]-t[m-1][1],w=t[m][2]-t[m-1][2],x=Math.sqrt(b*b+f*f+w*w);h+=x,a.push(h)}const c=[];for(let m=0;m<=n;m++)c.push(0);for(let m=1;m<=e-n;m++){const b=a[m]/h;c.push(b*(e-n+1))}for(let m=0;m<=n;m++)c.push(e-n+1);return c}function hh(i,t){const e=t.length-1,n=i,a=[0];let h=0;for(let m=1;m<=e;m++){const b=t[m][0]-t[m-1][0],f=t[m][1]-t[m-1][1],w=t[m][2]-t[m-1][2],x=Math.sqrt(b*b+f*f+w*w),I=Math.sqrt(x);h+=I,a.push(h)}const c=[];for(let m=0;m<=n;m++)c.push(0);for(let m=1;m<=e-n;m++){const b=a[m]/h;c.push(b*(e-n+1))}for(let m=0;m<=n;m++)c.push(e-n+1);return c}function _i(i,t,e,n){if(t===0)return e>=n[i]&&e<n[i+1]?1:0;const a=n[i+t]-n[i],h=n[i+t+1]-n[i+1],c=a>1e-10?(e-n[i])/a:0,m=h>1e-10?(n[i+t+1]-e)/h:0;return c*_i(i,t-1,e,n)+m*_i(i+1,t-1,e,n)}function Vs(i,t,e,n,a){const h=n.length-1,c=t;if(i=Math.max(e[c],Math.min(e[h+1],i)),Math.abs(i-e[h+1])<1e-8)return[...n[h]];if(Math.abs(i-e[c])<1e-8)return[...n[0]];const m=[0,0,0];let b=0;for(let f=0;f<=h;f++){const w=_i(f,c,i,e),x=a[f]*w;m[0]+=n[f][0]*x,m[1]+=n[f][1]*x,m[2]+=n[f][2]*x,b+=x}if(b<1e-10){const f=e[e.length-c-1];if(Math.abs(i-f)<1e-8)return[...n[h]];if(Math.abs(i-e[c])<1e-8)return[...n[0]]}return b>1e-10&&(m[0]/=b,m[1]/=b,m[2]/=b),m}function ch(i,t,e,n){const a=i,h=t[a],c=t[t.length-a-1];let m=0;const b=1e3,f=(c-h)/b;let w=Vs(h,i,t,e,n);for(let L=1;L<=b;L++){const F=h+L*f,D=Vs(F,i,t,e,n),dt=D[0]-w[0],vt=D[1]-w[1],ot=D[2]-w[2];m+=Math.sqrt(dt*dt+vt*vt+ot*ot),w=D}const x=Vs(c,i,t,e,n),I=x[0]-w[0],M=x[1]-w[1],O=x[2]-w[2];return m+=Math.sqrt(I*I+M*M+O*O),m}function Fu(i){return i.map(t=>[...t])}class wn{constructor(t=0,e=0,n=0,a=1){this._x=t,this._y=e,this._z=n,this._w=a}static slerpFlat(t,e,n,a,h,c,m){let b=n[a+0],f=n[a+1],w=n[a+2],x=n[a+3];const I=h[c+0],M=h[c+1],O=h[c+2],L=h[c+3];if(m===0){t[e+0]=b,t[e+1]=f,t[e+2]=w,t[e+3]=x;return}if(m===1){t[e+0]=I,t[e+1]=M,t[e+2]=O,t[e+3]=L;return}if(x!==L||b!==I||f!==M||w!==O){let F=1-m;const D=b*I+f*M+w*O+x*L,dt=D>=0?1:-1,vt=1-D*D;if(vt>Number.EPSILON){const H=Math.sqrt(vt),ct=Math.atan2(H,D*dt);F=Math.sin(F*ct)/H,m=Math.sin(m*ct)/H}const ot=m*dt;if(b=b*F+I*ot,f=f*F+M*ot,w=w*F+O*ot,x=x*F+L*ot,F===1-m){const H=1/Math.sqrt(b*b+f*f+w*w+x*x);b*=H,f*=H,w*=H,x*=H}}t[e]=b,t[e+1]=f,t[e+2]=w,t[e+3]=x}static multiplyQuaternionsFlat(t,e,n,a,h,c){const m=n[a],b=n[a+1],f=n[a+2],w=n[a+3],x=h[c],I=h[c+1],M=h[c+2],O=h[c+3];return t[e]=m*O+w*x+b*M-f*I,t[e+1]=b*O+w*I+f*x-m*M,t[e+2]=f*O+w*M+m*I-b*x,t[e+3]=w*O-m*x-b*I-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,n,a){return this._x=t,this._y=e,this._z=n,this._w=a,this._onChangeCallback(),this}clone(){return new wn(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 n=t.x,a=t.y,h=t.z,c=t.order,m=Math.cos,b=Math.sin,f=m(n/2),w=m(a/2),x=m(h/2),I=b(n/2),M=b(a/2),O=b(h/2);switch(c){case"XYZ":this._x=I*w*x+f*M*O,this._y=f*M*x-I*w*O,this._z=f*w*O+I*M*x,this._w=f*w*x-I*M*O;break;case"YXZ":this._x=I*w*x+f*M*O,this._y=f*M*x-I*w*O,this._z=f*w*O-I*M*x,this._w=f*w*x+I*M*O;break;case"ZXY":this._x=I*w*x-f*M*O,this._y=f*M*x+I*w*O,this._z=f*w*O+I*M*x,this._w=f*w*x-I*M*O;break;case"ZYX":this._x=I*w*x-f*M*O,this._y=f*M*x+I*w*O,this._z=f*w*O-I*M*x,this._w=f*w*x+I*M*O;break;case"YZX":this._x=I*w*x+f*M*O,this._y=f*M*x+I*w*O,this._z=f*w*O-I*M*x,this._w=f*w*x-I*M*O;break;case"XZY":this._x=I*w*x-f*M*O,this._y=f*M*x-I*w*O,this._z=f*w*O+I*M*x,this._w=f*w*x+I*M*O;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+c)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,a=Math.sin(n);return this._x=t.x*a,this._y=t.y*a,this._z=t.z*a,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],a=e[4],h=e[8],c=e[1],m=e[5],b=e[9],f=e[2],w=e[6],x=e[10],I=n+m+x;if(I>0){const M=.5/Math.sqrt(I+1);this._w=.25/M,this._x=(w-b)*M,this._y=(h-f)*M,this._z=(c-a)*M}else if(n>m&&n>x){const M=2*Math.sqrt(1+n-m-x);this._w=(w-b)/M,this._x=.25*M,this._y=(a+c)/M,this._z=(h+f)/M}else if(m>x){const M=2*Math.sqrt(1+m-n-x);this._w=(h-f)/M,this._x=(a+c)/M,this._y=.25*M,this._z=(b+w)/M}else{const M=2*Math.sqrt(1+x-n-m);this._w=(c-a)/M,this._x=(h+f)/M,this._y=(b+w)/M,this._z=.25*M}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<Number.EPSILON?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(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=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Br(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(n===0)return this;const a=Math.min(1,e/n);return this.slerp(t,a),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 n=t._x,a=t._y,h=t._z,c=t._w,m=e._x,b=e._y,f=e._z,w=e._w;return this._x=n*w+c*m+a*f-h*b,this._y=a*w+c*b+h*m-n*f,this._z=h*w+c*f+n*b-a*m,this._w=c*w-n*m-a*b-h*f,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const n=this._x,a=this._y,h=this._z,c=this._w;let m=c*t._w+n*t._x+a*t._y+h*t._z;if(m<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,m=-m):this.copy(t),m>=1)return this._w=c,this._x=n,this._y=a,this._z=h,this;const b=1-m*m;if(b<=Number.EPSILON){const M=1-e;return this._w=M*c+e*this._w,this._x=M*n+e*this._x,this._y=M*a+e*this._y,this._z=M*h+e*this._z,this.normalize(),this}const f=Math.sqrt(b),w=Math.atan2(f,m),x=Math.sin((1-e)*w)/f,I=Math.sin(e*w)/f;return this._w=c*x+this._w*I,this._x=n*x+this._x*I,this._y=a*x+this._y*I,this._z=h*x+this._z*I,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),a=Math.sqrt(1-n),h=Math.sqrt(n);return this.set(a*Math.sin(t),a*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 Ie=class uh{constructor(t,e,n){this.x=0,this.y=0,this.z=0;const a=+(t!==void 0)+ +(e!==void 0)+ +(n!==void 0);if(a!==0){if(a===1&&t instanceof Array){this.x=t[0],this.y=t[1],this.z=t[2];return}if(a===1){const{x:h,y:c,z:m}=t;this.x=h,this.y=c,this.z=m||0;return}if(a===3){this.x=t,this.y=e,this.z=n;return}throw Xe.ILLEGAL_PARAMETERS}}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,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 uh(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(cl.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(cl.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,a=this.z,h=t.elements;return this.x=h[0]*e+h[3]*n+h[6]*a,this.y=h[1]*e+h[4]*n+h[7]*a,this.z=h[2]*e+h[5]*n+h[8]*a,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,a=this.z,h=t.elements,c=1/(h[3]*e+h[7]*n+h[11]*a+h[15]);return this.x=(h[0]*e+h[4]*n+h[8]*a+h[12])*c,this.y=(h[1]*e+h[5]*n+h[9]*a+h[13])*c,this.z=(h[2]*e+h[6]*n+h[10]*a+h[14])*c,this}applyQuaternion(t){const e=this.x,n=this.y,a=this.z,h=t.x,c=t.y,m=t.z,b=t.w,f=2*(c*a-m*n),w=2*(m*e-h*a),x=2*(h*n-c*e);return this.x=e+b*f+c*x-m*w,this.y=n+b*w+m*f-h*x,this.z=a+b*x+h*w-c*f,this}transformDirection(t){const e=this.x,n=this.y,a=this.z,h=t.elements;return this.x=h[0]*e+h[4]*n+h[8]*a,this.y=h[1]*e+h[5]*n+h[9]*a,this.z=h[2]*e+h[6]*n+h[10]*a,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 n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}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),n=this.length(),a=t.length();return Math.abs(e)===n*a}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,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,a=t.y,h=t.z,c=e.x,m=e.y,b=e.z;return this.x=a*b-h*m,this.y=h*c-n*b,this.z=n*m-a*c,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return ha.copy(this).projectOnVector(t),this.sub(ha)}reflect(t){return this.sub(ha.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 n=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,n)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,a=this.z-t.z;return e*e+n*n+a*a}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(),n=this.setFromMatrixColumn(t,1).length(),a=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=a,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,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};Ie.ORIGIN=Object.freeze(new Ie(0,0,0)),Ie.X_AXIS=Object.freeze(new Ie(1,0,0)),Ie.NEGATIVE_X_AXIS=Object.freeze(new Ie(-1,0,0)),Ie.Y_AXIS=Object.freeze(new Ie(0,1,0)),Ie.NEGATIVE_Y_AXIS=Object.freeze(new Ie(0,-1,0)),Ie.Z_AXIS=Object.freeze(new Ie(0,0,1)),Ie.NEGATIVE_Z_AXIS=Object.freeze(new Ie(0,0,-1));let X=Ie;const ha=new X,cl=new wn,Sa=class dh{constructor(t,e,n,a,h,c,m,b,f,w,x,I,M,O,L,F){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!=null&&e!=null&&n!=null&&a!=null&&h!=null&&c!=null&&m!=null&&b!=null&&f!=null&&w!=null&&x!=null&&I!=null&&M!=null&&O!=null&&L!=null&&F!=null&&this.set(t,e,n,a,h,c,m,b,f,w,x,I,M,O,L,F)}set(t,e,n,a,h,c,m,b,f,w,x,I,M,O,L,F){const D=this.elements;return D[0]=t,D[4]=e,D[8]=n,D[12]=a,D[1]=h,D[5]=c,D[9]=m,D[13]=b,D[2]=f,D[6]=w,D[10]=x,D[14]=I,D[3]=M,D[7]=O,D[11]=L,D[15]=F,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 dh().fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[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(Ha.equalPoint3d(t,X.Z_AXIS))this.identity();else{const e=new X(1,0,0);Math.abs(t.x)<1/64&&Math.abs(t.y)<1/64?e.crossVectors(X.Y_AXIS,t).normalize():e.crossVectors(X.Z_AXIS,t).normalize();const n=t.clone().cross(e).normalize();this.set(e.x,e.y,e.z,0,n.x,n.y,n.z,0,t.x,t.y,t.z,0,0,0,0,1)}return this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,a=1/Fn.setFromMatrixColumn(t,0).length(),h=1/Fn.setFromMatrixColumn(t,1).length(),c=1/Fn.setFromMatrixColumn(t,2).length();return e[0]=n[0]*a,e[1]=n[1]*a,e[2]=n[2]*a,e[3]=0,e[4]=n[4]*h,e[5]=n[5]*h,e[6]=n[6]*h,e[7]=0,e[8]=n[8]*c,e[9]=n[9]*c,e[10]=n[10]*c,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(Vu,t,Uu)}lookAt(t,e,n){const a=this.elements;return Ve.subVectors(t,e),Ve.lengthSq()===0&&(Ve.z=1),Ve.normalize(),Kr.crossVectors(n,Ve),Kr.lengthSq()===0&&(Math.abs(n.z)===1?Ve.x+=1e-4:Ve.z+=1e-4,Ve.normalize(),Kr.crossVectors(n,Ve)),Kr.normalize(),ni.crossVectors(Ve,Kr),a[0]=Kr.x,a[4]=ni.x,a[8]=Ve.x,a[1]=Kr.y,a[5]=ni.y,a[9]=Ve.y,a[2]=Kr.z,a[6]=ni.z,a[10]=Ve.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,a=e.elements,h=this.elements,c=n[0],m=n[4],b=n[8],f=n[12],w=n[1],x=n[5],I=n[9],M=n[13],O=n[2],L=n[6],F=n[10],D=n[14],dt=n[3],vt=n[7],ot=n[11],H=n[15],ct=a[0],st=a[4],Gt=a[8],Kt=a[12],qt=a[1],wt=a[5],Bt=a[9],ge=a[13],fe=a[2],Be=a[6],re=a[10],he=a[14],Q=a[3],Nt=a[7],ce=a[11],fr=a[15];return h[0]=c*ct+m*qt+b*fe+f*Q,h[4]=c*st+m*wt+b*Be+f*Nt,h[8]=c*Gt+m*Bt+b*re+f*ce,h[12]=c*Kt+m*ge+b*he+f*fr,h[1]=w*ct+x*qt+I*fe+M*Q,h[5]=w*st+x*wt+I*Be+M*Nt,h[9]=w*Gt+x*Bt+I*re+M*ce,h[13]=w*Kt+x*ge+I*he+M*fr,h[2]=O*ct+L*qt+F*fe+D*Q,h[6]=O*st+L*wt+F*Be+D*Nt,h[10]=O*Gt+L*Bt+F*re+D*ce,h[14]=O*Kt+L*ge+F*he+D*fr,h[3]=dt*ct+vt*qt+ot*fe+H*Q,h[7]=dt*st+vt*wt+ot*Be+H*Nt,h[11]=dt*Gt+vt*Bt+ot*re+H*ce,h[15]=dt*Kt+vt*ge+ot*he+H*fr,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],n=t[4],a=t[8],h=t[12],c=t[1],m=t[5],b=t[9],f=t[13],w=t[2],x=t[6],I=t[10],M=t[14],O=t[3],L=t[7],F=t[11],D=t[15];return O*(+h*b*x-a*f*x-h*m*I+n*f*I+a*m*M-n*b*M)+L*(+e*b*M-e*f*I+h*c*I-a*c*M+a*f*w-h*b*w)+F*(+e*f*x-e*m*M-h*c*x+n*c*M+h*m*w-n*f*w)+D*(-a*m*w-e*b*x+e*m*I+a*c*x-n*c*I+n*b*w)}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,n){const a=this.elements;return t instanceof X?(a[12]=t.x,a[13]=t.y,a[14]=t.z):(a[12]=t,a[13]=e,a[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],a=t[2],h=t[3],c=t[4],m=t[5],b=t[6],f=t[7],w=t[8],x=t[9],I=t[10],M=t[11],O=t[12],L=t[13],F=t[14],D=t[15],dt=x*F*f-L*I*f+L*b*M-m*F*M-x*b*D+m*I*D,vt=O*I*f-w*F*f-O*b*M+c*F*M+w*b*D-c*I*D,ot=w*L*f-O*x*f+O*m*M-c*L*M-w*m*D+c*x*D,H=O*x*b-w*L*b-O*m*I+c*L*I+w*m*F-c*x*F,ct=e*dt+n*vt+a*ot+h*H;if(ct===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const st=1/ct;return t[0]=dt*st,t[1]=(L*I*h-x*F*h-L*a*M+n*F*M+x*a*D-n*I*D)*st,t[2]=(m*F*h-L*b*h+L*a*f-n*F*f-m*a*D+n*b*D)*st,t[3]=(x*b*h-m*I*h-x*a*f+n*I*f+m*a*M-n*b*M)*st,t[4]=vt*st,t[5]=(w*F*h-O*I*h+O*a*M-e*F*M-w*a*D+e*I*D)*st,t[6]=(O*b*h-c*F*h-O*a*f+e*F*f+c*a*D-e*b*D)*st,t[7]=(c*I*h-w*b*h+w*a*f-e*I*f-c*a*M+e*b*M)*st,t[8]=ot*st,t[9]=(O*x*h-w*L*h-O*n*M+e*L*M+w*n*D-e*x*D)*st,t[10]=(c*L*h-O*m*h+O*n*f-e*L*f-c*n*D+e*m*D)*st,t[11]=(w*m*h-c*x*h-w*n*f+e*x*f+c*n*M-e*m*M)*st,t[12]=H*st,t[13]=(w*L*a-O*x*a+O*n*I-e*L*I-w*n*F+e*x*F)*st,t[14]=(O*m*a-c*L*a-O*n*b+e*L*b+c*n*F-e*m*F)*st,t[15]=(c*x*a-w*m*a+w*n*b-e*x*b-c*n*I+e*m*I)*st,this}scale(t){const e=this.elements,n=t.x,a=t.y,h=t.z;return e[0]*=n,e[4]*=a,e[8]*=h,e[1]*=n,e[5]*=a,e[9]*=h,e[2]*=n,e[6]*=a,e[10]*=h,e[3]*=n,e[7]*=a,e[11]*=h,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],a=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,a))}makeTranslation(t,e,n){return t instanceof X?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,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),a=Math.sin(e),h=1-n,c=t.x,m=t.y,b=t.z,f=h*c,w=h*m;return this.set(f*c+n,f*m-a*b,f*b+a*m,0,f*m+a*b,w*m+n,w*b-a*c,0,f*b-a*m,w*b+a*c,h*b*b+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,a,h,c){return this.set(1,n,h,0,t,1,c,0,e,a,1,0,0,0,0,1),this}compose(t,e,n){const a=this.elements,h=e.x,c=e.y,m=e.z,b=e.w,f=h+h,w=c+c,x=m+m,I=h*f,M=h*w,O=h*x,L=c*w,F=c*x,D=m*x,dt=b*f,vt=b*w,ot=b*x,H=n.x,ct=n.y,st=n.z;return a[0]=(1-(L+D))*H,a[1]=(M+ot)*H,a[2]=(O-vt)*H,a[3]=0,a[4]=(M-ot)*ct,a[5]=(1-(I+D))*ct,a[6]=(F+dt)*ct,a[7]=0,a[8]=(O+vt)*st,a[9]=(F-dt)*st,a[10]=(1-(I+L))*st,a[11]=0,a[12]=t.x,a[13]=t.y,a[14]=t.z,a[15]=1,this}decompose(t,e,n){const a=this.elements;let h=Fn.set(a[0],a[1],a[2]).length();const c=Fn.set(a[4],a[5],a[6]).length(),m=Fn.set(a[8],a[9],a[10]).length();this.determinant()<0&&(h=-h),t.x=a[12],t.y=a[13],t.z=a[14],ir.copy(this);const b=1/h,f=1/c,w=1/m;return ir.elements[0]*=b,ir.elements[1]*=b,ir.elements[2]*=b,ir.elements[4]*=f,ir.elements[5]*=f,ir.elements[6]*=f,ir.elements[8]*=w,ir.elements[9]*=w,ir.elements[10]*=w,e.setFromRotationMatrix(ir),n.x=h,n.y=c,n.z=m,this}equals(t){const e=this.elements,n=t.elements;for(let a=0;a<16;a++)if(e[a]!==n[a])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}};Sa.IDENTITY=Object.freeze(new Sa);let Ye=Sa;const Fn=new X,ir=new Ye,Vu=new X(0,0,0),Uu=new X(1,1,1),Kr=new X,ni=new X,Ve=new X;class Ct{constructor(t=void 0,e=void 0){this.min=t==null?new X(1/0,1/0,1/0):new X(t.x,t.y,t.z),this.max=e==null?new X(-1/0,-1/0,-1/0):new X(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,n=t.length;e<n;e+=3)this.expandByPoint(ca.fromArray(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=ca.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}clone(){return new Ct().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 X(0,0,0):new X(0,0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new X(0,0,0):new X(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,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,ca).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:(xr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),xr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),xr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),xr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),xr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),xr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),xr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),xr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(xr),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 xr=[new X,new X,new X,new X,new X,new X,new X,new X],ca=new X,ul=new Jt;class xe{constructor(t=void 0,e=void 0){this.min=t==null?new Jt(1/0,1/0):new Jt(t.x,t.y),this.max=e==null?new Jt(-1/0,-1/0):new Jt(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,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=ul.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}clone(){return new xe().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 Jt(0,0):new Jt(0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new Jt(0,0):new Jt(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,ul).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 dl=new X,ju=new X,Gu=new Hi;class Zs{constructor(t=new X(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,n,a){return this.normal.set(t,e,n),this.constant=a,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const a=dl.subVectors(n,e).cross(ju.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(a,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 n=e||Gu.getNormalMatrix(t),a=this.coplanarPoint(dl).applyMatrix4(t),h=this.normal.applyMatrix3(n).normalize();return this.constant=-a.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 Zs().copy(this)}}class Tt extends Jt{static pointArrayToNumberArray(t){const e=new Array(t.length*2);return t.forEach((n,a)=>{n.toArray(e,a*2)}),e}}class G extends X{static pointArrayToNumberArray(t,e=!0){const n=e?3:2,a=new Array(t.length*n);return t.forEach((h,c)=>{h.toArray(a,c*n)}),a}}const pl=new Ye,ml=new wn,ph=class Ia{constructor(t=0,e=0,n=0,a=Ia.DEFAULT_ORDER){this._x=t,this._y=e,this._z=n,this._order=a}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,n,a=this._order){return this._x=t,this._y=e,this._z=n,this._order=a,this._onChangeCallback(),this}clone(){return new Ia(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const a=t.elements,h=a[0],c=a[4],m=a[8],b=a[1],f=a[5],w=a[9],x=a[2],I=a[6],M=a[10];switch(e){case"XYZ":this._y=Math.asin(Br(m,-1,1)),Math.abs(m)<.9999999?(this._x=Math.atan2(-w,M),this._z=Math.atan2(-c,h)):(this._x=Math.atan2(I,f),this._z=0);break;case"YXZ":this._x=Math.asin(-Br(w,-1,1)),Math.abs(w)<.9999999?(this._y=Math.atan2(m,M),this._z=Math.atan2(b,f)):(this._y=Math.atan2(-x,h),this._z=0);break;case"ZXY":this._x=Math.asin(Br(I,-1,1)),Math.abs(I)<.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(-Br(x,-1,1)),Math.abs(x)<.9999999?(this._x=Math.atan2(I,M),this._z=Math.atan2(b,h)):(this._x=0,this._z=Math.atan2(-c,f));break;case"YZX":this._z=Math.asin(Br(b,-1,1)),Math.abs(b)<.9999999?(this._x=Math.atan2(-w,f),this._y=Math.atan2(-x,h)):(this._x=0,this._y=Math.atan2(m,M));break;case"XZY":this._z=Math.asin(-Br(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(I,f),this._y=Math.atan2(m,h)):(this._x=Math.atan2(-w,M),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n=!0){return pl.makeRotationFromQuaternion(t),this.setFromRotationMatrix(pl,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return ml.setFromEuler(this),this.setFromQuaternion(ml,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}};ph.DEFAULT_ORDER="XYZ";let Wu=ph;class mh{constructor(){this._boundingBoxNeedsUpdate=!1}get boundingBoxNeedUpdate(){return this._boundingBoxNeedsUpdate}}let Ya=class extends mh{translate(t){return this.transform(new Hi().makeTranslation(t.x,t.y))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}};class qi extends Ya{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 xe}transform(t){return this._boundingBoxNeedsUpdate=!0,this}getPoints(t){const e=[];for(let n=0;n<this.loops.length;++n){const a=this.loops[n].getPoints(t);e.push(a)}return e}buildHierarchy(){var t;const e=this.getPoints(100),n=this.calculateBoundaryBoxes(e),a=this.sortBoundaryBoxesByAreas(n),h=new Map,c=a.length;for(let b=0;b<c;b++)h.set(a[b],{index:a[b],children:[]});const m={index:-1,children:[]};for(let b=0;b<c;b++){const f=a[b],w=e[f],x=n[f];let I=b+1;for(;I<c;I++){const M=a[I],O=e[M];if(n[M].containsBox(x)&&ah.isPointInPolygon(w[Pt.randInt(0,w.length-1)],O)){(t=h.get(M))==null||t.children.push(h.get(f));break}}I===c&&m.children.push(h.get(f))}return m}get area(){if(this._loops.length===0)return 0;let t=0;for(let e=0;e<this._loops.length;e++){const n=this._loops[e].getPoints(128),a=this.polygonArea(n);e===0?t+=Math.abs(a):t-=Math.abs(a)}return t}polygonArea(t){const e=t.length;if(e<3)return 0;let n=0;for(let a=0,h=e-1;a<e;h=a++){const c=t[h],m=t[a];n+=c.x*m.y-m.x*c.y}return n*.5}calculateBoundaryBoxes(t){const e=[];return t.forEach(n=>{e.push(new xe().setFromPoints(n))}),e}sortBoundaryBoxesByAreas(t){const e=[];t.forEach((a,h)=>{const c=a.size,m=c.width*c.height;e.push({area:m,index:h})}),e.sort((a,h)=>a.area-h.area);const n=[];return e.forEach(a=>{n.push(a.index)}),n}}class Zn extends Ya{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 n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){const e=[];let n,a=this.getPoint(0),h=0;e.push(0);for(let c=1;c<=t;c++)n=this.getPoint(c/t),h+=n.distanceTo(a),e.push(h),a=n;return e}getUtoTmapping(t,e){const n=this.getLengths();let a=0;const h=n.length;let c;e?c=e:c=t*n[h-1];let m=0,b=h-1,f;for(;m<=b;)if(a=Math.floor(m+(b-m)/2),f=n[a]-c,f<0)m=a+1;else if(f>0)b=a-1;else{b=a;break}if(a=b,n[a]===c)return a/(h-1);const w=n[a],x=n[a+1]-w,I=(c-w)/x;return(a+I)/(h-1)}getTangent(t){let e=t-1e-4,n=t+1e-4;e<0&&(e=0),n>1&&(n=1);const a=this.getPoint(e),h=this.getPoint(n),c=new Tt;return c.copy(h).sub(a).normalize(),c}getTangentAt(t){const e=this.getUtoTmapping(t);return this.getTangent(e)}}class Wn extends Zn{constructor(t,e,n,a,h){super();const c=+(t!==void 0)+ +(e!==void 0)+ +(n!==void 0)+ +(a!==void 0)+ +(h!==void 0);if(c==3)typeof t=="object"&&typeof e=="object"&&typeof n=="object"?this.createByThreePoints(t,e,n):this.createByStartEndPointsAndBulge(t,e,n);else if(c==5){const m=t;this.center=new Tt(m.x,m.y),this.radius=e,this._clockwise=h,this._startAngle=this._clockwise?this._mirrorAngle(Pt.normalizeAngle(n)):Pt.normalizeAngle(n),this._endAngle=this._clockwise?this._mirrorAngle(Pt.normalizeAngle(a)):Pt.normalizeAngle(a)}else throw Xe.ILLEGAL_PARAMETERS}createByThreePoints(t,e,n){const a=(st,Gt)=>({x:(st.x+Gt.x)/2,y:(st.y+Gt.y)/2}),h=(st,Gt)=>(Gt.y-st.y)/(Gt.x-st.x),c=st=>-1/st,m=a(t,e),b=a(e,n),f=h(t,e),w=h(e,n),x=c(f),I=c(w),M=(st,Gt,Kt,qt)=>{const wt=(qt-Gt)/(st-Kt),Bt=st*wt+Gt;return{x:wt,y:Bt}},O=m.y-x*m.x,L=b.y-I*b.x,F=M(x,O,I,L),D=Math.sqrt(Math.pow(t.x-F.x,2)+Math.pow(t.y-F.y,2)),dt=(st,Gt)=>Math.atan2(st.y-Gt.y,st.x-Gt.x),vt=dt(t,F),ot=dt(e,F),H=dt(n,F),ct=H>vt&&H<ot||vt>H&&vt<ot||ot>H&&ot<vt;this.center=F,this.radius=D,this._clockwise=!ct,this._startAngle=vt,this._endAngle=H}createByStartEndPointsAndBulge(t,e,n){let a,h,c;n<0?(a=Math.atan(-n)*4,h=new Jt(t),c=new Jt(e)):(a=Math.atan(n)*4,h=new Jt(e),c=new Jt(t));const m=new Jt().subVectors(c,h),b=m.length(),f=new Jt().addVectors(h,m.multiplyScalar(.5)),w=Math.abs(b/2/Math.tan(a/2)),x=m.normalize();let I;if(a<Math.PI){const M=new Jt(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));I=f.add(M.multiplyScalar(-w))}else{const M=new Jt(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));I=f.add(M.multiplyScalar(w))}n<0?(this._startAngle=Math.atan2(h.y-I.y,h.x-I.x),this._endAngle=Math.atan2(c.y-I.y,c.x-I.x)):(this._startAngle=Math.atan2(c.y-I.y,c.x-I.x),this._endAngle=Math.atan2(h.y-I.y,h.x-I.x)),this._clockwise=n<0,this.center=I,this.radius=c.sub(I).length()}get center(){return this._center}set center(t){this._center=new Tt(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(Pt.normalizeAngle(t)):Pt.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==Zt?t:Pt.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?Pt.normalizeAngle(t-e):Pt.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),n=Pt.normalizeAngle((t+e)/2),a=this._clockwise?this._mirrorAngle(n):n;return this.getPointAtAngle(a)}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);Pt.isBetweenAngle(c,this._getInternalAngle(this.startAngle),this._getInternalAngle(this.endAngle),this.clockwise)&&t.push(this.getPointAtAngle(h))}const n=t.map(h=>h.x),a=t.map(h=>h.y);return new xe(new Tt(Math.min(...n),Math.min(...a)),new Tt(Math.max(...n),Math.max(...a)))}get length(){return Math.abs(this.deltaAngle*this.radius)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}clone(){return new Wn(this.center.clone(),this.radius,this._startAngle,this._endAngle,this.clockwise)}getPointAtAngle(t){const e=this._getInternalAngle(t),n=this.center.x+this.radius*Math.cos(e),a=this.center.y+this.radius*Math.sin(e);return new Tt(n,a)}getPoints(t=100){const e=[];let n=this.deltaAngle,a=this._getInternalAngle(this.startAngle);if(this.closed&&(n=Zt,a=0),this.clockwise)for(let h=0;h<=t;h++){const c=a-n*(h/t),m=this._clockwise?this._mirrorAngle(c):c,b=this.getPointAtAngle(m);e.push(new Tt(b.x,b.y))}else for(let h=0;h<=t;h++){const c=a+n*(h/t),m=this._clockwise?this._mirrorAngle(c):c,b=this.getPointAtAngle(m);e.push(new Tt(b.x,b.y))}return e}}class Hu extends mh{translate(t){return this.transform(new Ye().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 Qs extends Hu{}let Hn=class gh extends Qs{constructor(t,e){super(),this._start=new G(t),this._end=new G(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 X().subVectors(this.endPoint,this.startPoint).normalize()}get midPoint(){return new G((this._start.x+this._end.x)/2,(this._start.y+this._end.y)/2,(this._start.z+this._end.z)/2)}nearestPoint(t){return this.project(t)}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 n=this.delta(on).normalize();return new G(this._start).addScaledVector(n,t)}else{const n=this.delta(on).normalize();return new G(this._end).addScaledVector(n,t)}}extend(t,e=!1){if(e){const n=on.subVectors(this._start,this._end).normalize();this._start=new G(this._start).addScaledVector(n,t)}else{const n=this.delta(on).normalize();this._end=new G(this._end).addScaledVector(n,t)}return this._boundingBoxNeedsUpdate=!0,this}closestPointToPointParameter(t,e){gl.subVectors(t,this._start),si.subVectors(this.endPoint,this.startPoint);const n=si.dot(si);let a=si.dot(gl)/n;return e&&(a=Pt.clamp(a,0,1)),a}closestPointToPoint(t,e,n){const a=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(a).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,n=on.subVectors(t,this.startPoint).dot(e);return new G().copy(e).multiplyScalar(n).add(this.startPoint)}perpPoint(t){const e=this.direction,n=this.startPoint,a=on.subVectors(t,n).dot(e),h=on.copy(e).multiplyScalar(a);return new G().addVectors(n,h)}calculateBoundingBox(){const t=new G(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 G(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 Ct(t,e)}transform(t){return this._start.applyMatrix4(t),this._end.applyMatrix4(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 gh(this._start.clone(),this._end.clone())}};const on=new X,gl=new X,si=new X;let Xa=class ci extends Qs{static computeCenterPoint(t,e,n){const a=new X().addVectors(t,e).multiplyScalar(.5),h=new X().addVectors(t,n).multiplyScalar(.5),c=new X().subVectors(e,t),m=new X().subVectors(n,t),b=new X().crossVectors(c,m).normalize();if(b.lengthSq()===0)return console.error("Points are collinear and cannot form a valid arc."),null;const f=new X().crossVectors(c,b).normalize(),w=new X().crossVectors(m,b).normalize(),x=f.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),I=w.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),M=new Hn(a,a.clone().add(x)),O=new Hn(h,h.clone().add(I)),L=new X;return M.closestPointToPoint(O.startPoint,!0,L)?L:(console.error("Cannot find a valid center for the arc."),null)}static createByThreePoints(t,e,n){const a=ci.computeCenterPoint(t,e,n);if(a){const h=a.distanceTo(t),c=new X().subVectors(t,a),m=new X().subVectors(e,a),b=Math.atan2(c.y,c.x),f=Math.atan2(m.y,m.x);return new ci(a,h,b,f,X.Z_AXIS)}}constructor(t,e,n,a,h,c=X.X_AXIS){super(),this.center=t,this.radius=e,this.startAngle=n,this.endAngle=a,this.normal=h,this.refVec=c,(a-n)%Zt==0?(this.startAngle=0,this.endAngle=Zt):(this.startAngle=n,this.endAngle=a)}get center(){return this._center}set center(t){this._center=new G(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){if(t<0)throw Xe.ILLEGAL_PARAMETERS;this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=Pt.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==Zt?t:Pt.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return Pt.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 X(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get refVec(){return this._refVec}set refVec(t){this._refVec=new X(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 midPoint(){let t=this.startAngle,e=this.deltaAngle;this.closed&&(t=0,e=Zt);const n=t+e*.5;return this.getPointAtAngle(n)}get length(){return this.closed?2*Math.PI*this.radius:Math.abs(this.deltaAngle*this.radius)}get area(){return this.closed?Math.PI*this.radius*this.radius:Math.abs(this.deltaAngle*this.radius*this.radius)}nearestPoint(t){const e=new X(t.x,t.y,t.z||0),n=this.center,a=this.normal,h=e.clone().sub(n).dot(a),c=e.clone().sub(a.clone().multiplyScalar(h)).clone().sub(n);if(c.lengthSq()===0)return this.startPoint.clone();c.normalize().multiplyScalar(this.radius);const m=n.clone().add(c),b=this.getAngle(m.clone()),f=this.startAngle,w=this.deltaAngle;let x=Pt.normalizeAngle(b-f);x<0&&(x=0),x>w&&(x=w);const I=this.getPointAtAngle(f+x),M=I.distanceTo(e),O=this.startPoint.distanceTo(e),L=this.endPoint.distanceTo(e);return O<M&&O<=L?this.startPoint.clone():L<M&&L<O?this.endPoint.clone():I}tangentPoints(t){const e=[],n=new X(t.x,t.y,t.z||0),a=this.center,h=this.normal,c=this.radius,m=n.clone().sub(a).dot(h),b=n.clone().sub(h.clone().multiplyScalar(m)),f=a.clone(),w=b.clone().sub(f).length();if(w<c)return e;const x=Math.acos(c/w),I=this.getAngle(b.clone()),M=[I+x,I-x];for(const O of M){const L=Pt.normalizeAngle(O-this.startAngle);L>=0&&L<=this.deltaAngle&&e.push(this.getPointAtAngle(this.startAngle+L))}return e}nearestTangentPoint(t){const e=this.tangentPoints(t);if(e.length===0)return null;const n=new G(t.x,t.y,t.z||0);return e.length===1||e[0].distanceTo(n)<e[1].distanceTo(n)?e[0]:e[1]}calculateBoundingBox(){const t=[this.startAngle,this.endAngle];for(let b=0;b<2*Math.PI;b+=Math.PI/2)Pt.isBetweenAngle(b,this.startAngle,this.endAngle)&&t.push(b);let e=1/0,n=1/0,a=1/0,h=-1/0,c=-1/0,m=-1/0;for(const b of t){const f=this.getPointAtAngle(b);f.x<e&&(e=f.x),f.y<n&&(n=f.y),f.z<a&&(a=f.z),f.x>h&&(h=f.x),f.y>c&&(c=f.y),f.z>m&&(m=f.z)}return new Ct({x:e,y:n,z:a},{x:h,y:c,z:m})}get closed(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0}getPoints(t){const e=[];let n=this.deltaAngle,a=this.startAngle;this.closed&&(n=Zt,a=0);for(let h=0;h<=t;h++){const c=a+n*(h/t),m=this.getPointAtAngle(c);e.push(m)}return e}transform(t){const e=ua.copy(this.refVec).applyAxisAngle(this.normal,this.startAngle).multiplyScalar(this.radius),n=ua.copy(this.refVec).applyAxisAngle(this.normal,this.endAngle).multiplyScalar(this.radius);return this.center.applyMatrix4(t),e.applyMatrix4(t),n.applyMatrix4(t),this.normal.applyMatrix4(t).normalize(),this.refVec.applyMatrix4(t).normalize(),this.startAngle=this.getAngle(e),this.endAngle=this.getAngle(n),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 ci(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)}getAngle(t){return t.sub(this.center),Math.atan2(t.dot(ua.crossVectors(this.refVec,this.normal)),t.dot(this.refVec))}getPointAtAngle(t){const e=this.normal,n=this.refVec,a={x:e.y*n.z-e.z*n.y,y:e.z*n.x-e.x*n.z,z:e.x*n.y-e.y*n.x},h=this.center,c=this.radius;return new G(h.x+c*(n.x*Math.cos(t)+a.x*Math.sin(t)),h.y+c*(n.y*Math.cos(t)+a.y*Math.sin(t)),h.z+c*(n.z*Math.cos(t)+a.z*Math.sin(t)))}get plane(){const t=new X(this.center).distanceTo(Ga);return new Zs(this.normal,t)}};const ua=new X;class Yi extends Zn{constructor(t,e,n,a=0,h=Zt,c=!1,m=0){super(),this.center=t,this.majorAxisRadius=e,this.minorAxisRadius=n,(h-a)%Zt==0?(this.startAngle=0,this.endAngle=Zt):(this.startAngle=a,this.endAngle=h),this.clockwise=c,this.rotation=m}get center(){return this._center}set center(t){this._center=new G(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw Xe.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw Xe.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=Pt.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==Zt?t:Pt.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 Pt.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}calculateBoundingBox(){let t=1/0,e=1/0,n=-1/0,a=-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),n=Math.max(n,c.x),a=Math.max(a,c.y)}return new xe({x:t,y:e},{x:n,y:a})}get closed(){return this.deltaAngle==0}getPoint(t){const e=Math.PI*2;let n=this.endAngle-this.startAngle;const a=Math.abs(n)<Number.EPSILON;for(;n<0;)n+=e;for(;n>e;)n-=e;n<Number.EPSILON&&(a?n=0:n=e),this.clockwise===!0&&!a&&(n===e?n=-e:n=n-e);const h=this.startAngle+t*n;let c=this.center.x+this.majorAxisRadius*Math.cos(h),m=this.center.y+this.minorAxisRadius*Math.sin(h);if(this.rotation!==0){const b=Math.cos(this.rotation),f=Math.sin(this.rotation),w=c-this.center.x,x=m-this.center.y;c=w*b-x*f+this.center.x,m=w*f+x*b+this.center.y}return new Tt(c,m)}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 Yi(this.center,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle,this.clockwise,this.rotation)}}class Xi extends Qs{constructor(t,e,n,a,h,c=0,m=Zt){super(),this.center=t,this.normal=e,this.majorAxis=n,this.majorAxisRadius=a,this.minorAxisRadius=h;const b=Math.abs(m-c);Math.abs(b-Zt)<1e-10||Math.abs(b-2*Zt)<1e-10?(this.startAngle=0,this.endAngle=Zt):(this.startAngle=c,this.endAngle=m)}get center(){return this._center}set center(t){this._center=new G(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw Xe.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw Xe.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=Pt.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==Zt?t:Pt.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){const t=this.endAngle-this.startAngle;return Math.abs(t-Zt)<1e-10?Zt:Pt.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 X(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get majorAxis(){return this._majorAxis}set majorAxis(t){this._majorAxis=new X(t.x,t.y,t.z),this._majorAxis.normalize(),this._boundingBoxNeedsUpdate=!0}get minorAxis(){return new X().crossVectors(this.normal,this.majorAxis).normalize()}get startPoint(){return this.getPointAtAngle(this._startAngle)}get endPoint(){return this.getPointAtAngle(this._endAngle)}get midPoint(){let t=this.startAngle,e=this.deltaAngle;(this.closed||Math.abs(e-Zt)<1e-10)&&(t=0,e=Zt);const n=t+e/2;return this.getPointAtAngle(n)}get isCircular(){return Wa.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 n=0,a=this.getPointAtAngle(this.startAngle);for(let h=1;h<=t;h++){const c=this.startAngle+h*e,m=this.getPointAtAngle(c),b=m.x-a.x,f=m.y-a.y,w=m.z-a.z;n+=Math.sqrt(b*b+f*f+w*w),a=m}return n}get area(){const t=this.majorAxisRadius,e=this.minorAxisRadius,n=this.startAngle,a=n+this.deltaAngle;if(Math.abs(this.deltaAngle-Zt)<1e-10)return Math.PI*t*e;const h=t*e/2*(a-n-(Math.sin(a)*Math.cos(a)-Math.sin(n)*Math.cos(n)));return Math.abs(h)}calculateBoundingBox(){if(this.majorAxis.equals(X.X_AXIS)||this.majorAxis.equals(X.Y_AXIS)||this.majorAxis.isParallelTo(X.X_AXIS)||this.majorAxis.isParallelTo(X.Y_AXIS)){const t=[this.startAngle,this.endAngle];for(let b=0;b<2*Math.PI;b+=Math.PI/2)Pt.isBetweenAngle(b,this.startAngle,this.endAngle)&&t.push(b);let e=1/0,n=1/0,a=1/0,h=-1/0,c=-1/0,m=-1/0;for(const b of t){const f=this.getPointAtAngle(b);f.x<e&&(e=f.x),f.y<n&&(n=f.y),f.z<a&&(a=f.z),f.x>h&&(h=f.x),f.y>c&&(c=f.y),f.z>m&&(m=f.z)}return new Ct({x:e,y:n,z:a},{x:h,y:c,z:m})}else{let t=1/0,e=1/0,n=1/0,a=-1/0,h=-1/0,c=-1/0;for(let m=0;m<=100;m++){const b=this.startAngle+this.deltaAngle*(m/100),f=this.getPointAtAngle(b);t=Math.min(t,f.x),e=Math.min(e,f.y),n=Math.min(n,f.z),a=Math.max(a,f.x),h=Math.max(h,f.y),c=Math.max(c,f.z)}return new Ct({x:t,y:e,z:n},{x:a,y:h,z:c})}}get closed(){return this.deltaAngle==0}getPoints(t=100){const e=[];let n=this.deltaAngle,a=this.startAngle;this.closed&&(n=Zt,a=0);for(let h=0;h<=t;h++){const c=a+n*(h/t),m=this.getPointAtAngle(c);e.push(m)}return e}getPointAtAngle(t){const e=Math.cos(t),n=Math.sin(t),a=this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(n),h=this.majorAxis.clone().multiplyScalar(e*this.majorAxisRadius).add(a);return new G(this.center.x+h.x,this.center.y+h.y,this.center.z+h.z)}contains(t){const e=new X(t).sub(this.center),n=e.dot(this.majorAxis),a=e.dot(this.minorAxis),h=n/this.majorAxisRadius,c=a/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 X(this.center).distanceTo(Ga);return new Zs(this.normal,t)}}class An extends Zn{constructor(t=null,e=!1){super(),this._vertices=t||new Array,this._closed=e}get vertices(){return this._vertices}get numberOfVertices(){return this._vertices.length}get closed(){return this._closed}get startPoint(){if(this.numberOfVertices>0){const t=this._vertices[0];return new Tt(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 Tt(e.x,e.y)}else{const e=this._vertices[t-1];return new Tt(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 n=0;n<e;++n){const a=this._vertices[n];let h=null;if(n<e-1?h=this._vertices[n+1]:n==e-1&&this.closed&&(h=this._vertices[0]),h)if(a.bulge){const c=new Wn(a,h,a.bulge);t+=c.length}else t+=new Tt(a.x,a.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 Tt(e.x,e.y)}calculateBoundingBox(){const t=this.getPoints(100);return new xe().setFromPoints(t)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}getPoints3d(t,e){const n=[];return this.getPoints(t).forEach(a=>n.push(new G().set(a.x,a.y,e))),n}getPoints(t){const e=[],n=this._vertices.length;for(let a=0;a<n;++a){const h=this._vertices[a];if(h.bulge){let c=null;if(a<n-1?c=this._vertices[a+1]:a==n-1&&this.closed&&(c=this._vertices[0]),c){const m=new Wn(h,c,h.bulge).getPoints(t),b=m.length;for(let f=0;f<b;++f){const w=m[f];e.push(new Tt(w.x,w.y))}}}else e.push(new Tt(h.x,h.y)),a==n-1&&this.closed&&e.push(e[0])}return e}}let Us=class fh extends Zn{constructor(t,e){super(),this._start=new Tt(t),this._end=new Tt(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 Tt(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y)),e=new Tt(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y));return new xe(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 fh(this._start.clone(),this._end.clone())}},Ka=class extends Zn{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 Tt(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 xe;return e.setFromPoints(t),e}transform(t){return this._boundingBoxNeedsUpdate=!0,this}get closed(){return!0}getPoints(t){const e=[];return this.curves.forEach(n=>{n.getPoints(t).forEach(a=>{e.push(new Tt(a.x,a.y))})}),e}};function qu(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var _h={exports:{}};(function(i,t){(function(e){i.exports=e()})(function(){var e={},n=this;new Function("try {return this===window;}catch(e){ return false;}");var a=new Function("try {return this===global;}catch(e){return false;}"),h=new Function("try {return typeof importScripts === 'function';}catch(e){return false;}");if(a()&&h(),a()||h()){var c=n;if(h()){var m=function(b,f){var w=n;return b.split(".").forEach(function(x){w&&(w=w[x])}),w?w[f]:null};onmessage=function(b){if(!(!b.data.className||!b.data.methodName)){var f=m(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,w){f.geom=f.geom||{},f.exe=f.exe||{},f.eval=f.eval||{},f.core=f.core||{},f.promhx=f.promhx||{};var x={},I=function(){return Nt.__string_rec(this,"")};function M(r,s){function o(){}o.prototype=r;var l=new o;for(var u in s)l[u]=s[u];return s.toString!==Object.prototype.toString&&(l.toString=s.toString),l}var O=function(){};x.HxOverrides=O,O.__name__=["HxOverrides"],O.strDate=function(r){var s=r.length;switch(s){case 8:var o=r.split(":"),l=new Date;return l.setTime(0),l.setUTCHours(o[0]),l.setUTCMinutes(o[1]),l.setUTCSeconds(o[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(" "),g=d[0].split("-"),_=d[1].split(":");return new Date(g[0],g[1]-1,g[2],_[0],_[1],_[2]);default:throw new Q("Invalid date format : "+r)}},O.cca=function(r,s){var o=r.charCodeAt(s);if(o==o)return o},O.substr=function(r,s,o){return s!=null&&s!=0&&o!=null&&o<0?"":(o==null&&(o=r.length),s<0?(s=r.length+s,s<0&&(s=0)):o<0&&(o=r.length+o-s),r.substr(s,o))},O.iter=function(r){return{cur:0,arr:r,hasNext:function(){return this.cur<this.arr.length},next:function(){return this.arr[this.cur++]}}};var L=function(){};x.Lambda=L,L.__name__=["Lambda"],L.fold=function(r,s,o){for(var l=tr(r)();l.hasNext();){var u=l.next();o=s(u,o)}return o};var F=function(){this.length=0};x.List=F,F.__name__=["List"],F.prototype={add:function(r){var s=[r];this.h==null?this.h=s:this.q[1]=s,this.q=s,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__:F},Math.__name__=["Math"];var D=function(){};x.Reflect=D,D.__name__=["Reflect"],D.field=function(r,s){try{return r[s]}catch(o){return o instanceof Q&&(o=o.val),null}},D.callMethod=function(r,s,o){return s.apply(r,o)},D.fields=function(r){var s=[];if(r!=null){var o=Object.prototype.hasOwnProperty;for(var l in r)l!="__id__"&&l!="hx__closures__"&&o.call(r,l)&&s.push(l)}return s},D.isFunction=function(r){return typeof r=="function"&&!(r.__name__||r.__ename__)},D.deleteField=function(r,s){return Object.prototype.hasOwnProperty.call(r,s)?(delete r[s],!0):!1};var dt=function(){};x.Std=dt,dt.__name__=["Std"],dt.string=function(r){return Nt.__string_rec(r,"")},dt.parseFloat=function(r){return parseFloat(r)};var vt=function(){this.b=""};x.StringBuf=vt,vt.__name__=["StringBuf"],vt.prototype={add:function(r){this.b+=dt.string(r)},__class__:vt};var ot=function(){};x.StringTools=ot,ot.__name__=["StringTools"],ot.fastCodeAt=function(r,s){return r.charCodeAt(s)};var H=x.ValueType={__ename__:["ValueType"],__constructs__:["TNull","TInt","TFloat","TBool","TObject","TFunction","TClass","TEnum","TUnknown"]};H.TNull=["TNull",0],H.TNull.toString=I,H.TNull.__enum__=H,H.TInt=["TInt",1],H.TInt.toString=I,H.TInt.__enum__=H,H.TFloat=["TFloat",2],H.TFloat.toString=I,H.TFloat.__enum__=H,H.TBool=["TBool",3],H.TBool.toString=I,H.TBool.__enum__=H,H.TObject=["TObject",4],H.TObject.toString=I,H.TObject.__enum__=H,H.TFunction=["TFunction",5],H.TFunction.toString=I,H.TFunction.__enum__=H,H.TClass=function(r){var s=["TClass",6,r];return s.__enum__=H,s.toString=I,s},H.TEnum=function(r){var s=["TEnum",7,r];return s.__enum__=H,s.toString=I,s},H.TUnknown=["TUnknown",8],H.TUnknown.toString=I,H.TUnknown.__enum__=H;var ct=function(){};x.Type=ct,ct.__name__=["Type"],ct.getClassName=function(r){var s=r.__name__;return s==null?null:s.join(".")},ct.getEnumName=function(r){var s=r.__ename__;return s.join(".")},ct.resolveClass=function(r){var s=x[r];return s==null||!s.__name__?null:s},ct.resolveEnum=function(r){var s=x[r];return s==null||!s.__ename__?null:s},ct.createEmptyInstance=function(r){function s(){}return s.prototype=r.prototype,new s},ct.createEnum=function(r,s,o){var l=D.field(r,s);if(l==null)throw new Q("No such constructor "+s);if(D.isFunction(l)){if(o==null)throw new Q("Constructor "+s+" need parameters");return D.callMethod(r,l,o)}if(o!=null&&o.length!=0)throw new Q("Constructor "+s+" does not need parameters");return l},ct.getEnumConstructs=function(r){var s=r.__constructs__;return s.slice()},ct.typeof=function(r){var s=typeof r;switch(s){case"boolean":return H.TBool;case"string":return H.TClass(String);case"number":return Math.ceil(r)==r%2147483648?H.TInt:H.TFloat;case"object":if(r==null)return H.TNull;var o=r.__enum__;if(o!=null)return H.TEnum(o);var l=Nt.getClass(r);return l!=null?H.TClass(l):H.TObject;case"function":return r.__name__||r.__ename__?H.TObject:H.TFunction;case"undefined":return H.TNull;default:return H.TUnknown}};var st=function(){};x["haxe.IMap"]=st,st.__name__=["haxe","IMap"];var Gt=function(r,s){this.high=r,this.low=s};x["haxe._Int64.___Int64"]=Gt,Gt.__name__=["haxe","_Int64","___Int64"],Gt.prototype={__class__:Gt};var Kt=function(){this.buf=new vt,this.cache=[],this.useCache=Kt.USE_CACHE,this.useEnumIndex=Kt.USE_ENUM_INDEX,this.shash=new fe,this.scount=0};x["haxe.Serializer"]=Kt,Kt.__name__=["haxe","Serializer"],Kt.prototype={toString:function(){return this.buf.b},serializeString:function(r){var s=this.shash.get(r);if(s!=null){this.buf.b+="R",s==null?this.buf.b+="null":this.buf.b+=""+s;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 s=typeof r,o=0,l=this.cache.length;o<l;){var u=o++,d=this.cache[u];if(typeof d==s&&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 s=0,o=D.fields(r);s<o.length;){var l=o[s];++s,this.serializeString(l),this.serialize(D.field(r,l))}this.buf.b+="g"},serialize:function(r){{var s=ct.typeof(r);switch(s[1]){case 0:this.buf.b+="n";break;case 1:var o=r;if(o==0){this.buf.b+="z";return}this.buf.b+="i",o==null?this.buf.b+="null":this.buf.b+=""+o;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=s[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 g=r.length,_=0;_<g;){var y=_++;r[y]==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[y]))}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 F:this.buf.b+="l";for(var A=r,S=A.h,P=null;S!=null;){var E;P=S[0],S=S[1],E=P,this.serialize(E)}this.buf.b+="h";break;case Date:var k=r;this.buf.b+="v",this.buf.add(k.getTime());break;case fe:this.buf.b+="b";for(var T=r,B=T.keys();B.hasNext();){var N=B.next();this.serializeString(N),this.serialize(ea[N]!=null?T.getReserved(N):T.h[N])}this.buf.b+="h";break;case wt:this.buf.b+="q";for(var R=r,z=R.keys();z.hasNext();){var V=z.next();this.buf.b+=":",V==null?this.buf.b+="null":this.buf.b+=""+V,this.serialize(R.h[V])}this.buf.b+="h";break;case Bt:this.buf.b+="M";for(var U=r,Y=U.keys();Y.hasNext();){var J=Y.next(),q=D.field(J,"__id__");D.deleteField(J,"__id__"),this.serialize(J),J.__id__=q,this.serialize(U.h[J.__id__])}this.buf.b+="h";break;case Be:for(var j=r,$=0,tt=j.length-2,et=new vt,it=Kt.BASE64;$<tt;){var ht=j.get($++),at=j.get($++),ut=j.get($++);et.add(it.charAt(ht>>2)),et.add(it.charAt((ht<<4|at>>4)&63)),et.add(it.charAt((at<<2|ut>>6)&63)),et.add(it.charAt(ut&63))}if($==tt){var nt=j.get($++),mt=j.get($++);et.add(it.charAt(nt>>2)),et.add(it.charAt((nt<<4|mt>>4)&63)),et.add(it.charAt(mt<<2&63))}else if($==tt+1){var K=j.get($++);et.add(it.charAt(K>>2)),et.add(it.charAt(K<<4&63))}var ft=et.b;this.buf.b+="s",ft.length==null?this.buf.b+="null":this.buf.b+=""+ft.length,this.buf.b+=":",ft==null?this.buf.b+="null":this.buf.b+=""+ft;break;default:this.useCache&&this.cache.pop(),r.hxSerialize!=null?(this.buf.b+="C",this.serializeString(ct.getClassName(u)),this.useCache&&this.cache.push(r),r.hxSerialize(this),this.buf.b+="g"):(this.buf.b+="c",this.serializeString(ct.getClassName(u)),this.useCache&&this.cache.push(r),this.serializeFields(r))}break;case 4:if(Nt.__instanceof(r,Yo)){var Et=ct.getClassName(r);this.buf.b+="A",this.serializeString(Et)}else if(Nt.__instanceof(r,Xo))this.buf.b+="B",this.serializeString(ct.getEnumName(r));else{if(this.useCache&&this.serializeRef(r))return;this.buf.b+="o",this.serializeFields(r)}break;case 7:var Ht=s[2];if(this.useCache){if(this.serializeRef(r))return;this.cache.pop()}this.useEnumIndex?this.buf.b+="j":this.buf.b+="w",this.serializeString(ct.getEnumName(Ht)),this.useEnumIndex?(this.buf.b+=":",this.buf.b+=dt.string(r[1])):this.serializeString(r[0]),this.buf.b+=":";var $t=r.length;this.buf.b+=dt.string($t-2);for(var Ut=2;Ut<$t;){var Qt=Ut++;this.serialize(r[Qt])}this.useCache&&this.cache.push(r);break;case 5:throw new Q("Cannot serialize function");default:throw new Q("Cannot serialize "+dt.string(r))}}},__class__:Kt};var qt=function(r){this.buf=r,this.length=r.length,this.pos=0,this.scache=[],this.cache=[];var s=qt.DEFAULT_RESOLVER;s==null&&(s=ct,qt.DEFAULT_RESOLVER=s),this.setResolver(s)};x["haxe.Unserializer"]=qt,qt.__name__=["haxe","Unserializer"],qt.initCodes=function(){for(var r=[],s=0,o=qt.BASE64.length;s<o;){var l=s++;r[qt.BASE64.charCodeAt(l)]=l}return r},qt.prototype={setResolver:function(r){r==null?this.resolver={resolveClass:function(s){return null},resolveEnum:function(s){return null}}:this.resolver=r},get:function(r){return this.buf.charCodeAt(r)},readDigits:function(){for(var r=0,s=!1,o=this.pos;;){var l=this.buf.charCodeAt(this.pos);if(l!=l)break;if(l==45){if(this.pos!=o)break;s=!0,this.pos++;continue}if(l<48||l>57)break;r=r*10+(l-48),this.pos++}return s&&(r*=-1),r},readFloat:function(){for(var r=this.pos;;){var s=this.buf.charCodeAt(this.pos);if(s>=43&&s<58||s==101||s==69)this.pos++;else break}return dt.parseFloat(O.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 s=this.unserialize();if(typeof s!="string")throw new Q("Invalid object key");var o=this.unserialize();r[s]=o}this.pos++},unserializeEnum:function(r,s){if(this.get(this.pos++)!=58)throw new Q("Invalid enum format");var o=this.readDigits();if(o==0)return ct.createEnum(r,s);for(var l=[];o-- >0;)l.push(this.unserialize());return ct.createEnum(r,s,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 s=this.readDigits();if(this.get(this.pos++)!=58||this.length-this.pos<s)throw new Q("Invalid string length");var o=O.substr(this.buf,this.pos,s);return this.pos+=s,o=decodeURIComponent(o.split("+").join(" ")),this.scache.push(o),o;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 g={};return this.cache.push(g),this.unserializeObject(g),g;case 114:var _=this.readDigits();if(_<0||_>=this.cache.length)throw new Q("Invalid reference");return this.cache[_];case 82:var y=this.readDigits();if(y<0||y>=this.scache.length)throw new Q("Invalid string reference");return this.scache[y];case 120:throw new Q(this.unserialize());case 99:var A=this.unserialize(),S=this.resolver.resolveClass(A);if(S==null)throw new Q("Class not found "+A);var P=ct.createEmptyInstance(S);return this.cache.push(P),this.unserializeObject(P),P;case 119:var E=this.unserialize(),k=this.resolver.resolveEnum(E);if(k==null)throw new Q("Enum not found "+E);var T=this.unserializeEnum(k,this.unserialize());return this.cache.push(T),T;case 106:var B=this.unserialize(),N=this.resolver.resolveEnum(B);if(N==null)throw new Q("Enum not found "+B);this.pos++;var R=this.readDigits(),z=ct.getEnumConstructs(N)[R];if(z==null)throw new Q("Unknown enum index "+B+"@"+R);var V=this.unserializeEnum(N,z);return this.cache.push(V),V;case 108:var U=new F;for(this.cache.push(U),this.buf;this.buf.charCodeAt(this.pos)!=104;)U.add(this.unserialize());return this.pos++,U;case 98:var Y=new fe;for(this.cache.push(Y),this.buf;this.buf.charCodeAt(this.pos)!=104;){var J=this.unserialize();Y.set(J,this.unserialize())}return this.pos++,Y;case 113:var q=new wt;this.cache.push(q),this.buf;for(var j=this.get(this.pos++);j==58;){var $=this.readDigits();q.set($,this.unserialize()),j=this.get(this.pos++)}if(j!=104)throw new Q("Invalid IntMap format");return q;case 77:var tt=new Bt;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 it;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 ht=O.substr(this.buf,this.pos,19);it=O.strDate(ht),this.pos+=19}else{var at=this.readFloat(),ut=new Date;ut.setTime(at),it=ut}return this.cache.push(it),it;case 115:var nt=this.readDigits(),mt=this.buf;if(this.get(this.pos++)!=58||this.length-this.pos<nt)throw new Q("Invalid bytes length");var K=qt.CODES;K==null&&(K=qt.initCodes(),qt.CODES=K);var ft=this.pos,Et=nt&3,Ht;Ht=(nt>>2)*3+(Et>=2?Et-1:0);for(var $t=ft+(nt-Et),Ut=Be.alloc(Ht),Qt=0;ft<$t;){var Ce=K[ot.fastCodeAt(mt,ft++)],Ze=K[ot.fastCodeAt(mt,ft++)];Ut.set(Qt++,Ce<<2|Ze>>4);var we=K[ot.fastCodeAt(mt,ft++)];Ut.set(Qt++,Ze<<4|we>>2);var ye=K[ot.fastCodeAt(mt,ft++)];Ut.set(Qt++,we<<6|ye)}if(Et>=2){var Ne=K[ot.fastCodeAt(mt,ft++)],Fe=K[ot.fastCodeAt(mt,ft++)];if(Ut.set(Qt++,Ne<<2|Fe>>4),Et==3){var er=K[ot.fastCodeAt(mt,ft++)];Ut.set(Qt++,Fe<<4|er>>2)}}return this.pos+=nt,this.cache.push(Ut),Ut;case 67:var pr=this.unserialize(),rr=this.resolver.resolveClass(pr);if(rr==null)throw new Q("Class not found "+pr);var nr=ct.createEmptyInstance(rr);if(this.cache.push(nr),nr.hxUnserialize(this),this.get(this.pos++)!=103)throw new Q("Invalid custom data");return nr;case 65:var sr=this.unserialize(),vr=this.resolver.resolveClass(sr);if(vr==null)throw new Q("Class not found "+sr);return vr;case 66:var Rn=this.unserialize(),nn=this.resolver.resolveEnum(Rn);if(nn==null)throw new Q("Enum not found "+Rn);return nn}throw this.pos--,new Q("Invalid char "+this.buf.charAt(this.pos)+" at position "+this.pos)},__class__:qt};var wt=function(){this.h={}};x["haxe.ds.IntMap"]=wt,wt.__name__=["haxe","ds","IntMap"],wt.__interfaces__=[st],wt.prototype={set:function(r,s){this.h[r]=s},remove:function(r){return this.h.hasOwnProperty(r)?(delete this.h[r],!0):!1},keys:function(){var r=[];for(var s in this.h)this.h.hasOwnProperty(s)&&r.push(s|0);return O.iter(r)},__class__:wt};var Bt=function(){this.h={},this.h.__keys__={}};x["haxe.ds.ObjectMap"]=Bt,Bt.__name__=["haxe","ds","ObjectMap"],Bt.__interfaces__=[st],Bt.prototype={set:function(r,s){var o=r.__id__||(r.__id__=++Bt.count);this.h[o]=s,this.h.__keys__[o]=r},keys:function(){var r=[];for(var s in this.h.__keys__)this.h.hasOwnProperty(s)&&r.push(this.h.__keys__[s]);return O.iter(r)},__class__:Bt};var ge=x["haxe.ds.Option"]={__ename__:["haxe","ds","Option"],__constructs__:["Some","None"]};ge.Some=function(r){var s=["Some",0,r];return s.__enum__=ge,s.toString=I,s},ge.None=["None",1],ge.None.toString=I,ge.None.__enum__=ge;var fe=function(){this.h={}};x["haxe.ds.StringMap"]=fe,fe.__name__=["haxe","ds","StringMap"],fe.__interfaces__=[st],fe.prototype={set:function(r,s){ea[r]!=null?this.setReserved(r,s):this.h[r]=s},get:function(r){return ea[r]!=null?this.getReserved(r):this.h[r]},setReserved:function(r,s){this.rh==null&&(this.rh={}),this.rh["$"+r]=s},getReserved:function(r){return this.rh==null?null:this.rh["$"+r]},keys:function(){var r=this.arrayKeys();return O.iter(r)},arrayKeys:function(){var r=[];for(var s in this.h)this.h.hasOwnProperty(s)&&r.push(s);if(this.rh!=null)for(var s in this.rh)s.charCodeAt(0)==36&&r.push(s.substr(1));return r},__class__:fe};var Be=function(r){this.length=r.byteLength,this.b=new ra(r),this.b.bufferValue=r,r.hxBytes=this,r.bytes=this.b};x["haxe.io.Bytes"]=Be,Be.__name__=["haxe","io","Bytes"],Be.alloc=function(r){return new Be(new ri(r))},Be.prototype={get:function(r){return this.b[r]},set:function(r,s){this.b[r]=s&255},__class__:Be};var re=x["haxe.io.Error"]={__ename__:["haxe","io","Error"],__constructs__:["Blocked","Overflow","OutsideBounds","Custom"]};re.Blocked=["Blocked",0],re.Blocked.toString=I,re.Blocked.__enum__=re,re.Overflow=["Overflow",1],re.Overflow.toString=I,re.Overflow.__enum__=re,re.OutsideBounds=["OutsideBounds",2],re.OutsideBounds.toString=I,re.OutsideBounds.__enum__=re,re.Custom=function(r){var s=["Custom",3,r];return s.__enum__=re,s.toString=I,s};var he=function(){};x["haxe.io.FPHelper"]=he,he.__name__=["haxe","io","FPHelper"],he.i32ToFloat=function(r){var s=1-(r>>>31<<1),o=r>>>23&255,l=r&8388607;return l==0&&o==0?0:s*(1+Math.pow(2,-23)*l)*Math.pow(2,o-127)},he.floatToI32=function(r){if(r==0)return 0;var s;r<0?s=-r:s=r;var o=Math.floor(Math.log(s)/.6931471805599453);o<-127?o=-127:o>128&&(o=128);var l=Math.round((s/Math.pow(2,o)-1)*8388608)&8388607;return(r<0?-2147483648:0)|o+127<<23|l},he.i64ToDouble=function(r,s){var o=1-(s>>>31<<1),l=(s>>20&2047)-1023,u=(s&1048575)*4294967296+(r>>>31)*2147483648+(r&2147483647);return u==0&&l==-1023?0:o*(1+Math.pow(2,-52)*u)*Math.pow(2,l)},he.doubleToI64=function(r){var s=he.i64tmp;if(r==0)s.low=0,s.high=0;else{var o;r<0?o=-r:o=r;var l=Math.floor(Math.log(o)/.6931471805599453),u,d=(o/Math.pow(2,l)-1)*4503599627370496;u=Math.round(d);var g=u|0,_=u/4294967296|0;s.low=g,s.high=(r<0?-2147483648:0)|l+1023<<20|_}return s};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 Nt=function(){};x["js.Boot"]=Nt,Nt.__name__=["js","Boot"],Nt.getClass=function(r){if(r instanceof Array&&r.__enum__==null)return Array;var s=r.__class__;if(s!=null)return s;var o=Nt.__nativeClassName(r);return o!=null?Nt.__resolveNativeClass(o):null},Nt.__string_rec=function(r,s){if(r==null)return"null";if(s.length>=5)return"<...>";var o=typeof r;switch(o=="function"&&(r.__name__||r.__ename__)&&(o="object"),o){case"object":if(r instanceof Array){if(r.__enum__){if(r.length==2)return r[0];var l=r[0]+"(";s+=" ";for(var u=2,d=r.length;u<d;){var g=u++;g!=2?l+=","+Nt.__string_rec(r[g],s):l+=Nt.__string_rec(r[g],s)}return l+")"}var _=r.length,y="[";s+=" ";for(var A=0;A<_;){var S=A++;y+=(S>0?",":"")+Nt.__string_rec(r[S],s)}return y+="]",y}var P;try{P=r.toString}catch(N){return N instanceof Q&&(N=N.val),"???"}if(P!=null&&P!=Object.toString&&typeof P=="function"){var E=r.toString();if(E!="[object Object]")return E}var k=null,T=`{
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function Su(i,t){for(var e=0;e<t.length;e++){const n=t[e];if(typeof n!="string"&&!Array.isArray(n)){for(const a in n)if(a!=="default"&&!(a in i)){const h=Object.getOwnPropertyDescriptor(n,a);h&&Object.defineProperty(i,a,h.get?h:{enumerable:!0,get:()=>n[a]})}}}return Object.freeze(Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}))}var pt=(i=>(i[i.ByColor=1]="ByColor",i[i.ByACI=2]="ByACI",i[i.ByLayer=3]="ByLayer",i[i.ByBlock=4]="ByBlock",i[i.None=0]="None",i))(pt||{});const ol={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},ha=[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];let fn=class{static getColorByIndex(t){return ha[t]}static getIndexByColor(t){const e=ha.length-1;for(let n=1;n<e;++n)if(ha[n]===t)return n}static getColorByName(t){return ol[t.toLowerCase()]}static getNameByColor(t){for(const[e,n]of Object.entries(ol))if(n===t)return e}static getNameByIndex(t){const e=this.getColorByIndex(t);return this.getNameByColor(e)}},Fr=class _n{constructor(t=pt.ByLayer,e){this._colorMethod=t,this._colorMethod==pt.ByColor&&e==null?this._value=16777215:this._colorMethod==pt.ByACI?e==null?this._value=8:e===0?this._colorMethod=pt.ByBlock:e===256?this._colorMethod=pt.ByLayer:this._value=Math.max(0,Math.min(e,256)):this._value=e}get colorMethod(){return this._colorMethod}set colorMethod(t){this._colorMethod=t}get red(){const t=this.RGB;return t!=null?t>>16&255:void 0}get green(){const t=this.RGB;return t!=null?t>>8&255:void 0}get blue(){const t=this.RGB;return t!=null?t&255:void 0}get RGB(){switch(this._colorMethod){case pt.ByColor:case pt.ByBlock:case pt.ByLayer:return this._value;case pt.ByACI:return this._value?fn.getColorByIndex(this._value):this._value;default:return}}setRGB(t,e,n){const a=Math.max(0,Math.min(255,Math.round(t))),h=Math.max(0,Math.min(255,Math.round(e))),c=Math.max(0,Math.min(255,Math.round(n)));return this._value=a<<16|h<<8|c,this._colorMethod=pt.ByColor,this}setRGBValue(t){return t==null||!Number.isFinite(t)?(console.warn("Invalid RGB value:",t),this):(this._value=t&16777215,this._colorMethod=pt.ByColor,this)}setRGBFromCss(t){if(!t)return this;const e=t.trim().toLowerCase();if(e.startsWith("#")){let h=0,c=0,m=0;if(e.length===7)h=parseInt(e.substr(1,2),16),c=parseInt(e.substr(3,2),16),m=parseInt(e.substr(5,2),16);else if(e.length===4)h=parseInt(e[1]+e[1],16),c=parseInt(e[2]+e[2],16),m=parseInt(e[3]+e[3],16);else return console.warn("Invalid hex color:",t),this;return this.setRGB(h,c,m)}const n=e.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);if(n){const h=parseInt(n[1],10),c=parseInt(n[2],10),m=parseInt(n[3],10);return this.setRGB(h,c,m)}const a=fn.getColorByName(t);return a!==void 0?this.setRGBValue(a):(console.warn("Unknown CSS color string:",t),this)}setScalar(t){return this.setRGB(t,t,t)}get hexColor(){const t=this.RGB;return t==null?void 0:"0x"+t.toString(16).padStart(6,"0").toUpperCase()}get cssColor(){const t=this.RGB;if(t!=null)return`rgb(${t>>16&255},${t>>8&255},${t&255})`}get colorIndex(){return this._colorMethod===pt.ByACI?this._value:this._colorMethod===pt.ByLayer?256:this._colorMethod===pt.ByBlock?0:void 0}set colorIndex(t){if(t==null)return;const e=Math.max(0,Math.min(256,Math.round(t)));e===0?(this._colorMethod=pt.ByBlock,this._value=void 0):e===256?(this._colorMethod=pt.ByLayer,this._value=void 0):(this._colorMethod=pt.ByACI,this._value=e)}get isByColor(){return this._colorMethod===pt.ByColor}get isByACI(){return this._colorMethod===pt.ByACI}get isByLayer(){return this._colorMethod===pt.ByLayer}setByLayer(t){return this._colorMethod=pt.ByLayer,t==null?this._value=256:this._value=t,this}get isByBlock(){return this._colorMethod===pt.ByBlock}setByBlock(t){return this._colorMethod=pt.ByBlock,t==null?this._value=0:this._value=t,this}get colorName(){switch(this._colorMethod){case pt.ByLayer:return"ByLayer";case pt.ByBlock:return"ByBlock";case pt.ByColor:return this._value?fn.getNameByColor(this._value):"";case pt.ByACI:return this._value?fn.getNameByIndex(this._value):"";default:return}}set colorName(t){if(!t)return;const e=fn.getColorByName(t);e!==void 0?(this._value=e,this._colorMethod=pt.ByColor):console.warn("Unknown color name:",t)}clone(){const t=new _n;return t._colorMethod=this._colorMethod,t._value=this._value,t}copy(t){return this._colorMethod=t._colorMethod,this._value=t._value,this}equals(t){return this._colorMethod===t._colorMethod&&this._value===t._value}toString(){switch(this._colorMethod){case pt.ByLayer:return"ByLayer";case pt.ByBlock:return"ByBlock";case pt.ByACI:return this._value!==void 0?String(this._value):"";case pt.ByColor:return this._value?`${this.red},${this.green},${this.blue}`:"";default:return""}}static fromString(t){if(!t)return;const e=t.trim();if(/^bylayer$/i.test(e))return new _n(pt.ByLayer);if(/^byblock$/i.test(e))return new _n(pt.ByBlock);if(/^\d{1,3},\d{1,3},\d{1,3}$/i.test(e)){const[a,h,c]=e.split(",").map(Number),m=new _n(pt.ByColor);return m.setRGB(a,h,c),m}if(/^\d+$/.test(e)){const a=parseInt(e,10);return new _n(pt.ByACI,a)}const n=fn.getColorByName(e);if(n!=null)return new _n(pt.ByColor,n);console.warn("Unknown color name:",t)}};class Eu{constructor(t=pt.ByColor,e=0){this._colorMethod=t,this._value=e}get colorMethd(){return this._colorMethod}get red(){return this._value>>16&255}set red(t){this._colorMethod=pt.ByColor,this._value=this._value&65535|(t&255)<<16}get green(){return this._value>>8&255}set green(t){this._colorMethod=pt.ByColor,this._value=this._value&16711935|(t&255)<<8}get blue(){return this._value&255}set blue(t){this._colorMethod=pt.ByColor,this._value=this._value&16776960|t&255}setRGB(t,e,n){this._colorMethod=pt.ByColor,this._value=(t&255)<<16|(e&255)<<8|n&255}get colorIndex(){return this._value}set colorIndex(t){this._colorMethod=pt.ByACI,this._value=t}get layerIndex(){return this._value}set layerIndex(t){this._colorMethod=pt.ByLayer,this._value=t}isByColor(){return this._colorMethod===pt.ByColor}isByLayer(){return this._colorMethod===pt.ByLayer}isByBlock(){return this._colorMethod===pt.ByBlock}isByACI(){return this._colorMethod===pt.ByACI}isNone(){return this._colorMethod===pt.None}get rawValue(){return this._value}set rawValue(t){this._value=t}}const Xe={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 Mu{constructor(){this._listeners={}}addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const n=this._listeners;return n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const n=this._listeners[t];if(n!==void 0){const a=n.indexOf(e);a!==-1&&n.splice(a,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const e=this._listeners[t.type];if(e!==void 0){t.target=this;const n=e.slice(0);for(let a=0,h=n.length;a<h;a++)n[a].call(this,t)}}}let ae=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 n of this.listeners)n.call(null,t,...e)}};function zs(i){return i===null||typeof i!="object"?i:Array.isArray(i)?[...i]:{...i}}function Pa(i){if(i===null||typeof i!="object")return i;if(i instanceof Date)return new Date(i.getTime());if(i instanceof RegExp)return new RegExp(i.source,i.flags);if(Array.isArray(i))return i.map(Pa);const t={};for(const e in i)Object.prototype.hasOwnProperty.call(i,e)&&(t[e]=Pa(i[e]));return t}function Kn(i,...t){for(const e of t)if(e)for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&i[n]===void 0&&(i[n]=e[n]);return i}function Sl(i,t){return i!=null&&Object.prototype.hasOwnProperty.call(i,t)}function El(i){return i==null?!0:Array.isArray(i)||typeof i=="string"?i.length===0:i instanceof Map||i instanceof Set?i.size===0:typeof i=="object"?Object.keys(i).length===0:!1}function Gn(i,t){if(i===t)return!0;if(i==null||t==null)return i===t;if(typeof i!=typeof t)return!1;if(typeof i!="object")return i===t;if(Array.isArray(i)!==Array.isArray(t))return!1;if(Array.isArray(i)){if(i.length!==t.length)return!1;for(let a=0;a<i.length;a++)if(!Gn(i[a],t[a]))return!1;return!0}const e=Object.keys(i),n=Object.keys(t);if(e.length!==n.length)return!1;for(const a of e)if(!Object.prototype.hasOwnProperty.call(t,a)||!Gn(i[a],t[a]))return!1;return!0}var ku=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Tu(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Ml={exports:{}};(function(i){(function(t,e){i.exports?i.exports=e():t.log=e()})(ku,function(){var t=function(){},e="undefined",n=typeof window!==e&&typeof window.navigator!==e&&/Trident\/|MSIE /.test(window.navigator.userAgent),a=["trace","debug","info","warn","error"],h={},c=null;function m(O,F){var D=O[F];if(typeof D.bind=="function")return D.bind(O);try{return Function.prototype.bind.call(D,O)}catch{return function(){return Function.prototype.apply.apply(D,[O,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(O){return O==="debug"&&(O="log"),typeof console===e?!1:O==="trace"&&n?b:console[O]!==void 0?m(console,O):console.log!==void 0?m(console,"log"):t}function w(){for(var O=this.getLevel(),F=0;F<a.length;F++){var D=a[F];this[D]=F<O?t:this.methodFactory(D,O,this.name)}if(this.log=this.debug,typeof console===e&&O<this.levels.SILENT)return"No console available for logging"}function x(O){return function(){typeof console!==e&&(w.call(this),this[O].apply(this,arguments))}}function S(O,F,D){return f(O)||x.apply(this,arguments)}function M(O,F){var D=this,at,ft,st,H="loglevel";typeof O=="string"?H+=":"+O:typeof O=="symbol"&&(H=void 0);function ut(wt){var Bt=(a[wt]||"silent").toUpperCase();if(!(typeof window===e||!H)){try{window.localStorage[H]=Bt;return}catch{}try{window.document.cookie=encodeURIComponent(H)+"="+Bt+";"}catch{}}}function it(){var wt;if(!(typeof window===e||!H)){try{wt=window.localStorage[H]}catch{}if(typeof wt===e)try{var Bt=window.document.cookie,fe=encodeURIComponent(H),_e=Bt.indexOf(fe+"=");_e!==-1&&(wt=/^([^;]+)/.exec(Bt.slice(_e+fe.length+1))[1])}catch{}return D.levels[wt]===void 0&&(wt=void 0),wt}}function Gt(){if(!(typeof window===e||!H)){try{window.localStorage.removeItem(H)}catch{}try{window.document.cookie=encodeURIComponent(H)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function Kt(wt){var Bt=wt;if(typeof Bt=="string"&&D.levels[Bt.toUpperCase()]!==void 0&&(Bt=D.levels[Bt.toUpperCase()]),typeof Bt=="number"&&Bt>=0&&Bt<=D.levels.SILENT)return Bt;throw new TypeError("log.setLevel() called with invalid level: "+wt)}D.name=O,D.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},D.methodFactory=F||S,D.getLevel=function(){return st??ft??at},D.setLevel=function(wt,Bt){return st=Kt(wt),Bt!==!1&&ut(st),w.call(D)},D.setDefaultLevel=function(wt){ft=Kt(wt),it()||D.setLevel(wt,!1)},D.resetLevel=function(){st=null,Gt(),w.call(D)},D.enableAll=function(wt){D.setLevel(D.levels.TRACE,wt)},D.disableAll=function(wt){D.setLevel(D.levels.SILENT,wt)},D.rebuild=function(){if(c!==D&&(at=Kt(c.getLevel())),w.call(D),c===D)for(var wt in h)h[wt].rebuild()},at=Kt(c?c.getLevel():"WARN");var qt=it();qt!=null&&(st=Kt(qt)),w.call(D)}c=new M,c.getLogger=function(O){if(typeof O!="symbol"&&typeof O!="string"||O==="")throw new TypeError("You must supply a name when creating a logger.");var F=h[O];return F||(F=h[O]=new M(O,c.methodFactory)),F};var N=typeof window!==e?window.log:void 0;return c.noConflict=function(){return typeof window!==e&&window.log===c&&(window.log=N),c},c.getLoggers=function(){return h},c.default=c,c})})(Ml);var kl=Ml.exports;const Cu=Tu(kl),Nu=Su({__proto__:null,default:Cu},[kl]),Lu=!0,Ds=Nu;Ds.setLevel("debug");const Ou=i=>{try{Ds.setLevel(i)}catch(t){Ds.setLevel("error"),Ds.error(t)}};let Tl=class Cl{constructor(t,e){this.events={attrChanged:new ae,modelChanged:new ae},this._changing=!1,this._previousAttributes={},this._pending=!1;const n=t||{};e&&Kn(n,e),this.attributes=n,this.changed={}}get(t){return this.attributes[t]}set(t,e,n){if(t==null)return this;let a;typeof t=="object"?(a=t,n=e):(a={},a[t]=e),n||(n={});const h=n.unset,c=n.silent,m=[],b=this._changing;this._changing=!0,b||(this._previousAttributes=zs(this.attributes),this.changed={});const f=this.attributes,w=this.changed,x=this._previousAttributes;for(const S in a)e=a[S],Gn(f[S],e)||m.push(S),Gn(x[S],e)?delete w[S]:w[S]=e,h?delete f[S]:f[S]=e;if(!c){m.length&&(this._pending=n);for(let S=0;S<m.length;S++)this.events.attrChanged.dispatch({object:this,attrName:m[S],attrValue:f[m[S]],options:n})}if(b)return this;if(!c)for(;this._pending;)n=this._pending,this._pending=!1,this.events.modelChanged.dispatch({object:this,options:n});return this._pending=!1,this._changing=!1,this}has(t){return this.get(t)!=null}hasChanged(t){return t==null?!El(this.changed):Sl(this.changed,t)}changedAttributes(t){if(!t)return this.hasChanged()?zs(this.changed):{};const e=this._changing?this._previousAttributes:this.attributes,n={};for(const a in t){const h=t[a];Gn(e[a],h)||(n[a]=h)}return n}previous(t){return t==null||!this._previousAttributes?null:this._previousAttributes[t]}previousAttributes(){return zs(this._previousAttributes)}clone(){const t=zs(this.attributes);return new Cl(t)}},Oa=class Rs{constructor(){this.entries=new Map}static getInstance(){return Rs.instance||(Rs.instance=new Rs),Rs.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 Bu{static formatBytes(t,e=2){if(t===0)return"0 B";const n=1024,a=Math.max(0,e),h=["B","KB","MB","GB","TB"],c=Math.floor(Math.log(t)/Math.log(n)),m=t/Math.pow(n,c);return`${parseFloat(m.toFixed(a))} ${h[c]}`}}var Me=(i=>(i[i.ByLayer=0]="ByLayer",i[i.ByBlock=1]="ByBlock",i[i.ByAlpha=2]="ByAlpha",i[i.ErrorValue=3]="ErrorValue",i))(Me||{});let qi=class mr{constructor(t){t!==void 0?(this._method=Me.ByAlpha,this._alpha=mr.clampAlpha(t)):(this._method=Me.ByLayer,this._alpha=255)}get method(){return this._method}set method(t){this._method=t}get alpha(){return this._alpha}set alpha(t){this._alpha=mr.clampAlpha(t),this._method=Me.ByAlpha}get percentage(){if(this._method===Me.ByAlpha)return Math.round((1-this._alpha/255)*100)}set percentage(t){const e=Math.max(0,Math.min(100,t)),n=Math.round(255*(1-e/100));this.alpha=n}static clampAlpha(t){return Math.max(0,Math.min(255,Math.floor(t)))}get isByAlpha(){return this._method===Me.ByAlpha}get isByBlock(){return this._method===Me.ByBlock}get isByLayer(){return this._method===Me.ByLayer}get isClear(){return this.isByAlpha&&this._alpha===0}get isSolid(){return this.isByAlpha&&this._alpha===255}get isInvalid(){return this._method===Me.ErrorValue}serialize(){return this._method<<24|this._alpha}clone(){const t=new mr;return t._method=this._method,t._alpha=this._alpha,t}equals(t){return this._method===t._method&&this._alpha===t._alpha}toString(){return this.isByLayer?"ByLayer":this.isByBlock?"ByBlock":this._alpha.toString()}static fromString(t){const e=t.trim();if(/^bylayer$/i.test(e)){const h=new mr;return h._method=Me.ByLayer,h}if(/^byblock$/i.test(e)){const h=new mr;return h._method=Me.ByBlock,h}const n=Number(e);if(Number.isInteger(n)&&n>=0&&n<=255)return new mr(n);const a=new mr;return a._method=Me.ErrorValue,a}static deserialize(t){const e=t>>>24&255,n=t&255,a=Object.values(Me)[e]??Me.ErrorValue,h=new mr;return h._method=a,h._alpha=mr.clampAlpha(n),h}};class Nl{constructor(t){this.name=t}run(t){throw new Error("run() must be implemented by subclass")}}let Ll=class{constructor(){this.tasks=[],this.onProgress=()=>{},this.onComplete=()=>{},this.onError=()=>!1}scheduleTask(t){return new Promise((e,n)=>{const a=()=>{Promise.resolve(t()).then(e).catch(n)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(a):setTimeout(a,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 n=t;for(let a=0;a<e;a++){const h=this.tasks[a];try{n=await this.scheduleTask(async()=>{const c=await h.run(n);return this.onProgress((a+1)/e,h),c})}catch(c){if(this.onError({error:c,taskIndex:a,task:h}))return Promise.reject(c)}}this.onComplete(n)}},Ol=class{constructor(t,e,n){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=n}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,n=this.handlers.length;e<n;e+=2){const a=this.handlers[e],h=this.handlers[e+1];if(a.global&&(a.lastIndex=0),a.test(t))return h}return null}};const Bl=new Ol;class zu{constructor(t){this.manager=t!==void 0?t:Bl,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}loadAsync(t,e){return new Promise((n,a)=>{this.load(t,n,e,a)})}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 Ba{constructor(t,e,n){this._chunkSize=-1,this._minimumChunkSize=50,this._count=t,this._numerOfChunk=e<1?1:e,this._minimumChunkSize=n,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,n)=>{const a=()=>{Promise.resolve(t()).then(e).catch(n)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(a):setTimeout(a,0)})}async processChunk(t,e){if(this._count<=0){await(e==null?void 0:e());return}let n=0;const a=async()=>{const h=n,c=Math.min(n+this._chunkSize,this._count);await t(h,c),n=c,n<this._count&&await this.scheduleTask(a)};await a(),await(e==null?void 0:e())}}var za=(i=>(i[i.DecimalDegrees=0]="DecimalDegrees",i[i.DegreesMinutesSeconds=1]="DegreesMinutesSeconds",i[i.Gradians=2]="Gradians",i[i.Radians=3]="Radians",i[i.SurveyorsUnits=4]="SurveyorsUnits",i))(za||{});class $n{static get instance(){return this._instance||(this._instance=new $n),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,n,a=[],h=!0,c,m){var f;const b=[];if(e!=null){const w=this.createKey(e.name,n);let x;if(this.has(w))x=this.get(w);else{const S=(f=t.basePoint)==null?void 0:f.clone();t.basePoint=void 0;const M=e.newIterator();let N=!0;for(const O of M)if(O.color.isByBlock&&n?(ll.copy(O.color),O.color.setRGBValue(n),this.addEntity(O,b,t),O.color.copy(ll)):this.addEntity(O,b,t),N){const F=b[0];t.basePoint=F.basePoint,N=!1}x=t.group(b),x&&h&&he.name&&!he.name.startsWith("*U")&&this.set(w,x),t.basePoint=S}return x&&c&&(x.applyMatrix(c),m&&(m.x!=0||m.y!=0||m.z!=1)&&(c.setFromExtrusionDirection(m),x.applyMatrix(c))),x&&a&&a.length>0&&(x.bakeTransformToChildren(),a.forEach(S=>x.addChild(S))),x}else return t.group(b)}addEntity(t,e,n){const a=t.worldDraw(n);a&&(this.attachEntityInfo(a,t),e.push(a))}attachEntityInfo(t,e){t.objectId=e.objectId,t.ownerId=e.ownerId,t.layerName=e.layer,t.visible=e.visibility}}const ll=new Fr;var Ra=(i=>(i[i.UTF8=0]="UTF8",i[i.US_ASCII=1]="US_ASCII",i[i.ISO_8859_1=2]="ISO_8859_1",i[i.ISO_8859_2=3]="ISO_8859_2",i[i.ISO_8859_3=4]="ISO_8859_3",i[i.ISO_8859_4=5]="ISO_8859_4",i[i.ISO_8859_5=6]="ISO_8859_5",i[i.ISO_8859_6=7]="ISO_8859_6",i[i.ISO_8859_7=8]="ISO_8859_7",i[i.ISO_8859_8=9]="ISO_8859_8",i[i.ISO_8859_9=10]="ISO_8859_9",i[i.CP437=11]="CP437",i[i.CP850=12]="CP850",i[i.CP852=13]="CP852",i[i.CP855=14]="CP855",i[i.CP857=15]="CP857",i[i.CP860=16]="CP860",i[i.CP861=17]="CP861",i[i.CP863=18]="CP863",i[i.CP864=19]="CP864",i[i.CP865=20]="CP865",i[i.CP869=21]="CP869",i[i.CP932=22]="CP932",i[i.MACINTOSH=23]="MACINTOSH",i[i.BIG5=24]="BIG5",i[i.CP949=25]="CP949",i[i.JOHAB=26]="JOHAB",i[i.CP866=27]="CP866",i[i.ANSI_1250=28]="ANSI_1250",i[i.ANSI_1251=29]="ANSI_1251",i[i.ANSI_1252=30]="ANSI_1252",i[i.GB2312=31]="GB2312",i[i.ANSI_1253=32]="ANSI_1253",i[i.ANSI_1254=33]="ANSI_1254",i[i.ANSI_1255=34]="ANSI_1255",i[i.ANSI_1256=35]="ANSI_1256",i[i.ANSI_1257=36]="ANSI_1257",i[i.ANSI_874=37]="ANSI_874",i[i.ANSI_932=38]="ANSI_932",i[i.ANSI_936=39]="ANSI_936",i[i.ANSI_949=40]="ANSI_949",i[i.ANSI_950=41]="ANSI_950",i[i.ANSI_1361=42]="ANSI_1361",i[i.UTF16=43]="UTF16",i[i.ANSI_1258=44]="ANSI_1258",i[i.UNDEFINED=255]="UNDEFINED",i))(Ra||{});const Ru=["utf-8","utf-8","iso-8859-1","iso-8859-2","iso-8859-3","iso-8859-4","iso-8859-5","iso-8859-6","iso-8859-7","iso-8859-8","iso-8859-9","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","shift-jis","macintosh","big5","utf-8","utf-8","ibm866","windows-1250","windows-1251","windows-1252","gbk","windows-1253","windows-1254","windows-1255","windows-1256","windows-1257","windows-874","shift-jis","gbk","euc-kr","big5","utf-8","utf-16le","windows-1258"],zl=i=>Ru[i],fi="Continuous",hi="ByLayer",Rl="ByBlock",be=["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 hl=1234567;const Da=Math.PI/180,Fa=180/Math.PI;function Dl(){const i=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(be[i&255]+be[i>>8&255]+be[i>>16&255]+be[i>>24&255]+"-"+be[t&255]+be[t>>8&255]+"-"+be[t>>16&15|64]+be[t>>24&255]+"-"+be[e&63|128]+be[e>>8&255]+"-"+be[e>>16&255]+be[e>>24&255]+be[n&255]+be[n>>8&255]+be[n>>16&255]+be[n>>24&255]).toLowerCase()}function zr(i,t,e){return Math.max(t,Math.min(e,i))}function Va(i,t){return(i%t+t)%t}function Fl(i,t,e,n,a){return n+(i-t)*(a-n)/(e-t)}function Vl(i,t,e){return i!==t?(e-i)/(t-i):0}function Ua(i,t,e){return(1-e)*i+e*t}function Ul(i,t,e,n){return Ua(i,t,1-Math.exp(-e*n))}function jl(i,t=1){return t-Math.abs(Va(i,t*2)-t)}function Gl(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*(3-2*i))}function Wl(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*i*(i*(i*6-15)+10))}function Hl(i,t){return i+Math.floor(Math.random()*(t-i+1))}function ql(i,t){return i+Math.random()*(t-i)}function Yl(i){return i*(.5-Math.random())}function Xl(i){i!==void 0&&(hl=i);let t=hl+=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 Kl(i){return i*Da}function $l(i){return i*Fa}function Zl(i){return(i&i-1)===0&&i!==0}function Ql(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Jl(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Fs(i){const t=Math.PI*2;return(i%t+t)%t}function th(i,t,e){return i>t&&i<e||i>e&&i<t}function eh(i,t,e,n=!1){return i=Fs(i),t=Fs(t),e=Fs(e),n?t>e?i<=t&&i>=e:i<=t||i>=e:t<e?i>=t&&i<=e:i>=t||i<=e}function ja(i){return i=Math.abs(i),i<1?0:Math.ceil(Math.log10(Math.abs(i)+1))}function rh(i,t=1e-7){const e=ja(i);return Math.max(Math.pow(10,e)*t,t)}const Pt={DEG2RAD:Da,RAD2DEG:Fa,generateUUID:Dl,clamp:zr,euclideanModulo:Va,mapLinear:Fl,inverseLerp:Vl,lerp:Ua,damp:Ul,pingpong:jl,smoothstep:Gl,smootherstep:Wl,randInt:Hl,randFloat:ql,randFloatSpread:Yl,seededRandom:Xl,degToRad:Kl,radToDeg:$l,isPowerOfTwo:Zl,ceilPowerOfTwo:Ql,floorPowerOfTwo:Jl,normalizeAngle:Fs,isBetween:th,isBetweenAngle:eh,intPartLength:ja,relativeEps:rh},Ia=class nh{constructor(t,e){this.x=0,this.y=0;const n=+(t!==void 0)+ +(e!==void 0);if(n!==0){if(n===1&&t instanceof Array){this.x=t[0],this.y=t[1];return}if(n===1){const{x:a,y:h}=t;this.x=a,this.y=h;return}if(n===2){this.x=t,this.y=e;return}throw Xe.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 nh(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,n=this.y,a=t.elements;return this.x=a[0]*e+a[3]*n+a[6],this.y=a[1]*e+a[4]*n+a[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 n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}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 n=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,n)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}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,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,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 n=Math.cos(e),a=Math.sin(e),h=this.x-t.x,c=this.y-t.y;return this.x=h*n-c*a+t.x,this.y=h*a+c*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}relativeEps(t=1e-7){return Math.min(Pt.relativeEps(this.x,t),Pt.relativeEps(this.y,t))}*[Symbol.iterator](){yield this.x,yield this.y}};Ia.EMPTY=Object.freeze(new Ia(0,0));let Jt=Ia;const Sa=class sh{constructor(t,e,n,a,h,c,m,b,f){this.elements=[1,0,0,0,1,0,0,0,1],t!=null&&e!=null&&n!=null&&a!=null&&h!=null&&c!=null&&m!=null&&b!=null&&f!=null&&this.set(t,e,n,a,h,c,m,b,f)}set(t,e,n,a,h,c,m,b,f){const w=this.elements;return w[0]=t,w[1]=a,w[2]=m,w[3]=e,w[4]=h,w[5]=b,w[6]=n,w[7]=c,w[8]=f,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.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 n=t.elements,a=e.elements,h=this.elements,c=n[0],m=n[3],b=n[6],f=n[1],w=n[4],x=n[7],S=n[2],M=n[5],N=n[8],O=a[0],F=a[3],D=a[6],at=a[1],ft=a[4],st=a[7],H=a[2],ut=a[5],it=a[8];return h[0]=c*O+m*at+b*H,h[3]=c*F+m*ft+b*ut,h[6]=c*D+m*st+b*it,h[1]=f*O+w*at+x*H,h[4]=f*F+w*ft+x*ut,h[7]=f*D+w*st+x*it,h[2]=S*O+M*at+N*H,h[5]=S*F+M*ft+N*ut,h[8]=S*D+M*st+N*it,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],n=t[1],a=t[2],h=t[3],c=t[4],m=t[5],b=t[6],f=t[7],w=t[8];return e*c*w-e*m*f-n*h*w+n*m*b+a*h*f-a*c*b}invert(){const t=this.elements,e=t[0],n=t[1],a=t[2],h=t[3],c=t[4],m=t[5],b=t[6],f=t[7],w=t[8],x=w*c-m*f,S=m*b-w*h,M=f*h-c*b,N=e*x+n*S+a*M;if(N===0)return this.set(0,0,0,0,0,0,0,0,0);const O=1/N;return t[0]=x*O,t[1]=(a*f-w*n)*O,t[2]=(m*n-a*c)*O,t[3]=S*O,t[4]=(w*e-a*b)*O,t[5]=(a*h-m*e)*O,t[6]=M*O,t[7]=(n*b-f*e)*O,t[8]=(c*e-n*h)*O,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,n,a,h,c,m){const b=Math.cos(h),f=Math.sin(h);return this.set(n*b,n*f,-n*(b*c+f*m)+c+t,-a*f,a*b,-a*(-f*c+b*m)+m+e,0,0,1),this}scale(t,e){return this.premultiply(ca.makeScale(t,e)),this}rotate(t){return this.premultiply(ca.makeRotation(-t)),this}translate(t,e){return this.premultiply(ca.makeTranslation(t,e)),this}makeTranslation(t,e){return t instanceof Jt?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),n=Math.sin(t);return this.set(e,-n,0,n,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,n=t.elements;for(let a=0;a<9;a++)if(e[a]!==n[a])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new sh().fromArray(this.elements)}};Sa.IDENTITY=Object.freeze(new Sa);let Yi=Sa;const ca=new Yi,yn=1e-6,Zt=2*Math.PI,Du={x:0,y:0},Ga={x:0,y:0,z:0};class Wa{constructor(){this.equalPointTol=yn,this.equalVectorTol=yn}equalPoint2d(t,e){return new Jt(t).sub(e).length()<this.equalPointTol}equalPoint3d(t,e){return new X(t).sub(e).length()<this.equalPointTol}static equalToZero(t,e=yn){return t<e&&t>-e}static equal(t,e,n=yn){return Math.abs(t-e)<n}static great(t,e,n=yn){return t-e>n}static less(t,e,n=yn){return t-e<n}}const Ha=new Wa;function qa(i,t,e=!1){const n=i.x,a=i.y;let h=!1;const c=t.length;for(let m=0,b=c-1;m<c;b=m++){const f=t[m].x,w=t[m].y,x=t[b].x,S=t[b].y;let M=w>a!=S>a;e&&(M=w>=a!=S>=a),M&&n<(x-f)*(a-w)/(S-w)+f&&(h=!h)}return h}function ih(i,t){if(i.length===0||t.length===0)return!1;const e=new we().setFromPoints(i),n=new we().setFromPoints(t);if(!e.intersectsBox(n))return!1;for(let a=0;a<i.length;){if(qa(i[a],t,!0))return!0;a<i.length-1&&Ha.equalPoint2d(i[a+1],i[a])&&++a,++a}return!1}const ah={isPointInPolygon:qa,isPolygonIntersect:ih};function oh(i,t){const e=[],n=t-1,a=i;for(let h=0;h<=a;h++)e.push(0);for(let h=1;h<=n-a;h++)e.push(h);for(let h=0;h<=a;h++)e.push(n-a+1);return e}function lh(i,t){const e=t.length-1,n=i,a=[0];let h=0;for(let m=1;m<=e;m++){const b=t[m][0]-t[m-1][0],f=t[m][1]-t[m-1][1],w=t[m][2]-t[m-1][2],x=Math.sqrt(b*b+f*f+w*w);h+=x,a.push(h)}const c=[];for(let m=0;m<=n;m++)c.push(0);for(let m=1;m<=e-n;m++){const b=a[m]/h;c.push(b*(e-n+1))}for(let m=0;m<=n;m++)c.push(e-n+1);return c}function hh(i,t){const e=t.length-1,n=i,a=[0];let h=0;for(let m=1;m<=e;m++){const b=t[m][0]-t[m-1][0],f=t[m][1]-t[m-1][1],w=t[m][2]-t[m-1][2],x=Math.sqrt(b*b+f*f+w*w),S=Math.sqrt(x);h+=S,a.push(h)}const c=[];for(let m=0;m<=n;m++)c.push(0);for(let m=1;m<=e-n;m++){const b=a[m]/h;c.push(b*(e-n+1))}for(let m=0;m<=n;m++)c.push(e-n+1);return c}function _i(i,t,e,n){if(t===0)return e>=n[i]&&e<n[i+1]?1:0;const a=n[i+t]-n[i],h=n[i+t+1]-n[i+1],c=a>1e-10?(e-n[i])/a:0,m=h>1e-10?(n[i+t+1]-e)/h:0;return c*_i(i,t-1,e,n)+m*_i(i+1,t-1,e,n)}function Vs(i,t,e,n,a){const h=n.length-1,c=t;if(i=Math.max(e[c],Math.min(e[h+1],i)),Math.abs(i-e[h+1])<1e-8)return[...n[h]];if(Math.abs(i-e[c])<1e-8)return[...n[0]];const m=[0,0,0];let b=0;for(let f=0;f<=h;f++){const w=_i(f,c,i,e),x=a[f]*w;m[0]+=n[f][0]*x,m[1]+=n[f][1]*x,m[2]+=n[f][2]*x,b+=x}if(b<1e-10){const f=e[e.length-c-1];if(Math.abs(i-f)<1e-8)return[...n[h]];if(Math.abs(i-e[c])<1e-8)return[...n[0]]}return b>1e-10&&(m[0]/=b,m[1]/=b,m[2]/=b),m}function ch(i,t,e,n){const a=i,h=t[a],c=t[t.length-a-1];let m=0;const b=1e3,f=(c-h)/b;let w=Vs(h,i,t,e,n);for(let O=1;O<=b;O++){const F=h+O*f,D=Vs(F,i,t,e,n),at=D[0]-w[0],ft=D[1]-w[1],st=D[2]-w[2];m+=Math.sqrt(at*at+ft*ft+st*st),w=D}const x=Vs(c,i,t,e,n),S=x[0]-w[0],M=x[1]-w[1],N=x[2]-w[2];return m+=Math.sqrt(S*S+M*M+N*N),m}function Fu(i){return i.map(t=>[...t])}class wn{constructor(t=0,e=0,n=0,a=1){this._x=t,this._y=e,this._z=n,this._w=a}static slerpFlat(t,e,n,a,h,c,m){let b=n[a+0],f=n[a+1],w=n[a+2],x=n[a+3];const S=h[c+0],M=h[c+1],N=h[c+2],O=h[c+3];if(m===0){t[e+0]=b,t[e+1]=f,t[e+2]=w,t[e+3]=x;return}if(m===1){t[e+0]=S,t[e+1]=M,t[e+2]=N,t[e+3]=O;return}if(x!==O||b!==S||f!==M||w!==N){let F=1-m;const D=b*S+f*M+w*N+x*O,at=D>=0?1:-1,ft=1-D*D;if(ft>Number.EPSILON){const H=Math.sqrt(ft),ut=Math.atan2(H,D*at);F=Math.sin(F*ut)/H,m=Math.sin(m*ut)/H}const st=m*at;if(b=b*F+S*st,f=f*F+M*st,w=w*F+N*st,x=x*F+O*st,F===1-m){const H=1/Math.sqrt(b*b+f*f+w*w+x*x);b*=H,f*=H,w*=H,x*=H}}t[e]=b,t[e+1]=f,t[e+2]=w,t[e+3]=x}static multiplyQuaternionsFlat(t,e,n,a,h,c){const m=n[a],b=n[a+1],f=n[a+2],w=n[a+3],x=h[c],S=h[c+1],M=h[c+2],N=h[c+3];return t[e]=m*N+w*x+b*M-f*S,t[e+1]=b*N+w*S+f*x-m*M,t[e+2]=f*N+w*M+m*S-b*x,t[e+3]=w*N-m*x-b*S-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,n,a){return this._x=t,this._y=e,this._z=n,this._w=a,this._onChangeCallback(),this}clone(){return new wn(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 n=t.x,a=t.y,h=t.z,c=t.order,m=Math.cos,b=Math.sin,f=m(n/2),w=m(a/2),x=m(h/2),S=b(n/2),M=b(a/2),N=b(h/2);switch(c){case"XYZ":this._x=S*w*x+f*M*N,this._y=f*M*x-S*w*N,this._z=f*w*N+S*M*x,this._w=f*w*x-S*M*N;break;case"YXZ":this._x=S*w*x+f*M*N,this._y=f*M*x-S*w*N,this._z=f*w*N-S*M*x,this._w=f*w*x+S*M*N;break;case"ZXY":this._x=S*w*x-f*M*N,this._y=f*M*x+S*w*N,this._z=f*w*N+S*M*x,this._w=f*w*x-S*M*N;break;case"ZYX":this._x=S*w*x-f*M*N,this._y=f*M*x+S*w*N,this._z=f*w*N-S*M*x,this._w=f*w*x+S*M*N;break;case"YZX":this._x=S*w*x+f*M*N,this._y=f*M*x+S*w*N,this._z=f*w*N-S*M*x,this._w=f*w*x-S*M*N;break;case"XZY":this._x=S*w*x-f*M*N,this._y=f*M*x-S*w*N,this._z=f*w*N+S*M*x,this._w=f*w*x+S*M*N;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+c)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,a=Math.sin(n);return this._x=t.x*a,this._y=t.y*a,this._z=t.z*a,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],a=e[4],h=e[8],c=e[1],m=e[5],b=e[9],f=e[2],w=e[6],x=e[10],S=n+m+x;if(S>0){const M=.5/Math.sqrt(S+1);this._w=.25/M,this._x=(w-b)*M,this._y=(h-f)*M,this._z=(c-a)*M}else if(n>m&&n>x){const M=2*Math.sqrt(1+n-m-x);this._w=(w-b)/M,this._x=.25*M,this._y=(a+c)/M,this._z=(h+f)/M}else if(m>x){const M=2*Math.sqrt(1+m-n-x);this._w=(h-f)/M,this._x=(a+c)/M,this._y=.25*M,this._z=(b+w)/M}else{const M=2*Math.sqrt(1+x-n-m);this._w=(c-a)/M,this._x=(h+f)/M,this._y=(b+w)/M,this._z=.25*M}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<Number.EPSILON?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(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=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(zr(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(n===0)return this;const a=Math.min(1,e/n);return this.slerp(t,a),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 n=t._x,a=t._y,h=t._z,c=t._w,m=e._x,b=e._y,f=e._z,w=e._w;return this._x=n*w+c*m+a*f-h*b,this._y=a*w+c*b+h*m-n*f,this._z=h*w+c*f+n*b-a*m,this._w=c*w-n*m-a*b-h*f,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const n=this._x,a=this._y,h=this._z,c=this._w;let m=c*t._w+n*t._x+a*t._y+h*t._z;if(m<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,m=-m):this.copy(t),m>=1)return this._w=c,this._x=n,this._y=a,this._z=h,this;const b=1-m*m;if(b<=Number.EPSILON){const M=1-e;return this._w=M*c+e*this._w,this._x=M*n+e*this._x,this._y=M*a+e*this._y,this._z=M*h+e*this._z,this.normalize(),this}const f=Math.sqrt(b),w=Math.atan2(f,m),x=Math.sin((1-e)*w)/f,S=Math.sin(e*w)/f;return this._w=c*x+this._w*S,this._x=n*x+this._x*S,this._y=a*x+this._y*S,this._z=h*x+this._z*S,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),a=Math.sqrt(1-n),h=Math.sqrt(n);return this.set(a*Math.sin(t),a*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 Ee=class uh{constructor(t,e,n){this.x=0,this.y=0,this.z=0;const a=+(t!==void 0)+ +(e!==void 0)+ +(n!==void 0);if(a!==0){if(a===1&&t instanceof Array){this.x=t[0],this.y=t[1],this.z=t[2];return}if(a===1){const{x:h,y:c,z:m}=t;this.x=h,this.y=c,this.z=m||0;return}if(a===3){this.x=t,this.y=e,this.z=n;return}throw Xe.ILLEGAL_PARAMETERS}}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,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 uh(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(cl.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(cl.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,a=this.z,h=t.elements;return this.x=h[0]*e+h[3]*n+h[6]*a,this.y=h[1]*e+h[4]*n+h[7]*a,this.z=h[2]*e+h[5]*n+h[8]*a,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,a=this.z,h=t.elements,c=1/(h[3]*e+h[7]*n+h[11]*a+h[15]);return this.x=(h[0]*e+h[4]*n+h[8]*a+h[12])*c,this.y=(h[1]*e+h[5]*n+h[9]*a+h[13])*c,this.z=(h[2]*e+h[6]*n+h[10]*a+h[14])*c,this}applyQuaternion(t){const e=this.x,n=this.y,a=this.z,h=t.x,c=t.y,m=t.z,b=t.w,f=2*(c*a-m*n),w=2*(m*e-h*a),x=2*(h*n-c*e);return this.x=e+b*f+c*x-m*w,this.y=n+b*w+m*f-h*x,this.z=a+b*x+h*w-c*f,this}transformDirection(t){const e=this.x,n=this.y,a=this.z,h=t.elements;return this.x=h[0]*e+h[4]*n+h[8]*a,this.y=h[1]*e+h[5]*n+h[9]*a,this.z=h[2]*e+h[6]*n+h[10]*a,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 n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}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),n=this.length(),a=t.length();return Math.abs(e)===n*a}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,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,a=t.y,h=t.z,c=e.x,m=e.y,b=e.z;return this.x=a*b-h*m,this.y=h*c-n*b,this.z=n*m-a*c,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return ua.copy(this).projectOnVector(t),this.sub(ua)}reflect(t){return this.sub(ua.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 n=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,n)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,a=this.z-t.z;return e*e+n*n+a*a}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(),n=this.setFromMatrixColumn(t,1).length(),a=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=a,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,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};Ee.ORIGIN=Object.freeze(new Ee(0,0,0)),Ee.X_AXIS=Object.freeze(new Ee(1,0,0)),Ee.NEGATIVE_X_AXIS=Object.freeze(new Ee(-1,0,0)),Ee.Y_AXIS=Object.freeze(new Ee(0,1,0)),Ee.NEGATIVE_Y_AXIS=Object.freeze(new Ee(0,-1,0)),Ee.Z_AXIS=Object.freeze(new Ee(0,0,1)),Ee.NEGATIVE_Z_AXIS=Object.freeze(new Ee(0,0,-1));let X=Ee;const ua=new X,cl=new wn,Ea=class dh{constructor(t,e,n,a,h,c,m,b,f,w,x,S,M,N,O,F){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!=null&&e!=null&&n!=null&&a!=null&&h!=null&&c!=null&&m!=null&&b!=null&&f!=null&&w!=null&&x!=null&&S!=null&&M!=null&&N!=null&&O!=null&&F!=null&&this.set(t,e,n,a,h,c,m,b,f,w,x,S,M,N,O,F)}set(t,e,n,a,h,c,m,b,f,w,x,S,M,N,O,F){const D=this.elements;return D[0]=t,D[4]=e,D[8]=n,D[12]=a,D[1]=h,D[5]=c,D[9]=m,D[13]=b,D[2]=f,D[6]=w,D[10]=x,D[14]=S,D[3]=M,D[7]=N,D[11]=O,D[15]=F,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 dh().fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[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(Ha.equalPoint3d(t,X.Z_AXIS))this.identity();else{const e=new X(1,0,0);Math.abs(t.x)<1/64&&Math.abs(t.y)<1/64?e.crossVectors(X.Y_AXIS,t).normalize():e.crossVectors(X.Z_AXIS,t).normalize();const n=t.clone().cross(e).normalize();this.set(e.x,e.y,e.z,0,n.x,n.y,n.z,0,t.x,t.y,t.z,0,0,0,0,1)}return this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,a=1/Fn.setFromMatrixColumn(t,0).length(),h=1/Fn.setFromMatrixColumn(t,1).length(),c=1/Fn.setFromMatrixColumn(t,2).length();return e[0]=n[0]*a,e[1]=n[1]*a,e[2]=n[2]*a,e[3]=0,e[4]=n[4]*h,e[5]=n[5]*h,e[6]=n[6]*h,e[7]=0,e[8]=n[8]*c,e[9]=n[9]*c,e[10]=n[10]*c,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(Vu,t,Uu)}lookAt(t,e,n){const a=this.elements;return Ve.subVectors(t,e),Ve.lengthSq()===0&&(Ve.z=1),Ve.normalize(),$r.crossVectors(n,Ve),$r.lengthSq()===0&&(Math.abs(n.z)===1?Ve.x+=1e-4:Ve.z+=1e-4,Ve.normalize(),$r.crossVectors(n,Ve)),$r.normalize(),ni.crossVectors(Ve,$r),a[0]=$r.x,a[4]=ni.x,a[8]=Ve.x,a[1]=$r.y,a[5]=ni.y,a[9]=Ve.y,a[2]=$r.z,a[6]=ni.z,a[10]=Ve.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,a=e.elements,h=this.elements,c=n[0],m=n[4],b=n[8],f=n[12],w=n[1],x=n[5],S=n[9],M=n[13],N=n[2],O=n[6],F=n[10],D=n[14],at=n[3],ft=n[7],st=n[11],H=n[15],ut=a[0],it=a[4],Gt=a[8],Kt=a[12],qt=a[1],wt=a[5],Bt=a[9],fe=a[13],_e=a[2],Be=a[6],re=a[10],ce=a[14],Q=a[3],Nt=a[7],ue=a[11],_r=a[15];return h[0]=c*ut+m*qt+b*_e+f*Q,h[4]=c*it+m*wt+b*Be+f*Nt,h[8]=c*Gt+m*Bt+b*re+f*ue,h[12]=c*Kt+m*fe+b*ce+f*_r,h[1]=w*ut+x*qt+S*_e+M*Q,h[5]=w*it+x*wt+S*Be+M*Nt,h[9]=w*Gt+x*Bt+S*re+M*ue,h[13]=w*Kt+x*fe+S*ce+M*_r,h[2]=N*ut+O*qt+F*_e+D*Q,h[6]=N*it+O*wt+F*Be+D*Nt,h[10]=N*Gt+O*Bt+F*re+D*ue,h[14]=N*Kt+O*fe+F*ce+D*_r,h[3]=at*ut+ft*qt+st*_e+H*Q,h[7]=at*it+ft*wt+st*Be+H*Nt,h[11]=at*Gt+ft*Bt+st*re+H*ue,h[15]=at*Kt+ft*fe+st*ce+H*_r,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],n=t[4],a=t[8],h=t[12],c=t[1],m=t[5],b=t[9],f=t[13],w=t[2],x=t[6],S=t[10],M=t[14],N=t[3],O=t[7],F=t[11],D=t[15];return N*(+h*b*x-a*f*x-h*m*S+n*f*S+a*m*M-n*b*M)+O*(+e*b*M-e*f*S+h*c*S-a*c*M+a*f*w-h*b*w)+F*(+e*f*x-e*m*M-h*c*x+n*c*M+h*m*w-n*f*w)+D*(-a*m*w-e*b*x+e*m*S+a*c*x-n*c*S+n*b*w)}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,n){const a=this.elements;return t instanceof X?(a[12]=t.x,a[13]=t.y,a[14]=t.z):(a[12]=t,a[13]=e,a[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],a=t[2],h=t[3],c=t[4],m=t[5],b=t[6],f=t[7],w=t[8],x=t[9],S=t[10],M=t[11],N=t[12],O=t[13],F=t[14],D=t[15],at=x*F*f-O*S*f+O*b*M-m*F*M-x*b*D+m*S*D,ft=N*S*f-w*F*f-N*b*M+c*F*M+w*b*D-c*S*D,st=w*O*f-N*x*f+N*m*M-c*O*M-w*m*D+c*x*D,H=N*x*b-w*O*b-N*m*S+c*O*S+w*m*F-c*x*F,ut=e*at+n*ft+a*st+h*H;if(ut===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const it=1/ut;return t[0]=at*it,t[1]=(O*S*h-x*F*h-O*a*M+n*F*M+x*a*D-n*S*D)*it,t[2]=(m*F*h-O*b*h+O*a*f-n*F*f-m*a*D+n*b*D)*it,t[3]=(x*b*h-m*S*h-x*a*f+n*S*f+m*a*M-n*b*M)*it,t[4]=ft*it,t[5]=(w*F*h-N*S*h+N*a*M-e*F*M-w*a*D+e*S*D)*it,t[6]=(N*b*h-c*F*h-N*a*f+e*F*f+c*a*D-e*b*D)*it,t[7]=(c*S*h-w*b*h+w*a*f-e*S*f-c*a*M+e*b*M)*it,t[8]=st*it,t[9]=(N*x*h-w*O*h-N*n*M+e*O*M+w*n*D-e*x*D)*it,t[10]=(c*O*h-N*m*h+N*n*f-e*O*f-c*n*D+e*m*D)*it,t[11]=(w*m*h-c*x*h-w*n*f+e*x*f+c*n*M-e*m*M)*it,t[12]=H*it,t[13]=(w*O*a-N*x*a+N*n*S-e*O*S-w*n*F+e*x*F)*it,t[14]=(N*m*a-c*O*a-N*n*b+e*O*b+c*n*F-e*m*F)*it,t[15]=(c*x*a-w*m*a+w*n*b-e*x*b-c*n*S+e*m*S)*it,this}scale(t){const e=this.elements,n=t.x,a=t.y,h=t.z;return e[0]*=n,e[4]*=a,e[8]*=h,e[1]*=n,e[5]*=a,e[9]*=h,e[2]*=n,e[6]*=a,e[10]*=h,e[3]*=n,e[7]*=a,e[11]*=h,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],a=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,a))}makeTranslation(t,e,n){return t instanceof X?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,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),a=Math.sin(e),h=1-n,c=t.x,m=t.y,b=t.z,f=h*c,w=h*m;return this.set(f*c+n,f*m-a*b,f*b+a*m,0,f*m+a*b,w*m+n,w*b-a*c,0,f*b-a*m,w*b+a*c,h*b*b+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,a,h,c){return this.set(1,n,h,0,t,1,c,0,e,a,1,0,0,0,0,1),this}compose(t,e,n){const a=this.elements,h=e.x,c=e.y,m=e.z,b=e.w,f=h+h,w=c+c,x=m+m,S=h*f,M=h*w,N=h*x,O=c*w,F=c*x,D=m*x,at=b*f,ft=b*w,st=b*x,H=n.x,ut=n.y,it=n.z;return a[0]=(1-(O+D))*H,a[1]=(M+st)*H,a[2]=(N-ft)*H,a[3]=0,a[4]=(M-st)*ut,a[5]=(1-(S+D))*ut,a[6]=(F+at)*ut,a[7]=0,a[8]=(N+ft)*it,a[9]=(F-at)*it,a[10]=(1-(S+O))*it,a[11]=0,a[12]=t.x,a[13]=t.y,a[14]=t.z,a[15]=1,this}decompose(t,e,n){const a=this.elements;let h=Fn.set(a[0],a[1],a[2]).length();const c=Fn.set(a[4],a[5],a[6]).length(),m=Fn.set(a[8],a[9],a[10]).length();this.determinant()<0&&(h=-h),t.x=a[12],t.y=a[13],t.z=a[14],ir.copy(this);const b=1/h,f=1/c,w=1/m;return ir.elements[0]*=b,ir.elements[1]*=b,ir.elements[2]*=b,ir.elements[4]*=f,ir.elements[5]*=f,ir.elements[6]*=f,ir.elements[8]*=w,ir.elements[9]*=w,ir.elements[10]*=w,e.setFromRotationMatrix(ir),n.x=h,n.y=c,n.z=m,this}equals(t){const e=this.elements,n=t.elements;for(let a=0;a<16;a++)if(e[a]!==n[a])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}};Ea.IDENTITY=Object.freeze(new Ea);let Ye=Ea;const Fn=new X,ir=new Ye,Vu=new X(0,0,0),Uu=new X(1,1,1),$r=new X,ni=new X,Ve=new X;class Ct{constructor(t=void 0,e=void 0){this.min=t==null?new X(1/0,1/0,1/0):new X(t.x,t.y,t.z),this.max=e==null?new X(-1/0,-1/0,-1/0):new X(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,n=t.length;e<n;e+=3)this.expandByPoint(da.fromArray(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=da.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}clone(){return new Ct().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 X(0,0,0):new X(0,0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new X(0,0,0):new X(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,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,da).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:(wr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),wr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),wr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),wr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),wr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),wr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),wr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),wr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(wr),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 wr=[new X,new X,new X,new X,new X,new X,new X,new X],da=new X,ul=new Jt;class we{constructor(t=void 0,e=void 0){this.min=t==null?new Jt(1/0,1/0):new Jt(t.x,t.y),this.max=e==null?new Jt(-1/0,-1/0):new Jt(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,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=ul.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}clone(){return new we().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 Jt(0,0):new Jt(0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new Jt(0,0):new Jt(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,ul).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 dl=new X,ju=new X,Gu=new Yi;class Zs{constructor(t=new X(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,n,a){return this.normal.set(t,e,n),this.constant=a,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const a=dl.subVectors(n,e).cross(ju.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(a,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 n=e||Gu.getNormalMatrix(t),a=this.coplanarPoint(dl).applyMatrix4(t),h=this.normal.applyMatrix3(n).normalize();return this.constant=-a.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 Zs().copy(this)}}class Tt extends Jt{static pointArrayToNumberArray(t){const e=new Array(t.length*2);return t.forEach((n,a)=>{n.toArray(e,a*2)}),e}}class G extends X{static pointArrayToNumberArray(t,e=!0){const n=e?3:2,a=new Array(t.length*n);return t.forEach((h,c)=>{h.toArray(a,c*n)}),a}}const pl=new Ye,ml=new wn,ph=class Ma{constructor(t=0,e=0,n=0,a=Ma.DEFAULT_ORDER){this._x=t,this._y=e,this._z=n,this._order=a}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,n,a=this._order){return this._x=t,this._y=e,this._z=n,this._order=a,this._onChangeCallback(),this}clone(){return new Ma(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,n=!0){const a=t.elements,h=a[0],c=a[4],m=a[8],b=a[1],f=a[5],w=a[9],x=a[2],S=a[6],M=a[10];switch(e){case"XYZ":this._y=Math.asin(zr(m,-1,1)),Math.abs(m)<.9999999?(this._x=Math.atan2(-w,M),this._z=Math.atan2(-c,h)):(this._x=Math.atan2(S,f),this._z=0);break;case"YXZ":this._x=Math.asin(-zr(w,-1,1)),Math.abs(w)<.9999999?(this._y=Math.atan2(m,M),this._z=Math.atan2(b,f)):(this._y=Math.atan2(-x,h),this._z=0);break;case"ZXY":this._x=Math.asin(zr(S,-1,1)),Math.abs(S)<.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(-zr(x,-1,1)),Math.abs(x)<.9999999?(this._x=Math.atan2(S,M),this._z=Math.atan2(b,h)):(this._x=0,this._z=Math.atan2(-c,f));break;case"YZX":this._z=Math.asin(zr(b,-1,1)),Math.abs(b)<.9999999?(this._x=Math.atan2(-w,f),this._y=Math.atan2(-x,h)):(this._x=0,this._y=Math.atan2(m,M));break;case"XZY":this._z=Math.asin(-zr(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(S,f),this._y=Math.atan2(m,h)):(this._x=Math.atan2(-w,M),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n=!0){return pl.makeRotationFromQuaternion(t),this.setFromRotationMatrix(pl,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return ml.setFromEuler(this),this.setFromQuaternion(ml,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}};ph.DEFAULT_ORDER="XYZ";let Wu=ph;class mh{constructor(){this._boundingBoxNeedsUpdate=!1}get boundingBoxNeedUpdate(){return this._boundingBoxNeedsUpdate}}let Ya=class extends mh{translate(t){return this.transform(new Yi().makeTranslation(t.x,t.y))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}};class Xi extends Ya{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 we}transform(t){return this._boundingBoxNeedsUpdate=!0,this}getPoints(t){const e=[];for(let n=0;n<this.loops.length;++n){const a=this.loops[n].getPoints(t);e.push(a)}return e}buildHierarchy(){var t;const e=this.getPoints(100),n=this.calculateBoundaryBoxes(e),a=this.sortBoundaryBoxesByAreas(n),h=new Map,c=a.length;for(let b=0;b<c;b++)h.set(a[b],{index:a[b],children:[]});const m={index:-1,children:[]};for(let b=0;b<c;b++){const f=a[b],w=e[f],x=n[f];let S=b+1;for(;S<c;S++){const M=a[S],N=e[M];if(n[M].containsBox(x)&&ah.isPointInPolygon(w[Pt.randInt(0,w.length-1)],N)){(t=h.get(M))==null||t.children.push(h.get(f));break}}S===c&&m.children.push(h.get(f))}return m}get area(){if(this._loops.length===0)return 0;let t=0;for(let e=0;e<this._loops.length;e++){const n=this._loops[e].getPoints(128),a=this.polygonArea(n);e===0?t+=Math.abs(a):t-=Math.abs(a)}return t}polygonArea(t){const e=t.length;if(e<3)return 0;let n=0;for(let a=0,h=e-1;a<e;h=a++){const c=t[h],m=t[a];n+=c.x*m.y-m.x*c.y}return n*.5}calculateBoundaryBoxes(t){const e=[];return t.forEach(n=>{e.push(new we().setFromPoints(n))}),e}sortBoundaryBoxesByAreas(t){const e=[];t.forEach((a,h)=>{const c=a.size,m=c.width*c.height;e.push({area:m,index:h})}),e.sort((a,h)=>a.area-h.area);const n=[];return e.forEach(a=>{n.push(a.index)}),n}}class Zn extends Ya{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 n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){const e=[];let n,a=this.getPoint(0),h=0;e.push(0);for(let c=1;c<=t;c++)n=this.getPoint(c/t),h+=n.distanceTo(a),e.push(h),a=n;return e}getUtoTmapping(t,e){const n=this.getLengths();let a=0;const h=n.length;let c;e?c=e:c=t*n[h-1];let m=0,b=h-1,f;for(;m<=b;)if(a=Math.floor(m+(b-m)/2),f=n[a]-c,f<0)m=a+1;else if(f>0)b=a-1;else{b=a;break}if(a=b,n[a]===c)return a/(h-1);const w=n[a],x=n[a+1]-w,S=(c-w)/x;return(a+S)/(h-1)}getTangent(t){let e=t-1e-4,n=t+1e-4;e<0&&(e=0),n>1&&(n=1);const a=this.getPoint(e),h=this.getPoint(n),c=new Tt;return c.copy(h).sub(a).normalize(),c}getTangentAt(t){const e=this.getUtoTmapping(t);return this.getTangent(e)}}class Wn extends Zn{constructor(t,e,n,a,h){super();const c=+(t!==void 0)+ +(e!==void 0)+ +(n!==void 0)+ +(a!==void 0)+ +(h!==void 0);if(c==3)typeof t=="object"&&typeof e=="object"&&typeof n=="object"?this.createByThreePoints(t,e,n):this.createByStartEndPointsAndBulge(t,e,n);else if(c==5){const m=t;this.center=new Tt(m.x,m.y),this.radius=e,this._clockwise=h,this._startAngle=this._clockwise?this._mirrorAngle(Pt.normalizeAngle(n)):Pt.normalizeAngle(n),this._endAngle=this._clockwise?this._mirrorAngle(Pt.normalizeAngle(a)):Pt.normalizeAngle(a)}else throw Xe.ILLEGAL_PARAMETERS}createByThreePoints(t,e,n){const a=(it,Gt)=>({x:(it.x+Gt.x)/2,y:(it.y+Gt.y)/2}),h=(it,Gt)=>(Gt.y-it.y)/(Gt.x-it.x),c=it=>-1/it,m=a(t,e),b=a(e,n),f=h(t,e),w=h(e,n),x=c(f),S=c(w),M=(it,Gt,Kt,qt)=>{const wt=(qt-Gt)/(it-Kt),Bt=it*wt+Gt;return{x:wt,y:Bt}},N=m.y-x*m.x,O=b.y-S*b.x,F=M(x,N,S,O),D=Math.sqrt(Math.pow(t.x-F.x,2)+Math.pow(t.y-F.y,2)),at=(it,Gt)=>Math.atan2(it.y-Gt.y,it.x-Gt.x),ft=at(t,F),st=at(e,F),H=at(n,F),ut=H>ft&&H<st||ft>H&&ft<st||st>H&&st<ft;this.center=F,this.radius=D,this._clockwise=!ut,this._startAngle=ft,this._endAngle=H}createByStartEndPointsAndBulge(t,e,n){let a,h,c;n<0?(a=Math.atan(-n)*4,h=new Jt(t),c=new Jt(e)):(a=Math.atan(n)*4,h=new Jt(e),c=new Jt(t));const m=new Jt().subVectors(c,h),b=m.length(),f=new Jt().addVectors(h,m.multiplyScalar(.5)),w=Math.abs(b/2/Math.tan(a/2)),x=m.normalize();let S;if(a<Math.PI){const M=new Jt(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));S=f.add(M.multiplyScalar(-w))}else{const M=new Jt(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));S=f.add(M.multiplyScalar(w))}n<0?(this._startAngle=Math.atan2(h.y-S.y,h.x-S.x),this._endAngle=Math.atan2(c.y-S.y,c.x-S.x)):(this._startAngle=Math.atan2(c.y-S.y,c.x-S.x),this._endAngle=Math.atan2(h.y-S.y,h.x-S.x)),this._clockwise=n<0,this.center=S,this.radius=c.sub(S).length()}get center(){return this._center}set center(t){this._center=new Tt(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(Pt.normalizeAngle(t)):Pt.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==Zt?t:Pt.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?Pt.normalizeAngle(t-e):Pt.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),n=Pt.normalizeAngle((t+e)/2),a=this._clockwise?this._mirrorAngle(n):n;return this.getPointAtAngle(a)}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);Pt.isBetweenAngle(c,this._getInternalAngle(this.startAngle),this._getInternalAngle(this.endAngle),this.clockwise)&&t.push(this.getPointAtAngle(h))}const n=t.map(h=>h.x),a=t.map(h=>h.y);return new we(new Tt(Math.min(...n),Math.min(...a)),new Tt(Math.max(...n),Math.max(...a)))}get length(){return Math.abs(this.deltaAngle*this.radius)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}clone(){return new Wn(this.center.clone(),this.radius,this._startAngle,this._endAngle,this.clockwise)}getPointAtAngle(t){const e=this._getInternalAngle(t),n=this.center.x+this.radius*Math.cos(e),a=this.center.y+this.radius*Math.sin(e);return new Tt(n,a)}getPoints(t=100){const e=[];let n=this.deltaAngle,a=this._getInternalAngle(this.startAngle);if(this.closed&&(n=Zt,a=0),this.clockwise)for(let h=0;h<=t;h++){const c=a-n*(h/t),m=this._clockwise?this._mirrorAngle(c):c,b=this.getPointAtAngle(m);e.push(new Tt(b.x,b.y))}else for(let h=0;h<=t;h++){const c=a+n*(h/t),m=this._clockwise?this._mirrorAngle(c):c,b=this.getPointAtAngle(m);e.push(new Tt(b.x,b.y))}return e}}class Hu extends mh{translate(t){return this.transform(new Ye().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 Qs extends Hu{}let Hn=class gh extends Qs{constructor(t,e){super(),this._start=new G(t),this._end=new G(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 X().subVectors(this.endPoint,this.startPoint).normalize()}get midPoint(){return new G((this._start.x+this._end.x)/2,(this._start.y+this._end.y)/2,(this._start.z+this._end.z)/2)}nearestPoint(t){return this.project(t)}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 n=this.delta(on).normalize();return new G(this._start).addScaledVector(n,t)}else{const n=this.delta(on).normalize();return new G(this._end).addScaledVector(n,t)}}extend(t,e=!1){if(e){const n=on.subVectors(this._start,this._end).normalize();this._start=new G(this._start).addScaledVector(n,t)}else{const n=this.delta(on).normalize();this._end=new G(this._end).addScaledVector(n,t)}return this._boundingBoxNeedsUpdate=!0,this}closestPointToPointParameter(t,e){gl.subVectors(t,this._start),si.subVectors(this.endPoint,this.startPoint);const n=si.dot(si);let a=si.dot(gl)/n;return e&&(a=Pt.clamp(a,0,1)),a}closestPointToPoint(t,e,n){const a=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(a).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,n=on.subVectors(t,this.startPoint).dot(e);return new G().copy(e).multiplyScalar(n).add(this.startPoint)}perpPoint(t){const e=this.direction,n=this.startPoint,a=on.subVectors(t,n).dot(e),h=on.copy(e).multiplyScalar(a);return new G().addVectors(n,h)}calculateBoundingBox(){const t=new G(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 G(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 Ct(t,e)}transform(t){return this._start.applyMatrix4(t),this._end.applyMatrix4(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 gh(this._start.clone(),this._end.clone())}};const on=new X,gl=new X,si=new X;let Xa=class ci extends Qs{static computeCenterPoint(t,e,n){const a=new X().addVectors(t,e).multiplyScalar(.5),h=new X().addVectors(t,n).multiplyScalar(.5),c=new X().subVectors(e,t),m=new X().subVectors(n,t),b=new X().crossVectors(c,m).normalize();if(b.lengthSq()===0)return console.error("Points are collinear and cannot form a valid arc."),null;const f=new X().crossVectors(c,b).normalize(),w=new X().crossVectors(m,b).normalize(),x=f.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),S=w.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),M=new Hn(a,a.clone().add(x)),N=new Hn(h,h.clone().add(S)),O=new X;return M.closestPointToPoint(N.startPoint,!0,O)?O:(console.error("Cannot find a valid center for the arc."),null)}static createByThreePoints(t,e,n){const a=ci.computeCenterPoint(t,e,n);if(a){const h=a.distanceTo(t),c=new X().subVectors(t,a),m=new X().subVectors(e,a),b=Math.atan2(c.y,c.x),f=Math.atan2(m.y,m.x);return new ci(a,h,b,f,X.Z_AXIS)}}constructor(t,e,n,a,h,c=X.X_AXIS){super(),this.center=t,this.radius=e,this.startAngle=n,this.endAngle=a,this.normal=h,this.refVec=c,(a-n)%Zt==0?(this.startAngle=0,this.endAngle=Zt):(this.startAngle=n,this.endAngle=a)}get center(){return this._center}set center(t){this._center=new G(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){if(t<0)throw Xe.ILLEGAL_PARAMETERS;this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=Pt.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==Zt?t:Pt.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return Pt.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 X(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get refVec(){return this._refVec}set refVec(t){this._refVec=new X(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 midPoint(){let t=this.startAngle,e=this.deltaAngle;this.closed&&(t=0,e=Zt);const n=t+e*.5;return this.getPointAtAngle(n)}get length(){return this.closed?2*Math.PI*this.radius:Math.abs(this.deltaAngle*this.radius)}get area(){return this.closed?Math.PI*this.radius*this.radius:Math.abs(this.deltaAngle*this.radius*this.radius)}nearestPoint(t){const e=new X(t.x,t.y,t.z||0),n=this.center,a=this.normal,h=e.clone().sub(n).dot(a),c=e.clone().sub(a.clone().multiplyScalar(h)).clone().sub(n);if(c.lengthSq()===0)return this.startPoint.clone();c.normalize().multiplyScalar(this.radius);const m=n.clone().add(c),b=this.getAngle(m.clone()),f=this.startAngle,w=this.deltaAngle;let x=Pt.normalizeAngle(b-f);x<0&&(x=0),x>w&&(x=w);const S=this.getPointAtAngle(f+x),M=S.distanceTo(e),N=this.startPoint.distanceTo(e),O=this.endPoint.distanceTo(e);return N<M&&N<=O?this.startPoint.clone():O<M&&O<N?this.endPoint.clone():S}tangentPoints(t){const e=[],n=new X(t.x,t.y,t.z||0),a=this.center,h=this.normal,c=this.radius,m=n.clone().sub(a).dot(h),b=n.clone().sub(h.clone().multiplyScalar(m)),f=a.clone(),w=b.clone().sub(f).length();if(w<c)return e;const x=Math.acos(c/w),S=this.getAngle(b.clone()),M=[S+x,S-x];for(const N of M){const O=Pt.normalizeAngle(N-this.startAngle);O>=0&&O<=this.deltaAngle&&e.push(this.getPointAtAngle(this.startAngle+O))}return e}nearestTangentPoint(t){const e=this.tangentPoints(t);if(e.length===0)return null;const n=new G(t.x,t.y,t.z||0);return e.length===1||e[0].distanceTo(n)<e[1].distanceTo(n)?e[0]:e[1]}calculateBoundingBox(){const t=[this.startAngle,this.endAngle];for(let b=0;b<2*Math.PI;b+=Math.PI/2)Pt.isBetweenAngle(b,this.startAngle,this.endAngle)&&t.push(b);let e=1/0,n=1/0,a=1/0,h=-1/0,c=-1/0,m=-1/0;for(const b of t){const f=this.getPointAtAngle(b);f.x<e&&(e=f.x),f.y<n&&(n=f.y),f.z<a&&(a=f.z),f.x>h&&(h=f.x),f.y>c&&(c=f.y),f.z>m&&(m=f.z)}return new Ct({x:e,y:n,z:a},{x:h,y:c,z:m})}get closed(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0}getPoints(t){const e=[];let n=this.deltaAngle,a=this.startAngle;this.closed&&(n=Zt,a=0);for(let h=0;h<=t;h++){const c=a+n*(h/t),m=this.getPointAtAngle(c);e.push(m)}return e}transform(t){const e=pa.copy(this.refVec).applyAxisAngle(this.normal,this.startAngle).multiplyScalar(this.radius),n=pa.copy(this.refVec).applyAxisAngle(this.normal,this.endAngle).multiplyScalar(this.radius);return this.center.applyMatrix4(t),e.applyMatrix4(t),n.applyMatrix4(t),this.normal.applyMatrix4(t).normalize(),this.refVec.applyMatrix4(t).normalize(),this.startAngle=this.getAngle(e),this.endAngle=this.getAngle(n),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 ci(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)}getAngle(t){return t.sub(this.center),Math.atan2(t.dot(pa.crossVectors(this.refVec,this.normal)),t.dot(this.refVec))}getPointAtAngle(t){const e=this.normal,n=this.refVec,a={x:e.y*n.z-e.z*n.y,y:e.z*n.x-e.x*n.z,z:e.x*n.y-e.y*n.x},h=this.center,c=this.radius;return new G(h.x+c*(n.x*Math.cos(t)+a.x*Math.sin(t)),h.y+c*(n.y*Math.cos(t)+a.y*Math.sin(t)),h.z+c*(n.z*Math.cos(t)+a.z*Math.sin(t)))}get plane(){const t=new X(this.center).distanceTo(Ga);return new Zs(this.normal,t)}};const pa=new X;class Ki extends Zn{constructor(t,e,n,a=0,h=Zt,c=!1,m=0){super(),this.center=t,this.majorAxisRadius=e,this.minorAxisRadius=n,(h-a)%Zt==0?(this.startAngle=0,this.endAngle=Zt):(this.startAngle=a,this.endAngle=h),this.clockwise=c,this.rotation=m}get center(){return this._center}set center(t){this._center=new G(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw Xe.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw Xe.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=Pt.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==Zt?t:Pt.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 Pt.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}calculateBoundingBox(){let t=1/0,e=1/0,n=-1/0,a=-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),n=Math.max(n,c.x),a=Math.max(a,c.y)}return new we({x:t,y:e},{x:n,y:a})}get closed(){return this.deltaAngle==0}getPoint(t){const e=Math.PI*2;let n=this.endAngle-this.startAngle;const a=Math.abs(n)<Number.EPSILON;for(;n<0;)n+=e;for(;n>e;)n-=e;n<Number.EPSILON&&(a?n=0:n=e),this.clockwise===!0&&!a&&(n===e?n=-e:n=n-e);const h=this.startAngle+t*n;let c=this.center.x+this.majorAxisRadius*Math.cos(h),m=this.center.y+this.minorAxisRadius*Math.sin(h);if(this.rotation!==0){const b=Math.cos(this.rotation),f=Math.sin(this.rotation),w=c-this.center.x,x=m-this.center.y;c=w*b-x*f+this.center.x,m=w*f+x*b+this.center.y}return new Tt(c,m)}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 Ki(this.center,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle,this.clockwise,this.rotation)}}class $i extends Qs{constructor(t,e,n,a,h,c=0,m=Zt){super(),this.center=t,this.normal=e,this.majorAxis=n,this.majorAxisRadius=a,this.minorAxisRadius=h;const b=Math.abs(m-c);Math.abs(b-Zt)<1e-10||Math.abs(b-2*Zt)<1e-10?(this.startAngle=0,this.endAngle=Zt):(this.startAngle=c,this.endAngle=m)}get center(){return this._center}set center(t){this._center=new G(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw Xe.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw Xe.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=Pt.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==Zt?t:Pt.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){const t=this.endAngle-this.startAngle;return Math.abs(t-Zt)<1e-10?Zt:Pt.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 X(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get majorAxis(){return this._majorAxis}set majorAxis(t){this._majorAxis=new X(t.x,t.y,t.z),this._majorAxis.normalize(),this._boundingBoxNeedsUpdate=!0}get minorAxis(){return new X().crossVectors(this.normal,this.majorAxis).normalize()}get startPoint(){return this.getPointAtAngle(this._startAngle)}get endPoint(){return this.getPointAtAngle(this._endAngle)}get midPoint(){let t=this.startAngle,e=this.deltaAngle;(this.closed||Math.abs(e-Zt)<1e-10)&&(t=0,e=Zt);const n=t+e/2;return this.getPointAtAngle(n)}get isCircular(){return Wa.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 n=0,a=this.getPointAtAngle(this.startAngle);for(let h=1;h<=t;h++){const c=this.startAngle+h*e,m=this.getPointAtAngle(c),b=m.x-a.x,f=m.y-a.y,w=m.z-a.z;n+=Math.sqrt(b*b+f*f+w*w),a=m}return n}get area(){const t=this.majorAxisRadius,e=this.minorAxisRadius,n=this.startAngle,a=n+this.deltaAngle;if(Math.abs(this.deltaAngle-Zt)<1e-10)return Math.PI*t*e;const h=t*e/2*(a-n-(Math.sin(a)*Math.cos(a)-Math.sin(n)*Math.cos(n)));return Math.abs(h)}calculateBoundingBox(){if(this.majorAxis.equals(X.X_AXIS)||this.majorAxis.equals(X.Y_AXIS)||this.majorAxis.isParallelTo(X.X_AXIS)||this.majorAxis.isParallelTo(X.Y_AXIS)){const t=[this.startAngle,this.endAngle];for(let b=0;b<2*Math.PI;b+=Math.PI/2)Pt.isBetweenAngle(b,this.startAngle,this.endAngle)&&t.push(b);let e=1/0,n=1/0,a=1/0,h=-1/0,c=-1/0,m=-1/0;for(const b of t){const f=this.getPointAtAngle(b);f.x<e&&(e=f.x),f.y<n&&(n=f.y),f.z<a&&(a=f.z),f.x>h&&(h=f.x),f.y>c&&(c=f.y),f.z>m&&(m=f.z)}return new Ct({x:e,y:n,z:a},{x:h,y:c,z:m})}else{let t=1/0,e=1/0,n=1/0,a=-1/0,h=-1/0,c=-1/0;for(let m=0;m<=100;m++){const b=this.startAngle+this.deltaAngle*(m/100),f=this.getPointAtAngle(b);t=Math.min(t,f.x),e=Math.min(e,f.y),n=Math.min(n,f.z),a=Math.max(a,f.x),h=Math.max(h,f.y),c=Math.max(c,f.z)}return new Ct({x:t,y:e,z:n},{x:a,y:h,z:c})}}get closed(){return this.deltaAngle==0}getPoints(t=100){const e=[];let n=this.deltaAngle,a=this.startAngle;this.closed&&(n=Zt,a=0);for(let h=0;h<=t;h++){const c=a+n*(h/t),m=this.getPointAtAngle(c);e.push(m)}return e}getPointAtAngle(t){const e=Math.cos(t),n=Math.sin(t),a=this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(n),h=this.majorAxis.clone().multiplyScalar(e*this.majorAxisRadius).add(a);return new G(this.center.x+h.x,this.center.y+h.y,this.center.z+h.z)}contains(t){const e=new X(t).sub(this.center),n=e.dot(this.majorAxis),a=e.dot(this.minorAxis),h=n/this.majorAxisRadius,c=a/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 $i(this.center,this.normal,this.majorAxis,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle)}get plane(){const t=new X(this.center).distanceTo(Ga);return new Zs(this.normal,t)}}class An extends Zn{constructor(t=null,e=!1){super(),this._vertices=t||new Array,this._closed=e}get vertices(){return this._vertices}get numberOfVertices(){return this._vertices.length}get closed(){return this._closed}get startPoint(){if(this.numberOfVertices>0){const t=this._vertices[0];return new Tt(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 Tt(e.x,e.y)}else{const e=this._vertices[t-1];return new Tt(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 n=0;n<e;++n){const a=this._vertices[n];let h=null;if(n<e-1?h=this._vertices[n+1]:n==e-1&&this.closed&&(h=this._vertices[0]),h)if(a.bulge){const c=new Wn(a,h,a.bulge);t+=c.length}else t+=new Tt(a.x,a.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 Tt(e.x,e.y)}calculateBoundingBox(){const t=this.getPoints(100);return new we().setFromPoints(t)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}getPoints3d(t,e){const n=[];return this.getPoints(t).forEach(a=>n.push(new G().set(a.x,a.y,e))),n}getPoints(t){const e=[],n=this._vertices.length;for(let a=0;a<n;++a){const h=this._vertices[a];if(h.bulge){let c=null;if(a<n-1?c=this._vertices[a+1]:a==n-1&&this.closed&&(c=this._vertices[0]),c){const m=new Wn(h,c,h.bulge).getPoints(t),b=m.length;for(let f=0;f<b;++f){const w=m[f];e.push(new Tt(w.x,w.y))}}}else e.push(new Tt(h.x,h.y)),a==n-1&&this.closed&&e.push(e[0])}return e}}let Us=class fh extends Zn{constructor(t,e){super(),this._start=new Tt(t),this._end=new Tt(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 Tt(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y)),e=new Tt(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y));return new we(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 fh(this._start.clone(),this._end.clone())}},Ka=class extends Zn{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 Tt(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 we;return e.setFromPoints(t),e}transform(t){return this._boundingBoxNeedsUpdate=!0,this}get closed(){return!0}getPoints(t){const e=[];return this.curves.forEach(n=>{n.getPoints(t).forEach(a=>{e.push(new Tt(a.x,a.y))})}),e}};function qu(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var _h={exports:{}};(function(i,t){(function(e){i.exports=e()})(function(){var e={},n=this;new Function("try {return this===window;}catch(e){ return false;}");var a=new Function("try {return this===global;}catch(e){return false;}"),h=new Function("try {return typeof importScripts === 'function';}catch(e){return false;}");if(a()&&h(),a()||h()){var c=n;if(h()){var m=function(b,f){var w=n;return b.split(".").forEach(function(x){w&&(w=w[x])}),w?w[f]:null};onmessage=function(b){if(!(!b.data.className||!b.data.methodName)){var f=m(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,w){f.geom=f.geom||{},f.exe=f.exe||{},f.eval=f.eval||{},f.core=f.core||{},f.promhx=f.promhx||{};var x={},S=function(){return Nt.__string_rec(this,"")};function M(r,s){function o(){}o.prototype=r;var l=new o;for(var u in s)l[u]=s[u];return s.toString!==Object.prototype.toString&&(l.toString=s.toString),l}var N=function(){};x.HxOverrides=N,N.__name__=["HxOverrides"],N.strDate=function(r){var s=r.length;switch(s){case 8:var o=r.split(":"),l=new Date;return l.setTime(0),l.setUTCHours(o[0]),l.setUTCMinutes(o[1]),l.setUTCSeconds(o[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(" "),g=d[0].split("-"),_=d[1].split(":");return new Date(g[0],g[1]-1,g[2],_[0],_[1],_[2]);default:throw new Q("Invalid date format : "+r)}},N.cca=function(r,s){var o=r.charCodeAt(s);if(o==o)return o},N.substr=function(r,s,o){return s!=null&&s!=0&&o!=null&&o<0?"":(o==null&&(o=r.length),s<0?(s=r.length+s,s<0&&(s=0)):o<0&&(o=r.length+o-s),r.substr(s,o))},N.iter=function(r){return{cur:0,arr:r,hasNext:function(){return this.cur<this.arr.length},next:function(){return this.arr[this.cur++]}}};var O=function(){};x.Lambda=O,O.__name__=["Lambda"],O.fold=function(r,s,o){for(var l=tr(r)();l.hasNext();){var u=l.next();o=s(u,o)}return o};var F=function(){this.length=0};x.List=F,F.__name__=["List"],F.prototype={add:function(r){var s=[r];this.h==null?this.h=s:this.q[1]=s,this.q=s,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__:F},Math.__name__=["Math"];var D=function(){};x.Reflect=D,D.__name__=["Reflect"],D.field=function(r,s){try{return r[s]}catch(o){return o instanceof Q&&(o=o.val),null}},D.callMethod=function(r,s,o){return s.apply(r,o)},D.fields=function(r){var s=[];if(r!=null){var o=Object.prototype.hasOwnProperty;for(var l in r)l!="__id__"&&l!="hx__closures__"&&o.call(r,l)&&s.push(l)}return s},D.isFunction=function(r){return typeof r=="function"&&!(r.__name__||r.__ename__)},D.deleteField=function(r,s){return Object.prototype.hasOwnProperty.call(r,s)?(delete r[s],!0):!1};var at=function(){};x.Std=at,at.__name__=["Std"],at.string=function(r){return Nt.__string_rec(r,"")},at.parseFloat=function(r){return parseFloat(r)};var ft=function(){this.b=""};x.StringBuf=ft,ft.__name__=["StringBuf"],ft.prototype={add:function(r){this.b+=at.string(r)},__class__:ft};var st=function(){};x.StringTools=st,st.__name__=["StringTools"],st.fastCodeAt=function(r,s){return r.charCodeAt(s)};var H=x.ValueType={__ename__:["ValueType"],__constructs__:["TNull","TInt","TFloat","TBool","TObject","TFunction","TClass","TEnum","TUnknown"]};H.TNull=["TNull",0],H.TNull.toString=S,H.TNull.__enum__=H,H.TInt=["TInt",1],H.TInt.toString=S,H.TInt.__enum__=H,H.TFloat=["TFloat",2],H.TFloat.toString=S,H.TFloat.__enum__=H,H.TBool=["TBool",3],H.TBool.toString=S,H.TBool.__enum__=H,H.TObject=["TObject",4],H.TObject.toString=S,H.TObject.__enum__=H,H.TFunction=["TFunction",5],H.TFunction.toString=S,H.TFunction.__enum__=H,H.TClass=function(r){var s=["TClass",6,r];return s.__enum__=H,s.toString=S,s},H.TEnum=function(r){var s=["TEnum",7,r];return s.__enum__=H,s.toString=S,s},H.TUnknown=["TUnknown",8],H.TUnknown.toString=S,H.TUnknown.__enum__=H;var ut=function(){};x.Type=ut,ut.__name__=["Type"],ut.getClassName=function(r){var s=r.__name__;return s==null?null:s.join(".")},ut.getEnumName=function(r){var s=r.__ename__;return s.join(".")},ut.resolveClass=function(r){var s=x[r];return s==null||!s.__name__?null:s},ut.resolveEnum=function(r){var s=x[r];return s==null||!s.__ename__?null:s},ut.createEmptyInstance=function(r){function s(){}return s.prototype=r.prototype,new s},ut.createEnum=function(r,s,o){var l=D.field(r,s);if(l==null)throw new Q("No such constructor "+s);if(D.isFunction(l)){if(o==null)throw new Q("Constructor "+s+" need parameters");return D.callMethod(r,l,o)}if(o!=null&&o.length!=0)throw new Q("Constructor "+s+" does not need parameters");return l},ut.getEnumConstructs=function(r){var s=r.__constructs__;return s.slice()},ut.typeof=function(r){var s=typeof r;switch(s){case"boolean":return H.TBool;case"string":return H.TClass(String);case"number":return Math.ceil(r)==r%2147483648?H.TInt:H.TFloat;case"object":if(r==null)return H.TNull;var o=r.__enum__;if(o!=null)return H.TEnum(o);var l=Nt.getClass(r);return l!=null?H.TClass(l):H.TObject;case"function":return r.__name__||r.__ename__?H.TObject:H.TFunction;case"undefined":return H.TNull;default:return H.TUnknown}};var it=function(){};x["haxe.IMap"]=it,it.__name__=["haxe","IMap"];var Gt=function(r,s){this.high=r,this.low=s};x["haxe._Int64.___Int64"]=Gt,Gt.__name__=["haxe","_Int64","___Int64"],Gt.prototype={__class__:Gt};var Kt=function(){this.buf=new ft,this.cache=[],this.useCache=Kt.USE_CACHE,this.useEnumIndex=Kt.USE_ENUM_INDEX,this.shash=new _e,this.scount=0};x["haxe.Serializer"]=Kt,Kt.__name__=["haxe","Serializer"],Kt.prototype={toString:function(){return this.buf.b},serializeString:function(r){var s=this.shash.get(r);if(s!=null){this.buf.b+="R",s==null?this.buf.b+="null":this.buf.b+=""+s;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 s=typeof r,o=0,l=this.cache.length;o<l;){var u=o++,d=this.cache[u];if(typeof d==s&&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 s=0,o=D.fields(r);s<o.length;){var l=o[s];++s,this.serializeString(l),this.serialize(D.field(r,l))}this.buf.b+="g"},serialize:function(r){{var s=ut.typeof(r);switch(s[1]){case 0:this.buf.b+="n";break;case 1:var o=r;if(o==0){this.buf.b+="z";return}this.buf.b+="i",o==null?this.buf.b+="null":this.buf.b+=""+o;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=s[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 g=r.length,_=0;_<g;){var y=_++;r[y]==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[y]))}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 F:this.buf.b+="l";for(var A=r,I=A.h,P=null;I!=null;){var E;P=I[0],I=I[1],E=P,this.serialize(E)}this.buf.b+="h";break;case Date:var k=r;this.buf.b+="v",this.buf.add(k.getTime());break;case _e:this.buf.b+="b";for(var T=r,B=T.keys();B.hasNext();){var L=B.next();this.serializeString(L),this.serialize(na[L]!=null?T.getReserved(L):T.h[L])}this.buf.b+="h";break;case wt:this.buf.b+="q";for(var R=r,z=R.keys();z.hasNext();){var V=z.next();this.buf.b+=":",V==null?this.buf.b+="null":this.buf.b+=""+V,this.serialize(R.h[V])}this.buf.b+="h";break;case Bt:this.buf.b+="M";for(var U=r,Y=U.keys();Y.hasNext();){var J=Y.next(),q=D.field(J,"__id__");D.deleteField(J,"__id__"),this.serialize(J),J.__id__=q,this.serialize(U.h[J.__id__])}this.buf.b+="h";break;case Be:for(var j=r,$=0,tt=j.length-2,et=new ft,ot=Kt.BASE64;$<tt;){var ct=j.get($++),lt=j.get($++),dt=j.get($++);et.add(ot.charAt(ct>>2)),et.add(ot.charAt((ct<<4|lt>>4)&63)),et.add(ot.charAt((lt<<2|dt>>6)&63)),et.add(ot.charAt(dt&63))}if($==tt){var nt=j.get($++),mt=j.get($++);et.add(ot.charAt(nt>>2)),et.add(ot.charAt((nt<<4|mt>>4)&63)),et.add(ot.charAt(mt<<2&63))}else if($==tt+1){var K=j.get($++);et.add(ot.charAt(K>>2)),et.add(ot.charAt(K<<4&63))}var _t=et.b;this.buf.b+="s",_t.length==null?this.buf.b+="null":this.buf.b+=""+_t.length,this.buf.b+=":",_t==null?this.buf.b+="null":this.buf.b+=""+_t;break;default:this.useCache&&this.cache.pop(),r.hxSerialize!=null?(this.buf.b+="C",this.serializeString(ut.getClassName(u)),this.useCache&&this.cache.push(r),r.hxSerialize(this),this.buf.b+="g"):(this.buf.b+="c",this.serializeString(ut.getClassName(u)),this.useCache&&this.cache.push(r),this.serializeFields(r))}break;case 4:if(Nt.__instanceof(r,Yo)){var Et=ut.getClassName(r);this.buf.b+="A",this.serializeString(Et)}else if(Nt.__instanceof(r,Xo))this.buf.b+="B",this.serializeString(ut.getEnumName(r));else{if(this.useCache&&this.serializeRef(r))return;this.buf.b+="o",this.serializeFields(r)}break;case 7:var Ht=s[2];if(this.useCache){if(this.serializeRef(r))return;this.cache.pop()}this.useEnumIndex?this.buf.b+="j":this.buf.b+="w",this.serializeString(ut.getEnumName(Ht)),this.useEnumIndex?(this.buf.b+=":",this.buf.b+=at.string(r[1])):this.serializeString(r[0]),this.buf.b+=":";var $t=r.length;this.buf.b+=at.string($t-2);for(var Ut=2;Ut<$t;){var Qt=Ut++;this.serialize(r[Qt])}this.useCache&&this.cache.push(r);break;case 5:throw new Q("Cannot serialize function");default:throw new Q("Cannot serialize "+at.string(r))}}},__class__:Kt};var qt=function(r){this.buf=r,this.length=r.length,this.pos=0,this.scache=[],this.cache=[];var s=qt.DEFAULT_RESOLVER;s==null&&(s=ut,qt.DEFAULT_RESOLVER=s),this.setResolver(s)};x["haxe.Unserializer"]=qt,qt.__name__=["haxe","Unserializer"],qt.initCodes=function(){for(var r=[],s=0,o=qt.BASE64.length;s<o;){var l=s++;r[qt.BASE64.charCodeAt(l)]=l}return r},qt.prototype={setResolver:function(r){r==null?this.resolver={resolveClass:function(s){return null},resolveEnum:function(s){return null}}:this.resolver=r},get:function(r){return this.buf.charCodeAt(r)},readDigits:function(){for(var r=0,s=!1,o=this.pos;;){var l=this.buf.charCodeAt(this.pos);if(l!=l)break;if(l==45){if(this.pos!=o)break;s=!0,this.pos++;continue}if(l<48||l>57)break;r=r*10+(l-48),this.pos++}return s&&(r*=-1),r},readFloat:function(){for(var r=this.pos;;){var s=this.buf.charCodeAt(this.pos);if(s>=43&&s<58||s==101||s==69)this.pos++;else break}return at.parseFloat(N.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 s=this.unserialize();if(typeof s!="string")throw new Q("Invalid object key");var o=this.unserialize();r[s]=o}this.pos++},unserializeEnum:function(r,s){if(this.get(this.pos++)!=58)throw new Q("Invalid enum format");var o=this.readDigits();if(o==0)return ut.createEnum(r,s);for(var l=[];o-- >0;)l.push(this.unserialize());return ut.createEnum(r,s,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 s=this.readDigits();if(this.get(this.pos++)!=58||this.length-this.pos<s)throw new Q("Invalid string length");var o=N.substr(this.buf,this.pos,s);return this.pos+=s,o=decodeURIComponent(o.split("+").join(" ")),this.scache.push(o),o;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 g={};return this.cache.push(g),this.unserializeObject(g),g;case 114:var _=this.readDigits();if(_<0||_>=this.cache.length)throw new Q("Invalid reference");return this.cache[_];case 82:var y=this.readDigits();if(y<0||y>=this.scache.length)throw new Q("Invalid string reference");return this.scache[y];case 120:throw new Q(this.unserialize());case 99:var A=this.unserialize(),I=this.resolver.resolveClass(A);if(I==null)throw new Q("Class not found "+A);var P=ut.createEmptyInstance(I);return this.cache.push(P),this.unserializeObject(P),P;case 119:var E=this.unserialize(),k=this.resolver.resolveEnum(E);if(k==null)throw new Q("Enum not found "+E);var T=this.unserializeEnum(k,this.unserialize());return this.cache.push(T),T;case 106:var B=this.unserialize(),L=this.resolver.resolveEnum(B);if(L==null)throw new Q("Enum not found "+B);this.pos++;var R=this.readDigits(),z=ut.getEnumConstructs(L)[R];if(z==null)throw new Q("Unknown enum index "+B+"@"+R);var V=this.unserializeEnum(L,z);return this.cache.push(V),V;case 108:var U=new F;for(this.cache.push(U),this.buf;this.buf.charCodeAt(this.pos)!=104;)U.add(this.unserialize());return this.pos++,U;case 98:var Y=new _e;for(this.cache.push(Y),this.buf;this.buf.charCodeAt(this.pos)!=104;){var J=this.unserialize();Y.set(J,this.unserialize())}return this.pos++,Y;case 113:var q=new wt;this.cache.push(q),this.buf;for(var j=this.get(this.pos++);j==58;){var $=this.readDigits();q.set($,this.unserialize()),j=this.get(this.pos++)}if(j!=104)throw new Q("Invalid IntMap format");return q;case 77:var tt=new Bt;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 ot;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 ct=N.substr(this.buf,this.pos,19);ot=N.strDate(ct),this.pos+=19}else{var lt=this.readFloat(),dt=new Date;dt.setTime(lt),ot=dt}return this.cache.push(ot),ot;case 115:var nt=this.readDigits(),mt=this.buf;if(this.get(this.pos++)!=58||this.length-this.pos<nt)throw new Q("Invalid bytes length");var K=qt.CODES;K==null&&(K=qt.initCodes(),qt.CODES=K);var _t=this.pos,Et=nt&3,Ht;Ht=(nt>>2)*3+(Et>=2?Et-1:0);for(var $t=_t+(nt-Et),Ut=Be.alloc(Ht),Qt=0;_t<$t;){var Ne=K[st.fastCodeAt(mt,_t++)],Ze=K[st.fastCodeAt(mt,_t++)];Ut.set(Qt++,Ne<<2|Ze>>4);var Ae=K[st.fastCodeAt(mt,_t++)];Ut.set(Qt++,Ze<<4|Ae>>2);var ve=K[st.fastCodeAt(mt,_t++)];Ut.set(Qt++,Ae<<6|ve)}if(Et>=2){var Le=K[st.fastCodeAt(mt,_t++)],Fe=K[st.fastCodeAt(mt,_t++)];if(Ut.set(Qt++,Le<<2|Fe>>4),Et==3){var er=K[st.fastCodeAt(mt,_t++)];Ut.set(Qt++,Fe<<4|er>>2)}}return this.pos+=nt,this.cache.push(Ut),Ut;case 67:var pr=this.unserialize(),rr=this.resolver.resolveClass(pr);if(rr==null)throw new Q("Class not found "+pr);var nr=ut.createEmptyInstance(rr);if(this.cache.push(nr),nr.hxUnserialize(this),this.get(this.pos++)!=103)throw new Q("Invalid custom data");return nr;case 65:var sr=this.unserialize(),br=this.resolver.resolveClass(sr);if(br==null)throw new Q("Class not found "+sr);return br;case 66:var Rn=this.unserialize(),nn=this.resolver.resolveEnum(Rn);if(nn==null)throw new Q("Enum not found "+Rn);return nn}throw this.pos--,new Q("Invalid char "+this.buf.charAt(this.pos)+" at position "+this.pos)},__class__:qt};var wt=function(){this.h={}};x["haxe.ds.IntMap"]=wt,wt.__name__=["haxe","ds","IntMap"],wt.__interfaces__=[it],wt.prototype={set:function(r,s){this.h[r]=s},remove:function(r){return this.h.hasOwnProperty(r)?(delete this.h[r],!0):!1},keys:function(){var r=[];for(var s in this.h)this.h.hasOwnProperty(s)&&r.push(s|0);return N.iter(r)},__class__:wt};var Bt=function(){this.h={},this.h.__keys__={}};x["haxe.ds.ObjectMap"]=Bt,Bt.__name__=["haxe","ds","ObjectMap"],Bt.__interfaces__=[it],Bt.prototype={set:function(r,s){var o=r.__id__||(r.__id__=++Bt.count);this.h[o]=s,this.h.__keys__[o]=r},keys:function(){var r=[];for(var s in this.h.__keys__)this.h.hasOwnProperty(s)&&r.push(this.h.__keys__[s]);return N.iter(r)},__class__:Bt};var fe=x["haxe.ds.Option"]={__ename__:["haxe","ds","Option"],__constructs__:["Some","None"]};fe.Some=function(r){var s=["Some",0,r];return s.__enum__=fe,s.toString=S,s},fe.None=["None",1],fe.None.toString=S,fe.None.__enum__=fe;var _e=function(){this.h={}};x["haxe.ds.StringMap"]=_e,_e.__name__=["haxe","ds","StringMap"],_e.__interfaces__=[it],_e.prototype={set:function(r,s){na[r]!=null?this.setReserved(r,s):this.h[r]=s},get:function(r){return na[r]!=null?this.getReserved(r):this.h[r]},setReserved:function(r,s){this.rh==null&&(this.rh={}),this.rh["$"+r]=s},getReserved:function(r){return this.rh==null?null:this.rh["$"+r]},keys:function(){var r=this.arrayKeys();return N.iter(r)},arrayKeys:function(){var r=[];for(var s in this.h)this.h.hasOwnProperty(s)&&r.push(s);if(this.rh!=null)for(var s in this.rh)s.charCodeAt(0)==36&&r.push(s.substr(1));return r},__class__:_e};var Be=function(r){this.length=r.byteLength,this.b=new sa(r),this.b.bufferValue=r,r.hxBytes=this,r.bytes=this.b};x["haxe.io.Bytes"]=Be,Be.__name__=["haxe","io","Bytes"],Be.alloc=function(r){return new Be(new ri(r))},Be.prototype={get:function(r){return this.b[r]},set:function(r,s){this.b[r]=s&255},__class__:Be};var re=x["haxe.io.Error"]={__ename__:["haxe","io","Error"],__constructs__:["Blocked","Overflow","OutsideBounds","Custom"]};re.Blocked=["Blocked",0],re.Blocked.toString=S,re.Blocked.__enum__=re,re.Overflow=["Overflow",1],re.Overflow.toString=S,re.Overflow.__enum__=re,re.OutsideBounds=["OutsideBounds",2],re.OutsideBounds.toString=S,re.OutsideBounds.__enum__=re,re.Custom=function(r){var s=["Custom",3,r];return s.__enum__=re,s.toString=S,s};var ce=function(){};x["haxe.io.FPHelper"]=ce,ce.__name__=["haxe","io","FPHelper"],ce.i32ToFloat=function(r){var s=1-(r>>>31<<1),o=r>>>23&255,l=r&8388607;return l==0&&o==0?0:s*(1+Math.pow(2,-23)*l)*Math.pow(2,o-127)},ce.floatToI32=function(r){if(r==0)return 0;var s;r<0?s=-r:s=r;var o=Math.floor(Math.log(s)/.6931471805599453);o<-127?o=-127:o>128&&(o=128);var l=Math.round((s/Math.pow(2,o)-1)*8388608)&8388607;return(r<0?-2147483648:0)|o+127<<23|l},ce.i64ToDouble=function(r,s){var o=1-(s>>>31<<1),l=(s>>20&2047)-1023,u=(s&1048575)*4294967296+(r>>>31)*2147483648+(r&2147483647);return u==0&&l==-1023?0:o*(1+Math.pow(2,-52)*u)*Math.pow(2,l)},ce.doubleToI64=function(r){var s=ce.i64tmp;if(r==0)s.low=0,s.high=0;else{var o;r<0?o=-r:o=r;var l=Math.floor(Math.log(o)/.6931471805599453),u,d=(o/Math.pow(2,l)-1)*4503599627370496;u=Math.round(d);var g=u|0,_=u/4294967296|0;s.low=g,s.high=(r<0?-2147483648:0)|l+1023<<20|_}return s};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 Nt=function(){};x["js.Boot"]=Nt,Nt.__name__=["js","Boot"],Nt.getClass=function(r){if(r instanceof Array&&r.__enum__==null)return Array;var s=r.__class__;if(s!=null)return s;var o=Nt.__nativeClassName(r);return o!=null?Nt.__resolveNativeClass(o):null},Nt.__string_rec=function(r,s){if(r==null)return"null";if(s.length>=5)return"<...>";var o=typeof r;switch(o=="function"&&(r.__name__||r.__ename__)&&(o="object"),o){case"object":if(r instanceof Array){if(r.__enum__){if(r.length==2)return r[0];var l=r[0]+"(";s+=" ";for(var u=2,d=r.length;u<d;){var g=u++;g!=2?l+=","+Nt.__string_rec(r[g],s):l+=Nt.__string_rec(r[g],s)}return l+")"}var _=r.length,y="[";s+=" ";for(var A=0;A<_;){var I=A++;y+=(I>0?",":"")+Nt.__string_rec(r[I],s)}return y+="]",y}var P;try{P=r.toString}catch(L){return L instanceof Q&&(L=L.val),"???"}if(P!=null&&P!=Object.toString&&typeof P=="function"){var E=r.toString();if(E!="[object Object]")return E}var k=null,T=`{
2
2
  `;s+=" ";var B=r.hasOwnProperty!=null;for(var k in r)B&&!r.hasOwnProperty(k)||k=="prototype"||k=="__class__"||k=="__super__"||k=="__interfaces__"||k=="__properties__"||(T.length!=2&&(T+=`,
3
3
  `),T+=s+k+" : "+Nt.__string_rec(r[k],s));return s=s.substring(1),T+=`
4
- `+s+"}",T;case"function":return"<function>";case"string":return r;default:return String(r)}},Nt.__interfLoop=function(r,s){if(r==null)return!1;if(r==s)return!0;var o=r.__interfaces__;if(o!=null)for(var l=0,u=o.length;l<u;){var d=l++,g=o[d];if(g==s||Nt.__interfLoop(g,s))return!0}return Nt.__interfLoop(r.__super__,s)},Nt.__instanceof=function(r,s){if(s==null)return!1;switch(s){case uu:return(r|0)===r;case Ho:return typeof r=="number";case qo:return typeof r=="boolean";case String:return typeof r=="string";case Array:return r instanceof Array&&r.__enum__==null;case du:return!0;default:if(r!=null){if(typeof s=="function"){if(r instanceof s||Nt.__interfLoop(Nt.getClass(r),s))return!0}else if(typeof s=="object"&&Nt.__isNativeObj(s)&&r instanceof s)return!0}else return!1;return s==Yo&&r.__name__!=null||s==Xo&&r.__ename__!=null?!0:r.__enum__==s}},Nt.__nativeClassName=function(r){var s=Nt.__toStr.call(r).slice(8,-1);return s=="Object"||s=="Function"||s=="Math"||s=="JSON"?null:s},Nt.__isNativeObj=function(r){return Nt.__nativeClassName(r)!=null},Nt.__resolveNativeClass=function(r){return w[r]};var ce=function(r){if(r instanceof Array&&r.__enum__==null)this.a=r,this.byteLength=r.length;else{var s=r;this.a=[];for(var o=0;o<s;){var l=o++;this.a[l]=0}this.byteLength=s}};x["js.html.compat.ArrayBuffer"]=ce,ce.__name__=["js","html","compat","ArrayBuffer"],ce.sliceImpl=function(r,s){var o=new ra(this,r,s==null?null:s-r),l=new ri(o.byteLength),u=new ra(l);return u.set(o),l},ce.prototype={slice:function(r,s){return new ce(this.a.slice(r,s))},__class__:ce};var fr=function(r,s,o){if(this.buf=r,s==null?this.offset=0:this.offset=s,o==null?this.length=r.byteLength-this.offset:this.length=o,this.offset<0||this.length<0||this.offset+this.length>r.byteLength)throw new Q(re.OutsideBounds)};x["js.html.compat.DataView"]=fr,fr.__name__=["js","html","compat","DataView"],fr.prototype={getInt8:function(r){var s=this.buf.a[this.offset+r];return s>=128?s-256:s},getUint8:function(r){return this.buf.a[this.offset+r]},getInt16:function(r,s){var o=this.getUint16(r,s);return o>=32768?o-65536:o},getUint16:function(r,s){return s?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,s){var o=this.offset+r,l=this.buf.a[o++],u=this.buf.a[o++],d=this.buf.a[o++],g=this.buf.a[o++];return s?l|u<<8|d<<16|g<<24:g|d<<8|u<<16|l<<24},getUint32:function(r,s){var o=this.getInt32(r,s);return o<0?o+4294967296:o},getFloat32:function(r,s){return he.i32ToFloat(this.getInt32(r,s))},getFloat64:function(r,s){var o=this.getInt32(r,s),l=this.getInt32(r+4,s);return he.i64ToDouble(s?o:l,s?l:o)},setInt8:function(r,s){s<0?this.buf.a[r+this.offset]=s+128&255:this.buf.a[r+this.offset]=s&255},setUint8:function(r,s){this.buf.a[r+this.offset]=s&255},setInt16:function(r,s,o){this.setUint16(r,s<0?s+65536:s,o)},setUint16:function(r,s,o){var l=r+this.offset;o?(this.buf.a[l]=s&255,this.buf.a[l++]=s>>8&255):(this.buf.a[l++]=s>>8&255,this.buf.a[l]=s&255)},setInt32:function(r,s,o){this.setUint32(r,s,o)},setUint32:function(r,s,o){var l=r+this.offset;o?(this.buf.a[l++]=s&255,this.buf.a[l++]=s>>8&255,this.buf.a[l++]=s>>16&255,this.buf.a[l++]=s>>>24):(this.buf.a[l++]=s>>>24,this.buf.a[l++]=s>>16&255,this.buf.a[l++]=s>>8&255,this.buf.a[l++]=s&255)},setFloat32:function(r,s,o){this.setUint32(r,he.floatToI32(s),o)},setFloat64:function(r,s,o){var l=he.doubleToI64(s);o?(this.setUint32(r,l.low),this.setUint32(r,l.high)):(this.setUint32(r,l.high),this.setUint32(r,l.low))},__class__:fr};var hr=function(){};x["js.html.compat.Uint8Array"]=hr,hr.__name__=["js","html","compat","Uint8Array"],hr._new=function(r,s,o){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 ce(l)}else if(Nt.__instanceof(r,ce)){var g=r;s==null&&(s=0),o==null&&(o=g.byteLength-s),s==0?l=g.a:l=g.a.slice(s,s+o),l.byteLength=l.length,l.byteOffset=s,l.buffer=g}else if(r instanceof Array&&r.__enum__==null)l=r.slice(),l.byteLength=l.length,l.byteOffset=0,l.buffer=new ce(l);else throw new Q("TODO "+dt.string(r));return l.subarray=hr._subarray,l.set=hr._set,l},hr._set=function(r,s){var o=this;if(Nt.__instanceof(r.buffer,ce)){var l=r;if(r.byteLength+s>o.byteLength)throw new Q("set() outside of range");for(var u=0,d=r.byteLength;u<d;){var g=u++;o[g+s]=l[g]}}else if(r instanceof Array&&r.__enum__==null){var _=r;if(_.length+s>o.byteLength)throw new Q("set() outside of range");for(var y=0,A=_.length;y<A;){var S=y++;o[S+s]=_[S]}}else throw new Q("TODO")},hr._subarray=function(r,s){var o=this,l=hr._new(o.slice(r,s));return l.byteOffset=r,l};var kt=function(r){this._resolved=!1,this._pending=!1,this._errorPending=!1,this._fulfilled=!1,this._update=[],this._error=[],this._errored=!1,r!=null&&kt.link(r,this,function(s){return s})};x["promhx.base.AsyncBase"]=kt,kt.__name__=["promhx","base","AsyncBase"],kt.link=function(r,s,o){r._update.push({async:s,linkf:function(l){s.handleResolve(o(l))}}),kt.immediateLinkUpdate(r,s,o)},kt.immediateLinkUpdate=function(r,s,o){if(r._errored&&!r._errorPending&&!(r._error.length>0)&&s.handleError(r._errorVal),r._resolved&&!r._pending)try{s.handleResolve(o(r._val))}catch(l){l instanceof Q&&(l=l.val),s.handleError(l)}},kt.linkAll=function(r,s){for(var o=function(d,g,_){if(d.length==0||kt.allFulfilled(d)){for(var y,A=[],S=tr(r)();S.hasNext();){var P=S.next();A.push(P==g?_:P._val)}y=A,s.handleResolve(y)}},l=tr(r)();l.hasNext();){var u=l.next();u._update.push({async:s,linkf:function(d,g,_){return function(y){d(g,_,y)}}(o,function(d){for(var g,_=[],y=tr(r)();y.hasNext();){var A=y.next();A!=u&&_.push(A)}return g=_,g}(),u)})}kt.allFulfilled(r)&&s.handleResolve(function(d){for(var g,_=[],y=tr(r)();y.hasNext();){var A=y.next();_.push(A._val)}return g=_,g}())},kt.pipeLink=function(r,s,o){var l=!1,u=function(d){if(!l){l=!0;var g=o(d);g._update.push({async:s,linkf:De(s,s.handleResolve)}),kt.immediateLinkUpdate(g,s,function(_){return _})}};if(r._update.push({async:s,linkf:u}),r._resolved&&!r._pending)try{u(r._val)}catch(d){d instanceof Q&&(d=d.val),s.handleError(d)}},kt.allResolved=function(r){for(var s=tr(r)();s.hasNext();){var o=s.next();if(!o._resolved)return!1}return!0},kt.allFulfilled=function(r){for(var s=tr(r)();s.hasNext();){var o=s.next();if(!o._fulfilled)return!1}return!0},kt.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 s=this;this._pending?It.enqueue(function(o,l){return function(){o(l)}}(De(this,this._resolve),r)):(this._resolved=!0,this._pending=!0,It.queue.add(function(){s._val=r;for(var o=0,l=s._update;o<l.length;){var u=l[o];++o;try{u.linkf(r)}catch(d){d instanceof Q&&(d=d.val),u.async.handleError(d)}}s._fulfilled=!0,s._pending=!1}),It.continueOnNextLoop())},handleError:function(r){this._handleError(r)},_handleError:function(r){var s=this,o=function(l){if(s._error.length>0)for(var u=0,d=s._error;u<d.length;){var g=d[u];++u,g(l)}else if(s._update.length>0)for(var _=0,y=s._update;_<y.length;){var A=y[_];++_,A.async.handleError(l)}else throw new Q(l);s._errorPending=!1};this._errorPending||(this._errorPending=!0,this._errored=!0,this._errorVal=r,It.queue.add(function(){if(s._errorMap!=null)try{s._resolve(s._errorMap(r))}catch(l){l instanceof Q&&(l=l.val),o(l)}else o(r)}),It.continueOnNextLoop())},then:function(r){var s=new kt(null);return kt.link(this,s,r),s},unlink:function(r){var s=this;It.queue.add(function(){s._update=s._update.filter(function(o){return o.async!=r})}),It.continueOnNextLoop()},isLinked:function(r){for(var s=!1,o=0,l=this._update;o<l.length;){var u=l[o];if(++o,u.async==r)return!0}return s},__class__:kt};var In=f.promhx.Deferred=function(){kt.call(this)};x["promhx.Deferred"]=In,In.__name__=["promhx","Deferred"],In.__super__=kt,In.prototype=M(kt.prototype,{resolve:function(r){this.handleResolve(r)},throwError:function(r){this.handleError(r)},promise:function(){return new _e(this)},stream:function(){return new Yt(this)},publicStream:function(){return new Fr(this)},__class__:In});var _e=f.promhx.Promise=function(r){kt.call(this,r),this._rejected=!1};x["promhx.Promise"]=_e,_e.__name__=["promhx","Promise"],_e.whenAll=function(r){var s=new _e(null);return kt.linkAll(r,s),s},_e.promise=function(r){var s=new _e;return s.handleResolve(r),s},_e.__super__=kt,_e.prototype=M(kt.prototype,{isRejected:function(){return this._rejected},reject:function(r){this._rejected=!0,this.handleError(r)},handleResolve:function(r){if(this._resolved){var s="Promise has already been resolved";throw new Q(En.AlreadyResolved(s))}this._resolve(r)},then:function(r){var s=new _e(null);return kt.link(this,s,r),s},unlink:function(r){var s=this;It.queue.add(function(){if(s._fulfilled)s._update=s._update.filter(function(l){return l.async!=r});else{var o="Downstream Promise is not fullfilled";s.handleError(En.DownstreamNotFullfilled(o))}}),It.continueOnNextLoop()},handleError:function(r){this._rejected=!0,this._handleError(r)},pipe:function(r){var s=new _e(null);return kt.pipeLink(this,s,r),s},errorPipe:function(r){var s=new _e;return this.catchError(function(o){var l=r(o);l.then(De(s,s._resolve))}),this.then(De(s,s._resolve)),s},__class__:_e});var Yt=f.promhx.Stream=function(r){kt.call(this,r),this._end_promise=new _e};x["promhx.Stream"]=Yt,Yt.__name__=["promhx","Stream"],Yt.foreach=function(r){for(var s=new Yt(null),o=tr(r)();o.hasNext();){var l=o.next();s.handleResolve(l)}return s.end(),s},Yt.wheneverAll=function(r){var s=new Yt(null);return kt.linkAll(r,s),s},Yt.concatAll=function(r){for(var s=new Yt(null),o=tr(r)();o.hasNext();){var l=o.next();s.concat(l)}return s},Yt.mergeAll=function(r){for(var s=new Yt(null),o=tr(r)();o.hasNext();){var l=o.next();s.merge(l)}return s},Yt.stream=function(r){var s=new Yt(null);return s.handleResolve(r),s},Yt.__super__=kt,Yt.prototype=M(kt.prototype,{then:function(r){var s=new Yt(null);return kt.link(this,s,r),this._end_promise._update.push({async:s._end_promise,linkf:function(o){s.end()}}),s},detachStream:function(r){for(var s=[],o=!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(g){return g.async!=r._end_promise}),o=!0):s.push(d)}return this._update=s,o},first:function(){var r=new _e(null);return this.then(function(s){r._resolved||r.handleResolve(s)}),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 s=new Yt(null);return kt.pipeLink(this,s,r),this._end_promise.then(function(o){s.end()}),s},errorPipe:function(r){var s=new Yt(null);return this.catchError(function(o){var l=r(o);l.then(De(s,s._resolve)),l._end_promise.then((ta=s._end_promise,De(ta,ta._resolve)))}),this.then(De(s,s._resolve)),this._end_promise.then(function(o){s.end()}),s},handleEnd:function(){if(this._pending)It.queue.add(De(this,this.handleEnd)),It.continueOnNextLoop();else{if(this._end_promise._resolved)return;this._end=!0;var r;this._resolved?r=ge.Some(this._val):r=ge.None,this._end_promise.handleResolve(r),this._update=[],this._error=[]}},end:function(){return It.queue.add(De(this,this.handleEnd)),It.continueOnNextLoop(),this},endThen:function(r){return this._end_promise.then(r)},filter:function(r){var s=new Yt(null);return this._update.push({async:s,linkf:function(o){r(o)&&s.handleResolve(o)}}),kt.immediateLinkUpdate(this,s,function(o){return o}),s},concat:function(r){var s=new Yt(null);return this._update.push({async:s,linkf:De(s,s.handleResolve)}),kt.immediateLinkUpdate(this,s,function(o){return o}),this._end_promise.then(function(o){r.pipe(function(l){return s.handleResolve(l),s}),r._end_promise.then(function(l){s.end()})}),s},merge:function(r){var s=new Yt(null);return this._update.push({async:s,linkf:De(s,s.handleResolve)}),r._update.push({async:s,linkf:De(s,s.handleResolve)}),kt.immediateLinkUpdate(this,s,function(o){return o}),kt.immediateLinkUpdate(r,s,function(o){return o}),s},__class__:Yt});var Fr=f.promhx.PublicStream=function(r){Yt.call(this,r)};x["promhx.PublicStream"]=Fr,Fr.__name__=["promhx","PublicStream"],Fr.publicstream=function(r){var s=new Fr(null);return s.handleResolve(r),s},Fr.__super__=Yt,Fr.prototype=M(Yt.prototype,{resolve:function(r){this.handleResolve(r)},throwError:function(r){this.handleError(r)},update:function(r){this.handleResolve(r)},__class__:Fr});var It=function(){};x["promhx.base.EventLoop"]=It,It.__name__=["promhx","base","EventLoop"],It.enqueue=function(r){It.queue.add(r),It.continueOnNextLoop()},It.set_nextLoop=function(r){if(It.nextLoop!=null)throw new Q("nextLoop has already been set");return It.nextLoop=r,It.nextLoop},It.queueEmpty=function(){return It.queue.isEmpty()},It.finish=function(r){r==null&&(r=1e3);for(var s=null;r-- >0&&(s=It.queue.pop())!=null;)s();return It.queue.isEmpty()},It.clear=function(){It.queue=new F},It.f=function(){var r=It.queue.pop();r!=null&&r(),It.queue.isEmpty()||It.continueOnNextLoop()},It.continueOnNextLoop=function(){It.nextLoop!=null?It.nextLoop(It.f):setImmediate(It.f)};var En=x["promhx.error.PromiseError"]={__ename__:["promhx","error","PromiseError"],__constructs__:["AlreadyResolved","DownstreamNotFullfilled"]};En.AlreadyResolved=function(r){var s=["AlreadyResolved",0,r];return s.__enum__=En,s.toString=I,s},En.DownstreamNotFullfilled=function(r){var s=["DownstreamNotFullfilled",1,r];return s.__enum__=En,s.toString=I,s};var ti=function(){};x["verb.Verb"]=ti,ti.__name__=["verb","Verb"],ti.main=function(){b.log("verb 2.1.0")};var Z=function(){};x["verb.core.ArrayExtensions"]=Z,Z.__name__=["verb","core","ArrayExtensions"],Z.alloc=function(r,s){if(!(s<0))for(;r.length<s;)r.push(null)},Z.reversed=function(r){var s=r.slice();return s.reverse(),s},Z.last=function(r){return r[r.length-1]},Z.first=function(r){return r[0]},Z.spliceAndInsert=function(r,s,o,l){r.splice(s,o),r.splice(s,0,l)},Z.left=function(r){if(r.length==0)return[];var s=Math.ceil(r.length/2);return r.slice(0,s)},Z.right=function(r){if(r.length==0)return[];var s=Math.ceil(r.length/2);return r.slice(s)},Z.rightWithPivot=function(r){if(r.length==0)return[];var s=Math.ceil(r.length/2);return r.slice(s-1)},Z.unique=function(r,s){if(r.length==0)return[];for(var o=[r.pop()];r.length>0;){for(var l=r.pop(),u=!0,d=0;d<o.length;){var g=o[d];if(++d,s(l,g)){u=!1;break}}u&&o.push(l)}return o};var Ft=function(){};x["verb.core.Binomial"]=Ft,Ft.__name__=["verb","core","Binomial"],Ft.get=function(r,s){if(s==0)return 1;if(r==0||s>r)return 0;if(s>r-s&&(s=r-s),Ft.memo_exists(r,s))return Ft.get_memo(r,s);for(var o=1,l=r,u=1,d=s+1;u<d;){var g=u++;if(Ft.memo_exists(l,g)){r--,o=Ft.get_memo(l,g);continue}o*=r--,o/=g,Ft.memoize(l,g,o)}return o},Ft.get_no_memo=function(r,s){if(s==0)return 1;if(r==0||s>r)return 0;s>r-s&&(s=r-s);for(var o=1,l=1,u=s+1;l<u;){var d=l++;o*=r--,o/=d}return o},Ft.memo_exists=function(r,s){return Ft.memo.h.hasOwnProperty(r)&&Ft.memo.h[r].h.hasOwnProperty(s)},Ft.get_memo=function(r,s){return Ft.memo.h[r].h[s]},Ft.memoize=function(r,s,o){Ft.memo.h.hasOwnProperty(r)||Ft.memo.set(r,new wt),Ft.memo.h[r].h[s]=o};var ze=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"]=ze,ze.__name__=["verb","core","BoundingBox"],ze.intervalsOverlap=function(r,s,o,l,u){u==null&&(u=-1);var d;u<-.5?d=rt.TOLERANCE:d=u;var g=Math.min(r,s)-d,_=Math.max(r,s)+d,y=Math.min(o,l)-d,A=Math.max(o,l)+d;return g>=y&&g<=A||_>=y&&_<=A||y>=g&&y<=_||A>=g&&A<=_},ze.prototype={fromPoint:function(r){return new ze([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 s=0,o=this.dim;s<o;){var l=s++;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 s=r.length,o=0;o<s;){var l=o++;this.add(r[l])}return this},contains:function(r,s){return s==null&&(s=-1),this.initialized?this.intersects(new ze([r]),s):!1},intersects:function(r,s){if(s==null&&(s=-1),!this.initialized||!r.initialized)return!1;for(var o=this.min,l=this.max,u=r.min,d=r.max,g=0,_=this.dim;g<_;){var y=g++;if(!ze.intervalsOverlap(o[y],l[y],u[y],d[y],s))return!1}return!0},clear:function(){return this.initialized=!1,this},getLongestAxis:function(){for(var r=0,s=0,o=0,l=this.dim;o<l;){var u=o++,d=this.getAxisLength(u);d>r&&(r=d,s=u)}return s},getAxisLength:function(r){return r<0||r>this.dim-1?0:Math.abs(this.min[r]-this.max[r])},intersect:function(r,s){if(!this.initialized)return null;var o=this.min,l=this.max,u=r.min,d=r.max;if(!this.intersects(r,s))return null;for(var g=[],_=[],y=0,A=this.dim;y<A;){var S=y++;g.push(Math.min(l[S],d[S])),_.push(Math.max(o[S],u[S]))}return new ze([_,g])},__class__:ze};var rt=f.core.Constants=function(){};x["verb.core.Constants"]=rt,rt.__name__=["verb","core","Constants"];var te=f.core.SerializableBase=function(){};x["verb.core.SerializableBase"]=te,te.__name__=["verb","core","SerializableBase"],te.prototype={serialize:function(){var r=new Kt;return r.serialize(this),r.toString()},__class__:te};var Jn=f.core.Plane=function(r,s){this.origin=r,this.normal=s};x["verb.core.Plane"]=Jn,Jn.__name__=["verb","core","Plane"],Jn.__super__=te,Jn.prototype=M(te.prototype,{__class__:Jn});var Mn=f.core.Ray=function(r,s){this.origin=r,this.dir=s};x["verb.core.Ray"]=Mn,Mn.__name__=["verb","core","Ray"],Mn.__super__=te,Mn.prototype=M(te.prototype,{__class__:Mn});var Wt=f.core.NurbsCurveData=function(r,s,o){this.degree=r,this.controlPoints=o,this.knots=s};x["verb.core.NurbsCurveData"]=Wt,Wt.__name__=["verb","core","NurbsCurveData"],Wt.__super__=te,Wt.prototype=M(te.prototype,{__class__:Wt});var ne=f.core.NurbsSurfaceData=function(r,s,o,l,u){this.degreeU=r,this.degreeV=s,this.knotsU=o,this.knotsV=l,this.controlPoints=u};x["verb.core.NurbsSurfaceData"]=ne,ne.__name__=["verb","core","NurbsSurfaceData"],ne.__super__=te,ne.prototype=M(te.prototype,{__class__:ne});var Qe=f.core.MeshData=function(r,s,o,l){this.faces=r,this.points=s,this.normals=o,this.uvs=l};x["verb.core.MeshData"]=Qe,Qe.__name__=["verb","core","MeshData"],Qe.empty=function(){return new Qe([],[],[],[])},Qe.__super__=te,Qe.prototype=M(te.prototype,{__class__:Qe});var ts=f.core.PolylineData=function(r,s){this.points=r,this.params=s};x["verb.core.PolylineData"]=ts,ts.__name__=["verb","core","PolylineData"],ts.__super__=te,ts.prototype=M(te.prototype,{__class__:ts});var es=f.core.VolumeData=function(r,s,o,l,u,d,g){this.degreeU=r,this.degreeV=s,this.degreeW=o,this.knotsU=l,this.knotsV=u,this.knotsW=d,this.controlPoints=g};x["verb.core.VolumeData"]=es,es.__name__=["verb","core","VolumeData"],es.__super__=te,es.prototype=M(te.prototype,{__class__:es});var se=f.core.Pair=function(r,s){this.item0=r,this.item1=s};x["verb.core.Pair"]=se,se.__name__=["verb","core","Pair"],se.prototype={__class__:se};var Te=f.core.Interval=function(r,s){this.min=r,this.max=s};x["verb.core.Interval"]=Te,Te.__name__=["verb","core","Interval"],Te.prototype={__class__:Te};var en=f.core.CurveCurveIntersection=function(r,s,o,l){this.point0=r,this.point1=s,this.u0=o,this.u1=l};x["verb.core.CurveCurveIntersection"]=en,en.__name__=["verb","core","CurveCurveIntersection"],en.prototype={__class__:en};var rs=f.core.CurveSurfaceIntersection=function(r,s,o,l){this.u=r,this.uv=s,this.curvePoint=o,this.surfacePoint=l};x["verb.core.CurveSurfaceIntersection"]=rs,rs.__name__=["verb","core","CurveSurfaceIntersection"],rs.prototype={__class__:rs};var Vr=f.core.MeshIntersectionPoint=function(r,s,o,l,u){this.visited=!1,this.adj=null,this.opp=null,this.uv0=r,this.uv1=s,this.point=o,this.faceIndex0,this.faceIndex1};x["verb.core.MeshIntersectionPoint"]=Vr,Vr.__name__=["verb","core","MeshIntersectionPoint"],Vr.prototype={__class__:Vr};var ns=f.core.PolylineMeshIntersection=function(r,s,o,l,u){this.point=r,this.u=s,this.uv=o,this.polylineIndex=l,this.faceIndex=u};x["verb.core.PolylineMeshIntersection"]=ns,ns.__name__=["verb","core","PolylineMeshIntersection"],ns.prototype={__class__:ns};var ss=f.core.SurfaceSurfaceIntersectionPoint=function(r,s,o,l){this.uv0=r,this.uv1=s,this.point=o,this.dist=l};x["verb.core.SurfaceSurfaceIntersectionPoint"]=ss,ss.__name__=["verb","core","SurfaceSurfaceIntersectionPoint"],ss.prototype={__class__:ss};var is=f.core.TriSegmentIntersection=function(r,s,o,l){this.point=r,this.s=s,this.t=o,this.p=l};x["verb.core.TriSegmentIntersection"]=is,is.__name__=["verb","core","TriSegmentIntersection"],is.prototype={__class__:is};var kn=f.core.CurveTriPoint=function(r,s,o){this.u=r,this.point=s,this.uv=o};x["verb.core.CurveTriPoint"]=kn,kn.__name__=["verb","core","CurveTriPoint"],kn.prototype={__class__:kn};var Ke=function(r,s,o,l,u){u==null&&(u=!1),l==null&&(l=-1),this.uv=o,this.point=r,this.normal=s,this.id=l,this.degen=u};x["verb.core.SurfacePoint"]=Ke,Ke.__name__=["verb","core","SurfacePoint"],Ke.fromUv=function(r,s){return new Ke(null,null,[r,s])},Ke.prototype={__class__:Ke};var ei=f.core.CurvePoint=function(r,s){this.u=r,this.pt=s};x["verb.core.CurvePoint"]=ei,ei.__name__=["verb","core","CurvePoint"],ei.prototype={__class__:ei};var as=f.core.KdTree=function(r,s){this.dim=3,this.points=r,this.distanceFunction=s,this.dim=r[0].point.length,this.root=this.buildTree(r,0,null)};x["verb.core.KdTree"]=as,as.__name__=["verb","core","KdTree"],as.prototype={buildTree:function(r,s,o){var l=s%this.dim,u,d;return r.length==0?null:r.length==1?new Cn(r[0],l,o):(r.sort(function(g,_){var y=g.point[l]-_.point[l];return y==0?0:y>0?1:-1}),u=Math.floor(r.length/2),d=new Cn(r[u],l,o),d.left=this.buildTree(r.slice(0,u),s+1,d),d.right=this.buildTree(r.slice(u+1),s+1,d),d)},nearest:function(r,s,o){var l=this,u=new os(function(P){return-P.item1}),d,g=null;g=function(P){for(var E,k=P.dimension,T=l.distanceFunction(r,P.kdPoint.point),B,N=[],R=0,z=l.dim;R<z;)R++,N.push(0);B=N;for(var V,U,Y=function($,tt){u.push(new se($,tt)),u.size()>s&&u.pop()},J=0,q=l.dim;J<q;){var j=J++;j==P.dimension?B[j]=r[j]:B[j]=P.kdPoint.point[j]}if(V=l.distanceFunction(B,P.kdPoint.point),P.right==null&&P.left==null){(u.size()<s||T<u.peek().item1)&&Y(P,T);return}P.right==null?E=P.left:P.left==null?E=P.right:r[k]<P.kdPoint.point[k]?E=P.left:E=P.right,g(E),(u.size()<s||T<u.peek().item1)&&Y(P,T),(u.size()<s||Math.abs(V)<u.peek().item1)&&(E==P.left?U=P.right:U=P.left,U!=null&&g(U))},d=g;for(var _=0;_<s;)_++,u.push(new se(null,o));d(this.root);for(var y=[],A=0;A<s;){var S=A++;u.content[S].item0!=null&&y.push(new se(u.content[S].item0.kdPoint,u.content[S].item1))}return y},__class__:as};var os=function(r){this.content=[],this.scoreFunction=r};x["verb.core.BinaryHeap"]=os,os.__name__=["verb","core","BinaryHeap"],os.prototype={push:function(r){this.content.push(r),this.bubbleUp(this.content.length-1)},pop:function(){var r=this.content[0],s=this.content.pop();return this.content.length>0&&(this.content[0]=s,this.sinkDown(0)),r},peek:function(){return this.content[0]},remove:function(r){for(var s=this.content.length,o=0;o<s;){var l=o++;if(this.content[l]==r){var u=this.content.pop();l!=s-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 s=this.content[r];r>0;){var o=Math.floor((r+1)/2)-1,l=this.content[o];if(this.scoreFunction(s)<this.scoreFunction(l))this.content[o]=s,this.content[r]=l,r=o;else break}},sinkDown:function(r){for(var s=this.content.length,o=this.content[r],l=this.scoreFunction(o);;){var u=(r+1)*2,d=u-1,g=-1,_=0;if(d<s){var y=this.content[d];_=this.scoreFunction(y),_<l&&(g=d)}if(u<s){var A=this.content[u],S=this.scoreFunction(A);S<(g==-1?l:_)&&(g=u)}if(g!=-1)this.content[r]=this.content[g],this.content[g]=o,r=g;else break}},__class__:os};var Tn=f.core.KdPoint=function(r,s){this.point=r,this.obj=s};x["verb.core.KdPoint"]=Tn,Tn.__name__=["verb","core","KdPoint"],Tn.prototype={__class__:Tn};var Cn=f.core.KdNode=function(r,s,o){this.kdPoint=r,this.left=null,this.right=null,this.parent=o,this.dimension=s};x["verb.core.KdNode"]=Cn,Cn.__name__=["verb","core","KdNode"],Cn.prototype={__class__:Cn};var _r=function(){};x["verb.eval.IBoundingBoxTree"]=_r,_r.__name__=["verb","eval","IBoundingBoxTree"],_r.prototype={__class__:_r};var cr=function(r,s){this._boundingBox=null,this._curve=r,s==null&&(s=p.domain(this._curve.knots)/64),this._knotTol=s};x["verb.core.LazyCurveBoundingBoxTree"]=cr,cr.__name__=["verb","core","LazyCurveBoundingBoxTree"],cr.__interfaces__=[_r],cr.prototype={split:function(){var r=Z.first(this._curve.knots),s=Z.last(this._curve.knots),o=s-r,l=ue.curveSplit(this._curve,(s+r)/2+o*.1*Math.random());return new se(new cr(l[0],this._knotTol),new cr(l[1],this._knotTol))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=new ze(C.dehomogenize1d(this._curve.controlPoints))),this._boundingBox},yield:function(){return this._curve},indivisible:function(r){return p.domain(this._curve.knots)<this._knotTol},empty:function(){return!1},__class__:cr};var ur=function(r,s){if(this._boundingBox=null,this._mesh=r,s==null){for(var o=[],l=0,u=r.faces.length;l<u;){var d=l++;o.push(d)}s=o}this._faceIndices=s};x["verb.core.LazyMeshBoundingBoxTree"]=ur,ur.__name__=["verb","core","LazyMeshBoundingBoxTree"],ur.__interfaces__=[_r],ur.prototype={split:function(){var r=ie.sortTrianglesOnLongestAxis(this.boundingBox(),this._mesh,this._faceIndices),s=Z.left(r),o=Z.right(r);return new se(new ur(this._mesh,s),new ur(this._mesh,o))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=ie.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__:ur};var dr=function(r,s){this._boundingBox=null,this._polyline=r,s==null&&(s=new Te(0,r.points.length!=0?r.points.length-1:0)),this._interval=s};x["verb.core.LazyPolylineBoundingBoxTree"]=dr,dr.__name__=["verb","core","LazyPolylineBoundingBoxTree"],dr.__interfaces__=[_r],dr.prototype={split:function(){var r=this._interval.min,s=this._interval.max,o=r+Math.ceil((s-r)/2),l=new Te(r,o),u=new Te(o,s);return new se(new dr(this._polyline,l),new dr(this._polyline,u))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=new ze(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__:dr};var Ur=function(r,s,o,l){s==null&&(s=!1),this._boundingBox=null,this._surface=r,this._splitV=s,o==null&&(o=p.domain(r.knotsU)/16),l==null&&(l=p.domain(r.knotsV)/16),this._knotTolU=o,this._knotTolV=l};x["verb.core.LazySurfaceBoundingBoxTree"]=Ur,Ur.__name__=["verb","core","LazySurfaceBoundingBoxTree"],Ur.__interfaces__=[_r],Ur.prototype={split:function(){var r,s;this._splitV?(r=Z.first(this._surface.knotsV),s=Z.last(this._surface.knotsV)):(r=Z.first(this._surface.knotsU),s=Z.last(this._surface.knotsU));var o=(r+s)/2,l=ue.surfaceSplit(this._surface,o,this._splitV);return new se(new Ur(l[0],!this._splitV,this._knotTolU,this._knotTolV),new Ur(l[1],!this._splitV,this._knotTolU,this._knotTolV))},boundingBox:function(){if(this._boundingBox==null){this._boundingBox=new ze;for(var r=0,s=this._surface.controlPoints;r<s.length;){var o=s[r];++r,this._boundingBox.addRange(C.dehomogenize1d(o))}}return this._boundingBox},yield:function(){return this._surface},indivisible:function(r){return p.domain(this._surface.knotsV)<this._knotTolV&&p.domain(this._surface.knotsU)<this._knotTolU},empty:function(){return!1},__class__:Ur};var Ot=f.core.Mat=function(){};x["verb.core.Mat"]=Ot,Ot.__name__=["verb","core","Mat"],Ot.mul=function(r,s){for(var o=[],l=0,u=s.length;l<u;){var d=l++;o.push(p.mul(r,s[d]))}return o},Ot.mult=function(r,s){var o,l,u,d,g,_,y,A;o=r.length,l=s.length,u=s[0].length,d=[];for(var S=o-1,P=0,E=0;S>=0;){for(g=[],_=r[S],E=u-1;E>=0;){for(y=_[l-1]*s[l-1][E],P=l-2;P>=1;)A=P-1,y+=_[P]*s[P][E]+_[A]*s[A][E],P-=2;P==0&&(y+=_[0]*s[0][E]),g[E]=y,E--}d[S]=g,S--}return d},Ot.add=function(r,s){for(var o=[],l=0,u=r.length;l<u;){var d=l++;o.push(p.add(r[d],s[d]))}return o},Ot.div=function(r,s){for(var o=[],l=0,u=r.length;l<u;){var d=l++;o.push(p.div(r[d],s))}return o},Ot.sub=function(r,s){for(var o=[],l=0,u=r.length;l<u;){var d=l++;o.push(p.sub(r[d],s[d]))}return o},Ot.dot=function(r,s){for(var o=[],l=0,u=r.length;l<u;){var d=l++;o.push(p.dot(r[d],s))}return o},Ot.identity=function(r){for(var s=p.zeros2d(r,r),o=0;o<r;){var l=o++;s[l][l]=1}return s},Ot.transpose=function(r){if(r.length==0)return[];for(var s=[],o=0,l=r[0].length;o<l;){var u=o++;s.push(function(d){for(var g,_=[],y=0,A=r.length;y<A;){var S=y++;_.push(r[S][u])}return g=_,g}())}return s},Ot.solve=function(r,s){return Ot.LUsolve(Ot.LU(r),s)},Ot.LUsolve=function(r,s){var o,l,u=r.LU,d=u.length,g=s.slice(),_=r.P,y,A,S;for(o=d-1;o!=-1;)g[o]=s[o],--o;for(o=0;o<d;){for(y=_[o],_[o]!=o&&(S=g[o],g[o]=g[y],g[y]=S),A=u[o],l=0;l<o;)g[o]-=g[l]*A[l],++l;++o}for(o=d-1;o>=0;){for(A=u[o],l=o+1;l<d;)g[o]-=g[l]*A[l],++l;g[o]/=A[o],--o}return g},Ot.LU=function(r){for(var s,o,l,u,d,g,_,y,A,S=[],P=0,E=r.length;P<E;){var k=P++;S.push(r[k].slice())}r=S;var T=r.length,B=T-1,N=[];for(l=0;l<T;){for(_=l,g=r[l],A=Math.abs(g[l]),o=l+1;o<T;)u=Math.abs(r[o][l]),A<u&&(A=u,_=o),++o;for(N[l]=_,_!=l&&(r[l]=r[_],r[_]=g,g=r[l]),d=g[l],s=l+1;s<T;)r[s][l]/=d,++s;for(s=l+1;s<T;){for(y=r[s],o=l+1;o<B;)y[o]-=y[l]*g[o],++o,y[o]-=y[l]*g[o],++o;o==B&&(y[o]-=y[l]*g[o]),++s}++l}return new ls(r,N)};var ls=function(r,s){this.LU=r,this.P=s};x["verb.core._Mat.LUDecomp"]=ls,ls.__name__=["verb","core","_Mat","LUDecomp"],ls.prototype={__class__:ls};var ie=f.core.Mesh=function(){};x["verb.core.Mesh"]=ie,ie.__name__=["verb","core","Mesh"],ie.getTriangleNorm=function(r,s){var o=r[s[0]],l=r[s[1]],u=r[s[2]],d=p.sub(l,o),g=p.sub(u,o),_=p.cross(d,g);return p.mul(1/p.norm(_),_)},ie.makeMeshAabb=function(r,s){for(var o=new ze,l=0;l<s.length;){var u=s[l];++l,o.add(r.points[r.faces[u][0]]),o.add(r.points[r.faces[u][1]]),o.add(r.points[r.faces[u][2]])}return o},ie.sortTrianglesOnLongestAxis=function(r,s,o){for(var l=r.getLongestAxis(),u=[],d=0;d<o.length;){var g=o[d];++d;var _=ie.getMinCoordOnAxis(s.points,s.faces[g],l);u.push(new se(_,g))}u.sort(function(E,k){var T=E.item0,B=k.item0;return T==B?0:T>B?1:-1});for(var y=[],A=0,S=u.length;A<S;){var P=A++;y.push(u[P].item1)}return y},ie.getMinCoordOnAxis=function(r,s,o){for(var l=1/0,u=0;u<3;){var d=u++,g=r[s[d]][o];g<l&&(l=g)}return l},ie.getTriangleCentroid=function(r,s){for(var o=[0,0,0],l=0;l<3;)for(var u=l++,d=0;d<3;){var g=d++;o[g]+=r[s[u]][g]}for(var _=0;_<3;){var y=_++;o[y]/=3}return o},ie.triangleUVFromPoint=function(r,s,o){var l=r.faces[s],u=r.points[l[0]],d=r.points[l[1]],g=r.points[l[2]],_=r.uvs[l[0]],y=r.uvs[l[1]],A=r.uvs[l[2]],S=p.sub(u,o),P=p.sub(d,o),E=p.sub(g,o),k=p.norm(p.cross(p.sub(u,d),p.sub(u,g))),T=p.norm(p.cross(P,E))/k,B=p.norm(p.cross(E,S))/k,N=p.norm(p.cross(S,P))/k;return p.add(p.mul(T,_),p.add(p.mul(B,y),p.mul(N,A)))};var jr=function(r,s){if(this._empty=!1,this._face=-1,s==null){for(var o=[],l=0,u=r.faces.length;l<u;){var d=l++;o.push(d)}s=o}if(this._boundingBox=ie.makeMeshAabb(r,s),s.length<1){this._empty=!0;return}else if(s.length<2){this._face=s[0];return}var g=ie.sortTrianglesOnLongestAxis(this._boundingBox,r,s),_=Z.left(g),y=Z.right(g);this._children=new se(new jr(r,_),new jr(r,y))};x["verb.core.MeshBoundingBoxTree"]=jr,jr.__name__=["verb","core","MeshBoundingBoxTree"],jr.__interfaces__=[_r],jr.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__:jr};var Je=f.core.Minimizer=function(){};x["verb.core.Minimizer"]=Je,Je.__name__=["verb","core","Minimizer"],Je.uncmin=function(r,s,o,l,u){o==null&&(o=1e-8),l==null&&(l=function(J){return Je.numericalGradient(r,J)}),u==null&&(u=1e3),s=s.slice(0);var d=s.length,g=r(s),_=g,y;if(isNaN(g))throw new Q("uncmin: f(x0) is a NaN!");o=Math.max(o,rt.EPSILON);var A,S,P,E=Ot.identity(d),k=0,T=[],B,N,R,z,V,U,Y="";for(S=l(s);k<u;){if(!p.all(p.finite(S))){Y="Gradient has Infinity or NaN";break}if(A=p.neg(Ot.dot(E,S)),!p.all(p.finite(A))){Y="Search direction has Infinity or NaN";break}if(U=p.norm(A),U<o){Y="Newton step smaller than tol";break}for(V=1,y=p.dot(S,A),B=s;k<u&&!(V*U<o);){if(T=p.mul(V,A),B=p.add(s,T),_=r(B),_-g>=.1*V*y||isNaN(_)){V*=.5,++k;continue}break}if(V*U<o){Y="Line search step size smaller than tol";break}if(k==u){Y="maxit reached during line search";break}P=l(B),N=p.sub(P,S),z=p.dot(N,T),R=Ot.dot(E,N),E=Ot.sub(Ot.add(E,Ot.mul((z+p.dot(N,R))/(z*z),Je.tensor(T,T))),Ot.div(Ot.add(Je.tensor(R,T),Je.tensor(T,R)),z)),s=B,g=_,S=P,++k}return new hs(s,g,S,E,k,Y)},Je.numericalGradient=function(r,s){var o=s.length,l=r(s);if(l==NaN)throw new Q("gradient: f(x) is a NaN!");for(var u=s.slice(0),d,g,_=[],y,A=.001,S,P,E,k=0,T,B,N,R=0;R<o;)for(var z=R++,V=Math.max(1e-6*l,1e-8);;){if(++k,k>20)throw new Q("Numerical gradient fails");if(u[z]=s[z]+V,d=r(u),u[z]=s[z]-V,g=r(u),u[z]=s[z],isNaN(d)||isNaN(g)){V/=16;continue}if(_[z]=(d-g)/(2*V),S=s[z]-V,P=s[z],E=s[z]+V,T=(d-l)/V,B=(l-g)/V,N=p.max([Math.abs(_[z]),Math.abs(l),Math.abs(d),Math.abs(g),Math.abs(S),Math.abs(P),Math.abs(E),1e-8]),y=Math.min(p.max([Math.abs(T-_[z]),Math.abs(B-_[z]),Math.abs(T-B)])/N,V/N),y>A)V/=16;else break}return _},Je.tensor=function(r,s){for(var o=r.length,l=s.length,u=[],d,g,_=o-1;_>=0;){d=[],g=r[_];for(var y=l-1;y>=3;)d[y]=g*s[y],--y,d[y]=g*s[y],--y,d[y]=g*s[y],--y,d[y]=g*s[y],--y;for(;y>=0;)d[y]=g*s[y],--y;u[_]=d,_--}return u};var hs=function(r,s,o,l,u,d){this.solution=r,this.value=s,this.gradient=o,this.invHessian=l,this.iterations=u,this.message=d};x["verb.core.MinimizationResult"]=hs,hs.__name__=["verb","core","MinimizationResult"],hs.prototype={__class__:hs};var Nn=function(){};x["verb.core.ISerializable"]=Nn,Nn.__name__=["verb","core","ISerializable"],Nn.prototype={__class__:Nn};var Ji=f.core.Deserializer=function(){};x["verb.core.Deserializer"]=Ji,Ji.__name__=["verb","core","Deserializer"],Ji.deserialize=function(r){var s=new qt(r),o=s.unserialize();return o};var Re=f.core.Trig=function(){};x["verb.core.Trig"]=Re,Re.__name__=["verb","core","Trig"],Re.isPointInPlane=function(r,s,o){return Math.abs(p.dot(p.sub(r,s.origin),s.normal))<o},Re.distToSegment=function(r,s,o){var l=Re.segmentClosestPoint(s,r,o,0,1);return p.dist(s,l.pt)},Re.rayClosestPoint=function(r,s,o){var l=p.sub(r,s),u=p.dot(l,o),d=p.add(s,p.mul(u,o));return d},Re.distToRay=function(r,s,o){var l=Re.rayClosestPoint(r,s,o),u=p.sub(l,r);return p.norm(u)},Re.threePointsAreFlat=function(r,s,o,l){var u=p.sub(s,r),d=p.sub(o,r),g=p.cross(u,d),_=p.dot(g,g);return _<l},Re.segmentClosestPoint=function(r,s,o,l,u){var d=p.sub(o,s),g=p.norm(d);if(g<rt.EPSILON)return{u:l,pt:s};var _=s,y=p.mul(1/g,d),A=p.sub(r,_),S=p.dot(A,y);return S<0?{u:l,pt:s}:S>g?{u,pt:o}:{u:l+(u-l)*S/g,pt:p.add(_,p.mul(S,y))}};var p=f.core.Vec=function(){};x["verb.core.Vec"]=p,p.__name__=["verb","core","Vec"],p.angleBetween=function(r,s){return Math.acos(p.dot(r,s)/(p.norm(r)*p.norm(s)))},p.positiveAngleBetween=function(r,s,o){var l=p.cross(r,s),u=p.norm(r),d=p.norm(s),g=u*d,_=p.dot(r,s),y=p.norm(l)/g,A=_/g,S=Math.atan2(y,A),P=p.dot(o,l);return Math.abs(P)<rt.EPSILON||P>0?S:-S},p.signedAngleBetween=function(r,s,o){var l=p.cross(r,s),u=p.norm(r),d=p.norm(s),g=u*d,_=p.dot(r,s),y=p.norm(l)/g,A=_/g,S=Math.atan2(y,A),P=p.dot(o,l);return P>0?S:2*Math.PI-S},p.angleBetweenNormalized2d=function(r,s){var o=r[0]*s[1]-r[1]*s[0];return Math.atan2(o,p.dot(r,s))},p.domain=function(r){return Z.last(r)-Z.first(r)},p.range=function(r){for(var s=[],o=0,l=0;l<r;)l++,s.push(o),o+=1;return s},p.span=function(r,s,o){if(o==null)return[];if(o<rt.EPSILON)return[];if(r>s&&o>0)return[];if(s>r&&o<0)return[];for(var l=[],u=r;u<=s;)l.push(u),u+=o;return l},p.neg=function(r){return r.map(function(s){return-s})},p.min=function(r){return L.fold(r,function(s,o){return Math.min(s,o)},1/0)},p.max=function(r){return L.fold(r,function(s,o){return Math.max(s,o)},-1/0)},p.all=function(r){return L.fold(r,function(s,o){return o&&s},!0)},p.finite=function(r){return r.map(function(s){return isFinite(s)})},p.onRay=function(r,s,o){return p.add(r,p.mul(o,s))},p.lerp=function(r,s,o){return p.add(p.mul(r,s),p.mul(1-r,o))},p.normalized=function(r){return p.div(r,p.norm(r))},p.cross=function(r,s){return[r[1]*s[2]-r[2]*s[1],r[2]*s[0]-r[0]*s[2],r[0]*s[1]-r[1]*s[0]]},p.dist=function(r,s){return p.norm(p.sub(r,s))},p.distSquared=function(r,s){return p.normSquared(p.sub(r,s))},p.sum=function(r){return L.fold(r,function(s,o){return o+s},0)},p.addAll=function(r){var s=tr(r)();if(!s.hasNext())return null;var o=s.next().length;return L.fold(r,function(l,u){return p.add(u,l)},p.rep(o,0))},p.addAllMutate=function(r){for(var s=r[0],o=1,l=r.length;o<l;){var u=o++;p.addMutate(s,r[u])}},p.addMulMutate=function(r,s,o){for(var l=0,u=r.length;l<u;){var d=l++;r[d]=r[d]+s*o[d]}},p.subMulMutate=function(r,s,o){for(var l=0,u=r.length;l<u;){var d=l++;r[d]=r[d]-s*o[d]}},p.addMutate=function(r,s){for(var o=0,l=r.length;o<l;){var u=o++;r[u]=r[u]+s[u]}},p.subMutate=function(r,s){for(var o=0,l=r.length;o<l;){var u=o++;r[u]=r[u]-s[u]}},p.mulMutate=function(r,s){for(var o=0,l=s.length;o<l;){var u=o++;s[u]=s[u]*r}},p.norm=function(r){var s=p.normSquared(r);return s!=0?Math.sqrt(s):s},p.normSquared=function(r){return L.fold(r,function(s,o){return o+s*s},0)},p.rep=function(r,s){for(var o=[],l=0;l<r;)l++,o.push(s);return o},p.zeros1d=function(r){for(var s=[],o=0;o<r;)o++,s.push(0);return s},p.zeros2d=function(r,s){for(var o=[],l=0;l<r;)l++,o.push(p.zeros1d(s));return o},p.zeros3d=function(r,s,o){for(var l=[],u=0;u<r;)u++,l.push(p.zeros2d(s,o));return l},p.dot=function(r,s){for(var o=0,l=0,u=r.length;l<u;){var d=l++;o+=r[d]*s[d]}return o},p.add=function(r,s){for(var o=[],l=0,u=r.length;l<u;){var d=l++;o.push(r[d]+s[d])}return o},p.mul=function(r,s){for(var o=[],l=0,u=s.length;l<u;){var d=l++;o.push(r*s[d])}return o},p.div=function(r,s){for(var o=[],l=0,u=r.length;l<u;){var d=l++;o.push(r[d]/s)}return o},p.sub=function(r,s){for(var o=[],l=0,u=r.length;l<u;){var d=l++;o.push(r[d]-s[d])}return o},p.isZero=function(r){for(var s=0,o=r.length;s<o;){var l=s++;if(Math.abs(r[l])>rt.TOLERANCE)return!1}return!0},p.sortedSetUnion=function(r,s){for(var o=[],l=0,u=0;l<r.length||u<s.length;){if(l>=r.length){o.push(s[u]),u++;continue}else if(u>=s.length){o.push(r[l]),l++;continue}var d=r[l]-s[u];if(Math.abs(d)<rt.EPSILON){o.push(r[l]),l++,u++;continue}if(d>0){o.push(s[u]),u++;continue}o.push(r[l]),l++}return o},p.sortedSetSub=function(r,s){for(var o=[],l=0,u=0;l<r.length;){if(u>=s.length){o.push(r[l]),l++;continue}if(Math.abs(r[l]-s[u])<rt.EPSILON){l++,u++;continue}o.push(r[l]),l++}return o};var bt=f.eval.Analyze=function(){};x["verb.eval.Analyze"]=bt,bt.__name__=["verb","eval","Analyze"],bt.knotMultiplicities=function(r){for(var s=[new Ln(r[0],0)],o=s[0],l=0;l<r.length;){var u=r[l];++l,Math.abs(u-o.knot)>rt.EPSILON&&(o=new Ln(u,0),s.push(o)),o.inc()}return s},bt.isRationalSurfaceClosed=function(r,s){s==null&&(s=!0);var o;s?o=r.controlPoints:o=Ot.transpose(r.controlPoints);for(var l=0,u=o[0].length;l<u;){var d=l++,g=p.dist(Z.first(o)[d],Z.last(o)[d])<rt.EPSILON;if(!g)return!1}return!0},bt.rationalSurfaceClosestPoint=function(r,s){var o=bt.rationalSurfaceClosestParam(r,s);return C.rationalSurfacePoint(r,o[0],o[1])},bt.rationalSurfaceClosestParam=function(r,s){for(var o=5,l=0,u,d=1e-4,g=5e-4,_,y=r.knotsU[0],A=Z.last(r.knotsU),S=r.knotsV[0],P=Z.last(r.knotsV),E=bt.isRationalSurfaceClosed(r),k=bt.isRationalSurfaceClosed(r,!1),T,B=zt.rationalSurfaceAdaptive(r,new Gr),N=1/0,R=0,z=B.points.length;R<z;){var V=R++,U=B.points[V],Y=p.normSquared(p.sub(s,U));Y<N&&(N=Y,T=B.uvs[V])}for(var J=function(Ht){return C.rationalSurfaceDerivatives(r,Ht[0],Ht[1],2)},q=function(Ht,$t,Ut){var Qt=$t[1][0],Ce=$t[0][1],Ze=$t[2][0],we=$t[0][2],ye=$t[1][1],Ne=$t[1][1],Fe=p.dot(Qt,Ut),er=p.dot(Ce,Ut),pr=[-Fe,-er],rr=p.dot(Qt,Qt)+p.dot(Ze,Ut),nr=p.dot(Qt,Ce)+p.dot(ye,Ut),sr=p.dot(Qt,Ce)+p.dot(Ne,Ut),vr=p.dot(Ce,Ce)+p.dot(we,Ut),Rn=[[rr,nr],[sr,vr]],nn=Ot.solve(Rn,pr);return p.add(nn,Ht)};l<o;){u=J(T),_=p.sub(u[0][0],s);var j=p.norm(_),$=p.dot(u[1][0],_),tt=p.norm(u[1][0])*j,et=p.dot(u[0][1],_),it=p.norm(u[0][1])*j,ht=$/tt,at=et/it,ut=j<d,nt=ht<g,mt=at<g;if(ut&&nt&&mt)return T;var K=q(T,u,_);K[0]<y?E?K=[A-(K[0]-y),K[1]]:K=[y+rt.EPSILON,K[1]]:K[0]>A&&(E?K=[y+(K[0]-A),K[1]]:K=[A-rt.EPSILON,K[1]]),K[1]<S?k?K=[K[0],P-(K[1]-S)]:K=[K[0],S+rt.EPSILON]:K[1]>P&&(k?K=[K[0],S+(K[0]-P)]:K=[K[0],P-rt.EPSILON]);var ft=p.norm(p.mul(K[0]-T[0],u[1][0])),Et=p.norm(p.mul(K[1]-T[1],u[0][1]));if(ft+Et<d)return T;T=K,l++}return T},bt.rationalCurveClosestPoint=function(r,s){return C.rationalCurvePoint(r,bt.rationalCurveClosestParam(r,s))},bt.rationalCurveClosestParam=function(r,s){for(var o=1/0,l=0,u=zt.rationalCurveRegularSample(r,r.controlPoints.length*r.degree,!0),d=0,g=u.length-1;d<g;){var _=d++,y=u[_][0],A=u[_+1][0],S=u[_].slice(1),P=u[_+1].slice(1),E=Re.segmentClosestPoint(s,S,P,y,A),k=p.norm(p.sub(s,E.pt));k<o&&(o=k,l=E.u)}for(var T=5,B=0,N,R=1e-4,z=5e-4,V,U=r.knots[0],Y=Z.last(r.knots),J=p.normSquared(p.sub(r.controlPoints[0],Z.last(r.controlPoints)))<rt.EPSILON,q=l,j=function(K){return C.rationalCurveDerivatives(r,K,2)},$=function(K,ft,Et){var Ht=p.dot(ft[1],Et),$t=p.dot(ft[2],Et),Ut=p.dot(ft[1],ft[1]),Qt=$t+Ut;return K-Ht/Qt};B<T;){N=j(q),V=p.sub(N[0],s);var tt=p.norm(V),et=p.dot(N[1],V),it=p.norm(N[1])*tt,ht=et/it,at=tt<R,ut=Math.abs(ht)<z;if(at&&ut)return q;var nt=$(q,N,V);nt<U?J?nt=Y-(nt-U):nt=U:nt>Y&&(J?nt=U+(nt-Y):nt=Y);var mt=p.norm(p.mul(nt-q,N[1]));if(mt<R)return q;q=nt,B++}return q},bt.rationalCurveParamAtArcLength=function(r,s,o,l,u){if(o==null&&(o=.001),s<rt.EPSILON)return r.knots[0];var d;l!=null?d=l:d=_t.decomposeCurveIntoBeziers(r);var g=0;d[g];var _=-rt.EPSILON,y;for(u!=null?y=u:y=[];_<s&&g<d.length;){if(g<y.length?y[g]=y[g]:y[g]=bt.rationalBezierCurveArcLength(r),_+=y[g],s<_+rt.EPSILON)return bt.rationalBezierCurveParamAtArcLength(r,s,o,y[g]);g++}return-1},bt.rationalBezierCurveParamAtArcLength=function(r,s,o,l){if(s<0)return r.knots[0];var u;if(l!=null?u=l:u=bt.rationalBezierCurveArcLength(r),s>u)return Z.last(r.knots);var d=r.knots[0],g=0,_=Z.last(r.knots),y=u,A=0,S=0,P;for(o!=null?P=o:P=rt.TOLERANCE*2;y-g>P;)A=(d+_)/2,S=bt.rationalBezierCurveArcLength(r,A),S>s?(_=A,y=S):(d=A,g=S);return(d+_)/2},bt.rationalCurveArcLength=function(r,s,o){o==null&&(o=16),s==null?s=Z.last(r.knots):s=s;for(var l=_t.decomposeCurveIntoBeziers(r),u=0,d=l[0],g=0;u<l.length&&d.knots[0]+rt.EPSILON<s;){var _=Math.min(Z.last(d.knots),s);g+=bt.rationalBezierCurveArcLength(d,_,o),d=l[++u]}return g},bt.rationalBezierCurveArcLength=function(r,s,o){o==null&&(o=16);var l;s==null?l=Z.last(r.knots):l=s;for(var u=(l-r.knots[0])/2,d=0,g=r.degree+o,_,y,A=0;A<g;){var S=A++;_=u*bt.Tvalues[g][S]+u+r.knots[0],y=C.rationalCurveDerivatives(r,_,1),d+=bt.Cvalues[g][S]*p.norm(y[1])}return u*d};var Ln=f.eval.KnotMultiplicity=function(r,s){this.knot=r,this.mult=s};x["verb.eval.KnotMultiplicity"]=Ln,Ln.__name__=["verb","eval","KnotMultiplicity"],Ln.prototype={inc:function(){this.mult++},__class__:Ln};var $e=f.eval.Check=function(){};x["verb.eval.Check"]=$e,$e.__name__=["verb","eval","Check"],$e.isValidKnotVector=function(r,s){if(r.length==0||r.length<(s+1)*2)return!1;for(var o=Z.first(r),l=0,u=s+1;l<u;){var d=l++;if(Math.abs(r[d]-o)>rt.EPSILON)return!1}o=Z.last(r);for(var g=r.length-s-1,_=r.length;g<_;){var y=g++;if(Math.abs(r[y]-o)>rt.EPSILON)return!1}return $e.isNonDecreasing(r)},$e.isNonDecreasing=function(r){for(var s=Z.first(r),o=0,l=r.length;o<l;){var u=o++;if(r[u]<s-rt.EPSILON)return!1;s=r[u]}return!0},$e.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(!$e.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},$e.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(!$e.isValidKnotVector(r.knotsU,r.degreeU)||!$e.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 ue=f.eval.Divide=function(){};x["verb.eval.Divide"]=ue,ue.__name__=["verb","eval","Divide"],ue.surfaceSplit=function(r,s,o){o==null&&(o=!1);var l,u,d;o?(d=r.controlPoints,l=r.knotsV,u=r.degreeV):(d=Ot.transpose(r.controlPoints),l=r.knotsU,u=r.degreeU);for(var g,_=[],y=0,A=u+1;y<A;)y++,_.push(s);g=_;for(var S=[],P=[],E=C.knotSpan(u,s,l),k=null,T=0;T<d.length;){var B=d[T];++T,k=_t.curveKnotRefine(new Wt(u,l,B),g),S.push(k.controlPoints.slice(0,E+1)),P.push(k.controlPoints.slice(E+1))}var N=k.knots.slice(0,E+u+2),R=k.knots.slice(E+1);return o?[new ne(r.degreeU,u,r.knotsU.slice(),N,S),new ne(r.degreeU,u,r.knotsU.slice(),R,P)]:(S=Ot.transpose(S),P=Ot.transpose(P),[new ne(u,r.degreeV,N,r.knotsV.slice(),S),new ne(u,r.degreeV,R,r.knotsV.slice(),P)])},ue.curveSplit=function(r,s){var o=r.degree;r.controlPoints;for(var l=r.knots,u,d=[],g=0,_=o+1;g<_;)g++,d.push(s);u=d;var y=_t.curveKnotRefine(r,u),A=C.knotSpan(o,s,l),S=y.knots.slice(0,A+o+2),P=y.knots.slice(A+1),E=y.controlPoints.slice(0,A+1),k=y.controlPoints.slice(A+1);return[new Wt(o,S,E),new Wt(o,P,k)]},ue.rationalCurveByEqualArcLength=function(r,s){var o=bt.rationalCurveArcLength(r),l=o/s;return ue.rationalCurveByArcLength(r,l)},ue.rationalCurveByArcLength=function(r,s){var o=_t.decomposeCurveIntoBeziers(r),l=o.map(function(E){return bt.rationalBezierCurveArcLength(E)}),u=p.sum(l),d=[new On(r.knots[0],0)];if(s>u)return d;for(var g=s,_=0,y=g,A=0,S=0,P;_<o.length;){for(A+=l[_];y<A+rt.EPSILON;)P=bt.rationalBezierCurveParamAtArcLength(o[_],y-S,rt.TOLERANCE,l[_]),d.push(new On(P,y)),y+=g;S+=l[_],_++}return d};var On=f.eval.CurveLengthSample=function(r,s){this.u=r,this.len=s};x["verb.eval.CurveLengthSample"]=On,On.__name__=["verb","eval","CurveLengthSample"],On.prototype={__class__:On};var C=f.eval.Eval=function(){};x["verb.eval.Eval"]=C,C.__name__=["verb","eval","Eval"],C.rationalCurveTangent=function(r,s){var o=C.rationalCurveDerivatives(r,s,1);return o[1]},C.rationalSurfaceNormal=function(r,s,o){var l=C.rationalSurfaceDerivatives(r,s,o,1);return p.cross(l[1][0],l[0][1])},C.rationalSurfaceDerivatives=function(r,s,o,l){l==null&&(l=1);for(var u=C.surfaceDerivatives(r,s,o,l),d=C.rational2d(u),g=C.weight2d(u),_=[],y=d[0][0].length,A=0,S=l+1;A<S;){var P=A++;_.push([]);for(var E=0,k=l-P+1;E<k;){for(var T=E++,B=d[P][T],N=1,R=T+1;N<R;){var z=N++;p.subMulMutate(B,Ft.get(T,z)*g[0][z],_[P][T-z])}for(var V=1,U=P+1;V<U;){var Y=V++;p.subMulMutate(B,Ft.get(P,Y)*g[Y][0],_[P-Y][T]);for(var J=p.zeros1d(y),q=1,j=T+1;q<j;){var $=q++;p.addMulMutate(J,Ft.get(T,$)*g[Y][$],_[P-Y][T-$])}p.subMulMutate(B,Ft.get(P,Y),J)}p.mulMutate(1/g[0][0],B),_[P].push(B)}}return _},C.rationalSurfacePoint=function(r,s,o){return C.dehomogenize(C.surfacePoint(r,s,o))},C.rationalCurveDerivatives=function(r,s,o){o==null&&(o=1);for(var l=C.curveDerivatives(r,s,o),u=C.rational1d(l),d=C.weight1d(l),g=[],_=0,y=o+1;_<y;){for(var A=_++,S=u[A],P=1,E=A+1;P<E;){var k=P++;p.subMulMutate(S,Ft.get(A,k)*d[k],g[A-k])}p.mulMutate(1/d[0],S),g.push(S)}return g},C.rationalCurvePoint=function(r,s){return C.dehomogenize(C.curvePoint(r,s))},C.surfaceDerivatives=function(r,s,o,l){var u=r.knotsU.length-r.degreeU-2,d=r.knotsV.length-r.degreeV-2;return C.surfaceDerivativesGivenNM(u,d,r,s,o,l)},C.surfaceDerivativesGivenNM=function(r,s,o,l,u,d){var g=o.degreeU,_=o.degreeV,y=o.controlPoints,A=o.knotsU,S=o.knotsV;if(!C.areValidRelations(g,y.length,A.length)||!C.areValidRelations(_,y[0].length,S.length))throw new Q("Invalid relations between control points, knot vector, and n");var P=y[0][0].length,E;d<g?E=d:E=g;var k;d<_?k=d:k=_;for(var T=p.zeros3d(d+1,d+1,P),B=C.knotSpanGivenN(r,g,l,A),N=C.knotSpanGivenN(s,_,u,S),R=C.derivativeBasisFunctionsGivenNI(B,l,g,r,A),z=C.derivativeBasisFunctionsGivenNI(N,u,_,s,S),V=p.zeros2d(_+1,P),U=0,Y=0,J=E+1;Y<J;){for(var q=Y++,j=0,$=_+1;j<$;){var tt=j++;V[tt]=p.zeros1d(P);for(var et=0,it=g+1;et<it;){var ht=et++;p.addMulMutate(V[tt],R[q][ht],y[B-g+ht][N-_+tt])}}var at=d-q;at<k?U=at:U=k;for(var ut=0,nt=U+1;ut<nt;){var mt=ut++;T[q][mt]=p.zeros1d(P);for(var K=0,ft=_+1;K<ft;){var Et=K++;p.addMulMutate(T[q][mt],z[mt][Et],V[Et])}}}return T},C.surfacePoint=function(r,s,o){var l=r.knotsU.length-r.degreeU-2,u=r.knotsV.length-r.degreeV-2;return C.surfacePointGivenNM(l,u,r,s,o)},C.surfacePointGivenNM=function(r,s,o,l,u){var d=o.degreeU,g=o.degreeV,_=o.controlPoints,y=o.knotsU,A=o.knotsV;if(!C.areValidRelations(d,_.length,y.length)||!C.areValidRelations(g,_[0].length,A.length))throw new Q("Invalid relations between control points, knot vector, and n");for(var S=_[0][0].length,P=C.knotSpanGivenN(r,d,l,y),E=C.knotSpanGivenN(s,g,u,A),k=C.basisFunctionsGivenKnotSpanIndex(P,l,d,y),T=C.basisFunctionsGivenKnotSpanIndex(E,u,g,A),B=P-d,N=E,R=p.zeros1d(S),z=p.zeros1d(S),V=0,U=g+1;V<U;){var Y=V++;z=p.zeros1d(S),N=E-g+Y;for(var J=0,q=d+1;J<q;){var j=J++;p.addMulMutate(z,k[j],_[B+j][N])}p.addMulMutate(R,T[Y],z)}return R},C.curveRegularSamplePoints=function(r,s){for(var o=C.curveDerivatives(r,r.knots[0],r.degree),l=1/s,u=l*l,d=o[0],g=p.mul(l,o[1]),_=p.mul(u*.5,o[2]),y=p.mul(u*l*.5,o[3]),A=p.add(_,_),S=p.add(y,y),P=p.mul(.3333333333333333,y),E=[],k=0,T=s+1;k<T;)k++,E.push(C.dehomogenize(d)),p.addAllMutate([d,g,_,P]),p.addAllMutate([g,A,y]),p.addAllMutate([A,S]),p.addAllMutate([_,y]);return E},C.curveRegularSamplePoints2=function(r,s){for(var o=C.curveDerivatives(r,r.knots[0],r.degree),l=1/s,u=l*l,d=o[0],g=p.mul(l,o[1]),_=p.mul(u*.5,o[2]),y=p.mul(u*l*.5,o[3]),A=p.add(_,_),S=p.add(y,y),P=p.mul(.3333333333333333,y),E=[],k=0,T=s+1;k<T;)k++,E.push(C.dehomogenize(d)),p.addAllMutate([d,g,_,P]),p.addAllMutate([g,A,y]),p.addAllMutate([A,S]),p.addAllMutate([_,y]);return E},C.rationalSurfaceRegularSampleDerivatives=function(r,s,o,l){for(var u=C.surfaceRegularSampleDerivatives(r,s,o,l),d=[],g=s+1,_=o+1,y=l+1,A=0;A<g;){var S=A++,P=[];d.push(P);for(var E=0;E<_;){for(var k=E++,T=u[S][k],B=C.rational2d(T),N=C.weight2d(T),R=[],z=B[0][0].length,V=0;V<y;){var U=V++;R.push([]);for(var Y=0,J=y-U;Y<J;){for(var q=Y++,j=B[U][q],$=1,tt=q+1;$<tt;){var et=$++;p.subMulMutate(j,Ft.get(q,et)*N[0][et],R[U][q-et])}for(var it=1,ht=U+1;it<ht;){var at=it++;p.subMulMutate(j,Ft.get(U,at)*N[at][0],R[U-at][q]);for(var ut=p.zeros1d(z),nt=1,mt=q+1;nt<mt;){var K=nt++;p.addMulMutate(ut,Ft.get(q,K)*N[at][K],R[U-at][q-K])}p.subMulMutate(j,Ft.get(U,at),ut)}p.mulMutate(1/N[0][0],j),R[U].push(j)}}P.push(R)}}return d},C.surfaceRegularSampleDerivatives=function(r,s,o,l){var u=r.degreeU,d=r.degreeV,g=r.controlPoints,_=r.knotsU,y=r.knotsV,A=g[0][0].length;(Z.last(_)-_[0])/s,(Z.last(y)-y[0])/o;for(var S=C.regularlySpacedDerivativeBasisFunctions(u,_,s),P=S.item0,E=S.item1,k=C.regularlySpacedDerivativeBasisFunctions(d,y,o),T=k.item0,B=k.item1,N=[],R=s+1,z=o+1,V=0;V<R;){var U=V++,Y=[];N.push(Y);for(var J=0;J<z;){var q=J++;Y.push(C.surfaceDerivativesGivenBasesKnotSpans(u,d,g,P[U],T[q],E[U],B[q],A,l))}}return N},C.rationalSurfaceRegularSamplePoints=function(r,s,o){return C.dehomogenize2d(C.surfaceRegularSamplePoints(r,s,o))},C.surfaceRegularSamplePoints=function(r,s,o){var l=r.degreeU,u=r.degreeV,d=r.controlPoints,g=r.knotsU,_=r.knotsV,y=d[0][0].length;(Z.last(g)-g[0])/s,(Z.last(_)-_[0])/o;for(var A=C.regularlySpacedBasisFunctions(l,g,s),S=A.item0,P=A.item1,E=C.regularlySpacedBasisFunctions(u,_,o),k=E.item0,T=E.item1,B=[],N=s+1,R=o+1,z=0;z<N;){var V=z++,U=[];B.push(U);for(var Y=0;Y<R;){var J=Y++;U.push(C.surfacePointGivenBasesKnotSpans(l,u,d,S[V],k[J],P[V],T[J],y))}}return B},C.regularlySpacedBasisFunctions=function(r,s,o){for(var l=s.length-r-2,u=(Z.last(s)-s[0])/o,d=[],g=[],_=s[0],y=C.knotSpanGivenN(l,r,_,s),A=o+1,S=0;S<A;){for(S++;_>=s[y+1];)y++;g.push(y),d.push(C.basisFunctionsGivenKnotSpanIndex(y,_,r,s)),_+=u}return new se(g,d)},C.regularlySpacedDerivativeBasisFunctions=function(r,s,o){for(var l=s.length-r-2,u=(Z.last(s)-s[0])/o,d=[],g=[],_=s[0],y=C.knotSpanGivenN(l,r,_,s),A=o+1,S=0;S<A;){for(S++;_>=s[y+1];)y++;g.push(y),d.push(C.derivativeBasisFunctionsGivenNI(y,_,r,l,s)),_+=u}return new se(g,d)},C.surfacePointGivenBasesKnotSpans=function(r,s,o,l,u,d,g,_){for(var y=p.zeros1d(_),A,S=l-r,P=u-s,E=0,k=s+1;E<k;){var T=E++;A=p.zeros1d(_);for(var B=0,N=r+1;B<N;){var R=B++;p.addMulMutate(A,d[R],o[S+R][P])}P++,p.addMulMutate(y,g[T],A)}return y},C.surfaceDerivativesGivenBasesKnotSpans=function(r,s,o,l,u,d,g,_,y){var A=o[0][0].length,S;y<r?S=y:S=r;var P;y<s?P=y:P=s;for(var E=p.zeros3d(S+1,P+1,A),k=p.zeros2d(s+1,A),T=0,B=0,N=S+1;B<N;){for(var R=B++,z=0,V=s+1;z<V;){var U=z++;k[U]=p.zeros1d(A);for(var Y=0,J=r+1;Y<J;){var q=Y++;p.addMulMutate(k[U],d[R][q],o[l-r+q][u-s+U])}}var j=y-R;j<P?T=j:T=P;for(var $=0,tt=T+1;$<tt;){var et=$++;E[R][et]=p.zeros1d(A);for(var it=0,ht=s+1;it<ht;){var at=it++;p.addMulMutate(E[R][et],g[et][at],k[at])}}}return E},C.curveDerivatives=function(r,s,o){var l=r.knots.length-r.degree-2;return C.curveDerivativesGivenN(l,r,s,o)},C.curveDerivativesGivenN=function(r,s,o,l){var u=s.degree,d=s.controlPoints,g=s.knots;if(!C.areValidRelations(u,d.length,g.length))throw new Q("Invalid relations between control points, knot vector, and n");var _=d[0].length,y;l<u?y=l:y=u;for(var A=p.zeros2d(l+1,_),S=C.knotSpanGivenN(r,u,o,g),P=C.derivativeBasisFunctionsGivenNI(S,o,u,y,g),E=0,k=y+1;E<k;)for(var T=E++,B=0,N=u+1;B<N;){var R=B++;p.addMulMutate(A[T],P[T][R],d[S-u+R])}return A},C.curvePoint=function(r,s){var o=r.knots.length-r.degree-2;return C.curvePointGivenN(o,r,s)},C.areValidRelations=function(r,s,o){return s+r+1-o==0},C.curvePointGivenN=function(r,s,o){var l=s.degree,u=s.controlPoints,d=s.knots;if(!C.areValidRelations(l,u.length,d.length))throw new Q("Invalid relations between control points, knot Array, and n");for(var g=C.knotSpanGivenN(r,l,o,d),_=C.basisFunctionsGivenKnotSpanIndex(g,o,l,d),y=p.zeros1d(u[0].length),A=0,S=l+1;A<S;){var P=A++;p.addMulMutate(y,_[P],u[g-l+P])}return y},C.volumePoint=function(r,s,o,l){var u=r.knotsU.length-r.degreeU-2,d=r.knotsV.length-r.degreeV-2,g=r.knotsW.length-r.degreeW-2;return C.volumePointGivenNML(r,u,d,g,s,o,l)},C.volumePointGivenNML=function(r,s,o,l,u,d,g){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,y=r.degreeU,A=r.degreeV,S=r.degreeW,P=r.knotsU,E=r.knotsV,k=r.knotsW,T=_[0][0][0].length,B=C.knotSpanGivenN(s,y,u,P),N=C.knotSpanGivenN(o,A,d,E),R=C.knotSpanGivenN(l,S,g,k),z=C.basisFunctionsGivenKnotSpanIndex(B,u,y,P),V=C.basisFunctionsGivenKnotSpanIndex(N,d,A,E),U=C.basisFunctionsGivenKnotSpanIndex(R,g,S,k),Y=B-y,J=p.zeros1d(T),q=p.zeros1d(T),j=p.zeros1d(T),$=0,tt=S+1;$<tt;){var et=$++;j=p.zeros1d(T);for(var it=R-S+et,ht=0,at=A+1;ht<at;){var ut=ht++;q=p.zeros1d(T);for(var nt=N-A+ut,mt=0,K=y+1;mt<K;){var ft=mt++;p.addMulMutate(q,z[ft],_[Y+ft][nt][it])}p.addMulMutate(j,V[ut],q)}p.addMulMutate(J,U[et],j)}return J},C.derivativeBasisFunctions=function(r,s,o){var l=C.knotSpan(s,r,o),u=o.length-1,d=u-s-1;return C.derivativeBasisFunctionsGivenNI(l,r,s,d,o)},C.derivativeBasisFunctionsGivenNI=function(r,s,o,l,u){var d=p.zeros2d(o+1,o+1),g=p.zeros1d(o+1),_=p.zeros1d(o+1),y=0,A=0;d[0][0]=1;for(var S=1,P=o+1;S<P;){var E=S++;g[E]=s-u[r+1-E],_[E]=u[r+E]-s,y=0;for(var k=0;k<E;){var T=k++;d[E][T]=_[T+1]+g[E-T],A=d[T][E-1]/d[E][T],d[T][E]=y+_[T+1]*A,y=g[E-T]*A}d[E][E]=y}for(var B=p.zeros2d(l+1,o+1),N=p.zeros2d(2,o+1),R=0,z=1,V=0,U=0,Y=0,J=0,q=0,j=0,$=o+1;j<$;){var tt=j++;B[0][tt]=d[tt][o]}for(var et=0,it=o+1;et<it;){var ht=et++;R=0,z=1,N[0][0]=1;for(var at=1,ut=l+1;at<ut;){var nt=at++;V=0,U=ht-nt,Y=o-nt,ht>=nt&&(N[z][0]=N[R][0]/d[Y+1][U],V=N[z][0]*d[U][Y]),U>=-1?J=1:J=-U,ht-1<=Y?q=nt-1:q=o-ht;for(var mt=J,K=q+1;mt<K;){var ft=mt++;N[z][ft]=(N[R][ft]-N[R][ft-1])/d[Y+1][U+ft],V+=N[z][ft]*d[U+ft][Y]}ht<=Y&&(N[z][nt]=-N[R][nt-1]/d[Y+1][ht],V+=N[z][nt]*d[ht][Y]),B[nt][ht]=V;var Et=R;R=z,z=Et}}for(var Ht=o,$t=1,Ut=l+1;$t<Ut;){for(var Qt=$t++,Ce=0,Ze=o+1;Ce<Ze;){var we=Ce++;B[Qt][we]*=Ht}Ht*=o-Qt}return B},C.basisFunctions=function(r,s,o){var l=C.knotSpan(s,r,o);return C.basisFunctionsGivenKnotSpanIndex(l,r,s,o)},C.basisFunctionsGivenKnotSpanIndex=function(r,s,o,l){var u=p.zeros1d(o+1),d=p.zeros1d(o+1),g=p.zeros1d(o+1),_=0,y=0;u[0]=1;for(var A=1,S=o+1;A<S;){var P=A++;d[P]=s-l[r+1-P],g[P]=l[r+P]-s,_=0;for(var E=0;E<P;){var k=E++;y=u[k]/(g[k+1]+d[P-k]),u[k]=_+g[k+1]*y,_=d[P-k]*y}u[P]=_}return u},C.knotSpan=function(r,s,o){return C.knotSpanGivenN(o.length-r-2,r,s,o)},C.knotSpanGivenN=function(r,s,o,l){if(o>l[r+1]-rt.EPSILON)return r;if(o<l[s]+rt.EPSILON)return s;for(var u=s,d=r+1,g=Math.floor((u+d)/2);o<l[g]||o>=l[g+1];)o<l[g]?d=g:u=g,g=Math.floor((u+d)/2);return g},C.dehomogenize=function(r){for(var s=r.length,o=[],l=r[s-1],u=r.length-1,d=0;d<u;){var g=d++;o.push(r[g]/l)}return o},C.rational1d=function(r){var s=r[0].length-1;return r.map(function(o){return o.slice(0,s)})},C.rational2d=function(r){return r.map(C.rational1d)},C.weight1d=function(r){var s=r[0].length-1;return r.map(function(o){return o[s]})},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,s){var o=r.length,l=r[0].length,u=[],d=0,g=[],_;s!=null?_=s:_=p.rep(r.length,1);for(var y=0;y<o;){var A=y++,S=[];g=r[A],d=_[A];for(var P=0;P<l;){var E=P++;S.push(g[E]*d)}S.push(d),u.push(S)}return u},C.homogenize2d=function(r,s){var o=r.length,l=[],u;if(s!=null)u=s;else{for(var d=[],g=0;g<o;)g++,d.push(p.rep(r[0].length,1));u=d}for(var _=0;_<o;){var y=_++;l.push(C.homogenize1d(r[y],u[y]))}return l};var lt=f.eval.Intersect=function(){};x["verb.eval.Intersect"]=lt,lt.__name__=["verb","eval","Intersect"],lt.surfaces=function(r,s,o){var l=zt.rationalSurfaceAdaptive(r),u=zt.rationalSurfaceAdaptive(s),d=lt.meshes(l,u),g=d.map(function(_){return _.map(function(y){return lt.surfacesAtPointWithEstimate(r,s,y.uv0,y.uv1,o)})});return g.map(function(_){return gt.rationalInterpCurve(_.map(function(y){return y.point}),3)})},lt.surfacesAtPointWithEstimate=function(r,s,o,l,u){var d,g,_,y,A,S,P,E,k,T,B,N,R,z=5,V=0;do{if(d=C.rationalSurfaceDerivatives(r,o[0],o[1],1),g=d[0][0],y=d[1][0],A=d[0][1],_=p.normalized(p.cross(y,A)),S=p.dot(_,g),P=C.rationalSurfaceDerivatives(s,l[0],l[1],1),E=P[0][0],T=P[1][0],B=P[0][1],k=p.normalized(p.cross(T,B)),N=p.dot(k,E),R=p.distSquared(g,E),R<u*u)break;var U=p.normalized(p.cross(_,k)),Y=p.dot(U,g),J=lt.threePlanes(_,S,k,N,U,Y);if(J==null)throw new Q("panic!");var q=p.sub(J,g),j=p.sub(J,E),$=p.cross(y,_),tt=p.cross(A,_),et=p.cross(T,k),it=p.cross(B,k),ht=p.dot(tt,q)/p.dot(tt,y),at=p.dot($,q)/p.dot($,A),ut=p.dot(it,j)/p.dot(it,T),nt=p.dot(et,j)/p.dot(et,B);o=p.add([ht,at],o),l=p.add([ut,nt],l),V++}while(V<z);return new ss(o,l,g,R)},lt.meshes=function(r,s,o,l){o==null&&(o=new ur(r)),l==null&&(l=new ur(s));var u=lt.boundingBoxTrees(o,l,0),d=Z.unique(u.map(function(g){return lt.triangles(r,g.item0,s,g.item1)}).filter(function(g){return g!=null}).filter(function(g){return p.distSquared(g.min.point,g.max.point)>rt.EPSILON}),function(g,_){var y=p.sub(g.min.uv0,_.min.uv0),A=p.dot(y,y),S=p.sub(g.max.uv0,_.max.uv0),P=p.dot(S,S),E=p.sub(g.min.uv0,_.max.uv0),k=p.dot(E,E),T=p.sub(g.max.uv0,_.min.uv0),B=p.dot(T,T);return A<rt.EPSILON&&P<rt.EPSILON||k<rt.EPSILON&&B<rt.EPSILON});return lt.makeMeshIntersectionPolylines(d)},lt.meshSlices=function(r,s,o,l){for(var u=new jr(r),d=u.boundingBox(),g=d.min[0],_=d.min[1],y=d.max[0],A=d.max[1],S=p.span(s,o,l),P=[],E=0;E<S.length;){var k=S[E];++E;var T=[[g,_,k],[y,_,k],[y,A,k],[g,A,k]],B=[[0,0],[1,0],[1,1],[0,1]],N=[[0,1,2],[0,2,3]],R=new Qe(N,T,null,B);P.push(lt.meshes(r,R,u))}return P},lt.makeMeshIntersectionPolylines=function(r){if(r.length==0)return[];for(var s=0;s<r.length;){var o=r[s];++s,o.max.opp=o.min,o.min.opp=o.max}for(var l=lt.kdTreeFromSegments(r),u=[],d=0;d<r.length;){var g=r[d];++d,u.push(g.min),u.push(g.max)}for(var _=0;_<u.length;){var y=u[_];if(++_,y.adj==null){var A=lt.lookupAdjacentSegment(y,l,r.length);A!=null&&A.adj==null&&(y.adj=A,A.adj=y)}}var S=u.filter(function(z){return z.adj==null});S.length==0&&(S=u);for(var P=[],E=0,k=!1;S.length!=0;){var T=S.pop();if(!T.visited){for(var B=[],N=T;N!=null&&!(N.visited||(N.visited=!0,N.opp.visited=!0,B.push(N),E+=2,N=N.opp.adj,N==T)););B.length>0&&(B.push(B[B.length-1].opp),P.push(B))}if(S.length==0&&u.length>0&&(k||E<u.length)){k=!0;var R=u.pop();S.push(R)}}return P},lt.kdTreeFromSegments=function(r){for(var s=[],o=0;o<r.length;){var l=r[o];++o,s.push(new Tn(l.min.point,l.min)),s.push(new Tn(l.max.point,l.max))}return new as(s,p.distSquared)},lt.lookupAdjacentSegment=function(r,s,o){var l=s.nearest(r.point,o,rt.EPSILON).filter(function(u){return r!=u.item0.obj}).map(function(u){return u.item0.obj});return l.length==1?l[0]:null},lt.curveAndSurface=function(r,s,o,l,u){o==null&&(o=.001),l!=null?l=l:l=new cr(r),u!=null?u=u:u=new Ur(s);var d=lt.boundingBoxTrees(l,u,o);return Z.unique(d.map(function(g){var _=g.item0,y=g.item1,A=Z.first(_.knots),S=Z.last(_.knots),P=(A+S)/2,E=Z.first(y.knotsU),k=Z.last(y.knotsU),T=Z.first(y.knotsV),B=Z.last(y.knotsV),N=[(E+k)/2,(T+B)/2];return lt.curveAndSurfaceWithEstimate(_,y,[P].concat(N),o)}).filter(function(g){return p.distSquared(g.curvePoint,g.surfacePoint)<o*o}),function(g,_){return Math.abs(g.u-_.u)<.5*o})},lt.curveAndSurfaceWithEstimate=function(r,s,o,l){l==null&&(l=.001);var u=function(y){var A=C.rationalCurvePoint(r,y[0]),S=C.rationalSurfacePoint(s,y[1],y[2]),P=p.sub(A,S);return p.dot(P,P)},d=function(y){var A=C.rationalCurveDerivatives(r,y[0],1),S=C.rationalSurfaceDerivatives(s,y[1],y[2],1),P=p.sub(S[0][0],A[0]),E=p.mul(-1,A[1]),k=S[1][0],T=S[0][1];return[2*p.dot(E,P),2*p.dot(k,P),2*p.dot(T,P)]},g=Je.uncmin(u,o,l*l,d),_=g.solution;return new rs(_[0],[_[1],_[2]],C.rationalCurvePoint(r,_[0]),C.rationalSurfacePoint(s,_[1],_[2]))},lt.polylineAndMesh=function(r,s,o){for(var l=lt.boundingBoxTrees(new dr(r),new ur(s),o),u=[],d=0;d<l.length;){var g=l[d];++d;var _=g.item0,y=g.item1,A=lt.segmentWithTriangle(r.points[_],r.points[_+1],s.points,s.faces[y]);if(A!=null){var S=A.point,P=p.lerp(A.p,[r.params[_]],[r.params[_+1]])[0],E=ie.triangleUVFromPoint(s,y,S);u.push(new ns(S,P,E,_,y))}}return u},lt.boundingBoxTrees=function(r,s,o){o==null&&(o=1e-9);var l=[],u=[];l.push(r),u.push(s);for(var d=[];l.length>0;){var g=l.pop(),_=u.pop();if(!(g.empty()||_.empty())&&g.boundingBox().intersects(_.boundingBox(),o)){var y=g.indivisible(o),A=_.indivisible(o);if(y&&A){d.push(new se(g.yield(),_.yield()));continue}else if(y&&!A){var S=_.split();l.push(g),u.push(S.item1),l.push(g),u.push(S.item0);continue}else if(!y&&A){var P=g.split();l.push(P.item1),u.push(_),l.push(P.item0),u.push(_);continue}var E=g.split(),k=_.split();l.push(E.item1),u.push(k.item1),l.push(E.item1),u.push(k.item0),l.push(E.item0),u.push(k.item1),l.push(E.item0),u.push(k.item0)}}return d},lt.curves=function(r,s,o){var l=lt.boundingBoxTrees(new cr(r),new cr(s),0);return Z.unique(l.map(function(u){return lt.curvesWithEstimate(r,s,Z.first(u.item0.knots),Z.first(u.item1.knots),o)}).filter(function(u){return p.distSquared(u.point0,u.point1)<o}),function(u,d){return Math.abs(u.u0-d.u0)<o*5})},lt.curvesWithEstimate=function(r,s,o,l,u){var d=function(E){var k=C.rationalCurvePoint(r,E[0]),T=C.rationalCurvePoint(s,E[1]),B=p.sub(k,T);return p.dot(B,B)},g=function(E){var k=C.rationalCurveDerivatives(r,E[0],1),T=C.rationalCurveDerivatives(s,E[1],1),B=p.sub(k[0],T[0]),N=k[1],R=p.mul(-1,T[1]);return[2*p.dot(N,B),2*p.dot(R,B)]},_=Je.uncmin(d,[o,l],u*u,g),y=_.solution[0],A=_.solution[1],S=C.rationalCurvePoint(r,y),P=C.rationalCurvePoint(s,A);return new en(S,P,y,A)},lt.triangles=function(r,s,o,l){var u=r.faces[s],d=o.faces[l],g=ie.getTriangleNorm(r.points,u),_=ie.getTriangleNorm(o.points,d),y=r.points[u[0]],A=o.points[d[0]],S=lt.planes(y,g,A,_);if(S==null)return null;var P=lt.clipRayInCoplanarTriangle(S,r,s);if(P==null)return null;var E=lt.clipRayInCoplanarTriangle(S,o,l);if(E==null)return null;var k=lt.mergeTriangleClipIntervals(P,E,r,s,o,l);return k==null?null:new Te(new Vr(k.min.uv0,k.min.uv1,k.min.point,s,l),new Vr(k.max.uv0,k.max.uv1,k.max.point,s,l))},lt.clipRayInCoplanarTriangle=function(r,s,o){for(var l=s.faces[o],u=[s.points[l[0]],s.points[l[1]],s.points[l[2]]],d=[s.uvs[l[0]],s.uvs[l[1]],s.uvs[l[2]]],g=[p.sub(d[1],d[0]),p.sub(d[2],d[1]),p.sub(d[0],d[2])],_=[p.sub(u[1],u[0]),p.sub(u[2],u[1]),p.sub(u[0],u[2])],y=_.map(p.normalized),A=_.map(p.norm),S=null,P=null,E=0;E<3;){var k=E++,T=u[k],B=y[k],N=lt.rays(T,B,r.origin,r.dir);if(N!=null){var R=N.u0,z=N.u1;R<-rt.EPSILON||R>A[k]+rt.EPSILON||((S==null||z<S.u)&&(S=new kn(z,p.onRay(r.origin,r.dir,z),p.onRay(d[k],g[k],R/A[k]))),(P==null||z>P.u)&&(P=new kn(z,p.onRay(r.origin,r.dir,z),p.onRay(d[k],g[k],R/A[k]))))}}return P==null||S==null?null:new Te(S,P)},lt.mergeTriangleClipIntervals=function(r,s,o,l,u,d){if(s.min.u>r.max.u+rt.EPSILON||r.min.u>s.max.u+rt.EPSILON)return null;var g;r.min.u>s.min.u?g=new se(r.min,0):g=new se(s.min,1);var _;r.max.u<s.max.u?_=new se(r.max,0):_=new se(s.max,1);var y=new Te(new Vr(null,null,g.item0.point,l,d),new Vr(null,null,_.item0.point,l,d));return g.item1==0?(y.min.uv0=g.item0.uv,y.min.uv1=ie.triangleUVFromPoint(u,d,g.item0.point)):(y.min.uv0=ie.triangleUVFromPoint(o,l,g.item0.point),y.min.uv1=g.item0.uv),_.item1==0?(y.max.uv0=_.item0.uv,y.max.uv1=ie.triangleUVFromPoint(u,d,_.item0.point)):(y.max.uv0=ie.triangleUVFromPoint(o,l,_.item0.point),y.max.uv1=_.item0.uv),y},lt.planes=function(r,s,o,l){var u=p.cross(s,l);if(p.dot(u,u)<rt.EPSILON)return null;var d=0,g=Math.abs(u[0]),_=Math.abs(u[1]),y=Math.abs(u[2]);_>g&&(d=1,g=_),y>g&&(d=2,g=y);var A,S,P,E;d==0?(A=s[1],S=s[2],P=l[1],E=l[2]):d==1?(A=s[0],S=s[2],P=l[0],E=l[2]):(A=s[0],S=s[1],P=l[0],E=l[1]);var k=-p.dot(r,s),T=-p.dot(o,l),B=A*E-S*P,N=(S*T-k*E)/B,R=(k*P-A*T)/B,z;return d==0?z=[0,N,R]:d==1?z=[N,0,R]:z=[N,R,0],new Mn(z,p.normalized(u))},lt.threePlanes=function(r,s,o,l,u,d){var g=p.cross(o,u),_=p.dot(r,g);if(Math.abs(_)<rt.EPSILON)return null;var y=p.sub(p.mul(d,o),p.mul(l,u)),A=p.add(p.mul(s,g),p.cross(r,y));return p.mul(1/_,A)},lt.polylines=function(r,s,o){for(var l=lt.boundingBoxTrees(new dr(r),new dr(s),o),u=[],d=0;d<l.length;){var g=l[d];++d;var _=g.item0,y=g.item1,A=lt.segments(r.points[_],r.points[_+1],s.points[y],s.points[y+1],o);A!=null&&(A.u0=p.lerp(A.u0,[r.params[_]],[r.params[_+1]])[0],A.u1=p.lerp(A.u1,[s.params[y]],[s.params[y+1]])[0],u.push(A))}return u},lt.segments=function(r,s,o,l,u){var d=p.sub(s,r),g=Math.sqrt(p.dot(d,d)),_=p.mul(1/g,d),y=p.sub(l,o),A=Math.sqrt(p.dot(y,y)),S=p.mul(1/A,y),P=lt.rays(r,_,o,S);if(P!=null){var E=Math.min(Math.max(0,P.u0/g),1),k=Math.min(Math.max(0,P.u1/A),1),T=p.onRay(r,d,E),B=p.onRay(o,y,k),N=p.distSquared(T,B);if(N<u*u)return new en(T,B,E,k)}return null},lt.rays=function(r,s,o,l){var u=p.dot(s,l),d=p.dot(s,o),g=p.dot(s,r),_=p.dot(l,o),y=p.dot(l,r),A=p.dot(s,s),S=p.dot(l,l),P=A*S-u*u;if(Math.abs(P)<rt.EPSILON)return null;var E=u*(d-g)-A*(_-y),k=E/P,T=(d-g+k*u)/A,B=p.onRay(r,s,T),N=p.onRay(o,l,k);return new en(B,N,T,k)},lt.segmentWithTriangle=function(r,s,o,l){var u=o[l[0]],d=o[l[1]],g=o[l[2]],_=p.sub(d,u),y=p.sub(g,u),A=p.cross(_,y),S=p.sub(s,r),P=p.sub(r,u),E=-p.dot(A,P),k=p.dot(A,S);if(Math.abs(k)<rt.EPSILON)return null;var T=E/k;if(T<0||T>1)return null;var B=p.add(r,p.mul(T,S)),N=p.dot(_,y),R=p.dot(_,_),z=p.dot(y,y),V=p.sub(B,u),U=p.dot(V,_),Y=p.dot(V,y),J=N*N-R*z;if(Math.abs(J)<rt.EPSILON)return null;var q=(N*Y-z*U)/J,j=(N*U-R*Y)/J;return q>1+rt.EPSILON||j>1+rt.EPSILON||j<-rt.EPSILON||q<-rt.EPSILON||q+j>1+rt.EPSILON?null:new is(B,q,j,T)},lt.segmentAndPlane=function(r,s,o,l){var u=p.dot(l,p.sub(s,r));if(Math.abs(u)<rt.EPSILON)return null;var d=p.dot(l,p.sub(o,r)),g=d/u;return g>1+rt.EPSILON||g<-rt.EPSILON?null:{p:g}};var gt=f.eval.Make=function(){};x["verb.eval.Make"]=gt,gt.__name__=["verb","eval","Make"],gt.rationalTranslationalSurface=function(r,s){for(var o=C.rationalCurvePoint(s,Z.first(s.knots)),l=Z.first(s.knots),u=Z.last(s.knots),d=2*s.controlPoints.length,g=(u-l)/(d-1),_=[],y=0;y<d;){var A=y++,S=p.sub(C.rationalCurvePoint(s,l+A*g),o),P=_t.rationalCurveTransform(r,[[1,0,0,S[0]],[0,1,0,S[1]],[0,0,1,S[2]],[0,0,0,1]]);_.push(P)}return gt.loftedSurface(_)},gt.surfaceBoundaryCurves=function(r){var s=gt.surfaceIsocurve(r,Z.first(r.knotsU),!1),o=gt.surfaceIsocurve(r,Z.last(r.knotsU),!1),l=gt.surfaceIsocurve(r,Z.first(r.knotsV),!0),u=gt.surfaceIsocurve(r,Z.last(r.knotsV),!0);return[s,o,l,u]},gt.surfaceIsocurve=function(r,s,o){o==null&&(o=!1);var l;o?l=r.knotsV:l=r.knotsU;var u;o?u=r.degreeV:u=r.degreeU;for(var d=bt.knotMultiplicities(l),g=-1,_=0,y=d.length;_<y;){var A=_++;if(Math.abs(s-d[A].knot)<rt.EPSILON){g=A;break}}var S=u+1;g>=0&&(S=S-d[g].mult);var P;S>0?P=_t.surfaceKnotRefine(r,p.rep(S,s),o):P=r;var E=C.knotSpan(u,s,l);return Math.abs(s-Z.first(l))<rt.EPSILON?E=0:Math.abs(s-Z.last(l))<rt.EPSILON&&(E=(o?P.controlPoints[0].length:P.controlPoints.length)-1),o?new Wt(P.degreeU,P.knotsU,function(k){for(var T,B=[],N=0,R=P.controlPoints;N<R.length;){var z=R[N];++N,B.push(z[E])}return T=B,T}()):new Wt(P.degreeV,P.knotsV,P.controlPoints[E])},gt.loftedSurface=function(r,s){r=_t.unifyCurveKnotVectors(r);var o=r[0].degree;s==null&&(s=3),s>r.length-1&&(s=r.length-1);for(var l=r[0].knots,u=[],d=[],g=0,_=r[0].controlPoints.length;g<_;){var y=[g++],A=r.map(function(P){return function(E){return E.controlPoints[P[0]]}}(y)),S=gt.rationalInterpCurve(A,s,!0);d.push(S.controlPoints),u=S.knots}return new ne(o,s,l,u,d)},gt.clonedCurve=function(r){return new Wt(r.degree,r.knots.slice(),r.controlPoints.map(function(s){return s.slice()}))},gt.rationalBezierCurve=function(r,s){for(var o=r.length-1,l=[],u=0,d=o+1;u<d;)u++,l.push(0);for(var g=0,_=o+1;g<_;)g++,l.push(1);return s==null&&(s=p.rep(r.length,1)),new Wt(o,l,C.homogenize1d(r,s))},gt.fourPointSurface=function(r,s,o,l,u){u==null&&(u=3);for(var d=u,g=[],_=0,y=u+1;_<y;){for(var A=_++,S=[],P=0,E=u+1;P<E;){var k=P++,T=1-A/d,B=p.lerp(T,r,s),N=p.lerp(T,l,o),R=p.lerp(1-k/d,B,N);R.push(1),S.push(R)}g.push(S)}var z=p.rep(u+1,0),V=p.rep(u+1,1);return new ne(u,u,z.concat(V),z.concat(V),g)},gt.ellipseArc=function(r,s,o,l,u){var d=p.norm(s),g=p.norm(o);s=p.normalized(s),o=p.normalized(o),u<l&&(u=2*Math.PI+l);var _=u-l,y=0;_<=Math.PI/2?y=1:_<=Math.PI?y=2:_<=3*Math.PI/2?y=3:y=4;var A=_/y,S=Math.cos(A/2),P=p.add(r,p.add(p.mul(d*Math.cos(l),s),p.mul(g*Math.sin(l),o))),E=p.sub(p.mul(Math.cos(l),o),p.mul(Math.sin(l),s)),k=[],T=p.zeros1d(2*y+3),B=0,N=l,R=p.zeros1d(y*2);k[0]=P,R[0]=1;for(var z=1,V=y+1;z<V;){var U=z++;N+=A;var Y=p.add(r,p.add(p.mul(d*Math.cos(N),s),p.mul(g*Math.sin(N),o)));R[B+2]=1,k[B+2]=Y;var J=p.sub(p.mul(Math.cos(N),o),p.mul(Math.sin(N),s)),q=lt.rays(P,p.mul(1/p.norm(E),E),Y,p.mul(1/p.norm(J),J)),j=p.add(P,p.mul(q.u0,E));R[B+1]=S,k[B+1]=j,B+=2,U<y&&(P=Y,E=J)}for(var $=2*y+1,tt=0;tt<3;){var et=tt++;T[et]=0,T[et+$]=1}switch(y){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 Wt(2,T,C.homogenize1d(k,R))},gt.arc=function(r,s,o,l,u,d){return gt.ellipseArc(r,p.mul(l,p.normalized(s)),p.mul(l,p.normalized(o)),u,d)},gt.polyline=function(r){for(var s=[0,0],o=0,l=0,u=r.length-1;l<u;){var d=l++;o+=p.dist(r[d],r[d+1]),s.push(o)}s.push(o),s=p.mul(1/o,s);for(var g,_=[],y=0,A=r.length;y<A;)y++,_.push(1);return g=_,new Wt(1,s,C.homogenize1d(r.slice(0),g))},gt.extrudedSurface=function(r,s,o){for(var l=[[],[],[]],u=[[],[],[]],d=C.dehomogenize1d(o.controlPoints),g=C.weight1d(o.controlPoints),_=p.mul(s,r),y=p.mul(.5*s,r),A=0,S=d.length;A<S;){var P=A++;l[2][P]=d[P],l[1][P]=p.add(y,d[P]),l[0][P]=p.add(_,d[P]),u[0][P]=g[P],u[1][P]=g[P],u[2][P]=g[P]}return new ne(2,o.degree,[0,0,0,1,1,1],o.knots,C.homogenize2d(l,u))},gt.cylindricalSurface=function(r,s,o,l,u){var d=p.cross(r,s),g=gt.arc(o,s,d,u,0,2*Math.PI);return gt.extrudedSurface(r,l,g)},gt.revolvedSurface=function(r,s,o,l){var u=C.dehomogenize1d(r.controlPoints),d=C.weight1d(r.controlPoints),g,_;l<=Math.PI/2?(g=1,_=p.zeros1d(6+2*(g-1))):l<=Math.PI?(g=2,_=p.zeros1d(6+2*(g-1)),_[3]=_[4]=.5):l<=3*Math.PI/2?(g=3,_=p.zeros1d(6+2*(g-1)),_[3]=_[4]=.3333333333333333,_[5]=_[6]=.6666666666666666):(g=4,_=p.zeros1d(6+2*(g-1)),_[3]=_[4]=.25,_[5]=_[6]=.5,_[7]=_[8]=.75);for(var y=l/g,A=3+2*(g-1),S=0;S<3;){var P=S++;_[P]=0,_[A+P]=1}for(var E=Math.cos(y/2),k=0,T=p.zeros1d(g+1),B=p.zeros1d(g+1),N=p.zeros3d(2*g+1,u.length,3),R=p.zeros2d(2*g+1,u.length),z=1,V=g+1;z<V;){var U=z++;k+=y,B[U]=Math.cos(k),T[U]=Math.sin(k)}for(var Y=0,J=u.length;Y<J;){var q=Y++,j=Re.rayClosestPoint(u[q],s,o),$=p.sub(u[q],j),tt=p.norm($),et=p.cross(o,$);tt>rt.EPSILON&&($=p.mul(1/tt,$),et=p.mul(1/tt,et)),N[0][q]=u[q];var it=u[q];R[0][q]=d[q];for(var ht=et,at=0,ut=1,nt=g+1;ut<nt;){var mt=ut++,K;tt==0?K=j:K=p.add(j,p.add(p.mul(tt*B[mt],$),p.mul(tt*T[mt],et))),N[at+2][q]=K,R[at+2][q]=d[q];var ft=p.sub(p.mul(B[mt],et),p.mul(T[mt],$));if(tt==0)N[at+1][q]=j;else{var Et=lt.rays(it,p.mul(1/p.norm(ht),ht),K,p.mul(1/p.norm(ft),ft)),Ht=p.add(it,p.mul(Et.u0,ht));N[at+1][q]=Ht}R[at+1][q]=E*d[q],at+=2,mt<g&&(it=K,ht=ft)}}return new ne(2,r.degree,_,r.knots,C.homogenize2d(N,R))},gt.sphericalSurface=function(r,s,o,l){var u=gt.arc(r,p.mul(-1,s),o,l,0,Math.PI);return gt.revolvedSurface(u,r,s,2*Math.PI)},gt.conicalSurface=function(r,s,o,l,u){var d=2*Math.PI,g=1,_=[p.add(o,p.mul(l,r)),p.add(o,p.mul(u,s))],y=[0,0,1,1],A=[1,1],S=new Wt(g,y,C.homogenize1d(_,A));return gt.revolvedSurface(S,o,r,d)},gt.rationalInterpCurve=function(r,s,o,l,u){if(o==null&&(o=!1),s==null&&(s=3),r.length<s+1)throw new Q("You need to supply at least degree + 1 points! You only supplied "+r.length+" points.");for(var d=[0],g=1,_=r.length;g<_;){var y=g++,A=p.norm(p.sub(r[y],r[y-1])),S=d[d.length-1];d.push(S+A)}for(var P=d[d.length-1],E=0,k=d.length;E<k;){var T=E++;d[T]=d[T]/P}var B=p.rep(s+1,0),N=l!=null&&u!=null,R;N?R=0:R=1;var z;N?z=d.length-s+1:z=d.length-s;for(var V=R;V<z;){for(var U=V++,Y=0,J=0;J<s;){var q=J++;Y+=d[U+q]}B.push(1/s*Y)}var j=B.concat(p.rep(s+1,1)),$=[],tt;N?tt=r.length+1:tt=r.length-1;var et;N?et=r.length-(s-1):et=r.length-(s+1);for(var it=0;it<d.length;){var ht=d[it];++it;var at=C.knotSpanGivenN(tt,s,ht,j),ut=C.basisFunctionsGivenKnotSpanIndex(at,ht,s,j),nt=at-s,mt=p.zeros1d(nt),K=p.zeros1d(et-nt);$.push(mt.concat(ut).concat(K))}if(N){var ft=$[0].length-2,Et=[-1,1].concat(p.zeros1d(ft)),Ht=p.zeros1d(ft).concat([-1,1]);Z.spliceAndInsert($,1,0,Et),Z.spliceAndInsert($,$.length-1,0,Ht)}for(var $t=r[0].length,Ut=[],Qt=(1-j[j.length-s-2])/s,Ce=j[s+1]/s,Ze=0;Ze<$t;){var we=[Ze++],ye;if(!N)ye=r.map(function(sr){return function(vr){return vr[sr[0]]}}(we));else{ye=[r[0][we[0]]],ye.push(Ce*l[we[0]]);for(var Ne=1,Fe=r.length-1;Ne<Fe;){var er=Ne++;ye.push(r[er][we[0]])}ye.push(Qt*u[we[0]]),ye.push(Z.last(r)[we[0]])}var pr=Ot.solve($,ye);Ut.push(pr)}var rr=Ot.transpose(Ut);if(!o){var nr=p.rep(rr.length,1);rr=C.homogenize1d(rr,nr)}return new Wt(s,j,rr)};var _t=f.eval.Modify=function(){};x["verb.eval.Modify"]=_t,_t.__name__=["verb","eval","Modify"],_t.curveReverse=function(r){return new Wt(r.degree,_t.knotsReverse(r.knots),Z.reversed(r.controlPoints))},_t.surfaceReverse=function(r,s){return s==null&&(s=!1),s?new ne(r.degreeU,r.degreeV,r.knotsU,_t.knotsReverse(r.knotsV),function(o){for(var l,u=[],d=0,g=r.controlPoints;d<g.length;){var _=g[d];++d,u.push(Z.reversed(_))}return l=u,l}()):new ne(r.degreeU,r.degreeV,_t.knotsReverse(r.knotsU),r.knotsV,Z.reversed(r.controlPoints))},_t.knotsReverse=function(r){var s=Z.first(r);Z.last(r);for(var o=[s],l=r.length,u=1;u<l;){var d=u++;o.push(o[d-1]+(r[l-d]-r[l-d-1]))}return o},_t.unifyCurveKnotVectors=function(r){r=r.map(gt.clonedCurve);for(var s=L.fold(r,function(j,$){return _t.imax(j.degree,$)},0),o=0,l=r.length;o<l;){var u=o++;r[u].degree<s&&(r[u]=_t.curveElevateDegree(r[u],s))}for(var d,g=[],_=0;_<r.length;){var y=r[_];++_,g.push(new Te(Z.first(y.knots),Z.last(y.knots)))}d=g;for(var A=0,S=r.length;A<S;){var P=A++,E=[d[P].min];r[P].knots=r[P].knots.map(function(j){return function($){return $-j[0]}}(E))}for(var k=d.map(function(j){return j.max-j.min}),T=L.fold(k,function(j,$){return Math.max(j,$)},0),B=0,N=r.length;B<N;){var R=B++,z=[T/k[R]];r[R].knots=r[R].knots.map(function(j){return function($){return $*j[0]}}(z))}for(var V=L.fold(r,function(j,$){return p.sortedSetUnion(j.knots,$)},[]),U=0,Y=r.length;U<Y;){var J=U++,q=p.sortedSetSub(V,r[J].knots);q.length==0&&(r[J]=r[J]),r[J]=_t.curveKnotRefine(r[J],q)}return r},_t.imin=function(r,s){return r<s?r:s},_t.imax=function(r,s){return r>s?r:s},_t.curveElevateDegree=function(r,s){if(s<=r.degree)return r;var o=r.knots.length-r.degree-2,l=r.degree,u=r.knots,d=r.controlPoints,g=s-r.degree,_=r.controlPoints[0].length,y=p.zeros2d(l+g+1,l+1),A=[],S=[],P=[],E=o+l+1,k=s,T=Math.floor(k/2),B=[],N=[];y[0][0]=1,y[k][l]=1;for(var R=1,z=T+1;R<z;)for(var V=R++,U=1/Ft.get(k,V),Y=_t.imin(l,V),J=_t.imax(0,V-g),q=Y+1;J<q;){var j=J++;y[V][j]=U*Ft.get(l,j)*Ft.get(g,V-j)}for(var $=T+1;$<k;)for(var tt=$++,et=_t.imin(l,tt),it=_t.imax(0,tt-g),ht=et+1;it<ht;){var at=it++;y[tt][at]=y[k-tt][l-at]}var ut=k+1,nt=-1,mt=l,K=l+1,ft=1,Et=u[0];B[0]=d[0];for(var Ht=0,$t=k+1;Ht<$t;){var Ut=Ht++;N[Ut]=Et}for(var Qt=0,Ce=l+1;Qt<Ce;){var Ze=Qt++;A[Ze]=d[Ze]}for(;K<E;){for(var we=K;K<E&&u[K]==u[K+1];)K=K+1;var ye=K-we+1,Ne=u[K],Fe=nt;nt=l-ye;var er;Fe>0?er=Math.floor((Fe+2)/2):er=1;var pr;if(nt>0?pr=Math.floor(k-(nt+1)/2):pr=k,nt>0){for(var rr=Ne-Et,nr=[],sr=l;sr>ye;)nr[sr-ye-1]=rr/(u[mt+sr]-Et),sr--;for(var vr=1,Rn=nt+1;vr<Rn;){for(var nn=vr++,pu=nt-nn,na=ye+nn,sn=l;sn>=na;)A[sn]=p.add(p.mul(nr[sn-na],A[sn]),p.mul(1-nr[sn-na],A[sn-1])),sn--;P[pu]=A[l]}}for(var Ko=er,mu=k+1;Ko<mu;){var Dn=Ko++;S[Dn]=p.zeros1d(_);for(var gu=_t.imin(l,Dn),$o=_t.imax(0,Dn-g),fu=gu+1;$o<fu;){var Zo=$o++;S[Dn]=p.add(S[Dn],p.mul(y[Dn][Zo],A[Zo]))}}if(Fe>1)for(var sa=ut-2,ia=ut,Qo=Ne-Et,_u=(Ne-N[ut-1])/Qo,Jo=1;Jo<Fe;){for(var aa=Jo++,br=sa,an=ia,Xr=an-ut+1;an-br>aa;){if(br<ft){var yu=(Ne-N[br])/(Et-N[br]);B[br]=p.lerp(yu,B[br],B[br-1])}if(an>=er){if(an-aa<=ut-k+Fe){var vu=(Ne-N[an-aa])/Qo;S[Xr]=p.lerp(vu,S[Xr],S[Xr+1])}}else S[Xr]=p.lerp(_u,S[Xr],S[Xr+1]);br=br+1,an=an-1,Xr=Xr-1}sa=sa-1,ia=ia+1}if(mt!=l)for(var tl=0,bu=k-Fe;tl<bu;)tl++,N[ut]=Et,ut=ut+1;for(var el=er,xu=pr+1;el<xu;){var wu=el++;B[ft]=S[wu],ft=ft+1}if(K<E){for(var rl=0;rl<nt;){var nl=rl++;A[nl]=P[nl]}for(var sl=nt,Au=l+1;sl<Au;){var il=sl++;A[il]=d[K-l+il]}mt=K,K=K+1,Et=Ne}else for(var al=0,Pu=k+1;al<Pu;){var Su=al++;N[ut+Su]=Ne}}return new Wt(s,N,B)},_t.rationalSurfaceTransform=function(r,s){for(var o=C.dehomogenize2d(r.controlPoints),l=0,u=o.length;l<u;)for(var d=l++,g=0,_=o[d].length;g<_;){var y=g++,A=o[d][y];A.push(1),o[d][y]=Ot.dot(s,A).slice(0,A.length-1)}return new ne(r.degreeU,r.degreeV,r.knotsU.slice(),r.knotsV.slice(),C.homogenize2d(o,C.weight2d(r.controlPoints)))},_t.rationalCurveTransform=function(r,s){for(var o=C.dehomogenize1d(r.controlPoints),l=0,u=o.length;l<u;){var d=l++,g=o[d];g.push(1),o[d]=Ot.dot(s,g).slice(0,g.length-1)}return new Wt(r.degree,r.knots.slice(),C.homogenize1d(o,C.weight1d(r.controlPoints)))},_t.surfaceKnotRefine=function(r,s,o){var l=[],u,d,g;o?(g=r.controlPoints,u=r.knotsV,d=r.degreeV):(g=Ot.transpose(r.controlPoints),u=r.knotsU,d=r.degreeU);for(var _=null,y=0;y<g.length;){var A=g[y];++y,_=_t.curveKnotRefine(new Wt(d,u,A),s),l.push(_.controlPoints)}var S=_.knots;return o?new ne(r.degreeU,r.degreeV,r.knotsU.slice(),S,l):(l=Ot.transpose(l),new ne(r.degreeU,r.degreeV,S,r.knotsV.slice(),l))},_t.decomposeCurveIntoBeziers=function(r){for(var s=r.degree,o=r.controlPoints,l=r.knots,u=bt.knotMultiplicities(l),d=s+1,g=0;g<u.length;){var _=u[g];if(++g,_.mult<d){var y=p.rep(d-_.mult,_.knot),A=_t.curveKnotRefine(new Wt(s,l,o),y);l=A.knots,o=A.controlPoints}}l.length/d-1;for(var S=d*2,P=[],E=0;E<o.length;){var k=l.slice(E,E+S),T=o.slice(E,E+d);P.push(new Wt(s,k,T)),E+=d}return P},_t.curveKnotRefine=function(r,s){if(s.length==0)return gt.clonedCurve(r);for(var o=r.degree,l=r.controlPoints,u=r.knots,d=l.length-1,g=d+o+1,_=s.length-1,y=C.knotSpan(o,s[0],u),A=C.knotSpan(o,s[_],u),S=[],P=[],E=0,k=y-o+1;E<k;){var T=E++;S[T]=l[T]}for(var B=A-1,N=d+1;B<N;){var R=B++;S[R+_+1]=l[R]}for(var z=0,V=y+1;z<V;){var U=z++;P[U]=u[U]}for(var Y=A+o,J=g+1;Y<J;){var q=Y++;P[q+_+1]=u[q]}for(var j=A+o-1,$=A+o+_,tt=_;tt>=0;){for(;s[tt]<=u[j]&&j>y;)S[$-o-1]=l[j-o-1],P[$]=u[j],$=$-1,j=j-1;S[$-o-1]=S[$-o];for(var et=1,it=o+1;et<it;){var ht=et++,at=$-o+ht,ut=P[$+ht]-s[tt];Math.abs(ut)<rt.EPSILON?S[at-1]=S[at]:(ut=ut/(P[$+ht]-u[j-o+ht]),S[at-1]=p.add(p.mul(ut,S[at-1]),p.mul(1-ut,S[at])))}P[$]=s[tt],$=$-1,tt--}return new Wt(o,P,S)},_t.curveKnotInsert=function(r,s,o){for(var l=r.degree,u=r.controlPoints,d=r.knots,g=0,_=u.length,y=C.knotSpan(l,s,d),A=[],S=[],P=[],E=1,k=y+1;E<k;){var T=E++;S[T]=d[T]}for(var B=1,N=o+1;B<N;){var R=B++;S[y+R]=s}for(var z=y+1,V=d.length;z<V;){var U=z++;S[U+o]=d[U]}for(var Y=0,J=y-l+1;Y<J;){var q=Y++;P[q]=u[q]}for(var j=y-g;j<_;){var $=j++;P[$+o]=u[$]}for(var tt=0,et=l-g+1;tt<et;){var it=tt++;A[it]=u[y-l+it]}for(var ht=0,at=0,ut=1,nt=o+1;ut<nt;){var mt=ut++;ht=y-l+mt;for(var K=0,ft=l-mt-g+1;K<ft;){var Et=K++;at=(s-d[ht+Et])/(d[Et+y+1]-d[ht+Et]),A[Et]=p.add(p.mul(at,A[Et+1]),p.mul(1-at,A[Et]))}P[ht]=A[0],P[y+o-mt-g]=A[l-mt-g]}for(var Ht=ht+1,$t=y-g;Ht<$t;){var Ut=Ht++;P[Ut]=A[Ut-ht]}return new Wt(l,S,P)};var zt=f.eval.Tess=function(){};x["verb.eval.Tess"]=zt,zt.__name__=["verb","eval","Tess"],zt.rationalCurveRegularSample=function(r,s,o){return zt.rationalCurveRegularSampleRange(r,r.knots[0],Z.last(r.knots),s,o)},zt.rationalCurveRegularSampleRange=function(r,s,o,l,u){l<1&&(l=2);for(var d=[],g=(o-s)/(l-1),_=0,y=0;y<l;){var A=y++;_=s+g*A,u?d.push([_].concat(C.rationalCurvePoint(r,_))):d.push(C.rationalCurvePoint(r,_))}return d},zt.rationalCurveAdaptiveSample=function(r,s,o){if(o==null&&(o=!1),s==null&&(s=1e-6),r.degree==1)if(o){for(var l=[],u=0,d=r.controlPoints.length;u<d;){var g=u++;l.push([r.knots[g+1]].concat(C.dehomogenize(r.controlPoints[g])))}return l}else return r.controlPoints.map(C.dehomogenize);return zt.rationalCurveAdaptiveSampleRange(r,r.knots[0],Z.last(r.knots),s,o)},zt.rationalCurveAdaptiveSampleRange=function(r,s,o,l,u){var d=C.rationalCurvePoint(r,s),g=C.rationalCurvePoint(r,o),_=.5+.2*Math.random(),y=s+(o-s)*_,A=C.rationalCurvePoint(r,y),S=p.sub(d,g),P=p.sub(d,A);if(p.dot(S,S)<l&&p.dot(P,P)>l||!Re.threePointsAreFlat(d,A,g,l)){var E=s+(o-s)*.5,k=zt.rationalCurveAdaptiveSampleRange(r,s,E,l,u),T=zt.rationalCurveAdaptiveSampleRange(r,E,o,l,u);return k.slice(0,-1).concat(T)}else return u?[[s].concat(d),[o].concat(g)]:[d,g]},zt.rationalSurfaceNaive=function(r,s,o){s<1&&(s=1),o<1&&(o=1),r.degreeU,r.degreeV,r.controlPoints;for(var l=r.knotsU,u=r.knotsV,d=Z.last(l)-l[0],g=Z.last(u)-u[0],_=d/s,y=g/o,A=[],S=[],P=[],E=0,k=s+1;E<k;)for(var T=E++,B=0,N=o+1;B<N;){var R=B++,z=T*_,V=R*y;S.push([z,V]);var U=C.rationalSurfaceDerivatives(r,z,V,1),Y=U[0][0];A.push(Y);var J=p.normalized(p.cross(U[1][0],U[0][1]));P.push(J)}for(var q=[],j=0;j<s;)for(var $=j++,tt=0;tt<o;){var et=tt++,it=$*(o+1)+et,ht=($+1)*(o+1)+et,at=ht+1,ut=it+1,nt=[it,ht,at],mt=[it,at,ut];q.push(nt),q.push(mt)}return new Qe(q,A,P,S)},zt.divideRationalSurfaceAdaptive=function(r,s){s==null&&(s=new Gr),s.minDivsU!=null?s.minDivsU=s.minDivsU:s.minDivsU=1,s.minDivsV!=null?s.minDivsU=s.minDivsV:s.minDivsU=1,s.refine!=null?s.refine=s.refine:s.refine=!0;var o=(r.controlPoints.length-1)*2,l=(r.controlPoints[0].length-1)*2,u;s.minDivsU>o?u=s.minDivsU=s.minDivsU:u=s.minDivsU=o;var d;s.minDivsV>l?d=s.minDivsV=s.minDivsV:d=s.minDivsV=l;for(var g=Z.last(r.knotsU),_=r.knotsU[0],y=Z.last(r.knotsV),A=r.knotsV[0],S=(g-_)/u,P=(y-A)/d,E=[],k=[],T=0,B=d+1;T<B;){for(var N=T++,R=[],z=0,V=u+1;z<V;){var U=z++,Y=_+S*U,J=A+P*N,q=C.rationalSurfaceDerivatives(r,Y,J,1),j=p.normalized(p.cross(q[0][1],q[1][0]));R.push(new Ke(q[0][0],j,[Y,J],-1,p.isZero(j)))}k.push(R)}for(var $=0;$<d;)for(var tt=$++,et=0;et<u;){var it=et++,ht=[k[d-tt-1][it],k[d-tt-1][it+1],k[d-tt][it+1],k[d-tt][it]];E.push(new yr(r,ht))}if(!s.refine)return E;for(var at=0;at<d;)for(var ut=at++,nt=0;nt<u;){var mt=nt++,K=ut*u+mt,ft=zt.north(K,ut,mt,u,d,E),Et=zt.east(K,ut,mt,u,d,E),Ht=zt.south(K,ut,mt,u,d,E),$t=zt.west(K,ut,mt,u,d,E);E[K].neighbors=[Ht,Et,ft,$t],E[K].divide(s)}return E},zt.north=function(r,s,o,l,u,d){return s==0?null:d[r-l]},zt.south=function(r,s,o,l,u,d){return s==u-1?null:d[r+l]},zt.east=function(r,s,o,l,u,d){return o==l-1?null:d[r+1]},zt.west=function(r,s,o,l,u,d){return o==0?null:d[r-1]},zt.triangulateAdaptiveRefinementNodeTree=function(r){for(var s=Qe.empty(),o=0;o<r.length;){var l=r[o];++o,l.triangulate(s)}return s},zt.rationalSurfaceAdaptive=function(r,s){s!=null?s=s:s=new Gr;var o=zt.divideRationalSurfaceAdaptive(r,s);return zt.triangulateAdaptiveRefinementNodeTree(o)};var Gr=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"]=Gr,Gr.__name__=["verb","eval","AdaptiveRefinementOptions"],Gr.prototype={__class__:Gr};var yr=f.core.AdaptiveRefinementNode=function(r,s,o){if(this.srf=r,o==null?this.neighbors=[null,null,null,null]:this.neighbors=o,this.corners=s,this.corners==null){var l=r.knotsU[0],u=Z.last(r.knotsU),d=r.knotsV[0],g=Z.last(r.knotsV);this.corners=[Ke.fromUv(l,d),Ke.fromUv(u,d),Ke.fromUv(u,g),Ke.fromUv(l,g)]}};x["verb.eval.AdaptiveRefinementNode"]=yr,yr.__name__=["verb","eval","AdaptiveRefinementNode"],yr.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 s=r++;if(this.corners[s].point==null){var o=this.corners[s];this.evalSrf(o.uv[0],o.uv[1],o)}}},evalSrf:function(r,s,o){var l=C.rationalSurfaceDerivatives(this.srf,r,s,1),u=l[0][0],d=p.cross(l[0][1],l[1][0]),g=p.isZero(d);return g||(d=p.normalized(d)),o!=null?(o.degen=g,o.point=u,o.normal=d,o):new Ke(u,d,[r,s],-1,g)},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 s=[this.corners[r]];if(this.neighbors[r]==null)return s;var o=this.neighbors[r].getEdgeCorners((r+2)%4),l=r%2,u=rt.EPSILON,d=this,g=[function(y){return y.uv[0]>d.corners[0].uv[0]+u&&y.uv[0]<d.corners[2].uv[0]-u},function(y){return y.uv[1]>d.corners[0].uv[1]+u&&y.uv[1]<d.corners[2].uv[1]-u}],_=o.filter(g[l]);return _.reverse(),s.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,s=0;s<r;){var o=s++;if(this.corners[o],this.corners[o].degen){var l=this.corners[(o+1)%r],u=this.corners[(o+3)%r];l.degen?this.corners[o].normal=u.normal:this.corners[o].normal=l.normal}}},shouldDivide:function(r,s){if(s<r.minDepth)return!0;if(s>=r.maxDepth)return!1;if(this.hasBadNormals())return this.fixNormals(),!1;if(this.splitVert=p.normSquared(p.sub(this.corners[0].normal,this.corners[1].normal))>r.normTol||p.normSquared(p.sub(this.corners[2].normal,this.corners[3].normal))>r.normTol,this.splitHoriz=p.normSquared(p.sub(this.corners[1].normal,this.corners[2].normal))>r.normTol||p.normSquared(p.sub(this.corners[3].normal,this.corners[0].normal))>r.normTol,this.splitVert||this.splitHoriz)return!0;var o=this.center();return p.normSquared(p.sub(o.normal,this.corners[0].normal))>r.normTol||p.normSquared(p.sub(o.normal,this.corners[1].normal))>r.normTol||p.normSquared(p.sub(o.normal,this.corners[2].normal))>r.normTol||p.normSquared(p.sub(o.normal,this.corners[3].normal))>r.normTol},divide:function(r){r==null&&(r=new Gr),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,s,o){if(this.evalCorners(),!!this.shouldDivide(r,s)){if(s++,this.splitVert&&!this.splitHoriz?o=!1:!this.splitVert&&this.splitHoriz&&(o=!0),this.horizontal=o,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 yr(this.srf,l),new yr(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]],g=[this.midpoint(0),this.corners[1],this.corners[2],this.midpoint(2)];this.children=[new yr(this.srf,d),new yr(this.srf,g)],this.children[0].neighbors=[this.neighbors[0],this.children[1],this.neighbors[2],this.neighbors[3]],this.children[1].neighbors=[this.neighbors[0],this.neighbors[1],this.neighbors[2],this.children[0]]}for(var _=0,y=this.children;_<y.length;){var A=y[_];++_,A._divide(r,s,!o)}}},triangulate:function(r){if(r==null&&(r=Qe.empty()),this.isLeaf())return this.triangulateLeaf(r);for(var s=0,o=this.children;s<o.length;){var l=o[s];if(++s,l==null)break;l.triangulate(r)}return r},triangulateLeaf:function(r){for(var s=r.points.length,o=[],l=[],u=0,d=0;d<4;){var g=d++,_=this.getAllCorners(g);_.length==2&&(u=g+1);for(var y=0,A=_.length;y<A;){var S=y++;o.push(_[S])}}for(var P=0;P<o.length;){var E=o[P];if(++P,E.id!=-1){l.push(E.id);continue}r.uvs.push(E.uv),r.points.push(E.point),r.normals.push(E.normal),E.id=s,l.push(s),s++}if(o.length==4)return r.faces.push([l[0],l[3],l[1]]),r.faces.push([l[3],l[2],l[1]]),r;if(o.length==5){var k=l.length;return r.faces.push([l[u],l[(u+2)%k],l[(u+1)%k]]),r.faces.push([l[(u+4)%k],l[(u+3)%k],l[u]]),r.faces.push([l[u],l[(u+3)%k],l[(u+2)%k]]),r}var T=this.center();r.uvs.push(T.uv),r.points.push(T.point),r.normals.push(T.normal);for(var B=r.points.length-1,N=0,R=o.length-1;N<o.length;)r.faces.push([B,l[N],l[R]]),R=N++;return r},__class__:yr};var At=f.exe.Dispatcher=function(){};x["verb.exe.Dispatcher"]=At,At.__name__=["verb","exe","Dispatcher"],At.init=function(){At._init||(At._workerPool=new Wr(At.THREADS),At._init=!0)},At.dispatchMethod=function(r,s,o){At.init();var l=new In,u=function(d){l.resolve(d)};return At._workerPool.addWork(ct.getClassName(r),s,o,u),new _e(l)};var Wr=f.exe.WorkerPool=function(r,s){s==null&&(s="verb.js"),r==null&&(r=1),this._callbacks=new wt,this._working=new wt,this._pool=[],this._queue=[];for(var o=0;o<r;){o++;var l;try{l=new Worker(Wr.basePath+s)}catch(u){u instanceof Q&&(u=u.val),l=new Worker(Wr.basePath+s.substring(0,-3)+".min.js")}this._pool.push(l)}};x["verb.exe.WorkerPool"]=Wr,Wr.__name__=["verb","exe","WorkerPool"],Wr.prototype={addWork:function(r,s,o,l){var u=new rn(r,s,o);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 s=this._queue.shift(),o=[s.id],l=[this._pool.shift()];this._working.h[o[0]]=l[0],l[0].onmessage=function(u,d){return function(g){r._working.remove(d[0]),r._pool.push(u[0]);try{r._callbacks.h.hasOwnProperty(d[0])&&(r._callbacks.h[d[0]](g.data.result),r._callbacks.remove(d[0]))}catch(_){_ instanceof Q&&(_=_.val),b.log(_)}r.processQueue()}}(l,o),l[0].postMessage(s)}},__class__:Wr};var rn=function(r,s,o){this.className=r,this.methodName=s,this.args=o,this.id=rn.uuid++};x["verb.exe._WorkerPool.Work"]=rn,rn.__name__=["verb","exe","_WorkerPool","Work"],rn.prototype={__class__:rn};var Bn=function(){};x["verb.geom.ICurve"]=Bn,Bn.__name__=["verb","geom","ICurve"],Bn.__interfaces__=[Nn],Bn.prototype={__class__:Bn};var Lt=f.geom.NurbsCurve=function(r){this._data=$e.isValidNurbsCurveData(r)};x["verb.geom.NurbsCurve"]=Lt,Lt.__name__=["verb","geom","NurbsCurve"],Lt.__interfaces__=[Bn],Lt.byKnotsControlPointsWeights=function(r,s,o,l){return new Lt(new Wt(r,s.slice(),C.homogenize1d(o,l)))},Lt.byPoints=function(r,s){return s==null&&(s=3),new Lt(gt.rationalInterpCurve(r,s))},Lt.__super__=te,Lt.prototype=M(te.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 Wt(this.degree(),this.knots(),C.homogenize1d(this.controlPoints(),this.weights()))},clone:function(){return new Lt(this._data)},domain:function(){return new Te(Z.first(this._data.knots),Z.last(this._data.knots))},transform:function(r){return new Lt(_t.rationalCurveTransform(this._data,r))},transformAsync:function(r){return At.dispatchMethod(_t,"rationalCurveTransform",[this._data,r]).then(function(s){return new Lt(s)})},point:function(r){return C.rationalCurvePoint(this._data,r)},pointAsync:function(r){return At.dispatchMethod(C,"rationalCurvePoint",[this._data,r])},tangent:function(r){return C.rationalCurveTangent(this._data,r)},tangentAsync:function(r){return At.dispatchMethod(C,"rationalCurveTangent",[this._data,r])},derivatives:function(r,s){return s==null&&(s=1),C.rationalCurveDerivatives(this._data,r,s)},derivativesAsync:function(r,s){return s==null&&(s=1),At.dispatchMethod(C,"rationalCurveDerivatives",[this._data,r,s])},closestPoint:function(r){return bt.rationalCurveClosestPoint(this._data,r)},closestPointAsync:function(r){return At.dispatchMethod(bt,"rationalCurveClosestPoint",[this._data,r])},closestParam:function(r){return bt.rationalCurveClosestParam(this._data,r)},closestParamAsync:function(r){return At.dispatchMethod(bt,"rationalCurveClosestParam",[this._data,r])},length:function(){return bt.rationalCurveArcLength(this._data)},lengthAsync:function(){return At.dispatchMethod(bt,"rationalCurveArcLength",[this._data])},lengthAtParam:function(r){return bt.rationalCurveArcLength(this._data,r)},lengthAtParamAsync:function(){return At.dispatchMethod(bt,"rationalCurveArcLength",[this._data])},paramAtLength:function(r,s){return bt.rationalCurveParamAtArcLength(this._data,r,s)},paramAtLengthAsync:function(r,s){return At.dispatchMethod(bt,"rationalCurveParamAtArcLength",[this._data,r,s])},divideByEqualArcLength:function(r){return ue.rationalCurveByEqualArcLength(this._data,r)},divideByEqualArcLengthAsync:function(r){return At.dispatchMethod(ue,"rationalCurveByEqualArcLength",[this._data,r])},divideByArcLength:function(r){return ue.rationalCurveByArcLength(this._data,r)},divideByArcLengthAsync:function(r){return At.dispatchMethod(ue,"rationalCurveByArcLength",[this._data,r])},split:function(r){return ue.curveSplit(this._data,r).map(function(s){return new Lt(s)})},splitAsync:function(r){return At.dispatchMethod(ue,"curveSplit",[this._data,r]).then(function(s){return s.map(function(o){return new Lt(o)})})},reverse:function(){return new Lt(_t.curveReverse(this._data))},reverseAsync:function(){return At.dispatchMethod(_t,"curveReverse",[this._data]).then(function(r){return new Lt(r)})},tessellate:function(r){return zt.rationalCurveAdaptiveSample(this._data,r,!1)},tessellateAsync:function(r){return At.dispatchMethod(zt,"rationalCurveAdaptiveSample",[this._data,r,!1])},__class__:Lt});var Hr=f.geom.Arc=function(r,s,o,l,u,d){Lt.call(this,gt.arc(r,s,o,l,u,d)),this._center=r,this._xaxis=s,this._yaxis=o,this._radius=l,this._minAngle=u,this._maxAngle=d};x["verb.geom.Arc"]=Hr,Hr.__name__=["verb","geom","Arc"],Hr.__super__=Lt,Hr.prototype=M(Lt.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__:Hr});var cs=f.geom.BezierCurve=function(r,s){Lt.call(this,gt.rationalBezierCurve(r,s))};x["verb.geom.BezierCurve"]=cs,cs.__name__=["verb","geom","BezierCurve"],cs.__super__=Lt,cs.prototype=M(Lt.prototype,{__class__:cs});var us=f.geom.Circle=function(r,s,o,l){Hr.call(this,r,s,o,l,0,Math.PI*2)};x["verb.geom.Circle"]=us,us.__name__=["verb","geom","Circle"],us.__super__=Hr,us.prototype=M(Hr.prototype,{__class__:us});var zn=function(){};x["verb.geom.ISurface"]=zn,zn.__name__=["verb","geom","ISurface"],zn.__interfaces__=[Nn],zn.prototype={__class__:zn};var Mt=f.geom.NurbsSurface=function(r){this._data=$e.isValidNurbsSurfaceData(r)};x["verb.geom.NurbsSurface"]=Mt,Mt.__name__=["verb","geom","NurbsSurface"],Mt.__interfaces__=[zn],Mt.byKnotsControlPointsWeights=function(r,s,o,l,u,d){return new Mt(new ne(r,s,o,l,C.homogenize2d(u,d)))},Mt.byCorners=function(r,s,o,l){return new Mt(gt.fourPointSurface(r,s,o,l))},Mt.byLoftingCurves=function(r,s){return new Mt(gt.loftedSurface(function(o){for(var l,u=[],d=0;d<r.length;){var g=r[d];++d,u.push(g.asNurbs())}return l=u,l}(),s))},Mt.__super__=te,Mt.prototype=M(te.prototype,{degreeU:function(){return this._data.degreeU},degreeV:function(){return this._data.degreeV},knotsU:function(){return this._data.knotsU.slice(0)},knotsV:function(){return this._data.knotsV.slice(0)},controlPoints:function(){return C.dehomogenize2d(this._data.controlPoints)},weights:function(){return C.weight2d(this._data.controlPoints)},asNurbs:function(){return new ne(this.degreeU(),this.degreeV(),this.knotsU(),this.knotsV(),C.homogenize2d(this.controlPoints(),this.weights()))},clone:function(){return new Mt(this.asNurbs())},domainU:function(){return new Te(Z.first(this._data.knotsU),Z.last(this._data.knotsU))},domainV:function(){return new Te(Z.first(this._data.knotsV),Z.last(this._data.knotsV))},point:function(r,s){return C.rationalSurfacePoint(this._data,r,s)},pointAsync:function(r,s){return At.dispatchMethod(C,"rationalSurfacePoint",[this._data,r,s])},normal:function(r,s){return C.rationalSurfaceNormal(this._data,r,s)},normalAsync:function(r,s){return At.dispatchMethod(C,"rationalSurfaceNormal",[this._data,r,s])},derivatives:function(r,s,o){return o==null&&(o=1),C.rationalSurfaceDerivatives(this._data,r,s,o)},derivativesAsync:function(r,s,o){return o==null&&(o=1),At.dispatchMethod(C,"rationalSurfaceDerivatives",[this._data,r,s,o])},closestParam:function(r){return bt.rationalSurfaceClosestParam(this._data,r)},closestParamAsync:function(r){return At.dispatchMethod(bt,"rationalSurfaceClosestParam",[this._data,r])},closestPoint:function(r){return bt.rationalSurfaceClosestPoint(this._data,r)},closestPointAsync:function(r){return At.dispatchMethod(bt,"rationalSurfaceClosestPoint",[this._data,r])},split:function(r,s){return s==null&&(s=!1),ue.surfaceSplit(this._data,r,s).map(function(o){return new Mt(o)})},splitAsync:function(r,s){return s==null&&(s=!1),At.dispatchMethod(ue,"surfaceSplit",[this._data,r,s]).then(function(o){return o.map(function(l){return new Mt(l)})})},reverse:function(r){return r==null&&(r=!1),new Mt(_t.surfaceReverse(this._data,r))},reverseAsync:function(r){return r==null&&(r=!1),At.dispatchMethod(_t,"surfaceReverse",[this._data,r]).then(function(s){return new Mt(s)})},isocurve:function(r,s){return s==null&&(s=!1),new Lt(gt.surfaceIsocurve(this._data,r,s))},isocurveAsync:function(r,s){return s==null&&(s=!1),At.dispatchMethod(gt,"surfaceIsocurve",[this._data,r,s]).then(function(o){return new Lt(o)})},boundaries:function(r){return gt.surfaceBoundaryCurves(this._data).map(function(s){return new Lt(s)})},boundariesAsync:function(r){return At.dispatchMethod(gt,"surfaceBoundaryCurves",[this._data]).then(function(s){return s.map(function(o){return new Lt(o)})})},tessellate:function(r){return zt.rationalSurfaceAdaptive(this._data,r)},tessellateAsync:function(r){return At.dispatchMethod(zt,"rationalSurfaceAdaptive",[this._data,r])},transform:function(r){return new Mt(_t.rationalSurfaceTransform(this._data,r))},transformAsync:function(r){return At.dispatchMethod(_t,"rationalSurfaceTransform",[this._data,r]).then(function(s){return new Mt(s)})},__class__:Mt});var ds=f.geom.ConicalSurface=function(r,s,o,l,u){Mt.call(this,gt.conicalSurface(r,s,o,l,u)),this._axis=r,this._xaxis=s,this._base=o,this._height=l,this._radius=u};x["verb.geom.ConicalSurface"]=ds,ds.__name__=["verb","geom","ConicalSurface"],ds.__super__=Mt,ds.prototype=M(Mt.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__:ds});var ps=f.geom.CylindricalSurface=function(r,s,o,l,u){Mt.call(this,gt.cylindricalSurface(r,s,o,l,u)),this._axis=r,this._xaxis=s,this._base=o,this._height=l,this._radius=u};x["verb.geom.CylindricalSurface"]=ps,ps.__name__=["verb","geom","CylindricalSurface"],ps.__super__=Mt,ps.prototype=M(Mt.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__:ps});var qr=f.geom.EllipseArc=function(r,s,o,l,u){Lt.call(this,gt.ellipseArc(r,s,o,l,u)),this._center=r,this._xaxis=s,this._yaxis=o,this._minAngle=l,this._maxAngle=u};x["verb.geom.EllipseArc"]=qr,qr.__name__=["verb","geom","EllipseArc"],qr.__super__=Lt,qr.prototype=M(Lt.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__:qr});var ms=f.geom.Ellipse=function(r,s,o){qr.call(this,r,s,o,0,Math.PI*2)};x["verb.geom.Ellipse"]=ms,ms.__name__=["verb","geom","Ellipse"],ms.__super__=qr,ms.prototype=M(qr.prototype,{__class__:ms});var gs=f.geom.ExtrudedSurface=function(r,s){Mt.call(this,gt.extrudedSurface(p.normalized(s),p.norm(s),r.asNurbs())),this._profile=r,this._direction=s};x["verb.geom.ExtrudedSurface"]=gs,gs.__name__=["verb","geom","ExtrudedSurface"],gs.__super__=Mt,gs.prototype=M(Mt.prototype,{profile:function(){return this._profile},direction:function(){return this._direction},__class__:gs});var Yr=f.geom.Intersect=function(){};x["verb.geom.Intersect"]=Yr,Yr.__name__=["verb","geom","Intersect"],Yr.curves=function(r,s,o){return o==null&&(o=.001),lt.curves(r.asNurbs(),s.asNurbs(),o)},Yr.curvesAsync=function(r,s,o){return o==null&&(o=.001),At.dispatchMethod(lt,"curves",[r.asNurbs(),s.asNurbs(),o])},Yr.curveAndSurface=function(r,s,o){return o==null&&(o=.001),lt.curveAndSurface(r.asNurbs(),s.asNurbs(),o)},Yr.curveAndSurfaceAsync=function(r,s,o){return o==null&&(o=.001),At.dispatchMethod(lt,"curveAndSurface",[r.asNurbs(),s.asNurbs(),o])},Yr.surfaces=function(r,s,o){return o==null&&(o=.001),lt.surfaces(r.asNurbs(),s.asNurbs(),o).map(function(l){return new Lt(l)})},Yr.surfacesAsync=function(r,s,o){return o==null&&(o=.001),At.dispatchMethod(lt,"surfaces",[r.asNurbs(),s.asNurbs(),o]).then(function(l){return l.map(function(u){return new Lt(u)})})};var fs=f.geom.Line=function(r,s){Lt.call(this,gt.polyline([r,s])),this._start=r,this._end=s};x["verb.geom.Line"]=fs,fs.__name__=["verb","geom","Line"],fs.__super__=Lt,fs.prototype=M(Lt.prototype,{start:function(){return this._start},end:function(){return this._end},__class__:fs});var _s=f.geom.RevolvedSurface=function(r,s,o,l){Mt.call(this,gt.revolvedSurface(r.asNurbs(),s,o,l)),this._profile=r,this._center=s,this._axis=o,this._angle=l};x["verb.geom.RevolvedSurface"]=_s,_s.__name__=["verb","geom","RevolvedSurface"],_s.__super__=Mt,_s.prototype=M(Mt.prototype,{profile:function(){return this._profile},center:function(){return this._center},axis:function(){return this._center},angle:function(){return this._angle},__class__:_s});var ys=f.geom.SphericalSurface=function(r,s){Mt.call(this,gt.sphericalSurface(r,[0,0,1],[1,0,0],s)),this._center=r,this._radius=s};x["verb.geom.SphericalSurface"]=ys,ys.__name__=["verb","geom","SphericalSurface"],ys.__super__=Mt,ys.prototype=M(Mt.prototype,{center:function(){return this._center},radius:function(){return this._radius},__class__:ys});var vs=f.geom.SweptSurface=function(r,s){Mt.call(this,gt.rationalTranslationalSurface(r.asNurbs(),s.asNurbs())),this._profile=r,this._rail=s};x["verb.geom.SweptSurface"]=vs,vs.__name__=["verb","geom","SweptSurface"],vs.__super__=Mt,vs.prototype=M(Mt.prototype,{profile:function(){return this._profile},rail:function(){return this._rail},__class__:vs});function tr(r){return r instanceof Array?function(){return O.iter(r)}:typeof r.iterator=="function"?De(r,r.iterator):r.iterator}var ta,cu=0;function De(r,s){if(s==null)return null;s.__id__==null&&(s.__id__=cu++);var o;return r.hx__closures__==null?r.hx__closures__={}:o=r.hx__closures__[s.__id__],o==null&&(o=function(){return o.method.apply(o.scope,arguments)},o.scope=r,o.method=s,r.hx__closures__[s.__id__]=o),o}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 uu=x.Int={__name__:["Int"]},du=x.Dynamic={__name__:["Dynamic"]},Ho=x.Float=Number;Ho.__name__=["Float"];var qo=x.Bool=Boolean;qo.__ename__=["Bool"];var Yo=x.Class={__name__:["Class"]},Xo={};Array.prototype.map==null&&(Array.prototype.map=function(r){for(var s=[],o=0,l=this.length;o<l;){var u=o++;s[u]=r(this[u])}return s}),Array.prototype.filter==null&&(Array.prototype.filter=function(r){for(var s=[],o=0,l=this.length;o<l;){var u=o++,d=this[u];r(d)&&s.push(d)}return s});var ea={},ri=w.ArrayBuffer||ce;ri.prototype.slice==null&&(ri.prototype.slice=ce.sliceImpl),w.DataView;var ra=w.Uint8Array||hr._new;(function(r,s){if(r.setImmediate)return;var o=1,l={},u=!1,d=r.document,g;function _(z){return l[o]=y.apply(s,z),o++}function y(z){var V=[].slice.call(arguments,1);return function(){typeof z=="function"?z.apply(s,V):new Function(""+z)()}}function A(z){if(u)setTimeout(y(A,z),0);else{var V=l[z];if(V){u=!0;try{V()}finally{S(z),u=!1}}}}function S(z){delete l[z]}function P(){g=function(){var z=_(arguments);return process.nextTick(y(A,z)),z}}function E(){if(r.postMessage&&!r.importScripts){var z=!0,V=r.onmessage;return r.onmessage=function(){z=!1},r.postMessage("","*"),r.onmessage=V,z}}function k(){var z="setImmediate$"+Math.random()+"$",V=function(U){U.source===r&&typeof U.data=="string"&&U.data.indexOf(z)===0&&A(+U.data.slice(z.length))};r.addEventListener?r.addEventListener("message",V,!1):r.attachEvent("onmessage",V),g=function(){var U=_(arguments);return r.postMessage(z+U,"*"),U}}function T(){var z=new MessageChannel;z.port1.onmessage=function(V){var U=V.data;A(U)},g=function(){var V=_(arguments);return z.port2.postMessage(V),V}}function B(){var z=d.documentElement;g=function(){var V=_(arguments),U=d.createElement("script");return U.onreadystatechange=function(){A(V),U.onreadystatechange=null,z.removeChild(U),U=null},z.appendChild(U),V}}function N(){g=function(){var z=_(arguments);return setTimeout(y(A,z),0),z}}var R=Object.getPrototypeOf&&Object.getPrototypeOf(r);R=R&&R.setTimeout?R:r,{}.toString.call(r.process)==="[object process]"?P():E()?k():r.MessageChannel?T():d&&"onreadystatechange"in d.createElement("script")?B():N(),R.setImmediate=g,R.clearImmediate=S})(new Function("return this")()),Kt.USE_CACHE=!1,Kt.USE_ENUM_INDEX=!1,Kt.BASE64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:",qt.DEFAULT_RESOLVER=ct,qt.BASE64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:",Bt.count=0,he.i64tmp=function(r){var s,o=new Gt(0,0);return s=o,s}(),Nt.__toStr={}.toString,hr.BYTES_PER_ELEMENT=1,It.queue=new F,Ft.memo=new wt,rt.TOLERANCE=1e-6,rt.EPSILON=1e-10,rt.VERSION="2.0.0",bt.Tvalues=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],bt.Cvalues=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],At.THREADS=1,At._init=!1,Wr.basePath="",rn.uuid=0,ti.main()}(typeof console<"u"?console:{log:function(){}},e,typeof c<"u"?c:typeof n<"u"?n:typeof self<"u"?self:this),e})})(_h);var Yu=_h.exports;const Vn=qu(Yu);class da{constructor(){this.c0=0,this.c1=0,this.c2=0,this.c3=0}init(t,e,n,a){this.c0=t,this.c1=n,this.c2=-3*t+3*e-2*n-a,this.c3=2*t-2*e+n+a}initCatmullRom(t,e,n,a,h){this.init(e,n,h*(n-t),h*(a-e))}initNonuniformCatmullRom(t,e,n,a,h,c,m){let b=(e-t)/h-(n-t)/(h+c)+(n-e)/c,f=(n-e)/c-(a-e)/(c+m)+(a-n)/m;b*=c,f*=c,this.init(e,n,b,f)}calc(t){const e=t*t,n=e*t;return this.c0+this.c1*t+this.c2*e+this.c3*n}}let yh=class extends Qs{constructor(t=[],e=!1,n="centripetal",a=.5){super(),this.isCatmullRomCurve3d=!0,this.type="CatmullRomCurve3d",this._tmp=new X,this._px=new da,this._py=new da,this._pz=new da,this._points=t.map(h=>new G(h)),this._closed=e,this._curveType=n,this._tension=a}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 G}get endPoint(){return this._points.length>0?this._points[this._points.length-1]:new G}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 G){const n=e,a=this._points,h=a.length;if(h===0)return n.set(0,0,0);if(h===1)return n.copy(a[0]);const c=(h-(this._closed?0:1))*t;let m=Math.floor(c),b=c-m;this._closed?m+=m>0?0:(Math.floor(Math.abs(m)/h)+1)*h:b===0&&m===h-1&&(m=h-2,b=1);let f,w;this._closed||m>0?f=a[(m-1)%h]:(this._tmp.subVectors(a[0],a[1]).add(a[0]),f=new G(this._tmp.x,this._tmp.y,this._tmp.z));const x=a[m%h],I=a[(m+1)%h];if(this._closed||m+2<h?w=a[(m+2)%h]:(this._tmp.subVectors(a[h-1],a[h-2]).add(a[h-1]),w=new G(this._tmp.x,this._tmp.y,this._tmp.z)),this._curveType==="centripetal"||this._curveType==="chordal"){const M=this._curveType==="chordal"?.5:.25;let O=Math.pow(f.distanceToSquared(x),M),L=Math.pow(x.distanceToSquared(I),M),F=Math.pow(I.distanceToSquared(w),M);L<1e-4&&(L=1),O<1e-4&&(O=L),F<1e-4&&(F=L),this._px.initNonuniformCatmullRom(f.x,x.x,I.x,w.x,O,L,F),this._py.initNonuniformCatmullRom(f.y,x.y,I.y,w.y,O,L,F),this._pz.initNonuniformCatmullRom(f.z,x.z,I.z,w.z,O,L,F)}else this._curveType==="catmullrom"&&(this._px.initCatmullRom(f.x,x.x,I.x,w.x,this._tension),this._py.initCatmullRom(f.y,x.y,I.y,w.y,this._tension),this._pz.initCatmullRom(f.z,x.z,I.z,w.z,this._tension));return n.set(this._px.calc(b),this._py.calc(b),this._pz.calc(b)),n}getPoints(t){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}setPoints(t){this._points=t.map(e=>new G(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 n=new G;return n.copy(e),n.applyMatrix4(t),n}),this._boundingBoxNeedsUpdate=!0,this}calculateBoundingBox(){if(this._points.length===0)return new Ct;const t=new Ct;return this._points.forEach(e=>{t.expandByPoint(e)}),t}};class bn{constructor(t,e,n,a){this._degree=t,this._knots=[...e],this._controlPoints=n.map(h=>({x:h.x,y:h.y,z:h.z})),this._weights=a?[...a]:new Array(n.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(n=>[n.x,n.y,n.z]);return Vs(t,this._degree,this._knots,e,this._weights)}length(){const t=this._controlPoints.map(e=>[e.x,e.y,e.z]);return ch(this._degree,this._knots,t,this._weights)}static byKnotsControlPointsWeights(t,e,n,a){return new bn(t,e,n,a)}static byPoints(t,e,n="Uniform"){let a;switch(n){case"Chord":a=lh(e,t);break;case"SqrtChord":a=hh(e,t);break;case"Uniform":default:a=oh(e,t.length);break}const h=t.map(m=>({x:m[0],y:m[1],z:m[2]})),c=new Array(h.length).fill(1);return new bn(e,a,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:n,end:a}=this.getParameterRange();for(let h=0;h<=t;h++){const c=n+(a-n)*(h/t);e.push(this.point(c))}return e}isClosed(t=1e-6){const{start:e,end:n}=this.getParameterRange(),a=this.point(e),h=this.point(n),c=a[0]-h[0],m=a[1]-h[1],b=a[2]-h[2];return Math.sqrt(c*c+m*m+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 yh(t,!0,"centripetal"),n=Math.max(50,t.length*2);return e.getPoints(n)}static createClosedCurve(t,e,n="Chord"){const a=this.createFitPointsForClosedCurve(t).map(h=>[h.x,h.y,h.z]);return bn.byPoints(a,e,n)}}class Jr extends Qs{constructor(t,e,n,a,h){super();const c=arguments.length;if(c<2||c>5)throw Xe.ILLEGAL_PARAMETERS;if(this._degree=3,this._closed=!1,Array.isArray(e)){this._controlPoints=t;let m,b=3,f=!1;if(c>=3&&(Array.isArray(n)?(m=n,c>=4&&(b=a||3),c>=5&&(f=h)):n!==void 0&&(b=n||3,c>=4&&(f=a))),n===void 0&&c>=4&&(b=a||3,c>=5&&(f=h)),this._degree=b,this._closed=f,this._controlPoints.length<this._degree+1)throw Xe.ILLEGAL_PARAMETERS;const w=this.toVerbPoints(this._controlPoints);this._nurbsCurve=Vn.geom.NurbsCurve.byKnotsControlPointsWeights(this._degree,e,w,m)}else{if(this._fitPoints=t,this._knotParameterization=e,c>=3&&(this._degree=n||3),c>=4&&(this._closed=a),this._fitPoints.length<this._degree+1)throw Xe.ILLEGAL_PARAMETERS;const m=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=Vn.geom.NurbsCurve.byPoints(m,this._degree),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}}buildCurve(){if(this._fitPoints&&this._knotParameterization){if(this._closed){const t=bn.createFitPointsForClosedCurve(this._fitPoints),e=this.toNurbsPoints(t);this._nurbsCurve=Vn.geom.NurbsCurve.byPoints(e,this._degree)}else{const t=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=Vn.geom.NurbsCurve.byPoints(t,this._degree)}this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}else if(this._controlPoints)if(this._closed){const t=bn.createFitPointsForClosedCurve(this._controlPoints),e=this.toNurbsPoints(t);this._nurbsCurve=Vn.geom.NurbsCurve.byPoints(e,this._degree),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}else{const t=this._nurbsCurve.knots(),e=this._nurbsCurve.weights(),n=this.toVerbPoints(this._controlPoints);this._nurbsCurve=Vn.geom.NurbsCurve.byKnotsControlPointsWeights(this._degree,t,n,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(),n=t[e],a=this._nurbsCurve.point(n);return new G(a[0],a[1],a[2])}get endPoint(){const t=this._nurbsCurve.knots(),e=this._nurbsCurve.degree(),n=t[t.length-e-1],a=this._nurbsCurve.point(n);return new G(a[0],a[1],a[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,n=t<0||t>=e?e-1:t,a=this._fitPoints[n];return{x:a.x,y:a.y,z:a.z||0}}getControlPointAt(t){const e=this._controlPoints.length,n=t<0||t>=e?e-1:t;return this._controlPoints[n]}getPoints(t=100){const e=this._nurbsCurve,n=[],a=e.knots(),h=this._nurbsCurve.degree(),c=a[h],m=a[a.length-h-1],b=(m-c)/(t-1);for(let f=0;f<t;f++){const w=f===t-1?m:c+f*b,x=e.point(w);n.push(new G(x[0],x[1],x[2]))}return n}getCurvePoints(t,e){const n=[],a=t.knots(),h=a[3],c=(a[a.length-4]-h)/(e-1);for(let m=0;m<e;m++){const b=h+m*c;n.push(t.point(b))}return n}calculateBoundingBox(){const t=this.getPoints(100);return new Ct().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((n,a)=>{e[a]=[n.x,n.y,n.z||0]}),e}toVerbPoints(t){const e=new Array(t.length);return t.forEach((n,a)=>{e[a]=[n.x,n.y,n.z||0]}),e}toGePoints(t){const e=new Array(t.length);return t.forEach((n,a)=>{e[a]={x:n[0],y:n[1],z:n[2]}}),e}static createClosedSpline(t,e="Uniform",n=3){if(t.length<n+1)throw new Error(`At least ${n+1} points are required for a degree ${n} closed spline`);return new Jr(t,e,n,!0)}}var $a=(i=>(i.ClosedFilled="",i.Dot="_DOT",i.DotSmall="_DOTSMALL",i.DotBlank="_DOTBLANK",i.Origin="_ORIGIN",i.Origin2="_ORIGIN2",i.Open="_OPEN",i.Open90="_OPEN90",i.Open30="_OPEN30",i.Closed="_CLOSED",i.Small="_SMALL",i.None="_NONE",i.Oblique="_OBLIQUE",i.BoxFilled="_BOXFILLED",i.Box="_BOXBLANK",i.ClosedBlank="_CLOSEDBLANK",i.DatumBlank="_DATUMBLANK",i.DatumFilled="_DATUMFILLED",i.Integral="_INTEGRAL",i.ArchTick="_ARCHTICK",i))($a||{}),Ki=(i=>(i[i.ByBlock=-2]="ByBlock",i[i.ByDIPs=-4]="ByDIPs",i[i.ByLayer=-1]="ByLayer",i[i.ByLineWeightDefault=-3]="ByLineWeightDefault",i[i.LineWeight000=0]="LineWeight000",i[i.LineWeight005=5]="LineWeight005",i[i.LineWeight009=9]="LineWeight009",i[i.LineWeight013=13]="LineWeight013",i[i.LineWeight015=15]="LineWeight015",i[i.LineWeight018=18]="LineWeight018",i[i.LineWeight020=20]="LineWeight020",i[i.LineWeight025=25]="LineWeight025",i[i.LineWeight030=30]="LineWeight030",i[i.LineWeight035=35]="LineWeight035",i[i.LineWeight040=40]="LineWeight040",i[i.LineWeight050=50]="LineWeight050",i[i.LineWeight053=53]="LineWeight053",i[i.LineWeight060=60]="LineWeight060",i[i.LineWeight070=70]="LineWeight070",i[i.LineWeight080=80]="LineWeight080",i[i.LineWeight090=90]="LineWeight090",i[i.LineWeight100=100]="LineWeight100",i[i.LineWeight106=106]="LineWeight106",i[i.LineWeight120=120]="LineWeight120",i[i.LineWeight140=140]="LineWeight140",i[i.LineWeight158=158]="LineWeight158",i[i.LineWeight200=200]="LineWeight200",i[i.LineWeight211=211]="LineWeight211",i))(Ki||{}),zr=(i=>(i[i.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",i[i.RIGHT_TO_LEFT=2]="RIGHT_TO_LEFT",i[i.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",i[i.BOTTOM_TO_TOP=4]="BOTTOM_TO_TOP",i[i.BY_STYLE=5]="BY_STYLE",i))(zr||{}),be=(i=>(i[i.TopLeft=1]="TopLeft",i[i.TopCenter=2]="TopCenter",i[i.TopRight=3]="TopRight",i[i.MiddleLeft=4]="MiddleLeft",i[i.MiddleCenter=5]="MiddleCenter",i[i.MiddleRight=6]="MiddleRight",i[i.BottomLeft=7]="BottomLeft",i[i.BottomCenter=8]="BottomCenter",i[i.BottomRight=9]="BottomRight",i))(be||{}),Za=(i=>(i[i.OPTIMIZED_2D=0]="OPTIMIZED_2D",i[i.WIREFRAME=1]="WIREFRAME",i[i.HIDDEN_LINE=2]="HIDDEN_LINE",i[i.FLAT_SHADED=3]="FLAT_SHADED",i[i.GOURAUD_SHADED=4]="GOURAUD_SHADED",i[i.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",i[i.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME",i))(Za||{}),Qa=(i=>(i[i.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",i[i.TOP=1]="TOP",i[i.BOTTOM=2]="BOTTOM",i[i.FRONT=3]="FRONT",i[i.BACK=4]="BACK",i[i.LEFT=5]="LEFT",i[i.RIGHT=6]="RIGHT",i))(Qa||{}),Ja=(i=>(i[i.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",i[i.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS",i))(Ja||{});let vh=class bh{constructor(){this._number=-1,this._id="",this._groupId="",this._centerPoint=new G,this._height=0,this._width=0,this._viewCenter=new G,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 xe;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 xe;return t.setFromCenterAndSize(this.viewCenter,{x:this.viewWidth,y:this.viewHeight}),t}clone(){const t=new bh;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}};var vn=256,xh=[],fl=256,ii;for(;vn--;)xh[vn]=(vn+256).toString(16).substring(1);function Xu(i){var t=0,e=11;if(!ii||vn+e>fl*2)for(ii="",vn=0;t<fl;t++)ii+=xh[Math.random()*256|0];return ii.substring(vn,vn+++e)}class tn{constructor(t,e){t=t||{},Kn(t,{objectId:Xu()}),this._attrs=new Tl(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:lo().workingDatabase}set database(t){this._database=t}close(){}}const ho=class ho extends tn{constructor(){super(...arguments),this._layer="0",this._color=new Dr,this._lineType=hi,this._lineWeight=Ki.ByLayer,this._linetypeScale=-1,this._visibility=!0,this._transparency=new Wi}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 n=this.getLayerColor();n&&n.RGB!=null&&(t=n)}else this.color.isByBlock||this.color.RGB!=null&&(t=this.color);const e=t.RGB;return e??16777215}get lineType(){return this._lineType}set lineType(t){this._lineType=t||hi}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.clone()}get properties(){return{type:this.type,groups:[this.getGeneralProperties()]}}subGetGripPoints(){return new Array}subGetOsnapPoints(t,e,n,a,h){}transformBy(t){return this}erase(){return this.database.tables.blockTable.removeEntity(this.objectId)}worldDraw(t,e){const n=t.subEntityTraits;n.color=this.color,n.rgbColor=this.rgbColor,n.lineType=this.lineStyle,n.lineTypeScale=this.linetypeScale,n.lineWeight=this.lineWeight,n.transparency=this.transparency,n.layer=this.layer,"thickness"in this&&(n.thickness=this.thickness);const a=this.subWorldDraw(t,e);return this.attachEntityInfo(a),a}triggerModifiedEvent(){this.database.events.entityModified.dispatch({database:this.database,entity:this})}getGeneralProperties(){return{groupName:"general",properties:[{name:"handle",type:"int",editable:!1,accessor:{get:()=>this.objectId}},{name:"color",type:"color",editable:!0,accessor:{get:()=>this.color,set:t=>{this.color.copy(t)}}},{name:"layer",type:"string",editable:!0,accessor:{get:()=>this.layer,set:t=>{this.layer=t}}},{name:"linetype",type:"linetype",editable:!0,accessor:{get:()=>this.lineType,set:t=>{this.lineType=t}}},{name:"linetypeScale",type:"float",editable:!0,accessor:{get:()=>this.linetypeScale,set:t=>{this.linetypeScale=t}}},{name:"lineWeight",type:"lineweight",editable:!0,accessor:{get:()=>this.lineWeight,set:t=>{this.lineWeight=t}}},{name:"transparency",type:"transparency",editable:!0,accessor:{get:()=>this.transparency,set:t=>{this.transparency=t}}}]}}get lineStyle(){var a;const{type:t,name:e}=this.getLineType(),n=(a=this.database)==null?void 0:a.tables.linetypeTable.getAt(e);return n?{type:t,...n.linetype}:{type:t,name:e,standardFlag:0,description:"",totalPatternLength:0}}getLineType(){if(this.lineType==hi){const t=this.database.tables.layerTable.getAt(this.layer);if(t&&t.linetype)return{type:"ByLayer",name:t.linetype}}else return this.lineType==Rl?{type:"ByBlock",name:fi}:{type:"UserSpecified",name:this.lineType};return{type:"UserSpecified",name:fi}}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}attachEntityInfo(t){t&&(t.objectId=this.objectId,this.attrs.has("ownerId")&&(t.ownerId=this.ownerId),t.layerName=this.layer,t.visible=this.visibility)}};ho.typeName="Entity";let Me=ho;const co=class co extends Me{};co.typeName="Curve";let ke=co;var jn=(i=>(i[i.SimplePoly=0]="SimplePoly",i[i.FitCurvePoly=1]="FitCurvePoly",i[i.QuadSplinePoly=2]="QuadSplinePoly",i[i.CubicSplinePoly=3]="CubicSplinePoly",i))(jn||{});const uo=class uo extends ke{constructor(t,e,n=0,a=!1,h=0,c=0,m=null){super(),this._polyType=t,this._elevation=n;const b=m&&(m==null?void 0:m.length)===e.length,f=e.map((w,x)=>({x:w.x,y:w.y,bulge:b?m[x]:void 0}));this._geo=new An(f,a)}get polyType(){return this._polyType}set polyType(t){this._polyType=t}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}get geometricExtents(){const t=this._geo.box;return new Ct({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._geo.numberOfVertices;++e){const n=this._geo.getPointAt(e);t.push(new G(n.x,n.y,0))}return t}subGetOsnapPoints(t,e,n,a){switch(t){case Dt.EndPoint:for(let h=0;h<this._geo.numberOfVertices;++h){const c=this._geo.getPointAt(h);a.push(new G(c.x,c.y,0))}break}}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!0},{name:"y",type:"float",editable:!0}]},accessor:{get:()=>this._geo.vertices}},{name:"elevation",type:"float",editable:!0,accessor:{get:()=>this.elevation,set:t=>{this.elevation=t}}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}}]},{groupName:"others",properties:[{name:"closed",type:"float",editable:!0,accessor:{get:()=>this.closed,set:t=>{this.closed=t}}}]}]}}subWorldDraw(t){const e=[];return this._geo.getPoints(100).forEach(a=>e.push(new G().set(a.x,a.y,this.elevation))),t.lines(e)}};uo.typeName="2dPolyline";let yi=uo;var wh=(i=>(i[i.Vertex=0]="Vertex",i[i.CurveFitVertex=1]="CurveFitVertex",i[i.SplineFitVertex=8]="SplineFitVertex",i[i.SplineCtlVertex=9]="SplineCtlVertex",i))(wh||{});const po=class po extends Me{constructor(){super(),this._position=new G,this._bulge=0,this._startWidth=0,this._endWidth=0,this._vertexType=0}get position(){return this._position}set position(t){this._position.copy(t)}get bulge(){return this._bulge}set bulge(t){this._bulge=t}get startWidth(){return this._startWidth}set startWidth(t){this._startWidth=t}get endWidth(){return this._endWidth}set endWidth(t){this._endWidth=t}get vertexType(){return this._vertexType}set vertexType(t){this._vertexType=t}get geometricExtents(){return new Ct().expandByPoint(this._position)}subGetGripPoints(){const t=new Array;return t.push(this._position),t}subGetOsnapPoints(t,e,n,a){a.push(this._position)}transformBy(t){return this._position.applyMatrix4(t),this}subWorldDraw(t){}};po.typeName="2dVertex";let Ea=po;var js=(i=>(i[i.SimplePoly=0]="SimplePoly",i[i.QuadSplinePoly=1]="QuadSplinePoly",i[i.CubicSplinePoly=2]="CubicSplinePoly",i))(js||{});const mo=class mo extends ke{constructor(t,e,n=!1){super(),this._polyType=t,this._geo=new An(e,n)}get polyType(){return this._polyType}set polyType(t){this._polyType=t}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}get geometricExtents(){const t=this._geo.box;return new Ct({x:t.min.x,y:t.min.y,z:0},{x:t.max.x,y:t.max.y,z:0})}subGetGripPoints(){const t=new Array;for(let e=0;e<this._geo.numberOfVertices;++e){const n=this._geo.getPointAt(e);t.push(new G(n.x,n.y,0))}return t}subGetOsnapPoints(t,e,n,a){switch(t){case Dt.EndPoint:for(let h=0;h<this._geo.numberOfVertices;++h){const c=this._geo.getPointAt(h);a.push(new G(c.x,c.y,0))}break}}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!0},{name:"y",type:"float",editable:!0},{name:"z",type:"float",editable:!0}]},accessor:{get:()=>this._geo.vertices}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}}]},{groupName:"others",properties:[{name:"closed",type:"float",editable:!0,accessor:{get:()=>this.closed,set:t=>{this.closed=t}}}]}]}}subWorldDraw(t){const e=[];return this._geo.getPoints(100).forEach(a=>e.push(new G().set(a.x,a.y,0))),t.lines(e)}};mo.typeName="3dPolyline";let vi=mo;var Ah=(i=>(i[i.SimpleVertex=0]="SimpleVertex",i[i.ControlVertex=1]="ControlVertex",i[i.FitVertex=2]="FitVertex",i))(Ah||{});const go=class go extends Me{constructor(){super(),this._position=new G,this._vertexType=0}get position(){return this._position}set position(t){this._position.copy(t)}get vertexType(){return this._vertexType}set vertexType(t){this._vertexType=t}get geometricExtents(){return new Ct().expandByPoint(this._position)}subGetGripPoints(){const t=new Array;return t.push(this._position),t}subGetOsnapPoints(t,e,n,a){a.push(this._position)}transformBy(t){return this._position.applyMatrix4(t),this}subWorldDraw(t){}};go.typeName="3dVertex";let Ma=go;const fo=class fo extends ke{constructor(t,e,n,a,h=X.Z_AXIS){super(),this._geo=new Xa(t,e,n,a,h,X.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 normal(){return this._geo.normal}set normal(t){this._geo.normal=t}get startPoint(){return this._geo.startPoint}get endPoint(){return this._geo.endPoint}get midPoint(){return this._geo.midPoint}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"centerX",type:"float",editable:!0,accessor:{get:()=>this.center.x,set:t=>{this.center.x=t}}},{name:"centerY",type:"float",editable:!0,accessor:{get:()=>this.center.y,set:t=>{this.center.y=t}}},{name:"centerZ",type:"float",editable:!0,accessor:{get:()=>this.center.z,set:t=>{this.center.z=t}}},{name:"radius",type:"float",editable:!0,accessor:{get:()=>this.radius,set:t=>{this.radius=t}}},{name:"startAngle",type:"float",editable:!0,accessor:{get:()=>this.startAngle,set:t=>{this.startAngle=t}}},{name:"endAngle",type:"float",editable:!0,accessor:{get:()=>this.endAngle,set:t=>{this.endAngle=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}},{name:"arcLength",type:"float",editable:!1,accessor:{get:()=>this._geo.length}},{name:"totalAngle",type:"float",editable:!1,accessor:{get:()=>Pt.radToDeg(Math.abs(this._geo.deltaAngle))}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this._geo.area}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.center),t.push(this.startPoint),t.push(this.endPoint),t}subGetOsnapPoints(t,e,n,a){const h=this.startPoint,c=this.endPoint;switch(t){case Dt.EndPoint:a.push(h),a.push(c);break;case Dt.MidPoint:a.push(this.midPoint);break;case Dt.Nearest:{const m=this._geo.nearestPoint(e);a.push(m)}break;case Dt.Perpendicular:break;case Dt.Tangent:{const m=this._geo.tangentPoints(e);a.push(...m);break}}}transformBy(t){return this._geo.transform(t),this}subWorldDraw(t){return t.circularArc(this._geo)}};fo.typeName="Arc";let bi=fo;var Ph=(i=>(i[i.LEFT=0]="LEFT",i[i.CENTER=1]="CENTER",i[i.RIGHT=2]="RIGHT",i[i.ALIGNED=3]="ALIGNED",i[i.MIDDLE=4]="MIDDLE",i[i.FIT=5]="FIT",i))(Ph||{}),Sh=(i=>(i[i.BASELINE=0]="BASELINE",i[i.BOTTOM=1]="BOTTOM",i[i.MIDDLE=2]="MIDDLE",i[i.TOP=3]="TOP",i))(Sh||{});const _o=class _o extends Me{constructor(){super(),this._textString="",this._height=0,this._thickness=1,this._position=new G,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 Ct}subGetOsnapPoints(t,e,n,a){Dt.Insertion===t&&a.push(this._position)}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"text",properties:[{name:"contents",type:"string",editable:!0,accessor:{get:()=>this.textString,set:t=>{this.textString=t}}},{name:"styleName",type:"string",editable:!0,accessor:{get:()=>this.styleName,set:t=>{this.styleName=t}}},{name:"textHeight",type:"float",editable:!0,accessor:{get:()=>this.height,set:t=>{this.height=t}}},{name:"rotation",type:"float",editable:!0,accessor:{get:()=>this.rotation,set:t=>{this.rotation=t}}},{name:"widthFactor",type:"float",editable:!0,accessor:{get:()=>this.widthFactor,set:t=>{this.widthFactor=t}}},{name:"oblique",type:"float",editable:!0,accessor:{get:()=>this.oblique,set:t=>{this.oblique=t}}}]},{groupName:"geometry",properties:[{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:t=>{this.position.x=t}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:t=>{this.position.y=t}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:t=>{this.position.z=t}}}]}]}}getTextStyle(){const t=this.database.tables.textStyleTable;let e=t.getAt(this.styleName);return e||(e=t.getAt("STANDARD")||t.getAt("Standard")),e.textStyle}subWorldDraw(t,e){const n={text:this.textString,height:this.height,width:1/0,widthFactor:this.widthFactor,position:this.position,rotation:this.rotation,drawingDirection:zr.BOTTOM_TO_TOP,attachmentPoint:be.BottomLeft};return t.mtext(n,this.getTextStyle(),e)}};_o.typeName="Text";let qn=_o;var Oe=(i=>(i[i.Invisible=1]="Invisible",i[i.Const=2]="Const",i[i.Verifiable=4]="Verifiable",i[i.Preset=8]="Preset",i))(Oe||{}),$r=(i=>(i[i.MultiLine=2]="MultiLine",i[i.ConstMultiLine=4]="ConstMultiLine",i))($r||{});const yo=class yo extends qn{constructor(){super(),this._flags=0,this._prompt="",this._mtextFlag=0,this._tag="",this._fieldLength=0,this._lockPositionInBlock=!1,this._isReallyLocked=!1}get isInvisible(){return(this._flags&1)!==0}set isInvisible(t){t?this._flags|=1:this._flags&=-2}get prompt(){return this._prompt}set prompt(t){this._prompt=t}get isConst(){return(this._flags&2)!==0}set isConst(t){t?this._flags|=2:this._flags&=-3}get isVerifiable(){return(this._flags&4)!==0}set isVerifiable(t){t?this._flags|=4:this._flags&=-5}get isPreset(){return(this._flags&8)!==0}set isPreset(t){t?this._flags|=8:this._flags&=-9}get isMTextAttribute(){return(this._mtextFlag&2)!==0}set isMTextAttribute(t){t?this._mtextFlag|=2:this._mtextFlag&=-3}get isConstMTextAttribute(){return(this._mtextFlag&4)!==0}set isConstMTextAttribute(t){t?this._mtextFlag|=4:this._mtextFlag&=-5}get tag(){return this._tag}set tag(t){this._tag=t}get fieldLength(){return this._fieldLength}set fieldLength(t){this._fieldLength=t}get lockPositionInBlock(){return this._lockPositionInBlock}set lockPositionInBlock(t){this._lockPositionInBlock=t}get isReallyLocked(){return this._isReallyLocked}set isReallyLocked(t){this._isReallyLocked=t}get mtext(){return this._mtext}set mtext(t){this._mtext=t,this.isMTextAttribute=t!=null}subWorldDraw(t){}};yo.typeName="AttDef";let ka=yo;const vo=class vo extends qn{constructor(){super(),this._flags=0,this._mtextFlag=0,this._tag="",this._fieldLength=0,this._lockPositionInBlock=!1,this._isReallyLocked=!1}get isInvisible(){return(this._flags&Oe.Invisible)!==0}set isInvisible(t){t?this._flags|=Oe.Invisible:this._flags&=~Oe.Invisible}get isConst(){return(this._flags&Oe.Const)!==0}set isConst(t){t?this._flags|=Oe.Const:this._flags&=~Oe.Const}get isVerifiable(){return(this._flags&Oe.Verifiable)!==0}set isVerifiable(t){t?this._flags|=Oe.Verifiable:this._flags&=~Oe.Verifiable}get isPreset(){return(this._flags&Oe.Preset)!==0}set isPreset(t){t?this._flags|=Oe.Preset:this._flags&=~Oe.Preset}get isMTextAttribute(){return(this._mtextFlag&$r.MultiLine)!==0}set isMTextAttribute(t){t?this._mtextFlag|=$r.MultiLine:this._mtextFlag&=~$r.MultiLine}get isConstMTextAttribute(){return(this._mtextFlag&$r.ConstMultiLine)!==0}set isConstMTextAttribute(t){t?this._mtextFlag|=$r.ConstMultiLine:this._mtextFlag&=~$r.ConstMultiLine}get tag(){return this._tag}set tag(t){this._tag=t}get fieldLength(){return this._fieldLength}set fieldLength(t){this._fieldLength=t}get lockPositionInBlock(){return this._lockPositionInBlock}set lockPositionInBlock(t){this._lockPositionInBlock=t}get isReallyLocked(){return this._isReallyLocked}set isReallyLocked(t){this._isReallyLocked=t}get mtext(){return this._mtext}set mtext(t){this._mtext=t,this.isMTextAttribute=t!=null}};vo.typeName="Attrib";let Ta=vo;const bo=class bo extends Me{constructor(t){super(),this._blockName=t,this._position=new G,this._rotation=0,this._normal=new X(0,0,1),this._scaleFactors=new G(1,1,1),this._attribs=new Map}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)}appendAttributes(t){this._attribs.set(t.objectId,t),t.ownerId=this.objectId}attributeIterator(){return new Js(this._attribs)}get blockTransform(){const t=this.blockTableRecord,e=(t==null?void 0:t.origin)??G.ORIGIN,n=new Ye().makeTranslation(-e.x,-e.y,-e.z),a=new Ye().makeScale(this._scaleFactors.x,this._scaleFactors.y,this._scaleFactors.z),h=new wn().setFromAxisAngle(X.Z_AXIS,this._rotation),c=new Ye().makeRotationFromQuaternion(h),m=new Ye().makeTranslation(this._position.x,this._position.y,this._position.z);return new Ye().multiplyMatrices(m,c).multiply(a).multiply(n)}subGetOsnapPoints(t,e,n,a,h){Dt.Insertion===t?a.push(this._position):h&&this.subEntityGetOsnapPoints(t,e,n,a,h)}get properties(){const t={type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"blockName",type:"float",editable:!1,accessor:{get:()=>this._blockName}},{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:e=>{this.position.x=e}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:e=>{this.position.y=e}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:e=>{this.position.z=e}}},{name:"rotation",type:"float",editable:!0,accessor:{get:()=>this.rotation,set:e=>{this.rotation=e}}},{name:"scaleFactorsX",type:"float",editable:!0,accessor:{get:()=>this.scaleFactors.x,set:e=>{this.scaleFactors.x=e}}},{name:"scaleFactorsY",type:"float",editable:!0,accessor:{get:()=>this.scaleFactors.y,set:e=>{this.scaleFactors.y=e}}},{name:"scaleFactorsZ",type:"float",editable:!0,accessor:{get:()=>this.scaleFactors.z,set:e=>{this.scaleFactors.z=e}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:e=>{this.normal.x=e}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:e=>{this.normal.y=e}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:e=>{this.normal.z=e}}}]}]};if(this._attribs.size>0){const e={groupName:"attribute",properties:[]};t.groups.push(e),this._attribs.forEach(n=>{e.properties.push({name:n.tag,type:"string",editable:!n.isConst,skipTranslation:!0,accessor:{get:()=>n.textString,set:a=>{n.textString=a}}})})}return t}get geometricExtents(){const t=new Ct,e=this.blockTableRecord;if(e!=null){const a=e.newIterator();for(const h of a)t.union(h.geometricExtents)}const n=this.blockTransform;return t.applyMatrix4(n),t}subWorldDraw(t){const e=this.blockTableRecord;if(e!=null){const n=this.blockTransform,a=[];return this._attribs.forEach(c=>{if(!c.isInvisible){const m=c.worldDraw(t);m&&a.push(m)}}),$n.instance.draw(t,e,this.rgbColor,a,!0,n,this._normal)}else return t.group([])}subEntityGetOsnapPoints(t,e,n,a,h){var m;if(h===this.objectId)return;const c=(m=this.database)==null?void 0:m.tables.blockTable;if(c!=null){const b=c.getEntityById(h);if(b){const f=[];b.subGetOsnapPoints(t,e,n,f,h);const w=this.blockTransform;f.forEach(x=>{const I=x.clone().applyMatrix4(w);a.push(I)})}}}};bo.typeName="BlockReference";let Yn=bo;const xo=class xo extends ke{constructor(t,e,n=X.Z_AXIS){super(),this._geo=new Xa(t,e,0,Zt,n,X.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}subGetOsnapPoints(t,e,n,a){switch(t){case Dt.Center:case Dt.Centroid:a.push(this._geo.center);break;case Dt.Quadrant:a.push(this._geo.getPointAtAngle(0)),a.push(this._geo.getPointAtAngle(Math.PI/2)),a.push(this._geo.getPointAtAngle(Math.PI)),a.push(this._geo.getPointAtAngle(Math.PI/2*3));break;case Dt.Nearest:{const h=this._geo.nearestPoint(e);a.push(h)}break;case Dt.Tangent:{const h=this._geo.tangentPoints(e);a.push(...h);break}}}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"centerX",type:"float",editable:!0,accessor:{get:()=>this.center.x,set:t=>{this.center.x=t}}},{name:"centerY",type:"float",editable:!0,accessor:{get:()=>this.center.y,set:t=>{this.center.y=t}}},{name:"centerZ",type:"float",editable:!0,accessor:{get:()=>this.center.z,set:t=>{this.center.z=t}}},{name:"radius",type:"float",editable:!0,accessor:{get:()=>this.radius,set:t=>{this.radius=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}},{name:"diameter",type:"float",editable:!1,accessor:{get:()=>this._geo.radius*2}},{name:"perimeter",type:"float",editable:!1,accessor:{get:()=>this._geo.length}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this._geo.area}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.center),t}transformBy(t){return this._geo.transform(t),this}subWorldDraw(t){return t.circularArc(this._geo)}};xo.typeName="Circle";let xi=xo;const wo=class wo extends ke{constructor(t,e,n,a,h,c,m){super(),this._geo=new Xi(t,e,n,a,h,c,m)}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 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 normal(){return this._geo.normal}set normal(t){this._geo.normal=t}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}subGetOsnapPoints(t,e,n,a){switch(t){case Dt.EndPoint:this.closed||(a.push(this._geo.startPoint),a.push(this._geo.endPoint));break;case Dt.MidPoint:this.closed||a.push(this._geo.midPoint);break;case Dt.Quadrant:this.closed&&(a.push(this._geo.getPointAtAngle(0)),a.push(this._geo.getPointAtAngle(Math.PI/2)),a.push(this._geo.getPointAtAngle(Math.PI)),a.push(this._geo.getPointAtAngle(Math.PI/2*3)));break}}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"centerX",type:"float",editable:!0,accessor:{get:()=>this.center.x,set:t=>{this.center.x=t}}},{name:"centerY",type:"float",editable:!0,accessor:{get:()=>this.center.y,set:t=>{this.center.y=t}}},{name:"centerZ",type:"float",editable:!0,accessor:{get:()=>this.center.z,set:t=>{this.center.z=t}}},{name:"majorAxisRadius",type:"float",editable:!0,accessor:{get:()=>this.majorAxisRadius,set:t=>{this.center.x=t}}},{name:"minorAxisRadius",type:"float",editable:!0,accessor:{get:()=>this.minorAxisRadius,set:t=>{this.minorAxisRadius=t}}},{name:"startAngle",type:"float",editable:!0,accessor:{get:()=>this.startAngle,set:t=>{this.startAngle=t}}},{name:"endAngle",type:"float",editable:!0,accessor:{get:()=>this.endAngle,set:t=>{this.endAngle=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this._geo.area}}]}]}}subWorldDraw(t){return t.ellipticalArc(this._geo)}};wo.typeName="Ellipse";let wi=wo;const Ao=class Ao extends Me{constructor(){super(),this._vertices=[new G,new G,new G],this._edgeInvisibilities=0}getVertexAt(t){return t<0?this._vertices[0]:t>this._vertices.length?this._vertices[this._vertices.length-1]:this._vertices[t]}setVertexAt(t,e){if(t<0&&this._vertices[0].copy(e),t>=3)return this._vertices.length===3&&this._vertices.push(new G),this._vertices[3].copy(e);this._vertices[t].copy(e)}setEdgeInvisibilities(t){this._edgeInvisibilities=t}isEdgeVisibleAt(t){if(t<0||t>3)throw new Error("Index out of range");return(this._edgeInvisibilities&1<<t)===0}makeEdgeInvisibleAt(t){if(t<0||t>3)throw new Error("Index out of range");this._edgeInvisibilities=this._edgeInvisibilities|1<<t}get geometricExtents(){return new Ct().setFromPoints(this._vertices)}subGetGripPoints(){const t=new Array;return t.push(...this._vertices),t}subGetOsnapPoints(t,e,n,a){switch(t){case Dt.EndPoint:a.push(...this._vertices);break}}subWorldDraw(t){const e=this._vertices.length,n=new Float32Array(e*3),a=new Uint16Array(e*2);for(let h=0;h<e;h++)n[h*3]=this._vertices[h].x,n[h*3+1]=this._vertices[h].y,n[h*3+2]=this._vertices[h].z,this.isEdgeVisibleAt(h)&&(a[h*2]=h,a[h*2+1]=(h+1)%4);return t.lineSegments(n,3,a)}};Ao.typeName="Face";let Ai=Ao;var Gs=(i=>(i[i.UserDefined=0]="UserDefined",i[i.Predefined=1]="Predefined",i[i.Custom=2]="Custom",i))(Gs||{}),Ih=(i=>(i[i.Normal=0]="Normal",i[i.Outer=1]="Outer",i[i.Ignore=2]="Ignore",i))(Ih||{});const Po=class Po extends Me{constructor(){super(),this._elevation=0,this._geo=new qi,this._isSolidFill=!1,this._definitionLines=[],this._patternName="",this._patternType=1,this._patternAngle=0,this._patternScale=1,this._hatchStyle=0}get isSolidFill(){return this._isSolidFill||this._patternName.toUpperCase()==="SOLID"}set isSolidFill(t){this._isSolidFill=t}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}get elevation(){return this._elevation}set elevation(t){this._elevation=t}add(t){this._geo.add(t)}get geometricExtents(){const t=this._geo.box;return new Ct({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"pattern",properties:[{name:"patternType",type:"enum",editable:!0,options:[{label:Gs[0],value:0},{label:Gs[1],value:1},{label:Gs[2],value:2}],accessor:{get:()=>this.patternType,set:t=>{this.patternType=t}}},{name:"patternName",type:"string",editable:!0,accessor:{get:()=>this.patternName,set:t=>{this.patternName=t}}},{name:"patternAngle",type:"float",editable:!0,accessor:{get:()=>this.patternAngle,set:t=>{this.patternAngle=t}}},{name:"patternScale",type:"float",editable:!0,accessor:{get:()=>this.patternScale,set:t=>{this.patternScale=t}}}]},{groupName:"geometry",properties:[{name:"elevation",type:"float",editable:!0,accessor:{get:()=>this.elevation,set:t=>{this.elevation=t}}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this._geo.area}}]}]}}subWorldDraw(t){const e=t.subEntityTraits;return e.fillType={solidFill:this.isSolidFill,patternAngle:this.patternAngle,definitionLines:this.definitionLines},t.area(this._geo)}};Po.typeName="Hatch";let qs=Po;var Eh=(i=>(i[i.MText=0]="MText",i[i.Fcf=1]="Fcf",i[i.BlockReference=2]="BlockReference",i[i.NoAnnotation=3]="NoAnnotation",i))(Eh||{});const So=class So extends ke{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 G().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 Ct().setFromPoints(this._vertices)}get closed(){return!1}set closed(t){}subWorldDraw(t){if(this.isSplined&&this.splineGeo){const e=this.splineGeo.getPoints(100);return t.lines(e)}else return t.lines(this._vertices)}get splineGeo(){return this.createSplineIfNeeded(),this._splineGeo}createSplineIfNeeded(){this.isSplined&&this.numVertices>=2&&(this._splineGeo==null||this._updated)&&(this._splineGeo=new Jr(this._vertices,"Uniform"),this._updated=!1)}};So.typeName="Leader";let Pi=So;var Dt=(i=>(i[i.EndPoint=1]="EndPoint",i[i.MidPoint=2]="MidPoint",i[i.Center=3]="Center",i[i.Node=4]="Node",i[i.Quadrant=5]="Quadrant",i[i.Insertion=7]="Insertion",i[i.Perpendicular=8]="Perpendicular",i[i.Tangent=9]="Tangent",i[i.Nearest=10]="Nearest",i[i.Centroid=11]="Centroid",i))(Dt||{});function Ku(i){let t=0;for(const e of i)t|=1<<e-1;return t}function $u(i){const t=[];for(const e of Object.values(Dt)){if(typeof e!="number")continue;const n=1<<e-1;i&n&&t.push(e)}return t}function Zu(i,t){return i^1<<t-1}function Qu(i,t){return(i&1<<t-1)!==0}function Ju(i,t){return i|1<<t-1}function td(i,t){return i&~(1<<t-1)}const Io=class Io extends ke{constructor(t,e){super(),this._geo=new Hn(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}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"startX",type:"float",editable:!0,accessor:{get:()=>this.startPoint.x,set:t=>{this.startPoint.x=t}}},{name:"startY",type:"float",editable:!0,accessor:{get:()=>this.startPoint.y,set:t=>{this.startPoint.y=t}}},{name:"startZ",type:"float",editable:!0,accessor:{get:()=>this.startPoint.z,set:t=>{this.startPoint.z=t}}},{name:"endX",type:"float",editable:!0,accessor:{get:()=>this.endPoint.x,set:t=>{this.endPoint.x=t}}},{name:"endY",type:"float",editable:!0,accessor:{get:()=>this.endPoint.y,set:t=>{this.endPoint.y=t}}},{name:"endZ",type:"float",editable:!0,accessor:{get:()=>this.endPoint.z,set:t=>{this.endPoint.z=t}}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.midPoint),t.push(this.startPoint),t.push(this.endPoint),t}subGetOsnapPoints(t,e,n,a){const h=this.startPoint,c=this.endPoint;switch(t){case Dt.EndPoint:a.push(h),a.push(c);break;case Dt.MidPoint:a.push(this.midPoint);break;case Dt.Nearest:{const m=this._geo.project(e);a.push(m)}break;case Dt.Perpendicular:{const m=this._geo.perpPoint(e);a.push(m)}break;case Dt.Tangent:break}}transformBy(t){return this._geo.transform(t),this}subWorldDraw(t){const e=this.startPoint,n=this.endPoint,a=[new G(e.x,e.y,0),new G(n.x,n.y,0)];return t.lines(a)}};Io.typeName="Line";let Ys=Io;const Eo=class Eo extends Me{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 G,this._attachmentPoint=be.TopLeft,this._direction=new X(1,0,0),this._drawingDirection=zr.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 Ct}subGetOsnapPoints(t,e,n,a){Dt.Insertion===t&&a.push(this._location)}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"text",properties:[{name:"contents",type:"string",editable:!0,accessor:{get:()=>this.contents,set:t=>{this.contents=t}}},{name:"styleName",type:"string",editable:!0,accessor:{get:()=>this.styleName,set:t=>{this.styleName=t}}},{name:"attachmentPoint",type:"enum",editable:!0,options:[{label:be[1],value:1},{label:be[2],value:2},{label:be[3],value:3},{label:be[4],value:4},{label:be[5],value:5},{label:be[6],value:6},{label:be[7],value:7},{label:be[8],value:8},{label:be[9],value:9}],accessor:{get:()=>this.attachmentPoint,set:t=>{this.attachmentPoint=t}}},{name:"drawingDirection",type:"enum",editable:!0,options:[{label:zr[1],value:1},{label:zr[2],value:2},{label:zr[3],value:3},{label:zr[4],value:4},{label:zr[5],value:5}],accessor:{get:()=>this.drawingDirection,set:t=>{this.drawingDirection=t}}},{name:"textHeight",type:"float",editable:!0,accessor:{get:()=>this.height,set:t=>{this.height=t}}},{name:"rotation",type:"float",editable:!0,accessor:{get:()=>this.rotation,set:t=>{this.rotation=t}}},{name:"lineSpacingFactor",type:"float",editable:!0,accessor:{get:()=>this.lineSpacingFactor,set:t=>{this.lineSpacingFactor=t}}},{name:"definedWidth",type:"float",editable:!0,accessor:{get:()=>this.width,set:t=>{this.width=t}}},{name:"directionX",type:"float",editable:!0,accessor:{get:()=>this.direction.x,set:t=>{this.direction.x=t}}},{name:"directionY",type:"float",editable:!0,accessor:{get:()=>this.direction.y,set:t=>{this.direction.y=t}}},{name:"directionZ",type:"float",editable:!0,accessor:{get:()=>this.direction.z,set:t=>{this.direction.z=t}}}]},{groupName:"geometry",properties:[{name:"locationX",type:"float",editable:!0,accessor:{get:()=>this.location.x,set:t=>{this.location.x=t}}},{name:"locationY",type:"float",editable:!0,accessor:{get:()=>this.location.y,set:t=>{this.location.y=t}}},{name:"locationZ",type:"float",editable:!0,accessor:{get:()=>this.location.z,set:t=>{this.location.z=t}}}]}]}}getTextStyle(){const t=this.database.tables.textStyleTable;let e=t.getAt(this.styleName);return e||(e=t.getAt("STANDARD")||t.getAt("Standard")),e.textStyle}subWorldDraw(t,e){const n={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};return t.mtext(n,this.getTextStyle(),e)}};Eo.typeName="MText";let Xs=Eo;const Mo=class Mo extends ke{constructor(t,e,n,a,h){super();const c=+(t!==void 0)+ +(e!==void 0)+ +(n!==void 0)+ +(a!==void 0)+ +(h!==void 0);if(c<2||c>5)throw Xe.ILLEGAL_PARAMETERS;!Array.isArray(e)?this._geo=new Jr(t,e,n,a):this._geo=new Jr(t,e,n,a,h)}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}subGetOsnapPoints(t,e,n,a){switch(t){case Dt.EndPoint:a.push(this._geo.startPoint),a.push(this._geo.endPoint);break}}subWorldDraw(t){const e=this._geo.getPoints(100);return t.lines(e)}};Mo.typeName="Spline";let Ks=Mo;const ed=new X,ko=class ko extends Yn{constructor(t,e,n){super(t),this._attachmentPoint=be.TopLeft,this._numColumns=n,this._numRows=e,this._columnWidth=new Array(n),this._rowHeight=new Array(e),this._cells=new Array(e*n)}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,n){return this._cells[t*e].text}setTextString(t,e,n){this._cells[t*e].text=n}isEmpty(t,e){return!this._cells[t*e].text}get geometricExtents(){return new Ct}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"table",properties:[{name:"numRows",type:"string",editable:!0,accessor:{get:()=>this.numRows,set:t=>{this.numRows=t}}},{name:"numColumns",type:"float",editable:!0,accessor:{get:()=>this.numColumns,set:t=>{this.numColumns=t}}},{name:"tableWidth",type:"float",editable:!1,accessor:{get:()=>this._columnWidth.reduce((t,e)=>t+e,0)}},{name:"tableHeight",type:"float",editable:!1,accessor:{get:()=>this._rowHeight.reduce((t,e)=>t+e,0)}}]},{groupName:"geometry",properties:[{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:t=>{this.position.x=t}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:t=>{this.position.y=t}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:t=>{this.position.z=t}}}]}]}}subWorldDraw(t){let e=0,n=0;const a=new Uint16Array(this.numColumns*this.numRows*8),h=new Float32Array((this.numColumns+1)*(this.numRows+1)*3);let c=0;for(let I=0;I<=this.numRows;I++){e-=I>0?this.rowHeight(I-1):0,n=0;for(let M=0;M<=this.numColumns;M++)n+=M>0?this.columnWidth(M-1):0,h[c++]=n,h[c++]=e,h[c++]=0}const m=[],b=new Array(this.numRows*this.numColumns).fill(!1);n=0,c=0;let f=0;for(let I=0;I<this.numColumns;I++){n+=I>0?this.columnWidth(I-1):0,e=0;for(let M=0;M<this.numRows;M++){e+=M>0?this.rowHeight(M-1):0;const O=this.cell(M*this.numColumns+I);if(f=M*this.numColumns+I,O&&!b[f]){const L=O.borderWidth??1,F=O.borderHeight??1;this.fillVisited(b,f,this.numColumns,L,F),a[c++]=I+M*(this.numColumns+1),a[c++]=I+M*(this.numColumns+1)+L;const D=h[a[c-1]*3]-n,dt=I+(M+F)*(this.numColumns+1)+L;I+L==this.numColumns&&(a[c++]=I+M*(this.numColumns+1)+L,a[c++]=dt);const vt=-h[dt*3+1]-e;if(M+F==this.numRows&&(a[c++]=I+(M+F)*(this.numColumns+1)+F,a[c++]=I+(M+F)*(this.numColumns+1)),a[c++]=I+(M+F)*(this.numColumns+1),a[c++]=I+M*(this.numColumns+1),O.text){const ot=O.attachmentPoint||this.attachmentPoint||be.MiddleCenter,H=this.getTableTextOffset(ot,D,vt),ct={text:O.text,height:O.textHeight,width:D,position:ed.set(n,-e,0).clone().add(H),rotation:this.rotation,attachmentPoint:ot},st=this.getTextStyle(O);m.push(t.mtext(ct,st))}}}}m.push(t.lineSegments(h,3,a));const w=t.group(m),x=new wn;return x.setFromAxisAngle(X.Z_AXIS,this.rotation),_l.compose(this.position,x,this.scaleFactors),w.applyMatrix(_l),w}fillVisited(t,e,n,a,h){if(h==1&&a==1)t[e]=!0;else for(let c=0;c<a;++c)for(let m=0;m<h;++m)t[e+c+m*n]=!0}getTextStyle(t){const e=this.database.tables.textStyleTable;let n;return t.textStyle&&(n=e.getAt(t.textStyle)),n||(n=e.getAt("STANDARD")||e.getAt("Standard")),n.textStyle}getTableTextOffset(t,e,n){const a=new X;switch(t){case 1:break;case 2:a.setX(e/2);break;case 3:a.setX(e);break;case 4:a.setY(-n/2);break;case 5:a.set(e/2,-n/2,0);break;case 6:a.set(e,-n/2,0);break;case 7:a.setY(-n);break;case 8:a.set(e/2,-n,0);break;case 9:a.set(e,-n,0);break}return a}};ko.typeName="Table";let Si=ko;const _l=new Ye,To=class To extends ke{constructor(){super(),this._elevation=0,this._thickness=1,this._vertices=[new G,new G,new G,new G]}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 Ct().setFromPoints(this._vertices)}subGetGripPoints(){const t=new Array;return t.push(...this._vertices),t}subGetOsnapPoints(t,e,n,a){switch(t){case Dt.EndPoint:a.push(...this._vertices);break}}subWorldDraw(t){const e=new An(this._vertices,!0),n=new qi;n.add(e);const a=t.subEntityTraits;return a.fillType={solidFill:!0,patternAngle:0,definitionLines:[]},t.area(n)}};To.typeName="Trace";let Ii=To;const Co=class Co extends ke{constructor(){super(),this._elevation=0,this._geo=new An}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,n=0,a=-1,h=-1){const c=a<0?void 0:a,m=h<0?void 0:h,b={x:e.x,y:e.y,bulge:n,startWidth:c,endWidth:m};this._geo.addVertexAt(t,b)}getPoint2dAt(t){return this._geo.getPointAt(t)}getPoint3dAt(t){const e=this.getPoint2dAt(t);return new G(e.x,e.y,this._elevation)}get geometricExtents(){const t=this._geo.box;return new Ct({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}subGetOsnapPoints(t,e,n,a){const h=new Array;for(let c=0;c<this.numberOfVertices;++c)h.push(this.getPoint3dAt(c));switch(t){case Dt.EndPoint:a.push(...h);break}}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!0},{name:"y",type:"float",editable:!0}]},accessor:{get:()=>this._geo.vertices}},{name:"elevation",type:"float",editable:!0,accessor:{get:()=>this.elevation,set:t=>{this.elevation=t}}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}}]},{groupName:"others",properties:[{name:"closed",type:"float",editable:!0,accessor:{get:()=>this.closed,set:t=>{this.closed=t}}}]}]}}subWorldDraw(t){const e=[];return this._geo.getPoints(100).forEach(a=>e.push(new G().set(a.x,a.y,this.elevation))),t.lines(e)}};Co.typeName="Polyline";let Ei=Co;const No=class No extends Me{constructor(){super(),this._geo=new G}get position(){return this._geo}set position(t){this._geo.set(t.x,t.y,t.z||0)}get geometricExtents(){return new Ct().expandByPoint(this._geo)}subGetOsnapPoints(t,e,n,a){Dt.Node===t&&a.push(this._geo)}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:t=>{this.position.x=t}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:t=>{this.position.y=t}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:t=>{this.position.z=t}}}]}]}}transformBy(t){return this._geo.applyMatrix4(t),this}subWorldDraw(t){return t.point(this._geo,{displayMode:this.database.pdmode,displaySize:this.database.pdsize})}};No.typeName="Point";let Mi=No;var Mh=(i=>(i[i.Invalid=0]="Invalid",i[i.Rect=1]="Rect",i[i.Poly=2]="Poly",i))(Mh||{}),kh=(i=>(i[i.Show=1]="Show",i[i.ShowUnAligned=2]="ShowUnAligned",i[i.Clip=4]="Clip",i[i.Transparent=8]="Transparent",i))(kh||{});const Lo=class Lo extends Me{constructor(){super(),this._brightness=50,this._contrast=50,this._fade=0,this._width=0,this._height=0,this._position=new G,this._scale=new Jt(1,1),this._rotation=0,this._clipBoundaryType=1,this._clipBoundary=[],this._isClipped=!1,this._isShownClipped=!1,this._isImageShown=!0,this._isImageTransparent=!1,this._imageDefId=""}get brightness(){return this._brightness}set brightness(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 isShownClipped(){return this._isShownClipped}set isShownClipped(t){this._isShownClipped=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 Ct;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()}subWorldDraw(t){const e=this.boundaryPath();return this._image?t.image(this._image,{boundary:e,roation:this._rotation}):t.lines(e)}boundaryPath(){const t=[];if(this.isClipped&&this._clipBoundary.length>3){const e=this._width,n=this._height,a=new xe;a.setFromPoints(this._clipBoundary);const h=new Tt;h.setX(this._position.x-a.min.x*e),h.setY(this._position.y-a.min.y*n),this._clipBoundary.forEach(c=>{const m=c.x*e+h.x,b=c.y*n+h.y;t.push(new G(m,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){yl.copy(t[1]);for(let e=1;e<4;e++)ai.copy(t[e]),ai.rotateAround(yl,this._rotation),t[e].setX(ai.x),t[e].setY(ai.y)}t.push(t[0])}return t}};Lo.typeName="RasterImage";let $s=Lo;const yl=new Tt,ai=new Tt,Oo=class Oo extends ke{constructor(){super(),this._basePoint=new G,this._unitDir=new X}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 Ct;return t.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),t.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),t}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"basePointX",type:"float",editable:!0,accessor:{get:()=>this.basePoint.x,set:t=>{this.basePoint.x=t}}},{name:"basePointY",type:"float",editable:!0,accessor:{get:()=>this.basePoint.y,set:t=>{this.basePoint.y=t}}},{name:"basePointZ",type:"float",editable:!0,accessor:{get:()=>this.basePoint.z,set:t=>{this.basePoint.z=t}}},{name:"unitDirX",type:"float",editable:!0,accessor:{get:()=>this.unitDir.x,set:t=>{this.unitDir.x=t}}},{name:"unitDirY",type:"float",editable:!0,accessor:{get:()=>this.unitDir.y,set:t=>{this.unitDir.y=t}}},{name:"unitDirZ",type:"float",editable:!0,accessor:{get:()=>this.unitDir.z,set:t=>{this.unitDir.z=t}}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.basePoint),t}subGetOsnapPoints(t,e,n,a){switch(t){case Dt.EndPoint:a.push(this.basePoint);break}}subWorldDraw(t){const e=[];return e.push(this.basePoint),e.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),t.lines(e)}};Oo.typeName="Ray";let ki=Oo;const Bo=class Bo extends Me{constructor(){super(),this._centerPoint=new G,this._height=0,this._width=0,this._viewCenter=new G,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 Ct}subWorldDraw(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 vh;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 n=[];return n.push(e.lines([new G(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0),new G(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0)])),n.push(e.lines([new G(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0),new G(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0)])),n.push(e.lines([new G(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0),new G(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0)])),n.push(e.lines([new G(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0),new G(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0)])),n}};Bo.typeName="Viewport";let Ti=Bo;const zo=class zo extends $s{subWorldDraw(t){const e=this.boundaryPath(),n=new qi;return n.add(new An(e)),t.area(n)}};zo.typeName="Wipeout";let Ci=zo;const Ro=class Ro extends ke{constructor(){super(),this._basePoint=new G,this._unitDir=new X}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 Ct;return t.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),t.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),t}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"basePointX",type:"float",editable:!0,accessor:{get:()=>this.basePoint.x,set:t=>{this.basePoint.x=t}}},{name:"basePointY",type:"float",editable:!0,accessor:{get:()=>this.basePoint.y,set:t=>{this.basePoint.y=t}}},{name:"basePointZ",type:"float",editable:!0,accessor:{get:()=>this.basePoint.z,set:t=>{this.basePoint.z=t}}},{name:"unitDirX",type:"float",editable:!0,accessor:{get:()=>this.unitDir.x,set:t=>{this.unitDir.x=t}}},{name:"unitDirY",type:"float",editable:!0,accessor:{get:()=>this.unitDir.y,set:t=>{this.unitDir.y=t}}},{name:"unitDirZ",type:"float",editable:!0,accessor:{get:()=>this.unitDir.z,set:t=>{this.unitDir.z=t}}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.basePoint),t}subWorldDraw(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)}};Ro.typeName="Xline";let Ni=Ro;var Th=(i=>(i[i.AtLeast=1]="AtLeast",i[i.Exactly=2]="Exactly",i))(Th||{});const Do=class Do extends Me{constructor(){super(),this._dimBlockId=null,this._dimBlockPosition=new G,this._dimensionStyleName=null,this._dimensionText=null,this._textLineSpacingFactor=1,this._textLineSpacingStyle=1,this._textPosition=new G,this._textRotation=0,this._normal=new X(0,0,1)}get dimBlockId(){return this._dimBlockId}set dimBlockId(t){this._dimBlockId=t}get dimBlockPosition(){return this._dimBlockPosition}set dimBlockPosition(t){this._dimBlockPosition.copy(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 Xn),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}get normal(){return this._normal}set normal(t){this._normal.copy(t).normalize()}subWorldDraw(t){if(this.dimBlockId){const n=this.database.tables.blockTable.getAt(this.dimBlockId);if(n){const a=this.computeDimBlockTransform();return $n.instance.draw(t,n,this.rgbColor,[],!1,a,this._normal)}}return t.group([])}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,n){const a=new G().subVectors(e,t).normalize();return new G(e).addScaledVector(a,n)}findPointOnLine2(t,e,n){const a=t.x+n*Math.cos(e),h=t.y+n*Math.sin(e);return{x:a,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}computeDimBlockTransform(){const t=this.dimBlockId?this.database.tables.blockTable.getAt(this.dimBlockId):void 0,e=(t==null?void 0:t.origin)??G.ORIGIN,n=new Ye().makeTranslation(-e.x,-e.y,-e.z),a=new Ye().makeTranslation(this._dimBlockPosition.x,this._dimBlockPosition.y,this._dimBlockPosition.z);return new Ye().multiplyMatrices(a,n)}};Do.typeName="Dimension";let Rr=Do;const Fo=class Fo extends Rr{constructor(t,e,n,a,h=null,c=null){super(),this._centerPoint=new G().copy(t),this._xLine1Point=new G().copy(e),this._xLine2Point=new G().copy(n),this._arcPoint=new G().copy(a),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 Ct}};Fo.typeName="3PointAngularDimension";let Li=Fo;const Vo=class Vo extends Rr{constructor(t,e,n,a=null,h=null){super(),this._dimLinePoint=new G().copy(n),this._xLine1Point=new G().copy(t),this._xLine2Point=new G().copy(e),this._oblique=0,this._rotation=0,this.calculateRotation(),a?this.dimensionText=a:this.dimensionText=this._xLine1Point.distanceTo(this._xLine2Point).toFixed(3),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 Ct}get isAppendArrow(){return!1}createDimBlock(t){const e=new le;e.name=t;const n=this.createLines();n.forEach(m=>e.appendEntity(new Ys(m.startPoint,m.endPoint))),this.createArrows(n[0]).forEach(m=>e.appendEntity(m));const h=n[0].midPoint,c=this.createMText(h,this._rotation);return c&&e.appendEntity(c),e}createMText(t,e){const n=a=>({x:Math.cos(a),y:Math.sin(a),z:0});if(this.dimensionText){const a=new Xs;return a.attachmentPoint=be.MiddleLeft,a.layer="0",a.color=new Dr(pt.ByBlock),a.location=t,a.contents=this.dimensionText??"",a.height=10,a.direction=n(e),a.styleName=this.dimensionStyle.dimtxsty,a}}createArrows(t){const e=[];return e.push(this.createArrow(t.startPoint,this.rotation+Math.PI,10)),e.push(this.createArrow(t.endPoint,this.rotation,10)),e}createArrow(t,e,n){const a="_CAXARROW",h=new Yn(a);return h.position=t,h.rotation=e,h.scaleFactors={x:n,y:n,z:n},h}createLines(){const t=[],e=this.createExtensionLine(this._xLine1Point),n=this.createExtensionLine(this._xLine2Point),a=this.findIntersectionPoint(e,this._dimLinePoint),h=this.findIntersectionPoint(n,this._dimLinePoint),c=new Hn(a,h);return t.push(c),e.endPoint=a,this.adjustExtensionLine(e),t.push(e),n.endPoint=h,this.adjustExtensionLine(n),t.push(n),t}createExtensionLine(t){const e=this.rotation+Math.PI/2,n=this.findPointOnLine2(t,e,100);return new Hn(t,{...n,z:t.z})}findIntersectionPoint(t,e){const n=t.startPoint,a=t.endPoint,h=new X().subVectors(a,n).normalize(),m=new X().subVectors(e,n).dot(h),b=new X().copy(h).multiplyScalar(m);return new X().addVectors(n,b)}calculateRotation(){const t=this._xLine1Point,e=this._xLine2Point,n=e.x-t.x,a=e.y-t.y;this._rotation=Math.atan2(a,n)}};Vo.typeName="AlignedDimension";let Oi=Vo;const Uo=class Uo extends Rr{constructor(t,e,n,a,h=null,c=null){super(),this._arcPoint=new G().copy(a),this._xLine1Point=new G().copy(e),this._xLine2Point=new G().copy(n),this._centerPoint=new G().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 Ct}};Uo.typeName="ArcDimension";let Ca=Uo;const jo=class jo extends Rr{constructor(t,e,n=0,a=null,h=null){super(),this._chordPoint=new G().copy(t),this._farChordPoint=new G().copy(e),this._extArcStartAngle=0,this._extArcEndAngle=0,this._leaderLength=n,this.dimensionText=a,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 Ct}drawLines(t,e){const n=[],a=e.length;return a==1?n.push(this.drawLine(t,e[0],{firstArrow:this.firstArrowStyle})):a==3?(this.sortLines(e),n.push(this.drawLine(t,e[0],{firstArrow:this.firstArrowStyle})),n.push(this.drawLine(t,e[1])),n.push(this.drawLine(t,e[2],{firstArrow:this.firstArrowStyle}))):e.forEach(h=>{n.push(this.drawLine(t,h))}),n}drawLine(t,e,n){if(n){const a=[e.startPoint,e.endPoint];return t.lines(a)}else return e.worldDraw(t)}sortLines(t){const e=(n,a)=>n.x!==a.x?n.x-a.x:n.y!==a.y?n.y-a.y:n.z-a.z;t.sort((n,a)=>{const h=e(n.startPoint,a.startPoint);return h!==0?h:e(n.endPoint,a.endPoint)})}};jo.typeName="DiametricDimension";let Bi=jo;const Go=class Go extends Rr{constructor(t,e,n=null,a=null){super(),this._definingPoint=new G().copy(t),this._leaderEndPoint=new G().copy(e),this.dimensionText=n,this.dimensionStyleName=a}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 Ct}get arrowLineCount(){return 0}};Go.typeName="OrdinateDimension";let zi=Go;const Wo=class Wo extends Rr{constructor(t,e,n,a=null,h=null){super(),this._center=new G().copy(t),this._chordPoint=new G().copy(e),this._leaderLength=n,this._extArcStartAngle=0,this._extArcEndAngle=0,this.dimensionText=a,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 Ct}getLineArrowStyle(t){return{secondArrow:this.secondArrowStyle}}};Wo.typeName="RadialDimension";let Ri=Wo;class $i extends tn{constructor(){super(),this._tabOrder=-1,this._tabSelected=!1,this._blockTableRecordId="",this._layoutName="",this._limits=new xe,this._extents=new Ct}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 to extends tn{constructor(t){super(),this.database=t,this._recordsByName=new Map,this._recordsById=new Map}get numEntries(){return this._recordsByName.size}setAt(t,e){e.database=this.database,this._recordsByName.set(t,e),this._recordsById.set(e.objectId,e),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((n,a)=>{n===e&&(this._recordsByName.delete(a),this.database.events.dictObjectErased.dispatch({database:this.database,object:e,key:a}))}),!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 Js(this._recordsByName)}}class Ch extends to{getBtrIdAt(t){for(const[e,n]of this._recordsByName)if(n.blockTableRecordId==t)return n}get maxTabOrder(){let t=-1;return this._recordsByName.forEach(e=>{e.tabOrder>t&&(t=e.tabOrder)}),t}}class Nh extends tn{constructor(){super(),this._sourceFileName=""}get sourceFileName(){return this._sourceFileName}set sourceFileName(t){this._sourceFileName=t}}class Lh{constructor(t){this.db=t}createDefaultLayer(){const t=new Dr;return t.colorIndex=7,this.db.tables.layerTable.add(new Qi({name:"0",standardFlags:0,linetype:"Continuous",lineWeight:0,isOff:!1,color:t,isPlottable:!0}))}createDefaultLineType(){this.db.tables.linetypeTable.add(new Hs({name:"ByBlock",standardFlag:0,description:"",totalPatternLength:0})),this.db.tables.linetypeTable.add(new Hs({name:"ByLayer",standardFlag:0,description:"",totalPatternLength:0})),this.db.tables.linetypeTable.add(new Hs({name:"Continuous",standardFlag:0,description:"Solid line",totalPatternLength:0}))}createDefaultTextStyle(){this.db.tables.textStyleTable.add(new oo({name:"Standard",standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:.2,font:"SimKai",bigFont:"",extendedFont:"SimKai"}))}createDefaultDimStyle(){this.db.tables.dimStyleTable.add(new Xn({name:"Standard",dimtxsty:"Standard"}))}createDefaultLayout(){const t=new $i;t.layoutName="Model",t.tabOrder=0,t.blockTableRecordId=this.db.tables.blockTable.modelSpace.objectId,t.limits.min.copy({x:0,y:0}),t.limits.max.copy({x:1e6,y:1e6}),t.extents.min.copy({x:0,y:0,z:0}),t.extents.max.copy({x:1e6,y:1e6,z:0}),this.db.dictionaries.layouts.setAt(t.layoutName,t),this.db.tables.blockTable.modelSpace.layoutId=t.objectId}createArrowBlock(){if(!this.db.tables.blockTable.getAt("_CAXARROW")){const e=new qs;e.patternName="SOLID";const n=new Ka;n.add(new Us({x:0,y:0},{x:-1,y:.125})),n.add(new Us({x:-1,y:.125},{x:-1,y:-.125})),n.add(new Us({x:-1,y:-.125},{x:0,y:0})),e.add(n);const a=new le;a.name="_CAXARROW",a.appendEntity(e),this.db.tables.blockTable.add(a)}}}var Oh=(i=>(i.ClosedFilled="",i.Dot="_DOT",i.DotSmall="_DOTSMALL",i.DotBlank="_DOTBLANK",i.Origin="_ORIGIN",i.Origin2="_ORIGIN2",i.Open="_OPEN",i.Open90="_OPEN90",i.Open30="_OPEN30",i.Closed="_CLOSED",i.Small="_SMALL",i.None="_NONE",i.Oblique="_OBLIQUE",i.BoxFilled="_BOXFILLED",i.Box="_BOXBLANK",i.ClosedBlank="_CLOSEDBLANK",i.DatumBlank="_DATUMBLANK",i.DatumFilled="_DATUMFILLED",i.Integral="_INTEGRAL",i.ArchTick="_ARCHTICK",i))(Oh||{});class Js{constructor(t){this.i=0,this._records=t,this._keys=Array.from(t.keys())}get count(){return this._records.size}toArray(){return Array.from(this._records.values())}[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}}}var eo=(i=>(i[i.Undefined=0]="Undefined",i[i.Inches=1]="Inches",i[i.Feet=2]="Feet",i[i.Miles=3]="Miles",i[i.Millimeters=4]="Millimeters",i[i.Centimeters=5]="Centimeters",i[i.Meters=6]="Meters",i[i.Kilometers=7]="Kilometers",i[i.Microinches=8]="Microinches",i[i.Mils=9]="Mils",i[i.Yards=10]="Yards",i[i.Angstroms=11]="Angstroms",i[i.Nanometers=12]="Nanometers",i[i.Microns=13]="Microns",i[i.Decimeters=14]="Decimeters",i[i.Dekameters=15]="Dekameters",i[i.Hectometers=16]="Hectometers",i[i.Gigameters=17]="Gigameters",i[i.Astronomical=18]="Astronomical",i[i.LightYears=19]="LightYears",i[i.Parsecs=20]="Parsecs",i[i.USSurveyFeet=21]="USSurveyFeet",i[i.USSurveyInch=22]="USSurveyInch",i[i.USSurveyYard=23]="USSurveyYard",i[i.USSurveyMile=24]="USSurveyMile",i[i.Max=24]="Max",i))(eo||{});function rd(i){return i==4||i==5||i==6||i==7||i==12||i==13||i==14||i==15||i==16||i==17}function nd(i){return i==1||i==2||i==3||i==8||i==9||i==10||i==21}const Bh="Load Database";class Le extends Nl{constructor(t,e){super(t.stage),this.data=t,this.progress=e}async run(t){const e=Oa.getInstance().getEntry(Bh),n=Date.now();this.progress&&await this.progress(this.data.progress.value,this.data.stage,"START");const a=await this.data.task(t);return this.progress&&(await this.progress(this.data.progress.value,this.data.stage,"END",a?a.data:null),this.data.progress.value+=this.data.step,this.data.progress.value>100&&(this.data.progress.value=100)),e&&(e.data[this.name]=Date.now()-n),a}}class ro{constructor(t={}){this.config=t}async read(t,e,n,a){const h={name:Bh,data:{total:0},format(){let f="";return Object.keys(this.data).forEach(w=>{w!=="total"&&(f+=`- ${w}: ${this.data[w]} ms
5
- `)}),f+=`- total: ${this.data.total} ms`,f}};Oa.getInstance().collect(h),this.progress=a;const c={value:0},m=new Ll;m.setCompleteCallback(()=>this.onFinished()),m.setErrorCallback(f=>this.onError(f)),m.addTask(new Le({stage:"START",step:1,progress:c,task:async f=>f},a)),m.addTask(new Le({stage:"PARSE",step:5,progress:c,task:async f=>await this.parse(f)},a)),m.addTask(new Le({stage:"FONT",step:5,progress:c,task:async f=>{const w=this.getFonts(f.model);return{model:f.model,data:w}}},a)),m.addTask(new Le({stage:"LTYPE",step:1,progress:c,task:async f=>(this.processLineTypes(f.model,e),f)},a)),m.addTask(new Le({stage:"STYLE",step:1,progress:c,task:async f=>(this.processTextStyles(f.model,e),f)},a)),m.addTask(new Le({stage:"DIMSTYLE",step:1,progress:c,task:async f=>(this.processDimStyles(f.model,e),f)},a)),m.addTask(new Le({stage:"LAYER",step:1,progress:c,task:async f=>(this.processLayers(f.model,e),e.tables.layerTable.numEntries===0&&e.createDefaultData({layer:!0}),f)},a)),m.addTask(new Le({stage:"VPORT",step:1,progress:c,task:async f=>(this.processViewports(f.model,e),f)},a)),m.addTask(new Le({stage:"HEADER",step:1,progress:c,task:async f=>(this.processHeader(f.model,e),f)},a)),m.addTask(new Le({stage:"BLOCK_RECORD",step:5,progress:c,task:async f=>(this.processBlockTables(f.model,e),f)},a)),m.addTask(new Le({stage:"OBJECT",step:5,progress:c,task:async f=>(this.processObjects(f.model,e),e.dictionaries.layouts.numEntries===0&&e.createDefaultData({layout:!0}),f)},a)),m.addTask(new Le({stage:"BLOCK",step:5,progress:c,task:async f=>(await this.processBlocks(f.model,e),f)},a)),m.addTask(new Le({stage:"ENTITY",step:100,progress:c,task:async f=>(await this.processEntities(f.model,e,n,c,a),f)},a)),m.addTask(new Le({stage:"END",step:0,progress:c,task:async f=>f},a));const b=Date.now();await m.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)}return console.error(`Error occurred in conversion stage '${t.task.name}': `,t.error),t.task.name==="ENTITY"?!1:(this.onFinished(),!0)}onFinished(){this.progress&&(this.progress(100,"END","END"),$n.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,n,a,h){throw new Error("Not impelemented yet!")}}var de,bs,ee,oe,xs,ar,Ae,wr,or,ln,ws,As,hn,cn,Ps,Ss,Is,Ue,Ar,Xt,un,Es,yt,Pe,Ms,Se,ks,Pr,Sr,lr,Ts,dn,je,Ir,pn,pa,ma,Er,Mr,Cs,Ns,kr,Ls,ga,fa,pe,Tr,me,Ge,_a,ya,va,ba,Cr,We,mn,Os,gn,He,Nr,qe,Lr;(de={})[de.None=0]="None",de[de.Anonymous=1]="Anonymous",de[de.NonConstant=2]="NonConstant",de[de.Xref=4]="Xref",de[de.XrefOverlay=8]="XrefOverlay",de[de.ExternallyDependent=16]="ExternallyDependent",de[de.ResolvedOrDependent=32]="ResolvedOrDependent",de[de.ReferencedXref=64]="ReferencedXref";(bs={})[bs.BYBLOCK=0]="BYBLOCK",bs[bs.BYLAYER=256]="BYLAYER";(ee={})[ee.Rotated=0]="Rotated",ee[ee.Aligned=1]="Aligned",ee[ee.Angular=2]="Angular",ee[ee.Diameter=3]="Diameter",ee[ee.Radius=4]="Radius",ee[ee.Angular3Point=5]="Angular3Point",ee[ee.Ordinate=6]="Ordinate",ee[ee.ReferenceIsExclusive=32]="ReferenceIsExclusive",ee[ee.IsOrdinateXTypeFlag=64]="IsOrdinateXTypeFlag",ee[ee.IsCustomTextPositionFlag=128]="IsCustomTextPositionFlag";(oe={})[oe.TopLeft=1]="TopLeft",oe[oe.TopCenter=2]="TopCenter",oe[oe.TopRight=3]="TopRight",oe[oe.MiddleLeft=4]="MiddleLeft",oe[oe.MiddleCenter=5]="MiddleCenter",oe[oe.MiddleRight=6]="MiddleRight",oe[oe.BottomLeft=7]="BottomLeft",oe[oe.BottomCenter=8]="BottomCenter",oe[oe.BottomRight=9]="BottomRight";(xs={})[xs.AtLeast=1]="AtLeast",xs[xs.Exact=2]="Exact";var vl=((ar={})[ar.Center=0]="Center",ar[ar.Above=1]="Above",ar[ar.Outside=2]="Outside",ar[ar.JIS=3]="JIS",ar[ar.Below=4]="Below",ar),Un=((Ae={})[Ae.Feet=0]="Feet",Ae[Ae.None=1]="None",Ae[Ae.Inch=2]="Inch",Ae[Ae.FeetAndInch=3]="FeetAndInch",Ae[Ae.Leading=4]="Leading",Ae[Ae.Trailing=8]="Trailing",Ae[Ae.LeadingAndTrailing=12]="LeadingAndTrailing",Ae),sd=((wr={})[wr.None=0]="None",wr[wr.Leading=1]="Leading",wr[wr.Trailing=2]="Trailing",wr[wr.LeadingAndTrailing=3]="LeadingAndTrailing",wr),id=((or={})[or.Center=0]="Center",or[or.Left=1]="Left",or[or.Right=2]="Right",or[or.OverFirst=3]="OverFirst",or[or.OverSecond=4]="OverSecond",or),ad=((ln={})[ln.Bottom=0]="Bottom",ln[ln.Center=1]="Center",ln[ln.Top=2]="Top",ln),od=((ws={})[ws.PatternFill=0]="PatternFill",ws[ws.SolidFill=1]="SolidFill",ws);(As={})[As.NonAssociative=0]="NonAssociative",As[As.Associative=1]="Associative";(hn={})[hn.Normal=0]="Normal",hn[hn.Outer=1]="Outer",hn[hn.Ignore=2]="Ignore";(cn={})[cn.UserDefined=0]="UserDefined",cn[cn.Predefined=1]="Predefined",cn[cn.Custom=2]="Custom";(Ps={})[Ps.NotAnnotated=0]="NotAnnotated",Ps[Ps.Annotated=1]="Annotated";(Ss={})[Ss.Solid=0]="Solid",Ss[Ss.Gradient=1]="Gradient";(Is={})[Is.TwoColor=0]="TwoColor",Is[Is.OneColor=1]="OneColor";var ld=((Ue={})[Ue.Default=0]="Default",Ue[Ue.External=1]="External",Ue[Ue.Polyline=2]="Polyline",Ue[Ue.Derived=4]="Derived",Ue[Ue.Textbox=8]="Textbox",Ue[Ue.Outermost=16]="Outermost",Ue),oi=((Ar={})[Ar.Line=1]="Line",Ar[Ar.Circular=2]="Circular",Ar[Ar.Elliptic=3]="Elliptic",Ar[Ar.Spline=4]="Spline",Ar),hd=((Xt={})[Xt.Off=0]="Off",Xt[Xt.Solid=1]="Solid",Xt[Xt.Dashed=2]="Dashed",Xt[Xt.Dotted=3]="Dotted",Xt[Xt.ShotDash=4]="ShotDash",Xt[Xt.MediumDash=5]="MediumDash",Xt[Xt.LongDash=6]="LongDash",Xt[Xt.DoubleShortDash=7]="DoubleShortDash",Xt[Xt.DoubleMediumDash=8]="DoubleMediumDash",Xt[Xt.DoubleLongDash=9]="DoubleLongDash",Xt[Xt.DoubleMediumLongDash=10]="DoubleMediumLongDash",Xt[Xt.SparseDot=11]="SparseDot",Xt);hd.Off;(un={})[un.Standard=-3]="Standard",un[un.ByLayer=-2]="ByLayer",un[un.ByBlock=-1]="ByBlock";(Es={})[Es.English=0]="English",Es[Es.Metric=1]="Metric";(yt={})[yt.PERSPECTIVE_MODE=1]="PERSPECTIVE_MODE",yt[yt.FRONT_CLIPPING=2]="FRONT_CLIPPING",yt[yt.BACK_CLIPPING=4]="BACK_CLIPPING",yt[yt.UCS_FOLLOW=8]="UCS_FOLLOW",yt[yt.FRONT_CLIP_NOT_AT_EYE=16]="FRONT_CLIP_NOT_AT_EYE",yt[yt.UCS_ICON_VISIBILITY=32]="UCS_ICON_VISIBILITY",yt[yt.UCS_ICON_AT_ORIGIN=64]="UCS_ICON_AT_ORIGIN",yt[yt.FAST_ZOOM=128]="FAST_ZOOM",yt[yt.SNAP_MODE=256]="SNAP_MODE",yt[yt.GRID_MODE=512]="GRID_MODE",yt[yt.ISOMETRIC_SNAP_STYLE=1024]="ISOMETRIC_SNAP_STYLE",yt[yt.HIDE_PLOT_MODE=2048]="HIDE_PLOT_MODE",yt[yt.K_ISO_PAIR_TOP=4096]="K_ISO_PAIR_TOP",yt[yt.K_ISO_PAIR_RIGHT=8192]="K_ISO_PAIR_RIGHT",yt[yt.VIEWPORT_ZOOM_LOCKING=16384]="VIEWPORT_ZOOM_LOCKING",yt[yt.UNUSED=32768]="UNUSED",yt[yt.NON_RECTANGULAR_CLIPPING=65536]="NON_RECTANGULAR_CLIPPING",yt[yt.VIEWPORT_OFF=131072]="VIEWPORT_OFF",yt[yt.GRID_BEYOND_DRAWING_LIMITS=262144]="GRID_BEYOND_DRAWING_LIMITS",yt[yt.ADAPTIVE_GRID_DISPLAY=524288]="ADAPTIVE_GRID_DISPLAY",yt[yt.SUBDIVISION_BELOW_SPACING=1048576]="SUBDIVISION_BELOW_SPACING",yt[yt.GRID_FOLLOWS_WORKPLANE=2097152]="GRID_FOLLOWS_WORKPLANE";(Pe={})[Pe.OPTIMIZED_2D=0]="OPTIMIZED_2D",Pe[Pe.WIREFRAME=1]="WIREFRAME",Pe[Pe.HIDDEN_LINE=2]="HIDDEN_LINE",Pe[Pe.FLAT_SHADED=3]="FLAT_SHADED",Pe[Pe.GOURAUD_SHADED=4]="GOURAUD_SHADED",Pe[Pe.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",Pe[Pe.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME";(Ms={})[Ms.UCS_UNCHANGED=0]="UCS_UNCHANGED",Ms[Ms.HAS_OWN_UCS=1]="HAS_OWN_UCS";(Se={})[Se.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",Se[Se.TOP=1]="TOP",Se[Se.BOTTOM=2]="BOTTOM",Se[Se.FRONT=3]="FRONT",Se[Se.BACK=4]="BACK",Se[Se.LEFT=5]="LEFT",Se[Se.RIGHT=6]="RIGHT";(ks={})[ks.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",ks[ks.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS";(Pr={})[Pr.ByLayer=0]="ByLayer",Pr[Pr.ByBlock=1]="ByBlock",Pr[Pr.ByDictionaryDefault=2]="ByDictionaryDefault",Pr[Pr.ByObject=3]="ByObject";function St(i,t,e){return i.code===t&&(e==null||i.value===e)}function Rt(i){let t={};i.rewind();let e=i.next(),n=e.code;if(t.x=e.value,(e=i.next()).code!==n+10)throw Error("Expected code for point value to be 20 but got "+e.code+".");return t.y=e.value,(e=i.next()).code!==n+20?i.rewind():t.z=e.value,t}let no=Symbol();function xt(i,t){return(e,n,a)=>{let h=function(b,f=!1){return b.reduce((w,x)=>{x.pushContext&&w.push({});let I=w[w.length-1];for(let M of typeof x.code=="number"?[x.code]:x.code){let O=I[M]??(I[M]=[]);x.isMultiple&&O.length&&f&&console.warn(`Snippet ${O[O.length-1].name} for code(${M}) is shadowed by ${x.name}`),O.push(x)}return w},[{}])}(i,n.debug),c=!1,m=h.length-1;for(;!St(e,0,"EOF");){let b=function(F,D,dt){return F.find((vt,ot)=>{var H;return ot>=dt&&((H=vt[D])==null?void 0:H.length)})}(h,e.code,m),f=b==null?void 0:b[e.code],w=f==null?void 0:f[f.length-1];if(!b||!w){n.rewind();break}w.isMultiple||b[e.code].pop();let{name:x,parser:I,isMultiple:M,isReducible:O}=w,L=I==null?void 0:I(e,n,a);if(L===no){n.rewind();break}if(x){let[F,D]=function(dt,vt){let ot=vt.split(".");if(!ot.length)throw Error("[parserGenerator::getObjectByPath] Invalid empty path");let H=dt;for(let ct=0;ct<ot.length-1;++ct){let st=xa(ot[ct]),Gt=xa(ot[ct+1]);Object.prototype.hasOwnProperty.call(H,st)||(typeof Gt=="number"?H[st]=[]:H[st]={}),H=H[st]}return[H,xa(ot[ot.length-1])]}(a,x);M&&!O?(Object.prototype.hasOwnProperty.call(F,D)||(F[D]=[]),F[D].push(L)):F[D]=L}w.pushContext&&(m-=1),c=!0,e=n.next()}return t&&Object.setPrototypeOf(a,t),c}}function xa(i){let t=Number.parseInt(i);return Number.isNaN(t)?i:t}function v({value:i}){return i}function W(i,t){return Rt(t)}function Vt({value:i}){return!!i}let cd=[{code:1001,name:"xdata",parser:zh}];function zh(i,t){var a;if(!St(i,1001))throw Error("XData must starts with code 1001");let e={appName:i.value,value:[]};i=t.next();let n=[e.value];for(;!St(i,0,"EOF")&&i.code>=1e3;){let h=n[n.length-1];switch(i.code){case 1002:i.value==="{"?n.push([]):(n.pop(),(a=n[n.length-1])==null||a.push(h));break;case 1e3:case 1004:case 1040:case 1070:case 1071:h.push({type:Or(i.code),value:i.value});break;case 1003:h.push({name:"layer",type:Or(i.code),value:i.value});break;case 1005:h.push({name:"handle",type:Or(i.code),value:i.value});break;case 1010:h.push({type:Or(i.code),value:Rt(t)});break;case 1011:h.push({name:"worldSpacePosition",type:Or(i.code),value:Rt(t)});break;case 1012:h.push({name:"worldSpaceDisplacement",type:Or(i.code),value:Rt(t)});break;case 1013:h.push({name:"worldSpaceDirection",type:Or(i.code),value:Rt(t)});break;case 1041:h.push({name:"distance",type:Or(i.code),value:i.value});break;case 1042:h.push({name:"scale",type:Or(i.code),value:i.value})}i=t.next()}return t.rewind(),e}function Or(i){switch(i){case 1e3:case 1003:case 1005:return"string";case 1004:return"hex";case 1040:case 1041:case 1042:return"real";case 1070:return"integer";case 1071:return"long";case 1010:case 1011:case 1012:case 1013:return"point";default:return""}}function xn(i,t,e){for(;St(i,102);){var n;let a=i.value;if(i=t.next(),!a.startsWith("{")){t.debug&&console.warn(`Invalid application group, expected to start with "{" but received: ${a}`),function(c,m){for(;!St(c,102)&&!St(c,0,"EOF");)c=m.next()}(i,t),i=t.next();continue}let h=a.slice(1).trim();e.extensions??(e.extensions={}),(n=e.extensions)[h]??(n[h]=[]),function(c,m,b){for(;!St(c,102,"}")&&!St(c,0,"EOF");)b.push(c),c=m.next()}(i,t,e.extensions[h]),i=t.next()}t.rewind()}let ud=0;function Rh(i){if(!i)throw TypeError("entity cannot be undefined or null");i.handle||(i.handle=ud++)}var dd=[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 Dh(i){return dd[i]}(Sr={})[Sr.CAST_AND_RECEIVE=0]="CAST_AND_RECEIVE",Sr[Sr.CAST=1]="CAST",Sr[Sr.RECEIVE=2]="RECEIVE",Sr[Sr.IGNORE=3]="IGNORE";let jt=[...cd,{code:284,name:"shadowMode",parser:v},{code:390,name:"plotStyleHardId",parser:v},{code:380,name:"plotStyleType",parser:v},{code:440,name:"transparency",parser:v},{code:430,name:"colorName",parser:v},{code:420,name:"color",parser:v},{code:310,name:"proxyEntity",isMultiple:!0,parser:v},{code:92,name:"proxyByte",parser:v},{code:60,name:"isVisible",parser:Vt},{code:48,name:"lineTypeScale",parser:v},{code:370,name:"lineweight",parser:v},{code:62,name:"colorIndex",parser(i,t,e){let n=i.value;return n>0&&n<256&&(e.color=Dh(Math.abs(n))),n}},{code:347,name:"materialObjectHardId",parser:v},{code:6,name:"lineType",parser:v},{code:8,name:"layer",parser:v},{code:410,name:"layoutTabName",parser:v},{code:67,name:"isInPaperSpace",parser:Vt},{code:100},{code:160},{code:330,name:"ownerBlockRecordSoftId",parser:v},{code:102,parser:xn},{code:102,parser:xn},{code:102,parser:xn},{code:5,name:"handle",parser:v}];function Zi(i){return[{code:3,name:i,parser:(t,e,n)=>(n._code3text=(n._code3text??"")+t.value,n._code3text+(n._code1text??"")),isMultiple:!0,isReducible:!0},{code:1,name:i,parser:(t,e,n)=>(n._code1text=t.value,(n._code3text??"")+n._code1text)}]}function Fh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let pd={extrusionDirection:{x:0,y:0,z:1}},md=[{code:210,name:"extrusionDirection",parser:W},{code:51,name:"endAngle",parser:v},{code:50,name:"startAngle",parser:v},{code:100,name:"subclassMarker",parser:v},{code:40,name:"radius",parser:v},{code:10,name:"center",parser:W},{code:39,name:"thickness",parser:v},{code:100},...jt];class Vh{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Fh(this,"parser",xt(md,pd))}}Fh(Vh,"ForEntityName","ARC");(lr={})[lr.NONE=0]="NONE",lr[lr.INVISIBLE=1]="INVISIBLE",lr[lr.CONSTANT=2]="CONSTANT",lr[lr.VERIFICATION_REQUIRED=4]="VERIFICATION_REQUIRED",lr[lr.PRESET=8]="PRESET";(Ts={})[Ts.MULTILINE=2]="MULTILINE",Ts[Ts.CONSTANT_MULTILINE=4]="CONSTANT_MULTILINE";(dn={})[dn.NONE=0]="NONE",dn[dn.MIRRORED_X=2]="MIRRORED_X",dn[dn.MIRRORED_Y=4]="MIRRORED_Y";var gd=((je={})[je.LEFT=0]="LEFT",je[je.CENTER=1]="CENTER",je[je.RIGHT=2]="RIGHT",je[je.ALIGNED=3]="ALIGNED",je[je.MIDDLE=4]="MIDDLE",je[je.FIT=5]="FIT",je),fd=((Ir={})[Ir.BASELINE=0]="BASELINE",Ir[Ir.BOTTOM=1]="BOTTOM",Ir[Ir.MIDDLE=2]="MIDDLE",Ir[Ir.TOP=3]="TOP",Ir);function Uh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let jh={thickness:0,rotation:0,xScale:1,obliqueAngle:0,styleName:"STANDARD",generationFlag:0,halign:gd.LEFT,valign:fd.BASELINE,extrusionDirection:{x:0,y:0,z:1}},Gh=[{code:73,name:"valign",parser:v},{code:100},{code:210,name:"extrusionDirection",parser:W},{code:11,name:"endPoint",parser:W},{code:72,name:"valign",parser:v},{code:72,name:"halign",parser:v},{code:71,name:"generationFlag",parser:v},{code:7,name:"styleName",parser:v},{code:51,name:"obliqueAngle",parser:v},{code:41,name:"xScale",parser:v},{code:50,name:"rotation",parser:v},{code:1,name:"text",parser:v},{code:40,name:"textHeight",parser:v},{code:10,name:"startPoint",parser:W},{code:39,name:"thickness",parser:v},{code:100,name:"subclassMarker",parser:v},...jt];class Wh{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Uh(this,"parser",xt(Gh,jh))}}function Hh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Uh(Wh,"ForEntityName","TEXT");let _d={...jh},yd=[{code:2},{code:40,name:"annotationScale",parser:v},{code:10,name:"alignmentPoint",parser:W},{code:340,name:"secondaryAttributesHardIds",isMultiple:!0,parser:v},{code:70,name:"numberOfSecondaryAttributes",parser:v},{code:70,name:"isReallyLocked",parser:Vt},{code:70,name:"mtextFlag",parser:v},{code:280,name:"isDuplicatedRecord",parser:Vt},{code:100},{code:280,name:"isLocked",parser:Vt},{code:74,name:"valign",parser:v},{code:73},{code:70,name:"attributeFlag",parser:v},{code:2,name:"tag",parser:v},{code:3,name:"prompt",parser:v},{code:280},{code:100,name:"subclassMarker",parser:v},...Gh.slice(2)];class qh{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Hh(this,"parser",xt(yd,_d))}}Hh(qh,"ForEntityName","ATTDEF");(pn={})[pn.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",pn[pn.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",pn[pn.BY_STYLE=5]="BY_STYLE";function vd(i,t){let e={};for(let n of i){let a=t(n);a!=null&&(e[a]??(e[a]=[]),e[a].push(n))}return e}function*Di(i,t=1/0,e=1){for(let n=i;n!==t;n+=e)yield n}function Zr(i){return{x:i.x??0,y:i.y??0,z:i.z??0}}function so(i,t,e){if(St(t,102))return xn(t,e,i),!0;switch(t.code){case 0:i.type=t.value;break;case 5:i.handle=t.value;break;case 330:i.ownerBlockRecordSoftId=t.value;break;case 67:i.isInPaperSpace=!!t.value;break;case 8:i.layer=t.value;break;case 6:i.lineType=t.value;break;case 347:i.materialObjectHardId=t.value;break;case 62:i.colorIndex=t.value,i.color=Dh(Math.abs(t.value));break;case 370:i.lineweight=t.value;break;case 48:i.lineTypeScale=t.value;break;case 60:i.isVisible=!!t.value;break;case 92:i.proxyByte=t.value;break;case 310:i.proxyEntity=t.value;break;case 100:break;case 420:i.color=t.value;break;case 430:i.transparency=t.value;break;case 390:i.plotStyleHardId=t.value;break;case 284:i.shadowMode=t.value;break;case 1001:i.xdata=zh(t,e);break;default:return!1}return!0}function Yh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let bd={textStyle:"STANDARD",extrusionDirection:{x:0,y:0,z:1},rotation:0},ui=[{code:46,name:"annotationHeight",parser:v},{code:101,parser(i,t){(function(e){e.rewind();let n=e.next();if(n.code!==101)throw Error("Bad call for skipEmbeddedObject()");do n=e.next();while(n.code!==0);e.rewind()})(t)}},{code:50,name:"columnHeight",parser:v},{code:49,name:"columnGutter",parser:v},{code:48,name:"columnWidth",parser:v},{code:79,name:"columnAutoHeight",parser:v},{code:78,name:"columnFlowReversed",parser:v},{code:76,name:"columnCount",parser:v},{code:75,name:"columnType",parser:v},{code:441,name:"backgroundFillTransparency",parser:v},{code:63,name:"backgroundFillColor",parser:v},{code:45,name:"fillBoxScale",parser:v},{code:[...Di(430,440)],name:"backgroundColor",parser:v},{code:[...Di(420,430)],name:"backgroundColor",parser:v},{code:90,name:"backgroundFill",parser:v},{code:44,name:"lineSpacing",parser:v},{code:73,name:"lineSpacingStyle",parser:v},{code:50,name:"rotation",parser:v},{code:43},{code:42},{code:11,name:"direction",parser:W},{code:210,name:"extrusionDirection",parser:W},{code:7,name:"styleName",parser:v},...Zi("text"),{code:72,name:"drawingDirection",parser:v},{code:71,name:"attachmentPoint",parser:v},{code:41,name:"width",parser:v},{code:40,name:"height",parser:v},{code:10,name:"insertionPoint",parser:W},{code:100,name:"subclassMarker",parser:v},...jt];class Xh{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Yh(this,"parser",xt(ui,bd))}}function Kh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Yh(Xh,"ForEntityName","MTEXT");let xd={thickness:0,rotation:0,scale:1,obliqueAngle:0,textStyle:"STANDARD",textGenerationFlag:0,horizontalJustification:0,verticalJustification:0,extrusionDirection:{x:0,y:0,z:1}},wd=[...ui.slice(ui.findIndex(({name:i})=>i==="columnType"),ui.findIndex(({name:i})=>i==="subclassMarker")+1),{code:100},{code:0,parser(i){if(!St(i,0,"MTEXT"))return no}},{code:2,name:"definitionTag",parser:v},{code:40,name:"annotationScale",parser:v},{code:10,name:"alignmentPoint",parser:W},{code:340,name:"secondaryAttributesHardId",parser:v},{code:70,name:"numberOfSecondaryAttributes",parser:v},{code:70,name:"isReallyLocked",parser:Vt},{code:70,name:"mtextFlag",parser:v},{code:280,name:"isDuplicatedEntriesKeep",parser:Vt},{code:100},{code:280,name:"lockPositionFlag",parser:Vt},{code:210,name:"extrusionDirection",parser:W},{code:11,name:"alignmentPoint",parser:W},{code:74,name:"verticalJustification",parser:v},{code:72,name:"horizontalJustification",parser:v},{code:71,name:"textGenerationFlag",parser:v},{code:7,name:"textStyle",parser:v},{code:51,name:"obliqueAngle",parser:v},{code:41,name:"scale",parser:v},{code:50,name:"rotation",parser:v},{code:73},{code:70,name:"attributeFlag",parser:v},{code:2,name:"tag",parser:v},{code:280},{code:100,name:"subclassMarker",parser:v},{code:1,name:"text",parser:v},{code:40,name:"textHeight",parser:v},{code:10,name:"startPoint",parser:W},{code:39,name:"thickness",parser:v},{code:100},...jt];class $h{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Kh(this,"parser",xt(wd,xd))}}function Zh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Kh($h,"ForEntityName","ATTRIB");let Ad=[...Zi("data"),{code:70,name:"version",parser:v},{code:100,name:"subclassMarker",parser:v},...jt];class Qh{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Zh(this,"parser",xt(Ad))}}function Jh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Zh(Qh,"ForEntityName","BODY");let Pd={thickness:0,extrusionDirection:{x:0,y:0,z:1}},Sd=[{code:210,name:"extrusionDirection",parser:W},{code:40,name:"radius",parser:v},{code:10,name:"center",parser:W},{code:39,name:"thickness",parser:v},{code:100,name:"subclassMarker",parser:v},...jt];class tc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Jh(this,"parser",xt(Sd,Pd))}}Jh(tc,"ForEntityName","CIRCLE");class di{parseEntity(t,e){let n={};for(;!St(e,0,"EOF");){if(e.code===0){t.rewind();break}(function(a,h,c){switch(h.code){case 100:a.subclassMarker=h.value;break;case 280:a.version=h.value;break;case 2:a.name=h.value;break;case 10:a.definitionPoint=Rt(c);break;case 11:a.textPoint=Rt(c);break;case 12:a.insertionPoint=Rt(c);break;case 13:a.subDefinitionPoint1=Rt(c);break;case 14:a.subDefinitionPoint2=Rt(c);break;case 15:a.centerPoint=Rt(c);break;case 16:a.arcPoint=Rt(c);break;case 70:a.dimensionType=h.value;break;case 71:a.attachmentPoint=h.value;break;case 72:a.textLineSpacingStyle=h.value;break;case 40:a.leaderLength=h.value;break;case 41:a.textLineSpacingFactor=h.value;break;case 42:a.measurement=h.value;break;case 1:a.text=h.value;break;case 50:a.rotationAngle=h.value;break;case 52:a.obliqueAngle=h.value;break;case 53:a.textRotation=h.value;break;case 51:a.ocsRotation=h.value;break;case 210:a.extrusionDirection=Rt(c);break;case 3:a.styleName=h.value;break;default:so(a,h,c)}})(n,e,t),e=t.next()}return n}}function ec(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}ma="DIMENSION",(pa="ForEntityName")in di?Object.defineProperty(di,pa,{value:ma,enumerable:!0,configurable:!0,writable:!0}):di[pa]=ma;let Id={extrusionDirection:{x:0,y:0,z:1}},Ed=[{code:42,name:"endAngle",parser:v},{code:41,name:"startAngle",parser:v},{code:40,name:"axisRatio",parser:v},{code:210,name:"extrusionDirection",parser:W},{code:11,name:"majorAxisEndPoint",parser:W},{code:10,name:"center",parser:W},{code:100,name:"subclassMarker",parser:v},...jt];class rc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){ec(this,"parser",xt(Ed,Id))}}ec(rc,"ForEntityName","ELLIPSE");(Er={})[Er.First=1]="First",Er[Er.Second=2]="Second",Er[Er.Third=4]="Third",Er[Er.Fourth=8]="Fourth";function nc(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Md=[{code:13,name:"vertices.3",parser:W},{code:12,name:"vertices.2",parser:W},{code:11,name:"vertices.1",parser:W},{code:10,name:"vertices.0",parser:W},{code:100,name:"subclassMarker",parser:v},...jt];class sc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){nc(this,"parser",xt(Md))}}nc(sc,"ForEntityName","3DFACE");let ic=[{code:330,name:"sourceBoundaryObjects",parser:v,isMultiple:!0},{code:97,name:"numberOfSourceBoundaryObjects",parser:v}],kd=[{code:11,name:"end",parser:W},{code:10,name:"start",parser:W}],Td=[{code:73,name:"isCCW",parser:Vt},{code:51,name:"endAngle",parser:v},{code:50,name:"startAngle",parser:v},{code:40,name:"radius",parser:v},{code:10,name:"center",parser:W}],Cd=[{code:73,name:"isCCW",parser:Vt},{code:51,name:"endAngle",parser:v},{code:50,name:"startAngle",parser:v},{code:40,name:"lengthOfMinorAxis",parser:v},{code:11,name:"end",parser:W},{code:10,name:"center",parser:W}],Nd=[{code:13,name:"endTangent",parser:W},{code:12,name:"startTangent",parser:W},{code:11,name:"fitDatum",isMultiple:!0,parser:W},{code:97,name:"numberOfFitData",parser:v},{code:10,name:"controlPoints",isMultiple:!0,parser(i,t){let e={...Rt(t),weight:1};return(i=t.next()).code===42?e.weight=i.value:t.rewind(),e}},{code:40,name:"knots",isMultiple:!0,parser:v},{code:96,name:"numberOfControlPoints",parser:v},{code:95,name:"numberOfKnots",parser:v},{code:74,name:"isPeriodic",parser:Vt},{code:73,name:"splineFlag",parser:v},{code:94,name:"degree",parser:v}],Ld={[oi.Line]:kd,[oi.Circular]:Td,[oi.Elliptic]:Cd,[oi.Spline]:Nd},Od=[...ic,{code:72,name:"edges",parser(i,t){let e={type:i.value},n=xt(Ld[e.type]);if(!n)throw Error(`Invalid edge type ${e.type}`);return n(i=t.next(),t,e),e},isMultiple:!0},{code:93,name:"numberOfEdges",parser:v}],Bd=[...ic,{code:10,name:"vertices",parser(i,t){let e={...Rt(t),bulge:0};return(i=t.next()).code===42?e.bulge=i.value:t.rewind(),e},isMultiple:!0},{code:93,name:"numberOfVertices",parser:v},{code:73,name:"isClosed",parser:Vt},{code:72,name:"hasBulge",parser:Vt}],zd=[{code:49,name:"dashLengths",parser:v,isMultiple:!0},{code:79,name:"numberOfDashLengths",parser:v},{code:45,name:"offset",parser:bl},{code:43,name:"base",parser:bl},{code:53,name:"angle",parser:v}];function bl(i,t){let e=i.code+1,n={x:i.value,y:1};return(i=t.next()).code===e?n.y=i.value:t.rewind(),n}function ac(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Rd={extrusionDirection:{x:0,y:0,z:1},gradientRotation:0,colorTint:0},Dd=[{code:470},{code:463},{code:462,name:"colorTint",parser:v},{code:461,name:"gradientDefinition",parser:v},{code:460,name:"gradientRotation",parser:v},{code:453,name:"numberOfColors",parser:v},{code:452,name:"gradientColorFlag",parser:v},{code:451},{code:450,name:"gradientFlag",parser:v},{code:10,name:"seedPoints",parser:W,isMultiple:!0},{code:99},{code:11,name:"offsetVector",parser:W},{code:98,name:"numberOfSeedPoints",parser:v},{code:47,name:"pixelSize",parser:v},{code:53,name:"definitionLines",parser:function(i,t){let e={};return xt(zd)(i,t,e),e},isMultiple:!0},{code:78,name:"numberOfDefinitionLines",parser:v},{code:77,name:"isDouble",parser:Vt},{code:73,name:"isAnnotated",parser:Vt},{code:41,name:"patternScale",parser:v},{code:52,name:"patternAngle",parser:v},{code:76,name:"patternType",parser:v},{code:75,name:"hatchStyle",parser:v},{code:92,name:"boundaryPaths",parser:function(i,t){let e={boundaryPathTypeFlag:i.value},n=e.boundaryPathTypeFlag&ld.Polyline;return i=t.next(),n?xt(Bd)(i,t,e):xt(Od)(i,t,e),e},isMultiple:!0},{code:91,name:"numberOfBoundaryPaths",parser:v},{code:71,name:"associativity",parser:v},{code:63,name:"patternFillColor",parser:v},{code:70,name:"solidFill",parser:v},{code:2,name:"patternName",parser:v},{code:210,name:"extrusionDirection",parser:W},{code:10,name:"elevationPoint",parser:W},{code:100,name:"subclassMarker",parser:v,pushContext:!0},...jt];class oc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){ac(this,"parser",xt(Dd,Rd))}}ac(oc,"ForEntityName","HATCH");(Mr={})[Mr.ShowImage=1]="ShowImage",Mr[Mr.ShowImageWhenNotAlignedWithScreen=2]="ShowImageWhenNotAlignedWithScreen",Mr[Mr.UseClippingBoundary=4]="UseClippingBoundary",Mr[Mr.TransparencyIsOn=8]="TransparencyIsOn";(Cs={})[Cs.Rectangular=1]="Rectangular",Cs[Cs.Polygonal=2]="Polygonal";(Ns={})[Ns.Outside=0]="Outside",Ns[Ns.Inside=1]="Inside";function lc(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Fd={brightness:50,contrast:50,fade:0,clippingBoundaryPath:[]},Vd=[{code:290,name:"clipMode",parser:v},{code:14,name:"clippingBoundaryPath",isMultiple:!0,parser:W},{code:91,name:"countBoundaryPoints",parser:v},{code:71,name:"clippingBoundaryType",parser:v},{code:360,name:"imageDefReactorHandle",parser:v},{code:283,name:"fade",parser:v},{code:282,name:"contrast",parser:v},{code:281,name:"brightness",parser:v},{code:280,name:"isClipped",parser:Vt},{code:70,name:"flags",parser:v},{code:340,name:"imageDefHandle",parser:v},{code:13,name:"imageSize",parser:W},{code:12,name:"vPixel",parser:W},{code:11,name:"uPixel",parser:W},{code:10,name:"position",parser:W},{code:90,name:"version",parser:v},{code:100,name:"subclassMarker",parser:v},...jt];class hc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){lc(this,"parser",xt(Vd,Fd))}}function cc(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}lc(hc,"ForEntityName","IMAGE");let Ud={xScale:1,yScale:1,zScale:1,rotation:0,columnCount:0,rowCount:0,columnSpacing:0,rowSpacing:0,extrusionDirection:{x:0,y:0,z:1}},jd=[{code:210,name:"extrusionDirection",parser:W},{code:45,name:"rowSpacing",parser:v},{code:44,name:"columnSpacing",parser:v},{code:71,name:"rowCount",parser:v},{code:70,name:"columnCount",parser:v},{code:50,name:"rotation",parser:v},{code:43,name:"zScale",parser:v},{code:42,name:"yScale",parser:v},{code:41,name:"xScale",parser:v},{code:10,name:"insertionPoint",parser:W},{code:2,name:"name",parser:v},{code:66,name:"isVariableAttributes",parser:Vt},{code:100,name:"subclassMarker",parser:v},...jt];class uc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){cc(this,"parser",xt(jd,Ud))}}function dc(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}cc(uc,"ForEntityName","INSERT");let Gd={isArrowheadEnabled:!0},Wd=[{code:213,name:"offsetFromAnnotation",parser:W},{code:212,name:"offsetFromBlock",parser:W},{code:211,name:"horizontalDirection",parser:W},{code:210,name:"normal",parser:W},{code:340,name:"associatedAnnotation",parser:v},{code:77,name:"byBlockColor",parser:v},{code:10,name:"vertices",parser:W,isMultiple:!0},{code:76,name:"numberOfVertices",parser:v},{code:41,name:"textWidth",parser:v},{code:40,name:"textHeight",parser:v},{code:75,name:"isHooklineExists",parser:Vt},{code:74,name:"isHooklineSameDirection",parser:Vt},{code:73,name:"leaderCreationFlag",parser:v},{code:72,name:"isSpline",parser:Vt},{code:71,name:"isArrowheadEnabled",parser:Vt},{code:3,name:"styleName",parser:v},{code:100,name:"subclassMarker",parser:v},...jt];class pc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){dc(this,"parser",xt(Wd,Gd))}}dc(pc,"ForEntityName","LEADER");(kr={})[kr.TextAnnotation=0]="TextAnnotation",kr[kr.ToleranceAnnotation=1]="ToleranceAnnotation",kr[kr.BlockReferenceAnnotation=2]="BlockReferenceAnnotation",kr[kr.NoAnnotation=3]="NoAnnotation";function mc(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Hd={thickness:0,extrusionDirection:{x:0,y:0,z:1}},qd=[{code:210,name:"extrusionDirection",parser:W},{code:11,name:"endPoint",parser:W},{code:10,name:"startPoint",parser:W},{code:39,name:"thickness",parser:v},{code:100,name:"subclassMarker",parser:v},...jt];class gc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){mc(this,"parser",xt(qd,Hd))}}mc(gc,"ForEntityName","LINE");(Ls={})[Ls.IS_CLOSED=1]="IS_CLOSED",Ls[Ls.PLINE_GEN=128]="PLINE_GEN";let Yd={flag:0,elevation:0,thickness:0,extrusionDirection:{x:0,y:0,z:1},vertices:[]},Xd={bulge:0},Kd=[{code:42,name:"bulge",parser:v},{code:41,name:"endWidth",parser:v},{code:40,name:"startWidth",parser:v},{code:91,name:"id",parser:v},{code:20,name:"y",parser:v},{code:10,name:"x",parser:v}],$d=[{code:210,name:"extrusionDirection",parser:W},{code:10,name:"vertices",isMultiple:!0,parser(i,t){let e={};return xt(Kd,Xd)(i,t,e),e}},{code:39,name:"thickness",parser:v},{code:38,name:"elevation",parser:v},{code:43,name:"constantWidth",parser:v},{code:70,name:"flag",parser:v},{code:90,name:"numberOfVertices",parser:v},{code:100,name:"subclassMarker",parser:v},...jt];class pi{parseEntity(t,e){let n={};return xt($d,Yd)(e,t,n),n}}function fc(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}fa="LWPOLYLINE",(ga="ForEntityName")in pi?Object.defineProperty(pi,ga,{value:fa,enumerable:!0,configurable:!0,writable:!0}):pi[ga]=fa;let Zd=[{code:90,name:"overridenSubEntityCount",parser:v},{code:140,name:"edgeCreaseWeights",parser:v,isMultiple:!0},{code:95,name:"edgeCreaseCount",parser:v},{code:94,parser(i,t,e){e.edgeCount=i.value,e.edgeIndices=[];for(let n=0;n<e.edgeCount;++n){let a=[];i=t.next(),a[0]=i.value,i=t.next(),a[1]=i.value,e.edgeIndices.push(a)}}},{code:93,parser(i,t,e){e.totalFaceIndices=i.value,e.faceIndices=[];let n=[];for(let h=0;h<e.totalFaceIndices&&!St(i,0);++h)i=t.next(),n.push(i.value);let a=0;for(;a<n.length;){let h=n[a++],c=[];for(let m=0;m<h;++m)c.push(n[a++]);e.faceIndices.push(c)}}},{code:10,name:"vertices",parser:W,isMultiple:!0},{code:92,name:"verticesCount",parser:v},{code:91,name:"subdivisionLevel",parser:v},{code:40,name:"blendCrease",parser:v},{code:72,name:"isBlendCreased",parser:Vt},{code:71,name:"version",parser:v},{code:100,name:"subclassMarker",parser:function({value:i}){return i.trim()},pushContext:!0},...jt];class _c{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){fc(this,"parser",xt(Zd))}}function yc(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}fc(_c,"ForEntityName","MESH");let Qd={thickness:0,extrusionDirection:{x:0,y:0,z:1},angle:0},Jd=[{code:50,name:"angle",parser:v},{code:210,name:"extrusionDirection",parser:W},{code:39,name:"thickness",parser:v},{code:10,name:"position",parser:W},{code:100,name:"subclassMarker",parser:v},...jt];class vc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){yc(this,"parser",xt(Jd,Qd))}}yc(vc,"ForEntityName","POINT");(pe={})[pe.CLOSED_POLYLINE=1]="CLOSED_POLYLINE",pe[pe.CURVE_FIT=2]="CURVE_FIT",pe[pe.SPLINE_FIT=4]="SPLINE_FIT",pe[pe.POLYLINE_3D=8]="POLYLINE_3D",pe[pe.POLYGON_3D=16]="POLYGON_3D",pe[pe.CLOSED_POLYGON=32]="CLOSED_POLYGON",pe[pe.POLYFACE=64]="POLYFACE",pe[pe.CONTINUOUS=128]="CONTINUOUS";var li=((Tr={})[Tr.NONE=0]="NONE",Tr[Tr.QUADRATIC=5]="QUADRATIC",Tr[Tr.CUBIC=6]="CUBIC",Tr[Tr.BEZIER=8]="BEZIER",Tr),t0=((me={})[me.CREATED_BY_CURVE_FIT=1]="CREATED_BY_CURVE_FIT",me[me.TANGENT_DEFINED=2]="TANGENT_DEFINED",me[me.NOT_USED=4]="NOT_USED",me[me.CREATED_BY_SPLINE_FIT=8]="CREATED_BY_SPLINE_FIT",me[me.SPLINE_CONTROL_POINT=16]="SPLINE_CONTROL_POINT",me[me.FOR_POLYLINE=32]="FOR_POLYLINE",me[me.FOR_POLYGON=64]="FOR_POLYGON",me[me.POLYFACE=128]="POLYFACE",me);function bc(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let e0={startWidth:0,endWidth:0,bulge:0},r0=[{code:91,name:"id",parser:v},{code:[...Di(71,75)],name:"faces",isMultiple:!0,parser:v},{code:50,name:"tangentDirection",parser:v},{code:70,name:"flag",parser:v},{code:42,name:"bulge",parser:v},{code:41,name:"endWidth",parser:v},{code:40,name:"startWidth",parser:v},{code:30,name:"z",parser:v},{code:20,name:"y",parser:v},{code:10,name:"x",parser:v},{code:100,name:"subclassMarker",parser:v},{code:100},...jt];class io{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){bc(this,"parser",xt(r0,e0))}}function xc(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}bc(io,"ForEntityName","VERTEX");let n0={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:[]},s0=[{code:0,name:"vertices",isMultiple:!0,parser:(i,t)=>St(i,0,"VERTEX")?(i=t.next(),new io().parseEntity(t,i)):no},{code:210,name:"extrusionDirection",parser:W},{code:75,name:"smoothType",parser:v},{code:74,name:"surfaceNDensity",parser:v},{code:73,name:"surfaceMDensity",parser:v},{code:72,name:"meshNVertexCount",parser:v},{code:71,name:"meshMVertexCount",parser:v},{code:41,name:"endWidth",parser:v},{code:40,name:"startWidth",parser:v},{code:70,name:"flag",parser:v},{code:39,name:"thickness",parser:v},{code:30,name:"elevation",parser:v},{code:20},{code:10},{code:66},{code:100,name:"subclassMarker",parser:v},...jt];class wc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){xc(this,"parser",xt(s0,n0))}}function Ac(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}xc(wc,"ForEntityName","POLYLINE");let i0=[{code:11,name:"direction",parser:W},{code:10,name:"position",parser:W},{code:100,name:"subclassMarker",parser:v},...jt];class Pc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Ac(this,"parser",xt(i0))}}function Sc(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Ac(Pc,"ForEntityName","RAY");let a0=[...Zi("data"),{code:70,name:"version",parser:v},{code:100,name:"subclassMarker",parser:v},...jt];class Ic{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Sc(this,"parser",xt(a0))}}function Ec(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Sc(Ic,"ForEntityName","REGION");let o0={vertices:[],backLineVertices:[]},l0=[{code:360,name:"geometrySettingHardId",parser:v},{code:12,name:"backLineVertices",isMultiple:!0,parser:W},{code:93,name:"numberOfBackLineVertices",parser:v},{code:11,name:"vertices",isMultiple:!0,parser:W},{code:92,name:"verticesCount",parser:v},{code:[63,411],name:"indicatorColor",parser:v},{code:70,name:"indicatorTransparency",parser:v},{code:41,name:"bottomHeight",parser:v},{code:40,name:"topHeight",parser:v},{code:10,name:"verticalDirection",parser:W},{code:1,name:"name",parser:v},{code:91,name:"flag",parser:v},{code:90,name:"state",parser:v},{code:100,name:"subclassMarker",parser:v},...jt];class Mc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Ec(this,"parser",xt(l0,o0))}}function kc(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Ec(Mc,"ForEntityName","SECTION");let h0={points:[],thickness:0,extrusionDirection:{x:0,y:0,z:1}},c0=[{code:210,name:"extrusionDirection",parser:W},{code:39,name:"thickness",parser:v},{code:[...Di(10,14)],name:"points",isMultiple:!0,parser:W},{code:100,name:"subclassMarker",parser:v},...jt];class Tc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){kc(this,"parser",xt(c0,h0))}}function Cc(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}kc(Tc,"ForEntityName","SOLID");let u0=[{code:350,name:"historyObjectSoftId",parser:v},{code:100,name:"subclassMarker",parser:v},...Zi("data"),{code:70,name:"version",parser:v},{code:100},...jt];class Nc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Cc(this,"parser",xt(u0))}}Cc(Nc,"ForEntityName","3DSOLID");(Ge={})[Ge.NONE=0]="NONE",Ge[Ge.CLOSED=1]="CLOSED",Ge[Ge.PERIODIC=2]="PERIODIC",Ge[Ge.RATIONAL=4]="RATIONAL",Ge[Ge.PLANAR=8]="PLANAR",Ge[Ge.LINEAR=16]="LINEAR";function Lc(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let d0={knotTolerance:1e-6,controlTolerance:1e-6,fitTolerance:1e-9,knotValues:[],controlPoints:[],fitPoints:[]},p0=[{code:11,name:"fitPoints",isMultiple:!0,parser:W},{code:10,name:"controlPoints",isMultiple:!0,parser:W},{code:41,name:"weights",isMultiple:!0,parser:v},{code:40,name:"knots",isMultiple:!0,parser:v},{code:13,name:"endTangent",parser:W},{code:12,name:"startTangent",parser:W},{code:44,name:"fitTolerance",parser:v},{code:43,name:"controlTolerance",parser:v},{code:42,name:"knotTolerance",parser:v},{code:74,name:"numberOfFitPoints",parser:v},{code:73,name:"numberOfControlPoints",parser:v},{code:72,name:"numberOfKnots",parser:v},{code:71,name:"degree",parser:v},{code:70,name:"flag",parser:v},{code:210,name:"normal",parser:W},{code:100,name:"subclassMarker",parser:v},...jt];class Oc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Lc(this,"parser",xt(p0,d0))}}Lc(Oc,"ForEntityName","SPLINE");class mi{parseEntity(t,e){let n={};for(;!t.isEOF();){if(e.code===0){t.rewind();break}switch(e.code){case 100:n.subclassMarker=e.value,e=t.next();break;case 2:n.name=e.value,e=t.next();break;case 5:n.handle=e.value,e=t.next();break;case 10:n.startPoint=Zr(Rt(t)),e=t.lastReadGroup;break;case 11:n.directionVector=Zr(Rt(t)),e=t.lastReadGroup;break;case 90:n.tableValue=e.value,e=t.next();break;case 91:n.rowCount=e.value,e=t.next();break;case 92:n.columnCount=e.value,e=t.next();break;case 93:n.overrideFlag=e.value,e=t.next();break;case 94:n.borderColorOverrideFlag=e.value,e=t.next();break;case 95:n.borderLineWeightOverrideFlag=e.value,e=t.next();break;case 96:n.borderVisibilityOverrideFlag=e.value,e=t.next();break;case 141:n.rowHeightArr??(n.rowHeightArr=[]),n.rowHeightArr.push(e.value),e=t.next();break;case 142:n.columnWidthArr??(n.columnWidthArr=[]),n.columnWidthArr.push(e.value),e=t.next();break;case 280:n.version=e.value,e=t.next();break;case 310:n.bmpPreview??(n.bmpPreview=""),n.bmpPreview+=e.value,e=t.next();break;case 330:n.ownerDictionaryId=e.value,e=t.next();break;case 342:n.tableStyleId=e.value,e=t.next();break;case 343:n.blockRecordHandle=e.value,e=t.next();break;case 170:n.attachmentPoint=e.value,e=t.next();break;case 171:n.cells??(n.cells=[]),n.cells.push(function(a,h){let c=!1,m=!1,b={};for(;!a.isEOF()&&h.code!==0&&!m;)switch(h.code){case 171:if(c){m=!0;continue}b.cellType=h.value,c=!0,h=a.next();break;case 172:b.flagValue=h.value,h=a.next();break;case 173:b.mergedValue=h.value,h=a.next();break;case 174:b.autoFit=h.value,h=a.next();break;case 175:b.borderWidth=h.value,h=a.next();break;case 176:b.borderHeight=h.value,h=a.next();break;case 91:b.overrideFlag=h.value,h=a.next();break;case 178:b.virtualEdgeFlag=h.value,h=a.next();break;case 145:b.rotation=h.value,h=a.next();break;case 345:b.fieldObjetId=h.value,h=a.next();break;case 340:b.blockTableRecordId=h.value,h=a.next();break;case 146:b.blockScale=h.value,h=a.next();break;case 177:b.blockAttrNum=h.value,h=a.next();break;case 7:b.textStyle=h.value,h=a.next();break;case 140:b.textHeight=h.value,h=a.next();break;case 170:b.attachmentPoint=h.value,h=a.next();break;case 92:b.extendedCellFlags=h.value,h=a.next();break;case 285:b.rightBorderVisibility=!!(h.value??!0),h=a.next();break;case 286:b.bottomBorderVisibility=!!(h.value??!0),h=a.next();break;case 288:b.leftBorderVisibility=!!(h.value??!0),h=a.next();break;case 289:b.topBorderVisibility=!!(h.value??!0),h=a.next();break;case 301:(function(f,w,x){for(;x.code!==304;)switch(x.code){case 301:case 93:case 90:case 94:x=w.next();break;case 1:f.text=x.value,x=w.next();break;case 300:f.attrText=x.value,x=w.next();break;case 302:f.text=x.value?x.value:f.text,x=w.next();break;default:console.log(`Ignore code: ${x.code}, value: ${x.value}`),x=w.next()}})(b,a,h),h=a.next();break;default:return b}return c=!1,m=!1,b}(t,e)),e=t.lastReadGroup;break;default:so(n,e,t),e=t.next()}}return n}}function Bc(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}ya="ACAD_TABLE",(_a="ForEntityName")in mi?Object.defineProperty(mi,_a,{value:ya,enumerable:!0,configurable:!0,writable:!0}):mi[_a]=ya;let m0=[{code:11,name:"xAxisDirection",parser:W},{code:210,name:"extrusionDirection",parser:W},{code:1,name:"text",parser:v},{code:10,name:"position",parser:W},{code:3,name:"styleName",parser:v},{code:100,name:"subclassMarker",parser:v},...jt];class zc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Bc(this,"parser",xt(m0))}}Bc(zc,"ForEntityName","TOLERANCE");class gi{parseEntity(t,e){let n={};for(;e!=="EOF";){if(e.code===0){t.rewind();break}!function(a,h,c){if(c==="EOF")return!1;switch(c.code){case 0:return!1;case 8:a.layer=c.value;break;case 100:a.subclassMarker=c.value;break;case 10:a.viewportCenter=Zr(Rt(h));break;case 40:a.width=c.value;break;case 41:a.height=c.value;break;case 68:a.status=c.value;break;case 69:a.viewportId=c.value;break;case 12:a.displayCenter=Rt(h);break;case 13:a.snapBase=Rt(h);break;case 14:a.snapSpacing=Rt(h);break;case 15:a.gridSpacing=Rt(h);break;case 16:a.viewDirection=Zr(Rt(h));break;case 17:a.targetPoint=Zr(Rt(h));break;case 42:a.perspectiveLensLength=c.value;break;case 43:a.frontClipZ=c.value;break;case 44:a.backClipZ=c.value;break;case 45:a.viewHeight=c.value;break;case 50:a.snapAngle=c.value;break;case 51:a.viewTwistAngle=c.value;break;case 72:a.circleZoomPercent=c.value;break;case 331:a.frozenLayerIds??(a.frozenLayerIds=[]),a.frozenLayerIds.push(c.value);break;case 90:a.statusBitFlags=c.value;break;case 340:a.clippingBoundaryId=c.value;break;case 1:a.sheetName=c.value;break;case 281:a.renderMode=c.value;break;case 71:a.ucsPerViewport=c.value;break;case 110:a.ucsOrigin=Zr(Rt(h));break;case 111:a.ucsXAxis=Zr(Rt(h));break;case 112:a.ucsYAxis=Zr(Rt(h));break;case 345:a.ucsId=c.value;break;case 346:a.ucsBaseId=c.value;break;case 79:a.orthographicType=c.value;break;case 146:a.elevation=c.value;break;case 170:a.shadePlotMode=c.value;break;case 61:a.majorGridFrequency=c.value;break;case 332:a.backgroundId=c.value;break;case 333:a.shadePlotId=c.value;break;case 348:a.visualStyleId=c.value;break;case 292:a.isDefaultLighting=!!c.value;break;case 282:a.defaultLightingType=c.value;break;case 141:a.brightness=c.value;break;case 142:a.contrast=c.value;break;case 63:case 421:case 431:a.ambientLightColor=c.value;break;case 361:a.sunId=c.value;break;case 335:case 343:case 344:case 91:a.softPointer=c.value}return!0}(n,t,e)&&so(n,e,t),e=t.next()}return n}}ba="VIEWPORT",(va="ForEntityName")in gi?Object.defineProperty(gi,va,{value:ba,enumerable:!0,configurable:!0,writable:!0}):gi[va]=ba;(Cr={})[Cr.ShowImage=1]="ShowImage",Cr[Cr.ShowImageWhenNotAligned=2]="ShowImageWhenNotAligned",Cr[Cr.UseClippingBoundary=4]="UseClippingBoundary",Cr[Cr.Transparency=8]="Transparency";function Rc(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let g0={brightness:50,constrast:50,fade:0},f0=[{code:14,name:"boundary",isMultiple:!0,parser:W},{code:91,name:"numberOfVertices",parser:v},{code:71,name:"boundaryType",parser:v},{code:360,name:"imageDefReactorHardId",parser:v},{code:283,name:"fade",parser:v},{code:282,name:"contrast",parser:v},{code:281,name:"brightness",parser:v},{code:280,name:"isClipping",parser:Vt},{code:70,name:"displayFlag",parser:v},{code:340,name:"imageDefHardId",parser:v},{code:13,name:"imageSize",parser:W},{code:12,name:"vDirection",parser:W},{code:11,name:"uDirection",parser:W},{code:10,name:"position",parser:W},{code:90,name:"classVersion",parser:v},{code:100,name:"subclassMarker",parser:v},...jt];class Dc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Rc(this,"parser",xt(f0,g0))}}function Fc(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Rc(Dc,"ForEntityName","WIPEOUT");let _0=[{code:11,name:"direction",parser:W},{code:10,name:"position",parser:W},{code:100,name:"subclassMarker",parser:v},...jt];class Vc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Fc(this,"parser",xt(_0))}}function Uc(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Fc(Vc,"ForEntityName","XLINE");let y0={},v0=[{code:170,name:"multileaderType",parser:v},{code:291,name:"doglegEnabled",parser:Vt},{code:40,name:"doglegLength",parser:v},{code:172,name:"contentType",parser:v},{code:3,name:"textContent",parser:v},{code:12,name:"textAnchor",parser:W},{code:344,name:"blockHandle",parser:v},{code:15,name:"blockPosition",parser:W},{code:302,name:"leaderSections",parser:function(i,t,e){let n,a={leaderLines:[]};for(;t.hasNext()&&(n=t.next()).code!==303;)switch(n.code){case 10:a.landingPoint=(n.value,Rt(t));break;case 11:a.doglegVector=(n.value,Rt(t));break;case 40:a.doglegLength=n.value;break;case 304:a.leaderLines.push(function(h,c,m){let b,f={vertices:[]};for(;c.hasNext()&&(b=c.next()).code!==305;)b.code===10&&f.vertices.push((b.value,Rt(c)));return f}(0,t))}return a},isMultiple:!0},...jt];class jc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Uc(this,"parser",xt(v0,y0))}}Uc(jc,"ForEntityName","MULTILEADER");let b0=Object.fromEntries([Vh,qh,$h,Qh,tc,di,rc,sc,hc,uc,pc,gc,pi,_c,Xh,jc,vc,wc,Pc,Ic,Mc,Tc,Nc,Oc,mi,Wh,zc,oc,io,gi,Dc,Vc].map(i=>[i.ForEntityName,new i]));function Gc(i,t){let e=[];for(;!St(i,0,"EOF");){if(i.code===0){if(i.value==="ENDBLK"||i.value==="ENDSEC"){t.rewind();break}let n=b0[i.value];if(n){let a=i.value;i=t.next();let h=n.parseEntity(t,i);h.type=a,Rh(h),e.push(h)}else t.debug&&console.warn(`Unsupported ENTITY type: ${i.value}`)}i=t.next()}return e}function x0(i,t){let e={};for(;!St(i,0,"EOF")&&!St(i,0,"ENDSEC");){if(St(i,0,"BLOCK")){let n=w0(i=t.next(),t);Rh(n),n.name&&(e[n.name]=n)}i=t.next()}return e}function w0(i,t){let e={};for(;!St(i,0,"EOF");){if(St(i,0,"ENDBLK")){for(i=t.next();!St(i,0,"EOF");){if(St(i,100,"AcDbBlockEnd"))return e;i=t.next()}break}switch(i.code){case 1:e.xrefPath=i.value;break;case 2:e.name=i.value;break;case 3:e.name2=i.value;break;case 5:e.handle=i.value;break;case 8:e.layer=i.value;break;case 10:e.position=Rt(t);break;case 67:e.paperSpace=!!i.value&&i.value==1;break;case 70:i.value!==0&&(e.type=i.value);break;case 100:break;case 330:e.ownerHandle=i.value;break;case 0:e.entities=Gc(i,t)}i=t.next()}return e}function A0(i,t){let e=null,n={};for(;!St(i,0,"EOF")&&!St(i,0,"ENDSEC");)i.code===9?e=i.value:i.code===10?n[e]=Rt(t):n[e]=i.value,i=t.next();return n}(We={})[We.NOT_APPLICABLE=0]="NOT_APPLICABLE",We[We.KEEP_EXISTING=1]="KEEP_EXISTING",We[We.USE_CLONE=2]="USE_CLONE",We[We.XREF_VALUE_NAME=3]="XREF_VALUE_NAME",We[We.VALUE_NAME=4]="VALUE_NAME",We[We.UNMANGLE_NAME=5]="UNMANGLE_NAME";let ao=[{code:330,name:"ownerObjectId",parser:v},{code:102,parser:xn},{code:102,parser:xn},{code:102,parser:xn},{code:5,name:"handle",parser:v}],P0=[{code:3,name:"entries",parser:(i,t)=>{let e={name:i.value};return(i=t.next()).code===350?e.objectSoftId=i.value:i.code===360?e.objectHardId=i.value:t.rewind(),e},isMultiple:!0},{code:281,name:"recordCloneFlag",parser:v},{code:280,name:"isHardOwned",parser:Vt},{code:100,name:"subclassMarker",parser:v},...ao],S0=[{code:330,name:"imageDefReactorIdSoft",isMultiple:!0,parser:v},{code:90,name:"version",parser:v},{code:1,name:"fileName",parser:v},{code:10,name:"size",parser:W},{code:11,name:"sizeOfOnePixel",parser:W},{code:280,name:"isLoaded",parser:v},{code:281,name:"resolutionUnits",parser:v},{code:100,name:"subclassMarker",parser:v}];(mn={})[mn.NOUNIT=0]="NOUNIT",mn[mn.CENTIMETERS=2]="CENTIMETERS",mn[mn.INCH=5]="INCH";(Os={})[Os.PSLTSCALE=1]="PSLTSCALE",Os[Os.LIMCHECK=2]="LIMCHECK";(gn={})[gn.INCHES=0]="INCHES",gn[gn.MILLIMETERS=1]="MILLIMETERS",gn[gn.PIXELS=2]="PIXELS";(He={})[He.LAST_SCREEN_DISPLAY=0]="LAST_SCREEN_DISPLAY",He[He.DRAWING_EXTENTS=1]="DRAWING_EXTENTS",He[He.DRAWING_LIMITS=2]="DRAWING_LIMITS",He[He.VIEW_SPECIFIED=3]="VIEW_SPECIFIED",He[He.WINDOW_SPECIFIED=4]="WINDOW_SPECIFIED",He[He.LAYOUT_INFORMATION=5]="LAYOUT_INFORMATION";(Nr={})[Nr.AS_DISPLAYED=0]="AS_DISPLAYED",Nr[Nr.WIREFRAME=1]="WIREFRAME",Nr[Nr.HIDDEN=2]="HIDDEN",Nr[Nr.RENDERED=3]="RENDERED";(qe={})[qe.DRAFT=0]="DRAFT",qe[qe.PREVIEW=1]="PREVIEW",qe[qe.NORMAL=2]="NORMAL",qe[qe.PRESENTATION=3]="PRESENTATION",qe[qe.MAXIMUM=4]="MAXIMUM",qe[qe.CUSTOM=5]="CUSTOM";let Wc=[{code:333,name:"shadePlotId",parser:v},{code:149,name:"imageOriginY",parser:v},{code:148,name:"imageOriginX",parser:v},{code:147,name:"scaleFactor",parser:v},{code:78,name:"shadePlotCustomDPI",parser:v},{code:77,name:"shadePlotResolution",parser:v},{code:76,name:"shadePlotMode",parser:v},{code:75,name:"standardScaleType",parser:v},{code:7,name:"currentStyleSheet",parser:v},{code:74,name:"plotType",parser:v},{code:73,name:"plotRotation",parser:v},{code:72,name:"plotPaperUnit",parser:v},{code:70,name:"layoutFlag",parser:v},{code:143,name:"printScaleDenominator",parser:v},{code:142,name:"printScaleNumerator",parser:v},{code:141,name:"windowAreaYMax",parser:v},{code:140,name:"windowAreaXMax",parser:v},{code:49,name:"windowAreaYMin",parser:v},{code:48,name:"windowAreaXMin",parser:v},{code:47,name:"plotOriginY",parser:v},{code:46,name:"plotOriginX",parser:v},{code:45,name:"paperHeight",parser:v},{code:44,name:"paperWidth",parser:v},{code:43,name:"marginTop",parser:v},{code:42,name:"marginRight",parser:v},{code:41,name:"marginBottom",parser:v},{code:40,name:"marginLeft",parser:v},{code:6,name:"plotViewName",parser:v},{code:4,name:"paperSize",parser:v},{code:2,name:"configName",parser:v},{code:1,name:"pageSetupName",parser:v},{code:100,name:"subclassMarker",parser:v},...ao],I0=[{code:346,name:"orthographicUcsId",parser:v},{code:345,name:"namedUcsId",parser:v},{code:331,name:"viewportId",parser:v},{code:330,name:"paperSpaceTableId",parser:v},{code:76,name:"orthographicType",parser:v},{code:17,name:"ucsYAxis",parser:W},{code:16,name:"ucsXAxis",parser:W},{code:13,name:"ucsOrigin",parser:W},{code:146,name:"elevation",parser:v},{code:15,name:"maxExtent",parser:W},{code:14,name:"minExtent",parser:W},{code:12,name:"insertionPoint",parser:W},{code:11,name:"maxLimit",parser:W},{code:10,name:"minLimit",parser:W},{code:71,name:"tabOrder",parser:v},{code:70,name:"controlFlag",parser:v},{code:1,name:"layoutName",parser:v},{code:100,name:"subclassMarker",parser:v},...Wc],E0=[{code:40,name:"wcsToOCSTransform",parser:xl},{code:40,name:"ocsToWCSTransform",parser:xl},{code:41,name:"backClippingDistance",parser:v},{code:73,name:"isBackClipping",parser:Vt,pushContext:!0},{code:40,name:"frontClippingDistance",parser:v},{code:72,name:"isFrontClipping",parser:Vt,pushContext:!0},{code:71,name:"isClipBoundaryDisplayed",parser:Vt},{code:11,name:"position",parser:W},{code:210,name:"normal",parser:W},{code:10,name:"boundaryVertices",parser:W,isMultiple:!0},{code:70,name:"boundaryCount",parser:v},{code:100,name:"subclassMarker",parser:v},{code:100},...ao];function xl(i,t){let e=[];for(let n=0;n<3&&St(i,40);++n){let a=[];for(let h=0;h<4&&St(i,40);++h)a.push(i.value),i=t.next();e.push(a)}return t.rewind(),e}let M0={LAYOUT:I0,PLOTSETTINGS:Wc,DICTIONARY:P0,SPATIAL_FILTER:E0,IMAGEDEF:S0};function k0(i,t){let e=[];for(;i.code!==0||!["EOF","ENDSEC"].includes(i.value);){let n=i.value,a=M0[n];if(i.code===0&&(a!=null&&a.length)){let h=xt(a),c={name:n};h(i=t.next(),t,c)?(e.push(c),i=t.peek()):i=t.next()}else i=t.next()}return{byName:vd(e,({name:n})=>n)}}let Qn=[{code:100,name:"subclassMarker",parser:v},{code:330,name:"ownerObjectId",parser:v},{code:102,parser(i,t){for(;!St(i,0,"EOF")&&!St(i,102,"}");)i=t.next()}},{code:5,name:"handle",parser:v}],T0=xt([{code:310,name:"bmpPreview",parser:v},{code:281,name:"scalability",parser:v},{code:280,name:"explodability",parser:v},{code:70,name:"insertionUnits",parser:v},{code:340,name:"layoutObjects",parser:v},{code:2,name:"name",parser:v},{code:100,name:"subclassMarker",parser:v},...Qn]),C0=[{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:vl.Above,defaultValueImperial:vl.Center},{name:"DIMZIN",code:78,defaultValue:Un.Trailing,defaultValueImperial:Un.Feet},{name:"DIMAZIN",code:79,defaultValue:sd.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:id.Center},{name:"DIMSD1",code:281,defaultValue:0},{name:"DIMSD2",code:282,defaultValue:0},{name:"DIMTOLJ",code:283,defaultValue:ad.Center},{name:"DIMTZIN",code:284,defaultValue:Un.Trailing,defaultValueImperial:Un.Feet},{name:"DIMALTZ",code:285,defaultValue:Un.Trailing},{name:"DIMALTTZ",code:286,defaultValue:Un.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}],N0=xt([...C0.map(i=>({...i,parser:v})),{code:70,name:"standardFlag",parser:v},{code:2,name:"name",parser:v},{code:100,name:"subclassMarker",parser:v},{code:105,name:"handle",parser:v},...Qn.filter(i=>i.code!==5)]),L0=xt([{code:347,name:"materialObjectId",parser:v},{code:390,name:"plotStyleNameObjectId",parser:v},{code:370,name:"lineweight",parser:v},{code:290,name:"isPlotting",parser:Vt},{code:6,name:"lineType",parser:v},{code:62,name:"colorIndex",parser:v},{code:70,name:"standardFlag",parser:v},{code:2,name:"name",parser:v},{code:100,name:"subclassMarker",parser:v},...Qn]);(Lr={})[Lr.NONE=0]="NONE",Lr[Lr.AbsoluteRotation=1]="AbsoluteRotation",Lr[Lr.TextEmbedded=2]="TextEmbedded",Lr[Lr.ShapeEmbedded=4]="ShapeEmbedded";let O0=xt([{code:9,name:"text",parser:v},{code:45,name:"offsetY",parser:v},{code:44,name:"offsetX",parser:v},{code:50,name:"rotation",parser:v},{code:46,name:"scale",parser:v},{code:340,name:"styleObjectId",parser:v},{code:75,name:"shapeNumber",parser:v},{code:74,name:"elementTypeFlag",parser:v},{code:49,name:"elementLength",parser:v}],{elementTypeFlag:0,elementLength:0}),B0=xt([{code:49,name:"pattern",parser(i,t){let e={};return O0(i,t,e),e},isMultiple:!0},{code:40,name:"totalPatternLength",parser:v},{code:73,name:"numberOfLineTypes",parser:v},{code:72,parser:v},{code:3,name:"description",parser:v},{code:70,name:"standardFlag",parser:v},{code:2,name:"name",parser:v},{code:100,name:"subclassMarker",parser:v},...Qn]),z0=xt([{code:1e3,name:"extendedFont",parser:v},{code:1001},{code:4,name:"bigFont",parser:v},{code:3,name:"font",parser:v},{code:42,name:"lastHeight",parser:v},{code:71,name:"textGenerationFlag",parser:v},{code:50,name:"obliqueAngle",parser:v},{code:41,name:"widthFactor",parser:v},{code:40,name:"fixedTextHeight",parser:v},{code:70,name:"standardFlag",parser:v},{code:2,name:"name",parser:v},{code:100,name:"subclassMarker",parser:v},...Qn]),R0=xt([{code:[63,421,431],name:"ambientColor",parser:v},{code:142,name:"contrast",parser:v},{code:141,name:"brightness",parser:v},{code:282,name:"defaultLightingType",parser:v},{code:292,name:"isDefaultLightingOn",parser:Vt},{code:348,name:"visualStyleObjectId",parser:v},{code:333,name:"shadePlotObjectId",parser:v},{code:332,name:"backgroundObjectId",parser:v},{code:61,name:"majorGridLines",parser:v},{code:170,name:"shadePlotSetting",parser:v},{code:146,name:"elevation",parser:v},{code:79,name:"orthographicType",parser:v},{code:112,name:"ucsYAxis",parser:W},{code:111,name:"ucsXAxis",parser:W},{code:110,name:"ucsOrigin",parser:W},{code:74,name:"ucsIconSetting",parser:v},{code:71,name:"viewMode",parser:v},{code:281,name:"renderMode",parser:v},{code:1,name:"styleSheet",parser:v},{code:[331,441],name:"frozenLayers",parser:v,isMultiple:!0},{code:72,name:"circleSides",parser:v},{code:51,name:"viewTwistAngle",parser:v},{code:50,name:"snapRotationAngle",parser:v},{code:45,name:"viewHeight",parser:v},{code:44,name:"backClippingPlane",parser:v},{code:43,name:"frontClippingPlane",parser:v},{code:42,name:"lensLength",parser:v},{code:17,name:"viewTarget",parser:W},{code:16,name:"viewDirectionFromTarget",parser:W},{code:15,name:"gridSpacing",parser:W},{code:14,name:"snapSpacing",parser:W},{code:13,name:"snapBasePoint",parser:W},{code:12,name:"center",parser:W},{code:11,name:"upperRightCorner",parser:W},{code:10,name:"lowerLeftCorner",parser:W},{code:70,name:"standardFlag",parser:v},{code:2,name:"name",parser:v},{code:100,name:"subclassMarker",parser:v},...Qn]),D0={BLOCK_RECORD:T0,DIMSTYLE:N0,LAYER:L0,LTYPE:B0,STYLE:z0,VPORT:R0},F0=xt([{code:70,name:"maxNumberOfEntries",parser:v},{code:100,name:"subclassMarker",parser:v},{code:330,name:"ownerObjectId",parser:v},{code:102},{code:360,isMultiple:!0},{code:102},{code:5,name:"handle",parser:v},{code:2,name:"name",parser:v}]);function V0(i,t){var n;let e={};for(;!St(i,0,"EOF")&&!St(i,0,"ENDSEC");){if(St(i,0,"TABLE")){i=t.next();let a={entries:[]};F0(i,t,a),e[a.name]=a}if(St(i,0)&&!St(i,0,"ENDTAB")){let a=i.value;i=t.next();let h=D0[a];if(!h){t.debug&&console.warn(`parseTable: Invalid table name '${a}'`),i=t.next();continue}let c={};h(i,t,c),(n=e[a])==null||n.entries.push(c)}i=t.next()}return e}function Bs(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}class wl{next(){if(!this.hasNext())return this._eof?this.debug&&console.warn("Cannot call 'next' after EOF group has been read"):this.debug&&console.warn("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]),{code:0,value:"EOF"};let t=parseInt(this._data[this._pointer++],10),e=Al(t,this._data[this._pointer++],this.debug),n={code:t,value:e};return St(n,0,"EOF")&&(this._eof=!0),this.lastReadGroup=n,n}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=Al(t.code,this._data[this._pointer+1],this.debug),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,e=!1){Bs(this,"_data",void 0),Bs(this,"debug",void 0),Bs(this,"_pointer",void 0),Bs(this,"_eof",void 0),Bs(this,"lastReadGroup",void 0),this._data=t,this.debug=e,this.lastReadGroup={code:0,value:0},this._pointer=0,this._eof=!1}}function Al(i,t,e=!1){return i<=9?t:i>=10&&i<=59?parseFloat(t.trim()):i>=60&&i<=99?parseInt(t.trim()):i>=100&&i<=109?t:i>=110&&i<=149?parseFloat(t.trim()):i>=160&&i<=179?parseInt(t.trim()):i>=210&&i<=239?parseFloat(t.trim()):i>=270&&i<=289?parseInt(t.trim()):i>=290&&i<=299?function(n){if(n==="0")return!1;if(n==="1")return!0;throw TypeError("String '"+n+"' cannot be cast to Boolean type")}(t.trim()):i>=300&&i<=369?t:i>=370&&i<=389?parseInt(t.trim()):i>=390&&i<=399?t:i>=400&&i<=409?parseInt(t.trim()):i>=410&&i<=419?t:i>=420&&i<=429?parseInt(t.trim()):i>=430&&i<=439?t:i>=440&&i<=459?parseInt(t.trim()):i>=460&&i<=469?parseFloat(t.trim()):i>=470&&i<=481||i===999||i>=1e3&&i<=1009?t:i>=1010&&i<=1059?parseFloat(t.trim()):i>=1060&&i<=1071?parseInt(t.trim()):(e&&console.warn("WARNING: Group code does not have a defined type: %j",{code:i,value:t}),t)}function Na(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}class U0{constructor(){Na(this,"encoding","utf-8"),Na(this,"encodingFailureFatal",!1)}}class j0 extends EventTarget{parseSync(t,e=!1){let n=new wl(t.split(/\r\n|\r|\n/g),e);if(!n.hasNext())throw Error("Empty file");return this.parseAll(n)}parseStream(t){let e="",n=this;return new Promise((a,h)=>{t.on("data",c=>{e+=c}),t.on("end",()=>{try{let c=e.split(/\r\n|\r|\n/g),m=new wl(c);if(!m.hasNext())throw Error("Empty file");a(n.parseAll(m))}catch(c){h(c)}}),t.on("error",c=>{h(c)})})}async parseFromUrl(t,e){let n=await fetch(t,e);if(!n.body)return null;let a=n.body.getReader(),h="";for(;;){let{done:c,value:m}=await a.read();if(c){h+=this._decoder.decode(new ArrayBuffer(0),{stream:!1});break}h+=this._decoder.decode(m,{stream:!0})}return this.parseSync(h)}parseAll(t){let e={header:{},blocks:{},entities:[],tables:{},objects:{byName:{},byTree:void 0}},n=t.next();for(;!St(n,0,"EOF");)St(n,0,"SECTION")&&(St(n=t.next(),2,"HEADER")?(n=t.next(),e.header=A0(n,t)):St(n,2,"BLOCKS")?(n=t.next(),e.blocks=x0(n,t)):St(n,2,"ENTITIES")?(n=t.next(),e.entities=Gc(n,t)):St(n,2,"TABLES")?(n=t.next(),e.tables=V0(n,t)):St(n,2,"OBJECTS")&&(n=t.next(),e.objects=k0(n,t))),n=t.next();return e}constructor(t=new U0){super(),Na(this,"_decoder",void 0),this._decoder=new TextDecoder(t.encoding,{fatal:t.encodingFailureFatal})}}const Pl=[{name:"AC1.2",value:1},{name:"AC1.40",value:2},{name:"AC1.50",value:3},{name:"AC2.20",value:4},{name:"AC2.10",value:5},{name:"AC2.21",value:6},{name:"AC2.22",value:7},{name:"AC1001",value:8},{name:"AC1002",value:9},{name:"AC1003",value:10},{name:"AC1004",value:11},{name:"AC1005",value:12},{name:"AC1006",value:13},{name:"AC1007",value:14},{name:"AC1008",value:15},{name:"AC1009",value:16},{name:"AC1010",value:17},{name:"AC1011",value:18},{name:"AC1012",value:19},{name:"AC1013",value:20},{name:"AC1014",value:21},{name:"AC1500",value:22},{name:"AC1015",value:23},{name:"AC1800a",value:24},{name:"AC1018",value:25},{name:"AC2100a",value:26},{name:"AC1021",value:27},{name:"AC2400a",value:28},{name:"AC1024",value:29},{name:"AC1027",value:31},{name:"AC3200a",value:32},{name:"AC1032",value:33}];class Fi{constructor(t){if(typeof t=="string"){const e=Pl.find(n=>n.name===t);if(!e)throw new Error(`Unknown DWG version name: ${t}`);this.name=e.name,this.value=e.value;return}if(typeof t=="number"){const e=Pl.find(n=>n.value===t);if(!e)throw new Error(`Unknown DWG version value: ${t}`);this.name=e.name,this.value=e.value;return}throw new Error("Invalid constructor argument for AcDbDwgVersion")}}class G0{parse(t){const e=new j0,n=this.getDxfInfoFromBuffer(t);let a="";return n.version&&n.version.value<=23&&n.encoding?a=new TextDecoder(n.encoding).decode(t):a=new TextDecoder().decode(t),e.parseSync(a)}getDxfInfoFromBuffer(t){var f,w,x;const n=new TextDecoder("utf-8");let a=0,h="",c=null,m=null,b=!1;for(;a<t.byteLength;){const I=Math.min(a+65536,t.byteLength),M=t.slice(a,I);a=I;const L=(h+n.decode(M,{stream:!0})).split(/\r?\n/);h=L.pop()??"";for(let F=0;F<L.length;F++){const D=L[F].trim();if(D==="SECTION"&&((f=L[F+2])==null?void 0:f.trim())==="HEADER")b=!0;else if(D==="ENDSEC"&&b)return{version:c,encoding:m};if(b&&D==="$ACADVER"){const dt=(w=L[F+2])==null?void 0:w.trim();dt&&(c=new Fi(dt))}else if(b&&D==="$DWGCODEPAGE"){const dt=(x=L[F+2])==null?void 0:x.trim();if(dt){const vt=Ra[dt];m=zl(vt)}}if(c&&m)return{version:c,encoding:m}}}return{version:c,encoding:m}}}class Sl{convert(t){const e=this.createEntity(t);return e&&this.processCommonAttrs(t,e),e}createEntity(t){return t.type=="3DFACE"?this.convertFace(t):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=="LWPOLYLINE"?this.convertLWPolyline(t):t.type=="MTEXT"?this.convertMText(t):t.type=="POLYLINE"?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}convertFace(t){const e=new Ai;return t.vertices.forEach((n,a)=>e.setVertexAt(a,n)),e}convertArc(t){return new bi(t.center,t.radius,Pt.degToRad(t.startAngle),Pt.degToRad(t.endAngle),t.extrusionDirection??X.Z_AXIS)}convertCirle(t){return new xi(t.center,t.radius,t.extrusionDirection??X.Z_AXIS)}convertEllipse(t){const e=new X(t.majorAxisEndPoint),n=e.length();return new wi(t.center,t.extrusionDirection??X.Z_AXIS,e,n,n*t.axisRatio,t.startAngle,t.endAngle)}convertLine(t){const e=t.startPoint,n=t.endPoint;return new Ys(new G(e.x,e.y,e.z||0),new G(n.x,n.y,n.z||0))}convertSpline(t){try{if(t.numberOfControlPoints>0&&t.numberOfKnots>0)return new Ks(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 Ks(e,"Uniform",t.degree,!!(t.flag&1))}}catch(e){console.log(`Failed to convert spline with error: ${e}`)}return null}convertPoint(t){const e=new Mi;return e.position=t.position,e}convertSolid(t){const e=new Ii;return t.points.forEach((n,a)=>e.setPointAt(a,n)),e.thickness=t.thickness,e}convertPolyline(t){const e=!!(t.flag&1),n=!!(t.flag&8),a=[],h=[];if(t.vertices.map(c=>{c.flag&t0.SPLINE_CONTROL_POINT||(a.push({x:c.x,y:c.y,z:c.z}),h.push(c.bulge??0))}),n){let c=js.SimplePoly;return t.flag&4&&(t.smoothType==li.CUBIC?c=js.CubicSplinePoly:t.smoothType==li.QUADRATIC&&(c=js.QuadSplinePoly)),new vi(c,a,e)}else{let c=jn.SimplePoly;return t.flag&2?c=jn.FitCurvePoly:t.flag&4&&(t.smoothType==li.CUBIC?c=jn.CubicSplinePoly:t.smoothType==li.QUADRATIC&&(c=jn.QuadSplinePoly)),new yi(c,a,0,e,t.startWidth,t.endWidth,h)}}convertLWPolyline(t){const e=new Ei;return e.closed=!!(t.flag&1),t.vertices.forEach((n,a)=>{e.addVertexAt(a,new Tt(n.x,n.y),n.bulge,n.startWidth,n.endWidth)}),e}convertHatch(t){var a;const e=new qs;return(a=t.definitionLines)==null||a.forEach(h=>{e.definitionLines.push({angle:h.angle,base:h.base,offset:h.offset,dashLengths:h.numberOfDashLengths>0?h.dashLengths:[]})}),e.isSolidFill=t.solidFill==od.SolidFill,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 m=h,b=new An;b.closed=m.isClosed,m.vertices.forEach((f,w)=>{b.addVertexAt(w,{x:f.x,y:f.y,bulge:f.bulge})}),e.add(b)}else{const m=h,b=new Ka;m.edges.forEach(f=>{if(f.type==1){const w=f;b.add(new Us(w.start,w.end))}else if(f.type==2){const w=f;b.add(new Wn(w.center,w.radius,Pt.degToRad(w.startAngle||0),Pt.degToRad(w.endAngle||0),!w.isCCW))}else if(f.type==3){const w=f;new Jt().subVectors(w.end,w.center);const I=Math.sqrt(Math.pow(w.end.x,2)+Math.pow(w.end.y,2)),M=I*w.lengthOfMinorAxis;let O=Pt.degToRad(w.startAngle||0),L=Pt.degToRad(w.endAngle||0);const F=Math.atan2(w.end.y,w.end.x);w.isCCW||(O=Math.PI*2-O,L=Math.PI*2-L),b.add(new Yi({...w.center,z:0},I,M,O,L,!w.isCCW,F))}else if(f.type==4){const w=f;if(w.numberOfControlPoints>0&&w.numberOfKnots>0){const x=w.controlPoints.map(O=>({x:O.x,y:O.y,z:0}));let I=!0;const M=w.controlPoints.map(O=>(O.weight==null&&(I=!1),O.weight||1));b.add(new Jr(x,w.knots,I?M:void 0))}else if(w.numberOfFitData>0){const x=w.fitDatum.map(I=>({x:I.x,y:I.y,z:0}));b.add(new Jr(x,"Uniform"))}}}),e.add(b)}}),e}convertTable(t){const e=new Si(t.name,t.rowCount,t.columnCount);return e.attachmentPoint=t.attachmentPoint,e.position.copy(t.startPoint),t.columnWidthArr.forEach((n,a)=>e.setColumnWidth(a,n)),t.rowHeightArr.forEach((n,a)=>e.setRowHeight(a,n)),t.cells.forEach((n,a)=>{e.setCell(a,n)}),e}convertText(t){const e=new qn;return e.textString=t.text,e.styleName=t.styleName,e.height=t.textHeight,e.position.copy(t.startPoint),e.rotation=Pt.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 Xs;return e.contents=t.text,t.styleName!=null&&(e.styleName=t.styleName),e.height=t.height,e.width=t.width,e.rotation=Pt.degToRad(t.rotation||0),e.location=t.insertionPoint,e.attachmentPoint=t.attachmentPoint,t.direction&&(e.direction=new X(t.direction)),e.drawingDirection=t.drawingDirection,e}convertLeader(t){const e=new Pi;return t.vertices.forEach(n=>{e.appendVertex(n)}),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,n=new Oi(e.subDefinitionPoint1,e.subDefinitionPoint2,e.definitionPoint);return e.insertionPoint&&(n.dimBlockPosition={...e.insertionPoint,z:0}),n.rotation=Pt.degToRad(e.rotationAngle||0),this.processDimensionCommonAttrs(t,n),n}else if(t.subclassMarker=="AcDb3PointAngularDimension"){const e=t,n=new Li(e.centerPoint,e.subDefinitionPoint1,e.subDefinitionPoint2,e.definitionPoint);return this.processDimensionCommonAttrs(t,n),n}else if(t.subclassMarker=="AcDbOrdinateDimension"){const e=t,n=new zi(e.subDefinitionPoint1,e.subDefinitionPoint2);return this.processDimensionCommonAttrs(t,n),n}else if(t.subclassMarker=="AcDbRadialDimension"){const e=t,n=new Ri(e.definitionPoint,e.centerPoint,e.leaderLength);return this.processDimensionCommonAttrs(t,n),n}else if(t.subclassMarker=="AcDbDiametricDimension"){const e=t,n=new Bi(e.definitionPoint,e.centerPoint,e.leaderLength);return this.processDimensionCommonAttrs(t,n),n}return null}processImage(t,e){e.position.copy(t.position),e.brightness=t.brightness,e.contrast=t.contrast,e.fade=t.fade,e.isShownClipped=(t.flags|4)>0,e.isImageShown=(t.flags|3)>0,e.isImageTransparent=(t.flags|8)>0,e.imageDefId=t.imageDefHandle,e.isClipped=t.isClipped,t.clippingBoundaryPath.forEach(n=>{e.clipBoundary.push(new Tt(n))}),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 $s;return this.processImage(t,e),e.clipBoundaryType=t.clippingBoundaryType,e}processWipeout(t,e){e.position.copy(t.position),e.brightness=t.brightness,e.contrast=t.contrast,e.fade=t.fade,e.isShownClipped=(t.displayFlag|4)>0,e.isImageShown=(t.displayFlag|3)>0,e.isImageTransparent=(t.displayFlag|8)>0,e.imageDefId=t.imageDefHardId,e.isClipped=t.isClipping,t.boundary.forEach(n=>{e.clipBoundary.push(new Tt(n))}),e.clipBoundaryType=t.boundaryType,e.width=Math.sqrt(t.uDirection.x**2+t.uDirection.y**2+t.uDirection.z**2)*t.imageSize.x,e.height=Math.sqrt(t.vDirection.x**2+t.vDirection.y**2+t.vDirection.z**2)*t.imageSize.y,e.rotation=Math.atan2(t.uDirection.y,t.uDirection.x)}convertWipeout(t){const e=new Ci;return this.processWipeout(t,e),e}convertViewport(t){const e=new Ti;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 ki;return e.basePoint.copy(t.position),e.unitDir.copy(t.direction),e}convertXline(t){const e=new Ni;return e.basePoint.copy(t.position),e.unitDir.copy(t.direction),e}convertBlockReference(t){const e=new Yn(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?Pt.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,e.normal.copy(t.extrusionDirection??{x:0,y:0,z:1})}processCommonAttrs(t,e){e.layer=t.layer||"0",t.handle&&(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.setRGBValue(t.color),t.colorIndex!=null&&(e.color.colorIndex=t.colorIndex),t.colorName&&(e.color.colorName=t.colorName),t.isVisible!=null&&(e.visibility=t.isVisible),t.transparency!=null&&(e.transparency=Wi.deserialize(t.transparency))}numberArrayToPointArray(t,e){const n=t.length;let a=0;if(n/2==e?a=2:n/3==e&&(a=3),a==0)return;const h=[];for(let c=0,m=n/a;c<m;++c)h.push({x:t[c*a],y:t[c*a+1],z:a==3?t[c*a+2]:0});return h}}class Pn extends tn{constructor(t,e){t=t||{},Kn(t,{name:""}),super(t,e)}get name(){return this.getAttr("name")}set name(t){this.setAttr("name",t)}}const Qr=class Qr extends Pn{static isModelSapceName(t){return t.toLowerCase()==Qr.MODEL_SPACE_NAME.toLowerCase()}static isPaperSapceName(t){return t.toLowerCase().startsWith(Qr.PAPER_SPACE_NAME_PREFIX.toLowerCase())}constructor(){super(),this._origin=new G,this._layoutId="",this._entities=new Map}get isModelSapce(){return Qr.isModelSapceName(this.name)}get isPaperSapce(){return Qr.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 n=t[e];n.database=this.database,n.ownerId=this.objectId,this._entities.set(n.objectId,n)}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})}removeEntity(t){const e=Array.isArray(t)?t:[t],n=[];return e.forEach(a=>{const h=this._entities.get(a);h&&n.push(h),this._entities.delete(a)}),n.length>0&&this.database.events.entityErased.dispatch({database:this.database,entity:n}),n.length>0}newIterator(){return new Js(this._entities)}getIdAt(t){return this._entities.get(t)}};Qr.MODEL_SPACE_NAME="*MODEL_SPACE",Qr.PAPER_SPACE_NAME_PREFIX="*PAPER_SPACE";let le=Qr;class W0{convertLayout(t,e){var a,h;const n=new $i;if(n.layoutName=t.layoutName,n.tabOrder=t.tabOrder,t.layoutName==="Model"){const c=le.MODEL_SPACE_NAME;(a=e.tables.BLOCK_RECORD)==null||a.entries.some(m=>m.name.toUpperCase()===c?(n.blockTableRecordId=m.handle,!0):!1)}else(h=e.tables.BLOCK_RECORD)==null||h.entries.some(c=>c.layoutObjects===t.handle?(n.blockTableRecordId=c.handle,!0):!1),n.blockTableRecordId||(n.blockTableRecordId=t.paperSpaceTableId);return n.limits.min.copy(t.minLimit),n.limits.max.copy(t.maxLimit),n.extents.min.copy(t.minExtent),n.extents.max.copy(t.maxExtent),this.processCommonAttrs(t,n),n}convertImageDef(t){const e=new Nh;return e.sourceFileName=t.fileName,this.processCommonAttrs(t,e),e}processCommonAttrs(t,e){e.objectId=t.handle,e.ownerId=t.ownerObjectId}}class Hc{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 n=Date.now(),a=this.generateTaskId();try{return await this.executeInWorker(a,t,e||this.config.workerUrl)}catch(h){const c=Date.now()-n;return{success:!1,error:h instanceof Error?h.message:String(h),duration:c}}}async executeInWorker(t,e,n){const a=Date.now();return new Promise((h,c)=>{const m=this.getAvailableWorker(n),b=setTimeout(()=>{this.cleanupTask(t),this.releaseWorker(m),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(m),h(x)},reject:x=>{clearTimeout(b),this.releaseWorker(m),c(x)},timeout:b});const f=x=>{const{id:I,success:M,data:O,error:L}=x.data;if(I!==t)return;this.cleanupTask(t);const F=Date.now()-a;h(M?{success:!0,data:O,duration:F}:{success:!1,error:L,duration:F})},w=x=>{this.cleanupTask(t),c(new Error(`Worker error: ${x.message}`))};m.addEventListener("message",f),m.addEventListener("error",w),m.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[n,a]of this.workers)if(!a.isBusy)return a.isBusy=!0,a.worker;if(this.workers.size<this.config.maxConcurrentWorkers){const n=new Worker(t,{type:"module"}),a=this.generateWorkerId(),h={worker:n,isBusy:!0,id:a,createdAt:new Date};return this.workers.set(a,h),n}const e=Array.from(this.workers.values()).sort((n,a)=>n.createdAt.getTime()-a.createdAt.getTime())[0];return e.isBusy=!0,e.worker}releaseWorker(t){for(const[e,n]of this.workers)if(n.worker===t){n.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 qc{constructor(t){this.framework=new Hc(t)}async execute(t,e){return this.framework.execute(t,e)}getStats(){return this.framework.getStats()}destroy(){this.framework.destroy()}}function Yc(i){return new qc(i)}class H0{constructor(){this.setupMessageHandler()}setupMessageHandler(){self.onmessage=async t=>{const{id:e,input:n}=t.data;try{const a=await this.executeTask(n);this.sendResponse(e,!0,a)}catch(a){this.sendResponse(e,!1,void 0,a instanceof Error?a.message:String(a))}}}sendResponse(t,e,n,a){const h={id:t,success:e,data:n,error:a};self.postMessage(h)}}class Xc extends ro{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=Yc({workerUrl:this.config.parserWorkerUrl,maxConcurrentWorkers:1}),n=await e.execute(t);if(e.destroy(),n.success)return{model:n.data,data:{unknownEntityCount:0}};throw new Error(`Failed to parse drawing due to error: '${n.error}'`)}else return{model:new G0().parse(t),data:{unknownEntityCount:0}}}getFonts(t){var h;const e=new Map,n=c=>{if(c){const m=c.lastIndexOf(".");return m>=0?c.substring(0,m).toLowerCase():c.toLowerCase()}};(h=t.tables.STYLE)==null||h.entries.forEach(c=>{const m=[];if(c.font){const b=n(c.font);b&&m.push(b)}if(c.bigFont){const b=n(c.bigFont);b&&m.push(b)}if(c.extendedFont){const b=n(c.extendedFont);b&&m.push(b)}e.set(c.name,m)});const a=new Set;return this.getFontsInBlock(t.entities,t.blocks,e,a),Array.from(a)}getFontsInBlock(t,e,n,a){const h=/\\f(.*?)\|/g;t.forEach(c=>{if(c.type=="MTEXT"){const m=c;[...m.text.matchAll(h)].forEach(w=>{a.add(w[1].toLowerCase())});const f=n.get(m.styleName);f==null||f.forEach(w=>a.add(w))}else if(c.type=="TEXT"){const m=c,b=n.get(m.styleName);b==null||b.forEach(f=>a.add(f))}else if(c.type=="INSERT"){const b=e[c.name];b&&b.entities&&this.getFontsInBlock(b.entities,e,n,a)}})}async processEntities(t,e,n,a,h){const c=new Sl;let m=t.entities;const b=m.length,f=new Ba(b,100-a.value,n);this.config.convertByEntityType&&(m=this.groupAndFlattenByType(m));const w=e.tables.blockTable.modelSpace;await f.processChunk(async(x,I)=>{let M=[],O=x<I?m[x].type:"";for(let L=x;L<I;L++){const F=m[L],D=c.convert(F);D&&(this.config.convertByEntityType&&F.type!==O&&(w.appendEntity(M),M=[],O=F.type),M.push(D))}if(w.appendEntity(M),h){let L=a.value+I/b*(100-a.value);L>100&&(L=100),await h(L,"ENTITY","IN-PROGRESS")}})}async processEntitiesInBlock(t,e,n=!1){const a=new Sl,h=t.length,c=[],m=e.objectId;for(let b=0;b<h;b++){const f=t[b],w=a.convert(f);w&&(!n||f.ownerBlockRecordSoftId===m)&&c.push(w)}e.appendEntity(c)}processBlocks(t,e){const n=t.blocks;for(const[a,h]of Object.entries(n)){let c=e.tables.blockTable.getAt(h.name);c||(c=new le,c.objectId=h.handle,c.name=a,c.origin.copy(h.position),e.tables.blockTable.add(c)),h.entities?this.processEntitiesInBlock(h.entities,c):c.isPaperSapce&&this.processEntitiesInBlock(t.entities,c,!0)}}processHeader(t,e){const n=t.header;n.$ACADVER&&(e.version=n.$ACADVER),e.cecolor.colorIndex=n.$CECOLOR||256,e.angBase=n.$ANGBASE||0,e.angDir=n.$ANGDIR||0,n.$AUNITS!=null&&(e.aunits=n.$AUNITS),e.celtscale=n.$CELTSCALE||1,e.ltscale=n.$LTSCALE||1,n.$EXTMAX&&(e.extmax=n.$EXTMAX),n.$EXTMIN&&(e.extmin=n.$EXTMIN),n.$INSUNITS!=null&&(e.insunits=n.$INSUNITS),e.pdmode=n.$PDMODE||0,e.pdsize=n.$PDSIZE||0}processBlockTables(t,e){var a;const n=(a=t.tables.BLOCK_RECORD)==null?void 0:a.entries;n&&n.length>0&&(e.tables.blockTable.removeAll(),n.forEach(h=>{const c=new le;c.objectId=h.handle,c.name=h.name,c.layoutId=h.layoutObjects,e.tables.blockTable.add(c)}))}processObjects(t,e){const n=t.objects.byName,a=new W0;if("LAYOUT"in n){const h=e.dictionaries.layouts;n.LAYOUT.forEach(c=>{const m=a.convertLayout(c,t);h.setAt(m.layoutName,m)})}if("IMAGEDEF"in n){const h=e.dictionaries.imageDefs;n.IMAGEDEF.forEach(c=>{const m=a.convertImageDef(c);h.setAt(m.objectId,m)})}}processViewports(t,e){var a,h;const n=(h=(a=t.tables)==null?void 0:a.VPORT)==null?void 0:h.entries;n&&n.length>0&&n.forEach(c=>{const m=new ou;this.processCommonTableEntryAttrs(c,m),c.circleSides&&(m.circleSides=c.circleSides),m.standardFlag=c.standardFlag,m.center.copy(c.center),m.lowerLeftCorner.copy(c.lowerLeftCorner),m.upperRightCorner.copy(c.upperRightCorner),c.snapBasePoint&&m.snapBase.copy(c.snapBasePoint),c.snapRotationAngle&&(m.snapAngle=c.snapRotationAngle),c.snapSpacing&&m.snapIncrements.copy(c.snapSpacing),c.majorGridLines&&(m.gridMajor=c.majorGridLines),c.gridSpacing&&m.gridIncrements.copy(c.gridSpacing),c.backgroundObjectId&&(m.backgroundObjectId=c.backgroundObjectId),m.gsView.center.copy(c.center),m.gsView.viewDirectionFromTarget.copy(c.viewDirectionFromTarget),m.gsView.viewTarget.copy(c.viewTarget),c.lensLength&&(m.gsView.lensLength=c.lensLength),c.frontClippingPlane&&(m.gsView.frontClippingPlane=c.frontClippingPlane),c.backClippingPlane&&(m.gsView.backClippingPlane=c.backClippingPlane),c.viewHeight&&(m.gsView.viewHeight=c.viewHeight),c.viewTwistAngle&&(m.gsView.viewTwistAngle=c.viewTwistAngle),c.frozenLayers&&(m.gsView.frozenLayers=c.frozenLayers),c.styleSheet&&(m.gsView.styleSheet=c.styleSheet),c.renderMode&&(m.gsView.renderMode=c.renderMode),c.viewMode&&(m.gsView.viewMode=c.viewMode),c.ucsIconSetting&&(m.gsView.ucsIconSetting=c.ucsIconSetting),c.ucsOrigin&&m.gsView.ucsOrigin.copy(c.ucsOrigin),c.ucsXAxis&&m.gsView.ucsXAxis.copy(c.ucsXAxis),c.ucsYAxis&&m.gsView.ucsYAxis.copy(c.ucsYAxis),c.orthographicType&&(m.gsView.orthographicType=c.orthographicType),c.shadePlotSetting&&(m.gsView.shadePlotSetting=c.shadePlotSetting),c.shadePlotObjectId&&(m.gsView.shadePlotObjectId=c.shadePlotObjectId),c.visualStyleObjectId&&(m.gsView.visualStyleObjectId=c.visualStyleObjectId),c.isDefaultLightingOn&&(m.gsView.isDefaultLightingOn=c.isDefaultLightingOn),c.defaultLightingType&&(m.gsView.defaultLightingType=c.defaultLightingType),c.brightness&&(m.gsView.brightness=c.brightness),c.contrast&&(m.gsView.contrast=c.contrast),c.ambientColor&&(m.gsView.ambientColor=c.ambientColor),e.tables.viewportTable.add(m)})}processLayers(t,e){var a,h;const n=(h=(a=t.tables)==null?void 0:a.LAYER)==null?void 0:h.entries;n&&n.length>0&&n.forEach(c=>{const m=new Dr;m.colorIndex=c.colorIndex;const b=new Qi({name:c.name,standardFlags:c.standardFlag,linetype:c.lineType,lineWeight:c.lineweight,isOff:c.colorIndex<0,color:m,isPlottable:c.isPlotting});this.processCommonTableEntryAttrs(c,b),e.tables.layerTable.add(b)})}processLineTypes(t,e){var a,h;const n=(h=(a=t.tables)==null?void 0:a.LTYPE)==null?void 0:h.entries;n&&n.length>0&&n.forEach(c=>{const m=new Hs(c);this.processCommonTableEntryAttrs(c,m),m.name=c.name,e.tables.linetypeTable.add(m)})}processTextStyles(t,e){var a;const n=(a=t.tables.STYLE)==null?void 0:a.entries;n&&n.length>0&&n.forEach(h=>{const c=new oo(h);this.processCommonTableEntryAttrs(h,c),e.tables.textStyleTable.add(c)})}processDimStyles(t,e){var a;const n=(a=t.tables.DIMSTYLE)==null?void 0:a.entries;n&&n.length>0&&n.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},m=new Xn(c);this.processCommonTableEntryAttrs(h,m),e.tables.dimStyleTable.add(m)})}processCommonTableEntryAttrs(t,e){e.name=t.name,e.objectId=t.handle,e.ownerId=t.ownerObjectId}groupAndFlattenByType(t){const e={},n=[];for(const a of t)e[a.type]||(e[a.type]=[],n.push(a.type)),e[a.type].push(a);return n.flatMap(a=>e[a])}}class Kc extends ro{constructor(t){super({}),this._database=t}async parse(){return{model:this._database,data:{unknownEntityCount:0}}}getFonts(){return[]}async processEntities(t,e,n,a,h){let c=t.tables.blockTable.modelSpace.newIterator().toArray();const m=c.length,b=new Ba(m,100-a.value,n);this.config.convertByEntityType&&(c=this.groupAndFlattenByType(c));const f=e.tables.blockTable.modelSpace;await b.processChunk(async(w,x)=>{let I=[],M=w<x?c[w].type:"";for(let O=w;O<x;O++){const L=c[O];this.config.convertByEntityType&&L.type!==M&&(this.triggerEvents(f,I),I=[],M=L.type),I.push(L)}if(this.triggerEvents(f,I),h){let O=a.value+x/m*(100-a.value);O>100&&(O=100),await h(O,"ENTITY","IN-PROGRESS")}})}processBlocks(){const t=this._database.tables.blockTable.newIterator();for(const e of t){const n=e.newIterator().toArray();this.triggerEvents(e,n)}}processHeader(){}processBlockTables(){}processObjects(){const t=this._database.dictionaries.layouts.newIterator();for(const n of t)this._database.events.dictObjetSet.dispatch({database:this._database,object:n,key:n.layoutName});const e=this._database.dictionaries.imageDefs.newIterator();for(const n of e)this._database.events.dictObjetSet.dispatch({database:this._database,object:n,key:n.objectId})}processViewports(){}processLayers(){this._database.tables.layerTable.newIterator().toArray().forEach(e=>{this._database.events.layerAppended.dispatch({database:this._database,layer:e})})}processLineTypes(){}processTextStyles(){}processDimStyles(){}groupAndFlattenByType(t){const e={},n=[];for(const a of t)e[a.type]||(e[a.type]=[],n.push(a.type)),e[a.type].push(a);return n.flatMap(a=>e[a])}triggerEvents(t,e){(t.isModelSapce||t.isPaperSapce)&&t.database.events.entityAppended.dispatch({database:t.database,entity:e})}}var Ws=(i=>(i.DXF="dxf",i.DWG="dwg",i))(Ws||{});class gr{constructor(){this.events={registered:new ae,unregistered:new ae},this._converters=new Map,this.register("dxf",new Xc)}static createInstance(){return gr._instance==null&&(gr._instance=new gr),this._instance}static get instance(){return gr._instance||(gr._instance=new gr),gr._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 Sn extends tn{constructor(t){super(),this.database=t,this._recordsByName=new Map,this._recordsById=new Map}get numEntries(){return this._recordsByName.size}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),n=this._recordsByName.get(e);return n?(this._recordsById.delete(n.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 Js(this._recordsByName)}normalizeName(t){return t}}class $c extends Sn{constructor(t){super(t)}get modelSpace(){let t=this.getAt(le.MODEL_SPACE_NAME);return t||(t=new le,t.name=le.MODEL_SPACE_NAME,this.add(t)),t}getEntityById(t){for(const e of this.database.tables.blockTable.newIterator()){const n=e.getIdAt(t);if(n)return n}}removeEntity(t){let e=!1;for(const n of this.database.tables.blockTable.newIterator())if(n.removeEntity(t)){e=!0;break}return e}normalizeName(t){let e=t;if(le.isModelSapceName(t))e=le.MODEL_SPACE_NAME;else if(le.isPaperSapceName(t)){const n=le.PAPER_SPACE_NAME_PREFIX,a=t.substring(n.length);e=n+a}return e}}class Zc extends Sn{constructor(t){super(t)}}class Qi extends Pn{constructor(t,e){t=t||{},Kn(t,{color:new Dr,description:"",standardFlags:0,isHidden:!1,isInUse:!0,isOff:!1,isPlottable:!0,transparency:new Wi,linetype:"",lineWeight:1,materialId:-1}),super(t,e),this.attrs.events.attrChanged.addEventListener(n=>{this.database.events.layerModified.dispatch({database:this.database,layer:this,changes:n.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.clone())}get linetype(){return this.getAttr("linetype")}set linetype(t){this.setAttr("linetype",t)}get lineStyle(){var e;const t=(e=this.database)==null?void 0:e.tables.linetypeTable.getAt(this.linetype);if(t)return{type:"UserSpecified",...t.linetype}}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 Qc extends Sn{constructor(t){super(t);const e=new Dr,n=new Qi({name:"0",standardFlags:0,linetype:fi,lineWeight:Ki.ByLineWeightDefault,isOff:!1,color:e,isPlottable:!0});this.add(n)}add(t){super.add(t),this.database.events.layerAppended.dispatch({database:this.database,layer:t})}}class Jc extends Sn{constructor(t){super(t)}}class tu extends Sn{constructor(t){super(t)}get fonts(){const t=new Set,e=a=>{if(a){const h=a.lastIndexOf(".");if(h>=0){const c=a.substring(0,h).toLowerCase();t.add(c)}else t.add(a.toLowerCase())}},n=this.newIterator();for(const a of n)e(a.fileName),e(a.bigFontFileName);return Array.from(t)}}class eu extends Sn{constructor(t){super(t)}}class q0 extends tn{constructor(){super(),this.events={dictObjetSet:new ae,dictObjectErased:new ae,entityAppended:new ae,entityModified:new ae,entityErased:new ae,layerAppended:new ae,layerModified:new ae,layerErased:new ae,openProgress:new ae,headerSysVarChanged:new ae},this._version=new Fi("AC1014"),this._angBase=0,this._angDir=0,this._aunits=za.DecimalDegrees,this._celtscale=1,this._cecolor=new Dr,this._extents=new Ct,this._insunits=eo.Millimeters,this._ltscale=1,this._pdmode=0,this._pdsize=0,this._tables={blockTable:new $c(this),dimStyleTable:new Zc(this),linetypeTable:new Jc(this),textStyleTable:new tu(this),layerTable:new Qc(this),viewportTable:new eu(this)},this._dictionaries={layouts:new Ch(this),imageDefs:new to(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 version(){return this._version}set version(t){this._version=new Fi(t),this.triggerHeaderSysVarChangedEvent("version")}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){t&&(this._extents.expandByPoint(t),this.triggerHeaderSysVarChangedEvent("extmax"))}get extmin(){return this._extents.min}set extmin(t){t&&(this._extents.expandByPoint(t),this.triggerHeaderSysVarChangedEvent("extmin"))}get extents(){return this._extents}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,n=Ws.DXF){const a=gr.instance.get(n);if(a==null)throw new Error(`Database converter for file type '${n}' isn't registered and can can't read this file!`);this.clear(),await a.read(t,this,e&&e.minimumChunkSize||10,async(h,c,m,b)=>{if(this.events.openProgress.dispatch({database:this,percentage:h,stage:"CONVERSION",subStage:c,subStageStatus:m,data:b}),e&&e.fontLoader&&c=="FONT"&&m=="END"){const f=b||this.tables.textStyleTable.fonts;await e.fontLoader.load(f)}})}async openUri(t,e){var M;this.events.openProgress.dispatch({database:this,percentage:0,stage:"FETCH_FILE",subStageStatus:"START"});const n=await fetch(t);if(!n.ok)throw this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",subStageStatus:"ERROR"}),new Error(`Failed to fetch file '${t}' with HTTP status code '${n.status}'!`);const a=n.headers.get("content-length"),h=a?parseInt(a,10):null;let c=0;const m=(M=n.body)==null?void 0:M.getReader();if(!m)throw new Error("Failed to get response reader");const b=[];for(;;){const{done:O,value:L}=await m.read();if(O)break;if(b.push(L),c+=L.length,h!==null){const F=Math.round(c/h*100);this.events.openProgress.dispatch({database:this,percentage:F,stage:"FETCH_FILE",subStageStatus:"IN-PROGRESS"})}}const f=new Uint8Array(c);let w=0;for(const O of b)f.set(O,w),w+=O.length;const I=this.getFileNameFromUri(t).toLowerCase().split(".").pop();I==="dwg"?await this.read(f.buffer,e,Ws.DWG):I==="dxf"?await this.read(f.buffer,e,Ws.DXF):await this.read(f.buffer,e,I),this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",subStageStatus:"END"})}async regen(){await new Kc(this).read(null,this,500,async(e,n,a,h)=>{this.events.openProgress.dispatch({database:this,percentage:e,stage:"CONVERSION",subStage:n,subStageStatus:a,data:h})})}createDefaultData(t={layer:!0,lineType:!0,textStyle:!0,dimStyle:!0,layout:!0}){const e=new Lh(this);t.layer&&e.createDefaultLayer(),t.lineType&&e.createDefaultLineType(),t.textStyle&&e.createDefaultTextStyle(),t.dimStyle&&e.createDefaultDimStyle(),t.layout&&e.createDefaultLayout()}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})}getFileNameFromUri(t){try{const n=new URL(t).pathname.split("/");return n[n.length-1]||""}catch(e){return console.error("Invalid URI:",e),""}}}var ru=(i=>(i[i.Center=0]="Center",i[i.Left=1]="Left",i[i.Right=2]="Right",i[i.OverFirst=3]="OverFirst",i[i.OverSecond=4]="OverSecond",i))(ru||{}),nu=(i=>(i[i.Center=0]="Center",i[i.Above=1]="Above",i[i.Outside=2]="Outside",i[i.JIS=3]="JIS",i[i.Below=4]="Below",i))(nu||{}),su=(i=>(i[i.Feet=0]="Feet",i[i.None=1]="None",i[i.Inch=2]="Inch",i[i.FeetAndInch=3]="FeetAndInch",i[i.Leading=4]="Leading",i[i.Trailing=8]="Trailing",i[i.LeadingAndTrailing=12]="LeadingAndTrailing",i))(su||{}),iu=(i=>(i[i.None=0]="None",i[i.Leading=1]="Leading",i[i.Trailing=2]="Trailing",i[i.LeadingAndTrailing=3]="LeadingAndTrailing",i))(iu||{}),au=(i=>(i[i.Bottom=0]="Bottom",i[i.Middle=1]="Middle",i[i.Top=2]="Top",i))(au||{});const Ui=class Ui extends Pn{constructor(t,e){t=t||{},Kn(t,Ui.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)}};Ui.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 Xn=Ui;class Hs extends Pn{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}}const ji=class ji{constructor(){this.registry=new Map,this.cache=new Map,this.events={sysVarChanged:new ae},this.registerVar({name:"PICKBOX",type:"number",defaultValue:0})}static instance(){return this._instance||(this._instance=new ji),this._instance}registerVar(t){this.registry.set(t.name.toUpperCase(),t)}registerMany(t){t.forEach(e=>this.registerVar(e))}getVar(t){if(t=t.toUpperCase(),this.cache.has(t))return this.cache.get(t)}setVar(t,e){t=t.toUpperCase();const n=this.getDescriptor(t);if(n){const a=this.getVar(t);if(this.cache.set(t,e),n.type!=="string"&&(typeof e=="string"||e instanceof String))if(n.type==="number"){const h=Number(e);if(Number.isNaN(h))throw new Error("Invalid input!");e=h}else n.type==="boolean"&&(e=this.parseBoolean(e));this.events.sysVarChanged.dispatch({name:t,newVal:e,oldVal:a})}else throw new Error(`System variable ${t} not found!`)}getDescriptor(t){return this.registry.get(t.toUpperCase())}getAllDescriptors(){return[...this.registry.values()]}parseBoolean(t){if(t==null)return!1;const e=String(t).trim().toLowerCase(),n=new Set(["true","t","1","yes","y"]),a=new Set(["false","f","0","no","n"]);return n.has(e)?!0:(a.has(e),!1)}};ji._instance=null;let La=ji;class oo extends Pn{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 n=e.lastIndexOf(".");return n===-1?e:e.substring(0,n)}return t}}const Y0={center:new Tt,viewDirectionFromTarget:new G(0,0,1),viewTarget:new G(0,0,0),lensLength:500,frontClippingPlane:0,backClippingPlane:0,viewHeight:1e3,viewTwistAngle:0,frozenLayers:[],styleSheet:"",renderMode:Za.OPTIMIZED_2D,viewMode:0,ucsIconSetting:0,ucsOrigin:new G(0,0,0),ucsXAxis:new G(1,0,0),ucsYAxis:new G(0,1,0),orthographicType:Qa.TOP,shadePlotSetting:0,shadePlotObjectId:void 0,visualStyleObjectId:void 0,isDefaultLightingOn:!1,defaultLightingType:Ja.ONE_DISTANT_LIGHT,brightness:0,contrast:0,ambientColor:void 0};class ou extends Pn{constructor(){super(),this._circleSides=100,this._center=new Tt,this._lowerLeftCorner=new Tt(0,0),this._upperRightCorner=new Tt(1,1),this._snapBase=new Tt(0,0),this._snapAngle=0,this._snapSpacing=new Tt(0,0),this._standardFlag=0,this._gridSpacing=new Tt,this._gridMajor=10,this._gsView=Y0}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 lu{constructor(){this.events={layoutCreated:new ae,layoutRemoved:new ae,layoutRenamed:new ae,layoutSwitched:new ae}}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 n=this.getWorkingDatabase(e),a=n.dictionaries.layouts.getIdAt(t);return this.setCurrentLayoutInternal(a,n)}setCurrentLayoutBtrId(t,e){const n=this.getWorkingDatabase(e),a=n.dictionaries.layouts.getBtrIdAt(t);return this.setCurrentLayoutInternal(a,n)}setCurrentLayout(t,e){const n=this.getWorkingDatabase(e),a=n.dictionaries.layouts.getAt(t);return this.setCurrentLayoutInternal(a,n)}renameLayout(t,e,n){const h=this.getWorkingDatabase(n).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 n=this.getWorkingDatabase(e).dictionaries.layouts,a=n.getAt(t);let h=!1;return a&&(h=n.remove(t),h&&this.events.layoutRemoved.dispatch({layout:a})),h}createLayout(t,e){const n=this.getWorkingDatabase(e),a=new $i;a.layoutName=t,a.tabOrder=n.dictionaries.layouts.maxTabOrder;const h=new le;return h.name=`*Paper_Space${a.tabOrder}`,n.tables.blockTable.add(h),n.dictionaries.layouts.setAt(t,a),this.events.layoutCreated.dispatch({layout:a}),{layout:a,btr:h}}getActiveLayout(t){const e=this.getWorkingDatabase(t);return e.dictionaries.layouts.getBtrIdAt(e.currentSpaceId)}getWorkingDatabase(t){return t||lo().workingDatabase}setCurrentLayoutInternal(t,e){return t?(this.events.layoutSwitched.dispatch({layout:t}),e.currentSpaceId=t.blockTableRecordId,!0):!1}}function lo(){return Vi.instance}const Gi=class Gi{constructor(){this._workingDatabase=null,this._layoutManager=new lu}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}};Gi.instance=new Gi;let Vi=Gi;var hu=(i=>(i.kForRead="kForRead",i.kForWrite="kForWrite",i))(hu||{});exports.AcCmColor=Dr;exports.AcCmColorMethod=pt;exports.AcCmColorUtil=fn;exports.AcCmEntityColor=Eu;exports.AcCmErrors=Xe;exports.AcCmEventDispatcher=Mu;exports.AcCmEventManager=ae;exports.AcCmLoader=zu;exports.AcCmLoadingManager=Ol;exports.AcCmObject=Tl;exports.AcCmPerformanceCollector=Oa;exports.AcCmTask=Nl;exports.AcCmTaskScheduler=Ll;exports.AcCmTransparency=Wi;exports.AcCmTransparencyMethod=Ee;exports.AcDb2dPolyline=yi;exports.AcDb2dVertex=Ea;exports.AcDb2dVertexType=wh;exports.AcDb3PointAngularDimension=Li;exports.AcDb3dPolyline=vi;exports.AcDb3dVertex=Ma;exports.AcDb3dVertexType=Ah;exports.AcDbAlignedDimension=Oi;exports.AcDbAngleUnits=za;exports.AcDbArc=bi;exports.AcDbArcDimension=Ca;exports.AcDbAttribute=Ta;exports.AcDbAttributeDefinition=ka;exports.AcDbAttributeFlags=Oe;exports.AcDbAttributeMTextFlag=$r;exports.AcDbBaseWorker=H0;exports.AcDbBatchProcessing=Ba;exports.AcDbBlockReference=Yn;exports.AcDbBlockTable=$c;exports.AcDbBlockTableRecord=le;exports.AcDbCircle=xi;exports.AcDbCodePage=Ra;exports.AcDbCurve=ke;exports.AcDbDataGenerator=Lh;exports.AcDbDatabase=q0;exports.AcDbDatabaseConverter=ro;exports.AcDbDatabaseConverterManager=gr;exports.AcDbDiametricDimension=Bi;exports.AcDbDictionary=to;exports.AcDbDimArrowType=Oh;exports.AcDbDimStyleTable=Zc;exports.AcDbDimStyleTableRecord=Xn;exports.AcDbDimTextHorizontal=ru;exports.AcDbDimTextVertical=nu;exports.AcDbDimVerticalJustification=au;exports.AcDbDimZeroSuppression=su;exports.AcDbDimZeroSuppressionAngular=iu;exports.AcDbDimension=Rr;exports.AcDbDwgVersion=Fi;exports.AcDbDxfConverter=Xc;exports.AcDbEllipse=wi;exports.AcDbEntity=Me;exports.AcDbFace=Ai;exports.AcDbFileType=Ws;exports.AcDbHatch=qs;exports.AcDbHatchPatternType=Gs;exports.AcDbHatchStyle=Ih;exports.AcDbHostApplicationServices=Vi;exports.AcDbLayerTable=Qc;exports.AcDbLayerTableRecord=Qi;exports.AcDbLayout=$i;exports.AcDbLayoutDictionary=Ch;exports.AcDbLayoutManager=lu;exports.AcDbLeader=Pi;exports.AcDbLeaderAnnotationType=Eh;exports.AcDbLine=Ys;exports.AcDbLineSpacingStyle=Th;exports.AcDbLinetypeTable=Jc;exports.AcDbLinetypeTableRecord=Hs;exports.AcDbMText=Xs;exports.AcDbObject=tn;exports.AcDbObjectIterator=Js;exports.AcDbOpenMode=hu;exports.AcDbOrdinateDimension=zi;exports.AcDbOsnapMode=Dt;exports.AcDbPoint=Mi;exports.AcDbPoly2dType=jn;exports.AcDbPoly3dType=js;exports.AcDbPolyline=Ei;exports.AcDbRadialDimension=Ri;exports.AcDbRasterImage=$s;exports.AcDbRasterImageClipBoundaryType=Mh;exports.AcDbRasterImageDef=Nh;exports.AcDbRasterImageImageDisplayOpt=kh;exports.AcDbRay=ki;exports.AcDbRegenerator=Kc;exports.AcDbRenderingCache=$n;exports.AcDbSpline=Ks;exports.AcDbSymbolTable=Sn;exports.AcDbSymbolTableRecord=Pn;exports.AcDbSysVarManager=La;exports.AcDbTable=Si;exports.AcDbText=qn;exports.AcDbTextHorizontalMode=Ph;exports.AcDbTextStyleTable=tu;exports.AcDbTextStyleTableRecord=oo;exports.AcDbTextVerticalMode=Sh;exports.AcDbTrace=Ii;exports.AcDbUnitsValue=eo;exports.AcDbViewport=Ti;exports.AcDbViewportTable=eu;exports.AcDbViewportTableRecord=ou;exports.AcDbWipeout=Ci;exports.AcDbWorkerApi=qc;exports.AcDbWorkerManager=Hc;exports.AcDbXline=Ni;exports.AcGeArea2d=qi;exports.AcGeBox2d=xe;exports.AcGeBox3d=Ct;exports.AcGeCatmullRomCurve3d=yh;exports.AcGeCircArc2d=Wn;exports.AcGeCircArc3d=Xa;exports.AcGeCurve2d=Zn;exports.AcGeEllipseArc2d=Yi;exports.AcGeEllipseArc3d=Xi;exports.AcGeEuler=Wu;exports.AcGeGeometryUtil=ah;exports.AcGeLine2d=Us;exports.AcGeLine3d=Hn;exports.AcGeLoop2d=Ka;exports.AcGeMathUtil=Pt;exports.AcGeMatrix2d=Hi;exports.AcGeMatrix3d=Ye;exports.AcGeNurbsCurve=bn;exports.AcGePlane=Zs;exports.AcGePoint2d=Tt;exports.AcGePoint3d=G;exports.AcGePolyline2d=An;exports.AcGeQuaternion=wn;exports.AcGeShape2d=Ya;exports.AcGeSpline3d=Jr;exports.AcGeTol=Wa;exports.AcGeVector2d=Jt;exports.AcGeVector3d=X;exports.AcGiArrowType=$a;exports.AcGiDefaultLightingType=Ja;exports.AcGiLineWeight=Ki;exports.AcGiMTextAttachmentPoint=be;exports.AcGiMTextFlowDirection=zr;exports.AcGiOrthographicType=Qa;exports.AcGiRenderMode=Za;exports.AcGiViewport=vh;exports.AcTrStringUtil=Bu;exports.ByBlock=Rl;exports.ByLayer=hi;exports.DEBUG_MODE=Lu;exports.DEFAULT_LINE_TYPE=fi;exports.DEFAULT_TOL=Ha;exports.DEG2RAD=Da;exports.DefaultLoadingManager=Bl;exports.FLOAT_TOL=yn;exports.ORIGIN_POINT_2D=Du;exports.ORIGIN_POINT_3D=Ga;exports.RAD2DEG=Fa;exports.TAU=Zt;exports.acdbDisableOsnapMode=td;exports.acdbEnableOsnapMode=Ju;exports.acdbHasOsnapMode=Qu;exports.acdbHostApplicationServices=lo;exports.acdbMaskToOsnapModes=$u;exports.acdbOsnapModesToMask=Ku;exports.acdbToggleOsnapMode=Zu;exports.basisFunction=_i;exports.calculateCurveLength=ch;exports.ceilPowerOfTwo=Ql;exports.clamp=Br;exports.clone=zs;exports.createWorkerApi=Yc;exports.damp=Ul;exports.deepClone=wa;exports.defaults=Kn;exports.degToRad=Kl;exports.dwgCodePageToEncoding=zl;exports.euclideanModulo=Va;exports.evaluateNurbsPoint=Vs;exports.floorPowerOfTwo=Jl;exports.generateChordKnots=lh;exports.generateSqrtChordKnots=hh;exports.generateUUID=Dl;exports.generateUniformKnots=oh;exports.has=Il;exports.intPartLength=ja;exports.interpolateControlPoints=Fu;exports.inverseLerp=Vl;exports.isBetween=th;exports.isBetweenAngle=eh;exports.isEmpty=El;exports.isEqual=Gn;exports.isImperialUnits=nd;exports.isMetricUnits=rd;exports.isPointInPolygon=qa;exports.isPolygonIntersect=ih;exports.isPowerOfTwo=Zl;exports.lerp=Ua;exports.log=Ds;exports.mapLinear=Fl;exports.normalizeAngle=Fs;exports.pingpong=jl;exports.radToDeg=$l;exports.randFloat=ql;exports.randFloatSpread=Yl;exports.randInt=Hl;exports.relativeEps=rh;exports.seededRandom=Xl;exports.setLogLevel=Ou;exports.smootherstep=Wl;exports.smoothstep=Gl;
4
+ `+s+"}",T;case"function":return"<function>";case"string":return r;default:return String(r)}},Nt.__interfLoop=function(r,s){if(r==null)return!1;if(r==s)return!0;var o=r.__interfaces__;if(o!=null)for(var l=0,u=o.length;l<u;){var d=l++,g=o[d];if(g==s||Nt.__interfLoop(g,s))return!0}return Nt.__interfLoop(r.__super__,s)},Nt.__instanceof=function(r,s){if(s==null)return!1;switch(s){case uu:return(r|0)===r;case Ho:return typeof r=="number";case qo:return typeof r=="boolean";case String:return typeof r=="string";case Array:return r instanceof Array&&r.__enum__==null;case du:return!0;default:if(r!=null){if(typeof s=="function"){if(r instanceof s||Nt.__interfLoop(Nt.getClass(r),s))return!0}else if(typeof s=="object"&&Nt.__isNativeObj(s)&&r instanceof s)return!0}else return!1;return s==Yo&&r.__name__!=null||s==Xo&&r.__ename__!=null?!0:r.__enum__==s}},Nt.__nativeClassName=function(r){var s=Nt.__toStr.call(r).slice(8,-1);return s=="Object"||s=="Function"||s=="Math"||s=="JSON"?null:s},Nt.__isNativeObj=function(r){return Nt.__nativeClassName(r)!=null},Nt.__resolveNativeClass=function(r){return w[r]};var ue=function(r){if(r instanceof Array&&r.__enum__==null)this.a=r,this.byteLength=r.length;else{var s=r;this.a=[];for(var o=0;o<s;){var l=o++;this.a[l]=0}this.byteLength=s}};x["js.html.compat.ArrayBuffer"]=ue,ue.__name__=["js","html","compat","ArrayBuffer"],ue.sliceImpl=function(r,s){var o=new sa(this,r,s==null?null:s-r),l=new ri(o.byteLength),u=new sa(l);return u.set(o),l},ue.prototype={slice:function(r,s){return new ue(this.a.slice(r,s))},__class__:ue};var _r=function(r,s,o){if(this.buf=r,s==null?this.offset=0:this.offset=s,o==null?this.length=r.byteLength-this.offset:this.length=o,this.offset<0||this.length<0||this.offset+this.length>r.byteLength)throw new Q(re.OutsideBounds)};x["js.html.compat.DataView"]=_r,_r.__name__=["js","html","compat","DataView"],_r.prototype={getInt8:function(r){var s=this.buf.a[this.offset+r];return s>=128?s-256:s},getUint8:function(r){return this.buf.a[this.offset+r]},getInt16:function(r,s){var o=this.getUint16(r,s);return o>=32768?o-65536:o},getUint16:function(r,s){return s?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,s){var o=this.offset+r,l=this.buf.a[o++],u=this.buf.a[o++],d=this.buf.a[o++],g=this.buf.a[o++];return s?l|u<<8|d<<16|g<<24:g|d<<8|u<<16|l<<24},getUint32:function(r,s){var o=this.getInt32(r,s);return o<0?o+4294967296:o},getFloat32:function(r,s){return ce.i32ToFloat(this.getInt32(r,s))},getFloat64:function(r,s){var o=this.getInt32(r,s),l=this.getInt32(r+4,s);return ce.i64ToDouble(s?o:l,s?l:o)},setInt8:function(r,s){s<0?this.buf.a[r+this.offset]=s+128&255:this.buf.a[r+this.offset]=s&255},setUint8:function(r,s){this.buf.a[r+this.offset]=s&255},setInt16:function(r,s,o){this.setUint16(r,s<0?s+65536:s,o)},setUint16:function(r,s,o){var l=r+this.offset;o?(this.buf.a[l]=s&255,this.buf.a[l++]=s>>8&255):(this.buf.a[l++]=s>>8&255,this.buf.a[l]=s&255)},setInt32:function(r,s,o){this.setUint32(r,s,o)},setUint32:function(r,s,o){var l=r+this.offset;o?(this.buf.a[l++]=s&255,this.buf.a[l++]=s>>8&255,this.buf.a[l++]=s>>16&255,this.buf.a[l++]=s>>>24):(this.buf.a[l++]=s>>>24,this.buf.a[l++]=s>>16&255,this.buf.a[l++]=s>>8&255,this.buf.a[l++]=s&255)},setFloat32:function(r,s,o){this.setUint32(r,ce.floatToI32(s),o)},setFloat64:function(r,s,o){var l=ce.doubleToI64(s);o?(this.setUint32(r,l.low),this.setUint32(r,l.high)):(this.setUint32(r,l.high),this.setUint32(r,l.low))},__class__:_r};var hr=function(){};x["js.html.compat.Uint8Array"]=hr,hr.__name__=["js","html","compat","Uint8Array"],hr._new=function(r,s,o){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 ue(l)}else if(Nt.__instanceof(r,ue)){var g=r;s==null&&(s=0),o==null&&(o=g.byteLength-s),s==0?l=g.a:l=g.a.slice(s,s+o),l.byteLength=l.length,l.byteOffset=s,l.buffer=g}else if(r instanceof Array&&r.__enum__==null)l=r.slice(),l.byteLength=l.length,l.byteOffset=0,l.buffer=new ue(l);else throw new Q("TODO "+at.string(r));return l.subarray=hr._subarray,l.set=hr._set,l},hr._set=function(r,s){var o=this;if(Nt.__instanceof(r.buffer,ue)){var l=r;if(r.byteLength+s>o.byteLength)throw new Q("set() outside of range");for(var u=0,d=r.byteLength;u<d;){var g=u++;o[g+s]=l[g]}}else if(r instanceof Array&&r.__enum__==null){var _=r;if(_.length+s>o.byteLength)throw new Q("set() outside of range");for(var y=0,A=_.length;y<A;){var I=y++;o[I+s]=_[I]}}else throw new Q("TODO")},hr._subarray=function(r,s){var o=this,l=hr._new(o.slice(r,s));return l.byteOffset=r,l};var kt=function(r){this._resolved=!1,this._pending=!1,this._errorPending=!1,this._fulfilled=!1,this._update=[],this._error=[],this._errored=!1,r!=null&&kt.link(r,this,function(s){return s})};x["promhx.base.AsyncBase"]=kt,kt.__name__=["promhx","base","AsyncBase"],kt.link=function(r,s,o){r._update.push({async:s,linkf:function(l){s.handleResolve(o(l))}}),kt.immediateLinkUpdate(r,s,o)},kt.immediateLinkUpdate=function(r,s,o){if(r._errored&&!r._errorPending&&!(r._error.length>0)&&s.handleError(r._errorVal),r._resolved&&!r._pending)try{s.handleResolve(o(r._val))}catch(l){l instanceof Q&&(l=l.val),s.handleError(l)}},kt.linkAll=function(r,s){for(var o=function(d,g,_){if(d.length==0||kt.allFulfilled(d)){for(var y,A=[],I=tr(r)();I.hasNext();){var P=I.next();A.push(P==g?_:P._val)}y=A,s.handleResolve(y)}},l=tr(r)();l.hasNext();){var u=l.next();u._update.push({async:s,linkf:function(d,g,_){return function(y){d(g,_,y)}}(o,function(d){for(var g,_=[],y=tr(r)();y.hasNext();){var A=y.next();A!=u&&_.push(A)}return g=_,g}(),u)})}kt.allFulfilled(r)&&s.handleResolve(function(d){for(var g,_=[],y=tr(r)();y.hasNext();){var A=y.next();_.push(A._val)}return g=_,g}())},kt.pipeLink=function(r,s,o){var l=!1,u=function(d){if(!l){l=!0;var g=o(d);g._update.push({async:s,linkf:De(s,s.handleResolve)}),kt.immediateLinkUpdate(g,s,function(_){return _})}};if(r._update.push({async:s,linkf:u}),r._resolved&&!r._pending)try{u(r._val)}catch(d){d instanceof Q&&(d=d.val),s.handleError(d)}},kt.allResolved=function(r){for(var s=tr(r)();s.hasNext();){var o=s.next();if(!o._resolved)return!1}return!0},kt.allFulfilled=function(r){for(var s=tr(r)();s.hasNext();){var o=s.next();if(!o._fulfilled)return!1}return!0},kt.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 s=this;this._pending?St.enqueue(function(o,l){return function(){o(l)}}(De(this,this._resolve),r)):(this._resolved=!0,this._pending=!0,St.queue.add(function(){s._val=r;for(var o=0,l=s._update;o<l.length;){var u=l[o];++o;try{u.linkf(r)}catch(d){d instanceof Q&&(d=d.val),u.async.handleError(d)}}s._fulfilled=!0,s._pending=!1}),St.continueOnNextLoop())},handleError:function(r){this._handleError(r)},_handleError:function(r){var s=this,o=function(l){if(s._error.length>0)for(var u=0,d=s._error;u<d.length;){var g=d[u];++u,g(l)}else if(s._update.length>0)for(var _=0,y=s._update;_<y.length;){var A=y[_];++_,A.async.handleError(l)}else throw new Q(l);s._errorPending=!1};this._errorPending||(this._errorPending=!0,this._errored=!0,this._errorVal=r,St.queue.add(function(){if(s._errorMap!=null)try{s._resolve(s._errorMap(r))}catch(l){l instanceof Q&&(l=l.val),o(l)}else o(r)}),St.continueOnNextLoop())},then:function(r){var s=new kt(null);return kt.link(this,s,r),s},unlink:function(r){var s=this;St.queue.add(function(){s._update=s._update.filter(function(o){return o.async!=r})}),St.continueOnNextLoop()},isLinked:function(r){for(var s=!1,o=0,l=this._update;o<l.length;){var u=l[o];if(++o,u.async==r)return!0}return s},__class__:kt};var Sn=f.promhx.Deferred=function(){kt.call(this)};x["promhx.Deferred"]=Sn,Sn.__name__=["promhx","Deferred"],Sn.__super__=kt,Sn.prototype=M(kt.prototype,{resolve:function(r){this.handleResolve(r)},throwError:function(r){this.handleError(r)},promise:function(){return new ye(this)},stream:function(){return new Yt(this)},publicStream:function(){return new Vr(this)},__class__:Sn});var ye=f.promhx.Promise=function(r){kt.call(this,r),this._rejected=!1};x["promhx.Promise"]=ye,ye.__name__=["promhx","Promise"],ye.whenAll=function(r){var s=new ye(null);return kt.linkAll(r,s),s},ye.promise=function(r){var s=new ye;return s.handleResolve(r),s},ye.__super__=kt,ye.prototype=M(kt.prototype,{isRejected:function(){return this._rejected},reject:function(r){this._rejected=!0,this.handleError(r)},handleResolve:function(r){if(this._resolved){var s="Promise has already been resolved";throw new Q(En.AlreadyResolved(s))}this._resolve(r)},then:function(r){var s=new ye(null);return kt.link(this,s,r),s},unlink:function(r){var s=this;St.queue.add(function(){if(s._fulfilled)s._update=s._update.filter(function(l){return l.async!=r});else{var o="Downstream Promise is not fullfilled";s.handleError(En.DownstreamNotFullfilled(o))}}),St.continueOnNextLoop()},handleError:function(r){this._rejected=!0,this._handleError(r)},pipe:function(r){var s=new ye(null);return kt.pipeLink(this,s,r),s},errorPipe:function(r){var s=new ye;return this.catchError(function(o){var l=r(o);l.then(De(s,s._resolve))}),this.then(De(s,s._resolve)),s},__class__:ye});var Yt=f.promhx.Stream=function(r){kt.call(this,r),this._end_promise=new ye};x["promhx.Stream"]=Yt,Yt.__name__=["promhx","Stream"],Yt.foreach=function(r){for(var s=new Yt(null),o=tr(r)();o.hasNext();){var l=o.next();s.handleResolve(l)}return s.end(),s},Yt.wheneverAll=function(r){var s=new Yt(null);return kt.linkAll(r,s),s},Yt.concatAll=function(r){for(var s=new Yt(null),o=tr(r)();o.hasNext();){var l=o.next();s.concat(l)}return s},Yt.mergeAll=function(r){for(var s=new Yt(null),o=tr(r)();o.hasNext();){var l=o.next();s.merge(l)}return s},Yt.stream=function(r){var s=new Yt(null);return s.handleResolve(r),s},Yt.__super__=kt,Yt.prototype=M(kt.prototype,{then:function(r){var s=new Yt(null);return kt.link(this,s,r),this._end_promise._update.push({async:s._end_promise,linkf:function(o){s.end()}}),s},detachStream:function(r){for(var s=[],o=!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(g){return g.async!=r._end_promise}),o=!0):s.push(d)}return this._update=s,o},first:function(){var r=new ye(null);return this.then(function(s){r._resolved||r.handleResolve(s)}),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 s=new Yt(null);return kt.pipeLink(this,s,r),this._end_promise.then(function(o){s.end()}),s},errorPipe:function(r){var s=new Yt(null);return this.catchError(function(o){var l=r(o);l.then(De(s,s._resolve)),l._end_promise.then((ra=s._end_promise,De(ra,ra._resolve)))}),this.then(De(s,s._resolve)),this._end_promise.then(function(o){s.end()}),s},handleEnd:function(){if(this._pending)St.queue.add(De(this,this.handleEnd)),St.continueOnNextLoop();else{if(this._end_promise._resolved)return;this._end=!0;var r;this._resolved?r=fe.Some(this._val):r=fe.None,this._end_promise.handleResolve(r),this._update=[],this._error=[]}},end:function(){return St.queue.add(De(this,this.handleEnd)),St.continueOnNextLoop(),this},endThen:function(r){return this._end_promise.then(r)},filter:function(r){var s=new Yt(null);return this._update.push({async:s,linkf:function(o){r(o)&&s.handleResolve(o)}}),kt.immediateLinkUpdate(this,s,function(o){return o}),s},concat:function(r){var s=new Yt(null);return this._update.push({async:s,linkf:De(s,s.handleResolve)}),kt.immediateLinkUpdate(this,s,function(o){return o}),this._end_promise.then(function(o){r.pipe(function(l){return s.handleResolve(l),s}),r._end_promise.then(function(l){s.end()})}),s},merge:function(r){var s=new Yt(null);return this._update.push({async:s,linkf:De(s,s.handleResolve)}),r._update.push({async:s,linkf:De(s,s.handleResolve)}),kt.immediateLinkUpdate(this,s,function(o){return o}),kt.immediateLinkUpdate(r,s,function(o){return o}),s},__class__:Yt});var Vr=f.promhx.PublicStream=function(r){Yt.call(this,r)};x["promhx.PublicStream"]=Vr,Vr.__name__=["promhx","PublicStream"],Vr.publicstream=function(r){var s=new Vr(null);return s.handleResolve(r),s},Vr.__super__=Yt,Vr.prototype=M(Yt.prototype,{resolve:function(r){this.handleResolve(r)},throwError:function(r){this.handleError(r)},update:function(r){this.handleResolve(r)},__class__:Vr});var St=function(){};x["promhx.base.EventLoop"]=St,St.__name__=["promhx","base","EventLoop"],St.enqueue=function(r){St.queue.add(r),St.continueOnNextLoop()},St.set_nextLoop=function(r){if(St.nextLoop!=null)throw new Q("nextLoop has already been set");return St.nextLoop=r,St.nextLoop},St.queueEmpty=function(){return St.queue.isEmpty()},St.finish=function(r){r==null&&(r=1e3);for(var s=null;r-- >0&&(s=St.queue.pop())!=null;)s();return St.queue.isEmpty()},St.clear=function(){St.queue=new F},St.f=function(){var r=St.queue.pop();r!=null&&r(),St.queue.isEmpty()||St.continueOnNextLoop()},St.continueOnNextLoop=function(){St.nextLoop!=null?St.nextLoop(St.f):setImmediate(St.f)};var En=x["promhx.error.PromiseError"]={__ename__:["promhx","error","PromiseError"],__constructs__:["AlreadyResolved","DownstreamNotFullfilled"]};En.AlreadyResolved=function(r){var s=["AlreadyResolved",0,r];return s.__enum__=En,s.toString=S,s},En.DownstreamNotFullfilled=function(r){var s=["DownstreamNotFullfilled",1,r];return s.__enum__=En,s.toString=S,s};var ti=function(){};x["verb.Verb"]=ti,ti.__name__=["verb","Verb"],ti.main=function(){b.log("verb 2.1.0")};var Z=function(){};x["verb.core.ArrayExtensions"]=Z,Z.__name__=["verb","core","ArrayExtensions"],Z.alloc=function(r,s){if(!(s<0))for(;r.length<s;)r.push(null)},Z.reversed=function(r){var s=r.slice();return s.reverse(),s},Z.last=function(r){return r[r.length-1]},Z.first=function(r){return r[0]},Z.spliceAndInsert=function(r,s,o,l){r.splice(s,o),r.splice(s,0,l)},Z.left=function(r){if(r.length==0)return[];var s=Math.ceil(r.length/2);return r.slice(0,s)},Z.right=function(r){if(r.length==0)return[];var s=Math.ceil(r.length/2);return r.slice(s)},Z.rightWithPivot=function(r){if(r.length==0)return[];var s=Math.ceil(r.length/2);return r.slice(s-1)},Z.unique=function(r,s){if(r.length==0)return[];for(var o=[r.pop()];r.length>0;){for(var l=r.pop(),u=!0,d=0;d<o.length;){var g=o[d];if(++d,s(l,g)){u=!1;break}}u&&o.push(l)}return o};var Ft=function(){};x["verb.core.Binomial"]=Ft,Ft.__name__=["verb","core","Binomial"],Ft.get=function(r,s){if(s==0)return 1;if(r==0||s>r)return 0;if(s>r-s&&(s=r-s),Ft.memo_exists(r,s))return Ft.get_memo(r,s);for(var o=1,l=r,u=1,d=s+1;u<d;){var g=u++;if(Ft.memo_exists(l,g)){r--,o=Ft.get_memo(l,g);continue}o*=r--,o/=g,Ft.memoize(l,g,o)}return o},Ft.get_no_memo=function(r,s){if(s==0)return 1;if(r==0||s>r)return 0;s>r-s&&(s=r-s);for(var o=1,l=1,u=s+1;l<u;){var d=l++;o*=r--,o/=d}return o},Ft.memo_exists=function(r,s){return Ft.memo.h.hasOwnProperty(r)&&Ft.memo.h[r].h.hasOwnProperty(s)},Ft.get_memo=function(r,s){return Ft.memo.h[r].h[s]},Ft.memoize=function(r,s,o){Ft.memo.h.hasOwnProperty(r)||Ft.memo.set(r,new wt),Ft.memo.h[r].h[s]=o};var ze=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"]=ze,ze.__name__=["verb","core","BoundingBox"],ze.intervalsOverlap=function(r,s,o,l,u){u==null&&(u=-1);var d;u<-.5?d=rt.TOLERANCE:d=u;var g=Math.min(r,s)-d,_=Math.max(r,s)+d,y=Math.min(o,l)-d,A=Math.max(o,l)+d;return g>=y&&g<=A||_>=y&&_<=A||y>=g&&y<=_||A>=g&&A<=_},ze.prototype={fromPoint:function(r){return new ze([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 s=0,o=this.dim;s<o;){var l=s++;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 s=r.length,o=0;o<s;){var l=o++;this.add(r[l])}return this},contains:function(r,s){return s==null&&(s=-1),this.initialized?this.intersects(new ze([r]),s):!1},intersects:function(r,s){if(s==null&&(s=-1),!this.initialized||!r.initialized)return!1;for(var o=this.min,l=this.max,u=r.min,d=r.max,g=0,_=this.dim;g<_;){var y=g++;if(!ze.intervalsOverlap(o[y],l[y],u[y],d[y],s))return!1}return!0},clear:function(){return this.initialized=!1,this},getLongestAxis:function(){for(var r=0,s=0,o=0,l=this.dim;o<l;){var u=o++,d=this.getAxisLength(u);d>r&&(r=d,s=u)}return s},getAxisLength:function(r){return r<0||r>this.dim-1?0:Math.abs(this.min[r]-this.max[r])},intersect:function(r,s){if(!this.initialized)return null;var o=this.min,l=this.max,u=r.min,d=r.max;if(!this.intersects(r,s))return null;for(var g=[],_=[],y=0,A=this.dim;y<A;){var I=y++;g.push(Math.min(l[I],d[I])),_.push(Math.max(o[I],u[I]))}return new ze([_,g])},__class__:ze};var rt=f.core.Constants=function(){};x["verb.core.Constants"]=rt,rt.__name__=["verb","core","Constants"];var te=f.core.SerializableBase=function(){};x["verb.core.SerializableBase"]=te,te.__name__=["verb","core","SerializableBase"],te.prototype={serialize:function(){var r=new Kt;return r.serialize(this),r.toString()},__class__:te};var Jn=f.core.Plane=function(r,s){this.origin=r,this.normal=s};x["verb.core.Plane"]=Jn,Jn.__name__=["verb","core","Plane"],Jn.__super__=te,Jn.prototype=M(te.prototype,{__class__:Jn});var Mn=f.core.Ray=function(r,s){this.origin=r,this.dir=s};x["verb.core.Ray"]=Mn,Mn.__name__=["verb","core","Ray"],Mn.__super__=te,Mn.prototype=M(te.prototype,{__class__:Mn});var Wt=f.core.NurbsCurveData=function(r,s,o){this.degree=r,this.controlPoints=o,this.knots=s};x["verb.core.NurbsCurveData"]=Wt,Wt.__name__=["verb","core","NurbsCurveData"],Wt.__super__=te,Wt.prototype=M(te.prototype,{__class__:Wt});var ne=f.core.NurbsSurfaceData=function(r,s,o,l,u){this.degreeU=r,this.degreeV=s,this.knotsU=o,this.knotsV=l,this.controlPoints=u};x["verb.core.NurbsSurfaceData"]=ne,ne.__name__=["verb","core","NurbsSurfaceData"],ne.__super__=te,ne.prototype=M(te.prototype,{__class__:ne});var Qe=f.core.MeshData=function(r,s,o,l){this.faces=r,this.points=s,this.normals=o,this.uvs=l};x["verb.core.MeshData"]=Qe,Qe.__name__=["verb","core","MeshData"],Qe.empty=function(){return new Qe([],[],[],[])},Qe.__super__=te,Qe.prototype=M(te.prototype,{__class__:Qe});var ts=f.core.PolylineData=function(r,s){this.points=r,this.params=s};x["verb.core.PolylineData"]=ts,ts.__name__=["verb","core","PolylineData"],ts.__super__=te,ts.prototype=M(te.prototype,{__class__:ts});var es=f.core.VolumeData=function(r,s,o,l,u,d,g){this.degreeU=r,this.degreeV=s,this.degreeW=o,this.knotsU=l,this.knotsV=u,this.knotsW=d,this.controlPoints=g};x["verb.core.VolumeData"]=es,es.__name__=["verb","core","VolumeData"],es.__super__=te,es.prototype=M(te.prototype,{__class__:es});var se=f.core.Pair=function(r,s){this.item0=r,this.item1=s};x["verb.core.Pair"]=se,se.__name__=["verb","core","Pair"],se.prototype={__class__:se};var Ce=f.core.Interval=function(r,s){this.min=r,this.max=s};x["verb.core.Interval"]=Ce,Ce.__name__=["verb","core","Interval"],Ce.prototype={__class__:Ce};var en=f.core.CurveCurveIntersection=function(r,s,o,l){this.point0=r,this.point1=s,this.u0=o,this.u1=l};x["verb.core.CurveCurveIntersection"]=en,en.__name__=["verb","core","CurveCurveIntersection"],en.prototype={__class__:en};var rs=f.core.CurveSurfaceIntersection=function(r,s,o,l){this.u=r,this.uv=s,this.curvePoint=o,this.surfacePoint=l};x["verb.core.CurveSurfaceIntersection"]=rs,rs.__name__=["verb","core","CurveSurfaceIntersection"],rs.prototype={__class__:rs};var Ur=f.core.MeshIntersectionPoint=function(r,s,o,l,u){this.visited=!1,this.adj=null,this.opp=null,this.uv0=r,this.uv1=s,this.point=o,this.faceIndex0,this.faceIndex1};x["verb.core.MeshIntersectionPoint"]=Ur,Ur.__name__=["verb","core","MeshIntersectionPoint"],Ur.prototype={__class__:Ur};var ns=f.core.PolylineMeshIntersection=function(r,s,o,l,u){this.point=r,this.u=s,this.uv=o,this.polylineIndex=l,this.faceIndex=u};x["verb.core.PolylineMeshIntersection"]=ns,ns.__name__=["verb","core","PolylineMeshIntersection"],ns.prototype={__class__:ns};var ss=f.core.SurfaceSurfaceIntersectionPoint=function(r,s,o,l){this.uv0=r,this.uv1=s,this.point=o,this.dist=l};x["verb.core.SurfaceSurfaceIntersectionPoint"]=ss,ss.__name__=["verb","core","SurfaceSurfaceIntersectionPoint"],ss.prototype={__class__:ss};var is=f.core.TriSegmentIntersection=function(r,s,o,l){this.point=r,this.s=s,this.t=o,this.p=l};x["verb.core.TriSegmentIntersection"]=is,is.__name__=["verb","core","TriSegmentIntersection"],is.prototype={__class__:is};var kn=f.core.CurveTriPoint=function(r,s,o){this.u=r,this.point=s,this.uv=o};x["verb.core.CurveTriPoint"]=kn,kn.__name__=["verb","core","CurveTriPoint"],kn.prototype={__class__:kn};var Ke=function(r,s,o,l,u){u==null&&(u=!1),l==null&&(l=-1),this.uv=o,this.point=r,this.normal=s,this.id=l,this.degen=u};x["verb.core.SurfacePoint"]=Ke,Ke.__name__=["verb","core","SurfacePoint"],Ke.fromUv=function(r,s){return new Ke(null,null,[r,s])},Ke.prototype={__class__:Ke};var ei=f.core.CurvePoint=function(r,s){this.u=r,this.pt=s};x["verb.core.CurvePoint"]=ei,ei.__name__=["verb","core","CurvePoint"],ei.prototype={__class__:ei};var as=f.core.KdTree=function(r,s){this.dim=3,this.points=r,this.distanceFunction=s,this.dim=r[0].point.length,this.root=this.buildTree(r,0,null)};x["verb.core.KdTree"]=as,as.__name__=["verb","core","KdTree"],as.prototype={buildTree:function(r,s,o){var l=s%this.dim,u,d;return r.length==0?null:r.length==1?new Cn(r[0],l,o):(r.sort(function(g,_){var y=g.point[l]-_.point[l];return y==0?0:y>0?1:-1}),u=Math.floor(r.length/2),d=new Cn(r[u],l,o),d.left=this.buildTree(r.slice(0,u),s+1,d),d.right=this.buildTree(r.slice(u+1),s+1,d),d)},nearest:function(r,s,o){var l=this,u=new os(function(P){return-P.item1}),d,g=null;g=function(P){for(var E,k=P.dimension,T=l.distanceFunction(r,P.kdPoint.point),B,L=[],R=0,z=l.dim;R<z;)R++,L.push(0);B=L;for(var V,U,Y=function($,tt){u.push(new se($,tt)),u.size()>s&&u.pop()},J=0,q=l.dim;J<q;){var j=J++;j==P.dimension?B[j]=r[j]:B[j]=P.kdPoint.point[j]}if(V=l.distanceFunction(B,P.kdPoint.point),P.right==null&&P.left==null){(u.size()<s||T<u.peek().item1)&&Y(P,T);return}P.right==null?E=P.left:P.left==null?E=P.right:r[k]<P.kdPoint.point[k]?E=P.left:E=P.right,g(E),(u.size()<s||T<u.peek().item1)&&Y(P,T),(u.size()<s||Math.abs(V)<u.peek().item1)&&(E==P.left?U=P.right:U=P.left,U!=null&&g(U))},d=g;for(var _=0;_<s;)_++,u.push(new se(null,o));d(this.root);for(var y=[],A=0;A<s;){var I=A++;u.content[I].item0!=null&&y.push(new se(u.content[I].item0.kdPoint,u.content[I].item1))}return y},__class__:as};var os=function(r){this.content=[],this.scoreFunction=r};x["verb.core.BinaryHeap"]=os,os.__name__=["verb","core","BinaryHeap"],os.prototype={push:function(r){this.content.push(r),this.bubbleUp(this.content.length-1)},pop:function(){var r=this.content[0],s=this.content.pop();return this.content.length>0&&(this.content[0]=s,this.sinkDown(0)),r},peek:function(){return this.content[0]},remove:function(r){for(var s=this.content.length,o=0;o<s;){var l=o++;if(this.content[l]==r){var u=this.content.pop();l!=s-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 s=this.content[r];r>0;){var o=Math.floor((r+1)/2)-1,l=this.content[o];if(this.scoreFunction(s)<this.scoreFunction(l))this.content[o]=s,this.content[r]=l,r=o;else break}},sinkDown:function(r){for(var s=this.content.length,o=this.content[r],l=this.scoreFunction(o);;){var u=(r+1)*2,d=u-1,g=-1,_=0;if(d<s){var y=this.content[d];_=this.scoreFunction(y),_<l&&(g=d)}if(u<s){var A=this.content[u],I=this.scoreFunction(A);I<(g==-1?l:_)&&(g=u)}if(g!=-1)this.content[r]=this.content[g],this.content[g]=o,r=g;else break}},__class__:os};var Tn=f.core.KdPoint=function(r,s){this.point=r,this.obj=s};x["verb.core.KdPoint"]=Tn,Tn.__name__=["verb","core","KdPoint"],Tn.prototype={__class__:Tn};var Cn=f.core.KdNode=function(r,s,o){this.kdPoint=r,this.left=null,this.right=null,this.parent=o,this.dimension=s};x["verb.core.KdNode"]=Cn,Cn.__name__=["verb","core","KdNode"],Cn.prototype={__class__:Cn};var yr=function(){};x["verb.eval.IBoundingBoxTree"]=yr,yr.__name__=["verb","eval","IBoundingBoxTree"],yr.prototype={__class__:yr};var cr=function(r,s){this._boundingBox=null,this._curve=r,s==null&&(s=p.domain(this._curve.knots)/64),this._knotTol=s};x["verb.core.LazyCurveBoundingBoxTree"]=cr,cr.__name__=["verb","core","LazyCurveBoundingBoxTree"],cr.__interfaces__=[yr],cr.prototype={split:function(){var r=Z.first(this._curve.knots),s=Z.last(this._curve.knots),o=s-r,l=de.curveSplit(this._curve,(s+r)/2+o*.1*Math.random());return new se(new cr(l[0],this._knotTol),new cr(l[1],this._knotTol))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=new ze(C.dehomogenize1d(this._curve.controlPoints))),this._boundingBox},yield:function(){return this._curve},indivisible:function(r){return p.domain(this._curve.knots)<this._knotTol},empty:function(){return!1},__class__:cr};var ur=function(r,s){if(this._boundingBox=null,this._mesh=r,s==null){for(var o=[],l=0,u=r.faces.length;l<u;){var d=l++;o.push(d)}s=o}this._faceIndices=s};x["verb.core.LazyMeshBoundingBoxTree"]=ur,ur.__name__=["verb","core","LazyMeshBoundingBoxTree"],ur.__interfaces__=[yr],ur.prototype={split:function(){var r=ie.sortTrianglesOnLongestAxis(this.boundingBox(),this._mesh,this._faceIndices),s=Z.left(r),o=Z.right(r);return new se(new ur(this._mesh,s),new ur(this._mesh,o))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=ie.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__:ur};var dr=function(r,s){this._boundingBox=null,this._polyline=r,s==null&&(s=new Ce(0,r.points.length!=0?r.points.length-1:0)),this._interval=s};x["verb.core.LazyPolylineBoundingBoxTree"]=dr,dr.__name__=["verb","core","LazyPolylineBoundingBoxTree"],dr.__interfaces__=[yr],dr.prototype={split:function(){var r=this._interval.min,s=this._interval.max,o=r+Math.ceil((s-r)/2),l=new Ce(r,o),u=new Ce(o,s);return new se(new dr(this._polyline,l),new dr(this._polyline,u))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=new ze(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__:dr};var jr=function(r,s,o,l){s==null&&(s=!1),this._boundingBox=null,this._surface=r,this._splitV=s,o==null&&(o=p.domain(r.knotsU)/16),l==null&&(l=p.domain(r.knotsV)/16),this._knotTolU=o,this._knotTolV=l};x["verb.core.LazySurfaceBoundingBoxTree"]=jr,jr.__name__=["verb","core","LazySurfaceBoundingBoxTree"],jr.__interfaces__=[yr],jr.prototype={split:function(){var r,s;this._splitV?(r=Z.first(this._surface.knotsV),s=Z.last(this._surface.knotsV)):(r=Z.first(this._surface.knotsU),s=Z.last(this._surface.knotsU));var o=(r+s)/2,l=de.surfaceSplit(this._surface,o,this._splitV);return new se(new jr(l[0],!this._splitV,this._knotTolU,this._knotTolV),new jr(l[1],!this._splitV,this._knotTolU,this._knotTolV))},boundingBox:function(){if(this._boundingBox==null){this._boundingBox=new ze;for(var r=0,s=this._surface.controlPoints;r<s.length;){var o=s[r];++r,this._boundingBox.addRange(C.dehomogenize1d(o))}}return this._boundingBox},yield:function(){return this._surface},indivisible:function(r){return p.domain(this._surface.knotsV)<this._knotTolV&&p.domain(this._surface.knotsU)<this._knotTolU},empty:function(){return!1},__class__:jr};var Ot=f.core.Mat=function(){};x["verb.core.Mat"]=Ot,Ot.__name__=["verb","core","Mat"],Ot.mul=function(r,s){for(var o=[],l=0,u=s.length;l<u;){var d=l++;o.push(p.mul(r,s[d]))}return o},Ot.mult=function(r,s){var o,l,u,d,g,_,y,A;o=r.length,l=s.length,u=s[0].length,d=[];for(var I=o-1,P=0,E=0;I>=0;){for(g=[],_=r[I],E=u-1;E>=0;){for(y=_[l-1]*s[l-1][E],P=l-2;P>=1;)A=P-1,y+=_[P]*s[P][E]+_[A]*s[A][E],P-=2;P==0&&(y+=_[0]*s[0][E]),g[E]=y,E--}d[I]=g,I--}return d},Ot.add=function(r,s){for(var o=[],l=0,u=r.length;l<u;){var d=l++;o.push(p.add(r[d],s[d]))}return o},Ot.div=function(r,s){for(var o=[],l=0,u=r.length;l<u;){var d=l++;o.push(p.div(r[d],s))}return o},Ot.sub=function(r,s){for(var o=[],l=0,u=r.length;l<u;){var d=l++;o.push(p.sub(r[d],s[d]))}return o},Ot.dot=function(r,s){for(var o=[],l=0,u=r.length;l<u;){var d=l++;o.push(p.dot(r[d],s))}return o},Ot.identity=function(r){for(var s=p.zeros2d(r,r),o=0;o<r;){var l=o++;s[l][l]=1}return s},Ot.transpose=function(r){if(r.length==0)return[];for(var s=[],o=0,l=r[0].length;o<l;){var u=o++;s.push(function(d){for(var g,_=[],y=0,A=r.length;y<A;){var I=y++;_.push(r[I][u])}return g=_,g}())}return s},Ot.solve=function(r,s){return Ot.LUsolve(Ot.LU(r),s)},Ot.LUsolve=function(r,s){var o,l,u=r.LU,d=u.length,g=s.slice(),_=r.P,y,A,I;for(o=d-1;o!=-1;)g[o]=s[o],--o;for(o=0;o<d;){for(y=_[o],_[o]!=o&&(I=g[o],g[o]=g[y],g[y]=I),A=u[o],l=0;l<o;)g[o]-=g[l]*A[l],++l;++o}for(o=d-1;o>=0;){for(A=u[o],l=o+1;l<d;)g[o]-=g[l]*A[l],++l;g[o]/=A[o],--o}return g},Ot.LU=function(r){for(var s,o,l,u,d,g,_,y,A,I=[],P=0,E=r.length;P<E;){var k=P++;I.push(r[k].slice())}r=I;var T=r.length,B=T-1,L=[];for(l=0;l<T;){for(_=l,g=r[l],A=Math.abs(g[l]),o=l+1;o<T;)u=Math.abs(r[o][l]),A<u&&(A=u,_=o),++o;for(L[l]=_,_!=l&&(r[l]=r[_],r[_]=g,g=r[l]),d=g[l],s=l+1;s<T;)r[s][l]/=d,++s;for(s=l+1;s<T;){for(y=r[s],o=l+1;o<B;)y[o]-=y[l]*g[o],++o,y[o]-=y[l]*g[o],++o;o==B&&(y[o]-=y[l]*g[o]),++s}++l}return new ls(r,L)};var ls=function(r,s){this.LU=r,this.P=s};x["verb.core._Mat.LUDecomp"]=ls,ls.__name__=["verb","core","_Mat","LUDecomp"],ls.prototype={__class__:ls};var ie=f.core.Mesh=function(){};x["verb.core.Mesh"]=ie,ie.__name__=["verb","core","Mesh"],ie.getTriangleNorm=function(r,s){var o=r[s[0]],l=r[s[1]],u=r[s[2]],d=p.sub(l,o),g=p.sub(u,o),_=p.cross(d,g);return p.mul(1/p.norm(_),_)},ie.makeMeshAabb=function(r,s){for(var o=new ze,l=0;l<s.length;){var u=s[l];++l,o.add(r.points[r.faces[u][0]]),o.add(r.points[r.faces[u][1]]),o.add(r.points[r.faces[u][2]])}return o},ie.sortTrianglesOnLongestAxis=function(r,s,o){for(var l=r.getLongestAxis(),u=[],d=0;d<o.length;){var g=o[d];++d;var _=ie.getMinCoordOnAxis(s.points,s.faces[g],l);u.push(new se(_,g))}u.sort(function(E,k){var T=E.item0,B=k.item0;return T==B?0:T>B?1:-1});for(var y=[],A=0,I=u.length;A<I;){var P=A++;y.push(u[P].item1)}return y},ie.getMinCoordOnAxis=function(r,s,o){for(var l=1/0,u=0;u<3;){var d=u++,g=r[s[d]][o];g<l&&(l=g)}return l},ie.getTriangleCentroid=function(r,s){for(var o=[0,0,0],l=0;l<3;)for(var u=l++,d=0;d<3;){var g=d++;o[g]+=r[s[u]][g]}for(var _=0;_<3;){var y=_++;o[y]/=3}return o},ie.triangleUVFromPoint=function(r,s,o){var l=r.faces[s],u=r.points[l[0]],d=r.points[l[1]],g=r.points[l[2]],_=r.uvs[l[0]],y=r.uvs[l[1]],A=r.uvs[l[2]],I=p.sub(u,o),P=p.sub(d,o),E=p.sub(g,o),k=p.norm(p.cross(p.sub(u,d),p.sub(u,g))),T=p.norm(p.cross(P,E))/k,B=p.norm(p.cross(E,I))/k,L=p.norm(p.cross(I,P))/k;return p.add(p.mul(T,_),p.add(p.mul(B,y),p.mul(L,A)))};var Gr=function(r,s){if(this._empty=!1,this._face=-1,s==null){for(var o=[],l=0,u=r.faces.length;l<u;){var d=l++;o.push(d)}s=o}if(this._boundingBox=ie.makeMeshAabb(r,s),s.length<1){this._empty=!0;return}else if(s.length<2){this._face=s[0];return}var g=ie.sortTrianglesOnLongestAxis(this._boundingBox,r,s),_=Z.left(g),y=Z.right(g);this._children=new se(new Gr(r,_),new Gr(r,y))};x["verb.core.MeshBoundingBoxTree"]=Gr,Gr.__name__=["verb","core","MeshBoundingBoxTree"],Gr.__interfaces__=[yr],Gr.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__:Gr};var Je=f.core.Minimizer=function(){};x["verb.core.Minimizer"]=Je,Je.__name__=["verb","core","Minimizer"],Je.uncmin=function(r,s,o,l,u){o==null&&(o=1e-8),l==null&&(l=function(J){return Je.numericalGradient(r,J)}),u==null&&(u=1e3),s=s.slice(0);var d=s.length,g=r(s),_=g,y;if(isNaN(g))throw new Q("uncmin: f(x0) is a NaN!");o=Math.max(o,rt.EPSILON);var A,I,P,E=Ot.identity(d),k=0,T=[],B,L,R,z,V,U,Y="";for(I=l(s);k<u;){if(!p.all(p.finite(I))){Y="Gradient has Infinity or NaN";break}if(A=p.neg(Ot.dot(E,I)),!p.all(p.finite(A))){Y="Search direction has Infinity or NaN";break}if(U=p.norm(A),U<o){Y="Newton step smaller than tol";break}for(V=1,y=p.dot(I,A),B=s;k<u&&!(V*U<o);){if(T=p.mul(V,A),B=p.add(s,T),_=r(B),_-g>=.1*V*y||isNaN(_)){V*=.5,++k;continue}break}if(V*U<o){Y="Line search step size smaller than tol";break}if(k==u){Y="maxit reached during line search";break}P=l(B),L=p.sub(P,I),z=p.dot(L,T),R=Ot.dot(E,L),E=Ot.sub(Ot.add(E,Ot.mul((z+p.dot(L,R))/(z*z),Je.tensor(T,T))),Ot.div(Ot.add(Je.tensor(R,T),Je.tensor(T,R)),z)),s=B,g=_,I=P,++k}return new hs(s,g,I,E,k,Y)},Je.numericalGradient=function(r,s){var o=s.length,l=r(s);if(l==NaN)throw new Q("gradient: f(x) is a NaN!");for(var u=s.slice(0),d,g,_=[],y,A=.001,I,P,E,k=0,T,B,L,R=0;R<o;)for(var z=R++,V=Math.max(1e-6*l,1e-8);;){if(++k,k>20)throw new Q("Numerical gradient fails");if(u[z]=s[z]+V,d=r(u),u[z]=s[z]-V,g=r(u),u[z]=s[z],isNaN(d)||isNaN(g)){V/=16;continue}if(_[z]=(d-g)/(2*V),I=s[z]-V,P=s[z],E=s[z]+V,T=(d-l)/V,B=(l-g)/V,L=p.max([Math.abs(_[z]),Math.abs(l),Math.abs(d),Math.abs(g),Math.abs(I),Math.abs(P),Math.abs(E),1e-8]),y=Math.min(p.max([Math.abs(T-_[z]),Math.abs(B-_[z]),Math.abs(T-B)])/L,V/L),y>A)V/=16;else break}return _},Je.tensor=function(r,s){for(var o=r.length,l=s.length,u=[],d,g,_=o-1;_>=0;){d=[],g=r[_];for(var y=l-1;y>=3;)d[y]=g*s[y],--y,d[y]=g*s[y],--y,d[y]=g*s[y],--y,d[y]=g*s[y],--y;for(;y>=0;)d[y]=g*s[y],--y;u[_]=d,_--}return u};var hs=function(r,s,o,l,u,d){this.solution=r,this.value=s,this.gradient=o,this.invHessian=l,this.iterations=u,this.message=d};x["verb.core.MinimizationResult"]=hs,hs.__name__=["verb","core","MinimizationResult"],hs.prototype={__class__:hs};var Nn=function(){};x["verb.core.ISerializable"]=Nn,Nn.__name__=["verb","core","ISerializable"],Nn.prototype={__class__:Nn};var ea=f.core.Deserializer=function(){};x["verb.core.Deserializer"]=ea,ea.__name__=["verb","core","Deserializer"],ea.deserialize=function(r){var s=new qt(r),o=s.unserialize();return o};var Re=f.core.Trig=function(){};x["verb.core.Trig"]=Re,Re.__name__=["verb","core","Trig"],Re.isPointInPlane=function(r,s,o){return Math.abs(p.dot(p.sub(r,s.origin),s.normal))<o},Re.distToSegment=function(r,s,o){var l=Re.segmentClosestPoint(s,r,o,0,1);return p.dist(s,l.pt)},Re.rayClosestPoint=function(r,s,o){var l=p.sub(r,s),u=p.dot(l,o),d=p.add(s,p.mul(u,o));return d},Re.distToRay=function(r,s,o){var l=Re.rayClosestPoint(r,s,o),u=p.sub(l,r);return p.norm(u)},Re.threePointsAreFlat=function(r,s,o,l){var u=p.sub(s,r),d=p.sub(o,r),g=p.cross(u,d),_=p.dot(g,g);return _<l},Re.segmentClosestPoint=function(r,s,o,l,u){var d=p.sub(o,s),g=p.norm(d);if(g<rt.EPSILON)return{u:l,pt:s};var _=s,y=p.mul(1/g,d),A=p.sub(r,_),I=p.dot(A,y);return I<0?{u:l,pt:s}:I>g?{u,pt:o}:{u:l+(u-l)*I/g,pt:p.add(_,p.mul(I,y))}};var p=f.core.Vec=function(){};x["verb.core.Vec"]=p,p.__name__=["verb","core","Vec"],p.angleBetween=function(r,s){return Math.acos(p.dot(r,s)/(p.norm(r)*p.norm(s)))},p.positiveAngleBetween=function(r,s,o){var l=p.cross(r,s),u=p.norm(r),d=p.norm(s),g=u*d,_=p.dot(r,s),y=p.norm(l)/g,A=_/g,I=Math.atan2(y,A),P=p.dot(o,l);return Math.abs(P)<rt.EPSILON||P>0?I:-I},p.signedAngleBetween=function(r,s,o){var l=p.cross(r,s),u=p.norm(r),d=p.norm(s),g=u*d,_=p.dot(r,s),y=p.norm(l)/g,A=_/g,I=Math.atan2(y,A),P=p.dot(o,l);return P>0?I:2*Math.PI-I},p.angleBetweenNormalized2d=function(r,s){var o=r[0]*s[1]-r[1]*s[0];return Math.atan2(o,p.dot(r,s))},p.domain=function(r){return Z.last(r)-Z.first(r)},p.range=function(r){for(var s=[],o=0,l=0;l<r;)l++,s.push(o),o+=1;return s},p.span=function(r,s,o){if(o==null)return[];if(o<rt.EPSILON)return[];if(r>s&&o>0)return[];if(s>r&&o<0)return[];for(var l=[],u=r;u<=s;)l.push(u),u+=o;return l},p.neg=function(r){return r.map(function(s){return-s})},p.min=function(r){return O.fold(r,function(s,o){return Math.min(s,o)},1/0)},p.max=function(r){return O.fold(r,function(s,o){return Math.max(s,o)},-1/0)},p.all=function(r){return O.fold(r,function(s,o){return o&&s},!0)},p.finite=function(r){return r.map(function(s){return isFinite(s)})},p.onRay=function(r,s,o){return p.add(r,p.mul(o,s))},p.lerp=function(r,s,o){return p.add(p.mul(r,s),p.mul(1-r,o))},p.normalized=function(r){return p.div(r,p.norm(r))},p.cross=function(r,s){return[r[1]*s[2]-r[2]*s[1],r[2]*s[0]-r[0]*s[2],r[0]*s[1]-r[1]*s[0]]},p.dist=function(r,s){return p.norm(p.sub(r,s))},p.distSquared=function(r,s){return p.normSquared(p.sub(r,s))},p.sum=function(r){return O.fold(r,function(s,o){return o+s},0)},p.addAll=function(r){var s=tr(r)();if(!s.hasNext())return null;var o=s.next().length;return O.fold(r,function(l,u){return p.add(u,l)},p.rep(o,0))},p.addAllMutate=function(r){for(var s=r[0],o=1,l=r.length;o<l;){var u=o++;p.addMutate(s,r[u])}},p.addMulMutate=function(r,s,o){for(var l=0,u=r.length;l<u;){var d=l++;r[d]=r[d]+s*o[d]}},p.subMulMutate=function(r,s,o){for(var l=0,u=r.length;l<u;){var d=l++;r[d]=r[d]-s*o[d]}},p.addMutate=function(r,s){for(var o=0,l=r.length;o<l;){var u=o++;r[u]=r[u]+s[u]}},p.subMutate=function(r,s){for(var o=0,l=r.length;o<l;){var u=o++;r[u]=r[u]-s[u]}},p.mulMutate=function(r,s){for(var o=0,l=s.length;o<l;){var u=o++;s[u]=s[u]*r}},p.norm=function(r){var s=p.normSquared(r);return s!=0?Math.sqrt(s):s},p.normSquared=function(r){return O.fold(r,function(s,o){return o+s*s},0)},p.rep=function(r,s){for(var o=[],l=0;l<r;)l++,o.push(s);return o},p.zeros1d=function(r){for(var s=[],o=0;o<r;)o++,s.push(0);return s},p.zeros2d=function(r,s){for(var o=[],l=0;l<r;)l++,o.push(p.zeros1d(s));return o},p.zeros3d=function(r,s,o){for(var l=[],u=0;u<r;)u++,l.push(p.zeros2d(s,o));return l},p.dot=function(r,s){for(var o=0,l=0,u=r.length;l<u;){var d=l++;o+=r[d]*s[d]}return o},p.add=function(r,s){for(var o=[],l=0,u=r.length;l<u;){var d=l++;o.push(r[d]+s[d])}return o},p.mul=function(r,s){for(var o=[],l=0,u=s.length;l<u;){var d=l++;o.push(r*s[d])}return o},p.div=function(r,s){for(var o=[],l=0,u=r.length;l<u;){var d=l++;o.push(r[d]/s)}return o},p.sub=function(r,s){for(var o=[],l=0,u=r.length;l<u;){var d=l++;o.push(r[d]-s[d])}return o},p.isZero=function(r){for(var s=0,o=r.length;s<o;){var l=s++;if(Math.abs(r[l])>rt.TOLERANCE)return!1}return!0},p.sortedSetUnion=function(r,s){for(var o=[],l=0,u=0;l<r.length||u<s.length;){if(l>=r.length){o.push(s[u]),u++;continue}else if(u>=s.length){o.push(r[l]),l++;continue}var d=r[l]-s[u];if(Math.abs(d)<rt.EPSILON){o.push(r[l]),l++,u++;continue}if(d>0){o.push(s[u]),u++;continue}o.push(r[l]),l++}return o},p.sortedSetSub=function(r,s){for(var o=[],l=0,u=0;l<r.length;){if(u>=s.length){o.push(r[l]),l++;continue}if(Math.abs(r[l]-s[u])<rt.EPSILON){l++,u++;continue}o.push(r[l]),l++}return o};var bt=f.eval.Analyze=function(){};x["verb.eval.Analyze"]=bt,bt.__name__=["verb","eval","Analyze"],bt.knotMultiplicities=function(r){for(var s=[new Ln(r[0],0)],o=s[0],l=0;l<r.length;){var u=r[l];++l,Math.abs(u-o.knot)>rt.EPSILON&&(o=new Ln(u,0),s.push(o)),o.inc()}return s},bt.isRationalSurfaceClosed=function(r,s){s==null&&(s=!0);var o;s?o=r.controlPoints:o=Ot.transpose(r.controlPoints);for(var l=0,u=o[0].length;l<u;){var d=l++,g=p.dist(Z.first(o)[d],Z.last(o)[d])<rt.EPSILON;if(!g)return!1}return!0},bt.rationalSurfaceClosestPoint=function(r,s){var o=bt.rationalSurfaceClosestParam(r,s);return C.rationalSurfacePoint(r,o[0],o[1])},bt.rationalSurfaceClosestParam=function(r,s){for(var o=5,l=0,u,d=1e-4,g=5e-4,_,y=r.knotsU[0],A=Z.last(r.knotsU),I=r.knotsV[0],P=Z.last(r.knotsV),E=bt.isRationalSurfaceClosed(r),k=bt.isRationalSurfaceClosed(r,!1),T,B=zt.rationalSurfaceAdaptive(r,new Wr),L=1/0,R=0,z=B.points.length;R<z;){var V=R++,U=B.points[V],Y=p.normSquared(p.sub(s,U));Y<L&&(L=Y,T=B.uvs[V])}for(var J=function(Ht){return C.rationalSurfaceDerivatives(r,Ht[0],Ht[1],2)},q=function(Ht,$t,Ut){var Qt=$t[1][0],Ne=$t[0][1],Ze=$t[2][0],Ae=$t[0][2],ve=$t[1][1],Le=$t[1][1],Fe=p.dot(Qt,Ut),er=p.dot(Ne,Ut),pr=[-Fe,-er],rr=p.dot(Qt,Qt)+p.dot(Ze,Ut),nr=p.dot(Qt,Ne)+p.dot(ve,Ut),sr=p.dot(Qt,Ne)+p.dot(Le,Ut),br=p.dot(Ne,Ne)+p.dot(Ae,Ut),Rn=[[rr,nr],[sr,br]],nn=Ot.solve(Rn,pr);return p.add(nn,Ht)};l<o;){u=J(T),_=p.sub(u[0][0],s);var j=p.norm(_),$=p.dot(u[1][0],_),tt=p.norm(u[1][0])*j,et=p.dot(u[0][1],_),ot=p.norm(u[0][1])*j,ct=$/tt,lt=et/ot,dt=j<d,nt=ct<g,mt=lt<g;if(dt&&nt&&mt)return T;var K=q(T,u,_);K[0]<y?E?K=[A-(K[0]-y),K[1]]:K=[y+rt.EPSILON,K[1]]:K[0]>A&&(E?K=[y+(K[0]-A),K[1]]:K=[A-rt.EPSILON,K[1]]),K[1]<I?k?K=[K[0],P-(K[1]-I)]:K=[K[0],I+rt.EPSILON]:K[1]>P&&(k?K=[K[0],I+(K[0]-P)]:K=[K[0],P-rt.EPSILON]);var _t=p.norm(p.mul(K[0]-T[0],u[1][0])),Et=p.norm(p.mul(K[1]-T[1],u[0][1]));if(_t+Et<d)return T;T=K,l++}return T},bt.rationalCurveClosestPoint=function(r,s){return C.rationalCurvePoint(r,bt.rationalCurveClosestParam(r,s))},bt.rationalCurveClosestParam=function(r,s){for(var o=1/0,l=0,u=zt.rationalCurveRegularSample(r,r.controlPoints.length*r.degree,!0),d=0,g=u.length-1;d<g;){var _=d++,y=u[_][0],A=u[_+1][0],I=u[_].slice(1),P=u[_+1].slice(1),E=Re.segmentClosestPoint(s,I,P,y,A),k=p.norm(p.sub(s,E.pt));k<o&&(o=k,l=E.u)}for(var T=5,B=0,L,R=1e-4,z=5e-4,V,U=r.knots[0],Y=Z.last(r.knots),J=p.normSquared(p.sub(r.controlPoints[0],Z.last(r.controlPoints)))<rt.EPSILON,q=l,j=function(K){return C.rationalCurveDerivatives(r,K,2)},$=function(K,_t,Et){var Ht=p.dot(_t[1],Et),$t=p.dot(_t[2],Et),Ut=p.dot(_t[1],_t[1]),Qt=$t+Ut;return K-Ht/Qt};B<T;){L=j(q),V=p.sub(L[0],s);var tt=p.norm(V),et=p.dot(L[1],V),ot=p.norm(L[1])*tt,ct=et/ot,lt=tt<R,dt=Math.abs(ct)<z;if(lt&&dt)return q;var nt=$(q,L,V);nt<U?J?nt=Y-(nt-U):nt=U:nt>Y&&(J?nt=U+(nt-Y):nt=Y);var mt=p.norm(p.mul(nt-q,L[1]));if(mt<R)return q;q=nt,B++}return q},bt.rationalCurveParamAtArcLength=function(r,s,o,l,u){if(o==null&&(o=.001),s<rt.EPSILON)return r.knots[0];var d;l!=null?d=l:d=yt.decomposeCurveIntoBeziers(r);var g=0;d[g];var _=-rt.EPSILON,y;for(u!=null?y=u:y=[];_<s&&g<d.length;){if(g<y.length?y[g]=y[g]:y[g]=bt.rationalBezierCurveArcLength(r),_+=y[g],s<_+rt.EPSILON)return bt.rationalBezierCurveParamAtArcLength(r,s,o,y[g]);g++}return-1},bt.rationalBezierCurveParamAtArcLength=function(r,s,o,l){if(s<0)return r.knots[0];var u;if(l!=null?u=l:u=bt.rationalBezierCurveArcLength(r),s>u)return Z.last(r.knots);var d=r.knots[0],g=0,_=Z.last(r.knots),y=u,A=0,I=0,P;for(o!=null?P=o:P=rt.TOLERANCE*2;y-g>P;)A=(d+_)/2,I=bt.rationalBezierCurveArcLength(r,A),I>s?(_=A,y=I):(d=A,g=I);return(d+_)/2},bt.rationalCurveArcLength=function(r,s,o){o==null&&(o=16),s==null?s=Z.last(r.knots):s=s;for(var l=yt.decomposeCurveIntoBeziers(r),u=0,d=l[0],g=0;u<l.length&&d.knots[0]+rt.EPSILON<s;){var _=Math.min(Z.last(d.knots),s);g+=bt.rationalBezierCurveArcLength(d,_,o),d=l[++u]}return g},bt.rationalBezierCurveArcLength=function(r,s,o){o==null&&(o=16);var l;s==null?l=Z.last(r.knots):l=s;for(var u=(l-r.knots[0])/2,d=0,g=r.degree+o,_,y,A=0;A<g;){var I=A++;_=u*bt.Tvalues[g][I]+u+r.knots[0],y=C.rationalCurveDerivatives(r,_,1),d+=bt.Cvalues[g][I]*p.norm(y[1])}return u*d};var Ln=f.eval.KnotMultiplicity=function(r,s){this.knot=r,this.mult=s};x["verb.eval.KnotMultiplicity"]=Ln,Ln.__name__=["verb","eval","KnotMultiplicity"],Ln.prototype={inc:function(){this.mult++},__class__:Ln};var $e=f.eval.Check=function(){};x["verb.eval.Check"]=$e,$e.__name__=["verb","eval","Check"],$e.isValidKnotVector=function(r,s){if(r.length==0||r.length<(s+1)*2)return!1;for(var o=Z.first(r),l=0,u=s+1;l<u;){var d=l++;if(Math.abs(r[d]-o)>rt.EPSILON)return!1}o=Z.last(r);for(var g=r.length-s-1,_=r.length;g<_;){var y=g++;if(Math.abs(r[y]-o)>rt.EPSILON)return!1}return $e.isNonDecreasing(r)},$e.isNonDecreasing=function(r){for(var s=Z.first(r),o=0,l=r.length;o<l;){var u=o++;if(r[u]<s-rt.EPSILON)return!1;s=r[u]}return!0},$e.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(!$e.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},$e.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(!$e.isValidKnotVector(r.knotsU,r.degreeU)||!$e.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 de=f.eval.Divide=function(){};x["verb.eval.Divide"]=de,de.__name__=["verb","eval","Divide"],de.surfaceSplit=function(r,s,o){o==null&&(o=!1);var l,u,d;o?(d=r.controlPoints,l=r.knotsV,u=r.degreeV):(d=Ot.transpose(r.controlPoints),l=r.knotsU,u=r.degreeU);for(var g,_=[],y=0,A=u+1;y<A;)y++,_.push(s);g=_;for(var I=[],P=[],E=C.knotSpan(u,s,l),k=null,T=0;T<d.length;){var B=d[T];++T,k=yt.curveKnotRefine(new Wt(u,l,B),g),I.push(k.controlPoints.slice(0,E+1)),P.push(k.controlPoints.slice(E+1))}var L=k.knots.slice(0,E+u+2),R=k.knots.slice(E+1);return o?[new ne(r.degreeU,u,r.knotsU.slice(),L,I),new ne(r.degreeU,u,r.knotsU.slice(),R,P)]:(I=Ot.transpose(I),P=Ot.transpose(P),[new ne(u,r.degreeV,L,r.knotsV.slice(),I),new ne(u,r.degreeV,R,r.knotsV.slice(),P)])},de.curveSplit=function(r,s){var o=r.degree;r.controlPoints;for(var l=r.knots,u,d=[],g=0,_=o+1;g<_;)g++,d.push(s);u=d;var y=yt.curveKnotRefine(r,u),A=C.knotSpan(o,s,l),I=y.knots.slice(0,A+o+2),P=y.knots.slice(A+1),E=y.controlPoints.slice(0,A+1),k=y.controlPoints.slice(A+1);return[new Wt(o,I,E),new Wt(o,P,k)]},de.rationalCurveByEqualArcLength=function(r,s){var o=bt.rationalCurveArcLength(r),l=o/s;return de.rationalCurveByArcLength(r,l)},de.rationalCurveByArcLength=function(r,s){var o=yt.decomposeCurveIntoBeziers(r),l=o.map(function(E){return bt.rationalBezierCurveArcLength(E)}),u=p.sum(l),d=[new On(r.knots[0],0)];if(s>u)return d;for(var g=s,_=0,y=g,A=0,I=0,P;_<o.length;){for(A+=l[_];y<A+rt.EPSILON;)P=bt.rationalBezierCurveParamAtArcLength(o[_],y-I,rt.TOLERANCE,l[_]),d.push(new On(P,y)),y+=g;I+=l[_],_++}return d};var On=f.eval.CurveLengthSample=function(r,s){this.u=r,this.len=s};x["verb.eval.CurveLengthSample"]=On,On.__name__=["verb","eval","CurveLengthSample"],On.prototype={__class__:On};var C=f.eval.Eval=function(){};x["verb.eval.Eval"]=C,C.__name__=["verb","eval","Eval"],C.rationalCurveTangent=function(r,s){var o=C.rationalCurveDerivatives(r,s,1);return o[1]},C.rationalSurfaceNormal=function(r,s,o){var l=C.rationalSurfaceDerivatives(r,s,o,1);return p.cross(l[1][0],l[0][1])},C.rationalSurfaceDerivatives=function(r,s,o,l){l==null&&(l=1);for(var u=C.surfaceDerivatives(r,s,o,l),d=C.rational2d(u),g=C.weight2d(u),_=[],y=d[0][0].length,A=0,I=l+1;A<I;){var P=A++;_.push([]);for(var E=0,k=l-P+1;E<k;){for(var T=E++,B=d[P][T],L=1,R=T+1;L<R;){var z=L++;p.subMulMutate(B,Ft.get(T,z)*g[0][z],_[P][T-z])}for(var V=1,U=P+1;V<U;){var Y=V++;p.subMulMutate(B,Ft.get(P,Y)*g[Y][0],_[P-Y][T]);for(var J=p.zeros1d(y),q=1,j=T+1;q<j;){var $=q++;p.addMulMutate(J,Ft.get(T,$)*g[Y][$],_[P-Y][T-$])}p.subMulMutate(B,Ft.get(P,Y),J)}p.mulMutate(1/g[0][0],B),_[P].push(B)}}return _},C.rationalSurfacePoint=function(r,s,o){return C.dehomogenize(C.surfacePoint(r,s,o))},C.rationalCurveDerivatives=function(r,s,o){o==null&&(o=1);for(var l=C.curveDerivatives(r,s,o),u=C.rational1d(l),d=C.weight1d(l),g=[],_=0,y=o+1;_<y;){for(var A=_++,I=u[A],P=1,E=A+1;P<E;){var k=P++;p.subMulMutate(I,Ft.get(A,k)*d[k],g[A-k])}p.mulMutate(1/d[0],I),g.push(I)}return g},C.rationalCurvePoint=function(r,s){return C.dehomogenize(C.curvePoint(r,s))},C.surfaceDerivatives=function(r,s,o,l){var u=r.knotsU.length-r.degreeU-2,d=r.knotsV.length-r.degreeV-2;return C.surfaceDerivativesGivenNM(u,d,r,s,o,l)},C.surfaceDerivativesGivenNM=function(r,s,o,l,u,d){var g=o.degreeU,_=o.degreeV,y=o.controlPoints,A=o.knotsU,I=o.knotsV;if(!C.areValidRelations(g,y.length,A.length)||!C.areValidRelations(_,y[0].length,I.length))throw new Q("Invalid relations between control points, knot vector, and n");var P=y[0][0].length,E;d<g?E=d:E=g;var k;d<_?k=d:k=_;for(var T=p.zeros3d(d+1,d+1,P),B=C.knotSpanGivenN(r,g,l,A),L=C.knotSpanGivenN(s,_,u,I),R=C.derivativeBasisFunctionsGivenNI(B,l,g,r,A),z=C.derivativeBasisFunctionsGivenNI(L,u,_,s,I),V=p.zeros2d(_+1,P),U=0,Y=0,J=E+1;Y<J;){for(var q=Y++,j=0,$=_+1;j<$;){var tt=j++;V[tt]=p.zeros1d(P);for(var et=0,ot=g+1;et<ot;){var ct=et++;p.addMulMutate(V[tt],R[q][ct],y[B-g+ct][L-_+tt])}}var lt=d-q;lt<k?U=lt:U=k;for(var dt=0,nt=U+1;dt<nt;){var mt=dt++;T[q][mt]=p.zeros1d(P);for(var K=0,_t=_+1;K<_t;){var Et=K++;p.addMulMutate(T[q][mt],z[mt][Et],V[Et])}}}return T},C.surfacePoint=function(r,s,o){var l=r.knotsU.length-r.degreeU-2,u=r.knotsV.length-r.degreeV-2;return C.surfacePointGivenNM(l,u,r,s,o)},C.surfacePointGivenNM=function(r,s,o,l,u){var d=o.degreeU,g=o.degreeV,_=o.controlPoints,y=o.knotsU,A=o.knotsV;if(!C.areValidRelations(d,_.length,y.length)||!C.areValidRelations(g,_[0].length,A.length))throw new Q("Invalid relations between control points, knot vector, and n");for(var I=_[0][0].length,P=C.knotSpanGivenN(r,d,l,y),E=C.knotSpanGivenN(s,g,u,A),k=C.basisFunctionsGivenKnotSpanIndex(P,l,d,y),T=C.basisFunctionsGivenKnotSpanIndex(E,u,g,A),B=P-d,L=E,R=p.zeros1d(I),z=p.zeros1d(I),V=0,U=g+1;V<U;){var Y=V++;z=p.zeros1d(I),L=E-g+Y;for(var J=0,q=d+1;J<q;){var j=J++;p.addMulMutate(z,k[j],_[B+j][L])}p.addMulMutate(R,T[Y],z)}return R},C.curveRegularSamplePoints=function(r,s){for(var o=C.curveDerivatives(r,r.knots[0],r.degree),l=1/s,u=l*l,d=o[0],g=p.mul(l,o[1]),_=p.mul(u*.5,o[2]),y=p.mul(u*l*.5,o[3]),A=p.add(_,_),I=p.add(y,y),P=p.mul(.3333333333333333,y),E=[],k=0,T=s+1;k<T;)k++,E.push(C.dehomogenize(d)),p.addAllMutate([d,g,_,P]),p.addAllMutate([g,A,y]),p.addAllMutate([A,I]),p.addAllMutate([_,y]);return E},C.curveRegularSamplePoints2=function(r,s){for(var o=C.curveDerivatives(r,r.knots[0],r.degree),l=1/s,u=l*l,d=o[0],g=p.mul(l,o[1]),_=p.mul(u*.5,o[2]),y=p.mul(u*l*.5,o[3]),A=p.add(_,_),I=p.add(y,y),P=p.mul(.3333333333333333,y),E=[],k=0,T=s+1;k<T;)k++,E.push(C.dehomogenize(d)),p.addAllMutate([d,g,_,P]),p.addAllMutate([g,A,y]),p.addAllMutate([A,I]),p.addAllMutate([_,y]);return E},C.rationalSurfaceRegularSampleDerivatives=function(r,s,o,l){for(var u=C.surfaceRegularSampleDerivatives(r,s,o,l),d=[],g=s+1,_=o+1,y=l+1,A=0;A<g;){var I=A++,P=[];d.push(P);for(var E=0;E<_;){for(var k=E++,T=u[I][k],B=C.rational2d(T),L=C.weight2d(T),R=[],z=B[0][0].length,V=0;V<y;){var U=V++;R.push([]);for(var Y=0,J=y-U;Y<J;){for(var q=Y++,j=B[U][q],$=1,tt=q+1;$<tt;){var et=$++;p.subMulMutate(j,Ft.get(q,et)*L[0][et],R[U][q-et])}for(var ot=1,ct=U+1;ot<ct;){var lt=ot++;p.subMulMutate(j,Ft.get(U,lt)*L[lt][0],R[U-lt][q]);for(var dt=p.zeros1d(z),nt=1,mt=q+1;nt<mt;){var K=nt++;p.addMulMutate(dt,Ft.get(q,K)*L[lt][K],R[U-lt][q-K])}p.subMulMutate(j,Ft.get(U,lt),dt)}p.mulMutate(1/L[0][0],j),R[U].push(j)}}P.push(R)}}return d},C.surfaceRegularSampleDerivatives=function(r,s,o,l){var u=r.degreeU,d=r.degreeV,g=r.controlPoints,_=r.knotsU,y=r.knotsV,A=g[0][0].length;(Z.last(_)-_[0])/s,(Z.last(y)-y[0])/o;for(var I=C.regularlySpacedDerivativeBasisFunctions(u,_,s),P=I.item0,E=I.item1,k=C.regularlySpacedDerivativeBasisFunctions(d,y,o),T=k.item0,B=k.item1,L=[],R=s+1,z=o+1,V=0;V<R;){var U=V++,Y=[];L.push(Y);for(var J=0;J<z;){var q=J++;Y.push(C.surfaceDerivativesGivenBasesKnotSpans(u,d,g,P[U],T[q],E[U],B[q],A,l))}}return L},C.rationalSurfaceRegularSamplePoints=function(r,s,o){return C.dehomogenize2d(C.surfaceRegularSamplePoints(r,s,o))},C.surfaceRegularSamplePoints=function(r,s,o){var l=r.degreeU,u=r.degreeV,d=r.controlPoints,g=r.knotsU,_=r.knotsV,y=d[0][0].length;(Z.last(g)-g[0])/s,(Z.last(_)-_[0])/o;for(var A=C.regularlySpacedBasisFunctions(l,g,s),I=A.item0,P=A.item1,E=C.regularlySpacedBasisFunctions(u,_,o),k=E.item0,T=E.item1,B=[],L=s+1,R=o+1,z=0;z<L;){var V=z++,U=[];B.push(U);for(var Y=0;Y<R;){var J=Y++;U.push(C.surfacePointGivenBasesKnotSpans(l,u,d,I[V],k[J],P[V],T[J],y))}}return B},C.regularlySpacedBasisFunctions=function(r,s,o){for(var l=s.length-r-2,u=(Z.last(s)-s[0])/o,d=[],g=[],_=s[0],y=C.knotSpanGivenN(l,r,_,s),A=o+1,I=0;I<A;){for(I++;_>=s[y+1];)y++;g.push(y),d.push(C.basisFunctionsGivenKnotSpanIndex(y,_,r,s)),_+=u}return new se(g,d)},C.regularlySpacedDerivativeBasisFunctions=function(r,s,o){for(var l=s.length-r-2,u=(Z.last(s)-s[0])/o,d=[],g=[],_=s[0],y=C.knotSpanGivenN(l,r,_,s),A=o+1,I=0;I<A;){for(I++;_>=s[y+1];)y++;g.push(y),d.push(C.derivativeBasisFunctionsGivenNI(y,_,r,l,s)),_+=u}return new se(g,d)},C.surfacePointGivenBasesKnotSpans=function(r,s,o,l,u,d,g,_){for(var y=p.zeros1d(_),A,I=l-r,P=u-s,E=0,k=s+1;E<k;){var T=E++;A=p.zeros1d(_);for(var B=0,L=r+1;B<L;){var R=B++;p.addMulMutate(A,d[R],o[I+R][P])}P++,p.addMulMutate(y,g[T],A)}return y},C.surfaceDerivativesGivenBasesKnotSpans=function(r,s,o,l,u,d,g,_,y){var A=o[0][0].length,I;y<r?I=y:I=r;var P;y<s?P=y:P=s;for(var E=p.zeros3d(I+1,P+1,A),k=p.zeros2d(s+1,A),T=0,B=0,L=I+1;B<L;){for(var R=B++,z=0,V=s+1;z<V;){var U=z++;k[U]=p.zeros1d(A);for(var Y=0,J=r+1;Y<J;){var q=Y++;p.addMulMutate(k[U],d[R][q],o[l-r+q][u-s+U])}}var j=y-R;j<P?T=j:T=P;for(var $=0,tt=T+1;$<tt;){var et=$++;E[R][et]=p.zeros1d(A);for(var ot=0,ct=s+1;ot<ct;){var lt=ot++;p.addMulMutate(E[R][et],g[et][lt],k[lt])}}}return E},C.curveDerivatives=function(r,s,o){var l=r.knots.length-r.degree-2;return C.curveDerivativesGivenN(l,r,s,o)},C.curveDerivativesGivenN=function(r,s,o,l){var u=s.degree,d=s.controlPoints,g=s.knots;if(!C.areValidRelations(u,d.length,g.length))throw new Q("Invalid relations between control points, knot vector, and n");var _=d[0].length,y;l<u?y=l:y=u;for(var A=p.zeros2d(l+1,_),I=C.knotSpanGivenN(r,u,o,g),P=C.derivativeBasisFunctionsGivenNI(I,o,u,y,g),E=0,k=y+1;E<k;)for(var T=E++,B=0,L=u+1;B<L;){var R=B++;p.addMulMutate(A[T],P[T][R],d[I-u+R])}return A},C.curvePoint=function(r,s){var o=r.knots.length-r.degree-2;return C.curvePointGivenN(o,r,s)},C.areValidRelations=function(r,s,o){return s+r+1-o==0},C.curvePointGivenN=function(r,s,o){var l=s.degree,u=s.controlPoints,d=s.knots;if(!C.areValidRelations(l,u.length,d.length))throw new Q("Invalid relations between control points, knot Array, and n");for(var g=C.knotSpanGivenN(r,l,o,d),_=C.basisFunctionsGivenKnotSpanIndex(g,o,l,d),y=p.zeros1d(u[0].length),A=0,I=l+1;A<I;){var P=A++;p.addMulMutate(y,_[P],u[g-l+P])}return y},C.volumePoint=function(r,s,o,l){var u=r.knotsU.length-r.degreeU-2,d=r.knotsV.length-r.degreeV-2,g=r.knotsW.length-r.degreeW-2;return C.volumePointGivenNML(r,u,d,g,s,o,l)},C.volumePointGivenNML=function(r,s,o,l,u,d,g){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,y=r.degreeU,A=r.degreeV,I=r.degreeW,P=r.knotsU,E=r.knotsV,k=r.knotsW,T=_[0][0][0].length,B=C.knotSpanGivenN(s,y,u,P),L=C.knotSpanGivenN(o,A,d,E),R=C.knotSpanGivenN(l,I,g,k),z=C.basisFunctionsGivenKnotSpanIndex(B,u,y,P),V=C.basisFunctionsGivenKnotSpanIndex(L,d,A,E),U=C.basisFunctionsGivenKnotSpanIndex(R,g,I,k),Y=B-y,J=p.zeros1d(T),q=p.zeros1d(T),j=p.zeros1d(T),$=0,tt=I+1;$<tt;){var et=$++;j=p.zeros1d(T);for(var ot=R-I+et,ct=0,lt=A+1;ct<lt;){var dt=ct++;q=p.zeros1d(T);for(var nt=L-A+dt,mt=0,K=y+1;mt<K;){var _t=mt++;p.addMulMutate(q,z[_t],_[Y+_t][nt][ot])}p.addMulMutate(j,V[dt],q)}p.addMulMutate(J,U[et],j)}return J},C.derivativeBasisFunctions=function(r,s,o){var l=C.knotSpan(s,r,o),u=o.length-1,d=u-s-1;return C.derivativeBasisFunctionsGivenNI(l,r,s,d,o)},C.derivativeBasisFunctionsGivenNI=function(r,s,o,l,u){var d=p.zeros2d(o+1,o+1),g=p.zeros1d(o+1),_=p.zeros1d(o+1),y=0,A=0;d[0][0]=1;for(var I=1,P=o+1;I<P;){var E=I++;g[E]=s-u[r+1-E],_[E]=u[r+E]-s,y=0;for(var k=0;k<E;){var T=k++;d[E][T]=_[T+1]+g[E-T],A=d[T][E-1]/d[E][T],d[T][E]=y+_[T+1]*A,y=g[E-T]*A}d[E][E]=y}for(var B=p.zeros2d(l+1,o+1),L=p.zeros2d(2,o+1),R=0,z=1,V=0,U=0,Y=0,J=0,q=0,j=0,$=o+1;j<$;){var tt=j++;B[0][tt]=d[tt][o]}for(var et=0,ot=o+1;et<ot;){var ct=et++;R=0,z=1,L[0][0]=1;for(var lt=1,dt=l+1;lt<dt;){var nt=lt++;V=0,U=ct-nt,Y=o-nt,ct>=nt&&(L[z][0]=L[R][0]/d[Y+1][U],V=L[z][0]*d[U][Y]),U>=-1?J=1:J=-U,ct-1<=Y?q=nt-1:q=o-ct;for(var mt=J,K=q+1;mt<K;){var _t=mt++;L[z][_t]=(L[R][_t]-L[R][_t-1])/d[Y+1][U+_t],V+=L[z][_t]*d[U+_t][Y]}ct<=Y&&(L[z][nt]=-L[R][nt-1]/d[Y+1][ct],V+=L[z][nt]*d[ct][Y]),B[nt][ct]=V;var Et=R;R=z,z=Et}}for(var Ht=o,$t=1,Ut=l+1;$t<Ut;){for(var Qt=$t++,Ne=0,Ze=o+1;Ne<Ze;){var Ae=Ne++;B[Qt][Ae]*=Ht}Ht*=o-Qt}return B},C.basisFunctions=function(r,s,o){var l=C.knotSpan(s,r,o);return C.basisFunctionsGivenKnotSpanIndex(l,r,s,o)},C.basisFunctionsGivenKnotSpanIndex=function(r,s,o,l){var u=p.zeros1d(o+1),d=p.zeros1d(o+1),g=p.zeros1d(o+1),_=0,y=0;u[0]=1;for(var A=1,I=o+1;A<I;){var P=A++;d[P]=s-l[r+1-P],g[P]=l[r+P]-s,_=0;for(var E=0;E<P;){var k=E++;y=u[k]/(g[k+1]+d[P-k]),u[k]=_+g[k+1]*y,_=d[P-k]*y}u[P]=_}return u},C.knotSpan=function(r,s,o){return C.knotSpanGivenN(o.length-r-2,r,s,o)},C.knotSpanGivenN=function(r,s,o,l){if(o>l[r+1]-rt.EPSILON)return r;if(o<l[s]+rt.EPSILON)return s;for(var u=s,d=r+1,g=Math.floor((u+d)/2);o<l[g]||o>=l[g+1];)o<l[g]?d=g:u=g,g=Math.floor((u+d)/2);return g},C.dehomogenize=function(r){for(var s=r.length,o=[],l=r[s-1],u=r.length-1,d=0;d<u;){var g=d++;o.push(r[g]/l)}return o},C.rational1d=function(r){var s=r[0].length-1;return r.map(function(o){return o.slice(0,s)})},C.rational2d=function(r){return r.map(C.rational1d)},C.weight1d=function(r){var s=r[0].length-1;return r.map(function(o){return o[s]})},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,s){var o=r.length,l=r[0].length,u=[],d=0,g=[],_;s!=null?_=s:_=p.rep(r.length,1);for(var y=0;y<o;){var A=y++,I=[];g=r[A],d=_[A];for(var P=0;P<l;){var E=P++;I.push(g[E]*d)}I.push(d),u.push(I)}return u},C.homogenize2d=function(r,s){var o=r.length,l=[],u;if(s!=null)u=s;else{for(var d=[],g=0;g<o;)g++,d.push(p.rep(r[0].length,1));u=d}for(var _=0;_<o;){var y=_++;l.push(C.homogenize1d(r[y],u[y]))}return l};var ht=f.eval.Intersect=function(){};x["verb.eval.Intersect"]=ht,ht.__name__=["verb","eval","Intersect"],ht.surfaces=function(r,s,o){var l=zt.rationalSurfaceAdaptive(r),u=zt.rationalSurfaceAdaptive(s),d=ht.meshes(l,u),g=d.map(function(_){return _.map(function(y){return ht.surfacesAtPointWithEstimate(r,s,y.uv0,y.uv1,o)})});return g.map(function(_){return gt.rationalInterpCurve(_.map(function(y){return y.point}),3)})},ht.surfacesAtPointWithEstimate=function(r,s,o,l,u){var d,g,_,y,A,I,P,E,k,T,B,L,R,z=5,V=0;do{if(d=C.rationalSurfaceDerivatives(r,o[0],o[1],1),g=d[0][0],y=d[1][0],A=d[0][1],_=p.normalized(p.cross(y,A)),I=p.dot(_,g),P=C.rationalSurfaceDerivatives(s,l[0],l[1],1),E=P[0][0],T=P[1][0],B=P[0][1],k=p.normalized(p.cross(T,B)),L=p.dot(k,E),R=p.distSquared(g,E),R<u*u)break;var U=p.normalized(p.cross(_,k)),Y=p.dot(U,g),J=ht.threePlanes(_,I,k,L,U,Y);if(J==null)throw new Q("panic!");var q=p.sub(J,g),j=p.sub(J,E),$=p.cross(y,_),tt=p.cross(A,_),et=p.cross(T,k),ot=p.cross(B,k),ct=p.dot(tt,q)/p.dot(tt,y),lt=p.dot($,q)/p.dot($,A),dt=p.dot(ot,j)/p.dot(ot,T),nt=p.dot(et,j)/p.dot(et,B);o=p.add([ct,lt],o),l=p.add([dt,nt],l),V++}while(V<z);return new ss(o,l,g,R)},ht.meshes=function(r,s,o,l){o==null&&(o=new ur(r)),l==null&&(l=new ur(s));var u=ht.boundingBoxTrees(o,l,0),d=Z.unique(u.map(function(g){return ht.triangles(r,g.item0,s,g.item1)}).filter(function(g){return g!=null}).filter(function(g){return p.distSquared(g.min.point,g.max.point)>rt.EPSILON}),function(g,_){var y=p.sub(g.min.uv0,_.min.uv0),A=p.dot(y,y),I=p.sub(g.max.uv0,_.max.uv0),P=p.dot(I,I),E=p.sub(g.min.uv0,_.max.uv0),k=p.dot(E,E),T=p.sub(g.max.uv0,_.min.uv0),B=p.dot(T,T);return A<rt.EPSILON&&P<rt.EPSILON||k<rt.EPSILON&&B<rt.EPSILON});return ht.makeMeshIntersectionPolylines(d)},ht.meshSlices=function(r,s,o,l){for(var u=new Gr(r),d=u.boundingBox(),g=d.min[0],_=d.min[1],y=d.max[0],A=d.max[1],I=p.span(s,o,l),P=[],E=0;E<I.length;){var k=I[E];++E;var T=[[g,_,k],[y,_,k],[y,A,k],[g,A,k]],B=[[0,0],[1,0],[1,1],[0,1]],L=[[0,1,2],[0,2,3]],R=new Qe(L,T,null,B);P.push(ht.meshes(r,R,u))}return P},ht.makeMeshIntersectionPolylines=function(r){if(r.length==0)return[];for(var s=0;s<r.length;){var o=r[s];++s,o.max.opp=o.min,o.min.opp=o.max}for(var l=ht.kdTreeFromSegments(r),u=[],d=0;d<r.length;){var g=r[d];++d,u.push(g.min),u.push(g.max)}for(var _=0;_<u.length;){var y=u[_];if(++_,y.adj==null){var A=ht.lookupAdjacentSegment(y,l,r.length);A!=null&&A.adj==null&&(y.adj=A,A.adj=y)}}var I=u.filter(function(z){return z.adj==null});I.length==0&&(I=u);for(var P=[],E=0,k=!1;I.length!=0;){var T=I.pop();if(!T.visited){for(var B=[],L=T;L!=null&&!(L.visited||(L.visited=!0,L.opp.visited=!0,B.push(L),E+=2,L=L.opp.adj,L==T)););B.length>0&&(B.push(B[B.length-1].opp),P.push(B))}if(I.length==0&&u.length>0&&(k||E<u.length)){k=!0;var R=u.pop();I.push(R)}}return P},ht.kdTreeFromSegments=function(r){for(var s=[],o=0;o<r.length;){var l=r[o];++o,s.push(new Tn(l.min.point,l.min)),s.push(new Tn(l.max.point,l.max))}return new as(s,p.distSquared)},ht.lookupAdjacentSegment=function(r,s,o){var l=s.nearest(r.point,o,rt.EPSILON).filter(function(u){return r!=u.item0.obj}).map(function(u){return u.item0.obj});return l.length==1?l[0]:null},ht.curveAndSurface=function(r,s,o,l,u){o==null&&(o=.001),l!=null?l=l:l=new cr(r),u!=null?u=u:u=new jr(s);var d=ht.boundingBoxTrees(l,u,o);return Z.unique(d.map(function(g){var _=g.item0,y=g.item1,A=Z.first(_.knots),I=Z.last(_.knots),P=(A+I)/2,E=Z.first(y.knotsU),k=Z.last(y.knotsU),T=Z.first(y.knotsV),B=Z.last(y.knotsV),L=[(E+k)/2,(T+B)/2];return ht.curveAndSurfaceWithEstimate(_,y,[P].concat(L),o)}).filter(function(g){return p.distSquared(g.curvePoint,g.surfacePoint)<o*o}),function(g,_){return Math.abs(g.u-_.u)<.5*o})},ht.curveAndSurfaceWithEstimate=function(r,s,o,l){l==null&&(l=.001);var u=function(y){var A=C.rationalCurvePoint(r,y[0]),I=C.rationalSurfacePoint(s,y[1],y[2]),P=p.sub(A,I);return p.dot(P,P)},d=function(y){var A=C.rationalCurveDerivatives(r,y[0],1),I=C.rationalSurfaceDerivatives(s,y[1],y[2],1),P=p.sub(I[0][0],A[0]),E=p.mul(-1,A[1]),k=I[1][0],T=I[0][1];return[2*p.dot(E,P),2*p.dot(k,P),2*p.dot(T,P)]},g=Je.uncmin(u,o,l*l,d),_=g.solution;return new rs(_[0],[_[1],_[2]],C.rationalCurvePoint(r,_[0]),C.rationalSurfacePoint(s,_[1],_[2]))},ht.polylineAndMesh=function(r,s,o){for(var l=ht.boundingBoxTrees(new dr(r),new ur(s),o),u=[],d=0;d<l.length;){var g=l[d];++d;var _=g.item0,y=g.item1,A=ht.segmentWithTriangle(r.points[_],r.points[_+1],s.points,s.faces[y]);if(A!=null){var I=A.point,P=p.lerp(A.p,[r.params[_]],[r.params[_+1]])[0],E=ie.triangleUVFromPoint(s,y,I);u.push(new ns(I,P,E,_,y))}}return u},ht.boundingBoxTrees=function(r,s,o){o==null&&(o=1e-9);var l=[],u=[];l.push(r),u.push(s);for(var d=[];l.length>0;){var g=l.pop(),_=u.pop();if(!(g.empty()||_.empty())&&g.boundingBox().intersects(_.boundingBox(),o)){var y=g.indivisible(o),A=_.indivisible(o);if(y&&A){d.push(new se(g.yield(),_.yield()));continue}else if(y&&!A){var I=_.split();l.push(g),u.push(I.item1),l.push(g),u.push(I.item0);continue}else if(!y&&A){var P=g.split();l.push(P.item1),u.push(_),l.push(P.item0),u.push(_);continue}var E=g.split(),k=_.split();l.push(E.item1),u.push(k.item1),l.push(E.item1),u.push(k.item0),l.push(E.item0),u.push(k.item1),l.push(E.item0),u.push(k.item0)}}return d},ht.curves=function(r,s,o){var l=ht.boundingBoxTrees(new cr(r),new cr(s),0);return Z.unique(l.map(function(u){return ht.curvesWithEstimate(r,s,Z.first(u.item0.knots),Z.first(u.item1.knots),o)}).filter(function(u){return p.distSquared(u.point0,u.point1)<o}),function(u,d){return Math.abs(u.u0-d.u0)<o*5})},ht.curvesWithEstimate=function(r,s,o,l,u){var d=function(E){var k=C.rationalCurvePoint(r,E[0]),T=C.rationalCurvePoint(s,E[1]),B=p.sub(k,T);return p.dot(B,B)},g=function(E){var k=C.rationalCurveDerivatives(r,E[0],1),T=C.rationalCurveDerivatives(s,E[1],1),B=p.sub(k[0],T[0]),L=k[1],R=p.mul(-1,T[1]);return[2*p.dot(L,B),2*p.dot(R,B)]},_=Je.uncmin(d,[o,l],u*u,g),y=_.solution[0],A=_.solution[1],I=C.rationalCurvePoint(r,y),P=C.rationalCurvePoint(s,A);return new en(I,P,y,A)},ht.triangles=function(r,s,o,l){var u=r.faces[s],d=o.faces[l],g=ie.getTriangleNorm(r.points,u),_=ie.getTriangleNorm(o.points,d),y=r.points[u[0]],A=o.points[d[0]],I=ht.planes(y,g,A,_);if(I==null)return null;var P=ht.clipRayInCoplanarTriangle(I,r,s);if(P==null)return null;var E=ht.clipRayInCoplanarTriangle(I,o,l);if(E==null)return null;var k=ht.mergeTriangleClipIntervals(P,E,r,s,o,l);return k==null?null:new Ce(new Ur(k.min.uv0,k.min.uv1,k.min.point,s,l),new Ur(k.max.uv0,k.max.uv1,k.max.point,s,l))},ht.clipRayInCoplanarTriangle=function(r,s,o){for(var l=s.faces[o],u=[s.points[l[0]],s.points[l[1]],s.points[l[2]]],d=[s.uvs[l[0]],s.uvs[l[1]],s.uvs[l[2]]],g=[p.sub(d[1],d[0]),p.sub(d[2],d[1]),p.sub(d[0],d[2])],_=[p.sub(u[1],u[0]),p.sub(u[2],u[1]),p.sub(u[0],u[2])],y=_.map(p.normalized),A=_.map(p.norm),I=null,P=null,E=0;E<3;){var k=E++,T=u[k],B=y[k],L=ht.rays(T,B,r.origin,r.dir);if(L!=null){var R=L.u0,z=L.u1;R<-rt.EPSILON||R>A[k]+rt.EPSILON||((I==null||z<I.u)&&(I=new kn(z,p.onRay(r.origin,r.dir,z),p.onRay(d[k],g[k],R/A[k]))),(P==null||z>P.u)&&(P=new kn(z,p.onRay(r.origin,r.dir,z),p.onRay(d[k],g[k],R/A[k]))))}}return P==null||I==null?null:new Ce(I,P)},ht.mergeTriangleClipIntervals=function(r,s,o,l,u,d){if(s.min.u>r.max.u+rt.EPSILON||r.min.u>s.max.u+rt.EPSILON)return null;var g;r.min.u>s.min.u?g=new se(r.min,0):g=new se(s.min,1);var _;r.max.u<s.max.u?_=new se(r.max,0):_=new se(s.max,1);var y=new Ce(new Ur(null,null,g.item0.point,l,d),new Ur(null,null,_.item0.point,l,d));return g.item1==0?(y.min.uv0=g.item0.uv,y.min.uv1=ie.triangleUVFromPoint(u,d,g.item0.point)):(y.min.uv0=ie.triangleUVFromPoint(o,l,g.item0.point),y.min.uv1=g.item0.uv),_.item1==0?(y.max.uv0=_.item0.uv,y.max.uv1=ie.triangleUVFromPoint(u,d,_.item0.point)):(y.max.uv0=ie.triangleUVFromPoint(o,l,_.item0.point),y.max.uv1=_.item0.uv),y},ht.planes=function(r,s,o,l){var u=p.cross(s,l);if(p.dot(u,u)<rt.EPSILON)return null;var d=0,g=Math.abs(u[0]),_=Math.abs(u[1]),y=Math.abs(u[2]);_>g&&(d=1,g=_),y>g&&(d=2,g=y);var A,I,P,E;d==0?(A=s[1],I=s[2],P=l[1],E=l[2]):d==1?(A=s[0],I=s[2],P=l[0],E=l[2]):(A=s[0],I=s[1],P=l[0],E=l[1]);var k=-p.dot(r,s),T=-p.dot(o,l),B=A*E-I*P,L=(I*T-k*E)/B,R=(k*P-A*T)/B,z;return d==0?z=[0,L,R]:d==1?z=[L,0,R]:z=[L,R,0],new Mn(z,p.normalized(u))},ht.threePlanes=function(r,s,o,l,u,d){var g=p.cross(o,u),_=p.dot(r,g);if(Math.abs(_)<rt.EPSILON)return null;var y=p.sub(p.mul(d,o),p.mul(l,u)),A=p.add(p.mul(s,g),p.cross(r,y));return p.mul(1/_,A)},ht.polylines=function(r,s,o){for(var l=ht.boundingBoxTrees(new dr(r),new dr(s),o),u=[],d=0;d<l.length;){var g=l[d];++d;var _=g.item0,y=g.item1,A=ht.segments(r.points[_],r.points[_+1],s.points[y],s.points[y+1],o);A!=null&&(A.u0=p.lerp(A.u0,[r.params[_]],[r.params[_+1]])[0],A.u1=p.lerp(A.u1,[s.params[y]],[s.params[y+1]])[0],u.push(A))}return u},ht.segments=function(r,s,o,l,u){var d=p.sub(s,r),g=Math.sqrt(p.dot(d,d)),_=p.mul(1/g,d),y=p.sub(l,o),A=Math.sqrt(p.dot(y,y)),I=p.mul(1/A,y),P=ht.rays(r,_,o,I);if(P!=null){var E=Math.min(Math.max(0,P.u0/g),1),k=Math.min(Math.max(0,P.u1/A),1),T=p.onRay(r,d,E),B=p.onRay(o,y,k),L=p.distSquared(T,B);if(L<u*u)return new en(T,B,E,k)}return null},ht.rays=function(r,s,o,l){var u=p.dot(s,l),d=p.dot(s,o),g=p.dot(s,r),_=p.dot(l,o),y=p.dot(l,r),A=p.dot(s,s),I=p.dot(l,l),P=A*I-u*u;if(Math.abs(P)<rt.EPSILON)return null;var E=u*(d-g)-A*(_-y),k=E/P,T=(d-g+k*u)/A,B=p.onRay(r,s,T),L=p.onRay(o,l,k);return new en(B,L,T,k)},ht.segmentWithTriangle=function(r,s,o,l){var u=o[l[0]],d=o[l[1]],g=o[l[2]],_=p.sub(d,u),y=p.sub(g,u),A=p.cross(_,y),I=p.sub(s,r),P=p.sub(r,u),E=-p.dot(A,P),k=p.dot(A,I);if(Math.abs(k)<rt.EPSILON)return null;var T=E/k;if(T<0||T>1)return null;var B=p.add(r,p.mul(T,I)),L=p.dot(_,y),R=p.dot(_,_),z=p.dot(y,y),V=p.sub(B,u),U=p.dot(V,_),Y=p.dot(V,y),J=L*L-R*z;if(Math.abs(J)<rt.EPSILON)return null;var q=(L*Y-z*U)/J,j=(L*U-R*Y)/J;return q>1+rt.EPSILON||j>1+rt.EPSILON||j<-rt.EPSILON||q<-rt.EPSILON||q+j>1+rt.EPSILON?null:new is(B,q,j,T)},ht.segmentAndPlane=function(r,s,o,l){var u=p.dot(l,p.sub(s,r));if(Math.abs(u)<rt.EPSILON)return null;var d=p.dot(l,p.sub(o,r)),g=d/u;return g>1+rt.EPSILON||g<-rt.EPSILON?null:{p:g}};var gt=f.eval.Make=function(){};x["verb.eval.Make"]=gt,gt.__name__=["verb","eval","Make"],gt.rationalTranslationalSurface=function(r,s){for(var o=C.rationalCurvePoint(s,Z.first(s.knots)),l=Z.first(s.knots),u=Z.last(s.knots),d=2*s.controlPoints.length,g=(u-l)/(d-1),_=[],y=0;y<d;){var A=y++,I=p.sub(C.rationalCurvePoint(s,l+A*g),o),P=yt.rationalCurveTransform(r,[[1,0,0,I[0]],[0,1,0,I[1]],[0,0,1,I[2]],[0,0,0,1]]);_.push(P)}return gt.loftedSurface(_)},gt.surfaceBoundaryCurves=function(r){var s=gt.surfaceIsocurve(r,Z.first(r.knotsU),!1),o=gt.surfaceIsocurve(r,Z.last(r.knotsU),!1),l=gt.surfaceIsocurve(r,Z.first(r.knotsV),!0),u=gt.surfaceIsocurve(r,Z.last(r.knotsV),!0);return[s,o,l,u]},gt.surfaceIsocurve=function(r,s,o){o==null&&(o=!1);var l;o?l=r.knotsV:l=r.knotsU;var u;o?u=r.degreeV:u=r.degreeU;for(var d=bt.knotMultiplicities(l),g=-1,_=0,y=d.length;_<y;){var A=_++;if(Math.abs(s-d[A].knot)<rt.EPSILON){g=A;break}}var I=u+1;g>=0&&(I=I-d[g].mult);var P;I>0?P=yt.surfaceKnotRefine(r,p.rep(I,s),o):P=r;var E=C.knotSpan(u,s,l);return Math.abs(s-Z.first(l))<rt.EPSILON?E=0:Math.abs(s-Z.last(l))<rt.EPSILON&&(E=(o?P.controlPoints[0].length:P.controlPoints.length)-1),o?new Wt(P.degreeU,P.knotsU,function(k){for(var T,B=[],L=0,R=P.controlPoints;L<R.length;){var z=R[L];++L,B.push(z[E])}return T=B,T}()):new Wt(P.degreeV,P.knotsV,P.controlPoints[E])},gt.loftedSurface=function(r,s){r=yt.unifyCurveKnotVectors(r);var o=r[0].degree;s==null&&(s=3),s>r.length-1&&(s=r.length-1);for(var l=r[0].knots,u=[],d=[],g=0,_=r[0].controlPoints.length;g<_;){var y=[g++],A=r.map(function(P){return function(E){return E.controlPoints[P[0]]}}(y)),I=gt.rationalInterpCurve(A,s,!0);d.push(I.controlPoints),u=I.knots}return new ne(o,s,l,u,d)},gt.clonedCurve=function(r){return new Wt(r.degree,r.knots.slice(),r.controlPoints.map(function(s){return s.slice()}))},gt.rationalBezierCurve=function(r,s){for(var o=r.length-1,l=[],u=0,d=o+1;u<d;)u++,l.push(0);for(var g=0,_=o+1;g<_;)g++,l.push(1);return s==null&&(s=p.rep(r.length,1)),new Wt(o,l,C.homogenize1d(r,s))},gt.fourPointSurface=function(r,s,o,l,u){u==null&&(u=3);for(var d=u,g=[],_=0,y=u+1;_<y;){for(var A=_++,I=[],P=0,E=u+1;P<E;){var k=P++,T=1-A/d,B=p.lerp(T,r,s),L=p.lerp(T,l,o),R=p.lerp(1-k/d,B,L);R.push(1),I.push(R)}g.push(I)}var z=p.rep(u+1,0),V=p.rep(u+1,1);return new ne(u,u,z.concat(V),z.concat(V),g)},gt.ellipseArc=function(r,s,o,l,u){var d=p.norm(s),g=p.norm(o);s=p.normalized(s),o=p.normalized(o),u<l&&(u=2*Math.PI+l);var _=u-l,y=0;_<=Math.PI/2?y=1:_<=Math.PI?y=2:_<=3*Math.PI/2?y=3:y=4;var A=_/y,I=Math.cos(A/2),P=p.add(r,p.add(p.mul(d*Math.cos(l),s),p.mul(g*Math.sin(l),o))),E=p.sub(p.mul(Math.cos(l),o),p.mul(Math.sin(l),s)),k=[],T=p.zeros1d(2*y+3),B=0,L=l,R=p.zeros1d(y*2);k[0]=P,R[0]=1;for(var z=1,V=y+1;z<V;){var U=z++;L+=A;var Y=p.add(r,p.add(p.mul(d*Math.cos(L),s),p.mul(g*Math.sin(L),o)));R[B+2]=1,k[B+2]=Y;var J=p.sub(p.mul(Math.cos(L),o),p.mul(Math.sin(L),s)),q=ht.rays(P,p.mul(1/p.norm(E),E),Y,p.mul(1/p.norm(J),J)),j=p.add(P,p.mul(q.u0,E));R[B+1]=I,k[B+1]=j,B+=2,U<y&&(P=Y,E=J)}for(var $=2*y+1,tt=0;tt<3;){var et=tt++;T[et]=0,T[et+$]=1}switch(y){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 Wt(2,T,C.homogenize1d(k,R))},gt.arc=function(r,s,o,l,u,d){return gt.ellipseArc(r,p.mul(l,p.normalized(s)),p.mul(l,p.normalized(o)),u,d)},gt.polyline=function(r){for(var s=[0,0],o=0,l=0,u=r.length-1;l<u;){var d=l++;o+=p.dist(r[d],r[d+1]),s.push(o)}s.push(o),s=p.mul(1/o,s);for(var g,_=[],y=0,A=r.length;y<A;)y++,_.push(1);return g=_,new Wt(1,s,C.homogenize1d(r.slice(0),g))},gt.extrudedSurface=function(r,s,o){for(var l=[[],[],[]],u=[[],[],[]],d=C.dehomogenize1d(o.controlPoints),g=C.weight1d(o.controlPoints),_=p.mul(s,r),y=p.mul(.5*s,r),A=0,I=d.length;A<I;){var P=A++;l[2][P]=d[P],l[1][P]=p.add(y,d[P]),l[0][P]=p.add(_,d[P]),u[0][P]=g[P],u[1][P]=g[P],u[2][P]=g[P]}return new ne(2,o.degree,[0,0,0,1,1,1],o.knots,C.homogenize2d(l,u))},gt.cylindricalSurface=function(r,s,o,l,u){var d=p.cross(r,s),g=gt.arc(o,s,d,u,0,2*Math.PI);return gt.extrudedSurface(r,l,g)},gt.revolvedSurface=function(r,s,o,l){var u=C.dehomogenize1d(r.controlPoints),d=C.weight1d(r.controlPoints),g,_;l<=Math.PI/2?(g=1,_=p.zeros1d(6+2*(g-1))):l<=Math.PI?(g=2,_=p.zeros1d(6+2*(g-1)),_[3]=_[4]=.5):l<=3*Math.PI/2?(g=3,_=p.zeros1d(6+2*(g-1)),_[3]=_[4]=.3333333333333333,_[5]=_[6]=.6666666666666666):(g=4,_=p.zeros1d(6+2*(g-1)),_[3]=_[4]=.25,_[5]=_[6]=.5,_[7]=_[8]=.75);for(var y=l/g,A=3+2*(g-1),I=0;I<3;){var P=I++;_[P]=0,_[A+P]=1}for(var E=Math.cos(y/2),k=0,T=p.zeros1d(g+1),B=p.zeros1d(g+1),L=p.zeros3d(2*g+1,u.length,3),R=p.zeros2d(2*g+1,u.length),z=1,V=g+1;z<V;){var U=z++;k+=y,B[U]=Math.cos(k),T[U]=Math.sin(k)}for(var Y=0,J=u.length;Y<J;){var q=Y++,j=Re.rayClosestPoint(u[q],s,o),$=p.sub(u[q],j),tt=p.norm($),et=p.cross(o,$);tt>rt.EPSILON&&($=p.mul(1/tt,$),et=p.mul(1/tt,et)),L[0][q]=u[q];var ot=u[q];R[0][q]=d[q];for(var ct=et,lt=0,dt=1,nt=g+1;dt<nt;){var mt=dt++,K;tt==0?K=j:K=p.add(j,p.add(p.mul(tt*B[mt],$),p.mul(tt*T[mt],et))),L[lt+2][q]=K,R[lt+2][q]=d[q];var _t=p.sub(p.mul(B[mt],et),p.mul(T[mt],$));if(tt==0)L[lt+1][q]=j;else{var Et=ht.rays(ot,p.mul(1/p.norm(ct),ct),K,p.mul(1/p.norm(_t),_t)),Ht=p.add(ot,p.mul(Et.u0,ct));L[lt+1][q]=Ht}R[lt+1][q]=E*d[q],lt+=2,mt<g&&(ot=K,ct=_t)}}return new ne(2,r.degree,_,r.knots,C.homogenize2d(L,R))},gt.sphericalSurface=function(r,s,o,l){var u=gt.arc(r,p.mul(-1,s),o,l,0,Math.PI);return gt.revolvedSurface(u,r,s,2*Math.PI)},gt.conicalSurface=function(r,s,o,l,u){var d=2*Math.PI,g=1,_=[p.add(o,p.mul(l,r)),p.add(o,p.mul(u,s))],y=[0,0,1,1],A=[1,1],I=new Wt(g,y,C.homogenize1d(_,A));return gt.revolvedSurface(I,o,r,d)},gt.rationalInterpCurve=function(r,s,o,l,u){if(o==null&&(o=!1),s==null&&(s=3),r.length<s+1)throw new Q("You need to supply at least degree + 1 points! You only supplied "+r.length+" points.");for(var d=[0],g=1,_=r.length;g<_;){var y=g++,A=p.norm(p.sub(r[y],r[y-1])),I=d[d.length-1];d.push(I+A)}for(var P=d[d.length-1],E=0,k=d.length;E<k;){var T=E++;d[T]=d[T]/P}var B=p.rep(s+1,0),L=l!=null&&u!=null,R;L?R=0:R=1;var z;L?z=d.length-s+1:z=d.length-s;for(var V=R;V<z;){for(var U=V++,Y=0,J=0;J<s;){var q=J++;Y+=d[U+q]}B.push(1/s*Y)}var j=B.concat(p.rep(s+1,1)),$=[],tt;L?tt=r.length+1:tt=r.length-1;var et;L?et=r.length-(s-1):et=r.length-(s+1);for(var ot=0;ot<d.length;){var ct=d[ot];++ot;var lt=C.knotSpanGivenN(tt,s,ct,j),dt=C.basisFunctionsGivenKnotSpanIndex(lt,ct,s,j),nt=lt-s,mt=p.zeros1d(nt),K=p.zeros1d(et-nt);$.push(mt.concat(dt).concat(K))}if(L){var _t=$[0].length-2,Et=[-1,1].concat(p.zeros1d(_t)),Ht=p.zeros1d(_t).concat([-1,1]);Z.spliceAndInsert($,1,0,Et),Z.spliceAndInsert($,$.length-1,0,Ht)}for(var $t=r[0].length,Ut=[],Qt=(1-j[j.length-s-2])/s,Ne=j[s+1]/s,Ze=0;Ze<$t;){var Ae=[Ze++],ve;if(!L)ve=r.map(function(sr){return function(br){return br[sr[0]]}}(Ae));else{ve=[r[0][Ae[0]]],ve.push(Ne*l[Ae[0]]);for(var Le=1,Fe=r.length-1;Le<Fe;){var er=Le++;ve.push(r[er][Ae[0]])}ve.push(Qt*u[Ae[0]]),ve.push(Z.last(r)[Ae[0]])}var pr=Ot.solve($,ve);Ut.push(pr)}var rr=Ot.transpose(Ut);if(!o){var nr=p.rep(rr.length,1);rr=C.homogenize1d(rr,nr)}return new Wt(s,j,rr)};var yt=f.eval.Modify=function(){};x["verb.eval.Modify"]=yt,yt.__name__=["verb","eval","Modify"],yt.curveReverse=function(r){return new Wt(r.degree,yt.knotsReverse(r.knots),Z.reversed(r.controlPoints))},yt.surfaceReverse=function(r,s){return s==null&&(s=!1),s?new ne(r.degreeU,r.degreeV,r.knotsU,yt.knotsReverse(r.knotsV),function(o){for(var l,u=[],d=0,g=r.controlPoints;d<g.length;){var _=g[d];++d,u.push(Z.reversed(_))}return l=u,l}()):new ne(r.degreeU,r.degreeV,yt.knotsReverse(r.knotsU),r.knotsV,Z.reversed(r.controlPoints))},yt.knotsReverse=function(r){var s=Z.first(r);Z.last(r);for(var o=[s],l=r.length,u=1;u<l;){var d=u++;o.push(o[d-1]+(r[l-d]-r[l-d-1]))}return o},yt.unifyCurveKnotVectors=function(r){r=r.map(gt.clonedCurve);for(var s=O.fold(r,function(j,$){return yt.imax(j.degree,$)},0),o=0,l=r.length;o<l;){var u=o++;r[u].degree<s&&(r[u]=yt.curveElevateDegree(r[u],s))}for(var d,g=[],_=0;_<r.length;){var y=r[_];++_,g.push(new Ce(Z.first(y.knots),Z.last(y.knots)))}d=g;for(var A=0,I=r.length;A<I;){var P=A++,E=[d[P].min];r[P].knots=r[P].knots.map(function(j){return function($){return $-j[0]}}(E))}for(var k=d.map(function(j){return j.max-j.min}),T=O.fold(k,function(j,$){return Math.max(j,$)},0),B=0,L=r.length;B<L;){var R=B++,z=[T/k[R]];r[R].knots=r[R].knots.map(function(j){return function($){return $*j[0]}}(z))}for(var V=O.fold(r,function(j,$){return p.sortedSetUnion(j.knots,$)},[]),U=0,Y=r.length;U<Y;){var J=U++,q=p.sortedSetSub(V,r[J].knots);q.length==0&&(r[J]=r[J]),r[J]=yt.curveKnotRefine(r[J],q)}return r},yt.imin=function(r,s){return r<s?r:s},yt.imax=function(r,s){return r>s?r:s},yt.curveElevateDegree=function(r,s){if(s<=r.degree)return r;var o=r.knots.length-r.degree-2,l=r.degree,u=r.knots,d=r.controlPoints,g=s-r.degree,_=r.controlPoints[0].length,y=p.zeros2d(l+g+1,l+1),A=[],I=[],P=[],E=o+l+1,k=s,T=Math.floor(k/2),B=[],L=[];y[0][0]=1,y[k][l]=1;for(var R=1,z=T+1;R<z;)for(var V=R++,U=1/Ft.get(k,V),Y=yt.imin(l,V),J=yt.imax(0,V-g),q=Y+1;J<q;){var j=J++;y[V][j]=U*Ft.get(l,j)*Ft.get(g,V-j)}for(var $=T+1;$<k;)for(var tt=$++,et=yt.imin(l,tt),ot=yt.imax(0,tt-g),ct=et+1;ot<ct;){var lt=ot++;y[tt][lt]=y[k-tt][l-lt]}var dt=k+1,nt=-1,mt=l,K=l+1,_t=1,Et=u[0];B[0]=d[0];for(var Ht=0,$t=k+1;Ht<$t;){var Ut=Ht++;L[Ut]=Et}for(var Qt=0,Ne=l+1;Qt<Ne;){var Ze=Qt++;A[Ze]=d[Ze]}for(;K<E;){for(var Ae=K;K<E&&u[K]==u[K+1];)K=K+1;var ve=K-Ae+1,Le=u[K],Fe=nt;nt=l-ve;var er;Fe>0?er=Math.floor((Fe+2)/2):er=1;var pr;if(nt>0?pr=Math.floor(k-(nt+1)/2):pr=k,nt>0){for(var rr=Le-Et,nr=[],sr=l;sr>ve;)nr[sr-ve-1]=rr/(u[mt+sr]-Et),sr--;for(var br=1,Rn=nt+1;br<Rn;){for(var nn=br++,pu=nt-nn,ia=ve+nn,sn=l;sn>=ia;)A[sn]=p.add(p.mul(nr[sn-ia],A[sn]),p.mul(1-nr[sn-ia],A[sn-1])),sn--;P[pu]=A[l]}}for(var Ko=er,mu=k+1;Ko<mu;){var Dn=Ko++;I[Dn]=p.zeros1d(_);for(var gu=yt.imin(l,Dn),$o=yt.imax(0,Dn-g),fu=gu+1;$o<fu;){var Zo=$o++;I[Dn]=p.add(I[Dn],p.mul(y[Dn][Zo],A[Zo]))}}if(Fe>1)for(var aa=dt-2,oa=dt,Qo=Le-Et,_u=(Le-L[dt-1])/Qo,Jo=1;Jo<Fe;){for(var la=Jo++,xr=aa,an=oa,Kr=an-dt+1;an-xr>la;){if(xr<_t){var yu=(Le-L[xr])/(Et-L[xr]);B[xr]=p.lerp(yu,B[xr],B[xr-1])}if(an>=er){if(an-la<=dt-k+Fe){var vu=(Le-L[an-la])/Qo;I[Kr]=p.lerp(vu,I[Kr],I[Kr+1])}}else I[Kr]=p.lerp(_u,I[Kr],I[Kr+1]);xr=xr+1,an=an-1,Kr=Kr-1}aa=aa-1,oa=oa+1}if(mt!=l)for(var tl=0,bu=k-Fe;tl<bu;)tl++,L[dt]=Et,dt=dt+1;for(var el=er,xu=pr+1;el<xu;){var wu=el++;B[_t]=I[wu],_t=_t+1}if(K<E){for(var rl=0;rl<nt;){var nl=rl++;A[nl]=P[nl]}for(var sl=nt,Au=l+1;sl<Au;){var il=sl++;A[il]=d[K-l+il]}mt=K,K=K+1,Et=Le}else for(var al=0,Pu=k+1;al<Pu;){var Iu=al++;L[dt+Iu]=Le}}return new Wt(s,L,B)},yt.rationalSurfaceTransform=function(r,s){for(var o=C.dehomogenize2d(r.controlPoints),l=0,u=o.length;l<u;)for(var d=l++,g=0,_=o[d].length;g<_;){var y=g++,A=o[d][y];A.push(1),o[d][y]=Ot.dot(s,A).slice(0,A.length-1)}return new ne(r.degreeU,r.degreeV,r.knotsU.slice(),r.knotsV.slice(),C.homogenize2d(o,C.weight2d(r.controlPoints)))},yt.rationalCurveTransform=function(r,s){for(var o=C.dehomogenize1d(r.controlPoints),l=0,u=o.length;l<u;){var d=l++,g=o[d];g.push(1),o[d]=Ot.dot(s,g).slice(0,g.length-1)}return new Wt(r.degree,r.knots.slice(),C.homogenize1d(o,C.weight1d(r.controlPoints)))},yt.surfaceKnotRefine=function(r,s,o){var l=[],u,d,g;o?(g=r.controlPoints,u=r.knotsV,d=r.degreeV):(g=Ot.transpose(r.controlPoints),u=r.knotsU,d=r.degreeU);for(var _=null,y=0;y<g.length;){var A=g[y];++y,_=yt.curveKnotRefine(new Wt(d,u,A),s),l.push(_.controlPoints)}var I=_.knots;return o?new ne(r.degreeU,r.degreeV,r.knotsU.slice(),I,l):(l=Ot.transpose(l),new ne(r.degreeU,r.degreeV,I,r.knotsV.slice(),l))},yt.decomposeCurveIntoBeziers=function(r){for(var s=r.degree,o=r.controlPoints,l=r.knots,u=bt.knotMultiplicities(l),d=s+1,g=0;g<u.length;){var _=u[g];if(++g,_.mult<d){var y=p.rep(d-_.mult,_.knot),A=yt.curveKnotRefine(new Wt(s,l,o),y);l=A.knots,o=A.controlPoints}}l.length/d-1;for(var I=d*2,P=[],E=0;E<o.length;){var k=l.slice(E,E+I),T=o.slice(E,E+d);P.push(new Wt(s,k,T)),E+=d}return P},yt.curveKnotRefine=function(r,s){if(s.length==0)return gt.clonedCurve(r);for(var o=r.degree,l=r.controlPoints,u=r.knots,d=l.length-1,g=d+o+1,_=s.length-1,y=C.knotSpan(o,s[0],u),A=C.knotSpan(o,s[_],u),I=[],P=[],E=0,k=y-o+1;E<k;){var T=E++;I[T]=l[T]}for(var B=A-1,L=d+1;B<L;){var R=B++;I[R+_+1]=l[R]}for(var z=0,V=y+1;z<V;){var U=z++;P[U]=u[U]}for(var Y=A+o,J=g+1;Y<J;){var q=Y++;P[q+_+1]=u[q]}for(var j=A+o-1,$=A+o+_,tt=_;tt>=0;){for(;s[tt]<=u[j]&&j>y;)I[$-o-1]=l[j-o-1],P[$]=u[j],$=$-1,j=j-1;I[$-o-1]=I[$-o];for(var et=1,ot=o+1;et<ot;){var ct=et++,lt=$-o+ct,dt=P[$+ct]-s[tt];Math.abs(dt)<rt.EPSILON?I[lt-1]=I[lt]:(dt=dt/(P[$+ct]-u[j-o+ct]),I[lt-1]=p.add(p.mul(dt,I[lt-1]),p.mul(1-dt,I[lt])))}P[$]=s[tt],$=$-1,tt--}return new Wt(o,P,I)},yt.curveKnotInsert=function(r,s,o){for(var l=r.degree,u=r.controlPoints,d=r.knots,g=0,_=u.length,y=C.knotSpan(l,s,d),A=[],I=[],P=[],E=1,k=y+1;E<k;){var T=E++;I[T]=d[T]}for(var B=1,L=o+1;B<L;){var R=B++;I[y+R]=s}for(var z=y+1,V=d.length;z<V;){var U=z++;I[U+o]=d[U]}for(var Y=0,J=y-l+1;Y<J;){var q=Y++;P[q]=u[q]}for(var j=y-g;j<_;){var $=j++;P[$+o]=u[$]}for(var tt=0,et=l-g+1;tt<et;){var ot=tt++;A[ot]=u[y-l+ot]}for(var ct=0,lt=0,dt=1,nt=o+1;dt<nt;){var mt=dt++;ct=y-l+mt;for(var K=0,_t=l-mt-g+1;K<_t;){var Et=K++;lt=(s-d[ct+Et])/(d[Et+y+1]-d[ct+Et]),A[Et]=p.add(p.mul(lt,A[Et+1]),p.mul(1-lt,A[Et]))}P[ct]=A[0],P[y+o-mt-g]=A[l-mt-g]}for(var Ht=ct+1,$t=y-g;Ht<$t;){var Ut=Ht++;P[Ut]=A[Ut-ct]}return new Wt(l,I,P)};var zt=f.eval.Tess=function(){};x["verb.eval.Tess"]=zt,zt.__name__=["verb","eval","Tess"],zt.rationalCurveRegularSample=function(r,s,o){return zt.rationalCurveRegularSampleRange(r,r.knots[0],Z.last(r.knots),s,o)},zt.rationalCurveRegularSampleRange=function(r,s,o,l,u){l<1&&(l=2);for(var d=[],g=(o-s)/(l-1),_=0,y=0;y<l;){var A=y++;_=s+g*A,u?d.push([_].concat(C.rationalCurvePoint(r,_))):d.push(C.rationalCurvePoint(r,_))}return d},zt.rationalCurveAdaptiveSample=function(r,s,o){if(o==null&&(o=!1),s==null&&(s=1e-6),r.degree==1)if(o){for(var l=[],u=0,d=r.controlPoints.length;u<d;){var g=u++;l.push([r.knots[g+1]].concat(C.dehomogenize(r.controlPoints[g])))}return l}else return r.controlPoints.map(C.dehomogenize);return zt.rationalCurveAdaptiveSampleRange(r,r.knots[0],Z.last(r.knots),s,o)},zt.rationalCurveAdaptiveSampleRange=function(r,s,o,l,u){var d=C.rationalCurvePoint(r,s),g=C.rationalCurvePoint(r,o),_=.5+.2*Math.random(),y=s+(o-s)*_,A=C.rationalCurvePoint(r,y),I=p.sub(d,g),P=p.sub(d,A);if(p.dot(I,I)<l&&p.dot(P,P)>l||!Re.threePointsAreFlat(d,A,g,l)){var E=s+(o-s)*.5,k=zt.rationalCurveAdaptiveSampleRange(r,s,E,l,u),T=zt.rationalCurveAdaptiveSampleRange(r,E,o,l,u);return k.slice(0,-1).concat(T)}else return u?[[s].concat(d),[o].concat(g)]:[d,g]},zt.rationalSurfaceNaive=function(r,s,o){s<1&&(s=1),o<1&&(o=1),r.degreeU,r.degreeV,r.controlPoints;for(var l=r.knotsU,u=r.knotsV,d=Z.last(l)-l[0],g=Z.last(u)-u[0],_=d/s,y=g/o,A=[],I=[],P=[],E=0,k=s+1;E<k;)for(var T=E++,B=0,L=o+1;B<L;){var R=B++,z=T*_,V=R*y;I.push([z,V]);var U=C.rationalSurfaceDerivatives(r,z,V,1),Y=U[0][0];A.push(Y);var J=p.normalized(p.cross(U[1][0],U[0][1]));P.push(J)}for(var q=[],j=0;j<s;)for(var $=j++,tt=0;tt<o;){var et=tt++,ot=$*(o+1)+et,ct=($+1)*(o+1)+et,lt=ct+1,dt=ot+1,nt=[ot,ct,lt],mt=[ot,lt,dt];q.push(nt),q.push(mt)}return new Qe(q,A,P,I)},zt.divideRationalSurfaceAdaptive=function(r,s){s==null&&(s=new Wr),s.minDivsU!=null?s.minDivsU=s.minDivsU:s.minDivsU=1,s.minDivsV!=null?s.minDivsU=s.minDivsV:s.minDivsU=1,s.refine!=null?s.refine=s.refine:s.refine=!0;var o=(r.controlPoints.length-1)*2,l=(r.controlPoints[0].length-1)*2,u;s.minDivsU>o?u=s.minDivsU=s.minDivsU:u=s.minDivsU=o;var d;s.minDivsV>l?d=s.minDivsV=s.minDivsV:d=s.minDivsV=l;for(var g=Z.last(r.knotsU),_=r.knotsU[0],y=Z.last(r.knotsV),A=r.knotsV[0],I=(g-_)/u,P=(y-A)/d,E=[],k=[],T=0,B=d+1;T<B;){for(var L=T++,R=[],z=0,V=u+1;z<V;){var U=z++,Y=_+I*U,J=A+P*L,q=C.rationalSurfaceDerivatives(r,Y,J,1),j=p.normalized(p.cross(q[0][1],q[1][0]));R.push(new Ke(q[0][0],j,[Y,J],-1,p.isZero(j)))}k.push(R)}for(var $=0;$<d;)for(var tt=$++,et=0;et<u;){var ot=et++,ct=[k[d-tt-1][ot],k[d-tt-1][ot+1],k[d-tt][ot+1],k[d-tt][ot]];E.push(new vr(r,ct))}if(!s.refine)return E;for(var lt=0;lt<d;)for(var dt=lt++,nt=0;nt<u;){var mt=nt++,K=dt*u+mt,_t=zt.north(K,dt,mt,u,d,E),Et=zt.east(K,dt,mt,u,d,E),Ht=zt.south(K,dt,mt,u,d,E),$t=zt.west(K,dt,mt,u,d,E);E[K].neighbors=[Ht,Et,_t,$t],E[K].divide(s)}return E},zt.north=function(r,s,o,l,u,d){return s==0?null:d[r-l]},zt.south=function(r,s,o,l,u,d){return s==u-1?null:d[r+l]},zt.east=function(r,s,o,l,u,d){return o==l-1?null:d[r+1]},zt.west=function(r,s,o,l,u,d){return o==0?null:d[r-1]},zt.triangulateAdaptiveRefinementNodeTree=function(r){for(var s=Qe.empty(),o=0;o<r.length;){var l=r[o];++o,l.triangulate(s)}return s},zt.rationalSurfaceAdaptive=function(r,s){s!=null?s=s:s=new Wr;var o=zt.divideRationalSurfaceAdaptive(r,s);return zt.triangulateAdaptiveRefinementNodeTree(o)};var Wr=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"]=Wr,Wr.__name__=["verb","eval","AdaptiveRefinementOptions"],Wr.prototype={__class__:Wr};var vr=f.core.AdaptiveRefinementNode=function(r,s,o){if(this.srf=r,o==null?this.neighbors=[null,null,null,null]:this.neighbors=o,this.corners=s,this.corners==null){var l=r.knotsU[0],u=Z.last(r.knotsU),d=r.knotsV[0],g=Z.last(r.knotsV);this.corners=[Ke.fromUv(l,d),Ke.fromUv(u,d),Ke.fromUv(u,g),Ke.fromUv(l,g)]}};x["verb.eval.AdaptiveRefinementNode"]=vr,vr.__name__=["verb","eval","AdaptiveRefinementNode"],vr.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 s=r++;if(this.corners[s].point==null){var o=this.corners[s];this.evalSrf(o.uv[0],o.uv[1],o)}}},evalSrf:function(r,s,o){var l=C.rationalSurfaceDerivatives(this.srf,r,s,1),u=l[0][0],d=p.cross(l[0][1],l[1][0]),g=p.isZero(d);return g||(d=p.normalized(d)),o!=null?(o.degen=g,o.point=u,o.normal=d,o):new Ke(u,d,[r,s],-1,g)},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 s=[this.corners[r]];if(this.neighbors[r]==null)return s;var o=this.neighbors[r].getEdgeCorners((r+2)%4),l=r%2,u=rt.EPSILON,d=this,g=[function(y){return y.uv[0]>d.corners[0].uv[0]+u&&y.uv[0]<d.corners[2].uv[0]-u},function(y){return y.uv[1]>d.corners[0].uv[1]+u&&y.uv[1]<d.corners[2].uv[1]-u}],_=o.filter(g[l]);return _.reverse(),s.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,s=0;s<r;){var o=s++;if(this.corners[o],this.corners[o].degen){var l=this.corners[(o+1)%r],u=this.corners[(o+3)%r];l.degen?this.corners[o].normal=u.normal:this.corners[o].normal=l.normal}}},shouldDivide:function(r,s){if(s<r.minDepth)return!0;if(s>=r.maxDepth)return!1;if(this.hasBadNormals())return this.fixNormals(),!1;if(this.splitVert=p.normSquared(p.sub(this.corners[0].normal,this.corners[1].normal))>r.normTol||p.normSquared(p.sub(this.corners[2].normal,this.corners[3].normal))>r.normTol,this.splitHoriz=p.normSquared(p.sub(this.corners[1].normal,this.corners[2].normal))>r.normTol||p.normSquared(p.sub(this.corners[3].normal,this.corners[0].normal))>r.normTol,this.splitVert||this.splitHoriz)return!0;var o=this.center();return p.normSquared(p.sub(o.normal,this.corners[0].normal))>r.normTol||p.normSquared(p.sub(o.normal,this.corners[1].normal))>r.normTol||p.normSquared(p.sub(o.normal,this.corners[2].normal))>r.normTol||p.normSquared(p.sub(o.normal,this.corners[3].normal))>r.normTol},divide:function(r){r==null&&(r=new Wr),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,s,o){if(this.evalCorners(),!!this.shouldDivide(r,s)){if(s++,this.splitVert&&!this.splitHoriz?o=!1:!this.splitVert&&this.splitHoriz&&(o=!0),this.horizontal=o,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 vr(this.srf,l),new vr(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]],g=[this.midpoint(0),this.corners[1],this.corners[2],this.midpoint(2)];this.children=[new vr(this.srf,d),new vr(this.srf,g)],this.children[0].neighbors=[this.neighbors[0],this.children[1],this.neighbors[2],this.neighbors[3]],this.children[1].neighbors=[this.neighbors[0],this.neighbors[1],this.neighbors[2],this.children[0]]}for(var _=0,y=this.children;_<y.length;){var A=y[_];++_,A._divide(r,s,!o)}}},triangulate:function(r){if(r==null&&(r=Qe.empty()),this.isLeaf())return this.triangulateLeaf(r);for(var s=0,o=this.children;s<o.length;){var l=o[s];if(++s,l==null)break;l.triangulate(r)}return r},triangulateLeaf:function(r){for(var s=r.points.length,o=[],l=[],u=0,d=0;d<4;){var g=d++,_=this.getAllCorners(g);_.length==2&&(u=g+1);for(var y=0,A=_.length;y<A;){var I=y++;o.push(_[I])}}for(var P=0;P<o.length;){var E=o[P];if(++P,E.id!=-1){l.push(E.id);continue}r.uvs.push(E.uv),r.points.push(E.point),r.normals.push(E.normal),E.id=s,l.push(s),s++}if(o.length==4)return r.faces.push([l[0],l[3],l[1]]),r.faces.push([l[3],l[2],l[1]]),r;if(o.length==5){var k=l.length;return r.faces.push([l[u],l[(u+2)%k],l[(u+1)%k]]),r.faces.push([l[(u+4)%k],l[(u+3)%k],l[u]]),r.faces.push([l[u],l[(u+3)%k],l[(u+2)%k]]),r}var T=this.center();r.uvs.push(T.uv),r.points.push(T.point),r.normals.push(T.normal);for(var B=r.points.length-1,L=0,R=o.length-1;L<o.length;)r.faces.push([B,l[L],l[R]]),R=L++;return r},__class__:vr};var At=f.exe.Dispatcher=function(){};x["verb.exe.Dispatcher"]=At,At.__name__=["verb","exe","Dispatcher"],At.init=function(){At._init||(At._workerPool=new Hr(At.THREADS),At._init=!0)},At.dispatchMethod=function(r,s,o){At.init();var l=new Sn,u=function(d){l.resolve(d)};return At._workerPool.addWork(ut.getClassName(r),s,o,u),new ye(l)};var Hr=f.exe.WorkerPool=function(r,s){s==null&&(s="verb.js"),r==null&&(r=1),this._callbacks=new wt,this._working=new wt,this._pool=[],this._queue=[];for(var o=0;o<r;){o++;var l;try{l=new Worker(Hr.basePath+s)}catch(u){u instanceof Q&&(u=u.val),l=new Worker(Hr.basePath+s.substring(0,-3)+".min.js")}this._pool.push(l)}};x["verb.exe.WorkerPool"]=Hr,Hr.__name__=["verb","exe","WorkerPool"],Hr.prototype={addWork:function(r,s,o,l){var u=new rn(r,s,o);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 s=this._queue.shift(),o=[s.id],l=[this._pool.shift()];this._working.h[o[0]]=l[0],l[0].onmessage=function(u,d){return function(g){r._working.remove(d[0]),r._pool.push(u[0]);try{r._callbacks.h.hasOwnProperty(d[0])&&(r._callbacks.h[d[0]](g.data.result),r._callbacks.remove(d[0]))}catch(_){_ instanceof Q&&(_=_.val),b.log(_)}r.processQueue()}}(l,o),l[0].postMessage(s)}},__class__:Hr};var rn=function(r,s,o){this.className=r,this.methodName=s,this.args=o,this.id=rn.uuid++};x["verb.exe._WorkerPool.Work"]=rn,rn.__name__=["verb","exe","_WorkerPool","Work"],rn.prototype={__class__:rn};var Bn=function(){};x["verb.geom.ICurve"]=Bn,Bn.__name__=["verb","geom","ICurve"],Bn.__interfaces__=[Nn],Bn.prototype={__class__:Bn};var Lt=f.geom.NurbsCurve=function(r){this._data=$e.isValidNurbsCurveData(r)};x["verb.geom.NurbsCurve"]=Lt,Lt.__name__=["verb","geom","NurbsCurve"],Lt.__interfaces__=[Bn],Lt.byKnotsControlPointsWeights=function(r,s,o,l){return new Lt(new Wt(r,s.slice(),C.homogenize1d(o,l)))},Lt.byPoints=function(r,s){return s==null&&(s=3),new Lt(gt.rationalInterpCurve(r,s))},Lt.__super__=te,Lt.prototype=M(te.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 Wt(this.degree(),this.knots(),C.homogenize1d(this.controlPoints(),this.weights()))},clone:function(){return new Lt(this._data)},domain:function(){return new Ce(Z.first(this._data.knots),Z.last(this._data.knots))},transform:function(r){return new Lt(yt.rationalCurveTransform(this._data,r))},transformAsync:function(r){return At.dispatchMethod(yt,"rationalCurveTransform",[this._data,r]).then(function(s){return new Lt(s)})},point:function(r){return C.rationalCurvePoint(this._data,r)},pointAsync:function(r){return At.dispatchMethod(C,"rationalCurvePoint",[this._data,r])},tangent:function(r){return C.rationalCurveTangent(this._data,r)},tangentAsync:function(r){return At.dispatchMethod(C,"rationalCurveTangent",[this._data,r])},derivatives:function(r,s){return s==null&&(s=1),C.rationalCurveDerivatives(this._data,r,s)},derivativesAsync:function(r,s){return s==null&&(s=1),At.dispatchMethod(C,"rationalCurveDerivatives",[this._data,r,s])},closestPoint:function(r){return bt.rationalCurveClosestPoint(this._data,r)},closestPointAsync:function(r){return At.dispatchMethod(bt,"rationalCurveClosestPoint",[this._data,r])},closestParam:function(r){return bt.rationalCurveClosestParam(this._data,r)},closestParamAsync:function(r){return At.dispatchMethod(bt,"rationalCurveClosestParam",[this._data,r])},length:function(){return bt.rationalCurveArcLength(this._data)},lengthAsync:function(){return At.dispatchMethod(bt,"rationalCurveArcLength",[this._data])},lengthAtParam:function(r){return bt.rationalCurveArcLength(this._data,r)},lengthAtParamAsync:function(){return At.dispatchMethod(bt,"rationalCurveArcLength",[this._data])},paramAtLength:function(r,s){return bt.rationalCurveParamAtArcLength(this._data,r,s)},paramAtLengthAsync:function(r,s){return At.dispatchMethod(bt,"rationalCurveParamAtArcLength",[this._data,r,s])},divideByEqualArcLength:function(r){return de.rationalCurveByEqualArcLength(this._data,r)},divideByEqualArcLengthAsync:function(r){return At.dispatchMethod(de,"rationalCurveByEqualArcLength",[this._data,r])},divideByArcLength:function(r){return de.rationalCurveByArcLength(this._data,r)},divideByArcLengthAsync:function(r){return At.dispatchMethod(de,"rationalCurveByArcLength",[this._data,r])},split:function(r){return de.curveSplit(this._data,r).map(function(s){return new Lt(s)})},splitAsync:function(r){return At.dispatchMethod(de,"curveSplit",[this._data,r]).then(function(s){return s.map(function(o){return new Lt(o)})})},reverse:function(){return new Lt(yt.curveReverse(this._data))},reverseAsync:function(){return At.dispatchMethod(yt,"curveReverse",[this._data]).then(function(r){return new Lt(r)})},tessellate:function(r){return zt.rationalCurveAdaptiveSample(this._data,r,!1)},tessellateAsync:function(r){return At.dispatchMethod(zt,"rationalCurveAdaptiveSample",[this._data,r,!1])},__class__:Lt});var qr=f.geom.Arc=function(r,s,o,l,u,d){Lt.call(this,gt.arc(r,s,o,l,u,d)),this._center=r,this._xaxis=s,this._yaxis=o,this._radius=l,this._minAngle=u,this._maxAngle=d};x["verb.geom.Arc"]=qr,qr.__name__=["verb","geom","Arc"],qr.__super__=Lt,qr.prototype=M(Lt.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__:qr});var cs=f.geom.BezierCurve=function(r,s){Lt.call(this,gt.rationalBezierCurve(r,s))};x["verb.geom.BezierCurve"]=cs,cs.__name__=["verb","geom","BezierCurve"],cs.__super__=Lt,cs.prototype=M(Lt.prototype,{__class__:cs});var us=f.geom.Circle=function(r,s,o,l){qr.call(this,r,s,o,l,0,Math.PI*2)};x["verb.geom.Circle"]=us,us.__name__=["verb","geom","Circle"],us.__super__=qr,us.prototype=M(qr.prototype,{__class__:us});var zn=function(){};x["verb.geom.ISurface"]=zn,zn.__name__=["verb","geom","ISurface"],zn.__interfaces__=[Nn],zn.prototype={__class__:zn};var Mt=f.geom.NurbsSurface=function(r){this._data=$e.isValidNurbsSurfaceData(r)};x["verb.geom.NurbsSurface"]=Mt,Mt.__name__=["verb","geom","NurbsSurface"],Mt.__interfaces__=[zn],Mt.byKnotsControlPointsWeights=function(r,s,o,l,u,d){return new Mt(new ne(r,s,o,l,C.homogenize2d(u,d)))},Mt.byCorners=function(r,s,o,l){return new Mt(gt.fourPointSurface(r,s,o,l))},Mt.byLoftingCurves=function(r,s){return new Mt(gt.loftedSurface(function(o){for(var l,u=[],d=0;d<r.length;){var g=r[d];++d,u.push(g.asNurbs())}return l=u,l}(),s))},Mt.__super__=te,Mt.prototype=M(te.prototype,{degreeU:function(){return this._data.degreeU},degreeV:function(){return this._data.degreeV},knotsU:function(){return this._data.knotsU.slice(0)},knotsV:function(){return this._data.knotsV.slice(0)},controlPoints:function(){return C.dehomogenize2d(this._data.controlPoints)},weights:function(){return C.weight2d(this._data.controlPoints)},asNurbs:function(){return new ne(this.degreeU(),this.degreeV(),this.knotsU(),this.knotsV(),C.homogenize2d(this.controlPoints(),this.weights()))},clone:function(){return new Mt(this.asNurbs())},domainU:function(){return new Ce(Z.first(this._data.knotsU),Z.last(this._data.knotsU))},domainV:function(){return new Ce(Z.first(this._data.knotsV),Z.last(this._data.knotsV))},point:function(r,s){return C.rationalSurfacePoint(this._data,r,s)},pointAsync:function(r,s){return At.dispatchMethod(C,"rationalSurfacePoint",[this._data,r,s])},normal:function(r,s){return C.rationalSurfaceNormal(this._data,r,s)},normalAsync:function(r,s){return At.dispatchMethod(C,"rationalSurfaceNormal",[this._data,r,s])},derivatives:function(r,s,o){return o==null&&(o=1),C.rationalSurfaceDerivatives(this._data,r,s,o)},derivativesAsync:function(r,s,o){return o==null&&(o=1),At.dispatchMethod(C,"rationalSurfaceDerivatives",[this._data,r,s,o])},closestParam:function(r){return bt.rationalSurfaceClosestParam(this._data,r)},closestParamAsync:function(r){return At.dispatchMethod(bt,"rationalSurfaceClosestParam",[this._data,r])},closestPoint:function(r){return bt.rationalSurfaceClosestPoint(this._data,r)},closestPointAsync:function(r){return At.dispatchMethod(bt,"rationalSurfaceClosestPoint",[this._data,r])},split:function(r,s){return s==null&&(s=!1),de.surfaceSplit(this._data,r,s).map(function(o){return new Mt(o)})},splitAsync:function(r,s){return s==null&&(s=!1),At.dispatchMethod(de,"surfaceSplit",[this._data,r,s]).then(function(o){return o.map(function(l){return new Mt(l)})})},reverse:function(r){return r==null&&(r=!1),new Mt(yt.surfaceReverse(this._data,r))},reverseAsync:function(r){return r==null&&(r=!1),At.dispatchMethod(yt,"surfaceReverse",[this._data,r]).then(function(s){return new Mt(s)})},isocurve:function(r,s){return s==null&&(s=!1),new Lt(gt.surfaceIsocurve(this._data,r,s))},isocurveAsync:function(r,s){return s==null&&(s=!1),At.dispatchMethod(gt,"surfaceIsocurve",[this._data,r,s]).then(function(o){return new Lt(o)})},boundaries:function(r){return gt.surfaceBoundaryCurves(this._data).map(function(s){return new Lt(s)})},boundariesAsync:function(r){return At.dispatchMethod(gt,"surfaceBoundaryCurves",[this._data]).then(function(s){return s.map(function(o){return new Lt(o)})})},tessellate:function(r){return zt.rationalSurfaceAdaptive(this._data,r)},tessellateAsync:function(r){return At.dispatchMethod(zt,"rationalSurfaceAdaptive",[this._data,r])},transform:function(r){return new Mt(yt.rationalSurfaceTransform(this._data,r))},transformAsync:function(r){return At.dispatchMethod(yt,"rationalSurfaceTransform",[this._data,r]).then(function(s){return new Mt(s)})},__class__:Mt});var ds=f.geom.ConicalSurface=function(r,s,o,l,u){Mt.call(this,gt.conicalSurface(r,s,o,l,u)),this._axis=r,this._xaxis=s,this._base=o,this._height=l,this._radius=u};x["verb.geom.ConicalSurface"]=ds,ds.__name__=["verb","geom","ConicalSurface"],ds.__super__=Mt,ds.prototype=M(Mt.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__:ds});var ps=f.geom.CylindricalSurface=function(r,s,o,l,u){Mt.call(this,gt.cylindricalSurface(r,s,o,l,u)),this._axis=r,this._xaxis=s,this._base=o,this._height=l,this._radius=u};x["verb.geom.CylindricalSurface"]=ps,ps.__name__=["verb","geom","CylindricalSurface"],ps.__super__=Mt,ps.prototype=M(Mt.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__:ps});var Yr=f.geom.EllipseArc=function(r,s,o,l,u){Lt.call(this,gt.ellipseArc(r,s,o,l,u)),this._center=r,this._xaxis=s,this._yaxis=o,this._minAngle=l,this._maxAngle=u};x["verb.geom.EllipseArc"]=Yr,Yr.__name__=["verb","geom","EllipseArc"],Yr.__super__=Lt,Yr.prototype=M(Lt.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__:Yr});var ms=f.geom.Ellipse=function(r,s,o){Yr.call(this,r,s,o,0,Math.PI*2)};x["verb.geom.Ellipse"]=ms,ms.__name__=["verb","geom","Ellipse"],ms.__super__=Yr,ms.prototype=M(Yr.prototype,{__class__:ms});var gs=f.geom.ExtrudedSurface=function(r,s){Mt.call(this,gt.extrudedSurface(p.normalized(s),p.norm(s),r.asNurbs())),this._profile=r,this._direction=s};x["verb.geom.ExtrudedSurface"]=gs,gs.__name__=["verb","geom","ExtrudedSurface"],gs.__super__=Mt,gs.prototype=M(Mt.prototype,{profile:function(){return this._profile},direction:function(){return this._direction},__class__:gs});var Xr=f.geom.Intersect=function(){};x["verb.geom.Intersect"]=Xr,Xr.__name__=["verb","geom","Intersect"],Xr.curves=function(r,s,o){return o==null&&(o=.001),ht.curves(r.asNurbs(),s.asNurbs(),o)},Xr.curvesAsync=function(r,s,o){return o==null&&(o=.001),At.dispatchMethod(ht,"curves",[r.asNurbs(),s.asNurbs(),o])},Xr.curveAndSurface=function(r,s,o){return o==null&&(o=.001),ht.curveAndSurface(r.asNurbs(),s.asNurbs(),o)},Xr.curveAndSurfaceAsync=function(r,s,o){return o==null&&(o=.001),At.dispatchMethod(ht,"curveAndSurface",[r.asNurbs(),s.asNurbs(),o])},Xr.surfaces=function(r,s,o){return o==null&&(o=.001),ht.surfaces(r.asNurbs(),s.asNurbs(),o).map(function(l){return new Lt(l)})},Xr.surfacesAsync=function(r,s,o){return o==null&&(o=.001),At.dispatchMethod(ht,"surfaces",[r.asNurbs(),s.asNurbs(),o]).then(function(l){return l.map(function(u){return new Lt(u)})})};var fs=f.geom.Line=function(r,s){Lt.call(this,gt.polyline([r,s])),this._start=r,this._end=s};x["verb.geom.Line"]=fs,fs.__name__=["verb","geom","Line"],fs.__super__=Lt,fs.prototype=M(Lt.prototype,{start:function(){return this._start},end:function(){return this._end},__class__:fs});var _s=f.geom.RevolvedSurface=function(r,s,o,l){Mt.call(this,gt.revolvedSurface(r.asNurbs(),s,o,l)),this._profile=r,this._center=s,this._axis=o,this._angle=l};x["verb.geom.RevolvedSurface"]=_s,_s.__name__=["verb","geom","RevolvedSurface"],_s.__super__=Mt,_s.prototype=M(Mt.prototype,{profile:function(){return this._profile},center:function(){return this._center},axis:function(){return this._center},angle:function(){return this._angle},__class__:_s});var ys=f.geom.SphericalSurface=function(r,s){Mt.call(this,gt.sphericalSurface(r,[0,0,1],[1,0,0],s)),this._center=r,this._radius=s};x["verb.geom.SphericalSurface"]=ys,ys.__name__=["verb","geom","SphericalSurface"],ys.__super__=Mt,ys.prototype=M(Mt.prototype,{center:function(){return this._center},radius:function(){return this._radius},__class__:ys});var vs=f.geom.SweptSurface=function(r,s){Mt.call(this,gt.rationalTranslationalSurface(r.asNurbs(),s.asNurbs())),this._profile=r,this._rail=s};x["verb.geom.SweptSurface"]=vs,vs.__name__=["verb","geom","SweptSurface"],vs.__super__=Mt,vs.prototype=M(Mt.prototype,{profile:function(){return this._profile},rail:function(){return this._rail},__class__:vs});function tr(r){return r instanceof Array?function(){return N.iter(r)}:typeof r.iterator=="function"?De(r,r.iterator):r.iterator}var ra,cu=0;function De(r,s){if(s==null)return null;s.__id__==null&&(s.__id__=cu++);var o;return r.hx__closures__==null?r.hx__closures__={}:o=r.hx__closures__[s.__id__],o==null&&(o=function(){return o.method.apply(o.scope,arguments)},o.scope=r,o.method=s,r.hx__closures__[s.__id__]=o),o}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 uu=x.Int={__name__:["Int"]},du=x.Dynamic={__name__:["Dynamic"]},Ho=x.Float=Number;Ho.__name__=["Float"];var qo=x.Bool=Boolean;qo.__ename__=["Bool"];var Yo=x.Class={__name__:["Class"]},Xo={};Array.prototype.map==null&&(Array.prototype.map=function(r){for(var s=[],o=0,l=this.length;o<l;){var u=o++;s[u]=r(this[u])}return s}),Array.prototype.filter==null&&(Array.prototype.filter=function(r){for(var s=[],o=0,l=this.length;o<l;){var u=o++,d=this[u];r(d)&&s.push(d)}return s});var na={},ri=w.ArrayBuffer||ue;ri.prototype.slice==null&&(ri.prototype.slice=ue.sliceImpl),w.DataView;var sa=w.Uint8Array||hr._new;(function(r,s){if(r.setImmediate)return;var o=1,l={},u=!1,d=r.document,g;function _(z){return l[o]=y.apply(s,z),o++}function y(z){var V=[].slice.call(arguments,1);return function(){typeof z=="function"?z.apply(s,V):new Function(""+z)()}}function A(z){if(u)setTimeout(y(A,z),0);else{var V=l[z];if(V){u=!0;try{V()}finally{I(z),u=!1}}}}function I(z){delete l[z]}function P(){g=function(){var z=_(arguments);return process.nextTick(y(A,z)),z}}function E(){if(r.postMessage&&!r.importScripts){var z=!0,V=r.onmessage;return r.onmessage=function(){z=!1},r.postMessage("","*"),r.onmessage=V,z}}function k(){var z="setImmediate$"+Math.random()+"$",V=function(U){U.source===r&&typeof U.data=="string"&&U.data.indexOf(z)===0&&A(+U.data.slice(z.length))};r.addEventListener?r.addEventListener("message",V,!1):r.attachEvent("onmessage",V),g=function(){var U=_(arguments);return r.postMessage(z+U,"*"),U}}function T(){var z=new MessageChannel;z.port1.onmessage=function(V){var U=V.data;A(U)},g=function(){var V=_(arguments);return z.port2.postMessage(V),V}}function B(){var z=d.documentElement;g=function(){var V=_(arguments),U=d.createElement("script");return U.onreadystatechange=function(){A(V),U.onreadystatechange=null,z.removeChild(U),U=null},z.appendChild(U),V}}function L(){g=function(){var z=_(arguments);return setTimeout(y(A,z),0),z}}var R=Object.getPrototypeOf&&Object.getPrototypeOf(r);R=R&&R.setTimeout?R:r,{}.toString.call(r.process)==="[object process]"?P():E()?k():r.MessageChannel?T():d&&"onreadystatechange"in d.createElement("script")?B():L(),R.setImmediate=g,R.clearImmediate=I})(new Function("return this")()),Kt.USE_CACHE=!1,Kt.USE_ENUM_INDEX=!1,Kt.BASE64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:",qt.DEFAULT_RESOLVER=ut,qt.BASE64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:",Bt.count=0,ce.i64tmp=function(r){var s,o=new Gt(0,0);return s=o,s}(),Nt.__toStr={}.toString,hr.BYTES_PER_ELEMENT=1,St.queue=new F,Ft.memo=new wt,rt.TOLERANCE=1e-6,rt.EPSILON=1e-10,rt.VERSION="2.0.0",bt.Tvalues=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],bt.Cvalues=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],At.THREADS=1,At._init=!1,Hr.basePath="",rn.uuid=0,ti.main()}(typeof console<"u"?console:{log:function(){}},e,typeof c<"u"?c:typeof n<"u"?n:typeof self<"u"?self:this),e})})(_h);var Yu=_h.exports;const Vn=qu(Yu);class ma{constructor(){this.c0=0,this.c1=0,this.c2=0,this.c3=0}init(t,e,n,a){this.c0=t,this.c1=n,this.c2=-3*t+3*e-2*n-a,this.c3=2*t-2*e+n+a}initCatmullRom(t,e,n,a,h){this.init(e,n,h*(n-t),h*(a-e))}initNonuniformCatmullRom(t,e,n,a,h,c,m){let b=(e-t)/h-(n-t)/(h+c)+(n-e)/c,f=(n-e)/c-(a-e)/(c+m)+(a-n)/m;b*=c,f*=c,this.init(e,n,b,f)}calc(t){const e=t*t,n=e*t;return this.c0+this.c1*t+this.c2*e+this.c3*n}}let yh=class extends Qs{constructor(t=[],e=!1,n="centripetal",a=.5){super(),this.isCatmullRomCurve3d=!0,this.type="CatmullRomCurve3d",this._tmp=new X,this._px=new ma,this._py=new ma,this._pz=new ma,this._points=t.map(h=>new G(h)),this._closed=e,this._curveType=n,this._tension=a}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 G}get endPoint(){return this._points.length>0?this._points[this._points.length-1]:new G}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 G){const n=e,a=this._points,h=a.length;if(h===0)return n.set(0,0,0);if(h===1)return n.copy(a[0]);const c=(h-(this._closed?0:1))*t;let m=Math.floor(c),b=c-m;this._closed?m+=m>0?0:(Math.floor(Math.abs(m)/h)+1)*h:b===0&&m===h-1&&(m=h-2,b=1);let f,w;this._closed||m>0?f=a[(m-1)%h]:(this._tmp.subVectors(a[0],a[1]).add(a[0]),f=new G(this._tmp.x,this._tmp.y,this._tmp.z));const x=a[m%h],S=a[(m+1)%h];if(this._closed||m+2<h?w=a[(m+2)%h]:(this._tmp.subVectors(a[h-1],a[h-2]).add(a[h-1]),w=new G(this._tmp.x,this._tmp.y,this._tmp.z)),this._curveType==="centripetal"||this._curveType==="chordal"){const M=this._curveType==="chordal"?.5:.25;let N=Math.pow(f.distanceToSquared(x),M),O=Math.pow(x.distanceToSquared(S),M),F=Math.pow(S.distanceToSquared(w),M);O<1e-4&&(O=1),N<1e-4&&(N=O),F<1e-4&&(F=O),this._px.initNonuniformCatmullRom(f.x,x.x,S.x,w.x,N,O,F),this._py.initNonuniformCatmullRom(f.y,x.y,S.y,w.y,N,O,F),this._pz.initNonuniformCatmullRom(f.z,x.z,S.z,w.z,N,O,F)}else this._curveType==="catmullrom"&&(this._px.initCatmullRom(f.x,x.x,S.x,w.x,this._tension),this._py.initCatmullRom(f.y,x.y,S.y,w.y,this._tension),this._pz.initCatmullRom(f.z,x.z,S.z,w.z,this._tension));return n.set(this._px.calc(b),this._py.calc(b),this._pz.calc(b)),n}getPoints(t){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}setPoints(t){this._points=t.map(e=>new G(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 n=new G;return n.copy(e),n.applyMatrix4(t),n}),this._boundingBoxNeedsUpdate=!0,this}calculateBoundingBox(){if(this._points.length===0)return new Ct;const t=new Ct;return this._points.forEach(e=>{t.expandByPoint(e)}),t}};class bn{constructor(t,e,n,a){this._degree=t,this._knots=[...e],this._controlPoints=n.map(h=>({x:h.x,y:h.y,z:h.z})),this._weights=a?[...a]:new Array(n.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(n=>[n.x,n.y,n.z]);return Vs(t,this._degree,this._knots,e,this._weights)}length(){const t=this._controlPoints.map(e=>[e.x,e.y,e.z]);return ch(this._degree,this._knots,t,this._weights)}static byKnotsControlPointsWeights(t,e,n,a){return new bn(t,e,n,a)}static byPoints(t,e,n="Uniform"){let a;switch(n){case"Chord":a=lh(e,t);break;case"SqrtChord":a=hh(e,t);break;case"Uniform":default:a=oh(e,t.length);break}const h=t.map(m=>({x:m[0],y:m[1],z:m[2]})),c=new Array(h.length).fill(1);return new bn(e,a,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:n,end:a}=this.getParameterRange();for(let h=0;h<=t;h++){const c=n+(a-n)*(h/t);e.push(this.point(c))}return e}isClosed(t=1e-6){const{start:e,end:n}=this.getParameterRange(),a=this.point(e),h=this.point(n),c=a[0]-h[0],m=a[1]-h[1],b=a[2]-h[2];return Math.sqrt(c*c+m*m+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 yh(t,!0,"centripetal"),n=Math.max(50,t.length*2);return e.getPoints(n)}static createClosedCurve(t,e,n="Chord"){const a=this.createFitPointsForClosedCurve(t).map(h=>[h.x,h.y,h.z]);return bn.byPoints(a,e,n)}}class Jr extends Qs{constructor(t,e,n,a,h){super();const c=arguments.length;if(c<2||c>5)throw Xe.ILLEGAL_PARAMETERS;if(this._degree=3,this._closed=!1,Array.isArray(e)){this._controlPoints=t;let m,b=3,f=!1;if(c>=3&&(Array.isArray(n)?(m=n,c>=4&&(b=a||3),c>=5&&(f=h)):n!==void 0&&(b=n||3,c>=4&&(f=a))),n===void 0&&c>=4&&(b=a||3,c>=5&&(f=h)),this._degree=b,this._closed=f,this._controlPoints.length<this._degree+1)throw Xe.ILLEGAL_PARAMETERS;const w=this.toVerbPoints(this._controlPoints);this._nurbsCurve=Vn.geom.NurbsCurve.byKnotsControlPointsWeights(this._degree,e,w,m)}else{if(this._fitPoints=t,this._knotParameterization=e,c>=3&&(this._degree=n||3),c>=4&&(this._closed=a),this._fitPoints.length<this._degree+1)throw Xe.ILLEGAL_PARAMETERS;const m=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=Vn.geom.NurbsCurve.byPoints(m,this._degree),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}}buildCurve(){if(this._fitPoints&&this._knotParameterization){if(this._closed){const t=bn.createFitPointsForClosedCurve(this._fitPoints),e=this.toNurbsPoints(t);this._nurbsCurve=Vn.geom.NurbsCurve.byPoints(e,this._degree)}else{const t=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=Vn.geom.NurbsCurve.byPoints(t,this._degree)}this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}else if(this._controlPoints)if(this._closed){const t=bn.createFitPointsForClosedCurve(this._controlPoints),e=this.toNurbsPoints(t);this._nurbsCurve=Vn.geom.NurbsCurve.byPoints(e,this._degree),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}else{const t=this._nurbsCurve.knots(),e=this._nurbsCurve.weights(),n=this.toVerbPoints(this._controlPoints);this._nurbsCurve=Vn.geom.NurbsCurve.byKnotsControlPointsWeights(this._degree,t,n,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(),n=t[e],a=this._nurbsCurve.point(n);return new G(a[0],a[1],a[2])}get endPoint(){const t=this._nurbsCurve.knots(),e=this._nurbsCurve.degree(),n=t[t.length-e-1],a=this._nurbsCurve.point(n);return new G(a[0],a[1],a[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,n=t<0||t>=e?e-1:t,a=this._fitPoints[n];return{x:a.x,y:a.y,z:a.z||0}}getControlPointAt(t){const e=this._controlPoints.length,n=t<0||t>=e?e-1:t;return this._controlPoints[n]}getPoints(t=100){const e=this._nurbsCurve,n=[],a=e.knots(),h=this._nurbsCurve.degree(),c=a[h],m=a[a.length-h-1],b=(m-c)/(t-1);for(let f=0;f<t;f++){const w=f===t-1?m:c+f*b,x=e.point(w);n.push(new G(x[0],x[1],x[2]))}return n}getCurvePoints(t,e){const n=[],a=t.knots(),h=a[3],c=(a[a.length-4]-h)/(e-1);for(let m=0;m<e;m++){const b=h+m*c;n.push(t.point(b))}return n}calculateBoundingBox(){const t=this.getPoints(100);return new Ct().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((n,a)=>{e[a]=[n.x,n.y,n.z||0]}),e}toVerbPoints(t){const e=new Array(t.length);return t.forEach((n,a)=>{e[a]=[n.x,n.y,n.z||0]}),e}toGePoints(t){const e=new Array(t.length);return t.forEach((n,a)=>{e[a]={x:n[0],y:n[1],z:n[2]}}),e}static createClosedSpline(t,e="Uniform",n=3){if(t.length<n+1)throw new Error(`At least ${n+1} points are required for a degree ${n} closed spline`);return new Jr(t,e,n,!0)}}var $a=(i=>(i.ClosedFilled="",i.Dot="_DOT",i.DotSmall="_DOTSMALL",i.DotBlank="_DOTBLANK",i.Origin="_ORIGIN",i.Origin2="_ORIGIN2",i.Open="_OPEN",i.Open90="_OPEN90",i.Open30="_OPEN30",i.Closed="_CLOSED",i.Small="_SMALL",i.None="_NONE",i.Oblique="_OBLIQUE",i.BoxFilled="_BOXFILLED",i.Box="_BOXBLANK",i.ClosedBlank="_CLOSEDBLANK",i.DatumBlank="_DATUMBLANK",i.DatumFilled="_DATUMFILLED",i.Integral="_INTEGRAL",i.ArchTick="_ARCHTICK",i))($a||{}),Zi=(i=>(i[i.ByBlock=-2]="ByBlock",i[i.ByDIPs=-4]="ByDIPs",i[i.ByLayer=-1]="ByLayer",i[i.ByLineWeightDefault=-3]="ByLineWeightDefault",i[i.LineWeight000=0]="LineWeight000",i[i.LineWeight005=5]="LineWeight005",i[i.LineWeight009=9]="LineWeight009",i[i.LineWeight013=13]="LineWeight013",i[i.LineWeight015=15]="LineWeight015",i[i.LineWeight018=18]="LineWeight018",i[i.LineWeight020=20]="LineWeight020",i[i.LineWeight025=25]="LineWeight025",i[i.LineWeight030=30]="LineWeight030",i[i.LineWeight035=35]="LineWeight035",i[i.LineWeight040=40]="LineWeight040",i[i.LineWeight050=50]="LineWeight050",i[i.LineWeight053=53]="LineWeight053",i[i.LineWeight060=60]="LineWeight060",i[i.LineWeight070=70]="LineWeight070",i[i.LineWeight080=80]="LineWeight080",i[i.LineWeight090=90]="LineWeight090",i[i.LineWeight100=100]="LineWeight100",i[i.LineWeight106=106]="LineWeight106",i[i.LineWeight120=120]="LineWeight120",i[i.LineWeight140=140]="LineWeight140",i[i.LineWeight158=158]="LineWeight158",i[i.LineWeight200=200]="LineWeight200",i[i.LineWeight211=211]="LineWeight211",i))(Zi||{}),Rr=(i=>(i[i.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",i[i.RIGHT_TO_LEFT=2]="RIGHT_TO_LEFT",i[i.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",i[i.BOTTOM_TO_TOP=4]="BOTTOM_TO_TOP",i[i.BY_STYLE=5]="BY_STYLE",i))(Rr||{}),xe=(i=>(i[i.TopLeft=1]="TopLeft",i[i.TopCenter=2]="TopCenter",i[i.TopRight=3]="TopRight",i[i.MiddleLeft=4]="MiddleLeft",i[i.MiddleCenter=5]="MiddleCenter",i[i.MiddleRight=6]="MiddleRight",i[i.BottomLeft=7]="BottomLeft",i[i.BottomCenter=8]="BottomCenter",i[i.BottomRight=9]="BottomRight",i))(xe||{}),Za=(i=>(i[i.OPTIMIZED_2D=0]="OPTIMIZED_2D",i[i.WIREFRAME=1]="WIREFRAME",i[i.HIDDEN_LINE=2]="HIDDEN_LINE",i[i.FLAT_SHADED=3]="FLAT_SHADED",i[i.GOURAUD_SHADED=4]="GOURAUD_SHADED",i[i.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",i[i.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME",i))(Za||{}),Qa=(i=>(i[i.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",i[i.TOP=1]="TOP",i[i.BOTTOM=2]="BOTTOM",i[i.FRONT=3]="FRONT",i[i.BACK=4]="BACK",i[i.LEFT=5]="LEFT",i[i.RIGHT=6]="RIGHT",i))(Qa||{}),Ja=(i=>(i[i.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",i[i.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS",i))(Ja||{});let vh=class bh{constructor(){this._number=-1,this._id="",this._groupId="",this._centerPoint=new G,this._height=0,this._width=0,this._viewCenter=new G,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 we;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 we;return t.setFromCenterAndSize(this.viewCenter,{x:this.viewWidth,y:this.viewHeight}),t}clone(){const t=new bh;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}};var vn=256,xh=[],fl=256,ii;for(;vn--;)xh[vn]=(vn+256).toString(16).substring(1);function Xu(i){var t=0,e=11;if(!ii||vn+e>fl*2)for(ii="",vn=0;t<fl;t++)ii+=xh[Math.random()*256|0];return ii.substring(vn,vn+++e)}class tn{constructor(t,e){t=t||{},Kn(t,{objectId:Xu()}),this._attrs=new Tl(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:lo().workingDatabase}set database(t){this._database=t}close(){}}const ho=class ho extends tn{constructor(){super(...arguments),this._layer="0",this._color=new Fr,this._lineType=hi,this._lineWeight=Zi.ByLayer,this._linetypeScale=-1,this._visibility=!0,this._transparency=new qi}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 n=this.getLayerColor();n&&n.RGB!=null&&(t=n)}else this.color.isByBlock||this.color.RGB!=null&&(t=this.color);const e=t.RGB;return e??16777215}get lineType(){return this._lineType}set lineType(t){this._lineType=t||hi}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.clone()}get properties(){return{type:this.type,groups:[this.getGeneralProperties()]}}subGetGripPoints(){return new Array}subGetOsnapPoints(t,e,n,a,h){}transformBy(t){return this}erase(){return this.database.tables.blockTable.removeEntity(this.objectId)}worldDraw(t,e){const n=t.subEntityTraits;n.color=this.color,n.rgbColor=this.rgbColor,n.lineType=this.lineStyle,n.lineTypeScale=this.linetypeScale,n.lineWeight=this.lineWeight,n.transparency=this.transparency,n.layer=this.layer,"thickness"in this&&(n.thickness=this.thickness);const a=this.subWorldDraw(t,e);return this.attachEntityInfo(a),a}triggerModifiedEvent(){this.database.events.entityModified.dispatch({database:this.database,entity:this})}getGeneralProperties(){return{groupName:"general",properties:[{name:"handle",type:"int",editable:!1,accessor:{get:()=>this.objectId}},{name:"color",type:"color",editable:!0,accessor:{get:()=>this.color,set:t=>{this.color.copy(t)}}},{name:"layer",type:"string",editable:!0,accessor:{get:()=>this.layer,set:t=>{this.layer=t}}},{name:"linetype",type:"linetype",editable:!0,accessor:{get:()=>this.lineType,set:t=>{this.lineType=t}}},{name:"linetypeScale",type:"float",editable:!0,accessor:{get:()=>this.linetypeScale,set:t=>{this.linetypeScale=t}}},{name:"lineWeight",type:"lineweight",editable:!0,accessor:{get:()=>this.lineWeight,set:t=>{this.lineWeight=t}}},{name:"transparency",type:"transparency",editable:!0,accessor:{get:()=>this.transparency,set:t=>{this.transparency=t}}}]}}get lineStyle(){var a;const{type:t,name:e}=this.getLineType(),n=(a=this.database)==null?void 0:a.tables.linetypeTable.getAt(e);return n?{type:t,...n.linetype}:{type:t,name:e,standardFlag:0,description:"",totalPatternLength:0}}getLineType(){if(this.lineType==hi){const t=this.database.tables.layerTable.getAt(this.layer);if(t&&t.linetype)return{type:"ByLayer",name:t.linetype}}else return this.lineType==Rl?{type:"ByBlock",name:fi}:{type:"UserSpecified",name:this.lineType};return{type:"UserSpecified",name:fi}}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}attachEntityInfo(t){t&&(t.objectId=this.objectId,this.attrs.has("ownerId")&&(t.ownerId=this.ownerId),t.layerName=this.layer,t.visible=this.visibility)}};ho.typeName="Entity";let ke=ho;const co=class co extends ke{};co.typeName="Curve";let Te=co;var jn=(i=>(i[i.SimplePoly=0]="SimplePoly",i[i.FitCurvePoly=1]="FitCurvePoly",i[i.QuadSplinePoly=2]="QuadSplinePoly",i[i.CubicSplinePoly=3]="CubicSplinePoly",i))(jn||{});const uo=class uo extends Te{constructor(t,e,n=0,a=!1,h=0,c=0,m=null){super(),this._polyType=t,this._elevation=n;const b=m&&(m==null?void 0:m.length)===e.length,f=e.map((w,x)=>({x:w.x,y:w.y,bulge:b?m[x]:void 0}));this._geo=new An(f,a)}get polyType(){return this._polyType}set polyType(t){this._polyType=t}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}get geometricExtents(){const t=this._geo.box;return new Ct({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._geo.numberOfVertices;++e){const n=this._geo.getPointAt(e);t.push(new G(n.x,n.y,0))}return t}subGetOsnapPoints(t,e,n,a){switch(t){case Dt.EndPoint:for(let h=0;h<this._geo.numberOfVertices;++h){const c=this._geo.getPointAt(h);a.push(new G(c.x,c.y,0))}break}}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!0},{name:"y",type:"float",editable:!0}]},accessor:{get:()=>this._geo.vertices}},{name:"elevation",type:"float",editable:!0,accessor:{get:()=>this.elevation,set:t=>{this.elevation=t}}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}}]},{groupName:"others",properties:[{name:"closed",type:"float",editable:!0,accessor:{get:()=>this.closed,set:t=>{this.closed=t}}}]}]}}subWorldDraw(t){const e=[];return this._geo.getPoints(100).forEach(a=>e.push(new G().set(a.x,a.y,this.elevation))),t.lines(e)}};uo.typeName="2dPolyline";let yi=uo;var wh=(i=>(i[i.Vertex=0]="Vertex",i[i.CurveFitVertex=1]="CurveFitVertex",i[i.SplineFitVertex=8]="SplineFitVertex",i[i.SplineCtlVertex=9]="SplineCtlVertex",i))(wh||{});const po=class po extends ke{constructor(){super(),this._position=new G,this._bulge=0,this._startWidth=0,this._endWidth=0,this._vertexType=0}get position(){return this._position}set position(t){this._position.copy(t)}get bulge(){return this._bulge}set bulge(t){this._bulge=t}get startWidth(){return this._startWidth}set startWidth(t){this._startWidth=t}get endWidth(){return this._endWidth}set endWidth(t){this._endWidth=t}get vertexType(){return this._vertexType}set vertexType(t){this._vertexType=t}get geometricExtents(){return new Ct().expandByPoint(this._position)}subGetGripPoints(){const t=new Array;return t.push(this._position),t}subGetOsnapPoints(t,e,n,a){a.push(this._position)}transformBy(t){return this._position.applyMatrix4(t),this}subWorldDraw(t){}};po.typeName="2dVertex";let ka=po;var js=(i=>(i[i.SimplePoly=0]="SimplePoly",i[i.QuadSplinePoly=1]="QuadSplinePoly",i[i.CubicSplinePoly=2]="CubicSplinePoly",i))(js||{});const mo=class mo extends Te{constructor(t,e,n=!1){super(),this._polyType=t,this._geo=new An(e,n)}get polyType(){return this._polyType}set polyType(t){this._polyType=t}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}get geometricExtents(){const t=this._geo.box;return new Ct({x:t.min.x,y:t.min.y,z:0},{x:t.max.x,y:t.max.y,z:0})}subGetGripPoints(){const t=new Array;for(let e=0;e<this._geo.numberOfVertices;++e){const n=this._geo.getPointAt(e);t.push(new G(n.x,n.y,0))}return t}subGetOsnapPoints(t,e,n,a){switch(t){case Dt.EndPoint:for(let h=0;h<this._geo.numberOfVertices;++h){const c=this._geo.getPointAt(h);a.push(new G(c.x,c.y,0))}break}}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!0},{name:"y",type:"float",editable:!0},{name:"z",type:"float",editable:!0}]},accessor:{get:()=>this._geo.vertices}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}}]},{groupName:"others",properties:[{name:"closed",type:"float",editable:!0,accessor:{get:()=>this.closed,set:t=>{this.closed=t}}}]}]}}subWorldDraw(t){const e=[];return this._geo.getPoints(100).forEach(a=>e.push(new G().set(a.x,a.y,0))),t.lines(e)}};mo.typeName="3dPolyline";let vi=mo;var Ah=(i=>(i[i.SimpleVertex=0]="SimpleVertex",i[i.ControlVertex=1]="ControlVertex",i[i.FitVertex=2]="FitVertex",i))(Ah||{});const go=class go extends ke{constructor(){super(),this._position=new G,this._vertexType=0}get position(){return this._position}set position(t){this._position.copy(t)}get vertexType(){return this._vertexType}set vertexType(t){this._vertexType=t}get geometricExtents(){return new Ct().expandByPoint(this._position)}subGetGripPoints(){const t=new Array;return t.push(this._position),t}subGetOsnapPoints(t,e,n,a){a.push(this._position)}transformBy(t){return this._position.applyMatrix4(t),this}subWorldDraw(t){}};go.typeName="3dVertex";let Ta=go;const fo=class fo extends Te{constructor(t,e,n,a,h=X.Z_AXIS){super(),this._geo=new Xa(t,e,n,a,h,X.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 normal(){return this._geo.normal}set normal(t){this._geo.normal=t}get startPoint(){return this._geo.startPoint}get endPoint(){return this._geo.endPoint}get midPoint(){return this._geo.midPoint}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"centerX",type:"float",editable:!0,accessor:{get:()=>this.center.x,set:t=>{this.center.x=t}}},{name:"centerY",type:"float",editable:!0,accessor:{get:()=>this.center.y,set:t=>{this.center.y=t}}},{name:"centerZ",type:"float",editable:!0,accessor:{get:()=>this.center.z,set:t=>{this.center.z=t}}},{name:"radius",type:"float",editable:!0,accessor:{get:()=>this.radius,set:t=>{this.radius=t}}},{name:"startAngle",type:"float",editable:!0,accessor:{get:()=>this.startAngle,set:t=>{this.startAngle=t}}},{name:"endAngle",type:"float",editable:!0,accessor:{get:()=>this.endAngle,set:t=>{this.endAngle=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}},{name:"arcLength",type:"float",editable:!1,accessor:{get:()=>this._geo.length}},{name:"totalAngle",type:"float",editable:!1,accessor:{get:()=>Pt.radToDeg(Math.abs(this._geo.deltaAngle))}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this._geo.area}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.center),t.push(this.startPoint),t.push(this.endPoint),t}subGetOsnapPoints(t,e,n,a){const h=this.startPoint,c=this.endPoint;switch(t){case Dt.EndPoint:a.push(h),a.push(c);break;case Dt.MidPoint:a.push(this.midPoint);break;case Dt.Nearest:{const m=this._geo.nearestPoint(e);a.push(m)}break;case Dt.Perpendicular:break;case Dt.Tangent:{const m=this._geo.tangentPoints(e);a.push(...m);break}}}transformBy(t){return this._geo.transform(t),this}subWorldDraw(t){return t.circularArc(this._geo)}};fo.typeName="Arc";let bi=fo;var Ph=(i=>(i[i.LEFT=0]="LEFT",i[i.CENTER=1]="CENTER",i[i.RIGHT=2]="RIGHT",i[i.ALIGNED=3]="ALIGNED",i[i.MIDDLE=4]="MIDDLE",i[i.FIT=5]="FIT",i))(Ph||{}),Ih=(i=>(i[i.BASELINE=0]="BASELINE",i[i.BOTTOM=1]="BOTTOM",i[i.MIDDLE=2]="MIDDLE",i[i.TOP=3]="TOP",i))(Ih||{});const _o=class _o extends ke{constructor(){super(),this._textString="",this._height=0,this._thickness=1,this._position=new G,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 Ct}subGetOsnapPoints(t,e,n,a){Dt.Insertion===t&&a.push(this._position)}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"text",properties:[{name:"contents",type:"string",editable:!0,accessor:{get:()=>this.textString,set:t=>{this.textString=t}}},{name:"styleName",type:"string",editable:!0,accessor:{get:()=>this.styleName,set:t=>{this.styleName=t}}},{name:"textHeight",type:"float",editable:!0,accessor:{get:()=>this.height,set:t=>{this.height=t}}},{name:"rotation",type:"float",editable:!0,accessor:{get:()=>this.rotation,set:t=>{this.rotation=t}}},{name:"widthFactor",type:"float",editable:!0,accessor:{get:()=>this.widthFactor,set:t=>{this.widthFactor=t}}},{name:"oblique",type:"float",editable:!0,accessor:{get:()=>this.oblique,set:t=>{this.oblique=t}}}]},{groupName:"geometry",properties:[{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:t=>{this.position.x=t}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:t=>{this.position.y=t}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:t=>{this.position.z=t}}}]}]}}getTextStyle(){const t=this.database.tables.textStyleTable;let e=t.getAt(this.styleName);return e||(e=t.getAt("STANDARD")||t.getAt("Standard")),e.textStyle}subWorldDraw(t,e){const n={text:this.textString,height:this.height,width:1/0,widthFactor:this.widthFactor,position:this.position,rotation:this.rotation,drawingDirection:Rr.BOTTOM_TO_TOP,attachmentPoint:xe.BottomLeft};return t.mtext(n,this.getTextStyle(),e)}};_o.typeName="Text";let qn=_o;var le=(i=>(i[i.Invisible=1]="Invisible",i[i.Const=2]="Const",i[i.Verifiable=4]="Verifiable",i[i.Preset=8]="Preset",i))(le||{}),fr=(i=>(i[i.MultiLine=2]="MultiLine",i[i.ConstMultiLine=4]="ConstMultiLine",i))(fr||{});const yo=class yo extends qn{constructor(){super(),this._flags=0,this._prompt="",this._mtextFlag=0,this._tag="",this._fieldLength=0,this._lockPositionInBlock=!1,this._isReallyLocked=!1}get isInvisible(){return(this._flags&1)!==0}set isInvisible(t){t?this._flags|=1:this._flags&=-2}get prompt(){return this._prompt}set prompt(t){this._prompt=t}get isConst(){return(this._flags&2)!==0}set isConst(t){t?this._flags|=2:this._flags&=-3}get isVerifiable(){return(this._flags&4)!==0}set isVerifiable(t){t?this._flags|=4:this._flags&=-5}get isPreset(){return(this._flags&8)!==0}set isPreset(t){t?this._flags|=8:this._flags&=-9}get isMTextAttribute(){return(this._mtextFlag&2)!==0}set isMTextAttribute(t){t?this._mtextFlag|=2:this._mtextFlag&=-3}get isConstMTextAttribute(){return(this._mtextFlag&4)!==0}set isConstMTextAttribute(t){t?this._mtextFlag|=4:this._mtextFlag&=-5}get tag(){return this._tag}set tag(t){this._tag=t}get fieldLength(){return this._fieldLength}set fieldLength(t){this._fieldLength=t}get lockPositionInBlock(){return this._lockPositionInBlock}set lockPositionInBlock(t){this._lockPositionInBlock=t}get isReallyLocked(){return this._isReallyLocked}set isReallyLocked(t){this._isReallyLocked=t}get mtext(){return this._mtext}set mtext(t){this._mtext=t,this.isMTextAttribute=t!=null}subWorldDraw(t){}};yo.typeName="AttDef";let xi=yo;const vo=class vo extends qn{constructor(){super(),this._flags=0,this._mtextFlag=0,this._tag="",this._fieldLength=0,this._lockPositionInBlock=!1,this._isReallyLocked=!1}get isInvisible(){return(this._flags&le.Invisible)!==0}set isInvisible(t){t?this._flags|=le.Invisible:this._flags&=~le.Invisible}get isConst(){return(this._flags&le.Const)!==0}set isConst(t){t?this._flags|=le.Const:this._flags&=~le.Const}get isVerifiable(){return(this._flags&le.Verifiable)!==0}set isVerifiable(t){t?this._flags|=le.Verifiable:this._flags&=~le.Verifiable}get isPreset(){return(this._flags&le.Preset)!==0}set isPreset(t){t?this._flags|=le.Preset:this._flags&=~le.Preset}get isMTextAttribute(){return(this._mtextFlag&fr.MultiLine)!==0}set isMTextAttribute(t){t?this._mtextFlag|=fr.MultiLine:this._mtextFlag&=~fr.MultiLine}get isConstMTextAttribute(){return(this._mtextFlag&fr.ConstMultiLine)!==0}set isConstMTextAttribute(t){t?this._mtextFlag|=fr.ConstMultiLine:this._mtextFlag&=~fr.ConstMultiLine}get tag(){return this._tag}set tag(t){this._tag=t}get fieldLength(){return this._fieldLength}set fieldLength(t){this._fieldLength=t}get lockPositionInBlock(){return this._lockPositionInBlock}set lockPositionInBlock(t){this._lockPositionInBlock=t}get isReallyLocked(){return this._isReallyLocked}set isReallyLocked(t){this._isReallyLocked=t}get mtext(){return this._mtext}set mtext(t){this._mtext=t,this.isMTextAttribute=t!=null}};vo.typeName="Attrib";let wi=vo;const bo=class bo extends ke{constructor(t){super(),this._blockName=t,this._position=new G,this._rotation=0,this._normal=new X(0,0,1),this._scaleFactors=new G(1,1,1),this._attribs=new Map}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)}appendAttributes(t){this._attribs.set(t.objectId,t),t.ownerId=this.objectId}attributeIterator(){return new Js(this._attribs)}get blockTransform(){const t=this.blockTableRecord,e=(t==null?void 0:t.origin)??G.ORIGIN,n=new Ye().makeTranslation(-e.x,-e.y,-e.z),a=new Ye().makeScale(this._scaleFactors.x,this._scaleFactors.y,this._scaleFactors.z),h=new wn().setFromAxisAngle(X.Z_AXIS,this._rotation),c=new Ye().makeRotationFromQuaternion(h),m=new Ye().makeTranslation(this._position.x,this._position.y,this._position.z);return new Ye().multiplyMatrices(m,c).multiply(a).multiply(n)}subGetOsnapPoints(t,e,n,a,h){Dt.Insertion===t?a.push(this._position):h&&this.subEntityGetOsnapPoints(t,e,n,a,h)}get properties(){const t={type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"blockName",type:"float",editable:!1,accessor:{get:()=>this._blockName}},{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:e=>{this.position.x=e}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:e=>{this.position.y=e}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:e=>{this.position.z=e}}},{name:"rotation",type:"float",editable:!0,accessor:{get:()=>this.rotation,set:e=>{this.rotation=e}}},{name:"scaleFactorsX",type:"float",editable:!0,accessor:{get:()=>this.scaleFactors.x,set:e=>{this.scaleFactors.x=e}}},{name:"scaleFactorsY",type:"float",editable:!0,accessor:{get:()=>this.scaleFactors.y,set:e=>{this.scaleFactors.y=e}}},{name:"scaleFactorsZ",type:"float",editable:!0,accessor:{get:()=>this.scaleFactors.z,set:e=>{this.scaleFactors.z=e}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:e=>{this.normal.x=e}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:e=>{this.normal.y=e}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:e=>{this.normal.z=e}}}]}]};if(this._attribs.size>0){const e={groupName:"attribute",properties:[]};t.groups.push(e),this._attribs.forEach(n=>{e.properties.push({name:n.tag,type:"string",editable:!n.isConst,skipTranslation:!0,accessor:{get:()=>n.textString,set:a=>{n.textString=a}}})})}return t}get geometricExtents(){const t=new Ct,e=this.blockTableRecord;if(e!=null){const a=e.newIterator();for(const h of a)t.union(h.geometricExtents)}const n=this.blockTransform;return t.applyMatrix4(n),t}subWorldDraw(t){const e=this.blockTableRecord;if(e!=null){const n=this.blockTransform,a=[];return this._attribs.forEach(c=>{if(!c.isInvisible){const m=c.worldDraw(t);m&&a.push(m)}}),$n.instance.draw(t,e,this.rgbColor,a,!0,n,this._normal)}else return t.group([])}subEntityGetOsnapPoints(t,e,n,a,h){var m;if(h===this.objectId)return;const c=(m=this.database)==null?void 0:m.tables.blockTable;if(c!=null){const b=c.getEntityById(h);if(b){const f=[];b.subGetOsnapPoints(t,e,n,f,h);const w=this.blockTransform;f.forEach(x=>{const S=x.clone().applyMatrix4(w);a.push(S)})}}}};bo.typeName="BlockReference";let Yn=bo;const xo=class xo extends Te{constructor(t,e,n=X.Z_AXIS){super(),this._geo=new Xa(t,e,0,Zt,n,X.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}subGetOsnapPoints(t,e,n,a){switch(t){case Dt.Center:case Dt.Centroid:a.push(this._geo.center);break;case Dt.Quadrant:a.push(this._geo.getPointAtAngle(0)),a.push(this._geo.getPointAtAngle(Math.PI/2)),a.push(this._geo.getPointAtAngle(Math.PI)),a.push(this._geo.getPointAtAngle(Math.PI/2*3));break;case Dt.Nearest:{const h=this._geo.nearestPoint(e);a.push(h)}break;case Dt.Tangent:{const h=this._geo.tangentPoints(e);a.push(...h);break}}}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"centerX",type:"float",editable:!0,accessor:{get:()=>this.center.x,set:t=>{this.center.x=t}}},{name:"centerY",type:"float",editable:!0,accessor:{get:()=>this.center.y,set:t=>{this.center.y=t}}},{name:"centerZ",type:"float",editable:!0,accessor:{get:()=>this.center.z,set:t=>{this.center.z=t}}},{name:"radius",type:"float",editable:!0,accessor:{get:()=>this.radius,set:t=>{this.radius=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}},{name:"diameter",type:"float",editable:!1,accessor:{get:()=>this._geo.radius*2}},{name:"perimeter",type:"float",editable:!1,accessor:{get:()=>this._geo.length}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this._geo.area}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.center),t}transformBy(t){return this._geo.transform(t),this}subWorldDraw(t){return t.circularArc(this._geo)}};xo.typeName="Circle";let Ai=xo;const wo=class wo extends Te{constructor(t,e,n,a,h,c,m){super(),this._geo=new $i(t,e,n,a,h,c,m)}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 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 normal(){return this._geo.normal}set normal(t){this._geo.normal=t}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}subGetOsnapPoints(t,e,n,a){switch(t){case Dt.EndPoint:this.closed||(a.push(this._geo.startPoint),a.push(this._geo.endPoint));break;case Dt.MidPoint:this.closed||a.push(this._geo.midPoint);break;case Dt.Quadrant:this.closed&&(a.push(this._geo.getPointAtAngle(0)),a.push(this._geo.getPointAtAngle(Math.PI/2)),a.push(this._geo.getPointAtAngle(Math.PI)),a.push(this._geo.getPointAtAngle(Math.PI/2*3)));break}}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"centerX",type:"float",editable:!0,accessor:{get:()=>this.center.x,set:t=>{this.center.x=t}}},{name:"centerY",type:"float",editable:!0,accessor:{get:()=>this.center.y,set:t=>{this.center.y=t}}},{name:"centerZ",type:"float",editable:!0,accessor:{get:()=>this.center.z,set:t=>{this.center.z=t}}},{name:"majorAxisRadius",type:"float",editable:!0,accessor:{get:()=>this.majorAxisRadius,set:t=>{this.center.x=t}}},{name:"minorAxisRadius",type:"float",editable:!0,accessor:{get:()=>this.minorAxisRadius,set:t=>{this.minorAxisRadius=t}}},{name:"startAngle",type:"float",editable:!0,accessor:{get:()=>this.startAngle,set:t=>{this.startAngle=t}}},{name:"endAngle",type:"float",editable:!0,accessor:{get:()=>this.endAngle,set:t=>{this.endAngle=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this._geo.area}}]}]}}subWorldDraw(t){return t.ellipticalArc(this._geo)}};wo.typeName="Ellipse";let Pi=wo;const Ao=class Ao extends ke{constructor(){super(),this._vertices=[new G,new G,new G],this._edgeInvisibilities=0}getVertexAt(t){return t<0?this._vertices[0]:t>this._vertices.length?this._vertices[this._vertices.length-1]:this._vertices[t]}setVertexAt(t,e){if(t<0&&this._vertices[0].copy(e),t>=3)return this._vertices.length===3&&this._vertices.push(new G),this._vertices[3].copy(e);this._vertices[t].copy(e)}setEdgeInvisibilities(t){this._edgeInvisibilities=t}isEdgeVisibleAt(t){if(t<0||t>3)throw new Error("Index out of range");return(this._edgeInvisibilities&1<<t)===0}makeEdgeInvisibleAt(t){if(t<0||t>3)throw new Error("Index out of range");this._edgeInvisibilities=this._edgeInvisibilities|1<<t}get geometricExtents(){return new Ct().setFromPoints(this._vertices)}subGetGripPoints(){const t=new Array;return t.push(...this._vertices),t}subGetOsnapPoints(t,e,n,a){switch(t){case Dt.EndPoint:a.push(...this._vertices);break}}subWorldDraw(t){const e=this._vertices.length,n=new Float32Array(e*3),a=new Uint16Array(e*2);for(let h=0;h<e;h++)n[h*3]=this._vertices[h].x,n[h*3+1]=this._vertices[h].y,n[h*3+2]=this._vertices[h].z,this.isEdgeVisibleAt(h)&&(a[h*2]=h,a[h*2+1]=(h+1)%4);return t.lineSegments(n,3,a)}};Ao.typeName="Face";let Ii=Ao;var Gs=(i=>(i[i.UserDefined=0]="UserDefined",i[i.Predefined=1]="Predefined",i[i.Custom=2]="Custom",i))(Gs||{}),Sh=(i=>(i[i.Normal=0]="Normal",i[i.Outer=1]="Outer",i[i.Ignore=2]="Ignore",i))(Sh||{});const Po=class Po extends ke{constructor(){super(),this._elevation=0,this._geo=new Xi,this._isSolidFill=!1,this._definitionLines=[],this._patternName="",this._patternType=1,this._patternAngle=0,this._patternScale=1,this._hatchStyle=0}get isSolidFill(){return this._isSolidFill||this._patternName.toUpperCase()==="SOLID"}set isSolidFill(t){this._isSolidFill=t}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}get elevation(){return this._elevation}set elevation(t){this._elevation=t}add(t){this._geo.add(t)}get geometricExtents(){const t=this._geo.box;return new Ct({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"pattern",properties:[{name:"patternType",type:"enum",editable:!0,options:[{label:Gs[0],value:0},{label:Gs[1],value:1},{label:Gs[2],value:2}],accessor:{get:()=>this.patternType,set:t=>{this.patternType=t}}},{name:"patternName",type:"string",editable:!0,accessor:{get:()=>this.patternName,set:t=>{this.patternName=t}}},{name:"patternAngle",type:"float",editable:!0,accessor:{get:()=>this.patternAngle,set:t=>{this.patternAngle=t}}},{name:"patternScale",type:"float",editable:!0,accessor:{get:()=>this.patternScale,set:t=>{this.patternScale=t}}}]},{groupName:"geometry",properties:[{name:"elevation",type:"float",editable:!0,accessor:{get:()=>this.elevation,set:t=>{this.elevation=t}}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this._geo.area}}]}]}}subWorldDraw(t){const e=t.subEntityTraits;return e.fillType={solidFill:this.isSolidFill,patternAngle:this.patternAngle,definitionLines:this.definitionLines},t.area(this._geo)}};Po.typeName="Hatch";let qs=Po;var Eh=(i=>(i[i.MText=0]="MText",i[i.Fcf=1]="Fcf",i[i.BlockReference=2]="BlockReference",i[i.NoAnnotation=3]="NoAnnotation",i))(Eh||{});const Io=class Io extends Te{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 G().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 Ct().setFromPoints(this._vertices)}get closed(){return!1}set closed(t){}subWorldDraw(t){if(this.isSplined&&this.splineGeo){const e=this.splineGeo.getPoints(100);return t.lines(e)}else return t.lines(this._vertices)}get splineGeo(){return this.createSplineIfNeeded(),this._splineGeo}createSplineIfNeeded(){this.isSplined&&this.numVertices>=2&&(this._splineGeo==null||this._updated)&&(this._splineGeo=new Jr(this._vertices,"Uniform"),this._updated=!1)}};Io.typeName="Leader";let Si=Io;var Dt=(i=>(i[i.EndPoint=1]="EndPoint",i[i.MidPoint=2]="MidPoint",i[i.Center=3]="Center",i[i.Node=4]="Node",i[i.Quadrant=5]="Quadrant",i[i.Insertion=7]="Insertion",i[i.Perpendicular=8]="Perpendicular",i[i.Tangent=9]="Tangent",i[i.Nearest=10]="Nearest",i[i.Centroid=11]="Centroid",i))(Dt||{});function Ku(i){let t=0;for(const e of i)t|=1<<e-1;return t}function $u(i){const t=[];for(const e of Object.values(Dt)){if(typeof e!="number")continue;const n=1<<e-1;i&n&&t.push(e)}return t}function Zu(i,t){return i^1<<t-1}function Qu(i,t){return(i&1<<t-1)!==0}function Ju(i,t){return i|1<<t-1}function td(i,t){return i&~(1<<t-1)}const So=class So extends Te{constructor(t,e){super(),this._geo=new Hn(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}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"startX",type:"float",editable:!0,accessor:{get:()=>this.startPoint.x,set:t=>{this.startPoint.x=t}}},{name:"startY",type:"float",editable:!0,accessor:{get:()=>this.startPoint.y,set:t=>{this.startPoint.y=t}}},{name:"startZ",type:"float",editable:!0,accessor:{get:()=>this.startPoint.z,set:t=>{this.startPoint.z=t}}},{name:"endX",type:"float",editable:!0,accessor:{get:()=>this.endPoint.x,set:t=>{this.endPoint.x=t}}},{name:"endY",type:"float",editable:!0,accessor:{get:()=>this.endPoint.y,set:t=>{this.endPoint.y=t}}},{name:"endZ",type:"float",editable:!0,accessor:{get:()=>this.endPoint.z,set:t=>{this.endPoint.z=t}}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.midPoint),t.push(this.startPoint),t.push(this.endPoint),t}subGetOsnapPoints(t,e,n,a){const h=this.startPoint,c=this.endPoint;switch(t){case Dt.EndPoint:a.push(h),a.push(c);break;case Dt.MidPoint:a.push(this.midPoint);break;case Dt.Nearest:{const m=this._geo.project(e);a.push(m)}break;case Dt.Perpendicular:{const m=this._geo.perpPoint(e);a.push(m)}break;case Dt.Tangent:break}}transformBy(t){return this._geo.transform(t),this}subWorldDraw(t){const e=this.startPoint,n=this.endPoint,a=[new G(e.x,e.y,0),new G(n.x,n.y,0)];return t.lines(a)}};So.typeName="Line";let Ys=So;const Eo=class Eo extends ke{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 G,this._attachmentPoint=xe.TopLeft,this._direction=new X(1,0,0),this._drawingDirection=Rr.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 Ct}subGetOsnapPoints(t,e,n,a){Dt.Insertion===t&&a.push(this._location)}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"text",properties:[{name:"contents",type:"string",editable:!0,accessor:{get:()=>this.contents,set:t=>{this.contents=t}}},{name:"styleName",type:"string",editable:!0,accessor:{get:()=>this.styleName,set:t=>{this.styleName=t}}},{name:"attachmentPoint",type:"enum",editable:!0,options:[{label:xe[1],value:1},{label:xe[2],value:2},{label:xe[3],value:3},{label:xe[4],value:4},{label:xe[5],value:5},{label:xe[6],value:6},{label:xe[7],value:7},{label:xe[8],value:8},{label:xe[9],value:9}],accessor:{get:()=>this.attachmentPoint,set:t=>{this.attachmentPoint=t}}},{name:"drawingDirection",type:"enum",editable:!0,options:[{label:Rr[1],value:1},{label:Rr[2],value:2},{label:Rr[3],value:3},{label:Rr[4],value:4},{label:Rr[5],value:5}],accessor:{get:()=>this.drawingDirection,set:t=>{this.drawingDirection=t}}},{name:"textHeight",type:"float",editable:!0,accessor:{get:()=>this.height,set:t=>{this.height=t}}},{name:"rotation",type:"float",editable:!0,accessor:{get:()=>this.rotation,set:t=>{this.rotation=t}}},{name:"lineSpacingFactor",type:"float",editable:!0,accessor:{get:()=>this.lineSpacingFactor,set:t=>{this.lineSpacingFactor=t}}},{name:"definedWidth",type:"float",editable:!0,accessor:{get:()=>this.width,set:t=>{this.width=t}}},{name:"directionX",type:"float",editable:!0,accessor:{get:()=>this.direction.x,set:t=>{this.direction.x=t}}},{name:"directionY",type:"float",editable:!0,accessor:{get:()=>this.direction.y,set:t=>{this.direction.y=t}}},{name:"directionZ",type:"float",editable:!0,accessor:{get:()=>this.direction.z,set:t=>{this.direction.z=t}}}]},{groupName:"geometry",properties:[{name:"locationX",type:"float",editable:!0,accessor:{get:()=>this.location.x,set:t=>{this.location.x=t}}},{name:"locationY",type:"float",editable:!0,accessor:{get:()=>this.location.y,set:t=>{this.location.y=t}}},{name:"locationZ",type:"float",editable:!0,accessor:{get:()=>this.location.z,set:t=>{this.location.z=t}}}]}]}}getTextStyle(){const t=this.database.tables.textStyleTable;let e=t.getAt(this.styleName);return e||(e=t.getAt("STANDARD")||t.getAt("Standard")),e.textStyle}subWorldDraw(t,e){const n={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};return t.mtext(n,this.getTextStyle(),e)}};Eo.typeName="MText";let Xs=Eo;const Mo=class Mo extends Te{constructor(t,e,n,a,h){super();const c=+(t!==void 0)+ +(e!==void 0)+ +(n!==void 0)+ +(a!==void 0)+ +(h!==void 0);if(c<2||c>5)throw Xe.ILLEGAL_PARAMETERS;!Array.isArray(e)?this._geo=new Jr(t,e,n,a):this._geo=new Jr(t,e,n,a,h)}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}subGetOsnapPoints(t,e,n,a){switch(t){case Dt.EndPoint:a.push(this._geo.startPoint),a.push(this._geo.endPoint);break}}subWorldDraw(t){const e=this._geo.getPoints(100);return t.lines(e)}};Mo.typeName="Spline";let Ks=Mo;const ed=new X,ko=class ko extends Yn{constructor(t,e,n){super(t),this._attachmentPoint=xe.TopLeft,this._numColumns=n,this._numRows=e,this._columnWidth=new Array(n),this._rowHeight=new Array(e),this._cells=new Array(e*n)}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,n){return this._cells[t*e].text}setTextString(t,e,n){this._cells[t*e].text=n}isEmpty(t,e){return!this._cells[t*e].text}get geometricExtents(){return new Ct}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"table",properties:[{name:"numRows",type:"string",editable:!0,accessor:{get:()=>this.numRows,set:t=>{this.numRows=t}}},{name:"numColumns",type:"float",editable:!0,accessor:{get:()=>this.numColumns,set:t=>{this.numColumns=t}}},{name:"tableWidth",type:"float",editable:!1,accessor:{get:()=>this._columnWidth.reduce((t,e)=>t+e,0)}},{name:"tableHeight",type:"float",editable:!1,accessor:{get:()=>this._rowHeight.reduce((t,e)=>t+e,0)}}]},{groupName:"geometry",properties:[{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:t=>{this.position.x=t}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:t=>{this.position.y=t}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:t=>{this.position.z=t}}}]}]}}subWorldDraw(t){let e=0,n=0;const a=new Uint16Array(this.numColumns*this.numRows*8),h=new Float32Array((this.numColumns+1)*(this.numRows+1)*3);let c=0;for(let S=0;S<=this.numRows;S++){e-=S>0?this.rowHeight(S-1):0,n=0;for(let M=0;M<=this.numColumns;M++)n+=M>0?this.columnWidth(M-1):0,h[c++]=n,h[c++]=e,h[c++]=0}const m=[],b=new Array(this.numRows*this.numColumns).fill(!1);n=0,c=0;let f=0;for(let S=0;S<this.numColumns;S++){n+=S>0?this.columnWidth(S-1):0,e=0;for(let M=0;M<this.numRows;M++){e+=M>0?this.rowHeight(M-1):0;const N=this.cell(M*this.numColumns+S);if(f=M*this.numColumns+S,N&&!b[f]){const O=N.borderWidth??1,F=N.borderHeight??1;this.fillVisited(b,f,this.numColumns,O,F),a[c++]=S+M*(this.numColumns+1),a[c++]=S+M*(this.numColumns+1)+O;const D=h[a[c-1]*3]-n,at=S+(M+F)*(this.numColumns+1)+O;S+O==this.numColumns&&(a[c++]=S+M*(this.numColumns+1)+O,a[c++]=at);const ft=-h[at*3+1]-e;if(M+F==this.numRows&&(a[c++]=S+(M+F)*(this.numColumns+1)+F,a[c++]=S+(M+F)*(this.numColumns+1)),a[c++]=S+(M+F)*(this.numColumns+1),a[c++]=S+M*(this.numColumns+1),N.text){const st=N.attachmentPoint||this.attachmentPoint||xe.MiddleCenter,H=this.getTableTextOffset(st,D,ft),ut={text:N.text,height:N.textHeight,width:D,position:ed.set(n,-e,0).clone().add(H),rotation:this.rotation,attachmentPoint:st},it=this.getTextStyle(N);m.push(t.mtext(ut,it))}}}}m.push(t.lineSegments(h,3,a));const w=t.group(m),x=new wn;return x.setFromAxisAngle(X.Z_AXIS,this.rotation),_l.compose(this.position,x,this.scaleFactors),w.applyMatrix(_l),w}fillVisited(t,e,n,a,h){if(h==1&&a==1)t[e]=!0;else for(let c=0;c<a;++c)for(let m=0;m<h;++m)t[e+c+m*n]=!0}getTextStyle(t){const e=this.database.tables.textStyleTable;let n;return t.textStyle&&(n=e.getAt(t.textStyle)),n||(n=e.getAt("STANDARD")||e.getAt("Standard")),n.textStyle}getTableTextOffset(t,e,n){const a=new X;switch(t){case 1:break;case 2:a.setX(e/2);break;case 3:a.setX(e);break;case 4:a.setY(-n/2);break;case 5:a.set(e/2,-n/2,0);break;case 6:a.set(e,-n/2,0);break;case 7:a.setY(-n);break;case 8:a.set(e/2,-n,0);break;case 9:a.set(e,-n,0);break}return a}};ko.typeName="Table";let Ei=ko;const _l=new Ye,To=class To extends Te{constructor(){super(),this._elevation=0,this._thickness=1,this._vertices=[new G,new G,new G,new G]}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 Ct().setFromPoints(this._vertices)}subGetGripPoints(){const t=new Array;return t.push(...this._vertices),t}subGetOsnapPoints(t,e,n,a){switch(t){case Dt.EndPoint:a.push(...this._vertices);break}}subWorldDraw(t){const e=new An(this._vertices,!0),n=new Xi;n.add(e);const a=t.subEntityTraits;return a.fillType={solidFill:!0,patternAngle:0,definitionLines:[]},t.area(n)}};To.typeName="Trace";let Mi=To;const Co=class Co extends Te{constructor(){super(),this._elevation=0,this._geo=new An}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,n=0,a=-1,h=-1){const c=a<0?void 0:a,m=h<0?void 0:h,b={x:e.x,y:e.y,bulge:n,startWidth:c,endWidth:m};this._geo.addVertexAt(t,b)}getPoint2dAt(t){return this._geo.getPointAt(t)}getPoint3dAt(t){const e=this.getPoint2dAt(t);return new G(e.x,e.y,this._elevation)}get geometricExtents(){const t=this._geo.box;return new Ct({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}subGetOsnapPoints(t,e,n,a){const h=new Array;for(let c=0;c<this.numberOfVertices;++c)h.push(this.getPoint3dAt(c));switch(t){case Dt.EndPoint:a.push(...h);break}}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!0},{name:"y",type:"float",editable:!0}]},accessor:{get:()=>this._geo.vertices}},{name:"elevation",type:"float",editable:!0,accessor:{get:()=>this.elevation,set:t=>{this.elevation=t}}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}}]},{groupName:"others",properties:[{name:"closed",type:"float",editable:!0,accessor:{get:()=>this.closed,set:t=>{this.closed=t}}}]}]}}subWorldDraw(t){const e=[];return this._geo.getPoints(100).forEach(a=>e.push(new G().set(a.x,a.y,this.elevation))),t.lines(e)}};Co.typeName="Polyline";let ki=Co;const No=class No extends ke{constructor(){super(),this._geo=new G}get position(){return this._geo}set position(t){this._geo.set(t.x,t.y,t.z||0)}get geometricExtents(){return new Ct().expandByPoint(this._geo)}subGetOsnapPoints(t,e,n,a){Dt.Node===t&&a.push(this._geo)}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:t=>{this.position.x=t}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:t=>{this.position.y=t}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:t=>{this.position.z=t}}}]}]}}transformBy(t){return this._geo.applyMatrix4(t),this}subWorldDraw(t){return t.point(this._geo,{displayMode:this.database.pdmode,displaySize:this.database.pdsize})}};No.typeName="Point";let Ti=No;var Mh=(i=>(i[i.Invalid=0]="Invalid",i[i.Rect=1]="Rect",i[i.Poly=2]="Poly",i))(Mh||{}),kh=(i=>(i[i.Show=1]="Show",i[i.ShowUnAligned=2]="ShowUnAligned",i[i.Clip=4]="Clip",i[i.Transparent=8]="Transparent",i))(kh||{});const Lo=class Lo extends ke{constructor(){super(),this._brightness=50,this._contrast=50,this._fade=0,this._width=0,this._height=0,this._position=new G,this._scale=new Jt(1,1),this._rotation=0,this._clipBoundaryType=1,this._clipBoundary=[],this._isClipped=!1,this._isShownClipped=!1,this._isImageShown=!0,this._isImageTransparent=!1,this._imageDefId=""}get brightness(){return this._brightness}set brightness(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 isShownClipped(){return this._isShownClipped}set isShownClipped(t){this._isShownClipped=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 Ct;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()}subWorldDraw(t){const e=this.boundaryPath();return this._image?t.image(this._image,{boundary:e,roation:this._rotation}):t.lines(e)}boundaryPath(){const t=[];if(this.isClipped&&this._clipBoundary.length>3){const e=this._width,n=this._height,a=new we;a.setFromPoints(this._clipBoundary);const h=new Tt;h.setX(this._position.x-a.min.x*e),h.setY(this._position.y-a.min.y*n),this._clipBoundary.forEach(c=>{const m=c.x*e+h.x,b=c.y*n+h.y;t.push(new G(m,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){yl.copy(t[1]);for(let e=1;e<4;e++)ai.copy(t[e]),ai.rotateAround(yl,this._rotation),t[e].setX(ai.x),t[e].setY(ai.y)}t.push(t[0])}return t}};Lo.typeName="RasterImage";let $s=Lo;const yl=new Tt,ai=new Tt,Oo=class Oo extends Te{constructor(){super(),this._basePoint=new G,this._unitDir=new X}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 Ct;return t.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),t.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),t}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"basePointX",type:"float",editable:!0,accessor:{get:()=>this.basePoint.x,set:t=>{this.basePoint.x=t}}},{name:"basePointY",type:"float",editable:!0,accessor:{get:()=>this.basePoint.y,set:t=>{this.basePoint.y=t}}},{name:"basePointZ",type:"float",editable:!0,accessor:{get:()=>this.basePoint.z,set:t=>{this.basePoint.z=t}}},{name:"unitDirX",type:"float",editable:!0,accessor:{get:()=>this.unitDir.x,set:t=>{this.unitDir.x=t}}},{name:"unitDirY",type:"float",editable:!0,accessor:{get:()=>this.unitDir.y,set:t=>{this.unitDir.y=t}}},{name:"unitDirZ",type:"float",editable:!0,accessor:{get:()=>this.unitDir.z,set:t=>{this.unitDir.z=t}}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.basePoint),t}subGetOsnapPoints(t,e,n,a){switch(t){case Dt.EndPoint:a.push(this.basePoint);break}}subWorldDraw(t){const e=[];return e.push(this.basePoint),e.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),t.lines(e)}};Oo.typeName="Ray";let Ci=Oo;const Bo=class Bo extends ke{constructor(){super(),this._centerPoint=new G,this._height=0,this._width=0,this._viewCenter=new G,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 Ct}subWorldDraw(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 vh;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 n=[];return n.push(e.lines([new G(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0),new G(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0)])),n.push(e.lines([new G(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0),new G(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0)])),n.push(e.lines([new G(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0),new G(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0)])),n.push(e.lines([new G(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0),new G(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0)])),n}};Bo.typeName="Viewport";let Ni=Bo;const zo=class zo extends $s{subWorldDraw(t){const e=this.boundaryPath(),n=new Xi;return n.add(new An(e)),t.area(n)}};zo.typeName="Wipeout";let Li=zo;const Ro=class Ro extends Te{constructor(){super(),this._basePoint=new G,this._unitDir=new X}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 Ct;return t.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),t.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),t}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"basePointX",type:"float",editable:!0,accessor:{get:()=>this.basePoint.x,set:t=>{this.basePoint.x=t}}},{name:"basePointY",type:"float",editable:!0,accessor:{get:()=>this.basePoint.y,set:t=>{this.basePoint.y=t}}},{name:"basePointZ",type:"float",editable:!0,accessor:{get:()=>this.basePoint.z,set:t=>{this.basePoint.z=t}}},{name:"unitDirX",type:"float",editable:!0,accessor:{get:()=>this.unitDir.x,set:t=>{this.unitDir.x=t}}},{name:"unitDirY",type:"float",editable:!0,accessor:{get:()=>this.unitDir.y,set:t=>{this.unitDir.y=t}}},{name:"unitDirZ",type:"float",editable:!0,accessor:{get:()=>this.unitDir.z,set:t=>{this.unitDir.z=t}}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.basePoint),t}subWorldDraw(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)}};Ro.typeName="Xline";let Oi=Ro;var Th=(i=>(i[i.AtLeast=1]="AtLeast",i[i.Exactly=2]="Exactly",i))(Th||{});const Do=class Do extends ke{constructor(){super(),this._dimBlockId=null,this._dimBlockPosition=new G,this._dimensionStyleName=null,this._dimensionText=null,this._textLineSpacingFactor=1,this._textLineSpacingStyle=1,this._textPosition=new G,this._textRotation=0,this._normal=new X(0,0,1)}get dimBlockId(){return this._dimBlockId}set dimBlockId(t){this._dimBlockId=t}get dimBlockPosition(){return this._dimBlockPosition}set dimBlockPosition(t){this._dimBlockPosition.copy(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 Xn),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}get normal(){return this._normal}set normal(t){this._normal.copy(t).normalize()}subWorldDraw(t){if(this.dimBlockId){const n=this.database.tables.blockTable.getAt(this.dimBlockId);if(n){const a=this.computeDimBlockTransform();return $n.instance.draw(t,n,this.rgbColor,[],!1,a,this._normal)}}return t.group([])}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,n){const a=new G().subVectors(e,t).normalize();return new G(e).addScaledVector(a,n)}findPointOnLine2(t,e,n){const a=t.x+n*Math.cos(e),h=t.y+n*Math.sin(e);return{x:a,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}computeDimBlockTransform(){const t=this.dimBlockId?this.database.tables.blockTable.getAt(this.dimBlockId):void 0,e=(t==null?void 0:t.origin)??G.ORIGIN,n=new Ye().makeTranslation(-e.x,-e.y,-e.z),a=new Ye().makeTranslation(this._dimBlockPosition.x,this._dimBlockPosition.y,this._dimBlockPosition.z);return new Ye().multiplyMatrices(a,n)}};Do.typeName="Dimension";let Dr=Do;const Fo=class Fo extends Dr{constructor(t,e,n,a,h=null,c=null){super(),this._centerPoint=new G().copy(t),this._xLine1Point=new G().copy(e),this._xLine2Point=new G().copy(n),this._arcPoint=new G().copy(a),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 Ct}};Fo.typeName="3PointAngularDimension";let Bi=Fo;const Vo=class Vo extends Dr{constructor(t,e,n,a=null,h=null){super(),this._dimLinePoint=new G().copy(n),this._xLine1Point=new G().copy(t),this._xLine2Point=new G().copy(e),this._oblique=0,this._rotation=0,this.calculateRotation(),a?this.dimensionText=a:this.dimensionText=this._xLine1Point.distanceTo(this._xLine2Point).toFixed(3),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 Ct}get isAppendArrow(){return!1}createDimBlock(t){const e=new he;e.name=t;const n=this.createLines();n.forEach(m=>e.appendEntity(new Ys(m.startPoint,m.endPoint))),this.createArrows(n[0]).forEach(m=>e.appendEntity(m));const h=n[0].midPoint,c=this.createMText(h,this._rotation);return c&&e.appendEntity(c),e}createMText(t,e){const n=a=>({x:Math.cos(a),y:Math.sin(a),z:0});if(this.dimensionText){const a=new Xs;return a.attachmentPoint=xe.MiddleLeft,a.layer="0",a.color=new Fr(pt.ByBlock),a.location=t,a.contents=this.dimensionText??"",a.height=10,a.direction=n(e),a.styleName=this.dimensionStyle.dimtxsty,a}}createArrows(t){const e=[];return e.push(this.createArrow(t.startPoint,this.rotation+Math.PI,10)),e.push(this.createArrow(t.endPoint,this.rotation,10)),e}createArrow(t,e,n){const a="_CAXARROW",h=new Yn(a);return h.position=t,h.rotation=e,h.scaleFactors={x:n,y:n,z:n},h}createLines(){const t=[],e=this.createExtensionLine(this._xLine1Point),n=this.createExtensionLine(this._xLine2Point),a=this.findIntersectionPoint(e,this._dimLinePoint),h=this.findIntersectionPoint(n,this._dimLinePoint),c=new Hn(a,h);return t.push(c),e.endPoint=a,this.adjustExtensionLine(e),t.push(e),n.endPoint=h,this.adjustExtensionLine(n),t.push(n),t}createExtensionLine(t){const e=this.rotation+Math.PI/2,n=this.findPointOnLine2(t,e,100);return new Hn(t,{...n,z:t.z})}findIntersectionPoint(t,e){const n=t.startPoint,a=t.endPoint,h=new X().subVectors(a,n).normalize(),m=new X().subVectors(e,n).dot(h),b=new X().copy(h).multiplyScalar(m);return new X().addVectors(n,b)}calculateRotation(){const t=this._xLine1Point,e=this._xLine2Point,n=e.x-t.x,a=e.y-t.y;this._rotation=Math.atan2(a,n)}};Vo.typeName="AlignedDimension";let zi=Vo;const Uo=class Uo extends Dr{constructor(t,e,n,a,h=null,c=null){super(),this._arcPoint=new G().copy(a),this._xLine1Point=new G().copy(e),this._xLine2Point=new G().copy(n),this._centerPoint=new G().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 Ct}};Uo.typeName="ArcDimension";let Ca=Uo;const jo=class jo extends Dr{constructor(t,e,n=0,a=null,h=null){super(),this._chordPoint=new G().copy(t),this._farChordPoint=new G().copy(e),this._extArcStartAngle=0,this._extArcEndAngle=0,this._leaderLength=n,this.dimensionText=a,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 Ct}drawLines(t,e){const n=[],a=e.length;return a==1?n.push(this.drawLine(t,e[0],{firstArrow:this.firstArrowStyle})):a==3?(this.sortLines(e),n.push(this.drawLine(t,e[0],{firstArrow:this.firstArrowStyle})),n.push(this.drawLine(t,e[1])),n.push(this.drawLine(t,e[2],{firstArrow:this.firstArrowStyle}))):e.forEach(h=>{n.push(this.drawLine(t,h))}),n}drawLine(t,e,n){if(n){const a=[e.startPoint,e.endPoint];return t.lines(a)}else return e.worldDraw(t)}sortLines(t){const e=(n,a)=>n.x!==a.x?n.x-a.x:n.y!==a.y?n.y-a.y:n.z-a.z;t.sort((n,a)=>{const h=e(n.startPoint,a.startPoint);return h!==0?h:e(n.endPoint,a.endPoint)})}};jo.typeName="DiametricDimension";let Ri=jo;const Go=class Go extends Dr{constructor(t,e,n=null,a=null){super(),this._definingPoint=new G().copy(t),this._leaderEndPoint=new G().copy(e),this.dimensionText=n,this.dimensionStyleName=a}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 Ct}get arrowLineCount(){return 0}};Go.typeName="OrdinateDimension";let Di=Go;const Wo=class Wo extends Dr{constructor(t,e,n,a=null,h=null){super(),this._center=new G().copy(t),this._chordPoint=new G().copy(e),this._leaderLength=n,this._extArcStartAngle=0,this._extArcEndAngle=0,this.dimensionText=a,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 Ct}getLineArrowStyle(t){return{secondArrow:this.secondArrowStyle}}};Wo.typeName="RadialDimension";let Fi=Wo;class Qi extends tn{constructor(){super(),this._tabOrder=-1,this._tabSelected=!1,this._blockTableRecordId="",this._layoutName="",this._limits=new we,this._extents=new Ct}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 to extends tn{constructor(t){super(),this.database=t,this._recordsByName=new Map,this._recordsById=new Map}get numEntries(){return this._recordsByName.size}setAt(t,e){e.database=this.database,this._recordsByName.set(t,e),this._recordsById.set(e.objectId,e),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((n,a)=>{n===e&&(this._recordsByName.delete(a),this.database.events.dictObjectErased.dispatch({database:this.database,object:e,key:a}))}),!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 Js(this._recordsByName)}}class Ch extends to{getBtrIdAt(t){for(const[e,n]of this._recordsByName)if(n.blockTableRecordId==t)return n}get maxTabOrder(){let t=-1;return this._recordsByName.forEach(e=>{e.tabOrder>t&&(t=e.tabOrder)}),t}}class Nh extends tn{constructor(){super(),this._sourceFileName=""}get sourceFileName(){return this._sourceFileName}set sourceFileName(t){this._sourceFileName=t}}class Lh{constructor(t){this.db=t}createDefaultLayer(){const t=new Fr;return t.colorIndex=7,this.db.tables.layerTable.add(new ta({name:"0",standardFlags:0,linetype:"Continuous",lineWeight:0,isOff:!1,color:t,isPlottable:!0}))}createDefaultLineType(){this.db.tables.linetypeTable.add(new Hs({name:"ByBlock",standardFlag:0,description:"",totalPatternLength:0})),this.db.tables.linetypeTable.add(new Hs({name:"ByLayer",standardFlag:0,description:"",totalPatternLength:0})),this.db.tables.linetypeTable.add(new Hs({name:"Continuous",standardFlag:0,description:"Solid line",totalPatternLength:0}))}createDefaultTextStyle(){this.db.tables.textStyleTable.add(new oo({name:"Standard",standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:.2,font:"SimKai",bigFont:"",extendedFont:"SimKai"}))}createDefaultDimStyle(){this.db.tables.dimStyleTable.add(new Xn({name:"Standard",dimtxsty:"Standard"}))}createDefaultLayout(){const t=new Qi;t.layoutName="Model",t.tabOrder=0,t.blockTableRecordId=this.db.tables.blockTable.modelSpace.objectId,t.limits.min.copy({x:0,y:0}),t.limits.max.copy({x:1e6,y:1e6}),t.extents.min.copy({x:0,y:0,z:0}),t.extents.max.copy({x:1e6,y:1e6,z:0}),this.db.dictionaries.layouts.setAt(t.layoutName,t),this.db.tables.blockTable.modelSpace.layoutId=t.objectId}createArrowBlock(){if(!this.db.tables.blockTable.getAt("_CAXARROW")){const e=new qs;e.patternName="SOLID";const n=new Ka;n.add(new Us({x:0,y:0},{x:-1,y:.125})),n.add(new Us({x:-1,y:.125},{x:-1,y:-.125})),n.add(new Us({x:-1,y:-.125},{x:0,y:0})),e.add(n);const a=new he;a.name="_CAXARROW",a.appendEntity(e),this.db.tables.blockTable.add(a)}}}var Oh=(i=>(i.ClosedFilled="",i.Dot="_DOT",i.DotSmall="_DOTSMALL",i.DotBlank="_DOTBLANK",i.Origin="_ORIGIN",i.Origin2="_ORIGIN2",i.Open="_OPEN",i.Open90="_OPEN90",i.Open30="_OPEN30",i.Closed="_CLOSED",i.Small="_SMALL",i.None="_NONE",i.Oblique="_OBLIQUE",i.BoxFilled="_BOXFILLED",i.Box="_BOXBLANK",i.ClosedBlank="_CLOSEDBLANK",i.DatumBlank="_DATUMBLANK",i.DatumFilled="_DATUMFILLED",i.Integral="_INTEGRAL",i.ArchTick="_ARCHTICK",i))(Oh||{});class Js{constructor(t){this.i=0,this._records=t,this._keys=Array.from(t.keys())}get count(){return this._records.size}toArray(){return Array.from(this._records.values())}[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}}}var eo=(i=>(i[i.Undefined=0]="Undefined",i[i.Inches=1]="Inches",i[i.Feet=2]="Feet",i[i.Miles=3]="Miles",i[i.Millimeters=4]="Millimeters",i[i.Centimeters=5]="Centimeters",i[i.Meters=6]="Meters",i[i.Kilometers=7]="Kilometers",i[i.Microinches=8]="Microinches",i[i.Mils=9]="Mils",i[i.Yards=10]="Yards",i[i.Angstroms=11]="Angstroms",i[i.Nanometers=12]="Nanometers",i[i.Microns=13]="Microns",i[i.Decimeters=14]="Decimeters",i[i.Dekameters=15]="Dekameters",i[i.Hectometers=16]="Hectometers",i[i.Gigameters=17]="Gigameters",i[i.Astronomical=18]="Astronomical",i[i.LightYears=19]="LightYears",i[i.Parsecs=20]="Parsecs",i[i.USSurveyFeet=21]="USSurveyFeet",i[i.USSurveyInch=22]="USSurveyInch",i[i.USSurveyYard=23]="USSurveyYard",i[i.USSurveyMile=24]="USSurveyMile",i[i.Max=24]="Max",i))(eo||{});function rd(i){return i==4||i==5||i==6||i==7||i==12||i==13||i==14||i==15||i==16||i==17}function nd(i){return i==1||i==2||i==3||i==8||i==9||i==10||i==21}const Bh="Load Database";class Oe extends Nl{constructor(t,e){super(t.stage),this.data=t,this.progress=e}async run(t){const e=Oa.getInstance().getEntry(Bh),n=Date.now();this.progress&&await this.progress(this.data.progress.value,this.data.stage,"START");const a=await this.data.task(t);return this.progress&&(await this.progress(this.data.progress.value,this.data.stage,"END",a?a.data:null),this.data.progress.value+=this.data.step,this.data.progress.value>100&&(this.data.progress.value=100)),e&&(e.data[this.name]=Date.now()-n),a}}class ro{constructor(t={}){this.config=t}async read(t,e,n,a){const h={name:Bh,data:{total:0},format(){let f="";return Object.keys(this.data).forEach(w=>{w!=="total"&&(f+=`- ${w}: ${this.data[w]} ms
5
+ `)}),f+=`- total: ${this.data.total} ms`,f}};Oa.getInstance().collect(h),this.progress=a;const c={value:0},m=new Ll;m.setCompleteCallback(()=>this.onFinished()),m.setErrorCallback(f=>this.onError(f)),m.addTask(new Oe({stage:"START",step:1,progress:c,task:async f=>f},a)),m.addTask(new Oe({stage:"PARSE",step:5,progress:c,task:async f=>await this.parse(f)},a)),m.addTask(new Oe({stage:"FONT",step:5,progress:c,task:async f=>{const w=this.getFonts(f.model);return{model:f.model,data:w}}},a)),m.addTask(new Oe({stage:"LTYPE",step:1,progress:c,task:async f=>(this.processLineTypes(f.model,e),f)},a)),m.addTask(new Oe({stage:"STYLE",step:1,progress:c,task:async f=>(this.processTextStyles(f.model,e),f)},a)),m.addTask(new Oe({stage:"DIMSTYLE",step:1,progress:c,task:async f=>(this.processDimStyles(f.model,e),f)},a)),m.addTask(new Oe({stage:"LAYER",step:1,progress:c,task:async f=>(this.processLayers(f.model,e),e.tables.layerTable.numEntries===0&&e.createDefaultData({layer:!0}),f)},a)),m.addTask(new Oe({stage:"VPORT",step:1,progress:c,task:async f=>(this.processViewports(f.model,e),f)},a)),m.addTask(new Oe({stage:"HEADER",step:1,progress:c,task:async f=>(this.processHeader(f.model,e),f)},a)),m.addTask(new Oe({stage:"BLOCK_RECORD",step:5,progress:c,task:async f=>(this.processBlockTables(f.model,e),f)},a)),m.addTask(new Oe({stage:"OBJECT",step:5,progress:c,task:async f=>(this.processObjects(f.model,e),e.dictionaries.layouts.numEntries===0&&e.createDefaultData({layout:!0}),f)},a)),m.addTask(new Oe({stage:"BLOCK",step:5,progress:c,task:async f=>(await this.processBlocks(f.model,e),f)},a)),m.addTask(new Oe({stage:"ENTITY",step:100,progress:c,task:async f=>(await this.processEntities(f.model,e,n,c,a),f)},a)),m.addTask(new Oe({stage:"END",step:0,progress:c,task:async f=>f},a));const b=Date.now();await m.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)}return console.error(`Error occurred in conversion stage '${t.task.name}': `,t.error),t.task.name==="ENTITY"?!1:(this.onFinished(),!0)}onFinished(){this.progress&&(this.progress(100,"END","END"),$n.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,n,a,h){throw new Error("Not impelemented yet!")}}var pe,bs,ee,oe,xs,ar,Pe,Ar,or,ln,ws,As,hn,cn,Ps,Is,Ss,Ue,Pr,Xt,un,Es,vt,Ie,Ms,Se,ks,Ir,Sr,lr,Ts,dn,je,Er,pn,ga,fa,Mr,kr,Cs,Ns,Tr,Ls,_a,ya,me,Cr,ge,Ge,va,ba,xa,wa,Nr,We,mn,Os,gn,He,Lr,qe,Or;(pe={})[pe.None=0]="None",pe[pe.Anonymous=1]="Anonymous",pe[pe.NonConstant=2]="NonConstant",pe[pe.Xref=4]="Xref",pe[pe.XrefOverlay=8]="XrefOverlay",pe[pe.ExternallyDependent=16]="ExternallyDependent",pe[pe.ResolvedOrDependent=32]="ResolvedOrDependent",pe[pe.ReferencedXref=64]="ReferencedXref";(bs={})[bs.BYBLOCK=0]="BYBLOCK",bs[bs.BYLAYER=256]="BYLAYER";(ee={})[ee.Rotated=0]="Rotated",ee[ee.Aligned=1]="Aligned",ee[ee.Angular=2]="Angular",ee[ee.Diameter=3]="Diameter",ee[ee.Radius=4]="Radius",ee[ee.Angular3Point=5]="Angular3Point",ee[ee.Ordinate=6]="Ordinate",ee[ee.ReferenceIsExclusive=32]="ReferenceIsExclusive",ee[ee.IsOrdinateXTypeFlag=64]="IsOrdinateXTypeFlag",ee[ee.IsCustomTextPositionFlag=128]="IsCustomTextPositionFlag";(oe={})[oe.TopLeft=1]="TopLeft",oe[oe.TopCenter=2]="TopCenter",oe[oe.TopRight=3]="TopRight",oe[oe.MiddleLeft=4]="MiddleLeft",oe[oe.MiddleCenter=5]="MiddleCenter",oe[oe.MiddleRight=6]="MiddleRight",oe[oe.BottomLeft=7]="BottomLeft",oe[oe.BottomCenter=8]="BottomCenter",oe[oe.BottomRight=9]="BottomRight";(xs={})[xs.AtLeast=1]="AtLeast",xs[xs.Exact=2]="Exact";var vl=((ar={})[ar.Center=0]="Center",ar[ar.Above=1]="Above",ar[ar.Outside=2]="Outside",ar[ar.JIS=3]="JIS",ar[ar.Below=4]="Below",ar),Un=((Pe={})[Pe.Feet=0]="Feet",Pe[Pe.None=1]="None",Pe[Pe.Inch=2]="Inch",Pe[Pe.FeetAndInch=3]="FeetAndInch",Pe[Pe.Leading=4]="Leading",Pe[Pe.Trailing=8]="Trailing",Pe[Pe.LeadingAndTrailing=12]="LeadingAndTrailing",Pe),sd=((Ar={})[Ar.None=0]="None",Ar[Ar.Leading=1]="Leading",Ar[Ar.Trailing=2]="Trailing",Ar[Ar.LeadingAndTrailing=3]="LeadingAndTrailing",Ar),id=((or={})[or.Center=0]="Center",or[or.Left=1]="Left",or[or.Right=2]="Right",or[or.OverFirst=3]="OverFirst",or[or.OverSecond=4]="OverSecond",or),ad=((ln={})[ln.Bottom=0]="Bottom",ln[ln.Center=1]="Center",ln[ln.Top=2]="Top",ln),od=((ws={})[ws.PatternFill=0]="PatternFill",ws[ws.SolidFill=1]="SolidFill",ws);(As={})[As.NonAssociative=0]="NonAssociative",As[As.Associative=1]="Associative";(hn={})[hn.Normal=0]="Normal",hn[hn.Outer=1]="Outer",hn[hn.Ignore=2]="Ignore";(cn={})[cn.UserDefined=0]="UserDefined",cn[cn.Predefined=1]="Predefined",cn[cn.Custom=2]="Custom";(Ps={})[Ps.NotAnnotated=0]="NotAnnotated",Ps[Ps.Annotated=1]="Annotated";(Is={})[Is.Solid=0]="Solid",Is[Is.Gradient=1]="Gradient";(Ss={})[Ss.TwoColor=0]="TwoColor",Ss[Ss.OneColor=1]="OneColor";var ld=((Ue={})[Ue.Default=0]="Default",Ue[Ue.External=1]="External",Ue[Ue.Polyline=2]="Polyline",Ue[Ue.Derived=4]="Derived",Ue[Ue.Textbox=8]="Textbox",Ue[Ue.Outermost=16]="Outermost",Ue),oi=((Pr={})[Pr.Line=1]="Line",Pr[Pr.Circular=2]="Circular",Pr[Pr.Elliptic=3]="Elliptic",Pr[Pr.Spline=4]="Spline",Pr),hd=((Xt={})[Xt.Off=0]="Off",Xt[Xt.Solid=1]="Solid",Xt[Xt.Dashed=2]="Dashed",Xt[Xt.Dotted=3]="Dotted",Xt[Xt.ShotDash=4]="ShotDash",Xt[Xt.MediumDash=5]="MediumDash",Xt[Xt.LongDash=6]="LongDash",Xt[Xt.DoubleShortDash=7]="DoubleShortDash",Xt[Xt.DoubleMediumDash=8]="DoubleMediumDash",Xt[Xt.DoubleLongDash=9]="DoubleLongDash",Xt[Xt.DoubleMediumLongDash=10]="DoubleMediumLongDash",Xt[Xt.SparseDot=11]="SparseDot",Xt);hd.Off;(un={})[un.Standard=-3]="Standard",un[un.ByLayer=-2]="ByLayer",un[un.ByBlock=-1]="ByBlock";(Es={})[Es.English=0]="English",Es[Es.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";(Ie={})[Ie.OPTIMIZED_2D=0]="OPTIMIZED_2D",Ie[Ie.WIREFRAME=1]="WIREFRAME",Ie[Ie.HIDDEN_LINE=2]="HIDDEN_LINE",Ie[Ie.FLAT_SHADED=3]="FLAT_SHADED",Ie[Ie.GOURAUD_SHADED=4]="GOURAUD_SHADED",Ie[Ie.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",Ie[Ie.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME";(Ms={})[Ms.UCS_UNCHANGED=0]="UCS_UNCHANGED",Ms[Ms.HAS_OWN_UCS=1]="HAS_OWN_UCS";(Se={})[Se.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",Se[Se.TOP=1]="TOP",Se[Se.BOTTOM=2]="BOTTOM",Se[Se.FRONT=3]="FRONT",Se[Se.BACK=4]="BACK",Se[Se.LEFT=5]="LEFT",Se[Se.RIGHT=6]="RIGHT";(ks={})[ks.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",ks[ks.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS";(Ir={})[Ir.ByLayer=0]="ByLayer",Ir[Ir.ByBlock=1]="ByBlock",Ir[Ir.ByDictionaryDefault=2]="ByDictionaryDefault",Ir[Ir.ByObject=3]="ByObject";function It(i,t,e){return i.code===t&&(e==null||i.value===e)}function Rt(i){let t={};i.rewind();let e=i.next(),n=e.code;if(t.x=e.value,(e=i.next()).code!==n+10)throw Error("Expected code for point value to be 20 but got "+e.code+".");return t.y=e.value,(e=i.next()).code!==n+20?i.rewind():t.z=e.value,t}let no=Symbol();function xt(i,t){return(e,n,a)=>{let h=function(b,f=!1){return b.reduce((w,x)=>{x.pushContext&&w.push({});let S=w[w.length-1];for(let M of typeof x.code=="number"?[x.code]:x.code){let N=S[M]??(S[M]=[]);x.isMultiple&&N.length&&f&&console.warn(`Snippet ${N[N.length-1].name} for code(${M}) is shadowed by ${x.name}`),N.push(x)}return w},[{}])}(i,n.debug),c=!1,m=h.length-1;for(;!It(e,0,"EOF");){let b=function(F,D,at){return F.find((ft,st)=>{var H;return st>=at&&((H=ft[D])==null?void 0:H.length)})}(h,e.code,m),f=b==null?void 0:b[e.code],w=f==null?void 0:f[f.length-1];if(!b||!w){n.rewind();break}w.isMultiple||b[e.code].pop();let{name:x,parser:S,isMultiple:M,isReducible:N}=w,O=S==null?void 0:S(e,n,a);if(O===no){n.rewind();break}if(x){let[F,D]=function(at,ft){let st=ft.split(".");if(!st.length)throw Error("[parserGenerator::getObjectByPath] Invalid empty path");let H=at;for(let ut=0;ut<st.length-1;++ut){let it=Aa(st[ut]),Gt=Aa(st[ut+1]);Object.prototype.hasOwnProperty.call(H,it)||(typeof Gt=="number"?H[it]=[]:H[it]={}),H=H[it]}return[H,Aa(st[st.length-1])]}(a,x);M&&!N?(Object.prototype.hasOwnProperty.call(F,D)||(F[D]=[]),F[D].push(O)):F[D]=O}w.pushContext&&(m-=1),c=!0,e=n.next()}return t&&Object.setPrototypeOf(a,t),c}}function Aa(i){let t=Number.parseInt(i);return Number.isNaN(t)?i:t}function v({value:i}){return i}function W(i,t){return Rt(t)}function Vt({value:i}){return!!i}let cd=[{code:1001,name:"xdata",parser:zh}];function zh(i,t){var a;if(!It(i,1001))throw Error("XData must starts with code 1001");let e={appName:i.value,value:[]};i=t.next();let n=[e.value];for(;!It(i,0,"EOF")&&i.code>=1e3;){let h=n[n.length-1];switch(i.code){case 1002:i.value==="{"?n.push([]):(n.pop(),(a=n[n.length-1])==null||a.push(h));break;case 1e3:case 1004:case 1040:case 1070:case 1071:h.push({type:Br(i.code),value:i.value});break;case 1003:h.push({name:"layer",type:Br(i.code),value:i.value});break;case 1005:h.push({name:"handle",type:Br(i.code),value:i.value});break;case 1010:h.push({type:Br(i.code),value:Rt(t)});break;case 1011:h.push({name:"worldSpacePosition",type:Br(i.code),value:Rt(t)});break;case 1012:h.push({name:"worldSpaceDisplacement",type:Br(i.code),value:Rt(t)});break;case 1013:h.push({name:"worldSpaceDirection",type:Br(i.code),value:Rt(t)});break;case 1041:h.push({name:"distance",type:Br(i.code),value:i.value});break;case 1042:h.push({name:"scale",type:Br(i.code),value:i.value})}i=t.next()}return t.rewind(),e}function Br(i){switch(i){case 1e3:case 1003:case 1005:return"string";case 1004:return"hex";case 1040:case 1041:case 1042:return"real";case 1070:return"integer";case 1071:return"long";case 1010:case 1011:case 1012:case 1013:return"point";default:return""}}function xn(i,t,e){for(;It(i,102);){var n;let a=i.value;if(i=t.next(),!a.startsWith("{")){t.debug&&console.warn(`Invalid application group, expected to start with "{" but received: ${a}`),function(c,m){for(;!It(c,102)&&!It(c,0,"EOF");)c=m.next()}(i,t),i=t.next();continue}let h=a.slice(1).trim();e.extensions??(e.extensions={}),(n=e.extensions)[h]??(n[h]=[]),function(c,m,b){for(;!It(c,102,"}")&&!It(c,0,"EOF");)b.push(c),c=m.next()}(i,t,e.extensions[h]),i=t.next()}t.rewind()}let ud=0;function Rh(i){if(!i)throw TypeError("entity cannot be undefined or null");i.handle||(i.handle=ud++)}var dd=[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 Dh(i){return dd[i]}(Sr={})[Sr.CAST_AND_RECEIVE=0]="CAST_AND_RECEIVE",Sr[Sr.CAST=1]="CAST",Sr[Sr.RECEIVE=2]="RECEIVE",Sr[Sr.IGNORE=3]="IGNORE";let jt=[...cd,{code:284,name:"shadowMode",parser:v},{code:390,name:"plotStyleHardId",parser:v},{code:380,name:"plotStyleType",parser:v},{code:440,name:"transparency",parser:v},{code:430,name:"colorName",parser:v},{code:420,name:"color",parser:v},{code:310,name:"proxyEntity",isMultiple:!0,parser:v},{code:92,name:"proxyByte",parser:v},{code:60,name:"isVisible",parser:Vt},{code:48,name:"lineTypeScale",parser:v},{code:370,name:"lineweight",parser:v},{code:62,name:"colorIndex",parser(i,t,e){let n=i.value;return n>0&&n<256&&(e.color=Dh(Math.abs(n))),n}},{code:347,name:"materialObjectHardId",parser:v},{code:6,name:"lineType",parser:v},{code:8,name:"layer",parser:v},{code:410,name:"layoutTabName",parser:v},{code:67,name:"isInPaperSpace",parser:Vt},{code:100},{code:160},{code:330,name:"ownerBlockRecordSoftId",parser:v},{code:102,parser:xn},{code:102,parser:xn},{code:102,parser:xn},{code:5,name:"handle",parser:v}];function Ji(i){return[{code:3,name:i,parser:(t,e,n)=>(n._code3text=(n._code3text??"")+t.value,n._code3text+(n._code1text??"")),isMultiple:!0,isReducible:!0},{code:1,name:i,parser:(t,e,n)=>(n._code1text=t.value,(n._code3text??"")+n._code1text)}]}function Fh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let pd={extrusionDirection:{x:0,y:0,z:1}},md=[{code:210,name:"extrusionDirection",parser:W},{code:51,name:"endAngle",parser:v},{code:50,name:"startAngle",parser:v},{code:100,name:"subclassMarker",parser:v},{code:40,name:"radius",parser:v},{code:10,name:"center",parser:W},{code:39,name:"thickness",parser:v},{code:100},...jt];class Vh{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Fh(this,"parser",xt(md,pd))}}Fh(Vh,"ForEntityName","ARC");(lr={})[lr.NONE=0]="NONE",lr[lr.INVISIBLE=1]="INVISIBLE",lr[lr.CONSTANT=2]="CONSTANT",lr[lr.VERIFICATION_REQUIRED=4]="VERIFICATION_REQUIRED",lr[lr.PRESET=8]="PRESET";(Ts={})[Ts.MULTILINE=2]="MULTILINE",Ts[Ts.CONSTANT_MULTILINE=4]="CONSTANT_MULTILINE";(dn={})[dn.NONE=0]="NONE",dn[dn.MIRRORED_X=2]="MIRRORED_X",dn[dn.MIRRORED_Y=4]="MIRRORED_Y";var gd=((je={})[je.LEFT=0]="LEFT",je[je.CENTER=1]="CENTER",je[je.RIGHT=2]="RIGHT",je[je.ALIGNED=3]="ALIGNED",je[je.MIDDLE=4]="MIDDLE",je[je.FIT=5]="FIT",je),fd=((Er={})[Er.BASELINE=0]="BASELINE",Er[Er.BOTTOM=1]="BOTTOM",Er[Er.MIDDLE=2]="MIDDLE",Er[Er.TOP=3]="TOP",Er);function Uh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let jh={thickness:0,rotation:0,xScale:1,obliqueAngle:0,styleName:"STANDARD",generationFlag:0,halign:gd.LEFT,valign:fd.BASELINE,extrusionDirection:{x:0,y:0,z:1}},Gh=[{code:73,name:"valign",parser:v},{code:100},{code:210,name:"extrusionDirection",parser:W},{code:11,name:"endPoint",parser:W},{code:72,name:"valign",parser:v},{code:72,name:"halign",parser:v},{code:71,name:"generationFlag",parser:v},{code:7,name:"styleName",parser:v},{code:51,name:"obliqueAngle",parser:v},{code:41,name:"xScale",parser:v},{code:50,name:"rotation",parser:v},{code:1,name:"text",parser:v},{code:40,name:"textHeight",parser:v},{code:10,name:"startPoint",parser:W},{code:39,name:"thickness",parser:v},{code:100,name:"subclassMarker",parser:v},...jt];class Wh{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Uh(this,"parser",xt(Gh,jh))}}function Hh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Uh(Wh,"ForEntityName","TEXT");let _d={...jh},yd=[{code:2},{code:40,name:"annotationScale",parser:v},{code:10,name:"alignmentPoint",parser:W},{code:340,name:"secondaryAttributesHardIds",isMultiple:!0,parser:v},{code:70,name:"numberOfSecondaryAttributes",parser:v},{code:70,name:"isReallyLocked",parser:Vt},{code:70,name:"mtextFlag",parser:v},{code:280,name:"isDuplicatedRecord",parser:Vt},{code:100},{code:280,name:"isLocked",parser:Vt},{code:74,name:"valign",parser:v},{code:73},{code:70,name:"attributeFlag",parser:v},{code:2,name:"tag",parser:v},{code:3,name:"prompt",parser:v},{code:280},{code:100,name:"subclassMarker",parser:v},...Gh.slice(2)];class qh{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Hh(this,"parser",xt(yd,_d))}}Hh(qh,"ForEntityName","ATTDEF");(pn={})[pn.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",pn[pn.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",pn[pn.BY_STYLE=5]="BY_STYLE";function vd(i,t){let e={};for(let n of i){let a=t(n);a!=null&&(e[a]??(e[a]=[]),e[a].push(n))}return e}function*Vi(i,t=1/0,e=1){for(let n=i;n!==t;n+=e)yield n}function Zr(i){return{x:i.x??0,y:i.y??0,z:i.z??0}}function so(i,t,e){if(It(t,102))return xn(t,e,i),!0;switch(t.code){case 0:i.type=t.value;break;case 5:i.handle=t.value;break;case 330:i.ownerBlockRecordSoftId=t.value;break;case 67:i.isInPaperSpace=!!t.value;break;case 8:i.layer=t.value;break;case 6:i.lineType=t.value;break;case 347:i.materialObjectHardId=t.value;break;case 62:i.colorIndex=t.value,i.color=Dh(Math.abs(t.value));break;case 370:i.lineweight=t.value;break;case 48:i.lineTypeScale=t.value;break;case 60:i.isVisible=!!t.value;break;case 92:i.proxyByte=t.value;break;case 310:i.proxyEntity=t.value;break;case 100:break;case 420:i.color=t.value;break;case 430:i.transparency=t.value;break;case 390:i.plotStyleHardId=t.value;break;case 284:i.shadowMode=t.value;break;case 1001:i.xdata=zh(t,e);break;default:return!1}return!0}function Yh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let bd={textStyle:"STANDARD",extrusionDirection:{x:0,y:0,z:1},rotation:0},ui=[{code:46,name:"annotationHeight",parser:v},{code:101,parser(i,t){(function(e){e.rewind();let n=e.next();if(n.code!==101)throw Error("Bad call for skipEmbeddedObject()");do n=e.next();while(n.code!==0);e.rewind()})(t)}},{code:50,name:"columnHeight",parser:v},{code:49,name:"columnGutter",parser:v},{code:48,name:"columnWidth",parser:v},{code:79,name:"columnAutoHeight",parser:v},{code:78,name:"columnFlowReversed",parser:v},{code:76,name:"columnCount",parser:v},{code:75,name:"columnType",parser:v},{code:441,name:"backgroundFillTransparency",parser:v},{code:63,name:"backgroundFillColor",parser:v},{code:45,name:"fillBoxScale",parser:v},{code:[...Vi(430,440)],name:"backgroundColor",parser:v},{code:[...Vi(420,430)],name:"backgroundColor",parser:v},{code:90,name:"backgroundFill",parser:v},{code:44,name:"lineSpacing",parser:v},{code:73,name:"lineSpacingStyle",parser:v},{code:50,name:"rotation",parser:v},{code:43},{code:42},{code:11,name:"direction",parser:W},{code:210,name:"extrusionDirection",parser:W},{code:7,name:"styleName",parser:v},...Ji("text"),{code:72,name:"drawingDirection",parser:v},{code:71,name:"attachmentPoint",parser:v},{code:41,name:"width",parser:v},{code:40,name:"height",parser:v},{code:10,name:"insertionPoint",parser:W},{code:100,name:"subclassMarker",parser:v},...jt];class Xh{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Yh(this,"parser",xt(ui,bd))}}function Kh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Yh(Xh,"ForEntityName","MTEXT");let xd={thickness:0,rotation:0,scale:1,obliqueAngle:0,textStyle:"STANDARD",textGenerationFlag:0,horizontalJustification:0,verticalJustification:0,extrusionDirection:{x:0,y:0,z:1}},wd=[...ui.slice(ui.findIndex(({name:i})=>i==="columnType"),ui.findIndex(({name:i})=>i==="subclassMarker")+1),{code:100},{code:0,parser(i){if(!It(i,0,"MTEXT"))return no}},{code:2,name:"definitionTag",parser:v},{code:40,name:"annotationScale",parser:v},{code:10,name:"alignmentPoint",parser:W},{code:340,name:"secondaryAttributesHardId",parser:v},{code:70,name:"numberOfSecondaryAttributes",parser:v},{code:70,name:"isReallyLocked",parser:Vt},{code:70,name:"mtextFlag",parser:v},{code:280,name:"isDuplicatedEntriesKeep",parser:Vt},{code:100},{code:280,name:"lockPositionFlag",parser:Vt},{code:210,name:"extrusionDirection",parser:W},{code:11,name:"alignmentPoint",parser:W},{code:74,name:"verticalJustification",parser:v},{code:72,name:"horizontalJustification",parser:v},{code:71,name:"textGenerationFlag",parser:v},{code:7,name:"textStyle",parser:v},{code:51,name:"obliqueAngle",parser:v},{code:41,name:"scale",parser:v},{code:50,name:"rotation",parser:v},{code:73},{code:70,name:"attributeFlag",parser:v},{code:2,name:"tag",parser:v},{code:280},{code:100,name:"subclassMarker",parser:v},{code:1,name:"text",parser:v},{code:40,name:"textHeight",parser:v},{code:10,name:"startPoint",parser:W},{code:39,name:"thickness",parser:v},{code:100},...jt];class $h{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Kh(this,"parser",xt(wd,xd))}}function Zh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Kh($h,"ForEntityName","ATTRIB");let Ad=[...Ji("data"),{code:70,name:"version",parser:v},{code:100,name:"subclassMarker",parser:v},...jt];class Qh{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Zh(this,"parser",xt(Ad))}}function Jh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Zh(Qh,"ForEntityName","BODY");let Pd={thickness:0,extrusionDirection:{x:0,y:0,z:1}},Id=[{code:210,name:"extrusionDirection",parser:W},{code:40,name:"radius",parser:v},{code:10,name:"center",parser:W},{code:39,name:"thickness",parser:v},{code:100,name:"subclassMarker",parser:v},...jt];class tc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Jh(this,"parser",xt(Id,Pd))}}Jh(tc,"ForEntityName","CIRCLE");class di{parseEntity(t,e){let n={};for(;!It(e,0,"EOF");){if(e.code===0){t.rewind();break}(function(a,h,c){switch(h.code){case 100:a.subclassMarker=h.value;break;case 280:a.version=h.value;break;case 2:a.name=h.value;break;case 10:a.definitionPoint=Rt(c);break;case 11:a.textPoint=Rt(c);break;case 12:a.insertionPoint=Rt(c);break;case 13:a.subDefinitionPoint1=Rt(c);break;case 14:a.subDefinitionPoint2=Rt(c);break;case 15:a.centerPoint=Rt(c);break;case 16:a.arcPoint=Rt(c);break;case 70:a.dimensionType=h.value;break;case 71:a.attachmentPoint=h.value;break;case 72:a.textLineSpacingStyle=h.value;break;case 40:a.leaderLength=h.value;break;case 41:a.textLineSpacingFactor=h.value;break;case 42:a.measurement=h.value;break;case 1:a.text=h.value;break;case 50:a.rotationAngle=h.value;break;case 52:a.obliqueAngle=h.value;break;case 53:a.textRotation=h.value;break;case 51:a.ocsRotation=h.value;break;case 210:a.extrusionDirection=Rt(c);break;case 3:a.styleName=h.value;break;default:so(a,h,c)}})(n,e,t),e=t.next()}return n}}function ec(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}fa="DIMENSION",(ga="ForEntityName")in di?Object.defineProperty(di,ga,{value:fa,enumerable:!0,configurable:!0,writable:!0}):di[ga]=fa;let Sd={extrusionDirection:{x:0,y:0,z:1}},Ed=[{code:42,name:"endAngle",parser:v},{code:41,name:"startAngle",parser:v},{code:40,name:"axisRatio",parser:v},{code:210,name:"extrusionDirection",parser:W},{code:11,name:"majorAxisEndPoint",parser:W},{code:10,name:"center",parser:W},{code:100,name:"subclassMarker",parser:v},...jt];class rc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){ec(this,"parser",xt(Ed,Sd))}}ec(rc,"ForEntityName","ELLIPSE");(Mr={})[Mr.First=1]="First",Mr[Mr.Second=2]="Second",Mr[Mr.Third=4]="Third",Mr[Mr.Fourth=8]="Fourth";function nc(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Md=[{code:13,name:"vertices.3",parser:W},{code:12,name:"vertices.2",parser:W},{code:11,name:"vertices.1",parser:W},{code:10,name:"vertices.0",parser:W},{code:100,name:"subclassMarker",parser:v},...jt];class sc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){nc(this,"parser",xt(Md))}}nc(sc,"ForEntityName","3DFACE");let ic=[{code:330,name:"sourceBoundaryObjects",parser:v,isMultiple:!0},{code:97,name:"numberOfSourceBoundaryObjects",parser:v}],kd=[{code:11,name:"end",parser:W},{code:10,name:"start",parser:W}],Td=[{code:73,name:"isCCW",parser:Vt},{code:51,name:"endAngle",parser:v},{code:50,name:"startAngle",parser:v},{code:40,name:"radius",parser:v},{code:10,name:"center",parser:W}],Cd=[{code:73,name:"isCCW",parser:Vt},{code:51,name:"endAngle",parser:v},{code:50,name:"startAngle",parser:v},{code:40,name:"lengthOfMinorAxis",parser:v},{code:11,name:"end",parser:W},{code:10,name:"center",parser:W}],Nd=[{code:13,name:"endTangent",parser:W},{code:12,name:"startTangent",parser:W},{code:11,name:"fitDatum",isMultiple:!0,parser:W},{code:97,name:"numberOfFitData",parser:v},{code:10,name:"controlPoints",isMultiple:!0,parser(i,t){let e={...Rt(t),weight:1};return(i=t.next()).code===42?e.weight=i.value:t.rewind(),e}},{code:40,name:"knots",isMultiple:!0,parser:v},{code:96,name:"numberOfControlPoints",parser:v},{code:95,name:"numberOfKnots",parser:v},{code:74,name:"isPeriodic",parser:Vt},{code:73,name:"splineFlag",parser:v},{code:94,name:"degree",parser:v}],Ld={[oi.Line]:kd,[oi.Circular]:Td,[oi.Elliptic]:Cd,[oi.Spline]:Nd},Od=[...ic,{code:72,name:"edges",parser(i,t){let e={type:i.value},n=xt(Ld[e.type]);if(!n)throw Error(`Invalid edge type ${e.type}`);return n(i=t.next(),t,e),e},isMultiple:!0},{code:93,name:"numberOfEdges",parser:v}],Bd=[...ic,{code:10,name:"vertices",parser(i,t){let e={...Rt(t),bulge:0};return(i=t.next()).code===42?e.bulge=i.value:t.rewind(),e},isMultiple:!0},{code:93,name:"numberOfVertices",parser:v},{code:73,name:"isClosed",parser:Vt},{code:72,name:"hasBulge",parser:Vt}],zd=[{code:49,name:"dashLengths",parser:v,isMultiple:!0},{code:79,name:"numberOfDashLengths",parser:v},{code:45,name:"offset",parser:bl},{code:43,name:"base",parser:bl},{code:53,name:"angle",parser:v}];function bl(i,t){let e=i.code+1,n={x:i.value,y:1};return(i=t.next()).code===e?n.y=i.value:t.rewind(),n}function ac(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Rd={extrusionDirection:{x:0,y:0,z:1},gradientRotation:0,colorTint:0},Dd=[{code:470},{code:463},{code:462,name:"colorTint",parser:v},{code:461,name:"gradientDefinition",parser:v},{code:460,name:"gradientRotation",parser:v},{code:453,name:"numberOfColors",parser:v},{code:452,name:"gradientColorFlag",parser:v},{code:451},{code:450,name:"gradientFlag",parser:v},{code:10,name:"seedPoints",parser:W,isMultiple:!0},{code:99},{code:11,name:"offsetVector",parser:W},{code:98,name:"numberOfSeedPoints",parser:v},{code:47,name:"pixelSize",parser:v},{code:53,name:"definitionLines",parser:function(i,t){let e={};return xt(zd)(i,t,e),e},isMultiple:!0},{code:78,name:"numberOfDefinitionLines",parser:v},{code:77,name:"isDouble",parser:Vt},{code:73,name:"isAnnotated",parser:Vt},{code:41,name:"patternScale",parser:v},{code:52,name:"patternAngle",parser:v},{code:76,name:"patternType",parser:v},{code:75,name:"hatchStyle",parser:v},{code:92,name:"boundaryPaths",parser:function(i,t){let e={boundaryPathTypeFlag:i.value},n=e.boundaryPathTypeFlag&ld.Polyline;return i=t.next(),n?xt(Bd)(i,t,e):xt(Od)(i,t,e),e},isMultiple:!0},{code:91,name:"numberOfBoundaryPaths",parser:v},{code:71,name:"associativity",parser:v},{code:63,name:"patternFillColor",parser:v},{code:70,name:"solidFill",parser:v},{code:2,name:"patternName",parser:v},{code:210,name:"extrusionDirection",parser:W},{code:10,name:"elevationPoint",parser:W},{code:100,name:"subclassMarker",parser:v,pushContext:!0},...jt];class oc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){ac(this,"parser",xt(Dd,Rd))}}ac(oc,"ForEntityName","HATCH");(kr={})[kr.ShowImage=1]="ShowImage",kr[kr.ShowImageWhenNotAlignedWithScreen=2]="ShowImageWhenNotAlignedWithScreen",kr[kr.UseClippingBoundary=4]="UseClippingBoundary",kr[kr.TransparencyIsOn=8]="TransparencyIsOn";(Cs={})[Cs.Rectangular=1]="Rectangular",Cs[Cs.Polygonal=2]="Polygonal";(Ns={})[Ns.Outside=0]="Outside",Ns[Ns.Inside=1]="Inside";function lc(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Fd={brightness:50,contrast:50,fade:0,clippingBoundaryPath:[]},Vd=[{code:290,name:"clipMode",parser:v},{code:14,name:"clippingBoundaryPath",isMultiple:!0,parser:W},{code:91,name:"countBoundaryPoints",parser:v},{code:71,name:"clippingBoundaryType",parser:v},{code:360,name:"imageDefReactorHandle",parser:v},{code:283,name:"fade",parser:v},{code:282,name:"contrast",parser:v},{code:281,name:"brightness",parser:v},{code:280,name:"isClipped",parser:Vt},{code:70,name:"flags",parser:v},{code:340,name:"imageDefHandle",parser:v},{code:13,name:"imageSize",parser:W},{code:12,name:"vPixel",parser:W},{code:11,name:"uPixel",parser:W},{code:10,name:"position",parser:W},{code:90,name:"version",parser:v},{code:100,name:"subclassMarker",parser:v},...jt];class hc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){lc(this,"parser",xt(Vd,Fd))}}function cc(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}lc(hc,"ForEntityName","IMAGE");let Ud={xScale:1,yScale:1,zScale:1,rotation:0,columnCount:0,rowCount:0,columnSpacing:0,rowSpacing:0,extrusionDirection:{x:0,y:0,z:1}},jd=[{code:210,name:"extrusionDirection",parser:W},{code:45,name:"rowSpacing",parser:v},{code:44,name:"columnSpacing",parser:v},{code:71,name:"rowCount",parser:v},{code:70,name:"columnCount",parser:v},{code:50,name:"rotation",parser:v},{code:43,name:"zScale",parser:v},{code:42,name:"yScale",parser:v},{code:41,name:"xScale",parser:v},{code:10,name:"insertionPoint",parser:W},{code:2,name:"name",parser:v},{code:66,name:"isVariableAttributes",parser:Vt},{code:100,name:"subclassMarker",parser:v},...jt];class uc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){cc(this,"parser",xt(jd,Ud))}}function dc(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}cc(uc,"ForEntityName","INSERT");let Gd={isArrowheadEnabled:!0},Wd=[{code:213,name:"offsetFromAnnotation",parser:W},{code:212,name:"offsetFromBlock",parser:W},{code:211,name:"horizontalDirection",parser:W},{code:210,name:"normal",parser:W},{code:340,name:"associatedAnnotation",parser:v},{code:77,name:"byBlockColor",parser:v},{code:10,name:"vertices",parser:W,isMultiple:!0},{code:76,name:"numberOfVertices",parser:v},{code:41,name:"textWidth",parser:v},{code:40,name:"textHeight",parser:v},{code:75,name:"isHooklineExists",parser:Vt},{code:74,name:"isHooklineSameDirection",parser:Vt},{code:73,name:"leaderCreationFlag",parser:v},{code:72,name:"isSpline",parser:Vt},{code:71,name:"isArrowheadEnabled",parser:Vt},{code:3,name:"styleName",parser:v},{code:100,name:"subclassMarker",parser:v},...jt];class pc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){dc(this,"parser",xt(Wd,Gd))}}dc(pc,"ForEntityName","LEADER");(Tr={})[Tr.TextAnnotation=0]="TextAnnotation",Tr[Tr.ToleranceAnnotation=1]="ToleranceAnnotation",Tr[Tr.BlockReferenceAnnotation=2]="BlockReferenceAnnotation",Tr[Tr.NoAnnotation=3]="NoAnnotation";function mc(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Hd={thickness:0,extrusionDirection:{x:0,y:0,z:1}},qd=[{code:210,name:"extrusionDirection",parser:W},{code:11,name:"endPoint",parser:W},{code:10,name:"startPoint",parser:W},{code:39,name:"thickness",parser:v},{code:100,name:"subclassMarker",parser:v},...jt];class gc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){mc(this,"parser",xt(qd,Hd))}}mc(gc,"ForEntityName","LINE");(Ls={})[Ls.IS_CLOSED=1]="IS_CLOSED",Ls[Ls.PLINE_GEN=128]="PLINE_GEN";let Yd={flag:0,elevation:0,thickness:0,extrusionDirection:{x:0,y:0,z:1},vertices:[]},Xd={bulge:0},Kd=[{code:42,name:"bulge",parser:v},{code:41,name:"endWidth",parser:v},{code:40,name:"startWidth",parser:v},{code:91,name:"id",parser:v},{code:20,name:"y",parser:v},{code:10,name:"x",parser:v}],$d=[{code:210,name:"extrusionDirection",parser:W},{code:10,name:"vertices",isMultiple:!0,parser(i,t){let e={};return xt(Kd,Xd)(i,t,e),e}},{code:39,name:"thickness",parser:v},{code:38,name:"elevation",parser:v},{code:43,name:"constantWidth",parser:v},{code:70,name:"flag",parser:v},{code:90,name:"numberOfVertices",parser:v},{code:100,name:"subclassMarker",parser:v},...jt];class pi{parseEntity(t,e){let n={};return xt($d,Yd)(e,t,n),n}}function fc(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}ya="LWPOLYLINE",(_a="ForEntityName")in pi?Object.defineProperty(pi,_a,{value:ya,enumerable:!0,configurable:!0,writable:!0}):pi[_a]=ya;let Zd=[{code:90,name:"overridenSubEntityCount",parser:v},{code:140,name:"edgeCreaseWeights",parser:v,isMultiple:!0},{code:95,name:"edgeCreaseCount",parser:v},{code:94,parser(i,t,e){e.edgeCount=i.value,e.edgeIndices=[];for(let n=0;n<e.edgeCount;++n){let a=[];i=t.next(),a[0]=i.value,i=t.next(),a[1]=i.value,e.edgeIndices.push(a)}}},{code:93,parser(i,t,e){e.totalFaceIndices=i.value,e.faceIndices=[];let n=[];for(let h=0;h<e.totalFaceIndices&&!It(i,0);++h)i=t.next(),n.push(i.value);let a=0;for(;a<n.length;){let h=n[a++],c=[];for(let m=0;m<h;++m)c.push(n[a++]);e.faceIndices.push(c)}}},{code:10,name:"vertices",parser:W,isMultiple:!0},{code:92,name:"verticesCount",parser:v},{code:91,name:"subdivisionLevel",parser:v},{code:40,name:"blendCrease",parser:v},{code:72,name:"isBlendCreased",parser:Vt},{code:71,name:"version",parser:v},{code:100,name:"subclassMarker",parser:function({value:i}){return i.trim()},pushContext:!0},...jt];class _c{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){fc(this,"parser",xt(Zd))}}function yc(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}fc(_c,"ForEntityName","MESH");let Qd={thickness:0,extrusionDirection:{x:0,y:0,z:1},angle:0},Jd=[{code:50,name:"angle",parser:v},{code:210,name:"extrusionDirection",parser:W},{code:39,name:"thickness",parser:v},{code:10,name:"position",parser:W},{code:100,name:"subclassMarker",parser:v},...jt];class vc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){yc(this,"parser",xt(Jd,Qd))}}yc(vc,"ForEntityName","POINT");(me={})[me.CLOSED_POLYLINE=1]="CLOSED_POLYLINE",me[me.CURVE_FIT=2]="CURVE_FIT",me[me.SPLINE_FIT=4]="SPLINE_FIT",me[me.POLYLINE_3D=8]="POLYLINE_3D",me[me.POLYGON_3D=16]="POLYGON_3D",me[me.CLOSED_POLYGON=32]="CLOSED_POLYGON",me[me.POLYFACE=64]="POLYFACE",me[me.CONTINUOUS=128]="CONTINUOUS";var li=((Cr={})[Cr.NONE=0]="NONE",Cr[Cr.QUADRATIC=5]="QUADRATIC",Cr[Cr.CUBIC=6]="CUBIC",Cr[Cr.BEZIER=8]="BEZIER",Cr),t0=((ge={})[ge.CREATED_BY_CURVE_FIT=1]="CREATED_BY_CURVE_FIT",ge[ge.TANGENT_DEFINED=2]="TANGENT_DEFINED",ge[ge.NOT_USED=4]="NOT_USED",ge[ge.CREATED_BY_SPLINE_FIT=8]="CREATED_BY_SPLINE_FIT",ge[ge.SPLINE_CONTROL_POINT=16]="SPLINE_CONTROL_POINT",ge[ge.FOR_POLYLINE=32]="FOR_POLYLINE",ge[ge.FOR_POLYGON=64]="FOR_POLYGON",ge[ge.POLYFACE=128]="POLYFACE",ge);function bc(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let e0={startWidth:0,endWidth:0,bulge:0},r0=[{code:91,name:"id",parser:v},{code:[...Vi(71,75)],name:"faces",isMultiple:!0,parser:v},{code:50,name:"tangentDirection",parser:v},{code:70,name:"flag",parser:v},{code:42,name:"bulge",parser:v},{code:41,name:"endWidth",parser:v},{code:40,name:"startWidth",parser:v},{code:30,name:"z",parser:v},{code:20,name:"y",parser:v},{code:10,name:"x",parser:v},{code:100,name:"subclassMarker",parser:v},{code:100},...jt];class io{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){bc(this,"parser",xt(r0,e0))}}function xc(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}bc(io,"ForEntityName","VERTEX");let n0={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:[]},s0=[{code:0,name:"vertices",isMultiple:!0,parser:(i,t)=>It(i,0,"VERTEX")?(i=t.next(),new io().parseEntity(t,i)):no},{code:210,name:"extrusionDirection",parser:W},{code:75,name:"smoothType",parser:v},{code:74,name:"surfaceNDensity",parser:v},{code:73,name:"surfaceMDensity",parser:v},{code:72,name:"meshNVertexCount",parser:v},{code:71,name:"meshMVertexCount",parser:v},{code:41,name:"endWidth",parser:v},{code:40,name:"startWidth",parser:v},{code:70,name:"flag",parser:v},{code:39,name:"thickness",parser:v},{code:30,name:"elevation",parser:v},{code:20},{code:10},{code:66},{code:100,name:"subclassMarker",parser:v},...jt];class wc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){xc(this,"parser",xt(s0,n0))}}function Ac(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}xc(wc,"ForEntityName","POLYLINE");let i0=[{code:11,name:"direction",parser:W},{code:10,name:"position",parser:W},{code:100,name:"subclassMarker",parser:v},...jt];class Pc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Ac(this,"parser",xt(i0))}}function Ic(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Ac(Pc,"ForEntityName","RAY");let a0=[...Ji("data"),{code:70,name:"version",parser:v},{code:100,name:"subclassMarker",parser:v},...jt];class Sc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Ic(this,"parser",xt(a0))}}function Ec(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Ic(Sc,"ForEntityName","REGION");let o0={vertices:[],backLineVertices:[]},l0=[{code:360,name:"geometrySettingHardId",parser:v},{code:12,name:"backLineVertices",isMultiple:!0,parser:W},{code:93,name:"numberOfBackLineVertices",parser:v},{code:11,name:"vertices",isMultiple:!0,parser:W},{code:92,name:"verticesCount",parser:v},{code:[63,411],name:"indicatorColor",parser:v},{code:70,name:"indicatorTransparency",parser:v},{code:41,name:"bottomHeight",parser:v},{code:40,name:"topHeight",parser:v},{code:10,name:"verticalDirection",parser:W},{code:1,name:"name",parser:v},{code:91,name:"flag",parser:v},{code:90,name:"state",parser:v},{code:100,name:"subclassMarker",parser:v},...jt];class Mc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Ec(this,"parser",xt(l0,o0))}}function kc(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Ec(Mc,"ForEntityName","SECTION");let h0={points:[],thickness:0,extrusionDirection:{x:0,y:0,z:1}},c0=[{code:210,name:"extrusionDirection",parser:W},{code:39,name:"thickness",parser:v},{code:[...Vi(10,14)],name:"points",isMultiple:!0,parser:W},{code:100,name:"subclassMarker",parser:v},...jt];class Tc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){kc(this,"parser",xt(c0,h0))}}function Cc(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}kc(Tc,"ForEntityName","SOLID");let u0=[{code:350,name:"historyObjectSoftId",parser:v},{code:100,name:"subclassMarker",parser:v},...Ji("data"),{code:70,name:"version",parser:v},{code:100},...jt];class Nc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Cc(this,"parser",xt(u0))}}Cc(Nc,"ForEntityName","3DSOLID");(Ge={})[Ge.NONE=0]="NONE",Ge[Ge.CLOSED=1]="CLOSED",Ge[Ge.PERIODIC=2]="PERIODIC",Ge[Ge.RATIONAL=4]="RATIONAL",Ge[Ge.PLANAR=8]="PLANAR",Ge[Ge.LINEAR=16]="LINEAR";function Lc(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let d0={knotTolerance:1e-6,controlTolerance:1e-6,fitTolerance:1e-9,knotValues:[],controlPoints:[],fitPoints:[]},p0=[{code:11,name:"fitPoints",isMultiple:!0,parser:W},{code:10,name:"controlPoints",isMultiple:!0,parser:W},{code:41,name:"weights",isMultiple:!0,parser:v},{code:40,name:"knots",isMultiple:!0,parser:v},{code:13,name:"endTangent",parser:W},{code:12,name:"startTangent",parser:W},{code:44,name:"fitTolerance",parser:v},{code:43,name:"controlTolerance",parser:v},{code:42,name:"knotTolerance",parser:v},{code:74,name:"numberOfFitPoints",parser:v},{code:73,name:"numberOfControlPoints",parser:v},{code:72,name:"numberOfKnots",parser:v},{code:71,name:"degree",parser:v},{code:70,name:"flag",parser:v},{code:210,name:"normal",parser:W},{code:100,name:"subclassMarker",parser:v},...jt];class Oc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Lc(this,"parser",xt(p0,d0))}}Lc(Oc,"ForEntityName","SPLINE");class mi{parseEntity(t,e){let n={};for(;!t.isEOF();){if(e.code===0){t.rewind();break}switch(e.code){case 100:n.subclassMarker=e.value,e=t.next();break;case 2:n.name=e.value,e=t.next();break;case 5:n.handle=e.value,e=t.next();break;case 10:n.startPoint=Zr(Rt(t)),e=t.lastReadGroup;break;case 11:n.directionVector=Zr(Rt(t)),e=t.lastReadGroup;break;case 90:n.tableValue=e.value,e=t.next();break;case 91:n.rowCount=e.value,e=t.next();break;case 92:n.columnCount=e.value,e=t.next();break;case 93:n.overrideFlag=e.value,e=t.next();break;case 94:n.borderColorOverrideFlag=e.value,e=t.next();break;case 95:n.borderLineWeightOverrideFlag=e.value,e=t.next();break;case 96:n.borderVisibilityOverrideFlag=e.value,e=t.next();break;case 141:n.rowHeightArr??(n.rowHeightArr=[]),n.rowHeightArr.push(e.value),e=t.next();break;case 142:n.columnWidthArr??(n.columnWidthArr=[]),n.columnWidthArr.push(e.value),e=t.next();break;case 280:n.version=e.value,e=t.next();break;case 310:n.bmpPreview??(n.bmpPreview=""),n.bmpPreview+=e.value,e=t.next();break;case 330:n.ownerDictionaryId=e.value,e=t.next();break;case 342:n.tableStyleId=e.value,e=t.next();break;case 343:n.blockRecordHandle=e.value,e=t.next();break;case 170:n.attachmentPoint=e.value,e=t.next();break;case 171:n.cells??(n.cells=[]),n.cells.push(function(a,h){let c=!1,m=!1,b={};for(;!a.isEOF()&&h.code!==0&&!m;)switch(h.code){case 171:if(c){m=!0;continue}b.cellType=h.value,c=!0,h=a.next();break;case 172:b.flagValue=h.value,h=a.next();break;case 173:b.mergedValue=h.value,h=a.next();break;case 174:b.autoFit=h.value,h=a.next();break;case 175:b.borderWidth=h.value,h=a.next();break;case 176:b.borderHeight=h.value,h=a.next();break;case 91:b.overrideFlag=h.value,h=a.next();break;case 178:b.virtualEdgeFlag=h.value,h=a.next();break;case 145:b.rotation=h.value,h=a.next();break;case 345:b.fieldObjetId=h.value,h=a.next();break;case 340:b.blockTableRecordId=h.value,h=a.next();break;case 146:b.blockScale=h.value,h=a.next();break;case 177:b.blockAttrNum=h.value,h=a.next();break;case 7:b.textStyle=h.value,h=a.next();break;case 140:b.textHeight=h.value,h=a.next();break;case 170:b.attachmentPoint=h.value,h=a.next();break;case 92:b.extendedCellFlags=h.value,h=a.next();break;case 285:b.rightBorderVisibility=!!(h.value??!0),h=a.next();break;case 286:b.bottomBorderVisibility=!!(h.value??!0),h=a.next();break;case 288:b.leftBorderVisibility=!!(h.value??!0),h=a.next();break;case 289:b.topBorderVisibility=!!(h.value??!0),h=a.next();break;case 301:(function(f,w,x){for(;x.code!==304;)switch(x.code){case 301:case 93:case 90:case 94:x=w.next();break;case 1:f.text=x.value,x=w.next();break;case 300:f.attrText=x.value,x=w.next();break;case 302:f.text=x.value?x.value:f.text,x=w.next();break;default:console.log(`Ignore code: ${x.code}, value: ${x.value}`),x=w.next()}})(b,a,h),h=a.next();break;default:return b}return c=!1,m=!1,b}(t,e)),e=t.lastReadGroup;break;default:so(n,e,t),e=t.next()}}return n}}function Bc(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}ba="ACAD_TABLE",(va="ForEntityName")in mi?Object.defineProperty(mi,va,{value:ba,enumerable:!0,configurable:!0,writable:!0}):mi[va]=ba;let m0=[{code:11,name:"xAxisDirection",parser:W},{code:210,name:"extrusionDirection",parser:W},{code:1,name:"text",parser:v},{code:10,name:"position",parser:W},{code:3,name:"styleName",parser:v},{code:100,name:"subclassMarker",parser:v},...jt];class zc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Bc(this,"parser",xt(m0))}}Bc(zc,"ForEntityName","TOLERANCE");class gi{parseEntity(t,e){let n={};for(;e!=="EOF";){if(e.code===0){t.rewind();break}!function(a,h,c){if(c==="EOF")return!1;switch(c.code){case 0:return!1;case 8:a.layer=c.value;break;case 100:a.subclassMarker=c.value;break;case 10:a.viewportCenter=Zr(Rt(h));break;case 40:a.width=c.value;break;case 41:a.height=c.value;break;case 68:a.status=c.value;break;case 69:a.viewportId=c.value;break;case 12:a.displayCenter=Rt(h);break;case 13:a.snapBase=Rt(h);break;case 14:a.snapSpacing=Rt(h);break;case 15:a.gridSpacing=Rt(h);break;case 16:a.viewDirection=Zr(Rt(h));break;case 17:a.targetPoint=Zr(Rt(h));break;case 42:a.perspectiveLensLength=c.value;break;case 43:a.frontClipZ=c.value;break;case 44:a.backClipZ=c.value;break;case 45:a.viewHeight=c.value;break;case 50:a.snapAngle=c.value;break;case 51:a.viewTwistAngle=c.value;break;case 72:a.circleZoomPercent=c.value;break;case 331:a.frozenLayerIds??(a.frozenLayerIds=[]),a.frozenLayerIds.push(c.value);break;case 90:a.statusBitFlags=c.value;break;case 340:a.clippingBoundaryId=c.value;break;case 1:a.sheetName=c.value;break;case 281:a.renderMode=c.value;break;case 71:a.ucsPerViewport=c.value;break;case 110:a.ucsOrigin=Zr(Rt(h));break;case 111:a.ucsXAxis=Zr(Rt(h));break;case 112:a.ucsYAxis=Zr(Rt(h));break;case 345:a.ucsId=c.value;break;case 346:a.ucsBaseId=c.value;break;case 79:a.orthographicType=c.value;break;case 146:a.elevation=c.value;break;case 170:a.shadePlotMode=c.value;break;case 61:a.majorGridFrequency=c.value;break;case 332:a.backgroundId=c.value;break;case 333:a.shadePlotId=c.value;break;case 348:a.visualStyleId=c.value;break;case 292:a.isDefaultLighting=!!c.value;break;case 282:a.defaultLightingType=c.value;break;case 141:a.brightness=c.value;break;case 142:a.contrast=c.value;break;case 63:case 421:case 431:a.ambientLightColor=c.value;break;case 361:a.sunId=c.value;break;case 335:case 343:case 344:case 91:a.softPointer=c.value}return!0}(n,t,e)&&so(n,e,t),e=t.next()}return n}}wa="VIEWPORT",(xa="ForEntityName")in gi?Object.defineProperty(gi,xa,{value:wa,enumerable:!0,configurable:!0,writable:!0}):gi[xa]=wa;(Nr={})[Nr.ShowImage=1]="ShowImage",Nr[Nr.ShowImageWhenNotAligned=2]="ShowImageWhenNotAligned",Nr[Nr.UseClippingBoundary=4]="UseClippingBoundary",Nr[Nr.Transparency=8]="Transparency";function Rc(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let g0={brightness:50,constrast:50,fade:0},f0=[{code:14,name:"boundary",isMultiple:!0,parser:W},{code:91,name:"numberOfVertices",parser:v},{code:71,name:"boundaryType",parser:v},{code:360,name:"imageDefReactorHardId",parser:v},{code:283,name:"fade",parser:v},{code:282,name:"contrast",parser:v},{code:281,name:"brightness",parser:v},{code:280,name:"isClipping",parser:Vt},{code:70,name:"displayFlag",parser:v},{code:340,name:"imageDefHardId",parser:v},{code:13,name:"imageSize",parser:W},{code:12,name:"vDirection",parser:W},{code:11,name:"uDirection",parser:W},{code:10,name:"position",parser:W},{code:90,name:"classVersion",parser:v},{code:100,name:"subclassMarker",parser:v},...jt];class Dc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Rc(this,"parser",xt(f0,g0))}}function Fc(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Rc(Dc,"ForEntityName","WIPEOUT");let _0=[{code:11,name:"direction",parser:W},{code:10,name:"position",parser:W},{code:100,name:"subclassMarker",parser:v},...jt];class Vc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Fc(this,"parser",xt(_0))}}function Uc(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Fc(Vc,"ForEntityName","XLINE");let y0={},v0=[{code:170,name:"multileaderType",parser:v},{code:291,name:"doglegEnabled",parser:Vt},{code:40,name:"doglegLength",parser:v},{code:172,name:"contentType",parser:v},{code:3,name:"textContent",parser:v},{code:12,name:"textAnchor",parser:W},{code:344,name:"blockHandle",parser:v},{code:15,name:"blockPosition",parser:W},{code:302,name:"leaderSections",parser:function(i,t,e){let n,a={leaderLines:[]};for(;t.hasNext()&&(n=t.next()).code!==303;)switch(n.code){case 10:a.landingPoint=(n.value,Rt(t));break;case 11:a.doglegVector=(n.value,Rt(t));break;case 40:a.doglegLength=n.value;break;case 304:a.leaderLines.push(function(h,c,m){let b,f={vertices:[]};for(;c.hasNext()&&(b=c.next()).code!==305;)b.code===10&&f.vertices.push((b.value,Rt(c)));return f}(0,t))}return a},isMultiple:!0},...jt];class jc{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Uc(this,"parser",xt(v0,y0))}}Uc(jc,"ForEntityName","MULTILEADER");let b0=Object.fromEntries([Vh,qh,$h,Qh,tc,di,rc,sc,hc,uc,pc,gc,pi,_c,Xh,jc,vc,wc,Pc,Sc,Mc,Tc,Nc,Oc,mi,Wh,zc,oc,io,gi,Dc,Vc].map(i=>[i.ForEntityName,new i]));function Gc(i,t){let e=[];for(;!It(i,0,"EOF");){if(i.code===0){if(i.value==="ENDBLK"||i.value==="ENDSEC"){t.rewind();break}let n=b0[i.value];if(n){let a=i.value;i=t.next();let h=n.parseEntity(t,i);h.type=a,Rh(h),e.push(h)}else t.debug&&console.warn(`Unsupported ENTITY type: ${i.value}`)}i=t.next()}return e}function x0(i,t){let e={};for(;!It(i,0,"EOF")&&!It(i,0,"ENDSEC");){if(It(i,0,"BLOCK")){let n=w0(i=t.next(),t);Rh(n),n.name&&(e[n.name]=n)}i=t.next()}return e}function w0(i,t){let e={};for(;!It(i,0,"EOF");){if(It(i,0,"ENDBLK")){for(i=t.next();!It(i,0,"EOF");){if(It(i,100,"AcDbBlockEnd"))return e;i=t.next()}break}switch(i.code){case 1:e.xrefPath=i.value;break;case 2:e.name=i.value;break;case 3:e.name2=i.value;break;case 5:e.handle=i.value;break;case 8:e.layer=i.value;break;case 10:e.position=Rt(t);break;case 67:e.paperSpace=!!i.value&&i.value==1;break;case 70:i.value!==0&&(e.type=i.value);break;case 100:break;case 330:e.ownerHandle=i.value;break;case 0:e.entities=Gc(i,t)}i=t.next()}return e}function A0(i,t){let e=null,n={};for(;!It(i,0,"EOF")&&!It(i,0,"ENDSEC");)i.code===9?e=i.value:i.code===10?n[e]=Rt(t):n[e]=i.value,i=t.next();return n}(We={})[We.NOT_APPLICABLE=0]="NOT_APPLICABLE",We[We.KEEP_EXISTING=1]="KEEP_EXISTING",We[We.USE_CLONE=2]="USE_CLONE",We[We.XREF_VALUE_NAME=3]="XREF_VALUE_NAME",We[We.VALUE_NAME=4]="VALUE_NAME",We[We.UNMANGLE_NAME=5]="UNMANGLE_NAME";let ao=[{code:330,name:"ownerObjectId",parser:v},{code:102,parser:xn},{code:102,parser:xn},{code:102,parser:xn},{code:5,name:"handle",parser:v}],P0=[{code:3,name:"entries",parser:(i,t)=>{let e={name:i.value};return(i=t.next()).code===350?e.objectSoftId=i.value:i.code===360?e.objectHardId=i.value:t.rewind(),e},isMultiple:!0},{code:281,name:"recordCloneFlag",parser:v},{code:280,name:"isHardOwned",parser:Vt},{code:100,name:"subclassMarker",parser:v},...ao],I0=[{code:330,name:"imageDefReactorIdSoft",isMultiple:!0,parser:v},{code:90,name:"version",parser:v},{code:1,name:"fileName",parser:v},{code:10,name:"size",parser:W},{code:11,name:"sizeOfOnePixel",parser:W},{code:280,name:"isLoaded",parser:v},{code:281,name:"resolutionUnits",parser:v},{code:100,name:"subclassMarker",parser:v}];(mn={})[mn.NOUNIT=0]="NOUNIT",mn[mn.CENTIMETERS=2]="CENTIMETERS",mn[mn.INCH=5]="INCH";(Os={})[Os.PSLTSCALE=1]="PSLTSCALE",Os[Os.LIMCHECK=2]="LIMCHECK";(gn={})[gn.INCHES=0]="INCHES",gn[gn.MILLIMETERS=1]="MILLIMETERS",gn[gn.PIXELS=2]="PIXELS";(He={})[He.LAST_SCREEN_DISPLAY=0]="LAST_SCREEN_DISPLAY",He[He.DRAWING_EXTENTS=1]="DRAWING_EXTENTS",He[He.DRAWING_LIMITS=2]="DRAWING_LIMITS",He[He.VIEW_SPECIFIED=3]="VIEW_SPECIFIED",He[He.WINDOW_SPECIFIED=4]="WINDOW_SPECIFIED",He[He.LAYOUT_INFORMATION=5]="LAYOUT_INFORMATION";(Lr={})[Lr.AS_DISPLAYED=0]="AS_DISPLAYED",Lr[Lr.WIREFRAME=1]="WIREFRAME",Lr[Lr.HIDDEN=2]="HIDDEN",Lr[Lr.RENDERED=3]="RENDERED";(qe={})[qe.DRAFT=0]="DRAFT",qe[qe.PREVIEW=1]="PREVIEW",qe[qe.NORMAL=2]="NORMAL",qe[qe.PRESENTATION=3]="PRESENTATION",qe[qe.MAXIMUM=4]="MAXIMUM",qe[qe.CUSTOM=5]="CUSTOM";let Wc=[{code:333,name:"shadePlotId",parser:v},{code:149,name:"imageOriginY",parser:v},{code:148,name:"imageOriginX",parser:v},{code:147,name:"scaleFactor",parser:v},{code:78,name:"shadePlotCustomDPI",parser:v},{code:77,name:"shadePlotResolution",parser:v},{code:76,name:"shadePlotMode",parser:v},{code:75,name:"standardScaleType",parser:v},{code:7,name:"currentStyleSheet",parser:v},{code:74,name:"plotType",parser:v},{code:73,name:"plotRotation",parser:v},{code:72,name:"plotPaperUnit",parser:v},{code:70,name:"layoutFlag",parser:v},{code:143,name:"printScaleDenominator",parser:v},{code:142,name:"printScaleNumerator",parser:v},{code:141,name:"windowAreaYMax",parser:v},{code:140,name:"windowAreaXMax",parser:v},{code:49,name:"windowAreaYMin",parser:v},{code:48,name:"windowAreaXMin",parser:v},{code:47,name:"plotOriginY",parser:v},{code:46,name:"plotOriginX",parser:v},{code:45,name:"paperHeight",parser:v},{code:44,name:"paperWidth",parser:v},{code:43,name:"marginTop",parser:v},{code:42,name:"marginRight",parser:v},{code:41,name:"marginBottom",parser:v},{code:40,name:"marginLeft",parser:v},{code:6,name:"plotViewName",parser:v},{code:4,name:"paperSize",parser:v},{code:2,name:"configName",parser:v},{code:1,name:"pageSetupName",parser:v},{code:100,name:"subclassMarker",parser:v},...ao],S0=[{code:346,name:"orthographicUcsId",parser:v},{code:345,name:"namedUcsId",parser:v},{code:331,name:"viewportId",parser:v},{code:330,name:"paperSpaceTableId",parser:v},{code:76,name:"orthographicType",parser:v},{code:17,name:"ucsYAxis",parser:W},{code:16,name:"ucsXAxis",parser:W},{code:13,name:"ucsOrigin",parser:W},{code:146,name:"elevation",parser:v},{code:15,name:"maxExtent",parser:W},{code:14,name:"minExtent",parser:W},{code:12,name:"insertionPoint",parser:W},{code:11,name:"maxLimit",parser:W},{code:10,name:"minLimit",parser:W},{code:71,name:"tabOrder",parser:v},{code:70,name:"controlFlag",parser:v},{code:1,name:"layoutName",parser:v},{code:100,name:"subclassMarker",parser:v},...Wc],E0=[{code:40,name:"wcsToOCSTransform",parser:xl},{code:40,name:"ocsToWCSTransform",parser:xl},{code:41,name:"backClippingDistance",parser:v},{code:73,name:"isBackClipping",parser:Vt,pushContext:!0},{code:40,name:"frontClippingDistance",parser:v},{code:72,name:"isFrontClipping",parser:Vt,pushContext:!0},{code:71,name:"isClipBoundaryDisplayed",parser:Vt},{code:11,name:"position",parser:W},{code:210,name:"normal",parser:W},{code:10,name:"boundaryVertices",parser:W,isMultiple:!0},{code:70,name:"boundaryCount",parser:v},{code:100,name:"subclassMarker",parser:v},{code:100},...ao];function xl(i,t){let e=[];for(let n=0;n<3&&It(i,40);++n){let a=[];for(let h=0;h<4&&It(i,40);++h)a.push(i.value),i=t.next();e.push(a)}return t.rewind(),e}let M0={LAYOUT:S0,PLOTSETTINGS:Wc,DICTIONARY:P0,SPATIAL_FILTER:E0,IMAGEDEF:I0};function k0(i,t){let e=[];for(;i.code!==0||!["EOF","ENDSEC"].includes(i.value);){let n=i.value,a=M0[n];if(i.code===0&&(a!=null&&a.length)){let h=xt(a),c={name:n};h(i=t.next(),t,c)?(e.push(c),i=t.peek()):i=t.next()}else i=t.next()}return{byName:vd(e,({name:n})=>n)}}let Qn=[{code:100,name:"subclassMarker",parser:v},{code:330,name:"ownerObjectId",parser:v},{code:102,parser(i,t){for(;!It(i,0,"EOF")&&!It(i,102,"}");)i=t.next()}},{code:5,name:"handle",parser:v}],T0=xt([{code:310,name:"bmpPreview",parser:v},{code:281,name:"scalability",parser:v},{code:280,name:"explodability",parser:v},{code:70,name:"insertionUnits",parser:v},{code:340,name:"layoutObjects",parser:v},{code:2,name:"name",parser:v},{code:100,name:"subclassMarker",parser:v},...Qn]),C0=[{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:vl.Above,defaultValueImperial:vl.Center},{name:"DIMZIN",code:78,defaultValue:Un.Trailing,defaultValueImperial:Un.Feet},{name:"DIMAZIN",code:79,defaultValue:sd.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:id.Center},{name:"DIMSD1",code:281,defaultValue:0},{name:"DIMSD2",code:282,defaultValue:0},{name:"DIMTOLJ",code:283,defaultValue:ad.Center},{name:"DIMTZIN",code:284,defaultValue:Un.Trailing,defaultValueImperial:Un.Feet},{name:"DIMALTZ",code:285,defaultValue:Un.Trailing},{name:"DIMALTTZ",code:286,defaultValue:Un.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}],N0=xt([...C0.map(i=>({...i,parser:v})),{code:70,name:"standardFlag",parser:v},{code:2,name:"name",parser:v},{code:100,name:"subclassMarker",parser:v},{code:105,name:"handle",parser:v},...Qn.filter(i=>i.code!==5)]),L0=xt([{code:347,name:"materialObjectId",parser:v},{code:390,name:"plotStyleNameObjectId",parser:v},{code:370,name:"lineweight",parser:v},{code:290,name:"isPlotting",parser:Vt},{code:6,name:"lineType",parser:v},{code:62,name:"colorIndex",parser:v},{code:70,name:"standardFlag",parser:v},{code:2,name:"name",parser:v},{code:100,name:"subclassMarker",parser:v},...Qn]);(Or={})[Or.NONE=0]="NONE",Or[Or.AbsoluteRotation=1]="AbsoluteRotation",Or[Or.TextEmbedded=2]="TextEmbedded",Or[Or.ShapeEmbedded=4]="ShapeEmbedded";let O0=xt([{code:9,name:"text",parser:v},{code:45,name:"offsetY",parser:v},{code:44,name:"offsetX",parser:v},{code:50,name:"rotation",parser:v},{code:46,name:"scale",parser:v},{code:340,name:"styleObjectId",parser:v},{code:75,name:"shapeNumber",parser:v},{code:74,name:"elementTypeFlag",parser:v},{code:49,name:"elementLength",parser:v}],{elementTypeFlag:0,elementLength:0}),B0=xt([{code:49,name:"pattern",parser(i,t){let e={};return O0(i,t,e),e},isMultiple:!0},{code:40,name:"totalPatternLength",parser:v},{code:73,name:"numberOfLineTypes",parser:v},{code:72,parser:v},{code:3,name:"description",parser:v},{code:70,name:"standardFlag",parser:v},{code:2,name:"name",parser:v},{code:100,name:"subclassMarker",parser:v},...Qn]),z0=xt([{code:1e3,name:"extendedFont",parser:v},{code:1001},{code:4,name:"bigFont",parser:v},{code:3,name:"font",parser:v},{code:42,name:"lastHeight",parser:v},{code:71,name:"textGenerationFlag",parser:v},{code:50,name:"obliqueAngle",parser:v},{code:41,name:"widthFactor",parser:v},{code:40,name:"fixedTextHeight",parser:v},{code:70,name:"standardFlag",parser:v},{code:2,name:"name",parser:v},{code:100,name:"subclassMarker",parser:v},...Qn]),R0=xt([{code:[63,421,431],name:"ambientColor",parser:v},{code:142,name:"contrast",parser:v},{code:141,name:"brightness",parser:v},{code:282,name:"defaultLightingType",parser:v},{code:292,name:"isDefaultLightingOn",parser:Vt},{code:348,name:"visualStyleObjectId",parser:v},{code:333,name:"shadePlotObjectId",parser:v},{code:332,name:"backgroundObjectId",parser:v},{code:61,name:"majorGridLines",parser:v},{code:170,name:"shadePlotSetting",parser:v},{code:146,name:"elevation",parser:v},{code:79,name:"orthographicType",parser:v},{code:112,name:"ucsYAxis",parser:W},{code:111,name:"ucsXAxis",parser:W},{code:110,name:"ucsOrigin",parser:W},{code:74,name:"ucsIconSetting",parser:v},{code:71,name:"viewMode",parser:v},{code:281,name:"renderMode",parser:v},{code:1,name:"styleSheet",parser:v},{code:[331,441],name:"frozenLayers",parser:v,isMultiple:!0},{code:72,name:"circleSides",parser:v},{code:51,name:"viewTwistAngle",parser:v},{code:50,name:"snapRotationAngle",parser:v},{code:45,name:"viewHeight",parser:v},{code:44,name:"backClippingPlane",parser:v},{code:43,name:"frontClippingPlane",parser:v},{code:42,name:"lensLength",parser:v},{code:17,name:"viewTarget",parser:W},{code:16,name:"viewDirectionFromTarget",parser:W},{code:15,name:"gridSpacing",parser:W},{code:14,name:"snapSpacing",parser:W},{code:13,name:"snapBasePoint",parser:W},{code:12,name:"center",parser:W},{code:11,name:"upperRightCorner",parser:W},{code:10,name:"lowerLeftCorner",parser:W},{code:70,name:"standardFlag",parser:v},{code:2,name:"name",parser:v},{code:100,name:"subclassMarker",parser:v},...Qn]),D0={BLOCK_RECORD:T0,DIMSTYLE:N0,LAYER:L0,LTYPE:B0,STYLE:z0,VPORT:R0},F0=xt([{code:70,name:"maxNumberOfEntries",parser:v},{code:100,name:"subclassMarker",parser:v},{code:330,name:"ownerObjectId",parser:v},{code:102},{code:360,isMultiple:!0},{code:102},{code:5,name:"handle",parser:v},{code:2,name:"name",parser:v}]);function V0(i,t){var n;let e={};for(;!It(i,0,"EOF")&&!It(i,0,"ENDSEC");){if(It(i,0,"TABLE")){i=t.next();let a={entries:[]};F0(i,t,a),e[a.name]=a}if(It(i,0)&&!It(i,0,"ENDTAB")){let a=i.value;i=t.next();let h=D0[a];if(!h){t.debug&&console.warn(`parseTable: Invalid table name '${a}'`),i=t.next();continue}let c={};h(i,t,c),(n=e[a])==null||n.entries.push(c)}i=t.next()}return e}function Bs(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}class wl{next(){if(!this.hasNext())return this._eof?this.debug&&console.warn("Cannot call 'next' after EOF group has been read"):this.debug&&console.warn("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]),{code:0,value:"EOF"};let t=parseInt(this._data[this._pointer++],10),e=Al(t,this._data[this._pointer++],this.debug),n={code:t,value:e};return It(n,0,"EOF")&&(this._eof=!0),this.lastReadGroup=n,n}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=Al(t.code,this._data[this._pointer+1],this.debug),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,e=!1){Bs(this,"_data",void 0),Bs(this,"debug",void 0),Bs(this,"_pointer",void 0),Bs(this,"_eof",void 0),Bs(this,"lastReadGroup",void 0),this._data=t,this.debug=e,this.lastReadGroup={code:0,value:0},this._pointer=0,this._eof=!1}}function Al(i,t,e=!1){return i<=9?t:i>=10&&i<=59?parseFloat(t.trim()):i>=60&&i<=99?parseInt(t.trim()):i>=100&&i<=109?t:i>=110&&i<=149?parseFloat(t.trim()):i>=160&&i<=179?parseInt(t.trim()):i>=210&&i<=239?parseFloat(t.trim()):i>=270&&i<=289?parseInt(t.trim()):i>=290&&i<=299?function(n){if(n==="0")return!1;if(n==="1")return!0;throw TypeError("String '"+n+"' cannot be cast to Boolean type")}(t.trim()):i>=300&&i<=369?t:i>=370&&i<=389?parseInt(t.trim()):i>=390&&i<=399?t:i>=400&&i<=409?parseInt(t.trim()):i>=410&&i<=419?t:i>=420&&i<=429?parseInt(t.trim()):i>=430&&i<=439?t:i>=440&&i<=459?parseInt(t.trim()):i>=460&&i<=469?parseFloat(t.trim()):i>=470&&i<=481||i===999||i>=1e3&&i<=1009?t:i>=1010&&i<=1059?parseFloat(t.trim()):i>=1060&&i<=1071?parseInt(t.trim()):(e&&console.warn("WARNING: Group code does not have a defined type: %j",{code:i,value:t}),t)}function Na(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}class U0{constructor(){Na(this,"encoding","utf-8"),Na(this,"encodingFailureFatal",!1)}}class j0 extends EventTarget{parseSync(t,e=!1){let n=new wl(t.split(/\r\n|\r|\n/g),e);if(!n.hasNext())throw Error("Empty file");return this.parseAll(n)}parseStream(t){let e="",n=this;return new Promise((a,h)=>{t.on("data",c=>{e+=c}),t.on("end",()=>{try{let c=e.split(/\r\n|\r|\n/g),m=new wl(c);if(!m.hasNext())throw Error("Empty file");a(n.parseAll(m))}catch(c){h(c)}}),t.on("error",c=>{h(c)})})}async parseFromUrl(t,e){let n=await fetch(t,e);if(!n.body)return null;let a=n.body.getReader(),h="";for(;;){let{done:c,value:m}=await a.read();if(c){h+=this._decoder.decode(new ArrayBuffer(0),{stream:!1});break}h+=this._decoder.decode(m,{stream:!0})}return this.parseSync(h)}parseAll(t){let e={header:{},blocks:{},entities:[],tables:{},objects:{byName:{},byTree:void 0}},n=t.next();for(;!It(n,0,"EOF");)It(n,0,"SECTION")&&(It(n=t.next(),2,"HEADER")?(n=t.next(),e.header=A0(n,t)):It(n,2,"BLOCKS")?(n=t.next(),e.blocks=x0(n,t)):It(n,2,"ENTITIES")?(n=t.next(),e.entities=Gc(n,t)):It(n,2,"TABLES")?(n=t.next(),e.tables=V0(n,t)):It(n,2,"OBJECTS")&&(n=t.next(),e.objects=k0(n,t))),n=t.next();return e}constructor(t=new U0){super(),Na(this,"_decoder",void 0),this._decoder=new TextDecoder(t.encoding,{fatal:t.encodingFailureFatal})}}const Pl=[{name:"AC1.2",value:1},{name:"AC1.40",value:2},{name:"AC1.50",value:3},{name:"AC2.20",value:4},{name:"AC2.10",value:5},{name:"AC2.21",value:6},{name:"AC2.22",value:7},{name:"AC1001",value:8},{name:"AC1002",value:9},{name:"AC1003",value:10},{name:"AC1004",value:11},{name:"AC1005",value:12},{name:"AC1006",value:13},{name:"AC1007",value:14},{name:"AC1008",value:15},{name:"AC1009",value:16},{name:"AC1010",value:17},{name:"AC1011",value:18},{name:"AC1012",value:19},{name:"AC1013",value:20},{name:"AC1014",value:21},{name:"AC1500",value:22},{name:"AC1015",value:23},{name:"AC1800a",value:24},{name:"AC1018",value:25},{name:"AC2100a",value:26},{name:"AC1021",value:27},{name:"AC2400a",value:28},{name:"AC1024",value:29},{name:"AC1027",value:31},{name:"AC3200a",value:32},{name:"AC1032",value:33}];class Ui{constructor(t){if(typeof t=="string"){const e=Pl.find(n=>n.name===t);if(!e)throw new Error(`Unknown DWG version name: ${t}`);this.name=e.name,this.value=e.value;return}if(typeof t=="number"){const e=Pl.find(n=>n.value===t);if(!e)throw new Error(`Unknown DWG version value: ${t}`);this.name=e.name,this.value=e.value;return}throw new Error("Invalid constructor argument for AcDbDwgVersion")}}class G0{parse(t){const e=new j0,n=this.getDxfInfoFromBuffer(t);let a="";return n.version&&n.version.value<=23&&n.encoding?a=new TextDecoder(n.encoding).decode(t):a=new TextDecoder().decode(t),e.parseSync(a)}getDxfInfoFromBuffer(t){var f,w,x;const n=new TextDecoder("utf-8");let a=0,h="",c=null,m=null,b=!1;for(;a<t.byteLength;){const S=Math.min(a+65536,t.byteLength),M=t.slice(a,S);a=S;const O=(h+n.decode(M,{stream:!0})).split(/\r?\n/);h=O.pop()??"";for(let F=0;F<O.length;F++){const D=O[F].trim();if(D==="SECTION"&&((f=O[F+2])==null?void 0:f.trim())==="HEADER")b=!0;else if(D==="ENDSEC"&&b)return{version:c,encoding:m};if(b&&D==="$ACADVER"){const at=(w=O[F+2])==null?void 0:w.trim();at&&(c=new Ui(at))}else if(b&&D==="$DWGCODEPAGE"){const at=(x=O[F+2])==null?void 0:x.trim();if(at){const ft=Ra[at];m=zl(ft)}}if(c&&m)return{version:c,encoding:m}}}return{version:c,encoding:m}}}class Il{convert(t){const e=this.createEntity(t);return e&&this.processCommonAttrs(t,e),e}createEntity(t){return t.type=="3DFACE"?this.convertFace(t):t.type=="ARC"?this.convertArc(t):t.type=="ATTDEF"?this.convertAttributeDefinition(t):t.type=="ATTRIB"?this.convertAttribute(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=="LWPOLYLINE"?this.convertLWPolyline(t):t.type=="MTEXT"?this.convertMText(t):t.type=="POLYLINE"?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}convertFace(t){const e=new Ii;return t.vertices.forEach((n,a)=>e.setVertexAt(a,n)),e}convertArc(t){return new bi(t.center,t.radius,Pt.degToRad(t.startAngle),Pt.degToRad(t.endAngle),t.extrusionDirection??X.Z_AXIS)}convertAttributeCommon(t,e){e.textString=t.text,e.height=t.textHeight,e.position.copy(t.startPoint),e.rotation=t.rotation,e.oblique=t.obliqueAngle??0,e.thickness=t.thickness,e.tag=t.tag,e.fieldLength=0,e.isInvisible=(t.attributeFlag&le.Invisible)!==0,e.isConst=(t.attributeFlag&le.Const)!==0,e.isVerifiable=(t.attributeFlag&le.Verifiable)!==0,e.isPreset=(t.attributeFlag&le.Preset)!==0,e.isReallyLocked=!!t.isReallyLocked,e.isMTextAttribute=(t.mtextFlag&fr.MultiLine)!==0,e.isConstMTextAttribute=(t.mtextFlag&fr.ConstMultiLine)!==0}convertAttribute(t){const e=new wi;return this.convertAttributeCommon(t,e),e.styleName=t.textStyle,e.horizontalMode=t.horizontalJustification,e.verticalMode=t.verticalJustification,e.widthFactor=t.scale??1,e.lockPositionInBlock=t.lockPositionFlag,e}convertAttributeDefinition(t){const e=new xi;return this.convertAttributeCommon(t,e),e.styleName=t.styleName,e.horizontalMode=t.halign,e.verticalMode=t.valign,e.widthFactor=t.xScale??1,e.prompt=t.prompt,e}convertCirle(t){return new Ai(t.center,t.radius,t.extrusionDirection??X.Z_AXIS)}convertEllipse(t){const e=new X(t.majorAxisEndPoint),n=e.length();return new Pi(t.center,t.extrusionDirection??X.Z_AXIS,e,n,n*t.axisRatio,t.startAngle,t.endAngle)}convertLine(t){const e=t.startPoint,n=t.endPoint;return new Ys(new G(e.x,e.y,e.z||0),new G(n.x,n.y,n.z||0))}convertSpline(t){try{if(t.numberOfControlPoints>0&&t.numberOfKnots>0)return new Ks(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 Ks(e,"Uniform",t.degree,!!(t.flag&1))}}catch(e){console.log(`Failed to convert spline with error: ${e}`)}return null}convertPoint(t){const e=new Ti;return e.position=t.position,e}convertSolid(t){const e=new Mi;return t.points.forEach((n,a)=>e.setPointAt(a,n)),e.thickness=t.thickness,e}convertPolyline(t){const e=!!(t.flag&1),n=!!(t.flag&8),a=[],h=[];if(t.vertices.map(c=>{c.flag&t0.SPLINE_CONTROL_POINT||(a.push({x:c.x,y:c.y,z:c.z}),h.push(c.bulge??0))}),n){let c=js.SimplePoly;return t.flag&4&&(t.smoothType==li.CUBIC?c=js.CubicSplinePoly:t.smoothType==li.QUADRATIC&&(c=js.QuadSplinePoly)),new vi(c,a,e)}else{let c=jn.SimplePoly;return t.flag&2?c=jn.FitCurvePoly:t.flag&4&&(t.smoothType==li.CUBIC?c=jn.CubicSplinePoly:t.smoothType==li.QUADRATIC&&(c=jn.QuadSplinePoly)),new yi(c,a,0,e,t.startWidth,t.endWidth,h)}}convertLWPolyline(t){const e=new ki;return e.closed=!!(t.flag&1),t.vertices.forEach((n,a)=>{e.addVertexAt(a,new Tt(n.x,n.y),n.bulge,n.startWidth,n.endWidth)}),e}convertHatch(t){var a;const e=new qs;return(a=t.definitionLines)==null||a.forEach(h=>{e.definitionLines.push({angle:h.angle,base:h.base,offset:h.offset,dashLengths:h.numberOfDashLengths>0?h.dashLengths:[]})}),e.isSolidFill=t.solidFill==od.SolidFill,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 m=h,b=new An;b.closed=m.isClosed,m.vertices.forEach((f,w)=>{b.addVertexAt(w,{x:f.x,y:f.y,bulge:f.bulge})}),e.add(b)}else{const m=h,b=new Ka;m.edges.forEach(f=>{if(f.type==1){const w=f;b.add(new Us(w.start,w.end))}else if(f.type==2){const w=f;b.add(new Wn(w.center,w.radius,Pt.degToRad(w.startAngle||0),Pt.degToRad(w.endAngle||0),!w.isCCW))}else if(f.type==3){const w=f;new Jt().subVectors(w.end,w.center);const S=Math.sqrt(Math.pow(w.end.x,2)+Math.pow(w.end.y,2)),M=S*w.lengthOfMinorAxis;let N=Pt.degToRad(w.startAngle||0),O=Pt.degToRad(w.endAngle||0);const F=Math.atan2(w.end.y,w.end.x);w.isCCW||(N=Math.PI*2-N,O=Math.PI*2-O),b.add(new Ki({...w.center,z:0},S,M,N,O,!w.isCCW,F))}else if(f.type==4){const w=f;if(w.numberOfControlPoints>0&&w.numberOfKnots>0){const x=w.controlPoints.map(N=>({x:N.x,y:N.y,z:0}));let S=!0;const M=w.controlPoints.map(N=>(N.weight==null&&(S=!1),N.weight||1));b.add(new Jr(x,w.knots,S?M:void 0))}else if(w.numberOfFitData>0){const x=w.fitDatum.map(S=>({x:S.x,y:S.y,z:0}));b.add(new Jr(x,"Uniform"))}}}),e.add(b)}}),e}convertTable(t){const e=new Ei(t.name,t.rowCount,t.columnCount);return e.attachmentPoint=t.attachmentPoint,e.position.copy(t.startPoint),t.columnWidthArr.forEach((n,a)=>e.setColumnWidth(a,n)),t.rowHeightArr.forEach((n,a)=>e.setRowHeight(a,n)),t.cells.forEach((n,a)=>{e.setCell(a,n)}),e}convertText(t){const e=new qn;return e.textString=t.text,e.styleName=t.styleName,e.height=t.textHeight,e.position.copy(t.startPoint),e.rotation=Pt.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 Xs;return e.contents=t.text,t.styleName!=null&&(e.styleName=t.styleName),e.height=t.height,e.width=t.width,e.rotation=Pt.degToRad(t.rotation||0),e.location=t.insertionPoint,e.attachmentPoint=t.attachmentPoint,t.direction&&(e.direction=new X(t.direction)),e.drawingDirection=t.drawingDirection,e}convertLeader(t){const e=new Si;return t.vertices.forEach(n=>{e.appendVertex(n)}),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,n=new zi(e.subDefinitionPoint1,e.subDefinitionPoint2,e.definitionPoint);return e.insertionPoint&&(n.dimBlockPosition={...e.insertionPoint,z:0}),n.rotation=Pt.degToRad(e.rotationAngle||0),this.processDimensionCommonAttrs(t,n),n}else if(t.subclassMarker=="AcDb3PointAngularDimension"){const e=t,n=new Bi(e.centerPoint,e.subDefinitionPoint1,e.subDefinitionPoint2,e.definitionPoint);return this.processDimensionCommonAttrs(t,n),n}else if(t.subclassMarker=="AcDbOrdinateDimension"){const e=t,n=new Di(e.subDefinitionPoint1,e.subDefinitionPoint2);return this.processDimensionCommonAttrs(t,n),n}else if(t.subclassMarker=="AcDbRadialDimension"){const e=t,n=new Fi(e.definitionPoint,e.centerPoint,e.leaderLength);return this.processDimensionCommonAttrs(t,n),n}else if(t.subclassMarker=="AcDbDiametricDimension"){const e=t,n=new Ri(e.definitionPoint,e.centerPoint,e.leaderLength);return this.processDimensionCommonAttrs(t,n),n}return null}processImage(t,e){e.position.copy(t.position),e.brightness=t.brightness,e.contrast=t.contrast,e.fade=t.fade,e.isShownClipped=(t.flags|4)>0,e.isImageShown=(t.flags|3)>0,e.isImageTransparent=(t.flags|8)>0,e.imageDefId=t.imageDefHandle,e.isClipped=t.isClipped,t.clippingBoundaryPath.forEach(n=>{e.clipBoundary.push(new Tt(n))}),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 $s;return this.processImage(t,e),e.clipBoundaryType=t.clippingBoundaryType,e}processWipeout(t,e){e.position.copy(t.position),e.brightness=t.brightness,e.contrast=t.contrast,e.fade=t.fade,e.isShownClipped=(t.displayFlag|4)>0,e.isImageShown=(t.displayFlag|3)>0,e.isImageTransparent=(t.displayFlag|8)>0,e.imageDefId=t.imageDefHardId,e.isClipped=t.isClipping,t.boundary.forEach(n=>{e.clipBoundary.push(new Tt(n))}),e.clipBoundaryType=t.boundaryType,e.width=Math.sqrt(t.uDirection.x**2+t.uDirection.y**2+t.uDirection.z**2)*t.imageSize.x,e.height=Math.sqrt(t.vDirection.x**2+t.vDirection.y**2+t.vDirection.z**2)*t.imageSize.y,e.rotation=Math.atan2(t.uDirection.y,t.uDirection.x)}convertWipeout(t){const e=new Li;return this.processWipeout(t,e),e}convertViewport(t){const e=new Ni;return e.number=t.viewportId,e.centerPoint.copy(t.viewportCenter),e.height=t.height,e.width=t.width,e.viewCenter.copy(t.displayCenter),e.viewHeight=t.viewHeight,e}convertRay(t){const e=new Ci;return e.basePoint.copy(t.position),e.unitDir.copy(t.direction),e}convertXline(t){const e=new Oi;return e.basePoint.copy(t.position),e.unitDir.copy(t.direction),e}convertBlockReference(t){const e=new Yn(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?Pt.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,e.normal.copy(t.extrusionDirection??{x:0,y:0,z:1})}processCommonAttrs(t,e){e.layer=t.layer||"0",t.handle&&(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.setRGBValue(t.color),t.colorIndex!=null&&(e.color.colorIndex=t.colorIndex),t.colorName&&(e.color.colorName=t.colorName),t.isVisible!=null&&(e.visibility=t.isVisible),t.transparency!=null&&(e.transparency=qi.deserialize(t.transparency))}numberArrayToPointArray(t,e){const n=t.length;let a=0;if(n/2==e?a=2:n/3==e&&(a=3),a==0)return;const h=[];for(let c=0,m=n/a;c<m;++c)h.push({x:t[c*a],y:t[c*a+1],z:a==3?t[c*a+2]:0});return h}}class Pn extends tn{constructor(t,e){t=t||{},Kn(t,{name:""}),super(t,e)}get name(){return this.getAttr("name")}set name(t){this.setAttr("name",t)}}const Qr=class Qr extends Pn{static isModelSapceName(t){return t.toLowerCase()==Qr.MODEL_SPACE_NAME.toLowerCase()}static isPaperSapceName(t){return t.toLowerCase().startsWith(Qr.PAPER_SPACE_NAME_PREFIX.toLowerCase())}constructor(){super(),this._origin=new G,this._layoutId="",this._entities=new Map}get isModelSapce(){return Qr.isModelSapceName(this.name)}get isPaperSapce(){return Qr.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 n=t[e];n.database=this.database,n.ownerId=this.objectId,this._entities.set(n.objectId,n)}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})}removeEntity(t){const e=Array.isArray(t)?t:[t],n=[];return e.forEach(a=>{const h=this._entities.get(a);h&&n.push(h),this._entities.delete(a)}),n.length>0&&this.database.events.entityErased.dispatch({database:this.database,entity:n}),n.length>0}newIterator(){return new Js(this._entities)}getIdAt(t){return this._entities.get(t)}};Qr.MODEL_SPACE_NAME="*MODEL_SPACE",Qr.PAPER_SPACE_NAME_PREFIX="*PAPER_SPACE";let he=Qr;class W0{convertLayout(t,e){var a,h;const n=new Qi;if(n.layoutName=t.layoutName,n.tabOrder=t.tabOrder,t.layoutName==="Model"){const c=he.MODEL_SPACE_NAME;(a=e.tables.BLOCK_RECORD)==null||a.entries.some(m=>m.name.toUpperCase()===c?(n.blockTableRecordId=m.handle,!0):!1)}else(h=e.tables.BLOCK_RECORD)==null||h.entries.some(c=>c.layoutObjects===t.handle?(n.blockTableRecordId=c.handle,!0):!1),n.blockTableRecordId||(n.blockTableRecordId=t.paperSpaceTableId);return n.limits.min.copy(t.minLimit),n.limits.max.copy(t.maxLimit),n.extents.min.copy(t.minExtent),n.extents.max.copy(t.maxExtent),this.processCommonAttrs(t,n),n}convertImageDef(t){const e=new Nh;return e.sourceFileName=t.fileName,this.processCommonAttrs(t,e),e}processCommonAttrs(t,e){e.objectId=t.handle,e.ownerId=t.ownerObjectId}}class Hc{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 n=Date.now(),a=this.generateTaskId();try{return await this.executeInWorker(a,t,e||this.config.workerUrl)}catch(h){const c=Date.now()-n;return{success:!1,error:h instanceof Error?h.message:String(h),duration:c}}}async executeInWorker(t,e,n){const a=Date.now();return new Promise((h,c)=>{const m=this.getAvailableWorker(n),b=setTimeout(()=>{this.cleanupTask(t),this.releaseWorker(m),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(m),h(x)},reject:x=>{clearTimeout(b),this.releaseWorker(m),c(x)},timeout:b});const f=x=>{const{id:S,success:M,data:N,error:O}=x.data;if(S!==t)return;this.cleanupTask(t);const F=Date.now()-a;h(M?{success:!0,data:N,duration:F}:{success:!1,error:O,duration:F})},w=x=>{this.cleanupTask(t),c(new Error(`Worker error: ${x.message}`))};m.addEventListener("message",f),m.addEventListener("error",w),m.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[n,a]of this.workers)if(!a.isBusy)return a.isBusy=!0,a.worker;if(this.workers.size<this.config.maxConcurrentWorkers){const n=new Worker(t,{type:"module"}),a=this.generateWorkerId(),h={worker:n,isBusy:!0,id:a,createdAt:new Date};return this.workers.set(a,h),n}const e=Array.from(this.workers.values()).sort((n,a)=>n.createdAt.getTime()-a.createdAt.getTime())[0];return e.isBusy=!0,e.worker}releaseWorker(t){for(const[e,n]of this.workers)if(n.worker===t){n.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 qc{constructor(t){this.framework=new Hc(t)}async execute(t,e){return this.framework.execute(t,e)}getStats(){return this.framework.getStats()}destroy(){this.framework.destroy()}}function Yc(i){return new qc(i)}class H0{constructor(){this.setupMessageHandler()}setupMessageHandler(){self.onmessage=async t=>{const{id:e,input:n}=t.data;try{const a=await this.executeTask(n);this.sendResponse(e,!0,a)}catch(a){this.sendResponse(e,!1,void 0,a instanceof Error?a.message:String(a))}}}sendResponse(t,e,n,a){const h={id:t,success:e,data:n,error:a};self.postMessage(h)}}class Xc extends ro{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=Yc({workerUrl:this.config.parserWorkerUrl,maxConcurrentWorkers:1}),n=await e.execute(t);if(e.destroy(),n.success)return{model:n.data,data:{unknownEntityCount:0}};throw new Error(`Failed to parse drawing due to error: '${n.error}'`)}else return{model:new G0().parse(t),data:{unknownEntityCount:0}}}getFonts(t){var h;const e=new Map,n=c=>{if(c){const m=c.lastIndexOf(".");return m>=0?c.substring(0,m).toLowerCase():c.toLowerCase()}};(h=t.tables.STYLE)==null||h.entries.forEach(c=>{const m=[];if(c.font){const b=n(c.font);b&&m.push(b)}if(c.bigFont){const b=n(c.bigFont);b&&m.push(b)}if(c.extendedFont){const b=n(c.extendedFont);b&&m.push(b)}e.set(c.name,m)});const a=new Set;return this.getFontsInBlock(t.entities,t.blocks,e,a),Array.from(a)}getFontsInBlock(t,e,n,a){const h=/\\f(.*?)\|/g;t.forEach(c=>{if(c.type=="MTEXT"){const m=c;[...m.text.matchAll(h)].forEach(w=>{a.add(w[1].toLowerCase())});const f=n.get(m.styleName);f==null||f.forEach(w=>a.add(w))}else if(c.type=="TEXT"){const m=c,b=n.get(m.styleName);b==null||b.forEach(f=>a.add(f))}else if(c.type=="INSERT"){const b=e[c.name];b&&b.entities&&this.getFontsInBlock(b.entities,e,n,a)}})}async processEntities(t,e,n,a,h){const c=new Il;let m=t.entities;const b=m.length,f=new Ba(b,100-a.value,n);this.config.convertByEntityType&&(m=this.groupAndFlattenByType(m));const w=new Map;for(let S=0;S<b;S++){const M=m[S];if(M.type==="ATTRIB"){const N=c.convert(M);if(N&&N.ownerId&&N.ownerId!=="0"){let O=w.get(N==null?void 0:N.ownerId);O==null&&(O=[],w.set(N.ownerId,O)),O.push(N)}}}const x=e.tables.blockTable.modelSpace;await f.processChunk(async(S,M)=>{let N=[],O=S<M?m[S].type:"";for(let D=S;D<M;D++){const at=m[D];if(at.type!=="ATTRIB"){const ft=c.convert(at);if(ft){if(this.config.convertByEntityType&&at.type!==O&&(x.appendEntity(N),N=[],O=at.type),at.type==="INSERT"){const st=w.get(ft.objectId);st&&st.length>0&&st.forEach(H=>{ft.appendAttributes(H)})}N.push(ft)}}}x.appendEntity(N);let F=a.value+M/b*(100-a.value);F>100&&(F=100),h&&await h(F,"ENTITY","IN-PROGRESS")})}async processEntitiesInBlock(t,e,n=!1){const a=new Il,h=t.length,c=[],m=e.objectId,b=[];for(let f=0;f<h;f++){const w=t[f],x=a.convert(w);x&&(w.type==="ATTRIB"?b.push(x):(!n||w.ownerBlockRecordSoftId===m)&&c.push(x))}b.forEach(f=>{const w=e.getIdAt(f.ownerId);w&&w.appendAttributes(f)}),e.appendEntity(c)}processBlocks(t,e){const n=t.blocks;for(const[a,h]of Object.entries(n)){let c=e.tables.blockTable.getAt(h.name);c||(c=new he,c.objectId=h.handle,c.name=a,c.origin.copy(h.position),e.tables.blockTable.add(c)),h.entities?this.processEntitiesInBlock(h.entities,c):c.isPaperSapce&&this.processEntitiesInBlock(t.entities,c,!0)}}processHeader(t,e){const n=t.header;n.$ACADVER&&(e.version=n.$ACADVER),e.cecolor.colorIndex=n.$CECOLOR||256,e.angBase=n.$ANGBASE||0,e.angDir=n.$ANGDIR||0,n.$AUNITS!=null&&(e.aunits=n.$AUNITS),e.celtscale=n.$CELTSCALE||1,e.ltscale=n.$LTSCALE||1,n.$EXTMAX&&(e.extmax=n.$EXTMAX),n.$EXTMIN&&(e.extmin=n.$EXTMIN),n.$INSUNITS!=null&&(e.insunits=n.$INSUNITS),e.pdmode=n.$PDMODE||0,e.pdsize=n.$PDSIZE||0}processBlockTables(t,e){var a;const n=(a=t.tables.BLOCK_RECORD)==null?void 0:a.entries;n&&n.length>0&&(e.tables.blockTable.removeAll(),n.forEach(h=>{const c=new he;c.objectId=h.handle,c.name=h.name,c.layoutId=h.layoutObjects,e.tables.blockTable.add(c)}))}processObjects(t,e){const n=t.objects.byName,a=new W0;if("LAYOUT"in n){const h=e.dictionaries.layouts;n.LAYOUT.forEach(c=>{const m=a.convertLayout(c,t);h.setAt(m.layoutName,m)})}if("IMAGEDEF"in n){const h=e.dictionaries.imageDefs;n.IMAGEDEF.forEach(c=>{const m=a.convertImageDef(c);h.setAt(m.objectId,m)})}}processViewports(t,e){var a,h;const n=(h=(a=t.tables)==null?void 0:a.VPORT)==null?void 0:h.entries;n&&n.length>0&&n.forEach(c=>{const m=new ou;this.processCommonTableEntryAttrs(c,m),c.circleSides&&(m.circleSides=c.circleSides),m.standardFlag=c.standardFlag,m.center.copy(c.center),m.lowerLeftCorner.copy(c.lowerLeftCorner),m.upperRightCorner.copy(c.upperRightCorner),c.snapBasePoint&&m.snapBase.copy(c.snapBasePoint),c.snapRotationAngle&&(m.snapAngle=c.snapRotationAngle),c.snapSpacing&&m.snapIncrements.copy(c.snapSpacing),c.majorGridLines&&(m.gridMajor=c.majorGridLines),c.gridSpacing&&m.gridIncrements.copy(c.gridSpacing),c.backgroundObjectId&&(m.backgroundObjectId=c.backgroundObjectId),m.gsView.center.copy(c.center),m.gsView.viewDirectionFromTarget.copy(c.viewDirectionFromTarget),m.gsView.viewTarget.copy(c.viewTarget),c.lensLength&&(m.gsView.lensLength=c.lensLength),c.frontClippingPlane&&(m.gsView.frontClippingPlane=c.frontClippingPlane),c.backClippingPlane&&(m.gsView.backClippingPlane=c.backClippingPlane),c.viewHeight&&(m.gsView.viewHeight=c.viewHeight),c.viewTwistAngle&&(m.gsView.viewTwistAngle=c.viewTwistAngle),c.frozenLayers&&(m.gsView.frozenLayers=c.frozenLayers),c.styleSheet&&(m.gsView.styleSheet=c.styleSheet),c.renderMode&&(m.gsView.renderMode=c.renderMode),c.viewMode&&(m.gsView.viewMode=c.viewMode),c.ucsIconSetting&&(m.gsView.ucsIconSetting=c.ucsIconSetting),c.ucsOrigin&&m.gsView.ucsOrigin.copy(c.ucsOrigin),c.ucsXAxis&&m.gsView.ucsXAxis.copy(c.ucsXAxis),c.ucsYAxis&&m.gsView.ucsYAxis.copy(c.ucsYAxis),c.orthographicType&&(m.gsView.orthographicType=c.orthographicType),c.shadePlotSetting&&(m.gsView.shadePlotSetting=c.shadePlotSetting),c.shadePlotObjectId&&(m.gsView.shadePlotObjectId=c.shadePlotObjectId),c.visualStyleObjectId&&(m.gsView.visualStyleObjectId=c.visualStyleObjectId),c.isDefaultLightingOn&&(m.gsView.isDefaultLightingOn=c.isDefaultLightingOn),c.defaultLightingType&&(m.gsView.defaultLightingType=c.defaultLightingType),c.brightness&&(m.gsView.brightness=c.brightness),c.contrast&&(m.gsView.contrast=c.contrast),c.ambientColor&&(m.gsView.ambientColor=c.ambientColor),e.tables.viewportTable.add(m)})}processLayers(t,e){var a,h;const n=(h=(a=t.tables)==null?void 0:a.LAYER)==null?void 0:h.entries;n&&n.length>0&&n.forEach(c=>{const m=new Fr;m.colorIndex=c.colorIndex;const b=new ta({name:c.name,standardFlags:c.standardFlag,linetype:c.lineType,lineWeight:c.lineweight,isOff:c.colorIndex<0,color:m,isPlottable:c.isPlotting});this.processCommonTableEntryAttrs(c,b),e.tables.layerTable.add(b)})}processLineTypes(t,e){var a,h;const n=(h=(a=t.tables)==null?void 0:a.LTYPE)==null?void 0:h.entries;n&&n.length>0&&n.forEach(c=>{const m=new Hs(c);this.processCommonTableEntryAttrs(c,m),m.name=c.name,e.tables.linetypeTable.add(m)})}processTextStyles(t,e){var a;const n=(a=t.tables.STYLE)==null?void 0:a.entries;n&&n.length>0&&n.forEach(h=>{const c=new oo(h);this.processCommonTableEntryAttrs(h,c),e.tables.textStyleTable.add(c)})}processDimStyles(t,e){var a;const n=(a=t.tables.DIMSTYLE)==null?void 0:a.entries;n&&n.length>0&&n.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},m=new Xn(c);this.processCommonTableEntryAttrs(h,m),e.tables.dimStyleTable.add(m)})}processCommonTableEntryAttrs(t,e){e.name=t.name,e.objectId=t.handle,e.ownerId=t.ownerObjectId}groupAndFlattenByType(t){const e={},n=[];for(const a of t)e[a.type]||(e[a.type]=[],n.push(a.type)),e[a.type].push(a);return n.flatMap(a=>e[a])}}class Kc extends ro{constructor(t){super({}),this._database=t}async parse(){return{model:this._database,data:{unknownEntityCount:0}}}getFonts(){return[]}async processEntities(t,e,n,a,h){let c=t.tables.blockTable.modelSpace.newIterator().toArray();const m=c.length,b=new Ba(m,100-a.value,n);this.config.convertByEntityType&&(c=this.groupAndFlattenByType(c));const f=e.tables.blockTable.modelSpace;await b.processChunk(async(w,x)=>{let S=[],M=w<x?c[w].type:"";for(let N=w;N<x;N++){const O=c[N];this.config.convertByEntityType&&O.type!==M&&(this.triggerEvents(f,S),S=[],M=O.type),S.push(O)}if(this.triggerEvents(f,S),h){let N=a.value+x/m*(100-a.value);N>100&&(N=100),await h(N,"ENTITY","IN-PROGRESS")}})}processBlocks(){const t=this._database.tables.blockTable.newIterator();for(const e of t){const n=e.newIterator().toArray();this.triggerEvents(e,n)}}processHeader(){}processBlockTables(){}processObjects(){const t=this._database.dictionaries.layouts.newIterator();for(const n of t)this._database.events.dictObjetSet.dispatch({database:this._database,object:n,key:n.layoutName});const e=this._database.dictionaries.imageDefs.newIterator();for(const n of e)this._database.events.dictObjetSet.dispatch({database:this._database,object:n,key:n.objectId})}processViewports(){}processLayers(){this._database.tables.layerTable.newIterator().toArray().forEach(e=>{this._database.events.layerAppended.dispatch({database:this._database,layer:e})})}processLineTypes(){}processTextStyles(){}processDimStyles(){}groupAndFlattenByType(t){const e={},n=[];for(const a of t)e[a.type]||(e[a.type]=[],n.push(a.type)),e[a.type].push(a);return n.flatMap(a=>e[a])}triggerEvents(t,e){(t.isModelSapce||t.isPaperSapce)&&t.database.events.entityAppended.dispatch({database:t.database,entity:e})}}var Ws=(i=>(i.DXF="dxf",i.DWG="dwg",i))(Ws||{});class gr{constructor(){this.events={registered:new ae,unregistered:new ae},this._converters=new Map,this.register("dxf",new Xc)}static createInstance(){return gr._instance==null&&(gr._instance=new gr),this._instance}static get instance(){return gr._instance||(gr._instance=new gr),gr._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 In extends tn{constructor(t){super(),this.database=t,this._recordsByName=new Map,this._recordsById=new Map}get numEntries(){return this._recordsByName.size}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),n=this._recordsByName.get(e);return n?(this._recordsById.delete(n.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 Js(this._recordsByName)}normalizeName(t){return t}}class $c extends In{constructor(t){super(t)}get modelSpace(){let t=this.getAt(he.MODEL_SPACE_NAME);return t||(t=new he,t.name=he.MODEL_SPACE_NAME,this.add(t)),t}getEntityById(t){for(const e of this.database.tables.blockTable.newIterator()){const n=e.getIdAt(t);if(n)return n}}removeEntity(t){let e=!1;for(const n of this.database.tables.blockTable.newIterator())if(n.removeEntity(t)){e=!0;break}return e}normalizeName(t){let e=t;if(he.isModelSapceName(t))e=he.MODEL_SPACE_NAME;else if(he.isPaperSapceName(t)){const n=he.PAPER_SPACE_NAME_PREFIX,a=t.substring(n.length);e=n+a}return e}}class Zc extends In{constructor(t){super(t)}}class ta extends Pn{constructor(t,e){t=t||{},Kn(t,{color:new Fr,description:"",standardFlags:0,isHidden:!1,isInUse:!0,isOff:!1,isPlottable:!0,transparency:new qi,linetype:"",lineWeight:1,materialId:-1}),super(t,e),this.attrs.events.attrChanged.addEventListener(n=>{this.database.events.layerModified.dispatch({database:this.database,layer:this,changes:n.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.clone())}get linetype(){return this.getAttr("linetype")}set linetype(t){this.setAttr("linetype",t)}get lineStyle(){var e;const t=(e=this.database)==null?void 0:e.tables.linetypeTable.getAt(this.linetype);if(t)return{type:"UserSpecified",...t.linetype}}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 Qc extends In{constructor(t){super(t);const e=new Fr,n=new ta({name:"0",standardFlags:0,linetype:fi,lineWeight:Zi.ByLineWeightDefault,isOff:!1,color:e,isPlottable:!0});this.add(n)}add(t){super.add(t),this.database.events.layerAppended.dispatch({database:this.database,layer:t})}}class Jc extends In{constructor(t){super(t)}}class tu extends In{constructor(t){super(t)}get fonts(){const t=new Set,e=a=>{if(a){const h=a.lastIndexOf(".");if(h>=0){const c=a.substring(0,h).toLowerCase();t.add(c)}else t.add(a.toLowerCase())}},n=this.newIterator();for(const a of n)e(a.fileName),e(a.bigFontFileName);return Array.from(t)}}class eu extends In{constructor(t){super(t)}}class q0 extends tn{constructor(){super(),this.events={dictObjetSet:new ae,dictObjectErased:new ae,entityAppended:new ae,entityModified:new ae,entityErased:new ae,layerAppended:new ae,layerModified:new ae,layerErased:new ae,openProgress:new ae,headerSysVarChanged:new ae},this._version=new Ui("AC1014"),this._angBase=0,this._angDir=0,this._aunits=za.DecimalDegrees,this._celtscale=1,this._cecolor=new Fr,this._extents=new Ct,this._insunits=eo.Millimeters,this._ltscale=1,this._pdmode=0,this._pdsize=0,this._tables={blockTable:new $c(this),dimStyleTable:new Zc(this),linetypeTable:new Jc(this),textStyleTable:new tu(this),layerTable:new Qc(this),viewportTable:new eu(this)},this._dictionaries={layouts:new Ch(this),imageDefs:new to(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 version(){return this._version}set version(t){this._version=new Ui(t),this.triggerHeaderSysVarChangedEvent("version")}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){t&&(this._extents.expandByPoint(t),this.triggerHeaderSysVarChangedEvent("extmax"))}get extmin(){return this._extents.min}set extmin(t){t&&(this._extents.expandByPoint(t),this.triggerHeaderSysVarChangedEvent("extmin"))}get extents(){return this._extents}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,n=Ws.DXF){const a=gr.instance.get(n);if(a==null)throw new Error(`Database converter for file type '${n}' isn't registered and can can't read this file!`);this.clear(),await a.read(t,this,e&&e.minimumChunkSize||10,async(h,c,m,b)=>{if(this.events.openProgress.dispatch({database:this,percentage:h,stage:"CONVERSION",subStage:c,subStageStatus:m,data:b}),e&&e.fontLoader&&c=="FONT"&&m=="END"){const f=b||this.tables.textStyleTable.fonts;await e.fontLoader.load(f)}})}async openUri(t,e){var M;this.events.openProgress.dispatch({database:this,percentage:0,stage:"FETCH_FILE",subStageStatus:"START"});const n=await fetch(t);if(!n.ok)throw this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",subStageStatus:"ERROR"}),new Error(`Failed to fetch file '${t}' with HTTP status code '${n.status}'!`);const a=n.headers.get("content-length"),h=a?parseInt(a,10):null;let c=0;const m=(M=n.body)==null?void 0:M.getReader();if(!m)throw new Error("Failed to get response reader");const b=[];for(;;){const{done:N,value:O}=await m.read();if(N)break;if(b.push(O),c+=O.length,h!==null){const F=Math.round(c/h*100);this.events.openProgress.dispatch({database:this,percentage:F,stage:"FETCH_FILE",subStageStatus:"IN-PROGRESS"})}}const f=new Uint8Array(c);let w=0;for(const N of b)f.set(N,w),w+=N.length;const S=this.getFileNameFromUri(t).toLowerCase().split(".").pop();S==="dwg"?await this.read(f.buffer,e,Ws.DWG):S==="dxf"?await this.read(f.buffer,e,Ws.DXF):await this.read(f.buffer,e,S),this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",subStageStatus:"END"})}async regen(){await new Kc(this).read(null,this,500,async(e,n,a,h)=>{this.events.openProgress.dispatch({database:this,percentage:e,stage:"CONVERSION",subStage:n,subStageStatus:a,data:h})})}createDefaultData(t={layer:!0,lineType:!0,textStyle:!0,dimStyle:!0,layout:!0}){const e=new Lh(this);t.layer&&e.createDefaultLayer(),t.lineType&&e.createDefaultLineType(),t.textStyle&&e.createDefaultTextStyle(),t.dimStyle&&e.createDefaultDimStyle(),t.layout&&e.createDefaultLayout()}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})}getFileNameFromUri(t){try{const n=new URL(t).pathname.split("/");return n[n.length-1]||""}catch(e){return console.error("Invalid URI:",e),""}}}var ru=(i=>(i[i.Center=0]="Center",i[i.Left=1]="Left",i[i.Right=2]="Right",i[i.OverFirst=3]="OverFirst",i[i.OverSecond=4]="OverSecond",i))(ru||{}),nu=(i=>(i[i.Center=0]="Center",i[i.Above=1]="Above",i[i.Outside=2]="Outside",i[i.JIS=3]="JIS",i[i.Below=4]="Below",i))(nu||{}),su=(i=>(i[i.Feet=0]="Feet",i[i.None=1]="None",i[i.Inch=2]="Inch",i[i.FeetAndInch=3]="FeetAndInch",i[i.Leading=4]="Leading",i[i.Trailing=8]="Trailing",i[i.LeadingAndTrailing=12]="LeadingAndTrailing",i))(su||{}),iu=(i=>(i[i.None=0]="None",i[i.Leading=1]="Leading",i[i.Trailing=2]="Trailing",i[i.LeadingAndTrailing=3]="LeadingAndTrailing",i))(iu||{}),au=(i=>(i[i.Bottom=0]="Bottom",i[i.Middle=1]="Middle",i[i.Top=2]="Top",i))(au||{});const Gi=class Gi extends Pn{constructor(t,e){t=t||{},Kn(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 Xn=Gi;class Hs extends Pn{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}}const Wi=class Wi{constructor(){this.registry=new Map,this.cache=new Map,this.events={sysVarChanged:new ae},this.registerVar({name:"PICKBOX",type:"number",defaultValue:0})}static instance(){return this._instance||(this._instance=new Wi),this._instance}registerVar(t){this.registry.set(t.name.toUpperCase(),t)}registerMany(t){t.forEach(e=>this.registerVar(e))}getVar(t){if(t=t.toUpperCase(),this.cache.has(t))return this.cache.get(t)}setVar(t,e){t=t.toUpperCase();const n=this.getDescriptor(t);if(n){const a=this.getVar(t);if(this.cache.set(t,e),n.type!=="string"&&(typeof e=="string"||e instanceof String))if(n.type==="number"){const h=Number(e);if(Number.isNaN(h))throw new Error("Invalid input!");e=h}else n.type==="boolean"&&(e=this.parseBoolean(e));this.events.sysVarChanged.dispatch({name:t,newVal:e,oldVal:a})}else throw new Error(`System variable ${t} not found!`)}getDescriptor(t){return this.registry.get(t.toUpperCase())}getAllDescriptors(){return[...this.registry.values()]}parseBoolean(t){if(t==null)return!1;const e=String(t).trim().toLowerCase(),n=new Set(["true","t","1","yes","y"]),a=new Set(["false","f","0","no","n"]);return n.has(e)?!0:(a.has(e),!1)}};Wi._instance=null;let La=Wi;class oo extends Pn{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 n=e.lastIndexOf(".");return n===-1?e:e.substring(0,n)}return t}}const Y0={center:new Tt,viewDirectionFromTarget:new G(0,0,1),viewTarget:new G(0,0,0),lensLength:500,frontClippingPlane:0,backClippingPlane:0,viewHeight:1e3,viewTwistAngle:0,frozenLayers:[],styleSheet:"",renderMode:Za.OPTIMIZED_2D,viewMode:0,ucsIconSetting:0,ucsOrigin:new G(0,0,0),ucsXAxis:new G(1,0,0),ucsYAxis:new G(0,1,0),orthographicType:Qa.TOP,shadePlotSetting:0,shadePlotObjectId:void 0,visualStyleObjectId:void 0,isDefaultLightingOn:!1,defaultLightingType:Ja.ONE_DISTANT_LIGHT,brightness:0,contrast:0,ambientColor:void 0};class ou extends Pn{constructor(){super(),this._circleSides=100,this._center=new Tt,this._lowerLeftCorner=new Tt(0,0),this._upperRightCorner=new Tt(1,1),this._snapBase=new Tt(0,0),this._snapAngle=0,this._snapSpacing=new Tt(0,0),this._standardFlag=0,this._gridSpacing=new Tt,this._gridMajor=10,this._gsView=Y0}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 lu{constructor(){this.events={layoutCreated:new ae,layoutRemoved:new ae,layoutRenamed:new ae,layoutSwitched:new ae}}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 n=this.getWorkingDatabase(e),a=n.dictionaries.layouts.getIdAt(t);return this.setCurrentLayoutInternal(a,n)}setCurrentLayoutBtrId(t,e){const n=this.getWorkingDatabase(e),a=n.dictionaries.layouts.getBtrIdAt(t);return this.setCurrentLayoutInternal(a,n)}setCurrentLayout(t,e){const n=this.getWorkingDatabase(e),a=n.dictionaries.layouts.getAt(t);return this.setCurrentLayoutInternal(a,n)}renameLayout(t,e,n){const h=this.getWorkingDatabase(n).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 n=this.getWorkingDatabase(e).dictionaries.layouts,a=n.getAt(t);let h=!1;return a&&(h=n.remove(t),h&&this.events.layoutRemoved.dispatch({layout:a})),h}createLayout(t,e){const n=this.getWorkingDatabase(e),a=new Qi;a.layoutName=t,a.tabOrder=n.dictionaries.layouts.maxTabOrder;const h=new he;return h.name=`*Paper_Space${a.tabOrder}`,n.tables.blockTable.add(h),n.dictionaries.layouts.setAt(t,a),this.events.layoutCreated.dispatch({layout:a}),{layout:a,btr:h}}getActiveLayout(t){const e=this.getWorkingDatabase(t);return e.dictionaries.layouts.getBtrIdAt(e.currentSpaceId)}getWorkingDatabase(t){return t||lo().workingDatabase}setCurrentLayoutInternal(t,e){return t?(this.events.layoutSwitched.dispatch({layout:t}),e.currentSpaceId=t.blockTableRecordId,!0):!1}}function lo(){return ji.instance}const Hi=class Hi{constructor(){this._workingDatabase=null,this._layoutManager=new lu}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}};Hi.instance=new Hi;let ji=Hi;var hu=(i=>(i.kForRead="kForRead",i.kForWrite="kForWrite",i))(hu||{});exports.AcCmColor=Fr;exports.AcCmColorMethod=pt;exports.AcCmColorUtil=fn;exports.AcCmEntityColor=Eu;exports.AcCmErrors=Xe;exports.AcCmEventDispatcher=Mu;exports.AcCmEventManager=ae;exports.AcCmLoader=zu;exports.AcCmLoadingManager=Ol;exports.AcCmObject=Tl;exports.AcCmPerformanceCollector=Oa;exports.AcCmTask=Nl;exports.AcCmTaskScheduler=Ll;exports.AcCmTransparency=qi;exports.AcCmTransparencyMethod=Me;exports.AcDb2dPolyline=yi;exports.AcDb2dVertex=ka;exports.AcDb2dVertexType=wh;exports.AcDb3PointAngularDimension=Bi;exports.AcDb3dPolyline=vi;exports.AcDb3dVertex=Ta;exports.AcDb3dVertexType=Ah;exports.AcDbAlignedDimension=zi;exports.AcDbAngleUnits=za;exports.AcDbArc=bi;exports.AcDbArcDimension=Ca;exports.AcDbAttribute=wi;exports.AcDbAttributeDefinition=xi;exports.AcDbAttributeFlags=le;exports.AcDbAttributeMTextFlag=fr;exports.AcDbBaseWorker=H0;exports.AcDbBatchProcessing=Ba;exports.AcDbBlockReference=Yn;exports.AcDbBlockTable=$c;exports.AcDbBlockTableRecord=he;exports.AcDbCircle=Ai;exports.AcDbCodePage=Ra;exports.AcDbCurve=Te;exports.AcDbDataGenerator=Lh;exports.AcDbDatabase=q0;exports.AcDbDatabaseConverter=ro;exports.AcDbDatabaseConverterManager=gr;exports.AcDbDiametricDimension=Ri;exports.AcDbDictionary=to;exports.AcDbDimArrowType=Oh;exports.AcDbDimStyleTable=Zc;exports.AcDbDimStyleTableRecord=Xn;exports.AcDbDimTextHorizontal=ru;exports.AcDbDimTextVertical=nu;exports.AcDbDimVerticalJustification=au;exports.AcDbDimZeroSuppression=su;exports.AcDbDimZeroSuppressionAngular=iu;exports.AcDbDimension=Dr;exports.AcDbDwgVersion=Ui;exports.AcDbDxfConverter=Xc;exports.AcDbEllipse=Pi;exports.AcDbEntity=ke;exports.AcDbFace=Ii;exports.AcDbFileType=Ws;exports.AcDbHatch=qs;exports.AcDbHatchPatternType=Gs;exports.AcDbHatchStyle=Sh;exports.AcDbHostApplicationServices=ji;exports.AcDbLayerTable=Qc;exports.AcDbLayerTableRecord=ta;exports.AcDbLayout=Qi;exports.AcDbLayoutDictionary=Ch;exports.AcDbLayoutManager=lu;exports.AcDbLeader=Si;exports.AcDbLeaderAnnotationType=Eh;exports.AcDbLine=Ys;exports.AcDbLineSpacingStyle=Th;exports.AcDbLinetypeTable=Jc;exports.AcDbLinetypeTableRecord=Hs;exports.AcDbMText=Xs;exports.AcDbObject=tn;exports.AcDbObjectIterator=Js;exports.AcDbOpenMode=hu;exports.AcDbOrdinateDimension=Di;exports.AcDbOsnapMode=Dt;exports.AcDbPoint=Ti;exports.AcDbPoly2dType=jn;exports.AcDbPoly3dType=js;exports.AcDbPolyline=ki;exports.AcDbRadialDimension=Fi;exports.AcDbRasterImage=$s;exports.AcDbRasterImageClipBoundaryType=Mh;exports.AcDbRasterImageDef=Nh;exports.AcDbRasterImageImageDisplayOpt=kh;exports.AcDbRay=Ci;exports.AcDbRegenerator=Kc;exports.AcDbRenderingCache=$n;exports.AcDbSpline=Ks;exports.AcDbSymbolTable=In;exports.AcDbSymbolTableRecord=Pn;exports.AcDbSysVarManager=La;exports.AcDbTable=Ei;exports.AcDbText=qn;exports.AcDbTextHorizontalMode=Ph;exports.AcDbTextStyleTable=tu;exports.AcDbTextStyleTableRecord=oo;exports.AcDbTextVerticalMode=Ih;exports.AcDbTrace=Mi;exports.AcDbUnitsValue=eo;exports.AcDbViewport=Ni;exports.AcDbViewportTable=eu;exports.AcDbViewportTableRecord=ou;exports.AcDbWipeout=Li;exports.AcDbWorkerApi=qc;exports.AcDbWorkerManager=Hc;exports.AcDbXline=Oi;exports.AcGeArea2d=Xi;exports.AcGeBox2d=we;exports.AcGeBox3d=Ct;exports.AcGeCatmullRomCurve3d=yh;exports.AcGeCircArc2d=Wn;exports.AcGeCircArc3d=Xa;exports.AcGeCurve2d=Zn;exports.AcGeEllipseArc2d=Ki;exports.AcGeEllipseArc3d=$i;exports.AcGeEuler=Wu;exports.AcGeGeometryUtil=ah;exports.AcGeLine2d=Us;exports.AcGeLine3d=Hn;exports.AcGeLoop2d=Ka;exports.AcGeMathUtil=Pt;exports.AcGeMatrix2d=Yi;exports.AcGeMatrix3d=Ye;exports.AcGeNurbsCurve=bn;exports.AcGePlane=Zs;exports.AcGePoint2d=Tt;exports.AcGePoint3d=G;exports.AcGePolyline2d=An;exports.AcGeQuaternion=wn;exports.AcGeShape2d=Ya;exports.AcGeSpline3d=Jr;exports.AcGeTol=Wa;exports.AcGeVector2d=Jt;exports.AcGeVector3d=X;exports.AcGiArrowType=$a;exports.AcGiDefaultLightingType=Ja;exports.AcGiLineWeight=Zi;exports.AcGiMTextAttachmentPoint=xe;exports.AcGiMTextFlowDirection=Rr;exports.AcGiOrthographicType=Qa;exports.AcGiRenderMode=Za;exports.AcGiViewport=vh;exports.AcTrStringUtil=Bu;exports.ByBlock=Rl;exports.ByLayer=hi;exports.DEBUG_MODE=Lu;exports.DEFAULT_LINE_TYPE=fi;exports.DEFAULT_TOL=Ha;exports.DEG2RAD=Da;exports.DefaultLoadingManager=Bl;exports.FLOAT_TOL=yn;exports.ORIGIN_POINT_2D=Du;exports.ORIGIN_POINT_3D=Ga;exports.RAD2DEG=Fa;exports.TAU=Zt;exports.acdbDisableOsnapMode=td;exports.acdbEnableOsnapMode=Ju;exports.acdbHasOsnapMode=Qu;exports.acdbHostApplicationServices=lo;exports.acdbMaskToOsnapModes=$u;exports.acdbOsnapModesToMask=Ku;exports.acdbToggleOsnapMode=Zu;exports.basisFunction=_i;exports.calculateCurveLength=ch;exports.ceilPowerOfTwo=Ql;exports.clamp=zr;exports.clone=zs;exports.createWorkerApi=Yc;exports.damp=Ul;exports.deepClone=Pa;exports.defaults=Kn;exports.degToRad=Kl;exports.dwgCodePageToEncoding=zl;exports.euclideanModulo=Va;exports.evaluateNurbsPoint=Vs;exports.floorPowerOfTwo=Jl;exports.generateChordKnots=lh;exports.generateSqrtChordKnots=hh;exports.generateUUID=Dl;exports.generateUniformKnots=oh;exports.has=Sl;exports.intPartLength=ja;exports.interpolateControlPoints=Fu;exports.inverseLerp=Vl;exports.isBetween=th;exports.isBetweenAngle=eh;exports.isEmpty=El;exports.isEqual=Gn;exports.isImperialUnits=nd;exports.isMetricUnits=rd;exports.isPointInPolygon=qa;exports.isPolygonIntersect=ih;exports.isPowerOfTwo=Zl;exports.lerp=Ua;exports.log=Ds;exports.mapLinear=Fl;exports.normalizeAngle=Fs;exports.pingpong=jl;exports.radToDeg=$l;exports.randFloat=ql;exports.randFloatSpread=Yl;exports.randInt=Hl;exports.relativeEps=rh;exports.seededRandom=Xl;exports.setLogLevel=Ou;exports.smootherstep=Wl;exports.smoothstep=Gl;