three-text 0.3.0 → 0.3.2

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