three-text 0.4.1 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * three-text v0.4.1
2
+ * three-text v0.4.3
3
3
  * Copyright (C) 2025 Countertype LLC
4
4
  *
5
5
  * This program is free software: you can redistribute it and/or modify
@@ -57,228 +57,228 @@ this.start(t,i)
57
57
  try{return e()}finally{this.end(t)}}async T(t,e,i){if(!h)return e()
58
58
  this.start(t,i)
59
59
  try{return await e()}finally{this.end(t)}}}
60
- const c=800,l=100,u=0,f=1/3
60
+ const l=800,c=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
70
  const i=Math.abs(t/e)
71
- return i>10?10001:Math.min(Math.round(100*i**3),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
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
88
- let c,l,u,y=s
89
- if(r)c=r.width,l=r.stretch,u=r.R
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,l){const c=[]
82
+ return c.push(...this.Y(t,e,i,n,s,r,o,h,a,l)),c.push({type:d.GLUE,width:0,stretch:1e7,J:0,text:"",K:t.length}),c.push({type:d.PENALTY,width:0,X:E,text:"",K:t.length}),c}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
86
+ let l,c,u,y=s
87
+ if(r)l=r.width,c=r.stretch,u=r.J
90
88
  else{const t=e("字")
91
- 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
89
+ l=0,c=.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:l,stretch:c,J:u,text:"",K:y})}}return o}static Y(t,e,i,n,s,r,o,h,a,l){const c=[],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?c.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})())):c.push(...this.st(d,y,e,n,s,r,o,h,a,l)),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(),c}static st(t,e,i,n,s,r,o,h,a,l){const c=[],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
+ c.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)c.push({type:d.DISCRETIONARY,width:i("-"),rt:"-",ot:"",ht:"-",lt:i("-"),X:a?.ct??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&&(c.push({type:d.BOX,width:i(s),text:s,K:f+n}),n+=s.length),e.length-1>t&&(c.push({type:d.DISCRETIONARY,width:0,rt:"-",ot:"",ht:"",lt: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)
116
- 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)
118
- 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
113
+ c.push({type:d.BOX,width:i(e),text:e,K:f+n}),c.push({type:d.DISCRETIONARY,width:0,rt:"-",ot:"",ht:"",lt:i("-"),X:a?.ft??w,ut:!0,text:"",K:f+s}),n=s}c.push({type:d.BOX,width:i(t.substring(n)),text:t.substring(n),K:f+n})}else{const e=i(t)
114
+ if(l&&e>l){const e=Array.from(t)
115
+ for(let t=0;e.length>t;t++)c.push({type:d.BOX,width:i(e[t]),text:e[t],K:f+t}),e.length-1>t&&c.push({type:d.PENALTY,width:0,X:5e3,K:f+t+1})}else c.push({type:d.BOX,width:e,text:t,K:f})}}else{const e=i(t)
116
+ if(l&&e>l){const e=Array.from(t)
117
+ for(let t=0;e.length>t;t++)c.push({type:d.BOX,width:i(e[t]),text:e[t],K:f+t}),e.length-1>t&&c.push({type:d.PENALTY,width:0,X:5e3,K:f+t+1})}else c.push({type:d.BOX,width:e,text:t,K:f})}f+=t.length}y+=t.length}}return c}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 l=0;t.length>l;l++){const c=t[l]
121
+ if(!(c.type===d.PENALTY&&1e4>c.X||c.type===d.DISCRETIONARY||c.type===d.GLUE&&l>0&&t[l-1].type===d.BOX)){c.type===d.BOX?o+=c.width:c.type===d.GLUE?(o+=c.width,h+=c.stretch,a+=c.J):c.type===d.DISCRETIONARY&&(o+=c.width)
122
+ continue}let u=0,f=!1;(c.type===d.PENALTY||c.type===d.DISCRETIONARY)&&(u=c.X,f=c.ut||!1)
123
+ let y=0
124
+ c.type===d.DISCRETIONARY&&(y=c.lt)
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],c=h-r.N,d=a-r.U,m=e-(o-r.D+y)
127
+ let x
128
+ if(m>0){const t=c+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?c+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:l,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
+ c.type===d.BOX?o+=c.width:c.type===d.GLUE?(o+=c.width,h+=c.stretch,a+=c.J):c.type===d.DISCRETIONARY&&(o+=c.width)}let l=null,c=1/0
142
+ for(const t of r.W())c>t.G&&(c=t.G,l=t)
143
+ return l}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=l,Tt:A=c,At:M=u,Mt:I,It:F=S,Ft:L=_,Lt:G=x,Gt:O=b,Ot:C=w,Ct:k=g,kt: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:C,ct:k,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
- for(let t=0;i.length>t;t++){const c=i[t],l=!(e.length-1>i[i.length-1]+1)&&t===i.length-1,u=[]
164
+ for(let t=0;i.length>t;t++){const l=i[t],c=!(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
- 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]
166
+ for(let t=a;l>t;t++){const i=e[t]
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[l]
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>l)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.lt,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
- if("justify"===s&&l&&(_="rtl"===r?"right":"left"),"center"===_)b=(n-p)/2
176
+ if("justify"===s&&c&&(_="rtl"===r?"right":"left"),"center"===_)b=(n-p)/2
177
177
  else if("right"===_)b=n-p
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=[]
180
- let i=-1,c=-1,l=0
178
+ else if("justify"===_&&!c){const t=n-p
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=l+1}if(e.length-1>a){const t=[]
180
+ let i=-1,l=-1,c=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>l&&(l=s.K)),s.text&&t.push(s.text),c+=s.width)}o?.Rt&&0!==c&&(c-=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-c)/2:"right"===f&&(u=n-c),h.push({text:t.join(""),Bt:i,Nt:l,Ut:u,Ht:0,Pt:!0,naturalWidth:c,$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
- 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
195
+ const o=a.json(t.font),l=n*t.upem
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
- 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)
200
+ break}}void 0!==n&&(h[n]+=e.ax,0!==l&&(h[n]+=l))}return h}finally{a.destroy()}}static measureTextWidth(t,i,n=0){const s=t.hb.createBuffer()
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:l,At:c,Mt:u,St:f,It:d,Ft:y,Lt:p,Gt:w,Ot:g,Ct:v,kt: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:l,At:c,Mt:u,St:f,It:d,Ft:y,Lt:p,Gt:w,Ot:g,Ct:v,kt:m,_t:this.Kt.upem,letterSpacing:x,measureText:t=>M.measureTextWidth(this.Kt,t,x),bt:t=>M.bt(this.Kt,t,x)})
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,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 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(C)?.offset??0,a=s.get(k)?.offset??0,l=s.get(D)?.offset??0,c=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),le: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)
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={}
227
+ return l&&c&&u&&(p=this.ce(e,c,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,le:y?.le||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
+ t.features.forEach(t=>h.add(t)),Object.assign(a,t.names)}}catch(t){return}const l=Array.from(h).sort()
231
+ if(0!==l.length)return{tags:l,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 ce(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)
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
- if(c!==i)continue
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)),l=t.getUint16(s+4),c=this.ve(t,i,l)
239
+ c&&(o[a]=c)}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
+ 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),l=t.getUint16(n+6),c=t.getUint16(n+8),u=t.getUint16(n+10)
241
+ if(l!==i)continue
242
242
  if(0!==o&&(3!==o||1033!==a))continue
243
- const f=new Uint8Array(t.buffer,e+s+u,l)
243
+ const f=new Uint8Array(t.buffer,e+s+u,c)
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),l=t.getUint16(n+6),c=t.getUint16(n+8),u=t.getUint16(n+10);(0===o||3===o&&1033===a)&&(i.has(l)||i.set(l,{offset:e+s+u,length:c,_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
256
- let l=null
257
- r&&(l={te:t.getInt16(r+4),ee:t.getInt16(r+6),ie:t.getInt16(r+8)})
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(C)?.offset??0,o=e.get(k)?.offset??0,h=e.get(D)?.offset??0,a=e.get(B)?.offset??0,l=s?t.getUint16(s+18):1e3
256
+ let c=null
257
+ r&&(c={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),le: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:l,fe:c?.ie||null,de:c?.ne||null,ye:c?.se||null,re:u?.re||null,oe:u?.oe||null,he:u?.he||null,ae:u?.ae||null,le:u?.le||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)),l=t.getUint16(s+4),c=this.Te(t,i,l)
264
+ c&&(o[a]=c)}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
269
269
  if(!i)continue
270
270
  if(29555!==a&&25462!==a)continue
271
- const c=h>>8&255,l=255&h
272
- if(48>c||c>57||48>l||l>57)continue
271
+ const l=h>>8&255,c=255&h
272
+ if(48>l||l>57||48>c||c>57)continue
273
273
  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.le?{ie:t.ae,ne:-t.le,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 Ce(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.")
@@ -286,445 +286,487 @@ const o=new Uint8Array(r),h=new DataView(o.buffer)
286
286
  h.setUint32(0,n),h.setUint16(4,s)
287
287
  const a=2**Math.floor(Math.log2(s))*16
288
288
  h.setUint16(6,a),h.setUint16(8,Math.floor(Math.log2(s))),h.setUint16(10,16*s-a)
289
- let c=12+16*s
290
- const l=[]
289
+ let l=12+16*s
290
+ const c=[]
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
+ c.push({tag:e.getUint32(i),offset:e.getUint32(i+4),length:e.getUint32(i+8),ke:e.getUint32(i+12),t:e.getUint32(i+16)})}c.sort((t,e)=>t.tag-e.tag)
293
+ const u=await Promise.all(c.map(async t=>{if(t.length===t.ke)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.ke)throw Error(`Decompression failed: expected ${t.ke} bytes, got ${n.byteLength}`)
296
296
  return new Uint8Array(n)}))
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)
297
+ for(let t=0;s>t;t++){const e=c[t],i=12+16*t
298
+ h.setUint32(i,e.tag),h.setUint32(i+4,e.t),h.setUint32(i+8,l),h.setUint32(i+12,e.ke),o.set(u[t],l),l+=e.ke,l+=(4-e.ke%4)%4}return o.buffer.slice(0,l)}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.Ce(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:l,features:c}=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:l.pe?.[t]||null}}return{hb:s,fontBlob:i,face:n,font:o,module:r,upem:l._t,h:l,Re:e,je:a,He:u,Ve:c?.tags,qe:c?.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
322
322
  return n+s>0?s>n?e.a-t.a+n/(n+s)*(t.a-i.a):e.a-i.a+s/(n+s)*(i.a-t.a):0}function s(t,e,i){var n=e.b-t.b,s=i.b-e.b
323
323
  return n+s>0?(e.a-i.a)*n+(e.a-t.a)*s:0}function r(t,e){return e.a>t.a||t.a===e.a&&e.b>=t.b}function o(t,e,i){var n=e.a-t.a,s=i.a-e.a
324
324
  return n+s>0?s>n?e.b-t.b+n/(n+s)*(t.b-i.b):e.b-i.b+s/(n+s)*(i.b-t.b):0}function h(t,e,i){var n=e.a-t.a,s=i.a-e.a
325
- return n+s>0?(e.b-i.b)*n+(e.b-t.b)*s:0}function a(t){return i(t.b.a,t.a)}function c(t){return i(t.a,t.b.a)}function l(t,e,i,n){return(t=0>t?0:t)>(i=0>i?0:i)?n+i/(t+i)*(e-n):0===i?(e+n)/2:e+t/(t+i)*(n-e)}function u(t){var e=w(t.b)
325
+ return n+s>0?(e.b-i.b)*n+(e.b-t.b)*s:0}function a(t){return i(t.b.a,t.a)}function l(t){return i(t.a,t.b.a)}function c(t,e,i,n){return(t=0>t?0:t)>(i=0>i?0:i)?n+i/(t+i)*(e-n):0===i?(e+n)/2:e+t/(t+i)*(n-e)}function u(t){var e=w(t.b)
326
326
  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
- 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)
344
+ return t.c&&(M(t,e=p(ct(t).a.b,t.a.e)),t=ut(t)),t}function F(t,e,i){var n=new lt
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
349
349
  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
- var n=lt(t),s=n.a
351
+ var n=ct(t),s=n.a
352
352
  if(s.a!==e.a){if(!n.c){G(t)
353
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
354
354
  do{F(t,e,i.b),i=i.c}while(i!==n)
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
355
+ for(null===s&&(s=ct(e).a.b.c);(i=(n=ct(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
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]
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
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
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
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=ct(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
- else{var c=(r=r.b).d,l=r.e,u=r.c,d=u[a]
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
366
- ut(n).b=n.b=!0,y(o.b),f(K(h),o)}return!0}function U(t,a){var c=lt(a),u=a.a,d=c.a,p=u.a,w=d.a,g=u.b.a,v=d.b.a,m=new X
364
+ else{var l=(r=r.b).d,c=r.e,u=r.c,d=u[a]
365
+ l[d]=l[r.a],u[l[d]]=d,d<=--r.a&&(d>1?i(c[l[d>>1]],c[l[d]])?ht(r,d):at(r,d):ht(r,d)),c[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
366
+ ut(n).b=n.b=!0,y(o.b),f(K(h),o)}return!0}function U(t,a){var l=ct(a),u=a.a,d=l.a,p=u.a,w=d.a,g=u.b.a,v=d.b.a,m=new X
367
367
  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
- 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
372
- if(g===t.a){y(d.b),f(u.e,K(d)),w=(p=c=a).a.b.a
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=c(x,E.b,b,_.b)):(0>(x=s(S,E,_))+(b=-s(S,T,_))&&(x=-x,b=-b),m.b=c(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=c(x,E.a,b,_.a)):(0>(x=h(S,E,_))+(b=-h(S,T,_))&&(x=-x,b=-b),m.a=c(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=ct(a=I(a)).a,O(t,ct(a),l),C(t,a,K(u),u,u,!0),!0
372
+ if(g===t.a){y(d.b),f(u.e,K(d)),w=(p=l=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=ct(a=p).a.b.c,l.a=K(d),C(t,a,(d=O(t,l,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=l.b=!0,y(d.b),d.a.b=t.a.b,d.a.a=t.a.a),!1}return y(u.b),y(d.b),f(K(d),u),u.a.b=m.b,u.a.a=m.a,u.a.ni=tt(t.e,u.a),d=[0,0,0,0],m=[p.d,g.d,w.d,v.d],(u=u.a).g[0]=u.g[1]=u.g[2]=0,B(u,p,g,d,0),B(u,w,v,d,2),k(t,u,m,d,!0),ut(a).b=a.b=l.b=!0,!1}function P(t,e){for(var n=ct(e);;){for(;n.b;)e=n,n=ct(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
378
- if(r=o.b.a!==h.b.a)t:{var a=lt(r=e),c=r.a,l=a.a,u=void 0
379
- if(i(c.b.a,l.b.a)){if(0>s(c.b.a,l.b.a,c.a)){r=!1
380
- break t}ut(r).b=r.b=!0,u=y(c),f(l.b,u),u.d.c=r.d}else{if(s(l.b.a,c.b.a,l.a)>0){r=!1
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)
378
+ if(r=o.b.a!==h.b.a)t:{var a=ct(r=e),l=r.a,c=a.a,u=void 0
379
+ if(i(l.b.a,c.b.a)){if(0>s(l.b.a,c.b.a,l.a)){r=!1
380
+ break t}ut(r).b=r.b=!0,u=y(l),f(c.b,u),u.d.c=r.d}else{if(s(c.b.a,l.b.a,c.a)>0){r=!1
381
+ break t}r.b=a.b=!0,u=y(c),f(l.e,c.b),u.b.d.c=r.d}r=!0}if(r&&(n.c?(A(n),d(h),h=(n=ct(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
385
- var o=n;(u=new ct).a=o.c.b
386
- var h=(l=r.f).a
387
- do{h=h.a}while(null!==h.b&&!l.c(l.b,u,h.b))
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
- 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)
384
+ for(var r=n.c;null===r.si;)if((r=r.c)===n.c){r=t
385
+ var o=n;(u=new lt).a=o.c.b
386
+ var h=(c=r.f).a
387
+ do{h=h.a}while(null!==h.b&&!c.c(c.b,u,h.b))
388
+ if(h=(l=ct(c=h.b)).a,0===s((u=c.a).b.a,o,u.a))e((u=c.a).a,o)||e(u.b.a,o)||(y(u.b),c.c&&(d(u.c),c.c=!1),f(o.c,u),$(r,o))
389
+ else{var a=i(h.b.a,u.b.a)?c:l,l=void 0
390
+ c.d||a.c?(l=a===c?p(o.c.b,u.e):p(h.b.c.b,o.c).b,a.c?M(a,l):(u=r,(c=F(r,c,l)).f=ut(c).f+c.a.f,c.d=L(u,c.f)),$(r,o)):C(r,c,o.c,o.c,null,!0)}return}if(c=(u=ct(r=I(r.si))).a,(u=O(t,u,null)).c===c){var c,u=(c=u).c,w=(h=ct(r),!1);(l=r.a).b.a!==(a=h.a).b.a&&U(t,r),e(l.a,t.a)&&(f(K(u),l),u=ct(r=I(r)).a,O(t,ct(r),h),w=!0),e(a.a,t.a)&&(f(c,K(a)),c=O(t,h,null),w=!0),w?C(t,r,c.c,u,u,!0):(o=i(a.a,l.a)?K(a):l,C(t,r,o=p(c.c.b,o),o.c,o.c,!1),o.b.si.c=!0,P(t,r))}else C(t,r,u.c,c,c,!0)}function z(t,e){var i=new lt,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.li=!1,this.c=this.r=this.si=this.ci=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
405
405
  t.a>a&&i(s[n[a+1]],s[n[a]])&&(a+=1)
406
- var c=n[a]
407
- if(a>t.a||i(s[h],s[c])){n[o]=h,r[h]=o
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
- 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
406
+ var l=n[a]
407
+ if(a>t.a||i(s[h],s[l])){n[o]=h,r[h]=o
408
+ break}n[o]=l,r[l]=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,l=n[a]
409
+ if(0===a||i(s[l],s[h])){n[o]=h,r[h]=o
410
+ break}n[o]=l,r[l]=o,o=a}}function lt(){this.e=this.a=null,this.f=0,this.c=this.b=this.ni=this.d=!1}function ct(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.li=!!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.li
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.ci=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]]
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
- 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])
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
+ if(0===u&&0===r&&0===h){for(var r=[-2e150,-2e150,-2e150],o=[2e150,2e150,2e150],h=[],c=[],u=(t=this.b.c).e;u!==t;u=u.e)for(var f=0;3>f;++f){var y=u.g[f]
436
+ o[f]>y&&(o[f]=y,c[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=c[u],c=[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],c[0]=o[1]*f[2]-o[2]*f[1],c[1]=o[2]*f[0]-o[0]*f[2],c[2]=o[0]*f[1]-o[1]*f[0],(y=c[0]*c[0]+c[1]*c[1]+c[2]*c[2])>r&&(r=y,n[0]=c[0],n[1]=c[1],n[2]=c[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
- 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]
438
+ t=!0}for(r=((c=_(n))+1)%3,h=(c+2)%3,c=n[c]>0?1:-1,n=(u=this.b.c).e;n!==u;n=n.e)n.b=n.g[r],n.a=c*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.li)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
- 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
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)
452
+ r=r.c.b}else{for(;r.e!==u&&(l(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.ni||this.si||this.ci||this.ui)if(this.li){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.ci&&this.ci(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),c=h.a
456
+ do{t&&r!==(o=c.b.d.c?0:1)&&(r=o,this.ui&&this.ui(!!r,this.c)),this.ci&&this.ci(c.a.d,this.c),c=c.e}while(c!==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,c=void 0
457
+ do{h=(c=h).e,c.d=null,null===c.b.d&&(c.c===c?b(c.a,null):(c.a.c=c.c,g(c,K(c))),(o=c.b).c===o?b(o.a,null):(o.a.c=o.c,g(o,K(o))),x(c))}while(c!==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.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)}Ci(t,e=!0,i=!1,n=!0){return 0===t.length?{Li:{vertices:[],indices:[]},Gi:[]}:this.ki(t,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.Di(t,!0),(e||n)&&(r=this.Di(t))):(r=this.Di(t),o=r)
465
+ let h=n?s?o:r??this.Di(t):[]
466
+ if(e){const t=this.Bi(r,"boundary")
467
+ if(!t)return a.warn("libtess returned empty result from boundary pass"),{Li:{vertices:[],indices:[]},Gi:[]}
468
+ o=this.Ni(t),n&&(h=o)}const l=this.Bi(o,"triangles")
469
+ return l?{Li:{vertices:l.vertices,indices:l.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,i,n){const s=!i&&!e
470
+ let r,o
471
+ s?(o=this.Ui(t),(e||n)&&(r=t)):(r=t,o=t)
472
+ let h=n?s?o:r??t:[]
473
+ if(e){const t=this.Bi(r,"boundary")
474
+ if(!t)return a.warn("libtess returned empty result from boundary pass"),{Li:{vertices:[],indices:[]},Gi:[]}
475
+ o=this.Ni(t),n&&(h=o)}const l=this.Bi(o,"triangles")
476
+ return l?{Li:{vertices:l.vertices,indices:l.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})}Di(t,e=!1){const i=Array(t.length)
470
477
  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
478
  let a=0
472
479
  if(e)for(let t=o-1;t>=0;t--){const e=s[t]
473
480
  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)
481
+ h[a++]=e.x,h[a++]=e.y}2>a||(h[a++]=h[0],h[a++]=h[1]),i[n]=h}return i}Ui(t){const e=Array(t.length)
482
+ for(let i=0;t.length>i;i++)e[i]=this.Pi(t[i])
483
+ return e}Pi(t){const e=t.length
484
+ if(0===e)return[]
485
+ const i=4>e||t[0]!==t[e-2]||t[1]!==t[e-1]?e:e-2
486
+ if(0===i)return[]
487
+ const n=Array(i+2)
488
+ let s=0
489
+ for(let e=i-2;e>=0;e-=2)n[s++]=t[e],n[s++]=t[e+1]
490
+ return 2>s||(n[s++]=n[0],n[s++]=n[1]),n}Bi(t,e){const i=new nt.GluTesselator
491
+ i.bi(nt.mi.GLU_TESS_WINDING_RULE,nt.wi.GLU_TESS_WINDING_NONZERO)
476
492
  const n=[],s=[],r=[]
477
493
  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()
494
+ "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
495
+ 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)
496
+ for(const e of t){i.Mi()
481
497
  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[]
498
+ 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,$i:r}}Ni(t){if(!t.$i)return[]
483
499
  const e=[]
484
- for(const i of t.ki){const n=[]
500
+ for(const i of t.$i){const n=[]
485
501
  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
502
+ n.push(t.vertices[i],t.vertices[i+1])}n.length>2&&(n[0]===n[n.length-2]&&n[1]===n[n.length-1]||n.push(n[0],n[1])),e.push(n)}return e}zi(t){if(0===t.length)return!1
487
503
  if(1===t.length)return!1
488
504
  let e=null
489
- for(const i of t){const t=0>this.Bi(i)?-1:1
505
+ for(const i of t){const t=0>this.Wi(i)?-1:1
490
506
  if(null===e)e=t
491
- else if(t!==e)return!0}return!1}Bi(t){let e=0
507
+ else if(t!==e)return!0}return!1}Wi(t){let e=0
492
508
  const i=t.length
493
509
  if(6>i)return 0
494
510
  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
496
- let o=[]
497
- if(0!==e){const t=new Map,e=s.length
511
+ return e/2}}class rt{constructor(){}Ri(t,e=0,i){const n=t.Li.vertices,s=t.Li.indices,r=t.Gi,o=n.length,h=o/2
512
+ let a=[],l=0,c=!1
513
+ if(0!==e)if(r.length>0){c=!0
514
+ for(const t of r){const e=t.length>>1
515
+ 2>e||(l+=e-1)}}else{const t=new Map,e=s.length
498
516
  for(let i=0;e>i;i+=3){const e=s[i],n=s[i+1],r=s[i+2]
499
- let o,h,a
500
- n>e?(o=e<<16|n,h=e,a=n):(o=n<<16|e,h=e,a=n)
501
- let c=t.get(o)
502
- c?c[2]++:t.set(o,[h,a,1]),r>n?(o=n<<16|r,h=n,a=r):(o=r<<16|n,h=n,a=r),c=t.get(o),c?c[2]++:t.set(o,[h,a,1]),e>r?(o=r<<16|e,h=r,a=e):(o=e<<16|r,h=r,a=e),c=t.get(o),c?c[2]++:t.set(o,[h,a,1])}o=[]
503
- for(const[e,i,n]of t.values())1===n&&o.push([e,i])}const h=0===e?0:o.length,a=(0===e?r:2*r)+(0===e?0:4*h),c=new Float32Array(3*a),l=new Float32Array(3*a),u=new Uint32Array(0===e?s.length:2*s.length+6*h)
504
- if(0===e){let t=0
505
- for(let e=0;n.length>e;e+=2)c[t]=n[e],c[t+1]=n[e+1],c[t+2]=0,l[t]=0,l[t+1]=0,l[t+2]=1,t+=3
506
- return u.set(s),{vertices:c,normals:l,indices:u}}const f=25e-6*i,d=e>f?e:f
507
- for(let t=0,e=0;n.length>t;t+=2,e++){const i=n[t],s=n[t+1],o=3*e
508
- c[o]=i,c[o+1]=s,c[o+2]=0,l[o]=0,l[o+1]=0,l[o+2]=-1
509
- const h=3*(r+e)
510
- c[h]=i,c[h+1]=s,c[h+2]=d,l[h]=0,l[h+1]=0,l[h+2]=1}const y=s.length
511
- for(let t=0;y>t;t++)u[t]=s[y-1-t]
512
- for(let t=0;y>t;t++)u[y+t]=s[t]+r
513
- let p=2*r,w=2*y
514
- const g=o.length
515
- for(let t=0;g>t;t++){const e=o[t],i=e[0]<<1,s=e[1]<<1,r=n[i],h=n[i+1],a=n[s],f=n[s+1],y=a-r,g=f-h,v=y*y+g*g
516
- let m=0,x=0
517
- if(v>1e-10){const t=1/Math.sqrt(v)
518
- m=g*t,x=-y*t}const b=3*p
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
- 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)
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)
517
+ let o,h
518
+ o=n>e?e<<16|n:n<<16|e,h=e<<16|n
519
+ let a=t.get(o)
520
+ void 0===a?t.set(o,h):null!==a&&t.set(o,null),o=r>n?n<<16|r:r<<16|n,h=n<<16|r,a=t.get(o),void 0===a?t.set(o,h):null!==a&&t.set(o,null),o=e>r?r<<16|e:e<<16|r,h=r<<16|e,a=t.get(o),void 0===a?t.set(o,h):null!==a&&t.set(o,null)}a=[]
521
+ for(const e of t.values())null!==e&&a.push(e>>>16,65535&e)
522
+ l=a.length>>1}const u=(0===e?h:2*h)+4*l,f=new Float32Array(3*u),d=new Float32Array(3*u),y=new Uint32Array(0===e?s.length:2*s.length+6*l)
523
+ if(0===e){for(let t=0,e=0;o>t;t+=2,e+=3)f[e]=n[t],f[e+1]=n[t+1],f[e+2]=0,d[e]=0,d[e+1]=0,d[e+2]=1
524
+ return y.set(s),{vertices:f,normals:d,indices:y}}const p=25e-6*i,w=e>p?e:p,g=3*h
525
+ for(let t=0,e=0,i=0;o>t;t+=2,e++,i+=3){const e=n[t],s=n[t+1]
526
+ f[i]=e,f[i+1]=s,f[i+2]=0,d[i]=0,d[i+1]=0,d[i+2]=-1
527
+ const r=i+g
528
+ f[r]=e,f[r+1]=s,f[r+2]=w,d[r]=0,d[r+1]=0,d[r+2]=1}const v=s.length
529
+ for(let t=0;v>t;t++)y[t]=s[v-1-t]
530
+ for(let t=0;v>t;t++)y[v+t]=s[t]+h
531
+ let m=2*h,x=2*v
532
+ if(c)for(const t of r){const e=t.length
533
+ if(e>=4)for(let i=0;e-2>i;i+=2){const e=t[i],n=t[i+1],s=t[i+2],r=t[i+3],o=s-e,h=r-n,a=o*o+h*h
534
+ let l=0,c=0
535
+ if(a>1e-10){const t=1/Math.sqrt(a)
536
+ l=h*t,c=-o*t}const u=3*m
537
+ f[u]=e,f[u+1]=n,f[u+2]=0,f[u+3]=s,f[u+4]=r,f[u+5]=0,f[u+6]=e,f[u+7]=n,f[u+8]=w,f[u+9]=s,f[u+10]=r,f[u+11]=w,d[u]=l,d[u+1]=c,d[u+2]=0,d[u+3]=l,d[u+4]=c,d[u+5]=0,d[u+6]=l,d[u+7]=c,d[u+8]=0,d[u+9]=l,d[u+10]=c,d[u+11]=0
538
+ const p=m
539
+ y[x]=p,y[x+1]=p+1,y[x+2]=p+2,y[x+3]=p+1,y[x+4]=p+3,y[x+5]=p+2,x+=6,m+=4}}else for(let t=0;l>t;t++){const e=t<<1,i=a[e]<<1,s=a[e+1]<<1,r=n[i],o=n[i+1],h=n[s],l=n[s+1],c=h-r,u=l-o,p=c*c+u*u
540
+ let g=0,v=0
541
+ if(p>1e-10){const t=1/Math.sqrt(p)
542
+ g=u*t,v=-c*t}const b=3*m
543
+ f[b]=r,f[b+1]=o,f[b+2]=0,f[b+3]=h,f[b+4]=l,f[b+5]=0,f[b+6]=r,f[b+7]=o,f[b+8]=w,f[b+9]=h,f[b+10]=l,f[b+11]=w,d[b]=g,d[b+1]=v,d[b+2]=0,d[b+3]=g,d[b+4]=v,d[b+5]=0,d[b+6]=g,d[b+7]=v,d[b+8]=0,d[b+9]=g,d[b+10]=v,d[b+11]=0
544
+ const S=m
545
+ y[x]=S,y[x+1]=S+1,y[x+2]=S+2,y[x+3]=S+1,y[x+4]=S+3,y[x+5]=S+2,x+=6,m+=4}return{vertices:f,normals:d,indices:y}}}class ot{constructor(){}ji(t,e){const i=t.length
546
+ return 0===i?[]:1===i?[[0]]:this.Hi(t,e)}Hi(t,e){function i(t){return a[t]===t?t:a[t]=i(a[t])}function n(t,e){const n=i(t),s=i(e)
547
+ n!==s&&(l[s]>l[n]?a[n]=s:l[n]>l[s]?a[s]=n:(a[s]=n,l[n]++))}const s=t.length,r=Array(s),o=Array(2*s)
524
548
  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]
549
+ for(let i=0;s>i;i++)r[i]=this.Vi(t[i],e[i]),o[h++]=[r[i].qi,0,i],o[h++]=[r[i].Yi,1,i]
526
550
  o.sort((t,e)=>t[0]-e[0]||t[1]-e[1])
527
- const a=Array.from({length:s},(t,e)=>e),c=Array(s).fill(0),l=new Set
551
+ const a=Array.from({length:s},(t,e)=>e),l=Array(s).fill(0),c=new Set
528
552
  for(const[,t,e]of o)if(0===t){const t=r[e]
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)
553
+ for(const i of c){const s=r[i]
554
+ s.Ji+.001>t.Ki&&t.Ji>s.Ki-.001&&n(e,i)}c.add(e)}else c.delete(e)
531
555
  const u=new Map
532
556
  for(let t=0;s>t;t++){const e=i(t)
533
557
  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
558
+ n||(n=[],u.set(e,n)),n.push(t)}return Array.from(u.values())}Vi(t,e){return{qi:t.bounds.min.x+e.x,Ki:t.bounds.min.y+e.y,Yi:t.bounds.max.x+e.x,Ji:t.bounds.max.y+e.y}}}class ht{constructor(t){this.Qi=[],this.Xi=new Map,this.compare=t}F(t){const e=this.Xi.get(t)
559
+ if(void 0!==e)return this.Zi(e),void this.tn(e)
560
+ const i=this.Qi.length
561
+ this.Qi.push(t),this.Xi.set(t,i),this.Zi(i)}en(){const t=this.Qi.length
538
562
  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]
563
+ if(1===t){const t=this.Qi.pop()
564
+ return this.Xi.clear(),t}const e=this.Qi[0],i=this.Qi.pop()
565
+ return this.Qi[0]=i,this.Xi.delete(e),this.Xi.set(i,0),this.tn(0),e}update(t){const e=this.Xi.get(t)
566
+ void 0!==e?(this.Zi(e),this.tn(e)):this.F(t)}nn(){return!this.Qi.length}sn(t,e){const i=this.Qi[t],n=this.Qi[e]
567
+ this.Qi[t]=n,this.Qi[e]=i,this.Xi.set(i,e),this.Xi.set(n,t)}Zi(t){const e=this.Qi[t]
568
+ for(;t>0;){const i=t-1>>1,n=this.Qi[i]
545
569
  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
570
+ this.Qi[t]=n,this.Xi.set(n,t),t=i}this.Qi[t]=e,this.Xi.set(e,t)}tn(t){const e=this.Qi[t],i=this.Qi.length,n=i>>1
547
571
  for(;n>t;){const n=1+(t<<1),s=n+1
548
572
  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]
573
+ const h=this.Qi[n]
574
+ if(0>this.compare(h,o)&&(r=n,o=h),i>s){const t=this.Qi[s]
551
575
  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
576
+ this.Qi[t]=o,this.Xi.set(o,t),t=r}this.Qi[t]=e,this.Xi.set(e,t)}}const at={enabled:!0,areaThreshold:1}
577
+ class lt{constructor(t){this.stats={pointsRemovedByVisvalingam:0,originalPointCount:0},this.config=t}rn(t){this.config=t}hn(t){if(2>=t.points.length)return t
554
578
  if(!this.config.enabled)return t
555
579
  this.stats.originalPointCount+=t.points.length
556
580
  const e=t.points
557
581
  if(5>e.length)return t
558
582
  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)
583
+ return i=this.an(i,this.config.areaThreshold),3>i.length?t:{...t,points:i}}an(t,e){if(3>=t.length)return t
584
+ const i=t.length,n=t.map((t,e)=>({index:e,ln:1/0,cn:null,next:null}))
585
+ for(let t=0;n.length>t;t++)n[t].cn=n[t-1]||null,n[t].next=n[t+1]||null
586
+ const s=new ht((t,e)=>t.ln-e.ln)
563
587
  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=[]
588
+ i.ln=this.un(t[i.cn.index],t[i.index],t[i.next.index]),s.F(i)}let r=i
589
+ for(;!s.nn()&&r>3;){const i=s.en()
590
+ if(!i||i.ln>e)break
591
+ i.cn&&(i.cn.next=i.next),i.next&&(i.next.cn=i.cn),r--,i.cn&&i.cn.cn&&(i.cn.ln=this.un(t[i.cn.cn.index],t[i.cn.index],t[i.next.index]),s.update(i.cn)),i.next&&i.next.next&&(i.next.ln=this.un(t[i.cn.index],t[i.next.index],t[i.next.next.index]),s.update(i.next))}const o=[]
568
592
  let h=n[0]
569
593
  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)
594
+ return this.stats.pointsRemovedByVisvalingam+=i-o.length,o}un(t,e,i){return Math.abs((t.x*(e.y-i.y)+e.x*(i.y-t.y)+i.x*(t.y-e.y))/2)}getStats(){return{...this.stats}}fn(){this.stats={pointsRemovedByVisvalingam:0,originalPointCount:0}}}const ct={distanceTolerance:.5,angleTolerance:.2},ut=1e-6
595
+ class ft{constructor(t){this.curveSteps=null,this.dn={...ct,...t}}yn(t){this.dn={...ct,...t}}pn(t){if(null==t)return void(this.curveSteps=null)
572
596
  if(!Number.isFinite(t))return void(this.curveSteps=null)
573
597
  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)
598
+ this.curveSteps=1>e?null:e}wn(t,e,i){if(null!==this.curveSteps)return this.gn(t,e,i,this.curveSteps)
575
599
  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)
600
+ return this.vn(t.x,t.y,e.x,e.y,i.x,i.y,n),this.mn(i.x,i.y,n),n}xn(t,e,i,n){if(null!==this.curveSteps)return this.bn(t,e,i,n,this.curveSteps)
577
601
  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)
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
602
+ return this.Sn(t.x,t.y,e.x,e.y,i.x,i.y,n.x,n.y,s),this.mn(n.x,n.y,s),s}_n(t,e,i){return t+(e-t)*i}gn(t,e,i,n){const s=[]
603
+ for(let r=1;n>=r;r++){const o=r/n,h=this._n(t.x,e.x,o),a=this._n(t.y,e.y,o),l=this._n(e.x,i.x,o),c=this._n(e.y,i.y,o),u=this._n(h,l,o),f=this._n(a,c,o)
604
+ this.mn(u,f,s)}return s}bn(t,e,i,n,s){const r=[]
605
+ for(let o=1;s>=o;o++){const h=o/s,a=this._n(t.x,e.x,h),l=this._n(t.y,e.y,h),c=this._n(e.x,i.x,h),u=this._n(e.y,i.y,h),f=this._n(i.x,n.x,h),d=this._n(i.y,n.y,h),y=this._n(a,c,h),p=this._n(l,u,h),w=this._n(c,f,h),g=this._n(u,d,h),v=this._n(y,w,h),m=this._n(p,g,h)
606
+ this.mn(v,m,r)}return r}vn(t,e,i,n,s,r,o,h=0){if(h>16)return
607
+ const a=(t+i)/2,l=(e+n)/2,c=(i+s)/2,u=(n+r)/2,f=(a+c)/2,d=(l+u)/2,y=s-t,p=r-e,w=Math.abs((i-s)*p-(n-r)*y),g=this.dn.distanceTolerance??ct.distanceTolerance,v=g*g
608
+ if(w>ut){if(v*(y*y+p*p)>=w*w){const h=this.dn.angleTolerance??ct.angleTolerance
609
+ if(0>=h)return void this.mn(i,n,o)
610
+ {const a=i-t,l=n-e,c=s-i,u=r-n
611
+ if(h>Math.abs(Math.atan2(a*u-l*c,a*c+l*u)))return void this.mn(i,n,o)}}}else{const s=y*y+p*p
612
+ if(0===s){if(v>=(i-t)*(i-t)+(n-e)*(n-e))return void this.mn(i,n,o)}else{const r=((i-t)*y+(n-e)*p)/s
613
+ if(r>0&&1>r&&v*s>=w*w)return void this.mn(i,n,o)}}this.vn(t,e,a,l,f,d,o,h+1),this.vn(f,d,c,u,s,r,o,h+1)}Sn(t,e,i,n,s,r,o,h,a,l=0){if(l>16)return
614
+ const c=(t+i)/2,u=(e+n)/2,f=(i+s)/2,d=(n+r)/2,y=(s+o)/2,p=(r+h)/2,w=(c+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.dn.distanceTolerance??ct.distanceTolerance,M=A*A
591
615
  let I=0
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)
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)
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)
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)
616
+ switch(E>ut&&(I|=1),T>ut&&(I|=2),I){case 0:const l=S*S+_*_
617
+ if(0===l){if(M>=(i-t)*(i-t)+(n-e)*(n-e)&&M>=(s-t)*(s-t)+(r-e)*(r-e))return this.mn(i,n,a),void this.mn(s,r,a)}else{const o=((i-t)*S+(n-e)*_)/l,h=((s-t)*S+(r-e)*_)/l
618
+ if(o>0&&1>o&&h>0&&1>h&&M*l>=(E+T)*(E+T))return this.mn(i,n,a),void this.mn(s,r,a)}break
619
+ case 1:if(M*(S*S+_*_)>=T*T){const t=this.dn.angleTolerance??ct.angleTolerance
620
+ if(0>=t)return this.mn(i,n,a),void this.mn(s,r,a)
621
+ {const e=s-i,l=r-n,c=o-s,u=h-r
622
+ if(t>Math.abs(Math.atan2(e*u-l*c,e*c+l*u)))return this.mn(i,n,a),void this.mn(s,r,a)}}break
623
+ case 2:if(M*(S*S+_*_)>=E*E){const o=this.dn.angleTolerance??ct.angleTolerance
624
+ if(0>=o)return this.mn(i,n,a),void this.mn(s,r,a)
625
+ {const h=i-t,l=n-e,c=s-i,u=r-n
626
+ if(o>Math.abs(Math.atan2(h*u-l*c,h*c+l*u)))return this.mn(i,n,a),void this.mn(s,r,a)}}break
627
+ case 3:if(M*(S*S+_*_)>=(E+T)*(E+T)){const l=this.dn.angleTolerance??ct.angleTolerance
628
+ if(0>=l)return this.mn(i,n,a),void this.mn(s,r,a)
629
+ {const c=i-t,u=n-e,f=s-i,d=r-n,y=o-s,p=h-r
630
+ if(l>Math.abs(Math.atan2(c*d-u*f,c*f+u*d))+Math.abs(Math.atan2(f*p-d*y,f*y+d*p)))return this.mn(i,n,a),void this.mn(s,r,a)}}}this.Sn(t,e,c,u,w,g,x,b,a,l+1),this.Sn(x,b,v,m,y,p,o,h,a,l+1)}mn(t,e,i){const n=new Y(t,e)
607
631
  if(0===i.length)return void i.push(n)
608
632
  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
633
+ r*r+o*o>1e-12&&i.push(n)}}class dt{constructor(t,e){this.En=0,this.Tn=0,this.An=[],this.Mn=null,this.In=null,this.Fn={min:new Y(1/0,1/0),max:new Y(-1/0,-1/0)},this.Ln=[],this.Gn=[],this.On=[],this.Cn=new Y(0,0),this.kn=new ft(t),this.Dn=new lt({...at,...e})}setPosition(t,e){this.Cn.set(t,e)}Bn(t,e){this.Cn.x+=t,this.Cn.y+=e}Nn(t,e){this.An.length>0&&this.Un(),this.En=t,this.Tn=e,this.An=[],this.Fn.min.set(1/0,1/0),this.Fn.max.set(-1/0,-1/0),this.Gn.push(this.Cn.clone())}Un(){this.Mn&&this.Pn(),this.An.length>0&&(this.Ln.push({$n:this.En,zn:this.An,bounds:{min:{x:this.Fn.min.x,y:this.Fn.min.y},max:{x:this.Fn.max.x,y:this.Fn.max.y}}}),this.On.push(this.Tn)),this.An=[]}Wn(t,e){this.Mn&&this.Pn(),this.In=new Y(t,e),this.Rn(this.In),this.Mn={points:[this.In],glyphIndex:this.En}}jn(t,e){if(!this.Mn||!this.In)return
610
634
  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)
635
+ this.Rn(i),this.Mn.points.push(i),this.In=i}Hn(t,e,i,n){if(!this.Mn||!this.In)return
636
+ const s=this.In,r=new Y(t,e),o=new Y(i,n)
637
+ if(ut>Math.abs((r.x-o.x)*(o.y-s.y)-(r.y-o.y)*(o.x-s.x)))return void this.jn(i,n)
638
+ const h=this.kn.wn(s,r,o)
615
639
  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)
640
+ this.Rn(e),this.Mn.points.push(e)}this.In=o}Vn(t,e,i,n,s,r){if(!this.Mn||!this.In)return
641
+ const o=this.In,h=new Y(t,e),a=new Y(i,n),l=new Y(s,r),c=l.x-o.x,u=l.y-o.y
642
+ if(ut>Math.abs((h.x-l.x)*u-(h.y-l.y)*c)&&ut>Math.abs((a.x-l.x)*u-(a.y-l.y)*c))return void this.jn(s,r)
643
+ const f=this.kn.xn(o,h,a,l)
620
644
  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
645
+ this.Rn(e),this.Mn.points.push(e)}this.In=l}qn(){if(!this.Mn||!this.In)return
646
+ const t=this.Mn.points[0]
647
+ this.In.equals(t)||this.Mn.points.push(t),this.Pn()}Pn(){if(this.Mn){const t=this.Dn.hn(this.Mn)
648
+ this.An.push(t),this.Mn=null,this.In=null}}Rn(t){this.Fn.min.x=Math.min(this.Fn.min.x,t.x),this.Fn.min.y=Math.min(this.Fn.min.y,t.y),this.Fn.max.x=Math.max(this.Fn.max.x,t.x),this.Fn.max.y=Math.max(this.Fn.max.y,t.y)}Yn(){return this.An.length>0&&this.Un(),this.Ln}Jn(){return this.Gn}Kn(){return this.On}reset(){this.Ln=[],this.Gn=[],this.On=[],this.An=[],this.Mn=null,this.In=null,this.En=0,this.Tn=0,this.Cn.set(0,0),this.Fn={min:new Y(1/0,1/0),max:new Y(-1/0,-1/0)}}yn(t){this.kn.yn(t)}pn(t){this.kn.pn(t)}Qn(t){this.Dn.rn({...at,...t})}Xn(){return this.Dn.getStats()}}class yt{constructor(){this.Zn=null,this.ts=null,this.es=null,this.ns=null,this.ss=null,this.rs=0,this.position={x:0,y:0}}setPosition(t,e){this.position.x=t,this.position.y=e,this.hs&&this.hs.setPosition(t,e)}Bn(t,e){this.position.x+=t,this.position.y+=e,this.hs&&this.hs.Bn(t,e)}ls(t){this.hs=t}cs(t,e){if(!t||!t.module||!t.hb)throw Error("Invalid font object")
649
+ if(this.hs=e,this.rs)return
626
650
  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
651
+ this.Zn=i.us((t,e,i,n,s)=>{this.hs?.Wn(n,s)},"viiiffi"),this.ts=i.us((t,e,i,n,s)=>{this.hs?.jn(n,s)},"viiiffi"),this.es=i.us((t,e,i,n,s,r,o)=>{this.hs?.Hn(n,s,r,o)},"viiiffffi"),this.ns=i.us((t,e,i,n,s,r,o,h,a)=>{this.hs?.Vn(n,s,r,o,h,a)},"viiiffffffi"),this.ss=i.us(()=>{this.hs?.qn()},"viiii"),this.rs=i.exports.fs(),i.exports.ds(this.rs,this.Zn,0,0),i.exports.ys(this.rs,this.ts,0,0),i.exports.ps(this.rs,this.es,0,0),i.exports.ws(this.rs,this.ns,0,0),i.exports.gs(this.rs,this.ss,0,0)}vs(){if(!this.rs)throw Error("Draw functions not initialized")
652
+ return this.rs}destroy(t){if(!t||!t.module||!t.hb)return
629
653
  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)
654
+ try{this.rs&&(e.exports.xs(this.rs),this.rs=0),null!==this.Zn&&(e.bs(this.Zn),this.Zn=null),null!==this.ts&&(e.bs(this.ts),this.ts=null),null!==this.es&&(e.bs(this.es),this.es=null),null!==this.ns&&(e.bs(this.ns),this.ns=null),null!==this.ss&&(e.bs(this.ss),this.ss=null)}catch(t){a.warn("Error destroying draw callbacks:",t)}this.hs=void 0}}const pt=new WeakMap
655
+ class wt{constructor(t,e){this.Ss="default",this._s="default",this.Es=new Set,this.Ts=[],this.As=[],this.Ms=[],this.cache=t,this.Kt=e,this.tessellator=new st,this.Is=new rt,this.Fs=new ot,this.hs=new dt,this.Ls=(()=>{const t=this.Kt.module,e=pt.get(t)
632
656
  if(e)return e
633
657
  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
658
+ return pt.set(t,i),i})(),this.Ls.cs(this.Kt,this.hs),this.Gs=X,this.Os=Z,this.Cs=tt}Xn(){return this.hs.Xn()}yn(t){this.dn=t,this.hs.yn(t),this.ks()}pn(t){if(null==t)this.curveSteps=void 0
635
659
  else if(Number.isFinite(t)){const e=Math.round(t)
636
660
  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
640
- for(let i=0;t.length>i;i++)e+=t[i].length}const c=[]
641
- let l=0,u=0,f=0,d=0
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}}
661
+ this.hs.pn(this.curveSteps),this.ks()}Qn(t){this.Ds=t,this.hs.Qn(t),this.ks()}Bs(t){this.Ss=t,this.ks()}ks(){this._s=`${this.Ss}__${this.Ns()}`}Ns(){return[(()=>{if(void 0!==this.curveSteps)return"cf:steps:"+this.curveSteps
662
+ const t=this.dn?.distanceTolerance??ct.distanceTolerance,e=this.dn?.angleTolerance??ct.angleTolerance
663
+ return`cf:${t.toFixed(4)},${e.toFixed(4)}`})(),`opt:${this.Ds?.enabled??1?1:0},${(this.Ds?.areaThreshold??1).toFixed(4)}`].join("|")}Us(t,e,i,n,r,o=!1,a){if(h){let e=0
664
+ for(let i=0;t.length>i;i++)e+=t[i].length}const l=this.Ms
665
+ l.length=0
666
+ let c=0,u=0,f=0,d=0,y=0
667
+ const p=(t,e,i,n)=>{const s=y
668
+ let r=l[c]
669
+ return r?(r.data=t,r.px=e,r.Ps=i,r.$s=n,r.zs=s):(r={data:t,px:e,Ps:i,$s:n,zs:s},l[c]=r),c++,u+=t.vertices.length,f+=t.normals.length,d+=t.indices.length,y+=t.vertices.length/3,s},w=[],g={min:{x:1/0,y:1/0,z:0},max:{x:-1/0,y:-1/0,z:e}}
644
670
  for(let r=0;t.length>r;r++){const h=t[r]
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))
671
+ for(const t of h){const r=t.position.x,h=t.position.y,l=t.position.z,c=[]
672
+ for(const e of t.glyphs)c.push(this.Ws(e.g))
647
673
  let u
648
- if(t.glyphs.length>1){const e=`${this.ws}_${t.text}`,i=this.Es.get(e)
674
+ if(t.glyphs.length>1){const e=`${this._s}_${t.text}`,i=this.Cs.get(e)
649
675
  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
676
+ if(i&&i.Rs.length===t.glyphs.length){n=!0
677
+ for(let e=0;t.glyphs.length>e;e++){const s=t.glyphs[e],r=i.js[e]
678
+ if(i.Rs[e]!==s.g||r.x!==(s.x??0)||r.y!==(s.y??0)){n=!1
653
679
  break}}}if(n&&i)u=i.groups
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]]
680
+ else{const i=t.glyphs.length
681
+ if(i>this.Ts.length)for(let t=this.Ts.length;i>t;t++)this.Ts.push(new J(0,0,0))
682
+ this.Ts.length=i
683
+ for(let e=0;i>e;e++){const i=t.glyphs[e],n=this.Ts[e]
684
+ n.x=i.x??0,n.y=i.y??0,n.z=0}u=this.Fs.ji(c,this.Ts),this.Cs.set(e,{Rs:t.glyphs.map(t=>t.g),js:t.glyphs.map(t=>({x:t.x??0,y:t.y??0})),groups:u})}}else u=[[0]]
656
685
  const f=o
657
686
  let d=u
658
687
  if(a&&a.size>0){d=[]
659
688
  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)
663
- if(!u){const i=[],r=s[0].x??0,h=s[0].y??0
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)
669
- p.push(t)
670
- continue}const v=s(this.ws,o.g,e,i)
689
+ for(const s of e)a.has(t.glyphs[s].Hs)?i.push(s):n.push(s)
690
+ 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.Vs(s,e,i)
691
+ let u=this.Os.get(a)
692
+ if(!u){const i=this.As
693
+ let r=0
694
+ const h=s[0].x??0,l=s[0].y??0
695
+ for(let e=0;o.length>e;e++){const n=o[e],s=c[n],a=t.glyphs[n],u=(a.x??0)-h,f=(a.y??0)-l
696
+ for(const t of s.zn){const e=t.points,n=e.length
697
+ if(3>n)continue
698
+ const s=n>1&&e[0].x===e[n-1].x&&e[0].y===e[n-1].y?n-1:n,o=2*(s+1)
699
+ let h=i[r]
700
+ !h||o>h.length?(h=Array(o),i[r]=h):h.length=o
701
+ let a=0
702
+ for(let t=0;s>t;t++){const i=e[t]
703
+ h[a++]=i.x+u,h[a++]=i.y+f}2>a||(h[a++]=h[0],h[a++]=h[1]),r++}}i.length=r,u=this.qs(i,e,n),this.Os.set(a,u)}const f=s[0],d=p(u,r+(f.x??0),h+(f.y??0),l),y=u.vertices.length/3
704
+ for(let i=0;o.length>i;i++){const n=o[i],s=t.glyphs[n],a=this.Ys(s,d,y,r+(s.x??0),h+(s.y??0),l,c[n],e)
705
+ w.push(a),this.Js(a.bounds,g)}}else for(const a of o){const o=t.glyphs[a],u=c[a],f=r+(o.x??0),d=h+(o.y??0),y=l
706
+ if(0===u.zn.length){const t=this.Ys(o,0,0,f,d,y,u,e)
707
+ w.push(t)
708
+ continue}const v=s(this._s,o.g,e,i)
671
709
  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)
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
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
- v.set(n,b),b+=n.length
679
- const l=e.Os
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
- 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""
710
+ m?m.Ks++:(m=this.Qs(u,e,i,n),this.cache.set(v,m))
711
+ const x=p(m,f,d,y),b=this.Ys(o,x,m.vertices.length/3,f,d,y,u,e)
712
+ w.push(b),this.Js(b.bounds,g)}}}l.length=c
713
+ const v=new Float32Array(u),m=new Float32Array(f),x=new Uint32Array(d)
714
+ let b=0,S=0,_=0
715
+ for(let t=0;l.length>t;t++){const e=l[t],i=e.data.vertices,n=e.data.normals,s=e.data.indices,o=e.px*r,h=e.Ps*r,a=e.$s*r,c=i.length
716
+ let u=b
717
+ for(let t=0;c>t;t+=3)v[u]=i[t]*r+o,v[u+1]=i[t+1]*r+h,v[u+2]=i[t+2]*r+a,u+=3
718
+ b=u,m.set(n,S),S+=n.length
719
+ const f=e.zs,d=s.length
720
+ let y=_
721
+ for(let t=0;d>t;t++)x[y++]=s[t]+f
722
+ _=y}g.min.x*=r,g.min.y*=r,g.min.z*=r,g.max.x*=r,g.max.y*=r,g.max.z*=r
723
+ for(let t=0;w.length>t;t++)w[t].bounds.min.x*=r,w[t].bounds.min.y*=r,w[t].bounds.min.z*=r,w[t].bounds.max.x*=r,w[t].bounds.max.y*=r,w[t].bounds.max.z*=r
724
+ return{vertices:v,normals:m,indices:x,Xs:w,planeBounds:g}}Vs(t,e,i){if(0===t.length)return""
683
725
  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)
726
+ return`${this._s}_${r}_${Math.round(1e3*e)/1e3}_${i}`}Ys(t,e,i,n,s,r,o,h){return{Zs:t.Hs,tr:t.tr,zs:e,er:i,bounds:{min:{x:o.bounds.min.x+n,y:o.bounds.min.y+s,z:r},max:{x:o.bounds.max.x+n,y:o.bounds.max.y+s,z:r+h}}}}Ws(t){if(this.Es.has(t))return{$n:t,zn:[],bounds:{min:{x:0,y:0},max:{x:0,y:0}}}
727
+ const e=`${this._s}_${t}`,i=this.Gs.get(e)
686
728
  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
691
- let s=1/0,r=1/0,o=1/0,h=-1/0,a=-1/0,c=-1/0
692
- for(let t=0;n.length>t;t+=3){const e=n[t],i=n[t+1],l=n[t+2]
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)
729
+ this.Ls.ls(this.hs),this.hs.reset(),this.hs.Nn(t,0),this.Kt.module.exports.ir(this.Kt.font.nr,t,this.Ls.vs(),0),this.hs.Un()
730
+ const n=this.hs.Yn()[0]||{$n:t,zn:[],bounds:{min:{x:0,y:0},max:{x:0,y:0}}}
731
+ return 0===n.zn.length&&this.Es.add(t),this.Gs.set(e,n),n}qs(t,e,i){const n=this.tessellator.Ci(t,!0,i,0!==e)
732
+ return this.sr(n,e)}sr(t,e){const i=this.Is.Ri(t,e,this.Kt.upem),n=i.vertices
733
+ let s=1/0,r=1/0,o=1/0,h=-1/0,a=-1/0,l=-1/0
734
+ for(let t=0;n.length>t;t+=3){const e=n[t],i=n[t+1],c=n[t+2]
735
+ s>e&&(s=e),e>h&&(h=e),r>i&&(r=i),i>a&&(a=i),o>c&&(o=c),c>l&&(l=c)}const c=new J(s,r,o),u=new J(h,a,l)
736
+ return{geometry:t,vertices:i.vertices,normals:i.normals,indices:i.indices,bounds:{min:c,max:u},Ks:1}}Qs(t,e,i,n){const s=this.tessellator.process(t.zn,i,n,0!==e)
737
+ return this.sr(s,e)}Js(t,e){const i=e.min,n=e.max,s=t.min,r=t.max
738
+ i.x>s.x&&(i.x=s.x),i.y>s.y&&(i.y=s.y),i.z>s.z&&(i.z=s.z),r.x>n.x&&(n.x=r.x),r.y>n.y&&(n.y=r.y),r.z>n.z&&(n.z=r.z)}rr(){return this.cache.getStats()}clearCache(){this.cache.clear(),this.Os.clear(),this.Cs.clear(),this.Gs.clear()}}class gt{constructor(t,e){this.hr=new Map,this.Kt=t,this.ar=e}lr(t,e,i,n,s,r,o){try{const r=[]
739
+ return t.forEach((t,o)=>{const h=this.cr(t,o,e,i,n,s)
740
+ r.push(h)}),r}finally{}}cr(t,i,n,s,r,o){const h=this.Kt.hb.createBuffer()
741
+ "rtl"===o&&h.ur("rtl"),h.Vt(t.text),h.qt()
742
+ const a=e(this.Kt.Yt)
743
+ this.Kt.hb.shape(this.Kt.font,h,a)
744
+ const l=h.json(this.Kt.font)
703
745
  h.destroy()
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
746
+ const c=[]
747
+ let u=[],f=[],d=0,y=0,p=t.Ut,w=-i*n
748
+ const g=s*this.Kt.upem,v=this.dr(t,r,s),m=this.yr(t,r),x=t.text,b=x.length,S=l.length
707
749
  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=[])
750
+ for(let e=0;S>e;e++){const n=l[e],s=n.Jt,r=x[s],o=r.charCodeAt(0),h=32===o||9===o||10===o||13===o
751
+ n.Hs=t.$t&&s===b-1&&"-"===r?t.Nt:t.Bt+s,n.tr=i,h&&u.length>0&&(c.push({text:f.join(""),glyphs:u,position:new J(d,y,0)}),u=[],f=[])
710
752
  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(...t){const e="undefined"!=typeof globalThis?globalThis.require:void 0
717
- if("function"==typeof e)return e("fs").sr(...t)
753
+ 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[l[e+1].Jt],i=void 0!==_?_:T.Z(r)
754
+ if(_=!!t&&T.Z(t),i&&_){let e=!0
755
+ 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&&c.push({text:f.join(""),glyphs:u,position:new J(d,y,0)}),c}dr(t,e,i){let n=0
756
+ if(void 0!==t.Ht&&"justify"===e&&!t.Pt){let e=this.hr.get(i)
757
+ void 0===e&&(e=M.measureTextWidth(this.Kt," ",i),this.hr.set(i,e)),t.Ht>0?n=t.Ht*e*.5:0>t.Ht&&(n=t.Ht*e*f)}return n}yr(t,e){if(void 0===t.Ht||"justify"!==e||t.Pt)return 0
758
+ return t.Ht>0||0>t.Ht?.04*t.Ht*this.Kt.upem:0}clearCache(){this.ar.clearCache()}rr(){return this.ar.rr()}}var vt={exports:{}},mt=o({__proto__:null,default:{},pr(...t){const e="undefined"!=typeof globalThis?globalThis.require:void 0
759
+ if("function"==typeof e)return e("fs").pr(...t)
718
760
  throw Error("fs not available in this environment")}})
719
761
  !(function(t){var e,i=(e="undefined"!=typeof document?document.currentScript?.src:void 0,async function(t={}){function i(){var t=g.buffer
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.rr?.(t),x(t="Aborted("+t+")"),b=!0,t+=". Build with -sASSERTIONS for more info."
762
+ s.HEAP8=new Int8Array(t),s.HEAPU8=v=new Uint8Array(t),s.HEAP32=new Int32Array(t),s.HEAPU32=new Uint32Array(t),s.HEAPF32=new Float32Array(t),new BigInt64Array(t),new BigUint64Array(t)}function n(t){s.wr?.(t),x(t="Aborted("+t+")"),b=!0,t+=". Build with -sASSERTIONS for more info."
721
763
  var e=new WebAssembly.RuntimeError(t)
722
764
  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}
723
765
  "undefined"!=typeof __filename?e=__filename:o&&(e=self.location.href)
724
- var c,l,u=""
766
+ var l,c,u=""
725
767
  if(h){var f=mt
726
- u="undefined"!=typeof __dirname?__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
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
768
+ u="undefined"!=typeof __dirname?__dirname+"/":"",c=t=>(t=S(t)?new URL(t):t,f.pr(t)),l=async(t,e=!0)=>(t=S(t)?new URL(t):t,f.pr(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&&(c=t=>{var e=new XMLHttpRequest
769
+ return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),l=async t=>{if(S(t))return new Promise((e,i)=>{var n=new XMLHttpRequest
728
770
  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)})
729
771
  var e=await fetch(t,{credentials:"same-origin"})
730
772
  if(e.ok)return e.arrayBuffer()
@@ -732,197 +774,197 @@ throw Error(e.status+" : "+e.url)}}console.log.bind(console)
732
774
  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
733
775
  class A{name="ExitStatus"
734
776
  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
735
- 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
777
+ a(1,t)},P=()=>D||B>0,$=t=>{y=t,P()||(s.gr?.(t),b=!0),a(t,new A(t))},z=(t,e)=>Math.ceil(t/e)*e,W=t=>{var e=(t-g.buffer.byteLength+65535)/65536|0
736
778
  try{return g.grow(e),i(),1}catch(t){}},R=t=>{const e=t.length
737
- 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)
738
- 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)
779
+ 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)
780
+ s.vr&&(D=s.vr),s.mr&&(x=s.mr),s.br&&(d=s.br),s.Sr=g,s._r=K,s.us=(t,e)=>{var i=(t=>(I||(I=new WeakMap,((t,e)=>{if(I)for(var i=0;0+e>i;i++){var n=V(i)
739
781
  n&&I.set(n,i)}})(0,M.length)),I.get(t)||0))(t)
740
782
  if(i)return i
741
783
  var n=q.length?q.pop():M.grow(1)
742
784
  try{Y(n,t)}catch(i){if(!(i instanceof TypeError))throw i
743
785
  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)
744
786
  return new WebAssembly.Instance(n,{e:{f:t}}).exports.f})(t,e)
745
- Y(n,s)}return I.set(t,n),n},s.ys=t=>{I.delete(V(t)),Y(t,null),q.push(t)}
746
- 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
787
+ Y(n,s)}return I.set(t,n),n},s.bs=t=>{I.delete(V(t)),Y(t,null),q.push(t)}
788
+ var J={Er:()=>n(""),Tr(){D=!1,B=0},Ar(t,e){if(N[t]&&(clearTimeout(N[t].id),delete N[t]),!e)return 0
747
789
  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)
748
- return N[t]={id:i,gr:e},0},vr(t){var e=v.length,i=2147483648
790
+ return N[t]={id:i,Mr:e},0},Ir(t){var e=v.length,i=2147483648
749
791
  if((t>>>=0)>i)return!1
750
792
  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))
751
- 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
752
- T=null,t()}})(),K}E++,s.ph?.(E)
753
- var e,r={o:J,wh:J}
754
- 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"})
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)
793
+ if(W(r))return!0}return!1},Fr:$},K=await(async()=>{function t(t){return s._r=K=t.exports,s.Sr=g=K.memory,i(),M=K.Lr,(t=>{s.Gr=t.Or,s.Cr=t.kr,s.Dr=t.Br,s.Nr=t.Ur,s.Pr=t.$r,s.zr=t.Wr,s.Rr=t.jr,s.Hr=t.Vr,s.qr=t.Yr,s.Jr=t.Kr,s.Qr=t.Xr,s.Zr=t.eo,s.io=t.no,s.so=t.ro,s.oo=t.ho,s.ao=t.lo,s.co=t.uo,s.fo=t.do,s.yo=t.po,s.wo=t.vo,s.mo=t.xo,s.bo=t.So,s._o=t.Eo,s.To=t.Ao,s.Mo=t.Io,s.Fo=t.Lo,s.Go=t.Oo,s.Co=t.ko,s.Do=t.ds,s.Bo=t.ys,s.No=t.ps,s.Uo=t.ws,s.Po=t.gs,s.$o=t.fs,s.zo=t.xs,s.Wo=t.Ro,s.jo=t.Ho,s.Vo=t.qo,s.Yo=t.Jo,s.Ko=t.Qo,s.Xo=t.ir,s.Zo=t.th,s.eh=t.ih,s.nh=t.sh,s.rh=t.oh,s.hh=t.ah,s.uh=t.fh,s.dh=t.yh,s.ph=t.wh,s.gh=t.mh,s.xh=t.bh,s.Sh=t._h,F=t.Eh})(K),(()=>{if(E--,s.Th?.(E),0==E&&T){var t=T
794
+ T=null,t()}})(),K}E++,s.Th?.(E)
795
+ var e,r={o:J,Ah:J}
796
+ return s.Mh?new Promise(e=>{s.Mh(r,i=>{e(t(i))})}):(m??=(e="hb.wasm",s.Ih?s.Ih(e,u):u+e),t((await(async function(t,e,i){if(!t&&!S(e)&&!h)try{var s=fetch(e,{credentials:"same-origin"})
797
+ 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 l(t)
756
798
  return new Uint8Array(e)}catch{}return(t=>{if(t==m&&d)return new Uint8Array(d)
757
- if(l)return l(t)
799
+ if(c)return c(t)
758
800
  throw"both async and sync fetching of the wasm failed"})(t)})(t)
759
- return await WebAssembly.instantiate(i,e)}catch(t){x("failed to asynchronously prepare wasm: "+t),n(t)}})(e,i)})(d,m,r)).xh))})()
760
- 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())
761
- 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())
801
+ return await WebAssembly.instantiate(i,e)}catch(t){x("failed to asynchronously prepare wasm: "+t),n(t)}})(e,i)})(d,m,r)).Fh))})()
802
+ return(()=>{if(s.Lh)for("function"==typeof s.Lh&&(s.Lh=[s.Lh]);s.Lh.length>0;)s.Lh.shift()()})(),(function t(){function e(){s.Gh=!0,b||(_=!0,K.Oh(),p?.(s),s.Ch?.(),(()=>{if(s.kh)for("function"==typeof s.kh&&(s.kh=[s.kh]);s.kh.length;)O(s.kh.shift())
803
+ L(G)})())}E>0?T=t:((()=>{if(s.Dh)for("function"==typeof s.Dh&&(s.Dh=[s.Dh]);s.Dh.length;)k(s.Dh.shift())
762
804
  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})})
763
805
  t.exports=i,t.exports.default=i})(vt)
764
806
  var xt=r(vt.exports),bt={exports:{}}
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._o(e.length+1)
807
+ try{bt.exports=t=>{function e(t){return(255&t.charCodeAt(0))<<24|(255&t.charCodeAt(1))<<16|(255&t.charCodeAt(2))<<8|255&t.charCodeAt(3)}function i(e){var i=s.Oo(e.length+1)
766
808
  for(let n=0;e.length>n;++n){const s=e.charCodeAt(n)
767
809
  if(s>127)throw Error("Expected ASCII text")
768
- 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
769
- n&&(n=n.split(","),r=s._o(16*n.length),n.forEach(t=>{var e=i(t)
770
- 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")
771
- let o=t.ns,h=t.ys
772
- var a=o(t=>{s.To(t)},"vi"),c=e("JSON"),l="",u=s._o(256)
773
- return{Be(e){var i=s._o(e.byteLength)
810
+ t.HEAPU8[i+n]=s}return t.HEAPU8[i+e.length]=0,{nr:i,length:e.length,ko(){s.ko(i)}}}function n(t,e,n){var r=0,o=0
811
+ n&&(n=n.split(","),r=s.Oo(16*n.length),n.forEach(t=>{var e=i(t)
812
+ s.Lo(e.nr,-1,r+16*o)&&o++,e.ko()})),s._h(t.nr,e.nr,r,o),r&&s.ko(r)}var s=t._r,r=new TextDecoder("utf8")
813
+ let o=t.us,h=t.bs
814
+ var a=o(t=>{s.ko(t)},"vi"),l=e("JSON"),c="",u=s.Oo(256)
815
+ return{Ue(e){var i=s.Oo(e.byteLength)
774
816
  t.HEAPU8.set(new Uint8Array(e),i)
775
- var n=s._r(i,e.byteLength,2,i,a)
776
- return{Ys:n,destroy(){s.Tr(n)}}},Ne(i,n){var r=s.ko(i.Ys,n)
777
- const o=s.$o(r)
778
- return{Ys:r,upem:o,Mh(i){var n=s.Uo(r,e(i)),o=s.Mr(n)
779
- if(o){var h=s.Fr(n,null)
780
- return t.HEAPU8.subarray(h,h+o)}},$e(){var e=s._o(2048),i=s._o(4)
781
- t.HEAPU32[i/4]=64,s.rh(r,0,i,e)
817
+ var n=s.Or(i,e.byteLength,2,i,a)
818
+ return{nr:n,destroy(){s.kr(n)}}},Pe(i,n){var r=s.Ro(i.nr,n)
819
+ const o=s.Jo(r)
820
+ return{nr:r,upem:o,Bh(i){var n=s.qo(r,e(i)),o=s.Br(n)
821
+ if(o){var h=s.Ur(n,null)
822
+ return t.HEAPU8.subarray(h,h+o)}},We(){var e=s.Oo(2048),i=s.Oo(4)
823
+ t.HEAPU32[i/4]=64,s.wh(r,0,i,e)
782
824
  var n={}
783
825
  return Array.from({length:t.HEAPU32[i/4]}).forEach((i,s)=>{var r
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.To(i),s.To(e),n},Ih(){var e=s.eh()
785
- s.Wo(r,e)
786
- var i=(e=>{const i=s.hh(e),n=s._o(i<<2),r=n>>2,o=t.HEAPU32.subarray(r,r+i)
787
- return t.HEAPU32.set(o,r),s.uh(e,-1,n,i),o})(e)
788
- 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
789
- return{Ys:a,Fh(e){s.Ho(a,e,u,256)
826
+ n[(r=t.HEAPU32[e/4+8*s+1],""+String.fromCharCode(r>>24&255)+String.fromCharCode(r>>16&255)+String.fromCharCode(r>>8&255)+String.fromCharCode(255&r))]={min:t.HEAPF32[e/4+8*s+4],default:t.HEAPF32[e/4+8*s+5],max:t.HEAPF32[e/4+8*s+6]}}),s.ko(i),s.ko(e),n},Nh(){var e=s.fh()
827
+ s.Qo(r,e)
828
+ var i=(e=>{const i=s.mh(e),n=s.Oo(i<<2),r=n>>2,o=t.HEAPU32.subarray(r,r+i)
829
+ return t.HEAPU32.set(o,r),s.bh(e,-1,n,i),o})(e)
830
+ return s.yh(e),i},destroy(){s.Ho(r)}}},$e(i){function n(t){return l||(f=o((t,e,i,n,s)=>{c+=`M${n},${s}`},"viiiffi"),d=o((t,e,i,n,s)=>{c+=`L${n},${s}`},"viiiffi"),y=o((t,e,i,n,s,r,o,h,a)=>{c+=`C${n},${s} ${r},${o} ${h},${a}`},"viiiffffffi"),p=o((t,e,i,n,s,r,o)=>{c+=`Q${n},${s} ${r},${o}`},"viiiffffi"),w=o(()=>{c+="Z"},"viiii"),l=s.fs(),s.ds(l,f,0,0),s.ys(l,d,0,0),s.ws(l,y,0,0),s.ps(l,p,0,0),s.gs(l,w,0,0)),c="",s.ir(a,t,l,0),c}var a=s.ih(i.nr),l=null,f=null,d=null,y=null,p=null,w=null
831
+ return{nr:a,Uh(e){s.th(a,e,u,256)
790
832
  var i=t.HEAPU8.subarray(u,u+256)
791
- 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)
792
- 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)
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.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()
794
- return{Ys:e,jt(i){const n=(e=>{const i=s._o(2*e.length),n=new Uint16Array(t.ur.buffer,i,e.length)
833
+ return r.decode(i.slice(0,i.indexOf(0)))},Ph:n,$h:t=>n(t).replace(/([MLQCZ])/g,"|$1 ").split("|").filter(t=>t.length).map(t=>{var e=t.split(/[ ,]/g)
834
+ return{type:e[0],values:e.slice(1).filter(t=>t.length).map(t=>+t)}}),setScale(t,e){s.ah(a,t,e)},ze(i){var n=Object.entries(i),r=s.Oo(8*n.length)
835
+ n.forEach((i,n)=>{t.HEAPU32[r/4+2*n+0]=e(i[0]),t.HEAPF32[r/4+2*n+1]=i[1]}),s.sh(a,r,n.length),s.ko(r)},destroy(){s.oh(a),l&&(s.xs(l),l=null,h(f),h(d),h(y),h(p),h(w))}}},createBuffer(){var e=s.Wr()
836
+ return{nr:e,Vt(i){const n=(e=>{const i=s.Oo(2*e.length),n=new Uint16Array(t.Sr.buffer,i,e.length)
795
837
  for(let t=0;n.length>t;++t)n[t]=e.charCodeAt(t)
796
- return{Ys:i,length:n.length,To(){s.To(i)}}})(i)
797
- 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
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.Hr(e,i)},Nh(t){var n=i(t)
799
- s.Rr(e,s.fo(n.Ys,-1)),n.To()},Uh(t){var n=i(t)
800
- 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)})
801
- 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)))
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.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")
803
- return s.lo(i.Ys,g,0,0),n(e,i,a),s.To(w),h(g),f},version(){var e=s._o(12)
804
- s.wo(e,e+4,e+8)
805
- var i={zh:t.HEAPU32[e/4],Wh:t.HEAPU32[(e+4)/4],Rh:t.HEAPU32[(e+8)/4]}
806
- return s.To(e),i},jh(){var e=s.mo()
838
+ return{nr:i,length:n.length,ko(){s.ko(i)}}})(i)
839
+ s.vo(e,n.nr,n.length,0,n.length),n.ko()},qt:()=>s.do(e),ur(t){s.Yr(e,{zh:4,Wh:5,Rh:6,jh:7}[t]||0)},Hh(t){var i=0
840
+ t.forEach(t=>{i|=(t=>"BOT"==t?1:"EOT"==t?2:"PRESERVE_DEFAULT_IGNORABLES"==t?4:"REMOVE_DEFAULT_IGNORABLES"==t?8:"DO_NOT_INSERT_DOTTED_CIRCLE"==t?16:"PRODUCE_UNSAFE_TO_CONCAT"==t?64:0)(t)}),s.eo(e,i)},Vh(t){var n=i(t)
841
+ s.Xr(e,s.So(n.nr,-1)),n.ko()},qh(t){var n=i(t)
842
+ s.Kr(e,s.Eo(n.nr,-1)),n.ko()},Yh(t){s.no(e,t)},json(){for(var i=s.ro(e),n=[],r=s.ho(e,0),o=r/4,h=s.lo(e,0)/4,a=t.HEAPU32.subarray(o,o+5*i),l=t.HEAP32.subarray(h,h+5*i),c=0;i>c;++c)n.push({g:a[5*c+0],Jt:a[5*c+2],ax:l[5*c+0],ay:l[5*c+1],dx:l[5*c+2],dy:l[5*c+3],flags:s.uo(r+20*c)})
843
+ return n},destroy(){s.jr(e)}}},shape:n,Jh(e,i,a,c,u){var f=[],d=0,y=!1,p=1048576,w=s.Oo(p),g=o((e,i,n)=>{var o=r.decode(t.HEAPU8.subarray(n,t.HEAPU8.indexOf(0,n)))
844
+ 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 "+c)&&(y=!0),y?0:(s.$r(e,0,s.ro(e),w,p,0,i,l,4),f.push({li:o,di:JSON.parse(r.decode(t.HEAPU8.subarray(w,t.HEAPU8.indexOf(0,w)))),glyphs:2==s.Vr(e)}),1)},"iiiii")
845
+ return s.xo(i.nr,g,0,0),n(e,i,a),s.ko(w),h(g),f},version(){var e=s.Oo(12)
846
+ s.Ao(e,e+4,e+8)
847
+ var i={Kh:t.HEAPU32[e/4],Qh:t.HEAPU32[(e+4)/4],Xh:t.HEAPU32[(e+8)/4]}
848
+ return s.ko(e),i},Zh(){var e=s.Io()
807
849
  return r.decode(t.HEAPU8.subarray(e,t.HEAPU8.indexOf(0,e)))}}}}catch(t){}var St=r(bt.exports)
808
850
  let _t=null,Et=null,Tt=null
809
- 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={}
810
- if(Tt)e.lr=Tt
851
+ const At={ta(t){Et=t,Tt=null,_t=null},ea(t){Tt=t,Et=null,_t=null},ia:async()=>_t||(_t=new Promise(async(t,e)=>{try{const e={}
852
+ if(Tt)e.br=Tt
811
853
  else{if(!Et)throw Error("HarfBuzz WASM path or buffer must be set before initialization.")
812
- e.mh=(t,e)=>t.endsWith(".wasm")?Et:e+t}const i=await xt(e)
813
- t({hb:St(i),module:{ns:i.ns,exports:i.dr,ys:i.ys}})}catch(t){e(Error("Failed to initialize HarfBuzz: "+t))}}),_t)}
814
- class Mt{constructor(t,e){this.text=t,this.Yh=new Map,e.forEach(t=>{const e=this.Yh.get(t.js)||[]
815
- e.push(t),this.Yh.set(t.js,e)})}Jh(t){const e=[]
816
- return t.Kh&&e.push(...this.Qh(t.Kh)),t.Xh&&e.push(...this.Zh(t.Xh)),e}Qh(t){const e=[]
854
+ e.Ih=(t,e)=>t.endsWith(".wasm")?Et:e+t}const i=await xt(e)
855
+ t({hb:St(i),module:{us:i.us,exports:i._r,bs:i.bs}})}catch(t){e(Error("Failed to initialize HarfBuzz: "+t))}}),_t)}
856
+ class Mt{constructor(t,e){this.text=t,this.na=new Map,e.forEach(t=>{const e=this.na.get(t.Zs)||[]
857
+ e.push(t),this.na.set(t.Zs,e)})}sa(t){const e=[]
858
+ return t.ra&&e.push(...this.oa(t.ra)),t.ha&&e.push(...this.aa(t.ha)),e}oa(t){const e=[]
817
859
  for(const i of t){let t=0
818
- 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)
860
+ for(;-1!==(t=this.text.indexOf(i,t));)e.push(this.createTextRange(t,t+i.length,i)),t+=i.length}return e}aa(t){return t.map(t=>{const e=this.text.slice(t.start,t.end)
819
861
  return this.createTextRange(t.start,t.end,e)})}createTextRange(t,e,i){const n=[],s=new Map
820
- for(let i=t;e>i;i++){const t=this.Yh.get(i)
862
+ for(let i=t;e>i;i++){const t=this.na.get(i)
821
863
  if(t)for(const e of t){n.push(e)
822
- const t=s.get(e.Hs)||[]
823
- 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}}
864
+ const t=s.get(e.tr)||[]
865
+ t.push(e),s.set(e.tr,t)}}return{start:t,end:e,la:i,bounds:Array.from(s.values()).map(t=>this.ca(t)),glyphs:n,ua:Array.from(s.keys()).sort((t,e)=>t-e)}}ca(t){if(0===t.length)return{min:{x:0,y:0,z:0},max:{x:0,y:0,z:0}}
824
866
  let e=1/0,i=1/0,n=1/0,s=-1/0,r=-1/0,o=-1/0
825
867
  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)
826
868
  return{min:{x:e,y:i,z:n},max:{x:s,y:r,z:o}}}}const It=72
827
- 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()
869
+ class Ft{static{this.fa=new Map}static{this.da=null}static{this.ya=new Map}static{this.pa=0}static{this.wa=1/0}static{this.ga=0}static va(t){const e=Object.keys(t).sort()
828
870
  let i=""
829
871
  for(let n=0;e.length>n;n++)n>0&&(i+=","),i+=e[n]+":"+t[e[n]]
830
- 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.")
831
- Ft.sa||(Ft.sa=At.qh())
832
- const e=await Ft.ya(t),i=new Ft
833
- i.pa(e)
834
- const n=await i.wa(t),s=async e=>{const n={...t}
872
+ return i}constructor(){this.ma="",Ft.da||(Ft.da=At.ia()),this.xa=new H(()=>Ft.da)}static ba(t){At.ta(t),Ft.da=null}static Sa(t){At.ea(t),Ft.da=null}static init(){return Ft.da||(Ft.da=At.ia()),Ft.da}static async create(t){if(!t.font)throw Error("Font is required. Specify options.font as a URL string or ArrayBuffer.")
873
+ Ft.da||(Ft.da=At.ia())
874
+ const e=await Ft._a(t),i=new Ft
875
+ i.Ea(e)
876
+ const n=await i.Ta(t),s=async e=>{const n={...t}
835
877
  for(const t in e){const i=e[t]
836
- 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)
837
- 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}}
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 ya(t){let e="string"==typeof t.font?t.font:"buffer-"+Ft.va(t.font)
839
- t.ze&&(e+="_var_"+Ft.ca(t.ze)),t.Vt&&(e+="_feat_"+Ft.ca(t.Vt))
840
- let i=Ft.ra.get(e)
841
- 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
842
- await s.De(e,i,n)
878
+ void 0!==i&&(n[t]=i)}if(void 0!==e.font||void 0!==e.Re||void 0!==e.Yt){const t=await Ft._a(n)
879
+ i.Ea(t),i.Aa()}return t=n,{...await i.Ta(t),getLoadedFont(){return i.getLoadedFont()},getCacheSize(){return i.getCacheSize()},clearCache(){return i.clearCache()},measureTextWidth(t,e){return i.measureTextWidth(t,e)},update:s}}
880
+ return{...n,getLoadedFont(){return i.getLoadedFont()},getCacheSize(){return i.getCacheSize()},clearCache(){return i.clearCache()},measureTextWidth(t,e){return i.measureTextWidth(t,e)},update:s}}static async _a(t){let e="string"==typeof t.font?t.font:"buffer-"+Ft.Ma(t.font)
881
+ t.Re&&(e+="_var_"+Ft.va(t.Re)),t.Yt&&(e+="_feat_"+Ft.va(t.Yt))
882
+ let i=Ft.ya.get(e)
883
+ return i||(i=await Ft.Ia(e,t.font,t.Re,t.Yt)),i}static async Ia(t,e,i,n){const s=new Ft
884
+ await s.Ne(e,i,n)
843
885
  const r=s.getLoadedFont()
844
- 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)
845
- 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
886
+ return Ft.ya.set(t,r),Ft.Fa(r),Ft.La(),r}static Fa(t){Ft.pa+=t.Ye?.byteLength??0}static Ga(t){const e=Ft.ya.get(t)
887
+ e&&(Ft.pa-=e.Ye?.byteLength??0,0>Ft.pa&&(Ft.pa=0))}static La(){if(Ft.wa!==1/0)for(;Ft.pa>Ft.wa&&Ft.ya.size>0;){const t=Ft.ya.keys().next().value
846
888
  if(void 0===t)break
847
- Ft.Sa(t),Ft.ra.delete(t)}}static va(t){if(t){const e=new Uint8Array(t)
889
+ Ft.Ga(t),Ft.ya.delete(t)}}static Ma(t){if(t){const e=new Uint8Array(t)
848
890
  let i=2166136261
849
891
  const n=Math.min(32,e.length),s=Math.floor(e.length/n)
850
892
  for(let t=0;n>t;t++)i^=e[t*s],i=Math.imul(i,16777619)
851
- return i^=e.length,i=Math.imul(i,16777619),(i>>>0).toString(36)}return"c"+ ++Ft.aa}pa(t){this.Yt=t
852
- const e=Ft.va(t.Ve)
853
- 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
893
+ return i^=e.length,i=Math.imul(i,16777619),(i>>>0).toString(36)}return"c"+ ++Ft.ga}Ea(t){this.Kt=t
894
+ const e=Ft.Ma(t.Ye)
895
+ this.ma="font_"+e,t.Re&&(this.ma+="_var_"+Ft.va(t.Re)),t.Yt&&(this.ma+="_feat_"+Ft.va(t.Yt))}async Ne(t,e,i){Ft.da||(Ft.da=At.ia()),await Ft.da
854
896
  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}`)
855
897
  return e.arrayBuffer()}):t
856
- try{this.Yt&&this.destroy(),this.Yt=await this.ua.De(n,e),i&&(this.Yt.Vt=i)
857
- const t=Ft.va(n)
858
- 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.")
859
- const e=await this._a(t)
860
- this.Ea(e),this.Ta(t=e),this.Xs||(this.Xs=new wt(Q,this.Yt),this.Xs.Ms(this.la))
898
+ try{this.Kt&&this.destroy(),this.Kt=await this.xa.Ne(n,e),i&&(this.Kt.Yt=i)
899
+ const t=Ft.Ma(n)
900
+ this.ma="font_"+t,e&&(this.ma+="_var_"+Ft.va(e)),i&&(this.ma+="_feat_"+Ft.va(i))}catch(t){throw a.error("Failed to load font:",t),t}}async Ta(t){try{if(!this.Kt)throw Error("Font not loaded. Use Text.create() with a font option.")
901
+ const e=await this.Oa(t)
902
+ this.Ca(e),this.ka(t=e),this.ar||(this.ar=new wt(Q,this.Kt),this.ar.Bs(this.ma))
861
903
  const i=null!=t.curveSteps&&t.curveSteps>0
862
- 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))
863
- 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)
904
+ this.ar.pn(t.curveSteps),this.ar.yn(i?void 0:t.curveFidelity),this.ar.Qn(t.geometryOptimization),this.Kt.font.setScale(this.Kt.upem,this.Kt.upem),this.Da||(this.Da=new gt(this.Kt,this.ar))
905
+ const n=this.Ba(t),s=t.Na??this.Kt.je??!1,r=this.Da.lr(n.lines,n.Ua,n.letterSpacing,n.align,n.direction,t.color,t.text)
864
906
  let o,h
865
- 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=[]
866
- for(const e of Object.keys(t.color.Kh)){let i=0
907
+ if(t.color&&"object"==typeof t.color&&!Array.isArray(t.color)&&(t.color.ra||t.color.ha)){if(o=new Set,t.color.ra){h=[]
908
+ for(const e of Object.keys(t.color.ra)){let i=0
867
909
  for(;-1!==(i=t.text.indexOf(e,i));){h.push({pattern:e,start:i,end:i+e.length})
868
910
  for(let t=i;i+e.length>t;t++)o.add(t)
869
- 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)
870
- if(t.perGlyphAttributes){const t=this.Oa(c.vertices.length/3,c.glyphs)
871
- c.glyphAttributes=t}return c}finally{}}async _a(t){if(!1!==t.layout?.wt&&t.layout?.width){const e=t.layout?.language||"en-us"
872
- if(!t.layout?.xt?.[e])try{if(!Ft.na.has(e)){const i=await n(e,t.layout?.Ca)
873
- 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")
874
- const e=t.ka??1e5
875
- 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")
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"),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
911
+ i+=e.length}}}if(t.color.ha)for(const e of t.color.ha)for(let t=e.start;e.end>t;t++)o.add(t)}const a=this.ar.Us(r,n.depth,s,this.Kt.h.ue,n.Pa,t.perGlyphAttributes??!1,o),l=this.$a(a.vertices,a.normals,a.indices,a.Xs,a.planeBounds,t,t.text,h)
912
+ if(t.perGlyphAttributes){const t=this.za(l.vertices.length/3,l.glyphs)
913
+ l.glyphAttributes=t}return l}finally{}}async Oa(t){if(!1!==t.layout?.vt&&t.layout?.width){const e=t.layout?.language||"en-us"
914
+ if(!t.layout?.St?.[e])try{if(!Ft.fa.has(e)){const i=await n(e,t.layout?.Wa)
915
+ Ft.fa.set(e,i)}return{...t,layout:{...t.layout,St:{...t.layout?.St,[e]:Ft.fa.get(e)}}}}catch(i){return a.warn(`Failed to load patterns for ${e}: ${i}`),{...t,layout:{...t.layout,vt:!1}}}}return t}Ca(t){if(!t.text)throw Error("Text content is required")
916
+ const e=t.Ra??1e5
917
+ if(t.text.length>e)throw Error(`Text exceeds ${e} character limit`)}ka(t){t.Re&&this.Kt&&Ft.va(t.Re)!==Ft.va(this.Kt.Re||{})&&(this.Kt.font.ze(t.Re),this.Kt.Re=t.Re)}Ba(t){if(!this.Kt)throw Error("Font not loaded. Use Text.create() with a font option")
918
+ 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=l,Tt:g=c,At:v=u,Mt:m,St:x,It:b,Ft:S,Lt:_,Gt:E,Ot:T,Ct:A,kt:M}=o,F=this.Kt.upem/i
877
919
  let L
878
920
  void 0!==h&&(L=h*F)
879
- const G=n*F,O=G>0?Math.max(G,25e-6*this.Yt.upem):0
880
- this.Da||(this.Da=new I(this.Yt))
881
- 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)
882
- 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=[]
921
+ const G=n*F,O=G>0?Math.max(G,25e-6*this.Kt.upem):0
922
+ this.ja||(this.ja=new I(this.Kt))
923
+ const C=this.ja.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,Ct:A,kt:M,letterSpacing:r}),k=R.Fe(this.Kt.h)
924
+ return{lines:C.lines,Ua:(k.ie-k.ne)*s,letterSpacing:r,align:f,direction:a,depth:O,size:i,Pa:1/F}}Ha(t,e,i,n,s){const r=t.length/3,o=new Float32Array(3*r),h=[]
883
925
  if(Array.isArray(i)){for(let t=0;r>t;t++){const e=3*t
884
- 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]
926
+ o[e]=i[0],o[e+1]=i[1],o[e+2]=i[2]}h.push({start:0,end:n.length,la:n,color:i,bounds:[],glyphs:e,ua:[...new Set(e.map(t=>t.tr))]})}else{const t=i.default||[1,1,1]
885
927
  for(let e=0;o.length>e;e+=3)o[e]=t[0],o[e+1]=t[1],o[e+2]=t[2]
886
928
  let r
887
- if(i.Kh&&s||i.Xh){r=new Map
888
- for(const t of e){const e=r.get(t.js)
889
- 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]
929
+ if(i.ra&&s||i.ha){r=new Map
930
+ for(const t of e){const e=r.get(t.Zs)
931
+ e?e.push(t):r.set(t.Zs,[t])}}if(i.ra&&s&&r)for(const t of s){const e=i.ra[t.pattern]
890
932
  if(!e)continue
891
933
  const n=[],s=new Map
892
934
  for(let i=t.start;t.end>i;i++){const t=r.get(i)
893
935
  if(t)for(const i of t){n.push(i)
894
- const t=s.get(i.Hs)
895
- t?t.push(i):s.set(i.Hs,[i])
896
- for(let t=0;i.Vs>t;t++){const n=3*(i.Os+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.Na(t))
898
- 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
936
+ const t=s.get(i.tr)
937
+ t?t.push(i):s.set(i.tr,[i])
938
+ for(let t=0;i.er>t;t++){const n=3*(i.zs+t)
939
+ n>=0&&o.length>n&&(o[n]=e[0],o[n+1]=e[1],o[n+2]=e[2])}}}const a=Array.from(s.values()).map(t=>this.Va(t))
940
+ h.push({start:t.start,end:t.end,la:t.pattern,color:e,bounds:a,glyphs:n,ua:Array.from(s.keys()).sort((t,e)=>t-e)})}if(i.ha&&r)for(const t of i.ha){const e=[],i=new Map
899
941
  for(let n=t.start;t.end>n;n++){const s=r.get(n)
900
942
  if(s)for(const n of s){e.push(n)
901
- const s=i.get(n.Hs)
902
- s?s.push(n):i.set(n.Hs,[n])
903
- for(let e=0;n.Vs>e;e++){const i=3*(n.Os+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.Na(t))
905
- 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}}
943
+ const s=i.get(n.tr)
944
+ s?s.push(n):i.set(n.tr,[n])
945
+ for(let e=0;n.er>e;e++){const i=3*(n.zs+e)
946
+ i>=0&&o.length>i&&(o[i]=t.color[0],o[i+1]=t.color[1],o[i+2]=t.color[2])}}}const s=Array.from(i.values()).map(t=>this.Va(t))
947
+ h.push({start:t.start,end:t.end,la:n.slice(t.start,t.end),color:t.color,bounds:s,glyphs:e,ua:Array.from(i.keys()).sort((t,e)=>t-e)})}}return{colors:o,qa:h}}Va(t){if(0===t.length)return{min:{x:0,y:0,z:0},max:{x:0,y:0,z:0}}
906
948
  let e=1/0,i=1/0,n=1/0,s=-1/0,r=-1/0,o=-1/0
907
949
  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)
908
- 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
909
- this.Da||(this.Da=new I(this.Yt))
910
- const u=this.Da.Xt({width:c,align:l,planeBounds:s}),f=u.offset
911
- 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
950
+ return{min:{x:e,y:i,z:n},max:{x:s,y:r,z:o}}}$a(t,e,i,n,s,r,o,h){const{layout:a={}}=r,{width:l,align:c=("rtl"===a.direction?"right":"left")}=a
951
+ this.ja||(this.ja=new I(this.Kt))
952
+ const u=this.ja.te({width:l,align:c,planeBounds:s}),f=u.offset
953
+ 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
912
954
  for(let t=0;n.length>t;t++)n[t].bounds.min.x+=f,n[t].bounds.max.x+=f}let d,y
913
- if(r.color){const e=this.Ba(t,n,r.color,r.text,h)
914
- d=e.colors,y=e.Ua}const p=this.Xs.Vn()
955
+ if(r.color){const e=this.Ha(t,n,r.color,r.text,h)
956
+ d=e.colors,y=e.qa}const p=this.ar.Xn()
915
957
  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
916
958
  return e=>{if(!o)throw Error("Original text not available for querying")
917
- 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")
918
- 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)
919
- 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")
920
- 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)
959
+ return t||(t=new Mt(o,n)),t.sa(e)}})(),qa:y,glyphAttributes:void 0}}Le(){if(!this.Kt)throw Error("Font not loaded. Call loadFont() first")
960
+ return R.Le(this.Kt.h)}static async Ya(t,e){await Promise.all(t.map(async t=>{if(!Ft.fa.has(t))try{const i=await n(t,e)
961
+ Ft.fa.set(t,i)}catch(e){a.warn(`Failed to pre-load patterns for ${t}: ${e}`)}}))}static Ja(t,e){Ft.fa.set(t,e)}static Ka(t){Ft.wa=t===1/0?1/0:1048576*Math.max(1,Math.floor(t)),Ft.La()}getLoadedFont(){return this.Kt}measureTextWidth(t,e=0){if(!this.Kt)throw Error("Font not loaded. Call loadFont() first")
962
+ return M.measureTextWidth(this.Kt,t,e)}getCacheSize(){return this.ar?this.ar.rr().size:0}clearCache(){this.ar&&this.ar.clearCache()}za(t,e){const i=new Float32Array(3*t),n=new Float32Array(t),s=new Float32Array(t),r=new Float32Array(t),o=new Float32Array(t)
921
963
  let h=1/0,a=-1/0
922
964
  for(let t=0;e.length>t;t++){const i=(e[t].bounds.min.x+e[t].bounds.max.x)/2
923
- h>i&&(h=i),i>a&&(a=i)}const c=a-h
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.Os,g=Math.min(w+l.Vs,t)
925
- if(g>w){n.fill(a,w,g),s.fill(l.Hs,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}}ga(){this.Xs=void 0,this.Aa=void 0,this.Da=void 0}destroy(){if(!this.Yt)return
927
- const t=this.Yt
928
- 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})
965
+ h>i&&(h=i),i>a&&(a=i)}const l=a-h
966
+ for(let a=0;e.length>a;a++){const c=e[a],u=(c.bounds.min.x+c.bounds.max.x)/2,f=(c.bounds.min.y+c.bounds.max.y)/2,d=(c.bounds.min.z+c.bounds.max.z)/2,y=c.bounds.min.y,p=l>0?(u-h)/l:0,w=c.zs,g=Math.min(w+c.er,t)
967
+ if(g>w){n.fill(a,w,g),s.fill(c.tr,w,g),r.fill(p,w,g),o.fill(y,w,g)
968
+ for(let t=3*w;3*g>t;t+=3)i[t]=u,i[t+1]=f,i[t+2]=d}}return{glyphCenter:i,glyphIndex:n,glyphLineIndex:s,glyphProgress:r,glyphBaselineY:o}}Aa(){this.ar=void 0,this.Da=void 0,this.ja=void 0}destroy(){if(!this.Kt)return
969
+ const t=this.Kt
970
+ try{H.Je(t)}catch(t){a.warn("Error destroying HarfBuzz objects:",t)}finally{this.Kt=void 0,this.ja=void 0,this.Da=void 0}}}t.DEFAULT_CURVE_FIDELITY=ct,t.FontMetadataExtractor=R,t.Text=Ft,t.Qa=()=>new K,t.Xa=Q})