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