three-text 0.4.0 → 0.4.2

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