@ragrails/api-playground-react 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -0
- package/dist/index.cjs +15 -0
- package/dist/index.js +2827 -0
- package/dist/src/components/ui/Badge.d.ts +21 -0
- package/dist/src/components/ui/Button.d.ts +14 -0
- package/dist/src/components/ui/Card.d.ts +12 -0
- package/dist/src/components/ui/Checkbox.d.ts +14 -0
- package/dist/src/components/ui/CodeBlock.d.ts +18 -0
- package/dist/src/components/ui/ColorField.d.ts +11 -0
- package/dist/src/components/ui/CopyButton.d.ts +13 -0
- package/dist/src/components/ui/Icon.d.ts +14 -0
- package/dist/src/components/ui/IconButton.d.ts +11 -0
- package/dist/src/components/ui/MethodSelect.d.ts +13 -0
- package/dist/src/components/ui/ResponseEmptyState.d.ts +11 -0
- package/dist/src/components/ui/ResponseLoadingState.d.ts +9 -0
- package/dist/src/components/ui/Select.d.ts +17 -0
- package/dist/src/components/ui/Skeleton.d.ts +13 -0
- package/dist/src/components/ui/Spinner.d.ts +10 -0
- package/dist/src/components/ui/Switch.d.ts +11 -0
- package/dist/src/components/ui/Tabs.d.ts +18 -0
- package/dist/src/components/ui/TextField.d.ts +16 -0
- package/dist/src/components/ui/index.d.ts +26 -0
- package/dist/src/features/api-widget/ApiConsole.d.ts +13 -0
- package/dist/src/features/api-widget/ApiWidget.d.ts +24 -0
- package/dist/src/features/api-widget/ImportCard.d.ts +11 -0
- package/dist/src/features/api-widget/RequestSnippet.d.ts +13 -0
- package/dist/src/features/api-widget/curl.d.ts +7 -0
- package/dist/src/features/api-widget/executor.d.ts +4 -0
- package/dist/src/features/api-widget/index.d.ts +10 -0
- package/dist/src/features/api-widget/request-model.d.ts +21 -0
- package/dist/src/features/api-widget/snippets.d.ts +9 -0
- package/dist/src/features/api-widget/types.d.ts +41 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/lib/clipboard.d.ts +15 -0
- package/dist/src/lib/cn.d.ts +2 -0
- package/dist/src/lib/highlight.d.ts +8 -0
- package/dist/src/types/index.d.ts +32 -0
- package/dist/styles.css +2 -0
- package/package.json +57 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,2827 @@
|
|
|
1
|
+
import e, { useEffect as t, useId as n, useLayoutEffect as r, useMemo as i, useRef as a, useState as o } from "react";
|
|
2
|
+
import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
3
|
+
//#region \0rolldown/runtime.js
|
|
4
|
+
var u = Object.create, d = Object.defineProperty, f = Object.getOwnPropertyDescriptor, p = Object.getOwnPropertyNames, m = Object.getPrototypeOf, h = Object.prototype.hasOwnProperty, g = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), _ = (e, t, n, r) => {
|
|
5
|
+
if (t && typeof t == "object" || typeof t == "function") for (var i = p(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !h.call(e, s) && s !== n && d(e, s, {
|
|
6
|
+
get: ((e) => t[e]).bind(null, s),
|
|
7
|
+
enumerable: !(r = f(t, s)) || r.enumerable
|
|
8
|
+
});
|
|
9
|
+
return e;
|
|
10
|
+
}, v = (e, t, n) => (n = e == null ? {} : u(m(e)), _(t || !e || !e.__esModule ? d(n, "default", {
|
|
11
|
+
value: e,
|
|
12
|
+
enumerable: !0
|
|
13
|
+
}) : n, e));
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/lib/cn.ts
|
|
16
|
+
function y(...e) {
|
|
17
|
+
return e.filter(Boolean).join(" ");
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/components/ui/Icon.tsx
|
|
21
|
+
var b = {
|
|
22
|
+
copy: /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("path", {
|
|
23
|
+
fill: "currentColor",
|
|
24
|
+
d: "M15.24 2h-3.894c-1.764 0-3.162 0-4.255.148c-1.126.152-2.037.472-2.755 1.193c-.719.721-1.038 1.636-1.189 2.766C3 7.205 3 8.608 3 10.379v5.838c0 1.508.92 2.8 2.227 3.342c-.067-.91-.067-2.185-.067-3.247v-5.01c0-1.281 0-2.386.118-3.27c.127-.948.413-1.856 1.147-2.593s1.639-1.024 2.583-1.152c.88-.118 1.98-.118 3.257-.118h3.07c1.276 0 2.374 0 3.255.118A3.6 3.6 0 0 0 15.24 2"
|
|
25
|
+
}), /* @__PURE__ */ c("path", {
|
|
26
|
+
fill: "currentColor",
|
|
27
|
+
d: "M6.6 11.397c0-2.726 0-4.089.844-4.936c.843-.847 2.2-.847 4.916-.847h2.88c2.715 0 4.073 0 4.917.847S21 8.671 21 11.397v4.82c0 2.726 0 4.089-.843 4.936c-.844.847-2.202.847-4.917.847h-2.88c-2.715 0-4.073 0-4.916-.847c-.844-.847-.844-2.21-.844-4.936z"
|
|
28
|
+
})] }),
|
|
29
|
+
check: /* @__PURE__ */ c("path", {
|
|
30
|
+
fill: "none",
|
|
31
|
+
stroke: "currentColor",
|
|
32
|
+
strokeLinecap: "round",
|
|
33
|
+
strokeLinejoin: "round",
|
|
34
|
+
strokeWidth: "1.5",
|
|
35
|
+
d: "m4 12.9l3.143 3.6L15 7.5m5 .063l-8.572 9L11 16"
|
|
36
|
+
}),
|
|
37
|
+
download: /* @__PURE__ */ c("path", {
|
|
38
|
+
fill: "none",
|
|
39
|
+
stroke: "currentColor",
|
|
40
|
+
strokeLinecap: "round",
|
|
41
|
+
strokeLinejoin: "round",
|
|
42
|
+
strokeWidth: "1.5",
|
|
43
|
+
d: "M3 15c0 2.828 0 4.243.879 5.121C4.757 21 6.172 21 9 21h6c2.828 0 4.243 0 5.121-.879C21 19.243 21 17.828 21 15M12 3v13m0 0l4-4.375M12 16l-4-4.375"
|
|
44
|
+
}),
|
|
45
|
+
send: /* @__PURE__ */ l("g", {
|
|
46
|
+
fill: "none",
|
|
47
|
+
children: [/* @__PURE__ */ c("path", {
|
|
48
|
+
stroke: "currentColor",
|
|
49
|
+
strokeWidth: "1.5",
|
|
50
|
+
d: "m18.636 15.67l1.716-5.15c1.5-4.498 2.25-6.747 1.062-7.934s-3.436-.438-7.935 1.062L8.33 5.364C4.7 6.574 2.885 7.18 2.37 8.067a2.72 2.72 0 0 0 0 2.73c.515.888 2.33 1.493 5.96 2.704c.584.194.875.291 1.119.454c.236.158.439.361.597.597c.163.244.26.535.454 1.118c1.21 3.63 1.816 5.446 2.703 5.962a2.72 2.72 0 0 0 2.731 0c.887-.516 1.492-2.331 2.703-5.962Z"
|
|
51
|
+
}), /* @__PURE__ */ c("path", {
|
|
52
|
+
fill: "currentColor",
|
|
53
|
+
d: "M16.212 8.848a.75.75 0 0 0-1.055-1.066zm-5.55 5.488l5.55-5.488l-1.055-1.066l-5.55 5.488z"
|
|
54
|
+
})]
|
|
55
|
+
}),
|
|
56
|
+
share: /* @__PURE__ */ l("g", {
|
|
57
|
+
fill: "none",
|
|
58
|
+
stroke: "currentColor",
|
|
59
|
+
strokeLinecap: "round",
|
|
60
|
+
strokeWidth: "1.5",
|
|
61
|
+
children: [/* @__PURE__ */ c("path", {
|
|
62
|
+
strokeLinejoin: "round",
|
|
63
|
+
d: "M22 7h-8c-1.818 0-2.913.892-3.32 1.3q-.187.19-.19.19q0 .003-.19.19C9.892 9.087 9 10.182 9 12v3m13-8l-5-5m5 5l-5 5"
|
|
64
|
+
}), /* @__PURE__ */ c("path", { d: "M3.465 20.535C4.93 22 7.287 22 12.003 22c4.715 0 7.073 0 8.537-1.465c1.242-1.241 1.431-3.123 1.46-6.537M3.465 20.535C2 19.07 2 16.713 2 11.997m1.465 8.538C4.929 22 7.286 22 12 22s7.071 0 8.535-1.465c1.241-1.24 1.43-3.122 1.46-6.536m-18.53 6.536C2 19.071 2 16.714 2 12m1.465-8.54C4.706 2.218 6.588 2.029 10.002 2M2.055 8c.11-2.193.436-3.562 1.41-4.536c1.24-1.24 3.122-1.43 6.535-1.459" })]
|
|
65
|
+
}),
|
|
66
|
+
code: /* @__PURE__ */ c("path", {
|
|
67
|
+
fill: "none",
|
|
68
|
+
stroke: "currentColor",
|
|
69
|
+
strokeLinecap: "round",
|
|
70
|
+
strokeWidth: "1.5",
|
|
71
|
+
d: "m17 7.83l1.697 1.526c1.542 1.389 2.313 2.083 2.313 2.974c0 .89-.771 1.585-2.314 2.973L17 16.83M13.987 5L12 12.415l-1.987 7.415M7 7.83L5.304 9.356C3.76 10.745 2.99 11.44 2.99 12.33s.771 1.585 2.314 2.973L7 16.83"
|
|
72
|
+
}),
|
|
73
|
+
"arrow-left": /* @__PURE__ */ c("path", {
|
|
74
|
+
fill: "none",
|
|
75
|
+
stroke: "currentColor",
|
|
76
|
+
strokeLinecap: "round",
|
|
77
|
+
strokeLinejoin: "round",
|
|
78
|
+
strokeWidth: "1.5",
|
|
79
|
+
d: "M20 12H4m0 0l6-6m-6 6l6 6"
|
|
80
|
+
}),
|
|
81
|
+
"arrow-right": /* @__PURE__ */ c("path", {
|
|
82
|
+
fill: "none",
|
|
83
|
+
stroke: "currentColor",
|
|
84
|
+
strokeLinecap: "round",
|
|
85
|
+
strokeLinejoin: "round",
|
|
86
|
+
strokeWidth: "1.5",
|
|
87
|
+
d: "M4 12h16m0 0l-6-6m6 6l-6 6"
|
|
88
|
+
}),
|
|
89
|
+
"chevron-down": /* @__PURE__ */ c("path", {
|
|
90
|
+
fill: "none",
|
|
91
|
+
stroke: "currentColor",
|
|
92
|
+
strokeLinecap: "round",
|
|
93
|
+
strokeLinejoin: "round",
|
|
94
|
+
strokeWidth: "1.5",
|
|
95
|
+
d: "m19 9l-7 6l-7-6"
|
|
96
|
+
}),
|
|
97
|
+
trash: /* @__PURE__ */ l("g", {
|
|
98
|
+
fill: "none",
|
|
99
|
+
stroke: "currentColor",
|
|
100
|
+
strokeWidth: "1.5",
|
|
101
|
+
children: [/* @__PURE__ */ c("path", {
|
|
102
|
+
strokeLinecap: "round",
|
|
103
|
+
d: "M20.5 6h-17m15.333 2.5l-.46 6.9c-.177 2.654-.265 3.981-1.13 4.79s-2.196.81-4.856.81h-.774c-2.66 0-3.991 0-4.856-.81c-.865-.809-.954-2.136-1.13-4.79l-.46-6.9M9.5 11l.5 5m4.5-5l-.5 5"
|
|
104
|
+
}), /* @__PURE__ */ c("path", { d: "M6.5 6h.11a2 2 0 0 0 1.83-1.32l.034-.103l.097-.291c.083-.249.125-.373.18-.479a1.5 1.5 0 0 1 1.094-.788C9.962 3 10.093 3 10.355 3h3.29c.262 0 .393 0 .51.019a1.5 1.5 0 0 1 1.094.788c.055.106.097.23.18.479l.097.291A2 2 0 0 0 17.5 6" })]
|
|
105
|
+
}),
|
|
106
|
+
plus: /* @__PURE__ */ l("g", {
|
|
107
|
+
fill: "none",
|
|
108
|
+
stroke: "currentColor",
|
|
109
|
+
strokeWidth: "1.5",
|
|
110
|
+
children: [/* @__PURE__ */ c("circle", {
|
|
111
|
+
cx: "12",
|
|
112
|
+
cy: "12",
|
|
113
|
+
r: "10"
|
|
114
|
+
}), /* @__PURE__ */ c("path", {
|
|
115
|
+
strokeLinecap: "round",
|
|
116
|
+
d: "M15 12h-3m0 0H9m3 0V9m0 3v3"
|
|
117
|
+
})]
|
|
118
|
+
}),
|
|
119
|
+
moon: /* @__PURE__ */ c("path", {
|
|
120
|
+
fill: "currentColor",
|
|
121
|
+
d: "M12 22c5.523 0 10-4.477 10-10c0-.463-.694-.54-.933-.143a6.5 6.5 0 1 1-8.924-8.924C12.54 2.693 12.463 2 12 2C6.477 2 2 6.477 2 12s4.477 10 10 10"
|
|
122
|
+
}),
|
|
123
|
+
sun: /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("path", {
|
|
124
|
+
fill: "currentColor",
|
|
125
|
+
d: "M17 12a5 5 0 1 1-10 0a5 5 0 0 1 10 0"
|
|
126
|
+
}), /* @__PURE__ */ c("path", {
|
|
127
|
+
fill: "currentColor",
|
|
128
|
+
fillRule: "evenodd",
|
|
129
|
+
d: "M12 1.25a.75.75 0 0 1 .75.75v2a.75.75 0 0 1-1.5 0V2a.75.75 0 0 1 .75-.75M3.669 3.716a.75.75 0 0 1 1.06-.047L6.95 5.7a.75.75 0 1 1-1.012 1.107L3.716 4.776a.75.75 0 0 1-.047-1.06m16.662 0a.75.75 0 0 1-.047 1.06l-2.222 2.031A.75.75 0 0 1 17.05 5.7l2.222-2.031a.75.75 0 0 1 1.06.047M1.25 12a.75.75 0 0 1 .75-.75h2a.75.75 0 0 1 0 1.5H2a.75.75 0 0 1-.75-.75m18 0a.75.75 0 0 1 .75-.75h2a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1-.75-.75m-2.224 5.025a.75.75 0 0 1 1.06 0l2.222 2.223a.75.75 0 0 1-1.06 1.06l-2.222-2.222a.75.75 0 0 1 0-1.06m-10.051 0a.75.75 0 0 1 0 1.061l-2.223 2.222a.75.75 0 0 1-1.06-1.06l2.222-2.223a.75.75 0 0 1 1.06 0M12 19.25a.75.75 0 0 1 .75.75v2a.75.75 0 0 1-1.5 0v-2a.75.75 0 0 1 .75-.75",
|
|
130
|
+
clipRule: "evenodd"
|
|
131
|
+
})] }),
|
|
132
|
+
palette: /* @__PURE__ */ l(s, { children: [
|
|
133
|
+
/* @__PURE__ */ c("mask", {
|
|
134
|
+
id: "solar-palette-a",
|
|
135
|
+
fill: "#fff",
|
|
136
|
+
children: /* @__PURE__ */ c("path", { d: "M11.085 7a1.5 1.5 0 1 1-3 0a1.5 1.5 0 0 1 3 0" })
|
|
137
|
+
}),
|
|
138
|
+
/* @__PURE__ */ c("mask", {
|
|
139
|
+
id: "solar-palette-b",
|
|
140
|
+
fill: "#fff",
|
|
141
|
+
children: /* @__PURE__ */ c("path", { d: "M16 7a1.5 1.5 0 1 1-3 0a1.5 1.5 0 0 1 3 0" })
|
|
142
|
+
}),
|
|
143
|
+
/* @__PURE__ */ l("g", {
|
|
144
|
+
fill: "none",
|
|
145
|
+
stroke: "currentColor",
|
|
146
|
+
children: [
|
|
147
|
+
/* @__PURE__ */ c("path", {
|
|
148
|
+
strokeWidth: "1.5",
|
|
149
|
+
d: "M2 12.026c0 5.146 3.867 9.387 8.847 9.96c.735.085 1.447-.228 1.97-.753a1.68 1.68 0 0 0 0-2.372c-.523-.525-.95-1.307-.555-1.934c1.576-2.508 9.738 3.251 9.738-4.9C22 6.488 17.523 2 12 2S2 6.489 2 12.026Z"
|
|
150
|
+
}),
|
|
151
|
+
/* @__PURE__ */ c("circle", {
|
|
152
|
+
cx: "17.5",
|
|
153
|
+
cy: "11.5",
|
|
154
|
+
r: ".75",
|
|
155
|
+
strokeWidth: "1.5"
|
|
156
|
+
}),
|
|
157
|
+
/* @__PURE__ */ c("circle", {
|
|
158
|
+
cx: "6.5",
|
|
159
|
+
cy: "11.5",
|
|
160
|
+
r: ".75",
|
|
161
|
+
strokeWidth: "1.5"
|
|
162
|
+
}),
|
|
163
|
+
/* @__PURE__ */ c("path", {
|
|
164
|
+
strokeWidth: "3",
|
|
165
|
+
d: "M11.085 7a1.5 1.5 0 1 1-3 0a1.5 1.5 0 0 1 3 0Z",
|
|
166
|
+
mask: "url(#solar-palette-a)"
|
|
167
|
+
}),
|
|
168
|
+
/* @__PURE__ */ c("path", {
|
|
169
|
+
strokeWidth: "3",
|
|
170
|
+
d: "M16 7a1.5 1.5 0 1 1-3 0a1.5 1.5 0 0 1 3 0Z",
|
|
171
|
+
mask: "url(#solar-palette-b)"
|
|
172
|
+
})
|
|
173
|
+
]
|
|
174
|
+
})
|
|
175
|
+
] }),
|
|
176
|
+
magic: /* @__PURE__ */ c("path", {
|
|
177
|
+
fill: "currentColor",
|
|
178
|
+
d: "M3.845 3.845a2.883 2.883 0 0 0 0 4.077L5.432 9.51l.038-.04l4-4l.04-.038l-1.588-1.587a2.883 2.883 0 0 0-4.077 0m6.723 2.645l-.038.04l-4 4l-.04.038l9.588 9.588a2.884 2.884 0 0 0 4.078-4.078zM16.1 2.307a.483.483 0 0 1 .9 0l.43 1.095a.48.48 0 0 0 .272.274l1.091.432a.486.486 0 0 1 0 .903l-1.09.432a.5.5 0 0 0-.273.273L17 6.81a.483.483 0 0 1-.9 0l-.43-1.095a.5.5 0 0 0-.273-.273l-1.09-.432a.486.486 0 0 1 0-.903l1.09-.432a.5.5 0 0 0 .273-.274zm3.867 6.823a.483.483 0 0 1 .9 0l.156.399c.05.125.148.224.273.273l.398.158a.486.486 0 0 1 0 .902l-.398.158a.5.5 0 0 0-.273.273l-.156.4a.483.483 0 0 1-.9 0l-.157-.4a.5.5 0 0 0-.272-.273l-.398-.158a.486.486 0 0 1 0-.902l.398-.158a.5.5 0 0 0 .272-.273zM5.133 15.307a.483.483 0 0 1 .9 0l.157.4a.48.48 0 0 0 .272.273l.398.157a.486.486 0 0 1 0 .903l-.398.158a.48.48 0 0 0-.272.273l-.157.4a.483.483 0 0 1-.9 0l-.157-.4a.48.48 0 0 0-.272-.273l-.398-.158a.486.486 0 0 1 0-.903l.398-.157a.48.48 0 0 0 .272-.274z"
|
|
179
|
+
}),
|
|
180
|
+
restart: /* @__PURE__ */ c("path", {
|
|
181
|
+
fill: "none",
|
|
182
|
+
stroke: "currentColor",
|
|
183
|
+
strokeLinecap: "round",
|
|
184
|
+
strokeLinejoin: "round",
|
|
185
|
+
strokeWidth: "1.5",
|
|
186
|
+
d: "m18.364 8.05l-.707-.707a8 8 0 1 0 2.28 4.658m-1.573-3.95h-4.243m4.243 0V3.807"
|
|
187
|
+
}),
|
|
188
|
+
close: /* @__PURE__ */ l("g", {
|
|
189
|
+
fill: "none",
|
|
190
|
+
stroke: "currentColor",
|
|
191
|
+
strokeWidth: "1.5",
|
|
192
|
+
children: [/* @__PURE__ */ c("circle", {
|
|
193
|
+
cx: "12",
|
|
194
|
+
cy: "12",
|
|
195
|
+
r: "10"
|
|
196
|
+
}), /* @__PURE__ */ c("path", {
|
|
197
|
+
strokeLinecap: "round",
|
|
198
|
+
d: "m14.5 9.5l-5 5m0-5l5 5"
|
|
199
|
+
})]
|
|
200
|
+
}),
|
|
201
|
+
eye: /* @__PURE__ */ l("g", {
|
|
202
|
+
fill: "none",
|
|
203
|
+
stroke: "currentColor",
|
|
204
|
+
strokeWidth: "1.5",
|
|
205
|
+
children: [/* @__PURE__ */ c("path", { d: "M3.275 15.296C2.425 14.192 2 13.639 2 12c0-1.64.425-2.191 1.275-3.296C4.972 6.5 7.818 4 12 4s7.028 2.5 8.725 4.704C21.575 9.81 22 10.361 22 12c0 1.64-.425 2.191-1.275 3.296C19.028 17.5 16.182 20 12 20s-7.028-2.5-8.725-4.704Z" }), /* @__PURE__ */ c("path", { d: "M15 12a3 3 0 1 1-6 0a3 3 0 0 1 6 0Z" })]
|
|
206
|
+
}),
|
|
207
|
+
"eye-closed": /* @__PURE__ */ c("path", {
|
|
208
|
+
fill: "currentColor",
|
|
209
|
+
d: "M2.69 6.705a.75.75 0 0 0-1.38.59zm12.897 6.624l-.274-.698zm-6.546.409a.75.75 0 1 0-1.257-.818zm-2.67 1.353a.75.75 0 1 0 1.258.818zM22.69 7.295a.75.75 0 0 0-1.378-.59zM19 11.13l-.513-.547zm.97 2.03a.75.75 0 1 0 1.06-1.06zm-8.72 3.34a.75.75 0 0 0 1.5 0zm5.121-.591a.75.75 0 1 0 1.258-.818zm-10.84-4.25A.75.75 0 0 0 4.47 10.6zm-2.561.44a.75.75 0 0 0 1.06 1.06zM12 13.25c-3.224 0-5.539-1.605-7.075-3.26a13.6 13.6 0 0 1-1.702-2.28a12 12 0 0 1-.507-.946l-.022-.049l-.004-.01l-.001-.001L2 7l-.69.296h.001l.001.003l.003.006l.04.088q.039.088.117.243c.103.206.256.496.462.841c.41.69 1.035 1.61 1.891 2.533C5.54 12.855 8.224 14.75 12 14.75zm3.313-.62c-.97.383-2.071.62-3.313.62v1.5c1.438 0 2.725-.276 3.862-.723zm-7.529.29l-1.413 2.17l1.258.818l1.412-2.171zM22 7l-.69-.296h.001v.002l-.007.013l-.028.062a12 12 0 0 1-.64 1.162a13.3 13.3 0 0 1-2.15 2.639l1.027 1.094a14.8 14.8 0 0 0 3.122-4.26l.039-.085l.01-.024l.004-.007v-.003h.001v-.001zm-3.513 3.582c-.86.806-1.913 1.552-3.174 2.049l.549 1.396c1.473-.58 2.685-1.444 3.651-2.351zm-.017 1.077l1.5 1.5l1.06-1.06l-1.5-1.5zM11.25 14v2.5h1.5V14zm3.709-.262l1.412 2.171l1.258-.818l-1.413-2.171zm-10.49-3.14l-1.5 1.5L4.03 13.16l1.5-1.5z"
|
|
210
|
+
})
|
|
211
|
+
}, x = ({ name: e, size: t, className: n, ...r }) => /* @__PURE__ */ c("svg", {
|
|
212
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
213
|
+
viewBox: "0 0 24 24",
|
|
214
|
+
width: t ?? "1em",
|
|
215
|
+
height: t ?? "1em",
|
|
216
|
+
className: y("inline-block shrink-0", n),
|
|
217
|
+
"aria-hidden": r["aria-label"] ? void 0 : !0,
|
|
218
|
+
...r,
|
|
219
|
+
children: b[e]
|
|
220
|
+
}), S = {
|
|
221
|
+
primary: "bg-primary text-primary-contrast hover:bg-primary-hover",
|
|
222
|
+
secondary: "bg-surface-2 text-content border border-border hover:bg-border",
|
|
223
|
+
ghost: "bg-transparent text-muted hover:text-content",
|
|
224
|
+
danger: "bg-[#EF5350] text-white hover:bg-[#e53935]"
|
|
225
|
+
}, C = {
|
|
226
|
+
sm: "text-[12px] px-3 py-1.5",
|
|
227
|
+
md: "text-[14px] px-4 py-2",
|
|
228
|
+
lg: "text-[16px] px-5 py-2.5"
|
|
229
|
+
}, w = {
|
|
230
|
+
sm: "gap-1.5",
|
|
231
|
+
md: "gap-2",
|
|
232
|
+
lg: "gap-2"
|
|
233
|
+
}, T = ({ variant: e = "primary", size: t = "md", isLoading: n = !1, leftIcon: r, rightIcon: i, className: a, children: o, disabled: s, ...u }) => /* @__PURE__ */ l("button", {
|
|
234
|
+
className: y("group relative isolate overflow-hidden rounded-lg font-heading font-medium", "inline-flex items-center justify-center", "transition duration-150 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/60", "active:scale-105 motion-reduce:active:scale-100", "disabled:opacity-50 disabled:cursor-not-allowed", S[e], C[t], a),
|
|
235
|
+
disabled: s || n,
|
|
236
|
+
...u,
|
|
237
|
+
children: [e !== "ghost" && /* @__PURE__ */ c("span", {
|
|
238
|
+
"aria-hidden": "true",
|
|
239
|
+
className: y("pointer-events-none absolute inset-0 -z-10 -translate-x-full -skew-x-12", "bg-gradient-to-r from-transparent via-white/25 to-transparent", "transition-transform duration-0 ease-out", "group-hover:translate-x-full group-hover:duration-[1200ms] group-disabled:hidden")
|
|
240
|
+
}), /* @__PURE__ */ l("span", {
|
|
241
|
+
className: y("inline-flex items-center", w[t]),
|
|
242
|
+
children: [
|
|
243
|
+
n ? /* @__PURE__ */ c("span", { className: "h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent" }) : r,
|
|
244
|
+
/* @__PURE__ */ c("span", {
|
|
245
|
+
className: y(e === "ghost" && "bg-gradient-to-r from-muted via-content to-muted bg-[length:200%_100%] bg-clip-text group-hover:text-transparent group-hover:[animation:text-shimmer_1.2s_linear_1_forwards]"),
|
|
246
|
+
children: o
|
|
247
|
+
}),
|
|
248
|
+
!n && i
|
|
249
|
+
]
|
|
250
|
+
})]
|
|
251
|
+
}), E = {
|
|
252
|
+
ghost: "text-muted hover:bg-surface-2 hover:text-content",
|
|
253
|
+
surface: "bg-surface-2 text-muted border border-border hover:text-content",
|
|
254
|
+
solid: "bg-primary text-primary-contrast hover:bg-primary-hover"
|
|
255
|
+
}, D = {
|
|
256
|
+
sm: "h-7 w-7",
|
|
257
|
+
md: "h-9 w-9"
|
|
258
|
+
}, O = ({ variant: e = "ghost", size: t = "md", className: n, children: r, ...i }) => /* @__PURE__ */ c("button", {
|
|
259
|
+
className: y("inline-flex items-center justify-center rounded-lg transition-colors duration-150", "focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/60", "disabled:opacity-50 disabled:cursor-not-allowed", E[e], D[t], n),
|
|
260
|
+
...i,
|
|
261
|
+
children: r
|
|
262
|
+
});
|
|
263
|
+
//#endregion
|
|
264
|
+
//#region src/lib/clipboard.ts
|
|
265
|
+
async function k(e) {
|
|
266
|
+
try {
|
|
267
|
+
if (navigator.clipboard && window.isSecureContext) try {
|
|
268
|
+
return await navigator.clipboard.writeText(e), !0;
|
|
269
|
+
} catch (e) {
|
|
270
|
+
console.warn("Clipboard API failed, trying fallback:", e);
|
|
271
|
+
}
|
|
272
|
+
let t = document.createElement("textarea");
|
|
273
|
+
t.value = e, t.style.position = "fixed", t.style.left = "-999999px", t.style.top = "-999999px", t.style.opacity = "0", t.setAttribute("readonly", ""), document.body.appendChild(t), t.focus(), t.select(), t.setSelectionRange(0, t.value.length);
|
|
274
|
+
try {
|
|
275
|
+
let e = document.execCommand("copy");
|
|
276
|
+
return document.body.removeChild(t), e;
|
|
277
|
+
} catch (e) {
|
|
278
|
+
return console.error("execCommand copy failed:", e), document.body.removeChild(t), !1;
|
|
279
|
+
}
|
|
280
|
+
} catch (e) {
|
|
281
|
+
return console.error("Failed to copy text:", e), !1;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
function A(t = 2e3) {
|
|
285
|
+
let [n, r] = e.useState(!1), i = e.useRef(null);
|
|
286
|
+
return e.useEffect(() => () => {
|
|
287
|
+
i.current && clearTimeout(i.current);
|
|
288
|
+
}, []), {
|
|
289
|
+
copy: async (e) => {
|
|
290
|
+
let n = await k(e);
|
|
291
|
+
return n && (r(!0), i.current && clearTimeout(i.current), i.current = window.setTimeout(() => {
|
|
292
|
+
r(!1);
|
|
293
|
+
}, t)), n;
|
|
294
|
+
},
|
|
295
|
+
copied: n
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
//#endregion
|
|
299
|
+
//#region src/components/ui/CopyButton.tsx
|
|
300
|
+
var j = ({ value: e, variant: t = "surface", size: n = "md", className: r, label: i = "Copy to clipboard" }) => {
|
|
301
|
+
let { copy: a, copied: o } = A(), s = n === "sm" ? 14 : 16;
|
|
302
|
+
return /* @__PURE__ */ c(O, {
|
|
303
|
+
"aria-label": o ? "Copied" : i,
|
|
304
|
+
variant: t,
|
|
305
|
+
size: n,
|
|
306
|
+
className: r,
|
|
307
|
+
onClick: () => a(e),
|
|
308
|
+
children: o ? /* @__PURE__ */ c(x, {
|
|
309
|
+
name: "check",
|
|
310
|
+
size: s,
|
|
311
|
+
className: "text-green-500"
|
|
312
|
+
}) : /* @__PURE__ */ c(x, {
|
|
313
|
+
name: "copy",
|
|
314
|
+
size: s
|
|
315
|
+
})
|
|
316
|
+
});
|
|
317
|
+
}, M = {
|
|
318
|
+
neutral: "bg-surface-2 text-muted border border-border",
|
|
319
|
+
primary: "bg-primary-soft text-primary border border-primary/30",
|
|
320
|
+
success: "bg-[#52b788]/15 text-[#52b788] border border-[#52b788]/25",
|
|
321
|
+
error: "bg-[#4A0F0F] text-[#FC7070] border border-[#FC7070]/20",
|
|
322
|
+
warning: "bg-amber-500/15 text-amber-500 border border-amber-500/30",
|
|
323
|
+
info: "bg-sky-500/15 text-sky-400 border border-sky-500/30"
|
|
324
|
+
}, N = ({ tone: e = "neutral", className: t, children: n }) => /* @__PURE__ */ c("span", {
|
|
325
|
+
className: y("inline-flex items-center gap-1 rounded-md px-2 py-0.5 text-xs font-heading font-[550]", M[e], t),
|
|
326
|
+
children: n
|
|
327
|
+
}), P = {
|
|
328
|
+
GET: "success",
|
|
329
|
+
POST: "info",
|
|
330
|
+
PUT: "warning",
|
|
331
|
+
PATCH: "primary",
|
|
332
|
+
DELETE: "error"
|
|
333
|
+
}, F = ({ method: e, className: t }) => /* @__PURE__ */ c(N, {
|
|
334
|
+
tone: P[e],
|
|
335
|
+
className: t,
|
|
336
|
+
children: e
|
|
337
|
+
}), I = ({ status: e, statusText: t, className: n }) => /* @__PURE__ */ l(N, {
|
|
338
|
+
tone: e >= 200 && e < 300 ? "success" : e >= 300 && e < 400 ? "warning" : "error",
|
|
339
|
+
className: n,
|
|
340
|
+
children: [
|
|
341
|
+
e,
|
|
342
|
+
" ",
|
|
343
|
+
t
|
|
344
|
+
]
|
|
345
|
+
}), L = {
|
|
346
|
+
sm: "h-4 w-4 rounded",
|
|
347
|
+
md: "h-5 w-5 rounded-md"
|
|
348
|
+
}, R = {
|
|
349
|
+
sm: "h-3 w-3",
|
|
350
|
+
md: "h-3.5 w-3.5"
|
|
351
|
+
}, ee = {
|
|
352
|
+
sm: "text-xs",
|
|
353
|
+
md: "text-sm"
|
|
354
|
+
}, te = ({ checked: e, onChange: t, label: n, disabled: r, size: i = "md", className: a, "aria-label": o }) => {
|
|
355
|
+
let s = /* @__PURE__ */ c("button", {
|
|
356
|
+
type: "button",
|
|
357
|
+
role: "checkbox",
|
|
358
|
+
"aria-checked": e,
|
|
359
|
+
"aria-label": o ?? n,
|
|
360
|
+
disabled: r,
|
|
361
|
+
onClick: () => t(!e),
|
|
362
|
+
className: y("inline-flex shrink-0 items-center justify-center border transition-colors duration-150", "focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/60", "disabled:cursor-not-allowed disabled:opacity-50", L[i], e ? "border-primary bg-primary text-primary-contrast" : "border-border bg-surface-2 text-transparent hover:border-primary/70"),
|
|
363
|
+
children: /* @__PURE__ */ c(x, {
|
|
364
|
+
name: "check",
|
|
365
|
+
className: R[i]
|
|
366
|
+
})
|
|
367
|
+
});
|
|
368
|
+
return n ? /* @__PURE__ */ l("label", {
|
|
369
|
+
className: y("inline-flex cursor-pointer select-none items-center gap-2", a),
|
|
370
|
+
children: [s, /* @__PURE__ */ c("span", {
|
|
371
|
+
className: y("text-content", ee[i]),
|
|
372
|
+
children: n
|
|
373
|
+
})]
|
|
374
|
+
}) : /* @__PURE__ */ c("span", {
|
|
375
|
+
className: a,
|
|
376
|
+
children: s
|
|
377
|
+
});
|
|
378
|
+
}, z = ({ label: e, flush: t, className: n, children: r }) => /* @__PURE__ */ l("div", {
|
|
379
|
+
className: "w-full",
|
|
380
|
+
children: [e && /* @__PURE__ */ c("div", {
|
|
381
|
+
className: "mb-2 text-sm text-muted",
|
|
382
|
+
children: e
|
|
383
|
+
}), /* @__PURE__ */ c("div", {
|
|
384
|
+
className: y("rounded-xl border border-border bg-surface", !t && "p-3", n),
|
|
385
|
+
children: r
|
|
386
|
+
})]
|
|
387
|
+
}), B = ({ items: e, activeId: n, onChange: i, variant: s = "underline", size: u = "md", className: d }) => {
|
|
388
|
+
let f = a({}), [p, m] = o({
|
|
389
|
+
left: 0,
|
|
390
|
+
top: 0,
|
|
391
|
+
width: 0,
|
|
392
|
+
height: 0
|
|
393
|
+
});
|
|
394
|
+
return r(() => {
|
|
395
|
+
let e = f.current[n];
|
|
396
|
+
e && m({
|
|
397
|
+
left: e.offsetLeft,
|
|
398
|
+
top: e.offsetTop,
|
|
399
|
+
width: e.offsetWidth,
|
|
400
|
+
height: e.offsetHeight
|
|
401
|
+
});
|
|
402
|
+
}, [n, e]), t(() => {
|
|
403
|
+
let e = () => {
|
|
404
|
+
let e = f.current[n];
|
|
405
|
+
e && m({
|
|
406
|
+
left: e.offsetLeft,
|
|
407
|
+
top: e.offsetTop,
|
|
408
|
+
width: e.offsetWidth,
|
|
409
|
+
height: e.offsetHeight
|
|
410
|
+
});
|
|
411
|
+
};
|
|
412
|
+
return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
413
|
+
}, [n]), s === "segmented" ? /* @__PURE__ */ l("div", {
|
|
414
|
+
className: y("relative inline-flex gap-1 rounded-lg border border-border bg-surface-2 p-1", d),
|
|
415
|
+
children: [/* @__PURE__ */ c("span", {
|
|
416
|
+
className: "pointer-events-none absolute z-0 rounded-md bg-primary transition-all duration-300 ease-out",
|
|
417
|
+
style: {
|
|
418
|
+
left: p.left,
|
|
419
|
+
top: p.top,
|
|
420
|
+
width: p.width,
|
|
421
|
+
height: p.height
|
|
422
|
+
}
|
|
423
|
+
}), e.map((e) => {
|
|
424
|
+
let t = e.id === n;
|
|
425
|
+
return /* @__PURE__ */ c("button", {
|
|
426
|
+
ref: (t) => {
|
|
427
|
+
f.current[e.id] = t;
|
|
428
|
+
},
|
|
429
|
+
onClick: () => i(e.id),
|
|
430
|
+
className: y("group/seg relative z-10 cursor-pointer rounded-md font-heading transition-colors duration-150", u === "sm" ? "px-2.5 py-1 text-[12px]" : "px-3 py-1.5 text-[14px]", t ? "text-primary-contrast" : "text-muted"),
|
|
431
|
+
children: /* @__PURE__ */ l("span", {
|
|
432
|
+
className: y("relative z-10", !t && "bg-gradient-to-r from-muted via-content to-muted bg-[length:200%_100%] bg-clip-text group-hover/seg:text-transparent group-hover/seg:[animation:text-shimmer_1.2s_linear_1_forwards]"),
|
|
433
|
+
children: [e.label, e.badge !== void 0 && /* @__PURE__ */ c("span", {
|
|
434
|
+
className: "ml-1.5 opacity-70",
|
|
435
|
+
children: e.badge
|
|
436
|
+
})]
|
|
437
|
+
})
|
|
438
|
+
}, e.id);
|
|
439
|
+
})]
|
|
440
|
+
}) : /* @__PURE__ */ l("div", {
|
|
441
|
+
className: y("relative flex gap-1 border-b border-border", d),
|
|
442
|
+
children: [e.map((e) => {
|
|
443
|
+
let t = e.id === n;
|
|
444
|
+
return /* @__PURE__ */ l("button", {
|
|
445
|
+
ref: (t) => {
|
|
446
|
+
f.current[e.id] = t;
|
|
447
|
+
},
|
|
448
|
+
onClick: () => i(e.id),
|
|
449
|
+
className: y("inline-flex cursor-pointer items-center gap-1.5 font-heading transition-colors duration-150", u === "sm" ? "px-2 py-2 text-[12px]" : "px-3 py-2.5 text-[14px]", t ? "text-content" : "text-muted hover:text-content"),
|
|
450
|
+
children: [e.label, e.badge !== void 0 && /* @__PURE__ */ c("span", {
|
|
451
|
+
className: "text-xs text-muted",
|
|
452
|
+
children: e.badge
|
|
453
|
+
})]
|
|
454
|
+
}, e.id);
|
|
455
|
+
}), /* @__PURE__ */ c("span", {
|
|
456
|
+
className: "pointer-events-none absolute -bottom-px h-0.5 rounded-full bg-primary transition-all duration-300 ease-out",
|
|
457
|
+
style: {
|
|
458
|
+
left: p.left,
|
|
459
|
+
width: p.width
|
|
460
|
+
}
|
|
461
|
+
})]
|
|
462
|
+
});
|
|
463
|
+
}, ne = {
|
|
464
|
+
sm: "gap-1.5 rounded-md px-2.5",
|
|
465
|
+
md: "gap-2 rounded-lg px-3",
|
|
466
|
+
lg: "gap-2.5 rounded-lg px-4"
|
|
467
|
+
}, re = {
|
|
468
|
+
sm: "py-1.5 text-[12px]",
|
|
469
|
+
md: "py-2 text-sm",
|
|
470
|
+
lg: "py-2.5 text-base"
|
|
471
|
+
}, ie = {
|
|
472
|
+
sm: "mb-1 text-xs",
|
|
473
|
+
md: "mb-1.5 text-sm",
|
|
474
|
+
lg: "mb-2 text-sm"
|
|
475
|
+
}, ae = {
|
|
476
|
+
sm: "mt-1 text-[11px]",
|
|
477
|
+
md: "mt-1 text-xs",
|
|
478
|
+
lg: "mt-1.5 text-xs"
|
|
479
|
+
}, V = ({ label: e, error: t, hint: r, size: i = "md", leftSlot: a, rightSlot: o, className: s, containerClassName: u, id: d, ...f }) => {
|
|
480
|
+
let p = n(), m = d ?? p;
|
|
481
|
+
return /* @__PURE__ */ l("div", {
|
|
482
|
+
className: y("w-full", u),
|
|
483
|
+
children: [
|
|
484
|
+
e && /* @__PURE__ */ c("label", {
|
|
485
|
+
htmlFor: m,
|
|
486
|
+
className: y("block font-medium text-muted", ie[i]),
|
|
487
|
+
children: e
|
|
488
|
+
}),
|
|
489
|
+
/* @__PURE__ */ l("div", {
|
|
490
|
+
className: y("flex items-center border bg-surface-2", "focus-within:border-primary/70 focus-within:ring-2 focus-within:ring-primary/15", ne[i], t ? "border-red-500" : "border-border"),
|
|
491
|
+
children: [
|
|
492
|
+
a,
|
|
493
|
+
/* @__PURE__ */ c("input", {
|
|
494
|
+
id: m,
|
|
495
|
+
className: y("w-full bg-transparent text-content placeholder:text-muted", "focus:outline-none disabled:cursor-not-allowed disabled:opacity-60", re[i], s),
|
|
496
|
+
...f
|
|
497
|
+
}),
|
|
498
|
+
o
|
|
499
|
+
]
|
|
500
|
+
}),
|
|
501
|
+
t ? /* @__PURE__ */ c("p", {
|
|
502
|
+
className: y("text-red-500", ae[i]),
|
|
503
|
+
children: t
|
|
504
|
+
}) : r ? /* @__PURE__ */ c("p", {
|
|
505
|
+
className: y("text-muted", ae[i]),
|
|
506
|
+
children: r
|
|
507
|
+
}) : null
|
|
508
|
+
]
|
|
509
|
+
});
|
|
510
|
+
}, oe = {
|
|
511
|
+
sm: "gap-1.5 px-2.5 py-1.5 text-[12px]",
|
|
512
|
+
md: "gap-1 px-2 py-1.5 text-[14px]"
|
|
513
|
+
}, se = {
|
|
514
|
+
sm: "px-2.5 py-1.5 text-[12px]",
|
|
515
|
+
md: "px-3 py-1.5 text-[14px]"
|
|
516
|
+
};
|
|
517
|
+
function ce({ items: e, value: n, onChange: r, size: i = "md", disabled: s, minWidthClassName: u = "min-w-[7rem]", className: d }) {
|
|
518
|
+
let [f, p] = o(!1), [m, h] = o(!1), g = a(null), _ = e.find((e) => e.id === n) ?? e[0];
|
|
519
|
+
t(() => {
|
|
520
|
+
if (f) {
|
|
521
|
+
h(!0);
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
let e = window.setTimeout(() => h(!1), 200);
|
|
525
|
+
return () => window.clearTimeout(e);
|
|
526
|
+
}, [f]), t(() => {
|
|
527
|
+
if (!f) return;
|
|
528
|
+
let e = (e) => {
|
|
529
|
+
g.current && !g.current.contains(e.target) && p(!1);
|
|
530
|
+
}, t = (e) => {
|
|
531
|
+
e.key === "Escape" && p(!1);
|
|
532
|
+
};
|
|
533
|
+
return document.addEventListener("mousedown", e), document.addEventListener("keydown", t), () => {
|
|
534
|
+
document.removeEventListener("mousedown", e), document.removeEventListener("keydown", t);
|
|
535
|
+
};
|
|
536
|
+
}, [f]);
|
|
537
|
+
let v = (e) => {
|
|
538
|
+
s || (r(e), p(!1));
|
|
539
|
+
};
|
|
540
|
+
return /* @__PURE__ */ l("div", {
|
|
541
|
+
ref: g,
|
|
542
|
+
className: y("relative inline-flex", d),
|
|
543
|
+
children: [/* @__PURE__ */ l("button", {
|
|
544
|
+
type: "button",
|
|
545
|
+
"aria-haspopup": "listbox",
|
|
546
|
+
"aria-expanded": f,
|
|
547
|
+
disabled: s,
|
|
548
|
+
onClick: () => p((e) => !e),
|
|
549
|
+
className: y("inline-flex cursor-pointer items-center rounded-md font-heading transition-colors duration-150", "focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/60", "disabled:cursor-not-allowed disabled:opacity-60", oe[i], _?.className ?? "text-content hover:bg-surface-2"),
|
|
550
|
+
children: [_?.label, /* @__PURE__ */ c(x, {
|
|
551
|
+
name: "chevron-down",
|
|
552
|
+
className: y("h-4 w-4 text-muted transition-transform duration-200", f && "rotate-180")
|
|
553
|
+
})]
|
|
554
|
+
}), m && /* @__PURE__ */ c("div", {
|
|
555
|
+
className: y("absolute left-0 top-full z-20 mt-1 grid overflow-hidden rounded-lg border border-border bg-surface shadow-lg [grid-template-rows:1fr]", u, f ? "motion-safe:animate-[dropdown-expand_0.2s_ease-out]" : "motion-safe:animate-[dropdown-expand_0.18s_ease-in_reverse_forwards]"),
|
|
556
|
+
children: /* @__PURE__ */ c("ul", {
|
|
557
|
+
role: "listbox",
|
|
558
|
+
className: "min-h-0 overflow-hidden p-1",
|
|
559
|
+
children: e.map((e) => {
|
|
560
|
+
let t = e.id === n;
|
|
561
|
+
return /* @__PURE__ */ c("li", {
|
|
562
|
+
role: "option",
|
|
563
|
+
"aria-selected": t,
|
|
564
|
+
children: /* @__PURE__ */ l("button", {
|
|
565
|
+
type: "button",
|
|
566
|
+
onClick: () => v(e.id),
|
|
567
|
+
className: y("flex w-full cursor-pointer items-center justify-between rounded-md font-heading transition-colors duration-150 hover:bg-surface-2", se[i], e.className ?? "text-muted hover:text-content", t && "bg-surface-2"),
|
|
568
|
+
children: [e.label, t && /* @__PURE__ */ c(x, {
|
|
569
|
+
name: "check",
|
|
570
|
+
className: "h-4 w-4"
|
|
571
|
+
})]
|
|
572
|
+
})
|
|
573
|
+
}, e.id);
|
|
574
|
+
})
|
|
575
|
+
})
|
|
576
|
+
})]
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
//#endregion
|
|
580
|
+
//#region src/components/ui/MethodSelect.tsx
|
|
581
|
+
var le = [
|
|
582
|
+
"GET",
|
|
583
|
+
"POST",
|
|
584
|
+
"PUT",
|
|
585
|
+
"PATCH",
|
|
586
|
+
"DELETE"
|
|
587
|
+
], ue = {
|
|
588
|
+
GET: "text-[#52b788]",
|
|
589
|
+
POST: "text-sky-400",
|
|
590
|
+
PUT: "text-amber-400",
|
|
591
|
+
PATCH: "text-primary",
|
|
592
|
+
DELETE: "text-red-400"
|
|
593
|
+
}, de = (e) => e.map((e) => ({
|
|
594
|
+
id: e,
|
|
595
|
+
label: e,
|
|
596
|
+
className: `${ue[e]} font-semibold`
|
|
597
|
+
})), fe = ({ value: e, onChange: t, methods: n = le, disabled: r, className: i }) => /* @__PURE__ */ c(ce, {
|
|
598
|
+
value: e,
|
|
599
|
+
onChange: t,
|
|
600
|
+
items: de(n),
|
|
601
|
+
disabled: r,
|
|
602
|
+
minWidthClassName: "min-w-[7rem]",
|
|
603
|
+
className: i
|
|
604
|
+
}), pe = /* @__PURE__ */ g(((e, t) => {
|
|
605
|
+
var n = function(e) {
|
|
606
|
+
var t = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i, n = 0, r = {}, i = {
|
|
607
|
+
manual: e.Prism && e.Prism.manual,
|
|
608
|
+
disableWorkerMessageHandler: e.Prism && e.Prism.disableWorkerMessageHandler,
|
|
609
|
+
util: {
|
|
610
|
+
encode: function e(t) {
|
|
611
|
+
return t instanceof a ? new a(t.type, e(t.content), t.alias) : Array.isArray(t) ? t.map(e) : t.replace(/&/g, "&").replace(/</g, "<").replace(/\u00a0/g, " ");
|
|
612
|
+
},
|
|
613
|
+
type: function(e) {
|
|
614
|
+
return Object.prototype.toString.call(e).slice(8, -1);
|
|
615
|
+
},
|
|
616
|
+
objId: function(e) {
|
|
617
|
+
return e.__id || Object.defineProperty(e, "__id", { value: ++n }), e.__id;
|
|
618
|
+
},
|
|
619
|
+
clone: function e(t, n) {
|
|
620
|
+
n ||= {};
|
|
621
|
+
var r, a;
|
|
622
|
+
switch (i.util.type(t)) {
|
|
623
|
+
case "Object":
|
|
624
|
+
if (a = i.util.objId(t), n[a]) return n[a];
|
|
625
|
+
for (var o in r = {}, n[a] = r, t) t.hasOwnProperty(o) && (r[o] = e(t[o], n));
|
|
626
|
+
return r;
|
|
627
|
+
case "Array": return a = i.util.objId(t), n[a] ? n[a] : (r = [], n[a] = r, t.forEach(function(t, i) {
|
|
628
|
+
r[i] = e(t, n);
|
|
629
|
+
}), r);
|
|
630
|
+
default: return t;
|
|
631
|
+
}
|
|
632
|
+
},
|
|
633
|
+
getLanguage: function(e) {
|
|
634
|
+
for (; e;) {
|
|
635
|
+
var n = t.exec(e.className);
|
|
636
|
+
if (n) return n[1].toLowerCase();
|
|
637
|
+
e = e.parentElement;
|
|
638
|
+
}
|
|
639
|
+
return "none";
|
|
640
|
+
},
|
|
641
|
+
setLanguage: function(e, n) {
|
|
642
|
+
e.className = e.className.replace(RegExp(t, "gi"), ""), e.classList.add("language-" + n);
|
|
643
|
+
},
|
|
644
|
+
currentScript: function() {
|
|
645
|
+
if (typeof document > "u") return null;
|
|
646
|
+
if (document.currentScript && document.currentScript.tagName === "SCRIPT") return document.currentScript;
|
|
647
|
+
try {
|
|
648
|
+
throw Error();
|
|
649
|
+
} catch (r) {
|
|
650
|
+
var e = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(r.stack) || [])[1];
|
|
651
|
+
if (e) {
|
|
652
|
+
var t = document.getElementsByTagName("script");
|
|
653
|
+
for (var n in t) if (t[n].src == e) return t[n];
|
|
654
|
+
}
|
|
655
|
+
return null;
|
|
656
|
+
}
|
|
657
|
+
},
|
|
658
|
+
isActive: function(e, t, n) {
|
|
659
|
+
for (var r = "no-" + t; e;) {
|
|
660
|
+
var i = e.classList;
|
|
661
|
+
if (i.contains(t)) return !0;
|
|
662
|
+
if (i.contains(r)) return !1;
|
|
663
|
+
e = e.parentElement;
|
|
664
|
+
}
|
|
665
|
+
return !!n;
|
|
666
|
+
}
|
|
667
|
+
},
|
|
668
|
+
languages: {
|
|
669
|
+
plain: r,
|
|
670
|
+
plaintext: r,
|
|
671
|
+
text: r,
|
|
672
|
+
txt: r,
|
|
673
|
+
extend: function(e, t) {
|
|
674
|
+
var n = i.util.clone(i.languages[e]);
|
|
675
|
+
for (var r in t) n[r] = t[r];
|
|
676
|
+
return n;
|
|
677
|
+
},
|
|
678
|
+
insertBefore: function(e, t, n, r) {
|
|
679
|
+
r ||= i.languages;
|
|
680
|
+
var a = r[e], o = {};
|
|
681
|
+
for (var s in a) if (a.hasOwnProperty(s)) {
|
|
682
|
+
if (s == t) for (var c in n) n.hasOwnProperty(c) && (o[c] = n[c]);
|
|
683
|
+
n.hasOwnProperty(s) || (o[s] = a[s]);
|
|
684
|
+
}
|
|
685
|
+
var l = r[e];
|
|
686
|
+
return r[e] = o, i.languages.DFS(i.languages, function(t, n) {
|
|
687
|
+
n === l && t != e && (this[t] = o);
|
|
688
|
+
}), o;
|
|
689
|
+
},
|
|
690
|
+
DFS: function e(t, n, r, a) {
|
|
691
|
+
a ||= {};
|
|
692
|
+
var o = i.util.objId;
|
|
693
|
+
for (var s in t) if (t.hasOwnProperty(s)) {
|
|
694
|
+
n.call(t, s, t[s], r || s);
|
|
695
|
+
var c = t[s], l = i.util.type(c);
|
|
696
|
+
l === "Object" && !a[o(c)] ? (a[o(c)] = !0, e(c, n, null, a)) : l === "Array" && !a[o(c)] && (a[o(c)] = !0, e(c, n, s, a));
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
},
|
|
700
|
+
plugins: {},
|
|
701
|
+
highlightAll: function(e, t) {
|
|
702
|
+
i.highlightAllUnder(document, e, t);
|
|
703
|
+
},
|
|
704
|
+
highlightAllUnder: function(e, t, n) {
|
|
705
|
+
var r = {
|
|
706
|
+
callback: n,
|
|
707
|
+
container: e,
|
|
708
|
+
selector: "code[class*=\"language-\"], [class*=\"language-\"] code, code[class*=\"lang-\"], [class*=\"lang-\"] code"
|
|
709
|
+
};
|
|
710
|
+
i.hooks.run("before-highlightall", r), r.elements = Array.prototype.slice.apply(r.container.querySelectorAll(r.selector)), i.hooks.run("before-all-elements-highlight", r);
|
|
711
|
+
for (var a = 0, o; o = r.elements[a++];) i.highlightElement(o, t === !0, r.callback);
|
|
712
|
+
},
|
|
713
|
+
highlightElement: function(t, n, r) {
|
|
714
|
+
var a = i.util.getLanguage(t), o = i.languages[a];
|
|
715
|
+
i.util.setLanguage(t, a);
|
|
716
|
+
var s = t.parentElement;
|
|
717
|
+
s && s.nodeName.toLowerCase() === "pre" && i.util.setLanguage(s, a);
|
|
718
|
+
var c = {
|
|
719
|
+
element: t,
|
|
720
|
+
language: a,
|
|
721
|
+
grammar: o,
|
|
722
|
+
code: t.textContent
|
|
723
|
+
};
|
|
724
|
+
function l(e) {
|
|
725
|
+
c.highlightedCode = e, i.hooks.run("before-insert", c), c.element.innerHTML = c.highlightedCode, i.hooks.run("after-highlight", c), i.hooks.run("complete", c), r && r.call(c.element);
|
|
726
|
+
}
|
|
727
|
+
if (i.hooks.run("before-sanity-check", c), s = c.element.parentElement, s && s.nodeName.toLowerCase() === "pre" && !s.hasAttribute("tabindex") && s.setAttribute("tabindex", "0"), !c.code) {
|
|
728
|
+
i.hooks.run("complete", c), r && r.call(c.element);
|
|
729
|
+
return;
|
|
730
|
+
}
|
|
731
|
+
if (i.hooks.run("before-highlight", c), !c.grammar) {
|
|
732
|
+
l(i.util.encode(c.code));
|
|
733
|
+
return;
|
|
734
|
+
}
|
|
735
|
+
if (n && e.Worker) {
|
|
736
|
+
var u = new Worker(i.filename);
|
|
737
|
+
u.onmessage = function(e) {
|
|
738
|
+
l(e.data);
|
|
739
|
+
}, u.postMessage(JSON.stringify({
|
|
740
|
+
language: c.language,
|
|
741
|
+
code: c.code,
|
|
742
|
+
immediateClose: !0
|
|
743
|
+
}));
|
|
744
|
+
} else l(i.highlight(c.code, c.grammar, c.language));
|
|
745
|
+
},
|
|
746
|
+
highlight: function(e, t, n) {
|
|
747
|
+
var r = {
|
|
748
|
+
code: e,
|
|
749
|
+
grammar: t,
|
|
750
|
+
language: n
|
|
751
|
+
};
|
|
752
|
+
if (i.hooks.run("before-tokenize", r), !r.grammar) throw Error("The language \"" + r.language + "\" has no grammar.");
|
|
753
|
+
return r.tokens = i.tokenize(r.code, r.grammar), i.hooks.run("after-tokenize", r), a.stringify(i.util.encode(r.tokens), r.language);
|
|
754
|
+
},
|
|
755
|
+
tokenize: function(e, t) {
|
|
756
|
+
var n = t.rest;
|
|
757
|
+
if (n) {
|
|
758
|
+
for (var r in n) t[r] = n[r];
|
|
759
|
+
delete t.rest;
|
|
760
|
+
}
|
|
761
|
+
var i = new c();
|
|
762
|
+
return l(i, i.head, e), s(e, i, t, i.head, 0), d(i);
|
|
763
|
+
},
|
|
764
|
+
hooks: {
|
|
765
|
+
all: {},
|
|
766
|
+
add: function(e, t) {
|
|
767
|
+
var n = i.hooks.all;
|
|
768
|
+
n[e] = n[e] || [], n[e].push(t);
|
|
769
|
+
},
|
|
770
|
+
run: function(e, t) {
|
|
771
|
+
var n = i.hooks.all[e];
|
|
772
|
+
if (!(!n || !n.length)) for (var r = 0, a; a = n[r++];) a(t);
|
|
773
|
+
}
|
|
774
|
+
},
|
|
775
|
+
Token: a
|
|
776
|
+
};
|
|
777
|
+
e.Prism = i;
|
|
778
|
+
function a(e, t, n, r) {
|
|
779
|
+
this.type = e, this.content = t, this.alias = n, this.length = (r || "").length | 0;
|
|
780
|
+
}
|
|
781
|
+
a.stringify = function e(t, n) {
|
|
782
|
+
if (typeof t == "string") return t;
|
|
783
|
+
if (Array.isArray(t)) {
|
|
784
|
+
var r = "";
|
|
785
|
+
return t.forEach(function(t) {
|
|
786
|
+
r += e(t, n);
|
|
787
|
+
}), r;
|
|
788
|
+
}
|
|
789
|
+
var a = {
|
|
790
|
+
type: t.type,
|
|
791
|
+
content: e(t.content, n),
|
|
792
|
+
tag: "span",
|
|
793
|
+
classes: ["token", t.type],
|
|
794
|
+
attributes: {},
|
|
795
|
+
language: n
|
|
796
|
+
}, o = t.alias;
|
|
797
|
+
o && (Array.isArray(o) ? Array.prototype.push.apply(a.classes, o) : a.classes.push(o)), i.hooks.run("wrap", a);
|
|
798
|
+
var s = "";
|
|
799
|
+
for (var c in a.attributes) s += " " + c + "=\"" + (a.attributes[c] || "").replace(/"/g, """) + "\"";
|
|
800
|
+
return "<" + a.tag + " class=\"" + a.classes.join(" ") + "\"" + s + ">" + a.content + "</" + a.tag + ">";
|
|
801
|
+
};
|
|
802
|
+
function o(e, t, n, r) {
|
|
803
|
+
e.lastIndex = t;
|
|
804
|
+
var i = e.exec(n);
|
|
805
|
+
if (i && r && i[1]) {
|
|
806
|
+
var a = i[1].length;
|
|
807
|
+
i.index += a, i[0] = i[0].slice(a);
|
|
808
|
+
}
|
|
809
|
+
return i;
|
|
810
|
+
}
|
|
811
|
+
function s(e, t, n, r, c, d) {
|
|
812
|
+
for (var f in n) if (!(!n.hasOwnProperty(f) || !n[f])) {
|
|
813
|
+
var p = n[f];
|
|
814
|
+
p = Array.isArray(p) ? p : [p];
|
|
815
|
+
for (var m = 0; m < p.length; ++m) {
|
|
816
|
+
if (d && d.cause == f + "," + m) return;
|
|
817
|
+
var h = p[m], g = h.inside, _ = !!h.lookbehind, v = !!h.greedy, y = h.alias;
|
|
818
|
+
if (v && !h.pattern.global) {
|
|
819
|
+
var b = h.pattern.toString().match(/[imsuy]*$/)[0];
|
|
820
|
+
h.pattern = RegExp(h.pattern.source, b + "g");
|
|
821
|
+
}
|
|
822
|
+
for (var x = h.pattern || h, S = r.next, C = c; S !== t.tail && !(d && C >= d.reach); C += S.value.length, S = S.next) {
|
|
823
|
+
var w = S.value;
|
|
824
|
+
if (t.length > e.length) return;
|
|
825
|
+
if (!(w instanceof a)) {
|
|
826
|
+
var T = 1, E;
|
|
827
|
+
if (v) {
|
|
828
|
+
if (E = o(x, C, e, _), !E || E.index >= e.length) break;
|
|
829
|
+
var D = E.index, O = E.index + E[0].length, k = C;
|
|
830
|
+
for (k += S.value.length; D >= k;) S = S.next, k += S.value.length;
|
|
831
|
+
if (k -= S.value.length, C = k, S.value instanceof a) continue;
|
|
832
|
+
for (var A = S; A !== t.tail && (k < O || typeof A.value == "string"); A = A.next) T++, k += A.value.length;
|
|
833
|
+
T--, w = e.slice(C, k), E.index -= C;
|
|
834
|
+
} else if (E = o(x, 0, w, _), !E) continue;
|
|
835
|
+
var D = E.index, j = E[0], M = w.slice(0, D), N = w.slice(D + j.length), P = C + w.length;
|
|
836
|
+
d && P > d.reach && (d.reach = P);
|
|
837
|
+
var F = S.prev;
|
|
838
|
+
M && (F = l(t, F, M), C += M.length), u(t, F, T);
|
|
839
|
+
var I = new a(f, g ? i.tokenize(j, g) : j, y, j);
|
|
840
|
+
if (S = l(t, F, I), N && l(t, S, N), T > 1) {
|
|
841
|
+
var L = {
|
|
842
|
+
cause: f + "," + m,
|
|
843
|
+
reach: P
|
|
844
|
+
};
|
|
845
|
+
s(e, t, n, S.prev, C, L), d && L.reach > d.reach && (d.reach = L.reach);
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
function c() {
|
|
853
|
+
var e = {
|
|
854
|
+
value: null,
|
|
855
|
+
prev: null,
|
|
856
|
+
next: null
|
|
857
|
+
}, t = {
|
|
858
|
+
value: null,
|
|
859
|
+
prev: e,
|
|
860
|
+
next: null
|
|
861
|
+
};
|
|
862
|
+
e.next = t, this.head = e, this.tail = t, this.length = 0;
|
|
863
|
+
}
|
|
864
|
+
function l(e, t, n) {
|
|
865
|
+
var r = t.next, i = {
|
|
866
|
+
value: n,
|
|
867
|
+
prev: t,
|
|
868
|
+
next: r
|
|
869
|
+
};
|
|
870
|
+
return t.next = i, r.prev = i, e.length++, i;
|
|
871
|
+
}
|
|
872
|
+
function u(e, t, n) {
|
|
873
|
+
for (var r = t.next, i = 0; i < n && r !== e.tail; i++) r = r.next;
|
|
874
|
+
t.next = r, r.prev = t, e.length -= i;
|
|
875
|
+
}
|
|
876
|
+
function d(e) {
|
|
877
|
+
for (var t = [], n = e.head.next; n !== e.tail;) t.push(n.value), n = n.next;
|
|
878
|
+
return t;
|
|
879
|
+
}
|
|
880
|
+
if (!e.document) return e.addEventListener && (i.disableWorkerMessageHandler || e.addEventListener("message", function(t) {
|
|
881
|
+
var n = JSON.parse(t.data), r = n.language, a = n.code, o = n.immediateClose;
|
|
882
|
+
e.postMessage(i.highlight(a, i.languages[r], r)), o && e.close();
|
|
883
|
+
}, !1)), i;
|
|
884
|
+
var f = i.util.currentScript();
|
|
885
|
+
f && (i.filename = f.src, f.hasAttribute("data-manual") && (i.manual = !0));
|
|
886
|
+
function p() {
|
|
887
|
+
i.manual || i.highlightAll();
|
|
888
|
+
}
|
|
889
|
+
if (!i.manual) {
|
|
890
|
+
var m = document.readyState;
|
|
891
|
+
m === "loading" || m === "interactive" && f && f.defer ? document.addEventListener("DOMContentLoaded", p) : window.requestAnimationFrame ? window.requestAnimationFrame(p) : window.setTimeout(p, 16);
|
|
892
|
+
}
|
|
893
|
+
return i;
|
|
894
|
+
}(typeof window < "u" ? window : typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope ? self : {});
|
|
895
|
+
t !== void 0 && t.exports && (t.exports = n), typeof global < "u" && (global.Prism = n), n.languages.markup = {
|
|
896
|
+
comment: {
|
|
897
|
+
pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
|
|
898
|
+
greedy: !0
|
|
899
|
+
},
|
|
900
|
+
prolog: {
|
|
901
|
+
pattern: /<\?[\s\S]+?\?>/,
|
|
902
|
+
greedy: !0
|
|
903
|
+
},
|
|
904
|
+
doctype: {
|
|
905
|
+
pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
|
|
906
|
+
greedy: !0,
|
|
907
|
+
inside: {
|
|
908
|
+
"internal-subset": {
|
|
909
|
+
pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/,
|
|
910
|
+
lookbehind: !0,
|
|
911
|
+
greedy: !0,
|
|
912
|
+
inside: null
|
|
913
|
+
},
|
|
914
|
+
string: {
|
|
915
|
+
pattern: /"[^"]*"|'[^']*'/,
|
|
916
|
+
greedy: !0
|
|
917
|
+
},
|
|
918
|
+
punctuation: /^<!|>$|[[\]]/,
|
|
919
|
+
"doctype-tag": /^DOCTYPE/i,
|
|
920
|
+
name: /[^\s<>'"]+/
|
|
921
|
+
}
|
|
922
|
+
},
|
|
923
|
+
cdata: {
|
|
924
|
+
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
|
|
925
|
+
greedy: !0
|
|
926
|
+
},
|
|
927
|
+
tag: {
|
|
928
|
+
pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
|
|
929
|
+
greedy: !0,
|
|
930
|
+
inside: {
|
|
931
|
+
tag: {
|
|
932
|
+
pattern: /^<\/?[^\s>\/]+/,
|
|
933
|
+
inside: {
|
|
934
|
+
punctuation: /^<\/?/,
|
|
935
|
+
namespace: /^[^\s>\/:]+:/
|
|
936
|
+
}
|
|
937
|
+
},
|
|
938
|
+
"special-attr": [],
|
|
939
|
+
"attr-value": {
|
|
940
|
+
pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
|
|
941
|
+
inside: { punctuation: [{
|
|
942
|
+
pattern: /^=/,
|
|
943
|
+
alias: "attr-equals"
|
|
944
|
+
}, {
|
|
945
|
+
pattern: /^(\s*)["']|["']$/,
|
|
946
|
+
lookbehind: !0
|
|
947
|
+
}] }
|
|
948
|
+
},
|
|
949
|
+
punctuation: /\/?>/,
|
|
950
|
+
"attr-name": {
|
|
951
|
+
pattern: /[^\s>\/]+/,
|
|
952
|
+
inside: { namespace: /^[^\s>\/:]+:/ }
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
},
|
|
956
|
+
entity: [{
|
|
957
|
+
pattern: /&[\da-z]{1,8};/i,
|
|
958
|
+
alias: "named-entity"
|
|
959
|
+
}, /&#x?[\da-f]{1,8};/i]
|
|
960
|
+
}, n.languages.markup.tag.inside["attr-value"].inside.entity = n.languages.markup.entity, n.languages.markup.doctype.inside["internal-subset"].inside = n.languages.markup, n.hooks.add("wrap", function(e) {
|
|
961
|
+
e.type === "entity" && (e.attributes.title = e.content.replace(/&/, "&"));
|
|
962
|
+
}), Object.defineProperty(n.languages.markup.tag, "addInlined", { value: function(e, t) {
|
|
963
|
+
var r = {};
|
|
964
|
+
r["language-" + t] = {
|
|
965
|
+
pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
|
|
966
|
+
lookbehind: !0,
|
|
967
|
+
inside: n.languages[t]
|
|
968
|
+
}, r.cdata = /^<!\[CDATA\[|\]\]>$/i;
|
|
969
|
+
var i = { "included-cdata": {
|
|
970
|
+
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
|
|
971
|
+
inside: r
|
|
972
|
+
} };
|
|
973
|
+
i["language-" + t] = {
|
|
974
|
+
pattern: /[\s\S]+/,
|
|
975
|
+
inside: n.languages[t]
|
|
976
|
+
};
|
|
977
|
+
var a = {};
|
|
978
|
+
a[e] = {
|
|
979
|
+
pattern: RegExp("(<__[^>]*>)(?:<!\\[CDATA\\[(?:[^\\]]|\\](?!\\]>))*\\]\\]>|(?!<!\\[CDATA\\[)[\\s\\S])*?(?=<\\/__>)".replace(/__/g, function() {
|
|
980
|
+
return e;
|
|
981
|
+
}), "i"),
|
|
982
|
+
lookbehind: !0,
|
|
983
|
+
greedy: !0,
|
|
984
|
+
inside: i
|
|
985
|
+
}, n.languages.insertBefore("markup", "cdata", a);
|
|
986
|
+
} }), Object.defineProperty(n.languages.markup.tag, "addAttribute", { value: function(e, t) {
|
|
987
|
+
n.languages.markup.tag.inside["special-attr"].push({
|
|
988
|
+
pattern: RegExp("(^|[\"'\\s])(?:" + e + ")\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^\\s'\">=]+(?=[\\s>]))", "i"),
|
|
989
|
+
lookbehind: !0,
|
|
990
|
+
inside: {
|
|
991
|
+
"attr-name": /^[^\s=]+/,
|
|
992
|
+
"attr-value": {
|
|
993
|
+
pattern: /=[\s\S]+/,
|
|
994
|
+
inside: {
|
|
995
|
+
value: {
|
|
996
|
+
pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
|
|
997
|
+
lookbehind: !0,
|
|
998
|
+
alias: [t, "language-" + t],
|
|
999
|
+
inside: n.languages[t]
|
|
1000
|
+
},
|
|
1001
|
+
punctuation: [{
|
|
1002
|
+
pattern: /^=/,
|
|
1003
|
+
alias: "attr-equals"
|
|
1004
|
+
}, /"|'/]
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
});
|
|
1009
|
+
} }), n.languages.html = n.languages.markup, n.languages.mathml = n.languages.markup, n.languages.svg = n.languages.markup, n.languages.xml = n.languages.extend("markup", {}), n.languages.ssml = n.languages.xml, n.languages.atom = n.languages.xml, n.languages.rss = n.languages.xml, (function(e) {
|
|
1010
|
+
var t = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
|
|
1011
|
+
e.languages.css = {
|
|
1012
|
+
comment: /\/\*[\s\S]*?\*\//,
|
|
1013
|
+
atrule: {
|
|
1014
|
+
pattern: RegExp("@[\\w-](?:[^;{\\s\"']|\\s+(?!\\s)|" + t.source + ")*?(?:;|(?=\\s*\\{))"),
|
|
1015
|
+
inside: {
|
|
1016
|
+
rule: /^@[\w-]+/,
|
|
1017
|
+
"selector-function-argument": {
|
|
1018
|
+
pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
|
|
1019
|
+
lookbehind: !0,
|
|
1020
|
+
alias: "selector"
|
|
1021
|
+
},
|
|
1022
|
+
keyword: {
|
|
1023
|
+
pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
|
|
1024
|
+
lookbehind: !0
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
},
|
|
1028
|
+
url: {
|
|
1029
|
+
pattern: RegExp("\\burl\\((?:" + t.source + "|(?:[^\\\\\\r\\n()\"']|\\\\[\\s\\S])*)\\)", "i"),
|
|
1030
|
+
greedy: !0,
|
|
1031
|
+
inside: {
|
|
1032
|
+
function: /^url/i,
|
|
1033
|
+
punctuation: /^\(|\)$/,
|
|
1034
|
+
string: {
|
|
1035
|
+
pattern: RegExp("^" + t.source + "$"),
|
|
1036
|
+
alias: "url"
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
},
|
|
1040
|
+
selector: {
|
|
1041
|
+
pattern: RegExp("(^|[{}\\s])[^{}\\s](?:[^{};\"'\\s]|\\s+(?![\\s{])|" + t.source + ")*(?=\\s*\\{)"),
|
|
1042
|
+
lookbehind: !0
|
|
1043
|
+
},
|
|
1044
|
+
string: {
|
|
1045
|
+
pattern: t,
|
|
1046
|
+
greedy: !0
|
|
1047
|
+
},
|
|
1048
|
+
property: {
|
|
1049
|
+
pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
|
|
1050
|
+
lookbehind: !0
|
|
1051
|
+
},
|
|
1052
|
+
important: /!important\b/i,
|
|
1053
|
+
function: {
|
|
1054
|
+
pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
|
|
1055
|
+
lookbehind: !0
|
|
1056
|
+
},
|
|
1057
|
+
punctuation: /[(){};:,]/
|
|
1058
|
+
}, e.languages.css.atrule.inside.rest = e.languages.css;
|
|
1059
|
+
var n = e.languages.markup;
|
|
1060
|
+
n && (n.tag.addInlined("style", "css"), n.tag.addAttribute("style", "css"));
|
|
1061
|
+
})(n), n.languages.clike = {
|
|
1062
|
+
comment: [{
|
|
1063
|
+
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
|
|
1064
|
+
lookbehind: !0,
|
|
1065
|
+
greedy: !0
|
|
1066
|
+
}, {
|
|
1067
|
+
pattern: /(^|[^\\:])\/\/.*/,
|
|
1068
|
+
lookbehind: !0,
|
|
1069
|
+
greedy: !0
|
|
1070
|
+
}],
|
|
1071
|
+
string: {
|
|
1072
|
+
pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
|
|
1073
|
+
greedy: !0
|
|
1074
|
+
},
|
|
1075
|
+
"class-name": {
|
|
1076
|
+
pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
|
|
1077
|
+
lookbehind: !0,
|
|
1078
|
+
inside: { punctuation: /[.\\]/ }
|
|
1079
|
+
},
|
|
1080
|
+
keyword: /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
|
|
1081
|
+
boolean: /\b(?:false|true)\b/,
|
|
1082
|
+
function: /\b\w+(?=\()/,
|
|
1083
|
+
number: /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
|
|
1084
|
+
operator: /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
|
|
1085
|
+
punctuation: /[{}[\];(),.:]/
|
|
1086
|
+
}, n.languages.javascript = n.languages.extend("clike", {
|
|
1087
|
+
"class-name": [n.languages.clike["class-name"], {
|
|
1088
|
+
pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
|
|
1089
|
+
lookbehind: !0
|
|
1090
|
+
}],
|
|
1091
|
+
keyword: [{
|
|
1092
|
+
pattern: /((?:^|\})\s*)catch\b/,
|
|
1093
|
+
lookbehind: !0
|
|
1094
|
+
}, {
|
|
1095
|
+
pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
|
|
1096
|
+
lookbehind: !0
|
|
1097
|
+
}],
|
|
1098
|
+
function: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
|
|
1099
|
+
number: {
|
|
1100
|
+
pattern: RegExp("(^|[^\\w$])(?:NaN|Infinity|0[bB][01]+(?:_[01]+)*n?|0[oO][0-7]+(?:_[0-7]+)*n?|0[xX][\\dA-Fa-f]+(?:_[\\dA-Fa-f]+)*n?|\\d+(?:_\\d+)*n|(?:\\d+(?:_\\d+)*(?:\\.(?:\\d+(?:_\\d+)*)?)?|\\.\\d+(?:_\\d+)*)(?:[Ee][+-]?\\d+(?:_\\d+)*)?)(?![\\w$])"),
|
|
1101
|
+
lookbehind: !0
|
|
1102
|
+
},
|
|
1103
|
+
operator: /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
|
|
1104
|
+
}), n.languages.javascript["class-name"][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/, n.languages.insertBefore("javascript", "keyword", {
|
|
1105
|
+
regex: {
|
|
1106
|
+
pattern: RegExp("((?:^|[^$\\w\\xA0-\\uFFFF.\"'\\])\\s]|\\b(?:return|yield))\\s*)\\/(?:(?:\\[(?:[^\\]\\\\\\r\\n]|\\\\.)*\\]|\\\\.|[^/\\\\\\[\\r\\n])+\\/[dgimyus]{0,7}|(?:\\[(?:[^[\\]\\\\\\r\\n]|\\\\.|\\[(?:[^[\\]\\\\\\r\\n]|\\\\.|\\[(?:[^[\\]\\\\\\r\\n]|\\\\.)*\\])*\\])*\\]|\\\\.|[^/\\\\\\[\\r\\n])+\\/[dgimyus]{0,7}v[dgimyus]{0,7})(?=(?:\\s|\\/\\*(?:[^*]|\\*(?!\\/))*\\*\\/)*(?:$|[\\r\\n,.;:})\\]]|\\/\\/))"),
|
|
1107
|
+
lookbehind: !0,
|
|
1108
|
+
greedy: !0,
|
|
1109
|
+
inside: {
|
|
1110
|
+
"regex-source": {
|
|
1111
|
+
pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
|
|
1112
|
+
lookbehind: !0,
|
|
1113
|
+
alias: "language-regex",
|
|
1114
|
+
inside: n.languages.regex
|
|
1115
|
+
},
|
|
1116
|
+
"regex-delimiter": /^\/|\/$/,
|
|
1117
|
+
"regex-flags": /^[a-z]+$/
|
|
1118
|
+
}
|
|
1119
|
+
},
|
|
1120
|
+
"function-variable": {
|
|
1121
|
+
pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,
|
|
1122
|
+
alias: "function"
|
|
1123
|
+
},
|
|
1124
|
+
parameter: [
|
|
1125
|
+
{
|
|
1126
|
+
pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
|
|
1127
|
+
lookbehind: !0,
|
|
1128
|
+
inside: n.languages.javascript
|
|
1129
|
+
},
|
|
1130
|
+
{
|
|
1131
|
+
pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
|
|
1132
|
+
lookbehind: !0,
|
|
1133
|
+
inside: n.languages.javascript
|
|
1134
|
+
},
|
|
1135
|
+
{
|
|
1136
|
+
pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
|
|
1137
|
+
lookbehind: !0,
|
|
1138
|
+
inside: n.languages.javascript
|
|
1139
|
+
},
|
|
1140
|
+
{
|
|
1141
|
+
pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,
|
|
1142
|
+
lookbehind: !0,
|
|
1143
|
+
inside: n.languages.javascript
|
|
1144
|
+
}
|
|
1145
|
+
],
|
|
1146
|
+
constant: /\b[A-Z](?:[A-Z_]|\dx?)*\b/
|
|
1147
|
+
}), n.languages.insertBefore("javascript", "string", {
|
|
1148
|
+
hashbang: {
|
|
1149
|
+
pattern: /^#!.*/,
|
|
1150
|
+
greedy: !0,
|
|
1151
|
+
alias: "comment"
|
|
1152
|
+
},
|
|
1153
|
+
"template-string": {
|
|
1154
|
+
pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
|
|
1155
|
+
greedy: !0,
|
|
1156
|
+
inside: {
|
|
1157
|
+
"template-punctuation": {
|
|
1158
|
+
pattern: /^`|`$/,
|
|
1159
|
+
alias: "string"
|
|
1160
|
+
},
|
|
1161
|
+
interpolation: {
|
|
1162
|
+
pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
|
|
1163
|
+
lookbehind: !0,
|
|
1164
|
+
inside: {
|
|
1165
|
+
"interpolation-punctuation": {
|
|
1166
|
+
pattern: /^\$\{|\}$/,
|
|
1167
|
+
alias: "punctuation"
|
|
1168
|
+
},
|
|
1169
|
+
rest: n.languages.javascript
|
|
1170
|
+
}
|
|
1171
|
+
},
|
|
1172
|
+
string: /[\s\S]+/
|
|
1173
|
+
}
|
|
1174
|
+
},
|
|
1175
|
+
"string-property": {
|
|
1176
|
+
pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
|
|
1177
|
+
lookbehind: !0,
|
|
1178
|
+
greedy: !0,
|
|
1179
|
+
alias: "property"
|
|
1180
|
+
}
|
|
1181
|
+
}), n.languages.insertBefore("javascript", "operator", { "literal-property": {
|
|
1182
|
+
pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
|
|
1183
|
+
lookbehind: !0,
|
|
1184
|
+
alias: "property"
|
|
1185
|
+
} }), n.languages.markup && (n.languages.markup.tag.addInlined("script", "javascript"), n.languages.markup.tag.addAttribute("on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)", "javascript")), n.languages.js = n.languages.javascript, (function() {
|
|
1186
|
+
if (n === void 0 || typeof document > "u") return;
|
|
1187
|
+
Element.prototype.matches || (Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector);
|
|
1188
|
+
var e = "Loading…", t = function(e, t) {
|
|
1189
|
+
return "✖ Error " + e + " while fetching file: " + t;
|
|
1190
|
+
}, r = "✖ Error: File does not exist or is empty", i = {
|
|
1191
|
+
js: "javascript",
|
|
1192
|
+
py: "python",
|
|
1193
|
+
rb: "ruby",
|
|
1194
|
+
ps1: "powershell",
|
|
1195
|
+
psm1: "powershell",
|
|
1196
|
+
sh: "bash",
|
|
1197
|
+
bat: "batch",
|
|
1198
|
+
h: "c",
|
|
1199
|
+
tex: "latex"
|
|
1200
|
+
}, a = "data-src-status", o = "loading", s = "loaded", c = "failed", l = "pre[data-src]:not([" + a + "=\"" + s + "\"]):not([" + a + "=\"" + o + "\"])";
|
|
1201
|
+
function u(e, n, i) {
|
|
1202
|
+
var a = new XMLHttpRequest();
|
|
1203
|
+
a.open("GET", e, !0), a.onreadystatechange = function() {
|
|
1204
|
+
a.readyState == 4 && (a.status < 400 && a.responseText ? n(a.responseText) : a.status >= 400 ? i(t(a.status, a.statusText)) : i(r));
|
|
1205
|
+
}, a.send(null);
|
|
1206
|
+
}
|
|
1207
|
+
function d(e) {
|
|
1208
|
+
var t = /^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(e || "");
|
|
1209
|
+
if (t) {
|
|
1210
|
+
var n = Number(t[1]), r = t[2], i = t[3];
|
|
1211
|
+
return r ? i ? [n, Number(i)] : [n, void 0] : [n, n];
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
n.hooks.add("before-highlightall", function(e) {
|
|
1215
|
+
e.selector += ", " + l;
|
|
1216
|
+
}), n.hooks.add("before-sanity-check", function(t) {
|
|
1217
|
+
var r = t.element;
|
|
1218
|
+
if (r.matches(l)) {
|
|
1219
|
+
t.code = "", r.setAttribute(a, o);
|
|
1220
|
+
var f = r.appendChild(document.createElement("CODE"));
|
|
1221
|
+
f.textContent = e;
|
|
1222
|
+
var p = r.getAttribute("data-src"), m = t.language;
|
|
1223
|
+
if (m === "none") {
|
|
1224
|
+
var h = (/\.(\w+)$/.exec(p) || [, "none"])[1];
|
|
1225
|
+
m = i[h] || h;
|
|
1226
|
+
}
|
|
1227
|
+
n.util.setLanguage(f, m), n.util.setLanguage(r, m);
|
|
1228
|
+
var g = n.plugins.autoloader;
|
|
1229
|
+
g && g.loadLanguages(m), u(p, function(e) {
|
|
1230
|
+
r.setAttribute(a, s);
|
|
1231
|
+
var t = d(r.getAttribute("data-range"));
|
|
1232
|
+
if (t) {
|
|
1233
|
+
var i = e.split(/\r\n?|\n/g), o = t[0], c = t[1] == null ? i.length : t[1];
|
|
1234
|
+
o < 0 && (o += i.length), o = Math.max(0, Math.min(o - 1, i.length)), c < 0 && (c += i.length), c = Math.max(0, Math.min(c, i.length)), e = i.slice(o, c).join("\n"), r.hasAttribute("data-start") || r.setAttribute("data-start", String(o + 1));
|
|
1235
|
+
}
|
|
1236
|
+
f.textContent = e, n.highlightElement(f);
|
|
1237
|
+
}, function(e) {
|
|
1238
|
+
r.setAttribute(a, c), f.textContent = e;
|
|
1239
|
+
});
|
|
1240
|
+
}
|
|
1241
|
+
}), n.plugins.fileHighlight = { highlight: function(e) {
|
|
1242
|
+
for (var t = (e || document).querySelectorAll(l), r = 0, i; i = t[r++];) n.highlightElement(i);
|
|
1243
|
+
} };
|
|
1244
|
+
var f = !1;
|
|
1245
|
+
n.fileHighlight = function() {
|
|
1246
|
+
f ||= (console.warn("Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead."), !0), n.plugins.fileHighlight.highlight.apply(this, arguments);
|
|
1247
|
+
};
|
|
1248
|
+
})();
|
|
1249
|
+
}));
|
|
1250
|
+
(function(e) {
|
|
1251
|
+
var t = "\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b", n = {
|
|
1252
|
+
pattern: /(^(["']?)\w+\2)[ \t]+\S.*/,
|
|
1253
|
+
lookbehind: !0,
|
|
1254
|
+
alias: "punctuation",
|
|
1255
|
+
inside: null
|
|
1256
|
+
}, r = {
|
|
1257
|
+
bash: n,
|
|
1258
|
+
environment: {
|
|
1259
|
+
pattern: RegExp("\\$" + t),
|
|
1260
|
+
alias: "constant"
|
|
1261
|
+
},
|
|
1262
|
+
variable: [
|
|
1263
|
+
{
|
|
1264
|
+
pattern: /\$?\(\([\s\S]+?\)\)/,
|
|
1265
|
+
greedy: !0,
|
|
1266
|
+
inside: {
|
|
1267
|
+
variable: [{
|
|
1268
|
+
pattern: /(^\$\(\([\s\S]+)\)\)/,
|
|
1269
|
+
lookbehind: !0
|
|
1270
|
+
}, /^\$\(\(/],
|
|
1271
|
+
number: /\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,
|
|
1272
|
+
operator: /--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,
|
|
1273
|
+
punctuation: /\(\(?|\)\)?|,|;/
|
|
1274
|
+
}
|
|
1275
|
+
},
|
|
1276
|
+
{
|
|
1277
|
+
pattern: /\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,
|
|
1278
|
+
greedy: !0,
|
|
1279
|
+
inside: { variable: /^\$\(|^`|\)$|`$/ }
|
|
1280
|
+
},
|
|
1281
|
+
{
|
|
1282
|
+
pattern: /\$\{[^}]+\}/,
|
|
1283
|
+
greedy: !0,
|
|
1284
|
+
inside: {
|
|
1285
|
+
operator: /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,
|
|
1286
|
+
punctuation: /[\[\]]/,
|
|
1287
|
+
environment: {
|
|
1288
|
+
pattern: RegExp("(\\{)" + t),
|
|
1289
|
+
lookbehind: !0,
|
|
1290
|
+
alias: "constant"
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
},
|
|
1294
|
+
/\$(?:\w+|[#?*!@$])/
|
|
1295
|
+
],
|
|
1296
|
+
entity: /\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/
|
|
1297
|
+
};
|
|
1298
|
+
e.languages.bash = {
|
|
1299
|
+
shebang: {
|
|
1300
|
+
pattern: /^#!\s*\/.*/,
|
|
1301
|
+
alias: "important"
|
|
1302
|
+
},
|
|
1303
|
+
comment: {
|
|
1304
|
+
pattern: /(^|[^"{\\$])#.*/,
|
|
1305
|
+
lookbehind: !0
|
|
1306
|
+
},
|
|
1307
|
+
"function-name": [{
|
|
1308
|
+
pattern: /(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,
|
|
1309
|
+
lookbehind: !0,
|
|
1310
|
+
alias: "function"
|
|
1311
|
+
}, {
|
|
1312
|
+
pattern: /\b[\w-]+(?=\s*\(\s*\)\s*\{)/,
|
|
1313
|
+
alias: "function"
|
|
1314
|
+
}],
|
|
1315
|
+
"for-or-select": {
|
|
1316
|
+
pattern: /(\b(?:for|select)\s+)\w+(?=\s+in\s)/,
|
|
1317
|
+
alias: "variable",
|
|
1318
|
+
lookbehind: !0
|
|
1319
|
+
},
|
|
1320
|
+
"assign-left": {
|
|
1321
|
+
pattern: /(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,
|
|
1322
|
+
inside: { environment: {
|
|
1323
|
+
pattern: RegExp("(^|[\\s;|&]|[<>]\\()" + t),
|
|
1324
|
+
lookbehind: !0,
|
|
1325
|
+
alias: "constant"
|
|
1326
|
+
} },
|
|
1327
|
+
alias: "variable",
|
|
1328
|
+
lookbehind: !0
|
|
1329
|
+
},
|
|
1330
|
+
parameter: {
|
|
1331
|
+
pattern: /(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,
|
|
1332
|
+
alias: "variable",
|
|
1333
|
+
lookbehind: !0
|
|
1334
|
+
},
|
|
1335
|
+
string: [
|
|
1336
|
+
{
|
|
1337
|
+
pattern: /((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,
|
|
1338
|
+
lookbehind: !0,
|
|
1339
|
+
greedy: !0,
|
|
1340
|
+
inside: r
|
|
1341
|
+
},
|
|
1342
|
+
{
|
|
1343
|
+
pattern: /((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,
|
|
1344
|
+
lookbehind: !0,
|
|
1345
|
+
greedy: !0,
|
|
1346
|
+
inside: { bash: n }
|
|
1347
|
+
},
|
|
1348
|
+
{
|
|
1349
|
+
pattern: /(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,
|
|
1350
|
+
lookbehind: !0,
|
|
1351
|
+
greedy: !0,
|
|
1352
|
+
inside: r
|
|
1353
|
+
},
|
|
1354
|
+
{
|
|
1355
|
+
pattern: /(^|[^$\\])'[^']*'/,
|
|
1356
|
+
lookbehind: !0,
|
|
1357
|
+
greedy: !0
|
|
1358
|
+
},
|
|
1359
|
+
{
|
|
1360
|
+
pattern: /\$'(?:[^'\\]|\\[\s\S])*'/,
|
|
1361
|
+
greedy: !0,
|
|
1362
|
+
inside: { entity: r.entity }
|
|
1363
|
+
}
|
|
1364
|
+
],
|
|
1365
|
+
environment: {
|
|
1366
|
+
pattern: RegExp("\\$?" + t),
|
|
1367
|
+
alias: "constant"
|
|
1368
|
+
},
|
|
1369
|
+
variable: r.variable,
|
|
1370
|
+
function: {
|
|
1371
|
+
pattern: /(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,
|
|
1372
|
+
lookbehind: !0
|
|
1373
|
+
},
|
|
1374
|
+
keyword: {
|
|
1375
|
+
pattern: /(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,
|
|
1376
|
+
lookbehind: !0
|
|
1377
|
+
},
|
|
1378
|
+
builtin: {
|
|
1379
|
+
pattern: /(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,
|
|
1380
|
+
lookbehind: !0,
|
|
1381
|
+
alias: "class-name"
|
|
1382
|
+
},
|
|
1383
|
+
boolean: {
|
|
1384
|
+
pattern: /(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,
|
|
1385
|
+
lookbehind: !0
|
|
1386
|
+
},
|
|
1387
|
+
"file-descriptor": {
|
|
1388
|
+
pattern: /\B&\d\b/,
|
|
1389
|
+
alias: "important"
|
|
1390
|
+
},
|
|
1391
|
+
operator: {
|
|
1392
|
+
pattern: /\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,
|
|
1393
|
+
inside: { "file-descriptor": {
|
|
1394
|
+
pattern: /^\d/,
|
|
1395
|
+
alias: "important"
|
|
1396
|
+
} }
|
|
1397
|
+
},
|
|
1398
|
+
punctuation: /\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,
|
|
1399
|
+
number: {
|
|
1400
|
+
pattern: /(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,
|
|
1401
|
+
lookbehind: !0
|
|
1402
|
+
}
|
|
1403
|
+
}, n.inside = e.languages.bash;
|
|
1404
|
+
for (var i = [
|
|
1405
|
+
"comment",
|
|
1406
|
+
"function-name",
|
|
1407
|
+
"for-or-select",
|
|
1408
|
+
"assign-left",
|
|
1409
|
+
"parameter",
|
|
1410
|
+
"string",
|
|
1411
|
+
"environment",
|
|
1412
|
+
"function",
|
|
1413
|
+
"keyword",
|
|
1414
|
+
"builtin",
|
|
1415
|
+
"boolean",
|
|
1416
|
+
"file-descriptor",
|
|
1417
|
+
"operator",
|
|
1418
|
+
"punctuation",
|
|
1419
|
+
"number"
|
|
1420
|
+
], a = r.variable[1].inside, o = 0; o < i.length; o++) a[i[o]] = e.languages.bash[i[o]];
|
|
1421
|
+
e.languages.sh = e.languages.bash, e.languages.shell = e.languages.bash;
|
|
1422
|
+
})(Prism), Prism.languages.json = {
|
|
1423
|
+
property: {
|
|
1424
|
+
pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,
|
|
1425
|
+
lookbehind: !0,
|
|
1426
|
+
greedy: !0
|
|
1427
|
+
},
|
|
1428
|
+
string: {
|
|
1429
|
+
pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,
|
|
1430
|
+
lookbehind: !0,
|
|
1431
|
+
greedy: !0
|
|
1432
|
+
},
|
|
1433
|
+
comment: {
|
|
1434
|
+
pattern: /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,
|
|
1435
|
+
greedy: !0
|
|
1436
|
+
},
|
|
1437
|
+
number: /-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,
|
|
1438
|
+
punctuation: /[{}[\],]/,
|
|
1439
|
+
operator: /:/,
|
|
1440
|
+
boolean: /\b(?:false|true)\b/,
|
|
1441
|
+
null: {
|
|
1442
|
+
pattern: /\bnull\b/,
|
|
1443
|
+
alias: "keyword"
|
|
1444
|
+
}
|
|
1445
|
+
}, Prism.languages.webmanifest = Prism.languages.json, Prism.languages.python = {
|
|
1446
|
+
comment: {
|
|
1447
|
+
pattern: /(^|[^\\])#.*/,
|
|
1448
|
+
lookbehind: !0,
|
|
1449
|
+
greedy: !0
|
|
1450
|
+
},
|
|
1451
|
+
"string-interpolation": {
|
|
1452
|
+
pattern: /(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
|
|
1453
|
+
greedy: !0,
|
|
1454
|
+
inside: {
|
|
1455
|
+
interpolation: {
|
|
1456
|
+
pattern: /((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,
|
|
1457
|
+
lookbehind: !0,
|
|
1458
|
+
inside: {
|
|
1459
|
+
"format-spec": {
|
|
1460
|
+
pattern: /(:)[^:(){}]+(?=\}$)/,
|
|
1461
|
+
lookbehind: !0
|
|
1462
|
+
},
|
|
1463
|
+
"conversion-option": {
|
|
1464
|
+
pattern: //,
|
|
1465
|
+
alias: "punctuation"
|
|
1466
|
+
},
|
|
1467
|
+
rest: null
|
|
1468
|
+
}
|
|
1469
|
+
},
|
|
1470
|
+
string: /[\s\S]+/
|
|
1471
|
+
}
|
|
1472
|
+
},
|
|
1473
|
+
"triple-quoted-string": {
|
|
1474
|
+
pattern: /(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,
|
|
1475
|
+
greedy: !0,
|
|
1476
|
+
alias: "string"
|
|
1477
|
+
},
|
|
1478
|
+
string: {
|
|
1479
|
+
pattern: /(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,
|
|
1480
|
+
greedy: !0
|
|
1481
|
+
},
|
|
1482
|
+
function: {
|
|
1483
|
+
pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,
|
|
1484
|
+
lookbehind: !0
|
|
1485
|
+
},
|
|
1486
|
+
"class-name": {
|
|
1487
|
+
pattern: /(\bclass\s+)\w+/i,
|
|
1488
|
+
lookbehind: !0
|
|
1489
|
+
},
|
|
1490
|
+
decorator: {
|
|
1491
|
+
pattern: /(^[\t ]*)@\w+(?:\.\w+)*/m,
|
|
1492
|
+
lookbehind: !0,
|
|
1493
|
+
alias: ["annotation", "punctuation"],
|
|
1494
|
+
inside: { punctuation: /\./ }
|
|
1495
|
+
},
|
|
1496
|
+
keyword: /\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,
|
|
1497
|
+
builtin: /\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,
|
|
1498
|
+
boolean: /\b(?:False|None|True)\b/,
|
|
1499
|
+
number: /\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,
|
|
1500
|
+
operator: /[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
|
|
1501
|
+
punctuation: /[{}[\];(),.:]/
|
|
1502
|
+
}, Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest = Prism.languages.python, Prism.languages.py = Prism.languages.python, Prism.languages.go = Prism.languages.extend("clike", {
|
|
1503
|
+
string: {
|
|
1504
|
+
pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,
|
|
1505
|
+
lookbehind: !0,
|
|
1506
|
+
greedy: !0
|
|
1507
|
+
},
|
|
1508
|
+
keyword: /\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,
|
|
1509
|
+
boolean: /\b(?:_|false|iota|nil|true)\b/,
|
|
1510
|
+
number: [
|
|
1511
|
+
/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,
|
|
1512
|
+
/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,
|
|
1513
|
+
/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i
|
|
1514
|
+
],
|
|
1515
|
+
operator: /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
|
|
1516
|
+
builtin: /\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/
|
|
1517
|
+
}), Prism.languages.insertBefore("go", "string", { char: {
|
|
1518
|
+
pattern: /'(?:\\.|[^'\\\r\n]){0,10}'/,
|
|
1519
|
+
greedy: !0
|
|
1520
|
+
} }), delete Prism.languages.go["class-name"];
|
|
1521
|
+
//#endregion
|
|
1522
|
+
//#region src/lib/highlight.tsx
|
|
1523
|
+
var H = /* @__PURE__ */ v(pe(), 1), me = {
|
|
1524
|
+
json: H.default.languages.json,
|
|
1525
|
+
bash: H.default.languages.bash,
|
|
1526
|
+
javascript: H.default.languages.javascript,
|
|
1527
|
+
python: H.default.languages.python,
|
|
1528
|
+
go: H.default.languages.go
|
|
1529
|
+
};
|
|
1530
|
+
function U(e, t) {
|
|
1531
|
+
if (typeof e == "string") return e;
|
|
1532
|
+
let n = Array.isArray(e.content) ? e.content.map((e, t) => U(e, t)) : U(e.content, 0);
|
|
1533
|
+
return /* @__PURE__ */ c("span", {
|
|
1534
|
+
className: `token ${e.type}`,
|
|
1535
|
+
children: n
|
|
1536
|
+
}, t);
|
|
1537
|
+
}
|
|
1538
|
+
function he(e, t) {
|
|
1539
|
+
let n = t === "plain" ? void 0 : me[t];
|
|
1540
|
+
return !n || !e ? e : H.default.tokenize(e, n).map((e, t) => U(e, t));
|
|
1541
|
+
}
|
|
1542
|
+
//#endregion
|
|
1543
|
+
//#region src/components/ui/CodeBlock.tsx
|
|
1544
|
+
var W = ({ code: e, language: t = "plain", showLineNumbers: n = !1, copyable: r = !0, maxHeight: a, reveal: o = !1, revealStagger: s = 70, className: u }) => {
|
|
1545
|
+
let d = i(() => e.replace(/\n$/, "").split("\n"), [e]), f = String(d.length).length;
|
|
1546
|
+
return /* @__PURE__ */ l("div", {
|
|
1547
|
+
className: y("group relative w-full overflow-hidden rounded-lg border border-border bg-surface-2", u),
|
|
1548
|
+
children: [r && /* @__PURE__ */ c("div", {
|
|
1549
|
+
className: "absolute right-2 top-2 z-10",
|
|
1550
|
+
children: /* @__PURE__ */ c(j, {
|
|
1551
|
+
value: e,
|
|
1552
|
+
size: "sm"
|
|
1553
|
+
})
|
|
1554
|
+
}), /* @__PURE__ */ c("div", {
|
|
1555
|
+
className: "overflow-auto",
|
|
1556
|
+
style: a ? { maxHeight: a } : void 0,
|
|
1557
|
+
children: /* @__PURE__ */ c("pre", {
|
|
1558
|
+
className: "w-max min-w-full p-3 font-mono text-[14px] leading-relaxed text-content",
|
|
1559
|
+
children: /* @__PURE__ */ c("code", {
|
|
1560
|
+
className: "flex flex-col bg-transparent p-0 text-[14px] text-content",
|
|
1561
|
+
children: d.map((e, r) => /* @__PURE__ */ l("span", {
|
|
1562
|
+
className: y("flex", o && "motion-safe:animate-[fade-in_0.6s_ease-out_both]"),
|
|
1563
|
+
style: o ? { animationDelay: `${r * s}ms` } : void 0,
|
|
1564
|
+
children: [n && /* @__PURE__ */ c("span", {
|
|
1565
|
+
className: "mr-4 shrink-0 select-none text-right text-muted",
|
|
1566
|
+
style: { width: `${f}ch` },
|
|
1567
|
+
children: r + 1
|
|
1568
|
+
}), /* @__PURE__ */ c("span", {
|
|
1569
|
+
className: "whitespace-pre",
|
|
1570
|
+
children: he(e, t) || " "
|
|
1571
|
+
})]
|
|
1572
|
+
}, r))
|
|
1573
|
+
})
|
|
1574
|
+
})
|
|
1575
|
+
})]
|
|
1576
|
+
});
|
|
1577
|
+
}, ge = /* @__PURE__ */ new Set([
|
|
1578
|
+
"accept-charset",
|
|
1579
|
+
"accept-encoding",
|
|
1580
|
+
"access-control-request-headers",
|
|
1581
|
+
"access-control-request-method",
|
|
1582
|
+
"connection",
|
|
1583
|
+
"content-length",
|
|
1584
|
+
"cookie",
|
|
1585
|
+
"cookie2",
|
|
1586
|
+
"date",
|
|
1587
|
+
"dnt",
|
|
1588
|
+
"expect",
|
|
1589
|
+
"host",
|
|
1590
|
+
"keep-alive",
|
|
1591
|
+
"origin",
|
|
1592
|
+
"referer",
|
|
1593
|
+
"te",
|
|
1594
|
+
"trailer",
|
|
1595
|
+
"transfer-encoding",
|
|
1596
|
+
"upgrade",
|
|
1597
|
+
"via"
|
|
1598
|
+
]);
|
|
1599
|
+
function _e(e) {
|
|
1600
|
+
return !e.auth || e.auth.type === "none" ? null : e.auth.type === "bearer" ? {
|
|
1601
|
+
key: "Authorization",
|
|
1602
|
+
value: `Bearer ${e.auth.token}`
|
|
1603
|
+
} : {
|
|
1604
|
+
key: e.auth.key,
|
|
1605
|
+
value: e.auth.value
|
|
1606
|
+
};
|
|
1607
|
+
}
|
|
1608
|
+
function ve(e) {
|
|
1609
|
+
let t = new Headers();
|
|
1610
|
+
for (let n of e.headers ?? []) n.key.trim() && (ge.has(n.key.trim().toLowerCase()) || t.set(n.key, n.value));
|
|
1611
|
+
let n = _e(e);
|
|
1612
|
+
return n && !ge.has(n.key.toLowerCase()) && t.set(n.key, n.value), t;
|
|
1613
|
+
}
|
|
1614
|
+
function ye(e) {
|
|
1615
|
+
return [...e.entries()].map(([e, t]) => ({
|
|
1616
|
+
key: e,
|
|
1617
|
+
value: t
|
|
1618
|
+
}));
|
|
1619
|
+
}
|
|
1620
|
+
function be(e) {
|
|
1621
|
+
let t = new TextEncoder().encode(e).length;
|
|
1622
|
+
return t < 1024 ? `${t} B` : t < 1024 * 1024 ? `${(t / 1024).toFixed(1)} KB` : `${(t / (1024 * 1024)).toFixed(1)} MB`;
|
|
1623
|
+
}
|
|
1624
|
+
function xe(e, t) {
|
|
1625
|
+
if (!(t?.includes("json") || /^[\s\n]*(?:\[|\{)/.test(e))) return e;
|
|
1626
|
+
try {
|
|
1627
|
+
return JSON.stringify(JSON.parse(e), null, 2);
|
|
1628
|
+
} catch {
|
|
1629
|
+
return e;
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
function Se(e) {
|
|
1633
|
+
return e instanceof Error ? e.message : "Request failed";
|
|
1634
|
+
}
|
|
1635
|
+
function G(e, t = performance.now()) {
|
|
1636
|
+
let n = Se(e);
|
|
1637
|
+
return {
|
|
1638
|
+
status: 0,
|
|
1639
|
+
statusText: "Network Error",
|
|
1640
|
+
headers: [],
|
|
1641
|
+
body: JSON.stringify({
|
|
1642
|
+
error: n,
|
|
1643
|
+
hint: "The browser may have blocked this request because of CORS or network policy."
|
|
1644
|
+
}, null, 2),
|
|
1645
|
+
timeMs: Math.round(performance.now() - t),
|
|
1646
|
+
size: "0 B",
|
|
1647
|
+
error: n
|
|
1648
|
+
};
|
|
1649
|
+
}
|
|
1650
|
+
async function Ce(e) {
|
|
1651
|
+
let t = performance.now();
|
|
1652
|
+
try {
|
|
1653
|
+
let n = await fetch(e.url, {
|
|
1654
|
+
method: e.method,
|
|
1655
|
+
headers: ve(e),
|
|
1656
|
+
body: e.body && e.method !== "GET" ? e.body : void 0
|
|
1657
|
+
}), r = await n.text(), i = xe(r, n.headers.get("content-type"));
|
|
1658
|
+
return {
|
|
1659
|
+
status: n.status,
|
|
1660
|
+
statusText: n.statusText || (n.ok ? "OK" : "Error"),
|
|
1661
|
+
headers: ye(n.headers),
|
|
1662
|
+
body: i,
|
|
1663
|
+
timeMs: Math.round(performance.now() - t),
|
|
1664
|
+
size: be(r)
|
|
1665
|
+
};
|
|
1666
|
+
} catch (e) {
|
|
1667
|
+
return G(e, t);
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
function we(e) {
|
|
1671
|
+
let t = e.sampleResponse ?? JSON.stringify({
|
|
1672
|
+
ok: !0,
|
|
1673
|
+
request: e.title
|
|
1674
|
+
}, null, 2);
|
|
1675
|
+
return {
|
|
1676
|
+
status: 200,
|
|
1677
|
+
statusText: "OK",
|
|
1678
|
+
headers: [{
|
|
1679
|
+
key: "content-type",
|
|
1680
|
+
value: "application/json"
|
|
1681
|
+
}, {
|
|
1682
|
+
key: "cache-control",
|
|
1683
|
+
value: "no-store"
|
|
1684
|
+
}],
|
|
1685
|
+
body: t,
|
|
1686
|
+
timeMs: 142,
|
|
1687
|
+
size: be(t)
|
|
1688
|
+
};
|
|
1689
|
+
}
|
|
1690
|
+
//#endregion
|
|
1691
|
+
//#region src/features/api-widget/request-model.ts
|
|
1692
|
+
var K = "Authorization", Te = "Bearer ", Ee = [{
|
|
1693
|
+
key: "Content-Type",
|
|
1694
|
+
value: "application/json",
|
|
1695
|
+
enabled: !0
|
|
1696
|
+
}];
|
|
1697
|
+
function De(e) {
|
|
1698
|
+
return e.type === "none" ? null : e.type === "bearer" ? {
|
|
1699
|
+
key: K,
|
|
1700
|
+
value: `${Te}${e.token}`,
|
|
1701
|
+
enabled: !0
|
|
1702
|
+
} : {
|
|
1703
|
+
key: e.key,
|
|
1704
|
+
value: e.value,
|
|
1705
|
+
enabled: !0
|
|
1706
|
+
};
|
|
1707
|
+
}
|
|
1708
|
+
function q(e, t) {
|
|
1709
|
+
return e.toLowerCase() === t.toLowerCase();
|
|
1710
|
+
}
|
|
1711
|
+
function Oe(e) {
|
|
1712
|
+
return e.toLowerCase().startsWith(Te.toLowerCase());
|
|
1713
|
+
}
|
|
1714
|
+
function ke(e) {
|
|
1715
|
+
return Oe(e) ? e.slice(7) : e;
|
|
1716
|
+
}
|
|
1717
|
+
function Ae(e) {
|
|
1718
|
+
return e ? q(e.key, K) && Oe(e.value) ? {
|
|
1719
|
+
type: "bearer",
|
|
1720
|
+
token: ke(e.value)
|
|
1721
|
+
} : {
|
|
1722
|
+
type: "apiKey",
|
|
1723
|
+
key: e.key || K,
|
|
1724
|
+
value: e.value,
|
|
1725
|
+
in: "header"
|
|
1726
|
+
} : { type: "none" };
|
|
1727
|
+
}
|
|
1728
|
+
function je(e) {
|
|
1729
|
+
return e.type === "apiKey" ? e.key : K;
|
|
1730
|
+
}
|
|
1731
|
+
function J(e, t) {
|
|
1732
|
+
return t.type === "none" ? q(e.key, K) : q(e.key, je(t));
|
|
1733
|
+
}
|
|
1734
|
+
function Me(e) {
|
|
1735
|
+
return e.auth ? e.auth : Ae(e.headers?.find((e) => q(e.key, K)));
|
|
1736
|
+
}
|
|
1737
|
+
function Ne(e, t) {
|
|
1738
|
+
let n = (e.headers?.length ? e.headers : Ee).filter((e) => !J(e, t)).map((e) => ({
|
|
1739
|
+
...e,
|
|
1740
|
+
enabled: !0
|
|
1741
|
+
})), r = De(t);
|
|
1742
|
+
return r ? [...n, r] : n;
|
|
1743
|
+
}
|
|
1744
|
+
function Pe(e, t, n) {
|
|
1745
|
+
if (t.type === "none") return e.map((e) => J(e, n) || q(e.key, K) ? {
|
|
1746
|
+
...e,
|
|
1747
|
+
enabled: !1
|
|
1748
|
+
} : e);
|
|
1749
|
+
let r = De(t);
|
|
1750
|
+
return r ? [...e.filter((e) => !J(e, n) && !J(e, t)), r] : e;
|
|
1751
|
+
}
|
|
1752
|
+
function Fe(e, t) {
|
|
1753
|
+
return e.filter((e) => e.enabled && e.key.trim() && !J(e, t)).map(({ key: e, value: t }) => ({
|
|
1754
|
+
key: e,
|
|
1755
|
+
value: t
|
|
1756
|
+
}));
|
|
1757
|
+
}
|
|
1758
|
+
function Y(e) {
|
|
1759
|
+
return JSON.stringify({
|
|
1760
|
+
method: e.method,
|
|
1761
|
+
url: e.url,
|
|
1762
|
+
headers: e.headers ?? [],
|
|
1763
|
+
auth: e.auth ?? { type: "none" },
|
|
1764
|
+
body: e.body ?? ""
|
|
1765
|
+
});
|
|
1766
|
+
}
|
|
1767
|
+
function Ie(e, t) {
|
|
1768
|
+
let n = t.body.trim() ? t.body : void 0;
|
|
1769
|
+
return {
|
|
1770
|
+
...e,
|
|
1771
|
+
method: t.method,
|
|
1772
|
+
url: t.url,
|
|
1773
|
+
body: n,
|
|
1774
|
+
auth: t.auth,
|
|
1775
|
+
headers: Fe(t.headers, t.auth)
|
|
1776
|
+
};
|
|
1777
|
+
}
|
|
1778
|
+
//#endregion
|
|
1779
|
+
//#region src/features/api-widget/ApiConsole.tsx
|
|
1780
|
+
var Le = "{\n \n}", X = "Authorization", Re = [
|
|
1781
|
+
"GET",
|
|
1782
|
+
"POST",
|
|
1783
|
+
"PUT",
|
|
1784
|
+
"PATCH",
|
|
1785
|
+
"DELETE"
|
|
1786
|
+
], ze = [
|
|
1787
|
+
{
|
|
1788
|
+
id: "body",
|
|
1789
|
+
label: "Body"
|
|
1790
|
+
},
|
|
1791
|
+
{
|
|
1792
|
+
id: "headers",
|
|
1793
|
+
label: "Headers"
|
|
1794
|
+
},
|
|
1795
|
+
{
|
|
1796
|
+
id: "auth",
|
|
1797
|
+
label: "Auth"
|
|
1798
|
+
}
|
|
1799
|
+
], Be = [{
|
|
1800
|
+
id: "response",
|
|
1801
|
+
label: "Response"
|
|
1802
|
+
}, {
|
|
1803
|
+
id: "history",
|
|
1804
|
+
label: "History"
|
|
1805
|
+
}], Ve = ["body", "headers"], He = [
|
|
1806
|
+
{
|
|
1807
|
+
id: "none",
|
|
1808
|
+
label: "None",
|
|
1809
|
+
className: "font-semibold text-content hover:bg-surface-2"
|
|
1810
|
+
},
|
|
1811
|
+
{
|
|
1812
|
+
id: "bearer",
|
|
1813
|
+
label: "Bearer",
|
|
1814
|
+
className: "font-semibold text-content hover:bg-surface-2"
|
|
1815
|
+
},
|
|
1816
|
+
{
|
|
1817
|
+
id: "apiKey",
|
|
1818
|
+
label: "API key",
|
|
1819
|
+
className: "font-semibold text-content hover:bg-surface-2"
|
|
1820
|
+
}
|
|
1821
|
+
];
|
|
1822
|
+
function Ue(e) {
|
|
1823
|
+
return Math.max(3, e.split("\n").length);
|
|
1824
|
+
}
|
|
1825
|
+
function We(e) {
|
|
1826
|
+
return JSON.stringify(JSON.parse(e), null, 2);
|
|
1827
|
+
}
|
|
1828
|
+
function Ge(e) {
|
|
1829
|
+
try {
|
|
1830
|
+
return We(e);
|
|
1831
|
+
} catch {
|
|
1832
|
+
return e;
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1835
|
+
var Ke = ({ children: e, className: t }) => /* @__PURE__ */ c("div", {
|
|
1836
|
+
className: y("flex min-h-10 items-center rounded-md border border-transparent bg-surface-2 px-3 text-sm text-content", "focus-within:border-primary/60 focus-within:ring-2 focus-within:ring-primary/20", t),
|
|
1837
|
+
children: e
|
|
1838
|
+
}), qe = ({ value: e, onChange: t }) => /* @__PURE__ */ c("div", {
|
|
1839
|
+
className: "inline-flex items-center gap-4",
|
|
1840
|
+
children: Ve.map((n) => /* @__PURE__ */ c("button", {
|
|
1841
|
+
type: "button",
|
|
1842
|
+
onClick: () => t(n),
|
|
1843
|
+
className: y("text-xs font-medium capitalize transition-colors", e === n ? "text-content" : "text-muted hover:text-content"),
|
|
1844
|
+
children: n
|
|
1845
|
+
}, n))
|
|
1846
|
+
}), Je = ({ method: e, url: t, isSending: n, editable: r, onMethodChange: i, onUrlChange: a, onSend: o }) => /* @__PURE__ */ l("div", {
|
|
1847
|
+
className: "grid gap-3 md:grid-cols-[1fr_auto]",
|
|
1848
|
+
children: [/* @__PURE__ */ l(Ke, {
|
|
1849
|
+
className: "min-w-0",
|
|
1850
|
+
children: [/* @__PURE__ */ c(fe, {
|
|
1851
|
+
value: e,
|
|
1852
|
+
onChange: i,
|
|
1853
|
+
methods: Re,
|
|
1854
|
+
disabled: !r
|
|
1855
|
+
}), /* @__PURE__ */ c("input", {
|
|
1856
|
+
value: t,
|
|
1857
|
+
onChange: (e) => a(e.target.value),
|
|
1858
|
+
readOnly: !r,
|
|
1859
|
+
"aria-label": "Request URL",
|
|
1860
|
+
className: "min-w-0 flex-1 bg-transparent px-2 py-2 font-mono text-[14px] text-muted outline-none read-only:cursor-default"
|
|
1861
|
+
})]
|
|
1862
|
+
}), /* @__PURE__ */ c(T, {
|
|
1863
|
+
size: "md",
|
|
1864
|
+
variant: "primary",
|
|
1865
|
+
isLoading: n,
|
|
1866
|
+
onClick: o,
|
|
1867
|
+
rightIcon: /* @__PURE__ */ c(x, {
|
|
1868
|
+
name: "send",
|
|
1869
|
+
className: "h-4 w-4"
|
|
1870
|
+
}),
|
|
1871
|
+
className: "min-h-10 px-7",
|
|
1872
|
+
children: "Send"
|
|
1873
|
+
})]
|
|
1874
|
+
}), Ye = ({ header: e, index: t, editable: n, onUpdate: r, onRemove: i }) => /* @__PURE__ */ l("div", {
|
|
1875
|
+
className: "grid grid-cols-[auto_1fr_auto] gap-3 md:grid-cols-[auto_1fr_1fr_auto]",
|
|
1876
|
+
children: [
|
|
1877
|
+
/* @__PURE__ */ c("span", {
|
|
1878
|
+
className: "flex h-8 items-center",
|
|
1879
|
+
children: /* @__PURE__ */ c(te, {
|
|
1880
|
+
size: "sm",
|
|
1881
|
+
checked: e.enabled,
|
|
1882
|
+
onChange: (e) => r(t, { enabled: e }),
|
|
1883
|
+
disabled: !n,
|
|
1884
|
+
"aria-label": `Enable ${e.key}`
|
|
1885
|
+
})
|
|
1886
|
+
}),
|
|
1887
|
+
/* @__PURE__ */ c(V, {
|
|
1888
|
+
size: "sm",
|
|
1889
|
+
value: e.key,
|
|
1890
|
+
onChange: (e) => r(t, { key: e.target.value }),
|
|
1891
|
+
readOnly: !n,
|
|
1892
|
+
"aria-label": "Header name",
|
|
1893
|
+
className: "font-mono"
|
|
1894
|
+
}),
|
|
1895
|
+
/* @__PURE__ */ c(V, {
|
|
1896
|
+
size: "sm",
|
|
1897
|
+
value: e.value,
|
|
1898
|
+
onChange: (e) => r(t, { value: e.target.value }),
|
|
1899
|
+
readOnly: !n,
|
|
1900
|
+
"aria-label": "Header value",
|
|
1901
|
+
containerClassName: "col-start-2 md:col-start-auto",
|
|
1902
|
+
className: "font-mono"
|
|
1903
|
+
}),
|
|
1904
|
+
/* @__PURE__ */ c("button", {
|
|
1905
|
+
type: "button",
|
|
1906
|
+
"aria-label": `Remove ${e.key}`,
|
|
1907
|
+
onClick: () => i(t),
|
|
1908
|
+
disabled: !n,
|
|
1909
|
+
className: "row-span-2 inline-flex h-8 w-8 items-center justify-center rounded-md text-muted transition-colors hover:bg-surface-2 hover:text-content disabled:cursor-not-allowed disabled:opacity-40 md:row-span-1",
|
|
1910
|
+
children: /* @__PURE__ */ c(x, {
|
|
1911
|
+
name: "trash",
|
|
1912
|
+
className: "h-4 w-4"
|
|
1913
|
+
})
|
|
1914
|
+
})
|
|
1915
|
+
]
|
|
1916
|
+
}), Xe = ({ body: e, error: t, editable: n, onBodyChange: r, onClearError: i }) => /* @__PURE__ */ l("div", {
|
|
1917
|
+
className: "space-y-2",
|
|
1918
|
+
children: [t && /* @__PURE__ */ c("div", {
|
|
1919
|
+
className: "text-xs text-muted",
|
|
1920
|
+
children: t
|
|
1921
|
+
}), /* @__PURE__ */ c("textarea", {
|
|
1922
|
+
value: e,
|
|
1923
|
+
onChange: (e) => {
|
|
1924
|
+
r(e.target.value), t && i();
|
|
1925
|
+
},
|
|
1926
|
+
readOnly: !n,
|
|
1927
|
+
"aria-label": "Request body",
|
|
1928
|
+
spellCheck: !1,
|
|
1929
|
+
rows: Ue(e),
|
|
1930
|
+
className: y("w-full resize-none overflow-hidden rounded-lg border border-border bg-surface-2 p-3 [field-sizing:content]", "font-mono text-[13px] leading-relaxed text-content outline-none placeholder:text-muted read-only:cursor-default")
|
|
1931
|
+
})]
|
|
1932
|
+
}), Ze = ({ auth: e, editable: t, onChange: n }) => {
|
|
1933
|
+
let [r, i] = o(!1), a = /* @__PURE__ */ c("button", {
|
|
1934
|
+
type: "button",
|
|
1935
|
+
"aria-label": r ? "Hide secret" : "Show secret",
|
|
1936
|
+
onClick: () => i((e) => !e),
|
|
1937
|
+
className: "inline-flex h-6 w-6 items-center justify-center rounded-md text-muted transition-colors hover:text-content",
|
|
1938
|
+
children: /* @__PURE__ */ c(x, {
|
|
1939
|
+
name: r ? "eye-closed" : "eye",
|
|
1940
|
+
className: "h-4 w-4"
|
|
1941
|
+
})
|
|
1942
|
+
});
|
|
1943
|
+
return /* @__PURE__ */ l("div", {
|
|
1944
|
+
className: "grid items-start gap-3 md:grid-cols-[auto_1fr]",
|
|
1945
|
+
children: [
|
|
1946
|
+
/* @__PURE__ */ c(ce, {
|
|
1947
|
+
value: e.type,
|
|
1948
|
+
onChange: (t) => {
|
|
1949
|
+
t === "none" && n({ type: "none" }), t === "bearer" && n({
|
|
1950
|
+
type: "bearer",
|
|
1951
|
+
token: e.type === "bearer" ? e.token : ""
|
|
1952
|
+
}), t === "apiKey" && n({
|
|
1953
|
+
type: "apiKey",
|
|
1954
|
+
key: e.type === "apiKey" ? e.key : X,
|
|
1955
|
+
value: e.type === "apiKey" ? e.value : "",
|
|
1956
|
+
in: "header"
|
|
1957
|
+
});
|
|
1958
|
+
},
|
|
1959
|
+
items: He,
|
|
1960
|
+
size: "md",
|
|
1961
|
+
disabled: !t,
|
|
1962
|
+
minWidthClassName: "min-w-28"
|
|
1963
|
+
}),
|
|
1964
|
+
e.type === "none" && /* @__PURE__ */ c("div", {
|
|
1965
|
+
className: "rounded-lg border border-border bg-surface-2 p-2.5 text-xs text-muted",
|
|
1966
|
+
children: "Auth is disabled for this request."
|
|
1967
|
+
}),
|
|
1968
|
+
e.type === "bearer" && /* @__PURE__ */ c(V, {
|
|
1969
|
+
size: "sm",
|
|
1970
|
+
type: r ? "text" : "password",
|
|
1971
|
+
value: e.token,
|
|
1972
|
+
onChange: (e) => n({
|
|
1973
|
+
type: "bearer",
|
|
1974
|
+
token: e.target.value
|
|
1975
|
+
}),
|
|
1976
|
+
readOnly: !t,
|
|
1977
|
+
rightSlot: a,
|
|
1978
|
+
className: "font-mono"
|
|
1979
|
+
}),
|
|
1980
|
+
e.type === "apiKey" && /* @__PURE__ */ l("div", {
|
|
1981
|
+
className: "grid gap-3 md:grid-cols-[minmax(0,0.7fr)_minmax(0,1fr)]",
|
|
1982
|
+
children: [/* @__PURE__ */ c(V, {
|
|
1983
|
+
size: "sm",
|
|
1984
|
+
value: e.key,
|
|
1985
|
+
onChange: (t) => n({
|
|
1986
|
+
type: "apiKey",
|
|
1987
|
+
key: t.target.value,
|
|
1988
|
+
value: e.value,
|
|
1989
|
+
in: "header"
|
|
1990
|
+
}),
|
|
1991
|
+
readOnly: !t,
|
|
1992
|
+
className: "font-mono"
|
|
1993
|
+
}), /* @__PURE__ */ c(V, {
|
|
1994
|
+
size: "sm",
|
|
1995
|
+
type: r ? "text" : "password",
|
|
1996
|
+
value: e.value,
|
|
1997
|
+
onChange: (t) => n({
|
|
1998
|
+
type: "apiKey",
|
|
1999
|
+
key: e.key,
|
|
2000
|
+
value: t.target.value,
|
|
2001
|
+
in: "header"
|
|
2002
|
+
}),
|
|
2003
|
+
readOnly: !t,
|
|
2004
|
+
rightSlot: a,
|
|
2005
|
+
className: "font-mono"
|
|
2006
|
+
})]
|
|
2007
|
+
})
|
|
2008
|
+
]
|
|
2009
|
+
});
|
|
2010
|
+
}, Qe = ({ activeTab: e, auth: t, headers: n, body: r, bodyError: i, editable: a, onAuthChange: o, onHeaderUpdate: s, onHeaderRemove: u, onHeaderAdd: d, onBodyChange: f, onBodyErrorClear: p }) => e === "body" ? /* @__PURE__ */ c(Xe, {
|
|
2011
|
+
body: r,
|
|
2012
|
+
error: i,
|
|
2013
|
+
editable: a,
|
|
2014
|
+
onBodyChange: f,
|
|
2015
|
+
onClearError: p
|
|
2016
|
+
}) : e === "auth" ? /* @__PURE__ */ c(Ze, {
|
|
2017
|
+
auth: t,
|
|
2018
|
+
editable: a,
|
|
2019
|
+
onChange: o
|
|
2020
|
+
}) : /* @__PURE__ */ l("div", {
|
|
2021
|
+
className: "space-y-2.5",
|
|
2022
|
+
children: [n.map((e, t) => /* @__PURE__ */ c(Ye, {
|
|
2023
|
+
header: e,
|
|
2024
|
+
index: t,
|
|
2025
|
+
editable: a,
|
|
2026
|
+
onUpdate: s,
|
|
2027
|
+
onRemove: u
|
|
2028
|
+
}, `${e.key}-${t}`)), /* @__PURE__ */ l("button", {
|
|
2029
|
+
type: "button",
|
|
2030
|
+
onClick: d,
|
|
2031
|
+
disabled: !a,
|
|
2032
|
+
className: "inline-flex items-center gap-1.5 rounded-md px-1 py-1 text-xs font-medium text-primary transition-colors hover:text-primary-hover disabled:cursor-not-allowed disabled:opacity-40",
|
|
2033
|
+
children: [/* @__PURE__ */ c(x, {
|
|
2034
|
+
name: "plus",
|
|
2035
|
+
className: "h-4 w-4"
|
|
2036
|
+
}), "Add header"]
|
|
2037
|
+
})]
|
|
2038
|
+
}), $e = ({ responsePanel: e, response: t }) => {
|
|
2039
|
+
let n = e === "body", r = t.headers.map((e) => `${e.key}: ${e.value}`).join("\n"), i = n ? t.body : r || "No response headers";
|
|
2040
|
+
return /* @__PURE__ */ l("div", {
|
|
2041
|
+
className: "relative p-3",
|
|
2042
|
+
children: [/* @__PURE__ */ l("div", {
|
|
2043
|
+
className: "absolute right-5 top-5 z-10 flex items-center gap-1",
|
|
2044
|
+
children: [
|
|
2045
|
+
/* @__PURE__ */ c(O, {
|
|
2046
|
+
"aria-label": "Download response",
|
|
2047
|
+
variant: "surface",
|
|
2048
|
+
size: "sm",
|
|
2049
|
+
onClick: () => {
|
|
2050
|
+
let e = new Blob([i], { type: n ? "application/json" : "text/plain" }), t = URL.createObjectURL(e), r = document.createElement("a");
|
|
2051
|
+
r.href = t, r.download = n ? "response.json" : "response-headers.txt", r.click(), URL.revokeObjectURL(t);
|
|
2052
|
+
},
|
|
2053
|
+
children: /* @__PURE__ */ c(x, {
|
|
2054
|
+
name: "download",
|
|
2055
|
+
size: 14
|
|
2056
|
+
})
|
|
2057
|
+
}),
|
|
2058
|
+
/* @__PURE__ */ c(O, {
|
|
2059
|
+
"aria-label": "Share response",
|
|
2060
|
+
variant: "surface",
|
|
2061
|
+
size: "sm",
|
|
2062
|
+
onClick: async () => {
|
|
2063
|
+
if (navigator.share) try {
|
|
2064
|
+
await navigator.share({
|
|
2065
|
+
title: "API response",
|
|
2066
|
+
text: i
|
|
2067
|
+
});
|
|
2068
|
+
} catch {}
|
|
2069
|
+
else await navigator.clipboard?.writeText(i);
|
|
2070
|
+
},
|
|
2071
|
+
children: /* @__PURE__ */ c(x, {
|
|
2072
|
+
name: "share",
|
|
2073
|
+
size: 14
|
|
2074
|
+
})
|
|
2075
|
+
}),
|
|
2076
|
+
/* @__PURE__ */ c(j, {
|
|
2077
|
+
value: i,
|
|
2078
|
+
size: "sm"
|
|
2079
|
+
})
|
|
2080
|
+
]
|
|
2081
|
+
}), /* @__PURE__ */ c(W, {
|
|
2082
|
+
code: i,
|
|
2083
|
+
language: n ? "json" : "plain",
|
|
2084
|
+
copyable: !1,
|
|
2085
|
+
reveal: !0,
|
|
2086
|
+
className: "pr-28"
|
|
2087
|
+
})]
|
|
2088
|
+
});
|
|
2089
|
+
};
|
|
2090
|
+
function et(e) {
|
|
2091
|
+
let t = Math.max(0, Math.round((Date.now() - e) / 1e3));
|
|
2092
|
+
if (t < 5) return "just now";
|
|
2093
|
+
if (t < 60) return `${t}s ago`;
|
|
2094
|
+
let n = Math.round(t / 60);
|
|
2095
|
+
return n < 60 ? `${n}m ago` : `${Math.round(n / 60)}h ago`;
|
|
2096
|
+
}
|
|
2097
|
+
var tt = ({ entries: e, onSelect: t, onClear: n }) => e.length === 0 ? /* @__PURE__ */ l("div", {
|
|
2098
|
+
className: "flex flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-border px-6 py-10 text-center",
|
|
2099
|
+
children: [
|
|
2100
|
+
/* @__PURE__ */ c(x, {
|
|
2101
|
+
name: "restart",
|
|
2102
|
+
className: "h-6 w-6 text-muted"
|
|
2103
|
+
}),
|
|
2104
|
+
/* @__PURE__ */ c("p", {
|
|
2105
|
+
className: "text-sm font-medium text-content",
|
|
2106
|
+
children: "No requests yet"
|
|
2107
|
+
}),
|
|
2108
|
+
/* @__PURE__ */ c("p", {
|
|
2109
|
+
className: "text-xs text-muted",
|
|
2110
|
+
children: "Requests you send will show up here."
|
|
2111
|
+
})
|
|
2112
|
+
]
|
|
2113
|
+
}) : /* @__PURE__ */ l("div", {
|
|
2114
|
+
className: "space-y-2",
|
|
2115
|
+
children: [/* @__PURE__ */ l("div", {
|
|
2116
|
+
className: "flex items-center justify-between px-0.5",
|
|
2117
|
+
children: [/* @__PURE__ */ l("span", {
|
|
2118
|
+
className: "text-xs text-muted",
|
|
2119
|
+
children: [
|
|
2120
|
+
e.length,
|
|
2121
|
+
" request",
|
|
2122
|
+
e.length === 1 ? "" : "s"
|
|
2123
|
+
]
|
|
2124
|
+
}), /* @__PURE__ */ c("button", {
|
|
2125
|
+
type: "button",
|
|
2126
|
+
onClick: n,
|
|
2127
|
+
className: "text-xs text-muted transition-colors hover:text-content",
|
|
2128
|
+
children: "Clear"
|
|
2129
|
+
})]
|
|
2130
|
+
}), /* @__PURE__ */ c("ul", {
|
|
2131
|
+
className: "overflow-hidden rounded-lg border border-border",
|
|
2132
|
+
children: e.map((e) => /* @__PURE__ */ c("li", {
|
|
2133
|
+
className: "border-b border-border last:border-b-0",
|
|
2134
|
+
children: /* @__PURE__ */ l("button", {
|
|
2135
|
+
type: "button",
|
|
2136
|
+
onClick: () => t(e),
|
|
2137
|
+
className: "flex w-full items-center gap-3 px-3 py-2.5 text-left transition-colors hover:bg-surface-2",
|
|
2138
|
+
children: [
|
|
2139
|
+
/* @__PURE__ */ c(F, {
|
|
2140
|
+
method: e.request.method,
|
|
2141
|
+
className: "shrink-0"
|
|
2142
|
+
}),
|
|
2143
|
+
/* @__PURE__ */ c("span", {
|
|
2144
|
+
className: "min-w-0 flex-1 truncate font-mono text-[13px] text-content",
|
|
2145
|
+
children: e.request.url
|
|
2146
|
+
}),
|
|
2147
|
+
/* @__PURE__ */ c(I, {
|
|
2148
|
+
status: e.response.status,
|
|
2149
|
+
statusText: e.response.statusText,
|
|
2150
|
+
className: "shrink-0"
|
|
2151
|
+
}),
|
|
2152
|
+
/* @__PURE__ */ l("span", {
|
|
2153
|
+
className: "hidden shrink-0 tabular-nums text-xs text-muted sm:inline",
|
|
2154
|
+
children: [e.response.timeMs, "ms"]
|
|
2155
|
+
}),
|
|
2156
|
+
/* @__PURE__ */ c("span", {
|
|
2157
|
+
className: "hidden shrink-0 text-xs text-muted md:inline",
|
|
2158
|
+
children: et(e.at)
|
|
2159
|
+
})
|
|
2160
|
+
]
|
|
2161
|
+
})
|
|
2162
|
+
}, Y(e.request)))
|
|
2163
|
+
})]
|
|
2164
|
+
});
|
|
2165
|
+
async function nt(e, t) {
|
|
2166
|
+
let n = performance.now();
|
|
2167
|
+
try {
|
|
2168
|
+
return t ? await t(e) : await Ce(e);
|
|
2169
|
+
} catch (e) {
|
|
2170
|
+
return G(e, n);
|
|
2171
|
+
}
|
|
2172
|
+
}
|
|
2173
|
+
var rt = ({ request: e, onRequestChange: t, onSend: n, editable: r = !0, onBack: a, onImport: u, className: d }) => {
|
|
2174
|
+
let f = i(() => Me(e), [e]), p = i(() => Ne(e, f), [e, f]), m = Ge(e.body ?? Le), h = e.body ?? "", [g, _] = o("body"), [v, b] = o("response"), [S, C] = o("body"), [w, E] = o(!1), [D, O] = o([]), [k, A] = o(null), [j, M] = o(null), N = i(() => we(e), [e]), P = j ?? N, F = p.filter((e) => e.enabled).length, L = ze.map((e) => e.id === "headers" ? {
|
|
2175
|
+
...e,
|
|
2176
|
+
badge: F
|
|
2177
|
+
} : e), R = (n) => {
|
|
2178
|
+
if (!r) return;
|
|
2179
|
+
let i = Ie(e, {
|
|
2180
|
+
method: e.method,
|
|
2181
|
+
url: e.url,
|
|
2182
|
+
body: h,
|
|
2183
|
+
auth: f,
|
|
2184
|
+
headers: p,
|
|
2185
|
+
...n
|
|
2186
|
+
});
|
|
2187
|
+
t?.(i);
|
|
2188
|
+
};
|
|
2189
|
+
return /* @__PURE__ */ l("div", {
|
|
2190
|
+
className: y("space-y-3", d),
|
|
2191
|
+
children: [/* @__PURE__ */ l(z, {
|
|
2192
|
+
flush: !0,
|
|
2193
|
+
children: [
|
|
2194
|
+
/* @__PURE__ */ l("div", {
|
|
2195
|
+
className: "p-3",
|
|
2196
|
+
children: [/* @__PURE__ */ l("div", {
|
|
2197
|
+
className: "mb-4 flex items-center justify-between gap-3",
|
|
2198
|
+
children: [/* @__PURE__ */ l("div", {
|
|
2199
|
+
className: "flex min-w-0 items-center gap-3",
|
|
2200
|
+
children: [a && /* @__PURE__ */ c("button", {
|
|
2201
|
+
type: "button",
|
|
2202
|
+
"aria-label": "Back to request snippets",
|
|
2203
|
+
onClick: a,
|
|
2204
|
+
className: "inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-content transition-colors hover:bg-surface-2",
|
|
2205
|
+
children: /* @__PURE__ */ c(x, {
|
|
2206
|
+
name: "arrow-left",
|
|
2207
|
+
className: "h-5 w-5"
|
|
2208
|
+
})
|
|
2209
|
+
}), /* @__PURE__ */ c("div", {
|
|
2210
|
+
className: "font-heading text-sm font-semibold text-content",
|
|
2211
|
+
children: "Try it Out"
|
|
2212
|
+
})]
|
|
2213
|
+
}), r && u && /* @__PURE__ */ c(T, {
|
|
2214
|
+
type: "button",
|
|
2215
|
+
size: "sm",
|
|
2216
|
+
variant: "ghost",
|
|
2217
|
+
onClick: u,
|
|
2218
|
+
leftIcon: /* @__PURE__ */ c(x, {
|
|
2219
|
+
name: "download",
|
|
2220
|
+
className: "h-4 w-4"
|
|
2221
|
+
}),
|
|
2222
|
+
children: "Import"
|
|
2223
|
+
})]
|
|
2224
|
+
}), /* @__PURE__ */ c(Je, {
|
|
2225
|
+
method: e.method,
|
|
2226
|
+
url: e.url,
|
|
2227
|
+
isSending: w,
|
|
2228
|
+
editable: r,
|
|
2229
|
+
onMethodChange: (e) => R({ method: e }),
|
|
2230
|
+
onUrlChange: (e) => R({ url: e }),
|
|
2231
|
+
onSend: async () => {
|
|
2232
|
+
let t = Ie(e, {
|
|
2233
|
+
method: e.method,
|
|
2234
|
+
url: e.url,
|
|
2235
|
+
body: h,
|
|
2236
|
+
auth: f,
|
|
2237
|
+
headers: p
|
|
2238
|
+
}), r = Y(t);
|
|
2239
|
+
E(!0);
|
|
2240
|
+
let i = await nt(t, n);
|
|
2241
|
+
E(!1), M(i), b("response"), O((e) => [{
|
|
2242
|
+
request: t,
|
|
2243
|
+
response: i,
|
|
2244
|
+
at: Date.now()
|
|
2245
|
+
}, ...e.filter((e) => Y(e.request) !== r)].slice(0, 25));
|
|
2246
|
+
}
|
|
2247
|
+
})]
|
|
2248
|
+
}),
|
|
2249
|
+
/* @__PURE__ */ l("div", {
|
|
2250
|
+
className: "flex items-center justify-between gap-3 border-y border-border px-3",
|
|
2251
|
+
children: [/* @__PURE__ */ c(B, {
|
|
2252
|
+
items: L,
|
|
2253
|
+
activeId: g,
|
|
2254
|
+
onChange: (e) => _(e),
|
|
2255
|
+
className: "border-b-0"
|
|
2256
|
+
}), g === "body" && /* @__PURE__ */ c(T, {
|
|
2257
|
+
type: "button",
|
|
2258
|
+
size: "sm",
|
|
2259
|
+
variant: "ghost",
|
|
2260
|
+
onClick: () => {
|
|
2261
|
+
try {
|
|
2262
|
+
R({ body: We(m) }), A(null);
|
|
2263
|
+
} catch {
|
|
2264
|
+
A("Invalid JSON");
|
|
2265
|
+
}
|
|
2266
|
+
},
|
|
2267
|
+
disabled: !r,
|
|
2268
|
+
leftIcon: /* @__PURE__ */ c(x, {
|
|
2269
|
+
name: "magic",
|
|
2270
|
+
className: "h-4 w-4"
|
|
2271
|
+
}),
|
|
2272
|
+
children: "Format"
|
|
2273
|
+
})]
|
|
2274
|
+
}),
|
|
2275
|
+
/* @__PURE__ */ c("div", {
|
|
2276
|
+
className: "p-3",
|
|
2277
|
+
children: /* @__PURE__ */ c(Qe, {
|
|
2278
|
+
activeTab: g,
|
|
2279
|
+
auth: f,
|
|
2280
|
+
headers: p,
|
|
2281
|
+
body: m,
|
|
2282
|
+
bodyError: k,
|
|
2283
|
+
editable: r,
|
|
2284
|
+
onAuthChange: (e) => {
|
|
2285
|
+
R({
|
|
2286
|
+
auth: e,
|
|
2287
|
+
headers: Pe(p, e, f)
|
|
2288
|
+
});
|
|
2289
|
+
},
|
|
2290
|
+
onHeaderUpdate: (e, t) => {
|
|
2291
|
+
let n = p[e], r = p.map((n, r) => r === e ? {
|
|
2292
|
+
...n,
|
|
2293
|
+
...t
|
|
2294
|
+
} : n), i = r[e];
|
|
2295
|
+
R({
|
|
2296
|
+
auth: i && (n && J(n, f) || J(i, f) || q(i.key, X)) ? i.enabled ? Ae(i) : { type: "none" } : f,
|
|
2297
|
+
headers: r
|
|
2298
|
+
});
|
|
2299
|
+
},
|
|
2300
|
+
onHeaderRemove: (e) => {
|
|
2301
|
+
let t = p[e];
|
|
2302
|
+
R({
|
|
2303
|
+
auth: t && (J(t, f) || q(t.key, X)) ? { type: "none" } : f,
|
|
2304
|
+
headers: p.filter((t, n) => n !== e)
|
|
2305
|
+
});
|
|
2306
|
+
},
|
|
2307
|
+
onHeaderAdd: () => {
|
|
2308
|
+
R({ headers: [...p, {
|
|
2309
|
+
key: "",
|
|
2310
|
+
value: "",
|
|
2311
|
+
enabled: !0
|
|
2312
|
+
}] });
|
|
2313
|
+
},
|
|
2314
|
+
onBodyChange: (e) => R({ body: e }),
|
|
2315
|
+
onBodyErrorClear: () => A(null)
|
|
2316
|
+
})
|
|
2317
|
+
})
|
|
2318
|
+
]
|
|
2319
|
+
}), /* @__PURE__ */ l(z, {
|
|
2320
|
+
flush: !0,
|
|
2321
|
+
children: [/* @__PURE__ */ l("div", {
|
|
2322
|
+
className: "flex flex-wrap items-center justify-between gap-3 border-b border-border px-3",
|
|
2323
|
+
children: [/* @__PURE__ */ c(B, {
|
|
2324
|
+
items: Be,
|
|
2325
|
+
activeId: v,
|
|
2326
|
+
onChange: (e) => b(e),
|
|
2327
|
+
className: "border-b-0"
|
|
2328
|
+
}), v === "response" && /* @__PURE__ */ c(qe, {
|
|
2329
|
+
value: S,
|
|
2330
|
+
onChange: C
|
|
2331
|
+
})]
|
|
2332
|
+
}), v === "response" ? /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ l("div", {
|
|
2333
|
+
className: "flex flex-wrap items-center gap-5 border-b border-border px-3 py-3 text-xs text-muted",
|
|
2334
|
+
children: [
|
|
2335
|
+
/* @__PURE__ */ c(I, {
|
|
2336
|
+
status: P.status,
|
|
2337
|
+
statusText: P.statusText
|
|
2338
|
+
}),
|
|
2339
|
+
/* @__PURE__ */ l("span", { children: [P.timeMs, "ms"] }),
|
|
2340
|
+
/* @__PURE__ */ c("span", { children: P.size })
|
|
2341
|
+
]
|
|
2342
|
+
}), /* @__PURE__ */ c($e, {
|
|
2343
|
+
responsePanel: S,
|
|
2344
|
+
response: P
|
|
2345
|
+
})] }) : /* @__PURE__ */ c("div", {
|
|
2346
|
+
className: "p-3",
|
|
2347
|
+
children: /* @__PURE__ */ c(tt, {
|
|
2348
|
+
entries: D,
|
|
2349
|
+
onSelect: (e) => {
|
|
2350
|
+
t?.(e.request), M(e.response), b("response");
|
|
2351
|
+
},
|
|
2352
|
+
onClear: () => O([])
|
|
2353
|
+
})
|
|
2354
|
+
})]
|
|
2355
|
+
})]
|
|
2356
|
+
});
|
|
2357
|
+
}, it = [
|
|
2358
|
+
"GET",
|
|
2359
|
+
"POST",
|
|
2360
|
+
"PUT",
|
|
2361
|
+
"PATCH",
|
|
2362
|
+
"DELETE"
|
|
2363
|
+
], at = /* @__PURE__ */ new Set([
|
|
2364
|
+
"-d",
|
|
2365
|
+
"--data",
|
|
2366
|
+
"--data-raw",
|
|
2367
|
+
"--data-binary",
|
|
2368
|
+
"--data-ascii"
|
|
2369
|
+
]), ot = /* @__PURE__ */ new Set(["-H", "--header"]), st = /* @__PURE__ */ new Set(["-X", "--request"]), ct = /* @__PURE__ */ new Set(["--url"]), lt = "authorization", ut = "Bearer ";
|
|
2370
|
+
function dt(e) {
|
|
2371
|
+
return e.replace(/\\\s*\n\s*/g, " ").trim();
|
|
2372
|
+
}
|
|
2373
|
+
function ft(e) {
|
|
2374
|
+
return e.trim().replace(/^```(?:bash|sh|shell|zsh|curl)?\s*/i, "").replace(/\s*```$/i, "").replace(/^\s*[$>]\s*/gm, "").replace(/\\n/g, "\n").replace(/\\"/g, "\"").replace(/\\'/g, "'");
|
|
2375
|
+
}
|
|
2376
|
+
function pt(e) {
|
|
2377
|
+
let t = [], n = "", r = null, i = !1, a = dt(ft(e)), o = () => {
|
|
2378
|
+
n &&= (t.push(n), "");
|
|
2379
|
+
};
|
|
2380
|
+
for (let e = 0; e < a.length; e++) {
|
|
2381
|
+
let t = a[e];
|
|
2382
|
+
if (i) {
|
|
2383
|
+
n += t, i = !1;
|
|
2384
|
+
continue;
|
|
2385
|
+
}
|
|
2386
|
+
if (t === "\\" && r !== "'") {
|
|
2387
|
+
let t = a[e + 1];
|
|
2388
|
+
if (!r && t === "n") {
|
|
2389
|
+
o(), e++;
|
|
2390
|
+
continue;
|
|
2391
|
+
}
|
|
2392
|
+
if (!r && t && /\s/.test(t)) {
|
|
2393
|
+
for (o(); e + 1 < a.length && /\s/.test(a[e + 1]);) e++;
|
|
2394
|
+
continue;
|
|
2395
|
+
}
|
|
2396
|
+
i = !0;
|
|
2397
|
+
continue;
|
|
2398
|
+
}
|
|
2399
|
+
if ((t === "\"" || t === "'") && (!r || r === t)) {
|
|
2400
|
+
r = r ? null : t;
|
|
2401
|
+
continue;
|
|
2402
|
+
}
|
|
2403
|
+
if (!r && /\s/.test(t)) {
|
|
2404
|
+
o();
|
|
2405
|
+
continue;
|
|
2406
|
+
}
|
|
2407
|
+
n += t;
|
|
2408
|
+
}
|
|
2409
|
+
return i && (n += "\\"), o(), t;
|
|
2410
|
+
}
|
|
2411
|
+
function mt(e) {
|
|
2412
|
+
let t = e.findIndex((e) => e === "curl" || e.endsWith("/curl"));
|
|
2413
|
+
return t >= 0 ? e.slice(t + 1) : e;
|
|
2414
|
+
}
|
|
2415
|
+
function ht(e) {
|
|
2416
|
+
return /^(?:https?:\/\/\S+|\/\S*|[A-Za-z0-9.-]+\.[A-Za-z]{2,}\S*)$/.test(e);
|
|
2417
|
+
}
|
|
2418
|
+
function Z(e) {
|
|
2419
|
+
return e.startsWith("http://") || e.startsWith("https://") || e.startsWith("/") ? e : `https://${e}`;
|
|
2420
|
+
}
|
|
2421
|
+
function gt(e) {
|
|
2422
|
+
let t = e.toUpperCase();
|
|
2423
|
+
return it.includes(t) ? t : null;
|
|
2424
|
+
}
|
|
2425
|
+
function _t(e) {
|
|
2426
|
+
let t = e.indexOf(":");
|
|
2427
|
+
return t < 0 ? null : {
|
|
2428
|
+
key: e.slice(0, t).trim(),
|
|
2429
|
+
value: e.slice(t + 1).trim()
|
|
2430
|
+
};
|
|
2431
|
+
}
|
|
2432
|
+
function vt(e) {
|
|
2433
|
+
let t = e.find((e) => e.key.toLowerCase() === lt);
|
|
2434
|
+
if (t) return t.value.toLowerCase().startsWith(ut.toLowerCase()) ? {
|
|
2435
|
+
type: "bearer",
|
|
2436
|
+
token: t.value.slice(7)
|
|
2437
|
+
} : {
|
|
2438
|
+
type: "apiKey",
|
|
2439
|
+
key: t.key,
|
|
2440
|
+
value: t.value,
|
|
2441
|
+
in: "header"
|
|
2442
|
+
};
|
|
2443
|
+
}
|
|
2444
|
+
function yt(e) {
|
|
2445
|
+
try {
|
|
2446
|
+
return JSON.stringify(JSON.parse(e), null, 2);
|
|
2447
|
+
} catch {
|
|
2448
|
+
return e;
|
|
2449
|
+
}
|
|
2450
|
+
}
|
|
2451
|
+
function Q(e) {
|
|
2452
|
+
let t = mt(pt(e));
|
|
2453
|
+
if (t.length === 0) return null;
|
|
2454
|
+
let n = [], r = [], i = null, a = "";
|
|
2455
|
+
for (let e = 0; e < t.length; e++) {
|
|
2456
|
+
let o = t[e], s = t[e + 1];
|
|
2457
|
+
if (st.has(o) && s) {
|
|
2458
|
+
i = gt(s) ?? i, e++;
|
|
2459
|
+
continue;
|
|
2460
|
+
}
|
|
2461
|
+
if (o.startsWith("-X") && o.length > 2) {
|
|
2462
|
+
i = gt(o.slice(2)) ?? i;
|
|
2463
|
+
continue;
|
|
2464
|
+
}
|
|
2465
|
+
if (ot.has(o) && s) {
|
|
2466
|
+
let t = _t(s);
|
|
2467
|
+
t && n.push(t), e++;
|
|
2468
|
+
continue;
|
|
2469
|
+
}
|
|
2470
|
+
if (o.startsWith("-H") && o.length > 2) {
|
|
2471
|
+
let e = _t(o.slice(2));
|
|
2472
|
+
e && n.push(e);
|
|
2473
|
+
continue;
|
|
2474
|
+
}
|
|
2475
|
+
if (at.has(o) && s !== void 0) {
|
|
2476
|
+
r.push(s), e++;
|
|
2477
|
+
continue;
|
|
2478
|
+
}
|
|
2479
|
+
let c = [...at].find((e) => o.startsWith(`${e}=`));
|
|
2480
|
+
if (c) {
|
|
2481
|
+
r.push(o.slice(c.length + 1));
|
|
2482
|
+
continue;
|
|
2483
|
+
}
|
|
2484
|
+
if (ct.has(o) && s) {
|
|
2485
|
+
a = Z(s), e++;
|
|
2486
|
+
continue;
|
|
2487
|
+
}
|
|
2488
|
+
if (o.startsWith("--url=")) {
|
|
2489
|
+
a = Z(o.slice(6));
|
|
2490
|
+
continue;
|
|
2491
|
+
}
|
|
2492
|
+
!o.startsWith("-") && ht(o) && (a = Z(o));
|
|
2493
|
+
}
|
|
2494
|
+
if (!a) return null;
|
|
2495
|
+
let o = r.length ? yt(r.join("&")) : "", s = i ?? (o ? "POST" : "GET"), c = vt(n);
|
|
2496
|
+
return {
|
|
2497
|
+
title: "Imported request",
|
|
2498
|
+
method: s,
|
|
2499
|
+
url: a,
|
|
2500
|
+
headers: c ? n.filter((e) => e.key.toLowerCase() !== lt) : n,
|
|
2501
|
+
auth: c,
|
|
2502
|
+
body: o || void 0
|
|
2503
|
+
};
|
|
2504
|
+
}
|
|
2505
|
+
//#endregion
|
|
2506
|
+
//#region src/features/api-widget/ImportCard.tsx
|
|
2507
|
+
var bt = "curl -X POST 'https://jsonplaceholder.typicode.com/posts' \\\n -H 'Content-Type: application/json' \\\n -d '{ \"title\": \"API client\", \"body\": \"Live request\", \"userId\": 1 }'", xt = ({ onImport: e, onCancel: t, className: n }) => {
|
|
2508
|
+
let [r, i] = o(""), [a, s] = o(null);
|
|
2509
|
+
return /* @__PURE__ */ c(z, {
|
|
2510
|
+
flush: !0,
|
|
2511
|
+
className: n,
|
|
2512
|
+
children: /* @__PURE__ */ l("div", {
|
|
2513
|
+
className: "space-y-4 p-3",
|
|
2514
|
+
children: [
|
|
2515
|
+
/* @__PURE__ */ l("div", {
|
|
2516
|
+
className: "flex items-center gap-3",
|
|
2517
|
+
children: [t && /* @__PURE__ */ c("button", {
|
|
2518
|
+
type: "button",
|
|
2519
|
+
"aria-label": "Back",
|
|
2520
|
+
onClick: t,
|
|
2521
|
+
className: "inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-content transition-colors hover:bg-surface-2",
|
|
2522
|
+
children: /* @__PURE__ */ c(x, {
|
|
2523
|
+
name: "arrow-left",
|
|
2524
|
+
className: "h-5 w-5"
|
|
2525
|
+
})
|
|
2526
|
+
}), /* @__PURE__ */ c("div", {
|
|
2527
|
+
className: "font-heading text-sm font-semibold text-content",
|
|
2528
|
+
children: "Import"
|
|
2529
|
+
})]
|
|
2530
|
+
}),
|
|
2531
|
+
/* @__PURE__ */ c("p", {
|
|
2532
|
+
className: "text-xs text-muted",
|
|
2533
|
+
children: "Paste a cURL command to populate the request."
|
|
2534
|
+
}),
|
|
2535
|
+
/* @__PURE__ */ c("textarea", {
|
|
2536
|
+
value: r,
|
|
2537
|
+
onChange: (e) => {
|
|
2538
|
+
i(e.target.value), a && s(null);
|
|
2539
|
+
},
|
|
2540
|
+
spellCheck: !1,
|
|
2541
|
+
rows: 5,
|
|
2542
|
+
placeholder: bt,
|
|
2543
|
+
"aria-label": "cURL command",
|
|
2544
|
+
className: y("w-full resize-none rounded-lg border bg-surface-2 p-3 font-mono text-[13px] leading-relaxed text-content outline-none", "placeholder:text-muted/50 focus:ring-2 focus:ring-primary/20", a ? "border-red-500/60" : "border-border focus:border-primary/60")
|
|
2545
|
+
}),
|
|
2546
|
+
a && /* @__PURE__ */ c("p", {
|
|
2547
|
+
className: "text-xs text-red-400",
|
|
2548
|
+
children: a
|
|
2549
|
+
}),
|
|
2550
|
+
/* @__PURE__ */ c("div", {
|
|
2551
|
+
className: "flex items-center justify-end",
|
|
2552
|
+
children: /* @__PURE__ */ c(T, {
|
|
2553
|
+
size: "sm",
|
|
2554
|
+
onClick: () => {
|
|
2555
|
+
let t = Q(r);
|
|
2556
|
+
if (!t) {
|
|
2557
|
+
s("Could not parse a valid cURL command. Make sure it includes a URL.");
|
|
2558
|
+
return;
|
|
2559
|
+
}
|
|
2560
|
+
e(t, r), i(""), s(null);
|
|
2561
|
+
},
|
|
2562
|
+
disabled: !r.trim(),
|
|
2563
|
+
leftIcon: /* @__PURE__ */ c(x, {
|
|
2564
|
+
name: "download",
|
|
2565
|
+
className: "h-4 w-4"
|
|
2566
|
+
}),
|
|
2567
|
+
children: "Import"
|
|
2568
|
+
})
|
|
2569
|
+
})
|
|
2570
|
+
]
|
|
2571
|
+
})
|
|
2572
|
+
});
|
|
2573
|
+
}, St = [
|
|
2574
|
+
{
|
|
2575
|
+
id: "curl",
|
|
2576
|
+
label: "cURL"
|
|
2577
|
+
},
|
|
2578
|
+
{
|
|
2579
|
+
id: "javascript",
|
|
2580
|
+
label: "Javascript"
|
|
2581
|
+
},
|
|
2582
|
+
{
|
|
2583
|
+
id: "python",
|
|
2584
|
+
label: "Python"
|
|
2585
|
+
},
|
|
2586
|
+
{
|
|
2587
|
+
id: "go",
|
|
2588
|
+
label: "Go"
|
|
2589
|
+
}
|
|
2590
|
+
];
|
|
2591
|
+
function Ct(e) {
|
|
2592
|
+
return e === "curl" ? "bash" : e;
|
|
2593
|
+
}
|
|
2594
|
+
function wt(e) {
|
|
2595
|
+
return !e || e.type === "none" ? null : e.type === "bearer" ? {
|
|
2596
|
+
key: "Authorization",
|
|
2597
|
+
value: `Bearer ${e.token}`
|
|
2598
|
+
} : {
|
|
2599
|
+
key: e.key,
|
|
2600
|
+
value: e.value
|
|
2601
|
+
};
|
|
2602
|
+
}
|
|
2603
|
+
function $(e) {
|
|
2604
|
+
let t = wt(e.auth);
|
|
2605
|
+
return t ? [...(e.headers ?? []).filter((e) => e.key.toLowerCase() !== t.key.toLowerCase()), t] : e.headers ?? [];
|
|
2606
|
+
}
|
|
2607
|
+
function Tt(e) {
|
|
2608
|
+
let t = `curl -X ${e.method} '${e.url}'`;
|
|
2609
|
+
for (let n of $(e)) t += ` \\\n -H '${n.key}: ${n.value}'`;
|
|
2610
|
+
return e.body && (t += ` \\\n -d '${e.body}'`), t;
|
|
2611
|
+
}
|
|
2612
|
+
function Et(e) {
|
|
2613
|
+
let t = [`method: '${e.method}'`], n = $(e);
|
|
2614
|
+
if (n.length) {
|
|
2615
|
+
let e = n.map((e) => ` '${e.key}': '${e.value}'`).join(",\n");
|
|
2616
|
+
t.push(`headers: {\n${e}\n }`);
|
|
2617
|
+
}
|
|
2618
|
+
return e.body && t.push(`body: JSON.stringify(${e.body})`), [
|
|
2619
|
+
`const res = await fetch('${e.url}', {`,
|
|
2620
|
+
` ${t.join(",\n ")},`,
|
|
2621
|
+
"});",
|
|
2622
|
+
"",
|
|
2623
|
+
"const data = await res.json();",
|
|
2624
|
+
"console.log(data);"
|
|
2625
|
+
].join("\n");
|
|
2626
|
+
}
|
|
2627
|
+
function Dt(e) {
|
|
2628
|
+
let t = [
|
|
2629
|
+
"import requests",
|
|
2630
|
+
"",
|
|
2631
|
+
`url = "${e.url}"`
|
|
2632
|
+
], n = ["url"], r = $(e);
|
|
2633
|
+
if (r.length) {
|
|
2634
|
+
t.push("", "headers = {");
|
|
2635
|
+
for (let e of r) t.push(` "${e.key}": "${e.value}",`);
|
|
2636
|
+
t.push("}"), n.push("headers=headers");
|
|
2637
|
+
}
|
|
2638
|
+
return e.body && (t.push("", `payload = ${e.body}`), n.push("json=payload")), t.push("", `response = requests.${e.method.toLowerCase()}(${n.join(", ")})`, "print(response.json())"), t.join("\n");
|
|
2639
|
+
}
|
|
2640
|
+
function Ot(e) {
|
|
2641
|
+
let t = [
|
|
2642
|
+
"\"fmt\"",
|
|
2643
|
+
"\"io\"",
|
|
2644
|
+
"\"net/http\""
|
|
2645
|
+
];
|
|
2646
|
+
e.body && t.push("\"strings\"");
|
|
2647
|
+
let n = [
|
|
2648
|
+
"package main",
|
|
2649
|
+
"",
|
|
2650
|
+
"import ("
|
|
2651
|
+
];
|
|
2652
|
+
for (let e of t) n.push(`\t${e}`);
|
|
2653
|
+
n.push(")", "", "func main() {"), e.body ? (n.push(`\tpayload := strings.NewReader(\`${e.body}\`)`), n.push(`\treq, _ := http.NewRequest("${e.method}", "${e.url}", payload)`)) : n.push(`\treq, _ := http.NewRequest("${e.method}", "${e.url}", nil)`);
|
|
2654
|
+
for (let t of $(e)) n.push(`\treq.Header.Set("${t.key}", "${t.value}")`);
|
|
2655
|
+
return n.push(" res, _ := http.DefaultClient.Do(req)", " defer res.Body.Close()", "", " body, _ := io.ReadAll(res.Body)", " fmt.Println(string(body))", "}"), n.join("\n");
|
|
2656
|
+
}
|
|
2657
|
+
function kt(e, t) {
|
|
2658
|
+
switch (t) {
|
|
2659
|
+
case "curl": return Tt(e);
|
|
2660
|
+
case "javascript": return Et(e);
|
|
2661
|
+
case "python": return Dt(e);
|
|
2662
|
+
case "go": return Ot(e);
|
|
2663
|
+
}
|
|
2664
|
+
}
|
|
2665
|
+
//#endregion
|
|
2666
|
+
//#region src/features/api-widget/RequestSnippet.tsx
|
|
2667
|
+
var At = ({ request: e, onTryItOut: t }) => {
|
|
2668
|
+
let [n, r] = o("curl"), a = i(() => kt(e, n), [e, n]), s = !!t;
|
|
2669
|
+
return /* @__PURE__ */ l("div", {
|
|
2670
|
+
className: "space-y-3",
|
|
2671
|
+
children: [/* @__PURE__ */ l(z, {
|
|
2672
|
+
label: e.title,
|
|
2673
|
+
children: [/* @__PURE__ */ l("div", {
|
|
2674
|
+
className: "relative flex items-center justify-between",
|
|
2675
|
+
children: [/* @__PURE__ */ c(B, {
|
|
2676
|
+
items: St,
|
|
2677
|
+
activeId: n,
|
|
2678
|
+
onChange: (e) => {
|
|
2679
|
+
r(e);
|
|
2680
|
+
},
|
|
2681
|
+
className: "[&_button]:text-[14px]"
|
|
2682
|
+
}), s && /* @__PURE__ */ c(T, {
|
|
2683
|
+
size: "sm",
|
|
2684
|
+
variant: "primary",
|
|
2685
|
+
onClick: t,
|
|
2686
|
+
rightIcon: /* @__PURE__ */ c(x, {
|
|
2687
|
+
name: "arrow-right",
|
|
2688
|
+
className: "h-4 w-4"
|
|
2689
|
+
}),
|
|
2690
|
+
children: "Try it"
|
|
2691
|
+
})]
|
|
2692
|
+
}), /* @__PURE__ */ c("div", {
|
|
2693
|
+
className: "mt-4",
|
|
2694
|
+
children: /* @__PURE__ */ c(W, {
|
|
2695
|
+
code: a,
|
|
2696
|
+
language: Ct(n),
|
|
2697
|
+
showLineNumbers: !0
|
|
2698
|
+
})
|
|
2699
|
+
})]
|
|
2700
|
+
}), e.sampleResponse && /* @__PURE__ */ c(z, {
|
|
2701
|
+
label: "",
|
|
2702
|
+
children: /* @__PURE__ */ c(W, {
|
|
2703
|
+
code: e.sampleResponse,
|
|
2704
|
+
language: "json"
|
|
2705
|
+
})
|
|
2706
|
+
})]
|
|
2707
|
+
});
|
|
2708
|
+
};
|
|
2709
|
+
//#endregion
|
|
2710
|
+
//#region src/features/api-widget/ApiWidget.tsx
|
|
2711
|
+
function jt(e) {
|
|
2712
|
+
let [n, r] = o(() => typeof window < "u" && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light");
|
|
2713
|
+
return t(() => {
|
|
2714
|
+
if (e !== "system") return;
|
|
2715
|
+
let t = window.matchMedia("(prefers-color-scheme: dark)"), n = () => r(t.matches ? "dark" : "light");
|
|
2716
|
+
return n(), t.addEventListener("change", n), () => t.removeEventListener("change", n);
|
|
2717
|
+
}, [e]), e === "system" ? n : e;
|
|
2718
|
+
}
|
|
2719
|
+
function Mt(e) {
|
|
2720
|
+
try {
|
|
2721
|
+
let t = new URL(e.url);
|
|
2722
|
+
return `${e.method} ${t.pathname || "/"}`;
|
|
2723
|
+
} catch {
|
|
2724
|
+
return `${e.method} ${e.url || "/"}`;
|
|
2725
|
+
}
|
|
2726
|
+
}
|
|
2727
|
+
var Nt = ({ request: e, allowImport: t, editable: n, onTryImport: r }) => /* @__PURE__ */ l(z, {
|
|
2728
|
+
label: "Invalid request",
|
|
2729
|
+
children: [
|
|
2730
|
+
/* @__PURE__ */ l("div", {
|
|
2731
|
+
className: "relative flex items-center justify-between",
|
|
2732
|
+
children: [/* @__PURE__ */ c("div", {
|
|
2733
|
+
className: "text-sm font-medium text-content",
|
|
2734
|
+
children: "cURL"
|
|
2735
|
+
}), t && n && /* @__PURE__ */ c(T, {
|
|
2736
|
+
size: "sm",
|
|
2737
|
+
variant: "primary",
|
|
2738
|
+
onClick: r,
|
|
2739
|
+
rightIcon: /* @__PURE__ */ c(x, {
|
|
2740
|
+
name: "download",
|
|
2741
|
+
className: "h-4 w-4"
|
|
2742
|
+
}),
|
|
2743
|
+
children: "Import"
|
|
2744
|
+
})]
|
|
2745
|
+
}),
|
|
2746
|
+
/* @__PURE__ */ c("div", {
|
|
2747
|
+
className: "mt-4",
|
|
2748
|
+
children: /* @__PURE__ */ c(W, {
|
|
2749
|
+
code: e.trim() || "Paste or pass a cURL request with a URL.",
|
|
2750
|
+
language: "bash",
|
|
2751
|
+
showLineNumbers: !0
|
|
2752
|
+
})
|
|
2753
|
+
}),
|
|
2754
|
+
/* @__PURE__ */ c("p", {
|
|
2755
|
+
className: "mt-3 text-xs text-muted",
|
|
2756
|
+
children: "The request could not be parsed into a valid URL."
|
|
2757
|
+
})
|
|
2758
|
+
]
|
|
2759
|
+
});
|
|
2760
|
+
function Pt(e, t, n) {
|
|
2761
|
+
return {
|
|
2762
|
+
...e,
|
|
2763
|
+
title: t ?? Mt(e),
|
|
2764
|
+
sampleResponse: n
|
|
2765
|
+
};
|
|
2766
|
+
}
|
|
2767
|
+
var Ft = ({ request: e, title: n, sampleResponse: r, onUpdateRequest: a, editable: s = !0, allowImport: l = !0, mode: u = "dark", syncSnippet: d = !1, customization: f }) => {
|
|
2768
|
+
let p = jt(u), [m, h] = o("idle"), [g, _] = o(e);
|
|
2769
|
+
t(() => {
|
|
2770
|
+
_(e);
|
|
2771
|
+
}, [e]);
|
|
2772
|
+
let v = i(() => {
|
|
2773
|
+
let e = Q(g);
|
|
2774
|
+
return e ? Pt(e, n, r) : null;
|
|
2775
|
+
}, [
|
|
2776
|
+
g,
|
|
2777
|
+
n,
|
|
2778
|
+
r
|
|
2779
|
+
]), y = d ? g : e, b = i(() => {
|
|
2780
|
+
let e = Q(y);
|
|
2781
|
+
return e ? Pt(e, n, r) : null;
|
|
2782
|
+
}, [
|
|
2783
|
+
y,
|
|
2784
|
+
n,
|
|
2785
|
+
r
|
|
2786
|
+
]), x = (e) => {
|
|
2787
|
+
_(e), a?.(e);
|
|
2788
|
+
}, S = (e) => {
|
|
2789
|
+
x(kt(e, "curl"));
|
|
2790
|
+
}, C = (e, t) => {
|
|
2791
|
+
x(t.trim()), h("console");
|
|
2792
|
+
};
|
|
2793
|
+
return /* @__PURE__ */ c("div", {
|
|
2794
|
+
"data-theme": p,
|
|
2795
|
+
style: {
|
|
2796
|
+
...f?.primary ? { "--primary": f.primary } : {},
|
|
2797
|
+
...f?.background ? { "--bg": f.background } : {}
|
|
2798
|
+
},
|
|
2799
|
+
className: "bg-bg text-content text-left",
|
|
2800
|
+
children: m === "import" ? /* @__PURE__ */ c("div", {
|
|
2801
|
+
className: "motion-safe:animate-[widget-slide-in_180ms_ease-out]",
|
|
2802
|
+
children: /* @__PURE__ */ c(xt, {
|
|
2803
|
+
onImport: C,
|
|
2804
|
+
onCancel: () => h(v ? "console" : "idle")
|
|
2805
|
+
})
|
|
2806
|
+
}, "import") : m === "console" && v ? /* @__PURE__ */ c("div", {
|
|
2807
|
+
className: "motion-safe:animate-[widget-slide-in_180ms_ease-out]",
|
|
2808
|
+
children: /* @__PURE__ */ c(rt, {
|
|
2809
|
+
request: v,
|
|
2810
|
+
onRequestChange: S,
|
|
2811
|
+
editable: s,
|
|
2812
|
+
onBack: () => h("idle"),
|
|
2813
|
+
onImport: l && s ? () => h("import") : void 0
|
|
2814
|
+
})
|
|
2815
|
+
}, "console") : b ? /* @__PURE__ */ c(At, {
|
|
2816
|
+
request: b,
|
|
2817
|
+
onTryItOut: () => h("console")
|
|
2818
|
+
}) : /* @__PURE__ */ c(Nt, {
|
|
2819
|
+
request: y,
|
|
2820
|
+
allowImport: l,
|
|
2821
|
+
editable: s,
|
|
2822
|
+
onTryImport: () => h("import")
|
|
2823
|
+
})
|
|
2824
|
+
});
|
|
2825
|
+
};
|
|
2826
|
+
//#endregion
|
|
2827
|
+
export { rt as ApiConsole, Ft as ApiWidget, xt as ImportCard, At as RequestSnippet, St as SNIPPET_LANGUAGES, Ce as executeWidgetRequest, kt as generateSnippet, Ct as highlightFor, we as mockWidgetResponse, Q as parseCurl, G as widgetErrorResponse };
|