svg-path-commander 1.0.5 → 2.0.0-alpha2

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 (131) hide show
  1. package/README.md +26 -4
  2. package/dist/svg-path-commander.cjs +2 -0
  3. package/dist/svg-path-commander.cjs.map +1 -0
  4. package/dist/svg-path-commander.d.ts +454 -0
  5. package/dist/svg-path-commander.js +2 -3762
  6. package/dist/svg-path-commander.js.map +1 -0
  7. package/dist/svg-path-commander.mjs +1194 -0
  8. package/dist/svg-path-commander.mjs.map +1 -0
  9. package/package.json +39 -42
  10. package/src/convert/pathToAbsolute.ts +101 -0
  11. package/src/convert/{pathToCurve.js → pathToCurve.ts} +12 -14
  12. package/src/convert/pathToRelative.ts +92 -0
  13. package/src/convert/pathToString.ts +17 -0
  14. package/src/{svg-path-commander.js → index.ts} +143 -66
  15. package/src/interface.ts +129 -0
  16. package/src/math/distanceSquareRoot.ts +13 -0
  17. package/src/math/midPoint.ts +16 -0
  18. package/src/math/{polygonArea.js → polygonArea.ts} +6 -4
  19. package/src/math/{polygonLength.js → polygonLength.ts} +5 -3
  20. package/src/math/rotateVector.ts +16 -0
  21. package/src/options/options.ts +9 -0
  22. package/src/parser/error.ts +2 -0
  23. package/src/parser/finalizeSegment.ts +31 -0
  24. package/src/parser/{invalidPathValue.js → invalidPathValue.ts} +0 -0
  25. package/src/parser/{isArcCommand.js → isArcCommand.ts} +5 -4
  26. package/src/parser/isDigit.ts +12 -0
  27. package/src/parser/isDigitStart.ts +14 -0
  28. package/src/parser/isPathCommand.ts +28 -0
  29. package/src/parser/isSpace.ts +23 -0
  30. package/src/parser/paramsCount.ts +16 -0
  31. package/src/parser/paramsParser.ts +14 -0
  32. package/src/parser/{parsePathString.js → parsePathString.ts} +13 -7
  33. package/src/parser/pathParser.ts +29 -0
  34. package/src/parser/{scanFlag.js → scanFlag.ts} +8 -5
  35. package/src/parser/{scanParam.js → scanParam.ts} +12 -11
  36. package/src/parser/{scanSegment.js → scanSegment.ts} +9 -5
  37. package/src/parser/{skipSpaces.js → skipSpaces.ts} +5 -3
  38. package/src/process/{arcToCubic.js → arcToCubic.ts} +42 -28
  39. package/src/process/fixArc.ts +23 -0
  40. package/src/process/getSVGMatrix.ts +70 -0
  41. package/src/process/lineToCubic.ts +17 -0
  42. package/src/process/{normalizePath.js → normalizePath.ts} +10 -10
  43. package/src/process/normalizeSegment.ts +47 -0
  44. package/src/process/{optimizePath.js → optimizePath.ts} +18 -21
  45. package/src/process/{projection2d.js → projection2d.ts} +16 -15
  46. package/src/process/quadToCubic.ts +31 -0
  47. package/src/process/reverseCurve.ts +21 -0
  48. package/src/process/reversePath.ts +101 -0
  49. package/src/process/roundPath.ts +29 -0
  50. package/src/process/segmentToCubic.ts +46 -0
  51. package/src/process/shortenSegment.ts +79 -0
  52. package/src/process/splitCubic.ts +28 -0
  53. package/src/process/{splitPath.js → splitPath.ts} +9 -8
  54. package/src/process/{transformPath.js → transformPath.ts} +55 -48
  55. package/src/types.ts +193 -0
  56. package/src/util/getClosestPoint.ts +15 -0
  57. package/src/util/{getDrawDirection.js → getDrawDirection.ts} +7 -4
  58. package/src/util/getPathArea.ts +70 -0
  59. package/src/util/{getPathBBox.js → getPathBBox.ts} +16 -5
  60. package/src/util/getPointAtLength.ts +14 -0
  61. package/src/util/{getPropertiesAtLength.js → getPropertiesAtLength.ts} +28 -19
  62. package/src/util/{getPropertiesAtPoint.js → getPropertiesAtPoint.ts} +16 -12
  63. package/src/util/getSegmentAtLength.ts +15 -0
  64. package/src/util/getSegmentOfPoint.ts +18 -0
  65. package/src/util/{getTotalLength.js → getTotalLength.ts} +6 -4
  66. package/src/util/isAbsoluteArray.ts +18 -0
  67. package/src/util/{isCurveArray.js → isCurveArray.ts} +6 -4
  68. package/src/util/{isNormalizedArray.js → isNormalizedArray.ts} +4 -2
  69. package/src/util/isPathArray.ts +19 -0
  70. package/src/util/isPointInStroke.ts +15 -0
  71. package/src/util/isRelativeArray.ts +18 -0
  72. package/src/util/{isValidPath.js → isValidPath.ts} +5 -4
  73. package/src/util/{pathLengthFactory.js → pathLengthFactory.ts} +38 -31
  74. package/src/util/{segmentArcFactory.js → segmentArcFactory.ts} +71 -55
  75. package/src/util/segmentCubicFactory.ts +114 -0
  76. package/src/util/{segmentLineFactory.js → segmentLineFactory.ts} +10 -8
  77. package/src/util/{segmentQuadFactory.js → segmentQuadFactory.ts} +47 -32
  78. package/src/util/shapeToPath.ts +214 -0
  79. package/dist/svg-path-commander.es5.js +0 -3875
  80. package/dist/svg-path-commander.es5.min.js +0 -2
  81. package/dist/svg-path-commander.esm.js +0 -3754
  82. package/dist/svg-path-commander.esm.min.js +0 -2
  83. package/dist/svg-path-commander.min.js +0 -2
  84. package/src/convert/pathToAbsolute.js +0 -86
  85. package/src/convert/pathToRelative.js +0 -84
  86. package/src/convert/pathToString.js +0 -14
  87. package/src/index.js +0 -10
  88. package/src/math/distanceSquareRoot.js +0 -14
  89. package/src/math/epsilon.js +0 -8
  90. package/src/math/midPoint.js +0 -13
  91. package/src/math/rotateVector.js +0 -14
  92. package/src/options/options.js +0 -10
  93. package/src/parser/error.js +0 -2
  94. package/src/parser/finalizeSegment.js +0 -28
  95. package/src/parser/isDigit.js +0 -9
  96. package/src/parser/isDigitStart.js +0 -13
  97. package/src/parser/isPathCommand.js +0 -25
  98. package/src/parser/isSpace.js +0 -16
  99. package/src/parser/paramsCount.js +0 -9
  100. package/src/parser/paramsParser.js +0 -8
  101. package/src/parser/pathParser.js +0 -24
  102. package/src/process/clonePath.js +0 -9
  103. package/src/process/fixArc.js +0 -21
  104. package/src/process/fixPath.js +0 -31
  105. package/src/process/getSVGMatrix.js +0 -61
  106. package/src/process/lineToCubic.js +0 -30
  107. package/src/process/normalizeSegment.js +0 -45
  108. package/src/process/quadToCubic.js +0 -22
  109. package/src/process/reverseCurve.js +0 -18
  110. package/src/process/reversePath.js +0 -89
  111. package/src/process/roundPath.js +0 -26
  112. package/src/process/segmentToCubic.js +0 -46
  113. package/src/process/shortenSegment.js +0 -58
  114. package/src/process/splitCubic.js +0 -26
  115. package/src/util/getClosestPoint.js +0 -12
  116. package/src/util/getPathArea.js +0 -47
  117. package/src/util/getPointAtLength.js +0 -12
  118. package/src/util/getSegmentAtLength.js +0 -11
  119. package/src/util/getSegmentOfPoint.js +0 -12
  120. package/src/util/isAbsoluteArray.js +0 -14
  121. package/src/util/isPathArray.js +0 -14
  122. package/src/util/isPointInStroke.js +0 -13
  123. package/src/util/isRelativeArray.js +0 -14
  124. package/src/util/segmentCubicFactory.js +0 -97
  125. package/src/util/shapeToPath.js +0 -204
  126. package/src/util/util.js +0 -82
  127. package/src/version.js +0 -8
  128. package/types/index.d.ts +0 -120
  129. package/types/more/modules.ts +0 -82
  130. package/types/more/svg.d.ts +0 -211
  131. package/types/svg-path-commander.d.ts +0 -1089
package/README.md CHANGED
@@ -4,12 +4,15 @@
4
4
  [![NPM Version](https://img.shields.io/npm/v/svg-path-commander.svg)](https://www.npmjs.com/package/svg-path-commander)
5
5
  [![NPM Downloads](https://img.shields.io/npm/dm/svg-path-commander.svg)](http://npm-stat.com/charts.html?svg-path-commander)
6
6
  [![jsDeliver](https://img.shields.io/jsdelivr/npm/hw/svg-path-commander)](https://www.jsdelivr.com/package/npm/svg-path-commander)
7
- ![cypress version](https://img.shields.io/badge/cypress-9.6.1-brightgreen)
8
- ![typescript version](https://img.shields.io/badge/typescript-4.5.2-brightgreen)
7
+ [![typescript version](https://img.shields.io/badge/typescript-4.9.4-brightgreen)](https://www.typescriptlang.org/)
8
+ [![cypress version](https://img.shields.io/badge/cypress-12.2.0-brightgreen)](https://www.cypress.io/)
9
+ [![eslint version](https://img.shields.io/badge/eslint-8.30.0-brightgreen)](https://github.com/eslint)
10
+ [![vite version](https://img.shields.io/badge/vite-4.0.3-brightgreen)](https://vitejs.dev/)
11
+ [![prettier version](https://img.shields.io/badge/prettier-2.8.1-brightgreen)](https://prettier.io/)
9
12
 
10
13
  ![image](./docs/assets/SVGPathCommander.svg)
11
14
 
12
- A modern set of ES6+ JavaScript tools for manipulating the `d` (description) attribute for *SVGPathElement* items. The library is implementing modern JavaScript API to produce reusable path strings with lossless quality. In addition, you also have a powerful tool to convert other SVG shapes like `<circle>` or `<rect>` to `<path>`.
15
+ A modern set of Typescript tools for manipulating the `d` (description) attribute for *SVGPathElement* items. The library is implementing modern JavaScript API to produce reusable path strings with lossless quality. In addition, you also have a powerful tool to convert other SVG shapes like `<circle>` or `<rect>` to `<path>`.
13
16
 
14
17
 
15
18
  While you may find familiar tools inside, this library brings ***new additions***:
@@ -19,7 +22,7 @@ While you may find familiar tools inside, this library brings ***new additions**
19
22
  * a new and unique tool to *apply transform functions to path commands* via the modern *DOMMatrix* API.
20
23
 
21
24
  **The key differences with other libraries**:
22
- * ES6+ sourced with modernized codebase and build tools; all inherited codebase has been modernized as well;
25
+ * Typescript sourced with modernized codebase and build tools; all inherited codebase has been modernized as well;
23
26
  * along with the modern codebase, the library also comes with strong TypeScript definitions;
24
27
  * this library can create 3D to 2D projections, making your SVGs look like 3D but in the SVG coordinate system;
25
28
  * you can use this library in both web apps and Node.js, you are not restricted to a single environment;
@@ -135,6 +138,25 @@ const myRectAttr = {
135
138
  const myRectPath = SVGPathCommander.shapeToPath(myRectAttr);
136
139
  document.getElementById('mySVG').append(myRectPath);
137
140
  ```
141
+ Server-side using `jsdom`:
142
+ ```js
143
+ const { document } = new JSDOM(
144
+ `<html>
145
+ <head></head>
146
+ <body>
147
+ <svg id="mySVG" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
148
+ <rect id="myRect" x="0" width="100" height="100" rx="15" />
149
+ </svg>
150
+ </body>
151
+ </html>`,
152
+ {
153
+ pretendToBeVisual: true,
154
+ }
155
+ ).window;
156
+
157
+ const myRect = document.getElementById('myRect');
158
+ SVGPathCommander.shapeToPath(myRect, true, document);
159
+ ```
138
160
 
139
161
  Get the path length:
140
162
  ```js
@@ -0,0 +1,2 @@
1
+ "use strict";const at={origin:[0,0,0],round:4},q="SVGPathCommander Error",B={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0},Ct=e=>{let t=e.pathValue[e.segmentStart],n=t.toLowerCase();const{data:r}=e;for(;r.length>=B[n]&&(n==="m"&&r.length>2?(e.segments.push([t,...r.splice(0,2)]),n="l",t=t==="m"?"l":"L"):e.segments.push([t,...r.splice(0,B[n])]),!!B[n]););},Ut=e=>{const{index:t,pathValue:n}=e,r=n.charCodeAt(t);if(r===48){e.param=0,e.index+=1;return}if(r===49){e.param=1,e.index+=1;return}e.err=`${q}: invalid Arc flag "${n[t]}", expecting 0 or 1 at index ${t}`},I=e=>e>=48&&e<=57,D="Invalid path value",Kt=e=>{const{max:t,pathValue:n,index:r}=e;let s=r,i=!1,o=!1,l=!1,c=!1,a;if(s>=t){e.err=`${q}: ${D} at index ${s}, "pathValue" is missing param`;return}if(a=n.charCodeAt(s),(a===43||a===45)&&(s+=1,a=n.charCodeAt(s)),!I(a)&&a!==46){e.err=`${q}: ${D} at index ${s}, "${n[s]}" is not a number`;return}if(a!==46){if(i=a===48,s+=1,a=n.charCodeAt(s),i&&s<t&&a&&I(a)){e.err=`${q}: ${D} at index ${r}, "${n[r]}" illegal number`;return}for(;s<t&&I(n.charCodeAt(s));)s+=1,o=!0;a=n.charCodeAt(s)}if(a===46){for(c=!0,s+=1;I(n.charCodeAt(s));)s+=1,l=!0;a=n.charCodeAt(s)}if(a===101||a===69){if(c&&!o&&!l){e.err=`${q}: ${D} at index ${s}, "${n[s]}" invalid float exponent`;return}if(s+=1,a=n.charCodeAt(s),(a===43||a===45)&&(s+=1),s<t&&I(n.charCodeAt(s)))for(;s<t&&I(n.charCodeAt(s));)s+=1;else{e.err=`${q}: ${D} at index ${s}, "${n[s]}" invalid integer exponent`;return}}e.index=s,e.param=+e.pathValue.slice(r,s)},_t=e=>[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279,10,13,8232,8233,32,9,11,12,160].includes(e),G=e=>{const{pathValue:t,max:n}=e;for(;e.index<n&&_t(t.charCodeAt(e.index));)e.index+=1},Wt=e=>{switch(e|32){case 109:case 122:case 108:case 104:case 118:case 99:case 115:case 113:case 116:case 97:return!0;default:return!1}},te=e=>I(e)||e===43||e===45||e===46,ee=e=>(e|32)===97,Vt=e=>{const{max:t,pathValue:n,index:r}=e,s=n.charCodeAt(r),i=B[n[r].toLowerCase()];if(e.segmentStart=r,!Wt(s)){e.err=`${q}: ${D} "${n[r]}" is not a path command`;return}if(e.index+=1,G(e),e.data=[],!i){Ct(e);return}for(;;){for(let o=i;o>0;o-=1){if(ee(s)&&(o===3||o===4)?Ut(e):Kt(e),e.err.length)return;e.data.push(e.param),G(e),e.index<t&&n.charCodeAt(e.index)===44&&(e.index+=1,G(e))}if(e.index>=e.max||!te(n.charCodeAt(e.index)))break}Ct(e)};class Ot{constructor(t){this.segments=[],this.pathValue=t,this.max=t.length,this.index=0,this.param=0,this.segmentStart=0,this.data=[],this.err=""}}const ct=e=>Array.isArray(e)&&e.every(t=>{const n=t[0].toLowerCase();return B[n]===t.length-1&&"achlmqstvz".includes(n)}),R=e=>{if(ct(e))return[...e];const t=new Ot(e);for(G(t);t.index<t.max&&!t.err.length;)Vt(t);if(t.err&&t.err.length)throw TypeError(t.err);return t.segments},ne=e=>{const t=e.length;let n=-1,r,s=e[t-1],i=0;for(;++n<t;)r=s,s=e[n],i+=r[1]*s[0]-r[0]*s[1];return i/2},U=(e,t)=>Math.sqrt((e[0]-t[0])*(e[0]-t[0])+(e[1]-t[1])*(e[1]-t[1])),se=e=>e.reduce((t,n,r)=>r?t+U(e[r-1],n):0,0);var re=Object.defineProperty,ie=(e,t,n)=>t in e?re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,C=(e,t,n)=>(ie(e,typeof t!="symbol"?t+"":t,n),n);const oe={a:1,b:0,c:0,d:1,e:0,f:0,m11:1,m12:0,m13:0,m14:0,m21:0,m22:1,m23:0,m24:0,m31:0,m32:0,m33:1,m34:0,m41:0,m42:0,m43:0,m44:1,is2D:!0,isIdentity:!0},zt=e=>(e instanceof Float64Array||e instanceof Float32Array||Array.isArray(e)&&e.every(t=>typeof t=="number"))&&[6,16].some(t=>e.length===t),It=e=>e instanceof DOMMatrix||e instanceof N||typeof e=="object"&&Object.keys(oe).every(t=>e&&t in e),K=e=>{const t=new N,n=Array.from(e);if(!zt(n))throw TypeError(`CSSMatrix: "${n.join(",")}" must be an array with 6/16 numbers.`);if(n.length===16){const[r,s,i,o,l,c,a,m,f,y,g,h,u,x,p,d]=n;t.m11=r,t.a=r,t.m21=l,t.c=l,t.m31=f,t.m41=u,t.e=u,t.m12=s,t.b=s,t.m22=c,t.d=c,t.m32=y,t.m42=x,t.f=x,t.m13=i,t.m23=a,t.m33=g,t.m43=p,t.m14=o,t.m24=m,t.m34=h,t.m44=d}else if(n.length===6){const[r,s,i,o,l,c]=n;t.m11=r,t.a=r,t.m12=s,t.b=s,t.m21=i,t.c=i,t.m22=o,t.d=o,t.m41=l,t.e=l,t.m42=c,t.f=c}return t},jt=e=>{if(It(e))return K([e.m11,e.m12,e.m13,e.m14,e.m21,e.m22,e.m23,e.m24,e.m31,e.m32,e.m33,e.m34,e.m41,e.m42,e.m43,e.m44]);throw TypeError(`CSSMatrix: "${JSON.stringify(e)}" is not a DOMMatrix / CSSMatrix / JSON compatible object.`)},Et=e=>{if(typeof e!="string")throw TypeError(`CSSMatrix: "${JSON.stringify(e)}" is not a string.`);const t=String(e).replace(/\s/g,"");let n=new N;const r=`CSSMatrix: invalid transform string "${e}"`;return t.split(")").filter(s=>s).forEach(s=>{const[i,o]=s.split("(");if(!o)throw TypeError(r);const l=o.split(",").map(h=>h.includes("rad")?parseFloat(h)*(180/Math.PI):parseFloat(h)),[c,a,m,f]=l,y=[c,a,m],g=[c,a,m,f];if(i==="perspective"&&c&&[a,m].every(h=>h===void 0))n.m34=-1/c;else if(i.includes("matrix")&&[6,16].includes(l.length)&&l.every(h=>!Number.isNaN(+h))){const h=l.map(u=>Math.abs(u)<1e-6?0:u);n=n.multiply(K(h))}else if(i==="translate3d"&&y.every(h=>!Number.isNaN(+h)))n=n.translate(c,a,m);else if(i==="translate"&&c&&m===void 0)n=n.translate(c,a||0,0);else if(i==="rotate3d"&&g.every(h=>!Number.isNaN(+h))&&f)n=n.rotateAxisAngle(c,a,m,f);else if(i==="rotate"&&c&&[a,m].every(h=>h===void 0))n=n.rotate(0,0,c);else if(i==="scale3d"&&y.every(h=>!Number.isNaN(+h))&&y.some(h=>h!==1))n=n.scale(c,a,m);else if(i==="scale"&&!Number.isNaN(c)&&c!==1&&m===void 0){const h=Number.isNaN(+a)?c:a;n=n.scale(c,h,1)}else if(i==="skew"&&(c||!Number.isNaN(c)&&a)&&m===void 0)n=n.skew(c,a||0);else if(["translate","rotate","scale","skew"].some(h=>i.includes(h))&&/[XYZ]/.test(i)&&c&&[a,m].every(h=>h===void 0))if(i==="skewX"||i==="skewY")n=n[i](c);else{const h=i.replace(/[XYZ]/,""),u=i.replace(h,""),x=["X","Y","Z"].indexOf(u),p=h==="scale"?1:0,d=[x===0?c:p,x===1?c:p,x===2?c:p];n=n[h](...d)}else throw TypeError(r)}),n},xt=(e,t)=>t?[e.a,e.b,e.c,e.d,e.e,e.f]:[e.m11,e.m12,e.m13,e.m14,e.m21,e.m22,e.m23,e.m24,e.m31,e.m32,e.m33,e.m34,e.m41,e.m42,e.m43,e.m44],Dt=(e,t,n)=>{const r=new N;return r.m41=e,r.e=e,r.m42=t,r.f=t,r.m43=n,r},Zt=(e,t,n)=>{const r=new N,s=Math.PI/180,i=e*s,o=t*s,l=n*s,c=Math.cos(i),a=-Math.sin(i),m=Math.cos(o),f=-Math.sin(o),y=Math.cos(l),g=-Math.sin(l),h=m*y,u=-m*g;r.m11=h,r.a=h,r.m12=u,r.b=u,r.m13=f;const x=a*f*y+c*g;r.m21=x,r.c=x;const p=c*y-a*f*g;return r.m22=p,r.d=p,r.m23=-a*m,r.m31=a*g-c*f*y,r.m32=a*y+c*f*g,r.m33=c*m,r},Rt=(e,t,n,r)=>{const s=new N,i=Math.sqrt(e*e+t*t+n*n);if(i===0)return s;const o=e/i,l=t/i,c=n/i,a=r*(Math.PI/360),m=Math.sin(a),f=Math.cos(a),y=m*m,g=o*o,h=l*l,u=c*c,x=1-2*(h+u)*y;s.m11=x,s.a=x;const p=2*(o*l*y+c*m*f);s.m12=p,s.b=p,s.m13=2*(o*c*y-l*m*f);const d=2*(l*o*y-c*m*f);s.m21=d,s.c=d;const A=1-2*(u+g)*y;return s.m22=A,s.d=A,s.m23=2*(l*c*y+o*m*f),s.m31=2*(c*o*y+l*m*f),s.m32=2*(c*l*y-o*m*f),s.m33=1-2*(g+h)*y,s},Xt=(e,t,n)=>{const r=new N;return r.m11=e,r.a=e,r.m22=t,r.d=t,r.m33=n,r},lt=(e,t)=>{const n=new N;if(e){const r=e*Math.PI/180,s=Math.tan(r);n.m21=s,n.c=s}if(t){const r=t*Math.PI/180,s=Math.tan(r);n.m12=s,n.b=s}return n},Ft=e=>lt(e,0),Qt=e=>lt(0,e),k=(e,t)=>{const n=t.m11*e.m11+t.m12*e.m21+t.m13*e.m31+t.m14*e.m41,r=t.m11*e.m12+t.m12*e.m22+t.m13*e.m32+t.m14*e.m42,s=t.m11*e.m13+t.m12*e.m23+t.m13*e.m33+t.m14*e.m43,i=t.m11*e.m14+t.m12*e.m24+t.m13*e.m34+t.m14*e.m44,o=t.m21*e.m11+t.m22*e.m21+t.m23*e.m31+t.m24*e.m41,l=t.m21*e.m12+t.m22*e.m22+t.m23*e.m32+t.m24*e.m42,c=t.m21*e.m13+t.m22*e.m23+t.m23*e.m33+t.m24*e.m43,a=t.m21*e.m14+t.m22*e.m24+t.m23*e.m34+t.m24*e.m44,m=t.m31*e.m11+t.m32*e.m21+t.m33*e.m31+t.m34*e.m41,f=t.m31*e.m12+t.m32*e.m22+t.m33*e.m32+t.m34*e.m42,y=t.m31*e.m13+t.m32*e.m23+t.m33*e.m33+t.m34*e.m43,g=t.m31*e.m14+t.m32*e.m24+t.m33*e.m34+t.m34*e.m44,h=t.m41*e.m11+t.m42*e.m21+t.m43*e.m31+t.m44*e.m41,u=t.m41*e.m12+t.m42*e.m22+t.m43*e.m32+t.m44*e.m42,x=t.m41*e.m13+t.m42*e.m23+t.m43*e.m33+t.m44*e.m43,p=t.m41*e.m14+t.m42*e.m24+t.m43*e.m34+t.m44*e.m44;return K([n,r,s,i,o,l,c,a,m,f,y,g,h,u,x,p])};class N{constructor(t){return this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0,this.m11=1,this.m12=0,this.m13=0,this.m14=0,this.m21=0,this.m22=1,this.m23=0,this.m24=0,this.m31=0,this.m32=0,this.m33=1,this.m34=0,this.m41=0,this.m42=0,this.m43=0,this.m44=1,t?this.setMatrixValue(t):this}get isIdentity(){return this.m11===1&&this.m12===0&&this.m13===0&&this.m14===0&&this.m21===0&&this.m22===1&&this.m23===0&&this.m24===0&&this.m31===0&&this.m32===0&&this.m33===1&&this.m34===0&&this.m41===0&&this.m42===0&&this.m43===0&&this.m44===1}get is2D(){return this.m31===0&&this.m32===0&&this.m33===1&&this.m34===0&&this.m43===0&&this.m44===1}setMatrixValue(t){return typeof t=="string"&&t.length&&t!=="none"?Et(t):Array.isArray(t)||t instanceof Float64Array||t instanceof Float32Array?K(t):typeof t=="object"?jt(t):this}toFloat32Array(t){return Float32Array.from(xt(this,t))}toFloat64Array(t){return Float64Array.from(xt(this,t))}toString(){const{is2D:t}=this,n=this.toFloat64Array(t).join(", ");return`${t?"matrix":"matrix3d"}(${n})`}toJSON(){const{is2D:t,isIdentity:n}=this;return{...this,is2D:t,isIdentity:n}}multiply(t){return k(this,t)}translate(t,n,r){const s=t;let i=n,o=r;return typeof i>"u"&&(i=0),typeof o>"u"&&(o=0),k(this,Dt(s,i,o))}scale(t,n,r){const s=t;let i=n,o=r;return typeof i>"u"&&(i=t),typeof o>"u"&&(o=1),k(this,Xt(s,i,o))}rotate(t,n,r){let s=t,i=n||0,o=r||0;return typeof t=="number"&&typeof n>"u"&&typeof r>"u"&&(o=s,s=0,i=0),k(this,Zt(s,i,o))}rotateAxisAngle(t,n,r,s){if([t,n,r,s].some(i=>Number.isNaN(+i)))throw new TypeError("CSSMatrix: expecting 4 values");return k(this,Rt(t,n,r,s))}skewX(t){return k(this,Ft(t))}skewY(t){return k(this,Qt(t))}skew(t,n){return k(this,lt(t,n))}transformPoint(t){const n=this.m11*t.x+this.m21*t.y+this.m31*t.z+this.m41*t.w,r=this.m12*t.x+this.m22*t.y+this.m32*t.z+this.m42*t.w,s=this.m13*t.x+this.m23*t.y+this.m33*t.z+this.m43*t.w,i=this.m14*t.x+this.m24*t.y+this.m34*t.z+this.m44*t.w;return t instanceof DOMPoint?new DOMPoint(n,r,s,i):{x:n,y:r,z:s,w:i}}}C(N,"Translate",Dt),C(N,"Rotate",Zt),C(N,"RotateAxisAngle",Rt),C(N,"Scale",Xt),C(N,"SkewX",Ft),C(N,"SkewY",Qt),C(N,"Skew",lt),C(N,"Multiply",k),C(N,"fromArray",K),C(N,"fromMatrix",jt),C(N,"fromString",Et),C(N,"toArray",xt),C(N,"isCompatibleArray",zt),C(N,"isCompatibleObject",It);const Mt=e=>ct(e)&&e.every(([t])=>t===t.toUpperCase()),X=e=>{if(Mt(e))return[...e];const t=R(e);let n=0,r=0,s=0,i=0;return t.map(o=>{const l=o.slice(1).map(Number),[c]=o,a=c.toUpperCase();if(c==="M")return[n,r]=l,s=n,i=r,["M",n,r];let m=[];if(c!==a)if(a==="A")m=[a,l[0],l[1],l[2],l[3],l[4],l[5]+n,l[6]+r];else if(a==="V")m=[a,l[0]+r];else if(a==="H")m=[a,l[0]+n];else{const f=l.map((y,g)=>y+(g%2?r:n));m=[a,...f]}else m=[a,...l];return a==="Z"?(n=s,r=i):a==="H"?[,n]=m:a==="V"?[,r]=m:([n,r]=m.slice(-2),a==="M"&&(s=n,i=r)),m})},ae=(e,t)=>{const[n]=e,{x1:r,y1:s,x2:i,y2:o}=t,l=e.slice(1).map(Number);let c=e;if("TQ".includes(n)||(t.qx=null,t.qy=null),n==="H")c=["L",e[1],s];else if(n==="V")c=["L",r,e[1]];else if(n==="S"){const a=r*2-i,m=s*2-o;t.x1=a,t.y1=m,c=["C",a,m,...l]}else if(n==="T"){const a=r*2-(t.qx?t.qx:0),m=s*2-(t.qy?t.qy:0);t.qx=a,t.qy=m,c=["Q",a,m,...l]}else if(n==="Q"){const[a,m]=l;t.qx=a,t.qy=m}return c},At=e=>Mt(e)&&e.every(([t])=>"ACLMQZ".includes(t)),mt={x1:0,y1:0,x2:0,y2:0,x:0,y:0,qx:null,qy:null},O=e=>{if(At(e))return[...e];const t=X(e),n={...mt},r=t.length;for(let s=0;s<r;s+=1){t[s],t[s]=ae(t[s],n);const i=t[s],o=i.length;n.x1=+i[o-2],n.y1=+i[o-1],n.x2=+i[o-4]||n.x1,n.y2=+i[o-3]||n.y1}return t},V=(e,t,n)=>{const[r,s]=e,[i,o]=t;return[r+(i-r)*n,s+(o-s)*n]},pt=(e,t,n,r,s)=>{const i=U([e,t],[n,r]);let o={x:0,y:0};if(typeof s=="number")if(s<=0)o={x:e,y:t};else if(s>=i)o={x:n,y:r};else{const[l,c]=V([e,t],[n,r],s/i);o={x:l,y:c}}return{length:i,point:o,min:{x:Math.min(e,n),y:Math.min(t,r)},max:{x:Math.max(e,n),y:Math.max(t,r)}}},wt=(e,t)=>{const{x:n,y:r}=e,{x:s,y:i}=t,o=n*s+r*i,l=Math.sqrt((n**2+r**2)*(s**2+i**2));return(n*i-r*s<0?-1:1)*Math.acos(o/l)},ce=(e,t,n,r,s,i,o,l,c,a)=>{const{abs:m,sin:f,cos:y,sqrt:g,PI:h}=Math;let u=m(n),x=m(r);const d=(s%360+360)%360*(h/180);if(e===l&&t===c)return{x:e,y:t};if(u===0||x===0)return pt(e,t,l,c,a).point;const A=(e-l)/2,b=(t-c)/2,M={x:y(d)*A+f(d)*b,y:-f(d)*A+y(d)*b},w=M.x**2/u**2+M.y**2/x**2;w>1&&(u*=g(w),x*=g(w));const $=u**2*x**2-u**2*M.y**2-x**2*M.x**2,F=u**2*M.y**2+x**2*M.x**2;let E=$/F;E=E<0?0:E;const _=(i!==o?1:-1)*g(E),S={x:_*(u*M.y/x),y:_*(-(x*M.x)/u)},W={x:y(d)*S.x-f(d)*S.y+(e+l)/2,y:f(d)*S.x+y(d)*S.y+(t+c)/2},Q={x:(M.x-S.x)/u,y:(M.y-S.y)/x},tt=wt({x:1,y:0},Q),et={x:(-M.x-S.x)/u,y:(-M.y-S.y)/x};let T=wt(Q,et);!o&&T>0?T-=2*h:o&&T<0&&(T+=2*h),T%=2*h;const L=tt+T*a,H=u*y(L),Y=x*f(L);return{x:y(d)*H-f(d)*Y+W.x,y:f(d)*H+y(d)*Y+W.y}},le=(e,t,n,r,s,i,o,l,c,a)=>{const m=typeof a=="number";let f=e,y=t,g=0,h=[f,y,g],u=[f,y],x=0,p={x:0,y:0},d=[{x:f,y}];m&&a<=0&&(p={x:f,y});const A=300;for(let b=0;b<=A;b+=1){if(x=b/A,{x:f,y}=ce(e,t,n,r,s,i,o,l,c,x),d=[...d,{x:f,y}],g+=U(u,[f,y]),u=[f,y],m&&g>a&&a>h[2]){const M=(g-a)/(g-h[2]);p={x:u[0]*(1-M)+h[0]*M,y:u[1]*(1-M)+h[1]*M}}h=[f,y,g]}return m&&a>=g&&(p={x:l,y:c}),{length:g,point:p,min:{x:Math.min(...d.map(b=>b.x)),y:Math.min(...d.map(b=>b.y))},max:{x:Math.max(...d.map(b=>b.x)),y:Math.max(...d.map(b=>b.y))}}},me=(e,t,n,r,s,i,o,l,c)=>{const a=1-c;return{x:a**3*e+3*a**2*c*n+3*a*c**2*s+c**3*o,y:a**3*t+3*a**2*c*r+3*a*c**2*i+c**3*l}},he=(e,t,n,r,s,i,o,l,c)=>{const a=typeof c=="number";let m=e,f=t,y=0,g=[m,f,y],h=[m,f],u=0,x={x:0,y:0},p=[{x:m,y:f}];a&&c<=0&&(x={x:m,y:f});const d=300;for(let A=0;A<=d;A+=1){if(u=A/d,{x:m,y:f}=me(e,t,n,r,s,i,o,l,u),p=[...p,{x:m,y:f}],y+=U(h,[m,f]),h=[m,f],a&&y>c&&c>g[2]){const b=(y-c)/(y-g[2]);x={x:h[0]*(1-b)+g[0]*b,y:h[1]*(1-b)+g[1]*b}}g=[m,f,y]}return a&&c>=y&&(x={x:o,y:l}),{length:y,point:x,min:{x:Math.min(...p.map(A=>A.x)),y:Math.min(...p.map(A=>A.y))},max:{x:Math.max(...p.map(A=>A.x)),y:Math.max(...p.map(A=>A.y))}}},ue=(e,t,n,r,s,i,o)=>{const l=1-o;return{x:l**2*e+2*l*o*n+o**2*s,y:l**2*t+2*l*o*r+o**2*i}},fe=(e,t,n,r,s,i,o)=>{const l=typeof o=="number";let c=e,a=t,m=0,f=[c,a,m],y=[c,a],g=0,h={x:0,y:0},u=[{x:c,y:a}];l&&o<=0&&(h={x:c,y:a});const x=300;for(let p=0;p<=x;p+=1){if(g=p/x,{x:c,y:a}=ue(e,t,n,r,s,i,g),u=[...u,{x:c,y:a}],m+=U(y,[c,a]),y=[c,a],l&&m>o&&o>f[2]){const d=(m-o)/(m-f[2]);h={x:y[0]*(1-d)+f[0]*d,y:y[1]*(1-d)+f[1]*d}}f=[c,a,m]}return l&&o>=m&&(h={x:s,y:i}),{length:m,point:h,min:{x:Math.min(...u.map(p=>p.x)),y:Math.min(...u.map(p=>p.y))},max:{x:Math.max(...u.map(p=>p.x)),y:Math.max(...u.map(p=>p.y))}}},ht=(e,t)=>{const n=O(e),r=typeof t=="number";let s,i=[],o,l=0,c=0,a=0,m=0,f,y=[],g=[],h=0,u={x:0,y:0},x=u,p=u,d=u,A=0;for(let b=0,M=n.length;b<M;b+=1)f=n[b],[o]=f,s=o==="M",i=s?i:[l,c,...f.slice(1)],s?([,a,m]=f,u={x:a,y:m},x=u,h=0,r&&t<.001&&(d=u)):o==="L"?{length:h,min:u,max:x,point:p}=pt(...i,(t||0)-A):o==="A"?{length:h,min:u,max:x,point:p}=le(...i,(t||0)-A):o==="C"?{length:h,min:u,max:x,point:p}=he(...i,(t||0)-A):o==="Q"?{length:h,min:u,max:x,point:p}=fe(...i,(t||0)-A):o==="Z"&&(i=[l,c,a,m],{length:h,min:u,max:x,point:p}=pt(...i,(t||0)-A)),r&&A<t&&A+h>=t&&(d=p),g=[...g,x],y=[...y,u],A+=h,[l,c]=o!=="Z"?f.slice(-2):[a,m];return r&&t>=A&&(d={x:l,y:c}),{length:A,point:d,min:{x:Math.min(...y.map(b=>b.x)),y:Math.min(...y.map(b=>b.y))},max:{x:Math.max(...g.map(b=>b.x)),y:Math.max(...g.map(b=>b.y))}}},vt=e=>{if(!e)return{x:0,y:0,width:0,height:0,x2:0,y2:0,cx:0,cy:0,cz:0};const{min:{x:t,y:n},max:{x:r,y:s}}=ht(e),i=r-t,o=s-n;return{width:i,height:o,x:t,y:n,x2:r,y2:s,cx:t+i/2,cy:n+o/2,cz:Math.max(i,o)+Math.min(i,o)/2}},dt=(e,t,n)=>{if(e[n].length>7){e[n].shift();const r=e[n];let s=n;for(;r.length;)t[n]="A",e.splice(s+=1,0,["C",...r.splice(0,6)]);e.splice(n,1)}},Ht=e=>At(e)&&e.every(([t])=>"MC".includes(t)),nt=(e,t,n)=>{const r=e*Math.cos(n)-t*Math.sin(n),s=e*Math.sin(n)+t*Math.cos(n);return{x:r,y:s}},Yt=(e,t,n,r,s,i,o,l,c,a)=>{let m=e,f=t,y=n,g=r,h=l,u=c;const x=Math.PI*120/180,p=Math.PI/180*(+s||0);let d=[],A,b,M,w,$;if(a)[b,M,w,$]=a;else{A=nt(m,f,-p),m=A.x,f=A.y,A=nt(h,u,-p),h=A.x,u=A.y;const P=(m-h)/2,v=(f-u)/2;let z=P*P/(y*y)+v*v/(g*g);z>1&&(z=Math.sqrt(z),y*=z,g*=z);const yt=y*y,gt=g*g,Pt=(i===o?-1:1)*Math.sqrt(Math.abs((yt*gt-yt*v*v-gt*P*P)/(yt*v*v+gt*P*P)));w=Pt*y*v/g+(m+h)/2,$=Pt*-g*P/y+(f+u)/2,b=Math.asin(((f-$)/g*10**9>>0)/10**9),M=Math.asin(((u-$)/g*10**9>>0)/10**9),b=m<w?Math.PI-b:b,M=h<w?Math.PI-M:M,b<0&&(b=Math.PI*2+b),M<0&&(M=Math.PI*2+M),o&&b>M&&(b-=Math.PI*2),!o&&M>b&&(M-=Math.PI*2)}let F=M-b;if(Math.abs(F)>x){const P=M,v=h,z=u;M=b+x*(o&&M>b?1:-1),h=w+y*Math.cos(M),u=$+g*Math.sin(M),d=Yt(h,u,y,g,s,0,o,v,z,[M,P,w,$])}F=M-b;const E=Math.cos(b),_=Math.sin(b),S=Math.cos(M),W=Math.sin(M),Q=Math.tan(F/4),tt=4/3*y*Q,et=4/3*g*Q,T=[m,f],L=[m+tt*_,f-et*E],H=[h+tt*W,u-et*S],Y=[h,u];if(L[0]=2*T[0]-L[0],L[1]=2*T[1]-L[1],a)return[...L,...H,...Y,...d];d=[...L,...H,...Y,...d];const ft=[];for(let P=0,v=d.length;P<v;P+=1)ft[P]=P%2?nt(d[P-1],d[P],p).y:nt(d[P],d[P+1],p).x;return ft},ye=(e,t,n,r,s,i)=>{const o=.3333333333333333,l=2/3;return[o*e+l*n,o*t+l*r,o*s+l*n,o*i+l*r,s,i]},St=(e,t,n,r)=>[...V([e,t],[n,r],.5),n,r,n,r],rt=(e,t)=>{const[n]=e,r=e.slice(1).map(Number),[s,i]=r;let o;const{x1:l,y1:c,x:a,y:m}=t;return"TQ".includes(n)||(t.qx=null,t.qy=null),n==="M"?(t.x=s,t.y=i,e):n==="A"?(o=[l,c,...r],["C",...Yt(...o)]):n==="Q"?(t.qx=s,t.qy=i,o=[l,c,...r],["C",...ye(...o)]):n==="L"?["C",...St(l,c,s,i)]:n==="Z"?["C",...St(l,c,a,m)]:e},it=e=>{if(Ht(e))return[...e];const t=O(e),n={...mt},r=[];let s="",i=t.length;for(let o=0;o<i;o+=1){[s]=t[o],r[o]=s,t[o]=rt(t[o],n),dt(t,r,o),i=t.length;const l=t[o],c=l.length;n.x1=+l[c-2],n.y1=+l[c-1],n.x2=+l[c-4]||n.x1,n.y2=+l[c-3]||n.y1}return t},ge=(e,t,n,r,s,i,o,l)=>3*((l-t)*(n+s)-(o-e)*(r+i)+r*(e-s)-n*(t-i)+l*(s+e/3)-o*(i+t/3))/20,Bt=e=>{let t=0,n=0,r=0;return it(e).map(s=>{switch(s[0]){case"M":return[,t,n]=s,0;default:return r=ge(t,n,...s.slice(1)),[t,n]=s.slice(-2),r}}).reduce((s,i)=>s+i,0)},Z=e=>ht(e).length,xe=e=>Bt(it(e))>=0,J=(e,t)=>ht(e,t).point,Nt=(e,t)=>{const n=R(e);let r=[...n],s=Z(r),i=r.length-1,o=0,l=0,c=n[0];const[a,m]=c.slice(-2),f={x:a,y:m};if(i<=0||!t||!Number.isFinite(t))return{segment:c,index:0,length:l,point:f,lengthAtSegment:o};if(t>=s)return r=n.slice(0,-1),o=Z(r),l=s-o,{segment:n[i],index:i,length:l,lengthAtSegment:o};const y=[];for(;i>0;)c=r[i],r=r.slice(0,-1),o=Z(r),l=s-o,s=o,y.push({segment:c,index:i,length:l,lengthAtSegment:o}),i-=1;return y.find(({lengthAtSegment:g})=>g<=t)},ut=(e,t)=>{const n=R(e),r=O(n),s=Z(n),i=b=>{const M=b.x-t.x,w=b.y-t.y;return M*M+w*w};let o=8,l,c={x:0,y:0},a=0,m=0,f=1/0;for(let b=0;b<=s;b+=o)l=J(r,b),a=i(l),a<f&&(c=l,m=b,f=a);o/=2;let y,g,h=0,u=0,x=0,p=0;for(;o>.5;)h=m-o,y=J(r,h),x=i(y),u=m+o,g=J(r,u),p=i(g),h>=0&&x<f?(c=y,m=h,f=x):u<=s&&p<f?(c=g,m=u,f=p):o/=2;const d=Nt(n,m),A=Math.sqrt(f);return{closest:c,distance:A,segment:d}},pe=(e,t)=>ut(e,t).closest,de=(e,t)=>ut(e,t).segment,be=(e,t)=>Nt(e,t).segment,Me=(e,t)=>{const{distance:n}=ut(e,t);return Math.abs(n)<.001},Gt=e=>{if(typeof e!="string")return!1;const t=new Ot(e);for(G(t);t.index<t.max&&!t.err.length;)Vt(t);return!t.err.length&&"mM".includes(t.segments[0][0])},Jt=e=>ct(e)&&e.slice(1).every(([t])=>t===t.toLowerCase()),ot=(e,t)=>{let{round:n}=at;if(t==="off"||n==="off")return[...e];n=typeof t=="number"&&t>=0?t:n;const r=typeof n=="number"&&n>=1?10**n:1;return e.map(s=>{const i=s.slice(1).map(Number).map(o=>n?Math.round(o*r)/r:Math.round(o));return[s[0],...i]})},j=(e,t)=>ot(e,t).map(n=>n[0]+n.slice(1).join(" ")).join(""),Tt={line:["x1","y1","x2","y2"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],rect:["width","height","x","y","rx","ry"],polygon:["points"],polyline:["points"],glyph:["d"]},Ae=e=>{const{x1:t,y1:n,x2:r,y2:s}=e;return[["M",t,n],["L",r,s]]},Ne=e=>{const t=[],n=(e.points||"").trim().split(/[\s|,]/).map(Number);let r=0;for(;r<n.length;)t.push([r?"L":"M",n[r],n[r+1]]),r+=2;return e.type==="polygon"?[...t,["z"]]:t},Pe=e=>{const{cx:t,cy:n,r}=e;return[["M",t-r,n],["a",r,r,0,1,0,2*r,0],["a",r,r,0,1,0,-2*r,0]]},Ce=e=>{const{cx:t,cy:n,rx:r,ry:s}=e;return[["M",t-r,n],["a",r,s,0,1,0,2*r,0],["a",r,s,0,1,0,-2*r,0]]},we=e=>{const t=+e.x||0,n=+e.y||0,r=+e.width,s=+e.height;let i=+e.rx,o=+e.ry;return i||o?(i=i||o,o=o||i,i*2>r&&(i-=(i*2-r)/2),o*2>s&&(o-=(o*2-s)/2),[["M",t+i,n],["h",r-i*2],["s",i,0,i,o],["v",s-o*2],["s",0,o,-i,o],["h",-r+i*2],["s",-i,0,-i,-o],["v",-s+o*2],["s",0,-o,i,-o]]):[["M",t,n],["h",r],["v",s],["H",t],["Z"]]},ve=(e,t,n)=>{const r=n||document,s=r.defaultView||window,i=Object.keys(Tt),o=e instanceof s.SVGElement,l=o?e.tagName:null;if(l&&i.every(h=>l!==h))throw TypeError(`${q}: "${l}" is not SVGElement`);const c=r.createElementNS("http://www.w3.org/2000/svg","path"),a=o?l:e.type,m=Tt[a],f={type:a};o?(m.forEach(h=>{m.includes(h)&&(f[h]=e.getAttribute(h))}),Object.values(e.attributes).forEach(({name:h,value:u})=>{m.includes(h)||c.setAttribute(h,u)})):(Object.assign(f,e),Object.keys(f).forEach(h=>{!m.includes(h)&&h!=="type"&&c.setAttribute(h.replace(/[A-Z]/g,u=>`-${u.toLowerCase()}`),f[h])}));let y="";const g=at.round;return a==="circle"?y=j(Pe(f),g):a==="ellipse"?y=j(Ce(f),g):["polyline","polygon"].includes(a)?y=j(Ne(f),g):a==="rect"?y=j(we(f),g):a==="line"?y=j(Ae(f),g):a==="glyph"&&(y=o?e.getAttribute("d"):e.d),Gt(y)?(c.setAttribute("d",y),t&&o&&(e.before(c,e),e.remove()),c):!1},Lt=e=>{const t=[];let n,r=-1;return e.forEach(s=>{s[0]==="M"?(n=[s],r+=1):n=[...n,s],t[r]=n}),t},bt=e=>{if(Jt(e))return[...e];const t=R(e);let n=0,r=0,s=0,i=0;return t.map(o=>{const l=o.slice(1).map(Number),[c]=o,a=c.toLowerCase();if(c==="M")return[n,r]=l,s=n,i=r,["M",n,r];let m=[];if(c!==a)if(a==="a")m=[a,l[0],l[1],l[2],l[3],l[4],l[5]-n,l[6]-r];else if(a==="v")m=[a,l[0]-r];else if(a==="h")m=[a,l[0]-n];else{const y=l.map((g,h)=>g-(h%2?r:n));m=[a,...y]}else c==="m"&&(s=l[0]+n,i=l[1]+r),m=[a,...l];const f=m.length;return a==="z"?(n=s,r=i):a==="h"?n+=m[1]:a==="v"?r+=m[1]:(n+=m[f-2],r+=m[f-1]),m})},Se=(e,t,n,r)=>{const[s]=e,i=p=>Math.round(p*10**4)/10**4,o=e.slice(1).map(p=>+p),l=t.slice(1).map(p=>+p),{x1:c,y1:a,x2:m,y2:f,x:y,y:g}=n;let h=e;const[u,x]=l.slice(-2);if("TQ".includes(s)||(n.qx=null,n.qy=null),["V","H","S","T","Z"].includes(s))h=[s,...o];else if(s==="L")i(y)===i(u)?h=["V",x]:i(g)===i(x)&&(h=["H",u]);else if(s==="C"){const[p,d]=l;"CS".includes(r)&&(i(p)===i(c*2-m)&&i(d)===i(a*2-f)||i(c)===i(m*2-y)&&i(a)===i(f*2-g))&&(h=["S",...l.slice(-4)]),n.x1=p,n.y1=d}else if(s==="Q"){const[p,d]=l;n.qx=p,n.qy=d,"QT".includes(r)&&(i(p)===i(c*2-m)&&i(d)===i(a*2-f)||i(c)===i(m*2-y)&&i(a)===i(f*2-g))&&(h=["T",...l.slice(-2)])}return h},kt=(e,t)=>{const n=X(e),r=O(n),s={...mt},i=[],o=n.length;let l="",c="",a=0,m=0,f=0,y=0;for(let u=0;u<o;u+=1){[l]=n[u],i[u]=l,u&&(c=i[u-1]),n[u]=Se(n[u],r[u],s,c);const x=n[u],p=x.length;switch(s.x1=+x[p-2],s.y1=+x[p-1],s.x2=+x[p-4]||s.x1,s.y2=+x[p-3]||s.y1,l){case"Z":a=f,m=y;break;case"H":[,a]=x;break;case"V":[,m]=x;break;default:[a,m]=x.slice(-2).map(Number),l==="M"&&(f=a,y=m)}s.x=a,s.y=m}const g=ot(n,t),h=ot(bt(n),t);return g.map((u,x)=>x?u.join("").length<h[x].join("").length?u:h[x]:u)},Te=e=>{const t=e.slice(1).map((n,r,s)=>r?[...s[r-1].slice(-2),...n.slice(1)]:[...e[0].slice(1),...n.slice(1)]).map(n=>n.map((r,s)=>n[n.length-s-2*(1-s%2)])).reverse();return[["M",...t[0].slice(0,2)],...t.map(n=>["C",...n.slice(2)])]},st=e=>{const t=X(e),n=t.slice(-1)[0][0]==="Z",r=O(t).map((s,i)=>{const[o,l]=s.slice(-2).map(Number);return{seg:t[i],n:s,c:t[i][0],x:o,y:l}}).map((s,i,o)=>{const l=s.seg,c=s.n,a=i&&o[i-1],m=o[i+1],f=s.c,y=o.length,g=i?o[i-1].x:o[y-1].x,h=i?o[i-1].y:o[y-1].y;let u=[];switch(f){case"M":u=n?["Z"]:[f,g,h];break;case"A":u=[f,...l.slice(1,-3),l[5]===1?0:1,g,h];break;case"C":m&&m.c==="S"?u=["S",l[1],l[2],g,h]:u=[f,l[3],l[4],l[1],l[2],g,h];break;case"S":a&&"CS".includes(a.c)&&(!m||m.c!=="S")?u=["C",c[3],c[4],c[1],c[2],g,h]:u=[f,c[1],c[2],g,h];break;case"Q":m&&m.c==="T"?u=["T",g,h]:u=[f,...l.slice(1,-2),g,h];break;case"T":a&&"QT".includes(a.c)&&(!m||m.c!=="T")?u=["Q",c[1],c[2],g,h]:u=[f,g,h];break;case"Z":u=["M",g,h];break;case"H":u=[f,g];break;case"V":u=[f,h];break;default:u=[f,...l.slice(1,-2),g,h]}return u});return n?r.reverse():[r[0],...r.slice(1).reverse()]},Le=e=>{let t=new N;const{origin:n}=e,[r,s]=n,{translate:i}=e,{rotate:o}=e,{skew:l}=e,{scale:c}=e;return Array.isArray(i)&&i.length>=2&&i.every(a=>!Number.isNaN(+a))&&i.some(a=>a!==0)?t=t.translate(...i):typeof i=="number"&&!Number.isNaN(i)&&(t=t.translate(i)),(o||l||c)&&(t=t.translate(r,s),Array.isArray(o)&&o.length>=2&&o.every(a=>!Number.isNaN(+a))&&o.some(a=>a!==0)?t=t.rotate(...o):typeof o=="number"&&!Number.isNaN(o)&&(t=t.rotate(o)),Array.isArray(l)&&l.length===2&&l.every(a=>!Number.isNaN(+a))&&l.some(a=>a!==0)?(t=l[0]?t.skewX(l[0]):t,t=l[1]?t.skewY(l[1]):t):typeof l=="number"&&!Number.isNaN(l)&&(t=t.skewX(l)),Array.isArray(c)&&c.length>=2&&c.every(a=>!Number.isNaN(+a))&&c.some(a=>a!==1)?t=t.scale(...c):typeof c=="number"&&!Number.isNaN(c)&&(t=t.scale(c)),t=t.translate(-r,-s)),t},ke=(e,t)=>{let n=N.Translate(...t.slice(0,-1));return[,,,n.m44]=t,n=e.multiply(n),[n.m41,n.m42,n.m43,n.m44]},qt=(e,t,n)=>{const[r,s,i]=n,[o,l,c]=ke(e,[...t,0,1]),a=o-r,m=l-s,f=c-i;return[a*(Math.abs(i)/Math.abs(f)||1)+r,m*(Math.abs(i)/Math.abs(f)||1)+s]},$t=(e,t)=>{let n=0,r=0,s,i,o,l,c,a;const m=X(e),f=t&&Object.keys(t);if(!t||f&&!f.length)return[...m];const y=O(m);if(!t.origin){const{origin:M}=at;Object.assign(t,{origin:M})}const g=Le(t),{origin:h}=t,u={...mt};let x=[],p=0,d="",A=[];const b=[];if(!g.isIdentity){for(s=0,o=m.length;s<o;s+=1){x=m[s],m[s]&&([d]=x),b[s]=d,d==="A"&&(x=rt(y[s],u),m[s]=rt(y[s],u),dt(m,b,s),y[s]=rt(y[s],u),dt(y,b,s),o=Math.max(m.length,y.length)),x=y[s],p=x.length,u.x1=+x[p-2],u.y1=+x[p-1],u.x2=+x[p-4]||u.x1,u.y2=+x[p-3]||u.y1;const M={s:m[s],c:m[s][0],x:u.x1,y:u.y1};A=[...A,M]}return A.map(M=>{if(d=M.c,x=M.s,d==="L"||d==="H"||d==="V")return[c,a]=qt(g,[M.x,M.y],h),n!==c&&r!==a?x=["L",c,a]:r===a?x=["H",c]:n===c&&(x=["V",a]),n=c,r=a,x;for(i=1,l=x.length;i<l;i+=2)[n,r]=qt(g,[+x[i],+x[i+1]],h),x[i]=n,x[i+1]=r;return x})}return[...m]},qe=e=>{const n=e.slice(0,2),r=e.slice(2,4),s=e.slice(4,6),i=e.slice(6,8),o=V(n,r,.5),l=V(r,s,.5),c=V(s,i,.5),a=V(o,l,.5),m=V(l,c,.5),f=V(a,m,.5);return[["C",...o,...a,...f],["C",...m,...c,...i]]};class $e{static CSSMatrix=N;static getPathBBox=vt;static getPathArea=Bt;static getTotalLength=Z;static getDrawDirection=xe;static getPointAtLength=J;static pathLengthFactory=ht;static getPropertiesAtLength=Nt;static getPropertiesAtPoint=ut;static polygonLength=se;static polygonArea=ne;static getClosestPoint=pe;static getSegmentOfPoint=de;static getSegmentAtLength=be;static isPointInStroke=Me;static isValidPath=Gt;static isPathArray=ct;static isAbsoluteArray=Mt;static isRelativeArray=Jt;static isCurveArray=Ht;static isNormalizedArray=At;static shapeToPath=ve;static parsePathString=R;static roundPath=ot;static splitPath=Lt;static splitCubic=qe;static optimizePath=kt;static reverseCurve=Te;static reversePath=st;static normalizePath=O;static transformPath=$t;static pathToAbsolute=X;static pathToRelative=bt;static pathToCurve=it;static pathToString=j;constructor(t,n){const r=n||{},s=typeof t>"u";if(s||!t.length)throw TypeError(`${q}: "pathValue" is ${s?"undefined":"empty"}`);const i=R(t);this.segments=i;const{width:o,height:l,cx:c,cy:a,cz:m}=this.getBBox(),{round:f,origin:y}=r;let g;if(f==="auto"){const u=`${Math.floor(Math.max(o,l))}`.length;g=u>=4?0:4-u}else Number.isInteger(f)||f==="off"?g=f:g=at.round;let h;if(Array.isArray(y)&&y.length>=2){const[u,x,p]=y.map(Number);h=[Number.isNaN(u)?c:u,Number.isNaN(x)?a:x,Number.isNaN(p)?m:p]}else h=[c,a,m];return this.round=g,this.origin=h,this}getBBox(){return vt(this.segments)}getTotalLength(){return Z(this.segments)}getPointAtLength(t){return J(this.segments,t)}toAbsolute(){const{segments:t}=this;return this.segments=X(t),this}toRelative(){const{segments:t}=this;return this.segments=bt(t),this}toCurve(){const{segments:t}=this;return this.segments=it(t),this}reverse(t){this.toAbsolute();const{segments:n}=this,r=Lt(n),s=r.length>1?r:!1,i=s?[...s].map((l,c)=>t?c?st(l):[...l]:st(l)):[...n];let o=[];return s?o=i.flat(1):o=t?n:st(n),this.segments=[...o],this}normalize(){const{segments:t}=this;return this.segments=O(t),this}optimize(){const{segments:t}=this;return this.segments=kt(t,this.round),this}transform(t){if(!t||typeof t!="object"||typeof t=="object"&&!["translate","rotate","skew","scale"].some(c=>c in t))return this;const{segments:n,origin:[r,s,i]}=this,o={};for(const[c,a]of Object.entries(t))c==="skew"&&Array.isArray(a)||(c==="rotate"||c==="translate"||c==="origin"||c==="scale")&&Array.isArray(a)?o[c]=a.map(Number):c!=="origin"&&typeof Number(a)=="number"&&(o[c]=Number(a));const{origin:l}=o;if(Array.isArray(l)&&l.length>=2){const[c,a,m]=l.map(Number);o.origin=[Number.isNaN(c)?r:c,Number.isNaN(a)?s:a,m||i]}else o.origin=[r,s,i];return this.segments=$t(n,o),this}flipX(){return this.transform({rotate:[0,180,0]}),this}flipY(){return this.transform({rotate:[180,0,0]}),this}toString(){return j(this.segments,this.round)}}module.exports=$e;
2
+ //# sourceMappingURL=svg-path-commander.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"svg-path-commander.cjs","sources":["../src/options/options.ts","../src/parser/error.ts","../src/parser/paramsCount.ts","../src/parser/finalizeSegment.ts","../src/parser/scanFlag.ts","../src/parser/isDigit.ts","../src/parser/invalidPathValue.ts","../src/parser/scanParam.ts","../src/parser/isSpace.ts","../src/parser/skipSpaces.ts","../src/parser/isPathCommand.ts","../src/parser/isDigitStart.ts","../src/parser/isArcCommand.ts","../src/parser/scanSegment.ts","../src/parser/pathParser.ts","../src/util/isPathArray.ts","../src/parser/parsePathString.ts","../src/math/polygonArea.ts","../src/math/distanceSquareRoot.ts","../src/math/polygonLength.ts","../node_modules/@thednp/dommatrix/dist/dommatrix.mjs","../src/util/isAbsoluteArray.ts","../src/convert/pathToAbsolute.ts","../src/process/normalizeSegment.ts","../src/util/isNormalizedArray.ts","../src/parser/paramsParser.ts","../src/process/normalizePath.ts","../src/math/midPoint.ts","../src/util/segmentLineFactory.ts","../src/util/segmentArcFactory.ts","../src/util/segmentCubicFactory.ts","../src/util/segmentQuadFactory.ts","../src/util/pathLengthFactory.ts","../src/util/getPathBBox.ts","../src/process/fixArc.ts","../src/util/isCurveArray.ts","../src/math/rotateVector.ts","../src/process/arcToCubic.ts","../src/process/quadToCubic.ts","../src/process/lineToCubic.ts","../src/process/segmentToCubic.ts","../src/convert/pathToCurve.ts","../src/util/getPathArea.ts","../src/util/getTotalLength.ts","../src/util/getDrawDirection.ts","../src/util/getPointAtLength.ts","../src/util/getPropertiesAtLength.ts","../src/util/getPropertiesAtPoint.ts","../src/util/getClosestPoint.ts","../src/util/getSegmentOfPoint.ts","../src/util/getSegmentAtLength.ts","../src/util/isPointInStroke.ts","../src/util/isValidPath.ts","../src/util/isRelativeArray.ts","../src/process/roundPath.ts","../src/convert/pathToString.ts","../src/util/shapeToPath.ts","../src/process/splitPath.ts","../src/convert/pathToRelative.ts","../src/process/shortenSegment.ts","../src/process/optimizePath.ts","../src/process/reverseCurve.ts","../src/process/reversePath.ts","../src/process/getSVGMatrix.ts","../src/process/projection2d.ts","../src/process/transformPath.ts","../src/process/splitCubic.ts","../src/index.ts"],"sourcesContent":["import { Options } from '../interface';\n\n/** SVGPathCommander default options */\nconst defaultOptions: Options = {\n origin: [0, 0, 0],\n round: 4,\n};\n\nexport default defaultOptions;\n","const error = 'SVGPathCommander Error';\nexport default error;\n","/** Segment params length */\nconst paramsCount = {\n a: 7,\n c: 6,\n h: 1,\n l: 2,\n m: 2,\n r: 4,\n q: 4,\n s: 4,\n t: 2,\n v: 1,\n z: 0,\n};\n\nexport default paramsCount;\n","import paramsCount from './paramsCount';\nimport PathParser from './pathParser';\nimport type { PathCommand, PathSegment, RelativeCommand } from '../types';\n\n/**\n * Breaks the parsing of a pathString once a segment is finalized.\n *\n * @param path the `PathParser` instance\n */\nconst finalizeSegment = (path: PathParser) => {\n let pathCommand = path.pathValue[path.segmentStart] as PathCommand;\n let LK = pathCommand.toLowerCase() as RelativeCommand;\n const { data } = path;\n\n while (data.length >= paramsCount[LK]) {\n // overloaded `moveTo`\n // https://github.com/rveciana/svg-path-properties/blob/master/src/parse.ts\n if (LK === 'm' && data.length > 2) {\n path.segments.push([pathCommand, ...(data.splice(0, 2) as number[])] as PathSegment);\n LK = 'l';\n pathCommand = pathCommand === 'm' ? 'l' : 'L';\n } else {\n path.segments.push([pathCommand, ...(data.splice(0, paramsCount[LK]) as number[])] as PathSegment);\n }\n\n if (!paramsCount[LK]) {\n break;\n }\n }\n};\nexport default finalizeSegment;\n","import error from './error';\nimport type PathParser from './pathParser';\n\n/**\n * Validates an A (arc-to) specific path command value.\n * Usually a `large-arc-flag` or `sweep-flag`.\n *\n * @param path the `PathParser` instance\n */\nconst scanFlag = (path: PathParser) => {\n const { index, pathValue } = path;\n const code = pathValue.charCodeAt(index);\n\n if (code === 0x30 /* 0 */) {\n path.param = 0;\n path.index += 1;\n return;\n }\n\n if (code === 0x31 /* 1 */) {\n path.param = 1;\n path.index += 1;\n return;\n }\n\n path.err = `${error}: invalid Arc flag \"${pathValue[index]}\", expecting 0 or 1 at index ${index}`;\n};\n\nexport default scanFlag;\n","import { DigitNumber } from '../types';\n\n/**\n * Checks if a character is a digit.\n *\n * @param code the character to check\n * @returns check result\n */\nconst isDigit = (code: number): code is DigitNumber => {\n return code >= 48 && code <= 57; // 0..9\n};\nexport default isDigit;\n","const invalidPathValue = 'Invalid path value';\nexport default invalidPathValue;\n","import isDigit from './isDigit';\nimport invalidPathValue from './invalidPathValue';\nimport error from './error';\nimport type PathParser from './pathParser';\n\n/**\n * Validates every character of the path string,\n * every path command, negative numbers or floating point numbers.\n *\n * @param path the `PathParser` instance\n */\nconst scanParam = (path: PathParser) => {\n const { max, pathValue, index: start } = path;\n let index = start;\n let zeroFirst = false;\n let hasCeiling = false;\n let hasDecimal = false;\n let hasDot = false;\n let ch;\n\n if (index >= max) {\n path.err = `${error}: ${invalidPathValue} at index ${index}, \"pathValue\" is missing param`;\n return;\n }\n ch = pathValue.charCodeAt(index);\n\n if (ch === 0x2b /* + */ || ch === 0x2d /* - */) {\n index += 1;\n // ch = (index < max) ? pathValue.charCodeAt(index) : 0;\n ch = pathValue.charCodeAt(index);\n }\n\n // This logic is shamelessly borrowed from Esprima\n // https://github.com/ariya/esprimas\n if (!isDigit(ch) && ch !== 0x2e /* . */) {\n // path.err = 'SvgPath: param should start with 0..9 or `.` (at pos ' + index + ')';\n path.err = `${error}: ${invalidPathValue} at index ${index}, \"${pathValue[index]}\" is not a number`;\n return;\n }\n\n if (ch !== 0x2e /* . */) {\n zeroFirst = ch === 0x30 /* 0 */;\n index += 1;\n\n ch = pathValue.charCodeAt(index);\n\n if (zeroFirst && index < max) {\n // decimal number starts with '0' such as '09' is illegal.\n if (ch && isDigit(ch)) {\n // path.err = 'SvgPath: numbers started with `0` such as `09`\n // are illegal (at pos ' + start + ')';\n path.err = `${error}: ${invalidPathValue} at index ${start}, \"${pathValue[start]}\" illegal number`;\n return;\n }\n }\n\n while (index < max && isDigit(pathValue.charCodeAt(index))) {\n index += 1;\n hasCeiling = true;\n }\n\n ch = pathValue.charCodeAt(index);\n }\n\n if (ch === 0x2e /* . */) {\n hasDot = true;\n index += 1;\n while (isDigit(pathValue.charCodeAt(index))) {\n index += 1;\n hasDecimal = true;\n }\n\n ch = pathValue.charCodeAt(index);\n }\n\n if (ch === 0x65 /* e */ || ch === 0x45 /* E */) {\n if (hasDot && !hasCeiling && !hasDecimal) {\n path.err = `${error}: ${invalidPathValue} at index ${index}, \"${pathValue[index]}\" invalid float exponent`;\n return;\n }\n\n index += 1;\n\n ch = pathValue.charCodeAt(index);\n\n if (ch === 0x2b /* + */ || ch === 0x2d /* - */) {\n index += 1;\n }\n if (index < max && isDigit(pathValue.charCodeAt(index))) {\n while (index < max && isDigit(pathValue.charCodeAt(index))) {\n index += 1;\n }\n } else {\n path.err = `${error}: ${invalidPathValue} at index ${index}, \"${pathValue[index]}\" invalid integer exponent`;\n return;\n }\n }\n\n path.index = index;\n path.param = +path.pathValue.slice(start, index);\n};\nexport default scanParam;\n","import type { SpaceNumber } from '../types';\n\n/**\n * Checks if the character is a space.\n *\n * @param ch the character to check\n * @returns check result\n */\n\nconst isSpace = (ch: number): ch is SpaceNumber => {\n const allSpaces = [\n // Special spaces\n 0x1680, 0x180e, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200a, 0x202f,\n 0x205f, 0x3000, 0xfeff,\n // Line terminators\n 0x0a, 0x0d, 0x2028, 0x2029,\n // White spaces\n 0x20, 0x09, 0x0b, 0x0c, 0xa0,\n ];\n\n return allSpaces.includes(ch);\n};\nexport default isSpace;\n","import isSpace from './isSpace';\nimport type PathParser from './pathParser';\n\n/**\n * Points the parser to the next character in the\n * path string every time it encounters any kind of\n * space character.\n *\n * @param path the `PathParser` instance\n */\nconst skipSpaces = (path: PathParser) => {\n const { pathValue, max } = path;\n while (path.index < max && isSpace(pathValue.charCodeAt(path.index))) {\n path.index += 1;\n }\n};\nexport default skipSpaces;\n","import type { PathCommandNumber } from '../types';\n\n/**\n * Checks if the character is a path command.\n *\n * @param code the character to check\n * @returns check result\n */\nconst isPathCommand = (code: number): code is PathCommandNumber => {\n // eslint-disable-next-line no-bitwise -- Impossible to satisfy\n switch (code | 0x20) {\n case 0x6d /* m */:\n case 0x7a /* z */:\n case 0x6c /* l */:\n case 0x68 /* h */:\n case 0x76 /* v */:\n case 0x63 /* c */:\n case 0x73 /* s */:\n case 0x71 /* q */:\n case 0x74 /* t */:\n case 0x61 /* a */:\n // case 0x72/* r */:\n return true;\n default:\n return false;\n }\n};\nexport default isPathCommand;\n","import isDigit from './isDigit';\nimport type { DigitNumber } from '../types';\n\n/**\n * Checks if the character is or belongs to a number.\n * [0-9]|+|-|.\n *\n * @param code the character to check\n * @returns check result\n */\nconst isDigitStart = (code: number): code is DigitNumber | 0x2b | 0x2d | 0x2e => {\n return isDigit(code) /* 0..9 */ || code === 0x2b /* + */ || code === 0x2d /* - */ || code === 0x2e; /* . */\n};\nexport default isDigitStart;\n","/**\n * Checks if the character is an A (arc-to) path command.\n *\n * @param code the character to check\n * @returns check result\n */\nconst isArcCommand = (code: number): code is 0x61 => {\n // eslint-disable-next-line no-bitwise -- Impossible to satisfy\n return (code | 0x20) === 0x61;\n};\nexport default isArcCommand;\n","import finalizeSegment from './finalizeSegment';\nimport paramCounts from './paramsCount';\nimport scanFlag from './scanFlag';\nimport scanParam from './scanParam';\nimport skipSpaces from './skipSpaces';\nimport isPathCommand from './isPathCommand';\nimport isDigitStart from './isDigitStart';\nimport isArcCommand from './isArcCommand';\nimport invalidPathValue from './invalidPathValue';\nimport error from './error';\n\nimport type PathParser from './pathParser';\nimport { RelativeCommand } from '../types';\n\n/**\n * Scans every character in the path string to determine\n * where a segment starts and where it ends.\n *\n * @param path the `PathParser` instance\n */\nconst scanSegment = (path: PathParser) => {\n const { max, pathValue, index } = path;\n const cmdCode = pathValue.charCodeAt(index);\n const reqParams = paramCounts[pathValue[index].toLowerCase() as RelativeCommand];\n\n path.segmentStart = index;\n\n if (!isPathCommand(cmdCode)) {\n path.err = `${error}: ${invalidPathValue} \"${pathValue[index]}\" is not a path command`;\n return;\n }\n\n path.index += 1;\n skipSpaces(path);\n\n path.data = [];\n\n if (!reqParams) {\n // Z\n finalizeSegment(path);\n return;\n }\n\n for (;;) {\n for (let i = reqParams; i > 0; i -= 1) {\n if (isArcCommand(cmdCode) && (i === 3 || i === 4)) scanFlag(path);\n else scanParam(path);\n\n if (path.err.length) {\n return;\n }\n path.data.push(path.param);\n\n skipSpaces(path);\n\n // after ',' param is mandatory\n if (path.index < max && pathValue.charCodeAt(path.index) === 0x2c /* , */) {\n path.index += 1;\n skipSpaces(path);\n }\n }\n\n if (path.index >= path.max) {\n break;\n }\n\n // Stop on next segment\n if (!isDigitStart(pathValue.charCodeAt(path.index))) {\n break;\n }\n }\n\n finalizeSegment(path);\n};\nexport default scanSegment;\n","import type { PathArray, PathSegment } from '../types';\n\n/**\n * The `PathParser` is used by the `parsePathString` static method\n * to generate a `pathArray`.\n *\n * @param pathString\n */\nexport default class PathParser {\n declare segments: PathArray | PathSegment[];\n declare pathValue: string;\n declare max: number;\n declare index: number;\n declare param: number;\n declare segmentStart: number;\n declare data: any[];\n declare err: string;\n\n constructor(pathString: string) {\n this.segments = [];\n this.pathValue = pathString;\n this.max = pathString.length;\n this.index = 0;\n this.param = 0.0;\n this.segmentStart = 0;\n this.data = [];\n this.err = '';\n }\n}\n","import type { PathArray, PathSegment, RelativeCommand } from '../types';\nimport paramsCount from '../parser/paramsCount';\n\n/**\n * Iterates an array to check if it's an actual `pathArray`.\n *\n * @param path the `pathArray` to be checked\n * @returns iteration result\n */\nconst isPathArray = (path: unknown): path is PathArray => {\n return (\n Array.isArray(path) &&\n path.every((seg: PathSegment) => {\n const lk = seg[0].toLowerCase() as RelativeCommand;\n return paramsCount[lk] === seg.length - 1 && 'achlmqstvz'.includes(lk);\n })\n );\n};\nexport default isPathArray;\n","import scanSegment from './scanSegment';\nimport skipSpaces from './skipSpaces';\nimport PathParser from './pathParser';\nimport isPathArray from '../util/isPathArray';\nimport type { PathArray } from '../types';\n\n/**\n * Parses a path string value and returns an array\n * of segments we like to call `pathArray`.\n *\n * @param pathInput the string to be parsed\n * @returns the resulted `pathArray` or error string\n */\nconst parsePathString = (pathInput: string | PathArray): PathArray => {\n if (isPathArray(pathInput)) {\n return [...pathInput];\n }\n\n const path = new PathParser(pathInput);\n\n skipSpaces(path);\n\n while (path.index < path.max && !path.err.length) {\n scanSegment(path);\n }\n\n if (path.err && path.err.length) {\n throw TypeError(path.err);\n }\n\n return path.segments as PathArray;\n};\n\nexport default parsePathString;\n","/**\n * d3-polygon-area\n * https://github.com/d3/d3-polygon\n *\n * Returns the area of a polygon.\n *\n * @param polygon an array of coordinates\n * @returns the polygon area\n */\nconst polygonArea = (polygon: [number, number][]): number => {\n const n = polygon.length;\n let i = -1;\n let a;\n let b = polygon[n - 1];\n let area = 0;\n\n /* eslint-disable-next-line */\n while (++i < n) {\n a = b;\n b = polygon[i];\n area += a[1] * b[0] - a[0] * b[1];\n }\n\n return area / 2;\n};\n\nexport default polygonArea;\n","/**\n * Returns the square root of the distance\n * between two given points.\n *\n * @param a the first point coordinates\n * @param b the second point coordinates\n * @returns the distance value\n */\nconst distanceSquareRoot = (a: [number, number], b: [number, number]): number => {\n return Math.sqrt((a[0] - b[0]) * (a[0] - b[0]) + (a[1] - b[1]) * (a[1] - b[1]));\n};\n\nexport default distanceSquareRoot;\n","import distanceSquareRoot from './distanceSquareRoot';\n\n/**\n * d3-polygon-length\n * https://github.com/d3/d3-polygon\n *\n * Returns the perimeter of a polygon.\n *\n * @param polygon an array of coordinates\n * @returns {number} the polygon length\n */\nconst polygonLength = (polygon: [number, number][]): number => {\n return polygon.reduce((length, point, i) => {\n if (i) {\n return length + distanceSquareRoot(polygon[i - 1], point);\n }\n return 0;\n }, 0);\n};\n\nexport default polygonLength;\n","var Z = Object.defineProperty;\nvar z = (s, t, e) => t in s ? Z(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;\nvar p = (s, t, e) => (z(s, typeof t != \"symbol\" ? t + \"\" : t, e), e);\nconst $ = {\n a: 1,\n b: 0,\n c: 0,\n d: 1,\n e: 0,\n f: 0,\n m11: 1,\n m12: 0,\n m13: 0,\n m14: 0,\n m21: 0,\n m22: 1,\n m23: 0,\n m24: 0,\n m31: 0,\n m32: 0,\n m33: 1,\n m34: 0,\n m41: 0,\n m42: 0,\n m43: 0,\n m44: 1,\n is2D: !0,\n isIdentity: !0\n}, E = (s) => (s instanceof Float64Array || s instanceof Float32Array || Array.isArray(s) && s.every((t) => typeof t == \"number\")) && [6, 16].some((t) => s.length === t), P = (s) => s instanceof DOMMatrix || s instanceof y || typeof s == \"object\" && Object.keys($).every((t) => s && t in s), g = (s) => {\n const t = new y(), e = Array.from(s);\n if (!E(e))\n throw TypeError(`CSSMatrix: \"${e.join(\",\")}\" must be an array with 6/16 numbers.`);\n if (e.length === 16) {\n const [n, i, r, a, l, m, h, c, u, f, w, o, d, A, M, b] = e;\n t.m11 = n, t.a = n, t.m21 = l, t.c = l, t.m31 = u, t.m41 = d, t.e = d, t.m12 = i, t.b = i, t.m22 = m, t.d = m, t.m32 = f, t.m42 = A, t.f = A, t.m13 = r, t.m23 = h, t.m33 = w, t.m43 = M, t.m14 = a, t.m24 = c, t.m34 = o, t.m44 = b;\n } else if (e.length === 6) {\n const [n, i, r, a, l, m] = e;\n t.m11 = n, t.a = n, t.m12 = i, t.b = i, t.m21 = r, t.c = r, t.m22 = a, t.d = a, t.m41 = l, t.e = l, t.m42 = m, t.f = m;\n }\n return t;\n}, X = (s) => {\n if (P(s))\n return g([\n s.m11,\n s.m12,\n s.m13,\n s.m14,\n s.m21,\n s.m22,\n s.m23,\n s.m24,\n s.m31,\n s.m32,\n s.m33,\n s.m34,\n s.m41,\n s.m42,\n s.m43,\n s.m44\n ]);\n throw TypeError(`CSSMatrix: \"${JSON.stringify(s)}\" is not a DOMMatrix / CSSMatrix / JSON compatible object.`);\n}, O = (s) => {\n if (typeof s != \"string\")\n throw TypeError(`CSSMatrix: \"${JSON.stringify(s)}\" is not a string.`);\n const t = String(s).replace(/\\s/g, \"\");\n let e = new y();\n const n = `CSSMatrix: invalid transform string \"${s}\"`;\n return t.split(\")\").filter((i) => i).forEach((i) => {\n const [r, a] = i.split(\"(\");\n if (!a)\n throw TypeError(n);\n const l = a.split(\",\").map((o) => o.includes(\"rad\") ? parseFloat(o) * (180 / Math.PI) : parseFloat(o)), [m, h, c, u] = l, f = [m, h, c], w = [m, h, c, u];\n if (r === \"perspective\" && m && [h, c].every((o) => o === void 0))\n e.m34 = -1 / m;\n else if (r.includes(\"matrix\") && [6, 16].includes(l.length) && l.every((o) => !Number.isNaN(+o))) {\n const o = l.map((d) => Math.abs(d) < 1e-6 ? 0 : d);\n e = e.multiply(g(o));\n } else if (r === \"translate3d\" && f.every((o) => !Number.isNaN(+o)))\n e = e.translate(m, h, c);\n else if (r === \"translate\" && m && c === void 0)\n e = e.translate(m, h || 0, 0);\n else if (r === \"rotate3d\" && w.every((o) => !Number.isNaN(+o)) && u)\n e = e.rotateAxisAngle(m, h, c, u);\n else if (r === \"rotate\" && m && [h, c].every((o) => o === void 0))\n e = e.rotate(0, 0, m);\n else if (r === \"scale3d\" && f.every((o) => !Number.isNaN(+o)) && f.some((o) => o !== 1))\n e = e.scale(m, h, c);\n else if (r === \"scale\" && !Number.isNaN(m) && m !== 1 && c === void 0) {\n const d = Number.isNaN(+h) ? m : h;\n e = e.scale(m, d, 1);\n } else if (r === \"skew\" && (m || !Number.isNaN(m) && h) && c === void 0)\n e = e.skew(m, h || 0);\n else if ([\"translate\", \"rotate\", \"scale\", \"skew\"].some((o) => r.includes(o)) && /[XYZ]/.test(r) && m && [h, c].every((o) => o === void 0))\n if (r === \"skewX\" || r === \"skewY\")\n e = e[r](m);\n else {\n const o = r.replace(/[XYZ]/, \"\"), d = r.replace(o, \"\"), A = [\"X\", \"Y\", \"Z\"].indexOf(d), M = o === \"scale\" ? 1 : 0, b = [A === 0 ? m : M, A === 1 ? m : M, A === 2 ? m : M];\n e = e[o](...b);\n }\n else\n throw TypeError(n);\n }), e;\n}, x = (s, t) => t ? [s.a, s.b, s.c, s.d, s.e, s.f] : [\n s.m11,\n s.m12,\n s.m13,\n s.m14,\n s.m21,\n s.m22,\n s.m23,\n s.m24,\n s.m31,\n s.m32,\n s.m33,\n s.m34,\n s.m41,\n s.m42,\n s.m43,\n s.m44\n], Y = (s, t, e) => {\n const n = new y();\n return n.m41 = s, n.e = s, n.m42 = t, n.f = t, n.m43 = e, n;\n}, F = (s, t, e) => {\n const n = new y(), i = Math.PI / 180, r = s * i, a = t * i, l = e * i, m = Math.cos(r), h = -Math.sin(r), c = Math.cos(a), u = -Math.sin(a), f = Math.cos(l), w = -Math.sin(l), o = c * f, d = -c * w;\n n.m11 = o, n.a = o, n.m12 = d, n.b = d, n.m13 = u;\n const A = h * u * f + m * w;\n n.m21 = A, n.c = A;\n const M = m * f - h * u * w;\n return n.m22 = M, n.d = M, n.m23 = -h * c, n.m31 = h * w - m * u * f, n.m32 = h * f + m * u * w, n.m33 = m * c, n;\n}, T = (s, t, e, n) => {\n const i = new y(), r = Math.sqrt(s * s + t * t + e * e);\n if (r === 0)\n return i;\n const a = s / r, l = t / r, m = e / r, h = n * (Math.PI / 360), c = Math.sin(h), u = Math.cos(h), f = c * c, w = a * a, o = l * l, d = m * m, A = 1 - 2 * (o + d) * f;\n i.m11 = A, i.a = A;\n const M = 2 * (a * l * f + m * c * u);\n i.m12 = M, i.b = M, i.m13 = 2 * (a * m * f - l * c * u);\n const b = 2 * (l * a * f - m * c * u);\n i.m21 = b, i.c = b;\n const k = 1 - 2 * (d + w) * f;\n return i.m22 = k, i.d = k, i.m23 = 2 * (l * m * f + a * c * u), i.m31 = 2 * (m * a * f + l * c * u), i.m32 = 2 * (m * l * f - a * c * u), i.m33 = 1 - 2 * (w + o) * f, i;\n}, I = (s, t, e) => {\n const n = new y();\n return n.m11 = s, n.a = s, n.m22 = t, n.d = t, n.m33 = e, n;\n}, v = (s, t) => {\n const e = new y();\n if (s) {\n const n = s * Math.PI / 180, i = Math.tan(n);\n e.m21 = i, e.c = i;\n }\n if (t) {\n const n = t * Math.PI / 180, i = Math.tan(n);\n e.m12 = i, e.b = i;\n }\n return e;\n}, R = (s) => v(s, 0), D = (s) => v(0, s), N = (s, t) => {\n const e = t.m11 * s.m11 + t.m12 * s.m21 + t.m13 * s.m31 + t.m14 * s.m41, n = t.m11 * s.m12 + t.m12 * s.m22 + t.m13 * s.m32 + t.m14 * s.m42, i = t.m11 * s.m13 + t.m12 * s.m23 + t.m13 * s.m33 + t.m14 * s.m43, r = t.m11 * s.m14 + t.m12 * s.m24 + t.m13 * s.m34 + t.m14 * s.m44, a = t.m21 * s.m11 + t.m22 * s.m21 + t.m23 * s.m31 + t.m24 * s.m41, l = t.m21 * s.m12 + t.m22 * s.m22 + t.m23 * s.m32 + t.m24 * s.m42, m = t.m21 * s.m13 + t.m22 * s.m23 + t.m23 * s.m33 + t.m24 * s.m43, h = t.m21 * s.m14 + t.m22 * s.m24 + t.m23 * s.m34 + t.m24 * s.m44, c = t.m31 * s.m11 + t.m32 * s.m21 + t.m33 * s.m31 + t.m34 * s.m41, u = t.m31 * s.m12 + t.m32 * s.m22 + t.m33 * s.m32 + t.m34 * s.m42, f = t.m31 * s.m13 + t.m32 * s.m23 + t.m33 * s.m33 + t.m34 * s.m43, w = t.m31 * s.m14 + t.m32 * s.m24 + t.m33 * s.m34 + t.m34 * s.m44, o = t.m41 * s.m11 + t.m42 * s.m21 + t.m43 * s.m31 + t.m44 * s.m41, d = t.m41 * s.m12 + t.m42 * s.m22 + t.m43 * s.m32 + t.m44 * s.m42, A = t.m41 * s.m13 + t.m42 * s.m23 + t.m43 * s.m33 + t.m44 * s.m43, M = t.m41 * s.m14 + t.m42 * s.m24 + t.m43 * s.m34 + t.m44 * s.m44;\n return g([e, n, i, r, a, l, m, h, c, u, f, w, o, d, A, M]);\n};\nclass y {\n constructor(t) {\n return this.a = 1, this.b = 0, this.c = 0, this.d = 1, this.e = 0, this.f = 0, this.m11 = 1, this.m12 = 0, this.m13 = 0, this.m14 = 0, this.m21 = 0, this.m22 = 1, this.m23 = 0, this.m24 = 0, this.m31 = 0, this.m32 = 0, this.m33 = 1, this.m34 = 0, this.m41 = 0, this.m42 = 0, this.m43 = 0, this.m44 = 1, t ? this.setMatrixValue(t) : this;\n }\n get isIdentity() {\n return this.m11 === 1 && this.m12 === 0 && this.m13 === 0 && this.m14 === 0 && this.m21 === 0 && this.m22 === 1 && this.m23 === 0 && this.m24 === 0 && this.m31 === 0 && this.m32 === 0 && this.m33 === 1 && this.m34 === 0 && this.m41 === 0 && this.m42 === 0 && this.m43 === 0 && this.m44 === 1;\n }\n get is2D() {\n return this.m31 === 0 && this.m32 === 0 && this.m33 === 1 && this.m34 === 0 && this.m43 === 0 && this.m44 === 1;\n }\n setMatrixValue(t) {\n return typeof t == \"string\" && t.length && t !== \"none\" ? O(t) : Array.isArray(t) || t instanceof Float64Array || t instanceof Float32Array ? g(t) : typeof t == \"object\" ? X(t) : this;\n }\n toFloat32Array(t) {\n return Float32Array.from(x(this, t));\n }\n toFloat64Array(t) {\n return Float64Array.from(x(this, t));\n }\n toString() {\n const { is2D: t } = this, e = this.toFloat64Array(t).join(\", \");\n return `${t ? \"matrix\" : \"matrix3d\"}(${e})`;\n }\n toJSON() {\n const { is2D: t, isIdentity: e } = this;\n return { ...this, is2D: t, isIdentity: e };\n }\n multiply(t) {\n return N(this, t);\n }\n translate(t, e, n) {\n const i = t;\n let r = e, a = n;\n return typeof r > \"u\" && (r = 0), typeof a > \"u\" && (a = 0), N(this, Y(i, r, a));\n }\n scale(t, e, n) {\n const i = t;\n let r = e, a = n;\n return typeof r > \"u\" && (r = t), typeof a > \"u\" && (a = 1), N(this, I(i, r, a));\n }\n rotate(t, e, n) {\n let i = t, r = e || 0, a = n || 0;\n return typeof t == \"number\" && typeof e > \"u\" && typeof n > \"u\" && (a = i, i = 0, r = 0), N(this, F(i, r, a));\n }\n rotateAxisAngle(t, e, n, i) {\n if ([t, e, n, i].some((r) => Number.isNaN(+r)))\n throw new TypeError(\"CSSMatrix: expecting 4 values\");\n return N(this, T(t, e, n, i));\n }\n skewX(t) {\n return N(this, R(t));\n }\n skewY(t) {\n return N(this, D(t));\n }\n skew(t, e) {\n return N(this, v(t, e));\n }\n transformPoint(t) {\n const e = this.m11 * t.x + this.m21 * t.y + this.m31 * t.z + this.m41 * t.w, n = this.m12 * t.x + this.m22 * t.y + this.m32 * t.z + this.m42 * t.w, i = this.m13 * t.x + this.m23 * t.y + this.m33 * t.z + this.m43 * t.w, r = this.m14 * t.x + this.m24 * t.y + this.m34 * t.z + this.m44 * t.w;\n return t instanceof DOMPoint ? new DOMPoint(e, n, i, r) : {\n x: e,\n y: n,\n z: i,\n w: r\n };\n }\n}\np(y, \"Translate\", Y), p(y, \"Rotate\", F), p(y, \"RotateAxisAngle\", T), p(y, \"Scale\", I), p(y, \"SkewX\", R), p(y, \"SkewY\", D), p(y, \"Skew\", v), p(y, \"Multiply\", N), p(y, \"fromArray\", g), p(y, \"fromMatrix\", X), p(y, \"fromString\", O), p(y, \"toArray\", x), p(y, \"isCompatibleArray\", E), p(y, \"isCompatibleObject\", P);\nexport {\n y as default\n};\n//# sourceMappingURL=dommatrix.mjs.map\n","import type { AbsoluteArray } from '../types';\nimport isPathArray from './isPathArray';\n\n/**\n * Iterates an array to check if it's a `pathArray`\n * with all absolute values.\n *\n * @param path the `pathArray` to be checked\n * @returns iteration result\n */\nconst isAbsoluteArray = (path: unknown): path is AbsoluteArray => {\n return (\n isPathArray(path) &&\n // `isPathArray` also checks if it's `Array`\n path.every(([x]) => x === x.toUpperCase())\n );\n};\nexport default isAbsoluteArray;\n","import parsePathString from '../parser/parsePathString';\nimport isAbsoluteArray from '../util/isAbsoluteArray';\nimport type {\n PathArray,\n AbsoluteArray,\n AbsoluteCommand,\n AbsoluteSegment,\n VSegment,\n HSegment,\n QSegment,\n TSegment,\n ASegment,\n SSegment,\n CSegment,\n MSegment,\n} from '../types';\n\n/**\n * Parses a path string value or object and returns an array\n * of segments, all converted to absolute values.\n *\n * @param pathInput the path string | object\n * @returns the resulted `pathArray` with absolute values\n */\nconst pathToAbsolute = (pathInput: string | PathArray): AbsoluteArray => {\n /* istanbul ignore else */\n if (isAbsoluteArray(pathInput)) {\n return [...pathInput];\n }\n\n const path = parsePathString(pathInput);\n let x = 0;\n let y = 0;\n let mx = 0;\n let my = 0;\n\n // the `absoluteSegment[]` is for sure an `absolutePath`\n return path.map(segment => {\n const values = segment.slice(1).map(Number);\n const [pathCommand] = segment;\n const absCommand = pathCommand.toUpperCase() as AbsoluteCommand;\n\n if (pathCommand === 'M') {\n [x, y] = values;\n mx = x;\n my = y;\n return ['M', x, y] as MSegment;\n }\n\n let absoluteSegment = [] as unknown as AbsoluteSegment;\n\n if (pathCommand !== absCommand) {\n if (absCommand === 'A') {\n absoluteSegment = [\n absCommand,\n values[0],\n values[1],\n values[2],\n values[3],\n values[4],\n values[5] + x,\n values[6] + y,\n ] as ASegment;\n } else if (absCommand === 'V') {\n absoluteSegment = [absCommand, values[0] + y] as VSegment;\n } else if (absCommand === 'H') {\n absoluteSegment = [absCommand, values[0] + x] as HSegment;\n } else {\n // use brakets for `eslint: no-case-declaration`\n // https://stackoverflow.com/a/50753272/803358\n const absValues = values.map((n, j) => n + (j % 2 ? y : x));\n // for n, l, c, s, q, t\n absoluteSegment = [absCommand, ...absValues] as QSegment | TSegment | SSegment | CSegment;\n }\n } else {\n absoluteSegment = [absCommand, ...values] as typeof segment;\n }\n\n // const segLength = absoluteSegment.length;\n if (absCommand === 'Z') {\n x = mx;\n y = my;\n } else if (absCommand === 'H') {\n [, x] = absoluteSegment as HSegment;\n } else if (absCommand === 'V') {\n [, y] = absoluteSegment as VSegment;\n } else {\n // x = absoluteSegment[segLength - 2];\n // y = absoluteSegment[segLength - 1];\n [x, y] = absoluteSegment.slice(-2) as [number, number];\n\n if (absCommand === 'M') {\n mx = x;\n my = y;\n }\n }\n\n return absoluteSegment;\n }) as AbsoluteArray;\n};\nexport default pathToAbsolute;\n","import type { ParserParams } from '../interface';\nimport type { NormalSegment, PathSegment } from '../types';\n\n/**\n * Normalizes a single segment of a `pathArray` object.\n *\n * @param segment the segment object\n * @param params the coordinates of the previous segment\n * @returns the normalized segment\n */\nconst normalizeSegment = (segment: PathSegment, params: ParserParams): NormalSegment => {\n const [pathCommand] = segment;\n const { x1: px1, y1: py1, x2: px2, y2: py2 } = params;\n const values = segment.slice(1).map(Number);\n let result = segment;\n\n if (!'TQ'.includes(pathCommand)) {\n // optional but good to be cautious\n params.qx = null;\n params.qy = null;\n }\n\n if (pathCommand === 'H') {\n result = ['L', segment[1], py1];\n } else if (pathCommand === 'V') {\n result = ['L', px1, segment[1]];\n } else if (pathCommand === 'S') {\n const x1 = px1 * 2 - px2;\n const y1 = py1 * 2 - py2;\n params.x1 = x1;\n params.y1 = y1;\n result = ['C', x1, y1, ...(values as [number, number, number, number])];\n } else if (pathCommand === 'T') {\n const qx = px1 * 2 - (params.qx ? params.qx : /* istanbul ignore next */ 0);\n const qy = py1 * 2 - (params.qy ? params.qy : /* istanbul ignore next */ 0);\n params.qx = qx;\n params.qy = qy;\n result = ['Q', qx, qy, ...(values as [number, number])];\n } else if (pathCommand === 'Q') {\n const [nqx, nqy] = values as [number, number];\n params.qx = nqx;\n params.qy = nqy;\n }\n\n return result as NormalSegment;\n};\nexport default normalizeSegment;\n","import type { NormalArray } from '../types';\nimport isAbsoluteArray from './isAbsoluteArray';\n\n/**\n * Iterates an array to check if it's a `pathArray`\n * with all segments are in non-shorthand notation\n * with absolute values.\n *\n * @param {string | SVGPath.pathArray} path the `pathArray` to be checked\n * @returns {boolean} iteration result\n */\nconst isNormalizedArray = (path: unknown): path is NormalArray => {\n // `isAbsoluteArray` also checks if it's `Array`\n return isAbsoluteArray(path) && path.every(([pc]) => 'ACLMQZ'.includes(pc));\n};\nexport default isNormalizedArray;\n","import type { ParserParams } from '../interface';\n\nconst paramsParser: ParserParams = {\n x1: 0,\n y1: 0,\n x2: 0,\n y2: 0,\n x: 0,\n y: 0,\n qx: null,\n qy: null,\n};\n\nexport default paramsParser;\n","import pathToAbsolute from '../convert/pathToAbsolute';\nimport normalizeSegment from './normalizeSegment';\nimport isNormalizedArray from '../util/isNormalizedArray';\nimport paramsParser from '../parser/paramsParser';\nimport type { NormalArray, PathArray } from '../types';\n\n/**\n * Normalizes a `path` object for further processing:\n * * convert segments to absolute values\n * * convert shorthand path commands to their non-shorthand notation\n *\n * @param pathInput the string to be parsed or 'pathArray'\n * @returns the normalized `pathArray`\n */\nconst normalizePath = (pathInput: string | PathArray): NormalArray => {\n if (isNormalizedArray(pathInput)) {\n return [...pathInput];\n }\n\n const path = pathToAbsolute(pathInput);\n const params = { ...paramsParser };\n const allPathCommands = [];\n const ii = path.length;\n let pathCommand = '';\n\n for (let i = 0; i < ii; i += 1) {\n [pathCommand] = path[i];\n\n // Save current path command\n allPathCommands[i] = pathCommand;\n path[i] = normalizeSegment(path[i], params);\n\n const segment = path[i];\n const seglen = segment.length;\n\n params.x1 = +segment[seglen - 2];\n params.y1 = +segment[seglen - 1];\n params.x2 = +segment[seglen - 4] || params.x1;\n params.y2 = +segment[seglen - 3] || params.y1;\n }\n\n return path as NormalArray;\n};\nexport default normalizePath;\n","/**\n * Returns the coordinates of a specified distance\n * ratio between two points.\n *\n * @param a the first point coordinates\n * @param b the second point coordinates\n * @param t the ratio\n * @returns the midpoint coordinates\n */\nconst midPoint = (a: [number, number], b: [number, number], t: number): [number, number] => {\n const [ax, ay] = a;\n const [bx, by] = b;\n return [ax + (bx - ax) * t, ay + (by - ay) * t];\n};\n\nexport default midPoint;\n","import midPoint from '../math/midPoint';\nimport distanceSquareRoot from '../math/distanceSquareRoot';\nimport type { LengthFactory } from '../interface';\n\n/**\n * Returns a {x,y} point at a given length, the total length and\n * the minimum and maximum {x,y} coordinates of a line (L,V,H,Z) segment.\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @param distance the distance to point\n * @returns the segment length, point, min & max\n */\nconst segmentLineFactory = (x1: number, y1: number, x2: number, y2: number, distance?: number): LengthFactory => {\n const length = distanceSquareRoot([x1, y1], [x2, y2]);\n let point = { x: 0, y: 0 };\n\n /* istanbul ignore else */\n if (typeof distance === 'number') {\n if (distance <= 0) {\n point = { x: x1, y: y1 };\n } else if (distance >= length) {\n point = { x: x2, y: y2 };\n } else {\n const [x, y] = midPoint([x1, y1], [x2, y2], distance / length);\n point = { x, y };\n }\n }\n\n return {\n length,\n point,\n min: {\n x: Math.min(x1, x2),\n y: Math.min(y1, y2),\n },\n max: {\n x: Math.max(x1, x2),\n y: Math.max(y1, y2),\n },\n };\n};\nexport default segmentLineFactory;\n","import type { LengthFactory } from '../interface';\nimport segmentLineFactory from './segmentLineFactory';\nimport distanceSquareRoot from '../math/distanceSquareRoot';\n\n/**\n * Returns an angle value between two points.\n *\n * @param v0\n * @param v1\n * @returns a number representing an angle\n */\nconst angleBetween = (v0: { x: number; y: number }, v1: { x: number; y: number }): number => {\n const { x: v0x, y: v0y } = v0;\n const { x: v1x, y: v1y } = v1;\n const p = v0x * v1x + v0y * v1y;\n const n = Math.sqrt((v0x ** 2 + v0y ** 2) * (v1x ** 2 + v1y ** 2));\n const sign = v0x * v1y - v0y * v1x < 0 ? -1 : 1;\n const angle = sign * Math.acos(p / n);\n\n return angle;\n};\n\n/**\n * Returns a {x,y} point at a given length, the total length and\n * the minimum and maximum {x,y} coordinates of a C (cubic-bezier) segment.\n *\n * @see https://github.com/MadLittleMods/svg-curve-lib/blob/master/src/js/svg-curve-lib.js\n *\n * @param x1 the starting x position\n * @param y1 the starting y position\n * @param RX x-radius of the arc\n * @param RY y-radius of the arc\n * @param angle x-axis-rotation of the arc\n * @param LAF large-arc-flag of the arc\n * @param SF sweep-flag of the arc\n * @param x the ending x position\n * @param y the ending y position\n * @param t the point distance\n * @returns the requested point\n */\nconst getPointAtArcSegmentLength = (\n x1: number,\n y1: number,\n RX: number,\n RY: number,\n angle: number,\n LAF: number,\n SF: number,\n x: number,\n y: number,\n t: number,\n): { x: number; y: number } => {\n const { abs, sin, cos, sqrt, PI } = Math;\n let rx = abs(RX);\n let ry = abs(RY);\n const xRot = ((angle % 360) + 360) % 360;\n const xRotRad = xRot * (PI / 180);\n\n if (x1 === x && y1 === y) {\n return { x: x1, y: y1 };\n }\n\n if (rx === 0 || ry === 0) {\n return segmentLineFactory(x1, y1, x, y, t).point;\n }\n\n const dx = (x1 - x) / 2;\n const dy = (y1 - y) / 2;\n\n const transformedPoint = {\n x: cos(xRotRad) * dx + sin(xRotRad) * dy,\n y: -sin(xRotRad) * dx + cos(xRotRad) * dy,\n };\n\n const radiiCheck = transformedPoint.x ** 2 / rx ** 2 + transformedPoint.y ** 2 / ry ** 2;\n\n if (radiiCheck > 1) {\n rx *= sqrt(radiiCheck);\n ry *= sqrt(radiiCheck);\n }\n\n const cSquareNumerator = rx ** 2 * ry ** 2 - rx ** 2 * transformedPoint.y ** 2 - ry ** 2 * transformedPoint.x ** 2;\n\n const cSquareRootDenom = rx ** 2 * transformedPoint.y ** 2 + ry ** 2 * transformedPoint.x ** 2;\n\n let cRadicand = cSquareNumerator / cSquareRootDenom;\n cRadicand = cRadicand < 0 ? 0 : cRadicand;\n const cCoef = (LAF !== SF ? 1 : -1) * sqrt(cRadicand);\n const transformedCenter = {\n x: cCoef * ((rx * transformedPoint.y) / ry),\n y: cCoef * (-(ry * transformedPoint.x) / rx),\n };\n\n const center = {\n x: cos(xRotRad) * transformedCenter.x - sin(xRotRad) * transformedCenter.y + (x1 + x) / 2,\n y: sin(xRotRad) * transformedCenter.x + cos(xRotRad) * transformedCenter.y + (y1 + y) / 2,\n };\n\n const startVector = {\n x: (transformedPoint.x - transformedCenter.x) / rx,\n y: (transformedPoint.y - transformedCenter.y) / ry,\n };\n\n const startAngle = angleBetween({ x: 1, y: 0 }, startVector);\n\n const endVector = {\n x: (-transformedPoint.x - transformedCenter.x) / rx,\n y: (-transformedPoint.y - transformedCenter.y) / ry,\n };\n\n let sweepAngle = angleBetween(startVector, endVector);\n if (!SF && sweepAngle > 0) {\n sweepAngle -= 2 * PI;\n } else if (SF && sweepAngle < 0) {\n sweepAngle += 2 * PI;\n }\n sweepAngle %= 2 * PI;\n\n const alpha = startAngle + sweepAngle * t;\n const ellipseComponentX = rx * cos(alpha);\n const ellipseComponentY = ry * sin(alpha);\n\n const point = {\n x: cos(xRotRad) * ellipseComponentX - sin(xRotRad) * ellipseComponentY + center.x,\n y: sin(xRotRad) * ellipseComponentX + cos(xRotRad) * ellipseComponentY + center.y,\n };\n\n // to be used later\n // point.ellipticalArcStartAngle = startAngle;\n // point.ellipticalArcEndAngle = startAngle + sweepAngle;\n // point.ellipticalArcAngle = alpha;\n\n // point.ellipticalArcCenter = center;\n // point.resultantRx = rx;\n // point.resultantRy = ry;\n\n return point;\n};\n\n/**\n * Returns a {x,y} point at a given length, the total length and\n * the shape minimum and maximum {x,y} coordinates of an A (arc-to) segment.\n *\n * @param X1 the starting x position\n * @param Y1 the starting y position\n * @param RX x-radius of the arc\n * @param RY y-radius of the arc\n * @param angle x-axis-rotation of the arc\n * @param LAF large-arc-flag of the arc\n * @param SF sweep-flag of the arc\n * @param X2 the ending x position\n * @param Y2 the ending y position\n * @param distance the point distance\n * @returns the segment length, point, min & max\n */\nconst segmentArcFactory = (\n X1: number,\n Y1: number,\n RX: number,\n RY: number,\n angle: number,\n LAF: number,\n SF: number,\n X2: number,\n Y2: number,\n distance: number,\n): LengthFactory => {\n const distanceIsNumber = typeof distance === 'number';\n let x = X1;\n let y = Y1;\n let LENGTH = 0;\n let prev = [x, y, LENGTH];\n let cur = [x, y] as [number, number];\n let t = 0;\n let POINT = { x: 0, y: 0 };\n let POINTS = [{ x, y }];\n\n if (distanceIsNumber && distance <= 0) {\n POINT = { x, y };\n }\n\n const sampleSize = 300;\n for (let j = 0; j <= sampleSize; j += 1) {\n t = j / sampleSize;\n\n ({ x, y } = getPointAtArcSegmentLength(X1, Y1, RX, RY, angle, LAF, SF, X2, Y2, t));\n POINTS = [...POINTS, { x, y }];\n LENGTH += distanceSquareRoot(cur, [x, y]);\n cur = [x, y];\n\n if (distanceIsNumber && LENGTH > distance && distance > prev[2]) {\n const dv = (LENGTH - distance) / (LENGTH - prev[2]);\n\n POINT = {\n x: cur[0] * (1 - dv) + prev[0] * dv,\n y: cur[1] * (1 - dv) + prev[1] * dv,\n };\n }\n prev = [x, y, LENGTH];\n }\n\n if (distanceIsNumber && distance >= LENGTH) {\n POINT = { x: X2, y: Y2 };\n }\n\n return {\n length: LENGTH,\n point: POINT,\n min: {\n x: Math.min(...POINTS.map(n => n.x)),\n y: Math.min(...POINTS.map(n => n.y)),\n },\n max: {\n x: Math.max(...POINTS.map(n => n.x)),\n y: Math.max(...POINTS.map(n => n.y)),\n },\n };\n};\nexport default segmentArcFactory;\n","import { LengthFactory } from 'src/interface';\nimport distanceSquareRoot from '../math/distanceSquareRoot';\n\n/**\n * Returns a {x,y} point at a given length, the total length and\n * the minimum and maximum {x,y} coordinates of a C (cubic-bezier) segment.\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param c1x the first control point X\n * @param c1y the first control point Y\n * @param c2x the second control point X\n * @param c2y the second control point Y\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @param t a [0-1] ratio\n * @returns the point at cubic-bezier segment length\n */\nconst getPointAtCubicSegmentLength = (\n x1: number,\n y1: number,\n c1x: number,\n c1y: number,\n c2x: number,\n c2y: number,\n x2: number,\n y2: number,\n t: number,\n): { x: number; y: number } => {\n const t1 = 1 - t;\n return {\n x: t1 ** 3 * x1 + 3 * t1 ** 2 * t * c1x + 3 * t1 * t ** 2 * c2x + t ** 3 * x2,\n y: t1 ** 3 * y1 + 3 * t1 ** 2 * t * c1y + 3 * t1 * t ** 2 * c2y + t ** 3 * y2,\n };\n};\n\n/**\n * Returns the length of a C (cubic-bezier) segment\n * or an {x,y} point at a given length.\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param c1x the first control point X\n * @param c1y the first control point Y\n * @param c2x the second control point X\n * @param c2y the second control point Y\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @param distance the point distance\n * @returns the segment length, point, min & max\n */\nconst segmentCubicFactory = (\n x1: number,\n y1: number,\n c1x: number,\n c1y: number,\n c2x: number,\n c2y: number,\n x2: number,\n y2: number,\n distance?: number,\n): LengthFactory => {\n const distanceIsNumber = typeof distance === 'number';\n let x = x1;\n let y = y1;\n let LENGTH = 0;\n let prev = [x, y, LENGTH];\n let cur = [x, y] as [number, number];\n let t = 0;\n let POINT = { x: 0, y: 0 };\n let POINTS = [{ x, y }];\n\n if (distanceIsNumber && distance <= 0) {\n POINT = { x, y };\n }\n\n const sampleSize = 300;\n for (let j = 0; j <= sampleSize; j += 1) {\n t = j / sampleSize;\n\n ({ x, y } = getPointAtCubicSegmentLength(x1, y1, c1x, c1y, c2x, c2y, x2, y2, t));\n POINTS = [...POINTS, { x, y }];\n LENGTH += distanceSquareRoot(cur, [x, y]);\n cur = [x, y];\n\n if (distanceIsNumber && LENGTH > distance && distance > prev[2]) {\n const dv = (LENGTH - distance) / (LENGTH - prev[2]);\n\n POINT = {\n x: cur[0] * (1 - dv) + prev[0] * dv,\n y: cur[1] * (1 - dv) + prev[1] * dv,\n };\n }\n prev = [x, y, LENGTH];\n }\n\n if (distanceIsNumber && distance >= LENGTH) {\n POINT = { x: x2, y: y2 };\n }\n\n return {\n length: LENGTH,\n point: POINT,\n min: {\n x: Math.min(...POINTS.map(n => n.x)),\n y: Math.min(...POINTS.map(n => n.y)),\n },\n max: {\n x: Math.max(...POINTS.map(n => n.x)),\n y: Math.max(...POINTS.map(n => n.y)),\n },\n };\n};\nexport default segmentCubicFactory;\n","import { LengthFactory } from 'src/interface';\nimport distanceSquareRoot from '../math/distanceSquareRoot';\n\n/**\n * Returns the {x,y} coordinates of a point at a\n * given length of a quadratic-bezier segment.\n *\n * @see https://github.com/substack/point-at-length\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param cx the control point X\n * @param cy the control point Y\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @param t a [0-1] ratio\n * @returns the requested {x,y} coordinates\n */\nconst getPointAtQuadSegmentLength = (\n x1: number,\n y1: number,\n cx: number,\n cy: number,\n x2: number,\n y2: number,\n t: number,\n): { x: number; y: number } => {\n const t1 = 1 - t;\n return {\n x: t1 ** 2 * x1 + 2 * t1 * t * cx + t ** 2 * x2,\n y: t1 ** 2 * y1 + 2 * t1 * t * cy + t ** 2 * y2,\n };\n};\n\n/**\n * Returns a {x,y} point at a given length, the total length and\n * the minimum and maximum {x,y} coordinates of a Q (quadratic-bezier) segment.\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param qx the control point X\n * @param qy the control point Y\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @param distance the distance to point\n * @returns the segment length, point, min & max\n */\nconst segmentQuadFactory = (\n x1: number,\n y1: number,\n qx: number,\n qy: number,\n x2: number,\n y2: number,\n distance?: number,\n): LengthFactory => {\n const distanceIsNumber = typeof distance === 'number';\n let x = x1;\n let y = y1;\n let LENGTH = 0;\n let prev = [x, y, LENGTH];\n let cur = [x, y] as [number, number];\n let t = 0;\n let POINT = { x: 0, y: 0 };\n let POINTS = [{ x, y }];\n\n if (distanceIsNumber && distance <= 0) {\n POINT = { x, y };\n }\n\n const sampleSize = 300;\n for (let j = 0; j <= sampleSize; j += 1) {\n t = j / sampleSize;\n\n ({ x, y } = getPointAtQuadSegmentLength(x1, y1, qx, qy, x2, y2, t));\n POINTS = [...POINTS, { x, y }];\n LENGTH += distanceSquareRoot(cur, [x, y]);\n cur = [x, y];\n\n if (distanceIsNumber && LENGTH > distance && distance > prev[2]) {\n const dv = (LENGTH - distance) / (LENGTH - prev[2]);\n\n POINT = {\n x: cur[0] * (1 - dv) + prev[0] * dv,\n y: cur[1] * (1 - dv) + prev[1] * dv,\n };\n }\n prev = [x, y, LENGTH];\n }\n\n /* istanbul ignore else */\n if (distanceIsNumber && distance >= LENGTH) {\n POINT = { x: x2, y: y2 };\n }\n\n return {\n length: LENGTH,\n point: POINT,\n min: {\n x: Math.min(...POINTS.map(n => n.x)),\n y: Math.min(...POINTS.map(n => n.y)),\n },\n max: {\n x: Math.max(...POINTS.map(n => n.x)),\n y: Math.max(...POINTS.map(n => n.y)),\n },\n };\n};\nexport default segmentQuadFactory;\n","import type { MSegment, PathArray } from '../types';\nimport type { LengthFactory } from '../interface';\nimport normalizePath from '../process/normalizePath';\nimport segmentLineFactory from './segmentLineFactory';\nimport segmentArcFactory from './segmentArcFactory';\nimport segmentCubicFactory from './segmentCubicFactory';\nimport segmentQuadFactory from './segmentQuadFactory';\n\n/**\n * Returns a {x,y} point at a given length\n * of a shape, the shape total length and\n * the shape minimum and maximum {x,y} coordinates.\n *\n * @param pathInput the `pathArray` to look into\n * @param distance the length of the shape to look at\n * @returns the path length, point, min & max\n */\nconst pathLengthFactory = (pathInput: string | PathArray, distance?: number): LengthFactory => {\n const path = normalizePath(pathInput);\n const distanceIsNumber = typeof distance === 'number';\n let isM;\n let data = [] as number[];\n let pathCommand;\n let x = 0;\n let y = 0;\n let mx = 0;\n let my = 0;\n let seg;\n let MIN = [] as { x: number; y: number }[];\n let MAX = [] as { x: number; y: number }[];\n let length = 0;\n let min = { x: 0, y: 0 };\n let max = min;\n let point = min;\n let POINT = min;\n let LENGTH = 0;\n\n for (let i = 0, ll = path.length; i < ll; i += 1) {\n seg = path[i];\n [pathCommand] = seg;\n isM = pathCommand === 'M';\n data = !isM ? [x, y, ...(seg.slice(1) as number[])] : data;\n\n // this segment is always ZERO\n /* istanbul ignore else */\n if (isM) {\n // remember mx, my for Z\n [, mx, my] = seg as MSegment;\n min = { x: mx, y: my };\n max = min;\n length = 0;\n\n if (distanceIsNumber && distance < 0.001) {\n POINT = min;\n }\n } else if (pathCommand === 'L') {\n ({ length, min, max, point } = segmentLineFactory(\n ...(data as [number, number, number, number]),\n (distance || 0) - LENGTH,\n ));\n } else if (pathCommand === 'A') {\n ({ length, min, max, point } = segmentArcFactory(\n ...(data as [number, number, number, number, number, number, number, number, number]),\n (distance || 0) - LENGTH,\n ));\n } else if (pathCommand === 'C') {\n ({ length, min, max, point } = segmentCubicFactory(\n ...(data as [number, number, number, number, number, number, number]),\n (distance || 0) - LENGTH,\n ));\n } else if (pathCommand === 'Q') {\n ({ length, min, max, point } = segmentQuadFactory(\n ...(data as [number, number, number, number, number, number]),\n (distance || 0) - LENGTH,\n ));\n } else if (pathCommand === 'Z') {\n data = [x, y, mx, my];\n ({ length, min, max, point } = segmentLineFactory(\n ...(data as [number, number, number, number]),\n (distance || 0) - LENGTH,\n ));\n }\n\n if (distanceIsNumber && LENGTH < distance && LENGTH + length >= distance) {\n POINT = point;\n }\n\n MAX = [...MAX, max];\n MIN = [...MIN, min];\n LENGTH += length;\n\n [x, y] = pathCommand !== 'Z' ? (seg.slice(-2) as [number, number]) : [mx, my];\n }\n\n // native `getPointAtLength` behavior when the given distance\n // is higher than total length\n if (distanceIsNumber && distance >= LENGTH) {\n POINT = { x, y };\n }\n\n return {\n length: LENGTH,\n point: POINT,\n min: {\n x: Math.min(...MIN.map(n => n.x)),\n y: Math.min(...MIN.map(n => n.y)),\n },\n max: {\n x: Math.max(...MAX.map(n => n.x)),\n y: Math.max(...MAX.map(n => n.y)),\n },\n };\n};\nexport default pathLengthFactory;\n","import { PathBBox } from 'src/interface';\nimport { PathArray } from 'src/types';\nimport pathLengthFactory from './pathLengthFactory';\n\n/**\n * Returns the bounding box of a shape.\n *\n * @param path the shape `pathArray`\n * @returns the length of the cubic-bezier segment\n */\nconst getPathBBox = (path?: PathArray | string): PathBBox => {\n if (!path) {\n return {\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n x2: 0,\n y2: 0,\n cx: 0,\n cy: 0,\n cz: 0,\n };\n }\n\n const {\n min: { x: xMin, y: yMin },\n max: { x: xMax, y: yMax },\n } = pathLengthFactory(path);\n\n const width = xMax - xMin;\n const height = yMax - yMin;\n\n return {\n width,\n height,\n x: xMin,\n y: yMin,\n x2: xMax,\n y2: yMax,\n cx: xMin + width / 2,\n cy: yMin + height / 2,\n // an estimted guess\n cz: Math.max(width, height) + Math.min(width, height) / 2,\n };\n};\nexport default getPathBBox;\n","import { CSegment, PathArray, PathCommand } from '../types';\n\n/**\n * Splits an extended A (arc-to) segment into two cubic-bezier segments.\n *\n * @param path the `pathArray` this segment belongs to\n * @param allPathCommands all previous path commands\n * @param i the segment index\n */\nconst fixArc = (path: PathArray, allPathCommands: PathCommand[], i: number) => {\n if (path[i].length > 7) {\n path[i].shift();\n const segment = path[i];\n let ni = i; // ESLint\n while (segment.length) {\n // if created multiple C:s, their original seg is saved\n allPathCommands[i] = 'A';\n path.splice((ni += 1), 0, ['C', ...segment.splice(0, 6)] as CSegment);\n }\n path.splice(i, 1);\n }\n};\nexport default fixArc;\n","import { CurveArray } from '../types';\nimport isNormalizedArray from './isNormalizedArray';\n\n/**\n * Iterates an array to check if it's a `pathArray`\n * with all C (cubic bezier) segments.\n *\n * @param path the `Array` to be checked\n * @returns iteration result\n */\nconst isCurveArray = (path: unknown): path is CurveArray => {\n // `isPathArray` also checks if it's `Array`\n return isNormalizedArray(path) && path.every(([pc]) => 'MC'.includes(pc));\n};\nexport default isCurveArray;\n","/**\n * Returns an {x,y} vector rotated by a given\n * angle in radian.\n *\n * @param x the initial vector x\n * @param y the initial vector y\n * @param rad the radian vector angle\n * @returns the rotated vector\n */\nconst rotateVector = (x: number, y: number, rad: number): { x: number; y: number } => {\n const X = x * Math.cos(rad) - y * Math.sin(rad);\n const Y = x * Math.sin(rad) + y * Math.cos(rad);\n return { x: X, y: Y };\n};\n\nexport default rotateVector;\n","import rotateVector from '../math/rotateVector';\n\n/**\n * Converts A (arc-to) segments to C (cubic-bezier-to).\n *\n * For more information of where this math came from visit:\n * http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes\n *\n * @param X1 the starting x position\n * @param Y1 the starting y position\n * @param RX x-radius of the arc\n * @param RY y-radius of the arc\n * @param angle x-axis-rotation of the arc\n * @param LAF large-arc-flag of the arc\n * @param SF sweep-flag of the arc\n * @param X2 the ending x position\n * @param Y2 the ending y position\n * @param recursive the parameters needed to split arc into 2 segments\n * @return the resulting cubic-bezier segment(s)\n */\nconst arcToCubic = (\n X1: number,\n Y1: number,\n RX: number,\n RY: number,\n angle: number,\n LAF: number,\n SF: number,\n X2: number,\n Y2: number,\n recursive?: [number, number, number, number],\n): number[] => {\n let x1 = X1;\n let y1 = Y1;\n let rx = RX;\n let ry = RY;\n let x2 = X2;\n let y2 = Y2;\n // for more information of where this Math came from visit:\n // http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes\n const d120 = (Math.PI * 120) / 180;\n\n const rad = (Math.PI / 180) * (+angle || 0);\n let res = [] as number[];\n let xy;\n let f1;\n let f2;\n let cx;\n let cy;\n\n if (!recursive) {\n xy = rotateVector(x1, y1, -rad);\n x1 = xy.x;\n y1 = xy.y;\n xy = rotateVector(x2, y2, -rad);\n x2 = xy.x;\n y2 = xy.y;\n\n const x = (x1 - x2) / 2;\n const y = (y1 - y2) / 2;\n let h = (x * x) / (rx * rx) + (y * y) / (ry * ry);\n if (h > 1) {\n h = Math.sqrt(h);\n rx *= h;\n ry *= h;\n }\n const rx2 = rx * rx;\n const ry2 = ry * ry;\n\n const k =\n (LAF === SF ? -1 : 1) *\n Math.sqrt(Math.abs((rx2 * ry2 - rx2 * y * y - ry2 * x * x) / (rx2 * y * y + ry2 * x * x)));\n\n cx = (k * rx * y) / ry + (x1 + x2) / 2;\n cy = (k * -ry * x) / rx + (y1 + y2) / 2;\n // eslint-disable-next-line no-bitwise -- Impossible to satisfy no-bitwise\n f1 = Math.asin(((((y1 - cy) / ry) * 10 ** 9) >> 0) / 10 ** 9);\n // eslint-disable-next-line no-bitwise -- Impossible to satisfy no-bitwise\n f2 = Math.asin(((((y2 - cy) / ry) * 10 ** 9) >> 0) / 10 ** 9);\n\n f1 = x1 < cx ? Math.PI - f1 : f1;\n f2 = x2 < cx ? Math.PI - f2 : f2;\n if (f1 < 0) f1 = Math.PI * 2 + f1;\n if (f2 < 0) f2 = Math.PI * 2 + f2;\n if (SF && f1 > f2) {\n f1 -= Math.PI * 2;\n }\n if (!SF && f2 > f1) {\n f2 -= Math.PI * 2;\n }\n } else {\n [f1, f2, cx, cy] = recursive;\n }\n let df = f2 - f1;\n if (Math.abs(df) > d120) {\n const f2old = f2;\n const x2old = x2;\n const y2old = y2;\n f2 = f1 + d120 * (SF && f2 > f1 ? 1 : -1);\n x2 = cx + rx * Math.cos(f2);\n y2 = cy + ry * Math.sin(f2);\n res = arcToCubic(x2, y2, rx, ry, angle, 0, SF, x2old, y2old, [f2, f2old, cx, cy]);\n }\n df = f2 - f1;\n const c1 = Math.cos(f1);\n const s1 = Math.sin(f1);\n const c2 = Math.cos(f2);\n const s2 = Math.sin(f2);\n const t = Math.tan(df / 4);\n const hx = (4 / 3) * rx * t;\n const hy = (4 / 3) * ry * t;\n const m1 = [x1, y1];\n const m2 = [x1 + hx * s1, y1 - hy * c1];\n const m3 = [x2 + hx * s2, y2 - hy * c2];\n const m4 = [x2, y2];\n m2[0] = 2 * m1[0] - m2[0];\n m2[1] = 2 * m1[1] - m2[1];\n if (recursive) {\n return [...m2, ...m3, ...m4, ...res];\n }\n res = [...m2, ...m3, ...m4, ...res];\n const newres = [];\n for (let i = 0, ii = res.length; i < ii; i += 1) {\n newres[i] = i % 2 ? rotateVector(res[i - 1], res[i], rad).y : rotateVector(res[i], res[i + 1], rad).x;\n }\n return newres;\n};\nexport default arcToCubic;\n","/**\n * Converts a Q (quadratic-bezier) segment to C (cubic-bezier).\n *\n * @param x1 curve start x\n * @param y1 curve start y\n * @param qx control point x\n * @param qy control point y\n * @param x2 curve end x\n * @param y2 curve end y\n * @returns the cubic-bezier segment\n */\nconst quadToCubic = (\n x1: number,\n y1: number,\n qx: number,\n qy: number,\n x2: number,\n y2: number,\n): [number, number, number, number, number, number] => {\n const r13 = 1 / 3;\n const r23 = 2 / 3;\n return [\n r13 * x1 + r23 * qx, // cpx1\n r13 * y1 + r23 * qy, // cpy1\n r13 * x2 + r23 * qx, // cpx2\n r13 * y2 + r23 * qy, // cpy2\n x2,\n y2, // x,y\n ];\n};\nexport default quadToCubic;\n","import midPoint from '../math/midPoint';\n\n/**\n * Converts an L (line-to) segment to C (cubic-bezier).\n *\n * @param x1 line start x\n * @param y1 line start y\n * @param x2 line end x\n * @param y2 line end y\n * @returns the cubic-bezier segment\n */\nconst lineToCubic = (x1: number, y1: number, x2: number, y2: number) => {\n const t = 0.5;\n const mid = midPoint([x1, y1], [x2, y2], t);\n return [...mid, x2, y2, x2, y2];\n};\nexport default lineToCubic;\n","import arcToCubic from './arcToCubic';\nimport quadToCubic from './quadToCubic';\nimport lineToCubic from './lineToCubic';\nimport type { CSegment, MSegment, PathSegment } from '../types';\nimport type { ParserParams } from '../interface';\n\n/**\n * Converts any segment to C (cubic-bezier).\n *\n * @param segment the source segment\n * @param params the source segment parameters\n * @returns the cubic-bezier segment\n */\nconst segmentToCubic = (segment: PathSegment, params: ParserParams): MSegment | CSegment => {\n const [pathCommand] = segment;\n const values = segment.slice(1).map(Number);\n const [x, y] = values;\n let args;\n const { x1: px1, y1: py1, x: px, y: py } = params;\n\n if (!'TQ'.includes(pathCommand)) {\n params.qx = null;\n params.qy = null;\n }\n\n if (pathCommand === 'M') {\n params.x = x;\n params.y = y;\n return segment;\n } else if (pathCommand === 'A') {\n args = [px1, py1, ...values] as [number, number, number, number, number, number, number, number, number];\n return ['C', ...arcToCubic(...args)] as CSegment;\n } else if (pathCommand === 'Q') {\n params.qx = x;\n params.qy = y;\n args = [px1, py1, ...values] as [number, number, number, number, number, number];\n return ['C', ...quadToCubic(...args)] as CSegment;\n } else if (pathCommand === 'L') {\n return ['C', ...lineToCubic(px1, py1, x, y)] as CSegment;\n } else if (pathCommand === 'Z') {\n return ['C', ...lineToCubic(px1, py1, px, py)] as CSegment;\n }\n\n return segment as MSegment | CSegment;\n};\nexport default segmentToCubic;\n","import fixArc from '../process/fixArc';\nimport isCurveArray from '../util/isCurveArray';\nimport normalizePath from '../process/normalizePath';\nimport segmentToCubic from '../process/segmentToCubic';\nimport paramsParser from '../parser/paramsParser';\nimport { CurveArray, PathArray, PathCommand } from '../types';\n\n/**\n * Parses a path string value or 'pathArray' and returns a new one\n * in which all segments are converted to cubic-bezier.\n *\n * In addition, un-necessary `Z` segment is removed if previous segment\n * extends to the `M` segment.\n *\n * @param pathInput the string to be parsed or 'pathArray'\n * @returns the resulted `pathArray` converted to cubic-bezier\n */\nconst pathToCurve = (pathInput: string | PathArray): CurveArray => {\n /* istanbul ignore else */\n if (isCurveArray(pathInput)) {\n return [...pathInput];\n }\n\n const path = normalizePath(pathInput);\n const params = { ...paramsParser };\n const allPathCommands = [] as PathCommand[];\n let pathCommand = ''; // ts-lint\n let ii = path.length;\n\n for (let i = 0; i < ii; i += 1) {\n [pathCommand] = path[i];\n allPathCommands[i] = pathCommand as PathCommand;\n\n path[i] = segmentToCubic(path[i], params);\n\n fixArc(path, allPathCommands, i);\n ii = path.length;\n\n const segment = path[i];\n const seglen = segment.length;\n params.x1 = +segment[seglen - 2];\n params.y1 = +segment[seglen - 1];\n params.x2 = +segment[seglen - 4] || params.x1;\n params.y2 = +segment[seglen - 3] || params.y1;\n }\n\n return path as CurveArray;\n};\nexport default pathToCurve;\n","import pathToCurve from '../convert/pathToCurve';\nimport type { PathArray } from '../types';\n\n/**\n * Returns the area of a single cubic-bezier segment.\n *\n * http://objectmix.com/graphics/133553-area-closed-bezier-curve.html\n *\n * @param x1 the starting point X\n * @param y1 the starting point Y\n * @param c1x the first control point X\n * @param c1y the first control point Y\n * @param c2x the second control point X\n * @param c2y the second control point Y\n * @param x2 the ending point X\n * @param y2 the ending point Y\n * @returns the area of the cubic-bezier segment\n */\nconst getCubicSegArea = (\n x1: number,\n y1: number,\n c1x: number,\n c1y: number,\n c2x: number,\n c2y: number,\n x2: number,\n y2: number,\n) => {\n return (\n (3 *\n ((y2 - y1) * (c1x + c2x) -\n (x2 - x1) * (c1y + c2y) +\n c1y * (x1 - c2x) -\n c1x * (y1 - c2y) +\n y2 * (c2x + x1 / 3) -\n x2 * (c2y + y1 / 3))) /\n 20\n );\n};\n\n/**\n * Returns the area of a shape.\n *\n * @author Jürg Lehni & Jonathan Puckey\n *\n * @see https://github.com/paperjs/paper.js/blob/develop/src/path/Path.js\n *\n * @param path the shape `pathArray`\n * @returns the length of the cubic-bezier segment\n */\nconst getPathArea = (path: PathArray) => {\n let x = 0;\n let y = 0;\n let len = 0;\n\n return pathToCurve(path)\n .map(seg => {\n switch (seg[0]) {\n case 'M':\n [, x, y] = seg;\n return 0;\n default:\n len = getCubicSegArea(x, y, ...(seg.slice(1) as [number, number, number, number, number, number]));\n [x, y] = seg.slice(-2) as [number, number];\n return len;\n }\n })\n .reduce((a, b) => a + b, 0);\n};\nexport default getPathArea;\n","import type { PathArray } from '../types';\nimport pathLengthFactory from './pathLengthFactory';\n\n/**\n * Returns the shape total length, or the equivalent to `shape.getTotalLength()`.\n *\n * The `normalizePath` version is lighter, faster, more efficient and more accurate\n * with paths that are not `curveArray`.\n *\n * @param pathInput the target `pathArray`\n * @returns the shape total length\n */\nconst getTotalLength = (pathInput: string | PathArray): number => {\n return pathLengthFactory(pathInput).length;\n};\nexport default getTotalLength;\n","import getPathArea from './getPathArea';\nimport pathToCurve from '../convert/pathToCurve';\nimport type { PathArray } from '../types';\n\n/**\n * Check if a path is drawn clockwise and returns true if so,\n * false otherwise.\n *\n * @param path the path string or `pathArray`\n * @returns true when clockwise or false if not\n */\nconst getDrawDirection = (path: string | PathArray) => {\n return getPathArea(pathToCurve(path)) >= 0;\n};\n\nexport default getDrawDirection;\n","import type { PathArray } from '../types';\nimport pathLengthFactory from './pathLengthFactory';\n\n/**\n * Returns [x,y] coordinates of a point at a given length of a shape.\n *\n * @param pathInput the `pathArray` to look into\n * @param distance the length of the shape to look at\n * @returns the requested {x, y} point coordinates\n */\nconst getPointAtLength = (pathInput: string | PathArray, distance: number): { x: number; y: number } => {\n return pathLengthFactory(pathInput, distance).point;\n};\nexport default getPointAtLength;\n","import type { PathArray, PathSegment } from '../types';\nimport type { SegmentProperties } from '../interface';\nimport parsePathString from '../parser/parsePathString';\nimport getTotalLength from './getTotalLength';\n\n/**\n * Returns the segment, its index and length as well as\n * the length to that segment at a given length in a path.\n *\n * @param pathInput target `pathArray`\n * @param distance the given length\n * @returns the requested properties\n */\nconst getPropertiesAtLength = (pathInput: string | PathArray, distance?: number): SegmentProperties => {\n const pathArray = parsePathString(pathInput);\n\n let pathTemp = [...pathArray] as PathArray;\n let pathLength = getTotalLength(pathTemp);\n let index = pathTemp.length - 1;\n let lengthAtSegment = 0;\n let length = 0;\n let segment = pathArray[0] as PathSegment;\n const [x, y] = segment.slice(-2) as [number, number];\n const point = { x, y };\n\n // If the path is empty, return 0.\n if (index <= 0 || !distance || !Number.isFinite(distance)) {\n return {\n segment,\n index: 0,\n length,\n point,\n lengthAtSegment,\n };\n }\n\n if (distance >= pathLength) {\n pathTemp = pathArray.slice(0, -1) as PathArray;\n lengthAtSegment = getTotalLength(pathTemp);\n length = pathLength - lengthAtSegment;\n return {\n segment: pathArray[index],\n index,\n length,\n lengthAtSegment,\n };\n }\n\n const segments = [] as SegmentProperties[];\n while (index > 0) {\n segment = pathTemp[index];\n pathTemp = pathTemp.slice(0, -1) as PathArray;\n lengthAtSegment = getTotalLength(pathTemp);\n length = pathLength - lengthAtSegment;\n pathLength = lengthAtSegment;\n segments.push({\n segment,\n index,\n length,\n lengthAtSegment,\n });\n index -= 1;\n }\n\n return segments.find(({ lengthAtSegment: l }) => l <= distance) as SegmentProperties;\n};\nexport default getPropertiesAtLength;\n","import type { PathArray } from '../types';\nimport type { PointProperties } from '../interface';\nimport getPointAtLength from './getPointAtLength';\nimport getPropertiesAtLength from './getPropertiesAtLength';\nimport getTotalLength from './getTotalLength';\nimport parsePathString from '../parser/parsePathString';\nimport normalizePath from '../process/normalizePath';\n\n/**\n * Returns the point and segment in path closest to a given point as well as\n * the distance to the path stroke.\n *\n * @see https://bl.ocks.org/mbostock/8027637\n *\n * @param pathInput target `pathArray`\n * @param point the given point\n * @returns the requested properties\n */\nconst getPropertiesAtPoint = (pathInput: string | PathArray, point: { x: number; y: number }): PointProperties => {\n const path = parsePathString(pathInput);\n const normalPath = normalizePath(path);\n const pathLength = getTotalLength(path);\n const distanceTo = (p: { x: number; y: number }) => {\n const dx = p.x - point.x;\n const dy = p.y - point.y;\n return dx * dx + dy * dy;\n };\n let precision = 8;\n let scan: { x: number; y: number };\n let closest = { x: 0, y: 0 }; // make TS happy\n let scanDistance = 0;\n let bestLength = 0;\n let bestDistance = Infinity;\n\n // linear scan for coarse approximation\n for (let scanLength = 0; scanLength <= pathLength; scanLength += precision) {\n scan = getPointAtLength(normalPath, scanLength);\n scanDistance = distanceTo(scan);\n if (scanDistance < bestDistance) {\n closest = scan;\n bestLength = scanLength;\n bestDistance = scanDistance;\n }\n }\n\n // binary search for precise estimate\n precision /= 2;\n let before: { x: number; y: number };\n let after: { x: number; y: number };\n let beforeLength = 0;\n let afterLength = 0;\n let beforeDistance = 0;\n let afterDistance = 0;\n\n while (precision > 0.5) {\n beforeLength = bestLength - precision;\n before = getPointAtLength(normalPath, beforeLength);\n beforeDistance = distanceTo(before);\n afterLength = bestLength + precision;\n after = getPointAtLength(normalPath, afterLength);\n afterDistance = distanceTo(after);\n if (beforeLength >= 0 && beforeDistance < bestDistance) {\n closest = before;\n bestLength = beforeLength;\n bestDistance = beforeDistance;\n } else if (afterLength <= pathLength && afterDistance < bestDistance) {\n closest = after;\n bestLength = afterLength;\n bestDistance = afterDistance;\n } else {\n precision /= 2;\n }\n }\n\n const segment = getPropertiesAtLength(path, bestLength);\n const distance = Math.sqrt(bestDistance);\n\n return { closest, distance, segment };\n};\n\nexport default getPropertiesAtPoint;\n","import type { PathArray } from '../types';\nimport getPropertiesAtPoint from './getPropertiesAtPoint';\n\n/**\n * Returns the point in path closest to a given point.\n *\n * @param pathInput target `pathArray`\n * @param point the given point\n * @returns the best match\n */\nconst getClosestPoint = (pathInput: string | PathArray, point: { x: number; y: number }): { x: number; y: number } => {\n return getPropertiesAtPoint(pathInput, point).closest;\n};\n\nexport default getClosestPoint;\n","import type { SegmentProperties } from '../interface';\nimport type { PathArray } from '../types';\nimport getPropertiesAtPoint from './getPropertiesAtPoint';\n\n/**\n * Returns the path segment which contains a given point.\n *\n * @param path the `pathArray` to look into\n * @param point the point of the shape to look for\n * @returns the requested segment\n */\nconst getSegmentOfPoint = (\n path: string | PathArray,\n point: { x: number; y: number },\n): SegmentProperties | undefined => {\n return getPropertiesAtPoint(path, point).segment;\n};\nexport default getSegmentOfPoint;\n","import type { PathArray, PathSegment } from '../types';\nimport getPropertiesAtLength from './getPropertiesAtLength';\n\n/**\n * Returns the segment at a given length.\n *\n * @param pathInput the target `pathArray`\n * @param distance the distance in path to look at\n * @returns the requested segment\n */\nconst getSegmentAtLength = (pathInput: string | PathArray, distance?: number): PathSegment | undefined => {\n return getPropertiesAtLength(pathInput, distance).segment;\n};\n\nexport default getSegmentAtLength;\n","import type { PathArray } from '../types';\nimport getPropertiesAtPoint from './getPropertiesAtPoint';\n\n/**\n * Checks if a given point is in the stroke of a path.\n *\n * @param pathInput target path\n * @param point the given `{x,y}` point\n * @returns the query result\n */\nconst isPointInStroke = (pathInput: string | PathArray, point: { x: number; y: number }) => {\n const { distance } = getPropertiesAtPoint(pathInput, point);\n return Math.abs(distance) < 0.001; // 0.01 might be more permissive\n};\nexport default isPointInStroke;\n","import scanSegment from '../parser/scanSegment';\nimport skipSpaces from '../parser/skipSpaces';\nimport PathParser from '../parser/pathParser';\n\n/**\n * Parses a path string value to determine its validity\n * then returns true if it's valid or false otherwise.\n *\n * @param pathString the path string to be parsed\n * @returns the path string validity\n */\nconst isValidPath = (pathString: string) => {\n if (typeof pathString !== 'string') {\n return false;\n }\n\n const path = new PathParser(pathString);\n\n skipSpaces(path);\n\n while (path.index < path.max && !path.err.length) {\n scanSegment(path);\n }\n\n return !path.err.length && 'mM'.includes(path.segments[0][0]);\n};\nexport default isValidPath;\n","import type { RelativeArray } from '../types';\nimport isPathArray from './isPathArray';\n\n/**\n * Iterates an array to check if it's a `pathArray`\n * with relative values.\n *\n * @param path the `pathArray` to be checked\n * @returns iteration result\n */\nconst isRelativeArray = (path: unknown): path is RelativeArray => {\n return (\n isPathArray(path) &&\n // `isPathArray` checks if it's `Array`\n path.slice(1).every(([pc]) => pc === pc.toLowerCase())\n );\n};\nexport default isRelativeArray;\n","import type { PathArray } from 'src/types';\nimport defaultOptions from '../options/options';\n\n/**\n * Rounds the values of a `pathArray` instance to\n * a specified amount of decimals and returns it.\n *\n * @param path the source `pathArray`\n * @param roundOption the amount of decimals to round numbers to\n * @returns the resulted `pathArray` with rounded values\n */\nconst roundPath = (path: PathArray, roundOption?: number | 'off'): PathArray => {\n let { round } = defaultOptions;\n if (roundOption === 'off' || round === 'off') return [...path];\n // allow for ZERO decimals\n round = typeof roundOption === 'number' && roundOption >= 0 ? roundOption : round;\n // to round values to the power\n // the `round` value must be integer\n const pow = typeof round === 'number' && round >= 1 ? 10 ** round : 1;\n\n return path.map(pi => {\n const values = pi\n .slice(1)\n .map(Number)\n .map(n => (round ? Math.round(n * pow) / pow : Math.round(n)));\n return [pi[0], ...values];\n }) as PathArray;\n};\nexport default roundPath;\n","import type { PathArray } from '../types';\nimport roundPath from '../process/roundPath';\n\n/**\n * Returns a valid `d` attribute string value created\n * by rounding values and concatenating the `pathArray` segments.\n *\n * @param path the `pathArray` object\n * @param round amount of decimals to round values to\n * @returns the concatenated path string\n */\nconst pathToString = (path: PathArray, round?: number | 'off'): string => {\n return roundPath(path, round)\n .map(x => x[0] + x.slice(1).join(' '))\n .join('');\n};\nexport default pathToString;\n","import type { CircleAttr, EllipseAttr, GlyphAttr, LineAttr, PolyAttr, RectAttr, ShapeParams } from '../interface';\nimport type { PathArray, PathSegment, ShapeOps, ShapeTypes } from '../types';\nimport pathToString from '../convert/pathToString';\nimport defaultOptions from '../options/options';\nimport error from '../parser/error';\nimport isValidPath from './isValidPath';\n\n/**\n * Supported shapes and their specific parameters.\n */\nconst shapeParams: ShapeParams = {\n line: ['x1', 'y1', 'x2', 'y2'],\n circle: ['cx', 'cy', 'r'],\n ellipse: ['cx', 'cy', 'rx', 'ry'],\n rect: ['width', 'height', 'x', 'y', 'rx', 'ry'],\n polygon: ['points'],\n polyline: ['points'],\n glyph: ['d'],\n};\n\n/**\n * Returns a new `pathArray` from line attributes.\n *\n * @param attr shape configuration\n * @returns a new line `pathArray`\n */\nexport const getLinePath = (attr: LineAttr): PathArray => {\n const { x1, y1, x2, y2 } = attr;\n return [\n ['M', x1, y1],\n ['L', x2, y2],\n ];\n};\n\n/**\n * Returns a new `pathArray` like from polyline/polygon attributes.\n *\n * @param attr shape configuration\n * @return a new polygon/polyline `pathArray`\n */\nexport const getPolyPath = (attr: PolyAttr): PathArray => {\n const pathArray = [] as PathSegment[];\n const points = (attr.points || '')\n .trim()\n .split(/[\\s|,]/)\n .map(Number);\n\n let index = 0;\n while (index < points.length) {\n pathArray.push([index ? 'L' : 'M', points[index], points[index + 1]]);\n index += 2;\n }\n\n return (attr.type === 'polygon' ? [...pathArray, ['z']] : pathArray) as PathArray;\n};\n\n/**\n * Returns a new `pathArray` from circle attributes.\n *\n * @param attr shape configuration\n * @return a circle `pathArray`\n */\nexport const getCirclePath = (attr: CircleAttr): PathArray => {\n const { cx, cy, r } = attr;\n\n return [\n ['M', cx - r, cy],\n ['a', r, r, 0, 1, 0, 2 * r, 0],\n ['a', r, r, 0, 1, 0, -2 * r, 0],\n ];\n};\n\n/**\n * Returns a new `pathArray` from ellipse attributes.\n *\n * @param attr shape configuration\n * @return an ellipse `pathArray`\n */\nexport const getEllipsePath = (attr: EllipseAttr): PathArray => {\n const { cx, cy, rx, ry } = attr;\n\n return [\n ['M', cx - rx, cy],\n ['a', rx, ry, 0, 1, 0, 2 * rx, 0],\n ['a', rx, ry, 0, 1, 0, -2 * rx, 0],\n ];\n};\n\n/**\n * Returns a new `pathArray` like from rect attributes.\n *\n * @param attr object with properties above\n * @return a new `pathArray` from `<rect>` attributes\n */\nexport const getRectanglePath = (attr: RectAttr): PathArray => {\n const x = +attr.x || 0;\n const y = +attr.y || 0;\n const w = +attr.width;\n const h = +attr.height;\n let rx = +attr.rx;\n let ry = +attr.ry;\n\n // Validity checks from http://www.w3.org/TR/SVG/shapes.html#RectElement:\n if (rx || ry) {\n rx = !rx ? ry : rx;\n ry = !ry ? rx : ry;\n\n /* istanbul ignore else */\n if (rx * 2 > w) rx -= (rx * 2 - w) / 2;\n /* istanbul ignore else */\n if (ry * 2 > h) ry -= (ry * 2 - h) / 2;\n\n return [\n ['M', x + rx, y],\n ['h', w - rx * 2],\n ['s', rx, 0, rx, ry],\n ['v', h - ry * 2],\n ['s', 0, ry, -rx, ry],\n ['h', -w + rx * 2],\n ['s', -rx, 0, -rx, -ry],\n ['v', -h + ry * 2],\n ['s', 0, -ry, rx, -ry],\n ];\n }\n\n return [['M', x, y], ['h', w], ['v', h], ['H', x], ['Z']];\n};\n\n/**\n * Returns a new `<path>` element created from attributes of a `<line>`, `<polyline>`,\n * `<polygon>`, `<rect>`, `<ellipse>`, `<circle>` or `<glyph>`. If `replace` parameter\n * is `true`, it will replace the target. The default `ownerDocument` is your current\n * `document` browser page, if you want to use in server-side using `jsdom`, you can\n * pass the `jsdom` `document` to `ownDocument`.\n *\n * It can also work with an options object,\n *\n * @see ShapeOps\n *\n * The newly created `<path>` element keeps all non-specific\n * attributes like `class`, `fill`, etc.\n *\n * @param element target shape\n * @param replace option to replace target\n * @param ownerDocument document for create element\n * @return the newly created `<path>` element\n */\nconst shapeToPath = (\n element: ShapeTypes | ShapeOps,\n replace?: boolean,\n ownerDocument?: Document,\n): SVGPathElement | false => {\n const doc = ownerDocument || document;\n const win = doc.defaultView || /* istanbul ignore next */ window;\n const supportedShapes = Object.keys(shapeParams) as (keyof ShapeParams)[];\n const elementIsElement = element instanceof win.SVGElement;\n const tagName = elementIsElement ? element.tagName : null;\n\n if (tagName && supportedShapes.every(s => tagName !== s)) {\n throw TypeError(`${error}: \"${tagName}\" is not SVGElement`);\n }\n\n const path = doc.createElementNS('http://www.w3.org/2000/svg', 'path');\n const type = (elementIsElement ? tagName : element.type) as ShapeOps['type'];\n const shapeAttrs = shapeParams[type] as string[];\n const config = { type } as Record<string, string>;\n\n if (elementIsElement) {\n shapeAttrs.forEach(p => {\n if (shapeAttrs.includes(p)) config[p] = element.getAttribute(p) as string;\n });\n // set no-specific shape attributes: fill, stroke, etc\n Object.values(element.attributes).forEach(({ name, value }) => {\n if (!shapeAttrs.includes(name)) path.setAttribute(name, value);\n });\n } else {\n Object.assign(config, element);\n // set no-specific shape attributes: fill, stroke, etc\n Object.keys(config).forEach(k => {\n if (!shapeAttrs.includes(k) && k !== 'type') {\n path.setAttribute(\n k.replace(/[A-Z]/g, m => `-${m.toLowerCase()}`),\n config[k],\n );\n }\n });\n }\n\n // set d\n let description = '';\n const round = defaultOptions.round as number;\n\n /* istanbul ignore else */\n if (type === 'circle') description = pathToString(getCirclePath(config as unknown as CircleAttr), round);\n else if (type === 'ellipse') description = pathToString(getEllipsePath(config as unknown as EllipseAttr), round);\n else if (['polyline', 'polygon'].includes(type))\n description = pathToString(getPolyPath(config as unknown as PolyAttr), round);\n else if (type === 'rect') description = pathToString(getRectanglePath(config as unknown as RectAttr), round);\n else if (type === 'line') description = pathToString(getLinePath(config as unknown as LineAttr), round);\n else if (type === 'glyph')\n description = elementIsElement ? (element.getAttribute('d') as string) : (element as GlyphAttr).d;\n\n // replace target element\n if (isValidPath(description)) {\n path.setAttribute('d', description);\n if (replace && elementIsElement) {\n element.before(path, element);\n element.remove();\n }\n return path;\n }\n return false;\n};\nexport default shapeToPath;\n","import type { PathArray } from '../types';\n\n/**\n * Split a path into an `Array` of sub-path strings.\n *\n * In the process, values are converted to absolute\n * for visual consistency.\n *\n * @param pathInput the source `pathArray`\n * @return {SVGPath.pathArray[]} an array with all sub-path strings\n */\nconst splitPath = (pathInput: PathArray): PathArray[] => {\n const composite = [] as PathArray[];\n let path: PathArray;\n let pi = -1;\n\n pathInput.forEach(seg => {\n if (seg[0] === 'M') {\n path = [seg];\n pi += 1;\n } else {\n path = [...path, seg];\n }\n composite[pi] = path;\n });\n\n return composite;\n};\nexport default splitPath;\n","import type {\n aSegment,\n hSegment,\n PathArray,\n RelativeArray,\n RelativeCommand,\n RelativeSegment,\n vSegment,\n} from '../types';\nimport parsePathString from '../parser/parsePathString';\nimport isRelativeArray from '../util/isRelativeArray';\n\n/**\n * Parses a path string value or object and returns an array\n * of segments, all converted to relative values.\n *\n * @param pathInput the path string | object\n * @returns the resulted `pathArray` with relative values\n */\nconst pathToRelative = (pathInput: string | PathArray): RelativeArray => {\n /* istanbul ignore else */\n if (isRelativeArray(pathInput)) {\n return [...pathInput];\n }\n\n const path = parsePathString(pathInput);\n let x = 0;\n let y = 0;\n let mx = 0;\n let my = 0;\n\n return path.map(segment => {\n const values = segment.slice(1).map(Number);\n const [pathCommand] = segment;\n const relativeCommand = pathCommand.toLowerCase() as RelativeCommand;\n\n if (pathCommand === 'M') {\n [x, y] = values;\n mx = x;\n my = y;\n return ['M', x, y];\n }\n\n let relativeSegment = [];\n\n if (pathCommand !== relativeCommand) {\n if (relativeCommand === 'a') {\n relativeSegment = [\n relativeCommand,\n values[0],\n values[1],\n values[2],\n values[3],\n values[4],\n values[5] - x,\n values[6] - y,\n ] as aSegment;\n } else if (relativeCommand === 'v') {\n relativeSegment = [relativeCommand, values[0] - y] as vSegment;\n } else if (relativeCommand === 'h') {\n relativeSegment = [relativeCommand, values[0] - x] as hSegment;\n } else {\n // use brakets for `eslint: no-case-declaration`\n // https://stackoverflow.com/a/50753272/803358\n const relValues = values.map((n, j) => n - (j % 2 ? y : x));\n relativeSegment = [relativeCommand, ...relValues] as RelativeSegment;\n }\n } else {\n if (pathCommand === 'm') {\n mx = values[0] + x;\n my = values[1] + y;\n }\n relativeSegment = [relativeCommand, ...values] as RelativeSegment;\n }\n\n const segLength = relativeSegment.length;\n if (relativeCommand === 'z') {\n x = mx;\n y = my;\n } else if (relativeCommand === 'h') {\n x += relativeSegment[1] as number;\n } else if (relativeCommand === 'v') {\n y += relativeSegment[1] as number;\n } else {\n x += relativeSegment[segLength - 2] as number;\n y += relativeSegment[segLength - 1] as number;\n }\n\n return relativeSegment as typeof segment;\n }) as RelativeArray;\n};\nexport default pathToRelative;\n","import type { ParserParams } from 'src/interface';\nimport type {\n AbsoluteSegment,\n HSegment,\n NormalSegment,\n PathCommand,\n ShortSegment,\n SSegment,\n TSegment,\n VSegment,\n ZSegment,\n} from '../types';\n\n/**\n * Shorten a single segment of a `pathArray` object.\n *\n * @param segment the `absoluteSegment` object\n * @param normalSegment the `normalSegment` object\n * @param params the coordinates of the previous segment\n * @param prevCommand the path command of the previous segment\n * @returns the shortened segment\n */\nconst shortenSegment = (\n segment: AbsoluteSegment,\n normalSegment: NormalSegment,\n params: ParserParams,\n prevCommand: PathCommand,\n): ShortSegment => {\n const [pathCommand] = segment;\n const round4 = (n: number) => Math.round(n * 10 ** 4) / 10 ** 4;\n const segmentValues = segment.slice(1).map(n => +n);\n const normalValues = normalSegment.slice(1).map(n => +n);\n const { x1: px1, y1: py1, x2: px2, y2: py2, x: px, y: py } = params;\n let result = segment;\n const [x, y] = normalValues.slice(-2);\n\n if (!'TQ'.includes(pathCommand)) {\n // optional but good to be cautious\n params.qx = null;\n params.qy = null;\n }\n\n if (['V', 'H', 'S', 'T', 'Z'].includes(pathCommand)) {\n result = [pathCommand, ...segmentValues] as VSegment | HSegment | SSegment | TSegment | ZSegment;\n } else if (pathCommand === 'L') {\n if (round4(px) === round4(x)) {\n result = ['V', y];\n } else if (round4(py) === round4(y)) {\n result = ['H', x];\n }\n } else if (pathCommand === 'C') {\n const [x1, y1] = normalValues;\n\n if (\n 'CS'.includes(prevCommand) &&\n ((round4(x1) === round4(px1 * 2 - px2) && round4(y1) === round4(py1 * 2 - py2)) ||\n (round4(px1) === round4(px2 * 2 - px) && round4(py1) === round4(py2 * 2 - py)))\n ) {\n result = ['S', ...normalValues.slice(-4)] as SSegment;\n }\n params.x1 = x1;\n params.y1 = y1;\n } else if (pathCommand === 'Q') {\n const [qx, qy] = normalValues;\n params.qx = qx;\n params.qy = qy;\n\n if (\n 'QT'.includes(prevCommand) &&\n ((round4(qx) === round4(px1 * 2 - px2) && round4(qy) === round4(py1 * 2 - py2)) ||\n (round4(px1) === round4(px2 * 2 - px) && round4(py1) === round4(py2 * 2 - py)))\n ) {\n result = ['T', ...normalValues.slice(-2)] as TSegment;\n }\n }\n\n return result as ShortSegment;\n};\nexport default shortenSegment;\n","import roundPath from './roundPath';\nimport pathToAbsolute from '../convert/pathToAbsolute';\nimport pathToRelative from '../convert/pathToRelative';\nimport shortenSegment from './shortenSegment';\nimport paramsParser from '../parser/paramsParser';\nimport normalizePath from './normalizePath';\nimport type { PathSegment, HSegment, PathArray, VSegment, PathCommand, AbsoluteSegment } from '../types';\n\n/**\n * Optimizes a `pathArray` object:\n * * convert segments to shorthand if possible\n * * select shortest segments from absolute and relative `pathArray`s\n *\n * @param pathInput a string or `pathArray`\n * @param round the amount of decimals to round values to\n * @returns the optimized `pathArray`\n */\nconst optimizePath = (pathInput: PathArray, round: 'off' | number): PathArray => {\n const path = pathToAbsolute(pathInput);\n const normalPath = normalizePath(path);\n const params = { ...paramsParser };\n const allPathCommands = [] as PathCommand[];\n const ii = path.length;\n let pathCommand = '' as PathCommand;\n let prevCommand = '' as PathCommand;\n let x = 0;\n let y = 0;\n let mx = 0;\n let my = 0;\n\n for (let i = 0; i < ii; i += 1) {\n [pathCommand] = path[i];\n\n // Save current path command\n allPathCommands[i] = pathCommand;\n // Get previous path command for `shortenSegment`\n if (i) prevCommand = allPathCommands[i - 1];\n path[i] = shortenSegment(path[i], normalPath[i], params, prevCommand) as AbsoluteSegment;\n\n const segment = path[i];\n const seglen = segment.length;\n\n // update C, S, Q, T specific params\n params.x1 = +segment[seglen - 2];\n params.y1 = +segment[seglen - 1];\n params.x2 = +segment[seglen - 4] || params.x1;\n params.y2 = +segment[seglen - 3] || params.y1;\n\n // update x, y params\n switch (pathCommand) {\n case 'Z':\n x = mx;\n y = my;\n break;\n case 'H':\n [, x] = segment as HSegment;\n break;\n case 'V':\n [, y] = segment as VSegment;\n break;\n default:\n [x, y] = segment.slice(-2).map(Number);\n\n if (pathCommand === 'M') {\n mx = x;\n my = y;\n }\n }\n params.x = x;\n params.y = y;\n }\n\n const absolutePath = roundPath(path, round);\n const relativePath = roundPath(pathToRelative(path), round);\n\n return absolutePath.map((a: PathSegment, i: number) => {\n if (i) {\n return a.join('').length < relativePath[i].join('').length ? a : relativePath[i];\n }\n return a;\n }) as PathArray;\n};\nexport default optimizePath;\n","import type { CurveArray } from '../types';\n\n/**\n * Reverses all segments of a `pathArray`\n * which consists of only C (cubic-bezier) path commands.\n *\n * @param path the source `pathArray`\n * @returns the reversed `pathArray`\n */\nconst reverseCurve = (path: CurveArray): CurveArray => {\n const rotatedCurve = path\n .slice(1)\n .map((x, i, curveOnly) =>\n !i ? [...path[0].slice(1), ...x.slice(1)] : [...curveOnly[i - 1].slice(-2), ...x.slice(1)],\n )\n .map(x => x.map((_, i) => x[x.length - i - 2 * (1 - (i % 2))]))\n .reverse();\n\n return [['M', ...rotatedCurve[0].slice(0, 2)], ...rotatedCurve.map(x => ['C', ...x.slice(2)])] as CurveArray;\n};\nexport default reverseCurve;\n","import type {\n ASegment,\n CSegment,\n HSegment,\n MSegment,\n PathArray,\n PathSegment,\n QSegment,\n SSegment,\n TSegment,\n VSegment,\n} from 'src/types';\nimport pathToAbsolute from '../convert/pathToAbsolute';\nimport normalizePath from './normalizePath';\n\n/**\n * Reverses all segments of a `pathArray` and returns a new `pathArray` instance.\n *\n * @param pathInput the source `pathArray`\n * @returns the reversed `pathArray`\n */\nconst reversePath = (pathInput: PathArray): PathArray => {\n const absolutePath = pathToAbsolute(pathInput);\n const isClosed = absolutePath.slice(-1)[0][0] === 'Z';\n\n const reversedPath = normalizePath(absolutePath)\n .map((segment, i) => {\n const [x, y] = segment.slice(-2).map(Number);\n return {\n seg: absolutePath[i], // absolute\n n: segment, // normalized\n c: absolutePath[i][0], // pathCommand\n x, // x\n y, // y\n };\n })\n .map((seg, i, path) => {\n const segment = seg.seg;\n const data = seg.n;\n const prevSeg = i && path[i - 1];\n const nextSeg = path[i + 1];\n const pathCommand = seg.c;\n const pLen = path.length;\n const x = i ? path[i - 1].x : path[pLen - 1].x;\n const y = i ? path[i - 1].y : path[pLen - 1].y;\n let result = [];\n\n switch (pathCommand) {\n case 'M':\n result = (isClosed ? ['Z'] : [pathCommand, x, y]) as PathSegment;\n break;\n case 'A':\n result = [pathCommand, ...segment.slice(1, -3), segment[5] === 1 ? 0 : 1, x, y] as ASegment;\n break;\n case 'C':\n if (nextSeg && nextSeg.c === 'S') {\n result = ['S', segment[1], segment[2], x, y] as SSegment;\n } else {\n result = [pathCommand, segment[3], segment[4], segment[1], segment[2], x, y] as CSegment;\n }\n break;\n case 'S':\n if (prevSeg && 'CS'.includes(prevSeg.c) && (!nextSeg || nextSeg.c !== 'S')) {\n result = ['C', data[3], data[4], data[1], data[2], x, y] as CSegment;\n } else {\n result = [pathCommand, data[1], data[2], x, y] as SSegment;\n }\n break;\n case 'Q':\n if (nextSeg && nextSeg.c === 'T') {\n result = ['T', x, y] as TSegment;\n } else {\n result = [pathCommand, ...segment.slice(1, -2), x, y] as QSegment;\n }\n break;\n case 'T':\n if (prevSeg && 'QT'.includes(prevSeg.c) && (!nextSeg || nextSeg.c !== 'T')) {\n result = ['Q', data[1], data[2], x, y] as QSegment;\n } else {\n result = [pathCommand, x, y] as TSegment;\n }\n break;\n case 'Z':\n result = ['M', x, y] as MSegment;\n break;\n case 'H':\n result = [pathCommand, x] as HSegment;\n break;\n case 'V':\n result = [pathCommand, y] as VSegment;\n break;\n default:\n result = [pathCommand, ...segment.slice(1, -2), x, y] as PathSegment;\n }\n\n return result;\n });\n\n return (isClosed ? reversedPath.reverse() : [reversedPath[0], ...reversedPath.slice(1).reverse()]) as PathArray;\n};\nexport default reversePath;\n","import CSSMatrix from '@thednp/dommatrix';\n// import type { TransformObject } from '../interface';\nimport type { TransformObjectValues } from '../types';\n\n/**\n * Returns a transformation matrix to apply to `<path>` elements.\n *\n * @see TransformObjectValues\n *\n * @param transform the `transformObject`\n * @returns a new transformation matrix\n */\nconst getSVGMatrix = (transform: TransformObjectValues): CSSMatrix => {\n let matrix = new CSSMatrix();\n const { origin } = transform;\n const [originX, originY] = origin as [number, number, number];\n const { translate } = transform;\n const { rotate } = transform;\n const { skew } = transform;\n const { scale } = transform;\n\n // set translate\n if (\n Array.isArray(translate) &&\n translate.length >= 2 &&\n translate.every(x => !Number.isNaN(+x)) &&\n translate.some(x => x !== 0)\n ) {\n matrix = matrix.translate(...(translate as [number, number, number?]));\n } else if (typeof translate === 'number' && !Number.isNaN(translate)) {\n matrix = matrix.translate(translate);\n }\n\n if (rotate || skew || scale) {\n // set SVG transform-origin, always defined\n matrix = matrix.translate(originX, originY);\n\n // set rotation\n if (\n Array.isArray(rotate) &&\n rotate.length >= 2 &&\n rotate.every(x => !Number.isNaN(+x)) &&\n rotate.some(x => x !== 0)\n ) {\n matrix = matrix.rotate(...(rotate as [number, number, number?]));\n } else if (typeof rotate === 'number' && !Number.isNaN(rotate)) {\n matrix = matrix.rotate(rotate);\n }\n\n // set skew(s)\n if (Array.isArray(skew) && skew.length === 2 && skew.every(x => !Number.isNaN(+x)) && skew.some(x => x !== 0)) {\n matrix = skew[0] ? matrix.skewX(skew[0]) : matrix;\n matrix = skew[1] ? matrix.skewY(skew[1]) : matrix;\n } else if (typeof skew === 'number' && !Number.isNaN(skew)) {\n matrix = matrix.skewX(skew);\n }\n\n // set scale\n if (Array.isArray(scale) && scale.length >= 2 && scale.every(x => !Number.isNaN(+x)) && scale.some(x => x !== 1)) {\n matrix = matrix.scale(...(scale as [number, number, number?]));\n } else if (typeof scale === 'number' && !Number.isNaN(scale)) {\n matrix = matrix.scale(scale);\n }\n // set SVG transform-origin\n matrix = matrix.translate(-originX, -originY);\n }\n\n return matrix;\n};\nexport default getSVGMatrix;\n","import CSSMatrix from '@thednp/dommatrix';\n\n/**\n * Transforms a specified point using a matrix, returning a new\n * Tuple *Object* comprising of the transformed point.\n * Neither the matrix nor the original point are altered.\n *\n * @copyright thednp © 2021\n *\n * @param cssm CSSMatrix instance\n * @param v Tuple\n * @return the resulting Tuple\n */\nconst translatePoint = (cssm: CSSMatrix, v: [number, number, number, number]): [number, number, number, number] => {\n let m = CSSMatrix.Translate(...(v.slice(0, -1) as [number, number, number]));\n\n [, , , m.m44] = v;\n m = cssm.multiply(m);\n\n return [m.m41, m.m42, m.m43, m.m44];\n};\n\n/**\n * Returns the [x,y] projected coordinates for a given an [x,y] point\n * and an [x,y,z] perspective origin point.\n *\n * Equation found here =>\n * http://en.wikipedia.org/wiki/3D_projection#Diagram\n * Details =>\n * https://stackoverflow.com/questions/23792505/predicted-rendering-of-css-3d-transformed-pixel\n *\n * @param m the transformation matrix\n * @param point2D the initial [x,y] coordinates\n * @param origin the [x,y,z] transform origin\n * @returns the projected [x,y] coordinates\n */\nconst projection2d = (m: CSSMatrix, point2D: [number, number], origin: [number, number, number]): [number, number] => {\n const [originX, originY, originZ] = origin;\n const [x, y, z] = translatePoint(m, [...point2D, 0, 1]);\n\n const relativePositionX = x - originX;\n const relativePositionY = y - originY;\n const relativePositionZ = z - originZ;\n\n return [\n // protect against division by ZERO\n relativePositionX * (Math.abs(originZ) / Math.abs(relativePositionZ) || 1) + originX,\n relativePositionY * (Math.abs(originZ) / Math.abs(relativePositionZ) || 1) + originY,\n ];\n};\nexport default projection2d;\n","import normalizePath from './normalizePath';\nimport pathToAbsolute from '../convert/pathToAbsolute';\nimport segmentToCubic from './segmentToCubic';\nimport fixArc from './fixArc';\nimport getSVGMatrix from './getSVGMatrix';\nimport projection2d from './projection2d';\nimport paramsParser from '../parser/paramsParser';\nimport defaultOptions from '../options/options';\nimport type { PathArray, PathCommand, TransformObjectValues } from '../types';\nimport type { PathTransform, TransformObject } from '../interface';\n\n/**\n * Apply a 2D / 3D transformation to a `pathArray` instance.\n *\n * Since *SVGElement* doesn't support 3D transformation, this function\n * creates a 2D projection of the <path> element.\n *\n * @param path the `pathArray` to apply transformation\n * @param transform the transform functions `Object`\n * @returns the resulted `pathArray`\n */\nconst transformPath = (path: string | PathArray, transform?: Partial<TransformObject>): PathArray => {\n let x = 0;\n let y = 0;\n let i;\n let j;\n let ii;\n let jj;\n let lx;\n let ly;\n const absolutePath = pathToAbsolute(path);\n const transformProps = transform && Object.keys(transform);\n\n // when used as a static method, invalidate somehow\n if (!transform || (transformProps && !transformProps.length)) return [...absolutePath];\n\n const normalizedPath = normalizePath(absolutePath);\n // transform origin is extremely important\n if (!transform.origin) {\n const { origin: defaultOrigin } = defaultOptions;\n Object.assign(transform, { origin: defaultOrigin });\n }\n const matrixInstance = getSVGMatrix(transform as TransformObjectValues);\n const { origin } = transform;\n const params = { ...paramsParser };\n let segment = [];\n let seglen = 0;\n let pathCommand = '';\n let transformedPath = [] as PathTransform[];\n const allPathCommands = [] as PathCommand[]; // needed for arc to curve transformation\n\n if (!matrixInstance.isIdentity) {\n for (i = 0, ii = absolutePath.length; i < ii; i += 1) {\n segment = absolutePath[i];\n\n /* istanbul ignore else */\n if (absolutePath[i]) [pathCommand] = segment;\n\n // REPLACE Arc path commands with Cubic Beziers\n // we don't have any scripting know-how on 3d ellipse transformation\n // Arc segments don't work 3D transformations or skews\n /// ////////////////////////////////////////\n allPathCommands[i] = pathCommand as PathCommand;\n\n if (pathCommand === 'A') {\n segment = segmentToCubic(normalizedPath[i], params);\n\n absolutePath[i] = segmentToCubic(normalizedPath[i], params);\n fixArc(absolutePath, allPathCommands, i);\n\n normalizedPath[i] = segmentToCubic(normalizedPath[i], params);\n fixArc(normalizedPath, allPathCommands, i);\n ii = Math.max(absolutePath.length, normalizedPath.length);\n }\n\n /// ////////////////////////////////////////\n segment = normalizedPath[i];\n seglen = segment.length;\n\n params.x1 = +segment[seglen - 2];\n params.y1 = +segment[seglen - 1];\n params.x2 = +segment[seglen - 4] || params.x1;\n params.y2 = +segment[seglen - 3] || params.y1;\n\n const result = {\n s: absolutePath[i],\n c: absolutePath[i][0],\n x: params.x1,\n y: params.y1,\n };\n\n transformedPath = [...transformedPath, ...[result]];\n }\n\n return transformedPath.map(seg => {\n pathCommand = seg.c;\n segment = seg.s;\n if (pathCommand === 'L' || pathCommand === 'H' || pathCommand === 'V') {\n [lx, ly] = projection2d(matrixInstance, [seg.x, seg.y], origin as [number, number, number]);\n\n /* istanbul ignore else */\n if (x !== lx && y !== ly) {\n segment = ['L', lx, ly];\n } else if (y === ly) {\n segment = ['H', lx];\n } else if (x === lx) {\n segment = ['V', ly];\n }\n\n // now update x and y\n x = lx;\n y = ly;\n\n return segment;\n } else {\n for (j = 1, jj = segment.length; j < jj; j += 2) {\n [x, y] = projection2d(matrixInstance, [+segment[j], +segment[j + 1]], origin as [number, number, number]);\n segment[j] = x;\n segment[j + 1] = y;\n }\n\n return segment;\n }\n }) as PathArray;\n }\n return [...absolutePath];\n};\nexport default transformPath;\n","import midPoint from '../math/midPoint';\nimport type { CubicSegment } from '../types';\n\n/**\n * Split a cubic-bezier segment into two.\n *\n * @param pts the cubic-bezier parameters\n * @return two new cubic-bezier segments\n */\nconst splitCubic = (pts: number[] /* , ratio */): [CubicSegment, CubicSegment] => {\n const t = /* ratio || */ 0.5;\n const p0 = pts.slice(0, 2) as [number, number];\n const p1 = pts.slice(2, 4) as [number, number];\n const p2 = pts.slice(4, 6) as [number, number];\n const p3 = pts.slice(6, 8) as [number, number];\n const p4 = midPoint(p0, p1, t);\n const p5 = midPoint(p1, p2, t);\n const p6 = midPoint(p2, p3, t);\n const p7 = midPoint(p4, p5, t);\n const p8 = midPoint(p5, p6, t);\n const p9 = midPoint(p7, p8, t);\n\n return [\n ['C', ...p4, ...p7, ...p9],\n ['C', ...p8, ...p6, ...p3],\n ];\n};\nexport default splitCubic;\n","import { PathArray, TransformObjectValues } from './types';\nimport { Options, PathBBox, TransformEntries, TransformObject } from './interface';\nimport defaultOptions from './options/options';\n\nimport error from './parser/error';\nimport parsePathString from './parser/parsePathString';\n\nimport polygonArea from './math/polygonArea';\nimport polygonLength from './math/polygonLength';\n\nimport CSSMatrix from '@thednp/dommatrix';\nimport getPathBBox from './util/getPathBBox';\nimport getPathArea from './util/getPathArea';\nimport getTotalLength from './util/getTotalLength';\nimport getDrawDirection from './util/getDrawDirection';\nimport getPointAtLength from './util/getPointAtLength';\nimport pathLengthFactory from './util/pathLengthFactory';\n\nimport getPropertiesAtLength from './util/getPropertiesAtLength';\nimport getPropertiesAtPoint from './util/getPropertiesAtPoint';\nimport getClosestPoint from './util/getClosestPoint';\nimport getSegmentOfPoint from './util/getSegmentOfPoint';\nimport getSegmentAtLength from './util/getSegmentAtLength';\nimport isPointInStroke from './util/isPointInStroke';\n\nimport isValidPath from './util/isValidPath';\nimport isPathArray from './util/isPathArray';\nimport isAbsoluteArray from './util/isAbsoluteArray';\nimport isRelativeArray from './util/isRelativeArray';\nimport isCurveArray from './util/isCurveArray';\nimport isNormalizedArray from './util/isNormalizedArray';\nimport shapeToPath from './util/shapeToPath';\n\nimport roundPath from './process/roundPath';\nimport splitPath from './process/splitPath';\nimport optimizePath from './process/optimizePath';\nimport reverseCurve from './process/reverseCurve';\nimport reversePath from './process/reversePath';\nimport normalizePath from './process/normalizePath';\nimport transformPath from './process/transformPath';\nimport splitCubic from './process/splitCubic';\n\nimport pathToAbsolute from './convert/pathToAbsolute';\nimport pathToRelative from './convert/pathToRelative';\nimport pathToCurve from './convert/pathToCurve';\nimport pathToString from './convert/pathToString';\n\n/**\n * Creates a new SVGPathCommander instance with the following properties:\n * * segments: `pathArray`\n * * round: number\n * * origin: [number, number, number?]\n *\n * @class\n * @author thednp <https://github.com/thednp/svg-path-commander>\n * @returns {SVGPathCommander} a new SVGPathCommander instance\n */\nclass SVGPathCommander {\n // bring main utilities to front\n public static CSSMatrix = CSSMatrix;\n public static getPathBBox = getPathBBox;\n public static getPathArea = getPathArea;\n public static getTotalLength = getTotalLength;\n public static getDrawDirection = getDrawDirection;\n public static getPointAtLength = getPointAtLength;\n public static pathLengthFactory = pathLengthFactory;\n public static getPropertiesAtLength = getPropertiesAtLength;\n public static getPropertiesAtPoint = getPropertiesAtPoint;\n public static polygonLength = polygonLength;\n public static polygonArea = polygonArea;\n public static getClosestPoint = getClosestPoint;\n public static getSegmentOfPoint = getSegmentOfPoint;\n public static getSegmentAtLength = getSegmentAtLength;\n public static isPointInStroke = isPointInStroke;\n public static isValidPath = isValidPath;\n public static isPathArray = isPathArray;\n public static isAbsoluteArray = isAbsoluteArray;\n public static isRelativeArray = isRelativeArray;\n public static isCurveArray = isCurveArray;\n public static isNormalizedArray = isNormalizedArray;\n public static shapeToPath = shapeToPath;\n public static parsePathString = parsePathString;\n public static roundPath = roundPath;\n public static splitPath = splitPath;\n public static splitCubic = splitCubic;\n public static optimizePath = optimizePath;\n public static reverseCurve = reverseCurve;\n public static reversePath = reversePath;\n public static normalizePath = normalizePath;\n public static transformPath = transformPath;\n public static pathToAbsolute = pathToAbsolute;\n public static pathToRelative = pathToRelative;\n public static pathToCurve = pathToCurve;\n public static pathToString = pathToString;\n // declare class properties\n declare segments: PathArray;\n declare round: number | 'off';\n declare origin: [number, number, number];\n\n /**\n * @constructor\n * @param {string} pathValue the path string\n * @param {any} config instance options\n */\n constructor(pathValue: string, config?: Partial<Options>) {\n const instanceOptions = config || {};\n const undefPath = typeof pathValue === 'undefined';\n\n if (undefPath || !pathValue.length) {\n throw TypeError(`${error}: \"pathValue\" is ${undefPath ? 'undefined' : 'empty'}`);\n }\n\n const segments = parsePathString(pathValue);\n // if (typeof segments === 'string') {\n // throw TypeError(segments);\n // }\n\n this.segments = segments;\n\n const { width, height, cx, cy, cz } = this.getBBox();\n\n // set instance options.round\n const { round: roundOption, origin: originOption } = instanceOptions;\n let round: number | 'off';\n\n if (roundOption === 'auto') {\n const pathScale = `${Math.floor(Math.max(width, height))}`.length;\n round = pathScale >= 4 ? 0 : 4 - pathScale;\n } else if (Number.isInteger(roundOption) || roundOption === 'off') {\n round = roundOption as number | 'off';\n } else {\n round = defaultOptions.round as number;\n }\n\n // set instance options.origin\n // the SVGPathCommander class will always override the default origin\n let origin: [number, number, number];\n if (Array.isArray(originOption) && originOption.length >= 2) {\n const [originX, originY, originZ] = originOption.map(Number);\n origin = [\n !Number.isNaN(originX) ? originX : cx,\n !Number.isNaN(originY) ? originY : cy,\n !Number.isNaN(originZ) ? originZ : cz,\n ];\n } else {\n origin = [cx, cy, cz];\n }\n\n this.round = round;\n this.origin = origin;\n\n return this;\n }\n\n /**\n * Returns the path bounding box, equivalent to native `path.getBBox()`.\n *\n * @public\n * @returns the pathBBox\n */\n getBBox(): PathBBox {\n return getPathBBox(this.segments);\n }\n\n /**\n * Returns the total path length, equivalent to native `path.getTotalLength()`.\n *\n * @public\n * @returns the path total length\n */\n getTotalLength() {\n return getTotalLength(this.segments);\n }\n\n /**\n * Returns an `{x,y}` point in the path stroke at a given length,\n * equivalent to the native `path.getPointAtLength()`.\n *\n * @public\n * @param length the length\n * @returns the requested point\n */\n getPointAtLength(length: number): { x: number; y: number } {\n return getPointAtLength(this.segments, length);\n }\n\n /**\n * Convert path to absolute values\n *\n * @public\n */\n toAbsolute() {\n const { segments } = this;\n this.segments = pathToAbsolute(segments);\n return this;\n }\n\n /**\n * Convert path to relative values\n *\n * @public\n */\n toRelative() {\n const { segments } = this;\n this.segments = pathToRelative(segments);\n return this;\n }\n\n /**\n * Convert path to cubic-bezier values. In addition, un-necessary `Z`\n * segment is removed if previous segment extends to the `M` segment.\n *\n * @public\n */\n toCurve() {\n const { segments } = this;\n this.segments = pathToCurve(segments);\n return this;\n }\n\n /**\n * Reverse the order of the segments and their values.\n *\n * @param onlySubpath option to reverse all sub-paths except first\n * @public\n */\n reverse(onlySubpath?: boolean) {\n this.toAbsolute();\n\n const { segments } = this;\n const split = splitPath(segments);\n const subPath = split.length > 1 ? split : false;\n\n const absoluteMultiPath = subPath\n ? [...subPath].map((x, i) => {\n if (onlySubpath) {\n // return i ? reversePath(x) : parsePathString(x);\n return i ? reversePath(x) : [...x];\n }\n return reversePath(x);\n })\n : [...segments];\n\n let path = [];\n if (subPath) {\n path = absoluteMultiPath.flat(1);\n } else {\n path = onlySubpath ? segments : reversePath(segments);\n }\n\n this.segments = [...path] as PathArray;\n return this;\n }\n\n /**\n * Normalize path in 2 steps:\n * * convert `pathArray`(s) to absolute values\n * * convert shorthand notation to standard notation\n *\n * @public\n */\n normalize() {\n const { segments } = this;\n this.segments = normalizePath(segments);\n return this;\n }\n\n /**\n * Optimize `pathArray` values:\n * * convert segments to absolute and/or relative values\n * * select segments with shortest resulted string\n * * round values to the specified `decimals` option value\n *\n * @public\n */\n optimize() {\n const { segments } = this;\n\n this.segments = optimizePath(segments, this.round);\n return this;\n }\n\n /**\n * Transform path using values from an `Object` defined as `transformObject`.\n *\n * @see TransformObject for a quick refference\n *\n * @param source a `transformObject`as described above\n * @public\n */\n transform(source?: Partial<TransformObject>) {\n if (\n !source ||\n typeof source !== 'object' ||\n (typeof source === 'object' && !['translate', 'rotate', 'skew', 'scale'].some(x => x in source))\n )\n return this;\n\n const {\n segments,\n origin: [cx, cy, cz],\n } = this;\n const transform = {} as TransformObjectValues;\n for (const [k, v] of Object.entries(source) as TransformEntries) {\n if (k === 'skew' && Array.isArray(v)) {\n transform[k] = v.map(Number) as [number, number];\n } else if ((k === 'rotate' || k === 'translate' || k === 'origin' || k === 'scale') && Array.isArray(v)) {\n transform[k] = v.map(Number) as [number, number, number];\n } else if (k !== 'origin' && typeof Number(v) === 'number') transform[k] = Number(v);\n }\n\n // if origin is not specified\n // it's important that we have one\n const { origin } = transform;\n\n if (Array.isArray(origin) && origin.length >= 2) {\n const [originX, originY, originZ] = origin.map(Number);\n transform.origin = [!Number.isNaN(originX) ? originX : cx, !Number.isNaN(originY) ? originY : cy, originZ || cz];\n } else {\n transform.origin = [cx, cy, cz];\n }\n\n this.segments = transformPath(segments, transform);\n return this;\n }\n\n /**\n * Rotate path 180deg vertically\n *\n * @public\n */\n flipX() {\n this.transform({ rotate: [0, 180, 0] });\n return this;\n }\n\n /**\n * Rotate path 180deg horizontally\n *\n * @public\n */\n flipY() {\n this.transform({ rotate: [180, 0, 0] });\n return this;\n }\n\n /**\n * Export the current path to be used\n * for the `d` (description) attribute.\n *\n * @public\n * @return the path string\n */\n toString() {\n return pathToString(this.segments, this.round);\n }\n}\n\nexport default SVGPathCommander;\n"],"names":["defaultOptions","error","paramsCount","finalizeSegment","path","pathCommand","LK","data","scanFlag","index","pathValue","code","isDigit","invalidPathValue","scanParam","max","start","zeroFirst","hasCeiling","hasDecimal","hasDot","ch","isSpace","skipSpaces","isPathCommand","isDigitStart","isArcCommand","scanSegment","cmdCode","reqParams","paramCounts","i","PathParser","pathString","isPathArray","seg","lk","parsePathString","pathInput","polygonArea","polygon","n","a","b","area","distanceSquareRoot","polygonLength","length","point","Z","z","s","e","p","$","E","P","y","g","r","m","h","c","u","f","w","o","d","A","M","X","O","x","Y","F","T","k","I","v","R","D","N","isAbsoluteArray","pathToAbsolute","mx","my","segment","values","absCommand","absoluteSegment","absValues","j","normalizeSegment","params","px1","py1","px2","py2","result","x1","y1","qx","qy","nqx","nqy","isNormalizedArray","pc","paramsParser","normalizePath","ii","seglen","midPoint","t","ax","ay","bx","by","segmentLineFactory","x2","y2","distance","angleBetween","v0","v1","v0x","v0y","v1x","v1y","getPointAtArcSegmentLength","RX","RY","angle","LAF","SF","abs","sin","cos","sqrt","PI","rx","ry","xRotRad","dx","dy","transformedPoint","radiiCheck","cSquareNumerator","cSquareRootDenom","cRadicand","cCoef","transformedCenter","center","startVector","startAngle","endVector","sweepAngle","alpha","ellipseComponentX","ellipseComponentY","segmentArcFactory","X1","Y1","X2","Y2","distanceIsNumber","LENGTH","prev","cur","POINT","POINTS","sampleSize","dv","getPointAtCubicSegmentLength","c1x","c1y","c2x","c2y","t1","segmentCubicFactory","getPointAtQuadSegmentLength","cx","cy","segmentQuadFactory","pathLengthFactory","isM","MIN","MAX","min","ll","getPathBBox","xMin","yMin","xMax","yMax","width","height","fixArc","allPathCommands","ni","isCurveArray","rotateVector","rad","arcToCubic","recursive","d120","res","xy","f1","f2","rx2","ry2","df","f2old","x2old","y2old","c1","s1","c2","s2","hx","hy","m1","m2","m3","m4","newres","quadToCubic","r13","r23","lineToCubic","segmentToCubic","args","px","py","pathToCurve","getCubicSegArea","getPathArea","len","getTotalLength","getDrawDirection","getPointAtLength","getPropertiesAtLength","pathArray","pathTemp","pathLength","lengthAtSegment","segments","l","getPropertiesAtPoint","normalPath","distanceTo","precision","scan","closest","scanDistance","bestLength","bestDistance","scanLength","before","after","beforeLength","afterLength","beforeDistance","afterDistance","getClosestPoint","getSegmentOfPoint","getSegmentAtLength","isPointInStroke","isValidPath","isRelativeArray","roundPath","roundOption","round","pow","pi","pathToString","shapeParams","getLinePath","attr","getPolyPath","points","getCirclePath","getEllipsePath","getRectanglePath","shapeToPath","element","replace","ownerDocument","doc","win","supportedShapes","elementIsElement","tagName","type","shapeAttrs","config","name","value","description","splitPath","composite","pathToRelative","relativeCommand","relativeSegment","relValues","segLength","shortenSegment","normalSegment","prevCommand","round4","segmentValues","normalValues","optimizePath","absolutePath","relativePath","reverseCurve","rotatedCurve","curveOnly","_","reversePath","isClosed","reversedPath","prevSeg","nextSeg","pLen","getSVGMatrix","transform","matrix","CSSMatrix","origin","originX","originY","translate","rotate","skew","scale","translatePoint","cssm","projection2d","point2D","originZ","relativePositionX","relativePositionY","relativePositionZ","transformPath","jj","lx","ly","transformProps","normalizedPath","defaultOrigin","matrixInstance","transformedPath","splitCubic","pts","p0","p1","p2","p3","p4","p5","p6","p7","p8","p9","SVGPathCommander","instanceOptions","undefPath","cz","originOption","pathScale","onlySubpath","split","subPath","absoluteMultiPath","source"],"mappings":"aAGA,MAAMA,GAA0B,CAC9B,OAAQ,CAAC,EAAG,EAAG,CAAC,EAChB,MAAO,CACT,ECNMC,EAAQ,yBCCRC,EAAc,CAClB,EAAG,EACH,EAAG,EACH,EAAG,EACH,EAAG,EACH,EAAG,EACH,EAAG,EACH,EAAG,EACH,EAAG,EACH,EAAG,EACH,EAAG,EACH,EAAG,CACL,ECJMC,GAAmBC,GAAqB,CACxC,IAAAC,EAAcD,EAAK,UAAUA,EAAK,cAClCE,EAAKD,EAAY,cACf,KAAA,CAAE,KAAAE,CAAS,EAAAH,EAEV,KAAAG,EAAK,QAAUL,EAAYI,KAG5BA,IAAO,KAAOC,EAAK,OAAS,GACzBH,EAAA,SAAS,KAAK,CAACC,EAAa,GAAIE,EAAK,OAAO,EAAG,CAAC,CAAc,CAAgB,EAC9ED,EAAA,IACSD,EAAAA,IAAgB,IAAM,IAAM,KAErCD,EAAA,SAAS,KAAK,CAACC,EAAa,GAAIE,EAAK,OAAO,EAAGL,EAAYI,EAAG,C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