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