@mlightcad/cad-simple-viewer-cli 1.5.11 → 1.6.0

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 mlightcad
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 mlightcad
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,139 +1,139 @@
1
- # @mlightcad/cad-simple-viewer-cli
2
-
3
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
- [![npm version](https://img.shields.io/npm/v/@mlightcad/cad-simple-viewer-cli.svg)](https://www.npmjs.com/package/@mlightcad/cad-simple-viewer-cli)
5
-
6
- AcCoreConsole-style **headless** CLI for MLight CAD Viewer. Install from npm, open a DXF/DWG (or start blank), run an AutoCAD-like **`.scr` command script**, and save exports (`pngout`, `-chtml`, `cdxf`, …) to disk.
7
-
8
- Requires **Node.js 20+**. The CLI uses headless Chromium via Playwright; on first use you must install the browser once.
9
-
10
- ## Install
11
-
12
- ```bash
13
- npm install -g @mlightcad/cad-simple-viewer-cli
14
- npx playwright install chromium
15
- ```
16
-
17
- Or as a project dependency:
18
-
19
- ```bash
20
- npm install -D @mlightcad/cad-simple-viewer-cli
21
- npx playwright install chromium
22
- ```
23
-
24
- ## Quick start
25
-
26
- ```bash
27
- # Export a drawing to PNG (sample script shipped with the package)
28
- cad-simple-viewer-cli \
29
- -i ./drawing.dwg \
30
- -s node_modules/@mlightcad/cad-simple-viewer-cli/examples/export-png.scr \
31
- -o ./out
32
-
33
- # Global install: same, with your own script
34
- cad-simple-viewer-cli -i ./drawing.dxf -s ./export-png.scr -o ./out
35
-
36
- # Open from URL
37
- cad-simple-viewer-cli \
38
- -i https://cdn.jsdelivr.net/gh/mlightcad/cad-data@main/data/canteen.dwg \
39
- -s ./export-png.scr \
40
- -o ./out
41
-
42
- # No input file: start from a blank ISO drawing (write mode)
43
- cad-simple-viewer-cli -s ./create-drawing-dxf.scr -o ./out --mode write
44
- ```
45
-
46
- With a local install, use `npx`:
47
-
48
- ```bash
49
- npx cad-simple-viewer-cli -i ./drawing.dwg -s ./export-png.scr -o ./out
50
- ```
51
-
52
- ## Options
53
-
54
- | Option | Description |
55
- |--------|-------------|
56
- | `-i, --input <file-or-url>` | Local `.dxf` / `.dwg` path or `http(s)` URL. Omit to start from a blank ISO template |
57
- | `-s, --script <file>` | `.scr` command script (**required**) |
58
- | `-o, --output <dir>` | Directory for downloaded exports (default: input file’s directory, or cwd when no `-i`) |
59
- | `--mode <read\|write>` | Document open mode (default: `read` with `-i`, `write` without `-i`) |
60
- | `--locale <code>` | Prompt/keyword locale (`en`, `zh`, …) |
61
- | `--logfile <path>` | Append start / finish / download log lines |
62
-
63
- ## AcCoreConsole mapping
64
-
65
- | AcCoreConsole | cad-simple-viewer-cli |
66
- |---------------|------------------------|
67
- | `accoreconsole /i drawing.dwg /s script.scr` | `cad-simple-viewer-cli -i drawing.dwg -s script.scr` |
68
- | `/i` | `-i, --input` (optional path or URL) |
69
- | `/s` | `-s, --script` |
70
- | plot / export path | `-o, --output` (download directory) |
71
-
72
- ## Script format
73
-
74
- 1. First non-blank line of each command is the **command name**
75
- 2. Following lines answer prompts (empty line = Enter / default / None)
76
- 3. Full-line `;` comments are ignored
77
- 4. `QUIT` / `EXIT` ends the script
78
-
79
- Example — zoom extents, then PNG (long side 2048):
80
-
81
- ```
82
- ; export-png.scr
83
- zoom
84
- e
85
- pngout
86
-
87
- 2048
88
- quit
89
- ```
90
-
91
- Useful commands (non-exhaustive): `zoom`, `pngout`, `cdxf`, `-chtml`, `chtml`, `cpdf`, `csvg`, `-layer`, `qnew`, `line`, `circle`, …
92
-
93
- Layer edits need `--mode write`. Export commands write files via browser download; the CLI captures them into `-o`.
94
-
95
- ## Sample scripts
96
-
97
- After install, examples live under `node_modules/@mlightcad/cad-simple-viewer-cli/examples/` (or the global package folder):
98
-
99
- | Script | Purpose |
100
- |--------|---------|
101
- | `export-png.scr` | Zoom extents → PNG |
102
- | `export-html.scr` | Offline HTML (`-chtml`) |
103
- | `export-dxf.scr` | DXF download (`cdxf`) |
104
- | `create-drawing-dxf.scr` | Blank drawing + LINE → DXF (no `-i`) |
105
- | `create-shapes-dxf.scr` | Blank drawing + LINE + CIRCLE → DXF |
106
- | `create-drawing-png.scr` | Blank drawing → PNG |
107
- | `freeze-layer-png.scr` | `-layer` Off then PNG (`--mode write`; edit `LAYER_NAME`) |
108
- | `batch-export-png.mjs` | Scan a folder of drawings → PNG |
109
- | `batch-export-html.mjs` | Scan a folder → HTML |
110
-
111
- Batch helpers (from your project after `npm install -D`):
112
-
113
- ```bash
114
- node node_modules/@mlightcad/cad-simple-viewer-cli/examples/batch-export-png.mjs ./drawings ./out-png
115
- node node_modules/@mlightcad/cad-simple-viewer-cli/examples/batch-export-html.mjs ./drawings ./out-html
116
- ```
117
-
118
- ## Programmatic API
119
-
120
- ```js
121
- import { runHeadless } from '@mlightcad/cad-simple-viewer-cli'
122
-
123
- const { outputDir, savedFiles } = await runHeadless({
124
- inputPath: './drawing.dwg', // optional; omit for blank drawing
125
- scriptPath: './export-png.scr',
126
- outputDir: './out',
127
- mode: 'read', // optional
128
- locale: 'en', // optional
129
- logfile: './cli.log' // optional
130
- })
131
-
132
- console.log(outputDir, savedFiles)
133
- ```
134
-
135
- ## How it works
136
-
137
- 1. The published package includes a prebuilt Playwright runner (`dist-runner/`).
138
- 2. The CLI starts headless Chromium, opens the drawing (or a blank template), waits for entity convert / deferred text geometry, then runs `AcApDocManager.runScript()`.
139
- 3. Export commands trigger downloads; the CLI writes captured files under `-o`.
1
+ # @mlightcad/cad-simple-viewer-cli
2
+
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
+ [![npm version](https://img.shields.io/npm/v/@mlightcad/cad-simple-viewer-cli.svg)](https://www.npmjs.com/package/@mlightcad/cad-simple-viewer-cli)
5
+
6
+ AcCoreConsole-style **headless** CLI for MLight CAD Viewer. Install from npm, open a DXF/DWG (or start blank), run an AutoCAD-like **`.scr` command script**, and save exports (`pngout`, `-chtml`, `cdxf`, …) to disk.
7
+
8
+ Requires **Node.js 20+**. The CLI uses headless Chromium via Playwright; on first use you must install the browser once.
9
+
10
+ ## Install
11
+
12
+ ```bash
13
+ npm install -g @mlightcad/cad-simple-viewer-cli
14
+ npx playwright install chromium
15
+ ```
16
+
17
+ Or as a project dependency:
18
+
19
+ ```bash
20
+ npm install -D @mlightcad/cad-simple-viewer-cli
21
+ npx playwright install chromium
22
+ ```
23
+
24
+ ## Quick start
25
+
26
+ ```bash
27
+ # Export a drawing to PNG (sample script shipped with the package)
28
+ cad-simple-viewer-cli \
29
+ -i ./drawing.dwg \
30
+ -s node_modules/@mlightcad/cad-simple-viewer-cli/examples/export-png.scr \
31
+ -o ./out
32
+
33
+ # Global install: same, with your own script
34
+ cad-simple-viewer-cli -i ./drawing.dxf -s ./export-png.scr -o ./out
35
+
36
+ # Open from URL
37
+ cad-simple-viewer-cli \
38
+ -i https://cdn.jsdelivr.net/gh/mlightcad/cad-data@main/data/canteen.dwg \
39
+ -s ./export-png.scr \
40
+ -o ./out
41
+
42
+ # No input file: start from a blank ISO drawing (write mode)
43
+ cad-simple-viewer-cli -s ./create-drawing-dxf.scr -o ./out --mode write
44
+ ```
45
+
46
+ With a local install, use `npx`:
47
+
48
+ ```bash
49
+ npx cad-simple-viewer-cli -i ./drawing.dwg -s ./export-png.scr -o ./out
50
+ ```
51
+
52
+ ## Options
53
+
54
+ | Option | Description |
55
+ |--------|-------------|
56
+ | `-i, --input <file-or-url>` | Local `.dxf` / `.dwg` path or `http(s)` URL. Omit to start from a blank ISO template |
57
+ | `-s, --script <file>` | `.scr` command script (**required**) |
58
+ | `-o, --output <dir>` | Directory for downloaded exports (default: input file’s directory, or cwd when no `-i`) |
59
+ | `--mode <read\|write>` | Document open mode (default: `read` with `-i`, `write` without `-i`) |
60
+ | `--locale <code>` | Prompt/keyword locale (`en`, `zh`, …) |
61
+ | `--logfile <path>` | Append start / finish / download log lines |
62
+
63
+ ## AcCoreConsole mapping
64
+
65
+ | AcCoreConsole | cad-simple-viewer-cli |
66
+ |---------------|------------------------|
67
+ | `accoreconsole /i drawing.dwg /s script.scr` | `cad-simple-viewer-cli -i drawing.dwg -s script.scr` |
68
+ | `/i` | `-i, --input` (optional path or URL) |
69
+ | `/s` | `-s, --script` |
70
+ | plot / export path | `-o, --output` (download directory) |
71
+
72
+ ## Script format
73
+
74
+ 1. First non-blank line of each command is the **command name**
75
+ 2. Following lines answer prompts (empty line = Enter / default / None)
76
+ 3. Full-line `;` comments are ignored
77
+ 4. `QUIT` / `EXIT` ends the script
78
+
79
+ Example — zoom extents, then PNG (long side 2048):
80
+
81
+ ```
82
+ ; export-png.scr
83
+ zoom
84
+ e
85
+ pngout
86
+
87
+ 2048
88
+ quit
89
+ ```
90
+
91
+ Useful commands (non-exhaustive): `zoom`, `pngout`, `cdxf`, `-chtml`, `chtml`, `cpdf`, `csvg`, `-layer`, `qnew`, `line`, `circle`, …
92
+
93
+ Layer edits need `--mode write`. Export commands write files via browser download; the CLI captures them into `-o`.
94
+
95
+ ## Sample scripts
96
+
97
+ After install, examples live under `node_modules/@mlightcad/cad-simple-viewer-cli/examples/` (or the global package folder):
98
+
99
+ | Script | Purpose |
100
+ |--------|---------|
101
+ | `export-png.scr` | Zoom extents → PNG |
102
+ | `export-html.scr` | Offline HTML (`-chtml`) |
103
+ | `export-dxf.scr` | DXF download (`cdxf`) |
104
+ | `create-drawing-dxf.scr` | Blank drawing + LINE → DXF (no `-i`) |
105
+ | `create-shapes-dxf.scr` | Blank drawing + LINE + CIRCLE → DXF |
106
+ | `create-drawing-png.scr` | Blank drawing → PNG |
107
+ | `freeze-layer-png.scr` | `-layer` Off then PNG (`--mode write`; edit `LAYER_NAME`) |
108
+ | `batch-export-png.mjs` | Scan a folder of drawings → PNG |
109
+ | `batch-export-html.mjs` | Scan a folder → HTML |
110
+
111
+ Batch helpers (from your project after `npm install -D`):
112
+
113
+ ```bash
114
+ node node_modules/@mlightcad/cad-simple-viewer-cli/examples/batch-export-png.mjs ./drawings ./out-png
115
+ node node_modules/@mlightcad/cad-simple-viewer-cli/examples/batch-export-html.mjs ./drawings ./out-html
116
+ ```
117
+
118
+ ## Programmatic API
119
+
120
+ ```js
121
+ import { runHeadless } from '@mlightcad/cad-simple-viewer-cli'
122
+
123
+ const { outputDir, savedFiles } = await runHeadless({
124
+ inputPath: './drawing.dwg', // optional; omit for blank drawing
125
+ scriptPath: './export-png.scr',
126
+ outputDir: './out',
127
+ mode: 'read', // optional
128
+ locale: 'en', // optional
129
+ logfile: './cli.log' // optional
130
+ })
131
+
132
+ console.log(outputDir, savedFiles)
133
+ ```
134
+
135
+ ## How it works
136
+
137
+ 1. The published package includes a prebuilt Playwright runner (`dist-runner/`).
138
+ 2. The CLI starts headless Chromium, opens the drawing (or a blank template), waits for entity convert / deferred text geometry, then runs `AcApDocManager.runScript()`.
139
+ 3. Export commands trigger downloads; the CLI writes captured files under `-o`.
@@ -1,4 +1,4 @@
1
- import{y as Ee,z as Ne,u as Ct,h as v,v as dt,w as B,c as Ze,a as D,b as Ye,t as Xe,k as Ge,i as We,n as Ke,T as ee,f as Je,E as ne,d as qe,L as Qe,e as tn,M as en,g as Ot,j as nn,l as rn,S as an,m as on,A as ln,o as sn,p as cn,q as dn,r as _t,s as un,x as fn,B as mn,C as pn,D as hn,F as gn,G as wn,H as yn,I as vn,J as bn,K as xn,N as An,O as kn,P as Mn,Q as Cn,R as Ln,U as Sn,V as zn,W as Pn,X as R,Y as yt,Z as Pe,_ as In,$ as vt,a0 as Bn,a1 as Un,a2 as $n,a3 as jn}from"./index-rDY9i-tf.js";import{a4 as Ka,a5 as Ja}from"./index-rDY9i-tf.js";const ft=2;var P=Uint8Array,z=Uint16Array,Et=Int32Array,Nt=new P([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Zt=new P([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),re=new P([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ie=function(t,e){for(var n=new z(31),r=0;r<31;++r)n[r]=e+=1<<t[r-1];for(var a=new Et(n[30]),r=1;r<30;++r)for(var i=n[r];i<n[r+1];++i)a[i]=i-n[r]<<5|r;return{b:n,r:a}},Be=Ie(Nt,2),Tn=Be.b,Ut=Be.r;Tn[28]=258,Ut[258]=28;var Hn=Ie(Zt,0),ae=Hn.r,$t=new z(32768);for(var y=0;y<32768;++y){var G=(y&43690)>>1|(y&21845)<<1;G=(G&52428)>>2|(G&13107)<<2,G=(G&61680)>>4|(G&3855)<<4,$t[y]=((G&65280)>>8|(G&255)<<8)>>1}var ut=(function(t,e,n){for(var r=t.length,a=0,i=new z(e);a<r;++a)t[a]&&++i[t[a]-1];var o=new z(e);for(a=1;a<e;++a)o[a]=o[a-1]+i[a-1]<<1;var l;if(n){l=new z(1<<e);var s=15-e;for(a=0;a<r;++a)if(t[a])for(var c=a<<4|t[a],d=e-t[a],u=o[t[a]-1]++<<d,f=u|(1<<d)-1;u<=f;++u)l[$t[u]>>s]=c}else for(l=new z(r),a=0;a<r;++a)t[a]&&(l[a]=$t[o[t[a]-1]++]>>15-t[a]);return l}),J=new P(288);for(var y=0;y<144;++y)J[y]=8;for(var y=144;y<256;++y)J[y]=9;for(var y=256;y<280;++y)J[y]=7;for(var y=280;y<288;++y)J[y]=8;var pt=new P(32);for(var y=0;y<32;++y)pt[y]=5;var Fn=ut(J,9,0),Dn=ut(pt,5,0),Ue=function(t){return(t+7)/8|0},$e=function(t,e,n){return(n==null||n>t.length)&&(n=t.length),new P(t.subarray(e,n))},Z=function(t,e,n){n<<=e&7;var r=e/8|0;t[r]|=n,t[r+1]|=n>>8},st=function(t,e,n){n<<=e&7;var r=e/8|0;t[r]|=n,t[r+1]|=n>>8,t[r+2]|=n>>16},Lt=function(t,e){for(var n=[],r=0;r<t.length;++r)t[r]&&n.push({s:r,f:t[r]});var a=n.length,i=n.slice();if(!a)return{t:Te,l:0};if(a==1){var o=new P(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(I,j){return I.f-j.f}),n.push({s:-1,f:25001});var l=n[0],s=n[1],c=0,d=1,u=2;for(n[0]={s:-1,f:l.f+s.f,l,r:s};d!=a-1;)l=n[n[c].f<n[u].f?c++:u++],s=n[c!=d&&n[c].f<n[u].f?c++:u++],n[d++]={s:-1,f:l.f+s.f,l,r:s};for(var f=i[0].s,r=1;r<a;++r)i[r].s>f&&(f=i[r].s);var p=new z(f+1),g=jt(n[d-1],p,0);if(g>e){var r=0,m=0,x=g-e,V=1<<x;for(i.sort(function(j,C){return p[C.s]-p[j.s]||j.f-C.f});r<a;++r){var N=i[r].s;if(p[N]>e)m+=V-(1<<g-p[N]),p[N]=e;else break}for(m>>=x;m>0;){var W=i[r].s;p[W]<e?m-=1<<e-p[W]++-1:++r}for(;r>=0&&m;--r){var $=i[r].s;p[$]==e&&(--p[$],++m)}g=e}return{t:new P(p),l:g}},jt=function(t,e,n){return t.s==-1?Math.max(jt(t.l,e,n+1),jt(t.r,e,n+1)):e[t.s]=n},ie=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new z(++e),r=0,a=t[0],i=1,o=function(s){n[r++]=s},l=1;l<=e;++l)if(t[l]==a&&l!=e)++i;else{if(!a&&i>2){for(;i>138;i-=138)o(32754);i>2&&(o(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(o(a),--i;i>6;i-=6)o(8304);i>2&&(o(i-3<<5|8208),i=0)}for(;i--;)o(a);i=1,a=t[l]}return{c:n.subarray(0,r),n:e}},ct=function(t,e){for(var n=0,r=0;r<e.length;++r)n+=t[r]*e[r];return n},je=function(t,e,n){var r=n.length,a=Ue(e+2);t[a]=r&255,t[a+1]=r>>8,t[a+2]=t[a]^255,t[a+3]=t[a+1]^255;for(var i=0;i<r;++i)t[a+i+4]=n[i];return(a+4+r)*8},oe=function(t,e,n,r,a,i,o,l,s,c,d){Z(e,d++,n),++a[256];for(var u=Lt(a,15),f=u.t,p=u.l,g=Lt(i,15),m=g.t,x=g.l,V=ie(f),N=V.c,W=V.n,$=ie(m),I=$.c,j=$.n,C=new z(19),w=0;w<N.length;++w)++C[N[w]&31];for(var w=0;w<I.length;++w)++C[I[w]&31];for(var h=Lt(C,7),L=h.t,q=h.l,S=19;S>4&&!L[re[S-1]];--S);var Q=c+5<<3,T=ct(a,J)+ct(i,pt)+o,H=ct(a,f)+ct(i,m)+o+14+3*S+ct(C,L)+2*C[16]+3*C[17]+7*C[18];if(s>=0&&Q<=T&&Q<=H)return je(e,d,t.subarray(s,s+c));var O,A,F,X;if(Z(e,d,1+(H<T)),d+=2,H<T){O=ut(f,p,0),A=f,F=ut(m,x,0),X=m;var xt=ut(L,q,0);Z(e,d,W-257),Z(e,d+5,j-1),Z(e,d+10,S-4),d+=14;for(var w=0;w<S;++w)Z(e,d+3*w,L[re[w]]);d+=3*S;for(var _=[N,I],lt=0;lt<2;++lt)for(var tt=_[lt],w=0;w<tt.length;++w){var E=tt[w]&31;Z(e,d,xt[E]),d+=L[E],E>15&&(Z(e,d,tt[w]>>5&127),d+=tt[w]>>12)}}else O=Fn,A=J,F=Dn,X=pt;for(var w=0;w<l;++w){var k=r[w];if(k>255){var E=k>>18&31;st(e,d,O[E+257]),d+=A[E+257],E>7&&(Z(e,d,k>>23&31),d+=Nt[E]);var et=k&31;st(e,d,F[et]),d+=X[et],et>3&&(st(e,d,k>>5&8191),d+=Zt[et])}else st(e,d,O[k]),d+=A[k]}return st(e,d,O[256]),d+A[256]},Rn=new Et([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Te=new P(0),Vn=function(t,e,n,r,a,i){var o=i.z||t.length,l=new P(r+o+5*(1+Math.ceil(o/7e3))+a),s=l.subarray(r,l.length-a),c=i.l,d=(i.r||0)&7;if(e){d&&(s[0]=i.r>>3);for(var u=Rn[e-1],f=u>>13,p=u&8191,g=(1<<n)-1,m=i.p||new z(32768),x=i.h||new z(g+1),V=Math.ceil(n/3),N=2*V,W=function(Mt){return(t[Mt]^t[Mt+1]<<V^t[Mt+2]<<N)&g},$=new Et(25e3),I=new z(288),j=new z(32),C=0,w=0,h=i.i||0,L=0,q=i.w||0,S=0;h+2<o;++h){var Q=W(h),T=h&32767,H=x[Q];if(m[T]=H,x[Q]=T,q<=h){var O=o-h;if((C>7e3||L>24576)&&(O>423||!c)){d=oe(t,s,0,$,I,j,w,L,S,h-S,d),L=C=w=0,S=h;for(var A=0;A<286;++A)I[A]=0;for(var A=0;A<30;++A)j[A]=0}var F=2,X=0,xt=p,_=T-H&32767;if(O>2&&Q==W(h-_))for(var lt=Math.min(f,O)-1,tt=Math.min(32767,h),E=Math.min(258,O);_<=tt&&--xt&&T!=H;){if(t[h+F]==t[h+F-_]){for(var k=0;k<E&&t[h+k]==t[h+k-_];++k);if(k>F){if(F=k,X=_,k>lt)break;for(var et=Math.min(_,k-2),Jt=0,A=0;A<et;++A){var At=h-_+A&32767,_e=m[At],qt=At-_e&32767;qt>Jt&&(Jt=qt,H=At)}}}T=H,H=m[T],_+=T-H&32767}if(X){$[L++]=268435456|Ut[F]<<18|ae[X];var Qt=Ut[F]&31,te=ae[X]&31;w+=Nt[Qt]+Zt[te],++I[257+Qt],++j[te],q=h+F,++C}else $[L++]=t[h],++I[t[h]]}}for(h=Math.max(h,q);h<o;++h)$[L++]=t[h],++I[t[h]];d=oe(t,s,c,$,I,j,w,L,S,h-S,d),c||(i.r=d&7|s[d/8|0]<<3,d-=7,i.h=x,i.p=m,i.i=h,i.w=q)}else{for(var h=i.w||0;h<o+c;h+=65535){var kt=h+65535;kt>=o&&(s[d/8|0]=c,kt=o),d=je(s,d+1,t.subarray(h,kt))}i.i=o}return $e(l,0,r+Ue(d)+a)},On=(function(){for(var t=new Int32Array(256),e=0;e<256;++e){for(var n=e,r=9;--r;)n=(n&1&&-306674912)^n>>>1;t[e]=n}return t})(),_n=function(){var t=-1;return{p:function(e){for(var n=t,r=0;r<e.length;++r)n=On[n&255^e[r]]^n>>>8;t=n},d:function(){return~t}}},En=function(t,e,n,r,a){if(!a&&(a={l:1},e.dictionary)){var i=e.dictionary.subarray(-32768),o=new P(i.length+t.length);o.set(i),o.set(t,i.length),t=o,a.w=i.length}return Vn(t,e.level==null?6:e.level,e.mem==null?a.l?Math.ceil(Math.max(8,Math.min(13,Math.log(t.length)))*1.5):20:12+e.mem,n,r,a)},Tt=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8},Nn=function(t,e){var n=e.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=e.level<2?4:e.level==9?2:0,t[9]=3,e.mtime!=0&&Tt(t,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),n){t[3]=8;for(var r=0;r<=n.length;++r)t[r+10]=n.charCodeAt(r)}},Zn=function(t){return 10+(t.filename?t.filename.length+1:0)};function Yn(t,e){e||(e={});var n=_n(),r=t.length;n.p(t);var a=En(t,e,Zn(e),8),i=a.length;return Nn(a,e),Tt(a,i-8,n.d()),Tt(a,i-4,r),a}var le=typeof TextEncoder<"u"&&new TextEncoder,Xn=typeof TextDecoder<"u"&&new TextDecoder,Gn=0;try{Xn.decode(Te,{stream:!0}),Gn=1}catch{}function Wn(t,e){var n;if(le)return le.encode(t);for(var r=t.length,a=new P(t.length+(t.length>>1)),i=0,o=function(d){a[i++]=d},n=0;n<r;++n){if(i+5>a.length){var l=new P(i+8+(r-n<<1));l.set(a),a=l}var s=t.charCodeAt(n);s<128||e?o(s):s<2048?(o(192|s>>6),o(128|s&63)):s>55295&&s<57344?(s=65536+(s&1047552)|t.charCodeAt(++n)&1023,o(240|s>>18),o(128|s>>12&63),o(128|s>>6&63),o(128|s&63)):(o(224|s>>12),o(128|s>>6&63),o(128|s&63))}return $e(a,0,i)}const Kn="gzip";function Jn(t){return{bytes:Yn(t),compression:Kn}}const qn=1480934209,se=1,ce=2,de=4,ue=8,fe=1,me=2,pe=4,he=8,ge=16,Qn=32;function tr(t){if(t.version!==ft)throw new Error(`Unsupported snapshot version: ${t.version}`);const e=new ar;e.writeU32(qn),e.writeU8(ft),e.writeU8(0),e.writeU8(0),e.writeU8(0),e.writeJson(t.meta),e.writeJson(t.layers),e.writeString(t.activeLayoutBtrId),e.writeU32(t.layouts.length);for(const n of t.layouts)er(e,n);return e.toUint8Array()}function er(t,e){t.writeString(e.btrId),t.writeString(e.name),t.writeU8(e.isModelSpace?1:0),t.writeJson(e.osnap??null),t.writeU32(e.lineBatches.length);for(const n of e.lineBatches)nr(t,n);t.writeU32(e.meshBatches.length);for(const n of e.meshBatches)rr(t,n)}function nr(t,e){t.writeString(e.layer),t.writeU32(e.color>>>0),t.writeF64(e.offset[0]),t.writeF64(e.offset[1]),t.writeF64(e.offset[2]),t.writeFloat32Array(e.positions);let n=0;e.indices&&e.indices.length>0&&(n|=se),e.linePattern&&(n|=ce),e.lineDistances&&e.lineDistances.length>0&&(n|=de),e.lineWidth!=null&&e.lineWidth>0&&(n|=ue),t.writeU8(n),n&se&&t.writeUint32Array(e.indices),n&ce&&t.writeJson(e.linePattern),n&de&&t.writeFloat32Array(e.lineDistances),n&ue&&t.writeF32(e.lineWidth)}function rr(t,e){t.writeString(e.layer),t.writeU32(e.color>>>0),t.writeF64(e.offset[0]),t.writeF64(e.offset[1]),t.writeF64(e.offset[2]),t.writeFloat32Array(e.positions);let n=0;e.indices&&e.indices.length>0&&(n|=fe),e.hatchPattern&&(n|=me),e.gradientFill&&(n|=pe),e.gradientPositions&&e.gradientPositions.length>0&&(n|=he),e.side!=null&&(n|=ge),e.points&&(n|=Qn),t.writeU8(n),n&fe&&t.writeUint32Array(e.indices),n&me&&t.writeJson(e.hatchPattern),n&pe&&t.writeJson(e.gradientFill),n&he&&t.writeFloat32Array(e.gradientPositions),n&ge&&t.writeU8(e.side)}class ar{constructor(){this.chunks=[],this.length=0}writeU8(e){const n=new Uint8Array(1);n[0]=e&255,this.chunks.push(n),this.length+=1}writeU32(e){const n=new Uint8Array(4);new DataView(n.buffer).setUint32(0,e>>>0,!0),this.chunks.push(n),this.length+=4}writeF32(e){const n=new Uint8Array(4);new DataView(n.buffer).setFloat32(0,e,!0),this.chunks.push(n),this.length+=4}writeF64(e){const n=new Uint8Array(8);new DataView(n.buffer).setFloat64(0,e,!0),this.chunks.push(n),this.length+=8}writeBytes(e){this.chunks.push(e),this.length+=e.length}writeString(e){const n=Wn(e);this.writeU32(n.length),this.writeBytes(n)}writeJson(e){this.writeString(JSON.stringify(e))}writeFloat32Array(e){this.alignTo(4);const n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);this.writeU32(n.length),this.writeBytes(n)}writeUint32Array(e){this.alignTo(4);const n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);this.writeU32(n.length),this.writeBytes(n)}alignTo(e){const n=this.length%e;if(n===0)return;const r=e-n;for(let a=0;a<r;a++)this.writeU8(0)}toUint8Array(){const e=new Uint8Array(this.length);let n=0;for(const r of this.chunks)e.set(r,n),n+=r.length;return e}}const ir="application/vnd.mlightcad.acex-snapshot+binary";function or(t){if(t.version!==ft)throw new Error(`Unsupported snapshot version: ${t.version}`);const e=tr(t),n=Jn(e);return{payload:sr(n.bytes),compression:n.compression}}function lr(){return ir}function sr(t){let e="";for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e)}function ot(t,e,n){if(n<=0)return new Float32Array(0);const r=new Float32Array(n);for(let a=0;a<n;a++)r[a]=t[e+a];return r}function cr(t,e,n){if(n<=0)return new Uint32Array(0);const r=new Uint32Array(n);for(let a=0;a<n;a++)r[a]=t[e+a];return r}function He(t,e){if(e.length===0)return{positions:t,indices:e};let n=0;for(let a=0;a<e.length;a++){const i=e[a];i>n&&(n=i)}const r=(n+1)*3;return r>=t.length?{positions:t,indices:e}:{positions:ot(t,0,r),indices:e}}function we(t,e){return t+e}const nt={x:0,y:0,z:0};function dr(t){t.updateMatrixWorld(!0);const e=t.matrixWorld.elements;return nt.x=e[12],nt.y=e[13],nt.z=e[14],[nt.x,nt.y,nt.z]}function ur(t,e){const n=e.elements,r=t.positions;if(r.length===0)return{positions:new Float32Array(0),indices:t.indices};const a=new Float32Array(r.length);for(let i=0;i<r.length;i+=3){const o=r[i],l=r[i+1],s=r[i+2];a[i]=n[0]*o+n[4]*l+n[8]*s+n[12],a[i+1]=n[1]*o+n[5]*l+n[9]*s+n[13],a[i+2]=n[2]*o+n[6]*l+n[10]*s+n[14]}return{positions:a,indices:t.indices?new Uint32Array(t.indices):void 0}}function fr(t){const e=t.positions;if(e.length<3)return{slice:t,offset:[0,0,0]};let n=1/0,r=1/0,a=1/0,i=-1/0,o=-1/0,l=-1/0;for(let d=0;d<e.length;d+=3){const u=e[d],f=e[d+1],p=e[d+2];n=Math.min(n,u),r=Math.min(r,f),a=Math.min(a,p),i=Math.max(i,u),o=Math.max(o,f),l=Math.max(l,p)}const s=[(n+i)/2,(r+o)/2,(a+l)/2],c=new Float32Array(e.length);for(let d=0;d<e.length;d+=3)c[d]=e[d]-s[0],c[d+1]=e[d+1]-s[1],c[d+2]=e[d+2]-s[2];return{slice:{positions:c,indices:t.indices?new Uint32Array(t.indices):void 0},offset:s}}function mr(t,e,n={}){t.updateMatrixWorld(!0);const r=ur(e,t.matrixWorld);return n.preserveWorldSpaceForPatternFill?{slice:r,offset:[0,0,0]}:fr(r)}function Yt(t){const e=t;if(e.isShaderMaterial===!0||t.type==="ShaderMaterial")return e}function pr(t){var e;const n=Yt(t);if(!n)return;const r=n.uniforms.pattern,a=n.uniforms.patternLength;if(!r||!a)return;const i=r.value;if(!(!Array.isArray(i)||i.length===0))return{pattern:[...i],patternLength:Number(a.value),viewportScale:Number(((e=n.uniforms.u_viewportScale)==null?void 0:e.value)??1)}}function hr(t){var e;const n=Yt(t);if(!n)return;const r=n.uniforms.u_patternLines;if(!r)return;const a=r.value;if(!(!Array.isArray(a)||a.length===0))return{patternAngle:Number(((e=n.uniforms.u_patternAngle)==null?void 0:e.value)??0),patternLines:a.map(wr)}}function gr(t){var e,n,r,a,i;const o=Yt(t);if(!o||o.uniforms.u_patternLines)return;const l=(e=o.uniforms.u_startColor)==null?void 0:e.value,s=(n=o.uniforms.u_endColor)==null?void 0:n.value,c=o.uniforms.u_gradientType;if(!(!(l!=null&&l.getHex)||c==null))return{startColor:l.getHex(),endColor:((r=s==null?void 0:s.getHex)==null?void 0:r.call(s))??l.getHex(),angle:Number(((a=o.uniforms.u_angle)==null?void 0:a.value)??0),shift:Number(((i=o.uniforms.u_shift)==null?void 0:i.value)??0),gradientType:Number(c.value)}}function wr(t){return{angle:t.angle,base:[t.base.x,t.base.y],offset:[t.offset.x,t.offset.y],dashLengths:[...t.dashLengths],patternLength:t.patternLength}}function Fe(t){const e=t.length/3;if(e<2)return new Float32Array(0);const n=new Float32Array(e);for(let r=0;r<e;r+=2){r===0?n[r]=0:n[r]=n[r-1];const a=t[r*3],i=t[r*3+1],o=t[r*3+2]??0,l=t[(r+1)*3],s=t[(r+1)*3+1],c=t[(r+1)*3+2]??0,d=l-a,u=s-i,f=c-o;n[r+1]=n[r]+Math.sqrt(d*d+u*u+f*f)}return n}function yr(t,e){const n=t.getAttribute(e);if(!n||n.count===0)return;const r=n.itemSize;if(t.getIndex()){const d=n.array;return ot(d,0,n.count*r)}const a=t.drawRange,i=n.count,o=Math.max(0,Math.min(Math.floor(a.start),i)),l=Math.max(0,i-o),s=!Number.isFinite(a.count)||a.count<=0?l:Math.min(Math.floor(a.count),l);if(s<=0)return;const c=n.array;return ot(c,o*r,s*r)}function vr(t,e){const n=Math.atan2(e[1],e[0]),r=(i,o)=>[e[0]*i+e[4]*o+e[12],e[1]*i+e[5]*o+e[13]],a=(i,o)=>[e[0]*i+e[4]*o,e[1]*i+e[5]*o];return{patternAngle:t.patternAngle+n,patternLines:t.patternLines.map(i=>({angle:i.angle+n,base:r(i.base[0],i.base[1]),offset:a(i.offset[0],i.offset[1]),dashLengths:[...i.dashLengths],patternLength:i.patternLength}))}}function Ht(t,e){return!Number.isFinite(t)||t<0?0:Math.min(Math.floor(t),e)}function Ft(t,e,n){const r=Math.max(0,e-n);return!Number.isFinite(t)||t<=0?r:Math.min(Math.floor(t),r)}function ye(t){const e=t.getAttribute("position");if(!e)return{positions:new Float32Array(0)};const n=t.drawRange,r=e.array,a=e.itemSize,i=t.getIndex();if(i){const s=ot(r,0,e.count*a),c=i.array,d=Ht(n.start,i.count),u=Ft(n.count,i.count,d),f=cr(c,d,u);return He(s,f)}const o=Ht(n.start,e.count),l=Ft(n.count,e.count,o);return{positions:ot(r,o*a,l*a)}}function Dt(t){return Sn(t.flags)&&zn(t.flags)}function Xt(t,e){const n=e.getAttribute("position");if(!n)return{positions:new Float32Array(0)};const r=n.itemSize,a=n.array,i=e.getIndex(),{count:o}=t.mappingStats;if(i){const s=ot(a,0,n.count*r),c=i.array,d=[];for(let u=0;u<o;u++){let f;try{f=t.getGeometryRangeAt(u)}catch{continue}const p=f.indexStart??0,g=f.indexCount??0;if(!(!Dt(f)||g<=0))for(let m=0;m<g;m++)d.push(c[p+m])}return d.length===0?{positions:new Float32Array(0)}:He(s,new Uint32Array(d))}const l=[];for(let s=0;s<o;s++){let c;try{c=t.getGeometryRangeAt(s)}catch{continue}if(!Dt(c)||c.vertexCount<=0)continue;const d=c.vertexStart*r,u=c.vertexCount*r;for(let f=0;f<u;f++)l.push(a[d+f])}return{positions:new Float32Array(l)}}function ht(t,e,n){t.push(e.getX(n),e.getY(n),e.getZ(n))}function br(t,e){const n=e.getAttribute("instanceStart"),r=e.getAttribute("instanceEnd");if(!n||!r)return{positions:new Float32Array(0)};const{count:a}=t.mappingStats,i=[];for(let o=0;o<a;o++){let l;try{l=t.getGeometryRangeAt(o)}catch{continue}if(!Dt(l)||l.vertexCount<=0)continue;const s=l.vertexStart,c=s+l.vertexCount;for(let d=s;d<c;d++)ht(i,n,d),ht(i,r,d)}return{positions:new Float32Array(i)}}function xr(t,e){const n=t.instanceCount;if(Number.isFinite(n)&&n>=0)return Math.min(Math.floor(n),e);const r=t.drawRange,a=Ht(r.start,e);return Ft(r.count,e,a)}function Ar(t){const e=t.getAttribute("instanceStart"),n=t.getAttribute("instanceEnd");if(!e||!n||e.count===0)return{positions:new Float32Array(0)};const r=xr(t,e.count);if(r<=0)return{positions:new Float32Array(0)};const a=[];for(let i=0;i<r;i++)ht(a,e,i),ht(a,n,i);return{positions:new Float32Array(a)}}function St(t){return nn(t)}function De(t){if(t instanceof on)return t.linewidth}function zt(t){if("material"in t){const e=t.userData.originalMaterial??t.material;return Array.isArray(e)?e[0]:e}return t.material}function it(t){var e;const n=rn(t),r=n.layer??"0",a=t;let i=a.color!=null?a.color.getHex():n.color??16777215;const o=pr(t),l=hr(t),s=gr(t);if(t instanceof an||t.type==="ShaderMaterial"){const c=(e=t.uniforms.u_color)==null?void 0:e.value;c!=null&&c.getHex?i=c.getHex():s&&(i=s.startColor)}return{color:i,layer:r,linePattern:o,hatchPattern:l,gradientFill:s,side:l||s?t.side:void 0}}function kr(t,e){if(!e)return;const n=t.userData.bakedWorldMatrix;return!n||n.length<16?e:vr(e,n)}function bt(t){return dr(t)}function Pt(t,e,n={}){const r=mr(t,e,n);return{...r.slice,offset:r.offset}}function Gt(t,e,n,r,a){const i=it(e),o=kr(n,i.hatchPattern),l=i.gradientFill?yr(t,"gradientPosition"):void 0;return{layer:i.layer,color:i.color,offset:a,hatchPattern:o,gradientFill:i.gradientFill,gradientPositions:l,side:i.side,...r}}function Mr(t){const e=br(t,t.geometry);if(e.positions.length===0)return;const{color:n,layer:r}=it(t.material),a=De(t.material);return{layer:r,color:n,offset:bt(t),lineWidth:a,...e}}function Cr(t){const e=Xt(t,t.geometry);if(e.positions.length===0)return;const{color:n,layer:r,linePattern:a}=it(t.material),i=a?Fe(e.positions):void 0;return{layer:r,color:n,offset:bt(t),linePattern:a,lineDistances:i,...e}}function Lr(t){const e=Xt(t,t.geometry);if(e.positions.length!==0)return Gt(t.geometry,t.material,t,e,bt(t))}function Sr(t){const e=Xt(t,t.geometry);if(e.positions.length!==0)return{points:!0,...Gt(t.geometry,t.material,t,e,bt(t))}}function ve(t){const e=[],n=[];return t.traverse(r=>{if(!(We(r)||Ke(r))){if(r instanceof ee){const a=Cr(r);a&&e.push(a);return}if(r instanceof Je){const a=Mr(r);a&&e.push(a);return}if(r instanceof ne){const a=Lr(r);a&&n.push(a);return}if(r instanceof qe){const a=Sr(r);a&&n.push(a);return}if(r instanceof Qe){if(!St(r))return;const a=Ar(r.geometry);if(a.positions.length===0)return;const i=zt(r),{color:o,layer:l}=it(i),{offset:s,...c}=Pt(r,a);e.push({layer:l,color:o,offset:s,lineWidth:De(i),...c})}else if(r instanceof tn&&!(r instanceof ee)){if(!St(r))return;const a=ye(r.geometry);if(a.positions.length===0)return;const i=zt(r),{color:o,layer:l,linePattern:s}=it(i),{offset:c,...d}=Pt(r,a),u=s?Fe(d.positions):void 0;e.push({layer:l,color:o,offset:c,linePattern:s,lineDistances:u,...d})}else if(r instanceof en&&!(r instanceof ne)){if(!St(r))return;const a=ye(r.geometry);if(a.positions.length===0)return;const i=zt(r),o=it(i),{offset:l,...s}=Pt(r,a,{preserveWorldSpaceForPatternFill:!!o.hatchPattern});n.push(Gt(r.geometry,i,r,s,l))}}}),{lineBatches:e,meshBatches:n}}function be(t,e){const n=t.extmin,r=t.extmax;return{title:e==null?void 0:e.title,extents:{minX:n.x,minY:n.y,maxX:r.x,maxY:r.y},units:{insunits:t.insunits,lunits:t.lunits,luprec:t.luprec,aunits:t.aunits,auprec:t.auprec,measurement:t.measurement,ltscale:t.ltscale,angbase:t.angbase,angdir:t.angdir},background:(e==null?void 0:e.background)??0}}function Wt(t){return t.z>=0?1:-1}const zr=1e6;function b(t,e){const n=new R(e.x,e.y,e.z??0).applyMatrix4(t);return{x:n.x,y:n.y}}function Pr(t){const e=t.elements;return new Ot(e[0],e[4],e[8],e[12],e[1],e[5],e[9],e[13],e[2],e[6],e[10],e[14],e[3],e[7],e[11],e[15])}function gt(t,e){return new Ot().multiplyMatrices(t,Pr(e))}function Kt(t,e){const n=new R(e.x,e.y,e.z??0).transformDirection(t).normalize();return{x:n.x,y:n.y}}function Rt(t){const e=new R(t.elements[0],t.elements[1],t.elements[2]).length(),n=new R(t.elements[4],t.elements[5],t.elements[6]).length();return yt.equal(e,n,Pe*Math.max(e,n,1))}function Ir(t,e){const n=t.tables.blockTable.getIdAt(e);if(n)return n;for(const a of t.tables.blockTable.newIterator())if(a.objectId===e)return a;const r=t.tables.blockTable.modelSpace;if(r.objectId===e)return r}function Br(t){if(t instanceof Pn)return!0;const e=t;return(e.type==="LINE"||e.type==="Line")&&e.startPoint!=null&&e.endPoint!=null}function Ur(t,e,n,r){Y(t,e,n,r.startPoint,r.endPoint)}function Re(t,e){return t.blockTableRecord??(t.blockName?e.tables.blockTable.getAt(t.blockName):void 0)}function $r(t,e){const n=t.dimBlockId;return n?e.tables.blockTable.getAt(n):void 0}function jr(t,e){const n=Re(t,e);if(n)return n;const r=t.owningBlockRecordId;return r?e.tables.blockTable.getAt(r):void 0}function Ve(t){return t.getFullInsertionTransform()}function Tr(t){for(const e of t.newIterator())return!0;return!1}function Hr(t){return typeof t.getFullInsertionTransform=="function"&&"blockTableRecord"in t}function Y(t,e,n,r,a){const i=b(n,r),o=b(n,a),l={kind:"line",layer:e,x0:i.x,y0:i.y,x1:o.x,y1:o.y};t.push(l)}function xe(t,e,n,r,a,i){const o=b(n,r),l=Kt(n,a),s=Math.hypot(l.x,l.y)||1,c=l.x/s,d=l.y/s,u=zr,f=i?o.x-c*u:o.x,p=i?o.y-d*u:o.y,g=o.x+c*u,m=o.y+d*u;t.push({kind:"line",layer:e,x0:f,y0:p,x1:g,y1:m})}function K(t,e,n,r,a){if(r.length<2)return;const i=a?r.length:r.length-1;for(let o=0;o<i;o++)Y(t,e,n,r[o],r[(o+1)%r.length])}function Fr(t,e,n,r){const a=[r.startPosition];for(const i of r.segments)a.push(i.position);K(t,e,n,a,r.closed)}function Dr(t,e,n){if(n.vertices.length>=2)return n.vertices;if(n.vertices.length===0)return[];const r=n.vertices[0],a=e.lastLeaderLinePoint??e.landingPoint??t.landingPoint??t.contentBasePosition;if(!a)return n.vertices;const i=r.x-a.x,o=r.y-a.y,l=(r.z??0)-(a.z??0);return Math.hypot(i,o,l)<=Pe?n.vertices:[r,a]}function Rr(t,e,n,r){var a,i;for(const l of r.leaders)for(const s of l.leaderLines){const c=Dr(r,l,s);K(t,e,n,c,!1)}const o=l=>{if(!l)return;const s=b(n,l);t.push({kind:"point",layer:e,x:s.x,y:s.y})};o(r.contentBasePosition),o((a=r.mtextContent)==null?void 0:a.anchorPoint),o((i=r.blockContent)==null?void 0:i.position)}function Vr(t,e,n,r){const a=r.numberOfVertices;if(a<2)return;const i=r.elevation,o=r.closed?a:a-1;for(let l=0;l<o;l++){const s=r.getPointAt(l),c=r.getPointAt((l+1)%a),d=r.getBulgeAt(l),u={x:s.x,y:s.y,z:i},f={x:c.x,y:c.y,z:i};if(yt.isPositive(Math.abs(d))){const p=b(n,u),g=b(n,f),m=new vt(p,g,d),x=m.center;t.push({kind:"arc",layer:e,cx:x.x,cy:x.y,r:m.radius,startAngle:m.startAngle,endAngle:m.endAngle,normalSign:m.clockwise?-1:1})}else Y(t,e,n,u,f)}}function Or(t,e,n,r,a,i){const o=b(n,r),l=new R(n.elements[0],n.elements[1],n.elements[2]).length(),s={kind:"circle",layer:e,cx:o.x,cy:o.y,r:a*l,normalSign:Wt(i)};t.push(s)}function _r(t,e,n,r){const a=b(n,r.center),i=new R(n.elements[0],n.elements[1],n.elements[2]).length(),o={kind:"arc",layer:e,cx:a.x,cy:a.y,r:r.radius*i,startAngle:r.startAngle,endAngle:r.endAngle,normalSign:Wt(r.normal)};t.push(o)}function It(t,e,n,r){const a=b(n,r.center),i=r._geo,o=(i==null?void 0:i.majorAxis)??{x:1,y:0,z:0},l=Kt(n,o),s=Math.hypot(l.x,l.y)||1,c=new R(n.elements[0],n.elements[1],n.elements[2]).length(),d=new R(n.elements[4],n.elements[5],n.elements[6]).length(),u={kind:"ellipse",layer:e,cx:a.x,cy:a.y,majorX:l.x/s,majorY:l.y/s,majorR:r.majorAxisRadius*c,minorR:r.minorAxisRadius*d,startAngle:r.startAngle,endAngle:r.endAngle,closed:r.closed,normalSign:Wt(r.normal)};t.push(u)}function Er(t,e,n,r){var a,i;const o=r._geo;if(!((a=o==null?void 0:o.controlPoints)!=null&&a.length))return;const l=[];for(const c of o.controlPoints){const d=b(n,c);l.push(d.x,d.y)}const s={kind:"spline",layer:e,controlPoints:l,degree:o.degree??3,knots:[...o.knots??[]],weights:[...o.weights??[]],closed:o.closed??!1};if((i=o.fitPoints)!=null&&i.length){s.fitPoints=[];for(const c of o.fitPoints){const d=b(n,c);s.fitPoints.push(d.x,d.y)}}t.push(s)}function Nr(t,e,n,r){var a;const i=(a=r._geo)==null?void 0:a.vertices,o=i&&i.length>1?i.map(c=>({x:c.x,y:c.y,bulge:c.bulge})):Array.from({length:r.numberOfVertices},(c,d)=>{const u=r.getPoint2dAt(d);return{x:u.x,y:u.y,bulge:0}}),l=o.length;if(l<2)return;const s=r.closed?l:l-1;for(let c=0;c<s;c++){const d=o[c],u=o[(c+1)%l],f=d.bulge??0;if(yt.isPositive(Math.abs(f))){const p=b(n,{x:d.x,y:d.y,z:0}),g=b(n,{x:u.x,y:u.y,z:0}),m=new vt(p,g,f),x=m.center;t.push({kind:"arc",layer:e,cx:x.x,cy:x.y,r:m.radius,startAngle:m.startAngle,endAngle:m.endAngle,normalSign:m.clockwise?-1:1})}else Y(t,e,n,{x:d.x,y:d.y,z:0},{x:u.x,y:u.y,z:0})}}function Zr(t,e,n,r,a){if(Rt(n)){const i=b(n,{x:r.center.x,y:r.center.y,z:a}),o=new R(n.elements[0],n.elements[1],n.elements[2]).length();t.push({kind:"arc",layer:e,cx:i.x,cy:i.y,r:r.radius*o,startAngle:r.startAngle,endAngle:r.endAngle,normalSign:r.clockwise?-1:1});return}Y(t,e,n,{x:r.startPoint.x,y:r.startPoint.y,z:a},{x:r.endPoint.x,y:r.endPoint.y,z:a})}function Yr(t,e,n,r,a){const i=b(n,{x:r.center.x,y:r.center.y,z:a}),o=Kt(n,{x:Math.cos(r.rotation),y:Math.sin(r.rotation),z:0}),l=Math.hypot(o.x,o.y)||1,s=new R(n.elements[0],n.elements[1],n.elements[2]).length(),c=new R(n.elements[4],n.elements[5],n.elements[6]).length();t.push({kind:"ellipse",layer:e,cx:i.x,cy:i.y,majorX:o.x/l,majorY:o.y/l,majorR:r.majorAxisRadius*s,minorR:r.minorAxisRadius*c,startAngle:r.startAngle,endAngle:r.endAngle,closed:!1,normalSign:r.clockwise?-1:1})}function Xr(t,e,n,r,a){var i;const o=r.numberOfVertices;if(o<2)return;const l=r.closed?o:o-1;for(let s=0;s<l;s++){const c=r.getPointAt(s),d=r.getPointAt((s+1)%o),u=((i=r.vertices[s])==null?void 0:i.bulge)??0,f={x:c.x,y:c.y,z:a},p={x:d.x,y:d.y,z:a};if(yt.isPositive(Math.abs(u))){const g=b(n,f),m=b(n,p),x=new vt(g,m,u),V=x.center;t.push({kind:"arc",layer:e,cx:V.x,cy:V.y,r:x.radius,startAngle:x.startAngle,endAngle:x.endAngle,normalSign:x.clockwise?-1:1})}else Y(t,e,n,f,p)}}function Gr(t,e,n,r,a){if(r instanceof Bn){Xr(t,e,n,r,a);return}if(r instanceof Un)for(const i of r.curves)i instanceof $n?Y(t,e,n,{x:i.startPoint.x,y:i.startPoint.y,z:a},{x:i.endPoint.x,y:i.endPoint.y,z:a}):i instanceof vt?Zr(t,e,n,i,a):i instanceof jn&&Yr(t,e,n,i,a)}function Wr(t,e,n,r){var a;const i=(a=r._geo)==null?void 0:a.loops;if(!(i!=null&&i.length))return;const o=r.elevation;for(const l of i)Gr(t,e,n,l,o)}function Kr(t,e,n,r){const a=gt(n,Ve(r)),i=[0];for(let c=0;c<r.numColumns;c++)i.push(i[c]+r.columnWidth(c));const o=[0];for(let c=0;c<r.numRows;c++)o.push(o[c]-r.rowHeight(c));const l=i[i.length-1],s=o[o.length-1];for(const c of o)Y(t,e,a,{x:0,y:c,z:0},{x:l,y:c,z:0});for(const c of i)Y(t,e,a,{x:c,y:0,z:0},{x:c,y:s,z:0})}function Jr(t,e,n,r,a,i,o){const l=Vt(t.layer,n);if(o&&!o(l))return;const s=jr(t,i);if(s&&!a.has(s.objectId)&&Tr(s)){a.add(s.objectId);const d=gt(e,Ve(t));wt(s,d,l,r,a,i,o),a.delete(s.objectId);return}Kr(r,l,e,t);const c=b(e,t.position);r.push({kind:"point",layer:l,x:c.x,y:c.y})}function qr(t,e,n,r){let a=r.boundaryPath();if(a.length>1){const o=a[0],l=a[a.length-1];o.x===l.x&&o.y===l.y&&(o.z??0)===(l.z??0)&&(a=a.slice(0,-1))}a.length>=2&&K(t,e,n,a,!0);const i=b(n,r.position);t.push({kind:"point",layer:e,x:i.x,y:i.y})}function Vt(t,e){return t==="0"?e:t}function Qr(t,e,n,r,a,i,o){if(!t.visibility)return;const l=Vt(t.layer,n);if(!(o&&!o(l))){if(t instanceof ln){Jr(t,e,n,r,a,i,o);return}if(Hr(t)){const s=Re(t,i);if(!s||a.has(s.objectId))return;a.add(s.objectId);const c=gt(e,t.getFullInsertionTransform()),d=Vt(t.layer,n);wt(s,c,d,r,a,i,o),a.delete(s.objectId);return}if(t instanceof sn){const s=t,c=$r(s,i);if(!c||a.has(c.objectId))return;a.add(c.objectId);const d=gt(e,s.getFullDimBlockTransform());wt(c,d,l,r,a,i,o),a.delete(c.objectId);return}if(Br(t)){Ur(r,l,e,t);return}if(t instanceof cn){Rt(e)?Or(r,l,e,t.center,t.radius,t.normal):It(r,l,e,ta(t));return}if(t instanceof dn){Rt(e)?_r(r,l,e,t):It(r,l,e,ea(t));return}if(t instanceof _t){It(r,l,e,t);return}if(t instanceof un){Er(r,l,e,t);return}if(t instanceof fn){Nr(r,l,e,t);return}if(t instanceof mn){Vr(r,l,e,t);return}if(t instanceof pn){const s=[];for(let c=0;c<t.numberOfVertices;c++)s.push(t.getPointAt(c));K(r,l,e,s,t.closed);return}if(t instanceof hn){Wr(r,l,e,t);return}if(t instanceof gn){xe(r,l,e,t.basePoint,t.unitDir,!1);return}if(t instanceof wn){xe(r,l,e,t.basePoint,t.unitDir,!0);return}if(t instanceof yn){const s=[t.getPointAt(0),t.getPointAt(1),t.getPointAt(2),t.getPointAt(3)];K(r,l,e,s,!0);return}if(t instanceof vn){const s=t.subGetGripPoints();s.length>=2&&K(r,l,e,s,s.length>=3);return}if(t instanceof bn){const s=t.vertices;s.length>=2&&K(r,l,e,s,!1);return}if(t instanceof xn){Fr(r,l,e,t);return}if(t instanceof An){Rr(r,l,e,t);return}if(t instanceof kn){const s=b(e,t.position);r.push({kind:"point",layer:l,x:s.x,y:s.y});return}if(t instanceof Mn){const s=b(e,t.location);r.push({kind:"point",layer:l,x:s.x,y:s.y});return}if(t instanceof Cn){qr(r,l,e,t);return}if(t instanceof Ln){const s=b(e,t.position);r.push({kind:"point",layer:l,x:s.x,y:s.y})}}}function wt(t,e,n,r,a,i,o){for(const l of t.newIterator())Qr(l,e,n,r,a,i,o)}function ta(t){return new _t(t.center,t.normal,{x:1,y:0,z:0},t.radius,t.radius,0,In)}function ea(t){return new _t(t.center,t.normal,{x:1,y:0,z:0},t.radius,t.radius,t.startAngle,t.endAngle)}function Ae(t,e,n={}){const r=Ir(t,e);if(!r)return{primitives:[]};const a=[],i=new Ot;return wt(r,i,"0",a,new Set,t,n.includeLayer),{primitives:a}}const na=["en","zh","cs","tr"];function ra(t){if(t==null||t==="")return null;const e=t.toLowerCase().replace("_","-");for(const n of na)if(e===n||e.startsWith(`${n}-`))return n;return null}const aa='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" aria-hidden="true"><path fill="currentColor" d="M9.3333 14.125 5.875 10.6667V14.125H9.3333Zm4.7917-3.4583-3.4583 3.4583H14.125V10.6667ZM10.6667 5.875 14.125 9.3333V5.875H10.6667ZM5.875 9.3333 9.3333 5.875H5.875V9.3333Zm9.2083 5.475c1.2333-1.3 1.9083-3.0333 1.9083-4.825-.0083-3.325-2.35-6.1833-5.6083-6.8417C8.125 2.4833 4.85 4.2 3.55 7.2583c-1.3 3.0583-.275 6.6083 2.4583 8.5 2.725 1.8917 6.4167 1.6 8.8167-.6917.0917-.0833.175-.175.2583-.2583Zm1.2583.5917 2.575 2.575c-.3167.3167-.625.625-.9417.9417-.8583-.8583-1.7167-1.7167-2.575-2.575-3.4083 2.9-8.4917 2.5917-11.525-.6917S.9417 7.275 4.1083 4.1083C7.2667.9417 12.3667.8417 15.65 3.875s3.5917 8.1167.6917 11.525Z"/></svg>',ia='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" aria-hidden="true"><path fill="currentColor" d="M3.75 9.25h12.5v1.5H3.75v-1.5ZM2.25 6.5h1.5v7h-1.5v-7ZM16.25 6.5h1.5v7h-1.5v-7Z"/></svg>',oa='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" aria-hidden="true"><polygon fill="currentColor" points="5.74 7.13 7 9.5 4.15 7.72 3.2 7.12 3 7 7 4.5 6.17 6.05 5.67 7 5.74 7.13"/><polygon fill="currentColor" points="16 12.5 13.5 16.5 12.66 15.15 11.92 13.97 11 12.5 12 13.03 12.98 13.55 13.5 13.83 16 12.5"/><rect fill="currentColor" x="2" y="2.5" width="1" height="15"/><rect fill="currentColor" x="3" y="16.5" width="15" height="1"/><path fill="currentColor" d="M14,13c0,.18,0,.37,0,.55v0a6.82,6.82,0,0,1-.32,1.57l-.74-1.18L13,13.5c0-.14,0-.31,0-.47v0a6,6,0,0,0-6-6,6.74,6.74,0,0,0-1.26.13l-.29.07a5.61,5.61,0,0,0-1.3.52l-1-.6a7.07,7.07,0,0,1,2-.88,6.78,6.78,0,0,1,1-.19A7.7,7.7,0,0,1,7,6a7,7,0,0,1,7,7Z"/></svg>',la='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" aria-hidden="true"><rect fill="currentColor" x="2" y="16" width="2" height="2"/><rect fill="currentColor" x="16" y="2" width="2" height="2"/><rect fill="currentColor" x="6.1" y="6.11" width="2" height="2"/><path fill="currentColor" d="M4.99,9.11c-1.15,1.74-1.94,3.74-2.24,5.89h.81c.32-2.18,1.16-4.18,2.39-5.89h-.96Z"/><path fill="currentColor" d="M9.1,5v.96c1.71-1.23,3.72-2.07,5.9-2.4v-.81c-2.16,.3-4.16,1.09-5.9,2.24Z"/></svg>',sa='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" aria-hidden="true"><path fill="currentColor" fill-rule="evenodd" d="M4 4h12v12H4V4Zm1.5 1.5v9h9v-9h-9Z"/><circle fill="currentColor" cx="4" cy="4" r="1.5"/><circle fill="currentColor" cx="16" cy="4" r="1.5"/><circle fill="currentColor" cx="4" cy="16" r="1.5"/><circle fill="currentColor" cx="16" cy="16" r="1.5"/></svg>',ca='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" aria-hidden="true"><path fill="currentColor" d="M9.25 2h1.5v5.25H16v1.5h-5.25V16h-1.5v-7.25H4v-1.5h5.25V2Z"/><circle fill="currentColor" cx="10" cy="10" r="1.75"/></svg>',da='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6l-1 14a2 2 0 01-2 2H8a2 2 0 01-2-2L5 6"/><path d="M10 11v6M14 11v6"/><path d="M9 6V4a1 1 0 011-1h4a1 1 0 011 1v2"/></svg>',ua='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" aria-hidden="true"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="m434.8 137.65-149.36-68.1c-16.19-7.4-42.69-7.4-58.88 0L77.3 137.65c-17.6 8-17.6 21.09 0 29.09l148 67.5c16.89 7.7 44.69 7.7 61.58 0l148-67.5c17.52-8 17.52-21.1-.08-29.09M160 308.52l-82.7 37.11c-17.6 8-17.6 21.1 0 29.1l148 67.5c16.89 7.69 44.69 7.69 61.58 0l148-67.5c17.6-8 17.6-21.1 0-29.1l-79.94-38.47"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="m160 204.48-82.8 37.16c-17.6 8-17.6 21.1 0 29.1l148 67.49c16.89 7.7 44.69 7.7 61.58 0l148-67.49c17.7-8 17.7-21.1.1-29.1L352 204.48"/></svg>',fa='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" aria-hidden="true"><path fill="currentColor" d="M10.09 3.53 16.09 6.97 10.09 10.29 4.18 7 10.09 3.56M10.09 2.4 2.17 7 3.31 7.65 10.09 11.45 17 7.62 18.17 7 10.08 2.37 10.09 2.4Z"/><path fill="currentColor" d="M10.25 14.83 18.17 10.22 17 9.57 10.22 13.57 3.32 9.59 2.17 10.22 10.25 14.83Z"/><path fill="currentColor" d="M10.25 17.63 18.17 13 17 12.37 10.22 16.37 3.32 12.38 2.17 13 10.25 17.63Z"/></svg>',ma='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" aria-hidden="true"><path fill="currentColor" d="M10.09 5.15 16.09 8.59 10.09 11.91 4.18 8.59 10.09 5.15ZM10.09 4 2.17 8.61 3.31 9.25 10.09 13.06 17 9.24 18.16 8.61 10.08 4 10.09 4Z"/><path fill="currentColor" d="M10.25 16.46 18.17 11.85 17 11.2 10.22 15.2 3.32 11.21 2.17 11.85 10.25 16.46Z"/><path fill="currentColor" d="M3.5 3.5 16.5 16.5" stroke="currentColor" stroke-width="1.25" stroke-linecap="round"/></svg>',pa='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true"><path fill="currentColor" d="m18.5 10 4.4 11h-2.155l-1.201-3h-4.09l-1.199 3h-2.154L16.5 10h2zM10 2v2h6v2h-1.968a18.222 18.222 0 0 1-3.62 6.301 14.864 14.864 0 0 0 2.336 1.707l-.751 1.878A17.015 17.015 0 0 1 9 13.725 16.676 16.676 0 0 1 3.524 17.273l-.536-1.929a14.7 14.7 0 0 0 5.327-3.042A18.078 18.078 0 0 1 4.767 8h2.24A16.032 16.032 0 0 0 9 10.877 16.165 16.165 0 0 0 11.91 6.001L2 6V4h6V2h2zm7.5 10.885L16.253 16h2.492L17.5 12.885z"/></svg>',ha='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" aria-hidden="true"><path fill="currentColor" d="M600.704 64a32 32 0 0 1 30.464 22.208l35.2 109.376c14.784 7.232 28.928 15.36 42.432 24.512l112.384-24.192a32 32 0 0 1 34.432 15.36L944.32 364.8a32 32 0 0 1-4.032 37.504l-77.12 85.12a357 357 0 0 1 0 49.024l77.12 85.248a32 32 0 0 1 4.032 37.504l-88.704 153.6a32 32 0 0 1-34.432 15.296L708.8 803.904c-13.44 9.088-27.648 17.28-42.368 24.512l-35.264 109.376A32 32 0 0 1 600.704 960H423.296a32 32 0 0 1-30.464-22.208L357.696 828.48a352 352 0 0 1-42.56-24.64l-112.32 24.256a32 32 0 0 1-34.432-15.36L79.68 659.2a32 32 0 0 1 4.032-37.504l77.12-85.248a357 357 0 0 1 0-48.896l-77.12-85.248A32 32 0 0 1 79.68 364.8l88.704-153.6a32 32 0 0 1 34.432-15.296l112.32 24.256c13.568-9.152 27.776-17.408 42.56-24.64l35.2-109.312A32 32 0 0 1 423.232 64H600.64zm-23.424 64H446.72l-36.352 113.088l-24.512 11.968a294 294 0 0 0-34.816 20.096l-22.656 15.36l-116.224-25.088l-65.28 113.152l79.68 88.192l-1.92 27.136a293 293 0 0 0 0 40.192l1.92 27.136l-79.808 88.192l65.344 113.152l116.224-25.024l22.656 15.296a294 294 0 0 0 34.816 20.096l24.512 11.968L446.72 896h130.688l36.48-113.152l24.448-11.904a288 288 0 0 0 34.752-20.096l22.592-15.296l116.288 25.024l65.28-113.152l-79.744-88.192l1.92-27.136a293 293 0 0 0 0-40.256l-1.92-27.136l79.808-88.128l-65.344-113.152l-116.288 24.96l-22.592-15.232a288 288 0 0 0-34.752-20.096l-24.448-11.904L577.344 128zM512 320a192 192 0 1 1 0 384a192 192 0 0 1 0-384m0 64a128 128 0 1 0 0 256a128 128 0 0 0 0-256"/></svg>',ga='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" aria-hidden="true"><path fill="currentColor" fill-rule="evenodd" d="M3 2H2v16h16v-1H8v-5H3V2zm0 11v4h4v-4H3z"/></svg>',wa='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" aria-hidden="true"><path fill="currentColor" fill-rule="evenodd" d="M16.98 11L18.5 11L18.5 10L16.98 10C16.86 8.13 16.05 6.44 14.8 5.2L16.88 2.83L16.12 2.17L14.05 4.54C12.79 3.57 11.21 3 9.5 3C5.36 3 2 6.36 2 10.5C2 14.64 5.36 18 9.5 18C13.47 18 16.73 14.91 16.98 11ZM15.98 10C15.86 8.43 15.18 7.01 14.14 5.95L10.6 10L15.98 10ZM13.39 5.29L8.4 11L15.98 11C15.73 14.36 12.92 17 9.5 17C5.91 17 3 14.09 3 10.5C3 6.91 5.91 4 9.5 4C10.96 4 12.31 4.48 13.39 5.29Z"/></svg>',ya='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true"><path fill="#e75958" d="M22 12H12l5 8.66A10 10 0 0 0 22 12Z"/><path fill="#814dff" d="M17 20.66 12 12 7 20.66A10 10 0 0 0 17 20.66Z"/><path fill="#13b0ce" d="M7 20.66 12 12H2A10 10 0 0 0 7 20.66Z"/><path fill="#4ecd83" d="M2 12H12L7 3.34A10 10 0 0 0 2 12Z"/><path fill="#ffc33f" d="M7 3.34 12 12l5-8.66A10 10 0 0 0 7 3.34Z"/><path fill="#ff9543" d="M17 3.34 12 12H22A10 10 0 0 0 17 3.34Z"/></svg>',va='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" aria-hidden="true"><path fill="currentColor" d="M10 6.5 5.5 11h9L10 6.5Z"/></svg>',M={zoomExtent:aa,measureDistance:ia,measureAngle:oa,measureArc:la,measureArea:sa,measureCoordinate:ca,clearMeasurements:da,layer:ua,layerOn:fa,layerOff:ma,language:pa,setting:ha,orthoMode:ga,polarTracking:wa,color:ya,chevronUp:va};function U(t,e,n){const r=Object.entries(n).map(([a,i])=>`${a}="${Bt(i)}"`).join(" ");return`<button type="button" class="mlcad-tool-btn" title="${Bt(e)}" aria-label="${Bt(e)}" ${r}>${t}</button>`}function Bt(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;")}const ba=583902,xa=[90,45,30,23,18,10,5];function Aa(t){return`#${t.toString(16).padStart(6,"0")}`}function Oe(){return`<button type="button" class="mlcad-tool-btn mlcad-lang-btn" id="mlcad-lang-btn" data-i18n-key="toolbar.languageSwitch" data-i18n-attr="title aria-label" title="Switch language" aria-label="Switch language">
1
+ import{v as Ee,F as Ne,u as Ct,d as v,w as dt,g as B,e as Ze,a as D,X as Xe,l as Ye,q as Ge,b as We,_ as Ke,D as ee,m as qe,c as ne,P as Je,L as Qe,f as tn,M as en,h as Ot,i as nn,j as rn,S as an,k as on,A as ln,n as sn,o as cn,p as dn,r as _t,s as un,t as fn,x as mn,y as pn,z as hn,B as gn,C as wn,E as yn,G as vn,H as bn,I as xn,J as An,K as kn,N as Mn,O as Cn,Q as Ln,R as Sn,T as zn,U as Pn,V as R,W as yt,Y as Pe,Z as In,$ as vt,a0 as Bn,a1 as Un,a2 as jn,a3 as $n}from"./index-DBlYvCOi.js";import{a4 as Ka,a5 as qa}from"./index-DBlYvCOi.js";const ft=2;var P=Uint8Array,z=Uint16Array,Et=Int32Array,Nt=new P([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Zt=new P([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),re=new P([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ie=function(t,e){for(var n=new z(31),r=0;r<31;++r)n[r]=e+=1<<t[r-1];for(var a=new Et(n[30]),r=1;r<30;++r)for(var i=n[r];i<n[r+1];++i)a[i]=i-n[r]<<5|r;return{b:n,r:a}},Be=Ie(Nt,2),Fn=Be.b,Ut=Be.r;Fn[28]=258,Ut[258]=28;var Hn=Ie(Zt,0),ae=Hn.r,jt=new z(32768);for(var y=0;y<32768;++y){var G=(y&43690)>>1|(y&21845)<<1;G=(G&52428)>>2|(G&13107)<<2,G=(G&61680)>>4|(G&3855)<<4,jt[y]=((G&65280)>>8|(G&255)<<8)>>1}var ut=(function(t,e,n){for(var r=t.length,a=0,i=new z(e);a<r;++a)t[a]&&++i[t[a]-1];var o=new z(e);for(a=1;a<e;++a)o[a]=o[a-1]+i[a-1]<<1;var l;if(n){l=new z(1<<e);var s=15-e;for(a=0;a<r;++a)if(t[a])for(var c=a<<4|t[a],d=e-t[a],u=o[t[a]-1]++<<d,f=u|(1<<d)-1;u<=f;++u)l[jt[u]>>s]=c}else for(l=new z(r),a=0;a<r;++a)t[a]&&(l[a]=jt[o[t[a]-1]++]>>15-t[a]);return l}),q=new P(288);for(var y=0;y<144;++y)q[y]=8;for(var y=144;y<256;++y)q[y]=9;for(var y=256;y<280;++y)q[y]=7;for(var y=280;y<288;++y)q[y]=8;var pt=new P(32);for(var y=0;y<32;++y)pt[y]=5;var Tn=ut(q,9,0),Dn=ut(pt,5,0),Ue=function(t){return(t+7)/8|0},je=function(t,e,n){return(n==null||n>t.length)&&(n=t.length),new P(t.subarray(e,n))},Z=function(t,e,n){n<<=e&7;var r=e/8|0;t[r]|=n,t[r+1]|=n>>8},st=function(t,e,n){n<<=e&7;var r=e/8|0;t[r]|=n,t[r+1]|=n>>8,t[r+2]|=n>>16},Lt=function(t,e){for(var n=[],r=0;r<t.length;++r)t[r]&&n.push({s:r,f:t[r]});var a=n.length,i=n.slice();if(!a)return{t:Fe,l:0};if(a==1){var o=new P(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(I,$){return I.f-$.f}),n.push({s:-1,f:25001});var l=n[0],s=n[1],c=0,d=1,u=2;for(n[0]={s:-1,f:l.f+s.f,l,r:s};d!=a-1;)l=n[n[c].f<n[u].f?c++:u++],s=n[c!=d&&n[c].f<n[u].f?c++:u++],n[d++]={s:-1,f:l.f+s.f,l,r:s};for(var f=i[0].s,r=1;r<a;++r)i[r].s>f&&(f=i[r].s);var p=new z(f+1),g=$t(n[d-1],p,0);if(g>e){var r=0,m=0,x=g-e,V=1<<x;for(i.sort(function($,C){return p[C.s]-p[$.s]||$.f-C.f});r<a;++r){var N=i[r].s;if(p[N]>e)m+=V-(1<<g-p[N]),p[N]=e;else break}for(m>>=x;m>0;){var W=i[r].s;p[W]<e?m-=1<<e-p[W]++-1:++r}for(;r>=0&&m;--r){var j=i[r].s;p[j]==e&&(--p[j],++m)}g=e}return{t:new P(p),l:g}},$t=function(t,e,n){return t.s==-1?Math.max($t(t.l,e,n+1),$t(t.r,e,n+1)):e[t.s]=n},ie=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new z(++e),r=0,a=t[0],i=1,o=function(s){n[r++]=s},l=1;l<=e;++l)if(t[l]==a&&l!=e)++i;else{if(!a&&i>2){for(;i>138;i-=138)o(32754);i>2&&(o(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(o(a),--i;i>6;i-=6)o(8304);i>2&&(o(i-3<<5|8208),i=0)}for(;i--;)o(a);i=1,a=t[l]}return{c:n.subarray(0,r),n:e}},ct=function(t,e){for(var n=0,r=0;r<e.length;++r)n+=t[r]*e[r];return n},$e=function(t,e,n){var r=n.length,a=Ue(e+2);t[a]=r&255,t[a+1]=r>>8,t[a+2]=t[a]^255,t[a+3]=t[a+1]^255;for(var i=0;i<r;++i)t[a+i+4]=n[i];return(a+4+r)*8},oe=function(t,e,n,r,a,i,o,l,s,c,d){Z(e,d++,n),++a[256];for(var u=Lt(a,15),f=u.t,p=u.l,g=Lt(i,15),m=g.t,x=g.l,V=ie(f),N=V.c,W=V.n,j=ie(m),I=j.c,$=j.n,C=new z(19),w=0;w<N.length;++w)++C[N[w]&31];for(var w=0;w<I.length;++w)++C[I[w]&31];for(var h=Lt(C,7),L=h.t,J=h.l,S=19;S>4&&!L[re[S-1]];--S);var Q=c+5<<3,F=ct(a,q)+ct(i,pt)+o,H=ct(a,f)+ct(i,m)+o+14+3*S+ct(C,L)+2*C[16]+3*C[17]+7*C[18];if(s>=0&&Q<=F&&Q<=H)return $e(e,d,t.subarray(s,s+c));var O,A,T,Y;if(Z(e,d,1+(H<F)),d+=2,H<F){O=ut(f,p,0),A=f,T=ut(m,x,0),Y=m;var xt=ut(L,J,0);Z(e,d,W-257),Z(e,d+5,$-1),Z(e,d+10,S-4),d+=14;for(var w=0;w<S;++w)Z(e,d+3*w,L[re[w]]);d+=3*S;for(var _=[N,I],lt=0;lt<2;++lt)for(var tt=_[lt],w=0;w<tt.length;++w){var E=tt[w]&31;Z(e,d,xt[E]),d+=L[E],E>15&&(Z(e,d,tt[w]>>5&127),d+=tt[w]>>12)}}else O=Tn,A=q,T=Dn,Y=pt;for(var w=0;w<l;++w){var k=r[w];if(k>255){var E=k>>18&31;st(e,d,O[E+257]),d+=A[E+257],E>7&&(Z(e,d,k>>23&31),d+=Nt[E]);var et=k&31;st(e,d,T[et]),d+=Y[et],et>3&&(st(e,d,k>>5&8191),d+=Zt[et])}else st(e,d,O[k]),d+=A[k]}return st(e,d,O[256]),d+A[256]},Rn=new Et([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Fe=new P(0),Vn=function(t,e,n,r,a,i){var o=i.z||t.length,l=new P(r+o+5*(1+Math.ceil(o/7e3))+a),s=l.subarray(r,l.length-a),c=i.l,d=(i.r||0)&7;if(e){d&&(s[0]=i.r>>3);for(var u=Rn[e-1],f=u>>13,p=u&8191,g=(1<<n)-1,m=i.p||new z(32768),x=i.h||new z(g+1),V=Math.ceil(n/3),N=2*V,W=function(Mt){return(t[Mt]^t[Mt+1]<<V^t[Mt+2]<<N)&g},j=new Et(25e3),I=new z(288),$=new z(32),C=0,w=0,h=i.i||0,L=0,J=i.w||0,S=0;h+2<o;++h){var Q=W(h),F=h&32767,H=x[Q];if(m[F]=H,x[Q]=F,J<=h){var O=o-h;if((C>7e3||L>24576)&&(O>423||!c)){d=oe(t,s,0,j,I,$,w,L,S,h-S,d),L=C=w=0,S=h;for(var A=0;A<286;++A)I[A]=0;for(var A=0;A<30;++A)$[A]=0}var T=2,Y=0,xt=p,_=F-H&32767;if(O>2&&Q==W(h-_))for(var lt=Math.min(f,O)-1,tt=Math.min(32767,h),E=Math.min(258,O);_<=tt&&--xt&&F!=H;){if(t[h+T]==t[h+T-_]){for(var k=0;k<E&&t[h+k]==t[h+k-_];++k);if(k>T){if(T=k,Y=_,k>lt)break;for(var et=Math.min(_,k-2),qt=0,A=0;A<et;++A){var At=h-_+A&32767,_e=m[At],Jt=At-_e&32767;Jt>qt&&(qt=Jt,H=At)}}}F=H,H=m[F],_+=F-H&32767}if(Y){j[L++]=268435456|Ut[T]<<18|ae[Y];var Qt=Ut[T]&31,te=ae[Y]&31;w+=Nt[Qt]+Zt[te],++I[257+Qt],++$[te],J=h+T,++C}else j[L++]=t[h],++I[t[h]]}}for(h=Math.max(h,J);h<o;++h)j[L++]=t[h],++I[t[h]];d=oe(t,s,c,j,I,$,w,L,S,h-S,d),c||(i.r=d&7|s[d/8|0]<<3,d-=7,i.h=x,i.p=m,i.i=h,i.w=J)}else{for(var h=i.w||0;h<o+c;h+=65535){var kt=h+65535;kt>=o&&(s[d/8|0]=c,kt=o),d=$e(s,d+1,t.subarray(h,kt))}i.i=o}return je(l,0,r+Ue(d)+a)},On=(function(){for(var t=new Int32Array(256),e=0;e<256;++e){for(var n=e,r=9;--r;)n=(n&1&&-306674912)^n>>>1;t[e]=n}return t})(),_n=function(){var t=-1;return{p:function(e){for(var n=t,r=0;r<e.length;++r)n=On[n&255^e[r]]^n>>>8;t=n},d:function(){return~t}}},En=function(t,e,n,r,a){if(!a&&(a={l:1},e.dictionary)){var i=e.dictionary.subarray(-32768),o=new P(i.length+t.length);o.set(i),o.set(t,i.length),t=o,a.w=i.length}return Vn(t,e.level==null?6:e.level,e.mem==null?a.l?Math.ceil(Math.max(8,Math.min(13,Math.log(t.length)))*1.5):20:12+e.mem,n,r,a)},Ft=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8},Nn=function(t,e){var n=e.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=e.level<2?4:e.level==9?2:0,t[9]=3,e.mtime!=0&&Ft(t,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),n){t[3]=8;for(var r=0;r<=n.length;++r)t[r+10]=n.charCodeAt(r)}},Zn=function(t){return 10+(t.filename?t.filename.length+1:0)};function Xn(t,e){e||(e={});var n=_n(),r=t.length;n.p(t);var a=En(t,e,Zn(e),8),i=a.length;return Nn(a,e),Ft(a,i-8,n.d()),Ft(a,i-4,r),a}var le=typeof TextEncoder<"u"&&new TextEncoder,Yn=typeof TextDecoder<"u"&&new TextDecoder,Gn=0;try{Yn.decode(Fe,{stream:!0}),Gn=1}catch{}function Wn(t,e){var n;if(le)return le.encode(t);for(var r=t.length,a=new P(t.length+(t.length>>1)),i=0,o=function(d){a[i++]=d},n=0;n<r;++n){if(i+5>a.length){var l=new P(i+8+(r-n<<1));l.set(a),a=l}var s=t.charCodeAt(n);s<128||e?o(s):s<2048?(o(192|s>>6),o(128|s&63)):s>55295&&s<57344?(s=65536+(s&1047552)|t.charCodeAt(++n)&1023,o(240|s>>18),o(128|s>>12&63),o(128|s>>6&63),o(128|s&63)):(o(224|s>>12),o(128|s>>6&63),o(128|s&63))}return je(a,0,i)}const Kn="gzip";function qn(t){return{bytes:Xn(t),compression:Kn}}const Jn=1480934209,se=1,ce=2,de=4,ue=8,fe=1,me=2,pe=4,he=8,ge=16,Qn=32;function tr(t){if(t.version!==ft)throw new Error(`Unsupported snapshot version: ${t.version}`);const e=new ar;e.writeU32(Jn),e.writeU8(ft),e.writeU8(0),e.writeU8(0),e.writeU8(0),e.writeJson(t.meta),e.writeJson(t.layers),e.writeString(t.activeLayoutBtrId),e.writeU32(t.layouts.length);for(const n of t.layouts)er(e,n);return e.toUint8Array()}function er(t,e){t.writeString(e.btrId),t.writeString(e.name),t.writeU8(e.isModelSpace?1:0),t.writeJson(e.osnap??null),t.writeU32(e.lineBatches.length);for(const n of e.lineBatches)nr(t,n);t.writeU32(e.meshBatches.length);for(const n of e.meshBatches)rr(t,n)}function nr(t,e){t.writeString(e.layer),t.writeU32(e.color>>>0),t.writeF64(e.offset[0]),t.writeF64(e.offset[1]),t.writeF64(e.offset[2]),t.writeFloat32Array(e.positions);let n=0;e.indices&&e.indices.length>0&&(n|=se),e.linePattern&&(n|=ce),e.lineDistances&&e.lineDistances.length>0&&(n|=de),e.lineWidth!=null&&e.lineWidth>0&&(n|=ue),t.writeU8(n),n&se&&t.writeUint32Array(e.indices),n&ce&&t.writeJson(e.linePattern),n&de&&t.writeFloat32Array(e.lineDistances),n&ue&&t.writeF32(e.lineWidth)}function rr(t,e){t.writeString(e.layer),t.writeU32(e.color>>>0),t.writeF64(e.offset[0]),t.writeF64(e.offset[1]),t.writeF64(e.offset[2]),t.writeFloat32Array(e.positions);let n=0;e.indices&&e.indices.length>0&&(n|=fe),e.hatchPattern&&(n|=me),e.gradientFill&&(n|=pe),e.gradientPositions&&e.gradientPositions.length>0&&(n|=he),e.side!=null&&(n|=ge),e.points&&(n|=Qn),t.writeU8(n),n&fe&&t.writeUint32Array(e.indices),n&me&&t.writeJson(e.hatchPattern),n&pe&&t.writeJson(e.gradientFill),n&he&&t.writeFloat32Array(e.gradientPositions),n&ge&&t.writeU8(e.side)}class ar{constructor(){this.chunks=[],this.length=0}writeU8(e){const n=new Uint8Array(1);n[0]=e&255,this.chunks.push(n),this.length+=1}writeU32(e){const n=new Uint8Array(4);new DataView(n.buffer).setUint32(0,e>>>0,!0),this.chunks.push(n),this.length+=4}writeF32(e){const n=new Uint8Array(4);new DataView(n.buffer).setFloat32(0,e,!0),this.chunks.push(n),this.length+=4}writeF64(e){const n=new Uint8Array(8);new DataView(n.buffer).setFloat64(0,e,!0),this.chunks.push(n),this.length+=8}writeBytes(e){this.chunks.push(e),this.length+=e.length}writeString(e){const n=Wn(e);this.writeU32(n.length),this.writeBytes(n)}writeJson(e){this.writeString(JSON.stringify(e))}writeFloat32Array(e){this.alignTo(4);const n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);this.writeU32(n.length),this.writeBytes(n)}writeUint32Array(e){this.alignTo(4);const n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);this.writeU32(n.length),this.writeBytes(n)}alignTo(e){const n=this.length%e;if(n===0)return;const r=e-n;for(let a=0;a<r;a++)this.writeU8(0)}toUint8Array(){const e=new Uint8Array(this.length);let n=0;for(const r of this.chunks)e.set(r,n),n+=r.length;return e}}const ir="application/vnd.mlightcad.acex-snapshot+binary";function or(t){if(t.version!==ft)throw new Error(`Unsupported snapshot version: ${t.version}`);const e=tr(t),n=qn(e);return{payload:sr(n.bytes),compression:n.compression}}function lr(){return ir}function sr(t){let e="";for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e)}function ot(t,e,n){if(n<=0)return new Float32Array(0);const r=new Float32Array(n);for(let a=0;a<n;a++)r[a]=t[e+a];return r}function cr(t,e,n){if(n<=0)return new Uint32Array(0);const r=new Uint32Array(n);for(let a=0;a<n;a++)r[a]=t[e+a];return r}function He(t,e){if(e.length===0)return{positions:t,indices:e};let n=0;for(let a=0;a<e.length;a++){const i=e[a];i>n&&(n=i)}const r=(n+1)*3;return r>=t.length?{positions:t,indices:e}:{positions:ot(t,0,r),indices:e}}function we(t,e){return t+e}const nt={x:0,y:0,z:0};function dr(t){t.updateMatrixWorld(!0);const e=t.matrixWorld.elements;return nt.x=e[12],nt.y=e[13],nt.z=e[14],[nt.x,nt.y,nt.z]}function ur(t,e){const n=e.elements,r=t.positions;if(r.length===0)return{positions:new Float32Array(0),indices:t.indices};const a=new Float32Array(r.length);for(let i=0;i<r.length;i+=3){const o=r[i],l=r[i+1],s=r[i+2];a[i]=n[0]*o+n[4]*l+n[8]*s+n[12],a[i+1]=n[1]*o+n[5]*l+n[9]*s+n[13],a[i+2]=n[2]*o+n[6]*l+n[10]*s+n[14]}return{positions:a,indices:t.indices?new Uint32Array(t.indices):void 0}}function fr(t){const e=t.positions;if(e.length<3)return{slice:t,offset:[0,0,0]};let n=1/0,r=1/0,a=1/0,i=-1/0,o=-1/0,l=-1/0;for(let d=0;d<e.length;d+=3){const u=e[d],f=e[d+1],p=e[d+2];n=Math.min(n,u),r=Math.min(r,f),a=Math.min(a,p),i=Math.max(i,u),o=Math.max(o,f),l=Math.max(l,p)}const s=[(n+i)/2,(r+o)/2,(a+l)/2],c=new Float32Array(e.length);for(let d=0;d<e.length;d+=3)c[d]=e[d]-s[0],c[d+1]=e[d+1]-s[1],c[d+2]=e[d+2]-s[2];return{slice:{positions:c,indices:t.indices?new Uint32Array(t.indices):void 0},offset:s}}function mr(t,e,n={}){t.updateMatrixWorld(!0);const r=ur(e,t.matrixWorld);return n.preserveWorldSpaceForPatternFill?{slice:r,offset:[0,0,0]}:fr(r)}function Xt(t){const e=t;if(e.isShaderMaterial===!0||t.type==="ShaderMaterial")return e}function pr(t){var e;const n=Xt(t);if(!n)return;const r=n.uniforms.pattern,a=n.uniforms.patternLength;if(!r||!a)return;const i=r.value;if(!(!Array.isArray(i)||i.length===0))return{pattern:[...i],patternLength:Number(a.value),viewportScale:Number(((e=n.uniforms.u_viewportScale)==null?void 0:e.value)??1)}}function hr(t){var e;const n=Xt(t);if(!n)return;const r=n.uniforms.u_patternLines;if(!r)return;const a=r.value;if(!(!Array.isArray(a)||a.length===0))return{patternAngle:Number(((e=n.uniforms.u_patternAngle)==null?void 0:e.value)??0),patternLines:a.map(wr)}}function gr(t){var e,n,r,a,i;const o=Xt(t);if(!o||o.uniforms.u_patternLines)return;const l=(e=o.uniforms.u_startColor)==null?void 0:e.value,s=(n=o.uniforms.u_endColor)==null?void 0:n.value,c=o.uniforms.u_gradientType;if(!(!(l!=null&&l.getHex)||c==null))return{startColor:l.getHex(),endColor:((r=s==null?void 0:s.getHex)==null?void 0:r.call(s))??l.getHex(),angle:Number(((a=o.uniforms.u_angle)==null?void 0:a.value)??0),shift:Number(((i=o.uniforms.u_shift)==null?void 0:i.value)??0),gradientType:Number(c.value)}}function wr(t){return{angle:t.angle,base:[t.base.x,t.base.y],offset:[t.offset.x,t.offset.y],dashLengths:[...t.dashLengths],patternLength:t.patternLength}}function Te(t){const e=t.length/3;if(e<2)return new Float32Array(0);const n=new Float32Array(e);for(let r=0;r<e;r+=2){r===0?n[r]=0:n[r]=n[r-1];const a=t[r*3],i=t[r*3+1],o=t[r*3+2]??0,l=t[(r+1)*3],s=t[(r+1)*3+1],c=t[(r+1)*3+2]??0,d=l-a,u=s-i,f=c-o;n[r+1]=n[r]+Math.sqrt(d*d+u*u+f*f)}return n}function yr(t,e){const n=t.getAttribute(e);if(!n||n.count===0)return;const r=n.itemSize;if(t.getIndex()){const d=n.array;return ot(d,0,n.count*r)}const a=t.drawRange,i=n.count,o=Math.max(0,Math.min(Math.floor(a.start),i)),l=Math.max(0,i-o),s=!Number.isFinite(a.count)||a.count<=0?l:Math.min(Math.floor(a.count),l);if(s<=0)return;const c=n.array;return ot(c,o*r,s*r)}function vr(t,e){const n=Math.atan2(e[1],e[0]),r=(i,o)=>[e[0]*i+e[4]*o+e[12],e[1]*i+e[5]*o+e[13]],a=(i,o)=>[e[0]*i+e[4]*o,e[1]*i+e[5]*o];return{patternAngle:t.patternAngle+n,patternLines:t.patternLines.map(i=>({angle:i.angle+n,base:r(i.base[0],i.base[1]),offset:a(i.offset[0],i.offset[1]),dashLengths:[...i.dashLengths],patternLength:i.patternLength}))}}function Ht(t,e){return!Number.isFinite(t)||t<0?0:Math.min(Math.floor(t),e)}function Tt(t,e,n){const r=Math.max(0,e-n);return!Number.isFinite(t)||t<=0?r:Math.min(Math.floor(t),r)}function ye(t){const e=t.getAttribute("position");if(!e)return{positions:new Float32Array(0)};const n=t.drawRange,r=e.array,a=e.itemSize,i=t.getIndex();if(i){const s=ot(r,0,e.count*a),c=i.array,d=Ht(n.start,i.count),u=Tt(n.count,i.count,d),f=cr(c,d,u);return He(s,f)}const o=Ht(n.start,e.count),l=Tt(n.count,e.count,o);return{positions:ot(r,o*a,l*a)}}function Dt(t){return Sn(t.flags)&&zn(t.flags)}function Yt(t,e){const n=e.getAttribute("position");if(!n)return{positions:new Float32Array(0)};const r=n.itemSize,a=n.array,i=e.getIndex(),{count:o}=t.mappingStats;if(i){const s=ot(a,0,n.count*r),c=i.array,d=[];for(let u=0;u<o;u++){let f;try{f=t.getGeometryRangeAt(u)}catch{continue}const p=f.indexStart??0,g=f.indexCount??0;if(!(!Dt(f)||g<=0))for(let m=0;m<g;m++)d.push(c[p+m])}return d.length===0?{positions:new Float32Array(0)}:He(s,new Uint32Array(d))}const l=[];for(let s=0;s<o;s++){let c;try{c=t.getGeometryRangeAt(s)}catch{continue}if(!Dt(c)||c.vertexCount<=0)continue;const d=c.vertexStart*r,u=c.vertexCount*r;for(let f=0;f<u;f++)l.push(a[d+f])}return{positions:new Float32Array(l)}}function ht(t,e,n){t.push(e.getX(n),e.getY(n),e.getZ(n))}function br(t,e){const n=e.getAttribute("instanceStart"),r=e.getAttribute("instanceEnd");if(!n||!r)return{positions:new Float32Array(0)};const{count:a}=t.mappingStats,i=[];for(let o=0;o<a;o++){let l;try{l=t.getGeometryRangeAt(o)}catch{continue}if(!Dt(l)||l.vertexCount<=0)continue;const s=l.vertexStart,c=s+l.vertexCount;for(let d=s;d<c;d++)ht(i,n,d),ht(i,r,d)}return{positions:new Float32Array(i)}}function xr(t,e){const n=t.instanceCount;if(Number.isFinite(n)&&n>=0)return Math.min(Math.floor(n),e);const r=t.drawRange,a=Ht(r.start,e);return Tt(r.count,e,a)}function Ar(t){const e=t.getAttribute("instanceStart"),n=t.getAttribute("instanceEnd");if(!e||!n||e.count===0)return{positions:new Float32Array(0)};const r=xr(t,e.count);if(r<=0)return{positions:new Float32Array(0)};const a=[];for(let i=0;i<r;i++)ht(a,e,i),ht(a,n,i);return{positions:new Float32Array(a)}}function St(t){return nn(t)}function De(t){if(t instanceof on)return t.linewidth}function zt(t){if("material"in t){const e=t.userData.originalMaterial??t.material;return Array.isArray(e)?e[0]:e}return t.material}function it(t){var e;const n=rn(t),r=n.layer??"0",a=t;let i=a.color!=null?a.color.getHex():n.color??16777215;const o=pr(t),l=hr(t),s=gr(t);if(t instanceof an||t.type==="ShaderMaterial"){const c=(e=t.uniforms.u_color)==null?void 0:e.value;c!=null&&c.getHex?i=c.getHex():s&&(i=s.startColor)}return{color:i,layer:r,linePattern:o,hatchPattern:l,gradientFill:s,side:l||s?t.side:void 0}}function kr(t,e){if(!e)return;const n=t.userData.bakedWorldMatrix;return!n||n.length<16?e:vr(e,n)}function bt(t){return dr(t)}function Pt(t,e,n={}){const r=mr(t,e,n);return{...r.slice,offset:r.offset}}function Gt(t,e,n,r,a){const i=it(e),o=kr(n,i.hatchPattern),l=i.gradientFill?yr(t,"gradientPosition"):void 0;return{layer:i.layer,color:i.color,offset:a,hatchPattern:o,gradientFill:i.gradientFill,gradientPositions:l,side:i.side,...r}}function Mr(t){const e=br(t,t.geometry);if(e.positions.length===0)return;const{color:n,layer:r}=it(t.material),a=De(t.material);return{layer:r,color:n,offset:bt(t),lineWidth:a,...e}}function Cr(t){const e=Yt(t,t.geometry);if(e.positions.length===0)return;const{color:n,layer:r,linePattern:a}=it(t.material),i=a?Te(e.positions):void 0;return{layer:r,color:n,offset:bt(t),linePattern:a,lineDistances:i,...e}}function Lr(t){const e=Yt(t,t.geometry);if(e.positions.length!==0)return Gt(t.geometry,t.material,t,e,bt(t))}function Sr(t){const e=Yt(t,t.geometry);if(e.positions.length!==0)return{points:!0,...Gt(t.geometry,t.material,t,e,bt(t))}}function ve(t){const e=[],n=[];return t.traverse(r=>{if(!(We(r)||Ke(r))){if(r instanceof ee){const a=Cr(r);a&&e.push(a);return}if(r instanceof qe){const a=Mr(r);a&&e.push(a);return}if(r instanceof ne){const a=Lr(r);a&&n.push(a);return}if(r instanceof Je){const a=Sr(r);a&&n.push(a);return}if(r instanceof Qe){if(!St(r))return;const a=Ar(r.geometry);if(a.positions.length===0)return;const i=zt(r),{color:o,layer:l}=it(i),{offset:s,...c}=Pt(r,a);e.push({layer:l,color:o,offset:s,lineWidth:De(i),...c})}else if(r instanceof tn&&!(r instanceof ee)){if(!St(r))return;const a=ye(r.geometry);if(a.positions.length===0)return;const i=zt(r),{color:o,layer:l,linePattern:s}=it(i),{offset:c,...d}=Pt(r,a),u=s?Te(d.positions):void 0;e.push({layer:l,color:o,offset:c,linePattern:s,lineDistances:u,...d})}else if(r instanceof en&&!(r instanceof ne)){if(!St(r))return;const a=ye(r.geometry);if(a.positions.length===0)return;const i=zt(r),o=it(i),{offset:l,...s}=Pt(r,a,{preserveWorldSpaceForPatternFill:!!o.hatchPattern});n.push(Gt(r.geometry,i,r,s,l))}}}),{lineBatches:e,meshBatches:n}}function be(t,e){const n=t.extmin,r=t.extmax;return{title:e==null?void 0:e.title,extents:{minX:n.x,minY:n.y,maxX:r.x,maxY:r.y},units:{insunits:t.insunits,lunits:t.lunits,luprec:t.luprec,aunits:t.aunits,auprec:t.auprec,measurement:t.measurement,ltscale:t.ltscale,angbase:t.angbase,angdir:t.angdir},background:(e==null?void 0:e.background)??0}}function Wt(t){return t.z>=0?1:-1}const zr=1e6;function b(t,e){const n=new R(e.x,e.y,e.z??0).applyMatrix4(t);return{x:n.x,y:n.y}}function Pr(t){const e=t.elements;return new Ot(e[0],e[4],e[8],e[12],e[1],e[5],e[9],e[13],e[2],e[6],e[10],e[14],e[3],e[7],e[11],e[15])}function gt(t,e){return new Ot().multiplyMatrices(t,Pr(e))}function Kt(t,e){const n=new R(e.x,e.y,e.z??0).transformDirection(t).normalize();return{x:n.x,y:n.y}}function Rt(t){const e=new R(t.elements[0],t.elements[1],t.elements[2]).length(),n=new R(t.elements[4],t.elements[5],t.elements[6]).length();return yt.equal(e,n,Pe*Math.max(e,n,1))}function Ir(t,e){const n=t.tables.blockTable.getIdAt(e);if(n)return n;for(const a of t.tables.blockTable.newIterator())if(a.objectId===e)return a;const r=t.tables.blockTable.modelSpace;if(r.objectId===e)return r}function Br(t){if(t instanceof Pn)return!0;const e=t;return(e.type==="LINE"||e.type==="Line")&&e.startPoint!=null&&e.endPoint!=null}function Ur(t,e,n,r){X(t,e,n,r.startPoint,r.endPoint)}function Re(t,e){return t.blockTableRecord??(t.blockName?e.tables.blockTable.getAt(t.blockName):void 0)}function jr(t,e){const n=t.dimBlockId;return n?e.tables.blockTable.getAt(n):void 0}function $r(t,e){const n=Re(t,e);if(n)return n;const r=t.owningBlockRecordId;return r?e.tables.blockTable.getAt(r):void 0}function Ve(t){return t.getFullInsertionTransform()}function Fr(t){for(const e of t.newIterator())return!0;return!1}function Hr(t){return typeof t.getFullInsertionTransform=="function"&&"blockTableRecord"in t}function X(t,e,n,r,a){const i=b(n,r),o=b(n,a),l={kind:"line",layer:e,x0:i.x,y0:i.y,x1:o.x,y1:o.y};t.push(l)}function xe(t,e,n,r,a,i){const o=b(n,r),l=Kt(n,a),s=Math.hypot(l.x,l.y)||1,c=l.x/s,d=l.y/s,u=zr,f=i?o.x-c*u:o.x,p=i?o.y-d*u:o.y,g=o.x+c*u,m=o.y+d*u;t.push({kind:"line",layer:e,x0:f,y0:p,x1:g,y1:m})}function K(t,e,n,r,a){if(r.length<2)return;const i=a?r.length:r.length-1;for(let o=0;o<i;o++)X(t,e,n,r[o],r[(o+1)%r.length])}function Tr(t,e,n,r){const a=[r.startPosition];for(const i of r.segments)a.push(i.position);K(t,e,n,a,r.closed)}function Dr(t,e,n){if(n.vertices.length>=2)return n.vertices;if(n.vertices.length===0)return[];const r=n.vertices[0],a=e.lastLeaderLinePoint??e.landingPoint??t.landingPoint??t.contentBasePosition;if(!a)return n.vertices;const i=r.x-a.x,o=r.y-a.y,l=(r.z??0)-(a.z??0);return Math.hypot(i,o,l)<=Pe?n.vertices:[r,a]}function Rr(t,e,n,r){var a,i;for(const l of r.leaders)for(const s of l.leaderLines){const c=Dr(r,l,s);K(t,e,n,c,!1)}const o=l=>{if(!l)return;const s=b(n,l);t.push({kind:"point",layer:e,x:s.x,y:s.y})};o(r.contentBasePosition),o((a=r.mtextContent)==null?void 0:a.anchorPoint),o((i=r.blockContent)==null?void 0:i.position)}function Vr(t,e,n,r){const a=r.numberOfVertices;if(a<2)return;const i=r.elevation,o=r.closed?a:a-1;for(let l=0;l<o;l++){const s=r.getPointAt(l),c=r.getPointAt((l+1)%a),d=r.getBulgeAt(l),u={x:s.x,y:s.y,z:i},f={x:c.x,y:c.y,z:i};if(yt.isPositive(Math.abs(d))){const p=b(n,u),g=b(n,f),m=new vt(p,g,d),x=m.center;t.push({kind:"arc",layer:e,cx:x.x,cy:x.y,r:m.radius,startAngle:m.startAngle,endAngle:m.endAngle,normalSign:m.clockwise?-1:1})}else X(t,e,n,u,f)}}function Or(t,e,n,r,a,i){const o=b(n,r),l=new R(n.elements[0],n.elements[1],n.elements[2]).length(),s={kind:"circle",layer:e,cx:o.x,cy:o.y,r:a*l,normalSign:Wt(i)};t.push(s)}function _r(t,e,n,r){const a=b(n,r.center),i=new R(n.elements[0],n.elements[1],n.elements[2]).length(),o={kind:"arc",layer:e,cx:a.x,cy:a.y,r:r.radius*i,startAngle:r.startAngle,endAngle:r.endAngle,normalSign:Wt(r.normal)};t.push(o)}function It(t,e,n,r){const a=b(n,r.center),i=r._geo,o=(i==null?void 0:i.majorAxis)??{x:1,y:0,z:0},l=Kt(n,o),s=Math.hypot(l.x,l.y)||1,c=new R(n.elements[0],n.elements[1],n.elements[2]).length(),d=new R(n.elements[4],n.elements[5],n.elements[6]).length(),u={kind:"ellipse",layer:e,cx:a.x,cy:a.y,majorX:l.x/s,majorY:l.y/s,majorR:r.majorAxisRadius*c,minorR:r.minorAxisRadius*d,startAngle:r.startAngle,endAngle:r.endAngle,closed:r.closed,normalSign:Wt(r.normal)};t.push(u)}function Er(t,e,n,r){var a,i;const o=r._geo;if(!((a=o==null?void 0:o.controlPoints)!=null&&a.length))return;const l=[];for(const c of o.controlPoints){const d=b(n,c);l.push(d.x,d.y)}const s={kind:"spline",layer:e,controlPoints:l,degree:o.degree??3,knots:[...o.knots??[]],weights:[...o.weights??[]],closed:o.closed??!1};if((i=o.fitPoints)!=null&&i.length){s.fitPoints=[];for(const c of o.fitPoints){const d=b(n,c);s.fitPoints.push(d.x,d.y)}}t.push(s)}function Nr(t,e,n,r){var a;const i=(a=r._geo)==null?void 0:a.vertices,o=i&&i.length>1?i.map(c=>({x:c.x,y:c.y,bulge:c.bulge})):Array.from({length:r.numberOfVertices},(c,d)=>{const u=r.getPoint2dAt(d);return{x:u.x,y:u.y,bulge:0}}),l=o.length;if(l<2)return;const s=r.closed?l:l-1;for(let c=0;c<s;c++){const d=o[c],u=o[(c+1)%l],f=d.bulge??0;if(yt.isPositive(Math.abs(f))){const p=b(n,{x:d.x,y:d.y,z:0}),g=b(n,{x:u.x,y:u.y,z:0}),m=new vt(p,g,f),x=m.center;t.push({kind:"arc",layer:e,cx:x.x,cy:x.y,r:m.radius,startAngle:m.startAngle,endAngle:m.endAngle,normalSign:m.clockwise?-1:1})}else X(t,e,n,{x:d.x,y:d.y,z:0},{x:u.x,y:u.y,z:0})}}function Zr(t,e,n,r,a){if(Rt(n)){const i=b(n,{x:r.center.x,y:r.center.y,z:a}),o=new R(n.elements[0],n.elements[1],n.elements[2]).length();t.push({kind:"arc",layer:e,cx:i.x,cy:i.y,r:r.radius*o,startAngle:r.startAngle,endAngle:r.endAngle,normalSign:r.clockwise?-1:1});return}X(t,e,n,{x:r.startPoint.x,y:r.startPoint.y,z:a},{x:r.endPoint.x,y:r.endPoint.y,z:a})}function Xr(t,e,n,r,a){const i=b(n,{x:r.center.x,y:r.center.y,z:a}),o=Kt(n,{x:Math.cos(r.rotation),y:Math.sin(r.rotation),z:0}),l=Math.hypot(o.x,o.y)||1,s=new R(n.elements[0],n.elements[1],n.elements[2]).length(),c=new R(n.elements[4],n.elements[5],n.elements[6]).length();t.push({kind:"ellipse",layer:e,cx:i.x,cy:i.y,majorX:o.x/l,majorY:o.y/l,majorR:r.majorAxisRadius*s,minorR:r.minorAxisRadius*c,startAngle:r.startAngle,endAngle:r.endAngle,closed:!1,normalSign:r.clockwise?-1:1})}function Yr(t,e,n,r,a){var i;const o=r.numberOfVertices;if(o<2)return;const l=r.closed?o:o-1;for(let s=0;s<l;s++){const c=r.getPointAt(s),d=r.getPointAt((s+1)%o),u=((i=r.vertices[s])==null?void 0:i.bulge)??0,f={x:c.x,y:c.y,z:a},p={x:d.x,y:d.y,z:a};if(yt.isPositive(Math.abs(u))){const g=b(n,f),m=b(n,p),x=new vt(g,m,u),V=x.center;t.push({kind:"arc",layer:e,cx:V.x,cy:V.y,r:x.radius,startAngle:x.startAngle,endAngle:x.endAngle,normalSign:x.clockwise?-1:1})}else X(t,e,n,f,p)}}function Gr(t,e,n,r,a){if(r instanceof Bn){Yr(t,e,n,r,a);return}if(r instanceof Un)for(const i of r.curves)i instanceof jn?X(t,e,n,{x:i.startPoint.x,y:i.startPoint.y,z:a},{x:i.endPoint.x,y:i.endPoint.y,z:a}):i instanceof vt?Zr(t,e,n,i,a):i instanceof $n&&Xr(t,e,n,i,a)}function Wr(t,e,n,r){var a;const i=(a=r._geo)==null?void 0:a.loops;if(!(i!=null&&i.length))return;const o=r.elevation;for(const l of i)Gr(t,e,n,l,o)}function Kr(t,e,n,r){const a=gt(n,Ve(r)),i=[0];for(let c=0;c<r.numColumns;c++)i.push(i[c]+r.columnWidth(c));const o=[0];for(let c=0;c<r.numRows;c++)o.push(o[c]-r.rowHeight(c));const l=i[i.length-1],s=o[o.length-1];for(const c of o)X(t,e,a,{x:0,y:c,z:0},{x:l,y:c,z:0});for(const c of i)X(t,e,a,{x:c,y:0,z:0},{x:c,y:s,z:0})}function qr(t,e,n,r,a,i,o){const l=Vt(t.layer,n);if(o&&!o(l))return;const s=$r(t,i);if(s&&!a.has(s.objectId)&&Fr(s)){a.add(s.objectId);const d=gt(e,Ve(t));wt(s,d,l,r,a,i,o),a.delete(s.objectId);return}Kr(r,l,e,t);const c=b(e,t.position);r.push({kind:"point",layer:l,x:c.x,y:c.y})}function Jr(t,e,n,r){let a=r.boundaryPath();if(a.length>1){const o=a[0],l=a[a.length-1];o.x===l.x&&o.y===l.y&&(o.z??0)===(l.z??0)&&(a=a.slice(0,-1))}a.length>=2&&K(t,e,n,a,!0);const i=b(n,r.position);t.push({kind:"point",layer:e,x:i.x,y:i.y})}function Vt(t,e){return t==="0"?e:t}function Qr(t,e,n,r,a,i,o){if(!t.visibility)return;const l=Vt(t.layer,n);if(!(o&&!o(l))){if(t instanceof ln){qr(t,e,n,r,a,i,o);return}if(Hr(t)){const s=Re(t,i);if(!s||a.has(s.objectId))return;a.add(s.objectId);const c=gt(e,t.getFullInsertionTransform()),d=Vt(t.layer,n);wt(s,c,d,r,a,i,o),a.delete(s.objectId);return}if(t instanceof sn){const s=t,c=jr(s,i);if(!c||a.has(c.objectId))return;a.add(c.objectId);const d=gt(e,s.getFullDimBlockTransform());wt(c,d,l,r,a,i,o),a.delete(c.objectId);return}if(Br(t)){Ur(r,l,e,t);return}if(t instanceof cn){Rt(e)?Or(r,l,e,t.center,t.radius,t.normal):It(r,l,e,ta(t));return}if(t instanceof dn){Rt(e)?_r(r,l,e,t):It(r,l,e,ea(t));return}if(t instanceof _t){It(r,l,e,t);return}if(t instanceof un){Er(r,l,e,t);return}if(t instanceof fn){Nr(r,l,e,t);return}if(t instanceof mn){Vr(r,l,e,t);return}if(t instanceof pn){const s=[];for(let c=0;c<t.numberOfVertices;c++)s.push(t.getPointAt(c));K(r,l,e,s,t.closed);return}if(t instanceof hn){Wr(r,l,e,t);return}if(t instanceof gn){xe(r,l,e,t.basePoint,t.unitDir,!1);return}if(t instanceof wn){xe(r,l,e,t.basePoint,t.unitDir,!0);return}if(t instanceof yn){const s=[t.getPointAt(0),t.getPointAt(1),t.getPointAt(2),t.getPointAt(3)];K(r,l,e,s,!0);return}if(t instanceof vn){const s=t.subGetGripPoints();s.length>=2&&K(r,l,e,s,s.length>=3);return}if(t instanceof bn){const s=t.vertices;s.length>=2&&K(r,l,e,s,!1);return}if(t instanceof xn){Tr(r,l,e,t);return}if(t instanceof An){Rr(r,l,e,t);return}if(t instanceof kn){const s=b(e,t.position);r.push({kind:"point",layer:l,x:s.x,y:s.y});return}if(t instanceof Mn){const s=b(e,t.location);r.push({kind:"point",layer:l,x:s.x,y:s.y});return}if(t instanceof Cn){Jr(r,l,e,t);return}if(t instanceof Ln){const s=b(e,t.position);r.push({kind:"point",layer:l,x:s.x,y:s.y})}}}function wt(t,e,n,r,a,i,o){for(const l of t.newIterator())Qr(l,e,n,r,a,i,o)}function ta(t){return new _t(t.center,t.normal,{x:1,y:0,z:0},t.radius,t.radius,0,In)}function ea(t){return new _t(t.center,t.normal,{x:1,y:0,z:0},t.radius,t.radius,t.startAngle,t.endAngle)}function Ae(t,e,n={}){const r=Ir(t,e);if(!r)return{primitives:[]};const a=[],i=new Ot;return wt(r,i,"0",a,new Set,t,n.includeLayer),{primitives:a}}const na=["en","zh","cs","tr"];function ra(t){if(t==null||t==="")return null;const e=t.toLowerCase().replace("_","-");for(const n of na)if(e===n||e.startsWith(`${n}-`))return n;return null}const aa='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" aria-hidden="true"><path fill="currentColor" d="M9.3333 14.125 5.875 10.6667V14.125H9.3333Zm4.7917-3.4583-3.4583 3.4583H14.125V10.6667ZM10.6667 5.875 14.125 9.3333V5.875H10.6667ZM5.875 9.3333 9.3333 5.875H5.875V9.3333Zm9.2083 5.475c1.2333-1.3 1.9083-3.0333 1.9083-4.825-.0083-3.325-2.35-6.1833-5.6083-6.8417C8.125 2.4833 4.85 4.2 3.55 7.2583c-1.3 3.0583-.275 6.6083 2.4583 8.5 2.725 1.8917 6.4167 1.6 8.8167-.6917.0917-.0833.175-.175.2583-.2583Zm1.2583.5917 2.575 2.575c-.3167.3167-.625.625-.9417.9417-.8583-.8583-1.7167-1.7167-2.575-2.575-3.4083 2.9-8.4917 2.5917-11.525-.6917S.9417 7.275 4.1083 4.1083C7.2667.9417 12.3667.8417 15.65 3.875s3.5917 8.1167.6917 11.525Z"/></svg>',ia='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" aria-hidden="true"><path fill="currentColor" d="M3.75 9.25h12.5v1.5H3.75v-1.5ZM2.25 6.5h1.5v7h-1.5v-7ZM16.25 6.5h1.5v7h-1.5v-7Z"/></svg>',oa='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" aria-hidden="true"><polygon fill="currentColor" points="5.74 7.13 7 9.5 4.15 7.72 3.2 7.12 3 7 7 4.5 6.17 6.05 5.67 7 5.74 7.13"/><polygon fill="currentColor" points="16 12.5 13.5 16.5 12.66 15.15 11.92 13.97 11 12.5 12 13.03 12.98 13.55 13.5 13.83 16 12.5"/><rect fill="currentColor" x="2" y="2.5" width="1" height="15"/><rect fill="currentColor" x="3" y="16.5" width="15" height="1"/><path fill="currentColor" d="M14,13c0,.18,0,.37,0,.55v0a6.82,6.82,0,0,1-.32,1.57l-.74-1.18L13,13.5c0-.14,0-.31,0-.47v0a6,6,0,0,0-6-6,6.74,6.74,0,0,0-1.26.13l-.29.07a5.61,5.61,0,0,0-1.3.52l-1-.6a7.07,7.07,0,0,1,2-.88,6.78,6.78,0,0,1,1-.19A7.7,7.7,0,0,1,7,6a7,7,0,0,1,7,7Z"/></svg>',la='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" aria-hidden="true"><rect fill="currentColor" x="2" y="16" width="2" height="2"/><rect fill="currentColor" x="16" y="2" width="2" height="2"/><rect fill="currentColor" x="6.1" y="6.11" width="2" height="2"/><path fill="currentColor" d="M4.99,9.11c-1.15,1.74-1.94,3.74-2.24,5.89h.81c.32-2.18,1.16-4.18,2.39-5.89h-.96Z"/><path fill="currentColor" d="M9.1,5v.96c1.71-1.23,3.72-2.07,5.9-2.4v-.81c-2.16,.3-4.16,1.09-5.9,2.24Z"/></svg>',sa='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" aria-hidden="true"><path fill="currentColor" fill-rule="evenodd" d="M4 4h12v12H4V4Zm1.5 1.5v9h9v-9h-9Z"/><circle fill="currentColor" cx="4" cy="4" r="1.5"/><circle fill="currentColor" cx="16" cy="4" r="1.5"/><circle fill="currentColor" cx="4" cy="16" r="1.5"/><circle fill="currentColor" cx="16" cy="16" r="1.5"/></svg>',ca='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" aria-hidden="true"><path fill="currentColor" d="M9.25 2h1.5v5.25H16v1.5h-5.25V16h-1.5v-7.25H4v-1.5h5.25V2Z"/><circle fill="currentColor" cx="10" cy="10" r="1.75"/></svg>',da='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6l-1 14a2 2 0 01-2 2H8a2 2 0 01-2-2L5 6"/><path d="M10 11v6M14 11v6"/><path d="M9 6V4a1 1 0 011-1h4a1 1 0 011 1v2"/></svg>',ua='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" aria-hidden="true"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="m434.8 137.65-149.36-68.1c-16.19-7.4-42.69-7.4-58.88 0L77.3 137.65c-17.6 8-17.6 21.09 0 29.09l148 67.5c16.89 7.7 44.69 7.7 61.58 0l148-67.5c17.52-8 17.52-21.1-.08-29.09M160 308.52l-82.7 37.11c-17.6 8-17.6 21.1 0 29.1l148 67.5c16.89 7.69 44.69 7.69 61.58 0l148-67.5c17.6-8 17.6-21.1 0-29.1l-79.94-38.47"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="m160 204.48-82.8 37.16c-17.6 8-17.6 21.1 0 29.1l148 67.49c16.89 7.7 44.69 7.7 61.58 0l148-67.49c17.7-8 17.7-21.1.1-29.1L352 204.48"/></svg>',fa='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" aria-hidden="true"><path fill="currentColor" d="M10.09 3.53 16.09 6.97 10.09 10.29 4.18 7 10.09 3.56M10.09 2.4 2.17 7 3.31 7.65 10.09 11.45 17 7.62 18.17 7 10.08 2.37 10.09 2.4Z"/><path fill="currentColor" d="M10.25 14.83 18.17 10.22 17 9.57 10.22 13.57 3.32 9.59 2.17 10.22 10.25 14.83Z"/><path fill="currentColor" d="M10.25 17.63 18.17 13 17 12.37 10.22 16.37 3.32 12.38 2.17 13 10.25 17.63Z"/></svg>',ma='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" aria-hidden="true"><path fill="currentColor" d="M10.09 5.15 16.09 8.59 10.09 11.91 4.18 8.59 10.09 5.15ZM10.09 4 2.17 8.61 3.31 9.25 10.09 13.06 17 9.24 18.16 8.61 10.08 4 10.09 4Z"/><path fill="currentColor" d="M10.25 16.46 18.17 11.85 17 11.2 10.22 15.2 3.32 11.21 2.17 11.85 10.25 16.46Z"/><path fill="currentColor" d="M3.5 3.5 16.5 16.5" stroke="currentColor" stroke-width="1.25" stroke-linecap="round"/></svg>',pa='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true"><path fill="currentColor" d="m18.5 10 4.4 11h-2.155l-1.201-3h-4.09l-1.199 3h-2.154L16.5 10h2zM10 2v2h6v2h-1.968a18.222 18.222 0 0 1-3.62 6.301 14.864 14.864 0 0 0 2.336 1.707l-.751 1.878A17.015 17.015 0 0 1 9 13.725 16.676 16.676 0 0 1 3.524 17.273l-.536-1.929a14.7 14.7 0 0 0 5.327-3.042A18.078 18.078 0 0 1 4.767 8h2.24A16.032 16.032 0 0 0 9 10.877 16.165 16.165 0 0 0 11.91 6.001L2 6V4h6V2h2zm7.5 10.885L16.253 16h2.492L17.5 12.885z"/></svg>',ha='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" aria-hidden="true"><path fill="currentColor" d="M600.704 64a32 32 0 0 1 30.464 22.208l35.2 109.376c14.784 7.232 28.928 15.36 42.432 24.512l112.384-24.192a32 32 0 0 1 34.432 15.36L944.32 364.8a32 32 0 0 1-4.032 37.504l-77.12 85.12a357 357 0 0 1 0 49.024l77.12 85.248a32 32 0 0 1 4.032 37.504l-88.704 153.6a32 32 0 0 1-34.432 15.296L708.8 803.904c-13.44 9.088-27.648 17.28-42.368 24.512l-35.264 109.376A32 32 0 0 1 600.704 960H423.296a32 32 0 0 1-30.464-22.208L357.696 828.48a352 352 0 0 1-42.56-24.64l-112.32 24.256a32 32 0 0 1-34.432-15.36L79.68 659.2a32 32 0 0 1 4.032-37.504l77.12-85.248a357 357 0 0 1 0-48.896l-77.12-85.248A32 32 0 0 1 79.68 364.8l88.704-153.6a32 32 0 0 1 34.432-15.296l112.32 24.256c13.568-9.152 27.776-17.408 42.56-24.64l35.2-109.312A32 32 0 0 1 423.232 64H600.64zm-23.424 64H446.72l-36.352 113.088l-24.512 11.968a294 294 0 0 0-34.816 20.096l-22.656 15.36l-116.224-25.088l-65.28 113.152l79.68 88.192l-1.92 27.136a293 293 0 0 0 0 40.192l1.92 27.136l-79.808 88.192l65.344 113.152l116.224-25.024l22.656 15.296a294 294 0 0 0 34.816 20.096l24.512 11.968L446.72 896h130.688l36.48-113.152l24.448-11.904a288 288 0 0 0 34.752-20.096l22.592-15.296l116.288 25.024l65.28-113.152l-79.744-88.192l1.92-27.136a293 293 0 0 0 0-40.256l-1.92-27.136l79.808-88.128l-65.344-113.152l-116.288 24.96l-22.592-15.232a288 288 0 0 0-34.752-20.096l-24.448-11.904L577.344 128zM512 320a192 192 0 1 1 0 384a192 192 0 0 1 0-384m0 64a128 128 0 1 0 0 256a128 128 0 0 0 0-256"/></svg>',ga='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" aria-hidden="true"><path fill="currentColor" fill-rule="evenodd" d="M3 2H2v16h16v-1H8v-5H3V2zm0 11v4h4v-4H3z"/></svg>',wa='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" aria-hidden="true"><path fill="currentColor" fill-rule="evenodd" d="M16.98 11L18.5 11L18.5 10L16.98 10C16.86 8.13 16.05 6.44 14.8 5.2L16.88 2.83L16.12 2.17L14.05 4.54C12.79 3.57 11.21 3 9.5 3C5.36 3 2 6.36 2 10.5C2 14.64 5.36 18 9.5 18C13.47 18 16.73 14.91 16.98 11ZM15.98 10C15.86 8.43 15.18 7.01 14.14 5.95L10.6 10L15.98 10ZM13.39 5.29L8.4 11L15.98 11C15.73 14.36 12.92 17 9.5 17C5.91 17 3 14.09 3 10.5C3 6.91 5.91 4 9.5 4C10.96 4 12.31 4.48 13.39 5.29Z"/></svg>',ya='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true"><path fill="#e75958" d="M22 12H12l5 8.66A10 10 0 0 0 22 12Z"/><path fill="#814dff" d="M17 20.66 12 12 7 20.66A10 10 0 0 0 17 20.66Z"/><path fill="#13b0ce" d="M7 20.66 12 12H2A10 10 0 0 0 7 20.66Z"/><path fill="#4ecd83" d="M2 12H12L7 3.34A10 10 0 0 0 2 12Z"/><path fill="#ffc33f" d="M7 3.34 12 12l5-8.66A10 10 0 0 0 7 3.34Z"/><path fill="#ff9543" d="M17 3.34 12 12H22A10 10 0 0 0 17 3.34Z"/></svg>',va='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" aria-hidden="true"><path fill="currentColor" d="M10 6.5 5.5 11h9L10 6.5Z"/></svg>',M={zoomExtent:aa,measureDistance:ia,measureAngle:oa,measureArc:la,measureArea:sa,measureCoordinate:ca,clearMeasurements:da,layer:ua,layerOn:fa,layerOff:ma,language:pa,setting:ha,orthoMode:ga,polarTracking:wa,color:ya,chevronUp:va};function U(t,e,n){const r=Object.entries(n).map(([a,i])=>`${a}="${Bt(i)}"`).join(" ");return`<button type="button" class="mlcad-tool-btn" title="${Bt(e)}" aria-label="${Bt(e)}" ${r}>${t}</button>`}function Bt(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;")}const ba=583902,xa=[90,45,30,23,18,10,5];function Aa(t){return`#${t.toString(16).padStart(6,"0")}`}function Oe(){return`<button type="button" class="mlcad-tool-btn mlcad-lang-btn" id="mlcad-lang-btn" data-i18n-key="toolbar.languageSwitch" data-i18n-attr="title aria-label" title="Switch language" aria-label="Switch language">
2
2
  ${M.language}
3
3
  <span class="mlcad-lang-badge" id="mlcad-lang-badge">EN</span>
4
4
  </button>`}function ka(){const t=xa.map(e=>`<button type="button" class="mlcad-tool-btn mlcad-settings-option-btn mlcad-polar-angle-btn" data-polar-ang="${e}" title="${e}°" aria-label="${e}°"><span class="mlcad-settings-option-indicator" aria-hidden="true"></span><span class="mlcad-settings-option-text">${e}°</span></button>`).join("");return`
@@ -474,4 +474,4 @@ ${Ca(l,c)}
474
474
  <script id="mlcad-snapshot" type="${i}+${o};base64">${r.payload}<\/script>
475
475
  <script>${Pa(a)}<\/script>
476
476
  </body>
477
- </html>`}function za(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Pa(t){return t.replace(/<\/script/gi,"<\\/script")}const Ia=400;function at(t={}){return{exportInvisibleLayers:t.exportInvisibleLayers!==!1,initialView:t.initialView??"fit",viewerMode:t.viewerMode??"measure"}}function Ba(t){const e=t.activeLayoutView,n=e.center,r=e.trCamera.zoom,a=Math.max(e.height,1),i=r*(2*Ia)/a;return{centerX:n.x,centerY:n.y,zoom:i}}const Ua="./viewer-runtime.iife.js";let mt={};function $a(t){mt={...mt,...t}}function ja(){return{...mt}}function Ta(t){return t!=null?String(t):mt.viewerRuntimeUrl!=null?String(mt.viewerRuntimeUrl):Ua}function Ha(){return{minX:0,minY:0,maxX:0,maxY:0,valid:!1}}function Fa(t,e,n){if(e.length<3)return;const r=n[0],a=n[1];for(let i=0;i+2<e.length;i+=3){const o=we(e[i],r),l=we(e[i+1],a);t.valid?(o<t.minX&&(t.minX=o),o>t.maxX&&(t.maxX=o),l<t.minY&&(t.minY=l),l>t.maxY&&(t.maxY=l)):(t.minX=t.maxX=o,t.minY=t.maxY=l,t.valid=!0)}}function Ce(t,e){Fa(t,e.positions,e.offset)}function Da(t){return t.valid?{minX:t.minX,minY:t.minY,maxX:t.maxX,maxY:t.maxY}:null}function Ra(t,e){const n=Ha();for(const r of t)Ce(n,r);for(const r of e)Ce(n,r);return Da(n)}class Va{build(e,n,r={}){return this.buildSync(e,n,r)}async buildAsync(e,n,r={}){await D();const a=r.exportInvisibleLayers!==!1,i=a?void 0:c=>rt(e,c,a),o=be(n,{title:r.title,background:r.background}),l=[];e.layers.forEach(c=>{rt(e,c.name,a)&&l.push({name:c.name,color:c.color.RGB??16777215,visible:!c.isOff&&!c.isFrozen})});const s=[];for(const[c,d]of e.layouts){const u=[],f=[];for(const[,p]of d.layers){if(!rt(e,p.name,a))continue;const g=ve(p.internalObject);u.push(...g.lineBatches),f.push(...g.meshBatches),await D()}s.push({btrId:c,name:ze(n,c),isModelSpace:c===e.modelSpaceBtrId,lineBatches:u,meshBatches:f,osnap:Se(r)?Ae(n,c,{includeLayer:i}):void 0}),await D()}return{version:ft,meta:Le(o,r,s,e.activeLayoutBtrId||e.modelSpaceBtrId),layers:l,layouts:s,activeLayoutBtrId:e.activeLayoutBtrId||e.modelSpaceBtrId}}buildSync(e,n,r){const a=r.exportInvisibleLayers!==!1,i=a?void 0:c=>rt(e,c,a),o=be(n,{title:r.title,background:r.background}),l=[];e.layers.forEach(c=>{rt(e,c.name,a)&&l.push({name:c.name,color:c.color.RGB??16777215,visible:!c.isOff&&!c.isFrozen})});const s=[];return e.layouts.forEach((c,d)=>{const u=[],f=[];for(const[,p]of c.layers){if(!rt(e,p.name,a))continue;const g=ve(p.internalObject);u.push(...g.lineBatches),f.push(...g.meshBatches)}s.push({btrId:d,name:ze(n,d),isModelSpace:d===e.modelSpaceBtrId,lineBatches:u,meshBatches:f,osnap:Se(r)?Ae(n,d,{includeLayer:i}):void 0})}),{version:ft,meta:Le(o,r,s,e.activeLayoutBtrId||e.modelSpaceBtrId),layers:l,layouts:s,activeLayoutBtrId:e.activeLayoutBtrId||e.modelSpaceBtrId}}}function Le(t,e,n,r){const a=n.find(l=>l.btrId===r)??n[0],i=a?Ra(a.lineBatches,a.meshBatches):null,o=e.initialView??"fit";return{title:t.title,createdAt:new Date().toISOString(),extents:t.extents,viewExtents:i??void 0,units:t.units,background:t.background,locale:e.locale??v.currentLocale,initialView:o,viewState:o==="current"?e.viewState:void 0,viewerMode:e.viewerMode??"measure"}}function Se(t){return(t.viewerMode??"measure")==="measure"}function rt(t,e,n){if(n)return!0;const r=t.layers.get(e);return r?!r.isOff&&!r.isFrozen:!0}function ze(t,e){for(const n of t.tables.blockTable.newIterator())if(n.objectId===e)return n.name;return e}class Oa{constructor(e={}){this.options=e,this._snapshotBuilder=new Va}async prepareAcTrView2dForHtmlExport(e,n={}){if(!e||!("cadScene"in e)||!e.cadScene)throw new Error("CAD scene is not available. Open a drawing before exporting to HTML.");if(!(e instanceof Ze))throw new Error("HTML export requires a 2D CAD view. Open a drawing before exporting.");const r=at(n);return await e.ensureEntitiesConvertedForExport({includeInvisibleLayers:r.exportInvisibleLayers}),await D(),e}async convert(e,n={},r){const a=dt.instance,i=at(n);await a.withBusyIndicator(async()=>{await D();const o=a.curDocument,l=await this.prepareAcTrView2dForHtmlExport(r??a.curView,i),s=e||o.fileName||o.docTitle,c=await this._snapshotBuilder.buildAsync(l.cadScene,o.database,{title:Ye(s),background:l.backgroundColor,exportInvisibleLayers:i.exportInvisibleLayers,initialView:i.initialView,viewerMode:i.viewerMode,viewState:i.initialView==="current"?Ba(l):void 0});await D();const d=await this.loadViewerRuntime();await D();const u=Me(c,{title:c.meta.title,viewerRuntime:d});await D(),this.downloadHtml(u,Xe(s,"html"))})}async packSnapshot(e,n){await dt.instance.withBusyIndicator(async()=>{await D();const r=await this.loadViewerRuntime();await D();const a=Me(e,{title:e.meta.title,viewerRuntime:r});await D(),this.downloadHtml(a,n)})}async loadViewerRuntime(){const e=Ta(this.options.viewerRuntimeUrl),n=await fetch(e);if(!n.ok)throw new Error(`Failed to load HTML viewer runtime from "${e}" (${n.status}). Install @mlightcad/cad-html-plugin, copy viewer-runtime.iife.js to your app assets, and set viewerRuntimeUrl on registerLazyHtmlPlugin / createHtmlPlugin / AcApHtmlConvertor.`);return n.text()}downloadHtml(e,n){const r=new Blob([e],{type:"text/html;charset=utf-8"}),a=URL.createObjectURL(r),i=document.createElement("a");i.href=a,i.download=n,document.body.appendChild(i),i.click(),document.body.removeChild(i),window.setTimeout(()=>URL.revokeObjectURL(a),6e4)}}class _a extends Ne{constructor(e={}){super(),this.pluginOptions=e}async execute(e){const n=await this.promptOptions();n&&await new Oa(this.pluginOptions).convert(e.doc.fileName||e.doc.docTitle,n,e.view)}async promptOptions(){const e=await this.promptExportInvisibleLayers();if(e===void 0)return;const n=await this.promptInitialView();if(n===void 0)return;const r=await this.promptViewerMode();if(r!==void 0)return at({exportInvisibleLayers:e,initialView:n,viewerMode:r})}async promptExportInvisibleLayers(){const e=at(),n=new Ct(v.t("jig.chtml.exportInvisibleLayers"));n.allowNone=!0;const r=n.keywords.add(v.t("jig.chtml.keywords.yes.display"),v.t("jig.chtml.keywords.yes.global"),v.t("jig.chtml.keywords.yes.local")),a=n.keywords.add(v.t("jig.chtml.keywords.no.display"),v.t("jig.chtml.keywords.no.global"),v.t("jig.chtml.keywords.no.local"));n.keywords.default=e.exportInvisibleLayers?r:a;const i=await dt.instance.editor.getKeywords(n);if(i.status!==B.Cancel){if(i.status===B.None)return e.exportInvisibleLayers;if(i.status===B.OK||i.status===B.Keyword)return i.stringResult?i.stringResult==="Yes":e.exportInvisibleLayers}}async promptInitialView(){const e=at(),n=new Ct(v.t("jig.chtml.initialView"));n.allowNone=!0;const r=n.keywords.add(v.t("jig.chtml.keywords.extents.display"),v.t("jig.chtml.keywords.extents.global"),v.t("jig.chtml.keywords.extents.local")),a=n.keywords.add(v.t("jig.chtml.keywords.current.display"),v.t("jig.chtml.keywords.current.global"),v.t("jig.chtml.keywords.current.local"));n.keywords.default=e.initialView==="current"?a:r;const i=await dt.instance.editor.getKeywords(n);if(i.status!==B.Cancel){if(i.status===B.None)return e.initialView;if(i.status===B.OK||i.status===B.Keyword)return i.stringResult?i.stringResult==="Current"?"current":"fit":e.initialView}}async promptViewerMode(){const e=at(),n=new Ct(v.t("jig.chtml.viewerMode"));n.allowNone=!0;const r=n.keywords.add(v.t("jig.chtml.keywords.view.display"),v.t("jig.chtml.keywords.view.global"),v.t("jig.chtml.keywords.view.local")),a=n.keywords.add(v.t("jig.chtml.keywords.measure.display"),v.t("jig.chtml.keywords.measure.global"),v.t("jig.chtml.keywords.measure.local"));n.keywords.default=e.viewerMode==="view"?r:a;const i=await dt.instance.editor.getKeywords(n);if(i.status!==B.Cancel){if(i.status===B.None)return e.viewerMode;if(i.status===B.OK||i.status===B.Keyword)return i.stringResult?i.stringResult==="View"?"view":"measure":e.viewerMode}}}const Ea="1.5.11",Na={version:Ea};class Za{constructor(e={}){this.options=e,this.name="HtmlPlugin",this.version=Na.version,this.description="HTML export (-chtml) command",this.registeredCommands=[]}onLoad(e,n){const r=Ee.SYSTEMT_COMMAND_GROUP_NAME,a=new _a(this.options);n.addCommand(r,"-chtml","-chtml",a),this.registeredCommands.push({group:r,name:"-chtml"}),n.lookupGlobalCmd("chtml")||(n.addCommand(r,"chtml","chtml",a),this.registeredCommands.push({group:r,name:"chtml"}))}onUnload(e,n){for(const r of this.registeredCommands)n.removeCmd(r.group,r.name);this.registeredCommands=[]}}async function Xa(t={}){return t.viewerRuntimeUrl!=null&&$a(t),new Za(ja())}export{Kn as ACEX_SNAPSHOT_COMPRESSION,ft as ACEX_SNAPSHOT_VERSION,_a as AcApExportHtmlCmd,Oa as AcApHtmlConvertor,Va as AcApHtmlSnapshotBuilder,Ua as DEFAULT_HTML_VIEWER_RUNTIME_URL,Ka as HTML_PLUGIN_NAME,Ja as HTML_PLUGIN_TRIGGERS,Ae as buildOsnapCatalog,be as buildViewerMetadata,Ba as captureAcApHtmlViewState,ve as collectBatchesFromObject3D,Jn as compressSnapshotBinary,$a as configureHtmlPlugin,Xa as createHtmlPlugin,or as encodeSnapshot,tr as encodeSnapshotBinary,br as exportActiveBatchedLine2Slice,Xt as exportActiveBatchedSlice,ye as exportBufferGeometrySlice,ja as getHtmlPluginOptions,Me as packHtml,at as resolveAcApHtmlExportOptions,ra as resolveAcExHtmlLocale,Ta as resolveViewerRuntimeUrl,lr as snapshotMimeType};
477
+ </html>`}function za(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Pa(t){return t.replace(/<\/script/gi,"<\\/script")}const Ia=400;function at(t={}){return{exportInvisibleLayers:t.exportInvisibleLayers!==!1,initialView:t.initialView??"fit",viewerMode:t.viewerMode??"measure"}}function Ba(t){const e=t.activeLayoutView,n=e.center,r=e.trCamera.zoom,a=Math.max(e.height,1),i=r*(2*Ia)/a;return{centerX:n.x,centerY:n.y,zoom:i}}const Ua="./viewer-runtime.iife.js";let mt={};function ja(t){mt={...mt,...t}}function $a(){return{...mt}}function Fa(t){return t!=null?String(t):mt.viewerRuntimeUrl!=null?String(mt.viewerRuntimeUrl):Ua}function Ha(){return{minX:0,minY:0,maxX:0,maxY:0,valid:!1}}function Ta(t,e,n){if(e.length<3)return;const r=n[0],a=n[1];for(let i=0;i+2<e.length;i+=3){const o=we(e[i],r),l=we(e[i+1],a);t.valid?(o<t.minX&&(t.minX=o),o>t.maxX&&(t.maxX=o),l<t.minY&&(t.minY=l),l>t.maxY&&(t.maxY=l)):(t.minX=t.maxX=o,t.minY=t.maxY=l,t.valid=!0)}}function Ce(t,e){Ta(t,e.positions,e.offset)}function Da(t){return t.valid?{minX:t.minX,minY:t.minY,maxX:t.maxX,maxY:t.maxY}:null}function Ra(t,e){const n=Ha();for(const r of t)Ce(n,r);for(const r of e)Ce(n,r);return Da(n)}class Va{build(e,n,r={}){return this.buildSync(e,n,r)}async buildAsync(e,n,r={}){await D();const a=r.exportInvisibleLayers!==!1,i=a?void 0:c=>rt(e,c,a),o=be(n,{title:r.title,background:r.background}),l=[];e.layers.forEach(c=>{rt(e,c.name,a)&&l.push({name:c.name,color:c.color.RGB??16777215,visible:!c.isOff&&!c.isFrozen})});const s=[];for(const[c,d]of e.layouts){const u=[],f=[];for(const[,p]of d.layers){if(!rt(e,p.name,a))continue;const g=ve(p.internalObject);u.push(...g.lineBatches),f.push(...g.meshBatches),await D()}s.push({btrId:c,name:ze(n,c),isModelSpace:c===e.modelSpaceBtrId,lineBatches:u,meshBatches:f,osnap:Se(r)?Ae(n,c,{includeLayer:i}):void 0}),await D()}return{version:ft,meta:Le(o,r,s,e.activeLayoutBtrId||e.modelSpaceBtrId),layers:l,layouts:s,activeLayoutBtrId:e.activeLayoutBtrId||e.modelSpaceBtrId}}buildSync(e,n,r){const a=r.exportInvisibleLayers!==!1,i=a?void 0:c=>rt(e,c,a),o=be(n,{title:r.title,background:r.background}),l=[];e.layers.forEach(c=>{rt(e,c.name,a)&&l.push({name:c.name,color:c.color.RGB??16777215,visible:!c.isOff&&!c.isFrozen})});const s=[];return e.layouts.forEach((c,d)=>{const u=[],f=[];for(const[,p]of c.layers){if(!rt(e,p.name,a))continue;const g=ve(p.internalObject);u.push(...g.lineBatches),f.push(...g.meshBatches)}s.push({btrId:d,name:ze(n,d),isModelSpace:d===e.modelSpaceBtrId,lineBatches:u,meshBatches:f,osnap:Se(r)?Ae(n,d,{includeLayer:i}):void 0})}),{version:ft,meta:Le(o,r,s,e.activeLayoutBtrId||e.modelSpaceBtrId),layers:l,layouts:s,activeLayoutBtrId:e.activeLayoutBtrId||e.modelSpaceBtrId}}}function Le(t,e,n,r){const a=n.find(l=>l.btrId===r)??n[0],i=a?Ra(a.lineBatches,a.meshBatches):null,o=e.initialView??"fit";return{title:t.title,createdAt:new Date().toISOString(),extents:t.extents,viewExtents:i??void 0,units:t.units,background:t.background,locale:e.locale??v.currentLocale,initialView:o,viewState:o==="current"?e.viewState:void 0,viewerMode:e.viewerMode??"measure"}}function Se(t){return(t.viewerMode??"measure")==="measure"}function rt(t,e,n){if(n)return!0;const r=t.layers.get(e);return r?!r.isOff&&!r.isFrozen:!0}function ze(t,e){for(const n of t.tables.blockTable.newIterator())if(n.objectId===e)return n.name;return e}class Oa{constructor(e={}){this.options=e,this._snapshotBuilder=new Va}async prepareAcTrView2dForHtmlExport(e,n={}){if(!e||!("cadScene"in e)||!e.cadScene)throw new Error("CAD scene is not available. Open a drawing before exporting to HTML.");if(!(e instanceof Ze))throw new Error("HTML export requires a 2D CAD view. Open a drawing before exporting.");const r=at(n);return await e.ensureEntitiesConvertedForExport({includeInvisibleLayers:r.exportInvisibleLayers}),await D(),e}async convert(e,n={},r){const a=dt.instance,i=at(n);await a.withBusyIndicator(async()=>{await D();const o=a.curDocument,l=await this.prepareAcTrView2dForHtmlExport(r??a.curView,i),s=e||o.fileName||o.docTitle,c=await this._snapshotBuilder.buildAsync(l.cadScene,o.database,{title:Xe(s),background:l.backgroundColor,exportInvisibleLayers:i.exportInvisibleLayers,initialView:i.initialView,viewerMode:i.viewerMode,viewState:i.initialView==="current"?Ba(l):void 0});await D();const d=await this.loadViewerRuntime();await D();const u=Me(c,{title:c.meta.title,viewerRuntime:d});await D(),this.downloadHtml(u,Ye(s,"html"))})}async packSnapshot(e,n){await dt.instance.withBusyIndicator(async()=>{await D();const r=await this.loadViewerRuntime();await D();const a=Me(e,{title:e.meta.title,viewerRuntime:r});await D(),this.downloadHtml(a,n)})}async loadViewerRuntime(){const e=Fa(this.options.viewerRuntimeUrl),n=await fetch(e);if(!n.ok)throw new Error(`Failed to load HTML viewer runtime from "${e}" (${n.status}). Install @mlightcad/cad-html-plugin, copy viewer-runtime.iife.js to your app assets, and set viewerRuntimeUrl on registerLazyHtmlPlugin / createHtmlPlugin / AcApHtmlConvertor.`);return n.text()}downloadHtml(e,n){const r=new Blob([e],{type:"text/html;charset=utf-8"}),a=URL.createObjectURL(r),i=document.createElement("a");i.href=a,i.download=n,document.body.appendChild(i),i.click(),document.body.removeChild(i),window.setTimeout(()=>URL.revokeObjectURL(a),6e4)}}class _a extends Ne{constructor(e={}){super(),this.pluginOptions=e}async execute(e){const n=await this.promptOptions();n&&await new Oa(this.pluginOptions).convert(e.doc.fileName||e.doc.docTitle,n,e.view)}async promptOptions(){const e=await this.promptExportInvisibleLayers();if(e===void 0)return;const n=await this.promptInitialView();if(n===void 0)return;const r=await this.promptViewerMode();if(r!==void 0)return at({exportInvisibleLayers:e,initialView:n,viewerMode:r})}async promptExportInvisibleLayers(){const e=at(),n=new Ct(v.t("jig.chtml.exportInvisibleLayers"));n.allowNone=!0;const r=n.keywords.add(v.t("jig.chtml.keywords.yes.display"),v.t("jig.chtml.keywords.yes.global"),v.t("jig.chtml.keywords.yes.local")),a=n.keywords.add(v.t("jig.chtml.keywords.no.display"),v.t("jig.chtml.keywords.no.global"),v.t("jig.chtml.keywords.no.local"));n.keywords.default=e.exportInvisibleLayers?r:a;const i=await dt.instance.editor.getKeywords(n);if(i.status!==B.Cancel){if(i.status===B.None)return e.exportInvisibleLayers;if(i.status===B.OK||i.status===B.Keyword)return i.stringResult?i.stringResult==="Yes":e.exportInvisibleLayers}}async promptInitialView(){const e=at(),n=new Ct(v.t("jig.chtml.initialView"));n.allowNone=!0;const r=n.keywords.add(v.t("jig.chtml.keywords.extents.display"),v.t("jig.chtml.keywords.extents.global"),v.t("jig.chtml.keywords.extents.local")),a=n.keywords.add(v.t("jig.chtml.keywords.current.display"),v.t("jig.chtml.keywords.current.global"),v.t("jig.chtml.keywords.current.local"));n.keywords.default=e.initialView==="current"?a:r;const i=await dt.instance.editor.getKeywords(n);if(i.status!==B.Cancel){if(i.status===B.None)return e.initialView;if(i.status===B.OK||i.status===B.Keyword)return i.stringResult?i.stringResult==="Current"?"current":"fit":e.initialView}}async promptViewerMode(){const e=at(),n=new Ct(v.t("jig.chtml.viewerMode"));n.allowNone=!0;const r=n.keywords.add(v.t("jig.chtml.keywords.view.display"),v.t("jig.chtml.keywords.view.global"),v.t("jig.chtml.keywords.view.local")),a=n.keywords.add(v.t("jig.chtml.keywords.measure.display"),v.t("jig.chtml.keywords.measure.global"),v.t("jig.chtml.keywords.measure.local"));n.keywords.default=e.viewerMode==="view"?r:a;const i=await dt.instance.editor.getKeywords(n);if(i.status!==B.Cancel){if(i.status===B.None)return e.viewerMode;if(i.status===B.OK||i.status===B.Keyword)return i.stringResult?i.stringResult==="View"?"view":"measure":e.viewerMode}}}const Ea="1.6.0",Na={version:Ea};class Za{constructor(e={}){this.options=e,this.name="HtmlPlugin",this.version=Na.version,this.description="HTML export (-chtml) command",this.registeredCommands=[]}onLoad(e,n){const r=Ee.SYSTEMT_COMMAND_GROUP_NAME,a=new _a(this.options);n.addCommand(r,"-chtml","-chtml",a),this.registeredCommands.push({group:r,name:"-chtml"}),n.lookupGlobalCmd("chtml")||(n.addCommand(r,"chtml","chtml",a),this.registeredCommands.push({group:r,name:"chtml"}))}onUnload(e,n){for(const r of this.registeredCommands)n.removeCmd(r.group,r.name);this.registeredCommands=[]}}async function Ya(t={}){return t.viewerRuntimeUrl!=null&&ja(t),new Za($a())}export{Kn as ACEX_SNAPSHOT_COMPRESSION,ft as ACEX_SNAPSHOT_VERSION,_a as AcApExportHtmlCmd,Oa as AcApHtmlConvertor,Va as AcApHtmlSnapshotBuilder,Ua as DEFAULT_HTML_VIEWER_RUNTIME_URL,Ka as HTML_PLUGIN_NAME,qa as HTML_PLUGIN_TRIGGERS,Ae as buildOsnapCatalog,be as buildViewerMetadata,Ba as captureAcApHtmlViewState,ve as collectBatchesFromObject3D,qn as compressSnapshotBinary,ja as configureHtmlPlugin,Ya as createHtmlPlugin,or as encodeSnapshot,tr as encodeSnapshotBinary,br as exportActiveBatchedLine2Slice,Yt as exportActiveBatchedSlice,ye as exportBufferGeometrySlice,$a as getHtmlPluginOptions,Me as packHtml,at as resolveAcApHtmlExportOptions,ra as resolveAcExHtmlLocale,Fa as resolveViewerRuntimeUrl,lr as snapshotMimeType};