three-text 0.2.16 → 0.2.18

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