ipx 4.0.0-beta.1 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +222 -209
- package/dist/THIRD-PARTY-LICENSES.md.gz +0 -0
- package/dist/_chunks/libs/@fastify/accept-negotiator.mjs +22 -23
- package/dist/_chunks/libs/css-select.mjs +1077 -937
- package/dist/_chunks/libs/css-tree.mjs +107 -191
- package/dist/_chunks/libs/csso.mjs +50 -82
- package/dist/_chunks/libs/h3.mjs +107 -106
- package/dist/_chunks/libs/image-meta.d.mts +2 -2
- package/dist/_chunks/libs/image-meta.mjs +464 -305
- package/dist/_chunks/libs/sax.mjs +61 -60
- package/dist/_chunks/libs/svgo.mjs +933 -1008
- package/dist/_chunks/node-fs.mjs +125 -49
- package/dist/_chunks/rolldown-runtime.mjs +2 -11
- package/dist/cli.mjs +4 -3
- package/dist/index.d.mts +64 -11
- package/package.json +30 -29
- package/dist/THIRD-PARTY-LICENSES.md +0 -593
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { __commonJSMin as e, __require as t
|
|
2
|
-
import {
|
|
3
|
-
import { require_cjs$1 as
|
|
4
|
-
import { require_cjs as
|
|
5
|
-
import { require_sax as
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
function
|
|
1
|
+
import { __commonJSMin as e, __require as t } from "../rolldown-runtime.mjs";
|
|
2
|
+
import { require_commonjs as n, require_commonjs$1 as r } from "./css-select.mjs";
|
|
3
|
+
import { require_cjs$1 as i } from "./css-tree.mjs";
|
|
4
|
+
import { require_cjs as a } from "./csso.mjs";
|
|
5
|
+
import { require_sax as o } from "./sax.mjs";
|
|
6
|
+
var s = e(((e) => {
|
|
7
|
+
var s = t(`os`), c = t(`fs/promises`), l = t(`path`), u = n(), d = r(), f = i(), p = a(), m = o(), h = t(`url`);
|
|
8
|
+
function g(e) {
|
|
9
9
|
var t = Object.create(null);
|
|
10
|
-
return e && Object.keys(e).forEach(
|
|
10
|
+
return e && Object.keys(e).forEach(function(n) {
|
|
11
11
|
if (n !== "default") {
|
|
12
12
|
var r = Object.getOwnPropertyDescriptor(e, n);
|
|
13
13
|
Object.defineProperty(t, n, r.get ? r : {
|
|
@@ -17,17 +17,17 @@ var l = e(((e) => {
|
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
})
|
|
20
|
+
}), t.default = e, Object.freeze(t);
|
|
21
21
|
}
|
|
22
|
-
var
|
|
23
|
-
let
|
|
22
|
+
var _ = g(d), v = g(f), y = g(p);
|
|
23
|
+
let b = Symbol(), x = (e, t, n) => {
|
|
24
24
|
let r = t[e.type];
|
|
25
|
-
if (!(r?.enter && r.enter(e, n) ===
|
|
26
|
-
if (e.type === `root`) for (let n of e.children)
|
|
27
|
-
if (e.type === `element` && n.children.includes(e)) for (let n of e.children)
|
|
25
|
+
if (!(r?.enter && r.enter(e, n) === b)) {
|
|
26
|
+
if (e.type === `root`) for (let n of e.children) x(n, t, e);
|
|
27
|
+
if (e.type === `element` && n.children.includes(e)) for (let n of e.children) x(n, t, e);
|
|
28
28
|
r?.exit && r.exit(e, n);
|
|
29
29
|
}
|
|
30
|
-
},
|
|
30
|
+
}, S = (e, t, n, r, i) => {
|
|
31
31
|
for (let a of n) {
|
|
32
32
|
let n = r?.[a.name];
|
|
33
33
|
if (n === !1) continue;
|
|
@@ -36,7 +36,7 @@ var l = e(((e) => {
|
|
|
36
36
|
...i,
|
|
37
37
|
...n
|
|
38
38
|
}, s = a.fn(e, o, t);
|
|
39
|
-
s != null &&
|
|
39
|
+
s != null && x(e, s);
|
|
40
40
|
}
|
|
41
41
|
}, ee = ({ name: e, plugins: t }) => ({
|
|
42
42
|
name: e,
|
|
@@ -45,46 +45,34 @@ var l = e(((e) => {
|
|
|
45
45
|
fn: (n, r, i) => {
|
|
46
46
|
let { floatPrecision: a, overrides: o } = r, s = {};
|
|
47
47
|
if (a != null && (s.floatPrecision = a), o) {
|
|
48
|
-
let n = t.map((
|
|
48
|
+
let n = t.map(({ name: e }) => e);
|
|
49
49
|
for (let t of Object.keys(o)) n.includes(t) || console.warn(`You are trying to configure ${t} which is not part of ${e}.\nTry to put it before or after, for example\n\nplugins: [\n {\n name: '${e}',\n },\n '${t}'\n]\n`);
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
S(n, i, t, o, s);
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
|
-
function
|
|
54
|
+
function C(e) {
|
|
55
55
|
let t = /* @__PURE__ */ new Map();
|
|
56
|
-
for (let n of e.children) t.set(n, e),
|
|
56
|
+
for (let n of e.children) t.set(n, e), x(n, { element: { enter: (e, n) => {
|
|
57
57
|
t.set(e, n);
|
|
58
58
|
} } }, e);
|
|
59
59
|
return t;
|
|
60
60
|
}
|
|
61
|
-
let
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return n;
|
|
65
|
-
}, se = (e, t) => {
|
|
66
|
-
for (let n of t) if (E(n)) {
|
|
67
|
-
if (e(n)) return n;
|
|
68
|
-
let t = se(e, D(n));
|
|
69
|
-
if (t) return t;
|
|
70
|
-
}
|
|
71
|
-
return null;
|
|
72
|
-
};
|
|
73
|
-
function ce(e, t) {
|
|
74
|
-
let n = (n) => (t ||= T(e), t.get(n) || null);
|
|
61
|
+
let w = (e) => e.type === `element`, te = (e, t) => e.attributes[t], T = (e) => e.children || [], ne = (e) => e.name, re = (e) => e.children[0].type === `text` || e.children[0].type === `cdata` ? e.children[0].value : ``, ie = (e, t) => e.attributes[t] !== void 0;
|
|
62
|
+
function ae(e, t) {
|
|
63
|
+
let n = (n) => (t ||= C(e), t.get(n) || null);
|
|
75
64
|
return {
|
|
76
|
-
isTag:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
getName: re,
|
|
65
|
+
isTag: w,
|
|
66
|
+
getAttributeValue: te,
|
|
67
|
+
getChildren: T,
|
|
68
|
+
getName: ne,
|
|
81
69
|
getParent: n,
|
|
82
70
|
getSiblings: (e) => {
|
|
83
71
|
let t = n(e);
|
|
84
|
-
return t ?
|
|
72
|
+
return t ? T(t) : [];
|
|
85
73
|
},
|
|
86
|
-
getText:
|
|
87
|
-
hasAttrib:
|
|
74
|
+
getText: re,
|
|
75
|
+
hasAttrib: ie,
|
|
88
76
|
removeSubsets: (e) => {
|
|
89
77
|
let t = e.length, r, i, a;
|
|
90
78
|
for (; --t > -1;) {
|
|
@@ -98,52 +86,50 @@ var l = e(((e) => {
|
|
|
98
86
|
a && (e[t] = r);
|
|
99
87
|
}
|
|
100
88
|
return e;
|
|
101
|
-
}
|
|
102
|
-
findAll: oe,
|
|
103
|
-
findOne: se
|
|
89
|
+
}
|
|
104
90
|
};
|
|
105
91
|
}
|
|
106
|
-
function
|
|
92
|
+
function oe(e, t) {
|
|
107
93
|
return {
|
|
108
94
|
xmlMode: !0,
|
|
109
|
-
adapter:
|
|
95
|
+
adapter: ae(e, t)
|
|
110
96
|
};
|
|
111
97
|
}
|
|
112
|
-
let
|
|
113
|
-
t.children = t.children.filter((
|
|
98
|
+
let E = (e, t, n) => u.selectAll(t, e, oe(e, n)), se = (e, t, n) => u.selectOne(t, e, oe(e, n)), ce = (e, t, n) => t !== `` && u.is(e, t, oe(e, n)), D = (e, t) => {
|
|
99
|
+
t.children = t.children.filter((t) => t !== e);
|
|
114
100
|
};
|
|
115
|
-
var
|
|
101
|
+
var le = Object.freeze({
|
|
116
102
|
__proto__: null,
|
|
117
103
|
description: `removes doctype declaration`,
|
|
118
104
|
fn: () => ({ doctype: { enter: (e, t) => {
|
|
119
|
-
|
|
105
|
+
D(e, t);
|
|
120
106
|
} } }),
|
|
121
107
|
name: `removeDoctype`
|
|
122
|
-
}),
|
|
108
|
+
}), ue = Object.freeze({
|
|
123
109
|
__proto__: null,
|
|
124
110
|
description: `removes XML processing instructions`,
|
|
125
111
|
fn: () => ({ instruction: { enter: (e, t) => {
|
|
126
|
-
e.name === `xml` &&
|
|
112
|
+
e.name === `xml` && D(e, t);
|
|
127
113
|
} } }),
|
|
128
114
|
name: `removeXMLProcInst`
|
|
129
115
|
});
|
|
130
|
-
let
|
|
131
|
-
var
|
|
116
|
+
let de = [/^!/];
|
|
117
|
+
var fe = Object.freeze({
|
|
132
118
|
__proto__: null,
|
|
133
119
|
description: `removes comments`,
|
|
134
120
|
fn: (e, t) => {
|
|
135
|
-
let { preservePatterns: n =
|
|
121
|
+
let { preservePatterns: n = de } = t;
|
|
136
122
|
return { comment: { enter: (e, t) => {
|
|
137
123
|
if (n) {
|
|
138
124
|
if (!Array.isArray(n)) throw Error(`Expected array in removeComments preservePatterns parameter but received ${n}`);
|
|
139
|
-
if (n.some((
|
|
125
|
+
if (n.some((t) => new RegExp(t).test(e.value))) return;
|
|
140
126
|
}
|
|
141
|
-
|
|
127
|
+
D(e, t);
|
|
142
128
|
} } };
|
|
143
129
|
},
|
|
144
130
|
name: `removeComments`
|
|
145
131
|
});
|
|
146
|
-
let
|
|
132
|
+
let O = {
|
|
147
133
|
animation: /* @__PURE__ */ new Set([
|
|
148
134
|
`animate`,
|
|
149
135
|
`animateColor`,
|
|
@@ -253,15 +239,15 @@ var l = e(((e) => {
|
|
|
253
239
|
`feTile`,
|
|
254
240
|
`feTurbulence`
|
|
255
241
|
])
|
|
256
|
-
},
|
|
257
|
-
...
|
|
242
|
+
}, pe = /* @__PURE__ */ new Set([
|
|
243
|
+
...O.textContent,
|
|
258
244
|
`pre`,
|
|
259
245
|
`title`
|
|
260
|
-
]),
|
|
246
|
+
]), me = /* @__PURE__ */ new Set([
|
|
261
247
|
`glyph`,
|
|
262
248
|
`missing-glyph`,
|
|
263
249
|
`path`
|
|
264
|
-
]),
|
|
250
|
+
]), k = {
|
|
265
251
|
animationAddition: /* @__PURE__ */ new Set([`additive`, `accumulate`]),
|
|
266
252
|
animationAttributeTarget: /* @__PURE__ */ new Set([`attributeType`, `attributeName`]),
|
|
267
253
|
animationEvent: /* @__PURE__ */ new Set([
|
|
@@ -354,7 +340,7 @@ var l = e(((e) => {
|
|
|
354
340
|
`tableValues`,
|
|
355
341
|
`type`
|
|
356
342
|
])
|
|
357
|
-
},
|
|
343
|
+
}, he = {
|
|
358
344
|
core: { "xml:space": `default` },
|
|
359
345
|
presentation: {
|
|
360
346
|
clip: `auto`,
|
|
@@ -416,7 +402,7 @@ var l = e(((e) => {
|
|
|
416
402
|
exponent: `1`,
|
|
417
403
|
offset: `0`
|
|
418
404
|
}
|
|
419
|
-
},
|
|
405
|
+
}, ge = {
|
|
420
406
|
animationAttributeTarget: { unsafe: /* @__PURE__ */ new Set([`attributeType`]) },
|
|
421
407
|
conditionalProcessing: { unsafe: /* @__PURE__ */ new Set([`requiredFeatures`]) },
|
|
422
408
|
core: { unsafe: /* @__PURE__ */ new Set([
|
|
@@ -432,7 +418,7 @@ var l = e(((e) => {
|
|
|
432
418
|
`glyph-orientation-vertical`,
|
|
433
419
|
`kerning`
|
|
434
420
|
]) }
|
|
435
|
-
},
|
|
421
|
+
}, _e = {
|
|
436
422
|
a: {
|
|
437
423
|
attrsGroups: /* @__PURE__ */ new Set([
|
|
438
424
|
`conditionalProcessing`,
|
|
@@ -2258,7 +2244,7 @@ var l = e(((e) => {
|
|
|
2258
2244
|
`u2`
|
|
2259
2245
|
]) }
|
|
2260
2246
|
}
|
|
2261
|
-
},
|
|
2247
|
+
}, ve = /* @__PURE__ */ new Set([
|
|
2262
2248
|
`http://creativecommons.org/ns#`,
|
|
2263
2249
|
`http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd`,
|
|
2264
2250
|
`http://krita.org/namespaces/svg/krita`,
|
|
@@ -2283,7 +2269,7 @@ var l = e(((e) => {
|
|
|
2283
2269
|
`http://www.vector.evaxdesign.sk`,
|
|
2284
2270
|
`http://www.w3.org/1999/02/22-rdf-syntax-ns#`,
|
|
2285
2271
|
`https://boxy-svg.com`
|
|
2286
|
-
]),
|
|
2272
|
+
]), A = /* @__PURE__ */ new Set([
|
|
2287
2273
|
`clip-path`,
|
|
2288
2274
|
`color-profile`,
|
|
2289
2275
|
`fill`,
|
|
@@ -2294,7 +2280,7 @@ var l = e(((e) => {
|
|
|
2294
2280
|
`mask`,
|
|
2295
2281
|
`stroke`,
|
|
2296
2282
|
`style`
|
|
2297
|
-
]),
|
|
2283
|
+
]), j = new Set(`clip-rule.color-interpolation-filters.color-interpolation.color-profile.color-rendering.color.cursor.direction.dominant-baseline.fill-opacity.fill-rule.fill.font-family.font-size-adjust.font-size.font-stretch.font-style.font-variant.font-weight.font.glyph-orientation-horizontal.glyph-orientation-vertical.image-rendering.letter-spacing.marker-end.marker-mid.marker-start.marker.paint-order.pointer-events.shape-rendering.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke-width.stroke.text-anchor.text-rendering.transform.visibility.word-spacing.writing-mode`.split(`.`)), ye = /* @__PURE__ */ new Set([
|
|
2298
2284
|
`clip-path`,
|
|
2299
2285
|
`display`,
|
|
2300
2286
|
`filter`,
|
|
@@ -2303,7 +2289,7 @@ var l = e(((e) => {
|
|
|
2303
2289
|
`text-decoration`,
|
|
2304
2290
|
`transform`,
|
|
2305
2291
|
`unicode-bidi`
|
|
2306
|
-
]),
|
|
2292
|
+
]), be = {
|
|
2307
2293
|
aliceblue: `#f0f8ff`,
|
|
2308
2294
|
antiquewhite: `#faebd7`,
|
|
2309
2295
|
aqua: `#0ff`,
|
|
@@ -2452,7 +2438,7 @@ var l = e(((e) => {
|
|
|
2452
2438
|
whitesmoke: `#f5f5f5`,
|
|
2453
2439
|
yellow: `#ff0`,
|
|
2454
2440
|
yellowgreen: `#9acd32`
|
|
2455
|
-
},
|
|
2441
|
+
}, xe = {
|
|
2456
2442
|
"#f0ffff": `azure`,
|
|
2457
2443
|
"#f5f5dc": `beige`,
|
|
2458
2444
|
"#ffe4c4": `bisque`,
|
|
@@ -2485,14 +2471,14 @@ var l = e(((e) => {
|
|
|
2485
2471
|
"#ff6347": `tomato`,
|
|
2486
2472
|
"#ee82ee": `violet`,
|
|
2487
2473
|
"#f5deb3": `wheat`
|
|
2488
|
-
},
|
|
2474
|
+
}, Se = /* @__PURE__ */ new Set([
|
|
2489
2475
|
`color`,
|
|
2490
2476
|
`fill`,
|
|
2491
2477
|
`flood-color`,
|
|
2492
2478
|
`lighting-color`,
|
|
2493
2479
|
`stop-color`,
|
|
2494
2480
|
`stroke`
|
|
2495
|
-
]),
|
|
2481
|
+
]), Ce = {
|
|
2496
2482
|
displayState: /* @__PURE__ */ new Set([
|
|
2497
2483
|
`fullscreen`,
|
|
2498
2484
|
`modal`,
|
|
@@ -2561,100 +2547,94 @@ var l = e(((e) => {
|
|
|
2561
2547
|
`has`
|
|
2562
2548
|
])
|
|
2563
2549
|
};
|
|
2564
|
-
var
|
|
2550
|
+
var we = Object.freeze({
|
|
2565
2551
|
__proto__: null,
|
|
2566
|
-
attrsGroups:
|
|
2567
|
-
attrsGroupsDefaults:
|
|
2568
|
-
attrsGroupsDeprecated:
|
|
2569
|
-
colorsNames:
|
|
2570
|
-
colorsProps:
|
|
2571
|
-
colorsShortNames:
|
|
2572
|
-
editorNamespaces:
|
|
2573
|
-
elems:
|
|
2574
|
-
elemsGroups:
|
|
2575
|
-
inheritableAttrs:
|
|
2576
|
-
pathElems:
|
|
2577
|
-
presentationNonInheritableGroupAttrs:
|
|
2578
|
-
pseudoClasses:
|
|
2579
|
-
referencesProps:
|
|
2580
|
-
textElems:
|
|
2552
|
+
attrsGroups: k,
|
|
2553
|
+
attrsGroupsDefaults: he,
|
|
2554
|
+
attrsGroupsDeprecated: ge,
|
|
2555
|
+
colorsNames: be,
|
|
2556
|
+
colorsProps: Se,
|
|
2557
|
+
colorsShortNames: xe,
|
|
2558
|
+
editorNamespaces: ve,
|
|
2559
|
+
elems: _e,
|
|
2560
|
+
elemsGroups: O,
|
|
2561
|
+
inheritableAttrs: j,
|
|
2562
|
+
pathElems: me,
|
|
2563
|
+
presentationNonInheritableGroupAttrs: ye,
|
|
2564
|
+
pseudoClasses: Ce,
|
|
2565
|
+
referencesProps: A,
|
|
2566
|
+
textElems: pe
|
|
2581
2567
|
});
|
|
2582
|
-
let
|
|
2568
|
+
let Te = v.walk.skip, Ee = (e, t) => {
|
|
2583
2569
|
let n = [];
|
|
2584
|
-
e.block.children.forEach((
|
|
2570
|
+
e.block.children.forEach((e) => {
|
|
2585
2571
|
e.type === `Declaration` && n.push({
|
|
2586
2572
|
name: e.property,
|
|
2587
|
-
value:
|
|
2573
|
+
value: v.generate(e.value),
|
|
2588
2574
|
important: e.important === !0
|
|
2589
2575
|
});
|
|
2590
|
-
})
|
|
2576
|
+
});
|
|
2591
2577
|
let r = [];
|
|
2592
|
-
return
|
|
2578
|
+
return v.walk(e.prelude, (e) => {
|
|
2593
2579
|
if (e.type === `Selector`) {
|
|
2594
|
-
let i =
|
|
2595
|
-
|
|
2580
|
+
let i = v.clone(e), a = !1;
|
|
2581
|
+
v.walk(i, (e, t, n) => {
|
|
2596
2582
|
e.type === `PseudoClassSelector` && (a = !0, n.remove(t));
|
|
2597
|
-
})
|
|
2598
|
-
specificity:
|
|
2583
|
+
}), r.push({
|
|
2584
|
+
specificity: p.syntax.specificity(e),
|
|
2599
2585
|
dynamic: a || t,
|
|
2600
|
-
selector:
|
|
2586
|
+
selector: v.generate(i),
|
|
2601
2587
|
declarations: n
|
|
2602
2588
|
});
|
|
2603
2589
|
}
|
|
2604
|
-
})
|
|
2605
|
-
},
|
|
2606
|
-
let n = [], r =
|
|
2590
|
+
}), r;
|
|
2591
|
+
}, De = (e, t) => {
|
|
2592
|
+
let n = [], r = v.parse(e, {
|
|
2607
2593
|
parseValue: !1,
|
|
2608
2594
|
parseAtrulePrelude: !1
|
|
2609
2595
|
});
|
|
2610
|
-
return
|
|
2611
|
-
if (e.type === `Rule`) return n.push(...
|
|
2596
|
+
return v.walk(r, (e) => {
|
|
2597
|
+
if (e.type === `Rule`) return n.push(...Ee(e, t || !1)), Te;
|
|
2612
2598
|
if (e.type === `Atrule`) return [
|
|
2613
2599
|
`keyframes`,
|
|
2614
2600
|
`-webkit-keyframes`,
|
|
2615
2601
|
`-o-keyframes`,
|
|
2616
2602
|
`-moz-keyframes`
|
|
2617
|
-
].includes(e.name) ||
|
|
2618
|
-
if (e.type === `Rule`) return n.push(...
|
|
2619
|
-
})
|
|
2620
|
-
})
|
|
2621
|
-
},
|
|
2622
|
-
let t = [], n =
|
|
2603
|
+
].includes(e.name) || v.walk(e, (e) => {
|
|
2604
|
+
if (e.type === `Rule`) return n.push(...Ee(e, t || !0)), Te;
|
|
2605
|
+
}), Te;
|
|
2606
|
+
}), n;
|
|
2607
|
+
}, Oe = (e) => {
|
|
2608
|
+
let t = [], n = v.parse(e, {
|
|
2623
2609
|
context: `declarationList`,
|
|
2624
2610
|
parseValue: !1
|
|
2625
2611
|
});
|
|
2626
|
-
return
|
|
2612
|
+
return v.walk(n, (e) => {
|
|
2627
2613
|
e.type === `Declaration` && t.push({
|
|
2628
2614
|
name: e.property,
|
|
2629
|
-
value:
|
|
2615
|
+
value: v.generate(e.value),
|
|
2630
2616
|
important: e.important === !0
|
|
2631
2617
|
});
|
|
2632
|
-
})
|
|
2633
|
-
},
|
|
2618
|
+
}), t;
|
|
2619
|
+
}, ke = (e, t, n) => {
|
|
2634
2620
|
let r = {}, i = /* @__PURE__ */ new Map();
|
|
2635
|
-
for (let [e, n] of Object.entries(t.attributes))
|
|
2621
|
+
for (let [e, n] of Object.entries(t.attributes)) k.presentation.has(e) && (r[e] = {
|
|
2636
2622
|
type: `static`,
|
|
2637
2623
|
inherited: !1,
|
|
2638
2624
|
value: n
|
|
2639
2625
|
}, i.set(e, !1));
|
|
2640
|
-
for (let { selector: a, declarations: o, dynamic: s } of e.rules) if (
|
|
2626
|
+
for (let { selector: a, declarations: o, dynamic: s } of e.rules) if (ce(t, a, n)) for (let { name: e, value: t, important: n } of o) {
|
|
2641
2627
|
let a = r[e];
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
(a == null || n === !0 || i.get(e) === !1) && (r[e] = {
|
|
2651
|
-
type: `static`,
|
|
2652
|
-
inherited: !1,
|
|
2653
|
-
value: t
|
|
2654
|
-
}, i.set(e, n));
|
|
2655
|
-
}
|
|
2628
|
+
a && a.type === `dynamic` || (s ? r[e] = {
|
|
2629
|
+
type: `dynamic`,
|
|
2630
|
+
inherited: !1
|
|
2631
|
+
} : (a == null || n === !0 || i.get(e) === !1) && (r[e] = {
|
|
2632
|
+
type: `static`,
|
|
2633
|
+
inherited: !1,
|
|
2634
|
+
value: t
|
|
2635
|
+
}, i.set(e, n)));
|
|
2656
2636
|
}
|
|
2657
|
-
let a = t.attributes.style == null ? [] :
|
|
2637
|
+
let a = t.attributes.style == null ? [] : Oe(t.attributes.style);
|
|
2658
2638
|
for (let { name: e, value: t, important: n } of a) {
|
|
2659
2639
|
let a = r[e];
|
|
2660
2640
|
a && a.type === `dynamic` || (a == null || n === !0 || i.get(e) === !1) && (r[e] = {
|
|
@@ -2664,83 +2644,83 @@ var l = e(((e) => {
|
|
|
2664
2644
|
}, i.set(e, n));
|
|
2665
2645
|
}
|
|
2666
2646
|
return r;
|
|
2667
|
-
},
|
|
2647
|
+
}, Ae = (e, t) => {
|
|
2668
2648
|
for (let n = 0; n < 4; n += 1) {
|
|
2669
2649
|
if (e[n] < t[n]) return -1;
|
|
2670
2650
|
if (e[n] > t[n]) return 1;
|
|
2671
2651
|
}
|
|
2672
2652
|
return 0;
|
|
2673
|
-
},
|
|
2653
|
+
}, M = (e) => {
|
|
2674
2654
|
let t = [], n = /* @__PURE__ */ new Map();
|
|
2675
|
-
return
|
|
2655
|
+
return x(e, { element: { enter: (e, r) => {
|
|
2676
2656
|
if (n.set(e, r), e.name === `style` && (e.attributes.type == null || e.attributes.type === `` || e.attributes.type === `text/css`)) {
|
|
2677
2657
|
let n = e.attributes.media != null && e.attributes.media !== `all`;
|
|
2678
|
-
for (let r of e.children) r.type !== `text` && r.type !== `cdata` || t.push(...
|
|
2658
|
+
for (let r of e.children) r.type !== `text` && r.type !== `cdata` || t.push(...De(r.value, n));
|
|
2679
2659
|
}
|
|
2680
|
-
} } }), t.sort((
|
|
2660
|
+
} } }), t.sort((e, t) => Ae(e.specificity, t.specificity)), {
|
|
2681
2661
|
rules: t,
|
|
2682
2662
|
parents: n
|
|
2683
2663
|
};
|
|
2684
|
-
},
|
|
2685
|
-
let { parents: n } = e, r =
|
|
2664
|
+
}, N = (e, t) => {
|
|
2665
|
+
let { parents: n } = e, r = ke(e, t, n), i = n.get(t);
|
|
2686
2666
|
for (; i != null && i.type !== `root`;) {
|
|
2687
|
-
let t =
|
|
2688
|
-
for (let [e, n] of Object.entries(t)) r[e] == null &&
|
|
2667
|
+
let t = ke(e, i, n);
|
|
2668
|
+
for (let [e, n] of Object.entries(t)) r[e] == null && j.has(e) && !ye.has(e) && (r[e] = {
|
|
2689
2669
|
...n,
|
|
2690
2670
|
inherited: !0
|
|
2691
2671
|
});
|
|
2692
2672
|
i = n.get(i);
|
|
2693
2673
|
}
|
|
2694
2674
|
return r;
|
|
2695
|
-
},
|
|
2696
|
-
let i = typeof e == `string` ?
|
|
2697
|
-
for (let e of i) if (e.some((
|
|
2675
|
+
}, je = (e, t, n = null, r = !1) => {
|
|
2676
|
+
let i = typeof e == `string` ? _.parse(e) : _.parse(v.generate(e.data));
|
|
2677
|
+
for (let e of i) if (e.some((i, a) => r && (a === e.length - 1 || !_.isTraversal(e[a + 1])) || i.type !== `attribute` || i.name !== t ? !1 : n == null || i.value === n)) return !0;
|
|
2698
2678
|
return !1;
|
|
2699
2679
|
};
|
|
2700
|
-
function
|
|
2680
|
+
function Me(e) {
|
|
2701
2681
|
let t = /* @__PURE__ */ new Set();
|
|
2702
|
-
return e.rules.forEach((
|
|
2703
|
-
|
|
2704
|
-
e.forEach((
|
|
2682
|
+
return e.rules.forEach((e) => {
|
|
2683
|
+
_.parse(e.selector).forEach((e) => {
|
|
2684
|
+
e.forEach((e) => {
|
|
2705
2685
|
e.type === `attribute` && t.add(e.name);
|
|
2706
|
-
})
|
|
2707
|
-
})
|
|
2708
|
-
})
|
|
2686
|
+
});
|
|
2687
|
+
});
|
|
2688
|
+
}), t;
|
|
2709
2689
|
}
|
|
2710
|
-
function
|
|
2711
|
-
t && (t.safe && t.safe.forEach((
|
|
2690
|
+
function Ne(e, t, n, r) {
|
|
2691
|
+
t && (t.safe && t.safe.forEach((t) => {
|
|
2712
2692
|
r.has(t) || delete e.attributes[t];
|
|
2713
|
-
})
|
|
2693
|
+
}), n.removeUnsafe && t.unsafe && t.unsafe.forEach((t) => {
|
|
2714
2694
|
r.has(t) || delete e.attributes[t];
|
|
2715
|
-
}))
|
|
2695
|
+
}));
|
|
2716
2696
|
}
|
|
2717
|
-
function
|
|
2718
|
-
let n =
|
|
2697
|
+
function Pe(e, t) {
|
|
2698
|
+
let n = Me(M(e));
|
|
2719
2699
|
return { element: { enter: (e) => {
|
|
2720
|
-
let r =
|
|
2721
|
-
r && (r.attrsGroups.has(`core`) && e.attributes[`xml:lang`] && !n.has(`xml:lang`) && e.attributes.lang && delete e.attributes[`xml:lang`], r.attrsGroups.forEach((
|
|
2722
|
-
|
|
2723
|
-
})
|
|
2700
|
+
let r = _e[e.name];
|
|
2701
|
+
r && (r.attrsGroups.has(`core`) && e.attributes[`xml:lang`] && !n.has(`xml:lang`) && e.attributes.lang && delete e.attributes[`xml:lang`], r.attrsGroups.forEach((r) => {
|
|
2702
|
+
Ne(e, ge[r], t, n);
|
|
2703
|
+
}), Ne(e, r.deprecated, t, n));
|
|
2724
2704
|
} } };
|
|
2725
2705
|
}
|
|
2726
|
-
var
|
|
2706
|
+
var Fe = Object.freeze({
|
|
2727
2707
|
__proto__: null,
|
|
2728
2708
|
description: `removes deprecated attributes`,
|
|
2729
|
-
fn:
|
|
2709
|
+
fn: Pe,
|
|
2730
2710
|
name: `removeDeprecatedAttrs`
|
|
2731
|
-
}),
|
|
2711
|
+
}), Ie = Object.freeze({
|
|
2732
2712
|
__proto__: null,
|
|
2733
2713
|
description: `removes <metadata>`,
|
|
2734
2714
|
fn: () => ({ element: { enter: (e, t) => {
|
|
2735
|
-
e.name === `metadata` &&
|
|
2715
|
+
e.name === `metadata` && D(e, t);
|
|
2736
2716
|
} } }),
|
|
2737
2717
|
name: `removeMetadata`
|
|
2738
|
-
}),
|
|
2718
|
+
}), Le = Object.freeze({
|
|
2739
2719
|
__proto__: null,
|
|
2740
2720
|
description: `removes editors namespaces, elements and attributes`,
|
|
2741
2721
|
fn: (e, t) => {
|
|
2742
|
-
let n = [...
|
|
2743
|
-
Array.isArray(t.additionalNamespaces) && (n = [...
|
|
2722
|
+
let n = [...ve];
|
|
2723
|
+
Array.isArray(t.additionalNamespaces) && (n = [...ve, ...t.additionalNamespaces]);
|
|
2744
2724
|
let r = [];
|
|
2745
2725
|
return { element: { enter: (e, t) => {
|
|
2746
2726
|
if (e.name === `svg`) for (let [t, i] of Object.entries(e.attributes)) t.startsWith(`xmlns:`) && n.includes(i) && (r.push(t.slice(6)), delete e.attributes[t]);
|
|
@@ -2750,58 +2730,54 @@ var l = e(((e) => {
|
|
|
2750
2730
|
}
|
|
2751
2731
|
if (e.name.includes(`:`)) {
|
|
2752
2732
|
let [n] = e.name.split(`:`);
|
|
2753
|
-
r.includes(n) &&
|
|
2733
|
+
r.includes(n) && D(e, t);
|
|
2754
2734
|
}
|
|
2755
2735
|
} } };
|
|
2756
2736
|
},
|
|
2757
2737
|
name: `removeEditorsNSData`
|
|
2758
2738
|
});
|
|
2759
|
-
let
|
|
2760
|
-
var
|
|
2739
|
+
let Re = /(\S)\r?\n(\S)/g, ze = /\r?\n/g, Be = /\s{2,}/g;
|
|
2740
|
+
var Ve = Object.freeze({
|
|
2761
2741
|
__proto__: null,
|
|
2762
2742
|
description: `cleanups attributes from newlines, trailing and repeating spaces`,
|
|
2763
2743
|
fn: (e, t) => {
|
|
2764
2744
|
let { newlines: n = !0, trim: r = !0, spaces: i = !0 } = t;
|
|
2765
2745
|
return { element: { enter: (e) => {
|
|
2766
|
-
for (let t of Object.keys(e.attributes)) n && (e.attributes[t] = e.attributes[t].replace(
|
|
2746
|
+
for (let t of Object.keys(e.attributes)) n && (e.attributes[t] = e.attributes[t].replace(Re, (e, t, n) => t + ` ` + n), e.attributes[t] = e.attributes[t].replace(ze, ``)), r && (e.attributes[t] = e.attributes[t].trim()), i && (e.attributes[t] = e.attributes[t].replace(Be, ` `));
|
|
2767
2747
|
} } };
|
|
2768
2748
|
},
|
|
2769
2749
|
name: `cleanupAttrs`
|
|
2770
|
-
}),
|
|
2750
|
+
}), He = Object.freeze({
|
|
2771
2751
|
__proto__: null,
|
|
2772
2752
|
description: `merge multiple style elements into one`,
|
|
2773
2753
|
fn: () => {
|
|
2774
2754
|
let e = null, t = ``, n = `text`;
|
|
2775
2755
|
return { element: { enter: (r, i) => {
|
|
2776
|
-
if (r.name === `foreignObject`) return
|
|
2756
|
+
if (r.name === `foreignObject`) return b;
|
|
2777
2757
|
if (r.name !== `style` || r.attributes.type != null && r.attributes.type !== `` && r.attributes.type !== `text/css`) return;
|
|
2778
2758
|
let a = ``;
|
|
2779
2759
|
for (let e of r.children) e.type === `text` && (a += e.value), e.type === `cdata` && (n = `cdata`, a += e.value);
|
|
2780
|
-
|
|
2781
|
-
k(r, i);
|
|
2782
|
-
return;
|
|
2783
|
-
}
|
|
2784
|
-
r.attributes.media == null ? t += a : (t += `@media ${r.attributes.media}{${a}}`, delete r.attributes.media), e == null ? e = r : (k(r, i), e.children = [{
|
|
2760
|
+
a.trim().length === 0 ? D(r, i) : (r.attributes.media == null ? t += a : (t += `@media ${r.attributes.media}{${a}}`, delete r.attributes.media), e == null ? e = r : (D(r, i), e.children = [{
|
|
2785
2761
|
type: n,
|
|
2786
2762
|
value: t
|
|
2787
|
-
}]);
|
|
2763
|
+
}]));
|
|
2788
2764
|
} } };
|
|
2789
2765
|
},
|
|
2790
2766
|
name: `mergeStyles`
|
|
2791
2767
|
});
|
|
2792
|
-
let
|
|
2793
|
-
var
|
|
2768
|
+
let Ue = [...Ce.functional, ...Ce.treeStructural];
|
|
2769
|
+
var We = Object.freeze({
|
|
2794
2770
|
__proto__: null,
|
|
2795
2771
|
description: `inline styles (additional options)`,
|
|
2796
2772
|
fn: (e, t) => {
|
|
2797
2773
|
let { onlyMatchedOnce: n = !0, removeMatchedSelectors: r = !0, useMqs: i = [``, `screen`], usePseudos: a = [``] } = t, o = [], s = [];
|
|
2798
2774
|
return {
|
|
2799
2775
|
element: { enter: (e, t) => {
|
|
2800
|
-
if (e.name === `foreignObject`) return
|
|
2776
|
+
if (e.name === `foreignObject`) return b;
|
|
2801
2777
|
if (e.name !== `style` || e.children.length === 0 || e.attributes.type != null && e.attributes.type !== `` && e.attributes.type !== `text/css`) return;
|
|
2802
|
-
let n = e.children.filter((
|
|
2778
|
+
let n = e.children.filter((e) => e.type === `text` || e.type === `cdata`).map((e) => e.value).join(``), r;
|
|
2803
2779
|
try {
|
|
2804
|
-
r =
|
|
2780
|
+
r = v.parse(n, {
|
|
2805
2781
|
parseValue: !1,
|
|
2806
2782
|
parseCustomProperty: !1
|
|
2807
2783
|
});
|
|
@@ -2812,22 +2788,22 @@ var l = e(((e) => {
|
|
|
2812
2788
|
node: e,
|
|
2813
2789
|
parentNode: t,
|
|
2814
2790
|
cssAst: r
|
|
2815
|
-
}),
|
|
2791
|
+
}), v.walk(r, {
|
|
2816
2792
|
visit: `Rule`,
|
|
2817
2793
|
enter(e) {
|
|
2818
2794
|
let t = this.atrule, n = ``;
|
|
2819
|
-
t != null && (n = t.name, t.prelude != null && (n += ` ${
|
|
2795
|
+
t != null && (n = t.name, t.prelude != null && (n += ` ${v.generate(t.prelude)}`)), i.includes(n) && e.prelude.type === `SelectorList` && e.prelude.children.forEach((t, n) => {
|
|
2820
2796
|
if (t.type === `Selector`) {
|
|
2821
2797
|
let r = [];
|
|
2822
|
-
t.children.forEach((
|
|
2823
|
-
(e.type === `PseudoClassSelector` || e.type === `PseudoElementSelector`) && !
|
|
2798
|
+
t.children.forEach((e, t, n) => {
|
|
2799
|
+
(e.type === `PseudoClassSelector` || e.type === `PseudoElementSelector`) && !Ue.includes(e.name) && r.push({
|
|
2824
2800
|
item: t,
|
|
2825
2801
|
list: n
|
|
2826
2802
|
});
|
|
2827
|
-
})
|
|
2828
|
-
let i =
|
|
2803
|
+
});
|
|
2804
|
+
let i = v.generate({
|
|
2829
2805
|
type: `Selector`,
|
|
2830
|
-
children: new
|
|
2806
|
+
children: new v.List().fromArray(r.map((e) => e.item.data))
|
|
2831
2807
|
});
|
|
2832
2808
|
if (a.includes(i)) for (let e of r) e.list.remove(e.item);
|
|
2833
2809
|
s.push({
|
|
@@ -2836,46 +2812,46 @@ var l = e(((e) => {
|
|
|
2836
2812
|
item: n
|
|
2837
2813
|
});
|
|
2838
2814
|
}
|
|
2839
|
-
})
|
|
2815
|
+
});
|
|
2840
2816
|
}
|
|
2841
2817
|
});
|
|
2842
2818
|
} },
|
|
2843
2819
|
root: { exit: () => {
|
|
2844
2820
|
if (o.length === 0) return;
|
|
2845
|
-
let t = s.slice().sort((
|
|
2846
|
-
let n =
|
|
2847
|
-
return
|
|
2848
|
-
})
|
|
2821
|
+
let t = s.slice().sort((e, t) => {
|
|
2822
|
+
let n = p.syntax.specificity(e.item.data), r = p.syntax.specificity(t.item.data);
|
|
2823
|
+
return Ae(n, r);
|
|
2824
|
+
}).reverse();
|
|
2849
2825
|
for (let i of t) {
|
|
2850
|
-
let t =
|
|
2826
|
+
let t = v.generate(i.item.data), a = [];
|
|
2851
2827
|
try {
|
|
2852
|
-
for (let n of
|
|
2828
|
+
for (let n of E(e, t)) n.type === `element` && a.push(n);
|
|
2853
2829
|
} catch {
|
|
2854
2830
|
continue;
|
|
2855
2831
|
}
|
|
2856
2832
|
if (a.length !== 0 && !(n && a.length > 1)) {
|
|
2857
2833
|
for (let e of a) {
|
|
2858
|
-
let t =
|
|
2834
|
+
let t = v.parse(e.attributes.style ?? ``, {
|
|
2859
2835
|
context: `declarationList`,
|
|
2860
2836
|
parseValue: !1
|
|
2861
2837
|
});
|
|
2862
2838
|
if (t.type !== `DeclarationList`) continue;
|
|
2863
2839
|
let n = /* @__PURE__ */ new Map(), r;
|
|
2864
|
-
|
|
2840
|
+
v.walk(t, {
|
|
2865
2841
|
visit: `Declaration`,
|
|
2866
2842
|
enter(e, t) {
|
|
2867
2843
|
r ??= t, n.set(e.property.toLowerCase(), t);
|
|
2868
2844
|
}
|
|
2869
|
-
}),
|
|
2845
|
+
}), v.walk(i.rule, {
|
|
2870
2846
|
visit: `Declaration`,
|
|
2871
2847
|
enter(i) {
|
|
2872
2848
|
let a = i.property;
|
|
2873
|
-
|
|
2849
|
+
k.presentation.has(a) && !s.some((e) => je(e.item, a)) && delete e.attributes[a];
|
|
2874
2850
|
let o = n.get(a), c = t.children.createItem(i);
|
|
2875
2851
|
o == null ? t.children.insert(c, r) : o.data.important !== !0 && i.important === !0 && (t.children.replace(o, c), n.set(a, c));
|
|
2876
2852
|
}
|
|
2877
2853
|
});
|
|
2878
|
-
let a =
|
|
2854
|
+
let a = v.generate(t);
|
|
2879
2855
|
a.length !== 0 && (e.attributes.style = a);
|
|
2880
2856
|
}
|
|
2881
2857
|
r && a.length !== 0 && i.rule.prelude.type === `SelectorList` && i.rule.prelude.children.remove(i.item), i.matchedElements = a;
|
|
@@ -2884,20 +2860,20 @@ var l = e(((e) => {
|
|
|
2884
2860
|
if (r) {
|
|
2885
2861
|
for (let e of t) if (e.matchedElements != null && !(n && e.matchedElements.length > 1)) for (let t of e.matchedElements) {
|
|
2886
2862
|
let n = new Set(t.attributes.class == null ? null : t.attributes.class.split(` `));
|
|
2887
|
-
for (let t of e.node.children) t.type !== `ClassSelector` || s.some((
|
|
2863
|
+
for (let t of e.node.children) t.type !== `ClassSelector` || s.some((e) => je(e.item, `class`, t.name, !0)) || n.delete(t.name);
|
|
2888
2864
|
n.size === 0 ? delete t.attributes.class : t.attributes.class = Array.from(n).join(` `);
|
|
2889
2865
|
let r = e.node.children.first;
|
|
2890
|
-
r?.type !== `IdSelector` || t.attributes.id !== r.name || s.some((
|
|
2866
|
+
r?.type !== `IdSelector` || t.attributes.id !== r.name || s.some((e) => je(e.item, `id`, r.name, !0)) || delete t.attributes.id;
|
|
2891
2867
|
}
|
|
2892
|
-
for (let e of o) if (
|
|
2868
|
+
for (let e of o) if (v.walk(e.cssAst, {
|
|
2893
2869
|
visit: `Rule`,
|
|
2894
2870
|
enter: function(e, t, n) {
|
|
2895
2871
|
e.type === `Rule` && e.prelude.type === `SelectorList` && e.prelude.children.isEmpty && n.remove(t);
|
|
2896
2872
|
}
|
|
2897
|
-
}), e.cssAst.children.isEmpty)
|
|
2873
|
+
}), e.cssAst.children.isEmpty) D(e.node, e.parentNode);
|
|
2898
2874
|
else {
|
|
2899
2875
|
let t = e.node.children[0];
|
|
2900
|
-
t.type !== `text` && t.type !== `cdata` || (t.value =
|
|
2876
|
+
t.type !== `text` && t.type !== `cdata` || (t.value = v.generate(e.cssAst));
|
|
2901
2877
|
}
|
|
2902
2878
|
}
|
|
2903
2879
|
} }
|
|
@@ -2905,45 +2881,57 @@ var l = e(((e) => {
|
|
|
2905
2881
|
},
|
|
2906
2882
|
name: `inlineStyles`
|
|
2907
2883
|
});
|
|
2908
|
-
let
|
|
2884
|
+
let Ge = /\burl\((["'])?#(.+?)\1\)/g, Ke = /^#(.+?)$/, qe = /(\w+)\.[a-zA-Z]/, Je = (e, t) => {
|
|
2909
2885
|
let n = `data:image/svg+xml`;
|
|
2910
2886
|
return t && t !== `base64` ? t === `enc` ? e = n + `,` + encodeURIComponent(e) : t === `unenc` && (e = n + `,` + e) : (n += `;base64,`, e = n + Buffer.from(e).toString(`base64`)), e;
|
|
2911
|
-
},
|
|
2887
|
+
}, P = (e, t, n) => {
|
|
2912
2888
|
let r = ``, i, a;
|
|
2913
|
-
return e.forEach((
|
|
2889
|
+
return e.forEach((e, n) => {
|
|
2914
2890
|
i = ` `, n == 0 && (i = ``), t.noSpaceAfterFlags;
|
|
2915
|
-
let o = t.leadingZero ?
|
|
2891
|
+
let o = t.leadingZero ? F(e) : e.toString();
|
|
2916
2892
|
t.negativeExtraSpace && i != `` && (e < 0 || o.charAt(0) === `.` && a % 1 != 0) && (i = ``), a = e, r += i + o;
|
|
2917
|
-
})
|
|
2918
|
-
},
|
|
2893
|
+
}), r;
|
|
2894
|
+
}, F = (e) => {
|
|
2919
2895
|
let t = e.toString();
|
|
2920
2896
|
return 0 < e && e < 1 && t.startsWith(`0`) ? t.slice(1) : -1 < e && e < 0 && t[1] === `0` ? t[0] + t.slice(2) : t;
|
|
2921
|
-
},
|
|
2922
|
-
...
|
|
2923
|
-
...
|
|
2924
|
-
...
|
|
2925
|
-
...
|
|
2926
|
-
...
|
|
2927
|
-
],
|
|
2897
|
+
}, Ye = [
|
|
2898
|
+
...k.animationEvent,
|
|
2899
|
+
...k.documentEvent,
|
|
2900
|
+
...k.documentElementEvent,
|
|
2901
|
+
...k.globalEvent,
|
|
2902
|
+
...k.graphicalEvent
|
|
2903
|
+
], Xe = /* @__PURE__ */ new Set([
|
|
2904
|
+
`application/xhtml+xml`,
|
|
2905
|
+
`image/svg+xml`,
|
|
2906
|
+
`text/html`
|
|
2907
|
+
]), Ze = (e) => {
|
|
2908
|
+
let t = e.replace(/[\t\n\r]/g, ``).trimStart().toLowerCase();
|
|
2909
|
+
if (t.startsWith(`javascript:`) || t.startsWith(`vbscript:`)) return !0;
|
|
2910
|
+
if (!t.startsWith(`data:`)) return !1;
|
|
2911
|
+
let n = t.slice(5).search(/[;,]/);
|
|
2912
|
+
if (n === -1) return !1;
|
|
2913
|
+
let r = t.slice(5, n + 5).trim();
|
|
2914
|
+
return Xe.has(r);
|
|
2915
|
+
}, Qe = (e) => e.name === `script` && e.children.length !== 0 || e.name === `a` && Object.entries(e.attributes).some(([e, t]) => (e === `href` || e.endsWith(`:href`)) && t != null && Ze(t)) ? !0 : Ye.some((t) => e.attributes[t] != null), $e = (e) => new RegExp(Ge).test(e), et = (e) => /var\s*\(\s*--/.test(e), tt = (e, t) => {
|
|
2928
2916
|
let n = [];
|
|
2929
|
-
if (
|
|
2930
|
-
let e = t.matchAll(
|
|
2917
|
+
if (A.has(e)) {
|
|
2918
|
+
let e = t.matchAll(Ge);
|
|
2931
2919
|
for (let t of e) n.push(t[2]);
|
|
2932
2920
|
}
|
|
2933
2921
|
if (e === `href` || e.endsWith(`:href`)) {
|
|
2934
|
-
let e =
|
|
2922
|
+
let e = Ke.exec(t);
|
|
2935
2923
|
e != null && n.push(e[1]);
|
|
2936
2924
|
}
|
|
2937
2925
|
if (e === `begin`) {
|
|
2938
|
-
let e =
|
|
2926
|
+
let e = qe.exec(t);
|
|
2939
2927
|
e != null && n.push(e[1]);
|
|
2940
2928
|
}
|
|
2941
|
-
return n.map((
|
|
2942
|
-
},
|
|
2929
|
+
return n.map((e) => decodeURI(e));
|
|
2930
|
+
}, I = (e, t) => {
|
|
2943
2931
|
let n = 10 ** t;
|
|
2944
2932
|
return Math.round(e * n) / n;
|
|
2945
2933
|
};
|
|
2946
|
-
var
|
|
2934
|
+
var nt = Object.freeze({
|
|
2947
2935
|
__proto__: null,
|
|
2948
2936
|
description: `minifies styles and removes unused styles`,
|
|
2949
2937
|
fn: (e, { usage: t, ...n }) => {
|
|
@@ -2952,42 +2940,42 @@ var l = e(((e) => {
|
|
|
2952
2940
|
let f = !1;
|
|
2953
2941
|
return {
|
|
2954
2942
|
element: { enter: (e, t) => {
|
|
2955
|
-
if (
|
|
2943
|
+
if (Qe(e) && (f = !0), a.add(e.name), e.attributes.id != null && o.add(e.attributes.id), e.attributes.class != null) for (let t of e.attributes.class.split(/\s+/)) s.add(t);
|
|
2956
2944
|
e.name === `style` && e.children.length !== 0 ? r.set(e, t) : e.attributes.style != null && i.push(e);
|
|
2957
2945
|
} },
|
|
2958
2946
|
root: { exit: () => {
|
|
2959
2947
|
let e = {};
|
|
2960
2948
|
(!f || d) && (c && (e.tags = Array.from(a)), l && (e.ids = Array.from(o)), u && (e.classes = Array.from(s)));
|
|
2961
2949
|
for (let [t, i] of r.entries()) if (t.children[0].type === `text` || t.children[0].type === `cdata`) {
|
|
2962
|
-
let r = t.children[0].value, a =
|
|
2950
|
+
let r = t.children[0].value, a = y.minify(r, {
|
|
2963
2951
|
...n,
|
|
2964
2952
|
usage: e
|
|
2965
2953
|
}).css;
|
|
2966
2954
|
if (a.length === 0) {
|
|
2967
|
-
|
|
2955
|
+
D(t, i);
|
|
2968
2956
|
continue;
|
|
2969
2957
|
}
|
|
2970
2958
|
r.indexOf(`>`) >= 0 || r.indexOf(`<`) >= 0 ? (t.children[0].type = `cdata`, t.children[0].value = a) : (t.children[0].type = `text`, t.children[0].value = a);
|
|
2971
2959
|
}
|
|
2972
2960
|
for (let e of i) {
|
|
2973
2961
|
let t = e.attributes.style;
|
|
2974
|
-
e.attributes.style =
|
|
2962
|
+
e.attributes.style = y.minifyBlock(t, { ...n }).css;
|
|
2975
2963
|
}
|
|
2976
2964
|
} }
|
|
2977
2965
|
};
|
|
2978
2966
|
},
|
|
2979
2967
|
name: `minifyStyles`
|
|
2980
2968
|
});
|
|
2981
|
-
let
|
|
2969
|
+
let rt = `abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`.split(``), it = rt.length - 1, at = (e, t) => {
|
|
2982
2970
|
for (let n of t) if (e.startsWith(n)) return !0;
|
|
2983
2971
|
return !1;
|
|
2984
|
-
},
|
|
2972
|
+
}, ot = (e) => {
|
|
2985
2973
|
if (e == null) return [0];
|
|
2986
2974
|
e[e.length - 1] += 1;
|
|
2987
|
-
for (let t = e.length - 1; t > 0; t--) e[t] >
|
|
2988
|
-
return e[0] >
|
|
2989
|
-
},
|
|
2990
|
-
var
|
|
2975
|
+
for (let t = e.length - 1; t > 0; t--) e[t] > it && (e[t] = 0, e[t - 1] !== void 0 && e[t - 1]++);
|
|
2976
|
+
return e[0] > it && (e[0] = 0, e.unshift(0)), e;
|
|
2977
|
+
}, st = (e) => e.map((e) => rt[e]).join(``);
|
|
2978
|
+
var ct = Object.freeze({
|
|
2991
2979
|
__proto__: null,
|
|
2992
2980
|
description: `removes unused IDs and minifies used`,
|
|
2993
2981
|
fn: (e, t) => {
|
|
@@ -2995,7 +2983,7 @@ var l = e(((e) => {
|
|
|
2995
2983
|
return {
|
|
2996
2984
|
element: { enter: (e) => {
|
|
2997
2985
|
if (!o) {
|
|
2998
|
-
if (e.name === `style` && e.children.length !== 0 ||
|
|
2986
|
+
if (e.name === `style` && e.children.length !== 0 || Qe(e)) {
|
|
2999
2987
|
d = !0;
|
|
3000
2988
|
return;
|
|
3001
2989
|
}
|
|
@@ -3005,14 +2993,14 @@ var l = e(((e) => {
|
|
|
3005
2993
|
t = !1;
|
|
3006
2994
|
break;
|
|
3007
2995
|
}
|
|
3008
|
-
if (t) return
|
|
2996
|
+
if (t) return b;
|
|
3009
2997
|
}
|
|
3010
2998
|
}
|
|
3011
2999
|
for (let [t, n] of Object.entries(e.attributes)) if (t === `id`) {
|
|
3012
3000
|
let t = n;
|
|
3013
3001
|
l.has(t) ? delete e.attributes.id : l.set(t, e);
|
|
3014
3002
|
} else {
|
|
3015
|
-
let r =
|
|
3003
|
+
let r = tt(t, n);
|
|
3016
3004
|
for (let n of r) {
|
|
3017
3005
|
let r = u.get(n);
|
|
3018
3006
|
r ?? (r = [], u.set(n, r)), r.push({
|
|
@@ -3024,14 +3012,14 @@ var l = e(((e) => {
|
|
|
3024
3012
|
} },
|
|
3025
3013
|
root: { exit: () => {
|
|
3026
3014
|
if (d) return;
|
|
3027
|
-
let e = (e) => s.has(e) ||
|
|
3015
|
+
let e = (e) => s.has(e) || at(e, c), t = null;
|
|
3028
3016
|
for (let [n, i] of u) {
|
|
3029
3017
|
let a = l.get(n);
|
|
3030
3018
|
if (a != null) {
|
|
3031
3019
|
if (r && e(n) === !1) {
|
|
3032
3020
|
let r;
|
|
3033
3021
|
do
|
|
3034
|
-
t =
|
|
3022
|
+
t = ot(t), r = st(t);
|
|
3035
3023
|
while (e(r) || u.has(r) && l.get(r) == null);
|
|
3036
3024
|
a.attributes.id = r;
|
|
3037
3025
|
for (let { element: e, name: t } of i) {
|
|
@@ -3048,21 +3036,21 @@ var l = e(((e) => {
|
|
|
3048
3036
|
},
|
|
3049
3037
|
name: `cleanupIds`
|
|
3050
3038
|
});
|
|
3051
|
-
let
|
|
3052
|
-
if (e.name === `defs` ||
|
|
3039
|
+
let lt = () => ({ element: { enter: (e, t) => {
|
|
3040
|
+
if (e.name === `defs` || O.nonRendering.has(e.name) && e.attributes.id == null) {
|
|
3053
3041
|
let n = [];
|
|
3054
|
-
|
|
3042
|
+
ut(e, n), n.length === 0 && D(e, t), e.children = n;
|
|
3055
3043
|
}
|
|
3056
|
-
} } }),
|
|
3057
|
-
for (let n of e.children) n.type === `element` && (n.attributes.id != null || n.name === `style` ? t.push(n) :
|
|
3044
|
+
} } }), ut = (e, t) => {
|
|
3045
|
+
for (let n of e.children) n.type === `element` && (n.attributes.id != null || n.name === `style` ? t.push(n) : ut(n, t));
|
|
3058
3046
|
};
|
|
3059
|
-
var
|
|
3047
|
+
var dt = Object.freeze({
|
|
3060
3048
|
__proto__: null,
|
|
3061
3049
|
description: `removes elements in <defs> without id`,
|
|
3062
|
-
fn:
|
|
3050
|
+
fn: lt,
|
|
3063
3051
|
name: `removeUselessDefs`
|
|
3064
3052
|
});
|
|
3065
|
-
let
|
|
3053
|
+
let ft = /^([-+]?\d*\.?\d+([eE][-+]?\d+)?)(px|pt|pc|mm|cm|m|in|ft|em|ex|%)?$/, pt = {
|
|
3066
3054
|
cm: 96 / 2.54,
|
|
3067
3055
|
mm: 96 / 25.4,
|
|
3068
3056
|
in: 96,
|
|
@@ -3070,7 +3058,7 @@ var l = e(((e) => {
|
|
|
3070
3058
|
pc: 16,
|
|
3071
3059
|
px: 1
|
|
3072
3060
|
};
|
|
3073
|
-
var
|
|
3061
|
+
var mt = Object.freeze({
|
|
3074
3062
|
__proto__: null,
|
|
3075
3063
|
description: `rounds numeric values to the fixed precision, removes default "px" units`,
|
|
3076
3064
|
fn: (e, t) => {
|
|
@@ -3078,30 +3066,30 @@ var l = e(((e) => {
|
|
|
3078
3066
|
return { element: { enter: (e) => {
|
|
3079
3067
|
if (e.attributes.viewBox != null) {
|
|
3080
3068
|
let t = e.attributes.viewBox.trim().split(/(?:\s,?|,)\s*/g);
|
|
3081
|
-
e.attributes.viewBox = t.map((
|
|
3069
|
+
e.attributes.viewBox = t.map((e) => {
|
|
3082
3070
|
let t = Number(e);
|
|
3083
3071
|
return Number.isNaN(t) ? e : Number(t.toFixed(n));
|
|
3084
|
-
})
|
|
3072
|
+
}).join(` `);
|
|
3085
3073
|
}
|
|
3086
3074
|
for (let [t, o] of Object.entries(e.attributes)) {
|
|
3087
3075
|
if (t === `version`) continue;
|
|
3088
|
-
let s =
|
|
3076
|
+
let s = ft.exec(o);
|
|
3089
3077
|
if (s) {
|
|
3090
3078
|
let o = Number(Number(s[1]).toFixed(n)), c = s[3] || ``;
|
|
3091
|
-
if (a && c !== `` && c in
|
|
3092
|
-
let e = Number((
|
|
3079
|
+
if (a && c !== `` && c in pt) {
|
|
3080
|
+
let e = Number((pt[c] * Number(s[1])).toFixed(n));
|
|
3093
3081
|
e.toString().length < s[0].length && (o = e, c = `px`);
|
|
3094
3082
|
}
|
|
3095
3083
|
let l;
|
|
3096
|
-
l = r ?
|
|
3084
|
+
l = r ? F(o) : o.toString(), i && c === `px` && (c = ``), e.attributes[t] = l + c;
|
|
3097
3085
|
}
|
|
3098
3086
|
}
|
|
3099
3087
|
} } };
|
|
3100
3088
|
},
|
|
3101
3089
|
name: `cleanupNumericValues`
|
|
3102
3090
|
});
|
|
3103
|
-
let
|
|
3104
|
-
var
|
|
3091
|
+
let ht = `([+-]?(?:\\d*\\.\\d+|\\d+\\.?)%?)`, gt = `(?:\\s*,\\s*|\\s+)`, _t = RegExp(`^rgb\\(\\s*` + ht + gt + ht + gt + ht + `\\s*\\)$`), vt = /^#(([a-fA-F0-9])\2){3}$/, yt = ([e, t, n]) => `#` + ((256 + e << 8 | t) << 8 | n).toString(16).slice(1).toUpperCase();
|
|
3092
|
+
var bt = Object.freeze({
|
|
3105
3093
|
__proto__: null,
|
|
3106
3094
|
description: `converts colors: rgb() to #rrggbb and #rrggbb to #rgb`,
|
|
3107
3095
|
fn: (e, t) => {
|
|
@@ -3109,7 +3097,7 @@ var l = e(((e) => {
|
|
|
3109
3097
|
return { element: {
|
|
3110
3098
|
enter: (e) => {
|
|
3111
3099
|
e.name === `mask` && c++;
|
|
3112
|
-
for (let [t, l] of Object.entries(e.attributes)) if (
|
|
3100
|
+
for (let [t, l] of Object.entries(e.attributes)) if (Se.has(t)) {
|
|
3113
3101
|
let u = l;
|
|
3114
3102
|
if (n && c === 0) {
|
|
3115
3103
|
let e;
|
|
@@ -3117,25 +3105,25 @@ var l = e(((e) => {
|
|
|
3117
3105
|
}
|
|
3118
3106
|
if (r) {
|
|
3119
3107
|
let e = u.toLowerCase();
|
|
3120
|
-
|
|
3108
|
+
be[e] != null && (u = be[e]);
|
|
3121
3109
|
}
|
|
3122
3110
|
if (i) {
|
|
3123
|
-
let e = u.match(
|
|
3111
|
+
let e = u.match(_t);
|
|
3124
3112
|
if (e != null) {
|
|
3125
|
-
let t = e.slice(1, 4).map((
|
|
3113
|
+
let t = e.slice(1, 4).map((e) => {
|
|
3126
3114
|
let t;
|
|
3127
3115
|
return t = e.indexOf(`%`) > -1 ? Math.round(parseFloat(e) * 2.55) : Number(e), Math.max(0, Math.min(t, 255));
|
|
3128
|
-
})
|
|
3129
|
-
u =
|
|
3116
|
+
});
|
|
3117
|
+
u = yt(t);
|
|
3130
3118
|
}
|
|
3131
3119
|
}
|
|
3132
|
-
if (!a ||
|
|
3133
|
-
let e =
|
|
3120
|
+
if (!a || $e(u) || et(u) || u === `currentColor` || (a === `lower` ? u = u.toLowerCase() : a === `upper` && (u = u.toUpperCase())), o) {
|
|
3121
|
+
let e = vt.exec(u);
|
|
3134
3122
|
e != null && (u = `#` + e[0][1] + e[0][3] + e[0][5]);
|
|
3135
3123
|
}
|
|
3136
3124
|
if (s) {
|
|
3137
3125
|
let e = u.toLowerCase();
|
|
3138
|
-
|
|
3126
|
+
xe[e] != null && (u = xe[e]);
|
|
3139
3127
|
}
|
|
3140
3128
|
e.attributes[t] = u;
|
|
3141
3129
|
}
|
|
@@ -3147,12 +3135,12 @@ var l = e(((e) => {
|
|
|
3147
3135
|
},
|
|
3148
3136
|
name: `convertColors`
|
|
3149
3137
|
});
|
|
3150
|
-
let
|
|
3151
|
-
for (let [e, t] of Object.entries(
|
|
3138
|
+
let xt = /* @__PURE__ */ new Map(), St = /* @__PURE__ */ new Map(), Ct = /* @__PURE__ */ new Map();
|
|
3139
|
+
for (let [e, t] of Object.entries(_e)) {
|
|
3152
3140
|
let n = /* @__PURE__ */ new Set();
|
|
3153
3141
|
if (t.content) for (let e of t.content) n.add(e);
|
|
3154
3142
|
if (t.contentGroups) for (let e of t.contentGroups) {
|
|
3155
|
-
let t =
|
|
3143
|
+
let t = O[e];
|
|
3156
3144
|
if (t) for (let e of t) n.add(e);
|
|
3157
3145
|
}
|
|
3158
3146
|
let r = /* @__PURE__ */ new Set();
|
|
@@ -3160,72 +3148,72 @@ var l = e(((e) => {
|
|
|
3160
3148
|
let i = /* @__PURE__ */ new Map();
|
|
3161
3149
|
if (t.defaults) for (let [e, n] of Object.entries(t.defaults)) i.set(e, n);
|
|
3162
3150
|
for (let e of t.attrsGroups) {
|
|
3163
|
-
let t =
|
|
3151
|
+
let t = k[e];
|
|
3164
3152
|
if (t) for (let e of t) r.add(e);
|
|
3165
|
-
let n =
|
|
3153
|
+
let n = he[e];
|
|
3166
3154
|
if (n) for (let [e, t] of Object.entries(n)) i.set(e, t);
|
|
3167
3155
|
}
|
|
3168
|
-
|
|
3156
|
+
xt.set(e, n), St.set(e, r), Ct.set(e, i);
|
|
3169
3157
|
}
|
|
3170
|
-
var
|
|
3158
|
+
var wt = Object.freeze({
|
|
3171
3159
|
__proto__: null,
|
|
3172
3160
|
description: `removes unknown elements content and attributes, removes attrs with default values`,
|
|
3173
3161
|
fn: (e, t) => {
|
|
3174
|
-
let { unknownContent: n = !0, unknownAttrs: r = !0, defaultAttrs: i = !0, defaultMarkupDeclarations: a = !0, uselessOverrides: o = !0, keepDataAttrs: s = !0, keepAriaAttrs: c = !0, keepRoleAttr: l = !1 } = t, u =
|
|
3162
|
+
let { unknownContent: n = !0, unknownAttrs: r = !0, defaultAttrs: i = !0, defaultMarkupDeclarations: a = !0, uselessOverrides: o = !0, keepDataAttrs: s = !0, keepAriaAttrs: c = !0, keepRoleAttr: l = !1 } = t, u = M(e);
|
|
3175
3163
|
return {
|
|
3176
3164
|
instruction: { enter: (e) => {
|
|
3177
3165
|
a && (e.value = e.value.replace(/\s*standalone\s*=\s*(["'])no\1/, ``));
|
|
3178
3166
|
} },
|
|
3179
3167
|
element: { enter: (e, t) => {
|
|
3180
3168
|
if (e.name.includes(`:`)) return;
|
|
3181
|
-
if (e.name === `foreignObject`) return
|
|
3169
|
+
if (e.name === `foreignObject`) return b;
|
|
3182
3170
|
if (n && t.type === `element`) {
|
|
3183
|
-
let n =
|
|
3171
|
+
let n = xt.get(t.name);
|
|
3184
3172
|
if (n == null || n.size === 0) {
|
|
3185
|
-
if (
|
|
3186
|
-
|
|
3173
|
+
if (xt.get(e.name) == null) {
|
|
3174
|
+
D(e, t);
|
|
3187
3175
|
return;
|
|
3188
3176
|
}
|
|
3189
3177
|
} else if (n.has(e.name) === !1) {
|
|
3190
|
-
|
|
3178
|
+
D(e, t);
|
|
3191
3179
|
return;
|
|
3192
3180
|
}
|
|
3193
3181
|
}
|
|
3194
|
-
let a =
|
|
3182
|
+
let a = St.get(e.name), d = Ct.get(e.name), f = t.type === `element` ? N(u, t) : null;
|
|
3195
3183
|
for (let [t, n] of Object.entries(e.attributes)) if (!(s && t.startsWith(`data-`)) && !(c && t.startsWith(`aria-`)) && !(l && t === `role`) && t !== `xmlns`) {
|
|
3196
3184
|
if (t.includes(`:`)) {
|
|
3197
3185
|
let [e] = t.split(`:`);
|
|
3198
3186
|
if (e !== `xml` && e !== `xlink`) continue;
|
|
3199
3187
|
}
|
|
3200
|
-
if (r && a && a.has(t) === !1 && delete e.attributes[t], i && e.attributes.id == null && d && d.get(t) === n && (f?.[t] != null || u.rules.some((
|
|
3188
|
+
if (r && a && a.has(t) === !1 && delete e.attributes[t], i && e.attributes.id == null && d && d.get(t) === n && (f?.[t] != null || u.rules.some((e) => je(e.selector, t)) || delete e.attributes[t]), o && e.attributes.id == null) {
|
|
3201
3189
|
let r = f?.[t];
|
|
3202
|
-
|
|
3190
|
+
ye.has(t) === !1 && r != null && r.type === `static` && r.value === n && delete e.attributes[t];
|
|
3203
3191
|
}
|
|
3204
3192
|
}
|
|
3205
3193
|
} }
|
|
3206
3194
|
};
|
|
3207
3195
|
},
|
|
3208
3196
|
name: `removeUnknownsAndDefaults`
|
|
3209
|
-
}),
|
|
3197
|
+
}), Tt = Object.freeze({
|
|
3210
3198
|
__proto__: null,
|
|
3211
3199
|
description: `removes non-inheritable group's presentational attributes`,
|
|
3212
3200
|
fn: () => ({ element: { enter: (e) => {
|
|
3213
|
-
if (e.name === `g`) for (let t of Object.keys(e.attributes)) !
|
|
3201
|
+
if (e.name === `g`) for (let t of Object.keys(e.attributes)) !k.presentation.has(t) || j.has(t) || ye.has(t) || delete e.attributes[t];
|
|
3214
3202
|
} } }),
|
|
3215
3203
|
name: `removeNonInheritableGroupAttrs`
|
|
3216
|
-
}),
|
|
3204
|
+
}), Et = Object.freeze({
|
|
3217
3205
|
__proto__: null,
|
|
3218
3206
|
description: `removes useless stroke and fill attributes`,
|
|
3219
3207
|
fn: (e, t) => {
|
|
3220
3208
|
let { stroke: n = !0, fill: r = !0, removeNone: i = !1 } = t, a = !1;
|
|
3221
|
-
if (
|
|
3222
|
-
(e.name === `style` ||
|
|
3209
|
+
if (x(e, { element: { enter: (e) => {
|
|
3210
|
+
(e.name === `style` || Qe(e)) && (a = !0);
|
|
3223
3211
|
} } }), a) return null;
|
|
3224
|
-
let o =
|
|
3212
|
+
let o = M(e);
|
|
3225
3213
|
return { element: { enter: (e, t) => {
|
|
3226
|
-
if (e.attributes.id != null) return
|
|
3227
|
-
if (!
|
|
3228
|
-
let a =
|
|
3214
|
+
if (e.attributes.id != null) return b;
|
|
3215
|
+
if (!O.shape.has(e.name)) return;
|
|
3216
|
+
let a = N(o, e), s = a.stroke, c = a[`stroke-opacity`], l = a[`stroke-width`], u = a[`marker-end`], d = a.fill, f = a[`fill-opacity`], p = t.type === `element` ? N(o, t) : null, m = p == null ? null : p.stroke;
|
|
3229
3217
|
if (n && (s == null || s.type === `static` && s.value == `none` || c != null && c.type === `static` && c.value === `0` || l != null && l.type === `static` && l.value === `0`) && (l != null && l.type === `static` && l.value === `0` || u == null)) {
|
|
3230
3218
|
for (let t of Object.keys(e.attributes)) t.startsWith(`stroke`) && delete e.attributes[t];
|
|
3231
3219
|
m != null && m.type === `static` && m.value !== `none` && (e.attributes.stroke = `none`);
|
|
@@ -3234,52 +3222,52 @@ var l = e(((e) => {
|
|
|
3234
3222
|
for (let t of Object.keys(e.attributes)) t.startsWith(`fill-`) && delete e.attributes[t];
|
|
3235
3223
|
(d == null || d.type === `static` && d.value !== `none`) && (e.attributes.fill = `none`);
|
|
3236
3224
|
}
|
|
3237
|
-
i && (s != null && e.attributes.stroke !== `none` || (d == null || d.type !== `static` || d.value !== `none`) && e.attributes.fill !== `none` ||
|
|
3225
|
+
i && (s != null && e.attributes.stroke !== `none` || (d == null || d.type !== `static` || d.value !== `none`) && e.attributes.fill !== `none` || D(e, t));
|
|
3238
3226
|
} } };
|
|
3239
3227
|
},
|
|
3240
3228
|
name: `removeUselessStrokeAndFill`
|
|
3241
3229
|
});
|
|
3242
|
-
let
|
|
3230
|
+
let Dt = /^new\s0\s0\s([-+]?\d*\.?\d+([eE][-+]?\d+)?)\s([-+]?\d*\.?\d+([eE][-+]?\d+)?)$/, Ot = (e) => {
|
|
3243
3231
|
let t = !1;
|
|
3244
|
-
return
|
|
3232
|
+
return x(e, { element: { enter: (e) => {
|
|
3245
3233
|
e.name === `filter` && (t = !0);
|
|
3246
3234
|
} } }), { element: { enter: (e) => {
|
|
3247
3235
|
let n = null, r = null;
|
|
3248
|
-
if (e.attributes.style != null && (n =
|
|
3236
|
+
if (e.attributes.style != null && (n = v.parse(e.attributes.style, { context: `declarationList` }), n.type === `DeclarationList`)) {
|
|
3249
3237
|
let e = [];
|
|
3250
|
-
|
|
3238
|
+
v.walk(n, (t, n) => {
|
|
3251
3239
|
t.type === `Declaration` && t.property === `enable-background` && (e.push(n), r = n);
|
|
3252
|
-
})
|
|
3240
|
+
});
|
|
3253
3241
|
for (let t = 0; t < e.length - 1; t++) n.children.remove(e[t]);
|
|
3254
3242
|
}
|
|
3255
3243
|
if (!t) {
|
|
3256
|
-
delete e.attributes[`enable-background`], n?.type === `DeclarationList` && (r && n.children.remove(r), n.children.isEmpty ? delete e.attributes.style : e.attributes.style =
|
|
3244
|
+
delete e.attributes[`enable-background`], n?.type === `DeclarationList` && (r && n.children.remove(r), n.children.isEmpty ? delete e.attributes.style : e.attributes.style = v.generate(n));
|
|
3257
3245
|
return;
|
|
3258
3246
|
}
|
|
3259
3247
|
let i = e.attributes.width != null && e.attributes.height != null;
|
|
3260
3248
|
if ((e.name === `svg` || e.name === `mask` || e.name === `pattern`) && i) {
|
|
3261
|
-
let t = e.attributes[`enable-background`], i =
|
|
3249
|
+
let t = e.attributes[`enable-background`], i = kt(t, e.name, e.attributes.width, e.attributes.height);
|
|
3262
3250
|
if (i ? e.attributes[`enable-background`] = i : delete e.attributes[`enable-background`], n?.type === `DeclarationList` && r) {
|
|
3263
|
-
let t =
|
|
3251
|
+
let t = v.generate(r.data.value), i = kt(t, e.name, e.attributes.width, e.attributes.height);
|
|
3264
3252
|
i ? r.data.value = {
|
|
3265
3253
|
type: `Raw`,
|
|
3266
3254
|
value: i
|
|
3267
3255
|
} : n.children.remove(r);
|
|
3268
3256
|
}
|
|
3269
3257
|
}
|
|
3270
|
-
n?.type === `DeclarationList` && (n.children.isEmpty ? delete e.attributes.style : e.attributes.style =
|
|
3258
|
+
n?.type === `DeclarationList` && (n.children.isEmpty ? delete e.attributes.style : e.attributes.style = v.generate(n));
|
|
3271
3259
|
} } };
|
|
3272
|
-
},
|
|
3273
|
-
let i =
|
|
3260
|
+
}, kt = (e, t, n, r) => {
|
|
3261
|
+
let i = Dt.exec(e);
|
|
3274
3262
|
return i != null && n === i[1] && r === i[3] ? t === `svg` ? void 0 : `new` : e;
|
|
3275
3263
|
};
|
|
3276
|
-
var
|
|
3264
|
+
var At = Object.freeze({
|
|
3277
3265
|
__proto__: null,
|
|
3278
3266
|
description: `remove or cleanup enable-background attribute when possible`,
|
|
3279
|
-
fn:
|
|
3267
|
+
fn: Ot,
|
|
3280
3268
|
name: `cleanupEnableBackground`
|
|
3281
3269
|
});
|
|
3282
|
-
let
|
|
3270
|
+
let jt = {
|
|
3283
3271
|
M: 2,
|
|
3284
3272
|
m: 2,
|
|
3285
3273
|
Z: 0,
|
|
@@ -3300,11 +3288,11 @@ var l = e(((e) => {
|
|
|
3300
3288
|
t: 2,
|
|
3301
3289
|
A: 7,
|
|
3302
3290
|
a: 7
|
|
3303
|
-
},
|
|
3304
|
-
`,
|
|
3291
|
+
}, Mt = (e) => e in jt, Nt = (e) => e === ` ` || e === ` ` || e === `\r` || e === `
|
|
3292
|
+
`, Pt = (e) => {
|
|
3305
3293
|
let t = e.codePointAt(0);
|
|
3306
3294
|
return t != null && 48 <= t && t <= 57;
|
|
3307
|
-
},
|
|
3295
|
+
}, Ft = (e, t) => {
|
|
3308
3296
|
let n = t, r = ``, i = `none`;
|
|
3309
3297
|
for (; n < e.length; n += 1) {
|
|
3310
3298
|
let t = e[n];
|
|
@@ -3318,7 +3306,7 @@ var l = e(((e) => {
|
|
|
3318
3306
|
continue;
|
|
3319
3307
|
}
|
|
3320
3308
|
}
|
|
3321
|
-
if (
|
|
3309
|
+
if (Pt(t)) {
|
|
3322
3310
|
if (i === `none` || i === `sign` || i === `whole`) {
|
|
3323
3311
|
i = `whole`, r += t;
|
|
3324
3312
|
continue;
|
|
@@ -3332,34 +3320,28 @@ var l = e(((e) => {
|
|
|
3332
3320
|
continue;
|
|
3333
3321
|
}
|
|
3334
3322
|
}
|
|
3335
|
-
if (t === `.` && (i === `none` || i === `sign` || i === `whole`))
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
}
|
|
3339
|
-
if ((t === `E` || t == `e`) && (i === `whole` || i === `decimal_point` || i === `decimal`)) {
|
|
3340
|
-
i = `e`, r += t;
|
|
3341
|
-
continue;
|
|
3342
|
-
}
|
|
3343
|
-
break;
|
|
3323
|
+
if (t === `.` && (i === `none` || i === `sign` || i === `whole`)) i = `decimal_point`, r += t;
|
|
3324
|
+
else if ((t === `E` || t == `e`) && (i === `whole` || i === `decimal_point` || i === `decimal`)) i = `e`, r += t;
|
|
3325
|
+
else break;
|
|
3344
3326
|
}
|
|
3345
3327
|
let a = Number.parseFloat(r);
|
|
3346
3328
|
return Number.isNaN(a) ? [t, null] : [n - 1, a];
|
|
3347
|
-
},
|
|
3329
|
+
}, It = (e) => {
|
|
3348
3330
|
let t = [], n = null, r = [], i = 0, a = !1, o = !1;
|
|
3349
3331
|
for (let s = 0; s < e.length; s += 1) {
|
|
3350
3332
|
let c = e.charAt(s);
|
|
3351
|
-
if (
|
|
3333
|
+
if (Nt(c)) continue;
|
|
3352
3334
|
if (a && c === `,`) {
|
|
3353
3335
|
if (o) break;
|
|
3354
3336
|
o = !0;
|
|
3355
3337
|
continue;
|
|
3356
3338
|
}
|
|
3357
|
-
if (
|
|
3339
|
+
if (Mt(c)) {
|
|
3358
3340
|
if (o) return t;
|
|
3359
3341
|
if (n == null) {
|
|
3360
3342
|
if (c !== `M` && c !== `m`) return t;
|
|
3361
3343
|
} else if (r.length !== 0) return t;
|
|
3362
|
-
n = c, r = [], i =
|
|
3344
|
+
n = c, r = [], i = jt[n], a = !1, i === 0 && t.push({
|
|
3363
3345
|
command: n,
|
|
3364
3346
|
args: r
|
|
3365
3347
|
});
|
|
@@ -3369,8 +3351,8 @@ var l = e(((e) => {
|
|
|
3369
3351
|
let l = s, u = null;
|
|
3370
3352
|
if (n === `A` || n === `a`) {
|
|
3371
3353
|
let t = r.length;
|
|
3372
|
-
t !== 0 && t !== 1 && t !== 2 && t !== 5 && t !== 6 || ([l, u] =
|
|
3373
|
-
} else [l, u] =
|
|
3354
|
+
t !== 0 && t !== 1 && t !== 2 && t !== 5 && t !== 6 || ([l, u] = Ft(e, s)), (t === 3 || t === 4) && (c === `0` && (u = 0), c === `1` && (u = 1));
|
|
3355
|
+
} else [l, u] = Ft(e, s);
|
|
3374
3356
|
if (u == null) return t;
|
|
3375
3357
|
r.push(u), a = !0, o = !1, s = l, r.length === i && ((n === `A` || n === `a`) && (r[0] = Math.abs(r[0]), r[1] = Math.abs(r[1])), t.push({
|
|
3376
3358
|
command: n,
|
|
@@ -3378,163 +3360,115 @@ var l = e(((e) => {
|
|
|
3378
3360
|
}), n === `M` && (n = `L`), n === `m` && (n = `l`), r = []);
|
|
3379
3361
|
}
|
|
3380
3362
|
return t;
|
|
3381
|
-
},
|
|
3382
|
-
roundedStr:
|
|
3363
|
+
}, Lt = (e, t) => (t != null && (e = I(e, t)), {
|
|
3364
|
+
roundedStr: F(e),
|
|
3383
3365
|
rounded: e
|
|
3384
|
-
}),
|
|
3366
|
+
}), Rt = (e, t, n, r) => {
|
|
3385
3367
|
let i = ``, a;
|
|
3386
3368
|
for (let o = 0; o < t.length; o++) {
|
|
3387
|
-
let { roundedStr: s, rounded: c } =
|
|
3388
|
-
!r || e !== `A` && e !== `a` || o % 7 != 4 && o % 7 != 5 ? o === 0 || c < 0 ? i += s : Number.isInteger(a) ||
|
|
3369
|
+
let { roundedStr: s, rounded: c } = Lt(t[o], n);
|
|
3370
|
+
!r || e !== `A` && e !== `a` || o % 7 != 4 && o % 7 != 5 ? o === 0 || c < 0 ? i += s : Number.isInteger(a) || Pt(s[0]) ? i += ` ${s}` : i += s : i += s, a = c;
|
|
3389
3371
|
}
|
|
3390
3372
|
return i;
|
|
3391
|
-
},
|
|
3373
|
+
}, L = ({ pathData: e, precision: t, disableSpaceAfterFlags: n }) => {
|
|
3392
3374
|
if (e.length === 1) {
|
|
3393
3375
|
let { command: r, args: i } = e[0];
|
|
3394
|
-
return r +
|
|
3376
|
+
return r + Rt(r, i, t, n);
|
|
3395
3377
|
}
|
|
3396
3378
|
let r = ``, i = { ...e[0] };
|
|
3397
3379
|
e[1].command === `L` ? i.command = `M` : e[1].command === `l` && (i.command = `m`);
|
|
3398
3380
|
for (let a = 1; a < e.length; a++) {
|
|
3399
3381
|
let { command: o, args: s } = e[a];
|
|
3400
|
-
i.command === o && i.command !== `M` && i.command !== `m` || i.command === `M` && o === `L` || i.command === `m` && o === `l` ? (i.args = [...i.args, ...s], a === e.length - 1 && (r += i.command +
|
|
3382
|
+
i.command === o && i.command !== `M` && i.command !== `m` || i.command === `M` && o === `L` || i.command === `m` && o === `l` ? (i.args = [...i.args, ...s], a === e.length - 1 && (r += i.command + Rt(i.command, i.args, t, n))) : (r += i.command + Rt(i.command, i.args, t, n), a === e.length - 1 ? r += o + Rt(o, s, t, n) : i = {
|
|
3401
3383
|
command: o,
|
|
3402
3384
|
args: s
|
|
3403
3385
|
});
|
|
3404
3386
|
}
|
|
3405
3387
|
return r;
|
|
3406
|
-
},
|
|
3407
|
-
var
|
|
3388
|
+
}, zt = O.nonRendering;
|
|
3389
|
+
var Bt = Object.freeze({
|
|
3408
3390
|
__proto__: null,
|
|
3409
3391
|
description: `removes hidden elements (zero sized, with absent attributes)`,
|
|
3410
3392
|
fn: (e, t) => {
|
|
3411
|
-
let { isHidden: n = !0, displayNone: r = !0, opacity0: i = !0, circleR0: a = !0, ellipseRX0: o = !0, ellipseRY0: s = !0, rectWidth0: c = !0, rectHeight0: l = !0, patternWidth0: u = !0, patternHeight0: d = !0, imageWidth0: f = !0, imageHeight0: p = !0, pathEmptyD: m = !0, polylineEmptyPoints: h = !0, polygonEmptyPoints: g = !0 } = t, _ =
|
|
3412
|
-
function
|
|
3413
|
-
if (
|
|
3414
|
-
for (let t of e.children) if (t.type === `element` && !
|
|
3393
|
+
let { isHidden: n = !0, displayNone: r = !0, opacity0: i = !0, circleR0: a = !0, ellipseRX0: o = !0, ellipseRY0: s = !0, rectWidth0: c = !0, rectHeight0: l = !0, patternWidth0: u = !0, patternHeight0: d = !0, imageWidth0: f = !0, imageHeight0: p = !0, pathEmptyD: m = !0, polylineEmptyPoints: h = !0, polygonEmptyPoints: g = !0 } = t, _ = M(e), v = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Set(), S = /* @__PURE__ */ new Map(), ee = /* @__PURE__ */ new Set(), C = /* @__PURE__ */ new Map(), w = !1;
|
|
3394
|
+
function te(e) {
|
|
3395
|
+
if (ee.has(e.attributes.id)) return !1;
|
|
3396
|
+
for (let t of e.children) if (t.type === `element` && !te(t)) return !1;
|
|
3415
3397
|
return !0;
|
|
3416
3398
|
}
|
|
3417
|
-
function
|
|
3418
|
-
e.type === `element` && e.attributes.id != null && t.type === `element` && t.name === `defs` && y.add(e.attributes.id),
|
|
3399
|
+
function T(e, t) {
|
|
3400
|
+
e.type === `element` && e.attributes.id != null && t.type === `element` && t.name === `defs` && y.add(e.attributes.id), D(e, t);
|
|
3419
3401
|
}
|
|
3420
|
-
return
|
|
3421
|
-
if (
|
|
3422
|
-
let n =
|
|
3402
|
+
return x(e, { element: { enter: (e, t) => {
|
|
3403
|
+
if (zt.has(e.name)) return v.set(e, t), b;
|
|
3404
|
+
let n = N(_, e);
|
|
3423
3405
|
if (i && n.opacity && n.opacity.type === `static` && n.opacity.value === `0`) {
|
|
3424
|
-
if (e.name === `path`) return v.set(e, t),
|
|
3425
|
-
|
|
3406
|
+
if (e.name === `path`) return v.set(e, t), b;
|
|
3407
|
+
T(e, t);
|
|
3426
3408
|
}
|
|
3427
3409
|
} } }), {
|
|
3428
3410
|
element: { enter: (e, t) => {
|
|
3429
|
-
if (e.name === `style` && e.children.length !== 0 ||
|
|
3430
|
-
|
|
3411
|
+
if (e.name === `style` && e.children.length !== 0 || Qe(e)) {
|
|
3412
|
+
w = !0;
|
|
3431
3413
|
return;
|
|
3432
3414
|
}
|
|
3433
|
-
if (e.name === `defs` &&
|
|
3415
|
+
if (e.name === `defs` && S.set(e, t), e.name === `use`) for (let n of Object.keys(e.attributes)) {
|
|
3434
3416
|
if (n !== `href` && !n.endsWith(`:href`)) continue;
|
|
3435
|
-
let r = e.attributes[n].slice(1), i =
|
|
3436
|
-
i || (i = [],
|
|
3417
|
+
let r = e.attributes[n].slice(1), i = C.get(r);
|
|
3418
|
+
i || (i = [], C.set(r, i)), i.push({
|
|
3437
3419
|
node: e,
|
|
3438
3420
|
parentNode: t
|
|
3439
3421
|
});
|
|
3440
3422
|
}
|
|
3441
|
-
if (a && e.name === `circle` && e.children.length === 0 && e.attributes.r === `0`) {
|
|
3442
|
-
|
|
3443
|
-
return;
|
|
3444
|
-
}
|
|
3445
|
-
if (o && e.name === `ellipse` && e.children.length === 0 && e.attributes.rx === `0`) {
|
|
3446
|
-
E(e, t);
|
|
3447
|
-
return;
|
|
3448
|
-
}
|
|
3449
|
-
if (s && e.name === `ellipse` && e.children.length === 0 && e.attributes.ry === `0`) {
|
|
3450
|
-
E(e, t);
|
|
3451
|
-
return;
|
|
3452
|
-
}
|
|
3453
|
-
if (c && e.name === `rect` && e.children.length === 0 && e.attributes.width === `0`) {
|
|
3454
|
-
E(e, t);
|
|
3455
|
-
return;
|
|
3456
|
-
}
|
|
3457
|
-
if (l && c && e.name === `rect` && e.children.length === 0 && e.attributes.height === `0`) {
|
|
3458
|
-
E(e, t);
|
|
3423
|
+
if (a && e.name === `circle` && e.children.length === 0 && e.attributes.r === `0` || o && e.name === `ellipse` && e.children.length === 0 && e.attributes.rx === `0` || s && e.name === `ellipse` && e.children.length === 0 && e.attributes.ry === `0` || c && e.name === `rect` && e.children.length === 0 && e.attributes.width === `0` || l && c && e.name === `rect` && e.children.length === 0 && e.attributes.height === `0` || u && e.name === `pattern` && e.attributes.width === `0` || d && e.name === `pattern` && e.attributes.height === `0` || f && e.name === `image` && e.attributes.width === `0` || p && e.name === `image` && e.attributes.height === `0` || h && e.name === `polyline` && e.attributes.points == null || g && e.name === `polygon` && e.attributes.points == null) {
|
|
3424
|
+
T(e, t);
|
|
3459
3425
|
return;
|
|
3460
3426
|
}
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
return;
|
|
3476
|
-
}
|
|
3477
|
-
if (h && e.name === `polyline` && e.attributes.points == null) {
|
|
3478
|
-
E(e, t);
|
|
3479
|
-
return;
|
|
3480
|
-
}
|
|
3481
|
-
if (g && e.name === `polygon` && e.attributes.points == null) {
|
|
3482
|
-
E(e, t);
|
|
3483
|
-
return;
|
|
3484
|
-
}
|
|
3485
|
-
let i = F(_, e);
|
|
3486
|
-
if (n && i.visibility && i.visibility.type === `static` && i.visibility.value === `hidden` && ue(e, `[visibility=visible]`) == null) {
|
|
3487
|
-
E(e, t);
|
|
3488
|
-
return;
|
|
3489
|
-
}
|
|
3490
|
-
if (r && i.display && i.display.type === `static` && i.display.value === `none` && e.name !== `marker`) {
|
|
3491
|
-
E(e, t);
|
|
3492
|
-
return;
|
|
3493
|
-
}
|
|
3494
|
-
if (m && e.name === `path`) {
|
|
3495
|
-
if (e.attributes.d == null) {
|
|
3496
|
-
E(e, t);
|
|
3497
|
-
return;
|
|
3498
|
-
}
|
|
3499
|
-
let n = Ft(e.attributes.d);
|
|
3500
|
-
if (n.length === 0) {
|
|
3501
|
-
E(e, t);
|
|
3502
|
-
return;
|
|
3427
|
+
let i = N(_, e);
|
|
3428
|
+
if (n && i.visibility && i.visibility.type === `static` && i.visibility.value === `hidden` && se(e, `[visibility=visible]`) == null) T(e, t);
|
|
3429
|
+
else if (r && i.display && i.display.type === `static` && i.display.value === `none` && e.name !== `marker`) T(e, t);
|
|
3430
|
+
else {
|
|
3431
|
+
if (m && e.name === `path`) {
|
|
3432
|
+
if (e.attributes.d == null) {
|
|
3433
|
+
T(e, t);
|
|
3434
|
+
return;
|
|
3435
|
+
}
|
|
3436
|
+
let n = It(e.attributes.d);
|
|
3437
|
+
if (n.length === 0 || n.length === 1 && i[`marker-start`] == null && i[`marker-end`] == null) {
|
|
3438
|
+
T(e, t);
|
|
3439
|
+
return;
|
|
3440
|
+
}
|
|
3503
3441
|
}
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3442
|
+
for (let [t, n] of Object.entries(e.attributes)) {
|
|
3443
|
+
let e = tt(t, n);
|
|
3444
|
+
for (let t of e) ee.add(t);
|
|
3507
3445
|
}
|
|
3508
3446
|
}
|
|
3509
|
-
for (let [t, n] of Object.entries(e.attributes)) {
|
|
3510
|
-
let e = nt(t, n);
|
|
3511
|
-
for (let t of e) x.add(t);
|
|
3512
|
-
}
|
|
3513
3447
|
} },
|
|
3514
3448
|
root: { exit: () => {
|
|
3515
3449
|
for (let e of y) {
|
|
3516
|
-
let t =
|
|
3517
|
-
if (t) for (let { node: e, parentNode: n } of t)
|
|
3450
|
+
let t = C.get(e);
|
|
3451
|
+
if (t) for (let { node: e, parentNode: n } of t) D(e, n);
|
|
3518
3452
|
}
|
|
3519
|
-
if (!
|
|
3520
|
-
for (let [e, t] of
|
|
3453
|
+
if (!w) for (let [e, t] of v.entries()) te(e) && D(e, t);
|
|
3454
|
+
for (let [e, t] of S.entries()) e.children.length === 0 && D(e, t);
|
|
3521
3455
|
} }
|
|
3522
3456
|
};
|
|
3523
3457
|
},
|
|
3524
3458
|
name: `removeHiddenElems`
|
|
3525
|
-
}),
|
|
3459
|
+
}), Vt = Object.freeze({
|
|
3526
3460
|
__proto__: null,
|
|
3527
3461
|
description: `removes empty <text> elements`,
|
|
3528
3462
|
fn: (e, t) => {
|
|
3529
3463
|
let { text: n = !0, tspan: r = !0, tref: i = !0 } = t;
|
|
3530
3464
|
return { element: { enter: (e, t) => {
|
|
3531
|
-
n && e.name === `text` && e.children.length === 0 &&
|
|
3465
|
+
n && e.name === `text` && e.children.length === 0 && D(e, t), r && e.name === `tspan` && e.children.length === 0 && D(e, t), i && e.name === `tref` && e.attributes[`xlink:href`] == null && D(e, t);
|
|
3532
3466
|
} } };
|
|
3533
3467
|
},
|
|
3534
3468
|
name: `removeEmptyText`
|
|
3535
3469
|
});
|
|
3536
|
-
let
|
|
3537
|
-
var
|
|
3470
|
+
let Ht = /[-+]?(?:\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?/g;
|
|
3471
|
+
var Ut = Object.freeze({
|
|
3538
3472
|
__proto__: null,
|
|
3539
3473
|
description: `converts basic shapes to more compact path form`,
|
|
3540
3474
|
fn: (e, t) => {
|
|
@@ -3565,7 +3499,7 @@ var l = e(((e) => {
|
|
|
3565
3499
|
args: []
|
|
3566
3500
|
}
|
|
3567
3501
|
];
|
|
3568
|
-
e.name = `path`, e.attributes.d =
|
|
3502
|
+
e.name = `path`, e.attributes.d = L({
|
|
3569
3503
|
pathData: o,
|
|
3570
3504
|
precision: r
|
|
3571
3505
|
}), delete e.attributes.x, delete e.attributes.y, delete e.attributes.width, delete e.attributes.height;
|
|
@@ -3580,15 +3514,15 @@ var l = e(((e) => {
|
|
|
3580
3514
|
command: `L`,
|
|
3581
3515
|
args: [i, a]
|
|
3582
3516
|
}];
|
|
3583
|
-
e.name = `path`, e.attributes.d =
|
|
3517
|
+
e.name = `path`, e.attributes.d = L({
|
|
3584
3518
|
pathData: o,
|
|
3585
3519
|
precision: r
|
|
3586
3520
|
}), delete e.attributes.x1, delete e.attributes.y1, delete e.attributes.x2, delete e.attributes.y2;
|
|
3587
3521
|
}
|
|
3588
3522
|
if ((e.name === `polyline` || e.name === `polygon`) && e.attributes.points != null) {
|
|
3589
|
-
let n = (e.attributes.points.match(
|
|
3523
|
+
let n = (e.attributes.points.match(Ht) || []).map(Number);
|
|
3590
3524
|
if (n.length < 4) {
|
|
3591
|
-
|
|
3525
|
+
D(e, t);
|
|
3592
3526
|
return;
|
|
3593
3527
|
}
|
|
3594
3528
|
let i = [];
|
|
@@ -3599,7 +3533,7 @@ var l = e(((e) => {
|
|
|
3599
3533
|
e.name === `polygon` && i.push({
|
|
3600
3534
|
command: `z`,
|
|
3601
3535
|
args: []
|
|
3602
|
-
}), e.name = `path`, e.attributes.d =
|
|
3536
|
+
}), e.name = `path`, e.attributes.d = L({
|
|
3603
3537
|
pathData: i,
|
|
3604
3538
|
precision: r
|
|
3605
3539
|
}), delete e.attributes.points;
|
|
@@ -3641,7 +3575,7 @@ var l = e(((e) => {
|
|
|
3641
3575
|
args: []
|
|
3642
3576
|
}
|
|
3643
3577
|
];
|
|
3644
|
-
e.name = `path`, e.attributes.d =
|
|
3578
|
+
e.name = `path`, e.attributes.d = L({
|
|
3645
3579
|
pathData: a,
|
|
3646
3580
|
precision: r
|
|
3647
3581
|
}), delete e.attributes.cx, delete e.attributes.cy, delete e.attributes.r;
|
|
@@ -3683,7 +3617,7 @@ var l = e(((e) => {
|
|
|
3683
3617
|
args: []
|
|
3684
3618
|
}
|
|
3685
3619
|
];
|
|
3686
|
-
e.name = `path`, e.attributes.d =
|
|
3620
|
+
e.name = `path`, e.attributes.d = L({
|
|
3687
3621
|
pathData: o,
|
|
3688
3622
|
precision: r
|
|
3689
3623
|
}), delete e.attributes.cx, delete e.attributes.cy, delete e.attributes.rx, delete e.attributes.ry;
|
|
@@ -3691,7 +3625,7 @@ var l = e(((e) => {
|
|
|
3691
3625
|
} } };
|
|
3692
3626
|
},
|
|
3693
3627
|
name: `convertShapeToPath`
|
|
3694
|
-
}),
|
|
3628
|
+
}), Wt = Object.freeze({
|
|
3695
3629
|
__proto__: null,
|
|
3696
3630
|
description: `converts non-eccentric <ellipse>s to <circle>s`,
|
|
3697
3631
|
fn: () => ({ element: { enter: (e) => {
|
|
@@ -3705,20 +3639,22 @@ var l = e(((e) => {
|
|
|
3705
3639
|
}
|
|
3706
3640
|
} } }),
|
|
3707
3641
|
name: `convertEllipseToCircle`
|
|
3708
|
-
}),
|
|
3642
|
+
}), Gt = Object.freeze({
|
|
3709
3643
|
__proto__: null,
|
|
3710
3644
|
description: `Move common attributes of group children to the group`,
|
|
3711
3645
|
fn: (e) => {
|
|
3712
3646
|
let t = !1;
|
|
3713
|
-
return
|
|
3647
|
+
return x(e, { element: { enter: (e) => {
|
|
3714
3648
|
e.name === `style` && (t = !0);
|
|
3715
3649
|
} } }), { element: { exit: (e) => {
|
|
3716
3650
|
if (e.name !== `g` || e.children.length <= 1 || t) return;
|
|
3717
3651
|
let n = /* @__PURE__ */ new Map(), r = !0, i = !0;
|
|
3718
|
-
for (let t of e.children) if (t.type === `element`)
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3652
|
+
for (let t of e.children) if (t.type === `element`) {
|
|
3653
|
+
if (me.has(t.name) || (i = !1), r) {
|
|
3654
|
+
r = !1;
|
|
3655
|
+
for (let [e, r] of Object.entries(t.attributes)) j.has(e) && n.set(e, r);
|
|
3656
|
+
} else for (let [e, r] of n) t.attributes[e] !== r && n.delete(e);
|
|
3657
|
+
}
|
|
3722
3658
|
e.attributes.filter == null && e.attributes[`clip-path`] == null && e.attributes.mask == null || n.delete(`transform`), i && n.delete(`transform`);
|
|
3723
3659
|
for (let [t, r] of n) t === `transform` ? e.attributes.transform == null ? e.attributes.transform = r : e.attributes.transform = `${e.attributes.transform} ${r}` : e.attributes[t] = r;
|
|
3724
3660
|
for (let t of e.children) if (t.type === `element`) for (let [e] of n) delete t.attributes[e];
|
|
@@ -3726,16 +3662,16 @@ var l = e(((e) => {
|
|
|
3726
3662
|
},
|
|
3727
3663
|
name: `moveElemsAttrsToGroup`
|
|
3728
3664
|
});
|
|
3729
|
-
let
|
|
3730
|
-
...
|
|
3665
|
+
let Kt = [
|
|
3666
|
+
...me,
|
|
3731
3667
|
`g`,
|
|
3732
3668
|
`text`
|
|
3733
3669
|
];
|
|
3734
|
-
var
|
|
3670
|
+
var qt = Object.freeze({
|
|
3735
3671
|
__proto__: null,
|
|
3736
3672
|
description: `moves some group attributes to the content elements`,
|
|
3737
3673
|
fn: () => ({ element: { enter: (e) => {
|
|
3738
|
-
if (e.name === `g` && e.children.length !== 0 && e.attributes.transform != null && Object.entries(e.attributes).some((
|
|
3674
|
+
if (e.name === `g` && e.children.length !== 0 && e.attributes.transform != null && Object.entries(e.attributes).some(([e, t]) => A.has(e) && $e(t)) === !1 && e.children.every((e) => e.type === `element` && Kt.includes(e.name) && e.attributes.id == null)) {
|
|
3739
3675
|
for (let t of e.children) {
|
|
3740
3676
|
let n = e.attributes.transform;
|
|
3741
3677
|
t.type === `element` && (t.attributes.transform == null ? t.attributes.transform = n : t.attributes.transform = `${n} ${t.attributes.transform}`);
|
|
@@ -3745,36 +3681,36 @@ var l = e(((e) => {
|
|
|
3745
3681
|
} } }),
|
|
3746
3682
|
name: `moveGroupAttrsToElems`
|
|
3747
3683
|
});
|
|
3748
|
-
let
|
|
3684
|
+
let Jt = (e, t) => {
|
|
3749
3685
|
if (e.type === `element`) {
|
|
3750
|
-
if (
|
|
3751
|
-
for (let n of e.children) if (
|
|
3686
|
+
if (O.animation.has(e.name) && e.attributes.attributeName === t) return !0;
|
|
3687
|
+
for (let n of e.children) if (Jt(n, t)) return !0;
|
|
3752
3688
|
}
|
|
3753
3689
|
return !1;
|
|
3754
3690
|
};
|
|
3755
|
-
var
|
|
3691
|
+
var Yt = Object.freeze({
|
|
3756
3692
|
__proto__: null,
|
|
3757
3693
|
description: `collapses useless groups`,
|
|
3758
3694
|
fn: (e) => {
|
|
3759
|
-
let t =
|
|
3695
|
+
let t = M(e);
|
|
3760
3696
|
return { element: { exit: (e, n) => {
|
|
3761
3697
|
if (n.type !== `root` && n.name !== `switch` && e.name === `g` && e.children.length !== 0) {
|
|
3762
3698
|
if (Object.keys(e.attributes).length !== 0 && e.children.length === 1) {
|
|
3763
|
-
let n = e.children[0], r = !!(e.attributes.filter ||
|
|
3699
|
+
let n = e.children[0], r = !!(e.attributes.filter || N(t, e).filter);
|
|
3764
3700
|
if (n.type === `element` && n.attributes.id == null && !r && (e.attributes.class == null || n.attributes.class == null) && (e.attributes[`clip-path`] == null && e.attributes.mask == null || n.name === `g` && e.attributes.transform == null && n.attributes.transform == null)) {
|
|
3765
3701
|
let t = { ...n.attributes };
|
|
3766
3702
|
for (let [r, i] of Object.entries(e.attributes)) {
|
|
3767
|
-
if (
|
|
3703
|
+
if (Jt(n, r)) return;
|
|
3768
3704
|
if (t[r] == null) t[r] = i;
|
|
3769
3705
|
else if (r === `transform`) t[r] = i + ` ` + t[r];
|
|
3770
3706
|
else if (t[r] === `inherit`) t[r] = i;
|
|
3771
|
-
else if (!
|
|
3707
|
+
else if (!j.has(r) && t[r] !== i) return;
|
|
3772
3708
|
}
|
|
3773
3709
|
e.attributes = {}, n.attributes = t;
|
|
3774
3710
|
}
|
|
3775
3711
|
}
|
|
3776
3712
|
if (Object.keys(e.attributes).length === 0) {
|
|
3777
|
-
for (let t of e.children) if (t.type === `element` &&
|
|
3713
|
+
for (let t of e.children) if (t.type === `element` && O.animation.has(t.name)) return;
|
|
3778
3714
|
let t = n.children.indexOf(e);
|
|
3779
3715
|
n.children.splice(t, 1, ...e.children);
|
|
3780
3716
|
}
|
|
@@ -3783,22 +3719,22 @@ var l = e(((e) => {
|
|
|
3783
3719
|
},
|
|
3784
3720
|
name: `collapseGroups`
|
|
3785
3721
|
});
|
|
3786
|
-
let
|
|
3722
|
+
let R, Xt = (e) => {
|
|
3787
3723
|
if (e.pathJS) return e.pathJS;
|
|
3788
|
-
let t = [], n =
|
|
3724
|
+
let t = [], n = It(e.attributes.d);
|
|
3789
3725
|
for (let { command: e, args: r } of n) t.push({
|
|
3790
3726
|
command: e,
|
|
3791
3727
|
args: r
|
|
3792
3728
|
});
|
|
3793
3729
|
return t.length && t[0].command == `m` && (t[0].command = `M`), e.pathJS = t, t;
|
|
3794
|
-
},
|
|
3730
|
+
}, Zt = (e) => {
|
|
3795
3731
|
let t = [], n = [0, 0], r = [0, 0];
|
|
3796
3732
|
for (let { command: i, args: a } of e) a = a.slice(), i === `m` && (a[0] += r[0], a[1] += r[1], i = `M`), i === `M` && (r[0] = a[0], r[1] = a[1], n[0] = r[0], n[1] = r[1]), i === `h` && (a[0] += r[0], i = `H`), i === `H` && (r[0] = a[0]), i === `v` && (a[0] += r[1], i = `V`), i === `V` && (r[1] = a[0]), i === `l` && (a[0] += r[0], a[1] += r[1], i = `L`), i === `L` && (r[0] = a[0], r[1] = a[1]), i === `c` && (a[0] += r[0], a[1] += r[1], a[2] += r[0], a[3] += r[1], a[4] += r[0], a[5] += r[1], i = `C`), i === `C` && (r[0] = a[4], r[1] = a[5]), i === `s` && (a[0] += r[0], a[1] += r[1], a[2] += r[0], a[3] += r[1], i = `S`), i === `S` && (r[0] = a[2], r[1] = a[3]), i === `q` && (a[0] += r[0], a[1] += r[1], a[2] += r[0], a[3] += r[1], i = `Q`), i === `Q` && (r[0] = a[2], r[1] = a[3]), i === `t` && (a[0] += r[0], a[1] += r[1], i = `T`), i === `T` && (r[0] = a[0], r[1] = a[1]), i === `a` && (a[5] += r[0], a[6] += r[1], i = `A`), i === `A` && (r[0] = a[5], r[1] = a[6]), (i === `z` || i === `Z`) && (r[0] = n[0], r[1] = n[1], i = `z`), t.push({
|
|
3797
3733
|
command: i,
|
|
3798
3734
|
args: a
|
|
3799
3735
|
});
|
|
3800
3736
|
return t;
|
|
3801
|
-
},
|
|
3737
|
+
}, Qt = function(e, t, n) {
|
|
3802
3738
|
e.pathJS = t;
|
|
3803
3739
|
let r = [];
|
|
3804
3740
|
for (let e of t) {
|
|
@@ -3811,67 +3747,67 @@ var l = e(((e) => {
|
|
|
3811
3747
|
args: e.args
|
|
3812
3748
|
});
|
|
3813
3749
|
}
|
|
3814
|
-
e.attributes.d =
|
|
3750
|
+
e.attributes.d = L({
|
|
3815
3751
|
pathData: r,
|
|
3816
3752
|
precision: n.floatPrecision,
|
|
3817
3753
|
disableSpaceAfterFlags: n.noSpaceAfterFlags
|
|
3818
3754
|
});
|
|
3819
3755
|
};
|
|
3820
|
-
function
|
|
3756
|
+
function z(e, t) {
|
|
3821
3757
|
return e[0] = t[t.length - 2], e[1] = t[t.length - 1], e;
|
|
3822
3758
|
}
|
|
3823
|
-
let
|
|
3824
|
-
let n =
|
|
3825
|
-
if (n.maxX <= r.minX || r.maxX <= n.minX || n.maxY <= r.minY || r.maxY <= n.minY || n.list.every((
|
|
3826
|
-
let i = n.list.map(
|
|
3827
|
-
return i.some(
|
|
3828
|
-
return e.list.length < 3 ? !1 : a.some(
|
|
3759
|
+
let $t = function(e, t) {
|
|
3760
|
+
let n = rn(Zt(e)), r = rn(Zt(t));
|
|
3761
|
+
if (n.maxX <= r.minX || r.maxX <= n.minX || n.maxY <= r.minY || r.maxY <= n.minY || n.list.every((e) => r.list.every((t) => e.list[e.maxX][0] <= t.list[t.minX][0] || t.list[t.maxX][0] <= e.list[e.minX][0] || e.list[e.maxY][1] <= t.list[t.minY][1] || t.list[t.maxY][1] <= e.list[e.minY][1]))) return !1;
|
|
3762
|
+
let i = n.list.map(an), a = r.list.map(an);
|
|
3763
|
+
return i.some(function(e) {
|
|
3764
|
+
return e.list.length < 3 ? !1 : a.some(function(t) {
|
|
3829
3765
|
if (t.list.length < 3) return !1;
|
|
3830
|
-
let n = [o(e, t, [1, 0])], r =
|
|
3766
|
+
let n = [o(e, t, [1, 0])], r = B(n[0]), i = 1e4;
|
|
3831
3767
|
for (;;) {
|
|
3832
3768
|
if (i-- == 0) return console.error(`Error: infinite loop while processing mergePaths plugin.`), !0;
|
|
3833
|
-
if (n.push(o(e, t, r)),
|
|
3834
|
-
if (
|
|
3769
|
+
if (n.push(o(e, t, r)), V(r, n[n.length - 1]) <= 0) return !1;
|
|
3770
|
+
if (en(n, r)) return !0;
|
|
3835
3771
|
}
|
|
3836
|
-
})
|
|
3837
|
-
})
|
|
3772
|
+
});
|
|
3773
|
+
});
|
|
3838
3774
|
function o(e, t, n) {
|
|
3839
|
-
return
|
|
3775
|
+
return tn(s(e, n), s(t, B(n)));
|
|
3840
3776
|
}
|
|
3841
3777
|
function s(e, t) {
|
|
3842
|
-
let n = t[1] >= 0 ? t[0] < 0 ? e.maxY : e.maxX : t[0] < 0 ? e.minX : e.minY, r = -
|
|
3843
|
-
for (; (i =
|
|
3778
|
+
let n = t[1] >= 0 ? t[0] < 0 ? e.maxY : e.maxX : t[0] < 0 ? e.minX : e.minY, r = -1 / 0, i;
|
|
3779
|
+
for (; (i = V(e.list[n], t)) > r;) r = i, n = (n + 1) % e.list.length;
|
|
3844
3780
|
return e.list[(n || e.list.length) - 1];
|
|
3845
3781
|
}
|
|
3846
3782
|
};
|
|
3847
|
-
function
|
|
3783
|
+
function en(e, t) {
|
|
3848
3784
|
if (e.length == 2) {
|
|
3849
|
-
let n = e[1], r = e[0], i =
|
|
3850
|
-
|
|
3785
|
+
let n = e[1], r = e[0], i = B(e[1]), a = tn(r, n);
|
|
3786
|
+
V(i, a) > 0 ? z(t, nn(a, n)) : (z(t, i), e.shift());
|
|
3851
3787
|
} else {
|
|
3852
|
-
let n = e[2], r = e[1], i = e[0], a =
|
|
3853
|
-
if (
|
|
3788
|
+
let n = e[2], r = e[1], i = e[0], a = tn(r, n), o = tn(i, n), s = B(n), c = nn(a, o), l = nn(o, a);
|
|
3789
|
+
if (V(c, s) > 0) V(a, s) > 0 ? (z(t, c), e.shift()) : (z(t, s), e.splice(0, 2));
|
|
3854
3790
|
else {
|
|
3855
|
-
if (!(
|
|
3856
|
-
|
|
3791
|
+
if (!(V(l, s) > 0)) return !0;
|
|
3792
|
+
V(o, s) > 0 ? (z(t, l), e.splice(1, 1)) : (z(t, s), e.splice(0, 2));
|
|
3857
3793
|
}
|
|
3858
3794
|
}
|
|
3859
3795
|
return !1;
|
|
3860
3796
|
}
|
|
3861
|
-
function
|
|
3797
|
+
function B(e) {
|
|
3862
3798
|
return [-e[0], -e[1]];
|
|
3863
3799
|
}
|
|
3864
|
-
function
|
|
3800
|
+
function tn(e, t) {
|
|
3865
3801
|
return [e[0] - t[0], e[1] - t[1]];
|
|
3866
3802
|
}
|
|
3867
|
-
function
|
|
3803
|
+
function V(e, t) {
|
|
3868
3804
|
return e[0] * t[0] + e[1] * t[1];
|
|
3869
3805
|
}
|
|
3870
|
-
function
|
|
3806
|
+
function nn(e, t) {
|
|
3871
3807
|
let n = [-e[1], e[0]];
|
|
3872
|
-
return
|
|
3808
|
+
return V(n, B(t)) < 0 ? B(n) : n;
|
|
3873
3809
|
}
|
|
3874
|
-
function
|
|
3810
|
+
function rn(e) {
|
|
3875
3811
|
let t = {
|
|
3876
3812
|
list: [],
|
|
3877
3813
|
minX: 0,
|
|
@@ -3906,19 +3842,19 @@ var l = e(((e) => {
|
|
|
3906
3842
|
c != null && n(o, [c[0], l[0]]);
|
|
3907
3843
|
break;
|
|
3908
3844
|
case `Q`:
|
|
3909
|
-
n(o, l.slice(0, 2)),
|
|
3845
|
+
n(o, l.slice(0, 2)), R = [l[2] - l[0], l[3] - l[1]];
|
|
3910
3846
|
break;
|
|
3911
3847
|
case `T`:
|
|
3912
|
-
c != null && s != null && (s.command == `Q` || s.command == `T`) && (u = [c[0] +
|
|
3848
|
+
c != null && s != null && (s.command == `Q` || s.command == `T`) && (u = [c[0] + R[0], c[1] + R[1]], n(o, u), R = [l[0] - u[0], l[1] - u[1]]);
|
|
3913
3849
|
break;
|
|
3914
3850
|
case `C`:
|
|
3915
|
-
c != null && n(o, [.5 * (c[0] + l[0]), .5 * (c[1] + l[1])]), n(o, [.5 * (l[0] + l[2]), .5 * (l[1] + l[3])]), n(o, [.5 * (l[2] + l[4]), .5 * (l[3] + l[5])]),
|
|
3851
|
+
c != null && n(o, [.5 * (c[0] + l[0]), .5 * (c[1] + l[1])]), n(o, [.5 * (l[0] + l[2]), .5 * (l[1] + l[3])]), n(o, [.5 * (l[2] + l[4]), .5 * (l[3] + l[5])]), R = [l[4] - l[2], l[5] - l[3]];
|
|
3916
3852
|
break;
|
|
3917
3853
|
case `S`:
|
|
3918
|
-
c != null && s != null && (s.command == `C` || s.command == `S`) && (n(o, [c[0] + .5 *
|
|
3854
|
+
c != null && s != null && (s.command == `C` || s.command == `S`) && (n(o, [c[0] + .5 * R[0], c[1] + .5 * R[1]]), u = [c[0] + R[0], c[1] + R[1]]), u != null && n(o, [.5 * (u[0] + l[0]), .5 * (u[1] + l[1])]), n(o, [.5 * (l[0] + l[2]), .5 * (l[1] + l[3])]), R = [l[2] - l[0], l[3] - l[1]];
|
|
3919
3855
|
break;
|
|
3920
3856
|
case `A`: if (c != null) {
|
|
3921
|
-
let e =
|
|
3857
|
+
let e = sn.apply(0, c.concat(l));
|
|
3922
3858
|
for (var r; (r = e.splice(0, 6).map(d)).length;) c != null && n(o, [.5 * (c[0] + r[0]), .5 * (c[1] + r[1])]), n(o, [.5 * (r[0] + r[2]), .5 * (r[1] + r[3])]), n(o, [.5 * (r[2] + r[4]), .5 * (r[3] + r[5])]), e.length && n(o, c = r.slice(-2));
|
|
3923
3859
|
}
|
|
3924
3860
|
}
|
|
@@ -3926,18 +3862,18 @@ var l = e(((e) => {
|
|
|
3926
3862
|
}
|
|
3927
3863
|
return t;
|
|
3928
3864
|
}
|
|
3929
|
-
function
|
|
3930
|
-
e.list.sort(
|
|
3865
|
+
function an(e) {
|
|
3866
|
+
e.list.sort(function(e, t) {
|
|
3931
3867
|
return e[0] == t[0] ? e[1] - t[1] : e[0] - t[0];
|
|
3932
|
-
})
|
|
3868
|
+
});
|
|
3933
3869
|
let t = [], n = 0, r = 0;
|
|
3934
3870
|
for (let i = 0; i < e.list.length; i++) {
|
|
3935
|
-
for (; t.length >= 2 &&
|
|
3871
|
+
for (; t.length >= 2 && on(t[t.length - 2], t[t.length - 1], e.list[i]) <= 0;) t.pop();
|
|
3936
3872
|
e.list[i][1] < e.list[n][1] && (n = i, r = t.length), t.push(e.list[i]);
|
|
3937
3873
|
}
|
|
3938
3874
|
let i = [], a = e.list.length - 1, o = 0;
|
|
3939
3875
|
for (let t = e.list.length; t--;) {
|
|
3940
|
-
for (; i.length >= 2 &&
|
|
3876
|
+
for (; i.length >= 2 && on(i[i.length - 2], i[i.length - 1], e.list[t]) <= 0;) i.pop();
|
|
3941
3877
|
e.list[t][1] > e.list[a][1] && (a = t, o = i.length), i.push(e.list[t]);
|
|
3942
3878
|
}
|
|
3943
3879
|
i.pop(), t.pop();
|
|
@@ -3950,10 +3886,10 @@ var l = e(((e) => {
|
|
|
3950
3886
|
maxY: (t.length + o) % s.length
|
|
3951
3887
|
};
|
|
3952
3888
|
}
|
|
3953
|
-
function
|
|
3889
|
+
function on(e, t, n) {
|
|
3954
3890
|
return (t[0] - e[0]) * (n[1] - e[1]) - (t[1] - e[1]) * (n[0] - e[0]);
|
|
3955
3891
|
}
|
|
3956
|
-
let
|
|
3892
|
+
let sn = (e, t, n, r, i, a, o, s, c, l) => {
|
|
3957
3893
|
let u = Math.PI * 120 / 180, d = Math.PI / 180 * (+i || 0), f = [], p = (e, t, n) => e * Math.cos(n) - t * Math.sin(n), m = (e, t, n) => e * Math.sin(n) + t * Math.cos(n);
|
|
3958
3894
|
if (l) _ = l[0], v = l[1], h = l[2], g = l[3];
|
|
3959
3895
|
else {
|
|
@@ -3967,7 +3903,7 @@ var l = e(((e) => {
|
|
|
3967
3903
|
let y = v - _;
|
|
3968
3904
|
if (Math.abs(y) > u) {
|
|
3969
3905
|
let e = v, t = s, a = c;
|
|
3970
|
-
v = _ + u * (o && v > _ ? 1 : -1), s = h + n * Math.cos(v), c = g + r * Math.sin(v), f =
|
|
3906
|
+
v = _ + u * (o && v > _ ? 1 : -1), s = h + n * Math.cos(v), c = g + r * Math.sin(v), f = sn(s, c, n, r, i, 0, o, t, a, [
|
|
3971
3907
|
v,
|
|
3972
3908
|
e,
|
|
3973
3909
|
h,
|
|
@@ -3975,58 +3911,60 @@ var l = e(((e) => {
|
|
|
3975
3911
|
]);
|
|
3976
3912
|
}
|
|
3977
3913
|
y = v - _;
|
|
3978
|
-
let b = Math.cos(_), x = Math.sin(_), S = Math.cos(v),
|
|
3979
|
-
-
|
|
3980
|
-
|
|
3981
|
-
s +
|
|
3982
|
-
c -
|
|
3914
|
+
let b = Math.cos(_), x = Math.sin(_), S = Math.cos(v), ee = Math.sin(v), C = Math.tan(y / 4), w = 4 / 3 * n * C, te = 4 / 3 * r * C, T = [
|
|
3915
|
+
-w * x,
|
|
3916
|
+
te * b,
|
|
3917
|
+
s + w * ee - e,
|
|
3918
|
+
c - te * S - t,
|
|
3983
3919
|
s - e,
|
|
3984
3920
|
c - t
|
|
3985
3921
|
];
|
|
3986
|
-
if (l) return
|
|
3922
|
+
if (l) return T.concat(f);
|
|
3987
3923
|
{
|
|
3988
|
-
f =
|
|
3924
|
+
f = T.concat(f);
|
|
3989
3925
|
let e = [];
|
|
3990
3926
|
for (let t = 0, n = f.length; t < n; t++) e[t] = t % 2 ? m(f[t - 1], f[t], d) : p(f[t], f[t + 1], d);
|
|
3991
3927
|
return e;
|
|
3992
3928
|
}
|
|
3993
|
-
},
|
|
3929
|
+
}, cn = /* @__PURE__ */ new Set([
|
|
3994
3930
|
`matrix`,
|
|
3995
3931
|
`rotate`,
|
|
3996
3932
|
`scale`,
|
|
3997
3933
|
`skewX`,
|
|
3998
3934
|
`skewY`,
|
|
3999
3935
|
`translate`
|
|
4000
|
-
]),
|
|
3936
|
+
]), ln = /\s*(matrix|translate|scale|rotate|skewX|skewY)\s*\(\s*(.+?)\s*\)[\s,]*/, un = /[-+]?(?:\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?/g, dn = (e) => {
|
|
4001
3937
|
let t = [], n = null;
|
|
4002
|
-
for (let r of e.split(
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
3938
|
+
for (let r of e.split(ln)) if (r) {
|
|
3939
|
+
if (cn.has(r)) n = {
|
|
3940
|
+
name: r,
|
|
3941
|
+
data: []
|
|
3942
|
+
}, t.push(n);
|
|
3943
|
+
else {
|
|
3944
|
+
let e;
|
|
3945
|
+
for (; e = un.exec(r);) e = Number(e), n?.data.push(e);
|
|
3946
|
+
}
|
|
4009
3947
|
}
|
|
4010
3948
|
return n == null || n.data.length == 0 ? [] : t;
|
|
4011
|
-
},
|
|
4012
|
-
let t = e.map((
|
|
3949
|
+
}, fn = (e) => {
|
|
3950
|
+
let t = e.map((e) => e.name === `matrix` ? e.data : xn(e));
|
|
4013
3951
|
return {
|
|
4014
3952
|
name: `matrix`,
|
|
4015
|
-
data: t.length > 0 ? t.reduce(
|
|
3953
|
+
data: t.length > 0 ? t.reduce(Cn) : []
|
|
4016
3954
|
};
|
|
4017
|
-
},
|
|
3955
|
+
}, H = {
|
|
4018
3956
|
rad: (e) => e * Math.PI / 180,
|
|
4019
3957
|
deg: (e) => e * 180 / Math.PI,
|
|
4020
|
-
cos: (e) => Math.cos(
|
|
4021
|
-
acos: (e, t) =>
|
|
4022
|
-
sin: (e) => Math.sin(
|
|
4023
|
-
asin: (e, t) =>
|
|
4024
|
-
tan: (e) => Math.tan(
|
|
4025
|
-
atan: (e, t) =>
|
|
4026
|
-
}, fn = (e) => {
|
|
4027
|
-
let t = [], n = pn(e), r = mn(e);
|
|
4028
|
-
return n && t.push(n), r && t.push(r), t;
|
|
3958
|
+
cos: (e) => Math.cos(H.rad(e)),
|
|
3959
|
+
acos: (e, t) => I(H.deg(Math.acos(e)), t),
|
|
3960
|
+
sin: (e) => Math.sin(H.rad(e)),
|
|
3961
|
+
asin: (e, t) => I(H.deg(Math.asin(e)), t),
|
|
3962
|
+
tan: (e) => Math.tan(H.rad(e)),
|
|
3963
|
+
atan: (e, t) => I(H.deg(Math.atan(e)), t)
|
|
4029
3964
|
}, pn = (e) => {
|
|
3965
|
+
let t = [], n = mn(e), r = hn(e);
|
|
3966
|
+
return n && t.push(n), r && t.push(r), t;
|
|
3967
|
+
}, mn = (e) => {
|
|
4030
3968
|
let [t, n, r, i, a, o] = e.data, s = t * i - n * r;
|
|
4031
3969
|
if (s === 0) return;
|
|
4032
3970
|
let c = Math.hypot(t, n);
|
|
@@ -4040,7 +3978,7 @@ var l = e(((e) => {
|
|
|
4040
3978
|
l.push({
|
|
4041
3979
|
name: `rotate`,
|
|
4042
3980
|
data: [
|
|
4043
|
-
|
|
3981
|
+
H.deg(n < 0 ? -e : e),
|
|
4044
3982
|
0,
|
|
4045
3983
|
0
|
|
4046
3984
|
]
|
|
@@ -4054,9 +3992,9 @@ var l = e(((e) => {
|
|
|
4054
3992
|
let p = t * r + n * i;
|
|
4055
3993
|
return p && l.push({
|
|
4056
3994
|
name: `skewX`,
|
|
4057
|
-
data: [
|
|
3995
|
+
data: [H.deg(Math.atan(p / (t * t + n * n)))]
|
|
4058
3996
|
}), l;
|
|
4059
|
-
},
|
|
3997
|
+
}, hn = (e) => {
|
|
4060
3998
|
let [t, n, r, i, a, o] = e.data, s = t * i - n * r;
|
|
4061
3999
|
if (s === 0) return;
|
|
4062
4000
|
let c = Math.hypot(r, i);
|
|
@@ -4070,7 +4008,7 @@ var l = e(((e) => {
|
|
|
4070
4008
|
l.push({
|
|
4071
4009
|
name: `rotate`,
|
|
4072
4010
|
data: [
|
|
4073
|
-
|
|
4011
|
+
H.deg(u),
|
|
4074
4012
|
0,
|
|
4075
4013
|
0
|
|
4076
4014
|
]
|
|
@@ -4083,10 +4021,10 @@ var l = e(((e) => {
|
|
|
4083
4021
|
let p = t * r + n * i;
|
|
4084
4022
|
return p && l.push({
|
|
4085
4023
|
name: `skewY`,
|
|
4086
|
-
data: [
|
|
4024
|
+
data: [H.deg(Math.atan(p / (r * r + i * i)))]
|
|
4087
4025
|
}), l;
|
|
4088
|
-
},
|
|
4089
|
-
let r =
|
|
4026
|
+
}, gn = (e, t, n) => {
|
|
4027
|
+
let r = H.rad(n), i = 1 - Math.cos(r), a = Math.sin(r), o = (i * t + a * e) / (i * i + a * a);
|
|
4090
4028
|
return {
|
|
4091
4029
|
name: `rotate`,
|
|
4092
4030
|
data: [
|
|
@@ -4095,7 +4033,7 @@ var l = e(((e) => {
|
|
|
4095
4033
|
o
|
|
4096
4034
|
]
|
|
4097
4035
|
};
|
|
4098
|
-
},
|
|
4036
|
+
}, _n = (e) => {
|
|
4099
4037
|
switch (e.name) {
|
|
4100
4038
|
case `rotate`:
|
|
4101
4039
|
case `skewX`:
|
|
@@ -4104,11 +4042,11 @@ var l = e(((e) => {
|
|
|
4104
4042
|
case `translate`: return e.data[0] === 0 && e.data[1] === 0;
|
|
4105
4043
|
}
|
|
4106
4044
|
return !1;
|
|
4107
|
-
},
|
|
4045
|
+
}, vn = (e, t) => {
|
|
4108
4046
|
let n = [];
|
|
4109
4047
|
for (let r = 0; r < e.length; r++) {
|
|
4110
4048
|
let i = e[r];
|
|
4111
|
-
if (
|
|
4049
|
+
if (_n(i)) continue;
|
|
4112
4050
|
let a = i.data;
|
|
4113
4051
|
switch (i.name) {
|
|
4114
4052
|
case `rotate`:
|
|
@@ -4117,7 +4055,7 @@ var l = e(((e) => {
|
|
|
4117
4055
|
case -180:
|
|
4118
4056
|
{
|
|
4119
4057
|
let t = e[r + 1];
|
|
4120
|
-
t && t.name === `scale` ? (n.push(
|
|
4058
|
+
t && t.name === `scale` ? (n.push(yn(t.data.map((e) => -e))), r++) : n.push({
|
|
4121
4059
|
name: `scale`,
|
|
4122
4060
|
data: [-1]
|
|
4123
4061
|
});
|
|
@@ -4130,7 +4068,7 @@ var l = e(((e) => {
|
|
|
4130
4068
|
});
|
|
4131
4069
|
break;
|
|
4132
4070
|
case `scale`:
|
|
4133
|
-
n.push(
|
|
4071
|
+
n.push(yn(a));
|
|
4134
4072
|
break;
|
|
4135
4073
|
case `skewX`:
|
|
4136
4074
|
case `skewY`:
|
|
@@ -4144,7 +4082,7 @@ var l = e(((e) => {
|
|
|
4144
4082
|
let i = e[r + 1];
|
|
4145
4083
|
if (i && i.name === `rotate` && i.data[0] !== 180 && i.data[0] !== -180 && i.data[0] !== 0 && i.data[1] === 0 && i.data[2] === 0) {
|
|
4146
4084
|
let e = t[r].data;
|
|
4147
|
-
n.push(
|
|
4085
|
+
n.push(gn(e[0], e[1], t[r + 1].data[0])), r++;
|
|
4148
4086
|
continue;
|
|
4149
4087
|
}
|
|
4150
4088
|
}
|
|
@@ -4158,23 +4096,23 @@ var l = e(((e) => {
|
|
|
4158
4096
|
name: `scale`,
|
|
4159
4097
|
data: [1]
|
|
4160
4098
|
}];
|
|
4161
|
-
},
|
|
4099
|
+
}, yn = (e) => ({
|
|
4162
4100
|
name: `scale`,
|
|
4163
4101
|
data: e.slice(0, e[0] === e[1] ? 1 : 2)
|
|
4164
|
-
}),
|
|
4165
|
-
let n =
|
|
4102
|
+
}), bn = (e, t) => {
|
|
4103
|
+
let n = pn(e), r, i = Number.MAX_VALUE;
|
|
4166
4104
|
for (let e of n) {
|
|
4167
|
-
let n = e.map((
|
|
4105
|
+
let n = e.map((e) => {
|
|
4168
4106
|
let n = {
|
|
4169
4107
|
name: e.name,
|
|
4170
4108
|
data: [...e.data]
|
|
4171
4109
|
};
|
|
4172
|
-
return
|
|
4173
|
-
})
|
|
4110
|
+
return wn(n, t);
|
|
4111
|
+
}), a = vn(n, e), o = An(a, t).length;
|
|
4174
4112
|
o < i && (r = a, i = o);
|
|
4175
4113
|
}
|
|
4176
4114
|
return r ?? [e];
|
|
4177
|
-
},
|
|
4115
|
+
}, xn = (e) => {
|
|
4178
4116
|
if (e.name === `matrix`) return e.data;
|
|
4179
4117
|
switch (e.name) {
|
|
4180
4118
|
case `translate`: return [
|
|
@@ -4194,7 +4132,7 @@ var l = e(((e) => {
|
|
|
4194
4132
|
0
|
|
4195
4133
|
];
|
|
4196
4134
|
case `rotate`:
|
|
4197
|
-
var t =
|
|
4135
|
+
var t = H.cos(e.data[0]), n = H.sin(e.data[0]), r = e.data[1] || 0, i = e.data[2] || 0;
|
|
4198
4136
|
return [
|
|
4199
4137
|
t,
|
|
4200
4138
|
n,
|
|
@@ -4206,14 +4144,14 @@ var l = e(((e) => {
|
|
|
4206
4144
|
case `skewX`: return [
|
|
4207
4145
|
1,
|
|
4208
4146
|
0,
|
|
4209
|
-
|
|
4147
|
+
H.tan(e.data[0]),
|
|
4210
4148
|
1,
|
|
4211
4149
|
0,
|
|
4212
4150
|
0
|
|
4213
4151
|
];
|
|
4214
4152
|
case `skewY`: return [
|
|
4215
4153
|
1,
|
|
4216
|
-
|
|
4154
|
+
H.tan(e.data[0]),
|
|
4217
4155
|
0,
|
|
4218
4156
|
1,
|
|
4219
4157
|
0,
|
|
@@ -4221,7 +4159,7 @@ var l = e(((e) => {
|
|
|
4221
4159
|
];
|
|
4222
4160
|
default: throw Error(`Unknown transform ${e.name}`);
|
|
4223
4161
|
}
|
|
4224
|
-
},
|
|
4162
|
+
}, Sn = (e, t, n) => {
|
|
4225
4163
|
let r = t[5] - e[0], i = t[6] - e[1], a = t[0], o = t[1], s = t[2] * Math.PI / 180, c = Math.cos(s), l = Math.sin(s);
|
|
4226
4164
|
if (a > 0 && o > 0) {
|
|
4227
4165
|
let e = (r * c + i * l) ** 2 / (4 * a * a) + (i * c - r * l) ** 2 / (4 * o * o);
|
|
@@ -4234,142 +4172,142 @@ var l = e(((e) => {
|
|
|
4234
4172
|
o * c,
|
|
4235
4173
|
0,
|
|
4236
4174
|
0
|
|
4237
|
-
], d =
|
|
4175
|
+
], d = Cn(n, u), f = d[2] * d[2] + d[3] * d[3], p = d[0] * d[0] + d[1] * d[1] + f, m = Math.hypot(d[0] - d[3], d[1] + d[2]) * Math.hypot(d[0] + d[3], d[1] - d[2]);
|
|
4238
4176
|
if (m) {
|
|
4239
4177
|
let e = (p + m) / 2, n = (p - m) / 2, r = Math.abs(e - f) > 1e-6, i = (r ? e : n) - f, a = d[0] * d[2] + d[1] * d[3], o = d[0] * i + d[2] * a, s = d[1] * i + d[3] * a;
|
|
4240
4178
|
t[0] = Math.sqrt(e), t[1] = Math.sqrt(n), t[2] = ((r ? s < 0 : o > 0) ? -1 : 1) * Math.acos((r ? o : s) / Math.hypot(o, s)) * 180 / Math.PI;
|
|
4241
4179
|
} else t[0] = t[1] = Math.sqrt(p / 2), t[2] = 0;
|
|
4242
4180
|
return n[0] < 0 != n[3] < 0 && (t[4] = 1 - t[4]), t;
|
|
4243
|
-
},
|
|
4181
|
+
}, Cn = (e, t) => [
|
|
4244
4182
|
e[0] * t[0] + e[2] * t[1],
|
|
4245
4183
|
e[1] * t[0] + e[3] * t[1],
|
|
4246
4184
|
e[0] * t[2] + e[2] * t[3],
|
|
4247
4185
|
e[1] * t[2] + e[3] * t[3],
|
|
4248
4186
|
e[0] * t[4] + e[2] * t[5] + e[4],
|
|
4249
4187
|
e[1] * t[4] + e[3] * t[5] + e[5]
|
|
4250
|
-
],
|
|
4188
|
+
], wn = (e, t) => {
|
|
4251
4189
|
switch (e.name) {
|
|
4252
4190
|
case `translate`:
|
|
4253
|
-
e.data =
|
|
4191
|
+
e.data = En(e.data, t);
|
|
4254
4192
|
break;
|
|
4255
4193
|
case `rotate`:
|
|
4256
|
-
e.data = [...
|
|
4194
|
+
e.data = [...Tn(e.data.slice(0, 1), t), ...En(e.data.slice(1), t)];
|
|
4257
4195
|
break;
|
|
4258
4196
|
case `skewX`:
|
|
4259
4197
|
case `skewY`:
|
|
4260
|
-
e.data =
|
|
4198
|
+
e.data = Tn(e.data, t);
|
|
4261
4199
|
break;
|
|
4262
4200
|
case `scale`:
|
|
4263
|
-
e.data =
|
|
4201
|
+
e.data = Dn(e.data, t);
|
|
4264
4202
|
break;
|
|
4265
|
-
case `matrix`: e.data = [...
|
|
4203
|
+
case `matrix`: e.data = [...Dn(e.data.slice(0, 4), t), ...En(e.data.slice(4), t)];
|
|
4266
4204
|
}
|
|
4267
4205
|
return e;
|
|
4268
|
-
},
|
|
4269
|
-
for (let n = t.length, r = +(.1 ** e).toFixed(e); n--;) if (
|
|
4206
|
+
}, Tn = (e, t) => t.degPrecision != null && t.degPrecision >= 1 && t.floatPrecision < 20 ? kn(t.degPrecision, e) : On(e), En = (e, t) => t.floatPrecision >= 1 && t.floatPrecision < 20 ? kn(t.floatPrecision, e) : On(e), Dn = (e, t) => t.transformPrecision >= 1 && t.floatPrecision < 20 ? kn(t.transformPrecision, e) : On(e), On = (e) => e.map(Math.round), kn = (e, t) => {
|
|
4207
|
+
for (let n = t.length, r = +(.1 ** e).toFixed(e); n--;) if (I(t[n], e) !== t[n]) {
|
|
4270
4208
|
let i = +t[n].toFixed(e - 1);
|
|
4271
4209
|
t[n] = +Math.abs(i - t[n]).toFixed(e + 1) >= r ? +t[n].toFixed(e) : i;
|
|
4272
4210
|
}
|
|
4273
4211
|
return t;
|
|
4274
|
-
},
|
|
4275
|
-
let n =
|
|
4212
|
+
}, An = (e, t) => e.map((e) => (wn(e, t), `${e.name}(${P(e.data, t)})`)).join(``), jn = /[-+]?(\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?/g, Mn = (e, t) => {
|
|
4213
|
+
let n = M(e);
|
|
4276
4214
|
return { element: { enter: (e) => {
|
|
4277
|
-
if (e.attributes.d == null || e.attributes.id != null || e.attributes.transform == null || e.attributes.transform === `` || e.attributes.style != null || Object.entries(e.attributes).some((
|
|
4278
|
-
let r =
|
|
4215
|
+
if (e.attributes.d == null || e.attributes.id != null || e.attributes.transform == null || e.attributes.transform === `` || e.attributes.style != null || Object.entries(e.attributes).some(([e, t]) => A.has(e) && $e(t))) return;
|
|
4216
|
+
let r = N(n, e), i = r.transform;
|
|
4279
4217
|
if (i.type === `static` && i.value !== e.attributes.transform) return;
|
|
4280
|
-
let a = dn(
|
|
4218
|
+
let a = fn(dn(e.attributes.transform)), o = r.stroke?.type === `static` ? r.stroke.value : null, s = r[`stroke-width`]?.type === `static` ? r[`stroke-width`].value : null, c = t.transformPrecision;
|
|
4281
4219
|
if (r.stroke?.type === `dynamic` || r[`stroke-width`]?.type === `dynamic`) return;
|
|
4282
4220
|
let l = Number(Math.hypot(a.data[0], a.data[1]).toFixed(c));
|
|
4283
4221
|
if (o && o != `none`) {
|
|
4284
4222
|
if (!t.applyTransformsStroked || (a.data[0] !== a.data[3] || a.data[1] !== -a.data[2]) && (a.data[0] !== -a.data[3] || a.data[1] !== a.data[2])) return;
|
|
4285
|
-
l !== 1 && e.attributes[`vector-effect`] !== `non-scaling-stroke` && (e.attributes[`stroke-width`] = (s ||
|
|
4223
|
+
l !== 1 && e.attributes[`vector-effect`] !== `non-scaling-stroke` && (e.attributes[`stroke-width`] = (s || he.presentation[`stroke-width`]).trim().replace(jn, (e) => F(Number(e) * l)), e.attributes[`stroke-dashoffset`] != null && (e.attributes[`stroke-dashoffset`] = e.attributes[`stroke-dashoffset`].trim().replace(jn, (e) => F(Number(e) * l))), e.attributes[`stroke-dasharray`] != null && (e.attributes[`stroke-dasharray`] = e.attributes[`stroke-dasharray`].trim().replace(jn, (e) => F(Number(e) * l))));
|
|
4286
4224
|
}
|
|
4287
|
-
let u =
|
|
4288
|
-
|
|
4225
|
+
let u = Xt(e);
|
|
4226
|
+
Nn(u, a.data), delete e.attributes.transform;
|
|
4289
4227
|
} } };
|
|
4290
|
-
},
|
|
4228
|
+
}, U = (e, t, n) => [e[0] * t + e[2] * n + e[4], e[1] * t + e[3] * n + e[5]], W = (e, t, n) => [e[0] * t + e[2] * n, e[1] * t + e[3] * n], Nn = (e, t) => {
|
|
4291
4229
|
let n = [0, 0], r = [0, 0];
|
|
4292
4230
|
for (let i of e) {
|
|
4293
4231
|
let { command: e, args: a } = i;
|
|
4294
4232
|
if (e === `M`) {
|
|
4295
4233
|
r[0] = a[0], r[1] = a[1], n[0] = r[0], n[1] = r[1];
|
|
4296
|
-
let [e, i] =
|
|
4234
|
+
let [e, i] = U(t, a[0], a[1]);
|
|
4297
4235
|
a[0] = e, a[1] = i;
|
|
4298
4236
|
}
|
|
4299
4237
|
if (e === `m`) {
|
|
4300
4238
|
r[0] += a[0], r[1] += a[1], n[0] = r[0], n[1] = r[1];
|
|
4301
|
-
let [e, i] =
|
|
4239
|
+
let [e, i] = W(t, a[0], a[1]);
|
|
4302
4240
|
a[0] = e, a[1] = i;
|
|
4303
4241
|
}
|
|
4304
4242
|
if (e === `H` && (e = `L`, a = [a[0], r[1]]), e === `h` && (e = `l`, a = [a[0], 0]), e === `V` && (e = `L`, a = [r[0], a[0]]), e === `v` && (e = `l`, a = [0, a[0]]), e === `L`) {
|
|
4305
4243
|
r[0] = a[0], r[1] = a[1];
|
|
4306
|
-
let [e, n] =
|
|
4244
|
+
let [e, n] = U(t, a[0], a[1]);
|
|
4307
4245
|
a[0] = e, a[1] = n;
|
|
4308
4246
|
}
|
|
4309
4247
|
if (e === `l`) {
|
|
4310
4248
|
r[0] += a[0], r[1] += a[1];
|
|
4311
|
-
let [e, n] =
|
|
4249
|
+
let [e, n] = W(t, a[0], a[1]);
|
|
4312
4250
|
a[0] = e, a[1] = n;
|
|
4313
4251
|
}
|
|
4314
4252
|
if (e === `C`) {
|
|
4315
4253
|
r[0] = a[4], r[1] = a[5];
|
|
4316
|
-
let [e, n] =
|
|
4254
|
+
let [e, n] = U(t, a[0], a[1]), [i, o] = U(t, a[2], a[3]), [s, c] = U(t, a[4], a[5]);
|
|
4317
4255
|
a[0] = e, a[1] = n, a[2] = i, a[3] = o, a[4] = s, a[5] = c;
|
|
4318
4256
|
}
|
|
4319
4257
|
if (e === `c`) {
|
|
4320
4258
|
r[0] += a[4], r[1] += a[5];
|
|
4321
|
-
let [e, n] =
|
|
4259
|
+
let [e, n] = W(t, a[0], a[1]), [i, o] = W(t, a[2], a[3]), [s, c] = W(t, a[4], a[5]);
|
|
4322
4260
|
a[0] = e, a[1] = n, a[2] = i, a[3] = o, a[4] = s, a[5] = c;
|
|
4323
4261
|
}
|
|
4324
4262
|
if (e === `S`) {
|
|
4325
4263
|
r[0] = a[2], r[1] = a[3];
|
|
4326
|
-
let [e, n] =
|
|
4264
|
+
let [e, n] = U(t, a[0], a[1]), [i, o] = U(t, a[2], a[3]);
|
|
4327
4265
|
a[0] = e, a[1] = n, a[2] = i, a[3] = o;
|
|
4328
4266
|
}
|
|
4329
4267
|
if (e === `s`) {
|
|
4330
4268
|
r[0] += a[2], r[1] += a[3];
|
|
4331
|
-
let [e, n] =
|
|
4269
|
+
let [e, n] = W(t, a[0], a[1]), [i, o] = W(t, a[2], a[3]);
|
|
4332
4270
|
a[0] = e, a[1] = n, a[2] = i, a[3] = o;
|
|
4333
4271
|
}
|
|
4334
4272
|
if (e === `Q`) {
|
|
4335
4273
|
r[0] = a[2], r[1] = a[3];
|
|
4336
|
-
let [e, n] =
|
|
4274
|
+
let [e, n] = U(t, a[0], a[1]), [i, o] = U(t, a[2], a[3]);
|
|
4337
4275
|
a[0] = e, a[1] = n, a[2] = i, a[3] = o;
|
|
4338
4276
|
}
|
|
4339
4277
|
if (e === `q`) {
|
|
4340
4278
|
r[0] += a[2], r[1] += a[3];
|
|
4341
|
-
let [e, n] =
|
|
4279
|
+
let [e, n] = W(t, a[0], a[1]), [i, o] = W(t, a[2], a[3]);
|
|
4342
4280
|
a[0] = e, a[1] = n, a[2] = i, a[3] = o;
|
|
4343
4281
|
}
|
|
4344
4282
|
if (e === `T`) {
|
|
4345
4283
|
r[0] = a[0], r[1] = a[1];
|
|
4346
|
-
let [e, n] =
|
|
4284
|
+
let [e, n] = U(t, a[0], a[1]);
|
|
4347
4285
|
a[0] = e, a[1] = n;
|
|
4348
4286
|
}
|
|
4349
4287
|
if (e === `t`) {
|
|
4350
4288
|
r[0] += a[0], r[1] += a[1];
|
|
4351
|
-
let [e, n] =
|
|
4289
|
+
let [e, n] = W(t, a[0], a[1]);
|
|
4352
4290
|
a[0] = e, a[1] = n;
|
|
4353
4291
|
}
|
|
4354
4292
|
if (e === `A`) {
|
|
4355
|
-
if (
|
|
4293
|
+
if (Sn(r, a, t), r[0] = a[5], r[1] = a[6], Math.abs(a[2]) > 80) {
|
|
4356
4294
|
let e = a[0], t = a[2];
|
|
4357
4295
|
a[0] = a[1], a[1] = e, a[2] = t + (t > 0 ? -90 : 90);
|
|
4358
4296
|
}
|
|
4359
|
-
let [e, n] =
|
|
4297
|
+
let [e, n] = U(t, a[5], a[6]);
|
|
4360
4298
|
a[5] = e, a[6] = n;
|
|
4361
4299
|
}
|
|
4362
4300
|
if (e === `a`) {
|
|
4363
|
-
if (
|
|
4301
|
+
if (Sn([0, 0], a, t), r[0] += a[5], r[1] += a[6], Math.abs(a[2]) > 80) {
|
|
4364
4302
|
let e = a[0], t = a[2];
|
|
4365
4303
|
a[0] = a[1], a[1] = e, a[2] = t + (t > 0 ? -90 : 90);
|
|
4366
4304
|
}
|
|
4367
|
-
let [e, n] =
|
|
4305
|
+
let [e, n] = W(t, a[5], a[6]);
|
|
4368
4306
|
a[5] = e, a[6] = n;
|
|
4369
4307
|
}
|
|
4370
4308
|
(e === `z` || e === `Z`) && (r[0] = n[0], r[1] = n[1]), i.command = e, i.args = a;
|
|
4371
4309
|
}
|
|
4372
|
-
},
|
|
4310
|
+
}, G, K, q, Pn, Fn, In = (e, t) => {
|
|
4373
4311
|
let { applyTransforms: n = !0, applyTransformsStroked: r = !0, makeArcs: i = {
|
|
4374
4312
|
threshold: 2.5,
|
|
4375
4313
|
tolerance: .5
|
|
@@ -4393,30 +4331,30 @@ var l = e(((e) => {
|
|
|
4393
4331
|
noSpaceAfterFlags: v,
|
|
4394
4332
|
forceAbsolutePath: y
|
|
4395
4333
|
};
|
|
4396
|
-
n &&
|
|
4334
|
+
n && x(e, Mn(e, {
|
|
4397
4335
|
transformPrecision: d,
|
|
4398
4336
|
applyTransformsStroked: r
|
|
4399
4337
|
}));
|
|
4400
|
-
let
|
|
4338
|
+
let S = M(e);
|
|
4401
4339
|
return { element: { enter: (e) => {
|
|
4402
|
-
if (
|
|
4403
|
-
let t =
|
|
4404
|
-
|
|
4405
|
-
let n = t[`marker-mid`] != null, r = t.stroke && (t.stroke.type === `dynamic` || t.stroke.value !== `none`), a = t[`stroke-linecap`] && (t[`stroke-linecap`].type === `dynamic` || t[`stroke-linecap`].value !== `butt`), o = !r || t[`stroke-linecap`]?.type === `static` && t[`stroke-linecap`].value === `round` && t[`stroke-linejoin`]?.type === `static` && t[`stroke-linejoin`].value === `round`, s = (e, t) => r ? e ? !a : t : !0, c =
|
|
4340
|
+
if (me.has(e.name) && e.attributes.d != null) {
|
|
4341
|
+
let t = N(S, e);
|
|
4342
|
+
K = u, q = K === !1 ? .01 : +(.1 ** K).toFixed(K), G = K && K > 0 && K < 20 ? Hn : Un, i && (Pn = i.threshold, Fn = i.tolerance);
|
|
4343
|
+
let n = t[`marker-mid`] != null, r = t.stroke && (t.stroke.type === `dynamic` || t.stroke.value !== `none`), a = t[`stroke-linecap`] && (t[`stroke-linecap`].type === `dynamic` || t[`stroke-linecap`].value !== `butt`), o = !r || t[`stroke-linecap`]?.type === `static` && t[`stroke-linecap`].value === `round` && t[`stroke-linejoin`]?.type === `static` && t[`stroke-linejoin`].value === `round`, s = (e, t) => r ? e ? !a : t : !0, c = Xt(e);
|
|
4406
4344
|
if (c.length) {
|
|
4407
|
-
let t = c.some((
|
|
4408
|
-
|
|
4345
|
+
let t = c.some((e) => e.command !== `m` && e.command !== `M`);
|
|
4346
|
+
Ln(c), c = Rn(c, b, {
|
|
4409
4347
|
isSafeToUseZ: o,
|
|
4410
4348
|
isSafeToRemove: s,
|
|
4411
4349
|
hasMarkerMid: n
|
|
4412
|
-
}), h && (c =
|
|
4350
|
+
}), h && (c = zn(c, b)), (e.attributes[`marker-start`] != null || e.attributes[`marker-end`] != null) && t && c.every((e) => e.command === `m` || e.command === `M`) && c.push({
|
|
4413
4351
|
command: `z`,
|
|
4414
4352
|
args: []
|
|
4415
|
-
}),
|
|
4353
|
+
}), Qt(e, c, b);
|
|
4416
4354
|
}
|
|
4417
4355
|
}
|
|
4418
4356
|
} } };
|
|
4419
|
-
},
|
|
4357
|
+
}, Ln = (e) => {
|
|
4420
4358
|
let t = [0, 0], n = [0, 0], r = [0, 0];
|
|
4421
4359
|
for (let i = 0; i < e.length; i += 1) {
|
|
4422
4360
|
let a = e[i], { command: o, args: s } = a;
|
|
@@ -4424,9 +4362,9 @@ var l = e(((e) => {
|
|
|
4424
4362
|
}
|
|
4425
4363
|
return e;
|
|
4426
4364
|
};
|
|
4427
|
-
function
|
|
4428
|
-
let a =
|
|
4429
|
-
return e = e.filter(
|
|
4365
|
+
function Rn(e, t, { isSafeToUseZ: n, isSafeToRemove: r, hasMarkerMid: i }) {
|
|
4366
|
+
let a = $n.bind(null, t), o = [0, 0], s = [0, 0], c = {}, l;
|
|
4367
|
+
return e = e.filter(function(e, u, d) {
|
|
4430
4368
|
let f = l, p = e.command, m = e.args, h = d[u + 1];
|
|
4431
4369
|
if (p !== `Z` && p !== `z`) {
|
|
4432
4370
|
let l = m, _;
|
|
@@ -4435,8 +4373,8 @@ var l = e(((e) => {
|
|
|
4435
4373
|
let e = c.args, t = e.length;
|
|
4436
4374
|
l[0] = e[t - 2] - e[t - 4], l[1] = e[t - 1] - e[t - 3];
|
|
4437
4375
|
}
|
|
4438
|
-
if (t.makeArcs && (p == `c` || p == `s`) &&
|
|
4439
|
-
let t =
|
|
4376
|
+
if (t.makeArcs && (p == `c` || p == `s`) && Bn(l) && (_ = Yn(l))) {
|
|
4377
|
+
let t = G([_.radius])[0], n = Qn(l, _), r = +(l[5] * l[0] - l[4] * l[1] > 0), i = {
|
|
4440
4378
|
command: `a`,
|
|
4441
4379
|
args: [
|
|
4442
4380
|
t,
|
|
@@ -4453,9 +4391,9 @@ var l = e(((e) => {
|
|
|
4453
4391
|
center: f,
|
|
4454
4392
|
radius: _.radius
|
|
4455
4393
|
}, y = [e], b = 0, x = ``, S;
|
|
4456
|
-
if (c.command == `c` &&
|
|
4394
|
+
if (c.command == `c` && Bn(c.args) && Zn(c.args, _) || c.command == `a` && c.sdata && Zn(c.sdata, _)) {
|
|
4457
4395
|
y.unshift(c), i.base = c.base, i.args[5] = i.coords[0] - i.base[0], i.args[6] = i.coords[1] - i.base[1];
|
|
4458
|
-
let e = c.command == `a` ? c.sdata : c.args, t =
|
|
4396
|
+
let e = c.command == `a` ? c.sdata : c.args, t = Qn(e, {
|
|
4459
4397
|
center: [e[4] + _.center[0], e[5] + _.center[1]],
|
|
4460
4398
|
radius: _.radius
|
|
4461
4399
|
});
|
|
@@ -4463,10 +4401,10 @@ var l = e(((e) => {
|
|
|
4463
4401
|
}
|
|
4464
4402
|
for (var g = u; (h = d[++g]) && (h.command === `c` || h.command === `s`);) {
|
|
4465
4403
|
let e = h.args;
|
|
4466
|
-
if (h.command == `s` && (S =
|
|
4404
|
+
if (h.command == `s` && (S = J({
|
|
4467
4405
|
command: `s`,
|
|
4468
4406
|
args: h.args.slice()
|
|
4469
|
-
}, d[g - 1].args), e = S.args, S.args = e.slice(0, 2), x = a([S])), !
|
|
4407
|
+
}, d[g - 1].args), e = S.args, S.args = e.slice(0, 2), x = a([S])), !Bn(e) || !Xn(e, v) || (n += Qn(e, v), n - 2 * Math.PI > .001)) break;
|
|
4470
4408
|
if (n > Math.PI && (i.args[3] = 1), y.push(h), !(2 * Math.PI - n > .001)) {
|
|
4471
4409
|
i.args[5] = 2 * (v.center[0] - e[4]), i.args[6] = 2 * (v.center[1] - e[5]), i.coords = [i.base[0] + i.args[5], i.base[1] + i.args[6]], i = {
|
|
4472
4410
|
command: `a`,
|
|
@@ -4487,75 +4425,75 @@ var l = e(((e) => {
|
|
|
4487
4425
|
i.coords = h.coords, i.args[5] = i.coords[0] - i.base[0], i.args[6] = i.coords[1] - i.base[1], f[0] -= e[4], f[1] -= e[5];
|
|
4488
4426
|
}
|
|
4489
4427
|
if ((a(s) + x).length < a(y).length) {
|
|
4490
|
-
if (d[g] && d[g].command == `s` &&
|
|
4428
|
+
if (d[g] && d[g].command == `s` && J(d[g], d[g - 1].args), b) {
|
|
4491
4429
|
let t = s.shift();
|
|
4492
|
-
|
|
4430
|
+
G(t.args), o[0] += t.args[5] - c.args[c.args.length - 2], o[1] += t.args[6] - c.args[c.args.length - 1], c.command = `a`, c.args = t.args, e.base = c.coords = t.coords;
|
|
4493
4431
|
}
|
|
4494
4432
|
if (i = s.shift(), y.length == 1 ? e.sdata = l.slice() : y.length - 1 - b > 0 && d.splice(u + 1, y.length - 1 - b, ...s), !i) return !1;
|
|
4495
4433
|
p = `a`, m = i.args, e.coords = i.coords;
|
|
4496
4434
|
}
|
|
4497
4435
|
}
|
|
4498
|
-
if (
|
|
4436
|
+
if (K !== !1) {
|
|
4499
4437
|
if (p === `m` || p === `l` || p === `t` || p === `q` || p === `s` || p === `c`) for (let t = m.length; t--;) m[t] += e.base[t % 2] - o[t % 2];
|
|
4500
4438
|
else p == `h` ? m[0] += e.base[0] - o[0] : p == `v` ? m[0] += e.base[1] - o[1] : p == `a` && (m[5] += e.base[0] - o[0], m[6] += e.base[1] - o[1]);
|
|
4501
|
-
|
|
4439
|
+
G(m), p == `h` ? o[0] += m[0] : p == `v` ? o[1] += m[0] : (o[0] += m[m.length - 2], o[1] += m[m.length - 1]), G(o), (p === `M` || p === `m`) && (s[0] = o[0], s[1] = o[1]);
|
|
4502
4440
|
}
|
|
4503
|
-
let v = p === `a` ?
|
|
4504
|
-
if (t.smartArcRounding && v !== void 0 &&
|
|
4505
|
-
let t =
|
|
4441
|
+
let v = p === `a` ? Gn(m) : void 0;
|
|
4442
|
+
if (t.smartArcRounding && v !== void 0 && K) for (let e = K; e >= 0; e--) {
|
|
4443
|
+
let t = I(m[0], e), n = Gn([
|
|
4506
4444
|
t,
|
|
4507
4445
|
t,
|
|
4508
4446
|
...m.slice(2)
|
|
4509
4447
|
]);
|
|
4510
|
-
if (!(Math.abs(v - n) <
|
|
4448
|
+
if (!(Math.abs(v - n) < q)) break;
|
|
4511
4449
|
m[0] = t, m[1] = t;
|
|
4512
4450
|
}
|
|
4513
|
-
if (t.straightCurves && (p === `c` &&
|
|
4451
|
+
if (t.straightCurves && (p === `c` && Wn(m) || p === `s` && Wn(l) ? (h && h.command == `s` && J(h, m), p = `l`, m = m.slice(-2)) : p === `q` && Wn(m) || p === `t` && c.command !== `q` && c.command !== `t` ? (p == `q` && h && h.command == `t` && J(h, m), p == `t` && h && h.command == `t` && (h.command = `q`, h.args.unshift(2 * e.coords[0] - e.base[0] - e.coords[0], 2 * e.coords[1] - e.base[1] - e.coords[1])), p = `l`, m = m.slice(-2)) : p === `a` && (m[0] === 0 || m[1] === 0 || v !== void 0 && v < q) && (p = `l`, m = m.slice(-2))), t.convertToQ && p == `c`) {
|
|
4514
4452
|
let n = .75 * (e.base[0] + m[0]) - .25 * e.base[0], r = .75 * (e.base[0] + m[2]) - .25 * (e.base[0] + m[4]);
|
|
4515
|
-
if (Math.abs(n - r) <
|
|
4453
|
+
if (Math.abs(n - r) < q * 2) {
|
|
4516
4454
|
let i = .75 * (e.base[1] + m[1]) - .25 * e.base[1], a = .75 * (e.base[1] + m[3]) - .25 * (e.base[1] + m[5]);
|
|
4517
|
-
if (Math.abs(i - a) <
|
|
4455
|
+
if (Math.abs(i - a) < q * 2) {
|
|
4518
4456
|
let o = m.slice();
|
|
4519
|
-
o.splice(0, 4, n + r - e.base[0], i + a - e.base[1]),
|
|
4520
|
-
let s =
|
|
4521
|
-
|
|
4457
|
+
o.splice(0, 4, n + r - e.base[0], i + a - e.base[1]), G(o);
|
|
4458
|
+
let s = P(m, t).length;
|
|
4459
|
+
P(o, t).length < s && (p = `q`, m = o, h && h.command == `s` && J(h, m));
|
|
4522
4460
|
}
|
|
4523
4461
|
}
|
|
4524
4462
|
}
|
|
4525
4463
|
if (t.lineShorthands && p === `l` && (m[1] === 0 ? (p = `h`, m.pop()) : m[0] === 0 && (p = `v`, m.shift())), t.collapseRepeated && i === !1 && (p === `m` || p === `h` || p === `v`) && c.command && p == c.command.toLowerCase() && (p != `h` && p != `v` || c.args[0] >= 0 == m[0] >= 0)) return c.args[0] += m[0], p != `h` && p != `v` && (c.args[1] += m[1]), c.coords = e.coords, d[u] = c, !1;
|
|
4526
4464
|
if (t.curveSmoothShorthands && c.command) {
|
|
4527
|
-
if (p === `c`) (c.command === `c` && Math.abs(m[0] - -(c.args[2] - c.args[4])) <
|
|
4465
|
+
if (p === `c`) (c.command === `c` && Math.abs(m[0] - -(c.args[2] - c.args[4])) < q && Math.abs(m[1] - -(c.args[3] - c.args[5])) < q || c.command === `s` && Math.abs(m[0] - -(c.args[0] - c.args[2])) < q && Math.abs(m[1] - -(c.args[1] - c.args[3])) < q || c.command !== `c` && c.command !== `s` && Math.abs(m[0]) < q && Math.abs(m[1]) < q) && (p = `s`, m = m.slice(2));
|
|
4528
4466
|
else if (p === `q`) {
|
|
4529
|
-
if (c.command === `q` && Math.abs(m[0] - (c.args[2] - c.args[0])) <
|
|
4467
|
+
if (c.command === `q` && Math.abs(m[0] - (c.args[2] - c.args[0])) < q && Math.abs(m[1] - (c.args[3] - c.args[1])) < q) p = `t`, m = m.slice(2);
|
|
4530
4468
|
else if (c.command === `t`) {
|
|
4531
|
-
let t =
|
|
4532
|
-
Math.abs(t[0] - n[0]) <
|
|
4469
|
+
let t = qn(f, e.base), n = [m[0] + e.base[0], m[1] + e.base[1]];
|
|
4470
|
+
Math.abs(t[0] - n[0]) < q && Math.abs(t[1] - n[1]) < q && (p = `t`, m = m.slice(2));
|
|
4533
4471
|
}
|
|
4534
4472
|
}
|
|
4535
4473
|
}
|
|
4536
|
-
if (t.removeUseless && r(c.command == `m` || c.command == `M`, !0) && ((p === `l` || p === `h` || p === `v` || p === `q` || p === `t` || p === `c` || p === `s`) && m.every(
|
|
4474
|
+
if (t.removeUseless && r(c.command == `m` || c.command == `M`, !0) && ((p === `l` || p === `h` || p === `v` || p === `q` || p === `t` || p === `c` || p === `s`) && m.every(function(e) {
|
|
4537
4475
|
return e === 0;
|
|
4538
|
-
})
|
|
4539
|
-
t.convertToZ && (n || h?.command === `Z` || h?.command === `z`) && (p === `l` || p === `h` || p === `v`) && Math.abs(s[0] - e.coords[0]) <
|
|
4476
|
+
}) || p === `a` && m[5] === 0 && m[6] === 0)) return d[u] = c, !1;
|
|
4477
|
+
t.convertToZ && (n || h?.command === `Z` || h?.command === `z`) && (p === `l` || p === `h` || p === `v`) && Math.abs(s[0] - e.coords[0]) < q && Math.abs(s[1] - e.coords[1]) < q && (p = `z`, m = []), e.command = p, e.args = m;
|
|
4540
4478
|
} else if (o[0] = s[0], o[1] = s[1], c.command === `Z` || c.command === `z`) return !1;
|
|
4541
|
-
return (p === `Z` || p === `z`) && t.removeUseless && r(c.command == `m` || c.command == `M`, n) && Math.abs(e.base[0] - e.coords[0]) <
|
|
4542
|
-
})
|
|
4479
|
+
return (p === `Z` || p === `z`) && t.removeUseless && r(c.command == `m` || c.command == `M`, n) && Math.abs(e.base[0] - e.coords[0]) < q / 10 && Math.abs(e.base[1] - e.coords[1]) < q / 10 ? !1 : (l = p === `q` ? [m[0] + e.base[0], m[1] + e.base[1]] : p === `t` ? f ? qn(f, e.base) : e.coords : void 0, c = e, !0);
|
|
4480
|
+
}), e;
|
|
4543
4481
|
}
|
|
4544
|
-
function
|
|
4482
|
+
function zn(e, t) {
|
|
4545
4483
|
let n = e[0];
|
|
4546
|
-
return e = e.filter(
|
|
4484
|
+
return e = e.filter(function(e, r) {
|
|
4547
4485
|
if (r == 0) return !0;
|
|
4548
4486
|
if (e.command === `Z` || e.command === `z`) return n = e, !0;
|
|
4549
4487
|
let i = e.command, a = e.args, o = a.slice(), s = a.slice();
|
|
4550
4488
|
if (i === `m` || i === `l` || i === `t` || i === `q` || i === `s` || i === `c`) for (let t = o.length; t--;) o[t] += e.base[t % 2];
|
|
4551
4489
|
else i == `h` ? o[0] += e.base[0] : i == `v` ? o[0] += e.base[1] : i == `a` && (o[5] += e.base[0], o[6] += e.base[1]);
|
|
4552
|
-
|
|
4553
|
-
let c =
|
|
4490
|
+
G(o), G(s);
|
|
4491
|
+
let c = P(o, t), l = P(s, t);
|
|
4554
4492
|
return (t.forceAbsolutePath || c.length < l.length && !(t.negativeExtraSpace && i == n.command && n.command.charCodeAt(0) > 96 && c.length == l.length - 1 && (a[0] < 0 || Math.floor(a[0]) === 0 && !Number.isInteger(a[0]) && n.args[n.args.length - 1] % 1))) && (e.command = i.toUpperCase(), e.args = o), n = e, !0;
|
|
4555
|
-
})
|
|
4493
|
+
}), e;
|
|
4556
4494
|
}
|
|
4557
|
-
function
|
|
4558
|
-
let t =
|
|
4495
|
+
function Bn(e) {
|
|
4496
|
+
let t = Vn([
|
|
4559
4497
|
0,
|
|
4560
4498
|
0,
|
|
4561
4499
|
e[2],
|
|
@@ -4567,41 +4505,41 @@ var l = e(((e) => {
|
|
|
4567
4505
|
]);
|
|
4568
4506
|
return t != null && e[2] < t[0] == t[0] < 0 && e[3] < t[1] == t[1] < 0 && e[4] < t[0] == t[0] < e[0] && e[5] < t[1] == t[1] < e[1];
|
|
4569
4507
|
}
|
|
4570
|
-
function
|
|
4508
|
+
function Vn(e) {
|
|
4571
4509
|
let t = e[1] - e[3], n = e[2] - e[0], r = e[0] * e[3] - e[2] * e[1], i = e[5] - e[7], a = e[6] - e[4], o = e[4] * e[7] - e[5] * e[6], s = t * a - i * n;
|
|
4572
4510
|
if (!s) return;
|
|
4573
4511
|
let c = [(n * o - a * r) / s, (t * o - i * r) / -s];
|
|
4574
4512
|
if (!isNaN(c[0]) && !isNaN(c[1]) && isFinite(c[0]) && isFinite(c[1])) return c;
|
|
4575
4513
|
}
|
|
4576
|
-
function
|
|
4577
|
-
let t =
|
|
4514
|
+
function Hn(e) {
|
|
4515
|
+
let t = K || 0;
|
|
4578
4516
|
for (let n = e.length; n-- > 0;) {
|
|
4579
|
-
let r =
|
|
4517
|
+
let r = I(e[n], t);
|
|
4580
4518
|
if (r !== e[n]) {
|
|
4581
|
-
let i =
|
|
4582
|
-
e[n] =
|
|
4519
|
+
let i = I(e[n], t - 1);
|
|
4520
|
+
e[n] = I(Math.abs(i - e[n]), t + 1) >= q ? r : i;
|
|
4583
4521
|
}
|
|
4584
4522
|
}
|
|
4585
4523
|
return e;
|
|
4586
4524
|
}
|
|
4587
|
-
function
|
|
4525
|
+
function Un(e) {
|
|
4588
4526
|
for (let t = e.length; t-- > 0;) e[t] = Math.round(e[t]);
|
|
4589
4527
|
return e;
|
|
4590
4528
|
}
|
|
4591
|
-
function
|
|
4529
|
+
function Wn(e) {
|
|
4592
4530
|
let t = e.length - 2, n = -e[t + 1], r = e[t], i = 1 / (n * n + r * r);
|
|
4593
4531
|
if (t <= 1 || !isFinite(i)) return !1;
|
|
4594
|
-
for (; (t -= 2) >= 0;) if (Math.sqrt((n * e[t] + r * e[t + 1]) ** 2 * i) >
|
|
4532
|
+
for (; (t -= 2) >= 0;) if (Math.sqrt((n * e[t] + r * e[t + 1]) ** 2 * i) > q) return !1;
|
|
4595
4533
|
return !0;
|
|
4596
4534
|
}
|
|
4597
|
-
function
|
|
4535
|
+
function Gn(e) {
|
|
4598
4536
|
if (e[3] === 1) return;
|
|
4599
4537
|
let [t, n] = e;
|
|
4600
|
-
if (Math.abs(t - n) >
|
|
4538
|
+
if (Math.abs(t - n) > q) return;
|
|
4601
4539
|
let r = Math.hypot(e[5], e[6]);
|
|
4602
4540
|
if (!(r > t * 2)) return t - Math.sqrt(t ** 2 - .25 * r ** 2);
|
|
4603
4541
|
}
|
|
4604
|
-
function
|
|
4542
|
+
function J(e, t) {
|
|
4605
4543
|
switch (e.command) {
|
|
4606
4544
|
case `s`:
|
|
4607
4545
|
e.command = `c`;
|
|
@@ -4610,18 +4548,18 @@ var l = e(((e) => {
|
|
|
4610
4548
|
}
|
|
4611
4549
|
return e.args.unshift(t[t.length - 2] - t[t.length - 4], t[t.length - 1] - t[t.length - 3]), e;
|
|
4612
4550
|
}
|
|
4613
|
-
function
|
|
4551
|
+
function Kn(e, t) {
|
|
4614
4552
|
return Math.hypot(e[0] - t[0], e[1] - t[1]);
|
|
4615
4553
|
}
|
|
4616
|
-
function
|
|
4554
|
+
function qn(e, t) {
|
|
4617
4555
|
return [2 * t[0] - e[0], 2 * t[1] - e[1]];
|
|
4618
4556
|
}
|
|
4619
|
-
function
|
|
4557
|
+
function Jn(e, t) {
|
|
4620
4558
|
let n = t * t, r = n * t, i = 1 - t, a = i * i;
|
|
4621
4559
|
return [3 * a * t * e[0] + 3 * i * n * e[2] + r * e[4], 3 * a * t * e[1] + 3 * i * n * e[3] + r * e[5]];
|
|
4622
4560
|
}
|
|
4623
|
-
function
|
|
4624
|
-
let t =
|
|
4561
|
+
function Yn(e) {
|
|
4562
|
+
let t = Jn(e, .5), n = [t[0] / 2, t[1] / 2], r = [(t[0] + e[4]) / 2, (t[1] + e[5]) / 2], i = Vn([
|
|
4625
4563
|
n[0],
|
|
4626
4564
|
n[1],
|
|
4627
4565
|
n[0] + n[1],
|
|
@@ -4630,49 +4568,49 @@ var l = e(((e) => {
|
|
|
4630
4568
|
r[1],
|
|
4631
4569
|
r[0] + (r[1] - t[1]),
|
|
4632
4570
|
r[1] - (r[0] - t[0])
|
|
4633
|
-
]), a = i &&
|
|
4634
|
-
if (i && a < 0x38d7ea4c68000 && [1 / 4, 3 / 4].every(
|
|
4635
|
-
return Math.abs(
|
|
4636
|
-
}))
|
|
4571
|
+
]), a = i && Kn([0, 0], i), o = Math.min(Pn * q, Fn * a / 100);
|
|
4572
|
+
if (i && a < 0x38d7ea4c68000 && [1 / 4, 3 / 4].every(function(t) {
|
|
4573
|
+
return Math.abs(Kn(Jn(e, t), i) - a) <= o;
|
|
4574
|
+
})) return {
|
|
4637
4575
|
center: i,
|
|
4638
4576
|
radius: a
|
|
4639
4577
|
};
|
|
4640
4578
|
}
|
|
4641
|
-
function
|
|
4642
|
-
let n = Math.min(
|
|
4579
|
+
function Xn(e, t) {
|
|
4580
|
+
let n = Math.min(Pn * q, Fn * t.radius / 100);
|
|
4643
4581
|
return [
|
|
4644
4582
|
0,
|
|
4645
4583
|
1 / 4,
|
|
4646
4584
|
.5,
|
|
4647
4585
|
3 / 4,
|
|
4648
4586
|
1
|
|
4649
|
-
].every(
|
|
4650
|
-
return Math.abs(
|
|
4651
|
-
})
|
|
4587
|
+
].every(function(r) {
|
|
4588
|
+
return Math.abs(Kn(Jn(e, r), t.center) - t.radius) <= n;
|
|
4589
|
+
});
|
|
4652
4590
|
}
|
|
4653
|
-
function
|
|
4654
|
-
return
|
|
4591
|
+
function Zn(e, t) {
|
|
4592
|
+
return Xn(e, {
|
|
4655
4593
|
center: [t.center[0] + e[4], t.center[1] + e[5]],
|
|
4656
4594
|
radius: t.radius
|
|
4657
4595
|
});
|
|
4658
4596
|
}
|
|
4659
|
-
function
|
|
4597
|
+
function Qn(e, t) {
|
|
4660
4598
|
let n = -t.center[0], r = -t.center[1], i = e[4] - t.center[0], a = e[5] - t.center[1];
|
|
4661
4599
|
return Math.acos((n * i + r * a) / Math.sqrt((n * n + r * r) * (i * i + a * a)));
|
|
4662
4600
|
}
|
|
4663
|
-
function
|
|
4664
|
-
return t.reduce(
|
|
4601
|
+
function $n(e, t) {
|
|
4602
|
+
return t.reduce(function(t, n) {
|
|
4665
4603
|
let r = ``;
|
|
4666
|
-
return n.args && (r =
|
|
4667
|
-
}
|
|
4604
|
+
return n.args && (r = P(G(n.args.slice()), e)), t + n.command + r;
|
|
4605
|
+
}, ``);
|
|
4668
4606
|
}
|
|
4669
|
-
var
|
|
4607
|
+
var er = Object.freeze({
|
|
4670
4608
|
__proto__: null,
|
|
4671
4609
|
description: `optimizes path data: writes in shorter form, applies transformations`,
|
|
4672
|
-
fn:
|
|
4610
|
+
fn: In,
|
|
4673
4611
|
name: `convertPathData`
|
|
4674
4612
|
});
|
|
4675
|
-
let
|
|
4613
|
+
let tr = (e, t) => {
|
|
4676
4614
|
let { convertToShorts: n = !0, degPrecision: r, floatPrecision: i = 3, transformPrecision: a = 5, matrixToTransform: o = !0, shortTranslate: s = !0, shortScale: c = !0, shortRotate: l = !0, removeUseless: u = !0, collapseIntoOne: d = !0, leadingZero: f = !0, negativeExtraSpace: p = !1 } = t, m = {
|
|
4677
4615
|
convertToShorts: n,
|
|
4678
4616
|
degPrecision: r,
|
|
@@ -4688,27 +4626,27 @@ var l = e(((e) => {
|
|
|
4688
4626
|
negativeExtraSpace: p
|
|
4689
4627
|
};
|
|
4690
4628
|
return { element: { enter: (e) => {
|
|
4691
|
-
e.attributes.transform != null &&
|
|
4629
|
+
e.attributes.transform != null && nr(e, `transform`, m), e.attributes.gradientTransform != null && nr(e, `gradientTransform`, m), e.attributes.patternTransform != null && nr(e, `patternTransform`, m);
|
|
4692
4630
|
} } };
|
|
4693
|
-
},
|
|
4694
|
-
let r =
|
|
4695
|
-
n =
|
|
4696
|
-
},
|
|
4631
|
+
}, nr = (e, t, n) => {
|
|
4632
|
+
let r = dn(e.attributes[t]);
|
|
4633
|
+
n = rr(r, n), n.collapseIntoOne && r.length > 1 && (r = [fn(r)]), n.convertToShorts ? r = ar(r, n) : r.forEach((e) => wn(e, n)), n.removeUseless && (r = or(r)), r.length ? e.attributes[t] = An(r, n) : delete e.attributes[t];
|
|
4634
|
+
}, rr = (e, { ...t }) => {
|
|
4697
4635
|
let n = [];
|
|
4698
4636
|
for (let t of e) t.name == `matrix` && n.push(...t.data.slice(0, 4));
|
|
4699
4637
|
let r = t.transformPrecision;
|
|
4700
|
-
return n.length && (t.transformPrecision = Math.min(t.transformPrecision, Math.max.apply(Math, n.map(
|
|
4701
|
-
},
|
|
4638
|
+
return n.length && (t.transformPrecision = Math.min(t.transformPrecision, Math.max.apply(Math, n.map(ir)) || t.transformPrecision), r = Math.max.apply(Math, n.map((e) => e.toString().replace(/\D+/g, ``).length))), t.degPrecision ??= Math.max(0, Math.min(t.floatPrecision, r - 2)), t;
|
|
4639
|
+
}, ir = (e) => {
|
|
4702
4640
|
let t = e.toString();
|
|
4703
4641
|
return t.slice(t.indexOf(`.`)).length - 1;
|
|
4704
|
-
},
|
|
4642
|
+
}, ar = (e, t) => {
|
|
4705
4643
|
for (let n = 0; n < e.length; n++) {
|
|
4706
4644
|
let r = e[n];
|
|
4707
4645
|
if (t.matrixToTransform && r.name === `matrix`) {
|
|
4708
|
-
let i =
|
|
4709
|
-
|
|
4646
|
+
let i = bn(r, t);
|
|
4647
|
+
An(i, t).length <= An([r], t).length && e.splice(n, 1, ...i), r = e[n];
|
|
4710
4648
|
}
|
|
4711
|
-
|
|
4649
|
+
wn(r, t), t.shortTranslate && r.name === `translate` && r.data.length === 2 && !r.data[1] && r.data.pop(), t.shortScale && r.name === `scale` && r.data.length === 2 && r.data[0] === r.data[1] && r.data.pop(), t.shortRotate && e[n - 2]?.name === `translate` && e[n - 1].name === `rotate` && e[n].name === `translate` && e[n - 2].data[0] === -e[n].data[0] && e[n - 2].data[1] === -e[n].data[1] && (e.splice(n - 2, 3, {
|
|
4712
4650
|
name: `rotate`,
|
|
4713
4651
|
data: [
|
|
4714
4652
|
e[n - 1].data[0],
|
|
@@ -4718,34 +4656,34 @@ var l = e(((e) => {
|
|
|
4718
4656
|
}), n -= 2);
|
|
4719
4657
|
}
|
|
4720
4658
|
return e;
|
|
4721
|
-
},
|
|
4659
|
+
}, or = (e) => e.filter((e) => !([
|
|
4722
4660
|
`translate`,
|
|
4723
4661
|
`rotate`,
|
|
4724
4662
|
`skewX`,
|
|
4725
4663
|
`skewY`
|
|
4726
|
-
].indexOf(e.name) > -1 && (e.data.length == 1 || e.name == `rotate`) && !e.data[0] || e.name == `translate` && !e.data[0] && !e.data[1] || e.name == `scale` && e.data[0] == 1 && (e.data.length < 2 || e.data[1] == 1) || e.name == `matrix` && e.data[0] == 1 && e.data[3] == 1 && !(e.data[1] || e.data[2] || e.data[4] || e.data[5])))
|
|
4727
|
-
var
|
|
4664
|
+
].indexOf(e.name) > -1 && (e.data.length == 1 || e.name == `rotate`) && !e.data[0] || e.name == `translate` && !e.data[0] && !e.data[1] || e.name == `scale` && e.data[0] == 1 && (e.data.length < 2 || e.data[1] == 1) || e.name == `matrix` && e.data[0] == 1 && e.data[3] == 1 && !(e.data[1] || e.data[2] || e.data[4] || e.data[5])));
|
|
4665
|
+
var sr = Object.freeze({
|
|
4728
4666
|
__proto__: null,
|
|
4729
4667
|
description: `collapses multiple transformations and optimizes it`,
|
|
4730
|
-
fn:
|
|
4668
|
+
fn: tr,
|
|
4731
4669
|
name: `convertTransform`
|
|
4732
|
-
}),
|
|
4670
|
+
}), cr = Object.freeze({
|
|
4733
4671
|
__proto__: null,
|
|
4734
4672
|
description: `removes empty attributes`,
|
|
4735
4673
|
fn: () => ({ element: { enter: (e) => {
|
|
4736
|
-
for (let [t, n] of Object.entries(e.attributes)) n !== `` ||
|
|
4674
|
+
for (let [t, n] of Object.entries(e.attributes)) n !== `` || k.conditionalProcessing.has(t) || delete e.attributes[t];
|
|
4737
4675
|
} } }),
|
|
4738
4676
|
name: `removeEmptyAttrs`
|
|
4739
|
-
}),
|
|
4677
|
+
}), lr = Object.freeze({
|
|
4740
4678
|
__proto__: null,
|
|
4741
4679
|
description: `removes empty container elements`,
|
|
4742
4680
|
fn: (e) => {
|
|
4743
|
-
let t =
|
|
4681
|
+
let t = M(e), n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Map();
|
|
4744
4682
|
return {
|
|
4745
4683
|
element: {
|
|
4746
4684
|
enter: (e, t) => {
|
|
4747
4685
|
if (e.name === `use`) for (let [n, i] of Object.entries(e.attributes)) {
|
|
4748
|
-
let a =
|
|
4686
|
+
let a = tt(n, i);
|
|
4749
4687
|
for (let n of a) {
|
|
4750
4688
|
let i = r.get(n);
|
|
4751
4689
|
i === void 0 && (i = [], r.set(n, i)), i.push({
|
|
@@ -4756,32 +4694,32 @@ var l = e(((e) => {
|
|
|
4756
4694
|
}
|
|
4757
4695
|
},
|
|
4758
4696
|
exit: (e, r) => {
|
|
4759
|
-
e.name
|
|
4697
|
+
e.name !== `svg` && O.container.has(e.name) && e.children.length === 0 && (e.name !== `pattern` || Object.keys(e.attributes).length === 0) && (e.name !== `mask` || e.attributes.id == null) && (r.type !== `element` || r.name !== `switch`) && (e.name !== `g` || e.attributes.filter == null && !N(t, e).filter) && (D(e, r), e.attributes.id && n.add(e.attributes.id));
|
|
4760
4698
|
}
|
|
4761
4699
|
},
|
|
4762
4700
|
root: { exit: () => {
|
|
4763
4701
|
for (let e of n) {
|
|
4764
4702
|
let t = r.get(e);
|
|
4765
|
-
if (t) for (let e of t)
|
|
4703
|
+
if (t) for (let e of t) D(e.node, e.parent);
|
|
4766
4704
|
}
|
|
4767
4705
|
} }
|
|
4768
4706
|
};
|
|
4769
4707
|
},
|
|
4770
4708
|
name: `removeEmptyContainers`
|
|
4771
4709
|
});
|
|
4772
|
-
function
|
|
4710
|
+
function ur(e, t) {
|
|
4773
4711
|
let n = e[t];
|
|
4774
|
-
return n?.type === `static` &&
|
|
4712
|
+
return n?.type === `static` && $e(n.value);
|
|
4775
4713
|
}
|
|
4776
|
-
var
|
|
4714
|
+
var dr = Object.freeze({
|
|
4777
4715
|
__proto__: null,
|
|
4778
4716
|
description: `merges multiple paths in one if possible`,
|
|
4779
4717
|
fn: (e, t) => {
|
|
4780
|
-
let { force: n = !1, floatPrecision: r = 3, noSpaceAfterFlags: i = !1 } = t, a =
|
|
4718
|
+
let { force: n = !1, floatPrecision: r = 3, noSpaceAfterFlags: i = !1 } = t, a = M(e);
|
|
4781
4719
|
return { element: { enter: (e) => {
|
|
4782
4720
|
if (e.children.length <= 1) return;
|
|
4783
4721
|
let t = /* @__PURE__ */ new Set(), o = e.children[0], s = null, c = (e, t) => {
|
|
4784
|
-
|
|
4722
|
+
Qt(e, t, {
|
|
4785
4723
|
floatPrecision: r,
|
|
4786
4724
|
noSpaceAfterFlags: i
|
|
4787
4725
|
}), s = null;
|
|
@@ -4796,36 +4734,28 @@ var l = e(((e) => {
|
|
|
4796
4734
|
s && c(o, s), o = i;
|
|
4797
4735
|
continue;
|
|
4798
4736
|
}
|
|
4799
|
-
let l =
|
|
4737
|
+
let l = N(a, i);
|
|
4800
4738
|
if (l[`marker-start`] || l[`marker-mid`] || l[`marker-end`] || l[`clip-path`] || l.mask || l[`mask-image`] || [
|
|
4801
4739
|
`fill`,
|
|
4802
4740
|
`filter`,
|
|
4803
4741
|
`stroke`
|
|
4804
|
-
].some((
|
|
4742
|
+
].some((e) => ur(l, e))) {
|
|
4805
4743
|
s && c(o, s), o = i;
|
|
4806
4744
|
continue;
|
|
4807
4745
|
}
|
|
4808
4746
|
let u = Object.keys(i.attributes);
|
|
4809
|
-
if (u.length !== Object.keys(o.attributes).length) {
|
|
4810
|
-
s && c(o, s), o = i;
|
|
4811
|
-
continue;
|
|
4812
|
-
}
|
|
4813
|
-
if (u.some(((e) => e !== `d` && o.type === `element` && o.attributes[e] !== i.attributes[e]))) {
|
|
4747
|
+
if (u.length !== Object.keys(o.attributes).length || u.some((e) => e !== `d` && o.type === `element` && o.attributes[e] !== i.attributes[e])) {
|
|
4814
4748
|
s && c(o, s), o = i;
|
|
4815
4749
|
continue;
|
|
4816
4750
|
}
|
|
4817
|
-
let d = s != null, f =
|
|
4818
|
-
|
|
4819
|
-
s.push(...f), t.add(i);
|
|
4820
|
-
continue;
|
|
4821
|
-
}
|
|
4822
|
-
d && c(o, s), o = i, s = null;
|
|
4751
|
+
let d = s != null, f = Xt(i);
|
|
4752
|
+
s ??= Xt(o), n || !$t(s, f) ? (s.push(...f), t.add(i)) : (d && c(o, s), o = i, s = null);
|
|
4823
4753
|
}
|
|
4824
|
-
s && o.type === `element` && c(o, s), e.children = e.children.filter((
|
|
4754
|
+
s && o.type === `element` && c(o, s), e.children = e.children.filter((e) => !t.has(e));
|
|
4825
4755
|
} } };
|
|
4826
4756
|
},
|
|
4827
4757
|
name: `mergePaths`
|
|
4828
|
-
}),
|
|
4758
|
+
}), fr = Object.freeze({
|
|
4829
4759
|
__proto__: null,
|
|
4830
4760
|
description: `removes unused namespaces declaration`,
|
|
4831
4761
|
fn: () => {
|
|
@@ -4855,7 +4785,7 @@ var l = e(((e) => {
|
|
|
4855
4785
|
} };
|
|
4856
4786
|
},
|
|
4857
4787
|
name: `removeUnusedNS`
|
|
4858
|
-
}),
|
|
4788
|
+
}), pr = Object.freeze({
|
|
4859
4789
|
__proto__: null,
|
|
4860
4790
|
description: `Sort element attributes for better compression`,
|
|
4861
4791
|
fn: (e, t) => {
|
|
@@ -4904,7 +4834,7 @@ var l = e(((e) => {
|
|
|
4904
4834
|
} } };
|
|
4905
4835
|
},
|
|
4906
4836
|
name: `sortAttrs`
|
|
4907
|
-
}),
|
|
4837
|
+
}), mr = Object.freeze({
|
|
4908
4838
|
__proto__: null,
|
|
4909
4839
|
description: `Sorts children of <defs> to improve compression`,
|
|
4910
4840
|
fn: () => ({ element: { enter: (e) => {
|
|
@@ -4914,7 +4844,7 @@ var l = e(((e) => {
|
|
|
4914
4844
|
let e = t.get(n.name);
|
|
4915
4845
|
e == null ? t.set(n.name, 1) : t.set(n.name, e + 1);
|
|
4916
4846
|
}
|
|
4917
|
-
e.children.sort((
|
|
4847
|
+
e.children.sort((e, n) => {
|
|
4918
4848
|
if (e.type !== `element` || n.type !== `element`) return 0;
|
|
4919
4849
|
let r = t.get(e.name), i = t.get(n.name);
|
|
4920
4850
|
if (r != null && i != null) {
|
|
@@ -4923,63 +4853,63 @@ var l = e(((e) => {
|
|
|
4923
4853
|
}
|
|
4924
4854
|
let a = n.name.length - e.name.length;
|
|
4925
4855
|
return a === 0 ? e.name === n.name ? 0 : e.name > n.name ? -1 : 1 : a;
|
|
4926
|
-
})
|
|
4856
|
+
});
|
|
4927
4857
|
}
|
|
4928
4858
|
} } }),
|
|
4929
4859
|
name: `sortDefsChildren`
|
|
4930
4860
|
});
|
|
4931
|
-
let
|
|
4932
|
-
var
|
|
4861
|
+
let hr = /^(Created with|Created using)/;
|
|
4862
|
+
var gr = Object.freeze({
|
|
4933
4863
|
__proto__: null,
|
|
4934
4864
|
description: `removes <desc>`,
|
|
4935
4865
|
fn: (e, t) => {
|
|
4936
4866
|
let { removeAny: n = !1 } = t;
|
|
4937
4867
|
return { element: { enter: (e, t) => {
|
|
4938
|
-
e.name === `desc` && (n || e.children.length === 0 || e.children[0].type === `text` &&
|
|
4868
|
+
e.name === `desc` && (n || e.children.length === 0 || e.children[0].type === `text` && hr.test(e.children[0].value)) && D(e, t);
|
|
4939
4869
|
} } };
|
|
4940
4870
|
},
|
|
4941
4871
|
name: `removeDesc`
|
|
4942
4872
|
});
|
|
4943
|
-
let
|
|
4873
|
+
let _r = ee({
|
|
4944
4874
|
name: `preset-default`,
|
|
4945
4875
|
plugins: [
|
|
4876
|
+
le,
|
|
4877
|
+
ue,
|
|
4946
4878
|
fe,
|
|
4947
|
-
|
|
4948
|
-
|
|
4949
|
-
|
|
4950
|
-
|
|
4951
|
-
|
|
4879
|
+
Fe,
|
|
4880
|
+
Ie,
|
|
4881
|
+
Le,
|
|
4882
|
+
Ve,
|
|
4883
|
+
He,
|
|
4952
4884
|
We,
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
ht,
|
|
4959
|
-
yt,
|
|
4960
|
-
Ct,
|
|
4885
|
+
nt,
|
|
4886
|
+
ct,
|
|
4887
|
+
dt,
|
|
4888
|
+
mt,
|
|
4889
|
+
bt,
|
|
4961
4890
|
wt,
|
|
4962
4891
|
Tt,
|
|
4963
|
-
|
|
4964
|
-
|
|
4892
|
+
Et,
|
|
4893
|
+
At,
|
|
4965
4894
|
Bt,
|
|
4966
|
-
|
|
4895
|
+
Vt,
|
|
4967
4896
|
Ut,
|
|
4968
4897
|
Wt,
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4898
|
+
Gt,
|
|
4899
|
+
qt,
|
|
4900
|
+
Yt,
|
|
4901
|
+
er,
|
|
4973
4902
|
sr,
|
|
4974
4903
|
cr,
|
|
4975
|
-
|
|
4904
|
+
lr,
|
|
4976
4905
|
dr,
|
|
4977
4906
|
fr,
|
|
4978
4907
|
pr,
|
|
4979
|
-
|
|
4908
|
+
mr,
|
|
4909
|
+
gr
|
|
4980
4910
|
]
|
|
4981
4911
|
});
|
|
4982
|
-
var
|
|
4912
|
+
var vr = Object.freeze({
|
|
4983
4913
|
__proto__: null,
|
|
4984
4914
|
description: `adds attributes to an outer <svg> element`,
|
|
4985
4915
|
fn: (e, t) => {
|
|
@@ -5029,7 +4959,7 @@ plugins: [
|
|
|
5029
4959
|
} } };
|
|
5030
4960
|
},
|
|
5031
4961
|
name: `addAttributesToSVGElement`
|
|
5032
|
-
}),
|
|
4962
|
+
}), yr = Object.freeze({
|
|
5033
4963
|
__proto__: null,
|
|
5034
4964
|
description: `adds classnames to an outer <svg> element`,
|
|
5035
4965
|
fn: (e, t, n) => {
|
|
@@ -5069,7 +4999,7 @@ plugins: [
|
|
|
5069
4999
|
},
|
|
5070
5000
|
name: `addClassesToSVGElement`
|
|
5071
5001
|
});
|
|
5072
|
-
let
|
|
5002
|
+
let br = /^([-+]?\d*\.?\d+([eE][-+]?\d+)?)(px|pt|pc|mm|cm|m|in|ft|em|ex|%)?$/, xr = /\s+,?\s*|,\s*/, Sr = {
|
|
5073
5003
|
cm: 96 / 2.54,
|
|
5074
5004
|
mm: 96 / 25.4,
|
|
5075
5005
|
in: 96,
|
|
@@ -5077,22 +5007,22 @@ plugins: [
|
|
|
5077
5007
|
pc: 16,
|
|
5078
5008
|
px: 1
|
|
5079
5009
|
};
|
|
5080
|
-
var
|
|
5010
|
+
var Cr = Object.freeze({
|
|
5081
5011
|
__proto__: null,
|
|
5082
5012
|
description: `rounds list of values to the fixed precision`,
|
|
5083
5013
|
fn: (e, t) => {
|
|
5084
5014
|
let { floatPrecision: n = 3, leadingZero: r = !0, defaultPx: i = !0, convertToPx: a = !0 } = t, o = (e) => {
|
|
5085
5015
|
let t = [];
|
|
5086
|
-
for (let o of e.split(
|
|
5087
|
-
let e = o.match(
|
|
5016
|
+
for (let o of e.split(xr)) {
|
|
5017
|
+
let e = o.match(br), s = o.match(/new/);
|
|
5088
5018
|
if (e) {
|
|
5089
5019
|
let o = Number(Number(e[1]).toFixed(n)), s = e[3] || ``;
|
|
5090
|
-
if (a && s && s in
|
|
5091
|
-
let t = Number((
|
|
5020
|
+
if (a && s && s in Sr) {
|
|
5021
|
+
let t = Number((Sr[s] * Number(e[1])).toFixed(n));
|
|
5092
5022
|
t.toString().length < e[0].length && (o = t, s = `px`);
|
|
5093
5023
|
}
|
|
5094
5024
|
let c;
|
|
5095
|
-
c = r ?
|
|
5025
|
+
c = r ? F(o) : o.toString(), i && s === `px` && (s = ``), t.push(c + s);
|
|
5096
5026
|
} else s ? t.push(`new`) : o && t.push(o);
|
|
5097
5027
|
}
|
|
5098
5028
|
return t.join(` `);
|
|
@@ -5102,11 +5032,11 @@ plugins: [
|
|
|
5102
5032
|
} } };
|
|
5103
5033
|
},
|
|
5104
5034
|
name: `cleanupListOfValues`
|
|
5105
|
-
}),
|
|
5035
|
+
}), wr = Object.freeze({
|
|
5106
5036
|
__proto__: null,
|
|
5107
5037
|
description: `converts one-stop (single color) gradients to a plain color`,
|
|
5108
5038
|
fn: (e) => {
|
|
5109
|
-
let t =
|
|
5039
|
+
let t = M(e), n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = 0;
|
|
5110
5040
|
return { element: {
|
|
5111
5041
|
enter: (o, s) => {
|
|
5112
5042
|
if (o.attributes[`xlink:href`] != null && a++, o.name === `defs`) {
|
|
@@ -5114,123 +5044,120 @@ plugins: [
|
|
|
5114
5044
|
return;
|
|
5115
5045
|
}
|
|
5116
5046
|
if (o.name !== `linearGradient` && o.name !== `radialGradient`) return;
|
|
5117
|
-
let c = o.children.filter((
|
|
5047
|
+
let c = o.children.filter((e) => e.type === `element` && e.name === `stop`), l = o.attributes[`xlink:href`] || o.attributes.href, u = c.length === 0 && l != null && l.startsWith(`#`) ? se(e, l) : o;
|
|
5118
5048
|
if (u == null || u.type !== `element`) {
|
|
5119
5049
|
i.set(o, s);
|
|
5120
5050
|
return;
|
|
5121
5051
|
}
|
|
5122
|
-
let d = u.children.filter((
|
|
5052
|
+
let d = u.children.filter((e) => e.type === `element` && e.name === `stop`);
|
|
5123
5053
|
if (d.length !== 1 || d[0].type !== `element`) return;
|
|
5124
5054
|
s.type === `element` && s.name === `defs` && n.add(s), i.set(o, s);
|
|
5125
|
-
let f, p =
|
|
5055
|
+
let f, p = N(t, d[0])[`stop-color`];
|
|
5126
5056
|
p != null && p.type === `static` && (f = p.value);
|
|
5127
|
-
let m = `url(#${o.attributes.id})`, h = [...
|
|
5128
|
-
for (let e of g) if (e.type === `element`) for (let t of
|
|
5129
|
-
let _ =
|
|
5130
|
-
for (let e of _) e.type === `element` && (e.attributes.style = e.attributes.style.replace(m, f ||
|
|
5057
|
+
let m = `url(#${o.attributes.id})`, h = [...Se].map((e) => `[${e}="${m}"]`).join(`,`), g = E(e, h);
|
|
5058
|
+
for (let e of g) if (e.type === `element`) for (let t of Se) e.attributes[t] === m && (f == null ? delete e.attributes[t] : e.attributes[t] = f);
|
|
5059
|
+
let _ = E(e, `[style*=${m}]`);
|
|
5060
|
+
for (let e of _) e.type === `element` && (e.attributes.style = e.attributes.style.replace(m, f || he.presentation[`stop-color`]));
|
|
5131
5061
|
},
|
|
5132
5062
|
exit: (e) => {
|
|
5133
5063
|
if (e.name === `svg`) {
|
|
5134
|
-
for (let [e, t] of i.entries()) e.attributes[`xlink:href`] != null && a--,
|
|
5064
|
+
for (let [e, t] of i.entries()) e.attributes[`xlink:href`] != null && a--, D(e, t);
|
|
5135
5065
|
a === 0 && delete e.attributes[`xmlns:xlink`];
|
|
5136
|
-
for (let [e, t] of r.entries()) n.has(e) && e.children.length === 0 &&
|
|
5066
|
+
for (let [e, t] of r.entries()) n.has(e) && e.children.length === 0 && D(e, t);
|
|
5137
5067
|
}
|
|
5138
5068
|
}
|
|
5139
5069
|
} };
|
|
5140
5070
|
},
|
|
5141
5071
|
name: `convertOneStopGradients`
|
|
5142
5072
|
});
|
|
5143
|
-
let
|
|
5144
|
-
var
|
|
5073
|
+
let Y = (...e) => `(?:` + e.join(`|`) + `)`, Tr = k.presentation, X = `\\\\(?:[0-9a-f]{1,6}\\s?|\\r\\n|.)`, Er = `\\s*(` + Y(`[^:;\\\\]`, X) + `*?)\\s*`, Dr = `'(?:[^'\\n\\r\\\\]|` + X + `)*?(?:'|$)`, Or = `"(?:[^"\\n\\r\\\\]|` + X + `)*?(?:"|$)`, kr = RegExp(`^` + Y(Dr, Or) + `$`), Ar = `\\s*(` + Y(`[^!'"();\\\\]+?`, X, Dr, Or, `\\(` + Y(`[^'"()\\\\]+`, X, Dr, Or) + `*?\\)`, `[^;]*?`) + `*?)`, jr = RegExp(Er + `:` + Ar + `(\\s*!important(?![-(\\w]))?\\s*(?:;\\s*|$)`, `ig`), Mr = new RegExp(Y(X, Dr, Or, `/\\*[^]*?\\*/`), `ig`);
|
|
5074
|
+
var Nr = Object.freeze({
|
|
5145
5075
|
__proto__: null,
|
|
5146
5076
|
description: `converts style to attributes`,
|
|
5147
5077
|
fn: (e, t) => {
|
|
5148
5078
|
let { keepImportant: n = !1 } = t;
|
|
5149
5079
|
return { element: { enter: (e) => {
|
|
5150
5080
|
if (e.attributes.style != null) {
|
|
5151
|
-
let r = [], i = {}, a = e.attributes.style.replace(
|
|
5152
|
-
|
|
5153
|
-
for (var t; t =
|
|
5154
|
-
r.length && (r = r.filter(
|
|
5081
|
+
let r = [], i = {}, a = e.attributes.style.replace(Mr, (e) => e[0] == `/` ? `` : e[0] == `\\` && /[-g-z]/i.test(e[1]) ? e[1] : e);
|
|
5082
|
+
jr.lastIndex = 0;
|
|
5083
|
+
for (var t; t = jr.exec(a);) n && t[3] || r.push([t[1], t[2]]);
|
|
5084
|
+
r.length && (r = r.filter(function(e) {
|
|
5155
5085
|
if (e[0]) {
|
|
5156
5086
|
let t = e[0].toLowerCase(), n = e[1];
|
|
5157
|
-
if (
|
|
5087
|
+
if (kr.test(n) && (n = n.slice(1, -1)), Tr.has(t)) return i[t] = n, !1;
|
|
5158
5088
|
}
|
|
5159
5089
|
return !0;
|
|
5160
|
-
})
|
|
5090
|
+
}), Object.assign(e.attributes, i), r.length ? e.attributes.style = r.map((e) => e.join(`:`)).join(`;`) : delete e.attributes.style);
|
|
5161
5091
|
}
|
|
5162
5092
|
} } };
|
|
5163
5093
|
},
|
|
5164
5094
|
name: `convertStyleToAttrs`
|
|
5165
5095
|
});
|
|
5166
|
-
let
|
|
5096
|
+
let Pr = (e) => {
|
|
5167
5097
|
let t = /[/\\]?([^/\\]+)$/.exec(e);
|
|
5168
5098
|
return t ? t[1] : ``;
|
|
5169
|
-
},
|
|
5099
|
+
}, Fr = (e) => e.replace(/[. ]/g, `_`), Ir = (e) => e.startsWith(`"`) && e.endsWith(`"`) || e.startsWith(`'`) && e.endsWith(`'`) ? e.slice(1, -1) : e, Z = (e, t) => {
|
|
5170
5100
|
let n = e(t);
|
|
5171
5101
|
return t.startsWith(n) ? t : n + t;
|
|
5172
|
-
},
|
|
5102
|
+
}, Lr = (e, t) => t.startsWith(`#`) ? `#` + Z(e, t.slice(1)) : null, Rr = (e, t, n, r, i, a) => {
|
|
5173
5103
|
if (typeof r == `function`) {
|
|
5174
5104
|
let o = a.get(e);
|
|
5175
|
-
return o ?? (o = r(t, n) + i, a.set(e, o), o
|
|
5105
|
+
return o ?? (o = r(t, n) + i, a.set(e, o)), o;
|
|
5176
5106
|
}
|
|
5177
|
-
return typeof r == `string` ? r + i : r === !1 ? `` : n.path != null && n.path.length > 0 ?
|
|
5107
|
+
return typeof r == `string` ? r + i : r === !1 ? `` : n.path != null && n.path.length > 0 ? Fr(Pr(n.path)) + i : `prefix` + i;
|
|
5178
5108
|
};
|
|
5179
|
-
var
|
|
5109
|
+
var zr = Object.freeze({
|
|
5180
5110
|
__proto__: null,
|
|
5181
5111
|
description: `prefix IDs`,
|
|
5182
5112
|
fn: (e, t, n) => {
|
|
5183
5113
|
let { delim: r = `__`, prefix: i, prefixIds: a = !0, prefixClassNames: o = !0 } = t, s = /* @__PURE__ */ new Map();
|
|
5184
5114
|
return { element: { enter: (e) => {
|
|
5185
|
-
let t = (t) =>
|
|
5115
|
+
let t = (t) => Rr(t, e, n, i, r, s);
|
|
5186
5116
|
if (e.name === `style`) {
|
|
5187
5117
|
if (e.children.length === 0) return;
|
|
5188
5118
|
for (let n of e.children) {
|
|
5189
5119
|
if (n.type !== `text` && n.type !== `cdata`) continue;
|
|
5190
5120
|
let e = n.value, r;
|
|
5191
5121
|
try {
|
|
5192
|
-
r =
|
|
5122
|
+
r = v.parse(e, {
|
|
5193
5123
|
parseValue: !0,
|
|
5194
5124
|
parseCustomProperty: !1
|
|
5195
5125
|
});
|
|
5196
5126
|
} catch {
|
|
5197
5127
|
return;
|
|
5198
5128
|
}
|
|
5199
|
-
|
|
5200
|
-
if (a && e.type === `IdSelector` || o && e.type === `ClassSelector`)
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
}
|
|
5204
|
-
if (e.type === `Url` && e.value.length > 0) {
|
|
5205
|
-
let n = zr(t, Lr(e.value));
|
|
5129
|
+
v.walk(r, (e) => {
|
|
5130
|
+
if (a && e.type === `IdSelector` || o && e.type === `ClassSelector`) e.name = Z(t, e.name);
|
|
5131
|
+
else if (e.type === `Url` && e.value.length > 0) {
|
|
5132
|
+
let n = Lr(t, Ir(e.value));
|
|
5206
5133
|
n != null && (e.value = n);
|
|
5207
5134
|
}
|
|
5208
|
-
})
|
|
5135
|
+
}), n.value = v.generate(r);
|
|
5209
5136
|
}
|
|
5210
5137
|
}
|
|
5211
|
-
a && e.attributes.id != null && e.attributes.id.length !== 0 && (e.attributes.id =
|
|
5138
|
+
a && e.attributes.id != null && e.attributes.id.length !== 0 && (e.attributes.id = Z(t, e.attributes.id)), o && e.attributes.class != null && e.attributes.class.length !== 0 && (e.attributes.class = e.attributes.class.split(/\s+/).map((e) => Z(t, e)).join(` `));
|
|
5212
5139
|
for (let n of [`href`, `xlink:href`]) if (e.attributes[n] != null && e.attributes[n].length !== 0) {
|
|
5213
|
-
let r =
|
|
5140
|
+
let r = Lr(t, e.attributes[n]);
|
|
5214
5141
|
r != null && (e.attributes[n] = r);
|
|
5215
5142
|
}
|
|
5216
|
-
for (let n of
|
|
5217
|
-
let i =
|
|
5143
|
+
for (let n of A) e.attributes[n] != null && e.attributes[n].length !== 0 && (e.attributes[n] = e.attributes[n].replace(/\burl\((["'])?(#.+?)\1\)/gi, (e, n, r) => {
|
|
5144
|
+
let i = Lr(t, r);
|
|
5218
5145
|
return i == null ? e : `url(${i})`;
|
|
5219
|
-
}))
|
|
5146
|
+
}));
|
|
5220
5147
|
for (let n of [`begin`, `end`]) if (e.attributes[n] != null && e.attributes[n].length !== 0) {
|
|
5221
|
-
let r = e.attributes[n].split(/\s*;\s+/).map((
|
|
5148
|
+
let r = e.attributes[n].split(/\s*;\s+/).map((e) => {
|
|
5222
5149
|
if (e.endsWith(`.end`) || e.endsWith(`.start`)) {
|
|
5223
5150
|
let [n, r] = e.split(`.`);
|
|
5224
|
-
return `${
|
|
5151
|
+
return `${Z(t, n)}.${r}`;
|
|
5225
5152
|
}
|
|
5226
5153
|
return e;
|
|
5227
|
-
})
|
|
5154
|
+
});
|
|
5228
5155
|
e.attributes[n] = r.join(`; `);
|
|
5229
5156
|
}
|
|
5230
5157
|
} } };
|
|
5231
5158
|
},
|
|
5232
5159
|
name: `prefixIds`
|
|
5233
|
-
}),
|
|
5160
|
+
}), Br = Object.freeze({
|
|
5234
5161
|
__proto__: null,
|
|
5235
5162
|
description: `removes attributes of elements that match a css selector`,
|
|
5236
5163
|
fn: (e, t) => {
|
|
@@ -5239,14 +5166,16 @@ It should have a list of "selectors", or one "selector" and one "attributes".
|
|
|
5239
5166
|
Without either, the plugin is a noop.`), null;
|
|
5240
5167
|
let n = Array.isArray(t.selectors) ? t.selectors : [t];
|
|
5241
5168
|
for (let { selector: t, attributes: r } of n) {
|
|
5242
|
-
let n =
|
|
5243
|
-
for (let e of n) if (e.type === `element`)
|
|
5244
|
-
|
|
5169
|
+
let n = E(e, t);
|
|
5170
|
+
for (let e of n) if (e.type === `element`) {
|
|
5171
|
+
if (Array.isArray(r)) for (let t of r) delete e.attributes[t];
|
|
5172
|
+
else delete e.attributes[r];
|
|
5173
|
+
}
|
|
5245
5174
|
}
|
|
5246
5175
|
return {};
|
|
5247
5176
|
},
|
|
5248
5177
|
name: `removeAttributesBySelector`
|
|
5249
|
-
}),
|
|
5178
|
+
}), Vr = Object.freeze({
|
|
5250
5179
|
__proto__: null,
|
|
5251
5180
|
description: `removes specified attributes`,
|
|
5252
5181
|
fn: (e, t) => {
|
|
@@ -5271,11 +5200,11 @@ plugins: [
|
|
|
5271
5200
|
t,
|
|
5272
5201
|
`.*`
|
|
5273
5202
|
].join(n);
|
|
5274
|
-
let i = t.split(n).map((
|
|
5203
|
+
let i = t.split(n).map((e) => (e === `*` && (e = `.*`), new RegExp([
|
|
5275
5204
|
`^`,
|
|
5276
5205
|
e,
|
|
5277
5206
|
`$`
|
|
5278
|
-
].join(``), `i`)))
|
|
5207
|
+
].join(``), `i`)));
|
|
5279
5208
|
if (i[0].test(e.name)) for (let [t, n] of Object.entries(e.attributes)) {
|
|
5280
5209
|
let a = n.toLowerCase() === `currentcolor`;
|
|
5281
5210
|
!(r && t == `fill` && a) && !(r && t == `stroke` && a) && i[1].test(t) && i[2].test(n) && delete e.attributes[t];
|
|
@@ -5284,7 +5213,7 @@ plugins: [
|
|
|
5284
5213
|
} } };
|
|
5285
5214
|
},
|
|
5286
5215
|
name: `removeAttrs`
|
|
5287
|
-
}),
|
|
5216
|
+
}), Hr = Object.freeze({
|
|
5288
5217
|
__proto__: null,
|
|
5289
5218
|
description: `removes width and height in presence of viewBox (opposite to removeViewBox)`,
|
|
5290
5219
|
fn: () => ({ element: { enter: (e) => {
|
|
@@ -5297,23 +5226,23 @@ plugins: [
|
|
|
5297
5226
|
}
|
|
5298
5227
|
} } }),
|
|
5299
5228
|
name: `removeDimensions`
|
|
5300
|
-
}),
|
|
5229
|
+
}), Ur = Object.freeze({
|
|
5301
5230
|
__proto__: null,
|
|
5302
5231
|
description: `removes arbitrary elements by ID or className`,
|
|
5303
5232
|
fn: (e, t) => {
|
|
5304
5233
|
let n = t.id == null ? [] : Array.isArray(t.id) ? t.id : [t.id], r = t.class == null ? [] : Array.isArray(t.class) ? t.class : [t.class];
|
|
5305
5234
|
return { element: { enter: (e, t) => {
|
|
5306
|
-
if (e.attributes.id != null && n.length !== 0 && n.includes(e.attributes.id) &&
|
|
5235
|
+
if (e.attributes.id != null && n.length !== 0 && n.includes(e.attributes.id) && D(e, t), e.attributes.class && r.length !== 0) {
|
|
5307
5236
|
let n = e.attributes.class.split(` `);
|
|
5308
5237
|
for (let i of r) if (n.includes(i)) {
|
|
5309
|
-
|
|
5238
|
+
D(e, t);
|
|
5310
5239
|
break;
|
|
5311
5240
|
}
|
|
5312
5241
|
}
|
|
5313
5242
|
} } };
|
|
5314
5243
|
},
|
|
5315
5244
|
name: `removeElementsByAttr`
|
|
5316
|
-
}),
|
|
5245
|
+
}), Wr = Object.freeze({
|
|
5317
5246
|
__proto__: null,
|
|
5318
5247
|
description: `removes elements that are drawn outside of the viewBox`,
|
|
5319
5248
|
fn: () => {
|
|
@@ -5334,9 +5263,9 @@ plugins: [
|
|
|
5334
5263
|
height: s
|
|
5335
5264
|
};
|
|
5336
5265
|
}
|
|
5337
|
-
if (t.attributes.transform != null) return
|
|
5266
|
+
if (t.attributes.transform != null) return b;
|
|
5338
5267
|
if (t.name === `path` && t.attributes.d != null && e != null) {
|
|
5339
|
-
let r =
|
|
5268
|
+
let r = It(t.attributes.d), i = !1;
|
|
5340
5269
|
for (let t of r) if (t.command === `M`) {
|
|
5341
5270
|
let [n, r] = t.args;
|
|
5342
5271
|
n >= e.left && n <= e.right && r >= e.top && r <= e.bottom && (i = !0);
|
|
@@ -5347,7 +5276,7 @@ plugins: [
|
|
|
5347
5276
|
args: []
|
|
5348
5277
|
});
|
|
5349
5278
|
let { left: a, top: o, width: s, height: c } = e;
|
|
5350
|
-
|
|
5279
|
+
$t([
|
|
5351
5280
|
{
|
|
5352
5281
|
command: `M`,
|
|
5353
5282
|
args: [a, o]
|
|
@@ -5368,27 +5297,33 @@ plugins: [
|
|
|
5368
5297
|
command: `z`,
|
|
5369
5298
|
args: []
|
|
5370
5299
|
}
|
|
5371
|
-
], r) === !1 &&
|
|
5300
|
+
], r) === !1 && D(t, n);
|
|
5372
5301
|
}
|
|
5373
5302
|
} } };
|
|
5374
5303
|
},
|
|
5375
5304
|
name: `removeOffCanvasPaths`
|
|
5376
|
-
}),
|
|
5305
|
+
}), Gr = Object.freeze({
|
|
5377
5306
|
__proto__: null,
|
|
5378
5307
|
description: `removes raster images`,
|
|
5379
5308
|
fn: () => ({ element: { enter: (e, t) => {
|
|
5380
|
-
e.name === `image` && e.attributes[`xlink:href`] != null && /(\.|image\/)(jpe?g|png|gif)/.test(e.attributes[`xlink:href`]) &&
|
|
5309
|
+
e.name === `image` && e.attributes[`xlink:href`] != null && /(\.|image\/)(jpe?g|png|gif)/.test(e.attributes[`xlink:href`]) && D(e, t);
|
|
5381
5310
|
} } }),
|
|
5382
5311
|
name: `removeRasterImages`
|
|
5383
5312
|
});
|
|
5384
|
-
let
|
|
5385
|
-
...
|
|
5386
|
-
...
|
|
5387
|
-
...
|
|
5388
|
-
...
|
|
5389
|
-
...
|
|
5390
|
-
],
|
|
5391
|
-
|
|
5313
|
+
let Kr = [
|
|
5314
|
+
...k.animationEvent,
|
|
5315
|
+
...k.documentEvent,
|
|
5316
|
+
...k.documentElementEvent,
|
|
5317
|
+
...k.globalEvent,
|
|
5318
|
+
...k.graphicalEvent
|
|
5319
|
+
], qr = `http://www.w3.org/2000/svg`, Jr = [qr], Yr = [qr], Xr = [qr, `http://www.w3.org/1999/xhtml`], Zr = /* @__PURE__ */ new Set([
|
|
5320
|
+
`action`,
|
|
5321
|
+
`data`,
|
|
5322
|
+
`formaction`,
|
|
5323
|
+
`href`,
|
|
5324
|
+
`src`
|
|
5325
|
+
]);
|
|
5326
|
+
function Qr(e, t, n, r) {
|
|
5392
5327
|
if (e === t) return !0;
|
|
5393
5328
|
if (e.includes(`:`)) {
|
|
5394
5329
|
let [i, a] = e.split(`:`, 2);
|
|
@@ -5399,66 +5334,68 @@ plugins: [
|
|
|
5399
5334
|
}
|
|
5400
5335
|
return !1;
|
|
5401
5336
|
}
|
|
5402
|
-
var
|
|
5337
|
+
var $r = Object.freeze({
|
|
5403
5338
|
__proto__: null,
|
|
5404
5339
|
description: `removes scripts`,
|
|
5405
5340
|
fn: () => {
|
|
5406
|
-
let e = /* @__PURE__ */ new Map();
|
|
5341
|
+
let e = /* @__PURE__ */ new Map(), t = 0;
|
|
5407
5342
|
return { element: {
|
|
5408
|
-
enter: (
|
|
5409
|
-
for (let [
|
|
5410
|
-
if (!
|
|
5411
|
-
let
|
|
5412
|
-
e.has(
|
|
5343
|
+
enter: (n, r) => {
|
|
5344
|
+
for (let [t, r] of Object.entries(n.attributes)) {
|
|
5345
|
+
if (!t.startsWith(`xmlns:`)) continue;
|
|
5346
|
+
let n = t.slice(6);
|
|
5347
|
+
e.has(n) ? e.get(n).push(r) : e.set(n, [r]);
|
|
5413
5348
|
}
|
|
5414
|
-
if (
|
|
5415
|
-
|
|
5416
|
-
|
|
5349
|
+
if (Qr(n.name, `foreignObject`, e, Jr) && (t += 1), Qr(n.name, `script`, e, Xr)) D(n, r);
|
|
5350
|
+
else for (let [e, r] of Object.entries(n.attributes)) {
|
|
5351
|
+
let i = e.slice(e.lastIndexOf(`:`) + 1).toLowerCase(), a = Kr.includes(e) || t > 0 && i.startsWith(`on`), o = t > 0 && i === `srcdoc`, s = t > 0 && Zr.has(i) && Ze(r);
|
|
5352
|
+
(a || o || s) && delete n.attributes[e];
|
|
5417
5353
|
}
|
|
5418
|
-
for (let e of Jr) t.attributes[e] != null && delete t.attributes[e];
|
|
5419
5354
|
},
|
|
5420
|
-
exit: (
|
|
5421
|
-
|
|
5422
|
-
|
|
5423
|
-
|
|
5424
|
-
|
|
5355
|
+
exit: (n, r) => {
|
|
5356
|
+
let i = Qr(n.name, `foreignObject`, e, Jr), a = Qr(n.name, `a`, e, Yr);
|
|
5357
|
+
for (let t of Object.keys(n.attributes)) {
|
|
5358
|
+
if (!t.startsWith(`xmlns:`)) continue;
|
|
5359
|
+
let n = t.slice(6);
|
|
5360
|
+
e.get(n).pop();
|
|
5425
5361
|
}
|
|
5426
|
-
if (
|
|
5427
|
-
for (let e of Object.keys(
|
|
5428
|
-
if (
|
|
5429
|
-
let
|
|
5430
|
-
|
|
5362
|
+
if (a) {
|
|
5363
|
+
for (let e of Object.keys(n.attributes)) if (e === `href` || e.endsWith(`:href`)) {
|
|
5364
|
+
if (n.attributes[e] == null || !Ze(n.attributes[e])) continue;
|
|
5365
|
+
let t = r.children.indexOf(n), i = n.children.filter((e) => e.type !== `text`);
|
|
5366
|
+
r.children.splice(t, 1, ...i);
|
|
5431
5367
|
}
|
|
5432
5368
|
}
|
|
5369
|
+
i && --t;
|
|
5433
5370
|
}
|
|
5434
5371
|
} };
|
|
5435
5372
|
},
|
|
5436
5373
|
name: `removeScripts`
|
|
5437
|
-
}),
|
|
5374
|
+
}), ei = Object.freeze({
|
|
5438
5375
|
__proto__: null,
|
|
5439
5376
|
description: `removes <style> element`,
|
|
5440
5377
|
fn: () => ({ element: { enter: (e, t) => {
|
|
5441
|
-
e.name === `style` &&
|
|
5378
|
+
e.name === `style` && D(e, t);
|
|
5442
5379
|
} } }),
|
|
5443
5380
|
name: `removeStyleElement`
|
|
5444
|
-
}),
|
|
5381
|
+
}), ti = Object.freeze({
|
|
5445
5382
|
__proto__: null,
|
|
5446
5383
|
description: `removes <title>`,
|
|
5447
5384
|
fn: () => ({ element: { enter: (e, t) => {
|
|
5448
|
-
e.name === `title` &&
|
|
5385
|
+
e.name === `title` && D(e, t);
|
|
5449
5386
|
} } }),
|
|
5450
5387
|
name: `removeTitle`
|
|
5451
5388
|
});
|
|
5452
|
-
let
|
|
5389
|
+
let ni = /* @__PURE__ */ new Set([
|
|
5453
5390
|
`pattern`,
|
|
5454
5391
|
`svg`,
|
|
5455
5392
|
`symbol`
|
|
5456
5393
|
]);
|
|
5457
|
-
var
|
|
5394
|
+
var ri = Object.freeze({
|
|
5458
5395
|
__proto__: null,
|
|
5459
5396
|
description: `removes viewBox attribute when possible`,
|
|
5460
5397
|
fn: () => ({ element: { enter: (e, t) => {
|
|
5461
|
-
if (
|
|
5398
|
+
if (ni.has(e.name) && e.attributes.viewBox != null && e.attributes.width != null && e.attributes.height != null) {
|
|
5462
5399
|
if (e.name === `svg` && t.type !== `root`) return;
|
|
5463
5400
|
let n = e.attributes.viewBox.split(/[ ,]+/g);
|
|
5464
5401
|
n[0] === `0` && n[1] === `0` && e.attributes.width.replace(/px$/, ``) === n[2] && e.attributes.height.replace(/px$/, ``) === n[3] && delete e.attributes.viewBox;
|
|
@@ -5466,17 +5403,17 @@ plugins: [
|
|
|
5466
5403
|
} } }),
|
|
5467
5404
|
name: `removeViewBox`
|
|
5468
5405
|
});
|
|
5469
|
-
let
|
|
5406
|
+
let ii = `http://www.w3.org/1999/xlink`, ai = {
|
|
5470
5407
|
new: `_blank`,
|
|
5471
5408
|
replace: `_self`
|
|
5472
|
-
},
|
|
5409
|
+
}, oi = /* @__PURE__ */ new Set([
|
|
5473
5410
|
`cursor`,
|
|
5474
5411
|
`filter`,
|
|
5475
5412
|
`font-face-uri`,
|
|
5476
5413
|
`glyphRef`,
|
|
5477
5414
|
`tref`
|
|
5478
|
-
]),
|
|
5479
|
-
var
|
|
5415
|
+
]), si = (e, t, n) => t.map((e) => `${e}:${n}`).filter((t) => e.attributes[t] != null);
|
|
5416
|
+
var ci = Object.freeze({
|
|
5480
5417
|
__proto__: null,
|
|
5481
5418
|
description: `remove xlink namespace and replaces attributes with the SVG 2 equivalent where applicable`,
|
|
5482
5419
|
fn: (e, t) => {
|
|
@@ -5485,26 +5422,22 @@ plugins: [
|
|
|
5485
5422
|
enter: (e) => {
|
|
5486
5423
|
for (let [t, n] of Object.entries(e.attributes)) if (t.startsWith(`xmlns:`)) {
|
|
5487
5424
|
let e = t.split(`:`, 2)[1];
|
|
5488
|
-
if (n ===
|
|
5425
|
+
if (n === ii) {
|
|
5489
5426
|
r.push(e);
|
|
5490
5427
|
continue;
|
|
5491
5428
|
}
|
|
5492
5429
|
r.includes(e) && i.push(e);
|
|
5493
5430
|
}
|
|
5494
|
-
if (i.some((
|
|
5495
|
-
let t =
|
|
5431
|
+
if (i.some((e) => r.includes(e))) return;
|
|
5432
|
+
let t = si(e, r, `show`), o = e.attributes.target != null;
|
|
5496
5433
|
for (let n = t.length - 1; n >= 0; n--) {
|
|
5497
|
-
let r = t[n], i = e.attributes[r], a =
|
|
5498
|
-
|
|
5499
|
-
delete e.attributes[r];
|
|
5500
|
-
continue;
|
|
5501
|
-
}
|
|
5502
|
-
a !== be[e.name]?.defaults?.target && (e.attributes.target = a), delete e.attributes[r], o = !0;
|
|
5434
|
+
let r = t[n], i = e.attributes[r], a = ai[i];
|
|
5435
|
+
o || a == null ? delete e.attributes[r] : (a !== _e[e.name]?.defaults?.target && (e.attributes.target = a), delete e.attributes[r], o = !0);
|
|
5503
5436
|
}
|
|
5504
|
-
let s =
|
|
5437
|
+
let s = si(e, r, `title`);
|
|
5505
5438
|
for (let t = s.length - 1; t >= 0; t--) {
|
|
5506
5439
|
let n = s[t], r = e.attributes[n];
|
|
5507
|
-
if (e.children.filter((
|
|
5440
|
+
if (e.children.filter((e) => e.type === `element` && e.name === `title`).length > 0) {
|
|
5508
5441
|
delete e.attributes[n];
|
|
5509
5442
|
continue;
|
|
5510
5443
|
}
|
|
@@ -5522,29 +5455,19 @@ plugins: [
|
|
|
5522
5455
|
value: e
|
|
5523
5456
|
}), e.children.unshift(i), delete e.attributes[n];
|
|
5524
5457
|
}
|
|
5525
|
-
let c =
|
|
5526
|
-
if (c.length > 0 &&
|
|
5527
|
-
|
|
5528
|
-
return;
|
|
5529
|
-
}
|
|
5530
|
-
for (let t = c.length - 1; t >= 0; t--) {
|
|
5458
|
+
let c = si(e, r, `href`);
|
|
5459
|
+
if (c.length > 0 && oi.has(e.name) && !n) c.map((e) => e.split(`:`, 1)[0]).forEach((e) => a.push(e));
|
|
5460
|
+
else for (let t = c.length - 1; t >= 0; t--) {
|
|
5531
5461
|
let n = c[t], r = e.attributes[n];
|
|
5532
|
-
|
|
5533
|
-
delete e.attributes[n];
|
|
5534
|
-
continue;
|
|
5535
|
-
}
|
|
5536
|
-
e.attributes.href = r, delete e.attributes[n];
|
|
5462
|
+
e.attributes.href ?? (e.attributes.href = r), delete e.attributes[n];
|
|
5537
5463
|
}
|
|
5538
5464
|
},
|
|
5539
5465
|
exit: (e) => {
|
|
5540
5466
|
for (let [t, o] of Object.entries(e.attributes)) {
|
|
5541
5467
|
let [s, c] = t.split(`:`, 2);
|
|
5542
|
-
if (r.includes(s) && !i.includes(s) && !a.includes(s) && !n)
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
}
|
|
5546
|
-
if (t.startsWith(`xmlns:`) && !a.includes(c)) {
|
|
5547
|
-
if (o === ni) {
|
|
5468
|
+
if (r.includes(s) && !i.includes(s) && !a.includes(s) && !n) delete e.attributes[t];
|
|
5469
|
+
else if (t.startsWith(`xmlns:`) && !a.includes(c)) {
|
|
5470
|
+
if (o === ii) {
|
|
5548
5471
|
let n = r.indexOf(c);
|
|
5549
5472
|
r.splice(n, 1), delete e.attributes[t];
|
|
5550
5473
|
continue;
|
|
@@ -5559,18 +5482,18 @@ plugins: [
|
|
|
5559
5482
|
} };
|
|
5560
5483
|
},
|
|
5561
5484
|
name: `removeXlink`
|
|
5562
|
-
}),
|
|
5485
|
+
}), li = Object.freeze({
|
|
5563
5486
|
__proto__: null,
|
|
5564
5487
|
description: `removes xmlns attribute (for inline svg)`,
|
|
5565
5488
|
fn: () => ({ element: { enter: (e) => {
|
|
5566
5489
|
e.name === `svg` && delete e.attributes.xmlns;
|
|
5567
5490
|
} } }),
|
|
5568
5491
|
name: `removeXMLNS`
|
|
5569
|
-
}),
|
|
5492
|
+
}), ui = Object.freeze({
|
|
5570
5493
|
__proto__: null,
|
|
5571
5494
|
description: `Finds <path> elements with the same d, fill, and stroke, and converts them to <use> elements referencing a single <path> def.`,
|
|
5572
5495
|
fn: (e) => {
|
|
5573
|
-
let t =
|
|
5496
|
+
let t = M(e), n = /* @__PURE__ */ new Map(), r, i = /* @__PURE__ */ new Set();
|
|
5574
5497
|
return { element: {
|
|
5575
5498
|
enter: (e, t) => {
|
|
5576
5499
|
if (e.name === `path` && e.attributes.d != null) {
|
|
@@ -5605,17 +5528,17 @@ plugins: [
|
|
|
5605
5528
|
`d`
|
|
5606
5529
|
]) r[0].attributes[e] != null && (n.attributes[e] = r[0].attributes[e]);
|
|
5607
5530
|
let s = r[0].attributes.id;
|
|
5608
|
-
s == null || i.has(s) || t.rules.some((
|
|
5531
|
+
s == null || i.has(s) || t.rules.some((e) => e.selector === `#${s}`) ? n.attributes.id = `reuse-` + o++ : (n.attributes.id = s, delete r[0].attributes.id), a.children.push(n);
|
|
5609
5532
|
for (let t of r) {
|
|
5610
5533
|
if (delete t.attributes.d, delete t.attributes.stroke, delete t.attributes.fill, a.children.includes(t) && t.children.length === 0) {
|
|
5611
5534
|
if (Object.keys(t.attributes).length === 0) {
|
|
5612
|
-
|
|
5535
|
+
D(t, a);
|
|
5613
5536
|
continue;
|
|
5614
5537
|
}
|
|
5615
5538
|
if (Object.keys(t.attributes).length === 1 && t.attributes.id != null) {
|
|
5616
|
-
|
|
5539
|
+
D(t, a);
|
|
5617
5540
|
let r = `[xlink\\:href=#${t.attributes.id}], [href=#${t.attributes.id}]`;
|
|
5618
|
-
for (let t of
|
|
5541
|
+
for (let t of E(e, r)) if (t.type === `element`) for (let e of [`href`, `xlink:href`]) t.attributes[e] != null && (t.attributes[e] = `#` + n.attributes.id);
|
|
5619
5542
|
continue;
|
|
5620
5543
|
}
|
|
5621
5544
|
}
|
|
@@ -5629,68 +5552,68 @@ plugins: [
|
|
|
5629
5552
|
},
|
|
5630
5553
|
name: `reusePaths`
|
|
5631
5554
|
});
|
|
5632
|
-
let
|
|
5633
|
-
gr,
|
|
5555
|
+
let di = Object.freeze([
|
|
5634
5556
|
_r,
|
|
5635
5557
|
vr,
|
|
5636
|
-
|
|
5637
|
-
|
|
5638
|
-
|
|
5639
|
-
|
|
5640
|
-
ht,
|
|
5641
|
-
Jt,
|
|
5642
|
-
yt,
|
|
5643
|
-
Ut,
|
|
5558
|
+
yr,
|
|
5559
|
+
Ve,
|
|
5560
|
+
At,
|
|
5561
|
+
ct,
|
|
5644
5562
|
Cr,
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
or,
|
|
5649
|
-
qe,
|
|
5650
|
-
ur,
|
|
5651
|
-
Ge,
|
|
5652
|
-
rt,
|
|
5563
|
+
mt,
|
|
5564
|
+
Yt,
|
|
5565
|
+
bt,
|
|
5653
5566
|
Wt,
|
|
5654
|
-
|
|
5567
|
+
wr,
|
|
5568
|
+
er,
|
|
5569
|
+
Ut,
|
|
5570
|
+
Nr,
|
|
5571
|
+
sr,
|
|
5572
|
+
We,
|
|
5573
|
+
dr,
|
|
5574
|
+
He,
|
|
5575
|
+
nt,
|
|
5576
|
+
Gt,
|
|
5577
|
+
qt,
|
|
5578
|
+
zr,
|
|
5579
|
+
Br,
|
|
5655
5580
|
Vr,
|
|
5581
|
+
fe,
|
|
5582
|
+
Fe,
|
|
5583
|
+
gr,
|
|
5656
5584
|
Hr,
|
|
5585
|
+
le,
|
|
5586
|
+
Le,
|
|
5657
5587
|
Ur,
|
|
5658
|
-
he,
|
|
5659
|
-
Re,
|
|
5660
|
-
hr,
|
|
5661
|
-
Wr,
|
|
5662
|
-
fe,
|
|
5663
|
-
Be,
|
|
5664
|
-
Gr,
|
|
5665
|
-
sr,
|
|
5666
5588
|
cr,
|
|
5589
|
+
lr,
|
|
5590
|
+
Vt,
|
|
5667
5591
|
Bt,
|
|
5668
|
-
|
|
5669
|
-
ze,
|
|
5670
|
-
wt,
|
|
5671
|
-
Kr,
|
|
5672
|
-
qr,
|
|
5673
|
-
Zr,
|
|
5674
|
-
Qr,
|
|
5675
|
-
$r,
|
|
5676
|
-
Ct,
|
|
5677
|
-
dr,
|
|
5678
|
-
ft,
|
|
5592
|
+
Ie,
|
|
5679
5593
|
Tt,
|
|
5594
|
+
Wr,
|
|
5595
|
+
Gr,
|
|
5596
|
+
$r,
|
|
5597
|
+
ei,
|
|
5680
5598
|
ti,
|
|
5681
|
-
|
|
5682
|
-
si,
|
|
5683
|
-
pe,
|
|
5684
|
-
ci,
|
|
5599
|
+
wt,
|
|
5685
5600
|
fr,
|
|
5686
|
-
|
|
5601
|
+
dt,
|
|
5602
|
+
Et,
|
|
5603
|
+
ri,
|
|
5604
|
+
ci,
|
|
5605
|
+
li,
|
|
5606
|
+
ue,
|
|
5607
|
+
ui,
|
|
5608
|
+
pr,
|
|
5609
|
+
mr
|
|
5687
5610
|
]);
|
|
5688
|
-
var
|
|
5611
|
+
var fi = class e extends Error {
|
|
5689
5612
|
constructor(t, n, r, i, a) {
|
|
5690
5613
|
super(t), this.name = `SvgoParserError`, this.message = `${a || `<input>`}:${n}:${r}: ${t}`, this.reason = t, this.line = n, this.column = r, this.source = i, Error.captureStackTrace && Error.captureStackTrace(this, e);
|
|
5691
5614
|
}
|
|
5692
5615
|
toString() {
|
|
5693
|
-
let e = this.source.split(/\r?\n/), t = Math.max(this.line - 3, 0), n = Math.min(this.line + 2, e.length), r = String(n).length, i = Math.max(this.column - 54, 0), a = Math.max(this.column + 20, 80), o = e.slice(t, n).map((
|
|
5616
|
+
let e = this.source.split(/\r?\n/), t = Math.max(this.line - 3, 0), n = Math.min(this.line + 2, e.length), r = String(n).length, i = Math.max(this.column - 54, 0), a = Math.max(this.column + 20, 80), o = e.slice(t, n).map((e, n) => {
|
|
5694
5617
|
let o = e.slice(i, a), s = ``, c = ``;
|
|
5695
5618
|
i !== 0 && (s = i > e.length - 1 ? ` ` : `…`), a < e.length - 1 && (c = `…`);
|
|
5696
5619
|
let l = t + 1 + n, u = ` ${l.toString().padStart(r)} | `;
|
|
@@ -5699,12 +5622,12 @@ plugins: [
|
|
|
5699
5622
|
return `>${u}${s}${o}${c}\n ${t}^`;
|
|
5700
5623
|
}
|
|
5701
5624
|
return ` ${u}${s}${o}${c}`;
|
|
5702
|
-
})
|
|
5625
|
+
}).join(`
|
|
5703
5626
|
`);
|
|
5704
5627
|
return `${this.name}: ${this.message}\n\n${o}\n`;
|
|
5705
5628
|
}
|
|
5706
5629
|
};
|
|
5707
|
-
let
|
|
5630
|
+
let pi = /<!ENTITY\s+(\S+)\s+(?:'([^']+)'|"([^"]+)")\s*>/g, mi = {
|
|
5708
5631
|
strict: !0,
|
|
5709
5632
|
trim: !1,
|
|
5710
5633
|
normalize: !1,
|
|
@@ -5712,8 +5635,8 @@ plugins: [
|
|
|
5712
5635
|
xmlns: !0,
|
|
5713
5636
|
position: !0,
|
|
5714
5637
|
unparsedEntities: !0
|
|
5715
|
-
},
|
|
5716
|
-
let n =
|
|
5638
|
+
}, hi = (e, t) => {
|
|
5639
|
+
let n = m.parser(mi.strict, mi), r = {
|
|
5717
5640
|
type: `root`,
|
|
5718
5641
|
children: []
|
|
5719
5642
|
}, i = r, a = [r], o = (e) => {
|
|
@@ -5727,9 +5650,9 @@ plugins: [
|
|
|
5727
5650
|
});
|
|
5728
5651
|
let r = t.indexOf(`[`);
|
|
5729
5652
|
if (r >= 0) {
|
|
5730
|
-
|
|
5731
|
-
let t =
|
|
5732
|
-
for (; t != null;) n.ENTITIES[t[1]] = t[2] || t[3], t =
|
|
5653
|
+
pi.lastIndex = r;
|
|
5654
|
+
let t = pi.exec(e);
|
|
5655
|
+
for (; t != null;) n.ENTITIES[t[1]] = t[2] || t[3], t = pi.exec(e);
|
|
5733
5656
|
}
|
|
5734
5657
|
}, n.onprocessinginstruction = (e) => {
|
|
5735
5658
|
let t = {
|
|
@@ -5759,25 +5682,27 @@ plugins: [
|
|
|
5759
5682
|
for (let [n, r] of Object.entries(e.attributes)) t.attributes[n] = r.value;
|
|
5760
5683
|
o(t), i = t, a.push(t);
|
|
5761
5684
|
}, n.ontext = (e) => {
|
|
5762
|
-
if (i.type === `element`)
|
|
5763
|
-
|
|
5764
|
-
value: e
|
|
5765
|
-
});
|
|
5766
|
-
else {
|
|
5767
|
-
let t = e.trim();
|
|
5768
|
-
t !== `` && o({
|
|
5685
|
+
if (i.type === `element`) {
|
|
5686
|
+
if (pe.has(i.name)) o({
|
|
5769
5687
|
type: `text`,
|
|
5770
|
-
value:
|
|
5688
|
+
value: e
|
|
5771
5689
|
});
|
|
5690
|
+
else {
|
|
5691
|
+
let t = e.trim();
|
|
5692
|
+
t !== `` && o({
|
|
5693
|
+
type: `text`,
|
|
5694
|
+
value: t
|
|
5695
|
+
});
|
|
5696
|
+
}
|
|
5772
5697
|
}
|
|
5773
5698
|
}, n.onclosetag = () => {
|
|
5774
5699
|
a.pop(), i = a[a.length - 1];
|
|
5775
5700
|
}, n.onerror = (r) => {
|
|
5776
5701
|
let i = r.message.split(`
|
|
5777
|
-
`)[0], a = new
|
|
5702
|
+
`)[0], a = new fi(i, n.line + 1, n.column, e, t);
|
|
5778
5703
|
if (r.message.indexOf(`Unexpected end`) === -1) throw a;
|
|
5779
5704
|
}, n.write(e).close(), r;
|
|
5780
|
-
},
|
|
5705
|
+
}, Q = {
|
|
5781
5706
|
doctypeStart: `<!DOCTYPE`,
|
|
5782
5707
|
doctypeEnd: `>`,
|
|
5783
5708
|
procInstStart: `<?`,
|
|
@@ -5799,20 +5724,20 @@ plugins: [
|
|
|
5799
5724
|
indent: 4,
|
|
5800
5725
|
regEntities: /[&'"<>]/g,
|
|
5801
5726
|
regValEntities: /[&"<>]/g,
|
|
5802
|
-
encodeEntity: (e) =>
|
|
5727
|
+
encodeEntity: (e) => gi[e],
|
|
5803
5728
|
pretty: !1,
|
|
5804
5729
|
useShortTags: !0,
|
|
5805
5730
|
eol: `lf`,
|
|
5806
5731
|
finalNewline: !1
|
|
5807
|
-
},
|
|
5732
|
+
}, gi = {
|
|
5808
5733
|
"&": `&`,
|
|
5809
5734
|
"'": `'`,
|
|
5810
5735
|
"\"": `"`,
|
|
5811
5736
|
">": `>`,
|
|
5812
5737
|
"<": `<`
|
|
5813
|
-
},
|
|
5738
|
+
}, _i = (e, t = {}) => {
|
|
5814
5739
|
let n = {
|
|
5815
|
-
...
|
|
5740
|
+
...Q,
|
|
5816
5741
|
...t
|
|
5817
5742
|
}, r = n.indent, i = ` `;
|
|
5818
5743
|
typeof r == `number` && Number.isNaN(r) === !1 ? i = r < 0 ? ` ` : ` `.repeat(r) : typeof r == `string` && (i = r);
|
|
@@ -5824,55 +5749,55 @@ plugins: [
|
|
|
5824
5749
|
` : `
|
|
5825
5750
|
`;
|
|
5826
5751
|
n.pretty && (n.doctypeEnd += o, n.procInstEnd += o, n.commentEnd += o, n.cdataEnd += o, n.tagShortEnd += o, n.tagOpenEnd += o, n.tagCloseEnd += o, n.textEnd += o);
|
|
5827
|
-
let s =
|
|
5752
|
+
let s = vi(e, n, a);
|
|
5828
5753
|
return n.finalNewline && s.length > 0 && !s.endsWith(`
|
|
5829
5754
|
`) && (s += o), s;
|
|
5830
|
-
},
|
|
5755
|
+
}, vi = (e, t, n) => {
|
|
5831
5756
|
let r = ``;
|
|
5832
5757
|
n.indentLevel++;
|
|
5833
5758
|
for (let i of e.children) switch (i.type) {
|
|
5834
5759
|
case `element`:
|
|
5835
|
-
r +=
|
|
5760
|
+
r += Ci(i, t, n);
|
|
5836
5761
|
break;
|
|
5837
5762
|
case `text`:
|
|
5838
|
-
r +=
|
|
5763
|
+
r += Ti(i, t, n);
|
|
5839
5764
|
break;
|
|
5840
5765
|
case `doctype`:
|
|
5841
|
-
r +=
|
|
5766
|
+
r += yi(i, t);
|
|
5842
5767
|
break;
|
|
5843
5768
|
case `instruction`:
|
|
5844
|
-
r +=
|
|
5769
|
+
r += bi(i, t);
|
|
5845
5770
|
break;
|
|
5846
5771
|
case `comment`:
|
|
5847
|
-
r +=
|
|
5772
|
+
r += xi(i, t);
|
|
5848
5773
|
break;
|
|
5849
|
-
case `cdata`: r +=
|
|
5774
|
+
case `cdata`: r += Si(i, t, n);
|
|
5850
5775
|
}
|
|
5851
5776
|
return n.indentLevel--, r;
|
|
5852
|
-
},
|
|
5777
|
+
}, $ = (e, t) => {
|
|
5853
5778
|
let n = ``;
|
|
5854
5779
|
return e.pretty && t.textContext == null && (n = t.indent.repeat(t.indentLevel - 1)), n;
|
|
5855
|
-
},
|
|
5856
|
-
if (e.children.length === 0) return t.useShortTags ?
|
|
5857
|
-
let r = t.tagOpenStart, i = t.tagOpenEnd, a = t.tagCloseStart, o = t.tagCloseEnd, s =
|
|
5858
|
-
n.textContext ? (r =
|
|
5859
|
-
let l =
|
|
5860
|
-
return n.textContext === e && (n.textContext = null), s + r + e.name +
|
|
5861
|
-
},
|
|
5780
|
+
}, yi = (e, t) => t.doctypeStart + e.data.doctype + t.doctypeEnd, bi = (e, t) => t.procInstStart + e.name + ` ` + e.value + t.procInstEnd, xi = (e, t) => t.commentStart + e.value + t.commentEnd, Si = (e, t, n) => $(t, n) + t.cdataStart + e.value + t.cdataEnd, Ci = (e, t, n) => {
|
|
5781
|
+
if (e.children.length === 0) return t.useShortTags ? $(t, n) + t.tagShortStart + e.name + wi(e, t) + t.tagShortEnd : $(t, n) + t.tagShortStart + e.name + wi(e, t) + t.tagOpenEnd + t.tagCloseStart + e.name + t.tagCloseEnd;
|
|
5782
|
+
let r = t.tagOpenStart, i = t.tagOpenEnd, a = t.tagCloseStart, o = t.tagCloseEnd, s = $(t, n), c = $(t, n);
|
|
5783
|
+
n.textContext ? (r = Q.tagOpenStart, i = Q.tagOpenEnd, a = Q.tagCloseStart, o = Q.tagCloseEnd, s = ``) : pe.has(e.name) && (i = Q.tagOpenEnd, a = Q.tagCloseStart, c = ``, n.textContext = e);
|
|
5784
|
+
let l = vi(e, t, n);
|
|
5785
|
+
return n.textContext === e && (n.textContext = null), s + r + e.name + wi(e, t) + i + l + c + a + e.name + o;
|
|
5786
|
+
}, wi = (e, t) => {
|
|
5862
5787
|
let n = ``;
|
|
5863
5788
|
for (let [r, i] of Object.entries(e.attributes)) if (n += ` ` + r, i !== void 0) {
|
|
5864
5789
|
let e = i.toString().replace(t.regValEntities, t.encodeEntity);
|
|
5865
5790
|
n += t.attrStart + e + t.attrEnd;
|
|
5866
5791
|
}
|
|
5867
5792
|
return n;
|
|
5868
|
-
},
|
|
5869
|
-
for (let e of
|
|
5870
|
-
function
|
|
5871
|
-
return e === `removeScriptElement` ? (console.warn(`Warning: removeScriptElement has been renamed to removeScripts, please update your SVGO config`),
|
|
5793
|
+
}, Ti = (e, t, n) => $(t, n) + t.textStart + e.value.replace(t.regEntities, t.encodeEntity) + (n.textContext ? `` : t.textEnd), Ei = /* @__PURE__ */ new Map();
|
|
5794
|
+
for (let e of di) Ei.set(e.name, e);
|
|
5795
|
+
function Di(e) {
|
|
5796
|
+
return e === `removeScriptElement` ? (console.warn(`Warning: removeScriptElement has been renamed to removeScripts, please update your SVGO config`), Ei.get(`removeScripts`)) : Ei.get(e);
|
|
5872
5797
|
}
|
|
5873
|
-
let
|
|
5798
|
+
let Oi = (e) => {
|
|
5874
5799
|
if (typeof e == `string`) {
|
|
5875
|
-
let t =
|
|
5800
|
+
let t = Di(e);
|
|
5876
5801
|
if (t == null) throw Error(`Unknown builtin plugin "${e}" specified.`);
|
|
5877
5802
|
return {
|
|
5878
5803
|
name: e,
|
|
@@ -5884,7 +5809,7 @@ plugins: [
|
|
|
5884
5809
|
if (e.name == null) throw Error(`Plugin name must be specified`);
|
|
5885
5810
|
let t = e.fn;
|
|
5886
5811
|
if (t == null) {
|
|
5887
|
-
let n =
|
|
5812
|
+
let n = Di(e.name);
|
|
5888
5813
|
if (n == null) throw Error(`Unknown builtin plugin "${e.name}" specified.`);
|
|
5889
5814
|
t = n.fn;
|
|
5890
5815
|
}
|
|
@@ -5895,56 +5820,56 @@ plugins: [
|
|
|
5895
5820
|
};
|
|
5896
5821
|
}
|
|
5897
5822
|
return null;
|
|
5898
|
-
},
|
|
5823
|
+
}, ki = (e, t) => {
|
|
5899
5824
|
if (t ??= {}, typeof t != `object`) throw Error(`Config should be an object`);
|
|
5900
|
-
let n = t.multipass ? 10 : 1, r =
|
|
5825
|
+
let n = t.multipass ? 10 : 1, r = 1 / 0, i = ``, a = {};
|
|
5901
5826
|
t.path != null && (a.path = t.path);
|
|
5902
5827
|
for (let o = 0; o < n; o += 1) {
|
|
5903
5828
|
a.multipassCount = o;
|
|
5904
|
-
let n =
|
|
5829
|
+
let n = hi(e, t.path), s = t.plugins || [`preset-default`];
|
|
5905
5830
|
if (!Array.isArray(s)) throw Error("malformed config, `plugins` property must be an array.\nSee more info here: https://github.com/svg/svgo#configuration");
|
|
5906
|
-
let c = s.filter((
|
|
5831
|
+
let c = s.filter((e) => e != null).map(Oi);
|
|
5907
5832
|
c.length < s.length && console.warn(`Warning: plugins list includes null or undefined elements, these will be ignored.`);
|
|
5908
5833
|
let l = {};
|
|
5909
|
-
if (t.floatPrecision != null && (l.floatPrecision = t.floatPrecision),
|
|
5834
|
+
if (t.floatPrecision != null && (l.floatPrecision = t.floatPrecision), S(n, a, c, null, l), i = _i(n, t.js2svg), !(i.length < r)) break;
|
|
5910
5835
|
e = i, r = i.length;
|
|
5911
5836
|
}
|
|
5912
|
-
return t.datauri && (i =
|
|
5913
|
-
},
|
|
5914
|
-
let t =
|
|
5837
|
+
return t.datauri && (i = Je(i, t.datauri)), { data: i };
|
|
5838
|
+
}, Ai = async (e) => {
|
|
5839
|
+
let t = l.resolve(e), n = (await import(h.pathToFileURL(t).toString())).default;
|
|
5915
5840
|
if (typeof n != `object` || !n || Array.isArray(n)) throw Error(`Invalid config file "${e}"`);
|
|
5916
5841
|
return n;
|
|
5917
|
-
},
|
|
5842
|
+
}, ji = async (e) => {
|
|
5918
5843
|
try {
|
|
5919
|
-
return (await
|
|
5844
|
+
return (await c.stat(e)).isFile();
|
|
5920
5845
|
} catch {
|
|
5921
5846
|
return !1;
|
|
5922
5847
|
}
|
|
5923
5848
|
};
|
|
5924
|
-
e.VERSION = `4.0
|
|
5925
|
-
if (e != null) return
|
|
5849
|
+
e.VERSION = `4.1.0`, e._collections = we, e.builtinPlugins = di, e.loadConfig = async (e, t = process.cwd()) => {
|
|
5850
|
+
if (e != null) return l.isAbsolute(e) ? Ai(e) : Ai(l.join(t, e));
|
|
5926
5851
|
let n = t;
|
|
5927
5852
|
for (;;) {
|
|
5928
|
-
let e =
|
|
5929
|
-
if (await
|
|
5930
|
-
let t =
|
|
5931
|
-
if (await
|
|
5932
|
-
let r =
|
|
5933
|
-
if (await
|
|
5934
|
-
let i =
|
|
5853
|
+
let e = l.join(n, `svgo.config.js`);
|
|
5854
|
+
if (await ji(e)) return Ai(e);
|
|
5855
|
+
let t = l.join(n, `svgo.config.mjs`);
|
|
5856
|
+
if (await ji(t)) return Ai(t);
|
|
5857
|
+
let r = l.join(n, `svgo.config.cjs`);
|
|
5858
|
+
if (await ji(r)) return Ai(r);
|
|
5859
|
+
let i = l.dirname(n);
|
|
5935
5860
|
if (n === i) return null;
|
|
5936
5861
|
n = i;
|
|
5937
5862
|
}
|
|
5938
|
-
}, e.mapNodesToParents =
|
|
5863
|
+
}, e.mapNodesToParents = C, e.optimize = (e, t) => {
|
|
5939
5864
|
if (t ??= {}, typeof t != `object`) throw Error(`Config should be an object`);
|
|
5940
|
-
return
|
|
5865
|
+
return ki(e, {
|
|
5941
5866
|
...t,
|
|
5942
5867
|
js2svg: {
|
|
5943
|
-
eol:
|
|
5868
|
+
eol: s.EOL === `\r
|
|
5944
5869
|
` ? `crlf` : `lf`,
|
|
5945
5870
|
...t.js2svg
|
|
5946
5871
|
}
|
|
5947
5872
|
});
|
|
5948
|
-
}, e.querySelector =
|
|
5873
|
+
}, e.querySelector = se, e.querySelectorAll = E;
|
|
5949
5874
|
}));
|
|
5950
|
-
export {
|
|
5875
|
+
export { s as require_svgo_node };
|