modern-text 2.1.2 → 2.1.4

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 (27) hide show
  1. package/dist/deformations/index.cjs +1 -1
  2. package/dist/deformations/index.d.cts +2 -2
  3. package/dist/deformations/index.d.mts +2 -2
  4. package/dist/deformations/index.d.ts +2 -2
  5. package/dist/deformations/index.mjs +1 -1
  6. package/dist/index.cjs +2 -2
  7. package/dist/index.d.cts +4 -4
  8. package/dist/index.d.mts +4 -4
  9. package/dist/index.d.ts +4 -4
  10. package/dist/index.js +3 -3
  11. package/dist/index.mjs +3 -3
  12. package/dist/shared/{modern-text._10DVHum.cjs → modern-text.B1qEGvHu.cjs} +1 -6
  13. package/dist/shared/{modern-text.DENkEKJN.d.cts → modern-text.Byk6gnkH.d.cts} +10 -1
  14. package/dist/shared/{modern-text.DENkEKJN.d.mts → modern-text.Byk6gnkH.d.mts} +10 -1
  15. package/dist/shared/{modern-text.DENkEKJN.d.ts → modern-text.Byk6gnkH.d.ts} +10 -1
  16. package/dist/shared/{modern-text.BAnUZM0U.cjs → modern-text.CJSp_eBm.cjs} +53 -5
  17. package/dist/shared/{modern-text.CdKp2H-o.mjs → modern-text.Cvc61q2w.mjs} +1 -6
  18. package/dist/shared/{modern-text.CjkLMv3V.d.cts → modern-text.DwLgm6ho.d.mts} +1 -1
  19. package/dist/shared/{modern-text.BdF52nXP.mjs → modern-text.Dz4np_87.mjs} +53 -5
  20. package/dist/shared/{modern-text.1LMQ6ZWb.d.ts → modern-text.kLi3S9Iu.d.ts} +1 -1
  21. package/dist/shared/{modern-text.Cv-GZog_.d.mts → modern-text.xspsgB0_.d.cts} +1 -1
  22. package/dist/web-components/index.cjs +2 -2
  23. package/dist/web-components/index.d.cts +1 -1
  24. package/dist/web-components/index.d.mts +1 -1
  25. package/dist/web-components/index.d.ts +1 -1
  26. package/dist/web-components/index.mjs +2 -2
  27. package/package.json +2 -2
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const modernPath2d = require('modern-path2d');
4
- const deformation = require('../shared/modern-text._10DVHum.cjs');
4
+ const deformation = require('../shared/modern-text.B1qEGvHu.cjs');
5
5
  const curves = require('../shared/modern-text.MC5bIC9E.cjs');
6
6
  require('modern-idoc');
7
7
 
@@ -1,6 +1,6 @@
1
- import { D as DeformationPreset } from '../shared/modern-text.CjkLMv3V.cjs';
1
+ import { D as DeformationPreset } from '../shared/modern-text.xspsgB0_.cjs';
2
2
  import 'modern-path2d';
3
- import '../shared/modern-text.DENkEKJN.cjs';
3
+ import '../shared/modern-text.Byk6gnkH.cjs';
4
4
  import 'modern-idoc';
5
5
  import 'modern-font';
6
6
 
@@ -1,6 +1,6 @@
1
- import { D as DeformationPreset } from '../shared/modern-text.Cv-GZog_.mjs';
1
+ import { D as DeformationPreset } from '../shared/modern-text.DwLgm6ho.mjs';
2
2
  import 'modern-path2d';
3
- import '../shared/modern-text.DENkEKJN.mjs';
3
+ import '../shared/modern-text.Byk6gnkH.mjs';
4
4
  import 'modern-idoc';
5
5
  import 'modern-font';
6
6
 
@@ -1,6 +1,6 @@
1
- import { D as DeformationPreset } from '../shared/modern-text.1LMQ6ZWb.js';
1
+ import { D as DeformationPreset } from '../shared/modern-text.kLi3S9Iu.js';
2
2
  import 'modern-path2d';
3
- import '../shared/modern-text.DENkEKJN.js';
3
+ import '../shared/modern-text.Byk6gnkH.js';
4
4
  import 'modern-idoc';
5
5
  import 'modern-font';
6
6
 
@@ -1,5 +1,5 @@
1
1
  import { Vector2 } from 'modern-path2d';
2
- import { d as defineDeformation } from '../shared/modern-text.CdKp2H-o.mjs';
2
+ import { d as defineDeformation } from '../shared/modern-text.Cvc61q2w.mjs';
3
3
  import { H as HeartCurve, R as RectangularCurve, E as EllipseCurve, C as CircleCurve, P as PolygonCurve } from '../shared/modern-text.fT17R5HY.mjs';
4
4
  import 'modern-idoc';
5
5
 
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const Text = require('./shared/modern-text.BAnUZM0U.cjs');
4
- const deformation = require('./shared/modern-text._10DVHum.cjs');
3
+ const Text = require('./shared/modern-text.CJSp_eBm.cjs');
4
+ const deformation = require('./shared/modern-text.B1qEGvHu.cjs');
5
5
  const curves = require('./shared/modern-text.MC5bIC9E.cjs');
6
6
  require('modern-font');
7
7
  require('modern-idoc');
package/dist/index.d.cts CHANGED
@@ -1,10 +1,10 @@
1
- import { P as Plugin, T as TextMeasurer, a as Paragraph, M as MeasurerResult, C as Character, O as Options, b as MeasureResult, R as RenderOptions, c as Text } from './shared/modern-text.DENkEKJN.cjs';
2
- export { d as Canvas2DRenderer, D as DrawShapePathsOptions, F as Fragment, e as TextEvents, t as textDefaultStyle } from './shared/modern-text.DENkEKJN.cjs';
1
+ import { P as Plugin, T as TextMeasurer, a as Paragraph, M as MeasurerResult, C as Character, O as Options, b as MeasureResult, R as RenderOptions, c as Text } from './shared/modern-text.Byk6gnkH.cjs';
2
+ export { d as Canvas2DRenderer, D as DrawShapePathsOptions, F as Fragment, e as TextEvents, t as textDefaultStyle } from './shared/modern-text.Byk6gnkH.cjs';
3
3
  import { Fonts } from 'modern-font';
4
4
  import { FullStyle, NormalizedStyle, NormalizedHighlight, NormalizedEffect } from 'modern-idoc';
5
5
  import { BoundingBox, Vector2, Path2DSet, Transform2D } from 'modern-path2d';
6
- import { D as DeformationPreset } from './shared/modern-text.CjkLMv3V.cjs';
7
- export { B as BendContext, a as BendPreset, C as CurvePreset, b as DeformationCharInfo, c as DeformationCurve, F as FfdContext, d as FfdPreset, O as OffsetPreset, V as VerbatimContext } from './shared/modern-text.CjkLMv3V.cjs';
6
+ import { D as DeformationPreset } from './shared/modern-text.xspsgB0_.cjs';
7
+ export { B as BendContext, a as BendPreset, C as CurvePreset, b as DeformationCharInfo, c as DeformationCurve, F as FfdContext, d as FfdPreset, O as OffsetPreset, V as VerbatimContext } from './shared/modern-text.xspsgB0_.cjs';
8
8
 
9
9
  declare function definePlugin(options: Plugin): Plugin;
10
10
 
package/dist/index.d.mts CHANGED
@@ -1,10 +1,10 @@
1
- import { P as Plugin, T as TextMeasurer, a as Paragraph, M as MeasurerResult, C as Character, O as Options, b as MeasureResult, R as RenderOptions, c as Text } from './shared/modern-text.DENkEKJN.mjs';
2
- export { d as Canvas2DRenderer, D as DrawShapePathsOptions, F as Fragment, e as TextEvents, t as textDefaultStyle } from './shared/modern-text.DENkEKJN.mjs';
1
+ import { P as Plugin, T as TextMeasurer, a as Paragraph, M as MeasurerResult, C as Character, O as Options, b as MeasureResult, R as RenderOptions, c as Text } from './shared/modern-text.Byk6gnkH.mjs';
2
+ export { d as Canvas2DRenderer, D as DrawShapePathsOptions, F as Fragment, e as TextEvents, t as textDefaultStyle } from './shared/modern-text.Byk6gnkH.mjs';
3
3
  import { Fonts } from 'modern-font';
4
4
  import { FullStyle, NormalizedStyle, NormalizedHighlight, NormalizedEffect } from 'modern-idoc';
5
5
  import { BoundingBox, Vector2, Path2DSet, Transform2D } from 'modern-path2d';
6
- import { D as DeformationPreset } from './shared/modern-text.Cv-GZog_.mjs';
7
- export { B as BendContext, a as BendPreset, C as CurvePreset, b as DeformationCharInfo, c as DeformationCurve, F as FfdContext, d as FfdPreset, O as OffsetPreset, V as VerbatimContext } from './shared/modern-text.Cv-GZog_.mjs';
6
+ import { D as DeformationPreset } from './shared/modern-text.DwLgm6ho.mjs';
7
+ export { B as BendContext, a as BendPreset, C as CurvePreset, b as DeformationCharInfo, c as DeformationCurve, F as FfdContext, d as FfdPreset, O as OffsetPreset, V as VerbatimContext } from './shared/modern-text.DwLgm6ho.mjs';
8
8
 
9
9
  declare function definePlugin(options: Plugin): Plugin;
10
10
 
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { P as Plugin, T as TextMeasurer, a as Paragraph, M as MeasurerResult, C as Character, O as Options, b as MeasureResult, R as RenderOptions, c as Text } from './shared/modern-text.DENkEKJN.js';
2
- export { d as Canvas2DRenderer, D as DrawShapePathsOptions, F as Fragment, e as TextEvents, t as textDefaultStyle } from './shared/modern-text.DENkEKJN.js';
1
+ import { P as Plugin, T as TextMeasurer, a as Paragraph, M as MeasurerResult, C as Character, O as Options, b as MeasureResult, R as RenderOptions, c as Text } from './shared/modern-text.Byk6gnkH.js';
2
+ export { d as Canvas2DRenderer, D as DrawShapePathsOptions, F as Fragment, e as TextEvents, t as textDefaultStyle } from './shared/modern-text.Byk6gnkH.js';
3
3
  import { Fonts } from 'modern-font';
4
4
  import { FullStyle, NormalizedStyle, NormalizedHighlight, NormalizedEffect } from 'modern-idoc';
5
5
  import { BoundingBox, Vector2, Path2DSet, Transform2D } from 'modern-path2d';
6
- import { D as DeformationPreset } from './shared/modern-text.1LMQ6ZWb.js';
7
- export { B as BendContext, a as BendPreset, C as CurvePreset, b as DeformationCharInfo, c as DeformationCurve, F as FfdContext, d as FfdPreset, O as OffsetPreset, V as VerbatimContext } from './shared/modern-text.1LMQ6ZWb.js';
6
+ import { D as DeformationPreset } from './shared/modern-text.kLi3S9Iu.js';
7
+ export { B as BendContext, a as BendPreset, C as CurvePreset, b as DeformationCharInfo, c as DeformationCurve, F as FfdContext, d as FfdPreset, O as OffsetPreset, V as VerbatimContext } from './shared/modern-text.kLi3S9Iu.js';
8
8
 
9
9
  declare function definePlugin(options: Plugin): Plugin;
10
10
 
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.modernText={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),c=(e,t,a,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=i(t),l=0,u=c.length,d;l<u;l++)d=c[l],!o.call(e,d)&&d!==a&&n(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(s=r(t,d))||s.enumerable});return e},l=(e,r,i)=>(i=e==null?{}:t(a(e)),c(r||!e||!e.__esModule?n(i,`default`,{value:e,enumerable:!0}):i,e)),u={grad:.9,turn:360,rad:360/(2*Math.PI)},d=function(e){return typeof e==`string`?e.length>0:typeof e==`number`},f=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=10**t),Math.round(n*e)/n+0},p=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e>n?n:e>t?e:t},m=function(e){return(e=isFinite(e)?e%360:0)>0?e:e+360},h=function(e){return{r:p(e.r,0,255),g:p(e.g,0,255),b:p(e.b,0,255),a:p(e.a)}},g=function(e){return{r:f(e.r),g:f(e.g),b:f(e.b),a:f(e.a,3)}},_=/^#([0-9a-f]{3,8})$/i,v=function(e){var t=e.toString(16);return t.length<2?`0`+t:t},y=function(e){var t=e.r,n=e.g,r=e.b,i=e.a,a=Math.max(t,n,r),o=a-Math.min(t,n,r),s=o?a===t?(n-r)/o:a===n?2+(r-t)/o:4+(t-n)/o:0;return{h:60*(s<0?s+6:s),s:a?o/a*100:0,v:a/255*100,a:i}},b=function(e){var t=e.h,n=e.s,r=e.v,i=e.a;t=t/360*6,n/=100,r/=100;var a=Math.floor(t),o=r*(1-n),s=r*(1-(t-a)*n),c=r*(1-(1-t+a)*n),l=a%6;return{r:255*[r,s,o,o,c,r][l],g:255*[c,r,r,s,o,o][l],b:255*[o,o,c,r,r,s][l],a:i}},x=function(e){return{h:m(e.h),s:p(e.s,0,100),l:p(e.l,0,100),a:p(e.a)}},S=function(e){return{h:f(e.h),s:f(e.s),l:f(e.l),a:f(e.a,3)}},C=function(e){return b((n=(t=e).s,{h:t.h,s:(n*=((r=t.l)<50?r:100-r)/100)>0?2*n/(r+n)*100:0,v:r+n,a:t.a}));var t,n,r},w=function(e){return{h:(t=y(e)).h,s:(i=(200-(n=t.s))*(r=t.v)/100)>0&&i<200?n*r/100/(i<=100?i:200-i)*100:0,l:i/2,a:t.a};var t,n,r,i},T=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,E=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,D=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,O=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,k={string:[[function(e){var t=_.exec(e);return t?(e=t[1]).length<=4?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:e.length===4?f(parseInt(e[3]+e[3],16)/255,2):1}:e.length===6||e.length===8?{r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16),a:e.length===8?f(parseInt(e.substr(6,2),16)/255,2):1}:null:null},`hex`],[function(e){var t=D.exec(e)||O.exec(e);return t?t[2]!==t[4]||t[4]!==t[6]?null:h({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},`rgb`],[function(e){var t=T.exec(e)||E.exec(e);if(!t)return null;var n,r;return C(x({h:(n=t[1],r=t[2],r===void 0&&(r=`deg`),Number(n)*(u[r]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)}))},`hsl`]],object:[[function(e){var t=e.r,n=e.g,r=e.b,i=e.a,a=i===void 0?1:i;return d(t)&&d(n)&&d(r)?h({r:Number(t),g:Number(n),b:Number(r),a:Number(a)}):null},`rgb`],[function(e){var t=e.h,n=e.s,r=e.l,i=e.a,a=i===void 0?1:i;return!d(t)||!d(n)||!d(r)?null:C(x({h:Number(t),s:Number(n),l:Number(r),a:Number(a)}))},`hsl`],[function(e){var t=e.h,n=e.s,r=e.v,i=e.a,a=i===void 0?1:i;return!d(t)||!d(n)||!d(r)?null:b(function(e){return{h:m(e.h),s:p(e.s,0,100),v:p(e.v,0,100),a:p(e.a)}}({h:Number(t),s:Number(n),v:Number(r),a:Number(a)}))},`hsv`]]},A=function(e,t){for(var n=0;n<t.length;n++){var r=t[n][0](e);if(r)return[r,t[n][1]]}return[null,void 0]},j=function(e){return typeof e==`string`?A(e.trim(),k.string):typeof e==`object`&&e?A(e,k.object):[null,void 0]},M=function(e,t){var n=w(e);return{h:n.h,s:p(n.s+100*t,0,100),l:n.l,a:n.a}},N=function(e){return(299*e.r+587*e.g+114*e.b)/1e3/255},P=function(e,t){var n=w(e);return{h:n.h,s:n.s,l:p(n.l+100*t,0,100),a:n.a}},F=function(){function e(e){this.parsed=j(e)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return e.prototype.isValid=function(){return this.parsed!==null},e.prototype.brightness=function(){return f(N(this.rgba),2)},e.prototype.isDark=function(){return N(this.rgba)<.5},e.prototype.isLight=function(){return N(this.rgba)>=.5},e.prototype.toHex=function(){return e=g(this.rgba),t=e.r,n=e.g,r=e.b,a=(i=e.a)<1?v(f(255*i)):``,`#`+v(t)+v(n)+v(r)+a;var e,t,n,r,i,a},e.prototype.toRgb=function(){return g(this.rgba)},e.prototype.toRgbString=function(){return e=g(this.rgba),t=e.r,n=e.g,r=e.b,(i=e.a)<1?`rgba(`+t+`, `+n+`, `+r+`, `+i+`)`:`rgb(`+t+`, `+n+`, `+r+`)`;var e,t,n,r,i},e.prototype.toHsl=function(){return S(w(this.rgba))},e.prototype.toHslString=function(){return e=S(w(this.rgba)),t=e.h,n=e.s,r=e.l,(i=e.a)<1?`hsla(`+t+`, `+n+`%, `+r+`%, `+i+`)`:`hsl(`+t+`, `+n+`%, `+r+`%)`;var e,t,n,r,i},e.prototype.toHsv=function(){return e=y(this.rgba),{h:f(e.h),s:f(e.s),v:f(e.v),a:f(e.a,3)};var e},e.prototype.invert=function(){return I({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},e.prototype.saturate=function(e){return e===void 0&&(e=.1),I(M(this.rgba,e))},e.prototype.desaturate=function(e){return e===void 0&&(e=.1),I(M(this.rgba,-e))},e.prototype.grayscale=function(){return I(M(this.rgba,-1))},e.prototype.lighten=function(e){return e===void 0&&(e=.1),I(P(this.rgba,e))},e.prototype.darken=function(e){return e===void 0&&(e=.1),I(P(this.rgba,-e))},e.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},e.prototype.alpha=function(e){return typeof e==`number`?I({r:(t=this.rgba).r,g:t.g,b:t.b,a:e}):f(this.rgba.a,3);var t},e.prototype.hue=function(e){var t=w(this.rgba);return typeof e==`number`?I({h:e,s:t.s,l:t.l,a:t.a}):f(t.h)},e.prototype.isEqual=function(e){return this.toHex()===I(e).toHex()},e}(),I=function(e){return e instanceof F?e:new F(e)};function L(e){return e==null||e===``||e===`none`}function R(e,t=0,n=10**t){return Math.round(n*e)/n+0}function z(e,t){if(typeof e==`number`)return Number.isFinite(e)?e:t;if(typeof e==`string`){let n=Number.parseFloat(e);return Number.isFinite(n)?n:t}return t}function B(e,t=!1){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return t?e.map(e=>B(e,t)):e;let n={};for(let r in e){let i=e[r];i!=null&&(t?n[r]=B(i,t):n[r]=i)}return n}function V(e,t){let n={};return t.forEach(t=>{t in e&&(n[t]=e[t])}),n}function ee(e,t){if(e===t)return!0;if(e&&t&&typeof e==`object`&&typeof t==`object`){let n=Array.from(new Set([...Object.keys(e),...Object.keys(t)]));return!n.length||n.every(n=>e[n]===t[n])}return!1}function te(e,t,n){let r=t.length-1;if(r<0)return e===void 0?n:e;for(let i=0;i<r;i++){if(e==null)return n;e=e[t[i]]}return e==null||e[t[r]]===void 0?n:e[t[r]]}function ne(e,t,n){let r=t.length-1;for(let n=0;n<r;n++)typeof e[t[n]]!=`object`&&(e[t[n]]={}),e=e[t[n]];e[t[r]]=n}function re(e,t,n){return e==null||!t||typeof t!=`string`?n:e[t]===void 0?(t=t.replace(/\[(\w+)\]/g,`.$1`),t=t.replace(/^\./,``),te(e,t.split(`.`),n)):e[t]}function ie(e,t,n){if(!(typeof e!=`object`||!t))return t=t.replace(/\[(\w+)\]/g,`.$1`),t=t.replace(/^\./,``),ne(e,t.split(`.`),n)}var ae=class{_eventListeners={};on(e,t){let n=this._eventListeners[e];n===void 0&&(n=[],this._eventListeners[e]=n);let r=n.indexOf(t);return r>-1&&n.splice(r,1),n.push(t),this}once(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return this.on(e,n),this}off(e,t){let n=this._eventListeners[e];if(n!==void 0){let e=n.indexOf(t);e>-1&&n.splice(e,1)}return this}emit(e,...t){let n=this._eventListeners[e];if(n!==void 0){let e=n.length;if(e>0)for(let r=0;r<e;r++)n[r].apply(this,t)}return this}removeAllListeners(){return this._eventListeners={},this}hasEventListener(e){return!!this._eventListeners[e]}destroy(){this.removeAllListeners()}},oe=Symbol.for(`declarations`),se=Symbol.for(`inited`);function ce(e){let t;if(Object.hasOwn(e,oe))t=e[oe];else{let n=Object.getPrototypeOf(e);t={...n?ce(n):{}},e[oe]=t}return t}function le(e,t,n,r){let{alias:i,internalKey:a}=r,o=e[t];i?ie(e,i,n):e[a]=n,e.onUpdateProperty?.(t,n??de(e,t,r),o)}function ue(e,t,n){let{alias:r,internalKey:i}=n,a;return a=r?re(e,r):e[i],a??=de(e,t,n),a}function de(e,t,n){let{default:r,fallback:i}=n,a;if(r!==void 0&&!e[se]?.[t]){e[se]||(e[se]={}),e[se][t]=!0;let n=typeof r==`function`?r():r;n!==void 0&&(e[t]=n,a=n)}return a===void 0&&i!==void 0&&(a=typeof i==`function`?i():i),a}function fe(e,t){function n(){return this.getProperty?this.getProperty(e):ue(this,e,t)}function r(n){this.setProperty?this.setProperty(e,n):le(this,e,n,t)}return{get:n,set:r}}function pe(e,t,n={}){let r={...n,internalKey:Symbol.for(t)},i=ce(e);i[t]=r;let{get:a,set:o}=fe(t,r);Object.defineProperty(e.prototype,t,{get(){return a.call(this)},set(e){o.call(this,e)},configurable:!0,enumerable:!0})}function me(e){return function(t,n){if(typeof n!=`string`)throw TypeError(`Failed to @property decorator, prop name cannot be a symbol`);pe(t.constructor,n,e)}}var he=class extends ae{_propertyAccessor;_properties={};_updatedProperties={};_changedProperties=new Set;_updatingPromise=Promise.resolve();_updating=!1;constructor(e){super(),this.setProperties(e)}isDirty(e){return e?!!this._updatedProperties[e]:Object.keys(this._updatedProperties).length>0}offsetGetProperty(e){return this._properties[e]}offsetSetProperty(e,t){t===void 0?delete this._properties[e]:this._properties[e]=t}offsetGetProperties(e){let t=this._properties,n=Object.keys(t),r={};for(let i,a,o=0;o<n.length;o++)i=n[o],a=t[i],a!==void 0&&(!e||e.includes(i))&&(a&&typeof a==`object`?`toJSON`in a?r[i]=a.toJSON():Array.isArray(a)?r[i]=[...a]:r[i]={...a}:r[i]=a);return r}offsetSetProperties(e){if(e&&typeof e==`object`){let t=Object.keys(e);for(let n,r=0;r<t.length;r++)n=t[r],this.offsetSetProperty(n,e[n])}return this}getProperty(e){let t=this.getPropertyDeclaration(e);if(t){if(t.internal||t.alias)return ue(this,e,t);{let n=this._propertyAccessor,r;return r=n&&n.getProperty?n.getProperty(e):this.offsetGetProperty(e),r??de(this,e,t)}}}setProperty(e,t){let n=this.getPropertyDeclaration(e);if(n)if(n.internal||n.alias)le(this,e,t,n);else{let r=this.offsetGetProperty(e);if(Object.is(r,t))return;let i=this.getProperty(e);this._propertyAccessor?.setProperty?.(e,t),this.offsetSetProperty(e,t),this.onUpdateProperty?.(e,t??de(this,e,n),i)}}getProperties(e){let t={},n=this.getPropertyDeclarations(),r=Object.keys(n);for(let i=0,a=r.length;i<a;i++){let a=r[i],o=n[a];o.internal||o.alias||(!e||e.includes(a))&&(t[a]=this.getProperty(a))}return t}setProperties(e){if(e&&typeof e==`object`)for(let t in e)this.setProperty(t,e[t]);return this}resetProperties(){let e=this.getPropertyDeclarations(),t=Object.keys(e);for(let n=0,r=t.length;n<r;n++){let r=t[n],i=e[r];this.setProperty(r,typeof i.default==`function`?i.default():i.default)}return this}getPropertyDeclarations(){return ce(this.constructor)}getPropertyDeclaration(e){return this.getPropertyDeclarations()[e]}setPropertyAccessor(e){let t=this.getPropertyDeclarations(),n=[];if(e&&e.getProperty&&e.setProperty){let r=Object.keys(t);for(let i=0,a=r.length;i<a;i++){let a=r[i],o=t[a];if(o.internal||o.alias)continue;let s=this.offsetGetProperty(a),c=e.getProperty(a);c!==void 0&&!Object.is(s,c)&&(this.offsetSetProperty(a,c),n.push({key:a,newValue:c,oldValue:s}))}}this._propertyAccessor=e;for(let e=0,t=n.length;e<t;e++){let{key:t,newValue:r,oldValue:i}=n[e];this.requestUpdate(t,r,i)}return this}async _nextTick(){return`requestAnimationFrame`in globalThis?new Promise(e=>globalThis.requestAnimationFrame(e)):Promise.resolve()}async _enqueueUpdate(){this._updating=!0;try{await this._updatingPromise}catch(e){Promise.reject(e)}await this._nextTick(),this._updating&&=(this.onUpdate(),!1)}onUpdate(){this._update(this._updatedProperties),this._updatedProperties={}}onUpdateProperty(e,t,n){Object.is(t,n)||this.requestUpdate(e,t,n)}requestUpdate(e,t,n){e!==void 0&&(this._updatedProperties[e]=n,this._changedProperties.add(e),this._updateProperty(e,t,n),this.emit(`updateProperty`,e,t,n)),this._updating||(this._updatingPromise=this._enqueueUpdate())}_update(e){}_updateProperty(e,t,n){}toJSON(){return this.offsetGetProperties()}clone(){return new this.constructor(this.toJSON())}destroy(){this.emit(`destroy`),super.destroy()}};function ge(e){let t;return t=typeof e==`number`?{r:e>>24&255,g:e>>16&255,b:e>>8&255,a:(e&255)/255}:e,I(t)}function _e(e){return{r:R(e.r),g:R(e.g),b:R(e.b),a:R(e.a,3)}}function ve(e){let t=e.toString(16);return t.length<2?`0${t}`:t}var ye=`#000000FF`;function be(e){return ge(e).isValid()}function xe(e,t=!1){let n=ge(e);if(!n.isValid()){if(typeof e==`string`)return e;let n=`Failed to normalizeColor ${e}`;if(t)throw Error(n);return console.warn(n),ye}let{r,g:i,b:a,a:o}=_e(n.rgba);return`#${ve(r)}${ve(i)}${ve(a)}${ve(R(o*255))}`}var Se=Se||{};Se.parse=(function(){let e={linearGradient:/^(-(webkit|o|ms|moz)-)?(linear-gradient)/i,repeatingLinearGradient:/^(-(webkit|o|ms|moz)-)?(repeating-linear-gradient)/i,radialGradient:/^(-(webkit|o|ms|moz)-)?(radial-gradient)/i,repeatingRadialGradient:/^(-(webkit|o|ms|moz)-)?(repeating-radial-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest-side|closest-corner|farthest-side|farthest-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?((\d*\.\d+)|(\d+\.?)))px/,percentageValue:/^(-?((\d*\.\d+)|(\d+\.?)))%/,emValue:/^(-?((\d*\.\d+)|(\d+\.?)))em/,angleValue:/^(-?((\d*\.\d+)|(\d+\.?)))deg/,radianValue:/^(-?((\d*\.\d+)|(\d+\.?)))rad/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^#([0-9a-f]+)/i,literalColor:/^([a-z]+)/i,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,varColor:/^var/i,calcValue:/^calc/i,variableName:/^(--[a-z0-9-,\s#]+)/i,number:/^((\d*\.\d+)|(\d+\.?))/,hslColor:/^hsl/i,hslaColor:/^hsla/i},t=``;function n(e){let n=Error(`${t}: ${e}`);throw n.source=t,n}function r(){let e=i();return t.length>0&&n(`Invalid input not EOF`),e}function i(){return y(a)}function a(){return o(`linear-gradient`,e.linearGradient,c)||o(`repeating-linear-gradient`,e.repeatingLinearGradient,c)||o(`radial-gradient`,e.radialGradient,d)||o(`repeating-radial-gradient`,e.repeatingRadialGradient,d)}function o(t,r,i){return s(r,r=>{let a=i();return a&&(I(e.comma)||n(`Missing comma before color stops`)),{type:t,orientation:a,colorStops:y(b)}})}function s(t,r){let i=I(t);if(i){I(e.startCall)||n(`Missing (`);let t=r(i);return I(e.endCall)||n(`Missing )`),t}}function c(){let t=l();if(t)return t;let n=F(`position-keyword`,e.positionKeywords,1);return n?{type:`directional`,value:n.value}:u()}function l(){return F(`directional`,e.sideOrCorner,1)}function u(){return F(`angular`,e.angleValue,1)||F(`angular`,e.radianValue,1)}function d(){let n,r=f(),i;return r&&(n=[],n.push(r),i=t,I(e.comma)&&(r=f(),r?n.push(r):t=i)),n}function f(){let e=p()||m();if(e)e.at=g();else{let t=h();if(t){e=t;let n=g();n&&(e.at=n)}else{let t=g();if(t)e={type:`default-radial`,at:t};else{let t=_();t&&(e={type:`default-radial`,at:t})}}}return e}function p(){let e=F(`shape`,/^(circle)/i,0);return e&&(e.style=P()||h()),e}function m(){let e=F(`shape`,/^(ellipse)/i,0);return e&&(e.style=_()||j()||h()),e}function h(){return F(`extent-keyword`,e.extentKeywords,1)}function g(){if(F(`position`,/^at/,0)){let e=_();return e||n(`Missing positioning value`),e}}function _(){let e=v();if(e.x||e.y)return{type:`position`,value:e}}function v(){return{x:j(),y:j()}}function y(t){let r=t(),i=[];if(r)for(i.push(r);I(e.comma);)r=t(),r?i.push(r):n(`One extra comma`);return i}function b(){let e=x();return e||n(`Expected color definition`),e.length=j(),e}function x(){return C()||O()||D()||T()||w()||E()||S()}function S(){return F(`literal`,e.literalColor,0)}function C(){return F(`hex`,e.hexColor,1)}function w(){return s(e.rgbColor,()=>({type:`rgb`,value:y(A)}))}function T(){return s(e.rgbaColor,()=>({type:`rgba`,value:y(A)}))}function E(){return s(e.varColor,()=>({type:`var`,value:k()}))}function D(){return s(e.hslColor,()=>{I(e.percentageValue)&&n(`HSL hue value must be a number in degrees (0-360) or normalized (-360 to 360), not a percentage`);let t=A();I(e.comma);let r=I(e.percentageValue),i=r?r[1]:null;I(e.comma),r=I(e.percentageValue);let a=r?r[1]:null;return(!i||!a)&&n(`Expected percentage value for saturation and lightness in HSL`),{type:`hsl`,value:[t,i,a]}})}function O(){return s(e.hslaColor,()=>{let t=A();I(e.comma);let r=I(e.percentageValue),i=r?r[1]:null;I(e.comma),r=I(e.percentageValue);let a=r?r[1]:null;I(e.comma);let o=A();return(!i||!a)&&n(`Expected percentage value for saturation and lightness in HSLA`),{type:`hsla`,value:[t,i,a,o]}})}function k(){return I(e.variableName)[1]}function A(){return I(e.number)[1]}function j(){return F(`%`,e.percentageValue,1)||M()||N()||P()}function M(){return F(`position-keyword`,e.positionKeywords,1)}function N(){return s(e.calcValue,()=>{let e=1,r=0;for(;e>0&&r<t.length;){let n=t.charAt(r);n===`(`?e++:n===`)`&&e--,r++}e>0&&n(`Missing closing parenthesis in calc() expression`);let i=t.substring(0,r-1);return L(r-1),{type:`calc`,value:i}})}function P(){return F(`px`,e.pixelValue,1)||F(`em`,e.emValue,1)}function F(e,t,n){let r=I(t);if(r)return{type:e,value:r[n]}}function I(e){let n,r;return r=/^\s+/.exec(t),r&&L(r[0].length),n=e.exec(t),n&&L(n[0].length),n}function L(e){t=t.substr(e)}return function(e){return t=e.toString().trim(),t.endsWith(`;`)&&(t=t.slice(0,-1)),r()}})();var Ce=Se.parse.bind(Se),we=we||{};we.stringify=(function(){var e={"visit_linear-gradient":function(t){return e.visit_gradient(t)},"visit_repeating-linear-gradient":function(t){return e.visit_gradient(t)},"visit_radial-gradient":function(t){return e.visit_gradient(t)},"visit_repeating-radial-gradient":function(t){return e.visit_gradient(t)},visit_gradient:function(t){var n=e.visit(t.orientation);return n&&(n+=`, `),t.type+`(`+n+e.visit(t.colorStops)+`)`},visit_shape:function(t){var n=t.value,r=e.visit(t.at),i=e.visit(t.style);return i&&(n+=` `+i),r&&(n+=` at `+r),n},"visit_default-radial":function(t){var n=``,r=e.visit(t.at);return r&&(n+=r),n},"visit_extent-keyword":function(t){var n=t.value,r=e.visit(t.at);return r&&(n+=` at `+r),n},"visit_position-keyword":function(e){return e.value},visit_position:function(t){return e.visit(t.value.x)+` `+e.visit(t.value.y)},"visit_%":function(e){return e.value+`%`},visit_em:function(e){return e.value+`em`},visit_px:function(e){return e.value+`px`},visit_calc:function(e){return`calc(`+e.value+`)`},visit_literal:function(t){return e.visit_color(t.value,t)},visit_hex:function(t){return e.visit_color(`#`+t.value,t)},visit_rgb:function(t){return e.visit_color(`rgb(`+t.value.join(`, `)+`)`,t)},visit_rgba:function(t){return e.visit_color(`rgba(`+t.value.join(`, `)+`)`,t)},visit_hsl:function(t){return e.visit_color(`hsl(`+t.value[0]+`, `+t.value[1]+`%, `+t.value[2]+`%)`,t)},visit_hsla:function(t){return e.visit_color(`hsla(`+t.value[0]+`, `+t.value[1]+`%, `+t.value[2]+`%, `+t.value[3]+`)`,t)},visit_var:function(t){return e.visit_color(`var(`+t.value+`)`,t)},visit_color:function(t,n){var r=t,i=e.visit(n.length);return i&&(r+=` `+i),r},visit_angular:function(e){return e.value+`deg`},visit_directional:function(e){return`to `+e.value},visit_array:function(t){var n=``,r=t.length;return t.forEach(function(t,i){n+=e.visit(t),i<r-1&&(n+=`, `)}),n},visit_object:function(t){return t.width&&t.height?e.visit(t.width)+` `+e.visit(t.height):``},visit:function(t){if(!t)return``;if(t instanceof Array)return e.visit_array(t);if(typeof t==`object`&&!t.type)return e.visit_object(t);if(t.type){var n=e[`visit_`+t.type];if(n)return n(t);throw Error(`Missing visitor visit_`+t.type)}else throw Error(`Invalid node.`)}};return function(t){return e.visit(t)}})(),we.stringify.bind(we);function Te(e){let t=e.length-1;return e.map((e,n)=>{let r=e.value,i=R(n/t,3),a=`#00000000`;switch(e.type){case`rgb`:a=xe({r:Number(r[0]??0),g:Number(r[1]??0),b:Number(r[2]??0)});break;case`rgba`:a=xe({r:Number(r[0]??0),g:Number(r[1]??0),b:Number(r[2]??0),a:Number(r[3]??0)});break;case`literal`:a=xe(e.value);break;case`hex`:a=xe(`#${e.value}`);break}switch(e.length?.type){case`%`:i=Number(e.length.value)/100;break}return{offset:i,color:a}})}function Ee(e){let t=0;switch(e.orientation?.type){case`angular`:t=Number(e.orientation.value);break}return{type:`linear-gradient`,angle:t,stops:Te(e.colorStops)}}function De(e){return e.orientation?.map(e=>{switch(e?.type){default:return null}}),{type:`radial-gradient`,stops:Te(e.colorStops)}}function Oe(e){return e.startsWith(`linear-gradient(`)||e.startsWith(`radial-gradient(`)}function ke(e){return Ce(e).map(e=>{switch(e?.type){case`linear-gradient`:return Ee(e);case`repeating-linear-gradient`:return{...Ee(e),repeat:!0};case`radial-gradient`:return De(e);case`repeating-radial-gradient`:return{...De(e),repeat:!0};default:return}}).filter(Boolean)}var Ae=[`color`];function je(e){let t;return t=typeof e==`string`?{color:e}:{...e},t.color&&=xe(t.color),V(t,Ae)}var Me=[`linearGradient`,`radialGradient`,`rotateWithShape`];function Ne(e){let t;if(t=typeof e==`string`?{image:e}:{...e},t.image){let{type:e,...n}=ke(t.image)[0]??{};switch(e){case`radial-gradient`:return{radialGradient:n};case`linear-gradient`:return{linearGradient:n}}}return V(t,Me)}function Pe(e){return B({name:e.name,params:e.params})}var Fe=[`image`,`cropRect`,`stretchRect`,`tile`,`dpi`,`opacity`,`rotateWithShape`,`imagePipelines`];function Ie(e){let t;t=typeof e==`string`?{image:e}:{...e};let n=V(t,Fe);return n.imagePipelines=t.imagePipelines?.length?t.imagePipelines.map(Pe):void 0,B(n)}var Le=[`preset`,`foregroundColor`,`backgroundColor`];function Re(e){let t;return t=typeof e==`string`?{preset:e}:{...e},L(t.foregroundColor)?delete t.foregroundColor:t.foregroundColor=xe(t.foregroundColor),L(t.backgroundColor)?delete t.backgroundColor:t.backgroundColor=xe(t.backgroundColor),V(t,Le)}function ze(e){return!L(e.color)}function Be(e){return typeof e==`string`?be(e):ze(e)}function Ve(e){return!L(e.image)&&Oe(e.image)||!!e.linearGradient||!!e.radialGradient}function He(e){return typeof e==`string`?Oe(e):Ve(e)}function Ue(e){return!L(e.image)&&!Oe(e.image)}function We(e){return typeof e==`string`?!be(e)&&!Oe(e):Ue(e)}function Ge(e){return!L(e.preset)}function Ke(e){return typeof e==`string`?!1:Ge(e)}function qe(e){let t={enabled:e&&typeof e==`object`?e.enabled??!0:!0};return Be(e)&&Object.assign(t,je(e)),He(e)&&Object.assign(t,Ne(e)),We(e)&&Object.assign(t,Ie(e)),Ke(e)&&Object.assign(t,Re(e)),V(B(t),Array.from(new Set([`enabled`,...Ae,...Fe,...Me,...Le])))}function Je(){return{backgroundImage:`none`,backgroundSize:`auto, auto`,backgroundColor:`none`,backgroundColormap:`none`}}function Ye(e){return typeof e==`string`?{...qe(e)}:{...qe(e),...V(e,[`width`,`style`,`lineCap`,`lineJoin`,`headEnd`,`tailEnd`])}}function Xe(){return{outlineWidth:0,outlineOffset:0,outlineColor:`none`,outlineStyle:`none`}}function Ze(e){return typeof e==`string`?{enabled:!0,color:xe(e)}:{...e,enabled:e.enabled??!0,color:L(e.color)?ye:xe(e.color)}}function Qe(){return{boxShadow:`none`}}function $e(e){return B({blur:e.blur,brightness:e.brightness,contrast:e.contrast,grayscale:e.grayscale,hueRotate:e.hueRotate,invert:e.invert,opacity:e.opacity,saturate:e.saturate,sepia:e.sepia,duotone:e.duotone?[xe(e.duotone[0]),xe(e.duotone[1])]:void 0,biLevel:e.biLevel,colorChange:e.colorChange?{from:xe(e.colorChange.from),to:xe(e.colorChange.to)}:void 0})}var et=[`fill`,`outline`,`shadow`,`transform`,`transformOrigin`,`filter`];function tt(e){let t=V(e,et),{rotate:n,scaleX:r,scaleY:i,skewX:a,skewY:o,translateX:s,translateY:c}=e,l=[];return(s||c)&&l.push(`translate(${s||0}, ${c||0})`),n&&l.push(`rotate(${n}deg)`),(r||i)&&l.push(`scale(${r??1}, ${i??1})`),a&&l.push(`skewX(${a}deg)`),o&&l.push(`skewY(${o}deg)`),l.length>0&&(t.transform=l.join(` `)),(e.textStrokeWidth||e.textStrokeColor)&&(t.outline={color:e.textStrokeColor,width:e.textStrokeWidth}),e.color&&(t.fill={color:e.color}),(e.shadowOffsetX||e.shadowOffsetY||e.shadowBlur||e.shadowColor)&&(t.shadow={offsetX:e.shadowOffsetX,offsetY:e.shadowOffsetY,blur:e.shadowBlur,color:e.shadowColor}),t}function nt(e){let t=tt(e);return B({fill:L(t.fill)?void 0:qe(t.fill),outline:L(t.outline)?void 0:Ye(t.outline),shadow:L(t.shadow)?void 0:Ze(t.shadow),transform:L(t.transform)?void 0:t.transform,transformOrigin:t.transformOrigin,filter:t.filter?$e(t.filter):void 0})}function rt(){return{overflow:`visible`,direction:void 0,display:void 0,boxSizing:void 0,width:void 0,height:void 0,maxHeight:void 0,maxWidth:void 0,minHeight:void 0,minWidth:void 0,position:void 0,left:0,top:0,right:void 0,bottom:void 0,borderTop:void 0,borderLeft:void 0,borderRight:void 0,borderBottom:void 0,borderWidth:0,border:void 0,flex:void 0,flexBasis:void 0,flexDirection:void 0,flexGrow:void 0,flexShrink:void 0,flexWrap:void 0,justifyContent:void 0,gap:void 0,alignContent:void 0,alignItems:void 0,alignSelf:void 0,marginTop:void 0,marginLeft:void 0,marginRight:void 0,marginBottom:void 0,margin:void 0,paddingTop:void 0,paddingLeft:void 0,paddingRight:void 0,paddingBottom:void 0,padding:void 0}}function it(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:`none`,transformOrigin:`center`}}function at(){return{...rt(),...it(),...Qe(),...Je(),...Xe(),borderRadius:0,borderColor:`none`,borderStyle:`solid`,visibility:`visible`,filter:`none`,opacity:1,pointerEvents:`auto`,maskImage:`none`}}function ot(){return{highlight:{},highlightImage:`none`,highlightReferImage:`none`,highlightColormap:`none`,highlightLine:`none`,highlightSize:`cover`,highlightThickness:`100%`}}function st(){return{listStyle:{},listStyleType:`none`,listStyleImage:`none`,listStyleColormap:`none`,listStyleSize:`cover`,listStylePosition:`outside`}}function ct(){return{...ot(),color:`#000000`,verticalAlign:`baseline`,letterSpacing:0,wordSpacing:0,fontSize:14,fontWeight:`normal`,fontFamily:``,fontStyle:`normal`,fontKerning:`normal`,textTransform:`none`,textOrientation:`mixed`,textDecoration:`none`}}function lt(){return{...st(),writingMode:`horizontal-tb`,textWrap:`wrap`,textAlign:`start`,textIndent:0,lineHeight:1.2}}function ut(){return{...lt(),...ct(),textStrokeWidth:0,textStrokeColor:`none`}}var dt=[`textIndent`,`lineHeight`,`letterSpacing`,`wordSpacing`,`fontSize`,`textStrokeWidth`,`borderRadius`,`opacity`,`rotate`,`scaleX`,`scaleY`,`skewX`,`skewY`,`translateX`,`translateY`,`borderWidth`,`flex`,`flexGrow`,`flexShrink`];function ft(e){let t=B({...e,color:L(e.color)?void 0:xe(e.color),backgroundColor:L(e.backgroundColor)?void 0:xe(e.backgroundColor),borderColor:L(e.borderColor)?void 0:xe(e.borderColor),outlineColor:L(e.outlineColor)?void 0:xe(e.outlineColor),shadowColor:L(e.shadowColor)?void 0:xe(e.shadowColor),textStrokeColor:L(e.textStrokeColor)?void 0:xe(e.textStrokeColor)});for(let e of dt)if(e in t){let n=z(t[e]);n===void 0?delete t[e]:t[e]=n}return t}function pt(){return{...at(),...ut()}}var mt=/\r\n|\n\r|\n|\r/;RegExp(`${mt.source}|<br\\/>`,`g`);var ht=RegExp(`^(${mt.source})$`),gt=`
2
2
  `;function _t(e){return ht.test(e)}function vt(e){let t=[];function n(){return t[t.length-1]}function r(e,n,r){let i=e?ft(e):{},a=n?qe(n):void 0,o=r?Ye(r):void 0,s=B({...i,fill:a,outline:o,fragments:[]});return t[t.length-1]?.fragments.length===0?t[t.length-1]=s:t.push(s),s}function i(e=``,t,i,a){let o=t?ft(t):{},s=i?qe(i):void 0,c=a?Ye(a):void 0;Array.from(e).forEach(e=>{if(_t(e)){let{fragments:e,fill:t,outline:i,...a}=n()||r();e.length||e.push(B({...o,fill:s,outline:c,content:gt})),r(a,t,i)}else{let t=n()||r(),i=t.fragments[t.fragments.length-1];if(i){let{content:t,fill:n,outline:r,...a}=i;if(ee(s,n)&&ee(c,r)&&ee(o,a)){i.content=`${t}${e}`;return}}t.fragments.push(B({...o,fill:s,outline:c,content:e}))}})}(Array.isArray(e)?e:[e]).forEach(e=>{if(typeof e==`string`)r(),i(e);else if(bt(e)){let{content:t,fill:n,outline:a,...o}=e;r(o,n,a),i(t)}else if(yt(e)){let{fragments:t,fill:n,outline:a,...o}=e;r(o,n,a),t.forEach(e=>{let{content:t,fill:n,outline:r,...a}=e;i(t,a,n,r)})}else Array.isArray(e)?(r(),e.forEach(e=>{if(typeof e==`string`)i(e);else if(bt(e)){let{content:t,fill:n,outline:r,...a}=e;i(t,a,n,r)}})):console.warn(`Failed to parse text content`,e)});let a=n();return a&&!a.fragments.length&&a.fragments.push({content:``}),t}function yt(e){return e&&typeof e==`object`&&`fragments`in e&&Array.isArray(e.fragments)}function bt(e){return e&&typeof e==`object`&&`content`in e&&typeof e.content==`string`}function xt(e){return B({type:e.type,intensities:e.intensities,maxFontSize:e.maxFontSize??100})}function St(e){return typeof e==`string`||Array.isArray(e)?{enabled:!0,content:vt(e)}:B({enabled:e.enabled??!0,content:vt(e.content??``),style:e.style?ft(e.style):void 0,deformation:e.deformation?xt(e.deformation):void 0,measureDom:e.measureDom,fonts:e.fonts,...nt(e),effects:e.effects?e.effects.map(e=>nt(e)):void 0})}var Ct=new Set,wt=!1;function Tt(e,t,n=2){let r=t&&t.length,i=r?t[0]*n:e.length;Ct.size&&Ct.clear();let a=Et(e,0,i,n,!0),o=[];if(!a||a.next===a.prev)return o;let s=0,c=0,l=0;if(r&&(a=Pt(e,t,a,n)),e.length>80*n){s=e[0],c=e[1];let t=s,r=c;for(let a=n;a<i;a+=n){let n=e[a],i=e[a+1];n<s&&(s=n),i<c&&(c=i),n>t&&(t=n),i>r&&(r=i)}l=Math.max(t-s,r-c),l=l===0?0:32767/l}return Ot(a,o,s,c,l),o}function Et(e,t,n,r,i){let a=null;if(i===vn(e,t,n,r)>0)for(let i=t;i<n;i+=r)a=hn(i/r|0,e[i],e[i+1],a);else for(let i=n-r;i>=t;i-=r)a=hn(i/r|0,e[i],e[i+1],a);return a&&cn(a,a.next)&&(gn(a),a=a.next),a}function Dt(e,t=e){let n=t===e,r=e,i;do i=!1,r!==r.next&&(Ct.size===0||!Ct.has(r))&&(cn(r,r.next)||sn(r.prev,r,r.next)===0)?((n||r===t)&&(t=r.prev),wt=!0,gn(r),r=r.prev,i=!0):(n||r!==t)&&(r=r.next,i=!n);while(i||r!==t);return t}function Ot(e,t,n,r,i){i&&$t(e,n,r,i);let a=e,o=!1;for(;e.prev!==e.next;){let s=e.prev,c=e.next;if(sn(s,e,c)<0&&(i?At(e,n,r,i):kt(e))){t.push(s.i,e.i,c.i),gn(e),e=c,a=c;continue}if(e=c,e===a){if(wt=!1,e=Dt(e),wt){a=e;continue}if(!o){e=jt(e,t),a=e,o=!0;continue}Mt(e,t,n,r,i);break}}}function kt(e){let t=e.prev,n=e,r=e.next,i=t.x,a=n.x,o=r.x,s=t.y,c=n.y,l=r.y,u=Math.min(i,a,o),d=Math.min(s,c,l),f=Math.max(i,a,o),p=Math.max(s,c,l),m=r.next;for(;m!==t;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=p&&!(i===m.x&&s===m.y)&&an(i,s,a,c,o,l,m.x,m.y)&&sn(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function At(e,t,n,r){let i=e.prev,a=e,o=e.next,s=i.x,c=a.x,l=o.x,u=i.y,d=a.y,f=o.y,p=Math.min(s,c,l),m=Math.min(u,d,f),h=Math.max(s,c,l),g=Math.max(u,d,f),_=nn(p,m,t,n,r),v=nn(h,g,t,n,r),y=e.prevZ;for(;y&&y.z>=_;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==o&&!(s===y.x&&u===y.y)&&an(s,u,c,d,l,f,y.x,y.y)&&sn(y.prev,y,y.next)>=0)return!1;y=y.prevZ}let b=e.nextZ;for(;b&&b.z<=v;){if(b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==o&&!(s===b.x&&u===b.y)&&an(s,u,c,d,l,f,b.x,b.y)&&sn(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function jt(e,t){let n=e,r=!1;do{let i=n.prev,a=n.next.next;ln(i,n,n.next,a,!1)&&fn(i,a)&&fn(a,i)&&(t.push(i.i,n.i,a.i),gn(n),gn(n.next),n=e=a,r=!0),n=n.next}while(n!==e);return r?Dt(n):n}function Mt(e,t,n,r,i){let a=e;do{let e=a.next.next;for(;e!==a.prev;){if(a.i!==e.i&&on(a,e)){let o=mn(a,e);a=Dt(a,a.next),o=Dt(o,o.next),Ot(a,t,n,r,i),Ot(o,t,n,r,i);return}e=e.next}a=a.next}while(a!==e)}var Nt=!1;function Pt(e,t,n,r){let i=[];for(let n=0,a=t.length;n<a;n++){let o=Et(e,t[n]*r,n<a-1?t[n+1]*r:e.length,r,!1);o===o.next&&Ct.add(o),i.push(rn(o))}i.sort(Ft),Vt(e.length/r,t.length),Ht(n,n),Nt=!0;for(let e=0;e<i.length;e++)n=It(i[e],n);return Nt=!1,Dt(n)}function Ft(e,t){return e.x-t.x||e.y-t.y||(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)}function It(e,t){let n=Kt(e,t);if(!n)return t;let r=mn(n,e),i=r.next;return Ht(n,i.next),Dt(r,r.next),Dt(n,n.next)}var Lt=16,H=new Float64Array,Rt=0,zt=[],Bt=[];function Vt(e,t){let n=Math.ceil((e+2*t)/Lt)+t+2;H.length<n*4&&(H=new Float64Array(n*4)),Rt=0}function Ht(e,t){let n=e;do{let e=Rt++;zt[e]=n;let r=1/0,i=1/0,a=-1/0,o=-1/0,s=0;do{let t=n.next;n.z=e,n.x<r&&(r=n.x),n.x>a&&(a=n.x),n.y<i&&(i=n.y),n.y>o&&(o=n.y),t.x<r&&(r=t.x),t.x>a&&(a=t.x),t.y<i&&(i=t.y),t.y>o&&(o=t.y),n=t}while(++s<Lt&&n!==t);Bt[e]=n;let c=e*4;H[c]=r,H[c+1]=i,H[c+2]=a,H[c+3]=o}while(n!==t)}function Ut(e,t){let n=e.z*4;t.x<H[n]&&(H[n]=t.x),t.y<H[n+1]&&(H[n+1]=t.y),t.x>H[n+2]&&(H[n+2]=t.x),t.y>H[n+3]&&(H[n+3]=t.y)}function Wt(e){let t=Bt[e];for(;t.prev.next!==t;)t=t.next;return Bt[e]=t,t}function Gt(e){let t=zt[e];for(;t.prev.next!==t;)t=t.next;return zt[e]=t,t}function Kt(e,t){let n=t,r=e.x,i=e.y,a=-1/0,o;if(cn(e,n))return n;for(let t=0,s=0;t<Rt;t++,s+=4){if(i<H[s+1]||i>H[s+3]||H[s]>r||H[s+2]<=a)continue;let c=Wt(t);n=Gt(t);do{if(n.prev.next===n){if(cn(e,n.next))return n.next;if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){let e=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=r&&e>a&&(a=e,o=n.x<n.next.x?n:n.next,e===r))return o}}n=n.next}while(n!==c)}if(!o)return null;let s=o.x,c=o.y,l=Math.min(i,c),u=Math.max(i,c),d=1/0;for(let t=0,f=0;t<Rt;t++,f+=4){if(H[f+2]<s||H[f]>r||H[f+3]<l||H[f+1]>u)continue;let p=Wt(t);n=Gt(t);do{if(n.prev.next===n&&r>=n.x&&n.x>=s&&r!==n.x&&an(i<c?r:a,i,s,c,i<c?a:r,i,n.x,n.y)){let t=Math.abs(i-n.y)/(r-n.x);(fn(n,e)||n.y===i&&n.next.y===i&&n.next.x>r)&&(t<d||t===d&&(n.x>o.x||n.x===o.x&&qt(o,n)))&&(o=n,d=t)}n=n.next}while(n!==p)}return o}function qt(e,t){return sn(e.prev,e,t.prev)<0&&sn(t.next,e,e.next)<0}var Jt=[],Yt=[],Xt=new Uint32Array,Zt=new Uint32Array,Qt=new Uint32Array(256);function $t(e,t,n,r){let i=e,a=0;do i.z=nn(i.x,i.y,t,n,r),Jt[a++]=i,i=i.next;while(i!==e);en(a);let o=null;for(let e=0;e<a;e++){let t=Jt[e];t.prevZ=o,o&&(o.nextZ=t),o=t}o.nextZ=null}function en(e){if(e<=32){for(let t=1;t<e;t++){let e=Jt[t],n=e.z,r=t-1;for(;r>=0&&Jt[r].z>n;)Jt[r+1]=Jt[r],r--;Jt[r+1]=e}return}Xt.length<e&&(Xt=new Uint32Array(e),Zt=new Uint32Array(e),Yt=Array(e));for(let t=0;t<e;t++)Xt[t]=Jt[t].z;tn(e,Jt,Xt,Yt,Zt,0),tn(e,Yt,Zt,Jt,Xt,8),tn(e,Jt,Xt,Yt,Zt,16),tn(e,Yt,Zt,Jt,Xt,24)}function tn(e,t,n,r,i,a){Qt.fill(0);for(let t=0;t<e;t++)Qt[n[t]>>>a&255]++;let o=0;for(let e=0;e<256;e++){let t=Qt[e];Qt[e]=o,o+=t}for(let o=0;o<e;o++){let e=n[o],s=Qt[e>>>a&255]++;r[s]=t[o],i[s]=e}}function nn(e,t,n,r,i){return e=(e-n)*i|0,t=(t-r)*i|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function rn(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function an(e,t,n,r,i,a,o,s){return(i-o)*(t-s)>=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function on(e,t){let n=cn(e,t)&&sn(e.prev,e,e.next)>0&&sn(t.prev,t,t.next)>0;return e.next.i!==t.i&&(n||fn(e,t)&&fn(t,e)&&(sn(e.prev,e,t.prev)!==0||sn(e,t.prev,t)!==0))&&!dn(e,t)&&(n||pn(e,t))}function sn(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function cn(e,t){return e.x===t.x&&e.y===t.y}function ln(e,t,n,r,i=!0){let a=sn(e,t,n),o=sn(e,t,r),s=sn(n,r,e),c=sn(n,r,t);return(a>0&&o<0||a<0&&o>0)&&(s>0&&c<0||s<0&&c>0)?!0:i?!!(a===0&&un(e,n,t)||o===0&&un(e,r,t)||s===0&&un(n,e,r)||c===0&&un(n,t,r)):!1}function un(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function dn(e,t){let n=Math.min(e.x,t.x),r=Math.max(e.x,t.x),i=Math.min(e.y,t.y),a=Math.max(e.y,t.y),o=e;do{let s=o.next;if(o.x>r&&s.x>r||o.x<n&&s.x<n||o.y>a&&s.y>a||o.y<i&&s.y<i){o=s;continue}if(o.i!==e.i&&s.i!==e.i&&o.i!==t.i&&s.i!==t.i&&ln(o,s,e,t))return!0;o=s}while(o!==e);return!1}function fn(e,t){return sn(e.prev,e,e.next)<0?sn(e,t,e.next)>=0&&sn(e,e.prev,t)>=0:sn(e,t,e.prev)<0||sn(e,e.next,t)<0}function pn(e,t){let n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do{let e=n.next;n.y>a!=e.y>a&&i<(e.x-n.x)*(a-n.y)/(e.y-n.y)+n.x&&(r=!r),n=e}while(n!==e);return r}function mn(e,t){let n=_n(e.i,e.x,e.y),r=_n(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function hn(e,t,n,r){let i=_n(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function gn(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ),Nt&&Ut(e.prev,e.next)}function _n(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null}}function vn(e,t,n,r){let i=0;for(let a=t,o=n-r;a<n;a+=r)i+=(e[o]-e[a])*(e[a+1]+e[o+1]),o=a;return i}var yn=l(s(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self,n.polygonClipping=r())})(e,(function(){"use strict";function e(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(o){if(r)throw TypeError(`Generator is already executing.`);for(;n;)try{if(r=1,i&&(a=o[0]&2?i.return:o[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,o[1])).done)return a;switch(i=0,a&&(o=[o[0]&2,a.value]),o[0]){case 0:case 1:a=o;break;case 4:return n.label++,{value:o[1],done:!1};case 5:n.label++,i=o[1],o=[0];continue;case 7:o=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(o[0]===6||o[0]===2)){n=0;continue}if(o[0]===3&&(!a||o[1]>a[0]&&o[1]<a[3])){n.label=o[1];break}if(o[0]===6&&n.label<a[1]){n.label=a[1],a=o;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(o);break}a[2]&&n.ops.pop(),n.trys.pop();continue}o=t.call(e,n)}catch(e){o=[6,e],i=0}finally{r=a=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}}var t=function(){function e(e,t){this.next=null,this.key=e,this.data=t,this.left=null,this.right=null}return e}();function n(e,t){return e>t?1:e<t?-1:0}function r(e,n,r){for(var i=new t(null,null),a=i,o=i;;){var s=r(e,n.key);if(s<0){if(n.left===null)break;if(r(e,n.left.key)<0){var c=n.left;if(n.left=c.right,c.right=n,n=c,n.left===null)break}o.left=n,o=n,n=n.left}else if(s>0){if(n.right===null)break;if(r(e,n.right.key)>0){var c=n.right;if(n.right=c.left,c.left=n,n=c,n.right===null)break}a.right=n,a=n,n=n.right}else break}return a.right=n.left,o.left=n.right,n.left=i.right,n.right=i.left,n}function i(e,n,i,a){var o=new t(e,n);if(i===null)return o.left=o.right=null,o;i=r(e,i,a);var s=a(e,i.key);return s<0?(o.left=i.left,o.right=i,i.left=null):s>=0&&(o.right=i.right,o.left=i,i.right=null),o}function a(e,t,n){var i=null,a=null;if(t){t=r(e,t,n);var o=n(t.key,e);o===0?(i=t.left,a=t.right):o<0?(a=t.right,t.right=null,i=t):(i=t.left,t.left=null,a=t)}return{left:i,right:a}}function o(e,t,n){return t===null?e:e===null?t:(t=r(e.key,t,n),t.left=e,t)}function s(e,t,n,r,i){if(e){r(``+t+(n?`└── `:`├── `)+i(e)+`
3
3
  `);var a=t+(n?` `:`│ `);e.left&&s(e.left,a,!1,r,i),e.right&&s(e.right,a,!0,r,i)}}var c=function(){function c(e){e===void 0&&(e=n),this._root=null,this._size=0,this._comparator=e}return c.prototype.insert=function(e,t){return this._size++,this._root=i(e,t,this._root,this._comparator)},c.prototype.add=function(e,n){var i=new t(e,n);this._root===null&&(i.left=i.right=null,this._size++,this._root=i);var a=this._comparator,o=r(e,this._root,a),s=a(e,o.key);return s===0?this._root=o:(s<0?(i.left=o.left,i.right=o,o.left=null):s>0&&(i.right=o.right,i.left=o,o.right=null),this._size++,this._root=i),this._root},c.prototype.remove=function(e){this._root=this._remove(e,this._root,this._comparator)},c.prototype._remove=function(e,t,n){var i;return t===null?null:(t=r(e,t,n),n(e,t.key)===0?(t.left===null?i=t.right:(i=r(e,t.left,n),i.right=t.right),this._size--,i):t)},c.prototype.pop=function(){var e=this._root;if(e){for(;e.left;)e=e.left;return this._root=r(e.key,this._root,this._comparator),this._root=this._remove(e.key,this._root,this._comparator),{key:e.key,data:e.data}}return null},c.prototype.findStatic=function(e){for(var t=this._root,n=this._comparator;t;){var r=n(e,t.key);if(r===0)return t;t=r<0?t.left:t.right}return null},c.prototype.find=function(e){return this._root&&(this._root=r(e,this._root,this._comparator),this._comparator(e,this._root.key)!==0)?null:this._root},c.prototype.contains=function(e){for(var t=this._root,n=this._comparator;t;){var r=n(e,t.key);if(r===0)return!0;t=r<0?t.left:t.right}return!1},c.prototype.forEach=function(e,t){for(var n=this._root,r=[],i=!1;!i;)n===null?r.length===0?i=!0:(n=r.pop(),e.call(t,n),n=n.right):(r.push(n),n=n.left);return this},c.prototype.range=function(e,t,n,r){for(var i=[],a=this._comparator,o=this._root,s;i.length!==0||o;)if(o)i.push(o),o=o.left;else{if(o=i.pop(),s=a(o.key,t),s>0)break;if(a(o.key,e)>=0&&n.call(r,o))return this;o=o.right}return this},c.prototype.keys=function(){var e=[];return this.forEach(function(t){var n=t.key;return e.push(n)}),e},c.prototype.values=function(){var e=[];return this.forEach(function(t){var n=t.data;return e.push(n)}),e},c.prototype.min=function(){return this._root?this.minNode(this._root).key:null},c.prototype.max=function(){return this._root?this.maxNode(this._root).key:null},c.prototype.minNode=function(e){if(e===void 0&&(e=this._root),e)for(;e.left;)e=e.left;return e},c.prototype.maxNode=function(e){if(e===void 0&&(e=this._root),e)for(;e.right;)e=e.right;return e},c.prototype.at=function(e){for(var t=this._root,n=!1,r=0,i=[];!n;)if(t)i.push(t),t=t.left;else if(i.length>0){if(t=i.pop(),r===e)return t;r++,t=t.right}else n=!0;return null},c.prototype.next=function(e){var t=this._root,n=null;if(e.right){for(n=e.right;n.left;)n=n.left;return n}for(var r=this._comparator;t;){var i=r(e.key,t.key);if(i===0)break;i<0?(n=t,t=t.left):t=t.right}return n},c.prototype.prev=function(e){var t=this._root,n=null;if(e.left!==null){for(n=e.left;n.right;)n=n.right;return n}for(var r=this._comparator;t;){var i=r(e.key,t.key);if(i===0)break;i<0?t=t.left:(n=t,t=t.right)}return n},c.prototype.clear=function(){return this._root=null,this._size=0,this},c.prototype.toList=function(){return d(this._root)},c.prototype.load=function(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!1);var r=e.length,i=this._comparator;if(n&&m(e,t,0,r-1,i),this._root===null)this._root=l(e,t,0,r),this._size=r;else{var a=p(this.toList(),u(e,t),i);r=this._size+r,this._root=f({head:a},0,r)}return this},c.prototype.isEmpty=function(){return this._root===null},Object.defineProperty(c.prototype,"size",{get:function(){return this._size},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"root",{get:function(){return this._root},enumerable:!0,configurable:!0}),c.prototype.toString=function(e){e===void 0&&(e=function(e){return String(e.key)});var t=[];return s(this._root,``,!0,function(e){return t.push(e)},e),t.join(``)},c.prototype.update=function(e,t,n){var r=this._comparator,s=a(e,this._root,r),c=s.left,l=s.right;r(e,t)<0?l=i(t,n,l,r):c=i(t,n,c,r),this._root=o(c,l,r)},c.prototype.split=function(e){return a(e,this._root,this._comparator)},c.prototype[Symbol.iterator]=function(){var t,n,r;return e(this,function(e){switch(e.label){case 0:t=this._root,n=[],r=!1,e.label=1;case 1:return r?[3,6]:t===null?[3,2]:(n.push(t),t=t.left,[3,5]);case 2:return n.length===0?[3,4]:(t=n.pop(),[4,t]);case 3:return e.sent(),t=t.right,[3,5];case 4:r=!0,e.label=5;case 5:return[3,1];case 6:return[2]}})},c}();function l(e,n,r,i){var a=i-r;if(a>0){var o=r+Math.floor(a/2),s=e[o],c=n[o],u=new t(s,c);return u.left=l(e,n,r,o),u.right=l(e,n,o+1,i),u}return null}function u(e,n){for(var r=new t(null,null),i=r,a=0;a<e.length;a++)i=i.next=new t(e[a],n[a]);return i.next=null,r.next}function d(e){for(var n=e,r=[],i=!1,a=new t(null,null),o=a;!i;)n?(r.push(n),n=n.left):r.length>0?(n=o=o.next=r.pop(),n=n.right):i=!0;return o.next=null,a.next}function f(e,t,n){var r=n-t;if(r>0){var i=t+Math.floor(r/2),a=f(e,t,i),o=e.head;return o.left=a,e.head=e.head.next,o.right=f(e,i+1,n),o}return null}function p(e,n,r){for(var i=new t(null,null),a=i,o=e,s=n;o!==null&&s!==null;)r(o.key,s.key)<0?(a.next=o,o=o.next):(a.next=s,s=s.next),a=a.next;return o===null?s!==null&&(a.next=s):a.next=o,i.next}function m(e,t,n,r,i){if(!(n>=r)){for(var a=e[n+r>>1],o=n-1,s=r+1;;){do o++;while(i(e[o],a)<0);do s--;while(i(e[s],a)>0);if(o>=s)break;var c=e[o];e[o]=e[s],e[s]=c,c=t[o],t[o]=t[s],t[s]=c}m(e,t,n,s,i),m(e,t,s+1,r,i)}}let h=(e,t)=>e.ll.x<=t.x&&t.x<=e.ur.x&&e.ll.y<=t.y&&t.y<=e.ur.y,g=(e,t)=>{if(t.ur.x<e.ll.x||e.ur.x<t.ll.x||t.ur.y<e.ll.y||e.ur.y<t.ll.y)return null;let n=e.ll.x<t.ll.x?t.ll.x:e.ll.x,r=e.ur.x<t.ur.x?e.ur.x:t.ur.x,i=e.ll.y<t.ll.y?t.ll.y:e.ll.y,a=e.ur.y<t.ur.y?e.ur.y:t.ur.y;return{ll:{x:n,y:i},ur:{x:r,y:a}}},_=2**-52;_===void 0&&(_=2**-52);let v=_*_,y=(e,t)=>{if(-_<e&&e<_&&-_<t&&t<_)return 0;let n=e-t;return n*n<v*e*t?0:e<t?-1:1};class b{constructor(){this.reset()}reset(){this.xRounder=new x,this.yRounder=new x}round(e,t){return{x:this.xRounder.round(e),y:this.yRounder.round(t)}}}class x{constructor(){this.tree=new c,this.round(0)}round(e){let t=this.tree.add(e),n=this.tree.prev(t);if(n!==null&&y(t.key,n.key)===0)return this.tree.remove(e),n.key;let r=this.tree.next(t);return r!==null&&y(t.key,r.key)===0?(this.tree.remove(e),r.key):e}}let S=new b,C=134217729;function w(e,t,n,r,i){let a,o,s,c,l=t[0],u=r[0],d=0,f=0;u>l==u>-l?(a=l,l=t[++d]):(a=u,u=r[++f]);let p=0;if(d<e&&f<n)for(u>l==u>-l?(o=l+a,s=a-(o-l),l=t[++d]):(o=u+a,s=a-(o-u),u=r[++f]),a=o,s!==0&&(i[p++]=s);d<e&&f<n;)u>l==u>-l?(o=a+l,c=o-a,s=a-(o-c)+(l-c),l=t[++d]):(o=a+u,c=o-a,s=a-(o-c)+(u-c),u=r[++f]),a=o,s!==0&&(i[p++]=s);for(;d<e;)o=a+l,c=o-a,s=a-(o-c)+(l-c),l=t[++d],a=o,s!==0&&(i[p++]=s);for(;f<n;)o=a+u,c=o-a,s=a-(o-c)+(u-c),u=r[++f],a=o,s!==0&&(i[p++]=s);return(a!==0||p===0)&&(i[p++]=a),p}function T(e,t){let n=t[0];for(let r=1;r<e;r++)n+=t[r];return n}function E(e){return new Float64Array(e)}let D=E(4),O=E(8),k=E(12),A=E(16),j=E(4);function M(e,t,n,r,i,a,o){let s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,E,M,N=e-i,P=n-i,F=t-a,I=r-a;b=N*I,f=C*N,p=f-(f-N),m=N-p,f=C*I,h=f-(f-I),g=I-h,x=m*g-(b-p*h-m*h-p*g),S=F*P,f=C*F,p=f-(f-F),m=F-p,f=C*P,h=f-(f-P),g=P-h,E=m*g-(S-p*h-m*h-p*g),_=x-E,d=x-_,D[0]=x-(_+d)+(d-E),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,D[1]=y-(_+d)+(d-S),M=v+_,d=M-v,D[2]=v-(M-d)+(_-d),D[3]=M;let L=T(4,D),R=22204460492503146e-32*o;if(L>=R||-L>=R||(d=e-N,s=e-(N+d)+(d-i),d=n-P,l=n-(P+d)+(d-i),d=t-F,c=t-(F+d)+(d-a),d=r-I,u=r-(I+d)+(d-a),s===0&&c===0&&l===0&&u===0)||(R=11093356479670487e-47*o+33306690738754706e-32*Math.abs(L),L+=N*u+I*s-(F*l+P*c),L>=R||-L>=R))return L;b=s*I,f=C*s,p=f-(f-s),m=s-p,f=C*I,h=f-(f-I),g=I-h,x=m*g-(b-p*h-m*h-p*g),S=c*P,f=C*c,p=f-(f-c),m=c-p,f=C*P,h=f-(f-P),g=P-h,E=m*g-(S-p*h-m*h-p*g),_=x-E,d=x-_,j[0]=x-(_+d)+(d-E),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,j[1]=y-(_+d)+(d-S),M=v+_,d=M-v,j[2]=v-(M-d)+(_-d),j[3]=M;let z=w(4,D,4,j,O);b=N*u,f=C*N,p=f-(f-N),m=N-p,f=C*u,h=f-(f-u),g=u-h,x=m*g-(b-p*h-m*h-p*g),S=F*l,f=C*F,p=f-(f-F),m=F-p,f=C*l,h=f-(f-l),g=l-h,E=m*g-(S-p*h-m*h-p*g),_=x-E,d=x-_,j[0]=x-(_+d)+(d-E),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,j[1]=y-(_+d)+(d-S),M=v+_,d=M-v,j[2]=v-(M-d)+(_-d),j[3]=M;let B=w(z,O,4,j,k);return b=s*u,f=C*s,p=f-(f-s),m=s-p,f=C*u,h=f-(f-u),g=u-h,x=m*g-(b-p*h-m*h-p*g),S=c*l,f=C*c,p=f-(f-c),m=c-p,f=C*l,h=f-(f-l),g=l-h,E=m*g-(S-p*h-m*h-p*g),_=x-E,d=x-_,j[0]=x-(_+d)+(d-E),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,j[1]=y-(_+d)+(d-S),M=v+_,d=M-v,j[2]=v-(M-d)+(_-d),j[3]=M,A[w(B,k,4,j,A)-1]}function N(e,t,n,r,i,a){let o=(t-a)*(n-i),s=(e-i)*(r-a),c=o-s,l=Math.abs(o+s);return Math.abs(c)>=33306690738754716e-32*l?c:-M(e,t,n,r,i,a,l)}let P=(e,t)=>e.x*t.y-e.y*t.x,F=(e,t)=>e.x*t.x+e.y*t.y,I=(e,t,n)=>{let r=N(e.x,e.y,t.x,t.y,n.x,n.y);return r>0?-1:+(r<0)},L=e=>Math.sqrt(F(e,e)),R=(e,t,n)=>{let r={x:t.x-e.x,y:t.y-e.y},i={x:n.x-e.x,y:n.y-e.y};return P(i,r)/L(i)/L(r)},z=(e,t,n)=>{let r={x:t.x-e.x,y:t.y-e.y},i={x:n.x-e.x,y:n.y-e.y};return F(i,r)/L(i)/L(r)},B=(e,t,n)=>t.y===0?null:{x:e.x+t.x/t.y*(n-e.y),y:n},V=(e,t,n)=>t.x===0?null:{x:n,y:e.y+t.y/t.x*(n-e.x)},ee=(e,t,n,r)=>{if(t.x===0)return V(n,r,e.x);if(r.x===0)return V(e,t,n.x);if(t.y===0)return B(n,r,e.y);if(r.y===0)return B(e,t,n.y);let i=P(t,r);if(i==0)return null;let a={x:n.x-e.x,y:n.y-e.y},o=P(a,t)/i,s=P(a,r)/i,c=e.x+s*t.x,l=n.x+o*r.x,u=e.y+s*t.y,d=n.y+o*r.y;return{x:(c+l)/2,y:(u+d)/2}};class te{static compare(e,t){let n=te.comparePoints(e.point,t.point);return n===0?(e.point!==t.point&&e.link(t),e.isLeft===t.isLeft?re.compare(e.segment,t.segment):e.isLeft?1:-1):n}static comparePoints(e,t){return e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)}constructor(e,t){e.events===void 0?e.events=[this]:e.events.push(this),this.point=e,this.isLeft=t}link(e){if(e.point===this.point)throw Error(`Tried to link already linked events`);let t=e.point.events;for(let e=0,n=t.length;e<n;e++){let n=t[e];this.point.events.push(n),n.point=this.point}this.checkForConsuming()}checkForConsuming(){let e=this.point.events.length;for(let t=0;t<e;t++){let n=this.point.events[t];if(n.segment.consumedBy===void 0)for(let r=t+1;r<e;r++){let e=this.point.events[r];e.consumedBy===void 0&&n.otherSE.point.events===e.otherSE.point.events&&n.segment.consume(e.segment)}}}getAvailableLinkedEvents(){let e=[];for(let t=0,n=this.point.events.length;t<n;t++){let n=this.point.events[t];n!==this&&!n.segment.ringOut&&n.segment.isInResult()&&e.push(n)}return e}getLeftmostComparator(e){let t=new Map,n=n=>{let r=n.otherSE;t.set(n,{sine:R(this.point,e.point,r.point),cosine:z(this.point,e.point,r.point)})};return(e,r)=>{t.has(e)||n(e),t.has(r)||n(r);let{sine:i,cosine:a}=t.get(e),{sine:o,cosine:s}=t.get(r);return i>=0&&o>=0?a<s?1:a>s?-1:0:i<0&&o<0?a<s?-1:+(a>s):o<i?-1:+(o>i)}}}let ne=0;class re{static compare(e,t){let n=e.leftSE.point.x,r=t.leftSE.point.x,i=e.rightSE.point.x,a=t.rightSE.point.x;if(a<n)return 1;if(i<r)return-1;let o=e.leftSE.point.y,s=t.leftSE.point.y,c=e.rightSE.point.y,l=t.rightSE.point.y;if(n<r){if(s<o&&s<c)return 1;if(s>o&&s>c)return-1;let n=e.comparePoint(t.leftSE.point);if(n<0)return 1;if(n>0)return-1;let r=t.comparePoint(e.rightSE.point);return r===0?-1:r}if(n>r){if(o<s&&o<l)return-1;if(o>s&&o>l)return 1;let n=t.comparePoint(e.leftSE.point);if(n!==0)return n;let r=e.comparePoint(t.rightSE.point);return r<0?1:r>0?-1:1}if(o<s)return-1;if(o>s)return 1;if(i<a){let n=t.comparePoint(e.rightSE.point);if(n!==0)return n}if(i>a){let n=e.comparePoint(t.rightSE.point);if(n<0)return 1;if(n>0)return-1}if(i!==a){let e=c-o,t=i-n,u=l-s,d=a-r;if(e>t&&u<d)return 1;if(e<t&&u>d)return-1}return i>a?1:i<a||c<l?-1:c>l?1:e.id<t.id?-1:+(e.id>t.id)}constructor(e,t,n,r){this.id=++ne,this.leftSE=e,e.segment=this,e.otherSE=t,this.rightSE=t,t.segment=this,t.otherSE=e,this.rings=n,this.windings=r}static fromRing(e,t,n){let r,i,a,o=te.comparePoints(e,t);if(o<0)r=e,i=t,a=1;else if(o>0)r=t,i=e,a=-1;else throw Error(`Tried to create degenerate segment at [${e.x}, ${e.y}]`);return new re(new te(r,!0),new te(i,!1),[n],[a])}replaceRightSE(e){this.rightSE=e,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}bbox(){let e=this.leftSE.point.y,t=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:e<t?e:t},ur:{x:this.rightSE.point.x,y:e>t?e:t}}}vector(){return{x:this.rightSE.point.x-this.leftSE.point.x,y:this.rightSE.point.y-this.leftSE.point.y}}isAnEndpoint(e){return e.x===this.leftSE.point.x&&e.y===this.leftSE.point.y||e.x===this.rightSE.point.x&&e.y===this.rightSE.point.y}comparePoint(e){if(this.isAnEndpoint(e))return 0;let t=this.leftSE.point,n=this.rightSE.point,r=this.vector();if(t.x===n.x)return e.x===t.x?0:e.x<t.x?1:-1;let i=(e.y-t.y)/r.y,a=t.x+i*r.x;if(e.x===a)return 0;let o=(e.x-t.x)/r.x,s=t.y+o*r.y;return e.y===s?0:e.y<s?-1:1}getIntersection(e){let t=this.bbox(),n=e.bbox(),r=g(t,n);if(r===null)return null;let i=this.leftSE.point,a=this.rightSE.point,o=e.leftSE.point,s=e.rightSE.point,c=h(t,o)&&this.comparePoint(o)===0,l=h(n,i)&&e.comparePoint(i)===0,u=h(t,s)&&this.comparePoint(s)===0,d=h(n,a)&&e.comparePoint(a)===0;if(l&&c)return d&&!u?a:!d&&u?s:null;if(l)return u&&i.x===s.x&&i.y===s.y?null:i;if(c)return d&&a.x===o.x&&a.y===o.y?null:o;if(d&&u)return null;if(d)return a;if(u)return s;let f=ee(i,this.vector(),o,e.vector());return f===null||!h(r,f)?null:S.round(f.x,f.y)}split(e){let t=[],n=e.events!==void 0,r=new te(e,!0),i=new te(e,!1),a=this.rightSE;this.replaceRightSE(i),t.push(i),t.push(r);let o=new re(r,a,this.rings.slice(),this.windings.slice());return te.comparePoints(o.leftSE.point,o.rightSE.point)>0&&o.swapEvents(),te.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),n&&(r.checkForConsuming(),i.checkForConsuming()),t}swapEvents(){let e=this.rightSE;this.rightSE=this.leftSE,this.leftSE=e,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(let e=0,t=this.windings.length;e<t;e++)this.windings[e]*=-1}consume(e){let t=this,n=e;for(;t.consumedBy;)t=t.consumedBy;for(;n.consumedBy;)n=n.consumedBy;let r=re.compare(t,n);if(r!==0){if(r>0){let e=t;t=n,n=e}if(t.prev===n){let e=t;t=n,n=e}for(let e=0,r=n.rings.length;e<r;e++){let r=n.rings[e],i=n.windings[e],a=t.rings.indexOf(r);a===-1?(t.rings.push(r),t.windings.push(i)):t.windings[a]+=i}n.rings=null,n.windings=null,n.consumedBy=t,n.leftSE.consumedBy=t.leftSE,n.rightSE.consumedBy=t.rightSE}}prevInResult(){return this._prevInResult===void 0&&(this.prev?this.prev.isInResult()?this._prevInResult=this.prev:this._prevInResult=this.prev.prevInResult():this._prevInResult=null),this._prevInResult}beforeState(){if(this._beforeState!==void 0)return this._beforeState;if(!this.prev)this._beforeState={rings:[],windings:[],multiPolys:[]};else{let e=this.prev.consumedBy||this.prev;this._beforeState=e.afterState()}return this._beforeState}afterState(){if(this._afterState!==void 0)return this._afterState;let e=this.beforeState();this._afterState={rings:e.rings.slice(0),windings:e.windings.slice(0),multiPolys:[]};let t=this._afterState.rings,n=this._afterState.windings,r=this._afterState.multiPolys;for(let e=0,r=this.rings.length;e<r;e++){let r=this.rings[e],i=this.windings[e],a=t.indexOf(r);a===-1?(t.push(r),n.push(i)):n[a]+=i}let i=[],a=[];for(let e=0,r=t.length;e<r;e++){if(n[e]===0)continue;let r=t[e],o=r.poly;if(a.indexOf(o)===-1)if(r.isExterior)i.push(o);else{a.indexOf(o)===-1&&a.push(o);let e=i.indexOf(r.poly);e!==-1&&i.splice(e,1)}}for(let e=0,t=i.length;e<t;e++){let t=i[e].multiPoly;r.indexOf(t)===-1&&r.push(t)}return this._afterState}isInResult(){if(this.consumedBy)return!1;if(this._isInResult!==void 0)return this._isInResult;let e=this.beforeState().multiPolys,t=this.afterState().multiPolys;switch(me.type){case`union`:{let n=e.length===0,r=t.length===0;this._isInResult=n!==r;break}case`intersection`:{let n,r;e.length<t.length?(n=e.length,r=t.length):(n=t.length,r=e.length),this._isInResult=r===me.numMultiPolys&&n<r;break}case`xor`:{let n=Math.abs(e.length-t.length);this._isInResult=n%2==1;break}case`difference`:{let n=e=>e.length===1&&e[0].isSubject;this._isInResult=n(e)!==n(t);break}default:throw Error(`Unrecognized operation type found ${me.type}`)}return this._isInResult}}class ie{constructor(e,t,n){if(!Array.isArray(e)||e.length===0||(this.poly=t,this.isExterior=n,this.segments=[],typeof e[0][0]!=`number`||typeof e[0][1]!=`number`))throw Error(`Input geometry is not a valid Polygon or MultiPolygon`);let r=S.round(e[0][0],e[0][1]);this.bbox={ll:{x:r.x,y:r.y},ur:{x:r.x,y:r.y}};let i=r;for(let t=1,n=e.length;t<n;t++){if(typeof e[t][0]!=`number`||typeof e[t][1]!=`number`)throw Error(`Input geometry is not a valid Polygon or MultiPolygon`);let n=S.round(e[t][0],e[t][1]);n.x===i.x&&n.y===i.y||(this.segments.push(re.fromRing(i,n,this)),n.x<this.bbox.ll.x&&(this.bbox.ll.x=n.x),n.y<this.bbox.ll.y&&(this.bbox.ll.y=n.y),n.x>this.bbox.ur.x&&(this.bbox.ur.x=n.x),n.y>this.bbox.ur.y&&(this.bbox.ur.y=n.y),i=n)}(r.x!==i.x||r.y!==i.y)&&this.segments.push(re.fromRing(i,r,this))}getSweepEvents(){let e=[];for(let t=0,n=this.segments.length;t<n;t++){let n=this.segments[t];e.push(n.leftSE),e.push(n.rightSE)}return e}}class ae{constructor(e,t){if(!Array.isArray(e))throw Error(`Input geometry is not a valid Polygon or MultiPolygon`);this.exteriorRing=new ie(e[0],this,!0),this.bbox={ll:{x:this.exteriorRing.bbox.ll.x,y:this.exteriorRing.bbox.ll.y},ur:{x:this.exteriorRing.bbox.ur.x,y:this.exteriorRing.bbox.ur.y}},this.interiorRings=[];for(let t=1,n=e.length;t<n;t++){let n=new ie(e[t],this,!1);n.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=n.bbox.ll.x),n.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=n.bbox.ll.y),n.bbox.ur.x>this.bbox.ur.x&&(this.bbox.ur.x=n.bbox.ur.x),n.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=n.bbox.ur.y),this.interiorRings.push(n)}this.multiPoly=t}getSweepEvents(){let e=this.exteriorRing.getSweepEvents();for(let t=0,n=this.interiorRings.length;t<n;t++){let n=this.interiorRings[t].getSweepEvents();for(let t=0,r=n.length;t<r;t++)e.push(n[t])}return e}}class oe{constructor(e,t){if(!Array.isArray(e))throw Error(`Input geometry is not a valid Polygon or MultiPolygon`);try{typeof e[0][0][0]==`number`&&(e=[e])}catch{}this.polys=[],this.bbox={ll:{x:1/0,y:1/0},ur:{x:-1/0,y:-1/0}};for(let t=0,n=e.length;t<n;t++){let n=new ae(e[t],this);n.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=n.bbox.ll.x),n.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=n.bbox.ll.y),n.bbox.ur.x>this.bbox.ur.x&&(this.bbox.ur.x=n.bbox.ur.x),n.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=n.bbox.ur.y),this.polys.push(n)}this.isSubject=t}getSweepEvents(){let e=[];for(let t=0,n=this.polys.length;t<n;t++){let n=this.polys[t].getSweepEvents();for(let t=0,r=n.length;t<r;t++)e.push(n[t])}return e}}class se{static factory(e){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];if(!r.isInResult()||r.ringOut)continue;let i=null,a=r.leftSE,o=r.rightSE,s=[a],c=a.point,l=[];for(;i=a,a=o,s.push(a),a.point!==c;)for(;;){let e=a.getAvailableLinkedEvents();if(e.length===0){let e=s[0].point,t=s[s.length-1].point;throw Error(`Unable to complete output ring starting at [${e.x}, ${e.y}]. Last matching segment found ends at [${t.x}, ${t.y}].`)}if(e.length===1){o=e[0].otherSE;break}let n=null;for(let e=0,t=l.length;e<t;e++)if(l[e].point===a.point){n=e;break}if(n!==null){let e=l.splice(n)[0],r=s.splice(e.index);r.unshift(r[0].otherSE),t.push(new se(r.reverse()));continue}l.push({index:s.length,point:a.point});let r=a.getLeftmostComparator(i);o=e.sort(r)[0].otherSE;break}t.push(new se(s))}return t}constructor(e){this.events=e;for(let t=0,n=e.length;t<n;t++)e[t].segment.ringOut=this;this.poly=null}getGeom(){let e=this.events[0].point,t=[e];for(let n=1,r=this.events.length-1;n<r;n++){let r=this.events[n].point,i=this.events[n+1].point;I(r,e,i)!==0&&(t.push(r),e=r)}if(t.length===1)return null;let n=t[0],r=t[1];I(n,e,r)===0&&t.shift(),t.push(t[0]);let i=this.isExteriorRing()?1:-1,a=this.isExteriorRing()?0:t.length-1,o=this.isExteriorRing()?t.length:-1,s=[];for(let e=a;e!=o;e+=i)s.push([t[e].x,t[e].y]);return s}isExteriorRing(){if(this._isExteriorRing===void 0){let e=this.enclosingRing();this._isExteriorRing=e?!e.isExteriorRing():!0}return this._isExteriorRing}enclosingRing(){return this._enclosingRing===void 0&&(this._enclosingRing=this._calcEnclosingRing()),this._enclosingRing}_calcEnclosingRing(){let e=this.events[0];for(let t=1,n=this.events.length;t<n;t++){let n=this.events[t];te.compare(e,n)>0&&(e=n)}let t=e.segment.prevInResult(),n=t?t.prevInResult():null;for(;;){if(!t)return null;if(!n)return t.ringOut;if(n.ringOut!==t.ringOut)return n.ringOut.enclosingRing()===t.ringOut?t.ringOut.enclosingRing():t.ringOut;t=n.prevInResult(),n=t?t.prevInResult():null}}}class ce{constructor(e){this.exteriorRing=e,e.poly=this,this.interiorRings=[]}addInterior(e){this.interiorRings.push(e),e.poly=this}getGeom(){let e=[this.exteriorRing.getGeom()];if(e[0]===null)return null;for(let t=0,n=this.interiorRings.length;t<n;t++){let n=this.interiorRings[t].getGeom();n!==null&&e.push(n)}return e}}class le{constructor(e){this.rings=e,this.polys=this._composePolys(e)}getGeom(){let e=[];for(let t=0,n=this.polys.length;t<n;t++){let n=this.polys[t].getGeom();n!==null&&e.push(n)}return e}_composePolys(e){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];if(!r.poly)if(r.isExteriorRing())t.push(new ce(r));else{let e=r.enclosingRing();e.poly||t.push(new ce(e)),e.poly.addInterior(r)}}return t}}class ue{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:re.compare;this.queue=e,this.tree=new c(t),this.segments=[]}process(e){let t=e.segment,n=[];if(e.consumedBy)return e.isLeft?this.queue.remove(e.otherSE):this.tree.remove(t),n;let r=e.isLeft?this.tree.add(t):this.tree.find(t);if(!r)throw Error(`Unable to find segment #${t.id} [${t.leftSE.point.x}, ${t.leftSE.point.y}] -> [${t.rightSE.point.x}, ${t.rightSE.point.y}] in SweepLine tree.`);let i=r,a=r,o,s;for(;o===void 0;)i=this.tree.prev(i),i===null?o=null:i.key.consumedBy===void 0&&(o=i.key);for(;s===void 0;)a=this.tree.next(a),a===null?s=null:a.key.consumedBy===void 0&&(s=a.key);if(e.isLeft){let r=null;if(o){let e=o.getIntersection(t);if(e!==null&&(t.isAnEndpoint(e)||(r=e),!o.isAnEndpoint(e))){let t=this._splitSafely(o,e);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}}let i=null;if(s){let e=s.getIntersection(t);if(e!==null&&(t.isAnEndpoint(e)||(i=e),!s.isAnEndpoint(e))){let t=this._splitSafely(s,e);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}}if(r!==null||i!==null){let e=null;e=r===null?i:i===null||te.comparePoints(r,i)<=0?r:i,this.queue.remove(t.rightSE),n.push(t.rightSE);let a=t.split(e);for(let e=0,t=a.length;e<t;e++)n.push(a[e])}n.length>0?(this.tree.remove(t),n.push(e)):(this.segments.push(t),t.prev=o)}else{if(o&&s){let e=o.getIntersection(s);if(e!==null){if(!o.isAnEndpoint(e)){let t=this._splitSafely(o,e);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}if(!s.isAnEndpoint(e)){let t=this._splitSafely(s,e);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}}}this.tree.remove(t)}return n}_splitSafely(e,t){this.tree.remove(e);let n=e.rightSE;this.queue.remove(n);let r=e.split(t);return r.push(n),e.consumedBy===void 0&&this.tree.add(e),r}}let de=typeof process<`u`&&process.env.POLYGON_CLIPPING_MAX_QUEUE_SIZE||1e6,fe=typeof process<`u`&&process.env.POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS||1e6;class pe{run(e,t,n){me.type=e,S.reset();let r=[new oe(t,!0)];for(let e=0,t=n.length;e<t;e++)r.push(new oe(n[e],!1));if(me.numMultiPolys=r.length,me.type===`difference`){let e=r[0],t=1;for(;t<r.length;)g(r[t].bbox,e.bbox)===null?r.splice(t,1):t++}if(me.type===`intersection`)for(let e=0,t=r.length;e<t;e++){let t=r[e];for(let n=e+1,i=r.length;n<i;n++)if(g(t.bbox,r[n].bbox)===null)return[]}let i=new c(te.compare);for(let e=0,t=r.length;e<t;e++){let t=r[e].getSweepEvents();for(let e=0,n=t.length;e<n;e++)if(i.insert(t[e]),i.size>de)throw Error(`Infinite loop when putting segment endpoints in a priority queue (queue size too big).`)}let a=new ue(i),o=i.size,s=i.pop();for(;s;){let e=s.key;if(i.size===o){let t=e.segment;throw Error(`Unable to pop() ${e.isLeft?`left`:`right`} SweepEvent [${e.point.x}, ${e.point.y}] from segment #${t.id} [${t.leftSE.point.x}, ${t.leftSE.point.y}] -> [${t.rightSE.point.x}, ${t.rightSE.point.y}] from queue.`)}if(i.size>de)throw Error(`Infinite loop when passing sweep line over endpoints (queue size too big).`);if(a.segments.length>fe)throw Error(`Infinite loop when passing sweep line over endpoints (too many sweep line segments).`);let t=a.process(e);for(let e=0,n=t.length;e<n;e++){let n=t[e];n.consumedBy===void 0&&i.insert(n)}o=i.size,s=i.pop()}return S.reset(),new le(se.factory(a.segments)).getGeom()}}let me=new pe;return{union:function(e){var t=[...arguments].slice(1);return me.run(`union`,e,t)},intersection:function(e){var t=[...arguments].slice(1);return me.run(`intersection`,e,t)},xor:function(e){var t=[...arguments].slice(1);return me.run(`xor`,e,t)},difference:function(e){var t=[...arguments].slice(1);return me.run(`difference`,e,t)}}}))}))(),1);function bn(e,t,n,r={}){let{radius:i=1}=r;e.moveTo(t,n),e.arc(t,n,i,0,Math.PI*2)}var xn={arcs:`bevel`,bevel:`bevel`,miter:`miter`,"miter-clip":`miter`,round:`round`};function Sn(e,t){let{fill:n=`#000`,stroke:r=`none`,strokeWidth:i=r===`none`?0:1,strokeLinecap:a=`round`,strokeLinejoin:o=`miter`,strokeMiterlimit:s=0,strokeDasharray:c=[],strokeDashoffset:l=0,shadowOffsetX:u=0,shadowOffsetY:d=0,shadowBlur:f=0,shadowColor:p=`rgba(0, 0, 0, 0)`}=t;e.fillStyle=n,e.strokeStyle=r,e.lineWidth=i,e.lineCap=a,e.lineJoin=xn[o],e.miterLimit=s,e.setLineDash(c),e.lineDashOffset=l,e.shadowOffsetX=u,e.shadowOffsetY=d,e.shadowBlur=f,e.shadowColor=p}var U=class e{constructor(e=0,t=0,n){this._x=e,this._y=t,this._onUpdate=n}static get MAX(){return new e(1/0,1/0)}static get MIN(){return new e(-1/0,-1/0)}static lerp(t,n,r){return new e(n.x,n.y).clone().sub(t).multiply(r).add(t)}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}get left(){return this.x}set left(e){this.x=e}get top(){return this.y}set top(e){this.y=e}get x(){return this._x}set x(e){this._x!==e&&(this._x=e,this._onUpdate?.(this))}get y(){return this._y}set y(e){this._y!==e&&(this._y=e,this._onUpdate?.(this))}set(e=0,t=e){return(this._x!==e||this._y!==t)&&(this._x=e,this._y=t,this._onUpdate?.(this)),this}add(e){return this.set(this._x+e.x,this._y+e.y)}sub(e){return this.set(this._x-e.x,this._y-e.y)}subVectors(e,t){return this.set(e.x-t.x,e.y-t.y)}multiply(e=0,t=e){return this.set(this._x*e,this._y*t)}divide(e=0,t=e){return this.set(e===0?this._x:this._x/e,t===0?this._y:this._y/t)}cross(e){return this._x*e.y-this._y*e.x}dot(e){return this._x*e.x+this._y*e.y}rotate(e,t={x:0,y:0}){let{x:n,y:r}=this,i=Math.cos(e),a=Math.sin(e);return this.set((n-t.x)*i-(r-t.y)*a+t.x,(n-t.x)*a+(r-t.y)*i+t.y)}getLength(){let{x:e,y:t}=this;return Math.sqrt(e*e+t*t)}getAngle(){return Math.atan2(-this.x,-this.y)+Math.PI}distanceTo(e){return Math.hypot(e.x-this.x,e.y-this.y)}normalize(){let e=1/(this.getLength()||1);return this.set(this.x*e,this.y*e),this}copyFrom(e){return(this._x!==e.x||this._y!==e.y)&&(this._x=e.x,this._y=e.y,this._onUpdate?.(this)),this}copyTo(e){return e.set(this._x,this._y),e}equals(e){return this._x===e.x&&this._y===e.y}get array(){return[this.x,this.y]}finite(){return this.set(Number.isFinite(this._x)?this._x:0,Number.isFinite(this._y)?this._y:0)}lengthSquared(){return this._x*this._x+this._y*this._y}length(){return Math.sqrt(this.lengthSquared())}scale(e,t=e,n={x:0,y:0}){return this.set(n.x+(this._x-n.x)*e,n.y+(this._y-n.y)*t)}skew(e,t=0,n={x:0,y:0}){let r=this._x-n.x,i=this._y-n.y;return this.set(n.x+(r+Math.tan(e)*i),n.y+(i+Math.tan(t)*r))}clampMin(...e){return this.set(Math.min(this._x,...e.map(e=>e.x)),Math.min(this._y,...e.map(e=>e.y)))}clampMax(...e){return this.set(Math.max(this.x,...e.map(e=>e.x)),Math.max(this.y,...e.map(e=>e.y)))}clone(t){return new e(this._x,this._y,t??this._onUpdate)}toJSON(){return{x:this._x,y:this._y}}destroy(){this._onUpdate=void 0}},W=class e{constructor(e=0,t=0,n=0,r=0){this.left=e,this.top=t,this.width=n,this.height=r}get x(){return this.left}set x(e){this.left=e}get y(){return this.top}set y(e){this.top=e}get right(){return this.left+this.width}get bottom(){return this.top+this.height}get center(){return new U((this.left+this.right)/2,(this.top+this.bottom)/2)}get array(){return[this.left,this.top,this.width,this.height]}static from(...t){if(t.length===0)return new e;if(t.length===1)return t[0].clone();let n=t[0],r=t.slice(1).reduce((e,t)=>(e.left=Math.min(e.left,t.left),e.top=Math.min(e.top,t.top),e.right=Math.max(e.right,t.right),e.bottom=Math.max(e.bottom,t.bottom),e),{left:n?.left??0,top:n?.top??0,right:n?.right??0,bottom:n?.bottom??0});return new e(r.left,r.top,r.right-r.left,r.bottom-r.top)}translate(e,t){return this.left+=e,this.top+=t,this}copy(e){return this.left=e.left,this.top=e.top,this.width=e.width,this.height=e.height,this}clone(){return new e(this.left,this.top,this.width,this.height)}};function Cn(e){let t=[];for(let n=0;n<e.length;n+=2)t.push([e[n],e[n+1]]);let n=t[0],r=t[t.length-1];return n&&r&&(n[0]!==r[0]||n[1]!==r[1])&&t.push([n[0],n[1]]),t}function wn(e){let t=e.filter(e=>e.length>=6).map(Cn);if(!t.length)return[];let n=[[t[0]]];for(let e=1;e<t.length;e++)n=yn.default.xor(n,[[t[e]]]);return n}function Tn(e){let t=[];for(let n of e)for(let e of n){let n=[];for(let[t,r]of e)n.push(t,r);t.push(n)}return t}function En(e,t,n){let r=wn(t),i=wn(n),a;switch(e){case`union`:a=yn.default.union(r,i);break;case`intersection`:a=yn.default.intersection(r,i);break;case`difference`:a=yn.default.difference(r,i);break;case`xor`:a=yn.default.xor(r,i);break}return Tn(a)}function Dn(e,t,n,r,i){let a=(r-t)*.5,o=(i-n)*.5,s=e*e,c=e*s;return(2*n-2*r+a+o)*c+(-3*n+3*r-2*a-o)*s+a*e+n}var On=Math.PI*2;function kn(e){return e.replace(/[^a-z0-9]/gi,`-`).replace(/\B([A-Z])/g,`-$1`).toLowerCase()}function An(e,t,n,r){let i=t.clone().sub(e),a=r.clone().sub(n),o=n.clone().sub(e),s=i.cross(a);if(s===0)return null;let c=o.cross(a)/s;return Math.abs(c)>1?null:new U(e.x+c*i.x,e.y+c*i.y)}var jn=/([\w-]+)\((.+?)\)/g,Mn=/[^,]+/g,Nn=/([-e.\d]+)(.*)/;function Pn(e,t={}){let n=[],r;for(;(r=jn.exec(e))!==null;){let[,e,i]=r;e&&n.push({name:e,args:Fn(e,i,t)})}return n}function Fn(e,t,n={}){let r=[],i,a=0;for(;(i=Mn.exec(t))!==null;)r.push(In(e,i[0],{...n,index:a++}));return r}function In(e,t,n={}){let{width:r=1,height:i=1,index:a=0}=n,o=t.match(Nn),s={unit:o?.[2]??null,value:t,intValue:Number(o?.[1]),normalizedIntValue:0,normalizedDefaultIntValue:0};switch(e){case`scale`:case`scaleX`:case`scaleY`:case`scale3d`:s.normalizedDefaultIntValue=1;break}switch(s.unit){case`%`:s.normalizedIntValue=s.intValue/100;break;case`rad`:s.normalizedIntValue=s.intValue/On;break;case`deg`:s.normalizedIntValue=s.intValue/360;break;case`px`:switch(a){case 0:s.normalizedIntValue=s.intValue/r;break;case 1:s.normalizedIntValue=s.intValue/i;break}break;default:s.normalizedIntValue=s.intValue;break}return s}function Ln(e,t){let n=1-e;return n*n*n*t}function Rn(e,t){let n=1-e;return 3*n*n*e*t}function zn(e,t){return 3*(1-e)*e*e*t}function Bn(e,t){return e*e*e*t}function Vn(e,t,n,r,i){return Ln(e,t)+Rn(e,n)+zn(e,r)+Bn(e,i)}function Hn(e,t,n,r,i,a){return(n-e)*(a-t)-(i-e)*(r-t)}function Un(e,t,n){let r=n.length,i=0;for(let a=0;a<r;a+=2){let o=n[a],s=n[a+1],c=(a+2)%r,l=n[c],u=n[c+1];s<=t?u>t&&Hn(o,s,l,u,e,t)>0&&i++:u<=t&&Hn(o,s,l,u,e,t)<0&&i--}return i}function Wn(e,t,n){let r=n.length,i=0;for(let a=0;a<r;a+=2){let o=n[a],s=n[a+1],c=(a+2)%r,l=n[c],u=n[c+1];(s<=t&&u>t||s>t&&u<=t)&&e<o+(t-s)/(u-s)*(l-o)&&i++}return i}function Gn(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s,l=c===0?0:((e-n)*o+(t-r)*s)/c;l<0?l=0:l>1&&(l=1);let u=n+l*o,d=r+l*s;return Math.hypot(e-u,t-d)}function Kn(e,t,n=`nonzero`){return t.length<6?!1:n===`evenodd`?(Wn(e.x,e.y,t)&1)==1:Un(e.x,e.y,t)!==0}function qn(e,t,n=`nonzero`){let{x:r,y:i}=e;if(n===`evenodd`){let e=0;for(let n=0,a=t.length;n<a;n++){let a=t[n];a.length>=6&&(e+=Wn(r,i,a))}return(e&1)==1}let a=0;for(let e=0,n=t.length;e<n;e++){let n=t[e];n.length>=6&&(a+=Un(r,i,n))}return a!==0}function Jn(e,t,n=!1){let r=t.length;if(r<2)return 1/0;let{x:i,y:a}=e;if(r===2)return Math.hypot(i-t[0],a-t[1]);let o=1/0;for(let e=0;e<r-2;e+=2){let n=Gn(i,a,t[e],t[e+1],t[e+2],t[e+3]);n<o&&(o=n)}if(n&&r>=6){let e=Gn(i,a,t[r-2],t[r-1],t[0],t[1]);e<o&&(o=e)}return o}function Yn(e){if(e.length<6)return null;let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a=0;a<e.length;a+=2){let o=e[a],s=e[a+1];o<t&&(t=o),s<n&&(n=s),o>r&&(r=o),s>i&&(i=s)}return{minX:t,minY:n,maxX:r,maxY:i}}function Xn(e,t){return e.minX>=t.minX&&e.maxX<=t.maxX&&e.minY>=t.minY&&e.maxY<=t.maxY}function Zn(e,t){let n=e.length/2,r=Math.max(1,Math.floor(n/9)),i=0,a=0;for(let o=0;o<n;o+=r)i++,Kn({x:e[o*2],y:e[o*2+1]},t,`evenodd`)&&a++;return i>0&&a*2>i}function Qn(e){let t=e.length,n=e.map(Yn),r=Array.from({length:t}).fill(0),i=e.map(()=>[]);for(let a=0;a<t;a++){let o=n[a];if(o)for(let s=0;s<t;s++){if(a===s)continue;let t=n[s];!t||!Xn(o,t)||Zn(e[a],e[s])&&(r[a]++,i[a].push(s))}}return e.map((e,t)=>{let n=-1,a=-1;for(let e of i[t])r[e]>a&&(a=r[e],n=e);return{index:t,depth:r[t],parentIndex:n}})}var $n=1e-7;function er(e,t,n){let r=e.length/2,i=[0,...t,r],a=[],o=[];for(let t=0;t<i.length-1;t++){let r=i[t],s=i[t+1];t>0&&o.push(a.length/2);let c=a.length;for(let t=r;t<s;t++){let r=e[t*2],i=e[t*2+1],o=a.length;o>c&&Math.abs(r-a[o-2])<n&&Math.abs(i-a[o-1])<n||a.push(r,i)}a.length-c>=4&&Math.abs(a[a.length-2]-a[c])<n&&Math.abs(a[a.length-1]-a[c+1])<n&&(a.length-=2)}return{points:a,holes:o}}function tr(e,t={}){let{vertices:n=[],indices:r=[],holes:i=[],verticesStride:a=2,verticesOffset:o=n.length/a,indicesOffset:s=r.length}=t;({points:e,holes:i}=er(e,i,$n));let c=Tt(e,i,2);if(c.length){for(let e=0;e<c.length;e+=3)r[s++]=c[e]+o,r[s++]=c[e+1]+o,r[s++]=c[e+2]+o;let t=o*a;for(let r=0;r<e.length;r+=2)n[t]=e[r],n[t+1]=e[r+1],t+=a}return{vertices:n,indices:r}}var nr=8,rr=1.1920929e-7,ir=1;function ar(e,t,n,r,i,a,o,s,c=.5,l=[]){let u=(ir-Math.min(.99,Math.max(0,c)))/1;return u*=u,or(e,t,n,r,i,a,o,s,l,u,0),l.push(o,s),l}function or(e,t,n,r,i,a,o,s,c,l,u){if(u>nr)return;let d=(e+n)/2,f=(t+r)/2,p=(n+i)/2,m=(r+a)/2,h=(i+o)/2,g=(a+s)/2,_=(d+p)/2,v=(f+m)/2,y=(p+h)/2,b=(m+g)/2,x=(_+y)/2,S=(v+b)/2;if(u>0){let u=o-e,d=s-t,f=Math.abs((n-o)*d-(r-s)*u),p=Math.abs((i-o)*d-(a-s)*u);if(f>rr&&p>rr){if((f+p)*(f+p)<=l*(u*u+d*d)){c.push(x,S);return}}else if(f>rr){if(f*f<=l*(u*u+d*d)){c.push(x,S);return}}else if(p>rr){if(p*p<=l*(u*u+d*d)){c.push(x,S);return}}else if(u=x-(e+o)/2,d=S-(t+s)/2,u*u+d*d<=l){c.push(x,S);return}}or(e,t,d,f,_,v,x,S,c,l,u+1),or(x,S,y,b,h,g,o,s,c,l,u+1)}var sr=8,cr=1.1920929e-7,lr=1;function ur(e,t,n,r,i,a,o=.5,s=[]){let c=(lr-Math.min(.99,Math.max(0,o)))/1;return c*=c,dr(s,e,t,n,r,i,a,c,0),s.push(i,a),s}function dr(e,t,n,r,i,a,o,s,c){if(c>sr)return;let l=(t+r)/2,u=(n+i)/2,d=(r+a)/2,f=(i+o)/2,p=(l+d)/2,m=(u+f)/2,h=a-t,g=o-n,_=Math.abs((r-a)*g-(i-o)*h);if(_>cr){if(_*_<=s*(h*h+g*g)){e.push(p,m);return}}else if(h=p-(t+a)/2,g=m-(n+o)/2,h*h+g*g<=s){e.push(p,m);return}dr(e,t,n,l,u,p,m,s,c+1),dr(e,p,m,d,f,a,o,s,c+1)}function fr(e,t,n,r,i,a){return(n-e)*(a-t)-(r-t)*(i-e)}function pr(e,t,n){let r=n.length,i=0;for(let a=0,o=r-2;a<r;o=a,a+=2){let r=n[a],s=n[a+1],c=n[o],l=n[o+1];s<=t?l>t&&fr(c,l,r,s,e,t)>0&&i++:l<=t&&fr(c,l,r,s,e,t)<0&&i--}return i}function mr(e,t){let n=t[0]-e[0],r=t[1]-e[1];return Math.sqrt(n*n+r*r)}function hr(e){let t=0,n=e.length;for(let r=0,i=n-2;r<n;i=r,r+=2)t+=e[i]*e[r+1]-e[r]*e[i+1];return Math.sign(t)}function gr(e,t){return e.minX<=t.maxX&&e.maxX>=t.minX&&e.minY<=t.maxY&&e.maxY>=t.minY}function _r(e){let t=e.map((e,t)=>({index:t})),n=[],r=e.map((e,t)=>{let r=e.length;if(!r)return n[t]=null,[];let i=[2**53-1,0],a=[0,2**53-1],o=[-(2**53-1),0],s=[0,-(2**53-1)];for(let t=0;t<r;t+=2){let n=e[t],r=e[t+1];i[0]>n&&(i=[n,r]),a[1]>r&&(a=[n,r]),o[0]<n&&(o=[n,r]),s[1]<r&&(s=[n,r])}n[t]={minX:i[0],minY:a[1],maxX:o[0],maxY:s[1]};let c=[(i[0]+o[0])/2,(a[1]+s[1])/2],l,u,d,f,p,m,h,g;for(let t=0;t<r;t+=2){let n=e[t],r=e[t+1],i=Math.abs(n-c[0]),a=Math.abs(r-c[1]);r<c[1]&&(!l||i<l)&&(l=i,d=[n,r]),r>c[1]&&(!u||i<u)&&(u=i,f=[n,r]),n<c[0]&&(!p||a<p)&&(p=a,h=[n,r]),n>c[0]&&(!m||a<m)&&(m=a,g=[n,r])}return[i,a,o,s,d,f,h,g].filter(Boolean)});for(let i=0,a=e.length;i<a;i++){let o=[],s=r[i],c=n[i];for(let t=0;t<a;t++){if(i===t)continue;let a=n[t];if(!c||!a||!gr(c,a))continue;let l={},u=[];for(let n=0,r=s.length;n<r;n++){let[r,i]=s[n],a=pr(r,i,e[t]);l[a]=(l[a]??0)+1,u.push(a)}u.filter(e=>e!==0).length>u.filter(e=>e===0).length&&o.push({index:i,parentIndex:t,winding:Number(Array.from(Object.entries(l)).sort((e,t)=>t[1]-e[1])?.[0]?.[0]??0),dist:mr(r[i][0],r[t][0])})}let l=o.reduce((e,t)=>e+t.winding,0);o.length&&l+hr(e[i])===0&&(o.sort((e,t)=>e.dist-t.dist),t[i]=o[0])}return t}function vr(e,t){let n=1-e;return n*n*t}function yr(e,t){return 2*(1-e)*e*t}function br(e,t){return e*e*t}function xr(e,t,n,r){return vr(e,t)+yr(e,n)+br(e,r)}function Sr(e){switch(e){case`round`:case`bevel`:case`miter`:return e;default:return`miter`}}function Cr(e){return{width:e?.strokeWidth??1,alignment:.5,join:Sr(e?.strokeLinejoin),cap:e?.strokeLinecap??`butt`,miterLimit:e?.strokeMiterlimit??10}}var wr=1e-4,Tr=1e-4;function Er(e,t={}){let{vertices:n=[],indices:r=[],flipAlignment:i=!1,closed:a=!0}=t,o=t.lineStyle??Cr(t.style),s=wr;if(e.length===0||(e=Dr(e,s),e.length<4))return{vertices:n,indices:r};let c=o,l=c.alignment;if(o.alignment!==.5){let t=Or(e);i&&(t*=-1),l=(l-.5)*t+.5}let u={x:e[0],y:e[1]},d={x:e[e.length-2],y:e[e.length-1]},f=a,p=Math.abs(u.x-d.x)<s&&Math.abs(u.y-d.y)<s;if(f){e=e.slice(),p&&(e.pop(),e.pop(),d.x=e[e.length-2],d.y=e[e.length-1]);let t=(u.x+d.x)*.5,n=(d.y+u.y)*.5;e.unshift(t,n),e.push(t,n)}let m=n,h=e.length/2,g=e.length,_=m.length/2,v=c.width/2,y=v*v,b=c.miterLimit*c.miterLimit,x=e[0],S=e[1],C=e[2],w=e[3],T=0,E=0,D=-(S-w),O=x-C,k=0,A=0,j=Math.sqrt(D*D+O*O);D/=j,O/=j,D*=v,O*=v;let M=l,N=(1-M)*2,P=M*2;f||(c.cap===`round`?g+=Ar(x-D*(N-P)*.5,S-O*(N-P)*.5,x-D*N,S-O*N,x+D*P,S+O*P,m,!0)+2:c.cap===`square`&&(g+=kr(x,S,D,O,N,P,!0,m))),m.push(x-D*N,S-O*N),m.push(x+D*P,S+O*P);for(let t=1;t<h-1;++t){x=e[(t-1)*2],S=e[(t-1)*2+1],C=e[t*2],w=e[t*2+1],T=e[(t+1)*2],E=e[(t+1)*2+1],D=-(S-w),O=x-C,j=Math.sqrt(D*D+O*O),D/=j,O/=j,D*=v,O*=v,k=-(w-E),A=C-T,j=Math.sqrt(k*k+A*A),k/=j,A/=j,k*=v,A*=v;let n=C-x,r=S-w,i=C-T,a=E-w,o=n*i+r*a,s=r*i-a*n,l=s<0;if(Math.abs(s)<.001*Math.abs(o)){m.push(C-D*N,w-O*N),m.push(C+D*P,w+O*P),o>=0&&(c.join===`round`?g+=Ar(C,w,C-D*N,w-O*N,C-k*N,w-A*N,m,!1)+4:g+=2,m.push(C-k*P,w-A*P),m.push(C+k*N,w+A*N));continue}let u=(-D+x)*(-O+w)-(-D+C)*(-O+S),d=(-k+T)*(-A+w)-(-k+C)*(-A+E),f=(n*d-i*u)/s,p=(a*u-r*d)/s,h=(f-C)*(f-C)+(p-w)*(p-w),_=C+(f-C)*N,M=w+(p-w)*N,F=C-(f-C)*P,I=w-(p-w)*P,L=Math.min(n*n+r*r,i*i+a*a),R=l?N:P;h<=L+R*R*y?c.join===`bevel`||h/y>b?(l?(m.push(_,M),m.push(C+D*P,w+O*P),m.push(_,M),m.push(C+k*P,w+A*P)):(m.push(C-D*N,w-O*N),m.push(F,I),m.push(C-k*N,w-A*N),m.push(F,I)),g+=2):c.join===`round`?l?(m.push(_,M),m.push(C+D*P,w+O*P),g+=Ar(C,w,C+D*P,w+O*P,C+k*P,w+A*P,m,!0)+4,m.push(_,M),m.push(C+k*P,w+A*P)):(m.push(C-D*N,w-O*N),m.push(F,I),g+=Ar(C,w,C-D*N,w-O*N,C-k*N,w-A*N,m,!1)+4,m.push(C-k*N,w-A*N),m.push(F,I)):(m.push(_,M),m.push(F,I)):(m.push(C-D*N,w-O*N),m.push(C+D*P,w+O*P),c.join===`round`?l?g+=Ar(C,w,C+D*P,w+O*P,C+k*P,w+A*P,m,!0)+2:g+=Ar(C,w,C-D*N,w-O*N,C-k*N,w-A*N,m,!1)+2:c.join===`miter`&&h/y<=b&&(l?(m.push(F,I),m.push(F,I)):(m.push(_,M),m.push(_,M)),g+=2),m.push(C-k*N,w-A*N),m.push(C+k*P,w+A*P),g+=2)}x=e[(h-2)*2],S=e[(h-2)*2+1],C=e[(h-1)*2],w=e[(h-1)*2+1],D=-(S-w),O=x-C,j=Math.sqrt(D*D+O*O),D/=j,O/=j,D*=v,O*=v,m.push(C-D*N,w-O*N),m.push(C+D*P,w+O*P),f||(c.cap===`round`?g+=Ar(C-D*(N-P)*.5,w-O*(N-P)*.5,C-D*N,w-O*N,C+D*P,w+O*P,m,!1)+2:c.cap===`square`&&(g+=kr(C,w,D,O,N,P,!1,m)));let F=Tr*Tr;for(let e=_;e<g+_-2;++e)x=m[e*2],S=m[e*2+1],C=m[(e+1)*2],w=m[(e+1)*2+1],T=m[(e+2)*2],E=m[(e+2)*2+1],!(Math.abs(x*(w-E)+C*(E-S)+T*(S-w))<F)&&r.push(e,e+1,e+2);return{vertices:n,indices:r}}function Dr(e,t){let n=[e[0],e[1]];for(let r=2;r<e.length;r+=2){let i=e[r],a=e[r+1];(Math.abs(i-n[n.length-2])>=t||Math.abs(a-n[n.length-1])>=t)&&n.push(i,a)}return n}function Or(e){let t=e.length;if(t<6)return 1;let n=0;for(let r=0,i=e[t-2],a=e[t-1];r<t;r+=2){let t=e[r],o=e[r+1];n+=(t-i)*(o+a),i=t,a=o}return n<0?-1:1}function kr(e,t,n,r,i,a,o,s){let c=e-n*i,l=t-r*i,u=e+n*a,d=t+r*a,f,p;o?(f=r,p=-n):(f=-r,p=n);let m=c+f,h=l+p,g=u+f,_=d+p;return s.push(m,h),s.push(g,_),2}function Ar(e,t,n,r,i,a,o,s){let c=n-e,l=r-t,u=Math.atan2(c,l),d=Math.atan2(i-e,a-t);s&&u<d?u+=Math.PI*2:!s&&u>d&&(d+=Math.PI*2);let f=u,p=d-u,m=Math.abs(p),h=Math.sqrt(c*c+l*l),g=(15*m*Math.sqrt(h)/Math.PI>>0)+1,_=p/g;if(f+=_,s){o.push(e,t),o.push(n,r);for(let n=1,r=f;n<g;n++,r+=_)o.push(e,t),o.push(e+Math.sin(r)*h,t+Math.cos(r)*h);o.push(e,t),o.push(i,a)}else{o.push(n,r),o.push(e,t);for(let n=1,r=f;n<g;n++,r+=_)o.push(e+Math.sin(r)*h,t+Math.cos(r)*h),o.push(e,t);o.push(i,a),o.push(e,t)}return g*2}var jr=class e{constructor(e=1,t=0,n=0,r=1,i=0,a=0){this.a=e,this.b=t,this.c=n,this.d=r,this.tx=i,this.ty=a}_array;set(e,t,n,r,i,a){return this.a=e,this.b=t,this.c=n,this.d=r,this.tx=i,this.ty=a,this}append(e){let t=this.a,n=this.b,r=this.c,i=this.d;return this.a=e.a*t+e.b*r,this.b=e.a*n+e.b*i,this.c=e.c*t+e.d*r,this.d=e.c*n+e.d*i,this.tx=e.tx*t+e.ty*r+this.tx,this.ty=e.tx*n+e.ty*i+this.ty,this}appendFrom(e,t){let n=e.a,r=e.b,i=e.c,a=e.d,o=e.tx,s=e.ty,c=t.a,l=t.b,u=t.c,d=t.d;return this.a=n*c+r*u,this.b=n*l+r*d,this.c=i*c+a*u,this.d=i*l+a*d,this.tx=o*c+s*u+t.tx,this.ty=o*l+s*d+t.ty,this}setTransform(e,t,n,r,i,a,o,s,c){return this.a=Math.cos(o+c)*i,this.b=Math.sin(o+c)*i,this.c=-Math.sin(o-s)*a,this.d=Math.cos(o-s)*a,this.tx=e-(n*this.a+r*this.c),this.ty=t-(n*this.b+r*this.d),this}prepend(e){let t=this.tx;if(e.a!==1||e.b!==0||e.c!==0||e.d!==1){let t=this.a,n=this.c;this.a=t*e.a+this.b*e.c,this.b=t*e.b+this.b*e.d,this.c=n*e.a+this.d*e.c,this.d=n*e.b+this.d*e.d}return this.tx=t*e.a+this.ty*e.c+e.tx,this.ty=t*e.b+this.ty*e.d+e.ty,this}skewX(e){let t=Math.tan(e);return this.a+=t*this.b,this.c+=t*this.d,this.tx+=t*this.ty,this}skewY(e){let t=Math.tan(e);return this.b+=t*this.a,this.d+=t*this.c,this.ty+=t*this.tx,this}skew(e,t){let n=Math.tan(e),r=Math.tan(t),i=this.a,a=this.b,o=this.c,s=this.d,c=this.tx,l=this.ty;return this.a=i+n*a,this.b=r*i+a,this.c=o+n*s,this.d=r*o+s,this.tx=c+n*l,this.ty=r*c+l,this}translateX(e){return this.translate(e,0)}translateY(e){return this.translate(0,e)}translateZ(e){return this.translate(0,0,e)}translate3d(e,t,n){return this.translate(e,t,n)}translate(e,t,n=0){return this.tx+=e,this.ty+=t,this}scaleX(e){return this.scale(e,1)}scaleY(e){return this.scale(1,e)}scale3d(e,t,n=1){return this.scale(e,t,n)}scale(e,t,n=1){return this.a*=e,this.d*=t,this.c*=e,this.b*=t,this.tx*=e,this.ty*=t,this}rotateX(e){return this.scaleY(this._rotateToScale(e))}rotateY(e){return this.scaleX(this._rotateToScale(e))}rotateZ(e){return this.rotate(e)}rotate(e){let t=Math.cos(e),n=Math.sin(e),r=this.a,i=this.c,a=this.tx;return this.a=r*t-this.b*n,this.b=r*n+this.b*t,this.c=i*t-this.d*n,this.d=i*n+this.d*t,this.tx=a*t-this.ty*n,this.ty=a*n+this.ty*t,this}rotate3d(e,t,n,r){let[i,a,o]=this._rotate3d(e,t,n,r);return i&&this.rotateX(i),a&&this.rotateY(a),o&&this.rotateZ(o),this}_rotateToScale(e){let t=e/On;return t<=.5?t*-4+1:(t-1)*4+1}_rotate3d(e,t,n,r){if(e===1&&t===0&&n===0)return[r,0,0];if(e===0&&t===1&&n===0)return[0,r,0];if(e===0&&t===0)return[0,0,r];{let i=Math.cos(r),a=Math.sin(r),o=i+e*e*(1-i),s=e*t*(1-i)-n*a,c=e*n*(1-i)+t*a,l=i+t*t*(1-i),u=t*n*(1-i)-e*a,d=i+n*n*(1-i);return[-Math.atan2(-u,l),-Math.atan2(c,Math.sqrt(u*u+d*d)),-Math.atan2(-s,o)]}}decompose(e={x:0,y:0},t={position:{x:0,y:0},scale:{x:0,y:0},skew:{x:0,y:0},rotation:0}){let{a:n,b:r,c:i,d:a,tx:o,ty:s}=this,c=-Math.atan2(-i,a),l=Math.atan2(r,n),u=Math.abs(c+l);return u<1e-5||Math.abs(On-u)<1e-5?(t.rotation=l,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=c,t.skew.y=l),t.scale.x=Math.sqrt(n*n+r*r),t.scale.y=Math.sqrt(i*i+a*a),t.position.x=o+(e.x*n+e.y*i),t.position.y=s+(e.x*r+e.y*a),t}apply(e,t){t||=new U;let{x:n,y:r}=e;return t.x=this.a*n+this.c*r+this.tx,t.y=this.b*n+this.d*r+this.ty,t}affineInvert(){let e=this.a,t=this.b,n=this.c,r=this.d,i=this.tx,a=e*r-t*n;return this.a=r/a,this.b=-t/a,this.c=-n/a,this.d=e/a,this.tx=(n*this.ty-r*i)/a,this.ty=-(e*this.ty-t*i)/a,this}affineInverse(){return this.clone().affineInvert()}applyAffineInverse(e,t){t||=new U;let{a:n,b:r,c:i,d:a,tx:o,ty:s}=this,c=1/(n*a+i*-r),l=e.x,u=e.y;return t.x=a*c*l+-i*c*u+(s*i-o*a)*c,t.y=n*c*u+-r*c*l+(-s*n+o*r)*c,t}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}isIdentity(){let{a:e,b:t,c:n,d:r,tx:i,ty:a}=this;return e===1&&t===0&&n===0&&r===1&&i===0&&a===0}copyTo(e){return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyFrom(e){return this.a=e.a,this.b=e.b,this.c=e.c,this.d=e.d,this.tx=e.tx,this.ty=e.ty,this}equals(e){return e.a===this.a&&e.b===this.b&&e.c===this.c&&e.d===this.d&&e.tx===this.tx&&e.ty===this.ty}prependCssTransform(t,n={}){let{width:r=1,height:i=1}=n,a=new e;return Pn(t,{width:r,height:i}).reverse().forEach(({name:e,args:t})=>{let n=t.map(e=>e.normalizedIntValue);switch(e){case`translateX`:a.translateX(n[0]*r);break;case`translateY`:a.translateY(n[0]*i);break;case`translateZ`:a.translateZ(n[0]);break;case`translate`:a.translate(n[0]*r,(n[1]??n[0])*i);break;case`translate3d`:a.translate3d(n[0]*r,(n[1]??n[0])*i,n[2]??n[1]??n[0]);break;case`scaleX`:a.scaleX(n[0]);break;case`scaleY`:a.scaleY(n[0]);break;case`scale`:a.scale(n[0],n[1]??n[0]);break;case`scale3d`:a.scale3d(n[0],n[1]??n[0],n[2]??n[1]??n[0]);break;case`rotateX`:a.rotateX(n[0]*On);break;case`rotateY`:a.rotateY(n[0]*On);break;case`rotateZ`:a.rotateZ(n[0]*On);break;case`rotate`:a.rotate(n[0]*On);break;case`rotate3d`:a.rotate3d(n[0]*On,(n[1]??n[0])*On,(n[2]??n[1]??n[0])*On,(n[3]??n[2]??n[1]??n[0])*On);break;case`skewX`:a.skewX(n[0]*On);break;case`skewY`:a.skewY(n[0]*On);break;case`skew`:a.skew(n[0]*On,(n[0]??n[1])*On);break;case`matrix`:a.set(n[0],n[1],n[2],n[3],n[4],n[5]);break}}),this.prepend(a),this}clone(){return new e(this.a,this.b,this.c,this.d,this.tx,this.ty)}toArray(e,t){this._array||=new Float32Array(9);let n=t||this._array;return e?(n[0]=this.a,n[1]=this.b,n[2]=0,n[3]=this.c,n[4]=this.d,n[5]=0,n[6]=this.tx,n[7]=this.ty,n[8]=1):(n[0]=this.a,n[1]=this.c,n[2]=this.tx,n[3]=this.b,n[4]=this.d,n[5]=this.ty,n[6]=0,n[7]=0,n[8]=1),n}toString(){return`[Transform2D a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}toJSON(){return{a:this.a,b:this.b,c:this.c,d:this.d,tx:this.tx,ty:this.ty}}destroy(){this._array=void 0}};function Mr(e,t,n,r){let i=e*n+t*r,a=Math.sqrt(e*e+t*t)*Math.sqrt(n*n+r*r),o=Math.acos(Math.max(-1,Math.min(1,i/a)));return e*r-t*n<0&&(o=-o),o}function Nr(e,t,n,r,i,a,o,s){if(t===0||n===0){e.lineTo(s.x,s.y);return}r=r*Math.PI/180,t=Math.abs(t),n=Math.abs(n);let c=(o.x-s.x)/2,l=(o.y-s.y)/2,u=Math.cos(r)*c+Math.sin(r)*l,d=-Math.sin(r)*c+Math.cos(r)*l,f=t*t,p=n*n,m=u*u,h=d*d,g=m/f+h/p;if(g>1){let e=Math.sqrt(g);t=e*t,n=e*n,f=t*t,p=n*n}let _=f*h+p*m,v=(f*p-_)/_,y=Math.sqrt(Math.max(0,v));i===a&&(y=-y);let b=y*t*d/n,x=-y*n*u/t,S=Math.cos(r)*b-Math.sin(r)*x+(o.x+s.x)/2,C=Math.sin(r)*b+Math.cos(r)*x+(o.y+s.y)/2,w=Mr(1,0,(u-b)/t,(d-x)/n),T=Mr((u-b)/t,(d-x)/n,(-u-b)/t,(-d-x)/n)%(Math.PI*2);e.ellipse(S,C,t,n,r,w,w+T,a===0)}var G={WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function Pr(e,t,n=0){let r=0,i=!0,a=``,o=``,s=[];function c(e,t,n){let r=SyntaxError(`Unexpected character "${e}" at index ${t}.`);throw r.partial=n,r}function l(){a!==``&&(o===``?s.push(Number(a)):s.push(Number(a)*10**Number(o))),a=``,o=``}let u,d=e.length;for(let f=0;f<d;f++){if(u=e[f],Array.isArray(t)&&t.includes(s.length%n)&&G.FLAGS.test(u)){r=1,a=u,l();continue}if(r===0){if(G.WHITESPACE.test(u))continue;if(G.DIGIT.test(u)||G.SIGN.test(u)){r=1,a=u;continue}if(G.POINT.test(u)){r=2,a=u;continue}G.COMMA.test(u)&&(i&&c(u,f,s),i=!0)}if(r===1){if(G.DIGIT.test(u)){a+=u;continue}if(G.POINT.test(u)){a+=u,r=2;continue}if(G.EXP.test(u)){r=3;continue}G.SIGN.test(u)&&a.length===1&&G.SIGN.test(a[0])&&c(u,f,s)}if(r===2){if(G.DIGIT.test(u)){a+=u;continue}if(G.EXP.test(u)){r=3;continue}G.POINT.test(u)&&a[a.length-1]===`.`&&c(u,f,s)}if(r===3){if(G.DIGIT.test(u)){o+=u;continue}if(G.SIGN.test(u)){if(o===``){o+=u;continue}o.length===1&&G.SIGN.test(o)&&c(u,f,s)}}G.WHITESPACE.test(u)?(l(),r=0,i=!1):G.COMMA.test(u)?(l(),r=0,i=!0):G.SIGN.test(u)?(l(),r=1,a=u):G.POINT.test(u)?(l(),r=2,a=u):c(u,f,s)}return l(),s}function Fr(e,t){return e-(t-e)}function Ir(e,t){let n=new U,r=new U,i=``;for(let a=0,o=e.length;a<o;a++){let o=e[a];if(((o.type===`s`||o.type===`S`)&&!`CcSs`.includes(i)||(o.type===`t`||o.type===`T`)&&!`QqTt`.includes(i))&&r.copyFrom(n),o.type===`m`||o.type===`M`)o.type===`m`?n.add(o):n.copyFrom(o),t.moveTo(n.x,n.y),r.copyFrom(n);else if(o.type===`h`||o.type===`H`)o.type===`h`?n.x+=o.x:n.x=o.x,t.lineTo(n.x,n.y),r.copyFrom(n);else if(o.type===`v`||o.type===`V`)o.type===`v`?n.y+=o.y:n.y=o.y,t.lineTo(n.x,n.y),r.copyFrom(n);else if(o.type===`l`||o.type===`L`)o.type===`l`?n.add(o):n.copyFrom(o),t.lineTo(n.x,n.y),r.copyFrom(n);else if(o.type===`c`||o.type===`C`)o.type===`c`?(t.bezierCurveTo(n.x+o.x1,n.y+o.y1,n.x+o.x2,n.y+o.y2,n.x+o.x,n.y+o.y),r.x=n.x+o.x2,r.y=n.y+o.y2,n.add(o)):(t.bezierCurveTo(o.x1,o.y1,o.x2,o.y2,o.x,o.y),r.x=o.x2,r.y=o.y2,n.copyFrom(o));else if(o.type===`s`||o.type===`S`)o.type===`s`?(t.bezierCurveTo(Fr(n.x,r.x),Fr(n.y,r.y),n.x+o.x2,n.y+o.y2,n.x+o.x,n.y+o.y),r.x=n.x+o.x2,r.y=n.y+o.y2,n.add(o)):(t.bezierCurveTo(Fr(n.x,r.x),Fr(n.y,r.y),o.x2,o.y2,o.x,o.y),r.x=o.x2,r.y=o.y2,n.copyFrom(o));else if(o.type===`q`||o.type===`Q`)o.type===`q`?(t.quadraticCurveTo(n.x+o.x1,n.y+o.y1,n.x+o.x,n.y+o.y),r.x=n.x+o.x1,r.y=n.y+o.y1,n.add(o)):(t.quadraticCurveTo(o.x1,o.y1,o.x,o.y),r.x=o.x1,r.y=o.y1,n.copyFrom(o));else if(o.type===`t`||o.type===`T`){let e=Fr(n.x,r.x),i=Fr(n.y,r.y);r.x=e,r.y=i,o.type===`t`?(t.quadraticCurveTo(e,i,n.x+o.x,n.y+o.y),n.add(o)):(t.quadraticCurveTo(e,i,o.x,o.y),n.copyFrom(o))}else if(o.type===`a`||o.type===`A`){let e=n.clone();if(o.type===`a`){if(o.x===0&&o.y===0)continue;n.add(o)}else{if(n.equals(o))continue;n.copyFrom(o)}r.copyFrom(n),Nr(t,o.rx,o.ry,o.angle,o.largeArcFlag,o.sweepFlag,e,n)}else o.type===`z`||o.type===`Z`?(t.startPoint&&n.copyFrom(t.startPoint),t.closePath()):console.warn(`Unsupported commands`,o);i=o.type}}function Lr(e){let t,n,r=[];for(let i=0,a=e.length;i<a;i++){let a=e[i];switch(a.type){case`m`:case`M`:if(a.x.toFixed(4)===n?.x.toFixed(4)&&a.y.toFixed(4)===n?.y.toFixed(4))continue;r.push(`${a.type} ${a.x} ${a.y}`),n={x:a.x,y:a.y},t={x:a.x,y:a.y};break;case`h`:case`H`:r.push(`${a.type} ${a.x}`),n={x:a.x,y:n?.y??0};break;case`v`:case`V`:r.push(`${a.type} ${a.y}`),n={x:n?.x??0,y:a.y};break;case`l`:case`L`:r.push(`${a.type} ${a.x} ${a.y}`),n={x:a.x,y:a.y};break;case`c`:case`C`:r.push(`${a.type} ${a.x1} ${a.y1} ${a.x2} ${a.y2} ${a.x} ${a.y}`),n={x:a.x,y:a.y};break;case`s`:case`S`:r.push(`${a.type} ${a.x2} ${a.y2} ${a.x} ${a.y}`),n={x:a.x,y:a.y};break;case`q`:case`Q`:r.push(`${a.type} ${a.x1} ${a.y1} ${a.x} ${a.y}`),n={x:a.x,y:a.y};break;case`t`:case`T`:r.push(`${a.type} ${a.x} ${a.y}`),n={x:a.x,y:a.y};break;case`a`:case`A`:r.push(`${a.type} ${a.rx} ${a.ry} ${a.angle} ${a.largeArcFlag} ${a.sweepFlag} ${a.x} ${a.y}`),n={x:a.x,y:a.y};break;case`z`:case`Z`:r.push(a.type),t&&(n={x:t.x,y:t.y});break}}return r.join(` `)}var Rr=/[a-df-z][^a-df-z]*/gi;function zr(e){let t=[],n=e.match(Rr);if(!n)return t;for(let e=0,r=n.length;e<r;e++){let r=n[e],i=r.charAt(0),a=r.slice(1).trim(),o;switch(i){case`m`:case`M`:o=Pr(a);for(let e=0,n=o.length;e<n;e+=2)e===0?t.push({type:i,x:o[e],y:o[e+1]}):t.push({type:i===`m`?`l`:`L`,x:o[e],y:o[e+1]});break;case`h`:case`H`:o=Pr(a);for(let e=0,n=o.length;e<n;e++)t.push({type:i,x:o[e]});break;case`v`:case`V`:o=Pr(a);for(let e=0,n=o.length;e<n;e++)t.push({type:i,y:o[e]});break;case`l`:case`L`:o=Pr(a);for(let e=0,n=o.length;e<n;e+=2)t.push({type:i,x:o[e],y:o[e+1]});break;case`c`:case`C`:o=Pr(a);for(let e=0,n=o.length;e<n;e+=6)t.push({type:i,x1:o[e],y1:o[e+1],x2:o[e+2],y2:o[e+3],x:o[e+4],y:o[e+5]});break;case`s`:case`S`:o=Pr(a);for(let e=0,n=o.length;e<n;e+=4)t.push({type:i,x2:o[e],y2:o[e+1],x:o[e+2],y:o[e+3]});break;case`q`:case`Q`:o=Pr(a);for(let e=0,n=o.length;e<n;e+=4)t.push({type:i,x1:o[e],y1:o[e+1],x:o[e+2],y:o[e+3]});break;case`t`:case`T`:o=Pr(a);for(let e=0,n=o.length;e<n;e+=2)t.push({type:i,x:o[e],y:o[e+1]});break;case`a`:case`A`:o=Pr(a,[3,4],7);for(let e=0,n=o.length;e<n;e+=7)t.push({type:i,rx:o[e],ry:o[e+1],angle:o[e+2],largeArcFlag:o[e+3],sweepFlag:o[e+4],x:o[e+5],y:o[e+6]});break;case`z`:case`Z`:t.push({type:i});break;default:console.warn(r)}}return t}var Br=`data:image/svg+xml;`,Vr=`${Br}base64,`,Hr=`${Br}charset=utf8,`;function Ur(e){if(typeof e==`string`){let t;e.startsWith(Vr)?(e=e.substring(Vr.length,e.length),t=atob(e)):e.startsWith(Hr)?(e=e.substring(Hr.length,e.length),t=decodeURIComponent(e)):t=e;let n=new DOMParser().parseFromString(t,`text/xml`),r=n.querySelector(`parsererror`);if(r)throw Error(`${r.textContent??`parser error`}
4
- ${t}`);return n.documentElement}else return e}var Wr=`px`,Gr=90,Kr=[`mm`,`cm`,`in`,`pt`,`pc`,`px`],qr={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{px:1}};function K(e){let t=`px`;if(typeof e==`string`)for(let n=0,r=Kr.length;n<r;n++){let r=Kr[n];if(e.endsWith(r)){t=r,e=e.substring(0,e.length-r.length);break}}let n;return n=qr[t][Wr],n<0&&(n=qr[t].in*Gr),n*Number.parseFloat(e)}function Jr(e,t,n){if(!(e.hasAttribute(`transform`)||e.nodeName===`use`&&(e.hasAttribute(`x`)||e.hasAttribute(`y`))))return null;let r=Yr(e);return n.length>0&&r.prepend(n[n.length-1]),t.copyFrom(r),n.push(r),r}function Yr(e){let t=new jr;return e.nodeName===`use`&&(e.hasAttribute(`x`)||e.hasAttribute(`y`))&&t.translate(K(e.getAttribute(`x`)),K(e.getAttribute(`y`))),e.hasAttribute(`transform`)&&t.prependCssTransform(e.getAttribute(`transform`)),t}function Xr(e){return new Mi().arc(K(e.getAttribute(`cx`)||0),K(e.getAttribute(`cy`)||0),K(e.getAttribute(`r`)||0),0,Math.PI*2)}function Zr(e,t){if(!(!e.sheet||!e.sheet.cssRules||!e.sheet.cssRules.length))for(let n=0;n<e.sheet.cssRules.length;n++){let r=e.sheet.cssRules[n];if(r.type!==1)continue;let i=r.selectorText.split(/,/g).filter(Boolean).map(e=>e.trim()),a={};for(let e=r.style.length,t=0;t<e;t++){let e=r.style.item(t);a[e]=r.style.getPropertyValue(e)}for(let e=0;e<i.length;e++)t[i[e]]=Object.assign(t[i[e]]||{},{...a})}}function Qr(e){return new Mi().ellipse(K(e.getAttribute(`cx`)||0),K(e.getAttribute(`cy`)||0),K(e.getAttribute(`rx`)||0),K(e.getAttribute(`ry`)||0),0,0,Math.PI*2)}function $r(e){return new Mi().moveTo(K(e.getAttribute(`x1`)||0),K(e.getAttribute(`y1`)||0)).lineTo(K(e.getAttribute(`x2`)||0),K(e.getAttribute(`y2`)||0))}function ei(e){let t=new Mi,n=e.getAttribute(`d`);return!n||n===`none`?null:(t.addData(n),t)}var ti=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function ni(e){let t=new Mi,n=0;return e.getAttribute(`points`)?.replace(ti,(e,r,i)=>{let a=K(r),o=K(i);return n===0?t.moveTo(a,o):t.lineTo(a,o),n++,e}),t.currentCurve.autoClose=!0,t}var ri=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function ii(e){let t=new Mi,n=0;return e.getAttribute(`points`)?.replace(ri,(e,r,i)=>{let a=K(r),o=K(i);return n===0?t.moveTo(a,o):t.lineTo(a,o),n++,e}),t.currentCurve.autoClose=!1,t}function ai(e){let t=K(e.getAttribute(`x`)||0),n=K(e.getAttribute(`y`)||0),r=e.getAttribute(`rx`),i=e.getAttribute(`ry`),a=K(r??i??0),o=K(i??r??0),s=K(e.getAttribute(`width`)),c=K(e.getAttribute(`height`));a=Math.max(0,Math.min(a,s/2)),o=Math.max(0,Math.min(o,c/2));let l=.448084975506,u=new Mi;return u.moveTo(t+a,n),u.lineTo(t+s-a,n),(a!==0||o!==0)&&u.bezierCurveTo(t+s-a*l,n,t+s,n+o*l,t+s,n+o),u.lineTo(t+s,n+c-o),(a!==0||o!==0)&&u.bezierCurveTo(t+s,n+c-o*l,t+s-a*l,n+c,t+s-a,n+c),u.lineTo(t+a,n+c),(a!==0||o!==0)&&u.bezierCurveTo(t+a*l,n+c,t,n+c-o*l,t,n+c-o),u.lineTo(t,n+o),(a!==0||o!==0)&&u.bezierCurveTo(t,n+o*l,t+a*l,n,t+a,n),u}function oi(e,t,n){t=Object.assign({},t);let r={};if(e.hasAttribute(`class`)){let t=e.getAttribute(`class`).split(/\s/).filter(Boolean).map(e=>e.trim());for(let e=0;e<t.length;e++)r=Object.assign(r,n[`.${t[e]}`])}e.hasAttribute(`id`)&&(r=Object.assign(r,n[`#${e.getAttribute(`id`)}`]));for(let n=e.style.length,i=0;i<n;i++){let n=e.style.item(i),a=e.style.getPropertyValue(n);t[n]=a,r[n]=a}function i(n,i,o=a){e.hasAttribute(n)&&(t[i]=o(e.getAttribute(n))),r[n]&&(t[i]=o(r[n]))}function a(e){return e.startsWith(`url`)&&console.warn(`url access in attributes is not implemented.`),e}function o(e){return Math.max(0,Math.min(1,K(e)))}function s(e){return Math.max(0,K(e))}function c(e){return e.split(` `).filter(e=>e!==``).map(e=>K(e))}return i(`fill`,`fill`),i(`fill-opacity`,`fillOpacity`,o),i(`fill-rule`,`fillRule`),i(`opacity`,`opacity`,o),i(`stroke`,`stroke`),i(`stroke-opacity`,`strokeOpacity`,o),i(`stroke-width`,`strokeWidth`,s),i(`stroke-linecap`,`strokeLinecap`),i(`stroke-linejoin`,`strokeLinejoin`),i(`stroke-miterlimit`,`strokeMiterlimit`,s),i(`stroke-dasharray`,`strokeDasharray`,c),i(`stroke-dashoffset`,`strokeDashoffset`,K),i(`visibility`,`visibility`),t}function si(e,t,n=[],r={}){if(e.nodeType!==1)return n;let i=!1,a=null,o={...t};switch(e.nodeName){case`svg`:o=oi(e,o,r);break;case`style`:Zr(e,r);break;case`g`:o=oi(e,o,r);break;case`path`:o=oi(e,o,r),e.hasAttribute(`d`)&&(a=ei(e));break;case`rect`:o=oi(e,o,r),a=ai(e);break;case`polygon`:o=oi(e,o,r),a=ni(e);break;case`polyline`:o=oi(e,o,r),a=ii(e);break;case`circle`:o=oi(e,o,r),a=Xr(e);break;case`ellipse`:o=oi(e,o,r),a=Qr(e);break;case`line`:o=oi(e,o,r),a=$r(e);break;case`defs`:i=!0;break;case`use`:{o=oi(e,o,r);let t=(e.getAttributeNS(`http://www.w3.org/1999/xlink`,`href`)||e.getAttribute(`href`)||``).substring(1),i=e.viewportElement?.getElementById(t);i?si(i,o,n,r):console.warn(`'use node' references non-existent node id: ${t}`);break}default:console.warn(e);break}if(o.display===`none`)return n;let s=new jr,c=[],l=Jr(e,s,c);a&&(a.applyTransform(s),n.push(a),a.style={...o});let u=e.childNodes;for(let e=0,t=u.length;e<t;e++){let t=u[e];i&&t.nodeName!==`style`&&t.nodeName!==`defs`||si(t,o,n,r)}return l&&(c.pop(),c.length>0?s.copyFrom(c[c.length-1]):s.identity()),n}function ci(e){let t=Ur(e);return new Ni(si(t,{}),t.getAttribute(`viewBox`)?.trim().split(` `).map(e=>Number(e)))}var li=class{arcLengthDivision=200;_lengths=[];_adaptiveCache;_owner;_invalidating=!1;invalidate(){return this._invalidating?this:(this._invalidating=!0,this._invalidateSelf(),this._owner?.invalidate(),this._invalidating=!1,this)}_invalidateSelf(){this._lengths.length=0,this._adaptiveCache=void 0}_getCachedAdaptiveVertices(){return this._adaptiveCache??=this.getAdaptiveVertices()}getPointAt(e,t=new U){return this.getPoint(this.getUToTMapping(e),t)}isClockwise(){return!1}getControlPointRefs(){return[]}reverse(){let e=this.getControlPointRefs(),t=e.length,n=e.map(e=>e.clone());for(let r=0;r<t;r++)e[r].copyFrom(n[t-1-r]);return this.invalidate(),this}applyTransform(e){let t=typeof e==`function`;return this.getControlPointRefs().forEach(n=>{t?e(n):e.apply(n,n)}),this.invalidate(),this}getUnevenVertices(e=5,t=[]){let n=new U;for(let r=0,i=Math.max(1,e)-1;r<=i;r++)this.getPoint(r/i,n),t.push(n.x,n.y);return t}getSpacedVertices(e=5,t=[]){let n=new U;for(let r=0,i=Math.max(1,e)-1;r<=i;r++)this.getPointAt(r/i,n),t.push(n.x,n.y);return t}getAdaptiveVertices(e=[]){return this.getUnevenVertices(5,e)}_verticesToPoints(e,t=[]){for(let n=0,r=e.length;n<r;n+=2){let r=e[n],i=e[n+1];t.push(new U(r,i))}return t}getSpacedPoints(e,t=[]){let n=this.getSpacedVertices(e);return this._verticesToPoints(n,t),t}getUnevenPoints(e,t=[]){let n=this.getUnevenVertices(e);return this._verticesToPoints(n,t),t}getAdaptivePoints(e=[]){let t=this.getAdaptiveVertices();return this._verticesToPoints(t,e),e}getPoints(e,t=[]){let n;return n=e?this.getUnevenVertices(e):this.getAdaptiveVertices(),this._verticesToPoints(n,t),t}getLength(){let e=this.getLengths();return e[e.length-1]??0}getLengths(){return this._lengths.length!==this.arcLengthDivision+1&&this.updateLengths(),this._lengths}updateLengths(){let e=this.arcLengthDivision,t=[0];for(let n=0,r=this.getPoint(0),i=1;i<=e;i++){let a=this.getPoint(i/e);n+=a.distanceTo(r),t.push(n),r=a}this._lengths=t}getUToTMapping(e,t){let n=this.getLengths(),r=n.length,i=t??e*n[r-1];if(r<2)return i/n[0];let a=0,o=0,s=r-1,c;for(;o<=s;)if(a=Math.floor(o+(s-o)/2),c=n[a]-i,c<0)o=a+1;else if(c>0)s=a-1;else{s=a;break}if(a=Math.max(0,s),n[a]===i)return a/(r-1);let l=n[a],u=n[a+1]-l,d=Math.max(0,(i-l)/u);return(a+d)/(r-1)}getTangent(e,t=new U){let n=1e-4,r=Math.max(0,e-n),i=Math.min(1,e+n);return t.copyFrom(this.getPoint(i).sub(this.getPoint(r)).normalize())}getTangentAt(e,t){return this.getTangent(this.getUToTMapping(e),t)}getPosTan(e){let t=this.getLength(),n=t>0?Math.min(Math.max(e/t,0),1):0,r=this.getUToTMapping(n),i=this.getTangent(r);return{position:this.getPoint(r),tangent:i,angle:Math.atan2(i.y,i.x)}}getNormal(e,t=new U){return this.getTangent(e,t),t.set(-t.y,t.x).normalize()}getNormalAt(e,t){return this.getNormal(this.getUToTMapping(e),t)}getTForPoint(e,t=.001){let n=0,r=1,i=(n+r)/2;for(;r-n>t;){i=(n+r)/2;let a=this.getPoint(i);if(a.distanceTo(e)<t)return i;a.x<e.x?n=i:r=i}return i}getMinMax(e=U.MAX,t=U.MIN){let n=this.getAdaptiveVertices(),r=e.x,i=e.y,a=t.x,o=t.y;for(let e=0,t=n.length;e<t;e+=2){let t=n[e],s=n[e+1];t<r&&(r=t),s<i&&(i=s),t>a&&(a=t),s>o&&(o=s)}return e.set(r,i),t.set(a,o),{min:e.finite(),max:t.finite()}}getBoundingBox(){let{min:e,max:t}=this.getMinMax();return new W(e.x,e.y,t.x-e.x,t.y-e.y)}isPointInFill(e,t={}){return Kn(e,this._getCachedAdaptiveVertices(),t.fillRule)}isPointInStroke(e,t={}){let{strokeWidth:n=1,tolerance:r=0,closed:i=!1}=t;return Jn(e,this._getCachedAdaptiveVertices(),i)<=n/2+r}contains(e,t,n={}){return this.isPointInFill({x:e,y:t},n)}getFillVertices(e){return this.getAdaptiveVertices()}fillTriangulate(e){return tr(this.getFillVertices(e),e)}isClosed(){let e=this._getCachedAdaptiveVertices(),t=e.length;if(t<6)return!1;let n=1e-4;return Math.abs(e[0]-e[t-2])<n&&Math.abs(e[1]-e[t-1])<n}strokeTriangulate(e){return Er(this.getAdaptiveVertices(),{...e,closed:e?.closed??this.isClosed()})}toCommands(){let e=[],t=this.getPoints();for(let n=0,r=t.length;n<r;n++){let r=t[n];n===0?e.push({type:`M`,x:r.x,y:r.y}):e.push({type:`L`,x:r.x,y:r.y})}return e}toData(){return Lr(this.toCommands())}drawTo(e){return this.toCommands().forEach(t=>{switch(t.type){case`M`:e.moveTo(t.x,t.y);break;case`L`:e.lineTo(t.x,t.y);break}}),this}copyFrom(e){return this.arcLengthDivision=e.arcLengthDivision,this}clone(){return new this.constructor().copyFrom(this)}},ui=new jr,di=new jr,fi=new jr,pi=new U,mi=class extends li{constructor(e=new U,t=new U,n=new U,r=0,i=0,a=Math.PI*2,o=!1){super(),this._center=e,this._radius=t,this._diff=n,this.rotate=r,this.startAngle=i,this.endAngle=a,this.clockwise=o}get cx(){return this._center.x}set cx(e){this._center.x=e}get cy(){return this._center.y}set cy(e){this._center.y=e}get rx(){return this._radius.x}set rx(e){this._radius.x=e}get ry(){return this._radius.y}set ry(e){this._radius.y=e}get dx(){return this._diff.x}set dx(e){this._diff.x=e}get dy(){return this._diff.y}set dy(e){this._diff.y=e}isClockwise(){return this.clockwise}isClosed(){return Math.abs(this.endAngle-this.startAngle)>=Math.PI*2-1e-9||super.isClosed()}reverse(){let{startAngle:e,endAngle:t}=this;return this.startAngle=t,this.endAngle=e,this.clockwise=!this.clockwise,this.invalidate(),this}_getDeltaAngle(){let e=Math.PI*2,t=this.endAngle-this.startAngle,n=Math.abs(t)<2**-52;return t=(t%e+e)%e,n?t=0:this.clockwise||(t=t===0?-e:t-e),t}getPoint(e,t=new U){let n=this._getDeltaAngle(),r=this.startAngle+e*n,i=this.cx+this.rx*Math.cos(r),a=this.cy+this.ry*Math.sin(r);if(this.rotate!==0){let e=Math.cos(this.rotate),t=Math.sin(this.rotate),n=i-this.cx,r=a-this.cy;i=n*e-r*t+this.cx,a=n*t+r*e+this.cy}return t.set(i,a)}_pointAtAngle(e,t){let n=this.cx+this.rx*Math.cos(e),r=this.cy+this.ry*Math.sin(e);if(this.rotate!==0){let e=Math.cos(this.rotate),t=Math.sin(this.rotate),i=n-this.cx,a=r-this.cy;n=i*e-a*t+this.cx,r=i*t+a*e+this.cy}return t.set(n,r)}getMinMax(e=U.MAX,t=U.MIN){let{startAngle:n,rotate:r}=this,i=this._getDeltaAngle(),a=Math.cos(r),o=Math.sin(r),s=pi,c=e.x,l=e.y,u=t.x,d=t.y,f=e=>{this._pointAtAngle(e,s),s.x<c&&(c=s.x),s.y<l&&(l=s.y),s.x>u&&(u=s.x),s.y>d&&(d=s.y)};f(n),f(n+i);let p=Math.atan2(-this.ry*o,this.rx*a),m=Math.atan2(this.ry*a,this.rx*o),h=[p,p+Math.PI,m,m+Math.PI];for(let e=0;e<4;e++)hi(h[e],n,i)&&f(h[e]);return e.set(c,l),t.set(u,d),{min:e.finite(),max:t.finite()}}toCommands(){let{cx:e,cy:t,rx:n,ry:r,startAngle:i,endAngle:a,clockwise:o,rotate:s}=this,c=e+n*Math.cos(i)*Math.cos(s)-r*Math.sin(i)*Math.sin(s),l=t+n*Math.cos(i)*Math.sin(s)+r*Math.sin(i)*Math.cos(s),u=Math.abs(i-a),d=+(u>Math.PI),f=+!!o,p=s*180/Math.PI;if(u>=2*Math.PI){let a=i+Math.PI,o=e+n*Math.cos(a)*Math.cos(s)-r*Math.sin(a)*Math.sin(s),u=t+n*Math.cos(a)*Math.sin(s)+r*Math.sin(a)*Math.cos(s);return[{type:`M`,x:c,y:l},{type:`A`,rx:n,ry:r,angle:p,largeArcFlag:0,sweepFlag:f,x:o,y:u},{type:`A`,rx:n,ry:r,angle:p,largeArcFlag:0,sweepFlag:f,x:c,y:l}]}else{let i=e+n*Math.cos(a)*Math.cos(s)-r*Math.sin(a)*Math.sin(s),o=t+n*Math.cos(a)*Math.sin(s)+r*Math.sin(a)*Math.cos(s);return[{type:`M`,x:c,y:l},{type:`A`,rx:n,ry:r,angle:p,largeArcFlag:d,sweepFlag:f,x:i,y:o}]}}drawTo(e){let{cx:t,cy:n,rx:r,ry:i,rotate:a,startAngle:o,endAngle:s,clockwise:c}=this;return e.ellipse(t,n,r,i,a,o,s,!c),this}applyTransform(e){return pi.set(this.cx,this.cy),e.apply(pi,pi),this.cx=pi.x,this.cy=pi.y,yi(e)?gi(this,e):_i(this,e),this.invalidate(),this}getControlPointRefs(){return[this._center]}_getAdaptiveVerticesByArc(e=[]){let{cx:t,cy:n,rx:r,ry:i,dx:a,dy:o,startAngle:s,endAngle:c,clockwise:l,rotate:u}=this,d=!l,f=Math.abs(s-c);(!d&&s>c||d&&c>s)&&(f=2*Math.PI-f);let p=Math.max(12,Math.floor(12*r**(1/3)*(f/Math.PI))),m=f/p,h=s;m*=d?-1:1;let g=Math.cos(d?u:-u),_=Math.sin(d?u:-u);for(let s=0;s<p+1;s++){let s=a+Math.cos(h)*r,c=o+Math.sin(h)*i,l=s*g-c*_,u=s*_+c*g;e.push(t+l,n+u),h+=m}return e}_getAdaptiveVerticesByCircle(e=[]){let{cx:t,cy:n,rx:r,ry:i,dx:a,dy:o,rotate:s,clockwise:c}=this;if(!(r>=0&&i>=0&&a>=0&&o>=0))return e;let l=Math.ceil(2.3*Math.sqrt(r+i)),u=l*8+(a?4:0)+(o?4:0),d=[];if(u===0)return e;{let e=d.length;if(l===0)d[e]=d[e+6]=t+a,d[e+1]=d[e+3]=n+o,d[e+2]=d[e+4]=t-a,d[e+5]=d[e+7]=n-o;else{let s=e,c=e+l*4+(a?2:0)+2,f=c,p=u,m=a+r,h=o,g=t+m,_=t-m,v=n+h;if(d[s++]=g,d[s++]=v,d[--c]=v,d[--c]=_,o){let e=n-h;d[f++]=_,d[f++]=e,d[--p]=e,d[--p]=g}for(let e=1;e<l;e++){let u=Math.PI/2*(e/l),m=a+Math.cos(u)*r,h=o+Math.sin(u)*i,g=t+m,_=t-m,v=n+h,y=n-h;d[s++]=g,d[s++]=v,d[--c]=v,d[--c]=_,d[f++]=_,d[f++]=y,d[--p]=y,d[--p]=g}m=a,h=o+i,g=t+m,_=t-m,v=n+h;let y=n-h;d[s++]=g,d[s++]=v,d[--p]=y,d[--p]=g,a&&(d[s++]=_,d[s++]=v,d[--p]=y,d[--p]=_)}}let f=Math.cos(c?-s:s),p=Math.sin(c?-s:s);for(let r=0;r<d.length;r+=2){let i=d[r],a=d[r+1],o=i-t,s=a-n,c=o*f-s*p,l=o*p+s*f;e.push(t+c,n+l)}return e}getAdaptiveVertices(e=[]){let t=Math.PI*2;if(this.startAngle===0&&this.endAngle===t)return this._getAdaptiveVerticesByCircle(e);if(Math.abs(this.endAngle-this.startAngle)>=t-1e-9){let t=this._getAdaptiveVerticesByCircle([]),n=t.length/2;if(this.endAngle>this.startAngle)for(let n=0;n<t.length;n++)e.push(t[n]);else{e.push(t[0],t[1]);for(let r=n-1;r>=1;r--)e.push(t[r*2],t[r*2+1])}return e}return this._getAdaptiveVerticesByArc(e)}copyFrom(e){return super.copyFrom(e),this.cx=e.cx,this.cy=e.cy,this.rx=e.rx,this.ry=e.ry,this.dx=e.dx,this.dy=e.dy,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.clockwise=e.clockwise,this.rotate=e.rotate,this}};function hi(e,t,n){let r=Math.PI*2,i=1e-9;if(Math.abs(n)>=r-i)return!0;let a=(e-t)%r;return n>=0?(a<-1e-9&&(a+=r),a>=-1e-9&&a<=n+i):(a>i&&(a-=r),a<=i&&a>=n-i)}function gi(e,t){let n=e.rx,r=e.ry,i=Math.cos(e.rotate),a=Math.sin(e.rotate),o=new U(n*i,n*a),s=new U(-r*a,r*i),c=t.a*o.x+t.c*o.y,l=t.b*o.x+t.d*o.y,u=t.a*s.x+t.c*s.y,d=t.b*s.x+t.d*s.y,f=ui.set(c,l,u,d,0,0),{a:p,b:m,c:h,d:g}=di.copyFrom(f).affineInvert(),_=bi(p*p+m*m,h*p+g*m,h*h+g*g),v=Math.sqrt(_.rt1),y=Math.sqrt(_.rt2);if(e.rx=1/v,e.ry=1/y,e.rotate=Math.atan2(_.sn,_.cs),!((e.endAngle-e.startAngle)%(2*Math.PI)<2**-52)){let n=di.set(v,0,0,y,0,0),r=fi.set(_.cs,_.sn,-_.sn,_.cs,0,0),i=n.append(r).append(f),a=e=>{let{x:t,y:n}=i.apply({x:Math.cos(e),y:Math.sin(e)});return Math.atan2(n,t)};e.startAngle=a(e.startAngle),e.endAngle=a(e.endAngle),vi(t)&&(e.clockwise=!e.clockwise)}}function _i(e,t){let{scale:n}=t.decompose();e.rx*=n.x,e.ry*=n.y;let r=n.x>2**-52?Math.atan2(t.b,t.a):Math.atan2(-t.c,t.d);e.rotate+=r,vi(t)&&(e.startAngle*=-1,e.endAngle*=-1,e.clockwise=!e.clockwise)}function vi(e){return e.a*e.d-e.c*e.b<0}function yi(e){let t=e.a*e.c+e.b*e.d;if(t===0)return!1;let{scale:n}=e.decompose();return Math.abs(t/(n.x*n.y))>2**-52}function bi(e,t,n){let r,i,a,o,s,c=e+n,l=e-n,u=Math.sqrt(l*l+4*t*t);return c>0?(r=.5*(c+u),s=1/r,i=e*s*n-t*s*t):c<0?(i=.5*(c-u),s=1/i,r=e*s*n-t*s*t):(r=.5*u,i=-.5*u),a=l>0?l+u:l-u,Math.abs(a)>2*Math.abs(t)?(s=-2*t/a,o=1/Math.sqrt(1+s*s),a=s*o):Math.abs(t)===0?(a=1,o=0):(s=-.5*a/t,a=1/Math.sqrt(1+s*s),o=s*a),l>0&&(s=a,a=-o,o=s),{rt1:r,rt2:i,cs:a,sn:o}}var xi=class extends mi{constructor(e=0,t=0,n=1,r=0,i=Math.PI*2,a=!1){super(new U(e,t),new U(n,n),new U,0,r,i,a)}drawTo(e){let{cx:t,cy:n,rx:r,startAngle:i,endAngle:a,clockwise:o}=this;return e.arc(t,n,r,i,a,!o),this}},Si=class e extends li{constructor(e=new U,t=new U){super(),this.p1=e,this.p2=t}static from(t,n,r,i){return new e(new U(t,n),new U(r,i))}getPoint(e,t=new U){return e===1?t.copyFrom(this.p2):t.copyFrom(this.p2).sub(this.p1).scale(e).add(this.p1),t}getPointAt(e,t=new U){return this.getPoint(e,t)}getTangent(e,t=new U){return t.subVectors(this.p2,this.p1).normalize()}getTangentAt(e,t=new U){return this.getTangent(e,t)}getControlPointRefs(){return[this.p1,this.p2]}reverse(){let{p1:e,p2:t}=this;return this.p1=t,this.p2=e,this.invalidate(),this}getAdaptiveVertices(e=[]){return e.push(this.p1.x,this.p1.y,this.p2.x,this.p2.y),e}getMinMax(e=U.MAX,t=U.MIN){let{p1:n,p2:r}=this;return e.x=Math.min(e.x,n.x,r.x),e.y=Math.min(e.y,n.y,r.y),t.x=Math.max(t.x,n.x,r.x),t.y=Math.max(t.y,n.y,r.y),{min:e.finite(),max:t.finite()}}toCommands(){let{p1:e,p2:t}=this;return[{type:`M`,x:e.x,y:e.y},{type:`L`,x:t.x,y:t.y}]}getFillVertices(e={}){let t=Math.min(this.p1.x,this.p2.x),n=Math.max(this.p1.x,this.p2.x),r=Math.min(this.p1.y,this.p2.y),i=Math.max(this.p1.y,this.p2.y),a=t,o=r,s=n-t||e.style?.strokeWidth||0,c=i-r||e.style?.strokeWidth||0;return[a,o,a+s,o,a+s,o+c,a,o+c]}drawTo(e){let{p1:t,p2:n}=this;return e.lineTo(t.x,t.y),e.lineTo(n.x,n.y),this}copyFrom(e){return super.copyFrom(e),this.p1.copyFrom(e.p1),this.p2.copyFrom(e.p2),this}},Ci=class e extends li{constructor(e=[]){super(),this.curves=e}_adaptiveCacheLen=-1;_invalidateSelf(){super._invalidateSelf(),this._adaptiveCacheLen=-1,this.curves.forEach(e=>e.invalidate())}_getCachedAdaptiveVertices(){return(!this._adaptiveCache||this._adaptiveCacheLen!==this.curves.length)&&(this.curves.forEach(e=>{e._owner=this}),this._adaptiveCache=this.getAdaptiveVertices(),this._adaptiveCacheLen=this.curves.length),this._adaptiveCache}getFlatCurves(){return this.curves.flatMap(t=>t instanceof e?t.getFlatCurves():t)}addCurve(e){return this.curves.push(e),this}getPoint(e,t=new U){let n=e*this.getLength(),r=this.getLengths(),i=r.length;if(i===0)return t;let a=0,o=i-1;for(;a<o;){let e=a+o>>>1;r[e]<n?a=e+1:o=e}let s=r[a]-n,c=this.curves[a],l=c.getLength();return c.getPointAt(l===0?0:1-s/l,t)}getLengths(){return this._lengths.length!==this.curves.length&&this.updateLengths(),this._lengths}updateLengths(){let e=[];for(let t=0,n=0,r=this.curves.length;t<r;t++)this.curves[t]._owner=this,n+=this.curves[t].getLength(),e.push(n);this._lengths=e}getControlPointRefs(){return this.curves.flatMap(e=>e.getControlPointRefs())}_removeNextPointIfEqualPrevPoint(e,t){let n=[e[t-1],e[t]],r=[e[t+1],e[t+2]];return n[0]===r[0]&&n[1]===r[1]&&e.splice(t+1,2),e}getSpacedVertices(e=5,t=[]){let n;return this.curves.forEach(r=>{r.getSpacedVertices(e,t),n&&this._removeNextPointIfEqualPrevPoint(t,n),n=t.length-1}),t}getAdaptiveVertices(e=[]){let t;return this.curves.forEach(n=>{n.getAdaptiveVertices(e),t&&this._removeNextPointIfEqualPrevPoint(e,t),t=e.length-1}),e}isClosed(){return this.curves.length===1?this.curves[0].isClosed():super.isClosed()}strokeTriangulate(e){return this.curves.length===1?this.curves[0].strokeTriangulate(e):super.strokeTriangulate(e)}reverse(){return this.curves.reverse(),this.curves.forEach(e=>e.reverse()),this.invalidate(),this}getFillVertices(e){if(this.curves.length===1)return this.curves[0].getFillVertices(e);{let t=[],n;return this.curves.forEach(r=>{let i;i=r instanceof Si?r.getAdaptiveVertices():r.getFillVertices(e),t.push(...i),n&&this._removeNextPointIfEqualPrevPoint(t,n),n=t.length-1}),t}}applyTransform(e){return this._invalidating=!0,this.curves.forEach(t=>t.applyTransform(e)),this._invalidating=!1,this.invalidate(),this}getMinMax(e=U.MAX,t=U.MIN){return this.curves.forEach(n=>n.getMinMax(e,t)),{min:e.finite(),max:t.finite()}}getBoundingBox(){let{min:e,max:t}=this.getMinMax();return new W(e.x,e.y,t.x-e.x,t.y-e.y)}toCommands(){return this.curves.flatMap(e=>e.toCommands())}drawTo(e){let t=this.curves[0]?.getPoint(0);return t&&e.moveTo(t.x,t.y),this.curves.forEach(t=>t.drawTo(e)),this}copyFrom(e){return super.copyFrom(e),this.curves=e.curves.map(e=>e.clone()),this}},wi=class e extends li{constructor(e=new U,t=new U,n=new U,r=new U){super(),this.p1=e,this.cp1=t,this.cp2=n,this.p2=r}static from(t,n,r,i,a,o,s,c){return new e(new U(t,n),new U(r,i),new U(a,o),new U(s,c))}getPoint(e,t=new U){let{p1:n,cp1:r,cp2:i,p2:a}=this;return t.set(Vn(e,n.x,r.x,i.x,a.x),Vn(e,n.y,r.y,i.y,a.y))}getAdaptiveVertices(e=[]){return ar(this.p1.x,this.p1.y,this.cp1.x,this.cp1.y,this.cp2.x,this.cp2.y,this.p2.x,this.p2.y,.5,e)}getControlPointRefs(){return[this.p1,this.cp1,this.cp2,this.p2]}reverse(){let{p1:e,cp1:t,cp2:n,p2:r}=this;return this.p1=r,this.cp1=n,this.cp2=t,this.p2=e,this.invalidate(),this}_solveQuadratic(e,t,n){if(Math.abs(e)<1e-12){if(Math.abs(t)<1e-12)return[];let e=-n/t;return e>=0&&e<=1?[e]:[]}let r=t*t-4*e*n;if(r<0)return[];let i=Math.sqrt(r);return[(-t+i)/(2*e),(-t-i)/(2*e)].filter(e=>e>=0&&e<=1)}getMinMax(e=U.MAX,t=U.MIN){let{p1:n,cp1:r,cp2:i,p2:a}=this,o=this._solveQuadratic(3*(-n.x+3*r.x-3*i.x+a.x),6*(n.x-2*r.x+i.x),3*(r.x-n.x)),s=this._solveQuadratic(3*(-n.y+3*r.y-3*i.y+a.y),6*(n.y-2*r.y+i.y),3*(r.y-n.y)),c=[0,1,...o,...s];for(let n of c){let r=this.getPoint(n);e.x=Math.min(e.x,r.x),e.y=Math.min(e.y,r.y),t.x=Math.max(t.x,r.x),t.y=Math.max(t.y,r.y)}return{min:e.finite(),max:t.finite()}}toCommands(){let{p1:e,cp1:t,cp2:n,p2:r}=this;return[{type:`M`,x:e.x,y:e.y},{type:`C`,x1:t.x,y1:t.y,x2:n.x,y2:n.y,x:r.x,y:r.y}]}drawTo(e){let{p1:t,cp1:n,cp2:r,p2:i}=this;return e.lineTo(t.x,t.y),e.bezierCurveTo(n.x,n.y,r.x,r.y,i.x,i.y),this}copyFrom(e){return super.copyFrom(e),this.p1.copyFrom(e.p1),this.cp1.copyFrom(e.cp1),this.cp2.copyFrom(e.cp2),this.p2.copyFrom(e.p2),this}},Ti=class extends mi{constructor(e=0,t=0,n=1,r=1,i=0,a=0,o=Math.PI*2,s=!1){super(new U(e,t),new U(n,r),new U,i,a,o,s)}drawTo(e){return e.ellipse(this.cx,this.cy,this.rx,this.ry,this.rotate,this.startAngle,this.endAngle,!this.clockwise),this}},Ei=class extends Ci{},Di=class e extends li{constructor(e=new U,t=new U,n=new U){super(),this.p1=e,this.cp=t,this.p2=n}static from(t,n,r,i,a,o){return new e(new U(t,n),new U(r,i),new U(a,o))}getPoint(e,t=new U){let{p1:n,cp:r,p2:i}=this;return t.set(xr(e,n.x,r.x,i.x),xr(e,n.y,r.y,i.y)),t}getControlPointRefs(){return[this.p1,this.cp,this.p2]}reverse(){let{p1:e,p2:t}=this;return this.p1=t,this.p2=e,this.invalidate(),this}getAdaptiveVertices(e=[]){return ur(this.p1.x,this.p1.y,this.cp.x,this.cp.y,this.p2.x,this.p2.y,.5,e)}getMinMax(e=U.MAX,t=U.MIN){let{p1:n,cp:r,p2:i}=this,a=(e,t,n)=>{let r=e-2*t+n;if(Math.abs(r)<1e-12)return null;let i=(e-t)/r;return i>0&&i<1?i:null},o=a(n.x,r.x,i.x),s=a(n.y,r.y,i.y),c=[n.x,i.x],l=[n.y,i.y];return o!==null&&c.push(xr(o,n.x,r.x,i.x)),s!==null&&l.push(xr(s,n.y,r.y,i.y)),e.x=Math.min(e.x,...c),e.y=Math.min(e.y,...l),t.x=Math.max(t.x,...c),t.y=Math.max(t.y,...l),{min:e.finite(),max:t.finite()}}toCommands(){let{p1:e,cp:t,p2:n}=this;return[{type:`M`,x:e.x,y:e.y},{type:`Q`,x1:t.x,y1:t.y,x:n.x,y:n.y}]}drawTo(e){let{p1:t,cp:n,p2:r}=this;return e.lineTo(t.x,t.y),e.quadraticCurveTo(n.x,n.y,r.x,r.y),this}copyFrom(e){return super.copyFrom(e),this.p1.copyFrom(e.p1),this.cp.copyFrom(e.cp),this.p2.copyFrom(e.p2),this}},Oi=class extends Ei{constructor(e=0,t=0,n=0,r=0){super(),this.x=e,this.y=t,this.width=n,this.height=r,this.update()}update(){let{x:e,y:t,width:n,height:r}=this,i=[new U(e,t),new U(e+n,t),new U(e+n,t+r),new U(e,t+r)];return this.curves=[new Si(i[0],i[1]),new Si(i[1],i[2]),new Si(i[2],i[3]),new Si(i[3],i[0])],this}drawTo(e){return e.rect(this.x,this.y,this.width,this.height),this}getFillVertices(e={}){let{x:t,y:n,width:r,height:i}=this;return[t,n,t+r,n,t+r,n+i,t,n+i]}copyFrom(e){return super.copyFrom(e),this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.update(),this}},ki=class extends Ci{constructor(e=0,t=0,n=1,r=1,i=1){super(),this.x=e,this.y=t,this.width=n,this.height=r,this.radius=i,this.update()}update(){let{x:e,y:t,width:n,height:r}=this,i=Math.max(0,Math.min(this.radius,Math.abs(n)/2,Math.abs(r)/2)),a=e,o=e+i,s=e+n-i,c=e+n,l=t,u=t+i,d=t+r-i,f=t+r;if(i<=0)this.curves=[Si.from(a,l,c,l),Si.from(c,l,c,f),Si.from(c,f,a,f),Si.from(a,f,a,l)];else{let e=Math.PI/2;this.curves=[Si.from(o,l,s,l),new xi(s,u,i,-e,0,!0),Si.from(c,u,c,d),new xi(s,d,i,0,e,!0),Si.from(s,f,o,f),new xi(o,d,i,e,Math.PI,!0),Si.from(a,d,a,u),new xi(o,u,i,Math.PI,Math.PI*1.5,!0)]}return this.invalidate(),this}drawTo(e){return e.roundRect(this.x,this.y,this.width,this.height,this.radius),this}copyFrom(e){return this.arcLengthDivision=e.arcLengthDivision,this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.radius=e.radius,this.update(),this}},Ai=class extends li{constructor(e=[]){super(),this.points=e}getPoint(e,t=new U){let{points:n}=this,r=(n.length-1)*e,i=Math.floor(r),a=r-i,o=n[i===0?i:i-1],s=n[i],c=n[i>n.length-2?n.length-1:i+1],l=n[i>n.length-3?n.length-1:i+2];return t.set(Dn(a,o.x,s.x,c.x,l.x),Dn(a,o.y,s.y,c.y,l.y)),t}getControlPointRefs(){return this.points}reverse(){return this.points.reverse(),this.invalidate(),this}copyFrom(e){super.copyFrom(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++)this.points.push(e.points[t].clone());return this}},ji=class extends Ci{startPoint;currentPoint;autoClose=!1;constructor(e){super(),e&&this.addPoints(e)}addPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++){let{x:n,y:r}=e[t];this.lineTo(n,r)}return this}addCommands(e){return Ir(e,this),this}addData(e){return this.addCommands(zr(e)),this}isClosed(){return this.autoClose||super.isClosed()}reverse(){return super.reverse(),this.curves.length&&(this.startPoint=this.getPoint(0),this.currentPoint=this.getPoint(1)),this}_closeVertices(e){return this.autoClose&&e.length>=4&&e[0]!==e[e.length-2]&&e[1]!==e[e.length-1]&&e.push(e[0],e[1]),e}getUnevenVertices(e=40,t=[]){return this._closeVertices(super.getUnevenVertices(e,t))}getSpacedVertices(e=40,t=[]){return this._closeVertices(super.getSpacedVertices(e,t))}getAdaptiveVertices(e=[]){return this._closeVertices(super.getAdaptiveVertices(e))}getFillVertices(e){return this._closeVertices(super.getFillVertices(e))}isPointInStroke(e,t={}){let{strokeWidth:n=1,tolerance:r=0}=t,i=this._getCachedAdaptiveVertices(),a=i.length;return Jn(e,i,t.closed??(this.autoClose||a>=6&&i[0]===i[a-2]&&i[1]===i[a-1]))<=n/2+r}_setCurrentPoint(e){return this.currentPoint=new U(e.x,e.y),this.startPoint||=this.currentPoint.clone(),this}_connetLineTo(e){if(this.curves.length>0){let t=e.getPoint(0);(!this.currentPoint||!t.equals(this.currentPoint))&&this.lineTo(t.x,t.y)}return this}closePath(){let e=this.startPoint;if(e){let t=this.currentPoint;t&&!e.equals(t)&&(this.curves.push(new Si(t.clone(),e.clone())),t.copyFrom(e)),this.startPoint=void 0}return this}moveTo(e,t){return this.currentPoint=new U(e,t),this.startPoint=this.currentPoint.clone(),this}lineTo(e,t){let n=this.currentPoint;return n?.equals({x:e,y:t})||this.curves.push(Si.from(n?.x??0,n?.y??0,e,t)),this._setCurrentPoint({x:e,y:t}),this}bezierCurveTo(e,t,n,r,i,a){let o=this.currentPoint;return o?.equals({x:i,y:a})||this.curves.push(wi.from(o?.x??0,o?.y??0,e,t,n,r,i,a)),this._setCurrentPoint({x:i,y:a}),this}quadraticCurveTo(e,t,n,r){let i=this.currentPoint;return i?.equals({x:n,y:r})||this.curves.push(Di.from(i?.x??0,i?.y??0,e,t,n,r)),this._setCurrentPoint({x:n,y:r}),this}arc(e,t,n,r,i,a){let o=new xi(e,t,n,r,i,!a);return this._connetLineTo(o),this.curves.push(o),this._setCurrentPoint(o.getPoint(1)),this}relativeArc(e,t,n,r,i,a){return e+=this.currentPoint?.x??0,t+=this.currentPoint?.y??0,this.arc(e,t,n,r,i,a),this}arcTo(e,t,n,r,i){return console.warn(`Method arcTo not supported yet`),this}ellipse(e,t,n,r,i,a,o,s=!0){let c=new Ti(e,t,n,r,i,a,o,!s);return this._connetLineTo(c),this.curves.push(c),this._setCurrentPoint(c.getPoint(1)),this}relativeEllipse(e,t,n,r,i,a,o,s){return e+=this.currentPoint?.x??0,t+=this.currentPoint?.y??0,this.ellipse(e,t,n,r,i,a,o,s),this}rect(e,t,n,r){let i=new Oi(e,t,n,r);return this._connetLineTo(i),this.curves.push(i),this._setCurrentPoint({x:e,y:t}),this}roundRect(e,t,n,r,i){let a=new ki(e,t,n,r,i);return this._connetLineTo(a),this.curves.push(a),this._setCurrentPoint({x:e,y:t}),this}splineThru(e){let t=this.currentPoint??new U;return this.curves.push(new Ai([t].concat(e))),this._setCurrentPoint(e[e.length-1]),this}drawTo(e){let t=this.curves[0]?.getPoint(0);return t&&e.moveTo(t.x,t.y),this.curves.forEach(t=>t.drawTo(e)),this.autoClose&&e.closePath(),this}copyFrom(e){return super.copyFrom(e),this.autoClose=e.autoClose,this.currentPoint=e.currentPoint?.clone(),this}},Mi=class e extends Ci{_meta;_ringsCache;_ringsCacheLen=-1;currentCurve=new ji;style;get startPoint(){return this.currentCurve.startPoint}get currentPoint(){return this.currentCurve.currentPoint}get strokeWidth(){return this.style.strokeWidth??((this.style.stroke??`none`)===`none`?0:1)}constructor(t,n={}){super(),this.curves.push(this.currentCurve),this.style=n,t&&(t instanceof e?this.addPath(t):Array.isArray(t)?this.addCommands(t):this.addData(t))}getMeta(){return this._meta}setMeta(e){return this._meta=e,this}addPath(t){let n=t instanceof e?t.curves:[t];if(n.filter(e=>e.curves.length).length===0)return this;if(!this.currentCurve.curves.length){let e=this.curves.findIndex(e=>e===this.currentCurve);e>-1&&this.curves.splice(e,1)}return this.curves.push(...n.map(e=>e.clone())),this.currentCurve=this.curves[this.curves.length-1],this}closePath(){let e=this.startPoint;return e&&this.currentCurve.curves.length&&(this.currentCurve.closePath(),this.currentCurve=new ji().moveTo(e.x,e.y),this.curves.push(this.currentCurve)),this}moveTo(e,t){return this.currentCurve.curves.length&&(this.currentCurve=new ji,this.curves.push(this.currentCurve)),this.currentCurve.moveTo(e,t),this}lineTo(e,t){return this.currentCurve.lineTo(e,t),this}bezierCurveTo(e,t,n,r,i,a){return this.currentCurve.bezierCurveTo(e,t,n,r,i,a),this}quadraticCurveTo(e,t,n,r){return this.currentCurve.quadraticCurveTo(e,t,n,r),this}arc(e,t,n,r,i,a){return this.currentCurve.arc(e,t,n,r,i,a),this}arcTo(e,t,n,r,i){return this.currentCurve.arcTo(e,t,n,r,i),this}ellipse(e,t,n,r,i,a,o,s){return this.currentCurve.ellipse(e,t,n,r,i,a,o,s),this}rect(e,t,n,r){return this.currentCurve.rect(e,t,n,r),this}roundRect(e,t,n,r,i){return this.currentCurve.roundRect(e,t,n,r,i),this}reset(){return this.currentCurve=new ji,this.curves=[this.currentCurve],this.style={},this}addCommands(e){return Ir(e,this),this}addData(e){return this.addCommands(zr(e)),this}splineThru(e){return this.currentCurve.splineThru(e),this}scale(e,t=e,n={x:0,y:0}){return this.getControlPointRefs().forEach(r=>{r.scale(e,t,n)}),this.invalidate(),this}skew(e,t=0,n={x:0,y:0}){return this.getControlPointRefs().forEach(r=>{r.skew(e,t,n)}),this.invalidate(),this}rotate(e,t={x:0,y:0}){return this.getControlPointRefs().forEach(n=>{n.rotate(e,t)}),this.invalidate(),this}bold(e){if(e===0)return this;let t=this.getFlatCurves(),n=[],r=[],i=[];t.forEach((e,t)=>{let a=e.getControlPointRefs(),o=e.isClockwise();i[t]=a,r[t]=o;let s=a[0],c=a[a.length-1]??s;n.push({start:o?c:s,end:o?s:c,index:t})});let a=[];return n.forEach((e,t)=>{a[t]=[],n.forEach((n,r)=>{n.start&&e.end&&r!==t&&n.start?.equals(e.end)&&a[t].push(n.index)})}),t.forEach((t,n)=>{let a=r[n];i[n].forEach(n=>{n.add(t.getNormal(t.getTForPoint(n)).scale(a?e:-e))})}),a.forEach((e,t)=>{let n=i[t];e.forEach(e=>{let t=i[e],r=An(n[n.length-1],n[n.length-2]??n[n.length-1],t[0],t[1]??t[0]);r&&(n[n.length-1].copyFrom(r),t[0].copyFrom(r))})}),this.invalidate(),this}_invalidateSelf(){super._invalidateSelf(),this._ringsCache=void 0,this._ringsCacheLen=-1}_getRings(){return(!this._ringsCache||this._ringsCacheLen!==this.curves.length)&&(this._ringsCache=this.curves.map(e=>(e._owner=this,e.getAdaptiveVertices())),this._ringsCacheLen=this.curves.length),this._ringsCache}isPointInFill(e,t={}){let n=t.fillRule??this.style.fillRule??`nonzero`;return qn(e,this._getRings(),n)}static fromRings(t,n={}){let r=new e(void 0,n);for(let e of t){if(e.length<6)continue;let t=e.length;e[0]===e[t-2]&&e[1]===e[t-1]&&(t-=2),r.moveTo(e[0],e[1]);for(let n=2;n<t;n+=2)r.lineTo(e[n],e[n+1]);r.closePath()}return r}booleanOp(t,n,r){let i=En(t,this._getRings(),n._getRings());return e.fromRings(i,{...this.style,...r})}union(e,t){return this.booleanOp(`union`,e,t)}intersection(e,t){return this.booleanOp(`intersection`,e,t)}difference(e,t){return this.booleanOp(`difference`,e,t)}xor(e,t){return this.booleanOp(`xor`,e,t)}isPointInStroke(e,t={}){let n=t.strokeWidth??this.strokeWidth,{tolerance:r=0,closed:i}=t;return this.curves.some(t=>t.isPointInStroke(e,{strokeWidth:n,tolerance:r,closed:i}))}getMinMax(e=U.MAX,t=U.MIN,n=!0){if(this.curves.forEach(n=>{n.getMinMax(e,t)}),n){let n=this.strokeWidth;if(n>1&&Number.isFinite(e.x)){let r=n/2;e.set(e.x-r,e.y-r),t.set(t.x+r,t.y+r)}}return{min:e.finite(),max:t.finite()}}strokeTriangulate(e){let t=e?.indices??[],n=e?.vertices??[];return this.curves.forEach(r=>{r.strokeTriangulate({...e,indices:t,vertices:n,style:{...this.style}})}),{indices:t,vertices:n}}fillTriangulate(e){let t={...e,style:{...this.style,...e?.style}},n=t.indices??[],r=t.vertices??[];if((e?.fillRule??t.style.fillRule??`nonzero`)===`nonzero`){let i=this.curves.map(e=>e.getFillVertices(t)),a=_r(i),o=a.length;for(let t=0;t<o;t++){let s=a[t],c=i[t];if(s.winding||!c.length)continue;let l=c.slice(),u=[];for(let e=0;e<o;e++){let n=a[e];n.parentIndex===t&&(u.push(l.length/2),l.push(...i[n.index]))}tr(l,{...e,indices:n,vertices:r,holes:u,style:{...this.style}})}}else{let i=this.curves.map(e=>e.getFillVertices(t)),a=Qn(i),o=a.length;for(let t=0;t<o;t++){let s=i[t];if((a[t].depth&1)==1||!s.length)continue;let c=s.slice(),l=[];for(let e=0;e<o;e++)a[e].parentIndex===t&&(a[e].depth&1)==1&&(l.push(c.length/2),c.push(...i[e]));tr(c,{...e,indices:n,vertices:r,holes:l,style:{...this.style}})}}return{indices:n,vertices:r}}getBoundingBox(e=!0){let{min:t,max:n}=this.getMinMax(void 0,void 0,e);return new W(t.x,t.y,n.x-t.x,n.y-t.y)}drawTo(e,t={}){t={...this.style,...t};let{fill:n=`#000`,stroke:r=`none`,fillRule:i=`nonzero`}=t;return e.beginPath(),e.save(),Sn(e,t),this.curves.forEach(t=>{t.drawTo(e)}),n!==`none`&&e.fill(i),r!==`none`&&e.stroke(),e.restore(),this}drawControlPointsTo(e,t={}){t={...this.style,...t};let{fill:n=`#000`,stroke:r=`none`}=t;return e.beginPath(),e.save(),Sn(e,t),this.getControlPointRefs().forEach(t=>{bn(e,t.x,t.y,{radius:4})}),n!==`none`&&e.fill(),r!==`none`&&e.stroke(),e.restore(),this}toCommands(){return this.curves.flatMap(e=>e.toCommands())}toData(){return this.curves.filter(e=>e.curves.length).map(e=>e.toData()).join(` `)}toSvgPathString(){let e={...this.style,fill:this.style.fill??`#000`,stroke:this.style.stroke??`none`},t={};for(let n in e)e[n]!==void 0&&(t[kn(n)]=e[n]);Object.assign(t,{"stroke-width":`${this.strokeWidth}px`});let n=``;for(let e in t)t[e]!==void 0&&(n+=`${e}:${t[e]};`);return`<path d="${this.toData()}" style="${n}"></path>`}copyFrom(e){return super.copyFrom(e),this.currentCurve=e.currentCurve.clone(),this.style={...e.style},this}},Ni=class{constructor(e=[],t){this.paths=e,this.viewBox=t}isPointInFill(e,t={}){return this.paths.some(n=>n.isPointInFill(e,t))}contains(e,t,n={}){return this.isPointInFill({x:e,y:t},n)}hitTest(e,t={}){let{stroke:n=!0,forceStroke:r=!1,tolerance:i,fillRule:a}=t;for(let t=this.paths.length-1;t>=0;t--){let o=this.paths[t];if((o.style.fill??`#000`)!==`none`&&o.isPointInFill(e,{fillRule:a})||n&&(r||(o.style.stroke??`none`)!==`none`)&&o.isPointInStroke(e,{tolerance:i}))return o}}getBoundingBox(e=!0){if(!this.paths.length)return;let t=U.MAX,n=U.MIN;return this.paths.forEach(r=>r.getMinMax(t,n,e)),new W(t.x,t.y,n.x-t.x,n.y-t.y)}toTriangulatedSvgString(e=this.paths.map(e=>e.fillTriangulate()),t=0){let n=``,r=``,i={x:-t,y:-t},a={x:t,y:t};(Array.isArray(e)?e:[e]).forEach(({vertices:e,indices:o,points:s=[]})=>{let c=n=>{let r=e[n*2],o=e[n*2+1];return i.x=Math.min(i.x,r+t),a.x=Math.max(a.x,r+t),i.y=Math.min(i.y,o+t),a.y=Math.max(a.y,o+t),[r,o]};for(let e=0,t=o.length;e<t;e+=3){let t=c(o[e]),r=c(o[e+1]),i=c(o[e+2]);n+=`<polygon
4
+ ${t}`);return n.documentElement}else return e}var Wr=`px`,Gr=90,Kr=[`mm`,`cm`,`in`,`pt`,`pc`,`px`],qr={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{px:1}};function K(e){let t=`px`;if(typeof e==`string`)for(let n=0,r=Kr.length;n<r;n++){let r=Kr[n];if(e.endsWith(r)){t=r,e=e.substring(0,e.length-r.length);break}}let n;return n=qr[t][Wr],n<0&&(n=qr[t].in*Gr),n*Number.parseFloat(e)}function Jr(e,t,n){if(!(e.hasAttribute(`transform`)||e.nodeName===`use`&&(e.hasAttribute(`x`)||e.hasAttribute(`y`))))return null;let r=Yr(e);return n.length>0&&r.prepend(n[n.length-1]),t.copyFrom(r),n.push(r),r}function Yr(e){let t=new jr;return e.nodeName===`use`&&(e.hasAttribute(`x`)||e.hasAttribute(`y`))&&t.translate(K(e.getAttribute(`x`)),K(e.getAttribute(`y`))),e.hasAttribute(`transform`)&&t.prependCssTransform(e.getAttribute(`transform`)),t}function Xr(e){return new Mi().arc(K(e.getAttribute(`cx`)||0),K(e.getAttribute(`cy`)||0),K(e.getAttribute(`r`)||0),0,Math.PI*2)}function Zr(e,t){if(!(!e.sheet||!e.sheet.cssRules||!e.sheet.cssRules.length))for(let n=0;n<e.sheet.cssRules.length;n++){let r=e.sheet.cssRules[n];if(r.type!==1)continue;let i=r.selectorText.split(/,/g).filter(Boolean).map(e=>e.trim()),a={};for(let e=r.style.length,t=0;t<e;t++){let e=r.style.item(t);a[e]=r.style.getPropertyValue(e)}for(let e=0;e<i.length;e++)t[i[e]]=Object.assign(t[i[e]]||{},{...a})}}function Qr(e){return new Mi().ellipse(K(e.getAttribute(`cx`)||0),K(e.getAttribute(`cy`)||0),K(e.getAttribute(`rx`)||0),K(e.getAttribute(`ry`)||0),0,0,Math.PI*2)}function $r(e){return new Mi().moveTo(K(e.getAttribute(`x1`)||0),K(e.getAttribute(`y1`)||0)).lineTo(K(e.getAttribute(`x2`)||0),K(e.getAttribute(`y2`)||0))}function ei(e){let t=new Mi,n=e.getAttribute(`d`);return!n||n===`none`?null:(t.addData(n),t)}var ti=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function ni(e){let t=new Mi,n=0;return e.getAttribute(`points`)?.replace(ti,(e,r,i)=>{let a=K(r),o=K(i);return n===0?t.moveTo(a,o):t.lineTo(a,o),n++,e}),t.currentCurve.autoClose=!0,t}var ri=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function ii(e){let t=new Mi,n=0;return e.getAttribute(`points`)?.replace(ri,(e,r,i)=>{let a=K(r),o=K(i);return n===0?t.moveTo(a,o):t.lineTo(a,o),n++,e}),t.currentCurve.autoClose=!1,t}function ai(e){let t=K(e.getAttribute(`x`)||0),n=K(e.getAttribute(`y`)||0),r=e.getAttribute(`rx`),i=e.getAttribute(`ry`),a=K(r??i??0),o=K(i??r??0),s=K(e.getAttribute(`width`)),c=K(e.getAttribute(`height`));a=Math.max(0,Math.min(a,s/2)),o=Math.max(0,Math.min(o,c/2));let l=.448084975506,u=new Mi;return u.moveTo(t+a,n),u.lineTo(t+s-a,n),(a!==0||o!==0)&&u.bezierCurveTo(t+s-a*l,n,t+s,n+o*l,t+s,n+o),u.lineTo(t+s,n+c-o),(a!==0||o!==0)&&u.bezierCurveTo(t+s,n+c-o*l,t+s-a*l,n+c,t+s-a,n+c),u.lineTo(t+a,n+c),(a!==0||o!==0)&&u.bezierCurveTo(t+a*l,n+c,t,n+c-o*l,t,n+c-o),u.lineTo(t,n+o),(a!==0||o!==0)&&u.bezierCurveTo(t,n+o*l,t+a*l,n,t+a,n),u}function oi(e,t,n){t=Object.assign({},t);let r={};if(e.hasAttribute(`class`)){let t=e.getAttribute(`class`).split(/\s/).filter(Boolean).map(e=>e.trim());for(let e=0;e<t.length;e++)r=Object.assign(r,n[`.${t[e]}`])}e.hasAttribute(`id`)&&(r=Object.assign(r,n[`#${e.getAttribute(`id`)}`]));for(let n=e.style.length,i=0;i<n;i++){let n=e.style.item(i),a=e.style.getPropertyValue(n);t[n]=a,r[n]=a}function i(n,i,o=a){e.hasAttribute(n)&&(t[i]=o(e.getAttribute(n))),r[n]&&(t[i]=o(r[n]))}function a(e){return e.startsWith(`url`)&&console.warn(`url access in attributes is not implemented.`),e}function o(e){return Math.max(0,Math.min(1,K(e)))}function s(e){return Math.max(0,K(e))}function c(e){return e.split(` `).filter(e=>e!==``).map(e=>K(e))}return i(`fill`,`fill`),i(`fill-opacity`,`fillOpacity`,o),i(`fill-rule`,`fillRule`),i(`opacity`,`opacity`,o),i(`stroke`,`stroke`),i(`stroke-opacity`,`strokeOpacity`,o),i(`stroke-width`,`strokeWidth`,s),i(`stroke-linecap`,`strokeLinecap`),i(`stroke-linejoin`,`strokeLinejoin`),i(`stroke-miterlimit`,`strokeMiterlimit`,s),i(`stroke-dasharray`,`strokeDasharray`,c),i(`stroke-dashoffset`,`strokeDashoffset`,K),i(`visibility`,`visibility`),t}function si(e,t,n=[],r={}){if(e.nodeType!==1)return n;let i=!1,a=null,o={...t};switch(e.nodeName){case`svg`:o=oi(e,o,r);break;case`style`:Zr(e,r);break;case`g`:o=oi(e,o,r);break;case`path`:o=oi(e,o,r),e.hasAttribute(`d`)&&(a=ei(e));break;case`rect`:o=oi(e,o,r),a=ai(e);break;case`polygon`:o=oi(e,o,r),a=ni(e);break;case`polyline`:o=oi(e,o,r),a=ii(e);break;case`circle`:o=oi(e,o,r),a=Xr(e);break;case`ellipse`:o=oi(e,o,r),a=Qr(e);break;case`line`:o=oi(e,o,r),a=$r(e);break;case`defs`:i=!0;break;case`use`:{o=oi(e,o,r);let t=(e.getAttributeNS(`http://www.w3.org/1999/xlink`,`href`)||e.getAttribute(`href`)||``).substring(1),i=e.viewportElement?.getElementById(t);i?si(i,o,n,r):console.warn(`'use node' references non-existent node id: ${t}`);break}default:console.warn(e);break}if(o.display===`none`)return n;let s=new jr,c=[],l=Jr(e,s,c);a&&(a.applyTransform(s),n.push(a),a.style={...o});let u=e.childNodes;for(let e=0,t=u.length;e<t;e++){let t=u[e];i&&t.nodeName!==`style`&&t.nodeName!==`defs`||si(t,o,n,r)}return l&&(c.pop(),c.length>0?s.copyFrom(c[c.length-1]):s.identity()),n}function ci(e){let t=Ur(e);return new Ni(si(t,{}),t.getAttribute(`viewBox`)?.trim().split(` `).map(e=>Number(e)))}var li=class{arcLengthDivision=200;_lengths=[];_adaptiveCache;_owner;_invalidating=!1;invalidate(){return this._invalidating?this:(this._invalidating=!0,this._invalidateSelf(),this._owner?.invalidate(),this._invalidating=!1,this)}_invalidateSelf(){this._lengths.length=0,this._adaptiveCache=void 0}_getCachedAdaptiveVertices(){return this._adaptiveCache??=this.getAdaptiveVertices()}getPointAt(e,t=new U){return this.getPoint(this.getUToTMapping(e),t)}isClockwise(){return!1}getControlPointRefs(){return[]}reverse(){let e=this.getControlPointRefs(),t=e.length,n=e.map(e=>e.clone());for(let r=0;r<t;r++)e[r].copyFrom(n[t-1-r]);return this.invalidate(),this}applyTransform(e){let t=typeof e==`function`;return this.getControlPointRefs().forEach(n=>{t?e(n):e.apply(n,n)}),this.invalidate(),this}getUnevenVertices(e=5,t=[]){let n=new U;for(let r=0,i=Math.max(1,e)-1;r<=i;r++)this.getPoint(r/i,n),t.push(n.x,n.y);return t}getSpacedVertices(e=5,t=[]){let n=new U;for(let r=0,i=Math.max(1,e)-1;r<=i;r++)this.getPointAt(r/i,n),t.push(n.x,n.y);return t}getAdaptiveVertices(e=[]){return this.getUnevenVertices(5,e)}_verticesToPoints(e,t=[]){for(let n=0,r=e.length;n<r;n+=2){let r=e[n],i=e[n+1];t.push(new U(r,i))}return t}getSpacedPoints(e,t=[]){let n=this.getSpacedVertices(e);return this._verticesToPoints(n,t),t}getUnevenPoints(e,t=[]){let n=this.getUnevenVertices(e);return this._verticesToPoints(n,t),t}getAdaptivePoints(e=[]){let t=this.getAdaptiveVertices();return this._verticesToPoints(t,e),e}getPoints(e,t=[]){let n;return n=e?this.getUnevenVertices(e):this.getAdaptiveVertices(),this._verticesToPoints(n,t),t}getLength(){let e=this.getLengths();return e[e.length-1]??0}getLengths(){return this._lengths.length!==this.arcLengthDivision+1&&this.updateLengths(),this._lengths}updateLengths(){let e=this.arcLengthDivision,t=[0];for(let n=0,r=this.getPoint(0),i=1;i<=e;i++){let a=this.getPoint(i/e);n+=a.distanceTo(r),t.push(n),r=a}this._lengths=t}getUToTMapping(e,t){let n=this.getLengths(),r=n.length,i=t??e*n[r-1];if(r<2)return i/n[0];let a=0,o=0,s=r-1,c;for(;o<=s;)if(a=Math.floor(o+(s-o)/2),c=n[a]-i,c<0)o=a+1;else if(c>0)s=a-1;else{s=a;break}if(a=Math.max(0,s),n[a]===i)return a/(r-1);let l=n[a],u=n[a+1]-l,d=Math.max(0,(i-l)/u);return(a+d)/(r-1)}getTangent(e,t=new U){let n=1e-4,r=Math.max(0,e-n),i=Math.min(1,e+n);return t.copyFrom(this.getPoint(i).sub(this.getPoint(r)).normalize())}getTangentAt(e,t){return this.getTangent(this.getUToTMapping(e),t)}getPosTan(e){let t=this.getLength(),n=t>0?Math.min(Math.max(e/t,0),1):0,r=this.getUToTMapping(n),i=this.getTangent(r);return{position:this.getPoint(r),tangent:i,angle:Math.atan2(i.y,i.x)}}getNormal(e,t=new U){return this.getTangent(e,t),t.set(-t.y,t.x).normalize()}getNormalAt(e,t){return this.getNormal(this.getUToTMapping(e),t)}getTForPoint(e,t=.001){let n=0,r=1,i=(n+r)/2;for(;r-n>t;){i=(n+r)/2;let a=this.getPoint(i);if(a.distanceTo(e)<t)return i;a.x<e.x?n=i:r=i}return i}getMinMax(e=U.MAX,t=U.MIN){let n=this.getAdaptiveVertices(),r=e.x,i=e.y,a=t.x,o=t.y;for(let e=0,t=n.length;e<t;e+=2){let t=n[e],s=n[e+1];t<r&&(r=t),s<i&&(i=s),t>a&&(a=t),s>o&&(o=s)}return e.set(r,i),t.set(a,o),{min:e.finite(),max:t.finite()}}getBoundingBox(){let{min:e,max:t}=this.getMinMax();return new W(e.x,e.y,t.x-e.x,t.y-e.y)}isPointInFill(e,t={}){return Kn(e,this._getCachedAdaptiveVertices(),t.fillRule)}isPointInStroke(e,t={}){let{strokeWidth:n=1,tolerance:r=0,closed:i=!1}=t;return Jn(e,this._getCachedAdaptiveVertices(),i)<=n/2+r}contains(e,t,n={}){return this.isPointInFill({x:e,y:t},n)}getFillVertices(e){return this.getAdaptiveVertices()}fillTriangulate(e){return tr(this.getFillVertices(e),e)}isClosed(){let e=this._getCachedAdaptiveVertices(),t=e.length;if(t<6)return!1;let n=1e-4;return Math.abs(e[0]-e[t-2])<n&&Math.abs(e[1]-e[t-1])<n}strokeTriangulate(e){return Er(this.getAdaptiveVertices(),{...e,closed:e?.closed??this.isClosed()})}toCommands(){let e=[],t=this.getPoints();for(let n=0,r=t.length;n<r;n++){let r=t[n];n===0?e.push({type:`M`,x:r.x,y:r.y}):e.push({type:`L`,x:r.x,y:r.y})}return e}toData(){return Lr(this.toCommands())}drawTo(e){return this.toCommands().forEach(t=>{switch(t.type){case`M`:e.moveTo(t.x,t.y);break;case`L`:e.lineTo(t.x,t.y);break}}),this}copyFrom(e){return this.arcLengthDivision=e.arcLengthDivision,this}clone(){return new this.constructor().copyFrom(this)}},ui=new jr,di=new jr,fi=new jr,pi=new U,mi=class extends li{constructor(e=new U,t=new U,n=new U,r=0,i=0,a=Math.PI*2,o=!1){super(),this._center=e,this._radius=t,this._diff=n,this.rotate=r,this.startAngle=i,this.endAngle=a,this.clockwise=o}get cx(){return this._center.x}set cx(e){this._center.x=e}get cy(){return this._center.y}set cy(e){this._center.y=e}get rx(){return this._radius.x}set rx(e){this._radius.x=e}get ry(){return this._radius.y}set ry(e){this._radius.y=e}get dx(){return this._diff.x}set dx(e){this._diff.x=e}get dy(){return this._diff.y}set dy(e){this._diff.y=e}isClockwise(){return this.clockwise}isClosed(){return Math.abs(this.endAngle-this.startAngle)>=Math.PI*2-1e-9||super.isClosed()}reverse(){let{startAngle:e,endAngle:t}=this;return this.startAngle=t,this.endAngle=e,this.clockwise=!this.clockwise,this.invalidate(),this}_getDeltaAngle(){let e=Math.PI*2,t=this.endAngle-this.startAngle,n=Math.abs(t)<2**-52;return t=(t%e+e)%e,n?t=0:this.clockwise?t===0&&(t=e):t=t===0?-e:t-e,t}getPoint(e,t=new U){let n=this._getDeltaAngle(),r=this.startAngle+e*n,i=this.cx+this.rx*Math.cos(r),a=this.cy+this.ry*Math.sin(r);if(this.rotate!==0){let e=Math.cos(this.rotate),t=Math.sin(this.rotate),n=i-this.cx,r=a-this.cy;i=n*e-r*t+this.cx,a=n*t+r*e+this.cy}return t.set(i,a)}_pointAtAngle(e,t){let n=this.cx+this.rx*Math.cos(e),r=this.cy+this.ry*Math.sin(e);if(this.rotate!==0){let e=Math.cos(this.rotate),t=Math.sin(this.rotate),i=n-this.cx,a=r-this.cy;n=i*e-a*t+this.cx,r=i*t+a*e+this.cy}return t.set(n,r)}getMinMax(e=U.MAX,t=U.MIN){let{startAngle:n,rotate:r}=this,i=this._getDeltaAngle(),a=Math.cos(r),o=Math.sin(r),s=pi,c=e.x,l=e.y,u=t.x,d=t.y,f=e=>{this._pointAtAngle(e,s),s.x<c&&(c=s.x),s.y<l&&(l=s.y),s.x>u&&(u=s.x),s.y>d&&(d=s.y)};f(n),f(n+i);let p=Math.atan2(-this.ry*o,this.rx*a),m=Math.atan2(this.ry*a,this.rx*o),h=[p,p+Math.PI,m,m+Math.PI];for(let e=0;e<4;e++)hi(h[e],n,i)&&f(h[e]);return e.set(c,l),t.set(u,d),{min:e.finite(),max:t.finite()}}toCommands(){let{cx:e,cy:t,rx:n,ry:r,startAngle:i,endAngle:a,clockwise:o,rotate:s}=this,c=e+n*Math.cos(i)*Math.cos(s)-r*Math.sin(i)*Math.sin(s),l=t+n*Math.cos(i)*Math.sin(s)+r*Math.sin(i)*Math.cos(s),u=Math.abs(i-a),d=+(u>Math.PI),f=+!!o,p=s*180/Math.PI;if(u>=2*Math.PI){let a=i+Math.PI,o=e+n*Math.cos(a)*Math.cos(s)-r*Math.sin(a)*Math.sin(s),u=t+n*Math.cos(a)*Math.sin(s)+r*Math.sin(a)*Math.cos(s);return[{type:`M`,x:c,y:l},{type:`A`,rx:n,ry:r,angle:p,largeArcFlag:0,sweepFlag:f,x:o,y:u},{type:`A`,rx:n,ry:r,angle:p,largeArcFlag:0,sweepFlag:f,x:c,y:l}]}else{let i=e+n*Math.cos(a)*Math.cos(s)-r*Math.sin(a)*Math.sin(s),o=t+n*Math.cos(a)*Math.sin(s)+r*Math.sin(a)*Math.cos(s);return[{type:`M`,x:c,y:l},{type:`A`,rx:n,ry:r,angle:p,largeArcFlag:d,sweepFlag:f,x:i,y:o}]}}drawTo(e){let{cx:t,cy:n,rx:r,ry:i,rotate:a,startAngle:o,endAngle:s,clockwise:c}=this;return e.ellipse(t,n,r,i,a,o,s,!c),this}applyTransform(e){return pi.set(this.cx,this.cy),e.apply(pi,pi),this.cx=pi.x,this.cy=pi.y,yi(e)?gi(this,e):_i(this,e),this.invalidate(),this}getControlPointRefs(){return[this._center]}_getAdaptiveVerticesByArc(e=[]){let{cx:t,cy:n,rx:r,ry:i,dx:a,dy:o,startAngle:s,endAngle:c,clockwise:l,rotate:u}=this,d=!l,f=Math.abs(s-c);(!d&&s>c||d&&c>s)&&(f=2*Math.PI-f);let p=Math.max(12,Math.floor(12*r**(1/3)*(f/Math.PI))),m=f/p,h=s;m*=d?-1:1;let g=Math.cos(d?u:-u),_=Math.sin(d?u:-u);for(let s=0;s<p+1;s++){let s=a+Math.cos(h)*r,c=o+Math.sin(h)*i,l=s*g-c*_,u=s*_+c*g;e.push(t+l,n+u),h+=m}return e}_getAdaptiveVerticesByCircle(e=[]){let{cx:t,cy:n,rx:r,ry:i,dx:a,dy:o,rotate:s,clockwise:c}=this;if(!(r>=0&&i>=0&&a>=0&&o>=0))return e;let l=Math.ceil(2.3*Math.sqrt(r+i)),u=l*8+(a?4:0)+(o?4:0),d=[];if(u===0)return e;{let e=d.length;if(l===0)d[e]=d[e+6]=t+a,d[e+1]=d[e+3]=n+o,d[e+2]=d[e+4]=t-a,d[e+5]=d[e+7]=n-o;else{let s=e,c=e+l*4+(a?2:0)+2,f=c,p=u,m=a+r,h=o,g=t+m,_=t-m,v=n+h;if(d[s++]=g,d[s++]=v,d[--c]=v,d[--c]=_,o){let e=n-h;d[f++]=_,d[f++]=e,d[--p]=e,d[--p]=g}for(let e=1;e<l;e++){let u=Math.PI/2*(e/l),m=a+Math.cos(u)*r,h=o+Math.sin(u)*i,g=t+m,_=t-m,v=n+h,y=n-h;d[s++]=g,d[s++]=v,d[--c]=v,d[--c]=_,d[f++]=_,d[f++]=y,d[--p]=y,d[--p]=g}m=a,h=o+i,g=t+m,_=t-m,v=n+h;let y=n-h;d[s++]=g,d[s++]=v,d[--p]=y,d[--p]=g,a&&(d[s++]=_,d[s++]=v,d[--p]=y,d[--p]=_)}}let f=Math.cos(c?-s:s),p=Math.sin(c?-s:s);for(let r=0;r<d.length;r+=2){let i=d[r],a=d[r+1],o=i-t,s=a-n,c=o*f-s*p,l=o*p+s*f;e.push(t+c,n+l)}return e}getAdaptiveVertices(e=[]){let t=Math.PI*2;if(this.startAngle===0&&this.endAngle===t)return this._getAdaptiveVerticesByCircle(e);if(Math.abs(this.endAngle-this.startAngle)>=t-1e-9){let t=this._getAdaptiveVerticesByCircle([]),n=t.length/2;if(this.endAngle>this.startAngle)for(let n=0;n<t.length;n++)e.push(t[n]);else{e.push(t[0],t[1]);for(let r=n-1;r>=1;r--)e.push(t[r*2],t[r*2+1])}return e}return this._getAdaptiveVerticesByArc(e)}copyFrom(e){return super.copyFrom(e),this.cx=e.cx,this.cy=e.cy,this.rx=e.rx,this.ry=e.ry,this.dx=e.dx,this.dy=e.dy,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.clockwise=e.clockwise,this.rotate=e.rotate,this}};function hi(e,t,n){let r=Math.PI*2,i=1e-9;if(Math.abs(n)>=r-i)return!0;let a=(e-t)%r;return n>=0?(a<-1e-9&&(a+=r),a>=-1e-9&&a<=n+i):(a>i&&(a-=r),a<=i&&a>=n-i)}function gi(e,t){let n=e.rx,r=e.ry,i=Math.cos(e.rotate),a=Math.sin(e.rotate),o=new U(n*i,n*a),s=new U(-r*a,r*i),c=t.a*o.x+t.c*o.y,l=t.b*o.x+t.d*o.y,u=t.a*s.x+t.c*s.y,d=t.b*s.x+t.d*s.y,f=ui.set(c,l,u,d,0,0),{a:p,b:m,c:h,d:g}=di.copyFrom(f).affineInvert(),_=bi(p*p+m*m,h*p+g*m,h*h+g*g),v=Math.sqrt(_.rt1),y=Math.sqrt(_.rt2);if(e.rx=1/v,e.ry=1/y,e.rotate=Math.atan2(_.sn,_.cs),!((e.endAngle-e.startAngle)%(2*Math.PI)<2**-52)){let n=di.set(v,0,0,y,0,0),r=fi.set(_.cs,_.sn,-_.sn,_.cs,0,0),i=n.append(r).append(f),a=e=>{let{x:t,y:n}=i.apply({x:Math.cos(e),y:Math.sin(e)});return Math.atan2(n,t)};e.startAngle=a(e.startAngle),e.endAngle=a(e.endAngle),vi(t)&&(e.clockwise=!e.clockwise)}}function _i(e,t){let{scale:n}=t.decompose();e.rx*=n.x,e.ry*=n.y;let r=n.x>2**-52?Math.atan2(t.b,t.a):Math.atan2(-t.c,t.d);e.rotate+=r,vi(t)&&(e.startAngle*=-1,e.endAngle*=-1,e.clockwise=!e.clockwise)}function vi(e){return e.a*e.d-e.c*e.b<0}function yi(e){let t=e.a*e.c+e.b*e.d;if(t===0)return!1;let{scale:n}=e.decompose();return Math.abs(t/(n.x*n.y))>2**-52}function bi(e,t,n){let r,i,a,o,s,c=e+n,l=e-n,u=Math.sqrt(l*l+4*t*t);return c>0?(r=.5*(c+u),s=1/r,i=e*s*n-t*s*t):c<0?(i=.5*(c-u),s=1/i,r=e*s*n-t*s*t):(r=.5*u,i=-.5*u),a=l>0?l+u:l-u,Math.abs(a)>2*Math.abs(t)?(s=-2*t/a,o=1/Math.sqrt(1+s*s),a=s*o):Math.abs(t)===0?(a=1,o=0):(s=-.5*a/t,a=1/Math.sqrt(1+s*s),o=s*a),l>0&&(s=a,a=-o,o=s),{rt1:r,rt2:i,cs:a,sn:o}}var xi=class extends mi{constructor(e=0,t=0,n=1,r=0,i=Math.PI*2,a=!1){super(new U(e,t),new U(n,n),new U,0,r,i,a)}drawTo(e){let{cx:t,cy:n,rx:r,startAngle:i,endAngle:a,clockwise:o}=this;return e.arc(t,n,r,i,a,!o),this}},Si=class e extends li{constructor(e=new U,t=new U){super(),this.p1=e,this.p2=t}static from(t,n,r,i){return new e(new U(t,n),new U(r,i))}getPoint(e,t=new U){return e===1?t.copyFrom(this.p2):t.copyFrom(this.p2).sub(this.p1).scale(e).add(this.p1),t}getPointAt(e,t=new U){return this.getPoint(e,t)}getTangent(e,t=new U){return t.subVectors(this.p2,this.p1).normalize()}getTangentAt(e,t=new U){return this.getTangent(e,t)}getControlPointRefs(){return[this.p1,this.p2]}reverse(){let{p1:e,p2:t}=this;return this.p1=t,this.p2=e,this.invalidate(),this}getAdaptiveVertices(e=[]){return e.push(this.p1.x,this.p1.y,this.p2.x,this.p2.y),e}getMinMax(e=U.MAX,t=U.MIN){let{p1:n,p2:r}=this;return e.x=Math.min(e.x,n.x,r.x),e.y=Math.min(e.y,n.y,r.y),t.x=Math.max(t.x,n.x,r.x),t.y=Math.max(t.y,n.y,r.y),{min:e.finite(),max:t.finite()}}toCommands(){let{p1:e,p2:t}=this;return[{type:`M`,x:e.x,y:e.y},{type:`L`,x:t.x,y:t.y}]}getFillVertices(e={}){let t=Math.min(this.p1.x,this.p2.x),n=Math.max(this.p1.x,this.p2.x),r=Math.min(this.p1.y,this.p2.y),i=Math.max(this.p1.y,this.p2.y),a=t,o=r,s=n-t||e.style?.strokeWidth||0,c=i-r||e.style?.strokeWidth||0;return[a,o,a+s,o,a+s,o+c,a,o+c]}drawTo(e){let{p1:t,p2:n}=this;return e.lineTo(t.x,t.y),e.lineTo(n.x,n.y),this}copyFrom(e){return super.copyFrom(e),this.p1.copyFrom(e.p1),this.p2.copyFrom(e.p2),this}},Ci=class e extends li{constructor(e=[]){super(),this.curves=e}_adaptiveCacheLen=-1;_invalidateSelf(){super._invalidateSelf(),this._adaptiveCacheLen=-1,this.curves.forEach(e=>e.invalidate())}_getCachedAdaptiveVertices(){return(!this._adaptiveCache||this._adaptiveCacheLen!==this.curves.length)&&(this.curves.forEach(e=>{e._owner=this}),this._adaptiveCache=this.getAdaptiveVertices(),this._adaptiveCacheLen=this.curves.length),this._adaptiveCache}getFlatCurves(){return this.curves.flatMap(t=>t instanceof e?t.getFlatCurves():t)}addCurve(e){return this.curves.push(e),this}getPoint(e,t=new U){let n=e*this.getLength(),r=this.getLengths(),i=r.length;if(i===0)return t;let a=0,o=i-1;for(;a<o;){let e=a+o>>>1;r[e]<n?a=e+1:o=e}let s=r[a]-n,c=this.curves[a],l=c.getLength();return c.getPointAt(l===0?0:1-s/l,t)}getLengths(){return this._lengths.length!==this.curves.length&&this.updateLengths(),this._lengths}updateLengths(){let e=[];for(let t=0,n=0,r=this.curves.length;t<r;t++)this.curves[t]._owner=this,n+=this.curves[t].getLength(),e.push(n);this._lengths=e}getControlPointRefs(){return this.curves.flatMap(e=>e.getControlPointRefs())}_removeNextPointIfEqualPrevPoint(e,t){let n=[e[t-1],e[t]],r=[e[t+1],e[t+2]];return n[0]===r[0]&&n[1]===r[1]&&e.splice(t+1,2),e}getSpacedVertices(e=5,t=[]){let n;return this.curves.forEach(r=>{r.getSpacedVertices(e,t),n&&this._removeNextPointIfEqualPrevPoint(t,n),n=t.length-1}),t}getAdaptiveVertices(e=[]){let t;return this.curves.forEach(n=>{n.getAdaptiveVertices(e),t&&this._removeNextPointIfEqualPrevPoint(e,t),t=e.length-1}),e}isClosed(){return this.curves.length===1?this.curves[0].isClosed():super.isClosed()}strokeTriangulate(e){return this.curves.length===1?this.curves[0].strokeTriangulate(e):super.strokeTriangulate(e)}reverse(){return this.curves.reverse(),this.curves.forEach(e=>e.reverse()),this.invalidate(),this}getFillVertices(e){if(this.curves.length===1)return this.curves[0].getFillVertices(e);{let t=[],n;return this.curves.forEach(r=>{let i;i=r instanceof Si?r.getAdaptiveVertices():r.getFillVertices(e),t.push(...i),n&&this._removeNextPointIfEqualPrevPoint(t,n),n=t.length-1}),t}}applyTransform(e){return this._invalidating=!0,this.curves.forEach(t=>t.applyTransform(e)),this._invalidating=!1,this.invalidate(),this}getMinMax(e=U.MAX,t=U.MIN){return this.curves.forEach(n=>n.getMinMax(e,t)),{min:e.finite(),max:t.finite()}}getBoundingBox(){let{min:e,max:t}=this.getMinMax();return new W(e.x,e.y,t.x-e.x,t.y-e.y)}toCommands(){return this.curves.flatMap(e=>e.toCommands())}drawTo(e){let t=this.curves[0]?.getPoint(0);return t&&e.moveTo(t.x,t.y),this.curves.forEach(t=>t.drawTo(e)),this}copyFrom(e){return super.copyFrom(e),this.curves=e.curves.map(e=>e.clone()),this}},wi=class e extends li{constructor(e=new U,t=new U,n=new U,r=new U){super(),this.p1=e,this.cp1=t,this.cp2=n,this.p2=r}static from(t,n,r,i,a,o,s,c){return new e(new U(t,n),new U(r,i),new U(a,o),new U(s,c))}getPoint(e,t=new U){let{p1:n,cp1:r,cp2:i,p2:a}=this;return t.set(Vn(e,n.x,r.x,i.x,a.x),Vn(e,n.y,r.y,i.y,a.y))}getAdaptiveVertices(e=[]){return ar(this.p1.x,this.p1.y,this.cp1.x,this.cp1.y,this.cp2.x,this.cp2.y,this.p2.x,this.p2.y,.5,e)}getControlPointRefs(){return[this.p1,this.cp1,this.cp2,this.p2]}reverse(){let{p1:e,cp1:t,cp2:n,p2:r}=this;return this.p1=r,this.cp1=n,this.cp2=t,this.p2=e,this.invalidate(),this}_solveQuadratic(e,t,n){if(Math.abs(e)<1e-12){if(Math.abs(t)<1e-12)return[];let e=-n/t;return e>=0&&e<=1?[e]:[]}let r=t*t-4*e*n;if(r<0)return[];let i=Math.sqrt(r);return[(-t+i)/(2*e),(-t-i)/(2*e)].filter(e=>e>=0&&e<=1)}getMinMax(e=U.MAX,t=U.MIN){let{p1:n,cp1:r,cp2:i,p2:a}=this,o=this._solveQuadratic(3*(-n.x+3*r.x-3*i.x+a.x),6*(n.x-2*r.x+i.x),3*(r.x-n.x)),s=this._solveQuadratic(3*(-n.y+3*r.y-3*i.y+a.y),6*(n.y-2*r.y+i.y),3*(r.y-n.y)),c=[0,1,...o,...s];for(let n of c){let r=this.getPoint(n);e.x=Math.min(e.x,r.x),e.y=Math.min(e.y,r.y),t.x=Math.max(t.x,r.x),t.y=Math.max(t.y,r.y)}return{min:e.finite(),max:t.finite()}}toCommands(){let{p1:e,cp1:t,cp2:n,p2:r}=this;return[{type:`M`,x:e.x,y:e.y},{type:`C`,x1:t.x,y1:t.y,x2:n.x,y2:n.y,x:r.x,y:r.y}]}drawTo(e){let{p1:t,cp1:n,cp2:r,p2:i}=this;return e.lineTo(t.x,t.y),e.bezierCurveTo(n.x,n.y,r.x,r.y,i.x,i.y),this}copyFrom(e){return super.copyFrom(e),this.p1.copyFrom(e.p1),this.cp1.copyFrom(e.cp1),this.cp2.copyFrom(e.cp2),this.p2.copyFrom(e.p2),this}},Ti=class extends mi{constructor(e=0,t=0,n=1,r=1,i=0,a=0,o=Math.PI*2,s=!1){super(new U(e,t),new U(n,r),new U,i,a,o,s)}drawTo(e){return e.ellipse(this.cx,this.cy,this.rx,this.ry,this.rotate,this.startAngle,this.endAngle,!this.clockwise),this}},Ei=class extends Ci{},Di=class e extends li{constructor(e=new U,t=new U,n=new U){super(),this.p1=e,this.cp=t,this.p2=n}static from(t,n,r,i,a,o){return new e(new U(t,n),new U(r,i),new U(a,o))}getPoint(e,t=new U){let{p1:n,cp:r,p2:i}=this;return t.set(xr(e,n.x,r.x,i.x),xr(e,n.y,r.y,i.y)),t}getControlPointRefs(){return[this.p1,this.cp,this.p2]}reverse(){let{p1:e,p2:t}=this;return this.p1=t,this.p2=e,this.invalidate(),this}getAdaptiveVertices(e=[]){return ur(this.p1.x,this.p1.y,this.cp.x,this.cp.y,this.p2.x,this.p2.y,.5,e)}getMinMax(e=U.MAX,t=U.MIN){let{p1:n,cp:r,p2:i}=this,a=(e,t,n)=>{let r=e-2*t+n;if(Math.abs(r)<1e-12)return null;let i=(e-t)/r;return i>0&&i<1?i:null},o=a(n.x,r.x,i.x),s=a(n.y,r.y,i.y),c=[n.x,i.x],l=[n.y,i.y];return o!==null&&c.push(xr(o,n.x,r.x,i.x)),s!==null&&l.push(xr(s,n.y,r.y,i.y)),e.x=Math.min(e.x,...c),e.y=Math.min(e.y,...l),t.x=Math.max(t.x,...c),t.y=Math.max(t.y,...l),{min:e.finite(),max:t.finite()}}toCommands(){let{p1:e,cp:t,p2:n}=this;return[{type:`M`,x:e.x,y:e.y},{type:`Q`,x1:t.x,y1:t.y,x:n.x,y:n.y}]}drawTo(e){let{p1:t,cp:n,p2:r}=this;return e.lineTo(t.x,t.y),e.quadraticCurveTo(n.x,n.y,r.x,r.y),this}copyFrom(e){return super.copyFrom(e),this.p1.copyFrom(e.p1),this.cp.copyFrom(e.cp),this.p2.copyFrom(e.p2),this}},Oi=class extends Ei{constructor(e=0,t=0,n=0,r=0){super(),this.x=e,this.y=t,this.width=n,this.height=r,this.update()}update(){let{x:e,y:t,width:n,height:r}=this,i=[new U(e,t),new U(e+n,t),new U(e+n,t+r),new U(e,t+r)];return this.curves=[new Si(i[0],i[1]),new Si(i[1],i[2]),new Si(i[2],i[3]),new Si(i[3],i[0])],this}drawTo(e){return e.rect(this.x,this.y,this.width,this.height),this}getFillVertices(e={}){let{x:t,y:n,width:r,height:i}=this;return[t,n,t+r,n,t+r,n+i,t,n+i]}copyFrom(e){return super.copyFrom(e),this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.update(),this}},ki=class extends Ci{constructor(e=0,t=0,n=1,r=1,i=1){super(),this.x=e,this.y=t,this.width=n,this.height=r,this.radius=i,this.update()}update(){let{x:e,y:t,width:n,height:r}=this,i=Math.max(0,Math.min(this.radius,Math.abs(n)/2,Math.abs(r)/2)),a=e,o=e+i,s=e+n-i,c=e+n,l=t,u=t+i,d=t+r-i,f=t+r;if(i<=0)this.curves=[Si.from(a,l,c,l),Si.from(c,l,c,f),Si.from(c,f,a,f),Si.from(a,f,a,l)];else{let e=Math.PI/2;this.curves=[Si.from(o,l,s,l),new xi(s,u,i,-e,0,!0),Si.from(c,u,c,d),new xi(s,d,i,0,e,!0),Si.from(s,f,o,f),new xi(o,d,i,e,Math.PI,!0),Si.from(a,d,a,u),new xi(o,u,i,Math.PI,Math.PI*1.5,!0)]}return this.invalidate(),this}drawTo(e){return e.roundRect(this.x,this.y,this.width,this.height,this.radius),this}copyFrom(e){return this.arcLengthDivision=e.arcLengthDivision,this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.radius=e.radius,this.update(),this}},Ai=class extends li{constructor(e=[]){super(),this.points=e}getPoint(e,t=new U){let{points:n}=this,r=(n.length-1)*e,i=Math.floor(r),a=r-i,o=n[i===0?i:i-1],s=n[i],c=n[i>n.length-2?n.length-1:i+1],l=n[i>n.length-3?n.length-1:i+2];return t.set(Dn(a,o.x,s.x,c.x,l.x),Dn(a,o.y,s.y,c.y,l.y)),t}getControlPointRefs(){return this.points}reverse(){return this.points.reverse(),this.invalidate(),this}copyFrom(e){super.copyFrom(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++)this.points.push(e.points[t].clone());return this}},ji=class extends Ci{startPoint;currentPoint;autoClose=!1;constructor(e){super(),e&&this.addPoints(e)}addPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++){let{x:n,y:r}=e[t];this.lineTo(n,r)}return this}addCommands(e){return Ir(e,this),this}addData(e){return this.addCommands(zr(e)),this}isClosed(){return this.autoClose||super.isClosed()}reverse(){return super.reverse(),this.curves.length&&(this.startPoint=this.getPoint(0),this.currentPoint=this.getPoint(1)),this}_closeVertices(e){return this.autoClose&&e.length>=4&&e[0]!==e[e.length-2]&&e[1]!==e[e.length-1]&&e.push(e[0],e[1]),e}getUnevenVertices(e=40,t=[]){return this._closeVertices(super.getUnevenVertices(e,t))}getSpacedVertices(e=40,t=[]){return this._closeVertices(super.getSpacedVertices(e,t))}getAdaptiveVertices(e=[]){return this._closeVertices(super.getAdaptiveVertices(e))}getFillVertices(e){return this._closeVertices(super.getFillVertices(e))}isPointInStroke(e,t={}){let{strokeWidth:n=1,tolerance:r=0}=t,i=this._getCachedAdaptiveVertices(),a=i.length;return Jn(e,i,t.closed??(this.autoClose||a>=6&&i[0]===i[a-2]&&i[1]===i[a-1]))<=n/2+r}_setCurrentPoint(e){return this.currentPoint=new U(e.x,e.y),this.startPoint||=this.currentPoint.clone(),this}_connetLineTo(e){if(this.curves.length>0){let t=e.getPoint(0);(!this.currentPoint||!t.equals(this.currentPoint))&&this.lineTo(t.x,t.y)}return this}closePath(){let e=this.startPoint;if(e){let t=this.currentPoint;t&&!e.equals(t)&&(this.curves.push(new Si(t.clone(),e.clone())),t.copyFrom(e)),this.startPoint=void 0}return this}moveTo(e,t){return this.currentPoint=new U(e,t),this.startPoint=this.currentPoint.clone(),this}lineTo(e,t){let n=this.currentPoint;return n?.equals({x:e,y:t})||this.curves.push(Si.from(n?.x??0,n?.y??0,e,t)),this._setCurrentPoint({x:e,y:t}),this}bezierCurveTo(e,t,n,r,i,a){let o=this.currentPoint;return o?.equals({x:i,y:a})||this.curves.push(wi.from(o?.x??0,o?.y??0,e,t,n,r,i,a)),this._setCurrentPoint({x:i,y:a}),this}quadraticCurveTo(e,t,n,r){let i=this.currentPoint;return i?.equals({x:n,y:r})||this.curves.push(Di.from(i?.x??0,i?.y??0,e,t,n,r)),this._setCurrentPoint({x:n,y:r}),this}arc(e,t,n,r,i,a){let o=new xi(e,t,n,r,i,!a);return this._connetLineTo(o),this.curves.push(o),this._setCurrentPoint(o.getPoint(1)),this}relativeArc(e,t,n,r,i,a){return e+=this.currentPoint?.x??0,t+=this.currentPoint?.y??0,this.arc(e,t,n,r,i,a),this}arcTo(e,t,n,r,i){return console.warn(`Method arcTo not supported yet`),this}ellipse(e,t,n,r,i,a,o,s=!0){let c=new Ti(e,t,n,r,i,a,o,!s);return this._connetLineTo(c),this.curves.push(c),this._setCurrentPoint(c.getPoint(1)),this}relativeEllipse(e,t,n,r,i,a,o,s){return e+=this.currentPoint?.x??0,t+=this.currentPoint?.y??0,this.ellipse(e,t,n,r,i,a,o,s),this}rect(e,t,n,r){let i=new Oi(e,t,n,r);return this._connetLineTo(i),this.curves.push(i),this._setCurrentPoint({x:e,y:t}),this}roundRect(e,t,n,r,i){let a=new ki(e,t,n,r,i);return this._connetLineTo(a),this.curves.push(a),this._setCurrentPoint({x:e,y:t}),this}splineThru(e){let t=this.currentPoint??new U;return this.curves.push(new Ai([t].concat(e))),this._setCurrentPoint(e[e.length-1]),this}drawTo(e){let t=this.curves[0]?.getPoint(0);return t&&e.moveTo(t.x,t.y),this.curves.forEach(t=>t.drawTo(e)),this.autoClose&&e.closePath(),this}copyFrom(e){return super.copyFrom(e),this.autoClose=e.autoClose,this.currentPoint=e.currentPoint?.clone(),this}},Mi=class e extends Ci{_meta;_ringsCache;_ringsCacheLen=-1;currentCurve=new ji;style;get startPoint(){return this.currentCurve.startPoint}get currentPoint(){return this.currentCurve.currentPoint}get strokeWidth(){return this.style.strokeWidth??((this.style.stroke??`none`)===`none`?0:1)}constructor(t,n={}){super(),this.curves.push(this.currentCurve),this.style=n,t&&(t instanceof e?this.addPath(t):Array.isArray(t)?this.addCommands(t):this.addData(t))}getMeta(){return this._meta}setMeta(e){return this._meta=e,this}addPath(t){let n=t instanceof e?t.curves:[t];if(!n.some(e=>e.curves.length))return this;if(!this.currentCurve.curves.length){let e=this.curves.findIndex(e=>e===this.currentCurve);e>-1&&this.curves.splice(e,1)}return this.curves.push(...n.map(e=>e.clone())),this.currentCurve=this.curves[this.curves.length-1],this}closePath(){let e=this.startPoint;return e&&this.currentCurve.curves.length&&(this.currentCurve.closePath(),this.currentCurve=new ji().moveTo(e.x,e.y),this.curves.push(this.currentCurve)),this}moveTo(e,t){return this.currentCurve.curves.length&&(this.currentCurve=new ji,this.curves.push(this.currentCurve)),this.currentCurve.moveTo(e,t),this}lineTo(e,t){return this.currentCurve.lineTo(e,t),this}bezierCurveTo(e,t,n,r,i,a){return this.currentCurve.bezierCurveTo(e,t,n,r,i,a),this}quadraticCurveTo(e,t,n,r){return this.currentCurve.quadraticCurveTo(e,t,n,r),this}arc(e,t,n,r,i,a){return this.currentCurve.arc(e,t,n,r,i,a),this}arcTo(e,t,n,r,i){return this.currentCurve.arcTo(e,t,n,r,i),this}ellipse(e,t,n,r,i,a,o,s){return this.currentCurve.ellipse(e,t,n,r,i,a,o,s),this}rect(e,t,n,r){return this.currentCurve.rect(e,t,n,r),this}roundRect(e,t,n,r,i){return this.currentCurve.roundRect(e,t,n,r,i),this}reset(){return this.currentCurve=new ji,this.curves=[this.currentCurve],this.style={},this}addCommands(e){return Ir(e,this),this}addData(e){return this.addCommands(zr(e)),this}splineThru(e){return this.currentCurve.splineThru(e),this}scale(e,t=e,n={x:0,y:0}){return this.getControlPointRefs().forEach(r=>{r.scale(e,t,n)}),this.invalidate(),this}skew(e,t=0,n={x:0,y:0}){return this.getControlPointRefs().forEach(r=>{r.skew(e,t,n)}),this.invalidate(),this}rotate(e,t={x:0,y:0}){return this.getControlPointRefs().forEach(n=>{n.rotate(e,t)}),this.invalidate(),this}bold(e){if(e===0)return this;let t=this.getFlatCurves(),n=[],r=[],i=[];t.forEach((e,t)=>{let a=e.getControlPointRefs(),o=e.isClockwise();i[t]=a,r[t]=o;let s=a[0],c=a[a.length-1]??s;n.push({start:o?c:s,end:o?s:c,index:t})});let a=[];return n.forEach((e,t)=>{a[t]=[],n.forEach((n,r)=>{n.start&&e.end&&r!==t&&n.start?.equals(e.end)&&a[t].push(n.index)})}),t.forEach((t,n)=>{let a=r[n];i[n].forEach(n=>{n.add(t.getNormal(t.getTForPoint(n)).scale(a?e:-e))})}),a.forEach((e,t)=>{let n=i[t];e.forEach(e=>{let t=i[e],r=An(n[n.length-1],n[n.length-2]??n[n.length-1],t[0],t[1]??t[0]);r&&(n[n.length-1].copyFrom(r),t[0].copyFrom(r))})}),this.invalidate(),this}_invalidateSelf(){super._invalidateSelf(),this._ringsCache=void 0,this._ringsCacheLen=-1}_getRings(){return(!this._ringsCache||this._ringsCacheLen!==this.curves.length)&&(this._ringsCache=this.curves.map(e=>(e._owner=this,e.getAdaptiveVertices())),this._ringsCacheLen=this.curves.length),this._ringsCache}isPointInFill(e,t={}){let n=t.fillRule??this.style.fillRule??`nonzero`;return qn(e,this._getRings(),n)}static fromRings(t,n={}){let r=new e(void 0,n);for(let e of t){if(e.length<6)continue;let t=e.length;e[0]===e[t-2]&&e[1]===e[t-1]&&(t-=2),r.moveTo(e[0],e[1]);for(let n=2;n<t;n+=2)r.lineTo(e[n],e[n+1]);r.closePath()}return r}booleanOp(t,n,r){let i=En(t,this._getRings(),n._getRings());return e.fromRings(i,{...this.style,...r})}union(e,t){return this.booleanOp(`union`,e,t)}intersection(e,t){return this.booleanOp(`intersection`,e,t)}difference(e,t){return this.booleanOp(`difference`,e,t)}xor(e,t){return this.booleanOp(`xor`,e,t)}isPointInStroke(e,t={}){let n=t.strokeWidth??this.strokeWidth,{tolerance:r=0,closed:i}=t;return this.curves.some(t=>t.isPointInStroke(e,{strokeWidth:n,tolerance:r,closed:i}))}getMinMax(e=U.MAX,t=U.MIN,n=!0){if(this.curves.forEach(n=>{n.getMinMax(e,t)}),n){let n=this.strokeWidth;if(n>1&&Number.isFinite(e.x)){let r=n/2;e.set(e.x-r,e.y-r),t.set(t.x+r,t.y+r)}}return{min:e.finite(),max:t.finite()}}strokeTriangulate(e){let t=e?.indices??[],n=e?.vertices??[];return this.curves.forEach(r=>{r.strokeTriangulate({...e,indices:t,vertices:n,style:{...this.style}})}),{indices:t,vertices:n}}fillTriangulate(e){let t={...e,style:{...this.style,...e?.style}},n=t.indices??[],r=t.vertices??[];if((e?.fillRule??t.style.fillRule??`nonzero`)===`nonzero`){let i=this.curves.map(e=>e.getFillVertices(t)),a=_r(i),o=a.length;for(let t=0;t<o;t++){let s=a[t],c=i[t];if(s.winding||!c.length)continue;let l=c.slice(),u=[];for(let e=0;e<o;e++){let n=a[e];n.parentIndex===t&&(u.push(l.length/2),l.push(...i[n.index]))}tr(l,{...e,indices:n,vertices:r,holes:u,style:{...this.style}})}}else{let i=this.curves.map(e=>e.getFillVertices(t)),a=Qn(i),o=a.length;for(let t=0;t<o;t++){let s=i[t];if((a[t].depth&1)==1||!s.length)continue;let c=s.slice(),l=[];for(let e=0;e<o;e++)a[e].parentIndex===t&&(a[e].depth&1)==1&&(l.push(c.length/2),c.push(...i[e]));tr(c,{...e,indices:n,vertices:r,holes:l,style:{...this.style}})}}return{indices:n,vertices:r}}getBoundingBox(e=!0){let{min:t,max:n}=this.getMinMax(void 0,void 0,e);return new W(t.x,t.y,n.x-t.x,n.y-t.y)}drawTo(e,t={}){t={...this.style,...t};let{fill:n=`#000`,stroke:r=`none`,fillRule:i=`nonzero`}=t;return e.beginPath(),e.save(),Sn(e,t),this.curves.forEach(t=>{t.drawTo(e)}),n!==`none`&&e.fill(i),r!==`none`&&e.stroke(),e.restore(),this}drawControlPointsTo(e,t={}){t={...this.style,...t};let{fill:n=`#000`,stroke:r=`none`}=t;return e.beginPath(),e.save(),Sn(e,t),this.getControlPointRefs().forEach(t=>{bn(e,t.x,t.y,{radius:4})}),n!==`none`&&e.fill(),r!==`none`&&e.stroke(),e.restore(),this}toCommands(){return this.curves.flatMap(e=>e.toCommands())}toData(){return this.curves.filter(e=>e.curves.length).map(e=>e.toData()).join(` `)}toSvgPathString(){let e={...this.style,fill:this.style.fill??`#000`,stroke:this.style.stroke??`none`},t={};for(let n in e)e[n]!==void 0&&(t[kn(n)]=e[n]);Object.assign(t,{"stroke-width":`${this.strokeWidth}px`});let n=``;for(let e in t)t[e]!==void 0&&(n+=`${e}:${t[e]};`);return`<path d="${this.toData()}" style="${n}"></path>`}copyFrom(e){return super.copyFrom(e),this.currentCurve=e.currentCurve.clone(),this.style={...e.style},this}},Ni=class{constructor(e=[],t){this.paths=e,this.viewBox=t}isPointInFill(e,t={}){return this.paths.some(n=>n.isPointInFill(e,t))}contains(e,t,n={}){return this.isPointInFill({x:e,y:t},n)}hitTest(e,t={}){let{stroke:n=!0,forceStroke:r=!1,tolerance:i,fillRule:a}=t;for(let t=this.paths.length-1;t>=0;t--){let o=this.paths[t];if((o.style.fill??`#000`)!==`none`&&o.isPointInFill(e,{fillRule:a})||n&&(r||(o.style.stroke??`none`)!==`none`)&&o.isPointInStroke(e,{tolerance:i}))return o}}getBoundingBox(e=!0){if(!this.paths.length)return;let t=U.MAX,n=U.MIN;return this.paths.forEach(r=>r.getMinMax(t,n,e)),new W(t.x,t.y,n.x-t.x,n.y-t.y)}toTriangulatedSvgString(e=this.paths.map(e=>e.fillTriangulate()),t=0){let n=``,r=``,i={x:-t,y:-t},a={x:t,y:t};(Array.isArray(e)?e:[e]).forEach(({vertices:e,indices:o,points:s=[]})=>{let c=n=>{let r=e[n*2],o=e[n*2+1];return i.x=Math.min(i.x,r+t),a.x=Math.max(a.x,r+t),i.y=Math.min(i.y,o+t),a.y=Math.max(a.y,o+t),[r,o]};for(let e=0,t=o.length;e<t;e+=3){let t=c(o[e]),r=c(o[e+1]),i=c(o[e+2]);n+=`<polygon
5
5
  points="${t.join(`,`)} ${r.join(`,`)} ${i.join(`,`)}"
6
6
  stroke="#28a745"
7
7
  stroke-width="#stroke-width"
@@ -32,6 +32,6 @@ ${this.paths.map(e=>e.toSvgPathString()).join(``)}
32
32
  font-family: "${e}";
33
33
  src: url(${t});
34
34
  }`)),document.head.appendChild(n)}return this}_parseUrls(e){let t=[...new Set([...e.split(`,`),e])];return[...new Set(t.map(e=>this.familyToUrl.get(e.trim())??this.familyToUrl.get(e)??e))]}get(e){let t;return e&&(t=this._parseUrls(e).reduce((e,t)=>e||this.loaded.get(t),void 0)),t??this.fallbackFont}set(e,t){return this.familyToUrl.set(e,t.src),this.loaded.set(t.src,t),this}delete(e){return this._parseUrls(e).forEach(e=>{this.familyToUrl.delete(e),this.loaded.delete(e)}),this}clear(){return this.familyToUrl.clear(),this.loading.clear(),this.loaded.clear(),this}_parseFamilies(e){return e?(Array.isArray(e)?e:[e]).flatMap(e=>e.split(`,`).map(e=>e.trim())):[]}async load(e,t={}){let{cancelOther:n,injectStyleTag:r=!1,injectFontFace:i=!1,...a}=t,o,s;typeof e==`string`?o=e:{src:o,family:s}=e;let c=this._parseFamilies(s);if(this.loaded.has(o))return n&&(this.loading.forEach(e=>e.cancel()),this.loading.clear()),u(this.loaded.get(o));let l=this.loading.get(o);return l||(l=this._createRequest(o,a),this.loading.set(o,l)),n&&this.loading.forEach((e,t)=>{e!==l&&(e.cancel(),this.loading.delete(t))}),l.when.then(e=>{let n;return this.loaded.has(o)?n=u(this.loaded.get(o)):(n=this._createLoadedFont(o,c,e),t.noAdd||this.loaded.set(o,n)),Promise.all(Array.from(n.familySet,async t=>{if(this.familyToUrl.set(t,o),typeof document<`u`&&(i&&await this.injectFontFace(t,e),r&&this.injectStyleTag(t,o),i||r))return await document.fonts.load(`14px "${t}"`)})).then(()=>(this._emitLoad(n),n))}).catch(e=>{if(e instanceof DOMException&&e.message===`The user aborted a request.`)return this._createLoadedFont(o,c);throw e}).finally(()=>{this.loading.delete(o)});function u(e){return c.forEach(t=>{e.familySet.add(t)}),e}}_createLoadedFont(e,t,n=new ArrayBuffer(0)){let r;function i(){return r||=n.byteLength?Zc(n,!1):void 0,r}function a(){let e=i();if(e instanceof Lc||e instanceof Yc)return e.sfnt}return{src:e,family:t.length===1?t[0]:t,buffer:n,familySet:new Set(t),getFont:i,getSFNT:a}}async waitUntilLoad(){await Promise.all(Array.from(this.loading.values(),e=>e.when))}},$c=new Set([`©`,`®`,`÷`]),el=new Set([`—`,`…`,`“`,`”`,`﹏`,`﹋`,`﹌`,`‘`,`’`,`˜`]),tl={1:`italic`,32:`bold`},nl={1:`italic`,2:`bold`},rl={100:-.2,200:-.1,300:0,400:0,normal:0,500:.1,600:.2,700:.3,bold:.3,800:.4,900:.5},il=4096,al=new Map;function ol(e,t){al.set(e,t),al.size>il&&al.delete(al.keys().next().value)}var sl=0,cl=new WeakMap;function ll(e){let t=cl.get(e);return t===void 0&&(t=++sl,cl.set(e,t)),t}var ul=256,dl=new Map;function fl(e,t){let n=`${ll(e)}|${t}`,r=dl.get(n);if(r)return r;let{hhea:i,os2:a,post:o,head:s}=e,c=s.unitsPerEm,l=i.ascent,u=i.descent,d=c/t,f=(l+Math.abs(u))/d,p=l/d,m={sfnt:e,unitsPerEm:c,advanceHeight:f,baseline:p,ascender:l/d,descender:u/d,underlinePosition:(l-o.underlinePosition)/d,underlineThickness:o.underlineThickness/d,strikeoutPosition:(l-a.yStrikeoutPosition)/d,strikeoutSize:a.yStrikeoutSize/d,typoAscender:a.sTypoAscender/d,typoDescender:a.sTypoDescender/d,typoLineGap:a.sTypoLineGap/d,winAscent:a.usWinAscent/d,winDescent:a.usWinDescent/d,xHeight:a.version>1?a.sxHeight/d:0,capHeight:a.version>1?a.sCapHeight/d:0,centerDiviation:f/2-p,fontStyle:tl[a.fsSelection]??nl[s.macStyle]};return dl.size>=ul&&dl.delete(dl.keys().next().value),dl.set(n,m),m}var pl=class{content;index;parent;_path;_lazyPath;get path(){if(this._path)return this._path;let e=this._lazyPath;if(e){let{x:t,y:n}=e,r=e.tmpl.path.clone().setMeta(this);return r.applyTransform(e=>{e.x+=t,e.y+=n}),r.style=e.style,this._path=r,this._lazyPath=void 0,r}let t=new Mi().setMeta(this);return this._path=t,t}set path(e){this._path=e,this._lazyPath=void 0}inlineBox=new W;get lineBox(){let e=this.inlineBox,t=this.fontHeight;return this.isVertical?new W(e.left+(e.width-t)/2,e.top,t,e.height):new W(e.left,e.top+(e.height-t)/2,e.width,t)}glyphBox;advanceWidth=0;kerningBefore=0;_glyphIndex;_metrics;get advanceHeight(){return this._metrics?.advanceHeight??0}get baseline(){return this._metrics?.baseline??0}get ascender(){return this._metrics?.ascender??0}get descender(){return this._metrics?.descender??0}get underlinePosition(){return this._metrics?.underlinePosition??0}get underlineThickness(){return this._metrics?.underlineThickness??0}get strikeoutPosition(){return this._metrics?.strikeoutPosition??0}get strikeoutSize(){return this._metrics?.strikeoutSize??0}get typoAscender(){return this._metrics?.typoAscender??0}get typoDescender(){return this._metrics?.typoDescender??0}get typoLineGap(){return this._metrics?.typoLineGap??0}get winAscent(){return this._metrics?.winAscent??0}get winDescent(){return this._metrics?.winDescent??0}get xHeight(){return this._metrics?.xHeight??0}get capHeight(){return this._metrics?.capHeight??0}get centerDiviation(){return this._metrics?.centerDiviation??0}get fontStyle(){return this._metrics?.fontStyle}translateY(e){e&&(this.inlineBox.top+=e,this.glyphBox&&(this.glyphBox.top+=e),this._lazyPath?this._lazyPath.y+=e:this._path&&this._path.applyTransform(t=>{t.y+=e}))}get compatibleGlyphBox(){if(this.glyphBox)return this.glyphBox;let e=this.computedStyle.fontSize*.8,t=this.lineBox;return this.isVertical?new W(t.left+t.width/2-e/2,t.top,e,t.height):new W(t.left,t.top+t.height/2-e/2,t.width,e)}get center(){return this.compatibleGlyphBox.center}get computedFill(){return this.parent.computedFill}get computedOutline(){return this.parent.computedOutline}get computedStyle(){return this.parent.computedStyle}get isVertical(){return this.computedStyle.writingMode.includes(`vertical`)}get fontSize(){return this.computedStyle.fontSize}get fontHeight(){return this.fontSize*this.computedStyle.lineHeight}constructor(e,t,n){this.content=e,this.index=t,this.parent=n}_getFontSFNT(e){let t=this.computedStyle.fontFamily,n=e??Qc,r=(t?n.get(t):n.fallbackFont)?.getSFNT();return r?.textToGlyphIndexes(this.content).includes(0)&&(r=n.fallbackFont?.getSFNT()),r}updateGlyph(e=this._getFontSFNT()){if(!e)return this;let{content:t,computedStyle:n}=this,r=n.fontSize;return this._metrics=fl(e,r),this.advanceWidth=e.getAdvanceWidth(t,r),this._glyphIndex=e.textToGlyphIndexes(t)[0],this}computeKerningBefore(e){let t=this._metrics;if(!e||!t||e._metrics?.sfnt!==t.sfnt||e._glyphIndex===void 0||this._glyphIndex===void 0)return 0;let n=t.sfnt.getKerningValue(e._glyphIndex,this._glyphIndex);return n?n*this.computedStyle.fontSize/t.unitsPerEm:0}measureGlyph(e){return this.updateGlyph(this._getFontSFNT(e))}update(e){let t=this._getFontSFNT(e);if(!t)return this;this.updateGlyph(t);let n=this.computedStyle,r=n.fontStyle===`italic`&&this.fontStyle!==`italic`;if(!this.isVertical&&!r&&!n.textStrokeWidth)return this._updateFromCache(t,n),this;let{isVertical:i,content:a,baseline:o,inlineBox:s,ascender:c,descender:l,typoAscender:u,fontStyle:d,advanceWidth:f,advanceHeight:p}=this,{left:m,top:h}=s,g=m,_=h+o,v,y=new Mi().setMeta(this);if(i&&(g+=(p-f)/2,Math.abs(f-p)>.1&&(_-=(c-u)/(c+Math.abs(l))*p),v=void 0),i&&!$c.has(a)&&(a.codePointAt(0)<=256||el.has(a))){y.addCommands(t.getPathCommands(a,g,h+o-(p-f)/2,n.fontSize));let e={y:h-(p-f)/2+p/2,x:g+f/2};r&&this._italic(y,{x:e.x,y:h-(p-f)/2+o}),y.rotate(Math.PI/2,e)}else v===void 0?(y.addCommands(t.getPathCommands(a,g,_,n.fontSize)),r&&this._italic(y,i?{x:g+p/2,y:_}:void 0)):(y.addCommands(t.glyphs.get(v).getPathCommands(g,_,n.fontSize)),r&&this._italic(y,i?{x:g+f/2,y:h+u/(c+Math.abs(l))*p}:void 0));let b=n.fontWeight??400;return b in rl&&(b===700||b===`bold`)&&d!==`bold`&&y.bold(rl[b]*n.fontSize*.05),y.style=B({fill:n.color,fillRule:`nonzero`,stroke:n.textStrokeWidth?n.textStrokeColor:void 0,strokeWidth:n.textStrokeWidth?n.textStrokeWidth*n.fontSize*.03:void 0}),this.path=y,this.glyphBox=this.getGlyphBoundingBox(),this}_updateFromCache(e,t){let n=this.content,r=t.fontSize,i=this.inlineBox.left,a=this.inlineBox.top+this.baseline,o=t.fontWeight??400,s=o in rl&&(o===700||o===`bold`)&&this.fontStyle!==`bold`?rl[o]*r*.05:0,c=`${n}|${ll(e)}|${r}|${s}`,l=al.get(c);if(!l){let t=new Mi;t.addCommands(e.getPathCommands(n,0,0,r)),s&&t.bold(s);let i;if(t.curves[0]?.curves.length){let{min:e,max:n}=t.getMinMax(void 0,void 0,!0);i=new W(e.x,e.y,n.x-e.x,n.y-e.y)}l={path:t,glyphBox:i},ol(c,l)}this._path=void 0,this._lazyPath={tmpl:l,x:i,y:a,style:B({fill:t.color,fillRule:`nonzero`})},this.glyphBox=l.glyphBox?new W(l.glyphBox.left+i,l.glyphBox.top+a,l.glyphBox.width,l.glyphBox.height):void 0}_italic(e,t){e.skew(-.24,0,t||{y:this.inlineBox.top+this.baseline,x:this.inlineBox.left+this.inlineBox.width/2})}getGlyphMinMax(e,t,n){if(this._path===void 0&&this._lazyPath!==void 0){let n=this.glyphBox;if(!n)return;let r=new U(n.left,n.top),i=new U(n.left+n.width,n.top+n.height),a=e??new U(2**53-1,2**53-1),o=t??new U(-(2**53-1),-(2**53-1));return a.clampMin(r,i),o.clampMax(r,i),{min:a,max:o}}if(this.path.curves[0]?.curves.length)return this.path.getMinMax(e,t,n)}getGlyphBoundingBox(e){let t=this.getGlyphMinMax(void 0,void 0,e);if(!t)return;let{min:n,max:r}=t;return new W(n.x,n.y,r.x-n.x,r.y-n.y)}},ml=class{content;style;fill;outline;index;parent;inlineBox=new W;get computedContent(){let e=this.computedStyle;return e.textTransform===`uppercase`?this.content.toUpperCase():e.textTransform===`lowercase`?this.content.toLowerCase():this.content}constructor(e,t={},n,r,i,a){this.content=e,this.style=t,this.fill=n,this.outline=r,this.index=i,this.parent=a,this.update().initCharacters()}update(){this.computedStyle={...this.parent.computedStyle,...B(this.style)};let e=this.fill??this.parent.computedFill;this.computedFill=e?B(e):void 0;let t=this.outline??this.parent.computedOutline;return this.computedOutline=t?B(t):void 0,this}initCharacters(){let e=[],t=0;for(let n of this.computedContent)e.push(new pl(n,t++,this));return this.characters=e,this}},hl=class{style;index;parent;lineBox=new W;fragments=[];fill;outline;_layoutDirty=!0;_layoutTop=0;_layoutHeight=0;_layoutRight=0;_glyphBox;_layoutValid=!1;constructor(e,t,n){this.style=e,this.index=t,this.parent=n,this.update()}update(){this.computedStyle={...B(this.parent.computedStyle),...B(this.style)};let e=this.fill??this.parent.computedFill;this.computedFill=e?B(e):void 0;let t=this.outline??this.parent.computedOutline;return this.computedOutline=t?B(t):void 0,this}};function gl(e){return e}function _l(e,t,n){return e[`${t}${n}`]??e[t]??0}var vl=class{measure(e,t,n,r){let i=r??Qc;for(let t of e)if(t._layoutDirty)for(let e of t.fragments)for(let t of e.characters)t.measureGlyph(i);return t.writingMode.includes(`vertical`)||this._applyKerning(e),t.writingMode.includes(`vertical`)?this._measureVertical(e,t):this._measureHorizontal(e,t)}_rootPadding(e){return{top:_l(e,`padding`,`Top`),right:_l(e,`padding`,`Right`),bottom:_l(e,`padding`,`Bottom`),left:_l(e,`padding`,`Left`)}}_measureHorizontal(e,t){let n=this._rootPadding(t),r=typeof t.width==`number`,i=t.textWrap===`nowrap`,a=r&&!i?t.width-n.left-n.right:1/0,o=n.top,s=n.left;for(let t of e){let e=t.computedStyle,r=t.style,i=_l(r,`margin`,`Top`),c=_l(r,`margin`,`Bottom`),l=_l(r,`margin`,`Left`),u=_l(r,`margin`,`Right`),d=_l(r,`padding`,`Top`),f=_l(r,`padding`,`Bottom`),p=_l(r,`padding`,`Left`),m=_l(r,`padding`,`Right`),h=n.left+l+p,g=a===1/0?1/0:a-l-u-p-m;o+=i+d;let _=o,v=h;if(!t._layoutDirty){let e=_-t._layoutTop;if(e){for(let n of t.fragments){for(let t of n.characters)t.translateY(e);n.inlineBox.top+=e}t.lineBox.top+=e,t._glyphBox&&(t._glyphBox.top+=e)}t._layoutTop=_,v=t._layoutRight,o=_+t.lineBox.height,v>s&&(s=v),o+=f+c;continue}let y=this._breakLines(t,g),b=e.textAlign,x=e.textIndent??0,S=!1,C=!1;for(let t=0;t<y.length;t++){let n=y[t],r=t===0?x:0,i=e.fontSize*e.lineHeight,a=0,s=!0;for(let e of n)e.fontHeight>i&&(i=e.fontHeight),s||(a+=e.kerningBefore),s=!1,a+=this._advance(e);let c=h+r;if(g!==1/0){let e=g-r-a;b===`center`?c+=e/2:(b===`end`||b===`right`)&&(c+=e)}let l=!0;for(let e of n){S=!0,e.advanceWidth>0&&(C=!0),l||(c+=e.kerningBefore),l=!1;let t=e.advanceWidth,n=e.advanceHeight;e.inlineBox.left=c,e.inlineBox.top=o+(i-n)/2,e.inlineBox.width=t,e.inlineBox.height=n,c+=this._advance(e)}c>v&&(v=c),o+=i}v>s&&(s=v);for(let e of t.fragments)this._unionInto(e.inlineBox,e.characters.map(e=>e.inlineBox));t.lineBox.left=h,t.lineBox.top=_,t.lineBox.width=g===1/0?v-h:g,t.lineBox.height=o-_,t._layoutTop=_,t._layoutHeight=t.lineBox.height,t._layoutRight=v,t._glyphBox=void 0,t._layoutValid=!S||C,o+=f+c}let c=o+n.bottom,l=r?t.width:s+n.right,u=typeof t.height==`number`?t.height:c;if(typeof t.height==`number`){let n=u-c,r=t.verticalAlign,i=r===`middle`?n/2:r===`bottom`?n:0;i&&this._shiftAll(e,i)}return{paragraphs:e,boundingBox:new W(0,0,l,u)}}_measureVertical(e,t){let n=this._rootPadding(t),r=typeof t.height==`number`,i=t.textWrap===`nowrap`,a=r&&!i?t.height-n.top-n.bottom:1/0,o=[];for(let t of e){let e=t.computedStyle.fontSize*t.computedStyle.lineHeight;for(let n of this._breakLines(t,a)){let t=e;for(let e of n)e.fontHeight>t&&(t=e.fontHeight);o.push({chars:n,thickness:t})}}let s=o.reduce((e,t)=>e+t.thickness,0),c=typeof t.width==`number`,l=c?Math.max(t.width-n.left-n.right,s):s,u=n.left+l,d=n.top;for(let e of o){u-=e.thickness;let t=u,r=n.top;for(let n of e.chars){let i=n.advanceWidth,a=n.advanceHeight;n.inlineBox.top=r,n.inlineBox.height=i,n.inlineBox.width=a,n.inlineBox.left=t+(e.thickness-a)/2,r+=this._advance(n)}r>d&&(d=r)}for(let t of e){for(let e of t.fragments)this._unionInto(e.inlineBox,e.characters.map(e=>e.inlineBox));this._unionInto(t.lineBox,t.fragments.flatMap(e=>e.characters.map(e=>e.inlineBox)))}return{paragraphs:e,boundingBox:new W(0,0,c?t.width:l+n.left+n.right,r?t.height:d+n.bottom)}}_advance(e){return e.advanceWidth+(e.computedStyle.letterSpacing??0)}_breakLines(e,t){let n=[],r=[],i=0,a=()=>{n.push(r),r=[],i=0};for(let n of e.fragments)for(let e of n.characters){if(e.content===`
35
- `||e.content===`\r`){a();continue}let n=r.length>0?e.kerningBefore:0;t!==1/0&&r.length>0&&i+n+e.advanceWidth>t&&a(),r.length>0&&(i+=e.kerningBefore),r.push(e),i+=this._advance(e)}return a(),n}_applyKerning(e){for(let t of e){if(!t._layoutDirty)continue;let e;for(let n of t.fragments)for(let t of n.characters)t.kerningBefore=t.computeKerningBefore(e),e=t}}_unionInto(e,t){let n=t.filter(e=>e.width!==0||e.height!==0);if(!n.length)return;let r=W.from(...n);e.left=r.left,e.top=r.top,e.width=r.width,e.height=r.height}_shiftAll(e,t){for(let n of e){n.lineBox.top+=t;for(let e of n.fragments){e.inlineBox.top+=t;for(let n of e.characters)n.inlineBox.top+=t}}}dispose(){}};function yl(){let e=new Ni,t=Pi(),n=Fi(t);return{name:`background`,pathSet:e,context:{loader:t,parser:n},load:async e=>{let{backgroundImage:n}=e.computedStyle;n&&t.needsLoad(n)&&await t.load(n)},update:t=>{e.paths.length=0;let{computedStyle:r,lineBox:i,isVertical:a}=t,{backgroundImage:o,backgroundSize:s,backgroundColormap:c}=r;if(L(o))return;let{pathSet:l}=n.parse(o),u=l.getBoundingBox(!0)??new W,d,f,p,m;a?{x:f,y:d,width:m,height:p}=i:{x:d,y:f,width:p,height:m}=i;let h=zi(c??`none`),g=l.paths.map(e=>{let t=e.clone();return t.style.fill&&t.style.fill in h&&(t.style.fill=h[t.style.fill]),t.style.stroke&&t.style.stroke in h&&(t.style.stroke=h[t.style.stroke]),t}),_,v;if(s===`rigid`){_=t.fontSize*5/u.width,v=_;let e=new U;e.x=u.width-p/_,e.y=u.height-m/v,g.forEach(t=>{t.applyTransform(t=>{let n=t.x>u.left+u.width/2,r=t.y>u.top+u.height/2;n&&(t.x-=e.x),r&&(t.y-=e.y)})})}else _=p/u.width,v=m/u.height;let y=new jr;y.translate(-u.x,-u.y),y.scale(_,v),a&&(y.translate(-p/2,-m/2),y.rotate(Math.PI/2),y.translate(m/2,p/2)),y.translate(d,f),g.forEach(e=>{e.applyTransform(y)}),e.paths.push(...g)},renderOrder:-2,render:t=>{let{text:n,context:r}=t,{lineBox:i,computedStyle:a}=n;L(a.backgroundColor)||(r.fillStyle=a.backgroundColor,r.fillRect(...i.array)),e.paths.forEach(e=>{if(t.drawPath(e),n.debug){let t=new Ni([e]).getBoundingBox();t&&r.strokeRect(t.x,t.y,t.width,t.height)}}),n.paragraphs.forEach(e=>{let{lineBox:t,style:n}=e;L(n.backgroundColor)||(r.fillStyle=n.backgroundColor,r.fillRect(...t.array)),e.fragments.forEach(e=>{let{inlineBox:t,style:n}=e;L(n.backgroundColor)||(r.fillStyle=n.backgroundColor,r.fillRect(...t.array))})})}}}function bl(e,t){let{x:n,y:r}=t;if(e instanceof Di){let{p1:t,cp:i,p2:a}=e,o=n!==void 0&&Math.abs(Math.sign(t.x-n)+Math.sign(i.x-n)+Math.sign(a.x-n))===1,s=r!==void 0&&Math.abs(Math.sign(t.y-r)+Math.sign(i.y-r)+Math.sign(a.y-r))===1,c,l,u,d;if(o&&(c=t.x-2*i.x+a.x,l=2*(-t.x+i.x),u=t.x-n),s&&(c=t.y-2*i.y+a.y,l=2*(-t.y+i.y),u=t.y-r),(o||s)&&(d=l*l-4*c*u,d>0)){let e=Math.sqrt(d),n=[(-l+e)/2/c,(-l-e)/2/c].find(e=>e>0&&e<1);if(n){let e=U.lerp(t,i,n),r=U.lerp(i,a,n),o=U.lerp(e,r,n);return[new Di(t,e,o),new Di(o.clone(),r,a)]}}}else if(e instanceof wi){let{p1:t,cp1:i,cp2:a,p2:o}=e,{min:s,max:c}=e.getMinMax(),l=n!==void 0&&(s.x-n)*(c.x-n)<0,u=r!==void 0&&(s.y-r)*(c.y-r)<0;if(l||u){n=.5*t.x+.5*i.x,r=.5*t.y+.5*i.y;let e=new U(n,r);n=.25*t.x+.5*i.x+.25*a.x,r=.25*t.y+.5*i.y+.25*a.y;let s=new U(n,r);n=.125*t.x+.375*i.x+.375*a.x+.125*o.x,r=.125*t.y+.375*i.y+.375*a.y+.125*o.y;let c=new U(n,r);n=.25*i.x+.5*a.x+.25*o.x,r=.25*i.y+.5*a.y+.25*o.y;let l=new U(n,r);n=.5*a.x+.5*o.x,r=.5*a.y+.5*o.y;let u=new U(n,r);return[new wi(t,e,s,c),new wi(c.clone(),l,u,o)]}}else if(e instanceof Si){let{p1:t,p2:i}=e,a=n!==void 0&&(t.x-n)*(i.x-n)<0,o=r!==void 0&&(t.y-r)*(i.y-r)<0;if(a&&(r=t.y+(i.y-t.y)/(i.x-t.x)*(n-t.x)),o&&(n=t.x+(i.x-t.x)/(i.y-t.y)*(r-t.y)),a||o)return[new Si(t,new U(n,r)),new Si(new U(n,r),i)]}return[e]}var xl=class{get boundingBox(){return this.text.lineBox}get paragraphs(){return this.text.paragraphs}get isHorizontal(){return this.text.computedStyle.writingMode.startsWith(`horizontal`)}get baseWidth(){return this.isHorizontal?this.boundingBox.width:this.boundingBox.height}get baseHeight(){return this.isHorizontal?this.boundingBox.height:this.boundingBox.width}get characters(){return this.paragraphs.flatMap(e=>e.fragments.flatMap(e=>e.characters))}constructor({text:e,intensities:t=[],maxFontSize:n}){this.text=e,this.intensities=t.map(e=>e/100),this.lineHeight=this._maxFontSize()||n||100}_maxFontSize(){let e=0;return this.characters.forEach(t=>{t.glyphBox&&(e=Math.max(e,t.fontSize))}),e}_breakLine(){let e=!this.isHorizontal,{left:t,top:n,bottom:r,right:i}=this.boundingBox,a=.5*(t+i),o=.5*(n+r);this.characters.forEach(t=>{t.glyphBox&&t.path.curves.forEach(t=>{t.curves=t.curves.flatMap(t=>bl(t,e?{y:o}:{x:a}))})})}_makeTheJointSmooth(){this.characters.forEach(e=>{e.glyphBox&&e.path.getFlatCurves().forEach(e=>{if(e instanceof Di&&e.isFromLine){let{p1:t,cp:n,p2:r}=e;n.x=2*n.x-.5*(t.x+r.x),n.y=2*n.y-.5*(t.y+r.y)}})})}_lineToQuadraticBezier(){this.characters.forEach(e=>{e.glyphBox&&e.path.curves.forEach(e=>{e.curves=e.curves.map(e=>{if(e instanceof Si&&e.getLength()>this.lineHeight*.05){let{p1:t,p2:n}=e,r=new Di(t.clone(),new U(.5*(t.x+n.x),.5*(t.y+n.y)),n.clone());return r.isFromLine=!0,r}return e})})})}_transform(e,t,n){let r=this.text.plugins.get(`highlight`),i=n?.(),a=0,o=this.characters.filter(e=>e.glyphBox).length;this.paragraphs.forEach((n,s)=>{n.fragments.forEach((n,c)=>{n.characters.forEach((n,l)=>{if(!n.glyphBox)return;let u=t?.({paragraphIndex:s,fragmentIndex:c,characterIndex:l,character:n},i);if(n.path.getControlPointRefs().forEach(t=>{let[n,r]=e(t,u);t.set(n,r)}),t&&r?.pathSet?.paths){let t=r.pathSet.paths.length/o,n=a*t;for(let i=0;i<t;i++)r?.pathSet?.paths[n+i]?.getControlPointRefs().forEach(t=>{let[n,r]=e(t,u);t.set(n,r)});a++}})})}),this.paragraphs.forEach(e=>{e.fragments.forEach(e=>{e.characters.forEach(e=>{e.glyphBox=e.getGlyphBoundingBox(),e.glyphBox&&(e.inlineBox=e.glyphBox)})})}),t||r?.pathSet?.paths?.forEach(t=>{t.getControlPointRefs().forEach(t=>{let[n,r]=e(t);t.set(n,r)})})}},Sl=class extends xl{preset;constructor(e,t){super(e),this.preset=t}deform(){Math.hypot(...this.intensities)&&(this._lineToQuadraticBezier(),this._bend(),this._makeTheJointSmooth())}_bend(){let{boundingBox:e,baseWidth:t,baseHeight:n,preset:r}=this,i=this.lineHeight*2/Math.sin(this.intensities[0]*Math.PI*.5),a=r.vertical===void 0||r.vertical===`auto`?!this.isHorizontal:r.vertical,{left:o,top:s,width:c,height:l}=e,u=(a?l:c)/2/i,d={x:o+c/2,y:s+l/2},f,p={x:d.x,y:d.y};a?(f=0,p.x-=n/2/Math.tan(u)+Math.sign(u)*c/2):(f=1.5*Math.PI,p.y+=t/2/Math.tan(u)+Math.sign(u)*l/2);let m=r.transform({lineHeight:i,size:u,center:d,centerDist:p,centerDistAngle:f,width:c,height:l,isHorizontal:this.isHorizontal});this._transform(m)}},Cl=class{arcLengthDivisions=200;_cacheArcLengths;_needsUpdate=!1;getPointAt(e,t=new U){return this.getPoint(this.getUToTMapping(e),t)}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this._cacheArcLengths&&this._cacheArcLengths.length===e+1&&!this._needsUpdate)return this._cacheArcLengths;this._needsUpdate=!1;let t=[0],n=this.getPoint(0),r=0;for(let i=1;i<=e;i++){let a=this.getPoint(i/e);r+=a.distanceTo(n),t.push(r),n=a}return this._cacheArcLengths=t,t}getUToTMapping(e,t){let n=this.getLengths(),r=n.length,i=t===void 0?e*n[r-1]:t,a=0,o=r-1,s=0;for(;a<=o;){s=Math.floor(a+(o-a)/2);let e=n[s]-i;if(e<0)a=s+1;else if(e>0)o=s-1;else{o=s;break}}if(s=o,n[s]===i)return s/(r-1);let c=n[s],l=n[s+1]-c,u=(i-c)/l;return(s+u)/(r-1)}getTangent(e,t=new U){let n=1e-4,r=Math.max(0,e-n),i=Math.min(1,e+n);return t.copyFrom(this.getPoint(i).sub(this.getPoint(r)).normalize())}getNormal(e,t=new U){return this.getTangent(e,t),t.set(-t.y,t.x).normalize()}},wl=class extends Cl{curveT=0;getPoint(e,t=new U){return this.getCurve(e).getPoint(this.curveT,t)}getPointAt(e,t=new U){return this.getPoint(e,t)}getTangent(e,t=new U){return this.getCurve(e).getTangent(this.curveT,t)}getNormal(e,t=new U){return this.getCurve(e).getNormal(this.curveT,t)}},Tl=class extends Cl{start;end;constructor(e,t){super(),this.start=e,this.end=t}getPoint(e,t=new U){return e===1?t.copyFrom(this.end):t.copyFrom(this.end).sub(this.start).scale(e).add(this.start),t}getPointAt(e,t=new U){return this.getPoint(e,t)}getTangent(e,t=new U){return t.subVectors(this.end,this.start).normalize()}},El=class extends Cl{center;radius;start;end;constructor(e,t,n=0,r=Math.PI*2){super(),this.center=e,this.radius=t,this.start=n,this.end=r}getPoint(e,t=new U){return t.copyFrom(this.center).add(this.getNormal(e).scale(this.radius))}getTangent(e,t=new U){let{x:n,y:r}=this.getNormal(e);return t.set(-r,n)}getNormal(e,t=new U){let{start:n,end:r}=this,i=e*(r-n)+n-.5*Math.PI;return t.set(Math.cos(i),Math.sin(i))}},Dl=class extends Cl{center;radiusX;radiusY;rotation;startAngle;endAngle;clockwise;constructor(e=new U,t=1,n=1,r=0,i=0,a=Math.PI*2,o=!1){super(),this.center=e,this.radiusX=t,this.radiusY=n,this.rotation=r,this.startAngle=i,this.endAngle=a,this.clockwise=o}getPoint(e,t=new U){let n=Math.PI*2,r=this.endAngle-this.startAngle,i=Math.abs(r)<2**-52;for(;r<0;)r+=n;for(;r>n;)r-=n;r<2**-52&&(r=i?0:n),this.clockwise&&!i&&(r=r===n?-n:r-n);let a=this.startAngle+e*r,o=this.center.x+this.radiusX*Math.cos(a),s=this.center.y+this.radiusY*Math.sin(a);if(this.rotation!==0){let e=Math.cos(this.rotation),t=Math.sin(this.rotation),n=o-this.center.x,r=s-this.center.y;o=n*e-r*t+this.center.x,s=n*t+r*e+this.center.y}return t.set(o,s)}},Ol=class extends wl{center;size;start;end;curves=[];constructor(e,t,n=0,r=1){super(),this.center=e,this.size=t,this.start=n,this.end=r,this.update()}update(){let{x:e,y:t}=this.center,n=new U(e+.5*this.size,t-.5*this.size),r=new U(e-.5*this.size,t-.5*this.size),i=new U(e,t+.5*this.size),a=new El(n,Math.SQRT1_2*this.size,-.25*Math.PI,.75*Math.PI),o=new El(r,Math.SQRT1_2*this.size,-.75*Math.PI,.25*Math.PI),s=new El(i,.5*Math.SQRT1_2*this.size,.75*Math.PI,1.25*Math.PI),c=new U(e,t+this.size),l=new U(e+this.size,t),u=U.lerp(l,c,.75),d=new U(e-this.size,t),f=U.lerp(d,c,.75),p=new Tl(l,u),m=new Tl(f,d);return this.curves=[a,p,s,m,o],this}getCurve(e){let t=(e*(this.end-this.start)+this.start)%1;t<0&&(t+=1),t*=9*Math.PI/8+1.5;let n=.5*Math.PI,r;return t<n?(r=0,this.curveT=t/n):t<n+.75?(r=1,this.curveT=(t-n)/.75):t<5*Math.PI/8+.75?(r=2,this.curveT=(t-n-.75)/(Math.PI/8)):t<5*Math.PI/8+1.5?(r=3,this.curveT=(t-5*Math.PI/8-.75)/.75):(r=4,this.curveT=(t-5*Math.PI/8-1.5)/n),this.curves[r]}},kl=class extends wl{center;radius;number;start;end;curves=[];points=[];constructor(e,t=0,n=0,r=0,i=1){super(),this.center=e,this.radius=t,this.number=n,this.start=r,this.end=i,this.update()}update(){for(let e=0;e<this.number;e++){let t=e*2*Math.PI/this.number;t-=.5*Math.PI,this.points.push(new U(this.radius*Math.cos(t),this.radius*Math.sin(t)).add(this.center))}for(let e=0;e<this.number;e++)this.curves.push(new Tl(this.points[e],this.points[(e+1)%this.number]));return this}getCurve(e){let t=(e*(this.end-this.start)+this.start)%1;t<0&&(t+=1);let n=t*this.number,r=Math.floor(n);return this.curveT=n-r,this.curves[r]}},Al=class extends wl{center;rx;aspectRatio;start;end;curves=[];constructor(e,t,n=1,r=0,i=1){super(),this.center=e,this.rx=t,this.aspectRatio=n,this.start=r,this.end=i,this.update()}update(){let{x:e,y:t}=this.center,n=this.rx,r=this.rx/this.aspectRatio,i=[new U(e-n,t-r),new U(e+n,t-r),new U(e+n,t+r),new U(e-n,t+r)];for(let e=0;e<4;e++)this.curves.push(new Tl(i[e].clone(),i[(e+1)%4].clone()));return this}getCurve(e){let t=(e*(this.end-this.start)+this.start)%1;t<0&&(t+=1),t*=(1+this.aspectRatio)*2;let n;return t<this.aspectRatio?(n=0,this.curveT=t/this.aspectRatio):t<this.aspectRatio+1?(n=1,this.curveT=t-this.aspectRatio):t<2*this.aspectRatio+1?(n=2,this.curveT=(t-this.aspectRatio-1)/this.aspectRatio):(n=3,this.curveT=t-2*this.aspectRatio-1),this.curves[n]}},jl=class extends xl{preset;constructor(e,t){super(e),this.preset=t}deform(){if(!Math.hypot(...this.intensities))return;let{preset:e}=this;e.breakLine&&this._breakLine(),e.lineToQuad&&this._lineToQuadraticBezier();let[t=0,n=0]=this.intensities,r=this._createFFDControlPoints(e.hBlocks,e.vBlocks);e.build(r,{a:t,b:n,baseWidth:this.baseWidth,baseHeight:this.baseHeight,lineHeight:this.lineHeight,adjust:(e,t,n)=>this._adjustControlPoints(e,{x:t,y:n})}),e.bezier?(this._calculateForBezierFFD(r,e.hBlocks,e.vBlocks),this._makeTheJointSmooth()):this._calculateForLinearFFD(r,e.hBlocks,e.vBlocks)}_calculateForFFD(e,t,n,r){let{left:i,top:a,right:o,width:s,height:c}=this.boundingBox;this._transform(this.isHorizontal?o=>{let l=(o.x-i)/s,u=(o.y-a)/c,[d,f]=[0,0];for(let i=0;i<n+2;i++){let a=e(n,i,l);for(let n=0;n<r+2;n++){let o=e(r,n,u),s=t[i*(r+2)+n];d+=a*o*s.x,f+=a*o*s.y}}return[d,f]}:i=>{let l=(o-i.x)/s,u=(i.y-a)/c,[d,f]=[0,0];for(let i=0;i<n+2;i++){let a=e(n,i,u);for(let n=0;n<r+2;n++){let o=e(r,n,l),s=t[i*(r+2)+n];d+=a*o*s.x,f+=a*o*s.y}}return[d,f]})}_createFFDControlPoints(e,t){let{left:n,top:r,right:i,width:a,height:o}=this.boundingBox,s=[];if(this.isHorizontal){let i=a/(e+1),c=o/(t+1);for(let a=0;a<e+2;a++)for(let e=0;e<t+2;e++)s.push(new U(n+a*i,r+e*c))}else{let n=a/(t+1),c=o/(e+1);for(let a=0;a<e+2;a++)for(let e=0;e<t+2;e++)s.push(new U(i-e*n,r+a*c))}return s}_adjustControlPoints(e,t){this.isHorizontal?(e.x+=t.x,e.y+=t.y):(e.x-=t.y,e.y+=t.x)}_factorialForFFD(e){let t=1;for(let n=2;n<=e;n++)t*=n;return t}_combineForFFD(e,t){return this._factorialForFFD(e)/this._factorialForFFD(e-t)/this._factorialForFFD(t)}_calculateForBezierFFD(e,t,n){this._calculateForFFD((e,t,n)=>this._combineForFFD(e+1,t)*(1-n)**(e+1-t)*n**t,e,t,n)}_linearBasis(e,t,n){let r=t<n*e?t+1-n*e:n*e-t+1;return Math.max(0,r)}_calculateForLinearFFD(e,t,n){this._calculateForFFD((e,t,n)=>this._linearBasis(e+1,t,n),e,t,n)}},Ml=class extends xl{preset;constructor(e,t){super(e),this.preset=t}_context(){return{intensities:this.intensities,baseWidth:this.baseWidth,lineHeight:this.lineHeight,isHorizontal:this.isHorizontal,boundingBox:this.boundingBox}}deform(){if(!Math.hypot(...this.intensities))return;let{preset:e}=this,t=this._context();if(e.engine===`offset`)this._transform(e.point,e.perChar?n=>e.perChar(t,n):void 0);else{let n=e.followTangent??!0,{funcPerChar:r,funcPerPoint:i}=this._getPerCharAndPointFunc(n);this._transform(i,r,()=>{let{width:n,height:r,left:i,top:a}=this.boundingBox;return{width:n,height:r,left:i,top:a,curve:e.makeCurve(t),isHorizontal:this.isHorizontal,needExpandAlongNormal:e.expandAlongNormal??!1}})}}_getPerCharAndPointFunc(e=!1){let t,n;return e?(n=this._resetPointPos,t=this._calculateNewCenter):(n=this._resetPointPosWithoutRotate,t=this._calculateNewCenterWithoutRotate),{funcPerPoint:n,funcPerChar:t}}_calculateNewCenter({character:e},t){let{width:n,height:r,left:i,top:a,curve:o,isHorizontal:s,needExpandAlongNormal:c=!1}=t,{center:l,centerDiviation:u}=e,d=s?(l.x-i)/n:(l.y-a)/r,f=s?new U(0,l.y-a):new U(l.x-i,0);if(c){let e=o.getNormal(d);f.x+=e.x*-u,f.y+=e.y*-u}let p=o.getPointAt(d).add(f),m=o.getTangent(d);return{cos:m.x,sin:m.y,newCenter:p,center:l}}_calculateNewCenterWithoutRotate({character:e},t){let{width:n,height:r,left:i,top:a,curve:o,isHorizontal:s}=t,{center:c}=e,l=s?(c.x-i)/n:(c.y-a)/r,u=s?new U(0,c.y-a):new U(c.x-i,0);return{newCenter:o.getPointAt(l).add(u),center:c}}_resetPointPos(e,t){let{cos:n=1,sin:r=0,center:i,newCenter:a}=t,o=e.x-i.x,s=e.y-i.y;return[a.x+o*n-s*r,a.y+o*r+s*n]}_resetPointPosWithoutRotate(e,t){let{center:n,newCenter:r}=t;return[e.x-n.x+r.x,e.y-n.y+r.y]}},Nl=new Map;function Pl(e,t){Nl.set(e,t)}function Fl(e){Nl.delete(e)}function Il(){return[...Nl.keys()]}function Ll(){return gl({name:`deformation`,updateOrder:2,update:e=>{let t=e.deformation,n=t?.type;if(L(n)||!n)return;let r=Nl.get(n);if(!r)return;let i={text:e,intensities:t.intensities??r.defaultIntensities,maxFontSize:t.maxFontSize},a;switch(r.engine){case`ffd`:a=new jl(i,r);break;case`bend`:a=new Sl(i,r);break;case`curve`:case`offset`:a=new Ml(i,r);break}a.deform();let o=e.getGlyphBox(),s=o.left,c=o.top;if(s||c){let t=e.plugins.get(`highlight`);for(let t of e.characters)t.glyphBox&&(t.path.getControlPointRefs().forEach(e=>{e.set(e.x-s,e.y-c)}),t.glyphBox=t.getGlyphBoundingBox(),t.glyphBox&&(t.inlineBox=t.glyphBox));t?.pathSet?.paths?.forEach(e=>{e.getControlPointRefs().forEach(e=>{e.set(e.x-s,e.y-c)})}),o=e.getGlyphBox()}e.rawGlyphBox=o,e.glyphBox=o,e.lineBox=o}})}function Rl(e){let{highlight:t,highlightImage:n,highlightReferImage:r,highlightColormap:i,highlightLine:a,highlightSize:o,highlightThickness:s}=e;return{image:t?.image??n??`none`,referImage:t?.referImage??r??`none`,colormap:t?.colormap??i??`none`,line:t?.line??a??`none`,size:t?.size??o??`cover`,thickness:t?.thickness??s??`100%`}}function zl(){let e=new Ni,t=[],n=Pi(),r=Fi(n);return gl({name:`highlight`,pathSet:e,context:{clipRects:t,loader:n,parser:r},load:async e=>{let t=new Set;e.forEachCharacter(e=>{let{computedStyle:r}=e,{image:i,referImage:a}=Rl(r);i&&n.needsLoad(i)&&t.add(i),a&&n.needsLoad(a)&&t.add(a)}),await Promise.all(Array.from(t).map(e=>n.load(e)))},update:n=>{t.length=0,e.paths.length=0;let i=[],a,o;n.forEachCharacter(e=>{let{computedStyle:t}=e,n=Rl(t),{image:r,colormap:s,line:c,size:l,thickness:u}=n;if(L(r))a?.length&&(a=[],i.push(a));else{let{inlineBox:n,isVertical:d}=e,{fontSize:f}=t;(!o||Vi(o.image,r)&&Vi(o.colormap,s)&&Vi(o.line,c)&&Vi(o.size,l)&&Vi(o.thickness,u))&&a?.length&&(d?a[0].inlineBox.left===n.left:a[0].inlineBox.top===n.top)&&a[0].fontSize===f?a.push(e):(a=[],a.push(e),i.push(a))}o=n}),i=i.filter(e=>e.length);for(let n=0;n<i.length;n++){let a=i[n],o=a[0],s=W.from(...a.map(e=>e.compatibleGlyphBox));if(!s.height||!s.width)continue;let{computedStyle:c,isVertical:l,inlineBox:u,compatibleGlyphBox:d,strikeoutPosition:f,underlinePosition:p}=o,{fontSize:m}=c,{image:h,referImage:g,colormap:_,line:v,size:y,thickness:b}=Rl(c),x=Ri(b,{fontSize:m,total:s.width})/s.width,S=zi(_),{pathSet:C,dom:w}=r.parse(h),T=C.getBoundingBox(!0)??new W,E=m/T.width*2,D=new W().copy(s);l&&(D.width=s.height,D.height=s.width,D.left=s.left+s.width);let O=Math.floor(D.width),k=O;y!==`cover`&&(k=Ri(y,{fontSize:m,total:s.width})||O,D.width=k);let A=!L(g)&&L(v);if(A)T.copy(r.parse(g).pathSet.getBoundingBox(!0)??new W);else{let e;if(L(v))if(T.width/T.height>4){e=`underline`;let t=w.getAttribute(`viewBox`);if(t){let[n,r,i,a]=t.split(` `).map(e=>Number(e)),o=r+a/2;e=T.y<o&&T.y+T.height>o?`line-through`:T.y+T.height<o?`overline`:`underline`}}else e=`outline`;else e=v;switch(e){case`outline`:{let e=D.width*.2,t=D.height*.2;l?(D.x-=t/2,D.y-=e/2,D.x-=D.height):(D.x-=e/2,D.y-=t/2),D.width+=e,D.height+=t;break}case`overline`:D.height=T.height*E,l?D.x=u.left+u.width:D.y=u.top;break;case`line-through`:D.height=T.height*E,l?D.x=u.left+u.width-f+D.height/2:D.y=u.top+f-D.height/2;break;case`underline`:D.height=T.height*E,l?D.x=d.left+d.width-p:D.y=u.top+p;break}}let j=new jr;if(j.translate(-T.x,-T.y),j.scale(D.width/T.width,D.height/T.height),l){let e=D.width/2,t=D.height/2;A||j.translate(-e,-t),j.rotate(Math.PI/2),A||j.translate(t,e)}j.translate(D.x,D.y);for(let n=0;n<Math.ceil(O/k);n++){let r=j.clone();l?r.translate(0,n*D.width):r.translate(n*D.width,0),C.paths.forEach(n=>{let i=n.clone().applyTransform(r);i.style.strokeWidth&&(i.style.strokeWidth*=E*x),i.style.strokeMiterlimit&&(i.style.strokeMiterlimit*=E),i.style.strokeDashoffset&&(i.style.strokeDashoffset*=E),i.style.strokeDasharray&&(i.style.strokeDasharray=i.style.strokeDasharray.map(e=>e*E)),i.style.fill&&i.style.fill in S&&(i.style.fill=S[i.style.fill]),i.style.stroke&&i.style.stroke in S&&(i.style.stroke=S[i.style.stroke]),e.paths.push(i),O!==k&&(l?t[e.paths.length-1]=new W(s.left-s.width*2,s.top,s.width*4,s.height):t[e.paths.length-1]=new W(s.left,s.top-s.height*2,s.width,s.height*4))})}}},renderOrder:-1,getBoundingBox:()=>{let n=[];return e.paths.forEach((e,r)=>{let i=t[r],a=e.getBoundingBox();if(i){let e=Math.max(a.x,i.x),t=Math.max(a.y,i.y),n=Math.min(a.right,i.right),r=Math.min(a.bottom,i.bottom);a=new W(e,t,n-e,r-t)}n.push(a)}),n.length?W.from(...n):void 0},render:n=>{let{text:r,context:i}=n;e.paths.forEach((e,a)=>{if(n.drawPath(e,{clipRect:t[a]}),r.debug){let t=new Ni([e]).getBoundingBox();t&&i.strokeRect(t.x,t.y,t.width,t.height)}})}})}function Bl(e,t){return`<svg width="${e*2}" height="${e*2}" xmlns="http://www.w3.org/2000/svg">
35
+ `||e.content===`\r`){a();continue}let n=r.length>0?e.kerningBefore:0;t!==1/0&&r.length>0&&i+n+e.advanceWidth>t&&a(),r.length>0&&(i+=e.kerningBefore),r.push(e),i+=this._advance(e)}return a(),n}_applyKerning(e){for(let t of e){if(!t._layoutDirty)continue;let e;for(let n of t.fragments)for(let t of n.characters)t.kerningBefore=t.computeKerningBefore(e),e=t}}_unionInto(e,t){let n=t.filter(e=>e.width!==0||e.height!==0);if(!n.length)return;let r=W.from(...n);e.left=r.left,e.top=r.top,e.width=r.width,e.height=r.height}_shiftAll(e,t){for(let n of e){n.lineBox.top+=t;for(let e of n.fragments){e.inlineBox.top+=t;for(let n of e.characters)n.inlineBox.top+=t}}}dispose(){}};function yl(){let e=new Ni,t=Pi(),n=Fi(t);return{name:`background`,pathSet:e,context:{loader:t,parser:n},load:async e=>{let{backgroundImage:n}=e.computedStyle;n&&t.needsLoad(n)&&await t.load(n)},update:t=>{e.paths.length=0;let{computedStyle:r,lineBox:i,isVertical:a}=t,{backgroundImage:o,backgroundSize:s,backgroundColormap:c}=r;if(L(o))return;let{pathSet:l}=n.parse(o),u=l.getBoundingBox(!0)??new W,d,f,p,m;a?{x:f,y:d,width:m,height:p}=i:{x:d,y:f,width:p,height:m}=i;let h=zi(c??`none`),g=l.paths.map(e=>{let t=e.clone();return t.style.fill&&t.style.fill in h&&(t.style.fill=h[t.style.fill]),t.style.stroke&&t.style.stroke in h&&(t.style.stroke=h[t.style.stroke]),t}),_,v;if(s===`rigid`){_=t.fontSize*5/u.width,v=_;let e=new U;e.x=u.width-p/_,e.y=u.height-m/v,g.forEach(t=>{t.applyTransform(t=>{let n=t.x>u.left+u.width/2,r=t.y>u.top+u.height/2;n&&(t.x-=e.x),r&&(t.y-=e.y)})})}else _=p/u.width,v=m/u.height;let y=new jr;y.translate(-u.x,-u.y),y.scale(_,v),a&&(y.translate(-p/2,-m/2),y.rotate(Math.PI/2),y.translate(m/2,p/2)),y.translate(d,f),g.forEach(e=>{e.applyTransform(y)}),e.paths.push(...g)},renderOrder:-2,render:t=>{let{text:n,context:r}=t,{lineBox:i,computedStyle:a}=n;L(a.backgroundColor)||(r.fillStyle=a.backgroundColor,r.fillRect(...i.array)),e.paths.forEach(e=>{if(t.drawPath(e),n.debug){let t=new Ni([e]).getBoundingBox();t&&r.strokeRect(t.x,t.y,t.width,t.height)}}),n.paragraphs.forEach(e=>{let{lineBox:t,style:n}=e;L(n.backgroundColor)||(r.fillStyle=n.backgroundColor,r.fillRect(...t.array)),e.fragments.forEach(e=>{let{inlineBox:t,style:n}=e;L(n.backgroundColor)||(r.fillStyle=n.backgroundColor,r.fillRect(...t.array))})})}}}function bl(e,t){let{x:n,y:r}=t;if(e instanceof Di){let{p1:t,cp:i,p2:a}=e,o=n!==void 0&&Math.abs(Math.sign(t.x-n)+Math.sign(i.x-n)+Math.sign(a.x-n))===1,s=r!==void 0&&Math.abs(Math.sign(t.y-r)+Math.sign(i.y-r)+Math.sign(a.y-r))===1,c,l,u,d;if(o&&(c=t.x-2*i.x+a.x,l=2*(-t.x+i.x),u=t.x-n),s&&(c=t.y-2*i.y+a.y,l=2*(-t.y+i.y),u=t.y-r),(o||s)&&(d=l*l-4*c*u,d>0)){let e=Math.sqrt(d),n=[(-l+e)/2/c,(-l-e)/2/c].find(e=>e>0&&e<1);if(n){let e=U.lerp(t,i,n),r=U.lerp(i,a,n),o=U.lerp(e,r,n);return[new Di(t,e,o),new Di(o.clone(),r,a)]}}}else if(e instanceof wi){let{p1:t,cp1:i,cp2:a,p2:o}=e,{min:s,max:c}=e.getMinMax(),l=n!==void 0&&(s.x-n)*(c.x-n)<0,u=r!==void 0&&(s.y-r)*(c.y-r)<0;if(l||u){n=.5*t.x+.5*i.x,r=.5*t.y+.5*i.y;let e=new U(n,r);n=.25*t.x+.5*i.x+.25*a.x,r=.25*t.y+.5*i.y+.25*a.y;let s=new U(n,r);n=.125*t.x+.375*i.x+.375*a.x+.125*o.x,r=.125*t.y+.375*i.y+.375*a.y+.125*o.y;let c=new U(n,r);n=.25*i.x+.5*a.x+.25*o.x,r=.25*i.y+.5*a.y+.25*o.y;let l=new U(n,r);n=.5*a.x+.5*o.x,r=.5*a.y+.5*o.y;let u=new U(n,r);return[new wi(t,e,s,c),new wi(c.clone(),l,u,o)]}}else if(e instanceof Si){let{p1:t,p2:i}=e,a=n!==void 0&&(t.x-n)*(i.x-n)<0,o=r!==void 0&&(t.y-r)*(i.y-r)<0;if(a&&(r=t.y+(i.y-t.y)/(i.x-t.x)*(n-t.x)),o&&(n=t.x+(i.x-t.x)/(i.y-t.y)*(r-t.y)),a||o)return[new Si(t,new U(n,r)),new Si(new U(n,r),i)]}return[e]}var xl=class{get boundingBox(){return this.text.lineBox}get paragraphs(){return this.text.paragraphs}get isHorizontal(){return this.text.computedStyle.writingMode.startsWith(`horizontal`)}get baseWidth(){return this.isHorizontal?this.boundingBox.width:this.boundingBox.height}get baseHeight(){return this.isHorizontal?this.boundingBox.height:this.boundingBox.width}get characters(){return this.paragraphs.flatMap(e=>e.fragments.flatMap(e=>e.characters))}constructor({text:e,intensities:t=[],maxFontSize:n}){this.text=e,this.intensities=t.map(e=>e/100),this.lineHeight=this._maxFontSize()||n||100}_maxFontSize(){let e=0;return this.characters.forEach(t=>{t.glyphBox&&(e=Math.max(e,t.fontSize))}),e}_breakLine(){let e=!this.isHorizontal,{left:t,top:n,bottom:r,right:i}=this.boundingBox,a=.5*(t+i),o=.5*(n+r);this.characters.forEach(t=>{t.glyphBox&&t.path.curves.forEach(t=>{t.curves=t.curves.flatMap(t=>bl(t,e?{y:o}:{x:a}))})})}_makeTheJointSmooth(){this.characters.forEach(e=>{e.glyphBox&&e.path.getFlatCurves().forEach(e=>{if(e instanceof Di&&e.isFromLine){let{p1:t,cp:n,p2:r}=e;n.x=2*n.x-.5*(t.x+r.x),n.y=2*n.y-.5*(t.y+r.y)}})})}_lineToQuadraticBezier(){this.characters.forEach(e=>{e.glyphBox&&e.path.curves.forEach(e=>{e.curves=e.curves.map(e=>{if(e instanceof Si&&e.getLength()>this.lineHeight*.05){let{p1:t,p2:n}=e,r=new Di(t.clone(),new U(.5*(t.x+n.x),.5*(t.y+n.y)),n.clone());return r.isFromLine=!0,r}return e})})})}_transform(e,t,n){let r=this.text.plugins.get(`highlight`),i=n?.(),a=0,o=this.characters.filter(e=>e.glyphBox).length;this.paragraphs.forEach((n,s)=>{n.fragments.forEach((n,c)=>{n.characters.forEach((n,l)=>{if(!n.glyphBox)return;let u=t?.({paragraphIndex:s,fragmentIndex:c,characterIndex:l,character:n},i);if(n.path.getControlPointRefs().forEach(t=>{let[n,r]=e(t,u);t.set(n,r)}),t&&r?.pathSet?.paths){let t=r.pathSet.paths.length/o,n=a*t;for(let i=0;i<t;i++)r?.pathSet?.paths[n+i]?.getControlPointRefs().forEach(t=>{let[n,r]=e(t,u);t.set(n,r)});a++}})})}),this.paragraphs.forEach(e=>{e.fragments.forEach(e=>{e.characters.forEach(e=>{e.glyphBox=e.getGlyphBoundingBox()})})}),t||r?.pathSet?.paths?.forEach(t=>{t.getControlPointRefs().forEach(t=>{let[n,r]=e(t);t.set(n,r)})})}},Sl=class extends xl{preset;constructor(e,t){super(e),this.preset=t}deform(){Math.hypot(...this.intensities)&&(this._lineToQuadraticBezier(),this._bend(),this._makeTheJointSmooth())}_bend(){let{boundingBox:e,baseWidth:t,baseHeight:n,preset:r}=this,i=this.lineHeight*2/Math.sin(this.intensities[0]*Math.PI*.5),a=r.vertical===void 0||r.vertical===`auto`?!this.isHorizontal:r.vertical,{left:o,top:s,width:c,height:l}=e,u=(a?l:c)/2/i,d={x:o+c/2,y:s+l/2},f,p={x:d.x,y:d.y};a?(f=0,p.x-=n/2/Math.tan(u)+Math.sign(u)*c/2):(f=1.5*Math.PI,p.y+=t/2/Math.tan(u)+Math.sign(u)*l/2);let m=r.transform({lineHeight:i,size:u,center:d,centerDist:p,centerDistAngle:f,width:c,height:l,isHorizontal:this.isHorizontal});this._transform(m)}},Cl=class{arcLengthDivisions=200;_cacheArcLengths;_needsUpdate=!1;getPointAt(e,t=new U){return this.getPoint(this.getUToTMapping(e),t)}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this._cacheArcLengths&&this._cacheArcLengths.length===e+1&&!this._needsUpdate)return this._cacheArcLengths;this._needsUpdate=!1;let t=[0],n=this.getPoint(0),r=0;for(let i=1;i<=e;i++){let a=this.getPoint(i/e);r+=a.distanceTo(n),t.push(r),n=a}return this._cacheArcLengths=t,t}getUToTMapping(e,t){let n=this.getLengths(),r=n.length,i=t===void 0?e*n[r-1]:t,a=0,o=r-1,s=0;for(;a<=o;){s=Math.floor(a+(o-a)/2);let e=n[s]-i;if(e<0)a=s+1;else if(e>0)o=s-1;else{o=s;break}}if(s=o,n[s]===i)return s/(r-1);let c=n[s],l=n[s+1]-c,u=(i-c)/l;return(s+u)/(r-1)}getTangent(e,t=new U){let n=1e-4,r=Math.max(0,e-n),i=Math.min(1,e+n);return t.copyFrom(this.getPoint(i).sub(this.getPoint(r)).normalize())}getNormal(e,t=new U){return this.getTangent(e,t),t.set(-t.y,t.x).normalize()}},wl=class extends Cl{curveT=0;getPoint(e,t=new U){return this.getCurve(e).getPoint(this.curveT,t)}getPointAt(e,t=new U){return this.getPoint(e,t)}getTangent(e,t=new U){return this.getCurve(e).getTangent(this.curveT,t)}getNormal(e,t=new U){return this.getCurve(e).getNormal(this.curveT,t)}},Tl=class extends Cl{start;end;constructor(e,t){super(),this.start=e,this.end=t}getPoint(e,t=new U){return e===1?t.copyFrom(this.end):t.copyFrom(this.end).sub(this.start).scale(e).add(this.start),t}getPointAt(e,t=new U){return this.getPoint(e,t)}getTangent(e,t=new U){return t.subVectors(this.end,this.start).normalize()}},El=class extends Cl{center;radius;start;end;constructor(e,t,n=0,r=Math.PI*2){super(),this.center=e,this.radius=t,this.start=n,this.end=r}getPoint(e,t=new U){return t.copyFrom(this.center).add(this.getNormal(e).scale(this.radius))}getTangent(e,t=new U){let{x:n,y:r}=this.getNormal(e);return t.set(-r,n)}getNormal(e,t=new U){let{start:n,end:r}=this,i=e*(r-n)+n-.5*Math.PI;return t.set(Math.cos(i),Math.sin(i))}},Dl=class extends Cl{center;radiusX;radiusY;rotation;startAngle;endAngle;clockwise;constructor(e=new U,t=1,n=1,r=0,i=0,a=Math.PI*2,o=!1){super(),this.center=e,this.radiusX=t,this.radiusY=n,this.rotation=r,this.startAngle=i,this.endAngle=a,this.clockwise=o}getPoint(e,t=new U){let n=Math.PI*2,r=this.endAngle-this.startAngle,i=Math.abs(r)<2**-52;for(;r<0;)r+=n;for(;r>n;)r-=n;r<2**-52&&(r=i?0:n),this.clockwise&&!i&&(r=r===n?-n:r-n);let a=this.startAngle+e*r,o=this.center.x+this.radiusX*Math.cos(a),s=this.center.y+this.radiusY*Math.sin(a);if(this.rotation!==0){let e=Math.cos(this.rotation),t=Math.sin(this.rotation),n=o-this.center.x,r=s-this.center.y;o=n*e-r*t+this.center.x,s=n*t+r*e+this.center.y}return t.set(o,s)}},Ol=class extends wl{center;size;start;end;curves=[];constructor(e,t,n=0,r=1){super(),this.center=e,this.size=t,this.start=n,this.end=r,this.update()}update(){let{x:e,y:t}=this.center,n=new U(e+.5*this.size,t-.5*this.size),r=new U(e-.5*this.size,t-.5*this.size),i=new U(e,t+.5*this.size),a=new El(n,Math.SQRT1_2*this.size,-.25*Math.PI,.75*Math.PI),o=new El(r,Math.SQRT1_2*this.size,-.75*Math.PI,.25*Math.PI),s=new El(i,.5*Math.SQRT1_2*this.size,.75*Math.PI,1.25*Math.PI),c=new U(e,t+this.size),l=new U(e+this.size,t),u=U.lerp(l,c,.75),d=new U(e-this.size,t),f=U.lerp(d,c,.75),p=new Tl(l,u),m=new Tl(f,d);return this.curves=[a,p,s,m,o],this}getCurve(e){let t=(e*(this.end-this.start)+this.start)%1;t<0&&(t+=1),t*=9*Math.PI/8+1.5;let n=.5*Math.PI,r;return t<n?(r=0,this.curveT=t/n):t<n+.75?(r=1,this.curveT=(t-n)/.75):t<5*Math.PI/8+.75?(r=2,this.curveT=(t-n-.75)/(Math.PI/8)):t<5*Math.PI/8+1.5?(r=3,this.curveT=(t-5*Math.PI/8-.75)/.75):(r=4,this.curveT=(t-5*Math.PI/8-1.5)/n),this.curves[r]}},kl=class extends wl{center;radius;number;start;end;curves=[];points=[];constructor(e,t=0,n=0,r=0,i=1){super(),this.center=e,this.radius=t,this.number=n,this.start=r,this.end=i,this.update()}update(){for(let e=0;e<this.number;e++){let t=e*2*Math.PI/this.number;t-=.5*Math.PI,this.points.push(new U(this.radius*Math.cos(t),this.radius*Math.sin(t)).add(this.center))}for(let e=0;e<this.number;e++)this.curves.push(new Tl(this.points[e],this.points[(e+1)%this.number]));return this}getCurve(e){let t=(e*(this.end-this.start)+this.start)%1;t<0&&(t+=1);let n=t*this.number,r=Math.floor(n);return this.curveT=n-r,this.curves[r]}},Al=class extends wl{center;rx;aspectRatio;start;end;curves=[];constructor(e,t,n=1,r=0,i=1){super(),this.center=e,this.rx=t,this.aspectRatio=n,this.start=r,this.end=i,this.update()}update(){let{x:e,y:t}=this.center,n=this.rx,r=this.rx/this.aspectRatio,i=[new U(e-n,t-r),new U(e+n,t-r),new U(e+n,t+r),new U(e-n,t+r)];for(let e=0;e<4;e++)this.curves.push(new Tl(i[e].clone(),i[(e+1)%4].clone()));return this}getCurve(e){let t=(e*(this.end-this.start)+this.start)%1;t<0&&(t+=1),t*=(1+this.aspectRatio)*2;let n;return t<this.aspectRatio?(n=0,this.curveT=t/this.aspectRatio):t<this.aspectRatio+1?(n=1,this.curveT=t-this.aspectRatio):t<2*this.aspectRatio+1?(n=2,this.curveT=(t-this.aspectRatio-1)/this.aspectRatio):(n=3,this.curveT=t-2*this.aspectRatio-1),this.curves[n]}},jl=class extends xl{preset;constructor(e,t){super(e),this.preset=t}deform(){if(!Math.hypot(...this.intensities))return;let{preset:e}=this;e.breakLine&&this._breakLine(),e.lineToQuad&&this._lineToQuadraticBezier();let[t=0,n=0]=this.intensities,r=this._createFFDControlPoints(e.hBlocks,e.vBlocks);e.build(r,{a:t,b:n,baseWidth:this.baseWidth,baseHeight:this.baseHeight,lineHeight:this.lineHeight,adjust:(e,t,n)=>this._adjustControlPoints(e,{x:t,y:n})}),e.bezier?(this._calculateForBezierFFD(r,e.hBlocks,e.vBlocks),this._makeTheJointSmooth()):this._calculateForLinearFFD(r,e.hBlocks,e.vBlocks)}_calculateForFFD(e,t,n,r){let{left:i,top:a,right:o,width:s,height:c}=this.boundingBox;this._transform(this.isHorizontal?o=>{let l=(o.x-i)/s,u=(o.y-a)/c,[d,f]=[0,0];for(let i=0;i<n+2;i++){let a=e(n,i,l);for(let n=0;n<r+2;n++){let o=e(r,n,u),s=t[i*(r+2)+n];d+=a*o*s.x,f+=a*o*s.y}}return[d,f]}:i=>{let l=(o-i.x)/s,u=(i.y-a)/c,[d,f]=[0,0];for(let i=0;i<n+2;i++){let a=e(n,i,u);for(let n=0;n<r+2;n++){let o=e(r,n,l),s=t[i*(r+2)+n];d+=a*o*s.x,f+=a*o*s.y}}return[d,f]})}_createFFDControlPoints(e,t){let{left:n,top:r,right:i,width:a,height:o}=this.boundingBox,s=[];if(this.isHorizontal){let i=a/(e+1),c=o/(t+1);for(let a=0;a<e+2;a++)for(let e=0;e<t+2;e++)s.push(new U(n+a*i,r+e*c))}else{let n=a/(t+1),c=o/(e+1);for(let a=0;a<e+2;a++)for(let e=0;e<t+2;e++)s.push(new U(i-e*n,r+a*c))}return s}_adjustControlPoints(e,t){this.isHorizontal?(e.x+=t.x,e.y+=t.y):(e.x-=t.y,e.y+=t.x)}_factorialForFFD(e){let t=1;for(let n=2;n<=e;n++)t*=n;return t}_combineForFFD(e,t){return this._factorialForFFD(e)/this._factorialForFFD(e-t)/this._factorialForFFD(t)}_calculateForBezierFFD(e,t,n){this._calculateForFFD((e,t,n)=>this._combineForFFD(e+1,t)*(1-n)**(e+1-t)*n**t,e,t,n)}_linearBasis(e,t,n){let r=t<n*e?t+1-n*e:n*e-t+1;return Math.max(0,r)}_calculateForLinearFFD(e,t,n){this._calculateForFFD((e,t,n)=>this._linearBasis(e+1,t,n),e,t,n)}},Ml=class extends xl{preset;constructor(e,t){super(e),this.preset=t}_context(){return{intensities:this.intensities,baseWidth:this.baseWidth,lineHeight:this.lineHeight,isHorizontal:this.isHorizontal,boundingBox:this.boundingBox}}deform(){if(!Math.hypot(...this.intensities))return;let{preset:e}=this,t=this._context();if(e.engine===`offset`)this._transform(e.point,e.perChar?n=>e.perChar(t,n):void 0);else{let n=e.followTangent??!0,{funcPerChar:r,funcPerPoint:i}=this._getPerCharAndPointFunc(n);this._transform(i,r,()=>{let{width:n,height:r,left:i,top:a}=this.boundingBox;return{width:n,height:r,left:i,top:a,curve:e.makeCurve(t),isHorizontal:this.isHorizontal,needExpandAlongNormal:e.expandAlongNormal??!1}})}}_getPerCharAndPointFunc(e=!1){let t,n;return e?(n=this._resetPointPos,t=this._calculateNewCenter):(n=this._resetPointPosWithoutRotate,t=this._calculateNewCenterWithoutRotate),{funcPerPoint:n,funcPerChar:t}}_calculateNewCenter({character:e},t){let{width:n,height:r,left:i,top:a,curve:o,isHorizontal:s,needExpandAlongNormal:c=!1}=t,{center:l,centerDiviation:u}=e,d=s?(l.x-i)/n:(l.y-a)/r,f=s?new U(0,l.y-a):new U(l.x-i,0);if(c){let e=o.getNormal(d);f.x+=e.x*-u,f.y+=e.y*-u}let p=o.getPointAt(d).add(f),m=o.getTangent(d);return{cos:m.x,sin:m.y,newCenter:p,center:l}}_calculateNewCenterWithoutRotate({character:e},t){let{width:n,height:r,left:i,top:a,curve:o,isHorizontal:s}=t,{center:c}=e,l=s?(c.x-i)/n:(c.y-a)/r,u=s?new U(0,c.y-a):new U(c.x-i,0);return{newCenter:o.getPointAt(l).add(u),center:c}}_resetPointPos(e,t){let{cos:n=1,sin:r=0,center:i,newCenter:a}=t,o=e.x-i.x,s=e.y-i.y;return[a.x+o*n-s*r,a.y+o*r+s*n]}_resetPointPosWithoutRotate(e,t){let{center:n,newCenter:r}=t;return[e.x-n.x+r.x,e.y-n.y+r.y]}},Nl=new Map;function Pl(e,t){Nl.set(e,t)}function Fl(e){Nl.delete(e)}function Il(){return[...Nl.keys()]}function Ll(){return gl({name:`deformation`,updateOrder:2,update:e=>{let t=e.deformation,n=t?.type;if(L(n)||!n)return;let r=Nl.get(n);if(!r)return;let i={text:e,intensities:t.intensities??r.defaultIntensities,maxFontSize:t.maxFontSize},a;switch(r.engine){case`ffd`:a=new jl(i,r);break;case`bend`:a=new Sl(i,r);break;case`curve`:case`offset`:a=new Ml(i,r);break}e.forEachCharacter(t=>t.update(e.fonts)),a.deform();let o=e.getGlyphBox(),s=o.left,c=o.top;if(s||c){let t=e.plugins.get(`highlight`);for(let t of e.characters)t.glyphBox&&=(t.path.getControlPointRefs().forEach(e=>{e.set(e.x-s,e.y-c)}),t.getGlyphBoundingBox());t?.pathSet?.paths?.forEach(e=>{e.getControlPointRefs().forEach(e=>{e.set(e.x-s,e.y-c)})}),o=e.getGlyphBox()}e.rawGlyphBox=o,e.glyphBox=o,e.lineBox=o}})}function Rl(e){let{highlight:t,highlightImage:n,highlightReferImage:r,highlightColormap:i,highlightLine:a,highlightSize:o,highlightThickness:s}=e;return{image:t?.image??n??`none`,referImage:t?.referImage??r??`none`,colormap:t?.colormap??i??`none`,line:t?.line??a??`none`,size:t?.size??o??`cover`,thickness:t?.thickness??s??`100%`}}function zl(){let e=new Ni,t=[],n=Pi(),r=Fi(n);return gl({name:`highlight`,pathSet:e,context:{clipRects:t,loader:n,parser:r},load:async e=>{let t=new Set;e.forEachCharacter(e=>{let{computedStyle:r}=e,{image:i,referImage:a}=Rl(r);i&&n.needsLoad(i)&&t.add(i),a&&n.needsLoad(a)&&t.add(a)}),await Promise.all(Array.from(t).map(e=>n.load(e)))},update:n=>{t.length=0,e.paths.length=0;let i=[],a,o;n.forEachCharacter(e=>{let{computedStyle:t}=e,n=Rl(t),{image:r,colormap:s,line:c,size:l,thickness:u}=n;if(L(r))a?.length&&(a=[],i.push(a));else{let{inlineBox:n,isVertical:d}=e,{fontSize:f}=t;(!o||Vi(o.image,r)&&Vi(o.colormap,s)&&Vi(o.line,c)&&Vi(o.size,l)&&Vi(o.thickness,u))&&a?.length&&(d?a[0].inlineBox.left===n.left:a[0].inlineBox.top===n.top)&&a[0].fontSize===f?a.push(e):(a=[],a.push(e),i.push(a))}o=n}),i=i.filter(e=>e.length);for(let n=0;n<i.length;n++){let a=i[n],o=a[0],s=W.from(...a.map(e=>e.compatibleGlyphBox));if(!s.height||!s.width)continue;let{computedStyle:c,isVertical:l,inlineBox:u,compatibleGlyphBox:d,strikeoutPosition:f,underlinePosition:p}=o,{fontSize:m}=c,{image:h,referImage:g,colormap:_,line:v,size:y,thickness:b}=Rl(c),x=Ri(b,{fontSize:m,total:s.width})/s.width,S=zi(_),{pathSet:C,dom:w}=r.parse(h),T=C.getBoundingBox(!0)??new W,E=m/T.width*2,D=new W().copy(s);l&&(D.width=s.height,D.height=s.width,D.left=s.left+s.width);let O=Math.floor(D.width),k=O;y!==`cover`&&(k=Ri(y,{fontSize:m,total:s.width})||O,D.width=k);let A=!L(g)&&L(v);if(A)T.copy(r.parse(g).pathSet.getBoundingBox(!0)??new W);else{let e;if(L(v))if(T.width/T.height>4){e=`underline`;let t=w.getAttribute(`viewBox`);if(t){let[n,r,i,a]=t.split(` `).map(e=>Number(e)),o=r+a/2;e=T.y<o&&T.y+T.height>o?`line-through`:T.y+T.height<o?`overline`:`underline`}}else e=`outline`;else e=v;switch(e){case`outline`:{let e=D.width*.2,t=D.height*.2;l?(D.x-=t/2,D.y-=e/2,D.x-=D.height):(D.x-=e/2,D.y-=t/2),D.width+=e,D.height+=t;break}case`overline`:D.height=T.height*E,l?D.x=u.left+u.width:D.y=u.top;break;case`line-through`:D.height=T.height*E,l?D.x=u.left+u.width-f+D.height/2:D.y=u.top+f-D.height/2;break;case`underline`:D.height=T.height*E,l?D.x=d.left+d.width-p:D.y=u.top+p;break}}let j=new jr;if(j.translate(-T.x,-T.y),j.scale(D.width/T.width,D.height/T.height),l){let e=D.width/2,t=D.height/2;A||j.translate(-e,-t),j.rotate(Math.PI/2),A||j.translate(t,e)}j.translate(D.x,D.y);for(let n=0;n<Math.ceil(O/k);n++){let r=j.clone();l?r.translate(0,n*D.width):r.translate(n*D.width,0),C.paths.forEach(n=>{let i=n.clone().applyTransform(r);i.style.strokeWidth&&(i.style.strokeWidth*=E*x),i.style.strokeMiterlimit&&(i.style.strokeMiterlimit*=E),i.style.strokeDashoffset&&(i.style.strokeDashoffset*=E),i.style.strokeDasharray&&(i.style.strokeDasharray=i.style.strokeDasharray.map(e=>e*E)),i.style.fill&&i.style.fill in S&&(i.style.fill=S[i.style.fill]),i.style.stroke&&i.style.stroke in S&&(i.style.stroke=S[i.style.stroke]),e.paths.push(i),O!==k&&(l?t[e.paths.length-1]=new W(s.left-s.width*2,s.top,s.width*4,s.height):t[e.paths.length-1]=new W(s.left,s.top-s.height*2,s.width,s.height*4))})}}},renderOrder:-1,getBoundingBox:()=>{let n=[];return e.paths.forEach((e,r)=>{let i=t[r],a=e.getBoundingBox();if(i){let e=Math.max(a.x,i.x),t=Math.max(a.y,i.y),n=Math.min(a.right,i.right),r=Math.min(a.bottom,i.bottom);a=new W(e,t,n-e,r-t)}n.push(a)}),n.length?W.from(...n):void 0},render:n=>{let{text:r,context:i}=n;e.paths.forEach((e,a)=>{if(n.drawPath(e,{clipRect:t[a]}),r.debug){let t=new Ni([e]).getBoundingBox();t&&i.strokeRect(t.x,t.y,t.width,t.height)}})}})}function Bl(e,t){return`<svg width="${e*2}" height="${e*2}" xmlns="http://www.w3.org/2000/svg">
36
36
  <circle cx="${e}" cy="${e}" r="${e}" fill="${t}" />
37
- </svg>`}function Vl(){let e=new Ni;return gl({name:`listStyle`,pathSet:e,update:t=>{e.paths.length=0;let{paragraphs:n,isVertical:r,fontSize:i}=t,a=i*.45;n.forEach(t=>{let{computedStyle:n}=t,{color:o,listStyleImage:s,listStyleColormap:c,listStyleSize:l,listStyleType:u}=n,d=zi(c),f=l,p;if(!L(s))p=s;else if(!L(u)){let e=i*.38/2;switch(f=f===`cover`?e*2:f,u){case`disc`:p=Bl(e,String(o));break}}if(!p)return;let m=ci(p),h=m.getBoundingBox()??new W,g=t.fragments[0]?.characters[0];if(!g)return;let{inlineBox:_}=g,v=f===`cover`?1:Ri(f,{total:i,fontSize:i})/i,y=new jr;if(r){let e=i/h.height*v;y.translate(-h.left,-h.top).rotate(-Math.PI/2).scale(e,e).translate(_.left+(_.width-h.height*e)/2,_.top-a)}else{let e=i/h.height*v;y.translate(-h.left,-h.top).scale(e,e).translate(_.left-h.width*e-a,_.top+(_.height-h.height*e)/2)}e.paths.push(...m.paths.map(e=>{let t=e.clone();return t.applyTransform(y),t.style.fill&&t.style.fill in d&&(t.style.fill=d[t.style.fill]),t.style.stroke&&t.style.stroke in d&&(t.style.stroke=d[t.style.stroke]),t}))})}})}function Hl(){return{name:`outline`}}function Ul(){let e=new Ni,t=[],n=[];return Object.defineProperty(e,"paths",{configurable:!0,enumerable:!0,get(){return n===null&&(n=t.map(e=>e.path)),n},set(e){n=e}}),gl({name:`render`,pathSet:e,update:r=>{let i=[],{paragraphs:a}=r;a.forEach(e=>{e.fragments.forEach(e=>{e.characters.forEach(e=>{i.push(e)})})}),t=i,n=null,e._lazyCount=i.length},getBoundingBox:e=>{let{characters:t,computedEffects:n,fontSize:r}=e,i=[];return n.forEach(n=>{let a=Ii(e,n);t.forEach(e=>{if(!e.glyphBox)return;let t=e.glyphBox.clone(),o=a.apply({x:t.left,y:t.top}),s=a.apply({x:t.right,y:t.top}),c=a.apply({x:t.right,y:t.bottom}),l=a.apply({x:t.left,y:t.bottom}),u=Math.min(o.x,s.x,c.x,l.x),d=Math.min(o.y,s.y,c.y,l.y),f=Math.max(o.x,s.x,c.x,l.x),p=Math.max(o.y,s.y,c.y,l.y);if(t.left=u,t.top=d,t.width=f-u,t.height=p-d,n.shadow?.enabled){let e=(n.shadow.offsetX??0)*r,i=(n.shadow.offsetY??0)*r,a=(n.shadow.blur??0)*r,o=t.left+Math.min(0,e-a),s=t.top+Math.min(0,i-a),c=t.left+t.width+Math.max(0,e+a),l=t.top+t.height+Math.max(0,i+a);t.left=o,t.top=s,t.width=c-o,t.height=l-s}if(n.outline?.enabled){let e=Math.max(.1,n.outline.width??0);t.left-=e,t.top-=e,t.width+=e*2,t.height+=e*2}i.push(t)})}),i.length?W.from(...i):void 0},render:e=>{let{text:t,context:n}=e,{paragraphs:r,glyphBox:i,computedEffects:a}=t;r.length&&(a.length?a.forEach(r=>{if(e.uploadColor(i,r),n.save(),e.transformEffect(r),r.shadow?.enabled){let n={...r,shadow:{...r.shadow,enabled:!1}};e.drawWithShadow(r.shadow,()=>{t.forEachCharacter(t=>{e.drawCharacter(t,n)})})}else t.forEachCharacter(t=>{e.drawCharacter(t,r)});n.restore()}):r.forEach(t=>{t.fragments.forEach(t=>{t.characters.forEach(t=>{e.drawCharacter(t)})})}),t.debug&&r.forEach(e=>{n.strokeRect(e.lineBox.x,e.lineBox.y,e.lineBox.width,e.lineBox.height)}))}})}function Wl(){let e=new Ni;return gl({name:`textDecoration`,pathSet:e,update:t=>{e.paths.length=0;let n=[],r,i;t.forEachCharacter(e=>{let{computedStyle:t,isVertical:a,inlineBox:o,underlinePosition:s,underlineThickness:c,strikeoutPosition:l,strikeoutSize:u}=e,{color:d,textDecoration:f,writingMode:p}=t;if(L(f))i=void 0;else{let m=!1;if(i?.textDecoration===f&&i?.writingMode===p&&i?.color===d&&(a?r[0].inlineBox.left===o.left:r[0].inlineBox.top===o.top))switch(f){case`underline`:r[0].underlinePosition===s&&r[0].underlineThickness===c&&(m=!0);break;case`line-through`:r[0].strikeoutPosition===l&&r[0].strikeoutSize===u&&(m=!0);break}m?r.push(e):(r=[],r.push(e),n.push(r)),i=t}}),n.forEach(t=>{let{computedStyle:n,isVertical:r,underlinePosition:i,underlineThickness:a,strikeoutPosition:o,strikeoutSize:s}=t[0],{color:c,textDecoration:l}=n,{left:u,top:d,width:f,height:p}=W.from(...t.map(e=>e.inlineBox)),m=r?u+f:d,h=r?-1:1,g=0;switch(l){case`overline`:g=a*2;break;case`underline`:m+=h*i,g=a*2;break;case`line-through`:m+=h*o,g=s*2;break}m-=g;let _;_=r?new Mi([{type:`M`,x:m,y:d},{type:`L`,x:m,y:d+p},{type:`L`,x:m+g,y:d+p},{type:`L`,x:m+g,y:d},{type:`Z`}],{fill:c}):new Mi([{type:`M`,x:u,y:m},{type:`L`,x:u+f,y:m},{type:`L`,x:u+f,y:m+g},{type:`L`,x:u,y:m+g},{type:`Z`}],{fill:c}),e.paths.push(_)})},render:t=>{let{text:n,context:r}=t,{computedEffects:i}=n;i.length?i.forEach(n=>{r.save(),t.transformEffect(n),e.paths.forEach(e=>{t.drawPath(e,t.effectToPathStyle(n))}),r.restore()}):e.paths.forEach(e=>{t.drawPath(e)})}})}function Gl(e,t){if(typeof Reflect==`object`&&typeof Reflect.metadata==`function`)return Reflect.metadata(e,t)}function Kl(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var ql=pt(),Jl=class extends he{needsUpdate=!0;computedStyle={...ql};computedFill;computedOutline;computedEffects=[];inlineBox=new W;lineBox=new W;rawGlyphBox=new W;glyphBox=new W;pathBox=new W;boundingBox=new W;measurer=new vl;plugins=new Map;pathSets=[];_paragraphs=[];_cachedCharacters;incrementalLayout=!0;_prevParagraphs=[];_prevContentKeys=[];_prevStyleKey=``;_prevFonts;_prevFontsSet=!1;_pendingContentKeys=[];_pendingStyleKey=``;_pluginsByUpdateOrder=[];_pluginsByRenderOrder=[];_renderer;_rendererCtx;get paragraphs(){return this._paragraphs}set paragraphs(e){this._paragraphs=e,this._cachedCharacters=void 0}get fontSize(){return this.computedStyle.fontSize}get defaultFamily(){return this.fonts?.fallbackFont?.familySet.values().next().value??`sans-serif`}get isVertical(){return this.computedStyle.writingMode.includes(`vertical`)}get characters(){if(this._cachedCharacters)return this._cachedCharacters;let e=[],t=this._paragraphs;for(let n=0;n<t.length;n++){let r=t[n].fragments;for(let t=0;t<r.length;t++){let n=r[t].characters;for(let t=0;t<n.length;t++)e.push(n[t])}}return this._cachedCharacters=e,e}constructor(e={}){super(),this.set(e)}set(e={}){let{content:t,effects:n,style:r,measureDom:i,fonts:a,fill:o,outline:s,deformation:c}=St(e);this.debug=e.debug??!1,this.content=t,this.effects=n,this.style=r,this.measureDom=i,this.fonts=a,this.fill=o,this.outline=s,this.deformation=c,this.use(yl()).use(Hl()).use(Vl()).use(Wl()).use(zl()).use(Ul()).use(Ll()),(e.plugins??[]).forEach(e=>{this.use(e)}),this._update()}use(e){return this.plugins.set(e.name,e),this._resortPlugins(),this}_resortPlugins(){this._pluginsByUpdateOrder=[...this.plugins.values()].sort((e,t)=>(e.updateOrder??0)-(t.updateOrder??0)),this._pluginsByRenderOrder=[...this.plugins.values()].sort((e,t)=>(e.renderOrder??0)-(t.renderOrder??0))}forEachCharacter(e){let t=this._paragraphs;for(let n=0;n<t.length;n++){let r=t[n].fragments;for(let t=0;t<r.length;t++){let i=r[t].characters;for(let r=0;r<i.length;r++)e(i[r],{paragraphIndex:n,fragmentIndex:t,characterIndex:r})}}return this}async load(){this._update();let[e]=await Promise.all([this._decodeFonts(),...Array.from(this.plugins.values()).map(e=>e.load?.(this))]);e>0&&(this._prevParagraphs=[])}async _decodeFonts(){let e=this.fonts??Qc,t=new Set;for(let n of this.characters){let r=n.computedStyle.fontFamily;r&&t.add(e.get(r))}return t.add(e.fallbackFont),(await Promise.all(Array.from(t,async e=>{let t=e?.getFont();return t&&typeof t.createSFNTAsync==`function`&&!t._sfnt?(t._sfnt=await t.createSFNTAsync(),1):0}))).reduce((e,t)=>e+t,0)}_normalizeComputedStyle(e){let t=e;for(let e in ql){let n=ql[e];if(typeof n!=`number`)continue;let r=t[e];if(typeof r==`number`)Number.isFinite(r)||(t[e]=n);else{let i=Number.parseFloat(r);t[e]=Number.isFinite(i)?i:n}}return e}_buildParagraph(e,t){let{fragments:n,fill:r,outline:i,...a}=e,o=new hl(a,t,this);return o.fill=r,o.outline=i,n.forEach((e,t)=>{let{content:n,fill:r,outline:i,...a}=e;n!==void 0&&o.fragments.push(new ml(n,a,r,i,t,o))}),o}_canReuseLayout(e){if(!this.incrementalLayout||!this._prevParagraphs.length||e!==this._prevStyleKey||!this._prevFontsSet||this.fonts!==this._prevFonts)return!1;let t=this.computedStyle;return!(t.writingMode.includes(`vertical`)||typeof t.height==`number`&&(t.verticalAlign===`middle`||t.verticalAlign===`bottom`))}_update(){this.computedStyle=this._normalizeComputedStyle({...ql,...this.style}),this.computedFill=this.fill?{...this.fill}:void 0,this.computedOutline=this.outline?{...this.outline}:void 0,this.computedEffects=this.effects?.map(e=>e)??[];let e=JSON.stringify([this.style,this.fill,this.outline,this.effects,this.deformation]),t=this._canReuseLayout(e),n=this.content,r=Array.from({length:n.length}),i=Array.from({length:n.length});for(let e=0;e<n.length;e++){let a=JSON.stringify(n[e]);r[e]=a;let o=this._prevParagraphs[e];if(t&&o&&o._layoutValid&&this._prevContentKeys[e]===a)o._layoutDirty=!1,i[e]=o;else{let t=this._buildParagraph(n[e],e);t._layoutDirty=!0,i[e]=t}}return this.paragraphs=i,this._pendingContentKeys=r,this._pendingStyleKey=e,this}measure(e=this.measureDom){let t={paragraphs:this.paragraphs,inlineBox:this.inlineBox,lineBox:this.lineBox,rawGlyphBox:this.rawGlyphBox,glyphBox:this.glyphBox,pathBox:this.pathBox,boundingBox:this.boundingBox};this._update();let n=this.measurer.measure(this.paragraphs,this.computedStyle,e,this.fonts);this.paragraphs=n.paragraphs,this.lineBox=n.boundingBox;let r=this.paragraphs;for(let e=0;e<r.length;e++){let t=r[e];if(t._layoutDirty)for(let e of t.fragments){let t=e.characters;for(let e=0;e<t.length;e++)t[e].update(this.fonts)}}let i=this._computeGlyphBox();this.rawGlyphBox=i,this.glyphBox=i,this._prevParagraphs=this.paragraphs,this._prevContentKeys=this._pendingContentKeys,this._prevStyleKey=this._pendingStyleKey,this._prevFonts=this.fonts,this._prevFontsSet=!0;let a=this._pluginsByUpdateOrder;for(let e=0;e<a.length;e++)a[e].update?.(this);let o=this._pluginsByRenderOrder;this.pathSets.length=0;for(let e=0;e<o.length;e++){let t=o[e].pathSet,n=t?._lazyCount??t?.paths.length;t&&n&&this.pathSets.push(t)}this._updateInlineBox()._updatePathBox()._updateBoundingBox();for(let e in t){let r=this[e];this[e]=t[e],n[e]=r}return this.emit(`measure`,{text:this,result:n}),n}getGlyphBox(){let e=U.MAX,t=U.MIN,n=this.characters;for(let r=0;r<n.length;r++){let i=n[r];if(i.getGlyphMinMax(e,t))continue;let{left:a,top:o,width:s,height:c}=i.inlineBox,l=new U(a,o),u=new U(a+s,o+c);e.clampMin(l,u),t.clampMax(l,u)}return e.x===-(2**53-1)||e.y===-(2**53-1)||t.x===2**53-1||t.y===2**53-1?new W(0,0,0,0):new W(e.x,e.y,t.x-e.x,t.y-e.y)}_paragraphGlyphBox(e){let t=U.MAX,n=U.MIN,r=e.fragments;for(let e=0;e<r.length;e++){let i=r[e].characters;for(let e=0;e<i.length;e++){let r=i[e];if(r.getGlyphMinMax(t,n))continue;let{left:a,top:o,width:s,height:c}=r.inlineBox;t.clampMin(new U(a,o),new U(a+s,o+c)),n.clampMax(new U(a,o),new U(a+s,o+c))}}if(!(!Number.isFinite(t.x)||!Number.isFinite(t.y)||!Number.isFinite(n.x)||!Number.isFinite(n.y)))return new W(t.x,t.y,n.x-t.x,n.y-t.y)}_computeGlyphBox(){let e=this.paragraphs,t=[];for(let n=0;n<e.length;n++){let r=e[n],i=r._glyphBox;(r._layoutDirty||!i)&&(i=this._paragraphGlyphBox(r),r._glyphBox=i),i&&t.push(i)}return t.length?W.from(...t):new W(0,0,0,0)}_updateInlineBox(){let e=[],t=this._paragraphs;for(let n=0;n<t.length;n++){let r=t[n].fragments;for(let t=0;t<r.length;t++)e.push(r[t].inlineBox)}return this.inlineBox=W.from(...e),this}_updatePathBox(){let e=[this.glyphBox];for(let t of this.plugins.values()){let n=t.getBoundingBox?t.getBoundingBox(this):t.pathSet?.getBoundingBox();n&&e.push(n)}return this.pathBox=W.from(...e),this}_updateBoundingBox(){return this.boundingBox=W.from(this.rawGlyphBox,this.lineBox,this.pathBox),this}requestUpdate(){return this.needsUpdate=!0,this}update(e=this.measureDom){return this.needsUpdate=!1,Object.assign(this,this.measure(e)),this.emit(`update`,{text:this}),this}_getRenderer(e){return(!this._renderer||this._rendererCtx!==e)&&(this._renderer=new Hi(this,e),this._rendererCtx=e),this._renderer}render(e){let{view:t,pixelRatio:n=2}=e,r=t.getContext(`2d`);if(!r)return;this.needsUpdate&&this.update();let i=this._getRenderer(r);i.pixelRatio=n,i.region=e.region,i.setup();let a=this._pluginsByRenderOrder;for(let e=0;e<a.length;e++){let t=a[e];if(t.render)t.render(i);else if(t.pathSet){let e=t.pathSet.paths;for(let t=0;t<e.length;t++)i.drawPath(e[t])}}this.emit(`render`,{text:this,view:t,pixelRatio:n}),e.onContext?.(r)}dispose(){this.measurer.dispose?.(),this._renderer=void 0,this._rendererCtx=void 0}toString(){return this.content.flatMap(e=>e.fragments.map(e=>e.content)).join(``)}};Kl([me({internal:!0}),Gl(`design:type`,Boolean)],Jl.prototype,`debug`,void 0),Kl([me(),Gl(`design:type`,Object)],Jl.prototype,`content`,void 0),Kl([me(),Gl(`design:type`,Object)],Jl.prototype,`style`,void 0),Kl([me(),Gl(`design:type`,Object)],Jl.prototype,`effects`,void 0),Kl([me(),Gl(`design:type`,Object)],Jl.prototype,`fill`,void 0),Kl([me(),Gl(`design:type`,Object)],Jl.prototype,`outline`,void 0),Kl([me(),Gl(`design:type`,Object)],Jl.prototype,`deformation`,void 0),Kl([me({internal:!0}),Gl(`design:type`,typeof HTMLElement>`u`?Object:HTMLElement)],Jl.prototype,`measureDom`,void 0),Kl([me({internal:!0}),Gl(`design:type`,Object)],Jl.prototype,`fonts`,void 0);function Yl(e,t){let n=new Jl(e);return t?n.load().then(()=>n.measure()):n.measure()}function Xl(e,t){let n=new Jl(e);return t?n.load().then(()=>n.render(e)):n.render(e)}e.Canvas2DRenderer=Hi,e.Character=pl,e.CircleCurve=El,e.EllipseCurve=Dl,e.Fragment=ml,e.HeartCurve=Ol,e.Measurer=vl,e.Paragraph=hl,e.PolygonCurve=kl,e.RectangularCurve=Al,e.Text=Jl,e.backgroundPlugin=yl,e.createSvgLoader=Pi,e.createSvgParser=Fi,e.defineDeformation=Pl,e.definePlugin=gl,e.deformationPlugin=Ll,e.getDeformationNames=Il,e.getEffectTransform2D=Ii,e.getHighlightStyle=Rl,e.highlightPlugin=zl,e.isEqualObject=Bi,e.isEqualValue=Vi,e.listStylePlugin=Vl,e.measureText=Yl,e.outlinePlugin=Hl,e.parseColormap=zi,e.parseTransformOrigin=Li,e.parseValueNumber=Ri,e.removeDeformation=Fl,e.renderPlugin=Ul,e.renderText=Xl,e.textDecorationPlugin=Wl,e.textDefaultStyle=ql});
37
+ </svg>`}function Vl(){let e=new Ni;return gl({name:`listStyle`,pathSet:e,update:t=>{e.paths.length=0;let{paragraphs:n,isVertical:r,fontSize:i}=t,a=i*.45;n.forEach(t=>{let{computedStyle:n}=t,{color:o,listStyleImage:s,listStyleColormap:c,listStyleSize:l,listStyleType:u}=n,d=zi(c),f=l,p;if(!L(s))p=s;else if(!L(u)){let e=i*.38/2;switch(f=f===`cover`?e*2:f,u){case`disc`:p=Bl(e,String(o));break}}if(!p)return;let m=ci(p),h=m.getBoundingBox()??new W,g=t.fragments[0]?.characters[0];if(!g)return;let{inlineBox:_}=g,v=f===`cover`?1:Ri(f,{total:i,fontSize:i})/i,y=new jr;if(r){let e=i/h.height*v;y.translate(-h.left,-h.top).rotate(-Math.PI/2).scale(e,e).translate(_.left+(_.width-h.height*e)/2,_.top-a)}else{let e=i/h.height*v;y.translate(-h.left,-h.top).scale(e,e).translate(_.left-h.width*e-a,_.top+(_.height-h.height*e)/2)}e.paths.push(...m.paths.map(e=>{let t=e.clone();return t.applyTransform(y),t.style.fill&&t.style.fill in d&&(t.style.fill=d[t.style.fill]),t.style.stroke&&t.style.stroke in d&&(t.style.stroke=d[t.style.stroke]),t}))})}})}function Hl(){return{name:`outline`}}function Ul(){let e=new Ni,t=[],n=[];return Object.defineProperty(e,"paths",{configurable:!0,enumerable:!0,get(){return n===null&&(n=t.map(e=>e.path)),n},set(e){n=e}}),gl({name:`render`,pathSet:e,update:r=>{let i=[],{paragraphs:a}=r;a.forEach(e=>{e.fragments.forEach(e=>{e.characters.forEach(e=>{i.push(e)})})}),t=i,n=null,e._lazyCount=i.length},getBoundingBox:e=>{let{characters:t,computedEffects:n,fontSize:r}=e,i=[];return n.forEach(n=>{let a=Ii(e,n);t.forEach(e=>{if(!e.glyphBox)return;let t=e.glyphBox.clone(),o=a.apply({x:t.left,y:t.top}),s=a.apply({x:t.right,y:t.top}),c=a.apply({x:t.right,y:t.bottom}),l=a.apply({x:t.left,y:t.bottom}),u=Math.min(o.x,s.x,c.x,l.x),d=Math.min(o.y,s.y,c.y,l.y),f=Math.max(o.x,s.x,c.x,l.x),p=Math.max(o.y,s.y,c.y,l.y);if(t.left=u,t.top=d,t.width=f-u,t.height=p-d,n.shadow?.enabled){let e=(n.shadow.offsetX??0)*r,i=(n.shadow.offsetY??0)*r,a=(n.shadow.blur??0)*r,o=t.left+Math.min(0,e-a),s=t.top+Math.min(0,i-a),c=t.left+t.width+Math.max(0,e+a),l=t.top+t.height+Math.max(0,i+a);t.left=o,t.top=s,t.width=c-o,t.height=l-s}if(n.outline?.enabled){let e=Math.max(.1,n.outline.width??0);t.left-=e,t.top-=e,t.width+=e*2,t.height+=e*2}i.push(t)})}),i.length?W.from(...i):void 0},render:e=>{let{text:t,context:n}=e,{paragraphs:r,glyphBox:i,computedEffects:a}=t;r.length&&(a.length?a.forEach(r=>{if(e.uploadColor(i,r),n.save(),e.transformEffect(r),r.shadow?.enabled){let n={...r,shadow:{...r.shadow,enabled:!1}};e.drawWithShadow(r.shadow,()=>{t.forEachCharacter(t=>{e.drawCharacter(t,n)})})}else t.forEachCharacter(t=>{e.drawCharacter(t,r)});n.restore()}):r.forEach(t=>{t.fragments.forEach(t=>{t.characters.forEach(t=>{e.drawCharacter(t)})})}),t.debug&&r.forEach(e=>{n.strokeRect(e.lineBox.x,e.lineBox.y,e.lineBox.width,e.lineBox.height)}))}})}function Wl(){let e=new Ni;return gl({name:`textDecoration`,pathSet:e,update:t=>{e.paths.length=0;let n=[],r,i;t.forEachCharacter(e=>{let{computedStyle:t,isVertical:a,inlineBox:o,underlinePosition:s,underlineThickness:c,strikeoutPosition:l,strikeoutSize:u}=e,{color:d,textDecoration:f,writingMode:p}=t;if(L(f))i=void 0;else{let m=!1;if(i?.textDecoration===f&&i?.writingMode===p&&i?.color===d&&(a?r[0].inlineBox.left===o.left:r[0].inlineBox.top===o.top))switch(f){case`underline`:r[0].underlinePosition===s&&r[0].underlineThickness===c&&(m=!0);break;case`line-through`:r[0].strikeoutPosition===l&&r[0].strikeoutSize===u&&(m=!0);break}m?r.push(e):(r=[],r.push(e),n.push(r)),i=t}}),n.forEach(t=>{let{computedStyle:n,isVertical:r,underlinePosition:i,underlineThickness:a,strikeoutPosition:o,strikeoutSize:s}=t[0],{color:c,textDecoration:l}=n,{left:u,top:d,width:f,height:p}=W.from(...t.map(e=>e.inlineBox)),m=r?u+f:d,h=r?-1:1,g=0;switch(l){case`overline`:g=a*2;break;case`underline`:m+=h*i,g=a*2;break;case`line-through`:m+=h*o,g=s*2;break}m-=g;let _;_=r?new Mi([{type:`M`,x:m,y:d},{type:`L`,x:m,y:d+p},{type:`L`,x:m+g,y:d+p},{type:`L`,x:m+g,y:d},{type:`Z`}],{fill:c}):new Mi([{type:`M`,x:u,y:m},{type:`L`,x:u+f,y:m},{type:`L`,x:u+f,y:m+g},{type:`L`,x:u,y:m+g},{type:`Z`}],{fill:c}),e.paths.push(_)})},render:t=>{let{text:n,context:r}=t,{computedEffects:i}=n;i.length?i.forEach(n=>{r.save(),t.transformEffect(n),e.paths.forEach(e=>{t.drawPath(e,t.effectToPathStyle(n))}),r.restore()}):e.paths.forEach(e=>{t.drawPath(e)})}})}function Gl(e,t){if(typeof Reflect==`object`&&typeof Reflect.metadata==`function`)return Reflect.metadata(e,t)}function Kl(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var ql=pt(),Jl=class extends he{needsUpdate=!0;computedStyle={...ql};computedFill;computedOutline;computedEffects=[];inlineBox=new W;lineBox=new W;rawGlyphBox=new W;glyphBox=new W;pathBox=new W;boundingBox=new W;measurer=new vl;plugins=new Map;pathSets=[];_paragraphs=[];_cachedCharacters;incrementalLayout=!0;_prevParagraphs=[];_prevContentKeys=[];_prevStyleKey=``;_prevFonts;_prevFontsSet=!1;_prevFontSig=``;_pendingFontSig=``;_pendingContentKeys=[];_pendingStyleKey=``;_pluginsByUpdateOrder=[];_pluginsByRenderOrder=[];_renderer;_rendererCtx;get paragraphs(){return this._paragraphs}set paragraphs(e){this._paragraphs=e,this._cachedCharacters=void 0}get fontSize(){return this.computedStyle.fontSize}get defaultFamily(){return this.fonts?.fallbackFont?.familySet.values().next().value??`sans-serif`}get isVertical(){return this.computedStyle.writingMode.includes(`vertical`)}get characters(){if(this._cachedCharacters)return this._cachedCharacters;let e=[],t=this._paragraphs;for(let n=0;n<t.length;n++){let r=t[n].fragments;for(let t=0;t<r.length;t++){let n=r[t].characters;for(let t=0;t<n.length;t++)e.push(n[t])}}return this._cachedCharacters=e,e}constructor(e={}){super(),this.set(e)}set(e={}){let{content:t,effects:n,style:r,measureDom:i,fonts:a,fill:o,outline:s,deformation:c}=St(e);this.debug=e.debug??!1,this.content=t,this.effects=n,this.style=r,this.measureDom=i,this.fonts=a,this.fill=o,this.outline=s,this.deformation=c,this.use(yl()).use(Hl()).use(Vl()).use(Wl()).use(zl()).use(Ul()).use(Ll()),(e.plugins??[]).forEach(e=>{this.use(e)}),this._update()}use(e){return this.plugins.set(e.name,e),this._resortPlugins(),this}_resortPlugins(){this._pluginsByUpdateOrder=[...this.plugins.values()].sort((e,t)=>(e.updateOrder??0)-(t.updateOrder??0)),this._pluginsByRenderOrder=[...this.plugins.values()].sort((e,t)=>(e.renderOrder??0)-(t.renderOrder??0))}forEachCharacter(e){let t=this._paragraphs;for(let n=0;n<t.length;n++){let r=t[n].fragments;for(let t=0;t<r.length;t++){let i=r[t].characters;for(let r=0;r<i.length;r++)e(i[r],{paragraphIndex:n,fragmentIndex:t,characterIndex:r})}}return this}async load(){this._update();let[e]=await Promise.all([this._decodeFonts(),...Array.from(this.plugins.values()).map(e=>e.load?.(this))]);e>0&&(this._prevParagraphs=[])}async _decodeFonts(){let e=this.fonts??Qc,t=new Set;for(let n of this.characters){let r=n.computedStyle.fontFamily;r&&t.add(e.get(r))}return t.add(e.fallbackFont),(await Promise.all(Array.from(t,async e=>{let t=e?.getFont();return t&&typeof t.createSFNTAsync==`function`&&!t._sfnt?(t._sfnt=await t.createSFNTAsync(),1):0}))).reduce((e,t)=>e+t,0)}_normalizeComputedStyle(e){let t=e;for(let e in ql){let n=ql[e];if(typeof n!=`number`)continue;let r=t[e];if(typeof r==`number`)Number.isFinite(r)||(t[e]=n);else{let i=Number.parseFloat(r);t[e]=Number.isFinite(i)?i:n}}return e}_buildParagraph(e,t){let{fragments:n,fill:r,outline:i,...a}=e,o=new hl(a,t,this);return o.fill=r,o.outline=i,n.forEach((e,t)=>{let{content:n,fill:r,outline:i,...a}=e;n!==void 0&&o.fragments.push(new ml(n,a,r,i,t,o))}),o}_computeFontSig(){let e=this.fonts;if(!e?.get)return``;let t=new Set,n=this.computedStyle?.fontFamily;n&&t.add(String(n));for(let e of this.content){let n=e?.fontFamily;n&&t.add(String(n));let r=e?.fragments;if(Array.isArray(r))for(let e of r){let n=e?.fontFamily;n&&t.add(String(n))}}let r=``;for(let n of t)r+=`${n}#${e.get(n)?.src??``};`;return r}_canReuseLayout(e,t){if(!this.incrementalLayout||!this._prevParagraphs.length||e!==this._prevStyleKey||!this._prevFontsSet||this.fonts!==this._prevFonts||t!==this._prevFontSig)return!1;let n=this.computedStyle;return!(n.writingMode.includes(`vertical`)||typeof n.height==`number`&&(n.verticalAlign===`middle`||n.verticalAlign===`bottom`))}_update(){this.computedStyle=this._normalizeComputedStyle({...ql,...this.style}),this.computedFill=this.fill?{...this.fill}:void 0,this.computedOutline=this.outline?{...this.outline}:void 0,this.computedEffects=this.effects?.map(e=>e)??[];let e=JSON.stringify([this.style,this.fill,this.outline,this.effects,this.deformation]),t=this._computeFontSig();this._pendingFontSig=t;let n=this._canReuseLayout(e,t),r=this.content,i=Array.from({length:r.length}),a=Array.from({length:r.length});for(let e=0;e<r.length;e++){let t=JSON.stringify(r[e]);i[e]=t;let o=this._prevParagraphs[e];if(n&&o&&o._layoutValid&&this._prevContentKeys[e]===t)o._layoutDirty=!1,a[e]=o;else{let t=this._buildParagraph(r[e],e);t._layoutDirty=!0,a[e]=t}}return this.paragraphs=a,this._pendingContentKeys=i,this._pendingStyleKey=e,this}measure(e=this.measureDom){let t={paragraphs:this.paragraphs,inlineBox:this.inlineBox,lineBox:this.lineBox,rawGlyphBox:this.rawGlyphBox,glyphBox:this.glyphBox,pathBox:this.pathBox,boundingBox:this.boundingBox};this._update();let n=this.measurer.measure(this.paragraphs,this.computedStyle,e,this.fonts);this.paragraphs=n.paragraphs,this.lineBox=n.boundingBox;let r=this.paragraphs;for(let e=0;e<r.length;e++){let t=r[e];if(t._layoutDirty)for(let e of t.fragments){let t=e.characters;for(let e=0;e<t.length;e++)t[e].update(this.fonts)}}let i=this._computeGlyphBox();this.rawGlyphBox=i,this.glyphBox=i,this._prevParagraphs=this.paragraphs,this._prevContentKeys=this._pendingContentKeys,this._prevStyleKey=this._pendingStyleKey,this._prevFonts=this.fonts,this._prevFontsSet=!0,this._prevFontSig=this._pendingFontSig;let a=this._pluginsByUpdateOrder;for(let e=0;e<a.length;e++)a[e].update?.(this);let o=this._pluginsByRenderOrder;this.pathSets.length=0;for(let e=0;e<o.length;e++){let t=o[e].pathSet,n=t?._lazyCount??t?.paths.length;t&&n&&this.pathSets.push(t)}this._updateInlineBox()._updatePathBox()._updateBoundingBox();for(let e in t){let r=this[e];this[e]=t[e],n[e]=r}return this.emit(`measure`,{text:this,result:n}),n}getGlyphBox(){let e=U.MAX,t=U.MIN,n=this.characters;for(let r=0;r<n.length;r++){let i=n[r];if(i.getGlyphMinMax(e,t))continue;let{left:a,top:o,width:s,height:c}=i.inlineBox,l=new U(a,o),u=new U(a+s,o+c);e.clampMin(l,u),t.clampMax(l,u)}return e.x===-(2**53-1)||e.y===-(2**53-1)||t.x===2**53-1||t.y===2**53-1?new W(0,0,0,0):new W(e.x,e.y,t.x-e.x,t.y-e.y)}_paragraphGlyphBox(e){let t=U.MAX,n=U.MIN,r=e.fragments;for(let e=0;e<r.length;e++){let i=r[e].characters;for(let e=0;e<i.length;e++){let r=i[e];if(r.getGlyphMinMax(t,n))continue;let{left:a,top:o,width:s,height:c}=r.inlineBox;t.clampMin(new U(a,o),new U(a+s,o+c)),n.clampMax(new U(a,o),new U(a+s,o+c))}}if(!(!Number.isFinite(t.x)||!Number.isFinite(t.y)||!Number.isFinite(n.x)||!Number.isFinite(n.y)))return new W(t.x,t.y,n.x-t.x,n.y-t.y)}_computeGlyphBox(){let e=this.paragraphs,t=[];for(let n=0;n<e.length;n++){let r=e[n],i=r._glyphBox;(r._layoutDirty||!i)&&(i=this._paragraphGlyphBox(r),r._glyphBox=i),i&&t.push(i)}return t.length?W.from(...t):new W(0,0,0,0)}_updateInlineBox(){let e=[],t=this._paragraphs;for(let n=0;n<t.length;n++){let r=t[n].fragments;for(let t=0;t<r.length;t++)e.push(r[t].inlineBox)}return this.inlineBox=W.from(...e),this}_updatePathBox(){let e=[this.glyphBox];for(let t of this.plugins.values()){let n=t.getBoundingBox?t.getBoundingBox(this):t.pathSet?.getBoundingBox();n&&e.push(n)}return this.pathBox=W.from(...e),this}_updateBoundingBox(){return this.boundingBox=W.from(this.rawGlyphBox,this.lineBox,this.pathBox),this}requestUpdate(){return this.needsUpdate=!0,this}update(e=this.measureDom){return this.needsUpdate=!1,Object.assign(this,this.measure(e)),this.emit(`update`,{text:this}),this}_getRenderer(e){return(!this._renderer||this._rendererCtx!==e)&&(this._renderer=new Hi(this,e),this._rendererCtx=e),this._renderer}render(e){let{view:t,pixelRatio:n=2}=e,r=t.getContext(`2d`);if(!r)return;this.needsUpdate&&this.update();let i=this._getRenderer(r);i.pixelRatio=n,i.region=e.region,i.setup();let a=this._pluginsByRenderOrder;for(let e=0;e<a.length;e++){let t=a[e];if(t.render)t.render(i);else if(t.pathSet){let e=t.pathSet.paths;for(let t=0;t<e.length;t++)i.drawPath(e[t])}}this.emit(`render`,{text:this,view:t,pixelRatio:n}),e.onContext?.(r)}dispose(){this.measurer.dispose?.(),this._renderer=void 0,this._rendererCtx=void 0}toString(){return this.content.flatMap(e=>e.fragments.map(e=>e.content)).join(``)}};Kl([me({internal:!0}),Gl(`design:type`,Boolean)],Jl.prototype,`debug`,void 0),Kl([me(),Gl(`design:type`,Object)],Jl.prototype,`content`,void 0),Kl([me(),Gl(`design:type`,Object)],Jl.prototype,`style`,void 0),Kl([me(),Gl(`design:type`,Object)],Jl.prototype,`effects`,void 0),Kl([me(),Gl(`design:type`,Object)],Jl.prototype,`fill`,void 0),Kl([me(),Gl(`design:type`,Object)],Jl.prototype,`outline`,void 0),Kl([me(),Gl(`design:type`,Object)],Jl.prototype,`deformation`,void 0),Kl([me({internal:!0}),Gl(`design:type`,typeof HTMLElement>`u`?Object:HTMLElement)],Jl.prototype,`measureDom`,void 0),Kl([me({internal:!0}),Gl(`design:type`,Object)],Jl.prototype,`fonts`,void 0);function Yl(e,t){let n=new Jl(e);return t?n.load().then(()=>n.measure()):n.measure()}function Xl(e,t){let n=new Jl(e);return t?n.load().then(()=>n.render(e)):n.render(e)}e.Canvas2DRenderer=Hi,e.Character=pl,e.CircleCurve=El,e.EllipseCurve=Dl,e.Fragment=ml,e.HeartCurve=Ol,e.Measurer=vl,e.Paragraph=hl,e.PolygonCurve=kl,e.RectangularCurve=Al,e.Text=Jl,e.backgroundPlugin=yl,e.createSvgLoader=Pi,e.createSvgParser=Fi,e.defineDeformation=Pl,e.definePlugin=gl,e.deformationPlugin=Ll,e.getDeformationNames=Il,e.getEffectTransform2D=Ii,e.getHighlightStyle=Rl,e.highlightPlugin=zl,e.isEqualObject=Bi,e.isEqualValue=Vi,e.listStylePlugin=Vl,e.measureText=Yl,e.outlinePlugin=Hl,e.parseColormap=zi,e.parseTransformOrigin=Li,e.parseValueNumber=Ri,e.removeDeformation=Fl,e.renderPlugin=Ul,e.renderText=Xl,e.textDecorationPlugin=Wl,e.textDefaultStyle=ql});
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { T as Text } from './shared/modern-text.BdF52nXP.mjs';
2
- export { C as Canvas2DRenderer, a as Character, F as Fragment, M as Measurer, P as Paragraph, b as backgroundPlugin, c as createSvgLoader, d as createSvgParser, g as getEffectTransform2D, e as getHighlightStyle, h as highlightPlugin, i as isEqualObject, f as isEqualValue, l as listStylePlugin, o as outlinePlugin, p as parseColormap, j as parseTransformOrigin, k as parseValueNumber, r as renderPlugin, t as textDecorationPlugin, m as textDefaultStyle } from './shared/modern-text.BdF52nXP.mjs';
3
- export { d as defineDeformation, a as definePlugin, b as deformationPlugin, g as getDeformationNames, r as removeDeformation } from './shared/modern-text.CdKp2H-o.mjs';
1
+ import { T as Text } from './shared/modern-text.Dz4np_87.mjs';
2
+ export { C as Canvas2DRenderer, a as Character, F as Fragment, M as Measurer, P as Paragraph, b as backgroundPlugin, c as createSvgLoader, d as createSvgParser, g as getEffectTransform2D, e as getHighlightStyle, h as highlightPlugin, i as isEqualObject, f as isEqualValue, l as listStylePlugin, o as outlinePlugin, p as parseColormap, j as parseTransformOrigin, k as parseValueNumber, r as renderPlugin, t as textDecorationPlugin, m as textDefaultStyle } from './shared/modern-text.Dz4np_87.mjs';
3
+ export { d as defineDeformation, a as definePlugin, b as deformationPlugin, g as getDeformationNames, r as removeDeformation } from './shared/modern-text.Cvc61q2w.mjs';
4
4
  export { C as CircleCurve, E as EllipseCurve, H as HeartCurve, P as PolygonCurve, R as RectangularCurve } from './shared/modern-text.fT17R5HY.mjs';
5
5
  import 'modern-font';
6
6
  import 'modern-idoc';
@@ -206,9 +206,6 @@ class Deformer {
206
206
  paragraph.fragments.forEach((fragment) => {
207
207
  fragment.characters.forEach((character) => {
208
208
  character.glyphBox = character.getGlyphBoundingBox();
209
- if (character.glyphBox) {
210
- character.inlineBox = character.glyphBox;
211
- }
212
209
  });
213
210
  });
214
211
  });
@@ -549,6 +546,7 @@ function deformationPlugin() {
549
546
  deformer = new VerbatimDeformer(options, preset);
550
547
  break;
551
548
  }
549
+ text.forEachCharacter((character) => character.update(text.fonts));
552
550
  deformer.deform();
553
551
  let box = text.getGlyphBox();
554
552
  const dx = box.left;
@@ -563,9 +561,6 @@ function deformationPlugin() {
563
561
  point.set(point.x - dx, point.y - dy);
564
562
  });
565
563
  character.glyphBox = character.getGlyphBoundingBox();
566
- if (character.glyphBox) {
567
- character.inlineBox = character.glyphBox;
568
- }
569
564
  }
570
565
  highlight?.pathSet?.paths?.forEach((path) => {
571
566
  path.getControlPointRefs().forEach((point) => {
@@ -262,6 +262,8 @@ declare class Text extends Reactivable {
262
262
  protected _prevStyleKey: string;
263
263
  protected _prevFonts: unknown;
264
264
  protected _prevFontsSet: boolean;
265
+ protected _prevFontSig: string;
266
+ protected _pendingFontSig: string;
265
267
  protected _pendingContentKeys: string[];
266
268
  protected _pendingStyleKey: string;
267
269
  protected _pluginsByUpdateOrder: Plugin[];
@@ -307,7 +309,14 @@ declare class Text extends Reactivable {
307
309
  */
308
310
  protected _normalizeComputedStyle(style: FullStyle): FullStyle;
309
311
  protected _buildParagraph(p: NormalizedText['content'][number], pIndex: number): Paragraph;
310
- protected _canReuseLayout(styleKey: string): boolean;
312
+ /**
313
+ * 本文本「已用字体族 → 当前解析到的字体源」的签名。
314
+ * 遍历根/段落/片段声明的 fontFamily,各取 `fonts.get(family)?.src`(modern-font 里每个已加载字体/兜底
315
+ * 字体的唯一源标识)拼成签名。某族未加载时 `get` 返回兜底字体(其 src 如 modern-font:embedded-fallback),
316
+ * 加载完成后返回该字体(src=字体 URL)→ src 变化 → 签名变化,据此可靠感知「字体到位」并作废增量复用。
317
+ */
318
+ protected _computeFontSig(): string;
319
+ protected _canReuseLayout(styleKey: string, fontSig: string): boolean;
311
320
  protected _update(): this;
312
321
  measure(dom?: HTMLElement | undefined): MeasureResult;
313
322
  getGlyphBox(): BoundingBox;
@@ -262,6 +262,8 @@ declare class Text extends Reactivable {
262
262
  protected _prevStyleKey: string;
263
263
  protected _prevFonts: unknown;
264
264
  protected _prevFontsSet: boolean;
265
+ protected _prevFontSig: string;
266
+ protected _pendingFontSig: string;
265
267
  protected _pendingContentKeys: string[];
266
268
  protected _pendingStyleKey: string;
267
269
  protected _pluginsByUpdateOrder: Plugin[];
@@ -307,7 +309,14 @@ declare class Text extends Reactivable {
307
309
  */
308
310
  protected _normalizeComputedStyle(style: FullStyle): FullStyle;
309
311
  protected _buildParagraph(p: NormalizedText['content'][number], pIndex: number): Paragraph;
310
- protected _canReuseLayout(styleKey: string): boolean;
312
+ /**
313
+ * 本文本「已用字体族 → 当前解析到的字体源」的签名。
314
+ * 遍历根/段落/片段声明的 fontFamily,各取 `fonts.get(family)?.src`(modern-font 里每个已加载字体/兜底
315
+ * 字体的唯一源标识)拼成签名。某族未加载时 `get` 返回兜底字体(其 src 如 modern-font:embedded-fallback),
316
+ * 加载完成后返回该字体(src=字体 URL)→ src 变化 → 签名变化,据此可靠感知「字体到位」并作废增量复用。
317
+ */
318
+ protected _computeFontSig(): string;
319
+ protected _canReuseLayout(styleKey: string, fontSig: string): boolean;
311
320
  protected _update(): this;
312
321
  measure(dom?: HTMLElement | undefined): MeasureResult;
313
322
  getGlyphBox(): BoundingBox;
@@ -262,6 +262,8 @@ declare class Text extends Reactivable {
262
262
  protected _prevStyleKey: string;
263
263
  protected _prevFonts: unknown;
264
264
  protected _prevFontsSet: boolean;
265
+ protected _prevFontSig: string;
266
+ protected _pendingFontSig: string;
265
267
  protected _pendingContentKeys: string[];
266
268
  protected _pendingStyleKey: string;
267
269
  protected _pluginsByUpdateOrder: Plugin[];
@@ -307,7 +309,14 @@ declare class Text extends Reactivable {
307
309
  */
308
310
  protected _normalizeComputedStyle(style: FullStyle): FullStyle;
309
311
  protected _buildParagraph(p: NormalizedText['content'][number], pIndex: number): Paragraph;
310
- protected _canReuseLayout(styleKey: string): boolean;
312
+ /**
313
+ * 本文本「已用字体族 → 当前解析到的字体源」的签名。
314
+ * 遍历根/段落/片段声明的 fontFamily,各取 `fonts.get(family)?.src`(modern-font 里每个已加载字体/兜底
315
+ * 字体的唯一源标识)拼成签名。某族未加载时 `get` 返回兜底字体(其 src 如 modern-font:embedded-fallback),
316
+ * 加载完成后返回该字体(src=字体 URL)→ src 变化 → 签名变化,据此可靠感知「字体到位」并作废增量复用。
317
+ */
318
+ protected _computeFontSig(): string;
319
+ protected _canReuseLayout(styleKey: string, fontSig: string): boolean;
311
320
  protected _update(): this;
312
321
  measure(dom?: HTMLElement | undefined): MeasureResult;
313
322
  getGlyphBox(): BoundingBox;
@@ -3,7 +3,7 @@
3
3
  const modernFont = require('modern-font');
4
4
  const modernIdoc = require('modern-idoc');
5
5
  const modernPath2d = require('modern-path2d');
6
- const deformation = require('./modern-text._10DVHum.cjs');
6
+ const deformation = require('./modern-text.B1qEGvHu.cjs');
7
7
 
8
8
  function createSvgLoader() {
9
9
  const loaded = /* @__PURE__ */ new Map();
@@ -2026,6 +2026,11 @@ class Text extends modernIdoc.Reactivable {
2026
2026
  // (否则会复用「fonts 未就绪」时测得的零宽字形)。
2027
2027
  _prevFonts;
2028
2028
  _prevFontsSet = false;
2029
+ // 字体解析签名(见 _computeFontSig):Fonts 容器引用不变、但某字体族从 fallback 变为已加载时,
2030
+ // 其解析结果会变 → 签名变 → 作废增量复用。修复「字体异步加载完文字不重排、须手动激活才生效」的根因
2031
+ // (原先只比较 fonts 容器引用,往同一实例新增字体时引用不变,永远测不出字体到位)。
2032
+ _prevFontSig = "";
2033
+ _pendingFontSig = "";
2029
2034
  // _update 计算出的待提交快照;仅在 measure() 真正完成测量后才提交到 _prev*(见 measure),
2030
2035
  // 否则构造函数里的 _update(只建树不测量)会让首测误把未测量段当作可复用。
2031
2036
  _pendingContentKeys = [];
@@ -2204,9 +2209,46 @@ class Text extends modernIdoc.Reactivable {
2204
2209
  });
2205
2210
  return paragraph;
2206
2211
  }
2207
- // 仅当根级样式/填充/描边/特效/形变未变、且非竖排、非块级垂直对齐位移时,才允许复用未变段落
2208
- // (这些会改变各段 computedStyle 或全局位移,复用会得到错误结果)。
2209
- _canReuseLayout(styleKey) {
2212
+ /**
2213
+ * 本文本「已用字体族 当前解析到的字体源」的签名。
2214
+ * 遍历根/段落/片段声明的 fontFamily,各取 `fonts.get(family)?.src`(modern-font 里每个已加载字体/兜底
2215
+ * 字体的唯一源标识)拼成签名。某族未加载时 `get` 返回兜底字体(其 src 如 modern-font:embedded-fallback),
2216
+ * 加载完成后返回该字体(src=字体 URL)→ src 变化 → 签名变化,据此可靠感知「字体到位」并作废增量复用。
2217
+ */
2218
+ _computeFontSig() {
2219
+ const fonts = this.fonts;
2220
+ if (!fonts?.get) {
2221
+ return "";
2222
+ }
2223
+ const families = /* @__PURE__ */ new Set();
2224
+ const rootFamily = this.computedStyle?.fontFamily;
2225
+ if (rootFamily) {
2226
+ families.add(String(rootFamily));
2227
+ }
2228
+ for (const para of this.content) {
2229
+ const pFamily = para?.fontFamily;
2230
+ if (pFamily) {
2231
+ families.add(String(pFamily));
2232
+ }
2233
+ const fragments = para?.fragments;
2234
+ if (Array.isArray(fragments)) {
2235
+ for (const frag of fragments) {
2236
+ const fFamily = frag?.fontFamily;
2237
+ if (fFamily) {
2238
+ families.add(String(fFamily));
2239
+ }
2240
+ }
2241
+ }
2242
+ }
2243
+ let sig = "";
2244
+ for (const family of families) {
2245
+ sig += `${family}#${fonts.get(family)?.src ?? ""};`;
2246
+ }
2247
+ return sig;
2248
+ }
2249
+ // 仅当根级样式/填充/描边/特效/形变未变、字体解析结果未变、且非竖排、非块级垂直对齐位移时,才允许复用未变段落
2250
+ // (这些会改变各段 computedStyle、字形度量或全局位移,复用会得到错误结果)。
2251
+ _canReuseLayout(styleKey, fontSig) {
2210
2252
  if (!this.incrementalLayout || !this._prevParagraphs.length) {
2211
2253
  return false;
2212
2254
  }
@@ -2216,6 +2258,9 @@ class Text extends modernIdoc.Reactivable {
2216
2258
  if (!this._prevFontsSet || this.fonts !== this._prevFonts) {
2217
2259
  return false;
2218
2260
  }
2261
+ if (fontSig !== this._prevFontSig) {
2262
+ return false;
2263
+ }
2219
2264
  const cs = this.computedStyle;
2220
2265
  if (cs.writingMode.includes("vertical")) {
2221
2266
  return false;
@@ -2231,7 +2276,9 @@ class Text extends modernIdoc.Reactivable {
2231
2276
  this.computedOutline = this.outline ? { ...this.outline } : void 0;
2232
2277
  this.computedEffects = this.effects?.map((v) => v) ?? [];
2233
2278
  const styleKey = JSON.stringify([this.style, this.fill, this.outline, this.effects, this.deformation]);
2234
- const reuse = this._canReuseLayout(styleKey);
2279
+ const fontSig = this._computeFontSig();
2280
+ this._pendingFontSig = fontSig;
2281
+ const reuse = this._canReuseLayout(styleKey, fontSig);
2235
2282
  const content = this.content;
2236
2283
  const contentKeys = Array.from({ length: content.length });
2237
2284
  const paragraphs = Array.from({ length: content.length });
@@ -2288,6 +2335,7 @@ class Text extends modernIdoc.Reactivable {
2288
2335
  this._prevStyleKey = this._pendingStyleKey;
2289
2336
  this._prevFonts = this.fonts;
2290
2337
  this._prevFontsSet = true;
2338
+ this._prevFontSig = this._pendingFontSig;
2291
2339
  const updatePlugins = this._pluginsByUpdateOrder;
2292
2340
  for (let i = 0; i < updatePlugins.length; i++) {
2293
2341
  updatePlugins[i].update?.(this);
@@ -204,9 +204,6 @@ class Deformer {
204
204
  paragraph.fragments.forEach((fragment) => {
205
205
  fragment.characters.forEach((character) => {
206
206
  character.glyphBox = character.getGlyphBoundingBox();
207
- if (character.glyphBox) {
208
- character.inlineBox = character.glyphBox;
209
- }
210
207
  });
211
208
  });
212
209
  });
@@ -547,6 +544,7 @@ function deformationPlugin() {
547
544
  deformer = new VerbatimDeformer(options, preset);
548
545
  break;
549
546
  }
547
+ text.forEachCharacter((character) => character.update(text.fonts));
550
548
  deformer.deform();
551
549
  let box = text.getGlyphBox();
552
550
  const dx = box.left;
@@ -561,9 +559,6 @@ function deformationPlugin() {
561
559
  point.set(point.x - dx, point.y - dy);
562
560
  });
563
561
  character.glyphBox = character.getGlyphBoundingBox();
564
- if (character.glyphBox) {
565
- character.inlineBox = character.glyphBox;
566
- }
567
562
  }
568
563
  highlight?.pathSet?.paths?.forEach((path) => {
569
564
  path.getControlPointRefs().forEach((point) => {
@@ -1,5 +1,5 @@
1
1
  import { Vector2, Vector2Like, BoundingBox } from 'modern-path2d';
2
- import { C as Character } from './modern-text.DENkEKJN.cjs';
2
+ import { C as Character } from './modern-text.Byk6gnkH.mjs';
3
3
 
4
4
  /** 逐字沿形状排布所需的曲线最小接口(实现了这三个方法即可当作变形曲线) */
5
5
  interface DeformationCurve {
@@ -1,7 +1,7 @@
1
1
  import { fonts } from 'modern-font';
2
2
  import { isNone, isGradient, normalizeGradient, clearUndef, Reactivable, normalizeText, getDefaultStyle, property } from 'modern-idoc';
3
3
  import { svgToDom, svgToPath2DSet, Path2DSet, Transform2D, setCanvasContext, Path2D, BoundingBox, Vector2 } from 'modern-path2d';
4
- import { a as definePlugin, b as deformationPlugin } from './modern-text.CdKp2H-o.mjs';
4
+ import { a as definePlugin, b as deformationPlugin } from './modern-text.Cvc61q2w.mjs';
5
5
 
6
6
  function createSvgLoader() {
7
7
  const loaded = /* @__PURE__ */ new Map();
@@ -2024,6 +2024,11 @@ class Text extends Reactivable {
2024
2024
  // (否则会复用「fonts 未就绪」时测得的零宽字形)。
2025
2025
  _prevFonts;
2026
2026
  _prevFontsSet = false;
2027
+ // 字体解析签名(见 _computeFontSig):Fonts 容器引用不变、但某字体族从 fallback 变为已加载时,
2028
+ // 其解析结果会变 → 签名变 → 作废增量复用。修复「字体异步加载完文字不重排、须手动激活才生效」的根因
2029
+ // (原先只比较 fonts 容器引用,往同一实例新增字体时引用不变,永远测不出字体到位)。
2030
+ _prevFontSig = "";
2031
+ _pendingFontSig = "";
2027
2032
  // _update 计算出的待提交快照;仅在 measure() 真正完成测量后才提交到 _prev*(见 measure),
2028
2033
  // 否则构造函数里的 _update(只建树不测量)会让首测误把未测量段当作可复用。
2029
2034
  _pendingContentKeys = [];
@@ -2202,9 +2207,46 @@ class Text extends Reactivable {
2202
2207
  });
2203
2208
  return paragraph;
2204
2209
  }
2205
- // 仅当根级样式/填充/描边/特效/形变未变、且非竖排、非块级垂直对齐位移时,才允许复用未变段落
2206
- // (这些会改变各段 computedStyle 或全局位移,复用会得到错误结果)。
2207
- _canReuseLayout(styleKey) {
2210
+ /**
2211
+ * 本文本「已用字体族 当前解析到的字体源」的签名。
2212
+ * 遍历根/段落/片段声明的 fontFamily,各取 `fonts.get(family)?.src`(modern-font 里每个已加载字体/兜底
2213
+ * 字体的唯一源标识)拼成签名。某族未加载时 `get` 返回兜底字体(其 src 如 modern-font:embedded-fallback),
2214
+ * 加载完成后返回该字体(src=字体 URL)→ src 变化 → 签名变化,据此可靠感知「字体到位」并作废增量复用。
2215
+ */
2216
+ _computeFontSig() {
2217
+ const fonts = this.fonts;
2218
+ if (!fonts?.get) {
2219
+ return "";
2220
+ }
2221
+ const families = /* @__PURE__ */ new Set();
2222
+ const rootFamily = this.computedStyle?.fontFamily;
2223
+ if (rootFamily) {
2224
+ families.add(String(rootFamily));
2225
+ }
2226
+ for (const para of this.content) {
2227
+ const pFamily = para?.fontFamily;
2228
+ if (pFamily) {
2229
+ families.add(String(pFamily));
2230
+ }
2231
+ const fragments = para?.fragments;
2232
+ if (Array.isArray(fragments)) {
2233
+ for (const frag of fragments) {
2234
+ const fFamily = frag?.fontFamily;
2235
+ if (fFamily) {
2236
+ families.add(String(fFamily));
2237
+ }
2238
+ }
2239
+ }
2240
+ }
2241
+ let sig = "";
2242
+ for (const family of families) {
2243
+ sig += `${family}#${fonts.get(family)?.src ?? ""};`;
2244
+ }
2245
+ return sig;
2246
+ }
2247
+ // 仅当根级样式/填充/描边/特效/形变未变、字体解析结果未变、且非竖排、非块级垂直对齐位移时,才允许复用未变段落
2248
+ // (这些会改变各段 computedStyle、字形度量或全局位移,复用会得到错误结果)。
2249
+ _canReuseLayout(styleKey, fontSig) {
2208
2250
  if (!this.incrementalLayout || !this._prevParagraphs.length) {
2209
2251
  return false;
2210
2252
  }
@@ -2214,6 +2256,9 @@ class Text extends Reactivable {
2214
2256
  if (!this._prevFontsSet || this.fonts !== this._prevFonts) {
2215
2257
  return false;
2216
2258
  }
2259
+ if (fontSig !== this._prevFontSig) {
2260
+ return false;
2261
+ }
2217
2262
  const cs = this.computedStyle;
2218
2263
  if (cs.writingMode.includes("vertical")) {
2219
2264
  return false;
@@ -2229,7 +2274,9 @@ class Text extends Reactivable {
2229
2274
  this.computedOutline = this.outline ? { ...this.outline } : void 0;
2230
2275
  this.computedEffects = this.effects?.map((v) => v) ?? [];
2231
2276
  const styleKey = JSON.stringify([this.style, this.fill, this.outline, this.effects, this.deformation]);
2232
- const reuse = this._canReuseLayout(styleKey);
2277
+ const fontSig = this._computeFontSig();
2278
+ this._pendingFontSig = fontSig;
2279
+ const reuse = this._canReuseLayout(styleKey, fontSig);
2233
2280
  const content = this.content;
2234
2281
  const contentKeys = Array.from({ length: content.length });
2235
2282
  const paragraphs = Array.from({ length: content.length });
@@ -2286,6 +2333,7 @@ class Text extends Reactivable {
2286
2333
  this._prevStyleKey = this._pendingStyleKey;
2287
2334
  this._prevFonts = this.fonts;
2288
2335
  this._prevFontsSet = true;
2336
+ this._prevFontSig = this._pendingFontSig;
2289
2337
  const updatePlugins = this._pluginsByUpdateOrder;
2290
2338
  for (let i = 0; i < updatePlugins.length; i++) {
2291
2339
  updatePlugins[i].update?.(this);
@@ -1,5 +1,5 @@
1
1
  import { Vector2, Vector2Like, BoundingBox } from 'modern-path2d';
2
- import { C as Character } from './modern-text.DENkEKJN.js';
2
+ import { C as Character } from './modern-text.Byk6gnkH.js';
3
3
 
4
4
  /** 逐字沿形状排布所需的曲线最小接口(实现了这三个方法即可当作变形曲线) */
5
5
  interface DeformationCurve {
@@ -1,5 +1,5 @@
1
1
  import { Vector2, Vector2Like, BoundingBox } from 'modern-path2d';
2
- import { C as Character } from './modern-text.DENkEKJN.mjs';
2
+ import { C as Character } from './modern-text.Byk6gnkH.cjs';
3
3
 
4
4
  /** 逐字沿形状排布所需的曲线最小接口(实现了这三个方法即可当作变形曲线) */
5
5
  interface DeformationCurve {
@@ -2,10 +2,10 @@
2
2
 
3
3
  const diff = require('diff');
4
4
  const modernIdoc = require('modern-idoc');
5
- const Text = require('../shared/modern-text.BAnUZM0U.cjs');
5
+ const Text = require('../shared/modern-text.CJSp_eBm.cjs');
6
6
  require('modern-font');
7
7
  require('modern-path2d');
8
- require('../shared/modern-text._10DVHum.cjs');
8
+ require('../shared/modern-text.B1qEGvHu.cjs');
9
9
 
10
10
  var __defProp = Object.defineProperty;
11
11
  var __decorateClass = (decorators, target, key, kind) => {
@@ -1,5 +1,5 @@
1
1
  import { PropertyAccessor, NormalizedTextContent } from 'modern-idoc';
2
- import { c as Text } from '../shared/modern-text.DENkEKJN.cjs';
2
+ import { c as Text } from '../shared/modern-text.Byk6gnkH.cjs';
3
3
  import 'modern-font';
4
4
  import 'modern-path2d';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { PropertyAccessor, NormalizedTextContent } from 'modern-idoc';
2
- import { c as Text } from '../shared/modern-text.DENkEKJN.mjs';
2
+ import { c as Text } from '../shared/modern-text.Byk6gnkH.mjs';
3
3
  import 'modern-font';
4
4
  import 'modern-path2d';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { PropertyAccessor, NormalizedTextContent } from 'modern-idoc';
2
- import { c as Text } from '../shared/modern-text.DENkEKJN.js';
2
+ import { c as Text } from '../shared/modern-text.Byk6gnkH.js';
3
3
  import 'modern-font';
4
4
  import 'modern-path2d';
5
5
 
@@ -1,9 +1,9 @@
1
1
  import { diffChars } from 'diff';
2
2
  import { isCRLF, textContentToString, normalizeCRLF, normalizeTextContent, property } from 'modern-idoc';
3
- import { T as Text } from '../shared/modern-text.BdF52nXP.mjs';
3
+ import { T as Text } from '../shared/modern-text.Dz4np_87.mjs';
4
4
  import 'modern-font';
5
5
  import 'modern-path2d';
6
- import '../shared/modern-text.CdKp2H-o.mjs';
6
+ import '../shared/modern-text.Cvc61q2w.mjs';
7
7
 
8
8
  var __defProp = Object.defineProperty;
9
9
  var __decorateClass = (decorators, target, key, kind) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-text",
3
3
  "type": "module",
4
- "version": "2.1.2",
4
+ "version": "2.1.4",
5
5
  "packageManager": "pnpm@10.18.1",
6
6
  "description": "Measure and render text in a way that describes the DOM.",
7
7
  "author": "wxm",
@@ -62,7 +62,7 @@
62
62
  "diff": "^9.0.0",
63
63
  "modern-font": "^0.6.2",
64
64
  "modern-idoc": "^0.12.3",
65
- "modern-path2d": "^1.8.6"
65
+ "modern-path2d": "^1.8.7"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@antfu/eslint-config": "^9.1.0",