three-text 0.4.3 → 0.4.5

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