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