three-text 0.3.4 → 0.4.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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * three-text v0.3.4
2
+ * three-text v0.4.0
3
3
  * Copyright (C) 2025 Countertype LLC
4
4
  *
5
5
  * This program is free software: you can redistribute it and/or modify
@@ -47,29 +47,29 @@ break}}return s.toFixed(2),s}u(){if(!a)return{}
47
47
  const t={}
48
48
  for(const e of this.h){if(!e.duration)continue
49
49
  const i=t[e.name]
50
- i?(i.count++,i.p+=e.duration,i.m=i.p/i.count,i.v=e.duration):t[e.name]={count:1,m:e.duration,p:e.duration,v:e.duration}}return t}S(){if(!a)return
50
+ i?(i.count++,i.p+=e.duration,i.v=i.p/i.count,i.m=e.duration):t[e.name]={count:1,v:e.duration,p:e.duration,m:e.duration}}return t}S(){if(!a)return
51
51
  const t=this.u()
52
52
  console.table(t),Object.keys(t).sort().join(", ")}_(){if(!a)return
53
53
  const t=this.u()
54
- Object.entries(t).forEach(([t,e])=>{e.m.toFixed(2)})}clear(){a&&(this.h.length=0,this.l.clear())}time(t,e,i){if(!a)return e()
54
+ Object.entries(t).forEach(([t,e])=>{e.v.toFixed(2)})}clear(){a&&(this.h.length=0,this.l.clear())}time(t,e,i){if(!a)return e()
55
55
  this.start(t,i)
56
56
  try{return e()}finally{this.end(t)}}async T(t,e,i){if(!a)return e()
57
57
  this.start(t,i)
58
58
  try{return await e()}finally{this.end(t)}}}
59
59
  const c=800,l=100,u=0,f=1/3
60
- var d,y;(t=>{t[t.BOX=0]="BOX",t[t.GLUE=1]="GLUE",t[t.PENALTY=2]="PENALTY",t[t.DISCRETIONARY=3]="DISCRETIONARY"})(d||(d={})),(t=>{t[t.VERY_LOOSE=0]="VERY_LOOSE",t[t.LOOSE=1]="LOOSE",t[t.DECENT=2]="DECENT",t[t.TIGHT=3]="TIGHT"})(y||(y={}))
61
- class p{constructor(){this.I=new Map,this.M=[]}getKey(t,e){return t<<2|e}L(t){const e=this.getKey(t.position,t.F),i=this.I.get(e)
60
+ var d,p;(t=>{t[t.BOX=0]="BOX",t[t.GLUE=1]="GLUE",t[t.PENALTY=2]="PENALTY",t[t.DISCRETIONARY=3]="DISCRETIONARY"})(d||(d={})),(t=>{t[t.VERY_LOOSE=0]="VERY_LOOSE",t[t.LOOSE=1]="LOOSE",t[t.DECENT=2]="DECENT",t[t.TIGHT=3]="TIGHT"})(p||(p={}))
61
+ class y{constructor(){this.I=new Map,this.M=[]}getKey(t,e){return t<<2|e}L(t){const e=this.getKey(t.position,t.F),i=this.I.get(e)
62
62
  return i?i.G>t.G&&(i.G=t.G,i.O=t.O,i.k=t.k,i.line=t.line,!0):(t.active=!0,t.D=this.M.length,this.M.push(t),this.I.set(e,t),!0)}U(t){if(!t.active)return
63
63
  t.active=!1
64
64
  const e=t.D,i=this.M.length-1
65
65
  if(e!==i){const t=this.M[i]
66
- this.M[e]=t,t.D=e}this.M.pop()}$(){return this.M}size(){return this.M.length}}const w=50,g=50,m=1e4,v=5e3,x=10,b=1e4,S=2,_=3,E=-1e4
67
- class T{static P(t,e){if(0===t)return 0
66
+ this.M[e]=t,t.D=e}this.M.pop()}N(){return this.M}size(){return this.M.length}}const w=50,g=50,v=1e4,m=5e3,x=10,S=1e4,b=2,_=3,E=-1e4
67
+ class T{static $(t,e){if(0===t)return 0
68
68
  if(0>=e)return 10001
69
69
  const i=Math.abs(t)/e
70
- return i>10?10001:Math.min(Math.round(100*i*i*i),1e4)}static N(t){return-.5>t?y.TIGHT:.5>t?y.DECENT:1>t?y.LOOSE:y.VERY_LOOSE}static R(t){const e=t.length+1,i=new Float64Array(e),n=new Float64Array(e),s=new Float64Array(e)
70
+ return i>10?10001:Math.min(Math.round(100*i*i*i),1e4)}static P(t){return-.5>t?p.TIGHT:.5>t?p.DECENT:1>t?p.LOOSE:p.VERY_LOOSE}static R(t){const e=t.length+1,i=new Float64Array(e),n=new Float64Array(e),s=new Float64Array(e)
71
71
  for(let e=0;t.length>e;e++){const r=t[e]
72
- i[e+1]=i[e]+r.width,r.type===d.GLUE?(n[e+1]=n[e]+r.stretch,s[e+1]=s[e]+r.j):(n[e+1]=n[e],s[e+1]=s[e])}return{width:i,stretch:n,j:s}}static W(t,e="en-us",i,n=S,s=_){let r
72
+ i[e+1]=i[e]+r.width,r.type===d.GLUE?(n[e+1]=n[e]+r.stretch,s[e+1]=s[e]+r.j):(n[e+1]=n[e],s[e+1]=s[e])}return{width:i,stretch:n,j:s}}static W(t,e="en-us",i,n=b,s=_){let r
73
73
  if(!i||!i[e])return[]
74
74
  if(r=i[e],!r)return[]
75
75
  const o=`.${t.toLowerCase()}.`,a=Array(o.length).fill(0)
@@ -79,30 +79,30 @@ if(!e.children||!e.children[n])break
79
79
  if(e=e.children[n],e.H)for(let i=0;e.H.length>i;i++){const n=t+i
80
80
  a.length>n&&(a[n]=Math.max(a[n],e.H[i]))}}}const h=[]
81
81
  for(let t=2;o.length-2>t;t++)a[t]%2==1&&h.push(t-1)
82
- return h.filter(e=>e>=n&&t.length-e>=s)}static V(t,e,i,n=!1,s="en-us",r,o=S,a=_,h,c){const l=[]
82
+ return h.filter(e=>e>=n&&t.length-e>=s)}static V(t,e,i,n=!1,s="en-us",r,o=b,a=_,h,c){const l=[]
83
83
  return l.push(...this.q(t,e,i,n,s,r,o,a,h,c)),l.push({type:d.GLUE,width:0,stretch:1e7,j:0,text:"",Y:t.length}),l.push({type:d.PENALTY,width:0,J:E,text:"",Y:t.length}),l}static K(t){const e=t.codePointAt(0)
84
84
  return void 0!==e&&(e>=19968&&40959>=e||e>=13312&&19903>=e||e>=131072&&173791>=e||e>=173824&&177983>=e||e>=177984&&178207>=e||e>=178208&&183983>=e||e>=63744&&64255>=e||e>=12352&&12447>=e||e>=12448&&12543>=e||e>=44032&&55215>=e||e>=4352&&4607>=e||e>=12592&&12687>=e||e>=43360&&43391>=e||e>=55216&&55295>=e||e>=65440&&65500>=e)}static X(t){const e=t.charCodeAt(0)
85
85
  return 12289===e||12290===e||65292===e||65294===e||65306===e||65307===e||65281===e||65311===e||65289===e||12305===e||65373===e||12301===e||12303===e||12297===e||12299===e||12309===e||12311===e||12313===e||12315===e||12540===e||8212===e||8230===e||8229===e}static Z(t){const e=t.charCodeAt(0)
86
86
  return 65288===e||12304===e||65371===e||12300===e||12302===e||12296===e||12298===e||12308===e||12310===e||12312===e||12314===e}static tt(t){return this.X(t)||this.Z(t)}static et(t,e,i,n,s=0,r){const o=[],a=Array.from(t),h=i?i(t):null
87
- let c,l,u,y=s
87
+ let c,l,u,p=s
88
88
  if(r)c=r.width,l=r.stretch,u=r.j
89
89
  else{const t=e("字")
90
90
  c=0,l=.04*t,u=.04*t}for(let t=0;a.length>t;t++){const i=a[t],n=a.length-1>t?a[t+1]:null
91
91
  if(/\s/.test(i)){const n=h?h[t]??e(i):e(i)
92
- o.push({type:d.GLUE,width:n,stretch:.5*n,j:n*f,text:i,Y:y}),y+=i.length
93
- continue}if(o.push({type:d.BOX,width:h?h[t]??e(i):e(i),text:i,Y:y}),y+=i.length,n&&!/\s/.test(n)){let t=!0
92
+ o.push({type:d.GLUE,width:n,stretch:.5*n,j:n*f,text:i,Y:p}),p+=i.length
93
+ continue}if(o.push({type:d.BOX,width:h?h[t]??e(i):e(i),text:i,Y:p}),p+=i.length,n&&!/\s/.test(n)){let t=!0
94
94
  this.X(n)&&(t=!1),this.Z(i)&&(t=!1)
95
95
  const e=this.tt(i)&&this.tt(n)
96
- t&&!e&&o.push({type:d.GLUE,width:c,stretch:l,j:u,text:"",Y:y})}}return o}static q(t,e,i,n,s,r,o,a,h,c){const l=[],u=Array.from(t)
97
- let f,d="",y=0,p=null,w=0
98
- const g=()=>{0!==d.length&&("cjk"===p?l.push(...this.et(d,e,i,h,y,(()=>{if(!f){const t=e("字")
99
- f={width:0,stretch:.04*t,j:.04*t}}return f})())):l.push(...this.it(d,y,e,n,s,r,o,a,h,c)),d="",p=null)}
96
+ t&&!e&&o.push({type:d.GLUE,width:c,stretch:l,j:u,text:"",Y:p})}}return o}static q(t,e,i,n,s,r,o,a,h,c){const l=[],u=Array.from(t)
97
+ let f,d="",p=0,y=null,w=0
98
+ const g=()=>{0!==d.length&&("cjk"===y?l.push(...this.et(d,e,i,h,p,(()=>{if(!f){const t=e("字")
99
+ f={width:0,stretch:.04*t,j:.04*t}}return f})())):l.push(...this.it(d,p,e,n,s,r,o,a,h,c)),d="",y=null)}
100
100
  for(let t=0;u.length>t;t++){const e=u[t],i=this.K(e)?"cjk":"word"
101
- null!==p&&p!==i&&(g(),y=w),null===p&&(p=i,y=w),d+=e,w+=e.length}return g(),l}static it(t,e,i,n,s,r,o,a,h,c){const l=[],u=t.match(/\S+|\s+/g)||[]
102
- let y=0
103
- for(const t of u){const u=e+y
101
+ null!==y&&y!==i&&(g(),p=w),null===y&&(y=i,p=w),d+=e,w+=e.length}return g(),l}static it(t,e,i,n,s,r,o,a,h,c){const l=[],u=t.match(/\S+|\s+/g)||[]
102
+ let p=0
103
+ for(const t of u){const u=e+p
104
104
  if(/\s+/.test(t)){const e=i(t)
105
- l.push({type:d.GLUE,width:e,stretch:.5*e,j:e*f,text:t,Y:u}),y+=t.length}else{const e=t.split(/(-)/)
105
+ l.push({type:d.GLUE,width:e,stretch:.5*e,j:e*f,text:t,Y:u}),p+=t.length}else{const e=t.split(/(-)/)
106
106
  let f=u
107
107
  for(const t of e)if(t){if("-"===t)l.push({type:d.DISCRETIONARY,width:i("-"),nt:"-",st:"",rt:"-",ot:i("-"),J:h?.ht??g,ct:!0,text:"-",Y:f}),f+=1
108
108
  else if(t.includes("­")){const e=t.split("­")
@@ -115,72 +115,72 @@ l.push({type:d.BOX,width:i(e),text:e,Y:f+n}),l.push({type:d.DISCRETIONARY,width:
115
115
  if(c&&e>c){const e=Array.from(t)
116
116
  for(let t=0;e.length>t;t++)l.push({type:d.BOX,width:i(e[t]),text:e[t],Y:f+t}),e.length-1>t&&l.push({type:d.PENALTY,width:0,J:5e3,Y:f+t+1})}else l.push({type:d.BOX,width:e,text:t,Y:f})}}else{const e=i(t)
117
117
  if(c&&e>c){const e=Array.from(t)
118
- for(let t=0;e.length>t;t++)l.push({type:d.BOX,width:i(e[t]),text:e[t],Y:f+t}),e.length-1>t&&l.push({type:d.PENALTY,width:0,J:5e3,Y:f+t+1})}else l.push({type:d.BOX,width:e,text:t,Y:f})}f+=t.length}y+=t.length}}return l}static lineBreak(t,e,i,n,s){const r=this.R(t),o=new p
119
- o.L({position:0,line:0,F:y.DECENT,G:0,O:null,k:!1,active:!0,D:0})
118
+ for(let t=0;e.length>t;t++)l.push({type:d.BOX,width:i(e[t]),text:e[t],Y:f+t}),e.length-1>t&&l.push({type:d.PENALTY,width:0,J:5e3,Y:f+t+1})}else l.push({type:d.BOX,width:e,text:t,Y:f})}f+=t.length}p+=t.length}}return l}static lineBreak(t,e,i,n,s){const r=this.R(t),o=new y
119
+ o.L({position:0,line:0,F:p.DECENT,G:0,O:null,k:!1,active:!0,D:0})
120
120
  for(let a=0;t.length>a;a++){const h=t[a]
121
121
  if(!(h.type===d.PENALTY&&1e4>h.J||h.type===d.DISCRETIONARY||h.type===d.GLUE&&a>0&&t[a-1].type===d.BOX))continue
122
122
  let c=0,l=!1;(h.type===d.PENALTY||h.type===d.DISCRETIONARY)&&(c=h.J,l=h.ct||!1)
123
123
  let u=0
124
124
  h.type===d.DISCRETIONARY&&(u=h.ot)
125
- const f=[null,null,null,null],y=[1/0,1/0,1/0,1/0],p=[],w=r.width[a],g=r.stretch[a],m=r.j[a],v=o.$()
126
- for(let t=0;v.length>t;t++){const o=v[t],h=g-r.stretch[o.position],d=m-r.j[o.position],x=e-(w-r.width[o.position]+u)
127
- let b
125
+ const f=[null,null,null,null],p=[1/0,1/0,1/0,1/0],y=[],w=r.width[a],g=r.stretch[a],v=r.j[a],m=o.N()
126
+ for(let t=0;m.length>t;t++){const o=m[t],h=g-r.stretch[o.position],d=v-r.j[o.position],x=e-(w-r.width[o.position]+u)
127
+ let S
128
128
  if(x>0){const t=h+n
129
- b=t>0?x/t:1/0}else b=0>x?d>0?x/d:-1/0:0
130
- const S=this.P(x,x>0?h+n:d)
131
- if(-1>b){p.push(o)
132
- continue}if(c!==E&&S>i)continue
133
- let _=s.ut+S
129
+ S=t>0?x/t:1/0}else S=0>x?d>0?x/d:-1/0:0
130
+ const b=this.$(x,x>0?h+n:d)
131
+ if(-1>S){y.push(o)
132
+ continue}if(c!==E&&b>i)continue
133
+ let _=s.ut+b
134
134
  1e4>Math.abs(_)?_*=_:_=1e8,c>0?_+=c*c:c>E&&(_-=c*c),l&&o.k&&(_+=s.ft)
135
- const T=this.N(b)
135
+ const T=this.P(S)
136
136
  Math.abs(T-o.F)>1&&(_+=s.dt)
137
137
  const A=o.G+_
138
- y[T]>A&&(y[T]=A,f[T]={position:a,line:o.line+1,F:T,G:A,O:o,k:l,active:!0,D:-1})}for(const t of p)o.U(t)
138
+ p[T]>A&&(p[T]=A,f[T]={position:a,line:o.line+1,F:T,G:A,O:o,k:l,active:!0,D:-1})}for(const t of y)o.U(t)
139
139
  for(let t=0;4>t;t++)f[t]&&o.L(f[t])
140
140
  if(0===o.size()&&c!==E)return null}let a=null,h=1/0
141
- for(const t of o.$())h>t.G&&(h=t.G,a=t)
141
+ for(const t of o.N())h>t.G&&(h=t.G,a=t)
142
142
  return a}static yt(t){if(!t.text||0===t.text.length)return[]
143
- const{text:e,width:i,align:n="left",direction:s="ltr",wt:r=!1,language:o="en-us",gt:a=!0,measureText:f,vt:d,xt:y,bt:p,letterSpacing:E=0,St:T=c,_t:A=l,Et:I=u,Tt:M,At:L=S,It:F=_,Mt:G=x,Lt:O=b,Ft:C=w,Gt:k=g,Ot:B=m,Ct:D=v}=t
143
+ const{text:e,width:i,align:n="left",direction:s="ltr",wt:r=!1,language:o="en-us",gt:a=!0,measureText:f,vt:d,xt:p,St:y,letterSpacing:E=0,bt:T=c,_t:A=l,Et:I=u,Tt:M,At:L=b,It:F=_,Mt:G=x,Lt:O=S,Ft:C=w,Gt:k=g,Ot:D=v,Ct:U=m}=t
144
144
  if(a&&e.includes("\n")){const i=e.split("\n"),n=[]
145
145
  let s=0
146
- for(const e of i){if(0===e.length)n.push({text:"",kt:s,Bt:s,Dt:0,Ut:!0,naturalWidth:0,$t:!1})
146
+ for(const e of i){if(0===e.length)n.push({text:"",kt:s,Dt:s,Ut:0,Bt:!0,naturalWidth:0,Nt:!1})
147
147
  else{const i=this.yt({...t,text:e,gt:!1})
148
- i.forEach(t=>{t.kt+=s,t.Bt+=s}),n.push(...i)}s+=e.length+1}return n}let U=r
149
- !U||y&&y[o]||(h.warn(`Hyphenation patterns for ${o} not available`),U=!1)
150
- let $=I
151
- void 0!==M&&i&&($=i*M)
152
- const P={ut:G,dt:O,ft:B,Pt:D,lt:C,ht:k,Nt:n,bt:p,Rt:p?E*p:0}
148
+ i.forEach(t=>{t.kt+=s,t.Dt+=s}),n.push(...i)}s+=e.length+1}return n}let B=r
149
+ !B||p&&p[o]||(h.warn(`Hyphenation patterns for ${o} not available`),B=!1)
150
+ let N=I
151
+ void 0!==M&&i&&(N=i*M)
152
+ const $={ut:G,dt:O,ft:D,$t:U,lt:C,ht:k,Pt:n,St:y,Rt:y?E*y:0}
153
153
  if(!i||i===1/0){const t=f(e)
154
- return[{text:e,kt:0,Bt:e.length-1,Dt:0,Ut:!0,naturalWidth:t,$t:!1}]}let N=this.V(e,f,d,!1,o,y,L,F,P,i),R=this.lineBreak(N,i,A,0,P)
155
- if(!R&&U&&(N=this.V(e,f,d,!0,o,y,L,F,P,i),R=this.lineBreak(N,i,T,0,P)),!R){const t=5
156
- for(let e=0;t>e&&!R;e++){const t=$+e*i*.1
157
- R=this.lineBreak(N,i,T,t,P),R||(R=this.lineBreak(N,i,1e4,t,P))}}if(R){const t=[]
154
+ return[{text:e,kt:0,Dt:e.length-1,Ut:0,Bt:!0,naturalWidth:t,Nt:!1}]}let P=this.V(e,f,d,!1,o,p,L,F,$,i),R=this.lineBreak(P,i,A,0,$)
155
+ if(!R&&B&&(P=this.V(e,f,d,!0,o,p,L,F,$,i),R=this.lineBreak(P,i,T,0,$)),!R){const t=5
156
+ for(let e=0;t>e&&!R;e++){const t=N+e*i*.1
157
+ R=this.lineBreak(P,i,T,t,$),R||(R=this.lineBreak(P,i,1e4,t,$))}}if(R){const t=[]
158
158
  let r=R
159
159
  for(;r&&r.position>0;)t.unshift(r.position),r=r.O
160
- return this.jt(e,N,t,i,n,s,P)}return[{text:e,kt:0,Bt:e.length-1,Dt:0,zt:0,Ut:!0,naturalWidth:f(e),$t:!1}]}static jt(t,e,i,n,s,r,o){if(0===i.length)return[{text:t,kt:0,Bt:t.length-1,Dt:0}]
160
+ return this.zt(e,P,t,i,n,s,$)}return[{text:e,kt:0,Dt:e.length-1,Ut:0,jt:0,Bt:!0,naturalWidth:f(e),Nt:!1}]}static zt(t,e,i,n,s,r,o){if(0===i.length)return[{text:t,kt:0,Dt:t.length-1,Ut:0}]
161
161
  const a=[]
162
162
  let h=0
163
163
  for(let t=0;i.length>t;t++){const c=i[t],l=!(e.length-1>i[i.length-1]+1)&&t===i.length-1,u=[]
164
- let f=-1,y=-1,p=0,w=0,g=0
164
+ let f=-1,p=-1,y=0,w=0,g=0
165
165
  for(let t=h;c>t;t++){const i=e[t]
166
166
  if((i.type!==d.PENALTY||i.text)&&(i.type!==d.DISCRETIONARY||i.rt)){if(void 0!==i.Y){(-1===f||f>i.Y)&&(f=i.Y)
167
167
  const t=i.Y+(i.text?i.text.length:0)-1
168
- t>y&&(y=t)}i.text?u.push(i.text):i.type===d.DISCRETIONARY&&i.rt&&u.push(i.rt),p+=i.width,i.type===d.GLUE&&(w+=i.stretch,g+=i.j)}}const m=e[c]
169
- let v=!1
170
- if(e.length>c)if(m.type===d.PENALTY&&m.ct)u.push("-"),p+=m.width,v=!0,void 0!==m.Y&&(y=m.Y-1)
171
- else if(m.type===d.DISCRETIONARY){const t=m
172
- t.nt&&(u.push(t.nt),p+=t.ot,v=t.ct||!1,void 0!==m.Y&&(y=m.Y-1))}const x=u.join("")
173
- o?.Rt&&0!==p&&(p-=o.Rt)
174
- let b=0,S=0,_=s
175
- if("justify"===s&&l&&(_="rtl"===r?"right":"left"),"center"===_)b=(n-p)/2
176
- else if("right"===_)b=n-p
177
- else if("justify"===_&&!l){const t=n-p
178
- t>0&&w>0?S=t/w:0>t&&g>0&&(S=t/g)}a.push({text:x,kt:f,Bt:y,Dt:b,zt:S,Ut:!1,naturalWidth:p,$t:v}),h=c+1}if(e.length-1>h){const t=[]
168
+ t>p&&(p=t)}i.text?u.push(i.text):i.type===d.DISCRETIONARY&&i.rt&&u.push(i.rt),y+=i.width,i.type===d.GLUE&&(w+=i.stretch,g+=i.j)}}const v=e[c]
169
+ let m=!1
170
+ if(e.length>c)if(v.type===d.PENALTY&&v.ct)u.push("-"),y+=v.width,m=!0,void 0!==v.Y&&(p=v.Y-1)
171
+ else if(v.type===d.DISCRETIONARY){const t=v
172
+ t.nt&&(u.push(t.nt),y+=t.ot,m=t.ct||!1,void 0!==v.Y&&(p=v.Y-1))}const x=u.join("")
173
+ o?.Rt&&0!==y&&(y-=o.Rt)
174
+ let S=0,b=0,_=s
175
+ if("justify"===s&&l&&(_="rtl"===r?"right":"left"),"center"===_)S=(n-y)/2
176
+ else if("right"===_)S=n-y
177
+ else if("justify"===_&&!l){const t=n-y
178
+ t>0&&w>0?b=t/w:0>t&&g>0&&(b=t/g)}a.push({text:x,kt:f,Dt:p,Ut:S,jt:b,Bt:!1,naturalWidth:y,Nt:m}),h=c+1}if(e.length-1>h){const t=[]
179
179
  let i=-1,c=-1,l=0
180
180
  for(let n=h;e.length-1>n;n++){const s=e[n]
181
181
  s.type!==d.PENALTY&&(void 0!==s.Y&&((-1===i||i>s.Y)&&(i=s.Y),s.Y>c&&(c=s.Y)),s.text&&t.push(s.text),l+=s.width)}o?.Rt&&0!==l&&(l-=o.Rt)
182
182
  let u=0,f=s
183
- "justify"===s&&(f="rtl"===r?"right":"left"),"center"===f?u=(n-l)/2:"right"===f&&(u=n-l),a.push({text:t.join(""),kt:i,Bt:c,Dt:u,zt:0,Ut:!0,naturalWidth:l,$t:!1}),a.length>1&&(a[a.length-2].Ut=!1),a[a.length-1].Ut=!0}else a.length>0&&(a[a.length-1].Ut=!0)
183
+ "justify"===s&&(f="rtl"===r?"right":"left"),"center"===f?u=(n-l)/2:"right"===f&&(u=n-l),a.push({text:t.join(""),kt:i,Dt:c,Ut:u,jt:0,Bt:!0,naturalWidth:l,Nt:!1}),a.length>1&&(a[a.length-2].Bt=!1),a[a.length-1].Bt=!0}else a.length>0&&(a[a.length-1].Bt=!0)
184
184
  return a}}const A=new WeakMap
185
185
  class I{static vt(e,i,n=0){const s=Array.from(i)
186
186
  if(0===s.length)return[]
@@ -202,32 +202,32 @@ const r=t(e.Vt)
202
202
  e.hb.shape(e.font,s,r)
203
203
  const o=s.json(e.font),a=n*e.upem
204
204
  let h=0
205
- return o.forEach(t=>{h+=t.ax,0!==a&&(h+=a)}),s.destroy(),h}}class M{constructor(t){this.Yt=t}Jt(t){const{text:e,width:i,align:n,direction:s,wt:r,language:o,gt:a,St:h,_t:c,Et:l,Tt:u,xt:f,At:d,It:y,Mt:p,Lt:w,Ft:g,Gt:m,Ot:v,letterSpacing:x}=t
206
- let b
207
- if(i)b=T.yt({text:e,width:i,align:n,direction:s,wt:r,language:o,gt:a,St:h,_t:c,Et:l,Tt:u,xt:f,At:d,It:y,Mt:p,Lt:w,Ft:g,Gt:m,Ot:v,bt:this.Yt.upem,letterSpacing:x,measureText:t=>I.measureTextWidth(this.Yt,t,x),vt:t=>I.vt(this.Yt,t,x)})
205
+ return o.forEach(t=>{h+=t.ax,0!==a&&(h+=a)}),s.destroy(),h}}class M{constructor(t){this.Yt=t}Jt(t){const{text:e,width:i,align:n,direction:s,wt:r,language:o,gt:a,bt:h,_t:c,Et:l,Tt:u,xt:f,At:d,It:p,Mt:y,Lt:w,Ft:g,Gt:v,Ot:m,letterSpacing:x}=t
206
+ let S
207
+ if(i)S=T.yt({text:e,width:i,align:n,direction:s,wt:r,language:o,gt:a,bt:h,_t:c,Et:l,Tt:u,xt:f,At:d,It:p,Mt:y,Lt:w,Ft:g,Gt:v,Ot:m,St:this.Yt.upem,letterSpacing:x,measureText:t=>I.measureTextWidth(this.Yt,t,x),vt:t=>I.vt(this.Yt,t,x)})
208
208
  else{const t=e.split("\n")
209
- b=[]
209
+ S=[]
210
210
  let i=0
211
- for(const e of t)b.push({text:e,kt:i,Bt:0===e.length?i:i+e.length-1,Dt:0}),i+=e.length+1}return{lines:b}}Kt(t,e){const{offset:i,Xt:n}=this.Qt(e)
211
+ for(const e of t)S.push({text:e,kt:i,Dt:0===e.length?i:i+e.length-1,Ut:0}),i+=e.length+1}return{lines:S}}Kt(t,e){const{offset:i,Qt:n}=this.Xt(e)
212
212
  if(0!==i)for(let e=0;t.length>e;e+=3)t[e]+=i
213
- return{offset:i,Xt:n}}Qt(t){const{width:e,align:i,planeBounds:n}=t
213
+ return{offset:i,Qt:n}}Xt(t){const{width:e,align:i,planeBounds:n}=t
214
214
  let s=0
215
215
  const r={min:{...n.min},max:{...n.max}}
216
- return!e||"center"!==i&&"right"!==i||(s="center"===i?(e-(n.max.x-n.min.x))/2-n.min.x:e-n.max.x),0!==s&&(r.min.x+=s,r.max.x+=s),{offset:s,Xt:r}}}const L=65536,F=1330926671,G=2001684038,O=1751474532,C=1751672161,k=1330851634,B=1719034226,D=1398030676,U=1851878757,$=1128678944,P=1128678962,N=1196643650,R=1196445523,j=new TextDecoder("utf-16be")
217
- class z{static Zt(t){if(!t||12>t.byteLength)throw Error("Invalid font buffer: too small to be a valid font file")
216
+ return!e||"center"!==i&&"right"!==i||(s="center"===i?(e-(n.max.x-n.min.x))/2-n.min.x:e-n.max.x),0!==s&&(r.min.x+=s,r.max.x+=s),{offset:s,Qt:r}}}const L=65536,F=1330926671,G=2001684038,O=1751474532,C=1751672161,k=1330851634,D=1719034226,U=1398030676,B=1851878757,N=1128678944,$=1128678962,P=1196643650,R=1196445523,z=new TextDecoder("utf-16be")
217
+ class j{static Zt(t){if(!t||12>t.byteLength)throw Error("Invalid font buffer: too small to be a valid font file")
218
218
  const i=new DataView(t),n=i.getUint32(0)
219
219
  if(![L,F].includes(n))throw Error("Invalid font format. Expected TTF/OTF (or WOFF), got signature: 0x"+n.toString(16))
220
- const s=e(i),r=s.has($)||s.has(P),o=s.get(O)?.offset??0,a=s.get(C)?.offset??0,h=s.get(k)?.offset??0,c=s.get(B)?.offset??0,l=s.get(D)?.offset??0,u=s.get(U)?.offset??0,f=o?i.getUint16(o+18):1e3
220
+ const s=e(i),r=s.has(N)||s.has($),o=s.get(O)?.offset??0,a=s.get(C)?.offset??0,h=s.get(k)?.offset??0,c=s.get(D)?.offset??0,l=s.get(U)?.offset??0,u=s.get(B)?.offset??0,f=o?i.getUint16(o+18):1e3
221
221
  let d=null
222
222
  a&&(d={te:i.getInt16(a+4),ee:i.getInt16(a+6),ie:i.getInt16(a+8)})
223
- let y=null
224
- h&&(y={ne:i.getInt16(h+68),se:i.getInt16(h+70),re:i.getInt16(h+72),oe:i.getUint16(h+74),ae:i.getUint16(h+76)})
225
223
  let p=null
226
- return c&&l&&u&&(p=this.he(i,l,u)),{ce:r,bt:f,le:d?.te||null,ue:d?.ee||null,fe:d?.ie||null,ne:y?.ne||null,se:y?.se||null,re:y?.re||null,oe:y?.oe||null,ae:y?.ae||null,de:p}}static ye(t){const i=new DataView(t),n=e(i),s=n.get(N)?.offset??0,r=n.get(R)?.offset??0,o=n.get(U)?.offset??0,a=new Set,h={}
227
- try{if(s){const t=this.pe(i,s,o)
228
- t.features.forEach(t=>a.add(t)),Object.assign(h,t.names)}if(r){const t=this.pe(i,r,o)
224
+ h&&(p={ne:i.getInt16(h+68),se:i.getInt16(h+70),re:i.getInt16(h+72),oe:i.getUint16(h+74),ae:i.getUint16(h+76)})
225
+ let y=null
226
+ return c&&l&&u&&(y=this.he(i,l,u)),{ce:r,St:f,le:d?.te||null,ue:d?.ee||null,fe:d?.ie||null,ne:p?.ne||null,se:p?.se||null,re:p?.re||null,oe:p?.oe||null,ae:p?.ae||null,de:y}}static pe(t){const i=new DataView(t),n=e(i),s=n.get(P)?.offset??0,r=n.get(R)?.offset??0,o=n.get(B)?.offset??0,a=new Set,h={}
227
+ try{if(s){const t=this.ye(i,s,o)
228
+ t.features.forEach(t=>a.add(t)),Object.assign(h,t.names)}if(r){const t=this.ye(i,r,o)
229
229
  t.features.forEach(t=>a.add(t)),Object.assign(h,t.names)}}catch(t){return}const c=Array.from(a).sort()
230
- if(0!==c.length)return{tags:c,names:Object.keys(h).length>0?h:{}}}static pe(t,e,i){const n=e+t.getUint16(e+6),s=t.getUint16(n),r=[],o={}
230
+ if(0!==c.length)return{tags:c,names:Object.keys(h).length>0?h:{}}}static ye(t,e,i){const n=e+t.getUint16(e+6),s=t.getUint16(n),r=[],o={}
231
231
  for(let e=0;s>e;e++){const s=n+2+6*e,a=String.fromCharCode(t.getUint8(s),t.getUint8(s+1),t.getUint8(s+2),t.getUint8(s+3))
232
232
  if(r.push(a),/^(ss\d{2}|cv\d{2})$/.test(a)&&i){const e=n+t.getUint16(s+4),r=t.getUint16(e)
233
233
  if(0!==r){const n=e+r
@@ -245,22 +245,22 @@ for(let e=0;f.length>e;e+=2)t+=String.fromCharCode(f[e]<<8|f[e+1])
245
245
  return t}return new TextDecoder("ascii").decode(f)}return null}catch(t){return null}}static ge(t){if(!t||12>t.byteLength)throw Error("Invalid font buffer: too small to be a valid font file")
246
246
  const i=new DataView(t),n=i.getUint32(0)
247
247
  if(![L,F].includes(n))throw Error("Invalid font format. Expected TTF/OTF (or WOFF), got signature: 0x"+n.toString(16))
248
- const s=e(i),r=s.get(U)?.offset??0,o=r?this.me(i,r):null
249
- return{h:this.ve(i,s,o),features:this.xe(i,s,o)}}static me(t,e){const i=new Map,n=t.getUint16(e+2),s=t.getUint16(e+4)
250
- for(let r=0;n>r;r++){const n=e+6+12*r,o=t.getUint16(n),a=t.getUint16(n+2),h=t.getUint16(n+4),c=t.getUint16(n+6),l=t.getUint16(n+8),u=t.getUint16(n+10);(0===o||3===o&&1033===h)&&(i.has(c)||i.set(c,{offset:e+s+u,length:l,be:o,Se:a}))}return i}static _e(t,e,i){if(!e)return null
248
+ const s=e(i),r=s.get(B)?.offset??0,o=r?this.ve(i,r):null
249
+ return{h:this.me(i,s,o),features:this.xe(i,s,o)}}static ve(t,e){const i=new Map,n=t.getUint16(e+2),s=t.getUint16(e+4)
250
+ for(let r=0;n>r;r++){const n=e+6+12*r,o=t.getUint16(n),a=t.getUint16(n+2),h=t.getUint16(n+4),c=t.getUint16(n+6),l=t.getUint16(n+8),u=t.getUint16(n+10);(0===o||3===o&&1033===h)&&(i.has(c)||i.set(c,{offset:e+s+u,length:l,Se:o,be:a}))}return i}static _e(t,e,i){if(!e)return null
251
251
  const n=e.get(i)
252
252
  if(!n)return null
253
253
  try{const e=new Uint8Array(t.buffer,n.offset,n.length)
254
- return 0===n.be||3===n.be&&1===n.Se?j.decode(e):new TextDecoder("ascii").decode(e)}catch{return null}}static ve(t,e,i){const n=e.has($)||e.has(P),s=e.get(O)?.offset??0,r=e.get(C)?.offset??0,o=e.get(k)?.offset??0,a=e.get(B)?.offset??0,h=e.get(D)?.offset??0,c=s?t.getUint16(s+18):1e3
254
+ return 0===n.Se||3===n.Se&&1===n.be?z.decode(e):new TextDecoder("ascii").decode(e)}catch{return null}}static me(t,e,i){const n=e.has(N)||e.has($),s=e.get(O)?.offset??0,r=e.get(C)?.offset??0,o=e.get(k)?.offset??0,a=e.get(D)?.offset??0,h=e.get(U)?.offset??0,c=s?t.getUint16(s+18):1e3
255
255
  let l=null
256
256
  r&&(l={te:t.getInt16(r+4),ee:t.getInt16(r+6),ie:t.getInt16(r+8)})
257
257
  let u=null
258
258
  o&&(u={ne:t.getInt16(o+68),se:t.getInt16(o+70),re:t.getInt16(o+72),oe:t.getUint16(o+74),ae:t.getUint16(o+76)})
259
259
  let f=null
260
- return a&&h&&i&&(f=this.Ee(t,h,i)),{ce:n,bt:c,le:l?.te||null,ue:l?.ee||null,fe:l?.ie||null,ne:u?.ne||null,se:u?.se||null,re:u?.re||null,oe:u?.oe||null,ae:u?.ae||null,de:f}}static Ee(t,e,i){try{if(1>t.getUint16(e))return null
260
+ return a&&h&&i&&(f=this.Ee(t,h,i)),{ce:n,St:c,le:l?.te||null,ue:l?.ee||null,fe:l?.ie||null,ne:u?.ne||null,se:u?.se||null,re:u?.re||null,oe:u?.oe||null,ae:u?.ae||null,de:f}}static Ee(t,e,i){try{if(1>t.getUint16(e))return null
261
261
  const n=t.getUint16(e+4),s=t.getUint16(e+6),r=t.getUint32(e+8),o={}
262
262
  for(let a=0;s>a;a++){const s=e+r+a*n,h=String.fromCharCode(t.getUint8(s),t.getUint8(s+1),t.getUint8(s+2),t.getUint8(s+3)),c=t.getUint16(s+4),l=this._e(t,i,c)
263
- l&&(o[h]=l)}return Object.keys(o).length>0?o:null}catch{return null}}static xe(t,e,i){const n=e.get(N)?.offset??0,s=e.get(R)?.offset??0,r=new Set,o={}
263
+ l&&(o[h]=l)}return Object.keys(o).length>0?o:null}catch{return null}}static xe(t,e,i){const n=e.get(P)?.offset??0,s=e.get(R)?.offset??0,r=new Set,o={}
264
264
  try{n&&this.Te(t,n,i,r,o),s&&this.Te(t,s,i,r,o)}catch{return}if(0!==r.size)return{tags:Array.from(r).sort((t,e)=>t-e).map(this.Ae),names:Object.keys(o).length>0?o:{}}}static Te(t,e,i,n,s){const r=e+t.getUint16(e+6),o=t.getUint16(r)
265
265
  for(let e=0;o>e;e++){const o=r+2+6*e,a=t.getUint32(o)
266
266
  n.add(a)
@@ -273,9 +273,9 @@ const u=r+t.getUint16(o+4),f=t.getUint16(u)
273
273
  if(0===f)continue
274
274
  const d=u+f
275
275
  if(0!==t.getUint16(d))continue
276
- const y=t.getUint16(d+2),p=this._e(t,i,y)
277
- p&&(s[String.fromCharCode(a>>24&255,a>>16&255,a>>8&255,255&a)]=p)}}static Ae(t){return String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,255&t)}static Ie(t){return null!==t.ne&&null!==t.se?{te:t.ne,ee:t.se,ie:0}:null!==t.le&&null!==t.ue?{te:t.le,ee:t.ue,ie:0}:null!==t.oe&&null!==t.ae?{te:t.oe,ee:-t.ae,ie:0}:{te:Math.round(.8*t.bt),ee:-Math.round(.2*t.bt),ie:0}}static Me(t){const e=z.Ie(t)
278
- return{te:e.te,ee:e.ee,ie:e.ie,bt:t.bt,Le:e.te-e.ee}}}class W{static Fe(t){if(4>t.byteLength)return"ttf/otf"
276
+ const p=t.getUint16(d+2),y=this._e(t,i,p)
277
+ y&&(s[String.fromCharCode(a>>24&255,a>>16&255,a>>8&255,255&a)]=y)}}static Ae(t){return String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,255&t)}static Ie(t){return null!==t.ne&&null!==t.se?{te:t.ne,ee:t.se,ie:0}:null!==t.le&&null!==t.ue?{te:t.le,ee:t.ue,ie:0}:null!==t.oe&&null!==t.ae?{te:t.oe,ee:-t.ae,ie:0}:{te:Math.round(.8*t.St),ee:-Math.round(.2*t.St),ie:0}}static Me(t){const e=j.Ie(t)
278
+ return{te:e.te,ee:e.ee,ie:e.ie,St:t.St,Le:e.te-e.ee}}}class W{static Fe(t){if(4>t.byteLength)return"ttf/otf"
279
279
  const e=new DataView(t).getUint32(0)
280
280
  return e===G?"woff":2001684018===e?"woff2":"ttf/otf"}static async Ge(t){const e=new DataView(t),i=new Uint8Array(t)
281
281
  if(e.getUint32(0)!==G)throw Error("Not a valid WOFF font")
@@ -295,53 +295,53 @@ if(n.byteLength!==t.Oe)throw Error(`Decompression failed: expected ${t.Oe} bytes
295
295
  return new Uint8Array(n)}))
296
296
  for(let t=0;s>t;t++){const e=l[t],i=12+16*t
297
297
  a.setUint32(i,e.tag),a.setUint32(i+4,e.t),a.setUint32(i+8,c),a.setUint32(i+12,e.Oe),o.set(u[t],c),c+=e.Oe,c+=(4-e.Oe%4)%4}return o.buffer.slice(0,c)}static async Ce(t){const e=new ReadableStream({start(e){e.enqueue(t),e.close()}}).pipeThrough(new DecompressionStream("deflate"))
298
- return new Response(e).arrayBuffer()}}class H{constructor(t){this.ke=t}async Be(t,e){if(!t||12>t.byteLength)throw Error("Invalid font buffer: too small to be a valid font file")
298
+ return new Response(e).arrayBuffer()}}class H{constructor(t){this.ke=t}async De(t,e){if(!t||12>t.byteLength)throw Error("Invalid font buffer: too small to be a valid font file")
299
299
  const i=W.Fe(t)
300
300
  if("woff"===i)t=await W.Ge(t)
301
301
  else if("woff2"===i)throw Error("WOFF2 fonts are not yet supported. Please use WOFF or TTF/OTF format.")
302
302
  const n=new DataView(t).getUint32(0)
303
303
  if(![L,F].includes(n))throw Error("Invalid font format. Expected TTF/OTF (or WOFF), got signature: 0x"+n.toString(16))
304
304
  const{hb:s,module:r}=await this.ke()
305
- try{const i=s.De(new Uint8Array(t)),n=s.Ue(i,0),o=s.$e(n)
306
- e&&o.Pe(e)
307
- const a=n.Ne(),h=Object.keys(a).length>0,{h:c,features:l}=z.ge(t)
305
+ try{const i=s.Ue(new Uint8Array(t)),n=s.Be(i,0),o=s.Ne(n)
306
+ e&&o.$e(e)
307
+ const a=n.Pe(),h=Object.keys(a).length>0,{h:c,features:l}=j.ge(t)
308
308
  let u
309
309
  if(h&&a){u={}
310
- for(const[t,e]of Object.entries(a))u[t]={...e,name:c.de?.[t]||null}}return{hb:s,fontBlob:i,face:n,font:o,module:r,upem:c.bt,h:c,Re:e,je:h,ze:u,We:l?.tags,He:l?.names,Ve:t}}catch(t){throw h.error("Failed to load font:",t),t}}static qe(t){try{t.font&&"function"==typeof t.font.destroy&&t.font.destroy(),t.face&&"function"==typeof t.face.destroy&&t.face.destroy(),t.fontBlob&&"function"==typeof t.fontBlob.destroy&&t.fontBlob.destroy()}catch(t){h.error("Error destroying font resources:",t)}}}const V=/^[a-z]{2,3}(?:-[a-z0-9]{2,16})*$/i,q=new Set(["af","as","be","bg","bn","ca","cs","cy","da","de-1996","el-monoton","el-polyton","en-gb","en-us","eo","es","et","eu","fi","fr","fur","ga","gl","gu","hi","hr","hsb","hu","hy","ia","id","is","it","ka","kmr","kn","la","lt","lv","mk","ml","mn-cyrl","mr","mul-ethi","nb","nl","nn","oc","or","pa","pl","pms","pt","rm","ro","ru","sa","sh-cyrl","sh-latn","sk","sl","sq","sr-cyrl","sv","ta","te","th","tk","tr","uk","zh-latn-pinyin"])
310
+ for(const[t,e]of Object.entries(a))u[t]={...e,name:c.de?.[t]||null}}return{hb:s,fontBlob:i,face:n,font:o,module:r,upem:c.St,h:c,Re:e,ze:h,je:u,We:l?.tags,He:l?.names,Ve:t}}catch(t){throw h.error("Failed to load font:",t),t}}static qe(t){try{t.font&&"function"==typeof t.font.destroy&&t.font.destroy(),t.face&&"function"==typeof t.face.destroy&&t.face.destroy(),t.fontBlob&&"function"==typeof t.fontBlob.destroy&&t.fontBlob.destroy()}catch(t){h.error("Error destroying font resources:",t)}}}const V=/^[a-z]{2,3}(?:-[a-z0-9]{2,16})*$/i,q=new Set(["af","as","be","bg","bn","ca","cs","cy","da","de-1996","el-monoton","el-polyton","en-gb","en-us","eo","es","et","eu","fi","fr","fur","ga","gl","gu","hi","hr","hsb","hu","hy","ia","id","is","it","ka","kmr","kn","la","lt","lv","mk","ml","mn-cyrl","mr","mul-ethi","nb","nl","nn","oc","or","pa","pl","pms","pt","rm","ro","ru","sa","sh-cyrl","sh-latn","sk","sl","sq","sr-cyrl","sv","ta","te","th","tk","tr","uk","zh-latn-pinyin"])
311
311
  class Y{constructor(t=0,e=0){this.x=t,this.y=e}set(t,e){return this.x=t,this.y=e,this}clone(){return new Y(this.x,this.y)}Ye(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}sub(t){return this.x-=t.x,this.y-=t.y,this}multiply(t){return this.x*=t,this.y*=t,this}Je(t){return this.x/=t,this.y/=t,this}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}Ke(){return this.x*this.x+this.y*this.y}normalize(){const t=this.length()
312
- return t>0&&this.Je(t),this}Xe(t){return this.x*t.x+this.y*t.y}Qe(t){const e=this.x-t.x,i=this.y-t.y
312
+ return t>0&&this.Je(t),this}Qe(t){return this.x*t.x+this.y*t.y}Xe(t){const e=this.x-t.x,i=this.y-t.y
313
313
  return Math.sqrt(e*e+i*i)}Ze(t){const e=this.x-t.x,i=this.y-t.y
314
314
  return e*e+i*i}equals(t){return this.x===t.x&&this.y===t.y}angle(){return Math.atan2(this.y,this.x)}}class J{constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.z=i}set(t,e,i){return this.x=t,this.y=e,this.z=i,this}clone(){return new J(this.x,this.y,this.z)}Ye(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}multiply(t){return this.x*=t,this.y*=t,this.z*=t,this}Je(t){return this.x/=t,this.y/=t,this.z/=t,this}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}Ke(){return this.x*this.x+this.y*this.y+this.z*this.z}normalize(){const t=this.length()
315
- return t>0&&this.Je(t),this}Xe(t){return this.x*t.x+this.y*t.y+this.z*t.z}ti(t){const e=this.z*t.x-this.x*t.z,i=this.x*t.y-this.y*t.x
316
- return this.x=this.y*t.z-this.z*t.y,this.y=e,this.z=i,this}Qe(t){const e=this.x-t.x,i=this.y-t.y,n=this.z-t.z
315
+ return t>0&&this.Je(t),this}Qe(t){return this.x*t.x+this.y*t.y+this.z*t.z}ti(t){const e=this.z*t.x-this.x*t.z,i=this.x*t.y-this.y*t.x
316
+ return this.x=this.y*t.z-this.z*t.y,this.y=e,this.z=i,this}Xe(t){const e=this.x-t.x,i=this.y-t.y,n=this.z-t.z
317
317
  return Math.sqrt(e*e+i*i+n*n)}Ze(t){const e=this.x-t.x,i=this.y-t.y,n=this.z-t.z
318
- return e*e+i*i+n*n}equals(t){return this.x===t.x&&this.y===t.y&&this.z===t.z}}class K{constructor(){this.cache=new Map}get(t){return this.cache.get(t)}has(t){return this.cache.has(t)}set(t,e){this.cache.set(t,e)}delete(t){return this.cache.delete(t)}clear(){this.cache.clear()}get size(){return this.cache.size}keys(){return Array.from(this.cache.keys())}getStats(){return{size:this.cache.size}}}const X=new K,Q=new K,Z=new K,tt=new K
318
+ return e*e+i*i+n*n}equals(t){return this.x===t.x&&this.y===t.y&&this.z===t.z}}class K{constructor(){this.cache=new Map}get(t){return this.cache.get(t)}has(t){return this.cache.has(t)}set(t,e){this.cache.set(t,e)}delete(t){return this.cache.delete(t)}clear(){this.cache.clear()}get size(){return this.cache.size}keys(){return Array.from(this.cache.keys())}getStats(){return{size:this.cache.size}}}const Q=new K,X=new K,Z=new K,tt=new K
319
319
  var et="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},it={exports:{}}
320
320
  !(function(t){function e(t,e){return t.b===e.b&&t.a===e.a}function i(t,e){return e.b>t.b||t.b===e.b&&e.a>=t.a}function n(t,e,i){var n=e.b-t.b,s=i.b-e.b
321
321
  return n+s>0?s>n?e.a-t.a+n/(n+s)*(t.a-i.a):e.a-i.a+s/(n+s)*(i.a-t.a):0}function s(t,e,i){var n=e.b-t.b,s=i.b-e.b
322
322
  return n+s>0?(e.a-i.a)*n+(e.a-t.a)*s:0}function r(t,e){return e.a>t.a||t.a===e.a&&e.b>=t.b}function o(t,e,i){var n=e.a-t.a,s=i.a-e.a
323
323
  return n+s>0?s>n?e.b-t.b+n/(n+s)*(t.b-i.b):e.b-i.b+s/(n+s)*(i.b-t.b):0}function a(t,e,i){var n=e.a-t.a,s=i.a-e.a
324
324
  return n+s>0?(e.b-i.b)*n+(e.b-t.b)*s:0}function h(t){return i(t.b.a,t.a)}function c(t){return i(t.a,t.b.a)}function l(t,e,i,n){return(t=0>t?0:t)>(i=0>i?0:i)?n+i/(t+i)*(e-n):0===i?(e+n)/2:e+t/(t+i)*(n-e)}function u(t){var e=w(t.b)
325
- return m(e,t.c),m(e.b,t.c),v(e,t.a),e}function f(t,e){var i=!1,n=!1
326
- t!==e&&(e.a!==t.a&&(n=!0,b(e.a,t.a)),e.d!==t.d&&(i=!0,S(e.d,t.d)),g(e,t),n||(m(e,t.a),t.a.c=t),i||(v(e,t.d),t.d.a=t))}function d(t){var e=t.b,i=!1
327
- t.d!==t.b.d&&(i=!0,S(t.d,t.b.d)),t.c===t?b(t.a,null):(t.b.d.a=K(t),t.a.c=t.c,g(t,K(t)),i||v(t,t.d)),e.c===e?(b(e.a,null),S(e.d,null)):(t.d.a=K(e),e.a.c=e.c,g(e,K(e))),x(t)}function y(t){var e=w(t),i=e.b
328
- return g(e,t.e),e.a=t.b.a,m(i,e.a),e.d=i.d=t.d,e=e.b,g(t.b,K(t.b)),g(t.b,e),t.b.a=e.a,e.b.a.c=e.b,e.b.d=t.b.d,e.f=t.f,e.b.f=t.b.f,e}function p(t,e){var i=!1,n=w(t),s=n.b
329
- return e.d!==t.d&&(i=!0,S(e.d,t.d)),g(n,t.e),g(s,e),n.a=t.b.a,s.a=e.a,n.d=s.d=t.d,t.d.a=s,i||v(n,t.d),n}function w(t){var e=new J,i=new J,n=t.b.ei
325
+ return v(e,t.c),v(e.b,t.c),m(e,t.a),e}function f(t,e){var i=!1,n=!1
326
+ t!==e&&(e.a!==t.a&&(n=!0,S(e.a,t.a)),e.d!==t.d&&(i=!0,b(e.d,t.d)),g(e,t),n||(v(e,t.a),t.a.c=t),i||(m(e,t.d),t.d.a=t))}function d(t){var e=t.b,i=!1
327
+ t.d!==t.b.d&&(i=!0,b(t.d,t.b.d)),t.c===t?S(t.a,null):(t.b.d.a=K(t),t.a.c=t.c,g(t,K(t)),i||m(t,t.d)),e.c===e?(S(e.a,null),b(e.d,null)):(t.d.a=K(e),e.a.c=e.c,g(e,K(e))),x(t)}function p(t){var e=w(t),i=e.b
328
+ return g(e,t.e),e.a=t.b.a,v(i,e.a),e.d=i.d=t.d,e=e.b,g(t.b,K(t.b)),g(t.b,e),t.b.a=e.a,e.b.a.c=e.b,e.b.d=t.b.d,e.f=t.f,e.b.f=t.b.f,e}function y(t,e){var i=!1,n=w(t),s=n.b
329
+ return e.d!==t.d&&(i=!0,b(e.d,t.d)),g(n,t.e),g(s,e),n.a=t.b.a,s.a=e.a,n.d=s.d=t.d,t.d.a=s,i||m(n,t.d),n}function w(t){var e=new J,i=new J,n=t.b.ei
330
330
  return i.ei=n,n.b.ei=e,e.ei=t,t.b.ei=i,e.b=i,e.c=e,e.e=i,i.b=e,i.c=i,i.e=e}function g(t,e){var i=t.c,n=e.c
331
- i.b.e=e,n.b.e=t,t.c=n,e.c=i}function m(t,e){var i=e.f,n=new Q(e,i)
331
+ i.b.e=e,n.b.e=t,t.c=n,e.c=i}function v(t,e){var i=e.f,n=new X(e,i)
332
332
  i.e=n,e.f=n,i=n.c=t
333
- do{i.a=n,i=i.c}while(i!==t)}function v(t,e){var i=e.d,n=new Y(e,i)
333
+ do{i.a=n,i=i.c}while(i!==t)}function m(t,e){var i=e.d,n=new Y(e,i)
334
334
  i.b=n,e.d=n,n.a=t,n.c=e.c,i=t
335
335
  do{i.d=n,i=i.e}while(i!==t)}function x(t){var e=t.ei
336
- e.b.ei=t=t.b.ei,t.b.ei=e}function b(t,e){var i=t.c,n=i
337
- do{n.a=e,n=n.c}while(n!==i);(n=t.e).f=i=t.f,i.e=n}function S(t,e){var i=t.a,n=i
336
+ e.b.ei=t=t.b.ei,t.b.ei=e}function S(t,e){var i=t.c,n=i
337
+ do{n.a=e,n=n.c}while(n!==i);(n=t.e).f=i=t.f,i.e=n}function b(t,e){var i=t.a,n=i
338
338
  do{n.d=e,n=n.e}while(n!==i);(n=t.b).d=i=t.d,i.b=n}function _(t){var e=0
339
339
  return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e}function E(t,e){t.f+=e.f,t.b.f+=e.b.f}function T(t,e,r){return r=r.a,(e=e.a).b.a===(t=t.a)?r.b.a===t?i(e.a,r.a)?0>=s(r.b.a,e.a,r.a):s(e.b.a,r.a,e.a)>=0:0>=s(r.b.a,t,r.a):r.b.a===t?s(e.b.a,t,e.a)>=0:(e=n(e.b.a,t,e.a))>=(t=n(r.b.a,t,r.a))}function A(t){t.a.ii=null
340
340
  var e=t.e
341
341
  e.a.c=e.c,e.c.a=e.a,t.e=null}function I(t,e){d(t.a),t.c=!1,t.a=e,e.ii=t}function M(t){var e=t.a.a
342
342
  do{t=ut(t)}while(t.a.a===e)
343
- return t.c&&(I(t,e=p(lt(t).a.b,t.a.e)),t=ut(t)),t}function L(t,e,i){var n=new ct
344
- return n.a=i,n.e=z(t.f,e.e,n),i.ii=n}function F(t,e){switch(t.s){case 100130:return!!(1&e)
343
+ return t.c&&(I(t,e=y(lt(t).a.b,t.a.e)),t=ut(t)),t}function L(t,e,i){var n=new ct
344
+ return n.a=i,n.e=j(t.f,e.e,n),i.ii=n}function F(t,e){switch(t.s){case 100130:return!!(1&e)
345
345
  case 100131:return 0!==e
346
346
  case 100132:return e>0
347
347
  case 100133:return 0>e
@@ -349,50 +349,50 @@ case 100134:return e>=2||-2>=e}return!1}function G(t){var e=t.a,i=e.d
349
349
  i.c=t.d,i.a=e,A(t)}function O(t,e,i){for(t=e,e=e.a;t!==i;){t.c=!1
350
350
  var n=lt(t),s=n.a
351
351
  if(s.a!==e.a){if(!n.c){G(t)
352
- break}I(n,s=p(e.c.b,s.b))}e.c!==s&&(f(K(s),s),f(e,s)),G(t),e=n.a,t=n}return e}function C(t,e,i,n,s,r){var o=!0
352
+ break}I(n,s=y(e.c.b,s.b))}e.c!==s&&(f(K(s),s),f(e,s)),G(t),e=n.a,t=n}return e}function C(t,e,i,n,s,r){var o=!0
353
353
  do{L(t,e,i.b),i=i.c}while(i!==n)
354
- for(null===s&&(s=lt(e).a.b.c);(i=(n=lt(e)).a.b).a===s.a;)i.c!==s&&(f(K(i),i),f(K(s),i)),n.f=e.f-i.f,n.d=F(t,n.f),e.b=!0,!o&&U(t,e)&&(E(i,s),A(e),d(s)),o=!1,e=n,s=i
355
- e.b=!0,r&&P(t,e)}function k(t,e,i,n,s){var r=[e.g[0],e.g[1],e.g[2]]
356
- e.d=null,e.d=t.ni&&t.ni(r,i,n,t.c)||null,null===e.d&&(s?t.n||(q(t,100156),t.n=!0):e.d=i[0])}function B(t,e,i){var n=[null,null,null,null]
357
- n[0]=e.a.d,n[1]=i.a.d,k(t,e.a,n,[.5,.5,0,0],!1),f(e,i)}function D(t,e,i,n,s){var r=Math.abs(e.b-t.b)+Math.abs(e.a-t.a),o=Math.abs(i.b-t.b)+Math.abs(i.a-t.a),a=s+1
358
- n[s]=.5*o/(r+o),n[a]=.5*r/(r+o),t.g[0]+=n[s]*e.g[0]+n[a]*i.g[0],t.g[1]+=n[s]*e.g[1]+n[a]*i.g[1],t.g[2]+=n[s]*e.g[2]+n[a]*i.g[2]}function U(t,n){var r=lt(n),o=n.a,a=r.a
354
+ for(null===s&&(s=lt(e).a.b.c);(i=(n=lt(e)).a.b).a===s.a;)i.c!==s&&(f(K(i),i),f(K(s),i)),n.f=e.f-i.f,n.d=F(t,n.f),e.b=!0,!o&&B(t,e)&&(E(i,s),A(e),d(s)),o=!1,e=n,s=i
355
+ e.b=!0,r&&$(t,e)}function k(t,e,i,n,s){var r=[e.g[0],e.g[1],e.g[2]]
356
+ e.d=null,e.d=t.ni&&t.ni(r,i,n,t.c)||null,null===e.d&&(s?t.n||(q(t,100156),t.n=!0):e.d=i[0])}function D(t,e,i){var n=[null,null,null,null]
357
+ n[0]=e.a.d,n[1]=i.a.d,k(t,e.a,n,[.5,.5,0,0],!1),f(e,i)}function U(t,e,i,n,s){var r=Math.abs(e.b-t.b)+Math.abs(e.a-t.a),o=Math.abs(i.b-t.b)+Math.abs(i.a-t.a),a=s+1
358
+ n[s]=.5*o/(r+o),n[a]=.5*r/(r+o),t.g[0]+=n[s]*e.g[0]+n[a]*i.g[0],t.g[1]+=n[s]*e.g[1]+n[a]*i.g[1],t.g[2]+=n[s]*e.g[2]+n[a]*i.g[2]}function B(t,n){var r=lt(n),o=n.a,a=r.a
359
359
  if(i(o.a,a.a)){if(s(a.b.a,o.a,a.a)>0)return!1
360
360
  if(e(o.a,a.a)){if(o.a!==a.a){r=t.e
361
361
  var h=o.a.ei
362
362
  if(0>h)for(r.c[-(h+1)]=null;r.a>0&&null===r.c[r.d[r.a-1]];)--r.a
363
363
  else{var c=(r=r.b).d,l=r.e,u=r.c,d=u[h]
364
- c[d]=c[r.a],u[c[d]]=d,d<=--r.a&&(d>1?i(l[c[d>>1]],l[c[d]])?at(r,d):ht(r,d):at(r,d)),l[h]=null,u[h]=r.b,r.b=h}B(t,K(a),o)}}else y(a.b),f(o,K(a)),n.b=r.b=!0}else{if(0>s(o.b.a,a.a,o.a))return!1
365
- ut(n).b=n.b=!0,y(o.b),f(K(a),o)}return!0}function $(t,h){var c=lt(h),u=h.a,d=c.a,p=u.a,w=d.a,g=u.b.a,m=d.b.a,v=new Q
366
- if(s(g,t.a,p),s(m,t.a,w),p===w||Math.min(p.a,g.a)>Math.max(w.a,m.a))return!1
367
- if(i(p,w)){if(s(m,p,w)>0)return!1}else if(0>s(g,w,p))return!1
368
- var x,b,S=g,_=p,E=m,T=w
369
- if(i(S,_)||(x=S,S=_,_=x),i(E,T)||(x=E,E=T,T=x),i(S,E)||(x=S,S=E,E=x,x=_,_=T,T=x),i(E,_)?i(_,T)?(0>(x=n(S,E,_))+(b=n(E,_,T))&&(x=-x,b=-b),v.b=l(x,E.b,b,_.b)):(0>(x=s(S,E,_))+(b=-s(S,T,_))&&(x=-x,b=-b),v.b=l(x,E.b,b,T.b)):v.b=(E.b+_.b)/2,r(S,_)||(x=S,S=_,_=x),r(E,T)||(x=E,E=T,T=x),r(S,E)||(x=S,S=E,E=x,x=_,_=T,T=x),r(E,_)?r(_,T)?(0>(x=o(S,E,_))+(b=o(E,_,T))&&(x=-x,b=-b),v.a=l(x,E.a,b,_.a)):(0>(x=a(S,E,_))+(b=-a(S,T,_))&&(x=-x,b=-b),v.a=l(x,E.a,b,T.a)):v.a=(E.a+_.a)/2,i(v,t.a)&&(v.b=t.a.b,v.a=t.a.a),S=i(p,w)?p:w,i(S,v)&&(v.b=S.b,v.a=S.a),e(v,p)||e(v,w))return U(t,h),!1
370
- if(!e(g,t.a)&&s(g,t.a,v)>=0||!e(m,t.a)&&0>=s(m,t.a,v)){if(m===t.a)return y(u.b),f(d.b,u),u=lt(h=M(h)).a,O(t,lt(h),c),C(t,h,K(u),u,u,!0),!0
371
- if(g===t.a){y(d.b),f(u.e,K(d)),w=(p=c=h).a.b.a
372
- do{p=ut(p)}while(p.a.b.a===w)
373
- return p=lt(h=p).a.b.c,c.a=K(d),C(t,h,(d=O(t,c,null)).c,u.b.c,p,!0),!0}return s(g,t.a,v)>=0&&(ut(h).b=h.b=!0,y(u.b),u.a.b=t.a.b,u.a.a=t.a.a),0>=s(m,t.a,v)&&(h.b=c.b=!0,y(d.b),d.a.b=t.a.b,d.a.a=t.a.a),!1}return y(u.b),y(d.b),f(K(d),u),u.a.b=v.b,u.a.a=v.a,u.a.ei=tt(t.e,u.a),d=[0,0,0,0],v=[p.d,g.d,w.d,m.d],(u=u.a).g[0]=u.g[1]=u.g[2]=0,D(u,p,g,d,0),D(u,w,m,d,2),k(t,u,v,d,!0),ut(h).b=h.b=c.b=!0,!1}function P(t,e){for(var n=lt(e);;){for(;n.b;)e=n,n=lt(n)
364
+ c[d]=c[r.a],u[c[d]]=d,d<=--r.a&&(d>1?i(l[c[d>>1]],l[c[d]])?at(r,d):ht(r,d):at(r,d)),l[h]=null,u[h]=r.b,r.b=h}D(t,K(a),o)}}else p(a.b),f(o,K(a)),n.b=r.b=!0}else{if(0>s(o.b.a,a.a,o.a))return!1
365
+ ut(n).b=n.b=!0,p(o.b),f(K(a),o)}return!0}function N(t,h){var c=lt(h),u=h.a,d=c.a,y=u.a,w=d.a,g=u.b.a,v=d.b.a,m=new X
366
+ if(s(g,t.a,y),s(v,t.a,w),y===w||Math.min(y.a,g.a)>Math.max(w.a,v.a))return!1
367
+ if(i(y,w)){if(s(v,y,w)>0)return!1}else if(0>s(g,w,y))return!1
368
+ var x,S,b=g,_=y,E=v,T=w
369
+ if(i(b,_)||(x=b,b=_,_=x),i(E,T)||(x=E,E=T,T=x),i(b,E)||(x=b,b=E,E=x,x=_,_=T,T=x),i(E,_)?i(_,T)?(0>(x=n(b,E,_))+(S=n(E,_,T))&&(x=-x,S=-S),m.b=l(x,E.b,S,_.b)):(0>(x=s(b,E,_))+(S=-s(b,T,_))&&(x=-x,S=-S),m.b=l(x,E.b,S,T.b)):m.b=(E.b+_.b)/2,r(b,_)||(x=b,b=_,_=x),r(E,T)||(x=E,E=T,T=x),r(b,E)||(x=b,b=E,E=x,x=_,_=T,T=x),r(E,_)?r(_,T)?(0>(x=o(b,E,_))+(S=o(E,_,T))&&(x=-x,S=-S),m.a=l(x,E.a,S,_.a)):(0>(x=a(b,E,_))+(S=-a(b,T,_))&&(x=-x,S=-S),m.a=l(x,E.a,S,T.a)):m.a=(E.a+_.a)/2,i(m,t.a)&&(m.b=t.a.b,m.a=t.a.a),b=i(y,w)?y:w,i(b,m)&&(m.b=b.b,m.a=b.a),e(m,y)||e(m,w))return B(t,h),!1
370
+ if(!e(g,t.a)&&s(g,t.a,m)>=0||!e(v,t.a)&&0>=s(v,t.a,m)){if(v===t.a)return p(u.b),f(d.b,u),u=lt(h=M(h)).a,O(t,lt(h),c),C(t,h,K(u),u,u,!0),!0
371
+ if(g===t.a){p(d.b),f(u.e,K(d)),w=(y=c=h).a.b.a
372
+ do{y=ut(y)}while(y.a.b.a===w)
373
+ return y=lt(h=y).a.b.c,c.a=K(d),C(t,h,(d=O(t,c,null)).c,u.b.c,y,!0),!0}return s(g,t.a,m)>=0&&(ut(h).b=h.b=!0,p(u.b),u.a.b=t.a.b,u.a.a=t.a.a),0>=s(v,t.a,m)&&(h.b=c.b=!0,p(d.b),d.a.b=t.a.b,d.a.a=t.a.a),!1}return p(u.b),p(d.b),f(K(d),u),u.a.b=m.b,u.a.a=m.a,u.a.ei=tt(t.e,u.a),d=[0,0,0,0],m=[y.d,g.d,w.d,v.d],(u=u.a).g[0]=u.g[1]=u.g[2]=0,U(u,y,g,d,0),U(u,w,v,d,2),k(t,u,m,d,!0),ut(h).b=h.b=c.b=!0,!1}function $(t,e){for(var n=lt(e);;){for(;n.b;)e=n,n=lt(n)
374
374
  if(!e.b&&(n=e,null===(e=ut(e))||!e.b))break
375
375
  e.b=!1
376
376
  var r,o=e.a,a=n.a
377
377
  if(r=o.b.a!==a.b.a)t:{var h=lt(r=e),c=r.a,l=h.a,u=void 0
378
378
  if(i(c.b.a,l.b.a)){if(0>s(c.b.a,l.b.a,c.a)){r=!1
379
- break t}ut(r).b=r.b=!0,u=y(c),f(l.b,u),u.d.c=r.d}else{if(s(l.b.a,c.b.a,l.a)>0){r=!1
380
- break t}r.b=h.b=!0,u=y(l),f(c.e,l.b),u.b.d.c=r.d}r=!0}if(r&&(n.c?(A(n),d(a),a=(n=lt(e)).a):e.c&&(A(e),d(o),o=(e=ut(n)).a)),o.a!==a.a)if(o.b.a===a.b.a||e.c||n.c||o.b.a!==t.a&&a.b.a!==t.a)U(t,e)
381
- else if($(t,e))break
382
- o.a===a.a&&o.b.a===a.b.a&&(E(a,o),A(e),d(o),e=ut(n))}}function N(t,n){t.a=n
379
+ break t}ut(r).b=r.b=!0,u=p(c),f(l.b,u),u.d.c=r.d}else{if(s(l.b.a,c.b.a,l.a)>0){r=!1
380
+ break t}r.b=h.b=!0,u=p(l),f(c.e,l.b),u.b.d.c=r.d}r=!0}if(r&&(n.c?(A(n),d(a),a=(n=lt(e)).a):e.c&&(A(e),d(o),o=(e=ut(n)).a)),o.a!==a.a)if(o.b.a===a.b.a||e.c||n.c||o.b.a!==t.a&&a.b.a!==t.a)B(t,e)
381
+ else if(N(t,e))break
382
+ o.a===a.a&&o.b.a===a.b.a&&(E(a,o),A(e),d(o),e=ut(n))}}function P(t,n){t.a=n
383
383
  for(var r=n.c;null===r.ii;)if((r=r.c)===n.c){r=t
384
384
  var o=n;(u=new ct).a=o.c.b
385
385
  var a=(l=r.f).a
386
386
  do{a=a.a}while(null!==a.b&&!l.c(l.b,u,a.b))
387
- if(a=(c=lt(l=a.b)).a,0===s((u=l.a).b.a,o,u.a))e((u=l.a).a,o)||e(u.b.a,o)||(y(u.b),l.c&&(d(u.c),l.c=!1),f(o.c,u),N(r,o))
387
+ if(a=(c=lt(l=a.b)).a,0===s((u=l.a).b.a,o,u.a))e((u=l.a).a,o)||e(u.b.a,o)||(p(u.b),l.c&&(d(u.c),l.c=!1),f(o.c,u),P(r,o))
388
388
  else{var h=i(a.b.a,u.b.a)?l:c,c=void 0
389
- l.d||h.c?(c=h===l?p(o.c.b,u.e):p(a.b.c.b,o.c).b,h.c?I(h,c):(u=r,(l=L(r,l,c)).f=ut(l).f+l.a.f,l.d=F(u,l.f)),N(r,o)):C(r,l,o.c,o.c,null,!0)}return}if(l=(u=lt(r=M(r.ii))).a,(u=O(t,u,null)).c===l){var l,u=(l=u).c,w=(a=lt(r),!1);(c=r.a).b.a!==(h=a.a).b.a&&$(t,r),e(c.a,t.a)&&(f(K(u),c),u=lt(r=M(r)).a,O(t,lt(r),a),w=!0),e(h.a,t.a)&&(f(l,K(h)),l=O(t,a,null),w=!0),w?C(t,r,l.c,u,u,!0):(o=i(h.a,c.a)?K(h):c,C(t,r,o=p(l.c.b,o),o.c,o.c,!1),o.b.ii.c=!0,P(t,r))}else C(t,r,u.c,l,l,!0)}function R(t,e){var i=new ct,n=u(t.b)
390
- n.a.b=dt,n.a.a=e,n.b.a.b=-dt,n.b.a.a=e,t.a=n.b.a,i.a=n,i.f=0,i.d=!1,i.c=!1,i.ei=!0,i.b=!1,n=z(n=t.f,n.a,i),i.e=n}function j(t){this.a=new W,this.b=t,this.c=T}function z(t,e,i){do{e=e.c}while(null!==e.b&&!t.c(t.b,e.b,i))
391
- return t=new W(i,e.a,e),e.a.c=t,e.a=t}function W(t,e,i){this.b=t||null,this.a=e||this,this.c=i||this}function H(){this.d=yt,this.si=this.b=this.ri=null,this.oi=[0,0,0],this.s=100130,this.n=!1,this.ni=this.a=this.e=this.f=null,this.ai=!1,this.c=this.r=this.ii=this.hi=this.ci=this.ei=null}function V(t,e){if(t.d!==e)for(;t.d!==e;)if(e>t.d)switch(t.d){case yt:q(t,100151),t.li(null)
389
+ l.d||h.c?(c=h===l?y(o.c.b,u.e):y(a.b.c.b,o.c).b,h.c?I(h,c):(u=r,(l=L(r,l,c)).f=ut(l).f+l.a.f,l.d=F(u,l.f)),P(r,o)):C(r,l,o.c,o.c,null,!0)}return}if(l=(u=lt(r=M(r.ii))).a,(u=O(t,u,null)).c===l){var l,u=(l=u).c,w=(a=lt(r),!1);(c=r.a).b.a!==(h=a.a).b.a&&N(t,r),e(c.a,t.a)&&(f(K(u),c),u=lt(r=M(r)).a,O(t,lt(r),a),w=!0),e(h.a,t.a)&&(f(l,K(h)),l=O(t,a,null),w=!0),w?C(t,r,l.c,u,u,!0):(o=i(h.a,c.a)?K(h):c,C(t,r,o=y(l.c.b,o),o.c,o.c,!1),o.b.ii.c=!0,$(t,r))}else C(t,r,u.c,l,l,!0)}function R(t,e){var i=new ct,n=u(t.b)
390
+ n.a.b=dt,n.a.a=e,n.b.a.b=-dt,n.b.a.a=e,t.a=n.b.a,i.a=n,i.f=0,i.d=!1,i.c=!1,i.ei=!0,i.b=!1,n=j(n=t.f,n.a,i),i.e=n}function z(t){this.a=new W,this.b=t,this.c=T}function j(t,e,i){do{e=e.c}while(null!==e.b&&!t.c(t.b,e.b,i))
391
+ return t=new W(i,e.a,e),e.a.c=t,e.a=t}function W(t,e,i){this.b=t||null,this.a=e||this,this.c=i||this}function H(){this.d=pt,this.si=this.b=this.ri=null,this.oi=[0,0,0],this.s=100130,this.n=!1,this.ni=this.a=this.e=this.f=null,this.ai=!1,this.c=this.r=this.ii=this.hi=this.ci=this.ei=null}function V(t,e){if(t.d!==e)for(;t.d!==e;)if(e>t.d)switch(t.d){case pt:q(t,100151),t.li(null)
392
392
  break
393
393
  case 1:q(t,100152),t.ui()}else switch(t.d){case 2:q(t,100154),t.fi()
394
394
  break
395
- case 1:q(t,100153),t.w()}}function q(t,e){t.si&&t.si(e,t.c)}function Y(t,e){this.b=t||this,this.d=e||this,this.a=null,this.c=!1}function J(){this.ei=this,this.ii=this.d=this.a=this.e=this.c=this.b=null,this.f=0}function K(t){return t.b.e}function X(){this.c=new Q,this.a=new Y,this.b=new J,this.d=new J,this.b.b=this.d,this.d.b=this.b}function Q(t,e){this.e=t||this,this.f=e||this,this.d=this.c=null,this.g=[0,0,0],this.ei=this.a=this.b=0}function Z(){this.c=[],this.d=null,this.a=0,this.e=!1,this.b=new nt}function tt(t,e){if(t.e){var i,n=t.b,s=++n.a
395
+ case 1:q(t,100153),t.w()}}function q(t,e){t.si&&t.si(e,t.c)}function Y(t,e){this.b=t||this,this.d=e||this,this.a=null,this.c=!1}function J(){this.ei=this,this.ii=this.d=this.a=this.e=this.c=this.b=null,this.f=0}function K(t){return t.b.e}function Q(){this.c=new X,this.a=new Y,this.b=new J,this.d=new J,this.b.b=this.d,this.d.b=this.b}function X(t,e){this.e=t||this,this.f=e||this,this.d=this.c=null,this.g=[0,0,0],this.ei=this.a=this.b=0}function Z(){this.c=[],this.d=null,this.a=0,this.e=!1,this.b=new nt}function tt(t,e){if(t.e){var i,n=t.b,s=++n.a
396
396
  return 2*s>n.f&&(n.f*=2,n.c=st(n.c,n.f+1)),0===n.b?i=s:(i=n.b,n.b=n.c[n.b]),n.e[i]=e,n.c[i]=s,n.d[s]=i,n.ei&&ht(n,s),i}return n=t.a++,t.c[n]=e,-(n+1)}function it(t){if(0===t.a)return ot(t.b)
397
397
  var e=t.c[t.d[t.a-1]]
398
398
  if(0!==t.b.a&&i(rt(t.b),e))return ot(t.b)
@@ -406,7 +406,7 @@ var c=n[h]
406
406
  if(h>t.a||i(s[a],s[c])){n[o]=a,r[a]=o
407
407
  break}n[o]=c,r[c]=o,o=h}}function ht(t,e){for(var n=t.d,s=t.e,r=t.c,o=e,a=n[o];;){var h=o>>1,c=n[h]
408
408
  if(0===h||i(s[c],s[a])){n[o]=a,r[a]=o
409
- break}n[o]=c,r[c]=o,o=h}}function ct(){this.e=this.a=null,this.f=0,this.c=this.b=this.ei=this.d=!1}function lt(t){return t.e.c.b}function ut(t){return t.e.a.b}var ft,dt=4e150,yt=0;(ft=H.prototype).x=function(){V(this,yt)},ft.B=function(t,e){switch(t){case 100142:return
409
+ break}n[o]=c,r[c]=o,o=h}}function ct(){this.e=this.a=null,this.f=0,this.c=this.b=this.ei=this.d=!1}function lt(t){return t.e.c.b}function ut(t){return t.e.a.b}var ft,dt=4e150,pt=0;(ft=H.prototype).x=function(){V(this,pt)},ft.B=function(t,e){switch(t){case 100142:return
410
410
  case 100140:switch(e){case 100130:case 100131:case 100132:case 100133:case 100134:return void(this.s=e)}break
411
411
  case 100141:return void(this.ai=!!e)
412
412
  default:return void q(this,100900)}q(this,100901)},ft.y=function(t){switch(t){case 100142:return 0
@@ -429,32 +429,32 @@ case 100112:this.r=i
429
429
  break
430
430
  default:q(this,100900)}},ft.C=function(t,e){var i=!1,n=[0,0,0]
431
431
  V(this,2)
432
- for(var s=0;3>s;++s){var r=t[s];-1e150>r&&(r=-1e150,i=!0),r>1e150&&(r=1e150,i=!0),n[s]=r}i&&q(this,100155),null===(i=this.ri)?f(i=u(this.b),i.b):(y(i),i=i.e),i.a.d=e,i.a.g[0]=n[0],i.a.g[1]=n[1],i.a.g[2]=n[2],i.f=1,i.b.f=-1,this.ri=i},ft.li=function(t){V(this,yt),this.d=1,this.b=new X,this.c=t},ft.ui=function(){V(this,1),this.d=2,this.ri=null},ft.fi=function(){V(this,2),this.d=1},ft.w=function(){V(this,1),this.d=yt
432
+ for(var s=0;3>s;++s){var r=t[s];-1e150>r&&(r=-1e150,i=!0),r>1e150&&(r=1e150,i=!0),n[s]=r}i&&q(this,100155),null===(i=this.ri)?f(i=u(this.b),i.b):(p(i),i=i.e),i.a.d=e,i.a.g[0]=n[0],i.a.g[1]=n[1],i.a.g[2]=n[2],i.f=1,i.b.f=-1,this.ri=i},ft.li=function(t){V(this,pt),this.d=1,this.b=new Q,this.c=t},ft.ui=function(){V(this,1),this.d=2,this.ri=null},ft.fi=function(){V(this,2),this.d=1},ft.w=function(){V(this,1),this.d=pt
433
433
  var t=!1,n=[u=this.oi[0],r=this.oi[1],a=this.oi[2]]
434
- if(0===u&&0===r&&0===a){for(var r=[-2e150,-2e150,-2e150],o=[2e150,2e150,2e150],a=[],l=[],u=(t=this.b.c).e;u!==t;u=u.e)for(var f=0;3>f;++f){var y=u.g[f]
435
- o[f]>y&&(o[f]=y,l[f]=u),y>r[f]&&(r[f]=y,a[f]=u)}if(u=0,r[1]-o[1]>r[0]-o[0]&&(u=1),r[2]-o[2]>r[u]-o[u]&&(u=2),r[u]>o[u]){for(r=0,o=l[u],l=[0,0,0],o=[o.g[0]-(a=a[u]).g[0],o.g[1]-a.g[1],o.g[2]-a.g[2]],f=[0,0,0],u=t.e;u!==t;u=u.e)f[0]=u.g[0]-a.g[0],f[1]=u.g[1]-a.g[1],f[2]=u.g[2]-a.g[2],l[0]=o[1]*f[2]-o[2]*f[1],l[1]=o[2]*f[0]-o[0]*f[2],l[2]=o[0]*f[1]-o[1]*f[0],(y=l[0]*l[0]+l[1]*l[1]+l[2]*l[2])>r&&(r=y,n[0]=l[0],n[1]=l[1],n[2]=l[2])
434
+ if(0===u&&0===r&&0===a){for(var r=[-2e150,-2e150,-2e150],o=[2e150,2e150,2e150],a=[],l=[],u=(t=this.b.c).e;u!==t;u=u.e)for(var f=0;3>f;++f){var p=u.g[f]
435
+ o[f]>p&&(o[f]=p,l[f]=u),p>r[f]&&(r[f]=p,a[f]=u)}if(u=0,r[1]-o[1]>r[0]-o[0]&&(u=1),r[2]-o[2]>r[u]-o[u]&&(u=2),r[u]>o[u]){for(r=0,o=l[u],l=[0,0,0],o=[o.g[0]-(a=a[u]).g[0],o.g[1]-a.g[1],o.g[2]-a.g[2]],f=[0,0,0],u=t.e;u!==t;u=u.e)f[0]=u.g[0]-a.g[0],f[1]=u.g[1]-a.g[1],f[2]=u.g[2]-a.g[2],l[0]=o[1]*f[2]-o[2]*f[1],l[1]=o[2]*f[0]-o[0]*f[2],l[2]=o[0]*f[1]-o[1]*f[0],(p=l[0]*l[0]+l[1]*l[1]+l[2]*l[2])>r&&(r=p,n[0]=l[0],n[1]=l[1],n[2]=l[2])
436
436
  0>=r&&(n[0]=n[1]=n[2]=0,n[_(o)]=1)}else n[0]=0,n[1]=0,n[2]=1
437
437
  t=!0}for(r=((l=_(n))+1)%3,a=(l+2)%3,l=n[l]>0?1:-1,n=(u=this.b.c).e;n!==u;n=n.e)n.b=n.g[r],n.a=l*n.g[a]
438
438
  if(t){for(n=0,u=(t=this.b.a).b;u!==t;u=u.b)if((r=u.a).f>0)do{n+=(r.a.b-r.b.a.b)*(r.a.a+r.b.a.a),r=r.e}while(r!==u.a)
439
- if(0>n)for(t=(n=this.b.c).e;t!==n;t=t.e)t.a=-t.a}for(this.n=!1,u=(n=this.b.b).ei;u!==n;u=t)t=u.ei,r=u.e,e(u.a,u.b.a)&&u.e.e!==u&&(B(this,r,u),d(u),r=(u=r).e),r.e===u&&(r!==u&&(r!==t&&r!==t.b||(t=t.ei),d(r)),u!==t&&u!==t.b||(t=t.ei),d(u))
439
+ if(0>n)for(t=(n=this.b.c).e;t!==n;t=t.e)t.a=-t.a}for(this.n=!1,u=(n=this.b.b).ei;u!==n;u=t)t=u.ei,r=u.e,e(u.a,u.b.a)&&u.e.e!==u&&(D(this,r,u),d(u),r=(u=r).e),r.e===u&&(r!==u&&(r!==t&&r!==t.b||(t=t.ei),d(r)),u!==t&&u!==t.b||(t=t.ei),d(u))
440
440
  for(this.e=n=new Z,u=(t=this.b.c).e;u!==t;u=u.e)u.ei=tt(n,u)
441
441
  for((t=>{t.d=[]
442
442
  for(var e=0;t.a>e;e++)t.d[e]=e
443
443
  t.d.sort((t=>(e,n)=>i(t[e],t[n])?1:-1)(t.c)),t.e=!0,(t=>{for(var e=t.a;e>=1;--e)at(t,e)
444
- t.ei=!0})(t.b)})(n),this.f=new j(this),R(this,-dt),R(this,dt);null!==(n=it(this.e));){for(;;){t:if(u=this.e,0===u.a)t=rt(u.b)
444
+ t.ei=!0})(t.b)})(n),this.f=new z(this),R(this,-dt),R(this,dt);null!==(n=it(this.e));){for(;;){t:if(u=this.e,0===u.a)t=rt(u.b)
445
445
  else if(t=u.c[u.d[u.a-1]],0!==u.b.a&&(u=rt(u.b),i(u,t))){t=u
446
446
  break t}if(null===t||!e(t,n))break
447
- t=it(this.e),B(this,n.c,t.c)}N(this,n)}for(this.a=this.f.a.a.b.a.a,n=0;null!==(t=this.f.a.a.b);)t.ei||++n,A(t)
447
+ t=it(this.e),D(this,n.c,t.c)}P(this,n)}for(this.a=this.f.a.a.b.a.a,n=0;null!==(t=this.f.a.a.b);)t.ei||++n,A(t)
448
448
  for(this.f=null,(n=this.e).b=null,n.d=null,this.e=n.c=null,u=(n=this.b).a.b;u!==n.a;u=t)t=u.b,(u=u.a).e.e===u&&(E(u.c,u),d(u))
449
449
  if(!this.n){if(n=this.b,this.ai)for(u=n.b.ei;u!==n.b;u=t)t=u.ei,u.b.d.c!==u.d.c?u.f=u.d.c?1:-1:d(u)
450
- else for(u=n.a.b;u!==n.a;u=t)if(t=u.b,u.c){for(u=u.a;i(u.b.a,u.a);u=u.c.b);for(;i(u.a,u.b.a);u=u.e);for(r=u.c.b,a=void 0;u.e!==r;)if(i(u.b.a,r.a)){for(;r.e!==u&&(h(r.e)||0>=s(r.a,r.b.a,r.e.b.a));)r=(a=p(r.e,r)).b
451
- r=r.c.b}else{for(;r.e!==u&&(c(u.c.b)||s(u.b.a,u.a,u.c.b.a)>=0);)u=(a=p(u,u.c.b)).b
452
- u=u.e}for(;r.e.e!==u;)r=(a=p(r.e,r)).b}if(this.ei||this.ii||this.hi||this.ci)if(this.ai){for(t=(n=this.b).a.b;t!==n.a;t=t.b)if(t.c){this.ei&&this.ei(2,this.c),u=t.a
450
+ else for(u=n.a.b;u!==n.a;u=t)if(t=u.b,u.c){for(u=u.a;i(u.b.a,u.a);u=u.c.b);for(;i(u.a,u.b.a);u=u.e);for(r=u.c.b,a=void 0;u.e!==r;)if(i(u.b.a,r.a)){for(;r.e!==u&&(h(r.e)||0>=s(r.a,r.b.a,r.e.b.a));)r=(a=y(r.e,r)).b
451
+ r=r.c.b}else{for(;r.e!==u&&(c(u.c.b)||s(u.b.a,u.a,u.c.b.a)>=0);)u=(a=y(u,u.c.b)).b
452
+ u=u.e}for(;r.e.e!==u;)r=(a=y(r.e,r)).b}if(this.ei||this.ii||this.hi||this.ci)if(this.ai){for(t=(n=this.b).a.b;t!==n.a;t=t.b)if(t.c){this.ei&&this.ei(2,this.c),u=t.a
453
453
  do{this.hi&&this.hi(u.a.d,this.c),u=u.e}while(u!==t.a)
454
454
  this.ii&&this.ii(this.c)}}else{for(t=!!this.ci,u=!1,r=-1,a=(n=this.b).a.d;a!==n.a;a=a.d)if(a.c){u||(this.ei&&this.ei(4,this.c),u=!0),l=a.a
455
455
  do{t&&r!==(o=l.b.d.c?0:1)&&(r=o,this.ci&&this.ci(!!r,this.c)),this.hi&&this.hi(l.a.d,this.c),l=l.e}while(l!==a.a)}u&&this.ii&&this.ii(this.c)}if(this.r){for(u=(n=this.b).a.b;u!==n.a;u=t)if(t=u.b,!u.c){a=(r=u.a).e,l=void 0
456
- do{a=(l=a).e,l.d=null,null===l.b.d&&(l.c===l?b(l.a,null):(l.a.c=l.c,g(l,K(l))),(o=l.b).c===o?b(o.a,null):(o.a.c=o.c,g(o,K(o))),x(l))}while(l!==r)
457
- r=u.d,(u=u.b).d=r,r.b=u}return this.r(this.b),void(this.c=this.b=null)}}this.b=this.c=null},et.di={GluTesselator:H,yi:{GLU_TESS_WINDING_ODD:100130,GLU_TESS_WINDING_NONZERO:100131,GLU_TESS_WINDING_POSITIVE:100132,GLU_TESS_WINDING_NEGATIVE:100133,GLU_TESS_WINDING_ABS_GEQ_TWO:100134},primitiveType:{GL_LINE_LOOP:2,GL_TRIANGLES:4,GL_TRIANGLE_STRIP:5,GL_TRIANGLE_FAN:6},pi:{GLU_TESS_MISSING_BEGIN_POLYGON:100151,GLU_TESS_MISSING_END_POLYGON:100153,GLU_TESS_MISSING_BEGIN_CONTOUR:100152,GLU_TESS_MISSING_END_CONTOUR:100154,GLU_TESS_COORD_TOO_LARGE:100155,GLU_TESS_NEED_COMBINE_CALLBACK:100156},wi:{GLU_TESS_MESH:100112,GLU_TESS_TOLERANCE:100142,GLU_TESS_WINDING_RULE:100140,GLU_TESS_BOUNDARY_ONLY:100141,GLU_INVALID_ENUM:100900,GLU_INVALID_VALUE:100901,GLU_TESS_BEGIN:100100,GLU_TESS_VERTEX:100101,GLU_TESS_END:100102,GLU_TESS_ERROR:100103,GLU_TESS_EDGE_FLAG:100104,GLU_TESS_COMBINE:100105,GLU_TESS_BEGIN_DATA:100106,GLU_TESS_VERTEX_DATA:100107,GLU_TESS_END_DATA:100108,GLU_TESS_ERROR_DATA:100109,GLU_TESS_EDGE_FLAG_DATA:100110,GLU_TESS_COMBINE_DATA:100111}},H.prototype.gi=H.prototype.x,H.prototype.mi=H.prototype.B,H.prototype.xi=H.prototype.y,H.prototype.bi=H.prototype.A,H.prototype.Si=H.prototype.z,H.prototype._i=H.prototype.C,H.prototype.Ei=H.prototype.li,H.prototype.Ti=H.prototype.ui,H.prototype.Ai=H.prototype.fi,H.prototype.Ii=H.prototype.w,t.exports=et.di})(it)
456
+ do{a=(l=a).e,l.d=null,null===l.b.d&&(l.c===l?S(l.a,null):(l.a.c=l.c,g(l,K(l))),(o=l.b).c===o?S(o.a,null):(o.a.c=o.c,g(o,K(o))),x(l))}while(l!==r)
457
+ r=u.d,(u=u.b).d=r,r.b=u}return this.r(this.b),void(this.c=this.b=null)}}this.b=this.c=null},et.di={GluTesselator:H,pi:{GLU_TESS_WINDING_ODD:100130,GLU_TESS_WINDING_NONZERO:100131,GLU_TESS_WINDING_POSITIVE:100132,GLU_TESS_WINDING_NEGATIVE:100133,GLU_TESS_WINDING_ABS_GEQ_TWO:100134},primitiveType:{GL_LINE_LOOP:2,GL_TRIANGLES:4,GL_TRIANGLE_STRIP:5,GL_TRIANGLE_FAN:6},yi:{GLU_TESS_MISSING_BEGIN_POLYGON:100151,GLU_TESS_MISSING_END_POLYGON:100153,GLU_TESS_MISSING_BEGIN_CONTOUR:100152,GLU_TESS_MISSING_END_CONTOUR:100154,GLU_TESS_COORD_TOO_LARGE:100155,GLU_TESS_NEED_COMBINE_CALLBACK:100156},wi:{GLU_TESS_MESH:100112,GLU_TESS_TOLERANCE:100142,GLU_TESS_WINDING_RULE:100140,GLU_TESS_BOUNDARY_ONLY:100141,GLU_INVALID_ENUM:100900,GLU_INVALID_VALUE:100901,GLU_TESS_BEGIN:100100,GLU_TESS_VERTEX:100101,GLU_TESS_END:100102,GLU_TESS_ERROR:100103,GLU_TESS_EDGE_FLAG:100104,GLU_TESS_COMBINE:100105,GLU_TESS_BEGIN_DATA:100106,GLU_TESS_VERTEX_DATA:100107,GLU_TESS_END_DATA:100108,GLU_TESS_ERROR_DATA:100109,GLU_TESS_EDGE_FLAG_DATA:100110,GLU_TESS_COMBINE_DATA:100111}},H.prototype.gi=H.prototype.x,H.prototype.mi=H.prototype.B,H.prototype.xi=H.prototype.y,H.prototype.Si=H.prototype.A,H.prototype.bi=H.prototype.z,H.prototype._i=H.prototype.C,H.prototype.Ei=H.prototype.li,H.prototype.Ti=H.prototype.ui,H.prototype.Ai=H.prototype.fi,H.prototype.Ii=H.prototype.w,t.exports=et.di})(it)
458
458
  var nt=it.exports
459
459
  class st{process(t,e=!0,i=!1,n=!0){if(0===t.length)return{Mi:{vertices:[],indices:[]},Li:[]}
460
460
  const s=t.filter(t=>t.points.length>=3)
@@ -471,27 +471,27 @@ let h=0
471
471
  if(e)for(let t=o-1;t>=0;t--){const e=s[t]
472
472
  a[h++]=e.x,a[h++]=e.y}else for(let t=0;o>t;t++){const e=s[t]
473
473
  a[h++]=e.x,a[h++]=e.y}2>h||(a[h++]=a[0],a[h++]=a[1]),i[n]=a}return i}Oi(t,e){const i=new nt.GluTesselator
474
- i.mi(nt.wi.GLU_TESS_WINDING_RULE,nt.yi.GLU_TESS_WINDING_NONZERO)
474
+ i.mi(nt.wi.GLU_TESS_WINDING_RULE,nt.pi.GLU_TESS_WINDING_NONZERO)
475
475
  const n=[],s=[],r=[]
476
476
  let o=[]
477
- "boundary"===e&&i.mi(nt.wi.GLU_TESS_BOUNDARY_ONLY,!0),"triangles"===e?i.Si(nt.wi.GLU_TESS_VERTEX_DATA,t=>{s.push(t)}):(i.Si(nt.wi.GLU_TESS_BEGIN,()=>{o=[]}),i.Si(nt.wi.GLU_TESS_VERTEX_DATA,t=>{o.push(t)}),i.Si(nt.wi.GLU_TESS_END,()=>{o.length>0&&r.push(o)})),i.Si(nt.wi.GLU_TESS_COMBINE,t=>{const e=n.length/2
478
- return n.push(t[0],t[1]),e}),i.Si(nt.wi.GLU_TESS_ERROR,t=>{h.warn("libtess error: "+t)}),i.bi(0,0,1),i.Ei(null)
477
+ "boundary"===e&&i.mi(nt.wi.GLU_TESS_BOUNDARY_ONLY,!0),"triangles"===e?i.bi(nt.wi.GLU_TESS_VERTEX_DATA,t=>{s.push(t)}):(i.bi(nt.wi.GLU_TESS_BEGIN,()=>{o=[]}),i.bi(nt.wi.GLU_TESS_VERTEX_DATA,t=>{o.push(t)}),i.bi(nt.wi.GLU_TESS_END,()=>{o.length>0&&r.push(o)})),i.bi(nt.wi.GLU_TESS_COMBINE,t=>{const e=n.length/2
478
+ return n.push(t[0],t[1]),e}),i.bi(nt.wi.GLU_TESS_ERROR,t=>{h.warn("libtess error: "+t)}),i.Si(0,0,1),i.Ei(null)
479
479
  for(const e of t){i.Ti()
480
480
  for(let t=0;e.length>t;t+=2){const s=n.length/2
481
481
  n.push(e[t],e[t+1]),i._i([e[t],e[t+1],0],s)}i.Ai()}return i.Ii(),0===n.length?null:"triangles"===e?{vertices:n,indices:s}:{vertices:n,ki:r}}Ci(t){if(!t.ki)return[]
482
482
  const e=[]
483
483
  for(const i of t.ki){const n=[]
484
484
  for(const e of i){const i=2*e
485
- n.push(t.vertices[i],t.vertices[i+1])}n.length>2&&(n[0]===n[n.length-2]&&n[1]===n[n.length-1]||n.push(n[0],n[1])),e.push(n)}return e}Bi(t){if(0===t.length)return!1
485
+ n.push(t.vertices[i],t.vertices[i+1])}n.length>2&&(n[0]===n[n.length-2]&&n[1]===n[n.length-1]||n.push(n[0],n[1])),e.push(n)}return e}Di(t){if(0===t.length)return!1
486
486
  if(1===t.length)return!1
487
487
  let e=null
488
- for(const i of t){const t=0>this.Di(i)?-1:1
488
+ for(const i of t){const t=0>this.Ui(i)?-1:1
489
489
  if(null===e)e=t
490
- else if(t!==e)return!0}return!1}Di(t){let e=0
490
+ else if(t!==e)return!0}return!1}Ui(t){let e=0
491
491
  const i=t.length
492
492
  if(6>i)return 0
493
493
  for(let n=0;i>n;n+=2)e+=t[n]*t[(n+3)%i]-t[(n+2)%i]*t[n+1]
494
- return e/2}}class rt{constructor(){}Ui(t,e=0,i){const n=t.Mi.vertices,s=t.Mi.indices,r=n.length/2
494
+ return e/2}}class rt{constructor(){}Bi(t,e=0,i){const n=t.Mi.vertices,s=t.Mi.indices,r=n.length/2
495
495
  let o=[]
496
496
  if(0!==e){const t=new Map,e=s.length
497
497
  for(let i=0;e>i;i+=3){const e=s[i],n=s[i+1],r=s[i+2]
@@ -506,31 +506,31 @@ return u.set(s),{vertices:c,normals:l,indices:u}}const f=25e-6*i,d=e>f?e:f
506
506
  for(let t=0,e=0;n.length>t;t+=2,e++){const i=n[t],s=n[t+1],o=3*e
507
507
  c[o]=i,c[o+1]=s,c[o+2]=0,l[o]=0,l[o+1]=0,l[o+2]=-1
508
508
  const a=3*(r+e)
509
- c[a]=i,c[a+1]=s,c[a+2]=d,l[a]=0,l[a+1]=0,l[a+2]=1}const y=s.length
510
- for(let t=0;y>t;t++)u[t]=s[y-1-t]
511
- for(let t=0;y>t;t++)u[y+t]=s[t]+r
512
- let p=2*r,w=2*y
509
+ c[a]=i,c[a+1]=s,c[a+2]=d,l[a]=0,l[a+1]=0,l[a+2]=1}const p=s.length
510
+ for(let t=0;p>t;t++)u[t]=s[p-1-t]
511
+ for(let t=0;p>t;t++)u[p+t]=s[t]+r
512
+ let y=2*r,w=2*p
513
513
  const g=o.length
514
- for(let t=0;g>t;t++){const e=o[t],i=e[0]<<1,s=e[1]<<1,r=n[i],a=n[i+1],h=n[s],f=n[s+1],y=h-r,g=f-a,m=y*y+g*g
515
- let v=0,x=0
516
- if(m>1e-10){const t=1/Math.sqrt(m)
517
- v=g*t,x=-y*t}const b=3*p
518
- c[b]=r,c[b+1]=a,c[b+2]=0,c[b+3]=h,c[b+4]=f,c[b+5]=0,c[b+6]=r,c[b+7]=a,c[b+8]=d,c[b+9]=h,c[b+10]=f,c[b+11]=d,l[b]=v,l[b+1]=x,l[b+2]=0,l[b+3]=v,l[b+4]=x,l[b+5]=0,l[b+6]=v,l[b+7]=x,l[b+8]=0,l[b+9]=v,l[b+10]=x,l[b+11]=0
519
- const S=p
520
- u[w]=S,u[w+1]=S+1,u[w+2]=S+2,u[w+3]=S+1,u[w+4]=S+3,u[w+5]=S+2,w+=6,p+=4}return{vertices:c,normals:l,indices:u}}}class ot{constructor(){}$i(t,e){const i=t.length
521
- return 0===i?[]:1===i?[[0]]:this.Pi(t,e)}Pi(t,e){function i(t){return h[t]===t?t:h[t]=i(h[t])}function n(t,e){const n=i(t),s=i(e)
514
+ for(let t=0;g>t;t++){const e=o[t],i=e[0]<<1,s=e[1]<<1,r=n[i],a=n[i+1],h=n[s],f=n[s+1],p=h-r,g=f-a,v=p*p+g*g
515
+ let m=0,x=0
516
+ if(v>1e-10){const t=1/Math.sqrt(v)
517
+ m=g*t,x=-p*t}const S=3*y
518
+ c[S]=r,c[S+1]=a,c[S+2]=0,c[S+3]=h,c[S+4]=f,c[S+5]=0,c[S+6]=r,c[S+7]=a,c[S+8]=d,c[S+9]=h,c[S+10]=f,c[S+11]=d,l[S]=m,l[S+1]=x,l[S+2]=0,l[S+3]=m,l[S+4]=x,l[S+5]=0,l[S+6]=m,l[S+7]=x,l[S+8]=0,l[S+9]=m,l[S+10]=x,l[S+11]=0
519
+ const b=y
520
+ u[w]=b,u[w+1]=b+1,u[w+2]=b+2,u[w+3]=b+1,u[w+4]=b+3,u[w+5]=b+2,w+=6,y+=4}return{vertices:c,normals:l,indices:u}}}class ot{constructor(){}Ni(t,e){const i=t.length
521
+ return 0===i?[]:1===i?[[0]]:this.$i(t,e)}$i(t,e){function i(t){return h[t]===t?t:h[t]=i(h[t])}function n(t,e){const n=i(t),s=i(e)
522
522
  n!==s&&(c[s]>c[n]?h[n]=s:c[n]>c[s]?h[s]=n:(h[s]=n,c[n]++))}const s=t.length,r=Array(s),o=Array(2*s)
523
523
  let a=0
524
- for(let i=0;s>i;i++)r[i]=this.Ni(t[i],e[i]),o[a++]=[r[i].Ri,0,i],o[a++]=[r[i].ji,1,i]
524
+ for(let i=0;s>i;i++)r[i]=this.Pi(t[i],e[i]),o[a++]=[r[i].Ri,0,i],o[a++]=[r[i].zi,1,i]
525
525
  o.sort((t,e)=>t[0]-e[0]||t[1]-e[1])
526
526
  const h=Array.from({length:s},(t,e)=>e),c=Array(s).fill(0),l=new Set
527
527
  for(const[,t,e]of o)if(0===t){const t=r[e]
528
528
  for(const i of l){const s=r[i]
529
- s.zi+.001>t.Wi&&t.zi>s.Wi-.001&&n(e,i)}l.add(e)}else l.delete(e)
529
+ s.ji+.001>t.Wi&&t.ji>s.Wi-.001&&n(e,i)}l.add(e)}else l.delete(e)
530
530
  const u=new Map
531
531
  for(let t=0;s>t;t++){const e=i(t)
532
532
  let n=u.get(e)
533
- n||(n=[],u.set(e,n)),n.push(t)}return Array.from(u.values())}Ni(t,e){return{Ri:t.bounds.min.x+e.x,Wi:t.bounds.min.y+e.y,ji:t.bounds.max.x+e.x,zi:t.bounds.max.y+e.y}}}class at{constructor(t){this.Hi=[],this.Vi=new Map,this.compare=t}L(t){const e=this.Vi.get(t)
533
+ n||(n=[],u.set(e,n)),n.push(t)}return Array.from(u.values())}Pi(t,e){return{Ri:t.bounds.min.x+e.x,Wi:t.bounds.min.y+e.y,zi:t.bounds.max.x+e.x,ji:t.bounds.max.y+e.y}}}class at{constructor(t){this.Hi=[],this.Vi=new Map,this.compare=t}L(t){const e=this.Vi.get(t)
534
534
  if(void 0!==e)return this.qi(e),void this.Yi(e)
535
535
  const i=this.Hi.length
536
536
  this.Hi.push(t),this.Vi.set(t,i),this.qi(i)}Ji(){const t=this.Hi.length
@@ -538,7 +538,7 @@ if(!t)return
538
538
  if(1===t){const t=this.Hi.pop()
539
539
  return this.Vi.clear(),t}const e=this.Hi[0],i=this.Hi.pop()
540
540
  return this.Hi[0]=i,this.Vi.delete(e),this.Vi.set(i,0),this.Yi(0),e}update(t){const e=this.Vi.get(t)
541
- void 0!==e?(this.qi(e),this.Yi(e)):this.L(t)}Ki(){return!this.Hi.length}Xi(t,e){const i=this.Hi[t],n=this.Hi[e]
541
+ void 0!==e?(this.qi(e),this.Yi(e)):this.L(t)}Ki(){return!this.Hi.length}Qi(t,e){const i=this.Hi[t],n=this.Hi[e]
542
542
  this.Hi[t]=n,this.Hi[e]=i,this.Vi.set(i,e),this.Vi.set(n,t)}qi(t){const e=this.Hi[t]
543
543
  for(;t>0;){const i=t-1>>1,n=this.Hi[i]
544
544
  if(this.compare(e,n)>=0)break
@@ -548,361 +548,378 @@ let r=t,o=e
548
548
  const a=this.Hi[n]
549
549
  if(0>this.compare(a,o)&&(r=n,o=a),i>s){const t=this.Hi[s]
550
550
  0>this.compare(t,o)&&(r=s,o=t)}if(r===t)break
551
- this.Hi[t]=o,this.Vi.set(o,t),t=r}this.Hi[t]=e,this.Vi.set(e,t)}}const ht={enabled:!0,Qi:1,Zi:.0087,tn:10}
552
- class ct{constructor(t){this.stats={en:0,nn:0,sn:0},this.config=t}rn(t){this.config=t}an(t){if(!this.config.enabled||2>=t.points.length)return t
553
- this.stats.sn+=t.points.length
551
+ this.Hi[t]=o,this.Vi.set(o,t),t=r}this.Hi[t]=e,this.Vi.set(e,t)}}const ht={enabled:!0,areaThreshold:1}
552
+ class ct{constructor(t){this.stats={pointsRemovedByVisvalingam:0,originalPointCount:0},this.config=t}Xi(t){this.config=t}Zi(t){if(2>=t.points.length)return t
553
+ if(!this.config.enabled)return t
554
+ this.stats.originalPointCount+=t.points.length
554
555
  const e=t.points
555
556
  if(5>e.length)return t
556
- let i=this.hn(e,this.config.Qi)
557
- return 3>i.length?t:(i=this.cn(i,this.config.Zi),3>i.length?t:{...t,points:i})}hn(t,e){if(3>=t.length)return t
558
- const i=t.length,n=t.map((t,e)=>({index:e,ln:1/0,un:null,next:null}))
559
- for(let t=0;n.length>t;t++)n[t].un=n[t-1]||null,n[t].next=n[t+1]||null
560
- const s=new at((t,e)=>t.ln-e.ln)
557
+ let i=e
558
+ return i=this.tn(i,this.config.areaThreshold),3>i.length?t:{...t,points:i}}tn(t,e){if(3>=t.length)return t
559
+ const i=t.length,n=t.map((t,e)=>({index:e,en:1/0,nn:null,next:null}))
560
+ for(let t=0;n.length>t;t++)n[t].nn=n[t-1]||null,n[t].next=n[t+1]||null
561
+ const s=new at((t,e)=>t.en-e.en)
561
562
  for(let e=1;n.length-1>e;e++){const i=n[e]
562
- i.ln=this.fn(t[i.un.index],t[i.index],t[i.next.index]),s.L(i)}let r=i
563
+ i.en=this.sn(t[i.nn.index],t[i.index],t[i.next.index]),s.L(i)}let r=i
563
564
  for(;!s.Ki()&&r>3;){const i=s.Ji()
564
- if(!i||i.ln>e)break
565
- if(this.config.tn>0&&i.un&&i.next){const e=t[i.index],n=t[i.next.index],s=t[i.un.index].Qe(e),r=e.Qe(n)
566
- if(this.config.tn>s||this.config.tn>r)continue}i.un&&(i.un.next=i.next),i.next&&(i.next.un=i.un),r--,i.un&&i.un.un&&(i.un.ln=this.fn(t[i.un.un.index],t[i.un.index],t[i.next.index]),s.update(i.un)),i.next&&i.next.next&&(i.next.ln=this.fn(t[i.un.index],t[i.next.index],t[i.next.next.index]),s.update(i.next))}const o=[]
565
+ if(!i||i.en>e)break
566
+ i.nn&&(i.nn.next=i.next),i.next&&(i.next.nn=i.nn),r--,i.nn&&i.nn.nn&&(i.nn.en=this.sn(t[i.nn.nn.index],t[i.nn.index],t[i.next.index]),s.update(i.nn)),i.next&&i.next.next&&(i.next.en=this.sn(t[i.nn.index],t[i.next.index],t[i.next.next.index]),s.update(i.next))}const o=[]
567
567
  let a=n[0]
568
568
  for(;a;)o.push(t[a.index]),a=a.next
569
- return this.stats.en+=i-o.length,o}cn(t,e){if(2>=t.length)return t
570
- const i=[t[0]]
571
- for(let n=1;t.length-1>n;n++){const s=t[n-1],r=t[n],o=t[n+1],a=r.x-s.x,h=r.y-s.y,c=o.x-r.x,l=o.y-r.y,u=this.config.tn*this.config.tn
572
- Math.abs(Math.atan2(a*l-h*c,a*c+h*l))>e||u>a*a+h*h||u>c*c+l*l?i.push(r):this.stats.nn++}return i.push(t[t.length-1]),i}fn(t,e,i){return Math.abs((t.x*(e.y-i.y)+e.x*(i.y-t.y)+i.x*(t.y-e.y))/2)}getStats(){return{...this.stats}}dn(){this.stats={en:0,nn:0,sn:0}}}const lt={yn:.5,pn:.2},ut=1e-6
573
- class ft{constructor(t){this.wn={...lt,...t}}gn(t){this.wn={...lt,...t}}mn(t,e,i){const n=[]
574
- return this.vn(t.x,t.y,e.x,e.y,i.x,i.y,n),this.xn(i.x,i.y,n),n}bn(t,e,i,n){const s=[]
575
- return this.Sn(t.x,t.y,e.x,e.y,i.x,i.y,n.x,n.y,s),this.xn(n.x,n.y,s),s}vn(t,e,i,n,s,r,o,a=0){if(a>16)return
576
- const h=(t+i)/2,c=(e+n)/2,l=(i+s)/2,u=(n+r)/2,f=(h+l)/2,d=(c+u)/2,y=s-t,p=r-e,w=Math.abs((i-s)*p-(n-r)*y),g=this.wn.yn??lt.yn,m=g*g
577
- if(w>ut){if(m*(y*y+p*p)>=w*w){const a=this.wn.pn??lt.pn
578
- if(0>=a)return void this.xn(i,n,o)
569
+ return this.stats.pointsRemovedByVisvalingam+=i-o.length,o}sn(t,e,i){return Math.abs((t.x*(e.y-i.y)+e.x*(i.y-t.y)+i.x*(t.y-e.y))/2)}getStats(){return{...this.stats}}rn(){this.stats={pointsRemovedByVisvalingam:0,originalPointCount:0}}}const lt={distanceTolerance:.5,angleTolerance:.2},ut=1e-6
570
+ class ft{constructor(t){this.curveSteps=null,this.an={...lt,...t}}hn(t){this.an={...lt,...t}}cn(t){if(null==t)return void(this.curveSteps=null)
571
+ if(!Number.isFinite(t))return void(this.curveSteps=null)
572
+ const e=Math.round(t)
573
+ this.curveSteps=1>e?null:e}ln(t,e,i){if(null!==this.curveSteps)return this.un(t,e,i,this.curveSteps)
574
+ const n=[]
575
+ return this.fn(t.x,t.y,e.x,e.y,i.x,i.y,n),this.dn(i.x,i.y,n),n}pn(t,e,i,n){if(null!==this.curveSteps)return this.yn(t,e,i,n,this.curveSteps)
576
+ const s=[]
577
+ return this.wn(t.x,t.y,e.x,e.y,i.x,i.y,n.x,n.y,s),this.dn(n.x,n.y,s),s}gn(t,e,i){return t+(e-t)*i}un(t,e,i,n){const s=[]
578
+ for(let r=1;n>=r;r++){const o=r/n,a=this.gn(t.x,e.x,o),h=this.gn(t.y,e.y,o),c=this.gn(e.x,i.x,o),l=this.gn(e.y,i.y,o),u=this.gn(a,c,o),f=this.gn(h,l,o)
579
+ this.dn(u,f,s)}return s}yn(t,e,i,n,s){const r=[]
580
+ for(let o=1;s>=o;o++){const a=o/s,h=this.gn(t.x,e.x,a),c=this.gn(t.y,e.y,a),l=this.gn(e.x,i.x,a),u=this.gn(e.y,i.y,a),f=this.gn(i.x,n.x,a),d=this.gn(i.y,n.y,a),p=this.gn(h,l,a),y=this.gn(c,u,a),w=this.gn(l,f,a),g=this.gn(u,d,a),v=this.gn(p,w,a),m=this.gn(y,g,a)
581
+ this.dn(v,m,r)}return r}fn(t,e,i,n,s,r,o,a=0){if(a>16)return
582
+ const h=(t+i)/2,c=(e+n)/2,l=(i+s)/2,u=(n+r)/2,f=(h+l)/2,d=(c+u)/2,p=s-t,y=r-e,w=Math.abs((i-s)*y-(n-r)*p),g=this.an.distanceTolerance??lt.distanceTolerance,v=g*g
583
+ if(w>ut){if(v*(p*p+y*y)>=w*w){const a=this.an.angleTolerance??lt.angleTolerance
584
+ if(0>=a)return void this.dn(i,n,o)
579
585
  {const h=i-t,c=n-e,l=s-i,u=r-n
580
- if(a>Math.abs(Math.atan2(h*u-c*l,h*l+c*u)))return void this.xn(i,n,o)}}}else{const s=y*y+p*p
581
- if(0===s){if(m>=(i-t)*(i-t)+(n-e)*(n-e))return void this.xn(i,n,o)}else{const r=((i-t)*y+(n-e)*p)/s
582
- if(r>0&&1>r&&m*s>=w*w)return void this.xn(i,n,o)}}this.vn(t,e,h,c,f,d,o,a+1),this.vn(f,d,l,u,s,r,o,a+1)}Sn(t,e,i,n,s,r,o,a,h,c=0){if(c>16)return
583
- const l=(t+i)/2,u=(e+n)/2,f=(i+s)/2,d=(n+r)/2,y=(s+o)/2,p=(r+a)/2,w=(l+f)/2,g=(u+d)/2,m=(f+y)/2,v=(d+p)/2,x=(w+m)/2,b=(g+v)/2,S=o-t,_=a-e,E=Math.abs((i-o)*_-(n-a)*S),T=Math.abs((s-o)*_-(r-a)*S),A=this.wn.yn??lt.yn,I=A*A
586
+ if(a>Math.abs(Math.atan2(h*u-c*l,h*l+c*u)))return void this.dn(i,n,o)}}}else{const s=p*p+y*y
587
+ if(0===s){if(v>=(i-t)*(i-t)+(n-e)*(n-e))return void this.dn(i,n,o)}else{const r=((i-t)*p+(n-e)*y)/s
588
+ if(r>0&&1>r&&v*s>=w*w)return void this.dn(i,n,o)}}this.fn(t,e,h,c,f,d,o,a+1),this.fn(f,d,l,u,s,r,o,a+1)}wn(t,e,i,n,s,r,o,a,h,c=0){if(c>16)return
589
+ const l=(t+i)/2,u=(e+n)/2,f=(i+s)/2,d=(n+r)/2,p=(s+o)/2,y=(r+a)/2,w=(l+f)/2,g=(u+d)/2,v=(f+p)/2,m=(d+y)/2,x=(w+v)/2,S=(g+m)/2,b=o-t,_=a-e,E=Math.abs((i-o)*_-(n-a)*b),T=Math.abs((s-o)*_-(r-a)*b),A=this.an.distanceTolerance??lt.distanceTolerance,I=A*A
584
590
  let M=0
585
- switch(E>ut&&(M|=1),T>ut&&(M|=2),M){case 0:const c=S*S+_*_
586
- if(0===c){if(I>=(i-t)*(i-t)+(n-e)*(n-e)&&I>=(s-t)*(s-t)+(r-e)*(r-e))return this.xn(i,n,h),void this.xn(s,r,h)}else{const o=((i-t)*S+(n-e)*_)/c,a=((s-t)*S+(r-e)*_)/c
587
- if(o>0&&1>o&&a>0&&1>a&&I*c>=(E+T)*(E+T))return this.xn(i,n,h),void this.xn(s,r,h)}break
588
- case 1:if(I*(S*S+_*_)>=T*T){const t=this.wn.pn??lt.pn
589
- if(0>=t)return this.xn(i,n,h),void this.xn(s,r,h)
591
+ switch(E>ut&&(M|=1),T>ut&&(M|=2),M){case 0:const c=b*b+_*_
592
+ if(0===c){if(I>=(i-t)*(i-t)+(n-e)*(n-e)&&I>=(s-t)*(s-t)+(r-e)*(r-e))return this.dn(i,n,h),void this.dn(s,r,h)}else{const o=((i-t)*b+(n-e)*_)/c,a=((s-t)*b+(r-e)*_)/c
593
+ if(o>0&&1>o&&a>0&&1>a&&I*c>=(E+T)*(E+T))return this.dn(i,n,h),void this.dn(s,r,h)}break
594
+ case 1:if(I*(b*b+_*_)>=T*T){const t=this.an.angleTolerance??lt.angleTolerance
595
+ if(0>=t)return this.dn(i,n,h),void this.dn(s,r,h)
590
596
  {const e=s-i,c=r-n,l=o-s,u=a-r
591
- if(t>Math.abs(Math.atan2(e*u-c*l,e*l+c*u)))return this.xn(i,n,h),void this.xn(s,r,h)}}break
592
- case 2:if(I*(S*S+_*_)>=E*E){const o=this.wn.pn??lt.pn
593
- if(0>=o)return this.xn(i,n,h),void this.xn(s,r,h)
597
+ if(t>Math.abs(Math.atan2(e*u-c*l,e*l+c*u)))return this.dn(i,n,h),void this.dn(s,r,h)}}break
598
+ case 2:if(I*(b*b+_*_)>=E*E){const o=this.an.angleTolerance??lt.angleTolerance
599
+ if(0>=o)return this.dn(i,n,h),void this.dn(s,r,h)
594
600
  {const a=i-t,c=n-e,l=s-i,u=r-n
595
- if(o>Math.abs(Math.atan2(a*u-c*l,a*l+c*u)))return this.xn(i,n,h),void this.xn(s,r,h)}}break
596
- case 3:if(I*(S*S+_*_)>=(E+T)*(E+T)){const c=this.wn.pn??lt.pn
597
- if(0>=c)return this.xn(i,n,h),void this.xn(s,r,h)
598
- {const l=i-t,u=n-e,f=s-i,d=r-n,y=o-s,p=a-r
599
- if(c>Math.abs(Math.atan2(l*d-u*f,l*f+u*d))+Math.abs(Math.atan2(f*p-d*y,f*y+d*p)))return this.xn(i,n,h),void this.xn(s,r,h)}}}this.Sn(t,e,l,u,w,g,x,b,h,c+1),this.Sn(x,b,m,v,y,p,o,a,h,c+1)}xn(t,e,i){const n=new Y(t,e)
601
+ if(o>Math.abs(Math.atan2(a*u-c*l,a*l+c*u)))return this.dn(i,n,h),void this.dn(s,r,h)}}break
602
+ case 3:if(I*(b*b+_*_)>=(E+T)*(E+T)){const c=this.an.angleTolerance??lt.angleTolerance
603
+ if(0>=c)return this.dn(i,n,h),void this.dn(s,r,h)
604
+ {const l=i-t,u=n-e,f=s-i,d=r-n,p=o-s,y=a-r
605
+ if(c>Math.abs(Math.atan2(l*d-u*f,l*f+u*d))+Math.abs(Math.atan2(f*y-d*p,f*p+d*y)))return this.dn(i,n,h),void this.dn(s,r,h)}}}this.wn(t,e,l,u,w,g,x,S,h,c+1),this.wn(x,S,v,m,p,y,o,a,h,c+1)}dn(t,e,i){const n=new Y(t,e)
600
606
  if(0===i.length)return void i.push(n)
601
607
  const s=i[i.length-1],r=n.x-s.x,o=n.y-s.y
602
- r*r+o*o>1e-12&&i.push(n)}}class dt{constructor(t,e){this._n=0,this.En=0,this.Tn=[],this.An=null,this.In=null,this.Mn={min:new Y(1/0,1/0),max:new Y(-1/0,-1/0)},this.Ln=[],this.Fn=[],this.Gn=[],this.On=new Y(0,0),this.Cn=new ft(t),this.kn=new ct({...ht,...e})}setPosition(t,e){this.On.set(t,e)}Bn(t,e){this.On.x+=t,this.On.y+=e}Dn(t,e){this.Tn.length>0&&this.Un(),this._n=t,this.En=e,this.Tn=[],this.Mn.min.set(1/0,1/0),this.Mn.max.set(-1/0,-1/0),this.Fn.push(this.On.clone())}Un(){this.An&&this.$n(),this.Tn.length>0&&(this.Ln.push({Pn:this._n,Nn:this.Tn,bounds:{min:{x:this.Mn.min.x,y:this.Mn.min.y},max:{x:this.Mn.max.x,y:this.Mn.max.y}}}),this.Gn.push(this.En)),this.Tn=[]}Rn(t,e){this.An&&this.$n(),this.In=new Y(t,e),this.jn(this.In),this.An={points:[this.In],glyphIndex:this._n}}zn(t,e){if(!this.An||!this.In)return
608
+ r*r+o*o>1e-12&&i.push(n)}}class dt{constructor(t,e){this.vn=0,this.mn=0,this.xn=[],this.Sn=null,this.bn=null,this._n={min:new Y(1/0,1/0),max:new Y(-1/0,-1/0)},this.En=[],this.Tn=[],this.An=[],this.In=new Y(0,0),this.Mn=new ft(t),this.Ln=new ct({...ht,...e})}setPosition(t,e){this.In.set(t,e)}Fn(t,e){this.In.x+=t,this.In.y+=e}Gn(t,e){this.xn.length>0&&this.On(),this.vn=t,this.mn=e,this.xn=[],this._n.min.set(1/0,1/0),this._n.max.set(-1/0,-1/0),this.Tn.push(this.In.clone())}On(){this.Sn&&this.Cn(),this.xn.length>0&&(this.En.push({kn:this.vn,Dn:this.xn,bounds:{min:{x:this._n.min.x,y:this._n.min.y},max:{x:this._n.max.x,y:this._n.max.y}}}),this.An.push(this.mn)),this.xn=[]}Un(t,e){this.Sn&&this.Cn(),this.bn=new Y(t,e),this.Bn(this.bn),this.Sn={points:[this.bn],glyphIndex:this.vn}}Nn(t,e){if(!this.Sn||!this.bn)return
603
609
  const i=new Y(t,e)
604
- this.jn(i),this.An.points.push(i),this.In=i}Wn(t,e,i,n){if(!this.An||!this.In)return
605
- const s=this.In,r=new Y(t,e),o=new Y(i,n)
606
- if(ut>Math.abs((r.x-o.x)*(o.y-s.y)-(r.y-o.y)*(o.x-s.x)))return void this.zn(i,n)
607
- const a=this.Cn.mn(s,r,o)
610
+ this.Bn(i),this.Sn.points.push(i),this.bn=i}$n(t,e,i,n){if(!this.Sn||!this.bn)return
611
+ const s=this.bn,r=new Y(t,e),o=new Y(i,n)
612
+ if(ut>Math.abs((r.x-o.x)*(o.y-s.y)-(r.y-o.y)*(o.x-s.x)))return void this.Nn(i,n)
613
+ const a=this.Mn.ln(s,r,o)
608
614
  for(let t=0;a.length>t;t++){const e=a[t]
609
- this.jn(e),this.An.points.push(e)}this.In=o}Hn(t,e,i,n,s,r){if(!this.An||!this.In)return
610
- const o=this.In,a=new Y(t,e),h=new Y(i,n),c=new Y(s,r),l=c.x-o.x,u=c.y-o.y
611
- if(ut>Math.abs((a.x-c.x)*u-(a.y-c.y)*l)&&ut>Math.abs((h.x-c.x)*u-(h.y-c.y)*l))return void this.zn(s,r)
612
- const f=this.Cn.bn(o,a,h,c)
615
+ this.Bn(e),this.Sn.points.push(e)}this.bn=o}Pn(t,e,i,n,s,r){if(!this.Sn||!this.bn)return
616
+ const o=this.bn,a=new Y(t,e),h=new Y(i,n),c=new Y(s,r),l=c.x-o.x,u=c.y-o.y
617
+ if(ut>Math.abs((a.x-c.x)*u-(a.y-c.y)*l)&&ut>Math.abs((h.x-c.x)*u-(h.y-c.y)*l))return void this.Nn(s,r)
618
+ const f=this.Mn.pn(o,a,h,c)
613
619
  for(let t=0;f.length>t;t++){const e=f[t]
614
- this.jn(e),this.An.points.push(e)}this.In=c}Vn(){if(!this.An||!this.In)return
615
- const t=this.An.points[0]
616
- this.In.equals(t)||this.An.points.push(t),this.$n()}$n(){if(this.An){const t=this.kn.an(this.An)
617
- this.Tn.push(t),this.An=null,this.In=null}}jn(t){this.Mn.min.x=Math.min(this.Mn.min.x,t.x),this.Mn.min.y=Math.min(this.Mn.min.y,t.y),this.Mn.max.x=Math.max(this.Mn.max.x,t.x),this.Mn.max.y=Math.max(this.Mn.max.y,t.y)}qn(){return this.Tn.length>0&&this.Un(),this.Ln}Yn(){return this.Fn}Jn(){return this.Gn}reset(){this.Ln=[],this.Fn=[],this.Gn=[],this.Tn=[],this.An=null,this.In=null,this._n=0,this.En=0,this.On.set(0,0),this.Mn={min:new Y(1/0,1/0),max:new Y(-1/0,-1/0)}}gn(t){this.Cn.gn(t)}Kn(t){this.kn.rn({...ht,...t})}Xn(){return this.kn.getStats()}}class yt{constructor(){this.Qn=null,this.Zn=null,this.ts=null,this.es=null,this.ns=null,this.ss=0,this.position={x:0,y:0}}setPosition(t,e){this.position.x=t,this.position.y=e,this.rs&&this.rs.setPosition(t,e)}Bn(t,e){this.position.x+=t,this.position.y+=e,this.rs&&this.rs.Bn(t,e)}hs(t){this.rs=t}cs(t,e){if(!t||!t.module||!t.hb)throw Error("Invalid font object")
618
- if(this.rs=e,this.ss)return
620
+ this.Bn(e),this.Sn.points.push(e)}this.bn=c}Rn(){if(!this.Sn||!this.bn)return
621
+ const t=this.Sn.points[0]
622
+ this.bn.equals(t)||this.Sn.points.push(t),this.Cn()}Cn(){if(this.Sn){const t=this.Ln.Zi(this.Sn)
623
+ this.xn.push(t),this.Sn=null,this.bn=null}}Bn(t){this._n.min.x=Math.min(this._n.min.x,t.x),this._n.min.y=Math.min(this._n.min.y,t.y),this._n.max.x=Math.max(this._n.max.x,t.x),this._n.max.y=Math.max(this._n.max.y,t.y)}zn(){return this.xn.length>0&&this.On(),this.En}jn(){return this.Tn}Wn(){return this.An}reset(){this.En=[],this.Tn=[],this.An=[],this.xn=[],this.Sn=null,this.bn=null,this.vn=0,this.mn=0,this.In.set(0,0),this._n={min:new Y(1/0,1/0),max:new Y(-1/0,-1/0)}}hn(t){this.Mn.hn(t)}cn(t){this.Mn.cn(t)}Hn(t){this.Ln.Xi({...ht,...t})}Vn(){return this.Ln.getStats()}}class pt{constructor(){this.qn=null,this.Yn=null,this.Jn=null,this.Kn=null,this.Qn=null,this.Xn=0,this.position={x:0,y:0}}setPosition(t,e){this.position.x=t,this.position.y=e,this.Zn&&this.Zn.setPosition(t,e)}Fn(t,e){this.position.x+=t,this.position.y+=e,this.Zn&&this.Zn.Fn(t,e)}ts(t){this.Zn=t}es(t,e){if(!t||!t.module||!t.hb)throw Error("Invalid font object")
624
+ if(this.Zn=e,this.Xn)return
619
625
  const i=t.module
620
- this.Qn=i.ls((t,e,i,n,s)=>{this.rs?.Rn(n,s)},"viiiffi"),this.Zn=i.ls((t,e,i,n,s)=>{this.rs?.zn(n,s)},"viiiffi"),this.ts=i.ls((t,e,i,n,s,r,o)=>{this.rs?.Wn(n,s,r,o)},"viiiffffi"),this.es=i.ls((t,e,i,n,s,r,o,a,h)=>{this.rs?.Hn(n,s,r,o,a,h)},"viiiffffffi"),this.ns=i.ls(()=>{this.rs?.Vn()},"viiii"),this.ss=i.exports.us(),i.exports.fs(this.ss,this.Qn,0,0),i.exports.ds(this.ss,this.Zn,0,0),i.exports.ys(this.ss,this.ts,0,0),i.exports.ps(this.ss,this.es,0,0),i.exports.ws(this.ss,this.ns,0,0)}gs(){if(!this.ss)throw Error("Draw functions not initialized")
621
- return this.ss}destroy(t){if(!t||!t.module||!t.hb)return
626
+ this.qn=i.ns((t,e,i,n,s)=>{this.Zn?.Un(n,s)},"viiiffi"),this.Yn=i.ns((t,e,i,n,s)=>{this.Zn?.Nn(n,s)},"viiiffi"),this.Jn=i.ns((t,e,i,n,s,r,o)=>{this.Zn?.$n(n,s,r,o)},"viiiffffi"),this.Kn=i.ns((t,e,i,n,s,r,o,a,h)=>{this.Zn?.Pn(n,s,r,o,a,h)},"viiiffffffi"),this.Qn=i.ns(()=>{this.Zn?.Rn()},"viiii"),this.Xn=i.exports.ss(),i.exports.rs(this.Xn,this.qn,0,0),i.exports.hs(this.Xn,this.Yn,0,0),i.exports.cs(this.Xn,this.Jn,0,0),i.exports.ls(this.Xn,this.Kn,0,0),i.exports.us(this.Xn,this.Qn,0,0)}fs(){if(!this.Xn)throw Error("Draw functions not initialized")
627
+ return this.Xn}destroy(t){if(!t||!t.module||!t.hb)return
622
628
  const e=t.module
623
- try{this.ss&&(e.exports.vs(this.ss),this.ss=0),null!==this.Qn&&(e.xs(this.Qn),this.Qn=null),null!==this.Zn&&(e.xs(this.Zn),this.Zn=null),null!==this.ts&&(e.xs(this.ts),this.ts=null),null!==this.es&&(e.xs(this.es),this.es=null),null!==this.ns&&(e.xs(this.ns),this.ns=null)}catch(t){h.warn("Error destroying draw callbacks:",t)}this.rs=void 0}}const pt=new WeakMap
624
- class wt{constructor(t,e){this.bs="default",this.Ss="default",this._s=new Set,this.cache=t,this.Yt=e,this.tessellator=new st,this.Es=new rt,this.Ts=new ot,this.rs=new dt,this.As=(()=>{const t=this.Yt.module,e=pt.get(t)
629
+ try{this.Xn&&(e.exports.ds(this.Xn),this.Xn=0),null!==this.qn&&(e.ps(this.qn),this.qn=null),null!==this.Yn&&(e.ps(this.Yn),this.Yn=null),null!==this.Jn&&(e.ps(this.Jn),this.Jn=null),null!==this.Kn&&(e.ps(this.Kn),this.Kn=null),null!==this.Qn&&(e.ps(this.Qn),this.Qn=null)}catch(t){h.warn("Error destroying draw callbacks:",t)}this.Zn=void 0}}const yt=new WeakMap
630
+ class wt{constructor(t,e){this.ys="default",this.ws="default",this.gs=new Set,this.cache=t,this.Yt=e,this.tessellator=new st,this.vs=new rt,this.xs=new ot,this.Zn=new dt,this.Ss=(()=>{const t=this.Yt.module,e=yt.get(t)
625
631
  if(e)return e
626
- const i=new yt
627
- return pt.set(t,i),i})(),this.As.cs(this.Yt,this.rs),this.Is=Q,this.Ms=Z,this.Ls=tt}Xn(){return this.rs.Xn()}gn(t){this.wn=t,this.rs.gn(t),this.Fs()}Kn(t){this.Gs=t,this.rs.Kn(t),this.Fs()}Os(t){this.bs=t,this.Fs()}Fs(){this.Ss=`${this.bs}__${this.Cs()}`}Cs(){const t=this.wn?.yn??lt.yn,e=this.wn?.pn??lt.pn,i=this.Gs?.enabled??!0,n=this.Gs?.Qi??1,s=this.Gs?.Zi??.0087,r=this.Gs?.tn??10
628
- return[`cf:${t.toFixed(4)},${e.toFixed(4)}`,`opt:${i?1:0},${n.toFixed(4)},${s.toFixed(6)},${r.toFixed(4)}`].join("|")}ks(t,e,i,s,r,o=!1,h){if(a){let e=0
632
+ const i=new pt
633
+ return yt.set(t,i),i})(),this.Ss.es(this.Yt,this.Zn),this.bs=X,this._s=Z,this.Es=tt}Vn(){return this.Zn.Vn()}hn(t){this.an=t,this.Zn.hn(t),this.Ts()}cn(t){if(null==t)this.curveSteps=void 0
634
+ else if(Number.isFinite(t)){const e=Math.round(t)
635
+ this.curveSteps=1>e?void 0:e}else this.curveSteps=void 0
636
+ this.Zn.cn(this.curveSteps),this.Ts()}Hn(t){this.As=t,this.Zn.Hn(t),this.Ts()}Is(t){this.ys=t,this.Ts()}Ts(){this.ws=`${this.ys}__${this.Ms()}`}Ms(){return[(()=>{if(void 0!==this.curveSteps)return"cf:steps:"+this.curveSteps
637
+ const t=this.an?.distanceTolerance??lt.distanceTolerance,e=this.an?.angleTolerance??lt.angleTolerance
638
+ return`cf:${t.toFixed(4)},${e.toFixed(4)}`})(),`opt:${this.As?.enabled??1?1:0},${(this.As?.areaThreshold??1).toFixed(4)}`].join("|")}Ls(t,e,i,s,r,o=!1,h){if(a){let e=0
629
639
  for(let i=0;t.length>i;i++)e+=t[i].length}const c=[]
630
640
  let l=0,u=0,f=0,d=0
631
- const y=(t,e,i,n)=>{const s=d
632
- return c.push({data:t,px:e,Bs:i,Ds:n,Us:s}),l+=t.vertices.length,u+=t.normals.length,f+=t.indices.length,d+=t.vertices.length/3,s},p=[],w={min:{x:1/0,y:1/0,z:0},max:{x:-1/0,y:-1/0,z:e}}
641
+ const p=(t,e,i,n)=>{const s=d
642
+ return c.push({data:t,px:e,Fs:i,Gs:n,Os:s}),l+=t.vertices.length,u+=t.normals.length,f+=t.indices.length,d+=t.vertices.length/3,s},y=[],w={min:{x:1/0,y:1/0,z:0},max:{x:-1/0,y:-1/0,z:e}}
633
643
  for(let r=0;t.length>r;r++){const a=t[r]
634
644
  for(const t of a){const r=t.position.x,a=t.position.y,c=t.position.z,l=[]
635
- for(const e of t.glyphs)l.push(this.$s(e.g))
645
+ for(const e of t.glyphs)l.push(this.Cs(e.g))
636
646
  let u
637
- if(t.glyphs.length>1){const e=`${this.Ss}_${t.text}`,i=this.Ls.get(e)
647
+ if(t.glyphs.length>1){const e=`${this.ws}_${t.text}`,i=this.Es.get(e)
638
648
  let n=!1
639
- if(i&&i.Ps.length===t.glyphs.length){n=!0
640
- for(let e=0;t.glyphs.length>e;e++)if(i.Ps[e]!==t.glyphs[e].g){n=!1
641
- break}}if(n&&i)u=i.groups
649
+ if(i&&i.ks.length===t.glyphs.length){n=!0
650
+ for(let e=0;t.glyphs.length>e;e++){const s=t.glyphs[e],r=i.Ds[e]
651
+ if(i.ks[e]!==s.g||r.x!==(s.x??0)||r.y!==(s.y??0)){n=!1
652
+ break}}}if(n&&i)u=i.groups
642
653
  else{const i=t.glyphs.map(t=>new J(t.x??0,t.y??0,0))
643
- u=this.Ts.$i(l,i),this.Ls.set(e,{Ps:t.glyphs.map(t=>t.g),groups:u})}}else u=[[0]]
644
- const f=h&&t.glyphs.some(t=>h.has(t.Ns)),d=o||f
645
- for(const o of u)if(o.length>1&&!d){const n=o.map(e=>t.glyphs[e]),h=this.Rs(n,e,i)
646
- let u=this.Ms.get(h)
654
+ u=this.xs.Ni(l,i),this.Es.set(e,{ks:t.glyphs.map(t=>t.g),Ds:t.glyphs.map(t=>({x:t.x??0,y:t.y??0})),groups:u})}}else u=[[0]]
655
+ const f=o
656
+ let d=u
657
+ if(h&&h.size>0){d=[]
658
+ for(const e of u)if(e.length>1){const i=[],n=[]
659
+ for(const s of e)h.has(t.glyphs[s].Us)?i.push(s):n.push(s)
660
+ i.length>0&&d.push(i),n.length>0&&d.push(n)}else d.push(e)}for(const o of d)if(o.length>1&&!f){const n=o.map(e=>t.glyphs[e]),h=this.Bs(n,e,i)
661
+ let u=this._s.get(h)
647
662
  if(!u){const i=[],r=n[0].x??0,a=n[0].y??0
648
663
  for(let e=0;o.length>e;e++){const n=o[e],s=l[n],h=t.glyphs[n],c=(h.x??0)-r,u=(h.y??0)-a
649
- for(const t of s.Nn)i.push({...t,points:t.points.map(t=>new Y(t.x+c,t.y+u))})}u=this.js(i,e,s),this.Ms.set(h,u)}const f=n[0],d=y(u,r+(f.x??0),a+(f.y??0),c),g=u.vertices.length/3
650
- for(let i=0;o.length>i;i++){const n=o[i],s=t.glyphs[n],h=this.zs(s,d,g,r+(s.x??0),a+(s.y??0),c,l[n],e)
651
- p.push(h),this.Ws(h.bounds,w)}}else for(const h of o){const o=t.glyphs[h],u=l[h],f=r+(o.x??0),d=a+(o.y??0),g=c
652
- if(0===u.Nn.length){const t=this.zs(o,0,0,f,d,g,u,e)
653
- p.push(t)
654
- continue}const m=n(this.Ss,o.g,e,i)
655
- let v=this.cache.get(m)
656
- v?v.Hs++:(v=this.Vs(u,e,i,s),this.cache.set(m,v))
657
- const x=y(v,f,d,g),b=this.zs(o,x,v.vertices.length/3,f,d,g,u,e)
658
- p.push(b),this.Ws(b.bounds,w)}}}const g=new Float32Array(l),m=new Float32Array(u),v=new Uint32Array(f)
659
- let x=0,b=0,S=0
660
- for(let t=0;c.length>t;t++){const e=c[t],i=e.data.vertices,n=e.data.normals,s=e.data.indices,o=e.px,a=e.Bs,h=e.Ds
664
+ for(const t of s.Dn)i.push({...t,points:t.points.map(t=>new Y(t.x+c,t.y+u))})}u=this.Ns(i,e,s),this._s.set(h,u)}const f=n[0],d=p(u,r+(f.x??0),a+(f.y??0),c),g=u.vertices.length/3
665
+ for(let i=0;o.length>i;i++){const n=o[i],s=t.glyphs[n],h=this.$s(s,d,g,r+(s.x??0),a+(s.y??0),c,l[n],e)
666
+ y.push(h),this.Ps(h.bounds,w)}}else for(const h of o){const o=t.glyphs[h],u=l[h],f=r+(o.x??0),d=a+(o.y??0),g=c
667
+ if(0===u.Dn.length){const t=this.$s(o,0,0,f,d,g,u,e)
668
+ y.push(t)
669
+ continue}const v=n(this.ws,o.g,e,i)
670
+ let m=this.cache.get(v)
671
+ m?m.Rs++:(m=this.zs(u,e,i,s),this.cache.set(v,m))
672
+ const x=p(m,f,d,g),S=this.$s(o,x,m.vertices.length/3,f,d,g,u,e)
673
+ y.push(S),this.Ps(S.bounds,w)}}}const g=new Float32Array(l),v=new Float32Array(u),m=new Uint32Array(f)
674
+ let x=0,S=0,b=0
675
+ for(let t=0;c.length>t;t++){const e=c[t],i=e.data.vertices,n=e.data.normals,s=e.data.indices,o=e.px,a=e.Fs,h=e.Gs
661
676
  for(let t=0;i.length>t;t+=3)g[x++]=(i[t]+o)*r,g[x++]=(i[t+1]+a)*r,g[x++]=(i[t+2]+h)*r
662
- m.set(n,b),b+=n.length
663
- const l=e.Us
664
- for(let t=0;s.length>t;t++)v[S++]=s[t]+l}w.min.x*=r,w.min.y*=r,w.min.z*=r,w.max.x*=r,w.max.y*=r,w.max.z*=r
665
- for(let t=0;p.length>t;t++)p[t].bounds.min.x*=r,p[t].bounds.min.y*=r,p[t].bounds.min.z*=r,p[t].bounds.max.x*=r,p[t].bounds.max.y*=r,p[t].bounds.max.z*=r
666
- return{vertices:g,normals:m,indices:v,qs:p,planeBounds:w}}Rs(t,e,i){if(0===t.length)return""
677
+ v.set(n,S),S+=n.length
678
+ const l=e.Os
679
+ for(let t=0;s.length>t;t++)m[b++]=s[t]+l}w.min.x*=r,w.min.y*=r,w.min.z*=r,w.max.x*=r,w.max.y*=r,w.max.z*=r
680
+ for(let t=0;y.length>t;t++)y[t].bounds.min.x*=r,y[t].bounds.min.y*=r,y[t].bounds.min.z*=r,y[t].bounds.max.x*=r,y[t].bounds.max.y*=r,y[t].bounds.max.z*=r
681
+ return{vertices:g,normals:v,indices:m,js:y,planeBounds:w}}Bs(t,e,i){if(0===t.length)return""
667
682
  const n=t[0].x??0,s=t[0].y??0,r=t.map(t=>`${t.g}:${(t.x??0)-n},${(t.y??0)-s}`).join("|")
668
- return`${this.Ss}_${r}_${Math.round(1e3*e)/1e3}_${i}`}zs(t,e,i,n,s,r,o,a){return{Ys:t.Ns,Js:t.Js,Us:e,Ks:i,bounds:{min:{x:o.bounds.min.x+n,y:o.bounds.min.y+s,z:r},max:{x:o.bounds.max.x+n,y:o.bounds.max.y+s,z:r+a}}}}$s(t){if(this._s.has(t))return{Pn:t,Nn:[],bounds:{min:{x:0,y:0},max:{x:0,y:0}}}
669
- const e=`${this.Ss}_${t}`,i=this.Is.get(e)
683
+ return`${this.ws}_${r}_${Math.round(1e3*e)/1e3}_${i}`}$s(t,e,i,n,s,r,o,a){return{Ws:t.Us,Hs:t.Hs,Os:e,Vs:i,bounds:{min:{x:o.bounds.min.x+n,y:o.bounds.min.y+s,z:r},max:{x:o.bounds.max.x+n,y:o.bounds.max.y+s,z:r+a}}}}Cs(t){if(this.gs.has(t))return{kn:t,Dn:[],bounds:{min:{x:0,y:0},max:{x:0,y:0}}}
684
+ const e=`${this.ws}_${t}`,i=this.bs.get(e)
670
685
  if(i)return i
671
- this.As.hs(this.rs),this.rs.reset(),this.rs.Dn(t,0),this.Yt.module.exports.Xs(this.Yt.font.Qs,t,this.As.gs(),0),this.rs.Un()
672
- const n=this.rs.qn()[0]||{Pn:t,Nn:[],bounds:{min:{x:0,y:0},max:{x:0,y:0}}}
673
- return 0===n.Nn.length&&this._s.add(t),this.Is.set(e,n),n}js(t,e,i){const n=this.tessellator.process(t,!0,i,0!==e)
674
- return this.Zs(n,e)}Zs(t,e){const i=this.Es.Ui(t,e,this.Yt.upem),n=i.vertices
686
+ this.Ss.ts(this.Zn),this.Zn.reset(),this.Zn.Gn(t,0),this.Yt.module.exports.qs(this.Yt.font.Ys,t,this.Ss.fs(),0),this.Zn.On()
687
+ const n=this.Zn.zn()[0]||{kn:t,Dn:[],bounds:{min:{x:0,y:0},max:{x:0,y:0}}}
688
+ return 0===n.Dn.length&&this.gs.add(t),this.bs.set(e,n),n}Ns(t,e,i){const n=this.tessellator.process(t,!0,i,0!==e)
689
+ return this.Js(n,e)}Js(t,e){const i=this.vs.Bi(t,e,this.Yt.upem),n=i.vertices
675
690
  let s=1/0,r=1/0,o=1/0,a=-1/0,h=-1/0,c=-1/0
676
691
  for(let t=0;n.length>t;t+=3){const e=n[t],i=n[t+1],l=n[t+2]
677
692
  s>e&&(s=e),e>a&&(a=e),r>i&&(r=i),i>h&&(h=i),o>l&&(o=l),l>c&&(c=l)}const l=new J(s,r,o),u=new J(a,h,c)
678
- return{geometry:t,vertices:i.vertices,normals:i.normals,indices:i.indices,bounds:{min:l,max:u},Hs:1}}Vs(t,e,i,n){const s=this.tessellator.process(t.Nn,i,n,0!==e)
679
- return this.Zs(s,e)}Ws(t,e){const i=e.min,n=e.max,s=t.min,r=t.max
680
- i.x>s.x&&(i.x=s.x),i.y>s.y&&(i.y=s.y),i.z>s.z&&(i.z=s.z),r.x>n.x&&(n.x=r.x),r.y>n.y&&(n.y=r.y),r.z>n.z&&(n.z=r.z)}tr(){return this.cache.getStats()}clearCache(){this.cache.clear(),this.Ms.clear(),this.Ls.clear(),this.Is.clear()}}class gt{constructor(t,e){this.er=new Map,this.Yt=t,this.ir=e}nr(t,e,i,n,s,r,o){try{const r=[]
681
- return t.forEach((t,o)=>{const a=this.sr(t,o,e,i,n,s)
682
- r.push(a)}),r}finally{}}sr(e,i,n,s,r,o){const a=this.Yt.hb.createBuffer()
683
- "rtl"===o&&a.rr("rtl"),a.Wt(e.text),a.Ht()
693
+ return{geometry:t,vertices:i.vertices,normals:i.normals,indices:i.indices,bounds:{min:l,max:u},Rs:1}}zs(t,e,i,n){const s=this.tessellator.process(t.Dn,i,n,0!==e)
694
+ return this.Js(s,e)}Ps(t,e){const i=e.min,n=e.max,s=t.min,r=t.max
695
+ i.x>s.x&&(i.x=s.x),i.y>s.y&&(i.y=s.y),i.z>s.z&&(i.z=s.z),r.x>n.x&&(n.x=r.x),r.y>n.y&&(n.y=r.y),r.z>n.z&&(n.z=r.z)}Ks(){return this.cache.getStats()}clearCache(){this.cache.clear(),this._s.clear(),this.Es.clear(),this.bs.clear()}}class gt{constructor(t,e){this.Qs=new Map,this.Yt=t,this.Xs=e}Zs(t,e,i,n,s,r,o){try{const r=[]
696
+ return t.forEach((t,o)=>{const a=this.tr(t,o,e,i,n,s)
697
+ r.push(a)}),r}finally{}}tr(e,i,n,s,r,o){const a=this.Yt.hb.createBuffer()
698
+ "rtl"===o&&a.er("rtl"),a.Wt(e.text),a.Ht()
684
699
  const h=t(this.Yt.Vt)
685
700
  this.Yt.hb.shape(this.Yt.font,a,h)
686
701
  const c=a.json(this.Yt.font)
687
702
  a.destroy()
688
703
  const l=[]
689
- let u=[],f=[],d=0,y=0,p=e.Dt,w=-i*n
690
- const g=s*this.Yt.upem,m=this.ar(e,r,s),v=this.hr(e,r),x=e.text,b=x.length,S=c.length
704
+ let u=[],f=[],d=0,p=0,y=e.Ut,w=-i*n
705
+ const g=s*this.Yt.upem,v=this.ir(e,r,s),m=this.nr(e,r),x=e.text,S=x.length,b=c.length
691
706
  let _
692
- for(let t=0;S>t;t++){const n=c[t],s=n.qt,r=x[s],o=r.charCodeAt(0),a=32===o||9===o||10===o||13===o
693
- n.Ns=e.$t&&s===b-1&&"-"===r?e.Bt:e.kt+s,n.Js=i,a&&u.length>0&&(l.push({text:f.join(""),glyphs:u,position:new J(d,y,0)}),u=[],f=[])
694
- const h=p+n.dx,E=w+n.dy
695
- if(a||(0===u.length&&(d=h,y=E),n.x=h-d,n.y=E-y,u.push(n),f.push(r)),p+=n.ax,w+=n.ay,0!==g&&S-1>t&&(p+=g),a&&(p+=m),0!==v&&S-1>t&&!a){const e=x[c[t+1].qt],i=void 0!==_?_:T.K(r)
707
+ for(let t=0;b>t;t++){const n=c[t],s=n.qt,r=x[s],o=r.charCodeAt(0),a=32===o||9===o||10===o||13===o
708
+ n.Us=e.Nt&&s===S-1&&"-"===r?e.Dt:e.kt+s,n.Hs=i,a&&u.length>0&&(l.push({text:f.join(""),glyphs:u,position:new J(d,p,0)}),u=[],f=[])
709
+ const h=y+n.dx,E=w+n.dy
710
+ if(a||(0===u.length&&(d=h,p=E),n.x=h-d,n.y=E-p,u.push(n),f.push(r)),y+=n.ax,w+=n.ay,0!==g&&b-1>t&&(y+=g),a&&(y+=v),0!==m&&b-1>t&&!a){const e=x[c[t+1].qt],i=void 0!==_?_:T.K(r)
696
711
  if(_=!!e&&T.K(e),i&&_){let t=!0
697
- T.X(e)&&(t=!1),T.Z(r)&&(t=!1),T.tt(r)&&T.tt(e)&&(t=!1),t&&(p+=v)}}else _=void 0}return u.length>0&&l.push({text:f.join(""),glyphs:u,position:new J(d,y,0)}),l}ar(t,e,i){let n=0
698
- if(void 0!==t.zt&&"justify"===e&&!t.Ut){let e=this.er.get(i)
699
- void 0===e&&(e=I.measureTextWidth(this.Yt," ",i),this.er.set(i,e)),t.zt>0?n=t.zt*e*.5:0>t.zt&&(n=t.zt*e*f)}return n}hr(t,e){if(void 0===t.zt||"justify"!==e||t.Ut)return 0
700
- return t.zt>0||0>t.zt?.04*t.zt*this.Yt.upem:0}clearCache(){this.ir.clearCache()}tr(){return this.ir.tr()}}var mt={exports:{}},vt=r(Object.freeze({__proto__:null,default:{},cr(){throw Error("fs not available in browser")}}))
712
+ T.X(e)&&(t=!1),T.Z(r)&&(t=!1),T.tt(r)&&T.tt(e)&&(t=!1),t&&(y+=m)}}else _=void 0}return u.length>0&&l.push({text:f.join(""),glyphs:u,position:new J(d,p,0)}),l}ir(t,e,i){let n=0
713
+ if(void 0!==t.jt&&"justify"===e&&!t.Bt){let e=this.Qs.get(i)
714
+ void 0===e&&(e=I.measureTextWidth(this.Yt," ",i),this.Qs.set(i,e)),t.jt>0?n=t.jt*e*.5:0>t.jt&&(n=t.jt*e*f)}return n}nr(t,e){if(void 0===t.jt||"justify"!==e||t.Bt)return 0
715
+ return t.jt>0||0>t.jt?.04*t.jt*this.Yt.upem:0}clearCache(){this.Xs.clearCache()}Ks(){return this.Xs.Ks()}}var vt={exports:{}},mt=r(Object.freeze({__proto__:null,default:{},sr(){throw Error("fs not available in browser")}}))
701
716
  !(function(t){var e,i=(e="undefined"!=typeof document?document.currentScript?.src:void 0,async function(t={}){function i(){var t=g.buffer
702
- s.HEAP8=new Int8Array(t),s.HEAPU8=m=new Uint8Array(t),s.HEAP32=new Int32Array(t),s.HEAPU32=new Uint32Array(t),s.HEAPF32=new Float32Array(t),new BigInt64Array(t),new BigUint64Array(t)}function n(t){s.lr?.(t),x(t="Aborted("+t+")"),b=!0,t+=". Build with -sASSERTIONS for more info."
717
+ s.HEAP8=new Int8Array(t),s.HEAPU8=v=new Uint8Array(t),s.HEAP32=new Int32Array(t),s.HEAPU32=new Uint32Array(t),s.HEAPF32=new Float32Array(t),new BigInt64Array(t),new BigUint64Array(t)}function n(t){s.rr?.(t),x(t="Aborted("+t+")"),S=!0,t+=". Build with -sASSERTIONS for more info."
703
718
  var e=new WebAssembly.RuntimeError(t)
704
719
  throw w?.(e),e}var s=t,r="object"==typeof window,o="undefined"!=typeof WorkerGlobalScope,a="object"==typeof process&&process.versions?.node&&"renderer"!=process.type,h=(t,e)=>{throw e}
705
720
  "undefined"!=typeof __filename?e=__filename:o&&(e=self.location.href)
706
721
  var c,l,u=""
707
- if(a){var f=vt
708
- u=__dirname+"/",l=t=>(t=S(t)?new URL(t):t,f.cr(t)),c=async(t,e=!0)=>(t=S(t)?new URL(t):t,f.cr(t,e?void 0:"utf8")),process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),h=(t,e)=>{throw process.exitCode=t,e}}else if(r||o){try{u=new URL(".",e).href}catch{}o&&(l=t=>{var e=new XMLHttpRequest
709
- return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),c=async t=>{if(S(t))return new Promise((e,i)=>{var n=new XMLHttpRequest
722
+ if(a){var f=mt
723
+ u=__dirname+"/",l=t=>(t=b(t)?new URL(t):t,f.sr(t)),c=async(t,e=!0)=>(t=b(t)?new URL(t):t,f.sr(t,e?void 0:"utf8")),process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),h=(t,e)=>{throw process.exitCode=t,e}}else if(r||o){try{u=new URL(".",e).href}catch{}o&&(l=t=>{var e=new XMLHttpRequest
724
+ return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),c=async t=>{if(b(t))return new Promise((e,i)=>{var n=new XMLHttpRequest
710
725
  n.open("GET",t,!0),n.responseType="arraybuffer",n.onload=()=>{200==n.status||0==n.status&&n.response?e(n.response):i(n.status)},n.onerror=i,n.send(null)})
711
726
  var e=await fetch(t,{credentials:"same-origin"})
712
727
  if(e.ok)return e.arrayBuffer()
713
728
  throw Error(e.status+" : "+e.url)}}console.log.bind(console)
714
- var d,y,p,w,g,m,v,x=console.error.bind(console),b=!1,S=t=>t.startsWith("file://"),_=!1,E=0,T=null
729
+ var d,p,y,w,g,v,m,x=console.error.bind(console),S=!1,b=t=>t.startsWith("file://"),_=!1,E=0,T=null
715
730
  class A{name="ExitStatus"
716
- constructor(t){this.message=`Program terminated with exit(${t})`,this.status=t}}var I,M,L,F=t=>{for(;t.length>0;)t.shift()(s)},G=[],O=t=>G.push(t),C=[],k=t=>C.push(t),B=!0,D=0,U={},$=t=>{if(t instanceof A||"unwind"==t)return y
717
- h(1,t)},P=()=>B||D>0,N=t=>{y=t,P()||(s.ur?.(t),b=!0),h(t,new A(t))},R=(t,e)=>Math.ceil(t/e)*e,j=t=>{var e=(t-g.buffer.byteLength+65535)/65536|0
718
- try{return g.grow(e),i(),1}catch(t){}},z=t=>{const e=t.length
719
- return[e%128|128,e>>7,...t]},W={ii:127,si:127,oi:126,f:125,d:124,e:111},H=t=>z(Array.from(t,t=>W[t])),V=t=>I.get(t),q=[],Y=(t,e)=>I.set(t,e)
720
- s.dr&&(B=s.dr),s.yr&&(x=s.yr),s.pr&&(d=s.pr),s.wr=g,s.gr=K,s.ls=(t,e)=>{var i=(t=>(M||(M=new WeakMap,((t,e)=>{if(M)for(var i=0;0+e>i;i++){var n=V(i)
731
+ constructor(t){this.message=`Program terminated with exit(${t})`,this.status=t}}var I,M,L,F=t=>{for(;t.length>0;)t.shift()(s)},G=[],O=t=>G.push(t),C=[],k=t=>C.push(t),D=!0,U=0,B={},N=t=>{if(t instanceof A||"unwind"==t)return p
732
+ h(1,t)},$=()=>D||U>0,P=t=>{p=t,$()||(s.ar?.(t),S=!0),h(t,new A(t))},R=(t,e)=>Math.ceil(t/e)*e,z=t=>{var e=(t-g.buffer.byteLength+65535)/65536|0
733
+ try{return g.grow(e),i(),1}catch(t){}},j=t=>{const e=t.length
734
+ return[e%128|128,e>>7,...t]},W={ii:127,si:127,oi:126,f:125,d:124,e:111},H=t=>j(Array.from(t,t=>W[t])),V=t=>I.get(t),q=[],Y=(t,e)=>I.set(t,e)
735
+ s.hr&&(D=s.hr),s.cr&&(x=s.cr),s.lr&&(d=s.lr),s.ur=g,s.dr=K,s.ns=(t,e)=>{var i=(t=>(M||(M=new WeakMap,((t,e)=>{if(M)for(var i=0;0+e>i;i++){var n=V(i)
721
736
  n&&M.set(n,i)}})(0,I.length)),M.get(t)||0))(t)
722
737
  if(i)return i
723
738
  var n=q.length?q.pop():I.grow(1)
724
739
  try{Y(n,t)}catch(i){if(!(i instanceof TypeError))throw i
725
- var s=((t,e)=>{var i=Uint8Array.of(0,97,115,109,1,0,0,0,1,...z([1,96,...H(e.slice(1)),...H("v"===e[0]?"":e[0])]),2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0),n=new WebAssembly.Module(i)
740
+ var s=((t,e)=>{var i=Uint8Array.of(0,97,115,109,1,0,0,0,1,...j([1,96,...H(e.slice(1)),...H("v"===e[0]?"":e[0])]),2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0),n=new WebAssembly.Module(i)
726
741
  return new WebAssembly.Instance(n,{e:{f:t}}).exports.f})(t,e)
727
- Y(n,s)}return M.set(t,n),n},s.xs=t=>{M.delete(V(t)),Y(t,null),q.push(t)}
728
- var J={mr:()=>n(""),vr(){B=!1,D=0},br(t,e){if(U[t]&&(clearTimeout(U[t].id),delete U[t]),!e)return 0
729
- var i=setTimeout(()=>{delete U[t],(t=>{if(!b)try{t(),(()=>{if(!P())try{y=t=y,N(t)}catch(t){$(t)}var t})()}catch(t){$(t)}})(()=>L(t,performance.now()))},e)
730
- return U[t]={id:i,Sr:e},0},_r(t){var e=m.length,i=2147483648
742
+ Y(n,s)}return M.set(t,n),n},s.ps=t=>{M.delete(V(t)),Y(t,null),q.push(t)}
743
+ var J={pr:()=>n(""),yr(){D=!1,U=0},wr(t,e){if(B[t]&&(clearTimeout(B[t].id),delete B[t]),!e)return 0
744
+ var i=setTimeout(()=>{delete B[t],(t=>{if(!S)try{t(),(()=>{if(!$())try{p=t=p,P(t)}catch(t){N(t)}var t})()}catch(t){N(t)}})(()=>L(t,performance.now()))},e)
745
+ return B[t]={id:i,gr:e},0},vr(t){var e=v.length,i=2147483648
731
746
  if((t>>>=0)>i)return!1
732
747
  for(var n=1;4>=n;n*=2){var s=e*(1+.2/n),r=Math.min(i,R(Math.max(t,s=Math.min(s,t+100663296)),65536))
733
- if(j(r))return!0}return!1},Er:N},K=await(async()=>{function t(t){return s.gr=K=t.exports,s.wr=g=K.memory,i(),I=K.Tr,(t=>{s.Ar=t.Ir,s.Mr=t.Lr,s.Fr=t.Gr,s.Or=t.Cr,s.kr=t.Br,s.Dr=t.Ur,s.$r=t.Pr,s.Nr=t.Rr,s.jr=t.zr,s.Wr=t.Hr,s.Vr=t.qr,s.Yr=t.Jr,s.Kr=t.Xr,s.Qr=t.Zr,s.eo=t.io,s.no=t.so,s.ro=t.oo,s.ao=t.ho,s.co=t.lo,s.uo=t.fo,s.do=t.yo,s.po=t.wo,s.mo=t.vo,s.xo=t.bo,s.So=t._o,s.Eo=t.To,s.Ao=t.Io,s.Mo=t.Lo,s.Fo=t.fs,s.Go=t.ds,s.Oo=t.ys,s.Co=t.ps,s.ko=t.ws,s.Bo=t.us,s.Do=t.vs,s.Uo=t.$o,s.Po=t.No,s.Ro=t.jo,s.zo=t.Wo,s.Ho=t.Vo,s.qo=t.Xs,s.Yo=t.Jo,s.Ko=t.Xo,s.Qo=t.Zo,s.ta=t.ea,s.ia=t.na,s.sa=t.ra,s.oa=t.aa,s.ha=t.ca,s.la=t.ua,s.fa=t.da,s.ya=t.pa,L=t.wa})(K),(()=>{if(E--,s.ga?.(E),0==E&&T){var t=T
734
- T=null,t()}})(),K}E++,s.ga?.(E)
735
- var e,r={o:J,ma:J}
736
- return s.va?new Promise(e=>{s.va(r,i=>{e(t(i))})}):(v??=(e="hb.wasm",s.xa?s.xa(e,u):u+e),t((await(async function(t,e,i){if(!t&&!S(e)&&!a)try{var s=fetch(e,{credentials:"same-origin"})
748
+ if(z(r))return!0}return!1},mr:P},K=await(async()=>{function t(t){return s.dr=K=t.exports,s.ur=g=K.memory,i(),I=K.Sr,(t=>{s.br=t._r,s.Er=t.Tr,s.Ar=t.Ir,s.Mr=t.Lr,s.Fr=t.Gr,s.Or=t.Cr,s.kr=t.Dr,s.Ur=t.Br,s.Nr=t.$r,s.Pr=t.Rr,s.zr=t.jr,s.Wr=t.Hr,s.Vr=t.qr,s.Yr=t.Jr,s.Kr=t.Qr,s.Xr=t.Zr,s.eo=t.io,s.no=t.so,s.ro=t.oo,s.ao=t.ho,s.co=t.lo,s.uo=t.fo,s.do=t.po,s.yo=t.wo,s.vo=t.mo,s.xo=t.So,s.bo=t._o,s.Eo=t.To,s.Ao=t.rs,s.Io=t.hs,s.Mo=t.cs,s.Lo=t.ls,s.Fo=t.us,s.Go=t.ss,s.Oo=t.ds,s.Co=t.ko,s.Do=t.Uo,s.Bo=t.No,s.$o=t.Po,s.Ro=t.zo,s.jo=t.qs,s.Wo=t.Ho,s.Vo=t.qo,s.Yo=t.Jo,s.Ko=t.Qo,s.Xo=t.Zo,s.ta=t.ea,s.ia=t.na,s.sa=t.ra,s.oa=t.aa,s.ha=t.ca,s.la=t.ua,L=t.fa})(K),(()=>{if(E--,s.da?.(E),0==E&&T){var t=T
749
+ T=null,t()}})(),K}E++,s.da?.(E)
750
+ var e,r={o:J,pa:J}
751
+ return s.ya?new Promise(e=>{s.ya(r,i=>{e(t(i))})}):(m??=(e="hb.wasm",s.wa?s.wa(e,u):u+e),t((await(async function(t,e,i){if(!t&&!b(e)&&!a)try{var s=fetch(e,{credentials:"same-origin"})
737
752
  return await WebAssembly.instantiateStreaming(s,i)}catch(t){x("wasm streaming compile failed: "+t),x("falling back to ArrayBuffer instantiation")}return(async(t,e)=>{try{var i=await(async t=>{if(!d)try{var e=await c(t)
738
- return new Uint8Array(e)}catch{}return(t=>{if(t==v&&d)return new Uint8Array(d)
753
+ return new Uint8Array(e)}catch{}return(t=>{if(t==m&&d)return new Uint8Array(d)
739
754
  if(l)return l(t)
740
755
  throw"both async and sync fetching of the wasm failed"})(t)})(t)
741
- return await WebAssembly.instantiate(i,e)}catch(t){x("failed to asynchronously prepare wasm: "+t),n(t)}})(e,i)})(d,v,r)).ba))})()
742
- return(()=>{if(s.Sa)for("function"==typeof s.Sa&&(s.Sa=[s.Sa]);s.Sa.length>0;)s.Sa.shift()()})(),(function t(){function e(){s._a=!0,b||(_=!0,K.Ea(),p?.(s),s.Ta?.(),(()=>{if(s.Aa)for("function"==typeof s.Aa&&(s.Aa=[s.Aa]);s.Aa.length;)O(s.Aa.shift())
743
- F(G)})())}E>0?T=t:((()=>{if(s.Ia)for("function"==typeof s.Ia&&(s.Ia=[s.Ia]);s.Ia.length;)k(s.Ia.shift())
744
- F(C)})(),E>0?T=t:s.setStatus?(s.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>s.setStatus(""),1),e()},1)):e())})(),_?s:new Promise((t,e)=>{p=t,w=e})})
745
- t.exports=i,t.exports.default=i})(mt)
746
- var xt=s(mt.exports),bt={exports:{}}
747
- try{bt.exports=t=>{function e(t){return(255&t.charCodeAt(0))<<24|(255&t.charCodeAt(1))<<16|(255&t.charCodeAt(2))<<8|255&t.charCodeAt(3)}function i(e){var i=s.Io(e.length+1)
756
+ return await WebAssembly.instantiate(i,e)}catch(t){x("failed to asynchronously prepare wasm: "+t),n(t)}})(e,i)})(d,m,r)).ga))})()
757
+ return(()=>{if(s.va)for("function"==typeof s.va&&(s.va=[s.va]);s.va.length>0;)s.va.shift()()})(),(function t(){function e(){s.ma=!0,S||(_=!0,K.xa(),y?.(s),s.Sa?.(),(()=>{if(s.ba)for("function"==typeof s.ba&&(s.ba=[s.ba]);s.ba.length;)O(s.ba.shift())
758
+ F(G)})())}E>0?T=t:((()=>{if(s._a)for("function"==typeof s._a&&(s._a=[s._a]);s._a.length;)k(s._a.shift())
759
+ F(C)})(),E>0?T=t:s.setStatus?(s.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>s.setStatus(""),1),e()},1)):e())})(),_?s:new Promise((t,e)=>{y=t,w=e})})
760
+ t.exports=i,t.exports.default=i})(vt)
761
+ var xt=s(vt.exports),St={exports:{}}
762
+ try{St.exports=t=>{function e(t){return(255&t.charCodeAt(0))<<24|(255&t.charCodeAt(1))<<16|(255&t.charCodeAt(2))<<8|255&t.charCodeAt(3)}function i(e){var i=s._o(e.length+1)
748
763
  for(let n=0;e.length>n;++n){const s=e.charCodeAt(n)
749
764
  if(s>127)throw Error("Expected ASCII text")
750
- t.HEAPU8[i+n]=s}return t.HEAPU8[i+e.length]=0,{Qs:i,length:e.length,Lo(){s.Lo(i)}}}function n(t,e,n){var r=0,o=0
751
- n&&(n=n.split(","),r=s.Io(16*n.length),n.forEach(t=>{var e=i(t)
752
- s.To(e.Qs,-1,r+16*o)&&o++,e.Lo()})),s.pa(t.Qs,e.Qs,r,o),r&&s.Lo(r)}var s=t.gr,r=new TextDecoder("utf8")
753
- let o=t.ls,a=t.xs
754
- var h=o(t=>{s.Lo(t)},"vi"),c=e("JSON"),l="",u=s.Io(256)
755
- return{De(e){var i=s.Io(e.byteLength)
765
+ t.HEAPU8[i+n]=s}return t.HEAPU8[i+e.length]=0,{Ys:i,length:e.length,To(){s.To(i)}}}function n(t,e,n){var r=0,o=0
766
+ n&&(n=n.split(","),r=s._o(16*n.length),n.forEach(t=>{var e=i(t)
767
+ s.So(e.Ys,-1,r+16*o)&&o++,e.To()})),s.ua(t.Ys,e.Ys,r,o),r&&s.To(r)}var s=t.dr,r=new TextDecoder("utf8")
768
+ let o=t.ns,a=t.ps
769
+ var h=o(t=>{s.To(t)},"vi"),c=e("JSON"),l="",u=s._o(256)
770
+ return{Ue(e){var i=s._o(e.byteLength)
756
771
  t.HEAPU8.set(new Uint8Array(e),i)
757
- var n=s.Ir(i,e.byteLength,2,i,h)
758
- return{Qs:n,destroy(){s.Lr(n)}}},Ue(i,n){var r=s.$o(i.Qs,n)
759
- const o=s.Wo(r)
760
- return{Qs:r,upem:o,Ma(i){var n=s.jo(r,e(i)),o=s.Gr(n)
761
- if(o){var a=s.Cr(n,null)
762
- return t.HEAPU8.subarray(a,a+o)}},Ne(){var e=s.Io(2048),i=s.Io(4)
763
- t.HEAPU32[i/4]=64,s.ca(r,0,i,e)
772
+ var n=s._r(i,e.byteLength,2,i,h)
773
+ return{Ys:n,destroy(){s.Tr(n)}}},Be(i,n){var r=s.ko(i.Ys,n)
774
+ const o=s.Po(r)
775
+ return{Ys:r,upem:o,Ea(i){var n=s.No(r,e(i)),o=s.Ir(n)
776
+ if(o){var a=s.Lr(n,null)
777
+ return t.HEAPU8.subarray(a,a+o)}},Pe(){var e=s._o(2048),i=s._o(4)
778
+ t.HEAPU32[i/4]=64,s.ra(r,0,i,e)
764
779
  var n={}
765
780
  return Array.from({length:t.HEAPU32[i/4]}).forEach((i,s)=>{var r
766
- n[(r=t.HEAPU32[e/4+8*s+1],""+String.fromCharCode(r>>24&255)+String.fromCharCode(r>>16&255)+String.fromCharCode(r>>8&255)+String.fromCharCode(255&r))]={min:t.HEAPF32[e/4+8*s+4],default:t.HEAPF32[e/4+8*s+5],max:t.HEAPF32[e/4+8*s+6]}}),s.Lo(i),s.Lo(e),n},La(){var e=s.ra()
767
- s.Vo(r,e)
768
- var i=(e=>{const i=s.ua(e),n=s.Io(i<<2),r=n>>2,o=t.HEAPU32.subarray(r,r+i)
769
- return t.HEAPU32.set(o,r),s.da(e,-1,n,i),o})(e)
770
- return s.aa(e),i},destroy(){s.No(r)}}},$e(i){function n(t){return c||(f=o((t,e,i,n,s)=>{l+=`M${n},${s}`},"viiiffi"),d=o((t,e,i,n,s)=>{l+=`L${n},${s}`},"viiiffi"),y=o((t,e,i,n,s,r,o,a,h)=>{l+=`C${n},${s} ${r},${o} ${a},${h}`},"viiiffffffi"),p=o((t,e,i,n,s,r,o)=>{l+=`Q${n},${s} ${r},${o}`},"viiiffffi"),w=o(()=>{l+="Z"},"viiii"),c=s.us(),s.fs(c,f,0,0),s.ds(c,d,0,0),s.ps(c,y,0,0),s.ys(c,p,0,0),s.ws(c,w,0,0)),l="",s.Xs(h,t,c,0),l}var h=s.Xo(i.Qs),c=null,f=null,d=null,y=null,p=null,w=null
771
- return{Qs:h,Fa(e){s.Jo(h,e,u,256)
781
+ n[(r=t.HEAPU32[e/4+8*s+1],""+String.fromCharCode(r>>24&255)+String.fromCharCode(r>>16&255)+String.fromCharCode(r>>8&255)+String.fromCharCode(255&r))]={min:t.HEAPF32[e/4+8*s+4],default:t.HEAPF32[e/4+8*s+5],max:t.HEAPF32[e/4+8*s+6]}}),s.To(i),s.To(e),n},Ta(){var e=s.ea()
782
+ s.zo(r,e)
783
+ var i=(e=>{const i=s.aa(e),n=s._o(i<<2),r=n>>2,o=t.HEAPU32.subarray(r,r+i)
784
+ return t.HEAPU32.set(o,r),s.ca(e,-1,n,i),o})(e)
785
+ return s.na(e),i},destroy(){s.Uo(r)}}},Ne(i){function n(t){return c||(f=o((t,e,i,n,s)=>{l+=`M${n},${s}`},"viiiffi"),d=o((t,e,i,n,s)=>{l+=`L${n},${s}`},"viiiffi"),p=o((t,e,i,n,s,r,o,a,h)=>{l+=`C${n},${s} ${r},${o} ${a},${h}`},"viiiffffffi"),y=o((t,e,i,n,s,r,o)=>{l+=`Q${n},${s} ${r},${o}`},"viiiffffi"),w=o(()=>{l+="Z"},"viiii"),c=s.ss(),s.rs(c,f,0,0),s.hs(c,d,0,0),s.ls(c,p,0,0),s.cs(c,y,0,0),s.us(c,w,0,0)),l="",s.qs(h,t,c,0),l}var h=s.qo(i.Ys),c=null,f=null,d=null,p=null,y=null,w=null
786
+ return{Ys:h,Aa(e){s.Ho(h,e,u,256)
772
787
  var i=t.HEAPU8.subarray(u,u+256)
773
- return r.decode(i.slice(0,i.indexOf(0)))},Ga:n,Oa:t=>n(t).replace(/([MLQCZ])/g,"|$1 ").split("|").filter(t=>t.length).map(t=>{var e=t.split(/[ ,]/g)
774
- return{type:e[0],values:e.slice(1).filter(t=>t.length).map(t=>+t)}}),setScale(t,e){s.na(h,t,e)},Pe(i){var n=Object.entries(i),r=s.Io(8*n.length)
775
- n.forEach((i,n)=>{t.HEAPU32[r/4+2*n+0]=e(i[0]),t.HEAPF32[r/4+2*n+1]=i[1]}),s.Zo(h,r,n.length),s.Lo(r)},destroy(){s.ea(h),c&&(s.vs(c),c=null,a(f),a(d),a(y),a(p),a(w))}}},createBuffer(){var e=s.Ur()
776
- return{Qs:e,Wt(i){const n=(e=>{const i=s.Io(2*e.length),n=new Uint16Array(t.wr.buffer,i,e.length)
788
+ return r.decode(i.slice(0,i.indexOf(0)))},Ia:n,Ma:t=>n(t).replace(/([MLQCZ])/g,"|$1 ").split("|").filter(t=>t.length).map(t=>{var e=t.split(/[ ,]/g)
789
+ return{type:e[0],values:e.slice(1).filter(t=>t.length).map(t=>+t)}}),setScale(t,e){s.Zo(h,t,e)},$e(i){var n=Object.entries(i),r=s._o(8*n.length)
790
+ n.forEach((i,n)=>{t.HEAPU32[r/4+2*n+0]=e(i[0]),t.HEAPF32[r/4+2*n+1]=i[1]}),s.Jo(h,r,n.length),s.To(r)},destroy(){s.Qo(h),c&&(s.ds(c),c=null,a(f),a(d),a(p),a(y),a(w))}}},createBuffer(){var e=s.Cr()
791
+ return{Ys:e,Wt(i){const n=(e=>{const i=s._o(2*e.length),n=new Uint16Array(t.ur.buffer,i,e.length)
777
792
  for(let t=0;n.length>t;++t)n[t]=e.charCodeAt(t)
778
- return{Qs:i,length:n.length,Lo(){s.Lo(i)}}})(i)
779
- s.fo(e,n.Qs,n.length,0,n.length),n.Lo()},Ht:()=>s.ho(e),rr(t){s.zr(e,{Ca:4,ka:5,Ba:6,Da:7}[t]||0)},Ua(t){var i=0
780
- t.forEach(t=>{i|=(t=>"BOT"==t?1:"EOT"==t?2:"PRESERVE_DEFAULT_IGNORABLES"==t?4:"REMOVE_DEFAULT_IGNORABLES"==t?8:"DO_NOT_INSERT_DOTTED_CIRCLE"==t?16:"PRODUCE_UNSAFE_TO_CONCAT"==t?64:0)(t)}),s.Jr(e,i)},$a(t){var n=i(t)
781
- s.qr(e,s.wo(n.Qs,-1)),n.Lo()},Pa(t){var n=i(t)
782
- s.Hr(e,s.vo(n.Qs,-1)),n.Lo()},Na(t){s.Xr(e,t)},json(){for(var i=s.Zr(e),n=[],r=s.io(e,0),o=r/4,a=s.so(e,0)/4,h=t.HEAPU32.subarray(o,o+5*i),c=t.HEAP32.subarray(a,a+5*i),l=0;i>l;++l)n.push({g:h[5*l+0],qt:h[5*l+2],ax:c[5*l+0],ay:c[5*l+1],dx:c[5*l+2],dy:c[5*l+3],flags:s.oo(r+20*l)})
783
- return n},destroy(){s.Pr(e)}}},shape:n,Ra(e,i,h,l,u){var f=[],d=0,y=!1,p=1048576,w=s.Io(p),g=o((e,i,n)=>{var o=r.decode(t.HEAPU8.subarray(n,t.HEAPU8.indexOf(0,n)))
784
- return o.startsWith("start table GSUB")?d=1:o.startsWith("start table GPOS")&&(d=2),d!=u&&(y=!1),0!=u&&d==u&&o.startsWith("end lookup "+l)&&(y=!0),y?0:(s.Br(e,0,s.Zr(e),w,p,0,i,c,4),f.push({ai:o,ui:JSON.parse(r.decode(t.HEAPU8.subarray(w,t.HEAPU8.indexOf(0,w)))),glyphs:2==s.Rr(e)}),1)},"iiiii")
785
- return s.yo(i.Qs,g,0,0),n(e,i,h),s.Lo(w),a(g),f},version(){var e=s.Io(12)
786
- s.bo(e,e+4,e+8)
787
- var i={ja:t.HEAPU32[e/4],za:t.HEAPU32[(e+4)/4],Wa:t.HEAPU32[(e+8)/4]}
788
- return s.Lo(e),i},Ha(){var e=s._o()
789
- return r.decode(t.HEAPU8.subarray(e,t.HEAPU8.indexOf(0,e)))}}}}catch(t){}var St=s(bt.exports)
793
+ return{Ys:i,length:n.length,To(){s.To(i)}}})(i)
794
+ s.ho(e,n.Ys,n.length,0,n.length),n.To()},Ht:()=>s.so(e),er(t){s.$r(e,{La:4,Fa:5,Ga:6,Oa:7}[t]||0)},Ca(t){var i=0
795
+ t.forEach(t=>{i|=(t=>"BOT"==t?1:"EOT"==t?2:"PRESERVE_DEFAULT_IGNORABLES"==t?4:"REMOVE_DEFAULT_IGNORABLES"==t?8:"DO_NOT_INSERT_DOTTED_CIRCLE"==t?16:"PRODUCE_UNSAFE_TO_CONCAT"==t?64:0)(t)}),s.Hr(e,i)},ka(t){var n=i(t)
796
+ s.jr(e,s.fo(n.Ys,-1)),n.To()},Da(t){var n=i(t)
797
+ s.Rr(e,s.po(n.Ys,-1)),n.To()},Ua(t){s.qr(e,t)},json(){for(var i=s.Jr(e),n=[],r=s.Qr(e,0),o=r/4,a=s.Zr(e,0)/4,h=t.HEAPU32.subarray(o,o+5*i),c=t.HEAP32.subarray(a,a+5*i),l=0;i>l;++l)n.push({g:h[5*l+0],qt:h[5*l+2],ax:c[5*l+0],ay:c[5*l+1],dx:c[5*l+2],dy:c[5*l+3],flags:s.io(r+20*l)})
798
+ return n},destroy(){s.Dr(e)}}},shape:n,Ba(e,i,h,l,u){var f=[],d=0,p=!1,y=1048576,w=s._o(y),g=o((e,i,n)=>{var o=r.decode(t.HEAPU8.subarray(n,t.HEAPU8.indexOf(0,n)))
799
+ return o.startsWith("start table GSUB")?d=1:o.startsWith("start table GPOS")&&(d=2),d!=u&&(p=!1),0!=u&&d==u&&o.startsWith("end lookup "+l)&&(p=!0),p?0:(s.Gr(e,0,s.Jr(e),w,y,0,i,c,4),f.push({ai:o,ui:JSON.parse(r.decode(t.HEAPU8.subarray(w,t.HEAPU8.indexOf(0,w)))),glyphs:2==s.Br(e)}),1)},"iiiii")
800
+ return s.lo(i.Ys,g,0,0),n(e,i,h),s.To(w),a(g),f},version(){var e=s._o(12)
801
+ s.wo(e,e+4,e+8)
802
+ var i={Na:t.HEAPU32[e/4],$a:t.HEAPU32[(e+4)/4],Pa:t.HEAPU32[(e+8)/4]}
803
+ return s.To(e),i},Ra(){var e=s.mo()
804
+ return r.decode(t.HEAPU8.subarray(e,t.HEAPU8.indexOf(0,e)))}}}}catch(t){}var bt=s(St.exports)
790
805
  let _t=null,Et=null,Tt=null
791
- const At={Va(t){Et=t,Tt=null,_t=null},qa(t){Tt=t,Et=null,_t=null},Ya:async()=>_t||(_t=new Promise(async(t,e)=>{try{const e={}
792
- if(Tt)e.pr=Tt
806
+ const At={za(t){Et=t,Tt=null,_t=null},ja(t){Tt=t,Et=null,_t=null},Wa:async()=>_t||(_t=new Promise(async(t,e)=>{try{const e={}
807
+ if(Tt)e.lr=Tt
793
808
  else{if(!Et)throw Error("HarfBuzz WASM path or buffer must be set before initialization.")
794
- e.xa=(t,e)=>t.endsWith(".wasm")?Et:e+t}const i=await xt(e)
795
- t({hb:St(i),module:{ls:i.ls,exports:i.gr,xs:i.xs}})}catch(t){e(Error("Failed to initialize HarfBuzz: "+t))}}),_t)}
796
- class It{constructor(t,e){this.text=t,this.Ja=new Map,e.forEach(t=>{const e=this.Ja.get(t.Ys)||[]
797
- e.push(t),this.Ja.set(t.Ys,e)})}Ka(t){const e=[]
798
- return t.Xa&&e.push(...this.Qa(t.Xa)),t.Za&&e.push(...this.th(t.Za)),e}Qa(t){const e=[]
809
+ e.wa=(t,e)=>t.endsWith(".wasm")?Et:e+t}const i=await xt(e)
810
+ t({hb:bt(i),module:{ns:i.ns,exports:i.dr,ps:i.ps}})}catch(t){e(Error("Failed to initialize HarfBuzz: "+t))}}),_t)}
811
+ class It{constructor(t,e){this.text=t,this.Ha=new Map,e.forEach(t=>{const e=this.Ha.get(t.Ws)||[]
812
+ e.push(t),this.Ha.set(t.Ws,e)})}Va(t){const e=[]
813
+ return t.qa&&e.push(...this.Ya(t.qa)),t.Ja&&e.push(...this.Ka(t.Ja)),e}Ya(t){const e=[]
799
814
  for(const i of t){let t=0
800
- for(;-1!==(t=this.text.indexOf(i,t));)e.push(this.createTextRange(t,t+i.length,i)),t+=i.length}return e}th(t){return t.map(t=>{const e=this.text.slice(t.start,t.end)
815
+ for(;-1!==(t=this.text.indexOf(i,t));)e.push(this.createTextRange(t,t+i.length,i)),t+=i.length}return e}Ka(t){return t.map(t=>{const e=this.text.slice(t.start,t.end)
801
816
  return this.createTextRange(t.start,t.end,e)})}createTextRange(t,e,i){const n=[],s=new Map
802
- for(let i=t;e>i;i++){const t=this.Ja.get(i)
817
+ for(let i=t;e>i;i++){const t=this.Ha.get(i)
803
818
  if(t)for(const e of t){n.push(e)
804
- const t=s.get(e.Js)||[]
805
- t.push(e),s.set(e.Js,t)}}return{start:t,end:e,eh:i,bounds:Array.from(s.values()).map(t=>this.ih(t)),glyphs:n,nh:Array.from(s.keys()).sort((t,e)=>t-e)}}ih(t){if(0===t.length)return{min:{x:0,y:0,z:0},max:{x:0,y:0,z:0}}
819
+ const t=s.get(e.Hs)||[]
820
+ t.push(e),s.set(e.Hs,t)}}return{start:t,end:e,Qa:i,bounds:Array.from(s.values()).map(t=>this.Xa(t)),glyphs:n,Za:Array.from(s.keys()).sort((t,e)=>t-e)}}Xa(t){if(0===t.length)return{min:{x:0,y:0,z:0},max:{x:0,y:0,z:0}}
806
821
  let e=1/0,i=1/0,n=1/0,s=-1/0,r=-1/0,o=-1/0
807
822
  for(const a of t)e>a.bounds.min.x&&(e=a.bounds.min.x),i>a.bounds.min.y&&(i=a.bounds.min.y),n>a.bounds.min.z&&(n=a.bounds.min.z),a.bounds.max.x>s&&(s=a.bounds.max.x),a.bounds.max.y>r&&(r=a.bounds.max.y),a.bounds.max.z>o&&(o=a.bounds.max.z)
808
823
  return{min:{x:e,y:i,z:n},max:{x:s,y:r,z:o}}}}const Mt=72
809
- class Lt{static{this.sh=new Map}static{this.rh=null}static{this.oh=new Map}static{this.ah=0}static{this.hh=1/0}static{this.uh=0}static fh(t){const e=Object.keys(t).sort()
824
+ class Lt{static{this.th=new Map}static{this.eh=null}static{this.ih=new Map}static{this.nh=0}static{this.sh=1/0}static{this.rh=0}static oh(t){const e=Object.keys(t).sort()
810
825
  let i=""
811
826
  for(let n=0;e.length>n;n++)n>0&&(i+=","),i+=e[n]+":"+t[e[n]]
812
- return i}constructor(){this.dh="",Lt.rh||(Lt.rh=At.Ya()),this.yh=new H(()=>Lt.rh)}static ph(t){At.Va(t),Lt.rh=null}static wh(t){At.qa(t),Lt.rh=null}static init(){return Lt.rh||(Lt.rh=At.Ya()),Lt.rh}static async create(t){if(!t.font)throw Error("Font is required. Specify options.font as a URL string or ArrayBuffer.")
813
- Lt.rh||(Lt.rh=At.Ya())
814
- const e=await Lt.gh(t),i=new Lt
815
- i.mh(e)
816
- const n=await i.xh(t),s=async e=>{const n={...t}
827
+ return i}constructor(){this.ah="",Lt.eh||(Lt.eh=At.Wa()),this.hh=new H(()=>Lt.eh)}static uh(t){At.za(t),Lt.eh=null}static fh(t){At.ja(t),Lt.eh=null}static init(){return Lt.eh||(Lt.eh=At.Wa()),Lt.eh}static async create(t){if(!t.font)throw Error("Font is required. Specify options.font as a URL string or ArrayBuffer.")
828
+ Lt.eh||(Lt.eh=At.Wa())
829
+ const e=await Lt.dh(t),i=new Lt
830
+ i.ph(e)
831
+ const n=await i.yh(t),s=async e=>{const n={...t}
817
832
  for(const t in e){const i=e[t]
818
- void 0!==i&&(n[t]=i)}if(void 0!==e.font||void 0!==e.Re||void 0!==e.Vt){const t=await Lt.gh(n)
819
- i.mh(t),i.bh()}return t=n,{...await i.xh(t),getLoadedFont(){return i.getLoadedFont()},getCacheSize(){return i.getCacheSize()},clearCache(){return i.clearCache()},measureTextWidth(t,e){return i.measureTextWidth(t,e)},update:s}}
820
- return{...n,getLoadedFont(){return i.getLoadedFont()},getCacheSize(){return i.getCacheSize()},clearCache(){return i.clearCache()},measureTextWidth(t,e){return i.measureTextWidth(t,e)},update:s}}static async gh(t){let e="string"==typeof t.font?t.font:"buffer-"+Lt.Sh(t.font)
821
- t.Re&&(e+="_var_"+Lt.fh(t.Re)),t.Vt&&(e+="_feat_"+Lt.fh(t.Vt))
822
- let i=Lt.oh.get(e)
823
- return i||(i=await Lt._h(e,t.font,t.Re,t.Vt)),i}static async _h(t,e,i,n){const s=new Lt
824
- await s.Be(e,i,n)
833
+ void 0!==i&&(n[t]=i)}if(void 0!==e.font||void 0!==e.Re||void 0!==e.Vt){const t=await Lt.dh(n)
834
+ i.ph(t),i.wh()}return t=n,{...await i.yh(t),getLoadedFont(){return i.getLoadedFont()},getCacheSize(){return i.getCacheSize()},clearCache(){return i.clearCache()},measureTextWidth(t,e){return i.measureTextWidth(t,e)},update:s}}
835
+ return{...n,getLoadedFont(){return i.getLoadedFont()},getCacheSize(){return i.getCacheSize()},clearCache(){return i.clearCache()},measureTextWidth(t,e){return i.measureTextWidth(t,e)},update:s}}static async dh(t){let e="string"==typeof t.font?t.font:"buffer-"+Lt.gh(t.font)
836
+ t.Re&&(e+="_var_"+Lt.oh(t.Re)),t.Vt&&(e+="_feat_"+Lt.oh(t.Vt))
837
+ let i=Lt.ih.get(e)
838
+ return i||(i=await Lt.mh(e,t.font,t.Re,t.Vt)),i}static async mh(t,e,i,n){const s=new Lt
839
+ await s.De(e,i,n)
825
840
  const r=s.getLoadedFont()
826
- return Lt.oh.set(t,r),Lt.Eh(r),Lt.Th(),r}static Eh(t){Lt.ah+=t.Ve?.byteLength??0}static Ah(t){const e=Lt.oh.get(t)
827
- e&&(Lt.ah-=e.Ve?.byteLength??0,0>Lt.ah&&(Lt.ah=0))}static Th(){if(Lt.hh!==1/0)for(;Lt.ah>Lt.hh&&Lt.oh.size>0;){const t=Lt.oh.keys().next().value
841
+ return Lt.ih.set(t,r),Lt.xh(r),Lt.Sh(),r}static xh(t){Lt.nh+=t.Ve?.byteLength??0}static bh(t){const e=Lt.ih.get(t)
842
+ e&&(Lt.nh-=e.Ve?.byteLength??0,0>Lt.nh&&(Lt.nh=0))}static Sh(){if(Lt.sh!==1/0)for(;Lt.nh>Lt.sh&&Lt.ih.size>0;){const t=Lt.ih.keys().next().value
828
843
  if(void 0===t)break
829
- Lt.Ah(t),Lt.oh.delete(t)}}static Sh(t){if(t){const e=new Uint8Array(t)
844
+ Lt.bh(t),Lt.ih.delete(t)}}static gh(t){if(t){const e=new Uint8Array(t)
830
845
  let i=2166136261
831
846
  const n=Math.min(32,e.length),s=Math.floor(e.length/n)
832
847
  for(let t=0;n>t;t++)i^=e[t*s],i=Math.imul(i,16777619)
833
- return i^=e.length,i=Math.imul(i,16777619),(i>>>0).toString(36)}return"c"+ ++Lt.uh}mh(t){this.Yt=t
834
- const e=Lt.Sh(t.Ve)
835
- this.dh="font_"+e,t.Re&&(this.dh+="_var_"+Lt.fh(t.Re)),t.Vt&&(this.dh+="_feat_"+Lt.fh(t.Vt))}async Be(t,e,i){Lt.rh||(Lt.rh=At.Ya()),await Lt.rh
848
+ return i^=e.length,i=Math.imul(i,16777619),(i>>>0).toString(36)}return"c"+ ++Lt.rh}ph(t){this.Yt=t
849
+ const e=Lt.gh(t.Ve)
850
+ this.ah="font_"+e,t.Re&&(this.ah+="_var_"+Lt.oh(t.Re)),t.Vt&&(this.ah+="_feat_"+Lt.oh(t.Vt))}async De(t,e,i){Lt.eh||(Lt.eh=At.Wa()),await Lt.eh
836
851
  const n="string"==typeof t?await fetch(t).then(e=>{if(!e.ok)throw Error(`Failed to load font from ${t}: HTTP ${e.status} ${e.statusText}`)
837
852
  return e.arrayBuffer()}):t
838
- try{this.Yt&&this.destroy(),this.Yt=await this.yh.Be(n,e),i&&(this.Yt.Vt=i)
839
- const t=Lt.Sh(n)
840
- this.dh="font_"+t,e&&(this.dh+="_var_"+Lt.fh(e)),i&&(this.dh+="_feat_"+Lt.fh(i))}catch(t){throw h.error("Failed to load font:",t),t}}async xh(t){try{if(!this.Yt)throw Error("Font not loaded. Use Text.create() with a font option.")
841
- const e=await this.Ih(t)
842
- this.Mh(e),this.Lh(t=e),this.ir||(this.ir=new wt(X,this.Yt),this.ir.Os(this.dh)),this.ir.gn(t.Fh),this.ir.Kn(t.Gh),this.Yt.font.setScale(this.Yt.upem,this.Yt.upem),this.Oh||(this.Oh=new gt(this.Yt,this.ir))
843
- const i=this.Ch(t),n=t.kh??this.Yt.je??!1,s=this.Oh.nr(i.lines,i.Bh,i.letterSpacing,i.align,i.direction,t.color,t.text)
844
- let r,o
845
- if(t.color&&"object"==typeof t.color&&!Array.isArray(t.color)&&(t.color.Xa||t.color.Za)){if(r=new Set,t.color.Xa){o=[]
846
- for(const e of Object.keys(t.color.Xa)){let i=0
847
- for(;-1!==(i=t.text.indexOf(e,i));){o.push({pattern:e,start:i,end:i+e.length})
848
- for(let t=i;i+e.length>t;t++)r.add(t)
849
- i+=e.length}}}if(t.color.Za)for(const e of t.color.Za)for(let t=e.start;e.end>t;t++)r.add(t)}const a=this.ir.ks(s,i.depth,n,this.Yt.h.ce,i.Dh,t.perGlyphAttributes??!1,r),h=this.Uh(a.vertices,a.normals,a.indices,a.qs,a.planeBounds,t,t.text,o)
850
- if(t.perGlyphAttributes){const t=this.$h(h.vertices.length/3,h.glyphs)
851
- h.glyphAttributes=t}return h}finally{}}async Ih(t){if(!1!==t.layout?.wt&&t.layout?.width){const e=t.layout?.language||"en-us"
852
- if(!t.layout?.xt?.[e])try{if(!Lt.sh.has(e)){const n=await i(e,t.layout?.Ph)
853
- Lt.sh.set(e,n)}return{...t,layout:{...t.layout,xt:{...t.layout?.xt,[e]:Lt.sh.get(e)}}}}catch(i){return h.warn(`Failed to load patterns for ${e}: ${i}`),{...t,layout:{...t.layout,wt:!1}}}}return t}Mh(t){if(!t.text)throw Error("Text content is required")
854
- const e=t.Nh??1e5
855
- if(t.text.length>e)throw Error(`Text exceeds ${e} character limit`)}Lh(t){t.Re&&this.Yt&&Lt.fh(t.Re)!==Lt.fh(this.Yt.Re||{})&&(this.Yt.font.Pe(t.Re),this.Yt.Re=t.Re)}Ch(t){if(!this.Yt)throw Error("Font not loaded. Use Text.create() with a font option")
856
- const{text:e,size:i=Mt,depth:n=0,lineHeight:s=1,letterSpacing:r=0,layout:o={}}=t,{width:a,direction:h="ltr",align:f=("rtl"===h?"right":"left"),gt:d=!0,wt:y=!0,language:p="en-us",St:w=c,_t:g=l,Et:m=u,Tt:v,xt:x,At:b,It:S,Mt:_,Lt:E,Ft:T,Gt:A,Ot:I}=o,L=this.Yt.upem/i
853
+ try{this.Yt&&this.destroy(),this.Yt=await this.hh.De(n,e),i&&(this.Yt.Vt=i)
854
+ const t=Lt.gh(n)
855
+ this.ah="font_"+t,e&&(this.ah+="_var_"+Lt.oh(e)),i&&(this.ah+="_feat_"+Lt.oh(i))}catch(t){throw h.error("Failed to load font:",t),t}}async yh(t){try{if(!this.Yt)throw Error("Font not loaded. Use Text.create() with a font option.")
856
+ const e=await this._h(t)
857
+ this.Eh(e),this.Th(t=e),this.Xs||(this.Xs=new wt(Q,this.Yt),this.Xs.Is(this.ah))
858
+ const i=null!=t.curveSteps&&t.curveSteps>0
859
+ this.Xs.cn(t.curveSteps),this.Xs.hn(i?void 0:t.curveFidelity),this.Xs.Hn(t.geometryOptimization),this.Yt.font.setScale(this.Yt.upem,this.Yt.upem),this.Ah||(this.Ah=new gt(this.Yt,this.Xs))
860
+ const n=this.Ih(t),s=t.Mh??this.Yt.ze??!1,r=this.Ah.Zs(n.lines,n.Lh,n.letterSpacing,n.align,n.direction,t.color,t.text)
861
+ let o,a
862
+ if(t.color&&"object"==typeof t.color&&!Array.isArray(t.color)&&(t.color.qa||t.color.Ja)){if(o=new Set,t.color.qa){a=[]
863
+ for(const e of Object.keys(t.color.qa)){let i=0
864
+ for(;-1!==(i=t.text.indexOf(e,i));){a.push({pattern:e,start:i,end:i+e.length})
865
+ for(let t=i;i+e.length>t;t++)o.add(t)
866
+ i+=e.length}}}if(t.color.Ja)for(const e of t.color.Ja)for(let t=e.start;e.end>t;t++)o.add(t)}const h=this.Xs.Ls(r,n.depth,s,this.Yt.h.ce,n.Fh,t.perGlyphAttributes??!1,o),c=this.Gh(h.vertices,h.normals,h.indices,h.js,h.planeBounds,t,t.text,a)
867
+ if(t.perGlyphAttributes){const t=this.Oh(c.vertices.length/3,c.glyphs)
868
+ c.glyphAttributes=t}return c}finally{}}async _h(t){if(!1!==t.layout?.wt&&t.layout?.width){const e=t.layout?.language||"en-us"
869
+ if(!t.layout?.xt?.[e])try{if(!Lt.th.has(e)){const n=await i(e,t.layout?.Ch)
870
+ Lt.th.set(e,n)}return{...t,layout:{...t.layout,xt:{...t.layout?.xt,[e]:Lt.th.get(e)}}}}catch(i){return h.warn(`Failed to load patterns for ${e}: ${i}`),{...t,layout:{...t.layout,wt:!1}}}}return t}Eh(t){if(!t.text)throw Error("Text content is required")
871
+ const e=t.kh??1e5
872
+ if(t.text.length>e)throw Error(`Text exceeds ${e} character limit`)}Th(t){t.Re&&this.Yt&&Lt.oh(t.Re)!==Lt.oh(this.Yt.Re||{})&&(this.Yt.font.$e(t.Re),this.Yt.Re=t.Re)}Ih(t){if(!this.Yt)throw Error("Font not loaded. Use Text.create() with a font option")
873
+ const{text:e,size:i=Mt,depth:n=0,lineHeight:s=1,letterSpacing:r=0,layout:o={}}=t,{width:a,direction:h="ltr",align:f=("rtl"===h?"right":"left"),gt:d=!0,wt:p=!0,language:y="en-us",bt:w=c,_t:g=l,Et:v=u,Tt:m,xt:x,At:S,It:b,Mt:_,Lt:E,Ft:T,Gt:A,Ot:I}=o,L=this.Yt.upem/i
857
874
  let F
858
875
  void 0!==a&&(F=a*L)
859
876
  const G=n*L,O=G>0?Math.max(G,25e-6*this.Yt.upem):0
860
- this.Rh||(this.Rh=new M(this.Yt))
861
- const C=this.Rh.Jt({text:e,width:F,align:f,direction:h,wt:y,language:p,gt:d,St:w,_t:g,Et:m,Tt:v,xt:x,At:b,It:S,Mt:_,Lt:E,Ft:T,Gt:A,Ot:I,letterSpacing:r}),k=z.Ie(this.Yt.h)
862
- return{lines:C.lines,Bh:(k.te-k.ee)*s,letterSpacing:r,align:f,direction:h,depth:O,size:i,Dh:1/L}}jh(t,e,i,n,s){const r=t.length/3,o=new Float32Array(3*r),a=[]
877
+ this.Dh||(this.Dh=new M(this.Yt))
878
+ const C=this.Dh.Jt({text:e,width:F,align:f,direction:h,wt:p,language:y,gt:d,bt:w,_t:g,Et:v,Tt:m,xt:x,At:S,It:b,Mt:_,Lt:E,Ft:T,Gt:A,Ot:I,letterSpacing:r}),k=j.Ie(this.Yt.h)
879
+ return{lines:C.lines,Lh:(k.te-k.ee)*s,letterSpacing:r,align:f,direction:h,depth:O,size:i,Fh:1/L}}Uh(t,e,i,n,s){const r=t.length/3,o=new Float32Array(3*r),a=[]
863
880
  if(Array.isArray(i)){for(let t=0;r>t;t++){const e=3*t
864
- o[e]=i[0],o[e+1]=i[1],o[e+2]=i[2]}a.push({start:0,end:n.length,eh:n,color:i,bounds:[],glyphs:e,nh:[...new Set(e.map(t=>t.Js))]})}else{const t=i.default||[1,1,1]
881
+ o[e]=i[0],o[e+1]=i[1],o[e+2]=i[2]}a.push({start:0,end:n.length,Qa:n,color:i,bounds:[],glyphs:e,Za:[...new Set(e.map(t=>t.Hs))]})}else{const t=i.default||[1,1,1]
865
882
  for(let e=0;o.length>e;e+=3)o[e]=t[0],o[e+1]=t[1],o[e+2]=t[2]
866
883
  let r
867
- if(i.Xa&&s||i.Za){r=new Map
868
- for(const t of e){const e=r.get(t.Ys)
869
- e?e.push(t):r.set(t.Ys,[t])}}if(i.Xa&&s&&r)for(const t of s){const e=i.Xa[t.pattern]
884
+ if(i.qa&&s||i.Ja){r=new Map
885
+ for(const t of e){const e=r.get(t.Ws)
886
+ e?e.push(t):r.set(t.Ws,[t])}}if(i.qa&&s&&r)for(const t of s){const e=i.qa[t.pattern]
870
887
  if(!e)continue
871
888
  const n=[],s=new Map
872
889
  for(let i=t.start;t.end>i;i++){const t=r.get(i)
873
890
  if(t)for(const i of t){n.push(i)
874
- const t=s.get(i.Js)
875
- t?t.push(i):s.set(i.Js,[i])
876
- for(let t=0;i.Ks>t;t++){const n=3*(i.Us+t)
877
- n>=0&&o.length>n&&(o[n]=e[0],o[n+1]=e[1],o[n+2]=e[2])}}}const h=Array.from(s.values()).map(t=>this.zh(t))
878
- a.push({start:t.start,end:t.end,eh:t.pattern,color:e,bounds:h,glyphs:n,nh:Array.from(s.keys()).sort((t,e)=>t-e)})}if(i.Za&&r)for(const t of i.Za){const e=[],i=new Map
891
+ const t=s.get(i.Hs)
892
+ t?t.push(i):s.set(i.Hs,[i])
893
+ for(let t=0;i.Vs>t;t++){const n=3*(i.Os+t)
894
+ n>=0&&o.length>n&&(o[n]=e[0],o[n+1]=e[1],o[n+2]=e[2])}}}const h=Array.from(s.values()).map(t=>this.Bh(t))
895
+ a.push({start:t.start,end:t.end,Qa:t.pattern,color:e,bounds:h,glyphs:n,Za:Array.from(s.keys()).sort((t,e)=>t-e)})}if(i.Ja&&r)for(const t of i.Ja){const e=[],i=new Map
879
896
  for(let n=t.start;t.end>n;n++){const s=r.get(n)
880
897
  if(s)for(const n of s){e.push(n)
881
- const s=i.get(n.Js)
882
- s?s.push(n):i.set(n.Js,[n])
883
- for(let e=0;n.Ks>e;e++){const i=3*(n.Us+e)
884
- i>=0&&o.length>i&&(o[i]=t.color[0],o[i+1]=t.color[1],o[i+2]=t.color[2])}}}const s=Array.from(i.values()).map(t=>this.zh(t))
885
- a.push({start:t.start,end:t.end,eh:n.slice(t.start,t.end),color:t.color,bounds:s,glyphs:e,nh:Array.from(i.keys()).sort((t,e)=>t-e)})}}return{colors:o,Wh:a}}zh(t){if(0===t.length)return{min:{x:0,y:0,z:0},max:{x:0,y:0,z:0}}
898
+ const s=i.get(n.Hs)
899
+ s?s.push(n):i.set(n.Hs,[n])
900
+ for(let e=0;n.Vs>e;e++){const i=3*(n.Os+e)
901
+ i>=0&&o.length>i&&(o[i]=t.color[0],o[i+1]=t.color[1],o[i+2]=t.color[2])}}}const s=Array.from(i.values()).map(t=>this.Bh(t))
902
+ a.push({start:t.start,end:t.end,Qa:n.slice(t.start,t.end),color:t.color,bounds:s,glyphs:e,Za:Array.from(i.keys()).sort((t,e)=>t-e)})}}return{colors:o,Nh:a}}Bh(t){if(0===t.length)return{min:{x:0,y:0,z:0},max:{x:0,y:0,z:0}}
886
903
  let e=1/0,i=1/0,n=1/0,s=-1/0,r=-1/0,o=-1/0
887
904
  for(const a of t)e>a.bounds.min.x&&(e=a.bounds.min.x),i>a.bounds.min.y&&(i=a.bounds.min.y),n>a.bounds.min.z&&(n=a.bounds.min.z),a.bounds.max.x>s&&(s=a.bounds.max.x),a.bounds.max.y>r&&(r=a.bounds.max.y),a.bounds.max.z>o&&(o=a.bounds.max.z)
888
- return{min:{x:e,y:i,z:n},max:{x:s,y:r,z:o}}}Uh(t,e,i,n,s,r,o,a){const{layout:h={}}=r,{width:c,align:l=("rtl"===h.direction?"right":"left")}=h
889
- this.Rh||(this.Rh=new M(this.Yt))
890
- const u=this.Rh.Qt({width:c,align:l,planeBounds:s}),f=u.offset
891
- if(s.min.x=u.Xt.min.x,s.max.x=u.Xt.max.x,0!==f){for(let e=0;t.length>e;e+=3)t[e]+=f
892
- for(let t=0;n.length>t;t++)n[t].bounds.min.x+=f,n[t].bounds.max.x+=f}let d,y
893
- if(r.color){const e=this.jh(t,n,r.color,r.text,a)
894
- d=e.colors,y=e.Wh}const p=this.ir.Xn()
895
- return{vertices:t,normals:e,indices:i,colors:d,glyphs:n,planeBounds:s,stats:{Hh:i.length/3,Vh:t.length/3,en:p.en,nn:p.nn,sn:p.sn},query:(()=>{let t=null
905
+ return{min:{x:e,y:i,z:n},max:{x:s,y:r,z:o}}}Gh(t,e,i,n,s,r,o,a){const{layout:h={}}=r,{width:c,align:l=("rtl"===h.direction?"right":"left")}=h
906
+ this.Dh||(this.Dh=new M(this.Yt))
907
+ const u=this.Dh.Xt({width:c,align:l,planeBounds:s}),f=u.offset
908
+ if(s.min.x=u.Qt.min.x,s.max.x=u.Qt.max.x,0!==f){for(let e=0;t.length>e;e+=3)t[e]+=f
909
+ for(let t=0;n.length>t;t++)n[t].bounds.min.x+=f,n[t].bounds.max.x+=f}let d,p
910
+ if(r.color){const e=this.Uh(t,n,r.color,r.text,a)
911
+ d=e.colors,p=e.Nh}const y=this.Xs.Vn()
912
+ return{vertices:t,normals:e,indices:i,colors:d,glyphs:n,planeBounds:s,stats:{trianglesGenerated:i.length/3,verticesGenerated:t.length/3,pointsRemovedByVisvalingam:y.pointsRemovedByVisvalingam,originalPointCount:y.originalPointCount},query:(()=>{let t=null
896
913
  return e=>{if(!o)throw Error("Original text not available for querying")
897
- return t||(t=new It(o,n)),t.Ka(e)}})(),Wh:y,glyphAttributes:void 0}}Me(){if(!this.Yt)throw Error("Font not loaded. Call loadFont() first")
898
- return z.Me(this.Yt.h)}static async qh(t,e){await Promise.all(t.map(async t=>{if(!Lt.sh.has(t))try{const n=await i(t,e)
899
- Lt.sh.set(t,n)}catch(e){h.warn(`Failed to pre-load patterns for ${t}: ${e}`)}}))}static Yh(t,e){Lt.sh.set(t,e)}static Jh(t){Lt.hh=t===1/0?1/0:1048576*Math.max(1,Math.floor(t)),Lt.Th()}getLoadedFont(){return this.Yt}measureTextWidth(t,e=0){if(!this.Yt)throw Error("Font not loaded. Call loadFont() first")
900
- return I.measureTextWidth(this.Yt,t,e)}getCacheSize(){return this.ir?this.ir.tr().size:0}clearCache(){this.ir&&this.ir.clearCache()}$h(t,e){const i=new Float32Array(3*t),n=new Float32Array(t),s=new Float32Array(t),r=new Float32Array(t),o=new Float32Array(t)
914
+ return t||(t=new It(o,n)),t.Va(e)}})(),Nh:p,glyphAttributes:void 0}}Me(){if(!this.Yt)throw Error("Font not loaded. Call loadFont() first")
915
+ return j.Me(this.Yt.h)}static async $h(t,e){await Promise.all(t.map(async t=>{if(!Lt.th.has(t))try{const n=await i(t,e)
916
+ Lt.th.set(t,n)}catch(e){h.warn(`Failed to pre-load patterns for ${t}: ${e}`)}}))}static Ph(t,e){Lt.th.set(t,e)}static Rh(t){Lt.sh=t===1/0?1/0:1048576*Math.max(1,Math.floor(t)),Lt.Sh()}getLoadedFont(){return this.Yt}measureTextWidth(t,e=0){if(!this.Yt)throw Error("Font not loaded. Call loadFont() first")
917
+ return I.measureTextWidth(this.Yt,t,e)}getCacheSize(){return this.Xs?this.Xs.Ks().size:0}clearCache(){this.Xs&&this.Xs.clearCache()}Oh(t,e){const i=new Float32Array(3*t),n=new Float32Array(t),s=new Float32Array(t),r=new Float32Array(t),o=new Float32Array(t)
901
918
  let a=1/0,h=-1/0
902
919
  for(let t=0;e.length>t;t++){const i=(e[t].bounds.min.x+e[t].bounds.max.x)/2
903
920
  a>i&&(a=i),i>h&&(h=i)}const c=h-a
904
- for(let h=0;e.length>h;h++){const l=e[h],u=(l.bounds.min.x+l.bounds.max.x)/2,f=(l.bounds.min.y+l.bounds.max.y)/2,d=(l.bounds.min.z+l.bounds.max.z)/2,y=l.bounds.min.y,p=c>0?(u-a)/c:0,w=l.Us,g=Math.min(w+l.Ks,t)
905
- if(g>w){n.fill(h,w,g),s.fill(l.Js,w,g),r.fill(p,w,g),o.fill(y,w,g)
906
- for(let t=3*w;3*g>t;t+=3)i[t]=u,i[t+1]=f,i[t+2]=d}}return{glyphCenter:i,glyphIndex:n,glyphLineIndex:s,glyphProgress:r,glyphBaselineY:o}}bh(){this.ir=void 0,this.Oh=void 0,this.Rh=void 0}destroy(){if(!this.Yt)return
921
+ for(let h=0;e.length>h;h++){const l=e[h],u=(l.bounds.min.x+l.bounds.max.x)/2,f=(l.bounds.min.y+l.bounds.max.y)/2,d=(l.bounds.min.z+l.bounds.max.z)/2,p=l.bounds.min.y,y=c>0?(u-a)/c:0,w=l.Os,g=Math.min(w+l.Vs,t)
922
+ if(g>w){n.fill(h,w,g),s.fill(l.Hs,w,g),r.fill(y,w,g),o.fill(p,w,g)
923
+ for(let t=3*w;3*g>t;t+=3)i[t]=u,i[t+1]=f,i[t+2]=d}}return{glyphCenter:i,glyphIndex:n,glyphLineIndex:s,glyphProgress:r,glyphBaselineY:o}}wh(){this.Xs=void 0,this.Ah=void 0,this.Dh=void 0}destroy(){if(!this.Yt)return
907
924
  const t=this.Yt
908
- try{H.qe(t)}catch(t){h.warn("Error destroying HarfBuzz objects:",t)}finally{this.Yt=void 0,this.Rh=void 0,this.Oh=void 0}}}exports.DEFAULT_CURVE_FIDELITY=lt,exports.FontMetadataExtractor=z,exports.Text=Lt,exports.createGlyphCache=()=>new K,exports.globalGlyphCache=X
925
+ try{H.qe(t)}catch(t){h.warn("Error destroying HarfBuzz objects:",t)}finally{this.Yt=void 0,this.Dh=void 0,this.Ah=void 0}}}exports.DEFAULT_CURVE_FIDELITY=lt,exports.FontMetadataExtractor=j,exports.Text=Lt,exports.createGlyphCache=()=>new K,exports.globalGlyphCache=Q