three-text 0.3.2 → 0.3.3

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.3.2
2
+ * three-text v0.3.3
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(!a)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.TIGHT=0]="TIGHT",t[t.NORMAL=1]="NORMAL",t[t.LOOSE=2]="LOOSE",t[t.VERY_LOOSE=3]="VERY_LOOSE"})(p||(p={}))
60
- class y{constructor(){this.L=new Map,this.M=[],this.I=new Set}getKey(t,e){return t<<2|e}F(t){const e=this.getKey(t.position,t.G),i=this.L.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.TIGHT=0]="TIGHT",t[t.NORMAL=1]="NORMAL",t[t.LOOSE=2]="LOOSE",t[t.VERY_LOOSE=3]="VERY_LOOSE"})(y||(y={}))
60
+ class p{constructor(){this.L=new Map,this.M=[],this.I=new Set}getKey(t,e){return t<<2|e}F(t){const e=this.getKey(t.position,t.G),i=this.L.get(e)
61
61
  i&&i.O>t.O?(i.O=t.O,i.k=t.k,i.D=t.D):i||(this.L.set(e,t),this.I.add(t),t.U=this.M.length,this.M.push(t))}$(t,e){return this.L.get(this.getKey(t,e))}N(){return this.M}P(t){if(t.active&&void 0!==t.U){t.active=!1
62
62
  const e=t.U,i=this.M.length-1
63
63
  if(e!==i){const t=this.M[i]
@@ -80,28 +80,28 @@ return c.push(...this.V(t,e,i,n,s,r,o,a,h)),c.push({type:d.GLUE,width:0,stretch:
80
80
  return void 0!==e&&(e>=19968&&40959>=e||e>=13312&&19903>=e||e>=131072&&173791>=e||e>=173824&&177983>=e||e>=177984&&178207>=e||e>=178208&&183983>=e||e>=63744&&64255>=e||e>=12352&&12447>=e||e>=12448&&12543>=e||e>=44032&&55215>=e||e>=4352&&4607>=e||e>=12592&&12687>=e||e>=43360&&43391>=e||e>=55216&&55295>=e||e>=65440&&65500>=e)}static X(t){const e=t.charCodeAt(0)
81
81
  return 12289===e||12290===e||65292===e||65294===e||65306===e||65307===e||65281===e||65311===e||65289===e||12305===e||65373===e||12301===e||12303===e||12297===e||12299===e||12309===e||12311===e||12313===e||12315===e||12540===e||8212===e||8230===e||8229===e}static Z(t){const e=t.charCodeAt(0)
82
82
  return 65288===e||12304===e||65371===e||12300===e||12302===e||12296===e||12298===e||12308===e||12310===e||12312===e||12314===e}static tt(t){return this.X(t)||this.Z(t)}static et(t,e,i,n,s=0,r){const o=[],a=Array.from(t),h=i?i(t):null
83
- let c,l,u,p=s
83
+ let c,l,u,y=s
84
84
  if(r)c=r.width,l=r.stretch,u=r.q
85
85
  else{const t=e("字")
86
86
  c=0,l=.04*t,u=.04*t}for(let t=0;a.length>t;t++){const i=a[t],n=a.length-1>t?a[t+1]:null
87
87
  if(/\s/.test(i)){const n=h?h[t]??e(i):e(i)
88
- o.push({type:d.GLUE,width:n,stretch:.5*n,q:n*f,text:i,Y:p}),p+=i.length
89
- continue}if(o.push({type:d.BOX,width:h?h[t]??e(i):e(i),text:i,Y:p}),p+=i.length,n&&!/\s/.test(n)){let t=!0
88
+ o.push({type:d.GLUE,width:n,stretch:.5*n,q:n*f,text:i,Y:y}),y+=i.length
89
+ continue}if(o.push({type:d.BOX,width:h?h[t]??e(i):e(i),text:i,Y:y}),y+=i.length,n&&!/\s/.test(n)){let t=!0
90
90
  this.X(n)&&(t=!1),this.Z(i)&&(t=!1)
91
91
  const e=this.tt(i)&&this.tt(n)
92
- t&&!e&&o.push({type:d.GLUE,width:c,stretch:l,q:u,text:"",Y:p})}}return o}static V(t,e,i,n,s,r,o,a,h){const c=[],l=Array.from(t)
93
- let u,f="",d=0,p=null,y=0
94
- const w=()=>{if(0!==f.length){if("cjk"===p){const t=this.et(f,e,i,h,d,(()=>{if(!u){const t=e("字")
92
+ t&&!e&&o.push({type:d.GLUE,width:c,stretch:l,q:u,text:"",Y:y})}}return o}static V(t,e,i,n,s,r,o,a,h){const c=[],l=Array.from(t)
93
+ let u,f="",d=0,y=null,p=0
94
+ const w=()=>{if(0!==f.length){if("cjk"===y){const t=this.et(f,e,i,h,d,(()=>{if(!u){const t=e("字")
95
95
  u={width:0,stretch:.04*t,q:.04*t}}return u})())
96
96
  c.push(...t)}else{const t=this.it(f,d,e,n,s,r,o,a,h)
97
- c.push(...t)}f="",p=null}}
97
+ c.push(...t)}f="",y=null}}
98
98
  for(let t=0;l.length>t;t++){const e=l[t],i=this.K(e)?"cjk":"word"
99
- null!==p&&p!==i&&(w(),d=y),null===p&&(p=i,d=y),f+=e,y+=e.length}return w(),c}static it(t,e,i,n,s,r,o,a,h){const c=[],l=t.match(/\S+|\s+/g)||[]
99
+ null!==y&&y!==i&&(w(),d=p),null===y&&(y=i,d=p),f+=e,p+=e.length}return w(),c}static it(t,e,i,n,s,r,o,a,h){const c=[],l=t.match(/\S+|\s+/g)||[]
100
100
  let u=0
101
- for(let t=0;l.length>t;t++){const p=l[t],y=e+u
102
- if(/\s+/.test(p)){const t=i(p)
103
- c.push({type:d.GLUE,width:t,stretch:.5*t,q:t*f,text:p,Y:y}),u+=p.length}else{const t=p.split(/(-)/)
104
- let e=y
101
+ for(let t=0;l.length>t;t++){const y=l[t],p=e+u
102
+ if(/\s+/.test(y)){const t=i(y)
103
+ c.push({type:d.GLUE,width:t,stretch:.5*t,q:t*f,text:y,Y:p}),u+=y.length}else{const t=y.split(/(-)/)
104
+ let e=p
105
105
  for(let l=0;t.length>l;l++){const u=t[l]
106
106
  if(u)if("-"===u)c.push({type:d.DISCRETIONARY,width:i("-"),nt:"-",st:"",rt:"-",ot:i("-"),J:h?.ht??g,ct:!0,text:"-",Y:e}),e+=1
107
107
  else{if(u.includes("­")){const t=u.split("­")
@@ -112,33 +112,33 @@ if(t.length>0){let n=0
112
112
  for(const s of t){const t=u.substring(n,s)
113
113
  c.push({type:d.BOX,width:i(t),text:t,Y:e+n}),c.push({type:d.DISCRETIONARY,width:0,nt:"-",st:"",rt:"",ot:i("-"),J:h?.lt??w,ct:!0,text:"",Y:e+s}),n=s}const s=u.substring(n)
114
114
  c.push({type:d.BOX,width:i(s),text:s,Y:e+n})}else c.push({type:d.BOX,width:i(u),text:u,Y:e})}else c.push({type:d.BOX,width:i(u),text:u,Y:e})
115
- e+=u.length}}u+=p.length}}return c}static ut(t,e,i,n){let s=0
115
+ e+=u.length}}u+=y.length}}return c}static ut(t,e,i,n){let s=0
116
116
  for(let r=0;e.length-1>r;r++){const o=e[r]
117
117
  let a=0
118
118
  for(let e=s;o>e;e++)t[e].type!==d.PENALTY&&(a+=t[e].width)
119
119
  if(a>0&&n>a/i)return!0
120
- s=o+1}return!1}static ft(t){const{text:e,width:i,align:n="left",direction:s="ltr",dt:r=!1,language:o="en-us",yt:a=!0,measureText:f,wt:d,gt:p,vt:y,letterSpacing:b=0,xt:L=c,bt:M=l,St:I=u,_t:F,Et:G=S,Tt:O=_,At:k=m,Lt:C=x,Mt:D=w,It:B=g,Ft:U=v,Gt:$=0,Ot:N=!1,kt:P=T}=t
120
+ s=o+1}return!1}static ft(t){const{text:e,width:i,align:n="left",direction:s="ltr",dt:r=!1,language:o="en-us",yt:a=!0,measureText:f,wt:d,gt:y,vt:p,letterSpacing:b=0,xt:L=c,bt:M=l,St:I=u,_t:F,Et:G=S,Tt:O=_,At:k=m,Lt:C=x,Mt:D=w,It:B=g,Ft:U=v,Gt:$=0,Ot:N=!1,kt:P=T}=t
121
121
  if(a&&e.includes("\n")){const i=e.split("\n"),n=[]
122
122
  let s=0
123
123
  for(const e of i){if(0===e.length)n.push({text:"",Ct:s,Dt:s,Bt:0,Ut:!0,naturalWidth:0,$t:!1})
124
124
  else{const i=A.ft({...t,text:e,yt:!1})
125
125
  i.forEach(t=>{t.Ct+=s,t.Dt+=s}),n.push(...i)}s+=e.length+1}return n}let R=r
126
- !R||p&&p[o]||(h.warn(`Hyphenation patterns for ${o} not available`),R=!1)
126
+ !R||y&&y[o]||(h.warn(`Hyphenation patterns for ${o} not available`),R=!1)
127
127
  let W=I
128
128
  void 0!==F&&i?W=i*F:!R&&I===u&&i&&(W=.1*i)
129
- const j={Nt:k,Pt:C,Rt:U,lt:D,ht:B,Wt:n,vt:y,jt:y?b*y:0}
129
+ const j={Nt:k,Pt:C,Rt:U,lt:D,ht:B,Wt:n,vt:p,jt:p?b*p:0}
130
130
  if(!i||i===1/0){const t=f(e)
131
- return[{text:e,Ct:0,Dt:e.length-1,Bt:0,Ut:!0,naturalWidth:t,$t:!1}]}const z=A.H(e,f,d,!1,o,p,G,O,j)
131
+ return[{text:e,Ct:0,Dt:e.length-1,Bt:0,Ut:!0,naturalWidth:t,$t:!1}]}const z=A.H(e,f,d,!1,o,y,G,O,j)
132
132
  if(0===z.length)return[]
133
133
  let H=0,V=W,q=null
134
134
  const Y=!N
135
135
  for(;5>H;){let t=z,r=A.zt(t,i,M,$,!1,0,j)
136
- if(0===r.length&&R&&(t=A.H(e,f,d,!0,o,p,G,O,j),r=A.zt(t,i,L,$,!1,0,j)),0===r.length&&(V=W+H*i*.1,r=A.zt(t,i,L,$,!0,V,j)),0===r.length&&(r=A.zt(t,i,E,$,!0,V,j)),r.length>0){const o=A.Ht(t)
136
+ if(0===r.length&&R&&(t=A.H(e,f,d,!0,o,y,G,O,j),r=A.zt(t,i,L,$,!1,0,j)),0===r.length&&(V=W+H*i*.1,r=A.zt(t,i,L,$,!0,V,j)),0===r.length&&(r=A.zt(t,i,E,$,!0,V,j)),r.length>0){const o=A.Ht(t)
137
137
  if(q=A.Vt(e,t,r,i,n,s,o,j),Y&&r.length>1&&A.ut(t,r,i,P)){H++
138
138
  continue}break}break}if(q&&q.length>0)return q
139
139
  const J=f(e)
140
- return[{text:e,Ct:0,Dt:e.length-1,Bt:0,qt:0,Ut:!0,naturalWidth:J,$t:!1}]}static zt(t,e,i=1/0,n=0,s=!1,r=0,o){const a=A.Ht(t),h=new y,c={value:1/0}
141
- h.F({position:0,line:0,G:p.NORMAL,O:0,D:0,k:null,active:!0})
140
+ return[{text:e,Ct:0,Dt:e.length-1,Bt:0,qt:0,Ut:!0,naturalWidth:J,$t:!1}]}static zt(t,e,i=1/0,n=0,s=!1,r=0,o){const a=A.Ht(t),h=new p,c={value:1/0}
141
+ h.F({position:0,line:0,G:y.NORMAL,O:0,D:0,k:null,active:!0})
142
142
  for(let n=0;t.length>n;n++){const l=t[n]
143
143
  l.type===d.PENALTY&&1/0>l.J&&A.Yt(t,h,n,e,i,r,a,o,s,c),l.type===d.DISCRETIONARY&&1/0>l.J&&A.Yt(t,h,n,e,i,r,a,o,s,c),l.type===d.GLUE&&n>0&&t[n-1].type===d.BOX&&A.Yt(t,h,n,e,i,r,a,o,s,c),A.Jt(h,n,e,a.Kt)}const l=[]
144
144
  let u=null
@@ -153,30 +153,30 @@ const t=i.line-e
153
153
  r>t&&t>=n||t>r&&n>=t?(u=i,r=t,o=i.O):t===r&&o>i.O&&(u=i,o=i.O)}if(!s&&r!==n&&u)return[]}if(!u)return[]
154
154
  for(;u&&u.position>0;)l.unshift(u.position),u=u.k
155
155
  return l}static Yt(t,e,i,n,s=1/0,r=0,o,a,h=!1,c={value:1/0}){const l=-1/0>=(t[i].type===d.PENALTY?t[i].J:0),u=e.N()
156
- for(let f=0;u.length>f;f++){const p=u[f]
157
- if(!p.active)continue
158
- const y=A.Xt(t,p.position,i,p.line,n,o,a),{ratio:w,Qt:g,stretch:v,q:m,D:x}=y
156
+ for(let f=0;u.length>f;f++){const y=u[f]
157
+ if(!y.active)continue
158
+ const p=A.Xt(t,y.position,i,y.line,n,o,a),{ratio:w,Qt:g,stretch:v,q:m,D:x}=p
159
159
  let S
160
160
  if(g>0){const t=v+r
161
161
  S=t>0?A.R(g,t):10001}else S=0>g?m>0?-g>m?10001:A.R(-g,m):10001:0
162
- const _=h&&l&&c.value===1/0&&1===u.length&&p.active
162
+ const _=h&&l&&c.value===1/0&&1===u.length&&y.active
163
163
  if(!l&&!_&&-1>w)continue
164
164
  const E=A.Zt(S,g>0)
165
165
  if(!l&&!_&&S>s)continue
166
166
  let T=0,L=0,M=(a?.Nt??0)+S,I=1e4>Math.abs(M)?M*M:1e8
167
167
  const F=_,G=t[i].type===d.PENALTY||t[i].type===d.DISCRETIONARY?t[i].J:0
168
- 0!==G&&(G>0?I+=G*G:G>b&&(I-=G*G)),(t[i].type===d.PENALTY&&t[i].ct||t[i].type===d.DISCRETIONARY&&t[i].ct)&&p.position>0&&(t[p.position].type===d.PENALTY&&t[p.position].ct||t[p.position].type===d.DISCRETIONARY&&t[p.position].ct)&&(T=a?.Rt??0,I+=T),Math.abs(E-p.G)>1&&(L=a?.Pt??0,I+=L),(l||F)&&(I=0)
169
- const O=p.O+I
168
+ 0!==G&&(G>0?I+=G*G:G>b&&(I-=G*G)),(t[i].type===d.PENALTY&&t[i].ct||t[i].type===d.DISCRETIONARY&&t[i].ct)&&y.position>0&&(t[y.position].type===d.PENALTY&&t[y.position].ct||t[y.position].type===d.DISCRETIONARY&&t[y.position].ct)&&(T=a?.Rt??0,I+=T),Math.abs(E-y.G)>1&&(L=a?.Pt??0,I+=L),(l||F)&&(I=0)
169
+ const O=y.O+I
170
170
  c.value>O&&(c.value=O)
171
171
  let k=e.$(i,E)
172
- k?k.O>O&&(k.O=O,k.k=p,k.D=x):e.F({position:i,line:p.line+1,G:E,O,D:x,k:p,active:!0})}}static Xt(t,e,i,n,s,r,o){let a=0,h=0,c=0
172
+ k?k.O>O&&(k.O=O,k.k=y,k.D=x):e.F({position:i,line:y.line+1,G:E,O,D:x,k:y,active:!0})}}static Xt(t,e,i,n,s,r,o){let a=0,h=0,c=0
173
173
  if(r){a=r.te[i]-r.te[e],h=r.ee[i]-r.ee[e],c=r.ie[i]-r.ie[e]
174
174
  for(let n=e;i>n;n++){const e=t[n]
175
175
  e.type===d.PENALTY&&(a-=e.width)}}else for(let n=e;i>n;n++){const e=t[n]
176
176
  e.type!==d.PENALTY&&(a+=e.width,e.type===d.GLUE&&(h+=e.stretch,c+=e.q))}i>=t.length||t[i].type!==d.PENALTY&&t[i].type!==d.DISCRETIONARY||(a+=t[i].type===d.PENALTY?t[i].width:t[i].ot),o?.jt&&0!==a&&(a-=o.jt)
177
177
  const l=s-a
178
178
  let u
179
- return u=l>0&&h>0?l/h:0>l&&c>0?l/c:0===l?0:l>0?3:-1,{ratio:u,Qt:l,stretch:h,q:c,D:a}}static Zt(t,e){return e?t>12?t>99?p.VERY_LOOSE:p.LOOSE:p.NORMAL:t>12?p.TIGHT:p.NORMAL}static Ht(t){const e=t.length+1,i=Array(e),n=Array(e),s=Array(e),r=Array(e)
179
+ return u=l>0&&h>0?l/h:0>l&&c>0?l/c:0===l?0:l>0?3:-1,{ratio:u,Qt:l,stretch:h,q:c,D:a}}static Zt(t,e){return e?t>12?t>99?y.VERY_LOOSE:y.LOOSE:y.NORMAL:t>12?y.TIGHT:y.NORMAL}static Ht(t){const e=t.length+1,i=Array(e),n=Array(e),s=Array(e),r=Array(e)
180
180
  i[0]=0,n[0]=0,s[0]=0,r[0]=0
181
181
  for(let e=0;t.length>e;e++){const o=t[e]
182
182
  if(i[e+1]=i[e]+o.width,o.type===d.PENALTY)n[e+1]=n[e],s[e+1]=s[e],r[e+1]=r[e]
@@ -187,24 +187,24 @@ o.active&&n[e]-n[o.position]>i&&t.P(o)}}static Vt(t,e,i,n,s,r,o,a){if(0===i.leng
187
187
  const h=[]
188
188
  let c=0
189
189
  for(let t=0;i.length>t;t++){const l=i[t],u=!(e.length-1>i[i.length-1]+1)&&t===i.length-1,f=[]
190
- let p=-1,y=-1,w=0
190
+ let y=-1,p=-1,w=0
191
191
  for(let t=c;l>t;t++){const i=e[t]
192
- if((i.type!==d.PENALTY||i.text)&&(i.type!==d.DISCRETIONARY||i.rt)){if(void 0!==i.Y){(-1===p||p>i.Y)&&(p=i.Y)
192
+ if((i.type!==d.PENALTY||i.text)&&(i.type!==d.DISCRETIONARY||i.rt)){if(void 0!==i.Y){(-1===y||y>i.Y)&&(y=i.Y)
193
193
  const t=i.Y+(i.text?i.text.length:0)-1
194
- t>y&&(y=t)}i.text?f.push(i.text):i.type===d.DISCRETIONARY&&i.rt&&f.push(i.rt),w+=i.width}}const g=e[l]
194
+ t>p&&(p=t)}i.text?f.push(i.text):i.type===d.DISCRETIONARY&&i.rt&&f.push(i.rt),w+=i.width}}const g=e[l]
195
195
  let v=!1
196
- if(e.length>l)if(g.type===d.PENALTY&&g.ct)f.push("-"),w+=g.width,v=!0,void 0!==g.Y&&(y=g.Y-1)
196
+ if(e.length>l)if(g.type===d.PENALTY&&g.ct)f.push("-"),w+=g.width,v=!0,void 0!==g.Y&&(p=g.Y-1)
197
197
  else if(g.type===d.DISCRETIONARY){const t=g
198
- t.nt&&(f.push(t.nt),w+=t.ot,v=t.ct||!1,void 0!==g.Y&&(y=g.Y-1))}const m=f.join("")
198
+ t.nt&&(f.push(t.nt),w+=t.ot,v=t.ct||!1,void 0!==g.Y&&(p=g.Y-1))}const m=f.join("")
199
199
  a?.jt&&0!==w&&(w-=a.jt)
200
200
  let x=0,b=0,S=s
201
- "justify"===s&&u&&(S="rtl"===r?"right":"left"),"center"===S?x=(n-w)/2:"right"===S?x=n-w:"justify"!==S||u||(b=A.Xt(e,c,l,t,n,o,a).ratio),h.push({text:m,Ct:p,Dt:y,Bt:x,qt:b,Ut:!1,naturalWidth:w,$t:v}),c=l+1}if(e.length-1>c){const t=[]
201
+ "justify"===s&&u&&(S="rtl"===r?"right":"left"),"center"===S?x=(n-w)/2:"right"===S?x=n-w:"justify"!==S||u||(b=A.Xt(e,c,l,t,n,o,a).ratio),h.push({text:m,Ct:y,Dt:p,Bt:x,qt:b,Ut:!1,naturalWidth:w,$t:v}),c=l+1}if(e.length-1>c){const t=[]
202
202
  let i=-1,o=-1,l=0
203
203
  for(let n=c;e.length-1>n;n++){const s=e[n]
204
204
  s.type!==d.PENALTY&&(void 0!==s.Y&&((-1===i||i>s.Y)&&(i=s.Y),s.Y>o&&(o=s.Y)),s.text&&t.push(s.text),l+=s.width)}const u=t.join("")
205
205
  a?.jt&&0!==l&&(l-=a.jt)
206
- let f=0,p=s
207
- "justify"===s&&(p="rtl"===r?"right":"left"),"center"===p?f=(n-l)/2:"right"===p&&(f=n-l),h.push({text:u,Ct:i,Dt:o,Bt:f,qt:0,Ut:!0,naturalWidth:l,$t:!1}),h.length>1&&(h[h.length-2].Ut=!1),h[h.length-1].Ut=!0}else h.length>0&&(h[h.length-1].Ut=!0)
206
+ let f=0,y=s
207
+ "justify"===s&&(y="rtl"===r?"right":"left"),"center"===y?f=(n-l)/2:"right"===y&&(f=n-l),h.push({text:u,Ct:i,Dt:o,Bt:f,qt:0,Ut:!0,naturalWidth:l,$t:!1}),h.length>1&&(h[h.length-2].Ut=!1),h[h.length-1].Ut=!0}else h.length>0&&(h[h.length-1].Ut=!0)
208
208
  return h}}const L=new WeakMap
209
209
  class M{static wt(e,i,n=0){const s=Array.from(i)
210
210
  if(0===s.length)return[]
@@ -226,9 +226,9 @@ const r=t(e.re)
226
226
  e.hb.shape(e.font,s,r)
227
227
  const o=s.json(e.font),a=n*e.upem
228
228
  let h=0
229
- return o.forEach(t=>{h+=t.ax,0!==a&&(h+=a)}),s.destroy(),h}}class I{constructor(t){this.ae=t}he(t){const{text:e,width:i,align:n,direction:s,dt:r,language:o,yt:a,xt:h,bt:c,St:l,_t:u,gt:f,Et:d,Tt:p,At:y,Lt:w,Mt:g,It:v,Ft:m,Gt:x,Ot:b,kt:S,letterSpacing:_}=t
229
+ return o.forEach(t=>{h+=t.ax,0!==a&&(h+=a)}),s.destroy(),h}}class I{constructor(t){this.ae=t}he(t){const{text:e,width:i,align:n,direction:s,dt:r,language:o,yt:a,xt:h,bt:c,St:l,_t:u,gt:f,Et:d,Tt:y,At:p,Lt:w,Mt:g,It:v,Ft:m,Gt:x,Ot:b,kt:S,letterSpacing:_}=t
230
230
  let E
231
- if(i)E=A.ft({text:e,width:i,align:n,direction:s,dt:r,language:o,yt:a,xt:h,bt:c,St:l,_t:u,gt:f,Et:d,Tt:p,At:y,Lt:w,Mt:g,It:v,Ft:m,Gt:x,Ot:b,kt:S,vt:this.ae.upem,letterSpacing:_,measureText:t=>M.measureTextWidth(this.ae,t,_),wt:t=>M.wt(this.ae,t,_)})
231
+ if(i)E=A.ft({text:e,width:i,align:n,direction:s,dt:r,language:o,yt:a,xt:h,bt:c,St:l,_t:u,gt:f,Et:d,Tt:y,At:p,Lt:w,Mt:g,It:v,Ft:m,Gt:x,Ot:b,kt:S,vt:this.ae.upem,letterSpacing:_,measureText:t=>M.measureTextWidth(this.ae,t,_),wt:t=>M.wt(this.ae,t,_)})
232
232
  else{const t=e.split("\n")
233
233
  E=[]
234
234
  let i=0
@@ -243,11 +243,11 @@ const i=new DataView(t),n=i.getUint32(0)
243
243
  if(![F,G].includes(n))throw Error("Invalid font format. Expected TTF/OTF (or WOFF), got signature: 0x"+n.toString(16))
244
244
  const s=e(i),r=s.has(N)||s.has(P),o=s.get(k)?.offset??0,a=s.get(C)?.offset??0,h=s.get(D)?.offset??0,c=s.get(B)?.offset??0,l=s.get(U)?.offset??0,u=s.get($)?.offset??0,f=o?i.getUint16(o+18):1e3
245
245
  let d=null
246
- a&&(d={de:i.getInt16(a+4),pe:i.getInt16(a+6),ye:i.getInt16(a+8)})
247
- let p=null
248
- h&&(p={we:i.getInt16(h+68),ge:i.getInt16(h+70),ve:i.getInt16(h+72),me:i.getUint16(h+74),xe:i.getUint16(h+76)})
246
+ a&&(d={de:i.getInt16(a+4),ye:i.getInt16(a+6),pe:i.getInt16(a+8)})
249
247
  let y=null
250
- return c&&l&&u&&(y=this.be(i,l,u)),{Se:r,vt:f,_e:d?.de||null,Ee:d?.pe||null,Te:d?.ye||null,we:p?.we||null,ge:p?.ge||null,ve:p?.ve||null,me:p?.me||null,xe:p?.xe||null,Ae:y}}static Le(t){const i=new DataView(t),n=e(i),s=n.get(R)?.offset??0,r=n.get(W)?.offset??0,o=n.get($)?.offset??0,a=new Set,h={}
248
+ h&&(y={we:i.getInt16(h+68),ge:i.getInt16(h+70),ve:i.getInt16(h+72),me:i.getUint16(h+74),xe:i.getUint16(h+76)})
249
+ let p=null
250
+ return c&&l&&u&&(p=this.be(i,l,u)),{Se:r,vt:f,_e:d?.de||null,Ee:d?.ye||null,Te:d?.pe||null,we:y?.we||null,ge:y?.ge||null,ve:y?.ve||null,me:y?.me||null,xe:y?.xe||null,Ae:p}}static Le(t){const i=new DataView(t),n=e(i),s=n.get(R)?.offset??0,r=n.get(W)?.offset??0,o=n.get($)?.offset??0,a=new Set,h={}
251
251
  try{if(s){const t=this.Me(i,s,o)
252
252
  t.features.forEach(t=>a.add(t)),Object.assign(h,t.names)}if(r){const t=this.Me(i,r,o)
253
253
  t.features.forEach(t=>a.add(t)),Object.assign(h,t.names)}}catch(t){return}const c=Array.from(a).sort()
@@ -277,11 +277,11 @@ if(!n)return null
277
277
  try{const e=new Uint8Array(t.buffer,n.offset,n.length)
278
278
  return 0===n.Ce||3===n.Ce&&1===n.De?j.decode(e):new TextDecoder("ascii").decode(e)}catch{return null}}static Oe(t,e,i){const n=e.has(N)||e.has(P),s=e.get(k)?.offset??0,r=e.get(C)?.offset??0,o=e.get(D)?.offset??0,a=e.get(B)?.offset??0,h=e.get(U)?.offset??0,c=s?t.getUint16(s+18):1e3
279
279
  let l=null
280
- r&&(l={de:t.getInt16(r+4),pe:t.getInt16(r+6),ye:t.getInt16(r+8)})
280
+ r&&(l={de:t.getInt16(r+4),ye:t.getInt16(r+6),pe:t.getInt16(r+8)})
281
281
  let u=null
282
282
  o&&(u={we:t.getInt16(o+68),ge:t.getInt16(o+70),ve:t.getInt16(o+72),me:t.getUint16(o+74),xe:t.getUint16(o+76)})
283
283
  let f=null
284
- return a&&h&&i&&(f=this.Ue(t,h,i)),{Se:n,vt:c,_e:l?.de||null,Ee:l?.pe||null,Te:l?.ye||null,we:u?.we||null,ge:u?.ge||null,ve:u?.ve||null,me:u?.me||null,xe:u?.xe||null,Ae:f}}static Ue(t,e,i){try{if(1>t.getUint16(e))return null
284
+ return a&&h&&i&&(f=this.Ue(t,h,i)),{Se:n,vt:c,_e:l?.de||null,Ee:l?.ye||null,Te:l?.pe||null,we:u?.we||null,ge:u?.ge||null,ve:u?.ve||null,me:u?.me||null,xe:u?.xe||null,Ae:f}}static Ue(t,e,i){try{if(1>t.getUint16(e))return null
285
285
  const n=t.getUint16(e+4),s=t.getUint16(e+6),r=t.getUint32(e+8),o={}
286
286
  for(let a=0;s>a;a++){const s=e+r+a*n,h=String.fromCharCode(t.getUint8(s),t.getUint8(s+1),t.getUint8(s+2),t.getUint8(s+3)),c=t.getUint16(s+4),l=this.Be(t,i,c)
287
287
  l&&(o[h]=l)}return Object.keys(o).length>0?o:null}catch{return null}}static ke(t,e,i){const n=e.get(R)?.offset??0,s=e.get(W)?.offset??0,r=new Set,o={}
@@ -297,9 +297,9 @@ const u=r+t.getUint16(o+4),f=t.getUint16(u)
297
297
  if(0===f)continue
298
298
  const d=u+f
299
299
  if(0!==t.getUint16(d))continue
300
- const p=t.getUint16(d+2),y=this.Be(t,i,p)
301
- y&&(s[String.fromCharCode(a>>24&255,a>>16&255,a>>8&255,255&a)]=y)}}static Ne(t){return String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,255&t)}static Pe(t){return null!==t.we&&null!==t.ge?{de:t.we,pe:t.ge,ye:0}:null!==t._e&&null!==t.Ee?{de:t._e,pe:t.Ee,ye:0}:null!==t.me&&null!==t.xe?{de:t.me,pe:-t.xe,ye:0}:{de:Math.round(.8*t.vt),pe:-Math.round(.2*t.vt),ye:0}}static Re(t){const e=z.Pe(t)
302
- return{de:e.de,pe:e.pe,ye:e.ye,vt:t.vt,We:e.de-e.pe}}}class H{static je(t){if(4>t.byteLength)return"ttf/otf"
300
+ const y=t.getUint16(d+2),p=this.Be(t,i,y)
301
+ p&&(s[String.fromCharCode(a>>24&255,a>>16&255,a>>8&255,255&a)]=p)}}static Ne(t){return String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,255&t)}static Pe(t){return null!==t.we&&null!==t.ge?{de:t.we,ye:t.ge,pe:0}:null!==t._e&&null!==t.Ee?{de:t._e,ye:t.Ee,pe:0}:null!==t.me&&null!==t.xe?{de:t.me,ye:-t.xe,pe:0}:{de:Math.round(.8*t.vt),ye:-Math.round(.2*t.vt),pe:0}}static Re(t){const e=z.Pe(t)
302
+ return{de:e.de,ye:e.ye,pe:e.pe,vt:t.vt,We:e.de-e.ye}}}class H{static je(t){if(4>t.byteLength)return"ttf/otf"
303
303
  const e=new DataView(t).getUint32(0)
304
304
  return e===O?"woff":2001684018===e?"woff2":"ttf/otf"}static async ze(t){const e=new DataView(t),i=new Uint8Array(t)
305
305
  if(e.getUint32(0)!==O)throw Error("Not a valid WOFF font")
@@ -348,24 +348,24 @@ 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
348
348
  return n+s>0?(e.b-i.b)*n+(e.b-t.b)*s:0}function h(t){return i(t.b.a,t.a)}function c(t){return i(t.a,t.b.a)}function l(t,e,i,n){return(t=0>t?0:t)>(i=0>i?0:i)?n+i/(t+i)*(e-n):0===i?(e+n)/2:e+t/(t+i)*(n-e)}function u(t){var e=w(t.b)
349
349
  return v(e,t.c),v(e.b,t.c),m(e,t.a),e}function f(t,e){var i=!1,n=!1
350
350
  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
351
- 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
352
- 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
353
- 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.pi
354
- return i.pi=n,n.b.pi=e,e.pi=t,t.b.pi=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
351
+ 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
352
+ 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
353
+ 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.yi
354
+ return i.yi=n,n.b.yi=e,e.yi=t,t.b.yi=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
355
355
  i.b.e=e,n.b.e=t,t.c=n,e.c=i}function v(t,e){var i=e.f,n=new Q(e,i)
356
356
  i.e=n,e.f=n,i=n.c=t
357
357
  do{i.a=n,i=i.c}while(i!==t)}function m(t,e){var i=e.d,n=new Y(e,i)
358
358
  i.b=n,e.d=n,n.a=t,n.c=e.c,i=t
359
- do{i.d=n,i=i.e}while(i!==t)}function x(t){var e=t.pi
360
- e.b.pi=t=t.b.pi,t.b.pi=e}function b(t,e){var i=t.c,n=i
359
+ do{i.d=n,i=i.e}while(i!==t)}function x(t){var e=t.yi
360
+ e.b.yi=t=t.b.yi,t.b.yi=e}function b(t,e){var i=t.c,n=i
361
361
  do{n.a=e,n=n.c}while(n!==i);(n=t.e).f=i=t.f,i.e=n}function S(t,e){var i=t.a,n=i
362
362
  do{n.d=e,n=n.e}while(n!==i);(n=t.b).d=i=t.d,i.b=n}function _(t){var e=0
363
- return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e}function E(t,e){t.f+=e.f,t.b.f+=e.b.f}function T(t,e,r){return r=r.a,(e=e.a).b.a===(t=t.a)?r.b.a===t?i(e.a,r.a)?0>=s(r.b.a,e.a,r.a):s(e.b.a,r.a,e.a)>=0:0>=s(r.b.a,t,r.a):r.b.a===t?s(e.b.a,t,e.a)>=0:(e=n(e.b.a,t,e.a))>=(t=n(r.b.a,t,r.a))}function A(t){t.a.yi=null
363
+ return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e}function E(t,e){t.f+=e.f,t.b.f+=e.b.f}function T(t,e,r){return r=r.a,(e=e.a).b.a===(t=t.a)?r.b.a===t?i(e.a,r.a)?0>=s(r.b.a,e.a,r.a):s(e.b.a,r.a,e.a)>=0:0>=s(r.b.a,t,r.a):r.b.a===t?s(e.b.a,t,e.a)>=0:(e=n(e.b.a,t,e.a))>=(t=n(r.b.a,t,r.a))}function A(t){t.a.pi=null
364
364
  var e=t.e
365
- e.a.c=e.c,e.c.a=e.a,t.e=null}function L(t,e){d(t.a),t.c=!1,t.a=e,e.yi=t}function M(t){var e=t.a.a
365
+ e.a.c=e.c,e.c.a=e.a,t.e=null}function L(t,e){d(t.a),t.c=!1,t.a=e,e.pi=t}function M(t){var e=t.a.a
366
366
  do{t=ut(t)}while(t.a.a===e)
367
- return t.c&&(L(t,e=y(lt(t).a.b,t.a.e)),t=ut(t)),t}function I(t,e,i){var n=new ct
368
- return n.a=i,n.e=j(t.f,e.e,n),i.yi=n}function F(t,e){switch(t.s){case 100130:return!!(1&e)
367
+ return t.c&&(L(t,e=p(lt(t).a.b,t.a.e)),t=ut(t)),t}function I(t,e,i){var n=new ct
368
+ return n.a=i,n.e=j(t.f,e.e,n),i.pi=n}function F(t,e){switch(t.s){case 100130:return!!(1&e)
369
369
  case 100131:return 0!==e
370
370
  case 100132:return e>0
371
371
  case 100133:return 0>e
@@ -373,7 +373,7 @@ case 100134:return e>=2||-2>=e}return!1}function G(t){var e=t.a,i=e.d
373
373
  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
374
374
  var n=lt(t),s=n.a
375
375
  if(s.a!==e.a){if(!n.c){G(t)
376
- break}L(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 k(t,e,i,n,s,r){var o=!0
376
+ break}L(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 k(t,e,i,n,s,r){var o=!0
377
377
  do{I(t,e,i.b),i=i.c}while(i!==n)
378
378
  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
379
379
  e.b=!0,r&&N(t,e)}function C(t,e,i,n,s){var r=[e.g[0],e.g[1],e.g[2]]
@@ -382,46 +382,46 @@ n[0]=e.a.d,n[1]=i.a.d,C(t,e.a,n,[.5,.5,0,0],!1),f(e,i)}function B(t,e,i,n,s){var
382
382
  n[s]=.5*o/(r+o),n[a]=.5*r/(r+o),t.g[0]+=n[s]*e.g[0]+n[a]*i.g[0],t.g[1]+=n[s]*e.g[1]+n[a]*i.g[1],t.g[2]+=n[s]*e.g[2]+n[a]*i.g[2]}function U(t,n){var r=lt(n),o=n.a,a=r.a
383
383
  if(i(o.a,a.a)){if(s(a.b.a,o.a,a.a)>0)return!1
384
384
  if(e(o.a,a.a)){if(o.a!==a.a){r=t.e
385
- var h=o.a.pi
385
+ var h=o.a.yi
386
386
  if(0>h)for(r.c[-(h+1)]=null;r.a>0&&null===r.c[r.d[r.a-1]];)--r.a
387
387
  else{var c=(r=r.b).d,l=r.e,u=r.c,d=u[h]
388
- c[d]=c[r.a],u[c[d]]=d,d<=--r.a&&(d>1?i(l[c[d>>1]],l[c[d]])?at(r,d):ht(r,d):at(r,d)),l[h]=null,u[h]=r.b,r.b=h}D(t,K(a),o)}}else p(a.b),f(o,K(a)),n.b=r.b=!0}else{if(0>s(o.b.a,a.a,o.a))return!1
389
- ut(n).b=n.b=!0,p(o.b),f(K(a),o)}return!0}function $(t,h){var c=lt(h),u=h.a,d=c.a,y=u.a,w=d.a,g=u.b.a,v=d.b.a,m=new Q
390
- 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
391
- if(i(y,w)){if(s(v,y,w)>0)return!1}else if(0>s(g,w,y))return!1
392
- var x,b,S=g,_=y,E=v,T=w
393
- 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=a(S,E,_))+(b=-a(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 U(t,h),!1
394
- if(!e(g,t.a)&&s(g,t.a,m)>=0||!e(v,t.a)&&0>=s(v,t.a,m)){if(v===t.a)return p(u.b),f(d.b,u),u=lt(h=M(h)).a,O(t,lt(h),c),k(t,h,K(u),u,u,!0),!0
395
- if(g===t.a){p(d.b),f(u.e,K(d)),w=(y=c=h).a.b.a
396
- do{y=ut(y)}while(y.a.b.a===w)
397
- return y=lt(h=y).a.b.c,c.a=K(d),k(t,h,(d=O(t,c,null)).c,u.b.c,y,!0),!0}return s(g,t.a,m)>=0&&(ut(h).b=h.b=!0,p(u.b),u.a.b=t.a.b,u.a.a=t.a.a),0>=s(v,t.a,m)&&(h.b=c.b=!0,p(d.b),d.a.b=t.a.b,d.a.a=t.a.a),!1}return p(u.b),p(d.b),f(K(d),u),u.a.b=m.b,u.a.a=m.a,u.a.pi=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,B(u,y,g,d,0),B(u,w,v,d,2),C(t,u,m,d,!0),ut(h).b=h.b=c.b=!0,!1}function N(t,e){for(var n=lt(e);;){for(;n.b;)e=n,n=lt(n)
388
+ c[d]=c[r.a],u[c[d]]=d,d<=--r.a&&(d>1?i(l[c[d>>1]],l[c[d]])?at(r,d):ht(r,d):at(r,d)),l[h]=null,u[h]=r.b,r.b=h}D(t,K(a),o)}}else y(a.b),f(o,K(a)),n.b=r.b=!0}else{if(0>s(o.b.a,a.a,o.a))return!1
389
+ ut(n).b=n.b=!0,y(o.b),f(K(a),o)}return!0}function $(t,h){var c=lt(h),u=h.a,d=c.a,p=u.a,w=d.a,g=u.b.a,v=d.b.a,m=new Q
390
+ 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
391
+ if(i(p,w)){if(s(v,p,w)>0)return!1}else if(0>s(g,w,p))return!1
392
+ var x,b,S=g,_=p,E=v,T=w
393
+ 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=a(S,E,_))+(b=-a(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,h),!1
394
+ 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(h=M(h)).a,O(t,lt(h),c),k(t,h,K(u),u,u,!0),!0
395
+ if(g===t.a){y(d.b),f(u.e,K(d)),w=(p=c=h).a.b.a
396
+ do{p=ut(p)}while(p.a.b.a===w)
397
+ return p=lt(h=p).a.b.c,c.a=K(d),k(t,h,(d=O(t,c,null)).c,u.b.c,p,!0),!0}return s(g,t.a,m)>=0&&(ut(h).b=h.b=!0,y(u.b),u.a.b=t.a.b,u.a.a=t.a.a),0>=s(v,t.a,m)&&(h.b=c.b=!0,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.yi=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),C(t,u,m,d,!0),ut(h).b=h.b=c.b=!0,!1}function N(t,e){for(var n=lt(e);;){for(;n.b;)e=n,n=lt(n)
398
398
  if(!e.b&&(n=e,null===(e=ut(e))||!e.b))break
399
399
  e.b=!1
400
400
  var r,o=e.a,a=n.a
401
401
  if(r=o.b.a!==a.b.a)t:{var h=lt(r=e),c=r.a,l=h.a,u=void 0
402
402
  if(i(c.b.a,l.b.a)){if(0>s(c.b.a,l.b.a,c.a)){r=!1
403
- 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
404
- break t}r.b=h.b=!0,u=p(l),f(c.e,l.b),u.b.d.c=r.d}r=!0}if(r&&(n.c?(A(n),d(a),a=(n=lt(e)).a):e.c&&(A(e),d(o),o=(e=ut(n)).a)),o.a!==a.a)if(o.b.a===a.b.a||e.c||n.c||o.b.a!==t.a&&a.b.a!==t.a)U(t,e)
403
+ 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
404
+ break t}r.b=h.b=!0,u=y(l),f(c.e,l.b),u.b.d.c=r.d}r=!0}if(r&&(n.c?(A(n),d(a),a=(n=lt(e)).a):e.c&&(A(e),d(o),o=(e=ut(n)).a)),o.a!==a.a)if(o.b.a===a.b.a||e.c||n.c||o.b.a!==t.a&&a.b.a!==t.a)U(t,e)
405
405
  else if($(t,e))break
406
406
  o.a===a.a&&o.b.a===a.b.a&&(E(a,o),A(e),d(o),e=ut(n))}}function P(t,n){t.a=n
407
- for(var r=n.c;null===r.yi;)if((r=r.c)===n.c){r=t
407
+ for(var r=n.c;null===r.pi;)if((r=r.c)===n.c){r=t
408
408
  var o=n;(u=new ct).a=o.c.b
409
409
  var a=(l=r.f).a
410
410
  do{a=a.a}while(null!==a.b&&!l.c(l.b,u,a.b))
411
- if(a=(c=lt(l=a.b)).a,0===s((u=l.a).b.a,o,u.a))e((u=l.a).a,o)||e(u.b.a,o)||(p(u.b),l.c&&(d(u.c),l.c=!1),f(o.c,u),P(r,o))
411
+ if(a=(c=lt(l=a.b)).a,0===s((u=l.a).b.a,o,u.a))e((u=l.a).a,o)||e(u.b.a,o)||(y(u.b),l.c&&(d(u.c),l.c=!1),f(o.c,u),P(r,o))
412
412
  else{var h=i(a.b.a,u.b.a)?l:c,c=void 0
413
- l.d||h.c?(c=h===l?y(o.c.b,u.e):y(a.b.c.b,o.c).b,h.c?L(h,c):(u=r,(l=I(r,l,c)).f=ut(l).f+l.a.f,l.d=F(u,l.f)),P(r,o)):k(r,l,o.c,o.c,null,!0)}return}if(l=(u=lt(r=M(r.yi))).a,(u=O(t,u,null)).c===l){var l,u=(l=u).c,w=(a=lt(r),!1);(c=r.a).b.a!==(h=a.a).b.a&&$(t,r),e(c.a,t.a)&&(f(K(u),c),u=lt(r=M(r)).a,O(t,lt(r),a),w=!0),e(h.a,t.a)&&(f(l,K(h)),l=O(t,a,null),w=!0),w?k(t,r,l.c,u,u,!0):(o=i(h.a,c.a)?K(h):c,k(t,r,o=y(l.c.b,o),o.c,o.c,!1),o.b.yi.c=!0,N(t,r))}else k(t,r,u.c,l,l,!0)}function R(t,e){var i=new ct,n=u(t.b)
414
- 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.pi=!0,i.b=!1,n=j(n=t.f,n.a,i),i.e=n}function W(t){this.a=new z,this.b=t,this.c=T}function j(t,e,i){do{e=e.c}while(null!==e.b&&!t.c(t.b,e.b,i))
415
- return t=new z(i,e.a,e),e.a.c=t,e.a=t}function z(t,e,i){this.b=t||null,this.a=e||this,this.c=i||this}function H(){this.d=pt,this.gi=this.b=this.mi=null,this.xi=[0,0,0],this.s=100130,this.n=!1,this.wi=this.a=this.e=this.f=null,this.bi=!1,this.c=this.r=this.yi=this.Si=this._i=this.pi=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.Ei(null)
413
+ l.d||h.c?(c=h===l?p(o.c.b,u.e):p(a.b.c.b,o.c).b,h.c?L(h,c):(u=r,(l=I(r,l,c)).f=ut(l).f+l.a.f,l.d=F(u,l.f)),P(r,o)):k(r,l,o.c,o.c,null,!0)}return}if(l=(u=lt(r=M(r.pi))).a,(u=O(t,u,null)).c===l){var l,u=(l=u).c,w=(a=lt(r),!1);(c=r.a).b.a!==(h=a.a).b.a&&$(t,r),e(c.a,t.a)&&(f(K(u),c),u=lt(r=M(r)).a,O(t,lt(r),a),w=!0),e(h.a,t.a)&&(f(l,K(h)),l=O(t,a,null),w=!0),w?k(t,r,l.c,u,u,!0):(o=i(h.a,c.a)?K(h):c,k(t,r,o=p(l.c.b,o),o.c,o.c,!1),o.b.pi.c=!0,N(t,r))}else k(t,r,u.c,l,l,!0)}function R(t,e){var i=new ct,n=u(t.b)
414
+ 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.yi=!0,i.b=!1,n=j(n=t.f,n.a,i),i.e=n}function W(t){this.a=new z,this.b=t,this.c=T}function j(t,e,i){do{e=e.c}while(null!==e.b&&!t.c(t.b,e.b,i))
415
+ return t=new z(i,e.a,e),e.a.c=t,e.a=t}function z(t,e,i){this.b=t||null,this.a=e||this,this.c=i||this}function H(){this.d=yt,this.gi=this.b=this.mi=null,this.xi=[0,0,0],this.s=100130,this.n=!1,this.wi=this.a=this.e=this.f=null,this.bi=!1,this.c=this.r=this.pi=this.Si=this._i=this.yi=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.Ei(null)
416
416
  break
417
417
  case 1:q(t,100152),t.Ti()}else switch(t.d){case 2:q(t,100154),t.Ai()
418
418
  break
419
- case 1:q(t,100153),t.w()}}function q(t,e){t.gi&&t.gi(e,t.c)}function Y(t,e){this.b=t||this,this.d=e||this,this.a=null,this.c=!1}function J(){this.pi=this,this.yi=this.d=this.a=this.e=this.c=this.b=null,this.f=0}function K(t){return t.b.e}function X(){this.c=new Q,this.a=new Y,this.b=new J,this.d=new J,this.b.b=this.d,this.d.b=this.b}function Q(t,e){this.e=t||this,this.f=e||this,this.d=this.c=null,this.g=[0,0,0],this.pi=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
420
- 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.pi&&ht(n,s),i}return n=t.a++,t.c[n]=e,-(n+1)}function et(t){if(0===t.a)return ot(t.b)
419
+ case 1:q(t,100153),t.w()}}function q(t,e){t.gi&&t.gi(e,t.c)}function Y(t,e){this.b=t||this,this.d=e||this,this.a=null,this.c=!1}function J(){this.yi=this,this.pi=this.d=this.a=this.e=this.c=this.b=null,this.f=0}function K(t){return t.b.e}function X(){this.c=new Q,this.a=new Y,this.b=new J,this.d=new J,this.b.b=this.d,this.d.b=this.b}function Q(t,e){this.e=t||this,this.f=e||this,this.d=this.c=null,this.g=[0,0,0],this.yi=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
420
+ 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.yi&&ht(n,s),i}return n=t.a++,t.c[n]=e,-(n+1)}function et(t){if(0===t.a)return ot(t.b)
421
421
  var e=t.c[t.d[t.a-1]]
422
422
  if(0!==t.b.a&&i(rt(t.b),e))return ot(t.b)
423
423
  do{--t.a}while(t.a>0&&null===t.c[t.d[t.a-1]])
424
- return e}function nt(){this.d=st([0],33),this.e=[null,null],this.c=[0,0],this.a=0,this.f=32,this.b=0,this.pi=!1,this.d[1]=1}function st(t,e){for(var i=Array(e),n=0;t.length>n;n++)i[n]=t[n]
424
+ return e}function nt(){this.d=st([0],33),this.e=[null,null],this.c=[0,0],this.a=0,this.f=32,this.b=0,this.yi=!1,this.d[1]=1}function st(t,e){for(var i=Array(e),n=0;t.length>n;n++)i[n]=t[n]
425
425
  for(;e>n;n++)i[n]=0
426
426
  return i}function rt(t){return t.e[t.d[1]]}function ot(t){var e=t.d,i=t.e,n=t.c,s=e[1],r=i[s]
427
427
  return t.a>0&&(e[1]=e[t.a],n[e[1]]=1,i[s]=null,n[s]=t.b,t.b=s,--t.a>0&&at(t,1)),r}function at(t,e){for(var n=t.d,s=t.e,r=t.c,o=e,a=n[o];;){var h=o<<1
@@ -430,20 +430,20 @@ var c=n[h]
430
430
  if(h>t.a||i(s[a],s[c])){n[o]=a,r[a]=o
431
431
  break}n[o]=c,r[c]=o,o=h}}function ht(t,e){for(var n=t.d,s=t.e,r=t.c,o=e,a=n[o];;){var h=o>>1,c=n[h]
432
432
  if(0===h||i(s[c],s[a])){n[o]=a,r[a]=o
433
- break}n[o]=c,r[c]=o,o=h}}function ct(){this.e=this.a=null,this.f=0,this.c=this.b=this.pi=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
433
+ break}n[o]=c,r[c]=o,o=h}}function ct(){this.e=this.a=null,this.f=0,this.c=this.b=this.yi=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
434
434
  case 100140:switch(e){case 100130:case 100131:case 100132:case 100133:case 100134:return void(this.s=e)}break
435
435
  case 100141:return void(this.bi=!!e)
436
436
  default:return void q(this,100900)}q(this,100901)},ft.y=function(t){switch(t){case 100142:return 0
437
437
  case 100140:return this.s
438
438
  case 100141:return this.bi
439
439
  default:q(this,100900)}return!1},ft.A=function(t,e,i){this.xi[0]=t,this.xi[1]=e,this.xi[2]=i},ft.z=function(t,e){var i=e||null
440
- switch(t){case 100100:case 100106:this.pi=i
440
+ switch(t){case 100100:case 100106:this.yi=i
441
441
  break
442
442
  case 100104:case 100110:this._i=i
443
443
  break
444
444
  case 100101:case 100107:this.Si=i
445
445
  break
446
- case 100102:case 100108:this.yi=i
446
+ case 100102:case 100108:this.pi=i
447
447
  break
448
448
  case 100103:case 100109:this.gi=i
449
449
  break
@@ -453,30 +453,30 @@ case 100112:this.r=i
453
453
  break
454
454
  default:q(this,100900)}},ft.C=function(t,e){var i=!1,n=[0,0,0]
455
455
  V(this,2)
456
- 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.mi)?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.mi=i},ft.Ei=function(t){V(this,pt),this.d=1,this.b=new X,this.c=t},ft.Ti=function(){V(this,1),this.d=2,this.mi=null},ft.Ai=function(){V(this,2),this.d=1},ft.w=function(){V(this,1),this.d=pt
456
+ 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.mi)?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.mi=i},ft.Ei=function(t){V(this,yt),this.d=1,this.b=new X,this.c=t},ft.Ti=function(){V(this,1),this.d=2,this.mi=null},ft.Ai=function(){V(this,2),this.d=1},ft.w=function(){V(this,1),this.d=yt
457
457
  var t=!1,n=[u=this.xi[0],r=this.xi[1],a=this.xi[2]]
458
- if(0===u&&0===r&&0===a){for(var r=[-2e150,-2e150,-2e150],o=[2e150,2e150,2e150],a=[],l=[],u=(t=this.b.c).e;u!==t;u=u.e)for(var f=0;3>f;++f){var p=u.g[f]
459
- o[f]>p&&(o[f]=p,l[f]=u),p>r[f]&&(r[f]=p,a[f]=u)}if(u=0,r[1]-o[1]>r[0]-o[0]&&(u=1),r[2]-o[2]>r[u]-o[u]&&(u=2),r[u]>o[u]){for(r=0,o=l[u],l=[0,0,0],o=[o.g[0]-(a=a[u]).g[0],o.g[1]-a.g[1],o.g[2]-a.g[2]],f=[0,0,0],u=t.e;u!==t;u=u.e)f[0]=u.g[0]-a.g[0],f[1]=u.g[1]-a.g[1],f[2]=u.g[2]-a.g[2],l[0]=o[1]*f[2]-o[2]*f[1],l[1]=o[2]*f[0]-o[0]*f[2],l[2]=o[0]*f[1]-o[1]*f[0],(p=l[0]*l[0]+l[1]*l[1]+l[2]*l[2])>r&&(r=p,n[0]=l[0],n[1]=l[1],n[2]=l[2])
458
+ if(0===u&&0===r&&0===a){for(var r=[-2e150,-2e150,-2e150],o=[2e150,2e150,2e150],a=[],l=[],u=(t=this.b.c).e;u!==t;u=u.e)for(var f=0;3>f;++f){var y=u.g[f]
459
+ o[f]>y&&(o[f]=y,l[f]=u),y>r[f]&&(r[f]=y,a[f]=u)}if(u=0,r[1]-o[1]>r[0]-o[0]&&(u=1),r[2]-o[2]>r[u]-o[u]&&(u=2),r[u]>o[u]){for(r=0,o=l[u],l=[0,0,0],o=[o.g[0]-(a=a[u]).g[0],o.g[1]-a.g[1],o.g[2]-a.g[2]],f=[0,0,0],u=t.e;u!==t;u=u.e)f[0]=u.g[0]-a.g[0],f[1]=u.g[1]-a.g[1],f[2]=u.g[2]-a.g[2],l[0]=o[1]*f[2]-o[2]*f[1],l[1]=o[2]*f[0]-o[0]*f[2],l[2]=o[0]*f[1]-o[1]*f[0],(y=l[0]*l[0]+l[1]*l[1]+l[2]*l[2])>r&&(r=y,n[0]=l[0],n[1]=l[1],n[2]=l[2])
460
460
  0>=r&&(n[0]=n[1]=n[2]=0,n[_(o)]=1)}else n[0]=0,n[1]=0,n[2]=1
461
461
  t=!0}for(r=((l=_(n))+1)%3,a=(l+2)%3,l=n[l]>0?1:-1,n=(u=this.b.c).e;n!==u;n=n.e)n.b=n.g[r],n.a=l*n.g[a]
462
462
  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)
463
- if(0>n)for(t=(n=this.b.c).e;t!==n;t=t.e)t.a=-t.a}for(this.n=!1,u=(n=this.b.b).pi;u!==n;u=t)t=u.pi,r=u.e,e(u.a,u.b.a)&&u.e.e!==u&&(D(this,r,u),d(u),r=(u=r).e),r.e===u&&(r!==u&&(r!==t&&r!==t.b||(t=t.pi),d(r)),u!==t&&u!==t.b||(t=t.pi),d(u))
464
- for(this.e=n=new Z,u=(t=this.b.c).e;u!==t;u=u.e)u.pi=tt(n,u)
463
+ if(0>n)for(t=(n=this.b.c).e;t!==n;t=t.e)t.a=-t.a}for(this.n=!1,u=(n=this.b.b).yi;u!==n;u=t)t=u.yi,r=u.e,e(u.a,u.b.a)&&u.e.e!==u&&(D(this,r,u),d(u),r=(u=r).e),r.e===u&&(r!==u&&(r!==t&&r!==t.b||(t=t.yi),d(r)),u!==t&&u!==t.b||(t=t.yi),d(u))
464
+ for(this.e=n=new Z,u=(t=this.b.c).e;u!==t;u=u.e)u.yi=tt(n,u)
465
465
  for((t=>{t.d=[]
466
466
  for(var e=0;t.a>e;e++)t.d[e]=e
467
467
  t.d.sort((t=>(e,n)=>i(t[e],t[n])?1:-1)(t.c)),t.e=!0,(t=>{for(var e=t.a;e>=1;--e)at(t,e)
468
- t.pi=!0})(t.b)})(n),this.f=new W(this),R(this,-dt),R(this,dt);null!==(n=et(this.e));){for(;;){t:if(u=this.e,0===u.a)t=rt(u.b)
468
+ t.yi=!0})(t.b)})(n),this.f=new W(this),R(this,-dt),R(this,dt);null!==(n=et(this.e));){for(;;){t:if(u=this.e,0===u.a)t=rt(u.b)
469
469
  else if(t=u.c[u.d[u.a-1]],0!==u.b.a&&(u=rt(u.b),i(u,t))){t=u
470
470
  break t}if(null===t||!e(t,n))break
471
- t=et(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.pi||++n,A(t)
471
+ t=et(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.yi||++n,A(t)
472
472
  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))
473
- if(!this.n){if(n=this.b,this.bi)for(u=n.b.pi;u!==n.b;u=t)t=u.pi,u.b.d.c!==u.d.c?u.f=u.d.c?1:-1:d(u)
474
- else for(u=n.a.b;u!==n.a;u=t)if(t=u.b,u.c){for(u=u.a;i(u.b.a,u.a);u=u.c.b);for(;i(u.a,u.b.a);u=u.e);for(r=u.c.b,a=void 0;u.e!==r;)if(i(u.b.a,r.a)){for(;r.e!==u&&(h(r.e)||0>=s(r.a,r.b.a,r.e.b.a));)r=(a=y(r.e,r)).b
475
- r=r.c.b}else{for(;r.e!==u&&(c(u.c.b)||s(u.b.a,u.a,u.c.b.a)>=0);)u=(a=y(u,u.c.b)).b
476
- u=u.e}for(;r.e.e!==u;)r=(a=y(r.e,r)).b}if(this.pi||this.yi||this.Si||this._i)if(this.bi){for(t=(n=this.b).a.b;t!==n.a;t=t.b)if(t.c){this.pi&&this.pi(2,this.c),u=t.a
473
+ if(!this.n){if(n=this.b,this.bi)for(u=n.b.yi;u!==n.b;u=t)t=u.yi,u.b.d.c!==u.d.c?u.f=u.d.c?1:-1:d(u)
474
+ else for(u=n.a.b;u!==n.a;u=t)if(t=u.b,u.c){for(u=u.a;i(u.b.a,u.a);u=u.c.b);for(;i(u.a,u.b.a);u=u.e);for(r=u.c.b,a=void 0;u.e!==r;)if(i(u.b.a,r.a)){for(;r.e!==u&&(h(r.e)||0>=s(r.a,r.b.a,r.e.b.a));)r=(a=p(r.e,r)).b
475
+ r=r.c.b}else{for(;r.e!==u&&(c(u.c.b)||s(u.b.a,u.a,u.c.b.a)>=0);)u=(a=p(u,u.c.b)).b
476
+ u=u.e}for(;r.e.e!==u;)r=(a=p(r.e,r)).b}if(this.yi||this.pi||this.Si||this._i)if(this.bi){for(t=(n=this.b).a.b;t!==n.a;t=t.b)if(t.c){this.yi&&this.yi(2,this.c),u=t.a
477
477
  do{this.Si&&this.Si(u.a.d,this.c),u=u.e}while(u!==t.a)
478
- this.yi&&this.yi(this.c)}}else{for(t=!!this._i,u=!1,r=-1,a=(n=this.b).a.d;a!==n.a;a=a.d)if(a.c){u||(this.pi&&this.pi(4,this.c),u=!0),l=a.a
479
- do{t&&r!==(o=l.b.d.c?0:1)&&(r=o,this._i&&this._i(!!r,this.c)),this.Si&&this.Si(l.a.d,this.c),l=l.e}while(l!==a.a)}u&&this.yi&&this.yi(this.c)}if(this.r){for(u=(n=this.b).a.b;u!==n.a;u=t)if(t=u.b,!u.c){a=(r=u.a).e,l=void 0
478
+ this.pi&&this.pi(this.c)}}else{for(t=!!this._i,u=!1,r=-1,a=(n=this.b).a.d;a!==n.a;a=a.d)if(a.c){u||(this.yi&&this.yi(4,this.c),u=!0),l=a.a
479
+ do{t&&r!==(o=l.b.d.c?0:1)&&(r=o,this._i&&this._i(!!r,this.c)),this.Si&&this.Si(l.a.d,this.c),l=l.e}while(l!==a.a)}u&&this.pi&&this.pi(this.c)}if(this.r){for(u=(n=this.b).a.b;u!==n.a;u=t)if(t=u.b,!u.c){a=(r=u.a).e,l=void 0
480
480
  do{a=(l=a).e,l.d=null,null===l.b.d&&(l.c===l?b(l.a,null):(l.a.c=l.c,g(l,K(l))),(o=l.b).c===o?b(o.a,null):(o.a.c=o.c,g(o,K(o))),x(l))}while(l!==r)
481
481
  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},it.Li={GluTesselator:H,Mi:{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},Ii:{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},Fi:{GLU_TESS_MESH:100112,GLU_TESS_TOLERANCE:100142,GLU_TESS_WINDING_RULE:100140,GLU_TESS_BOUNDARY_ONLY:100141,GLU_INVALID_ENUM:100900,GLU_INVALID_VALUE:100901,GLU_TESS_BEGIN:100100,GLU_TESS_VERTEX:100101,GLU_TESS_END:100102,GLU_TESS_ERROR:100103,GLU_TESS_EDGE_FLAG:100104,GLU_TESS_COMBINE:100105,GLU_TESS_BEGIN_DATA:100106,GLU_TESS_VERTEX_DATA:100107,GLU_TESS_END_DATA:100108,GLU_TESS_ERROR_DATA:100109,GLU_TESS_EDGE_FLAG_DATA:100110,GLU_TESS_COMBINE_DATA:100111}},H.prototype.Gi=H.prototype.x,H.prototype.Oi=H.prototype.B,H.prototype.ki=H.prototype.y,H.prototype.Ci=H.prototype.A,H.prototype.Di=H.prototype.z,H.prototype.Bi=H.prototype.C,H.prototype.Ui=H.prototype.Ei,H.prototype.$i=H.prototype.Ti,H.prototype.Ni=H.prototype.Ai,H.prototype.Pi=H.prototype.w,t.exports=it.Li})(nt)
482
482
  var st=nt.exports
@@ -530,18 +530,18 @@ return u.set(s),{vertices:c,normals:l,indices:u}}const f=25e-6*i,d=e>f?e:f
530
530
  for(let t=0,e=0;n.length>t;t+=2,e++){const i=n[t],s=n[t+1],o=3*e
531
531
  c[o]=i,c[o+1]=s,c[o+2]=0,l[o]=0,l[o+1]=0,l[o+2]=-1
532
532
  const a=3*(r+e)
533
- c[a]=i,c[a+1]=s,c[a+2]=d,l[a]=0,l[a+1]=0,l[a+2]=1}const p=s.length
534
- for(let t=0;p>t;t++)u[t]=s[p-1-t]
535
- for(let t=0;p>t;t++)u[p+t]=s[t]+r
536
- let y=2*r,w=2*p
533
+ c[a]=i,c[a+1]=s,c[a+2]=d,l[a]=0,l[a+1]=0,l[a+2]=1}const y=s.length
534
+ for(let t=0;y>t;t++)u[t]=s[y-1-t]
535
+ for(let t=0;y>t;t++)u[y+t]=s[t]+r
536
+ let p=2*r,w=2*y
537
537
  const g=o.length
538
- for(let t=0;g>t;t++){const e=o[t],i=e[0]<<1,s=e[1]<<1,r=n[i],a=n[i+1],h=n[s],f=n[s+1],p=h-r,g=f-a,v=p*p+g*g
538
+ for(let t=0;g>t;t++){const e=o[t],i=e[0]<<1,s=e[1]<<1,r=n[i],a=n[i+1],h=n[s],f=n[s+1],y=h-r,g=f-a,v=y*y+g*g
539
539
  let m=0,x=0
540
540
  if(v>1e-10){const t=1/Math.sqrt(v)
541
- m=g*t,x=-p*t}const b=3*y
541
+ m=g*t,x=-y*t}const b=3*p
542
542
  c[b]=r,c[b+1]=a,c[b+2]=0,c[b+3]=h,c[b+4]=f,c[b+5]=0,c[b+6]=r,c[b+7]=a,c[b+8]=d,c[b+9]=h,c[b+10]=f,c[b+11]=d,l[b]=m,l[b+1]=x,l[b+2]=0,l[b+3]=m,l[b+4]=x,l[b+5]=0,l[b+6]=m,l[b+7]=x,l[b+8]=0,l[b+9]=m,l[b+10]=x,l[b+11]=0
543
- const S=y
544
- u[w]=S,u[w+1]=S+1,u[w+2]=S+2,u[w+3]=S+1,u[w+4]=S+3,u[w+5]=S+2,w+=6,y+=4}return{vertices:c,normals:l,indices:u}}}class at{constructor(){}Xi(t,e){const i=t.length
543
+ const S=p
544
+ u[w]=S,u[w+1]=S+1,u[w+2]=S+2,u[w+3]=S+1,u[w+4]=S+3,u[w+5]=S+2,w+=6,p+=4}return{vertices:c,normals:l,indices:u}}}class at{constructor(){}Xi(t,e){const i=t.length
545
545
  return 0===i?[]:1===i?[[0]]:this.Qi(t,e)}Qi(t,e){function i(t){return h[t]===t?t:h[t]=i(h[t])}function n(t,e){const n=i(t),s=i(e)
546
546
  n!==s&&(c[s]>c[n]?h[n]=s:c[n]>c[s]?h[s]=n:(h[s]=n,c[n]++))}const s=t.length,r=Array(s),o=Array(2*s)
547
547
  let a=0
@@ -572,13 +572,13 @@ let r=t,o=e
572
572
  const a=this.rn[n]
573
573
  if(0>this.compare(a,o)&&(r=n,o=a),i>s){const t=this.rn[s]
574
574
  0>this.compare(t,o)&&(r=s,o=t)}if(r===t)break
575
- this.rn[t]=o,this.an.set(o,t),t=r}this.rn[t]=e,this.an.set(e,t)}}const ct={enabled:!0,dn:1,pn:.0087,yn:10}
575
+ this.rn[t]=o,this.an.set(o,t),t=r}this.rn[t]=e,this.an.set(e,t)}}const ct={enabled:!0,dn:1,yn:.0087,pn:10}
576
576
  class lt{constructor(t){this.stats={wn:0,gn:0,vn:0},this.config=t}mn(t){this.config=t}xn(t){if(!this.config.enabled||2>=t.points.length)return t
577
577
  this.stats.vn+=t.points.length
578
578
  const e=t.points
579
579
  if(5>e.length)return t
580
580
  let i=this.bn(e,this.config.dn)
581
- return 3>i.length?t:(i=this.Sn(i,this.config.pn),3>i.length?t:{...t,points:i})}bn(t,e){if(3>=t.length)return t
581
+ return 3>i.length?t:(i=this.Sn(i,this.config.yn),3>i.length?t:{...t,points:i})}bn(t,e){if(3>=t.length)return t
582
582
  const i=t.length,n=t.map((t,e)=>({index:e,_n:1/0,En:null,next:null}))
583
583
  for(let t=0;n.length>t;t++)n[t].En=n[t-1]||null,n[t].next=n[t+1]||null
584
584
  const s=new ht((t,e)=>t._n-e._n)
@@ -586,25 +586,25 @@ for(let e=1;n.length-1>e;e++){const i=n[e]
586
586
  i._n=this.Tn(t[i.En.index],t[i.index],t[i.next.index]),s.F(i)}let r=i
587
587
  for(;!s.un()&&r>3;){const i=s.ln()
588
588
  if(!i||i._n>e)break
589
- if(this.config.yn>0&&i.En&&i.next){const e=t[i.index],n=t[i.next.index],s=t[i.En.index].ui(e),r=e.ui(n)
590
- if(this.config.yn>s||this.config.yn>r)continue}i.En&&(i.En.next=i.next),i.next&&(i.next.En=i.En),r--,i.En&&i.En.En&&(i.En._n=this.Tn(t[i.En.En.index],t[i.En.index],t[i.next.index]),s.update(i.En)),i.next&&i.next.next&&(i.next._n=this.Tn(t[i.En.index],t[i.next.index],t[i.next.next.index]),s.update(i.next))}const o=[]
589
+ if(this.config.pn>0&&i.En&&i.next){const e=t[i.index],n=t[i.next.index],s=t[i.En.index].ui(e),r=e.ui(n)
590
+ if(this.config.pn>s||this.config.pn>r)continue}i.En&&(i.En.next=i.next),i.next&&(i.next.En=i.En),r--,i.En&&i.En.En&&(i.En._n=this.Tn(t[i.En.En.index],t[i.En.index],t[i.next.index]),s.update(i.En)),i.next&&i.next.next&&(i.next._n=this.Tn(t[i.En.index],t[i.next.index],t[i.next.next.index]),s.update(i.next))}const o=[]
591
591
  let a=n[0]
592
592
  for(;a;)o.push(t[a.index]),a=a.next
593
593
  return this.stats.wn+=i-o.length,o}Sn(t,e){if(2>=t.length)return t
594
594
  const i=[t[0]]
595
- for(let n=1;t.length-1>n;n++){const s=t[n-1],r=t[n],o=t[n+1],a=r.x-s.x,h=r.y-s.y,c=o.x-r.x,l=o.y-r.y,u=this.config.yn*this.config.yn
595
+ for(let n=1;t.length-1>n;n++){const s=t[n-1],r=t[n],o=t[n+1],a=r.x-s.x,h=r.y-s.y,c=o.x-r.x,l=o.y-r.y,u=this.config.pn*this.config.pn
596
596
  Math.abs(Math.atan2(a*l-h*c,a*c+h*l))>e||u>a*a+h*h||u>c*c+l*l?i.push(r):this.stats.gn++}return i.push(t[t.length-1]),i}Tn(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}}An(){this.stats={wn:0,gn:0,vn:0}}}const ut={Ln:.5,Mn:.2},ft=1e-6
597
597
  class dt{constructor(t){this.In={...ut,...t}}Fn(t){this.In={...ut,...t}}Gn(t,e,i){const n=[]
598
598
  return this.On(t.x,t.y,e.x,e.y,i.x,i.y,n),this.kn(i.x,i.y,n),n}Cn(t,e,i,n){const s=[]
599
599
  return this.Dn(t.x,t.y,e.x,e.y,i.x,i.y,n.x,n.y,s),this.kn(n.x,n.y,s),s}On(t,e,i,n,s,r,o,a=0){if(a>16)return
600
- const h=(t+i)/2,c=(e+n)/2,l=(i+s)/2,u=(n+r)/2,f=(h+l)/2,d=(c+u)/2,p=s-t,y=r-e,w=Math.abs((i-s)*y-(n-r)*p),g=this.In.Ln??.5,v=g*g
601
- if(w>ft){if(v*(p*p+y*y)>=w*w){const a=this.In.Mn??.2
600
+ const h=(t+i)/2,c=(e+n)/2,l=(i+s)/2,u=(n+r)/2,f=(h+l)/2,d=(c+u)/2,y=s-t,p=r-e,w=Math.abs((i-s)*p-(n-r)*y),g=this.In.Ln??.5,v=g*g
601
+ if(w>ft){if(v*(y*y+p*p)>=w*w){const a=this.In.Mn??.2
602
602
  if(0>=a)return void this.kn(i,n,o)
603
603
  {const h=i-t,c=n-e,l=s-i,u=r-n
604
- if(a>Math.abs(Math.atan2(h*u-c*l,h*l+c*u)))return void this.kn(i,n,o)}}}else{const s=p*p+y*y
605
- if(0===s){if(v>=(i-t)*(i-t)+(n-e)*(n-e))return void this.kn(i,n,o)}else{const r=((i-t)*p+(n-e)*y)/s
604
+ if(a>Math.abs(Math.atan2(h*u-c*l,h*l+c*u)))return void this.kn(i,n,o)}}}else{const s=y*y+p*p
605
+ if(0===s){if(v>=(i-t)*(i-t)+(n-e)*(n-e))return void this.kn(i,n,o)}else{const r=((i-t)*y+(n-e)*p)/s
606
606
  if(r>0&&1>r&&v*s>=w*w)return void this.kn(i,n,o)}}this.On(t,e,h,c,f,d,o,a+1),this.On(f,d,l,u,s,r,o,a+1)}Dn(t,e,i,n,s,r,o,a,h,c=0){if(c>16)return
607
- const l=(t+i)/2,u=(e+n)/2,f=(i+s)/2,d=(n+r)/2,p=(s+o)/2,y=(r+a)/2,w=(l+f)/2,g=(u+d)/2,v=(f+p)/2,m=(d+y)/2,x=(w+v)/2,b=(g+m)/2,S=o-t,_=a-e,E=Math.abs((i-o)*_-(n-a)*S),T=Math.abs((s-o)*_-(r-a)*S),A=this.In.Ln??.5,L=A*A
607
+ const l=(t+i)/2,u=(e+n)/2,f=(i+s)/2,d=(n+r)/2,y=(s+o)/2,p=(r+a)/2,w=(l+f)/2,g=(u+d)/2,v=(f+y)/2,m=(d+p)/2,x=(w+v)/2,b=(g+m)/2,S=o-t,_=a-e,E=Math.abs((i-o)*_-(n-a)*S),T=Math.abs((s-o)*_-(r-a)*S),A=this.In.Ln??.5,L=A*A
608
608
  let M=0
609
609
  switch(E>ft&&(M|=1),T>ft&&(M|=2),M){case 0:const c=S*S+_*_
610
610
  if(0===c){if(L>=(i-t)*(i-t)+(n-e)*(n-e)&&L>=(s-t)*(s-t)+(r-e)*(r-e))return this.kn(i,n,h),void this.kn(s,r,h)}else{const o=((i-t)*S+(n-e)*_)/c,a=((s-t)*S+(r-e)*_)/c
@@ -619,11 +619,11 @@ if(0>=o)return this.kn(i,n,h),void this.kn(s,r,h)
619
619
  if(o>Math.abs(Math.atan2(a*u-c*l,a*l+c*u)))return this.kn(i,n,h),void this.kn(s,r,h)}}break
620
620
  case 3:if(L*(S*S+_*_)>=(E+T)*(E+T)){const c=this.In.Mn??.2
621
621
  if(0>=c)return this.kn(i,n,h),void this.kn(s,r,h)
622
- {const l=i-t,u=n-e,f=s-i,d=r-n,p=o-s,y=a-r
623
- 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.kn(i,n,h),void this.kn(s,r,h)}}}this.Dn(t,e,l,u,w,g,x,b,h,c+1),this.Dn(x,b,v,m,p,y,o,a,h,c+1)}kn(t,e,i){const n=new J(t,e)
622
+ {const l=i-t,u=n-e,f=s-i,d=r-n,y=o-s,p=a-r
623
+ 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.kn(i,n,h),void this.kn(s,r,h)}}}this.Dn(t,e,l,u,w,g,x,b,h,c+1),this.Dn(x,b,v,m,y,p,o,a,h,c+1)}kn(t,e,i){const n=new J(t,e)
624
624
  if(0===i.length)return void i.push(n)
625
625
  const s=i[i.length-1],r=n.x-s.x,o=n.y-s.y
626
- r*r+o*o>1e-12&&i.push(n)}}class pt{constructor(t,e){this.Bn=0,this.Un=0,this.$n=[],this.Nn=null,this.Pn=null,this.Rn={min:new J(1/0,1/0),max:new J(-1/0,-1/0)},this.Wn=[],this.jn=[],this.zn=[],this.Hn=new J(0,0),this.Vn=new dt(t),this.qn=new lt({...ct,...e})}setPosition(t,e){this.Hn.set(t,e)}Yn(t,e){this.Hn.x+=t,this.Hn.y+=e}Jn(t,e){this.$n.length>0&&this.Kn(),this.Bn=t,this.Un=e,this.$n=[],this.Rn.min.set(1/0,1/0),this.Rn.max.set(-1/0,-1/0),this.jn.push(this.Hn.clone())}Kn(){this.Nn&&this.Xn(),this.$n.length>0&&(this.Wn.push({Qn:this.Bn,Zn:this.$n,bounds:{min:{x:this.Rn.min.x,y:this.Rn.min.y},max:{x:this.Rn.max.x,y:this.Rn.max.y}}}),this.zn.push(this.Un)),this.$n=[]}ts(t,e){this.Nn&&this.Xn(),this.Pn=new J(t,e),this.es(this.Pn),this.Nn={points:[this.Pn],glyphIndex:this.Bn}}ns(t,e){if(!this.Nn||!this.Pn)return
626
+ r*r+o*o>1e-12&&i.push(n)}}class yt{constructor(t,e){this.Bn=0,this.Un=0,this.$n=[],this.Nn=null,this.Pn=null,this.Rn={min:new J(1/0,1/0),max:new J(-1/0,-1/0)},this.Wn=[],this.jn=[],this.zn=[],this.Hn=new J(0,0),this.Vn=new dt(t),this.qn=new lt({...ct,...e})}setPosition(t,e){this.Hn.set(t,e)}Yn(t,e){this.Hn.x+=t,this.Hn.y+=e}Jn(t,e){this.$n.length>0&&this.Kn(),this.Bn=t,this.Un=e,this.$n=[],this.Rn.min.set(1/0,1/0),this.Rn.max.set(-1/0,-1/0),this.jn.push(this.Hn.clone())}Kn(){this.Nn&&this.Xn(),this.$n.length>0&&(this.Wn.push({Qn:this.Bn,Zn:this.$n,bounds:{min:{x:this.Rn.min.x,y:this.Rn.min.y},max:{x:this.Rn.max.x,y:this.Rn.max.y}}}),this.zn.push(this.Un)),this.$n=[]}ts(t,e){this.Nn&&this.Xn(),this.Pn=new J(t,e),this.es(this.Pn),this.Nn={points:[this.Pn],glyphIndex:this.Bn}}ns(t,e){if(!this.Nn||!this.Pn)return
627
627
  const i=new J(t,e)
628
628
  this.es(i),this.Nn.points.push(i),this.Pn=i}ss(t,e,i,n){if(!this.Nn||!this.Pn)return
629
629
  const s=this.Pn,r=new J(t,e),o=new J(i,n)
@@ -638,22 +638,22 @@ for(let t=0;f.length>t;t++){const e=f[t]
638
638
  this.es(e),this.Nn.points.push(e)}this.Pn=c}hs(){if(!this.Nn||!this.Pn)return
639
639
  const t=this.Nn.points[0]
640
640
  this.Pn.equals(t)||this.Nn.points.push(t),this.Xn()}Xn(){if(this.Nn){const t=this.qn.xn(this.Nn)
641
- this.$n.push(t),this.Nn=null,this.Pn=null}}es(t){this.Rn.min.x=Math.min(this.Rn.min.x,t.x),this.Rn.min.y=Math.min(this.Rn.min.y,t.y),this.Rn.max.x=Math.max(this.Rn.max.x,t.x),this.Rn.max.y=Math.max(this.Rn.max.y,t.y)}cs(){return this.$n.length>0&&this.Kn(),this.Wn}ls(){return this.jn}us(){return this.zn}reset(){this.Wn=[],this.jn=[],this.zn=[],this.$n=[],this.Nn=null,this.Pn=null,this.Bn=0,this.Un=0,this.Hn.set(0,0),this.Rn={min:new J(1/0,1/0),max:new J(-1/0,-1/0)}}Fn(t){this.Vn.Fn(t)}fs(t){this.qn.mn({...ct,...t})}ds(){return this.qn.getStats()}}class yt{constructor(){this.ps=null,this.ys=null,this.ws=null,this.gs=null,this.vs=null,this.xs=0,this.position={x:0,y:0}}setPosition(t,e){this.position.x=t,this.position.y=e,this.bs&&this.bs.setPosition(t,e)}Yn(t,e){this.position.x+=t,this.position.y+=e,this.bs&&this.bs.Yn(t,e)}Ss(t){this.bs=t}_s(t,e){if(!t||!t.module||!t.hb)throw Error("Invalid font object")
641
+ this.$n.push(t),this.Nn=null,this.Pn=null}}es(t){this.Rn.min.x=Math.min(this.Rn.min.x,t.x),this.Rn.min.y=Math.min(this.Rn.min.y,t.y),this.Rn.max.x=Math.max(this.Rn.max.x,t.x),this.Rn.max.y=Math.max(this.Rn.max.y,t.y)}cs(){return this.$n.length>0&&this.Kn(),this.Wn}ls(){return this.jn}us(){return this.zn}reset(){this.Wn=[],this.jn=[],this.zn=[],this.$n=[],this.Nn=null,this.Pn=null,this.Bn=0,this.Un=0,this.Hn.set(0,0),this.Rn={min:new J(1/0,1/0),max:new J(-1/0,-1/0)}}Fn(t){this.Vn.Fn(t)}fs(t){this.qn.mn({...ct,...t})}ds(){return this.qn.getStats()}}class pt{constructor(){this.ys=null,this.ps=null,this.ws=null,this.gs=null,this.vs=null,this.xs=0,this.position={x:0,y:0}}setPosition(t,e){this.position.x=t,this.position.y=e,this.bs&&this.bs.setPosition(t,e)}Yn(t,e){this.position.x+=t,this.position.y+=e,this.bs&&this.bs.Yn(t,e)}Ss(t){this.bs=t}_s(t,e){if(!t||!t.module||!t.hb)throw Error("Invalid font object")
642
642
  if(this.bs=e,this.xs)return
643
643
  const i=t.module
644
- this.ps=i.Es((t,e,i,n,s)=>{this.bs?.ts(n,s)},"viiiffi"),this.ys=i.Es((t,e,i,n,s)=>{this.bs?.ns(n,s)},"viiiffi"),this.ws=i.Es((t,e,i,n,s,r,o)=>{this.bs?.ss(n,s,r,o)},"viiiffffi"),this.gs=i.Es((t,e,i,n,s,r,o,a,h)=>{this.bs?.rs(n,s,r,o,a,h)},"viiiffffffi"),this.vs=i.Es(()=>{this.bs?.hs()},"viiii"),this.xs=i.exports.Ts(),i.exports.As(this.xs,this.ps,0,0),i.exports.Ls(this.xs,this.ys,0,0),i.exports.Ms(this.xs,this.ws,0,0),i.exports.Is(this.xs,this.gs,0,0),i.exports.Fs(this.xs,this.vs,0,0)}Gs(){if(!this.xs)throw Error("Draw functions not initialized")
644
+ this.ys=i.Es((t,e,i,n,s)=>{this.bs?.ts(n,s)},"viiiffi"),this.ps=i.Es((t,e,i,n,s)=>{this.bs?.ns(n,s)},"viiiffi"),this.ws=i.Es((t,e,i,n,s,r,o)=>{this.bs?.ss(n,s,r,o)},"viiiffffi"),this.gs=i.Es((t,e,i,n,s,r,o,a,h)=>{this.bs?.rs(n,s,r,o,a,h)},"viiiffffffi"),this.vs=i.Es(()=>{this.bs?.hs()},"viiii"),this.xs=i.exports.Ts(),i.exports.As(this.xs,this.ys,0,0),i.exports.Ls(this.xs,this.ps,0,0),i.exports.Ms(this.xs,this.ws,0,0),i.exports.Is(this.xs,this.gs,0,0),i.exports.Fs(this.xs,this.vs,0,0)}Gs(){if(!this.xs)throw Error("Draw functions not initialized")
645
645
  return this.xs}destroy(t){if(!t||!t.module||!t.hb)return
646
646
  const e=t.module
647
- try{this.xs&&(e.exports.Os(this.xs),this.xs=0),null!==this.ps&&(e.ks(this.ps),this.ps=null),null!==this.ys&&(e.ks(this.ys),this.ys=null),null!==this.ws&&(e.ks(this.ws),this.ws=null),null!==this.gs&&(e.ks(this.gs),this.gs=null),null!==this.vs&&(e.ks(this.vs),this.vs=null)}catch(t){h.warn("Error destroying draw callbacks:",t)}this.bs=void 0}}const wt=new WeakMap
648
- class gt{constructor(t,e){this.Cs="default",this.Ds="default",this.Bs=new Set,this.cache=t,this.ae=e,this.tessellator=new rt,this.Us=new ot,this.$s=new at,this.bs=new pt,this.Ns=(()=>{const t=this.ae.module,e=wt.get(t)
647
+ try{this.xs&&(e.exports.Os(this.xs),this.xs=0),null!==this.ys&&(e.ks(this.ys),this.ys=null),null!==this.ps&&(e.ks(this.ps),this.ps=null),null!==this.ws&&(e.ks(this.ws),this.ws=null),null!==this.gs&&(e.ks(this.gs),this.gs=null),null!==this.vs&&(e.ks(this.vs),this.vs=null)}catch(t){h.warn("Error destroying draw callbacks:",t)}this.bs=void 0}}const wt=new WeakMap
648
+ class gt{constructor(t,e){this.Cs="default",this.Ds="default",this.Bs=new Set,this.cache=t,this.ae=e,this.tessellator=new rt,this.Us=new ot,this.$s=new at,this.bs=new yt,this.Ns=(()=>{const t=this.ae.module,e=wt.get(t)
649
649
  if(e)return e
650
- const i=new yt
651
- return wt.set(t,i),i})(),this.Ns._s(this.ae,this.bs),this.Ps=Z,this.Rs=tt,this.Ws=et}ds(){return this.bs.ds()}Fn(t){this.In=t,this.bs.Fn(t),this.js()}fs(t){this.zs=t,this.bs.fs(t),this.js()}Hs(t){this.Cs=t,this.js()}js(){this.Ds=`${this.Cs}__${this.Vs()}`}Vs(){const t=this.In?.Ln??.5,e=this.In?.Mn??.2,i=this.zs?.enabled??!0,n=this.zs?.dn??1,s=this.zs?.pn??.0087,r=this.zs?.yn??10
650
+ const i=new pt
651
+ return wt.set(t,i),i})(),this.Ns._s(this.ae,this.bs),this.Ps=Z,this.Rs=tt,this.Ws=et}ds(){return this.bs.ds()}Fn(t){this.In=t,this.bs.Fn(t),this.js()}fs(t){this.zs=t,this.bs.fs(t),this.js()}Hs(t){this.Cs=t,this.js()}js(){this.Ds=`${this.Cs}__${this.Vs()}`}Vs(){const t=this.In?.Ln??.5,e=this.In?.Mn??.2,i=this.zs?.enabled??!0,n=this.zs?.dn??1,s=this.zs?.yn??.0087,r=this.zs?.pn??10
652
652
  return[`cf:${t.toFixed(4)},${e.toFixed(4)}`,`opt:${i?1:0},${n.toFixed(4)},${s.toFixed(6)},${r.toFixed(4)}`].join("|")}qs(t,e,i,s,r,o=!1,h){if(a){let e=0
653
653
  for(let i=0;t.length>i;i++)e+=t[i].length}const c=[]
654
654
  let l=0,u=0,f=0,d=0
655
- const p=(t,e,i,n)=>{const s=d
656
- return c.push({data:t,px:e,Ys:i,Js:n,Ks:s}),l+=t.vertices.length,u+=t.normals.length,f+=t.indices.length,d+=t.vertices.length/3,s},y=[],w={min:{x:1/0,y:1/0,z:0},max:{x:-1/0,y:-1/0,z:e}}
655
+ const y=(t,e,i,n)=>{const s=d
656
+ return c.push({data:t,px:e,Ys:i,Js:n,Ks:s}),l+=t.vertices.length,u+=t.normals.length,f+=t.indices.length,d+=t.vertices.length/3,s},p=[],w={min:{x:1/0,y:1/0,z:0},max:{x:-1/0,y:-1/0,z:e}}
657
657
  for(let r=0;t.length>r;r++){const a=t[r]
658
658
  for(const t of a){const r=t.position.x,a=t.position.y,c=t.position.z,l=[]
659
659
  for(const e of t.glyphs)l.push(this.Xs(e.g))
@@ -670,24 +670,24 @@ for(const o of u)if(o.length>1&&!d){const n=o.map(e=>t.glyphs[e]),h=this.tr(n,e,
670
670
  let u=this.Rs.get(h)
671
671
  if(!u){const i=[],r=n[0].x??0,a=n[0].y??0
672
672
  for(let e=0;o.length>e;e++){const n=o[e],s=l[n],h=t.glyphs[n],c=(h.x??0)-r,u=(h.y??0)-a
673
- for(const t of s.Zn)i.push({...t,points:t.points.map(t=>new J(t.x+c,t.y+u))})}u=this.er(i,e,s),this.Rs.set(h,u)}const f=n[0],d=p(u,r+(f.x??0),a+(f.y??0),c),g=u.vertices.length/3
673
+ for(const t of s.Zn)i.push({...t,points:t.points.map(t=>new J(t.x+c,t.y+u))})}u=this.er(i,e,s),this.Rs.set(h,u)}const f=n[0],d=y(u,r+(f.x??0),a+(f.y??0),c),g=u.vertices.length/3
674
674
  for(let i=0;o.length>i;i++){const n=o[i],s=t.glyphs[n],h=this.ir(s,d,g,r+(s.x??0),a+(s.y??0),c,l[n],e)
675
- y.push(h),this.nr(h.bounds,w)}}else for(const h of o){const o=t.glyphs[h],u=l[h],f=r+(o.x??0),d=a+(o.y??0),g=c
675
+ p.push(h),this.nr(h.bounds,w)}}else for(const h of o){const o=t.glyphs[h],u=l[h],f=r+(o.x??0),d=a+(o.y??0),g=c
676
676
  if(0===u.Zn.length){const t=this.ir(o,0,0,f,d,g,u,e)
677
- y.push(t)
677
+ p.push(t)
678
678
  continue}const v=n(this.Ds,o.g,e,i)
679
679
  let m=this.cache.get(v)
680
680
  m?m.sr++:(m=this.rr(u,e,i,s),this.cache.set(v,m))
681
- const x=p(m,f,d,g),b=this.ir(o,x,m.vertices.length/3,f,d,g,u,e)
682
- y.push(b),this.nr(b.bounds,w)}}}const g=new Float32Array(l),v=new Float32Array(u),m=new Uint32Array(f)
681
+ const x=y(m,f,d,g),b=this.ir(o,x,m.vertices.length/3,f,d,g,u,e)
682
+ p.push(b),this.nr(b.bounds,w)}}}const g=new Float32Array(l),v=new Float32Array(u),m=new Uint32Array(f)
683
683
  let x=0,b=0,S=0
684
684
  for(let t=0;c.length>t;t++){const e=c[t],i=e.data.vertices,n=e.data.normals,s=e.data.indices,o=e.px,a=e.Ys,h=e.Js
685
685
  for(let t=0;i.length>t;t+=3)g[x++]=(i[t]+o)*r,g[x++]=(i[t+1]+a)*r,g[x++]=(i[t+2]+h)*r
686
686
  v.set(n,b),b+=n.length
687
687
  const l=e.Ks
688
688
  for(let t=0;s.length>t;t++)m[S++]=s[t]+l}w.min.x*=r,w.min.y*=r,w.min.z*=r,w.max.x*=r,w.max.y*=r,w.max.z*=r
689
- for(let t=0;y.length>t;t++)y[t].bounds.min.x*=r,y[t].bounds.min.y*=r,y[t].bounds.min.z*=r,y[t].bounds.max.x*=r,y[t].bounds.max.y*=r,y[t].bounds.max.z*=r
690
- return{vertices:g,normals:v,indices:m,ar:y,planeBounds:w}}tr(t,e,i){if(0===t.length)return""
689
+ for(let t=0;p.length>t;t++)p[t].bounds.min.x*=r,p[t].bounds.min.y*=r,p[t].bounds.min.z*=r,p[t].bounds.max.x*=r,p[t].bounds.max.y*=r,p[t].bounds.max.z*=r
690
+ return{vertices:g,normals:v,indices:m,ar:p,planeBounds:w}}tr(t,e,i){if(0===t.length)return""
691
691
  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("|")
692
692
  return`${this.Ds}_${r}_${Math.round(1e3*e)/1e3}_${i}`}ir(t,e,i,n,s,r,o,a){return{hr:t.Zs,cr:t.cr,Ks:e,lr:i,bounds:{min:{x:o.bounds.min.x+n,y:o.bounds.min.y+s,z:r},max:{x:o.bounds.max.x+n,y:o.bounds.max.y+s,z:r+a}}}}Xs(t){if(this.Bs.has(t))return{Qn:t,Zn:[],bounds:{min:{x:0,y:0},max:{x:0,y:0}}}
693
693
  const e=`${this.Ds}_${t}`,i=this.Ps.get(e)
@@ -695,13 +695,13 @@ if(i)return i
695
695
  this.Ns.Ss(this.bs),this.bs.reset(),this.bs.Jn(t,0),this.ae.module.exports.ur(this.ae.font.dr,t,this.Ns.Gs(),0),this.bs.Kn()
696
696
  const n=this.bs.cs()[0]||{Qn:t,Zn:[],bounds:{min:{x:0,y:0},max:{x:0,y:0}}}
697
697
  return 0===n.Zn.length&&this.Bs.add(t),this.Ps.set(e,n),n}er(t,e,i){const n=this.tessellator.process(t,!0,i,0!==e)
698
- return this.pr(n,e)}pr(t,e){const i=this.Us.Ki(t,e,this.ae.upem),n=i.vertices
698
+ return this.yr(n,e)}yr(t,e){const i=this.Us.Ki(t,e,this.ae.upem),n=i.vertices
699
699
  let s=1/0,r=1/0,o=1/0,a=-1/0,h=-1/0,c=-1/0
700
700
  for(let t=0;n.length>t;t+=3){const e=n[t],i=n[t+1],l=n[t+2]
701
701
  s>e&&(s=e),e>a&&(a=e),r>i&&(r=i),i>h&&(h=i),o>l&&(o=l),l>c&&(c=l)}const l=new K(s,r,o),u=new K(a,h,c)
702
702
  return{geometry:t,vertices:i.vertices,normals:i.normals,indices:i.indices,bounds:{min:l,max:u},sr:1}}rr(t,e,i,n){const s=this.tessellator.process(t.Zn,i,n,0!==e)
703
- return this.pr(s,e)}nr(t,e){const i=e.min,n=e.max,s=t.min,r=t.max
704
- 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)}yr(){return this.cache.getStats()}clearCache(){this.cache.clear(),this.Rs.clear(),this.Ws.clear(),this.Ps.clear()}}class vt{constructor(t,e){this.wr=new Map,this.ae=t,this.gr=e}vr(t,e,i,n,s,r,o){try{const r=[]
703
+ return this.yr(s,e)}nr(t,e){const i=e.min,n=e.max,s=t.min,r=t.max
704
+ 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)}pr(){return this.cache.getStats()}clearCache(){this.cache.clear(),this.Rs.clear(),this.Ws.clear(),this.Ps.clear()}}class vt{constructor(t,e){this.wr=new Map,this.ae=t,this.gr=e}vr(t,e,i,n,s,r,o){try{const r=[]
705
705
  return t.forEach((t,o)=>{const a=this.mr(t,o,e,i,n,s)
706
706
  r.push(a)}),r}finally{}}mr(e,i,n,s,r,o){const a=this.ae.hb.createBuffer()
707
707
  "rtl"===o&&a.br("rtl"),a.ne(e.text),a.se()
@@ -710,18 +710,18 @@ this.ae.hb.shape(this.ae.font,a,h)
710
710
  const c=a.json(this.ae.font)
711
711
  a.destroy()
712
712
  const l=[]
713
- let u=[],f=[],d=0,p=0,y=e.Bt,w=-i*n
713
+ let u=[],f=[],d=0,y=0,p=e.Bt,w=-i*n
714
714
  const g=s*this.ae.upem,v=this.Sr(e,r,s),m=this._r(e,r),x=e.text,b=x.length,S=c.length
715
715
  let _
716
716
  for(let t=0;S>t;t++){const n=c[t],s=n.oe,r=x[s],o=r.charCodeAt(0),a=32===o||9===o||10===o||13===o
717
- n.Zs=e.$t&&s===b-1&&"-"===r?e.Dt:e.Ct+s,n.cr=i,a&&u.length>0&&(l.push({text:f.join(""),glyphs:u,position:new K(d,p,0)}),u=[],f=[])
718
- const h=y+n.dx,E=w+n.dy
719
- if(a||(0===u.length&&(d=h,p=E),n.x=h-d,n.y=E-p,u.push(n),f.push(r)),y+=n.ax,w+=n.ay,0!==g&&S-1>t&&(y+=g),a&&(y+=v),0!==m&&S-1>t&&!a){const e=x[c[t+1].oe],i=void 0!==_?_:A.K(r)
717
+ n.Zs=e.$t&&s===b-1&&"-"===r?e.Dt:e.Ct+s,n.cr=i,a&&u.length>0&&(l.push({text:f.join(""),glyphs:u,position:new K(d,y,0)}),u=[],f=[])
718
+ const h=p+n.dx,E=w+n.dy
719
+ if(a||(0===u.length&&(d=h,y=E),n.x=h-d,n.y=E-y,u.push(n),f.push(r)),p+=n.ax,w+=n.ay,0!==g&&S-1>t&&(p+=g),a&&(p+=v),0!==m&&S-1>t&&!a){const e=x[c[t+1].oe],i=void 0!==_?_:A.K(r)
720
720
  if(_=!!e&&A.K(e),i&&_){let t=!0
721
- A.X(e)&&(t=!1),A.Z(r)&&(t=!1),A.tt(r)&&A.tt(e)&&(t=!1),t&&(y+=m)}}else _=void 0}return u.length>0&&l.push({text:f.join(""),glyphs:u,position:new K(d,p,0)}),l}Sr(t,e,i){let n=0
721
+ A.X(e)&&(t=!1),A.Z(r)&&(t=!1),A.tt(r)&&A.tt(e)&&(t=!1),t&&(p+=m)}}else _=void 0}return u.length>0&&l.push({text:f.join(""),glyphs:u,position:new K(d,y,0)}),l}Sr(t,e,i){let n=0
722
722
  if(void 0!==t.qt&&"justify"===e&&!t.Ut){let e=this.wr.get(i)
723
723
  void 0===e&&(e=M.measureTextWidth(this.ae," ",i),this.wr.set(i,e)),t.qt>0?n=t.qt*e*.5:0>t.qt&&(n=t.qt*e*f)}return n}_r(t,e){if(void 0===t.qt||"justify"!==e||t.Ut)return 0
724
- return t.qt>0||0>t.qt?.04*t.qt*this.ae.upem:0}clearCache(){this.gr.clearCache()}yr(){return this.gr.yr()}}var mt={exports:{}},xt=o(Object.freeze({__proto__:null,default:{},Er(){throw Error("fs not available in browser")}}))
724
+ return t.qt>0||0>t.qt?.04*t.qt*this.ae.upem:0}clearCache(){this.gr.clearCache()}pr(){return this.gr.pr()}}var mt={exports:{}},xt=o(Object.freeze({__proto__:null,default:{},Er(){throw Error("fs not available in browser")}}))
725
725
  !(function(t){var e,i=(e="undefined"!=typeof document?document.currentScript?.src:void 0,async function(t={}){function i(){var t=g.buffer
726
726
  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.Tr?.(t),x(t="Aborted("+t+")"),b=!0,t+=". Build with -sASSERTIONS for more info."
727
727
  var e=new WebAssembly.RuntimeError(t)
@@ -735,12 +735,12 @@ n.open("GET",t,!0),n.responseType="arraybuffer",n.onload=()=>{200==n.status||0==
735
735
  var e=await fetch(t,{credentials:"same-origin"})
736
736
  if(e.ok)return e.arrayBuffer()
737
737
  throw Error(e.status+" : "+e.url)}}console.log.bind(console)
738
- 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
738
+ 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
739
739
  class A{name="ExitStatus"
740
- constructor(t){this.message=`Program terminated with exit(${t})`,this.status=t}}var L,M,I,F=t=>{for(;t.length>0;)t.shift()(s)},G=[],O=t=>G.push(t),k=[],C=t=>k.push(t),D=!0,B=0,U={},$=t=>{if(t instanceof A||"unwind"==t)return p
741
- h(1,t)},N=()=>D||B>0,P=t=>{p=t,N()||(s.Ar?.(t),b=!0),h(t,new A(t))},R=(t,e)=>Math.ceil(t/e)*e,W=t=>{var e=(t-g.buffer.byteLength+65535)/65536|0
740
+ constructor(t){this.message=`Program terminated with exit(${t})`,this.status=t}}var L,M,I,F=t=>{for(;t.length>0;)t.shift()(s)},G=[],O=t=>G.push(t),k=[],C=t=>k.push(t),D=!0,B=0,U={},$=t=>{if(t instanceof A||"unwind"==t)return y
741
+ h(1,t)},N=()=>D||B>0,P=t=>{y=t,N()||(s.Ar?.(t),b=!0),h(t,new A(t))},R=(t,e)=>Math.ceil(t/e)*e,W=t=>{var e=(t-g.buffer.byteLength+65535)/65536|0
742
742
  try{return g.grow(e),i(),1}catch(t){}},j=t=>{const e=t.length
743
- return[e%128|128,e>>7,...t]},z={yi:127,gi:127,xi:126,f:125,d:124,e:111},H=t=>j(Array.from(t,t=>z[t])),V=t=>L.get(t),q=[],Y=(t,e)=>L.set(t,e)
743
+ return[e%128|128,e>>7,...t]},z={pi:127,gi:127,xi:126,f:125,d:124,e:111},H=t=>j(Array.from(t,t=>z[t])),V=t=>L.get(t),q=[],Y=(t,e)=>L.set(t,e)
744
744
  s.Lr&&(D=s.Lr),s.Mr&&(x=s.Mr),s.Ir&&(d=s.Ir),s.Fr=g,s.Gr=K,s.Es=(t,e)=>{var i=(t=>(M||(M=new WeakMap,((t,e)=>{if(M)for(var i=0;0+e>i;i++){var n=V(i)
745
745
  n&&M.set(n,i)}})(0,L.length)),M.get(t)||0))(t)
746
746
  if(i)return i
@@ -750,11 +750,11 @@ var s=((t,e)=>{var i=Uint8Array.of(0,97,115,109,1,0,0,0,1,...j([1,96,...H(e.slic
750
750
  return new WebAssembly.Instance(n,{e:{f:t}}).exports.f})(t,e)
751
751
  Y(n,s)}return M.set(t,n),n},s.ks=t=>{M.delete(V(t)),Y(t,null),q.push(t)}
752
752
  var J={Or:()=>n(""),kr(){D=!1,B=0},Cr(t,e){if(U[t]&&(clearTimeout(U[t].id),delete U[t]),!e)return 0
753
- var i=setTimeout(()=>{delete U[t],(t=>{if(!b)try{t(),(()=>{if(!N())try{p=t=p,P(t)}catch(t){$(t)}var t})()}catch(t){$(t)}})(()=>I(t,performance.now()))},e)
753
+ var i=setTimeout(()=>{delete U[t],(t=>{if(!b)try{t(),(()=>{if(!N())try{y=t=y,P(t)}catch(t){$(t)}var t})()}catch(t){$(t)}})(()=>I(t,performance.now()))},e)
754
754
  return U[t]={id:i,Dr:e},0},Br(t){var e=v.length,i=2147483648
755
755
  if((t>>>=0)>i)return!1
756
756
  for(var n=1;4>=n;n*=2){var s=e*(1+.2/n),r=Math.min(i,R(Math.max(t,s=Math.min(s,t+100663296)),65536))
757
- if(W(r))return!0}return!1},Ur:P},K=await(async()=>{function t(t){return s.Gr=K=t.exports,s.Fr=g=K.memory,i(),L=K.$r,(t=>{s.Nr=t.Pr,s.Rr=t.Wr,s.jr=t.zr,s.Hr=t.Vr,s.qr=t.Yr,s.Jr=t.Kr,s.Xr=t.Qr,s.Zr=t.eo,s.io=t.no,s.so=t.ro,s.oo=t.ao,s.ho=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.Lo=t.Mo,s.Io=t.Fo,s.Go=t.Oo,s.ko=t.Co,s.Do=t.Bo,s.Uo=t.$o,s.No=t.Po,s.Ro=t.Wo,s.jo=t.As,s.zo=t.Ls,s.Ho=t.Ms,s.Vo=t.Is,s.qo=t.Fs,s.Yo=t.Ts,s.Jo=t.Os,s.Ko=t.Xo,s.Qo=t.Zo,s.ta=t.ea,s.ia=t.na,s.sa=t.ra,s.oa=t.ur,s.aa=t.ha,s.ca=t.la,s.ua=t.fa,s.da=t.pa,s.ya=t.wa,s.ga=t.va,s.ma=t.xa,s.ba=t.Sa,s._a=t.Ea,s.Ta=t.Aa,s.La=t.Ma,I=t.Ia})(K),(()=>{if(E--,s.Fa?.(E),0==E&&T){var t=T
757
+ if(W(r))return!0}return!1},Ur:P},K=await(async()=>{function t(t){return s.Gr=K=t.exports,s.Fr=g=K.memory,i(),L=K.$r,(t=>{s.Nr=t.Pr,s.Rr=t.Wr,s.jr=t.zr,s.Hr=t.Vr,s.qr=t.Yr,s.Jr=t.Kr,s.Xr=t.Qr,s.Zr=t.eo,s.io=t.no,s.so=t.ro,s.oo=t.ao,s.ho=t.co,s.lo=t.uo,s.fo=t.do,s.yo=t.po,s.wo=t.vo,s.mo=t.xo,s.bo=t.So,s._o=t.Eo,s.To=t.Ao,s.Lo=t.Mo,s.Io=t.Fo,s.Go=t.Oo,s.ko=t.Co,s.Do=t.Bo,s.Uo=t.$o,s.No=t.Po,s.Ro=t.Wo,s.jo=t.As,s.zo=t.Ls,s.Ho=t.Ms,s.Vo=t.Is,s.qo=t.Fs,s.Yo=t.Ts,s.Jo=t.Os,s.Ko=t.Xo,s.Qo=t.Zo,s.ta=t.ea,s.ia=t.na,s.sa=t.ra,s.oa=t.ur,s.aa=t.ha,s.ca=t.la,s.ua=t.fa,s.da=t.ya,s.pa=t.wa,s.ga=t.va,s.ma=t.xa,s.ba=t.Sa,s._a=t.Ea,s.Ta=t.Aa,s.La=t.Ma,I=t.Ia})(K),(()=>{if(E--,s.Fa?.(E),0==E&&T){var t=T
758
758
  T=null,t()}})(),K}E++,s.Fa?.(E)
759
759
  var e,r={o:J,Ga:J}
760
760
  return s.Oa?new Promise(e=>{s.Oa(r,i=>{e(t(i))})}):(m??=(e="hb.wasm",s.ka?s.ka(e,u):u+e),t((await(async function(t,e,i){if(!t&&!S(e)&&!a)try{var s=fetch(e,{credentials:"same-origin"})
@@ -763,9 +763,9 @@ return new Uint8Array(e)}catch{}return(t=>{if(t==m&&d)return new Uint8Array(d)
763
763
  if(l)return l(t)
764
764
  throw"both async and sync fetching of the wasm failed"})(t)})(t)
765
765
  return await WebAssembly.instantiate(i,e)}catch(t){x("failed to asynchronously prepare wasm: "+t),n(t)}})(e,i)})(d,m,r)).Ca))})()
766
- return(()=>{if(s.Da)for("function"==typeof s.Da&&(s.Da=[s.Da]);s.Da.length>0;)s.Da.shift()()})(),(function t(){function e(){s.Ba=!0,b||(_=!0,K.Ua(),y?.(s),s.$a?.(),(()=>{if(s.Na)for("function"==typeof s.Na&&(s.Na=[s.Na]);s.Na.length;)O(s.Na.shift())
766
+ return(()=>{if(s.Da)for("function"==typeof s.Da&&(s.Da=[s.Da]);s.Da.length>0;)s.Da.shift()()})(),(function t(){function e(){s.Ba=!0,b||(_=!0,K.Ua(),p?.(s),s.$a?.(),(()=>{if(s.Na)for("function"==typeof s.Na&&(s.Na=[s.Na]);s.Na.length;)O(s.Na.shift())
767
767
  F(G)})())}E>0?T=t:((()=>{if(s.Pa)for("function"==typeof s.Pa&&(s.Pa=[s.Pa]);s.Pa.length;)C(s.Pa.shift())
768
- F(k)})(),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})})
768
+ F(k)})(),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})})
769
769
  t.exports=i,t.exports.default=i})(mt)
770
770
  var bt=r(mt.exports),St={exports:{}}
771
771
  try{St.exports=t=>{function e(t){return(255&t.charCodeAt(0))<<24|(255&t.charCodeAt(1))<<16|(255&t.charCodeAt(2))<<8|255&t.charCodeAt(3)}function i(e){var i=s.Po(e.length+1)
@@ -791,21 +791,21 @@ n[(r=t.HEAPU32[e/4+8*s+1],""+String.fromCharCode(r>>24&255)+String.fromCharCode(
791
791
  s.ra(r,e)
792
792
  var i=(e=>{const i=s.Ea(e),n=s.Po(i<<2),r=n>>2,o=t.HEAPU32.subarray(r,r+i)
793
793
  return t.HEAPU32.set(o,r),s.Aa(e,-1,n,i),o})(e)
794
- return s.xa(e),i},destroy(){s.Zo(r)}}},Xe(i){function n(t){return c||(f=o((t,e,i,n,s)=>{l+=`M${n},${s}`},"viiiffi"),d=o((t,e,i,n,s)=>{l+=`L${n},${s}`},"viiiffi"),p=o((t,e,i,n,s,r,o,a,h)=>{l+=`C${n},${s} ${r},${o} ${a},${h}`},"viiiffffffi"),y=o((t,e,i,n,s,r,o)=>{l+=`Q${n},${s} ${r},${o}`},"viiiffffi"),w=o(()=>{l+="Z"},"viiii"),c=s.Ts(),s.As(c,f,0,0),s.Ls(c,d,0,0),s.Is(c,p,0,0),s.Ms(c,y,0,0),s.Fs(c,w,0,0)),l="",s.ur(h,t,c,0),l}var h=s.la(i.dr),c=null,f=null,d=null,p=null,y=null,w=null
794
+ return s.xa(e),i},destroy(){s.Zo(r)}}},Xe(i){function n(t){return c||(f=o((t,e,i,n,s)=>{l+=`M${n},${s}`},"viiiffi"),d=o((t,e,i,n,s)=>{l+=`L${n},${s}`},"viiiffi"),y=o((t,e,i,n,s,r,o,a,h)=>{l+=`C${n},${s} ${r},${o} ${a},${h}`},"viiiffffffi"),p=o((t,e,i,n,s,r,o)=>{l+=`Q${n},${s} ${r},${o}`},"viiiffffi"),w=o(()=>{l+="Z"},"viiii"),c=s.Ts(),s.As(c,f,0,0),s.Ls(c,d,0,0),s.Is(c,y,0,0),s.Ms(c,p,0,0),s.Fs(c,w,0,0)),l="",s.ur(h,t,c,0),l}var h=s.la(i.dr),c=null,f=null,d=null,y=null,p=null,w=null
795
795
  return{dr:h,ja(e){s.ha(h,e,u,256)
796
796
  var i=t.HEAPU8.subarray(u,u+256)
797
797
  return r.decode(i.slice(0,i.indexOf(0)))},za:n,Ha:t=>n(t).replace(/([MLQCZ])/g,"|$1 ").split("|").filter(t=>t.length).map(t=>{var e=t.split(/[ ,]/g)
798
798
  return{type:e[0],values:e.slice(1).filter(t=>t.length).map(t=>+t)}}),setScale(t,e){s.wa(h,t,e)},Qe(i){var n=Object.entries(i),r=s.Po(8*n.length)
799
- n.forEach((i,n)=>{t.HEAPU32[r/4+2*n+0]=e(i[0]),t.HEAPF32[r/4+2*n+1]=i[1]}),s.fa(h,r,n.length),s.Wo(r)},destroy(){s.pa(h),c&&(s.Os(c),c=null,a(f),a(d),a(p),a(y),a(w))}}},createBuffer(){var e=s.Kr()
799
+ n.forEach((i,n)=>{t.HEAPU32[r/4+2*n+0]=e(i[0]),t.HEAPF32[r/4+2*n+1]=i[1]}),s.fa(h,r,n.length),s.Wo(r)},destroy(){s.ya(h),c&&(s.Os(c),c=null,a(f),a(d),a(y),a(p),a(w))}}},createBuffer(){var e=s.Kr()
800
800
  return{dr:e,ne(i){const n=(e=>{const i=s.Po(2*e.length),n=new Uint16Array(t.Fr.buffer,i,e.length)
801
801
  for(let t=0;n.length>t;++t)n[t]=e.charCodeAt(t)
802
802
  return{dr:i,length:n.length,Wo(){s.Wo(i)}}})(i)
803
803
  s.Ao(e,n.dr,n.length,0,n.length),n.Wo()},se:()=>s.So(e),br(t){s.no(e,{Va:4,qa:5,Ya:6,Ja:7}[t]||0)},Ka(t){var i=0
804
804
  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.co(e,i)},Xa(t){var n=i(t)
805
805
  s.ao(e,s.Fo(n.dr,-1)),n.Wo()},Qa(t){var n=i(t)
806
- s.ro(e,s.Oo(n.dr,-1)),n.Wo()},Za(t){s.uo(e,t)},json(){for(var i=s.do(e),n=[],r=s.yo(e,0),o=r/4,a=s.vo(e,0)/4,h=t.HEAPU32.subarray(o,o+5*i),c=t.HEAP32.subarray(a,a+5*i),l=0;i>l;++l)n.push({g:h[5*l+0],oe:h[5*l+2],ax:c[5*l+0],ay:c[5*l+1],dx:c[5*l+2],dy:c[5*l+3],flags:s.xo(r+20*l)})
807
- return n},destroy(){s.Qr(e)}}},shape:n,th(e,i,h,l,u){var f=[],d=0,p=!1,y=1048576,w=s.Po(y),g=o((e,i,n)=>{var o=r.decode(t.HEAPU8.subarray(n,t.HEAPU8.indexOf(0,n)))
808
- 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.Yr(e,0,s.do(e),w,y,0,i,c,4),f.push({bi:o,Ti:JSON.parse(r.decode(t.HEAPU8.subarray(w,t.HEAPU8.indexOf(0,w)))),glyphs:2==s.eo(e)}),1)},"iiiii")
806
+ s.ro(e,s.Oo(n.dr,-1)),n.Wo()},Za(t){s.uo(e,t)},json(){for(var i=s.do(e),n=[],r=s.po(e,0),o=r/4,a=s.vo(e,0)/4,h=t.HEAPU32.subarray(o,o+5*i),c=t.HEAP32.subarray(a,a+5*i),l=0;i>l;++l)n.push({g:h[5*l+0],oe:h[5*l+2],ax:c[5*l+0],ay:c[5*l+1],dx:c[5*l+2],dy:c[5*l+3],flags:s.xo(r+20*l)})
807
+ return n},destroy(){s.Qr(e)}}},shape:n,th(e,i,h,l,u){var f=[],d=0,y=!1,p=1048576,w=s.Po(p),g=o((e,i,n)=>{var o=r.decode(t.HEAPU8.subarray(n,t.HEAPU8.indexOf(0,n)))
808
+ 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.Yr(e,0,s.do(e),w,p,0,i,c,4),f.push({bi:o,Ti:JSON.parse(r.decode(t.HEAPU8.subarray(w,t.HEAPU8.indexOf(0,w)))),glyphs:2==s.eo(e)}),1)},"iiiii")
809
809
  return s.Mo(i.dr,g,0,0),n(e,i,h),s.Wo(w),a(g),f},version(){var e=s.Po(12)
810
810
  s.Co(e,e+4,e+8)
811
811
  var i={eh:t.HEAPU32[e/4],ih:t.HEAPU32[(e+4)/4],nh:t.HEAPU32[(e+8)/4]}
@@ -819,9 +819,9 @@ e.ka=(t,e)=>t.endsWith(".wasm")?Tt:e+t}const i=await bt(e)
819
819
  t({hb:_t(i),module:{Es:i.Es,exports:i.Gr,ks:i.ks}})}catch(t){e(Error("Failed to initialize HarfBuzz: "+t))}}),Et)}
820
820
  class Mt{constructor(t,e){this.text=t,this.hh=new Map,e.forEach(t=>{const e=this.hh.get(t.hr)||[]
821
821
  e.push(t),this.hh.set(t.hr,e)})}uh(t){const e=[]
822
- return t.fh&&e.push(...this.dh(t.fh)),t.ph&&e.push(...this.yh(t.ph)),e}dh(t){const e=[]
822
+ return t.fh&&e.push(...this.dh(t.fh)),t.yh&&e.push(...this.ph(t.yh)),e}dh(t){const e=[]
823
823
  for(const i of t){let t=0
824
- for(;-1!==(t=this.text.indexOf(i,t));)e.push(this.createTextRange(t,t+i.length,i)),t+=i.length}return e}yh(t){return t.map(t=>{const e=this.text.slice(t.start,t.end)
824
+ for(;-1!==(t=this.text.indexOf(i,t));)e.push(this.createTextRange(t,t+i.length,i)),t+=i.length}return e}ph(t){return t.map(t=>{const e=this.text.slice(t.start,t.end)
825
825
  return this.createTextRange(t.start,t.end,e)})}createTextRange(t,e,i){const n=[],s=new Map
826
826
  for(let i=t;e>i;i++){const t=this.hh.get(i)
827
827
  if(t)for(const e of t){n.push(e)
@@ -866,56 +866,67 @@ const e=await this.Ph(t)
866
866
  this.Rh(e),this.Wh(t=e),this.gr||(this.gr=new gt(Q,this.ae),this.gr.Hs(this.Lh)),this.gr.Fn(t.jh),this.gr.fs(t.zh),this.ae.font.setScale(this.ae.upem,this.ae.upem),this.Hh||(this.Hh=new vt(this.ae,this.gr))
867
867
  const i=this.Vh(t),n=t.qh??this.ae.ei??!1,s=this.Hh.vr(i.lines,i.Yh,i.letterSpacing,i.align,i.direction,t.color,t.text)
868
868
  let r,o
869
- if(t.color&&"object"==typeof t.color&&!Array.isArray(t.color)&&(t.color.fh||t.color.ph)){if(r=new Set,t.color.fh){o=[]
869
+ if(t.color&&"object"==typeof t.color&&!Array.isArray(t.color)&&(t.color.fh||t.color.yh)){if(r=new Set,t.color.fh){o=[]
870
870
  for(const e of Object.keys(t.color.fh)){let i=0
871
871
  for(;-1!==(i=t.text.indexOf(e,i));){o.push({pattern:e,start:i,end:i+e.length})
872
872
  for(let t=i;i+e.length>t;t++)r.add(t)
873
- i+=e.length}}}if(t.color.ph)for(const e of t.color.ph)for(let t=e.start;e.end>t;t++)r.add(t)}const a=this.gr.qs(s,i.depth,n,this.ae.h.Se,i.Jh,t.perGlyphAttributes??!1,r),h=this.Kh(a.vertices,a.normals,a.indices,a.ar,a.planeBounds,t,t.text,o)
873
+ i+=e.length}}}if(t.color.yh)for(const e of t.color.yh)for(let t=e.start;e.end>t;t++)r.add(t)}const a=this.gr.qs(s,i.depth,n,this.ae.h.Se,i.Jh,t.perGlyphAttributes??!1,r),h=this.Kh(a.vertices,a.normals,a.indices,a.ar,a.planeBounds,t,t.text,o)
874
874
  if(t.perGlyphAttributes){const t=this.Xh(h.vertices.length/3,h.glyphs)
875
875
  h.glyphAttributes=t}return h}finally{}}async Ph(t){if(!1!==t.layout?.dt&&t.layout?.width){const e=t.layout?.language||"en-us"
876
876
  if(!t.layout?.gt?.[e])try{if(!Ft.xh.has(e)){const n=await i(e,t.layout?.Qh)
877
877
  Ft.xh.set(e,n)}return{...t,layout:{...t.layout,gt:{...t.layout?.gt,[e]:Ft.xh.get(e)}}}}catch(i){return h.warn(`Failed to load patterns for ${e}: ${i}`),{...t,layout:{...t.layout,dt:!1}}}}return t}Rh(t){if(!t.text)throw Error("Text content is required")
878
878
  const e=t.Zh??1e5
879
879
  if(t.text.length>e)throw Error(`Text exceeds ${e} character limit`)}Wh(t){t.ti&&this.ae&&Ft.Ah(t.ti)!==Ft.Ah(this.ae.ti||{})&&(this.ae.font.Qe(t.ti),this.ae.ti=t.ti)}Vh(t){if(!this.ae)throw Error("Font not loaded. Use Text.create() with a font option")
880
- const{text:e,size:i=It,depth:n=0,lineHeight:s=1,letterSpacing:r=0,layout:o={}}=t,{width:a,direction:h="ltr",align:f=("rtl"===h?"right":"left"),yt:d=!0,dt:p=!0,language:y="en-us",xt:w=c,bt:g=l,St:v=u,_t:m,gt:x,Et:b,Tt:S,At:_,Lt:E,Mt:T,It:A,Ft:L,Gt:M,Ot:F,kt:G}=o,O=this.ae.upem/i
880
+ const{text:e,size:i=It,depth:n=0,lineHeight:s=1,letterSpacing:r=0,layout:o={}}=t,{width:a,direction:h="ltr",align:f=("rtl"===h?"right":"left"),yt:d=!0,dt:y=!0,language:p="en-us",xt:w=c,bt:g=l,St:v=u,_t:m,gt:x,Et:b,Tt:S,At:_,Lt:E,Mt:T,It:A,Ft:L,Gt:M,Ot:F,kt:G}=o,O=this.ae.upem/i
881
881
  let k
882
882
  void 0!==a&&(k=a*O)
883
883
  const C=n*O,D=C>0?Math.max(C,25e-6*this.ae.upem):0
884
884
  this.tc||(this.tc=new I(this.ae))
885
- const B=this.tc.he({text:e,width:k,align:f,direction:h,dt:p,language:y,yt:d,xt:w,bt:g,St:v,_t:m,gt:x,Et:b,Tt:S,At:_,Lt:E,Mt:T,It:A,Ft:L,Gt:M,Ot:F,kt:G,letterSpacing:r}),U=z.Pe(this.ae.h)
886
- return{lines:B.lines,Yh:(U.de-U.pe)*s,letterSpacing:r,align:f,direction:h,depth:D,size:i,Jh:1/O}}ec(t,e,i,n,s){const r=t.length/3,o=new Float32Array(3*r),a=[]
885
+ const B=this.tc.he({text:e,width:k,align:f,direction:h,dt:y,language:p,yt:d,xt:w,bt:g,St:v,_t:m,gt:x,Et:b,Tt:S,At:_,Lt:E,Mt:T,It:A,Ft:L,Gt:M,Ot:F,kt:G,letterSpacing:r}),U=z.Pe(this.ae.h)
886
+ return{lines:B.lines,Yh:(U.de-U.ye)*s,letterSpacing:r,align:f,direction:h,depth:D,size:i,Jh:1/O}}ec(t,e,i,n,s){const r=t.length/3,o=new Float32Array(3*r),a=[]
887
887
  if(Array.isArray(i)){for(let t=0;r>t;t++){const e=3*t
888
888
  o[e]=i[0],o[e+1]=i[1],o[e+2]=i[2]}a.push({start:0,end:n.length,wh:n,color:i,bounds:[],glyphs:e,mh:[...new Set(e.map(t=>t.cr))]})}else{const t=i.default||[1,1,1]
889
889
  for(let e=0;o.length>e;e+=3)o[e]=t[0],o[e+1]=t[1],o[e+2]=t[2]
890
- if(i.fh&&s){const t=new Map
891
- for(const i of e){const e=t.get(i.hr)
892
- e?e.push(i):t.set(i.hr,[i])}for(const e of s){const n=i.fh[e.pattern]
893
- if(!n)continue
894
- const s=[],r=new Set
895
- for(let i=e.start;e.end>i;i++){const e=t.get(i)
896
- if(e)for(const t of e){s.push(t),r.add(t.cr)
897
- for(let e=0;t.lr>e;e++){const i=3*(t.Ks+e)
898
- i>=0&&o.length>i&&(o[i]=n[0],o[i+1]=n[1],o[i+2]=n[2])}}}a.push({start:e.start,end:e.end,wh:e.pattern,color:n,bounds:[],glyphs:s,mh:Array.from(r).sort((t,e)=>t-e)})}}i.ph&&i.ph.forEach(t=>{const i=[]
899
- for(const n of e)if(n.hr>=t.start&&t.end>n.hr){i.push(n)
890
+ let r
891
+ if(i.fh&&s||i.yh){r=new Map
892
+ for(const t of e){const e=r.get(t.hr)
893
+ e?e.push(t):r.set(t.hr,[t])}}if(i.fh&&s&&r)for(const t of s){const e=i.fh[t.pattern]
894
+ if(!e)continue
895
+ const n=[],s=new Map
896
+ for(let i=t.start;t.end>i;i++){const t=r.get(i)
897
+ if(t)for(const i of t){n.push(i)
898
+ const t=s.get(i.cr)
899
+ t?t.push(i):s.set(i.cr,[i])
900
+ for(let t=0;i.lr>t;t++){const n=3*(i.Ks+t)
901
+ n>=0&&o.length>n&&(o[n]=e[0],o[n+1]=e[1],o[n+2]=e[2])}}}const h=Array.from(s.values()).map(t=>this.nc(t))
902
+ a.push({start:t.start,end:t.end,wh:t.pattern,color:e,bounds:h,glyphs:n,mh:Array.from(s.keys()).sort((t,e)=>t-e)})}if(i.yh&&r)for(const t of i.yh){const e=[],i=new Map
903
+ for(let n=t.start;t.end>n;n++){const s=r.get(n)
904
+ if(s)for(const n of s){e.push(n)
905
+ const s=i.get(n.cr)
906
+ s?s.push(n):i.set(n.cr,[n])
900
907
  for(let e=0;n.lr>e;e++){const i=3*(n.Ks+e)
901
- i>=0&&o.length>i&&(o[i]=t.color[0],o[i+1]=t.color[1],o[i+2]=t.color[2])}}a.push({start:t.start,end:t.end,wh:n.slice(t.start,t.end),color:t.color,bounds:[],glyphs:i,mh:[...new Set(i.map(t=>t.cr))]})})}return{colors:o,nc:a}}Kh(t,e,i,n,s,r,o,a){const{layout:h={}}=r,{width:c,align:l=("rtl"===h.direction?"right":"left")}=h
908
+ 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.nc(t))
909
+ a.push({start:t.start,end:t.end,wh:n.slice(t.start,t.end),color:t.color,bounds:s,glyphs:e,mh:Array.from(i.keys()).sort((t,e)=>t-e)})}}return{colors:o,sc:a}}nc(t){if(0===t.length)return{min:{x:0,y:0,z:0},max:{x:0,y:0,z:0}}
910
+ let e=1/0,i=1/0,n=1/0,s=-1/0,r=-1/0,o=-1/0
911
+ for(const a of t)e>a.bounds.min.x&&(e=a.bounds.min.x),i>a.bounds.min.y&&(i=a.bounds.min.y),n>a.bounds.min.z&&(n=a.bounds.min.z),a.bounds.max.x>s&&(s=a.bounds.max.x),a.bounds.max.y>r&&(r=a.bounds.max.y),a.bounds.max.z>o&&(o=a.bounds.max.z)
912
+ return{min:{x:e,y:i,z:n},max:{x:s,y:r,z:o}}}Kh(t,e,i,n,s,r,o,a){const{layout:h={}}=r,{width:c,align:l=("rtl"===h.direction?"right":"left")}=h
902
913
  this.tc||(this.tc=new I(this.ae))
903
914
  const u=this.tc.ue({width:c,align:l,planeBounds:s}),f=u.offset
904
915
  if(s.min.x=u.le.min.x,s.max.x=u.le.max.x,0!==f){for(let e=0;t.length>e;e+=3)t[e]+=f
905
- for(let t=0;n.length>t;t++)n[t].bounds.min.x+=f,n[t].bounds.max.x+=f}let d,p
916
+ for(let t=0;n.length>t;t++)n[t].bounds.min.x+=f,n[t].bounds.max.x+=f}let d,y
906
917
  if(r.color){const e=this.ec(t,n,r.color,r.text,a)
907
- d=e.colors,p=e.nc}const y=this.gr.ds()
908
- return{vertices:t,normals:e,indices:i,colors:d,glyphs:n,planeBounds:s,stats:{sc:i.length/3,rc:t.length/3,wn:y.wn,gn:y.gn,vn:y.vn},query:(()=>{let t=null
918
+ d=e.colors,y=e.sc}const p=this.gr.ds()
919
+ return{vertices:t,normals:e,indices:i,colors:d,glyphs:n,planeBounds:s,stats:{rc:i.length/3,oc:t.length/3,wn:p.wn,gn:p.gn,vn:p.vn},query:(()=>{let t=null
909
920
  return e=>{if(!o)throw Error("Original text not available for querying")
910
- return t||(t=new Mt(o,n)),t.uh(e)}})(),nc:p,glyphAttributes:void 0}}Re(){if(!this.ae)throw Error("Font not loaded. Call loadFont() first")
911
- return z.Re(this.ae.h)}static async oc(t,e){await Promise.all(t.map(async t=>{if(!Ft.xh.has(t))try{const n=await i(t,e)
912
- Ft.xh.set(t,n)}catch(e){h.warn(`Failed to pre-load patterns for ${t}: ${e}`)}}))}static ac(t,e){Ft.xh.set(t,e)}static hc(t){Ft.Eh=t===1/0?1/0:1048576*Math.max(1,Math.floor(t)),Ft.$h()}getLoadedFont(){return this.ae}measureTextWidth(t,e=0){if(!this.ae)throw Error("Font not loaded. Call loadFont() first")
913
- return M.measureTextWidth(this.ae,t,e)}getCacheSize(){return this.gr?this.gr.yr().size:0}clearCache(){this.gr&&this.gr.clearCache()}Xh(t,e){const i=new Float32Array(3*t),n=new Float32Array(t),s=new Float32Array(t),r=new Float32Array(t),o=new Float32Array(t)
921
+ return t||(t=new Mt(o,n)),t.uh(e)}})(),sc:y,glyphAttributes:void 0}}Re(){if(!this.ae)throw Error("Font not loaded. Call loadFont() first")
922
+ return z.Re(this.ae.h)}static async ac(t,e){await Promise.all(t.map(async t=>{if(!Ft.xh.has(t))try{const n=await i(t,e)
923
+ Ft.xh.set(t,n)}catch(e){h.warn(`Failed to pre-load patterns for ${t}: ${e}`)}}))}static hc(t,e){Ft.xh.set(t,e)}static cc(t){Ft.Eh=t===1/0?1/0:1048576*Math.max(1,Math.floor(t)),Ft.$h()}getLoadedFont(){return this.ae}measureTextWidth(t,e=0){if(!this.ae)throw Error("Font not loaded. Call loadFont() first")
924
+ return M.measureTextWidth(this.ae,t,e)}getCacheSize(){return this.gr?this.gr.pr().size:0}clearCache(){this.gr&&this.gr.clearCache()}Xh(t,e){const i=new Float32Array(3*t),n=new Float32Array(t),s=new Float32Array(t),r=new Float32Array(t),o=new Float32Array(t)
914
925
  let a=1/0,h=-1/0
915
926
  for(let t=0;e.length>t;t++){const i=(e[t].bounds.min.x+e[t].bounds.max.x)/2
916
927
  a>i&&(a=i),i>h&&(h=i)}const c=h-a
917
- for(let h=0;e.length>h;h++){const l=e[h],u=(l.bounds.min.x+l.bounds.max.x)/2,f=(l.bounds.min.y+l.bounds.max.y)/2,d=(l.bounds.min.z+l.bounds.max.z)/2,p=l.bounds.min.y,y=c>0?(u-a)/c:0,w=l.Ks,g=Math.min(w+l.lr,t)
918
- if(g>w){n.fill(h,w,g),s.fill(l.cr,w,g),r.fill(y,w,g),o.fill(p,w,g)
928
+ for(let h=0;e.length>h;h++){const l=e[h],u=(l.bounds.min.x+l.bounds.max.x)/2,f=(l.bounds.min.y+l.bounds.max.y)/2,d=(l.bounds.min.z+l.bounds.max.z)/2,y=l.bounds.min.y,p=c>0?(u-a)/c:0,w=l.Ks,g=Math.min(w+l.lr,t)
929
+ if(g>w){n.fill(h,w,g),s.fill(l.cr,w,g),r.fill(p,w,g),o.fill(y,w,g)
919
930
  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}}Ch(){this.gr=void 0,this.Hh=void 0,this.tc=void 0}destroy(){if(!this.ae)return
920
931
  const t=this.ae
921
932
  try{V.oi(t)}catch(t){h.warn("Error destroying HarfBuzz objects:",t)}finally{this.ae=void 0,this.tc=void 0,this.Hh=void 0}}}export{ut as DEFAULT_CURVE_FIDELITY,z as FontMetadataExtractor,Ft as Text,s as createGlyphCache,Q as globalGlyphCache}