@mlightcad/libredwg-converter 3.16.7 → 3.16.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/libredwg-converter.umd.cjs +1 -1
- package/dist/libredwg-parser-worker.js +18 -22
- package/dist/libredwg-web.wasm +0 -0
- package/lib/AcDbEntitiyConverter.d.ts +1 -0
- package/lib/AcDbEntitiyConverter.d.ts.map +1 -1
- package/lib/AcDbEntitiyConverter.js +7 -1
- package/lib/AcDbEntitiyConverter.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,30 +1,26 @@
|
|
|
1
|
-
var _o=Object.defineProperty;var lo=(r,t,o)=>t in r?_o(r,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[t]=o;var bt=(r,t,o)=>lo(r,typeof t!="symbol"?t+"":t,o);var zt;(function(r){r[r.ByBlock=-2]="ByBlock",r[r.ByDIPs=-4]="ByDIPs",r[r.ByLayer=-1]="ByLayer",r[r.ByLineWeightDefault=-3]="ByLineWeightDefault",r[r.LineWeight000=0]="LineWeight000",r[r.LineWeight005=5]="LineWeight005",r[r.LineWeight009=9]="LineWeight009",r[r.LineWeight013=13]="LineWeight013",r[r.LineWeight015=15]="LineWeight015",r[r.LineWeight018=18]="LineWeight018",r[r.LineWeight020=20]="LineWeight020",r[r.LineWeight025=25]="LineWeight025",r[r.LineWeight030=30]="LineWeight030",r[r.LineWeight035=35]="LineWeight035",r[r.LineWeight040=40]="LineWeight040",r[r.LineWeight050=50]="LineWeight050",r[r.LineWeight053=53]="LineWeight053",r[r.LineWeight060=60]="LineWeight060",r[r.LineWeight070=70]="LineWeight070",r[r.LineWeight080=80]="LineWeight080",r[r.LineWeight090=90]="LineWeight090",r[r.LineWeight100=100]="LineWeight100",r[r.LineWeight106=106]="LineWeight106",r[r.LineWeight120=120]="LineWeight120",r[r.LineWeight140=140]="LineWeight140",r[r.LineWeight158=158]="LineWeight158",r[r.LineWeight200=200]="LineWeight200",r[r.LineWeight211=211]="LineWeight211"})(zt||(zt={}));var co="DwgConverterLicenseError",uo=["evaluation of @mlightcad/dwg-converter has expired"],Eo=["invalid @mlightcad/dwg-converter license key"];function fo(r){return r==="license_expired"||r==="license_invalid"}function fr(r){var t=r.toLowerCase();if(uo.some(function(o){return t.includes(o)}))return"license_expired";if(Eo.some(function(o){return t.includes(o)}))return"license_invalid"}function ho(r){var t;return(t=fr(r))!==null&&t!==void 0?t:"license_invalid"}var go=function(r,t,o,e){function s(_){return _ instanceof o?_:new o(function(l){l(_)})}return new(o||(o=Promise))(function(_,l){function f(y){try{g(e.next(y))}catch(T){l(T)}}function h(y){try{g(e.throw(y))}catch(T){l(T)}}function g(y){y.done?_(y.value):s(y.value).then(f,h)}g((e=e.apply(r,t||[])).next())})},Ao=function(r,t){var o={label:0,sent:function(){if(_[0]&1)throw _[1];return _[1]},trys:[],ops:[]},e,s,_,l;return l={next:f(0),throw:f(1),return:f(2)},typeof Symbol=="function"&&(l[Symbol.iterator]=function(){return this}),l;function f(g){return function(y){return h([g,y])}}function h(g){if(e)throw new TypeError("Generator is already executing.");for(;l&&(l=0,g[0]&&(o=0)),o;)try{if(e=1,s&&(_=g[0]&2?s.return:g[0]?s.throw||((_=s.return)&&_.call(s),0):s.next)&&!(_=_.call(s,g[1])).done)return _;switch(s=0,_&&(g=[g[0]&2,_.value]),g[0]){case 0:case 1:_=g;break;case 4:return o.label++,{value:g[1],done:!1};case 5:o.label++,s=g[1],g=[0];continue;case 7:g=o.ops.pop(),o.trys.pop();continue;default:if(_=o.trys,!(_=_.length>0&&_[_.length-1])&&(g[0]===6||g[0]===2)){o=0;continue}if(g[0]===3&&(!_||g[1]>_[0]&&g[1]<_[3])){o.label=g[1];break}if(g[0]===6&&o.label<_[1]){o.label=_[1],_=g;break}if(_&&o.label<_[2]){o.label=_[2],o.ops.push(g);break}_[2]&&o.ops.pop(),o.trys.pop();continue}g=t.call(r,o)}catch(y){g=[6,y],s=0}finally{e=_=0}if(g[0]&5)throw g[1];return{value:g[0]?g[1]:void 0,done:!0}}},yo=["out of memory","data cannot be cloned","allocation failed","memory access out of bounds"];function po(r){var t=r.toLowerCase();return yo.some(function(o){return t.includes(o)})}function wn(){var r=globalThis;if(typeof r.postMessage!="function")throw new Error("Worker messaging is not available in this runtime");return r}var To=(function(){function r(){this.setupMessageHandler()}return r.prototype.setupMessageHandler=function(){var t=this;wn().onmessage=function(o){return go(t,void 0,void 0,function(){var e,s,_,l,f,h,g;return Ao(this,function(y){switch(y.label){case 0:e=o,s=e.data,_=s.id,l=s.input,y.label=1;case 1:return y.trys.push([1,3,,4]),[4,this.executeTask(l)];case 2:return f=y.sent(),this.sendResponse(_,!0,f),[3,4];case 3:return h=y.sent(),g=h instanceof Error?h.message:String(h),this.sendResponse(_,!1,void 0,g,this.classifyTaskError(h,g)),[3,4];case 4:return[2]}})})}},r.prototype.sendResponse=function(t,o,e,s,_){var l={id:t,success:o,data:e,error:s,errorCode:_};try{wn().postMessage(l)}catch(h){var f=h instanceof Error?h.message:String(h);wn().postMessage({id:t,success:!1,error:f,errorCode:this.classifyPostMessageError(f)})}},r.prototype.classifyTaskError=function(t,o){if(t instanceof Error){var e=t.code;if(fo(e))return e;if(t.name===co)return ho(o)}var s=fr(o);return s||this.classifyPostMessageError(o)},r.prototype.classifyPostMessageError=function(t){return po(t)?"worker_oom":t.toLowerCase().includes("timed out")?"worker_timeout":"worker_error"},r})();const Po="modulepreload",vo=function(r,t){return new URL(r,t).href},rr={},mo=function(t,o,e){let s=Promise.resolve();if(o&&o.length>0){let l=function(y){return Promise.all(y.map(T=>Promise.resolve(T).then(P=>({status:"fulfilled",value:P}),P=>({status:"rejected",reason:P}))))};const f=document.getElementsByTagName("link"),h=document.querySelector("meta[property=csp-nonce]"),g=(h==null?void 0:h.nonce)||(h==null?void 0:h.getAttribute("nonce"));s=l(o.map(y=>{if(y=vo(y,e),y in rr)return;rr[y]=!0;const T=y.endsWith(".css"),P=T?'[rel="stylesheet"]':"";if(!!e)for(let w=f.length-1;w>=0;w--){const I=f[w];if(I.href===y&&(!T||I.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${y}"]${P}`))return;const C=document.createElement("link");if(C.rel=T?"stylesheet":Po,T||(C.as="script"),C.crossOrigin="",C.href=y,g&&C.setAttribute("nonce",g),document.head.appendChild(C),T)return new Promise((w,I)=>{C.addEventListener("load",w),C.addEventListener("error",()=>I(new Error(`Unable to preload CSS for ${y}`)))})}))}function _(l){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=l,window.dispatchEvent(f),!f.defaultPrevented)throw l}return s.then(l=>{for(const f of l||[])f.status==="rejected"&&_(f.reason);return t().catch(_)})};var ar=(()=>{var r=import.meta.url;return(async function(t={}){var o,e=t,s,_,l=new Promise((n,a)=>{s=n,_=a}),f=typeof window=="object",h=typeof WorkerGlobalScope<"u",g=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&process.type!="renderer";if(g){const{createRequire:n}=await mo(()=>Promise.resolve().then(()=>oi),void 0,import.meta.url);var y=n(import.meta.url)}var T=Object.assign({},e),P="./this.program",v="";function C(n){return e.locateFile?e.locateFile(n,v):v+n}var w,I;if(g){var L=y("fs"),W=y("path");import.meta.url.startsWith("data:")||(v=W.dirname(y("url").fileURLToPath(import.meta.url))+"/"),I=n=>{n=pt(n)?new URL(n):n;var a=L.readFileSync(n);return a},w=async(n,a=!0)=>{n=pt(n)?new URL(n):n;var i=L.readFileSync(n,a?void 0:"utf8");return i},!e.thisProgram&&process.argv.length>1&&(P=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2)}else(f||h)&&(h?v=self.location.href:typeof document<"u"&&document.currentScript&&(v=document.currentScript.src),r&&(v=r),v.startsWith("blob:")?v="":v=v.slice(0,v.replace(/[?#].*/,"").lastIndexOf("/")+1),h&&(I=n=>{var a=new XMLHttpRequest;return a.open("GET",n,!1),a.responseType="arraybuffer",a.send(null),new Uint8Array(a.response)}),w=async n=>{if(pt(n))return new Promise((i,d)=>{var u=new XMLHttpRequest;u.open("GET",n,!0),u.responseType="arraybuffer",u.onload=()=>{if(u.status==200||u.status==0&&u.response){i(u.response);return}d(u.status)},u.onerror=d,u.send(null)});var a=await fetch(n,{credentials:"same-origin"});if(a.ok)return a.arrayBuffer();throw new Error(a.status+" : "+a.url)});var M=e.print||(()=>{}).bind(console),b=e.printErr||(()=>{}).bind(console);Object.assign(e,T),T=null,e.arguments&&e.arguments,e.thisProgram&&(P=e.thisProgram);var O=e.wasmBinary,$,q=!1,U,Z,rt,dt,Y,F,ct,it,Yt,wt,pt=n=>n.startsWith("file://");function Ct(){var n=$.buffer;e.HEAP8=U=new Int8Array(n),e.HEAP16=rt=new Int16Array(n),e.HEAPU8=Z=new Uint8Array(n),e.HEAPU16=dt=new Uint16Array(n),e.HEAP32=Y=new Int32Array(n),e.HEAPU32=F=new Uint32Array(n),e.HEAPF32=ct=new Float32Array(n),e.HEAPF64=wt=new Float64Array(n),e.HEAP64=it=new BigInt64Array(n),e.HEAPU64=Yt=new BigUint64Array(n)}function xt(){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)We(e.preRun.shift());$t(ge)}function Dt(){!e.noFSInit&&!c.initialized&&c.init(),X.__wasm_call_ctors(),c.ignorePermissions=!1}function Ot(){if(e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;)Vt(e.postRun.shift());$t(ie)}var ht=0,Rt=null;function Jt(n){var a;ht++,(a=e.monitorRunDependencies)==null||a.call(e,ht)}function kt(n){var i;if(ht--,(i=e.monitorRunDependencies)==null||i.call(e,ht),ht==0&&Rt){var a=Rt;Rt=null,a()}}function Nt(n){var i;(i=e.onAbort)==null||i.call(e,n),n="Aborted("+n+")",b(n),q=!0,n+=". Build with -sASSERTIONS for more info.";var a=new WebAssembly.RuntimeError(n);throw _(a),a}var Bt;function Ft(){return e.locateFile?C("libredwg-web.wasm"):new URL(""+new URL("libredwg-web.wasm",import.meta.url).href,import.meta.url).href}function re(n){if(n==Bt&&O)return new Uint8Array(O);if(I)return I(n);throw"both async and sync fetching of the wasm failed"}async function ae(n){if(!O)try{var a=await w(n);return new Uint8Array(a)}catch{}return re(n)}async function oe(n,a){try{var i=await ae(n),d=await WebAssembly.instantiate(i,a);return d}catch(u){b(`failed to asynchronously prepare wasm: ${u}`),Nt(u)}}async function Ut(n,a,i){if(!n&&typeof WebAssembly.instantiateStreaming=="function"&&!pt(a)&&!g)try{var d=fetch(a,{credentials:"same-origin"}),u=await WebAssembly.instantiateStreaming(d,i);return u}catch(E){b(`wasm streaming compile failed: ${E}`),b("falling back to ArrayBuffer instantiation")}return oe(a,i)}function Q(){return{env:er,wasi_snapshot_preview1:er}}async function H(){function n(E,A){return X=E.exports,X=so(X),$=X.memory,Ct(),Fn=X.__indirect_function_table,kt(),X}Jt();function a(E){return n(E.instance)}var i=Q();if(e.instantiateWasm)return new Promise((E,A)=>{e.instantiateWasm(i,(p,m)=>{n(p),E(p.exports)})});Bt??(Bt=Ft());try{var d=await Ut(O,Bt,i),u=a(d);return u}catch(E){return _(E),Promise.reject(E)}}var $t=n=>{for(;n.length>0;)n.shift()(e)},ie=[],Vt=n=>ie.unshift(n),ge=[],We=n=>ge.unshift(n);e.noExitRuntime;function Ge(n,a,i="i8"){switch(i.endsWith("*")&&(i="*"),i){case"i1":U[n>>>0]=a;break;case"i8":U[n>>>0]=a;break;case"i16":rt[n>>>1>>>0]=a;break;case"i32":Y[n>>>2>>>0]=a;break;case"i64":it[n>>>3]=BigInt(a);break;case"float":ct[n>>>2>>>0]=a;break;case"double":wt[n>>>3>>>0]=a;break;case"*":F[n>>>2>>>0]=a;break;default:Nt(`invalid type for setValue: ${i}`)}}var Me=n=>ao(n),be=()=>io();class xe{constructor(a){this.excPtr=a,this.ptr=a-24}set_type(a){F[this.ptr+4>>>2>>>0]=a}get_type(){return F[this.ptr+4>>>2>>>0]}set_destructor(a){F[this.ptr+8>>>2>>>0]=a}get_destructor(){return F[this.ptr+8>>>2>>>0]}set_caught(a){a=a?1:0,U[this.ptr+12>>>0]=a}get_caught(){return U[this.ptr+12>>>0]!=0}set_rethrown(a){a=a?1:0,U[this.ptr+13>>>0]=a}get_rethrown(){return U[this.ptr+13>>>0]!=0}init(a,i){this.set_adjusted_ptr(0),this.set_type(a),this.set_destructor(i)}set_adjusted_ptr(a){F[this.ptr+16>>>2>>>0]=a}get_adjusted_ptr(){return F[this.ptr+16>>>2>>>0]}}var Ae=0,ye=9007199254740992,pe=-9007199254740992,Te=n=>n<pe||n>ye?NaN:Number(n);function Oe(n,a,i){n>>>=0,a>>>=0,i>>>=0;var d=new xe(n);throw d.init(a,i),Ae=n,Ae}var Zt=()=>{var n=Y[+et.varargs>>>2>>>0];return et.varargs+=4,n},Wt=Zt,z={isAbs:n=>n.charAt(0)==="/",splitPath:n=>{var a=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return a.exec(n).slice(1)},normalizeArray:(n,a)=>{for(var i=0,d=n.length-1;d>=0;d--){var u=n[d];u==="."?n.splice(d,1):u===".."?(n.splice(d,1),i++):i&&(n.splice(d,1),i--)}if(a)for(;i;i--)n.unshift("..");return n},normalize:n=>{var a=z.isAbs(n),i=n.slice(-1)==="/";return n=z.normalizeArray(n.split("/").filter(d=>!!d),!a).join("/"),!n&&!a&&(n="."),n&&i&&(n+="/"),(a?"/":"")+n},dirname:n=>{var a=z.splitPath(n),i=a[0],d=a[1];return!i&&!d?".":(d&&(d=d.slice(0,-1)),i+d)},basename:n=>n&&n.match(/([^\/]+|\/)\/*$/)[1],join:(...n)=>z.normalize(n.join("/")),join2:(n,a)=>z.normalize(n+"/"+a)},Pe=()=>{if(g){var n=y("crypto");return a=>n.randomFillSync(a)}return a=>crypto.getRandomValues(a)},qt=n=>{(qt=Pe())(n)},St={resolve:(...n)=>{for(var a="",i=!1,d=n.length-1;d>=-1&&!i;d--){var u=d>=0?n[d]:c.cwd();if(typeof u!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!u)return"";a=u+"/"+a,i=z.isAbs(u)}return a=z.normalizeArray(a.split("/").filter(E=>!!E),!i).join("/"),(i?"/":"")+a||"."},relative:(n,a)=>{n=St.resolve(n).slice(1),a=St.resolve(a).slice(1);function i(D){for(var R=0;R<D.length&&D[R]==="";R++);for(var N=D.length-1;N>=0&&D[N]==="";N--);return R>N?[]:D.slice(R,N-R+1)}for(var d=i(n.split("/")),u=i(a.split("/")),E=Math.min(d.length,u.length),A=E,p=0;p<E;p++)if(d[p]!==u[p]){A=p;break}for(var m=[],p=A;p<d.length;p++)m.push("..");return m=m.concat(u.slice(A)),m.join("/")}},se=typeof TextDecoder<"u"?new TextDecoder:void 0,Lt=(n,a=0,i=NaN)=>{a>>>=0;for(var d=a+i,u=a;n[u]&&!(u>=d);)++u;if(u-a>16&&n.buffer&&se)return se.decode(n.subarray(a,u));for(var E="";a<u;){var A=n[a++];if(!(A&128)){E+=String.fromCharCode(A);continue}var p=n[a++]&63;if((A&224)==192){E+=String.fromCharCode((A&31)<<6|p);continue}var m=n[a++]&63;if((A&240)==224?A=(A&15)<<12|p<<6|m:A=(A&7)<<18|p<<12|m<<6|n[a++]&63,A<65536)E+=String.fromCharCode(A);else{var D=A-65536;E+=String.fromCharCode(55296|D>>10,56320|D&1023)}}return E},Qt=[],Gt=n=>{for(var a=0,i=0;i<n.length;++i){var d=n.charCodeAt(i);d<=127?a++:d<=2047?a+=2:d>=55296&&d<=57343?(a+=4,++i):a+=3}return a},jt=(n,a,i,d)=>{if(i>>>=0,!(d>0))return 0;for(var u=i,E=i+d-1,A=0;A<n.length;++A){var p=n.charCodeAt(A);if(p>=55296&&p<=57343){var m=n.charCodeAt(++A);p=65536+((p&1023)<<10)|m&1023}if(p<=127){if(i>=E)break;a[i++>>>0]=p}else if(p<=2047){if(i+1>=E)break;a[i++>>>0]=192|p>>6,a[i++>>>0]=128|p&63}else if(p<=65535){if(i+2>=E)break;a[i++>>>0]=224|p>>12,a[i++>>>0]=128|p>>6&63,a[i++>>>0]=128|p&63}else{if(i+3>=E)break;a[i++>>>0]=240|p>>18,a[i++>>>0]=128|p>>12&63,a[i++>>>0]=128|p>>6&63,a[i++>>>0]=128|p&63}}return a[i>>>0]=0,i-u},_e=(n,a,i)=>{var d=Gt(n)+1,u=new Array(d),E=jt(n,u,0,u.length);return u.length=E,u},ve=()=>{if(!Qt.length){var n=null;if(g){var a=256,i=Buffer.alloc(a),d=0,u=process.stdin.fd;try{d=L.readSync(u,i,0,a)}catch(E){if(E.toString().includes("EOF"))d=0;else throw E}d>0&&(n=i.slice(0,d).toString("utf-8"))}else typeof window<"u"&&typeof window.prompt=="function"&&(n=window.prompt("Input: "),n!==null&&(n+=`
|
|
2
|
-
`));if(!n)return null;Qt=_e(n)}return Qt.shift()},Tt={ttys:[],init(){},shutdown(){},register(n,a){Tt.ttys[n]={input:[],output:[],ops:a},c.registerDevice(n,Tt.stream_ops)},stream_ops:{open(n){var a=Tt.ttys[n.node.rdev];if(!a)throw new c.ErrnoError(43);n.tty=a,n.seekable=!1},close(n){n.tty.ops.fsync(n.tty)},fsync(n){n.tty.ops.fsync(n.tty)},read(n,a,i,d,u){if(!n.tty||!n.tty.ops.get_char)throw new c.ErrnoError(60);for(var E=0,A=0;A<d;A++){var p;try{p=n.tty.ops.get_char(n.tty)}catch{throw new c.ErrnoError(29)}if(p===void 0&&E===0)throw new c.ErrnoError(6);if(p==null)break;E++,a[i+A]=p}return E&&(n.node.atime=Date.now()),E},write(n,a,i,d,u){if(!n.tty||!n.tty.ops.put_char)throw new c.ErrnoError(60);try{for(var E=0;E<d;E++)n.tty.ops.put_char(n.tty,a[i+E])}catch{throw new c.ErrnoError(29)}return d&&(n.node.mtime=n.node.ctime=Date.now()),E}},default_tty_ops:{get_char(n){return ve()},put_char(n,a){a===null||a===10?(M(Lt(n.output)),n.output=[]):a!=0&&n.output.push(a)},fsync(n){var a;((a=n.output)==null?void 0:a.length)>0&&(M(Lt(n.output)),n.output=[])},ioctl_tcgets(n){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets(n,a,i){return 0},ioctl_tiocgwinsz(n){return[24,80]}},default_tty1_ops:{put_char(n,a){a===null||a===10?(b(Lt(n.output)),n.output=[]):a!=0&&n.output.push(a)},fsync(n){var a;((a=n.output)==null?void 0:a.length)>0&&(b(Lt(n.output)),n.output=[])}}},me=(n,a)=>Math.ceil(n/a)*a,de=n=>{Nt()},B={ops_table:null,mount(n){return B.createNode(null,"/",16895,0)},createNode(n,a,i,d){if(c.isBlkdev(i)||c.isFIFO(i))throw new c.ErrnoError(63);B.ops_table||(B.ops_table={dir:{node:{getattr:B.node_ops.getattr,setattr:B.node_ops.setattr,lookup:B.node_ops.lookup,mknod:B.node_ops.mknod,rename:B.node_ops.rename,unlink:B.node_ops.unlink,rmdir:B.node_ops.rmdir,readdir:B.node_ops.readdir,symlink:B.node_ops.symlink},stream:{llseek:B.stream_ops.llseek}},file:{node:{getattr:B.node_ops.getattr,setattr:B.node_ops.setattr},stream:{llseek:B.stream_ops.llseek,read:B.stream_ops.read,write:B.stream_ops.write,allocate:B.stream_ops.allocate,mmap:B.stream_ops.mmap,msync:B.stream_ops.msync}},link:{node:{getattr:B.node_ops.getattr,setattr:B.node_ops.setattr,readlink:B.node_ops.readlink},stream:{}},chrdev:{node:{getattr:B.node_ops.getattr,setattr:B.node_ops.setattr},stream:c.chrdev_stream_ops}});var u=c.createNode(n,a,i,d);return c.isDir(u.mode)?(u.node_ops=B.ops_table.dir.node,u.stream_ops=B.ops_table.dir.stream,u.contents={}):c.isFile(u.mode)?(u.node_ops=B.ops_table.file.node,u.stream_ops=B.ops_table.file.stream,u.usedBytes=0,u.contents=null):c.isLink(u.mode)?(u.node_ops=B.ops_table.link.node,u.stream_ops=B.ops_table.link.stream):c.isChrdev(u.mode)&&(u.node_ops=B.ops_table.chrdev.node,u.stream_ops=B.ops_table.chrdev.stream),u.atime=u.mtime=u.ctime=Date.now(),n&&(n.contents[a]=u,n.atime=n.mtime=n.ctime=u.atime),u},getFileDataAsTypedArray(n){return n.contents?n.contents.subarray?n.contents.subarray(0,n.usedBytes):new Uint8Array(n.contents):new Uint8Array(0)},expandFileStorage(n,a){var i=n.contents?n.contents.length:0;if(!(i>=a)){var d=1024*1024;a=Math.max(a,i*(i<d?2:1.125)>>>0),i!=0&&(a=Math.max(a,256));var u=n.contents;n.contents=new Uint8Array(a),n.usedBytes>0&&n.contents.set(u.subarray(0,n.usedBytes),0)}},resizeFileStorage(n,a){if(n.usedBytes!=a)if(a==0)n.contents=null,n.usedBytes=0;else{var i=n.contents;n.contents=new Uint8Array(a),i&&n.contents.set(i.subarray(0,Math.min(a,n.usedBytes))),n.usedBytes=a}},node_ops:{getattr(n){var a={};return a.dev=c.isChrdev(n.mode)?n.id:1,a.ino=n.id,a.mode=n.mode,a.nlink=1,a.uid=0,a.gid=0,a.rdev=n.rdev,c.isDir(n.mode)?a.size=4096:c.isFile(n.mode)?a.size=n.usedBytes:c.isLink(n.mode)?a.size=n.link.length:a.size=0,a.atime=new Date(n.atime),a.mtime=new Date(n.mtime),a.ctime=new Date(n.ctime),a.blksize=4096,a.blocks=Math.ceil(a.size/a.blksize),a},setattr(n,a){for(const i of["mode","atime","mtime","ctime"])a[i]!=null&&(n[i]=a[i]);a.size!==void 0&&B.resizeFileStorage(n,a.size)},lookup(n,a){throw B.doesNotExistError},mknod(n,a,i,d){return B.createNode(n,a,i,d)},rename(n,a,i){var d;try{d=c.lookupNode(a,i)}catch{}if(d){if(c.isDir(n.mode))for(var u in d.contents)throw new c.ErrnoError(55);c.hashRemoveNode(d)}delete n.parent.contents[n.name],a.contents[i]=n,n.name=i,a.ctime=a.mtime=n.parent.ctime=n.parent.mtime=Date.now()},unlink(n,a){delete n.contents[a],n.ctime=n.mtime=Date.now()},rmdir(n,a){var i=c.lookupNode(n,a);for(var d in i.contents)throw new c.ErrnoError(55);delete n.contents[a],n.ctime=n.mtime=Date.now()},readdir(n){return[".","..",...Object.keys(n.contents)]},symlink(n,a,i){var d=B.createNode(n,a,41471,0);return d.link=i,d},readlink(n){if(!c.isLink(n.mode))throw new c.ErrnoError(28);return n.link}},stream_ops:{read(n,a,i,d,u){var E=n.node.contents;if(u>=n.node.usedBytes)return 0;var A=Math.min(n.node.usedBytes-u,d);if(A>8&&E.subarray)a.set(E.subarray(u,u+A),i);else for(var p=0;p<A;p++)a[i+p]=E[u+p];return A},write(n,a,i,d,u,E){if(a.buffer===U.buffer&&(E=!1),!d)return 0;var A=n.node;if(A.mtime=A.ctime=Date.now(),a.subarray&&(!A.contents||A.contents.subarray)){if(E)return A.contents=a.subarray(i,i+d),A.usedBytes=d,d;if(A.usedBytes===0&&u===0)return A.contents=a.slice(i,i+d),A.usedBytes=d,d;if(u+d<=A.usedBytes)return A.contents.set(a.subarray(i,i+d),u),d}if(B.expandFileStorage(A,u+d),A.contents.subarray&&a.subarray)A.contents.set(a.subarray(i,i+d),u);else for(var p=0;p<d;p++)A.contents[u+p]=a[i+p];return A.usedBytes=Math.max(A.usedBytes,u+d),d},llseek(n,a,i){var d=a;if(i===1?d+=n.position:i===2&&c.isFile(n.node.mode)&&(d+=n.node.usedBytes),d<0)throw new c.ErrnoError(28);return d},allocate(n,a,i){B.expandFileStorage(n.node,a+i),n.node.usedBytes=Math.max(n.node.usedBytes,a+i)},mmap(n,a,i,d,u){if(!c.isFile(n.node.mode))throw new c.ErrnoError(43);var E,A,p=n.node.contents;if(!(u&2)&&p&&p.buffer===U.buffer)A=!1,E=p.byteOffset;else{if(A=!0,E=de(),!E)throw new c.ErrnoError(48);p&&((i>0||i+a<p.length)&&(p.subarray?p=p.subarray(i,i+a):p=Array.prototype.slice.call(p,i,i+a)),U.set(p,E>>>0))}return{ptr:E,allocated:A}},msync(n,a,i,d,u){return B.stream_ops.write(n,a,0,d,i,!1),0}}},Ie=async n=>{var a=await w(n);return new Uint8Array(a)},we=(n,a,i,d,u,E)=>{c.createDataFile(n,a,i,d,u,E)},Ce=e.preloadPlugins||[],De=(n,a,i,d)=>{typeof Browser<"u"&&Browser.init();var u=!1;return Ce.forEach(E=>{u||E.canHandle(a)&&(E.handle(n,a,i,d),u=!0)}),u},Je=(n,a,i,d,u,E,A,p,m,D)=>{var R=a?St.resolve(z.join2(n,a)):n;function N(k){function G(x){D==null||D(),p||we(n,a,x,d,u,m),E==null||E(),kt()}De(k,R,G,()=>{A==null||A(),kt()})||G(k)}Jt(),typeof i=="string"?Ie(i).then(N,A):N(i)},Ze=n=>{var a={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},i=a[n];if(typeof i>"u")throw new Error(`Unknown file open mode: ${n}`);return i},Re=(n,a)=>{var i=0;return n&&(i|=365),a&&(i|=146),i},c={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:class{constructor(n){bt(this,"name","ErrnoError");this.errno=n}},filesystems:null,syncFSRequests:0,readFiles:{},FSStream:class{constructor(){bt(this,"shared",{})}get object(){return this.node}set object(n){this.node=n}get isRead(){return(this.flags&2097155)!==1}get isWrite(){return(this.flags&2097155)!==0}get isAppend(){return this.flags&1024}get flags(){return this.shared.flags}set flags(n){this.shared.flags=n}get position(){return this.shared.position}set position(n){this.shared.position=n}},FSNode:class{constructor(n,a,i,d){bt(this,"node_ops",{});bt(this,"stream_ops",{});bt(this,"readMode",365);bt(this,"writeMode",146);bt(this,"mounted",null);n||(n=this),this.parent=n,this.mount=n.mount,this.id=c.nextInode++,this.name=a,this.mode=i,this.rdev=d,this.atime=this.mtime=this.ctime=Date.now()}get read(){return(this.mode&this.readMode)===this.readMode}set read(n){n?this.mode|=this.readMode:this.mode&=~this.readMode}get write(){return(this.mode&this.writeMode)===this.writeMode}set write(n){n?this.mode|=this.writeMode:this.mode&=~this.writeMode}get isFolder(){return c.isDir(this.mode)}get isDevice(){return c.isChrdev(this.mode)}},lookupPath(n,a={}){if(!n)throw new c.ErrnoError(44);a.follow_mount??(a.follow_mount=!0),z.isAbs(n)||(n=c.cwd()+"/"+n);t:for(var i=0;i<40;i++){for(var d=n.split("/").filter(D=>!!D),u=c.root,E="/",A=0;A<d.length;A++){var p=A===d.length-1;if(p&&a.parent)break;if(d[A]!=="."){if(d[A]===".."){E=z.dirname(E),u=u.parent;continue}E=z.join2(E,d[A]);try{u=c.lookupNode(u,d[A])}catch(D){if((D==null?void 0:D.errno)===44&&p&&a.noent_okay)return{path:E};throw D}if(c.isMountpoint(u)&&(!p||a.follow_mount)&&(u=u.mounted.root),c.isLink(u.mode)&&(!p||a.follow)){if(!u.node_ops.readlink)throw new c.ErrnoError(52);var m=u.node_ops.readlink(u);z.isAbs(m)||(m=z.dirname(E)+"/"+m),n=m+"/"+d.slice(A+1).join("/");continue t}}}return{path:E,node:u}}throw new c.ErrnoError(32)},getPath(n){for(var a;;){if(c.isRoot(n)){var i=n.mount.mountpoint;return a?i[i.length-1]!=="/"?`${i}/${a}`:i+a:i}a=a?`${n.name}/${a}`:n.name,n=n.parent}},hashName(n,a){for(var i=0,d=0;d<a.length;d++)i=(i<<5)-i+a.charCodeAt(d)|0;return(n+i>>>0)%c.nameTable.length},hashAddNode(n){var a=c.hashName(n.parent.id,n.name);n.name_next=c.nameTable[a],c.nameTable[a]=n},hashRemoveNode(n){var a=c.hashName(n.parent.id,n.name);if(c.nameTable[a]===n)c.nameTable[a]=n.name_next;else for(var i=c.nameTable[a];i;){if(i.name_next===n){i.name_next=n.name_next;break}i=i.name_next}},lookupNode(n,a){var i=c.mayLookup(n);if(i)throw new c.ErrnoError(i);for(var d=c.hashName(n.id,a),u=c.nameTable[d];u;u=u.name_next){var E=u.name;if(u.parent.id===n.id&&E===a)return u}return c.lookup(n,a)},createNode(n,a,i,d){var u=new c.FSNode(n,a,i,d);return c.hashAddNode(u),u},destroyNode(n){c.hashRemoveNode(n)},isRoot(n){return n===n.parent},isMountpoint(n){return!!n.mounted},isFile(n){return(n&61440)===32768},isDir(n){return(n&61440)===16384},isLink(n){return(n&61440)===40960},isChrdev(n){return(n&61440)===8192},isBlkdev(n){return(n&61440)===24576},isFIFO(n){return(n&61440)===4096},isSocket(n){return(n&49152)===49152},flagsToPermissionString(n){var a=["r","w","rw"][n&3];return n&512&&(a+="w"),a},nodePermissions(n,a){return c.ignorePermissions?0:a.includes("r")&&!(n.mode&292)||a.includes("w")&&!(n.mode&146)||a.includes("x")&&!(n.mode&73)?2:0},mayLookup(n){if(!c.isDir(n.mode))return 54;var a=c.nodePermissions(n,"x");return a||(n.node_ops.lookup?0:2)},mayCreate(n,a){if(!c.isDir(n.mode))return 54;try{var i=c.lookupNode(n,a);return 20}catch{}return c.nodePermissions(n,"wx")},mayDelete(n,a,i){var d;try{d=c.lookupNode(n,a)}catch(E){return E.errno}var u=c.nodePermissions(n,"wx");if(u)return u;if(i){if(!c.isDir(d.mode))return 54;if(c.isRoot(d)||c.getPath(d)===c.cwd())return 10}else if(c.isDir(d.mode))return 31;return 0},mayOpen(n,a){return n?c.isLink(n.mode)?32:c.isDir(n.mode)&&(c.flagsToPermissionString(a)!=="r"||a&576)?31:c.nodePermissions(n,c.flagsToPermissionString(a)):44},checkOpExists(n,a){if(!n)throw new c.ErrnoError(a);return n},MAX_OPEN_FDS:4096,nextfd(){for(var n=0;n<=c.MAX_OPEN_FDS;n++)if(!c.streams[n])return n;throw new c.ErrnoError(33)},getStreamChecked(n){var a=c.getStream(n);if(!a)throw new c.ErrnoError(8);return a},getStream:n=>c.streams[n],createStream(n,a=-1){return n=Object.assign(new c.FSStream,n),a==-1&&(a=c.nextfd()),n.fd=a,c.streams[a]=n,n},closeStream(n){c.streams[n]=null},dupStream(n,a=-1){var d,u;var i=c.createStream(n,a);return(u=(d=i.stream_ops)==null?void 0:d.dup)==null||u.call(d,i),i},doSetAttr(n,a,i){var d=n==null?void 0:n.stream_ops.setattr,u=d?n:a;d??(d=a.node_ops.setattr),c.checkOpExists(d,63),d(u,i)},chrdev_stream_ops:{open(n){var i,d;var a=c.getDevice(n.node.rdev);n.stream_ops=a.stream_ops,(d=(i=n.stream_ops).open)==null||d.call(i,n)},llseek(){throw new c.ErrnoError(70)}},major:n=>n>>8,minor:n=>n&255,makedev:(n,a)=>n<<8|a,registerDevice(n,a){c.devices[n]={stream_ops:a}},getDevice:n=>c.devices[n],getMounts(n){for(var a=[],i=[n];i.length;){var d=i.pop();a.push(d),i.push(...d.mounts)}return a},syncfs(n,a){typeof n=="function"&&(a=n,n=!1),c.syncFSRequests++,c.syncFSRequests>1&&b(`warning: ${c.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var i=c.getMounts(c.root.mount),d=0;function u(A){return c.syncFSRequests--,a(A)}function E(A){if(A)return E.errored?void 0:(E.errored=!0,u(A));++d>=i.length&&u(null)}i.forEach(A=>{if(!A.type.syncfs)return E(null);A.type.syncfs(A,n,E)})},mount(n,a,i){var d=i==="/",u=!i,E;if(d&&c.root)throw new c.ErrnoError(10);if(!d&&!u){var A=c.lookupPath(i,{follow_mount:!1});if(i=A.path,E=A.node,c.isMountpoint(E))throw new c.ErrnoError(10);if(!c.isDir(E.mode))throw new c.ErrnoError(54)}var p={type:n,opts:a,mountpoint:i,mounts:[]},m=n.mount(p);return m.mount=p,p.root=m,d?c.root=m:E&&(E.mounted=p,E.mount&&E.mount.mounts.push(p)),m},unmount(n){var a=c.lookupPath(n,{follow_mount:!1});if(!c.isMountpoint(a.node))throw new c.ErrnoError(28);var i=a.node,d=i.mounted,u=c.getMounts(d);Object.keys(c.nameTable).forEach(A=>{for(var p=c.nameTable[A];p;){var m=p.name_next;u.includes(p.mount)&&c.destroyNode(p),p=m}}),i.mounted=null;var E=i.mount.mounts.indexOf(d);i.mount.mounts.splice(E,1)},lookup(n,a){return n.node_ops.lookup(n,a)},mknod(n,a,i){var d=c.lookupPath(n,{parent:!0}),u=d.node,E=z.basename(n);if(!E)throw new c.ErrnoError(28);if(E==="."||E==="..")throw new c.ErrnoError(20);var A=c.mayCreate(u,E);if(A)throw new c.ErrnoError(A);if(!u.node_ops.mknod)throw new c.ErrnoError(63);return u.node_ops.mknod(u,E,a,i)},statfs(n){return c.statfsNode(c.lookupPath(n,{follow:!0}).node)},statfsStream(n){return c.statfsNode(n.node)},statfsNode(n){var a={bsize:4096,frsize:4096,blocks:1e6,bfree:5e5,bavail:5e5,files:c.nextInode,ffree:c.nextInode-1,fsid:42,flags:2,namelen:255};return n.node_ops.statfs&&Object.assign(a,n.node_ops.statfs(n.mount.opts.root)),a},create(n,a=438){return a&=4095,a|=32768,c.mknod(n,a,0)},mkdir(n,a=511){return a&=1023,a|=16384,c.mknod(n,a,0)},mkdirTree(n,a){for(var i=n.split("/"),d="",u=0;u<i.length;++u)if(i[u]){d+="/"+i[u];try{c.mkdir(d,a)}catch(E){if(E.errno!=20)throw E}}},mkdev(n,a,i){return typeof i>"u"&&(i=a,a=438),a|=8192,c.mknod(n,a,i)},symlink(n,a){if(!St.resolve(n))throw new c.ErrnoError(44);var i=c.lookupPath(a,{parent:!0}),d=i.node;if(!d)throw new c.ErrnoError(44);var u=z.basename(a),E=c.mayCreate(d,u);if(E)throw new c.ErrnoError(E);if(!d.node_ops.symlink)throw new c.ErrnoError(63);return d.node_ops.symlink(d,u,n)},rename(n,a){var i=z.dirname(n),d=z.dirname(a),u=z.basename(n),E=z.basename(a),A,p,m;if(A=c.lookupPath(n,{parent:!0}),p=A.node,A=c.lookupPath(a,{parent:!0}),m=A.node,!p||!m)throw new c.ErrnoError(44);if(p.mount!==m.mount)throw new c.ErrnoError(75);var D=c.lookupNode(p,u),R=St.relative(n,d);if(R.charAt(0)!==".")throw new c.ErrnoError(28);if(R=St.relative(a,i),R.charAt(0)!==".")throw new c.ErrnoError(55);var N;try{N=c.lookupNode(m,E)}catch{}if(D!==N){var k=c.isDir(D.mode),G=c.mayDelete(p,u,k);if(G)throw new c.ErrnoError(G);if(G=N?c.mayDelete(m,E,k):c.mayCreate(m,E),G)throw new c.ErrnoError(G);if(!p.node_ops.rename)throw new c.ErrnoError(63);if(c.isMountpoint(D)||N&&c.isMountpoint(N))throw new c.ErrnoError(10);if(m!==p&&(G=c.nodePermissions(p,"w"),G))throw new c.ErrnoError(G);c.hashRemoveNode(D);try{p.node_ops.rename(D,m,E),D.parent=m}catch(x){throw x}finally{c.hashAddNode(D)}}},rmdir(n){var a=c.lookupPath(n,{parent:!0}),i=a.node,d=z.basename(n),u=c.lookupNode(i,d),E=c.mayDelete(i,d,!0);if(E)throw new c.ErrnoError(E);if(!i.node_ops.rmdir)throw new c.ErrnoError(63);if(c.isMountpoint(u))throw new c.ErrnoError(10);i.node_ops.rmdir(i,d),c.destroyNode(u)},readdir(n){var a=c.lookupPath(n,{follow:!0}),i=a.node,d=c.checkOpExists(i.node_ops.readdir,54);return d(i)},unlink(n){var a=c.lookupPath(n,{parent:!0}),i=a.node;if(!i)throw new c.ErrnoError(44);var d=z.basename(n),u=c.lookupNode(i,d),E=c.mayDelete(i,d,!1);if(E)throw new c.ErrnoError(E);if(!i.node_ops.unlink)throw new c.ErrnoError(63);if(c.isMountpoint(u))throw new c.ErrnoError(10);i.node_ops.unlink(i,d),c.destroyNode(u)},readlink(n){var a=c.lookupPath(n),i=a.node;if(!i)throw new c.ErrnoError(44);if(!i.node_ops.readlink)throw new c.ErrnoError(28);return i.node_ops.readlink(i)},stat(n,a){var i=c.lookupPath(n,{follow:!a}),d=i.node,u=c.checkOpExists(d.node_ops.getattr,63);return u(d)},fstat(n){var a=c.getStreamChecked(n),i=a.node,d=a.stream_ops.getattr,u=d?a:i;return d??(d=i.node_ops.getattr),c.checkOpExists(d,63),d(u)},lstat(n){return c.stat(n,!0)},doChmod(n,a,i,d){c.doSetAttr(n,a,{mode:i&4095|a.mode&-4096,ctime:Date.now(),dontFollow:d})},chmod(n,a,i){var d;if(typeof n=="string"){var u=c.lookupPath(n,{follow:!i});d=u.node}else d=n;c.doChmod(null,d,a,i)},lchmod(n,a){c.chmod(n,a,!0)},fchmod(n,a){var i=c.getStreamChecked(n);c.doChmod(i,i.node,a,!1)},doChown(n,a,i){c.doSetAttr(n,a,{timestamp:Date.now(),dontFollow:i})},chown(n,a,i,d){var u;if(typeof n=="string"){var E=c.lookupPath(n,{follow:!d});u=E.node}else u=n;c.doChown(null,u,d)},lchown(n,a,i){c.chown(n,a,i,!0)},fchown(n,a,i){var d=c.getStreamChecked(n);c.doChown(d,d.node,!1)},doTruncate(n,a,i){if(c.isDir(a.mode))throw new c.ErrnoError(31);if(!c.isFile(a.mode))throw new c.ErrnoError(28);var d=c.nodePermissions(a,"w");if(d)throw new c.ErrnoError(d);c.doSetAttr(n,a,{size:i,timestamp:Date.now()})},truncate(n,a){if(a<0)throw new c.ErrnoError(28);var i;if(typeof n=="string"){var d=c.lookupPath(n,{follow:!0});i=d.node}else i=n;c.doTruncate(null,i,a)},ftruncate(n,a){var i=c.getStreamChecked(n);if(a<0||(i.flags&2097155)===0)throw new c.ErrnoError(28);c.doTruncate(i,i.node,a)},utime(n,a,i){var d=c.lookupPath(n,{follow:!0}),u=d.node,E=c.checkOpExists(u.node_ops.setattr,63);E(u,{atime:a,mtime:i})},open(n,a,i=438){if(n==="")throw new c.ErrnoError(44);a=typeof a=="string"?Ze(a):a,a&64?i=i&4095|32768:i=0;var d,u;if(typeof n=="object")d=n;else{u=n.endsWith("/");var E=c.lookupPath(n,{follow:!(a&131072),noent_okay:!0});d=E.node,n=E.path}var A=!1;if(a&64)if(d){if(a&128)throw new c.ErrnoError(20)}else{if(u)throw new c.ErrnoError(31);d=c.mknod(n,i|511,0),A=!0}if(!d)throw new c.ErrnoError(44);if(c.isChrdev(d.mode)&&(a&=-513),a&65536&&!c.isDir(d.mode))throw new c.ErrnoError(54);if(!A){var p=c.mayOpen(d,a);if(p)throw new c.ErrnoError(p)}a&512&&!A&&c.truncate(d,0),a&=-131713;var m=c.createStream({node:d,path:c.getPath(d),flags:a,seekable:!0,position:0,stream_ops:d.stream_ops,ungotten:[],error:!1});return m.stream_ops.open&&m.stream_ops.open(m),A&&c.chmod(d,i&511),e.logReadFiles&&!(a&1)&&(n in c.readFiles||(c.readFiles[n]=1)),m},close(n){if(c.isClosed(n))throw new c.ErrnoError(8);n.getdents&&(n.getdents=null);try{n.stream_ops.close&&n.stream_ops.close(n)}catch(a){throw a}finally{c.closeStream(n.fd)}n.fd=null},isClosed(n){return n.fd===null},llseek(n,a,i){if(c.isClosed(n))throw new c.ErrnoError(8);if(!n.seekable||!n.stream_ops.llseek)throw new c.ErrnoError(70);if(i!=0&&i!=1&&i!=2)throw new c.ErrnoError(28);return n.position=n.stream_ops.llseek(n,a,i),n.ungotten=[],n.position},read(n,a,i,d,u){if(d<0||u<0)throw new c.ErrnoError(28);if(c.isClosed(n))throw new c.ErrnoError(8);if((n.flags&2097155)===1)throw new c.ErrnoError(8);if(c.isDir(n.node.mode))throw new c.ErrnoError(31);if(!n.stream_ops.read)throw new c.ErrnoError(28);var E=typeof u<"u";if(!E)u=n.position;else if(!n.seekable)throw new c.ErrnoError(70);var A=n.stream_ops.read(n,a,i,d,u);return E||(n.position+=A),A},write(n,a,i,d,u,E){if(d<0||u<0)throw new c.ErrnoError(28);if(c.isClosed(n))throw new c.ErrnoError(8);if((n.flags&2097155)===0)throw new c.ErrnoError(8);if(c.isDir(n.node.mode))throw new c.ErrnoError(31);if(!n.stream_ops.write)throw new c.ErrnoError(28);n.seekable&&n.flags&1024&&c.llseek(n,0,2);var A=typeof u<"u";if(!A)u=n.position;else if(!n.seekable)throw new c.ErrnoError(70);var p=n.stream_ops.write(n,a,i,d,u,E);return A||(n.position+=p),p},allocate(n,a,i){if(c.isClosed(n))throw new c.ErrnoError(8);if(a<0||i<=0)throw new c.ErrnoError(28);if((n.flags&2097155)===0)throw new c.ErrnoError(8);if(!c.isFile(n.node.mode)&&!c.isDir(n.node.mode))throw new c.ErrnoError(43);if(!n.stream_ops.allocate)throw new c.ErrnoError(138);n.stream_ops.allocate(n,a,i)},mmap(n,a,i,d,u){if((d&2)!==0&&(u&2)===0&&(n.flags&2097155)!==2)throw new c.ErrnoError(2);if((n.flags&2097155)===1)throw new c.ErrnoError(2);if(!n.stream_ops.mmap)throw new c.ErrnoError(43);if(!a)throw new c.ErrnoError(28);return n.stream_ops.mmap(n,a,i,d,u)},msync(n,a,i,d,u){return n.stream_ops.msync?n.stream_ops.msync(n,a,i,d,u):0},ioctl(n,a,i){if(!n.stream_ops.ioctl)throw new c.ErrnoError(59);return n.stream_ops.ioctl(n,a,i)},readFile(n,a={}){if(a.flags=a.flags||0,a.encoding=a.encoding||"binary",a.encoding!=="utf8"&&a.encoding!=="binary")throw new Error(`Invalid encoding type "${a.encoding}"`);var i,d=c.open(n,a.flags),u=c.stat(n),E=u.size,A=new Uint8Array(E);return c.read(d,A,0,E,0),a.encoding==="utf8"?i=Lt(A):a.encoding==="binary"&&(i=A),c.close(d),i},writeFile(n,a,i={}){i.flags=i.flags||577;var d=c.open(n,i.flags,i.mode);if(typeof a=="string"){var u=new Uint8Array(Gt(a)+1),E=jt(a,u,0,u.length);c.write(d,u,0,E,void 0,i.canOwn)}else if(ArrayBuffer.isView(a))c.write(d,a,0,a.byteLength,void 0,i.canOwn);else throw new Error("Unsupported data type");c.close(d)},cwd:()=>c.currentPath,chdir(n){var a=c.lookupPath(n,{follow:!0});if(a.node===null)throw new c.ErrnoError(44);if(!c.isDir(a.node.mode))throw new c.ErrnoError(54);var i=c.nodePermissions(a.node,"x");if(i)throw new c.ErrnoError(i);c.currentPath=a.path},createDefaultDirectories(){c.mkdir("/tmp"),c.mkdir("/home"),c.mkdir("/home/web_user")},createDefaultDevices(){c.mkdir("/dev"),c.registerDevice(c.makedev(1,3),{read:()=>0,write:(d,u,E,A,p)=>A,llseek:()=>0}),c.mkdev("/dev/null",c.makedev(1,3)),Tt.register(c.makedev(5,0),Tt.default_tty_ops),Tt.register(c.makedev(6,0),Tt.default_tty1_ops),c.mkdev("/dev/tty",c.makedev(5,0)),c.mkdev("/dev/tty1",c.makedev(6,0));var n=new Uint8Array(1024),a=0,i=()=>(a===0&&(qt(n),a=n.byteLength),n[--a]);c.createDevice("/dev","random",i),c.createDevice("/dev","urandom",i),c.mkdir("/dev/shm"),c.mkdir("/dev/shm/tmp")},createSpecialDirectories(){c.mkdir("/proc");var n=c.mkdir("/proc/self");c.mkdir("/proc/self/fd"),c.mount({mount(){var a=c.createNode(n,"fd",16895,73);return a.stream_ops={llseek:B.stream_ops.llseek},a.node_ops={lookup(i,d){var u=+d,E=c.getStreamChecked(u),A={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>E.path},id:u+1};return A.parent=A,A},readdir(){return Array.from(c.streams.entries()).filter(([i,d])=>d).map(([i,d])=>i.toString())}},a}},{},"/proc/self/fd")},createStandardStreams(n,a,i){n?c.createDevice("/dev","stdin",n):c.symlink("/dev/tty","/dev/stdin"),a?c.createDevice("/dev","stdout",null,a):c.symlink("/dev/tty","/dev/stdout"),i?c.createDevice("/dev","stderr",null,i):c.symlink("/dev/tty1","/dev/stderr"),c.open("/dev/stdin",0),c.open("/dev/stdout",1),c.open("/dev/stderr",1)},staticInit(){c.nameTable=new Array(4096),c.mount(B,{},"/"),c.createDefaultDirectories(),c.createDefaultDevices(),c.createSpecialDirectories(),c.filesystems={MEMFS:B}},init(n,a,i){c.initialized=!0,n??(n=e.stdin),a??(a=e.stdout),i??(i=e.stderr),c.createStandardStreams(n,a,i)},quit(){c.initialized=!1;for(var n=0;n<c.streams.length;n++){var a=c.streams[n];a&&c.close(a)}},findObject(n,a){var i=c.analyzePath(n,a);return i.exists?i.object:null},analyzePath(n,a){try{var i=c.lookupPath(n,{follow:!a});n=i.path}catch{}var d={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var i=c.lookupPath(n,{parent:!0});d.parentExists=!0,d.parentPath=i.path,d.parentObject=i.node,d.name=z.basename(n),i=c.lookupPath(n,{follow:!a}),d.exists=!0,d.path=i.path,d.object=i.node,d.name=i.node.name,d.isRoot=i.path==="/"}catch(u){d.error=u.errno}return d},createPath(n,a,i,d){n=typeof n=="string"?n:c.getPath(n);for(var u=a.split("/").reverse();u.length;){var E=u.pop();if(E){var A=z.join2(n,E);try{c.mkdir(A)}catch{}n=A}}return A},createFile(n,a,i,d,u){var E=z.join2(typeof n=="string"?n:c.getPath(n),a),A=Re(d,u);return c.create(E,A)},createDataFile(n,a,i,d,u,E){var A=a;n&&(n=typeof n=="string"?n:c.getPath(n),A=a?z.join2(n,a):n);var p=Re(d,u),m=c.create(A,p);if(i){if(typeof i=="string"){for(var D=new Array(i.length),R=0,N=i.length;R<N;++R)D[R]=i.charCodeAt(R);i=D}c.chmod(m,p|146);var k=c.open(m,577);c.write(k,i,0,i.length,0,E),c.close(k),c.chmod(m,p)}},createDevice(n,a,i,d){var p;var u=z.join2(typeof n=="string"?n:c.getPath(n),a),E=Re(!!i,!!d);(p=c.createDevice).major??(p.major=64);var A=c.makedev(c.createDevice.major++,0);return c.registerDevice(A,{open(m){m.seekable=!1},close(m){var D;(D=d==null?void 0:d.buffer)!=null&&D.length&&d(10)},read(m,D,R,N,k){for(var G=0,x=0;x<N;x++){var K;try{K=i()}catch{throw new c.ErrnoError(29)}if(K===void 0&&G===0)throw new c.ErrnoError(6);if(K==null)break;G++,D[R+x]=K}return G&&(m.node.atime=Date.now()),G},write(m,D,R,N,k){for(var G=0;G<N;G++)try{d(D[R+G])}catch{throw new c.ErrnoError(29)}return N&&(m.node.mtime=m.node.ctime=Date.now()),G}}),c.mkdev(u,E,A)},forceLoadFile(n){if(n.isDevice||n.isFolder||n.link||n.contents)return!0;if(typeof XMLHttpRequest<"u")throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");try{n.contents=I(n.url),n.usedBytes=n.contents.length}catch{throw new c.ErrnoError(29)}},createLazyFile(n,a,i,d,u){class E{constructor(){bt(this,"lengthKnown",!1);bt(this,"chunks",[])}get(G){if(!(G>this.length-1||G<0)){var x=G%this.chunkSize,K=G/this.chunkSize|0;return this.getter(K)[x]}}setDataGetter(G){this.getter=G}cacheLength(){var G=new XMLHttpRequest;if(G.open("HEAD",i,!1),G.send(null),!(G.status>=200&&G.status<300||G.status===304))throw new Error("Couldn't load "+i+". Status: "+G.status);var x=Number(G.getResponseHeader("Content-length")),K,_t=(K=G.getResponseHeader("Accept-Ranges"))&&K==="bytes",at=(K=G.getResponseHeader("Content-Encoding"))&&K==="gzip",lt=1024*1024;_t||(lt=x);var tt=(yt,Kt)=>{if(yt>Kt)throw new Error("invalid range ("+yt+", "+Kt+") or no bytes requested!");if(Kt>x-1)throw new Error("only "+x+" bytes available! programmer error!");var ot=new XMLHttpRequest;if(ot.open("GET",i,!1),x!==lt&&ot.setRequestHeader("Range","bytes="+yt+"-"+Kt),ot.responseType="arraybuffer",ot.overrideMimeType&&ot.overrideMimeType("text/plain; charset=x-user-defined"),ot.send(null),!(ot.status>=200&&ot.status<300||ot.status===304))throw new Error("Couldn't load "+i+". Status: "+ot.status);return ot.response!==void 0?new Uint8Array(ot.response||[]):_e(ot.responseText||"")},Ee=this;Ee.setDataGetter(yt=>{var Kt=yt*lt,ot=(yt+1)*lt-1;if(ot=Math.min(ot,x-1),typeof Ee.chunks[yt]>"u"&&(Ee.chunks[yt]=tt(Kt,ot)),typeof Ee.chunks[yt]>"u")throw new Error("doXHR failed!");return Ee.chunks[yt]}),(at||!x)&&(lt=x=1,x=this.getter(0).length,lt=x,M("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=x,this._chunkSize=lt,this.lengthKnown=!0}get length(){return this.lengthKnown||this.cacheLength(),this._length}get chunkSize(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}if(typeof XMLHttpRequest<"u"){if(!h)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var A=new E,p={isDevice:!1,contents:A}}else var p={isDevice:!1,url:i};var m=c.createFile(n,a,p,d,u);p.contents?m.contents=p.contents:p.url&&(m.contents=null,m.url=p.url),Object.defineProperties(m,{usedBytes:{get:function(){return this.contents.length}}});var D={},R=Object.keys(m.stream_ops);R.forEach(k=>{var G=m.stream_ops[k];D[k]=(...x)=>(c.forceLoadFile(m),G(...x))});function N(k,G,x,K,_t){var at=k.node.contents;if(_t>=at.length)return 0;var lt=Math.min(at.length-_t,K);if(at.slice)for(var tt=0;tt<lt;tt++)G[x+tt]=at[_t+tt];else for(var tt=0;tt<lt;tt++)G[x+tt]=at.get(_t+tt);return lt}return D.read=(k,G,x,K,_t)=>(c.forceLoadFile(m),N(k,G,x,K,_t)),D.mmap=(k,G,x,K,_t)=>{c.forceLoadFile(m);var at=de();if(!at)throw new c.ErrnoError(48);return N(k,U,at,G,x),{ptr:at,allocated:!0}},m.stream_ops=D,m}},le=(n,a)=>(n>>>=0,n?Lt(Z,n,a):""),et={DEFAULT_POLLMASK:5,calculateAt(n,a,i){if(z.isAbs(a))return a;var d;if(n===-100)d=c.cwd();else{var u=et.getStreamFromFD(n);d=u.path}if(a.length==0){if(!i)throw new c.ErrnoError(44);return d}return d+"/"+a},writeStat(n,a){Y[n>>>2>>>0]=a.dev,Y[n+4>>>2>>>0]=a.mode,F[n+8>>>2>>>0]=a.nlink,Y[n+12>>>2>>>0]=a.uid,Y[n+16>>>2>>>0]=a.gid,Y[n+20>>>2>>>0]=a.rdev,it[n+24>>>3]=BigInt(a.size),Y[n+32>>>2>>>0]=4096,Y[n+36>>>2>>>0]=a.blocks;var i=a.atime.getTime(),d=a.mtime.getTime(),u=a.ctime.getTime();return it[n+40>>>3]=BigInt(Math.floor(i/1e3)),F[n+48>>>2>>>0]=i%1e3*1e3*1e3,it[n+56>>>3]=BigInt(Math.floor(d/1e3)),F[n+64>>>2>>>0]=d%1e3*1e3*1e3,it[n+72>>>3]=BigInt(Math.floor(u/1e3)),F[n+80>>>2>>>0]=u%1e3*1e3*1e3,it[n+88>>>3]=BigInt(a.ino),0},writeStatFs(n,a){Y[n+4>>>2>>>0]=a.bsize,Y[n+40>>>2>>>0]=a.bsize,Y[n+8>>>2>>>0]=a.blocks,Y[n+12>>>2>>>0]=a.bfree,Y[n+16>>>2>>>0]=a.bavail,Y[n+20>>>2>>>0]=a.files,Y[n+24>>>2>>>0]=a.ffree,Y[n+28>>>2>>>0]=a.fsid,Y[n+44>>>2>>>0]=a.flags,Y[n+36>>>2>>>0]=a.namelen},doMsync(n,a,i,d,u){if(!c.isFile(a.node.mode))throw new c.ErrnoError(43);if(d&2)return 0;var E=Z.slice(n,n+i);c.msync(a,E,u,i,d)},getStreamFromFD(n){var a=c.getStreamChecked(n);return a},varargs:void 0,getStr(n){var a=le(n);return a}};function un(n,a,i){i>>>=0,et.varargs=i;try{var d=et.getStreamFromFD(n);switch(a){case 0:{var u=Zt();if(u<0)return-28;for(;c.streams[u];)u++;var E;return E=c.dupStream(d,u),E.fd}case 1:case 2:return 0;case 3:return d.flags;case 4:{var u=Zt();return d.flags|=u,0}case 12:{var u=Wt(),A=0;return rt[u+A>>>1>>>0]=2,0}case 13:case 14:return 0}return-28}catch(p){if(typeof c>"u"||p.name!=="ErrnoError")throw p;return-p.errno}}function qe(n,a){a>>>=0;try{return et.writeStat(a,c.fstat(n))}catch(i){if(typeof c>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}function ke(n,a,i){i>>>=0,et.varargs=i;try{var d=et.getStreamFromFD(n);switch(a){case 21509:return d.tty?0:-59;case 21505:{if(!d.tty)return-59;if(d.tty.ops.ioctl_tcgets){var u=d.tty.ops.ioctl_tcgets(d),E=Wt();Y[E>>>2>>>0]=u.c_iflag||0,Y[E+4>>>2>>>0]=u.c_oflag||0,Y[E+8>>>2>>>0]=u.c_cflag||0,Y[E+12>>>2>>>0]=u.c_lflag||0;for(var A=0;A<32;A++)U[E+A+17>>>0]=u.c_cc[A]||0;return 0}return 0}case 21510:case 21511:case 21512:return d.tty?0:-59;case 21506:case 21507:case 21508:{if(!d.tty)return-59;if(d.tty.ops.ioctl_tcsets){for(var E=Wt(),p=Y[E>>>2>>>0],m=Y[E+4>>>2>>>0],D=Y[E+8>>>2>>>0],R=Y[E+12>>>2>>>0],N=[],A=0;A<32;A++)N.push(U[E+A+17>>>0]);return d.tty.ops.ioctl_tcsets(d.tty,a,{c_iflag:p,c_oflag:m,c_cflag:D,c_lflag:R,c_cc:N})}return 0}case 21519:{if(!d.tty)return-59;var E=Wt();return Y[E>>>2>>>0]=0,0}case 21520:return d.tty?-28:-59;case 21531:{var E=Wt();return c.ioctl(d,a,E)}case 21523:{if(!d.tty)return-59;if(d.tty.ops.ioctl_tiocgwinsz){var k=d.tty.ops.ioctl_tiocgwinsz(d.tty),E=Wt();rt[E>>>1>>>0]=k[0],rt[E+2>>>1>>>0]=k[1]}return 0}case 21524:return d.tty?0:-59;case 21515:return d.tty?0:-59;default:return-28}}catch(G){if(typeof c>"u"||G.name!=="ErrnoError")throw G;return-G.errno}}function J(n,a){n>>>=0,a>>>=0;try{return n=et.getStr(n),et.writeStat(a,c.lstat(n))}catch(i){if(typeof c>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}function j(n,a,i,d){a>>>=0,i>>>=0;try{a=et.getStr(a);var u=d&256,E=d&4096;return d=d&-6401,a=et.calculateAt(n,a,E),et.writeStat(i,u?c.lstat(a):c.stat(a))}catch(A){if(typeof c>"u"||A.name!=="ErrnoError")throw A;return-A.errno}}function te(n,a,i,d){a>>>=0,d>>>=0,et.varargs=d;try{a=et.getStr(a),a=et.calculateAt(n,a);var u=d?Zt():0;return c.open(a,i,u).fd}catch(E){if(typeof c>"u"||E.name!=="ErrnoError")throw E;return-E.errno}}function Qe(n,a){n>>>=0,a>>>=0;try{return n=et.getStr(n),et.writeStat(a,c.stat(n))}catch(i){if(typeof c>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}var En=()=>Nt(""),Se=n=>{if(n===null)return"null";var a=typeof n;return a==="object"||a==="array"||a==="function"?n.toString():""+n},Be=()=>{for(var n=new Array(256),a=0;a<256;++a)n[a]=String.fromCharCode(a);je=n},je,st=n=>{for(var a="",i=n;Z[i>>>0];)a+=je[Z[i++>>>0]];return a},Ht={},ut={},gt={},ee,V=n=>{throw new ee(n)},tn,Le=n=>{throw new tn(n)},Ye=(n,a,i)=>{n.forEach(p=>gt[p]=a);function d(p){var m=i(p);m.length!==n.length&&Le("Mismatched type converter count");for(var D=0;D<n.length;++D)Et(n[D],m[D])}var u=new Array(a.length),E=[],A=0;a.forEach((p,m)=>{ut.hasOwnProperty(p)?u[m]=ut[p]:(E.push(p),Ht.hasOwnProperty(p)||(Ht[p]=[]),Ht[p].push(()=>{u[m]=ut[p],++A,A===E.length&&d(u)}))}),E.length===0&&d(u)};function Fe(n,a,i={}){var d=a.name;if(n||V(`type "${d}" must have a positive integer typeid pointer`),ut.hasOwnProperty(n)){if(i.ignoreDuplicateRegistrations)return;V(`Cannot register type '${d}' twice`)}if(ut[n]=a,delete gt[n],Ht.hasOwnProperty(n)){var u=Ht[n];delete Ht[n],u.forEach(E=>E())}}function Et(n,a,i={}){return Fe(n,a,i)}var Ue=(n,a,i)=>{switch(a){case 1:return i?d=>U[d>>>0]:d=>Z[d>>>0];case 2:return i?d=>rt[d>>>1>>>0]:d=>dt[d>>>1>>>0];case 4:return i?d=>Y[d>>>2>>>0]:d=>F[d>>>2>>>0];case 8:return i?d=>it[d>>>3]:d=>Yt[d>>>3];default:throw new TypeError(`invalid integer width (${a}): ${n}`)}};function vr(n,a,i,d,u){n>>>=0,a>>>=0,i>>>=0,a=st(a);var E=a.indexOf("u")!=-1;Et(n,{name:a,fromWireType:A=>A,toWireType:function(A,p){if(typeof p!="bigint"&&typeof p!="number")throw new TypeError(`Cannot convert "${Se(p)}" to ${this.name}`);return typeof p=="number"&&(p=BigInt(p)),p},argPackAdvance:Mt,readValueFromPointer:Ue(a,i,!E),destructorFunction:null})}var Mt=8;function mr(n,a,i,d){n>>>=0,a>>>=0,a=st(a),Et(n,{name:a,fromWireType:function(u){return!!u},toWireType:function(u,E){return E?i:d},argPackAdvance:Mt,readValueFromPointer:function(u){return this.fromWireType(Z[u>>>0])},destructorFunction:null})}var Ir=n=>({count:n.count,deleteScheduled:n.deleteScheduled,preservePointerOnDelete:n.preservePointerOnDelete,ptr:n.ptr,ptrType:n.ptrType,smartPtr:n.smartPtr,smartPtrType:n.smartPtrType}),fn=n=>{function a(i){return i.$$.ptrType.registeredClass.name}V(a(n)+" instance already deleted")},hn=!1,bn=n=>{},wr=n=>{n.smartPtr?n.smartPtrType.rawDestructor(n.smartPtr):n.ptrType.registeredClass.rawDestructor(n.ptr)},xn=n=>{n.count.value-=1;var a=n.count.value===0;a&&wr(n)},On=(n,a,i)=>{if(a===i)return n;if(i.baseClass===void 0)return null;var d=On(n,a,i.baseClass);return d===null?null:i.downcast(d)},kn={},Cr={},Dr=(n,a)=>{for(a===void 0&&V("ptr should not be undefined");n.baseClass;)a=n.upcast(a),n=n.baseClass;return a},Rr=(n,a)=>(a=Dr(n,a),Cr[a]),en=(n,a)=>{(!a.ptrType||!a.ptr)&&Le("makeClassHandle requires ptr and ptrType");var i=!!a.smartPtrType,d=!!a.smartPtr;return i!==d&&Le("Both smartPtrType and smartPtr must be specified"),a.count={value:1},$e(Object.create(n,{$$:{value:a,writable:!0}}))};function Sr(n){var a=this.getPointee(n);if(!a)return this.destructor(n),null;var i=Rr(this.registeredClass,a);if(i!==void 0){if(i.$$.count.value===0)return i.$$.ptr=a,i.$$.smartPtr=n,i.clone();var d=i.clone();return this.destructor(n),d}function u(){return this.isSmartPointer?en(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:a,smartPtrType:this,smartPtr:n}):en(this.registeredClass.instancePrototype,{ptrType:this,ptr:n})}var E=this.registeredClass.getActualType(a),A=kn[E];if(!A)return u.call(this);var p;this.isConst?p=A.constPointerType:p=A.pointerType;var m=On(a,this.registeredClass,p.registeredClass);return m===null?u.call(this):this.isSmartPointer?en(p.registeredClass.instancePrototype,{ptrType:p,ptr:m,smartPtrType:this,smartPtr:n}):en(p.registeredClass.instancePrototype,{ptrType:p,ptr:m})}var $e=n=>typeof FinalizationRegistry>"u"?($e=a=>a,n):(hn=new FinalizationRegistry(a=>{xn(a.$$)}),$e=a=>{var i=a.$$,d=!!i.smartPtr;if(d){var u={$$:i};hn.register(a,u,a)}return a},bn=a=>hn.unregister(a),$e(n)),Lr=()=>{Object.assign(nn.prototype,{isAliasOf(n){if(!(this instanceof nn)||!(n instanceof nn))return!1;var a=this.$$.ptrType.registeredClass,i=this.$$.ptr;n.$$=n.$$;for(var d=n.$$.ptrType.registeredClass,u=n.$$.ptr;a.baseClass;)i=a.upcast(i),a=a.baseClass;for(;d.baseClass;)u=d.upcast(u),d=d.baseClass;return a===d&&i===u},clone(){if(this.$$.ptr||fn(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var n=$e(Object.create(Object.getPrototypeOf(this),{$$:{value:Ir(this.$$)}}));return n.$$.count.value+=1,n.$$.deleteScheduled=!1,n},delete(){this.$$.ptr||fn(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&V("Object already scheduled for deletion"),bn(this),xn(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},isDeleted(){return!this.$$.ptr},deleteLater(){return this.$$.ptr||fn(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&V("Object already scheduled for deletion"),this.$$.deleteScheduled=!0,this}})};function nn(){}var Ne=(n,a)=>Object.defineProperty(a,"name",{value:n}),Yr=(n,a,i)=>{if(n[a].overloadTable===void 0){var d=n[a];n[a]=function(...u){return n[a].overloadTable.hasOwnProperty(u.length)||V(`Function '${i}' called with an invalid number of arguments (${u.length}) - expects one of (${n[a].overloadTable})!`),n[a].overloadTable[u.length].apply(this,u)},n[a].overloadTable=[],n[a].overloadTable[d.argCount]=d}},gn=(n,a,i)=>{e.hasOwnProperty(n)?((i===void 0||e[n].overloadTable!==void 0&&e[n].overloadTable[i]!==void 0)&&V(`Cannot register public name '${n}' twice`),Yr(e,n,n),e[n].overloadTable.hasOwnProperty(i)&&V(`Cannot register multiple overloads of a function with the same number of arguments (${i})!`),e[n].overloadTable[i]=a):(e[n]=a,e[n].argCount=i)},Nr=48,Wr=57,Gr=n=>{n=n.replace(/[^a-zA-Z0-9_]/g,"$");var a=n.charCodeAt(0);return a>=Nr&&a<=Wr?`_${n}`:n};function Mr(n,a,i,d,u,E,A,p){this.name=n,this.constructor=a,this.instancePrototype=i,this.rawDestructor=d,this.baseClass=u,this.getActualType=E,this.upcast=A,this.downcast=p,this.pureVirtualFunctions=[]}var rn=(n,a,i)=>{for(;a!==i;)a.upcast||V(`Expected null or instance of ${i.name}, got an instance of ${a.name}`),n=a.upcast(n),a=a.baseClass;return n};function br(n,a){if(a===null)return this.isReference&&V(`null is not a valid ${this.name}`),0;a.$$||V(`Cannot pass "${Se(a)}" as a ${this.name}`),a.$$.ptr||V(`Cannot pass deleted object as a pointer of type ${this.name}`);var i=a.$$.ptrType.registeredClass,d=rn(a.$$.ptr,i,this.registeredClass);return d}function xr(n,a){var i;if(a===null)return this.isReference&&V(`null is not a valid ${this.name}`),this.isSmartPointer?(i=this.rawConstructor(),n!==null&&n.push(this.rawDestructor,i),i):0;(!a||!a.$$)&&V(`Cannot pass "${Se(a)}" as a ${this.name}`),a.$$.ptr||V(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&a.$$.ptrType.isConst&&V(`Cannot convert argument of type ${a.$$.smartPtrType?a.$$.smartPtrType.name:a.$$.ptrType.name} to parameter type ${this.name}`);var d=a.$$.ptrType.registeredClass;if(i=rn(a.$$.ptr,d,this.registeredClass),this.isSmartPointer)switch(a.$$.smartPtr===void 0&&V("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:a.$$.smartPtrType===this?i=a.$$.smartPtr:V(`Cannot convert argument of type ${a.$$.smartPtrType?a.$$.smartPtrType.name:a.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:i=a.$$.smartPtr;break;case 2:if(a.$$.smartPtrType===this)i=a.$$.smartPtr;else{var u=a.clone();i=this.rawShare(i,At.toHandle(()=>u.delete())),n!==null&&n.push(this.rawDestructor,i)}break;default:V("Unsupporting sharing policy")}return i}function Or(n,a){if(a===null)return this.isReference&&V(`null is not a valid ${this.name}`),0;a.$$||V(`Cannot pass "${Se(a)}" as a ${this.name}`),a.$$.ptr||V(`Cannot pass deleted object as a pointer of type ${this.name}`),a.$$.ptrType.isConst&&V(`Cannot convert argument of type ${a.$$.ptrType.name} to parameter type ${this.name}`);var i=a.$$.ptrType.registeredClass,d=rn(a.$$.ptr,i,this.registeredClass);return d}function an(n){return this.fromWireType(F[n>>>2>>>0])}var kr=()=>{Object.assign(on.prototype,{getPointee(n){return this.rawGetPointee&&(n=this.rawGetPointee(n)),n},destructor(n){var a;(a=this.rawDestructor)==null||a.call(this,n)},argPackAdvance:Mt,readValueFromPointer:an,fromWireType:Sr})};function on(n,a,i,d,u,E,A,p,m,D,R){this.name=n,this.registeredClass=a,this.isReference=i,this.isConst=d,this.isSmartPointer=u,this.pointeeType=E,this.sharingPolicy=A,this.rawGetPointee=p,this.rawConstructor=m,this.rawShare=D,this.rawDestructor=R,!u&&a.baseClass===void 0?d?(this.toWireType=br,this.destructorFunction=null):(this.toWireType=Or,this.destructorFunction=null):this.toWireType=xr}var Bn=(n,a,i)=>{e.hasOwnProperty(n)||Le("Replacing nonexistent public symbol"),e[n].overloadTable!==void 0&&i!==void 0?e[n].overloadTable[i]=a:(e[n]=a,e[n].argCount=i)},sn=[],Fn,Un=n=>{var a=sn[n];return a||(n>=sn.length&&(sn.length=n+1),sn[n]=a=Fn.get(n)),a},Br=(n,a,i=[])=>{var d=Un(a)(...i);return n[0]=="p"?d>>>0:d},Fr=(n,a)=>(...i)=>Br(n,a,i),ce=(n,a)=>{n=st(n);function i(){return n.includes("p")?Fr(n,a):Un(a)}var d=i();return typeof d!="function"&&V(`unknown function pointer with signature ${n}: ${a}`),d},Ur=(n,a)=>{var i=Ne(a,function(d){this.name=a,this.message=d;var u=new Error(d).stack;u!==void 0&&(this.stack=this.toString()+`
|
|
3
|
-
`+u.replace(/^Error(:[^\n]*)?\n/,""))});return i.prototype=Object.create(n.prototype),i.prototype.constructor=i,i.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},i},$n,Vn=n=>{var a=ro(n),i=st(a);return ne(a),i},_n=(n,a)=>{var i=[],d={};function u(E){if(!d[E]&&!ut[E]){if(gt[E]){gt[E].forEach(u);return}i.push(E),d[E]=!0}}throw a.forEach(u),new $n(`${n}: `+i.map(Vn).join([", "]))};function $r(n,a,i,d,u,E,A,p,m,D,R,N,k){n>>>=0,a>>>=0,i>>>=0,d>>>=0,u>>>=0,E>>>=0,A>>>=0,p>>>=0,m>>>=0,D>>>=0,R>>>=0,N>>>=0,k>>>=0,R=st(R),E=ce(u,E),p&&(p=ce(A,p)),D&&(D=ce(m,D)),k=ce(N,k);var G=Gr(R);gn(G,function(){_n(`Cannot construct ${R} due to unbound types`,[d])}),Ye([n,a,i],d?[d]:[],x=>{var ot;x=x[0];var K,_t;d?(K=x.registeredClass,_t=K.instancePrototype):_t=nn.prototype;var at=Ne(R,function(...In){if(Object.getPrototypeOf(this)!==lt)throw new ee("Use 'new' to construct "+R);if(tt.constructor_body===void 0)throw new ee(R+" has no accessible constructor");var nr=tt.constructor_body[In.length];if(nr===void 0)throw new ee(`Tried to invoke ctor of ${R} with invalid number of parameters (${In.length}) - expected (${Object.keys(tt.constructor_body).toString()}) parameters instead!`);return nr.apply(this,In)}),lt=Object.create(_t,{constructor:{value:at}});at.prototype=lt;var tt=new Mr(R,at,lt,k,K,E,p,D);tt.baseClass&&((ot=tt.baseClass).__derivedClasses??(ot.__derivedClasses=[]),tt.baseClass.__derivedClasses.push(tt));var Ee=new on(R,tt,!0,!1,!1),yt=new on(R+"*",tt,!1,!1,!1),Kt=new on(R+" const*",tt,!1,!0,!1);return kn[n]={pointerType:yt,constPointerType:Kt},Bn(G,at),[Ee,yt,Kt]})}var An=n=>{for(;n.length;){var a=n.pop(),i=n.pop();i(a)}},Hn=(n,a,i)=>(n instanceof Object||V(`${i} with invalid "this": ${n}`),n instanceof a.registeredClass.constructor||V(`${i} incompatible with "this" of type ${n.constructor.name}`),n.$$.ptr||V(`cannot call emscripten binding method ${i} on deleted object`),rn(n.$$.ptr,n.$$.ptrType.registeredClass,a.registeredClass)),Vr=function(n,a,i,d,u,E,A,p,m,D){n>>>=0,a>>>=0,i>>>=0,d>>>=0,u>>>=0,E>>>=0,A>>>=0,p>>>=0,m>>>=0,D>>>=0,a=st(a),u=ce(d,u),Ye([],[n],R=>{R=R[0];var N=`${R.name}.${a}`,k={get(){_n(`Cannot access ${N} due to unbound types`,[i,A])},enumerable:!0,configurable:!0};return m?k.set=()=>_n(`Cannot access ${N} due to unbound types`,[i,A]):k.set=G=>V(N+" is a read-only property"),Object.defineProperty(R.registeredClass.instancePrototype,a,k),Ye([],m?[i,A]:[i],G=>{var x=G[0],K={get(){var at=Hn(this,R,N+" getter");return x.fromWireType(u(E,at))},enumerable:!0};if(m){m=ce(p,m);var _t=G[1];K.set=function(at){var lt=Hn(this,R,N+" setter"),tt=[];m(D,lt,_t.toWireType(tt,at)),An(tt)}}return Object.defineProperty(R.registeredClass.instancePrototype,a,K),[]}),[]})},yn=[],Xt=[];function pn(n){n>>>=0,n>9&&--Xt[n+1]===0&&(Xt[n]=void 0,yn.push(n))}var Hr=()=>Xt.length/2-5-yn.length,Xr=()=>{Xt.push(0,1,void 0,1,null,1,!0,1,!1,1),e.count_emval_handles=Hr},At={toValue:n=>(n||V("Cannot use deleted val. handle = "+n),Xt[n]),toHandle:n=>{switch(n){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:{const a=yn.pop()||Xt.length;return Xt[a]=n,Xt[a+1]=1,a}}}},Kr={name:"emscripten::val",fromWireType:n=>{var a=At.toValue(n);return pn(n),a},toWireType:(n,a)=>At.toHandle(a),argPackAdvance:Mt,readValueFromPointer:an,destructorFunction:null};function zr(n){return n>>>=0,Et(n,Kr)}var Jr=(n,a,i)=>{switch(a){case 1:return i?function(d){return this.fromWireType(U[d>>>0])}:function(d){return this.fromWireType(Z[d>>>0])};case 2:return i?function(d){return this.fromWireType(rt[d>>>1>>>0])}:function(d){return this.fromWireType(dt[d>>>1>>>0])};case 4:return i?function(d){return this.fromWireType(Y[d>>>2>>>0])}:function(d){return this.fromWireType(F[d>>>2>>>0])};default:throw new TypeError(`invalid integer width (${a}): ${n}`)}};function Zr(n,a,i,d){n>>>=0,a>>>=0,i>>>=0,a=st(a);function u(){}u.values={},Et(n,{name:a,constructor:u,fromWireType:function(E){return this.constructor.values[E]},toWireType:(E,A)=>A.value,argPackAdvance:Mt,readValueFromPointer:Jr(a,i,d),destructorFunction:null}),gn(a,u)}var Tn=(n,a)=>{var i=ut[n];return i===void 0&&V(`${a} has unknown type ${Vn(n)}`),i};function qr(n,a,i){n>>>=0,a>>>=0;var d=Tn(n,"enum");a=st(a);var u=d.constructor,E=Object.create(d.constructor.prototype,{value:{value:i},constructor:{value:Ne(`${d.name}_${a}`,function(){})}});u.values[i]=E,u[a]=E}var Qr=(n,a)=>{switch(a){case 4:return function(i){return this.fromWireType(ct[i>>>2>>>0])};case 8:return function(i){return this.fromWireType(wt[i>>>3>>>0])};default:throw new TypeError(`invalid float width (${a}): ${n}`)}},jr=function(n,a,i){n>>>=0,a>>>=0,i>>>=0,a=st(a),Et(n,{name:a,fromWireType:d=>d,toWireType:(d,u)=>u,argPackAdvance:Mt,readValueFromPointer:Qr(a,i),destructorFunction:null})};function Xn(n){for(var a=1;a<n.length;++a)if(n[a]!==null&&n[a].destructorFunction===void 0)return!0;return!1}function Kn(n,a){if(!(n instanceof Function))throw new TypeError(`new_ called with constructor type ${typeof n} which is not a function`);var i=Ne(n.name||"unknownFunctionName",function(){});i.prototype=n.prototype;var d=new i,u=n.apply(d,a);return u instanceof Object?u:d}function ta(n,a,i,d){for(var u=Xn(n),E=n.length-2,A=[],p=["fn"],m=0;m<E;++m)A.push(`arg${m}`),p.push(`arg${m}Wired`);A=A.join(","),p=p.join(",");var D=`return function (${A}) {
|
|
1
|
+
var ro=Object.defineProperty;var ao=(r,t,o)=>t in r?ro(r,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[t]=o;var Gt=(r,t,o)=>ao(r,typeof t!="symbol"?t+"":t,o);var Ht;(function(r){r[r.ByBlock=-2]="ByBlock",r[r.ByDIPs=-4]="ByDIPs",r[r.ByLayer=-1]="ByLayer",r[r.ByLineWeightDefault=-3]="ByLineWeightDefault",r[r.LineWeight000=0]="LineWeight000",r[r.LineWeight005=5]="LineWeight005",r[r.LineWeight009=9]="LineWeight009",r[r.LineWeight013=13]="LineWeight013",r[r.LineWeight015=15]="LineWeight015",r[r.LineWeight018=18]="LineWeight018",r[r.LineWeight020=20]="LineWeight020",r[r.LineWeight025=25]="LineWeight025",r[r.LineWeight030=30]="LineWeight030",r[r.LineWeight035=35]="LineWeight035",r[r.LineWeight040=40]="LineWeight040",r[r.LineWeight050=50]="LineWeight050",r[r.LineWeight053=53]="LineWeight053",r[r.LineWeight060=60]="LineWeight060",r[r.LineWeight070=70]="LineWeight070",r[r.LineWeight080=80]="LineWeight080",r[r.LineWeight090=90]="LineWeight090",r[r.LineWeight100=100]="LineWeight100",r[r.LineWeight106=106]="LineWeight106",r[r.LineWeight120=120]="LineWeight120",r[r.LineWeight140=140]="LineWeight140",r[r.LineWeight158=158]="LineWeight158",r[r.LineWeight200=200]="LineWeight200",r[r.LineWeight211=211]="LineWeight211"})(Ht||(Ht={}));var oo="DwgConverterLicenseError",io=["evaluation of @mlightcad/dwg-converter has expired"],so=["invalid @mlightcad/dwg-converter license key"];function _o(r){return r==="license_expired"||r==="license_invalid"}function Ar(r){var t=r.toLowerCase();if(io.some(function(o){return t.includes(o)}))return"license_expired";if(so.some(function(o){return t.includes(o)}))return"license_invalid"}function lo(r){var t;return(t=Ar(r))!==null&&t!==void 0?t:"license_invalid"}var co=function(r,t,o,n){function s(_){return _ instanceof o?_:new o(function(l){l(_)})}return new(o||(o=Promise))(function(_,l){function f(y){try{g(n.next(y))}catch(P){l(P)}}function h(y){try{g(n.throw(y))}catch(P){l(P)}}function g(y){y.done?_(y.value):s(y.value).then(f,h)}g((n=n.apply(r,t||[])).next())})},uo=function(r,t){var o={label:0,sent:function(){if(_[0]&1)throw _[1];return _[1]},trys:[],ops:[]},n,s,_,l;return l={next:f(0),throw:f(1),return:f(2)},typeof Symbol=="function"&&(l[Symbol.iterator]=function(){return this}),l;function f(g){return function(y){return h([g,y])}}function h(g){if(n)throw new TypeError("Generator is already executing.");for(;l&&(l=0,g[0]&&(o=0)),o;)try{if(n=1,s&&(_=g[0]&2?s.return:g[0]?s.throw||((_=s.return)&&_.call(s),0):s.next)&&!(_=_.call(s,g[1])).done)return _;switch(s=0,_&&(g=[g[0]&2,_.value]),g[0]){case 0:case 1:_=g;break;case 4:return o.label++,{value:g[1],done:!1};case 5:o.label++,s=g[1],g=[0];continue;case 7:g=o.ops.pop(),o.trys.pop();continue;default:if(_=o.trys,!(_=_.length>0&&_[_.length-1])&&(g[0]===6||g[0]===2)){o=0;continue}if(g[0]===3&&(!_||g[1]>_[0]&&g[1]<_[3])){o.label=g[1];break}if(g[0]===6&&o.label<_[1]){o.label=_[1],_=g;break}if(_&&o.label<_[2]){o.label=_[2],o.ops.push(g);break}_[2]&&o.ops.pop(),o.trys.pop();continue}g=t.call(r,o)}catch(y){g=[6,y],s=0}finally{n=_=0}if(g[0]&5)throw g[1];return{value:g[0]?g[1]:void 0,done:!0}}},Eo=["out of memory","data cannot be cloned","allocation failed","memory access out of bounds"];function fo(r){var t=r.toLowerCase();return Eo.some(function(o){return t.includes(o)})}function mn(){var r=globalThis;if(typeof r.postMessage!="function")throw new Error("Worker messaging is not available in this runtime");return r}var ho=(function(){function r(){this.setupMessageHandler()}return r.prototype.setupMessageHandler=function(){var t=this;mn().onmessage=function(o){return co(t,void 0,void 0,function(){var n,s,_,l,f,h,g;return uo(this,function(y){switch(y.label){case 0:n=o,s=n.data,_=s.id,l=s.input,y.label=1;case 1:return y.trys.push([1,3,,4]),[4,this.executeTask(l)];case 2:return f=y.sent(),this.sendResponse(_,!0,f),[3,4];case 3:return h=y.sent(),g=h instanceof Error?h.message:String(h),this.sendResponse(_,!1,void 0,g,this.classifyTaskError(h,g)),[3,4];case 4:return[2]}})})}},r.prototype.sendResponse=function(t,o,n,s,_){var l={id:t,success:o,data:n,error:s,errorCode:_};try{mn().postMessage(l)}catch(h){var f=h instanceof Error?h.message:String(h);mn().postMessage({id:t,success:!1,error:f,errorCode:this.classifyPostMessageError(f)})}},r.prototype.classifyTaskError=function(t,o){if(t instanceof Error){var n=t.code;if(_o(n))return n;if(t.name===oo)return lo(o)}var s=Ar(o);return s||this.classifyPostMessageError(o)},r.prototype.classifyPostMessageError=function(t){return fo(t)?"worker_oom":t.toLowerCase().includes("timed out")?"worker_timeout":"worker_error"},r})();const go="modulepreload",Ao=function(r,t){return new URL(r,t).href},ir={},yo=function(t,o,n){let s=Promise.resolve();if(o&&o.length>0){let l=function(y){return Promise.all(y.map(P=>Promise.resolve(P).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};const f=document.getElementsByTagName("link"),h=document.querySelector("meta[property=csp-nonce]"),g=(h==null?void 0:h.nonce)||(h==null?void 0:h.getAttribute("nonce"));s=l(o.map(y=>{if(y=Ao(y,n),y in ir)return;ir[y]=!0;const P=y.endsWith(".css"),p=P?'[rel="stylesheet"]':"";if(!!n)for(let w=f.length-1;w>=0;w--){const m=f[w];if(m.href===y&&(!P||m.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${y}"]${p}`))return;const C=document.createElement("link");if(C.rel=P?"stylesheet":go,P||(C.as="script"),C.crossOrigin="",C.href=y,g&&C.setAttribute("nonce",g),document.head.appendChild(C),P)return new Promise((w,m)=>{C.addEventListener("load",w),C.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${y}`)))})}))}function _(l){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=l,window.dispatchEvent(f),!f.defaultPrevented)throw l}return s.then(l=>{for(const f of l||[])f.status==="rejected"&&_(f.reason);return t().catch(_)})};async function sr(r={}){var er,nr,rr;var t,o=r,n=!!globalThis.window,s=!!globalThis.WorkerGlobalScope,_=((nr=(er=globalThis.process)==null?void 0:er.versions)==null?void 0:nr.node)&&((rr=globalThis.process)==null?void 0:rr.type)!="renderer";if(_){const{createRequire:e}=await yo(()=>Promise.resolve().then(()=>ti),void 0,import.meta.url);var l=e(import.meta.url)}var f="./this.program",h=import.meta.url,g="";function y(e){return o.locateFile?o.locateFile(e,g):g+e}var P,p;if(_){var I=l("node:fs");h.startsWith("file:")&&(g=l("node:path").dirname(l("node:url").fileURLToPath(h))+"/"),p=e=>{e=N(e)?new URL(e):e;var a=I.readFileSync(e);return a},P=async(e,a=!0)=>{e=N(e)?new URL(e):e;var i=I.readFileSync(e,a?void 0:"utf8");return i},process.argv.length>1&&(f=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2)}else if(n||s){try{g=new URL(".",h).href}catch{}s&&(p=e=>{var a=new XMLHttpRequest;return a.open("GET",e,!1),a.responseType="arraybuffer",a.send(null),new Uint8Array(a.response)}),P=async e=>{if(N(e))return new Promise((i,d)=>{var u=new XMLHttpRequest;u.open("GET",e,!0),u.responseType="arraybuffer",u.onload=()=>{if(u.status==200||u.status==0&&u.response){i(u.response);return}d(u.status)},u.onerror=d,u.send(null)});var a=await fetch(e,{credentials:"same-origin"});if(a.ok)return a.arrayBuffer();throw new Error(a.status+" : "+a.url)}}var C=(()=>{}).bind(console),w=(()=>{}).bind(console),m,S=!1,N=e=>e.startsWith("file://"),W,M,O=!1;function U(){var e=_n.buffer;z=new Int8Array(e),dt=new Int16Array(e),lt=new Uint8Array(e),Tt=new Uint16Array(e),k=new Int32Array(e),B=new Uint32Array(e),kt=new Float32Array(e),Bt=new Float64Array(e),tt=new BigInt64Array(e),Xt=new BigUint64Array(e)}function J(){if(o.preRun)for(typeof o.preRun=="function"&&(o.preRun=[o.preRun]);o.preRun.length;)Ft(o.preRun.shift());St(zt)}function nt(){O=!0,!o.noFSInit&&!c.initialized&&c.init(),he.__wasm_call_ctors(),c.ignorePermissions=!1}function gt(){if(o.postRun)for(typeof o.postRun=="function"&&(o.postRun=[o.postRun]);o.postRun.length;)se(o.postRun.shift());St(Kt)}function Z(e){var i;(i=o.onAbort)==null||i.call(o,e),e=`Aborted(${e})`,w(e),S=!0,e+=". Build with -sASSERTIONS for more info.";var a=new WebAssembly.RuntimeError(e);throw M==null||M(a),a}var ut;function Et(){return o.locateFile?y("libredwg-web.wasm"):new URL(""+new URL("libredwg-web.wasm",import.meta.url).href,import.meta.url).href}function At(e){if(e==ut&&m)return new Uint8Array(m);if(p)return p(e);throw"both async and sync fetching of the wasm failed"}async function yt(e){if(!m)try{var a=await P(e);return new Uint8Array(a)}catch{}return At(e)}async function Mt(e,a){try{var i=await yt(e),d=await WebAssembly.instantiate(i,a);return d}catch(u){w(`failed to asynchronously prepare wasm: ${u}`),Z(u)}}async function bt(e,a,i){if(!e&&!N(a)&&!_)try{var d=fetch(a,{credentials:"same-origin"}),u=await WebAssembly.instantiateStreaming(d,i);return u}catch(E){w(`wasm streaming compile failed: ${E}`),w("falling back to ArrayBuffer instantiation")}return Mt(a,i)}function xt(){var e={env:tr,wasi_snapshot_preview1:tr};return e}async function Ot(){function e(E,A){return he=E.exports,he=no(he),eo(he),U(),he}function a(E){return e(E.instance)}var i=xt();if(o.instantiateWasm)return new Promise((E,A)=>{o.instantiateWasm(i,(T,v)=>{E(e(T))})});ut??(ut=Et());var d=await bt(m,ut,i),u=a(d);return u}var dt,k,tt,z,kt,Bt,Tt,B,Xt,lt,St=e=>{for(;e.length>0;)e.shift()(o)},Kt=[],se=e=>Kt.push(e),zt=[],Ft=e=>zt.push(e);function q(e,a,i="i8"){switch(i.endsWith("*")&&(i="*"),i){case"i1":z[e>>>0]=a;break;case"i8":z[e>>>0]=a;break;case"i16":dt[e>>>1>>>0]=a;break;case"i32":k[e>>>2>>>0]=a;break;case"i64":tt[e>>>3>>>0]=BigInt(a);break;case"float":kt[e>>>2>>>0]=a;break;case"double":Bt[e>>>3>>>0]=a;break;case"*":B[e>>>2>>>0]=a;break;default:Z(`invalid type for setValue: ${i}`)}}var V=e=>Zn(e),Jt=()=>Qn();class ye{constructor(a){this.excPtr=a,this.ptr=a-24}set_type(a){B[this.ptr+4>>>2>>>0]=a}get_type(){return B[this.ptr+4>>>2>>>0]}set_destructor(a){B[this.ptr+8>>>2>>>0]=a}get_destructor(){return B[this.ptr+8>>>2>>>0]}set_caught(a){a=a?1:0,z[this.ptr+12>>>0]=a}get_caught(){return z[this.ptr+12>>>0]!=0}set_rethrown(a){a=a?1:0,z[this.ptr+13>>>0]=a}get_rethrown(){return z[this.ptr+13>>>0]!=0}init(a,i){this.set_adjusted_ptr(0),this.set_type(a),this.set_destructor(i)}set_adjusted_ptr(a){B[this.ptr+16>>>2>>>0]=a}get_adjusted_ptr(){return B[this.ptr+16>>>2>>>0]}}var Ut=9007199254740992,Ye=-9007199254740992,Te=e=>e<Ye||e>Ut?NaN:Number(e);function Ne(e,a,i){e>>>=0,a>>>=0,i>>>=0;var d=new ye(e);d.init(a,i),Z()}var Zt=()=>{var e=k[+Q.varargs>>>2>>>0];return Q.varargs+=4,e},Lt=Zt,X={isAbs:e=>e.charAt(0)==="/",splitPath:e=>{var a=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return a.exec(e).slice(1)},normalizeArray:(e,a)=>{for(var i=0,d=e.length-1;d>=0;d--){var u=e[d];u==="."?e.splice(d,1):u===".."?(e.splice(d,1),i++):i&&(e.splice(d,1),i--)}if(a)for(;i;i--)e.unshift("..");return e},normalize:e=>{var a=X.isAbs(e),i=e.slice(-1)==="/";return e=X.normalizeArray(e.split("/").filter(d=>!!d),!a).join("/"),!e&&!a&&(e="."),e&&i&&(e+="/"),(a?"/":"")+e},dirname:e=>{var a=X.splitPath(e),i=a[0],d=a[1];return!i&&!d?".":(d&&(d=d.slice(0,-1)),i+d)},basename:e=>e&&e.match(/([^\/]+|\/)\/*$/)[1],join:(...e)=>X.normalize(e.join("/")),join2:(e,a)=>X.normalize(e+"/"+a)},We=()=>{if(_){var e=l("node:crypto");return a=>e.randomFillSync(a)}return a=>(crypto.getRandomValues(a),0)},qt=e=>(qt=We())(e),Dt={resolve:(...e)=>{for(var a="",i=!1,d=e.length-1;d>=-1&&!i;d--){var u=d>=0?e[d]:c.cwd();if(typeof u!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!u)return"";a=u+"/"+a,i=X.isAbs(u)}return a=X.normalizeArray(a.split("/").filter(E=>!!E),!i).join("/"),(i?"/":"")+a||"."},relative:(e,a)=>{e=Dt.resolve(e).slice(1),a=Dt.resolve(a).slice(1);function i(D){for(var L=0;L<D.length&&D[L]==="";L++);for(var G=D.length-1;G>=0&&D[G]==="";G--);return L>G?[]:D.slice(L,G-L+1)}for(var d=i(e.split("/")),u=i(a.split("/")),E=Math.min(d.length,u.length),A=E,T=0;T<E;T++)if(d[T]!==u[T]){A=T;break}for(var v=[],T=A;T<d.length;T++)v.push("..");return v=v.concat(u.slice(A)),v.join("/")}},Pe=globalThis.TextDecoder&&new TextDecoder,pe=(e,a,i,d)=>{var u=a+i;if(d)return u;for(;e[a]&&!(a>=u);)++a;return a},Yt=(e,a=0,i,d)=>{a>>>=0;var u=pe(e,a,i,d);if(u-a>16&&e.buffer&&Pe)return Pe.decode(e.subarray(a,u));for(var E="";a<u;){var A=e[a++];if(!(A&128)){E+=String.fromCharCode(A);continue}var T=e[a++]&63;if((A&224)==192){E+=String.fromCharCode((A&31)<<6|T);continue}var v=e[a++]&63;if((A&240)==224?A=(A&15)<<12|T<<6|v:A=(A&7)<<18|T<<12|v<<6|e[a++]&63,A<65536)E+=String.fromCharCode(A);else{var D=A-65536;E+=String.fromCharCode(55296|D>>10,56320|D&1023)}}return E},_e=[],Nt=e=>{for(var a=0,i=0;i<e.length;++i){var d=e.charCodeAt(i);d<=127?a++:d<=2047?a+=2:d>=55296&&d<=57343?(a+=4,++i):a+=3}return a},de=(e,a,i,d)=>{if(i>>>=0,!(d>0))return 0;for(var u=i,E=i+d-1,A=0;A<e.length;++A){var T=e.codePointAt(A);if(T<=127){if(i>=E)break;a[i++>>>0]=T}else if(T<=2047){if(i+1>=E)break;a[i++>>>0]=192|T>>6,a[i++>>>0]=128|T&63}else if(T<=65535){if(i+2>=E)break;a[i++>>>0]=224|T>>12,a[i++>>>0]=128|T>>6&63,a[i++>>>0]=128|T&63}else{if(i+3>=E)break;a[i++>>>0]=240|T>>18,a[i++>>>0]=128|T>>12&63,a[i++>>>0]=128|T>>6&63,a[i++>>>0]=128|T&63,A++}}return a[i>>>0]=0,i-u},Qt=(e,a,i)=>{var d=Nt(e)+1,u=new Array(d),E=de(e,u,0,u.length);return u.length=E,u},ve=()=>{var E;if(!_e.length){var e=null;if(_){var a=256,i=Buffer.alloc(a),d=0,u=process.stdin.fd;try{d=I.readSync(u,i,0,a)}catch(A){if(A.toString().includes("EOF"))d=0;else throw A}d>0&&(e=i.slice(0,d).toString("utf-8"))}else(E=globalThis.window)!=null&&E.prompt&&(e=window.prompt("Input: "),e!==null&&(e+=`
|
|
2
|
+
`));if(!e)return null;_e=Qt(e)}return _e.shift()},Pt={ttys:[],init(){},shutdown(){},register(e,a){Pt.ttys[e]={input:[],output:[],ops:a},c.registerDevice(e,Pt.stream_ops)},stream_ops:{open(e){var a=Pt.ttys[e.node.rdev];if(!a)throw new c.ErrnoError(43);e.tty=a,e.seekable=!1},close(e){e.tty.ops.fsync(e.tty)},fsync(e){e.tty.ops.fsync(e.tty)},read(e,a,i,d,u){if(!e.tty||!e.tty.ops.get_char)throw new c.ErrnoError(60);for(var E=0,A=0;A<d;A++){var T;try{T=e.tty.ops.get_char(e.tty)}catch{throw new c.ErrnoError(29)}if(T===void 0&&E===0)throw new c.ErrnoError(6);if(T==null)break;E++,a[i+A]=T}return E&&(e.node.atime=Date.now()),E},write(e,a,i,d,u){if(!e.tty||!e.tty.ops.put_char)throw new c.ErrnoError(60);try{for(var E=0;E<d;E++)e.tty.ops.put_char(e.tty,a[i+E])}catch{throw new c.ErrnoError(29)}return d&&(e.node.mtime=e.node.ctime=Date.now()),E}},default_tty_ops:{get_char(e){return ve()},put_char(e,a){a===null||a===10?(C(Yt(e.output)),e.output=[]):a!=0&&e.output.push(a)},fsync(e){var a;((a=e.output)==null?void 0:a.length)>0&&(C(Yt(e.output)),e.output=[])},ioctl_tcgets(e){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets(e,a,i){return 0},ioctl_tiocgwinsz(e){return[24,80]}},default_tty1_ops:{put_char(e,a){a===null||a===10?(w(Yt(e.output)),e.output=[]):a!=0&&e.output.push(a)},fsync(e){var a;((a=e.output)==null?void 0:a.length)>0&&(w(Yt(e.output)),e.output=[])}}},le=e=>{Z()},x={ops_table:null,mount(e){return x.createNode(null,"/",16895,0)},createNode(e,a,i,d){if(c.isBlkdev(i)||c.isFIFO(i))throw new c.ErrnoError(63);x.ops_table||(x.ops_table={dir:{node:{getattr:x.node_ops.getattr,setattr:x.node_ops.setattr,lookup:x.node_ops.lookup,mknod:x.node_ops.mknod,rename:x.node_ops.rename,unlink:x.node_ops.unlink,rmdir:x.node_ops.rmdir,readdir:x.node_ops.readdir,symlink:x.node_ops.symlink},stream:{llseek:x.stream_ops.llseek}},file:{node:{getattr:x.node_ops.getattr,setattr:x.node_ops.setattr},stream:{llseek:x.stream_ops.llseek,read:x.stream_ops.read,write:x.stream_ops.write,mmap:x.stream_ops.mmap,msync:x.stream_ops.msync}},link:{node:{getattr:x.node_ops.getattr,setattr:x.node_ops.setattr,readlink:x.node_ops.readlink},stream:{}},chrdev:{node:{getattr:x.node_ops.getattr,setattr:x.node_ops.setattr},stream:c.chrdev_stream_ops}});var u=c.createNode(e,a,i,d);return c.isDir(u.mode)?(u.node_ops=x.ops_table.dir.node,u.stream_ops=x.ops_table.dir.stream,u.contents={}):c.isFile(u.mode)?(u.node_ops=x.ops_table.file.node,u.stream_ops=x.ops_table.file.stream,u.usedBytes=0,u.contents=x.emptyFileContents??(x.emptyFileContents=new Uint8Array(0))):c.isLink(u.mode)?(u.node_ops=x.ops_table.link.node,u.stream_ops=x.ops_table.link.stream):c.isChrdev(u.mode)&&(u.node_ops=x.ops_table.chrdev.node,u.stream_ops=x.ops_table.chrdev.stream),u.atime=u.mtime=u.ctime=Date.now(),e&&(e.contents[a]=u,e.atime=e.mtime=e.ctime=u.atime),u},getFileDataAsTypedArray(e){return e.contents.subarray(0,e.usedBytes)},expandFileStorage(e,a){var i=e.contents.length;if(!(i>=a)){var d=1024*1024;a=Math.max(a,i*(i<d?2:1.125)>>>0),i&&(a=Math.max(a,256));var u=x.getFileDataAsTypedArray(e);e.contents=new Uint8Array(a),e.contents.set(u)}},resizeFileStorage(e,a){if(e.usedBytes!=a){var i=e.contents;e.contents=new Uint8Array(a),e.contents.set(i.subarray(0,Math.min(a,e.usedBytes))),e.usedBytes=a}},node_ops:{getattr(e){var a={};return a.dev=c.isChrdev(e.mode)?e.id:1,a.ino=e.id,a.mode=e.mode,a.nlink=1,a.uid=0,a.gid=0,a.rdev=e.rdev,c.isDir(e.mode)?a.size=4096:c.isFile(e.mode)?a.size=e.usedBytes:c.isLink(e.mode)?a.size=e.link.length:a.size=0,a.atime=new Date(e.atime),a.mtime=new Date(e.mtime),a.ctime=new Date(e.ctime),a.blksize=4096,a.blocks=Math.ceil(a.size/a.blksize),a},setattr(e,a){for(const i of["mode","atime","mtime","ctime"])a[i]!=null&&(e[i]=a[i]);a.size!==void 0&&x.resizeFileStorage(e,a.size)},lookup(e,a){throw x.doesNotExistError||(x.doesNotExistError=new c.ErrnoError(44),x.doesNotExistError.stack="<generic error, no stack>"),x.doesNotExistError},mknod(e,a,i,d){return x.createNode(e,a,i,d)},rename(e,a,i){var d;try{d=c.lookupNode(a,i)}catch{}if(d){if(c.isDir(e.mode))for(var u in d.contents)throw new c.ErrnoError(55);c.hashRemoveNode(d)}delete e.parent.contents[e.name],a.contents[i]=e,e.name=i,a.ctime=a.mtime=e.parent.ctime=e.parent.mtime=Date.now()},unlink(e,a){delete e.contents[a],e.ctime=e.mtime=Date.now()},rmdir(e,a){var i=c.lookupNode(e,a);for(var d in i.contents)throw new c.ErrnoError(55);delete e.contents[a],e.ctime=e.mtime=Date.now()},readdir(e){return[".","..",...Object.keys(e.contents)]},symlink(e,a,i){var d=x.createNode(e,a,41471,0);return d.link=i,d},readlink(e){if(!c.isLink(e.mode))throw new c.ErrnoError(28);return e.link}},stream_ops:{read(e,a,i,d,u){var E=e.node.contents;if(u>=e.node.usedBytes)return 0;var A=Math.min(e.node.usedBytes-u,d);return a.set(E.subarray(u,u+A),i),A},write(e,a,i,d,u,E){if(a.buffer===z.buffer&&(E=!1),!d)return 0;var A=e.node;return A.mtime=A.ctime=Date.now(),E?(A.contents=a.subarray(i,i+d),A.usedBytes=d):A.usedBytes===0&&u===0?(A.contents=a.slice(i,i+d),A.usedBytes=d):(x.expandFileStorage(A,u+d),A.contents.set(a.subarray(i,i+d),u),A.usedBytes=Math.max(A.usedBytes,u+d)),d},llseek(e,a,i){var d=a;if(i===1?d+=e.position:i===2&&c.isFile(e.node.mode)&&(d+=e.node.usedBytes),d<0)throw new c.ErrnoError(28);return d},mmap(e,a,i,d,u){if(!c.isFile(e.node.mode))throw new c.ErrnoError(43);var E,A,T=e.node.contents;if(!(u&2)&&T.buffer===z.buffer)A=!1,E=T.byteOffset;else{if(A=!0,E=le(),!E)throw new c.ErrnoError(48);T&&((i>0||i+a<T.length)&&(T.subarray?T=T.subarray(i,i+a):T=Array.prototype.slice.call(T,i,i+a)),z.set(T,E>>>0))}return{ptr:E,allocated:A}},msync(e,a,i,d,u){return x.stream_ops.write(e,a,0,d,i,!1),0}}},Ie=e=>{if(typeof e!="string")return e;var a={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},i=a[e];if(typeof i>"u")throw new Error(`Unknown file open mode: ${e}`);return i},ce=e=>(typeof e=="string"&&(e=Qt(e)),e.subarray||(e=new Uint8Array(e)),e),jt=(e,a)=>{var i=0;return e&&(i|=365),a&&(i|=146),i},me=async e=>{var a=await P(e);return new Uint8Array(a)},we=(...e)=>c.createDataFile(...e),pt=0,Wt=null,Ce=e=>{var i;if(pt--,(i=o.monitorRunDependencies)==null||i.call(o,pt),pt==0&&Wt){var a=Wt;Wt=null,a()}},De=e=>{var a;pt++,(a=o.monitorRunDependencies)==null||a.call(o,pt)},ue=[],Re=async(e,a)=>{typeof Browser<"u"&&Browser.init();for(var i of ue)if(i.canHandle(a))return i.handle(e,a);return e},Ee=async(e,a,i,d,u,E,A,T)=>{var v=a?Dt.resolve(X.join2(e,a)):e;De();try{var D=i;typeof i=="string"&&(D=await me(i)),D=await Re(D,v),T==null||T(),E||we(e,a,D,d,u,A)}finally{Ce()}},Xe=(e,a,i,d,u,E,A,T,v,D)=>{Ee(e,a,i,d,u,T,v,D).then(E).catch(A)},c={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,filesystems:null,syncFSRequests:0,ErrnoError:class{constructor(e){Gt(this,"name","ErrnoError");this.errno=e}},FSStream:class{constructor(){Gt(this,"shared",{})}get object(){return this.node}set object(e){this.node=e}get isRead(){return(this.flags&2097155)!==1}get isWrite(){return(this.flags&2097155)!==0}get isAppend(){return this.flags&1024}get flags(){return this.shared.flags}set flags(e){this.shared.flags=e}get position(){return this.shared.position}set position(e){this.shared.position=e}},FSNode:class{constructor(e,a,i,d){Gt(this,"node_ops",{});Gt(this,"stream_ops",{});Gt(this,"readMode",365);Gt(this,"writeMode",146);Gt(this,"mounted",null);e||(e=this),this.parent=e,this.mount=e.mount,this.id=c.nextInode++,this.name=a,this.mode=i,this.rdev=d,this.atime=this.mtime=this.ctime=Date.now()}get read(){return(this.mode&this.readMode)===this.readMode}set read(e){e?this.mode|=this.readMode:this.mode&=~this.readMode}get write(){return(this.mode&this.writeMode)===this.writeMode}set write(e){e?this.mode|=this.writeMode:this.mode&=~this.writeMode}get isFolder(){return c.isDir(this.mode)}get isDevice(){return c.isChrdev(this.mode)}},lookupPath(e,a={}){if(!e)throw new c.ErrnoError(44);a.follow_mount??(a.follow_mount=!0),X.isAbs(e)||(e=c.cwd()+"/"+e);t:for(var i=0;i<40;i++){for(var d=e.split("/").filter(D=>!!D),u=c.root,E="/",A=0;A<d.length;A++){var T=A===d.length-1;if(T&&a.parent)break;if(d[A]!=="."){if(d[A]===".."){if(E=X.dirname(E),c.isRoot(u)){e=E+"/"+d.slice(A+1).join("/"),i--;continue t}else u=u.parent;continue}E=X.join2(E,d[A]);try{u=c.lookupNode(u,d[A])}catch(D){if((D==null?void 0:D.errno)===44&&T&&a.noent_okay)return{path:E};throw D}if(c.isMountpoint(u)&&(!T||a.follow_mount)&&(u=u.mounted.root),c.isLink(u.mode)&&(!T||a.follow)){if(!u.node_ops.readlink)throw new c.ErrnoError(52);var v=u.node_ops.readlink(u);X.isAbs(v)||(v=X.dirname(E)+"/"+v),e=v+"/"+d.slice(A+1).join("/");continue t}}}return{path:E,node:u}}throw new c.ErrnoError(32)},getPath(e){for(var a;;){if(c.isRoot(e)){var i=e.mount.mountpoint;return a?i[i.length-1]!=="/"?`${i}/${a}`:i+a:i}a=a?`${e.name}/${a}`:e.name,e=e.parent}},hashName(e,a){for(var i=0,d=0;d<a.length;d++)i=(i<<5)-i+a.charCodeAt(d)|0;return(e+i>>>0)%c.nameTable.length},hashAddNode(e){var a=c.hashName(e.parent.id,e.name);e.name_next=c.nameTable[a],c.nameTable[a]=e},hashRemoveNode(e){var a=c.hashName(e.parent.id,e.name);if(c.nameTable[a]===e)c.nameTable[a]=e.name_next;else for(var i=c.nameTable[a];i;){if(i.name_next===e){i.name_next=e.name_next;break}i=i.name_next}},lookupNode(e,a){var i=c.mayLookup(e);if(i)throw new c.ErrnoError(i);for(var d=c.hashName(e.id,a),u=c.nameTable[d];u;u=u.name_next){var E=u.name;if(u.parent.id===e.id&&E===a)return u}return c.lookup(e,a)},createNode(e,a,i,d){var u=new c.FSNode(e,a,i,d);return c.hashAddNode(u),u},destroyNode(e){c.hashRemoveNode(e)},isRoot(e){return e===e.parent},isMountpoint(e){return!!e.mounted},isFile(e){return(e&61440)===32768},isDir(e){return(e&61440)===16384},isLink(e){return(e&61440)===40960},isChrdev(e){return(e&61440)===8192},isBlkdev(e){return(e&61440)===24576},isFIFO(e){return(e&61440)===4096},isSocket(e){return(e&49152)===49152},flagsToPermissionString(e){var a=["r","w","rw"][e&3];return e&512&&(a+="w"),a},nodePermissions(e,a){return c.ignorePermissions?0:a.includes("r")&&!(e.mode&292)||a.includes("w")&&!(e.mode&146)||a.includes("x")&&!(e.mode&73)?2:0},mayLookup(e){if(!c.isDir(e.mode))return 54;var a=c.nodePermissions(e,"x");return a||(e.node_ops.lookup?0:2)},mayCreate(e,a){if(!c.isDir(e.mode))return 54;try{var i=c.lookupNode(e,a);return 20}catch{}return c.nodePermissions(e,"wx")},mayDelete(e,a,i){var d;try{d=c.lookupNode(e,a)}catch(E){return E.errno}var u=c.nodePermissions(e,"wx");if(u)return u;if(i){if(!c.isDir(d.mode))return 54;if(c.isRoot(d)||c.getPath(d)===c.cwd())return 10}else if(c.isDir(d.mode))return 31;return 0},mayOpen(e,a){if(!e)return 44;if(c.isLink(e.mode))return 32;var i=c.flagsToPermissionString(a);return c.isDir(e.mode)&&(i!=="r"||a&576)?31:c.nodePermissions(e,i)},checkOpExists(e,a){if(!e)throw new c.ErrnoError(a);return e},MAX_OPEN_FDS:4096,nextfd(){for(var e=0;e<=c.MAX_OPEN_FDS;e++)if(!c.streams[e])return e;throw new c.ErrnoError(33)},getStreamChecked(e){var a=c.getStream(e);if(!a)throw new c.ErrnoError(8);return a},getStream:e=>c.streams[e],createStream(e,a=-1){return e=Object.assign(new c.FSStream,e),a==-1&&(a=c.nextfd()),e.fd=a,c.streams[a]=e,e},closeStream(e){c.streams[e]=null},dupStream(e,a=-1){var d,u;var i=c.createStream(e,a);return(u=(d=i.stream_ops)==null?void 0:d.dup)==null||u.call(d,i),i},doSetAttr(e,a,i){var d=e==null?void 0:e.stream_ops.setattr,u=d?e:a;d??(d=a.node_ops.setattr),c.checkOpExists(d,63);try{d(u,i)}catch(E){throw E instanceof RangeError?new c.ErrnoError(22):E}},chrdev_stream_ops:{open(e){var i,d;var a=c.getDevice(e.node.rdev);e.stream_ops=a.stream_ops,(d=(i=e.stream_ops).open)==null||d.call(i,e)},llseek(){throw new c.ErrnoError(70)}},major:e=>e>>8,minor:e=>e&255,makedev:(e,a)=>e<<8|a,registerDevice(e,a){c.devices[e]={stream_ops:a}},getDevice:e=>c.devices[e],getMounts(e){for(var a=[],i=[e];i.length;){var d=i.pop();a.push(d),i.push(...d.mounts)}return a},syncfs(e,a){typeof e=="function"&&(a=e,e=!1),c.syncFSRequests++,c.syncFSRequests>1&&w(`warning: ${c.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var i=c.getMounts(c.root.mount),d=0;function u(T){return c.syncFSRequests--,a(T)}function E(T){if(T)return E.errored?void 0:(E.errored=!0,u(T));++d>=i.length&&u(null)}for(var A of i)A.type.syncfs?A.type.syncfs(A,e,E):E(null)},mount(e,a,i){var d=i==="/",u=!i,E;if(d&&c.root)throw new c.ErrnoError(10);if(!d&&!u){var A=c.lookupPath(i,{follow_mount:!1});if(i=A.path,E=A.node,c.isMountpoint(E))throw new c.ErrnoError(10);if(!c.isDir(E.mode))throw new c.ErrnoError(54)}var T={type:e,opts:a,mountpoint:i,mounts:[]},v=e.mount(T);return v.mount=T,T.root=v,d?c.root=v:E&&(E.mounted=T,E.mount&&E.mount.mounts.push(T)),v},unmount(e){var a=c.lookupPath(e,{follow_mount:!1});if(!c.isMountpoint(a.node))throw new c.ErrnoError(28);var i=a.node,d=i.mounted,u=c.getMounts(d);for(var[E,A]of Object.entries(c.nameTable))for(;A;){var T=A.name_next;u.includes(A.mount)&&c.destroyNode(A),A=T}i.mounted=null;var v=i.mount.mounts.indexOf(d);i.mount.mounts.splice(v,1)},lookup(e,a){return e.node_ops.lookup(e,a)},mknod(e,a,i){var d=c.lookupPath(e,{parent:!0}),u=d.node,E=X.basename(e);if(!E)throw new c.ErrnoError(28);if(E==="."||E==="..")throw new c.ErrnoError(20);var A=c.mayCreate(u,E);if(A)throw new c.ErrnoError(A);if(!u.node_ops.mknod)throw new c.ErrnoError(63);return u.node_ops.mknod(u,E,a,i)},statfs(e){return c.statfsNode(c.lookupPath(e,{follow:!0}).node)},statfsStream(e){return c.statfsNode(e.node)},statfsNode(e){var a={bsize:4096,frsize:4096,blocks:1e6,bfree:5e5,bavail:5e5,files:c.nextInode,ffree:c.nextInode-1,fsid:42,flags:2,namelen:255};return e.node_ops.statfs&&Object.assign(a,e.node_ops.statfs(e.mount.opts.root)),a},create(e,a=438){return a&=4095,a|=32768,c.mknod(e,a,0)},mkdir(e,a=511){return a&=1023,a|=16384,c.mknod(e,a,0)},mkdirTree(e,a){var i=e.split("/"),d="";for(var u of i)if(u){(d||X.isAbs(e))&&(d+="/"),d+=u;try{c.mkdir(d,a)}catch(E){if(E.errno!=20)throw E}}},mkdev(e,a,i){return typeof i>"u"&&(i=a,a=438),a|=8192,c.mknod(e,a,i)},symlink(e,a){if(!Dt.resolve(e))throw new c.ErrnoError(44);var i=c.lookupPath(a,{parent:!0}),d=i.node;if(!d)throw new c.ErrnoError(44);var u=X.basename(a),E=c.mayCreate(d,u);if(E)throw new c.ErrnoError(E);if(!d.node_ops.symlink)throw new c.ErrnoError(63);return d.node_ops.symlink(d,u,e)},rename(e,a){var i=X.dirname(e),d=X.dirname(a),u=X.basename(e),E=X.basename(a),A,T,v;if(A=c.lookupPath(e,{parent:!0}),T=A.node,A=c.lookupPath(a,{parent:!0}),v=A.node,!T||!v)throw new c.ErrnoError(44);if(T.mount!==v.mount)throw new c.ErrnoError(75);var D=c.lookupNode(T,u),L=Dt.relative(e,d);if(L.charAt(0)!==".")throw new c.ErrnoError(28);if(L=Dt.relative(a,i),L.charAt(0)!==".")throw new c.ErrnoError(55);var G;try{G=c.lookupNode(v,E)}catch{}if(D!==G){var b=c.isDir(D.mode),Y=c.mayDelete(T,u,b);if(Y)throw new c.ErrnoError(Y);if(Y=G?c.mayDelete(v,E,b):c.mayCreate(v,E),Y)throw new c.ErrnoError(Y);if(!T.node_ops.rename)throw new c.ErrnoError(63);if(c.isMountpoint(D)||G&&c.isMountpoint(G))throw new c.ErrnoError(10);if(v!==T&&(Y=c.nodePermissions(T,"w"),Y))throw new c.ErrnoError(Y);c.hashRemoveNode(D);try{T.node_ops.rename(D,v,E),D.parent=v}catch(F){throw F}finally{c.hashAddNode(D)}}},rmdir(e){var a=c.lookupPath(e,{parent:!0}),i=a.node,d=X.basename(e),u=c.lookupNode(i,d),E=c.mayDelete(i,d,!0);if(E)throw new c.ErrnoError(E);if(!i.node_ops.rmdir)throw new c.ErrnoError(63);if(c.isMountpoint(u))throw new c.ErrnoError(10);i.node_ops.rmdir(i,d),c.destroyNode(u)},readdir(e){var a=c.lookupPath(e,{follow:!0}),i=a.node,d=c.checkOpExists(i.node_ops.readdir,54);return d(i)},unlink(e){var a=c.lookupPath(e,{parent:!0}),i=a.node;if(!i)throw new c.ErrnoError(44);var d=X.basename(e),u=c.lookupNode(i,d),E=c.mayDelete(i,d,!1);if(E)throw new c.ErrnoError(E);if(!i.node_ops.unlink)throw new c.ErrnoError(63);if(c.isMountpoint(u))throw new c.ErrnoError(10);i.node_ops.unlink(i,d),c.destroyNode(u)},readlink(e){var a=c.lookupPath(e),i=a.node;if(!i)throw new c.ErrnoError(44);if(!i.node_ops.readlink)throw new c.ErrnoError(28);return i.node_ops.readlink(i)},stat(e,a){var i=c.lookupPath(e,{follow:!a}),d=i.node,u=c.checkOpExists(d.node_ops.getattr,63);return u(d)},fstat(e){var a=c.getStreamChecked(e),i=a.node,d=a.stream_ops.getattr,u=d?a:i;return d??(d=i.node_ops.getattr),c.checkOpExists(d,63),d(u)},lstat(e){return c.stat(e,!0)},doChmod(e,a,i,d){c.doSetAttr(e,a,{mode:i&4095|a.mode&-4096,ctime:Date.now(),dontFollow:d})},chmod(e,a,i){var d;if(typeof e=="string"){var u=c.lookupPath(e,{follow:!i});d=u.node}else d=e;c.doChmod(null,d,a,i)},lchmod(e,a){c.chmod(e,a,!0)},fchmod(e,a){var i=c.getStreamChecked(e);c.doChmod(i,i.node,a,!1)},doChown(e,a,i){c.doSetAttr(e,a,{timestamp:Date.now(),dontFollow:i})},chown(e,a,i,d){var u;if(typeof e=="string"){var E=c.lookupPath(e,{follow:!d});u=E.node}else u=e;c.doChown(null,u,d)},lchown(e,a,i){c.chown(e,a,i,!0)},fchown(e,a,i){var d=c.getStreamChecked(e);c.doChown(d,d.node,!1)},doTruncate(e,a,i){if(c.isDir(a.mode))throw new c.ErrnoError(31);if(!c.isFile(a.mode))throw new c.ErrnoError(28);var d=c.nodePermissions(a,"w");if(d)throw new c.ErrnoError(d);c.doSetAttr(e,a,{size:i,timestamp:Date.now()})},truncate(e,a){if(a<0)throw new c.ErrnoError(28);var i;if(typeof e=="string"){var d=c.lookupPath(e,{follow:!0});i=d.node}else i=e;c.doTruncate(null,i,a)},ftruncate(e,a){var i=c.getStreamChecked(e);if(a<0||(i.flags&2097155)===0)throw new c.ErrnoError(28);c.doTruncate(i,i.node,a)},utime(e,a,i){var d=c.lookupPath(e,{follow:!0}),u=d.node,E=c.checkOpExists(u.node_ops.setattr,63);E(u,{atime:a,mtime:i})},open(e,a,i=438){if(e==="")throw new c.ErrnoError(44);a=Ie(a),a&64?i=i&4095|32768:i=0;var d,u;if(typeof e=="object")d=e;else{u=e.endsWith("/");var E=c.lookupPath(e,{follow:!(a&131072),noent_okay:!0});d=E.node,e=E.path}var A=!1;if(a&64)if(d){if(a&128)throw new c.ErrnoError(20)}else{if(u)throw new c.ErrnoError(31);d=c.mknod(e,i|511,0),A=!0}if(!d)throw new c.ErrnoError(44);if(c.isChrdev(d.mode)&&(a&=-513),a&65536&&!c.isDir(d.mode))throw new c.ErrnoError(54);if(!A){var T=c.mayOpen(d,a);if(T)throw new c.ErrnoError(T)}a&512&&!A&&c.truncate(d,0),a&=-131713;var v=c.createStream({node:d,path:c.getPath(d),flags:a,seekable:!0,position:0,stream_ops:d.stream_ops,ungotten:[],error:!1});return v.stream_ops.open&&v.stream_ops.open(v),A&&c.chmod(d,i&511),v},close(e){if(c.isClosed(e))throw new c.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(a){throw a}finally{c.closeStream(e.fd)}e.fd=null},isClosed(e){return e.fd===null},llseek(e,a,i){if(c.isClosed(e))throw new c.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new c.ErrnoError(70);if(i!=0&&i!=1&&i!=2)throw new c.ErrnoError(28);return e.position=e.stream_ops.llseek(e,a,i),e.ungotten=[],e.position},read(e,a,i,d,u){if(d<0||u<0)throw new c.ErrnoError(28);if(c.isClosed(e))throw new c.ErrnoError(8);if((e.flags&2097155)===1)throw new c.ErrnoError(8);if(c.isDir(e.node.mode))throw new c.ErrnoError(31);if(!e.stream_ops.read)throw new c.ErrnoError(28);var E=typeof u<"u";if(!E)u=e.position;else if(!e.seekable)throw new c.ErrnoError(70);var A=e.stream_ops.read(e,a,i,d,u);return E||(e.position+=A),A},write(e,a,i,d,u,E){if(d<0||u<0)throw new c.ErrnoError(28);if(c.isClosed(e))throw new c.ErrnoError(8);if((e.flags&2097155)===0)throw new c.ErrnoError(8);if(c.isDir(e.node.mode))throw new c.ErrnoError(31);if(!e.stream_ops.write)throw new c.ErrnoError(28);e.seekable&&e.flags&1024&&c.llseek(e,0,2);var A=typeof u<"u";if(!A)u=e.position;else if(!e.seekable)throw new c.ErrnoError(70);var T=e.stream_ops.write(e,a,i,d,u,E);return A||(e.position+=T),T},mmap(e,a,i,d,u){if((d&2)!==0&&(u&2)===0&&(e.flags&2097155)!==2)throw new c.ErrnoError(2);if((e.flags&2097155)===1)throw new c.ErrnoError(2);if(!e.stream_ops.mmap)throw new c.ErrnoError(43);if(!a)throw new c.ErrnoError(28);return e.stream_ops.mmap(e,a,i,d,u)},msync(e,a,i,d,u){return e.stream_ops.msync?e.stream_ops.msync(e,a,i,d,u):0},ioctl(e,a,i){if(!e.stream_ops.ioctl)throw new c.ErrnoError(59);return e.stream_ops.ioctl(e,a,i)},readFile(e,a={}){a.flags=a.flags??0,a.encoding=a.encoding??"binary",a.encoding!=="utf8"&&a.encoding!=="binary"&&Z(`Invalid encoding type "${a.encoding}"`);var i=c.open(e,a.flags),d=c.stat(e),u=d.size,E=new Uint8Array(u);return c.read(i,E,0,u,0),a.encoding==="utf8"&&(E=Yt(E)),c.close(i),E},writeFile(e,a,i={}){i.flags=i.flags??577;var d=c.open(e,i.flags,i.mode);a=ce(a),c.write(d,a,0,a.byteLength,void 0,i.canOwn),c.close(d)},cwd:()=>c.currentPath,chdir(e){var a=c.lookupPath(e,{follow:!0});if(a.node===null)throw new c.ErrnoError(44);if(!c.isDir(a.node.mode))throw new c.ErrnoError(54);var i=c.nodePermissions(a.node,"x");if(i)throw new c.ErrnoError(i);c.currentPath=a.path},createDefaultDirectories(){c.mkdir("/tmp"),c.mkdir("/home"),c.mkdir("/home/web_user")},createDefaultDevices(){c.mkdir("/dev"),c.registerDevice(c.makedev(1,3),{read:()=>0,write:(d,u,E,A,T)=>A,llseek:()=>0}),c.mkdev("/dev/null",c.makedev(1,3)),Pt.register(c.makedev(5,0),Pt.default_tty_ops),Pt.register(c.makedev(6,0),Pt.default_tty1_ops),c.mkdev("/dev/tty",c.makedev(5,0)),c.mkdev("/dev/tty1",c.makedev(6,0));var e=new Uint8Array(1024),a=0,i=()=>(a===0&&(qt(e),a=e.byteLength),e[--a]);c.createDevice("/dev","random",i),c.createDevice("/dev","urandom",i),c.mkdir("/dev/shm"),c.mkdir("/dev/shm/tmp")},createSpecialDirectories(){c.mkdir("/proc");var e=c.mkdir("/proc/self");c.mkdir("/proc/self/fd"),c.mount({mount(){var a=c.createNode(e,"fd",16895,73);return a.stream_ops={llseek:x.stream_ops.llseek},a.node_ops={lookup(i,d){var u=+d,E=c.getStreamChecked(u),A={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>E.path},id:u+1};return A.parent=A,A},readdir(){return Array.from(c.streams.entries()).filter(([i,d])=>d).map(([i,d])=>i.toString())}},a}},{},"/proc/self/fd")},createStandardStreams(e,a,i){e?c.createDevice("/dev","stdin",e):c.symlink("/dev/tty","/dev/stdin"),a?c.createDevice("/dev","stdout",null,a):c.symlink("/dev/tty","/dev/stdout"),i?c.createDevice("/dev","stderr",null,i):c.symlink("/dev/tty1","/dev/stderr"),c.open("/dev/stdin",0),c.open("/dev/stdout",1),c.open("/dev/stderr",1)},staticInit(){c.nameTable=new Array(4096),c.mount(x,{},"/"),c.createDefaultDirectories(),c.createDefaultDevices(),c.createSpecialDirectories(),c.filesystems={MEMFS:x}},init(e,a,i){c.initialized=!0,e??(e=o.stdin),a??(a=o.stdout),i??(i=o.stderr),c.createStandardStreams(e,a,i)},quit(){c.initialized=!1;for(var e of c.streams)e&&c.close(e)},findObject(e,a){var i=c.analyzePath(e,a);return i.exists?i.object:null},analyzePath(e,a){try{var i=c.lookupPath(e,{follow:!a});e=i.path}catch{}var d={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var i=c.lookupPath(e,{parent:!0});d.parentExists=!0,d.parentPath=i.path,d.parentObject=i.node,d.name=X.basename(e),i=c.lookupPath(e,{follow:!a}),d.exists=!0,d.path=i.path,d.object=i.node,d.name=i.node.name,d.isRoot=i.path==="/"}catch(u){d.error=u.errno}return d},createPath(e,a,i,d){e=typeof e=="string"?e:c.getPath(e);for(var u=a.split("/").reverse();u.length;){var E=u.pop();if(E){var A=X.join2(e,E);try{c.mkdir(A)}catch(T){if(T.errno!=20)throw T}e=A}}return A},createFile(e,a,i,d,u){var E=X.join2(typeof e=="string"?e:c.getPath(e),a),A=jt(d,u);return c.create(E,A)},createDataFile(e,a,i,d,u,E){var A=a;e&&(e=typeof e=="string"?e:c.getPath(e),A=a?X.join2(e,a):e);var T=jt(d,u),v=c.create(A,T);if(i){i=ce(i),c.chmod(v,T|146);var D=c.open(v,577);c.write(D,i,0,i.length,0,E),c.close(D),c.chmod(v,T)}},createDevice(e,a,i,d){var T;var u=X.join2(typeof e=="string"?e:c.getPath(e),a),E=jt(!!i,!!d);(T=c.createDevice).major??(T.major=64);var A=c.makedev(c.createDevice.major++,0);return c.registerDevice(A,{open(v){v.seekable=!1},close(v){var D;(D=d==null?void 0:d.buffer)!=null&&D.length&&d(10)},read(v,D,L,G,b){for(var Y=0,F=0;F<G;F++){var H;try{H=i()}catch{throw new c.ErrnoError(29)}if(H===void 0&&Y===0)throw new c.ErrnoError(6);if(H==null)break;Y++,D[L+F]=H}return Y&&(v.node.atime=Date.now()),Y},write(v,D,L,G,b){for(var Y=0;Y<G;Y++)try{d(D[L+Y])}catch{throw new c.ErrnoError(29)}return G&&(v.node.mtime=v.node.ctime=Date.now()),Y}}),c.mkdev(u,E,A)},forceLoadFile(e){if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if(globalThis.XMLHttpRequest)Z("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");else try{e.contents=p(e.url)}catch{throw new c.ErrnoError(29)}},createLazyFile(e,a,i,d,u){class E{constructor(){Gt(this,"lengthKnown",!1);Gt(this,"chunks",[])}get(b){if(!(b>this.length-1||b<0)){var Y=b%this.chunkSize,F=b/this.chunkSize|0;return this.getter(F)[Y]}}setDataGetter(b){this.getter=b}cacheLength(){var b=new XMLHttpRequest;b.open("HEAD",i,!1),b.send(null),b.status>=200&&b.status<300||b.status===304||Z("Couldn't load "+i+". Status: "+b.status);var Y=Number(b.getResponseHeader("Content-length")),F,H=(F=b.getResponseHeader("Accept-Ranges"))&&F==="bytes",rt=(F=b.getResponseHeader("Content-Encoding"))&&F==="gzip",at=1024*1024;H||(at=Y);var ct=(vt,Vt)=>{vt>Vt&&Z(`invalid range (${vt}, ${Vt}) or no bytes requested!`),Vt>Y-1&&Z(`only ${Y} bytes available! programmer error!`);var it=new XMLHttpRequest;return it.open("GET",i,!1),Y!==at&&it.setRequestHeader("Range","bytes="+vt+"-"+Vt),it.responseType="arraybuffer",it.overrideMimeType&&it.overrideMimeType("text/plain; charset=x-user-defined"),it.send(null),it.status>=200&&it.status<300||it.status===304||Z("Couldn't load "+i+". Status: "+it.status),it.response!==void 0?new Uint8Array(it.response||[]):Qt(it.responseText??"")},_t=this;_t.setDataGetter(vt=>{var Vt=vt*at,it=(vt+1)*at-1;return it=Math.min(it,Y-1),typeof _t.chunks[vt]>"u"&&(_t.chunks[vt]=ct(Vt,it)),typeof _t.chunks[vt]>"u"&&Z("doXHR failed!"),_t.chunks[vt]}),(rt||!Y)&&(at=Y=1,Y=this.getter(0).length,at=Y,C("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=Y,this._chunkSize=at,this.lengthKnown=!0}get length(){return this.lengthKnown||this.cacheLength(),this._length}get chunkSize(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}if(globalThis.XMLHttpRequest){s||Z("Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc");var A=new E,T={isDevice:!1,contents:A}}else var T={isDevice:!1,url:i};var v=c.createFile(e,a,T,d,u);T.contents?v.contents=T.contents:T.url&&(v.contents=null,v.url=T.url),Object.defineProperties(v,{usedBytes:{get:function(){return this.contents.length}}});var D={};for(const[G,b]of Object.entries(v.stream_ops))D[G]=(...Y)=>(c.forceLoadFile(v),b(...Y));function L(G,b,Y,F,H){var rt=G.node.contents;if(H>=rt.length)return 0;var at=Math.min(rt.length-H,F);if(rt.slice)for(var ct=0;ct<at;ct++)b[Y+ct]=rt[H+ct];else for(var ct=0;ct<at;ct++)b[Y+ct]=rt.get(H+ct);return at}return D.read=(G,b,Y,F,H)=>(c.forceLoadFile(v),L(G,b,Y,F,H)),D.mmap=(G,b,Y,F,H)=>{c.forceLoadFile(v);var rt=le();if(!rt)throw new c.ErrnoError(48);return L(G,z,rt,b,Y),{ptr:rt,allocated:!0}},v.stream_ops=D,v}},te=(e,a,i)=>(e>>>=0,e?Yt(lt,e,a,i):""),Q={currentUmask:18,calculateAt(e,a,i){if(X.isAbs(a))return a;var d;if(e===-100)d=c.cwd();else{var u=Q.getStreamFromFD(e);d=u.path}if(a.length==0){if(!i)throw new c.ErrnoError(44);return d}return d+"/"+a},writeStat(e,a){B[e>>>2>>>0]=a.dev,B[e+4>>>2>>>0]=a.mode,B[e+8>>>2>>>0]=a.nlink,B[e+12>>>2>>>0]=a.uid,B[e+16>>>2>>>0]=a.gid,B[e+20>>>2>>>0]=a.rdev,tt[e+24>>>3>>>0]=BigInt(a.size),k[e+32>>>2>>>0]=4096,k[e+36>>>2>>>0]=a.blocks;var i=a.atime.getTime(),d=a.mtime.getTime(),u=a.ctime.getTime();return tt[e+40>>>3>>>0]=BigInt(Math.floor(i/1e3)),B[e+48>>>2>>>0]=i%1e3*1e3*1e3,tt[e+56>>>3>>>0]=BigInt(Math.floor(d/1e3)),B[e+64>>>2>>>0]=d%1e3*1e3*1e3,tt[e+72>>>3>>>0]=BigInt(Math.floor(u/1e3)),B[e+80>>>2>>>0]=u%1e3*1e3*1e3,tt[e+88>>>3>>>0]=BigInt(a.ino),0},writeStatFs(e,a){B[e+4>>>2>>>0]=a.bsize,B[e+60>>>2>>>0]=a.bsize,tt[e+8>>>3>>>0]=BigInt(a.blocks),tt[e+16>>>3>>>0]=BigInt(a.bfree),tt[e+24>>>3>>>0]=BigInt(a.bavail),tt[e+32>>>3>>>0]=BigInt(a.files),tt[e+40>>>3>>>0]=BigInt(a.ffree),B[e+48>>>2>>>0]=a.fsid,B[e+64>>>2>>>0]=a.flags,B[e+56>>>2>>>0]=a.namelen},doMsync(e,a,i,d,u){if(!c.isFile(a.node.mode))throw new c.ErrnoError(43);if(d&2)return 0;var E=lt.slice(e,e+i);c.msync(a,E,u,i,d)},getStreamFromFD(e){var a=c.getStreamChecked(e);return a},varargs:void 0,getStr(e){var a=te(e);return a}};function cn(e,a,i){i>>>=0,Q.varargs=i;try{var d=Q.getStreamFromFD(e);switch(a){case 0:{var u=Zt();if(u<0)return-28;for(;c.streams[u];)u++;var E;return E=c.dupStream(d,u),E.fd}case 1:case 2:return 0;case 3:return d.flags;case 4:{var u=Zt(),A=289792;return d.flags=d.flags&~A|u&A,0}case 12:{var u=Lt(),T=0;return dt[u+T>>>1>>>0]=2,0}case 13:case 14:return 0}return-28}catch(v){if(typeof c>"u"||v.name!=="ErrnoError")throw v;return-v.errno}}function un(e,a){a>>>=0;try{return Q.writeStat(a,c.fstat(e))}catch(i){if(typeof c>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}function En(e,a,i){i>>>=0,Q.varargs=i;try{var d=Q.getStreamFromFD(e);switch(a){case 21509:return d.tty?0:-59;case 21505:{if(!d.tty)return-59;if(d.tty.ops.ioctl_tcgets){var u=d.tty.ops.ioctl_tcgets(d),E=Lt();k[E>>>2>>>0]=u.c_iflag||0,k[E+4>>>2>>>0]=u.c_oflag||0,k[E+8>>>2>>>0]=u.c_cflag||0,k[E+12>>>2>>>0]=u.c_lflag||0;for(var A=0;A<32;A++)z[E+A+17>>>0]=u.c_cc[A]||0;return 0}return 0}case 21510:case 21511:case 21512:return d.tty?0:-59;case 21506:case 21507:case 21508:{if(!d.tty)return-59;if(d.tty.ops.ioctl_tcsets){for(var E=Lt(),T=k[E>>>2>>>0],v=k[E+4>>>2>>>0],D=k[E+8>>>2>>>0],L=k[E+12>>>2>>>0],G=[],A=0;A<32;A++)G.push(z[E+A+17>>>0]);return d.tty.ops.ioctl_tcsets(d.tty,a,{c_iflag:T,c_oflag:v,c_cflag:D,c_lflag:L,c_cc:G})}return 0}case 21519:{if(!d.tty)return-59;var E=Lt();return k[E>>>2>>>0]=0,0}case 21520:return d.tty?-28:-59;case 21537:case 21531:{var E=Lt();return c.ioctl(d,a,E)}case 21523:{if(!d.tty)return-59;if(d.tty.ops.ioctl_tiocgwinsz){var b=d.tty.ops.ioctl_tiocgwinsz(d.tty),E=Lt();dt[E>>>1>>>0]=b[0],dt[E+2>>>1>>>0]=b[1]}return 0}case 21524:return d.tty?0:-59;case 21515:return d.tty?0:-59;default:return-28}}catch(Y){if(typeof c>"u"||Y.name!=="ErrnoError")throw Y;return-Y.errno}}function Ke(e,a){e>>>=0,a>>>=0;try{return e=Q.getStr(e),Q.writeStat(a,c.lstat(e))}catch(i){if(typeof c>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}function Ge(e,a,i,d){a>>>=0,i>>>=0;try{a=Q.getStr(a);var u=d&256,E=d&4096;return d=d&-6401,a=Q.calculateAt(e,a,E),Q.writeStat(i,u?c.lstat(a):c.stat(a))}catch(A){if(typeof c>"u"||A.name!=="ErrnoError")throw A;return-A.errno}}function K(e,a,i,d){a>>>=0,d>>>=0,Q.varargs=d;try{a=Q.getStr(a),a=Q.calculateAt(e,a);var u=d?Zt():0;return i&64&&(u&=~Q.currentUmask),c.open(a,i,u).fd}catch(E){if(typeof c>"u"||E.name!=="ErrnoError")throw E;return-E.errno}}function j(e,a){e>>>=0,a>>>=0;try{return e=Q.getStr(e),Q.writeStat(a,c.stat(e))}catch(i){if(typeof c>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}var ee=()=>Z(""),st=e=>{e>>>=0;for(var a="";;){var i=lt[e++>>>0];if(!i)return a;a+=String.fromCharCode(i)}},ne={},$t={},re={},Se=class extends Error{constructor(a){super(a),this.name="BindingError"}},$=e=>{throw new Se(e)};function ze(e,a,i={}){var d=a.name;if(e||$(`type "${d}" must have a positive integer typeid pointer`),$t.hasOwnProperty(e)){if(i.ignoreDuplicateRegistrations)return;$(`Cannot register type '${d}' twice`)}if($t[e]=a,delete re[e],ne.hasOwnProperty(e)){var u=ne[e];delete ne[e],u.forEach(E=>E())}}function ot(e,a,i={}){return ze(e,a,i)}var Rt=(e,a,i)=>{switch(a){case 1:return i?d=>z[d>>>0]:d=>lt[d>>>0];case 2:return i?d=>dt[d>>>1>>>0]:d=>Tt[d>>>1>>>0];case 4:return i?d=>k[d>>>2>>>0]:d=>B[d>>>2>>>0];case 8:return i?d=>tt[d>>>3>>>0]:d=>Xt[d>>>3>>>0];default:throw new TypeError(`invalid integer width (${a}): ${e}`)}},Je=function(e,a,i,d,u){e>>>=0,a>>>=0,i>>>=0,a=st(a);const E=d===0n;let A=T=>T;if(E){const T=i*8;A=v=>BigInt.asUintN(T,v),u=A(u)}ot(e,{name:a,fromWireType:A,toWireType:(T,v)=>(typeof v=="number"&&(v=BigInt(v)),v),readValueFromPointer:Rt(a,i,!E),destructorFunction:null})};function fn(e,a,i,d){e>>>=0,a>>>=0,a=st(a),ot(e,{name:a,fromWireType:function(u){return!!u},toWireType:function(u,E){return E?i:d},readValueFromPointer:function(u){return this.fromWireType(lt[u>>>0])},destructorFunction:null})}var hn=e=>({count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}),Me=e=>{function a(i){return i.$$.ptrType.registeredClass.name}$(a(e)+" instance already deleted")},be=!1,Le=e=>{},xe=e=>{e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)},Oe=e=>{e.count.value-=1;var a=e.count.value===0;a&&xe(e)},ke=e=>globalThis.FinalizationRegistry?(be=new FinalizationRegistry(a=>{Oe(a.$$)}),ke=a=>{var i=a.$$,d=!!i.smartPtr;if(d){var u={$$:i};be.register(a,u,a)}return a},Le=a=>be.unregister(a),ke(e)):(ke=a=>a,e),wr=()=>{let e=Ze.prototype;Object.assign(e,{isAliasOf(i){if(!(this instanceof Ze)||!(i instanceof Ze))return!1;var d=this.$$.ptrType.registeredClass,u=this.$$.ptr;i.$$=i.$$;for(var E=i.$$.ptrType.registeredClass,A=i.$$.ptr;d.baseClass;)u=d.upcast(u),d=d.baseClass;for(;E.baseClass;)A=E.upcast(A),E=E.baseClass;return d===E&&u===A},clone(){if(this.$$.ptr||Me(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var i=ke(Object.create(Object.getPrototypeOf(this),{$$:{value:hn(this.$$)}}));return i.$$.count.value+=1,i.$$.deleteScheduled=!1,i},delete(){this.$$.ptr||Me(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&$("Object already scheduled for deletion"),Le(this),Oe(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},isDeleted(){return!this.$$.ptr},deleteLater(){return this.$$.ptr||Me(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&$("Object already scheduled for deletion"),this.$$.deleteScheduled=!0,this}});const a=Symbol.dispose;a&&(e[a]=e.delete)};function Ze(){}var qe=(e,a)=>Object.defineProperty(a,"name",{value:e}),Mn={},Cr=(e,a,i)=>{if(e[a].overloadTable===void 0){var d=e[a];e[a]=function(...u){return e[a].overloadTable.hasOwnProperty(u.length)||$(`Function '${i}' called with an invalid number of arguments (${u.length}) - expects one of (${e[a].overloadTable})!`),e[a].overloadTable[u.length].apply(this,u)},e[a].overloadTable=[],e[a].overloadTable[d.argCount]=d}},Be=(e,a,i)=>{o.hasOwnProperty(e)?((i===void 0||o[e].overloadTable!==void 0&&o[e].overloadTable[i]!==void 0)&&$(`Cannot register public name '${e}' twice`),Cr(o,e,e),o[e].overloadTable.hasOwnProperty(i)&&$(`Cannot register multiple overloads of a function with the same number of arguments (${i})!`),o[e].overloadTable[i]=a):(o[e]=a,o[e].argCount=i)},Dr=48,Rr=57,Sr=e=>{e=e.replace(/[^a-zA-Z0-9_]/g,"$");var a=e.charCodeAt(0);return a>=Dr&&a<=Rr?`_${e}`:e};function Lr(e,a,i,d,u,E,A,T){this.name=e,this.constructor=a,this.instancePrototype=i,this.rawDestructor=d,this.baseClass=u,this.getActualType=E,this.upcast=A,this.downcast=T,this.pureVirtualFunctions=[]}var Qe=(e,a,i)=>{for(;a!==i;)a.upcast||$(`Expected null or instance of ${i.name}, got an instance of ${a.name}`),e=a.upcast(e),a=a.baseClass;return e},gn=e=>{if(e===null)return"null";var a=typeof e;return a==="object"||a==="array"||a==="function"?e.toString():""+e};function Yr(e,a){if(a===null)return this.isReference&&$(`null is not a valid ${this.name}`),0;a.$$||$(`Cannot pass "${gn(a)}" as a ${this.name}`),a.$$.ptr||$(`Cannot pass deleted object as a pointer of type ${this.name}`);var i=a.$$.ptrType.registeredClass,d=Qe(a.$$.ptr,i,this.registeredClass);return d}function Nr(e,a){var i;if(a===null)return this.isReference&&$(`null is not a valid ${this.name}`),this.isSmartPointer?(i=this.rawConstructor(),e!==null&&e.push(this.rawDestructor,i),i):0;(!a||!a.$$)&&$(`Cannot pass "${gn(a)}" as a ${this.name}`),a.$$.ptr||$(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&a.$$.ptrType.isConst&&$(`Cannot convert argument of type ${a.$$.smartPtrType?a.$$.smartPtrType.name:a.$$.ptrType.name} to parameter type ${this.name}`);var d=a.$$.ptrType.registeredClass;if(i=Qe(a.$$.ptr,d,this.registeredClass),this.isSmartPointer)switch(a.$$.smartPtr===void 0&&$("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:a.$$.smartPtrType===this?i=a.$$.smartPtr:$(`Cannot convert argument of type ${a.$$.smartPtrType?a.$$.smartPtrType.name:a.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:i=a.$$.smartPtr;break;case 2:if(a.$$.smartPtrType===this)i=a.$$.smartPtr;else{var u=a.clone();i=this.rawShare(i,ft.toHandle(()=>u.delete())),e!==null&&e.push(this.rawDestructor,i)}break;default:$("Unsupported sharing policy")}return i}function Wr(e,a){if(a===null)return this.isReference&&$(`null is not a valid ${this.name}`),0;a.$$||$(`Cannot pass "${gn(a)}" as a ${this.name}`),a.$$.ptr||$(`Cannot pass deleted object as a pointer of type ${this.name}`),a.$$.ptrType.isConst&&$(`Cannot convert argument of type ${a.$$.ptrType.name} to parameter type ${this.name}`);var i=a.$$.ptrType.registeredClass,d=Qe(a.$$.ptr,i,this.registeredClass);return d}function je(e){return this.fromWireType(B[e>>>2>>>0])}var bn=(e,a,i)=>{if(a===i)return e;if(i.baseClass===void 0)return null;var d=bn(e,a,i.baseClass);return d===null?null:i.downcast(d)},Gr={},Mr=(e,a)=>{for(a===void 0&&$("ptr should not be undefined");e.baseClass;)a=e.upcast(a),e=e.baseClass;return a},br=(e,a)=>(a=Mr(e,a),Gr[a]),xr=class extends Error{constructor(a){super(a),this.name="InternalError"}},tn=e=>{throw new xr(e)},en=(e,a)=>{(!a.ptrType||!a.ptr)&&tn("makeClassHandle requires ptr and ptrType");var i=!!a.smartPtrType,d=!!a.smartPtr;return i!==d&&tn("Both smartPtrType and smartPtr must be specified"),a.count={value:1},ke(Object.create(e,{$$:{value:a,writable:!0}}))};function Or(e){var a=this.getPointee(e);if(!a)return this.destructor(e),null;var i=br(this.registeredClass,a);if(i!==void 0){if(i.$$.count.value===0)return i.$$.ptr=a,i.$$.smartPtr=e,i.clone();var d=i.clone();return this.destructor(e),d}function u(){return this.isSmartPointer?en(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:a,smartPtrType:this,smartPtr:e}):en(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var E=this.registeredClass.getActualType(a),A=Mn[E];if(!A)return u.call(this);var T;this.isConst?T=A.constPointerType:T=A.pointerType;var v=bn(a,this.registeredClass,T.registeredClass);return v===null?u.call(this):this.isSmartPointer?en(T.registeredClass.instancePrototype,{ptrType:T,ptr:v,smartPtrType:this,smartPtr:e}):en(T.registeredClass.instancePrototype,{ptrType:T,ptr:v})}var kr=()=>{Object.assign(nn.prototype,{getPointee(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e},destructor(e){var a;(a=this.rawDestructor)==null||a.call(this,e)},readValueFromPointer:je,fromWireType:Or})};function nn(e,a,i,d,u,E,A,T,v,D,L){this.name=e,this.registeredClass=a,this.isReference=i,this.isConst=d,this.isSmartPointer=u,this.pointeeType=E,this.sharingPolicy=A,this.rawGetPointee=T,this.rawConstructor=v,this.rawShare=D,this.rawDestructor=L,!u&&a.baseClass===void 0?d?(this.toWireType=Yr,this.destructorFunction=null):(this.toWireType=Wr,this.destructorFunction=null):this.toWireType=Nr}var xn=(e,a,i)=>{o.hasOwnProperty(e)||tn("Replacing nonexistent public symbol"),o[e].overloadTable!==void 0&&i!==void 0?o[e].overloadTable[i]=a:(o[e]=a,o[e].argCount=i)},On=[],kn=e=>{var a=On[e];return a||(On[e]=a=jn.get(e)),a},Br=(e,a,i=[],d=!1)=>{var u=kn(a),E=u(...i);function A(T){return e[0]=="p"?T>>>0:T}return A(E)},Fr=(e,a,i=!1)=>(...d)=>Br(e,a,d,i),fe=(e,a,i=!1)=>{e=st(e);function d(){if(e.includes("p"))return Fr(e,a,i);var E=kn(a);return E}var u=d();return typeof u!="function"&&$(`unknown function pointer with signature ${e}: ${a}`),u};class Ur extends Error{}var Bn=e=>{var a=Jn(e),i=st(a);return ie(a),i},rn=(e,a)=>{var i=[],d={};function u(E){if(!d[E]&&!$t[E]){if(re[E]){re[E].forEach(u);return}i.push(E),d[E]=!0}}throw a.forEach(u),new Ur(`${e}: `+i.map(Bn).join([", "]))},an=(e,a,i)=>{e.forEach(T=>re[T]=a);function d(T){var v=i(T);v.length!==e.length&&tn("Mismatched type converter count");for(var D=0;D<e.length;++D)ot(e[D],v[D])}var u=new Array(a.length),E=[],A=0;for(let[T,v]of a.entries())$t.hasOwnProperty(v)?u[T]=$t[v]:(E.push(v),ne.hasOwnProperty(v)||(ne[v]=[]),ne[v].push(()=>{u[T]=$t[v],++A,A===E.length&&d(u)}));E.length===0&&d(u)};function $r(e,a,i,d,u,E,A,T,v,D,L,G,b){e>>>=0,a>>>=0,i>>>=0,d>>>=0,u>>>=0,E>>>=0,A>>>=0,T>>>=0,v>>>=0,D>>>=0,L>>>=0,G>>>=0,b>>>=0,L=st(L),E=fe(u,E),T&&(T=fe(A,T)),D&&(D=fe(v,D)),b=fe(G,b);var Y=Sr(L);Be(Y,function(){rn(`Cannot construct ${L} due to unbound types`,[d])}),an([e,a,i],d?[d]:[],F=>{var ar;F=F[0];var H,rt;d?(H=F.registeredClass,rt=H.instancePrototype):rt=Ze.prototype;var at=qe(L,function(...In){if(Object.getPrototypeOf(this)!==ct)throw new Se(`Use 'new' to construct ${L}`);if(_t.constructor_body===void 0)throw new Se(`${L} has no accessible constructor`);var or=_t.constructor_body[In.length];if(or===void 0)throw new Se(`Tried to invoke ctor of ${L} with invalid number of parameters (${In.length}) - expected (${Object.keys(_t.constructor_body).toString()}) parameters instead!`);return or.apply(this,In)}),ct=Object.create(rt,{constructor:{value:at}});at.prototype=ct;var _t=new Lr(L,at,ct,b,H,E,T,D);_t.baseClass&&((ar=_t.baseClass).__derivedClasses??(ar.__derivedClasses=[]),_t.baseClass.__derivedClasses.push(_t));var vt=new nn(L,_t,!0,!1,!1),Vt=new nn(L+"*",_t,!1,!1,!1),it=new nn(L+" const*",_t,!1,!0,!1);return Mn[e]={pointerType:Vt,constPointerType:it},xn(Y,at),[vt,Vt,it]})}var An=e=>{for(;e.length;){var a=e.pop(),i=e.pop();i(a)}},Fn=(e,a,i)=>(e instanceof Object||$(`${i} with invalid "this": ${e}`),e instanceof a.registeredClass.constructor||$(`${i} incompatible with "this" of type ${e.constructor.name}`),e.$$.ptr||$(`cannot call emscripten binding method ${i} on deleted object`),Qe(e.$$.ptr,e.$$.ptrType.registeredClass,a.registeredClass)),Vr=function(e,a,i,d,u,E,A,T,v,D){e>>>=0,a>>>=0,i>>>=0,d>>>=0,u>>>=0,E>>>=0,A>>>=0,T>>>=0,v>>>=0,D>>>=0,a=st(a),u=fe(d,u),an([],[e],L=>{L=L[0];var G=`${L.name}.${a}`,b={get(){rn(`Cannot access ${G} due to unbound types`,[i,A])},enumerable:!0,configurable:!0};return v?b.set=()=>rn(`Cannot access ${G} due to unbound types`,[i,A]):b.set=Y=>$(G+" is a read-only property"),Object.defineProperty(L.registeredClass.instancePrototype,a,b),an([],v?[i,A]:[i],Y=>{var F=Y[0],H={get(){var at=Fn(this,L,G+" getter");return F.fromWireType(u(E,at))},enumerable:!0};if(v){v=fe(T,v);var rt=Y[1];H.set=function(at){var ct=Fn(this,L,G+" setter"),_t=[];v(D,ct,rt.toWireType(_t,at)),An(_t)}}return Object.defineProperty(L.registeredClass.instancePrototype,a,H),[]}),[]})},Un=[],ae=[0,1,,1,null,1,!0,1,!1,1];function yn(e){e>>>=0,e>9&&--ae[e+1]===0&&(ae[e],ae[e]=void 0,Un.push(e))}var ft={toValue:e=>(e||$(`Cannot use deleted val. handle = ${e}`),ae[e]),toHandle:e=>{switch(e){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:{const a=Un.pop()||ae.length;return ae[a]=e,ae[a+1]=1,a}}}},Hr={name:"emscripten::val",fromWireType:e=>{var a=ft.toValue(e);return yn(e),a},toWireType:(e,a)=>ft.toHandle(a),readValueFromPointer:je,destructorFunction:null};function Xr(e){return e>>>=0,ot(e,Hr)}var Tn=(e,a,i)=>{switch(a){case 1:return i?function(d){return this.fromWireType(z[d>>>0])}:function(d){return this.fromWireType(lt[d>>>0])};case 2:return i?function(d){return this.fromWireType(dt[d>>>1>>>0])}:function(d){return this.fromWireType(Tt[d>>>1>>>0])};case 4:return i?function(d){return this.fromWireType(k[d>>>2>>>0])}:function(d){return this.fromWireType(B[d>>>2>>>0])};default:throw new TypeError(`invalid integer width (${a}): ${e}`)}};function Kr(e){return e===0?"object":e===1?"number":"string"}function zr(e,a,i,d,u){e>>>=0,a>>>=0,i>>>=0,a=st(a);const E=Kr(u);switch(E){case"object":{let D=function(){};D.values={},ot(e,{name:a,constructor:D,valueType:E,fromWireType:function(L){return this.constructor.values[L]},toWireType:(L,G)=>G.value,readValueFromPointer:Tn(a,i,d),destructorFunction:null}),Be(a,D);break}case"number":{var A={};ot(e,{name:a,keysMap:A,valueType:E,fromWireType:D=>D,toWireType:(D,L)=>L,readValueFromPointer:Tn(a,i,d),destructorFunction:null}),Be(a,A),delete o[a].argCount;break}case"string":{var T={},v={},A={};ot(e,{name:a,valuesMap:T,reverseMap:v,keysMap:A,valueType:E,fromWireType:function(L){return this.reverseMap[L]},toWireType:function(L,G){return this.valuesMap[G]},readValueFromPointer:Tn(a,i,d),destructorFunction:null}),Be(a,A),delete o[a].argCount;break}}}var $n=(e,a)=>{var i=$t[e];return i===void 0&&$(`${a} has unknown type ${Bn(e)}`),i};function Jr(e,a,i){e>>>=0,a>>>=0;var d=$n(e,"enum");switch(a=st(a),d.valueType){case"object":{var u=d.constructor,E=Object.create(d.constructor.prototype,{value:{value:i},constructor:{value:qe(`${d.name}_${a}`,function(){})}});u.values[i]=E,u[a]=E;break}case"number":{d.keysMap[a]=i;break}case"string":{d.valuesMap[a]=i,d.reverseMap[i]=a,d.keysMap[a]=a;break}}}var Zr=(e,a)=>{switch(a){case 4:return function(i){return this.fromWireType(kt[i>>>2>>>0])};case 8:return function(i){return this.fromWireType(Bt[i>>>3>>>0])};default:throw new TypeError(`invalid float width (${a}): ${e}`)}},qr=function(e,a,i){e>>>=0,a>>>=0,i>>>=0,a=st(a),ot(e,{name:a,fromWireType:d=>d,toWireType:(d,u)=>u,readValueFromPointer:Zr(a,i),destructorFunction:null})};function Vn(e){for(var a=1;a<e.length;++a)if(e[a]!==null&&e[a].destructorFunction===void 0)return!0;return!1}function Qr(e,a,i,d){for(var u=Vn(e),E=e.length-2,A=[],T=["fn"],v=0;v<E;++v)A.push(`arg${v}`),T.push(`arg${v}Wired`);A=A.join(","),T=T.join(",");var D=`return function (${A}) {
|
|
4
3
|
`;u&&(D+=`var destructors = [];
|
|
5
|
-
`);for(var
|
|
6
|
-
`,
|
|
4
|
+
`);for(var L=u?"destructors":"null",G=["humanName","throwBindingError","invoker","fn","runDestructors","fromRetWire","toClassParamWire"],v=0;v<E;++v){var b=`toArg${v}Wire`;D+=`var arg${v}Wired = ${b}(${L}, arg${v});
|
|
5
|
+
`,G.push(b)}if(D+=(i||d?"var rv = ":"")+`invoker(${T});
|
|
7
6
|
`,u)D+=`runDestructors(destructors);
|
|
8
|
-
`;else for(var
|
|
9
|
-
`,
|
|
7
|
+
`;else for(var v=2;v<e.length;++v){var Y=v===1?"thisWired":"arg"+(v-2)+"Wired";e[v].destructorFunction!==null&&(D+=`${Y}_dtor(${Y});
|
|
8
|
+
`,G.push(`${Y}_dtor`))}return i&&(D+=`var ret = fromRetWire(rv);
|
|
10
9
|
return ret;
|
|
11
10
|
`),D+=`}
|
|
12
|
-
`,
|
|
13
|
-
|
|
14
|
-
`,A+=d[R].argPackAdvance;var N=i===1?"new func":"func.call";E+=` var rv = ${N}(${p.join(", ")});
|
|
15
|
-
`,u.isVoid||(m.push("emval_returnValue"),D.push(Ta),E+=` return emval_returnValue(retType, destructorsRef, rv);
|
|
16
|
-
`),E+=`};
|
|
17
|
-
`,m.push(E);var k=Kn(Function,m)(...D),G=`methodCaller<(${d.map(x=>x.name).join(", ")}) => ${u.name}>`;return ya(Ne(G,k))}function va(n){n>>>=0,n>9&&(Xt[n+1]+=1)}function ma(){return At.toHandle([])}function Ia(n){return n>>>=0,At.toHandle(Jn(n))}function wa(){return At.toHandle({})}function Ca(n){n>>>=0;var a=At.toValue(n);An(a),pn(n)}function Da(n,a,i){n>>>=0,a>>>=0,i>>>=0,n=At.toValue(n),a=At.toValue(a),i=At.toValue(i),n[a]=i}function Ra(n,a){n>>>=0,a>>>=0,n=Tn(n,"_emval_take_value");var i=n.readValueFromPointer(a);return At.toHandle(i)}function Sa(n,a){n=Te(n),a>>>=0;var i=new Date(n*1e3);Y[a>>>2>>>0]=i.getUTCSeconds(),Y[a+4>>>2>>>0]=i.getUTCMinutes(),Y[a+8>>>2>>>0]=i.getUTCHours(),Y[a+12>>>2>>>0]=i.getUTCDate(),Y[a+16>>>2>>>0]=i.getUTCMonth(),Y[a+20>>>2>>>0]=i.getUTCFullYear()-1900,Y[a+24>>>2>>>0]=i.getUTCDay();var d=Date.UTC(i.getUTCFullYear(),0,1,0,0,0,0),u=(i.getTime()-d)/(1e3*60*60*24)|0;Y[a+28>>>2>>>0]=u}var La=n=>n%4===0&&(n%100!==0||n%400===0),Ya=[0,31,60,91,121,152,182,213,244,274,305,335],Na=[0,31,59,90,120,151,181,212,243,273,304,334],Wa=n=>{var a=La(n.getFullYear()),i=a?Ya:Na,d=i[n.getMonth()]+n.getDate()-1;return d},Ga=function(n){n>>>=0;var a=(()=>{var i=new Date(Y[n+20>>>2>>>0]+1900,Y[n+16>>>2>>>0],Y[n+12>>>2>>>0],Y[n+8>>>2>>>0],Y[n+4>>>2>>>0],Y[n>>>2>>>0],0),d=Y[n+32>>>2>>>0],u=i.getTimezoneOffset(),E=new Date(i.getFullYear(),0,1),A=new Date(i.getFullYear(),6,1).getTimezoneOffset(),p=E.getTimezoneOffset(),m=Math.min(p,A);if(d<0)Y[n+32>>>2>>>0]=+(A!=p&&m==u);else if(d>0!=(m==u)){var D=Math.max(p,A),R=d>0?m:D;i.setTime(i.getTime()+(R-u)*6e4)}Y[n+24>>>2>>>0]=i.getDay();var N=Wa(i)|0;Y[n+28>>>2>>>0]=N,Y[n>>>2>>>0]=i.getSeconds(),Y[n+4>>>2>>>0]=i.getMinutes(),Y[n+8>>>2>>>0]=i.getHours(),Y[n+12>>>2>>>0]=i.getDate(),Y[n+16>>>2>>>0]=i.getMonth(),Y[n+20>>>2>>>0]=i.getYear();var k=i.getTime();return isNaN(k)?-1:k/1e3})();return BigInt(a)},Ma=function(n,a,i,d){n>>>=0,a>>>=0,i>>>=0,d>>>=0;var u=new Date().getFullYear(),E=new Date(u,0,1),A=new Date(u,6,1),p=E.getTimezoneOffset(),m=A.getTimezoneOffset(),D=Math.max(p,m);F[n>>>2>>>0]=D*60,Y[a>>>2>>>0]=+(p!=m);var R=G=>{var x=G>=0?"-":"+",K=Math.abs(G),_t=String(Math.floor(K/60)).padStart(2,"0"),at=String(K%60).padStart(2,"0");return`UTC${x}${_t}${at}`},N=R(p),k=R(m);m<p?(ue(N,i,17),ue(k,d,17)):(ue(N,d,17),ue(k,i,17))},Zn=()=>performance.now(),qn=()=>Date.now(),ba=n=>n>=0&&n<=3;function xa(n,a,i){if(i>>>=0,!ba(n))return 28;var d;n===0?d=qn():d=Zn();var u=Math.round(d*1e3*1e3);return it[i>>>3]=BigInt(u),0}function Oa(n){return n>>>=0,b(le(n))}var ka=()=>4294901760,Ba=n=>{var a=$.buffer,i=(n-a.byteLength+65535)/65536|0;try{return $.grow(i),Ct(),1}catch{}};function Fa(n){n>>>=0;var a=Z.length,i=ka();if(n>i)return!1;for(var d=1;d<=4;d*=2){var u=a*(1+.2/d);u=Math.min(u,n+100663296);var E=Math.min(i,me(Math.max(n,u),65536)),A=Ba(E);if(A)return!0}return!1}var dn={},Ua=()=>P||"./this.program",Ve=()=>{if(!Ve.strings){var n=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",a={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:n,_:Ua()};for(var i in dn)dn[i]===void 0?delete a[i]:a[i]=dn[i];var d=[];for(var i in a)d.push(`${i}=${a[i]}`);Ve.strings=d}return Ve.strings},$a=(n,a)=>{for(var i=0;i<n.length;++i)U[a++>>>0]=n.charCodeAt(i);U[a>>>0]=0},Va=function(n,a){n>>>=0,a>>>=0;var i=0;return Ve().forEach((d,u)=>{var E=a+i;F[n+u*4>>>2>>>0]=E,$a(d,E),i+=d.length+1}),0},Ha=function(n,a){n>>>=0,a>>>=0;var i=Ve();F[n>>>2>>>0]=i.length;var d=0;return i.forEach(u=>d+=u.length+1),F[a>>>2>>>0]=d,0};function Xa(n){try{var a=et.getStreamFromFD(n);return c.close(a),0}catch(i){if(typeof c>"u"||i.name!=="ErrnoError")throw i;return i.errno}}var Ka=(n,a,i,d)=>{for(var u=0,E=0;E<i;E++){var A=F[a>>>2>>>0],p=F[a+4>>>2>>>0];a+=8;var m=c.read(n,U,A,p,d);if(m<0)return-1;if(u+=m,m<p)break}return u};function za(n,a,i,d){a>>>=0,i>>>=0,d>>>=0;try{var u=et.getStreamFromFD(n),E=Ka(u,a,i);return F[d>>>2>>>0]=E,0}catch(A){if(typeof c>"u"||A.name!=="ErrnoError")throw A;return A.errno}}function Ja(n,a,i,d){a=Te(a),d>>>=0;try{if(isNaN(a))return 61;var u=et.getStreamFromFD(n);return c.llseek(u,a,i),it[d>>>3]=BigInt(u.position),u.getdents&&a===0&&i===0&&(u.getdents=null),0}catch(E){if(typeof c>"u"||E.name!=="ErrnoError")throw E;return E.errno}}var Za=(n,a,i,d)=>{for(var u=0,E=0;E<i;E++){var A=F[a>>>2>>>0],p=F[a+4>>>2>>>0];a+=8;var m=c.write(n,U,A,p,d);if(m<0)return-1;if(u+=m,m<p)break}return u};function qa(n,a,i,d){a>>>=0,i>>>=0,d>>>=0;try{var u=et.getStreamFromFD(n),E=Za(u,a,i);return F[d>>>2>>>0]=E,0}catch(A){if(typeof c>"u"||A.name!=="ErrnoError")throw A;return A.errno}}function Qa(n,a){n>>>=0,a>>>=0;try{return qt(Z.subarray(n>>>0,n+a>>>0)),0}catch(i){if(typeof c>"u"||i.name!=="ErrnoError")throw i;return i.errno}}var Qn=n=>{var a=e["_"+n];return a},ja=(n,a)=>{U.set(n,a>>>0)},jn=n=>oo(n),to=n=>{var a=Gt(n)+1,i=jn(a);return ue(n,i,a),i},tr=(n,a,i,d,u)=>{var E={string:x=>{var K=0;return x!=null&&x!==0&&(K=to(x)),K},array:x=>{var K=jn(x.length);return ja(x,K),K}};function A(x){return a==="string"?le(x):a==="boolean"?!!x:x}var p=Qn(n),m=[],D=0;if(d)for(var R=0;R<d.length;R++){var N=E[i[R]];N?(D===0&&(D=be()),m[R]=N(d[R])):m[R]=d[R]}var k=p(...m);function G(x){return D!==0&&Me(D),A(x)}return k=G(k),k},eo=(n,a,i,d)=>{var u=!i||i.every(A=>A==="number"||A==="boolean"),E=a!=="string";return E&&u&&!d?Qn(n):(...A)=>tr(n,a,i,A)},no=n=>{var a=Gt(n)+1,i=vn(a);return i&&ue(n,i,a),i};c.createPreloadedFile=Je,c.staticInit(),B.doesNotExistError=new c.ErrnoError(44),B.doesNotExistError.stack="<generic error, no stack>",Be(),ee=e.BindingError=class extends Error{constructor(a){super(a),this.name="BindingError"}},tn=e.InternalError=class extends Error{constructor(a){super(a),this.name="InternalError"}},Lr(),kr(),$n=e.UnboundTypeError=Ur(Error,"UnboundTypeError"),Xr();var er={__cxa_throw:Oe,__syscall_fcntl64:un,__syscall_fstat64:qe,__syscall_ioctl:ke,__syscall_lstat64:J,__syscall_newfstatat:j,__syscall_openat:te,__syscall_stat64:Qe,_abort_js:En,_embind_register_bigint:vr,_embind_register_bool:mr,_embind_register_class:$r,_embind_register_class_property:Vr,_embind_register_emval:zr,_embind_register_enum:Zr,_embind_register_enum_value:qr,_embind_register_float:jr,_embind_register_function:aa,_embind_register_integer:oa,_embind_register_memory_view:ia,_embind_register_std_string:sa,_embind_register_std_wstring:fa,_embind_register_void:ha,_emval_call_method:Aa,_emval_decref:pn,_emval_get_method_caller:Pa,_emval_incref:va,_emval_new_array:ma,_emval_new_cstring:Ia,_emval_new_object:wa,_emval_run_destructors:Ca,_emval_set_property:Da,_emval_take_value:Ra,_gmtime_js:Sa,_mktime_js:Ga,_tzset_js:Ma,clock_time_get:xa,emscripten_date_now:qn,emscripten_err:Oa,emscripten_get_now:Zn,emscripten_resize_heap:Fa,environ_get:Va,environ_sizes_get:Ha,fd_close:Xa,fd_read:za,fd_seek:Ja,fd_write:qa,random_get:Qa},X=await H();X.__wasm_call_ctors,e.__ZdlPvm=X._ZdlPvm;var vn=X.malloc,ne=X.free;X.realloc,X.calloc;var ro=X.__getTypeName;e._strndup=X.strndup,e.__ZdaPv=X._ZdaPv,e.__ZdaPvm=X._ZdaPvm,e.__ZdlPv=X._ZdlPv,e._emscripten_builtin_malloc=X.emscripten_builtin_malloc,e.__Znaj=X._Znaj,e.__ZnajSt11align_val_t=X._ZnajSt11align_val_t,e.__Znwj=X._Znwj,e.__ZnwjSt11align_val_t=X._ZnwjSt11align_val_t,e.___libc_calloc=X.__libc_calloc,e.___libc_free=X.__libc_free,e.___libc_malloc=X.__libc_malloc,e.___libc_realloc=X.__libc_realloc,e._emscripten_builtin_calloc=X.emscripten_builtin_calloc,e._emscripten_builtin_free=X.emscripten_builtin_free,e._emscripten_builtin_realloc=X.emscripten_builtin_realloc,e._malloc_size=X.malloc_size,e._malloc_usable_size=X.malloc_usable_size,e._reallocf=X.reallocf;var ao=X._emscripten_stack_restore,oo=X._emscripten_stack_alloc,io=X.emscripten_stack_get_current;function so(n){n=Object.assign({},n);var a=u=>E=>u(E)>>>0,i=u=>(E,A)=>u(E,A)>>>0,d=u=>()=>u()>>>0;return n.malloc=a(n.malloc),n.calloc=i(n.calloc),n.__getTypeName=a(n.__getTypeName),n.emscripten_builtin_malloc=a(n.emscripten_builtin_malloc),n.emscripten_builtin_calloc=i(n.emscripten_builtin_calloc),n._emscripten_stack_alloc=a(n._emscripten_stack_alloc),n.emscripten_stack_get_current=d(n.emscripten_stack_get_current),n}e.ENV=dn,e.ccall=tr,e.cwrap=eo,e.setValue=Ge,e.UTF8ToString=le,e.stringToNewUTF8=no,e.FS=c;function mn(){if(ht>0){Rt=mn;return}if(xt(),ht>0){Rt=mn;return}function n(){var a;e.calledRun=!0,!q&&(Dt(),s(e),(a=e.onRuntimeInitialized)==null||a.call(e),Ot())}e.setStatus?(e.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>e.setStatus(""),1),n()},1)):n()}if(e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.pop()();return mn(),o=l,o})})(),Io=Object.defineProperty,wo=(r,t,o)=>t in r?Io(r,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[t]=o,nt=(r,t,o)=>wo(r,typeof t!="symbol"?t+"":t,o);const Co=["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","euc-kr","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"],or=r=>Co[r];var fe=(r=>(r[r.TopLeft=1]="TopLeft",r[r.TopCenter=2]="TopCenter",r[r.TopRight=3]="TopRight",r[r.MiddleLeft=4]="MiddleLeft",r[r.MiddleCenter=5]="MiddleCenter",r[r.MiddleRight=6]="MiddleRight",r[r.BottomLeft=7]="BottomLeft",r[r.BottomCenter=8]="BottomCenter",r[r.BottomRight=9]="BottomRight",r))(fe||{}),Rn=(r=>(r[r.PatternFill=0]="PatternFill",r[r.SolidFill=1]="SolidFill",r))(Rn||{}),Sn=(r=>(r[r.NonAssociative=0]="NonAssociative",r[r.Associative=1]="Associative",r))(Sn||{}),hr=(r=>(r[r.Solid=0]="Solid",r[r.Gradient=1]="Gradient",r))(hr||{}),Ln=(r=>(r[r.TwoColor=0]="TwoColor",r[r.OneColor=1]="OneColor",r))(Ln||{}),Xe=(r=>(r[r.Line=1]="Line",r[r.Circular=2]="Circular",r[r.Elliptic=3]="Elliptic",r[r.Spline=4]="Spline",r))(Xe||{}),Yn=(r=>(r[r.LEFT=0]="LEFT",r[r.CENTER=1]="CENTER",r[r.RIGHT=2]="RIGHT",r[r.ALIGNED=3]="ALIGNED",r[r.MIDDLE=4]="MIDDLE",r[r.FIT=5]="FIT",r))(Yn||{});const Do=Object.freeze(["ACADMAINTVER","ACADVER","ANGBASE","ANGDIR","ATTMODE","AUNITS","AUPREC","CECOLOR","CELTSCALE","CELTYPE","CELWEIGHT","CEPSNID","CEPSNTYPE","CHAMFERA","CHAMFERB","CHAMFERC","CHAMFERD","CLAYER","CMLJUST","CMLSCALE","CMLSTYLE","CSHADOW","DIMADEC","DIMALT","DIMALTD","DIMALTF","DIMALTRND","DIMALTTD","DIMALTTZ","DIMALTU","DIMALTZ","DIMAPOST","DIMASO","DIMASSOC","DIMASZ","DIMATFIT","DIMAUNIT","DIMAZIN","DIMBLK","DIMBLK1","DIMBLK2","DIMCEN","DIMCLRD","DIMCLRE","DIMCLRT","DIMDEC","DIMDLE","DIMDLI","DIMDSEP","DIMEXE","DIMEXO","DIMFAC","DIMGAP","DIMJUST","DIMLDRBLK","DIMLFAC","DIMLIM","DIMLUNIT","DIMLWD","DIMLWE","DIMPOST","DIMRND","DIMSAH","DIMSCALE","DIMSD1","DIMSD2","DIMSE1","DIMSE2","DIMSHO","DIMSOXD","DIMSTYLE","DIMTAD","DIMTDEC","DIMTFAC","DIMTIH","DIMTIX","DIMTM","DIMTMOVE","DIMTOFL","DIMTOH","DIMTOL","DIMTOLJ","DIMTP","DIMTSZ","DIMTVP","DIMTXSTY","DIMTXT","DIMTZIN","DIMUPT","DIMZIN","DISPSILH","DRAGVS","DWGCODEPAGE","ELEVATION","ENDCAPS","EXTMAX","EXTMIN","EXTNAMES","FILLETRAD","FILLMODE","FINGERPRINTGUID","HALOGAP","HANDSEED","HIDETEXT","HYPERLINKBASE","INDEXCTL","INSBASE","INSUNITS","INTERFERECOLOR","INTERFEREOBJVS","INTERFEREVPVS","INTERSECTIONCOLOR","INTERSECTIONDISPLAY","JOINSTYLE","LIMCHECK","LIMMAX","LIMMIN","LTSCALE","LUNITS","LUPREC","LWDISPLAY","MAXACTVP","MEASUREMENT","MENU","MIRRTEXT","OBSCOLOR","OBSLTYPE","ORTHOMODE","PDMODE","PDSIZE","PELEVATION","PEXTMAX","PEXTMIN","PINSBASE","PLIMCHECK","PLIMMAX","PLIMMIN","PLINEGEN","PLINEWID","PROJECTNAME","PROXYGRAPHICS","PSLTSCALE","PSTYLEMODE","PSVPSCALE","PUCSBASE","PUCSNAME","PUCSORG","PUCSORGBACK","PUCSORGBOTTOM","PUCSORGFRONT","PUCSORGLEFT","PUCSORGRIGHT","PUCSORGTOP","PUCSORTHOREF","PUCSORTHOVIEW","PUCSXDIR","PUCSYDIR","QTEXTMODE","REGENMODE","SHADEDGE","SHADEDIF","SHADOWPLANELOCATION","SKETCHINC","SKPOLY","SORTENTS","SPLINESEGS","SPLINETYPE","SURFTAB1","SURFTAB2","SURFTYPE","SURFU","SURFV","TDCREATE","TDINDWG","TDUCREATE","TDUPDATE","TDUSRTIMER","TDUUPDATE","TEXTSIZE","TEXTSTYLE","THICKNESS","TILEMODE","TRACEWID","TREEDEPTH","UCSBASE","UCSNAME","UCSORG","UCSORGBACK","UCSORGBOTTOM","UCSORGFRONT","UCSORGLEFT","UCSORGRIGHT","UCSORGTOP","UCSORTHOREF","UCSORTHOVIEW","UCSXDIR","UCSYDIR","UNITMODE","USERI1","USERI2","USERI3","USERI4","USERI5","USERR1","USERR2","USERR3","USERR4","USERR5","USRTIMER","VERSIONGUID","VISRETAIN","WORLDVIEW","XCLIPFRAME","XEDIT"]),Ro=/\\U\+([0-9A-Fa-f]{4})/g;function ir(r){return!r||!r.includes("\\U+")?r:r.replace(Ro,(t,o)=>String.fromCharCode(parseInt(o,16)))}const So=[{type:"invalid",hdr:"INVALI",description:"No DWG",version:0},{type:"r1.1",hdr:"MC0.0",description:"MicroCAD Release 1.1",version:0},{type:"r1.2",hdr:"AC1.2",description:"AutoCAD Release 1.2",version:0},{type:"r1.3",hdr:"AC1.3",description:"AutoCAD Release 1.3",version:1},{type:"r1.4",hdr:"AC1.40",description:"AutoCAD Release 1.4",version:2},{type:"r2.0b",hdr:"AC1.50",description:"AutoCAD 2.0 beta",version:3},{type:"r2.0",hdr:"AC1.50",description:"AutoCAD Release 2.0",version:4},{type:"r2.10",hdr:"AC2.10",description:"AutoCAD Release 2.10",version:5},{type:"r2.21",hdr:"AC2.21",description:"AutoCAD Release 2.21",version:6},{type:"r2.22",hdr:"AC2.22",description:"AutoCAD Release 2.22",version:7},{type:"r2.4",hdr:"AC1001",description:"AutoCAD Release 2.4",version:8},{type:"r2.5",hdr:"AC1002",description:"AutoCAD Release 2.5",version:9},{type:"r2.6",hdr:"AC1003",description:"AutoCAD Release 2.6",version:10},{type:"r9",hdr:"AC1004",description:"AutoCAD Release 9",version:11},{type:"r9c1",hdr:"AC1005",description:"AutoCAD Release 9c1",version:12},{type:"r10",hdr:"AC1006",description:"AutoCAD Release 10",version:13},{type:"r11b1",hdr:"AC1007",description:"AutoCAD 11 beta 1",version:14},{type:"r11b2",hdr:"AC1008",description:"AutoCAD 11 beta 2",version:15},{type:"r11",hdr:"AC1009",description:"AutoCAD Release 11/12 (LT R1/R2)",version:16},{type:"r13b1",hdr:"AC1010",description:"AutoCAD pre-R13 a",version:17},{type:"r13b2",hdr:"AC1011",description:"AutoCAD pre-R13 b",version:18},{type:"r13",hdr:"AC1012",description:"AutoCAD Release 13",version:19},{type:"r13c3",hdr:"AC1013",description:"AutoCAD Release 13c3",version:20},{type:"r14",hdr:"AC1014",description:"AutoCAD Release 14",version:21},{type:"r2000b",hdr:"AC1500",description:"AutoCAD 2000 beta",version:22},{type:"r2000",hdr:"AC1015",description:"AutoCAD Release 2000",version:23},{type:"r2000i",hdr:"AC1016",description:"AutoCAD Release 2000i",version:23},{type:"r2002",hdr:"AC1017",description:"AutoCAD Release 2002",version:23},{type:"r2004a",hdr:"AC402a",description:"AutoCAD 2004 alpha a",version:24},{type:"r2004b",hdr:"AC402b",description:"AutoCAD 2004 alpha b",version:24},{type:"r2004c",hdr:"AC1018",description:"AutoCAD 2004 beta",version:24},{type:"r2004",hdr:"AC1018",description:"AutoCAD Release 2004",version:25},{type:"r2007a",hdr:"AC701a",description:"AutoCAD 2007 alpha",version:26},{type:"r2007b",hdr:"AC1021",description:"AutoCAD 2007 beta",version:26},{type:"r2007",hdr:"AC1021",description:"AutoCAD Release 2007",version:27},{type:"r2010b",hdr:"AC1024",description:"AutoCAD 2010 beta",version:28},{type:"r2010",hdr:"AC1024",description:"AutoCAD Release 2010",version:29},{type:"r2013b",hdr:"AC1027",description:"AutoCAD 2013 beta",version:30},{type:"r2013",hdr:"AC1027",description:"AutoCAD Release 2013",version:31},{type:"r2018b",hdr:"AC1032",description:"AutoCAD 2018 beta",version:32},{type:"r2018",hdr:"AC1032",description:"AutoCAD Release 2018",version:33},{type:"r2022b",hdr:"AC103-4",description:"AutoCAD 2022 beta",version:36},{type:"r>2022",hdr:"",description:"AutoCAD Release >2022",version:0}];var Nn=(r=>(r[r.DWG_SUPERTYPE_ENTITY=0]="DWG_SUPERTYPE_ENTITY",r[r.DWG_SUPERTYPE_OBJECT=1]="DWG_SUPERTYPE_OBJECT",r))(Nn||{}),Wn=(r=>(r[r.WRONGCRC=1]="WRONGCRC",r[r.NOTYETSUPPORTED=2]="NOTYETSUPPORTED",r[r.UNHANDLEDCLASS=4]="UNHANDLEDCLASS",r[r.INVALIDTYPE=8]="INVALIDTYPE",r[r.INVALIDHANDLE=16]="INVALIDHANDLE",r[r.INVALIDEED=32]="INVALIDEED",r[r.VALUEOUTOFBOUNDS=64]="VALUEOUTOFBOUNDS",r[r.CLASSESNOTFOUND=128]="CLASSESNOTFOUND",r[r.SECTIONNOTFOUND=256]="SECTIONNOTFOUND",r[r.PAGENOTFOUND=512]="PAGENOTFOUND",r[r.INTERNALERROR=1024]="INTERNALERROR",r[r.INVALIDDWG=2048]="INVALIDDWG",r[r.IOERROR=4096]="IOERROR",r[r.OUTOFMEM=8192]="OUTOFMEM",r))(Wn||{}),S=(r=>(r[r.DWG_TYPE_UNUSED=0]="DWG_TYPE_UNUSED",r[r.DWG_TYPE_TEXT=1]="DWG_TYPE_TEXT",r[r.DWG_TYPE_ATTRIB=2]="DWG_TYPE_ATTRIB",r[r.DWG_TYPE_ATTDEF=3]="DWG_TYPE_ATTDEF",r[r.DWG_TYPE_BLOCK=4]="DWG_TYPE_BLOCK",r[r.DWG_TYPE_ENDBLK=5]="DWG_TYPE_ENDBLK",r[r.DWG_TYPE_SEQEND=6]="DWG_TYPE_SEQEND",r[r.DWG_TYPE_INSERT=7]="DWG_TYPE_INSERT",r[r.DWG_TYPE_MINSERT=8]="DWG_TYPE_MINSERT",r[r.DWG_TYPE_VERTEX_2D=10]="DWG_TYPE_VERTEX_2D",r[r.DWG_TYPE_VERTEX_3D=11]="DWG_TYPE_VERTEX_3D",r[r.DWG_TYPE_VERTEX_MESH=12]="DWG_TYPE_VERTEX_MESH",r[r.DWG_TYPE_VERTEX_PFACE=13]="DWG_TYPE_VERTEX_PFACE",r[r.DWG_TYPE_VERTEX_PFACE_FACE=14]="DWG_TYPE_VERTEX_PFACE_FACE",r[r.DWG_TYPE_POLYLINE_2D=15]="DWG_TYPE_POLYLINE_2D",r[r.DWG_TYPE_POLYLINE_3D=16]="DWG_TYPE_POLYLINE_3D",r[r.DWG_TYPE_ARC=17]="DWG_TYPE_ARC",r[r.DWG_TYPE_CIRCLE=18]="DWG_TYPE_CIRCLE",r[r.DWG_TYPE_LINE=19]="DWG_TYPE_LINE",r[r.DWG_TYPE_DIMENSION_ORDINATE=20]="DWG_TYPE_DIMENSION_ORDINATE",r[r.DWG_TYPE_DIMENSION_LINEAR=21]="DWG_TYPE_DIMENSION_LINEAR",r[r.DWG_TYPE_DIMENSION_ALIGNED=22]="DWG_TYPE_DIMENSION_ALIGNED",r[r.DWG_TYPE_DIMENSION_ANG3PT=23]="DWG_TYPE_DIMENSION_ANG3PT",r[r.DWG_TYPE_DIMENSION_ANG2LN=24]="DWG_TYPE_DIMENSION_ANG2LN",r[r.DWG_TYPE_DIMENSION_RADIUS=25]="DWG_TYPE_DIMENSION_RADIUS",r[r.DWG_TYPE_DIMENSION_DIAMETER=26]="DWG_TYPE_DIMENSION_DIAMETER",r[r.DWG_TYPE_POINT=27]="DWG_TYPE_POINT",r[r.DWG_TYPE_3DFACE=28]="DWG_TYPE_3DFACE",r[r.DWG_TYPE_POLYLINE_PFACE=29]="DWG_TYPE_POLYLINE_PFACE",r[r.DWG_TYPE_POLYLINE_MESH=30]="DWG_TYPE_POLYLINE_MESH",r[r.DWG_TYPE_SOLID=31]="DWG_TYPE_SOLID",r[r.DWG_TYPE_TRACE=32]="DWG_TYPE_TRACE",r[r.DWG_TYPE_SHAPE=33]="DWG_TYPE_SHAPE",r[r.DWG_TYPE_VIEWPORT=34]="DWG_TYPE_VIEWPORT",r[r.DWG_TYPE_ELLIPSE=35]="DWG_TYPE_ELLIPSE",r[r.DWG_TYPE_SPLINE=36]="DWG_TYPE_SPLINE",r[r.DWG_TYPE_REGION=37]="DWG_TYPE_REGION",r[r.DWG_TYPE_3DSOLID=38]="DWG_TYPE_3DSOLID",r[r.DWG_TYPE_BODY=39]="DWG_TYPE_BODY",r[r.DWG_TYPE_RAY=40]="DWG_TYPE_RAY",r[r.DWG_TYPE_XLINE=41]="DWG_TYPE_XLINE",r[r.DWG_TYPE_DICTIONARY=42]="DWG_TYPE_DICTIONARY",r[r.DWG_TYPE_OLEFRAME=43]="DWG_TYPE_OLEFRAME",r[r.DWG_TYPE_MTEXT=44]="DWG_TYPE_MTEXT",r[r.DWG_TYPE_LEADER=45]="DWG_TYPE_LEADER",r[r.DWG_TYPE_TOLERANCE=46]="DWG_TYPE_TOLERANCE",r[r.DWG_TYPE_MLINE=47]="DWG_TYPE_MLINE",r[r.DWG_TYPE_BLOCK_CONTROL=48]="DWG_TYPE_BLOCK_CONTROL",r[r.DWG_TYPE_BLOCK_HEADER=49]="DWG_TYPE_BLOCK_HEADER",r[r.DWG_TYPE_LAYER_CONTROL=50]="DWG_TYPE_LAYER_CONTROL",r[r.DWG_TYPE_LAYER=51]="DWG_TYPE_LAYER",r[r.DWG_TYPE_STYLE_CONTROL=52]="DWG_TYPE_STYLE_CONTROL",r[r.DWG_TYPE_STYLE=53]="DWG_TYPE_STYLE",r[r.DWG_TYPE_LTYPE_CONTROL=56]="DWG_TYPE_LTYPE_CONTROL",r[r.DWG_TYPE_LTYPE=57]="DWG_TYPE_LTYPE",r[r.DWG_TYPE_VIEW_CONTROL=60]="DWG_TYPE_VIEW_CONTROL",r[r.DWG_TYPE_VIEW=61]="DWG_TYPE_VIEW",r[r.DWG_TYPE_UCS_CONTROL=62]="DWG_TYPE_UCS_CONTROL",r[r.DWG_TYPE_UCS=63]="DWG_TYPE_UCS",r[r.DWG_TYPE_VPORT_CONTROL=64]="DWG_TYPE_VPORT_CONTROL",r[r.DWG_TYPE_VPORT=65]="DWG_TYPE_VPORT",r[r.DWG_TYPE_APPID_CONTROL=66]="DWG_TYPE_APPID_CONTROL",r[r.DWG_TYPE_APPID=67]="DWG_TYPE_APPID",r[r.DWG_TYPE_DIMSTYLE_CONTROL=68]="DWG_TYPE_DIMSTYLE_CONTROL",r[r.DWG_TYPE_DIMSTYLE=69]="DWG_TYPE_DIMSTYLE",r[r.DWG_TYPE_VX_CONTROL=70]="DWG_TYPE_VX_CONTROL",r[r.DWG_TYPE_VX_TABLE_RECORD=71]="DWG_TYPE_VX_TABLE_RECORD",r[r.DWG_TYPE_GROUP=72]="DWG_TYPE_GROUP",r[r.DWG_TYPE_MLINESTYLE=73]="DWG_TYPE_MLINESTYLE",r[r.DWG_TYPE_OLE2FRAME=74]="DWG_TYPE_OLE2FRAME",r[r.DWG_TYPE_DUMMY=75]="DWG_TYPE_DUMMY",r[r.DWG_TYPE_LONG_TRANSACTION=76]="DWG_TYPE_LONG_TRANSACTION",r[r.DWG_TYPE_LWPOLYLINE=77]="DWG_TYPE_LWPOLYLINE",r[r.DWG_TYPE_HATCH=78]="DWG_TYPE_HATCH",r[r.DWG_TYPE_XRECORD=79]="DWG_TYPE_XRECORD",r[r.DWG_TYPE_PLACEHOLDER=80]="DWG_TYPE_PLACEHOLDER",r[r.DWG_TYPE_VBA_PROJECT=81]="DWG_TYPE_VBA_PROJECT",r[r.DWG_TYPE_LAYOUT=82]="DWG_TYPE_LAYOUT",r[r.DWG_TYPE_PROXY_ENTITY=498]="DWG_TYPE_PROXY_ENTITY",r[r.DWG_TYPE_PROXY_OBJECT=499]="DWG_TYPE_PROXY_OBJECT",r[r.DWG_TYPE_ACDSRECORD=500]="DWG_TYPE_ACDSRECORD",r[r.DWG_TYPE_ACDSSCHEMA=501]="DWG_TYPE_ACDSSCHEMA",r[r.DWG_TYPE_ACIDBLOCKREFERENCE=502]="DWG_TYPE_ACIDBLOCKREFERENCE",r[r.DWG_TYPE_ACMECOMMANDHISTORY=503]="DWG_TYPE_ACMECOMMANDHISTORY",r[r.DWG_TYPE_ACMESCOPE=504]="DWG_TYPE_ACMESCOPE",r[r.DWG_TYPE_ACMESTATEMGR=505]="DWG_TYPE_ACMESTATEMGR",r[r.DWG_TYPE_ACSH_BOOLEAN_CLASS=506]="DWG_TYPE_ACSH_BOOLEAN_CLASS",r[r.DWG_TYPE_ACSH_BOX_CLASS=507]="DWG_TYPE_ACSH_BOX_CLASS",r[r.DWG_TYPE_ACSH_BREP_CLASS=508]="DWG_TYPE_ACSH_BREP_CLASS",r[r.DWG_TYPE_ACSH_CHAMFER_CLASS=509]="DWG_TYPE_ACSH_CHAMFER_CLASS",r[r.DWG_TYPE_ACSH_CONE_CLASS=510]="DWG_TYPE_ACSH_CONE_CLASS",r[r.DWG_TYPE_ACSH_CYLINDER_CLASS=511]="DWG_TYPE_ACSH_CYLINDER_CLASS",r[r.DWG_TYPE_ACSH_EXTRUSION_CLASS=512]="DWG_TYPE_ACSH_EXTRUSION_CLASS",r[r.DWG_TYPE_ACSH_FILLET_CLASS=513]="DWG_TYPE_ACSH_FILLET_CLASS",r[r.DWG_TYPE_ACSH_HISTORY_CLASS=514]="DWG_TYPE_ACSH_HISTORY_CLASS",r[r.DWG_TYPE_ACSH_LOFT_CLASS=515]="DWG_TYPE_ACSH_LOFT_CLASS",r[r.DWG_TYPE_ACSH_PYRAMID_CLASS=516]="DWG_TYPE_ACSH_PYRAMID_CLASS",r[r.DWG_TYPE_ACSH_REVOLVE_CLASS=517]="DWG_TYPE_ACSH_REVOLVE_CLASS",r[r.DWG_TYPE_ACSH_SPHERE_CLASS=518]="DWG_TYPE_ACSH_SPHERE_CLASS",r[r.DWG_TYPE_ACSH_SWEEP_CLASS=519]="DWG_TYPE_ACSH_SWEEP_CLASS",r[r.DWG_TYPE_ACSH_TORUS_CLASS=520]="DWG_TYPE_ACSH_TORUS_CLASS",r[r.DWG_TYPE_ACSH_WEDGE_CLASS=521]="DWG_TYPE_ACSH_WEDGE_CLASS",r[r.DWG_TYPE_ALDIMOBJECTCONTEXTDATA=522]="DWG_TYPE_ALDIMOBJECTCONTEXTDATA",r[r.DWG_TYPE_ALIGNMENTPARAMETERENTITY=523]="DWG_TYPE_ALIGNMENTPARAMETERENTITY",r[r.DWG_TYPE_ANGDIMOBJECTCONTEXTDATA=524]="DWG_TYPE_ANGDIMOBJECTCONTEXTDATA",r[r.DWG_TYPE_ANNOTSCALEOBJECTCONTEXTDATA=525]="DWG_TYPE_ANNOTSCALEOBJECTCONTEXTDATA",r[r.DWG_TYPE_ARCALIGNEDTEXT=526]="DWG_TYPE_ARCALIGNEDTEXT",r[r.DWG_TYPE_ARC_DIMENSION=527]="DWG_TYPE_ARC_DIMENSION",r[r.DWG_TYPE_ASSOC2DCONSTRAINTGROUP=528]="DWG_TYPE_ASSOC2DCONSTRAINTGROUP",r[r.DWG_TYPE_ASSOC3POINTANGULARDIMACTIONBODY=529]="DWG_TYPE_ASSOC3POINTANGULARDIMACTIONBODY",r[r.DWG_TYPE_ASSOCACTION=530]="DWG_TYPE_ASSOCACTION",r[r.DWG_TYPE_ASSOCACTIONPARAM=531]="DWG_TYPE_ASSOCACTIONPARAM",r[r.DWG_TYPE_ASSOCALIGNEDDIMACTIONBODY=532]="DWG_TYPE_ASSOCALIGNEDDIMACTIONBODY",r[r.DWG_TYPE_ASSOCARRAYACTIONBODY=533]="DWG_TYPE_ASSOCARRAYACTIONBODY",r[r.DWG_TYPE_ASSOCARRAYMODIFYACTIONBODY=534]="DWG_TYPE_ASSOCARRAYMODIFYACTIONBODY",r[r.DWG_TYPE_ASSOCARRAYMODIFYPARAMETERS=535]="DWG_TYPE_ASSOCARRAYMODIFYPARAMETERS",r[r.DWG_TYPE_ASSOCARRAYPATHPARAMETERS=536]="DWG_TYPE_ASSOCARRAYPATHPARAMETERS",r[r.DWG_TYPE_ASSOCARRAYPOLARPARAMETERS=537]="DWG_TYPE_ASSOCARRAYPOLARPARAMETERS",r[r.DWG_TYPE_ASSOCARRAYRECTANGULARPARAMETERS=538]="DWG_TYPE_ASSOCARRAYRECTANGULARPARAMETERS",r[r.DWG_TYPE_ASSOCASMBODYACTIONPARAM=539]="DWG_TYPE_ASSOCASMBODYACTIONPARAM",r[r.DWG_TYPE_ASSOCBLENDSURFACEACTIONBODY=540]="DWG_TYPE_ASSOCBLENDSURFACEACTIONBODY",r[r.DWG_TYPE_ASSOCCOMPOUNDACTIONPARAM=541]="DWG_TYPE_ASSOCCOMPOUNDACTIONPARAM",r[r.DWG_TYPE_ASSOCDEPENDENCY=542]="DWG_TYPE_ASSOCDEPENDENCY",r[r.DWG_TYPE_ASSOCDIMDEPENDENCYBODY=543]="DWG_TYPE_ASSOCDIMDEPENDENCYBODY",r[r.DWG_TYPE_ASSOCEDGEACTIONPARAM=544]="DWG_TYPE_ASSOCEDGEACTIONPARAM",r[r.DWG_TYPE_ASSOCEDGECHAMFERACTIONBODY=545]="DWG_TYPE_ASSOCEDGECHAMFERACTIONBODY",r[r.DWG_TYPE_ASSOCEDGEFILLETACTIONBODY=546]="DWG_TYPE_ASSOCEDGEFILLETACTIONBODY",r[r.DWG_TYPE_ASSOCEXTENDSURFACEACTIONBODY=547]="DWG_TYPE_ASSOCEXTENDSURFACEACTIONBODY",r[r.DWG_TYPE_ASSOCEXTRUDEDSURFACEACTIONBODY=548]="DWG_TYPE_ASSOCEXTRUDEDSURFACEACTIONBODY",r[r.DWG_TYPE_ASSOCFACEACTIONPARAM=549]="DWG_TYPE_ASSOCFACEACTIONPARAM",r[r.DWG_TYPE_ASSOCFILLETSURFACEACTIONBODY=550]="DWG_TYPE_ASSOCFILLETSURFACEACTIONBODY",r[r.DWG_TYPE_ASSOCGEOMDEPENDENCY=551]="DWG_TYPE_ASSOCGEOMDEPENDENCY",r[r.DWG_TYPE_ASSOCLOFTEDSURFACEACTIONBODY=552]="DWG_TYPE_ASSOCLOFTEDSURFACEACTIONBODY",r[r.DWG_TYPE_ASSOCMLEADERACTIONBODY=553]="DWG_TYPE_ASSOCMLEADERACTIONBODY",r[r.DWG_TYPE_ASSOCNETWORK=554]="DWG_TYPE_ASSOCNETWORK",r[r.DWG_TYPE_ASSOCNETWORKSURFACEACTIONBODY=555]="DWG_TYPE_ASSOCNETWORKSURFACEACTIONBODY",r[r.DWG_TYPE_ASSOCOBJECTACTIONPARAM=556]="DWG_TYPE_ASSOCOBJECTACTIONPARAM",r[r.DWG_TYPE_ASSOCOFFSETSURFACEACTIONBODY=557]="DWG_TYPE_ASSOCOFFSETSURFACEACTIONBODY",r[r.DWG_TYPE_ASSOCORDINATEDIMACTIONBODY=558]="DWG_TYPE_ASSOCORDINATEDIMACTIONBODY",r[r.DWG_TYPE_ASSOCOSNAPPOINTREFACTIONPARAM=559]="DWG_TYPE_ASSOCOSNAPPOINTREFACTIONPARAM",r[r.DWG_TYPE_ASSOCPATCHSURFACEACTIONBODY=560]="DWG_TYPE_ASSOCPATCHSURFACEACTIONBODY",r[r.DWG_TYPE_ASSOCPATHACTIONPARAM=561]="DWG_TYPE_ASSOCPATHACTIONPARAM",r[r.DWG_TYPE_ASSOCPERSSUBENTMANAGER=562]="DWG_TYPE_ASSOCPERSSUBENTMANAGER",r[r.DWG_TYPE_ASSOCPLANESURFACEACTIONBODY=563]="DWG_TYPE_ASSOCPLANESURFACEACTIONBODY",r[r.DWG_TYPE_ASSOCPOINTREFACTIONPARAM=564]="DWG_TYPE_ASSOCPOINTREFACTIONPARAM",r[r.DWG_TYPE_ASSOCRESTOREENTITYSTATEACTIONBODY=565]="DWG_TYPE_ASSOCRESTOREENTITYSTATEACTIONBODY",r[r.DWG_TYPE_ASSOCREVOLVEDSURFACEACTIONBODY=566]="DWG_TYPE_ASSOCREVOLVEDSURFACEACTIONBODY",r[r.DWG_TYPE_ASSOCROTATEDDIMACTIONBODY=567]="DWG_TYPE_ASSOCROTATEDDIMACTIONBODY",r[r.DWG_TYPE_ASSOCSWEPTSURFACEACTIONBODY=568]="DWG_TYPE_ASSOCSWEPTSURFACEACTIONBODY",r[r.DWG_TYPE_ASSOCTRIMSURFACEACTIONBODY=569]="DWG_TYPE_ASSOCTRIMSURFACEACTIONBODY",r[r.DWG_TYPE_ASSOCVALUEDEPENDENCY=570]="DWG_TYPE_ASSOCVALUEDEPENDENCY",r[r.DWG_TYPE_ASSOCVARIABLE=571]="DWG_TYPE_ASSOCVARIABLE",r[r.DWG_TYPE_ASSOCVERTEXACTIONPARAM=572]="DWG_TYPE_ASSOCVERTEXACTIONPARAM",r[r.DWG_TYPE_BASEPOINTPARAMETERENTITY=573]="DWG_TYPE_BASEPOINTPARAMETERENTITY",r[r.DWG_TYPE_BLKREFOBJECTCONTEXTDATA=574]="DWG_TYPE_BLKREFOBJECTCONTEXTDATA",r[r.DWG_TYPE_BLOCKALIGNEDCONSTRAINTPARAMETER=575]="DWG_TYPE_BLOCKALIGNEDCONSTRAINTPARAMETER",r[r.DWG_TYPE_BLOCKALIGNMENTGRIP=576]="DWG_TYPE_BLOCKALIGNMENTGRIP",r[r.DWG_TYPE_BLOCKALIGNMENTPARAMETER=577]="DWG_TYPE_BLOCKALIGNMENTPARAMETER",r[r.DWG_TYPE_BLOCKANGULARCONSTRAINTPARAMETER=578]="DWG_TYPE_BLOCKANGULARCONSTRAINTPARAMETER",r[r.DWG_TYPE_BLOCKARRAYACTION=579]="DWG_TYPE_BLOCKARRAYACTION",r[r.DWG_TYPE_BLOCKBASEPOINTPARAMETER=580]="DWG_TYPE_BLOCKBASEPOINTPARAMETER",r[r.DWG_TYPE_BLOCKDIAMETRICCONSTRAINTPARAMETER=581]="DWG_TYPE_BLOCKDIAMETRICCONSTRAINTPARAMETER",r[r.DWG_TYPE_BLOCKFLIPACTION=582]="DWG_TYPE_BLOCKFLIPACTION",r[r.DWG_TYPE_BLOCKFLIPGRIP=583]="DWG_TYPE_BLOCKFLIPGRIP",r[r.DWG_TYPE_BLOCKFLIPPARAMETER=584]="DWG_TYPE_BLOCKFLIPPARAMETER",r[r.DWG_TYPE_BLOCKGRIPLOCATIONCOMPONENT=585]="DWG_TYPE_BLOCKGRIPLOCATIONCOMPONENT",r[r.DWG_TYPE_BLOCKHORIZONTALCONSTRAINTPARAMETER=586]="DWG_TYPE_BLOCKHORIZONTALCONSTRAINTPARAMETER",r[r.DWG_TYPE_BLOCKLINEARCONSTRAINTPARAMETER=587]="DWG_TYPE_BLOCKLINEARCONSTRAINTPARAMETER",r[r.DWG_TYPE_BLOCKLINEARGRIP=588]="DWG_TYPE_BLOCKLINEARGRIP",r[r.DWG_TYPE_BLOCKLINEARPARAMETER=589]="DWG_TYPE_BLOCKLINEARPARAMETER",r[r.DWG_TYPE_BLOCKLOOKUPACTION=590]="DWG_TYPE_BLOCKLOOKUPACTION",r[r.DWG_TYPE_BLOCKLOOKUPGRIP=591]="DWG_TYPE_BLOCKLOOKUPGRIP",r[r.DWG_TYPE_BLOCKLOOKUPPARAMETER=592]="DWG_TYPE_BLOCKLOOKUPPARAMETER",r[r.DWG_TYPE_BLOCKMOVEACTION=593]="DWG_TYPE_BLOCKMOVEACTION",r[r.DWG_TYPE_BLOCKPARAMDEPENDENCYBODY=594]="DWG_TYPE_BLOCKPARAMDEPENDENCYBODY",r[r.DWG_TYPE_BLOCKPOINTPARAMETER=595]="DWG_TYPE_BLOCKPOINTPARAMETER",r[r.DWG_TYPE_BLOCKPOLARGRIP=596]="DWG_TYPE_BLOCKPOLARGRIP",r[r.DWG_TYPE_BLOCKPOLARPARAMETER=597]="DWG_TYPE_BLOCKPOLARPARAMETER",r[r.DWG_TYPE_BLOCKPOLARSTRETCHACTION=598]="DWG_TYPE_BLOCKPOLARSTRETCHACTION",r[r.DWG_TYPE_BLOCKPROPERTIESTABLE=599]="DWG_TYPE_BLOCKPROPERTIESTABLE",r[r.DWG_TYPE_BLOCKPROPERTIESTABLEGRIP=600]="DWG_TYPE_BLOCKPROPERTIESTABLEGRIP",r[r.DWG_TYPE_BLOCKRADIALCONSTRAINTPARAMETER=601]="DWG_TYPE_BLOCKRADIALCONSTRAINTPARAMETER",r[r.DWG_TYPE_BLOCKREPRESENTATION=602]="DWG_TYPE_BLOCKREPRESENTATION",r[r.DWG_TYPE_BLOCKROTATEACTION=603]="DWG_TYPE_BLOCKROTATEACTION",r[r.DWG_TYPE_BLOCKROTATIONGRIP=604]="DWG_TYPE_BLOCKROTATIONGRIP",r[r.DWG_TYPE_BLOCKROTATIONPARAMETER=605]="DWG_TYPE_BLOCKROTATIONPARAMETER",r[r.DWG_TYPE_BLOCKSCALEACTION=606]="DWG_TYPE_BLOCKSCALEACTION",r[r.DWG_TYPE_BLOCKSTRETCHACTION=607]="DWG_TYPE_BLOCKSTRETCHACTION",r[r.DWG_TYPE_BLOCKUSERPARAMETER=608]="DWG_TYPE_BLOCKUSERPARAMETER",r[r.DWG_TYPE_BLOCKVERTICALCONSTRAINTPARAMETER=609]="DWG_TYPE_BLOCKVERTICALCONSTRAINTPARAMETER",r[r.DWG_TYPE_BLOCKVISIBILITYGRIP=610]="DWG_TYPE_BLOCKVISIBILITYGRIP",r[r.DWG_TYPE_BLOCKVISIBILITYPARAMETER=611]="DWG_TYPE_BLOCKVISIBILITYPARAMETER",r[r.DWG_TYPE_BLOCKXYGRIP=612]="DWG_TYPE_BLOCKXYGRIP",r[r.DWG_TYPE_BLOCKXYPARAMETER=613]="DWG_TYPE_BLOCKXYPARAMETER",r[r.DWG_TYPE_CAMERA=614]="DWG_TYPE_CAMERA",r[r.DWG_TYPE_CELLSTYLEMAP=615]="DWG_TYPE_CELLSTYLEMAP",r[r.DWG_TYPE_CONTEXTDATAMANAGER=616]="DWG_TYPE_CONTEXTDATAMANAGER",r[r.DWG_TYPE_CSACDOCUMENTOPTIONS=617]="DWG_TYPE_CSACDOCUMENTOPTIONS",r[r.DWG_TYPE_CURVEPATH=618]="DWG_TYPE_CURVEPATH",r[r.DWG_TYPE_DATALINK=619]="DWG_TYPE_DATALINK",r[r.DWG_TYPE_DATATABLE=620]="DWG_TYPE_DATATABLE",r[r.DWG_TYPE_DBCOLOR=621]="DWG_TYPE_DBCOLOR",r[r.DWG_TYPE_DETAILVIEWSTYLE=622]="DWG_TYPE_DETAILVIEWSTYLE",r[r.DWG_TYPE_DGNDEFINITION=623]="DWG_TYPE_DGNDEFINITION",r[r.DWG_TYPE_DGNUNDERLAY=624]="DWG_TYPE_DGNUNDERLAY",r[r.DWG_TYPE_DICTIONARYVAR=625]="DWG_TYPE_DICTIONARYVAR",r[r.DWG_TYPE_DICTIONARYWDFLT=626]="DWG_TYPE_DICTIONARYWDFLT",r[r.DWG_TYPE_DIMASSOC=627]="DWG_TYPE_DIMASSOC",r[r.DWG_TYPE_DMDIMOBJECTCONTEXTDATA=628]="DWG_TYPE_DMDIMOBJECTCONTEXTDATA",r[r.DWG_TYPE_DWFDEFINITION=629]="DWG_TYPE_DWFDEFINITION",r[r.DWG_TYPE_DWFUNDERLAY=630]="DWG_TYPE_DWFUNDERLAY",r[r.DWG_TYPE_DYNAMICBLOCKPROXYNODE=631]="DWG_TYPE_DYNAMICBLOCKPROXYNODE",r[r.DWG_TYPE_DYNAMICBLOCKPURGEPREVENTER=632]="DWG_TYPE_DYNAMICBLOCKPURGEPREVENTER",r[r.DWG_TYPE_EVALUATION_GRAPH=633]="DWG_TYPE_EVALUATION_GRAPH",r[r.DWG_TYPE_EXTRUDEDSURFACE=634]="DWG_TYPE_EXTRUDEDSURFACE",r[r.DWG_TYPE_FCFOBJECTCONTEXTDATA=635]="DWG_TYPE_FCFOBJECTCONTEXTDATA",r[r.DWG_TYPE_FIELD=636]="DWG_TYPE_FIELD",r[r.DWG_TYPE_FIELDLIST=637]="DWG_TYPE_FIELDLIST",r[r.DWG_TYPE_FLIPPARAMETERENTITY=638]="DWG_TYPE_FLIPPARAMETERENTITY",r[r.DWG_TYPE_FLIPACTIONENTITY=639]="DWG_TYPE_FLIPACTIONENTITY",r[r.DWG_TYPE_GEODATA=640]="DWG_TYPE_GEODATA",r[r.DWG_TYPE_GEOMAPIMAGE=641]="DWG_TYPE_GEOMAPIMAGE",r[r.DWG_TYPE_GEOPOSITIONMARKER=642]="DWG_TYPE_GEOPOSITIONMARKER",r[r.DWG_TYPE_GRADIENT_BACKGROUND=643]="DWG_TYPE_GRADIENT_BACKGROUND",r[r.DWG_TYPE_GROUND_PLANE_BACKGROUND=644]="DWG_TYPE_GROUND_PLANE_BACKGROUND",r[r.DWG_TYPE_HELIX=645]="DWG_TYPE_HELIX",r[r.DWG_TYPE_IBL_BACKGROUND=646]="DWG_TYPE_IBL_BACKGROUND",r[r.DWG_TYPE_IDBUFFER=647]="DWG_TYPE_IDBUFFER",r[r.DWG_TYPE_IMAGE=648]="DWG_TYPE_IMAGE",r[r.DWG_TYPE_IMAGEDEF=649]="DWG_TYPE_IMAGEDEF",r[r.DWG_TYPE_IMAGEDEF_REACTOR=650]="DWG_TYPE_IMAGEDEF_REACTOR",r[r.DWG_TYPE_IMAGE_BACKGROUND=651]="DWG_TYPE_IMAGE_BACKGROUND",r[r.DWG_TYPE_INDEX=652]="DWG_TYPE_INDEX",r[r.DWG_TYPE_LARGE_RADIAL_DIMENSION=653]="DWG_TYPE_LARGE_RADIAL_DIMENSION",r[r.DWG_TYPE_LAYERFILTER=654]="DWG_TYPE_LAYERFILTER",r[r.DWG_TYPE_LAYER_INDEX=655]="DWG_TYPE_LAYER_INDEX",r[r.DWG_TYPE_LAYOUTPRINTCONFIG=656]="DWG_TYPE_LAYOUTPRINTCONFIG",r[r.DWG_TYPE_LEADEROBJECTCONTEXTDATA=657]="DWG_TYPE_LEADEROBJECTCONTEXTDATA",r[r.DWG_TYPE_LIGHT=658]="DWG_TYPE_LIGHT",r[r.DWG_TYPE_LIGHTLIST=659]="DWG_TYPE_LIGHTLIST",r[r.DWG_TYPE_LINEARPARAMETERENTITY=660]="DWG_TYPE_LINEARPARAMETERENTITY",r[r.DWG_TYPE_LOFTEDSURFACE=661]="DWG_TYPE_LOFTEDSURFACE",r[r.DWG_TYPE_MATERIAL=662]="DWG_TYPE_MATERIAL",r[r.DWG_TYPE_MENTALRAYRENDERSETTINGS=663]="DWG_TYPE_MENTALRAYRENDERSETTINGS",r[r.DWG_TYPE_MESH=664]="DWG_TYPE_MESH",r[r.DWG_TYPE_MLEADEROBJECTCONTEXTDATA=665]="DWG_TYPE_MLEADEROBJECTCONTEXTDATA",r[r.DWG_TYPE_MLEADERSTYLE=666]="DWG_TYPE_MLEADERSTYLE",r[r.DWG_TYPE_MOVEACTIONENTITY=667]="DWG_TYPE_MOVEACTIONENTITY",r[r.DWG_TYPE_MOTIONPATH=668]="DWG_TYPE_MOTIONPATH",r[r.DWG_TYPE_MPOLYGON=669]="DWG_TYPE_MPOLYGON",r[r.DWG_TYPE_MTEXTATTRIBUTEOBJECTCONTEXTDATA=670]="DWG_TYPE_MTEXTATTRIBUTEOBJECTCONTEXTDATA",r[r.DWG_TYPE_MTEXTOBJECTCONTEXTDATA=671]="DWG_TYPE_MTEXTOBJECTCONTEXTDATA",r[r.DWG_TYPE_MULTILEADER=672]="DWG_TYPE_MULTILEADER",r[r.DWG_TYPE_NAVISWORKSMODEL=673]="DWG_TYPE_NAVISWORKSMODEL",r[r.DWG_TYPE_NAVISWORKSMODELDEF=674]="DWG_TYPE_NAVISWORKSMODELDEF",r[r.DWG_TYPE_NPOCOLLECTION=675]="DWG_TYPE_NPOCOLLECTION",r[r.DWG_TYPE_NURBSURFACE=676]="DWG_TYPE_NURBSURFACE",r[r.DWG_TYPE_OBJECT_PTR=677]="DWG_TYPE_OBJECT_PTR",r[r.DWG_TYPE_ORDDIMOBJECTCONTEXTDATA=678]="DWG_TYPE_ORDDIMOBJECTCONTEXTDATA",r[r.DWG_TYPE_PARTIAL_VIEWING_INDEX=679]="DWG_TYPE_PARTIAL_VIEWING_INDEX",r[r.DWG_TYPE_PDFDEFINITION=680]="DWG_TYPE_PDFDEFINITION",r[r.DWG_TYPE_PDFUNDERLAY=681]="DWG_TYPE_PDFUNDERLAY",r[r.DWG_TYPE_PERSUBENTMGR=682]="DWG_TYPE_PERSUBENTMGR",r[r.DWG_TYPE_PLANESURFACE=683]="DWG_TYPE_PLANESURFACE",r[r.DWG_TYPE_PLOTSETTINGS=684]="DWG_TYPE_PLOTSETTINGS",r[r.DWG_TYPE_POINTCLOUD=685]="DWG_TYPE_POINTCLOUD",r[r.DWG_TYPE_POINTCLOUDCOLORMAP=686]="DWG_TYPE_POINTCLOUDCOLORMAP",r[r.DWG_TYPE_POINTCLOUDDEF=687]="DWG_TYPE_POINTCLOUDDEF",r[r.DWG_TYPE_POINTCLOUDDEFEX=688]="DWG_TYPE_POINTCLOUDDEFEX",r[r.DWG_TYPE_POINTCLOUDDEF_REACTOR=689]="DWG_TYPE_POINTCLOUDDEF_REACTOR",r[r.DWG_TYPE_POINTCLOUDDEF_REACTOR_EX=690]="DWG_TYPE_POINTCLOUDDEF_REACTOR_EX",r[r.DWG_TYPE_POINTCLOUDEX=691]="DWG_TYPE_POINTCLOUDEX",r[r.DWG_TYPE_POINTPARAMETERENTITY=692]="DWG_TYPE_POINTPARAMETERENTITY",r[r.DWG_TYPE_POINTPATH=693]="DWG_TYPE_POINTPATH",r[r.DWG_TYPE_POLARGRIPENTITY=694]="DWG_TYPE_POLARGRIPENTITY",r[r.DWG_TYPE_RADIMLGOBJECTCONTEXTDATA=695]="DWG_TYPE_RADIMLGOBJECTCONTEXTDATA",r[r.DWG_TYPE_RADIMOBJECTCONTEXTDATA=696]="DWG_TYPE_RADIMOBJECTCONTEXTDATA",r[r.DWG_TYPE_RAPIDRTRENDERSETTINGS=697]="DWG_TYPE_RAPIDRTRENDERSETTINGS",r[r.DWG_TYPE_RASTERVARIABLES=698]="DWG_TYPE_RASTERVARIABLES",r[r.DWG_TYPE_RENDERENTRY=699]="DWG_TYPE_RENDERENTRY",r[r.DWG_TYPE_RENDERENVIRONMENT=700]="DWG_TYPE_RENDERENVIRONMENT",r[r.DWG_TYPE_RENDERGLOBAL=701]="DWG_TYPE_RENDERGLOBAL",r[r.DWG_TYPE_RENDERSETTINGS=702]="DWG_TYPE_RENDERSETTINGS",r[r.DWG_TYPE_REVOLVEDSURFACE=703]="DWG_TYPE_REVOLVEDSURFACE",r[r.DWG_TYPE_ROTATIONPARAMETERENTITY=704]="DWG_TYPE_ROTATIONPARAMETERENTITY",r[r.DWG_TYPE_ROTATEACTIONENTITY=705]="DWG_TYPE_ROTATEACTIONENTITY",r[r.DWG_TYPE_RTEXT=706]="DWG_TYPE_RTEXT",r[r.DWG_TYPE_SCALE=707]="DWG_TYPE_SCALE",r[r.DWG_TYPE_SCALEACTIONENTITY=708]="DWG_TYPE_SCALEACTIONENTITY",r[r.DWG_TYPE_SECTIONOBJECT=709]="DWG_TYPE_SECTIONOBJECT",r[r.DWG_TYPE_SECTIONVIEWSTYLE=710]="DWG_TYPE_SECTIONVIEWSTYLE",r[r.DWG_TYPE_SECTION_MANAGER=711]="DWG_TYPE_SECTION_MANAGER",r[r.DWG_TYPE_SECTION_SETTINGS=712]="DWG_TYPE_SECTION_SETTINGS",r[r.DWG_TYPE_SKYLIGHT_BACKGROUND=713]="DWG_TYPE_SKYLIGHT_BACKGROUND",r[r.DWG_TYPE_SOLID_BACKGROUND=714]="DWG_TYPE_SOLID_BACKGROUND",r[r.DWG_TYPE_SORTENTSTABLE=715]="DWG_TYPE_SORTENTSTABLE",r[r.DWG_TYPE_SPATIAL_FILTER=716]="DWG_TYPE_SPATIAL_FILTER",r[r.DWG_TYPE_SPATIAL_INDEX=717]="DWG_TYPE_SPATIAL_INDEX",r[r.DWG_TYPE_STRETCHACTIONENTITY=718]="DWG_TYPE_STRETCHACTIONENTITY",r[r.DWG_TYPE_SUN=719]="DWG_TYPE_SUN",r[r.DWG_TYPE_SUNSTUDY=720]="DWG_TYPE_SUNSTUDY",r[r.DWG_TYPE_SWEPTSURFACE=721]="DWG_TYPE_SWEPTSURFACE",r[r.DWG_TYPE_TABLE=722]="DWG_TYPE_TABLE",r[r.DWG_TYPE_TABLECONTENT=723]="DWG_TYPE_TABLECONTENT",r[r.DWG_TYPE_TABLEGEOMETRY=724]="DWG_TYPE_TABLEGEOMETRY",r[r.DWG_TYPE_TABLESTYLE=725]="DWG_TYPE_TABLESTYLE",r[r.DWG_TYPE_TEXTOBJECTCONTEXTDATA=726]="DWG_TYPE_TEXTOBJECTCONTEXTDATA",r[r.DWG_TYPE_TVDEVICEPROPERTIES=727]="DWG_TYPE_TVDEVICEPROPERTIES",r[r.DWG_TYPE_VISIBILITYGRIPENTITY=728]="DWG_TYPE_VISIBILITYGRIPENTITY",r[r.DWG_TYPE_VISIBILITYPARAMETERENTITY=729]="DWG_TYPE_VISIBILITYPARAMETERENTITY",r[r.DWG_TYPE_VISUALSTYLE=730]="DWG_TYPE_VISUALSTYLE",r[r.DWG_TYPE_WIPEOUT=731]="DWG_TYPE_WIPEOUT",r[r.DWG_TYPE_WIPEOUTVARIABLES=732]="DWG_TYPE_WIPEOUTVARIABLES",r[r.DWG_TYPE_XREFPANELOBJECT=733]="DWG_TYPE_XREFPANELOBJECT",r[r.DWG_TYPE_XYPARAMETERENTITY=734]="DWG_TYPE_XYPARAMETERENTITY",r[r.DWG_TYPE_BREAKDATA=735]="DWG_TYPE_BREAKDATA",r[r.DWG_TYPE_BREAKPOINTREF=736]="DWG_TYPE_BREAKPOINTREF",r[r.DWG_TYPE_FLIPGRIPENTITY=737]="DWG_TYPE_FLIPGRIPENTITY",r[r.DWG_TYPE_LINEARGRIPENTITY=738]="DWG_TYPE_LINEARGRIPENTITY",r[r.DWG_TYPE_ROTATIONGRIPENTITY=739]="DWG_TYPE_ROTATIONGRIPENTITY",r[r.DWG_TYPE_XYGRIPENTITY=740]="DWG_TYPE_XYGRIPENTITY",r[r.DWG_TYPE__3DLINE=741]="DWG_TYPE__3DLINE",r[r.DWG_TYPE_REPEAT=742]="DWG_TYPE_REPEAT",r[r.DWG_TYPE_ENDREP=743]="DWG_TYPE_ENDREP",r[r.DWG_TYPE_JUMP=744]="DWG_TYPE_JUMP",r[r.DWG_TYPE_LOAD=745]="DWG_TYPE_LOAD",r[r.DWG_TYPE_FREED=65533]="DWG_TYPE_FREED",r[r.DWG_TYPE_UNKNOWN_ENT=65534]="DWG_TYPE_UNKNOWN_ENT",r[r.DWG_TYPE_UNKNOWN_OBJ=65535]="DWG_TYPE_UNKNOWN_OBJ",r))(S||{});Object.fromEntries(Object.entries(S).map(([r,t])=>[t,r]));var vt=(r=>(r[r.DWG=0]="DWG",r[r.DXF=1]="DXF",r))(vt||{}),Ke=(r=>(r[r.Line=1]="Line",r[r.CircularArc=2]="CircularArc",r[r.EllipticArc=3]="EllipticArc",r[r.Spline=4]="Spline",r))(Ke||{}),mt=(r=>(r[r.ByLayer=192]="ByLayer",r[r.ByBlock=193]="ByBlock",r[r.Entities=194]="Entities",r[r.TrueColor=195]="TrueColor",r[r.ForegroundColor=197]="ForegroundColor",r[r.None=200]="None",r))(mt||{});const sr=192,_r=193,Lo=194,Cn=195,dr=200;function gr(r){if(r==null)return;const t=r.method,o=r.method!=null&&t!==0?t:r.rgb>>>24&255,e=r.index;if(r.rgb!=null&&o>=sr&&o<=dr&&(r.rgb>>>24&255)===o)return r.rgb>>0;if(o===mt.ByLayer||e===256)return sr<<24>>0;if(o===mt.ByBlock||e===0)return _r<<24>>0;if(o===mt.None)return dr<<24>>0;if(o===mt.TrueColor){const s=r.rgb!=null?r.rgb&16777215:void 0;if(s!=null)return(Lo<<24|s)>>0}return o===mt.ForegroundColor?(Cn<<24|7)>>0:o===mt.Entities&&e>0&&e<256||e>0&&e<256?(Cn<<24|e&255)>>0:_r<<24>>0}function Yo(r){if(r==null)return;const t=r.method,o=r.method!=null&&t!==0?t:r.rgb>>>24&255,e=r.index;if(!(o===mt.ByLayer||o===mt.ByBlock||o===mt.None||e===256)){if(o===mt.ForegroundColor)return 7;if(o===mt.TrueColor)return r.rgb==null?void 0:r.rgb&16777215;if(e>=1&&e<=255)return e;if(e!==0&&r.rgb!=null){const s=r.rgb&16777215;if(s!==0)return s}}}const No="*MODEL_SPACE",Wo="*PAPER_SPACE",Gn=r=>r&&r.toUpperCase()==No,Go=r=>r&&r.toUpperCase().startsWith(Wo),ft=r=>r.toString(16).toUpperCase(),ze=r=>{const t=new Array(r.length);for(let o=0;o<r.length;o++)t[o]=r[o].toString(16).toUpperCase().padStart(2,"0");return t.join("")},Mo=r=>{if(!r||r.length<98)return null;const t=new DataView(r.buffer,r.byteOffset,r.byteLength),o=_=>({x:t.getFloat64(_,!0),y:t.getFloat64(_+8,!0),z:t.getFloat64(_+16,!0)}),e=o(2),s=o(50);return[e.x,e.y,e.z,s.x,s.y,s.z].every(Number.isFinite)?{upperLeft:e,lowerRight:s}:null};class bo{constructor(t){nt(this,"libredwg"),nt(this,"layers",new Map),nt(this,"ltypes",new Map),nt(this,"classes",[]),nt(this,"unknownEntityCount"),this.libredwg=t,this.unknownEntityCount=0}prepare(t,o=!1){(o||this.layers.size==0)&&(this.layers.clear(),t.tables.LAYER.entries.forEach(e=>{this.layers.set(e.handle,e.name)})),(o||this.ltypes.size==0)&&(this.ltypes.clear(),t.tables.LTYPE.entries.forEach(e=>{this.ltypes.set(e.handle,e.name)})),this.classes=t.classes,this.unknownEntityCount=0}setClasses(t){this.classes=t}clear(){this.layers.clear(),this.ltypes.clear(),this.classes=[],this.unknownEntityCount=0}convert(t){const o=this.libredwg,e=o.dwg_object_to_entity(t),s=o.dwg_object_to_entity_tio(t);if(e&&s){const _=this.getCommonAttrs(e),l=o.dwg_object_get_fixedtype(t);if(l==S.DWG_TYPE_3DFACE)return this.convert3dFace(s,_);if(l==S.DWG_TYPE_3DSOLID)return this.convert3dSolid(s,_);if(l==S.DWG_TYPE_ARC)return this.convertArc(s,_);if(l==S.DWG_TYPE_ARCALIGNEDTEXT)return this.convertArcAlignedText(s,_);if(l==S.DWG_TYPE_ATTDEF)return this.convertAttdef(s,_);if(l==S.DWG_TYPE_CIRCLE)return this.convertCircle(s,_);if(l==S.DWG_TYPE_DIMENSION_ALIGNED)return this.convertAlignedDimension(s,_);if(l==S.DWG_TYPE_DIMENSION_LINEAR)return this.convertRotatedDimension(s,_);if(l==S.DWG_TYPE_DIMENSION_ANG3PT)return this.convert3PointAngularDimension(s,_);if(l==S.DWG_TYPE_DIMENSION_ANG2LN)return this.convert2LineAngularDimension(s,_);if(l==S.DWG_TYPE_DIMENSION_DIAMETER)return this.convertDiameterDimension(s,_);if(l==S.DWG_TYPE_DIMENSION_ORDINATE)return this.convertOrdinateDimension(s,_);if(l==S.DWG_TYPE_DIMENSION_RADIUS)return this.convertRadiusDimension(s,_);if(l==S.DWG_TYPE_ELLIPSE)return this.convertEllise(s,_);if(l==S.DWG_TYPE_HATCH)return this.convertHatch(s,_);if(l==S.DWG_TYPE_IMAGE)return this.convertImage(s,_);if(l==S.DWG_TYPE_INSERT||l==S.DWG_TYPE_MINSERT)return this.convertInsert(s,_);if(l==S.DWG_TYPE_LEADER)return this.convertLeader(s,_);if(l==S.DWG_TYPE_LINE)return this.convertLine(s,_);if(l==S.DWG_TYPE_LWPOLYLINE)return this.convertLWPolyline(s,_);if(l==S.DWG_TYPE_MLINE)return this.convertMLine(s,_);if(l==S.DWG_TYPE_MULTILEADER)return this.convertMultiLeader(s,_);if(l==S.DWG_TYPE_MTEXT)return this.convertMText(s,_);if(l==S.DWG_TYPE_OLE2FRAME)return this.convertOle2Frame(s,_);if(l==S.DWG_TYPE_OLEFRAME)return this.convertOleFrame(s,_);if(l==S.DWG_TYPE_POINT)return this.convertPoint(s,_);if(l==S.DWG_TYPE_POLYLINE_2D)return this.convertPolyline2d(s,_,t);if(l==S.DWG_TYPE_POLYLINE_3D)return this.convertPolyline3d(s,_,t);if(l==S.DWG_TYPE_PROXY_ENTITY)return this.convertProxyEntity(s,_,t);if(l==S.DWG_TYPE_RAY)return this.convertRay(s,_);if(l==S.DWG_TYPE_SECTIONOBJECT)return this.convertSection(s,_);if(l==S.DWG_TYPE_SHAPE)return this.convertShape(s,_);if(l==S.DWG_TYPE_SOLID)return this.convertSolid(s,_);if(l==S.DWG_TYPE_TRACE)return this.convertTrace(s,_);if(l==S.DWG_TYPE_SPLINE)return this.convertSpline(s,_);if(l==S.DWG_TYPE_TABLE)return this.convertTable(s,_);if(l==S.DWG_TYPE_TEXT)return this.convertText(s,_);if(l==S.DWG_TYPE_TOLERANCE)return this.convertTolerance(s,_);if(l==S.DWG_TYPE_VIEWPORT)return this.convertViewport(s,_);if(l==S.DWG_TYPE_WIPEOUT)return this.convertWipeout(s,_);if(l==S.DWG_TYPE_XLINE)return this.convertXline(s,_);l===S.DWG_TYPE_UNKNOWN_ENT&&this.unknownEntityCount++}}convert3dFace(t,o){const e=this.libredwg,s=e.dwg_dynapi_entity_data(t,"corner1"),_=e.dwg_dynapi_entity_data(t,"corner2"),l=e.dwg_dynapi_entity_data(t,"corner3"),f=e.dwg_dynapi_entity_data(t,"corner4"),h=e.dwg_dynapi_entity_data(t,"invis_flags");return{type:"3DFACE",...o,corner1:s,corner2:_,corner3:l,corner4:f,flag:h}}convert3dSolid(t,o){const e=this.libredwg,s=e.dwg_dynapi_entity_data(t,"version"),_=e.dwg_dynapi_entity_data(t,"acis_empty"),l=e.dwg_dynapi_entity_data(t,"acis_data"),f=e.dwg_dynapi_entity_data(t,"has_revision_guid"),h=e.dwg_dynapi_entity_data(t,"history_id"),g=e.dwg_ref_get_id(h),y={type:"3DSOLID",subclassMarker:"AcDb3dSolid",...o};if(s&&(y.version=s),y.satCache=_,l&&(y.data=l),f){const T=e.dwg_dynapi_entity_field_offset(t,"revision_guid");if(T>=0){const P=e.UTF8ToString(t+T,38);P&&(y.guid=P)}}return g&&(y.historyObjectSoftId=g),y}convertArc(t,o){const e=this.libredwg,s=e.dwg_dynapi_entity_data(t,"center"),_=e.dwg_dynapi_entity_data(t,"radius"),l=e.dwg_dynapi_entity_data(t,"thickness"),f=e.dwg_dynapi_entity_data(t,"extrusion"),h=e.dwg_dynapi_entity_data(t,"start_angle"),g=e.dwg_dynapi_entity_data(t,"end_angle");return{type:"ARC",...o,thickness:l,center:s,radius:_,startAngle:h,endAngle:g,extrusionDirection:f}}convertArcAlignedText(t,o){const e=this.libredwg,s=(g,y=0)=>{const T=e.dwg_dynapi_entity_data(t,g);if(typeof T=="number"&&Number.isFinite(T))return T;if(typeof T=="string"&&T.trim()!==""){const P=Number(T);if(Number.isFinite(P))return P}return y},_=e.dwg_dynapi_entity_data(t,"center"),l=e.dwg_dynapi_entity_data(t,"extrusion"),f=e.dwg_dynapi_entity_data(t,"arc_handle"),h=s("xscale",1);return{type:"ARCALIGNEDTEXT",...o,text:e.dwg_dynapi_entity_data(t,"text_value")??"",textSize:s("text_size"),xScale:h>0?h:1,characterSpacing:s("char_spacing"),styleName:e.dwg_dynapi_entity_data(t,"style")??"",fontName:e.dwg_dynapi_entity_data(t,"font_name")??"",bigFontName:e.dwg_dynapi_entity_data(t,"bigfont_name")??"",offsetFromArc:s("offset_from_arc"),rightOffset:s("right_offset"),leftOffset:s("left_offset"),center:_??{x:0,y:0,z:0},radius:e.dwg_dynapi_entity_data(t,"radius")??0,startAngle:e.dwg_dynapi_entity_data(t,"start_angle")??0,endAngle:e.dwg_dynapi_entity_data(t,"end_angle")??0,extrusionDirection:l??{x:0,y:0,z:1},rawTextColor:e.dwg_dynapi_entity_data(t,"color")??256,characterSet:e.dwg_dynapi_entity_data(t,"character_set")??0,pitchAndFamily:e.dwg_dynapi_entity_data(t,"pitch_and_family")??0,isShx:(e.dwg_dynapi_entity_data(t,"is_shx")??0)!==0,isBold:(e.dwg_dynapi_entity_data(t,"is_bold")??0)!==0,isItalic:(e.dwg_dynapi_entity_data(t,"is_italic")??0)!==0,isUnderlined:(e.dwg_dynapi_entity_data(t,"is_underlined")??0)!==0,alignment:e.dwg_dynapi_entity_data(t,"alignment")??0,isReverse:(e.dwg_dynapi_entity_data(t,"is_reverse")??0)!==0,wizardFlag:e.dwg_dynapi_entity_data(t,"wizard_flag")??0,textPosition:e.dwg_dynapi_entity_data(t,"text_position")??1,textDirection:e.dwg_dynapi_entity_data(t,"text_direction")??1,arcHandle:f?e.dwg_ref_get_id(f)??"":""}}convertEmbeddedMText(t,o){const e=this.libredwg,s=e.dwg_dynapi_subclass_data(t,o,"attachment"),_=e.dwg_dynapi_subclass_data(t,o,"ins_pt"),l=e.dwg_dynapi_subclass_data(t,o,"x_axis_dir"),f=e.dwg_dynapi_subclass_data(t,o,"rect_height"),h=e.dwg_dynapi_subclass_data(t,o,"rect_width"),g=e.dwg_dynapi_subclass_data(t,o,"extents_height"),y=e.dwg_dynapi_subclass_data(t,o,"extents_width");return{insertionPoint:_,rectHeight:f,rectWidth:h,extentsHeight:g,extentsWidth:y,attachmentPoint:s,direction:l}}convertAttdef(t,o){const e=this.libredwg,s=e.dwg_dynapi_entity_data(t,"default_value"),_=this.convertTextBase(t);_.text=s;const l=e.dwg_dynapi_entity_data(t,"prompt"),f=e.dwg_dynapi_entity_data(t,"tag"),h=e.dwg_dynapi_entity_data(t,"flags"),g=e.dwg_dynapi_entity_data(t,"field_length"),y=e.dwg_dynapi_entity_data(t,"lock_position_flag"),T=e.dwg_dynapi_entity_data(t,"keep_duplicate_records"),P=e.dwg_dynapi_entity_data(t,"is_really_locked"),v=e.dwg_dynapi_entity_data(t,"mtext_type"),C=e.dwg_dynapi_entity_data(t,"alignment_pt");return{type:"ATTDEF",...o,text:this.convertTextBase(t),prompt:l,tag:f,flags:h,fieldLength:g,lockPositionFlag:y>0,duplicateRecordCloningFlag:T>0,mtextFlag:v,isReallyLocked:P>0,alignmentPoint:C,annotationScale:1,attrTag:"",mtext:this.convertEmbeddedMText(t,"ATTDEF_mtext")}}convertAttrib(t,o){const e=this.libredwg,s=this.convertTextBase(t),_=e.dwg_dynapi_entity_data(t,"tag"),l=e.dwg_dynapi_entity_data(t,"flags"),f=e.dwg_dynapi_entity_data(t,"field_length"),h=e.dwg_dynapi_entity_data(t,"lock_position_flag"),g=e.dwg_dynapi_entity_data(t,"keep_duplicate_records"),y=e.dwg_dynapi_entity_data(t,"mtext_type"),T=e.dwg_dynapi_entity_data(t,"is_really_locked"),P=e.dwg_dynapi_entity_data(t,"alignment_pt");return{type:"ATTRIB",...o,text:s,tag:_,flags:l,fieldLength:f,lockPositionFlag:!!h,duplicateRecordCloningFlag:!!g,mtextFlag:y,isReallyLocked:!!T,numberOfSecondaryAttrs:0,secondaryAttrsHardId:"0",alignmentPoint:{...P,z:0},annotationScale:1,attrTag:"",mtext:this.convertEmbeddedMText(t,"ATTDEF_mtext")}}convertCircle(t,o){const e=this.libredwg,s=e.dwg_dynapi_entity_data(t,"center"),_=e.dwg_dynapi_entity_data(t,"radius"),l=e.dwg_dynapi_entity_data(t,"thickness"),f=e.dwg_dynapi_entity_data(t,"extrusion");return{type:"CIRCLE",...o,thickness:l,center:s,radius:_,extrusionDirection:f}}convertAlignedDimension(t,o){return this.convertLinearOrAlignedDimension(t,o,"AcDbAlignedDimension")}convertRotatedDimension(t,o){return this.convertLinearOrAlignedDimension(t,o,"AcDbRotatedDimension")}convertLinearOrAlignedDimension(t,o,e){const s=this.libredwg,_=this.getDimensionCommonAttrs(t),l=s.dwg_dynapi_entity_data(t,"clone_ins_pt"),f=s.dwg_dynapi_entity_data(t,"xline1_pt"),h=s.dwg_dynapi_entity_data(t,"xline2_pt"),g=e==="AcDbRotatedDimension"?s.dwg_dynapi_entity_data(t,"dim_rotation"):0,y=s.dwg_dynapi_entity_data(t,"oblique_angle");return{subclassMarker:e,...o,..._,insertionPoint:l,subDefinitionPoint1:f,subDefinitionPoint2:h,rotationAngle:g??0,obliqueAngle:y}}convert3PointAngularDimension(t,o){const e=this.libredwg,s=this.getDimensionCommonAttrs(t),_=e.dwg_dynapi_entity_data(t,"xline1_pt"),l=e.dwg_dynapi_entity_data(t,"xline2_pt"),f=e.dwg_dynapi_entity_data(t,"center_pt"),h=e.dwg_dynapi_entity_data(t,"xline2end_pt");return{subclassMarker:"AcDb3PointAngularDimension",...o,...s,subDefinitionPoint1:_,subDefinitionPoint2:l,centerPoint:f,arcPoint:h}}convert2LineAngularDimension(t,o){const e=this.libredwg,s=this.getDimensionCommonAttrs(t),_=e.dwg_dynapi_entity_data(t,"xline1start_pt"),l=e.dwg_dynapi_entity_data(t,"xline1end_pt"),f=e.dwg_dynapi_entity_data(t,"xline2start_pt"),h=e.dwg_dynapi_entity_data(t,"xline2end_pt"),g=e.dwg_dynapi_entity_data(t,"def_pt");return h&&(s.definitionPoint=h),{subclassMarker:"AcDb2LineAngularDimension",...o,...s,subDefinitionPoint1:_??l??g??h,subDefinitionPoint2:f??h??g??l,centerPoint:g??f??l??h,arcPoint:h??s.definitionPoint}}convertDiameterDimension(t,o){const e=this.libredwg,s=this.getDimensionCommonAttrs(t),_=e.dwg_dynapi_entity_data(t,"first_arc_pt"),l=e.dwg_dynapi_entity_data(t,"leader_len");return{subclassMarker:"AcDbDiametricDimension",...o,...s,centerPoint:_,leaderLength:l}}convertOrdinateDimension(t,o){const e=this.libredwg,s=this.getDimensionCommonAttrs(t),_=e.dwg_dynapi_entity_data(t,"feature_location_pt"),l=e.dwg_dynapi_entity_data(t,"leader_endpt");return{subclassMarker:"AcDbOrdinateDimension",...o,...s,subDefinitionPoint1:_,subDefinitionPoint2:l}}convertRadiusDimension(t,o){const e=this.libredwg,s=this.getDimensionCommonAttrs(t),_=e.dwg_dynapi_entity_data(t,"first_arc_pt"),l=e.dwg_dynapi_entity_data(t,"leader_len");return{subclassMarker:"AcDbRadialDimension",...o,...s,centerPoint:_,leaderLength:l}}convertEllise(t,o){const e=this.libredwg,s=e.dwg_dynapi_entity_data(t,"center"),_=e.dwg_dynapi_entity_data(t,"sm_axis"),l=e.dwg_dynapi_entity_data(t,"extrusion"),f=e.dwg_dynapi_entity_data(t,"axis_ratio"),h=e.dwg_dynapi_entity_data(t,"start_angle"),g=e.dwg_dynapi_entity_data(t,"end_angle");return{type:"ELLIPSE",...o,center:s,majorAxisEndPoint:_,extrusionDirection:l,axisRatio:f,startAngle:h,endAngle:g}}convertHatch(t,o){const e=this.libredwg,s=e.dwg_dynapi_entity_data(t,"extrusion"),_=e.dwg_dynapi_entity_data(t,"name"),l=e.dwg_dynapi_entity_data(t,"is_solid_fill"),f=e.dwg_dynapi_entity_data(t,"is_associative"),h=e.dwg_dynapi_entity_data(t,"num_paths"),g=e.dwg_dynapi_entity_data(t,"paths"),y=e.dwg_ptr_to_hatch_path_array(g,h),T=e.dwg_dynapi_entity_data(t,"style"),P=e.dwg_dynapi_entity_data(t,"pattern_type"),v=e.dwg_dynapi_entity_data(t,"angle"),C=e.dwg_dynapi_entity_data(t,"scale_spacing"),w=e.dwg_dynapi_entity_data(t,"num_deflines"),I=e.dwg_dynapi_entity_data(t,"deflines"),L=e.dwg_ptr_to_hatch_defline_array(I,w),W=e.dwg_dynapi_entity_data(t,"pixel_size"),M=e.dwg_dynapi_entity_data(t,"num_seeds"),b=e.dwg_dynapi_entity_data(t,"seeds"),O=e.dwg_ptr_to_point2d_array(b,M),$={...o,extrusionDirection:s,patternName:_,solidFill:l?Rn.SolidFill:Rn.PatternFill,associativity:f?Sn.Associative:Sn.NonAssociative,numberOfBoundaryPaths:h,boundaryPaths:this.convertHatchBoundaryPaths(y),hatchStyle:T,patternType:P,patternAngle:v,patternScale:C,numberOfDefinitionLines:w,definitionLines:L.map(U=>({angle:U.angle,base:U.pt0,offset:U.offset,numberOfDashLengths:U.dashes.length,dashLengths:U.dashes})),pixelSize:W,numberOfSeedPoints:M,seedPoints:O};if(e.dwg_dynapi_entity_data(t,"is_gradient_fill")>0){const U=e.dwg_dynapi_entity_data(t,"gradient_name"),Z=e.dwg_dynapi_entity_data(t,"gradient_angle"),rt=e.dwg_dynapi_entity_data(t,"gradient_shift"),dt=e.dwg_dynapi_entity_data(t,"gradient_tint"),Y=e.dwg_dynapi_entity_data(t,"single_color_gradient"),F=e.dwg_dynapi_entity_data(t,"colors"),ct=e.dwg_ptr_to_hatch_gradient_color_array(F,Y==1?1:2);return{type:"HATCH",...$,gradientFlag:hr.Gradient,gradientColorFlag:Y==1?Ln.OneColor:Ln.TwoColor,gradientName:U,gradientRotation:Z,gradientDefinition:rt,colorTint:dt,gradientColors:ct}}else return{type:"HATCH",...$}}convertHatchBoundaryPaths(t){return t.filter(e=>e.num_segs_or_paths>0).map(e=>{const s={boundaryPathTypeFlag:e.flag};if(e.flag&2)return{...s,hasBulge:e.bulges_present,isClosed:e.closed,numberOfVertices:e.num_segs_or_paths,vertices:e.polyline_paths.map(_=>({x:_.point.x,y:_.point.y,bulge:_.bulge}))};{const _=e.segs.map(l=>{if(l.curve_type==Ke.Line)return{type:Xe.Line,start:l.first_endpoint,end:l.second_endpoint};if(l.curve_type==Ke.CircularArc)return{type:Xe.Circular,center:l.center,radius:l.radius,startAngle:l.start_angle,endAngle:l.end_angle,isCCW:l.is_ccw};if(l.curve_type==Ke.EllipticArc)return{type:Xe.Elliptic,center:l.center,end:l.endpoint,lengthOfMinorAxis:l.minor_major_ratio,startAngle:l.start_angle,endAngle:l.end_angle,isCCW:l.is_ccw};if(l.curve_type==Ke.Spline)return{type:Xe.Spline,degree:l.degree,isRational:l.is_rational,isPeriodic:l.is_periodic,numberOfKnots:l.num_knots,numberOfControlPoints:l.num_control_points,knots:l.knots,controlPoints:l.control_points,numberOfFitData:l.num_fitpts,fitDatum:l.fitpts,startTangent:l.start_tangent,endTangent:l.end_tangent}}).filter(l=>l!=null);return{...s,numberOfEdges:_.length,edges:_}}})}convertImage(t,o){const e=this.libredwg,s=e.dwg_dynapi_entity_data(t,"class_version"),_=e.dwg_dynapi_entity_data(t,"pt0"),l=e.dwg_dynapi_entity_data(t,"uvec"),f=e.dwg_dynapi_entity_data(t,"vvec"),h=e.dwg_dynapi_entity_data(t,"image_size"),g=e.dwg_dynapi_entity_data(t,"display_props"),y=e.dwg_dynapi_entity_data(t,"clipping"),T=e.dwg_dynapi_entity_data(t,"brightness"),P=e.dwg_dynapi_entity_data(t,"contrast"),v=e.dwg_dynapi_entity_data(t,"fade"),C=e.dwg_dynapi_entity_data(t,"clip_mode"),w=e.dwg_dynapi_entity_data(t,"clip_boundary_type"),I=e.dwg_dynapi_entity_data(t,"num_clip_verts"),L=e.dwg_dynapi_entity_data(t,"clip_verts"),W=e.dwg_ptr_to_point3d_array(L,I),M=e.dwg_dynapi_entity_data(t,"imagedef"),b=e.dwg_ref_get_id(M)??"",O=e.dwg_dynapi_entity_data(t,"imagedefreactor"),$=e.dwg_ref_get_id(O)??"";return{type:"IMAGE",...o,version:s,position:_,uPixel:l,vPixel:f,imageSize:h,imageDefHandle:b,flags:g,clipping:y,brightness:T,contrast:P,fade:v,imageDefReactorHandle:$,clippingBoundaryType:w,countBoundaryPoints:I,clippingBoundaryPath:W,clipMode:C}}convertInsert(t,o){const e=this.libredwg;let s="";const _=e.dwg_dynapi_entity_data(t,"block_header");if(_){const I=e.dwg_ref_get_object(_);if(I){const L=e.dwg_object_to_object_tio(I);L&&(s=e.dwg_entity_block_header_get_block(L).name)}}s||(s=e.dwg_dynapi_entity_data(t,"block_name"));const l=e.dwg_dynapi_entity_data(t,"ins_pt"),f=e.dwg_dynapi_entity_data(t,"scale"),h=e.dwg_dynapi_entity_data(t,"rotation"),g=e.dwg_dynapi_entity_data(t,"num_cols"),y=e.dwg_dynapi_entity_data(t,"num_rows"),T=e.dwg_dynapi_entity_data(t,"col_spacing"),P=e.dwg_dynapi_entity_data(t,"row_spacing"),v=e.dwg_dynapi_entity_data(t,"extrusion"),C=e.dwg_entity_insert_get_attribs(t),w=[];return C.forEach(I=>{const L=e.dwg_object_to_entity(I),W=e.dwg_object_to_entity_tio(I);if(L&&W){const M=this.getCommonAttrs(L);e.dwg_object_get_fixedtype(I)==S.DWG_TYPE_ATTRIB&&w.push(this.convertAttrib(W,M))}}),{type:"INSERT",...o,name:s,insertionPoint:l,xScale:f?f.x:1,yScale:f?f.y:1,zScale:f?f.z:1,rotation:h,columnCount:g||1,rowCount:y||1,columnSpacing:T||0,rowSpacing:P||0,extrusionDirection:v,attribs:w}}convertLeader(t,o){const e=this.libredwg;let s="";try{s=e.dwg_entity_get_dimstyle_name(t)||""}catch{s=""}const l=e.dwg_dynapi_entity_data(t,"arrowhead_on")>0,f=e.dwg_dynapi_entity_data(t,"path_type"),h=e.dwg_dynapi_entity_data(t,"annot_type"),g=e.dwg_dynapi_entity_data(t,"hookline_dir"),y=e.dwg_dynapi_entity_data(t,"hookline_on"),T=e.dwg_dynapi_entity_data(t,"box_height"),P=e.dwg_dynapi_entity_data(t,"box_width"),v=e.dwg_dynapi_entity_data(t,"num_points"),C=e.dwg_dynapi_entity_data(t,"points"),w=v>0?e.dwg_ptr_to_point3d_array(C,v):[],I=e.dwg_dynapi_entity_data(t,"byblock_color"),L=e.dwg_dynapi_entity_data(t,"extrusion"),W=e.dwg_dynapi_entity_data(t,"x_direction"),M=e.dwg_dynapi_entity_data(t,"inspt_offset"),b=e.dwg_dynapi_entity_data(t,"endptproj");return{type:"LEADER",...o,styleName:s,isArrowheadEnabled:l,isSpline:f>0,leaderCreationFlag:h,isHooklineSameDirection:g>0,isHooklineExists:y>0,textHeight:T,textWidth:P,numberOfVertices:v,vertices:w,byBlockColor:I,normal:L,horizontalDirection:W,offsetFromBlock:M,offsetFromAnnotation:b}}convertLine(t,o){const e=this.libredwg,s=e.dwg_dynapi_entity_data(t,"start"),_=e.dwg_dynapi_entity_data(t,"end"),l=e.dwg_dynapi_entity_data(t,"thickness"),f=e.dwg_dynapi_entity_data(t,"extrusion");return{type:"LINE",...o,thickness:l,startPoint:s,endPoint:_,extrusionDirection:f}}convertLWPolyline(t,o){const e=this.libredwg,s=e.dwg_dynapi_entity_data(t,"num_points"),_=e.dwg_dynapi_entity_data(t,"flag"),l=e.dwg_dynapi_entity_data(t,"const_width"),f=e.dwg_dynapi_entity_data(t,"elevation"),h=e.dwg_dynapi_entity_data(t,"thickness"),g=e.dwg_dynapi_entity_data(t,"extrusion"),y=[],T=e.dwg_dynapi_entity_data(t,"num_points"),P=e.dwg_dynapi_entity_data(t,"points"),v=e.dwg_ptr_to_point2d_array(P,T),C=e.dwg_dynapi_entity_data(t,"num_bulges"),w=e.dwg_dynapi_entity_data(t,"bulges"),I=e.dwg_ptr_to_double_array(w,C),L=e.dwg_dynapi_entity_data(t,"num_widths")??0,W=e.dwg_dynapi_entity_data(t,"widths"),M=L>0&&W?e.dwg_ptr_to_double_array(W,L*2):[];return v.forEach((b,O)=>{const $={id:O,x:b.x,y:b.y,bulge:I.length>O?I[O]:0};O<L&&M.length>=(O+1)*2&&($.startWidth=M[O*2],$.endWidth=M[O*2+1]),y.push($)}),{type:"LWPOLYLINE",...o,numberOfVertices:s,flag:_,constantWidth:l,elevation:f,thickness:h,extrusionDirection:g,vertices:y}}convertMLine(t,o){const e=this.libredwg,s=e.dwg_dynapi_entity_data(t,"scale"),_=e.dwg_dynapi_entity_data(t,"flags"),l=e.dwg_dynapi_entity_data(t,"justification"),f=e.dwg_dynapi_entity_data(t,"base_point"),h=e.dwg_dynapi_entity_data(t,"extrusion"),g=e.dwg_dynapi_entity_data(t,"num_lines"),y=e.dwg_dynapi_entity_data(t,"num_verts"),T=e.dwg_dynapi_entity_data(t,"verts"),P=e.dwg_ptr_to_mline_vertex_array(T,y),v=[];return P.forEach(C=>{v.push({vertex:C.vertex,vertexDirection:C.vertex_direction,miterDirection:C.miter_direction,numberOfLines:C.num_lines,lines:C.lines.map(w=>({numberOfSegmentParams:w.num_segparms,segmentParams:w.segparms,numberOfAreaFillParams:w.num_areafillparms,areaFillParams:w.areafillparms}))})}),{type:"MLINE",...o,scale:s,flags:_,justification:l,startPoint:f,extrusionDirection:h,numberOfLines:g,numberOfVertices:y,vertices:v,mlineStyle:""}}convertMultiLeader(t,o){const e=this.libredwg,s=J=>e.dwg_dynapi_entity_data(t,J),_=(J,j,te)=>e.dwg_dynapi_subclass_data(J,j,te),l=J=>e.dwg_ref_get_id(J),f=J=>J>0,h=J=>J!=null?gr(J):void 0,g=s("class_version"),y=l(s("mleaderstyle")),T=s("flags"),P=s("type"),v=h(s("line_color")),C=l(s("line_ltype")),w=s("line_linewt"),I=f(s("has_landing")),L=f(s("has_dogleg")),W=s("landing_dist"),M=l(s("arrow_handle")),b=s("arrow_size"),O=s("style_content"),$=l(s("text_style")),q=s("text_left"),U=s("text_right"),Z=s("text_angletype"),rt=s("text_alignment"),dt=h(s("text_color")),Y=f(s("has_text_frame")),F=l(s("block_style")),ct=h(s("block_color")),it=s("block_scale"),Yt=s("block_rotation"),wt=s("style_attachment"),pt=f(s("is_annotative")),Ct=f(s("is_neg_textdir")),xt=s("ipe_alignment");let Dt=s("justification");const Ot=s("attach_dir"),ht=s("attach_bottom"),Rt=s("attach_top"),Jt=s("scale_factor"),kt=s("num_arrowheads"),Nt=s("arrowheads"),Bt=e.dwg_dynapi_subclass_size("LEADER_ArrowHead"),Ft=[];for(let J=0;J<kt;J++){const j=Nt+J*Bt;Ft.push({index:_(j,"LEADER_ArrowHead","is_default"),handle:l(_(j,"LEADER_ArrowHead","arrowhead"))??""})}const re=s("num_blocklabels"),ae=s("blocklabels"),oe=e.dwg_dynapi_subclass_size("LEADER_BlockLabel"),Ut=[];for(let J=0;J<re;J++){const j=ae+J*oe;Ut.push({id:l(_(j,"LEADER_BlockLabel","attdef")),index:_(j,"LEADER_BlockLabel","ui_index"),width:_(j,"LEADER_BlockLabel","width"),text:_(j,"LEADER_BlockLabel","label_text")})}const Q=t+e.dwg_dynapi_entity_field_offset(t,"ctx"),H=Q+e.dwg_dynapi_subclass_field_offset("MLEADER_AnnotContext","content"),$t=_(Q,"MLEADER_AnnotContext","scale_factor"),ie=_(Q,"MLEADER_AnnotContext","content_base"),Vt=_(Q,"MLEADER_AnnotContext","landing_gap"),ge=_(Q,"MLEADER_AnnotContext","attach_dir"),We=_(Q,"MLEADER_AnnotContext","text_height"),Ge=_(Q,"MLEADER_AnnotContext","arrow_size"),Me=_(Q,"MLEADER_AnnotContext","text_left"),be=_(Q,"MLEADER_AnnotContext","text_right"),xe=_(Q,"MLEADER_AnnotContext","text_angletype"),Ae=_(Q,"MLEADER_AnnotContext","text_alignment"),ye=f(_(Q,"MLEADER_AnnotContext","has_content_txt")),pe=f(_(Q,"MLEADER_AnnotContext","has_content_blk")),Te=_(Q,"MLEADER_AnnotContext","base"),Oe=_(Q,"MLEADER_AnnotContext","base_dir"),Zt=_(Q,"MLEADER_AnnotContext","base_vert"),Wt=f(_(Q,"MLEADER_AnnotContext","is_normal_reversed"));let z,Pe,qt,St,se,Lt,Qt,Gt,jt,_e,ve,Tt,me,de,B,Ie,we,Ce,De,Je,Ze;if(ye){const J=_(H,"MLEADER_Content_MText","alignment");J!=null&&J!==0&&(Dt=J),Pe=_(H,"MLEADER_Content_MText","normal"),Qt=_(H,"MLEADER_Content_MText","location"),qt=_(H,"MLEADER_Content_MText","rotation"),Gt=_(H,"MLEADER_Content_MText","direction"),St=_(H,"MLEADER_Content_MText","width"),se=_(H,"MLEADER_Content_MText","line_spacing_factor"),Lt=_(H,"MLEADER_Content_MText","line_spacing_style"),z=_(H,"MLEADER_Content_MText","flow"),jt=h(_(H,"MLEADER_Content_MText","bg_color")),_e=_(H,"MLEADER_Content_MText","bg_scale"),ve=_(H,"MLEADER_Content_MText","bg_transparency"),me=f(_(H,"MLEADER_Content_MText","is_bg_fill")),Tt=f(_(H,"MLEADER_Content_MText","is_bg_mask_fill")),de=_(H,"MLEADER_Content_MText","col_type"),B=f(_(H,"MLEADER_Content_MText","is_height_auto")),Ie=_(H,"MLEADER_Content_MText","col_width"),we=_(H,"MLEADER_Content_MText","col_gutter"),Ce=f(_(H,"MLEADER_Content_MText","is_col_flow_reversed"));const j=_(H,"MLEADER_Content_MText","num_col_sizes"),te=_(H,"MLEADER_Content_MText","col_sizes");j>0&&(De=e.dwg_ptr_to_double_array(te,j)[0]),Je=f(_(H,"MLEADER_Content_MText","word_break")),Ze=_(H,"MLEADER_Content_MText","default_text")}let Re;if(pe){const J=_(H,"MLEADER_Content_Block","transform");Re={blockContentId:l(_(H,"MLEADER_Content_Block","block_table")),normal:_(H,"MLEADER_Content_Block","normal"),position:_(H,"MLEADER_Content_Block","location"),scale:_(H,"MLEADER_Content_Block","scale"),rotation:_(H,"MLEADER_Content_Block","rotation"),color:h(_(H,"MLEADER_Content_Block","color")),transformationMatrix:J?e.dwg_ptr_to_double_array(J,16):void 0}}const c=_(Q,"MLEADER_AnnotContext","num_leaders"),le=_(Q,"MLEADER_AnnotContext","leaders"),et=e.dwg_dynapi_subclass_size("LEADER_Node"),un=e.dwg_dynapi_subclass_size("LEADER_Line"),qe=e.dwg_dynapi_subclass_size("LEADER_Break"),ke=[];for(let J=0;J<c;J++){const j=le+J*et,te=f(_(j,"LEADER_Node","has_lastleaderlinepoint")),Qe=f(_(j,"LEADER_Node","has_dogleg")),En=_(j,"LEADER_Node","num_breaks"),Se=_(j,"LEADER_Node","breaks"),Be=[];for(let ut=0;ut<En;ut++){const gt=Se+ut*qe;Be.push({start:_(gt,"LEADER_Break","start"),end:_(gt,"LEADER_Break","end")})}const je=_(j,"LEADER_Node","num_lines"),st=_(j,"LEADER_Node","lines"),Ht=[];for(let ut=0;ut<je;ut++){const gt=st+ut*un,ee=_(gt,"LEADER_Line","num_points"),V=_(gt,"LEADER_Line","points"),tn=ee>0?e.dwg_ptr_to_point3d_array(V,ee):[],Le=_(gt,"LEADER_Line","num_breaks"),Ye=_(gt,"LEADER_Line","breaks"),Fe=[];for(let Et=0;Et<Le;Et++){const Ue=Ye+Et*qe;Fe.push({start:_(Ue,"LEADER_Break","start"),end:_(Ue,"LEADER_Break","end")})}Ht.push({vertices:tn,leaderLineIndex:_(gt,"LEADER_Line","line_index"),breaks:Fe.length>0?Fe:void 0})}ke.push({lastLeaderLinePoint:te?_(j,"LEADER_Node","lastleaderlinepoint"):void 0,lastLeaderLinePointSet:te,doglegVector:Qe?_(j,"LEADER_Node","dogleg_vector"):void 0,doglegVectorSet:Qe,doglegLength:_(j,"LEADER_Node","dogleg_length"),breaks:Be.length>0?Be:void 0,leaderBranchIndex:_(j,"LEADER_Node","branch_index"),leaderLines:Ht})}return{type:"MULTILEADER",...o,subclassMarker:"AcDbMLeader",version:g,leaderStyleId:y,propertyOverrideFlag:T,leaderLineType:P,leaderLineColor:v,leaderLineTypeId:C,leaderLineWeight:w,landingEnabled:I,doglegEnabled:L,doglegLength:W,arrowheadId:M,arrowheadSize:b||Ge,contentType:O,textStyleId:$,textLeftAttachmentType:q||Me,textRightAttachmentType:U||be,textAngleType:Z||xe,textAlignmentType:rt||Ae,textColor:dt,textFrameEnabled:Y,landingGap:Vt,textAttachment:ge,textFlowDirection:z,blockContentId:F,blockContentColor:ct,blockContentScale:it,blockContentRotation:Yt,blockContentConnectionType:wt,annotativeScaleEnabled:pt,arrowheadOverrides:Ft.length>0?Ft:void 0,blockAttributes:Ut.length>0?Ut:void 0,textDirectionNegative:Ct,textAlignInIPE:xt,textAttachmentPoint:Dt,textAttachmentDirection:Ot,bottomTextAttachmentDirection:ht,topTextAttachmentDirection:Rt,contentScale:Jt||$t,contentBasePosition:ie,normal:Pe,textHeight:We,textRotation:qt,textWidth:St,textLineSpacingFactor:se,textLineSpacingStyle:Lt,textAnchor:Qt,textDirection:Gt,textBackgroundColor:jt,textBackgroundScaleFactor:_e,textBackgroundTransparency:ve,textBackgroundColorOn:Tt,textFillOn:me,textColumnType:de,textUseAutoHeight:B,textColumnWidth:Ie,textColumnGutterWidth:we,textColumnFlowReversed:Ce,textColumnHeight:De,textUseWordBreak:Je,textContent:Ze,hasMText:ye,hasBlock:pe,blockContent:Re,planeOrigin:Te,planeXAxisDirection:Oe,planeYAxisDirection:Zt,planeNormalReversed:Wt,leaderSections:ke.length>0?ke:void 0}}convertOle2Frame(t,o){const e=this.libredwg,s=e.dwg_dynapi_entity_data(t,"oleversion"),_=e.dwg_dynapi_entity_data(t,"oleclient"),l=e.dwg_dynapi_entity_data(t,"data_size");let f=e.dwg_dynapi_entity_data(t,"pt1"),h=e.dwg_dynapi_entity_data(t,"pt2");const g=e.dwg_dynapi_entity_data(t,"lock_aspect"),y=e.dwg_dynapi_entity_data(t,"type"),T=e.dwg_dynapi_entity_data(t,"mode"),P=e.dwg_entity_ole2frame_get_data(t),v=P?ze(P):"";if(P){const C=Mo(P);C&&(f=C.upperLeft,h=C.lowerRight)}return{type:"OLE2FRAME",...o,oleVersion:s,oleClient:_,dataSize:l,leftUpPoint:f,rightDownPoint:h,lockAspect:g,oleObjectType:y,tileModeDescriptor:T,binaryData:v}}convertOleFrame(t,o){const e=this.libredwg,s=e.dwg_dynapi_entity_data(t,"flag"),_=e.dwg_dynapi_entity_data(t,"mode"),l=e.dwg_dynapi_entity_data(t,"data_size"),f=e.dwg_entity_oleframe_get_data(t),h=f?ze(f):"";return{type:"OLEFRAME",...o,flag:s,mode:_,dataSize:l,binaryData:h}}convertMText(t,o){const e=this.libredwg,s=e.dwg_dynapi_entity_data(t,"ins_pt"),_=e.dwg_dynapi_entity_data(t,"text_height"),l=e.dwg_dynapi_entity_data(t,"rect_height"),f=e.dwg_dynapi_entity_data(t,"rect_width"),h=e.dwg_dynapi_entity_data(t,"extents_width"),g=e.dwg_dynapi_entity_data(t,"extents_height"),y=e.dwg_dynapi_entity_data(t,"attachment"),T=e.dwg_dynapi_entity_data(t,"flow_dir"),P=e.dwg_dynapi_entity_data(t,"text"),v=e.dwg_entity_mtext_get_style_name(t),C=e.dwg_dynapi_entity_data(t,"extrusion"),w=e.dwg_dynapi_entity_data(t,"x_axis_dir"),I=e.dwg_dynapi_entity_data(t,"linespace_style"),L=e.dwg_dynapi_entity_data(t,"linespace_factor"),W=e.dwg_dynapi_entity_data(t,"bg_fill_flag"),M=e.dwg_dynapi_entity_data(t,"bg_fill_scale"),b=e.dwg_dynapi_entity_data(t,"bg_fill_color"),O=e.dwg_dynapi_entity_data(t,"bg_fill_trans"),$=W===1?Yo(b):void 0,q=e.dwg_dynapi_entity_data(t,"column_type"),U=e.dwg_dynapi_entity_data(t,"flow_reversed"),Z=e.dwg_dynapi_entity_data(t,"auto_height"),rt=e.dwg_dynapi_entity_data(t,"column_width"),dt=e.dwg_dynapi_entity_data(t,"gutter"),Y=e.dwg_dynapi_entity_data(t,"num_column_heights"),F=e.dwg_dynapi_entity_data(t,"column_heights"),ct=e.dwg_ptr_to_double_array(F,Y);return{type:"MTEXT",...o,insertionPoint:s,textHeight:_,rectHeight:l,rectWidth:f,extentsHeight:g,extentsWidth:h,attachmentPoint:y,drawingDirection:T,text:P,styleName:v,extrusionDirection:C,direction:w,rotation:0,lineSpacingStyle:I,lineSpacing:L,backgroundFill:W,fillBoxScale:M,...$!==void 0?{backgroundFillColor:$}:{},backgroundFillTransparency:O,columnType:q,columnFlowReversed:U,columnAutoHeight:Z,columnWidth:rt,columnGutter:dt,columnHeightCount:Y,columnHeights:ct}}convertPoint(t,o){const e=this.libredwg,s=e.dwg_dynapi_entity_data(t,"x"),_=e.dwg_dynapi_entity_data(t,"y"),l=e.dwg_dynapi_entity_data(t,"z"),f=e.dwg_dynapi_entity_data(t,"thickness"),h=e.dwg_dynapi_entity_data(t,"extrusion"),g=e.dwg_dynapi_entity_data(t,"x_ang");return{type:"POINT",...o,position:{x:s,y:_,z:l},thickness:f,extrusionDirection:h,angle:g}}convertPolyline2d(t,o,e){const s=this.libredwg,_=s.dwg_dynapi_entity_data(t,"flag"),l=s.dwg_dynapi_entity_data(t,"curve_type"),f=s.dwg_dynapi_entity_data(t,"start_width"),h=s.dwg_dynapi_entity_data(t,"end_width"),g=s.dwg_dynapi_entity_data(t,"elevation"),y=s.dwg_dynapi_entity_data(t,"thickness"),T=s.dwg_dynapi_entity_data(t,"extrusion"),P=s.dwg_entity_polyline_2d_get_vertices(e)??[];return{type:"POLYLINE2D",...o,flag:_,smoothType:l,startWidth:f,endWidth:h,elevation:g,thickness:y,extrusionDirection:T,vertices:P.map(v=>({x:v.point.x,y:v.point.y,z:v.point.z,startWidth:v.start_width,endWidth:v.end_width,bulge:v.bulge,flag:v.flag,tangentDirection:v.tangent_dir})),meshMVertexCount:0,meshNVertexCount:0,surfaceMDensity:0,surfaceNDensity:0}}convertPolyline3d(t,o,e){const s=this.libredwg,_=s.dwg_dynapi_entity_data(t,"flag"),l=s.dwg_dynapi_entity_data(t,"curve_type"),f=s.dwg_dynapi_entity_data(t,"start_width"),h=s.dwg_dynapi_entity_data(t,"end_width"),g=s.dwg_dynapi_entity_data(t,"extrusion"),y=s.dwg_entity_polyline_3d_get_vertices(e)??[];return{type:"POLYLINE3D",...o,flag:_,smoothType:l,startWidth:f,endWidth:h,extrusionDirection:g,vertices:y.map(T=>({x:T.point.x,y:T.point.y,z:T.point.z,flag:T.flag}))}}convertProxyEntity(t,o,e){const s=this.libredwg,_=s.dwg_dynapi_entity_data(t,"proxy_id"),l=s.dwg_dynapi_entity_data(t,"class_id"),f=s.dwg_dynapi_entity_data(t,"data_numbits"),h=s.dwg_dynapi_entity_data(t,"version"),g=s.dwg_dynapi_entity_data(t,"from_dxf"),y=s.dwg_dynapi_entity_data(t,"num_objids"),T=s.dwg_entity_get_preview(e),P=(T==null?void 0:T.length)??0,v=s.dwg_entity_proxy_entity_get_entity_data(t),C=T?ze(T):void 0,w=v?ze(v):void 0;let I;if(y>0){const M=s.dwg_dynapi_entity_data(t,"objids");M&&(I=s.dwg_ptr_to_object_ref_array(M,y).map(O=>ft(O.absolute_ref)))}const L=this.getOriginalDxfName(l),W={type:"ACAD_PROXY_ENTITY",subclassMarker:"AcDbProxyEntity",...o,proxyEntityClassId:_||498,applicationEntityClassId:l};return L&&(W.originalDxfName=L),P>0&&(W.graphicsDataSize=P),C&&(W.graphicsData=C),f>0&&(W.entityDataSize=f),w&&(W.entityData=w),I&&I.length>0&&(W.linkedObjectIds=I),h&&(W.objectDrawingFormat=h),(g===0||g===1)&&(W.originalDataFormat=g),W}getOriginalDxfName(t){if(this.classes.length===0||t<0)return;const o=t>=500?t-500:t;if(o>=0&&o<this.classes.length)return this.classes[o].dxfName}convertRay(t,o){const e=this.libredwg,s=e.dwg_dynapi_entity_data(t,"point"),_=e.dwg_dynapi_entity_data(t,"vector");return{type:"RAY",...o,firstPoint:s,unitDirection:_}}convertSection(t,o){const e=this.libredwg,s=e.dwg_dynapi_entity_data(t,"state"),_=e.dwg_dynapi_entity_data(t,"flag"),l=e.dwg_dynapi_entity_data(t,"name"),f=e.dwg_dynapi_entity_data(t,"vert_dir"),h=e.dwg_dynapi_entity_data(t,"top_height"),g=e.dwg_dynapi_entity_data(t,"bottom_height"),y=e.dwg_dynapi_entity_data(t,"indicator_alpha"),T=e.dwg_dynapi_entity_data(t,"indicator_color"),P=e.dwg_dynapi_entity_data(t,"num_verts"),v=e.dwg_dynapi_entity_data(t,"verts"),C=P>0?e.dwg_ptr_to_point3d_array(v,P):[],w=e.dwg_dynapi_entity_data(t,"num_blverts"),I=e.dwg_dynapi_entity_data(t,"blverts"),L=w>0?e.dwg_ptr_to_point3d_array(I,w):[],W=e.dwg_dynapi_entity_data(t,"geometrySettingHardId"),M=e.dwg_ref_get_handle_absolute_ref(W)??0n;return{type:"SECTION",...o,state:s,flags:_,name:l,verticalDirection:f,topHeight:h,bottomHeight:g,indicatorTransparency:y,indicatorColor:T.rgb,numberOfVertices:P,vertices:C,numberOfBackLineVertices:w,backLineVertices:L,geometrySettingHardId:M}}convertShape(t,o){const e=this.libredwg,s=e.dwg_dynapi_entity_data(t,"ins_pt"),_=e.dwg_dynapi_entity_data(t,"scale"),l=e.dwg_dynapi_entity_data(t,"rotation"),f=e.dwg_dynapi_entity_data(t,"width_factor"),h=e.dwg_dynapi_entity_data(t,"oblique_angle"),g=e.dwg_dynapi_entity_data(t,"thickness"),y=e.dwg_dynapi_entity_data(t,"extrusion"),T=e.dwg_dynapi_entity_data(t,"style_id"),P=e.dwg_entity_text_get_style_name(t);return{type:"SHAPE",subclassMarker:"AcDbShape",...o,thickness:g,insertionPoint:s,size:_,shapeNumber:T,styleName:P,rotation:l,xScale:f,obliqueAngle:h,extrusionDirection:y}}convertSolid(t,o){const e=this.libredwg,s=e.dwg_dynapi_entity_data(t,"corner1"),_=e.dwg_dynapi_entity_data(t,"corner2"),l=e.dwg_dynapi_entity_data(t,"corner3"),f=e.dwg_dynapi_entity_data(t,"corner4"),h=e.dwg_dynapi_entity_data(t,"thickness"),g=e.dwg_dynapi_entity_data(t,"extrusion");return{type:"SOLID",...o,corner1:s,corner2:_,corner3:l,corner4:f,thickness:h,extrusionDirection:g}}convertTrace(t,o){return{...this.convertSolid(t,o),type:"TRACE"}}convertSpline(t,o){const e=this.libredwg,s=e.dwg_dynapi_entity_data(t,"splineflags"),_=e.dwg_dynapi_entity_data(t,"degree"),l=e.dwg_dynapi_entity_data(t,"knot_tol"),f=e.dwg_dynapi_entity_data(t,"num_knots"),h=e.dwg_dynapi_entity_data(t,"knots"),g=e.dwg_ptr_to_double_array(h,f),y=e.dwg_dynapi_entity_data(t,"fit_tol"),T=e.dwg_dynapi_entity_data(t,"num_fit_pts"),P=e.dwg_dynapi_entity_data(t,"fit_pts"),v=e.dwg_ptr_to_point3d_array(P,T),C=e.dwg_dynapi_entity_data(t,"weighted"),w=e.dwg_dynapi_entity_data(t,"ctrl_tol"),I=e.dwg_dynapi_entity_data(t,"num_ctrl_pts"),L=e.dwg_dynapi_entity_data(t,"ctrl_pts"),W=e.dwg_ptr_to_point4d_array(L,I),M=e.dwg_dynapi_entity_data(t,"beg_tan_vec"),b=e.dwg_dynapi_entity_data(t,"end_tan_vec");return{type:"SPLINE",...o,flag:s,degree:_,numberOfKnots:f,numberOfControlPoints:I,numberOfFitPoints:T,knotTolerance:l,controlTolerance:w,fitTolerance:y,startTangent:M,endTangent:b,knots:g,weights:C?W.map(O=>O.w):void 0,controlPoints:W.map(O=>({x:O.x,y:O.y,z:O.z})),fitPoints:v}}convertTable(t,o){const e=this.libredwg,s=e.dwg_dynapi_subclass_data(t,"ldata","name"),_=e.dwg_dynapi_entity_data(t,"ins_pt"),l=e.dwg_dynapi_entity_data(t,"horiz_direction"),f=e.dwg_dynapi_entity_data(t,"flag_for_table_value"),h=e.dwg_dynapi_entity_data(t,"num_rows"),g=e.dwg_dynapi_entity_data(t,"num_cols"),y=e.dwg_dynapi_entity_data(t,"row_heights"),T=e.dwg_ptr_to_double_array(y,h),P=e.dwg_dynapi_entity_data(t,"col_widths"),v=e.dwg_ptr_to_double_array(P,g),C=e.dwg_dynapi_entity_data(t,"tablestyle"),w=e.dwg_ref_get_id(C)??"",I=e.dwg_dynapi_entity_data(t,"block_header"),L=e.dwg_ref_get_id(I)??"",W=e.dwg_dynapi_entity_data(t,"table_flag_override"),M=e.dwg_dynapi_entity_data(t,"border_color_overrides_flag"),b=e.dwg_dynapi_entity_data(t,"border_lineweight_overrides_flag"),O=e.dwg_dynapi_entity_data(t,"border_visibility_overrides_flag"),$=e.dwg_dynapi_entity_data(t,"num_cells"),q=e.dwg_dynapi_entity_data(t,"cells"),U=e.dwg_ptr_to_table_cell_array(q,$);return{type:"ACAD_TABLE",...o,name:s,startPoint:_,directionVector:l,tableValue:f,rowCount:h,columnCount:g,overrideFlag:W,borderColorOverrideFlag:M,borderLineWeightOverrideFlag:b,borderVisibilityOverrideFlag:O,rowHeightArr:T,columnWidthArr:v,tableStyleId:w,blockRecordHandle:L,cells:this.convertTableCells(U),bmpPreview:""}}convertTableCells(t){return t.map(o=>{var e,s;return{text:o.text_value,attachmentPoint:o.cell_alignment,textStyle:o.text_style?String(o.text_style):void 0,rotation:o.rotation,cellType:o.type,flagValue:o.flags,mergedValue:o.is_merged_value,autoFit:o.is_autofit_flag,topBorderVisibility:!!o.top_visibility,bottomBorderVisibility:!!o.bottom_visibility,leftBorderVisibility:!!o.left_visibility,rightBorderVisibility:!!o.right_visibility,overrideFlag:o.cell_flag_override,virtualEdgeFlag:o.virtual_edge_flag,blockTableRecordId:o.block_handle?String(o.block_handle.absolute_ref??""):void 0,blockScale:o.block_scale,blockAttrNum:((e=o.attr_defs)==null?void 0:e.length)??0,attrDefineId:(s=o.attr_defs)==null?void 0:s.map(_=>{var l;return String(((l=_.attdef)==null?void 0:l.absolute_ref)??"")}),textHeight:o.text_height??0,extendedCellFlags:o.additional_data_flag}})}convertTextBase(t){const o=this.libredwg,e=o.dwg_dynapi_entity_data(t,"text_value"),s=o.dwg_dynapi_entity_data(t,"thickness"),_=o.dwg_dynapi_entity_data(t,"ins_pt"),l=o.dwg_dynapi_entity_data(t,"alignment_pt"),f=o.dwg_dynapi_entity_data(t,"rotation"),h=o.dwg_dynapi_entity_data(t,"height"),g=o.dwg_dynapi_entity_data(t,"width_factor"),y=o.dwg_dynapi_entity_data(t,"oblique_angle"),T=o.dwg_entity_text_get_style_name(t),P=o.dwg_dynapi_entity_data(t,"generation"),v=o.dwg_dynapi_entity_data(t,"horiz_alignment"),C=o.dwg_dynapi_entity_data(t,"vert_alignment"),w=o.dwg_dynapi_entity_data(t,"elevation"),I=o.dwg_dynapi_entity_data(t,"extrusion");return{text:e,thickness:s,startPoint:_,endPoint:l,textHeight:h,rotation:f,xScale:g,obliqueAngle:y,styleName:T,generationFlag:P,halign:v,valign:C,elevation:w,extrusionDirection:I}}convertText(t,o){return{type:"TEXT",...o,...this.convertTextBase(t)}}convertTolerance(t,o){const e=this.libredwg,s=e.dwg_dynapi_entity_data(t,"ins_pt"),_=e.dwg_dynapi_entity_data(t,"text_value"),l=e.dwg_dynapi_entity_data(t,"x_direction"),f=e.dwg_dynapi_entity_data(t,"extrusion"),h=e.dwg_entity_get_dimstyle_name(t);return{type:"TOLERANCE",...o,styleName:h,insertionPoint:s,text:_,extrusionDirection:f,xAxisDirection:l}}convertViewport(t,o){const e=this.libredwg,s=e.dwg_dynapi_entity_data(t,"center"),_=e.dwg_dynapi_entity_data(t,"width"),l=e.dwg_dynapi_entity_data(t,"height"),f=e.dwg_dynapi_entity_data(t,"on_off"),h=e.dwg_dynapi_entity_data(t,"VIEWCTR"),g=e.dwg_dynapi_entity_data(t,"SNAPBASE"),y=e.dwg_dynapi_entity_data(t,"SNAPUNIT"),T=e.dwg_dynapi_entity_data(t,"GRIDUNIT"),P=e.dwg_dynapi_entity_data(t,"VIEWDIR"),v=e.dwg_dynapi_entity_data(t,"view_target"),C=e.dwg_dynapi_entity_data(t,"lens_length"),w=e.dwg_dynapi_entity_data(t,"front_clip_z"),I=e.dwg_dynapi_entity_data(t,"back_clip_z"),L=e.dwg_dynapi_entity_data(t,"VIEWSIZE"),W=e.dwg_dynapi_entity_data(t,"SNAPANG"),M=e.dwg_dynapi_entity_data(t,"twist_angle"),b=e.dwg_dynapi_entity_data(t,"circle_zoom"),O=e.dwg_dynapi_entity_data(t,"num_frozen_layers");let $;if(O>0){const $t=e.dwg_dynapi_entity_data(t,"frozen_layers");$t&&($=e.dwg_ptr_to_object_ref_ptr_array($t,O).map(Vt=>e.dwg_ref_get_id(Vt)).filter(Vt=>!!Vt))}const q=e.dwg_dynapi_entity_data(t,"status_flag"),U=e.dwg_dynapi_entity_data(t,"clip_boundary"),Z=e.dwg_ref_get_id(U),rt=e.dwg_dynapi_entity_data(t,"style_sheet"),dt=e.dwg_dynapi_entity_data(t,"render_mode"),Y=e.dwg_dynapi_entity_data(t,"UCSVP"),F=e.dwg_dynapi_entity_data(t,"ucsorg"),ct=e.dwg_dynapi_entity_data(t,"ucsxdir"),it=e.dwg_dynapi_entity_data(t,"ucsydir"),Yt=e.dwg_dynapi_entity_data(t,"named_ucs"),wt=e.dwg_ref_get_id(Yt),pt=e.dwg_dynapi_entity_data(t,"base_ucs"),Ct=e.dwg_ref_get_id(pt),xt=e.dwg_dynapi_entity_data(t,"UCSORTHOVIEW"),Dt=e.dwg_dynapi_entity_data(t,"ucs_elevation"),Ot=e.dwg_dynapi_entity_data(t,"shadeplot_mode"),ht=e.dwg_dynapi_entity_data(t,"use_default_lights"),Rt=e.dwg_dynapi_entity_data(t,"default_lighting_type"),Jt=e.dwg_dynapi_entity_data(t,"brightness"),kt=e.dwg_dynapi_entity_data(t,"contrast"),Nt=e.dwg_dynapi_entity_data(t,"grid_major"),Bt=e.dwg_dynapi_entity_data(t,"background"),Ft=e.dwg_ref_get_id(Bt),re=e.dwg_dynapi_entity_data(t,"shadeplot"),ae=e.dwg_ref_get_id(re),oe=e.dwg_dynapi_entity_data(t,"visualstyle"),Ut=e.dwg_ref_get_id(oe),Q=e.dwg_dynapi_entity_data(t,"sun"),H=e.dwg_ref_get_id(Q);return{type:"VIEWPORT",...o,viewportCenter:s,width:_,height:l,status:f,viewportId:0,displayCenter:h,snapBase:g,snapSpacing:y,gridSpacing:T,viewDirection:P,targetPoint:v,perspectiveLensLength:C,frontClipZ:w,backClipZ:I,viewHeight:L,snapAngle:W,viewTwistAngle:M,circleZoomPercent:b,frozenLayerIds:$,statusBitFlags:q,clippingBoundaryId:Z,sheetName:rt,renderMode:dt,ucsPerViewport:Y,ucsOrigin:F,ucsXAxis:ct,ucsYAxis:it,ucsId:wt??"",ucsBaseId:Ct??"",orthographicType:xt,elevation:Dt,shadePlotMode:Ot,majorGridFrequency:Nt,backgroundId:Ft??"",shadePlotId:ae??"",visualStyleId:Ut??"",isDefaultLighting:!!ht,defaultLightingType:Rt,brightness:Jt,contrast:kt,sunId:H??""}}convertWipeout(t,o){const e=this.libredwg,s=e.dwg_dynapi_entity_data(t,"class_version"),_=e.dwg_dynapi_entity_data(t,"pt0"),l=e.dwg_dynapi_entity_data(t,"uvec"),f=e.dwg_dynapi_entity_data(t,"vvec"),h=e.dwg_dynapi_entity_data(t,"image_size"),g=e.dwg_dynapi_entity_data(t,"display_props"),y=e.dwg_dynapi_entity_data(t,"clipping"),T=e.dwg_dynapi_entity_data(t,"brightness"),P=e.dwg_dynapi_entity_data(t,"contrast"),v=e.dwg_dynapi_entity_data(t,"fade"),C=e.dwg_dynapi_entity_data(t,"clip_mode"),w=e.dwg_dynapi_entity_data(t,"clip_boundary_type"),I=e.dwg_dynapi_entity_data(t,"num_clip_verts"),L=e.dwg_dynapi_entity_data(t,"clip_verts"),W=e.dwg_ptr_to_point2d_array(L,I),M=e.dwg_dynapi_entity_data(t,"imagedef"),b=e.dwg_ref_get_absref(M)??0,O=e.dwg_dynapi_entity_data(t,"imagedefreactor"),$=e.dwg_ref_get_absref(O)??0;return{type:"WIPEOUT",...o,version:s,position:_,uPixel:l,vPixel:f,imageSize:h,imageDefHandle:b,flags:g,clipping:y,brightness:T,contrast:P,fade:v,imageDefReactorHandle:$,clippingBoundaryType:w,countBoundaryPoints:I,clippingBoundaryPath:W,clipMode:C}}convertXline(t,o){const e=this.libredwg,s=e.dwg_dynapi_entity_data(t,"point"),_=e.dwg_dynapi_entity_data(t,"vector");return{type:"XLINE",...o,firstPoint:s,unitDirection:_}}getDimensionCommonAttrs(t){const o=this.libredwg,e=o.dwg_dynapi_entity_data(t,"class_version"),s=o.dwg_entity_get_block_name(t,"block"),_=o.dwg_dynapi_entity_data(t,"def_pt"),l=o.dwg_dynapi_entity_data(t,"text_midpt"),f=o.dwg_dynapi_entity_data(t,"attachmentPoint"),h=o.dwg_dynapi_entity_data(t,"flag"),g=o.dwg_dynapi_entity_data(t,"lspace_factor"),y=o.dwg_dynapi_entity_data(t,"lspace_factor"),T=o.dwg_dynapi_entity_data(t,"act_measurement"),P=o.dwg_dynapi_entity_data(t,"user_text"),v=o.dwg_dynapi_entity_data(t,"text_rotation"),C=o.dwg_dynapi_entity_data(t,"ins_rotation"),w=o.dwg_dynapi_entity_data(t,"extrusion"),I=o.dwg_entity_get_dimstyle_name(t);return{type:"DIMENSION",version:e,name:s,definitionPoint:_,textPoint:l,dimensionType:h,attachmentPoint:f,textLineSpacingStyle:g,textLineSpacingFactor:y||1,measurement:T,text:P,textRotation:v,ocsRotation:C,extrusionDirection:w,styleName:I}}getCommonAttrs(t){const o=this.libredwg,e=o.dwg_object_entity_get_color_object(t),s=e.method,_=e.index;let l;(s==194||(e.rgb>>>24&255)===194)&&(l=e.rgb&16777215);const f=this.getLayerName(t),h=o.dwg_object_entity_get_handle_object(t),g=o.dwg_object_entity_get_ownerhandle_object(t),y=o.dwg_object_entity_get_xdicobjhandle_object(t),T=this.getLtypeName(t),P=o.dwg_object_entity_get_line_weight(t),v=o.dwg_object_entity_get_ltype_scale(t),C=!o.dwg_object_entity_get_invisible(t),w=o.dwg_object_entity_get_xdata(t);return{handle:ft(h.value),ownerDictionaryHardId:ft(y.absolute_ref),ownerBlockRecordSoftId:ft(g.absolute_ref),layer:f,color:l,colorIndex:_,colorName:e.name,lineType:T,lineweight:P,lineTypeScale:v,isVisible:C,transparency:e.alpha,transparencyType:e.alpha_type,xdata:w}}getLayerName(t){const e=this.libredwg.dwg_object_entity_get_layer_object_ref(t);return this.layers.get(ft(e.handleref.value))??"0"}getLtypeName(t){const e=this.libredwg.dwg_object_entity_get_ltype_object_ref(t);return this.ltypes.get(ft(e.handleref.value))??""}}class lr{constructor(t){nt(this,"libredwg"),nt(this,"entityConverter"),nt(this,"orphanEntitiesByBlock",null),nt(this,"ownerlessOrphanIndices",null),nt(this,"orphanIndexDataPtr",null),nt(this,"layerPlotFlagSupported",!0),this.libredwg=t,this.entityConverter=new bo(t)}convert(t){var o;this.entityConverter.clear(),this.orphanEntitiesByBlock=null,this.ownerlessOrphanIndices=null,this.orphanIndexDataPtr=t,this.layerPlotFlagSupported=!0;const e={tables:{APPID:{entries:[]},BLOCK_RECORD:{entries:[]},DIMSTYLE:{entries:[]},LAYER:{entries:[]},LTYPE:{entries:[]},STYLE:{entries:[]},VPORT:{entries:[]}},objects:{ASSOCNETWORK:[],ASSOCACTION:[],ASSOCDEPENDENCY:[],ASSOCARRAYACTIONBODY:[],ASSOCVERTEXACTIONPARAM:[],ASSOCEDGEACTIONPARAM:[],DICTIONARY:[],GROUP:[],IMAGEDEF:[],LAYER_FILTER:[],LAYER_INDEX:[],LAYOUT:[],MLEADERSTYLE:[],SPATIAL_FILTER:[],XRECORD:[]},header:{},entities:[],classes:[]},s=this.libredwg;this.convertHeader(t,e.header),this.layerPlotFlagSupported=s.dwg_get_version_type(t).version>=22,this.convertClasses(t,e.classes),this.entityConverter.setClasses(e.classes);const _=s.dwg_get_num_objects(t);for(let h=0;h<_;h++){const g=s.dwg_get_object(t,h);if(g){const y=this.safeObjectTio(g);if(y)switch(s.dwg_object_get_fixedtype(g)){case S.DWG_TYPE_LAYER:{const P=this.convertLayer(y,g);e.tables.LAYER.entries.push(P),this.entityConverter.layers.set(P.handle,P.name)}break;case S.DWG_TYPE_LTYPE:{const P=this.convertLineType(y,g);e.tables.LTYPE.entries.push(P),this.entityConverter.ltypes.set(P.handle,P.name)}break}}}for(let h=0;h<_;h++){const g=s.dwg_get_object(t,h);if(g){const y=this.safeObjectTio(g);if(y)switch(s.dwg_object_get_fixedtype(g)){case S.DWG_TYPE_APPID:e.tables.APPID.entries.push(this.convertAppId(y));break;case S.DWG_TYPE_BLOCK_HEADER:{const P=this.convertBlockRecord(y,g);e.tables.BLOCK_RECORD.entries.push(P),(Gn(P.name)||Go(P.name))&&P.entities.forEach(v=>{e.entities.push(v),v.type==="INSERT"&&v.attribs.forEach(C=>{e.entities.push(C)})})}break;case S.DWG_TYPE_DIMSTYLE:e.tables.DIMSTYLE.entries.push(this.convertDimStyle(y,g));break;case S.DWG_TYPE_STYLE:e.tables.STYLE.entries.push(this.convertStyle(y,g));break;case S.DWG_TYPE_VPORT:e.tables.VPORT.entries.push(this.convertViewport(y,g));break;case S.DWG_TYPE_DICTIONARY:e.objects.DICTIONARY.push(this.convertDictionary(y,g));break;case S.DWG_TYPE_GROUP:e.objects.GROUP.push(this.convertGroup(y,g));break;case S.DWG_TYPE_IMAGEDEF:e.objects.IMAGEDEF.push(this.convertImageDef(y,g));break;case S.DWG_TYPE_LAYERFILTER:e.objects.LAYER_FILTER.push(this.convertLayerFilter(y,g));break;case S.DWG_TYPE_LAYER_INDEX:e.objects.LAYER_INDEX.push(this.convertLayerIndex(y,g));break;case S.DWG_TYPE_LAYOUT:e.objects.LAYOUT.push(this.convertLayout(y,g));break;case S.DWG_TYPE_MLEADERSTYLE:e.objects.MLEADERSTYLE.push(this.convertMLeaderStyle(y,g));break;case S.DWG_TYPE_SPATIAL_FILTER:e.objects.SPATIAL_FILTER.push(this.convertSpatialFilter(y,g));break;case S.DWG_TYPE_XRECORD:e.objects.XRECORD.push(this.convertXRecord(y,g));break;case S.DWG_TYPE_ASSOCNETWORK:e.objects.ASSOCNETWORK.push(this.convertAssocNetwork(y,g));break;case S.DWG_TYPE_ASSOCACTION:e.objects.ASSOCACTION.push(this.convertAssocAction(y,g));break;case S.DWG_TYPE_ASSOCDEPENDENCY:e.objects.ASSOCDEPENDENCY.push(this.convertAssocDependency(y,g));break;case S.DWG_TYPE_ASSOCARRAYACTIONBODY:e.objects.ASSOCARRAYACTIONBODY.push(this.convertAssocArrayActionBody(y,g));break;case S.DWG_TYPE_ASSOCVERTEXACTIONPARAM:e.objects.ASSOCVERTEXACTIONPARAM.push(this.convertAssocVertexActionParam(y,g));break;case S.DWG_TYPE_ASSOCEDGEACTIONPARAM:e.objects.ASSOCEDGEACTIONPARAM.push(this.convertAssocEdgeActionParam(y,g));break}}}const l=e.entities.filter(h=>h.type==="VIEWPORT");l.sort((h,g)=>{const y=parseInt(h.handle,16),T=parseInt(g.handle,16);return y-T}),l.forEach((h,g)=>{h.viewportId=g+1});const f=s.dwg_bmp(t);return(o=f==null?void 0:f.data)!=null&&o.length&&(e.thumbnailImage=f.data),e}getConversionStats(){return{unknownEntityCount:this.entityConverter.unknownEntityCount}}safeObjectTio(t){const o=this.libredwg;try{if(o.dwg_object_get_supertype(t)!=Nn.DWG_SUPERTYPE_OBJECT)return null;const e=o.dwg_object_to_object_tio(t);return e||null}catch{return null}}convertHeader(t,o){const e=this.libredwg;Do.forEach(s=>{let _=s;(s=="DIMBLK"||s=="DIMBLK1"||s=="DIMBLK2")&&(_=_+"_T");let l=e.dwg_dynapi_header_data(t,_);s=="CELTYPE"||s=="CLAYER"||s=="CLAYER"||s=="DIMSTYLE"||s=="DIMTXSTY"||s=="TEXTSTYLE"?l=l?e.dwg_ref_get_object_name(l):"":s=="DRAGVS"&&(l=l?e.dwg_ref_get_absref(l)??2:2),o[s]=l})}convertClasses(t,o){const e=this.libredwg,s=e.dwg_get_num_classes(t);for(let _=0;_<s;_++){const l=e.dwg_get_class(t,_);o.push({dxfName:l.dxfname,cppName:l.cppname,appName:l.appname,capabilitiesFlag:l.proxyflag,instanceCount:l.num_instances,wasAProxyFlag:l.s_zombie,isAnEntityFlag:l.item_class_id===498})}}convertAppId(t){const o=this.libredwg,e=o.dwg_dynapi_entity_data(t,"name"),s=o.dwg_dynapi_entity_data(t,"flag");return{name:e,standardFlag:s}}convertBlockRecord(t,o){const e=this.libredwg,s=this.getCommonTableEntryAttrs(t,o),_=e.dwg_entity_block_header_get_block(t);_.name&&(s.name=_.name);const l=e.dwg_dynapi_entity_data(t,"num_owned"),f=e.dwg_dynapi_entity_data(t,"flag"),h=e.dwg_dynapi_entity_data(t,"description"),g=e.dwg_dynapi_entity_data(t,"base_pt"),y=e.dwg_dynapi_entity_data(t,"insert_units"),T=e.dwg_dynapi_entity_data(t,"explodable"),P=e.dwg_dynapi_entity_data(t,"block_scaling"),v=e.dwg_dynapi_entity_data(t,"layout"),C=e.dwg_ref_get_id(v)??"";let w;const I=e.dwg_entity_block_header_get_preview(t);I&&I.length>0&&(w=ze(I));let L=this.convertEntities(o,s.handle);if(!L||L.length==0){L=[];const W=e.dwg_dynapi_entity_data(t,"entities");if(W){const M=e.dwg_ptr_to_object_ref_ptr_array(W,l),b=this.entityConverter;for(let O=0;O<l;O++){const $=e.dwg_ref_get_object(M[O]),q=b.convert($);q&&(q.ownerBlockRecordSoftId=s.handle,L.push(q))}}}if(this.orphanIndexDataPtr!=null){const W=this.convertOrphanOwnedEntities(this.orphanIndexDataPtr,o,s.handle,Gn(s.name)===!0);if(W.length)if(L.length===0)L=W;else{const M=new Set(L.map(b=>b.handle));for(const b of W)M.has(b.handle)||L.push(b)}}return{...s,flags:f,description:h,basePoint:g,layout:C,insertionUnits:y,explodability:T,scalability:P,bmpPreview:w,entities:L}}convertEntities(t,o){const e=this.libredwg,s=this.entityConverter,_=[];let l=e.get_first_owned_entity(t);for(;l;){const f=s.convert(l);f&&(f.ownerBlockRecordSoftId=o,_.push(f)),l=e.get_next_owned_entity(t,l)}return _}convertOrphanOwnedEntities(t,o,e,s){this.ensureOrphanEntityIndex(t);const l=(this.orphanEntitiesByBlock??new Map).get(o)??[],f=s&&this.ownerlessOrphanIndices?this.ownerlessOrphanIndices:[],h=l.length&&f.length?l.concat(f):l.length?l:f;if(h.length===0)return[];const g=this.libredwg,y=this.entityConverter,T=[];for(const P of h){const v=g.dwg_get_object(t,P),C=y.convert(v);C&&(C.ownerBlockRecordSoftId=e,T.push(C))}return T}isOwnedByMissingBlock(t,o){if(!o)return!1;const e=this.libredwg;try{const s=e.dwg_dynapi_common_value(o,"entmode");if(!s.success||Number(s.data)!==0)return!1;const _=e.dwg_dynapi_common_value(o,"ownerhandle");if(!_.success||!_.data)return!1;const l=e.dwg_ref_get_absref(_.data);return l==null?!1:!e.dwg_resolve_handle_silent(t,BigInt(l))}catch{return!1}}ensureOrphanEntityIndex(t){if(this.orphanEntitiesByBlock)return;const o=this.libredwg,e=o.dwg_get_num_objects(t),s=new Map,_=[],l=[],f=new Map;for(let T=0;T<e;T++){const P=o.dwg_get_object(t,T);if(P){if(o.dwg_object_get_supertype(P)===Nn.DWG_SUPERTYPE_ENTITY)_.push(T),s.set(P,T);else if(o.dwg_object_get_fixedtype(P)===S.DWG_TYPE_BLOCK_HEADER){l.push(P);const v=o.dwg_object_to_object_tio(P);v&&f.set(v,P)}}}const h=new Set;for(const T of l){let P=o.get_first_owned_entity(T),v=0;for(;P&&v++<=_.length;){const C=s.get(P);if(C===void 0||h.has(C))break;h.add(C),P=o.get_next_owned_entity(T,P)}}const g=new Map,y=[];for(const T of _){if(h.has(T))continue;const P=o.dwg_get_object(t,T),v=P?o.dwg_object_to_entity_tio(P):0,C=v?o.dwg_entity_owner(v):0,w=C?f.get(C)??0:0;if(w){const I=g.get(w);I?I.push(T):g.set(w,[T])}else this.isOwnedByMissingBlock(t,v)||y.push(T)}this.orphanEntitiesByBlock=g,this.ownerlessOrphanIndices=y}convertDimStyle(t,o){const e=this.libredwg,s=this.getCommonTableEntryAttrs(t,o),_=e.dwg_dynapi_entity_data(t,"DIMTOL"),l=e.dwg_dynapi_entity_data(t,"DIMLIM"),f=e.dwg_dynapi_entity_data(t,"DIMTIH"),h=e.dwg_dynapi_entity_data(t,"DIMTOH"),g=e.dwg_dynapi_entity_data(t,"DIMSE1"),y=e.dwg_dynapi_entity_data(t,"DIMSE2"),T=e.dwg_dynapi_entity_data(t,"DIMALT"),P=e.dwg_dynapi_entity_data(t,"DIMTOFL"),v=e.dwg_dynapi_entity_data(t,"DIMSAH"),C=e.dwg_dynapi_entity_data(t,"DIMTIX"),w=e.dwg_dynapi_entity_data(t,"DIMSOXD"),I=e.dwg_dynapi_entity_data(t,"DIMALTD"),L=e.dwg_dynapi_entity_data(t,"DIMZIN"),W=e.dwg_dynapi_entity_data(t,"DIMSD1"),M=e.dwg_dynapi_entity_data(t,"DIMSD2"),b=e.dwg_dynapi_entity_data(t,"DIMTOLJ"),O=e.dwg_dynapi_entity_data(t,"DIMJUST"),$=e.dwg_dynapi_entity_data(t,"DIMFIT"),q=e.dwg_dynapi_entity_data(t,"DIMUPT"),U=e.dwg_dynapi_entity_data(t,"DIMTZIN"),Z=e.dwg_dynapi_entity_data(t,"DIMALTZ"),rt=e.dwg_dynapi_entity_data(t,"DIMALTTZ"),dt=e.dwg_dynapi_entity_data(t,"DIMTAD"),Y=e.dwg_dynapi_entity_data(t,"DIMUNIT"),F=e.dwg_dynapi_entity_data(t,"DIMAUNIT"),ct=e.dwg_dynapi_entity_data(t,"DIMDEC"),it=e.dwg_dynapi_entity_data(t,"DIMTDEC"),Yt=e.dwg_dynapi_entity_data(t,"DIMALTU"),wt=e.dwg_dynapi_entity_data(t,"DIMALTTD"),pt=e.dwg_dynapi_entity_data(t,"DIMSCALE"),Ct=e.dwg_dynapi_entity_data(t,"DIMASZ"),xt=e.dwg_dynapi_entity_data(t,"DIMEXO"),Dt=e.dwg_dynapi_entity_data(t,"DIMDLI"),Ot=e.dwg_dynapi_entity_data(t,"DIMEXE"),ht=e.dwg_dynapi_entity_data(t,"DIMRND"),Rt=e.dwg_dynapi_entity_data(t,"DIMDLE"),Jt=e.dwg_dynapi_entity_data(t,"DIMTP"),kt=e.dwg_dynapi_entity_data(t,"DIMTM"),Nt=e.dwg_dynapi_entity_data(t,"DIMFXL"),Bt=e.dwg_dynapi_entity_data(t,"DIMJOGANG"),Ft=e.dwg_dynapi_entity_data(t,"DIMTFILL"),re=e.dwg_dynapi_entity_data(t,"DIMTFILLCLR"),ae=e.dwg_dynapi_entity_data(t,"DIMAZIN"),oe=e.dwg_dynapi_entity_data(t,"DIMARCSYM"),Ut=e.dwg_dynapi_entity_data(t,"DIMTXT"),Q=e.dwg_dynapi_entity_data(t,"DIMCEN"),H=e.dwg_dynapi_entity_data(t,"DIMTSZ"),$t=e.dwg_dynapi_entity_data(t,"DIMALTF"),ie=e.dwg_dynapi_entity_data(t,"DIMLFAC"),Vt=e.dwg_dynapi_entity_data(t,"DIMTVP"),ge=e.dwg_dynapi_entity_data(t,"DIMTFAC"),We=e.dwg_dynapi_entity_data(t,"DIMGAP"),Ge=e.dwg_dynapi_entity_data(t,"DIMPOST"),Me=e.dwg_dynapi_entity_data(t,"DIMAPOST"),be=e.dwg_dynapi_entity_data(t,"DIMBLK_T"),xe=e.dwg_dynapi_entity_data(t,"DIMBLK1_T"),Ae=e.dwg_dynapi_entity_data(t,"DIMBLK2_T"),ye=e.dwg_dynapi_entity_data(t,"DIMALTRND"),pe=e.dwg_dynapi_entity_data(t,"DIMCLRD_N"),Te=e.dwg_dynapi_entity_data(t,"DIMCLRE_N"),Oe=e.dwg_dynapi_entity_data(t,"DIMCLRT_N"),Zt=e.dwg_dynapi_entity_data(t,"DIMCLRD"),Wt=e.dwg_dynapi_entity_data(t,"DIMCLRE"),z=e.dwg_dynapi_entity_data(t,"DIMCLRT"),Pe=e.dwg_dynapi_entity_data(t,"DIMADEC"),qt=e.dwg_dynapi_entity_data(t,"DIMFRAC"),St=e.dwg_dynapi_entity_data(t,"DIMLUNIT"),se=e.dwg_dynapi_entity_data(t,"DIMDSEP"),Lt=e.dwg_dynapi_entity_data(t,"DIMTMOVE"),Qt=e.dwg_dynapi_entity_data(t,"DIMATFIT"),Gt=e.dwg_dynapi_entity_data(t,"DIMFXLON"),jt=e.dwg_dynapi_entity_data(t,"DIMTXTDIRECTION"),_e=e.dwg_dynapi_entity_data(t,"DIMALTMZF"),ve=e.dwg_dynapi_entity_data(t,"DIMALTMZS"),Tt=e.dwg_dynapi_entity_data(t,"DIMMZF"),me=e.dwg_dynapi_entity_data(t,"DIMMZS"),de=e.dwg_dynapi_entity_data(t,"DIMLWD"),B=e.dwg_dynapi_entity_data(t,"DIMLWE"),Ie=e.dwg_dynapi_entity_data(t,"DIMTXSTY"),we=e.dwg_ref_get_absref(Ie)??void 0,Ce=e.dwg_dynapi_entity_data(t,"DIMLDRBLK"),De=e.dwg_ref_get_absref(Ce)??void 0;return{...s,DIMPOST:Ge,DIMAPOST:Me,DIMBLK:be,DIMBLK1:xe,DIMBLK2:Ae,DIMSCALE:pt,DIMASZ:Ct,DIMEXO:xt,DIMDLI:Dt,DIMEXE:Ot,DIMRND:ht,DIMDLE:Rt,DIMTP:Jt,DIMTM:kt,DIMTXT:Ut,DIMCEN:Q,DIMTSZ:H,DIMALTF:$t,DIMLFAC:ie,DIMTVP:Vt,DIMTFAC:ge,DIMGAP:We,DIMALTRND:ye,DIMTOL:_,DIMLIM:l,DIMTIH:f,DIMTOH:h,DIMSE1:g,DIMSE2:y,DIMTAD:dt,DIMZIN:L,DIMAZIN:ae,DIMALT:T,DIMALTD:I,DIMTOFL:P,DIMSAH:v,DIMTIX:C,DIMSOXD:w,DIMCLRD:Zt,DIMCLRE:Wt,DIMCLRT:z,DIMADEC:Pe,DIMUNIT:Y,DIMDEC:ct,DIMTDEC:it,DIMALTU:Yt,DIMALTTD:wt,DIMAUNIT:F,DIMFRAC:qt,DIMLUNIT:St,DIMDSEP:String.fromCharCode(se),DIMTMOVE:Lt,DIMJUST:O,DIMSD1:W,DIMSD2:M,DIMTOLJ:b,DIMTZIN:U,DIMALTZ:Z,DIMALTTZ:rt,DIMFIT:$,DIMUPT:q,DIMATFIT:Qt,DIMTXSTY:we,DIMLDRBLK:De,DIMLWD:de,DIMLWE:B,DIMFXL:Nt,DIMJOGANG:Bt,DIMTFILL:Ft,DIMTFILLCLR:re,DIMARCSYM:oe,DIMCLRD_N:pe,DIMCLRE_N:Te,DIMCLRT_N:Oe,DIMFXLON:Gt,DIMTXTDIRECTION:jt,DIMALTMZF:_e,DIMALTMZS:ve,DIMMZF:Tt,DIMMZS:me}}convertLayer(t,o){const e=this.libredwg,s=this.getCommonTableEntryAttrs(t,o),_=e.dwg_dynapi_entity_data(t,"flag"),l=e.dwg_dynapi_entity_data(t,"frozen"),f=e.dwg_dynapi_entity_data(t,"off"),h=e.dwg_dynapi_entity_data(t,"frozen_in_new"),g=e.dwg_dynapi_entity_data(t,"locked");let y=e.dwg_dynapi_entity_data(t,"plotflag");this.layerPlotFlagSupported||(y=1);const T=e.dwg_dynapi_entity_data(t,"linewt"),P=e.dwg_dynapi_entity_data(t,"color"),v=e.dwg_dynapi_entity_data(t,"ltype");let C="Continuous";if(v)try{C=e.dwg_ref_get_object_name(v)}catch{}const w=P.method;let I=256,L=16777215;return w===195||(P.rgb>>>24&255)===195?I=P.rgb&255:w==194||(P.rgb>>>24&255)===194?L=P.rgb&16777215:P.index>=1&&P.index<=255&&(I=P.index),{...s,standardFlag:_,colorIndex:I,color:L,colorName:P.name,transparency:P.alpha,lineType:C,frozen:l!=0,off:f!=0,frozenInNew:h!=0,locked:g!=0,plotFlag:y,lineweight:T,plotStyleNameObjectId:"",materialObjectId:""}}convertLineType(t,o){const e=this.libredwg,s=this.getCommonTableEntryAttrs(t,o),_=e.dwg_dynapi_entity_data(t,"flag"),l=e.dwg_dynapi_entity_data(t,"description"),f=e.dwg_dynapi_entity_data(t,"numdashes"),h=e.dwg_dynapi_entity_data(t,"pattern_len"),g=e.dwg_dynapi_entity_data(t,"dashes"),y=g?e.dwg_ptr_to_ltype_dash_array(g,f):[];return{...s,description:l,standardFlag:_,numberOfLineTypes:f,totalPatternLength:h,pattern:this.convertLineTypePattern(y)}}convertLineTypePattern(t){const o=[];return t.forEach(e=>{o.push({elementLength:e.length||0,elementTypeFlag:e.shape_flag||0,shapeNumber:e.complex_shapecode,scale:e.scale,rotation:e.rotation,offsetX:e.x_offset,offsetY:e.y_offset,text:e.text})}),o}convertStyle(t,o){const e=this.libredwg,s=this.getCommonTableEntryAttrs(t,o),_=e.dwg_dynapi_entity_data(t,"flag"),l=e.dwg_dynapi_entity_data(t,"width_factor"),f=e.dwg_dynapi_entity_data(t,"oblique_angle"),h=e.dwg_dynapi_entity_data(t,"generation"),g=e.dwg_dynapi_entity_data(t,"last_height"),y=e.dwg_dynapi_entity_data(t,"font_file"),T=e.dwg_dynapi_entity_data(t,"bigfont_file");return{...s,standardFlag:_,fixedTextHeight:0,widthFactor:l,obliqueAngle:f,textGenerationFlag:h,lastHeight:g,font:y,bigFont:T}}convertViewport(t,o){const e=this.libredwg,s=this.getCommonTableEntryAttrs(t,o),_=e.dwg_dynapi_entity_data(t,"flag"),l=e.dwg_dynapi_entity_data(t,"VIEWSIZE"),f=e.dwg_dynapi_entity_data(t,"aspect_ratio"),h=e.dwg_dynapi_entity_data(t,"VIEWCTR"),g=e.dwg_dynapi_entity_data(t,"view_target"),y=e.dwg_dynapi_entity_data(t,"VIEWDIR"),T=e.dwg_dynapi_entity_data(t,"view_twist"),P=e.dwg_dynapi_entity_data(t,"lens_length"),v=e.dwg_dynapi_entity_data(t,"front_clip_z"),C=e.dwg_dynapi_entity_data(t,"back_clip_z"),w=e.dwg_dynapi_entity_data(t,"VIEWMODE"),I=e.dwg_dynapi_entity_data(t,"render_mode"),L=e.dwg_dynapi_entity_data(t,"use_default_lights")!=0,W=e.dwg_dynapi_entity_data(t,"default_lightning_type"),M=e.dwg_dynapi_entity_data(t,"brightness"),b=e.dwg_dynapi_entity_data(t,"contrast"),O=e.dwg_dynapi_entity_data(t,"ambient_color"),$=e.dwg_dynapi_entity_data(t,"lower_left"),q=e.dwg_dynapi_entity_data(t,"upper_right"),U=e.dwg_dynapi_entity_data(t,"circle_zoom"),Z=e.dwg_dynapi_entity_data(t,"UCSICON"),rt=e.dwg_dynapi_entity_data(t,"GRIDUNIT"),dt=e.dwg_dynapi_entity_data(t,"SNAPANG"),Y=e.dwg_dynapi_entity_data(t,"SNAPBASE"),F=e.dwg_dynapi_entity_data(t,"SNAPUNIT"),ct=e.dwg_dynapi_entity_data(t,"ucsorg"),it=e.dwg_dynapi_entity_data(t,"ucsxdir"),Yt=e.dwg_dynapi_entity_data(t,"ucsydir"),wt=e.dwg_dynapi_entity_data(t,"ucs_elevation"),pt=e.dwg_dynapi_entity_data(t,"grid_major"),Ct=e.dwg_dynapi_entity_data(t,"background"),xt=Ct?e.dwg_ref_get_id(Ct)??"":void 0,Dt=e.dwg_dynapi_entity_data(t,"visualstyle"),Ot=Dt?e.dwg_ref_get_id(Dt)??"":void 0;return{...s,standardFlag:_,lowerLeftCorner:$,upperRightCorner:q,center:h,snapBasePoint:Y,snapSpacing:F,gridSpacing:rt,viewDirectionFromTarget:y,viewTarget:g,lensLength:P,frontClippingPlane:v,backClippingPlane:C,viewHeight:l,aspectRatio:f,snapRotationAngle:dt,viewTwistAngle:T,circleSides:U,frozenLayers:[],styleSheet:"",renderMode:I,viewMode:w,ucsIconSetting:Z,ucsOrigin:ct,ucsXAxis:it,ucsYAxis:Yt,orthographicType:0,elevation:wt,shadePlotSetting:0,majorGridLines:pt,backgroundObjectId:xt,visualStyleObjectId:Ot,isDefaultLightingOn:L,defaultLightingType:W,brightness:M,contrast:b,ambientColor:O.index}}getCommonTableEntryAttrs(t,o){const e=this.libredwg,s=e.dwg_object_get_tio(o),_=e.dwg_object_object_get_ownerhandle_object(s),l=e.dwg_object_get_handle_object(o);return{handle:ft(l.value),ownerHandle:ft(_.absolute_ref),name:e.dwg_dynapi_entity_data(t,"name")}}convertDictionary(t,o){const e=this.libredwg,s=this.getCommonObjectAttrs(o),_=e.dwg_dynapi_entity_data(t,"is_hardowner"),l=e.dwg_dynapi_entity_data(t,"cloning"),f=e.dwg_dynapi_entity_data(t,"numitems"),h=e.dwg_dynapi_entity_data(t,"itemhandles"),g=e.dwg_ptr_to_object_ref_array(h,f),y=e.dwg_object_dictionary_get_texts(o),T={};return g.forEach((P,v)=>T[y[v]]=ft(P.absolute_ref)),{...s,isHardOwner:!!_,cloningFlag:l,entries:T}}convertImageDef(t,o){const e=this.libredwg,s=this.getCommonObjectAttrs(o),_=e.dwg_dynapi_entity_data(t,"image_size"),l=e.dwg_dynapi_entity_data(t,"file_path"),f=e.dwg_dynapi_entity_data(t,"is_loaded"),h=e.dwg_dynapi_entity_data(t,"pixel_size"),g=e.dwg_dynapi_entity_data(t,"resunits");return{...s,fileName:l,size:_,sizeOfOnePixel:h,isLoaded:f,resolutionUnits:g}}convertLayerFilter(t,o){const e=this.libredwg,s=this.getCommonObjectAttrs(o),_=e.dwg_dynapi_entity_data(t,"num_names")??0,l=e.dwg_dynapi_entity_data(t,"names"),f=l&&_>0?e.dwg_ptr_to_wchar_string_array(l,_).filter(h=>h!=null&&h!==""):[];return{...s,...f.length?{layerNames:f}:{}}}convertLayerIndex(t,o){const e=this.libredwg,s=this.getCommonObjectAttrs(o),_=e.dwg_dynapi_entity_data(t,"last_updated"),l=e.dwg_dynapi_entity_data(t,"num_entries")??0,f=e.dwg_dynapi_entity_data(t,"entries"),h=e.dwg_dynapi_subclass_size("LAYER_entry"),g=[],y=[],T=[];if(f&&h>0)for(let P=0;P<l;P++){const v=f+P*h,C=e.dwg_dynapi_subclass_data(v,"LAYER_entry","name");g.push(C??"");const w=e.dwg_dynapi_subclass_data(v,"LAYER_entry","handle");y.push(w?e.dwg_ref_get_id(w)??"":""),T.push(e.dwg_dynapi_subclass_data(v,"LAYER_entry","numlayers")??0)}return{...s,..._!=null?{timeStamp:_}:{},...g.length?{layerNames:g}:{},...y.length?{idBufferIds:y}:{},...T.length?{idBufferEntryCounts:T}:{}}}convertLayout(t,o){const e=this.libredwg,s=this.getCommonObjectAttrs(o),_=e.dwg_dynapi_entity_data(t,"layout_name"),l=e.dwg_dynapi_entity_data(t,"tab_order"),f=e.dwg_dynapi_entity_data(t,"layout_flags"),h=e.dwg_dynapi_entity_data(t,"INSBASE"),g=e.dwg_dynapi_entity_data(t,"LIMMIN"),y=e.dwg_dynapi_entity_data(t,"LIMMAX"),T=e.dwg_dynapi_entity_data(t,"UCSORG"),P=e.dwg_dynapi_entity_data(t,"UCSXDIR"),v=e.dwg_dynapi_entity_data(t,"UCSYDIR"),C=e.dwg_dynapi_entity_data(t,"UCSORTHOVIEW"),w=e.dwg_dynapi_entity_data(t,"EXTMIN"),I=e.dwg_dynapi_entity_data(t,"EXTMAX"),L=e.dwg_dynapi_entity_data(t,"ucs_elevation"),W=e.dwg_dynapi_entity_data(t,"block_header"),M=e.dwg_ref_get_id(W)??"",b=e.dwg_dynapi_entity_data(t,"active_viewport"),O=e.dwg_ref_get_id(b)??"",$=e.dwg_dynapi_entity_data(t,"named_ucs"),q=$?e.dwg_ref_get_id($)??"":void 0;return{...s,layoutName:_,controlFlag:f,tabOrder:l,minLimit:g,maxLimit:y,insertionPoint:h,minExtent:w,maxExtent:I,elevation:L,ucsOrigin:T,ucsXAxis:P,ucsYAxis:v,orthographicType:C,paperSpaceTableId:M,viewportId:O,namedUcsId:q,shadePlotId:""}}convertMLeaderStyle(t,o){const e=this.libredwg,s=this.getCommonObjectAttrs(o),_=g=>e.dwg_dynapi_entity_data(t,g),l=g=>e.dwg_ref_get_id(g),f=g=>g>0,h=g=>g!=null?gr(g):void 0;return{...s,subclassMarker:"AcDbMLeaderStyle",unknown1:_("class_version"),contentType:_("content_type"),drawMLeaderOrderType:_("mleader_order"),drawLeaderOrderType:_("leader_order"),maxLeaderSegmentPoints:_("max_points"),firstSegmentAngleConstraint:_("first_seg_angle"),secondSegmentAngleConstraint:_("second_seg_angle"),leaderLineType:_("type"),leaderLineColor:h(_("line_color")),leaderLineTypeId:l(_("line_type")),leaderLineWeight:_("linewt"),landingEnabled:f(_("has_landing")),landingGap:_("landing_gap"),doglegEnabled:f(_("has_dogleg")),doglegLength:_("landing_dist"),description:_("description"),arrowheadId:l(_("arrow_head")),arrowheadSize:_("arrow_head_size"),defaultMTextContents:_("text_default"),textStyleId:l(_("text_style")),textLeftAttachmentType:_("attach_left"),textAngleType:_("text_angle_type"),textAlignmentType:_("text_align_type"),textRightAttachmentType:_("attach_right"),textColor:h(_("text_color")),textHeight:_("text_height"),textFrameEnabled:f(_("has_text_frame")),textAlignAlwaysLeft:f(_("text_always_left")),alignSpace:_("align_space"),blockContentId:l(_("block")),blockContentColor:h(_("block_color")),blockContentScale:_("block_scale"),blockContentScaleEnabled:f(_("use_block_scale")),blockContentRotation:_("block_rotation"),blockContentRotationEnabled:f(_("use_block_rotation")),blockContentConnectionType:_("block_connection"),scale:_("scale"),overwritePropertyValue:f(_("is_changed")),annotative:f(_("is_annotative")),breakGapSize:_("break_size"),textAttachmentDirection:_("attach_dir"),bottomTextAttachmentDirection:_("attach_bottom"),topTextAttachmentDirection:_("attach_top"),unknown2:f(_("text_extended"))}}convertSpatialFilter(t,o){const e=this.libredwg,s=this.getCommonObjectAttrs(o),_=e.dwg_dynapi_entity_data(t,"origin"),l=e.dwg_dynapi_entity_data(t,"num_clip_verts"),f=e.dwg_dynapi_entity_data(t,"clip_verts"),h=e.dwg_ptr_to_point2d_array(f,l),g=e.dwg_dynapi_entity_data(t,"extrusion"),y=e.dwg_dynapi_entity_data(t,"display_boundary_on"),T=e.dwg_dynapi_entity_data(t,"front_clip_on"),P=e.dwg_dynapi_entity_data(t,"front_clip_z"),v=e.dwg_dynapi_entity_data(t,"back_clip_on"),C=e.dwg_dynapi_entity_data(t,"back_clip_z"),w=e.dwg_dynapi_entity_data(t,"transform"),I=e.dwg_ptr_to_double_array(w,12),L=e.dwg_dynapi_entity_data(t,"inverse_transform"),W=e.dwg_ptr_to_double_array(L,12);return{...s,origin:_,numberOfPointsOnClipBoundary:l,vertices:h,extrusionDirection:g,clipBoundaryVisible:!!y,frontClippingPlaneFlag:!!T,frontClippingPlaneDistance:P,backClippingPlaneFlag:!!v,backClippingPlaneDistance:C,matrix:I,invertBlockMatrix:W}}convertGroup(t,o){const e=this.libredwg,s=this.getCommonObjectAttrs(o),_=e.dwg_dynapi_entity_data(t,"name")??"",l=!!e.dwg_dynapi_entity_data(t,"unnamed"),f=e.dwg_dynapi_entity_data(t,"selectable"),h=f!=null?!!f:!0,g=e.dwg_dynapi_entity_data(t,"num_groups")??0,y=e.dwg_dynapi_entity_data(t,"groups")??0,P=(g>0&&y?e.dwg_ptr_to_object_ref_array(y,g):[]).map(v=>ft(v.absolute_ref));return{...s,description:_,unnamed:l,selectable:h,objectHandles:P}}convertXRecord(t,o){const e=this.libredwg,s=this.getCommonObjectAttrs(o),_=e.dwg_dynapi_entity_data(t,"cloning"),l=e.dwg_object_xrecord_get_xdata(t)??[],f=e.dwg_object_get_tio(o),h=f?e.dwg_object_object_get_xdicobjhandle_object(f):null,g=h&&h.absolute_ref?ft(h.absolute_ref):void 0;return{...s,..._!=null?{cloning:_}:{},...g?{extensionDictionary:g}:{},data:l}}refId(t){return t?this.libredwg.dwg_ref_get_id(t)??"0":"0"}refIds(t,o){return!t||o<=0?[]:this.libredwg.dwg_ptr_to_object_ref_array(t,o).map(e=>ft(e.absolute_ref))}assocHandleRefs(t,o){const e=this.libredwg,s=e.dwg_dynapi_subclass_size("ASSOCACTION_Deps"),_=[];if(!t||s<=0)return _;for(let l=0;l<o;l++){const f=t+l*s;_.push({handle:this.refId(e.dwg_dynapi_subclass_data(f,"ASSOCACTION_Deps","dep")),isOwned:!!e.dwg_dynapi_subclass_data(f,"ASSOCACTION_Deps","is_owned")})}return _}assocVariant(t){const o=this.libredwg,e=o.dwg_dynapi_subclass_data(t,"EvalVariant","code")??0,s=f=>o.dwg_dynapi_subclass_data(t,"EvalVariant",f),_=(f,h)=>e>=f&&e<=h;let l=null;return _(38,59)||_(140,149)||_(460,469)||_(1040,1042)?l=s("u.bd"):_(90,99)||_(420,429)||_(440,459)||e===1071?l=s("u.bl")|0:_(60,79)||_(170,179)||_(270,279)||_(370,389)||_(400,409)||e===1070?l=s("u.bs")<<16>>16:_(280,289)?l=s("u.rc"):(_(1,4)||_(6,9)||_(100,102)||_(300,309)||_(410,419)||_(430,439)||_(470,479)||e===999||_(1e3,1009))&&(l=null),{code:e,value:l}}assocValueParams(t,o){const e=this.libredwg,s=e.dwg_dynapi_subclass_size("VALUEPARAM"),_=e.dwg_dynapi_subclass_size("VALUEPARAM_vars"),l=[];if(!t||s<=0)return l;for(let f=0;f<o;f++){const h=t+f*s,g=v=>e.dwg_dynapi_subclass_data(h,"VALUEPARAM",v),y=g("num_vars")??0,T=g("vars"),P=[];for(let v=0;T&&_>0&&v<y;v++){const C=T+v*_;P.push({...this.assocVariant(C),variableHandle:this.refId(e.dwg_dynapi_subclass_data(C,"VALUEPARAM_vars","handle"))})}l.push({classVersion:g("class_version")??0,name:g("name")??"",unitType:g("unit_type")??0,values:P,controlledObjectDependencyHandle:this.refId(g("controlled_objdep"))})}return l}convertAssocAction(t,o){const e=this.libredwg,s=_=>e.dwg_dynapi_entity_data(t,_);return{...this.getCommonObjectAttrs(o),classVersion:s("class_version")??0,status:s("geometry_status")??0,owningNetworkHandle:this.refId(s("owningnetwork")),actionBodyHandle:this.refId(s("actionbody")),actionIndex:s("action_index")??0,maxDependencyIndex:s("max_assoc_dep_index")??0,dependencies:this.assocHandleRefs(s("deps"),s("num_deps")??0),ownedParamHandles:this.refIds(s("owned_params"),s("num_owned_params")??0),valueParams:this.assocValueParams(s("values"),s("num_values")??0)}}convertAssocNetwork(t,o){const e=this.libredwg,s=_=>e.dwg_dynapi_entity_data(t,_);return{...this.convertAssocAction(t,o),networkVersion:s("network_version")??0,maxActionIndex:s("network_action_index")??0,actions:this.assocHandleRefs(s("actions"),s("num_actions")??0),ownedActionHandles:this.refIds(s("owned_actions"),s("num_owned_actions")??0)}}convertAssocDependency(t,o){const e=this.libredwg,s=_=>e.dwg_dynapi_entity_data(t,_);return{...this.getCommonObjectAttrs(o),classVersion:s("class_version")??0,status:s("status")??0,isReadDependency:!!s("is_read_dep"),isWriteDependency:!!s("is_write_dep"),isAttachedToObject:!!s("is_attached_to_object"),isDelegatingToOwningAction:!!s("is_delegating_to_owning_action"),order:(s("order")??0)|0,name:s("has_name")?s("name")??"":"",dependentOnHandle:this.refId(s("dep_on")),prevDependencyHandle:this.refId(s("readdep")),nextDependencyHandle:this.refId(s("node")),dependencyBodyHandle:this.refId(s("dep_body")),dependencyIndex:(s("depbodyid")??0)|0}}convertAssocArrayActionBody(t,o){const e=this.libredwg,s=y=>e.dwg_dynapi_entity_data(t,y),_=y=>y?e.dwg_ptr_to_double_array(y,16):[],l=[],f=s("num_arrayitems")??0,h=s("arrayitems"),g=e.dwg_dynapi_subclass_size("ASSOCARRAYITEM");for(let y=0;h&&g>0&&y<f;y++){const T=h+y*g,P=(I,L=T)=>e.dwg_dynapi_subclass_data(L,"ASSOCARRAYITEM",I),v=P("flags")??0;let C;if(v&4)C=_(P("transmatrix"));else{const I=P("x_dir")??{x:0,y:0,z:0};C=[1,0,0,I.x,0,1,0,I.y,0,0,1,I.z,0,0,0,1]}const w=v&2?_(P("rel_transform")):void 0;l.push({...w?{relativeMatrix:w}:{},...v&16?{secondaryEntityHandle:this.refId(P("h2"))}:{},classVersion:P("class_version")??0,itemIndex:P("itemloc")??0,rowIndex:P("itemloc",T+4)??0,levelIndex:P("itemloc",T+8)??0,flags:v,matrix:C,entityHandle:this.refId(P("h1"))})}return{...this.getCommonObjectAttrs(o),actionBodyVersion:s("aab_version")??0,classVersion:s("aaab_version")??0,parametersClassName:s("paramblock")??"",parametersVersion:s("aap_version")??0,items:l,arrayTransform:_(s("transmatrix"))}}convertAssocActionParamBase(t,o){const e=this.libredwg,s=_=>e.dwg_dynapi_entity_data(t,_);return{...this.getCommonObjectAttrs(o),classVersion:s("is_r2013")??0,paramVersion:s("aap_version")??0,name:s("name")??"",singleDependencyVersion:s("asdap_class_version")??0,dependencyHandle:this.refId(s("dep"))}}convertAssocVertexActionParam(t,o){const e=this.libredwg;return{...this.convertAssocActionParamBase(t,o),vertexVersion:e.dwg_dynapi_entity_data(t,"class_version")??0,point:e.dwg_dynapi_entity_data(t,"pt")??{x:0,y:0,z:0}}}convertAssocEdgeActionParam(t,o){const e=this.libredwg,s=_=>e.dwg_dynapi_entity_data(t,_);return{...this.convertAssocActionParamBase(t,o),edgeVersion:s("class_version")??0,hasCachedCurve:!!s("has_action"),curveType:s("action_type")??0}}getCommonObjectAttrs(t){const o=this.libredwg,e=o.dwg_object_get_tio(t),s=o.dwg_object_object_get_ownerhandle_object(e),_=o.dwg_object_get_handle_object(t);return{handle:ft(_.value),ownerHandle:ft(s.absolute_ref)}}}class Pt{constructor(){nt(this,"min"),nt(this,"max"),nt(this,"valid"),this.min={x:1/0,y:1/0},this.max={x:-1/0,y:-1/0},this.valid=!1}expandByPoint(t){return this.min.x=Math.min(this.min.x,t.x),this.min.y=Math.min(this.min.y,t.y),this.max.x=Math.max(this.max.x,t.x),this.max.y=Math.max(this.max.y,t.y),this.valid=!0,this}transform(t,o){const e=this.getCorners().map(s=>({x:s.x*t.x+o.x,y:s.y*t.y+o.y}));this.reset();for(const s of e)this.expandByPoint(s);return this}rotate(t,o){const e=Math.cos(t),s=Math.sin(t),_=this.getCorners().map(l=>{const f=l.x-o.x,h=l.y-o.y;return{x:o.x+f*e-h*s,y:o.y+f*s+h*e}});this.reset();for(const l of _)this.expandByPoint(l);return this}clone(){const t=new Pt;return t.min={x:this.min.x,y:this.min.y},t.max={x:this.max.x,y:this.max.y},t.valid=this.valid,t}reset(){this.min={x:1/0,y:1/0},this.max={x:-1/0,y:-1/0},this.valid=!1}getCorners(){return[{x:this.min.x,y:this.min.y},{x:this.min.x,y:this.max.y},{x:this.max.x,y:this.min.y},{x:this.max.x,y:this.max.y}]}}function xo(r,t,o,e,s){const _=o.length;if(_===0)throw new Error("points must not be empty");const l=o[0].length;if(r<0||r>1)throw new Error(`t out of bounds [0,1]: ${r}`);if(t<1)throw new Error("degree must be at least 1 (linear)");if(t>_-1)throw new Error("degree must be less than or equal to point count - 1");const f=s??new Array(_).fill(1),h=e??(()=>{const w=[];for(let I=0;I<_+t+1;I++)w.push(I);return w})();if(h.length!==_+t+1)throw new Error("bad knot vector length");const g=[t,h.length-1-t],y=h[g[0]],T=h[g[1]];r=r*(T-y)+y,r=Math.max(r,y),r=Math.min(r,T);let P=g[0];for(;P<g[1]&&!(r>=h[P]&&r<=h[P+1]);P++);const v=new Array(_);for(let w=0;w<_;w++){v[w]=new Array(l+1);for(let I=0;I<l;I++)v[w][I]=o[w][I]*f[w];v[w][l]=f[w]}for(let w=1;w<=t+1;w++)for(let I=P;I>P-t-1+w;I--){const L=h[I+t+1-w]-h[I],W=L===0?0:(r-h[I])/L;for(let M=0;M<l+1;M++)v[I][M]=(1-W)*v[I-1][M]+W*v[I][M]}const C=new Array(l);for(let w=0;w<l;w++)C[w]=Oo(v[P][w]/v[P][l],-9);return C}function Oo(r,t){if(isNaN(r)||!Number.isInteger(t))return NaN;const[o,e="0"]=r.toString().split("e"),s=Math.round(+`${o}e${+e-t}`),[_,l="0"]=s.toString().split("e");return+`${_}e${+l+t}`}const ln={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},Dn=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215,0];function He(r,t,o){return Math.max(t,Math.min(o,r))}const Ar=class yr{constructor(){nt(this,"_colorIndex"),nt(this,"_color"),nt(this,"_colorName"),this._colorIndex=256,this._color=null,this._colorName=null}get color(){return this._color}set color(t){t==null?this._color=null:(this._color=Math.round(He(t,0,256*256*256-1)),this._colorIndex=this.getColorIndexByValue(this._color),this._colorName=this.getColorNameByValue(this._color))}get hexColor(){if(this._color&&this._color>0&&this._color<=16777215){let t=this._color.toString(16).toUpperCase();for(;t.length<6;)t="0"+t;return`0x${t}`}return""}get cssColor(){return`rgb(${this.red},${this.green},${this.blue})`}get red(){return this.color!=null?this.color>>16&255:null}get green(){return this.color!=null?this.color>>8&255:null}get blue(){return this.color!=null?this.color&255:null}get colorIndex(){return this._colorIndex}set colorIndex(t){t==null?this._colorIndex=null:(this._colorIndex=He(t,0,256),this._color=Dn[t],this._colorName=this.getColorNameByValue(this._color))}get colorName(){return this._colorName}set colorName(t){if(t){const o=ln[t.toLowerCase()];o!==void 0&&(this._colorName=t,this._color=o,this._colorIndex=this.getColorIndexByValue(this._color))}else this._colorName=null}get hasColorName(){return this._colorName==null}get hasColorIndex(){return this._colorIndex==null}get isByLayer(){return this.colorIndex==256}setByLayer(){return this.colorIndex=256,this}get isByBlock(){return this.colorIndex==0}setByBlock(){return this.colorIndex=0,this}setScalar(t){return this.setRGB(t,t,t),this}setRGB(t,o,e){const s=Math.round(He(t,0,255)),_=Math.round(He(o,0,255)),l=Math.round(He(e,0,255));return this.color=(s<<16)+(_<<8)+l,this}setColorName(t){const o=ln[t.toLowerCase()];return o!==void 0&&(this.color=o),this}clone(){const t=new yr;return t.colorIndex=this.colorIndex,t.color=this.color,t._colorName=this._colorName,this}copy(t){return this.colorIndex=t.colorIndex,this.color=t.color,this._colorName=t._colorName,this}equals(t){return t.color==this.color&&t.colorIndex==this.colorIndex&&t._colorName==this._colorName}toString(){return this.isByLayer?"ByLayer":this.isByBlock?"ByBlock":this.colorName?this.colorName:this.hexColor}getColorNameByValue(t){for(const[o,e]of Object.entries(ln))if(e===t)return o;return null}getColorIndexByValue(t){const o=Dn.length-1;for(let e=1;e<o;++e)if(Dn[e]===t)return e;return null}};nt(Ar,"NAMES",ln);let ko=Ar;class It{constructor(t,o){nt(this,"x"),nt(this,"y"),this.x=t,this.y=o}add(t){return new It(this.x+t.x,this.y+t.y)}sub(t){return new It(this.x-t.x,this.y-t.y)}multiply(t){return new It(this.x*t,this.y*t)}length(){return Math.sqrt(this.x**2+this.y**2)}norm(){const t=this.length();return t===0?new It(0,0):new It(this.x/t,this.y/t)}}function Bo(r,t,o,e=5){let s,_,l;o<0?(s=Math.atan(-o)*4,_=new It(r.x,r.y),l=new It(t.x,t.y)):(s=Math.atan(o)*4,_=new It(t.x,t.y),l=new It(r.x,r.y));const f=l.sub(_),h=f.length(),g=_.add(f.multiply(.5)),y=Math.abs(h/2/Math.tan(s/2)),T=f.norm(),P=new It(T.x*Math.cos(Math.PI/2)-T.y*Math.sin(Math.PI/2),T.y*Math.cos(Math.PI/2)+T.x*Math.sin(Math.PI/2)),v=s<Math.PI?g.add(P.multiply(-y)):g.add(P.multiply(y)),C=Math.atan2(l.y-v.y,l.x-v.x)/Math.PI*180;let w=Math.atan2(_.y-v.y,_.x-v.x)/Math.PI*180;w<C&&(w+=360);const I=l.sub(v).length(),L=Math.floor(C/e)*e+e,W=Math.ceil(w/e)*e-e,M=[];for(let b=L;b<=W;b+=e){const O=b/180*Math.PI,$=v.add(new It(Math.cos(O)*I,Math.sin(O)*I));M.push($)}return o<0&&M.reverse(),M}function Fo(r,t=!1){let o=[];const e=r.vertices.map(s=>({x:s.x,y:s.y,bulge:s.bulge}));t&&e.push(e[0]);for(let s=0,_=e.length;s<_-1;++s){const l=e[s],f=e[s+1];o.push(l),e[s].bulge&&(o=o.concat(Bo(l,f,r.vertices[s].bulge))),s===_-2&&o.push(f)}return o}class Uo{constructor(){nt(this,"blockMap",new Map)}rotate(t,o){const e=Math.cos(o),s=Math.sin(o);return{x:t.x*e-t.y*s,y:t.x*s+t.y*e}}interpolateBSpline(t,o,e,s=25,_){const l=[],f=t.map(y=>[y.x,y.y]),h=[e[o]],g=[e[o],e[e.length-1-o]];for(let y=o+1;y<e.length-o;++y)h[h.length-1]!==e[y]&&h.push(e[y]);for(let y=1;y<h.length;++y){const T=h[y-1],P=h[y];for(let v=0;v<=s;++v){let w=(v/s*(P-T)+T-g[0])/(g[1]-g[0]);w=Math.max(0,Math.min(1,w));const I=xo(w,o,f,e,_);l.push({x:I[0],y:I[1]})}}return l}addFlipXIfApplicable(t,{bbox:o,element:e}){return"extrusionDirection"in t&&t.extrusionDirection.z===-1?{bbox:new Pt().expandByPoint({x:-o.min.x,y:o.min.y}).expandByPoint({x:-o.max.x,y:o.max.y}),element:`<g transform="matrix(-1 0 0 1 0 0)">${e}</g>`}:{bbox:o,element:e}}line(t){const o=new Pt().expandByPoint({x:t.startPoint.x,y:t.startPoint.y}).expandByPoint({x:t.endPoint.x,y:t.endPoint.y}),e=`<line x1="${t.startPoint.x}" y1="${t.startPoint.y}" x2="${t.endPoint.x}" y2="${t.endPoint.y}" />`;return{bbox:o,element:e}}ray(t){const e=t.firstPoint,s={x:e.x+t.unitDirection.x*1e4,y:e.y+t.unitDirection.y*1e4},_=new Pt().expandByPoint(e).expandByPoint(s),l=`<line x1="${e.x}" y1="${e.y}" x2="${s.x}" y2="${s.y}" />`;return{bbox:_,element:l}}xline(t){const e={x:t.firstPoint.x-t.unitDirection.x*1e4,y:t.firstPoint.y-t.unitDirection.y*1e4},s={x:t.firstPoint.x+t.unitDirection.x*1e4,y:t.firstPoint.y+t.unitDirection.y*1e4},_=new Pt().expandByPoint(e).expandByPoint(s),l=`<line x1="${e.x}" y1="${e.y}" x2="${s.x}" y2="${s.y}" />`;return{bbox:_,element:l}}extractMTextLines(t){return t.replace(/\\U\+([0-9A-Fa-f]{4})/g,(o,e)=>String.fromCharCode(parseInt(e,16))).replace(/\\P/g,`
|
|
11
|
+
`,new Function(G,D)}function jr(e,a,i,d,u,E){var A=a.length;A<2&&$("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var T=a[1]!==null&&i!==null,v=Vn(a),D=!a[0].isVoid,L=a[0],G=a[1],b=[e,$,d,u,An,L.fromWireType.bind(L),G==null?void 0:G.toWireType.bind(G)],Y=2;Y<A;++Y){var F=a[Y];b.push(F.toWireType.bind(F))}if(!v)for(var Y=2;Y<a.length;++Y)a[Y].destructorFunction!==null&&b.push(a[Y].destructorFunction);var rt=Qr(a,T,D,E)(...b);return qe(e,rt)}var ta=(e,a)=>{for(var i=[],d=0;d<e;d++)i.push(B[a+d*4>>>2>>>0]);return i},ea=e=>{e=e.trim();const a=e.indexOf("(");return a===-1?e:e.slice(0,a)};function na(e,a,i,d,u,E,A,T){e>>>=0,i>>>=0,d>>>=0,u>>>=0,E>>>=0;var v=ta(a,i);e=st(e),e=ea(e),u=fe(d,u,A),Be(e,function(){rn(`Cannot call ${e} due to unbound types`,v)},a-1),an([],v,D=>{var L=[D[0],null].concat(D.slice(1));return xn(e,jr(e,L,null,u,E,A),a-1),[]})}var ra=function(e,a,i,d,u){e>>>=0,a>>>=0,i>>>=0,a=st(a);const E=d===0;let A=v=>v;if(E){var T=32-8*i;A=v=>v<<T>>>T,u=A(u)}ot(e,{name:a,fromWireType:A,toWireType:(v,D)=>D,readValueFromPointer:Rt(a,i,d!==0),destructorFunction:null})};function aa(e,a,i){e>>>=0,i>>>=0;var d=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array],u=d[a];function E(A){var T=B[A>>>2>>>0],v=B[A+4>>>2>>>0];return new u(z.buffer,v,T)}i=st(i),ot(e,{name:i,fromWireType:E,readValueFromPointer:E},{ignoreDuplicateRegistrations:!0})}var oe=(e,a,i)=>de(e,lt,a,i);function oa(e,a){e>>>=0,a>>>=0,a=st(a),ot(e,{name:a,fromWireType(i){var d=B[i>>>2>>>0],u=i+4,E;return E=te(u,d,!0),ie(i),E},toWireType(i,d){d instanceof ArrayBuffer&&(d=new Uint8Array(d));var u,E=typeof d=="string";E||ArrayBuffer.isView(d)&&d.BYTES_PER_ELEMENT==1||$("Cannot pass non-string to std::string"),E?u=Nt(d):u=d.length;var A=sn(4+u+1),T=A+4;return B[A>>>2>>>0]=u,E?oe(d,T,u+1):lt.set(d,T>>>0),i!==null&&i.push(ie,A),A},readValueFromPointer:je,destructorFunction(i){ie(i)}})}var Hn=globalThis.TextDecoder?new TextDecoder("utf-16le"):void 0,ia=(e,a,i)=>{var d=e>>>1,u=pe(Tt,d,a/2,i);if(u-d>16&&Hn)return Hn.decode(Tt.subarray(d>>>0,u>>>0));for(var E="",A=d;A<u;++A){var T=Tt[A>>>0];E+=String.fromCharCode(T)}return E},sa=(e,a,i)=>{if(i??(i=2147483647),i<2)return 0;i-=2;for(var d=a,u=i<e.length*2?i/2:e.length,E=0;E<u;++E){var A=e.charCodeAt(E);dt[a>>>1>>>0]=A,a+=2}return dt[a>>>1>>>0]=0,a-d},_a=e=>e.length*2,da=(e,a,i)=>{for(var d="",u=e>>>2,E=0;!(E>=a/4);E++){var A=B[u+E>>>0];if(!A&&!i)break;d+=String.fromCodePoint(A)}return d},la=(e,a,i)=>{if(a>>>=0,i??(i=2147483647),i<4)return 0;for(var d=a,u=d+i-4,E=0;E<e.length;++E){var A=e.codePointAt(E);if(A>65535&&E++,k[a>>>2>>>0]=A,a+=4,a+4>u)break}return k[a>>>2>>>0]=0,a-d},ca=e=>{for(var a=0,i=0;i<e.length;++i){var d=e.codePointAt(i);d>65535&&i++,a+=4}return a};function ua(e,a,i){e>>>=0,a>>>=0,i>>>=0,i=st(i);var d,u,E;a===2?(d=ia,u=sa,E=_a):(d=da,u=la,E=ca),ot(e,{name:i,fromWireType:A=>{var T=B[A>>>2>>>0],v=d(A+4,T*a,!0);return ie(A),v},toWireType:(A,T)=>{typeof T!="string"&&$(`Cannot pass non-string to C++ string type ${i}`);var v=E(T),D=sn(4+v+a);return B[D>>>2>>>0]=v/a,u(T,D+4,v+a),A!==null&&A.push(ie,D),D},readValueFromPointer:je,destructorFunction(A){ie(A)}})}var Ea=function(e,a){e>>>=0,a>>>=0,a=st(a),ot(e,{isVoid:!0,name:a,fromWireType:()=>{},toWireType:(i,d)=>{}})},Pn=[],fa=e=>{var a=Pn.length;return Pn.push(e),a},ha=(e,a)=>{for(var i=new Array(e),d=0;d<e;++d)i[d]=$n(B[a+d*4>>>2>>>0],`parameter ${d}`);return i},ga=(e,a,i)=>{var d=[],u=e(d,i);return d.length&&(B[a>>>2>>>0]=ft.toHandle(d)),u},Aa={},pn=e=>{var a=Aa[e];return a===void 0?st(e):a},ya=function(e,a,i){a>>>=0;var d=8,[u,...E]=ha(e,a),A=u.toWireType.bind(u),T=E.map(Y=>Y.readValueFromPointer.bind(Y));e--;var v={toValue:ft.toValue},D=T.map((Y,F)=>{var H=`argFromPtr${F}`;return v[H]=Y,`${H}(args${F?"+"+F*d:""})`}),L;switch(i){case 0:L="toValue(handle)";break;case 2:L="new (toValue(handle))";break;case 3:L="";break;case 1:v.getStringOrSymbol=pn,L="toValue(handle)[getStringOrSymbol(methodName)]";break}L+=`(${D})`,u.isVoid||(v.toReturnWire=A,v.emval_returnValue=ga,L=`return emval_returnValue(toReturnWire, destructorsRef, ${L})`),L=`return function (handle, methodName, destructorsRef, args) {
|
|
12
|
+
${L}
|
|
13
|
+
}`;var G=new Function(Object.keys(v),L)(...Object.values(v)),b=`methodCaller<(${E.map(Y=>Y.name)}) => ${u.name}>`;return fa(qe(b,G))};function Ta(e){return e>>>=0,e?(e=pn(e),ft.toHandle(globalThis[e])):ft.toHandle(globalThis)}function Pa(e){e>>>=0,e>9&&(ae[e+1]+=1)}function pa(e,a,i,d,u){return e>>>=0,a>>>=0,i>>>=0,d>>>=0,u>>>=0,Pn[e](a,i,d,u)}function va(){return ft.toHandle([])}function Ia(e){return e>>>=0,ft.toHandle(pn(e))}function ma(){return ft.toHandle({})}function wa(e){e>>>=0;var a=ft.toValue(e);An(a),yn(e)}function Ca(e,a,i){e>>>=0,a>>>=0,i>>>=0,e=ft.toValue(e),a=ft.toValue(a),i=ft.toValue(i),e[a]=i}function Da(e,a){e=Te(e),a>>>=0;var i=new Date(e*1e3);k[a>>>2>>>0]=i.getUTCSeconds(),k[a+4>>>2>>>0]=i.getUTCMinutes(),k[a+8>>>2>>>0]=i.getUTCHours(),k[a+12>>>2>>>0]=i.getUTCDate(),k[a+16>>>2>>>0]=i.getUTCMonth(),k[a+20>>>2>>>0]=i.getUTCFullYear()-1900,k[a+24>>>2>>>0]=i.getUTCDay();var d=Date.UTC(i.getUTCFullYear(),0,1,0,0,0,0),u=(i.getTime()-d)/(1e3*60*60*24)|0;k[a+28>>>2>>>0]=u}var Ra=e=>e%4===0&&(e%100!==0||e%400===0),Sa=[0,31,60,91,121,152,182,213,244,274,305,335],La=[0,31,59,90,120,151,181,212,243,273,304,334],Ya=e=>{var a=Ra(e.getFullYear()),i=a?Sa:La,d=i[e.getMonth()]+e.getDate()-1;return d},Na=function(e){e>>>=0;var a=(()=>{var i=new Date(k[e+20>>>2>>>0]+1900,k[e+16>>>2>>>0],k[e+12>>>2>>>0],k[e+8>>>2>>>0],k[e+4>>>2>>>0],k[e>>>2>>>0],0);if(isNaN(i.getTime()))return-1;var d=k[e+32>>>2>>>0],u=i.getTimezoneOffset(),E=new Date(i.getFullYear(),0,1),A=new Date(i.getFullYear(),6,1).getTimezoneOffset(),T=E.getTimezoneOffset(),v=Math.min(T,A);if(d<0)k[e+32>>>2>>>0]=+(A!=T&&v==u);else if(d>0!=(v==u)){var D=Math.max(T,A),L=d>0?v:D;i.setTime(i.getTime()+(L-u)*6e4)}k[e+24>>>2>>>0]=i.getDay();var G=Ya(i)|0;return k[e+28>>>2>>>0]=G,k[e>>>2>>>0]=i.getSeconds(),k[e+4>>>2>>>0]=i.getMinutes(),k[e+8>>>2>>>0]=i.getHours(),k[e+12>>>2>>>0]=i.getDate(),k[e+16>>>2>>>0]=i.getMonth(),k[e+20>>>2>>>0]=i.getYear(),i.getTime()/1e3})();return BigInt(a)},Wa=function(e,a,i,d){e>>>=0,a>>>=0,i>>>=0,d>>>=0;var u=new Date().getFullYear(),E=new Date(u,0,1),A=new Date(u,6,1),T=E.getTimezoneOffset(),v=A.getTimezoneOffset(),D=Math.max(T,v);B[e>>>2>>>0]=D*60,k[a>>>2>>>0]=+(T!=v);var L=Y=>{var F=Y>=0?"-":"+",H=Math.abs(Y),rt=String(Math.floor(H/60)).padStart(2,"0"),at=String(H%60).padStart(2,"0");return`UTC${F}${rt}${at}`},G=L(T),b=L(v);v<T?(oe(G,i,17),oe(b,d,17)):(oe(G,d,17),oe(b,i,17))},Ga=()=>Date.now();function Ma(e){return e>>>=0,w(te(e))}var ba=()=>performance.now(),xa=()=>4294901760,Oa=(e,a)=>Math.ceil(e/a)*a,ka=e=>{var a=_n.buffer.byteLength,i=(e-a+65535)/65536|0;try{return _n.grow(i),U(),1}catch{}};function Ba(e){e>>>=0;var a=lt.length,i=xa();if(e>i)return!1;for(var d=1;d<=4;d*=2){var u=a*(1+.2/d);u=Math.min(u,e+100663296);var E=Math.min(i,Oa(Math.max(e,u),65536)),A=ka(E);if(A)return!0}return!1}var on={},Fa=()=>f,Fe=()=>{var u;if(!Fe.strings){var e=(((u=globalThis.navigator)==null?void 0:u.language)??"C").replace("-","_")+".UTF-8",a={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:e,_:Fa()};for(var i in on)on[i]===void 0?delete a[i]:a[i]=on[i];var d=[];for(var i in a)d.push(`${i}=${a[i]}`);Fe.strings=d}return Fe.strings};function Ua(e,a){e>>>=0,a>>>=0;var i=0,d=0;for(var u of Fe()){var E=a+i;B[e+d>>>2>>>0]=E,i+=oe(u,E,1/0)+1,d+=4}return 0}function $a(e,a){e>>>=0,a>>>=0;var i=Fe();B[e>>>2>>>0]=i.length;var d=0;for(var u of i)d+=Nt(u)+1;return B[a>>>2>>>0]=d,0}function Va(e){try{var a=Q.getStreamFromFD(e);return c.close(a),0}catch(i){if(typeof c>"u"||i.name!=="ErrnoError")throw i;return i.errno}}var Ha=(e,a,i,d)=>{for(var u=0,E=0;E<i;E++){var A=B[a>>>2>>>0],T=B[a+4>>>2>>>0];a+=8;var v=c.read(e,z,A,T,d);if(v<0)return-1;if(u+=v,v<T)break}return u};function Xa(e,a,i,d){a>>>=0,i>>>=0,d>>>=0;try{var u=Q.getStreamFromFD(e),E=Ha(u,a,i);return B[d>>>2>>>0]=E,0}catch(A){if(typeof c>"u"||A.name!=="ErrnoError")throw A;return A.errno}}function Ka(e,a,i,d){a=Te(a),d>>>=0;try{if(isNaN(a))return 22;var u=Q.getStreamFromFD(e);return c.llseek(u,a,i),tt[d>>>3>>>0]=BigInt(u.position),u.getdents&&a===0&&i===0&&(u.getdents=null),0}catch(E){if(typeof c>"u"||E.name!=="ErrnoError")throw E;return E.errno}}var za=(e,a,i,d)=>{for(var u=0,E=0;E<i;E++){var A=B[a>>>2>>>0],T=B[a+4>>>2>>>0];a+=8;var v=c.write(e,z,A,T,d);if(v<0)return-1;if(u+=v,v<T)break}return u};function Ja(e,a,i,d){a>>>=0,i>>>=0,d>>>=0;try{var u=Q.getStreamFromFD(e),E=za(u,a,i);return B[d>>>2>>>0]=E,0}catch(A){if(typeof c>"u"||A.name!=="ErrnoError")throw A;return A.errno}}function Za(e,a){return e>>>=0,a>>>=0,qt(lt.subarray(e>>>0,e+a>>>0))}var Xn=e=>{var a=o["_"+e];return a},qa=(e,a)=>{z.set(e,a>>>0)},Kn=e=>qn(e),Qa=e=>{var a=Nt(e)+1,i=Kn(a);return oe(e,i,a),i},zn=(e,a,i,d,u)=>{var E={string:F=>{var H=0;return F!=null&&F!==0&&(H=Qa(F)),H},array:F=>{var H=Kn(F.length);return qa(F,H),H}};function A(F){return a==="string"?te(F):a==="pointer"?F>>>0:a==="boolean"?!!F:F}var T=Xn(e),v=[],D=0;if(d)for(var L=0;L<d.length;L++){var G=E[i[L]];G?(D===0&&(D=Jt()),v[L]=G(d[L])):v[L]=d[L]}var b=T(...v);function Y(F){return D!==0&&V(D),A(F)}return b=Y(b),b},ja=(e,a,i,d)=>{var u=!i||i.every(A=>A==="number"||A==="boolean"),E=a!=="string";return E&&u&&!d?Xn(e):(...A)=>zn(e,a,i,A)},to=e=>{var a=Nt(e)+1,i=sn(a);return i&&oe(e,i,a),i};if(c.createPreloadedFile=Xe,c.preloadFile=Ee,c.staticInit(),wr(),kr(),o.noExitRuntime&&o.noExitRuntime,o.preloadPlugins&&(ue=o.preloadPlugins),o.print&&(C=o.print),o.printErr&&(w=o.printErr),o.wasmBinary&&(m=o.wasmBinary),o.arguments&&o.arguments,o.thisProgram&&(f=o.thisProgram),o.preInit)for(typeof o.preInit=="function"&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.shift()();o.ENV=on,o.ccall=zn,o.cwrap=ja,o.setValue=q,o.UTF8ToString=te,o.stringToNewUTF8=to,o.FS=c;var ie,sn,Jn,Zn,qn,Qn,_n,jn;function eo(e){o.__Znwm=e._Znwm,o.__ZdlPvm=e._ZdlPvm,ie=e.free,sn=e.malloc,e.realloc,e.calloc,Jn=e.__getTypeName,o._strndup=e.strndup,o.__ZdaPv=e._ZdaPv,o.__ZdaPvm=e._ZdaPvm,o.__ZdlPv=e._ZdlPv,o._emscripten_builtin_malloc=e.emscripten_builtin_malloc,o.__Znam=e._Znam,o.__ZnamSt11align_val_t=e._ZnamSt11align_val_t,o.__ZnwmSt11align_val_t=e._ZnwmSt11align_val_t,o.___libc_calloc=e.__libc_calloc,o.___libc_free=e.__libc_free,o.___libc_malloc=e.__libc_malloc,o.___libc_realloc=e.__libc_realloc,o._emscripten_builtin_calloc=e.emscripten_builtin_calloc,o._emscripten_builtin_free=e.emscripten_builtin_free,o._emscripten_builtin_realloc=e.emscripten_builtin_realloc,o._malloc_size=e.malloc_size,o._malloc_usable_size=e.malloc_usable_size,o._reallocf=e.reallocf,Zn=e._emscripten_stack_restore,qn=e._emscripten_stack_alloc,Qn=e.emscripten_stack_get_current,_n=e.memory,jn=e.__indirect_function_table}var tr={__cxa_throw:Ne,__syscall_fcntl64:cn,__syscall_fstat64:un,__syscall_ioctl:En,__syscall_lstat64:Ke,__syscall_newfstatat:Ge,__syscall_openat:K,__syscall_stat64:j,_abort_js:ee,_embind_register_bigint:Je,_embind_register_bool:fn,_embind_register_class:$r,_embind_register_class_property:Vr,_embind_register_emval:Xr,_embind_register_enum:zr,_embind_register_enum_value:Jr,_embind_register_float:qr,_embind_register_function:na,_embind_register_integer:ra,_embind_register_memory_view:aa,_embind_register_std_string:oa,_embind_register_std_wstring:ua,_embind_register_void:Ea,_emval_create_invoker:ya,_emval_decref:yn,_emval_get_global:Ta,_emval_incref:Pa,_emval_invoke:pa,_emval_new_array:va,_emval_new_cstring:Ia,_emval_new_object:ma,_emval_run_destructors:wa,_emval_set_property:Ca,_gmtime_js:Da,_mktime_js:Na,_tzset_js:Wa,emscripten_date_now:Ga,emscripten_err:Ma,emscripten_get_now:ba,emscripten_resize_heap:Ba,environ_get:Ua,environ_sizes_get:$a,fd_close:Va,fd_read:Xa,fd_seek:Ka,fd_write:Ja,random_get:Za};function no(e){e=Object.assign({},e);var a=u=>E=>u(E)>>>0,i=u=>(E,A)=>u(E,A)>>>0,d=u=>()=>u()>>>0;return e.malloc=a(e.malloc),e.realloc=i(e.realloc),e.calloc=i(e.calloc),e.__getTypeName=a(e.__getTypeName),e.emscripten_builtin_malloc=a(e.emscripten_builtin_malloc),e.emscripten_builtin_calloc=i(e.emscripten_builtin_calloc),e._emscripten_stack_alloc=a(e._emscripten_stack_alloc),e.emscripten_stack_get_current=d(e.emscripten_stack_get_current),e}function vn(){if(pt>0){Wt=vn;return}if(J(),pt>0){Wt=vn;return}function e(){var a;o.calledRun=!0,!S&&(nt(),W==null||W(o),(a=o.onRuntimeInitialized)==null||a.call(o),gt())}o.setStatus?(o.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>o.setStatus(""),1),e()},1)):e()}var he;return he=await Ot(),vn(),O?t=o:t=new Promise((e,a)=>{W=e,M=a}),t}var To=Object.defineProperty,Po=(r,t,o)=>t in r?To(r,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[t]=o,et=(r,t,o)=>Po(r,typeof t!="symbol"?t+"":t,o);const po=["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","euc-kr","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"],_r=r=>po[r];var ge=(r=>(r[r.TopLeft=1]="TopLeft",r[r.TopCenter=2]="TopCenter",r[r.TopRight=3]="TopRight",r[r.MiddleLeft=4]="MiddleLeft",r[r.MiddleCenter=5]="MiddleCenter",r[r.MiddleRight=6]="MiddleRight",r[r.BottomLeft=7]="BottomLeft",r[r.BottomCenter=8]="BottomCenter",r[r.BottomRight=9]="BottomRight",r))(ge||{}),Dn=(r=>(r[r.PatternFill=0]="PatternFill",r[r.SolidFill=1]="SolidFill",r))(Dn||{}),Rn=(r=>(r[r.NonAssociative=0]="NonAssociative",r[r.Associative=1]="Associative",r))(Rn||{}),yr=(r=>(r[r.Solid=0]="Solid",r[r.Gradient=1]="Gradient",r))(yr||{}),Sn=(r=>(r[r.TwoColor=0]="TwoColor",r[r.OneColor=1]="OneColor",r))(Sn||{}),$e=(r=>(r[r.Line=1]="Line",r[r.Circular=2]="Circular",r[r.Elliptic=3]="Elliptic",r[r.Spline=4]="Spline",r))($e||{}),Ln=(r=>(r[r.LEFT=0]="LEFT",r[r.CENTER=1]="CENTER",r[r.RIGHT=2]="RIGHT",r[r.ALIGNED=3]="ALIGNED",r[r.MIDDLE=4]="MIDDLE",r[r.FIT=5]="FIT",r))(Ln||{});const vo=Object.freeze(["ACADMAINTVER","ACADVER","ANGBASE","ANGDIR","ATTMODE","AUNITS","AUPREC","CECOLOR","CELTSCALE","CELTYPE","CELWEIGHT","CEPSNID","CEPSNTYPE","CHAMFERA","CHAMFERB","CHAMFERC","CHAMFERD","CLAYER","CMLJUST","CMLSCALE","CMLSTYLE","CSHADOW","DIMADEC","DIMALT","DIMALTD","DIMALTF","DIMALTRND","DIMALTTD","DIMALTTZ","DIMALTU","DIMALTZ","DIMAPOST","DIMASO","DIMASSOC","DIMASZ","DIMATFIT","DIMAUNIT","DIMAZIN","DIMBLK","DIMBLK1","DIMBLK2","DIMCEN","DIMCLRD","DIMCLRE","DIMCLRT","DIMDEC","DIMDLE","DIMDLI","DIMDSEP","DIMEXE","DIMEXO","DIMFAC","DIMGAP","DIMJUST","DIMLDRBLK","DIMLFAC","DIMLIM","DIMLUNIT","DIMLWD","DIMLWE","DIMPOST","DIMRND","DIMSAH","DIMSCALE","DIMSD1","DIMSD2","DIMSE1","DIMSE2","DIMSHO","DIMSOXD","DIMSTYLE","DIMTAD","DIMTDEC","DIMTFAC","DIMTIH","DIMTIX","DIMTM","DIMTMOVE","DIMTOFL","DIMTOH","DIMTOL","DIMTOLJ","DIMTP","DIMTSZ","DIMTVP","DIMTXSTY","DIMTXT","DIMTZIN","DIMUPT","DIMZIN","DISPSILH","DRAGVS","DWGCODEPAGE","ELEVATION","ENDCAPS","EXTMAX","EXTMIN","EXTNAMES","FILLETRAD","FILLMODE","FINGERPRINTGUID","HALOGAP","HANDSEED","HIDETEXT","HYPERLINKBASE","INDEXCTL","INSBASE","INSUNITS","INTERFERECOLOR","INTERFEREOBJVS","INTERFEREVPVS","INTERSECTIONCOLOR","INTERSECTIONDISPLAY","JOINSTYLE","LIMCHECK","LIMMAX","LIMMIN","LTSCALE","LUNITS","LUPREC","LWDISPLAY","MAXACTVP","MEASUREMENT","MENU","MIRRTEXT","OBSCOLOR","OBSLTYPE","ORTHOMODE","PDMODE","PDSIZE","PELEVATION","PEXTMAX","PEXTMIN","PINSBASE","PLIMCHECK","PLIMMAX","PLIMMIN","PLINEGEN","PLINEWID","PROJECTNAME","PROXYGRAPHICS","PSLTSCALE","PSTYLEMODE","PSVPSCALE","PUCSBASE","PUCSNAME","PUCSORG","PUCSORGBACK","PUCSORGBOTTOM","PUCSORGFRONT","PUCSORGLEFT","PUCSORGRIGHT","PUCSORGTOP","PUCSORTHOREF","PUCSORTHOVIEW","PUCSXDIR","PUCSYDIR","QTEXTMODE","REGENMODE","SHADEDGE","SHADEDIF","SHADOWPLANELOCATION","SKETCHINC","SKPOLY","SORTENTS","SPLINESEGS","SPLINETYPE","SURFTAB1","SURFTAB2","SURFTYPE","SURFU","SURFV","TDCREATE","TDINDWG","TDUCREATE","TDUPDATE","TDUSRTIMER","TDUUPDATE","TEXTSIZE","TEXTSTYLE","THICKNESS","TILEMODE","TRACEWID","TREEDEPTH","UCSBASE","UCSNAME","UCSORG","UCSORGBACK","UCSORGBOTTOM","UCSORGFRONT","UCSORGLEFT","UCSORGRIGHT","UCSORGTOP","UCSORTHOREF","UCSORTHOVIEW","UCSXDIR","UCSYDIR","UNITMODE","USERI1","USERI2","USERI3","USERI4","USERI5","USERR1","USERR2","USERR3","USERR4","USERR5","USRTIMER","VERSIONGUID","VISRETAIN","WORLDVIEW","XCLIPFRAME","XEDIT"]),Io=/\\U\+([0-9A-Fa-f]{4})/g;function dr(r){return!r||!r.includes("\\U+")?r:r.replace(Io,(t,o)=>String.fromCharCode(parseInt(o,16)))}const mo=[{type:"invalid",hdr:"INVALI",description:"No DWG",version:0},{type:"r1.1",hdr:"MC0.0",description:"MicroCAD Release 1.1",version:0},{type:"r1.2",hdr:"AC1.2",description:"AutoCAD Release 1.2",version:0},{type:"r1.3",hdr:"AC1.3",description:"AutoCAD Release 1.3",version:1},{type:"r1.4",hdr:"AC1.40",description:"AutoCAD Release 1.4",version:2},{type:"r2.0b",hdr:"AC1.50",description:"AutoCAD 2.0 beta",version:3},{type:"r2.0",hdr:"AC1.50",description:"AutoCAD Release 2.0",version:4},{type:"r2.10",hdr:"AC2.10",description:"AutoCAD Release 2.10",version:5},{type:"r2.21",hdr:"AC2.21",description:"AutoCAD Release 2.21",version:6},{type:"r2.22",hdr:"AC2.22",description:"AutoCAD Release 2.22",version:7},{type:"r2.4",hdr:"AC1001",description:"AutoCAD Release 2.4",version:8},{type:"r2.5",hdr:"AC1002",description:"AutoCAD Release 2.5",version:9},{type:"r2.6",hdr:"AC1003",description:"AutoCAD Release 2.6",version:10},{type:"r9",hdr:"AC1004",description:"AutoCAD Release 9",version:11},{type:"r9c1",hdr:"AC1005",description:"AutoCAD Release 9c1",version:12},{type:"r10",hdr:"AC1006",description:"AutoCAD Release 10",version:13},{type:"r11b1",hdr:"AC1007",description:"AutoCAD 11 beta 1",version:14},{type:"r11b2",hdr:"AC1008",description:"AutoCAD 11 beta 2",version:15},{type:"r11",hdr:"AC1009",description:"AutoCAD Release 11/12 (LT R1/R2)",version:16},{type:"r13b1",hdr:"AC1010",description:"AutoCAD pre-R13 a",version:17},{type:"r13b2",hdr:"AC1011",description:"AutoCAD pre-R13 b",version:18},{type:"r13",hdr:"AC1012",description:"AutoCAD Release 13",version:19},{type:"r13c3",hdr:"AC1013",description:"AutoCAD Release 13c3",version:20},{type:"r14",hdr:"AC1014",description:"AutoCAD Release 14",version:21},{type:"r2000b",hdr:"AC1500",description:"AutoCAD 2000 beta",version:22},{type:"r2000",hdr:"AC1015",description:"AutoCAD Release 2000",version:23},{type:"r2000i",hdr:"AC1016",description:"AutoCAD Release 2000i",version:23},{type:"r2002",hdr:"AC1017",description:"AutoCAD Release 2002",version:23},{type:"r2004a",hdr:"AC402a",description:"AutoCAD 2004 alpha a",version:24},{type:"r2004b",hdr:"AC402b",description:"AutoCAD 2004 alpha b",version:24},{type:"r2004c",hdr:"AC1018",description:"AutoCAD 2004 beta",version:24},{type:"r2004",hdr:"AC1018",description:"AutoCAD Release 2004",version:25},{type:"r2007a",hdr:"AC701a",description:"AutoCAD 2007 alpha",version:26},{type:"r2007b",hdr:"AC1021",description:"AutoCAD 2007 beta",version:26},{type:"r2007",hdr:"AC1021",description:"AutoCAD Release 2007",version:27},{type:"r2010b",hdr:"AC1024",description:"AutoCAD 2010 beta",version:28},{type:"r2010",hdr:"AC1024",description:"AutoCAD Release 2010",version:29},{type:"r2013b",hdr:"AC1027",description:"AutoCAD 2013 beta",version:30},{type:"r2013",hdr:"AC1027",description:"AutoCAD Release 2013",version:31},{type:"r2018b",hdr:"AC1032",description:"AutoCAD 2018 beta",version:32},{type:"r2018",hdr:"AC1032",description:"AutoCAD Release 2018",version:33},{type:"r2022b",hdr:"AC103-4",description:"AutoCAD 2022 beta",version:36},{type:"r>2022",hdr:"",description:"AutoCAD Release >2022",version:0}];var Yn=(r=>(r[r.DWG_SUPERTYPE_ENTITY=0]="DWG_SUPERTYPE_ENTITY",r[r.DWG_SUPERTYPE_OBJECT=1]="DWG_SUPERTYPE_OBJECT",r))(Yn||{}),Nn=(r=>(r[r.WRONGCRC=1]="WRONGCRC",r[r.NOTYETSUPPORTED=2]="NOTYETSUPPORTED",r[r.UNHANDLEDCLASS=4]="UNHANDLEDCLASS",r[r.INVALIDTYPE=8]="INVALIDTYPE",r[r.INVALIDHANDLE=16]="INVALIDHANDLE",r[r.INVALIDEED=32]="INVALIDEED",r[r.VALUEOUTOFBOUNDS=64]="VALUEOUTOFBOUNDS",r[r.CLASSESNOTFOUND=128]="CLASSESNOTFOUND",r[r.SECTIONNOTFOUND=256]="SECTIONNOTFOUND",r[r.PAGENOTFOUND=512]="PAGENOTFOUND",r[r.INTERNALERROR=1024]="INTERNALERROR",r[r.INVALIDDWG=2048]="INVALIDDWG",r[r.IOERROR=4096]="IOERROR",r[r.OUTOFMEM=8192]="OUTOFMEM",r))(Nn||{}),R=(r=>(r[r.DWG_TYPE_UNUSED=0]="DWG_TYPE_UNUSED",r[r.DWG_TYPE_TEXT=1]="DWG_TYPE_TEXT",r[r.DWG_TYPE_ATTRIB=2]="DWG_TYPE_ATTRIB",r[r.DWG_TYPE_ATTDEF=3]="DWG_TYPE_ATTDEF",r[r.DWG_TYPE_BLOCK=4]="DWG_TYPE_BLOCK",r[r.DWG_TYPE_ENDBLK=5]="DWG_TYPE_ENDBLK",r[r.DWG_TYPE_SEQEND=6]="DWG_TYPE_SEQEND",r[r.DWG_TYPE_INSERT=7]="DWG_TYPE_INSERT",r[r.DWG_TYPE_MINSERT=8]="DWG_TYPE_MINSERT",r[r.DWG_TYPE_VERTEX_2D=10]="DWG_TYPE_VERTEX_2D",r[r.DWG_TYPE_VERTEX_3D=11]="DWG_TYPE_VERTEX_3D",r[r.DWG_TYPE_VERTEX_MESH=12]="DWG_TYPE_VERTEX_MESH",r[r.DWG_TYPE_VERTEX_PFACE=13]="DWG_TYPE_VERTEX_PFACE",r[r.DWG_TYPE_VERTEX_PFACE_FACE=14]="DWG_TYPE_VERTEX_PFACE_FACE",r[r.DWG_TYPE_POLYLINE_2D=15]="DWG_TYPE_POLYLINE_2D",r[r.DWG_TYPE_POLYLINE_3D=16]="DWG_TYPE_POLYLINE_3D",r[r.DWG_TYPE_ARC=17]="DWG_TYPE_ARC",r[r.DWG_TYPE_CIRCLE=18]="DWG_TYPE_CIRCLE",r[r.DWG_TYPE_LINE=19]="DWG_TYPE_LINE",r[r.DWG_TYPE_DIMENSION_ORDINATE=20]="DWG_TYPE_DIMENSION_ORDINATE",r[r.DWG_TYPE_DIMENSION_LINEAR=21]="DWG_TYPE_DIMENSION_LINEAR",r[r.DWG_TYPE_DIMENSION_ALIGNED=22]="DWG_TYPE_DIMENSION_ALIGNED",r[r.DWG_TYPE_DIMENSION_ANG3PT=23]="DWG_TYPE_DIMENSION_ANG3PT",r[r.DWG_TYPE_DIMENSION_ANG2LN=24]="DWG_TYPE_DIMENSION_ANG2LN",r[r.DWG_TYPE_DIMENSION_RADIUS=25]="DWG_TYPE_DIMENSION_RADIUS",r[r.DWG_TYPE_DIMENSION_DIAMETER=26]="DWG_TYPE_DIMENSION_DIAMETER",r[r.DWG_TYPE_POINT=27]="DWG_TYPE_POINT",r[r.DWG_TYPE_3DFACE=28]="DWG_TYPE_3DFACE",r[r.DWG_TYPE_POLYLINE_PFACE=29]="DWG_TYPE_POLYLINE_PFACE",r[r.DWG_TYPE_POLYLINE_MESH=30]="DWG_TYPE_POLYLINE_MESH",r[r.DWG_TYPE_SOLID=31]="DWG_TYPE_SOLID",r[r.DWG_TYPE_TRACE=32]="DWG_TYPE_TRACE",r[r.DWG_TYPE_SHAPE=33]="DWG_TYPE_SHAPE",r[r.DWG_TYPE_VIEWPORT=34]="DWG_TYPE_VIEWPORT",r[r.DWG_TYPE_ELLIPSE=35]="DWG_TYPE_ELLIPSE",r[r.DWG_TYPE_SPLINE=36]="DWG_TYPE_SPLINE",r[r.DWG_TYPE_REGION=37]="DWG_TYPE_REGION",r[r.DWG_TYPE_3DSOLID=38]="DWG_TYPE_3DSOLID",r[r.DWG_TYPE_BODY=39]="DWG_TYPE_BODY",r[r.DWG_TYPE_RAY=40]="DWG_TYPE_RAY",r[r.DWG_TYPE_XLINE=41]="DWG_TYPE_XLINE",r[r.DWG_TYPE_DICTIONARY=42]="DWG_TYPE_DICTIONARY",r[r.DWG_TYPE_OLEFRAME=43]="DWG_TYPE_OLEFRAME",r[r.DWG_TYPE_MTEXT=44]="DWG_TYPE_MTEXT",r[r.DWG_TYPE_LEADER=45]="DWG_TYPE_LEADER",r[r.DWG_TYPE_TOLERANCE=46]="DWG_TYPE_TOLERANCE",r[r.DWG_TYPE_MLINE=47]="DWG_TYPE_MLINE",r[r.DWG_TYPE_BLOCK_CONTROL=48]="DWG_TYPE_BLOCK_CONTROL",r[r.DWG_TYPE_BLOCK_HEADER=49]="DWG_TYPE_BLOCK_HEADER",r[r.DWG_TYPE_LAYER_CONTROL=50]="DWG_TYPE_LAYER_CONTROL",r[r.DWG_TYPE_LAYER=51]="DWG_TYPE_LAYER",r[r.DWG_TYPE_STYLE_CONTROL=52]="DWG_TYPE_STYLE_CONTROL",r[r.DWG_TYPE_STYLE=53]="DWG_TYPE_STYLE",r[r.DWG_TYPE_LTYPE_CONTROL=56]="DWG_TYPE_LTYPE_CONTROL",r[r.DWG_TYPE_LTYPE=57]="DWG_TYPE_LTYPE",r[r.DWG_TYPE_VIEW_CONTROL=60]="DWG_TYPE_VIEW_CONTROL",r[r.DWG_TYPE_VIEW=61]="DWG_TYPE_VIEW",r[r.DWG_TYPE_UCS_CONTROL=62]="DWG_TYPE_UCS_CONTROL",r[r.DWG_TYPE_UCS=63]="DWG_TYPE_UCS",r[r.DWG_TYPE_VPORT_CONTROL=64]="DWG_TYPE_VPORT_CONTROL",r[r.DWG_TYPE_VPORT=65]="DWG_TYPE_VPORT",r[r.DWG_TYPE_APPID_CONTROL=66]="DWG_TYPE_APPID_CONTROL",r[r.DWG_TYPE_APPID=67]="DWG_TYPE_APPID",r[r.DWG_TYPE_DIMSTYLE_CONTROL=68]="DWG_TYPE_DIMSTYLE_CONTROL",r[r.DWG_TYPE_DIMSTYLE=69]="DWG_TYPE_DIMSTYLE",r[r.DWG_TYPE_VX_CONTROL=70]="DWG_TYPE_VX_CONTROL",r[r.DWG_TYPE_VX_TABLE_RECORD=71]="DWG_TYPE_VX_TABLE_RECORD",r[r.DWG_TYPE_GROUP=72]="DWG_TYPE_GROUP",r[r.DWG_TYPE_MLINESTYLE=73]="DWG_TYPE_MLINESTYLE",r[r.DWG_TYPE_OLE2FRAME=74]="DWG_TYPE_OLE2FRAME",r[r.DWG_TYPE_DUMMY=75]="DWG_TYPE_DUMMY",r[r.DWG_TYPE_LONG_TRANSACTION=76]="DWG_TYPE_LONG_TRANSACTION",r[r.DWG_TYPE_LWPOLYLINE=77]="DWG_TYPE_LWPOLYLINE",r[r.DWG_TYPE_HATCH=78]="DWG_TYPE_HATCH",r[r.DWG_TYPE_XRECORD=79]="DWG_TYPE_XRECORD",r[r.DWG_TYPE_PLACEHOLDER=80]="DWG_TYPE_PLACEHOLDER",r[r.DWG_TYPE_VBA_PROJECT=81]="DWG_TYPE_VBA_PROJECT",r[r.DWG_TYPE_LAYOUT=82]="DWG_TYPE_LAYOUT",r[r.DWG_TYPE_PROXY_ENTITY=498]="DWG_TYPE_PROXY_ENTITY",r[r.DWG_TYPE_PROXY_OBJECT=499]="DWG_TYPE_PROXY_OBJECT",r[r.DWG_TYPE_ACDSRECORD=500]="DWG_TYPE_ACDSRECORD",r[r.DWG_TYPE_ACDSSCHEMA=501]="DWG_TYPE_ACDSSCHEMA",r[r.DWG_TYPE_ACIDBLOCKREFERENCE=502]="DWG_TYPE_ACIDBLOCKREFERENCE",r[r.DWG_TYPE_ACMECOMMANDHISTORY=503]="DWG_TYPE_ACMECOMMANDHISTORY",r[r.DWG_TYPE_ACMESCOPE=504]="DWG_TYPE_ACMESCOPE",r[r.DWG_TYPE_ACMESTATEMGR=505]="DWG_TYPE_ACMESTATEMGR",r[r.DWG_TYPE_ACSH_BOOLEAN_CLASS=506]="DWG_TYPE_ACSH_BOOLEAN_CLASS",r[r.DWG_TYPE_ACSH_BOX_CLASS=507]="DWG_TYPE_ACSH_BOX_CLASS",r[r.DWG_TYPE_ACSH_BREP_CLASS=508]="DWG_TYPE_ACSH_BREP_CLASS",r[r.DWG_TYPE_ACSH_CHAMFER_CLASS=509]="DWG_TYPE_ACSH_CHAMFER_CLASS",r[r.DWG_TYPE_ACSH_CONE_CLASS=510]="DWG_TYPE_ACSH_CONE_CLASS",r[r.DWG_TYPE_ACSH_CYLINDER_CLASS=511]="DWG_TYPE_ACSH_CYLINDER_CLASS",r[r.DWG_TYPE_ACSH_EXTRUSION_CLASS=512]="DWG_TYPE_ACSH_EXTRUSION_CLASS",r[r.DWG_TYPE_ACSH_FILLET_CLASS=513]="DWG_TYPE_ACSH_FILLET_CLASS",r[r.DWG_TYPE_ACSH_HISTORY_CLASS=514]="DWG_TYPE_ACSH_HISTORY_CLASS",r[r.DWG_TYPE_ACSH_LOFT_CLASS=515]="DWG_TYPE_ACSH_LOFT_CLASS",r[r.DWG_TYPE_ACSH_PYRAMID_CLASS=516]="DWG_TYPE_ACSH_PYRAMID_CLASS",r[r.DWG_TYPE_ACSH_REVOLVE_CLASS=517]="DWG_TYPE_ACSH_REVOLVE_CLASS",r[r.DWG_TYPE_ACSH_SPHERE_CLASS=518]="DWG_TYPE_ACSH_SPHERE_CLASS",r[r.DWG_TYPE_ACSH_SWEEP_CLASS=519]="DWG_TYPE_ACSH_SWEEP_CLASS",r[r.DWG_TYPE_ACSH_TORUS_CLASS=520]="DWG_TYPE_ACSH_TORUS_CLASS",r[r.DWG_TYPE_ACSH_WEDGE_CLASS=521]="DWG_TYPE_ACSH_WEDGE_CLASS",r[r.DWG_TYPE_ALDIMOBJECTCONTEXTDATA=522]="DWG_TYPE_ALDIMOBJECTCONTEXTDATA",r[r.DWG_TYPE_ALIGNMENTPARAMETERENTITY=523]="DWG_TYPE_ALIGNMENTPARAMETERENTITY",r[r.DWG_TYPE_ANGDIMOBJECTCONTEXTDATA=524]="DWG_TYPE_ANGDIMOBJECTCONTEXTDATA",r[r.DWG_TYPE_ANNOTSCALEOBJECTCONTEXTDATA=525]="DWG_TYPE_ANNOTSCALEOBJECTCONTEXTDATA",r[r.DWG_TYPE_ARCALIGNEDTEXT=526]="DWG_TYPE_ARCALIGNEDTEXT",r[r.DWG_TYPE_ARC_DIMENSION=527]="DWG_TYPE_ARC_DIMENSION",r[r.DWG_TYPE_ASSOC2DCONSTRAINTGROUP=528]="DWG_TYPE_ASSOC2DCONSTRAINTGROUP",r[r.DWG_TYPE_ASSOC3POINTANGULARDIMACTIONBODY=529]="DWG_TYPE_ASSOC3POINTANGULARDIMACTIONBODY",r[r.DWG_TYPE_ASSOCACTION=530]="DWG_TYPE_ASSOCACTION",r[r.DWG_TYPE_ASSOCACTIONPARAM=531]="DWG_TYPE_ASSOCACTIONPARAM",r[r.DWG_TYPE_ASSOCALIGNEDDIMACTIONBODY=532]="DWG_TYPE_ASSOCALIGNEDDIMACTIONBODY",r[r.DWG_TYPE_ASSOCARRAYACTIONBODY=533]="DWG_TYPE_ASSOCARRAYACTIONBODY",r[r.DWG_TYPE_ASSOCARRAYMODIFYACTIONBODY=534]="DWG_TYPE_ASSOCARRAYMODIFYACTIONBODY",r[r.DWG_TYPE_ASSOCARRAYMODIFYPARAMETERS=535]="DWG_TYPE_ASSOCARRAYMODIFYPARAMETERS",r[r.DWG_TYPE_ASSOCARRAYPATHPARAMETERS=536]="DWG_TYPE_ASSOCARRAYPATHPARAMETERS",r[r.DWG_TYPE_ASSOCARRAYPOLARPARAMETERS=537]="DWG_TYPE_ASSOCARRAYPOLARPARAMETERS",r[r.DWG_TYPE_ASSOCARRAYRECTANGULARPARAMETERS=538]="DWG_TYPE_ASSOCARRAYRECTANGULARPARAMETERS",r[r.DWG_TYPE_ASSOCASMBODYACTIONPARAM=539]="DWG_TYPE_ASSOCASMBODYACTIONPARAM",r[r.DWG_TYPE_ASSOCBLENDSURFACEACTIONBODY=540]="DWG_TYPE_ASSOCBLENDSURFACEACTIONBODY",r[r.DWG_TYPE_ASSOCCOMPOUNDACTIONPARAM=541]="DWG_TYPE_ASSOCCOMPOUNDACTIONPARAM",r[r.DWG_TYPE_ASSOCDEPENDENCY=542]="DWG_TYPE_ASSOCDEPENDENCY",r[r.DWG_TYPE_ASSOCDIMDEPENDENCYBODY=543]="DWG_TYPE_ASSOCDIMDEPENDENCYBODY",r[r.DWG_TYPE_ASSOCEDGEACTIONPARAM=544]="DWG_TYPE_ASSOCEDGEACTIONPARAM",r[r.DWG_TYPE_ASSOCEDGECHAMFERACTIONBODY=545]="DWG_TYPE_ASSOCEDGECHAMFERACTIONBODY",r[r.DWG_TYPE_ASSOCEDGEFILLETACTIONBODY=546]="DWG_TYPE_ASSOCEDGEFILLETACTIONBODY",r[r.DWG_TYPE_ASSOCEXTENDSURFACEACTIONBODY=547]="DWG_TYPE_ASSOCEXTENDSURFACEACTIONBODY",r[r.DWG_TYPE_ASSOCEXTRUDEDSURFACEACTIONBODY=548]="DWG_TYPE_ASSOCEXTRUDEDSURFACEACTIONBODY",r[r.DWG_TYPE_ASSOCFACEACTIONPARAM=549]="DWG_TYPE_ASSOCFACEACTIONPARAM",r[r.DWG_TYPE_ASSOCFILLETSURFACEACTIONBODY=550]="DWG_TYPE_ASSOCFILLETSURFACEACTIONBODY",r[r.DWG_TYPE_ASSOCGEOMDEPENDENCY=551]="DWG_TYPE_ASSOCGEOMDEPENDENCY",r[r.DWG_TYPE_ASSOCLOFTEDSURFACEACTIONBODY=552]="DWG_TYPE_ASSOCLOFTEDSURFACEACTIONBODY",r[r.DWG_TYPE_ASSOCMLEADERACTIONBODY=553]="DWG_TYPE_ASSOCMLEADERACTIONBODY",r[r.DWG_TYPE_ASSOCNETWORK=554]="DWG_TYPE_ASSOCNETWORK",r[r.DWG_TYPE_ASSOCNETWORKSURFACEACTIONBODY=555]="DWG_TYPE_ASSOCNETWORKSURFACEACTIONBODY",r[r.DWG_TYPE_ASSOCOBJECTACTIONPARAM=556]="DWG_TYPE_ASSOCOBJECTACTIONPARAM",r[r.DWG_TYPE_ASSOCOFFSETSURFACEACTIONBODY=557]="DWG_TYPE_ASSOCOFFSETSURFACEACTIONBODY",r[r.DWG_TYPE_ASSOCORDINATEDIMACTIONBODY=558]="DWG_TYPE_ASSOCORDINATEDIMACTIONBODY",r[r.DWG_TYPE_ASSOCOSNAPPOINTREFACTIONPARAM=559]="DWG_TYPE_ASSOCOSNAPPOINTREFACTIONPARAM",r[r.DWG_TYPE_ASSOCPATCHSURFACEACTIONBODY=560]="DWG_TYPE_ASSOCPATCHSURFACEACTIONBODY",r[r.DWG_TYPE_ASSOCPATHACTIONPARAM=561]="DWG_TYPE_ASSOCPATHACTIONPARAM",r[r.DWG_TYPE_ASSOCPERSSUBENTMANAGER=562]="DWG_TYPE_ASSOCPERSSUBENTMANAGER",r[r.DWG_TYPE_ASSOCPLANESURFACEACTIONBODY=563]="DWG_TYPE_ASSOCPLANESURFACEACTIONBODY",r[r.DWG_TYPE_ASSOCPOINTREFACTIONPARAM=564]="DWG_TYPE_ASSOCPOINTREFACTIONPARAM",r[r.DWG_TYPE_ASSOCRESTOREENTITYSTATEACTIONBODY=565]="DWG_TYPE_ASSOCRESTOREENTITYSTATEACTIONBODY",r[r.DWG_TYPE_ASSOCREVOLVEDSURFACEACTIONBODY=566]="DWG_TYPE_ASSOCREVOLVEDSURFACEACTIONBODY",r[r.DWG_TYPE_ASSOCROTATEDDIMACTIONBODY=567]="DWG_TYPE_ASSOCROTATEDDIMACTIONBODY",r[r.DWG_TYPE_ASSOCSWEPTSURFACEACTIONBODY=568]="DWG_TYPE_ASSOCSWEPTSURFACEACTIONBODY",r[r.DWG_TYPE_ASSOCTRIMSURFACEACTIONBODY=569]="DWG_TYPE_ASSOCTRIMSURFACEACTIONBODY",r[r.DWG_TYPE_ASSOCVALUEDEPENDENCY=570]="DWG_TYPE_ASSOCVALUEDEPENDENCY",r[r.DWG_TYPE_ASSOCVARIABLE=571]="DWG_TYPE_ASSOCVARIABLE",r[r.DWG_TYPE_ASSOCVERTEXACTIONPARAM=572]="DWG_TYPE_ASSOCVERTEXACTIONPARAM",r[r.DWG_TYPE_BASEPOINTPARAMETERENTITY=573]="DWG_TYPE_BASEPOINTPARAMETERENTITY",r[r.DWG_TYPE_BLKREFOBJECTCONTEXTDATA=574]="DWG_TYPE_BLKREFOBJECTCONTEXTDATA",r[r.DWG_TYPE_BLOCKALIGNEDCONSTRAINTPARAMETER=575]="DWG_TYPE_BLOCKALIGNEDCONSTRAINTPARAMETER",r[r.DWG_TYPE_BLOCKALIGNMENTGRIP=576]="DWG_TYPE_BLOCKALIGNMENTGRIP",r[r.DWG_TYPE_BLOCKALIGNMENTPARAMETER=577]="DWG_TYPE_BLOCKALIGNMENTPARAMETER",r[r.DWG_TYPE_BLOCKANGULARCONSTRAINTPARAMETER=578]="DWG_TYPE_BLOCKANGULARCONSTRAINTPARAMETER",r[r.DWG_TYPE_BLOCKARRAYACTION=579]="DWG_TYPE_BLOCKARRAYACTION",r[r.DWG_TYPE_BLOCKBASEPOINTPARAMETER=580]="DWG_TYPE_BLOCKBASEPOINTPARAMETER",r[r.DWG_TYPE_BLOCKDIAMETRICCONSTRAINTPARAMETER=581]="DWG_TYPE_BLOCKDIAMETRICCONSTRAINTPARAMETER",r[r.DWG_TYPE_BLOCKFLIPACTION=582]="DWG_TYPE_BLOCKFLIPACTION",r[r.DWG_TYPE_BLOCKFLIPGRIP=583]="DWG_TYPE_BLOCKFLIPGRIP",r[r.DWG_TYPE_BLOCKFLIPPARAMETER=584]="DWG_TYPE_BLOCKFLIPPARAMETER",r[r.DWG_TYPE_BLOCKGRIPLOCATIONCOMPONENT=585]="DWG_TYPE_BLOCKGRIPLOCATIONCOMPONENT",r[r.DWG_TYPE_BLOCKHORIZONTALCONSTRAINTPARAMETER=586]="DWG_TYPE_BLOCKHORIZONTALCONSTRAINTPARAMETER",r[r.DWG_TYPE_BLOCKLINEARCONSTRAINTPARAMETER=587]="DWG_TYPE_BLOCKLINEARCONSTRAINTPARAMETER",r[r.DWG_TYPE_BLOCKLINEARGRIP=588]="DWG_TYPE_BLOCKLINEARGRIP",r[r.DWG_TYPE_BLOCKLINEARPARAMETER=589]="DWG_TYPE_BLOCKLINEARPARAMETER",r[r.DWG_TYPE_BLOCKLOOKUPACTION=590]="DWG_TYPE_BLOCKLOOKUPACTION",r[r.DWG_TYPE_BLOCKLOOKUPGRIP=591]="DWG_TYPE_BLOCKLOOKUPGRIP",r[r.DWG_TYPE_BLOCKLOOKUPPARAMETER=592]="DWG_TYPE_BLOCKLOOKUPPARAMETER",r[r.DWG_TYPE_BLOCKMOVEACTION=593]="DWG_TYPE_BLOCKMOVEACTION",r[r.DWG_TYPE_BLOCKPARAMDEPENDENCYBODY=594]="DWG_TYPE_BLOCKPARAMDEPENDENCYBODY",r[r.DWG_TYPE_BLOCKPOINTPARAMETER=595]="DWG_TYPE_BLOCKPOINTPARAMETER",r[r.DWG_TYPE_BLOCKPOLARGRIP=596]="DWG_TYPE_BLOCKPOLARGRIP",r[r.DWG_TYPE_BLOCKPOLARPARAMETER=597]="DWG_TYPE_BLOCKPOLARPARAMETER",r[r.DWG_TYPE_BLOCKPOLARSTRETCHACTION=598]="DWG_TYPE_BLOCKPOLARSTRETCHACTION",r[r.DWG_TYPE_BLOCKPROPERTIESTABLE=599]="DWG_TYPE_BLOCKPROPERTIESTABLE",r[r.DWG_TYPE_BLOCKPROPERTIESTABLEGRIP=600]="DWG_TYPE_BLOCKPROPERTIESTABLEGRIP",r[r.DWG_TYPE_BLOCKRADIALCONSTRAINTPARAMETER=601]="DWG_TYPE_BLOCKRADIALCONSTRAINTPARAMETER",r[r.DWG_TYPE_BLOCKREPRESENTATION=602]="DWG_TYPE_BLOCKREPRESENTATION",r[r.DWG_TYPE_BLOCKROTATEACTION=603]="DWG_TYPE_BLOCKROTATEACTION",r[r.DWG_TYPE_BLOCKROTATIONGRIP=604]="DWG_TYPE_BLOCKROTATIONGRIP",r[r.DWG_TYPE_BLOCKROTATIONPARAMETER=605]="DWG_TYPE_BLOCKROTATIONPARAMETER",r[r.DWG_TYPE_BLOCKSCALEACTION=606]="DWG_TYPE_BLOCKSCALEACTION",r[r.DWG_TYPE_BLOCKSTRETCHACTION=607]="DWG_TYPE_BLOCKSTRETCHACTION",r[r.DWG_TYPE_BLOCKUSERPARAMETER=608]="DWG_TYPE_BLOCKUSERPARAMETER",r[r.DWG_TYPE_BLOCKVERTICALCONSTRAINTPARAMETER=609]="DWG_TYPE_BLOCKVERTICALCONSTRAINTPARAMETER",r[r.DWG_TYPE_BLOCKVISIBILITYGRIP=610]="DWG_TYPE_BLOCKVISIBILITYGRIP",r[r.DWG_TYPE_BLOCKVISIBILITYPARAMETER=611]="DWG_TYPE_BLOCKVISIBILITYPARAMETER",r[r.DWG_TYPE_BLOCKXYGRIP=612]="DWG_TYPE_BLOCKXYGRIP",r[r.DWG_TYPE_BLOCKXYPARAMETER=613]="DWG_TYPE_BLOCKXYPARAMETER",r[r.DWG_TYPE_CAMERA=614]="DWG_TYPE_CAMERA",r[r.DWG_TYPE_CELLSTYLEMAP=615]="DWG_TYPE_CELLSTYLEMAP",r[r.DWG_TYPE_CONTEXTDATAMANAGER=616]="DWG_TYPE_CONTEXTDATAMANAGER",r[r.DWG_TYPE_CSACDOCUMENTOPTIONS=617]="DWG_TYPE_CSACDOCUMENTOPTIONS",r[r.DWG_TYPE_CURVEPATH=618]="DWG_TYPE_CURVEPATH",r[r.DWG_TYPE_DATALINK=619]="DWG_TYPE_DATALINK",r[r.DWG_TYPE_DATATABLE=620]="DWG_TYPE_DATATABLE",r[r.DWG_TYPE_DBCOLOR=621]="DWG_TYPE_DBCOLOR",r[r.DWG_TYPE_DETAILVIEWSTYLE=622]="DWG_TYPE_DETAILVIEWSTYLE",r[r.DWG_TYPE_DGNDEFINITION=623]="DWG_TYPE_DGNDEFINITION",r[r.DWG_TYPE_DGNUNDERLAY=624]="DWG_TYPE_DGNUNDERLAY",r[r.DWG_TYPE_DICTIONARYVAR=625]="DWG_TYPE_DICTIONARYVAR",r[r.DWG_TYPE_DICTIONARYWDFLT=626]="DWG_TYPE_DICTIONARYWDFLT",r[r.DWG_TYPE_DIMASSOC=627]="DWG_TYPE_DIMASSOC",r[r.DWG_TYPE_DMDIMOBJECTCONTEXTDATA=628]="DWG_TYPE_DMDIMOBJECTCONTEXTDATA",r[r.DWG_TYPE_DWFDEFINITION=629]="DWG_TYPE_DWFDEFINITION",r[r.DWG_TYPE_DWFUNDERLAY=630]="DWG_TYPE_DWFUNDERLAY",r[r.DWG_TYPE_DYNAMICBLOCKPROXYNODE=631]="DWG_TYPE_DYNAMICBLOCKPROXYNODE",r[r.DWG_TYPE_DYNAMICBLOCKPURGEPREVENTER=632]="DWG_TYPE_DYNAMICBLOCKPURGEPREVENTER",r[r.DWG_TYPE_EVALUATION_GRAPH=633]="DWG_TYPE_EVALUATION_GRAPH",r[r.DWG_TYPE_EXTRUDEDSURFACE=634]="DWG_TYPE_EXTRUDEDSURFACE",r[r.DWG_TYPE_FCFOBJECTCONTEXTDATA=635]="DWG_TYPE_FCFOBJECTCONTEXTDATA",r[r.DWG_TYPE_FIELD=636]="DWG_TYPE_FIELD",r[r.DWG_TYPE_FIELDLIST=637]="DWG_TYPE_FIELDLIST",r[r.DWG_TYPE_FLIPPARAMETERENTITY=638]="DWG_TYPE_FLIPPARAMETERENTITY",r[r.DWG_TYPE_FLIPACTIONENTITY=639]="DWG_TYPE_FLIPACTIONENTITY",r[r.DWG_TYPE_GEODATA=640]="DWG_TYPE_GEODATA",r[r.DWG_TYPE_GEOMAPIMAGE=641]="DWG_TYPE_GEOMAPIMAGE",r[r.DWG_TYPE_GEOPOSITIONMARKER=642]="DWG_TYPE_GEOPOSITIONMARKER",r[r.DWG_TYPE_GRADIENT_BACKGROUND=643]="DWG_TYPE_GRADIENT_BACKGROUND",r[r.DWG_TYPE_GROUND_PLANE_BACKGROUND=644]="DWG_TYPE_GROUND_PLANE_BACKGROUND",r[r.DWG_TYPE_HELIX=645]="DWG_TYPE_HELIX",r[r.DWG_TYPE_IBL_BACKGROUND=646]="DWG_TYPE_IBL_BACKGROUND",r[r.DWG_TYPE_IDBUFFER=647]="DWG_TYPE_IDBUFFER",r[r.DWG_TYPE_IMAGE=648]="DWG_TYPE_IMAGE",r[r.DWG_TYPE_IMAGEDEF=649]="DWG_TYPE_IMAGEDEF",r[r.DWG_TYPE_IMAGEDEF_REACTOR=650]="DWG_TYPE_IMAGEDEF_REACTOR",r[r.DWG_TYPE_IMAGE_BACKGROUND=651]="DWG_TYPE_IMAGE_BACKGROUND",r[r.DWG_TYPE_INDEX=652]="DWG_TYPE_INDEX",r[r.DWG_TYPE_LARGE_RADIAL_DIMENSION=653]="DWG_TYPE_LARGE_RADIAL_DIMENSION",r[r.DWG_TYPE_LAYERFILTER=654]="DWG_TYPE_LAYERFILTER",r[r.DWG_TYPE_LAYER_INDEX=655]="DWG_TYPE_LAYER_INDEX",r[r.DWG_TYPE_LAYOUTPRINTCONFIG=656]="DWG_TYPE_LAYOUTPRINTCONFIG",r[r.DWG_TYPE_LEADEROBJECTCONTEXTDATA=657]="DWG_TYPE_LEADEROBJECTCONTEXTDATA",r[r.DWG_TYPE_LIGHT=658]="DWG_TYPE_LIGHT",r[r.DWG_TYPE_LIGHTLIST=659]="DWG_TYPE_LIGHTLIST",r[r.DWG_TYPE_LINEARPARAMETERENTITY=660]="DWG_TYPE_LINEARPARAMETERENTITY",r[r.DWG_TYPE_LOFTEDSURFACE=661]="DWG_TYPE_LOFTEDSURFACE",r[r.DWG_TYPE_MATERIAL=662]="DWG_TYPE_MATERIAL",r[r.DWG_TYPE_MENTALRAYRENDERSETTINGS=663]="DWG_TYPE_MENTALRAYRENDERSETTINGS",r[r.DWG_TYPE_MESH=664]="DWG_TYPE_MESH",r[r.DWG_TYPE_MLEADEROBJECTCONTEXTDATA=665]="DWG_TYPE_MLEADEROBJECTCONTEXTDATA",r[r.DWG_TYPE_MLEADERSTYLE=666]="DWG_TYPE_MLEADERSTYLE",r[r.DWG_TYPE_MOVEACTIONENTITY=667]="DWG_TYPE_MOVEACTIONENTITY",r[r.DWG_TYPE_MOTIONPATH=668]="DWG_TYPE_MOTIONPATH",r[r.DWG_TYPE_MPOLYGON=669]="DWG_TYPE_MPOLYGON",r[r.DWG_TYPE_MTEXTATTRIBUTEOBJECTCONTEXTDATA=670]="DWG_TYPE_MTEXTATTRIBUTEOBJECTCONTEXTDATA",r[r.DWG_TYPE_MTEXTOBJECTCONTEXTDATA=671]="DWG_TYPE_MTEXTOBJECTCONTEXTDATA",r[r.DWG_TYPE_MULTILEADER=672]="DWG_TYPE_MULTILEADER",r[r.DWG_TYPE_NAVISWORKSMODEL=673]="DWG_TYPE_NAVISWORKSMODEL",r[r.DWG_TYPE_NAVISWORKSMODELDEF=674]="DWG_TYPE_NAVISWORKSMODELDEF",r[r.DWG_TYPE_NPOCOLLECTION=675]="DWG_TYPE_NPOCOLLECTION",r[r.DWG_TYPE_NURBSURFACE=676]="DWG_TYPE_NURBSURFACE",r[r.DWG_TYPE_OBJECT_PTR=677]="DWG_TYPE_OBJECT_PTR",r[r.DWG_TYPE_ORDDIMOBJECTCONTEXTDATA=678]="DWG_TYPE_ORDDIMOBJECTCONTEXTDATA",r[r.DWG_TYPE_PARTIAL_VIEWING_INDEX=679]="DWG_TYPE_PARTIAL_VIEWING_INDEX",r[r.DWG_TYPE_PDFDEFINITION=680]="DWG_TYPE_PDFDEFINITION",r[r.DWG_TYPE_PDFUNDERLAY=681]="DWG_TYPE_PDFUNDERLAY",r[r.DWG_TYPE_PERSUBENTMGR=682]="DWG_TYPE_PERSUBENTMGR",r[r.DWG_TYPE_PLANESURFACE=683]="DWG_TYPE_PLANESURFACE",r[r.DWG_TYPE_PLOTSETTINGS=684]="DWG_TYPE_PLOTSETTINGS",r[r.DWG_TYPE_POINTCLOUD=685]="DWG_TYPE_POINTCLOUD",r[r.DWG_TYPE_POINTCLOUDCOLORMAP=686]="DWG_TYPE_POINTCLOUDCOLORMAP",r[r.DWG_TYPE_POINTCLOUDDEF=687]="DWG_TYPE_POINTCLOUDDEF",r[r.DWG_TYPE_POINTCLOUDDEFEX=688]="DWG_TYPE_POINTCLOUDDEFEX",r[r.DWG_TYPE_POINTCLOUDDEF_REACTOR=689]="DWG_TYPE_POINTCLOUDDEF_REACTOR",r[r.DWG_TYPE_POINTCLOUDDEF_REACTOR_EX=690]="DWG_TYPE_POINTCLOUDDEF_REACTOR_EX",r[r.DWG_TYPE_POINTCLOUDEX=691]="DWG_TYPE_POINTCLOUDEX",r[r.DWG_TYPE_POINTPARAMETERENTITY=692]="DWG_TYPE_POINTPARAMETERENTITY",r[r.DWG_TYPE_POINTPATH=693]="DWG_TYPE_POINTPATH",r[r.DWG_TYPE_POLARGRIPENTITY=694]="DWG_TYPE_POLARGRIPENTITY",r[r.DWG_TYPE_RADIMLGOBJECTCONTEXTDATA=695]="DWG_TYPE_RADIMLGOBJECTCONTEXTDATA",r[r.DWG_TYPE_RADIMOBJECTCONTEXTDATA=696]="DWG_TYPE_RADIMOBJECTCONTEXTDATA",r[r.DWG_TYPE_RAPIDRTRENDERSETTINGS=697]="DWG_TYPE_RAPIDRTRENDERSETTINGS",r[r.DWG_TYPE_RASTERVARIABLES=698]="DWG_TYPE_RASTERVARIABLES",r[r.DWG_TYPE_RENDERENTRY=699]="DWG_TYPE_RENDERENTRY",r[r.DWG_TYPE_RENDERENVIRONMENT=700]="DWG_TYPE_RENDERENVIRONMENT",r[r.DWG_TYPE_RENDERGLOBAL=701]="DWG_TYPE_RENDERGLOBAL",r[r.DWG_TYPE_RENDERSETTINGS=702]="DWG_TYPE_RENDERSETTINGS",r[r.DWG_TYPE_REVOLVEDSURFACE=703]="DWG_TYPE_REVOLVEDSURFACE",r[r.DWG_TYPE_ROTATIONPARAMETERENTITY=704]="DWG_TYPE_ROTATIONPARAMETERENTITY",r[r.DWG_TYPE_ROTATEACTIONENTITY=705]="DWG_TYPE_ROTATEACTIONENTITY",r[r.DWG_TYPE_RTEXT=706]="DWG_TYPE_RTEXT",r[r.DWG_TYPE_SCALE=707]="DWG_TYPE_SCALE",r[r.DWG_TYPE_SCALEACTIONENTITY=708]="DWG_TYPE_SCALEACTIONENTITY",r[r.DWG_TYPE_SECTIONOBJECT=709]="DWG_TYPE_SECTIONOBJECT",r[r.DWG_TYPE_SECTIONVIEWSTYLE=710]="DWG_TYPE_SECTIONVIEWSTYLE",r[r.DWG_TYPE_SECTION_MANAGER=711]="DWG_TYPE_SECTION_MANAGER",r[r.DWG_TYPE_SECTION_SETTINGS=712]="DWG_TYPE_SECTION_SETTINGS",r[r.DWG_TYPE_SKYLIGHT_BACKGROUND=713]="DWG_TYPE_SKYLIGHT_BACKGROUND",r[r.DWG_TYPE_SOLID_BACKGROUND=714]="DWG_TYPE_SOLID_BACKGROUND",r[r.DWG_TYPE_SORTENTSTABLE=715]="DWG_TYPE_SORTENTSTABLE",r[r.DWG_TYPE_SPATIAL_FILTER=716]="DWG_TYPE_SPATIAL_FILTER",r[r.DWG_TYPE_SPATIAL_INDEX=717]="DWG_TYPE_SPATIAL_INDEX",r[r.DWG_TYPE_STRETCHACTIONENTITY=718]="DWG_TYPE_STRETCHACTIONENTITY",r[r.DWG_TYPE_SUN=719]="DWG_TYPE_SUN",r[r.DWG_TYPE_SUNSTUDY=720]="DWG_TYPE_SUNSTUDY",r[r.DWG_TYPE_SWEPTSURFACE=721]="DWG_TYPE_SWEPTSURFACE",r[r.DWG_TYPE_TABLE=722]="DWG_TYPE_TABLE",r[r.DWG_TYPE_TABLECONTENT=723]="DWG_TYPE_TABLECONTENT",r[r.DWG_TYPE_TABLEGEOMETRY=724]="DWG_TYPE_TABLEGEOMETRY",r[r.DWG_TYPE_TABLESTYLE=725]="DWG_TYPE_TABLESTYLE",r[r.DWG_TYPE_TEXTOBJECTCONTEXTDATA=726]="DWG_TYPE_TEXTOBJECTCONTEXTDATA",r[r.DWG_TYPE_TVDEVICEPROPERTIES=727]="DWG_TYPE_TVDEVICEPROPERTIES",r[r.DWG_TYPE_VISIBILITYGRIPENTITY=728]="DWG_TYPE_VISIBILITYGRIPENTITY",r[r.DWG_TYPE_VISIBILITYPARAMETERENTITY=729]="DWG_TYPE_VISIBILITYPARAMETERENTITY",r[r.DWG_TYPE_VISUALSTYLE=730]="DWG_TYPE_VISUALSTYLE",r[r.DWG_TYPE_WIPEOUT=731]="DWG_TYPE_WIPEOUT",r[r.DWG_TYPE_WIPEOUTVARIABLES=732]="DWG_TYPE_WIPEOUTVARIABLES",r[r.DWG_TYPE_XREFPANELOBJECT=733]="DWG_TYPE_XREFPANELOBJECT",r[r.DWG_TYPE_XYPARAMETERENTITY=734]="DWG_TYPE_XYPARAMETERENTITY",r[r.DWG_TYPE_BREAKDATA=735]="DWG_TYPE_BREAKDATA",r[r.DWG_TYPE_BREAKPOINTREF=736]="DWG_TYPE_BREAKPOINTREF",r[r.DWG_TYPE_FLIPGRIPENTITY=737]="DWG_TYPE_FLIPGRIPENTITY",r[r.DWG_TYPE_LINEARGRIPENTITY=738]="DWG_TYPE_LINEARGRIPENTITY",r[r.DWG_TYPE_ROTATIONGRIPENTITY=739]="DWG_TYPE_ROTATIONGRIPENTITY",r[r.DWG_TYPE_XYGRIPENTITY=740]="DWG_TYPE_XYGRIPENTITY",r[r.DWG_TYPE__3DLINE=741]="DWG_TYPE__3DLINE",r[r.DWG_TYPE_REPEAT=742]="DWG_TYPE_REPEAT",r[r.DWG_TYPE_ENDREP=743]="DWG_TYPE_ENDREP",r[r.DWG_TYPE_JUMP=744]="DWG_TYPE_JUMP",r[r.DWG_TYPE_LOAD=745]="DWG_TYPE_LOAD",r[r.DWG_TYPE_FREED=65533]="DWG_TYPE_FREED",r[r.DWG_TYPE_UNKNOWN_ENT=65534]="DWG_TYPE_UNKNOWN_ENT",r[r.DWG_TYPE_UNKNOWN_OBJ=65535]="DWG_TYPE_UNKNOWN_OBJ",r))(R||{});Object.fromEntries(Object.entries(R).map(([r,t])=>[t,r]));var mt=(r=>(r[r.DWG=0]="DWG",r[r.DXF=1]="DXF",r))(mt||{}),Ve=(r=>(r[r.Line=1]="Line",r[r.CircularArc=2]="CircularArc",r[r.EllipticArc=3]="EllipticArc",r[r.Spline=4]="Spline",r))(Ve||{}),wt=(r=>(r[r.ByLayer=192]="ByLayer",r[r.ByBlock=193]="ByBlock",r[r.Entities=194]="Entities",r[r.TrueColor=195]="TrueColor",r[r.ForegroundColor=197]="ForegroundColor",r[r.None=200]="None",r))(wt||{});const lr=192,cr=193,wo=194,wn=195,ur=200;function Tr(r){if(r==null)return;const t=r.method,o=r.method!=null&&t!==0?t:r.rgb>>>24&255,n=r.index;if(r.rgb!=null&&o>=lr&&o<=ur&&(r.rgb>>>24&255)===o)return r.rgb>>0;if(o===wt.ByLayer||n===256)return lr<<24>>0;if(o===wt.ByBlock||n===0)return cr<<24>>0;if(o===wt.None)return ur<<24>>0;if(o===wt.TrueColor){const s=r.rgb!=null?r.rgb&16777215:void 0;if(s!=null)return(wo<<24|s)>>0}return o===wt.ForegroundColor?(wn<<24|7)>>0:o===wt.Entities&&n>0&&n<256||n>0&&n<256?(wn<<24|n&255)>>0:cr<<24>>0}function Co(r){if(r==null)return;const t=r.method,o=r.method!=null&&t!==0?t:r.rgb>>>24&255,n=r.index;if(!(o===wt.ByLayer||o===wt.ByBlock||o===wt.None||n===256)){if(o===wt.ForegroundColor)return 7;if(o===wt.TrueColor)return r.rgb==null?void 0:r.rgb&16777215;if(n>=1&&n<=255)return n;if(n!==0&&r.rgb!=null){const s=r.rgb&16777215;if(s!==0)return s}}}const Do="*MODEL_SPACE",Ro="*PAPER_SPACE",Wn=r=>r&&r.toUpperCase()==Do,So=r=>r&&r.toUpperCase().startsWith(Ro),ht=r=>r.toString(16).toUpperCase(),He=r=>{const t=new Array(r.length);for(let o=0;o<r.length;o++)t[o]=r[o].toString(16).toUpperCase().padStart(2,"0");return t.join("")},Lo=r=>{if(!r||r.length<98)return null;const t=new DataView(r.buffer,r.byteOffset,r.byteLength),o=_=>({x:t.getFloat64(_,!0),y:t.getFloat64(_+8,!0),z:t.getFloat64(_+16,!0)}),n=o(2),s=o(50);return[n.x,n.y,n.z,s.x,s.y,s.z].every(Number.isFinite)?{upperLeft:n,lowerRight:s}:null};class Yo{constructor(t){et(this,"libredwg"),et(this,"layers",new Map),et(this,"ltypes",new Map),et(this,"classes",[]),et(this,"unknownEntityCount"),this.libredwg=t,this.unknownEntityCount=0}prepare(t,o=!1){(o||this.layers.size==0)&&(this.layers.clear(),t.tables.LAYER.entries.forEach(n=>{this.layers.set(n.handle,n.name)})),(o||this.ltypes.size==0)&&(this.ltypes.clear(),t.tables.LTYPE.entries.forEach(n=>{this.ltypes.set(n.handle,n.name)})),this.classes=t.classes,this.unknownEntityCount=0}setClasses(t){this.classes=t}clear(){this.layers.clear(),this.ltypes.clear(),this.classes=[],this.unknownEntityCount=0}convert(t){const o=this.libredwg,n=o.dwg_object_to_entity(t),s=o.dwg_object_to_entity_tio(t);if(n&&s){const _=this.getCommonAttrs(n),l=o.dwg_object_get_fixedtype(t);if(l==R.DWG_TYPE_3DFACE)return this.convert3dFace(s,_);if(l==R.DWG_TYPE_3DSOLID)return this.convert3dSolid(s,_);if(l==R.DWG_TYPE_ARC)return this.convertArc(s,_);if(l==R.DWG_TYPE_ARCALIGNEDTEXT)return this.convertArcAlignedText(s,_);if(l==R.DWG_TYPE_ATTDEF)return this.convertAttdef(s,_);if(l==R.DWG_TYPE_CIRCLE)return this.convertCircle(s,_);if(l==R.DWG_TYPE_DIMENSION_ALIGNED)return this.convertAlignedDimension(s,_);if(l==R.DWG_TYPE_DIMENSION_LINEAR)return this.convertRotatedDimension(s,_);if(l==R.DWG_TYPE_DIMENSION_ANG3PT)return this.convert3PointAngularDimension(s,_);if(l==R.DWG_TYPE_DIMENSION_ANG2LN)return this.convert2LineAngularDimension(s,_);if(l==R.DWG_TYPE_DIMENSION_DIAMETER)return this.convertDiameterDimension(s,_);if(l==R.DWG_TYPE_DIMENSION_ORDINATE)return this.convertOrdinateDimension(s,_);if(l==R.DWG_TYPE_DIMENSION_RADIUS)return this.convertRadiusDimension(s,_);if(l==R.DWG_TYPE_ELLIPSE)return this.convertEllise(s,_);if(l==R.DWG_TYPE_HATCH)return this.convertHatch(s,_);if(l==R.DWG_TYPE_IMAGE)return this.convertImage(s,_);if(l==R.DWG_TYPE_INSERT||l==R.DWG_TYPE_MINSERT)return this.convertInsert(s,_);if(l==R.DWG_TYPE_LEADER)return this.convertLeader(s,_);if(l==R.DWG_TYPE_LINE)return this.convertLine(s,_);if(l==R.DWG_TYPE_LWPOLYLINE)return this.convertLWPolyline(s,_);if(l==R.DWG_TYPE_MESH)return this.convertMesh(_,t);if(l==R.DWG_TYPE_MLINE)return this.convertMLine(s,_);if(l==R.DWG_TYPE_MULTILEADER)return this.convertMultiLeader(s,_);if(l==R.DWG_TYPE_MTEXT)return this.convertMText(s,_);if(l==R.DWG_TYPE_OLE2FRAME)return this.convertOle2Frame(s,_);if(l==R.DWG_TYPE_OLEFRAME)return this.convertOleFrame(s,_);if(l==R.DWG_TYPE_POINT)return this.convertPoint(s,_);if(l==R.DWG_TYPE_POLYLINE_2D)return this.convertPolyline2d(s,_,t);if(l==R.DWG_TYPE_POLYLINE_3D)return this.convertPolyline3d(s,_,t);if(l==R.DWG_TYPE_PROXY_ENTITY)return this.convertProxyEntity(s,_,t);if(l==R.DWG_TYPE_RAY)return this.convertRay(s,_);if(l==R.DWG_TYPE_SECTIONOBJECT)return this.convertSection(s,_);if(l==R.DWG_TYPE_SHAPE)return this.convertShape(s,_);if(l==R.DWG_TYPE_SOLID)return this.convertSolid(s,_);if(l==R.DWG_TYPE_TRACE)return this.convertTrace(s,_);if(l==R.DWG_TYPE_SPLINE)return this.convertSpline(s,_);if(l==R.DWG_TYPE_TABLE)return this.convertTable(s,_);if(l==R.DWG_TYPE_TEXT)return this.convertText(s,_);if(l==R.DWG_TYPE_TOLERANCE)return this.convertTolerance(s,_);if(l==R.DWG_TYPE_VIEWPORT)return this.convertViewport(s,_);if(l==R.DWG_TYPE_WIPEOUT)return this.convertWipeout(s,_);if(l==R.DWG_TYPE_XLINE)return this.convertXline(s,_);l===R.DWG_TYPE_UNKNOWN_ENT&&this.unknownEntityCount++}}convert3dFace(t,o){const n=this.libredwg,s=n.dwg_dynapi_entity_data(t,"corner1"),_=n.dwg_dynapi_entity_data(t,"corner2"),l=n.dwg_dynapi_entity_data(t,"corner3"),f=n.dwg_dynapi_entity_data(t,"corner4"),h=n.dwg_dynapi_entity_data(t,"invis_flags");return{type:"3DFACE",...o,corner1:s,corner2:_,corner3:l,corner4:f,flag:h}}convert3dSolid(t,o){const n=this.libredwg,s=n.dwg_dynapi_entity_data(t,"version"),_=n.dwg_dynapi_entity_data(t,"acis_empty"),l=n.dwg_dynapi_entity_data(t,"acis_data"),f=n.dwg_dynapi_entity_data(t,"has_revision_guid"),h=n.dwg_dynapi_entity_data(t,"history_id"),g=n.dwg_ref_get_id(h),y={type:"3DSOLID",subclassMarker:"AcDb3dSolid",...o};if(s&&(y.version=s),y.satCache=_,l&&(y.data=l),f){const P=n.dwg_dynapi_entity_field_offset(t,"revision_guid");if(P>=0){const p=n.UTF8ToString(t+P,38);p&&(y.guid=p)}}return g&&(y.historyObjectSoftId=g),y}convertArc(t,o){const n=this.libredwg,s=n.dwg_dynapi_entity_data(t,"center"),_=n.dwg_dynapi_entity_data(t,"radius"),l=n.dwg_dynapi_entity_data(t,"thickness"),f=n.dwg_dynapi_entity_data(t,"extrusion"),h=n.dwg_dynapi_entity_data(t,"start_angle"),g=n.dwg_dynapi_entity_data(t,"end_angle");return{type:"ARC",...o,thickness:l,center:s,radius:_,startAngle:h,endAngle:g,extrusionDirection:f}}convertArcAlignedText(t,o){const n=this.libredwg,s=(g,y=0)=>{const P=n.dwg_dynapi_entity_data(t,g);if(typeof P=="number"&&Number.isFinite(P))return P;if(typeof P=="string"&&P.trim()!==""){const p=Number(P);if(Number.isFinite(p))return p}return y},_=n.dwg_dynapi_entity_data(t,"center"),l=n.dwg_dynapi_entity_data(t,"extrusion"),f=n.dwg_dynapi_entity_data(t,"arc_handle"),h=s("xscale",1);return{type:"ARCALIGNEDTEXT",...o,text:n.dwg_dynapi_entity_data(t,"text_value")??"",textSize:s("text_size"),xScale:h>0?h:1,characterSpacing:s("char_spacing"),styleName:n.dwg_dynapi_entity_data(t,"style")??"",fontName:n.dwg_dynapi_entity_data(t,"font_name")??"",bigFontName:n.dwg_dynapi_entity_data(t,"bigfont_name")??"",offsetFromArc:s("offset_from_arc"),rightOffset:s("right_offset"),leftOffset:s("left_offset"),center:_??{x:0,y:0,z:0},radius:n.dwg_dynapi_entity_data(t,"radius")??0,startAngle:n.dwg_dynapi_entity_data(t,"start_angle")??0,endAngle:n.dwg_dynapi_entity_data(t,"end_angle")??0,extrusionDirection:l??{x:0,y:0,z:1},rawTextColor:n.dwg_dynapi_entity_data(t,"color")??256,characterSet:n.dwg_dynapi_entity_data(t,"character_set")??0,pitchAndFamily:n.dwg_dynapi_entity_data(t,"pitch_and_family")??0,isShx:(n.dwg_dynapi_entity_data(t,"is_shx")??0)!==0,isBold:(n.dwg_dynapi_entity_data(t,"is_bold")??0)!==0,isItalic:(n.dwg_dynapi_entity_data(t,"is_italic")??0)!==0,isUnderlined:(n.dwg_dynapi_entity_data(t,"is_underlined")??0)!==0,alignment:n.dwg_dynapi_entity_data(t,"alignment")??0,isReverse:(n.dwg_dynapi_entity_data(t,"is_reverse")??0)!==0,wizardFlag:n.dwg_dynapi_entity_data(t,"wizard_flag")??0,textPosition:n.dwg_dynapi_entity_data(t,"text_position")??1,textDirection:n.dwg_dynapi_entity_data(t,"text_direction")??1,arcHandle:f?n.dwg_ref_get_id(f)??"":""}}convertEmbeddedMText(t,o){const n=this.libredwg,s=n.dwg_dynapi_subclass_data(t,o,"attachment"),_=n.dwg_dynapi_subclass_data(t,o,"ins_pt"),l=n.dwg_dynapi_subclass_data(t,o,"x_axis_dir"),f=n.dwg_dynapi_subclass_data(t,o,"rect_height"),h=n.dwg_dynapi_subclass_data(t,o,"rect_width"),g=n.dwg_dynapi_subclass_data(t,o,"extents_height"),y=n.dwg_dynapi_subclass_data(t,o,"extents_width");return{insertionPoint:_,rectHeight:f,rectWidth:h,extentsHeight:g,extentsWidth:y,attachmentPoint:s,direction:l}}convertAttdef(t,o){const n=this.libredwg,s=n.dwg_dynapi_entity_data(t,"default_value"),_=this.convertTextBase(t);_.text=s;const l=n.dwg_dynapi_entity_data(t,"prompt"),f=n.dwg_dynapi_entity_data(t,"tag"),h=n.dwg_dynapi_entity_data(t,"flags"),g=n.dwg_dynapi_entity_data(t,"field_length"),y=n.dwg_dynapi_entity_data(t,"lock_position_flag"),P=n.dwg_dynapi_entity_data(t,"keep_duplicate_records"),p=n.dwg_dynapi_entity_data(t,"is_really_locked"),I=n.dwg_dynapi_entity_data(t,"mtext_type"),C=n.dwg_dynapi_entity_data(t,"alignment_pt");return{type:"ATTDEF",...o,text:this.convertTextBase(t),prompt:l,tag:f,flags:h,fieldLength:g,lockPositionFlag:y>0,duplicateRecordCloningFlag:P>0,mtextFlag:I,isReallyLocked:p>0,alignmentPoint:C,annotationScale:1,attrTag:"",mtext:this.convertEmbeddedMText(t,"ATTDEF_mtext")}}convertAttrib(t,o){const n=this.libredwg,s=this.convertTextBase(t),_=n.dwg_dynapi_entity_data(t,"tag"),l=n.dwg_dynapi_entity_data(t,"flags"),f=n.dwg_dynapi_entity_data(t,"field_length"),h=n.dwg_dynapi_entity_data(t,"lock_position_flag"),g=n.dwg_dynapi_entity_data(t,"keep_duplicate_records"),y=n.dwg_dynapi_entity_data(t,"mtext_type"),P=n.dwg_dynapi_entity_data(t,"is_really_locked"),p=n.dwg_dynapi_entity_data(t,"alignment_pt");return{type:"ATTRIB",...o,text:s,tag:_,flags:l,fieldLength:f,lockPositionFlag:!!h,duplicateRecordCloningFlag:!!g,mtextFlag:y,isReallyLocked:!!P,numberOfSecondaryAttrs:0,secondaryAttrsHardId:"0",alignmentPoint:{...p,z:0},annotationScale:1,attrTag:"",mtext:this.convertEmbeddedMText(t,"ATTDEF_mtext")}}convertCircle(t,o){const n=this.libredwg,s=n.dwg_dynapi_entity_data(t,"center"),_=n.dwg_dynapi_entity_data(t,"radius"),l=n.dwg_dynapi_entity_data(t,"thickness"),f=n.dwg_dynapi_entity_data(t,"extrusion");return{type:"CIRCLE",...o,thickness:l,center:s,radius:_,extrusionDirection:f}}convertAlignedDimension(t,o){return this.convertLinearOrAlignedDimension(t,o,"AcDbAlignedDimension")}convertRotatedDimension(t,o){return this.convertLinearOrAlignedDimension(t,o,"AcDbRotatedDimension")}convertLinearOrAlignedDimension(t,o,n){const s=this.libredwg,_=this.getDimensionCommonAttrs(t),l=s.dwg_dynapi_entity_data(t,"clone_ins_pt"),f=s.dwg_dynapi_entity_data(t,"xline1_pt"),h=s.dwg_dynapi_entity_data(t,"xline2_pt"),g=n==="AcDbRotatedDimension"?s.dwg_dynapi_entity_data(t,"dim_rotation"):0,y=s.dwg_dynapi_entity_data(t,"oblique_angle");return{subclassMarker:n,...o,..._,insertionPoint:l,subDefinitionPoint1:f,subDefinitionPoint2:h,rotationAngle:g??0,obliqueAngle:y}}convert3PointAngularDimension(t,o){const n=this.libredwg,s=this.getDimensionCommonAttrs(t),_=n.dwg_dynapi_entity_data(t,"xline1_pt"),l=n.dwg_dynapi_entity_data(t,"xline2_pt"),f=n.dwg_dynapi_entity_data(t,"center_pt"),h=n.dwg_dynapi_entity_data(t,"xline2end_pt");return{subclassMarker:"AcDb3PointAngularDimension",...o,...s,subDefinitionPoint1:_,subDefinitionPoint2:l,centerPoint:f,arcPoint:h}}convert2LineAngularDimension(t,o){const n=this.libredwg,s=this.getDimensionCommonAttrs(t),_=n.dwg_dynapi_entity_data(t,"xline1start_pt"),l=n.dwg_dynapi_entity_data(t,"xline1end_pt"),f=n.dwg_dynapi_entity_data(t,"xline2start_pt"),h=n.dwg_dynapi_entity_data(t,"xline2end_pt"),g=n.dwg_dynapi_entity_data(t,"def_pt");return h&&(s.definitionPoint=h),{subclassMarker:"AcDb2LineAngularDimension",...o,...s,subDefinitionPoint1:_??l??g??h,subDefinitionPoint2:f??h??g??l,centerPoint:g??f??l??h,arcPoint:h??s.definitionPoint}}convertDiameterDimension(t,o){const n=this.libredwg,s=this.getDimensionCommonAttrs(t),_=n.dwg_dynapi_entity_data(t,"first_arc_pt"),l=n.dwg_dynapi_entity_data(t,"leader_len");return{subclassMarker:"AcDbDiametricDimension",...o,...s,centerPoint:_,leaderLength:l}}convertOrdinateDimension(t,o){const n=this.libredwg,s=this.getDimensionCommonAttrs(t),_=n.dwg_dynapi_entity_data(t,"feature_location_pt"),l=n.dwg_dynapi_entity_data(t,"leader_endpt");return{subclassMarker:"AcDbOrdinateDimension",...o,...s,subDefinitionPoint1:_,subDefinitionPoint2:l}}convertRadiusDimension(t,o){const n=this.libredwg,s=this.getDimensionCommonAttrs(t),_=n.dwg_dynapi_entity_data(t,"first_arc_pt"),l=n.dwg_dynapi_entity_data(t,"leader_len");return{subclassMarker:"AcDbRadialDimension",...o,...s,centerPoint:_,leaderLength:l}}convertEllise(t,o){const n=this.libredwg,s=n.dwg_dynapi_entity_data(t,"center"),_=n.dwg_dynapi_entity_data(t,"sm_axis"),l=n.dwg_dynapi_entity_data(t,"extrusion"),f=n.dwg_dynapi_entity_data(t,"axis_ratio"),h=n.dwg_dynapi_entity_data(t,"start_angle"),g=n.dwg_dynapi_entity_data(t,"end_angle");return{type:"ELLIPSE",...o,center:s,majorAxisEndPoint:_,extrusionDirection:l,axisRatio:f,startAngle:h,endAngle:g}}convertHatch(t,o){const n=this.libredwg,s=n.dwg_dynapi_entity_data(t,"extrusion"),_=n.dwg_dynapi_entity_data(t,"name"),l=n.dwg_dynapi_entity_data(t,"is_solid_fill"),f=n.dwg_dynapi_entity_data(t,"is_associative"),h=n.dwg_dynapi_entity_data(t,"num_paths"),g=n.dwg_dynapi_entity_data(t,"paths"),y=n.dwg_ptr_to_hatch_path_array(g,h),P=n.dwg_dynapi_entity_data(t,"style"),p=n.dwg_dynapi_entity_data(t,"pattern_type"),I=n.dwg_dynapi_entity_data(t,"angle"),C=n.dwg_dynapi_entity_data(t,"scale_spacing"),w=n.dwg_dynapi_entity_data(t,"num_deflines"),m=n.dwg_dynapi_entity_data(t,"deflines"),S=n.dwg_ptr_to_hatch_defline_array(m,w),N=n.dwg_dynapi_entity_data(t,"pixel_size"),W=n.dwg_dynapi_entity_data(t,"num_seeds"),M=n.dwg_dynapi_entity_data(t,"seeds"),O=n.dwg_ptr_to_point2d_array(M,W),U={...o,extrusionDirection:s,patternName:_,solidFill:l?Dn.SolidFill:Dn.PatternFill,associativity:f?Rn.Associative:Rn.NonAssociative,numberOfBoundaryPaths:h,boundaryPaths:this.convertHatchBoundaryPaths(y),hatchStyle:P,patternType:p,patternAngle:I,patternScale:C,numberOfDefinitionLines:w,definitionLines:S.map(nt=>({angle:nt.angle,base:nt.pt0,offset:nt.offset,numberOfDashLengths:nt.dashes.length,dashLengths:nt.dashes})),pixelSize:N,numberOfSeedPoints:W,seedPoints:O};if(n.dwg_dynapi_entity_data(t,"is_gradient_fill")>0){const nt=n.dwg_dynapi_entity_data(t,"gradient_name"),gt=n.dwg_dynapi_entity_data(t,"gradient_angle"),Z=n.dwg_dynapi_entity_data(t,"gradient_shift"),ut=n.dwg_dynapi_entity_data(t,"gradient_tint"),Et=n.dwg_dynapi_entity_data(t,"single_color_gradient"),At=n.dwg_dynapi_entity_data(t,"colors"),yt=n.dwg_ptr_to_hatch_gradient_color_array(At,Et==1?1:2);return{type:"HATCH",...U,gradientFlag:yr.Gradient,gradientColorFlag:Et==1?Sn.OneColor:Sn.TwoColor,gradientName:nt,gradientRotation:gt,gradientDefinition:Z,colorTint:ut,gradientColors:yt}}else return{type:"HATCH",...U}}convertHatchBoundaryPaths(t){return t.filter(n=>n.num_segs_or_paths>0).map(n=>{const s={boundaryPathTypeFlag:n.flag};if(n.flag&2)return{...s,hasBulge:n.bulges_present,isClosed:n.closed,numberOfVertices:n.num_segs_or_paths,vertices:n.polyline_paths.map(_=>({x:_.point.x,y:_.point.y,bulge:_.bulge}))};{const _=n.segs.map(l=>{if(l.curve_type==Ve.Line)return{type:$e.Line,start:l.first_endpoint,end:l.second_endpoint};if(l.curve_type==Ve.CircularArc)return{type:$e.Circular,center:l.center,radius:l.radius,startAngle:l.start_angle,endAngle:l.end_angle,isCCW:l.is_ccw};if(l.curve_type==Ve.EllipticArc)return{type:$e.Elliptic,center:l.center,end:l.endpoint,lengthOfMinorAxis:l.minor_major_ratio,startAngle:l.start_angle,endAngle:l.end_angle,isCCW:l.is_ccw};if(l.curve_type==Ve.Spline)return{type:$e.Spline,degree:l.degree,isRational:l.is_rational,isPeriodic:l.is_periodic,numberOfKnots:l.num_knots,numberOfControlPoints:l.num_control_points,knots:l.knots,controlPoints:l.control_points,numberOfFitData:l.num_fitpts,fitDatum:l.fitpts,startTangent:l.start_tangent,endTangent:l.end_tangent}}).filter(l=>l!=null);return{...s,numberOfEdges:_.length,edges:_}}})}convertImage(t,o){const n=this.libredwg,s=n.dwg_dynapi_entity_data(t,"class_version"),_=n.dwg_dynapi_entity_data(t,"pt0"),l=n.dwg_dynapi_entity_data(t,"uvec"),f=n.dwg_dynapi_entity_data(t,"vvec"),h=n.dwg_dynapi_entity_data(t,"image_size"),g=n.dwg_dynapi_entity_data(t,"display_props"),y=n.dwg_dynapi_entity_data(t,"clipping"),P=n.dwg_dynapi_entity_data(t,"brightness"),p=n.dwg_dynapi_entity_data(t,"contrast"),I=n.dwg_dynapi_entity_data(t,"fade"),C=n.dwg_dynapi_entity_data(t,"clip_mode"),w=n.dwg_dynapi_entity_data(t,"clip_boundary_type"),m=n.dwg_dynapi_entity_data(t,"num_clip_verts"),S=n.dwg_dynapi_entity_data(t,"clip_verts"),N=n.dwg_ptr_to_point3d_array(S,m),W=n.dwg_dynapi_entity_data(t,"imagedef"),M=n.dwg_ref_get_id(W)??"",O=n.dwg_dynapi_entity_data(t,"imagedefreactor"),U=n.dwg_ref_get_id(O)??"";return{type:"IMAGE",...o,version:s,position:_,uPixel:l,vPixel:f,imageSize:h,imageDefHandle:M,flags:g,clipping:y,brightness:P,contrast:p,fade:I,imageDefReactorHandle:U,clippingBoundaryType:w,countBoundaryPoints:m,clippingBoundaryPath:N,clipMode:C}}convertInsert(t,o){const n=this.libredwg;let s="";const _=n.dwg_dynapi_entity_data(t,"block_header");if(_){const m=n.dwg_ref_get_object(_);if(m){const S=n.dwg_object_to_object_tio(m);S&&(s=n.dwg_entity_block_header_get_block(S).name)}}s||(s=n.dwg_dynapi_entity_data(t,"block_name"));const l=n.dwg_dynapi_entity_data(t,"ins_pt"),f=n.dwg_dynapi_entity_data(t,"scale"),h=n.dwg_dynapi_entity_data(t,"rotation"),g=n.dwg_dynapi_entity_data(t,"num_cols"),y=n.dwg_dynapi_entity_data(t,"num_rows"),P=n.dwg_dynapi_entity_data(t,"col_spacing"),p=n.dwg_dynapi_entity_data(t,"row_spacing"),I=n.dwg_dynapi_entity_data(t,"extrusion"),C=n.dwg_entity_insert_get_attribs(t),w=[];return C.forEach(m=>{const S=n.dwg_object_to_entity(m),N=n.dwg_object_to_entity_tio(m);if(S&&N){const W=this.getCommonAttrs(S);n.dwg_object_get_fixedtype(m)==R.DWG_TYPE_ATTRIB&&w.push(this.convertAttrib(N,W))}}),{type:"INSERT",...o,name:s,insertionPoint:l,xScale:f?f.x:1,yScale:f?f.y:1,zScale:f?f.z:1,rotation:h,columnCount:g||1,rowCount:y||1,columnSpacing:P||0,rowSpacing:p||0,extrusionDirection:I,attribs:w}}convertLeader(t,o){const n=this.libredwg;let s="";try{s=n.dwg_entity_get_dimstyle_name(t)||""}catch{s=""}const l=n.dwg_dynapi_entity_data(t,"arrowhead_on")>0,f=n.dwg_dynapi_entity_data(t,"path_type"),h=n.dwg_dynapi_entity_data(t,"annot_type"),g=n.dwg_dynapi_entity_data(t,"hookline_dir"),y=n.dwg_dynapi_entity_data(t,"hookline_on"),P=n.dwg_dynapi_entity_data(t,"box_height"),p=n.dwg_dynapi_entity_data(t,"box_width"),I=n.dwg_dynapi_entity_data(t,"num_points"),C=n.dwg_dynapi_entity_data(t,"points"),w=I>0?n.dwg_ptr_to_point3d_array(C,I):[],m=n.dwg_dynapi_entity_data(t,"byblock_color"),S=n.dwg_dynapi_entity_data(t,"extrusion"),N=n.dwg_dynapi_entity_data(t,"x_direction"),W=n.dwg_dynapi_entity_data(t,"inspt_offset"),M=n.dwg_dynapi_entity_data(t,"endptproj");return{type:"LEADER",...o,styleName:s,isArrowheadEnabled:l,isSpline:f>0,leaderCreationFlag:h,isHooklineSameDirection:g>0,isHooklineExists:y>0,textHeight:P,textWidth:p,numberOfVertices:I,vertices:w,byBlockColor:m,normal:S,horizontalDirection:N,offsetFromBlock:W,offsetFromAnnotation:M}}convertLine(t,o){const n=this.libredwg,s=n.dwg_dynapi_entity_data(t,"start"),_=n.dwg_dynapi_entity_data(t,"end"),l=n.dwg_dynapi_entity_data(t,"thickness"),f=n.dwg_dynapi_entity_data(t,"extrusion");return{type:"LINE",...o,thickness:l,startPoint:s,endPoint:_,extrusionDirection:f}}convertLWPolyline(t,o){const n=this.libredwg,s=n.dwg_dynapi_entity_data(t,"num_points"),_=n.dwg_dynapi_entity_data(t,"flag"),l=n.dwg_dynapi_entity_data(t,"const_width"),f=n.dwg_dynapi_entity_data(t,"elevation"),h=n.dwg_dynapi_entity_data(t,"thickness"),g=n.dwg_dynapi_entity_data(t,"extrusion"),y=[],P=n.dwg_dynapi_entity_data(t,"num_points"),p=n.dwg_dynapi_entity_data(t,"points"),I=n.dwg_ptr_to_point2d_array(p,P),C=n.dwg_dynapi_entity_data(t,"num_bulges"),w=n.dwg_dynapi_entity_data(t,"bulges"),m=n.dwg_ptr_to_double_array(w,C),S=n.dwg_dynapi_entity_data(t,"num_widths")??0,N=n.dwg_dynapi_entity_data(t,"widths"),W=S>0&&N?n.dwg_ptr_to_double_array(N,S*2):[];return I.forEach((M,O)=>{const U={id:O,x:M.x,y:M.y,bulge:m.length>O?m[O]:0};O<S&&W.length>=(O+1)*2&&(U.startWidth=W[O*2],U.endWidth=W[O*2+1]),y.push(U)}),{type:"LWPOLYLINE",...o,numberOfVertices:s,flag:_,constantWidth:l,elevation:f,thickness:h,extrusionDirection:g,vertices:y}}convertMLine(t,o){const n=this.libredwg,s=n.dwg_dynapi_entity_data(t,"scale"),_=n.dwg_dynapi_entity_data(t,"flags"),l=n.dwg_dynapi_entity_data(t,"justification"),f=n.dwg_dynapi_entity_data(t,"base_point"),h=n.dwg_dynapi_entity_data(t,"extrusion"),g=n.dwg_dynapi_entity_data(t,"num_lines"),y=n.dwg_dynapi_entity_data(t,"num_verts"),P=n.dwg_dynapi_entity_data(t,"verts"),p=n.dwg_ptr_to_mline_vertex_array(P,y),I=[];return p.forEach(C=>{I.push({vertex:C.vertex,vertexDirection:C.vertex_direction,miterDirection:C.miter_direction,numberOfLines:C.num_lines,lines:C.lines.map(w=>({numberOfSegmentParams:w.num_segparms,segmentParams:w.segparms,numberOfAreaFillParams:w.num_areafillparms,areaFillParams:w.areafillparms}))})}),{type:"MLINE",...o,scale:s,flags:_,justification:l,startPoint:f,extrusionDirection:h,numberOfLines:g,numberOfVertices:y,vertices:I,mlineStyle:""}}convertMultiLeader(t,o){const n=this.libredwg,s=K=>n.dwg_dynapi_entity_data(t,K),_=(K,j,ee)=>n.dwg_dynapi_subclass_data(K,j,ee),l=K=>n.dwg_ref_get_id(K),f=K=>K>0,h=K=>K!=null?Tr(K):void 0,g=s("class_version"),y=l(s("mleaderstyle")),P=s("flags"),p=s("type"),I=h(s("line_color")),C=l(s("line_ltype")),w=s("line_linewt"),m=f(s("has_landing")),S=f(s("has_dogleg")),N=s("landing_dist"),W=l(s("arrow_handle")),M=s("arrow_size"),O=s("style_content"),U=l(s("text_style")),J=s("text_left"),nt=s("text_right"),gt=s("text_angletype"),Z=s("text_alignment"),ut=h(s("text_color")),Et=f(s("has_text_frame")),At=l(s("block_style")),yt=h(s("block_color")),Mt=s("block_scale"),bt=s("block_rotation"),xt=s("style_attachment"),Ot=f(s("is_annotative")),dt=f(s("is_neg_textdir")),k=s("ipe_alignment");let tt=s("justification");const z=s("attach_dir"),kt=s("attach_bottom"),Bt=s("attach_top"),Tt=s("scale_factor"),B=s("num_arrowheads"),Xt=s("arrowheads"),lt=n.dwg_dynapi_subclass_size("LEADER_ArrowHead"),St=[];for(let K=0;K<B;K++){const j=Xt+K*lt;St.push({index:_(j,"LEADER_ArrowHead","is_default"),handle:l(_(j,"LEADER_ArrowHead","arrowhead"))??""})}const Kt=s("num_blocklabels"),se=s("blocklabels"),zt=n.dwg_dynapi_subclass_size("LEADER_BlockLabel"),Ft=[];for(let K=0;K<Kt;K++){const j=se+K*zt;Ft.push({id:l(_(j,"LEADER_BlockLabel","attdef")),index:_(j,"LEADER_BlockLabel","ui_index"),width:_(j,"LEADER_BlockLabel","width"),text:_(j,"LEADER_BlockLabel","label_text")})}const q=t+n.dwg_dynapi_entity_field_offset(t,"ctx"),V=q+n.dwg_dynapi_subclass_field_offset("MLEADER_AnnotContext","content"),Jt=_(q,"MLEADER_AnnotContext","scale_factor"),ye=_(q,"MLEADER_AnnotContext","content_base"),Ut=_(q,"MLEADER_AnnotContext","landing_gap"),Ye=_(q,"MLEADER_AnnotContext","attach_dir"),Te=_(q,"MLEADER_AnnotContext","text_height"),Ne=_(q,"MLEADER_AnnotContext","arrow_size"),Zt=_(q,"MLEADER_AnnotContext","text_left"),Lt=_(q,"MLEADER_AnnotContext","text_right"),X=_(q,"MLEADER_AnnotContext","text_angletype"),We=_(q,"MLEADER_AnnotContext","text_alignment"),qt=f(_(q,"MLEADER_AnnotContext","has_content_txt")),Dt=f(_(q,"MLEADER_AnnotContext","has_content_blk")),Pe=_(q,"MLEADER_AnnotContext","base"),pe=_(q,"MLEADER_AnnotContext","base_dir"),Yt=_(q,"MLEADER_AnnotContext","base_vert"),_e=f(_(q,"MLEADER_AnnotContext","is_normal_reversed"));let Nt,de,Qt,ve,Pt,le,x,Ie,ce,jt,me,we,pt,Wt,Ce,De,ue,Re,Ee,Xe,c;if(qt){const K=_(V,"MLEADER_Content_MText","alignment");K!=null&&K!==0&&(tt=K),de=_(V,"MLEADER_Content_MText","normal"),x=_(V,"MLEADER_Content_MText","location"),Qt=_(V,"MLEADER_Content_MText","rotation"),Ie=_(V,"MLEADER_Content_MText","direction"),ve=_(V,"MLEADER_Content_MText","width"),Pt=_(V,"MLEADER_Content_MText","line_spacing_factor"),le=_(V,"MLEADER_Content_MText","line_spacing_style"),Nt=_(V,"MLEADER_Content_MText","flow"),ce=h(_(V,"MLEADER_Content_MText","bg_color")),jt=_(V,"MLEADER_Content_MText","bg_scale"),me=_(V,"MLEADER_Content_MText","bg_transparency"),pt=f(_(V,"MLEADER_Content_MText","is_bg_fill")),we=f(_(V,"MLEADER_Content_MText","is_bg_mask_fill")),Wt=_(V,"MLEADER_Content_MText","col_type"),Ce=f(_(V,"MLEADER_Content_MText","is_height_auto")),De=_(V,"MLEADER_Content_MText","col_width"),ue=_(V,"MLEADER_Content_MText","col_gutter"),Re=f(_(V,"MLEADER_Content_MText","is_col_flow_reversed"));const j=_(V,"MLEADER_Content_MText","num_col_sizes"),ee=_(V,"MLEADER_Content_MText","col_sizes");j>0&&(Ee=n.dwg_ptr_to_double_array(ee,j)[0]),Xe=f(_(V,"MLEADER_Content_MText","word_break")),c=_(V,"MLEADER_Content_MText","default_text")}let te;if(Dt){const K=_(V,"MLEADER_Content_Block","transform");te={blockContentId:l(_(V,"MLEADER_Content_Block","block_table")),normal:_(V,"MLEADER_Content_Block","normal"),position:_(V,"MLEADER_Content_Block","location"),scale:_(V,"MLEADER_Content_Block","scale"),rotation:_(V,"MLEADER_Content_Block","rotation"),color:h(_(V,"MLEADER_Content_Block","color")),transformationMatrix:K?n.dwg_ptr_to_double_array(K,16):void 0}}const Q=_(q,"MLEADER_AnnotContext","num_leaders"),cn=_(q,"MLEADER_AnnotContext","leaders"),un=n.dwg_dynapi_subclass_size("LEADER_Node"),En=n.dwg_dynapi_subclass_size("LEADER_Line"),Ke=n.dwg_dynapi_subclass_size("LEADER_Break"),Ge=[];for(let K=0;K<Q;K++){const j=cn+K*un,ee=f(_(j,"LEADER_Node","has_lastleaderlinepoint")),st=f(_(j,"LEADER_Node","has_dogleg")),ne=_(j,"LEADER_Node","num_breaks"),$t=_(j,"LEADER_Node","breaks"),re=[];for(let ot=0;ot<ne;ot++){const Rt=$t+ot*Ke;re.push({start:_(Rt,"LEADER_Break","start"),end:_(Rt,"LEADER_Break","end")})}const Se=_(j,"LEADER_Node","num_lines"),$=_(j,"LEADER_Node","lines"),ze=[];for(let ot=0;ot<Se;ot++){const Rt=$+ot*En,Je=_(Rt,"LEADER_Line","num_points"),fn=_(Rt,"LEADER_Line","points"),hn=Je>0?n.dwg_ptr_to_point3d_array(fn,Je):[],Me=_(Rt,"LEADER_Line","num_breaks"),be=_(Rt,"LEADER_Line","breaks"),Le=[];for(let xe=0;xe<Me;xe++){const Oe=be+xe*Ke;Le.push({start:_(Oe,"LEADER_Break","start"),end:_(Oe,"LEADER_Break","end")})}ze.push({vertices:hn,leaderLineIndex:_(Rt,"LEADER_Line","line_index"),breaks:Le.length>0?Le:void 0})}Ge.push({lastLeaderLinePoint:ee?_(j,"LEADER_Node","lastleaderlinepoint"):void 0,lastLeaderLinePointSet:ee,doglegVector:st?_(j,"LEADER_Node","dogleg_vector"):void 0,doglegVectorSet:st,doglegLength:_(j,"LEADER_Node","dogleg_length"),breaks:re.length>0?re:void 0,leaderBranchIndex:_(j,"LEADER_Node","branch_index"),leaderLines:ze})}return{type:"MULTILEADER",...o,subclassMarker:"AcDbMLeader",version:g,leaderStyleId:y,propertyOverrideFlag:P,leaderLineType:p,leaderLineColor:I,leaderLineTypeId:C,leaderLineWeight:w,landingEnabled:m,doglegEnabled:S,doglegLength:N,arrowheadId:W,arrowheadSize:M||Ne,contentType:O,textStyleId:U,textLeftAttachmentType:J||Zt,textRightAttachmentType:nt||Lt,textAngleType:gt||X,textAlignmentType:Z||We,textColor:ut,textFrameEnabled:Et,landingGap:Ut,textAttachment:Ye,textFlowDirection:Nt,blockContentId:At,blockContentColor:yt,blockContentScale:Mt,blockContentRotation:bt,blockContentConnectionType:xt,annotativeScaleEnabled:Ot,arrowheadOverrides:St.length>0?St:void 0,blockAttributes:Ft.length>0?Ft:void 0,textDirectionNegative:dt,textAlignInIPE:k,textAttachmentPoint:tt,textAttachmentDirection:z,bottomTextAttachmentDirection:kt,topTextAttachmentDirection:Bt,contentScale:Tt||Jt,contentBasePosition:ye,normal:de,textHeight:Te,textRotation:Qt,textWidth:ve,textLineSpacingFactor:Pt,textLineSpacingStyle:le,textAnchor:x,textDirection:Ie,textBackgroundColor:ce,textBackgroundScaleFactor:jt,textBackgroundTransparency:me,textBackgroundColorOn:we,textFillOn:pt,textColumnType:Wt,textUseAutoHeight:Ce,textColumnWidth:De,textColumnGutterWidth:ue,textColumnFlowReversed:Re,textColumnHeight:Ee,textUseWordBreak:Xe,textContent:c,hasMText:qt,hasBlock:Dt,blockContent:te,planeOrigin:Pe,planeXAxisDirection:pe,planeYAxisDirection:Yt,planeNormalReversed:_e,leaderSections:Ge.length>0?Ge:void 0}}convertOle2Frame(t,o){const n=this.libredwg,s=n.dwg_dynapi_entity_data(t,"oleversion"),_=n.dwg_dynapi_entity_data(t,"oleclient"),l=n.dwg_dynapi_entity_data(t,"data_size");let f=n.dwg_dynapi_entity_data(t,"pt1"),h=n.dwg_dynapi_entity_data(t,"pt2");const g=n.dwg_dynapi_entity_data(t,"lock_aspect"),y=n.dwg_dynapi_entity_data(t,"type"),P=n.dwg_dynapi_entity_data(t,"mode"),p=n.dwg_entity_ole2frame_get_data(t),I=p?He(p):"";if(p){const C=Lo(p);C&&(f=C.upperLeft,h=C.lowerRight)}return{type:"OLE2FRAME",...o,oleVersion:s,oleClient:_,dataSize:l,leftUpPoint:f,rightDownPoint:h,lockAspect:g,oleObjectType:y,tileModeDescriptor:P,binaryData:I}}convertOleFrame(t,o){const n=this.libredwg,s=n.dwg_dynapi_entity_data(t,"flag"),_=n.dwg_dynapi_entity_data(t,"mode"),l=n.dwg_dynapi_entity_data(t,"data_size"),f=n.dwg_entity_oleframe_get_data(t),h=f?He(f):"";return{type:"OLEFRAME",...o,flag:s,mode:_,dataSize:l,binaryData:h}}convertMText(t,o){const n=this.libredwg,s=n.dwg_dynapi_entity_data(t,"ins_pt"),_=n.dwg_dynapi_entity_data(t,"text_height"),l=n.dwg_dynapi_entity_data(t,"rect_height"),f=n.dwg_dynapi_entity_data(t,"rect_width"),h=n.dwg_dynapi_entity_data(t,"extents_width"),g=n.dwg_dynapi_entity_data(t,"extents_height"),y=n.dwg_dynapi_entity_data(t,"attachment"),P=n.dwg_dynapi_entity_data(t,"flow_dir"),p=n.dwg_dynapi_entity_data(t,"text"),I=n.dwg_entity_mtext_get_style_name(t),C=n.dwg_dynapi_entity_data(t,"extrusion"),w=n.dwg_dynapi_entity_data(t,"x_axis_dir"),m=n.dwg_dynapi_entity_data(t,"linespace_style"),S=n.dwg_dynapi_entity_data(t,"linespace_factor"),N=n.dwg_dynapi_entity_data(t,"bg_fill_flag"),W=n.dwg_dynapi_entity_data(t,"bg_fill_scale"),M=n.dwg_dynapi_entity_data(t,"bg_fill_color"),O=n.dwg_dynapi_entity_data(t,"bg_fill_trans"),U=N===1?Co(M):void 0,J=n.dwg_dynapi_entity_data(t,"column_type"),nt=n.dwg_dynapi_entity_data(t,"flow_reversed"),gt=n.dwg_dynapi_entity_data(t,"auto_height"),Z=n.dwg_dynapi_entity_data(t,"column_width"),ut=n.dwg_dynapi_entity_data(t,"gutter"),Et=n.dwg_dynapi_entity_data(t,"num_column_heights"),At=n.dwg_dynapi_entity_data(t,"column_heights"),yt=n.dwg_ptr_to_double_array(At,Et);return{type:"MTEXT",...o,insertionPoint:s,textHeight:_,rectHeight:l,rectWidth:f,extentsHeight:g,extentsWidth:h,attachmentPoint:y,drawingDirection:P,text:p,styleName:I,extrusionDirection:C,direction:w,rotation:0,lineSpacingStyle:m,lineSpacing:S,backgroundFill:N,fillBoxScale:W,...U!==void 0?{backgroundFillColor:U}:{},backgroundFillTransparency:O,columnType:J,columnFlowReversed:nt,columnAutoHeight:gt,columnWidth:Z,columnGutter:ut,columnHeightCount:Et,columnHeights:yt}}convertPoint(t,o){const n=this.libredwg,s=n.dwg_dynapi_entity_data(t,"x"),_=n.dwg_dynapi_entity_data(t,"y"),l=n.dwg_dynapi_entity_data(t,"z"),f=n.dwg_dynapi_entity_data(t,"thickness"),h=n.dwg_dynapi_entity_data(t,"extrusion"),g=n.dwg_dynapi_entity_data(t,"x_ang");return{type:"POINT",...o,position:{x:s,y:_,z:l},thickness:f,extrusionDirection:h,angle:g}}convertMesh(t,o){const{subdivisionLevel:n,vertices:s,faces:_}=this.libredwg.dwg_entity_mesh_get_data(o);return{type:"MESH",...t,subdivisionLevel:n,vertices:s,faces:_}}convertPolyline2d(t,o,n){const s=this.libredwg,_=s.dwg_dynapi_entity_data(t,"flag"),l=s.dwg_dynapi_entity_data(t,"curve_type"),f=s.dwg_dynapi_entity_data(t,"start_width"),h=s.dwg_dynapi_entity_data(t,"end_width"),g=s.dwg_dynapi_entity_data(t,"elevation"),y=s.dwg_dynapi_entity_data(t,"thickness"),P=s.dwg_dynapi_entity_data(t,"extrusion"),p=s.dwg_entity_polyline_2d_get_vertices(n)??[];return{type:"POLYLINE2D",...o,flag:_,smoothType:l,startWidth:f,endWidth:h,elevation:g,thickness:y,extrusionDirection:P,vertices:p.map(I=>({x:I.point.x,y:I.point.y,z:I.point.z,startWidth:I.start_width,endWidth:I.end_width,bulge:I.bulge,flag:I.flag,tangentDirection:I.tangent_dir})),meshMVertexCount:0,meshNVertexCount:0,surfaceMDensity:0,surfaceNDensity:0}}convertPolyline3d(t,o,n){const s=this.libredwg,_=s.dwg_dynapi_entity_data(t,"flag"),l=s.dwg_dynapi_entity_data(t,"curve_type"),f=s.dwg_dynapi_entity_data(t,"start_width"),h=s.dwg_dynapi_entity_data(t,"end_width"),g=s.dwg_dynapi_entity_data(t,"extrusion"),y=s.dwg_entity_polyline_3d_get_vertices(n)??[];return{type:"POLYLINE3D",...o,flag:_,smoothType:l,startWidth:f,endWidth:h,extrusionDirection:g,vertices:y.map(P=>({x:P.point.x,y:P.point.y,z:P.point.z,flag:P.flag}))}}convertProxyEntity(t,o,n){const s=this.libredwg,_=s.dwg_dynapi_entity_data(t,"proxy_id"),l=s.dwg_dynapi_entity_data(t,"class_id"),f=s.dwg_dynapi_entity_data(t,"data_numbits"),h=s.dwg_dynapi_entity_data(t,"version"),g=s.dwg_dynapi_entity_data(t,"from_dxf"),y=s.dwg_dynapi_entity_data(t,"num_objids"),P=s.dwg_entity_get_preview(n),p=(P==null?void 0:P.length)??0,I=s.dwg_entity_proxy_entity_get_entity_data(t),C=P?He(P):void 0,w=I?He(I):void 0;let m;if(y>0){const W=s.dwg_dynapi_entity_data(t,"objids");W&&(m=s.dwg_ptr_to_object_ref_array(W,y).map(O=>ht(O.absolute_ref)))}const S=this.getOriginalDxfName(l),N={type:"ACAD_PROXY_ENTITY",subclassMarker:"AcDbProxyEntity",...o,proxyEntityClassId:_||498,applicationEntityClassId:l};return S&&(N.originalDxfName=S),p>0&&(N.graphicsDataSize=p),C&&(N.graphicsData=C),f>0&&(N.entityDataSize=f),w&&(N.entityData=w),m&&m.length>0&&(N.linkedObjectIds=m),h&&(N.objectDrawingFormat=h),(g===0||g===1)&&(N.originalDataFormat=g),N}getOriginalDxfName(t){if(this.classes.length===0||t<0)return;const o=t>=500?t-500:t;if(o>=0&&o<this.classes.length)return this.classes[o].dxfName}convertRay(t,o){const n=this.libredwg,s=n.dwg_dynapi_entity_data(t,"point"),_=n.dwg_dynapi_entity_data(t,"vector");return{type:"RAY",...o,firstPoint:s,unitDirection:_}}convertSection(t,o){const n=this.libredwg,s=n.dwg_dynapi_entity_data(t,"state"),_=n.dwg_dynapi_entity_data(t,"flag"),l=n.dwg_dynapi_entity_data(t,"name"),f=n.dwg_dynapi_entity_data(t,"vert_dir"),h=n.dwg_dynapi_entity_data(t,"top_height"),g=n.dwg_dynapi_entity_data(t,"bottom_height"),y=n.dwg_dynapi_entity_data(t,"indicator_alpha"),P=n.dwg_dynapi_entity_data(t,"indicator_color"),p=n.dwg_dynapi_entity_data(t,"num_verts"),I=n.dwg_dynapi_entity_data(t,"verts"),C=p>0?n.dwg_ptr_to_point3d_array(I,p):[],w=n.dwg_dynapi_entity_data(t,"num_blverts"),m=n.dwg_dynapi_entity_data(t,"blverts"),S=w>0?n.dwg_ptr_to_point3d_array(m,w):[],N=n.dwg_dynapi_entity_data(t,"geometrySettingHardId"),W=n.dwg_ref_get_handle_absolute_ref(N)??0n;return{type:"SECTION",...o,state:s,flags:_,name:l,verticalDirection:f,topHeight:h,bottomHeight:g,indicatorTransparency:y,indicatorColor:P.rgb,numberOfVertices:p,vertices:C,numberOfBackLineVertices:w,backLineVertices:S,geometrySettingHardId:W}}convertShape(t,o){const n=this.libredwg,s=n.dwg_dynapi_entity_data(t,"ins_pt"),_=n.dwg_dynapi_entity_data(t,"scale"),l=n.dwg_dynapi_entity_data(t,"rotation"),f=n.dwg_dynapi_entity_data(t,"width_factor"),h=n.dwg_dynapi_entity_data(t,"oblique_angle"),g=n.dwg_dynapi_entity_data(t,"thickness"),y=n.dwg_dynapi_entity_data(t,"extrusion"),P=n.dwg_dynapi_entity_data(t,"style_id"),p=n.dwg_entity_text_get_style_name(t);return{type:"SHAPE",subclassMarker:"AcDbShape",...o,thickness:g,insertionPoint:s,size:_,shapeNumber:P,styleName:p,rotation:l,xScale:f,obliqueAngle:h,extrusionDirection:y}}convertSolid(t,o){const n=this.libredwg,s=n.dwg_dynapi_entity_data(t,"corner1"),_=n.dwg_dynapi_entity_data(t,"corner2"),l=n.dwg_dynapi_entity_data(t,"corner3"),f=n.dwg_dynapi_entity_data(t,"corner4"),h=n.dwg_dynapi_entity_data(t,"thickness"),g=n.dwg_dynapi_entity_data(t,"extrusion");return{type:"SOLID",...o,corner1:s,corner2:_,corner3:l,corner4:f,thickness:h,extrusionDirection:g}}convertTrace(t,o){return{...this.convertSolid(t,o),type:"TRACE"}}convertSpline(t,o){const n=this.libredwg,s=n.dwg_dynapi_entity_data(t,"splineflags"),_=n.dwg_dynapi_entity_data(t,"degree"),l=n.dwg_dynapi_entity_data(t,"knot_tol"),f=n.dwg_dynapi_entity_data(t,"num_knots"),h=n.dwg_dynapi_entity_data(t,"knots"),g=n.dwg_ptr_to_double_array(h,f),y=n.dwg_dynapi_entity_data(t,"fit_tol"),P=n.dwg_dynapi_entity_data(t,"num_fit_pts"),p=n.dwg_dynapi_entity_data(t,"fit_pts"),I=n.dwg_ptr_to_point3d_array(p,P),C=n.dwg_dynapi_entity_data(t,"weighted"),w=n.dwg_dynapi_entity_data(t,"ctrl_tol"),m=n.dwg_dynapi_entity_data(t,"num_ctrl_pts"),S=n.dwg_dynapi_entity_data(t,"ctrl_pts"),N=n.dwg_ptr_to_point4d_array(S,m),W=n.dwg_dynapi_entity_data(t,"beg_tan_vec"),M=n.dwg_dynapi_entity_data(t,"end_tan_vec");return{type:"SPLINE",...o,flag:s,degree:_,numberOfKnots:f,numberOfControlPoints:m,numberOfFitPoints:P,knotTolerance:l,controlTolerance:w,fitTolerance:y,startTangent:W,endTangent:M,knots:g,weights:C?N.map(O=>O.w):void 0,controlPoints:N.map(O=>({x:O.x,y:O.y,z:O.z})),fitPoints:I}}convertTable(t,o){const n=this.libredwg,s=n.dwg_dynapi_subclass_data(t,"ldata","name"),_=n.dwg_dynapi_entity_data(t,"ins_pt"),l=n.dwg_dynapi_entity_data(t,"horiz_direction"),f=n.dwg_dynapi_entity_data(t,"flag_for_table_value"),h=n.dwg_dynapi_entity_data(t,"num_rows"),g=n.dwg_dynapi_entity_data(t,"num_cols"),y=n.dwg_dynapi_entity_data(t,"row_heights"),P=n.dwg_ptr_to_double_array(y,h),p=n.dwg_dynapi_entity_data(t,"col_widths"),I=n.dwg_ptr_to_double_array(p,g),C=n.dwg_dynapi_entity_data(t,"tablestyle"),w=n.dwg_ref_get_id(C)??"",m=n.dwg_dynapi_entity_data(t,"block_header"),S=n.dwg_ref_get_id(m)??"",N=n.dwg_dynapi_entity_data(t,"table_flag_override"),W=n.dwg_dynapi_entity_data(t,"border_color_overrides_flag"),M=n.dwg_dynapi_entity_data(t,"border_lineweight_overrides_flag"),O=n.dwg_dynapi_entity_data(t,"border_visibility_overrides_flag"),U=n.dwg_dynapi_entity_data(t,"num_cells"),J=n.dwg_dynapi_entity_data(t,"cells"),nt=n.dwg_ptr_to_table_cell_array(J,U);return{type:"ACAD_TABLE",...o,name:s,startPoint:_,directionVector:l,tableValue:f,rowCount:h,columnCount:g,overrideFlag:N,borderColorOverrideFlag:W,borderLineWeightOverrideFlag:M,borderVisibilityOverrideFlag:O,rowHeightArr:P,columnWidthArr:I,tableStyleId:w,blockRecordHandle:S,cells:this.convertTableCells(nt),bmpPreview:""}}convertTableCells(t){return t.map(o=>{var n,s;return{text:o.text_value,attachmentPoint:o.cell_alignment,textStyle:o.text_style?String(o.text_style):void 0,rotation:o.rotation,cellType:o.type,flagValue:o.flags,mergedValue:o.is_merged_value,autoFit:o.is_autofit_flag,topBorderVisibility:!!o.top_visibility,bottomBorderVisibility:!!o.bottom_visibility,leftBorderVisibility:!!o.left_visibility,rightBorderVisibility:!!o.right_visibility,overrideFlag:o.cell_flag_override,virtualEdgeFlag:o.virtual_edge_flag,blockTableRecordId:o.block_handle?String(o.block_handle.absolute_ref??""):void 0,blockScale:o.block_scale,blockAttrNum:((n=o.attr_defs)==null?void 0:n.length)??0,attrDefineId:(s=o.attr_defs)==null?void 0:s.map(_=>{var l;return String(((l=_.attdef)==null?void 0:l.absolute_ref)??"")}),textHeight:o.text_height??0,extendedCellFlags:o.additional_data_flag}})}convertTextBase(t){const o=this.libredwg,n=o.dwg_dynapi_entity_data(t,"text_value"),s=o.dwg_dynapi_entity_data(t,"thickness"),_=o.dwg_dynapi_entity_data(t,"ins_pt"),l=o.dwg_dynapi_entity_data(t,"alignment_pt"),f=o.dwg_dynapi_entity_data(t,"rotation"),h=o.dwg_dynapi_entity_data(t,"height"),g=o.dwg_dynapi_entity_data(t,"width_factor"),y=o.dwg_dynapi_entity_data(t,"oblique_angle"),P=o.dwg_entity_text_get_style_name(t),p=o.dwg_dynapi_entity_data(t,"generation"),I=o.dwg_dynapi_entity_data(t,"horiz_alignment"),C=o.dwg_dynapi_entity_data(t,"vert_alignment"),w=o.dwg_dynapi_entity_data(t,"elevation"),m=o.dwg_dynapi_entity_data(t,"extrusion");return{text:n,thickness:s,startPoint:_,endPoint:l,textHeight:h,rotation:f,xScale:g,obliqueAngle:y,styleName:P,generationFlag:p,halign:I,valign:C,elevation:w,extrusionDirection:m}}convertText(t,o){return{type:"TEXT",...o,...this.convertTextBase(t)}}convertTolerance(t,o){const n=this.libredwg,s=n.dwg_dynapi_entity_data(t,"ins_pt"),_=n.dwg_dynapi_entity_data(t,"text_value"),l=n.dwg_dynapi_entity_data(t,"x_direction"),f=n.dwg_dynapi_entity_data(t,"extrusion"),h=n.dwg_entity_get_dimstyle_name(t);return{type:"TOLERANCE",...o,styleName:h,insertionPoint:s,text:_,extrusionDirection:f,xAxisDirection:l}}convertViewport(t,o){const n=this.libredwg,s=n.dwg_dynapi_entity_data(t,"center"),_=n.dwg_dynapi_entity_data(t,"width"),l=n.dwg_dynapi_entity_data(t,"height"),f=n.dwg_dynapi_entity_data(t,"on_off"),h=n.dwg_dynapi_entity_data(t,"VIEWCTR"),g=n.dwg_dynapi_entity_data(t,"SNAPBASE"),y=n.dwg_dynapi_entity_data(t,"SNAPUNIT"),P=n.dwg_dynapi_entity_data(t,"GRIDUNIT"),p=n.dwg_dynapi_entity_data(t,"VIEWDIR"),I=n.dwg_dynapi_entity_data(t,"view_target"),C=n.dwg_dynapi_entity_data(t,"lens_length"),w=n.dwg_dynapi_entity_data(t,"front_clip_z"),m=n.dwg_dynapi_entity_data(t,"back_clip_z"),S=n.dwg_dynapi_entity_data(t,"VIEWSIZE"),N=n.dwg_dynapi_entity_data(t,"SNAPANG"),W=n.dwg_dynapi_entity_data(t,"twist_angle"),M=n.dwg_dynapi_entity_data(t,"circle_zoom"),O=n.dwg_dynapi_entity_data(t,"num_frozen_layers");let U;if(O>0){const Jt=n.dwg_dynapi_entity_data(t,"frozen_layers");Jt&&(U=n.dwg_ptr_to_object_ref_ptr_array(Jt,O).map(Ut=>n.dwg_ref_get_id(Ut)).filter(Ut=>!!Ut))}const J=n.dwg_dynapi_entity_data(t,"status_flag"),nt=n.dwg_dynapi_entity_data(t,"clip_boundary"),gt=n.dwg_ref_get_id(nt),Z=n.dwg_dynapi_entity_data(t,"style_sheet"),ut=n.dwg_dynapi_entity_data(t,"render_mode"),Et=n.dwg_dynapi_entity_data(t,"UCSVP"),At=n.dwg_dynapi_entity_data(t,"ucsorg"),yt=n.dwg_dynapi_entity_data(t,"ucsxdir"),Mt=n.dwg_dynapi_entity_data(t,"ucsydir"),bt=n.dwg_dynapi_entity_data(t,"named_ucs"),xt=n.dwg_ref_get_id(bt),Ot=n.dwg_dynapi_entity_data(t,"base_ucs"),dt=n.dwg_ref_get_id(Ot),k=n.dwg_dynapi_entity_data(t,"UCSORTHOVIEW"),tt=n.dwg_dynapi_entity_data(t,"ucs_elevation"),z=n.dwg_dynapi_entity_data(t,"shadeplot_mode"),kt=n.dwg_dynapi_entity_data(t,"use_default_lights"),Bt=n.dwg_dynapi_entity_data(t,"default_lighting_type"),Tt=n.dwg_dynapi_entity_data(t,"brightness"),B=n.dwg_dynapi_entity_data(t,"contrast"),Xt=n.dwg_dynapi_entity_data(t,"grid_major"),lt=n.dwg_dynapi_entity_data(t,"background"),St=n.dwg_ref_get_id(lt),Kt=n.dwg_dynapi_entity_data(t,"shadeplot"),se=n.dwg_ref_get_id(Kt),zt=n.dwg_dynapi_entity_data(t,"visualstyle"),Ft=n.dwg_ref_get_id(zt),q=n.dwg_dynapi_entity_data(t,"sun"),V=n.dwg_ref_get_id(q);return{type:"VIEWPORT",...o,viewportCenter:s,width:_,height:l,status:f,viewportId:0,displayCenter:h,snapBase:g,snapSpacing:y,gridSpacing:P,viewDirection:p,targetPoint:I,perspectiveLensLength:C,frontClipZ:w,backClipZ:m,viewHeight:S,snapAngle:N,viewTwistAngle:W,circleZoomPercent:M,frozenLayerIds:U,statusBitFlags:J,clippingBoundaryId:gt,sheetName:Z,renderMode:ut,ucsPerViewport:Et,ucsOrigin:At,ucsXAxis:yt,ucsYAxis:Mt,ucsId:xt??"",ucsBaseId:dt??"",orthographicType:k,elevation:tt,shadePlotMode:z,majorGridFrequency:Xt,backgroundId:St??"",shadePlotId:se??"",visualStyleId:Ft??"",isDefaultLighting:!!kt,defaultLightingType:Bt,brightness:Tt,contrast:B,sunId:V??""}}convertWipeout(t,o){const n=this.libredwg,s=n.dwg_dynapi_entity_data(t,"class_version"),_=n.dwg_dynapi_entity_data(t,"pt0"),l=n.dwg_dynapi_entity_data(t,"uvec"),f=n.dwg_dynapi_entity_data(t,"vvec"),h=n.dwg_dynapi_entity_data(t,"image_size"),g=n.dwg_dynapi_entity_data(t,"display_props"),y=n.dwg_dynapi_entity_data(t,"clipping"),P=n.dwg_dynapi_entity_data(t,"brightness"),p=n.dwg_dynapi_entity_data(t,"contrast"),I=n.dwg_dynapi_entity_data(t,"fade"),C=n.dwg_dynapi_entity_data(t,"clip_mode"),w=n.dwg_dynapi_entity_data(t,"clip_boundary_type"),m=n.dwg_dynapi_entity_data(t,"num_clip_verts"),S=n.dwg_dynapi_entity_data(t,"clip_verts"),N=n.dwg_ptr_to_point2d_array(S,m),W=n.dwg_dynapi_entity_data(t,"imagedef"),M=n.dwg_ref_get_absref(W)??0,O=n.dwg_dynapi_entity_data(t,"imagedefreactor"),U=n.dwg_ref_get_absref(O)??0;return{type:"WIPEOUT",...o,version:s,position:_,uPixel:l,vPixel:f,imageSize:h,imageDefHandle:M,flags:g,clipping:y,brightness:P,contrast:p,fade:I,imageDefReactorHandle:U,clippingBoundaryType:w,countBoundaryPoints:m,clippingBoundaryPath:N,clipMode:C}}convertXline(t,o){const n=this.libredwg,s=n.dwg_dynapi_entity_data(t,"point"),_=n.dwg_dynapi_entity_data(t,"vector");return{type:"XLINE",...o,firstPoint:s,unitDirection:_}}getDimensionCommonAttrs(t){const o=this.libredwg,n=o.dwg_dynapi_entity_data(t,"class_version"),s=o.dwg_entity_get_block_name(t,"block"),_=o.dwg_dynapi_entity_data(t,"def_pt"),l=o.dwg_dynapi_entity_data(t,"text_midpt"),f=o.dwg_dynapi_entity_data(t,"attachmentPoint"),h=o.dwg_dynapi_entity_data(t,"flag"),g=o.dwg_dynapi_entity_data(t,"lspace_factor"),y=o.dwg_dynapi_entity_data(t,"lspace_factor"),P=o.dwg_dynapi_entity_data(t,"act_measurement"),p=o.dwg_dynapi_entity_data(t,"user_text"),I=o.dwg_dynapi_entity_data(t,"text_rotation"),C=o.dwg_dynapi_entity_data(t,"ins_rotation"),w=o.dwg_dynapi_entity_data(t,"extrusion"),m=o.dwg_entity_get_dimstyle_name(t);return{type:"DIMENSION",version:n,name:s,definitionPoint:_,textPoint:l,dimensionType:h,attachmentPoint:f,textLineSpacingStyle:g,textLineSpacingFactor:y||1,measurement:P,text:p,textRotation:I,ocsRotation:C,extrusionDirection:w,styleName:m}}getCommonAttrs(t){const o=this.libredwg,n=o.dwg_object_entity_get_color_object(t),s=n.method,_=n.index;let l;(s==194||(n.rgb>>>24&255)===194)&&(l=n.rgb&16777215);const f=this.getLayerName(t),h=o.dwg_object_entity_get_handle_object(t),g=o.dwg_object_entity_get_ownerhandle_object(t),y=o.dwg_object_entity_get_xdicobjhandle_object(t),P=this.getLtypeName(t),p=o.dwg_object_entity_get_line_weight(t),I=o.dwg_object_entity_get_ltype_scale(t),C=!o.dwg_object_entity_get_invisible(t),w=o.dwg_object_entity_get_xdata(t);return{handle:ht(h.value),ownerDictionaryHardId:ht(y.absolute_ref),ownerBlockRecordSoftId:ht(g.absolute_ref),layer:f,color:l,colorIndex:_,colorName:n.name,lineType:P,lineweight:p,lineTypeScale:I,isVisible:C,transparency:n.alpha,transparencyType:n.alpha_type,xdata:w}}getLayerName(t){const n=this.libredwg.dwg_object_entity_get_layer_object_ref(t);return this.layers.get(ht(n.handleref.value))??"0"}getLtypeName(t){const n=this.libredwg.dwg_object_entity_get_ltype_object_ref(t);return this.ltypes.get(ht(n.handleref.value))??""}}class Er{constructor(t){et(this,"libredwg"),et(this,"entityConverter"),et(this,"orphanEntitiesByBlock",null),et(this,"ownerlessOrphanIndices",null),et(this,"orphanIndexDataPtr",null),et(this,"layerPlotFlagSupported",!0),this.libredwg=t,this.entityConverter=new Yo(t)}convert(t){var o;this.entityConverter.clear(),this.orphanEntitiesByBlock=null,this.ownerlessOrphanIndices=null,this.orphanIndexDataPtr=t,this.layerPlotFlagSupported=!0;const n={tables:{APPID:{entries:[]},BLOCK_RECORD:{entries:[]},DIMSTYLE:{entries:[]},LAYER:{entries:[]},LTYPE:{entries:[]},STYLE:{entries:[]},VPORT:{entries:[]}},objects:{ASSOCNETWORK:[],ASSOCACTION:[],ASSOCDEPENDENCY:[],ASSOCARRAYACTIONBODY:[],ASSOCVERTEXACTIONPARAM:[],ASSOCEDGEACTIONPARAM:[],DICTIONARY:[],GROUP:[],IMAGEDEF:[],LAYER_FILTER:[],LAYER_INDEX:[],LAYOUT:[],MLEADERSTYLE:[],SPATIAL_FILTER:[],XRECORD:[]},header:{},entities:[],classes:[]},s=this.libredwg;this.convertHeader(t,n.header),this.layerPlotFlagSupported=s.dwg_get_version_type(t).version>=22,this.convertClasses(t,n.classes),this.entityConverter.setClasses(n.classes);const _=s.dwg_get_num_objects(t);for(let h=0;h<_;h++){const g=s.dwg_get_object(t,h);if(g){const y=this.safeObjectTio(g);if(y)switch(s.dwg_object_get_fixedtype(g)){case R.DWG_TYPE_LAYER:{const p=this.convertLayer(y,g);n.tables.LAYER.entries.push(p),this.entityConverter.layers.set(p.handle,p.name)}break;case R.DWG_TYPE_LTYPE:{const p=this.convertLineType(y,g);n.tables.LTYPE.entries.push(p),this.entityConverter.ltypes.set(p.handle,p.name)}break}}}for(let h=0;h<_;h++){const g=s.dwg_get_object(t,h);if(g){const y=this.safeObjectTio(g);if(y)switch(s.dwg_object_get_fixedtype(g)){case R.DWG_TYPE_APPID:n.tables.APPID.entries.push(this.convertAppId(y));break;case R.DWG_TYPE_BLOCK_HEADER:{const p=this.convertBlockRecord(y,g);n.tables.BLOCK_RECORD.entries.push(p),(Wn(p.name)||So(p.name))&&p.entities.forEach(I=>{n.entities.push(I),I.type==="INSERT"&&I.attribs.forEach(C=>{n.entities.push(C)})})}break;case R.DWG_TYPE_DIMSTYLE:n.tables.DIMSTYLE.entries.push(this.convertDimStyle(y,g));break;case R.DWG_TYPE_STYLE:n.tables.STYLE.entries.push(this.convertStyle(y,g));break;case R.DWG_TYPE_VPORT:n.tables.VPORT.entries.push(this.convertViewport(y,g));break;case R.DWG_TYPE_DICTIONARY:n.objects.DICTIONARY.push(this.convertDictionary(y,g));break;case R.DWG_TYPE_GROUP:n.objects.GROUP.push(this.convertGroup(y,g));break;case R.DWG_TYPE_IMAGEDEF:n.objects.IMAGEDEF.push(this.convertImageDef(y,g));break;case R.DWG_TYPE_LAYERFILTER:n.objects.LAYER_FILTER.push(this.convertLayerFilter(y,g));break;case R.DWG_TYPE_LAYER_INDEX:n.objects.LAYER_INDEX.push(this.convertLayerIndex(y,g));break;case R.DWG_TYPE_LAYOUT:n.objects.LAYOUT.push(this.convertLayout(y,g));break;case R.DWG_TYPE_MLEADERSTYLE:n.objects.MLEADERSTYLE.push(this.convertMLeaderStyle(y,g));break;case R.DWG_TYPE_SPATIAL_FILTER:n.objects.SPATIAL_FILTER.push(this.convertSpatialFilter(y,g));break;case R.DWG_TYPE_XRECORD:n.objects.XRECORD.push(this.convertXRecord(y,g));break;case R.DWG_TYPE_ASSOCNETWORK:n.objects.ASSOCNETWORK.push(this.convertAssocNetwork(y,g));break;case R.DWG_TYPE_ASSOCACTION:n.objects.ASSOCACTION.push(this.convertAssocAction(y,g));break;case R.DWG_TYPE_ASSOCDEPENDENCY:n.objects.ASSOCDEPENDENCY.push(this.convertAssocDependency(y,g));break;case R.DWG_TYPE_ASSOCARRAYACTIONBODY:n.objects.ASSOCARRAYACTIONBODY.push(this.convertAssocArrayActionBody(y,g));break;case R.DWG_TYPE_ASSOCVERTEXACTIONPARAM:n.objects.ASSOCVERTEXACTIONPARAM.push(this.convertAssocVertexActionParam(y,g));break;case R.DWG_TYPE_ASSOCEDGEACTIONPARAM:n.objects.ASSOCEDGEACTIONPARAM.push(this.convertAssocEdgeActionParam(y,g));break}}}const l=n.entities.filter(h=>h.type==="VIEWPORT");l.sort((h,g)=>{const y=parseInt(h.handle,16),P=parseInt(g.handle,16);return y-P}),l.forEach((h,g)=>{h.viewportId=g+1});const f=s.dwg_bmp(t);return(o=f==null?void 0:f.data)!=null&&o.length&&(n.thumbnailImage=f.data),n}getConversionStats(){return{unknownEntityCount:this.entityConverter.unknownEntityCount}}safeObjectTio(t){const o=this.libredwg;try{if(o.dwg_object_get_supertype(t)!=Yn.DWG_SUPERTYPE_OBJECT)return null;const n=o.dwg_object_to_object_tio(t);return n||null}catch{return null}}convertHeader(t,o){const n=this.libredwg;vo.forEach(s=>{let _=s;(s=="DIMBLK"||s=="DIMBLK1"||s=="DIMBLK2")&&(_=_+"_T");let l=n.dwg_dynapi_header_data(t,_);s=="CELTYPE"||s=="CLAYER"||s=="CLAYER"||s=="DIMSTYLE"||s=="DIMTXSTY"||s=="TEXTSTYLE"?l=l?n.dwg_ref_get_object_name(l):"":s=="DRAGVS"&&(l=l?n.dwg_ref_get_absref(l)??2:2),o[s]=l})}convertClasses(t,o){const n=this.libredwg,s=n.dwg_get_num_classes(t);for(let _=0;_<s;_++){const l=n.dwg_get_class(t,_);o.push({dxfName:l.dxfname,cppName:l.cppname,appName:l.appname,capabilitiesFlag:l.proxyflag,instanceCount:l.num_instances,wasAProxyFlag:l.s_zombie,isAnEntityFlag:l.item_class_id===498})}}convertAppId(t){const o=this.libredwg,n=o.dwg_dynapi_entity_data(t,"name"),s=o.dwg_dynapi_entity_data(t,"flag");return{name:n,standardFlag:s}}convertBlockRecord(t,o){const n=this.libredwg,s=this.getCommonTableEntryAttrs(t,o),_=n.dwg_entity_block_header_get_block(t);_.name&&(s.name=_.name);const l=n.dwg_dynapi_entity_data(t,"num_owned"),f=n.dwg_dynapi_entity_data(t,"flag"),h=n.dwg_dynapi_entity_data(t,"description"),g=n.dwg_dynapi_entity_data(t,"base_pt"),y=n.dwg_dynapi_entity_data(t,"insert_units"),P=n.dwg_dynapi_entity_data(t,"explodable"),p=n.dwg_dynapi_entity_data(t,"block_scaling"),I=n.dwg_dynapi_entity_data(t,"layout"),C=n.dwg_ref_get_id(I)??"";let w;const m=n.dwg_entity_block_header_get_preview(t);m&&m.length>0&&(w=He(m));let S=this.convertEntities(o,s.handle);if(!S||S.length==0){S=[];const N=n.dwg_dynapi_entity_data(t,"entities");if(N){const W=n.dwg_ptr_to_object_ref_ptr_array(N,l),M=this.entityConverter;for(let O=0;O<l;O++){const U=n.dwg_ref_get_object(W[O]),J=M.convert(U);J&&(J.ownerBlockRecordSoftId=s.handle,S.push(J))}}}if(this.orphanIndexDataPtr!=null){const N=this.convertOrphanOwnedEntities(this.orphanIndexDataPtr,o,s.handle,Wn(s.name)===!0);if(N.length)if(S.length===0)S=N;else{const W=new Set(S.map(M=>M.handle));for(const M of N)W.has(M.handle)||S.push(M)}}return{...s,flags:f,description:h,basePoint:g,layout:C,insertionUnits:y,explodability:P,scalability:p,bmpPreview:w,entities:S}}convertEntities(t,o){const n=this.libredwg,s=this.entityConverter,_=[];let l=n.get_first_owned_entity(t);for(;l;){const f=s.convert(l);f&&(f.ownerBlockRecordSoftId=o,_.push(f)),l=n.get_next_owned_entity(t,l)}return _}convertOrphanOwnedEntities(t,o,n,s){this.ensureOrphanEntityIndex(t);const l=(this.orphanEntitiesByBlock??new Map).get(o)??[],f=s&&this.ownerlessOrphanIndices?this.ownerlessOrphanIndices:[],h=l.length&&f.length?l.concat(f):l.length?l:f;if(h.length===0)return[];const g=this.libredwg,y=this.entityConverter,P=[];for(const p of h){const I=g.dwg_get_object(t,p),C=y.convert(I);C&&(C.ownerBlockRecordSoftId=n,P.push(C))}return P}isOwnedByMissingBlock(t,o){if(!o)return!1;const n=this.libredwg;try{const s=n.dwg_dynapi_common_value(o,"entmode");if(!s.success||Number(s.data)!==0)return!1;const _=n.dwg_dynapi_common_value(o,"ownerhandle");if(!_.success||!_.data)return!1;const l=n.dwg_ref_get_absref(_.data);return l==null?!1:!n.dwg_resolve_handle_silent(t,BigInt(l))}catch{return!1}}ensureOrphanEntityIndex(t){if(this.orphanEntitiesByBlock)return;const o=this.libredwg,n=o.dwg_get_num_objects(t),s=new Map,_=[],l=[],f=new Map;for(let P=0;P<n;P++){const p=o.dwg_get_object(t,P);if(p){if(o.dwg_object_get_supertype(p)===Yn.DWG_SUPERTYPE_ENTITY)_.push(P),s.set(p,P);else if(o.dwg_object_get_fixedtype(p)===R.DWG_TYPE_BLOCK_HEADER){l.push(p);const I=o.dwg_object_to_object_tio(p);I&&f.set(I,p)}}}const h=new Set;for(const P of l){let p=o.get_first_owned_entity(P),I=0;for(;p&&I++<=_.length;){const C=s.get(p);if(C===void 0||h.has(C))break;h.add(C),p=o.get_next_owned_entity(P,p)}}const g=new Map,y=[];for(const P of _){if(h.has(P))continue;const p=o.dwg_get_object(t,P),I=p?o.dwg_object_to_entity_tio(p):0,C=I?o.dwg_entity_owner(I):0,w=C?f.get(C)??0:0;if(w){const m=g.get(w);m?m.push(P):g.set(w,[P])}else this.isOwnedByMissingBlock(t,I)||y.push(P)}this.orphanEntitiesByBlock=g,this.ownerlessOrphanIndices=y}convertDimStyle(t,o){const n=this.libredwg,s=this.getCommonTableEntryAttrs(t,o),_=n.dwg_dynapi_entity_data(t,"DIMTOL"),l=n.dwg_dynapi_entity_data(t,"DIMLIM"),f=n.dwg_dynapi_entity_data(t,"DIMTIH"),h=n.dwg_dynapi_entity_data(t,"DIMTOH"),g=n.dwg_dynapi_entity_data(t,"DIMSE1"),y=n.dwg_dynapi_entity_data(t,"DIMSE2"),P=n.dwg_dynapi_entity_data(t,"DIMALT"),p=n.dwg_dynapi_entity_data(t,"DIMTOFL"),I=n.dwg_dynapi_entity_data(t,"DIMSAH"),C=n.dwg_dynapi_entity_data(t,"DIMTIX"),w=n.dwg_dynapi_entity_data(t,"DIMSOXD"),m=n.dwg_dynapi_entity_data(t,"DIMALTD"),S=n.dwg_dynapi_entity_data(t,"DIMZIN"),N=n.dwg_dynapi_entity_data(t,"DIMSD1"),W=n.dwg_dynapi_entity_data(t,"DIMSD2"),M=n.dwg_dynapi_entity_data(t,"DIMTOLJ"),O=n.dwg_dynapi_entity_data(t,"DIMJUST"),U=n.dwg_dynapi_entity_data(t,"DIMFIT"),J=n.dwg_dynapi_entity_data(t,"DIMUPT"),nt=n.dwg_dynapi_entity_data(t,"DIMTZIN"),gt=n.dwg_dynapi_entity_data(t,"DIMALTZ"),Z=n.dwg_dynapi_entity_data(t,"DIMALTTZ"),ut=n.dwg_dynapi_entity_data(t,"DIMTAD"),Et=n.dwg_dynapi_entity_data(t,"DIMUNIT"),At=n.dwg_dynapi_entity_data(t,"DIMAUNIT"),yt=n.dwg_dynapi_entity_data(t,"DIMDEC"),Mt=n.dwg_dynapi_entity_data(t,"DIMTDEC"),bt=n.dwg_dynapi_entity_data(t,"DIMALTU"),xt=n.dwg_dynapi_entity_data(t,"DIMALTTD"),Ot=n.dwg_dynapi_entity_data(t,"DIMSCALE"),dt=n.dwg_dynapi_entity_data(t,"DIMASZ"),k=n.dwg_dynapi_entity_data(t,"DIMEXO"),tt=n.dwg_dynapi_entity_data(t,"DIMDLI"),z=n.dwg_dynapi_entity_data(t,"DIMEXE"),kt=n.dwg_dynapi_entity_data(t,"DIMRND"),Bt=n.dwg_dynapi_entity_data(t,"DIMDLE"),Tt=n.dwg_dynapi_entity_data(t,"DIMTP"),B=n.dwg_dynapi_entity_data(t,"DIMTM"),Xt=n.dwg_dynapi_entity_data(t,"DIMFXL"),lt=n.dwg_dynapi_entity_data(t,"DIMJOGANG"),St=n.dwg_dynapi_entity_data(t,"DIMTFILL"),Kt=n.dwg_dynapi_entity_data(t,"DIMTFILLCLR"),se=n.dwg_dynapi_entity_data(t,"DIMAZIN"),zt=n.dwg_dynapi_entity_data(t,"DIMARCSYM"),Ft=n.dwg_dynapi_entity_data(t,"DIMTXT"),q=n.dwg_dynapi_entity_data(t,"DIMCEN"),V=n.dwg_dynapi_entity_data(t,"DIMTSZ"),Jt=n.dwg_dynapi_entity_data(t,"DIMALTF"),ye=n.dwg_dynapi_entity_data(t,"DIMLFAC"),Ut=n.dwg_dynapi_entity_data(t,"DIMTVP"),Ye=n.dwg_dynapi_entity_data(t,"DIMTFAC"),Te=n.dwg_dynapi_entity_data(t,"DIMGAP"),Ne=n.dwg_dynapi_entity_data(t,"DIMPOST"),Zt=n.dwg_dynapi_entity_data(t,"DIMAPOST"),Lt=n.dwg_dynapi_entity_data(t,"DIMBLK_T"),X=n.dwg_dynapi_entity_data(t,"DIMBLK1_T"),We=n.dwg_dynapi_entity_data(t,"DIMBLK2_T"),qt=n.dwg_dynapi_entity_data(t,"DIMALTRND"),Dt=n.dwg_dynapi_entity_data(t,"DIMCLRD_N"),Pe=n.dwg_dynapi_entity_data(t,"DIMCLRE_N"),pe=n.dwg_dynapi_entity_data(t,"DIMCLRT_N"),Yt=n.dwg_dynapi_entity_data(t,"DIMCLRD"),_e=n.dwg_dynapi_entity_data(t,"DIMCLRE"),Nt=n.dwg_dynapi_entity_data(t,"DIMCLRT"),de=n.dwg_dynapi_entity_data(t,"DIMADEC"),Qt=n.dwg_dynapi_entity_data(t,"DIMFRAC"),ve=n.dwg_dynapi_entity_data(t,"DIMLUNIT"),Pt=n.dwg_dynapi_entity_data(t,"DIMDSEP"),le=n.dwg_dynapi_entity_data(t,"DIMTMOVE"),x=n.dwg_dynapi_entity_data(t,"DIMATFIT"),Ie=n.dwg_dynapi_entity_data(t,"DIMFXLON"),ce=n.dwg_dynapi_entity_data(t,"DIMTXTDIRECTION"),jt=n.dwg_dynapi_entity_data(t,"DIMALTMZF"),me=n.dwg_dynapi_entity_data(t,"DIMALTMZS"),we=n.dwg_dynapi_entity_data(t,"DIMMZF"),pt=n.dwg_dynapi_entity_data(t,"DIMMZS"),Wt=n.dwg_dynapi_entity_data(t,"DIMLWD"),Ce=n.dwg_dynapi_entity_data(t,"DIMLWE"),De=n.dwg_dynapi_entity_data(t,"DIMTXSTY"),ue=n.dwg_ref_get_absref(De)??void 0,Re=n.dwg_dynapi_entity_data(t,"DIMLDRBLK"),Ee=n.dwg_ref_get_absref(Re)??void 0;return{...s,DIMPOST:Ne,DIMAPOST:Zt,DIMBLK:Lt,DIMBLK1:X,DIMBLK2:We,DIMSCALE:Ot,DIMASZ:dt,DIMEXO:k,DIMDLI:tt,DIMEXE:z,DIMRND:kt,DIMDLE:Bt,DIMTP:Tt,DIMTM:B,DIMTXT:Ft,DIMCEN:q,DIMTSZ:V,DIMALTF:Jt,DIMLFAC:ye,DIMTVP:Ut,DIMTFAC:Ye,DIMGAP:Te,DIMALTRND:qt,DIMTOL:_,DIMLIM:l,DIMTIH:f,DIMTOH:h,DIMSE1:g,DIMSE2:y,DIMTAD:ut,DIMZIN:S,DIMAZIN:se,DIMALT:P,DIMALTD:m,DIMTOFL:p,DIMSAH:I,DIMTIX:C,DIMSOXD:w,DIMCLRD:Yt,DIMCLRE:_e,DIMCLRT:Nt,DIMADEC:de,DIMUNIT:Et,DIMDEC:yt,DIMTDEC:Mt,DIMALTU:bt,DIMALTTD:xt,DIMAUNIT:At,DIMFRAC:Qt,DIMLUNIT:ve,DIMDSEP:String.fromCharCode(Pt),DIMTMOVE:le,DIMJUST:O,DIMSD1:N,DIMSD2:W,DIMTOLJ:M,DIMTZIN:nt,DIMALTZ:gt,DIMALTTZ:Z,DIMFIT:U,DIMUPT:J,DIMATFIT:x,DIMTXSTY:ue,DIMLDRBLK:Ee,DIMLWD:Wt,DIMLWE:Ce,DIMFXL:Xt,DIMJOGANG:lt,DIMTFILL:St,DIMTFILLCLR:Kt,DIMARCSYM:zt,DIMCLRD_N:Dt,DIMCLRE_N:Pe,DIMCLRT_N:pe,DIMFXLON:Ie,DIMTXTDIRECTION:ce,DIMALTMZF:jt,DIMALTMZS:me,DIMMZF:we,DIMMZS:pt}}convertLayer(t,o){const n=this.libredwg,s=this.getCommonTableEntryAttrs(t,o),_=n.dwg_dynapi_entity_data(t,"flag"),l=n.dwg_dynapi_entity_data(t,"frozen"),f=n.dwg_dynapi_entity_data(t,"off"),h=n.dwg_dynapi_entity_data(t,"frozen_in_new"),g=n.dwg_dynapi_entity_data(t,"locked");let y=n.dwg_dynapi_entity_data(t,"plotflag");this.layerPlotFlagSupported||(y=1);const P=n.dwg_dynapi_entity_data(t,"linewt"),p=n.dwg_dynapi_entity_data(t,"color"),I=n.dwg_dynapi_entity_data(t,"ltype");let C="Continuous";if(I)try{C=n.dwg_ref_get_object_name(I)}catch{}const w=p.method;let m=256,S=16777215;return w===195||(p.rgb>>>24&255)===195?m=p.rgb&255:w==194||(p.rgb>>>24&255)===194?S=p.rgb&16777215:p.index>=1&&p.index<=255&&(m=p.index),{...s,standardFlag:_,colorIndex:m,color:S,colorName:p.name,transparency:p.alpha,lineType:C,frozen:l!=0,off:f!=0,frozenInNew:h!=0,locked:g!=0,plotFlag:y,lineweight:P,plotStyleNameObjectId:"",materialObjectId:""}}convertLineType(t,o){const n=this.libredwg,s=this.getCommonTableEntryAttrs(t,o),_=n.dwg_dynapi_entity_data(t,"flag"),l=n.dwg_dynapi_entity_data(t,"description"),f=n.dwg_dynapi_entity_data(t,"numdashes"),h=n.dwg_dynapi_entity_data(t,"pattern_len"),g=n.dwg_dynapi_entity_data(t,"dashes"),y=g?n.dwg_ptr_to_ltype_dash_array(g,f):[];return{...s,description:l,standardFlag:_,numberOfLineTypes:f,totalPatternLength:h,pattern:this.convertLineTypePattern(y)}}convertLineTypePattern(t){const o=[];return t.forEach(n=>{o.push({elementLength:n.length||0,elementTypeFlag:n.shape_flag||0,shapeNumber:n.complex_shapecode,scale:n.scale,rotation:n.rotation,offsetX:n.x_offset,offsetY:n.y_offset,text:n.text})}),o}convertStyle(t,o){const n=this.libredwg,s=this.getCommonTableEntryAttrs(t,o),_=n.dwg_dynapi_entity_data(t,"flag"),l=n.dwg_dynapi_entity_data(t,"width_factor"),f=n.dwg_dynapi_entity_data(t,"oblique_angle"),h=n.dwg_dynapi_entity_data(t,"generation"),g=n.dwg_dynapi_entity_data(t,"last_height"),y=n.dwg_dynapi_entity_data(t,"font_file"),P=n.dwg_dynapi_entity_data(t,"bigfont_file");return{...s,standardFlag:_,fixedTextHeight:0,widthFactor:l,obliqueAngle:f,textGenerationFlag:h,lastHeight:g,font:y,bigFont:P}}convertViewport(t,o){const n=this.libredwg,s=this.getCommonTableEntryAttrs(t,o),_=n.dwg_dynapi_entity_data(t,"flag"),l=n.dwg_dynapi_entity_data(t,"VIEWSIZE"),f=n.dwg_dynapi_entity_data(t,"aspect_ratio"),h=n.dwg_dynapi_entity_data(t,"VIEWCTR"),g=n.dwg_dynapi_entity_data(t,"view_target"),y=n.dwg_dynapi_entity_data(t,"VIEWDIR"),P=n.dwg_dynapi_entity_data(t,"view_twist"),p=n.dwg_dynapi_entity_data(t,"lens_length"),I=n.dwg_dynapi_entity_data(t,"front_clip_z"),C=n.dwg_dynapi_entity_data(t,"back_clip_z"),w=n.dwg_dynapi_entity_data(t,"VIEWMODE"),m=n.dwg_dynapi_entity_data(t,"render_mode"),S=n.dwg_dynapi_entity_data(t,"use_default_lights")!=0,N=n.dwg_dynapi_entity_data(t,"default_lightning_type"),W=n.dwg_dynapi_entity_data(t,"brightness"),M=n.dwg_dynapi_entity_data(t,"contrast"),O=n.dwg_dynapi_entity_data(t,"ambient_color"),U=n.dwg_dynapi_entity_data(t,"lower_left"),J=n.dwg_dynapi_entity_data(t,"upper_right"),nt=n.dwg_dynapi_entity_data(t,"circle_zoom"),gt=n.dwg_dynapi_entity_data(t,"UCSICON"),Z=n.dwg_dynapi_entity_data(t,"GRIDUNIT"),ut=n.dwg_dynapi_entity_data(t,"SNAPANG"),Et=n.dwg_dynapi_entity_data(t,"SNAPBASE"),At=n.dwg_dynapi_entity_data(t,"SNAPUNIT"),yt=n.dwg_dynapi_entity_data(t,"ucsorg"),Mt=n.dwg_dynapi_entity_data(t,"ucsxdir"),bt=n.dwg_dynapi_entity_data(t,"ucsydir"),xt=n.dwg_dynapi_entity_data(t,"ucs_elevation"),Ot=n.dwg_dynapi_entity_data(t,"grid_major"),dt=n.dwg_dynapi_entity_data(t,"background"),k=dt?n.dwg_ref_get_id(dt)??"":void 0,tt=n.dwg_dynapi_entity_data(t,"visualstyle"),z=tt?n.dwg_ref_get_id(tt)??"":void 0;return{...s,standardFlag:_,lowerLeftCorner:U,upperRightCorner:J,center:h,snapBasePoint:Et,snapSpacing:At,gridSpacing:Z,viewDirectionFromTarget:y,viewTarget:g,lensLength:p,frontClippingPlane:I,backClippingPlane:C,viewHeight:l,aspectRatio:f,snapRotationAngle:ut,viewTwistAngle:P,circleSides:nt,frozenLayers:[],styleSheet:"",renderMode:m,viewMode:w,ucsIconSetting:gt,ucsOrigin:yt,ucsXAxis:Mt,ucsYAxis:bt,orthographicType:0,elevation:xt,shadePlotSetting:0,majorGridLines:Ot,backgroundObjectId:k,visualStyleObjectId:z,isDefaultLightingOn:S,defaultLightingType:N,brightness:W,contrast:M,ambientColor:O.index}}getCommonTableEntryAttrs(t,o){const n=this.libredwg,s=n.dwg_object_get_tio(o),_=n.dwg_object_object_get_ownerhandle_object(s),l=n.dwg_object_get_handle_object(o);return{handle:ht(l.value),ownerHandle:ht(_.absolute_ref),name:n.dwg_dynapi_entity_data(t,"name")}}convertDictionary(t,o){const n=this.libredwg,s=this.getCommonObjectAttrs(o),_=n.dwg_dynapi_entity_data(t,"is_hardowner"),l=n.dwg_dynapi_entity_data(t,"cloning"),f=n.dwg_dynapi_entity_data(t,"numitems"),h=n.dwg_dynapi_entity_data(t,"itemhandles"),g=n.dwg_ptr_to_object_ref_array(h,f),y=n.dwg_object_dictionary_get_texts(o),P={};return g.forEach((p,I)=>P[y[I]]=ht(p.absolute_ref)),{...s,isHardOwner:!!_,cloningFlag:l,entries:P}}convertImageDef(t,o){const n=this.libredwg,s=this.getCommonObjectAttrs(o),_=n.dwg_dynapi_entity_data(t,"image_size"),l=n.dwg_dynapi_entity_data(t,"file_path"),f=n.dwg_dynapi_entity_data(t,"is_loaded"),h=n.dwg_dynapi_entity_data(t,"pixel_size"),g=n.dwg_dynapi_entity_data(t,"resunits");return{...s,fileName:l,size:_,sizeOfOnePixel:h,isLoaded:f,resolutionUnits:g}}convertLayerFilter(t,o){const n=this.libredwg,s=this.getCommonObjectAttrs(o),_=n.dwg_dynapi_entity_data(t,"num_names")??0,l=n.dwg_dynapi_entity_data(t,"names"),f=l&&_>0?n.dwg_ptr_to_wchar_string_array(l,_).filter(h=>h!=null&&h!==""):[];return{...s,...f.length?{layerNames:f}:{}}}convertLayerIndex(t,o){const n=this.libredwg,s=this.getCommonObjectAttrs(o),_=n.dwg_dynapi_entity_data(t,"last_updated"),l=n.dwg_dynapi_entity_data(t,"num_entries")??0,f=n.dwg_dynapi_entity_data(t,"entries"),h=n.dwg_dynapi_subclass_size("LAYER_entry"),g=[],y=[],P=[];if(f&&h>0)for(let p=0;p<l;p++){const I=f+p*h,C=n.dwg_dynapi_subclass_data(I,"LAYER_entry","name");g.push(C??"");const w=n.dwg_dynapi_subclass_data(I,"LAYER_entry","handle");y.push(w?n.dwg_ref_get_id(w)??"":""),P.push(n.dwg_dynapi_subclass_data(I,"LAYER_entry","numlayers")??0)}return{...s,..._!=null?{timeStamp:_}:{},...g.length?{layerNames:g}:{},...y.length?{idBufferIds:y}:{},...P.length?{idBufferEntryCounts:P}:{}}}convertLayout(t,o){const n=this.libredwg,s=this.getCommonObjectAttrs(o),_=n.dwg_dynapi_entity_data(t,"layout_name"),l=n.dwg_dynapi_entity_data(t,"tab_order"),f=n.dwg_dynapi_entity_data(t,"layout_flags"),h=n.dwg_dynapi_entity_data(t,"INSBASE"),g=n.dwg_dynapi_entity_data(t,"LIMMIN"),y=n.dwg_dynapi_entity_data(t,"LIMMAX"),P=n.dwg_dynapi_entity_data(t,"UCSORG"),p=n.dwg_dynapi_entity_data(t,"UCSXDIR"),I=n.dwg_dynapi_entity_data(t,"UCSYDIR"),C=n.dwg_dynapi_entity_data(t,"UCSORTHOVIEW"),w=n.dwg_dynapi_entity_data(t,"EXTMIN"),m=n.dwg_dynapi_entity_data(t,"EXTMAX"),S=n.dwg_dynapi_entity_data(t,"ucs_elevation"),N=n.dwg_dynapi_entity_data(t,"block_header"),W=n.dwg_ref_get_id(N)??"",M=n.dwg_dynapi_entity_data(t,"active_viewport"),O=n.dwg_ref_get_id(M)??"",U=n.dwg_dynapi_entity_data(t,"named_ucs"),J=U?n.dwg_ref_get_id(U)??"":void 0;return{...s,layoutName:_,controlFlag:f,tabOrder:l,minLimit:g,maxLimit:y,insertionPoint:h,minExtent:w,maxExtent:m,elevation:S,ucsOrigin:P,ucsXAxis:p,ucsYAxis:I,orthographicType:C,paperSpaceTableId:W,viewportId:O,namedUcsId:J,shadePlotId:""}}convertMLeaderStyle(t,o){const n=this.libredwg,s=this.getCommonObjectAttrs(o),_=g=>n.dwg_dynapi_entity_data(t,g),l=g=>n.dwg_ref_get_id(g),f=g=>g>0,h=g=>g!=null?Tr(g):void 0;return{...s,subclassMarker:"AcDbMLeaderStyle",unknown1:_("class_version"),contentType:_("content_type"),drawMLeaderOrderType:_("mleader_order"),drawLeaderOrderType:_("leader_order"),maxLeaderSegmentPoints:_("max_points"),firstSegmentAngleConstraint:_("first_seg_angle"),secondSegmentAngleConstraint:_("second_seg_angle"),leaderLineType:_("type"),leaderLineColor:h(_("line_color")),leaderLineTypeId:l(_("line_type")),leaderLineWeight:_("linewt"),landingEnabled:f(_("has_landing")),landingGap:_("landing_gap"),doglegEnabled:f(_("has_dogleg")),doglegLength:_("landing_dist"),description:_("description"),arrowheadId:l(_("arrow_head")),arrowheadSize:_("arrow_head_size"),defaultMTextContents:_("text_default"),textStyleId:l(_("text_style")),textLeftAttachmentType:_("attach_left"),textAngleType:_("text_angle_type"),textAlignmentType:_("text_align_type"),textRightAttachmentType:_("attach_right"),textColor:h(_("text_color")),textHeight:_("text_height"),textFrameEnabled:f(_("has_text_frame")),textAlignAlwaysLeft:f(_("text_always_left")),alignSpace:_("align_space"),blockContentId:l(_("block")),blockContentColor:h(_("block_color")),blockContentScale:_("block_scale"),blockContentScaleEnabled:f(_("use_block_scale")),blockContentRotation:_("block_rotation"),blockContentRotationEnabled:f(_("use_block_rotation")),blockContentConnectionType:_("block_connection"),scale:_("scale"),overwritePropertyValue:f(_("is_changed")),annotative:f(_("is_annotative")),breakGapSize:_("break_size"),textAttachmentDirection:_("attach_dir"),bottomTextAttachmentDirection:_("attach_bottom"),topTextAttachmentDirection:_("attach_top"),unknown2:f(_("text_extended"))}}convertSpatialFilter(t,o){const n=this.libredwg,s=this.getCommonObjectAttrs(o),_=n.dwg_dynapi_entity_data(t,"origin"),l=n.dwg_dynapi_entity_data(t,"num_clip_verts"),f=n.dwg_dynapi_entity_data(t,"clip_verts"),h=n.dwg_ptr_to_point2d_array(f,l),g=n.dwg_dynapi_entity_data(t,"extrusion"),y=n.dwg_dynapi_entity_data(t,"display_boundary_on"),P=n.dwg_dynapi_entity_data(t,"front_clip_on"),p=n.dwg_dynapi_entity_data(t,"front_clip_z"),I=n.dwg_dynapi_entity_data(t,"back_clip_on"),C=n.dwg_dynapi_entity_data(t,"back_clip_z"),w=n.dwg_dynapi_entity_data(t,"transform"),m=n.dwg_ptr_to_double_array(w,12),S=n.dwg_dynapi_entity_data(t,"inverse_transform"),N=n.dwg_ptr_to_double_array(S,12);return{...s,origin:_,numberOfPointsOnClipBoundary:l,vertices:h,extrusionDirection:g,clipBoundaryVisible:!!y,frontClippingPlaneFlag:!!P,frontClippingPlaneDistance:p,backClippingPlaneFlag:!!I,backClippingPlaneDistance:C,matrix:m,invertBlockMatrix:N}}convertGroup(t,o){const n=this.libredwg,s=this.getCommonObjectAttrs(o),_=n.dwg_dynapi_entity_data(t,"name")??"",l=!!n.dwg_dynapi_entity_data(t,"unnamed"),f=n.dwg_dynapi_entity_data(t,"selectable"),h=f!=null?!!f:!0,g=n.dwg_dynapi_entity_data(t,"num_groups")??0,y=n.dwg_dynapi_entity_data(t,"groups")??0,p=(g>0&&y?n.dwg_ptr_to_object_ref_array(y,g):[]).map(I=>ht(I.absolute_ref));return{...s,description:_,unnamed:l,selectable:h,objectHandles:p}}convertXRecord(t,o){const n=this.libredwg,s=this.getCommonObjectAttrs(o),_=n.dwg_dynapi_entity_data(t,"cloning"),l=n.dwg_object_xrecord_get_xdata(t)??[],f=n.dwg_object_get_tio(o),h=f?n.dwg_object_object_get_xdicobjhandle_object(f):null,g=h&&h.absolute_ref?ht(h.absolute_ref):void 0;return{...s,..._!=null?{cloning:_}:{},...g?{extensionDictionary:g}:{},data:l}}refId(t){return t?this.libredwg.dwg_ref_get_id(t)??"0":"0"}refIds(t,o){return!t||o<=0?[]:this.libredwg.dwg_ptr_to_object_ref_array(t,o).map(n=>ht(n.absolute_ref))}assocHandleRefs(t,o){const n=this.libredwg,s=n.dwg_dynapi_subclass_size("ASSOCACTION_Deps"),_=[];if(!t||s<=0)return _;for(let l=0;l<o;l++){const f=t+l*s;_.push({handle:this.refId(n.dwg_dynapi_subclass_data(f,"ASSOCACTION_Deps","dep")),isOwned:!!n.dwg_dynapi_subclass_data(f,"ASSOCACTION_Deps","is_owned")})}return _}assocVariant(t){const o=this.libredwg,n=o.dwg_dynapi_subclass_data(t,"EvalVariant","code")??0,s=f=>o.dwg_dynapi_subclass_data(t,"EvalVariant",f),_=(f,h)=>n>=f&&n<=h;let l=null;return _(38,59)||_(140,149)||_(460,469)||_(1040,1042)?l=s("u.bd"):_(90,99)||_(420,429)||_(440,459)||n===1071?l=s("u.bl")|0:_(60,79)||_(170,179)||_(270,279)||_(370,389)||_(400,409)||n===1070?l=s("u.bs")<<16>>16:_(280,289)?l=s("u.rc"):(_(1,4)||_(6,9)||_(100,102)||_(300,309)||_(410,419)||_(430,439)||_(470,479)||n===999||_(1e3,1009))&&(l=null),{code:n,value:l}}assocValueParams(t,o){const n=this.libredwg,s=n.dwg_dynapi_subclass_size("VALUEPARAM"),_=n.dwg_dynapi_subclass_size("VALUEPARAM_vars"),l=[];if(!t||s<=0)return l;for(let f=0;f<o;f++){const h=t+f*s,g=I=>n.dwg_dynapi_subclass_data(h,"VALUEPARAM",I),y=g("num_vars")??0,P=g("vars"),p=[];for(let I=0;P&&_>0&&I<y;I++){const C=P+I*_;p.push({...this.assocVariant(C),variableHandle:this.refId(n.dwg_dynapi_subclass_data(C,"VALUEPARAM_vars","handle"))})}l.push({classVersion:g("class_version")??0,name:g("name")??"",unitType:g("unit_type")??0,values:p,controlledObjectDependencyHandle:this.refId(g("controlled_objdep"))})}return l}convertAssocAction(t,o){const n=this.libredwg,s=_=>n.dwg_dynapi_entity_data(t,_);return{...this.getCommonObjectAttrs(o),classVersion:s("class_version")??0,status:s("geometry_status")??0,owningNetworkHandle:this.refId(s("owningnetwork")),actionBodyHandle:this.refId(s("actionbody")),actionIndex:s("action_index")??0,maxDependencyIndex:s("max_assoc_dep_index")??0,dependencies:this.assocHandleRefs(s("deps"),s("num_deps")??0),ownedParamHandles:this.refIds(s("owned_params"),s("num_owned_params")??0),valueParams:this.assocValueParams(s("values"),s("num_values")??0)}}convertAssocNetwork(t,o){const n=this.libredwg,s=_=>n.dwg_dynapi_entity_data(t,_);return{...this.convertAssocAction(t,o),networkVersion:s("network_version")??0,maxActionIndex:s("network_action_index")??0,actions:this.assocHandleRefs(s("actions"),s("num_actions")??0),ownedActionHandles:this.refIds(s("owned_actions"),s("num_owned_actions")??0)}}convertAssocDependency(t,o){const n=this.libredwg,s=_=>n.dwg_dynapi_entity_data(t,_);return{...this.getCommonObjectAttrs(o),classVersion:s("class_version")??0,status:s("status")??0,isReadDependency:!!s("is_read_dep"),isWriteDependency:!!s("is_write_dep"),isAttachedToObject:!!s("is_attached_to_object"),isDelegatingToOwningAction:!!s("is_delegating_to_owning_action"),order:(s("order")??0)|0,name:s("has_name")?s("name")??"":"",dependentOnHandle:this.refId(s("dep_on")),prevDependencyHandle:this.refId(s("readdep")),nextDependencyHandle:this.refId(s("node")),dependencyBodyHandle:this.refId(s("dep_body")),dependencyIndex:(s("depbodyid")??0)|0}}convertAssocArrayActionBody(t,o){const n=this.libredwg,s=y=>n.dwg_dynapi_entity_data(t,y),_=y=>y?n.dwg_ptr_to_double_array(y,16):[],l=[],f=s("num_arrayitems")??0,h=s("arrayitems"),g=n.dwg_dynapi_subclass_size("ASSOCARRAYITEM");for(let y=0;h&&g>0&&y<f;y++){const P=h+y*g,p=(m,S=P)=>n.dwg_dynapi_subclass_data(S,"ASSOCARRAYITEM",m),I=p("flags")??0;let C;if(I&4)C=_(p("transmatrix"));else{const m=p("x_dir")??{x:0,y:0,z:0};C=[1,0,0,m.x,0,1,0,m.y,0,0,1,m.z,0,0,0,1]}const w=I&2?_(p("rel_transform")):void 0;l.push({...w?{relativeMatrix:w}:{},...I&16?{secondaryEntityHandle:this.refId(p("h2"))}:{},classVersion:p("class_version")??0,itemIndex:p("itemloc")??0,rowIndex:p("itemloc",P+4)??0,levelIndex:p("itemloc",P+8)??0,flags:I,matrix:C,entityHandle:this.refId(p("h1"))})}return{...this.getCommonObjectAttrs(o),actionBodyVersion:s("aab_version")??0,classVersion:s("aaab_version")??0,parametersClassName:s("paramblock")??"",parametersVersion:s("aap_version")??0,items:l,arrayTransform:_(s("transmatrix"))}}convertAssocActionParamBase(t,o){const n=this.libredwg,s=_=>n.dwg_dynapi_entity_data(t,_);return{...this.getCommonObjectAttrs(o),classVersion:s("is_r2013")??0,paramVersion:s("aap_version")??0,name:s("name")??"",singleDependencyVersion:s("asdap_class_version")??0,dependencyHandle:this.refId(s("dep"))}}convertAssocVertexActionParam(t,o){const n=this.libredwg;return{...this.convertAssocActionParamBase(t,o),vertexVersion:n.dwg_dynapi_entity_data(t,"class_version")??0,point:n.dwg_dynapi_entity_data(t,"pt")??{x:0,y:0,z:0}}}convertAssocEdgeActionParam(t,o){const n=this.libredwg,s=_=>n.dwg_dynapi_entity_data(t,_);return{...this.convertAssocActionParamBase(t,o),edgeVersion:s("class_version")??0,hasCachedCurve:!!s("has_action"),curveType:s("action_type")??0}}getCommonObjectAttrs(t){const o=this.libredwg,n=o.dwg_object_get_tio(t),s=o.dwg_object_object_get_ownerhandle_object(n),_=o.dwg_object_get_handle_object(t);return{handle:ht(_.value),ownerHandle:ht(s.absolute_ref)}}}class It{constructor(){et(this,"min"),et(this,"max"),et(this,"valid"),this.min={x:1/0,y:1/0},this.max={x:-1/0,y:-1/0},this.valid=!1}expandByPoint(t){return this.min.x=Math.min(this.min.x,t.x),this.min.y=Math.min(this.min.y,t.y),this.max.x=Math.max(this.max.x,t.x),this.max.y=Math.max(this.max.y,t.y),this.valid=!0,this}transform(t,o){const n=this.getCorners().map(s=>({x:s.x*t.x+o.x,y:s.y*t.y+o.y}));this.reset();for(const s of n)this.expandByPoint(s);return this}rotate(t,o){const n=Math.cos(t),s=Math.sin(t),_=this.getCorners().map(l=>{const f=l.x-o.x,h=l.y-o.y;return{x:o.x+f*n-h*s,y:o.y+f*s+h*n}});this.reset();for(const l of _)this.expandByPoint(l);return this}clone(){const t=new It;return t.min={x:this.min.x,y:this.min.y},t.max={x:this.max.x,y:this.max.y},t.valid=this.valid,t}reset(){this.min={x:1/0,y:1/0},this.max={x:-1/0,y:-1/0},this.valid=!1}getCorners(){return[{x:this.min.x,y:this.min.y},{x:this.min.x,y:this.max.y},{x:this.max.x,y:this.min.y},{x:this.max.x,y:this.max.y}]}}function No(r,t,o,n,s){const _=o.length;if(_===0)throw new Error("points must not be empty");const l=o[0].length;if(r<0||r>1)throw new Error(`t out of bounds [0,1]: ${r}`);if(t<1)throw new Error("degree must be at least 1 (linear)");if(t>_-1)throw new Error("degree must be less than or equal to point count - 1");const f=s??new Array(_).fill(1),h=n??(()=>{const w=[];for(let m=0;m<_+t+1;m++)w.push(m);return w})();if(h.length!==_+t+1)throw new Error("bad knot vector length");const g=[t,h.length-1-t],y=h[g[0]],P=h[g[1]];r=r*(P-y)+y,r=Math.max(r,y),r=Math.min(r,P);let p=g[0];for(;p<g[1]&&!(r>=h[p]&&r<=h[p+1]);p++);const I=new Array(_);for(let w=0;w<_;w++){I[w]=new Array(l+1);for(let m=0;m<l;m++)I[w][m]=o[w][m]*f[w];I[w][l]=f[w]}for(let w=1;w<=t+1;w++)for(let m=p;m>p-t-1+w;m--){const S=h[m+t+1-w]-h[m],N=S===0?0:(r-h[m])/S;for(let W=0;W<l+1;W++)I[m][W]=(1-N)*I[m-1][W]+N*I[m][W]}const C=new Array(l);for(let w=0;w<l;w++)C[w]=Wo(I[p][w]/I[p][l],-9);return C}function Wo(r,t){if(isNaN(r)||!Number.isInteger(t))return NaN;const[o,n="0"]=r.toString().split("e"),s=Math.round(+`${o}e${+n-t}`),[_,l="0"]=s.toString().split("e");return+`${_}e${+l+t}`}const dn={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},Cn=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215,0];function Ue(r,t,o){return Math.max(t,Math.min(o,r))}const Pr=class pr{constructor(){et(this,"_colorIndex"),et(this,"_color"),et(this,"_colorName"),this._colorIndex=256,this._color=null,this._colorName=null}get color(){return this._color}set color(t){t==null?this._color=null:(this._color=Math.round(Ue(t,0,256*256*256-1)),this._colorIndex=this.getColorIndexByValue(this._color),this._colorName=this.getColorNameByValue(this._color))}get hexColor(){if(this._color&&this._color>0&&this._color<=16777215){let t=this._color.toString(16).toUpperCase();for(;t.length<6;)t="0"+t;return`0x${t}`}return""}get cssColor(){return`rgb(${this.red},${this.green},${this.blue})`}get red(){return this.color!=null?this.color>>16&255:null}get green(){return this.color!=null?this.color>>8&255:null}get blue(){return this.color!=null?this.color&255:null}get colorIndex(){return this._colorIndex}set colorIndex(t){t==null?this._colorIndex=null:(this._colorIndex=Ue(t,0,256),this._color=Cn[t],this._colorName=this.getColorNameByValue(this._color))}get colorName(){return this._colorName}set colorName(t){if(t){const o=dn[t.toLowerCase()];o!==void 0&&(this._colorName=t,this._color=o,this._colorIndex=this.getColorIndexByValue(this._color))}else this._colorName=null}get hasColorName(){return this._colorName==null}get hasColorIndex(){return this._colorIndex==null}get isByLayer(){return this.colorIndex==256}setByLayer(){return this.colorIndex=256,this}get isByBlock(){return this.colorIndex==0}setByBlock(){return this.colorIndex=0,this}setScalar(t){return this.setRGB(t,t,t),this}setRGB(t,o,n){const s=Math.round(Ue(t,0,255)),_=Math.round(Ue(o,0,255)),l=Math.round(Ue(n,0,255));return this.color=(s<<16)+(_<<8)+l,this}setColorName(t){const o=dn[t.toLowerCase()];return o!==void 0&&(this.color=o),this}clone(){const t=new pr;return t.colorIndex=this.colorIndex,t.color=this.color,t._colorName=this._colorName,this}copy(t){return this.colorIndex=t.colorIndex,this.color=t.color,this._colorName=t._colorName,this}equals(t){return t.color==this.color&&t.colorIndex==this.colorIndex&&t._colorName==this._colorName}toString(){return this.isByLayer?"ByLayer":this.isByBlock?"ByBlock":this.colorName?this.colorName:this.hexColor}getColorNameByValue(t){for(const[o,n]of Object.entries(dn))if(n===t)return o;return null}getColorIndexByValue(t){const o=Cn.length-1;for(let n=1;n<o;++n)if(Cn[n]===t)return n;return null}};et(Pr,"NAMES",dn);let Go=Pr;class Ct{constructor(t,o){et(this,"x"),et(this,"y"),this.x=t,this.y=o}add(t){return new Ct(this.x+t.x,this.y+t.y)}sub(t){return new Ct(this.x-t.x,this.y-t.y)}multiply(t){return new Ct(this.x*t,this.y*t)}length(){return Math.sqrt(this.x**2+this.y**2)}norm(){const t=this.length();return t===0?new Ct(0,0):new Ct(this.x/t,this.y/t)}}function Mo(r,t,o,n=5){let s,_,l;o<0?(s=Math.atan(-o)*4,_=new Ct(r.x,r.y),l=new Ct(t.x,t.y)):(s=Math.atan(o)*4,_=new Ct(t.x,t.y),l=new Ct(r.x,r.y));const f=l.sub(_),h=f.length(),g=_.add(f.multiply(.5)),y=Math.abs(h/2/Math.tan(s/2)),P=f.norm(),p=new Ct(P.x*Math.cos(Math.PI/2)-P.y*Math.sin(Math.PI/2),P.y*Math.cos(Math.PI/2)+P.x*Math.sin(Math.PI/2)),I=s<Math.PI?g.add(p.multiply(-y)):g.add(p.multiply(y)),C=Math.atan2(l.y-I.y,l.x-I.x)/Math.PI*180;let w=Math.atan2(_.y-I.y,_.x-I.x)/Math.PI*180;w<C&&(w+=360);const m=l.sub(I).length(),S=Math.floor(C/n)*n+n,N=Math.ceil(w/n)*n-n,W=[];for(let M=S;M<=N;M+=n){const O=M/180*Math.PI,U=I.add(new Ct(Math.cos(O)*m,Math.sin(O)*m));W.push(U)}return o<0&&W.reverse(),W}function bo(r,t=!1){let o=[];const n=r.vertices.map(s=>({x:s.x,y:s.y,bulge:s.bulge}));t&&n.push(n[0]);for(let s=0,_=n.length;s<_-1;++s){const l=n[s],f=n[s+1];o.push(l),n[s].bulge&&(o=o.concat(Mo(l,f,r.vertices[s].bulge))),s===_-2&&o.push(f)}return o}class xo{constructor(){et(this,"blockMap",new Map)}rotate(t,o){const n=Math.cos(o),s=Math.sin(o);return{x:t.x*n-t.y*s,y:t.x*s+t.y*n}}interpolateBSpline(t,o,n,s=25,_){const l=[],f=t.map(y=>[y.x,y.y]),h=[n[o]],g=[n[o],n[n.length-1-o]];for(let y=o+1;y<n.length-o;++y)h[h.length-1]!==n[y]&&h.push(n[y]);for(let y=1;y<h.length;++y){const P=h[y-1],p=h[y];for(let I=0;I<=s;++I){let w=(I/s*(p-P)+P-g[0])/(g[1]-g[0]);w=Math.max(0,Math.min(1,w));const m=No(w,o,f,n,_);l.push({x:m[0],y:m[1]})}}return l}addFlipXIfApplicable(t,{bbox:o,element:n}){return"extrusionDirection"in t&&t.extrusionDirection.z===-1?{bbox:new It().expandByPoint({x:-o.min.x,y:o.min.y}).expandByPoint({x:-o.max.x,y:o.max.y}),element:`<g transform="matrix(-1 0 0 1 0 0)">${n}</g>`}:{bbox:o,element:n}}line(t){const o=new It().expandByPoint({x:t.startPoint.x,y:t.startPoint.y}).expandByPoint({x:t.endPoint.x,y:t.endPoint.y}),n=`<line x1="${t.startPoint.x}" y1="${t.startPoint.y}" x2="${t.endPoint.x}" y2="${t.endPoint.y}" />`;return{bbox:o,element:n}}ray(t){const n=t.firstPoint,s={x:n.x+t.unitDirection.x*1e4,y:n.y+t.unitDirection.y*1e4},_=new It().expandByPoint(n).expandByPoint(s),l=`<line x1="${n.x}" y1="${n.y}" x2="${s.x}" y2="${s.y}" />`;return{bbox:_,element:l}}xline(t){const n={x:t.firstPoint.x-t.unitDirection.x*1e4,y:t.firstPoint.y-t.unitDirection.y*1e4},s={x:t.firstPoint.x+t.unitDirection.x*1e4,y:t.firstPoint.y+t.unitDirection.y*1e4},_=new It().expandByPoint(n).expandByPoint(s),l=`<line x1="${n.x}" y1="${n.y}" x2="${s.x}" y2="${s.y}" />`;return{bbox:_,element:l}}extractMTextLines(t){return t.replace(/\\U\+([0-9A-Fa-f]{4})/g,(o,n)=>String.fromCharCode(parseInt(n,16))).replace(/\\P/g,`
|
|
18
14
|
`).replace(/\\[LOlo]/g,"").replace(/\\[Ff][^;\\]*?(?:\|[^;\\]*)*;/g,"").replace(/\\[KkCcHhWwTtAa][^;\\]*;?/g,"").replace(/\\[a-zA-Z]+;?/g,"").replace(/%%(d|p|c|%)/gi,"").replace(/\\\\/g,"\\").replace(/\\~/g," ").replace(/[{}]/g,"").split(`
|
|
19
|
-
`).map(o=>o.trim()).filter(o=>o.length>0)}lines(t,o,
|
|
20
|
-
`)}}mtext(t){const o=t.textHeight,
|
|
15
|
+
`).map(o=>o.trim()).filter(o=>o.length>0)}lines(t,o,n,s,_="start"){const l=new It().expandByPoint({x:n.x,y:n.y}).expandByPoint({x:n.x+s,y:n.y-t.length*o*1.5}),f=t.map((h,g)=>{const y=n.x,P=n.y-g*o*1.5,p=`translate(${y},${P}) scale(1,-1) translate(${-y},${-P})`;return`<text x="${y}" y="${P}" font-size="${o}" text-anchor="${_}" transform="${p}">${h}</text>`});return{bbox:l,element:f.join(`
|
|
16
|
+
`)}}mtext(t){const o=t.textHeight,n=t.insertionPoint,s=this.extractMTextLines(t.text),_=t.attachmentPoint;let l="start";return _==ge.BottomCenter||_==ge.MiddleCenter||_==ge.TopCenter?l="middle":(_==ge.BottomRight||_==ge.MiddleRight||_==ge.TopRight)&&(l="end"),this.lines(s,o,n,t.extentsWidth,l)}table(t){const{rowCount:o,columnCount:n,rowHeightArr:s,columnWidthArr:_,startPoint:l,cells:f}=t,h=l.x,g=l.y,y=[];for(let m=0,S=g;m<o;m++){const N=s[m];let W=h;for(let M=0;M<n;M++){const O=m*n+M,U=f[O],J=_[M];y.push({x:W,y:S,width:J,height:N,cell:U,row:m,col:M}),W+=J}S+=N}const P=y.map(({x:m,y:S,width:N,height:W,cell:M})=>{const O=[];M.topBorderVisibility&&O.push(`<line x1="${m}" y1="${S}" x2="${m+N}" y2="${S}" stroke="black" />`),M.bottomBorderVisibility&&O.push(`<line x1="${m}" y1="${S+W}" x2="${m+N}" y2="${S+W}" stroke="black" />`),M.leftBorderVisibility&&O.push(`<line x1="${m}" y1="${S}" x2="${m}" y2="${S+W}" stroke="black" />`),M.rightBorderVisibility&&O.push(`<line x1="${m+N}" y1="${S}" x2="${m+N}" y2="${S+W}" stroke="black" />`);const U=m+N/2,J=S+W/2+M.textHeight/3,nt=`<text x="${U}" y="${J}" font-size="${M.textHeight}" text-anchor="middle" dominant-baseline="middle">${M.text}</text>`;return[...O,nt].join(`
|
|
21
17
|
`)}).join(`
|
|
22
|
-
`),
|
|
23
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="${
|
|
24
|
-
${
|
|
18
|
+
`),p=_.reduce((m,S)=>m+S,0),I=s.reduce((m,S)=>m+S,0),C=new It().expandByPoint({x:h,y:g}).expandByPoint({x:h+p,y:g+I}),w=`
|
|
19
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="${p}" height="${I}" viewBox="${h} ${g} ${p} ${I}">
|
|
20
|
+
${P}
|
|
25
21
|
</svg>
|
|
26
|
-
`.trim();return{bbox:C,element:w}}text(t){const o=t.textHeight,
|
|
27
|
-
`)}</g>`}:null}entityToBoundsAndElement(t){let o=null;switch(t.type){case"ARC":o=this.arc(t);break;case"CIRCLE":o=this.circle(t);break;case"DIMENSION":o=this.dimension(t);break;case"ELLIPSE":o=this.ellipse(t);break;case"INSERT":o=this.insert(t);break;case"LINE":o=this.line(t);break;case"LWPOLYLINE":{const
|
|
22
|
+
`.trim();return{bbox:C,element:w}}text(t){const o=t.textHeight,n=t.startPoint,s=[t.text];let _=t.endPoint.x-t.endPoint.x;t.halign==0&&(_=t.text.length*o+t.startPoint.x);let l="start";return t.halign==Ln.CENTER?l="middle":t.halign==Ln.RIGHT&&(l="end"),this.lines(s,o,n,_,l)}vertices(t,o=!1){const n=t.reduce((_,l)=>_.expandByPoint(l),new It);let s=t.reduce((_,l,f)=>(_+=f===0?"M":"L",_+=l.x+","+l.y,_),"");return o&&(s+="Z"),{bbox:n,element:`<path d="${s}" />`}}circle(t){const o=new It().expandByPoint({x:t.center.x+t.radius,y:t.center.y+t.radius}).expandByPoint({x:t.center.x-t.radius,y:t.center.y-t.radius}),n=`<circle cx="${t.center.x}" cy="${t.center.y}" r="${t.radius}" />`;return{bbox:o,element:n}}ellipseOrArc(t,o,n,s,_,l,f){const h=Math.sqrt(n*n+s*s),g=_*h,y=-Math.atan2(-s,n),P=this.bboxEllipseOrArc(t,o,n,s,_,l,f);if(Math.abs(l-f)<1e-9||Math.abs(l-f+Math.PI*2)<1e-9){const p=`<g transform="rotate(${y/Math.PI*180} ${t}, ${o})"><ellipse cx="${t}" cy="${o}" rx="${h}" ry="${g}" /></g>`;return{bbox:P,element:p}}else{const p=this.rotate({x:Math.cos(l)*h,y:Math.sin(l)*g},y),I={x:t+p.x,y:o+p.y},C=this.rotate({x:Math.cos(f)*h,y:Math.sin(f)*g},y),w={x:t+C.x,y:o+C.y},S=(f<l?f+Math.PI*2:f)-l<Math.PI?0:1,W=`<path d="${`M ${I.x} ${I.y} A ${h} ${g} ${y/Math.PI*180} ${S} 1 ${w.x} ${w.y}`}" />`;return{bbox:P,element:W}}}bboxEllipseOrArc(t,o,n,s,_,l,f){for(;l<0;)l+=Math.PI*2;for(;f<=l;)f+=Math.PI*2;const h=[];if(Math.abs(n)<1e-12||Math.abs(s)<1e-12)for(let I=0;I<4;I++)h.push(I/2*Math.PI);else h[0]=Math.atan(-s*_/n)-Math.PI,h[1]=Math.atan(n*_/s)-Math.PI,h[2]=h[0]-Math.PI,h[3]=h[1]-Math.PI;for(let I=4;I>=0;I--){for(;h[I]<l;)h[I]+=Math.PI*2;h[I]>f&&h.splice(I,1)}h.push(l),h.push(f);const g=h.map(I=>({x:Math.cos(I),y:Math.sin(I)})),y=[[n,-s*_],[s,n*_]];return g.map(I=>({x:I.x*y[0][0]+I.y*y[0][1]+t,y:I.x*y[1][0]+I.y*y[1][1]+o})).reduce((I,C)=>(I.expandByPoint(C),I),new It)}ellipse(t){const{bbox:o,element:n}=this.ellipseOrArc(t.center.x,t.center.y,t.majorAxisEndPoint.x,t.majorAxisEndPoint.y,t.axisRatio,t.startAngle,t.endAngle);return{bbox:o,element:n}}arc(t){const{bbox:o,element:n}=this.ellipseOrArc(t.center.x,t.center.y,t.radius,0,1,t.startAngle,t.endAngle);return{bbox:o,element:n}}dimension(t){const o=this.blockMap.get(t.name);return o?{bbox:o.bbox,element:`<use href="#${t.name}" />`}:null}insert(t){const o=this.blockMap.get(t.name);if(o){const n=t.insertionPoint,s=t.rotation*(180/Math.PI),_=`translate(${n.x},${n.y}) rotate(${s}) scale(${t.xScale},${t.yScale})`;return{bbox:o.bbox.clone().transform({x:t.xScale,y:t.yScale},{x:n.x,y:n.y}).rotate(t.rotation,n),element:`<use href="#${t.name}" transform="${_}" />`}}return null}block(t,o){const n=t.entities,{bbox:s,elements:_}=n.reduce((l,f)=>{const h=this.entityToBoundsAndElement(f);if(h){const{bbox:g,element:y}=h;g.valid&&(l.bbox.expandByPoint(g.min),l.bbox.expandByPoint(g.max));const P=this.getEntityColor(o.tables.LAYER.entries,f),p=f.type=="TEXT"||f.type=="MTEXT"?P.cssColor:"none";P.isByBlock?l.elements.push(`<g id="${f.handle}">${y}</g>`):l.elements.push(`<g id="${f.handle}" stroke="${P.cssColor}" fill="${p}">${y}</g>`)}return l},{bbox:new It,elements:[]});return s.valid?{bbox:s,element:`<g id="${t.name}">${_.join(`
|
|
23
|
+
`)}</g>`}:null}entityToBoundsAndElement(t){let o=null;switch(t.type){case"ARC":o=this.arc(t);break;case"CIRCLE":o=this.circle(t);break;case"DIMENSION":o=this.dimension(t);break;case"ELLIPSE":o=this.ellipse(t);break;case"INSERT":o=this.insert(t);break;case"LINE":o=this.line(t);break;case"LWPOLYLINE":{const n=t,s=!!(n.flag&512),_=bo(n,s);o=this.vertices(_,s);break}case"MTEXT":o=this.mtext(t);break;case"SPLINE":{const n=t;o=this.vertices(this.interpolateBSpline(n.controlPoints,n.degree,n.knots,25,n.weights));break}case"POLYLINE":break;case"RAY":o=this.ray(t);break;case"TABLE":case"ACAD_TABLE":o=this.table(t);break;case"TEXT":o=this.text(t);break;case"XLINE":o=this.xline(t);break;default:o=null;break}return o?this.addFlipXIfApplicable(t,o):null}getEntityColor(t,o){const n=new Go;if(o.colorIndex!=null?n.colorIndex=o.colorIndex:o.colorName?n.colorName=o.colorName:o.color!=null&&(n.color=o.color),n.colorIndex==7&&(n.colorIndex=256),n.isByLayer){const s=t.find(_=>_.name===o.layer);s!=null&&(n.colorIndex=s.colorIndex)}return n.color==null&&(n.color=16777215),n}convert(t){let o=null;this.blockMap.clear();let n="";t.tables.BLOCK_RECORD.entries.forEach(l=>{if(Wn(l.name))o=l;else{const f=this.block(l,t);f&&(n+=f.element,this.blockMap.set(l.name,f))}});const s=this.block(o,t),_=s&&s.bbox.valid?{x:s.bbox.min.x,y:-s.bbox.max.y,width:s.bbox.max.x-s.bbox.min.x,height:s.bbox.max.y-s.bbox.min.y}:{x:0,y:0,width:0,height:0};return`<?xml version="1.0"?>
|
|
28
24
|
<svg
|
|
29
25
|
xmlns="http://www.w3.org/2000/svg"
|
|
30
26
|
xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"
|
|
@@ -32,8 +28,8 @@ return ret;
|
|
|
32
28
|
viewBox="${_.x} ${_.y} ${_.width} ${_.height}"
|
|
33
29
|
width="100%" height="100%"
|
|
34
30
|
>
|
|
35
|
-
<defs>${
|
|
31
|
+
<defs>${n}</defs>
|
|
36
32
|
<g stroke="#000000" stroke-width="0.1%" fill="none" transform="matrix(1,0,0,-1,0,0)">
|
|
37
33
|
${s?s.element:""}
|
|
38
34
|
</g>
|
|
39
|
-
</svg>`}}const pr=class Tr{constructor(t){return nt(this,"wasmInstance"),nt(this,"decoder"),this.wasmInstance=t,new Proxy(this,{get:(o,e,s)=>e in o?Reflect.get(o,e,s):Reflect.get(o.wasmInstance,e,s)})}dwg_read_data(t,o){const e=typeof t=="string"?new TextEncoder().encode(t):new Uint8Array(t);if(o==vt.DWG){const s="tmp.dwg";try{this.wasmInstance.FS.writeFile(s,e);const _=this.wasmInstance.dwg_read_file(s);if(_.error&Wn.OUTOFMEM)throw this.wasmInstance.dwg_abandon(_.data),new Error("Failed to decode DWG: out of WASM memory. Rebuild with pnpm build:wasm (INITIAL_MEMORY=1GB) or use a smaller file.");return _.error!=0,_.data}finally{this.wasmInstance.FS.analyzePath(s,!1).exists&&this.wasmInstance.FS.unlink(s)}}else if(o==vt.DXF){const s="tmp.dxf";try{this.wasmInstance.FS.writeFile(s,e);const _=this.wasmInstance.dxf_read_file(s);if(_.error&Wn.OUTOFMEM)throw this.wasmInstance.dwg_abandon(_.data),new Error("Failed to decode DXF: out of WASM memory. Rebuild with pnpm build:wasm (INITIAL_MEMORY=1GB) or use a smaller file.");return _.error!=0,_.data?_.data:void 0}finally{this.wasmInstance.FS.analyzePath(s,!1).exists&&this.wasmInstance.FS.unlink(s)}}}dwg_write_dxf(t){const o="tmp.dwg",e="tmp.dxf";try{return this.wasmInstance.FS.writeFile(o,new Uint8Array(t)),this.wasmInstance.dwg_write_dxf(o,e)!=0?null:this.wasmInstance.FS.readFile(e)}finally{this.wasmInstance.FS.analyzePath(o,!1).exists&&this.wasmInstance.FS.unlink(o),this.wasmInstance.FS.analyzePath(e,!1).exists&&this.wasmInstance.FS.unlink(e)}}dwg_get_version_type(t){const o=this.wasmInstance.dwg_get_version_type(t);return So[o]}dwg_get_codepage(t){return this.wasmInstance.dwg_get_codepage(t)}dwg_bmp(t){return this.wasmInstance.dwg_bmp(t)}dwg_get_num_classes(t){return this.wasmInstance.dwg_get_num_classes(t)}dwg_get_class(t,o){return this.wasmInstance.dwg_get_class(t,o)}convert(t){const o=this.dwg_get_codepage(t),e=or(o);return this.decoder=new TextDecoder(e),new lr(this).convert(t)}convertEx(t){const o=this.dwg_get_codepage(t),e=or(o);this.decoder=new TextDecoder(e);const s=new lr(this);return{database:s.convert(t),stats:s.getConversionStats()}}dwg_to_svg(t){return new Uo().convert(t)}dwg_free(t){if(t)try{this.wasmInstance.dwg_free(t)}catch{try{this.wasmInstance.dwg_abandon(t)}catch{}}}dwg_free_object(t){this.wasmInstance.dwg_free_object(t)}dwg_ref_object(t,o){return this.wasmInstance.dwg_ref_object(t,o)}dwg_ref_object_silent(t,o){return this.wasmInstance.dwg_ref_object_silent(t,o)}dwg_ref_object_relative(t,o,e){return this.wasmInstance.dwg_ref_object_relative(t,o,e)}dwg_resolve_handle(t,o){return this.wasmInstance.dwg_resolve_handle(t,o)}dwg_resolve_handle_silent(t,o){return this.wasmInstance.dwg_resolve_handle_silent(t,o)}dwg_resolve_handleref(t,o){return this.wasmInstance.dwg_resolve_handleref(t,o)}dwg_ref_get_absref(t){if(!t)return null;const o=this.wasmInstance.dwg_ref_get_absref(t);return o===0?null:o}dwg_ref_get_handle_value(t){if(!t)return null;const o=this.wasmInstance.dwg_ref_get_handle_value(t);return o===0n?null:o}dwg_ref_get_handle_absolute_ref(t){if(!t)return null;const o=this.wasmInstance.dwg_ref_get_handle_absolute_ref(t);return o===0n?null:o}dwg_obj_get_handle_value(t){if(!t)return null;const o=this.wasmInstance.dwg_obj_get_handle_value(t);return o===0n?null:o}dwg_ref_get_id(t){const o=this.dwg_ref_get_absref(t);return o==null?void 0:o.toString(16).toUpperCase()}dwg_ref_get_object_name(t){const o=this.wasmInstance,e=o.dwg_ref_get_object(t),s=o.dwg_object_to_object_tio(e);return this.dwg_dynapi_entity_data(s,"name")}dwg_obj_obj_to_object(t){return this.wasmInstance.dwg_obj_obj_to_object(t)}dwg_obj_generic_to_object(t){return this.wasmInstance.dwg_obj_generic_to_object(t)}dwg_object_to_object(t){return this.wasmInstance.dwg_object_to_object(t)}dwg_object_to_object_tio(t){return this.wasmInstance.dwg_object_to_object_tio(t)}dwg_object_to_entity(t){return this.wasmInstance.dwg_object_to_entity(t)}dwg_object_to_entity_tio(t){return this.wasmInstance.dwg_object_to_entity_tio(t)}dwg_getall_entities_in_model_space(t){const o=this.wasmInstance,e=o.dwg_model_space_object(t),s=[];let _=o.get_first_owned_entity(e);for(;_;)s.push(_),_=o.get_next_owned_entity(e,_);return s}dwg_getall_object_by_type(t,o){const e=this.wasmInstance,s=e.dwg_get_num_objects(t),_=[];for(let l=0;l<s;l++){const f=e.dwg_get_object(t,l),h=e.dwg_object_to_object_tio(f);h&&e.dwg_object_get_fixedtype(f)==o&&_.push(h)}return _}dwg_getall_entity_by_type(t,o){const e=this.wasmInstance,s=e.dwg_get_num_objects(t),_=[];for(let l=0;l<s;l++){const f=e.dwg_get_object(t,l),h=e.dwg_object_to_entity_tio(f);h&&e.dwg_object_get_fixedtype(f)==o&&_.push(h)}return _}dwg_getall_LAYER(t){return this.dwg_getall_object_by_type(t,S.DWG_TYPE_LAYER)}dwg_getall_LTYPE(t){return this.dwg_getall_object_by_type(t,S.DWG_TYPE_LTYPE)}dwg_getall_STYLE(t){return this.dwg_getall_object_by_type(t,S.DWG_TYPE_STYLE)}dwg_getall_DIMSTYLE(t){return this.dwg_getall_object_by_type(t,S.DWG_TYPE_DIMSTYLE)}dwg_getall_VPORT(t){return this.dwg_getall_object_by_type(t,S.DWG_TYPE_VPORT)}dwg_getall_LAYOUT(t){return this.dwg_getall_object_by_type(t,S.DWG_TYPE_LAYOUT)}dwg_getall_BLOCK(t){return this.dwg_getall_object_by_type(t,S.DWG_TYPE_BLOCK)}dwg_getall_BLOCK_HEADER(t){return this.dwg_getall_object_by_type(t,S.DWG_TYPE_BLOCK_HEADER)}dwg_getall_IMAGEDEF(t){return this.dwg_getall_object_by_type(t,S.DWG_TYPE_IMAGEDEF)}dwg_getall_VERTEX_2D(t){return this.dwg_getall_entity_by_type(t,S.DWG_TYPE_VERTEX_2D)}dwg_getall_VERTEX_3D(t){return this.dwg_getall_entity_by_type(t,S.DWG_TYPE_VERTEX_3D)}dwg_getall_POLYLINE_2D(t){return this.dwg_getall_entity_by_type(t,S.DWG_TYPE_POLYLINE_2D)}dwg_getall_POLYLINE_3D(t){return this.dwg_getall_entity_by_type(t,S.DWG_TYPE_POLYLINE_3D)}dwg_getall_IMAGE(t){return this.dwg_getall_entity_by_type(t,S.DWG_TYPE_IMAGE)}dwg_getall_LWPOLYLINE(t){return this.dwg_getall_entity_by_type(t,S.DWG_TYPE_LWPOLYLINE)}dwg_ptr_to_object_ref_array(t,o){return this.wasmInstance.dwg_ptr_to_object_ref_array(t,o)}dwg_ptr_to_object_ref_ptr_array(t,o){return this.wasmInstance.dwg_ptr_to_object_ref_ptr_array(t,o)}dwg_ptr_to_wchar_string_array(t,o){return this.wasmInstance.dwg_ptr_to_wchar_string_array(t,o)}dwg_ptr_to_unsigned_char_array(t,o){return this.wasmInstance.dwg_ptr_to_unsigned_char_array(t,o)}dwg_ptr_to_signed_char_array(t,o){return this.wasmInstance.dwg_ptr_to_signed_char_array(t,o)}dwg_ptr_to_uint16_t_array(t,o){return this.wasmInstance.dwg_ptr_to_uint16_t_array(t,o)}dwg_ptr_to_int16_t_array(t,o){return this.wasmInstance.dwg_ptr_to_int16_t_array(t,o)}dwg_ptr_to_uint32_t_array(t,o){return this.wasmInstance.dwg_ptr_to_uint32_t_array(t,o)}dwg_ptr_to_int32_t_array(t,o){return this.wasmInstance.dwg_ptr_to_int32_t_array(t,o)}dwg_ptr_to_uint64_t_array(t,o){return this.wasmInstance.dwg_ptr_to_uint64_t_array(t,o)}dwg_ptr_to_int64_t_array(t,o){return this.wasmInstance.dwg_ptr_to_int64_t_array(t,o)}dwg_ptr_to_double_array(t,o){return this.wasmInstance.dwg_ptr_to_double_array(t,o)}dwg_ptr_to_point2d_array(t,o){return this.wasmInstance.dwg_ptr_to_point2d_array(t,o)}dwg_ptr_to_point3d_array(t,o){return this.wasmInstance.dwg_ptr_to_point3d_array(t,o)}dwg_ptr_to_point4d_array(t,o){return this.wasmInstance.dwg_ptr_to_point4d_array(t,o)}dwg_ptr_to_ltype_dash_array(t,o){return this.wasmInstance.dwg_ptr_to_ltype_dash_array(t,o)}dwg_ptr_to_table_cell_array(t,o){return this.wasmInstance.dwg_ptr_to_table_cell_array(t,o)}dwg_ptr_to_hatch_defline_array(t,o){return this.wasmInstance.dwg_ptr_to_hatch_defline_array(t,o)}dwg_ptr_to_hatch_path_array(t,o){return this.wasmInstance.dwg_ptr_to_hatch_path_array(t,o)}dwg_ptr_to_hatch_gradient_color_array(t,o){return this.wasmInstance.dwg_ptr_to_hatch_gradient_color_array(t,o)}dwg_ptr_to_mline_vertex_array(t,o){return this.wasmInstance.dwg_ptr_to_mline_vertex_array(t,o)}dwg_dynapi_entity_value(t,o){const e=this.wasmInstance.dwg_dynapi_entity_value(t,o);return e.bin&&this.decoder&&(e.data=this.decoder.decode(e.bin)),typeof e.data=="string"&&(e.data=ir(e.data)),e}dwg_dynapi_entity_data(t,o){return this.dwg_dynapi_entity_value(t,o).data}dwg_dynapi_header_value(t,o){return this.wasmInstance.dwg_dynapi_header_value(t,o)}dwg_dynapi_header_data(t,o){return this.dwg_dynapi_header_value(t,o).data}dwg_dynapi_common_value(t,o){return this.wasmInstance.dwg_dynapi_common_value(t,o)}dwg_dynapi_common_data(t,o){return this.dwg_dynapi_common_value(t,o).data}dwg_dynapi_subclass_value(t,o,e){const s=this.wasmInstance.dwg_dynapi_subclass_value(t,o,e);return s.bin&&this.decoder&&(s.data=this.decoder.decode(s.bin)),typeof s.data=="string"&&(s.data=ir(s.data)),s}dwg_dynapi_subclass_data(t,o,e){return this.dwg_dynapi_subclass_value(t,o,e).data}dwg_dynapi_subclass_size(t){return this.wasmInstance.dwg_dynapi_subclass_size(t)}dwg_dynapi_entity_field_offset(t,o){return this.wasmInstance.dwg_dynapi_entity_field_offset(t,o)}dwg_dynapi_subclass_field_offset(t,o){return this.wasmInstance.dwg_dynapi_subclass_field_offset(t,o)}dwg_object_get_handle_object(t){return this.wasmInstance.dwg_object_get_handle_object(t)}dwg_object_object_get_handle_object(t){return this.wasmInstance.dwg_object_object_get_handle_object(t)}dwg_object_object_get_ownerhandle_object(t){return this.wasmInstance.dwg_object_object_get_ownerhandle_object(t)}dwg_object_entity_get_handle_object(t){return this.wasmInstance.dwg_object_entity_get_handle_object(t)}dwg_object_entity_get_ownerhandle_object(t){return this.wasmInstance.dwg_object_entity_get_ownerhandle_object(t)}dwg_object_entity_get_xdicobjhandle_object(t){return this.wasmInstance.dwg_object_entity_get_xdicobjhandle_object(t)}dwg_object_entity_get_layer_object_ref(t){return this.wasmInstance.dwg_object_entity_get_layer_object_ref(t)}dwg_object_entity_get_ltype_object_ref(t){return this.wasmInstance.dwg_object_entity_get_ltype_object_ref(t)}dwg_object_entity_get_color_object(t){return this.wasmInstance.dwg_object_entity_get_color_object(t)}dwg_object_entity_get_xdata(t){return this.wasmInstance.dwg_object_entity_get_xdata(t)}dwg_object_object_get_xdicobjhandle_object(t){return this.wasmInstance.dwg_object_object_get_xdicobjhandle_object(t)}dwg_object_xrecord_get_xdata(t){return this.wasmInstance.dwg_object_xrecord_get_xdata(t)??[]}dwg_entity_owner(t){return this.wasmInstance.dwg_entity_owner(t)}dwg_entity_get_block_name(t,o){const e=this.wasmInstance,s=this.dwg_dynapi_entity_data(t,o),_=e.dwg_ref_get_object(s),l=e.dwg_object_to_object_tio(_);return this.dwg_entity_block_header_get_block(l).name}dwg_entity_get_dimstyle_name(t,o="dimstyle"){const e=this.wasmInstance,s=this.dwg_dynapi_entity_data(t,o),_=e.dwg_ref_get_object(s),l=e.dwg_object_to_object_tio(_);return this.dwg_dynapi_entity_data(l,"name")}dwg_entity_block_header_get_block(t){const o=this.wasmInstance,e=this.dwg_dynapi_entity_data(t,"block_entity"),s=o.dwg_ref_get_object(e),_=o.dwg_object_to_entity_tio(s),l=this.dwg_dynapi_entity_data(_,"name"),f=this.dwg_dynapi_entity_data(_,"base_pt");return{name:l,base_pt:f}}dwg_entity_block_header_get_preview(t){const o=this.wasmInstance;if(typeof o.dwg_entity_block_header_get_preview!="function")return null;const e=o.dwg_entity_block_header_get_preview(t);return(e==null?void 0:e.data)??null}dwg_entity_get_preview(t){const o=this.wasmInstance;if(typeof o.dwg_entity_get_preview!="function")return null;const e=o.dwg_entity_get_preview(t);return(e==null?void 0:e.data)??null}dwg_entity_proxy_entity_get_entity_data(t){const o=this.wasmInstance;if(typeof o.dwg_entity_proxy_entity_get_entity_data!="function")return null;const e=o.dwg_entity_proxy_entity_get_entity_data(t);return(e==null?void 0:e.data)??null}dwg_entity_ole2frame_get_data(t){const o=this.wasmInstance;if(typeof o.dwg_entity_ole2frame_get_data!="function")return null;const e=o.dwg_entity_ole2frame_get_data(t);return(e==null?void 0:e.data)??null}dwg_entity_oleframe_get_data(t){const o=this.wasmInstance;if(typeof o.dwg_entity_oleframe_get_data!="function")return null;const e=o.dwg_entity_oleframe_get_data(t);return(e==null?void 0:e.data)??null}get_first_owned_entity(t){return this.wasmInstance.get_first_owned_entity(t)}get_next_owned_entity(t,o){return this.wasmInstance.get_next_owned_entity(t,o)}dwg_entity_mtext_get_style_name(t){const o=this.wasmInstance,e=this.dwg_dynapi_entity_data(t,"style"),s=o.dwg_ref_get_object(e),_=o.dwg_object_to_object_tio(s);return this.dwg_dynapi_entity_data(_,"name")}dwg_entity_text_get_style_name(t){return this.dwg_entity_mtext_get_style_name(t)}dwg_entity_polyline_2d_get_numpoints(t){return this.wasmInstance.dwg_entity_polyline_2d_get_numpoints(t).data}dwg_entity_polyline_2d_get_points(t){return this.wasmInstance.dwg_entity_polyline_2d_get_points(t).data}dwg_entity_polyline_2d_get_vertices(t){return this.wasmInstance.dwg_entity_polyline_2d_get_vertices(t).data}dwg_entity_polyline_3d_get_numpoints(t){return this.wasmInstance.dwg_entity_polyline_3d_get_numpoints(t).data}dwg_entity_polyline_3d_get_points(t){return this.wasmInstance.dwg_entity_polyline_3d_get_points(t).data}dwg_entity_polyline_3d_get_vertices(t){return this.wasmInstance.dwg_entity_polyline_3d_get_vertices(t).data}dwg_entity_insert_get_attribs(t){return this.wasmInstance.dwg_entity_insert_get_attribs(t).data}dwg_object_dictionary_get_texts(t){return this.wasmInstance.dwg_object_dictionary_get_texts(t).data}static createByWasmInstance(t){return this.instance==null?new Tr(t):this.instance}static async create(t){const o=t==null?await ar():await ar({locateFile:e=>`${t}/${e}`});return this.createByWasmInstance(o)}};nt(pr,"instance");let $o=pr;const cn=new Uint8Array([31,37,109,7,212,54,40,40,157,87,202,63,157,68,16,43]);function Vo(r){if(r.length<17)return;const t=new DataView(r.buffer,r.byteOffset,r.byteLength).getUint32(13,!0),o=cr(r,t);if(o)return o;const e=Math.min(r.length,1024*1024);for(let s=0;s+cn.length<=e;s++){if(!Pr(r,s,cn)||s===t)continue;const _=cr(r,s);if(_)return _}}function Ho(r,t){var e;if((e=r.thumbnailImage)!=null&&e.length)return;const o=Vo(t);o!=null&&o.length&&(r.thumbnailImage=o)}function cr(r,t){if(t<=0||t>=r.length||!Pr(r,t,cn))return;let o=t+cn.length;if(o+5>r.length)return;const e=new DataView(r.buffer,r.byteOffset,r.byteLength);e.getInt32(o,!0),o+=4;const s=r[o];if(o+=1,s<=0||s>16)return;const _=[];for(let h=0;h<s;h++){if(o+9>r.length)return;const g=r[o];o+=1;const y=e.getInt32(o,!0);o+=4;const T=e.getInt32(o,!0);o+=4,_.push({code:g,start:y,size:T})}const l=o,f=ur(r,_,"absolute");return f||ur(r,_,"sequential",l)}function ur(r,t,o,e=0){let s,_=e;for(const l of t){const f=o==="absolute"?l.start:_;if(o==="sequential"&&(_+=Math.max(0,l.size)),l.code!==2&&l.code!==6)continue;const h=Xo(r,f,l.size);if(h!=null&&h.length){if(l.code===6)return h.slice();s||(s=h.slice())}}return s}function Xo(r,t,o){if(!(t<0||o<=0)&&!(t+o>r.length))return r.subarray(t,t+o)}function Pr(r,t,o){if(t+o.length>r.length)return!1;for(let e=0;e<o.length;e++)if(r[t+e]!==o[e])return!1;return!0}const Ko=[0,5,9,13,15,18,20,25,30,35,40,50,53,60,70,80,90,100,106,120,140,158,200,211];function Er(r,t=zt.ByLayer){return r===29?zt.ByLayer:r===30?zt.ByBlock:r===31?zt.ByLineWeightDefault:Ko[r]??t}function zo(r,t){var _,l,f,h,g;const o=!t||Jo((_=r.header)==null?void 0:_.ACADVER);for(const y of((f=(l=r.tables)==null?void 0:l.LAYER)==null?void 0:f.entries)??[])y.lineweight!=null&&(y.lineweight=o?Er(y.lineweight,zt.ByLineWeightDefault):zt.ByLineWeightDefault);const e=new Set,s=y=>{if(y)for(const T of y)e.has(T)||(e.add(T),T.lineweight!=null&&(T.lineweight=o?Er(T.lineweight):zt.ByLayer),s(T.attribs),s(T.vertices))};s(r.entities);for(const y of((g=(h=r.tables)==null?void 0:h.BLOCK_RECORD)==null?void 0:g.entries)??[])s(y.entities)}function Jo(r){const t=typeof r=="string"?/^AC(\d{4})$/.exec(r.trim()):null;return t?Number(t[1])>=1015:!0}function Zo(r){if(typeof r=="string"){const s=r.slice(0,64);return/AutoCAD Binary DXF/i.test(s),vt.DXF}const t=r instanceof Uint8Array?r:new Uint8Array(r),o=new TextDecoder("latin1").decode(t.subarray(0,22));if(o.startsWith("AutoCAD Binary DXF"))return vt.DXF;if(o.startsWith("AC1")||o.startsWith("AC2"))return vt.DWG;const e=new TextDecoder("utf-8").decode(t.subarray(0,64));return/^\s*(0|999)\b/.test(e)?vt.DXF:vt.DWG}async function qo(r,t){const o=await $o.create();if(o==null)throw new Error("libredwg is not loaded!");const e=Zo(r),s=o.dwg_read_data(r,e);if(s==null)throw new Error(e===vt.DXF?"Failed to read dxf data!":"Failed to read dwg data!");const _=o.convertEx(s);return Qo(o,s,_.database),jo(o,s,_.database),zo(_.database,e===vt.DWG),o.dwg_free(s),e===vt.DWG&&typeof r!="string"&&Ho(_.database,new Uint8Array(r)),_}function Qo(r,t,o){if(o.header&&!(typeof o.header.ACADVER=="string"&&o.header.ACADVER))try{const e=r.dwg_get_version_type(t);e!=null&&e.hdr&&e.type!=="invalid"&&(o.header.ACADVER=e.hdr)}catch{}}function jo(r,t,o){var f;const e={},s=new Map,_=new Map;for(const h of o.objects.DICTIONARY??[]){const g=he(h.handle);g&&_.set(g,h)}const l=((f=o.tables.BLOCK_RECORD)==null?void 0:f.entries)??[];for(const h of l)for(const g of h.entities??[]){if(g.type!=="DIMENSION")continue;const y=g.styleName;if(!y||e[y]!=null)continue;const T=ti(r,t,g,_,s);T!=null&&T>0&&(e[y]=T)}Object.keys(e).length>0&&(o.dimStyleAnnotationScales=e)}function ti(r,t,o,e,s){var y,T;const _=e.get(he(o.ownerDictionaryHardId)),l=e.get(he((y=_==null?void 0:_.entries)==null?void 0:y.AcDbContextDataManager)),f=e.get(he((T=l==null?void 0:l.entries)==null?void 0:T.ACDB_ANNOTATIONSCALES)),h=f==null?void 0:f.entries;if(!h)return;let g;for(const P of Object.values(h)){const v=ni(r,t,he(P),s);if(v==null)continue;if(ei(r,t,he(P)))return v;g??(g=v)}return g}function ei(r,t,o){const e=Mn(r,t,o);if(!e)return!1;try{const s=r.dwg_dynapi_entity_value(e,"is_default");return!!(s!=null&&s.success)&&Number(s.data)===1}catch{return!1}}function ni(r,t,o,e){const s=Mn(r,t,o);if(s)try{const _=r.dwg_dynapi_entity_value(s,"scale");if(!(_!=null&&_.success)||_.data==null)return;const l=he(r.dwg_ref_get_id(_.data));if(!l)return;const f=e.get(l);if(f!=null)return f;const h=Mn(r,t,l);if(!h)return;const g=r.dwg_dynapi_entity_value(h,"paper_units"),y=r.dwg_dynapi_entity_value(h,"drawing_units");if(!(g!=null&&g.success)||!(y!=null&&y.success))return;const T=Number(g.data),P=Number(y.data);if(!(T>0)||!(P>0))return;const v=P/T;return e.set(l,v),v}catch{return}}function Mn(r,t,o){if(!(!o||!/^[0-9A-F]+$/i.test(o)))try{const e=r.dwg_resolve_handle(t,BigInt("0x"+o));return e?r.dwg_object_to_object_tio(e):void 0}catch{return}}function he(r){return r==null||r===""||r===!1||r===0?"":String(r).trim().toUpperCase()}class ri extends To{async executeTask(t){const o=await qo(t);return{model:o.database,data:o.stats}}}new ri;const ai={},oi=Object.freeze(Object.defineProperty({__proto__:null,default:ai},Symbol.toStringTag,{value:"Module"}));
|
|
35
|
+
</svg>`}}const vr=class Ir{constructor(t){return et(this,"wasmInstance"),et(this,"decoder"),this.wasmInstance=t,new Proxy(this,{get:(o,n,s)=>n in o?Reflect.get(o,n,s):Reflect.get(o.wasmInstance,n,s)})}dwg_read_data(t,o){const n=typeof t=="string"?new TextEncoder().encode(t):new Uint8Array(t);if(o==mt.DWG){const s="tmp.dwg";try{this.wasmInstance.FS.writeFile(s,n);const _=this.wasmInstance.dwg_read_file(s);if(_.error&Nn.OUTOFMEM)throw this.wasmInstance.dwg_abandon(_.data),new Error("Failed to decode DWG: out of WASM memory. Rebuild with pnpm build:wasm (INITIAL_MEMORY=1GB) or use a smaller file.");return _.error!=0,_.data}finally{this.wasmInstance.FS.analyzePath(s,!1).exists&&this.wasmInstance.FS.unlink(s)}}else if(o==mt.DXF){const s="tmp.dxf";try{this.wasmInstance.FS.writeFile(s,n);const _=this.wasmInstance.dxf_read_file(s);if(_.error&Nn.OUTOFMEM)throw this.wasmInstance.dwg_abandon(_.data),new Error("Failed to decode DXF: out of WASM memory. Rebuild with pnpm build:wasm (INITIAL_MEMORY=1GB) or use a smaller file.");return _.error!=0,_.data?_.data:void 0}finally{this.wasmInstance.FS.analyzePath(s,!1).exists&&this.wasmInstance.FS.unlink(s)}}}dwg_write_dxf(t){const o="tmp.dwg",n="tmp.dxf";try{return this.wasmInstance.FS.writeFile(o,new Uint8Array(t)),this.wasmInstance.dwg_write_dxf(o,n)!=0?null:this.wasmInstance.FS.readFile(n)}finally{this.wasmInstance.FS.analyzePath(o,!1).exists&&this.wasmInstance.FS.unlink(o),this.wasmInstance.FS.analyzePath(n,!1).exists&&this.wasmInstance.FS.unlink(n)}}dwg_get_version_type(t){const o=this.wasmInstance.dwg_get_version_type(t);return mo[o]}dwg_get_codepage(t){return this.wasmInstance.dwg_get_codepage(t)}dwg_bmp(t){return this.wasmInstance.dwg_bmp(t)}dwg_get_num_classes(t){return this.wasmInstance.dwg_get_num_classes(t)}dwg_get_class(t,o){return this.wasmInstance.dwg_get_class(t,o)}convert(t){const o=this.dwg_get_codepage(t),n=_r(o);return this.decoder=new TextDecoder(n),new Er(this).convert(t)}convertEx(t){const o=this.dwg_get_codepage(t),n=_r(o);this.decoder=new TextDecoder(n);const s=new Er(this);return{database:s.convert(t),stats:s.getConversionStats()}}dwg_to_svg(t){return new xo().convert(t)}dwg_free(t){if(t)try{this.wasmInstance.dwg_free(t)}catch{try{this.wasmInstance.dwg_abandon(t)}catch{}}}dwg_free_object(t){this.wasmInstance.dwg_free_object(t)}dwg_ref_object(t,o){return this.wasmInstance.dwg_ref_object(t,o)}dwg_ref_object_silent(t,o){return this.wasmInstance.dwg_ref_object_silent(t,o)}dwg_ref_object_relative(t,o,n){return this.wasmInstance.dwg_ref_object_relative(t,o,n)}dwg_resolve_handle(t,o){return this.wasmInstance.dwg_resolve_handle(t,o)}dwg_resolve_handle_silent(t,o){return this.wasmInstance.dwg_resolve_handle_silent(t,o)}dwg_resolve_handleref(t,o){return this.wasmInstance.dwg_resolve_handleref(t,o)}dwg_ref_get_absref(t){if(!t)return null;const o=this.wasmInstance.dwg_ref_get_absref(t);return o===0?null:o}dwg_ref_get_handle_value(t){if(!t)return null;const o=this.wasmInstance.dwg_ref_get_handle_value(t);return o===0n?null:o}dwg_ref_get_handle_absolute_ref(t){if(!t)return null;const o=this.wasmInstance.dwg_ref_get_handle_absolute_ref(t);return o===0n?null:o}dwg_obj_get_handle_value(t){if(!t)return null;const o=this.wasmInstance.dwg_obj_get_handle_value(t);return o===0n?null:o}dwg_ref_get_id(t){const o=this.dwg_ref_get_absref(t);return o==null?void 0:o.toString(16).toUpperCase()}dwg_ref_get_object_name(t){const o=this.wasmInstance,n=o.dwg_ref_get_object(t),s=o.dwg_object_to_object_tio(n);return this.dwg_dynapi_entity_data(s,"name")}dwg_obj_obj_to_object(t){return this.wasmInstance.dwg_obj_obj_to_object(t)}dwg_obj_generic_to_object(t){return this.wasmInstance.dwg_obj_generic_to_object(t)}dwg_object_to_object(t){return this.wasmInstance.dwg_object_to_object(t)}dwg_object_to_object_tio(t){return this.wasmInstance.dwg_object_to_object_tio(t)}dwg_object_to_entity(t){return this.wasmInstance.dwg_object_to_entity(t)}dwg_object_to_entity_tio(t){return this.wasmInstance.dwg_object_to_entity_tio(t)}dwg_getall_entities_in_model_space(t){const o=this.wasmInstance,n=o.dwg_model_space_object(t),s=[];let _=o.get_first_owned_entity(n);for(;_;)s.push(_),_=o.get_next_owned_entity(n,_);return s}dwg_getall_object_by_type(t,o){const n=this.wasmInstance,s=n.dwg_get_num_objects(t),_=[];for(let l=0;l<s;l++){const f=n.dwg_get_object(t,l),h=n.dwg_object_to_object_tio(f);h&&n.dwg_object_get_fixedtype(f)==o&&_.push(h)}return _}dwg_getall_entity_by_type(t,o){const n=this.wasmInstance,s=n.dwg_get_num_objects(t),_=[];for(let l=0;l<s;l++){const f=n.dwg_get_object(t,l),h=n.dwg_object_to_entity_tio(f);h&&n.dwg_object_get_fixedtype(f)==o&&_.push(h)}return _}dwg_getall_LAYER(t){return this.dwg_getall_object_by_type(t,R.DWG_TYPE_LAYER)}dwg_getall_LTYPE(t){return this.dwg_getall_object_by_type(t,R.DWG_TYPE_LTYPE)}dwg_getall_STYLE(t){return this.dwg_getall_object_by_type(t,R.DWG_TYPE_STYLE)}dwg_getall_DIMSTYLE(t){return this.dwg_getall_object_by_type(t,R.DWG_TYPE_DIMSTYLE)}dwg_getall_VPORT(t){return this.dwg_getall_object_by_type(t,R.DWG_TYPE_VPORT)}dwg_getall_LAYOUT(t){return this.dwg_getall_object_by_type(t,R.DWG_TYPE_LAYOUT)}dwg_getall_BLOCK(t){return this.dwg_getall_object_by_type(t,R.DWG_TYPE_BLOCK)}dwg_getall_BLOCK_HEADER(t){return this.dwg_getall_object_by_type(t,R.DWG_TYPE_BLOCK_HEADER)}dwg_getall_IMAGEDEF(t){return this.dwg_getall_object_by_type(t,R.DWG_TYPE_IMAGEDEF)}dwg_getall_VERTEX_2D(t){return this.dwg_getall_entity_by_type(t,R.DWG_TYPE_VERTEX_2D)}dwg_getall_VERTEX_3D(t){return this.dwg_getall_entity_by_type(t,R.DWG_TYPE_VERTEX_3D)}dwg_getall_POLYLINE_2D(t){return this.dwg_getall_entity_by_type(t,R.DWG_TYPE_POLYLINE_2D)}dwg_getall_POLYLINE_3D(t){return this.dwg_getall_entity_by_type(t,R.DWG_TYPE_POLYLINE_3D)}dwg_getall_IMAGE(t){return this.dwg_getall_entity_by_type(t,R.DWG_TYPE_IMAGE)}dwg_getall_LWPOLYLINE(t){return this.dwg_getall_entity_by_type(t,R.DWG_TYPE_LWPOLYLINE)}dwg_ptr_to_object_ref_array(t,o){return this.wasmInstance.dwg_ptr_to_object_ref_array(t,o)}dwg_ptr_to_object_ref_ptr_array(t,o){return this.wasmInstance.dwg_ptr_to_object_ref_ptr_array(t,o)}dwg_ptr_to_wchar_string_array(t,o){return this.wasmInstance.dwg_ptr_to_wchar_string_array(t,o)}dwg_ptr_to_unsigned_char_array(t,o){return this.wasmInstance.dwg_ptr_to_unsigned_char_array(t,o)}dwg_ptr_to_signed_char_array(t,o){return this.wasmInstance.dwg_ptr_to_signed_char_array(t,o)}dwg_ptr_to_uint16_t_array(t,o){return this.wasmInstance.dwg_ptr_to_uint16_t_array(t,o)}dwg_ptr_to_int16_t_array(t,o){return this.wasmInstance.dwg_ptr_to_int16_t_array(t,o)}dwg_ptr_to_uint32_t_array(t,o){return this.wasmInstance.dwg_ptr_to_uint32_t_array(t,o)}dwg_ptr_to_int32_t_array(t,o){return this.wasmInstance.dwg_ptr_to_int32_t_array(t,o)}dwg_ptr_to_uint64_t_array(t,o){return this.wasmInstance.dwg_ptr_to_uint64_t_array(t,o)}dwg_ptr_to_int64_t_array(t,o){return this.wasmInstance.dwg_ptr_to_int64_t_array(t,o)}dwg_ptr_to_double_array(t,o){return this.wasmInstance.dwg_ptr_to_double_array(t,o)}dwg_ptr_to_point2d_array(t,o){return this.wasmInstance.dwg_ptr_to_point2d_array(t,o)}dwg_ptr_to_point3d_array(t,o){return this.wasmInstance.dwg_ptr_to_point3d_array(t,o)}dwg_ptr_to_point4d_array(t,o){return this.wasmInstance.dwg_ptr_to_point4d_array(t,o)}dwg_ptr_to_ltype_dash_array(t,o){return this.wasmInstance.dwg_ptr_to_ltype_dash_array(t,o)}dwg_ptr_to_table_cell_array(t,o){return this.wasmInstance.dwg_ptr_to_table_cell_array(t,o)}dwg_ptr_to_hatch_defline_array(t,o){return this.wasmInstance.dwg_ptr_to_hatch_defline_array(t,o)}dwg_ptr_to_hatch_path_array(t,o){return this.wasmInstance.dwg_ptr_to_hatch_path_array(t,o)}dwg_ptr_to_hatch_gradient_color_array(t,o){return this.wasmInstance.dwg_ptr_to_hatch_gradient_color_array(t,o)}dwg_ptr_to_mline_vertex_array(t,o){return this.wasmInstance.dwg_ptr_to_mline_vertex_array(t,o)}dwg_dynapi_entity_value(t,o){const n=this.wasmInstance.dwg_dynapi_entity_value(t,o);return n.bin&&this.decoder&&(n.data=this.decoder.decode(n.bin)),typeof n.data=="string"&&(n.data=dr(n.data)),n}dwg_dynapi_entity_data(t,o){return this.dwg_dynapi_entity_value(t,o).data}dwg_dynapi_header_value(t,o){return this.wasmInstance.dwg_dynapi_header_value(t,o)}dwg_dynapi_header_data(t,o){return this.dwg_dynapi_header_value(t,o).data}dwg_dynapi_common_value(t,o){return this.wasmInstance.dwg_dynapi_common_value(t,o)}dwg_dynapi_common_data(t,o){return this.dwg_dynapi_common_value(t,o).data}dwg_dynapi_subclass_value(t,o,n){const s=this.wasmInstance.dwg_dynapi_subclass_value(t,o,n);return s.bin&&this.decoder&&(s.data=this.decoder.decode(s.bin)),typeof s.data=="string"&&(s.data=dr(s.data)),s}dwg_dynapi_subclass_data(t,o,n){return this.dwg_dynapi_subclass_value(t,o,n).data}dwg_dynapi_subclass_size(t){return this.wasmInstance.dwg_dynapi_subclass_size(t)}dwg_dynapi_entity_field_offset(t,o){return this.wasmInstance.dwg_dynapi_entity_field_offset(t,o)}dwg_dynapi_subclass_field_offset(t,o){return this.wasmInstance.dwg_dynapi_subclass_field_offset(t,o)}dwg_object_get_handle_object(t){return this.wasmInstance.dwg_object_get_handle_object(t)}dwg_object_object_get_handle_object(t){return this.wasmInstance.dwg_object_object_get_handle_object(t)}dwg_object_object_get_ownerhandle_object(t){return this.wasmInstance.dwg_object_object_get_ownerhandle_object(t)}dwg_object_entity_get_handle_object(t){return this.wasmInstance.dwg_object_entity_get_handle_object(t)}dwg_object_entity_get_ownerhandle_object(t){return this.wasmInstance.dwg_object_entity_get_ownerhandle_object(t)}dwg_object_entity_get_xdicobjhandle_object(t){return this.wasmInstance.dwg_object_entity_get_xdicobjhandle_object(t)}dwg_object_entity_get_layer_object_ref(t){return this.wasmInstance.dwg_object_entity_get_layer_object_ref(t)}dwg_object_entity_get_ltype_object_ref(t){return this.wasmInstance.dwg_object_entity_get_ltype_object_ref(t)}dwg_object_entity_get_color_object(t){return this.wasmInstance.dwg_object_entity_get_color_object(t)}dwg_object_entity_get_xdata(t){return this.wasmInstance.dwg_object_entity_get_xdata(t)}dwg_object_object_get_xdicobjhandle_object(t){return this.wasmInstance.dwg_object_object_get_xdicobjhandle_object(t)}dwg_object_xrecord_get_xdata(t){return this.wasmInstance.dwg_object_xrecord_get_xdata(t)??[]}dwg_entity_owner(t){return this.wasmInstance.dwg_entity_owner(t)}dwg_entity_get_block_name(t,o){const n=this.wasmInstance,s=this.dwg_dynapi_entity_data(t,o),_=n.dwg_ref_get_object(s),l=n.dwg_object_to_object_tio(_);return this.dwg_entity_block_header_get_block(l).name}dwg_entity_get_dimstyle_name(t,o="dimstyle"){const n=this.wasmInstance,s=this.dwg_dynapi_entity_data(t,o),_=n.dwg_ref_get_object(s),l=n.dwg_object_to_object_tio(_);return this.dwg_dynapi_entity_data(l,"name")}dwg_entity_block_header_get_block(t){const o=this.wasmInstance,n=this.dwg_dynapi_entity_data(t,"block_entity"),s=o.dwg_ref_get_object(n),_=o.dwg_object_to_entity_tio(s),l=this.dwg_dynapi_entity_data(_,"name"),f=this.dwg_dynapi_entity_data(_,"base_pt");return{name:l,base_pt:f}}dwg_entity_block_header_get_preview(t){const o=this.wasmInstance;if(typeof o.dwg_entity_block_header_get_preview!="function")return null;const n=o.dwg_entity_block_header_get_preview(t);return(n==null?void 0:n.data)??null}dwg_entity_get_preview(t){const o=this.wasmInstance;if(typeof o.dwg_entity_get_preview!="function")return null;const n=o.dwg_entity_get_preview(t);return(n==null?void 0:n.data)??null}dwg_entity_proxy_entity_get_entity_data(t){const o=this.wasmInstance;if(typeof o.dwg_entity_proxy_entity_get_entity_data!="function")return null;const n=o.dwg_entity_proxy_entity_get_entity_data(t);return(n==null?void 0:n.data)??null}dwg_entity_ole2frame_get_data(t){const o=this.wasmInstance;if(typeof o.dwg_entity_ole2frame_get_data!="function")return null;const n=o.dwg_entity_ole2frame_get_data(t);return(n==null?void 0:n.data)??null}dwg_entity_oleframe_get_data(t){const o=this.wasmInstance;if(typeof o.dwg_entity_oleframe_get_data!="function")return null;const n=o.dwg_entity_oleframe_get_data(t);return(n==null?void 0:n.data)??null}get_first_owned_entity(t){return this.wasmInstance.get_first_owned_entity(t)}get_next_owned_entity(t,o){return this.wasmInstance.get_next_owned_entity(t,o)}dwg_entity_mtext_get_style_name(t){const o=this.wasmInstance,n=this.dwg_dynapi_entity_data(t,"style"),s=o.dwg_ref_get_object(n),_=o.dwg_object_to_object_tio(s);return this.dwg_dynapi_entity_data(_,"name")}dwg_entity_text_get_style_name(t){return this.dwg_entity_mtext_get_style_name(t)}dwg_entity_polyline_2d_get_numpoints(t){return this.wasmInstance.dwg_entity_polyline_2d_get_numpoints(t).data}dwg_entity_polyline_2d_get_points(t){return this.wasmInstance.dwg_entity_polyline_2d_get_points(t).data}dwg_entity_polyline_2d_get_vertices(t){return this.wasmInstance.dwg_entity_polyline_2d_get_vertices(t).data}dwg_entity_mesh_get_data(t){const n=this.wasmInstance.dwg_entity_mesh_get_data(t);return{subdivisionLevel:n.subdivisionLevel??0,vertices:n.vertices??new Float64Array(0),faces:n.faces??new Uint32Array(0)}}dwg_entity_polyline_3d_get_numpoints(t){return this.wasmInstance.dwg_entity_polyline_3d_get_numpoints(t).data}dwg_entity_polyline_3d_get_points(t){return this.wasmInstance.dwg_entity_polyline_3d_get_points(t).data}dwg_entity_polyline_3d_get_vertices(t){return this.wasmInstance.dwg_entity_polyline_3d_get_vertices(t).data}dwg_entity_insert_get_attribs(t){return this.wasmInstance.dwg_entity_insert_get_attribs(t).data}dwg_object_dictionary_get_texts(t){return this.wasmInstance.dwg_object_dictionary_get_texts(t).data}static createByWasmInstance(t){return this.instance==null?new Ir(t):this.instance}static async create(t){const o=t==null?await sr():await sr({locateFile:n=>`${t}/${n}`});return this.createByWasmInstance(o)}};et(vr,"instance");let Oo=vr;const ln=new Uint8Array([31,37,109,7,212,54,40,40,157,87,202,63,157,68,16,43]);function ko(r){if(r.length<17)return;const t=new DataView(r.buffer,r.byteOffset,r.byteLength).getUint32(13,!0),o=fr(r,t);if(o)return o;const n=Math.min(r.length,1024*1024);for(let s=0;s+ln.length<=n;s++){if(!mr(r,s,ln)||s===t)continue;const _=fr(r,s);if(_)return _}}function Bo(r,t){var n;if((n=r.thumbnailImage)!=null&&n.length)return;const o=ko(t);o!=null&&o.length&&(r.thumbnailImage=o)}function fr(r,t){if(t<=0||t>=r.length||!mr(r,t,ln))return;let o=t+ln.length;if(o+5>r.length)return;const n=new DataView(r.buffer,r.byteOffset,r.byteLength);n.getInt32(o,!0),o+=4;const s=r[o];if(o+=1,s<=0||s>16)return;const _=[];for(let h=0;h<s;h++){if(o+9>r.length)return;const g=r[o];o+=1;const y=n.getInt32(o,!0);o+=4;const P=n.getInt32(o,!0);o+=4,_.push({code:g,start:y,size:P})}const l=o,f=hr(r,_,"absolute");return f||hr(r,_,"sequential",l)}function hr(r,t,o,n=0){let s,_=n;for(const l of t){const f=o==="absolute"?l.start:_;if(o==="sequential"&&(_+=Math.max(0,l.size)),l.code!==2&&l.code!==6)continue;const h=Fo(r,f,l.size);if(h!=null&&h.length){if(l.code===6)return h.slice();s||(s=h.slice())}}return s}function Fo(r,t,o){if(!(t<0||o<=0)&&!(t+o>r.length))return r.subarray(t,t+o)}function mr(r,t,o){if(t+o.length>r.length)return!1;for(let n=0;n<o.length;n++)if(r[t+n]!==o[n])return!1;return!0}const Uo=[0,5,9,13,15,18,20,25,30,35,40,50,53,60,70,80,90,100,106,120,140,158,200,211];function gr(r,t=Ht.ByLayer){return r===29?Ht.ByLayer:r===30?Ht.ByBlock:r===31?Ht.ByLineWeightDefault:Uo[r]??t}function $o(r,t){var _,l,f,h,g;const o=!t||Vo((_=r.header)==null?void 0:_.ACADVER);for(const y of((f=(l=r.tables)==null?void 0:l.LAYER)==null?void 0:f.entries)??[])y.lineweight!=null&&(y.lineweight=o?gr(y.lineweight,Ht.ByLineWeightDefault):Ht.ByLineWeightDefault);const n=new Set,s=y=>{if(y)for(const P of y)n.has(P)||(n.add(P),P.lineweight!=null&&(P.lineweight=o?gr(P.lineweight):Ht.ByLayer),s(P.attribs),s(P.vertices))};s(r.entities);for(const y of((g=(h=r.tables)==null?void 0:h.BLOCK_RECORD)==null?void 0:g.entries)??[])s(y.entities)}function Vo(r){const t=typeof r=="string"?/^AC(\d{4})$/.exec(r.trim()):null;return t?Number(t[1])>=1015:!0}function Ho(r){if(typeof r=="string"){const s=r.slice(0,64);return/AutoCAD Binary DXF/i.test(s),mt.DXF}const t=r instanceof Uint8Array?r:new Uint8Array(r),o=new TextDecoder("latin1").decode(t.subarray(0,22));if(o.startsWith("AutoCAD Binary DXF"))return mt.DXF;if(o.startsWith("AC1")||o.startsWith("AC2"))return mt.DWG;const n=new TextDecoder("utf-8").decode(t.subarray(0,64));return/^\s*(0|999)\b/.test(n)?mt.DXF:mt.DWG}async function Xo(r,t){const o=await Oo.create();if(o==null)throw new Error("libredwg is not loaded!");const n=Ho(r),s=o.dwg_read_data(r,n);if(s==null)throw new Error(n===mt.DXF?"Failed to read dxf data!":"Failed to read dwg data!");const _=o.convertEx(s);return Ko(o,s,_.database),zo(o,s,_.database),$o(_.database,n===mt.DWG),o.dwg_free(s),n===mt.DWG&&typeof r!="string"&&Bo(_.database,new Uint8Array(r)),_}function Ko(r,t,o){if(o.header&&!(typeof o.header.ACADVER=="string"&&o.header.ACADVER))try{const n=r.dwg_get_version_type(t);n!=null&&n.hdr&&n.type!=="invalid"&&(o.header.ACADVER=n.hdr)}catch{}}function zo(r,t,o){var f;const n={},s=new Map,_=new Map;for(const h of o.objects.DICTIONARY??[]){const g=Ae(h.handle);g&&_.set(g,h)}const l=((f=o.tables.BLOCK_RECORD)==null?void 0:f.entries)??[];for(const h of l)for(const g of h.entities??[]){if(g.type!=="DIMENSION")continue;const y=g.styleName;if(!y||n[y]!=null)continue;const P=Jo(r,t,g,_,s);P!=null&&P>0&&(n[y]=P)}Object.keys(n).length>0&&(o.dimStyleAnnotationScales=n)}function Jo(r,t,o,n,s){var y,P;const _=n.get(Ae(o.ownerDictionaryHardId)),l=n.get(Ae((y=_==null?void 0:_.entries)==null?void 0:y.AcDbContextDataManager)),f=n.get(Ae((P=l==null?void 0:l.entries)==null?void 0:P.ACDB_ANNOTATIONSCALES)),h=f==null?void 0:f.entries;if(!h)return;let g;for(const p of Object.values(h)){const I=qo(r,t,Ae(p),s);if(I==null)continue;if(Zo(r,t,Ae(p)))return I;g??(g=I)}return g}function Zo(r,t,o){const n=Gn(r,t,o);if(!n)return!1;try{const s=r.dwg_dynapi_entity_value(n,"is_default");return!!(s!=null&&s.success)&&Number(s.data)===1}catch{return!1}}function qo(r,t,o,n){const s=Gn(r,t,o);if(s)try{const _=r.dwg_dynapi_entity_value(s,"scale");if(!(_!=null&&_.success)||_.data==null)return;const l=Ae(r.dwg_ref_get_id(_.data));if(!l)return;const f=n.get(l);if(f!=null)return f;const h=Gn(r,t,l);if(!h)return;const g=r.dwg_dynapi_entity_value(h,"paper_units"),y=r.dwg_dynapi_entity_value(h,"drawing_units");if(!(g!=null&&g.success)||!(y!=null&&y.success))return;const P=Number(g.data),p=Number(y.data);if(!(P>0)||!(p>0))return;const I=p/P;return n.set(l,I),I}catch{return}}function Gn(r,t,o){if(!(!o||!/^[0-9A-F]+$/i.test(o)))try{const n=r.dwg_resolve_handle(t,BigInt("0x"+o));return n?r.dwg_object_to_object_tio(n):void 0}catch{return}}function Ae(r){return r==null||r===""||r===!1||r===0?"":String(r).trim().toUpperCase()}class Qo extends ho{async executeTask(t){const o=await Xo(t);return{model:o.database,data:o.stats}}}new Qo;const jo={},ti=Object.freeze(Object.defineProperty({__proto__:null,default:jo},Symbol.toStringTag,{value:"Module"}));
|