@scalar/api-reference 1.4.0 → 1.5.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.
@@ -0,0 +1,879 @@
1
+ import { defineComponent as R, useCssVars as ae, openBlock as f, createElementBlock as g, normalizeClass as T, createElementVNode as v, createCommentVNode as _, createStaticVNode as re, renderSlot as E, toDisplayString as x, createBlock as A, useAttrs as ie, ref as b, onMounted as le, resolveDynamicComponent as ce, mergeProps as de, unref as y, withKeys as ue, watch as W, Fragment as P, createTextVNode as C, createVNode as S, withCtx as U, computed as he, isRef as pe } from "vue";
2
+ import { _ as F, n as fe, u as me, H as X, F as ge, f as ye, r as Z, c as B, U as K, a as z, b as J, E as H, d as oe, V as q, A as ne, e as se, R as ve, g as ee, m as we, h as Se, D as M, W as _e, i as N, t as I, j as D, k as be, l as ke, o as Ce } from "./index-1820592b.js";
3
+ import { p as Xt } from "./index-1820592b.js";
4
+ import { useTextareaAutosize as xe, useMediaQuery as Fe, useFileDialog as $e } from "@vueuse/core";
5
+ import "@headlessui/vue";
6
+ import "axios";
7
+ import "@vcarl/remark-headings";
8
+ import "github-slugger";
9
+ import "remark-parse";
10
+ import "remark-stringify";
11
+ import "unified";
12
+ import "js-yaml";
13
+ import "unhead";
14
+ import "rehype-external-links";
15
+ import "rehype-format";
16
+ import "rehype-highlight";
17
+ import "rehype-sanitize";
18
+ import "rehype-stringify";
19
+ import "remark-gfm";
20
+ import "remark-rehype";
21
+ import "httpsnippet-lite";
22
+ import "fuse.js";
23
+ const Me = (r) => {
24
+ if (typeof r != "string")
25
+ return !1;
26
+ try {
27
+ JSON.parse(r);
28
+ } catch {
29
+ return !1;
30
+ }
31
+ return !0;
32
+ }, Ue = {
33
+ key: 0,
34
+ class: "loader-wrapper"
35
+ }, Re = /* @__PURE__ */ re('<path class="svg-path svg-check-mark" d="m 0 60 l 30 30 l 70 -80" data-v-f02d7027></path><path class="svg-path svg-x-mark" d="m 50 50 l 40 -40" data-v-f02d7027></path><path class="svg-path svg-x-mark" d="m 50 50 l 40 40" data-v-f02d7027></path><path class="svg-path svg-x-mark" d="m 50 50 l -40 -40" data-v-f02d7027></path><path class="svg-path svg-x-mark" d="m 50 50 l -40 40" data-v-f02d7027></path>', 5), Ee = {
36
+ key: 0,
37
+ class: "circular-loader"
38
+ }, Te = /* @__PURE__ */ R({
39
+ __name: "FlowLoader",
40
+ props: {
41
+ loaderState: {},
42
+ size: { default: "24px" }
43
+ },
44
+ setup(r) {
45
+ return ae((e) => ({
46
+ "0a23b95e": e.size
47
+ })), (e, t) => e.loaderState ? (f(), g("div", Ue, [
48
+ (f(), g("svg", {
49
+ class: T(["svg-loader", {
50
+ "icon-is-valid": e.loaderState.valid,
51
+ "icon-is-invalid": e.loaderState.invalid
52
+ }]),
53
+ viewBox: "0 0 100 100",
54
+ xmlns: "http://www.w3.org/2000/svg",
55
+ "xmlns:xlink": "http://www.w3.org/1999/xlink"
56
+ }, [
57
+ Re,
58
+ e.loaderState.isLoading ? (f(), g("g", Ee, [
59
+ v("circle", {
60
+ class: T(["loader-path", {
61
+ "loader-path-off": e.loaderState.valid || e.loaderState.invalid
62
+ }]),
63
+ cx: "50",
64
+ cy: "50",
65
+ fill: "none",
66
+ r: "20",
67
+ "stroke-width": "2"
68
+ }, null, 2)
69
+ ])) : _("", !0)
70
+ ], 2))
71
+ ])) : _("", !0);
72
+ }
73
+ }), Be = /* @__PURE__ */ F(Te, [["__scopeId", "data-v-f02d7027"]]), Ie = ["title"], De = {
74
+ key: 0,
75
+ class: "flow-button-decorator"
76
+ }, Ae = { class: "flow-button-loader" }, Oe = /* @__PURE__ */ R({
77
+ __name: "FlowButton",
78
+ props: {
79
+ label: {},
80
+ error: { type: Boolean },
81
+ loaderState: {},
82
+ variant: {},
83
+ title: {},
84
+ icon: { type: Boolean }
85
+ },
86
+ setup(r) {
87
+ return (e, t) => (f(), g("button", {
88
+ class: T(["flow-button", {
89
+ "flow-button-outlined": !e.error && e.variant === "outlined",
90
+ "flow-button-clear": !e.error && e.variant === "clear",
91
+ "flow-button-text": !e.error && e.variant === "text",
92
+ "flow-button--delete": e.error,
93
+ "flow-button-icon-only": e.icon
94
+ }]),
95
+ title: e.title || e.label,
96
+ type: "button"
97
+ }, [
98
+ e.$slots.default ? (f(), g("div", De, [
99
+ E(e.$slots, "default", {}, void 0, !0)
100
+ ])) : _("", !0),
101
+ v("span", {
102
+ class: T({ "sr-only": e.icon })
103
+ }, x(e.label), 3),
104
+ v("div", Ae, [
105
+ e.loaderState ? (f(), A(Be, {
106
+ key: 0,
107
+ loaderState: e.loaderState
108
+ }, null, 8, ["loaderState"])) : _("", !0)
109
+ ])
110
+ ], 10, Ie));
111
+ }
112
+ }), te = /* @__PURE__ */ F(Oe, [["__scopeId", "data-v-48c181db"]]), Ve = { class: "flow-input-cont" }, Le = ["for"], Ye = { class: "icon-slot" }, Ne = { class: "helper-text" }, Pe = {
113
+ inheritAttrs: !1
114
+ }, ze = /* @__PURE__ */ R({
115
+ ...Pe,
116
+ __name: "FlowTextField",
117
+ props: {
118
+ modelValue: {},
119
+ label: {},
120
+ error: { type: Boolean },
121
+ warn: { type: Boolean },
122
+ isMultiline: { type: Boolean },
123
+ helperText: {},
124
+ emitOnBlur: { type: Boolean, default: !0 },
125
+ handleFieldSubmit: {},
126
+ handleFieldChange: {},
127
+ disableTrim: { type: Boolean, default: !1 }
128
+ },
129
+ emits: ["submit", "update:modelValue"],
130
+ setup(r, { emit: e }) {
131
+ const t = r, s = ie(), i = s.id || `id-${fe()}`, a = b(), l = b(!1);
132
+ let u;
133
+ if (t.isMultiline) {
134
+ const { triggerResize: o } = xe({
135
+ element: a,
136
+ input: t.modelValue
137
+ });
138
+ u = o;
139
+ }
140
+ function d(o) {
141
+ const n = o.target.value;
142
+ t.isMultiline && u(), t.handleFieldChange ? t.handleFieldChange(n) : e("update:modelValue", n);
143
+ }
144
+ function c(o) {
145
+ const n = o.target, p = t.disableTrim || t.isMultiline ? n.value : n.value.trim();
146
+ t.handleFieldSubmit ? t.handleFieldSubmit(p) : e("submit", p);
147
+ }
148
+ function h(o) {
149
+ l.value = !1, t.emitOnBlur && t.modelValue && c(o);
150
+ }
151
+ return le(() => {
152
+ var o;
153
+ Object.prototype.hasOwnProperty.call(s, "autofocus") && ((o = a.value) == null || o.focus());
154
+ }), (o, n) => (f(), g("div", Ve, [
155
+ v("div", {
156
+ class: T(["flow-input-wrapper", {
157
+ "flow-input-wrapper--focus": l.value,
158
+ "flow-input-wrapper--error": o.error,
159
+ "flow-input-wrapper--warn": o.warn
160
+ }])
161
+ }, [
162
+ (f(), A(ce(o.isMultiline ? "textarea" : "input"), de({ id: y(i) }, o.$attrs, {
163
+ ref_key: "input",
164
+ ref: a,
165
+ class: ["flow-input hotkeys", { "flow-input__multiline": o.isMultiline }],
166
+ value: o.modelValue,
167
+ onBlur: h,
168
+ onFocus: n[0] || (n[0] = (p) => l.value = !0),
169
+ onInput: d,
170
+ onKeyup: ue(c, ["enter"])
171
+ }), null, 16, ["id", "class", "value", "onKeyup"])),
172
+ o.label ? (f(), g("label", {
173
+ key: 0,
174
+ class: "flow-label",
175
+ for: y(i)
176
+ }, x(o.label), 9, Le)) : _("", !0),
177
+ v("div", Ye, [
178
+ E(o.$slots, "default", {}, void 0, !0)
179
+ ])
180
+ ], 2),
181
+ v("span", Ne, x(o.helperText), 1)
182
+ ]));
183
+ }
184
+ }), Je = /* @__PURE__ */ F(ze, [["__scopeId", "data-v-12153368"]]), je = { class: "swagger-editor-header" }, We = { class: "swagger-editor-title" }, Ke = { class: "swagger-editor-actions" }, qe = { key: 0 }, Qe = { key: 0 }, Ge = { class: "flex-col gap-1" }, Xe = { class: "flex-mobile gap-1" }, Ze = /* @__PURE__ */ R({
185
+ __name: "SwaggerEditorHeader",
186
+ props: {
187
+ proxyUrl: {}
188
+ },
189
+ emits: ["import"],
190
+ setup(r, { expose: e, emit: t }) {
191
+ const s = r, i = Fe("(max-width: 1000px)"), { files: a, open: l, reset: u } = $e({
192
+ multiple: !1,
193
+ accept: ".json,.yaml,.yml"
194
+ }), d = me(), c = b(null);
195
+ e({
196
+ importUrlModal: d,
197
+ openFileDialog: l
198
+ });
199
+ const h = b(""), o = () => {
200
+ c.value = "", ye(h.value, s.proxyUrl).then(async (n) => {
201
+ t("import", n), d.hide();
202
+ }).catch((n) => {
203
+ console.error("[importUrl]", n), c.value = n;
204
+ });
205
+ };
206
+ return W(a, () => {
207
+ var n;
208
+ if ((n = a.value) != null && n.length) {
209
+ const p = a.value[0], m = new FileReader();
210
+ m.onload = (w) => {
211
+ var k;
212
+ const $ = (k = w.target) == null ? void 0 : k.result;
213
+ typeof $ == "string" && (t("import", $), u());
214
+ }, m.readAsText(p);
215
+ }
216
+ }), (n, p) => (f(), g(P, null, [
217
+ v("div", je, [
218
+ v("div", We, [
219
+ y(i) ? _("", !0) : (f(), g(P, { key: 0 }, [
220
+ C("Swagger ")
221
+ ], 64)),
222
+ C("Editor ")
223
+ ]),
224
+ E(n.$slots, "tab-items", {}, void 0, !0),
225
+ v("div", Ke, [
226
+ S(X, {
227
+ onClick: p[0] || (p[0] = () => y(l)())
228
+ }, {
229
+ default: U(() => [
230
+ C(" Upload"),
231
+ y(i) ? _("", !0) : (f(), g("span", qe, " File"))
232
+ ]),
233
+ _: 1
234
+ }),
235
+ S(X, {
236
+ onClick: p[1] || (p[1] = (m) => y(d).show())
237
+ }, {
238
+ default: U(() => [
239
+ y(i) ? _("", !0) : (f(), g("span", Qe, "Import ")),
240
+ C("URL ")
241
+ ]),
242
+ _: 1
243
+ })
244
+ ])
245
+ ]),
246
+ S(y(ge), {
247
+ state: y(d),
248
+ title: "Import Swagger from URL"
249
+ }, {
250
+ default: U(() => [
251
+ v("div", Ge, [
252
+ S(Je, {
253
+ modelValue: h.value,
254
+ "onUpdate:modelValue": p[2] || (p[2] = (m) => h.value = m),
255
+ autofocus: "",
256
+ label: "URL",
257
+ placeholder: "https://scalar.com/swagger.json"
258
+ }, null, 8, ["modelValue"]),
259
+ C(" " + x(c.value) + " ", 1),
260
+ v("div", Xe, [
261
+ S(te, {
262
+ label: "Cancel",
263
+ variant: "outlined",
264
+ onClick: p[3] || (p[3] = (m) => y(d).hide())
265
+ }),
266
+ S(te, {
267
+ label: "Import",
268
+ onClick: o
269
+ })
270
+ ])
271
+ ])
272
+ ]),
273
+ _: 1
274
+ }, 8, ["state"])
275
+ ], 64));
276
+ }
277
+ }), He = /* @__PURE__ */ F(Ze, [["__scopeId", "data-v-000eb19c"]]);
278
+ class Q {
279
+ /**
280
+ * @param {Y.RelativePosition} yanchor
281
+ * @param {Y.RelativePosition} yhead
282
+ */
283
+ constructor(e, t) {
284
+ this.yanchor = e, this.yhead = t;
285
+ }
286
+ /**
287
+ * @returns {any}
288
+ */
289
+ toJSON() {
290
+ return {
291
+ yanchor: Z(this.yanchor),
292
+ yhead: Z(this.yhead)
293
+ };
294
+ }
295
+ /**
296
+ * @param {any} json
297
+ * @return {YRange}
298
+ */
299
+ static fromJSON(e) {
300
+ return new Q(B(e.yanchor), B(e.yhead));
301
+ }
302
+ }
303
+ class et {
304
+ constructor(e, t) {
305
+ this.ytext = e, this.awareness = t, this.undoManager = new K(e);
306
+ }
307
+ /**
308
+ * Helper function to transform an absolute index position to a Yjs-based relative position
309
+ * (https://docs.yjs.dev/api/relative-positions).
310
+ *
311
+ * A relative position can be transformed back to an absolute position even after the document has changed. The position is
312
+ * automatically adapted. This does not require any position transformations. Relative positions are computed based on
313
+ * the internal Yjs document model. Peers that share content through Yjs are guaranteed that their positions will always
314
+ * synced up when using relatve positions.
315
+ *
316
+ * ```js
317
+ * import { ySyncFacet } from 'y-codemirror'
318
+ *
319
+ * ..
320
+ * const ysync = view.state.facet(ySyncFacet)
321
+ * // transform an absolute index position to a ypos
322
+ * const ypos = ysync.getYPos(3)
323
+ * // transform the ypos back to an absolute position
324
+ * ysync.fromYPos(ypos) // => 3
325
+ * ```
326
+ *
327
+ * It cannot be guaranteed that absolute index positions can be synced up between peers.
328
+ * This might lead to undesired behavior when implementing features that require that all peers see the
329
+ * same marked range (e.g. a comment plugin).
330
+ *
331
+ * @param {number} pos
332
+ * @param {number} [assoc]
333
+ */
334
+ toYPos(e, t = 0) {
335
+ return z(this.ytext, e, t);
336
+ }
337
+ /**
338
+ * @param {Y.RelativePosition | Object} rpos
339
+ */
340
+ fromYPos(e) {
341
+ const t = J(B(e), this.ytext.doc);
342
+ if (t == null || t.type !== this.ytext)
343
+ throw new Error("[y-codemirror] The position you want to retrieve was created by a different document");
344
+ return {
345
+ pos: t.index,
346
+ assoc: t.assoc
347
+ };
348
+ }
349
+ /**
350
+ * @param {cmState.SelectionRange} range
351
+ * @return {YRange}
352
+ */
353
+ toYRange(e) {
354
+ const t = e.assoc, s = this.toYPos(e.anchor, t), i = this.toYPos(e.head, t);
355
+ return new Q(s, i);
356
+ }
357
+ /**
358
+ * @param {YRange} yrange
359
+ */
360
+ fromYRange(e) {
361
+ const t = this.fromYPos(e.yanchor), s = this.fromYPos(e.yhead);
362
+ return t.pos === s.pos ? H.cursor(s.pos, s.assoc) : H.range(t.pos, s.pos);
363
+ }
364
+ }
365
+ const O = oe.define({
366
+ combine(r) {
367
+ return r[r.length - 1];
368
+ }
369
+ }), j = ne.define();
370
+ class tt {
371
+ /**
372
+ * @param {cmView.EditorView} view
373
+ */
374
+ constructor(e) {
375
+ this.view = e, this.conf = e.state.facet(O), this._observer = (t, s) => {
376
+ if (s.origin !== this.conf) {
377
+ const i = t.delta, a = [];
378
+ let l = 0;
379
+ for (let u = 0; u < i.length; u++) {
380
+ const d = i[u];
381
+ d.insert != null ? a.push({ from: l, to: l, insert: d.insert }) : d.delete != null ? (a.push({ from: l, to: l + d.delete, insert: "" }), l += d.delete) : l += d.retain;
382
+ }
383
+ e.dispatch({ changes: a, annotations: [j.of(this.conf)] });
384
+ }
385
+ }, this._ytext = this.conf.ytext, this._ytext.observe(this._observer);
386
+ }
387
+ /**
388
+ * @param {cmView.ViewUpdate} update
389
+ */
390
+ update(e) {
391
+ if (!e.docChanged || e.transactions.length > 0 && e.transactions[0].annotation(j) === this.conf)
392
+ return;
393
+ const t = this.conf.ytext;
394
+ t.doc.transact(() => {
395
+ let s = 0;
396
+ e.changes.iterChanges((i, a, l, u, d) => {
397
+ const c = d.sliceString(0, d.length, `
398
+ `);
399
+ i !== a && t.delete(i + s, a - i), c.length > 0 && t.insert(i + s, c), s += c.length - (a - i);
400
+ });
401
+ }, this.conf);
402
+ }
403
+ destroy() {
404
+ this._ytext.unobserve(this._observer);
405
+ }
406
+ }
407
+ const ot = q.fromClass(tt), nt = se.baseTheme({
408
+ ".cm-ySelection": {},
409
+ ".cm-yLineSelection": {
410
+ padding: 0,
411
+ margin: "0px 2px 0px 4px"
412
+ },
413
+ ".cm-ySelectionCaret": {
414
+ position: "relative",
415
+ borderLeft: "1px solid black",
416
+ borderRight: "1px solid black",
417
+ marginLeft: "-1px",
418
+ marginRight: "-1px",
419
+ boxSizing: "border-box",
420
+ display: "inline"
421
+ },
422
+ ".cm-ySelectionCaretDot": {
423
+ borderRadius: "50%",
424
+ position: "absolute",
425
+ width: ".4em",
426
+ height: ".4em",
427
+ top: "-.2em",
428
+ left: "-.2em",
429
+ backgroundColor: "inherit",
430
+ transition: "transform .3s ease-in-out",
431
+ boxSizing: "border-box"
432
+ },
433
+ ".cm-ySelectionCaret:hover > .cm-ySelectionCaretDot": {
434
+ transformOrigin: "bottom center",
435
+ transform: "scale(0)"
436
+ },
437
+ ".cm-ySelectionInfo": {
438
+ position: "absolute",
439
+ top: "-1.05em",
440
+ left: "-1px",
441
+ fontSize: ".75em",
442
+ fontFamily: "serif",
443
+ fontStyle: "normal",
444
+ fontWeight: "normal",
445
+ lineHeight: "normal",
446
+ userSelect: "none",
447
+ color: "white",
448
+ paddingLeft: "2px",
449
+ paddingRight: "2px",
450
+ zIndex: 101,
451
+ transition: "opacity .3s ease-in-out",
452
+ backgroundColor: "inherit",
453
+ // these should be separate
454
+ opacity: 0,
455
+ transitionDelay: "0s",
456
+ whiteSpace: "nowrap"
457
+ },
458
+ ".cm-ySelectionCaret:hover > .cm-ySelectionInfo": {
459
+ opacity: 1,
460
+ transitionDelay: "0s"
461
+ }
462
+ }), st = ne.define();
463
+ class at extends _e {
464
+ /**
465
+ * @param {string} color
466
+ * @param {string} name
467
+ */
468
+ constructor(e, t) {
469
+ super(), this.color = e, this.name = t;
470
+ }
471
+ toDOM() {
472
+ return (
473
+ /** @type {HTMLElement} */
474
+ N("span", [D("class", "cm-ySelectionCaret"), D("style", `background-color: ${this.color}; border-color: ${this.color}`)], [
475
+ I("⁠"),
476
+ N("div", [
477
+ D("class", "cm-ySelectionCaretDot")
478
+ ]),
479
+ I("⁠"),
480
+ N("div", [
481
+ D("class", "cm-ySelectionInfo")
482
+ ], [
483
+ I(this.name)
484
+ ]),
485
+ I("⁠")
486
+ ])
487
+ );
488
+ }
489
+ eq(e) {
490
+ return e.color === this.color;
491
+ }
492
+ compare(e) {
493
+ return e.color === this.color;
494
+ }
495
+ updateDOM() {
496
+ return !1;
497
+ }
498
+ get estimatedHeight() {
499
+ return -1;
500
+ }
501
+ ignoreEvent() {
502
+ return !0;
503
+ }
504
+ }
505
+ class rt {
506
+ /**
507
+ * @param {cmView.EditorView} view
508
+ */
509
+ constructor(e) {
510
+ this.conf = e.state.facet(O), this._listener = ({ added: t, updated: s, removed: i }, a, l) => {
511
+ t.concat(s).concat(i).findIndex((d) => d !== this.conf.awareness.doc.clientID) >= 0 && e.dispatch({ annotations: [st.of([])] });
512
+ }, this._awareness = this.conf.awareness, this._awareness.on("change", this._listener), this.decorations = ve.of([]);
513
+ }
514
+ destroy() {
515
+ this._awareness.off("change", this._listener);
516
+ }
517
+ /**
518
+ * @param {cmView.ViewUpdate} update
519
+ */
520
+ update(e) {
521
+ const t = this.conf.ytext, s = (
522
+ /** @type {Y.Doc} */
523
+ t.doc
524
+ ), i = this.conf.awareness, a = [], l = this.conf.awareness.getLocalState();
525
+ if (l != null) {
526
+ const u = e.view.hasFocus && e.view.dom.ownerDocument.hasFocus(), d = u ? e.state.selection.main : null, c = l.cursor == null ? null : B(l.cursor.anchor), h = l.cursor == null ? null : B(l.cursor.head);
527
+ if (d != null) {
528
+ const o = z(t, d.anchor), n = z(t, d.head);
529
+ (l.cursor == null || !ee(c, o) || !ee(h, n)) && i.setLocalStateField("cursor", {
530
+ anchor: o,
531
+ head: n
532
+ });
533
+ } else
534
+ l.cursor != null && u && i.setLocalStateField("cursor", null);
535
+ }
536
+ i.getStates().forEach((u, d) => {
537
+ if (d === i.doc.clientID)
538
+ return;
539
+ const c = u.cursor;
540
+ if (c == null || c.anchor == null || c.head == null)
541
+ return;
542
+ const h = J(c.anchor, s), o = J(c.head, s);
543
+ if (h == null || o == null || h.type !== t || o.type !== t)
544
+ return;
545
+ const { color: n = "#30bced", name: p = "Anonymous" } = u.user || {}, m = u.user && u.user.colorLight || n + "33", w = we(h.index, o.index), $ = Se(h.index, o.index), k = e.view.state.doc.lineAt(w), L = e.view.state.doc.lineAt($);
546
+ if (k.number === L.number)
547
+ a.push({
548
+ from: w,
549
+ to: $,
550
+ value: M.mark({
551
+ attributes: { style: `background-color: ${m}` },
552
+ class: "cm-ySelection"
553
+ })
554
+ });
555
+ else {
556
+ a.push({
557
+ from: w,
558
+ to: k.from + k.length,
559
+ value: M.mark({
560
+ attributes: { style: `background-color: ${m}` },
561
+ class: "cm-ySelection"
562
+ })
563
+ }), a.push({
564
+ from: L.from,
565
+ to: $,
566
+ value: M.mark({
567
+ attributes: { style: `background-color: ${m}` },
568
+ class: "cm-ySelection"
569
+ })
570
+ });
571
+ for (let Y = k.number + 1; Y < L.number; Y++) {
572
+ const G = e.view.state.doc.line(Y).from;
573
+ a.push({
574
+ from: G,
575
+ to: G,
576
+ value: M.line({
577
+ attributes: { style: `background-color: ${m}`, class: "cm-yLineSelection" }
578
+ })
579
+ });
580
+ }
581
+ }
582
+ a.push({
583
+ from: o.index,
584
+ to: o.index,
585
+ value: M.widget({
586
+ side: o.index - h.index > 0 ? -1 : 1,
587
+ // the local cursor should be rendered outside the remote selection
588
+ block: !1,
589
+ widget: new at(n, p)
590
+ })
591
+ });
592
+ }), this.decorations = M.set(a, !0);
593
+ }
594
+ }
595
+ const it = q.fromClass(rt, {
596
+ decorations: (r) => r.decorations
597
+ }), lt = () => {
598
+ let r = !0;
599
+ return (e, t) => {
600
+ if (r) {
601
+ r = !1;
602
+ try {
603
+ e();
604
+ } finally {
605
+ r = !0;
606
+ }
607
+ } else
608
+ t !== void 0 && t();
609
+ };
610
+ };
611
+ class ct {
612
+ /**
613
+ * @param {Y.UndoManager} undoManager
614
+ */
615
+ constructor(e) {
616
+ this.undoManager = e;
617
+ }
618
+ /**
619
+ * @param {any} origin
620
+ */
621
+ addTrackedOrigin(e) {
622
+ this.undoManager.addTrackedOrigin(e);
623
+ }
624
+ /**
625
+ * @param {any} origin
626
+ */
627
+ removeTrackedOrigin(e) {
628
+ this.undoManager.removeTrackedOrigin(e);
629
+ }
630
+ /**
631
+ * @return {boolean} Whether a change was undone.
632
+ */
633
+ undo() {
634
+ return this.undoManager.undo() != null;
635
+ }
636
+ /**
637
+ * @return {boolean} Whether a change was redone.
638
+ */
639
+ redo() {
640
+ return this.undoManager.redo() != null;
641
+ }
642
+ }
643
+ const V = oe.define({
644
+ combine(r) {
645
+ return r[r.length - 1];
646
+ }
647
+ });
648
+ class dt {
649
+ /**
650
+ * @param {cmView.EditorView} view
651
+ */
652
+ constructor(e) {
653
+ this.view = e, this.conf = e.state.facet(V), this._undoManager = this.conf.undoManager, this.syncConf = e.state.facet(O), this._beforeChangeSelection = null, this._mux = lt(), this._onStackItemAdded = ({ stackItem: t, changedParentTypes: s }) => {
654
+ s.has(this.syncConf.ytext) && this._beforeChangeSelection && !t.meta.has(this) && t.meta.set(this, this._beforeChangeSelection);
655
+ }, this._onStackItemPopped = ({ stackItem: t }) => {
656
+ const s = t.meta.get(this);
657
+ if (s) {
658
+ const i = this.syncConf.fromYRange(s);
659
+ e.dispatch(e.state.update({ selection: i })), this._storeSelection();
660
+ }
661
+ }, this._storeSelection = () => {
662
+ this._beforeChangeSelection = this.syncConf.toYRange(this.view.state.selection.main);
663
+ }, this._undoManager.on("stack-item-added", this._onStackItemAdded), this._undoManager.on("stack-item-popped", this._onStackItemPopped), this._undoManager.addTrackedOrigin(this.syncConf);
664
+ }
665
+ /**
666
+ * @param {cmView.ViewUpdate} update
667
+ */
668
+ update(e) {
669
+ e.selectionSet && (e.transactions.length === 0 || e.transactions[0].annotation(j) !== this.syncConf) && this._storeSelection();
670
+ }
671
+ destroy() {
672
+ this._undoManager.off("stack-item-added", this._onStackItemAdded), this._undoManager.off("stack-item-popped", this._onStackItemPopped), this._undoManager.removeTrackedOrigin(this.syncConf);
673
+ }
674
+ }
675
+ const ut = q.fromClass(dt), ht = ({ state: r, dispatch: e }) => r.facet(V).undo() || !0, pt = ({ state: r, dispatch: e }) => r.facet(V).redo() || !0, ft = (r, e, { undoManager: t = new K(r) } = {}) => {
676
+ const s = new et(r, e), i = [
677
+ O.of(s),
678
+ ot
679
+ ];
680
+ return e && i.push(
681
+ nt,
682
+ it
683
+ ), t !== !1 && i.push(
684
+ V.of(new ct(t)),
685
+ ut,
686
+ se.domEventHandlers({
687
+ beforeinput(a, l) {
688
+ return a.inputType === "historyUndo" ? ht(l) : a.inputType === "historyRedo" ? pt(l) : !1;
689
+ }
690
+ })
691
+ ), i;
692
+ }, mt = { class: "swagger-editor-input" }, gt = /* @__PURE__ */ R({
693
+ __name: "SwaggerEditorInput",
694
+ props: {
695
+ value: {},
696
+ hocuspocusConfiguration: {}
697
+ },
698
+ emits: ["contentUpdate", "awarenessUpdate"],
699
+ setup(r, { expose: e, emit: t }) {
700
+ const s = r, i = (c) => c[Math.floor(Math.random() * c.length)];
701
+ let a = null;
702
+ const l = b(null);
703
+ e({
704
+ setCodeMirrorContent: (c) => {
705
+ var h;
706
+ (h = u.value) == null || h.setCodeMirrorContent(c);
707
+ }
708
+ }), W(
709
+ () => s.hocuspocusConfiguration,
710
+ (c, h) => {
711
+ if (JSON.stringify(h) === JSON.stringify(c) || (a && (a.destroy(), l.value = null), !s.hocuspocusConfiguration))
712
+ return;
713
+ const { username: o, ...n } = s.hocuspocusConfiguration;
714
+ a = new be({
715
+ ...n,
716
+ onAuthenticated() {
717
+ console.log(
718
+ `[SwaggerEditor] ✅ onAuthentication (${n == null ? void 0 : n.name})`
719
+ );
720
+ },
721
+ onConnect() {
722
+ n.token || console.log(
723
+ `[SwaggerEditor] 🟢 onConnect (${n == null ? void 0 : n.name})`
724
+ );
725
+ },
726
+ onAuthenticationFailed() {
727
+ console.log(
728
+ `[SwaggerEditor] ❌ onAuthenticationFailed (${n == null ? void 0 : n.name})`
729
+ );
730
+ },
731
+ onSynced() {
732
+ console.log(
733
+ `[SwaggerEditor] 🔄 onSynced (${n == null ? void 0 : n.name})`
734
+ );
735
+ },
736
+ onDisconnect() {
737
+ console.log(
738
+ `[SwaggerEditor] ⚪️ onDisconnect (${n == null ? void 0 : n.name})`
739
+ );
740
+ },
741
+ onAwarenessUpdate({ states: w }) {
742
+ t("awarenessUpdate", w);
743
+ }
744
+ }), a == null || a.on("authenticated", () => {
745
+ const w = i([
746
+ "#958DF1",
747
+ "#F98181",
748
+ "#FBBC88",
749
+ "#FAF594",
750
+ "#70CFF8",
751
+ "#94FADB",
752
+ "#B9F18D"
753
+ ]);
754
+ a == null || a.setAwarenessField("user", {
755
+ name: o || "guest",
756
+ color: w,
757
+ colorLight: w
758
+ });
759
+ });
760
+ const p = a.document.getText("codemirror"), m = new K(p);
761
+ l.value = ft(
762
+ p,
763
+ a.awareness,
764
+ { undoManager: m }
765
+ );
766
+ },
767
+ { immediate: !0, deep: !0 }
768
+ );
769
+ const u = b(null);
770
+ function d(c) {
771
+ return Me(c) ? ["json"] : ["yaml"];
772
+ }
773
+ return (c, h) => {
774
+ var o;
775
+ return f(), g("div", mt, [
776
+ S(y(ke), {
777
+ ref_key: "codeMirrorRef",
778
+ ref: u,
779
+ content: c.value,
780
+ extensions: l.value ? [l.value] : [],
781
+ languages: d(c.value),
782
+ lineNumbers: "",
783
+ name: (o = c.hocuspocusConfiguration) == null ? void 0 : o.name,
784
+ onChange: h[0] || (h[0] = (n) => c.$emit("contentUpdate", n))
785
+ }, null, 8, ["content", "extensions", "languages", "name"])
786
+ ]);
787
+ };
788
+ }
789
+ }), yt = {}, vt = { class: "swagger-editor-notification swagger-editor-notification--error" };
790
+ function wt(r, e) {
791
+ return f(), g("div", vt, [
792
+ E(r.$slots, "default")
793
+ ]);
794
+ }
795
+ const St = /* @__PURE__ */ F(yt, [["render", wt]]), _t = {}, bt = { class: "swagger-editor-status-bar" };
796
+ function kt(r, e) {
797
+ return f(), g("div", bt, [
798
+ E(r.$slots, "default")
799
+ ]);
800
+ }
801
+ const Ct = /* @__PURE__ */ F(_t, [["render", kt]]), xt = { class: "swagger-editor" }, Ft = /* @__PURE__ */ R({
802
+ __name: "SwaggerEditor",
803
+ props: {
804
+ value: {},
805
+ hocuspocusConfiguration: {},
806
+ theme: {},
807
+ proxyUrl: {},
808
+ error: {}
809
+ },
810
+ emits: ["contentUpdate", "import", "changeTheme"],
811
+ setup(r, { expose: e, emit: t }) {
812
+ const s = r, i = b(null), a = b([]), l = (o) => {
813
+ t("contentUpdate", o);
814
+ }, u = (o) => {
815
+ a.value = o;
816
+ }, d = b(null), c = he(() => {
817
+ if (s.error === void 0 || s.error === null || s.error === "")
818
+ return "";
819
+ const o = pe(s.error) ? s.error.value : s.error;
820
+ return o.startsWith("YAMLException:") ? o.split(`
821
+ `)[0] : o;
822
+ });
823
+ return W(
824
+ () => s.value,
825
+ async () => {
826
+ s.value && l(s.value);
827
+ },
828
+ { immediate: !0 }
829
+ ), e({
830
+ handleOpenSwaggerEditor: (o) => {
831
+ var n, p, m;
832
+ o === "importUrl" ? (p = (n = i == null ? void 0 : i.value) == null ? void 0 : n.importUrlModal) == null || p.show() : o === "uploadFile" && ((m = i == null ? void 0 : i.value) == null || m.openFileDialog());
833
+ }
834
+ }), (o, n) => (f(), g(P, null, [
835
+ S(y(Ce), { id: o.theme }, null, 8, ["id"]),
836
+ v("div", xt, [
837
+ S(He, {
838
+ ref_key: "swaggerEditorHeaderRef",
839
+ ref: i,
840
+ proxyUrl: o.proxyUrl,
841
+ onImport: l
842
+ }, {
843
+ "tab-items": U(() => [
844
+ E(o.$slots, "tab-items", {}, void 0, !0)
845
+ ]),
846
+ _: 3
847
+ }, 8, ["proxyUrl"]),
848
+ c.value ? (f(), A(St, { key: 0 }, {
849
+ default: U(() => [
850
+ C(x(c.value), 1)
851
+ ]),
852
+ _: 1
853
+ })) : _("", !0),
854
+ S(gt, {
855
+ ref_key: "codeMirrorReference",
856
+ ref: d,
857
+ hocuspocusConfiguration: o.hocuspocusConfiguration,
858
+ value: o.value,
859
+ onAwarenessUpdate: u,
860
+ onContentUpdate: l
861
+ }, null, 8, ["hocuspocusConfiguration", "value"]),
862
+ a.value.length ? (f(), A(Ct, { key: 1 }, {
863
+ default: U(() => [
864
+ C(x(a.value.length) + " user" + x(a.value.length === 1 ? "" : "s") + " online ", 1)
865
+ ]),
866
+ _: 1
867
+ })) : _("", !0)
868
+ ])
869
+ ], 64));
870
+ }
871
+ }), qt = /* @__PURE__ */ F(Ft, [["__scopeId", "data-v-16132f63"]]);
872
+ export {
873
+ qt as CodeEditor,
874
+ X as HeaderTabButton,
875
+ qt as SwaggerEditor,
876
+ ye as fetchSpecFromUrl,
877
+ Me as isJsonString,
878
+ Xt as useDarkModeState
879
+ };