@terrafirmagreg-team/ui 0.0.0-stage → 1.2.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/package.json +93 -3
- package/src/components/blocks/button/icon-button.tsx +49 -0
- package/src/components/blocks/canvas/chevron-edge.tsx +242 -0
- package/src/components/blocks/canvas/flow-canvas.tsx +181 -0
- package/src/components/blocks/canvas/flow-toolbar.tsx +33 -0
- package/src/components/blocks/canvas/flow-viewport.tsx +244 -0
- package/src/components/blocks/fit-box.tsx +26 -0
- package/src/components/blocks/git/github-info.tsx +78 -0
- package/src/components/blocks/lang/content.tsx +52 -0
- package/src/components/blocks/lang/flag.tsx +25 -0
- package/src/components/blocks/lang/link.tsx +23 -0
- package/src/components/blocks/lang/redirect.tsx +48 -0
- package/src/components/blocks/lang/switcher.tsx +54 -0
- package/src/components/blocks/lang/untranslated-callout.tsx +29 -0
- package/src/components/blocks/lang/untranslated-chip.tsx +53 -0
- package/src/components/blocks/link/link-preview.tsx +257 -0
- package/src/components/blocks/list/row.tsx +92 -0
- package/src/components/blocks/media/glb/model.tsx +244 -0
- package/src/components/blocks/media/glb/scene.tsx +373 -0
- package/src/components/blocks/media/glb/viewer.tsx +52 -0
- package/src/components/blocks/media/image.tsx +136 -0
- package/src/components/blocks/media/slideshow.tsx +178 -0
- package/src/components/blocks/nav/breadcrumb.tsx +51 -0
- package/src/components/blocks/nav/copy-menu.tsx +37 -0
- package/src/components/blocks/nav/link.tsx +86 -0
- package/src/components/blocks/nav/site-menu.tsx +78 -0
- package/src/components/blocks/nav/site-title.tsx +61 -0
- package/src/components/blocks/nav/switcher.tsx +206 -0
- package/src/components/blocks/page/empty-state.tsx +32 -0
- package/src/components/blocks/page/heading.tsx +54 -0
- package/src/components/blocks/page/pager.tsx +220 -0
- package/src/components/blocks/readability/fields.tsx +250 -0
- package/src/components/blocks/readability/menu.tsx +247 -0
- package/src/components/blocks/readability/track.tsx +165 -0
- package/src/components/blocks/search/command.tsx +80 -0
- package/src/components/blocks/search/dialog.tsx +724 -0
- package/src/components/blocks/search/provider.tsx +118 -0
- package/src/components/blocks/sidebar.tsx +406 -0
- package/src/components/blocks/sprite.tsx +231 -0
- package/src/components/blocks/text/format-text.tsx +110 -0
- package/src/components/blocks/theme/toggle.tsx +75 -0
- package/src/components/blocks/tooltip/hint.tsx +28 -0
- package/src/components/blocks/tooltip/lazy.tsx +41 -0
- package/src/components/blocks/viewer/controls.tsx +284 -0
- package/src/components/blocks/viewer/float-bar.tsx +51 -0
- package/src/components/layouts/layout.tsx +94 -0
- package/src/components/layouts/left-sidebar/content.tsx +63 -0
- package/src/components/layouts/left-sidebar/context.tsx +55 -0
- package/src/components/layouts/left-sidebar/expand.tsx +23 -0
- package/src/components/layouts/left-sidebar/footer.tsx +111 -0
- package/src/components/layouts/left-sidebar/index.ts +29 -0
- package/src/components/layouts/left-sidebar/items.tsx +103 -0
- package/src/components/layouts/left-sidebar/search.tsx +75 -0
- package/src/components/layouts/left-sidebar/sidebar.tsx +189 -0
- package/src/components/layouts/left-sidebar/tree.tsx +157 -0
- package/src/components/layouts/right-sidebar.tsx +96 -0
- package/src/components/layouts/tree-context.tsx +42 -0
- package/src/components/mdx/accordion.tsx +185 -0
- package/src/components/mdx/banner.tsx +157 -0
- package/src/components/mdx/callout.tsx +97 -0
- package/src/components/mdx/card.tsx +56 -0
- package/src/components/mdx/codeblock.tsx +250 -0
- package/src/components/mdx/collapsible.tsx +33 -0
- package/src/components/mdx/files.tsx +63 -0
- package/src/components/mdx/glow-header.tsx +54 -0
- package/src/components/mdx/gradient-text.tsx +28 -0
- package/src/components/mdx/icon.tsx +35 -0
- package/src/components/mdx/image-zoom.tsx +315 -0
- package/src/components/mdx/math.tsx +30 -0
- package/src/components/mdx/mermaid.tsx +23 -0
- package/src/components/mdx/multiblock.tsx +19 -0
- package/src/components/mdx/preview.tsx +101 -0
- package/src/components/mdx/steps.tsx +10 -0
- package/src/components/mdx/table.tsx +14 -0
- package/src/components/mdx/tabs.tsx +354 -0
- package/src/components/mdx/type-table.tsx +171 -0
- package/src/components/provider.tsx +139 -0
- package/src/components/ui/accordion.tsx +71 -0
- package/src/components/ui/alert-dialog.tsx +187 -0
- package/src/components/ui/alert.tsx +75 -0
- package/src/components/ui/aspect-ratio.tsx +22 -0
- package/src/components/ui/attachment.tsx +207 -0
- package/src/components/ui/avatar.tsx +108 -0
- package/src/components/ui/badge.tsx +51 -0
- package/src/components/ui/breadcrumb.tsx +124 -0
- package/src/components/ui/bubble.tsx +127 -0
- package/src/components/ui/button-group.tsx +87 -0
- package/src/components/ui/button.tsx +57 -0
- package/src/components/ui/calendar.tsx +221 -0
- package/src/components/ui/card.tsx +102 -0
- package/src/components/ui/carousel.tsx +242 -0
- package/src/components/ui/chart.tsx +371 -0
- package/src/components/ui/checkbox.tsx +28 -0
- package/src/components/ui/collapsible.tsx +21 -0
- package/src/components/ui/combobox.tsx +297 -0
- package/src/components/ui/command.tsx +198 -0
- package/src/components/ui/context-menu.tsx +270 -0
- package/src/components/ui/dialog.tsx +160 -0
- package/src/components/ui/direction.tsx +6 -0
- package/src/components/ui/drawer.tsx +227 -0
- package/src/components/ui/dropdown-menu.tsx +269 -0
- package/src/components/ui/empty.tsx +103 -0
- package/src/components/ui/field.tsx +238 -0
- package/src/components/ui/hover-card.tsx +50 -0
- package/src/components/ui/input-group.tsx +158 -0
- package/src/components/ui/input-otp.tsx +86 -0
- package/src/components/ui/input.tsx +19 -0
- package/src/components/ui/item.tsx +201 -0
- package/src/components/ui/kbd.tsx +26 -0
- package/src/components/ui/label.tsx +19 -0
- package/src/components/ui/marker.tsx +70 -0
- package/src/components/ui/menubar.tsx +280 -0
- package/src/components/ui/message-scroller.tsx +131 -0
- package/src/components/ui/message.tsx +91 -0
- package/src/components/ui/native-select.tsx +60 -0
- package/src/components/ui/navigation-menu.tsx +167 -0
- package/src/components/ui/pagination.tsx +130 -0
- package/src/components/ui/popover.tsx +91 -0
- package/src/components/ui/progress.tsx +82 -0
- package/src/components/ui/questionnaire.tsx +324 -0
- package/src/components/ui/radio-group.tsx +37 -0
- package/src/components/ui/resizable.tsx +49 -0
- package/src/components/ui/scroll-area.tsx +54 -0
- package/src/components/ui/select.tsx +200 -0
- package/src/components/ui/separator.tsx +24 -0
- package/src/components/ui/sheet.tsx +138 -0
- package/src/components/ui/sidebar.tsx +730 -0
- package/src/components/ui/skeleton.tsx +13 -0
- package/src/components/ui/slider.tsx +51 -0
- package/src/components/ui/spinner.tsx +10 -0
- package/src/components/ui/switch.tsx +31 -0
- package/src/components/ui/table.tsx +115 -0
- package/src/components/ui/tabs.tsx +81 -0
- package/src/components/ui/textarea.tsx +17 -0
- package/src/components/ui/toast.tsx +234 -0
- package/src/components/ui/toggle-group.tsx +89 -0
- package/src/components/ui/toggle.tsx +44 -0
- package/src/components/ui/tooltip.tsx +65 -0
- package/src/hooks/canvas/use-flow-hover.ts +19 -0
- package/src/hooks/canvas/use-flow-viewport-persist.ts +34 -0
- package/src/hooks/page/use-fit-pages.ts +92 -0
- package/src/hooks/page/use-location-search.ts +31 -0
- package/src/hooks/page/use-page-preview.ts +41 -0
- package/src/hooks/page/use-paged-list.ts +21 -0
- package/src/hooks/readability/use-readability.ts +87 -0
- package/src/hooks/search/use-dialog.ts +42 -0
- package/src/hooks/search/use-highlight-query.ts +58 -0
- package/src/hooks/search/use-provider.ts +26 -0
- package/src/hooks/use-async-value.ts +60 -0
- package/src/hooks/use-close-on-scroll.ts +24 -0
- package/src/hooks/use-copy-button.ts +47 -0
- package/src/hooks/use-cycle-index.ts +76 -0
- package/src/hooks/use-document-title.ts +10 -0
- package/src/hooks/use-element-size.ts +36 -0
- package/src/hooks/use-external-meta.ts +133 -0
- package/src/hooks/use-hot-key.ts +34 -0
- package/src/hooks/use-hover-follow.ts +55 -0
- package/src/hooks/use-in-view.ts +31 -0
- package/src/hooks/use-lang.ts +9 -0
- package/src/hooks/use-last-value.ts +16 -0
- package/src/hooks/use-layout.ts +19 -0
- package/src/hooks/use-marquee.ts +52 -0
- package/src/hooks/use-media-query.ts +15 -0
- package/src/hooks/use-mobile.ts +20 -0
- package/src/hooks/use-modifier-keys.ts +32 -0
- package/src/hooks/use-on-change.ts +36 -0
- package/src/hooks/use-pane-keys.ts +29 -0
- package/src/hooks/use-sidebar.ts +64 -0
- package/src/hooks/use-swipe.ts +27 -0
- package/src/hooks/use-tree.ts +100 -0
- package/src/hooks/viewer/use-in-float-bar.ts +7 -0
- package/src/hooks/viewer/use-viewer-prefs.ts +78 -0
- package/src/lib/canvas/edge.ts +202 -0
- package/src/lib/canvas/geometry.ts +54 -0
- package/src/lib/canvas/state.ts +48 -0
- package/src/lib/canvas/viewport.ts +38 -0
- package/src/lib/canvas/xyflow.ts +2 -0
- package/src/lib/config.ts +106 -0
- package/src/lib/mdx/callout.ts +21 -0
- package/src/lib/mdx/gradient.ts +16 -0
- package/src/lib/mdx/mermaid.ts +15 -0
- package/src/lib/media/crop-opaque.ts +77 -0
- package/src/lib/media/nearby-indexes.ts +7 -0
- package/src/lib/media/trim-transparent.ts +118 -0
- package/src/lib/readability/config.ts +11 -0
- package/src/lib/readability/spotlight.ts +187 -0
- package/src/lib/readability/store.ts +147 -0
- package/src/lib/tree.ts +90 -0
- package/src/lib/utils/cn.ts +2 -0
- package/src/lib/utils/format.ts +22 -0
- package/src/lib/utils/highlight-style.ts +10 -0
- package/src/lib/utils/history.ts +10 -0
- package/src/lib/utils/merge-refs.ts +14 -0
- package/src/lib/utils/nav-active.ts +59 -0
- package/src/lib/utils/stored-value.ts +137 -0
- package/src/lib/utils/urls.ts +18 -0
- package/src/locales/en_us.json +110 -0
- package/src/locales/pl_pl.json +33 -0
- package/src/locales/ru_ru.json +110 -0
- package/src/locales/uk_ua.json +33 -0
- package/src/locales/zh_cn.json +15 -0
- package/src/locales/zh_tw.json +15 -0
- package/src/locales.ts +6 -0
- package/src/types/canvas.ts +54 -0
- package/src/types/glb.ts +26 -0
- package/src/types/mdx-directives.ts +106 -0
- package/src/types/nav.ts +96 -0
- package/src/types/preview.ts +15 -0
- package/src/types/readability.ts +29 -0
- package/src/types/search.ts +57 -0
- package/src/types/tree.ts +19 -0
- package/src/types/viewer.ts +54 -0
- package/styles/content/base.css +198 -0
- package/styles/content/default-colors.css +51 -0
- package/styles/content/shiki.css +107 -0
- package/styles/content/typography.mjs +3637 -0
- package/styles/content.css +5 -0
- package/styles/image-zoom.css +83 -0
- package/styles/layout.css +28 -0
- package/styles/left-sidebar.css +140 -0
- package/styles/readability.css +50 -0
- package/styles/right-sidebar.css +6 -0
- package/styles/workspace.css +26 -0
- package/styles.css +430 -0
- package/README.md +0 -3
|
@@ -0,0 +1,3637 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import plugin from "tailwindcss/plugin";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
|
+
key = keys[i];
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
21
|
+
value: mod,
|
|
22
|
+
enumerable: true
|
|
23
|
+
}) : target, mod));
|
|
24
|
+
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
25
|
+
function round(num) {
|
|
26
|
+
return num.toFixed(7).replace(/(\.[0-9]+?)0+$/, "$1").replace(/\.0$/, "");
|
|
27
|
+
}
|
|
28
|
+
function scaled(value) {
|
|
29
|
+
return `calc(${value} * var(--tw-prose-size))`;
|
|
30
|
+
}
|
|
31
|
+
function scaledPx(value) {
|
|
32
|
+
return scaled(`${round(value)}px`);
|
|
33
|
+
}
|
|
34
|
+
function rem(px) {
|
|
35
|
+
return `${round(px / 16)}rem`;
|
|
36
|
+
}
|
|
37
|
+
function scaledRem(px) {
|
|
38
|
+
return scaled(rem(px));
|
|
39
|
+
}
|
|
40
|
+
function em(px, base) {
|
|
41
|
+
return `${round(px / base)}em`;
|
|
42
|
+
}
|
|
43
|
+
const colors = {
|
|
44
|
+
"--tw-prose-body": "color-mix(in oklab, var(--color-foreground) 90%, transparent)",
|
|
45
|
+
"--tw-prose-headings": "var(--color-foreground)",
|
|
46
|
+
"--tw-prose-lead": `var(--color-foreground)`,
|
|
47
|
+
"--tw-prose-links": `var(--color-foreground)`,
|
|
48
|
+
"--tw-prose-bold": `var(--color-foreground)`,
|
|
49
|
+
"--tw-prose-counters": `var(--color-muted-foreground)`,
|
|
50
|
+
"--tw-prose-bullets": `var(--color-muted-foreground)`,
|
|
51
|
+
"--tw-prose-hr": `var(--color-border)`,
|
|
52
|
+
"--tw-prose-quotes": `var(--color-foreground)`,
|
|
53
|
+
"--tw-prose-quote-borders": `var(--color-border)`,
|
|
54
|
+
"--tw-prose-captions": `var(--color-foreground)`,
|
|
55
|
+
"--tw-prose-code": `var(--color-foreground)`,
|
|
56
|
+
"--tw-prose-th-borders": `var(--color-border)`,
|
|
57
|
+
"--tw-prose-td-borders": `var(--color-border)`,
|
|
58
|
+
"--tw-prose-kbd": `var(--color-foreground)`,
|
|
59
|
+
"--tw-prose-kbd-shadows": `color-mix(in oklab, var(--color-primary) 50%, transparent)`
|
|
60
|
+
};
|
|
61
|
+
const roundedTable = {
|
|
62
|
+
table: {
|
|
63
|
+
borderCollapse: "separate",
|
|
64
|
+
borderSpacing: "0",
|
|
65
|
+
background: "var(--color-card)",
|
|
66
|
+
borderRadius: "var(--radius-lg)",
|
|
67
|
+
border: "1px solid var(--color-border)",
|
|
68
|
+
overflow: "hidden"
|
|
69
|
+
},
|
|
70
|
+
th: {
|
|
71
|
+
textAlign: "start",
|
|
72
|
+
padding: scaled("var(--spacing) * 2.5"),
|
|
73
|
+
"border-inline-start": "1px solid var(--color-border)",
|
|
74
|
+
background: "var(--color-muted)"
|
|
75
|
+
},
|
|
76
|
+
"th:first-child": { "border-inline-start": "none" },
|
|
77
|
+
"th:not(tr:last-child *), td:not(tr:last-child *)": { "border-bottom": "1px solid var(--color-border)" },
|
|
78
|
+
td: {
|
|
79
|
+
textAlign: "start",
|
|
80
|
+
"border-inline-start": "1px solid var(--color-border)",
|
|
81
|
+
padding: scaled("var(--spacing) * 2.5")
|
|
82
|
+
},
|
|
83
|
+
"td:first-child": { "border-inline-start": "none" },
|
|
84
|
+
"tfoot th, tfoot td": {
|
|
85
|
+
borderTopWidth: "1px",
|
|
86
|
+
borderTopColor: "var(--tw-prose-th-borders)"
|
|
87
|
+
},
|
|
88
|
+
"thead th, thead td": {
|
|
89
|
+
borderBottomWidth: "1px",
|
|
90
|
+
borderBottomColor: "var(--tw-prose-th-borders)"
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
const normalTable = {
|
|
94
|
+
thead: {
|
|
95
|
+
borderBottomWidth: "1px",
|
|
96
|
+
borderBottomColor: "var(--tw-prose-th-borders)"
|
|
97
|
+
},
|
|
98
|
+
"thead th": {
|
|
99
|
+
verticalAlign: "bottom",
|
|
100
|
+
paddingInlineEnd: em(8, 14),
|
|
101
|
+
paddingBottom: em(8, 14),
|
|
102
|
+
paddingInlineStart: em(8, 14)
|
|
103
|
+
},
|
|
104
|
+
"thead th:first-child": { paddingInlineStart: "0" },
|
|
105
|
+
"thead th:last-child": { paddingInlineEnd: "0" },
|
|
106
|
+
"tbody td, tfoot td": {
|
|
107
|
+
paddingTop: em(8, 14),
|
|
108
|
+
paddingInlineEnd: em(8, 14),
|
|
109
|
+
paddingBottom: em(8, 14),
|
|
110
|
+
paddingInlineStart: em(8, 14)
|
|
111
|
+
},
|
|
112
|
+
"tbody td:first-child, tfoot td:first-child": { paddingInlineStart: "0" },
|
|
113
|
+
"tbody td:last-child, tfoot td:last-child": { paddingInlineEnd: "0" },
|
|
114
|
+
"tbody tr": {
|
|
115
|
+
borderBottomWidth: "1px",
|
|
116
|
+
borderBottomColor: "var(--tw-prose-td-borders)"
|
|
117
|
+
},
|
|
118
|
+
"tbody tr:last-child": { borderBottomWidth: "0" },
|
|
119
|
+
"tbody td": { verticalAlign: "baseline" },
|
|
120
|
+
tfoot: {
|
|
121
|
+
borderTopWidth: "1px",
|
|
122
|
+
borderTopColor: "var(--tw-prose-th-borders)"
|
|
123
|
+
},
|
|
124
|
+
"tfoot td": { verticalAlign: "top" },
|
|
125
|
+
"th, td": { textAlign: "start" }
|
|
126
|
+
};
|
|
127
|
+
const DEFAULT = { css: [
|
|
128
|
+
{
|
|
129
|
+
"--tw-prose-size": "1",
|
|
130
|
+
color: "var(--tw-prose-body)",
|
|
131
|
+
maxWidth: "none",
|
|
132
|
+
fontSize: scaledRem(16),
|
|
133
|
+
lineHeight: `var(--tw-leading, ${scaledRem(28)})`,
|
|
134
|
+
"[class~=\"lead\"]": {
|
|
135
|
+
fontSize: em(20, 16),
|
|
136
|
+
lineHeight: round(32 / 20),
|
|
137
|
+
marginTop: em(24, 20),
|
|
138
|
+
marginBottom: em(24, 20),
|
|
139
|
+
color: "var(--tw-prose-lead)"
|
|
140
|
+
},
|
|
141
|
+
ul: {
|
|
142
|
+
paddingInlineStart: scaledRem(16),
|
|
143
|
+
listStyleType: "disc",
|
|
144
|
+
marginTop: em(20, 16),
|
|
145
|
+
marginBottom: em(20, 16)
|
|
146
|
+
},
|
|
147
|
+
li: {
|
|
148
|
+
marginTop: em(8, 16),
|
|
149
|
+
marginBottom: em(8, 16)
|
|
150
|
+
},
|
|
151
|
+
"ol > li": { paddingInlineStart: em(6, 16) },
|
|
152
|
+
"ul > li": { paddingInlineStart: "0" },
|
|
153
|
+
"> ul > li p": {
|
|
154
|
+
marginTop: em(12, 16),
|
|
155
|
+
marginBottom: em(12, 16)
|
|
156
|
+
},
|
|
157
|
+
"> ul > li > p:first-child": { marginTop: em(20, 16) },
|
|
158
|
+
"> ul > li > p:last-child": { marginBottom: em(20, 16) },
|
|
159
|
+
"> ol > li > p:first-child": { marginTop: em(20, 16) },
|
|
160
|
+
"> ol > li > p:last-child": { marginBottom: em(20, 16) },
|
|
161
|
+
"ul ul, ul ol, ol ul, ol ol": {
|
|
162
|
+
marginTop: em(12, 16),
|
|
163
|
+
marginBottom: em(12, 16)
|
|
164
|
+
},
|
|
165
|
+
dl: {
|
|
166
|
+
marginTop: em(20, 16),
|
|
167
|
+
marginBottom: em(20, 16)
|
|
168
|
+
},
|
|
169
|
+
dt: {
|
|
170
|
+
color: "var(--tw-prose-headings)",
|
|
171
|
+
fontWeight: "600",
|
|
172
|
+
marginTop: em(20, 16)
|
|
173
|
+
},
|
|
174
|
+
dd: {
|
|
175
|
+
marginTop: em(8, 16),
|
|
176
|
+
paddingInlineStart: em(26, 16)
|
|
177
|
+
},
|
|
178
|
+
hr: {
|
|
179
|
+
borderColor: "var(--tw-prose-hr)",
|
|
180
|
+
borderTopWidth: "1px",
|
|
181
|
+
marginTop: em(48, 16),
|
|
182
|
+
marginBottom: em(48, 16)
|
|
183
|
+
},
|
|
184
|
+
p: {
|
|
185
|
+
marginTop: em(20, 16),
|
|
186
|
+
marginBottom: em(20, 16)
|
|
187
|
+
},
|
|
188
|
+
strong: {
|
|
189
|
+
color: "var(--tw-prose-bold)",
|
|
190
|
+
fontWeight: "500"
|
|
191
|
+
},
|
|
192
|
+
"a strong": { color: "inherit" },
|
|
193
|
+
"blockquote strong": { color: "inherit" },
|
|
194
|
+
"thead th strong": { color: "inherit" },
|
|
195
|
+
ol: {
|
|
196
|
+
listStyleType: "decimal",
|
|
197
|
+
marginTop: em(20, 16),
|
|
198
|
+
marginBottom: em(20, 16),
|
|
199
|
+
paddingInlineStart: em(26, 16)
|
|
200
|
+
},
|
|
201
|
+
"ol[type=\"A\"]": { listStyleType: "upper-alpha" },
|
|
202
|
+
"ol[type=\"a\"]": { listStyleType: "lower-alpha" },
|
|
203
|
+
"ol[type=\"A\" s]": { listStyleType: "upper-alpha" },
|
|
204
|
+
"ol[type=\"a\" s]": { listStyleType: "lower-alpha" },
|
|
205
|
+
"ol[type=\"I\"]": { listStyleType: "upper-roman" },
|
|
206
|
+
"ol[type=\"i\"]": { listStyleType: "lower-roman" },
|
|
207
|
+
"ol[type=\"I\" s]": { listStyleType: "upper-roman" },
|
|
208
|
+
"ol[type=\"i\" s]": { listStyleType: "lower-roman" },
|
|
209
|
+
"ol[type=\"1\"]": { listStyleType: "decimal" },
|
|
210
|
+
"ol > li::marker": {
|
|
211
|
+
fontWeight: "400",
|
|
212
|
+
color: "var(--tw-prose-counters)"
|
|
213
|
+
},
|
|
214
|
+
"ul > li::marker": { color: "var(--tw-prose-bullets)" },
|
|
215
|
+
blockquote: {
|
|
216
|
+
marginTop: em(32, 20),
|
|
217
|
+
marginBottom: em(32, 20),
|
|
218
|
+
paddingInlineStart: em(20, 20),
|
|
219
|
+
fontWeight: "500",
|
|
220
|
+
fontStyle: "italic",
|
|
221
|
+
color: "var(--tw-prose-quotes)",
|
|
222
|
+
borderInlineStartWidth: "0.25rem",
|
|
223
|
+
borderInlineStartColor: "var(--tw-prose-quote-borders)",
|
|
224
|
+
quotes: "\"\\201C\"\"\\201D\"\"\\2018\"\"\\2019\""
|
|
225
|
+
},
|
|
226
|
+
"blockquote p:first-of-type::before": { content: "open-quote" },
|
|
227
|
+
"blockquote p:last-of-type::after": { content: "close-quote" },
|
|
228
|
+
h1: {
|
|
229
|
+
color: "var(--tw-prose-headings)",
|
|
230
|
+
fontWeight: "800",
|
|
231
|
+
fontSize: scaled("var(--text-3xl)"),
|
|
232
|
+
marginTop: "0",
|
|
233
|
+
marginBottom: em(32, 36),
|
|
234
|
+
lineHeight: round(40 / 36)
|
|
235
|
+
},
|
|
236
|
+
"h1 strong": {
|
|
237
|
+
fontWeight: "900",
|
|
238
|
+
color: "inherit"
|
|
239
|
+
},
|
|
240
|
+
h2: {
|
|
241
|
+
color: "var(--tw-prose-headings)",
|
|
242
|
+
fontSize: em(24, 16),
|
|
243
|
+
marginTop: em(48, 24),
|
|
244
|
+
marginBottom: em(24, 24),
|
|
245
|
+
lineHeight: round(32 / 24),
|
|
246
|
+
fontWeight: "600"
|
|
247
|
+
},
|
|
248
|
+
"h2 strong": {
|
|
249
|
+
fontWeight: "800",
|
|
250
|
+
color: "inherit"
|
|
251
|
+
},
|
|
252
|
+
h3: {
|
|
253
|
+
color: "var(--tw-prose-headings)",
|
|
254
|
+
fontWeight: "600",
|
|
255
|
+
fontSize: em(20, 16),
|
|
256
|
+
marginTop: em(32, 20),
|
|
257
|
+
marginBottom: em(12, 20),
|
|
258
|
+
lineHeight: round(32 / 20)
|
|
259
|
+
},
|
|
260
|
+
"h3 strong": {
|
|
261
|
+
fontWeight: "700",
|
|
262
|
+
color: "inherit"
|
|
263
|
+
},
|
|
264
|
+
h4: {
|
|
265
|
+
color: "var(--tw-prose-headings)",
|
|
266
|
+
fontWeight: "600",
|
|
267
|
+
marginTop: em(24, 16),
|
|
268
|
+
marginBottom: em(8, 16),
|
|
269
|
+
lineHeight: round(24 / 16)
|
|
270
|
+
},
|
|
271
|
+
"h4 strong": {
|
|
272
|
+
fontWeight: "700",
|
|
273
|
+
color: "inherit"
|
|
274
|
+
},
|
|
275
|
+
"hr + *": { marginTop: "0" },
|
|
276
|
+
"h2 + *": { marginTop: "0" },
|
|
277
|
+
"h3 + *": { marginTop: "0" },
|
|
278
|
+
"h4 + *": { marginTop: "0" },
|
|
279
|
+
img: {
|
|
280
|
+
marginTop: em(32, 16),
|
|
281
|
+
marginBottom: em(32, 16)
|
|
282
|
+
},
|
|
283
|
+
picture: {
|
|
284
|
+
display: "block",
|
|
285
|
+
marginTop: em(32, 16),
|
|
286
|
+
marginBottom: em(32, 16)
|
|
287
|
+
},
|
|
288
|
+
"picture > img": {
|
|
289
|
+
marginTop: "0",
|
|
290
|
+
marginBottom: "0"
|
|
291
|
+
},
|
|
292
|
+
video: {
|
|
293
|
+
marginTop: em(32, 16),
|
|
294
|
+
marginBottom: em(32, 16)
|
|
295
|
+
},
|
|
296
|
+
kbd: {
|
|
297
|
+
fontSize: em(14, 16),
|
|
298
|
+
borderRadius: rem(5),
|
|
299
|
+
paddingTop: em(3, 16),
|
|
300
|
+
paddingInlineEnd: em(6, 16),
|
|
301
|
+
paddingBottom: em(3, 16),
|
|
302
|
+
paddingInlineStart: em(6, 16),
|
|
303
|
+
fontWeight: "500",
|
|
304
|
+
fontFamily: "inherit",
|
|
305
|
+
color: "var(--tw-prose-kbd)",
|
|
306
|
+
boxShadow: "0 0 0 1px var(--tw-prose-kbd-shadows),0 3px 0 var(--tw-prose-kbd-shadows)"
|
|
307
|
+
},
|
|
308
|
+
code: {
|
|
309
|
+
padding: scaledPx(3),
|
|
310
|
+
border: "solid 1px",
|
|
311
|
+
fontSize: scaledPx(13),
|
|
312
|
+
borderColor: `var(--color-border)`,
|
|
313
|
+
borderRadius: "5px",
|
|
314
|
+
fontWeight: "400",
|
|
315
|
+
background: `var(--color-muted)`,
|
|
316
|
+
color: "var(--tw-prose-code)"
|
|
317
|
+
},
|
|
318
|
+
"a code": { color: "inherit" },
|
|
319
|
+
"h1 code": {
|
|
320
|
+
color: "inherit",
|
|
321
|
+
fontSize: scaled("var(--text-2xl)")
|
|
322
|
+
},
|
|
323
|
+
"h2 code": {
|
|
324
|
+
color: "inherit",
|
|
325
|
+
fontSize: em(21, 24)
|
|
326
|
+
},
|
|
327
|
+
"h3 code": {
|
|
328
|
+
color: "inherit",
|
|
329
|
+
fontSize: em(18, 20)
|
|
330
|
+
},
|
|
331
|
+
"h4 code": { color: "inherit" },
|
|
332
|
+
"blockquote code": { color: "inherit" },
|
|
333
|
+
"thead th code": { color: "inherit" },
|
|
334
|
+
table: {
|
|
335
|
+
fontSize: em(14, 16),
|
|
336
|
+
lineHeight: round(24 / 14),
|
|
337
|
+
width: "100%",
|
|
338
|
+
tableLayout: "auto",
|
|
339
|
+
marginTop: em(32, 16),
|
|
340
|
+
marginBottom: em(32, 16)
|
|
341
|
+
},
|
|
342
|
+
"thead th": {
|
|
343
|
+
color: "var(--tw-prose-headings)",
|
|
344
|
+
fontWeight: "600"
|
|
345
|
+
},
|
|
346
|
+
figure: {
|
|
347
|
+
marginTop: em(32, 16),
|
|
348
|
+
marginBottom: em(32, 16)
|
|
349
|
+
},
|
|
350
|
+
"figure > *": {
|
|
351
|
+
marginTop: "0",
|
|
352
|
+
marginBottom: "0"
|
|
353
|
+
},
|
|
354
|
+
figcaption: {
|
|
355
|
+
color: "var(--tw-prose-captions)",
|
|
356
|
+
fontSize: em(14, 16),
|
|
357
|
+
lineHeight: round(20 / 14),
|
|
358
|
+
marginTop: em(12, 14)
|
|
359
|
+
},
|
|
360
|
+
"a:not([data-card])": {
|
|
361
|
+
color: "var(--tw-prose-links)",
|
|
362
|
+
transition: "opacity .2s",
|
|
363
|
+
fontWeight: "500",
|
|
364
|
+
textDecoration: "underline",
|
|
365
|
+
textUnderlineOffset: "3.5px",
|
|
366
|
+
textDecorationColor: "var(--color-primary)",
|
|
367
|
+
textDecorationThickness: "1.5px"
|
|
368
|
+
},
|
|
369
|
+
"a:not([data-card]):hover": { opacity: "80%" }
|
|
370
|
+
},
|
|
371
|
+
colors,
|
|
372
|
+
{
|
|
373
|
+
"> :first-child": { marginTop: "0" },
|
|
374
|
+
"> :last-child": { marginBottom: "0" },
|
|
375
|
+
"blockquote > :first-child": { marginTop: "0" },
|
|
376
|
+
"blockquote > :last-child": { marginBottom: "0" }
|
|
377
|
+
}
|
|
378
|
+
] };
|
|
379
|
+
const smallWeights = { "dt, strong, blockquote, h1, h2, h3, h4, kbd, thead th, a:not([data-card])": { fontWeight: "450" } };
|
|
380
|
+
const SMALL = { css: [{
|
|
381
|
+
"--tw-prose-size": "0.875",
|
|
382
|
+
lineHeight: `var(--tw-leading, ${rem(20)})`
|
|
383
|
+
}, smallWeights] };
|
|
384
|
+
const EXTRA_SMALL = { css: [{
|
|
385
|
+
"--tw-prose-size": "0.75",
|
|
386
|
+
lineHeight: `var(--tw-leading, ${rem(16)})`
|
|
387
|
+
}, smallWeights] };
|
|
388
|
+
var require_deepmerge = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
389
|
+
const JSON_PROTO = Object.getPrototypeOf({});
|
|
390
|
+
function defaultIsMergeableObjectFactory() {
|
|
391
|
+
return function defaultIsMergeableObject(value) {
|
|
392
|
+
return typeof value === "object" && value !== null && !(value instanceof RegExp) && !(value instanceof Date);
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
function deepmergeConstructor(options) {
|
|
396
|
+
function isNotPrototypeKey(value) {
|
|
397
|
+
return value !== "constructor" && value !== "prototype" && value !== "__proto__";
|
|
398
|
+
}
|
|
399
|
+
function cloneArray(value) {
|
|
400
|
+
let i = 0;
|
|
401
|
+
const il = value.length;
|
|
402
|
+
const result = new Array(il);
|
|
403
|
+
for (; i < il; ++i) result[i] = clone(value[i]);
|
|
404
|
+
return result;
|
|
405
|
+
}
|
|
406
|
+
function cloneObject(target) {
|
|
407
|
+
const result = {};
|
|
408
|
+
if (cloneProtoObject && Object.getPrototypeOf(target) !== JSON_PROTO) return cloneProtoObject(target);
|
|
409
|
+
const targetKeys = getKeys(target);
|
|
410
|
+
let i, il, key;
|
|
411
|
+
for (i = 0, il = targetKeys.length; i < il; ++i) isNotPrototypeKey(key = targetKeys[i]) && (result[key] = clone(target[key]));
|
|
412
|
+
return result;
|
|
413
|
+
}
|
|
414
|
+
function concatArrays(target, source) {
|
|
415
|
+
const tl = target.length;
|
|
416
|
+
const sl = source.length;
|
|
417
|
+
let i = 0;
|
|
418
|
+
const result = new Array(tl + sl);
|
|
419
|
+
for (; i < tl; ++i) result[i] = clone(target[i]);
|
|
420
|
+
for (i = 0; i < sl; ++i) result[i + tl] = clone(source[i]);
|
|
421
|
+
return result;
|
|
422
|
+
}
|
|
423
|
+
const propertyIsEnumerable = Object.prototype.propertyIsEnumerable;
|
|
424
|
+
function getSymbolsAndKeys(value) {
|
|
425
|
+
const result = Object.keys(value);
|
|
426
|
+
const keys = Object.getOwnPropertySymbols(value);
|
|
427
|
+
for (let i = 0, il = keys.length; i < il; ++i) propertyIsEnumerable.call(value, keys[i]) && result.push(keys[i]);
|
|
428
|
+
return result;
|
|
429
|
+
}
|
|
430
|
+
const getKeys = options?.symbols ? getSymbolsAndKeys : Object.keys;
|
|
431
|
+
const cloneProtoObject = typeof options?.cloneProtoObject === "function" ? options.cloneProtoObject : void 0;
|
|
432
|
+
const isMergeableObject = typeof options?.isMergeableObject === "function" ? options.isMergeableObject : defaultIsMergeableObjectFactory();
|
|
433
|
+
const onlyDefinedProperties = options?.onlyDefinedProperties === true;
|
|
434
|
+
function isPrimitive(value) {
|
|
435
|
+
return typeof value !== "object" || value === null;
|
|
436
|
+
}
|
|
437
|
+
const mergeArray = options && typeof options.mergeArray === "function" ? options.mergeArray({
|
|
438
|
+
clone,
|
|
439
|
+
deepmerge: _deepmerge,
|
|
440
|
+
getKeys,
|
|
441
|
+
isMergeableObject
|
|
442
|
+
}) : concatArrays;
|
|
443
|
+
function clone(entry) {
|
|
444
|
+
return isMergeableObject(entry) ? Array.isArray(entry) ? cloneArray(entry) : cloneObject(entry) : entry;
|
|
445
|
+
}
|
|
446
|
+
function mergeObject(target, source) {
|
|
447
|
+
const result = {};
|
|
448
|
+
const targetKeys = getKeys(target);
|
|
449
|
+
const sourceKeys = getKeys(source);
|
|
450
|
+
let i, il, key;
|
|
451
|
+
for (i = 0, il = targetKeys.length; i < il; ++i) isNotPrototypeKey(key = targetKeys[i]) && sourceKeys.indexOf(key) === -1 && (result[key] = clone(target[key]));
|
|
452
|
+
for (i = 0, il = sourceKeys.length; i < il; ++i) {
|
|
453
|
+
if (!isNotPrototypeKey(key = sourceKeys[i])) continue;
|
|
454
|
+
if (key in target) {
|
|
455
|
+
if (targetKeys.indexOf(key) !== -1) {
|
|
456
|
+
if (cloneProtoObject && isMergeableObject(source[key]) && Object.getPrototypeOf(source[key]) !== JSON_PROTO) result[key] = cloneProtoObject(source[key]);
|
|
457
|
+
else result[key] = _deepmerge(target[key], source[key]);
|
|
458
|
+
}
|
|
459
|
+
} else {
|
|
460
|
+
if (onlyDefinedProperties && typeof source[key] === "undefined") continue;
|
|
461
|
+
result[key] = clone(source[key]);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
return result;
|
|
465
|
+
}
|
|
466
|
+
function _deepmerge(target, source) {
|
|
467
|
+
if (onlyDefinedProperties && typeof source === "undefined") return clone(target);
|
|
468
|
+
const sourceIsArray = Array.isArray(source);
|
|
469
|
+
const targetIsArray = Array.isArray(target);
|
|
470
|
+
if (isPrimitive(source)) return source;
|
|
471
|
+
else if (!isMergeableObject(target)) return clone(source);
|
|
472
|
+
else if (sourceIsArray && targetIsArray) return mergeArray(target, source);
|
|
473
|
+
else if (sourceIsArray !== targetIsArray) return clone(source);
|
|
474
|
+
else return mergeObject(target, source);
|
|
475
|
+
}
|
|
476
|
+
function _deepmergeAll() {
|
|
477
|
+
switch (arguments.length) {
|
|
478
|
+
case 0: return {};
|
|
479
|
+
case 1: return clone(arguments[0]);
|
|
480
|
+
case 2: return _deepmerge(arguments[0], arguments[1]);
|
|
481
|
+
}
|
|
482
|
+
let result;
|
|
483
|
+
for (let i = 0, il = arguments.length; i < il; ++i) result = _deepmerge(result, arguments[i]);
|
|
484
|
+
return result;
|
|
485
|
+
}
|
|
486
|
+
return options?.all ? _deepmergeAll : _deepmerge;
|
|
487
|
+
}
|
|
488
|
+
module.exports = deepmergeConstructor;
|
|
489
|
+
module.exports.default = deepmergeConstructor;
|
|
490
|
+
module.exports.deepmerge = deepmergeConstructor;
|
|
491
|
+
Object.defineProperty(module.exports, "isMergeableObject", { get: defaultIsMergeableObjectFactory });
|
|
492
|
+
}));
|
|
493
|
+
var require_unesc = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
494
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
495
|
+
exports.default = unesc;
|
|
496
|
+
function gobbleHex(str) {
|
|
497
|
+
var lower = str.toLowerCase();
|
|
498
|
+
var hex = "";
|
|
499
|
+
var spaceTerminated = false;
|
|
500
|
+
for (var i = 0; i < 6 && lower[i] !== void 0; i++) {
|
|
501
|
+
var code = lower.charCodeAt(i);
|
|
502
|
+
var valid = code >= 97 && code <= 102 || code >= 48 && code <= 57;
|
|
503
|
+
spaceTerminated = code === 32;
|
|
504
|
+
if (!valid) break;
|
|
505
|
+
hex += lower[i];
|
|
506
|
+
}
|
|
507
|
+
if (hex.length === 0) return;
|
|
508
|
+
var codePoint = parseInt(hex, 16);
|
|
509
|
+
if (codePoint >= 55296 && codePoint <= 57343 || codePoint === 0 || codePoint > 1114111) return ["�", hex.length + (spaceTerminated ? 1 : 0)];
|
|
510
|
+
return [String.fromCodePoint(codePoint), hex.length + (spaceTerminated ? 1 : 0)];
|
|
511
|
+
}
|
|
512
|
+
var CONTAINS_ESCAPE = /\\/;
|
|
513
|
+
function unesc(str) {
|
|
514
|
+
if (!CONTAINS_ESCAPE.test(str)) return str;
|
|
515
|
+
var ret = "";
|
|
516
|
+
for (var i = 0; i < str.length; i++) {
|
|
517
|
+
if (str[i] === "\\") {
|
|
518
|
+
var gobbled = gobbleHex(str.slice(i + 1, i + 7));
|
|
519
|
+
if (gobbled !== void 0) {
|
|
520
|
+
ret += gobbled[0];
|
|
521
|
+
i += gobbled[1];
|
|
522
|
+
continue;
|
|
523
|
+
}
|
|
524
|
+
if (str[i + 1] === "\\") {
|
|
525
|
+
ret += "\\";
|
|
526
|
+
i++;
|
|
527
|
+
continue;
|
|
528
|
+
}
|
|
529
|
+
if (str.length === i + 1) ret += str[i];
|
|
530
|
+
continue;
|
|
531
|
+
}
|
|
532
|
+
ret += str[i];
|
|
533
|
+
}
|
|
534
|
+
return ret;
|
|
535
|
+
}
|
|
536
|
+
}));
|
|
537
|
+
var require_getProp = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
538
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
539
|
+
exports.default = getProp;
|
|
540
|
+
function getProp(obj) {
|
|
541
|
+
var props = [];
|
|
542
|
+
for (var _i = 1; _i < arguments.length; _i++) props[_i - 1] = arguments[_i];
|
|
543
|
+
while (props.length > 0) {
|
|
544
|
+
var prop = props.shift();
|
|
545
|
+
if (!obj[prop]) return;
|
|
546
|
+
obj = obj[prop];
|
|
547
|
+
}
|
|
548
|
+
return obj;
|
|
549
|
+
}
|
|
550
|
+
}));
|
|
551
|
+
var require_ensureObject = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
552
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
553
|
+
exports.default = ensureObject;
|
|
554
|
+
function ensureObject(obj) {
|
|
555
|
+
var props = [];
|
|
556
|
+
for (var _i = 1; _i < arguments.length; _i++) props[_i - 1] = arguments[_i];
|
|
557
|
+
while (props.length > 0) {
|
|
558
|
+
var prop = props.shift();
|
|
559
|
+
if (!obj[prop]) obj[prop] = {};
|
|
560
|
+
obj = obj[prop];
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}));
|
|
564
|
+
var require_stripComments = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
565
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
566
|
+
exports.default = stripComments;
|
|
567
|
+
function stripComments(str) {
|
|
568
|
+
var s = "";
|
|
569
|
+
var commentStart = str.indexOf("/*");
|
|
570
|
+
var lastEnd = 0;
|
|
571
|
+
while (commentStart >= 0) {
|
|
572
|
+
s = s + str.slice(lastEnd, commentStart);
|
|
573
|
+
var commentEnd = str.indexOf("*/", commentStart + 2);
|
|
574
|
+
if (commentEnd < 0) return s;
|
|
575
|
+
lastEnd = commentEnd + 2;
|
|
576
|
+
commentStart = str.indexOf("/*", lastEnd);
|
|
577
|
+
}
|
|
578
|
+
s = s + str.slice(lastEnd);
|
|
579
|
+
return s;
|
|
580
|
+
}
|
|
581
|
+
}));
|
|
582
|
+
var require_maxNestingDepth = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
583
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
584
|
+
exports.MAX_NESTING_DEPTH = void 0;
|
|
585
|
+
exports.default = resolveMaxNestingDepth;
|
|
586
|
+
exports.MAX_NESTING_DEPTH = 256;
|
|
587
|
+
function resolveMaxNestingDepth(value) {
|
|
588
|
+
return Number.isSafeInteger(value) && value >= 0 ? value : exports.MAX_NESTING_DEPTH;
|
|
589
|
+
}
|
|
590
|
+
}));
|
|
591
|
+
var require_util = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
592
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
593
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
594
|
+
};
|
|
595
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
596
|
+
exports.MAX_NESTING_DEPTH = exports.resolveMaxNestingDepth = exports.stripComments = exports.ensureObject = exports.getProp = exports.unesc = void 0;
|
|
597
|
+
var unesc_1 = require_unesc();
|
|
598
|
+
Object.defineProperty(exports, "unesc", {
|
|
599
|
+
enumerable: true,
|
|
600
|
+
get: function() {
|
|
601
|
+
return __importDefault(unesc_1).default;
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
var getProp_1 = require_getProp();
|
|
605
|
+
Object.defineProperty(exports, "getProp", {
|
|
606
|
+
enumerable: true,
|
|
607
|
+
get: function() {
|
|
608
|
+
return __importDefault(getProp_1).default;
|
|
609
|
+
}
|
|
610
|
+
});
|
|
611
|
+
var ensureObject_1 = require_ensureObject();
|
|
612
|
+
Object.defineProperty(exports, "ensureObject", {
|
|
613
|
+
enumerable: true,
|
|
614
|
+
get: function() {
|
|
615
|
+
return __importDefault(ensureObject_1).default;
|
|
616
|
+
}
|
|
617
|
+
});
|
|
618
|
+
var stripComments_1 = require_stripComments();
|
|
619
|
+
Object.defineProperty(exports, "stripComments", {
|
|
620
|
+
enumerable: true,
|
|
621
|
+
get: function() {
|
|
622
|
+
return __importDefault(stripComments_1).default;
|
|
623
|
+
}
|
|
624
|
+
});
|
|
625
|
+
var maxNestingDepth_1 = require_maxNestingDepth();
|
|
626
|
+
Object.defineProperty(exports, "resolveMaxNestingDepth", {
|
|
627
|
+
enumerable: true,
|
|
628
|
+
get: function() {
|
|
629
|
+
return __importDefault(maxNestingDepth_1).default;
|
|
630
|
+
}
|
|
631
|
+
});
|
|
632
|
+
Object.defineProperty(exports, "MAX_NESTING_DEPTH", {
|
|
633
|
+
enumerable: true,
|
|
634
|
+
get: function() {
|
|
635
|
+
return maxNestingDepth_1.MAX_NESTING_DEPTH;
|
|
636
|
+
}
|
|
637
|
+
});
|
|
638
|
+
}));
|
|
639
|
+
var require_node$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
640
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
641
|
+
var util_1 = require_util();
|
|
642
|
+
var cloneNode = function(obj, parent, depth) {
|
|
643
|
+
if (depth === void 0) depth = 0;
|
|
644
|
+
if (depth > util_1.MAX_NESTING_DEPTH) throw new Error("Cannot clone selector: nesting depth exceeds the maximum of ".concat(util_1.MAX_NESTING_DEPTH, "."));
|
|
645
|
+
if (typeof obj !== "object" || obj === null) return obj;
|
|
646
|
+
var cloned = new obj.constructor();
|
|
647
|
+
for (var i in obj) {
|
|
648
|
+
if (!obj.hasOwnProperty(i)) continue;
|
|
649
|
+
var value = obj[i];
|
|
650
|
+
if (i === "parent" && typeof value === "object") {
|
|
651
|
+
if (parent) cloned[i] = parent;
|
|
652
|
+
} else if (value instanceof Array) cloned[i] = value.map(function(j) {
|
|
653
|
+
return cloneNode(j, cloned, depth + 1);
|
|
654
|
+
});
|
|
655
|
+
else cloned[i] = cloneNode(value, cloned, depth + 1);
|
|
656
|
+
}
|
|
657
|
+
return cloned;
|
|
658
|
+
};
|
|
659
|
+
exports.default = function() {
|
|
660
|
+
function Node(opts) {
|
|
661
|
+
if (opts === void 0) opts = {};
|
|
662
|
+
Object.assign(this, opts);
|
|
663
|
+
this.spaces = this.spaces || {};
|
|
664
|
+
this.spaces.before = this.spaces.before || "";
|
|
665
|
+
this.spaces.after = this.spaces.after || "";
|
|
666
|
+
}
|
|
667
|
+
Node.prototype.remove = function() {
|
|
668
|
+
if (this.parent) this.parent.removeChild(this);
|
|
669
|
+
this.parent = void 0;
|
|
670
|
+
return this;
|
|
671
|
+
};
|
|
672
|
+
Node.prototype.replaceWith = function() {
|
|
673
|
+
if (this.parent) {
|
|
674
|
+
for (var index in arguments) this.parent.insertBefore(this, arguments[index]);
|
|
675
|
+
this.remove();
|
|
676
|
+
}
|
|
677
|
+
return this;
|
|
678
|
+
};
|
|
679
|
+
Node.prototype.next = function() {
|
|
680
|
+
return this.parent.at(this.parent.index(this) + 1);
|
|
681
|
+
};
|
|
682
|
+
Node.prototype.prev = function() {
|
|
683
|
+
return this.parent.at(this.parent.index(this) - 1);
|
|
684
|
+
};
|
|
685
|
+
Node.prototype.clone = function(overrides) {
|
|
686
|
+
if (overrides === void 0) overrides = {};
|
|
687
|
+
var cloned = cloneNode(this);
|
|
688
|
+
for (var name in overrides) cloned[name] = overrides[name];
|
|
689
|
+
return cloned;
|
|
690
|
+
};
|
|
691
|
+
Node.prototype.appendToPropertyAndEscape = function(name, value, valueEscaped) {
|
|
692
|
+
if (!this.raws) this.raws = {};
|
|
693
|
+
var originalValue = this[name];
|
|
694
|
+
var originalEscaped = this.raws[name];
|
|
695
|
+
this[name] = originalValue + value;
|
|
696
|
+
if (originalEscaped || valueEscaped !== value) this.raws[name] = (originalEscaped || originalValue) + valueEscaped;
|
|
697
|
+
else delete this.raws[name];
|
|
698
|
+
};
|
|
699
|
+
Node.prototype.setPropertyAndEscape = function(name, value, valueEscaped) {
|
|
700
|
+
if (!this.raws) this.raws = {};
|
|
701
|
+
this[name] = value;
|
|
702
|
+
this.raws[name] = valueEscaped;
|
|
703
|
+
};
|
|
704
|
+
Node.prototype.setPropertyWithoutEscape = function(name, value) {
|
|
705
|
+
this[name] = value;
|
|
706
|
+
if (this.raws) delete this.raws[name];
|
|
707
|
+
};
|
|
708
|
+
Node.prototype.isAtPosition = function(line, column) {
|
|
709
|
+
if (this.source && this.source.start && this.source.end) {
|
|
710
|
+
if (this.source.start.line > line) return false;
|
|
711
|
+
if (this.source.end.line < line) return false;
|
|
712
|
+
if (this.source.start.line === line && this.source.start.column > column) return false;
|
|
713
|
+
if (this.source.end.line === line && this.source.end.column < column) return false;
|
|
714
|
+
return true;
|
|
715
|
+
}
|
|
716
|
+
};
|
|
717
|
+
Node.prototype.stringifyProperty = function(name) {
|
|
718
|
+
return this.raws && this.raws[name] || this[name];
|
|
719
|
+
};
|
|
720
|
+
Object.defineProperty(Node.prototype, "rawSpaceBefore", {
|
|
721
|
+
get: function() {
|
|
722
|
+
var rawSpace = this.raws && this.raws.spaces && this.raws.spaces.before;
|
|
723
|
+
if (rawSpace === void 0) rawSpace = this.spaces && this.spaces.before;
|
|
724
|
+
return rawSpace || "";
|
|
725
|
+
},
|
|
726
|
+
set: function(raw) {
|
|
727
|
+
(0, util_1.ensureObject)(this, "raws", "spaces");
|
|
728
|
+
this.raws.spaces.before = raw;
|
|
729
|
+
},
|
|
730
|
+
enumerable: false,
|
|
731
|
+
configurable: true
|
|
732
|
+
});
|
|
733
|
+
Object.defineProperty(Node.prototype, "rawSpaceAfter", {
|
|
734
|
+
get: function() {
|
|
735
|
+
var rawSpace = this.raws && this.raws.spaces && this.raws.spaces.after;
|
|
736
|
+
if (rawSpace === void 0) rawSpace = this.spaces.after;
|
|
737
|
+
return rawSpace || "";
|
|
738
|
+
},
|
|
739
|
+
set: function(raw) {
|
|
740
|
+
(0, util_1.ensureObject)(this, "raws", "spaces");
|
|
741
|
+
this.raws.spaces.after = raw;
|
|
742
|
+
},
|
|
743
|
+
enumerable: false,
|
|
744
|
+
configurable: true
|
|
745
|
+
});
|
|
746
|
+
Node.prototype.valueToString = function() {
|
|
747
|
+
return String(this.stringifyProperty("value"));
|
|
748
|
+
};
|
|
749
|
+
Node.prototype.toString = function() {
|
|
750
|
+
return [
|
|
751
|
+
this.rawSpaceBefore,
|
|
752
|
+
this.valueToString(),
|
|
753
|
+
this.rawSpaceAfter
|
|
754
|
+
].join("");
|
|
755
|
+
};
|
|
756
|
+
Node.prototype._stringify = function() {
|
|
757
|
+
return this.toString();
|
|
758
|
+
};
|
|
759
|
+
return Node;
|
|
760
|
+
}();
|
|
761
|
+
}));
|
|
762
|
+
var require_types = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
763
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
764
|
+
exports.UNIVERSAL = exports.ATTRIBUTE = exports.CLASS = exports.COMBINATOR = exports.COMMENT = exports.ID = exports.NESTING = exports.PSEUDO = exports.ROOT = exports.SELECTOR = exports.STRING = exports.TAG = void 0;
|
|
765
|
+
exports.TAG = "tag";
|
|
766
|
+
exports.STRING = "string";
|
|
767
|
+
exports.SELECTOR = "selector";
|
|
768
|
+
exports.ROOT = "root";
|
|
769
|
+
exports.PSEUDO = "pseudo";
|
|
770
|
+
exports.NESTING = "nesting";
|
|
771
|
+
exports.ID = "id";
|
|
772
|
+
exports.COMMENT = "comment";
|
|
773
|
+
exports.COMBINATOR = "combinator";
|
|
774
|
+
exports.CLASS = "class";
|
|
775
|
+
exports.ATTRIBUTE = "attribute";
|
|
776
|
+
exports.UNIVERSAL = "universal";
|
|
777
|
+
}));
|
|
778
|
+
var require_container = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
779
|
+
var __extends = exports && exports.__extends || (function() {
|
|
780
|
+
var extendStatics = function(d, b) {
|
|
781
|
+
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d, b) {
|
|
782
|
+
d.__proto__ = b;
|
|
783
|
+
} || function(d, b) {
|
|
784
|
+
for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
785
|
+
};
|
|
786
|
+
return extendStatics(d, b);
|
|
787
|
+
};
|
|
788
|
+
return function(d, b) {
|
|
789
|
+
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
790
|
+
extendStatics(d, b);
|
|
791
|
+
function __() {
|
|
792
|
+
this.constructor = d;
|
|
793
|
+
}
|
|
794
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
795
|
+
};
|
|
796
|
+
})();
|
|
797
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
798
|
+
if (k2 === void 0) k2 = k;
|
|
799
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
800
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) desc = {
|
|
801
|
+
enumerable: true,
|
|
802
|
+
get: function() {
|
|
803
|
+
return m[k];
|
|
804
|
+
}
|
|
805
|
+
};
|
|
806
|
+
Object.defineProperty(o, k2, desc);
|
|
807
|
+
}) : (function(o, m, k, k2) {
|
|
808
|
+
if (k2 === void 0) k2 = k;
|
|
809
|
+
o[k2] = m[k];
|
|
810
|
+
}));
|
|
811
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
|
|
812
|
+
Object.defineProperty(o, "default", {
|
|
813
|
+
enumerable: true,
|
|
814
|
+
value: v
|
|
815
|
+
});
|
|
816
|
+
}) : function(o, v) {
|
|
817
|
+
o["default"] = v;
|
|
818
|
+
});
|
|
819
|
+
var __importStar = exports && exports.__importStar || (function() {
|
|
820
|
+
var ownKeys = function(o) {
|
|
821
|
+
ownKeys = Object.getOwnPropertyNames || function(o) {
|
|
822
|
+
var ar = [];
|
|
823
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
824
|
+
return ar;
|
|
825
|
+
};
|
|
826
|
+
return ownKeys(o);
|
|
827
|
+
};
|
|
828
|
+
return function(mod) {
|
|
829
|
+
if (mod && mod.__esModule) return mod;
|
|
830
|
+
var result = {};
|
|
831
|
+
if (mod != null) {
|
|
832
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
833
|
+
}
|
|
834
|
+
__setModuleDefault(result, mod);
|
|
835
|
+
return result;
|
|
836
|
+
};
|
|
837
|
+
})();
|
|
838
|
+
var __values = exports && exports.__values || function(o) {
|
|
839
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
840
|
+
if (m) return m.call(o);
|
|
841
|
+
if (o && typeof o.length === "number") return { next: function() {
|
|
842
|
+
if (o && i >= o.length) o = void 0;
|
|
843
|
+
return {
|
|
844
|
+
value: o && o[i++],
|
|
845
|
+
done: !o
|
|
846
|
+
};
|
|
847
|
+
} };
|
|
848
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
849
|
+
};
|
|
850
|
+
var __read = exports && exports.__read || function(o, n) {
|
|
851
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
852
|
+
if (!m) return o;
|
|
853
|
+
var i = m.call(o), r, ar = [], e;
|
|
854
|
+
try {
|
|
855
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
856
|
+
} catch (error) {
|
|
857
|
+
e = { error };
|
|
858
|
+
} finally {
|
|
859
|
+
try {
|
|
860
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
861
|
+
} finally {
|
|
862
|
+
if (e) throw e.error;
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
return ar;
|
|
866
|
+
};
|
|
867
|
+
var __spreadArray = exports && exports.__spreadArray || function(to, from, pack) {
|
|
868
|
+
if (pack || arguments.length === 2) {
|
|
869
|
+
for (var i = 0, l = from.length, ar; i < l; i++) if (ar || !(i in from)) {
|
|
870
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
871
|
+
ar[i] = from[i];
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
875
|
+
};
|
|
876
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
877
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
878
|
+
};
|
|
879
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
880
|
+
var util_1 = require_util();
|
|
881
|
+
var node_1 = __importDefault(require_node$1());
|
|
882
|
+
var types = __importStar(require_types());
|
|
883
|
+
exports.default = function(_super) {
|
|
884
|
+
__extends(Container, _super);
|
|
885
|
+
function Container(opts) {
|
|
886
|
+
var _this = _super.call(this, opts) || this;
|
|
887
|
+
if (!_this.nodes) _this.nodes = [];
|
|
888
|
+
return _this;
|
|
889
|
+
}
|
|
890
|
+
Container.prototype.append = function(selector) {
|
|
891
|
+
selector.parent = this;
|
|
892
|
+
this.nodes.push(selector);
|
|
893
|
+
return this;
|
|
894
|
+
};
|
|
895
|
+
Container.prototype.prepend = function(selector) {
|
|
896
|
+
selector.parent = this;
|
|
897
|
+
this.nodes.unshift(selector);
|
|
898
|
+
for (var id in this.indexes) this.indexes[id]++;
|
|
899
|
+
return this;
|
|
900
|
+
};
|
|
901
|
+
Container.prototype.at = function(index) {
|
|
902
|
+
return this.nodes[index];
|
|
903
|
+
};
|
|
904
|
+
Container.prototype.index = function(child) {
|
|
905
|
+
if (typeof child === "number") return child;
|
|
906
|
+
return this.nodes.indexOf(child);
|
|
907
|
+
};
|
|
908
|
+
Object.defineProperty(Container.prototype, "first", {
|
|
909
|
+
get: function() {
|
|
910
|
+
return this.at(0);
|
|
911
|
+
},
|
|
912
|
+
enumerable: false,
|
|
913
|
+
configurable: true
|
|
914
|
+
});
|
|
915
|
+
Object.defineProperty(Container.prototype, "last", {
|
|
916
|
+
get: function() {
|
|
917
|
+
return this.at(this.length - 1);
|
|
918
|
+
},
|
|
919
|
+
enumerable: false,
|
|
920
|
+
configurable: true
|
|
921
|
+
});
|
|
922
|
+
Object.defineProperty(Container.prototype, "length", {
|
|
923
|
+
get: function() {
|
|
924
|
+
return this.nodes.length;
|
|
925
|
+
},
|
|
926
|
+
enumerable: false,
|
|
927
|
+
configurable: true
|
|
928
|
+
});
|
|
929
|
+
Container.prototype.removeChild = function(child) {
|
|
930
|
+
child = this.index(child);
|
|
931
|
+
this.at(child).parent = void 0;
|
|
932
|
+
this.nodes.splice(child, 1);
|
|
933
|
+
var index;
|
|
934
|
+
for (var id in this.indexes) {
|
|
935
|
+
index = this.indexes[id];
|
|
936
|
+
if (index >= child) this.indexes[id] = index - 1;
|
|
937
|
+
}
|
|
938
|
+
return this;
|
|
939
|
+
};
|
|
940
|
+
Container.prototype.removeAll = function() {
|
|
941
|
+
var e_1, _a;
|
|
942
|
+
try {
|
|
943
|
+
for (var _b = __values(this.nodes), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
944
|
+
var node = _c.value;
|
|
945
|
+
node.parent = void 0;
|
|
946
|
+
}
|
|
947
|
+
} catch (e_1_1) {
|
|
948
|
+
e_1 = { error: e_1_1 };
|
|
949
|
+
} finally {
|
|
950
|
+
try {
|
|
951
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
952
|
+
} finally {
|
|
953
|
+
if (e_1) throw e_1.error;
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
this.nodes = [];
|
|
957
|
+
return this;
|
|
958
|
+
};
|
|
959
|
+
Container.prototype.empty = function() {
|
|
960
|
+
return this.removeAll();
|
|
961
|
+
};
|
|
962
|
+
Container.prototype.insertAfter = function(oldNode, newNode) {
|
|
963
|
+
var _a;
|
|
964
|
+
newNode.parent = this;
|
|
965
|
+
var oldIndex = this.index(oldNode);
|
|
966
|
+
var resetNode = [];
|
|
967
|
+
for (var i = 2; i < arguments.length; i++) resetNode.push(arguments[i]);
|
|
968
|
+
(_a = this.nodes).splice.apply(_a, __spreadArray([
|
|
969
|
+
oldIndex + 1,
|
|
970
|
+
0,
|
|
971
|
+
newNode
|
|
972
|
+
], __read(resetNode), false));
|
|
973
|
+
newNode.parent = this;
|
|
974
|
+
var index;
|
|
975
|
+
for (var id in this.indexes) {
|
|
976
|
+
index = this.indexes[id];
|
|
977
|
+
if (oldIndex < index) this.indexes[id] = index + arguments.length - 1;
|
|
978
|
+
}
|
|
979
|
+
return this;
|
|
980
|
+
};
|
|
981
|
+
Container.prototype.insertBefore = function(oldNode, newNode) {
|
|
982
|
+
var _a;
|
|
983
|
+
newNode.parent = this;
|
|
984
|
+
var oldIndex = this.index(oldNode);
|
|
985
|
+
var resetNode = [];
|
|
986
|
+
for (var i = 2; i < arguments.length; i++) resetNode.push(arguments[i]);
|
|
987
|
+
(_a = this.nodes).splice.apply(_a, __spreadArray([
|
|
988
|
+
oldIndex,
|
|
989
|
+
0,
|
|
990
|
+
newNode
|
|
991
|
+
], __read(resetNode), false));
|
|
992
|
+
newNode.parent = this;
|
|
993
|
+
var index;
|
|
994
|
+
for (var id in this.indexes) {
|
|
995
|
+
index = this.indexes[id];
|
|
996
|
+
if (index >= oldIndex) this.indexes[id] = index + arguments.length - 1;
|
|
997
|
+
}
|
|
998
|
+
return this;
|
|
999
|
+
};
|
|
1000
|
+
Container.prototype._findChildAtPosition = function(line, col) {
|
|
1001
|
+
var found = void 0;
|
|
1002
|
+
this.each(function(node) {
|
|
1003
|
+
if (node.atPosition) {
|
|
1004
|
+
var foundChild = node.atPosition(line, col);
|
|
1005
|
+
if (foundChild) {
|
|
1006
|
+
found = foundChild;
|
|
1007
|
+
return false;
|
|
1008
|
+
}
|
|
1009
|
+
} else if (node.isAtPosition(line, col)) {
|
|
1010
|
+
found = node;
|
|
1011
|
+
return false;
|
|
1012
|
+
}
|
|
1013
|
+
});
|
|
1014
|
+
return found;
|
|
1015
|
+
};
|
|
1016
|
+
Container.prototype.atPosition = function(line, col) {
|
|
1017
|
+
if (this.isAtPosition(line, col)) return this._findChildAtPosition(line, col) || this;
|
|
1018
|
+
else return;
|
|
1019
|
+
};
|
|
1020
|
+
Container.prototype._inferEndPosition = function() {
|
|
1021
|
+
if (this.last && this.last.source && this.last.source.end) {
|
|
1022
|
+
this.source = this.source || {};
|
|
1023
|
+
this.source.end = this.source.end || {};
|
|
1024
|
+
Object.assign(this.source.end, this.last.source.end);
|
|
1025
|
+
}
|
|
1026
|
+
};
|
|
1027
|
+
Container.prototype.each = function(callback) {
|
|
1028
|
+
if (!this.lastEach) this.lastEach = 0;
|
|
1029
|
+
if (!this.indexes) this.indexes = {};
|
|
1030
|
+
this.lastEach++;
|
|
1031
|
+
var id = this.lastEach;
|
|
1032
|
+
this.indexes[id] = 0;
|
|
1033
|
+
if (!this.length) return;
|
|
1034
|
+
var index, result;
|
|
1035
|
+
while (this.indexes[id] < this.length) {
|
|
1036
|
+
index = this.indexes[id];
|
|
1037
|
+
result = callback(this.at(index), index);
|
|
1038
|
+
if (result === false) break;
|
|
1039
|
+
this.indexes[id] += 1;
|
|
1040
|
+
}
|
|
1041
|
+
delete this.indexes[id];
|
|
1042
|
+
if (result === false) return false;
|
|
1043
|
+
};
|
|
1044
|
+
Container.prototype.walk = function(callback, depth) {
|
|
1045
|
+
if (depth === void 0) depth = 0;
|
|
1046
|
+
if (depth > util_1.MAX_NESTING_DEPTH) throw new Error("Cannot walk selector: nesting depth exceeds the maximum of ".concat(util_1.MAX_NESTING_DEPTH, "."));
|
|
1047
|
+
return this.each(function(node, i) {
|
|
1048
|
+
var result = callback(node, i);
|
|
1049
|
+
if (result !== false && node.length) result = node.walk(callback, depth + 1);
|
|
1050
|
+
if (result === false) return false;
|
|
1051
|
+
});
|
|
1052
|
+
};
|
|
1053
|
+
Container.prototype.walkAttributes = function(callback) {
|
|
1054
|
+
var _this = this;
|
|
1055
|
+
return this.walk(function(selector) {
|
|
1056
|
+
if (selector.type === types.ATTRIBUTE) return callback.call(_this, selector);
|
|
1057
|
+
});
|
|
1058
|
+
};
|
|
1059
|
+
Container.prototype.walkClasses = function(callback) {
|
|
1060
|
+
var _this = this;
|
|
1061
|
+
return this.walk(function(selector) {
|
|
1062
|
+
if (selector.type === types.CLASS) return callback.call(_this, selector);
|
|
1063
|
+
});
|
|
1064
|
+
};
|
|
1065
|
+
Container.prototype.walkCombinators = function(callback) {
|
|
1066
|
+
var _this = this;
|
|
1067
|
+
return this.walk(function(selector) {
|
|
1068
|
+
if (selector.type === types.COMBINATOR) return callback.call(_this, selector);
|
|
1069
|
+
});
|
|
1070
|
+
};
|
|
1071
|
+
Container.prototype.walkComments = function(callback) {
|
|
1072
|
+
var _this = this;
|
|
1073
|
+
return this.walk(function(selector) {
|
|
1074
|
+
if (selector.type === types.COMMENT) return callback.call(_this, selector);
|
|
1075
|
+
});
|
|
1076
|
+
};
|
|
1077
|
+
Container.prototype.walkIds = function(callback) {
|
|
1078
|
+
var _this = this;
|
|
1079
|
+
return this.walk(function(selector) {
|
|
1080
|
+
if (selector.type === types.ID) return callback.call(_this, selector);
|
|
1081
|
+
});
|
|
1082
|
+
};
|
|
1083
|
+
Container.prototype.walkNesting = function(callback) {
|
|
1084
|
+
var _this = this;
|
|
1085
|
+
return this.walk(function(selector) {
|
|
1086
|
+
if (selector.type === types.NESTING) return callback.call(_this, selector);
|
|
1087
|
+
});
|
|
1088
|
+
};
|
|
1089
|
+
Container.prototype.walkPseudos = function(callback) {
|
|
1090
|
+
var _this = this;
|
|
1091
|
+
return this.walk(function(selector) {
|
|
1092
|
+
if (selector.type === types.PSEUDO) return callback.call(_this, selector);
|
|
1093
|
+
});
|
|
1094
|
+
};
|
|
1095
|
+
Container.prototype.walkTags = function(callback) {
|
|
1096
|
+
var _this = this;
|
|
1097
|
+
return this.walk(function(selector) {
|
|
1098
|
+
if (selector.type === types.TAG) return callback.call(_this, selector);
|
|
1099
|
+
});
|
|
1100
|
+
};
|
|
1101
|
+
Container.prototype.walkUniversals = function(callback) {
|
|
1102
|
+
var _this = this;
|
|
1103
|
+
return this.walk(function(selector) {
|
|
1104
|
+
if (selector.type === types.UNIVERSAL) return callback.call(_this, selector);
|
|
1105
|
+
});
|
|
1106
|
+
};
|
|
1107
|
+
Container.prototype.split = function(callback) {
|
|
1108
|
+
var _this = this;
|
|
1109
|
+
var current = [];
|
|
1110
|
+
return this.reduce(function(memo, node, index) {
|
|
1111
|
+
var split = callback.call(_this, node);
|
|
1112
|
+
current.push(node);
|
|
1113
|
+
if (split) {
|
|
1114
|
+
memo.push(current);
|
|
1115
|
+
current = [];
|
|
1116
|
+
} else if (index === _this.length - 1) memo.push(current);
|
|
1117
|
+
return memo;
|
|
1118
|
+
}, []);
|
|
1119
|
+
};
|
|
1120
|
+
Container.prototype.map = function(callback) {
|
|
1121
|
+
return this.nodes.map(callback);
|
|
1122
|
+
};
|
|
1123
|
+
Container.prototype.reduce = function(callback, memo) {
|
|
1124
|
+
return this.nodes.reduce(callback, memo);
|
|
1125
|
+
};
|
|
1126
|
+
Container.prototype.every = function(callback) {
|
|
1127
|
+
return this.nodes.every(callback);
|
|
1128
|
+
};
|
|
1129
|
+
Container.prototype.some = function(callback) {
|
|
1130
|
+
return this.nodes.some(callback);
|
|
1131
|
+
};
|
|
1132
|
+
Container.prototype.filter = function(callback) {
|
|
1133
|
+
return this.nodes.filter(callback);
|
|
1134
|
+
};
|
|
1135
|
+
Container.prototype.sort = function(callback) {
|
|
1136
|
+
return this.nodes.sort(callback);
|
|
1137
|
+
};
|
|
1138
|
+
Container.prototype.toString = function(options) {
|
|
1139
|
+
if (options === void 0) options = {};
|
|
1140
|
+
return this._stringify(options, 0, (0, util_1.resolveMaxNestingDepth)(options.maxNestingDepth));
|
|
1141
|
+
};
|
|
1142
|
+
Container.prototype._stringify = function(options, depth, max) {
|
|
1143
|
+
var _this = this;
|
|
1144
|
+
return this.map(function(child) {
|
|
1145
|
+
return _this._stringifyChild(child, options, depth, max);
|
|
1146
|
+
}).join("");
|
|
1147
|
+
};
|
|
1148
|
+
Container.prototype._stringifyChild = function(child, options, depth, max) {
|
|
1149
|
+
return typeof child._stringify === "function" ? child._stringify(options, depth, max) : String(child);
|
|
1150
|
+
};
|
|
1151
|
+
return Container;
|
|
1152
|
+
}(node_1.default);
|
|
1153
|
+
}));
|
|
1154
|
+
var require_root = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1155
|
+
var __extends = exports && exports.__extends || (function() {
|
|
1156
|
+
var extendStatics = function(d, b) {
|
|
1157
|
+
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d, b) {
|
|
1158
|
+
d.__proto__ = b;
|
|
1159
|
+
} || function(d, b) {
|
|
1160
|
+
for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
1161
|
+
};
|
|
1162
|
+
return extendStatics(d, b);
|
|
1163
|
+
};
|
|
1164
|
+
return function(d, b) {
|
|
1165
|
+
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1166
|
+
extendStatics(d, b);
|
|
1167
|
+
function __() {
|
|
1168
|
+
this.constructor = d;
|
|
1169
|
+
}
|
|
1170
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1171
|
+
};
|
|
1172
|
+
})();
|
|
1173
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
1174
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
1175
|
+
};
|
|
1176
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1177
|
+
var container_1 = __importDefault(require_container());
|
|
1178
|
+
var types_1 = require_types();
|
|
1179
|
+
exports.default = function(_super) {
|
|
1180
|
+
__extends(Root, _super);
|
|
1181
|
+
function Root(opts) {
|
|
1182
|
+
var _this = _super.call(this, opts) || this;
|
|
1183
|
+
_this.type = types_1.ROOT;
|
|
1184
|
+
return _this;
|
|
1185
|
+
}
|
|
1186
|
+
Root.prototype._stringify = function(options, depth, max) {
|
|
1187
|
+
var _this = this;
|
|
1188
|
+
var str = this.reduce(function(memo, selector) {
|
|
1189
|
+
memo.push(_this._stringifyChild(selector, options, depth, max));
|
|
1190
|
+
return memo;
|
|
1191
|
+
}, []).join(",");
|
|
1192
|
+
return this.trailingComma ? str + "," : str;
|
|
1193
|
+
};
|
|
1194
|
+
Root.prototype.error = function(message, options) {
|
|
1195
|
+
if (this._error) return this._error(message, options);
|
|
1196
|
+
else return new Error(message);
|
|
1197
|
+
};
|
|
1198
|
+
Object.defineProperty(Root.prototype, "errorGenerator", {
|
|
1199
|
+
set: function(handler) {
|
|
1200
|
+
this._error = handler;
|
|
1201
|
+
},
|
|
1202
|
+
enumerable: false,
|
|
1203
|
+
configurable: true
|
|
1204
|
+
});
|
|
1205
|
+
return Root;
|
|
1206
|
+
}(container_1.default);
|
|
1207
|
+
}));
|
|
1208
|
+
var require_selector = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1209
|
+
var __extends = exports && exports.__extends || (function() {
|
|
1210
|
+
var extendStatics = function(d, b) {
|
|
1211
|
+
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d, b) {
|
|
1212
|
+
d.__proto__ = b;
|
|
1213
|
+
} || function(d, b) {
|
|
1214
|
+
for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
1215
|
+
};
|
|
1216
|
+
return extendStatics(d, b);
|
|
1217
|
+
};
|
|
1218
|
+
return function(d, b) {
|
|
1219
|
+
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1220
|
+
extendStatics(d, b);
|
|
1221
|
+
function __() {
|
|
1222
|
+
this.constructor = d;
|
|
1223
|
+
}
|
|
1224
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1225
|
+
};
|
|
1226
|
+
})();
|
|
1227
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
1228
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
1229
|
+
};
|
|
1230
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1231
|
+
var container_1 = __importDefault(require_container());
|
|
1232
|
+
var types_1 = require_types();
|
|
1233
|
+
exports.default = function(_super) {
|
|
1234
|
+
__extends(Selector, _super);
|
|
1235
|
+
function Selector(opts) {
|
|
1236
|
+
var _this = _super.call(this, opts) || this;
|
|
1237
|
+
_this.type = types_1.SELECTOR;
|
|
1238
|
+
return _this;
|
|
1239
|
+
}
|
|
1240
|
+
return Selector;
|
|
1241
|
+
}(container_1.default);
|
|
1242
|
+
}));
|
|
1243
|
+
/*! https://mths.be/cssesc v3.0.0 by @mathias */
|
|
1244
|
+
var require_cssesc = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1245
|
+
var hasOwnProperty = {}.hasOwnProperty;
|
|
1246
|
+
var merge = function merge(options, defaults) {
|
|
1247
|
+
if (!options) return defaults;
|
|
1248
|
+
var result = {};
|
|
1249
|
+
for (var key in defaults) result[key] = hasOwnProperty.call(options, key) ? options[key] : defaults[key];
|
|
1250
|
+
return result;
|
|
1251
|
+
};
|
|
1252
|
+
var regexAnySingleEscape = /[ -,\.\/:-@\[-\^`\{-~]/;
|
|
1253
|
+
var regexSingleEscape = /[ -,\.\/:-@\[\]\^`\{-~]/;
|
|
1254
|
+
var regexExcessiveSpaces = /(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g;
|
|
1255
|
+
var cssesc = function cssesc(string, options) {
|
|
1256
|
+
options = merge(options, cssesc.options);
|
|
1257
|
+
if (options.quotes != "single" && options.quotes != "double") options.quotes = "single";
|
|
1258
|
+
var quote = options.quotes == "double" ? "\"" : "'";
|
|
1259
|
+
var isIdentifier = options.isIdentifier;
|
|
1260
|
+
var firstChar = string.charAt(0);
|
|
1261
|
+
var output = "";
|
|
1262
|
+
var counter = 0;
|
|
1263
|
+
var length = string.length;
|
|
1264
|
+
while (counter < length) {
|
|
1265
|
+
var character = string.charAt(counter++);
|
|
1266
|
+
var codePoint = character.charCodeAt();
|
|
1267
|
+
var value = void 0;
|
|
1268
|
+
if (codePoint < 32 || codePoint > 126) {
|
|
1269
|
+
if (codePoint >= 55296 && codePoint <= 56319 && counter < length) {
|
|
1270
|
+
var extra = string.charCodeAt(counter++);
|
|
1271
|
+
if ((extra & 64512) == 56320) codePoint = ((codePoint & 1023) << 10) + (extra & 1023) + 65536;
|
|
1272
|
+
else counter--;
|
|
1273
|
+
}
|
|
1274
|
+
value = "\\" + codePoint.toString(16).toUpperCase() + " ";
|
|
1275
|
+
} else if (options.escapeEverything) {
|
|
1276
|
+
if (regexAnySingleEscape.test(character)) value = "\\" + character;
|
|
1277
|
+
else value = "\\" + codePoint.toString(16).toUpperCase() + " ";
|
|
1278
|
+
} else if (/[\t\n\f\r\x0B]/.test(character)) value = "\\" + codePoint.toString(16).toUpperCase() + " ";
|
|
1279
|
+
else if (character == "\\" || !isIdentifier && (character == "\"" && quote == character || character == "'" && quote == character) || isIdentifier && regexSingleEscape.test(character)) value = "\\" + character;
|
|
1280
|
+
else value = character;
|
|
1281
|
+
output += value;
|
|
1282
|
+
}
|
|
1283
|
+
if (isIdentifier) {
|
|
1284
|
+
if (/^-[-\d]/.test(output)) output = "\\-" + output.slice(1);
|
|
1285
|
+
else if (/\d/.test(firstChar)) output = "\\3" + firstChar + " " + output.slice(1);
|
|
1286
|
+
}
|
|
1287
|
+
output = output.replace(regexExcessiveSpaces, function($0, $1, $2) {
|
|
1288
|
+
if ($1 && $1.length % 2) return $0;
|
|
1289
|
+
return ($1 || "") + $2;
|
|
1290
|
+
});
|
|
1291
|
+
if (!isIdentifier && options.wrap) return quote + output + quote;
|
|
1292
|
+
return output;
|
|
1293
|
+
};
|
|
1294
|
+
cssesc.options = {
|
|
1295
|
+
"escapeEverything": false,
|
|
1296
|
+
"isIdentifier": false,
|
|
1297
|
+
"quotes": "single",
|
|
1298
|
+
"wrap": false
|
|
1299
|
+
};
|
|
1300
|
+
cssesc.version = "3.0.0";
|
|
1301
|
+
module.exports = cssesc;
|
|
1302
|
+
}));
|
|
1303
|
+
var require_className = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1304
|
+
var __extends = exports && exports.__extends || (function() {
|
|
1305
|
+
var extendStatics = function(d, b) {
|
|
1306
|
+
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d, b) {
|
|
1307
|
+
d.__proto__ = b;
|
|
1308
|
+
} || function(d, b) {
|
|
1309
|
+
for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
1310
|
+
};
|
|
1311
|
+
return extendStatics(d, b);
|
|
1312
|
+
};
|
|
1313
|
+
return function(d, b) {
|
|
1314
|
+
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1315
|
+
extendStatics(d, b);
|
|
1316
|
+
function __() {
|
|
1317
|
+
this.constructor = d;
|
|
1318
|
+
}
|
|
1319
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1320
|
+
};
|
|
1321
|
+
})();
|
|
1322
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
1323
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
1324
|
+
};
|
|
1325
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1326
|
+
var cssesc_1 = __importDefault(require_cssesc());
|
|
1327
|
+
var util_1 = require_util();
|
|
1328
|
+
var node_1 = __importDefault(require_node$1());
|
|
1329
|
+
var types_1 = require_types();
|
|
1330
|
+
exports.default = function(_super) {
|
|
1331
|
+
__extends(ClassName, _super);
|
|
1332
|
+
function ClassName(opts) {
|
|
1333
|
+
var _this = _super.call(this, opts) || this;
|
|
1334
|
+
_this.type = types_1.CLASS;
|
|
1335
|
+
_this._constructed = true;
|
|
1336
|
+
return _this;
|
|
1337
|
+
}
|
|
1338
|
+
Object.defineProperty(ClassName.prototype, "value", {
|
|
1339
|
+
get: function() {
|
|
1340
|
+
return this._value;
|
|
1341
|
+
},
|
|
1342
|
+
set: function(v) {
|
|
1343
|
+
if (this._constructed) {
|
|
1344
|
+
var escaped = (0, cssesc_1.default)(v, { isIdentifier: true });
|
|
1345
|
+
if (escaped !== v) {
|
|
1346
|
+
(0, util_1.ensureObject)(this, "raws");
|
|
1347
|
+
this.raws.value = escaped;
|
|
1348
|
+
} else if (this.raws) delete this.raws.value;
|
|
1349
|
+
}
|
|
1350
|
+
this._value = v;
|
|
1351
|
+
},
|
|
1352
|
+
enumerable: false,
|
|
1353
|
+
configurable: true
|
|
1354
|
+
});
|
|
1355
|
+
ClassName.prototype.valueToString = function() {
|
|
1356
|
+
return "." + _super.prototype.valueToString.call(this);
|
|
1357
|
+
};
|
|
1358
|
+
return ClassName;
|
|
1359
|
+
}(node_1.default);
|
|
1360
|
+
}));
|
|
1361
|
+
var require_comment = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1362
|
+
var __extends = exports && exports.__extends || (function() {
|
|
1363
|
+
var extendStatics = function(d, b) {
|
|
1364
|
+
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d, b) {
|
|
1365
|
+
d.__proto__ = b;
|
|
1366
|
+
} || function(d, b) {
|
|
1367
|
+
for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
1368
|
+
};
|
|
1369
|
+
return extendStatics(d, b);
|
|
1370
|
+
};
|
|
1371
|
+
return function(d, b) {
|
|
1372
|
+
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1373
|
+
extendStatics(d, b);
|
|
1374
|
+
function __() {
|
|
1375
|
+
this.constructor = d;
|
|
1376
|
+
}
|
|
1377
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1378
|
+
};
|
|
1379
|
+
})();
|
|
1380
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
1381
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
1382
|
+
};
|
|
1383
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1384
|
+
var node_1 = __importDefault(require_node$1());
|
|
1385
|
+
var types_1 = require_types();
|
|
1386
|
+
exports.default = function(_super) {
|
|
1387
|
+
__extends(Comment, _super);
|
|
1388
|
+
function Comment(opts) {
|
|
1389
|
+
var _this = _super.call(this, opts) || this;
|
|
1390
|
+
_this.type = types_1.COMMENT;
|
|
1391
|
+
return _this;
|
|
1392
|
+
}
|
|
1393
|
+
return Comment;
|
|
1394
|
+
}(node_1.default);
|
|
1395
|
+
}));
|
|
1396
|
+
var require_id = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1397
|
+
var __extends = exports && exports.__extends || (function() {
|
|
1398
|
+
var extendStatics = function(d, b) {
|
|
1399
|
+
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d, b) {
|
|
1400
|
+
d.__proto__ = b;
|
|
1401
|
+
} || function(d, b) {
|
|
1402
|
+
for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
1403
|
+
};
|
|
1404
|
+
return extendStatics(d, b);
|
|
1405
|
+
};
|
|
1406
|
+
return function(d, b) {
|
|
1407
|
+
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1408
|
+
extendStatics(d, b);
|
|
1409
|
+
function __() {
|
|
1410
|
+
this.constructor = d;
|
|
1411
|
+
}
|
|
1412
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1413
|
+
};
|
|
1414
|
+
})();
|
|
1415
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
1416
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
1417
|
+
};
|
|
1418
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1419
|
+
var node_1 = __importDefault(require_node$1());
|
|
1420
|
+
var types_1 = require_types();
|
|
1421
|
+
exports.default = function(_super) {
|
|
1422
|
+
__extends(ID, _super);
|
|
1423
|
+
function ID(opts) {
|
|
1424
|
+
var _this = _super.call(this, opts) || this;
|
|
1425
|
+
_this.type = types_1.ID;
|
|
1426
|
+
return _this;
|
|
1427
|
+
}
|
|
1428
|
+
ID.prototype.valueToString = function() {
|
|
1429
|
+
return "#" + _super.prototype.valueToString.call(this);
|
|
1430
|
+
};
|
|
1431
|
+
return ID;
|
|
1432
|
+
}(node_1.default);
|
|
1433
|
+
}));
|
|
1434
|
+
var require_namespace = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1435
|
+
var __extends = exports && exports.__extends || (function() {
|
|
1436
|
+
var extendStatics = function(d, b) {
|
|
1437
|
+
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d, b) {
|
|
1438
|
+
d.__proto__ = b;
|
|
1439
|
+
} || function(d, b) {
|
|
1440
|
+
for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
1441
|
+
};
|
|
1442
|
+
return extendStatics(d, b);
|
|
1443
|
+
};
|
|
1444
|
+
return function(d, b) {
|
|
1445
|
+
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1446
|
+
extendStatics(d, b);
|
|
1447
|
+
function __() {
|
|
1448
|
+
this.constructor = d;
|
|
1449
|
+
}
|
|
1450
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1451
|
+
};
|
|
1452
|
+
})();
|
|
1453
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
1454
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
1455
|
+
};
|
|
1456
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1457
|
+
var cssesc_1 = __importDefault(require_cssesc());
|
|
1458
|
+
var util_1 = require_util();
|
|
1459
|
+
exports.default = function(_super) {
|
|
1460
|
+
__extends(Namespace, _super);
|
|
1461
|
+
function Namespace() {
|
|
1462
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
1463
|
+
}
|
|
1464
|
+
Object.defineProperty(Namespace.prototype, "namespace", {
|
|
1465
|
+
get: function() {
|
|
1466
|
+
return this._namespace;
|
|
1467
|
+
},
|
|
1468
|
+
set: function(namespace) {
|
|
1469
|
+
if (namespace === true || namespace === "*" || namespace === "&") {
|
|
1470
|
+
this._namespace = namespace;
|
|
1471
|
+
if (this.raws) delete this.raws.namespace;
|
|
1472
|
+
return;
|
|
1473
|
+
}
|
|
1474
|
+
var escaped = (0, cssesc_1.default)(namespace, { isIdentifier: true });
|
|
1475
|
+
this._namespace = namespace;
|
|
1476
|
+
if (escaped !== namespace) {
|
|
1477
|
+
(0, util_1.ensureObject)(this, "raws");
|
|
1478
|
+
this.raws.namespace = escaped;
|
|
1479
|
+
} else if (this.raws) delete this.raws.namespace;
|
|
1480
|
+
},
|
|
1481
|
+
enumerable: false,
|
|
1482
|
+
configurable: true
|
|
1483
|
+
});
|
|
1484
|
+
Object.defineProperty(Namespace.prototype, "ns", {
|
|
1485
|
+
get: function() {
|
|
1486
|
+
return this._namespace;
|
|
1487
|
+
},
|
|
1488
|
+
set: function(namespace) {
|
|
1489
|
+
this.namespace = namespace;
|
|
1490
|
+
},
|
|
1491
|
+
enumerable: false,
|
|
1492
|
+
configurable: true
|
|
1493
|
+
});
|
|
1494
|
+
Object.defineProperty(Namespace.prototype, "namespaceString", {
|
|
1495
|
+
get: function() {
|
|
1496
|
+
if (this.namespace) {
|
|
1497
|
+
var ns = this.stringifyProperty("namespace");
|
|
1498
|
+
if (ns === true) return "";
|
|
1499
|
+
else return ns;
|
|
1500
|
+
} else return "";
|
|
1501
|
+
},
|
|
1502
|
+
enumerable: false,
|
|
1503
|
+
configurable: true
|
|
1504
|
+
});
|
|
1505
|
+
Namespace.prototype.qualifiedName = function(value) {
|
|
1506
|
+
if (this.namespace) return "".concat(this.namespaceString, "|").concat(value);
|
|
1507
|
+
else return value;
|
|
1508
|
+
};
|
|
1509
|
+
Namespace.prototype.valueToString = function() {
|
|
1510
|
+
return this.qualifiedName(_super.prototype.valueToString.call(this));
|
|
1511
|
+
};
|
|
1512
|
+
return Namespace;
|
|
1513
|
+
}(__importDefault(require_node$1()).default);
|
|
1514
|
+
}));
|
|
1515
|
+
var require_tag = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1516
|
+
var __extends = exports && exports.__extends || (function() {
|
|
1517
|
+
var extendStatics = function(d, b) {
|
|
1518
|
+
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d, b) {
|
|
1519
|
+
d.__proto__ = b;
|
|
1520
|
+
} || function(d, b) {
|
|
1521
|
+
for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
1522
|
+
};
|
|
1523
|
+
return extendStatics(d, b);
|
|
1524
|
+
};
|
|
1525
|
+
return function(d, b) {
|
|
1526
|
+
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1527
|
+
extendStatics(d, b);
|
|
1528
|
+
function __() {
|
|
1529
|
+
this.constructor = d;
|
|
1530
|
+
}
|
|
1531
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1532
|
+
};
|
|
1533
|
+
})();
|
|
1534
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
1535
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
1536
|
+
};
|
|
1537
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1538
|
+
var namespace_1 = __importDefault(require_namespace());
|
|
1539
|
+
var types_1 = require_types();
|
|
1540
|
+
exports.default = function(_super) {
|
|
1541
|
+
__extends(Tag, _super);
|
|
1542
|
+
function Tag(opts) {
|
|
1543
|
+
var _this = _super.call(this, opts) || this;
|
|
1544
|
+
_this.type = types_1.TAG;
|
|
1545
|
+
return _this;
|
|
1546
|
+
}
|
|
1547
|
+
return Tag;
|
|
1548
|
+
}(namespace_1.default);
|
|
1549
|
+
}));
|
|
1550
|
+
var require_string = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1551
|
+
var __extends = exports && exports.__extends || (function() {
|
|
1552
|
+
var extendStatics = function(d, b) {
|
|
1553
|
+
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d, b) {
|
|
1554
|
+
d.__proto__ = b;
|
|
1555
|
+
} || function(d, b) {
|
|
1556
|
+
for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
1557
|
+
};
|
|
1558
|
+
return extendStatics(d, b);
|
|
1559
|
+
};
|
|
1560
|
+
return function(d, b) {
|
|
1561
|
+
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1562
|
+
extendStatics(d, b);
|
|
1563
|
+
function __() {
|
|
1564
|
+
this.constructor = d;
|
|
1565
|
+
}
|
|
1566
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1567
|
+
};
|
|
1568
|
+
})();
|
|
1569
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
1570
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
1571
|
+
};
|
|
1572
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1573
|
+
var node_1 = __importDefault(require_node$1());
|
|
1574
|
+
var types_1 = require_types();
|
|
1575
|
+
var String = function(_super) {
|
|
1576
|
+
__extends(String, _super);
|
|
1577
|
+
function String(opts) {
|
|
1578
|
+
var _this = _super.call(this, opts) || this;
|
|
1579
|
+
_this.type = types_1.STRING;
|
|
1580
|
+
return _this;
|
|
1581
|
+
}
|
|
1582
|
+
return String;
|
|
1583
|
+
}(node_1.default);
|
|
1584
|
+
exports.default = String;
|
|
1585
|
+
}));
|
|
1586
|
+
var require_pseudo = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1587
|
+
var __extends = exports && exports.__extends || (function() {
|
|
1588
|
+
var extendStatics = function(d, b) {
|
|
1589
|
+
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d, b) {
|
|
1590
|
+
d.__proto__ = b;
|
|
1591
|
+
} || function(d, b) {
|
|
1592
|
+
for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
1593
|
+
};
|
|
1594
|
+
return extendStatics(d, b);
|
|
1595
|
+
};
|
|
1596
|
+
return function(d, b) {
|
|
1597
|
+
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1598
|
+
extendStatics(d, b);
|
|
1599
|
+
function __() {
|
|
1600
|
+
this.constructor = d;
|
|
1601
|
+
}
|
|
1602
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1603
|
+
};
|
|
1604
|
+
})();
|
|
1605
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
1606
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
1607
|
+
};
|
|
1608
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1609
|
+
var container_1 = __importDefault(require_container());
|
|
1610
|
+
var types_1 = require_types();
|
|
1611
|
+
exports.default = function(_super) {
|
|
1612
|
+
__extends(Pseudo, _super);
|
|
1613
|
+
function Pseudo(opts) {
|
|
1614
|
+
var _this = _super.call(this, opts) || this;
|
|
1615
|
+
_this.type = types_1.PSEUDO;
|
|
1616
|
+
return _this;
|
|
1617
|
+
}
|
|
1618
|
+
Pseudo.prototype._stringify = function(options, depth, max) {
|
|
1619
|
+
var _this = this;
|
|
1620
|
+
if (depth >= max) throw new Error("Cannot serialize selector: nesting depth exceeds the maximum of ".concat(max, "."));
|
|
1621
|
+
var params = this.length ? "(" + this.map(function(child) {
|
|
1622
|
+
return _this._stringifyChild(child, options, depth + 1, max);
|
|
1623
|
+
}).join(",") + ")" : "";
|
|
1624
|
+
return [
|
|
1625
|
+
this.rawSpaceBefore,
|
|
1626
|
+
this.stringifyProperty("value"),
|
|
1627
|
+
params,
|
|
1628
|
+
this.rawSpaceAfter
|
|
1629
|
+
].join("");
|
|
1630
|
+
};
|
|
1631
|
+
return Pseudo;
|
|
1632
|
+
}(container_1.default);
|
|
1633
|
+
}));
|
|
1634
|
+
var require_node = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1635
|
+
module.exports = __require("util").deprecate;
|
|
1636
|
+
}));
|
|
1637
|
+
var require_attribute = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1638
|
+
var __extends = exports && exports.__extends || (function() {
|
|
1639
|
+
var extendStatics = function(d, b) {
|
|
1640
|
+
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d, b) {
|
|
1641
|
+
d.__proto__ = b;
|
|
1642
|
+
} || function(d, b) {
|
|
1643
|
+
for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
1644
|
+
};
|
|
1645
|
+
return extendStatics(d, b);
|
|
1646
|
+
};
|
|
1647
|
+
return function(d, b) {
|
|
1648
|
+
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1649
|
+
extendStatics(d, b);
|
|
1650
|
+
function __() {
|
|
1651
|
+
this.constructor = d;
|
|
1652
|
+
}
|
|
1653
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1654
|
+
};
|
|
1655
|
+
})();
|
|
1656
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
1657
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
1658
|
+
};
|
|
1659
|
+
var _a;
|
|
1660
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1661
|
+
exports.unescapeValue = unescapeValue;
|
|
1662
|
+
var cssesc_1 = __importDefault(require_cssesc());
|
|
1663
|
+
var unesc_1 = __importDefault(require_unesc());
|
|
1664
|
+
var namespace_1 = __importDefault(require_namespace());
|
|
1665
|
+
var types_1 = require_types();
|
|
1666
|
+
var deprecate = require_node();
|
|
1667
|
+
var WRAPPED_IN_QUOTES = /^('|")([^]*)\1$/;
|
|
1668
|
+
var warnOfDeprecatedValueAssignment = deprecate(function() {}, "Assigning an attribute a value containing characters that might need to be escaped is deprecated. Call attribute.setValue() instead.");
|
|
1669
|
+
var warnOfDeprecatedQuotedAssignment = deprecate(function() {}, "Assigning attr.quoted is deprecated and has no effect. Assign to attr.quoteMark instead.");
|
|
1670
|
+
var warnOfDeprecatedConstructor = deprecate(function() {}, "Constructing an Attribute selector with a value without specifying quoteMark is deprecated. Note: The value should be unescaped now.");
|
|
1671
|
+
function unescapeValue(value) {
|
|
1672
|
+
var deprecatedUsage = false;
|
|
1673
|
+
var quoteMark = null;
|
|
1674
|
+
var unescaped = value;
|
|
1675
|
+
var m = unescaped.match(WRAPPED_IN_QUOTES);
|
|
1676
|
+
if (m) {
|
|
1677
|
+
quoteMark = m[1];
|
|
1678
|
+
unescaped = m[2];
|
|
1679
|
+
}
|
|
1680
|
+
unescaped = (0, unesc_1.default)(unescaped);
|
|
1681
|
+
if (unescaped !== value) deprecatedUsage = true;
|
|
1682
|
+
return {
|
|
1683
|
+
deprecatedUsage,
|
|
1684
|
+
unescaped,
|
|
1685
|
+
quoteMark
|
|
1686
|
+
};
|
|
1687
|
+
}
|
|
1688
|
+
function handleDeprecatedContructorOpts(opts) {
|
|
1689
|
+
if (opts.quoteMark !== void 0) return opts;
|
|
1690
|
+
if (opts.value === void 0) return opts;
|
|
1691
|
+
warnOfDeprecatedConstructor();
|
|
1692
|
+
var _a = unescapeValue(opts.value), quoteMark = _a.quoteMark, unescaped = _a.unescaped;
|
|
1693
|
+
if (!opts.raws) opts.raws = {};
|
|
1694
|
+
if (opts.raws.value === void 0) opts.raws.value = opts.value;
|
|
1695
|
+
opts.value = unescaped;
|
|
1696
|
+
opts.quoteMark = quoteMark;
|
|
1697
|
+
return opts;
|
|
1698
|
+
}
|
|
1699
|
+
exports.default = function(_super) {
|
|
1700
|
+
__extends(Attribute, _super);
|
|
1701
|
+
function Attribute(opts) {
|
|
1702
|
+
if (opts === void 0) opts = {};
|
|
1703
|
+
var _this = _super.call(this, handleDeprecatedContructorOpts(opts)) || this;
|
|
1704
|
+
_this.type = types_1.ATTRIBUTE;
|
|
1705
|
+
_this.raws = _this.raws || {};
|
|
1706
|
+
Object.defineProperty(_this.raws, "unquoted", {
|
|
1707
|
+
get: deprecate(function() {
|
|
1708
|
+
return _this.value;
|
|
1709
|
+
}, "attr.raws.unquoted is deprecated. Call attr.value instead."),
|
|
1710
|
+
set: deprecate(function() {
|
|
1711
|
+
return _this.value;
|
|
1712
|
+
}, "Setting attr.raws.unquoted is deprecated and has no effect. attr.value is unescaped by default now.")
|
|
1713
|
+
});
|
|
1714
|
+
_this._constructed = true;
|
|
1715
|
+
return _this;
|
|
1716
|
+
}
|
|
1717
|
+
Attribute.prototype.getQuotedValue = function(options) {
|
|
1718
|
+
if (options === void 0) options = {};
|
|
1719
|
+
var cssescopts = CSSESC_QUOTE_OPTIONS[this._determineQuoteMark(options)];
|
|
1720
|
+
return (0, cssesc_1.default)(this._value, cssescopts);
|
|
1721
|
+
};
|
|
1722
|
+
Attribute.prototype._determineQuoteMark = function(options) {
|
|
1723
|
+
return options.smart ? this.smartQuoteMark(options) : this.preferredQuoteMark(options);
|
|
1724
|
+
};
|
|
1725
|
+
Attribute.prototype.setValue = function(value, options) {
|
|
1726
|
+
if (options === void 0) options = {};
|
|
1727
|
+
this._value = value;
|
|
1728
|
+
this._quoteMark = this._determineQuoteMark(options);
|
|
1729
|
+
this._syncRawValue();
|
|
1730
|
+
};
|
|
1731
|
+
Attribute.prototype.smartQuoteMark = function(options) {
|
|
1732
|
+
var v = this.value;
|
|
1733
|
+
var numSingleQuotes = v.replace(/[^']/g, "").length;
|
|
1734
|
+
var numDoubleQuotes = v.replace(/[^"]/g, "").length;
|
|
1735
|
+
if (numSingleQuotes + numDoubleQuotes === 0) {
|
|
1736
|
+
var escaped = (0, cssesc_1.default)(v, { isIdentifier: true });
|
|
1737
|
+
if (escaped === v) return Attribute.NO_QUOTE;
|
|
1738
|
+
else {
|
|
1739
|
+
var pref = this.preferredQuoteMark(options);
|
|
1740
|
+
if (pref === Attribute.NO_QUOTE) {
|
|
1741
|
+
var quote = this.quoteMark || options.quoteMark || Attribute.DOUBLE_QUOTE;
|
|
1742
|
+
var opts = CSSESC_QUOTE_OPTIONS[quote];
|
|
1743
|
+
if ((0, cssesc_1.default)(v, opts).length < escaped.length) return quote;
|
|
1744
|
+
}
|
|
1745
|
+
return pref;
|
|
1746
|
+
}
|
|
1747
|
+
} else if (numDoubleQuotes === numSingleQuotes) return this.preferredQuoteMark(options);
|
|
1748
|
+
else if (numDoubleQuotes < numSingleQuotes) return Attribute.DOUBLE_QUOTE;
|
|
1749
|
+
else return Attribute.SINGLE_QUOTE;
|
|
1750
|
+
};
|
|
1751
|
+
Attribute.prototype.preferredQuoteMark = function(options) {
|
|
1752
|
+
var quoteMark = options.preferCurrentQuoteMark ? this.quoteMark : options.quoteMark;
|
|
1753
|
+
if (quoteMark === void 0) quoteMark = options.preferCurrentQuoteMark ? options.quoteMark : this.quoteMark;
|
|
1754
|
+
if (quoteMark === void 0) quoteMark = Attribute.DOUBLE_QUOTE;
|
|
1755
|
+
return quoteMark;
|
|
1756
|
+
};
|
|
1757
|
+
Object.defineProperty(Attribute.prototype, "quoted", {
|
|
1758
|
+
get: function() {
|
|
1759
|
+
var qm = this.quoteMark;
|
|
1760
|
+
return qm === "'" || qm === "\"";
|
|
1761
|
+
},
|
|
1762
|
+
set: function(value) {
|
|
1763
|
+
warnOfDeprecatedQuotedAssignment();
|
|
1764
|
+
},
|
|
1765
|
+
enumerable: false,
|
|
1766
|
+
configurable: true
|
|
1767
|
+
});
|
|
1768
|
+
Object.defineProperty(Attribute.prototype, "quoteMark", {
|
|
1769
|
+
get: function() {
|
|
1770
|
+
return this._quoteMark;
|
|
1771
|
+
},
|
|
1772
|
+
set: function(quoteMark) {
|
|
1773
|
+
if (!this._constructed) {
|
|
1774
|
+
this._quoteMark = quoteMark;
|
|
1775
|
+
return;
|
|
1776
|
+
}
|
|
1777
|
+
if (this._quoteMark !== quoteMark) {
|
|
1778
|
+
this._quoteMark = quoteMark;
|
|
1779
|
+
this._syncRawValue();
|
|
1780
|
+
}
|
|
1781
|
+
},
|
|
1782
|
+
enumerable: false,
|
|
1783
|
+
configurable: true
|
|
1784
|
+
});
|
|
1785
|
+
Attribute.prototype._syncRawValue = function() {
|
|
1786
|
+
var rawValue = (0, cssesc_1.default)(this._value, CSSESC_QUOTE_OPTIONS[this.quoteMark]);
|
|
1787
|
+
if (rawValue === this._value) {
|
|
1788
|
+
if (this.raws) delete this.raws.value;
|
|
1789
|
+
} else this.raws.value = rawValue;
|
|
1790
|
+
};
|
|
1791
|
+
Object.defineProperty(Attribute.prototype, "qualifiedAttribute", {
|
|
1792
|
+
get: function() {
|
|
1793
|
+
return this.qualifiedName(this.raws.attribute || this.attribute);
|
|
1794
|
+
},
|
|
1795
|
+
enumerable: false,
|
|
1796
|
+
configurable: true
|
|
1797
|
+
});
|
|
1798
|
+
Object.defineProperty(Attribute.prototype, "insensitiveFlag", {
|
|
1799
|
+
get: function() {
|
|
1800
|
+
return this.insensitive ? "i" : "";
|
|
1801
|
+
},
|
|
1802
|
+
enumerable: false,
|
|
1803
|
+
configurable: true
|
|
1804
|
+
});
|
|
1805
|
+
Object.defineProperty(Attribute.prototype, "value", {
|
|
1806
|
+
get: function() {
|
|
1807
|
+
return this._value;
|
|
1808
|
+
},
|
|
1809
|
+
set: function(v) {
|
|
1810
|
+
if (this._constructed) {
|
|
1811
|
+
var _a = unescapeValue(v), deprecatedUsage = _a.deprecatedUsage, unescaped = _a.unescaped, quoteMark = _a.quoteMark;
|
|
1812
|
+
if (deprecatedUsage) warnOfDeprecatedValueAssignment();
|
|
1813
|
+
if (unescaped === this._value && quoteMark === this._quoteMark) return;
|
|
1814
|
+
this._value = unescaped;
|
|
1815
|
+
this._quoteMark = quoteMark;
|
|
1816
|
+
this._syncRawValue();
|
|
1817
|
+
} else this._value = v;
|
|
1818
|
+
},
|
|
1819
|
+
enumerable: false,
|
|
1820
|
+
configurable: true
|
|
1821
|
+
});
|
|
1822
|
+
Object.defineProperty(Attribute.prototype, "insensitive", {
|
|
1823
|
+
get: function() {
|
|
1824
|
+
return this._insensitive;
|
|
1825
|
+
},
|
|
1826
|
+
set: function(insensitive) {
|
|
1827
|
+
if (!insensitive) {
|
|
1828
|
+
this._insensitive = false;
|
|
1829
|
+
if (this.raws && (this.raws.insensitiveFlag === "I" || this.raws.insensitiveFlag === "i")) this.raws.insensitiveFlag = void 0;
|
|
1830
|
+
}
|
|
1831
|
+
this._insensitive = insensitive;
|
|
1832
|
+
},
|
|
1833
|
+
enumerable: false,
|
|
1834
|
+
configurable: true
|
|
1835
|
+
});
|
|
1836
|
+
Object.defineProperty(Attribute.prototype, "attribute", {
|
|
1837
|
+
get: function() {
|
|
1838
|
+
return this._attribute;
|
|
1839
|
+
},
|
|
1840
|
+
set: function(name) {
|
|
1841
|
+
this._handleEscapes("attribute", name);
|
|
1842
|
+
this._attribute = name;
|
|
1843
|
+
},
|
|
1844
|
+
enumerable: false,
|
|
1845
|
+
configurable: true
|
|
1846
|
+
});
|
|
1847
|
+
Attribute.prototype._handleEscapes = function(prop, value) {
|
|
1848
|
+
if (this._constructed) {
|
|
1849
|
+
var escaped = (0, cssesc_1.default)(value, { isIdentifier: true });
|
|
1850
|
+
if (escaped !== value) this.raws[prop] = escaped;
|
|
1851
|
+
else delete this.raws[prop];
|
|
1852
|
+
}
|
|
1853
|
+
};
|
|
1854
|
+
Attribute.prototype._spacesFor = function(name) {
|
|
1855
|
+
var attrSpaces = {
|
|
1856
|
+
before: "",
|
|
1857
|
+
after: ""
|
|
1858
|
+
};
|
|
1859
|
+
var spaces = this.spaces[name] || {};
|
|
1860
|
+
var rawSpaces = this.raws.spaces && this.raws.spaces[name] || {};
|
|
1861
|
+
return Object.assign(attrSpaces, spaces, rawSpaces);
|
|
1862
|
+
};
|
|
1863
|
+
Attribute.prototype._stringFor = function(name, spaceName, concat) {
|
|
1864
|
+
if (spaceName === void 0) spaceName = name;
|
|
1865
|
+
if (concat === void 0) concat = defaultAttrConcat;
|
|
1866
|
+
var attrSpaces = this._spacesFor(spaceName);
|
|
1867
|
+
return concat(this.stringifyProperty(name), attrSpaces);
|
|
1868
|
+
};
|
|
1869
|
+
Attribute.prototype.offsetOf = function(name) {
|
|
1870
|
+
var count = 1;
|
|
1871
|
+
var attributeSpaces = this._spacesFor("attribute");
|
|
1872
|
+
count += attributeSpaces.before.length;
|
|
1873
|
+
if (name === "namespace" || name === "ns") return this.namespace ? count : -1;
|
|
1874
|
+
if (name === "attributeNS") return count;
|
|
1875
|
+
count += this.namespaceString.length;
|
|
1876
|
+
if (this.namespace) count += 1;
|
|
1877
|
+
if (name === "attribute") return count;
|
|
1878
|
+
count += this.stringifyProperty("attribute").length;
|
|
1879
|
+
count += attributeSpaces.after.length;
|
|
1880
|
+
var operatorSpaces = this._spacesFor("operator");
|
|
1881
|
+
count += operatorSpaces.before.length;
|
|
1882
|
+
var operator = this.stringifyProperty("operator");
|
|
1883
|
+
if (name === "operator") return operator ? count : -1;
|
|
1884
|
+
count += operator.length;
|
|
1885
|
+
count += operatorSpaces.after.length;
|
|
1886
|
+
var valueSpaces = this._spacesFor("value");
|
|
1887
|
+
count += valueSpaces.before.length;
|
|
1888
|
+
var value = this.stringifyProperty("value");
|
|
1889
|
+
if (name === "value") return value ? count : -1;
|
|
1890
|
+
count += value.length;
|
|
1891
|
+
count += valueSpaces.after.length;
|
|
1892
|
+
var insensitiveSpaces = this._spacesFor("insensitive");
|
|
1893
|
+
count += insensitiveSpaces.before.length;
|
|
1894
|
+
if (name === "insensitive") return this.insensitive ? count : -1;
|
|
1895
|
+
return -1;
|
|
1896
|
+
};
|
|
1897
|
+
Attribute.prototype.toString = function() {
|
|
1898
|
+
var _this = this;
|
|
1899
|
+
var selector = [this.rawSpaceBefore, "["];
|
|
1900
|
+
selector.push(this._stringFor("qualifiedAttribute", "attribute"));
|
|
1901
|
+
if (this.operator && (this.value || this.value === "")) {
|
|
1902
|
+
selector.push(this._stringFor("operator"));
|
|
1903
|
+
selector.push(this._stringFor("value"));
|
|
1904
|
+
selector.push(this._stringFor("insensitiveFlag", "insensitive", function(attrValue, attrSpaces) {
|
|
1905
|
+
if (attrValue.length > 0 && !_this.quoted && attrSpaces.before.length === 0 && !(_this.spaces.value && _this.spaces.value.after)) attrSpaces.before = " ";
|
|
1906
|
+
return defaultAttrConcat(attrValue, attrSpaces);
|
|
1907
|
+
}));
|
|
1908
|
+
}
|
|
1909
|
+
selector.push("]");
|
|
1910
|
+
selector.push(this.rawSpaceAfter);
|
|
1911
|
+
return selector.join("");
|
|
1912
|
+
};
|
|
1913
|
+
Attribute.NO_QUOTE = null;
|
|
1914
|
+
Attribute.SINGLE_QUOTE = "'";
|
|
1915
|
+
Attribute.DOUBLE_QUOTE = "\"";
|
|
1916
|
+
return Attribute;
|
|
1917
|
+
}(namespace_1.default);
|
|
1918
|
+
var CSSESC_QUOTE_OPTIONS = (_a = {
|
|
1919
|
+
"'": {
|
|
1920
|
+
quotes: "single",
|
|
1921
|
+
wrap: true
|
|
1922
|
+
},
|
|
1923
|
+
"\"": {
|
|
1924
|
+
quotes: "double",
|
|
1925
|
+
wrap: true
|
|
1926
|
+
}
|
|
1927
|
+
}, _a[null] = { isIdentifier: true }, _a);
|
|
1928
|
+
function defaultAttrConcat(attrValue, attrSpaces) {
|
|
1929
|
+
return "".concat(attrSpaces.before).concat(attrValue).concat(attrSpaces.after);
|
|
1930
|
+
}
|
|
1931
|
+
}));
|
|
1932
|
+
var require_universal = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1933
|
+
var __extends = exports && exports.__extends || (function() {
|
|
1934
|
+
var extendStatics = function(d, b) {
|
|
1935
|
+
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d, b) {
|
|
1936
|
+
d.__proto__ = b;
|
|
1937
|
+
} || function(d, b) {
|
|
1938
|
+
for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
1939
|
+
};
|
|
1940
|
+
return extendStatics(d, b);
|
|
1941
|
+
};
|
|
1942
|
+
return function(d, b) {
|
|
1943
|
+
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1944
|
+
extendStatics(d, b);
|
|
1945
|
+
function __() {
|
|
1946
|
+
this.constructor = d;
|
|
1947
|
+
}
|
|
1948
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1949
|
+
};
|
|
1950
|
+
})();
|
|
1951
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
1952
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
1953
|
+
};
|
|
1954
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1955
|
+
var namespace_1 = __importDefault(require_namespace());
|
|
1956
|
+
var types_1 = require_types();
|
|
1957
|
+
exports.default = function(_super) {
|
|
1958
|
+
__extends(Universal, _super);
|
|
1959
|
+
function Universal(opts) {
|
|
1960
|
+
var _this = _super.call(this, opts) || this;
|
|
1961
|
+
_this.type = types_1.UNIVERSAL;
|
|
1962
|
+
_this.value = "*";
|
|
1963
|
+
return _this;
|
|
1964
|
+
}
|
|
1965
|
+
return Universal;
|
|
1966
|
+
}(namespace_1.default);
|
|
1967
|
+
}));
|
|
1968
|
+
var require_combinator = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1969
|
+
var __extends = exports && exports.__extends || (function() {
|
|
1970
|
+
var extendStatics = function(d, b) {
|
|
1971
|
+
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d, b) {
|
|
1972
|
+
d.__proto__ = b;
|
|
1973
|
+
} || function(d, b) {
|
|
1974
|
+
for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
1975
|
+
};
|
|
1976
|
+
return extendStatics(d, b);
|
|
1977
|
+
};
|
|
1978
|
+
return function(d, b) {
|
|
1979
|
+
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1980
|
+
extendStatics(d, b);
|
|
1981
|
+
function __() {
|
|
1982
|
+
this.constructor = d;
|
|
1983
|
+
}
|
|
1984
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1985
|
+
};
|
|
1986
|
+
})();
|
|
1987
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
1988
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
1989
|
+
};
|
|
1990
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1991
|
+
var node_1 = __importDefault(require_node$1());
|
|
1992
|
+
var types_1 = require_types();
|
|
1993
|
+
exports.default = function(_super) {
|
|
1994
|
+
__extends(Combinator, _super);
|
|
1995
|
+
function Combinator(opts) {
|
|
1996
|
+
var _this = _super.call(this, opts) || this;
|
|
1997
|
+
_this.type = types_1.COMBINATOR;
|
|
1998
|
+
return _this;
|
|
1999
|
+
}
|
|
2000
|
+
return Combinator;
|
|
2001
|
+
}(node_1.default);
|
|
2002
|
+
}));
|
|
2003
|
+
var require_nesting = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
2004
|
+
var __extends = exports && exports.__extends || (function() {
|
|
2005
|
+
var extendStatics = function(d, b) {
|
|
2006
|
+
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d, b) {
|
|
2007
|
+
d.__proto__ = b;
|
|
2008
|
+
} || function(d, b) {
|
|
2009
|
+
for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
2010
|
+
};
|
|
2011
|
+
return extendStatics(d, b);
|
|
2012
|
+
};
|
|
2013
|
+
return function(d, b) {
|
|
2014
|
+
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
2015
|
+
extendStatics(d, b);
|
|
2016
|
+
function __() {
|
|
2017
|
+
this.constructor = d;
|
|
2018
|
+
}
|
|
2019
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
2020
|
+
};
|
|
2021
|
+
})();
|
|
2022
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
2023
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
2024
|
+
};
|
|
2025
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2026
|
+
var node_1 = __importDefault(require_node$1());
|
|
2027
|
+
var types_1 = require_types();
|
|
2028
|
+
exports.default = function(_super) {
|
|
2029
|
+
__extends(Nesting, _super);
|
|
2030
|
+
function Nesting(opts) {
|
|
2031
|
+
var _this = _super.call(this, opts) || this;
|
|
2032
|
+
_this.type = types_1.NESTING;
|
|
2033
|
+
_this.value = "&";
|
|
2034
|
+
return _this;
|
|
2035
|
+
}
|
|
2036
|
+
return Nesting;
|
|
2037
|
+
}(node_1.default);
|
|
2038
|
+
}));
|
|
2039
|
+
var require_sortAscending = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
2040
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2041
|
+
exports.default = sortAscending;
|
|
2042
|
+
function sortAscending(list) {
|
|
2043
|
+
return list.sort(function(a, b) {
|
|
2044
|
+
return a - b;
|
|
2045
|
+
});
|
|
2046
|
+
}
|
|
2047
|
+
}));
|
|
2048
|
+
var require_tokenTypes = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
2049
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2050
|
+
exports.combinator = exports.word = exports.comment = exports.str = exports.tab = exports.newline = exports.feed = exports.cr = exports.backslash = exports.bang = exports.slash = exports.doubleQuote = exports.singleQuote = exports.space = exports.greaterThan = exports.pipe = exports.equals = exports.plus = exports.caret = exports.tilde = exports.dollar = exports.closeSquare = exports.openSquare = exports.closeParenthesis = exports.openParenthesis = exports.semicolon = exports.colon = exports.comma = exports.at = exports.asterisk = exports.ampersand = void 0;
|
|
2051
|
+
exports.ampersand = 38;
|
|
2052
|
+
exports.asterisk = 42;
|
|
2053
|
+
exports.at = 64;
|
|
2054
|
+
exports.comma = 44;
|
|
2055
|
+
exports.colon = 58;
|
|
2056
|
+
exports.semicolon = 59;
|
|
2057
|
+
exports.openParenthesis = 40;
|
|
2058
|
+
exports.closeParenthesis = 41;
|
|
2059
|
+
exports.openSquare = 91;
|
|
2060
|
+
exports.closeSquare = 93;
|
|
2061
|
+
exports.dollar = 36;
|
|
2062
|
+
exports.tilde = 126;
|
|
2063
|
+
exports.caret = 94;
|
|
2064
|
+
exports.plus = 43;
|
|
2065
|
+
exports.equals = 61;
|
|
2066
|
+
exports.pipe = 124;
|
|
2067
|
+
exports.greaterThan = 62;
|
|
2068
|
+
exports.space = 32;
|
|
2069
|
+
exports.singleQuote = 39;
|
|
2070
|
+
exports.doubleQuote = 34;
|
|
2071
|
+
exports.slash = 47;
|
|
2072
|
+
exports.bang = 33;
|
|
2073
|
+
exports.backslash = 92;
|
|
2074
|
+
exports.cr = 13;
|
|
2075
|
+
exports.feed = 12;
|
|
2076
|
+
exports.newline = 10;
|
|
2077
|
+
exports.tab = 9;
|
|
2078
|
+
exports.str = exports.singleQuote;
|
|
2079
|
+
exports.comment = -1;
|
|
2080
|
+
exports.word = -2;
|
|
2081
|
+
exports.combinator = -3;
|
|
2082
|
+
}));
|
|
2083
|
+
var require_tokenize = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
2084
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
2085
|
+
if (k2 === void 0) k2 = k;
|
|
2086
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
2087
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) desc = {
|
|
2088
|
+
enumerable: true,
|
|
2089
|
+
get: function() {
|
|
2090
|
+
return m[k];
|
|
2091
|
+
}
|
|
2092
|
+
};
|
|
2093
|
+
Object.defineProperty(o, k2, desc);
|
|
2094
|
+
}) : (function(o, m, k, k2) {
|
|
2095
|
+
if (k2 === void 0) k2 = k;
|
|
2096
|
+
o[k2] = m[k];
|
|
2097
|
+
}));
|
|
2098
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
|
|
2099
|
+
Object.defineProperty(o, "default", {
|
|
2100
|
+
enumerable: true,
|
|
2101
|
+
value: v
|
|
2102
|
+
});
|
|
2103
|
+
}) : function(o, v) {
|
|
2104
|
+
o["default"] = v;
|
|
2105
|
+
});
|
|
2106
|
+
var __importStar = exports && exports.__importStar || (function() {
|
|
2107
|
+
var ownKeys = function(o) {
|
|
2108
|
+
ownKeys = Object.getOwnPropertyNames || function(o) {
|
|
2109
|
+
var ar = [];
|
|
2110
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
2111
|
+
return ar;
|
|
2112
|
+
};
|
|
2113
|
+
return ownKeys(o);
|
|
2114
|
+
};
|
|
2115
|
+
return function(mod) {
|
|
2116
|
+
if (mod && mod.__esModule) return mod;
|
|
2117
|
+
var result = {};
|
|
2118
|
+
if (mod != null) {
|
|
2119
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
2120
|
+
}
|
|
2121
|
+
__setModuleDefault(result, mod);
|
|
2122
|
+
return result;
|
|
2123
|
+
};
|
|
2124
|
+
})();
|
|
2125
|
+
var _a;
|
|
2126
|
+
var _b;
|
|
2127
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2128
|
+
exports.FIELDS = void 0;
|
|
2129
|
+
exports.default = tokenize;
|
|
2130
|
+
var t = __importStar(require_tokenTypes());
|
|
2131
|
+
var unescapable = (_a = {}, _a[t.tab] = true, _a[t.newline] = true, _a[t.cr] = true, _a[t.feed] = true, _a);
|
|
2132
|
+
var wordDelimiters = (_b = {}, _b[t.space] = true, _b[t.tab] = true, _b[t.newline] = true, _b[t.cr] = true, _b[t.feed] = true, _b[t.ampersand] = true, _b[t.asterisk] = true, _b[t.bang] = true, _b[t.comma] = true, _b[t.colon] = true, _b[t.semicolon] = true, _b[t.openParenthesis] = true, _b[t.closeParenthesis] = true, _b[t.openSquare] = true, _b[t.closeSquare] = true, _b[t.singleQuote] = true, _b[t.doubleQuote] = true, _b[t.plus] = true, _b[t.pipe] = true, _b[t.tilde] = true, _b[t.greaterThan] = true, _b[t.equals] = true, _b[t.dollar] = true, _b[t.caret] = true, _b[t.slash] = true, _b);
|
|
2133
|
+
var hex = {};
|
|
2134
|
+
var hexChars = "0123456789abcdefABCDEF";
|
|
2135
|
+
for (var i = 0; i < hexChars.length; i++) hex[hexChars.charCodeAt(i)] = true;
|
|
2136
|
+
function consumeWord(css, start) {
|
|
2137
|
+
var next = start;
|
|
2138
|
+
var code;
|
|
2139
|
+
do {
|
|
2140
|
+
code = css.charCodeAt(next);
|
|
2141
|
+
if (wordDelimiters[code]) return next - 1;
|
|
2142
|
+
else if (code === t.backslash) next = consumeEscape(css, next) + 1;
|
|
2143
|
+
else next++;
|
|
2144
|
+
} while (next < css.length);
|
|
2145
|
+
return next - 1;
|
|
2146
|
+
}
|
|
2147
|
+
function consumeEscape(css, start) {
|
|
2148
|
+
var next = start;
|
|
2149
|
+
var code = css.charCodeAt(next + 1);
|
|
2150
|
+
if (unescapable[code]) {} else if (hex[code]) {
|
|
2151
|
+
var hexDigits = 0;
|
|
2152
|
+
do {
|
|
2153
|
+
next++;
|
|
2154
|
+
hexDigits++;
|
|
2155
|
+
code = css.charCodeAt(next + 1);
|
|
2156
|
+
} while (hex[code] && hexDigits < 6);
|
|
2157
|
+
if (hexDigits < 6 && code === t.space) next++;
|
|
2158
|
+
} else next++;
|
|
2159
|
+
return next;
|
|
2160
|
+
}
|
|
2161
|
+
exports.FIELDS = {
|
|
2162
|
+
TYPE: 0,
|
|
2163
|
+
START_LINE: 1,
|
|
2164
|
+
START_COL: 2,
|
|
2165
|
+
END_LINE: 3,
|
|
2166
|
+
END_COL: 4,
|
|
2167
|
+
START_POS: 5,
|
|
2168
|
+
END_POS: 6
|
|
2169
|
+
};
|
|
2170
|
+
function tokenize(input) {
|
|
2171
|
+
var tokens = [];
|
|
2172
|
+
var css = input.css.valueOf();
|
|
2173
|
+
var length = css.length;
|
|
2174
|
+
var offset = -1;
|
|
2175
|
+
var line = 1;
|
|
2176
|
+
var start = 0;
|
|
2177
|
+
var end = 0;
|
|
2178
|
+
var code, content, endColumn, endLine, escaped, escapePos, last, lines, next, nextLine, nextOffset, quote, tokenType;
|
|
2179
|
+
function unclosed(what, fix) {
|
|
2180
|
+
if (input.safe) {
|
|
2181
|
+
css += fix;
|
|
2182
|
+
next = css.length - 1;
|
|
2183
|
+
} else throw input.error("Unclosed " + what, line, start - offset, start);
|
|
2184
|
+
}
|
|
2185
|
+
while (start < length) {
|
|
2186
|
+
code = css.charCodeAt(start);
|
|
2187
|
+
if (code === t.newline) {
|
|
2188
|
+
offset = start;
|
|
2189
|
+
line += 1;
|
|
2190
|
+
}
|
|
2191
|
+
switch (code) {
|
|
2192
|
+
case t.space:
|
|
2193
|
+
case t.tab:
|
|
2194
|
+
case t.newline:
|
|
2195
|
+
case t.cr:
|
|
2196
|
+
case t.feed:
|
|
2197
|
+
next = start;
|
|
2198
|
+
do {
|
|
2199
|
+
next += 1;
|
|
2200
|
+
code = css.charCodeAt(next);
|
|
2201
|
+
if (code === t.newline) {
|
|
2202
|
+
offset = next;
|
|
2203
|
+
line += 1;
|
|
2204
|
+
}
|
|
2205
|
+
} while (code === t.space || code === t.newline || code === t.tab || code === t.cr || code === t.feed);
|
|
2206
|
+
tokenType = t.space;
|
|
2207
|
+
endLine = line;
|
|
2208
|
+
endColumn = next - offset - 1;
|
|
2209
|
+
end = next;
|
|
2210
|
+
break;
|
|
2211
|
+
case t.plus:
|
|
2212
|
+
case t.greaterThan:
|
|
2213
|
+
case t.tilde:
|
|
2214
|
+
case t.pipe:
|
|
2215
|
+
next = start;
|
|
2216
|
+
do {
|
|
2217
|
+
next += 1;
|
|
2218
|
+
code = css.charCodeAt(next);
|
|
2219
|
+
} while (code === t.plus || code === t.greaterThan || code === t.tilde || code === t.pipe);
|
|
2220
|
+
tokenType = t.combinator;
|
|
2221
|
+
endLine = line;
|
|
2222
|
+
endColumn = start - offset;
|
|
2223
|
+
end = next;
|
|
2224
|
+
break;
|
|
2225
|
+
case t.asterisk:
|
|
2226
|
+
case t.ampersand:
|
|
2227
|
+
case t.bang:
|
|
2228
|
+
case t.comma:
|
|
2229
|
+
case t.equals:
|
|
2230
|
+
case t.dollar:
|
|
2231
|
+
case t.caret:
|
|
2232
|
+
case t.openSquare:
|
|
2233
|
+
case t.closeSquare:
|
|
2234
|
+
case t.colon:
|
|
2235
|
+
case t.semicolon:
|
|
2236
|
+
case t.openParenthesis:
|
|
2237
|
+
case t.closeParenthesis:
|
|
2238
|
+
next = start;
|
|
2239
|
+
tokenType = code;
|
|
2240
|
+
endLine = line;
|
|
2241
|
+
endColumn = start - offset;
|
|
2242
|
+
end = next + 1;
|
|
2243
|
+
break;
|
|
2244
|
+
case t.singleQuote:
|
|
2245
|
+
case t.doubleQuote:
|
|
2246
|
+
quote = code === t.singleQuote ? "'" : "\"";
|
|
2247
|
+
next = start;
|
|
2248
|
+
do {
|
|
2249
|
+
escaped = false;
|
|
2250
|
+
next = css.indexOf(quote, next + 1);
|
|
2251
|
+
if (next === -1) unclosed("quote", quote);
|
|
2252
|
+
escapePos = next;
|
|
2253
|
+
while (css.charCodeAt(escapePos - 1) === t.backslash) {
|
|
2254
|
+
escapePos -= 1;
|
|
2255
|
+
escaped = !escaped;
|
|
2256
|
+
}
|
|
2257
|
+
} while (escaped);
|
|
2258
|
+
tokenType = t.str;
|
|
2259
|
+
endLine = line;
|
|
2260
|
+
endColumn = start - offset;
|
|
2261
|
+
end = next + 1;
|
|
2262
|
+
break;
|
|
2263
|
+
default:
|
|
2264
|
+
if (code === t.slash && css.charCodeAt(start + 1) === t.asterisk) {
|
|
2265
|
+
next = css.indexOf("*/", start + 2) + 1;
|
|
2266
|
+
if (next === 0) unclosed("comment", "*/");
|
|
2267
|
+
content = css.slice(start, next + 1);
|
|
2268
|
+
lines = content.split("\n");
|
|
2269
|
+
last = lines.length - 1;
|
|
2270
|
+
if (last > 0) {
|
|
2271
|
+
nextLine = line + last;
|
|
2272
|
+
nextOffset = next - lines[last].length;
|
|
2273
|
+
} else {
|
|
2274
|
+
nextLine = line;
|
|
2275
|
+
nextOffset = offset;
|
|
2276
|
+
}
|
|
2277
|
+
tokenType = t.comment;
|
|
2278
|
+
line = nextLine;
|
|
2279
|
+
endLine = nextLine;
|
|
2280
|
+
endColumn = next - nextOffset;
|
|
2281
|
+
} else if (code === t.slash) {
|
|
2282
|
+
next = start;
|
|
2283
|
+
tokenType = code;
|
|
2284
|
+
endLine = line;
|
|
2285
|
+
endColumn = start - offset;
|
|
2286
|
+
end = next + 1;
|
|
2287
|
+
} else {
|
|
2288
|
+
next = consumeWord(css, start);
|
|
2289
|
+
tokenType = t.word;
|
|
2290
|
+
endLine = line;
|
|
2291
|
+
endColumn = next - offset;
|
|
2292
|
+
}
|
|
2293
|
+
end = next + 1;
|
|
2294
|
+
}
|
|
2295
|
+
tokens.push([
|
|
2296
|
+
tokenType,
|
|
2297
|
+
line,
|
|
2298
|
+
start - offset,
|
|
2299
|
+
endLine,
|
|
2300
|
+
endColumn,
|
|
2301
|
+
start,
|
|
2302
|
+
end
|
|
2303
|
+
]);
|
|
2304
|
+
if (nextOffset) {
|
|
2305
|
+
offset = nextOffset;
|
|
2306
|
+
nextOffset = null;
|
|
2307
|
+
}
|
|
2308
|
+
start = end;
|
|
2309
|
+
}
|
|
2310
|
+
return tokens;
|
|
2311
|
+
}
|
|
2312
|
+
}));
|
|
2313
|
+
var require_parser = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
2314
|
+
var __assign = exports && exports.__assign || function() {
|
|
2315
|
+
__assign = Object.assign || function(t) {
|
|
2316
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
2317
|
+
s = arguments[i];
|
|
2318
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
2319
|
+
}
|
|
2320
|
+
return t;
|
|
2321
|
+
};
|
|
2322
|
+
return __assign.apply(this, arguments);
|
|
2323
|
+
};
|
|
2324
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
2325
|
+
if (k2 === void 0) k2 = k;
|
|
2326
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
2327
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) desc = {
|
|
2328
|
+
enumerable: true,
|
|
2329
|
+
get: function() {
|
|
2330
|
+
return m[k];
|
|
2331
|
+
}
|
|
2332
|
+
};
|
|
2333
|
+
Object.defineProperty(o, k2, desc);
|
|
2334
|
+
}) : (function(o, m, k, k2) {
|
|
2335
|
+
if (k2 === void 0) k2 = k;
|
|
2336
|
+
o[k2] = m[k];
|
|
2337
|
+
}));
|
|
2338
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
|
|
2339
|
+
Object.defineProperty(o, "default", {
|
|
2340
|
+
enumerable: true,
|
|
2341
|
+
value: v
|
|
2342
|
+
});
|
|
2343
|
+
}) : function(o, v) {
|
|
2344
|
+
o["default"] = v;
|
|
2345
|
+
});
|
|
2346
|
+
var __importStar = exports && exports.__importStar || (function() {
|
|
2347
|
+
var ownKeys = function(o) {
|
|
2348
|
+
ownKeys = Object.getOwnPropertyNames || function(o) {
|
|
2349
|
+
var ar = [];
|
|
2350
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
2351
|
+
return ar;
|
|
2352
|
+
};
|
|
2353
|
+
return ownKeys(o);
|
|
2354
|
+
};
|
|
2355
|
+
return function(mod) {
|
|
2356
|
+
if (mod && mod.__esModule) return mod;
|
|
2357
|
+
var result = {};
|
|
2358
|
+
if (mod != null) {
|
|
2359
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
2360
|
+
}
|
|
2361
|
+
__setModuleDefault(result, mod);
|
|
2362
|
+
return result;
|
|
2363
|
+
};
|
|
2364
|
+
})();
|
|
2365
|
+
var __read = exports && exports.__read || function(o, n) {
|
|
2366
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
2367
|
+
if (!m) return o;
|
|
2368
|
+
var i = m.call(o), r, ar = [], e;
|
|
2369
|
+
try {
|
|
2370
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
2371
|
+
} catch (error) {
|
|
2372
|
+
e = { error };
|
|
2373
|
+
} finally {
|
|
2374
|
+
try {
|
|
2375
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
2376
|
+
} finally {
|
|
2377
|
+
if (e) throw e.error;
|
|
2378
|
+
}
|
|
2379
|
+
}
|
|
2380
|
+
return ar;
|
|
2381
|
+
};
|
|
2382
|
+
var __spreadArray = exports && exports.__spreadArray || function(to, from, pack) {
|
|
2383
|
+
if (pack || arguments.length === 2) {
|
|
2384
|
+
for (var i = 0, l = from.length, ar; i < l; i++) if (ar || !(i in from)) {
|
|
2385
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
2386
|
+
ar[i] = from[i];
|
|
2387
|
+
}
|
|
2388
|
+
}
|
|
2389
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
2390
|
+
};
|
|
2391
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
2392
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
2393
|
+
};
|
|
2394
|
+
var _a;
|
|
2395
|
+
var _b;
|
|
2396
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2397
|
+
var root_1 = __importDefault(require_root());
|
|
2398
|
+
var selector_1 = __importDefault(require_selector());
|
|
2399
|
+
var className_1 = __importDefault(require_className());
|
|
2400
|
+
var comment_1 = __importDefault(require_comment());
|
|
2401
|
+
var id_1 = __importDefault(require_id());
|
|
2402
|
+
var tag_1 = __importDefault(require_tag());
|
|
2403
|
+
var string_1 = __importDefault(require_string());
|
|
2404
|
+
var pseudo_1 = __importDefault(require_pseudo());
|
|
2405
|
+
var attribute_1 = __importStar(require_attribute());
|
|
2406
|
+
var universal_1 = __importDefault(require_universal());
|
|
2407
|
+
var combinator_1 = __importDefault(require_combinator());
|
|
2408
|
+
var nesting_1 = __importDefault(require_nesting());
|
|
2409
|
+
var sortAscending_1 = __importDefault(require_sortAscending());
|
|
2410
|
+
var tokenize_1 = __importStar(require_tokenize());
|
|
2411
|
+
var tokens = __importStar(require_tokenTypes());
|
|
2412
|
+
var types = __importStar(require_types());
|
|
2413
|
+
var util_1 = require_util();
|
|
2414
|
+
var WHITESPACE_TOKENS = (_a = {}, _a[tokens.space] = true, _a[tokens.cr] = true, _a[tokens.feed] = true, _a[tokens.newline] = true, _a[tokens.tab] = true, _a);
|
|
2415
|
+
var WHITESPACE_EQUIV_TOKENS = __assign(__assign({}, WHITESPACE_TOKENS), (_b = {}, _b[tokens.comment] = true, _b));
|
|
2416
|
+
function tokenStart(token) {
|
|
2417
|
+
return {
|
|
2418
|
+
line: token[tokenize_1.FIELDS.START_LINE],
|
|
2419
|
+
column: token[tokenize_1.FIELDS.START_COL]
|
|
2420
|
+
};
|
|
2421
|
+
}
|
|
2422
|
+
function tokenEnd(token) {
|
|
2423
|
+
return {
|
|
2424
|
+
line: token[tokenize_1.FIELDS.END_LINE],
|
|
2425
|
+
column: token[tokenize_1.FIELDS.END_COL]
|
|
2426
|
+
};
|
|
2427
|
+
}
|
|
2428
|
+
function getSource(startLine, startColumn, endLine, endColumn) {
|
|
2429
|
+
return {
|
|
2430
|
+
start: {
|
|
2431
|
+
line: startLine,
|
|
2432
|
+
column: startColumn
|
|
2433
|
+
},
|
|
2434
|
+
end: {
|
|
2435
|
+
line: endLine,
|
|
2436
|
+
column: endColumn
|
|
2437
|
+
}
|
|
2438
|
+
};
|
|
2439
|
+
}
|
|
2440
|
+
function getTokenSource(token) {
|
|
2441
|
+
return getSource(token[tokenize_1.FIELDS.START_LINE], token[tokenize_1.FIELDS.START_COL], token[tokenize_1.FIELDS.END_LINE], token[tokenize_1.FIELDS.END_COL]);
|
|
2442
|
+
}
|
|
2443
|
+
function getTokenSourceSpan(startToken, endToken) {
|
|
2444
|
+
if (!startToken) return;
|
|
2445
|
+
return getSource(startToken[tokenize_1.FIELDS.START_LINE], startToken[tokenize_1.FIELDS.START_COL], endToken[tokenize_1.FIELDS.END_LINE], endToken[tokenize_1.FIELDS.END_COL]);
|
|
2446
|
+
}
|
|
2447
|
+
function unescapeProp(node, prop) {
|
|
2448
|
+
var value = node[prop];
|
|
2449
|
+
if (typeof value !== "string") return;
|
|
2450
|
+
if (value.indexOf("\\") !== -1) {
|
|
2451
|
+
(0, util_1.ensureObject)(node, "raws");
|
|
2452
|
+
node[prop] = (0, util_1.unesc)(value);
|
|
2453
|
+
if (node.raws[prop] === void 0) node.raws[prop] = value;
|
|
2454
|
+
}
|
|
2455
|
+
return node;
|
|
2456
|
+
}
|
|
2457
|
+
function indexesOf(array, item) {
|
|
2458
|
+
var i = -1;
|
|
2459
|
+
var indexes = [];
|
|
2460
|
+
while ((i = array.indexOf(item, i + 1)) !== -1) indexes.push(i);
|
|
2461
|
+
return indexes;
|
|
2462
|
+
}
|
|
2463
|
+
function uniqs() {
|
|
2464
|
+
return Array.from(new Set(Array.prototype.concat.apply([], arguments)));
|
|
2465
|
+
}
|
|
2466
|
+
exports.default = function() {
|
|
2467
|
+
function Parser(rule, options) {
|
|
2468
|
+
if (options === void 0) options = {};
|
|
2469
|
+
this.rule = rule;
|
|
2470
|
+
this.options = Object.assign({
|
|
2471
|
+
lossy: false,
|
|
2472
|
+
safe: false
|
|
2473
|
+
}, options);
|
|
2474
|
+
this.position = 0;
|
|
2475
|
+
this.nestingDepth = 0;
|
|
2476
|
+
this.maxNestingDepth = (0, util_1.resolveMaxNestingDepth)(this.options.maxNestingDepth);
|
|
2477
|
+
this.css = typeof this.rule === "string" ? this.rule : this.rule.selector;
|
|
2478
|
+
this.tokens = (0, tokenize_1.default)({
|
|
2479
|
+
css: this.css,
|
|
2480
|
+
error: this._errorGenerator(),
|
|
2481
|
+
safe: this.options.safe
|
|
2482
|
+
});
|
|
2483
|
+
var rootSource = getTokenSourceSpan(this.tokens[0], this.tokens[this.tokens.length - 1]);
|
|
2484
|
+
this.root = new root_1.default({ source: rootSource });
|
|
2485
|
+
this.root.errorGenerator = this._errorGenerator();
|
|
2486
|
+
var selector = new selector_1.default({
|
|
2487
|
+
source: { start: {
|
|
2488
|
+
line: 1,
|
|
2489
|
+
column: 1
|
|
2490
|
+
} },
|
|
2491
|
+
sourceIndex: 0
|
|
2492
|
+
});
|
|
2493
|
+
this.root.append(selector);
|
|
2494
|
+
this.current = selector;
|
|
2495
|
+
this.loop();
|
|
2496
|
+
}
|
|
2497
|
+
Parser.prototype._errorGenerator = function() {
|
|
2498
|
+
var _this = this;
|
|
2499
|
+
return function(message, errorOptions) {
|
|
2500
|
+
if (typeof _this.rule === "string") return new Error(message);
|
|
2501
|
+
return _this.rule.error(message, errorOptions);
|
|
2502
|
+
};
|
|
2503
|
+
};
|
|
2504
|
+
Parser.prototype.attribute = function() {
|
|
2505
|
+
var attr = [];
|
|
2506
|
+
var startingToken = this.currToken;
|
|
2507
|
+
this.position++;
|
|
2508
|
+
while (this.position < this.tokens.length && this.currToken[tokenize_1.FIELDS.TYPE] !== tokens.closeSquare) {
|
|
2509
|
+
attr.push(this.currToken);
|
|
2510
|
+
this.position++;
|
|
2511
|
+
}
|
|
2512
|
+
if (!this.currToken) return this.expected("closing square bracket", startingToken[tokenize_1.FIELDS.START_POS]);
|
|
2513
|
+
if (this.currToken[tokenize_1.FIELDS.TYPE] !== tokens.closeSquare) return this.expected("closing square bracket", this.currToken[tokenize_1.FIELDS.START_POS]);
|
|
2514
|
+
var len = attr.length;
|
|
2515
|
+
var node = {
|
|
2516
|
+
source: getSource(startingToken[1], startingToken[2], this.currToken[3], this.currToken[4]),
|
|
2517
|
+
sourceIndex: startingToken[tokenize_1.FIELDS.START_POS]
|
|
2518
|
+
};
|
|
2519
|
+
if (len === 1 && !~[tokens.word].indexOf(attr[0][tokenize_1.FIELDS.TYPE])) return this.expected("attribute", attr[0][tokenize_1.FIELDS.START_POS]);
|
|
2520
|
+
var pos = 0;
|
|
2521
|
+
var spaceBefore = "";
|
|
2522
|
+
var commentBefore = "";
|
|
2523
|
+
var lastAdded = null;
|
|
2524
|
+
var spaceAfterMeaningfulToken = false;
|
|
2525
|
+
while (pos < len) {
|
|
2526
|
+
var token = attr[pos];
|
|
2527
|
+
var content = this.content(token);
|
|
2528
|
+
var next = attr[pos + 1];
|
|
2529
|
+
switch (token[tokenize_1.FIELDS.TYPE]) {
|
|
2530
|
+
case tokens.space:
|
|
2531
|
+
spaceAfterMeaningfulToken = true;
|
|
2532
|
+
if (this.options.lossy) break;
|
|
2533
|
+
if (lastAdded) {
|
|
2534
|
+
(0, util_1.ensureObject)(node, "spaces", lastAdded);
|
|
2535
|
+
var prevContent = node.spaces[lastAdded].after || "";
|
|
2536
|
+
node.spaces[lastAdded].after = prevContent + content;
|
|
2537
|
+
var existingComment = (0, util_1.getProp)(node, "raws", "spaces", lastAdded, "after") || null;
|
|
2538
|
+
if (existingComment) node.raws.spaces[lastAdded].after = existingComment + content;
|
|
2539
|
+
} else {
|
|
2540
|
+
spaceBefore = spaceBefore + content;
|
|
2541
|
+
commentBefore = commentBefore + content;
|
|
2542
|
+
}
|
|
2543
|
+
break;
|
|
2544
|
+
case tokens.asterisk:
|
|
2545
|
+
if (next[tokenize_1.FIELDS.TYPE] === tokens.equals) {
|
|
2546
|
+
node.operator = content;
|
|
2547
|
+
lastAdded = "operator";
|
|
2548
|
+
} else if ((!node.namespace || lastAdded === "namespace" && !spaceAfterMeaningfulToken) && next) {
|
|
2549
|
+
if (spaceBefore) {
|
|
2550
|
+
(0, util_1.ensureObject)(node, "spaces", "attribute");
|
|
2551
|
+
node.spaces.attribute.before = spaceBefore;
|
|
2552
|
+
spaceBefore = "";
|
|
2553
|
+
}
|
|
2554
|
+
if (commentBefore) {
|
|
2555
|
+
(0, util_1.ensureObject)(node, "raws", "spaces", "attribute");
|
|
2556
|
+
node.raws.spaces.attribute.before = commentBefore;
|
|
2557
|
+
commentBefore = "";
|
|
2558
|
+
}
|
|
2559
|
+
node.namespace = (node.namespace || "") + content;
|
|
2560
|
+
var rawValue = (0, util_1.getProp)(node, "raws", "namespace") || null;
|
|
2561
|
+
if (rawValue) node.raws.namespace += content;
|
|
2562
|
+
lastAdded = "namespace";
|
|
2563
|
+
}
|
|
2564
|
+
spaceAfterMeaningfulToken = false;
|
|
2565
|
+
break;
|
|
2566
|
+
case tokens.dollar: if (lastAdded === "value") {
|
|
2567
|
+
var oldRawValue = (0, util_1.getProp)(node, "raws", "value");
|
|
2568
|
+
node.value += "$";
|
|
2569
|
+
if (oldRawValue) node.raws.value = oldRawValue + "$";
|
|
2570
|
+
break;
|
|
2571
|
+
}
|
|
2572
|
+
case tokens.caret:
|
|
2573
|
+
if (next[tokenize_1.FIELDS.TYPE] === tokens.equals) {
|
|
2574
|
+
node.operator = content;
|
|
2575
|
+
lastAdded = "operator";
|
|
2576
|
+
}
|
|
2577
|
+
spaceAfterMeaningfulToken = false;
|
|
2578
|
+
break;
|
|
2579
|
+
case tokens.combinator:
|
|
2580
|
+
if (content === "~" && next[tokenize_1.FIELDS.TYPE] === tokens.equals) {
|
|
2581
|
+
node.operator = content;
|
|
2582
|
+
lastAdded = "operator";
|
|
2583
|
+
}
|
|
2584
|
+
if (content !== "|") {
|
|
2585
|
+
spaceAfterMeaningfulToken = false;
|
|
2586
|
+
break;
|
|
2587
|
+
}
|
|
2588
|
+
if (next[tokenize_1.FIELDS.TYPE] === tokens.equals) {
|
|
2589
|
+
node.operator = content;
|
|
2590
|
+
lastAdded = "operator";
|
|
2591
|
+
} else if (!node.namespace && !node.attribute) node.namespace = true;
|
|
2592
|
+
spaceAfterMeaningfulToken = false;
|
|
2593
|
+
break;
|
|
2594
|
+
case tokens.word:
|
|
2595
|
+
if (next && this.content(next) === "|" && attr[pos + 2] && attr[pos + 2][tokenize_1.FIELDS.TYPE] !== tokens.equals && !node.operator && !node.namespace) {
|
|
2596
|
+
node.namespace = content;
|
|
2597
|
+
lastAdded = "namespace";
|
|
2598
|
+
} else if (!node.attribute || lastAdded === "attribute" && !spaceAfterMeaningfulToken) {
|
|
2599
|
+
if (spaceBefore) {
|
|
2600
|
+
(0, util_1.ensureObject)(node, "spaces", "attribute");
|
|
2601
|
+
node.spaces.attribute.before = spaceBefore;
|
|
2602
|
+
spaceBefore = "";
|
|
2603
|
+
}
|
|
2604
|
+
if (commentBefore) {
|
|
2605
|
+
(0, util_1.ensureObject)(node, "raws", "spaces", "attribute");
|
|
2606
|
+
node.raws.spaces.attribute.before = commentBefore;
|
|
2607
|
+
commentBefore = "";
|
|
2608
|
+
}
|
|
2609
|
+
node.attribute = (node.attribute || "") + content;
|
|
2610
|
+
var rawValue = (0, util_1.getProp)(node, "raws", "attribute") || null;
|
|
2611
|
+
if (rawValue) node.raws.attribute += content;
|
|
2612
|
+
lastAdded = "attribute";
|
|
2613
|
+
} else if (!node.value && node.value !== "" || lastAdded === "value" && !(spaceAfterMeaningfulToken || node.quoteMark)) {
|
|
2614
|
+
var unescaped_1 = (0, util_1.unesc)(content);
|
|
2615
|
+
var oldRawValue = (0, util_1.getProp)(node, "raws", "value") || "";
|
|
2616
|
+
var oldValue = node.value || "";
|
|
2617
|
+
node.value = oldValue + unescaped_1;
|
|
2618
|
+
node.quoteMark = null;
|
|
2619
|
+
if (unescaped_1 !== content || oldRawValue) {
|
|
2620
|
+
(0, util_1.ensureObject)(node, "raws");
|
|
2621
|
+
node.raws.value = (oldRawValue || oldValue) + content;
|
|
2622
|
+
}
|
|
2623
|
+
lastAdded = "value";
|
|
2624
|
+
} else {
|
|
2625
|
+
var insensitive = content === "i" || content === "I";
|
|
2626
|
+
if ((node.value || node.value === "") && (node.quoteMark || spaceAfterMeaningfulToken)) {
|
|
2627
|
+
node.insensitive = insensitive;
|
|
2628
|
+
if (!insensitive || content === "I") {
|
|
2629
|
+
(0, util_1.ensureObject)(node, "raws");
|
|
2630
|
+
node.raws.insensitiveFlag = content;
|
|
2631
|
+
}
|
|
2632
|
+
lastAdded = "insensitive";
|
|
2633
|
+
if (spaceBefore) {
|
|
2634
|
+
(0, util_1.ensureObject)(node, "spaces", "insensitive");
|
|
2635
|
+
node.spaces.insensitive.before = spaceBefore;
|
|
2636
|
+
spaceBefore = "";
|
|
2637
|
+
}
|
|
2638
|
+
if (commentBefore) {
|
|
2639
|
+
(0, util_1.ensureObject)(node, "raws", "spaces", "insensitive");
|
|
2640
|
+
node.raws.spaces.insensitive.before = commentBefore;
|
|
2641
|
+
commentBefore = "";
|
|
2642
|
+
}
|
|
2643
|
+
} else if (node.value || node.value === "") {
|
|
2644
|
+
lastAdded = "value";
|
|
2645
|
+
node.value += content;
|
|
2646
|
+
if (node.raws.value) node.raws.value += content;
|
|
2647
|
+
}
|
|
2648
|
+
}
|
|
2649
|
+
spaceAfterMeaningfulToken = false;
|
|
2650
|
+
break;
|
|
2651
|
+
case tokens.str:
|
|
2652
|
+
if (!node.attribute || !node.operator) return this.error("Expected an attribute followed by an operator preceding the string.", { index: token[tokenize_1.FIELDS.START_POS] });
|
|
2653
|
+
var _a = (0, attribute_1.unescapeValue)(content), unescaped = _a.unescaped, quoteMark = _a.quoteMark;
|
|
2654
|
+
node.value = unescaped;
|
|
2655
|
+
node.quoteMark = quoteMark;
|
|
2656
|
+
lastAdded = "value";
|
|
2657
|
+
(0, util_1.ensureObject)(node, "raws");
|
|
2658
|
+
node.raws.value = content;
|
|
2659
|
+
spaceAfterMeaningfulToken = false;
|
|
2660
|
+
break;
|
|
2661
|
+
case tokens.equals:
|
|
2662
|
+
if (!node.attribute) return this.expected("attribute", token[tokenize_1.FIELDS.START_POS], content);
|
|
2663
|
+
if (node.value) return this.error("Unexpected \"=\" found; an operator was already defined.", { index: token[tokenize_1.FIELDS.START_POS] });
|
|
2664
|
+
node.operator = node.operator ? node.operator + content : content;
|
|
2665
|
+
lastAdded = "operator";
|
|
2666
|
+
spaceAfterMeaningfulToken = false;
|
|
2667
|
+
break;
|
|
2668
|
+
case tokens.comment:
|
|
2669
|
+
if (lastAdded) {
|
|
2670
|
+
if (spaceAfterMeaningfulToken || next && next[tokenize_1.FIELDS.TYPE] === tokens.space || lastAdded === "insensitive") {
|
|
2671
|
+
var lastComment = (0, util_1.getProp)(node, "spaces", lastAdded, "after") || "";
|
|
2672
|
+
var rawLastComment = (0, util_1.getProp)(node, "raws", "spaces", lastAdded, "after") || lastComment;
|
|
2673
|
+
(0, util_1.ensureObject)(node, "raws", "spaces", lastAdded);
|
|
2674
|
+
node.raws.spaces[lastAdded].after = rawLastComment + content;
|
|
2675
|
+
} else {
|
|
2676
|
+
var lastValue = node[lastAdded] || "";
|
|
2677
|
+
var rawLastValue = (0, util_1.getProp)(node, "raws", lastAdded) || lastValue;
|
|
2678
|
+
(0, util_1.ensureObject)(node, "raws");
|
|
2679
|
+
node.raws[lastAdded] = rawLastValue + content;
|
|
2680
|
+
}
|
|
2681
|
+
} else commentBefore = commentBefore + content;
|
|
2682
|
+
break;
|
|
2683
|
+
default: return this.error("Unexpected \"".concat(content, "\" found."), { index: token[tokenize_1.FIELDS.START_POS] });
|
|
2684
|
+
}
|
|
2685
|
+
pos++;
|
|
2686
|
+
}
|
|
2687
|
+
unescapeProp(node, "attribute");
|
|
2688
|
+
unescapeProp(node, "namespace");
|
|
2689
|
+
this.newNode(new attribute_1.default(node));
|
|
2690
|
+
this.position++;
|
|
2691
|
+
};
|
|
2692
|
+
Parser.prototype.parseWhitespaceEquivalentTokens = function(stopPosition) {
|
|
2693
|
+
if (stopPosition < 0) stopPosition = this.tokens.length;
|
|
2694
|
+
var startPosition = this.position;
|
|
2695
|
+
var nodes = [];
|
|
2696
|
+
var space = "";
|
|
2697
|
+
var lastComment = void 0;
|
|
2698
|
+
do
|
|
2699
|
+
if (WHITESPACE_TOKENS[this.currToken[tokenize_1.FIELDS.TYPE]]) {
|
|
2700
|
+
if (!this.options.lossy) space += this.content();
|
|
2701
|
+
} else if (this.currToken[tokenize_1.FIELDS.TYPE] === tokens.comment) {
|
|
2702
|
+
var spaces = {};
|
|
2703
|
+
if (space) {
|
|
2704
|
+
spaces.before = space;
|
|
2705
|
+
space = "";
|
|
2706
|
+
}
|
|
2707
|
+
lastComment = new comment_1.default({
|
|
2708
|
+
value: this.content(),
|
|
2709
|
+
source: getTokenSource(this.currToken),
|
|
2710
|
+
sourceIndex: this.currToken[tokenize_1.FIELDS.START_POS],
|
|
2711
|
+
spaces
|
|
2712
|
+
});
|
|
2713
|
+
nodes.push(lastComment);
|
|
2714
|
+
}
|
|
2715
|
+
while (++this.position < stopPosition);
|
|
2716
|
+
if (space) {
|
|
2717
|
+
if (lastComment) lastComment.spaces.after = space;
|
|
2718
|
+
else if (!this.options.lossy) {
|
|
2719
|
+
var firstToken = this.tokens[startPosition];
|
|
2720
|
+
var lastToken = this.tokens[this.position - 1];
|
|
2721
|
+
nodes.push(new string_1.default({
|
|
2722
|
+
value: "",
|
|
2723
|
+
source: getSource(firstToken[tokenize_1.FIELDS.START_LINE], firstToken[tokenize_1.FIELDS.START_COL], lastToken[tokenize_1.FIELDS.END_LINE], lastToken[tokenize_1.FIELDS.END_COL]),
|
|
2724
|
+
sourceIndex: firstToken[tokenize_1.FIELDS.START_POS],
|
|
2725
|
+
spaces: {
|
|
2726
|
+
before: space,
|
|
2727
|
+
after: ""
|
|
2728
|
+
}
|
|
2729
|
+
}));
|
|
2730
|
+
}
|
|
2731
|
+
}
|
|
2732
|
+
return nodes;
|
|
2733
|
+
};
|
|
2734
|
+
Parser.prototype.convertWhitespaceNodesToSpace = function(nodes, requiredSpace) {
|
|
2735
|
+
var _this = this;
|
|
2736
|
+
if (requiredSpace === void 0) requiredSpace = false;
|
|
2737
|
+
var space = "";
|
|
2738
|
+
var rawSpace = "";
|
|
2739
|
+
nodes.forEach(function(n) {
|
|
2740
|
+
var spaceBefore = _this.lossySpace(n.spaces.before, requiredSpace);
|
|
2741
|
+
var rawSpaceBefore = _this.lossySpace(n.rawSpaceBefore, requiredSpace);
|
|
2742
|
+
space += spaceBefore + _this.lossySpace(n.spaces.after, requiredSpace && spaceBefore.length === 0);
|
|
2743
|
+
rawSpace += spaceBefore + n.value + _this.lossySpace(n.rawSpaceAfter, requiredSpace && rawSpaceBefore.length === 0);
|
|
2744
|
+
});
|
|
2745
|
+
if (rawSpace === space) rawSpace = void 0;
|
|
2746
|
+
return {
|
|
2747
|
+
space,
|
|
2748
|
+
rawSpace
|
|
2749
|
+
};
|
|
2750
|
+
};
|
|
2751
|
+
Parser.prototype.isNamedCombinator = function(position) {
|
|
2752
|
+
if (position === void 0) position = this.position;
|
|
2753
|
+
return this.tokens[position + 0] && this.tokens[position + 0][tokenize_1.FIELDS.TYPE] === tokens.slash && this.tokens[position + 1] && this.tokens[position + 1][tokenize_1.FIELDS.TYPE] === tokens.word && this.tokens[position + 2] && this.tokens[position + 2][tokenize_1.FIELDS.TYPE] === tokens.slash;
|
|
2754
|
+
};
|
|
2755
|
+
Parser.prototype.namedCombinator = function() {
|
|
2756
|
+
if (this.isNamedCombinator()) {
|
|
2757
|
+
var nameRaw = this.content(this.tokens[this.position + 1]);
|
|
2758
|
+
var name = (0, util_1.unesc)(nameRaw).toLowerCase();
|
|
2759
|
+
var raws = {};
|
|
2760
|
+
if (name !== nameRaw) raws.value = "/".concat(nameRaw, "/");
|
|
2761
|
+
var node = new combinator_1.default({
|
|
2762
|
+
value: "/".concat(name, "/"),
|
|
2763
|
+
source: getSource(this.currToken[tokenize_1.FIELDS.START_LINE], this.currToken[tokenize_1.FIELDS.START_COL], this.tokens[this.position + 2][tokenize_1.FIELDS.END_LINE], this.tokens[this.position + 2][tokenize_1.FIELDS.END_COL]),
|
|
2764
|
+
sourceIndex: this.currToken[tokenize_1.FIELDS.START_POS],
|
|
2765
|
+
raws
|
|
2766
|
+
});
|
|
2767
|
+
this.position = this.position + 3;
|
|
2768
|
+
return node;
|
|
2769
|
+
} else this.unexpected();
|
|
2770
|
+
};
|
|
2771
|
+
Parser.prototype.combinator = function() {
|
|
2772
|
+
var _this = this;
|
|
2773
|
+
if (this.content() === "|") return this.namespace();
|
|
2774
|
+
var nextSigTokenPos = this.locateNextMeaningfulToken(this.position);
|
|
2775
|
+
if (nextSigTokenPos < 0 || this.tokens[nextSigTokenPos][tokenize_1.FIELDS.TYPE] === tokens.comma || this.tokens[nextSigTokenPos][tokenize_1.FIELDS.TYPE] === tokens.closeParenthesis) {
|
|
2776
|
+
var nodes = this.parseWhitespaceEquivalentTokens(nextSigTokenPos);
|
|
2777
|
+
if (nodes.length > 0) {
|
|
2778
|
+
var last = this.current.last;
|
|
2779
|
+
if (last) {
|
|
2780
|
+
var _a = this.convertWhitespaceNodesToSpace(nodes), space = _a.space, rawSpace = _a.rawSpace;
|
|
2781
|
+
if (rawSpace !== void 0) last.rawSpaceAfter += rawSpace;
|
|
2782
|
+
last.spaces.after += space;
|
|
2783
|
+
} else nodes.forEach(function(n) {
|
|
2784
|
+
return _this.newNode(n);
|
|
2785
|
+
});
|
|
2786
|
+
}
|
|
2787
|
+
return;
|
|
2788
|
+
}
|
|
2789
|
+
var firstToken = this.currToken;
|
|
2790
|
+
var spaceOrDescendantSelectorNodes = void 0;
|
|
2791
|
+
if (nextSigTokenPos > this.position) spaceOrDescendantSelectorNodes = this.parseWhitespaceEquivalentTokens(nextSigTokenPos);
|
|
2792
|
+
var node;
|
|
2793
|
+
if (this.isNamedCombinator()) node = this.namedCombinator();
|
|
2794
|
+
else if (this.currToken[tokenize_1.FIELDS.TYPE] === tokens.combinator) {
|
|
2795
|
+
node = new combinator_1.default({
|
|
2796
|
+
value: this.content(),
|
|
2797
|
+
source: getTokenSource(this.currToken),
|
|
2798
|
+
sourceIndex: this.currToken[tokenize_1.FIELDS.START_POS]
|
|
2799
|
+
});
|
|
2800
|
+
this.position++;
|
|
2801
|
+
} else if (WHITESPACE_TOKENS[this.currToken[tokenize_1.FIELDS.TYPE]]) {} else if (!spaceOrDescendantSelectorNodes) this.unexpected();
|
|
2802
|
+
if (node) {
|
|
2803
|
+
if (spaceOrDescendantSelectorNodes) {
|
|
2804
|
+
var _b = this.convertWhitespaceNodesToSpace(spaceOrDescendantSelectorNodes), space = _b.space, rawSpace = _b.rawSpace;
|
|
2805
|
+
node.spaces.before = space;
|
|
2806
|
+
node.rawSpaceBefore = rawSpace;
|
|
2807
|
+
}
|
|
2808
|
+
} else {
|
|
2809
|
+
var _c = this.convertWhitespaceNodesToSpace(spaceOrDescendantSelectorNodes, true), space = _c.space, rawSpace = _c.rawSpace;
|
|
2810
|
+
if (!rawSpace) rawSpace = space;
|
|
2811
|
+
var spaces = {};
|
|
2812
|
+
var raws = { spaces: {} };
|
|
2813
|
+
if (space.endsWith(" ") && rawSpace.endsWith(" ")) {
|
|
2814
|
+
spaces.before = space.slice(0, space.length - 1);
|
|
2815
|
+
raws.spaces.before = rawSpace.slice(0, rawSpace.length - 1);
|
|
2816
|
+
} else if (space[0] === " " && rawSpace[0] === " ") {
|
|
2817
|
+
spaces.after = space.slice(1);
|
|
2818
|
+
raws.spaces.after = rawSpace.slice(1);
|
|
2819
|
+
} else raws.value = rawSpace;
|
|
2820
|
+
node = new combinator_1.default({
|
|
2821
|
+
value: " ",
|
|
2822
|
+
source: getTokenSourceSpan(firstToken, this.tokens[this.position - 1]),
|
|
2823
|
+
sourceIndex: firstToken[tokenize_1.FIELDS.START_POS],
|
|
2824
|
+
spaces,
|
|
2825
|
+
raws
|
|
2826
|
+
});
|
|
2827
|
+
}
|
|
2828
|
+
if (this.currToken && this.currToken[tokenize_1.FIELDS.TYPE] === tokens.space) {
|
|
2829
|
+
node.spaces.after = this.optionalSpace(this.content());
|
|
2830
|
+
this.position++;
|
|
2831
|
+
}
|
|
2832
|
+
return this.newNode(node);
|
|
2833
|
+
};
|
|
2834
|
+
Parser.prototype.comma = function() {
|
|
2835
|
+
if (this.position === this.tokens.length - 1) {
|
|
2836
|
+
this.root.trailingComma = true;
|
|
2837
|
+
this.position++;
|
|
2838
|
+
return;
|
|
2839
|
+
}
|
|
2840
|
+
this.current._inferEndPosition();
|
|
2841
|
+
var selector = new selector_1.default({
|
|
2842
|
+
source: { start: tokenStart(this.tokens[this.position + 1]) },
|
|
2843
|
+
sourceIndex: this.tokens[this.position + 1][tokenize_1.FIELDS.START_POS]
|
|
2844
|
+
});
|
|
2845
|
+
this.current.parent.append(selector);
|
|
2846
|
+
this.current = selector;
|
|
2847
|
+
this.position++;
|
|
2848
|
+
};
|
|
2849
|
+
Parser.prototype.comment = function() {
|
|
2850
|
+
var current = this.currToken;
|
|
2851
|
+
this.newNode(new comment_1.default({
|
|
2852
|
+
value: this.content(),
|
|
2853
|
+
source: getTokenSource(current),
|
|
2854
|
+
sourceIndex: current[tokenize_1.FIELDS.START_POS]
|
|
2855
|
+
}));
|
|
2856
|
+
this.position++;
|
|
2857
|
+
};
|
|
2858
|
+
Parser.prototype.error = function(message, opts) {
|
|
2859
|
+
throw this.root.error(message, opts);
|
|
2860
|
+
};
|
|
2861
|
+
Parser.prototype.missingBackslash = function() {
|
|
2862
|
+
return this.error("Expected a backslash preceding the semicolon.", { index: this.currToken[tokenize_1.FIELDS.START_POS] });
|
|
2863
|
+
};
|
|
2864
|
+
Parser.prototype.missingParenthesis = function() {
|
|
2865
|
+
return this.expected("opening parenthesis", this.currToken[tokenize_1.FIELDS.START_POS]);
|
|
2866
|
+
};
|
|
2867
|
+
Parser.prototype.missingSquareBracket = function() {
|
|
2868
|
+
return this.expected("opening square bracket", this.currToken[tokenize_1.FIELDS.START_POS]);
|
|
2869
|
+
};
|
|
2870
|
+
Parser.prototype.unexpected = function() {
|
|
2871
|
+
return this.error("Unexpected '".concat(this.content(), "'. Escaping special characters with \\ may help."), this.currToken[tokenize_1.FIELDS.START_POS]);
|
|
2872
|
+
};
|
|
2873
|
+
Parser.prototype.unexpectedPipe = function() {
|
|
2874
|
+
return this.error("Unexpected '|'.", this.currToken[tokenize_1.FIELDS.START_POS]);
|
|
2875
|
+
};
|
|
2876
|
+
Parser.prototype.namespace = function() {
|
|
2877
|
+
var prev = this.prevToken;
|
|
2878
|
+
var before = prev && (prev[tokenize_1.FIELDS.TYPE] === tokens.word || prev[tokenize_1.FIELDS.TYPE] === tokens.asterisk || prev[tokenize_1.FIELDS.TYPE] === tokens.ampersand) ? this.content(prev) : true;
|
|
2879
|
+
if (!this.nextToken) return this.unexpectedPipe();
|
|
2880
|
+
if (this.nextToken[tokenize_1.FIELDS.TYPE] === tokens.word) {
|
|
2881
|
+
this.position++;
|
|
2882
|
+
return this.word(before);
|
|
2883
|
+
} else if (this.nextToken[tokenize_1.FIELDS.TYPE] === tokens.asterisk) {
|
|
2884
|
+
this.position++;
|
|
2885
|
+
return this.universal(before);
|
|
2886
|
+
}
|
|
2887
|
+
this.unexpectedPipe();
|
|
2888
|
+
};
|
|
2889
|
+
Parser.prototype.nesting = function() {
|
|
2890
|
+
if (this.nextToken) {
|
|
2891
|
+
if (this.content(this.nextToken) === "|") {
|
|
2892
|
+
this.position++;
|
|
2893
|
+
return;
|
|
2894
|
+
}
|
|
2895
|
+
}
|
|
2896
|
+
var current = this.currToken;
|
|
2897
|
+
this.newNode(new nesting_1.default({
|
|
2898
|
+
value: this.content(),
|
|
2899
|
+
source: getTokenSource(current),
|
|
2900
|
+
sourceIndex: current[tokenize_1.FIELDS.START_POS]
|
|
2901
|
+
}));
|
|
2902
|
+
this.position++;
|
|
2903
|
+
};
|
|
2904
|
+
Parser.prototype.parentheses = function() {
|
|
2905
|
+
var last = this.current.last;
|
|
2906
|
+
var unbalanced = 1;
|
|
2907
|
+
var openingToken = this.currToken;
|
|
2908
|
+
this.position++;
|
|
2909
|
+
if (last && last.type === types.PSEUDO) {
|
|
2910
|
+
var selector = new selector_1.default({
|
|
2911
|
+
source: { start: tokenStart(this.tokens[this.position]) },
|
|
2912
|
+
sourceIndex: this.tokens[this.position][tokenize_1.FIELDS.START_POS]
|
|
2913
|
+
});
|
|
2914
|
+
var cache = this.current;
|
|
2915
|
+
last.append(selector);
|
|
2916
|
+
this.current = selector;
|
|
2917
|
+
this.nestingDepth++;
|
|
2918
|
+
try {
|
|
2919
|
+
if (this.nestingDepth > this.maxNestingDepth) this.error("Cannot parse selector: nesting depth exceeds the maximum of ".concat(this.maxNestingDepth, "."), { index: this.currToken[tokenize_1.FIELDS.START_POS] });
|
|
2920
|
+
while (this.position < this.tokens.length && unbalanced) {
|
|
2921
|
+
if (this.currToken[tokenize_1.FIELDS.TYPE] === tokens.openParenthesis) unbalanced++;
|
|
2922
|
+
if (this.currToken[tokenize_1.FIELDS.TYPE] === tokens.closeParenthesis) unbalanced--;
|
|
2923
|
+
if (unbalanced) this.parse();
|
|
2924
|
+
else {
|
|
2925
|
+
this.current.source.end = tokenEnd(this.currToken);
|
|
2926
|
+
this.current.parent.source.end = tokenEnd(this.currToken);
|
|
2927
|
+
this.position++;
|
|
2928
|
+
}
|
|
2929
|
+
}
|
|
2930
|
+
} finally {
|
|
2931
|
+
this.nestingDepth--;
|
|
2932
|
+
}
|
|
2933
|
+
this.current = cache;
|
|
2934
|
+
} else {
|
|
2935
|
+
var parenStart = this.currToken;
|
|
2936
|
+
var parenValue = "(";
|
|
2937
|
+
var parenEnd = void 0;
|
|
2938
|
+
while (this.position < this.tokens.length && unbalanced) {
|
|
2939
|
+
if (this.currToken[tokenize_1.FIELDS.TYPE] === tokens.openParenthesis) unbalanced++;
|
|
2940
|
+
if (this.currToken[tokenize_1.FIELDS.TYPE] === tokens.closeParenthesis) unbalanced--;
|
|
2941
|
+
parenEnd = this.currToken;
|
|
2942
|
+
parenValue += this.parseParenthesisToken(this.currToken);
|
|
2943
|
+
this.position++;
|
|
2944
|
+
}
|
|
2945
|
+
if (last) last.appendToPropertyAndEscape("value", parenValue, parenValue);
|
|
2946
|
+
else this.newNode(new string_1.default({
|
|
2947
|
+
value: parenValue,
|
|
2948
|
+
source: getSource(parenStart[tokenize_1.FIELDS.START_LINE], parenStart[tokenize_1.FIELDS.START_COL], parenEnd[tokenize_1.FIELDS.END_LINE], parenEnd[tokenize_1.FIELDS.END_COL]),
|
|
2949
|
+
sourceIndex: parenStart[tokenize_1.FIELDS.START_POS]
|
|
2950
|
+
}));
|
|
2951
|
+
}
|
|
2952
|
+
if (unbalanced) return this.expected("closing parenthesis", (this.currToken || openingToken)[tokenize_1.FIELDS.START_POS]);
|
|
2953
|
+
};
|
|
2954
|
+
Parser.prototype.pseudo = function() {
|
|
2955
|
+
var _this = this;
|
|
2956
|
+
var pseudoStr = "";
|
|
2957
|
+
var startingToken = this.currToken;
|
|
2958
|
+
while (this.currToken && this.currToken[tokenize_1.FIELDS.TYPE] === tokens.colon) {
|
|
2959
|
+
pseudoStr += this.content();
|
|
2960
|
+
this.position++;
|
|
2961
|
+
}
|
|
2962
|
+
if (!this.currToken) return this.expected(["pseudo-class", "pseudo-element"], this.position - 1);
|
|
2963
|
+
if (this.currToken[tokenize_1.FIELDS.TYPE] === tokens.word) this.splitWord(false, function(first, length) {
|
|
2964
|
+
pseudoStr += first;
|
|
2965
|
+
_this.newNode(new pseudo_1.default({
|
|
2966
|
+
value: pseudoStr,
|
|
2967
|
+
source: getTokenSourceSpan(startingToken, _this.currToken),
|
|
2968
|
+
sourceIndex: startingToken[tokenize_1.FIELDS.START_POS]
|
|
2969
|
+
}));
|
|
2970
|
+
if (length > 1 && _this.nextToken && _this.nextToken[tokenize_1.FIELDS.TYPE] === tokens.openParenthesis) _this.error("Misplaced parenthesis.", { index: _this.nextToken[tokenize_1.FIELDS.START_POS] });
|
|
2971
|
+
});
|
|
2972
|
+
else return this.expected(["pseudo-class", "pseudo-element"], this.currToken[tokenize_1.FIELDS.START_POS]);
|
|
2973
|
+
};
|
|
2974
|
+
Parser.prototype.space = function() {
|
|
2975
|
+
var content = this.content();
|
|
2976
|
+
if (this.position === 0 || this.prevToken[tokenize_1.FIELDS.TYPE] === tokens.comma || this.prevToken[tokenize_1.FIELDS.TYPE] === tokens.openParenthesis || this.current.nodes.every(function(node) {
|
|
2977
|
+
return node.type === "comment";
|
|
2978
|
+
})) {
|
|
2979
|
+
this.spaces = this.optionalSpace(content);
|
|
2980
|
+
this.position++;
|
|
2981
|
+
} else if (this.position === this.tokens.length - 1 || this.nextToken[tokenize_1.FIELDS.TYPE] === tokens.comma || this.nextToken[tokenize_1.FIELDS.TYPE] === tokens.closeParenthesis) {
|
|
2982
|
+
this.current.last.spaces.after = this.optionalSpace(content);
|
|
2983
|
+
this.position++;
|
|
2984
|
+
} else this.combinator();
|
|
2985
|
+
};
|
|
2986
|
+
Parser.prototype.string = function() {
|
|
2987
|
+
var current = this.currToken;
|
|
2988
|
+
this.newNode(new string_1.default({
|
|
2989
|
+
value: this.content(),
|
|
2990
|
+
source: getTokenSource(current),
|
|
2991
|
+
sourceIndex: current[tokenize_1.FIELDS.START_POS]
|
|
2992
|
+
}));
|
|
2993
|
+
this.position++;
|
|
2994
|
+
};
|
|
2995
|
+
Parser.prototype.universal = function(namespace) {
|
|
2996
|
+
var nextToken = this.nextToken;
|
|
2997
|
+
if (nextToken && this.content(nextToken) === "|") {
|
|
2998
|
+
this.position++;
|
|
2999
|
+
return this.namespace();
|
|
3000
|
+
}
|
|
3001
|
+
var current = this.currToken;
|
|
3002
|
+
this.newNode(new universal_1.default({
|
|
3003
|
+
value: this.content(),
|
|
3004
|
+
source: getTokenSource(current),
|
|
3005
|
+
sourceIndex: current[tokenize_1.FIELDS.START_POS]
|
|
3006
|
+
}), namespace);
|
|
3007
|
+
this.position++;
|
|
3008
|
+
};
|
|
3009
|
+
Parser.prototype.splitWord = function(namespace, firstCallback) {
|
|
3010
|
+
var _this = this;
|
|
3011
|
+
var nextToken = this.nextToken;
|
|
3012
|
+
var word = this.content();
|
|
3013
|
+
while (nextToken && ~[
|
|
3014
|
+
tokens.dollar,
|
|
3015
|
+
tokens.caret,
|
|
3016
|
+
tokens.equals,
|
|
3017
|
+
tokens.word
|
|
3018
|
+
].indexOf(nextToken[tokenize_1.FIELDS.TYPE])) {
|
|
3019
|
+
this.position++;
|
|
3020
|
+
var current = this.content();
|
|
3021
|
+
word += current;
|
|
3022
|
+
if (current.lastIndexOf("\\") === current.length - 1) {
|
|
3023
|
+
var next = this.nextToken;
|
|
3024
|
+
if (next && next[tokenize_1.FIELDS.TYPE] === tokens.space) {
|
|
3025
|
+
word += this.requiredSpace(this.content(next));
|
|
3026
|
+
this.position++;
|
|
3027
|
+
}
|
|
3028
|
+
}
|
|
3029
|
+
nextToken = this.nextToken;
|
|
3030
|
+
}
|
|
3031
|
+
var hasClass = indexesOf(word, ".").filter(function(i) {
|
|
3032
|
+
var escapedDot = word[i - 1] === "\\";
|
|
3033
|
+
var isKeyframesPercent = /^\d+\.\d+%$/.test(word);
|
|
3034
|
+
return !escapedDot && !isKeyframesPercent;
|
|
3035
|
+
});
|
|
3036
|
+
var hasId = indexesOf(word, "#").filter(function(i) {
|
|
3037
|
+
return word[i - 1] !== "\\";
|
|
3038
|
+
});
|
|
3039
|
+
var interpolations = indexesOf(word, "#{");
|
|
3040
|
+
if (interpolations.length) {
|
|
3041
|
+
var interpolationIndexes_1 = new Set(interpolations);
|
|
3042
|
+
hasId = hasId.filter(function(hashIndex) {
|
|
3043
|
+
return !interpolationIndexes_1.has(hashIndex);
|
|
3044
|
+
});
|
|
3045
|
+
}
|
|
3046
|
+
var classIndexes = new Set(hasClass);
|
|
3047
|
+
var idIndexes = new Set(hasId);
|
|
3048
|
+
var indices = (0, sortAscending_1.default)(uniqs(__spreadArray(__spreadArray([0], __read(hasClass), false), __read(hasId), false)));
|
|
3049
|
+
indices.forEach(function(ind, i) {
|
|
3050
|
+
var index = indices[i + 1] || word.length;
|
|
3051
|
+
var value = word.slice(ind, index);
|
|
3052
|
+
if (i === 0 && firstCallback) return firstCallback.call(_this, value, indices.length);
|
|
3053
|
+
var node;
|
|
3054
|
+
var current = _this.currToken;
|
|
3055
|
+
var sourceIndex = current[tokenize_1.FIELDS.START_POS] + indices[i];
|
|
3056
|
+
var source = getSource(current[1], current[2] + ind, current[3], current[2] + (index - 1));
|
|
3057
|
+
if (classIndexes.has(ind)) {
|
|
3058
|
+
var classNameOpts = {
|
|
3059
|
+
value: value.slice(1),
|
|
3060
|
+
source,
|
|
3061
|
+
sourceIndex
|
|
3062
|
+
};
|
|
3063
|
+
node = new className_1.default(unescapeProp(classNameOpts, "value"));
|
|
3064
|
+
} else if (idIndexes.has(ind)) {
|
|
3065
|
+
var idOpts = {
|
|
3066
|
+
value: value.slice(1),
|
|
3067
|
+
source,
|
|
3068
|
+
sourceIndex
|
|
3069
|
+
};
|
|
3070
|
+
node = new id_1.default(unescapeProp(idOpts, "value"));
|
|
3071
|
+
} else {
|
|
3072
|
+
var tagOpts = {
|
|
3073
|
+
value,
|
|
3074
|
+
source,
|
|
3075
|
+
sourceIndex
|
|
3076
|
+
};
|
|
3077
|
+
unescapeProp(tagOpts, "value");
|
|
3078
|
+
node = new tag_1.default(tagOpts);
|
|
3079
|
+
}
|
|
3080
|
+
_this.newNode(node, namespace);
|
|
3081
|
+
namespace = null;
|
|
3082
|
+
});
|
|
3083
|
+
this.position++;
|
|
3084
|
+
};
|
|
3085
|
+
Parser.prototype.word = function(namespace) {
|
|
3086
|
+
var nextToken = this.nextToken;
|
|
3087
|
+
if (nextToken && this.content(nextToken) === "|") {
|
|
3088
|
+
this.position++;
|
|
3089
|
+
return this.namespace();
|
|
3090
|
+
}
|
|
3091
|
+
return this.splitWord(namespace);
|
|
3092
|
+
};
|
|
3093
|
+
Parser.prototype.loop = function() {
|
|
3094
|
+
while (this.position < this.tokens.length) this.parse(true);
|
|
3095
|
+
this.current._inferEndPosition();
|
|
3096
|
+
return this.root;
|
|
3097
|
+
};
|
|
3098
|
+
Parser.prototype.parse = function(throwOnParenthesis) {
|
|
3099
|
+
switch (this.currToken[tokenize_1.FIELDS.TYPE]) {
|
|
3100
|
+
case tokens.space:
|
|
3101
|
+
this.space();
|
|
3102
|
+
break;
|
|
3103
|
+
case tokens.comment:
|
|
3104
|
+
this.comment();
|
|
3105
|
+
break;
|
|
3106
|
+
case tokens.openParenthesis:
|
|
3107
|
+
this.parentheses();
|
|
3108
|
+
break;
|
|
3109
|
+
case tokens.closeParenthesis:
|
|
3110
|
+
if (throwOnParenthesis) this.missingParenthesis();
|
|
3111
|
+
break;
|
|
3112
|
+
case tokens.openSquare:
|
|
3113
|
+
this.attribute();
|
|
3114
|
+
break;
|
|
3115
|
+
case tokens.dollar:
|
|
3116
|
+
case tokens.caret:
|
|
3117
|
+
case tokens.equals:
|
|
3118
|
+
case tokens.word:
|
|
3119
|
+
this.word();
|
|
3120
|
+
break;
|
|
3121
|
+
case tokens.colon:
|
|
3122
|
+
this.pseudo();
|
|
3123
|
+
break;
|
|
3124
|
+
case tokens.comma:
|
|
3125
|
+
this.comma();
|
|
3126
|
+
break;
|
|
3127
|
+
case tokens.asterisk:
|
|
3128
|
+
this.universal();
|
|
3129
|
+
break;
|
|
3130
|
+
case tokens.ampersand:
|
|
3131
|
+
this.nesting();
|
|
3132
|
+
break;
|
|
3133
|
+
case tokens.slash:
|
|
3134
|
+
case tokens.combinator:
|
|
3135
|
+
this.combinator();
|
|
3136
|
+
break;
|
|
3137
|
+
case tokens.str:
|
|
3138
|
+
this.string();
|
|
3139
|
+
break;
|
|
3140
|
+
case tokens.closeSquare: this.missingSquareBracket();
|
|
3141
|
+
case tokens.semicolon: this.missingBackslash();
|
|
3142
|
+
default: this.unexpected();
|
|
3143
|
+
}
|
|
3144
|
+
};
|
|
3145
|
+
Parser.prototype.expected = function(description, index, found) {
|
|
3146
|
+
if (Array.isArray(description)) {
|
|
3147
|
+
var last = description.pop();
|
|
3148
|
+
description = "".concat(description.join(", "), " or ").concat(last);
|
|
3149
|
+
}
|
|
3150
|
+
var an = /^[aeiou]/.test(description[0]) ? "an" : "a";
|
|
3151
|
+
if (!found) return this.error("Expected ".concat(an, " ").concat(description, "."), { index });
|
|
3152
|
+
return this.error("Expected ".concat(an, " ").concat(description, ", found \"").concat(found, "\" instead."), { index });
|
|
3153
|
+
};
|
|
3154
|
+
Parser.prototype.requiredSpace = function(space) {
|
|
3155
|
+
return this.options.lossy ? " " : space;
|
|
3156
|
+
};
|
|
3157
|
+
Parser.prototype.optionalSpace = function(space) {
|
|
3158
|
+
return this.options.lossy ? "" : space;
|
|
3159
|
+
};
|
|
3160
|
+
Parser.prototype.lossySpace = function(space, required) {
|
|
3161
|
+
if (this.options.lossy) return required ? " " : "";
|
|
3162
|
+
else return space;
|
|
3163
|
+
};
|
|
3164
|
+
Parser.prototype.parseParenthesisToken = function(token) {
|
|
3165
|
+
var content = this.content(token);
|
|
3166
|
+
if (token[tokenize_1.FIELDS.TYPE] === tokens.space) return this.requiredSpace(content);
|
|
3167
|
+
else return content;
|
|
3168
|
+
};
|
|
3169
|
+
Parser.prototype.newNode = function(node, namespace) {
|
|
3170
|
+
if (namespace) {
|
|
3171
|
+
if (/^ +$/.test(namespace)) {
|
|
3172
|
+
if (!this.options.lossy) this.spaces = (this.spaces || "") + namespace;
|
|
3173
|
+
namespace = true;
|
|
3174
|
+
}
|
|
3175
|
+
node.namespace = namespace;
|
|
3176
|
+
unescapeProp(node, "namespace");
|
|
3177
|
+
}
|
|
3178
|
+
if (this.spaces) {
|
|
3179
|
+
node.spaces.before = this.spaces;
|
|
3180
|
+
this.spaces = "";
|
|
3181
|
+
}
|
|
3182
|
+
return this.current.append(node);
|
|
3183
|
+
};
|
|
3184
|
+
Parser.prototype.content = function(token) {
|
|
3185
|
+
if (token === void 0) token = this.currToken;
|
|
3186
|
+
return this.css.slice(token[tokenize_1.FIELDS.START_POS], token[tokenize_1.FIELDS.END_POS]);
|
|
3187
|
+
};
|
|
3188
|
+
Object.defineProperty(Parser.prototype, "currToken", {
|
|
3189
|
+
get: function() {
|
|
3190
|
+
return this.tokens[this.position];
|
|
3191
|
+
},
|
|
3192
|
+
enumerable: false,
|
|
3193
|
+
configurable: true
|
|
3194
|
+
});
|
|
3195
|
+
Object.defineProperty(Parser.prototype, "nextToken", {
|
|
3196
|
+
get: function() {
|
|
3197
|
+
return this.tokens[this.position + 1];
|
|
3198
|
+
},
|
|
3199
|
+
enumerable: false,
|
|
3200
|
+
configurable: true
|
|
3201
|
+
});
|
|
3202
|
+
Object.defineProperty(Parser.prototype, "prevToken", {
|
|
3203
|
+
get: function() {
|
|
3204
|
+
return this.tokens[this.position - 1];
|
|
3205
|
+
},
|
|
3206
|
+
enumerable: false,
|
|
3207
|
+
configurable: true
|
|
3208
|
+
});
|
|
3209
|
+
Parser.prototype.locateNextMeaningfulToken = function(startPosition) {
|
|
3210
|
+
if (startPosition === void 0) startPosition = this.position + 1;
|
|
3211
|
+
var searchPosition = startPosition;
|
|
3212
|
+
while (searchPosition < this.tokens.length) if (WHITESPACE_EQUIV_TOKENS[this.tokens[searchPosition][tokenize_1.FIELDS.TYPE]]) {
|
|
3213
|
+
searchPosition++;
|
|
3214
|
+
continue;
|
|
3215
|
+
} else return searchPosition;
|
|
3216
|
+
return -1;
|
|
3217
|
+
};
|
|
3218
|
+
return Parser;
|
|
3219
|
+
}();
|
|
3220
|
+
}));
|
|
3221
|
+
var require_processor = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
3222
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
3223
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
3224
|
+
};
|
|
3225
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3226
|
+
var parser_1 = __importDefault(require_parser());
|
|
3227
|
+
exports.default = function() {
|
|
3228
|
+
function Processor(func, options) {
|
|
3229
|
+
this.func = func || function noop() {};
|
|
3230
|
+
this.funcRes = null;
|
|
3231
|
+
this.options = options;
|
|
3232
|
+
}
|
|
3233
|
+
Processor.prototype._shouldUpdateSelector = function(rule, options) {
|
|
3234
|
+
if (options === void 0) options = {};
|
|
3235
|
+
if (Object.assign({}, this.options, options).updateSelector === false) return false;
|
|
3236
|
+
else return typeof rule !== "string";
|
|
3237
|
+
};
|
|
3238
|
+
Processor.prototype._isLossy = function(options) {
|
|
3239
|
+
if (options === void 0) options = {};
|
|
3240
|
+
if (Object.assign({}, this.options, options).lossless === false) return true;
|
|
3241
|
+
else return false;
|
|
3242
|
+
};
|
|
3243
|
+
Processor.prototype._root = function(rule, options) {
|
|
3244
|
+
if (options === void 0) options = {};
|
|
3245
|
+
return new parser_1.default(rule, this._parseOptions(options)).root;
|
|
3246
|
+
};
|
|
3247
|
+
Processor.prototype._parseOptions = function(options) {
|
|
3248
|
+
var merged = Object.assign({}, this.options, options);
|
|
3249
|
+
return {
|
|
3250
|
+
lossy: this._isLossy(merged),
|
|
3251
|
+
maxNestingDepth: merged.maxNestingDepth
|
|
3252
|
+
};
|
|
3253
|
+
};
|
|
3254
|
+
Processor.prototype._stringifyOptions = function(options) {
|
|
3255
|
+
return { maxNestingDepth: Object.assign({}, this.options, options).maxNestingDepth };
|
|
3256
|
+
};
|
|
3257
|
+
Processor.prototype._run = function(rule, options) {
|
|
3258
|
+
var _this = this;
|
|
3259
|
+
if (options === void 0) options = {};
|
|
3260
|
+
return new Promise(function(resolve, reject) {
|
|
3261
|
+
try {
|
|
3262
|
+
var root_1 = _this._root(rule, options);
|
|
3263
|
+
Promise.resolve(_this.func(root_1)).then(function(transform) {
|
|
3264
|
+
var string = void 0;
|
|
3265
|
+
if (_this._shouldUpdateSelector(rule, options)) {
|
|
3266
|
+
string = root_1.toString(_this._stringifyOptions(options));
|
|
3267
|
+
rule.selector = string;
|
|
3268
|
+
}
|
|
3269
|
+
return {
|
|
3270
|
+
transform,
|
|
3271
|
+
root: root_1,
|
|
3272
|
+
string
|
|
3273
|
+
};
|
|
3274
|
+
}).then(resolve, reject);
|
|
3275
|
+
} catch (e) {
|
|
3276
|
+
reject(e);
|
|
3277
|
+
return;
|
|
3278
|
+
}
|
|
3279
|
+
});
|
|
3280
|
+
};
|
|
3281
|
+
Processor.prototype._runSync = function(rule, options) {
|
|
3282
|
+
if (options === void 0) options = {};
|
|
3283
|
+
var root = this._root(rule, options);
|
|
3284
|
+
var transform = this.func(root);
|
|
3285
|
+
if (transform && typeof transform.then === "function") throw new Error("Selector processor returned a promise to a synchronous call.");
|
|
3286
|
+
var string = void 0;
|
|
3287
|
+
if (options.updateSelector && typeof rule !== "string") {
|
|
3288
|
+
string = root.toString(this._stringifyOptions(options));
|
|
3289
|
+
rule.selector = string;
|
|
3290
|
+
}
|
|
3291
|
+
return {
|
|
3292
|
+
transform,
|
|
3293
|
+
root,
|
|
3294
|
+
string
|
|
3295
|
+
};
|
|
3296
|
+
};
|
|
3297
|
+
Processor.prototype.ast = function(rule, options) {
|
|
3298
|
+
return this._run(rule, options).then(function(result) {
|
|
3299
|
+
return result.root;
|
|
3300
|
+
});
|
|
3301
|
+
};
|
|
3302
|
+
Processor.prototype.astSync = function(rule, options) {
|
|
3303
|
+
return this._runSync(rule, options).root;
|
|
3304
|
+
};
|
|
3305
|
+
Processor.prototype.transform = function(rule, options) {
|
|
3306
|
+
return this._run(rule, options).then(function(result) {
|
|
3307
|
+
return result.transform;
|
|
3308
|
+
});
|
|
3309
|
+
};
|
|
3310
|
+
Processor.prototype.transformSync = function(rule, options) {
|
|
3311
|
+
return this._runSync(rule, options).transform;
|
|
3312
|
+
};
|
|
3313
|
+
Processor.prototype.process = function(rule, options) {
|
|
3314
|
+
var _this = this;
|
|
3315
|
+
return this._run(rule, options).then(function(result) {
|
|
3316
|
+
return result.string || result.root.toString(_this._stringifyOptions(options));
|
|
3317
|
+
});
|
|
3318
|
+
};
|
|
3319
|
+
Processor.prototype.processSync = function(rule, options) {
|
|
3320
|
+
var result = this._runSync(rule, options);
|
|
3321
|
+
return result.string || result.root.toString(this._stringifyOptions(options));
|
|
3322
|
+
};
|
|
3323
|
+
return Processor;
|
|
3324
|
+
}();
|
|
3325
|
+
}));
|
|
3326
|
+
var require_constructors = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
3327
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
3328
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
3329
|
+
};
|
|
3330
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3331
|
+
exports.universal = exports.tag = exports.string = exports.selector = exports.root = exports.pseudo = exports.nesting = exports.id = exports.comment = exports.combinator = exports.className = exports.attribute = void 0;
|
|
3332
|
+
var attribute_1 = __importDefault(require_attribute());
|
|
3333
|
+
var className_1 = __importDefault(require_className());
|
|
3334
|
+
var combinator_1 = __importDefault(require_combinator());
|
|
3335
|
+
var comment_1 = __importDefault(require_comment());
|
|
3336
|
+
var id_1 = __importDefault(require_id());
|
|
3337
|
+
var nesting_1 = __importDefault(require_nesting());
|
|
3338
|
+
var pseudo_1 = __importDefault(require_pseudo());
|
|
3339
|
+
var root_1 = __importDefault(require_root());
|
|
3340
|
+
var selector_1 = __importDefault(require_selector());
|
|
3341
|
+
var string_1 = __importDefault(require_string());
|
|
3342
|
+
var tag_1 = __importDefault(require_tag());
|
|
3343
|
+
var universal_1 = __importDefault(require_universal());
|
|
3344
|
+
var attribute = function(opts) {
|
|
3345
|
+
return new attribute_1.default(opts);
|
|
3346
|
+
};
|
|
3347
|
+
exports.attribute = attribute;
|
|
3348
|
+
var className = function(opts) {
|
|
3349
|
+
return new className_1.default(opts);
|
|
3350
|
+
};
|
|
3351
|
+
exports.className = className;
|
|
3352
|
+
var combinator = function(opts) {
|
|
3353
|
+
return new combinator_1.default(opts);
|
|
3354
|
+
};
|
|
3355
|
+
exports.combinator = combinator;
|
|
3356
|
+
var comment = function(opts) {
|
|
3357
|
+
return new comment_1.default(opts);
|
|
3358
|
+
};
|
|
3359
|
+
exports.comment = comment;
|
|
3360
|
+
var id = function(opts) {
|
|
3361
|
+
return new id_1.default(opts);
|
|
3362
|
+
};
|
|
3363
|
+
exports.id = id;
|
|
3364
|
+
var nesting = function(opts) {
|
|
3365
|
+
return new nesting_1.default(opts);
|
|
3366
|
+
};
|
|
3367
|
+
exports.nesting = nesting;
|
|
3368
|
+
var pseudo = function(opts) {
|
|
3369
|
+
return new pseudo_1.default(opts);
|
|
3370
|
+
};
|
|
3371
|
+
exports.pseudo = pseudo;
|
|
3372
|
+
var root = function(opts) {
|
|
3373
|
+
return new root_1.default(opts);
|
|
3374
|
+
};
|
|
3375
|
+
exports.root = root;
|
|
3376
|
+
var selector = function(opts) {
|
|
3377
|
+
return new selector_1.default(opts);
|
|
3378
|
+
};
|
|
3379
|
+
exports.selector = selector;
|
|
3380
|
+
var string = function(opts) {
|
|
3381
|
+
return new string_1.default(opts);
|
|
3382
|
+
};
|
|
3383
|
+
exports.string = string;
|
|
3384
|
+
var tag = function(opts) {
|
|
3385
|
+
return new tag_1.default(opts);
|
|
3386
|
+
};
|
|
3387
|
+
exports.tag = tag;
|
|
3388
|
+
var universal = function(opts) {
|
|
3389
|
+
return new universal_1.default(opts);
|
|
3390
|
+
};
|
|
3391
|
+
exports.universal = universal;
|
|
3392
|
+
}));
|
|
3393
|
+
var require_guards = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
3394
|
+
var _a;
|
|
3395
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3396
|
+
exports.isUniversal = exports.isTag = exports.isString = exports.isSelector = exports.isRoot = exports.isPseudo = exports.isNesting = exports.isIdentifier = exports.isComment = exports.isCombinator = exports.isClassName = exports.isAttribute = void 0;
|
|
3397
|
+
exports.isNode = isNode;
|
|
3398
|
+
exports.isPseudoElement = isPseudoElement;
|
|
3399
|
+
exports.isPseudoClass = isPseudoClass;
|
|
3400
|
+
exports.isContainer = isContainer;
|
|
3401
|
+
exports.isNamespace = isNamespace;
|
|
3402
|
+
var types_1 = require_types();
|
|
3403
|
+
var IS_TYPE = (_a = {}, _a[types_1.ATTRIBUTE] = true, _a[types_1.CLASS] = true, _a[types_1.COMBINATOR] = true, _a[types_1.COMMENT] = true, _a[types_1.ID] = true, _a[types_1.NESTING] = true, _a[types_1.PSEUDO] = true, _a[types_1.ROOT] = true, _a[types_1.SELECTOR] = true, _a[types_1.STRING] = true, _a[types_1.TAG] = true, _a[types_1.UNIVERSAL] = true, _a);
|
|
3404
|
+
function isNode(node) {
|
|
3405
|
+
return typeof node === "object" && IS_TYPE[node.type];
|
|
3406
|
+
}
|
|
3407
|
+
function isNodeType(type, node) {
|
|
3408
|
+
return isNode(node) && node.type === type;
|
|
3409
|
+
}
|
|
3410
|
+
exports.isAttribute = isNodeType.bind(null, types_1.ATTRIBUTE);
|
|
3411
|
+
exports.isClassName = isNodeType.bind(null, types_1.CLASS);
|
|
3412
|
+
exports.isCombinator = isNodeType.bind(null, types_1.COMBINATOR);
|
|
3413
|
+
exports.isComment = isNodeType.bind(null, types_1.COMMENT);
|
|
3414
|
+
exports.isIdentifier = isNodeType.bind(null, types_1.ID);
|
|
3415
|
+
exports.isNesting = isNodeType.bind(null, types_1.NESTING);
|
|
3416
|
+
exports.isPseudo = isNodeType.bind(null, types_1.PSEUDO);
|
|
3417
|
+
exports.isRoot = isNodeType.bind(null, types_1.ROOT);
|
|
3418
|
+
exports.isSelector = isNodeType.bind(null, types_1.SELECTOR);
|
|
3419
|
+
exports.isString = isNodeType.bind(null, types_1.STRING);
|
|
3420
|
+
exports.isTag = isNodeType.bind(null, types_1.TAG);
|
|
3421
|
+
exports.isUniversal = isNodeType.bind(null, types_1.UNIVERSAL);
|
|
3422
|
+
function isPseudoElement(node) {
|
|
3423
|
+
return (0, exports.isPseudo)(node) && node.value && (node.value.startsWith("::") || node.value.toLowerCase() === ":before" || node.value.toLowerCase() === ":after" || node.value.toLowerCase() === ":first-letter" || node.value.toLowerCase() === ":first-line");
|
|
3424
|
+
}
|
|
3425
|
+
function isPseudoClass(node) {
|
|
3426
|
+
return (0, exports.isPseudo)(node) && !isPseudoElement(node);
|
|
3427
|
+
}
|
|
3428
|
+
function isContainer(node) {
|
|
3429
|
+
return !!(isNode(node) && node.walk);
|
|
3430
|
+
}
|
|
3431
|
+
function isNamespace(node) {
|
|
3432
|
+
return (0, exports.isAttribute)(node) || (0, exports.isTag)(node);
|
|
3433
|
+
}
|
|
3434
|
+
}));
|
|
3435
|
+
var require_selectors = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
3436
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
3437
|
+
if (k2 === void 0) k2 = k;
|
|
3438
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
3439
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) desc = {
|
|
3440
|
+
enumerable: true,
|
|
3441
|
+
get: function() {
|
|
3442
|
+
return m[k];
|
|
3443
|
+
}
|
|
3444
|
+
};
|
|
3445
|
+
Object.defineProperty(o, k2, desc);
|
|
3446
|
+
}) : (function(o, m, k, k2) {
|
|
3447
|
+
if (k2 === void 0) k2 = k;
|
|
3448
|
+
o[k2] = m[k];
|
|
3449
|
+
}));
|
|
3450
|
+
var __exportStar = exports && exports.__exportStar || function(m, exports$1) {
|
|
3451
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$1, p)) __createBinding(exports$1, m, p);
|
|
3452
|
+
};
|
|
3453
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3454
|
+
__exportStar(require_types(), exports);
|
|
3455
|
+
__exportStar(require_constructors(), exports);
|
|
3456
|
+
__exportStar(require_guards(), exports);
|
|
3457
|
+
}));
|
|
3458
|
+
var require_dist = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
3459
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
3460
|
+
if (k2 === void 0) k2 = k;
|
|
3461
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
3462
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) desc = {
|
|
3463
|
+
enumerable: true,
|
|
3464
|
+
get: function() {
|
|
3465
|
+
return m[k];
|
|
3466
|
+
}
|
|
3467
|
+
};
|
|
3468
|
+
Object.defineProperty(o, k2, desc);
|
|
3469
|
+
}) : (function(o, m, k, k2) {
|
|
3470
|
+
if (k2 === void 0) k2 = k;
|
|
3471
|
+
o[k2] = m[k];
|
|
3472
|
+
}));
|
|
3473
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
|
|
3474
|
+
Object.defineProperty(o, "default", {
|
|
3475
|
+
enumerable: true,
|
|
3476
|
+
value: v
|
|
3477
|
+
});
|
|
3478
|
+
}) : function(o, v) {
|
|
3479
|
+
o["default"] = v;
|
|
3480
|
+
});
|
|
3481
|
+
var __importStar = exports && exports.__importStar || (function() {
|
|
3482
|
+
var ownKeys = function(o) {
|
|
3483
|
+
ownKeys = Object.getOwnPropertyNames || function(o) {
|
|
3484
|
+
var ar = [];
|
|
3485
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
3486
|
+
return ar;
|
|
3487
|
+
};
|
|
3488
|
+
return ownKeys(o);
|
|
3489
|
+
};
|
|
3490
|
+
return function(mod) {
|
|
3491
|
+
if (mod && mod.__esModule) return mod;
|
|
3492
|
+
var result = {};
|
|
3493
|
+
if (mod != null) {
|
|
3494
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
3495
|
+
}
|
|
3496
|
+
__setModuleDefault(result, mod);
|
|
3497
|
+
return result;
|
|
3498
|
+
};
|
|
3499
|
+
})();
|
|
3500
|
+
var processor_1 = (exports && exports.__importDefault || function(mod) {
|
|
3501
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
3502
|
+
})(require_processor());
|
|
3503
|
+
var selectors = __importStar(require_selectors());
|
|
3504
|
+
var parser = function(processor) {
|
|
3505
|
+
return new processor_1.default(processor);
|
|
3506
|
+
};
|
|
3507
|
+
Object.assign(parser, selectors);
|
|
3508
|
+
delete parser.__esModule;
|
|
3509
|
+
module.exports = parser;
|
|
3510
|
+
}));
|
|
3511
|
+
var import_deepmerge = require_deepmerge();
|
|
3512
|
+
var import_dist = /* @__PURE__ */ __toESM(require_dist(), 1);
|
|
3513
|
+
function inWhere(selector, { className, prefix, modifier }) {
|
|
3514
|
+
const prefixedNot = prefix(`.not-${className}`).slice(1);
|
|
3515
|
+
const selectorPrefix = selector.startsWith(">") ? `${modifier === "DEFAULT" ? `.${className}` : `.${className}-${modifier}`} ` : "";
|
|
3516
|
+
const [trailingPseudo, rebuiltSelector] = commonTrailingPseudos(selector);
|
|
3517
|
+
if (trailingPseudo) return `:where(${selectorPrefix}${rebuiltSelector}):not(:where([class~="${prefixedNot}"],[class~="${prefixedNot}"] *))${trailingPseudo}`;
|
|
3518
|
+
return `:where(${selectorPrefix}${selector}):not(:where([class~="${prefixedNot}"],[class~="${prefixedNot}"] *))`;
|
|
3519
|
+
}
|
|
3520
|
+
function configToCss(config = {}, { className, modifier, prefix }) {
|
|
3521
|
+
function updateSelector(k, v) {
|
|
3522
|
+
if (Array.isArray(v)) return [k, v];
|
|
3523
|
+
if (typeof v === "object" && v !== null) {
|
|
3524
|
+
if (Object.values(v).some((prop) => typeof prop === "object")) return [
|
|
3525
|
+
inWhere(k, {
|
|
3526
|
+
className,
|
|
3527
|
+
modifier,
|
|
3528
|
+
prefix
|
|
3529
|
+
}),
|
|
3530
|
+
v,
|
|
3531
|
+
Object.fromEntries(Object.entries(v).map(([k, v]) => updateSelector(k, v)))
|
|
3532
|
+
];
|
|
3533
|
+
return [inWhere(k, {
|
|
3534
|
+
className,
|
|
3535
|
+
modifier,
|
|
3536
|
+
prefix
|
|
3537
|
+
}), v];
|
|
3538
|
+
}
|
|
3539
|
+
return [k, v];
|
|
3540
|
+
}
|
|
3541
|
+
const css = config.css ?? [];
|
|
3542
|
+
const mergedCss = Array.isArray(css) ? dm(...css) : css;
|
|
3543
|
+
return Object.fromEntries(Object.entries(mergedCss).map(([k, v]) => updateSelector(k, v)));
|
|
3544
|
+
}
|
|
3545
|
+
const dm = (0, import_deepmerge.deepmerge)({ all: true });
|
|
3546
|
+
const parseSelector = (0, import_dist.default)();
|
|
3547
|
+
function commonTrailingPseudos(selector) {
|
|
3548
|
+
const ast = parseSelector.astSync(selector);
|
|
3549
|
+
const matrix = [];
|
|
3550
|
+
for (const [i, sel] of ast.nodes.entries()) for (const [j, child] of [...sel.nodes].reverse().entries()) {
|
|
3551
|
+
if (child.type !== "pseudo" || !child.value.startsWith("::")) break;
|
|
3552
|
+
matrix[j] = matrix[j] || [];
|
|
3553
|
+
matrix[j][i] = child;
|
|
3554
|
+
}
|
|
3555
|
+
const trailingPseudos = import_dist.default.selector({ value: "" });
|
|
3556
|
+
for (const pseudos of matrix) {
|
|
3557
|
+
if (!pseudos) continue;
|
|
3558
|
+
if (new Set(pseudos.map((p) => p.value)).size > 1) break;
|
|
3559
|
+
pseudos.forEach((pseudo) => pseudo.remove());
|
|
3560
|
+
trailingPseudos.prepend(pseudos[0]);
|
|
3561
|
+
}
|
|
3562
|
+
if (trailingPseudos.nodes.length) return [trailingPseudos.toString(), ast.toString()];
|
|
3563
|
+
return [null, selector];
|
|
3564
|
+
}
|
|
3565
|
+
const SELECTORS = [
|
|
3566
|
+
[
|
|
3567
|
+
"headings",
|
|
3568
|
+
"h1",
|
|
3569
|
+
"h2",
|
|
3570
|
+
"h3",
|
|
3571
|
+
"h4",
|
|
3572
|
+
"h5",
|
|
3573
|
+
"h6",
|
|
3574
|
+
"th"
|
|
3575
|
+
],
|
|
3576
|
+
["h1"],
|
|
3577
|
+
["h2"],
|
|
3578
|
+
["h3"],
|
|
3579
|
+
["h4"],
|
|
3580
|
+
["h5"],
|
|
3581
|
+
["h6"],
|
|
3582
|
+
["p"],
|
|
3583
|
+
["a"],
|
|
3584
|
+
["blockquote"],
|
|
3585
|
+
["figure"],
|
|
3586
|
+
["figcaption"],
|
|
3587
|
+
["strong"],
|
|
3588
|
+
["em"],
|
|
3589
|
+
["kbd"],
|
|
3590
|
+
["code"],
|
|
3591
|
+
["pre"],
|
|
3592
|
+
["ol"],
|
|
3593
|
+
["ul"],
|
|
3594
|
+
["li"],
|
|
3595
|
+
["table"],
|
|
3596
|
+
["thead"],
|
|
3597
|
+
["tr"],
|
|
3598
|
+
["th"],
|
|
3599
|
+
["td"],
|
|
3600
|
+
["img"],
|
|
3601
|
+
["video"],
|
|
3602
|
+
["hr"],
|
|
3603
|
+
["lead", "[class~=\"lead\"]"]
|
|
3604
|
+
];
|
|
3605
|
+
const typography = plugin.withOptions(({ className = "prose", ...styleOptions } = {}) => {
|
|
3606
|
+
return ({ addVariant, addComponents, ...rest }) => {
|
|
3607
|
+
const prefix = rest.prefix;
|
|
3608
|
+
for (const [name, ...values] of SELECTORS) {
|
|
3609
|
+
const selector = (values.length === 0 ? [name] : values).join(", ");
|
|
3610
|
+
addVariant(`${className}-${name}`, `& :is(${inWhere(selector, {
|
|
3611
|
+
prefix,
|
|
3612
|
+
className
|
|
3613
|
+
})})`);
|
|
3614
|
+
}
|
|
3615
|
+
addComponents({
|
|
3616
|
+
[`.${className}`]: configToCss({
|
|
3617
|
+
...DEFAULT,
|
|
3618
|
+
css: [...DEFAULT.css ?? [], styleOptions.disableRoundedTable ? normalTable : roundedTable]
|
|
3619
|
+
}, {
|
|
3620
|
+
className,
|
|
3621
|
+
modifier: "DEFAULT",
|
|
3622
|
+
prefix
|
|
3623
|
+
}),
|
|
3624
|
+
[`.${className}-sm`]: configToCss(SMALL, {
|
|
3625
|
+
className,
|
|
3626
|
+
modifier: "sm",
|
|
3627
|
+
prefix
|
|
3628
|
+
}),
|
|
3629
|
+
[`.${className}-xs`]: configToCss(EXTRA_SMALL, {
|
|
3630
|
+
className,
|
|
3631
|
+
modifier: "xs",
|
|
3632
|
+
prefix
|
|
3633
|
+
})
|
|
3634
|
+
});
|
|
3635
|
+
};
|
|
3636
|
+
});
|
|
3637
|
+
export { typography as default, typography };
|