three-text 0.4.3 → 0.4.4

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