three-text 0.4.10 → 0.4.11
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/dist/index.cjs +515 -446
- package/dist/index.d.ts +3 -0
- package/dist/index.js +515 -446
- package/dist/index.min.cjs +563 -545
- package/dist/index.min.js +550 -532
- package/dist/index.umd.js +515 -446
- package/dist/index.umd.min.js +534 -516
- package/dist/three/react.d.ts +3 -0
- package/dist/types/core/geometry/PathOptimizer.d.ts +0 -2
- package/dist/types/core/geometry/Polygonizer.d.ts +10 -5
- package/dist/types/core/types.d.ts +3 -0
- package/package.json +1 -1
- package/dist/types/utils/MinHeap.d.ts +0 -14
package/dist/index.min.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* three-text v0.4.
|
|
2
|
+
* three-text v0.4.11
|
|
3
3
|
* Copyright (C) 2025 Countertype LLC
|
|
4
4
|
*
|
|
5
5
|
* This program is free software: you can redistribute it and/or modify
|
|
@@ -12,45 +12,45 @@
|
|
|
12
12
|
* This software includes third-party code - see LICENSE_THIRD_PARTY for details.
|
|
13
13
|
*/
|
|
14
14
|
function t(t){if(!t||0===Object.keys(t).length)return
|
|
15
|
-
const e=
|
|
15
|
+
const e=At.get(t)
|
|
16
16
|
if(void 0!==e)return e??void 0
|
|
17
17
|
const i=[]
|
|
18
|
-
for(const[e,s]of Object.entries(t))/^[a-zA-Z0-9]{4}$/.test(e)?!1===s||0===s?i.push(e+"=0"):!0===s||1===s?i.push(e):"number"==typeof s&&s>1?i.push(`${e}=${Math.floor(s)}`):
|
|
18
|
+
for(const[e,s]of Object.entries(t))/^[a-zA-Z0-9]{4}$/.test(e)?!1===s||0===s?i.push(e+"=0"):!0===s||1===s?i.push(e):"number"==typeof s&&s>1?i.push(`${e}=${Math.floor(s)}`):st.warn(`Invalid value for feature "${e}": ${s}. Expected boolean or positive number.`):st.warn(`Invalid OpenType feature tag: "${e}". Tags must be exactly 4 alphanumeric characters.`)
|
|
19
19
|
const s=i.length>0?i.join(","):void 0
|
|
20
|
-
return
|
|
20
|
+
return At.set(t,s??null),s}function e(t){const e=t.getUint16(4),i=new Map
|
|
21
21
|
for(let s=0;e>s;s++){const e=12+16*s
|
|
22
22
|
if(e+16>t.byteLength)break
|
|
23
23
|
const n=t.getUint32(e),r=t.getUint32(e+4),o=t.getUint32(e+8),h=t.getUint32(e+12)
|
|
24
|
-
i.set(n,{tag:n,t:r,offset:o,length:h})}return i}async function i(t,e){if(!
|
|
25
|
-
if(!e
|
|
24
|
+
i.set(n,{tag:n,t:r,offset:o,length:h})}return i}async function i(t,e){if(!jt.test(t))throw Error(`Invalid hyphenation language code "${t}". Expected e.g. "en-us".`)
|
|
25
|
+
if(!e&&!Ut.has(t))throw Error(`Unsupported hyphenation language "${t}". Use a built-in language (e.g. "en-us") or register patterns via Text.registerPattern("${t}", pattern).`)
|
|
26
26
|
try{if(e)return(await import(`${e}${t}.js`)).default
|
|
27
|
-
if("string"==typeof("undefined"==typeof document?require("url").pathToFileURL(__filename).href:
|
|
27
|
+
if("string"==typeof("undefined"==typeof document?require("url").pathToFileURL(__filename).href:et&&"SCRIPT"===et.tagName.toUpperCase()&&et.src||new URL("index.min.cjs",document.baseURI).href)){const e=new URL(".","undefined"==typeof document?require("url").pathToFileURL(__filename).href:et&&"SCRIPT"===et.tagName.toUpperCase()&&et.src||new URL("index.min.cjs",document.baseURI).href).href,i=new URL(`./patterns/${t}.js`,e).href
|
|
28
28
|
return(await import(i)).default}return(await import(`./patterns/${t}.js`)).default}catch(e){throw Error(`Failed to load hyphenation patterns for ${t}. Consider using static imports: import pattern from 'three-text/patterns/${t}'; Text.registerPattern('${t}', pattern);`)}}function s(t,e,i,s){return`${t}_${e}_${Math.round(1e3*i)/1e3}_${s}`}function n(t,e){return t.s===e.s&&t.i===e.i}function r(t,e){return e.s>t.s||t.s===e.s&&e.i>=t.i}function o(t,e){return e.i>t.i||t.i===e.i&&e.s>=t.s}function h(t){return r(t.h.o,t.o)}function a(t){return r(t.o,t.h.o)}function l(t,e){return Math.abs(t.s-e.s)+Math.abs(t.i-e.i)}function c(t,e,i){let s=e.s-t.s,n=i.s-e.s
|
|
29
29
|
return s+n>0?n>s?e.i-t.i+s/(s+n)*(t.i-i.i):e.i-i.i+n/(s+n)*(i.i-t.i):0}function u(t,e,i){let s=e.s-t.s,n=i.s-e.s
|
|
30
30
|
return s+n>0?(e.i-i.i)*s+(e.i-t.i)*n:0}function f(t,e,i){let s=e.i-t.i,n=i.i-e.i
|
|
31
31
|
return s+n>0?n>s?e.s-t.s+s/(s+n)*(t.s-i.s):e.s-i.s+n/(s+n)*(i.s-t.s):0}function d(t,e,i){let s=e.i-t.i,n=i.i-e.i
|
|
32
32
|
return s+n>0?(e.s-i.s)*s+(e.s-t.s)*n:0}function y(t,e,i,s){return(t=0>t?0:t)>(i=0>i?0:i)?s+i/(t+i)*(e-s):0===i?(e+s)/2:e+t/(t+i)*(s-e)}function p(t,e,i){const s=t.event,n=e.l,o=i.l
|
|
33
|
-
return n.h.o===s?o.h.o===s?r(n.o,o.o)?0>=u(o.h.o,n.o,o.o):u(n.h.o,o.o,n.o)>=0:0>=u(o.h.o,s,o.o):o.h.o===s?u(n.h.o,s,n.o)>=0:c(n.h.o,s,n.o)>=c(o.h.o,s,o.o)}function w(t){return t.u}function g(t){return t.next}function m(t,e){t.p+=e.p,t.h.p+=e.h.p}function v(t,e){e.l.N=null,t.m.delete(e)}function x(t,e,i){t.A.delete(e.l),e.I=0,e.l=i,i.N=e}function
|
|
33
|
+
return n.h.o===s?o.h.o===s?r(n.o,o.o)?0>=u(o.h.o,n.o,o.o):u(n.h.o,o.o,n.o)>=0:0>=u(o.h.o,s,o.o):o.h.o===s?u(n.h.o,s,n.o)>=0:c(n.h.o,s,n.o)>=c(o.h.o,s,o.o)}function w(t){return t.u}function g(t){return t.next}function m(t,e){t.p+=e.p,t.h.p+=e.h.p}function v(t,e){e.l.N=null,t.m.delete(e)}function x(t,e,i){t.A.delete(e.l),e.I=0,e.l=i,i.N=e}function A(t,e){let i,s=e.l.o
|
|
34
34
|
do{e=g(e)}while(e.l.o===s)
|
|
35
|
-
return e.I&&(i=t.A.connect(w(e).l.h,e.l.O),x(t,e,i),e=g(e)),e}function
|
|
35
|
+
return e.I&&(i=t.A.connect(w(e).l.h,e.l.O),x(t,e,i),e=g(e)),e}function b(t){let e=t.l.h.o
|
|
36
36
|
do{t=g(t)}while(t.l.h.o===e)
|
|
37
|
-
return t}function E(t,e,i){const s=new
|
|
38
|
-
return s.l=i,t.m.insertBefore(e,s),s.I=0,s.v=0,s.T=0,i.N=s,s}function T(t,e){switch(t.M){case
|
|
39
|
-
case
|
|
40
|
-
case
|
|
41
|
-
case
|
|
42
|
-
case
|
|
43
|
-
s._=e._,s.L=i,v(t,e)}function
|
|
44
|
-
for(;r!==i;){if(r.I=0,n=w(r),s=n.l,s.o!=o.o){if(!n.I){
|
|
45
|
-
break}s=t.A.connect(o.C.h,s.h),x(t,n,s)}o.C!==s&&(t.A.splice(s.h.O,s),t.A.splice(o,s)),
|
|
37
|
+
return t}function E(t,e,i){const s=new ie
|
|
38
|
+
return s.l=i,t.m.insertBefore(e,s),s.I=0,s.v=0,s.T=0,i.N=s,s}function T(t,e){switch(t.M){case Qt.ODD:return!!(1&e)
|
|
39
|
+
case Qt.NONZERO:return 0!==e
|
|
40
|
+
case Qt.POSITIVE:return e>0
|
|
41
|
+
case Qt.NEGATIVE:return 0>e
|
|
42
|
+
case Qt.ABS_GEQ_TWO:return e>=2||-2>=e}throw Error("Invalid winding rule")}function I(t,e){const i=e.l,s=i.D
|
|
43
|
+
s._=e._,s.L=i,v(t,e)}function S(t,e,i){let s,n=null,r=e,o=e.l
|
|
44
|
+
for(;r!==i;){if(r.I=0,n=w(r),s=n.l,s.o!=o.o){if(!n.I){I(t,r)
|
|
45
|
+
break}s=t.A.connect(o.C.h,s.h),x(t,n,s)}o.C!==s&&(t.A.splice(s.h.O,s),t.A.splice(o,s)),I(t,r),o=n.l,r=n}return o}function F(t,e,i,s,n,r){let o,h,a,l,c=1
|
|
46
46
|
a=i
|
|
47
47
|
do{E(t,e,a.h),a=a.C}while(a!==s)
|
|
48
48
|
for(null===n&&(n=w(e).l.h.C),h=e,l=n;o=w(h),a=o.l.h,a.o===l.o;)a.C!==l&&(t.A.splice(a.h.O,a),t.A.splice(l.h.O,a)),o.G=h.G-a.p,o._=T(t,o.G),h.T=1,!c&&C(t,h)&&(m(a,l),v(t,h),t.A.delete(l)),c=0,h=o,l=a
|
|
49
|
-
h.T=1,r&&
|
|
49
|
+
h.T=1,r&&L(t,h)}function M(t,e,i,s,n){e.data=null,t.R&&(ye[0]=e.coords[0],ye[1]=e.coords[1],ye[2]=e.coords[2],e.data=t.R(ye,i,s,t.k)),null===e.data&&(n?(t.j(100156),t.U=1):e.data=i[0])}function _(t,e,i){t.R&&(de[0]=e.o.data,de[1]=i.o.data,de[2]=null,de[3]=null,fe[0]=.5,fe[1]=.5,fe[2]=0,fe[3]=0,M(t,e.o,de,fe,0)),t.A.splice(e,i)}function O(t,e,i,s,n){let r=l(e,t),o=l(i,t),h=.5*o/(r+o),a=.5*r/(r+o)
|
|
50
50
|
void 0!==s&&void 0!==n&&(s[n]=h,s[n+1]=a),t.coords[0]+=h*e.coords[0]+a*i.coords[0],t.coords[1]+=h*e.coords[1]+a*i.coords[1],t.coords[2]+=h*e.coords[2]+a*i.coords[2]}function C(t,e){let i=w(e)
|
|
51
51
|
const s=e.l,r=i.l
|
|
52
52
|
if(r.o.s>s.o.s||s.o.s===r.o.s&&r.o.i>=s.o.i){if(u(r.h.o,s.o,r.o)>0)return 0
|
|
53
|
-
n(s.o,r.o)?s.o!==r.o&&(t.S.delete(s.o.B),
|
|
53
|
+
n(s.o,r.o)?s.o!==r.o&&(t.S.delete(s.o.B),_(t,r.h.O,s)):(t.A.V(r.h),t.A.splice(s,r.h.O),e.T=i.T=1)}else{if(0>u(s.h.o,r.o,s.o))return 0
|
|
54
54
|
g(e).T=e.T=1,t.A.V(s.h),t.A.splice(r.h.O,s)}return 1}function k(t,e){let i=w(e)
|
|
55
55
|
const s=e.l,n=i.l
|
|
56
56
|
let r
|
|
@@ -59,30 +59,30 @@ g(e).T=e.T=1,r=t.A.V(s),t.A.splice(n.h,r),r.D._=e._}else{if(u(n.h.o,s.h.o,n.o)>0
|
|
|
59
59
|
e.T=i.T=1,r=t.A.V(n),t.A.splice(s.O,n.h),r.h.D._=e._}return 1}function B(t,e){let i=w(e),s=e.l,h=i.l
|
|
60
60
|
const a=s.o,l=h.o
|
|
61
61
|
let p,m,v=s.h.o,x=h.h.o
|
|
62
|
-
const E=
|
|
63
|
-
let T,
|
|
62
|
+
const E=ce||(ce=new ne)
|
|
63
|
+
let T,I
|
|
64
64
|
if(a===l)return 0
|
|
65
65
|
if(p=Math.min(a.i,v.i),m=Math.max(l.i,x.i),p>m)return 0
|
|
66
66
|
if(r(a,l)){if(u(x,a,l)>0)return 0}else if(0>u(v,l,a))return 0
|
|
67
67
|
return((t,e,i,s,n)=>{let h,a,l
|
|
68
|
-
r(t,e)||(l=t,t=e,e=l),r(i,s)||(l=i,i=s,s=l),r(t,i)||(l=t,t=i,i=l,l=e,e=s,s=l),r(i,e)?r(e,s)?(h=c(t,i,e),a=c(i,e,s),0>h+a&&(h=-h,a=-a),n.s=y(h,i.s,a,e.s)):(h=u(t,i,e),a=-u(t,s,e),0>h+a&&(h=-h,a=-a),n.s=y(h,i.s,a,s.s)):n.s=.5*(i.s+e.s),o(t,e)||(l=t,t=e,e=l),o(i,s)||(l=i,i=s,s=l),o(t,i)||(l=t,t=i,i=l,l=e,e=s,s=l),o(i,e)?o(e,s)?(h=f(t,i,e),a=f(i,e,s),0>h+a&&(h=-h,a=-a),n.i=y(h,i.i,a,e.i)):(h=d(t,i,e),a=-d(t,s,e),0>h+a&&(h=-h,a=-a),n.i=y(h,i.i,a,s.i)):n.i=.5*(i.i+e.i)})(v,a,x,l,E),(t.event.s>E.s||E.s===t.event.s&&t.event.i>=E.i)&&(E.s=t.event.s,E.i=t.event.i),T=l.s>a.s||a.s===l.s&&l.i>=a.i?a:l,(E.s>T.s||T.s===E.s&&E.i>=T.i)&&(E.s=T.s,E.i=T.i),n(E,a)||n(E,l)?(C(t,e),0):!n(v,t.event)&&u(v,t.event,E)>=0||!n(x,t.event)&&0>=u(x,t.event,E)?x===t.event?(t.A.V(s.h),t.A.splice(h.h,s),s=w(e=
|
|
68
|
+
r(t,e)||(l=t,t=e,e=l),r(i,s)||(l=i,i=s,s=l),r(t,i)||(l=t,t=i,i=l,l=e,e=s,s=l),r(i,e)?r(e,s)?(h=c(t,i,e),a=c(i,e,s),0>h+a&&(h=-h,a=-a),n.s=y(h,i.s,a,e.s)):(h=u(t,i,e),a=-u(t,s,e),0>h+a&&(h=-h,a=-a),n.s=y(h,i.s,a,s.s)):n.s=.5*(i.s+e.s),o(t,e)||(l=t,t=e,e=l),o(i,s)||(l=i,i=s,s=l),o(t,i)||(l=t,t=i,i=l,l=e,e=s,s=l),o(i,e)?o(e,s)?(h=f(t,i,e),a=f(i,e,s),0>h+a&&(h=-h,a=-a),n.i=y(h,i.i,a,e.i)):(h=d(t,i,e),a=-d(t,s,e),0>h+a&&(h=-h,a=-a),n.i=y(h,i.i,a,s.i)):n.i=.5*(i.i+e.i)})(v,a,x,l,E),(t.event.s>E.s||E.s===t.event.s&&t.event.i>=E.i)&&(E.s=t.event.s,E.i=t.event.i),T=l.s>a.s||a.s===l.s&&l.i>=a.i?a:l,(E.s>T.s||T.s===E.s&&E.i>=T.i)&&(E.s=T.s,E.i=T.i),n(E,a)||n(E,l)?(C(t,e),0):!n(v,t.event)&&u(v,t.event,E)>=0||!n(x,t.event)&&0>=u(x,t.event,E)?x===t.event?(t.A.V(s.h),t.A.splice(h.h,s),s=w(e=A(t,e)).l,S(t,w(e),i),F(t,e,s.h.O,s,s,1),1):v===t.event?(t.A.V(h.h),t.A.splice(s.O,h.h.O),i=e,I=w(e=b(e)).l.h.C,i.l=h.h.O,h=S(t,i,null),F(t,e,h.C,s.h.C,I,1),1):(0>u(v,t.event,E)||(g(e).T=e.T=1,t.A.V(s.h),s.o.s=t.event.s,s.o.i=t.event.i),u(x,t.event,E)>0||(e.T=i.T=1,t.A.V(h.h),h.o.s=t.event.s,h.o.i=t.event.i),0):(t.A.V(s.h),t.A.V(h.h),t.A.splice(h.h.O,s),s.o.s=E.s,s.o.i=E.i,s.o.B=t.S.P(s.o),((t,e,i,s,n,r)=>{fe[0]=0,fe[1]=0,fe[2]=0,fe[3]=0,de[0]=i.data,de[1]=s.data,de[2]=n.data,de[3]=r.data,e.coords[0]=e.coords[1]=e.coords[2]=0,O(e,i,s,fe,0),O(e,n,r,fe,2),M(t,e,de,fe,1)})(t,s.o,a,v,l,x),g(e).T=e.T=i.T=1,0)}function L(t,e){let i,s,n=w(e)
|
|
69
69
|
for(;;){for(;n.T;)e=n,n=w(n)
|
|
70
70
|
if(!e.T&&(n=e,null===(e=g(e))||!e.T))return
|
|
71
71
|
if(e.T=0,i=e.l,s=n.l,i.h.o!==s.h.o&&k(t,e)&&(n.I?(v(t,n),t.A.delete(s),n=w(e),s=n.l):e.I&&(v(t,e),t.A.delete(i),i=(e=g(n)).l)),i.o!==s.o)if(i.h.o===s.h.o||e.I||n.I||i.h.o!==t.event&&s.h.o!==t.event)C(t,e)
|
|
72
72
|
else if(B(t,e))return
|
|
73
|
-
i.o===s.o&&i.h.o===s.h.o&&(m(s,i),v(t,e),t.A.delete(i),e=g(n))}}function
|
|
74
|
-
const f=
|
|
75
|
-
f.l=e.L.h,i=t.m.search(f),s=w(i),s&&(a=i.l,l=s.l,0!==u(a.h.o,e,a.o)?(o=r(l.h.o,a.h.o)?i:s,i._||o.I?(c=o===i?t.A.connect(e.L.h,a.O):t.A.connect(l.h.C.h,e.L).h,o.I?x(t,o,c):((t,e)=>{e.G=g(e).G+e.l.p,e._=T(t,e.G)})(t,E(t,i,c)),
|
|
76
|
-
if(s=e.l,n(s.o,i))
|
|
77
|
-
else{if(!n(s.h.o,i))return t.A.V(s.h),e.I&&(t.A.delete(s.C),e.I=0),t.A.splice(i.L,s),void
|
|
78
|
-
l=w(e=
|
|
73
|
+
i.o===s.o&&i.h.o===s.h.o&&(m(s,i),v(t,e),t.A.delete(i),e=g(n))}}function D(t,e){let i,s,o,a,l,c
|
|
74
|
+
const f=ue||(ue=new ie)
|
|
75
|
+
f.l=e.L.h,i=t.m.search(f),s=w(i),s&&(a=i.l,l=s.l,0!==u(a.h.o,e,a.o)?(o=r(l.h.o,a.h.o)?i:s,i._||o.I?(c=o===i?t.A.connect(e.L.h,a.O):t.A.connect(l.h.C.h,e.L).h,o.I?x(t,o,c):((t,e)=>{e.G=g(e).G+e.l.p,e._=T(t,e.G)})(t,E(t,i,c)),N(t,e)):F(t,i,e.L,e.L,null,1)):((t,e,i)=>{let s,r,o,a,l
|
|
76
|
+
if(s=e.l,n(s.o,i))_(t,s,i.L)
|
|
77
|
+
else{if(!n(s.h.o,i))return t.A.V(s.h),e.I&&(t.A.delete(s.C),e.I=0),t.A.splice(i.L,s),void N(t,i)
|
|
78
|
+
l=w(e=b(e)),o=l.l.h,r=a=o.C,l.I&&(v(t,l),t.A.delete(o),o=r.h.O),t.A.splice(i.L,o),h(r)||(r=null),F(t,e,o.C,a,r,1)}})(t,i,e))}function N(t,e){t.event=e
|
|
79
79
|
let i=e.L
|
|
80
|
-
for(;null===i.N;)if(i=i.C,i===e.L)return void
|
|
81
|
-
let s=
|
|
80
|
+
for(;null===i.N;)if(i=i.C,i===e.L)return void D(t,e)
|
|
81
|
+
let s=A(t,i.N),o=w(s)
|
|
82
82
|
const h=o.l
|
|
83
|
-
let a=
|
|
83
|
+
let a=S(t,o,null)
|
|
84
84
|
a.C===h?((t,e,i)=>{let s,o=i.C,h=w(e),a=e.l,l=h.l,c=0
|
|
85
|
-
a.h.o!==l.h.o&&B(t,e),n(a.o,t.event)&&(t.A.splice(o.h.O,a),o=w(e=
|
|
85
|
+
a.h.o!==l.h.o&&B(t,e),n(a.o,t.event)&&(t.A.splice(o.h.O,a),o=w(e=A(t,e)).l,S(t,w(e),h),c=1),n(l.o,t.event)&&(t.A.splice(i,l.h.O),i=S(t,h,null),c=1),c?F(t,e,i.C,o,o,1):(s=r(l.o,a.o)?l.h.O:a,s=t.A.connect(i.C.h,s),F(t,e,s,s.C,s.C,0),s.h.N.I=1,L(t,e))})(t,s,a):F(t,s,a.C,h,h,1)}function P(t,e,i,s){const n=new ie
|
|
86
86
|
let r=t.A.F()
|
|
87
87
|
r.o.s=i,r.o.i=s,r.h.o.s=e,r.h.o.i=s,t.event=r.h.o,n.l=r,n.G=0,n._=0,n.I=0,n.v=1,n.T=0,t.m.P(n)}function $(t,e){const i=t.Y
|
|
88
88
|
let s=i.next,n=s.coords[0],r=s.coords[1],o=s.coords[2],h=n,a=r,l=o,c=s,u=s,f=s,d=s,y=s,p=s
|
|
@@ -93,35 +93,35 @@ let v,x
|
|
|
93
93
|
if(m>g&&(w=1,g=m),l-o>g&&(w=2),0===w){if(n>=h)return e[0]=0,e[1]=0,void(e[2]=1)
|
|
94
94
|
v=c,x=d}else if(1===w){if(r>=a)return e[0]=0,e[1]=0,void(e[2]=1)
|
|
95
95
|
v=u,x=y}else{if(o>=l)return e[0]=0,e[1]=0,void(e[2]=1)
|
|
96
|
-
v=f,x=p}const
|
|
96
|
+
v=f,x=p}const A=v.coords[0]-x.coords[0],b=v.coords[1]-x.coords[1],E=v.coords[2]-x.coords[2]
|
|
97
97
|
let T=0
|
|
98
|
-
for(s=i.next;s!==i;s=s.next){const t=s.coords[0]-x.coords[0],i=s.coords[1]-x.coords[1],n=s.coords[2]-x.coords[2],r=
|
|
99
|
-
a>T&&(T=a,e[0]=r,e[1]=o,e[2]=h)}T>0||(e[0]=e[1]=e[2]=0,Math.abs(
|
|
98
|
+
for(s=i.next;s!==i;s=s.next){const t=s.coords[0]-x.coords[0],i=s.coords[1]-x.coords[1],n=s.coords[2]-x.coords[2],r=b*n-E*i,o=E*t-A*n,h=A*i-b*t,a=r*r+o*o+h*h
|
|
99
|
+
a>T&&(T=a,e[0]=r,e[1]=o,e[2]=h)}T>0||(e[0]=e[1]=e[2]=0,Math.abs(b)>Math.abs(A)?e[Math.abs(E)>Math.abs(b)?2:1]=1:e[Math.abs(E)>Math.abs(A)?2:0]=1)}function G(t,e){let i,s,n,r=t.q,o=t.Y,h=0
|
|
100
100
|
for(i=r.next;i!==r;i=i.next)if(n=i.L,n.p>0)do{h+=(n.o.s-n.h.o.s)*(n.o.i+n.h.o.i),n=n.O}while(n!==i.L)
|
|
101
101
|
if(0>h){for(s=o.next;s!==o;s=s.next)s.i=-s.i
|
|
102
102
|
e[0]=-e[0],e[1]=-e[1],e[2]=-e[2]}}function z(t,e){let i=0
|
|
103
103
|
for(let s=e.q.next;s!==e.q;s=s.next)s._&&(i||(t.H(4),i=1),W(s,t))
|
|
104
104
|
i&&t.tt()}function R(t,e,i,s){0>e.s*(i.i-s.i)+i.s*(s.i-e.i)+s.s*(e.i-i.i)?(t.W(e.data),t.W(s.data),t.W(i.data)):(t.W(e.data),t.W(i.data),t.W(s.data))}function W(t,e){let i=0,s=t.L
|
|
105
|
-
do{
|
|
105
|
+
do{we[i++]=s.o,s=s.O}while(s!==t.L)
|
|
106
106
|
if(3>i)return
|
|
107
|
-
if(3===i)return void R(e,
|
|
108
|
-
|
|
107
|
+
if(3===i)return void R(e,we[0],we[1],we[2]);(t=>{if(t>ge.length){const e=2*t
|
|
108
|
+
ge=new Int8Array(e),me=new Int32Array(e),ve=new Int32Array(e)}})(i)
|
|
109
109
|
let n=0,o=0
|
|
110
|
-
for(let t=1;i>t;t++)r(
|
|
110
|
+
for(let t=1;i>t;t++)r(we[t],we[n])||(n=t),r(we[t],we[o])&&(o=t)
|
|
111
111
|
if(n===o)return
|
|
112
112
|
let h=0
|
|
113
|
-
|
|
113
|
+
me[h]=n,ge[h]=1,h++
|
|
114
114
|
let a=(n+1)%i,l=(n+i-1)%i
|
|
115
115
|
for(;a!==o||l!==o;){let t
|
|
116
|
-
t=a===o?0:l===o?1:!r(
|
|
116
|
+
t=a===o?0:l===o?1:!r(we[a],we[l]),t?(me[h]=a,ge[h]=1,h++,a=(a+1)%i):(me[h]=l,ge[h]=0,h++,l=(l+i-1)%i)}me[h]=o,ge[h]=1,h++
|
|
117
117
|
let c=0
|
|
118
|
-
|
|
119
|
-
for(let t=2;h-1>t;t++)if(
|
|
120
|
-
R(e,
|
|
121
|
-
for(;c>0;){const s=
|
|
122
|
-
if(!(1===
|
|
123
|
-
R(e,s,n,r),i=
|
|
124
|
-
R(e,
|
|
118
|
+
ve[c++]=0,ve[c++]=1
|
|
119
|
+
for(let t=2;h-1>t;t++)if(ge[t]!==ge[ve[c-1]]){for(;c>1;){const i=ve[--c]
|
|
120
|
+
R(e,we[me[t]],we[me[i]],we[me[ve[c-1]]])}--c,ve[c++]=t-1,ve[c++]=t}else{let i=ve[--c]
|
|
121
|
+
for(;c>0;){const s=we[me[t]],n=we[me[i]],r=we[me[ve[c-1]]],o=s.s*(n.i-r.i)+n.s*(r.i-s.i)+r.s*(s.i-n.i)
|
|
122
|
+
if(!(1===ge[t]?0>=o:o>=0))break
|
|
123
|
+
R(e,s,n,r),i=ve[--c]}ve[c++]=i,ve[c++]=t}for(;c>1;){const t=ve[--c]
|
|
124
|
+
R(e,we[me[h-1]],we[me[t]],we[me[ve[c-1]]])}}function j(t,e){let i
|
|
125
125
|
for(let s=t.Z.next;s!==t.Z;s=i)i=s.next,s.h.D._!==s.D._?s.p=s.D._?e:-e:t.delete(s)}function U(t,e){let i=0,s=-1
|
|
126
126
|
for(let n=e.q.u;n!==e.q;n=n.u){if(!n._)continue
|
|
127
127
|
i||(t.H(4),i=1)
|
|
@@ -131,7 +131,54 @@ s!==i&&(s=i,t.K(!!s))}t.W(e.o.data),e=e.O}while(e!==n.L)}i&&t.tt()}function V(t,
|
|
|
131
131
|
t.H(2)
|
|
132
132
|
let e=i.L
|
|
133
133
|
do{t.W(e.o.data),e=e.O}while(e!==i.L)
|
|
134
|
-
t.tt()}}
|
|
134
|
+
t.tt()}}function H(t,e,i,s){const n=t[s],r=i[n]
|
|
135
|
+
for(;s>0;){const n=s-1>>1,o=t[n]
|
|
136
|
+
if(r>=i[o])break
|
|
137
|
+
t[s]=o,e[o]=s,s=n}t[s]=n,e[n]=s}function q(t,e,i,s,n){const r=t[s],o=i[r],h=n>>1
|
|
138
|
+
for(;h>s;){let r=1+(s<<1),h=t[r],a=i[h]
|
|
139
|
+
const l=r+1
|
|
140
|
+
if(n>l){const e=t[l],s=i[e]
|
|
141
|
+
a>s&&(r=l,h=e,a=s)}if(a>=o)break
|
|
142
|
+
t[s]=h,e[h]=s,s=r}t[s]=r,e[r]=s}function Y(t,e,i,s,n){const r=t[i]*(e[s]-e[n])+t[s]*(e[n]-e[i])+t[n]*(e[i]-e[s])
|
|
143
|
+
return 0>r?-r:r}function J(t,e){Pe.push(new Vt(t,e))}function K(t,e,i,s,n,r,o){if(o>ze)return
|
|
144
|
+
const h=.5*(t+i),a=.5*(e+s),l=.5*(i+n),c=.5*(s+r),u=.5*(h+l),f=.5*(a+c),d=n-t,y=r-e
|
|
145
|
+
let p=Math.abs((i-n)*y-(s-r)*d)
|
|
146
|
+
if(p>Ge){if($e*(d*d+y*y)>=p*p){if(0>=Re)return void J(u,f)
|
|
147
|
+
{const o=i-t,h=s-e,a=n-i,l=r-s,c=o*l-h*a,d=o*a+h*l
|
|
148
|
+
if(d>0&&We*d*d>c*c)return void J(u,f)}}}else{let o=d*d+y*y
|
|
149
|
+
if(0===o)p=(i-t)*(i-t)+(s-e)*(s-e)
|
|
150
|
+
else{if(p=((i-t)*d+(s-e)*y)/o,p>0&&1>p)return
|
|
151
|
+
if(p>0)if(1>p){const n=t+p*d,r=e+p*y
|
|
152
|
+
p=(i-n)*(i-n)+(s-r)*(s-r)}else p=(i-n)*(i-n)+(s-r)*(s-r)
|
|
153
|
+
else p=(i-t)*(i-t)+(s-e)*(s-e)}if($e>p)return void J(i,s)}const w=o+1
|
|
154
|
+
K(t,e,h,a,u,f,w),K(u,f,l,c,n,r,w)}function X(t,e,i,s,n,r,o,h,a){if(a>ze)return
|
|
155
|
+
const l=.5*(t+i),c=.5*(e+s),u=.5*(i+n),f=.5*(s+r),d=.5*(n+o),y=.5*(r+h),p=.5*(l+u),w=.5*(c+f),g=.5*(u+d),m=.5*(f+y),v=.5*(p+g),x=.5*(w+m),A=o-t,b=h-e
|
|
156
|
+
let E=Math.abs((i-o)*b-(s-h)*A),T=Math.abs((n-o)*b-(r-h)*A)
|
|
157
|
+
switch((E>Ge?2:0)+(T>Ge?1:0)){case 0:{let a=A*A+b*b
|
|
158
|
+
if(0===a)E=(i-t)*(i-t)+(s-e)*(s-e),T=(n-t)*(n-t)+(r-e)*(r-e)
|
|
159
|
+
else{a=1/a
|
|
160
|
+
let l=i-t,c=s-e
|
|
161
|
+
if(E=a*(l*A+c*b),l=n-t,c=r-e,T=a*(l*A+c*b),E>0&&1>E&&T>0&&1>T)return
|
|
162
|
+
if(E>0)if(1>E){const n=t+E*A,r=e+E*b
|
|
163
|
+
E=(i-n)*(i-n)+(s-r)*(s-r)}else E=(i-o)*(i-o)+(s-h)*(s-h)
|
|
164
|
+
else E=(i-t)*(i-t)+(s-e)*(s-e)
|
|
165
|
+
if(T>0)if(1>T){const i=t+T*A,s=e+T*b
|
|
166
|
+
T=(n-i)*(n-i)+(r-s)*(r-s)}else T=(n-o)*(n-o)+(r-h)*(r-h)
|
|
167
|
+
else T=(n-t)*(n-t)+(r-e)*(r-e)}if(E>T){if($e>E)return void J(i,s)}else if($e>T)return void J(n,r)
|
|
168
|
+
break}case 1:if($e*(A*A+b*b)>=T*T){if(0>=Re)return void J(u,f)
|
|
169
|
+
{const t=n-i,e=r-s,a=o-n,l=h-r,c=t*l-e*a,u=t*a+e*l
|
|
170
|
+
if(u>0&&We*u*u>c*c)return J(i,s),void J(n,r)
|
|
171
|
+
if(je>0&&(0>=u||c*c>Ue*u*u))return void J(n,r)}}break
|
|
172
|
+
case 2:if($e*(A*A+b*b)>=E*E){if(0>=Re)return void J(u,f)
|
|
173
|
+
{const o=i-t,h=s-e,a=n-i,l=r-s,c=o*l-h*a,u=o*a+h*l
|
|
174
|
+
if(u>0&&We*u*u>c*c)return J(i,s),void J(n,r)
|
|
175
|
+
if(je>0&&(0>=u||c*c>Ue*u*u))return void J(i,s)}}break
|
|
176
|
+
case 3:if($e*(A*A+b*b)>=(E+T)*(E+T)){if(0>=Re)return void J(u,f)
|
|
177
|
+
{const a=i-t,l=s-e,c=n-i,d=r-s,y=a*d-l*c,p=a*c+l*d,w=o-n,g=h-r,m=c*g-d*w,v=c*w+d*g
|
|
178
|
+
if(p>0&&v>0){const t=0>y?-y:y,e=0>m?-m:m,i=t*v+e*p,s=p*v-t*e
|
|
179
|
+
if(s>0&&We*s*s>i*i)return void J(u,f)}if(je>0){if(0>=p||y*y>Ue*p*p)return void J(i,s)
|
|
180
|
+
if(0>=v||m*m>Ue*v*v)return void J(n,r)}}}}const I=a+1
|
|
181
|
+
X(t,e,l,c,p,w,v,x,I),X(v,x,g,m,d,y,o,h,I)}async function Q(t){try{const e=await fetch(t)
|
|
135
182
|
if(!e.ok)throw Error("HTTP "+e.status)
|
|
136
183
|
return await e.arrayBuffer()}catch(e){const i=globalThis.require
|
|
137
184
|
if("function"!=typeof i)throw Error(`Failed to fetch ${t}: ${e}`)
|
|
@@ -139,49 +186,49 @@ try{const e=i("fs"),s=i("path")
|
|
|
139
186
|
let n=t
|
|
140
187
|
if("undefined"!=typeof window&&"file:"===window.location?.protocol){const e=s.et(window.location.pathname)
|
|
141
188
|
n=s.join(e,t)}const r=e.it(n)
|
|
142
|
-
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})`)}}}function
|
|
189
|
+
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})`)}}}function Z(t){return t&&t.st&&{}.hasOwnProperty.call(t,"default")?t.default:t}function tt(t){if(t.st)return t
|
|
143
190
|
var e=t.default
|
|
144
191
|
if("function"==typeof e){var i=function t(){return this instanceof t?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)}
|
|
145
192
|
i.prototype=e.prototype}else i={}
|
|
146
193
|
return Object.defineProperty(i,"st",{value:!0}),Object.keys(t).forEach(e=>{var s=Object.getOwnPropertyDescriptor(t,e)
|
|
147
|
-
Object.defineProperty(i,e,s.get?s:{enumerable:!0,get(){return t[e]}})}),i}var
|
|
148
|
-
const
|
|
149
|
-
new class{constructor(){this.rt=[],this.ot=new Map}start(t,e){if(!
|
|
194
|
+
Object.defineProperty(i,e,s.get?s:{enumerable:!0,get(){return t[e]}})}),i}var et="undefined"!=typeof document?document.currentScript:null
|
|
195
|
+
const it=!("undefined"==typeof window||!window.THREE_TEXT_LOG)||"undefined"!=typeof globalThis&&"true"===globalThis.process?.nt?.THREE_TEXT_LOG,st=new class{warn(t,...e){}error(t,...e){console.error(t,...e)}log(t,...e){}}
|
|
196
|
+
new class{constructor(){this.rt=[],this.ot=new Map}start(t,e){if(!it)return
|
|
150
197
|
const i=performance.now()
|
|
151
|
-
this.ot.set(`${t}_${i}`,i),this.rt.push({name:t,startTime:i,metadata:e})}end(t){if(!
|
|
198
|
+
this.ot.set(`${t}_${i}`,i),this.rt.push({name:t,startTime:i,metadata:e})}end(t){if(!it)return null
|
|
152
199
|
const e=performance.now()
|
|
153
200
|
let i,s
|
|
154
201
|
for(const[e,n]of Array.from(this.ot.entries()).reverse())if(e.startsWith(t+"_")){i=e,s=n
|
|
155
|
-
break}if(void 0===s||!i)return
|
|
202
|
+
break}if(void 0===s||!i)return st.warn(`Performance timer "${t}" was not started`),null
|
|
156
203
|
const n=e-s
|
|
157
204
|
this.ot.delete(i)
|
|
158
205
|
for(let i=this.rt.length-1;i>=0;i--){const r=this.rt[i]
|
|
159
206
|
if(r.name===t&&r.startTime===s&&!r.endTime){r.endTime=e,r.duration=n
|
|
160
|
-
break}}return n.toFixed(2),n}ht(){if(!
|
|
207
|
+
break}}return n.toFixed(2),n}ht(){if(!it)return{}
|
|
161
208
|
const t={}
|
|
162
209
|
for(const e of this.rt){if(!e.duration)continue
|
|
163
210
|
const i=t[e.name]
|
|
164
|
-
i?(i.count++,i.lt+=e.duration,i.ct=i.lt/i.count,i.ut=e.duration):t[e.name]={count:1,ct:e.duration,lt:e.duration,ut:e.duration}}return t}ft(){if(!
|
|
211
|
+
i?(i.count++,i.lt+=e.duration,i.ct=i.lt/i.count,i.ut=e.duration):t[e.name]={count:1,ct:e.duration,lt:e.duration,ut:e.duration}}return t}ft(){if(!it)return
|
|
165
212
|
const t=this.ht()
|
|
166
|
-
console.table(t),Object.keys(t).sort().join(", ")}dt(){if(!
|
|
213
|
+
console.table(t),Object.keys(t).sort().join(", ")}dt(){if(!it)return
|
|
167
214
|
const t=this.ht()
|
|
168
|
-
Object.entries(t).forEach(([t,e])=>{e.ct.toFixed(2)})}clear(){
|
|
215
|
+
Object.entries(t).forEach(([t,e])=>{e.ct.toFixed(2)})}clear(){it&&(this.rt.length=0,this.ot.clear())}time(t,e,i){if(!it)return e()
|
|
169
216
|
this.start(t,i)
|
|
170
|
-
try{return e()}finally{this.end(t)}}async yt(t,e,i){if(!
|
|
217
|
+
try{return e()}finally{this.end(t)}}async yt(t,e,i){if(!it)return e()
|
|
171
218
|
this.start(t,i)
|
|
172
219
|
try{return await e()}finally{this.end(t)}}}
|
|
173
|
-
const
|
|
174
|
-
var
|
|
175
|
-
class
|
|
220
|
+
const nt=800,rt=100,ot=0,ht=1/3
|
|
221
|
+
var at,lt;(t=>{t[t.BOX=0]="BOX",t[t.GLUE=1]="GLUE",t[t.PENALTY=2]="PENALTY",t[t.DISCRETIONARY=3]="DISCRETIONARY"})(at||(at={})),(t=>{t[t.VERY_LOOSE=0]="VERY_LOOSE",t[t.LOOSE=1]="LOOSE",t[t.DECENT=2]="DECENT",t[t.TIGHT=3]="TIGHT"})(lt||(lt={}))
|
|
222
|
+
class ct{constructor(){this.wt=new Map,this.gt=[]}getKey(t,e){return t<<2|e}vt(t){const e=this.getKey(t.position,t.xt),i=this.wt.get(e)
|
|
176
223
|
return i?i.bt>t.bt&&(i.bt=t.bt,i._t=t._t,i.kt=t.kt,i.line=t.line,i.zt=t.zt,i.jt=t.jt,i.qt=t.qt,!0):(t.active=!0,t.te=this.gt.length,this.gt.push(t),this.wt.set(e,t),!0)}ee(t){if(!t.active)return
|
|
177
224
|
t.active=!1
|
|
178
225
|
const e=t.te,i=this.gt.length-1
|
|
179
226
|
if(e!==i){const t=this.gt[i]
|
|
180
|
-
this.gt[e]=t,t.te=e}this.gt.pop()}ie(){return this.gt}size(){return this.gt.length}}const
|
|
181
|
-
class
|
|
227
|
+
this.gt[e]=t,t.te=e}this.gt.pop()}ie(){return this.gt}size(){return this.gt.length}}const ut=50,ft=50,dt=1e4,yt=5e3,pt=10,wt=1e4,gt=2,mt=3,vt=-1e4
|
|
228
|
+
class xt{static se(t,e){if(0===t)return 0
|
|
182
229
|
if(0>=e)return 10001
|
|
183
230
|
const i=Math.abs(t/e)
|
|
184
|
-
return i>10?10001:Math.min(Math.round(100*i**3),1e4)}static ne(t){return-.5>t?
|
|
231
|
+
return i>10?10001:Math.min(Math.round(100*i**3),1e4)}static ne(t){return-.5>t?lt.TIGHT:.5>t?lt.DECENT:1>t?lt.LOOSE:lt.VERY_LOOSE}static re(t,e="en-us",i,s=gt,n=mt){let r
|
|
185
232
|
if(!i||!i[e])return[]
|
|
186
233
|
if(r=i[e],!r)return[]
|
|
187
234
|
const o=`.${t.toLowerCase()}.`,h=Array(o.length).fill(0)
|
|
@@ -191,8 +238,8 @@ if(!e.children||!e.children[s])break
|
|
|
191
238
|
if(e=e.children[s],e.oe)for(let i=0;e.oe.length>i;i++){const s=t+i
|
|
192
239
|
h.length>s&&(h[s]=Math.max(h[s],e.oe[i]))}}}const a=[]
|
|
193
240
|
for(let t=2;o.length-2>t;t++)h[t]%2==1&&a.push(t-1)
|
|
194
|
-
return a.filter(e=>e>=s&&t.length-e>=n)}static he(t,e,i,s=!1,n="en-us",r,o=
|
|
195
|
-
return c.push(...this.ae(t,e,i,s,n,r,o,h,a,l)),c.push({type:
|
|
241
|
+
return a.filter(e=>e>=s&&t.length-e>=n)}static he(t,e,i,s=!1,n="en-us",r,o=gt,h=mt,a,l){const c=[]
|
|
242
|
+
return c.push(...this.ae(t,e,i,s,n,r,o,h,a,l)),c.push({type:at.GLUE,width:0,stretch:1e7,le:0,text:"",ce:t.length}),c.push({type:at.PENALTY,width:0,ue:vt,text:"",ce:t.length}),c}static fe(t){const e=t.codePointAt(0)
|
|
196
243
|
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 de(t){const e=t.charCodeAt(0)
|
|
197
244
|
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 ye(t){const e=t.charCodeAt(0)
|
|
198
245
|
return 65288===e||12304===e||65371===e||12300===e||12302===e||12296===e||12298===e||12308===e||12310===e||12312===e||12314===e}static pe(t){return this.de(t)||this.ye(t)}static we(t,e,i,s,n=0,r){const o=[],h=Array.from(t),a=i?i(t):null
|
|
@@ -201,11 +248,11 @@ if(r)l=r.width,c=r.stretch,u=r.le
|
|
|
201
248
|
else{const t=e("字")
|
|
202
249
|
l=0,c=.04*t,u=.04*t}for(let t=0;h.length>t;t++){const i=h[t],s=h.length-1>t?h[t+1]:null
|
|
203
250
|
if(/\s/.test(i)){const s=a?a[t]??e(i):e(i)
|
|
204
|
-
o.push({type:
|
|
205
|
-
continue}if(o.push({type:
|
|
251
|
+
o.push({type:at.GLUE,width:s,stretch:.5*s,le:s*ht,text:i,ce:f}),f+=i.length
|
|
252
|
+
continue}if(o.push({type:at.BOX,width:a?a[t]??e(i):e(i),text:i,ce:f}),f+=i.length,s&&!/\s/.test(s)){let t=!0
|
|
206
253
|
this.de(s)&&(t=!1),this.ye(i)&&(t=!1)
|
|
207
254
|
const e=this.pe(i)&&this.pe(s)
|
|
208
|
-
t&&!e&&o.push({type:
|
|
255
|
+
t&&!e&&o.push({type:at.GLUE,width:l,stretch:c,le:u,text:"",ce:f})}}return o}static ae(t,e,i,s,n,r,o,h,a,l){const c=[],u=Array.from(t)
|
|
209
256
|
let f,d="",y=0,p=null,w=0
|
|
210
257
|
const g=()=>{0!==d.length&&("cjk"===p?c.push(...this.we(d,e,i,a,y,(()=>{if(!f){const t=e("字")
|
|
211
258
|
f={width:0,stretch:.04*t,le:.04*t}}return f})())):c.push(...this.ge(d,y,e,s,n,r,o,h,a,l)),d="",p=null)}
|
|
@@ -214,92 +261,92 @@ null!==p&&p!==i&&(g(),y=w),null===p&&(p=i,y=w),d+=e,w+=e.length}return g(),c}sta
|
|
|
214
261
|
let f=0
|
|
215
262
|
for(const t of u){const u=e+f
|
|
216
263
|
if(/\s+/.test(t)){const e=i(t)
|
|
217
|
-
c.push({type:
|
|
218
|
-
for(let t=0;e.length>t;t++)c.push({type:
|
|
264
|
+
c.push({type:at.GLUE,width:e,stretch:.5*e,le:e*ht,text:t,ce:u}),f+=t.length}else{if(l&&t.includes("-")&&!t.includes("")&&i(t)>l){const e=Array.from(t)
|
|
265
|
+
for(let t=0;e.length>t;t++)c.push({type:at.BOX,width:i(e[t]),text:e[t],ce:u+t}),e.length-1>t&&c.push({type:at.PENALTY,width:0,ue:5e3,ce:u+t+1})
|
|
219
266
|
f+=t.length
|
|
220
267
|
continue}const e=t.split(/(-)/)
|
|
221
268
|
let d=u
|
|
222
|
-
for(const t of e)if(t){if("-"===t)c.push({type:
|
|
269
|
+
for(const t of e)if(t){if("-"===t)c.push({type:at.DISCRETIONARY,width:i("-"),me:"-",ve:"",xe:"-",Ae:i("-"),ue:a?.be??ft,Ee:!0,text:"-",ce:d}),d+=1
|
|
223
270
|
else if(t.includes("")){const e=t.split("")
|
|
224
271
|
let s=0
|
|
225
272
|
for(let t=0;e.length>t;t++){const n=e[t]
|
|
226
|
-
n.length>0&&(c.push({type:
|
|
273
|
+
n.length>0&&(c.push({type:at.BOX,width:i(n),text:n,ce:d+s}),s+=n.length),e.length-1>t&&(c.push({type:at.DISCRETIONARY,width:0,me:"-",ve:"",xe:"",Ae:i("-"),ue:a?.Te??ut,Ee:!0,text:"",ce:d+s}),s+=1)}}else if(s&&t.length>=o+h&&/^\p{L}+$/u.test(t)){const e=this.re(t,n,r,o,h)
|
|
227
274
|
if(e.length>0){let s=0
|
|
228
275
|
for(const n of e){const e=t.substring(s,n)
|
|
229
|
-
c.push({type:
|
|
276
|
+
c.push({type:at.BOX,width:i(e),text:e,ce:d+s}),c.push({type:at.DISCRETIONARY,width:0,me:"-",ve:"",xe:"",Ae:i("-"),ue:a?.Te??ut,Ee:!0,text:"",ce:d+n}),s=n}c.push({type:at.BOX,width:i(t.substring(s)),text:t.substring(s),ce:d+s})}else{const e=i(t)
|
|
230
277
|
if(l&&e>l){const e=Array.from(t)
|
|
231
|
-
for(let t=0;e.length>t;t++)c.push({type:
|
|
278
|
+
for(let t=0;e.length>t;t++)c.push({type:at.BOX,width:i(e[t]),text:e[t],ce:d+t}),e.length-1>t&&c.push({type:at.PENALTY,width:0,ue:5e3,ce:d+t+1})}else c.push({type:at.BOX,width:e,text:t,ce:d})}}else{const e=i(t)
|
|
232
279
|
if(l&&e>l){const e=Array.from(t)
|
|
233
|
-
for(let t=0;e.length>t;t++)c.push({type:
|
|
234
|
-
r.vt({position:0,line:0,xt:
|
|
280
|
+
for(let t=0;e.length>t;t++)c.push({type:at.BOX,width:i(e[t]),text:e[t],ce:d+t}),e.length-1>t&&c.push({type:at.PENALTY,width:0,ue:5e3,ce:d+t+1})}else c.push({type:at.BOX,width:e,text:t,ce:d})}d+=t.length}f+=t.length}}return c}static lineBreak(t,e,i,s,n){const r=new ct
|
|
281
|
+
r.vt({position:0,line:0,xt:lt.DECENT,bt:0,_t:null,kt:!1,active:!0,te:0,zt:0,jt:0,qt:0})
|
|
235
282
|
let o=0,h=0,a=0
|
|
236
283
|
for(let l=0;t.length>l;l++){const c=t[l]
|
|
237
|
-
if(!(c.type===
|
|
238
|
-
continue}let u=0,f=!1;(c.type===
|
|
284
|
+
if(!(c.type===at.PENALTY&&1e4>c.ue||c.type===at.DISCRETIONARY||c.type===at.GLUE&&l>0&&t[l-1].type===at.BOX)){c.type===at.BOX?o+=c.width:c.type===at.GLUE?(o+=c.width,h+=c.stretch,a+=c.le):c.type===at.DISCRETIONARY&&(o+=c.width)
|
|
285
|
+
continue}let u=0,f=!1;(c.type===at.PENALTY||c.type===at.DISCRETIONARY)&&(u=c.ue,f=c.Ee||!1)
|
|
239
286
|
let d=0
|
|
240
|
-
c.type===
|
|
287
|
+
c.type===at.DISCRETIONARY&&(d=c.Ae)
|
|
241
288
|
const y=[null,null,null,null],p=[1/0,1/0,1/0,1/0],w=[],g=r.ie()
|
|
242
289
|
for(let t=0;g.length>t;t++){const r=g[t],c=h-r.jt,m=a-r.qt,v=e-(o-r.zt+d)
|
|
243
290
|
let x
|
|
244
291
|
if(v>0){const t=c+s
|
|
245
292
|
x=t>0?v/t:1/0}else x=0>v?m>0?v/m:-1/0:0
|
|
246
|
-
const
|
|
293
|
+
const A=this.se(v,v>0?c+s:m)
|
|
247
294
|
if(-1>x){w.push(r)
|
|
248
|
-
continue}if(u!==
|
|
249
|
-
let
|
|
250
|
-
1e4>Math.abs(
|
|
295
|
+
continue}if(u!==vt&&A>i)continue
|
|
296
|
+
let b=n.Ie+A
|
|
297
|
+
1e4>Math.abs(b)?b*=b:b=1e8,u>0?b+=u*u:u>vt&&(b-=u*u),f&&r.kt&&(b+=n.Se)
|
|
251
298
|
const E=this.ne(x)
|
|
252
|
-
Math.abs(E-r.xt)>1&&(
|
|
253
|
-
const T=r.bt+
|
|
299
|
+
Math.abs(E-r.xt)>1&&(b+=n.Fe)
|
|
300
|
+
const T=r.bt+b
|
|
254
301
|
p[E]>T&&(p[E]=T,y[E]={position:l,line:r.line+1,xt:E,bt:T,_t:r,kt:f,active:!0,te:-1,zt:o,jt:h,qt:a})}for(const t of w)r.ee(t)
|
|
255
302
|
for(let t=0;4>t;t++)y[t]&&r.vt(y[t])
|
|
256
|
-
if(0===r.size()&&u!==
|
|
257
|
-
c.type===
|
|
303
|
+
if(0===r.size()&&u!==vt)return null
|
|
304
|
+
c.type===at.BOX?o+=c.width:c.type===at.GLUE?(o+=c.width,h+=c.stretch,a+=c.le):c.type===at.DISCRETIONARY&&(o+=c.width)}let l=null,c=1/0
|
|
258
305
|
for(const t of r.ie())c>t.bt&&(c=t.bt,l=t)
|
|
259
|
-
return l}static
|
|
260
|
-
const{text:e,width:i,align:s="left",direction:n="ltr",
|
|
306
|
+
return l}static Me(t){if(!t.text||0===t.text.length)return[]
|
|
307
|
+
const{text:e,width:i,align:s="left",direction:n="ltr",_e:r=!1,language:o="en-us",Oe:h=!0,measureText:a,Ce:l,ke:c,Be:u,letterSpacing:f=0,Le:d=nt,De:y=rt,Ne:p=ot,Pe:w,$e:g=gt,Ge:m=mt,ze:v=pt,Re:x=wt,We:A=ut,je:b=ft,Ue:E=dt,Ve:T=yt}=t
|
|
261
308
|
if(h&&e.includes("\n")){const i=e.split("\n"),s=[]
|
|
262
309
|
let n=0
|
|
263
310
|
for(const e of i){if(0===e.length)s.push({text:"",He:n,qe:n,Ye:0,Je:!0,naturalWidth:0,Ke:!1})
|
|
264
|
-
else{const i=this.
|
|
265
|
-
i.forEach(t=>{t.He+=n,t.qe+=n}),s.push(...i)}n+=e.length+1}return s}let
|
|
266
|
-
!
|
|
267
|
-
let
|
|
268
|
-
void 0!==w&&i&&(
|
|
269
|
-
const
|
|
311
|
+
else{const i=this.Me({...t,text:e,Oe:!1})
|
|
312
|
+
i.forEach(t=>{t.He+=n,t.qe+=n}),s.push(...i)}n+=e.length+1}return s}let I=r
|
|
313
|
+
!I||c&&c[o]||(st.warn(`Hyphenation patterns for ${o} not available`),I=!1)
|
|
314
|
+
let S=p
|
|
315
|
+
void 0!==w&&i&&(S=i*w)
|
|
316
|
+
const F={Ie:v,Fe:x,Se:E,Xe:T,Te:A,be:b,Qe:s,Be:u,Ze:u?f*u:0}
|
|
270
317
|
if(!i||i===1/0){const t=a(e)
|
|
271
|
-
return[{text:e,He:0,qe:e.length-1,Ye:0,Je:!0,naturalWidth:t,Ke:!1}]}let
|
|
272
|
-
if(!
|
|
273
|
-
for(let e=0;t>e&&!
|
|
274
|
-
|
|
275
|
-
let r=
|
|
318
|
+
return[{text:e,He:0,qe:e.length-1,Ye:0,Je:!0,naturalWidth:t,Ke:!1}]}let M=this.he(e,a,l,!1,o,c,g,m,F,i),_=this.lineBreak(M,i,y,0,F)
|
|
319
|
+
if(!_&&I&&(M=this.he(e,a,l,!0,o,c,g,m,F,i),_=this.lineBreak(M,i,d,0,F)),!_){const t=5
|
|
320
|
+
for(let e=0;t>e&&!_;e++){const t=S+e*i*.1
|
|
321
|
+
_=this.lineBreak(M,i,d,t,F),_||(_=this.lineBreak(M,i,1e4,t,F))}}if(_){const t=[]
|
|
322
|
+
let r=_
|
|
276
323
|
for(;r&&r.position>0;)t.unshift(r.position),r=r._t
|
|
277
|
-
return this.ti(e,
|
|
324
|
+
return this.ti(e,M,t,i,s,n,F)}return[{text:e,He:0,qe:e.length-1,Ye:0,ei:0,Je:!0,naturalWidth:a(e),Ke:!1}]}static ti(t,e,i,s,n,r,o){if(0===i.length)return[{text:t,He:0,qe:t.length-1,Ye:0}]
|
|
278
325
|
const h=[]
|
|
279
326
|
let a=0
|
|
280
327
|
for(let t=0;i.length>t;t++){const l=i[t],c=!(e.length-1>i[i.length-1]+1)&&t===i.length-1,u=[]
|
|
281
328
|
let f=-1,d=-1,y=0,p=0,w=0
|
|
282
329
|
for(let t=a;l>t;t++){const i=e[t]
|
|
283
|
-
if((i.type!==
|
|
330
|
+
if((i.type!==at.PENALTY||i.text)&&(i.type!==at.DISCRETIONARY||i.xe)){if(void 0!==i.ce){(-1===f||f>i.ce)&&(f=i.ce)
|
|
284
331
|
const t=i.ce+(i.text?i.text.length:0)-1
|
|
285
|
-
t>d&&(d=t)}i.text?u.push(i.text):i.type===
|
|
332
|
+
t>d&&(d=t)}i.text?u.push(i.text):i.type===at.DISCRETIONARY&&i.xe&&u.push(i.xe),y+=i.width,i.type===at.GLUE&&(p+=i.stretch,w+=i.le)}}const g=e[l]
|
|
286
333
|
let m=!1
|
|
287
|
-
if(e.length>l)if(g.type===
|
|
288
|
-
else if(g.type===
|
|
289
|
-
t.me&&(u.push(t.me),y+=t.
|
|
334
|
+
if(e.length>l)if(g.type===at.PENALTY&&g.Ee)u.push("-"),y+=g.width,m=!0,void 0!==g.ce&&(d=g.ce-1)
|
|
335
|
+
else if(g.type===at.DISCRETIONARY){const t=g
|
|
336
|
+
t.me&&(u.push(t.me),y+=t.Ae,m=t.Ee||!1,void 0!==g.ce&&(d=g.ce-1))}const v=u.join("")
|
|
290
337
|
o?.Ze&&0!==y&&(y-=o.Ze)
|
|
291
|
-
let x=0,
|
|
292
|
-
if("justify"===n&&c&&(
|
|
293
|
-
else if("right"===
|
|
294
|
-
else if("justify"===
|
|
295
|
-
t>0&&p>0?
|
|
338
|
+
let x=0,A=0,b=n
|
|
339
|
+
if("justify"===n&&c&&(b="rtl"===r?"right":"left"),"center"===b)x=(s-y)/2
|
|
340
|
+
else if("right"===b)x=s-y
|
|
341
|
+
else if("justify"===b&&!c){const t=s-y
|
|
342
|
+
t>0&&p>0?A=t/p:0>t&&w>0&&(A=t/w)}h.push({text:v,He:f,qe:d,Ye:x,ei:A,Je:!1,naturalWidth:y,Ke:m}),a=l+1}if(e.length-1>a){const t=[]
|
|
296
343
|
let i=-1,l=-1,c=0
|
|
297
344
|
for(let s=a;e.length-1>s;s++){const n=e[s]
|
|
298
|
-
n.type!==
|
|
345
|
+
n.type!==at.PENALTY&&(void 0!==n.ce&&((-1===i||i>n.ce)&&(i=n.ce),n.ce>l&&(l=n.ce)),n.text&&t.push(n.text),c+=n.width)}o?.Ze&&0!==c&&(c-=o.Ze)
|
|
299
346
|
let u=0,f=n
|
|
300
347
|
"justify"===n&&(f="rtl"===r?"right":"left"),"center"===f?u=(s-c)/2:"right"===f&&(u=s-c),h.push({text:t.join(""),He:i,qe:l,Ye:u,ei:0,Je:!0,naturalWidth:c,Ke:!1}),h.length>1&&(h[h.length-2].Je=!1),h[h.length-1].Je=!0}else h.length>0&&(h[h.length-1].Je=!0)
|
|
301
|
-
return h}}const
|
|
302
|
-
class
|
|
348
|
+
return h}}const At=new WeakMap
|
|
349
|
+
class bt{static Ce(e,i,s=0){const n=Array.from(i)
|
|
303
350
|
if(0===n.length)return[]
|
|
304
351
|
const r=new Map
|
|
305
352
|
let o=0
|
|
@@ -319,65 +366,65 @@ const r=t(e.ni)
|
|
|
319
366
|
e.hb.shape(e.font,n,r)
|
|
320
367
|
const o=n.json(e.font),h=s*e.upem
|
|
321
368
|
let a=0
|
|
322
|
-
return o.forEach(t=>{a+=t.ax,0!==h&&(a+=h)}),n.destroy(),a}}class
|
|
323
|
-
let
|
|
324
|
-
if(i)
|
|
369
|
+
return o.forEach(t=>{a+=t.ax,0!==h&&(a+=h)}),n.destroy(),a}}class Et{constructor(t){this.oi=t}hi(t){const{text:e,width:i,align:s,direction:n,_e:r,language:o,Oe:h,Le:a,De:l,Ne:c,Pe:u,ke:f,$e:d,Ge:y,ze:p,Re:w,We:g,je:m,Ue:v,letterSpacing:x}=t
|
|
370
|
+
let A
|
|
371
|
+
if(i)A=xt.Me({text:e,width:i,align:s,direction:n,_e:r,language:o,Oe:h,Le:a,De:l,Ne:c,Pe:u,ke:f,$e:d,Ge:y,ze:p,Re:w,We:g,je:m,Ue:v,Be:this.oi.upem,letterSpacing:x,measureText:t=>bt.measureTextWidth(this.oi,t,x),Ce:t=>bt.Ce(this.oi,t,x)})
|
|
325
372
|
else{const t=e.split("\n")
|
|
326
|
-
|
|
373
|
+
A=[]
|
|
327
374
|
let i=0
|
|
328
|
-
for(const e of t)
|
|
375
|
+
for(const e of t)A.push({text:e,He:i,qe:0===e.length?i:i+e.length-1,Ye:0}),i+=e.length+1}return{lines:A}}ai(t,e){const{offset:i,li:s}=this.ci(e)
|
|
329
376
|
if(0!==i)for(let e=0;t.length>e;e+=3)t[e]+=i
|
|
330
377
|
return{offset:i,li:s}}ci(t){const{width:e,align:i,planeBounds:s}=t
|
|
331
378
|
let n=0
|
|
332
379
|
const r={min:{...s.min},max:{...s.max}}
|
|
333
|
-
return!e||"center"!==i&&"right"!==i||(n="center"===i?(e-(s.max.x-s.min.x))/2-s.min.x:e-s.max.x),0!==n&&(r.min.x+=n,r.max.x+=n),{offset:n,li:r}}}const
|
|
334
|
-
class
|
|
380
|
+
return!e||"center"!==i&&"right"!==i||(n="center"===i?(e-(s.max.x-s.min.x))/2-s.min.x:e-s.max.x),0!==n&&(r.min.x+=n,r.max.x+=n),{offset:n,li:r}}}const Tt=65536,It=1330926671,St=2001684038,Ft=2001684018,Mt=1751474532,_t=1751672161,Ot=1330851634,Ct=1719034226,kt=1398030676,Bt=1851878757,Lt=1128678944,Dt=1128678962,Nt=1196643650,Pt=1196445523,$t=new TextDecoder("utf-16be")
|
|
381
|
+
class Gt{static ui(t){if(!t||12>t.byteLength)throw Error("Invalid font buffer: too small to be a valid font file")
|
|
335
382
|
const i=new DataView(t),s=i.getUint32(0)
|
|
336
|
-
if(![
|
|
337
|
-
const n=e(i),r=n.has(
|
|
383
|
+
if(![Tt,It].includes(s))throw Error("Invalid font format. Expected TTF/OTF/WOFF/WOFF2, got signature: 0x"+s.toString(16))
|
|
384
|
+
const n=e(i),r=n.has(Lt)||n.has(Dt),o=n.get(Mt)?.offset??0,h=n.get(_t)?.offset??0,a=n.get(Ot)?.offset??0,l=n.get(Ct)?.offset??0,c=n.get(kt)?.offset??0,u=n.get(Bt)?.offset??0,f=o?i.getUint16(o+18):1e3
|
|
338
385
|
let d=null
|
|
339
386
|
h&&(d={fi:i.getInt16(h+4),di:i.getInt16(h+6),yi:i.getInt16(h+8)})
|
|
340
387
|
let y=null
|
|
341
388
|
a&&(y={pi:i.getInt16(a+68),wi:i.getInt16(a+70),gi:i.getInt16(a+72),mi:i.getUint16(a+74),xi:i.getUint16(a+76)})
|
|
342
389
|
let p=null
|
|
343
|
-
return l&&c&&u&&(p=this.
|
|
344
|
-
try{if(n){const t=this.
|
|
345
|
-
t.features.forEach(t=>h.add(t)),Object.assign(a,t.names)}if(r){const t=this.
|
|
390
|
+
return l&&c&&u&&(p=this.Ai(i,c,u)),{bi:r,Be:f,Ei:d?.fi||null,Ti:d?.di||null,Ii:d?.yi||null,pi:y?.pi||null,wi:y?.wi||null,gi:y?.gi||null,mi:y?.mi||null,xi:y?.xi||null,Si:p}}static Fi(t){const i=new DataView(t),s=e(i),n=s.get(Nt)?.offset??0,r=s.get(Pt)?.offset??0,o=s.get(Bt)?.offset??0,h=new Set,a={}
|
|
391
|
+
try{if(n){const t=this.Mi(i,n,o)
|
|
392
|
+
t.features.forEach(t=>h.add(t)),Object.assign(a,t.names)}if(r){const t=this.Mi(i,r,o)
|
|
346
393
|
t.features.forEach(t=>h.add(t)),Object.assign(a,t.names)}}catch(t){return}const l=Array.from(h).sort()
|
|
347
|
-
if(0!==l.length)return{tags:l,names:Object.keys(a).length>0?a:{}}}static
|
|
394
|
+
if(0!==l.length)return{tags:l,names:Object.keys(a).length>0?a:{}}}static Mi(t,e,i){const s=e+t.getUint16(e+6),n=t.getUint16(s),r=[],o={}
|
|
348
395
|
for(let e=0;n>e;e++){const n=s+2+6*e,h=String.fromCharCode(t.getUint8(n),t.getUint8(n+1),t.getUint8(n+2),t.getUint8(n+3))
|
|
349
396
|
if(r.push(h),/^(ss\d{2}|cv\d{2})$/.test(h)&&i){const e=s+t.getUint16(n+4),r=t.getUint16(e)
|
|
350
397
|
if(0!==r){const s=e+r
|
|
351
|
-
if(0===t.getUint16(s)){const e=t.getUint16(s+2),n=this.
|
|
352
|
-
n&&(o[h]=n)}}}}return{features:r,names:o}}static
|
|
398
|
+
if(0===t.getUint16(s)){const e=t.getUint16(s+2),n=this._i(t,i,e)
|
|
399
|
+
n&&(o[h]=n)}}}}return{features:r,names:o}}static Ai(t,e,i){try{if(1>t.getUint16(e))return null
|
|
353
400
|
const s=t.getUint16(e+4),n=t.getUint16(e+6),r=t.getUint32(e+8),o={}
|
|
354
|
-
for(let h=0;n>h;h++){const n=e+r+h*s,a=String.fromCharCode(t.getUint8(n),t.getUint8(n+1),t.getUint8(n+2),t.getUint8(n+3)),l=t.getUint16(n+4),c=this.
|
|
355
|
-
c&&(o[a]=c)}return Object.keys(o).length>0?o:null}catch(t){return null}}static
|
|
401
|
+
for(let h=0;n>h;h++){const n=e+r+h*s,a=String.fromCharCode(t.getUint8(n),t.getUint8(n+1),t.getUint8(n+2),t.getUint8(n+3)),l=t.getUint16(n+4),c=this._i(t,i,l)
|
|
402
|
+
c&&(o[a]=c)}return Object.keys(o).length>0?o:null}catch(t){return null}}static _i(t,e,i){try{const s=t.getUint16(e+2),n=t.getUint16(e+4)
|
|
356
403
|
for(let r=0;s>r;r++){const s=e+6+12*r,o=t.getUint16(s),h=t.getUint16(s+2),a=t.getUint16(s+4),l=t.getUint16(s+6),c=t.getUint16(s+8),u=t.getUint16(s+10)
|
|
357
404
|
if(l!==i)continue
|
|
358
405
|
if(0!==o&&(3!==o||1033!==a))continue
|
|
359
406
|
const f=new Uint8Array(t.buffer,e+n+u,c)
|
|
360
407
|
if(0===o||3===o&&1===h){let t=""
|
|
361
408
|
for(let e=0;f.length>e;e+=2)t+=String.fromCharCode(f[e]<<8|f[e+1])
|
|
362
|
-
return t}return new TextDecoder("ascii").decode(f)}return null}catch(t){return null}}static
|
|
409
|
+
return t}return new TextDecoder("ascii").decode(f)}return null}catch(t){return null}}static Oi(t){if(!t||12>t.byteLength)throw Error("Invalid font buffer: too small to be a valid font file")
|
|
363
410
|
const i=new DataView(t),s=i.getUint32(0)
|
|
364
|
-
if(![
|
|
365
|
-
const n=e(i),r=n.get(
|
|
411
|
+
if(![Tt,It].includes(s))throw Error("Invalid font format. Expected TTF/OTF/WOFF/WOFF2, got signature: 0x"+s.toString(16))
|
|
412
|
+
const n=e(i),r=n.get(Bt)?.offset??0,o=r?this.Ci(i,r):null
|
|
366
413
|
return{rt:this.ki(i,n,o),features:this.Bi(i,n,o)}}static Ci(t,e){const i=new Map,s=t.getUint16(e+2),n=t.getUint16(e+4)
|
|
367
|
-
for(let r=0;s>r;r++){const s=e+6+12*r,o=t.getUint16(s),h=t.getUint16(s+2),a=t.getUint16(s+4),l=t.getUint16(s+6),c=t.getUint16(s+8),u=t.getUint16(s+10);(0===o||3===o&&1033===a)&&(i.has(l)||i.set(l,{offset:e+n+u,length:c,
|
|
414
|
+
for(let r=0;s>r;r++){const s=e+6+12*r,o=t.getUint16(s),h=t.getUint16(s+2),a=t.getUint16(s+4),l=t.getUint16(s+6),c=t.getUint16(s+8),u=t.getUint16(s+10);(0===o||3===o&&1033===a)&&(i.has(l)||i.set(l,{offset:e+n+u,length:c,Li:o,Di:h}))}return i}static Ni(t,e,i){if(!e)return null
|
|
368
415
|
const s=e.get(i)
|
|
369
416
|
if(!s)return null
|
|
370
417
|
try{const e=new Uint8Array(t.buffer,s.offset,s.length)
|
|
371
|
-
return 0===s.
|
|
418
|
+
return 0===s.Li||3===s.Li&&1===s.Di?$t.decode(e):new TextDecoder("ascii").decode(e)}catch{return null}}static ki(t,e,i){const s=e.has(Lt)||e.has(Dt),n=e.get(Mt)?.offset??0,r=e.get(_t)?.offset??0,o=e.get(Ot)?.offset??0,h=e.get(Ct)?.offset??0,a=e.get(kt)?.offset??0,l=n?t.getUint16(n+18):1e3
|
|
372
419
|
let c=null
|
|
373
420
|
r&&(c={fi:t.getInt16(r+4),di:t.getInt16(r+6),yi:t.getInt16(r+8)})
|
|
374
421
|
let u=null
|
|
375
422
|
o&&(u={pi:t.getInt16(o+68),wi:t.getInt16(o+70),gi:t.getInt16(o+72),mi:t.getUint16(o+74),xi:t.getUint16(o+76)})
|
|
376
423
|
let f=null
|
|
377
|
-
return h&&a&&i&&(f=this.
|
|
424
|
+
return h&&a&&i&&(f=this.Pi(t,a,i)),{bi:s,Be:l,Ei:c?.fi||null,Ti:c?.di||null,Ii:c?.yi||null,pi:u?.pi||null,wi:u?.wi||null,gi:u?.gi||null,mi:u?.mi||null,xi:u?.xi||null,Si:f}}static Pi(t,e,i){try{if(1>t.getUint16(e))return null
|
|
378
425
|
const s=t.getUint16(e+4),n=t.getUint16(e+6),r=t.getUint32(e+8),o={}
|
|
379
|
-
for(let h=0;n>h;h++){const n=e+r+h*s,a=String.fromCharCode(t.getUint8(n),t.getUint8(n+1),t.getUint8(n+2),t.getUint8(n+3)),l=t.getUint16(n+4),c=this.
|
|
380
|
-
c&&(o[a]=c)}return Object.keys(o).length>0?o:null}catch{return null}}static Bi(t,e,i){const s=e.get(
|
|
426
|
+
for(let h=0;n>h;h++){const n=e+r+h*s,a=String.fromCharCode(t.getUint8(n),t.getUint8(n+1),t.getUint8(n+2),t.getUint8(n+3)),l=t.getUint16(n+4),c=this.Ni(t,i,l)
|
|
427
|
+
c&&(o[a]=c)}return Object.keys(o).length>0?o:null}catch{return null}}static Bi(t,e,i){const s=e.get(Nt)?.offset??0,n=e.get(Pt)?.offset??0,r=new Set,o={}
|
|
381
428
|
try{s&&this.$i(t,s,i,r,o),n&&this.$i(t,n,i,r,o)}catch{return}if(0===r.size)return
|
|
382
429
|
const h=Array.from(r).sort((t,e)=>t-e)
|
|
383
430
|
return{tags:h.map(this.Gi),names:Object.keys(o).length>0?o:{}}}static $i(t,e,i,s,n){const r=e+t.getUint16(e+6),o=t.getUint16(r)
|
|
@@ -392,13 +439,13 @@ const u=r+t.getUint16(o+4),f=t.getUint16(u)
|
|
|
392
439
|
if(0===f)continue
|
|
393
440
|
const d=u+f
|
|
394
441
|
if(0!==t.getUint16(d))continue
|
|
395
|
-
const y=t.getUint16(d+2),p=this.
|
|
396
|
-
p&&(n[String.fromCharCode(h>>24&255,h>>16&255,h>>8&255,255&h)]=p)}}static Gi(t){return String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,255&t)}static zi(t){return null!==t.pi&&null!==t.wi?{fi:t.pi,di:t.wi,yi:0}:null!==t.Ei&&null!==t.Ti?{fi:t.Ei,di:t.Ti,yi:0}:null!==t.mi&&null!==t.xi?{fi:t.mi,di:-t.xi,yi:0}:{fi:Math.round(.8*t.Be),di:-Math.round(.2*t.Be),yi:0}}static Ri(t){const e=
|
|
397
|
-
return{fi:e.fi,di:e.di,yi:e.yi,Be:t.Be,Wi:e.fi-e.di}}}let
|
|
398
|
-
class
|
|
442
|
+
const y=t.getUint16(d+2),p=this.Ni(t,i,y)
|
|
443
|
+
p&&(n[String.fromCharCode(h>>24&255,h>>16&255,h>>8&255,255&h)]=p)}}static Gi(t){return String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,255&t)}static zi(t){return null!==t.pi&&null!==t.wi?{fi:t.pi,di:t.wi,yi:0}:null!==t.Ei&&null!==t.Ti?{fi:t.Ei,di:t.Ti,yi:0}:null!==t.mi&&null!==t.xi?{fi:t.mi,di:-t.xi,yi:0}:{fi:Math.round(.8*t.Be),di:-Math.round(.2*t.Be),yi:0}}static Ri(t){const e=Gt.zi(t)
|
|
444
|
+
return{fi:e.fi,di:e.di,yi:e.yi,Be:t.Be,Wi:e.fi-e.di}}}let zt=null
|
|
445
|
+
class Rt{static ji(t){if(4>t.byteLength)return"ttf/otf"
|
|
399
446
|
const e=new DataView(t).getUint32(0)
|
|
400
|
-
return e===
|
|
401
|
-
if(e.getUint32(0)!==
|
|
447
|
+
return e===St?"woff":e===Ft?"woff2":"ttf/otf"}static async Ui(t){const e=new DataView(t),i=new Uint8Array(t)
|
|
448
|
+
if(e.getUint32(0)!==St)throw Error("Not a valid WOFF font")
|
|
402
449
|
const s=e.getUint32(4),n=e.getUint16(12),r=e.getUint32(16)
|
|
403
450
|
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.")
|
|
404
451
|
const o=new Uint8Array(r),h=new DataView(o.buffer)
|
|
@@ -410,70 +457,70 @@ const c=[]
|
|
|
410
457
|
for(let t=0;n>t;t++){const i=44+20*t
|
|
411
458
|
c.push({tag:e.getUint32(i),offset:e.getUint32(i+4),length:e.getUint32(i+8),Vi:e.getUint32(i+12),t:e.getUint32(i+16)})}c.sort((t,e)=>t.tag-e.tag)
|
|
412
459
|
const u=await Promise.all(c.map(async t=>{if(t.length===t.Vi)return i.subarray(t.offset,t.offset+t.length)
|
|
413
|
-
const e=i.subarray(t.offset,t.offset+t.length),s=await
|
|
460
|
+
const e=i.subarray(t.offset,t.offset+t.length),s=await Rt.Hi(e)
|
|
414
461
|
if(s.byteLength!==t.Vi)throw Error(`Decompression failed: expected ${t.Vi} bytes, got ${s.byteLength}`)
|
|
415
462
|
return new Uint8Array(s)}))
|
|
416
463
|
for(let t=0;n>t;t++){const e=c[t],i=12+16*t
|
|
417
|
-
h.setUint32(i,e.tag),h.setUint32(i+4,e.t),h.setUint32(i+8,l),h.setUint32(i+12,e.Vi),o.set(u[t],l),l+=e.Vi,l+=(4-e.Vi%4)%4}return o.buffer.slice(0,l)}static async qi(t){if(new DataView(t).getUint32(0)!==
|
|
418
|
-
if(!
|
|
419
|
-
return(await
|
|
420
|
-
return new Response(e).arrayBuffer()}}class
|
|
421
|
-
const i=
|
|
422
|
-
"woff"===i?t=await
|
|
464
|
+
h.setUint32(i,e.tag),h.setUint32(i+4,e.t),h.setUint32(i+8,l),h.setUint32(i+12,e.Vi),o.set(u[t],l),l+=e.Vi,l+=(4-e.Vi%4)%4}return o.buffer.slice(0,l)}static async qi(t){if(new DataView(t).getUint32(0)!==Ft)throw Error("Not a valid WOFF2 font")
|
|
465
|
+
if(!zt)throw Error("WOFF2 fonts require enabling the decoder. Add to your code:\n import { woff2Decode } from 'woff-lib/woff2/decode';\n Text.enableWoff2(woff2Decode);")
|
|
466
|
+
return(await zt(t)).buffer}static async Hi(t){const e=new ReadableStream({start(e){e.enqueue(t),e.close()}}).pipeThrough(new DecompressionStream("deflate"))
|
|
467
|
+
return new Response(e).arrayBuffer()}}class Wt{constructor(t){this.Yi=t}async Ji(t,e){if(!t||12>t.byteLength)throw Error("Invalid font buffer: too small to be a valid font file")
|
|
468
|
+
const i=Rt.ji(t)
|
|
469
|
+
"woff"===i?t=await Rt.Ui(t):"woff2"===i&&(t=await Rt.qi(t))
|
|
423
470
|
const s=new DataView(t).getUint32(0)
|
|
424
|
-
if(![
|
|
471
|
+
if(![Tt,It].includes(s))throw Error("Invalid font format. Expected TTF/OTF/WOFF/WOFF2, got signature: 0x"+s.toString(16))
|
|
425
472
|
const{hb:n,module:r}=await this.Yi()
|
|
426
|
-
try{const i=n.Ki(new Uint8Array(t)),s=n.
|
|
473
|
+
try{const i=n.Ki(new Uint8Array(t)),s=n.Xi(i,0),o=n.Qi(s)
|
|
427
474
|
e&&o.Zi(e)
|
|
428
|
-
const h=s.ts(),a=Object.keys(h).length>0,{rt:l,features:c}=
|
|
475
|
+
const h=s.ts(),a=Object.keys(h).length>0,{rt:l,features:c}=Gt.Oi(t)
|
|
429
476
|
let u
|
|
430
477
|
if(a&&h){u={}
|
|
431
|
-
for(const[t,e]of Object.entries(h))u[t]={...e,name:l.
|
|
432
|
-
class
|
|
478
|
+
for(const[t,e]of Object.entries(h))u[t]={...e,name:l.Si?.[t]||null}}return{hb:n,fontBlob:i,face:s,font:o,module:r,upem:l.Be,rt:l,es:e,ss:a,ns:u,rs:c?.tags,hs:c?.names,ls:t}}catch(t){throw st.error("Failed to load font:",t),t}}static cs(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){st.error("Error destroying font resources:",t)}}}const jt=/^[a-z]{2,3}(?:-[a-z0-9]{2,16})*$/i,Ut=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"])
|
|
479
|
+
class Vt{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 Vt(this.x,this.y)}us(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}fs(t){return this.x/=t,this.y/=t,this}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}ds(){return this.x*this.x+this.y*this.y}normalize(){const t=this.length()
|
|
433
480
|
return t>0&&this.fs(t),this}ys(t){return this.x*t.x+this.y*t.y}ps(t){const e=this.x-t.x,i=this.y-t.y
|
|
434
481
|
return Math.sqrt(e*e+i*i)}ws(t){const e=this.x-t.x,i=this.y-t.y
|
|
435
|
-
return e*e+i*i}equals(t){return this.x===t.x&&this.y===t.y}angle(){return Math.atan2(this.y,this.x)}}class
|
|
482
|
+
return e*e+i*i}equals(t){return this.x===t.x&&this.y===t.y}angle(){return Math.atan2(this.y,this.x)}}class Ht{constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.z=i}set(t,e,i){return this.x=t,this.y=e,this.z=i,this}clone(){return new Ht(this.x,this.y,this.z)}us(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}multiply(t){return this.x*=t,this.y*=t,this.z*=t,this}fs(t){return this.x/=t,this.y/=t,this.z/=t,this}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}ds(){return this.x*this.x+this.y*this.y+this.z*this.z}normalize(){const t=this.length()
|
|
436
483
|
return t>0&&this.fs(t),this}ys(t){return this.x*t.x+this.y*t.y+this.z*t.z}gs(t){const e=this.z*t.x-this.x*t.z,i=this.x*t.y-this.y*t.x
|
|
437
484
|
return this.x=this.y*t.z-this.z*t.y,this.y=e,this.z=i,this}ps(t){const e=this.x-t.x,i=this.y-t.y,s=this.z-t.z
|
|
438
485
|
return Math.sqrt(e*e+i*i+s*s)}ws(t){const e=this.x-t.x,i=this.y-t.y,s=this.z-t.z
|
|
439
|
-
return e*e+i*i+s*s}equals(t){return this.x===t.x&&this.y===t.y&&this.z===t.z}}class
|
|
440
|
-
var
|
|
441
|
-
class
|
|
486
|
+
return e*e+i*i+s*s}equals(t){return this.x===t.x&&this.y===t.y&&this.z===t.z}}class qt{constructor(){this.cache=new Map}get(t){return this.cache.get(t)}has(t){return this.cache.has(t)}set(t,e){this.cache.set(t,e)}delete(t){return this.cache.delete(t)}clear(){this.cache.clear()}get size(){return this.cache.size}keys(){return Array.from(this.cache.keys())}getStats(){return{size:this.cache.size}}}const Yt=new qt,Jt=new qt,Kt=new qt,Xt=new qt
|
|
487
|
+
var Qt,Zt,te,ee;(t=>{t[t.ODD=0]="ODD",t[t.NONZERO=1]="NONZERO",t[t.POSITIVE=2]="POSITIVE",t[t.NEGATIVE=3]="NEGATIVE",t[t.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(Qt||(Qt={})),(t=>{t[t.X=0]="POLYGONS",t[t.J=1]="CONNECTED_POLYGONS",t[t.$=2]="BOUNDARY_CONTOURS"})(Zt||(Zt={})),(t=>{t[t.BEGIN=100100]="BEGIN",t[t.EDGE_FLAG=100104]="EDGE_FLAG",t[t.VERTEX=100101]="VERTEX",t[t.END=100102]="END",t[t.ERROR=100103]="ERROR",t[t.COMBINE=100105]="COMBINE",t[t.BEGIN_DATA=100106]="BEGIN_DATA",t[t.EDGE_FLAG_DATA=100110]="EDGE_FLAG_DATA",t[t.VERTEX_DATA=100107]="VERTEX_DATA",t[t.END_DATA=100108]="END_DATA",t[t.ERROR_DATA=100109]="ERROR_DATA",t[t.COMBINE_DATA=100111]="COMBINE_DATA",t[t.WINDING_RULE=100140]="WINDING_RULE",t[t.BOUNDARY_ONLY=100141]="BOUNDARY_ONLY",t[t.TOLERANCE=100142]="TOLERANCE"})(te||(te={})),(t=>{t[t.vs=100151]="MISSING_BEGIN_POLYGON",t[t.xs=100152]="MISSING_BEGIN_CONTOUR",t[t.As=100153]="MISSING_END_POLYGON",t[t.bs=100154]="MISSING_END_CONTOUR",t[t.Es=100155]="COORD_TOO_LARGE",t[t.Ts=100156]="NEED_COMBINE_CALLBACK"})(ee||(ee={}))
|
|
488
|
+
class ie{next
|
|
442
489
|
u
|
|
443
490
|
l=null
|
|
444
491
|
G=0
|
|
445
492
|
_=0
|
|
446
493
|
v=0
|
|
447
494
|
T=0
|
|
448
|
-
I=0}class
|
|
495
|
+
I=0}class se{next
|
|
449
496
|
o
|
|
450
497
|
h
|
|
451
498
|
C
|
|
452
499
|
O
|
|
453
500
|
D
|
|
454
501
|
N=null
|
|
455
|
-
p=0}class
|
|
502
|
+
p=0}class ne{next
|
|
456
503
|
u
|
|
457
504
|
L
|
|
458
505
|
coords=[0,0,0]
|
|
459
506
|
s=0
|
|
460
507
|
i=0
|
|
461
508
|
B=0
|
|
462
|
-
data=null}class
|
|
509
|
+
data=null}class re{next
|
|
463
510
|
u
|
|
464
511
|
L
|
|
465
|
-
_=0}class
|
|
512
|
+
_=0}class oe{Y
|
|
466
513
|
q
|
|
467
514
|
Z
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
constructor(){const t=new
|
|
471
|
-
t.next=t.u=t,e.next=e.u=e,i.next=i,i.h=s,s.next=s,s.h=i,this.Y=t,this.q=e,this.Z=i,this.
|
|
472
|
-
return i.next=s,s.h.next=e,e.next=t,t.h.next=i,e.h=i,e.C=e,e.O=i,e.p=0,e.N=null,i.h=e,i.C=i,i.O=e,i.p=0,i.N=null,e}
|
|
473
|
-
i.h.O=e,s.h.O=t,t.C=s,e.C=i}
|
|
474
|
-
s.u=n,n.next=s,s.next=i,i.u=s,s.L=e,++this.
|
|
515
|
+
Is
|
|
516
|
+
Ss=0
|
|
517
|
+
constructor(){const t=new ne,e=new re,i=new se,s=new se
|
|
518
|
+
t.next=t.u=t,e.next=e.u=e,i.next=i,i.h=s,s.next=s,s.h=i,this.Y=t,this.q=e,this.Z=i,this.Is=s}Fs(t){const e=new se,i=new se,s=t.h.next
|
|
519
|
+
return i.next=s,s.h.next=e,e.next=t,t.h.next=i,e.h=i,e.C=e,e.O=i,e.p=0,e.N=null,i.h=e,i.C=i,i.O=e,i.p=0,i.N=null,e}Ms(t,e){const i=t.C,s=e.C
|
|
520
|
+
i.h.O=e,s.h.O=t,t.C=s,e.C=i}_s(t,e,i){const s=t,n=i.u
|
|
521
|
+
s.u=n,n.next=s,s.next=i,i.u=s,s.L=e,++this.Ss
|
|
475
522
|
let r=e
|
|
476
|
-
do{r.o=s,r=r.C}while(r!==e)}
|
|
523
|
+
do{r.o=s,r=r.C}while(r!==e)}Os(t,e,i){const s=t,n=i.u
|
|
477
524
|
s.u=n,n.next=s,s.next=i,i.u=s,s.L=e,s._=i._
|
|
478
525
|
let r=e
|
|
479
526
|
do{r.D=s,r=r.O}while(r!==e)}Cs(t){const e=t.next,i=t.h.next
|
|
@@ -481,73 +528,73 @@ e.h.next=i,i.h.next=e}ks(t,e){const i=t.L
|
|
|
481
528
|
let s=i
|
|
482
529
|
do{s.o=e,s=s.C}while(s!==i)
|
|
483
530
|
const n=t.u,r=t.next
|
|
484
|
-
r.u=n,n.next=r,--this.
|
|
531
|
+
r.u=n,n.next=r,--this.Ss}Bs(t,e){const i=t.L
|
|
485
532
|
let s=i
|
|
486
533
|
do{s.D=e,s=s.O}while(s!==i)
|
|
487
534
|
const n=t.u,r=t.next
|
|
488
|
-
r.u=n,n.next=r}F(){const t=new
|
|
489
|
-
return this.
|
|
490
|
-
if(t!==e){if(e.o!==t.o&&(s=1,this.ks(e.o,t.o)),e.D!==t.D&&(i=1,this.Bs(e.D,t.D)),this.
|
|
491
|
-
this.
|
|
492
|
-
this.
|
|
535
|
+
r.u=n,n.next=r}F(){const t=new ne,e=new ne,i=new re,s=this.Fs(this.Z)
|
|
536
|
+
return this._s(t,s,this.Y),this._s(e,s.h,this.Y),this.Os(i,s,this.q),s}splice(t,e){let i=0,s=0
|
|
537
|
+
if(t!==e){if(e.o!==t.o&&(s=1,this.ks(e.o,t.o)),e.D!==t.D&&(i=1,this.Bs(e.D,t.D)),this.Ms(e,t),!s){const i=new ne
|
|
538
|
+
this._s(i,e,t.o),t.o.L=t}if(!i){const i=new re
|
|
539
|
+
this.Os(i,e,t.D),t.D.L=t}}}delete(t){const e=t.h
|
|
493
540
|
let i=0
|
|
494
541
|
if(t.D!==t.h.D&&(i=1,this.Bs(t.D,t.h.D)),t.C===t)this.ks(t.o,null)
|
|
495
|
-
else if(t.h.D.L=t.h.O,t.o.L=t.C,this.
|
|
496
|
-
this.
|
|
497
|
-
this.
|
|
498
|
-
const s=new
|
|
499
|
-
return this.
|
|
500
|
-
return this.
|
|
501
|
-
const s=this.
|
|
502
|
-
if(e.D!==t.D&&(i=1,this.Bs(e.D,t.D)),this.
|
|
503
|
-
this.
|
|
542
|
+
else if(t.h.D.L=t.h.O,t.o.L=t.C,this.Ms(t,t.h.O),!i){const e=new re
|
|
543
|
+
this.Os(e,t,t.D)}e.C===e?(this.ks(e.o,null),this.Bs(e.D,null)):(t.D.L=e.h.O,e.o.L=e.C,this.Ms(e,e.h.O)),this.Cs(t)}Et(t){const e=this.Fs(t),i=e.h
|
|
544
|
+
this.Ms(e,t.O),e.o=t.h.o
|
|
545
|
+
const s=new ne
|
|
546
|
+
return this._s(s,i,e.o),e.D=i.D=t.D,e}V(t){const e=this.Et(t).h
|
|
547
|
+
return this.Ms(t.h,t.h.h.O),this.Ms(t.h,e),t.h.o=e.o,e.h.o.L=e.h,e.h.D=t.h.D,e.p=t.p,e.h.p=t.h.p,e}connect(t,e){let i=0
|
|
548
|
+
const s=this.Fs(t),n=s.h
|
|
549
|
+
if(e.D!==t.D&&(i=1,this.Bs(e.D,t.D)),this.Ms(s,t.O),this.Ms(n,e),s.o=t.h.o,n.o=e.o,s.D=n.D=t.D,t.D.L=n,!i){const e=new re
|
|
550
|
+
this.Os(e,s,t.D)}return s}Nt(t){const e=t.L
|
|
504
551
|
let i,s,n,r,o
|
|
505
552
|
s=e.O
|
|
506
|
-
do{i=s,s=i.O,i.D=null,i.h.D||(i.C===i?this.ks(i.o,null):(i.o.L=i.C,this.
|
|
507
|
-
r=t.u,o=t.next,o.u=r,r.next=o}
|
|
553
|
+
do{i=s,s=i.O,i.D=null,i.h.D||(i.C===i?this.ks(i.o,null):(i.o.L=i.C,this.Ms(i,i.h.O)),n=i.h,n.C===n?this.ks(n.o,null):(n.o.L=n.C,this.Ms(n,n.h.O)),this.Cs(i))}while(i!=e)
|
|
554
|
+
r=t.u,o=t.next,o.u=r,r.next=o}Ls(t){let e=t.L,i=0
|
|
508
555
|
do{i++,e=e.O}while(e!==t.L)
|
|
509
|
-
return i}check(){}}class
|
|
556
|
+
return i}check(){}}class he{max=0
|
|
510
557
|
At
|
|
511
558
|
It
|
|
512
|
-
|
|
559
|
+
Ds
|
|
513
560
|
Ot=0
|
|
514
|
-
|
|
561
|
+
Ns=0
|
|
515
562
|
size=0
|
|
516
|
-
constructor(t){this.max=t,this.At=new Int32Array(t+1),this.It=Array(t+1).fill(null),this.
|
|
563
|
+
constructor(t){this.max=t,this.At=new Int32Array(t+1),this.It=Array(t+1).fill(null),this.Ds=new Int32Array(t+1),this.Ot=0,this.At[1]=1,this.It[1]=null}reset(t){if(t+1>this.max)this.max=t,this.At=new Int32Array(t+1),this.It=Array(t+1).fill(null),this.Ds=new Int32Array(t+1)
|
|
517
564
|
else{const t=this.It
|
|
518
|
-
for(let e=1;this.size>=e;e++)t[e]=null}this.size=0,this.
|
|
565
|
+
for(let e=1;this.size>=e;e++)t[e]=null}this.size=0,this.Ns=0,this.Ot=0,this.At[1]=1,this.It[1]=null}Ps(t){const e=this.At,i=this.It,s=this.Ds
|
|
519
566
|
let n=e[t]
|
|
520
567
|
for(;;){let r=t<<1
|
|
521
568
|
if(r>this.size)break
|
|
522
569
|
let o=r,h=e[r]
|
|
523
570
|
if(this.size>=r+1){const t=e[r+1],s=i[t],n=i[h];(n.s>s.s||s.s===n.s&&n.i>=s.i)&&(o=r+1,h=t)}const a=i[n],l=i[h]
|
|
524
571
|
if(l.s>a.s||a.s===l.s&&l.i>=a.i)break
|
|
525
|
-
e[t]=h,s[h]=t,t=o}e[t]=n,s[n]=t}Tt(t){const e=this.At,i=this.It,s=this.
|
|
572
|
+
e[t]=h,s[h]=t,t=o}e[t]=n,s[n]=t}Tt(t){const e=this.At,i=this.It,s=this.Ds
|
|
526
573
|
let n=e[t]
|
|
527
574
|
for(;;){const r=t>>1
|
|
528
575
|
if(0===r)break
|
|
529
576
|
const o=e[r],h=i[o],a=i[n]
|
|
530
577
|
if(a.s>h.s||h.s===a.s&&a.i>=h.i)break
|
|
531
|
-
e[t]=o,s[o]=t,t=r}e[t]=n,s[n]=t}init(){for(let t=this.size>>1;t>=1;--t)this.
|
|
578
|
+
e[t]=o,s[o]=t,t=r}e[t]=n,s[n]=t}init(){for(let t=this.size>>1;t>=1;--t)this.Ps(t)
|
|
532
579
|
this.Ot=1}$s(){return 0===this.size}min(){return 0===this.size?null:this.It[this.At[1]]}P(t){let e,i
|
|
533
580
|
if(e=++this.size,2*e>this.max){this.max*=2
|
|
534
581
|
const t=new Int32Array(this.max+1),e=new Int32Array(this.max+1),i=Array(this.max+1).fill(null)
|
|
535
|
-
t.set(this.At),e.set(this.
|
|
582
|
+
t.set(this.At),e.set(this.Ds)
|
|
536
583
|
for(let t=0;this.It.length>t;t++)i[t]=this.It[t]
|
|
537
|
-
this.At=t,this.
|
|
584
|
+
this.At=t,this.Ds=e,this.It=i}return 0===this.Ns?i=e:(i=this.Ns,this.Ns=this.Ds[i]),this.At[e]=i,this.Ds[i]=e,this.It[i]=t,this.Ot&&this.Tt(e),i}Mt(){const t=this.At,e=this.It,i=this.Ds
|
|
538
585
|
let s=t[1],n=e[s]
|
|
539
|
-
return this.size>0&&(t[1]=t[this.size],i[t[1]]=1,e[s]=null,i[s]=this.
|
|
586
|
+
return this.size>0&&(t[1]=t[this.size],i[t[1]]=1,e[s]=null,i[s]=this.Ns,this.Ns=s,--this.size,this.size>0&&this.Ps(1)),n}delete(t){const e=this.At,i=this.It,s=this.Ds
|
|
540
587
|
let n
|
|
541
588
|
if(n=s[t],e[n]=e[this.size],s[e[n]]=n,--this.size,this.size>=n)if(n>1){const t=i[e[n>>1]],s=i[e[n]]
|
|
542
|
-
s.s>t.s||t.s===s.s&&s.i>=t.i?this.
|
|
543
|
-
i[t]=null,s[t]=this.
|
|
589
|
+
s.s>t.s||t.s===s.s&&s.i>=t.i?this.Ps(n):this.Tt(n)}else this.Ps(n)
|
|
590
|
+
i[t]=null,s[t]=this.Ns,this.Ns=t}}class ae{Dt
|
|
544
591
|
keys
|
|
545
592
|
order=null
|
|
546
593
|
size=0
|
|
547
594
|
max=0
|
|
548
595
|
Ot=0
|
|
549
596
|
Lt
|
|
550
|
-
constructor(t){this.max=t,this.size=0,this.Ot=0,this.Lt=128>=t,this.Dt=new
|
|
597
|
+
constructor(t){this.max=t,this.size=0,this.Ot=0,this.Lt=128>=t,this.Dt=new he(t),this.Lt||(this.keys=Array(t).fill(null))}reset(t){this.Dt.reset(t),this.Lt=128>=t,this.Lt||this.keys&&this.max>=t||(this.keys=Array(t).fill(null)),t>this.max&&(this.max=t),this.size=0,this.Ot=0,this.order=null}P(t){if(this.Lt||this.Ot)return this.Dt.P(t)
|
|
551
598
|
const e=this.size
|
|
552
599
|
if(++this.size>=this.max){const t=this.max
|
|
553
600
|
this.max*=2
|
|
@@ -565,24 +612,24 @@ if(e&&r(e,t))return this.Dt.Mt()}do{--this.size}while(this.size>0&&null===this.k
|
|
|
565
612
|
return t}min(){if(this.Lt||0===this.size)return this.Dt.min()
|
|
566
613
|
const t=this.keys[this.order[this.size-1]]
|
|
567
614
|
if(!this.Dt.$s()){const e=this.Dt.min()
|
|
568
|
-
if(e&&r(e,t))return e}return t}delete(t){0>t?this.keys[-(t+1)]=null:this.Dt.delete(t)}$s(){return(this.Lt||0===this.size)&&this.Dt.$s()}}class
|
|
615
|
+
if(e&&r(e,t))return e}return t}delete(t){0>t?this.keys[-(t+1)]=null:this.Dt.delete(t)}$s(){return(this.Lt||0===this.size)&&this.Dt.$s()}}class le{head=new ie
|
|
569
616
|
frame
|
|
570
617
|
constructor(t){this.frame=t,this.head.next=this.head,this.head.u=this.head}min(){return this.head.next}max(){return this.head.u}P(t){return this.insertBefore(this.head,t)}search(t){let e=this.head
|
|
571
618
|
do{e=e.next}while(null!==e.l&&!p(this.frame,t,e))
|
|
572
619
|
return e}insertBefore(t,e){do{t=t.u}while(null!==t.l&&!p(this.frame,t,e))
|
|
573
|
-
return e.next=t.next,t.next.u=e,e.u=t,t.next=e,e}delete(t){t.next.u=t.u,t.u.next=t.next}}let
|
|
574
|
-
const
|
|
575
|
-
class
|
|
620
|
+
return e.next=t.next,t.next.u=e,e.u=t,t.next=e,e}delete(t){t.next.u=t.u,t.u.next=t.next}}let ce=null,ue=null
|
|
621
|
+
const fe=[0,0,0,0],de=[null,null,null,null],ye=[0,0,0]
|
|
622
|
+
class pe{static Ct(t,e){t.p+=e.p,t.h.p+=e.h.p}static Gt(t,e){let i,s,n
|
|
576
623
|
if(i=e.L,i.O===i||i.O.O===i)throw Error("Monotone region has degenerate topology")
|
|
577
624
|
for(;r(i.h.o,i.o);i=i.C.h);for(;r(i.o,i.h.o);i=i.O);for(s=i.C.h;i.O!==s;)if(r(i.h.o,s.o)){for(;s.O!==i&&(h(s.O)||0>=u(s.o,s.h.o,s.O.h.o));)n=t.connect(s.O,s),s=n.h
|
|
578
625
|
s=s.C.h}else{for(;s.O!==i&&(a(i.C.h)||u(i.h.o,i.o,i.C.h.o)>=0);)n=t.connect(i,i.C.h),i=n.h
|
|
579
626
|
i=i.O}if(s.O===i)throw Error("Monotone region has insufficient vertices")
|
|
580
627
|
for(;s.O.O!==i;)n=t.connect(s.O,s),s=n.h
|
|
581
628
|
return 1}static Gs(t){let e
|
|
582
|
-
for(let i=t.q.next;i!==t.q;i=e)e=i.next,i._&&
|
|
583
|
-
return 1}}let
|
|
584
|
-
var
|
|
585
|
-
class
|
|
629
|
+
for(let i=t.q.next;i!==t.q;i=e)e=i.next,i._&&pe.Gt(t,i)
|
|
630
|
+
return 1}}let we=[],ge=new Int8Array(64),me=new Int32Array(64),ve=new Int32Array(64)
|
|
631
|
+
var xe;(t=>{t[t.Rt=0]="T_DORMANT",t[t.zs=1]="T_IN_POLYGON",t[t.Rs=2]="T_IN_CONTOUR"})(xe||(xe={}))
|
|
632
|
+
class Ae{state=xe.Rt
|
|
586
633
|
Ut=null
|
|
587
634
|
St=0
|
|
588
635
|
Bt=0
|
|
@@ -597,8 +644,8 @@ js
|
|
|
597
644
|
Us
|
|
598
645
|
Wt
|
|
599
646
|
Zt
|
|
600
|
-
M=
|
|
601
|
-
Kt=
|
|
647
|
+
M=Qt.ODD
|
|
648
|
+
Kt=Qt.ODD
|
|
602
649
|
m
|
|
603
650
|
S
|
|
604
651
|
event
|
|
@@ -632,13 +679,13 @@ break
|
|
|
632
679
|
default:throw Error("GLU_INVALID_ENUM")}}Ks(t,e){switch(t){case 100140:{const t=e,i=100130>t?t:t-100130
|
|
633
680
|
if(0>i||i>4)throw Error("GLU_INVALID_VALUE")
|
|
634
681
|
this.Kt=t,this.M=i
|
|
635
|
-
break}case 100141:this.
|
|
682
|
+
break}case 100141:this.Xs=!!e
|
|
636
683
|
break
|
|
637
684
|
case 100142:break
|
|
638
|
-
default:throw Error("GLU_INVALID_ENUM")}}
|
|
639
|
-
case 100141:return this.
|
|
685
|
+
default:throw Error("GLU_INVALID_ENUM")}}Qs(t){switch(t){case 100140:return this.Kt
|
|
686
|
+
case 100141:return this.Xs
|
|
640
687
|
case 100142:return 0
|
|
641
|
-
default:throw Error("GLU_INVALID_ENUM")}}Zs(t,e,i){this.Ht[0]=t,this.Ht[1]=e,this.Ht[2]=i,0===i||t||e||(this.Vt=i>0?1:-1)}H(t){this.Xt&&this.Xt(t,this.k)}W(t){this.Qt&&this.Qt(t,this.k)}tt(){this.Jt&&this.Jt(this.k)}K(t){this.$t&&this.$t(t,this.k)}j(t){this.Hs?this.Hs(t,this.k):this.Vs&&this.Vs(t)}tn(t){if(this.state!==t)for(;this.state!==t;)t>this.state?this.state===
|
|
688
|
+
default:throw Error("GLU_INVALID_ENUM")}}Zs(t,e,i){this.Ht[0]=t,this.Ht[1]=e,this.Ht[2]=i,0===i||t||e||(this.Vt=i>0?1:-1)}H(t){this.Xt&&this.Xt(t,this.k)}W(t){this.Qt&&this.Qt(t,this.k)}tt(){this.Jt&&this.Jt(this.k)}K(t){this.$t&&this.$t(t,this.k)}j(t){this.Hs?this.Hs(t,this.k):this.Vs&&this.Vs(t)}tn(t){if(this.state!==t)for(;this.state!==t;)t>this.state?this.state===xe.Rt?(this.j(100151),this.en()):this.state===xe.zs&&(this.j(100152),this.sn()):this.state===xe.Rs?(this.j(100154),this.nn()):this.state===xe.zs&&(this.j(100153),this.rn())}Xs=0
|
|
642
689
|
Js=0
|
|
643
690
|
hn(){const t=this.A,e=t.Y,i=this.Ht[0],s=this.Ht[1],n=this.Ht[2]
|
|
644
691
|
let r,o
|
|
@@ -664,59 +711,59 @@ let c=e.next
|
|
|
664
711
|
c.s=c.coords[0]*r[0]+c.coords[1]*r[1]+c.coords[2]*r[2],c.i=c.coords[0]*o[0]+c.coords[1]*o[1]+c.coords[2]*o[2]
|
|
665
712
|
let u=c.s,f=c.s,d=c.i,y=c.i
|
|
666
713
|
for(c=c.next;c!==e;c=c.next){const t=c.coords[0]*r[0]+c.coords[1]*r[1]+c.coords[2]*r[2],e=c.coords[0]*o[0]+c.coords[1]*o[1]+c.coords[2]*o[2]
|
|
667
|
-
c.s=t,c.i=e,u>t?u=t:t>f&&(f=t),d>e?d=e:e>y&&(y=e)}h&&G(t,this.Us),h&&o[(l+2)%3]!==(a[l]>0?1:-1)?(this.Wt[0]=u,this.Zt[0]=f,this.Wt[1]=-y,this.Zt[1]=-d):(this.Wt[0]=u,this.Zt[0]=f,this.Wt[1]=d,this.Zt[1]=y)}en(t){this.tn(
|
|
714
|
+
c.s=t,c.i=e,u>t?u=t:t>f&&(f=t),d>e?d=e:e>y&&(y=e)}h&&G(t,this.Us),h&&o[(l+2)%3]!==(a[l]>0?1:-1)?(this.Wt[0]=u,this.Zt[0]=f,this.Wt[1]=-y,this.Zt[1]=-d):(this.Wt[0]=u,this.Zt[0]=f,this.Wt[1]=d,this.Zt[1]=y)}en(t){this.tn(xe.Rt),this.state=xe.zs,this.U=0,this.A=new oe,this.St=0,this.Bt=0!==this.Ht[2]&&!this.Ht[0]&&!this.Ht[1],this.Pt=1/0,this.Ft=-1/0,this.Yt=1/0,this.Ws=-1/0,this.k=t}sn(){this.tn(xe.zs),this.state=xe.Rs,this.Ut=null}an(t,e){this.tn(xe.Rs)
|
|
668
715
|
let i=t[0],s=t[1],n=t.length>2?t[2]:0,r=0;-1e150>i?(i=-1e150,r=1):i>1e150&&(i=1e150,r=1),-1e150>s?(s=-1e150,r=1):s>1e150&&(s=1e150,r=1),-1e150>n?(n=-1e150,r=1):n>1e150&&(n=1e150,r=1),r&&this.j(100155)
|
|
669
716
|
let o=this.Ut
|
|
670
717
|
if(null===o?(o=this.A.F(),this.A.splice(o,o.h)):(this.A.V(o),o=o.O),o.o.data=e||null,o.o.coords[0]=i,o.o.coords[1]=s,0!==n?(o.o.coords[2]=n,this.St=1,this.Bt=0):o.o.coords[2]=0,this.Bt){o.o.s=i
|
|
671
718
|
const t=s*this.Vt
|
|
672
|
-
o.o.i=t,this.Pt>i&&(this.Pt=i),i>this.Ft&&(this.Ft=i),this.Yt>t&&(this.Yt=t),t>this.Ws&&(this.Ws=t)}o.p=1,o.h.p=-1,this.Ut=o}nn(){this.tn(
|
|
719
|
+
o.o.i=t,this.Pt>i&&(this.Pt=i),i>this.Ft&&(this.Ft=i),this.Yt>t&&(this.Yt=t),t>this.Ws&&(this.Ws=t)}o.p=1,o.h.p=-1,this.Ut=o}nn(){this.tn(xe.Rs),this.state=xe.zs}rn(){this.tn(xe.zs),this.state=xe.Rt,this.compute(this.M,void 0,0)
|
|
673
720
|
const t=this.A
|
|
674
|
-
this.U||(this.
|
|
721
|
+
this.U||(this.Xs?(j(t,1),V(this,t)):this.Js?(pe.Gs(t),U(this,t)):z(this,t)),this.qs&&this.qs(t),this.A=null,this.Ut=null,this.event=null,this.k=null,this.m=null}ln(){this.tn(xe.Rt)}compute(t=Qt.ODD,e,i=0){this.state!==xe.Rt&&this.state===xe.zs&&(this.state=xe.Rt),this.A||(this.A=new oe),e&&(this.Ht[0]=e[0],this.Ht[1]=e[1],this.Ht[2]=e[2]),this.M=t,this.hn(),((t,e=1)=>{let i,s
|
|
675
722
|
if((t=>{let e,i,s,r=t.A.Z
|
|
676
|
-
for(e=r.next;e!==r;e=i)i=e.next,s=e.O,n(e.o,e.h.o)&&e.O.O!==e&&(
|
|
677
|
-
for(t.S?(t.S.reset(n),e=t.S):e=t.S=new
|
|
723
|
+
for(e=r.next;e!==r;e=i)i=e.next,s=e.O,n(e.o,e.h.o)&&e.O.O!==e&&(_(t,s,e),t.A.delete(e),e=s,s=e.O),s.O===e&&(s!==e&&(s!==i&&s!==i.h||(i=i.next),t.A.delete(s)),e!==i&&e!==i.h||(i=i.next),t.A.delete(e))})(t),!(t=>{let e,i,s,n=t.A.Ss+8
|
|
724
|
+
for(t.S?(t.S.reset(n),e=t.S):e=t.S=new ae(n),s=t.A.Y,i=s.next;i!==s;i=i.next)i.B=e.P(i)
|
|
678
725
|
return i!==s?0:(e.init(),1)})(t))return 0
|
|
679
|
-
for((t=>{t.m=new
|
|
726
|
+
for((t=>{t.m=new le(t)
|
|
680
727
|
let e=t.Zt[0]-t.Wt[0],i=t.Zt[1]-t.Wt[1],s=t.Wt[0]-e,n=t.Zt[0]+e,r=t.Zt[1]+i
|
|
681
|
-
|
|
682
|
-
|
|
728
|
+
P(t,s,n,t.Wt[1]-i),P(t,s,n,r)})(t);null!==(i=t.S.Mt());){for(;s=t.S.min(),null!==s&&n(s,i);)s=t.S.Mt(),_(t,i.L,s.L)
|
|
729
|
+
N(t,i)}t.event=t.m.min().l.o,(t=>{let e
|
|
683
730
|
for(;null!==(e=t.m.min()).l;)v(t,e)})(t),((t,e)=>{let i,s,n
|
|
684
|
-
for(i=e.q.next;i!==e.q;i=s)s=i.next,n=i.L,n.O.O===n&&(m(n.C,n),t.A.delete(n))})(t,t.A),e&&t.A.check()})(this,i)}cn(){this.A&&(j(this.A,1),V(this,this.A))}un(t=0){this.A&&(t?(
|
|
731
|
+
for(i=e.q.next;i!==e.q;i=s)s=i.next,n=i.L,n.O.O===n&&(m(n.C,n),t.A.delete(n))})(t,t.A),e&&t.A.check()})(this,i)}cn(){this.A&&(j(this.A,1),V(this,this.A))}un(t=0){this.A&&(t?(pe.Gs(this.A),U(this,this.A)):z(this,this.A))}}class be{process(t,e=!0,i=!1,s=!0){if(0===t.length)return{fn:{vertices:[],indices:[]},dn:[]}
|
|
685
732
|
const n=t.filter(t=>t.points.length>=3)
|
|
686
733
|
return 0===n.length?{fn:{vertices:[],indices:[]},dn:[]}:this.yn(n,e,i,s)}pn(t,e=!0,i=!1,s=!0){return 0===t.length?{fn:{vertices:[],indices:[]},dn:[]}:this.wn(t,e,i,s)}yn(t,e,i,s){const n=!i&&!e
|
|
687
734
|
let r,o
|
|
688
735
|
n?(o=this.gn(t,!0),(e||s)&&(r=this.gn(t))):(r=this.gn(t),o=r)
|
|
689
736
|
let h=s?n?o:r??this.gn(t):[]
|
|
690
737
|
if(e){const t=this.mn(r,"boundary")
|
|
691
|
-
if(!t)return
|
|
738
|
+
if(!t)return st.warn("libtess returned empty result from boundary pass"),{fn:{vertices:[],indices:[]},dn:[]}
|
|
692
739
|
o=this.vn(t),s&&(h=o)}const a=this.mn(o,"triangles")
|
|
693
|
-
return a?{fn:{vertices:a.vertices,indices:a.indices||[]},dn:h,xn:e}:(
|
|
740
|
+
return a?{fn:{vertices:a.vertices,indices:a.indices||[]},dn:h,xn:e}:(st.warn(e?"libtess returned empty result from triangulation pass":"libtess returned empty result from single-pass triangulation"),{fn:{vertices:[],indices:[]},dn:h})}wn(t,e,i,s){const n=!i&&!e
|
|
694
741
|
let r,o
|
|
695
|
-
n?(o=this.
|
|
742
|
+
n?(o=this.An(t),(e||s)&&(r=t)):(r=t,o=t)
|
|
696
743
|
let h=s?n?o:r??t:[]
|
|
697
744
|
if(e){const t=this.mn(r,"boundary")
|
|
698
|
-
if(!t)return
|
|
745
|
+
if(!t)return st.warn("libtess returned empty result from boundary pass"),{fn:{vertices:[],indices:[]},dn:[]}
|
|
699
746
|
o=this.vn(t),s&&(h=o)}const a=this.mn(o,"triangles")
|
|
700
|
-
return a?{fn:{vertices:a.vertices,indices:a.indices||[]},dn:h,xn:e}:(
|
|
747
|
+
return a?{fn:{vertices:a.vertices,indices:a.indices||[]},dn:h,xn:e}:(st.warn(e?"libtess returned empty result from triangulation pass":"libtess returned empty result from single-pass triangulation"),{fn:{vertices:[],indices:[]},dn:h})}gn(t,e=!1){const i=Array(t.length)
|
|
701
748
|
for(let s=0;t.length>s;s++){const n=t[s].points,r=n.length,o=r>1&&n[0].x===n[r-1].x&&n[0].y===n[r-1].y?r-1:r,h=Array(2*(o+1))
|
|
702
749
|
let a=0
|
|
703
750
|
if(e)for(let t=o-1;t>=0;t--){const e=n[t]
|
|
704
751
|
h[a++]=e.x,h[a++]=e.y}else for(let t=0;o>t;t++){const e=n[t]
|
|
705
|
-
h[a++]=e.x,h[a++]=e.y}2>a||(h[a++]=h[0],h[a++]=h[1]),i[s]=h}return i}
|
|
706
|
-
for(let i=0;t.length>i;i++)e[i]=this.
|
|
707
|
-
return e}
|
|
752
|
+
h[a++]=e.x,h[a++]=e.y}2>a||(h[a++]=h[0],h[a++]=h[1]),i[s]=h}return i}An(t){const e=Array(t.length)
|
|
753
|
+
for(let i=0;t.length>i;i++)e[i]=this.bn(t[i])
|
|
754
|
+
return e}bn(t){const e=t.length
|
|
708
755
|
if(0===e)return[]
|
|
709
756
|
const i=4>e||t[0]!==t[e-2]||t[1]!==t[e-1]?e:e-2
|
|
710
757
|
if(0===i)return[]
|
|
711
758
|
const s=Array(i+2)
|
|
712
759
|
let n=0
|
|
713
760
|
for(let e=i-2;e>=0;e-=2)s[n++]=t[e],s[n++]=t[e+1]
|
|
714
|
-
return 2>n||(s[n++]=s[0],s[n++]=s[1]),s}mn(t,e){const i=new
|
|
715
|
-
i.Ks(
|
|
761
|
+
return 2>n||(s[n++]=s[0],s[n++]=s[1]),s}mn(t,e){const i=new Ae
|
|
762
|
+
i.Ks(te.WINDING_RULE,Qt.NONZERO)
|
|
716
763
|
const s=[],n=[],r=[]
|
|
717
764
|
let o=[]
|
|
718
|
-
"boundary"===e&&i.Ks(
|
|
719
|
-
return s.push(t[0],t[1]),e}),i.Ys(
|
|
765
|
+
"boundary"===e&&i.Ks(te.BOUNDARY_ONLY,1),"triangles"===e?i.Ys(te.VERTEX_DATA,t=>{n.push(t)}):(i.Ys(te.BEGIN,()=>{o=[]}),i.Ys(te.VERTEX_DATA,t=>{o.push(t)}),i.Ys(te.END,()=>{o.length>0&&r.push(o)})),i.Ys(te.COMBINE,t=>{const e=s.length/2
|
|
766
|
+
return s.push(t[0],t[1]),e}),i.Ys(te.ERROR,t=>{st.warn("libtess error: "+t)}),i.Zs(0,0,1),i.en()
|
|
720
767
|
for(const e of t){i.sn()
|
|
721
768
|
for(let t=0;e.length>t;t+=2){const n=s.length/2
|
|
722
769
|
s.push(e[t],e[t+1]),i.an([e[t],e[t+1]],n)}i.nn()}return i.rn(),0===s.length?null:"triangles"===e?{vertices:s,indices:n}:{vertices:s,En:r}}vn(t){if(!t.En)return[]
|
|
@@ -726,13 +773,13 @@ for(const e of i){const i=2*e
|
|
|
726
773
|
s.push(t.vertices[i],t.vertices[i+1])}s.length>2&&(s[0]===s[s.length-2]&&s[1]===s[s.length-1]||s.push(s[0],s[1])),e.push(s)}return e}Tn(t){if(0===t.length)return!1
|
|
727
774
|
if(1===t.length)return!1
|
|
728
775
|
let e=null
|
|
729
|
-
for(const i of t){const t=0>this.
|
|
776
|
+
for(const i of t){const t=0>this.In(i)?-1:1
|
|
730
777
|
if(null===e)e=t
|
|
731
|
-
else if(t!==e)return!0}return!1}
|
|
778
|
+
else if(t!==e)return!0}return!1}In(t){let e=0
|
|
732
779
|
const i=t.length
|
|
733
780
|
if(6>i)return 0
|
|
734
781
|
for(let s=0;i>s;s+=2)e+=t[s]*t[(s+3)%i]-t[(s+2)%i]*t[s+1]
|
|
735
|
-
return e/2}}class
|
|
782
|
+
return e/2}}class Ee{constructor(){}Sn(t,e=0,i){const s=t.fn.vertices,n=t.fn.indices,r=t.dn,o=s.length,h=o/2
|
|
736
783
|
let a=[],l=0,c=!1
|
|
737
784
|
if(0!==e)if(!0===t.xn&&r.length>0){c=!0
|
|
738
785
|
for(const t of r){const e=t.length>>1
|
|
@@ -763,14 +810,14 @@ const p=v
|
|
|
763
810
|
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,v+=4}}else for(let t=0;l>t;t++){const e=t<<1,i=a[e]<<1,n=a[e+1]<<1,r=s[i],o=s[i+1],h=s[n],l=s[n+1],c=h-r,u=l-o,p=c*c+u*u
|
|
764
811
|
let g=0,m=0
|
|
765
812
|
if(p>1e-10){const t=1/Math.sqrt(p)
|
|
766
|
-
g=u*t,m=-c*t}const
|
|
767
|
-
f[
|
|
768
|
-
const
|
|
769
|
-
y[x]=
|
|
770
|
-
return 0===i?[]:1===i?[[0]]:this.
|
|
813
|
+
g=u*t,m=-c*t}const A=3*v
|
|
814
|
+
f[A]=r,f[A+1]=o,f[A+2]=0,f[A+3]=h,f[A+4]=l,f[A+5]=0,f[A+6]=r,f[A+7]=o,f[A+8]=w,f[A+9]=h,f[A+10]=l,f[A+11]=w,d[A]=g,d[A+1]=m,d[A+2]=0,d[A+3]=g,d[A+4]=m,d[A+5]=0,d[A+6]=g,d[A+7]=m,d[A+8]=0,d[A+9]=g,d[A+10]=m,d[A+11]=0
|
|
815
|
+
const b=v
|
|
816
|
+
y[x]=b,y[x+1]=b+1,y[x+2]=b+2,y[x+3]=b+1,y[x+4]=b+3,y[x+5]=b+2,x+=6,v+=4}return{vertices:f,normals:d,indices:y}}}class Te{constructor(){}Fn(t,e){const i=t.length
|
|
817
|
+
return 0===i?[]:1===i?[[0]]:this.Mn(t,e)}Mn(t,e){function i(t){return a[t]===t?t:a[t]=i(a[t])}function s(t,e){const s=i(t),n=i(e)
|
|
771
818
|
s!==n&&(l[n]>l[s]?a[s]=n:l[s]>l[n]?a[n]=s:(a[n]=s,l[s]++))}const n=t.length,r=Array(n),o=Array(2*n)
|
|
772
819
|
let h=0
|
|
773
|
-
for(let i=0;n>i;i++)r[i]=this.
|
|
820
|
+
for(let i=0;n>i;i++)r[i]=this._n(t[i],e[i]),o[h++]=[r[i].On,0,i],o[h++]=[r[i].Cn,1,i]
|
|
774
821
|
o.sort((t,e)=>t[0]-e[0]||t[1]-e[1])
|
|
775
822
|
const a=Array.from({length:n},(t,e)=>e),l=Array(n).fill(0),c=new Set
|
|
776
823
|
for(const[,t,e]of o)if(0===t){const t=r[e]
|
|
@@ -779,415 +826,386 @@ n.kn+.001>t.Bn&&t.kn>n.Bn-.001&&s(e,i)}c.add(e)}else c.delete(e)
|
|
|
779
826
|
const u=new Map
|
|
780
827
|
for(let t=0;n>t;t++){const e=i(t)
|
|
781
828
|
let s=u.get(e)
|
|
782
|
-
s||(s=[],u.set(e,s)),s.push(t)}return Array.from(u.values())}
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
this.
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
let
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
0
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
if(
|
|
803
|
-
|
|
804
|
-
const e=t
|
|
805
|
-
if(
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
const
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
class
|
|
829
|
+
s||(s=[],u.set(e,s)),s.push(t)}return Array.from(u.values())}_n(t,e){return{On:t.bounds.min.x+e.x,Bn:t.bounds.min.y+e.y,Cn:t.bounds.max.x+e.x,kn:t.bounds.max.y+e.y}}}const Ie={enabled:!0,areaThreshold:1}
|
|
830
|
+
let Se=1024,Fe=new Float64Array(Se),Me=new Float64Array(Se),_e=new Float64Array(Se),Oe=new Int32Array(Se),Ce=new Int32Array(Se),ke=new Int32Array(Se),Be=new Int32Array(Se)
|
|
831
|
+
class Le{constructor(t){this.stats={pointsRemovedByVisvalingam:0,originalPointCount:0},this.config=t}Ln(t){this.config=t}Dn(t){const e=t.points,i=e.length
|
|
832
|
+
if(5>i||!this.config.enabled)return this.config.enabled&&(this.stats.originalPointCount+=i),t
|
|
833
|
+
this.stats.originalPointCount+=i
|
|
834
|
+
const s=((t,e,i)=>{if(3>=e)return 0;(t=>{if(t>Se){for(Se=1;t>Se;)Se<<=1
|
|
835
|
+
Fe=new Float64Array(Se),Me=new Float64Array(Se),_e=new Float64Array(Se),Oe=new Int32Array(Se),Ce=new Int32Array(Se),ke=new Int32Array(Se),Be=new Int32Array(Se)}})(e)
|
|
836
|
+
const s=Fe,n=Me,r=_e,o=Oe,h=Ce,a=ke,l=Be
|
|
837
|
+
for(let i=0;e>i;i++){const e=t[i]
|
|
838
|
+
s[i]=e.x,n[i]=e.y,o[i]=i-1,h[i]=i+1}h[e-1]=-1
|
|
839
|
+
const c=e-2
|
|
840
|
+
r[0]=1/0,r[e-1]=1/0
|
|
841
|
+
for(let t=1;e-1>t;t++)r[t]=Y(s,n,t-1,t,t+1),a[t-1]=t,l[t]=t-1
|
|
842
|
+
l[0]=-1,l[e-1]=-1
|
|
843
|
+
let u=c
|
|
844
|
+
for(let t=(u>>1)-1;t>=0;t--)q(a,l,r,t,u)
|
|
845
|
+
const f=2*i,d=e-3
|
|
846
|
+
let y=0
|
|
847
|
+
for(;u>0&&d>y;){const t=a[0]
|
|
848
|
+
if(r[t]>f)break
|
|
849
|
+
if(u--,u>0){const t=a[u]
|
|
850
|
+
a[0]=t,l[t]=0,q(a,l,r,0,u)}l[t]=-1
|
|
851
|
+
const e=o[t],i=h[t]
|
|
852
|
+
if(0>e||(h[e]=i),0>i||(o[i]=e),y++,e>=0&&o[e]>=0){const t=r[e],h=Y(s,n,o[e],e,i)
|
|
853
|
+
r[e]=h
|
|
854
|
+
const c=l[e]
|
|
855
|
+
0>c||(t>h?H(a,l,r,c):h>t&&q(a,l,r,c,u))}if(i>=0&&h[i]>=0){const t=r[i],o=Y(s,n,e,i,h[i])
|
|
856
|
+
r[i]=o
|
|
857
|
+
const c=l[i]
|
|
858
|
+
0>c||(t>o?H(a,l,r,c):o>t&&q(a,l,r,c,u))}}return y})(e,i,this.config.areaThreshold)
|
|
859
|
+
if(0===s)return t
|
|
860
|
+
this.stats.pointsRemovedByVisvalingam+=s
|
|
861
|
+
const n=Array(i-s)
|
|
862
|
+
let r=0,o=0
|
|
863
|
+
for(;r>=0;)n[o++]=e[r],r=Ce[r]
|
|
864
|
+
return{...t,points:n}}getStats(){return{...this.stats}}Nn(){this.stats={pointsRemovedByVisvalingam:0,originalPointCount:0}}}const De={distanceTolerance:.5,angleTolerance:.2,Pn:0,$n:1e-6,Gn:16},Ne=De.$n
|
|
865
|
+
let Pe,$e=0,Ge=0,ze=0,Re=0,We=0,je=0,Ue=0
|
|
866
|
+
class Ve{constructor(t){this.curveSteps=null,this.zn=0,this.Rn=0,this.Wn=0,this.jn=0,this.Un=0,this.Vn=0,this.Hn=0,this.qn={...De,...t},this.Yn()}Jn(t){this.qn={...De,...t},this.Yn()}Yn(){const t=this.qn,e=t.distanceTolerance??De.distanceTolerance
|
|
867
|
+
this.zn=e*e,this.Rn=t.angleTolerance??De.angleTolerance,this.Wn=this.Rn>0?Math.tan(this.Rn)**2:0,this.jn=t.Pn??0,this.Un=this.jn>0?Math.tan(this.jn)**2:0,this.Vn=t.$n??De.$n,this.Hn=t.Gn??De.Gn}Kn(){$e=this.zn,Re=this.Rn,We=this.Wn,je=this.jn,Ue=this.Un,Ge=this.Vn,ze=this.Hn,Pe=[]}Xn(t){if(null==t)return void(this.curveSteps=null)
|
|
820
868
|
if(!Number.isFinite(t))return void(this.curveSteps=null)
|
|
821
869
|
const e=Math.round(t)
|
|
822
|
-
this.curveSteps=1>e?null:e}Qn(t,e,i){
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
this.
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
if(0>=h)return void this.tr(i,s,o)
|
|
834
|
-
{const a=i-t,l=s-e,c=n-i,u=r-s
|
|
835
|
-
if(h>Math.abs(Math.atan2(a*u-l*c,a*c+l*u)))return void this.tr(i,s,o)}}}else{const n=y*y+p*p
|
|
836
|
-
if(0===n){if(m>=(i-t)*(i-t)+(s-e)*(s-e))return void this.tr(i,s,o)}else{const r=((i-t)*y+(s-e)*p)/n
|
|
837
|
-
if(r>0&&1>r&&m*n>=w*w)return void this.tr(i,s,o)}}this.Zn(t,e,a,l,f,d,o,h+1),this.Zn(f,d,c,u,n,r,o,h+1)}sr(t,e,i,s,n,r,o,h,a,l=0){if(l>16)return
|
|
838
|
-
const c=(t+i)/2,u=(e+s)/2,f=(i+n)/2,d=(s+r)/2,y=(n+o)/2,p=(r+h)/2,w=(c+f)/2,g=(u+d)/2,m=(f+y)/2,v=(d+p)/2,x=(w+m)/2,b=(g+v)/2,A=o-t,E=h-e,T=Math.abs((i-o)*E-(s-h)*A),M=Math.abs((n-o)*E-(r-h)*A),I=this.Yn.distanceTolerance??Ae.distanceTolerance,S=I*I
|
|
839
|
-
let _=0
|
|
840
|
-
switch(T>Ee&&(_|=1),M>Ee&&(_|=2),_){case 0:const l=A*A+E*E
|
|
841
|
-
if(0===l){if(S>=(i-t)*(i-t)+(s-e)*(s-e)&&S>=(n-t)*(n-t)+(r-e)*(r-e))return this.tr(i,s,a),void this.tr(n,r,a)}else{const o=((i-t)*A+(s-e)*E)/l,h=((n-t)*A+(r-e)*E)/l
|
|
842
|
-
if(o>0&&1>o&&h>0&&1>h&&S*l>=(T+M)*(T+M))return this.tr(i,s,a),void this.tr(n,r,a)}break
|
|
843
|
-
case 1:if(S*(A*A+E*E)>=M*M){const t=this.Yn.angleTolerance??Ae.angleTolerance
|
|
844
|
-
if(0>=t)return this.tr(i,s,a),void this.tr(n,r,a)
|
|
845
|
-
{const e=n-i,l=r-s,c=o-n,u=h-r
|
|
846
|
-
if(t>Math.abs(Math.atan2(e*u-l*c,e*c+l*u)))return this.tr(i,s,a),void this.tr(n,r,a)}}break
|
|
847
|
-
case 2:if(S*(A*A+E*E)>=T*T){const o=this.Yn.angleTolerance??Ae.angleTolerance
|
|
848
|
-
if(0>=o)return this.tr(i,s,a),void this.tr(n,r,a)
|
|
849
|
-
{const h=i-t,l=s-e,c=n-i,u=r-s
|
|
850
|
-
if(o>Math.abs(Math.atan2(h*u-l*c,h*c+l*u)))return this.tr(i,s,a),void this.tr(n,r,a)}}break
|
|
851
|
-
case 3:if(S*(A*A+E*E)>=(T+M)*(T+M)){const l=this.Yn.angleTolerance??Ae.angleTolerance
|
|
852
|
-
if(0>=l)return this.tr(i,s,a),void this.tr(n,r,a)
|
|
853
|
-
{const c=i-t,u=s-e,f=n-i,d=r-s,y=o-n,p=h-r
|
|
854
|
-
if(l>Math.abs(Math.atan2(c*d-u*f,c*f+u*d))+Math.abs(Math.atan2(f*p-d*y,f*y+d*p)))return this.tr(i,s,a),void this.tr(n,r,a)}}}this.sr(t,e,c,u,w,g,x,b,a,l+1),this.sr(x,b,m,v,y,p,o,h,a,l+1)}tr(t,e,i){const s=new Gt(t,e)
|
|
855
|
-
if(0===i.length)return void i.push(s)
|
|
856
|
-
const n=i[i.length-1],r=s.x-n.x,o=s.y-n.y
|
|
857
|
-
r*r+o*o>1e-12&&i.push(s)}}class Me{constructor(t,e){this.rr=0,this.hr=0,this.ar=[],this.lr=null,this.cr=null,this.ur={min:new Gt(1/0,1/0),max:new Gt(-1/0,-1/0)},this.dr=[],this.yr=[],this.pr=[],this.wr=new Gt(0,0),this.gr=new Te(t),this.mr=new be({...xe,...e})}setPosition(t,e){this.wr.set(t,e)}vr(t,e){this.wr.x+=t,this.wr.y+=e}br(t,e){this.ar.length>0&&this.Ar(),this.rr=t,this.hr=e,this.ar=[],this.ur.min.set(1/0,1/0),this.ur.max.set(-1/0,-1/0),this.yr.push(this.wr.clone())}Ar(){this.lr&&this.Er(),this.ar.length>0&&(this.dr.push({Tr:this.rr,Mr:this.ar,bounds:{min:{x:this.ur.min.x,y:this.ur.min.y},max:{x:this.ur.max.x,y:this.ur.max.y}}}),this.pr.push(this.hr)),this.ar=[]}Ir(t,e){this.lr&&this.Er(),this.cr=new Gt(t,e),this.Sr(this.cr),this.lr={points:[this.cr],glyphIndex:this.rr}}_r(t,e){if(!this.lr||!this.cr)return
|
|
858
|
-
const i=new Gt(t,e)
|
|
859
|
-
this.Sr(i),this.lr.points.push(i),this.cr=i}Or(t,e,i,s){if(!this.lr||!this.cr)return
|
|
860
|
-
const n=this.cr,r=new Gt(t,e),o=new Gt(i,s)
|
|
861
|
-
if(Ee>Math.abs((r.x-o.x)*(o.y-n.y)-(r.y-o.y)*(o.x-n.x)))return void this._r(i,s)
|
|
862
|
-
const h=this.gr.Qn(n,r,o)
|
|
870
|
+
this.curveSteps=1>e?null:e}Qn(t,e,i){return null!==this.curveSteps?this.Zn(t,e,i,this.curveSteps):(this.Kn(),K(t.x,t.y,e.x,e.y,i.x,i.y,0),J(i.x,i.y),Pe)}tr(t,e,i,s){return null!==this.curveSteps?this.er(t,e,i,s,this.curveSteps):(this.Kn(),((t,e,i,s,n,r,o,h)=>{const a=.5*(t+i),l=.5*(e+s),c=.5*(i+n),u=.5*(s+r),f=.5*(n+o),d=.5*(r+h),y=.5*(a+c),p=.5*(l+u),w=.5*(c+f),g=.5*(u+d),m=.5*(y+w),v=.5*(p+g)
|
|
871
|
+
X(t,e,a,l,y,p,m,v,1),X(m,v,w,g,f,d,o,h,1)})(t.x,t.y,e.x,e.y,i.x,i.y,s.x,s.y),J(s.x,s.y),Pe)}Zn(t,e,i,s){this.Kn()
|
|
872
|
+
for(let n=1;s>=n;n++){const r=n/s,o=t.x+(e.x-t.x)*r,h=t.y+(e.y-t.y)*r
|
|
873
|
+
J(o+(e.x+(i.x-e.x)*r-o)*r,h+(e.y+(i.y-e.y)*r-h)*r)}return Pe}er(t,e,i,s,n){this.Kn()
|
|
874
|
+
for(let r=1;n>=r;r++){const o=r/n,h=t.x+(e.x-t.x)*o,a=t.y+(e.y-t.y)*o,l=e.x+(i.x-e.x)*o,c=e.y+(i.y-e.y)*o,u=h+(l-h)*o,f=a+(c-a)*o
|
|
875
|
+
J(u+(l+(i.x+(s.x-i.x)*o-l)*o-u)*o,f+(c+(i.y+(s.y-i.y)*o-c)*o-f)*o)}return Pe}}class He{constructor(t,e){this.ir=0,this.sr=0,this.nr=[],this.rr=null,this.hr=null,this.ar={min:new Vt(1/0,1/0),max:new Vt(-1/0,-1/0)},this.lr=[],this.cr=[],this.ur=[],this.dr=new Vt(0,0),this.yr=new Ve(t),this.pr=new Le({...Ie,...e})}setPosition(t,e){this.dr.set(t,e)}wr(t,e){this.dr.x+=t,this.dr.y+=e}gr(t,e){this.nr.length>0&&this.mr(),this.ir=t,this.sr=e,this.nr=[],this.ar.min.set(1/0,1/0),this.ar.max.set(-1/0,-1/0),this.cr.push(this.dr.clone())}mr(){this.rr&&this.vr(),this.nr.length>0&&(this.lr.push({Ar:this.ir,br:this.nr,bounds:{min:{x:this.ar.min.x,y:this.ar.min.y},max:{x:this.ar.max.x,y:this.ar.max.y}}}),this.ur.push(this.sr)),this.nr=[]}Er(t,e){this.rr&&this.vr(),this.hr=new Vt(t,e),this.Tr(this.hr),this.rr={points:[this.hr],glyphIndex:this.ir}}Ir(t,e){if(!this.rr||!this.hr)return
|
|
876
|
+
const i=new Vt(t,e)
|
|
877
|
+
this.Tr(i),this.rr.points.push(i),this.hr=i}Sr(t,e,i,s){if(!this.rr||!this.hr)return
|
|
878
|
+
const n=this.hr,r=new Vt(t,e),o=new Vt(i,s)
|
|
879
|
+
if(Ne>Math.abs((r.x-o.x)*(o.y-n.y)-(r.y-o.y)*(o.x-n.x)))return void this.Ir(i,s)
|
|
880
|
+
const h=this.yr.Qn(n,r,o)
|
|
863
881
|
for(let t=0;h.length>t;t++){const e=h[t]
|
|
864
|
-
this.
|
|
865
|
-
const o=this.
|
|
866
|
-
if(
|
|
867
|
-
const f=this.
|
|
882
|
+
this.Tr(e),this.rr.points.push(e)}this.hr=o}Fr(t,e,i,s,n,r){if(!this.rr||!this.hr)return
|
|
883
|
+
const o=this.hr,h=new Vt(t,e),a=new Vt(i,s),l=new Vt(n,r),c=l.x-o.x,u=l.y-o.y
|
|
884
|
+
if(Ne>Math.abs((h.x-l.x)*u-(h.y-l.y)*c)&&Ne>Math.abs((a.x-l.x)*u-(a.y-l.y)*c))return void this.Ir(n,r)
|
|
885
|
+
const f=this.yr.tr(o,h,a,l)
|
|
868
886
|
for(let t=0;f.length>t;t++){const e=f[t]
|
|
869
|
-
this.
|
|
870
|
-
const t=this.
|
|
871
|
-
this.
|
|
872
|
-
this.
|
|
873
|
-
if(this.
|
|
887
|
+
this.Tr(e),this.rr.points.push(e)}this.hr=l}Mr(){if(!this.rr||!this.hr)return
|
|
888
|
+
const t=this.rr.points[0]
|
|
889
|
+
this.hr.equals(t)||this.rr.points.push(t),this.vr()}vr(){if(this.rr){const t=this.pr.Dn(this.rr)
|
|
890
|
+
this.nr.push(t),this.rr=null,this.hr=null}}Tr(t){this.ar.min.x=Math.min(this.ar.min.x,t.x),this.ar.min.y=Math.min(this.ar.min.y,t.y),this.ar.max.x=Math.max(this.ar.max.x,t.x),this.ar.max.y=Math.max(this.ar.max.y,t.y)}_r(){return this.nr.length>0&&this.mr(),this.lr}Or(){return this.cr}Cr(){return this.ur}reset(){this.lr=[],this.cr=[],this.ur=[],this.nr=[],this.rr=null,this.hr=null,this.ir=0,this.sr=0,this.dr.set(0,0),this.ar={min:new Vt(1/0,1/0),max:new Vt(-1/0,-1/0)}}Jn(t){this.yr.Jn(t)}Xn(t){this.yr.Xn(t)}kr(t){this.pr.Ln({...Ie,...t})}Br(){return this.pr.getStats()}}class qe{constructor(){this.Lr=null,this.Dr=null,this.Nr=null,this.Pr=null,this.$r=null,this.Gr=0,this.position={x:0,y:0}}setPosition(t,e){this.position.x=t,this.position.y=e,this.zr&&this.zr.setPosition(t,e)}wr(t,e){this.position.x+=t,this.position.y+=e,this.zr&&this.zr.wr(t,e)}Rr(t){this.zr=t}Wr(t,e){if(!t||!t.module||!t.hb)throw Error("Invalid font object")
|
|
891
|
+
if(this.zr=e,this.Gr)return
|
|
874
892
|
const i=t.module
|
|
875
|
-
this.
|
|
876
|
-
return this.
|
|
893
|
+
this.Lr=i.jr((t,e,i,s,n)=>{this.zr?.Er(s,n)},"viiiffi"),this.Dr=i.jr((t,e,i,s,n)=>{this.zr?.Ir(s,n)},"viiiffi"),this.Nr=i.jr((t,e,i,s,n,r,o)=>{this.zr?.Sr(s,n,r,o)},"viiiffffi"),this.Pr=i.jr((t,e,i,s,n,r,o,h,a)=>{this.zr?.Fr(s,n,r,o,h,a)},"viiiffffffi"),this.$r=i.jr(()=>{this.zr?.Mr()},"viiii"),this.Gr=i.exports.Ur(),i.exports.Vr(this.Gr,this.Lr,0,0),i.exports.Hr(this.Gr,this.Dr,0,0),i.exports.qr(this.Gr,this.Nr,0,0),i.exports.Yr(this.Gr,this.Pr,0,0),i.exports.Jr(this.Gr,this.$r,0,0)}Kr(){if(!this.Gr)throw Error("Draw functions not initialized")
|
|
894
|
+
return this.Gr}destroy(t){if(!t||!t.module||!t.hb)return
|
|
877
895
|
const e=t.module
|
|
878
|
-
try{this.
|
|
879
|
-
class
|
|
896
|
+
try{this.Gr&&(e.exports.Xr(this.Gr),this.Gr=0),null!==this.Lr&&(e.Qr(this.Lr),this.Lr=null),null!==this.Dr&&(e.Qr(this.Dr),this.Dr=null),null!==this.Nr&&(e.Qr(this.Nr),this.Nr=null),null!==this.Pr&&(e.Qr(this.Pr),this.Pr=null),null!==this.$r&&(e.Qr(this.$r),this.$r=null)}catch(t){st.warn("Error destroying draw callbacks:",t)}this.zr=void 0}}const Ye=new WeakMap
|
|
897
|
+
class Je{constructor(t,e){this.Zr="default",this.eo="default",this.io=new Set,this.so=[],this.no=[],this.ro=[],this.cache=t,this.oi=e,this.tessellator=new be,this.oo=new Ee,this.ho=new Te,this.zr=new He,this.ao=(()=>{const t=this.oi.module,e=Ye.get(t)
|
|
880
898
|
if(e)return e
|
|
881
|
-
const i=new
|
|
882
|
-
return
|
|
899
|
+
const i=new qe
|
|
900
|
+
return Ye.set(t,i),i})(),this.ao.Wr(this.oi,this.zr),this.lo=Jt,this.co=Kt,this.uo=Xt}Br(){return this.zr.Br()}Jn(t){this.qn=t,this.zr.Jn(t),this.fo()}Xn(t){if(null==t)this.curveSteps=void 0
|
|
883
901
|
else if(Number.isFinite(t)){const e=Math.round(t)
|
|
884
902
|
this.curveSteps=1>e?void 0:e}else this.curveSteps=void 0
|
|
885
|
-
this.
|
|
886
|
-
const t=this.
|
|
887
|
-
return`cf:${t.toFixed(4)},${e.toFixed(4)}`})(),`opt:${this.
|
|
888
|
-
for(let i=0;t.length>i;i++)e+=t[i].length}const a=this.
|
|
903
|
+
this.zr.Xn(this.curveSteps),this.fo()}kr(t){this.do=t,this.zr.kr(t),this.fo()}yo(t){this.Zr=t,this.fo()}fo(){this.eo=`${this.Zr}__${this.po()}`}po(){return[(()=>{if(void 0!==this.curveSteps)return"cf:steps:"+this.curveSteps
|
|
904
|
+
const t=this.qn?.distanceTolerance??De.distanceTolerance,e=this.qn?.angleTolerance??De.angleTolerance
|
|
905
|
+
return`cf:${t.toFixed(4)},${e.toFixed(4)}`})(),`opt:${this.do?.enabled??1?1:0},${(this.do?.areaThreshold??1).toFixed(4)}`].join("|")}wo(t,e,i,n,r,o=!1,h){if(it){let e=0
|
|
906
|
+
for(let i=0;t.length>i;i++)e+=t[i].length}const a=this.ro
|
|
889
907
|
a.length=0
|
|
890
908
|
let l=0,c=0,u=0,f=0,d=0
|
|
891
909
|
const y=(t,e,i,s)=>{const n=d
|
|
892
910
|
let r=a[l]
|
|
893
|
-
return r?(r.data=t,r.px=e,r.
|
|
911
|
+
return r?(r.data=t,r.px=e,r.mo=i,r.vo=s,r.xo=n):(r={data:t,px:e,mo:i,vo:s,xo:n},a[l]=r),l++,c+=t.vertices.length,u+=t.normals.length,f+=t.indices.length,d+=t.vertices.length/3,n},p=[],w={min:{x:1/0,y:1/0,z:0},max:{x:-1/0,y:-1/0,z:e}}
|
|
894
912
|
for(let r=0;t.length>r;r++){const a=t[r]
|
|
895
913
|
for(const t of a){const r=t.position.x,a=t.position.y,l=t.position.z,c=[]
|
|
896
|
-
for(const e of t.glyphs)c.push(this.
|
|
914
|
+
for(const e of t.glyphs)c.push(this.Ao(e.g))
|
|
897
915
|
let u
|
|
898
|
-
if(t.glyphs.length>1){const e=`${this.
|
|
916
|
+
if(t.glyphs.length>1){const e=`${this.eo}_${t.text}`,i=this.uo.get(e)
|
|
899
917
|
let s=!1
|
|
900
|
-
if(i&&i.
|
|
901
|
-
for(let e=0;t.glyphs.length>e;e++){const n=t.glyphs[e],r=i.
|
|
902
|
-
if(i.
|
|
918
|
+
if(i&&i.bo.length===t.glyphs.length){s=!0
|
|
919
|
+
for(let e=0;t.glyphs.length>e;e++){const n=t.glyphs[e],r=i.Eo[e]
|
|
920
|
+
if(i.bo[e]!==n.g||r.x!==(n.x??0)||r.y!==(n.y??0)){s=!1
|
|
903
921
|
break}}}if(s&&i)u=i.groups
|
|
904
922
|
else{const i=t.glyphs.length
|
|
905
|
-
if(i>this.
|
|
906
|
-
this.
|
|
907
|
-
for(let e=0;i>e;e++){const i=t.glyphs[e],s=this.
|
|
908
|
-
s.x=i.x??0,s.y=i.y??0,s.z=0}u=this.
|
|
923
|
+
if(i>this.so.length)for(let t=this.so.length;i>t;t++)this.so.push(new Ht(0,0,0))
|
|
924
|
+
this.so.length=i
|
|
925
|
+
for(let e=0;i>e;e++){const i=t.glyphs[e],s=this.so[e]
|
|
926
|
+
s.x=i.x??0,s.y=i.y??0,s.z=0}u=this.ho.Fn(c,this.so),this.uo.set(e,{bo:t.glyphs.map(t=>t.g),Eo:t.glyphs.map(t=>({x:t.x??0,y:t.y??0})),groups:u})}}else u=[[0]]
|
|
909
927
|
const f=o
|
|
910
928
|
let d=u
|
|
911
929
|
if(h&&h.size>0){d=[]
|
|
912
930
|
for(const e of u)if(e.length>1){const i=[],s=[]
|
|
913
|
-
for(const n of e)h.has(t.glyphs[n].
|
|
914
|
-
i.length>0&&d.push(i),s.length>0&&d.push(s)}else d.push(e)}for(const o of d)if(o.length>1&&!f){const s=o.map(e=>t.glyphs[e]),h=this.
|
|
915
|
-
let u=this.
|
|
916
|
-
if(!u){const i=this.
|
|
931
|
+
for(const n of e)h.has(t.glyphs[n].To)?i.push(n):s.push(n)
|
|
932
|
+
i.length>0&&d.push(i),s.length>0&&d.push(s)}else d.push(e)}for(const o of d)if(o.length>1&&!f){const s=o.map(e=>t.glyphs[e]),h=this.Io(s,e,i)
|
|
933
|
+
let u=this.co.get(h)
|
|
934
|
+
if(!u){const i=this.no
|
|
917
935
|
let r=0
|
|
918
936
|
const a=s[0].x??0,l=s[0].y??0
|
|
919
937
|
for(let e=0;o.length>e;e++){const s=o[e],n=c[s],h=t.glyphs[s],u=(h.x??0)-a,f=(h.y??0)-l
|
|
920
|
-
for(const t of n.
|
|
938
|
+
for(const t of n.br){const e=t.points,s=e.length
|
|
921
939
|
if(3>s)continue
|
|
922
940
|
const n=s>1&&e[0].x===e[s-1].x&&e[0].y===e[s-1].y?s-1:s,o=2*(n+1)
|
|
923
941
|
let h=i[r]
|
|
924
942
|
!h||o>h.length?(h=Array(o),i[r]=h):h.length=o
|
|
925
943
|
let a=0
|
|
926
944
|
for(let t=0;n>t;t++){const i=e[t]
|
|
927
|
-
h[a++]=i.x+u,h[a++]=i.y+f}2>a||(h[a++]=h[0],h[a++]=h[1]),r++}}i.length=r,u=this.
|
|
945
|
+
h[a++]=i.x+u,h[a++]=i.y+f}2>a||(h[a++]=h[0],h[a++]=h[1]),r++}}i.length=r,u=this.So(i,e,n),this.co.set(h,u)}const f=s[0],d=y(u,r+(f.x??0),a+(f.y??0),l),g=u.vertices.length/3
|
|
928
946
|
for(let i=0;o.length>i;i++){const s=o[i],n=t.glyphs[s],h=this.Fo(n,d,g,r+(n.x??0),a+(n.y??0),l,c[s],e)
|
|
929
|
-
p.push(h),this.
|
|
930
|
-
if(0===u.
|
|
947
|
+
p.push(h),this.Mo(h.bounds,w)}}else for(const h of o){const o=t.glyphs[h],u=c[h],f=r+(o.x??0),d=a+(o.y??0),g=l
|
|
948
|
+
if(0===u.br.length){const t=this.Fo(o,0,0,f,d,g,u,e)
|
|
931
949
|
p.push(t)
|
|
932
|
-
continue}const m=s(this.
|
|
950
|
+
continue}const m=s(this.eo,o.g,e,i)
|
|
933
951
|
let v=this.cache.get(m)
|
|
934
|
-
v?v.
|
|
935
|
-
const x=y(v,f,d,g),
|
|
936
|
-
p.push(
|
|
952
|
+
v?v._o++:(v=this.Oo(u,e,i,n),this.cache.set(m,v))
|
|
953
|
+
const x=y(v,f,d,g),A=this.Fo(o,x,v.vertices.length/3,f,d,g,u,e)
|
|
954
|
+
p.push(A),this.Mo(A.bounds,w)}}}a.length=l
|
|
937
955
|
const g=new Float32Array(c),m=new Float32Array(u),v=new Uint32Array(f)
|
|
938
|
-
let x=0,
|
|
939
|
-
for(let t=0;a.length>t;t++){const e=a[t],i=e.data.vertices,s=e.data.normals,n=e.data.indices,o=e.px*r,h=e.
|
|
956
|
+
let x=0,A=0,b=0
|
|
957
|
+
for(let t=0;a.length>t;t++){const e=a[t],i=e.data.vertices,s=e.data.normals,n=e.data.indices,o=e.px*r,h=e.mo*r,l=e.vo*r,c=i.length
|
|
940
958
|
let u=x
|
|
941
959
|
for(let t=0;c>t;t+=3)g[u]=i[t]*r+o,g[u+1]=i[t+1]*r+h,g[u+2]=i[t+2]*r+l,u+=3
|
|
942
|
-
x=u,m.set(s,
|
|
943
|
-
const f=e.
|
|
944
|
-
let y=
|
|
960
|
+
x=u,m.set(s,A),A+=s.length
|
|
961
|
+
const f=e.xo,d=n.length
|
|
962
|
+
let y=b
|
|
945
963
|
for(let t=0;d>t;t++)v[y++]=n[t]+f
|
|
946
|
-
|
|
964
|
+
b=y}w.min.x*=r,w.min.y*=r,w.min.z*=r,w.max.x*=r,w.max.y*=r,w.max.z*=r
|
|
947
965
|
for(let t=0;p.length>t;t++)p[t].bounds.min.x*=r,p[t].bounds.min.y*=r,p[t].bounds.min.z*=r,p[t].bounds.max.x*=r,p[t].bounds.max.y*=r,p[t].bounds.max.z*=r
|
|
948
|
-
return{vertices:g,normals:m,indices:v,
|
|
966
|
+
return{vertices:g,normals:m,indices:v,Co:p,planeBounds:w}}Io(t,e,i){if(0===t.length)return""
|
|
949
967
|
const s=t[0].x??0,n=t[0].y??0,r=t.map(t=>`${t.g}:${(t.x??0)-s},${(t.y??0)-n}`),o=r.join("|")
|
|
950
|
-
return`${this.
|
|
951
|
-
const e=`${this.
|
|
968
|
+
return`${this.eo}_${o}_${Math.round(1e3*e)/1e3}_${i}`}Fo(t,e,i,s,n,r,o,h){return{ko:t.To,Bo:t.Bo,xo:e,Ss:i,bounds:{min:{x:o.bounds.min.x+s,y:o.bounds.min.y+n,z:r},max:{x:o.bounds.max.x+s,y:o.bounds.max.y+n,z:r+h}}}}Ao(t){if(this.io.has(t))return{Ar:t,br:[],bounds:{min:{x:0,y:0},max:{x:0,y:0}}}
|
|
969
|
+
const e=`${this.eo}_${t}`,i=this.lo.get(e)
|
|
952
970
|
if(i)return i
|
|
953
|
-
this.
|
|
954
|
-
const s=this.
|
|
955
|
-
return 0===s.
|
|
956
|
-
return this.
|
|
971
|
+
this.ao.Rr(this.zr),this.zr.reset(),this.zr.gr(t,0),this.oi.module.exports.Lo(this.oi.font.Do,t,this.ao.Kr(),0),this.zr.mr()
|
|
972
|
+
const s=this.zr._r()[0]||{Ar:t,br:[],bounds:{min:{x:0,y:0},max:{x:0,y:0}}}
|
|
973
|
+
return 0===s.br.length&&this.io.add(t),this.lo.set(e,s),s}So(t,e,i){const s=this.tessellator.pn(t,!0,i,0!==e)
|
|
974
|
+
return this.No(s,e)}No(t,e){const i=this.oo.Sn(t,e,this.oi.upem),s=i.vertices
|
|
957
975
|
let n=1/0,r=1/0,o=1/0,h=-1/0,a=-1/0,l=-1/0
|
|
958
976
|
for(let t=0;s.length>t;t+=3){const e=s[t],i=s[t+1],c=s[t+2]
|
|
959
|
-
n>e&&(n=e),e>h&&(h=e),r>i&&(r=i),i>a&&(a=i),o>c&&(o=c),c>l&&(l=c)}const c=new
|
|
960
|
-
return{geometry:t,vertices:i.vertices,normals:i.normals,indices:i.indices,bounds:{min:c,max:u},
|
|
961
|
-
return this.
|
|
962
|
-
i.x>n.x&&(i.x=n.x),i.y>n.y&&(i.y=n.y),i.z>n.z&&(i.z=n.z),r.x>s.x&&(s.x=r.x),r.y>s.y&&(s.y=r.y),r.z>s.z&&(s.z=r.z)}
|
|
963
|
-
return t.forEach((t,o)=>{const h=this.
|
|
964
|
-
r.push(h)}),r}finally{}}
|
|
965
|
-
"rtl"===o&&h.
|
|
977
|
+
n>e&&(n=e),e>h&&(h=e),r>i&&(r=i),i>a&&(a=i),o>c&&(o=c),c>l&&(l=c)}const c=new Ht(n,r,o),u=new Ht(h,a,l)
|
|
978
|
+
return{geometry:t,vertices:i.vertices,normals:i.normals,indices:i.indices,bounds:{min:c,max:u},_o:1}}Oo(t,e,i,s){const n=this.tessellator.process(t.br,i,s,0!==e)
|
|
979
|
+
return this.No(n,e)}Mo(t,e){const i=e.min,s=e.max,n=t.min,r=t.max
|
|
980
|
+
i.x>n.x&&(i.x=n.x),i.y>n.y&&(i.y=n.y),i.z>n.z&&(i.z=n.z),r.x>s.x&&(s.x=r.x),r.y>s.y&&(s.y=r.y),r.z>s.z&&(s.z=r.z)}Po(){return this.cache.getStats()}clearCache(){this.cache.clear(),this.co.clear(),this.uo.clear(),this.lo.clear()}}class Ke{constructor(t,e){this.$o=new Map,this.oi=t,this.Go=e}zo(t,e,i,s,n,r,o){try{const r=[]
|
|
981
|
+
return t.forEach((t,o)=>{const h=this.Ro(t,o,e,i,s,n)
|
|
982
|
+
r.push(h)}),r}finally{}}Ro(e,i,s,n,r,o){const h=this.oi.hb.createBuffer()
|
|
983
|
+
"rtl"===o&&h.Wo("rtl"),h.ii(e.text),h.si()
|
|
966
984
|
const a=t(this.oi.ni)
|
|
967
985
|
this.oi.hb.shape(this.oi.font,h,a)
|
|
968
986
|
const l=h.json(this.oi.font)
|
|
969
987
|
h.destroy()
|
|
970
988
|
const c=[]
|
|
971
989
|
let u=[],f=[],d=0,y=0,p=e.Ye,w=-i*s
|
|
972
|
-
const g=n*this.oi.upem,m=this.
|
|
990
|
+
const g=n*this.oi.upem,m=this.jo(e,r,n),v=this.Uo(e,r),x=e.text,A=x.length,b=l.length
|
|
973
991
|
let E
|
|
974
|
-
for(let t=0;
|
|
975
|
-
s.
|
|
992
|
+
for(let t=0;b>t;t++){const s=l[t],n=s.ri,r=x[n],o=r.charCodeAt(0),h=32===o||9===o||10===o||13===o
|
|
993
|
+
s.To=e.Ke&&n===A-1&&"-"===r?e.qe:e.He+n,s.Bo=i,h&&u.length>0&&(c.push({text:f.join(""),glyphs:u,position:new Ht(d,y,0)}),u=[],f=[])
|
|
976
994
|
const a=p+s.dx,T=w+s.dy
|
|
977
|
-
if(h||(0===u.length&&(d=a,y=T),s.x=a-d,s.y=T-y,u.push(s),f.push(r)),p+=s.ax,w+=s.ay,0!==g&&
|
|
978
|
-
if(E=!!e&&
|
|
979
|
-
|
|
980
|
-
if(void 0!==t.ei&&"justify"===e&&!t.Je){let e=this.
|
|
981
|
-
void 0===e&&(e=
|
|
982
|
-
return t.ei>0||0>t.ei?.04*t.ei*this.oi.upem:0}clearCache(){this.
|
|
995
|
+
if(h||(0===u.length&&(d=a,y=T),s.x=a-d,s.y=T-y,u.push(s),f.push(r)),p+=s.ax,w+=s.ay,0!==g&&b-1>t&&(p+=g),h&&(p+=m),0!==v&&b-1>t&&!h){const e=x[l[t+1].ri],i=void 0!==E?E:xt.fe(r)
|
|
996
|
+
if(E=!!e&&xt.fe(e),i&&E){let t=!0
|
|
997
|
+
xt.de(e)&&(t=!1),xt.ye(r)&&(t=!1),xt.pe(r)&&xt.pe(e)&&(t=!1),t&&(p+=v)}}else E=void 0}return u.length>0&&c.push({text:f.join(""),glyphs:u,position:new Ht(d,y,0)}),c}jo(t,e,i){let s=0
|
|
998
|
+
if(void 0!==t.ei&&"justify"===e&&!t.Je){let e=this.$o.get(i)
|
|
999
|
+
void 0===e&&(e=bt.measureTextWidth(this.oi," ",i),this.$o.set(i,e)),t.ei>0?s=t.ei*e*.5:0>t.ei&&(s=t.ei*e*ht)}return s}Uo(t,e){if(void 0===t.ei||"justify"!==e||t.Je)return 0
|
|
1000
|
+
return t.ei>0||0>t.ei?.04*t.ei*this.oi.upem:0}clearCache(){this.Go.clearCache()}Po(){return this.Go.Po()}}var Xe={exports:{}},Qe=tt(Object.freeze({__proto__:null,default:{},it(...t){const e="undefined"!=typeof globalThis?globalThis.require:void 0
|
|
983
1001
|
if("function"==typeof e)return e("fs").it(...t)
|
|
984
1002
|
throw Error("fs not available in this environment")}}))
|
|
985
1003
|
!(function(t){var e,i=(e="undefined"!=typeof document?document.currentScript?.src:void 0,async function(t={}){function i(){var t=g.buffer
|
|
986
|
-
n.HEAP8=new Int8Array(t),n.HEAPU8=m=new Uint8Array(t),n.HEAP32=new Int32Array(t),n.HEAPU32=new Uint32Array(t),n.HEAPF32=new Float32Array(t),new BigInt64Array(t),new BigUint64Array(t)}function s(t){n.
|
|
1004
|
+
n.HEAP8=new Int8Array(t),n.HEAPU8=m=new Uint8Array(t),n.HEAP32=new Int32Array(t),n.HEAPU32=new Uint32Array(t),n.HEAPF32=new Float32Array(t),new BigInt64Array(t),new BigUint64Array(t)}function s(t){n.Vo?.(t),x(t="Aborted("+t+")"),A=!0,t+=". Build with -sASSERTIONS for more info."
|
|
987
1005
|
var e=new WebAssembly.RuntimeError(t)
|
|
988
1006
|
throw w?.(e),e}var n=t,r="object"==typeof window,o="undefined"!=typeof WorkerGlobalScope,h="object"==typeof process&&process.versions?.node&&"renderer"!=process.type,a=(t,e)=>{throw e}
|
|
989
1007
|
"undefined"!=typeof __filename?e=__filename:o&&(e=self.location.href)
|
|
990
1008
|
var l,c,u=""
|
|
991
|
-
if(h){var f=
|
|
992
|
-
u="undefined"!=typeof __dirname?__dirname+"/":"",c=t=>(t=
|
|
993
|
-
return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),l=async t=>{if(
|
|
1009
|
+
if(h){var f=Qe
|
|
1010
|
+
u="undefined"!=typeof __dirname?__dirname+"/":"",c=t=>(t=b(t)?new URL(t):t,f.it(t)),l=async(t,e=!0)=>(t=b(t)?new URL(t):t,f.it(t,e?void 0:"utf8")),process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),a=(t,e)=>{throw process.exitCode=t,e}}else if(r||o){try{u=new URL(".",e).href}catch{}o&&(c=t=>{var e=new XMLHttpRequest
|
|
1011
|
+
return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),l=async t=>{if(b(t))return new Promise((e,i)=>{var s=new XMLHttpRequest
|
|
994
1012
|
s.open("GET",t,!0),s.responseType="arraybuffer",s.onload=()=>{200==s.status||0==s.status&&s.response?e(s.response):i(s.status)},s.onerror=i,s.send(null)})
|
|
995
1013
|
var e=await fetch(t,{credentials:"same-origin"})
|
|
996
1014
|
if(e.ok)return e.arrayBuffer()
|
|
997
1015
|
throw Error(e.status+" : "+e.url)}}console.log.bind(console)
|
|
998
|
-
var d,y,p,w,g,m,v,x=console.error.bind(console),
|
|
999
|
-
class
|
|
1000
|
-
constructor(t){this.message=`Program terminated with exit(${t})`,this.status=t}}var
|
|
1001
|
-
a(1,t)},G=()=>
|
|
1016
|
+
var d,y,p,w,g,m,v,x=console.error.bind(console),A=!1,b=t=>t.startsWith("file://"),E=!1,T=0,I=null
|
|
1017
|
+
class S{name="ExitStatus"
|
|
1018
|
+
constructor(t){this.message=`Program terminated with exit(${t})`,this.status=t}}var F,M,_,O=t=>{for(;t.length>0;)t.shift()(n)},C=[],k=t=>C.push(t),B=[],L=t=>B.push(t),D=!0,N=0,P={},$=t=>{if(t instanceof S||"unwind"==t)return y
|
|
1019
|
+
a(1,t)},G=()=>D||N>0,z=t=>{y=t,G()||(n.Ho?.(t),A=!0),a(t,new S(t))},R=(t,e)=>Math.ceil(t/e)*e,W=t=>{var e=(t-g.buffer.byteLength+65535)/65536|0
|
|
1002
1020
|
try{return g.grow(e),i(),1}catch(t){}},j=t=>{const e=t.length
|
|
1003
|
-
return[e%128|128,e>>7,...t]},U={o:127,_:127,q:126,f:125,d:124,e:111},V=t=>j(Array.from(t,t=>U[t])),H=t=>
|
|
1004
|
-
n.
|
|
1005
|
-
s&&
|
|
1021
|
+
return[e%128|128,e>>7,...t]},U={o:127,_:127,q:126,f:125,d:124,e:111},V=t=>j(Array.from(t,t=>U[t])),H=t=>F.get(t),q=[],Y=(t,e)=>F.set(t,e)
|
|
1022
|
+
n.qo&&(D=n.qo),n.Yo&&(x=n.Yo),n.Jo&&(d=n.Jo),n.Ko=g,n.Xo=K,n.jr=(t,e)=>{var i=(t=>(M||(M=new WeakMap,((t,e)=>{if(M)for(var i=0;0+e>i;i++){var s=H(i)
|
|
1023
|
+
s&&M.set(s,i)}})(0,F.length)),M.get(t)||0))(t)
|
|
1006
1024
|
if(i)return i
|
|
1007
|
-
var s=q.length?q.pop():
|
|
1025
|
+
var s=q.length?q.pop():F.grow(1)
|
|
1008
1026
|
try{Y(s,t)}catch(i){if(!(i instanceof TypeError))throw i
|
|
1009
1027
|
var n=((t,e)=>{var i=Uint8Array.of(0,97,115,109,1,0,0,0,1,...j([1,96,...V(e.slice(1)),...V("v"===e[0]?"":e[0])]),2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0),s=new WebAssembly.Module(i)
|
|
1010
1028
|
return new WebAssembly.Instance(s,{e:{f:t}}).exports.f})(t,e)
|
|
1011
|
-
Y(s,n)}return
|
|
1012
|
-
var J={
|
|
1013
|
-
var i=setTimeout(()=>{delete
|
|
1014
|
-
return
|
|
1029
|
+
Y(s,n)}return M.set(t,s),s},n.Qr=t=>{M.delete(H(t)),Y(t,null),q.push(t)}
|
|
1030
|
+
var J={Qo:()=>s(""),Zo(){D=!1,N=0},th(t,e){if(P[t]&&(clearTimeout(P[t].id),delete P[t]),!e)return 0
|
|
1031
|
+
var i=setTimeout(()=>{delete P[t],(t=>{if(!A)try{t(),(()=>{if(!G())try{y=t=y,z(t)}catch(t){$(t)}var t})()}catch(t){$(t)}})(()=>_(t,performance.now()))},e)
|
|
1032
|
+
return P[t]={id:i,eh:e},0},ih(t){var e=m.length,i=2147483648
|
|
1015
1033
|
if((t>>>=0)>i)return!1
|
|
1016
1034
|
for(var s=1;4>=s;s*=2){var n=e*(1+.2/s),r=Math.min(i,R(Math.max(t,n=Math.min(n,t+100663296)),65536))
|
|
1017
|
-
if(W(r))return!0}return!1},
|
|
1018
|
-
|
|
1019
|
-
var e,r={nt:J,
|
|
1020
|
-
return n.
|
|
1035
|
+
if(W(r))return!0}return!1},sh:z},K=await(async()=>{function t(t){return n.Xo=K=t.exports,n.Ko=g=K.memory,i(),F=K.nh,(t=>{n.rh=t.oh,n.hh=t.ah,n.uh=t.fh,n.dh=t.yh,n.ph=t.wh,n.gh=t.mh,n.xh=t.Ah,n.bh=t.Eh,n.Th=t.Ih,n.Sh=t.Fh,n.Mh=t._h,n.Oh=t.Ch,n.kh=t.Bh,n.Lh=t.Dh,n.Nh=t.Ph,n.$h=t.Gh,n.zh=t.Rh,n.Wh=t.jh,n.Uh=t.Vh,n.Hh=t.qh,n.Yh=t.Jh,n.Kh=t.Xh,n.Qh=t.Zh,n.ta=t.ea,n.ia=t.sa,n.na=t.ra,n.oa=t.ha,n.aa=t.la,n.ca=t.Vr,n.ua=t.Hr,n.fa=t.qr,n.da=t.Yr,n.ya=t.Jr,n.pa=t.Ur,n.wa=t.Xr,n.ga=t.ma,n.va=t.xa,n.Aa=t.ba,n.Ea=t.Ta,n.Ia=t.Sa,n.Fa=t.Lo,n.Ma=t._a,n.Oa=t.Ca,n.ka=t.Ba,n.La=t.Da,n.Na=t.Pa,n.$a=t.Ga,n.za=t.Ra,n.Wa=t.ja,n.Ua=t.Va,n.Ha=t.qa,n.Ya=t.Ja,_=t.Ka})(K),(()=>{if(T--,n.Xa?.(T),0==T&&I){var t=I
|
|
1036
|
+
I=null,t()}})(),K}T++,n.Xa?.(T)
|
|
1037
|
+
var e,r={nt:J,Qa:J}
|
|
1038
|
+
return n.Za?new Promise(e=>{n.Za(r,i=>{e(t(i))})}):(v??=(e="hb.wasm",n.tl?n.tl(e,u):u+e),t((await(async function(t,e,i){if(!t&&!b(e)&&!h)try{var n=fetch(e,{credentials:"same-origin"})
|
|
1021
1039
|
return await WebAssembly.instantiateStreaming(n,i)}catch(t){x("wasm streaming compile failed: "+t),x("falling back to ArrayBuffer instantiation")}return(async(t,e)=>{try{var i=await(async t=>{if(!d)try{var e=await l(t)
|
|
1022
1040
|
return new Uint8Array(e)}catch{}return(t=>{if(t==v&&d)return new Uint8Array(d)
|
|
1023
1041
|
if(c)return c(t)
|
|
1024
1042
|
throw"both async and sync fetching of the wasm failed"})(t)})(t)
|
|
1025
|
-
return await WebAssembly.instantiate(i,e)}catch(t){x("failed to asynchronously prepare wasm: "+t),s(t)}})(e,i)})(d,v,r)).
|
|
1026
|
-
return(()=>{if(n.
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
t.exports=i,t.exports.default=i})(
|
|
1030
|
-
var
|
|
1031
|
-
try{
|
|
1043
|
+
return await WebAssembly.instantiate(i,e)}catch(t){x("failed to asynchronously prepare wasm: "+t),s(t)}})(e,i)})(d,v,r)).el))})()
|
|
1044
|
+
return(()=>{if(n.il)for("function"==typeof n.il&&(n.il=[n.il]);n.il.length>0;)n.il.shift()()})(),(function t(){function e(){n.sl=!0,A||(E=!0,K.nl(),p?.(n),n.rl?.(),(()=>{if(n.ol)for("function"==typeof n.ol&&(n.ol=[n.ol]);n.ol.length;)k(n.ol.shift())
|
|
1045
|
+
O(C)})())}T>0?I=t:((()=>{if(n.hl)for("function"==typeof n.hl&&(n.hl=[n.hl]);n.hl.length;)L(n.hl.shift())
|
|
1046
|
+
O(B)})(),T>0?I=t:n.setStatus?(n.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>n.setStatus(""),1),e()},1)):e())})(),E?n:new Promise((t,e)=>{p=t,w=e})})
|
|
1047
|
+
t.exports=i,t.exports.default=i})(Xe)
|
|
1048
|
+
var Ze=Z(Xe.exports),ti={exports:{}}
|
|
1049
|
+
try{ti.exports=t=>{function e(t){return(255&t.charCodeAt(0))<<24|(255&t.charCodeAt(1))<<16|(255&t.charCodeAt(2))<<8|255&t.charCodeAt(3)}function i(e){var i=n.ha(e.length+1)
|
|
1032
1050
|
for(let s=0;e.length>s;++s){const n=e.charCodeAt(s)
|
|
1033
1051
|
if(n>127)throw Error("Expected ASCII text")
|
|
1034
|
-
t.HEAPU8[i+s]=n}return t.HEAPU8[i+e.length]=0,{
|
|
1035
|
-
s&&(s=s.split(","),r=n.
|
|
1036
|
-
n.
|
|
1037
|
-
let o=t.
|
|
1038
|
-
var a=o(t=>{n.
|
|
1039
|
-
return{Ki(e){var i=n.
|
|
1052
|
+
t.HEAPU8[i+s]=n}return t.HEAPU8[i+e.length]=0,{Do:i,length:e.length,la(){n.la(i)}}}function s(t,e,s){var r=0,o=0
|
|
1053
|
+
s&&(s=s.split(","),r=n.ha(16*s.length),s.forEach(t=>{var e=i(t)
|
|
1054
|
+
n.ra(e.Do,-1,r+16*o)&&o++,e.la()})),n.Ja(t.Do,e.Do,r,o),r&&n.la(r)}var n=t.Xo,r=new TextDecoder("utf8")
|
|
1055
|
+
let o=t.jr,h=t.Qr
|
|
1056
|
+
var a=o(t=>{n.la(t)},"vi"),l=e("JSON"),c="",u=n.ha(256)
|
|
1057
|
+
return{Ki(e){var i=n.ha(e.byteLength)
|
|
1040
1058
|
t.HEAPU8.set(new Uint8Array(e),i)
|
|
1041
|
-
var s=n.
|
|
1042
|
-
return{
|
|
1043
|
-
const o=n.
|
|
1044
|
-
return{
|
|
1045
|
-
if(o){var h=n.
|
|
1046
|
-
return t.HEAPU8.subarray(h,h+o)}},ts(){var e=n.
|
|
1047
|
-
t.HEAPU32[i/4]=64,n.
|
|
1059
|
+
var s=n.oh(i,e.byteLength,2,i,a)
|
|
1060
|
+
return{Do:s,destroy(){n.ah(s)}}},Xi(i,s){var r=n.ma(i.Do,s)
|
|
1061
|
+
const o=n.Ta(r)
|
|
1062
|
+
return{Do:r,upem:o,al(i){var s=n.ba(r,e(i)),o=n.fh(s)
|
|
1063
|
+
if(o){var h=n.yh(s,null)
|
|
1064
|
+
return t.HEAPU8.subarray(h,h+o)}},ts(){var e=n.ha(2048),i=n.ha(4)
|
|
1065
|
+
t.HEAPU32[i/4]=64,n.ja(r,0,i,e)
|
|
1048
1066
|
var s={}
|
|
1049
1067
|
return Array.from({length:t.HEAPU32[i/4]}).forEach((i,n)=>{var r
|
|
1050
|
-
s[(r=t.HEAPU32[e/4+8*n+1],""+String.fromCharCode(r>>24&255)+String.fromCharCode(r>>16&255)+String.fromCharCode(r>>8&255)+String.fromCharCode(255&r))]={min:t.HEAPF32[e/4+8*n+4],default:t.HEAPF32[e/4+8*n+5],max:t.HEAPF32[e/4+8*n+6]}}),n.
|
|
1051
|
-
n.
|
|
1052
|
-
var i=(e=>{const i=n.
|
|
1053
|
-
return t.HEAPU32.set(o,r),n.
|
|
1054
|
-
return n.
|
|
1055
|
-
return{
|
|
1068
|
+
s[(r=t.HEAPU32[e/4+8*n+1],""+String.fromCharCode(r>>24&255)+String.fromCharCode(r>>16&255)+String.fromCharCode(r>>8&255)+String.fromCharCode(255&r))]={min:t.HEAPF32[e/4+8*n+4],default:t.HEAPF32[e/4+8*n+5],max:t.HEAPF32[e/4+8*n+6]}}),n.la(i),n.la(e),s},ll(){var e=n.Ga()
|
|
1069
|
+
n.Sa(r,e)
|
|
1070
|
+
var i=(e=>{const i=n.Va(e),s=n.ha(i<<2),r=s>>2,o=t.HEAPU32.subarray(r,r+i)
|
|
1071
|
+
return t.HEAPU32.set(o,r),n.qa(e,-1,s,i),o})(e)
|
|
1072
|
+
return n.Ra(e),i},destroy(){n.xa(r)}}},Qi(i){function s(t){return l||(f=o((t,e,i,s,n)=>{c+=`M${s},${n}`},"viiiffi"),d=o((t,e,i,s,n)=>{c+=`L${s},${n}`},"viiiffi"),y=o((t,e,i,s,n,r,o,h,a)=>{c+=`C${s},${n} ${r},${o} ${h},${a}`},"viiiffffffi"),p=o((t,e,i,s,n,r,o)=>{c+=`Q${s},${n} ${r},${o}`},"viiiffffi"),w=o(()=>{c+="Z"},"viiii"),l=n.Ur(),n.Vr(l,f,0,0),n.Hr(l,d,0,0),n.Yr(l,y,0,0),n.qr(l,p,0,0),n.Jr(l,w,0,0)),c="",n.Lo(a,t,l,0),c}var a=n.Ca(i.Do),l=null,f=null,d=null,y=null,p=null,w=null
|
|
1073
|
+
return{Do:a,cl(e){n._a(a,e,u,256)
|
|
1056
1074
|
var i=t.HEAPU8.subarray(u,u+256)
|
|
1057
|
-
return r.decode(i.slice(0,i.indexOf(0)))},
|
|
1058
|
-
return{type:e[0],values:e.slice(1).filter(t=>t.length).map(t=>+t)}}),setScale(t,e){n.
|
|
1059
|
-
s.forEach((i,s)=>{t.HEAPU32[r/4+2*s+0]=e(i[0]),t.HEAPF32[r/4+2*s+1]=i[1]}),n.
|
|
1060
|
-
return{
|
|
1075
|
+
return r.decode(i.slice(0,i.indexOf(0)))},ul:s,fl:t=>s(t).replace(/([MLQCZ])/g,"|$1 ").split("|").filter(t=>t.length).map(t=>{var e=t.split(/[ ,]/g)
|
|
1076
|
+
return{type:e[0],values:e.slice(1).filter(t=>t.length).map(t=>+t)}}),setScale(t,e){n.Pa(a,t,e)},Zi(i){var s=Object.entries(i),r=n.ha(8*s.length)
|
|
1077
|
+
s.forEach((i,s)=>{t.HEAPU32[r/4+2*s+0]=e(i[0]),t.HEAPF32[r/4+2*s+1]=i[1]}),n.Ba(a,r,s.length),n.la(r)},destroy(){n.Da(a),l&&(n.Xr(l),l=null,h(f),h(d),h(y),h(p),h(w))}}},createBuffer(){var e=n.mh()
|
|
1078
|
+
return{Do:e,ii(i){const s=(e=>{const i=n.ha(2*e.length),s=new Uint16Array(t.Ko.buffer,i,e.length)
|
|
1061
1079
|
for(let t=0;s.length>t;++t)s[t]=e.charCodeAt(t)
|
|
1062
|
-
return{
|
|
1063
|
-
n.
|
|
1064
|
-
t.forEach(t=>{i|=(t=>"BOT"==t?1:"EOT"==t?2:"PRESERVE_DEFAULT_IGNORABLES"==t?4:"REMOVE_DEFAULT_IGNORABLES"==t?8:"DO_NOT_INSERT_DOTTED_CIRCLE"==t?16:"PRODUCE_UNSAFE_TO_CONCAT"==t?64:0)(t)}),n.
|
|
1065
|
-
n.
|
|
1066
|
-
n.Fh(e,n.
|
|
1067
|
-
return s},destroy(){n.
|
|
1068
|
-
return o.startsWith("start table GSUB")?d=1:o.startsWith("start table GPOS")&&(d=2),d!=u&&(y=!1),0!=u&&d==u&&o.startsWith("end lookup "+c)&&(y=!0),y?0:(n.
|
|
1069
|
-
return n.
|
|
1070
|
-
n.
|
|
1071
|
-
var i={
|
|
1072
|
-
return n.
|
|
1073
|
-
return r.decode(t.HEAPU8.subarray(e,t.HEAPU8.indexOf(0,e)))}}}}catch(h){}var
|
|
1074
|
-
let
|
|
1075
|
-
const
|
|
1076
|
-
if(
|
|
1077
|
-
else{if(!
|
|
1078
|
-
e.
|
|
1079
|
-
t({hb:
|
|
1080
|
-
class
|
|
1081
|
-
e.push(t),this.
|
|
1082
|
-
return t.
|
|
1080
|
+
return{Do:i,length:s.length,la(){n.la(i)}}})(i)
|
|
1081
|
+
n.qh(e,s.Do,s.length,0,s.length),s.la()},si:()=>n.jh(e),Wo(t){n.Ih(e,{dl:4,yl:5,pl:6,wl:7}[t]||0)},gl(t){var i=0
|
|
1082
|
+
t.forEach(t=>{i|=(t=>"BOT"==t?1:"EOT"==t?2:"PRESERVE_DEFAULT_IGNORABLES"==t?4:"REMOVE_DEFAULT_IGNORABLES"==t?8:"DO_NOT_INSERT_DOTTED_CIRCLE"==t?16:"PRODUCE_UNSAFE_TO_CONCAT"==t?64:0)(t)}),n.Ch(e,i)},ml(t){var s=i(t)
|
|
1083
|
+
n._h(e,n.Xh(s.Do,-1)),s.la()},vl(t){var s=i(t)
|
|
1084
|
+
n.Fh(e,n.Zh(s.Do,-1)),s.la()},xl(t){n.Bh(e,t)},json(){for(var i=n.Dh(e),s=[],r=n.Ph(e,0),o=r/4,h=n.Gh(e,0)/4,a=t.HEAPU32.subarray(o,o+5*i),l=t.HEAP32.subarray(h,h+5*i),c=0;i>c;++c)s.push({g:a[5*c+0],ri:a[5*c+2],ax:l[5*c+0],ay:l[5*c+1],dx:l[5*c+2],dy:l[5*c+3],flags:n.Rh(r+20*c)})
|
|
1085
|
+
return s},destroy(){n.Ah(e)}}},shape:s,Al(e,i,a,c,u){var f=[],d=0,y=!1,p=1048576,w=n.ha(p),g=o((e,i,s)=>{var o=r.decode(t.HEAPU8.subarray(s,t.HEAPU8.indexOf(0,s)))
|
|
1086
|
+
return o.startsWith("start table GSUB")?d=1:o.startsWith("start table GPOS")&&(d=2),d!=u&&(y=!1),0!=u&&d==u&&o.startsWith("end lookup "+c)&&(y=!0),y?0:(n.wh(e,0,n.Dh(e),w,p,0,i,l,4),f.push({k:o,i:JSON.parse(r.decode(t.HEAPU8.subarray(w,t.HEAPU8.indexOf(0,w)))),glyphs:2==n.Eh(e)}),1)},"iiiii")
|
|
1087
|
+
return n.Jh(i.Do,g,0,0),s(e,i,a),n.la(w),h(g),f},version(){var e=n.ha(12)
|
|
1088
|
+
n.ea(e,e+4,e+8)
|
|
1089
|
+
var i={bl:t.HEAPU32[e/4],El:t.HEAPU32[(e+4)/4],Tl:t.HEAPU32[(e+8)/4]}
|
|
1090
|
+
return n.la(e),i},Il(){var e=n.sa()
|
|
1091
|
+
return r.decode(t.HEAPU8.subarray(e,t.HEAPU8.indexOf(0,e)))}}}}catch(h){}var ei=Z(ti.exports)
|
|
1092
|
+
let ii=null,si=null,ni=null
|
|
1093
|
+
const ri={Sl(t){si=t,ni=null,ii=null},Fl(t){ni=t,si=null,ii=null},Ml:async()=>ii||(ii=new Promise(async(t,e)=>{try{const e={}
|
|
1094
|
+
if(ni)e.Jo=ni
|
|
1095
|
+
else{if(!si)throw Error("HarfBuzz WASM path or buffer must be set before initialization.")
|
|
1096
|
+
e.Jo=await Q(si)}const i=await Ze(e)
|
|
1097
|
+
t({hb:ei(i),module:{jr:i.jr,exports:i.Xo,Qr:i.Qr}})}catch(t){e(Error("Failed to initialize HarfBuzz: "+t))}}),ii)}
|
|
1098
|
+
class oi{constructor(t,e){this.text=t,this._l=new Map,e.forEach(t=>{const e=this._l.get(t.ko)||[]
|
|
1099
|
+
e.push(t),this._l.set(t.ko,e)})}Ol(t){const e=[]
|
|
1100
|
+
return t.Cl&&e.push(...this.kl(t.Cl)),t.Bl&&e.push(...this.Ll(t.Bl)),e}kl(t){const e=[]
|
|
1083
1101
|
for(const i of t){let t=0
|
|
1084
|
-
for(;-1!==(t=this.text.indexOf(i,t));)e.push(this.createTextRange(t,t+i.length,i)),t+=i.length}return e}
|
|
1102
|
+
for(;-1!==(t=this.text.indexOf(i,t));)e.push(this.createTextRange(t,t+i.length,i)),t+=i.length}return e}Ll(t){return t.map(t=>{const e=this.text.slice(t.start,t.end)
|
|
1085
1103
|
return this.createTextRange(t.start,t.end,e)})}createTextRange(t,e,i){const s=[],n=new Map
|
|
1086
|
-
for(let i=t;e>i;i++){const t=this.
|
|
1104
|
+
for(let i=t;e>i;i++){const t=this._l.get(i)
|
|
1087
1105
|
if(t)for(const e of t){s.push(e)
|
|
1088
|
-
const t=n.get(e.
|
|
1089
|
-
t.push(e),n.set(e.
|
|
1106
|
+
const t=n.get(e.Bo)||[]
|
|
1107
|
+
t.push(e),n.set(e.Bo,t)}}return{start:t,end:e,Dl:i,bounds:Array.from(n.values()).map(t=>this.Nl(t)),glyphs:s,Pl:Array.from(n.keys()).sort((t,e)=>t-e)}}Nl(t){if(0===t.length)return{min:{x:0,y:0,z:0},max:{x:0,y:0,z:0}}
|
|
1090
1108
|
let e=1/0,i=1/0,s=1/0,n=-1/0,r=-1/0,o=-1/0
|
|
1091
1109
|
for(const h of t)e>h.bounds.min.x&&(e=h.bounds.min.x),i>h.bounds.min.y&&(i=h.bounds.min.y),s>h.bounds.min.z&&(s=h.bounds.min.z),h.bounds.max.x>n&&(n=h.bounds.max.x),h.bounds.max.y>r&&(r=h.bounds.max.y),h.bounds.max.z>o&&(o=h.bounds.max.z)
|
|
1092
|
-
return{min:{x:e,y:i,z:s},max:{x:n,y:r,z:o}}}}const
|
|
1093
|
-
class
|
|
1110
|
+
return{min:{x:e,y:i,z:s},max:{x:n,y:r,z:o}}}}const hi=72
|
|
1111
|
+
class ai{static{this.$l=new Map}static{this.Gl=null}static{this.zl=new Map}static{this.Rl=0}static{this.Wl=1/0}static{this.jl=0}static Ul(t){(t=>{zt=t})(t)}static Vl(t){const e=Object.keys(t).sort()
|
|
1094
1112
|
let i=""
|
|
1095
1113
|
for(let s=0;e.length>s;s++)s>0&&(i+=","),i+=e[s]+":"+t[e[s]]
|
|
1096
|
-
return i}constructor(){this.
|
|
1097
|
-
|
|
1098
|
-
const e=await
|
|
1099
|
-
i.
|
|
1100
|
-
const s=await i.
|
|
1114
|
+
return i}constructor(){this.Hl="",ai.Gl||(ai.Gl=ri.Ml()),this.ql=new Wt(()=>ai.Gl)}static Yl(t){ri.Sl(t),ai.Gl=null}static Jl(t){ri.Fl(t),ai.Gl=null}static init(){return ai.Gl||(ai.Gl=ri.Ml()),ai.Gl}static async create(t){if(!t.font)throw Error("Font is required. Specify options.font as a URL string or ArrayBuffer.")
|
|
1115
|
+
ai.Gl||(ai.Gl=ri.Ml())
|
|
1116
|
+
const e=await ai.Kl(t),i=new ai
|
|
1117
|
+
i.Xl(e)
|
|
1118
|
+
const s=await i.Ql(t),n=async e=>{const s={...t}
|
|
1101
1119
|
for(const t in e){const i=e[t]
|
|
1102
|
-
void 0!==i&&(s[t]=i)}if(void 0!==e.font||void 0!==e.es||void 0!==e.ni){const t=await
|
|
1103
|
-
i.
|
|
1104
|
-
return{...s,getLoadedFont(){return i.getLoadedFont()},getCacheSize(){return i.getCacheSize()},clearCache(){return i.clearCache()},measureTextWidth(t,e){return i.measureTextWidth(t,e)},update:n}}static async
|
|
1105
|
-
t.es&&(e+="_var_"+
|
|
1106
|
-
let i=
|
|
1107
|
-
return i||(i=await
|
|
1120
|
+
void 0!==i&&(s[t]=i)}if(void 0!==e.font||void 0!==e.es||void 0!==e.ni){const t=await ai.Kl(s)
|
|
1121
|
+
i.Xl(t),i.Zl()}return t=s,{...await i.Ql(t),getLoadedFont(){return i.getLoadedFont()},getCacheSize(){return i.getCacheSize()},clearCache(){return i.clearCache()},measureTextWidth(t,e){return i.measureTextWidth(t,e)},update:n}}
|
|
1122
|
+
return{...s,getLoadedFont(){return i.getLoadedFont()},getCacheSize(){return i.getCacheSize()},clearCache(){return i.clearCache()},measureTextWidth(t,e){return i.measureTextWidth(t,e)},update:n}}static async Kl(t){let e="string"==typeof t.font?t.font:"buffer-"+ai.tc(t.font)
|
|
1123
|
+
t.es&&(e+="_var_"+ai.Vl(t.es)),t.ni&&(e+="_feat_"+ai.Vl(t.ni))
|
|
1124
|
+
let i=ai.zl.get(e)
|
|
1125
|
+
return i||(i=await ai.ec(e,t.font,t.es,t.ni)),i}static async ec(t,e,i,s){const n=new ai
|
|
1108
1126
|
await n.Ji(e,i,s)
|
|
1109
1127
|
const r=n.getLoadedFont()
|
|
1110
|
-
return
|
|
1111
|
-
e&&(
|
|
1128
|
+
return ai.zl.set(t,r),ai.sc(r),ai.nc(),r}static sc(t){ai.Rl+=t.ls?.byteLength??0}static rc(t){const e=ai.zl.get(t)
|
|
1129
|
+
e&&(ai.Rl-=e.ls?.byteLength??0,0>ai.Rl&&(ai.Rl=0))}static nc(){if(ai.Wl!==1/0)for(;ai.Rl>ai.Wl&&ai.zl.size>0;){const t=ai.zl.keys().next().value
|
|
1112
1130
|
if(void 0===t)break
|
|
1113
|
-
|
|
1131
|
+
ai.rc(t),ai.zl.delete(t)}}static tc(t){if(t){const e=new Uint8Array(t)
|
|
1114
1132
|
let i=2166136261
|
|
1115
1133
|
const s=Math.min(32,e.length),n=Math.floor(e.length/s)
|
|
1116
1134
|
for(let t=0;s>t;t++)i^=e[t*n],i=Math.imul(i,16777619)
|
|
1117
|
-
return i^=e.length,i=Math.imul(i,16777619),(i>>>0).toString(36)}return"c"+ ++
|
|
1118
|
-
const e=
|
|
1119
|
-
this.
|
|
1120
|
-
const s="string"==typeof t?await
|
|
1121
|
-
try{this.oi&&this.destroy(),this.oi=await this.
|
|
1122
|
-
const t=
|
|
1123
|
-
this.
|
|
1124
|
-
const e=await this.
|
|
1125
|
-
this.
|
|
1135
|
+
return i^=e.length,i=Math.imul(i,16777619),(i>>>0).toString(36)}return"c"+ ++ai.jl}Xl(t){this.oi=t
|
|
1136
|
+
const e=ai.tc(t.ls)
|
|
1137
|
+
this.Hl="font_"+e,t.es&&(this.Hl+="_var_"+ai.Vl(t.es)),t.ni&&(this.Hl+="_feat_"+ai.Vl(t.ni))}async Ji(t,e,i){ai.Gl||(ai.Gl=ri.Ml()),await ai.Gl
|
|
1138
|
+
const s="string"==typeof t?await Q(t):t
|
|
1139
|
+
try{this.oi&&this.destroy(),this.oi=await this.ql.Ji(s,e),i&&(this.oi.ni=i)
|
|
1140
|
+
const t=ai.tc(s)
|
|
1141
|
+
this.Hl="font_"+t,e&&(this.Hl+="_var_"+ai.Vl(e)),i&&(this.Hl+="_feat_"+ai.Vl(i))}catch(t){throw st.error("Failed to load font:",t),t}}async Ql(t){try{if(!this.oi)throw Error("Font not loaded. Use Text.create() with a font option.")
|
|
1142
|
+
const e=await this.oc(t)
|
|
1143
|
+
this.hc(e),this.ac(t=e),this.Go||(this.Go=new Je(Yt,this.oi),this.Go.yo(this.Hl))
|
|
1126
1144
|
const i=null!=t.curveSteps&&t.curveSteps>0
|
|
1127
|
-
this.
|
|
1128
|
-
const s=this.
|
|
1145
|
+
this.Go.Xn(t.curveSteps),this.Go.Jn(i?void 0:t.curveFidelity),this.Go.kr(t.geometryOptimization),this.oi.font.setScale(this.oi.upem,this.oi.upem),this.lc||(this.lc=new Ke(this.oi,this.Go))
|
|
1146
|
+
const s=this.cc(t),n=t.uc??this.oi.ss??!1,r=this.lc.zo(s.lines,s.fc,s.letterSpacing,s.align,s.direction,t.color,t.text)
|
|
1129
1147
|
let o,h
|
|
1130
|
-
if(t.color&&"object"==typeof t.color&&!Array.isArray(t.color)&&(t.color.
|
|
1131
|
-
for(const e of Object.keys(t.color.
|
|
1148
|
+
if(t.color&&"object"==typeof t.color&&!Array.isArray(t.color)&&(t.color.Cl||t.color.Bl)){if(o=new Set,t.color.Cl){h=[]
|
|
1149
|
+
for(const e of Object.keys(t.color.Cl)){let i=0
|
|
1132
1150
|
for(;-1!==(i=t.text.indexOf(e,i));){h.push({pattern:e,start:i,end:i+e.length})
|
|
1133
1151
|
for(let t=i;i+e.length>t;t++)o.add(t)
|
|
1134
|
-
i+=e.length}}}if(t.color.
|
|
1135
|
-
if(t.perGlyphAttributes){const t=this.
|
|
1136
|
-
l.glyphAttributes=t}return l}finally{}}async
|
|
1137
|
-
if(!t.layout?.ke?.[e])try{if(!
|
|
1138
|
-
|
|
1139
|
-
const e=t.
|
|
1140
|
-
if(t.text.length>e)throw Error(`Text exceeds ${e} character limit`)}
|
|
1141
|
-
const{text:e,size:i=
|
|
1142
|
-
let
|
|
1143
|
-
void 0!==h&&(
|
|
1144
|
-
const
|
|
1145
|
-
this.
|
|
1146
|
-
const
|
|
1147
|
-
return{lines:
|
|
1152
|
+
i+=e.length}}}if(t.color.Bl)for(const e of t.color.Bl)for(let t=e.start;e.end>t;t++)o.add(t)}const a=this.Go.wo(r,s.depth,n,this.oi.rt.bi,s.dc,t.perGlyphAttributes??!1,o),l=this.yc(a.vertices,a.normals,a.indices,a.Co,a.planeBounds,t,t.text,h)
|
|
1153
|
+
if(t.perGlyphAttributes){const t=this.wc(l.vertices.length/3,l.glyphs)
|
|
1154
|
+
l.glyphAttributes=t}return l}finally{}}async oc(t){if(!1!==t.layout?._e&&t.layout?.width){const e=t.layout?.language||"en-us"
|
|
1155
|
+
if(!t.layout?.ke?.[e])try{if(!ai.$l.has(e)){const s=await i(e,t.layout?.gc)
|
|
1156
|
+
ai.$l.set(e,s)}return{...t,layout:{...t.layout,ke:{...t.layout?.ke,[e]:ai.$l.get(e)}}}}catch(i){return st.warn(`Failed to load patterns for ${e}: ${i}`),{...t,layout:{...t.layout,_e:!1}}}}return t}hc(t){if(!t.text)throw Error("Text content is required")
|
|
1157
|
+
const e=t.mc??1e5
|
|
1158
|
+
if(t.text.length>e)throw Error(`Text exceeds ${e} character limit`)}ac(t){t.es&&this.oi&&ai.Vl(t.es)!==ai.Vl(this.oi.es||{})&&(this.oi.font.Zi(t.es),this.oi.es=t.es)}cc(t){if(!this.oi)throw Error("Font not loaded. Use Text.create() with a font option")
|
|
1159
|
+
const{text:e,size:i=hi,depth:s=0,lineHeight:n=1,letterSpacing:r=0,layout:o={}}=t,{width:h,direction:a="ltr",align:l=("rtl"===a?"right":"left"),Oe:c=!0,_e:u=!0,language:f="en-us",Le:d=nt,De:y=rt,Ne:p=ot,Pe:w,ke:g,$e:m,Ge:v,ze:x,Re:A,We:b,je:E,Ue:T}=o,I=this.oi.upem/i
|
|
1160
|
+
let S
|
|
1161
|
+
void 0!==h&&(S=h*I)
|
|
1162
|
+
const F=s*I,M=F>0?Math.max(F,25e-6*this.oi.upem):0
|
|
1163
|
+
this.vc||(this.vc=new Et(this.oi))
|
|
1164
|
+
const _=this.vc.hi({text:e,width:S,align:l,direction:a,_e:u,language:f,Oe:c,Le:d,De:y,Ne:p,Pe:w,ke:g,$e:m,Ge:v,ze:x,Re:A,We:b,je:E,Ue:T,letterSpacing:r}),O=Gt.zi(this.oi.rt)
|
|
1165
|
+
return{lines:_.lines,fc:(O.fi-O.di)*n,letterSpacing:r,align:l,direction:a,depth:M,size:i,dc:1/I}}xc(t,e,i,s,n){const r=t.length/3,o=new Float32Array(3*r),h=[]
|
|
1148
1166
|
if(Array.isArray(i)){for(let t=0;r>t;t++){const e=3*t
|
|
1149
|
-
o[e]=i[0],o[e+1]=i[1],o[e+2]=i[2]}h.push({start:0,end:s.length
|
|
1167
|
+
o[e]=i[0],o[e+1]=i[1],o[e+2]=i[2]}h.push({start:0,end:s.length,Dl:s,color:i,bounds:[],glyphs:e,Pl:[...new Set(e.map(t=>t.Bo))]})}else{const t=i.default||[1,1,1]
|
|
1150
1168
|
for(let e=0;o.length>e;e+=3)o[e]=t[0],o[e+1]=t[1],o[e+2]=t[2]
|
|
1151
1169
|
let r
|
|
1152
|
-
if(i.
|
|
1153
|
-
for(const t of e){const e=r.get(t.
|
|
1154
|
-
e?e.push(t):r.set(t.
|
|
1170
|
+
if(i.Cl&&n||i.Bl){r=new Map
|
|
1171
|
+
for(const t of e){const e=r.get(t.ko)
|
|
1172
|
+
e?e.push(t):r.set(t.ko,[t])}}if(i.Cl&&n&&r)for(const t of n){const e=i.Cl[t.pattern]
|
|
1155
1173
|
if(!e)continue
|
|
1156
1174
|
const s=[],n=new Map
|
|
1157
1175
|
for(let i=t.start;t.end>i;i++){const t=r.get(i)
|
|
1158
1176
|
if(t)for(const i of t){s.push(i)
|
|
1159
|
-
const t=n.get(i.
|
|
1160
|
-
t?t.push(i):n.set(i.
|
|
1161
|
-
for(let t=0;i.
|
|
1162
|
-
s>=0&&o.length>s&&(o[s]=e[0],o[s+1]=e[1],o[s+2]=e[2])}}}const a=Array.from(n.values()).map(t=>this.
|
|
1163
|
-
h.push({start:t.start,end:t.end
|
|
1177
|
+
const t=n.get(i.Bo)
|
|
1178
|
+
t?t.push(i):n.set(i.Bo,[i])
|
|
1179
|
+
for(let t=0;i.Ss>t;t++){const s=3*(i.xo+t)
|
|
1180
|
+
s>=0&&o.length>s&&(o[s]=e[0],o[s+1]=e[1],o[s+2]=e[2])}}}const a=Array.from(n.values()).map(t=>this.Ac(t))
|
|
1181
|
+
h.push({start:t.start,end:t.end,Dl:t.pattern,color:e,bounds:a,glyphs:s,Pl:Array.from(n.keys()).sort((t,e)=>t-e)})}if(i.Bl&&r)for(const t of i.Bl){const e=[],i=new Map
|
|
1164
1182
|
for(let s=t.start;t.end>s;s++){const n=r.get(s)
|
|
1165
1183
|
if(n)for(const s of n){e.push(s)
|
|
1166
|
-
const n=i.get(s.
|
|
1167
|
-
n?n.push(s):i.set(s.
|
|
1168
|
-
for(let e=0;s.
|
|
1169
|
-
i>=0&&o.length>i&&(o[i]=t.color[0],o[i+1]=t.color[1],o[i+2]=t.color[2])}}}const n=Array.from(i.values()).map(t=>this.
|
|
1170
|
-
h.push({start:t.start,end:t.end
|
|
1184
|
+
const n=i.get(s.Bo)
|
|
1185
|
+
n?n.push(s):i.set(s.Bo,[s])
|
|
1186
|
+
for(let e=0;s.Ss>e;e++){const i=3*(s.xo+e)
|
|
1187
|
+
i>=0&&o.length>i&&(o[i]=t.color[0],o[i+1]=t.color[1],o[i+2]=t.color[2])}}}const n=Array.from(i.values()).map(t=>this.Ac(t))
|
|
1188
|
+
h.push({start:t.start,end:t.end,Dl:s.slice(t.start,t.end),color:t.color,bounds:n,glyphs:e,Pl:Array.from(i.keys()).sort((t,e)=>t-e)})}}return{colors:o,bc:h}}Ac(t){if(0===t.length)return{min:{x:0,y:0,z:0},max:{x:0,y:0,z:0}}
|
|
1171
1189
|
let e=1/0,i=1/0,s=1/0,n=-1/0,r=-1/0,o=-1/0
|
|
1172
1190
|
for(const h of t)e>h.bounds.min.x&&(e=h.bounds.min.x),i>h.bounds.min.y&&(i=h.bounds.min.y),s>h.bounds.min.z&&(s=h.bounds.min.z),h.bounds.max.x>n&&(n=h.bounds.max.x),h.bounds.max.y>r&&(r=h.bounds.max.y),h.bounds.max.z>o&&(o=h.bounds.max.z)
|
|
1173
|
-
return{min:{x:e,y:i,z:s},max:{x:n,y:r,z:o}}}
|
|
1174
|
-
this.
|
|
1175
|
-
const u=this.
|
|
1191
|
+
return{min:{x:e,y:i,z:s},max:{x:n,y:r,z:o}}}yc(t,e,i,s,n,r,o,h){const{layout:a={}}=r,{width:l,align:c=("rtl"===a.direction?"right":"left")}=a
|
|
1192
|
+
this.vc||(this.vc=new Et(this.oi))
|
|
1193
|
+
const u=this.vc.ci({width:l,align:c,planeBounds:n}),f=u.offset
|
|
1176
1194
|
if(n.min.x=u.li.min.x,n.max.x=u.li.max.x,0!==f){for(let e=0;t.length>e;e+=3)t[e]+=f
|
|
1177
1195
|
for(let t=0;s.length>t;t++)s[t].bounds.min.x+=f,s[t].bounds.max.x+=f}let d,y
|
|
1178
|
-
if(r.color){const e=this.
|
|
1179
|
-
d=e.colors,y=e.
|
|
1196
|
+
if(r.color){const e=this.xc(t,s,r.color,r.text,h)
|
|
1197
|
+
d=e.colors,y=e.bc}const p=this.Go.Br()
|
|
1180
1198
|
return{vertices:t,normals:e,indices:i,colors:d,glyphs:s,planeBounds:n,stats:{trianglesGenerated:i.length/3,verticesGenerated:t.length/3,pointsRemovedByVisvalingam:p.pointsRemovedByVisvalingam,originalPointCount:p.originalPointCount},query:(()=>{let t=null
|
|
1181
1199
|
return e=>{if(!o)throw Error("Original text not available for querying")
|
|
1182
|
-
return t||(t=new
|
|
1183
|
-
return
|
|
1184
|
-
|
|
1185
|
-
return
|
|
1200
|
+
return t||(t=new oi(o,s)),t.Ol(e)}})(),bc:y,glyphAttributes:void 0}}Ri(){if(!this.oi)throw Error("Font not loaded. Call loadFont() first")
|
|
1201
|
+
return Gt.Ri(this.oi.rt)}static async Ec(t,e){await Promise.all(t.map(async t=>{if(!ai.$l.has(t))try{const s=await i(t,e)
|
|
1202
|
+
ai.$l.set(t,s)}catch(e){st.warn(`Failed to pre-load patterns for ${t}: ${e}`)}}))}static Tc(t,e){ai.$l.set(t,e)}static Ic(t){ai.Wl=t===1/0?1/0:1048576*Math.max(1,Math.floor(t)),ai.nc()}getLoadedFont(){return this.oi}measureTextWidth(t,e=0){if(!this.oi)throw Error("Font not loaded. Call loadFont() first")
|
|
1203
|
+
return bt.measureTextWidth(this.oi,t,e)}getCacheSize(){return this.Go?this.Go.Po().size:0}clearCache(){this.Go&&this.Go.clearCache()}wc(t,e){const i=new Float32Array(3*t),s=new Float32Array(t),n=new Float32Array(t),r=new Float32Array(t),o=new Float32Array(t)
|
|
1186
1204
|
let h=1/0,a=-1/0
|
|
1187
1205
|
for(let t=0;e.length>t;t++){const i=(e[t].bounds.min.x+e[t].bounds.max.x)/2
|
|
1188
1206
|
h>i&&(h=i),i>a&&(a=i)}const l=a-h
|
|
1189
|
-
for(let a=0;e.length>a;a++){const c=e[a],u=(c.bounds.min.x+c.bounds.max.x)/2,f=(c.bounds.min.y+c.bounds.max.y)/2,d=(c.bounds.min.z+c.bounds.max.z)/2,y=c.bounds.min.y,p=l>0?(u-h)/l:0,w=c.
|
|
1190
|
-
if(g>w){s.fill(a,w,g),n.fill(c.
|
|
1191
|
-
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:s,glyphLineIndex:n,glyphProgress:r,glyphBaselineY:o}}
|
|
1207
|
+
for(let a=0;e.length>a;a++){const c=e[a],u=(c.bounds.min.x+c.bounds.max.x)/2,f=(c.bounds.min.y+c.bounds.max.y)/2,d=(c.bounds.min.z+c.bounds.max.z)/2,y=c.bounds.min.y,p=l>0?(u-h)/l:0,w=c.xo,g=Math.min(w+c.Ss,t)
|
|
1208
|
+
if(g>w){s.fill(a,w,g),n.fill(c.Bo,w,g),r.fill(p,w,g),o.fill(y,w,g)
|
|
1209
|
+
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:s,glyphLineIndex:n,glyphProgress:r,glyphBaselineY:o}}Zl(){this.Go=void 0,this.lc=void 0,this.vc=void 0}destroy(){if(!this.oi)return
|
|
1192
1210
|
const t=this.oi
|
|
1193
|
-
try{
|
|
1211
|
+
try{Wt.cs(t)}catch(t){st.warn("Error destroying HarfBuzz objects:",t)}finally{this.oi=void 0,this.vc=void 0,this.lc=void 0}}}exports.DEFAULT_CURVE_FIDELITY=De,exports.FontMetadataExtractor=Gt,exports.Text=ai,exports.createGlyphCache=()=>new qt,exports.globalGlyphCache=Yt
|