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