@openbkn/workshop 0.2.2 → 0.3.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/README.md +1 -1
  2. package/dist/{ActionConfirm-DJ91X3ml.js → ActionConfirm-BX1dlrAM.js} +5 -5
  3. package/dist/{ActionFailure-ZgPt_3B-.js → ActionFailure-xcSfKJYC.js} +2 -2
  4. package/dist/{AgentChat-CRYai8ge.js → AgentChat-DHdX_6W7.js} +407 -383
  5. package/dist/AppListPage-DsUvFo6B.js +1549 -0
  6. package/dist/{AskDrawer-BUMYsRnt.js → AskDrawer-j-CR4yXP.js} +4 -4
  7. package/dist/{ComputedView-CgYrDbx1.js → ComputedView-dWFlHngu.js} +1035 -1016
  8. package/dist/{ConclusionApply-sjGfoEBY.js → ConclusionApply-BAoZpxl-.js} +4 -4
  9. package/dist/{CypherEditor-lus6FA5L.js → CypherEditor-CZ5Z4SGH.js} +47 -47
  10. package/dist/{LandingList-6JI6864C.js → LandingList-BUO6-at_.js} +5 -5
  11. package/dist/{MenuUnfoldOutlined-Cdg24l2h.js → MenuUnfoldOutlined-DAeIeIap.js} +3 -3
  12. package/dist/{ModelTrial-ClHFGTpQ.js → ModelTrial-C7XvLVY7.js} +4 -4
  13. package/dist/{PageRenderer-DBd_g6mN.js → PageRenderer-CkmvW4aO.js} +21264 -20549
  14. package/dist/{ScenarioApply-DtW_hh47.js → ScenarioApply-COdlyvrC.js} +6 -6
  15. package/dist/{SimulateForm-C-i08Jjd.js → SimulateForm-B_9laTIl.js} +4 -4
  16. package/dist/{Subgraph-CnrkH9AN.js → Subgraph-CDY3wvCA.js} +3 -3
  17. package/dist/WorkshopLabPage-BtYnBpk4.js +12020 -0
  18. package/dist/{WorkshopRunPage-6hjRUf64.js → WorkshopRunPage-DHMJ3b8k.js} +24 -24
  19. package/dist/{abnfDiagram-WEYOIA3C-beRNhN3c.js → abnfDiagram-WEYOIA3C-Blje2Kbf.js} +3 -3
  20. package/dist/{action-type-tool.service-B2B74fKC.js → action-type-tool.service-BN-W_Az_.js} +1 -1
  21. package/dist/{architectureDiagram-ZHVYKT53-DY2l1qxx.js → architectureDiagram-ZHVYKT53-B_FkRXc3.js} +3 -3
  22. package/dist/{bkn-agent-execution.service-DVh-SHyl.js → bkn-agent-execution.service-CJalMVIc.js} +1 -1
  23. package/dist/{blockDiagram-RJAE7QA3-DR0mjN2h.js → blockDiagram-RJAE7QA3-CYJLthoI.js} +3 -3
  24. package/dist/{c4Diagram-XDPPPE54-DH5zsGug.js → c4Diagram-XDPPPE54-CmMaN3M4.js} +2 -2
  25. package/dist/{channel-B034hcOF.js → channel-Dp24Bgua.js} +1 -1
  26. package/dist/{chunk-2E7WHVMD-Ba3svxgx.js → chunk-2E7WHVMD-DrnpfYKB.js} +1 -1
  27. package/dist/{chunk-2Q5K7J3B-rT4eU6_y.js → chunk-2Q5K7J3B-BXqKcHlQ.js} +1 -1
  28. package/dist/{chunk-4EMNKR2T-C1kQZYHK.js → chunk-4EMNKR2T-DYgY_0_y.js} +1 -1
  29. package/dist/{chunk-55XCU76K-dcpLOktb.js → chunk-55XCU76K-Bja7bE8g.js} +1 -1
  30. package/dist/{chunk-5VM5RSS4-BdpQuzmO.js → chunk-5VM5RSS4-CGTnbRRi.js} +1 -1
  31. package/dist/{chunk-JWPE2WC7-CDBrSjU7.js → chunk-JWPE2WC7-2AyjxdJR.js} +1 -1
  32. package/dist/{chunk-VQ5W62QI-BiVKc40w.js → chunk-VQ5W62QI-B3PGCKOg.js} +1 -1
  33. package/dist/{chunk-XXDRQBXY-CPYrcdVW.js → chunk-XXDRQBXY-RrIsI-B5.js} +1 -1
  34. package/dist/{chunk-ZCHMQSOR-BG8OLpvb.js → chunk-ZCHMQSOR-COJTBW1i.js} +2 -2
  35. package/dist/{classDiagram-v2-4MYWR3UA-DqbpQpwI.js → classDiagram-v2-4MYWR3UA-DolLxH6t.js} +5 -5
  36. package/dist/{cose-bilkent-JH36ORCC-CdXk4sPf.js → cose-bilkent-JH36ORCC-DMSYgFxc.js} +2 -2
  37. package/dist/customComponents-DasaZ6pq.js +1 -1
  38. package/dist/customComponents.en-US-CkabuCXg.js +1 -1
  39. package/dist/{customParseFormat-C0uLEpdq.js → customParseFormat-C9WAjjqH.js} +1 -1
  40. package/dist/{cynefinDiagram-WF24UDRP-BYT_KpDL.js → cynefinDiagram-WF24UDRP-DrksRWCn.js} +2 -2
  41. package/dist/{dagre-NK4GIZVX-l-ghPdM8.js → dagre-NK4GIZVX-CFRT2dAc.js} +2 -2
  42. package/dist/{dayjs.min-DZ-YV8Mv.js → dayjs.min-CziT8yW9.js} +1 -1
  43. package/dist/{diagram-CBK3MWTC-Bt3HiwvA.js → diagram-CBK3MWTC-DzZ_sQCl.js} +3 -3
  44. package/dist/{diagram-I5XIIV2D-DcbqfBjx.js → diagram-I5XIIV2D-RYNBUOF4.js} +2 -2
  45. package/dist/{diagram-ODIL2UCW-9PC1n3n5.js → diagram-ODIL2UCW-DqJETE9R.js} +3 -3
  46. package/dist/{diagram-PFBEJUXE-DGhr2kc7.js → diagram-PFBEJUXE-BekIE7hh.js} +2 -2
  47. package/dist/{diagram-RJA3I4VV-DwzpOjZ_.js → diagram-RJA3I4VV-DAIwlMxl.js} +2 -2
  48. package/dist/{diagram-TYUNFSNR-B3Bd3TDU.js → diagram-TYUNFSNR-CLJ0Ou9i.js} +6 -6
  49. package/dist/{ebnfDiagram-V4P3TTPT-E5NN2oKc.js → ebnfDiagram-V4P3TTPT-CRs8ppfT.js} +3 -3
  50. package/dist/{elk-QONTBCTQ-dFjcujl_.js → elk-QONTBCTQ-Bqoh6AYY.js} +5 -5
  51. package/dist/{erDiagram-KYQIGQAA-BMrasBzB.js → erDiagram-KYQIGQAA-BSp8Z7uQ.js} +4 -4
  52. package/dist/{flowDiagram-IUGLLWBU-BGIBH0q0.js → flowDiagram-IUGLLWBU-WKILTCDc.js} +7 -7
  53. package/dist/{ganttDiagram-R7GPNTJY-C0tb1Lpp.js → ganttDiagram-R7GPNTJY-CaTn_Mmr.js} +4 -4
  54. package/dist/generateCypher-BE_4YCWB.js +1032 -0
  55. package/dist/{gitGraphDiagram-PDYL7XHY-DBqcOa-c.js → gitGraphDiagram-PDYL7XHY-DGPs-RF6.js} +3 -3
  56. package/dist/{infoDiagram-MVDRKAX5-Bwuki4JA.js → infoDiagram-MVDRKAX5-HIQg7U3R.js} +1 -1
  57. package/dist/{ishikawaDiagram-HPEHV2GE-Dz4d6ygx.js → ishikawaDiagram-HPEHV2GE-C84x8n2j.js} +2 -2
  58. package/dist/{journeyDiagram-BOSHW7O7-C99m34Bb.js → journeyDiagram-BOSHW7O7-CvYDNxSY.js} +4 -4
  59. package/dist/{kanban-definition-FNSA4HC5-mdqjODsT.js → kanban-definition-FNSA4HC5-B586ryFD.js} +2 -2
  60. package/dist/{mermaid.core-yQghUlIz.js → mermaid.core-3J01L12Z.js} +5803 -5740
  61. package/dist/{mindmap-definition-6OY57UG3-BZhO2wX4.js → mindmap-definition-6OY57UG3-Donc6BMy.js} +3 -3
  62. package/dist/{models-DekiCOuZ.js → models-Rf3LB8wS.js} +1 -1
  63. package/dist/{object-metric-numeric-vs3BeDkH.js → object-metric-numeric-BcgaJ6EW.js} +1 -1
  64. package/dist/{object-metric.service-flZgBMRX.js → object-metric.service-CKiaFYcp.js} +2 -2
  65. package/dist/{pegDiagram-ECIUJNBX-BDa5RfZt.js → pegDiagram-ECIUJNBX-CYVi7x6D.js} +3 -3
  66. package/dist/{pieDiagram-GNMPY74T-DNVtzXPv.js → pieDiagram-GNMPY74T-4iWKYTTS.js} +2 -2
  67. package/dist/{prompt-DYrjlEFr.js → prompt-BQzBLrua.js} +110 -100
  68. package/dist/{quadrantDiagram-D57K4MC3-vK0f2OvQ.js → quadrantDiagram-D57K4MC3-Bm6Cyi1I.js} +1 -1
  69. package/dist/{railroadDiagram-Y72NRBL7-j6ZrTmRp.js → railroadDiagram-Y72NRBL7-Du6iN-Jz.js} +3 -3
  70. package/dist/{requirementDiagram-EQYSW5RA-DgfEyljA.js → requirementDiagram-EQYSW5RA-BGxpuSlc.js} +3 -3
  71. package/dist/{sankeyDiagram-SY24JHO5-CImx-IX0.js → sankeyDiagram-SY24JHO5-CsHmu__D.js} +2 -2
  72. package/dist/{sequenceDiagram-BLEHNHQU-nWmjd1ci.js → sequenceDiagram-BLEHNHQU-DBNi943L.js} +3 -3
  73. package/dist/{sizeCapture-INFHLROL-D3jlbt7h.js → sizeCapture-INFHLROL-CcGr2ilA.js} +1 -1
  74. package/dist/{stateDiagram-v2-A6IESKWZ-DG1ZetEu.js → stateDiagram-v2-A6IESKWZ-C78tVzaF.js} +4 -4
  75. package/dist/{swimlanes-B3ENRKFQ-cCmJE8AU.js → swimlanes-B3ENRKFQ-BROc4LGM.js} +3 -3
  76. package/dist/{swimlanesDiagram-AYQRV4AK-CtuhyguU.js → swimlanesDiagram-AYQRV4AK-C0RDY4m2.js} +3 -3
  77. package/dist/{text-BqSVQKS6.js → text-CzC6K33E.js} +7 -3
  78. package/dist/{text.en-US-BhAxy_LE.js → text.en-US-D8mxBP0p.js} +6 -2
  79. package/dist/{timeline-definition-JXYKGLGB-Cc-INsOv.js → timeline-definition-JXYKGLGB-C6WGe4xl.js} +1 -1
  80. package/dist/toolMatchLines-DrXpUwcl.js +4675 -0
  81. package/dist/{useLabData-Df-jEHKs.js → useLabData-B-3UW8zF.js} +8008 -7251
  82. package/dist/{usecaseDiagram-WPOLBNNX-r8wVjopm.js → usecaseDiagram-WPOLBNNX-yMP7SDIg.js} +3 -3
  83. package/dist/{vennDiagram-Q3Y3IDCW-BZiOcgrj.js → vennDiagram-Q3Y3IDCW-bZW2LzBB.js} +2 -2
  84. package/dist/{wardleyDiagram-IVAIDKWA-16jd07C_.js → wardleyDiagram-IVAIDKWA-DBbog93x.js} +2 -2
  85. package/dist/{workshop-app-DnHNjBqy.js → workshop-app-ByYXbgcn.js} +5060 -4721
  86. package/dist/workshop-app.css +1 -1
  87. package/dist/workshop-app.js +1 -1
  88. package/dist/{xychartDiagram-4URNHDU4-C8DwWQNh.js → xychartDiagram-4URNHDU4-CVLJNXOt.js} +1 -1
  89. package/dist-cli/workshop.js +182 -140
  90. package/package.json +1 -1
  91. package/skill/SKILL.en-US.md +5 -0
  92. package/skill/SKILL.md +3 -0
  93. package/dist/AppFormModal-D73ucaHK.js +0 -4282
  94. package/dist/AppListPage-D87piiOw.js +0 -1364
  95. package/dist/WorkshopLabPage-DiVXQL9e.js +0 -11364
  96. package/dist/generateCypher-Ch9_lQa6.js +0 -399
@@ -0,0 +1,4675 @@
1
+ import { r as b, as as Be, at as fe, au as hs, av as ue, aw as z, ax as te, ay as wn, az as vn, aA as kn, aB as F, aC as K, aD as gs, aE as $n, aF as ys, aG as V, aH as bt, aI as bs, aJ as ws, aK as X, aL as Sn, aM as Nn, aN as qt, aO as vs, aP as Kt, aQ as ks, aR as $s, aS as Ss, aT as Ns, aU as St, Y as Is, aV as In, aW as Ts, aX as Es, aY as As, aZ as zt, a as wt, a_ as Ht, a$ as Os, b0 as Ls, b1 as Cs, b2 as _s, b3 as Vt, b4 as xs, N as Ds, O as Ps, b5 as Ee, b6 as Ms, b7 as Fe, b8 as Rs, b9 as Tn, ba as j, bb as Te, bc as Nt, bd as It, be as Tt, bf as Fs, bg as we, bh as js, bi as Us, bj as Ve, bk as Et, bl as Xt, bm as Bs, bn as Gt, bo as Wt, bp as Qe, bq as qs, br as Ks, bs as En, bt as zs, bu as be, bv as et, bw as Xe, bx as je, by as Yt, bz as Hs, bA as Vs, bB as Xs, bC as An, bD as Gs, bE as Ws, bF as Ys, bG as Js, w as At, j as _, u as Zs, i as Jt, I as Zt, ao as Qs } from "./workshop-app-ByYXbgcn.js";
2
+ import { bM as ei, bN as ti, bO as ni, bP as ee, bQ as Qt, M as si, A as ii, bR as ai, bS as en, ap as ri, aq as oi, bT as li, bU as ci, a7 as ui, b6 as fi, bV as di, bW as pi, bX as mi } from "./useLabData-B-3UW8zF.js";
3
+ var hi = { icon: { tag: "svg", attrs: { viewBox: "64 64 896 896", focusable: "false" }, children: [{ tag: "path", attrs: { d: "M360 184h-8c4.4 0 8-3.6 8-8v8h304v-8c0 4.4 3.6 8 8 8h-8v72h72v-80c0-35.3-28.7-64-64-64H352c-35.3 0-64 28.7-64 64v80h72v-72zm504 72H160c-17.7 0-32 14.3-32 32v32c0 4.4 3.6 8 8 8h60.4l24.7 523c1.6 34.1 29.8 61 63.9 61h454c34.2 0 62.3-26.8 63.9-61l24.7-523H888c4.4 0 8-3.6 8-8v-32c0-17.7-14.3-32-32-32zM731.3 840H292.7l-24.2-512h487l-24.2 512z" } }] }, name: "delete", theme: "outlined" }, gi = function(t, n) {
4
+ return /* @__PURE__ */ b.createElement(Be, fe({}, t, {
5
+ ref: n,
6
+ icon: hi
7
+ }));
8
+ }, yi = /* @__PURE__ */ b.forwardRef(gi);
9
+ const ut = (function(e, t) {
10
+ if (e && t) {
11
+ var n = Array.isArray(t) ? t : t.split(","), s = e.name || "", i = e.type || "", a = i.replace(/\/.*$/, "");
12
+ return n.some(function(r) {
13
+ var o = r.trim();
14
+ if (/^\*(\/\*)?$/.test(r))
15
+ return !0;
16
+ if (o.charAt(0) === ".") {
17
+ var c = s.toLowerCase(), l = o.toLowerCase(), u = [l];
18
+ return (l === ".jpg" || l === ".jpeg") && (u = [".jpg", ".jpeg"]), u.some(function(f) {
19
+ return c.endsWith(f);
20
+ });
21
+ }
22
+ return /\/\*$/.test(o) ? a === o.replace(/\/.*$/, "") : i === o ? !0 : /^\w+$/.test(o) ? (hs(!1, "Upload takes an invalidate 'accept' type '".concat(o, "'.Skip for check.")), !0) : !1;
23
+ });
24
+ }
25
+ return !0;
26
+ });
27
+ function bi(e, t) {
28
+ var n = "cannot ".concat(e.method, " ").concat(e.action, " ").concat(t.status, "'"), s = new Error(n);
29
+ return s.status = t.status, s.method = e.method, s.url = e.action, s;
30
+ }
31
+ function tn(e) {
32
+ var t = e.responseText || e.response;
33
+ if (!t)
34
+ return t;
35
+ try {
36
+ return JSON.parse(t);
37
+ } catch {
38
+ return t;
39
+ }
40
+ }
41
+ function nn(e) {
42
+ var t = new XMLHttpRequest();
43
+ e.onProgress && t.upload && (t.upload.onprogress = function(a) {
44
+ a.total > 0 && (a.percent = a.loaded / a.total * 100), e.onProgress(a);
45
+ });
46
+ var n = new FormData();
47
+ e.data && Object.keys(e.data).forEach(function(i) {
48
+ var a = e.data[i];
49
+ if (Array.isArray(a)) {
50
+ a.forEach(function(r) {
51
+ n.append("".concat(i, "[]"), r);
52
+ });
53
+ return;
54
+ }
55
+ n.append(i, a);
56
+ }), e.file instanceof Blob ? n.append(e.filename, e.file, e.file.name) : n.append(e.filename, e.file), t.onerror = function(a) {
57
+ e.onError(a);
58
+ }, t.onload = function() {
59
+ return t.status < 200 || t.status >= 300 ? e.onError(bi(e, t), tn(t)) : e.onSuccess(tn(t), t);
60
+ }, t.open(e.method, e.action, !0), e.withCredentials && "withCredentials" in t && (t.withCredentials = !0);
61
+ var s = e.headers || {};
62
+ return s["X-Requested-With"] !== null && t.setRequestHeader("X-Requested-With", "XMLHttpRequest"), Object.keys(s).forEach(function(i) {
63
+ s[i] !== null && t.setRequestHeader(i, s[i]);
64
+ }), t.send(n), {
65
+ abort: function() {
66
+ t.abort();
67
+ }
68
+ };
69
+ }
70
+ var wi = /* @__PURE__ */ (function() {
71
+ var e = ue(/* @__PURE__ */ z().mark(function t(n, s) {
72
+ var i, a, r, o, c, l, u, f;
73
+ return z().wrap(function(h) {
74
+ for (; ; ) switch (h.prev = h.next) {
75
+ case 0:
76
+ l = function() {
77
+ return l = ue(/* @__PURE__ */ z().mark(function p(m) {
78
+ return z().wrap(function(v) {
79
+ for (; ; ) switch (v.prev = v.next) {
80
+ case 0:
81
+ return v.abrupt("return", new Promise(function($) {
82
+ m.file(function(S) {
83
+ s(S) ? (m.fullPath && !S.webkitRelativePath && (Object.defineProperties(S, {
84
+ webkitRelativePath: {
85
+ writable: !0
86
+ }
87
+ }), S.webkitRelativePath = m.fullPath.replace(/^\//, ""), Object.defineProperties(S, {
88
+ webkitRelativePath: {
89
+ writable: !1
90
+ }
91
+ })), $(S)) : $(null);
92
+ });
93
+ }));
94
+ case 1:
95
+ case "end":
96
+ return v.stop();
97
+ }
98
+ }, p);
99
+ })), l.apply(this, arguments);
100
+ }, c = function(p) {
101
+ return l.apply(this, arguments);
102
+ }, o = function() {
103
+ return o = ue(/* @__PURE__ */ z().mark(function p(m) {
104
+ var w, v, $, S, y;
105
+ return z().wrap(function(I) {
106
+ for (; ; ) switch (I.prev = I.next) {
107
+ case 0:
108
+ w = m.createReader(), v = [];
109
+ case 2:
110
+ return I.next = 5, new Promise(function(k) {
111
+ w.readEntries(k, function() {
112
+ return k([]);
113
+ });
114
+ });
115
+ case 5:
116
+ if ($ = I.sent, S = $.length, S) {
117
+ I.next = 9;
118
+ break;
119
+ }
120
+ return I.abrupt("break", 12);
121
+ case 9:
122
+ for (y = 0; y < S; y++)
123
+ v.push($[y]);
124
+ I.next = 2;
125
+ break;
126
+ case 12:
127
+ return I.abrupt("return", v);
128
+ case 13:
129
+ case "end":
130
+ return I.stop();
131
+ }
132
+ }, p);
133
+ })), o.apply(this, arguments);
134
+ }, r = function(p) {
135
+ return o.apply(this, arguments);
136
+ }, i = [], a = [], n.forEach(function(g) {
137
+ return a.push(g.webkitGetAsEntry());
138
+ }), u = /* @__PURE__ */ (function() {
139
+ var g = ue(/* @__PURE__ */ z().mark(function p(m, w) {
140
+ var v, $;
141
+ return z().wrap(function(y) {
142
+ for (; ; ) switch (y.prev = y.next) {
143
+ case 0:
144
+ if (m) {
145
+ y.next = 2;
146
+ break;
147
+ }
148
+ return y.abrupt("return");
149
+ case 2:
150
+ if (m.path = w || "", !m.isFile) {
151
+ y.next = 10;
152
+ break;
153
+ }
154
+ return y.next = 6, c(m);
155
+ case 6:
156
+ v = y.sent, v && i.push(v), y.next = 15;
157
+ break;
158
+ case 10:
159
+ if (!m.isDirectory) {
160
+ y.next = 15;
161
+ break;
162
+ }
163
+ return y.next = 13, r(m);
164
+ case 13:
165
+ $ = y.sent, a.push.apply(a, te($));
166
+ case 15:
167
+ case "end":
168
+ return y.stop();
169
+ }
170
+ }, p);
171
+ }));
172
+ return function(m, w) {
173
+ return g.apply(this, arguments);
174
+ };
175
+ })(), f = 0;
176
+ case 9:
177
+ if (!(f < a.length)) {
178
+ h.next = 15;
179
+ break;
180
+ }
181
+ return h.next = 12, u(a[f]);
182
+ case 12:
183
+ f++, h.next = 9;
184
+ break;
185
+ case 15:
186
+ return h.abrupt("return", i);
187
+ case 16:
188
+ case "end":
189
+ return h.stop();
190
+ }
191
+ }, t);
192
+ }));
193
+ return function(n, s) {
194
+ return e.apply(this, arguments);
195
+ };
196
+ })(), vi = +/* @__PURE__ */ new Date(), ki = 0;
197
+ function ft() {
198
+ return "rc-upload-".concat(vi, "-").concat(++ki);
199
+ }
200
+ var $i = ["component", "prefixCls", "className", "classNames", "disabled", "id", "name", "style", "styles", "multiple", "accept", "capture", "children", "directory", "folder", "openFileDialogOnClick", "onMouseEnter", "onMouseLeave", "hasControlInside"], Si = /* @__PURE__ */ (function(e) {
201
+ wn(n, e);
202
+ var t = vn(n);
203
+ function n() {
204
+ var s;
205
+ kn(this, n);
206
+ for (var i = arguments.length, a = new Array(i), r = 0; r < i; r++)
207
+ a[r] = arguments[r];
208
+ return s = t.call.apply(t, [this].concat(a)), F(K(s), "state", {
209
+ uid: ft()
210
+ }), F(K(s), "reqs", {}), F(K(s), "fileInput", void 0), F(K(s), "_isMounted", void 0), F(K(s), "onChange", function(o) {
211
+ var c = s.props, l = c.accept, u = c.directory, f = o.target.files, d = te(f).filter(function(h) {
212
+ return !u || ut(h, l);
213
+ });
214
+ s.uploadFiles(d), s.reset();
215
+ }), F(K(s), "onClick", function(o) {
216
+ var c = s.fileInput;
217
+ if (c) {
218
+ var l = o.target, u = s.props.onClick;
219
+ if (l && l.tagName === "BUTTON") {
220
+ var f = c.parentNode;
221
+ f.focus(), l.blur();
222
+ }
223
+ c.click(), u && u(o);
224
+ }
225
+ }), F(K(s), "onKeyDown", function(o) {
226
+ o.key === "Enter" && s.onClick(o);
227
+ }), F(K(s), "onDataTransferFiles", /* @__PURE__ */ (function() {
228
+ var o = ue(/* @__PURE__ */ z().mark(function c(l, u) {
229
+ var f, d, h, g, p, m, w;
230
+ return z().wrap(function($) {
231
+ for (; ; ) switch ($.prev = $.next) {
232
+ case 0:
233
+ if (f = s.props, d = f.multiple, h = f.accept, g = f.directory, p = te(l.items || []), m = te(l.files || []), (m.length > 0 || p.some(function(S) {
234
+ return S.kind === "file";
235
+ })) && u?.(), !g) {
236
+ $.next = 11;
237
+ break;
238
+ }
239
+ return $.next = 7, wi(Array.prototype.slice.call(p), function(S) {
240
+ return ut(S, s.props.accept);
241
+ });
242
+ case 7:
243
+ m = $.sent, s.uploadFiles(m), $.next = 14;
244
+ break;
245
+ case 11:
246
+ w = te(m).filter(function(S) {
247
+ return ut(S, h);
248
+ }), d === !1 && (w = m.slice(0, 1)), s.uploadFiles(w);
249
+ case 14:
250
+ case "end":
251
+ return $.stop();
252
+ }
253
+ }, c);
254
+ }));
255
+ return function(c, l) {
256
+ return o.apply(this, arguments);
257
+ };
258
+ })()), F(K(s), "onFilePaste", /* @__PURE__ */ (function() {
259
+ var o = ue(/* @__PURE__ */ z().mark(function c(l) {
260
+ var u, f;
261
+ return z().wrap(function(h) {
262
+ for (; ; ) switch (h.prev = h.next) {
263
+ case 0:
264
+ if (u = s.props.pastable, u) {
265
+ h.next = 3;
266
+ break;
267
+ }
268
+ return h.abrupt("return");
269
+ case 3:
270
+ if (l.type !== "paste") {
271
+ h.next = 6;
272
+ break;
273
+ }
274
+ return f = l.clipboardData, h.abrupt("return", s.onDataTransferFiles(f, function() {
275
+ l.preventDefault();
276
+ }));
277
+ case 6:
278
+ case "end":
279
+ return h.stop();
280
+ }
281
+ }, c);
282
+ }));
283
+ return function(c) {
284
+ return o.apply(this, arguments);
285
+ };
286
+ })()), F(K(s), "onFileDragOver", function(o) {
287
+ o.preventDefault();
288
+ }), F(K(s), "onFileDrop", /* @__PURE__ */ (function() {
289
+ var o = ue(/* @__PURE__ */ z().mark(function c(l) {
290
+ var u;
291
+ return z().wrap(function(d) {
292
+ for (; ; ) switch (d.prev = d.next) {
293
+ case 0:
294
+ if (l.preventDefault(), l.type !== "drop") {
295
+ d.next = 4;
296
+ break;
297
+ }
298
+ return u = l.dataTransfer, d.abrupt("return", s.onDataTransferFiles(u));
299
+ case 4:
300
+ case "end":
301
+ return d.stop();
302
+ }
303
+ }, c);
304
+ }));
305
+ return function(c) {
306
+ return o.apply(this, arguments);
307
+ };
308
+ })()), F(K(s), "uploadFiles", function(o) {
309
+ var c = te(o), l = c.map(function(u) {
310
+ return u.uid = ft(), s.processFile(u, c);
311
+ });
312
+ Promise.all(l).then(function(u) {
313
+ var f = s.props.onBatchStart;
314
+ f?.(u.map(function(d) {
315
+ var h = d.origin, g = d.parsedFile;
316
+ return {
317
+ file: h,
318
+ parsedFile: g
319
+ };
320
+ })), u.filter(function(d) {
321
+ return d.parsedFile !== null;
322
+ }).forEach(function(d) {
323
+ s.post(d);
324
+ });
325
+ });
326
+ }), F(K(s), "processFile", /* @__PURE__ */ (function() {
327
+ var o = ue(/* @__PURE__ */ z().mark(function c(l, u) {
328
+ var f, d, h, g, p, m, w, v, $;
329
+ return z().wrap(function(y) {
330
+ for (; ; ) switch (y.prev = y.next) {
331
+ case 0:
332
+ if (f = s.props.beforeUpload, d = l, !f) {
333
+ y.next = 14;
334
+ break;
335
+ }
336
+ return y.prev = 3, y.next = 6, f(l, u);
337
+ case 6:
338
+ d = y.sent, y.next = 12;
339
+ break;
340
+ case 9:
341
+ y.prev = 9, y.t0 = y.catch(3), d = !1;
342
+ case 12:
343
+ if (d !== !1) {
344
+ y.next = 14;
345
+ break;
346
+ }
347
+ return y.abrupt("return", {
348
+ origin: l,
349
+ parsedFile: null,
350
+ action: null,
351
+ data: null
352
+ });
353
+ case 14:
354
+ if (h = s.props.action, typeof h != "function") {
355
+ y.next = 21;
356
+ break;
357
+ }
358
+ return y.next = 18, h(l);
359
+ case 18:
360
+ g = y.sent, y.next = 22;
361
+ break;
362
+ case 21:
363
+ g = h;
364
+ case 22:
365
+ if (p = s.props.data, typeof p != "function") {
366
+ y.next = 29;
367
+ break;
368
+ }
369
+ return y.next = 26, p(l);
370
+ case 26:
371
+ m = y.sent, y.next = 30;
372
+ break;
373
+ case 29:
374
+ m = p;
375
+ case 30:
376
+ return w = // string type is from legacy `transformFile`.
377
+ // Not sure if this will work since no related test case works with it
378
+ (gs(d) === "object" || typeof d == "string") && d ? d : l, w instanceof File ? v = w : v = new File([w], l.name, {
379
+ type: l.type
380
+ }), $ = v, $.uid = l.uid, y.abrupt("return", {
381
+ origin: l,
382
+ data: m,
383
+ parsedFile: $,
384
+ action: g
385
+ });
386
+ case 35:
387
+ case "end":
388
+ return y.stop();
389
+ }
390
+ }, c, null, [[3, 9]]);
391
+ }));
392
+ return function(c, l) {
393
+ return o.apply(this, arguments);
394
+ };
395
+ })()), F(K(s), "saveFileInput", function(o) {
396
+ s.fileInput = o;
397
+ }), s;
398
+ }
399
+ return $n(n, [{
400
+ key: "componentDidMount",
401
+ value: function() {
402
+ this._isMounted = !0;
403
+ var i = this.props.pastable;
404
+ i && document.addEventListener("paste", this.onFilePaste);
405
+ }
406
+ }, {
407
+ key: "componentWillUnmount",
408
+ value: function() {
409
+ this._isMounted = !1, this.abort(), document.removeEventListener("paste", this.onFilePaste);
410
+ }
411
+ }, {
412
+ key: "componentDidUpdate",
413
+ value: function(i) {
414
+ var a = this.props.pastable;
415
+ a && !i.pastable ? document.addEventListener("paste", this.onFilePaste) : !a && i.pastable && document.removeEventListener("paste", this.onFilePaste);
416
+ }
417
+ }, {
418
+ key: "post",
419
+ value: function(i) {
420
+ var a = this, r = i.data, o = i.origin, c = i.action, l = i.parsedFile;
421
+ if (this._isMounted) {
422
+ var u = this.props, f = u.onStart, d = u.customRequest, h = u.name, g = u.headers, p = u.withCredentials, m = u.method, w = o.uid, v = d || nn, $ = {
423
+ action: c,
424
+ filename: h,
425
+ data: r,
426
+ file: l,
427
+ headers: g,
428
+ withCredentials: p,
429
+ method: m || "post",
430
+ onProgress: function(y) {
431
+ var N = a.props.onProgress;
432
+ N?.(y, l);
433
+ },
434
+ onSuccess: function(y, N) {
435
+ var I = a.props.onSuccess;
436
+ I?.(y, l, N), delete a.reqs[w];
437
+ },
438
+ onError: function(y, N) {
439
+ var I = a.props.onError;
440
+ I?.(y, N, l), delete a.reqs[w];
441
+ }
442
+ };
443
+ f(o), this.reqs[w] = v($, {
444
+ defaultRequest: nn
445
+ });
446
+ }
447
+ }
448
+ }, {
449
+ key: "reset",
450
+ value: function() {
451
+ this.setState({
452
+ uid: ft()
453
+ });
454
+ }
455
+ }, {
456
+ key: "abort",
457
+ value: function(i) {
458
+ var a = this.reqs;
459
+ if (i) {
460
+ var r = i.uid ? i.uid : i;
461
+ a[r] && a[r].abort && a[r].abort(), delete a[r];
462
+ } else
463
+ Object.keys(a).forEach(function(o) {
464
+ a[o] && a[o].abort && a[o].abort(), delete a[o];
465
+ });
466
+ }
467
+ }, {
468
+ key: "render",
469
+ value: function() {
470
+ var i = this.props, a = i.component, r = i.prefixCls, o = i.className, c = i.classNames, l = c === void 0 ? {} : c, u = i.disabled, f = i.id, d = i.name, h = i.style, g = i.styles, p = g === void 0 ? {} : g, m = i.multiple, w = i.accept, v = i.capture, $ = i.children, S = i.directory, y = i.folder, N = i.openFileDialogOnClick, I = i.onMouseEnter, k = i.onMouseLeave, L = i.hasControlInside, D = ys(i, $i), G = V(F(F(F({}, r, !0), "".concat(r, "-disabled"), u), o, o)), M = S || y ? {
471
+ directory: "directory",
472
+ webkitdirectory: "webkitdirectory"
473
+ } : {}, J = u ? {} : {
474
+ onClick: N ? this.onClick : function() {
475
+ },
476
+ onKeyDown: N ? this.onKeyDown : function() {
477
+ },
478
+ onMouseEnter: I,
479
+ onMouseLeave: k,
480
+ onDrop: this.onFileDrop,
481
+ onDragOver: this.onFileDragOver,
482
+ tabIndex: L ? void 0 : "0"
483
+ };
484
+ return /* @__PURE__ */ bt.createElement(a, fe({}, J, {
485
+ className: G,
486
+ role: L ? void 0 : "button",
487
+ style: h
488
+ }), /* @__PURE__ */ bt.createElement("input", fe({}, bs(D, {
489
+ aria: !0,
490
+ data: !0
491
+ }), {
492
+ id: f,
493
+ name: d,
494
+ disabled: u,
495
+ type: "file",
496
+ ref: this.saveFileInput,
497
+ onClick: function(ne) {
498
+ return ne.stopPropagation();
499
+ },
500
+ key: this.state.uid,
501
+ style: ws({
502
+ display: "none"
503
+ }, p.input),
504
+ className: l.input,
505
+ accept: w
506
+ }, M, {
507
+ multiple: m,
508
+ onChange: this.onChange
509
+ }, v != null ? {
510
+ capture: v
511
+ } : {})), $);
512
+ }
513
+ }]), n;
514
+ })(b.Component);
515
+ function dt() {
516
+ }
517
+ var vt = /* @__PURE__ */ (function(e) {
518
+ wn(n, e);
519
+ var t = vn(n);
520
+ function n() {
521
+ var s;
522
+ kn(this, n);
523
+ for (var i = arguments.length, a = new Array(i), r = 0; r < i; r++)
524
+ a[r] = arguments[r];
525
+ return s = t.call.apply(t, [this].concat(a)), F(K(s), "uploader", void 0), F(K(s), "saveUploader", function(o) {
526
+ s.uploader = o;
527
+ }), s;
528
+ }
529
+ return $n(n, [{
530
+ key: "abort",
531
+ value: function(i) {
532
+ this.uploader.abort(i);
533
+ }
534
+ }, {
535
+ key: "render",
536
+ value: function() {
537
+ return /* @__PURE__ */ bt.createElement(Si, fe({}, this.props, {
538
+ ref: this.saveUploader
539
+ }));
540
+ }
541
+ }]), n;
542
+ })(b.Component);
543
+ F(vt, "defaultProps", {
544
+ component: "span",
545
+ prefixCls: "rc-upload",
546
+ data: {},
547
+ headers: {},
548
+ name: "file",
549
+ multipart: !1,
550
+ onStart: dt,
551
+ onError: dt,
552
+ onSuccess: dt,
553
+ multiple: !1,
554
+ beforeUpload: null,
555
+ customRequest: null,
556
+ withCredentials: !1,
557
+ openFileDialogOnClick: !0,
558
+ hasControlInside: !1
559
+ });
560
+ const Ni = (e) => {
561
+ const {
562
+ componentCls: t,
563
+ iconCls: n
564
+ } = e;
565
+ return {
566
+ [`${t}-wrapper`]: {
567
+ [`${t}-drag`]: {
568
+ position: "relative",
569
+ width: "100%",
570
+ height: "100%",
571
+ textAlign: "center",
572
+ background: e.colorFillAlter,
573
+ border: `${X(e.lineWidth)} dashed ${e.colorBorder}`,
574
+ borderRadius: e.borderRadiusLG,
575
+ cursor: "pointer",
576
+ transition: `border-color ${e.motionDurationSlow}`,
577
+ [t]: {
578
+ padding: e.padding
579
+ },
580
+ [`${t}-btn`]: {
581
+ display: "table",
582
+ width: "100%",
583
+ height: "100%",
584
+ outline: "none",
585
+ borderRadius: e.borderRadiusLG,
586
+ "&:focus-visible": {
587
+ outline: `${X(e.lineWidthFocus)} solid ${e.colorPrimaryBorder}`
588
+ }
589
+ },
590
+ [`${t}-drag-container`]: {
591
+ display: "table-cell",
592
+ verticalAlign: "middle"
593
+ },
594
+ [`
595
+ &:not(${t}-disabled):hover,
596
+ &-hover:not(${t}-disabled)
597
+ `]: {
598
+ borderColor: e.colorPrimaryHover
599
+ },
600
+ [`p${t}-drag-icon`]: {
601
+ marginBottom: e.margin,
602
+ [n]: {
603
+ color: e.colorPrimary,
604
+ fontSize: e.uploadThumbnailSize
605
+ }
606
+ },
607
+ [`p${t}-text`]: {
608
+ margin: `0 0 ${X(e.marginXXS)}`,
609
+ color: e.colorTextHeading,
610
+ fontSize: e.fontSizeLG
611
+ },
612
+ [`p${t}-hint`]: {
613
+ color: e.colorTextDescription,
614
+ fontSize: e.fontSize
615
+ },
616
+ // ===================== Disabled =====================
617
+ [`&${t}-disabled`]: {
618
+ [`p${t}-drag-icon ${n},
619
+ p${t}-text,
620
+ p${t}-hint
621
+ `]: {
622
+ color: e.colorTextDisabled
623
+ }
624
+ }
625
+ }
626
+ }
627
+ };
628
+ }, Ii = (e) => {
629
+ const {
630
+ componentCls: t,
631
+ iconCls: n,
632
+ fontSize: s,
633
+ lineHeight: i,
634
+ calc: a
635
+ } = e, r = `${t}-list-item`, o = `${r}-actions`, c = `${r}-action`;
636
+ return {
637
+ [`${t}-wrapper`]: {
638
+ [`${t}-list`]: Object.assign(Object.assign({}, Sn()), {
639
+ lineHeight: e.lineHeight,
640
+ [r]: {
641
+ position: "relative",
642
+ height: a(e.lineHeight).mul(s).equal(),
643
+ marginTop: e.marginXS,
644
+ fontSize: s,
645
+ display: "flex",
646
+ alignItems: "center",
647
+ transition: `background-color ${e.motionDurationSlow}`,
648
+ borderRadius: e.borderRadiusSM,
649
+ "&:hover": {
650
+ backgroundColor: e.controlItemBgHover
651
+ },
652
+ [`${r}-name`]: Object.assign(Object.assign({}, Nn), {
653
+ padding: `0 ${X(e.paddingXS)}`,
654
+ lineHeight: i,
655
+ flex: "auto",
656
+ transition: `all ${e.motionDurationSlow}`
657
+ }),
658
+ [o]: {
659
+ whiteSpace: "nowrap",
660
+ [c]: {
661
+ opacity: 0
662
+ },
663
+ [n]: {
664
+ color: e.actionsColor,
665
+ transition: `all ${e.motionDurationSlow}`
666
+ },
667
+ [`
668
+ ${c}:focus-visible,
669
+ &.picture ${c}
670
+ `]: {
671
+ opacity: 1
672
+ }
673
+ },
674
+ [`${t}-icon ${n}`]: {
675
+ color: e.colorIcon,
676
+ fontSize: s
677
+ },
678
+ [`${r}-progress`]: {
679
+ position: "absolute",
680
+ bottom: e.calc(e.uploadProgressOffset).mul(-1).equal(),
681
+ width: "100%",
682
+ paddingInlineStart: a(s).add(e.paddingXS).equal(),
683
+ fontSize: s,
684
+ lineHeight: 0,
685
+ pointerEvents: "none",
686
+ "> div": {
687
+ margin: 0
688
+ }
689
+ }
690
+ },
691
+ [`${r}:hover ${c}`]: {
692
+ opacity: 1
693
+ },
694
+ [`${r}-error`]: {
695
+ color: e.colorError,
696
+ [`${r}-name, ${t}-icon ${n}`]: {
697
+ color: e.colorError
698
+ },
699
+ [o]: {
700
+ [`${n}, ${n}:hover`]: {
701
+ color: e.colorError
702
+ },
703
+ [c]: {
704
+ opacity: 1
705
+ }
706
+ }
707
+ },
708
+ [`${t}-list-item-container`]: {
709
+ transition: `opacity ${e.motionDurationSlow}, height ${e.motionDurationSlow}`,
710
+ // For smooth removing animation
711
+ "&::before": {
712
+ display: "table",
713
+ width: 0,
714
+ height: 0,
715
+ content: '""'
716
+ }
717
+ }
718
+ })
719
+ }
720
+ };
721
+ }, Ti = (e) => {
722
+ const {
723
+ componentCls: t
724
+ } = e, n = new qt("uploadAnimateInlineIn", {
725
+ from: {
726
+ width: 0,
727
+ height: 0,
728
+ padding: 0,
729
+ opacity: 0,
730
+ margin: e.calc(e.marginXS).div(-2).equal()
731
+ }
732
+ }), s = new qt("uploadAnimateInlineOut", {
733
+ to: {
734
+ width: 0,
735
+ height: 0,
736
+ padding: 0,
737
+ opacity: 0,
738
+ margin: e.calc(e.marginXS).div(-2).equal()
739
+ }
740
+ }), i = `${t}-animate-inline`;
741
+ return [{
742
+ [`${t}-wrapper`]: {
743
+ [`${i}-appear, ${i}-enter, ${i}-leave`]: {
744
+ animationDuration: e.motionDurationSlow,
745
+ animationTimingFunction: e.motionEaseInOutCirc,
746
+ animationFillMode: "forwards"
747
+ },
748
+ [`${i}-appear, ${i}-enter`]: {
749
+ animationName: n
750
+ },
751
+ [`${i}-leave`]: {
752
+ animationName: s
753
+ }
754
+ }
755
+ }, {
756
+ [`${t}-wrapper`]: vs(e)
757
+ }, n, s];
758
+ }, Ei = (e) => {
759
+ const {
760
+ componentCls: t,
761
+ iconCls: n,
762
+ uploadThumbnailSize: s,
763
+ uploadProgressOffset: i,
764
+ calc: a
765
+ } = e, r = `${t}-list`, o = `${r}-item`;
766
+ return {
767
+ [`${t}-wrapper`]: {
768
+ // ${listCls} 增加优先级
769
+ [`
770
+ ${r}${r}-picture,
771
+ ${r}${r}-picture-card,
772
+ ${r}${r}-picture-circle
773
+ `]: {
774
+ [o]: {
775
+ position: "relative",
776
+ height: a(s).add(a(e.lineWidth).mul(2)).add(a(e.paddingXS).mul(2)).equal(),
777
+ padding: e.paddingXS,
778
+ border: `${X(e.lineWidth)} ${e.lineType} ${e.colorBorder}`,
779
+ borderRadius: e.borderRadiusLG,
780
+ "&:hover": {
781
+ background: "transparent"
782
+ },
783
+ [`${o}-thumbnail`]: Object.assign(Object.assign({}, Nn), {
784
+ width: s,
785
+ height: s,
786
+ lineHeight: X(a(s).add(e.paddingSM).equal()),
787
+ textAlign: "center",
788
+ flex: "none",
789
+ [n]: {
790
+ fontSize: e.fontSizeHeading2,
791
+ color: e.colorPrimary
792
+ },
793
+ img: {
794
+ display: "block",
795
+ width: "100%",
796
+ height: "100%",
797
+ overflow: "hidden"
798
+ }
799
+ }),
800
+ [`${o}-progress`]: {
801
+ bottom: i,
802
+ width: `calc(100% - ${X(a(e.paddingSM).mul(2).equal())})`,
803
+ marginTop: 0,
804
+ paddingInlineStart: a(s).add(e.paddingXS).equal()
805
+ }
806
+ },
807
+ [`${o}-error`]: {
808
+ borderColor: e.colorError,
809
+ // Adjust the color of the error icon : https://github.com/ant-design/ant-design/pull/24160
810
+ [`${o}-thumbnail ${n}`]: {
811
+ [`svg path[fill='${Kt[0]}']`]: {
812
+ fill: e.colorErrorBg
813
+ },
814
+ [`svg path[fill='${Kt.primary}']`]: {
815
+ fill: e.colorError
816
+ }
817
+ }
818
+ },
819
+ [`${o}-uploading`]: {
820
+ borderStyle: "dashed",
821
+ [`${o}-name`]: {
822
+ marginBottom: i
823
+ }
824
+ }
825
+ },
826
+ [`${r}${r}-picture-circle ${o}`]: {
827
+ [`&, &::before, ${o}-thumbnail`]: {
828
+ borderRadius: "50%"
829
+ }
830
+ }
831
+ }
832
+ };
833
+ }, Ai = (e) => {
834
+ const {
835
+ componentCls: t,
836
+ iconCls: n,
837
+ fontSizeLG: s,
838
+ colorTextLightSolid: i,
839
+ calc: a
840
+ } = e, r = `${t}-list`, o = `${r}-item`, c = e.uploadPicCardSize;
841
+ return {
842
+ [`
843
+ ${t}-wrapper${t}-picture-card-wrapper,
844
+ ${t}-wrapper${t}-picture-circle-wrapper
845
+ `]: Object.assign(Object.assign({}, Sn()), {
846
+ display: "block",
847
+ [`${t}${t}-select`]: {
848
+ width: c,
849
+ height: c,
850
+ textAlign: "center",
851
+ verticalAlign: "top",
852
+ backgroundColor: e.colorFillAlter,
853
+ border: `${X(e.lineWidth)} dashed ${e.colorBorder}`,
854
+ borderRadius: e.borderRadiusLG,
855
+ cursor: "pointer",
856
+ transition: `border-color ${e.motionDurationSlow}`,
857
+ [`> ${t}`]: {
858
+ display: "flex",
859
+ alignItems: "center",
860
+ justifyContent: "center",
861
+ height: "100%",
862
+ textAlign: "center"
863
+ },
864
+ [`&:not(${t}-disabled):hover`]: {
865
+ borderColor: e.colorPrimary
866
+ }
867
+ },
868
+ // list
869
+ [`${r}${r}-picture-card, ${r}${r}-picture-circle`]: {
870
+ display: "flex",
871
+ flexWrap: "wrap",
872
+ "@supports not (gap: 1px)": {
873
+ "& > *": {
874
+ marginBlockEnd: e.marginXS,
875
+ marginInlineEnd: e.marginXS
876
+ }
877
+ },
878
+ "@supports (gap: 1px)": {
879
+ gap: e.marginXS
880
+ },
881
+ [`${r}-item-container`]: {
882
+ display: "inline-block",
883
+ width: c,
884
+ height: c,
885
+ verticalAlign: "top"
886
+ },
887
+ "&::after": {
888
+ display: "none"
889
+ },
890
+ "&::before": {
891
+ display: "none"
892
+ },
893
+ [o]: {
894
+ height: "100%",
895
+ margin: 0,
896
+ "&::before": {
897
+ position: "absolute",
898
+ zIndex: 1,
899
+ width: `calc(100% - ${X(a(e.paddingXS).mul(2).equal())})`,
900
+ height: `calc(100% - ${X(a(e.paddingXS).mul(2).equal())})`,
901
+ backgroundColor: e.colorBgMask,
902
+ opacity: 0,
903
+ transition: `all ${e.motionDurationSlow}`,
904
+ content: '" "'
905
+ }
906
+ },
907
+ [`${o}:hover`]: {
908
+ [`&::before, ${o}-actions`]: {
909
+ opacity: 1
910
+ }
911
+ },
912
+ [`${o}-actions`]: {
913
+ position: "absolute",
914
+ insetInlineStart: 0,
915
+ zIndex: 10,
916
+ width: "100%",
917
+ whiteSpace: "nowrap",
918
+ textAlign: "center",
919
+ opacity: 0,
920
+ transition: `all ${e.motionDurationSlow}`,
921
+ [`
922
+ ${n}-eye,
923
+ ${n}-download,
924
+ ${n}-delete
925
+ `]: {
926
+ zIndex: 10,
927
+ width: s,
928
+ margin: `0 ${X(e.marginXXS)}`,
929
+ fontSize: s,
930
+ cursor: "pointer",
931
+ transition: `all ${e.motionDurationSlow}`,
932
+ color: i,
933
+ "&:hover": {
934
+ color: i
935
+ },
936
+ svg: {
937
+ verticalAlign: "baseline"
938
+ }
939
+ }
940
+ },
941
+ [`${o}-thumbnail, ${o}-thumbnail img`]: {
942
+ position: "static",
943
+ display: "block",
944
+ width: "100%",
945
+ height: "100%",
946
+ objectFit: "contain"
947
+ },
948
+ [`${o}-name`]: {
949
+ display: "none",
950
+ textAlign: "center"
951
+ },
952
+ [`${o}-file + ${o}-name`]: {
953
+ position: "absolute",
954
+ bottom: e.margin,
955
+ display: "block",
956
+ width: `calc(100% - ${X(a(e.paddingXS).mul(2).equal())})`
957
+ },
958
+ [`${o}-uploading`]: {
959
+ [`&${o}`]: {
960
+ backgroundColor: e.colorFillAlter
961
+ },
962
+ [`&::before, ${n}-eye, ${n}-download, ${n}-delete`]: {
963
+ display: "none"
964
+ }
965
+ },
966
+ [`${o}-progress`]: {
967
+ bottom: e.marginXL,
968
+ width: `calc(100% - ${X(a(e.paddingXS).mul(2).equal())})`,
969
+ paddingInlineStart: 0
970
+ }
971
+ }
972
+ }),
973
+ [`${t}-wrapper${t}-picture-circle-wrapper`]: {
974
+ [`${t}${t}-select`]: {
975
+ borderRadius: "50%"
976
+ }
977
+ }
978
+ };
979
+ }, Oi = (e) => {
980
+ const {
981
+ componentCls: t
982
+ } = e;
983
+ return {
984
+ [`${t}-rtl`]: {
985
+ direction: "rtl"
986
+ }
987
+ };
988
+ }, Li = (e) => {
989
+ const {
990
+ componentCls: t,
991
+ colorTextDisabled: n
992
+ } = e;
993
+ return {
994
+ [`${t}-wrapper`]: Object.assign(Object.assign({}, Ss(e)), {
995
+ [t]: {
996
+ outline: 0,
997
+ "input[type='file']": {
998
+ cursor: "pointer"
999
+ }
1000
+ },
1001
+ [`${t}-select`]: {
1002
+ display: "inline-block"
1003
+ },
1004
+ [`${t}-hidden`]: {
1005
+ display: "none"
1006
+ },
1007
+ [`${t}-disabled`]: {
1008
+ color: n,
1009
+ cursor: "not-allowed"
1010
+ }
1011
+ })
1012
+ };
1013
+ }, Ci = (e) => ({
1014
+ actionsColor: e.colorIcon,
1015
+ pictureCardSize: e.controlHeightLG * 2.55
1016
+ }), _i = ks("Upload", (e) => {
1017
+ const {
1018
+ fontSizeHeading3: t,
1019
+ fontHeight: n,
1020
+ lineWidth: s,
1021
+ pictureCardSize: i,
1022
+ calc: a
1023
+ } = e, r = $s(e, {
1024
+ uploadThumbnailSize: a(t).mul(2).equal(),
1025
+ uploadProgressOffset: a(a(n).div(2)).add(s).equal(),
1026
+ uploadPicCardSize: i
1027
+ });
1028
+ return [Li(r), Ni(r), Ei(r), Ai(r), Ii(r), Ti(r), Oi(r), ei(r)];
1029
+ }, Ci);
1030
+ var xi = { icon: function(t, n) {
1031
+ return { tag: "svg", attrs: { viewBox: "64 64 896 896", focusable: "false" }, children: [{ tag: "path", attrs: { d: "M534 352V136H232v752h560V394H576a42 42 0 01-42-42z", fill: n } }, { tag: "path", attrs: { d: "M854.6 288.6L639.4 73.4c-6-6-14.1-9.4-22.6-9.4H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V311.3c0-8.5-3.4-16.7-9.4-22.7zM602 137.8L790.2 326H602V137.8zM792 888H232V136h302v216a42 42 0 0042 42h216v494z", fill: t } }] };
1032
+ }, name: "file", theme: "twotone" }, Di = function(t, n) {
1033
+ return /* @__PURE__ */ b.createElement(Be, fe({}, t, {
1034
+ ref: n,
1035
+ icon: xi
1036
+ }));
1037
+ }, Pi = /* @__PURE__ */ b.forwardRef(Di), Mi = { icon: { tag: "svg", attrs: { viewBox: "64 64 896 896", focusable: "false" }, children: [{ tag: "path", attrs: { d: "M779.3 196.6c-94.2-94.2-247.6-94.2-341.7 0l-261 260.8c-1.7 1.7-2.6 4-2.6 6.4s.9 4.7 2.6 6.4l36.9 36.9a9 9 0 0012.7 0l261-260.8c32.4-32.4 75.5-50.2 121.3-50.2s88.9 17.8 121.2 50.2c32.4 32.4 50.2 75.5 50.2 121.2 0 45.8-17.8 88.8-50.2 121.2l-266 265.9-43.1 43.1c-40.3 40.3-105.8 40.3-146.1 0-19.5-19.5-30.2-45.4-30.2-73s10.7-53.5 30.2-73l263.9-263.8c6.7-6.6 15.5-10.3 24.9-10.3h.1c9.4 0 18.1 3.7 24.7 10.3 6.7 6.7 10.3 15.5 10.3 24.9 0 9.3-3.7 18.1-10.3 24.7L372.4 653c-1.7 1.7-2.6 4-2.6 6.4s.9 4.7 2.6 6.4l36.9 36.9a9 9 0 0012.7 0l215.6-215.6c19.9-19.9 30.8-46.3 30.8-74.4s-11-54.6-30.8-74.4c-41.1-41.1-107.9-41-149 0L463 364 224.8 602.1A172.22 172.22 0 00174 724.8c0 46.3 18.1 89.8 50.8 122.5 33.9 33.8 78.3 50.7 122.7 50.7 44.4 0 88.8-16.9 122.6-50.7l309.2-309C824.8 492.7 850 432 850 367.5c.1-64.6-25.1-125.3-70.7-170.9z" } }] }, name: "paper-clip", theme: "outlined" }, Ri = function(t, n) {
1038
+ return /* @__PURE__ */ b.createElement(Be, fe({}, t, {
1039
+ ref: n,
1040
+ icon: Mi
1041
+ }));
1042
+ }, Fi = /* @__PURE__ */ b.forwardRef(Ri), ji = { icon: function(t, n) {
1043
+ return { tag: "svg", attrs: { viewBox: "64 64 896 896", focusable: "false" }, children: [{ tag: "path", attrs: { d: "M928 160H96c-17.7 0-32 14.3-32 32v640c0 17.7 14.3 32 32 32h832c17.7 0 32-14.3 32-32V192c0-17.7-14.3-32-32-32zm-40 632H136v-39.9l138.5-164.3 150.1 178L658.1 489 888 761.6V792zm0-129.8L664.2 396.8c-3.2-3.8-9-3.8-12.2 0L424.6 666.4l-144-170.7c-3.2-3.8-9-3.8-12.2 0L136 652.7V232h752v430.2z", fill: t } }, { tag: "path", attrs: { d: "M424.6 765.8l-150.1-178L136 752.1V792h752v-30.4L658.1 489z", fill: n } }, { tag: "path", attrs: { d: "M136 652.7l132.4-157c3.2-3.8 9-3.8 12.2 0l144 170.7L652 396.8c3.2-3.8 9-3.8 12.2 0L888 662.2V232H136v420.7zM304 280a88 88 0 110 176 88 88 0 010-176z", fill: n } }, { tag: "path", attrs: { d: "M276 368a28 28 0 1056 0 28 28 0 10-56 0z", fill: n } }, { tag: "path", attrs: { d: "M304 456a88 88 0 100-176 88 88 0 000 176zm0-116c15.5 0 28 12.5 28 28s-12.5 28-28 28-28-12.5-28-28 12.5-28 28-28z", fill: t } }] };
1044
+ }, name: "picture", theme: "twotone" }, Ui = function(t, n) {
1045
+ return /* @__PURE__ */ b.createElement(Be, fe({}, t, {
1046
+ ref: n,
1047
+ icon: ji
1048
+ }));
1049
+ }, Bi = /* @__PURE__ */ b.forwardRef(Ui);
1050
+ function Ge(e) {
1051
+ return Object.assign(Object.assign({}, e), {
1052
+ lastModified: e.lastModified,
1053
+ lastModifiedDate: e.lastModifiedDate,
1054
+ name: e.name,
1055
+ size: e.size,
1056
+ type: e.type,
1057
+ uid: e.uid,
1058
+ percent: 0,
1059
+ originFileObj: e
1060
+ });
1061
+ }
1062
+ function We(e, t) {
1063
+ const n = te(t), s = n.findIndex(({
1064
+ uid: i
1065
+ }) => i === e.uid);
1066
+ return s === -1 ? n.push(e) : n[s] = e, n;
1067
+ }
1068
+ function pt(e, t) {
1069
+ const n = e.uid !== void 0 ? "uid" : "name";
1070
+ return t.filter((s) => s[n] === e[n])[0];
1071
+ }
1072
+ function qi(e, t) {
1073
+ const n = e.uid !== void 0 ? "uid" : "name", s = t.filter((i) => i[n] !== e[n]);
1074
+ return s.length === t.length ? null : s;
1075
+ }
1076
+ const Ki = (e = "") => {
1077
+ const t = e.split("/"), s = t[t.length - 1].split(/#|\?/)[0];
1078
+ return (/\.[^./\\]*$/.exec(s) || [""])[0];
1079
+ }, On = (e) => e.indexOf("image/") === 0, zi = (e) => {
1080
+ if (e.type && !e.thumbUrl)
1081
+ return On(e.type);
1082
+ const t = e.thumbUrl || e.url || "", n = Ki(t);
1083
+ return /^data:image\//.test(t) || /(webp|svg|png|gif|jpg|jpeg|jfif|bmp|dpg|ico|heic|heif)$/i.test(n) ? !0 : !(/^data:/.test(t) || n);
1084
+ }, oe = 200;
1085
+ function Hi(e) {
1086
+ return new Promise((t) => {
1087
+ if (!e.type || !On(e.type)) {
1088
+ t("");
1089
+ return;
1090
+ }
1091
+ const n = document.createElement("canvas");
1092
+ n.width = oe, n.height = oe, n.style.cssText = `position: fixed; left: 0; top: 0; width: ${oe}px; height: ${oe}px; z-index: 9999; display: none;`, document.body.appendChild(n);
1093
+ const s = n.getContext("2d"), i = new Image();
1094
+ if (i.onload = () => {
1095
+ const {
1096
+ width: a,
1097
+ height: r
1098
+ } = i;
1099
+ let o = oe, c = oe, l = 0, u = 0;
1100
+ a > r ? (c = r * (oe / a), u = -(c - o) / 2) : (o = a * (oe / r), l = -(o - c) / 2), s.drawImage(i, l, u, o, c);
1101
+ const f = n.toDataURL();
1102
+ document.body.removeChild(n), window.URL.revokeObjectURL(i.src), t(f);
1103
+ }, i.crossOrigin = "anonymous", e.type.startsWith("image/svg+xml")) {
1104
+ const a = new FileReader();
1105
+ a.onload = () => {
1106
+ a.result && typeof a.result == "string" && (i.src = a.result);
1107
+ }, a.readAsDataURL(e);
1108
+ } else if (e.type.startsWith("image/gif")) {
1109
+ const a = new FileReader();
1110
+ a.onload = () => {
1111
+ a.result && t(a.result);
1112
+ }, a.readAsDataURL(e);
1113
+ } else
1114
+ i.src = window.URL.createObjectURL(e);
1115
+ });
1116
+ }
1117
+ var Vi = { icon: { tag: "svg", attrs: { viewBox: "64 64 896 896", focusable: "false" }, children: [{ tag: "path", attrs: { d: "M505.7 661a8 8 0 0012.6 0l112-141.7c4.1-5.2.4-12.9-6.3-12.9h-74.1V168c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v338.3H400c-6.7 0-10.4 7.7-6.3 12.9l112 141.8zM878 626h-60c-4.4 0-8 3.6-8 8v154H214V634c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v198c0 17.7 14.3 32 32 32h684c17.7 0 32-14.3 32-32V634c0-4.4-3.6-8-8-8z" } }] }, name: "download", theme: "outlined" }, Xi = function(t, n) {
1118
+ return /* @__PURE__ */ b.createElement(Be, fe({}, t, {
1119
+ ref: n,
1120
+ icon: Vi
1121
+ }));
1122
+ }, Gi = /* @__PURE__ */ b.forwardRef(Xi);
1123
+ const Wi = /* @__PURE__ */ b.forwardRef(({
1124
+ prefixCls: e,
1125
+ className: t,
1126
+ style: n,
1127
+ locale: s,
1128
+ listType: i,
1129
+ file: a,
1130
+ items: r,
1131
+ progress: o,
1132
+ iconRender: c,
1133
+ actionIconRender: l,
1134
+ itemRender: u,
1135
+ isImgUrl: f,
1136
+ showPreviewIcon: d,
1137
+ showRemoveIcon: h,
1138
+ showDownloadIcon: g,
1139
+ previewIcon: p,
1140
+ removeIcon: m,
1141
+ downloadIcon: w,
1142
+ extra: v,
1143
+ onPreview: $,
1144
+ onDownload: S,
1145
+ onClose: y
1146
+ }, N) => {
1147
+ var I, k;
1148
+ const {
1149
+ status: L
1150
+ } = a, [D, G] = b.useState(L);
1151
+ b.useEffect(() => {
1152
+ L !== "removed" && G(L);
1153
+ }, [L]);
1154
+ const [M, J] = b.useState(!1);
1155
+ b.useEffect(() => {
1156
+ const U = setTimeout(() => {
1157
+ J(!0);
1158
+ }, 300);
1159
+ return () => {
1160
+ clearTimeout(U);
1161
+ };
1162
+ }, []);
1163
+ const ae = c(a);
1164
+ let ne = /* @__PURE__ */ b.createElement("div", {
1165
+ className: `${e}-icon`
1166
+ }, ae);
1167
+ if (i === "picture" || i === "picture-card" || i === "picture-circle")
1168
+ if (D === "uploading" || !a.thumbUrl && !a.url) {
1169
+ const U = V(`${e}-list-item-thumbnail`, {
1170
+ [`${e}-list-item-file`]: D !== "uploading"
1171
+ });
1172
+ ne = /* @__PURE__ */ b.createElement("div", {
1173
+ className: U
1174
+ }, ae);
1175
+ } else {
1176
+ const U = f?.(a) ? /* @__PURE__ */ b.createElement("img", {
1177
+ src: a.thumbUrl || a.url,
1178
+ alt: a.name,
1179
+ className: `${e}-list-item-image`,
1180
+ crossOrigin: a.crossOrigin
1181
+ }) : ae, xe = V(`${e}-list-item-thumbnail`, {
1182
+ [`${e}-list-item-file`]: f && !f(a)
1183
+ });
1184
+ ne = /* @__PURE__ */ b.createElement("a", {
1185
+ className: xe,
1186
+ onClick: (He) => $(a, He),
1187
+ href: a.url || a.thumbUrl,
1188
+ target: "_blank",
1189
+ rel: "noopener noreferrer"
1190
+ }, U);
1191
+ }
1192
+ const Ce = V(`${e}-list-item`, `${e}-list-item-${D}`), Z = typeof a.linkProps == "string" ? JSON.parse(a.linkProps) : a.linkProps, se = (typeof h == "function" ? h(a) : h) ? l(
1193
+ (typeof m == "function" ? m(a) : m) || /* @__PURE__ */ b.createElement(yi, null),
1194
+ () => y(a),
1195
+ e,
1196
+ s.removeFile,
1197
+ // acceptUploadDisabled is true, only remove icon will follow Upload disabled prop
1198
+ // https://github.com/ant-design/ant-design/issues/46171
1199
+ !0
1200
+ ) : null, R = (typeof g == "function" ? g(a) : g) && D === "done" ? l((typeof w == "function" ? w(a) : w) || /* @__PURE__ */ b.createElement(Gi, null), () => S(a), e, s.downloadFile) : null, _e = i !== "picture-card" && i !== "picture-circle" && /* @__PURE__ */ b.createElement("span", {
1201
+ key: "download-delete",
1202
+ className: V(`${e}-list-item-actions`, {
1203
+ picture: i === "picture"
1204
+ })
1205
+ }, R, se), ve = typeof v == "function" ? v(a) : v, de = ve && /* @__PURE__ */ b.createElement("span", {
1206
+ className: `${e}-list-item-extra`
1207
+ }, ve), T = V(`${e}-list-item-name`), P = a.url ? /* @__PURE__ */ b.createElement("a", Object.assign({
1208
+ key: "view",
1209
+ target: "_blank",
1210
+ rel: "noopener noreferrer",
1211
+ className: T,
1212
+ title: a.name
1213
+ }, Z, {
1214
+ href: a.url,
1215
+ onClick: (U) => $(a, U)
1216
+ }), a.name, de) : /* @__PURE__ */ b.createElement("span", {
1217
+ key: "view",
1218
+ className: T,
1219
+ onClick: (U) => $(a, U),
1220
+ title: a.name
1221
+ }, a.name, de), q = (typeof d == "function" ? d(a) : d) && (a.url || a.thumbUrl) ? /* @__PURE__ */ b.createElement("a", {
1222
+ href: a.url || a.thumbUrl,
1223
+ target: "_blank",
1224
+ rel: "noopener noreferrer",
1225
+ onClick: (U) => $(a, U),
1226
+ title: s.previewFile
1227
+ }, typeof p == "function" ? p(a) : p || /* @__PURE__ */ b.createElement(Ns, null)) : null, ie = (i === "picture-card" || i === "picture-circle") && D !== "uploading" && /* @__PURE__ */ b.createElement("span", {
1228
+ className: `${e}-list-item-actions`
1229
+ }, q, D === "done" && R, se), {
1230
+ getPrefixCls: ke
1231
+ } = b.useContext(St), pe = ke(), me = /* @__PURE__ */ b.createElement("div", {
1232
+ className: Ce
1233
+ }, ne, P, _e, ie, M && /* @__PURE__ */ b.createElement(In, {
1234
+ motionName: `${pe}-fade`,
1235
+ visible: D === "uploading",
1236
+ motionDeadline: 2e3
1237
+ }, ({
1238
+ className: U
1239
+ }) => {
1240
+ const xe = "percent" in a ? /* @__PURE__ */ b.createElement(ti, Object.assign({
1241
+ type: "line",
1242
+ percent: a.percent,
1243
+ "aria-label": a["aria-label"],
1244
+ "aria-labelledby": a["aria-labelledby"]
1245
+ }, o)) : null;
1246
+ return /* @__PURE__ */ b.createElement("div", {
1247
+ className: V(`${e}-list-item-progress`, U)
1248
+ }, xe);
1249
+ })), he = a.response && typeof a.response == "string" ? a.response : ((I = a.error) === null || I === void 0 ? void 0 : I.statusText) || ((k = a.error) === null || k === void 0 ? void 0 : k.message) || s.uploadError, re = D === "error" ? /* @__PURE__ */ b.createElement(Is, {
1250
+ title: he,
1251
+ getPopupContainer: (U) => U.parentNode
1252
+ }, me) : me;
1253
+ return /* @__PURE__ */ b.createElement("div", {
1254
+ className: V(`${e}-list-item-container`, t),
1255
+ style: n,
1256
+ ref: N
1257
+ }, u ? u(re, a, r, {
1258
+ download: S.bind(null, a),
1259
+ preview: $.bind(null, a),
1260
+ remove: y.bind(null, a)
1261
+ }) : re);
1262
+ }), Yi = (e, t) => {
1263
+ const {
1264
+ listType: n = "text",
1265
+ previewFile: s = Hi,
1266
+ onPreview: i,
1267
+ onDownload: a,
1268
+ onRemove: r,
1269
+ locale: o,
1270
+ iconRender: c,
1271
+ isImageUrl: l = zi,
1272
+ prefixCls: u,
1273
+ items: f = [],
1274
+ showPreviewIcon: d = !0,
1275
+ showRemoveIcon: h = !0,
1276
+ showDownloadIcon: g = !1,
1277
+ removeIcon: p,
1278
+ previewIcon: m,
1279
+ downloadIcon: w,
1280
+ extra: v,
1281
+ progress: $ = {
1282
+ size: [-1, 2],
1283
+ showInfo: !1
1284
+ },
1285
+ appendAction: S,
1286
+ appendActionVisible: y = !0,
1287
+ itemRender: N,
1288
+ disabled: I
1289
+ } = e, [, k] = ni(), [L, D] = b.useState(!1), G = ["picture-card", "picture-circle"].includes(n);
1290
+ b.useEffect(() => {
1291
+ n.startsWith("picture") && (f || []).forEach((T) => {
1292
+ !(T.originFileObj instanceof File || T.originFileObj instanceof Blob) || T.thumbUrl !== void 0 || (T.thumbUrl = "", s?.(T.originFileObj).then((P) => {
1293
+ T.thumbUrl = P || "", k();
1294
+ }));
1295
+ });
1296
+ }, [n, f, s]), b.useEffect(() => {
1297
+ D(!0);
1298
+ }, []);
1299
+ const M = (T, P) => {
1300
+ if (i)
1301
+ return P?.preventDefault(), i(T);
1302
+ }, J = (T) => {
1303
+ typeof a == "function" ? a(T) : T.url && window.open(T.url);
1304
+ }, ae = (T) => {
1305
+ r?.(T);
1306
+ }, ne = (T) => {
1307
+ if (c)
1308
+ return c(T, n);
1309
+ const P = T.status === "uploading";
1310
+ if (n.startsWith("picture")) {
1311
+ const q = n === "picture" ? /* @__PURE__ */ b.createElement(Ht, null) : o.uploading, ie = l?.(T) ? /* @__PURE__ */ b.createElement(Bi, null) : /* @__PURE__ */ b.createElement(Pi, null);
1312
+ return P ? q : ie;
1313
+ }
1314
+ return P ? /* @__PURE__ */ b.createElement(Ht, null) : /* @__PURE__ */ b.createElement(Fi, null);
1315
+ }, Ce = (T, P, q, ie, ke) => {
1316
+ const pe = {
1317
+ type: "text",
1318
+ size: "small",
1319
+ title: ie,
1320
+ onClick: (me) => {
1321
+ var he, re;
1322
+ P(), /* @__PURE__ */ b.isValidElement(T) && ((re = (he = T.props).onClick) === null || re === void 0 || re.call(he, me));
1323
+ },
1324
+ className: `${q}-list-item-action`,
1325
+ disabled: ke ? I : !1
1326
+ };
1327
+ return /* @__PURE__ */ b.isValidElement(T) ? /* @__PURE__ */ b.createElement(wt, Object.assign({}, pe, {
1328
+ icon: zt(T, Object.assign(Object.assign({}, T.props), {
1329
+ onClick: () => {
1330
+ }
1331
+ }))
1332
+ })) : /* @__PURE__ */ b.createElement(wt, Object.assign({}, pe), /* @__PURE__ */ b.createElement("span", null, T));
1333
+ };
1334
+ b.useImperativeHandle(t, () => ({
1335
+ handlePreview: M,
1336
+ handleDownload: J
1337
+ }));
1338
+ const {
1339
+ getPrefixCls: Z
1340
+ } = b.useContext(St), se = Z("upload", u), R = Z(), _e = V(`${se}-list`, `${se}-list-${n}`), ve = b.useMemo(() => Ts(Es(R), ["onAppearEnd", "onEnterEnd", "onLeaveEnd"]), [R]), de = Object.assign(Object.assign({}, G ? {} : ve), {
1341
+ motionDeadline: 2e3,
1342
+ motionName: `${se}-${G ? "animate-inline" : "animate"}`,
1343
+ keys: te(f.map((T) => ({
1344
+ key: T.uid,
1345
+ file: T
1346
+ }))),
1347
+ motionAppear: L
1348
+ });
1349
+ return /* @__PURE__ */ b.createElement("div", {
1350
+ className: _e
1351
+ }, /* @__PURE__ */ b.createElement(As, Object.assign({}, de, {
1352
+ component: !1
1353
+ }), ({
1354
+ key: T,
1355
+ file: P,
1356
+ className: q,
1357
+ style: ie
1358
+ }) => /* @__PURE__ */ b.createElement(Wi, {
1359
+ key: T,
1360
+ locale: o,
1361
+ prefixCls: se,
1362
+ className: q,
1363
+ style: ie,
1364
+ file: P,
1365
+ items: f,
1366
+ progress: $,
1367
+ listType: n,
1368
+ isImgUrl: l,
1369
+ showPreviewIcon: d,
1370
+ showRemoveIcon: h,
1371
+ showDownloadIcon: g,
1372
+ removeIcon: p,
1373
+ previewIcon: m,
1374
+ downloadIcon: w,
1375
+ extra: v,
1376
+ iconRender: ne,
1377
+ actionIconRender: Ce,
1378
+ itemRender: N,
1379
+ onPreview: M,
1380
+ onDownload: J,
1381
+ onClose: ae
1382
+ })), S && /* @__PURE__ */ b.createElement(In, Object.assign({}, de, {
1383
+ visible: y,
1384
+ forceRender: !0
1385
+ }), ({
1386
+ className: T,
1387
+ style: P
1388
+ }) => zt(S, (q) => ({
1389
+ className: V(q.className, T),
1390
+ style: Object.assign(Object.assign(Object.assign({}, P), {
1391
+ // prevent the element has hover css pseudo-class that may cause animation to end prematurely.
1392
+ pointerEvents: T ? "none" : void 0
1393
+ }), q.style)
1394
+ }))));
1395
+ }, Ji = /* @__PURE__ */ b.forwardRef(Yi);
1396
+ var Zi = function(e, t, n, s) {
1397
+ function i(a) {
1398
+ return a instanceof n ? a : new n(function(r) {
1399
+ r(a);
1400
+ });
1401
+ }
1402
+ return new (n || (n = Promise))(function(a, r) {
1403
+ function o(u) {
1404
+ try {
1405
+ l(s.next(u));
1406
+ } catch (f) {
1407
+ r(f);
1408
+ }
1409
+ }
1410
+ function c(u) {
1411
+ try {
1412
+ l(s.throw(u));
1413
+ } catch (f) {
1414
+ r(f);
1415
+ }
1416
+ }
1417
+ function l(u) {
1418
+ u.done ? a(u.value) : i(u.value).then(o, c);
1419
+ }
1420
+ l((s = s.apply(e, [])).next());
1421
+ });
1422
+ };
1423
+ const Me = `__LIST_IGNORE_${Date.now()}__`, Qi = (e, t) => {
1424
+ const n = Os("upload"), {
1425
+ fileList: s,
1426
+ defaultFileList: i,
1427
+ onRemove: a,
1428
+ showUploadList: r = !0,
1429
+ listType: o = "text",
1430
+ onPreview: c,
1431
+ onDownload: l,
1432
+ onChange: u,
1433
+ onDrop: f,
1434
+ previewFile: d,
1435
+ disabled: h,
1436
+ locale: g,
1437
+ iconRender: p,
1438
+ isImageUrl: m,
1439
+ progress: w,
1440
+ prefixCls: v,
1441
+ className: $,
1442
+ type: S = "select",
1443
+ children: y,
1444
+ style: N,
1445
+ itemRender: I,
1446
+ maxCount: k,
1447
+ data: L = {},
1448
+ multiple: D = !1,
1449
+ hasControlInside: G = !0,
1450
+ action: M = "",
1451
+ accept: J = "",
1452
+ supportServerRender: ae = !0,
1453
+ rootClassName: ne
1454
+ } = e, Ce = b.useContext(Ls), Z = h ?? Ce, se = e.customRequest || n.customRequest, [R, _e] = Cs(i || [], {
1455
+ value: s,
1456
+ postState: (E) => E ?? []
1457
+ }), [ve, de] = b.useState("drop"), T = b.useRef(null), P = b.useRef(null);
1458
+ b.useMemo(() => {
1459
+ const E = Date.now();
1460
+ (s || []).forEach((O, x) => {
1461
+ !O.uid && !Object.isFrozen(O) && (O.uid = `__AUTO__${E}_${x}__`);
1462
+ });
1463
+ }, [s]);
1464
+ const q = (E, O, x) => {
1465
+ let A = te(O), C = !1;
1466
+ k === 1 ? A = A.slice(-1) : k && (C = A.length > k, A = A.slice(0, k)), Vt.flushSync(() => {
1467
+ _e(A);
1468
+ });
1469
+ const H = {
1470
+ file: E,
1471
+ fileList: A
1472
+ };
1473
+ x && (H.event = x), (!C || E.status === "removed" || // We should ignore event if current file is exceed `maxCount`
1474
+ A.some((ge) => ge.uid === E.uid)) && Vt.flushSync(() => {
1475
+ u?.(H);
1476
+ });
1477
+ }, ie = (E, O) => Zi(void 0, void 0, void 0, function* () {
1478
+ const {
1479
+ beforeUpload: x,
1480
+ transformFile: A
1481
+ } = e;
1482
+ let C = E;
1483
+ if (x) {
1484
+ const H = yield x(E, O);
1485
+ if (H === !1)
1486
+ return !1;
1487
+ if (delete E[Me], H === Me)
1488
+ return Object.defineProperty(E, Me, {
1489
+ value: !0,
1490
+ configurable: !0
1491
+ }), !1;
1492
+ typeof H == "object" && H && (C = H);
1493
+ }
1494
+ return A && (C = yield A(C)), C;
1495
+ }), ke = (E) => {
1496
+ const O = E.filter((C) => !C.file[Me]);
1497
+ if (!O.length)
1498
+ return;
1499
+ const x = O.map((C) => Ge(C.file));
1500
+ let A = te(R);
1501
+ x.forEach((C) => {
1502
+ A = We(C, A);
1503
+ }), x.forEach((C, H) => {
1504
+ let ge = C;
1505
+ if (O[H].parsedFile)
1506
+ C.status = "uploading";
1507
+ else {
1508
+ const {
1509
+ originFileObj: Se
1510
+ } = C;
1511
+ let ye;
1512
+ try {
1513
+ ye = new File([Se], Se.name, {
1514
+ type: Se.type
1515
+ });
1516
+ } catch {
1517
+ ye = new Blob([Se], {
1518
+ type: Se.type
1519
+ }), ye.name = Se.name, ye.lastModifiedDate = /* @__PURE__ */ new Date(), ye.lastModified = (/* @__PURE__ */ new Date()).getTime();
1520
+ }
1521
+ ye.uid = C.uid, ge = ye;
1522
+ }
1523
+ q(ge, A);
1524
+ });
1525
+ }, pe = (E, O, x) => {
1526
+ try {
1527
+ typeof E == "string" && (E = JSON.parse(E));
1528
+ } catch {
1529
+ }
1530
+ if (!pt(O, R))
1531
+ return;
1532
+ const A = Ge(O);
1533
+ A.status = "done", A.percent = 100, A.response = E, A.xhr = x;
1534
+ const C = We(A, R);
1535
+ q(A, C);
1536
+ }, me = (E, O) => {
1537
+ if (!pt(O, R))
1538
+ return;
1539
+ const x = Ge(O);
1540
+ x.status = "uploading", x.percent = E.percent;
1541
+ const A = We(x, R);
1542
+ q(x, A, E);
1543
+ }, he = (E, O, x) => {
1544
+ if (!pt(x, R))
1545
+ return;
1546
+ const A = Ge(x);
1547
+ A.error = E, A.response = O, A.status = "error";
1548
+ const C = We(A, R);
1549
+ q(A, C);
1550
+ }, re = (E) => {
1551
+ let O;
1552
+ Promise.resolve(typeof a == "function" ? a(E) : a).then((x) => {
1553
+ var A;
1554
+ if (x === !1)
1555
+ return;
1556
+ const C = qi(E, R);
1557
+ C && (O = Object.assign(Object.assign({}, E), {
1558
+ status: "removed"
1559
+ }), R?.forEach((H) => {
1560
+ const ge = O.uid !== void 0 ? "uid" : "name";
1561
+ H[ge] === O[ge] && !Object.isFrozen(H) && (H.status = "removed");
1562
+ }), (A = T.current) === null || A === void 0 || A.abort(O), q(O, C));
1563
+ });
1564
+ }, U = (E) => {
1565
+ de(E.type), E.type === "drop" && f?.(E);
1566
+ };
1567
+ b.useImperativeHandle(t, () => ({
1568
+ onBatchStart: ke,
1569
+ onSuccess: pe,
1570
+ onProgress: me,
1571
+ onError: he,
1572
+ fileList: R,
1573
+ upload: T.current,
1574
+ nativeElement: P.current
1575
+ }));
1576
+ const {
1577
+ getPrefixCls: xe,
1578
+ direction: He,
1579
+ upload: $e
1580
+ } = b.useContext(St), B = xe("upload", v), De = Object.assign(Object.assign({
1581
+ onBatchStart: ke,
1582
+ onError: he,
1583
+ onProgress: me,
1584
+ onSuccess: pe
1585
+ }, e), {
1586
+ customRequest: se,
1587
+ data: L,
1588
+ multiple: D,
1589
+ action: M,
1590
+ accept: J,
1591
+ supportServerRender: ae,
1592
+ prefixCls: B,
1593
+ disabled: Z,
1594
+ beforeUpload: ie,
1595
+ onChange: void 0,
1596
+ hasControlInside: G
1597
+ });
1598
+ delete De.className, delete De.style, (!y || Z) && delete De.id;
1599
+ const Rt = `${B}-wrapper`, [ot, Ft, as] = _i(B, Rt), [rs] = _s("Upload", xs.Upload), {
1600
+ showRemoveIcon: jt,
1601
+ showPreviewIcon: os,
1602
+ showDownloadIcon: ls,
1603
+ removeIcon: cs,
1604
+ previewIcon: us,
1605
+ downloadIcon: fs,
1606
+ extra: ds
1607
+ } = typeof r == "boolean" ? {} : r, ps = typeof jt > "u" ? !Z : jt, lt = (E, O) => r ? /* @__PURE__ */ b.createElement(Ji, {
1608
+ prefixCls: B,
1609
+ listType: o,
1610
+ items: R,
1611
+ previewFile: d,
1612
+ onPreview: c,
1613
+ onDownload: l,
1614
+ onRemove: re,
1615
+ showRemoveIcon: ps,
1616
+ showPreviewIcon: os,
1617
+ showDownloadIcon: ls,
1618
+ removeIcon: cs,
1619
+ previewIcon: us,
1620
+ downloadIcon: fs,
1621
+ iconRender: p,
1622
+ extra: ds,
1623
+ locale: Object.assign(Object.assign({}, rs), g),
1624
+ isImageUrl: m,
1625
+ progress: w,
1626
+ appendAction: E,
1627
+ appendActionVisible: O,
1628
+ itemRender: I,
1629
+ disabled: Z
1630
+ }) : E, ct = V(Rt, $, ne, Ft, as, $e?.className, {
1631
+ [`${B}-rtl`]: He === "rtl",
1632
+ [`${B}-picture-card-wrapper`]: o === "picture-card",
1633
+ [`${B}-picture-circle-wrapper`]: o === "picture-circle"
1634
+ }), Ut = Object.assign(Object.assign({}, $e?.style), N);
1635
+ if (S === "drag") {
1636
+ const E = V(Ft, B, `${B}-drag`, {
1637
+ [`${B}-drag-uploading`]: R.some((O) => O.status === "uploading"),
1638
+ [`${B}-drag-hover`]: ve === "dragover",
1639
+ [`${B}-disabled`]: Z,
1640
+ [`${B}-rtl`]: He === "rtl"
1641
+ });
1642
+ return ot(/* @__PURE__ */ b.createElement("span", {
1643
+ className: ct,
1644
+ ref: P
1645
+ }, /* @__PURE__ */ b.createElement("div", {
1646
+ className: E,
1647
+ style: Ut,
1648
+ onDrop: U,
1649
+ onDragOver: U,
1650
+ onDragLeave: U
1651
+ }, /* @__PURE__ */ b.createElement(vt, Object.assign({}, De, {
1652
+ ref: T,
1653
+ className: `${B}-btn`
1654
+ }), /* @__PURE__ */ b.createElement("div", {
1655
+ className: `${B}-drag-container`
1656
+ }, y))), lt()));
1657
+ }
1658
+ const ms = V(B, `${B}-select`, {
1659
+ [`${B}-disabled`]: Z,
1660
+ [`${B}-hidden`]: !y
1661
+ }), Bt = /* @__PURE__ */ b.createElement("div", {
1662
+ className: ms,
1663
+ style: Ut
1664
+ }, /* @__PURE__ */ b.createElement(vt, Object.assign({}, De, {
1665
+ ref: T
1666
+ })));
1667
+ return ot(o === "picture-card" || o === "picture-circle" ? /* @__PURE__ */ b.createElement("span", {
1668
+ className: ct,
1669
+ ref: P
1670
+ }, lt(Bt, !!y)) : /* @__PURE__ */ b.createElement("span", {
1671
+ className: ct,
1672
+ ref: P
1673
+ }, Bt, lt()));
1674
+ }, Ln = /* @__PURE__ */ b.forwardRef(Qi);
1675
+ var ea = function(e, t) {
1676
+ var n = {};
1677
+ for (var s in e) Object.prototype.hasOwnProperty.call(e, s) && t.indexOf(s) < 0 && (n[s] = e[s]);
1678
+ if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var i = 0, s = Object.getOwnPropertySymbols(e); i < s.length; i++)
1679
+ t.indexOf(s[i]) < 0 && Object.prototype.propertyIsEnumerable.call(e, s[i]) && (n[s[i]] = e[s[i]]);
1680
+ return n;
1681
+ };
1682
+ const ta = /* @__PURE__ */ b.forwardRef((e, t) => {
1683
+ const {
1684
+ style: n,
1685
+ height: s,
1686
+ hasControlInside: i = !1,
1687
+ children: a
1688
+ } = e, r = ea(e, ["style", "height", "hasControlInside", "children"]), o = Object.assign(Object.assign({}, n), {
1689
+ height: s
1690
+ });
1691
+ return /* @__PURE__ */ b.createElement(Ln, Object.assign({
1692
+ ref: t,
1693
+ hasControlInside: i
1694
+ }, r, {
1695
+ style: o,
1696
+ type: "drag"
1697
+ }), a);
1698
+ }), Cn = Ln;
1699
+ Cn.Dragger = ta;
1700
+ Cn.LIST_IGNORE = Me;
1701
+ var Ye = {}, sn;
1702
+ function na() {
1703
+ if (sn) return Ye;
1704
+ sn = 1, Object.defineProperty(Ye, "__esModule", { value: !0 });
1705
+ var e = { icon: { tag: "svg", attrs: { "fill-rule": "evenodd", viewBox: "64 64 896 896", focusable: "false" }, children: [{ tag: "path", attrs: { d: "M799.86 166.31c.02 0 .04.02.08.06l57.69 57.7c.04.03.05.05.06.08a.12.12 0 010 .06c0 .03-.02.05-.06.09L569.93 512l287.7 287.7c.04.04.05.06.06.09a.12.12 0 010 .07c0 .02-.02.04-.06.08l-57.7 57.69c-.03.04-.05.05-.07.06a.12.12 0 01-.07 0c-.03 0-.05-.02-.09-.06L512 569.93l-287.7 287.7c-.04.04-.06.05-.09.06a.12.12 0 01-.07 0c-.02 0-.04-.02-.08-.06l-57.69-57.7c-.04-.03-.05-.05-.06-.07a.12.12 0 010-.07c0-.03.02-.05.06-.09L454.07 512l-287.7-287.7c-.04-.04-.05-.06-.06-.09a.12.12 0 010-.07c0-.02.02-.04.06-.08l57.7-57.69c.03-.04.05-.05.07-.06a.12.12 0 01.07 0c.03 0 .05.02.09.06L512 454.07l287.7-287.7c.04-.04.06-.05.09-.06a.12.12 0 01.07 0z" } }] }, name: "close", theme: "outlined" };
1706
+ return Ye.default = e, Ye;
1707
+ }
1708
+ var sa = /* @__PURE__ */ na();
1709
+ const ia = /* @__PURE__ */ Ds(sa);
1710
+ function kt() {
1711
+ return kt = Object.assign ? Object.assign.bind() : function(e) {
1712
+ for (var t = 1; t < arguments.length; t++) {
1713
+ var n = arguments[t];
1714
+ for (var s in n)
1715
+ Object.prototype.hasOwnProperty.call(n, s) && (e[s] = n[s]);
1716
+ }
1717
+ return e;
1718
+ }, kt.apply(this, arguments);
1719
+ }
1720
+ const aa = (e, t) => /* @__PURE__ */ b.createElement(Ps, kt({}, e, {
1721
+ ref: t,
1722
+ icon: ia
1723
+ })), cr = /* @__PURE__ */ b.forwardRef(aa), Oe = {
1724
+ collection: "map",
1725
+ default: !0,
1726
+ nodeClass: Ee,
1727
+ tag: "tag:yaml.org,2002:map",
1728
+ resolve(e, t) {
1729
+ return Ms(e) || t("Expected a mapping for this tag"), e;
1730
+ },
1731
+ createNode: (e, t, n) => Ee.from(e, t, n)
1732
+ }, Le = {
1733
+ collection: "seq",
1734
+ default: !0,
1735
+ nodeClass: Fe,
1736
+ tag: "tag:yaml.org,2002:seq",
1737
+ resolve(e, t) {
1738
+ return Rs(e) || t("Expected a sequence for this tag"), e;
1739
+ },
1740
+ createNode: (e, t, n) => Fe.from(e, t, n)
1741
+ }, nt = {
1742
+ identify: (e) => typeof e == "string",
1743
+ default: !0,
1744
+ tag: "tag:yaml.org,2002:str",
1745
+ resolve: (e) => e,
1746
+ stringify(e, t, n, s) {
1747
+ return t = Object.assign({ actualString: !0 }, t), Tn(e, t, n, s);
1748
+ }
1749
+ }, st = {
1750
+ identify: (e) => e == null,
1751
+ createNode: () => new j(null),
1752
+ default: !0,
1753
+ tag: "tag:yaml.org,2002:null",
1754
+ test: /^(?:~|[Nn]ull|NULL)?$/,
1755
+ resolve: () => new j(null),
1756
+ stringify: ({ source: e }, t) => typeof e == "string" && st.test.test(e) ? e : t.options.nullStr
1757
+ }, Ot = {
1758
+ identify: (e) => typeof e == "boolean",
1759
+ default: !0,
1760
+ tag: "tag:yaml.org,2002:bool",
1761
+ test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,
1762
+ resolve: (e) => new j(e[0] === "t" || e[0] === "T"),
1763
+ stringify({ source: e, value: t }, n) {
1764
+ if (e && Ot.test.test(e)) {
1765
+ const s = e[0] === "t" || e[0] === "T";
1766
+ if (t === s)
1767
+ return e;
1768
+ }
1769
+ return t ? n.options.trueStr : n.options.falseStr;
1770
+ }
1771
+ };
1772
+ function Q({ format: e, minFractionDigits: t, tag: n, value: s }) {
1773
+ if (typeof s == "bigint")
1774
+ return String(s);
1775
+ const i = typeof s == "number" ? s : Number(s);
1776
+ if (!isFinite(i))
1777
+ return isNaN(i) ? ".nan" : i < 0 ? "-.inf" : ".inf";
1778
+ let a = Object.is(s, -0) ? "-0" : JSON.stringify(s);
1779
+ if (!e && t && (!n || n === "tag:yaml.org,2002:float") && /^-?\d/.test(a) && !a.includes("e")) {
1780
+ let r = a.indexOf(".");
1781
+ r < 0 && (r = a.length, a += ".");
1782
+ let o = t - (a.length - r - 1);
1783
+ for (; o-- > 0; )
1784
+ a += "0";
1785
+ }
1786
+ return a;
1787
+ }
1788
+ const _n = {
1789
+ identify: (e) => typeof e == "number",
1790
+ default: !0,
1791
+ tag: "tag:yaml.org,2002:float",
1792
+ test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,
1793
+ resolve: (e) => e.slice(-3).toLowerCase() === "nan" ? NaN : e[0] === "-" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
1794
+ stringify: Q
1795
+ }, xn = {
1796
+ identify: (e) => typeof e == "number",
1797
+ default: !0,
1798
+ tag: "tag:yaml.org,2002:float",
1799
+ format: "EXP",
1800
+ test: /^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,
1801
+ resolve: (e) => parseFloat(e),
1802
+ stringify(e) {
1803
+ const t = Number(e.value);
1804
+ return isFinite(t) ? t.toExponential() : Q(e);
1805
+ }
1806
+ }, Dn = {
1807
+ identify: (e) => typeof e == "number",
1808
+ default: !0,
1809
+ tag: "tag:yaml.org,2002:float",
1810
+ test: /^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,
1811
+ resolve(e) {
1812
+ const t = new j(parseFloat(e)), n = e.indexOf(".");
1813
+ return n !== -1 && e[e.length - 1] === "0" && (t.minFractionDigits = e.length - n - 1), t;
1814
+ },
1815
+ stringify: Q
1816
+ }, it = (e) => typeof e == "bigint" || Number.isInteger(e), Lt = (e, t, n, { intAsBigInt: s }) => s ? BigInt(e) : parseInt(e.substring(t), n);
1817
+ function Pn(e, t, n) {
1818
+ const { value: s } = e;
1819
+ return it(s) && s >= 0 ? n + s.toString(t) : Q(e);
1820
+ }
1821
+ const Mn = {
1822
+ identify: (e) => it(e) && e >= 0,
1823
+ default: !0,
1824
+ tag: "tag:yaml.org,2002:int",
1825
+ format: "OCT",
1826
+ test: /^0o[0-7]+$/,
1827
+ resolve: (e, t, n) => Lt(e, 2, 8, n),
1828
+ stringify: (e) => Pn(e, 8, "0o")
1829
+ }, Rn = {
1830
+ identify: it,
1831
+ default: !0,
1832
+ tag: "tag:yaml.org,2002:int",
1833
+ test: /^[-+]?[0-9]+$/,
1834
+ resolve: (e, t, n) => Lt(e, 0, 10, n),
1835
+ stringify: Q
1836
+ }, Fn = {
1837
+ identify: (e) => it(e) && e >= 0,
1838
+ default: !0,
1839
+ tag: "tag:yaml.org,2002:int",
1840
+ format: "HEX",
1841
+ test: /^0x[0-9a-fA-F]+$/,
1842
+ resolve: (e, t, n) => Lt(e, 2, 16, n),
1843
+ stringify: (e) => Pn(e, 16, "0x")
1844
+ }, ra = [
1845
+ Oe,
1846
+ Le,
1847
+ nt,
1848
+ st,
1849
+ Ot,
1850
+ Mn,
1851
+ Rn,
1852
+ Fn,
1853
+ _n,
1854
+ xn,
1855
+ Dn
1856
+ ];
1857
+ function an(e) {
1858
+ return typeof e == "bigint" || Number.isInteger(e);
1859
+ }
1860
+ const Je = ({ value: e }) => JSON.stringify(e), oa = [
1861
+ {
1862
+ identify: (e) => typeof e == "string",
1863
+ default: !0,
1864
+ tag: "tag:yaml.org,2002:str",
1865
+ resolve: (e) => e,
1866
+ stringify: Je
1867
+ },
1868
+ {
1869
+ identify: (e) => e == null,
1870
+ createNode: () => new j(null),
1871
+ default: !0,
1872
+ tag: "tag:yaml.org,2002:null",
1873
+ test: /^null$/,
1874
+ resolve: () => null,
1875
+ stringify: Je
1876
+ },
1877
+ {
1878
+ identify: (e) => typeof e == "boolean",
1879
+ default: !0,
1880
+ tag: "tag:yaml.org,2002:bool",
1881
+ test: /^true$|^false$/,
1882
+ resolve: (e) => e === "true",
1883
+ stringify: Je
1884
+ },
1885
+ {
1886
+ identify: an,
1887
+ default: !0,
1888
+ tag: "tag:yaml.org,2002:int",
1889
+ test: /^-?(?:0|[1-9][0-9]*)$/,
1890
+ resolve: (e, t, { intAsBigInt: n }) => n ? BigInt(e) : parseInt(e, 10),
1891
+ stringify: ({ value: e }) => an(e) ? e.toString() : JSON.stringify(e)
1892
+ },
1893
+ {
1894
+ identify: (e) => typeof e == "number",
1895
+ default: !0,
1896
+ tag: "tag:yaml.org,2002:float",
1897
+ test: /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,
1898
+ resolve: (e) => parseFloat(e),
1899
+ stringify: Je
1900
+ }
1901
+ ], la = {
1902
+ default: !0,
1903
+ tag: "",
1904
+ test: /^/,
1905
+ resolve(e, t) {
1906
+ return t(`Unresolved plain scalar ${JSON.stringify(e)}`), e;
1907
+ }
1908
+ }, ca = [Oe, Le].concat(oa, la), Ct = {
1909
+ identify: (e) => e instanceof Uint8Array,
1910
+ // Buffer inherits from Uint8Array
1911
+ default: !1,
1912
+ tag: "tag:yaml.org,2002:binary",
1913
+ /**
1914
+ * Returns a Buffer in node and an Uint8Array in browsers
1915
+ *
1916
+ * To use the resulting buffer as an image, you'll want to do something like:
1917
+ *
1918
+ * const blob = new Blob([buffer], { type: 'image/jpeg' })
1919
+ * document.querySelector('#photo').src = URL.createObjectURL(blob)
1920
+ */
1921
+ resolve(e, t) {
1922
+ if (typeof atob == "function") {
1923
+ const n = atob(e.replace(/[\n\r]/g, "")), s = new Uint8Array(n.length);
1924
+ for (let i = 0; i < n.length; ++i)
1925
+ s[i] = n.charCodeAt(i);
1926
+ return s;
1927
+ } else
1928
+ return t("This environment does not support reading binary tags; either Buffer or atob is required"), e;
1929
+ },
1930
+ stringify({ comment: e, type: t, value: n }, s, i, a) {
1931
+ if (!n)
1932
+ return "";
1933
+ const r = n;
1934
+ let o;
1935
+ if (typeof btoa == "function") {
1936
+ let c = "";
1937
+ for (let l = 0; l < r.length; ++l)
1938
+ c += String.fromCharCode(r[l]);
1939
+ o = btoa(c);
1940
+ } else
1941
+ throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");
1942
+ if (t ?? (t = j.BLOCK_LITERAL), t !== j.QUOTE_DOUBLE) {
1943
+ const c = Math.max(s.options.lineWidth - s.indent.length, s.options.minContentWidth), l = Math.ceil(o.length / c), u = new Array(l);
1944
+ for (let f = 0, d = 0; f < l; ++f, d += c)
1945
+ u[f] = o.substr(d, c);
1946
+ o = u.join(t === j.BLOCK_LITERAL ? `
1947
+ ` : " ");
1948
+ }
1949
+ return Tn({ comment: e, type: t, value: o }, s, i, a);
1950
+ }
1951
+ };
1952
+ function jn({ value: e, source: t }, n) {
1953
+ return t && (e ? Un : Bn).test.test(t) ? t : e ? n.options.trueStr : n.options.falseStr;
1954
+ }
1955
+ const Un = {
1956
+ identify: (e) => e === !0,
1957
+ default: !0,
1958
+ tag: "tag:yaml.org,2002:bool",
1959
+ test: /^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,
1960
+ resolve: () => new j(!0),
1961
+ stringify: jn
1962
+ }, Bn = {
1963
+ identify: (e) => e === !1,
1964
+ default: !0,
1965
+ tag: "tag:yaml.org,2002:bool",
1966
+ test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,
1967
+ resolve: () => new j(!1),
1968
+ stringify: jn
1969
+ }, ua = {
1970
+ identify: (e) => typeof e == "number",
1971
+ default: !0,
1972
+ tag: "tag:yaml.org,2002:float",
1973
+ test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,
1974
+ resolve: (e) => e.slice(-3).toLowerCase() === "nan" ? NaN : e[0] === "-" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
1975
+ stringify: Q
1976
+ }, fa = {
1977
+ identify: (e) => typeof e == "number",
1978
+ default: !0,
1979
+ tag: "tag:yaml.org,2002:float",
1980
+ format: "EXP",
1981
+ test: /^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,
1982
+ resolve: (e) => parseFloat(e.replace(/_/g, "")),
1983
+ stringify(e) {
1984
+ const t = Number(e.value);
1985
+ return isFinite(t) ? t.toExponential() : Q(e);
1986
+ }
1987
+ }, da = {
1988
+ identify: (e) => typeof e == "number",
1989
+ default: !0,
1990
+ tag: "tag:yaml.org,2002:float",
1991
+ test: /^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,
1992
+ resolve(e) {
1993
+ const t = new j(parseFloat(e.replace(/_/g, ""))), n = e.indexOf(".");
1994
+ if (n !== -1) {
1995
+ const s = e.substring(n + 1).replace(/_/g, "");
1996
+ s[s.length - 1] === "0" && (t.minFractionDigits = s.length);
1997
+ }
1998
+ return t;
1999
+ },
2000
+ stringify: Q
2001
+ }, qe = (e) => typeof e == "bigint" || Number.isInteger(e);
2002
+ function at(e, t, n, { intAsBigInt: s }) {
2003
+ const i = e[0];
2004
+ if ((i === "-" || i === "+") && (t += 1), e = e.substring(t).replace(/_/g, ""), s) {
2005
+ switch (n) {
2006
+ case 2:
2007
+ e = `0b${e}`;
2008
+ break;
2009
+ case 8:
2010
+ e = `0o${e}`;
2011
+ break;
2012
+ case 16:
2013
+ e = `0x${e}`;
2014
+ break;
2015
+ }
2016
+ const r = BigInt(e);
2017
+ return i === "-" ? BigInt(-1) * r : r;
2018
+ }
2019
+ const a = parseInt(e, n);
2020
+ return i === "-" ? -1 * a : a;
2021
+ }
2022
+ function _t(e, t, n) {
2023
+ const { value: s } = e;
2024
+ if (qe(s)) {
2025
+ const i = s.toString(t);
2026
+ return s < 0 ? "-" + n + i.substr(1) : n + i;
2027
+ }
2028
+ return Q(e);
2029
+ }
2030
+ const pa = {
2031
+ identify: qe,
2032
+ default: !0,
2033
+ tag: "tag:yaml.org,2002:int",
2034
+ format: "BIN",
2035
+ test: /^[-+]?0b[0-1_]+$/,
2036
+ resolve: (e, t, n) => at(e, 2, 2, n),
2037
+ stringify: (e) => _t(e, 2, "0b")
2038
+ }, ma = {
2039
+ identify: qe,
2040
+ default: !0,
2041
+ tag: "tag:yaml.org,2002:int",
2042
+ format: "OCT",
2043
+ test: /^[-+]?0[0-7_]+$/,
2044
+ resolve: (e, t, n) => at(e, 1, 8, n),
2045
+ stringify: (e) => _t(e, 8, "0")
2046
+ }, ha = {
2047
+ identify: qe,
2048
+ default: !0,
2049
+ tag: "tag:yaml.org,2002:int",
2050
+ test: /^[-+]?[0-9][0-9_]*$/,
2051
+ resolve: (e, t, n) => at(e, 0, 10, n),
2052
+ stringify: Q
2053
+ }, ga = {
2054
+ identify: qe,
2055
+ default: !0,
2056
+ tag: "tag:yaml.org,2002:int",
2057
+ format: "HEX",
2058
+ test: /^[-+]?0x[0-9a-fA-F_]+$/,
2059
+ resolve: (e, t, n) => at(e, 2, 16, n),
2060
+ stringify: (e) => _t(e, 16, "0x")
2061
+ };
2062
+ function xt(e, t) {
2063
+ const n = e[0], s = n === "-" || n === "+" ? e.substring(1) : e, i = (r) => t ? BigInt(r) : Number(r), a = s.replace(/_/g, "").split(":").reduce((r, o) => r * i(60) + i(o), i(0));
2064
+ return n === "-" ? i(-1) * a : a;
2065
+ }
2066
+ function qn(e) {
2067
+ let { value: t } = e, n = (r) => r;
2068
+ if (typeof t == "bigint")
2069
+ n = (r) => BigInt(r);
2070
+ else if (isNaN(t) || !isFinite(t))
2071
+ return Q(e);
2072
+ let s = "";
2073
+ t < 0 && (s = "-", t *= n(-1));
2074
+ const i = n(60), a = [t % i];
2075
+ return t < 60 ? a.unshift(0) : (t = (t - a[0]) / i, a.unshift(t % i), t >= 60 && (t = (t - a[0]) / i, a.unshift(t))), s + a.map((r) => String(r).padStart(2, "0")).join(":").replace(/000000\d*$/, "");
2076
+ }
2077
+ const Kn = {
2078
+ identify: (e) => typeof e == "bigint" || Number.isInteger(e),
2079
+ default: !0,
2080
+ tag: "tag:yaml.org,2002:int",
2081
+ format: "TIME",
2082
+ test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,
2083
+ resolve: (e, t, { intAsBigInt: n }) => xt(e, n),
2084
+ stringify: qn
2085
+ }, zn = {
2086
+ identify: (e) => typeof e == "number",
2087
+ default: !0,
2088
+ tag: "tag:yaml.org,2002:float",
2089
+ format: "TIME",
2090
+ test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,
2091
+ resolve: (e) => xt(e, !1),
2092
+ stringify: qn
2093
+ }, rt = {
2094
+ identify: (e) => e instanceof Date,
2095
+ default: !0,
2096
+ tag: "tag:yaml.org,2002:timestamp",
2097
+ // If the time zone is omitted, the timestamp is assumed to be specified in UTC. The time part
2098
+ // may be omitted altogether, resulting in a date format. In such a case, the time part is
2099
+ // assumed to be 00:00:00Z (start of day, UTC).
2100
+ test: RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),
2101
+ resolve(e) {
2102
+ const t = e.match(rt.test);
2103
+ if (!t)
2104
+ throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");
2105
+ const [, n, s, i, a, r, o] = t.map(Number), c = t[7] ? Number((t[7] + "00").substr(1, 3)) : 0;
2106
+ let l = Date.UTC(n, s - 1, i, a || 0, r || 0, o || 0, c);
2107
+ const u = t[8];
2108
+ if (u && u !== "Z") {
2109
+ let f = xt(u, !1);
2110
+ Math.abs(f) < 30 && (f *= 60), l -= 6e4 * f;
2111
+ }
2112
+ return new Date(l);
2113
+ },
2114
+ stringify: ({ value: e }) => e?.toISOString().replace(/(T00:00:00)?\.000Z$/, "") ?? ""
2115
+ }, rn = [
2116
+ Oe,
2117
+ Le,
2118
+ nt,
2119
+ st,
2120
+ Un,
2121
+ Bn,
2122
+ pa,
2123
+ ma,
2124
+ ha,
2125
+ ga,
2126
+ ua,
2127
+ fa,
2128
+ da,
2129
+ Ct,
2130
+ Te,
2131
+ Nt,
2132
+ It,
2133
+ Tt,
2134
+ Kn,
2135
+ zn,
2136
+ rt
2137
+ ], on = /* @__PURE__ */ new Map([
2138
+ ["core", ra],
2139
+ ["failsafe", [Oe, Le, nt]],
2140
+ ["json", ca],
2141
+ ["yaml11", rn],
2142
+ ["yaml-1.1", rn]
2143
+ ]), ln = {
2144
+ binary: Ct,
2145
+ bool: Ot,
2146
+ float: Dn,
2147
+ floatExp: xn,
2148
+ floatNaN: _n,
2149
+ floatTime: zn,
2150
+ int: Rn,
2151
+ intHex: Fn,
2152
+ intOct: Mn,
2153
+ intTime: Kn,
2154
+ map: Oe,
2155
+ merge: Te,
2156
+ null: st,
2157
+ omap: Nt,
2158
+ pairs: It,
2159
+ seq: Le,
2160
+ set: Tt,
2161
+ timestamp: rt
2162
+ }, ya = {
2163
+ "tag:yaml.org,2002:binary": Ct,
2164
+ "tag:yaml.org,2002:merge": Te,
2165
+ "tag:yaml.org,2002:omap": Nt,
2166
+ "tag:yaml.org,2002:pairs": It,
2167
+ "tag:yaml.org,2002:set": Tt,
2168
+ "tag:yaml.org,2002:timestamp": rt
2169
+ };
2170
+ function mt(e, t, n) {
2171
+ const s = on.get(t);
2172
+ if (s && !e)
2173
+ return n && !s.includes(Te) ? s.concat(Te) : s.slice();
2174
+ let i = s;
2175
+ if (!i)
2176
+ if (Array.isArray(e))
2177
+ i = [];
2178
+ else {
2179
+ const a = Array.from(on.keys()).filter((r) => r !== "yaml11").map((r) => JSON.stringify(r)).join(", ");
2180
+ throw new Error(`Unknown schema "${t}"; use one of ${a} or define customTags array`);
2181
+ }
2182
+ if (Array.isArray(e))
2183
+ for (const a of e)
2184
+ i = i.concat(a);
2185
+ else typeof e == "function" && (i = e(i.slice()));
2186
+ return n && (i = i.concat(Te)), i.reduce((a, r) => {
2187
+ const o = typeof r == "string" ? ln[r] : r;
2188
+ if (!o) {
2189
+ const c = JSON.stringify(r), l = Object.keys(ln).map((u) => JSON.stringify(u)).join(", ");
2190
+ throw new Error(`Unknown custom tag ${c}; use one of ${l}`);
2191
+ }
2192
+ return a.includes(o) || a.push(o), a;
2193
+ }, []);
2194
+ }
2195
+ const ba = (e, t) => e.key < t.key ? -1 : e.key > t.key ? 1 : 0;
2196
+ class Dt {
2197
+ constructor({ compat: t, customTags: n, merge: s, resolveKnownTags: i, schema: a, sortMapEntries: r, toStringDefaults: o }) {
2198
+ this.compat = Array.isArray(t) ? mt(t, "compat") : t ? mt(null, t) : null, this.name = typeof a == "string" && a || "core", this.knownTags = i ? ya : {}, this.tags = mt(n, this.name, s), this.toStringOptions = o ?? null, Object.defineProperty(this, Fs, { value: Oe }), Object.defineProperty(this, we, { value: nt }), Object.defineProperty(this, js, { value: Le }), this.sortMapEntries = typeof r == "function" ? r : r === !0 ? ba : null;
2199
+ }
2200
+ clone() {
2201
+ const t = Object.create(Dt.prototype, Object.getOwnPropertyDescriptors(this));
2202
+ return t.tags = this.tags.slice(), t;
2203
+ }
2204
+ }
2205
+ function wa(e, t) {
2206
+ const n = [];
2207
+ let s = t.directives === !0;
2208
+ if (t.directives !== !1 && e.directives) {
2209
+ const c = e.directives.toString(e);
2210
+ c ? (n.push(c), s = !0) : e.directives.docStart && (s = !0);
2211
+ }
2212
+ s && n.push("---");
2213
+ const i = Us(e, t), { commentString: a } = i.options;
2214
+ if (e.commentBefore) {
2215
+ n.length !== 1 && n.unshift("");
2216
+ const c = a(e.commentBefore);
2217
+ n.unshift(Ve(c, ""));
2218
+ }
2219
+ let r = !1, o = null;
2220
+ if (e.contents) {
2221
+ if (Et(e.contents)) {
2222
+ if (e.contents.spaceBefore && s && n.push(""), e.contents.commentBefore) {
2223
+ const u = a(e.contents.commentBefore);
2224
+ n.push(Ve(u, ""));
2225
+ }
2226
+ i.forceBlockIndent = !!e.comment, o = e.contents.comment;
2227
+ }
2228
+ const c = o ? void 0 : () => r = !0;
2229
+ let l = Xt(e.contents, i, () => o = null, c);
2230
+ o && (l += Bs(l, "", a(o))), (l[0] === "|" || l[0] === ">") && n[n.length - 1] === "---" ? n[n.length - 1] = `--- ${l}` : n.push(l);
2231
+ } else
2232
+ n.push(Xt(e.contents, i));
2233
+ if (e.directives?.docEnd)
2234
+ if (e.comment) {
2235
+ const c = a(e.comment);
2236
+ c.includes(`
2237
+ `) ? (n.push("..."), n.push(Ve(c, ""))) : n.push(`... ${c}`);
2238
+ } else
2239
+ n.push("...");
2240
+ else {
2241
+ let c = e.comment;
2242
+ c && r && (c = c.replace(/^\n+/, "")), c && ((!r || o) && n[n.length - 1] !== "" && n.push(""), n.push(Ve(a(c), "")));
2243
+ }
2244
+ return n.join(`
2245
+ `) + `
2246
+ `;
2247
+ }
2248
+ class Ke {
2249
+ constructor(t, n, s) {
2250
+ this.commentBefore = null, this.comment = null, this.errors = [], this.warnings = [], Object.defineProperty(this, Gt, { value: Wt });
2251
+ let i = null;
2252
+ typeof n == "function" || Array.isArray(n) ? i = n : s === void 0 && n && (s = n, n = void 0);
2253
+ const a = Object.assign({
2254
+ intAsBigInt: !1,
2255
+ keepSourceTokens: !1,
2256
+ logLevel: "warn",
2257
+ prettyErrors: !0,
2258
+ strict: !0,
2259
+ stringKeys: !1,
2260
+ uniqueKeys: !0,
2261
+ version: "1.2"
2262
+ }, s);
2263
+ this.options = a;
2264
+ let { version: r } = a;
2265
+ s?._directives ? (this.directives = s._directives.atDocument(), this.directives.yaml.explicit && (r = this.directives.yaml.version)) : this.directives = new Qe({ version: r }), this.setSchema(r, s), this.contents = t === void 0 ? null : this.createNode(t, i, s);
2266
+ }
2267
+ /**
2268
+ * Create a deep copy of this Document and its contents.
2269
+ *
2270
+ * Custom Node values that inherit from `Object` still refer to their original instances.
2271
+ */
2272
+ clone() {
2273
+ const t = Object.create(Ke.prototype, {
2274
+ [Gt]: { value: Wt }
2275
+ });
2276
+ return t.commentBefore = this.commentBefore, t.comment = this.comment, t.errors = this.errors.slice(), t.warnings = this.warnings.slice(), t.options = Object.assign({}, this.options), this.directives && (t.directives = this.directives.clone()), t.schema = this.schema.clone(), t.contents = Et(this.contents) ? this.contents.clone(t.schema) : this.contents, this.range && (t.range = this.range.slice()), t;
2277
+ }
2278
+ /** Adds a value to the document. */
2279
+ add(t) {
2280
+ Ne(this.contents) && this.contents.add(t);
2281
+ }
2282
+ /** Adds a value to the document. */
2283
+ addIn(t, n) {
2284
+ Ne(this.contents) && this.contents.addIn(t, n);
2285
+ }
2286
+ /**
2287
+ * Create a new `Alias` node, ensuring that the target `node` has the required anchor.
2288
+ *
2289
+ * If `node` already has an anchor, `name` is ignored.
2290
+ * Otherwise, the `node.anchor` value will be set to `name`,
2291
+ * or if an anchor with that name is already present in the document,
2292
+ * `name` will be used as a prefix for a new unique anchor.
2293
+ * If `name` is undefined, the generated anchor will use 'a' as a prefix.
2294
+ */
2295
+ createAlias(t, n) {
2296
+ if (!t.anchor) {
2297
+ const s = qs(this);
2298
+ t.anchor = // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
2299
+ !n || s.has(n) ? Ks(n || "a", s) : n;
2300
+ }
2301
+ return new En(t.anchor);
2302
+ }
2303
+ createNode(t, n, s) {
2304
+ let i;
2305
+ if (typeof n == "function")
2306
+ t = n.call({ "": t }, "", t), i = n;
2307
+ else if (Array.isArray(n)) {
2308
+ const m = (v) => typeof v == "number" || v instanceof String || v instanceof Number, w = n.filter(m).map(String);
2309
+ w.length > 0 && (n = n.concat(w)), i = n;
2310
+ } else s === void 0 && n && (s = n, n = void 0);
2311
+ const { aliasDuplicateObjects: a, anchorPrefix: r, flow: o, keepUndefined: c, onTagObj: l, tag: u } = s ?? {}, { onAnchor: f, setAnchors: d, sourceObjects: h } = Xs(
2312
+ this,
2313
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
2314
+ r || "a"
2315
+ ), g = {
2316
+ aliasDuplicateObjects: a ?? !0,
2317
+ keepUndefined: c ?? !1,
2318
+ onAnchor: f,
2319
+ onTagObj: l,
2320
+ replacer: i,
2321
+ schema: this.schema,
2322
+ sourceObjects: h
2323
+ }, p = zs(t, u, g);
2324
+ return o && be(p) && (p.flow = !0), d(), p;
2325
+ }
2326
+ /**
2327
+ * Convert a key and a value into a `Pair` using the current schema,
2328
+ * recursively wrapping all values as `Scalar` or `Collection` nodes.
2329
+ */
2330
+ createPair(t, n, s = {}) {
2331
+ const i = this.createNode(t, null, s), a = this.createNode(n, null, s);
2332
+ return new et(i, a);
2333
+ }
2334
+ /**
2335
+ * Removes a value from the document.
2336
+ * @returns `true` if the item was found and removed.
2337
+ */
2338
+ delete(t) {
2339
+ return Ne(this.contents) ? this.contents.delete(t) : !1;
2340
+ }
2341
+ /**
2342
+ * Removes a value from the document.
2343
+ * @returns `true` if the item was found and removed.
2344
+ */
2345
+ deleteIn(t) {
2346
+ return Xe(t) ? this.contents == null ? !1 : (this.contents = null, !0) : Ne(this.contents) ? this.contents.deleteIn(t) : !1;
2347
+ }
2348
+ /**
2349
+ * Returns item at `key`, or `undefined` if not found. By default unwraps
2350
+ * scalar values from their surrounding node; to disable set `keepScalar` to
2351
+ * `true` (collections are always returned intact).
2352
+ */
2353
+ get(t, n) {
2354
+ return be(this.contents) ? this.contents.get(t, n) : void 0;
2355
+ }
2356
+ /**
2357
+ * Returns item at `path`, or `undefined` if not found. By default unwraps
2358
+ * scalar values from their surrounding node; to disable set `keepScalar` to
2359
+ * `true` (collections are always returned intact).
2360
+ */
2361
+ getIn(t, n) {
2362
+ return Xe(t) ? !n && je(this.contents) ? this.contents.value : this.contents : be(this.contents) ? this.contents.getIn(t, n) : void 0;
2363
+ }
2364
+ /**
2365
+ * Checks if the document includes a value with the key `key`.
2366
+ */
2367
+ has(t) {
2368
+ return be(this.contents) ? this.contents.has(t) : !1;
2369
+ }
2370
+ /**
2371
+ * Checks if the document includes a value at `path`.
2372
+ */
2373
+ hasIn(t) {
2374
+ return Xe(t) ? this.contents !== void 0 : be(this.contents) ? this.contents.hasIn(t) : !1;
2375
+ }
2376
+ /**
2377
+ * Sets a value in this document. For `!!set`, `value` needs to be a
2378
+ * boolean to add/remove the item from the set.
2379
+ */
2380
+ set(t, n) {
2381
+ this.contents == null ? this.contents = Yt(this.schema, [t], n) : Ne(this.contents) && this.contents.set(t, n);
2382
+ }
2383
+ /**
2384
+ * Sets a value in this document. For `!!set`, `value` needs to be a
2385
+ * boolean to add/remove the item from the set.
2386
+ */
2387
+ setIn(t, n) {
2388
+ Xe(t) ? this.contents = n : this.contents == null ? this.contents = Yt(this.schema, Array.from(t), n) : Ne(this.contents) && this.contents.setIn(t, n);
2389
+ }
2390
+ /**
2391
+ * Change the YAML version and schema used by the document.
2392
+ * A `null` version disables support for directives, explicit tags, anchors, and aliases.
2393
+ * It also requires the `schema` option to be given as a `Schema` instance value.
2394
+ *
2395
+ * Overrides all previously set schema options.
2396
+ */
2397
+ setSchema(t, n = {}) {
2398
+ typeof t == "number" && (t = String(t));
2399
+ let s;
2400
+ switch (t) {
2401
+ case "1.1":
2402
+ this.directives ? this.directives.yaml.version = "1.1" : this.directives = new Qe({ version: "1.1" }), s = { resolveKnownTags: !1, schema: "yaml-1.1" };
2403
+ break;
2404
+ case "1.2":
2405
+ case "next":
2406
+ this.directives ? this.directives.yaml.version = t : this.directives = new Qe({ version: t }), s = { resolveKnownTags: !0, schema: "core" };
2407
+ break;
2408
+ case null:
2409
+ this.directives && delete this.directives, s = null;
2410
+ break;
2411
+ default: {
2412
+ const i = JSON.stringify(t);
2413
+ throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${i}`);
2414
+ }
2415
+ }
2416
+ if (n.schema instanceof Object)
2417
+ this.schema = n.schema;
2418
+ else if (s)
2419
+ this.schema = new Dt(Object.assign(s, n));
2420
+ else
2421
+ throw new Error("With a null YAML version, the { schema: Schema } option is required");
2422
+ }
2423
+ // json & jsonArg are only used from toJSON()
2424
+ toJS({ json: t, jsonArg: n, mapAsMap: s, maxAliasCount: i, onAnchor: a, reviver: r } = {}) {
2425
+ const o = {
2426
+ anchors: /* @__PURE__ */ new Map(),
2427
+ doc: this,
2428
+ keep: !t,
2429
+ mapAsMap: s === !0,
2430
+ mapKeyWarned: !1,
2431
+ maxAliasCount: typeof i == "number" ? i : 100
2432
+ }, c = Hs(this.contents, n ?? "", o);
2433
+ if (typeof a == "function")
2434
+ for (const { count: l, res: u } of o.anchors.values())
2435
+ a(u, l);
2436
+ return typeof r == "function" ? Vs(r, { "": c }, "", c) : c;
2437
+ }
2438
+ /**
2439
+ * A JSON representation of the document `contents`.
2440
+ *
2441
+ * @param jsonArg Used by `JSON.stringify` to indicate the array index or
2442
+ * property name.
2443
+ */
2444
+ toJSON(t, n) {
2445
+ return this.toJS({ json: !0, jsonArg: t, mapAsMap: !1, onAnchor: n });
2446
+ }
2447
+ /** A YAML representation of the document. */
2448
+ toString(t = {}) {
2449
+ if (this.errors.length > 0)
2450
+ throw new Error("Document with errors cannot be stringified");
2451
+ if ("indent" in t && (!Number.isInteger(t.indent) || Number(t.indent) <= 0)) {
2452
+ const n = JSON.stringify(t.indent);
2453
+ throw new Error(`"indent" option must be a positive integer, not ${n}`);
2454
+ }
2455
+ return wa(this, t);
2456
+ }
2457
+ }
2458
+ function Ne(e) {
2459
+ if (be(e))
2460
+ return !0;
2461
+ throw new Error("Expected a YAML collection as document contents");
2462
+ }
2463
+ class Hn extends Error {
2464
+ constructor(t, n, s, i) {
2465
+ super(), this.name = t, this.code = s, this.message = i, this.pos = n;
2466
+ }
2467
+ }
2468
+ class Re extends Hn {
2469
+ constructor(t, n, s) {
2470
+ super("YAMLParseError", t, n, s);
2471
+ }
2472
+ }
2473
+ class va extends Hn {
2474
+ constructor(t, n, s) {
2475
+ super("YAMLWarning", t, n, s);
2476
+ }
2477
+ }
2478
+ const cn = (e, t) => (n) => {
2479
+ if (n.pos[0] === -1)
2480
+ return;
2481
+ n.linePos = n.pos.map((o) => t.linePos(o));
2482
+ const { line: s, col: i } = n.linePos[0];
2483
+ n.message += ` at line ${s}, column ${i}`;
2484
+ let a = i - 1, r = e.substring(t.lineStarts[s - 1], t.lineStarts[s]).replace(/[\n\r]+$/, "");
2485
+ if (a >= 60 && r.length > 80) {
2486
+ const o = Math.min(a - 39, r.length - 79);
2487
+ r = "…" + r.substring(o), a -= o - 1;
2488
+ }
2489
+ if (r.length > 80 && (r = r.substring(0, 79) + "…"), s > 1 && /^ *$/.test(r.substring(0, a))) {
2490
+ let o = e.substring(t.lineStarts[s - 2], t.lineStarts[s - 1]);
2491
+ o.length > 80 && (o = o.substring(0, 79) + `…
2492
+ `), r = o + r;
2493
+ }
2494
+ if (/[^ ]/.test(r)) {
2495
+ let o = 1;
2496
+ const c = n.linePos[1];
2497
+ c?.line === s && c.col > i && (o = Math.max(1, Math.min(c.col - i, 80 - a)));
2498
+ const l = " ".repeat(a) + "^".repeat(o);
2499
+ n.message += `:
2500
+
2501
+ ${r}
2502
+ ${l}
2503
+ `;
2504
+ }
2505
+ };
2506
+ function Ae(e, { flow: t, indicator: n, next: s, offset: i, onError: a, parentIndent: r, startOnNewline: o }) {
2507
+ let c = !1, l = o, u = o, f = "", d = "", h = !1, g = !1, p = null, m = null, w = null, v = null, $ = null, S = null, y = null;
2508
+ for (const k of e)
2509
+ switch (g && (k.type !== "space" && k.type !== "newline" && k.type !== "comma" && a(k.offset, "MISSING_CHAR", "Tags and anchors must be separated from the next token by white space"), g = !1), p && (l && k.type !== "comment" && k.type !== "newline" && a(p, "TAB_AS_INDENT", "Tabs are not allowed as indentation"), p = null), k.type) {
2510
+ case "space":
2511
+ !t && (n !== "doc-start" || s?.type !== "flow-collection") && k.source.includes(" ") && (p = k), u = !0;
2512
+ break;
2513
+ case "comment": {
2514
+ u || a(k, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters");
2515
+ const L = k.source.substring(1) || " ";
2516
+ f ? f += d + L : f = L, d = "", l = !1;
2517
+ break;
2518
+ }
2519
+ case "newline":
2520
+ l ? f ? f += k.source : (!S || n !== "seq-item-ind") && (c = !0) : d += k.source, l = !0, h = !0, (m || w) && (v = k), u = !0;
2521
+ break;
2522
+ case "anchor":
2523
+ m && a(k, "MULTIPLE_ANCHORS", "A node can have at most one anchor"), k.source.endsWith(":") && a(k.offset + k.source.length - 1, "BAD_ALIAS", "Anchor ending in : is ambiguous", !0), m = k, y ?? (y = k.offset), l = !1, u = !1, g = !0;
2524
+ break;
2525
+ case "tag": {
2526
+ w && a(k, "MULTIPLE_TAGS", "A node can have at most one tag"), w = k, y ?? (y = k.offset), l = !1, u = !1, g = !0;
2527
+ break;
2528
+ }
2529
+ case n:
2530
+ (m || w) && a(k, "BAD_PROP_ORDER", `Anchors and tags must be after the ${k.source} indicator`), S && a(k, "UNEXPECTED_TOKEN", `Unexpected ${k.source} in ${t ?? "collection"}`), S = k, l = n === "seq-item-ind" || n === "explicit-key-ind", u = !1;
2531
+ break;
2532
+ case "comma":
2533
+ if (t) {
2534
+ $ && a(k, "UNEXPECTED_TOKEN", `Unexpected , in ${t}`), $ = k, l = !1, u = !1;
2535
+ break;
2536
+ }
2537
+ // else fallthrough
2538
+ default:
2539
+ a(k, "UNEXPECTED_TOKEN", `Unexpected ${k.type} token`), l = !1, u = !1;
2540
+ }
2541
+ const N = e[e.length - 1], I = N ? N.offset + N.source.length : i;
2542
+ return g && s && s.type !== "space" && s.type !== "newline" && s.type !== "comma" && (s.type !== "scalar" || s.source !== "") && a(s.offset, "MISSING_CHAR", "Tags and anchors must be separated from the next token by white space"), p && (l && p.indent <= r || s?.type === "block-map" || s?.type === "block-seq") && a(p, "TAB_AS_INDENT", "Tabs are not allowed as indentation"), {
2543
+ comma: $,
2544
+ found: S,
2545
+ spaceBefore: c,
2546
+ comment: f,
2547
+ hasNewline: h,
2548
+ anchor: m,
2549
+ tag: w,
2550
+ newlineAfterProp: v,
2551
+ end: I,
2552
+ start: y ?? I
2553
+ };
2554
+ }
2555
+ function Ue(e) {
2556
+ if (!e)
2557
+ return null;
2558
+ switch (e.type) {
2559
+ case "alias":
2560
+ case "scalar":
2561
+ case "double-quoted-scalar":
2562
+ case "single-quoted-scalar":
2563
+ if (e.source.includes(`
2564
+ `))
2565
+ return !0;
2566
+ if (e.end) {
2567
+ for (const t of e.end)
2568
+ if (t.type === "newline")
2569
+ return !0;
2570
+ }
2571
+ return !1;
2572
+ case "flow-collection":
2573
+ for (const t of e.items) {
2574
+ for (const n of t.start)
2575
+ if (n.type === "newline")
2576
+ return !0;
2577
+ if (t.sep) {
2578
+ for (const n of t.sep)
2579
+ if (n.type === "newline")
2580
+ return !0;
2581
+ }
2582
+ if (Ue(t.key) || Ue(t.value))
2583
+ return !0;
2584
+ }
2585
+ return !1;
2586
+ default:
2587
+ return !0;
2588
+ }
2589
+ }
2590
+ function $t(e, t, n) {
2591
+ if (t?.type === "flow-collection") {
2592
+ const s = t.end[0];
2593
+ s.indent === e && (s.source === "]" || s.source === "}") && Ue(t) && n(s, "BAD_INDENT", "Flow end indicator should be more indented than parent", !0);
2594
+ }
2595
+ }
2596
+ function Vn(e, t, n) {
2597
+ const { uniqueKeys: s } = e.options;
2598
+ if (s === !1)
2599
+ return !1;
2600
+ const i = typeof s == "function" ? s : (a, r) => a === r || je(a) && je(r) && a.value === r.value;
2601
+ return t.some((a) => i(a.key, n));
2602
+ }
2603
+ const un = "All mapping items must start at the same column";
2604
+ function ka({ composeNode: e, composeEmptyNode: t }, n, s, i, a) {
2605
+ const r = a?.nodeClass ?? Ee, o = new r(n.schema);
2606
+ n.atRoot && (n.atRoot = !1);
2607
+ let c = s.offset, l = null;
2608
+ for (const u of s.items) {
2609
+ const { start: f, key: d, sep: h, value: g } = u, p = Ae(f, {
2610
+ indicator: "explicit-key-ind",
2611
+ next: d ?? h?.[0],
2612
+ offset: c,
2613
+ onError: i,
2614
+ parentIndent: s.indent,
2615
+ startOnNewline: !0
2616
+ }), m = !p.found;
2617
+ if (m) {
2618
+ if (d && (d.type === "block-seq" ? i(c, "BLOCK_AS_IMPLICIT_KEY", "A block sequence may not be used as an implicit map key") : "indent" in d && d.indent !== s.indent && i(c, "BAD_INDENT", un)), !p.anchor && !p.tag && !h) {
2619
+ l = p.end, p.comment && (o.comment ? o.comment += `
2620
+ ` + p.comment : o.comment = p.comment);
2621
+ continue;
2622
+ }
2623
+ (p.newlineAfterProp || Ue(d)) && i(d ?? f[f.length - 1], "MULTILINE_IMPLICIT_KEY", "Implicit keys need to be on a single line");
2624
+ } else p.found?.indent !== s.indent && i(c, "BAD_INDENT", un);
2625
+ n.atKey = !0;
2626
+ const w = p.end, v = d ? e(n, d, p, i) : t(n, w, f, null, p, i);
2627
+ n.schema.compat && $t(s.indent, d, i), n.atKey = !1, Vn(n, o.items, v) && i(w, "DUPLICATE_KEY", "Map keys must be unique");
2628
+ const $ = Ae(h ?? [], {
2629
+ indicator: "map-value-ind",
2630
+ next: g,
2631
+ offset: v.range[2],
2632
+ onError: i,
2633
+ parentIndent: s.indent,
2634
+ startOnNewline: !d || d.type === "block-scalar"
2635
+ });
2636
+ if (c = $.end, $.found) {
2637
+ m && (g?.type === "block-map" && !$.hasNewline && i(c, "BLOCK_AS_IMPLICIT_KEY", "Nested mappings are not allowed in compact mappings"), n.options.strict && p.start < $.found.offset - 1024 && i(v.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));
2638
+ const S = g ? e(n, g, $, i) : t(n, c, h, null, $, i);
2639
+ n.schema.compat && $t(s.indent, g, i), c = S.range[2];
2640
+ const y = new et(v, S);
2641
+ n.options.keepSourceTokens && (y.srcToken = u), o.items.push(y);
2642
+ } else {
2643
+ m && i(v.range, "MISSING_CHAR", "Implicit map keys need to be followed by map values"), $.comment && (v.comment ? v.comment += `
2644
+ ` + $.comment : v.comment = $.comment);
2645
+ const S = new et(v);
2646
+ n.options.keepSourceTokens && (S.srcToken = u), o.items.push(S);
2647
+ }
2648
+ }
2649
+ return l && l < c && i(l, "IMPOSSIBLE", "Map comment with trailing content"), o.range = [s.offset, c, l ?? c], o;
2650
+ }
2651
+ function $a({ composeNode: e, composeEmptyNode: t }, n, s, i, a) {
2652
+ const r = a?.nodeClass ?? Fe, o = new r(n.schema);
2653
+ n.atRoot && (n.atRoot = !1), n.atKey && (n.atKey = !1);
2654
+ let c = s.offset, l = null;
2655
+ for (const { start: u, value: f } of s.items) {
2656
+ const d = Ae(u, {
2657
+ indicator: "seq-item-ind",
2658
+ next: f,
2659
+ offset: c,
2660
+ onError: i,
2661
+ parentIndent: s.indent,
2662
+ startOnNewline: !0
2663
+ });
2664
+ if (!d.found)
2665
+ if (d.anchor || d.tag || f)
2666
+ f?.type === "block-seq" ? i(d.end, "BAD_INDENT", "All sequence items must start at the same column") : i(c, "MISSING_CHAR", "Sequence item without - indicator");
2667
+ else {
2668
+ l = d.end, d.comment && (o.comment = d.comment);
2669
+ continue;
2670
+ }
2671
+ const h = f ? e(n, f, d, i) : t(n, d.end, u, null, d, i);
2672
+ n.schema.compat && $t(s.indent, f, i), c = h.range[2], o.items.push(h);
2673
+ }
2674
+ return o.range = [s.offset, c, l ?? c], o;
2675
+ }
2676
+ function ze(e, t, n, s) {
2677
+ let i = "";
2678
+ if (e) {
2679
+ let a = !1, r = "";
2680
+ for (const o of e) {
2681
+ const { source: c, type: l } = o;
2682
+ switch (l) {
2683
+ case "space":
2684
+ a = !0;
2685
+ break;
2686
+ case "comment": {
2687
+ n && !a && s(o, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters");
2688
+ const u = c.substring(1) || " ";
2689
+ i ? i += r + u : i = u, r = "";
2690
+ break;
2691
+ }
2692
+ case "newline":
2693
+ i && (r += c), a = !0;
2694
+ break;
2695
+ default:
2696
+ s(o, "UNEXPECTED_TOKEN", `Unexpected ${l} at node end`);
2697
+ }
2698
+ t += c.length;
2699
+ }
2700
+ }
2701
+ return { comment: i, offset: t };
2702
+ }
2703
+ const ht = "Block collections are not allowed within flow collections", gt = (e) => e && (e.type === "block-map" || e.type === "block-seq");
2704
+ function Sa({ composeNode: e, composeEmptyNode: t }, n, s, i, a) {
2705
+ const r = s.start.source === "{", o = r ? "flow map" : "flow sequence", c = a?.nodeClass ?? (r ? Ee : Fe), l = new c(n.schema);
2706
+ l.flow = !0;
2707
+ const u = n.atRoot;
2708
+ u && (n.atRoot = !1), n.atKey && (n.atKey = !1);
2709
+ let f = s.offset + s.start.source.length;
2710
+ for (let m = 0; m < s.items.length; ++m) {
2711
+ const w = s.items[m], { start: v, key: $, sep: S, value: y } = w, N = Ae(v, {
2712
+ flow: o,
2713
+ indicator: "explicit-key-ind",
2714
+ next: $ ?? S?.[0],
2715
+ offset: f,
2716
+ onError: i,
2717
+ parentIndent: s.indent,
2718
+ startOnNewline: !1
2719
+ });
2720
+ if (!N.found) {
2721
+ if (!N.anchor && !N.tag && !S && !y) {
2722
+ m === 0 && N.comma ? i(N.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${o}`) : m < s.items.length - 1 && i(N.start, "UNEXPECTED_TOKEN", `Unexpected empty item in ${o}`), N.comment && (l.comment ? l.comment += `
2723
+ ` + N.comment : l.comment = N.comment), f = N.end;
2724
+ continue;
2725
+ }
2726
+ !r && n.options.strict && Ue($) && i(
2727
+ $,
2728
+ // checked by containsNewline()
2729
+ "MULTILINE_IMPLICIT_KEY",
2730
+ "Implicit keys of flow sequence pairs need to be on a single line"
2731
+ );
2732
+ }
2733
+ if (m === 0)
2734
+ N.comma && i(N.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${o}`);
2735
+ else if (N.comma || i(N.start, "MISSING_CHAR", `Missing , between ${o} items`), N.comment) {
2736
+ let I = "";
2737
+ e: for (const k of v)
2738
+ switch (k.type) {
2739
+ case "comma":
2740
+ case "space":
2741
+ break;
2742
+ case "comment":
2743
+ I = k.source.substring(1);
2744
+ break e;
2745
+ default:
2746
+ break e;
2747
+ }
2748
+ if (I) {
2749
+ let k = l.items[l.items.length - 1];
2750
+ An(k) && (k = k.value ?? k.key), k.comment ? k.comment += `
2751
+ ` + I : k.comment = I, N.comment = N.comment.substring(I.length + 1);
2752
+ }
2753
+ }
2754
+ if (!r && !S && !N.found) {
2755
+ const I = y ? e(n, y, N, i) : t(n, N.end, S, null, N, i);
2756
+ l.items.push(I), f = I.range[2], gt(y) && i(I.range, "BLOCK_IN_FLOW", ht);
2757
+ } else {
2758
+ n.atKey = !0;
2759
+ const I = N.end, k = $ ? e(n, $, N, i) : t(n, I, v, null, N, i);
2760
+ gt($) && i(k.range, "BLOCK_IN_FLOW", ht), n.atKey = !1;
2761
+ const L = Ae(S ?? [], {
2762
+ flow: o,
2763
+ indicator: "map-value-ind",
2764
+ next: y,
2765
+ offset: k.range[2],
2766
+ onError: i,
2767
+ parentIndent: s.indent,
2768
+ startOnNewline: !1
2769
+ });
2770
+ if (L.found) {
2771
+ if (!r && !N.found && n.options.strict) {
2772
+ if (S)
2773
+ for (const M of S) {
2774
+ if (M === L.found)
2775
+ break;
2776
+ if (M.type === "newline") {
2777
+ i(M, "MULTILINE_IMPLICIT_KEY", "Implicit keys of flow sequence pairs need to be on a single line");
2778
+ break;
2779
+ }
2780
+ }
2781
+ N.start < L.found.offset - 1024 && i(L.found, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit flow sequence key");
2782
+ }
2783
+ } else y && ("source" in y && y.source?.[0] === ":" ? i(y, "MISSING_CHAR", `Missing space after : in ${o}`) : i(L.start, "MISSING_CHAR", `Missing , or : between ${o} items`));
2784
+ const D = y ? e(n, y, L, i) : L.found ? t(n, L.end, S, null, L, i) : null;
2785
+ D ? gt(y) && i(D.range, "BLOCK_IN_FLOW", ht) : L.comment && (k.comment ? k.comment += `
2786
+ ` + L.comment : k.comment = L.comment);
2787
+ const G = new et(k, D);
2788
+ if (n.options.keepSourceTokens && (G.srcToken = w), r) {
2789
+ const M = l;
2790
+ Vn(n, M.items, k) && i(I, "DUPLICATE_KEY", "Map keys must be unique"), M.items.push(G);
2791
+ } else {
2792
+ const M = new Ee(n.schema);
2793
+ M.flow = !0, M.items.push(G);
2794
+ const J = (D ?? k).range;
2795
+ M.range = [k.range[0], J[1], J[2]], l.items.push(M);
2796
+ }
2797
+ f = D ? D.range[2] : L.end;
2798
+ }
2799
+ }
2800
+ const d = r ? "}" : "]", [h, ...g] = s.end;
2801
+ let p = f;
2802
+ if (h?.source === d)
2803
+ p = h.offset + h.source.length;
2804
+ else {
2805
+ const m = o[0].toUpperCase() + o.substring(1), w = u ? `${m} must end with a ${d}` : `${m} in block collection must be sufficiently indented and end with a ${d}`;
2806
+ i(f, u ? "MISSING_CHAR" : "BAD_INDENT", w), h && h.source.length !== 1 && g.unshift(h);
2807
+ }
2808
+ if (g.length > 0) {
2809
+ const m = ze(g, p, n.options.strict, i);
2810
+ m.comment && (l.comment ? l.comment += `
2811
+ ` + m.comment : l.comment = m.comment), l.range = [s.offset, p, m.offset];
2812
+ } else
2813
+ l.range = [s.offset, p, p];
2814
+ return l;
2815
+ }
2816
+ function yt(e, t, n, s, i, a) {
2817
+ const r = n.type === "block-map" ? ka(e, t, n, s, a) : n.type === "block-seq" ? $a(e, t, n, s, a) : Sa(e, t, n, s, a), o = r.constructor;
2818
+ return i === "!" || i === o.tagName ? (r.tag = o.tagName, r) : (i && (r.tag = i), r);
2819
+ }
2820
+ function Na(e, t, n, s, i) {
2821
+ const a = s.tag, r = a ? t.directives.tagName(a.source, (d) => i(a, "TAG_RESOLVE_FAILED", d)) : null;
2822
+ if (n.type === "block-seq") {
2823
+ const { anchor: d, newlineAfterProp: h } = s, g = d && a ? d.offset > a.offset ? d : a : d ?? a;
2824
+ g && (!h || h.offset < g.offset) && i(g, "MISSING_CHAR", "Missing newline after block sequence props");
2825
+ }
2826
+ const o = n.type === "block-map" ? "map" : n.type === "block-seq" ? "seq" : n.start.source === "{" ? "map" : "seq";
2827
+ if (!a || !r || r === "!" || r === Ee.tagName && o === "map" || r === Fe.tagName && o === "seq")
2828
+ return yt(e, t, n, i, r);
2829
+ let c = t.schema.tags.find((d) => d.tag === r && d.collection === o);
2830
+ if (!c) {
2831
+ const d = t.schema.knownTags[r];
2832
+ if (d?.collection === o)
2833
+ t.schema.tags.push(Object.assign({}, d, { default: !1 })), c = d;
2834
+ else
2835
+ return d ? i(a, "BAD_COLLECTION_TYPE", `${d.tag} used for ${o} collection, but expects ${d.collection ?? "scalar"}`, !0) : i(a, "TAG_RESOLVE_FAILED", `Unresolved tag: ${r}`, !0), yt(e, t, n, i, r);
2836
+ }
2837
+ const l = yt(e, t, n, i, r, c), u = c.resolve?.(l, (d) => i(a, "TAG_RESOLVE_FAILED", d), t.options) ?? l, f = Et(u) ? u : new j(u);
2838
+ return f.range = l.range, f.tag = r, c?.format && (f.format = c.format), f;
2839
+ }
2840
+ function Ia(e, t, n) {
2841
+ const s = t.offset, i = Ta(t, e.options.strict, n);
2842
+ if (!i)
2843
+ return { value: "", type: null, comment: "", range: [s, s, s] };
2844
+ const a = i.mode === ">" ? j.BLOCK_FOLDED : j.BLOCK_LITERAL, r = t.source ? Ea(t.source) : [];
2845
+ let o = r.length;
2846
+ for (let p = r.length - 1; p >= 0; --p) {
2847
+ const m = r[p][1];
2848
+ if (m === "" || m === "\r")
2849
+ o = p;
2850
+ else
2851
+ break;
2852
+ }
2853
+ if (o === 0) {
2854
+ const p = i.chomp === "+" && r.length > 0 ? `
2855
+ `.repeat(Math.max(1, r.length - 1)) : "";
2856
+ let m = s + i.length;
2857
+ return t.source && (m += t.source.length), { value: p, type: a, comment: i.comment, range: [s, m, m] };
2858
+ }
2859
+ let c = t.indent + i.indent, l = t.offset + i.length, u = 0;
2860
+ for (let p = 0; p < o; ++p) {
2861
+ const [m, w] = r[p];
2862
+ if (w === "" || w === "\r")
2863
+ i.indent === 0 && m.length > c && (c = m.length);
2864
+ else {
2865
+ m.length < c && n(l + m.length, "MISSING_CHAR", "Block scalars with more-indented leading empty lines must use an explicit indentation indicator"), i.indent === 0 && (c = m.length), u = p, c === 0 && !e.atRoot && n(l, "BAD_INDENT", "Block scalar values in collections must be indented");
2866
+ break;
2867
+ }
2868
+ l += m.length + w.length + 1;
2869
+ }
2870
+ for (let p = r.length - 1; p >= o; --p)
2871
+ r[p][0].length > c && (o = p + 1);
2872
+ let f = "", d = "", h = !1;
2873
+ for (let p = 0; p < u; ++p)
2874
+ f += r[p][0].slice(c) + `
2875
+ `;
2876
+ for (let p = u; p < o; ++p) {
2877
+ let [m, w] = r[p];
2878
+ l += m.length + w.length + 1;
2879
+ const v = w[w.length - 1] === "\r";
2880
+ if (v && (w = w.slice(0, -1)), w && m.length < c) {
2881
+ const S = `Block scalar lines must not be less indented than their ${i.indent ? "explicit indentation indicator" : "first line"}`;
2882
+ n(l - w.length - (v ? 2 : 1), "BAD_INDENT", S), m = "";
2883
+ }
2884
+ a === j.BLOCK_LITERAL ? (f += d + m.slice(c) + w, d = `
2885
+ `) : m.length > c || w[0] === " " ? (d === " " ? d = `
2886
+ ` : !h && d === `
2887
+ ` && (d = `
2888
+
2889
+ `), f += d + m.slice(c) + w, d = `
2890
+ `, h = !0) : w === "" ? d === `
2891
+ ` ? f += `
2892
+ ` : d = `
2893
+ ` : (f += d + w, d = " ", h = !1);
2894
+ }
2895
+ switch (i.chomp) {
2896
+ case "-":
2897
+ break;
2898
+ case "+":
2899
+ for (let p = o; p < r.length; ++p)
2900
+ f += `
2901
+ ` + r[p][0].slice(c);
2902
+ f[f.length - 1] !== `
2903
+ ` && (f += `
2904
+ `);
2905
+ break;
2906
+ default:
2907
+ f += `
2908
+ `;
2909
+ }
2910
+ const g = s + i.length + t.source.length;
2911
+ return { value: f, type: a, comment: i.comment, range: [s, g, g] };
2912
+ }
2913
+ function Ta({ offset: e, props: t }, n, s) {
2914
+ if (t[0].type !== "block-scalar-header")
2915
+ return s(t[0], "IMPOSSIBLE", "Block scalar header not found"), null;
2916
+ const { source: i } = t[0], a = i[0];
2917
+ let r = 0, o = "", c = -1;
2918
+ for (let d = 1; d < i.length; ++d) {
2919
+ const h = i[d];
2920
+ if (!o && (h === "-" || h === "+"))
2921
+ o = h;
2922
+ else {
2923
+ const g = Number(h);
2924
+ !r && g ? r = g : c === -1 && (c = e + d);
2925
+ }
2926
+ }
2927
+ c !== -1 && s(c, "UNEXPECTED_TOKEN", `Block scalar header includes extra characters: ${i}`);
2928
+ let l = !1, u = "", f = i.length;
2929
+ for (let d = 1; d < t.length; ++d) {
2930
+ const h = t[d];
2931
+ switch (h.type) {
2932
+ case "space":
2933
+ l = !0;
2934
+ // fallthrough
2935
+ case "newline":
2936
+ f += h.source.length;
2937
+ break;
2938
+ case "comment":
2939
+ n && !l && s(h, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters"), f += h.source.length, u = h.source.substring(1);
2940
+ break;
2941
+ case "error":
2942
+ s(h, "UNEXPECTED_TOKEN", h.message), f += h.source.length;
2943
+ break;
2944
+ /* istanbul ignore next should not happen */
2945
+ default: {
2946
+ const g = `Unexpected token in block scalar header: ${h.type}`;
2947
+ s(h, "UNEXPECTED_TOKEN", g);
2948
+ const p = h.source;
2949
+ p && typeof p == "string" && (f += p.length);
2950
+ }
2951
+ }
2952
+ }
2953
+ return { mode: a, indent: r, chomp: o, comment: u, length: f };
2954
+ }
2955
+ function Ea(e) {
2956
+ const t = e.split(/\n( *)/), n = t[0], s = n.match(/^( *)/), a = [s?.[1] ? [s[1], n.slice(s[1].length)] : ["", n]];
2957
+ for (let r = 1; r < t.length; r += 2)
2958
+ a.push([t[r], t[r + 1]]);
2959
+ return a;
2960
+ }
2961
+ function Aa(e, t, n) {
2962
+ const { offset: s, type: i, source: a, end: r } = e;
2963
+ let o, c;
2964
+ const l = (d, h, g) => n(s + d, h, g);
2965
+ switch (i) {
2966
+ case "scalar":
2967
+ o = j.PLAIN, c = Oa(a, l);
2968
+ break;
2969
+ case "single-quoted-scalar":
2970
+ o = j.QUOTE_SINGLE, c = La(a, l);
2971
+ break;
2972
+ case "double-quoted-scalar":
2973
+ o = j.QUOTE_DOUBLE, c = Ca(a, l);
2974
+ break;
2975
+ /* istanbul ignore next should not happen */
2976
+ default:
2977
+ return n(e, "UNEXPECTED_TOKEN", `Expected a flow scalar value, but found: ${i}`), {
2978
+ value: "",
2979
+ type: null,
2980
+ comment: "",
2981
+ range: [s, s + a.length, s + a.length]
2982
+ };
2983
+ }
2984
+ const u = s + a.length, f = ze(r, u, t, n);
2985
+ return {
2986
+ value: c,
2987
+ type: o,
2988
+ comment: f.comment,
2989
+ range: [s, u, f.offset]
2990
+ };
2991
+ }
2992
+ function Oa(e, t) {
2993
+ let n = "";
2994
+ switch (e[0]) {
2995
+ /* istanbul ignore next should not happen */
2996
+ case " ":
2997
+ n = "a tab character";
2998
+ break;
2999
+ case ",":
3000
+ n = "flow indicator character ,";
3001
+ break;
3002
+ case "%":
3003
+ n = "directive indicator character %";
3004
+ break;
3005
+ case "|":
3006
+ case ">": {
3007
+ n = `block scalar indicator ${e[0]}`;
3008
+ break;
3009
+ }
3010
+ case "@":
3011
+ case "`": {
3012
+ n = `reserved character ${e[0]}`;
3013
+ break;
3014
+ }
3015
+ }
3016
+ return n && t(0, "BAD_SCALAR_START", `Plain value cannot start with ${n}`), Xn(e);
3017
+ }
3018
+ function La(e, t) {
3019
+ return (e[e.length - 1] !== "'" || e.length === 1) && t(e.length, "MISSING_CHAR", "Missing closing 'quote"), Xn(e.slice(1, -1)).replace(/''/g, "'");
3020
+ }
3021
+ function Xn(e) {
3022
+ let t, n;
3023
+ try {
3024
+ t = new RegExp(`(.*?)(?<![ ])[ ]*\r?
3025
+ `, "sy"), n = new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
3026
+ `, "sy");
3027
+ } catch {
3028
+ t = /(.*?)[ \t]*\r?\n/sy, n = /[ \t]*(.*?)[ \t]*\r?\n/sy;
3029
+ }
3030
+ let s = t.exec(e);
3031
+ if (!s)
3032
+ return e;
3033
+ let i = s[1], a = " ", r = t.lastIndex;
3034
+ for (n.lastIndex = r; s = n.exec(e); )
3035
+ s[1] === "" ? a === `
3036
+ ` ? i += a : a = `
3037
+ ` : (i += a + s[1], a = " "), r = n.lastIndex;
3038
+ const o = /[ \t]*(.*)/sy;
3039
+ return o.lastIndex = r, s = o.exec(e), i + a + (s?.[1] ?? "");
3040
+ }
3041
+ function Ca(e, t) {
3042
+ let n = "";
3043
+ for (let s = 1; s < e.length - 1; ++s) {
3044
+ const i = e[s];
3045
+ if (!(i === "\r" && e[s + 1] === `
3046
+ `))
3047
+ if (i === `
3048
+ `) {
3049
+ const { fold: a, offset: r } = _a(e, s);
3050
+ n += a, s = r;
3051
+ } else if (i === "\\") {
3052
+ let a = e[++s];
3053
+ const r = xa[a];
3054
+ if (r)
3055
+ n += r;
3056
+ else if (a === `
3057
+ `)
3058
+ for (a = e[s + 1]; a === " " || a === " "; )
3059
+ a = e[++s + 1];
3060
+ else if (a === "\r" && e[s + 1] === `
3061
+ `)
3062
+ for (a = e[++s + 1]; a === " " || a === " "; )
3063
+ a = e[++s + 1];
3064
+ else if (a === "x" || a === "u" || a === "U") {
3065
+ const o = a === "x" ? 2 : a === "u" ? 4 : 8;
3066
+ n += Da(e, s + 1, o, t), s += o;
3067
+ } else {
3068
+ const o = e.substr(s - 1, 2);
3069
+ t(s - 1, "BAD_DQ_ESCAPE", `Invalid escape sequence ${o}`), n += o;
3070
+ }
3071
+ } else if (i === " " || i === " ") {
3072
+ const a = s;
3073
+ let r = e[s + 1];
3074
+ for (; r === " " || r === " "; )
3075
+ r = e[++s + 1];
3076
+ r !== `
3077
+ ` && !(r === "\r" && e[s + 2] === `
3078
+ `) && (n += s > a ? e.slice(a, s + 1) : i);
3079
+ } else
3080
+ n += i;
3081
+ }
3082
+ return (e[e.length - 1] !== '"' || e.length === 1) && t(e.length, "MISSING_CHAR", 'Missing closing "quote'), n;
3083
+ }
3084
+ function _a(e, t) {
3085
+ let n = "", s = e[t + 1];
3086
+ for (; (s === " " || s === " " || s === `
3087
+ ` || s === "\r") && !(s === "\r" && e[t + 2] !== `
3088
+ `); )
3089
+ s === `
3090
+ ` && (n += `
3091
+ `), t += 1, s = e[t + 1];
3092
+ return n || (n = " "), { fold: n, offset: t };
3093
+ }
3094
+ const xa = {
3095
+ 0: "\0",
3096
+ // null character
3097
+ a: "\x07",
3098
+ // bell character
3099
+ b: "\b",
3100
+ // backspace
3101
+ e: "\x1B",
3102
+ // escape character
3103
+ f: "\f",
3104
+ // form feed
3105
+ n: `
3106
+ `,
3107
+ // line feed
3108
+ r: "\r",
3109
+ // carriage return
3110
+ t: " ",
3111
+ // horizontal tab
3112
+ v: "\v",
3113
+ // vertical tab
3114
+ N: "…",
3115
+ // Unicode next line
3116
+ _: " ",
3117
+ // Unicode non-breaking space
3118
+ L: "\u2028",
3119
+ // Unicode line separator
3120
+ P: "\u2029",
3121
+ // Unicode paragraph separator
3122
+ " ": " ",
3123
+ '"': '"',
3124
+ "/": "/",
3125
+ "\\": "\\",
3126
+ " ": " "
3127
+ };
3128
+ function Da(e, t, n, s) {
3129
+ const i = e.substr(t, n), r = i.length === n && /^[0-9a-fA-F]+$/.test(i) ? parseInt(i, 16) : NaN;
3130
+ try {
3131
+ return String.fromCodePoint(r);
3132
+ } catch {
3133
+ const o = e.substr(t - 2, n + 2);
3134
+ return s(t - 2, "BAD_DQ_ESCAPE", `Invalid escape sequence ${o}`), o;
3135
+ }
3136
+ }
3137
+ function Gn(e, t, n, s) {
3138
+ const { value: i, type: a, comment: r, range: o } = t.type === "block-scalar" ? Ia(e, t, s) : Aa(t, e.options.strict, s), c = n ? e.directives.tagName(n.source, (f) => s(n, "TAG_RESOLVE_FAILED", f)) : null;
3139
+ let l;
3140
+ e.options.stringKeys && e.atKey ? l = e.schema[we] : c ? l = Pa(e.schema, i, c, n, s) : t.type === "scalar" ? l = Ma(e, i, t, s) : l = e.schema[we];
3141
+ let u;
3142
+ try {
3143
+ const f = l.resolve(i, (d) => s(n ?? t, "TAG_RESOLVE_FAILED", d), e.options);
3144
+ u = je(f) ? f : new j(f);
3145
+ } catch (f) {
3146
+ const d = f instanceof Error ? f.message : String(f);
3147
+ s(n ?? t, "TAG_RESOLVE_FAILED", d), u = new j(i);
3148
+ }
3149
+ return u.range = o, u.source = i, a && (u.type = a), c && (u.tag = c), l.format && (u.format = l.format), r && (u.comment = r), u;
3150
+ }
3151
+ function Pa(e, t, n, s, i) {
3152
+ if (n === "!")
3153
+ return e[we];
3154
+ const a = [];
3155
+ for (const o of e.tags)
3156
+ if (!o.collection && o.tag === n)
3157
+ if (o.default && o.test)
3158
+ a.push(o);
3159
+ else
3160
+ return o;
3161
+ for (const o of a)
3162
+ if (o.test?.test(t))
3163
+ return o;
3164
+ const r = e.knownTags[n];
3165
+ return r && !r.collection ? (e.tags.push(Object.assign({}, r, { default: !1, test: void 0 })), r) : (i(s, "TAG_RESOLVE_FAILED", `Unresolved tag: ${n}`, n !== "tag:yaml.org,2002:str"), e[we]);
3166
+ }
3167
+ function Ma({ atKey: e, directives: t, schema: n }, s, i, a) {
3168
+ const r = n.tags.find((o) => (o.default === !0 || e && o.default === "key") && o.test?.test(s)) || n[we];
3169
+ if (n.compat) {
3170
+ const o = n.compat.find((c) => c.default && c.test?.test(s)) ?? n[we];
3171
+ if (r.tag !== o.tag) {
3172
+ const c = t.tagString(r.tag), l = t.tagString(o.tag), u = `Value may be parsed as either ${c} or ${l}`;
3173
+ a(i, "TAG_RESOLVE_FAILED", u, !0);
3174
+ }
3175
+ }
3176
+ return r;
3177
+ }
3178
+ function Ra(e, t, n) {
3179
+ if (t) {
3180
+ n ?? (n = t.length);
3181
+ for (let s = n - 1; s >= 0; --s) {
3182
+ let i = t[s];
3183
+ switch (i.type) {
3184
+ case "space":
3185
+ case "comment":
3186
+ case "newline":
3187
+ e -= i.source.length;
3188
+ continue;
3189
+ }
3190
+ for (i = t[++s]; i?.type === "space"; )
3191
+ e += i.source.length, i = t[++s];
3192
+ break;
3193
+ }
3194
+ }
3195
+ return e;
3196
+ }
3197
+ const Fa = { composeNode: Wn, composeEmptyNode: Pt };
3198
+ function Wn(e, t, n, s) {
3199
+ const i = e.atKey, { spaceBefore: a, comment: r, anchor: o, tag: c } = n;
3200
+ let l, u = !0;
3201
+ switch (t.type) {
3202
+ case "alias":
3203
+ l = ja(e, t, s), (o || c) && s(t, "ALIAS_PROPS", "An alias node must not specify any properties");
3204
+ break;
3205
+ case "scalar":
3206
+ case "single-quoted-scalar":
3207
+ case "double-quoted-scalar":
3208
+ case "block-scalar":
3209
+ l = Gn(e, t, c, s), o && (l.anchor = o.source.substring(1));
3210
+ break;
3211
+ case "block-map":
3212
+ case "block-seq":
3213
+ case "flow-collection":
3214
+ try {
3215
+ l = Na(Fa, e, t, n, s), o && (l.anchor = o.source.substring(1));
3216
+ } catch (f) {
3217
+ const d = f instanceof Error ? f.message : String(f);
3218
+ s(t, "RESOURCE_EXHAUSTION", d);
3219
+ }
3220
+ break;
3221
+ default: {
3222
+ const f = t.type === "error" ? t.message : `Unsupported token (type: ${t.type})`;
3223
+ s(t, "UNEXPECTED_TOKEN", f), u = !1;
3224
+ }
3225
+ }
3226
+ return l ?? (l = Pt(e, t.offset, void 0, null, n, s)), o && l.anchor === "" && s(o, "BAD_ALIAS", "Anchor cannot be an empty string"), i && e.options.stringKeys && (!je(l) || typeof l.value != "string" || l.tag && l.tag !== "tag:yaml.org,2002:str") && s(c ?? t, "NON_STRING_KEY", "With stringKeys, all keys must be strings"), a && (l.spaceBefore = !0), r && (t.type === "scalar" && t.source === "" ? l.comment = r : l.commentBefore = r), e.options.keepSourceTokens && u && (l.srcToken = t), l;
3227
+ }
3228
+ function Pt(e, t, n, s, { spaceBefore: i, comment: a, anchor: r, tag: o, end: c }, l) {
3229
+ const u = {
3230
+ type: "scalar",
3231
+ offset: Ra(t, n, s),
3232
+ indent: -1,
3233
+ source: ""
3234
+ }, f = Gn(e, u, o, l);
3235
+ return r && (f.anchor = r.source.substring(1), f.anchor === "" && l(r, "BAD_ALIAS", "Anchor cannot be an empty string")), i && (f.spaceBefore = !0), a && (f.comment = a, f.range[2] = c), f;
3236
+ }
3237
+ function ja({ options: e }, { offset: t, source: n, end: s }, i) {
3238
+ const a = new En(n.substring(1));
3239
+ a.source === "" && i(t, "BAD_ALIAS", "Alias cannot be an empty string"), a.source.endsWith(":") && i(t + n.length - 1, "BAD_ALIAS", "Alias ending in : is ambiguous", !0);
3240
+ const r = t + n.length, o = ze(s, r, e.strict, i);
3241
+ return a.range = [t, r, o.offset], o.comment && (a.comment = o.comment), a;
3242
+ }
3243
+ function Ua(e, t, { offset: n, start: s, value: i, end: a }, r) {
3244
+ const o = Object.assign({ _directives: t }, e), c = new Ke(void 0, o), l = {
3245
+ atKey: !1,
3246
+ atRoot: !0,
3247
+ directives: c.directives,
3248
+ options: c.options,
3249
+ schema: c.schema
3250
+ }, u = Ae(s, {
3251
+ indicator: "doc-start",
3252
+ next: i ?? a?.[0],
3253
+ offset: n,
3254
+ onError: r,
3255
+ parentIndent: 0,
3256
+ startOnNewline: !0
3257
+ });
3258
+ u.found && (c.directives.docStart = !0, i && (i.type === "block-map" || i.type === "block-seq") && !u.hasNewline && r(u.end, "MISSING_CHAR", "Block collection cannot start on same line with directives-end marker")), c.contents = i ? Wn(l, i, u, r) : Pt(l, u.end, s, null, u, r);
3259
+ const f = c.contents.range[2], d = ze(a, f, !1, r);
3260
+ return d.comment && (c.comment = d.comment), c.range = [n, f, d.offset], c;
3261
+ }
3262
+ function Pe(e) {
3263
+ if (typeof e == "number")
3264
+ return [e, e + 1];
3265
+ if (Array.isArray(e))
3266
+ return e.length === 2 ? e : [e[0], e[1]];
3267
+ const { offset: t, source: n } = e;
3268
+ return [t, t + (typeof n == "string" ? n.length : 1)];
3269
+ }
3270
+ function fn(e) {
3271
+ let t = "", n = !1, s = !1;
3272
+ for (let i = 0; i < e.length; ++i) {
3273
+ const a = e[i];
3274
+ switch (a[0]) {
3275
+ case "#":
3276
+ t += (t === "" ? "" : s ? `
3277
+
3278
+ ` : `
3279
+ `) + (a.substring(1) || " "), n = !0, s = !1;
3280
+ break;
3281
+ case "%":
3282
+ e[i + 1]?.[0] !== "#" && (i += 1), n = !1;
3283
+ break;
3284
+ default:
3285
+ n || (s = !0), n = !1;
3286
+ }
3287
+ }
3288
+ return { comment: t, afterEmptyLine: s };
3289
+ }
3290
+ class Ba {
3291
+ constructor(t = {}) {
3292
+ this.doc = null, this.atDirectives = !1, this.prelude = [], this.errors = [], this.warnings = [], this.onError = (n, s, i, a) => {
3293
+ const r = Pe(n);
3294
+ a ? this.warnings.push(new va(r, s, i)) : this.errors.push(new Re(r, s, i));
3295
+ }, this.directives = new Qe({ version: t.version || "1.2" }), this.options = t;
3296
+ }
3297
+ decorate(t, n) {
3298
+ const { comment: s, afterEmptyLine: i } = fn(this.prelude);
3299
+ if (s) {
3300
+ const a = t.contents;
3301
+ if (n)
3302
+ t.comment = t.comment ? `${t.comment}
3303
+ ${s}` : s;
3304
+ else if (i || t.directives.docStart || !a)
3305
+ t.commentBefore = s;
3306
+ else if (be(a) && !a.flow && a.items.length > 0) {
3307
+ let r = a.items[0];
3308
+ An(r) && (r = r.key);
3309
+ const o = r.commentBefore;
3310
+ r.commentBefore = o ? `${s}
3311
+ ${o}` : s;
3312
+ } else {
3313
+ const r = a.commentBefore;
3314
+ a.commentBefore = r ? `${s}
3315
+ ${r}` : s;
3316
+ }
3317
+ }
3318
+ if (n) {
3319
+ for (let a = 0; a < this.errors.length; ++a)
3320
+ t.errors.push(this.errors[a]);
3321
+ for (let a = 0; a < this.warnings.length; ++a)
3322
+ t.warnings.push(this.warnings[a]);
3323
+ } else
3324
+ t.errors = this.errors, t.warnings = this.warnings;
3325
+ this.prelude = [], this.errors = [], this.warnings = [];
3326
+ }
3327
+ /**
3328
+ * Current stream status information.
3329
+ *
3330
+ * Mostly useful at the end of input for an empty stream.
3331
+ */
3332
+ streamInfo() {
3333
+ return {
3334
+ comment: fn(this.prelude).comment,
3335
+ directives: this.directives,
3336
+ errors: this.errors,
3337
+ warnings: this.warnings
3338
+ };
3339
+ }
3340
+ /**
3341
+ * Compose tokens into documents.
3342
+ *
3343
+ * @param forceDoc - If the stream contains no document, still emit a final document including any comments and directives that would be applied to a subsequent document.
3344
+ * @param endOffset - Should be set if `forceDoc` is also set, to set the document range end and to indicate errors correctly.
3345
+ */
3346
+ *compose(t, n = !1, s = -1) {
3347
+ for (const i of t)
3348
+ yield* this.next(i);
3349
+ yield* this.end(n, s);
3350
+ }
3351
+ /** Advance the composer by one CST token. */
3352
+ *next(t) {
3353
+ switch (t.type) {
3354
+ case "directive":
3355
+ this.directives.add(t.source, (n, s, i) => {
3356
+ const a = Pe(t);
3357
+ a[0] += n, this.onError(a, "BAD_DIRECTIVE", s, i);
3358
+ }), this.prelude.push(t.source), this.atDirectives = !0;
3359
+ break;
3360
+ case "document": {
3361
+ const n = Ua(this.options, this.directives, t, this.onError);
3362
+ this.atDirectives && !n.directives.docStart && this.onError(t, "MISSING_CHAR", "Missing directives-end/doc-start indicator line"), this.decorate(n, !1), this.doc && (yield this.doc), this.doc = n, this.atDirectives = !1;
3363
+ break;
3364
+ }
3365
+ case "byte-order-mark":
3366
+ case "space":
3367
+ break;
3368
+ case "comment":
3369
+ case "newline":
3370
+ this.prelude.push(t.source);
3371
+ break;
3372
+ case "error": {
3373
+ const n = t.source ? `${t.message}: ${JSON.stringify(t.source)}` : t.message, s = new Re(Pe(t), "UNEXPECTED_TOKEN", n);
3374
+ this.atDirectives || !this.doc ? this.errors.push(s) : this.doc.errors.push(s);
3375
+ break;
3376
+ }
3377
+ case "doc-end": {
3378
+ if (!this.doc) {
3379
+ const s = "Unexpected doc-end without preceding document";
3380
+ this.errors.push(new Re(Pe(t), "UNEXPECTED_TOKEN", s));
3381
+ break;
3382
+ }
3383
+ this.doc.directives.docEnd = !0;
3384
+ const n = ze(t.end, t.offset + t.source.length, this.doc.options.strict, this.onError);
3385
+ if (this.decorate(this.doc, !0), n.comment) {
3386
+ const s = this.doc.comment;
3387
+ this.doc.comment = s ? `${s}
3388
+ ${n.comment}` : n.comment;
3389
+ }
3390
+ this.doc.range[2] = n.offset;
3391
+ break;
3392
+ }
3393
+ default:
3394
+ this.errors.push(new Re(Pe(t), "UNEXPECTED_TOKEN", `Unsupported token ${t.type}`));
3395
+ }
3396
+ }
3397
+ /**
3398
+ * Call at end of input to yield any remaining document.
3399
+ *
3400
+ * @param forceDoc - If the stream contains no document, still emit a final document including any comments and directives that would be applied to a subsequent document.
3401
+ * @param endOffset - Should be set if `forceDoc` is also set, to set the document range end and to indicate errors correctly.
3402
+ */
3403
+ *end(t = !1, n = -1) {
3404
+ if (this.doc)
3405
+ this.decorate(this.doc, !0), yield this.doc, this.doc = null;
3406
+ else if (t) {
3407
+ const s = Object.assign({ _directives: this.directives }, this.options), i = new Ke(void 0, s);
3408
+ this.atDirectives && this.onError(n, "MISSING_CHAR", "Missing directives-end indicator line"), i.range = [0, n, n], this.decorate(i, !1), yield i;
3409
+ }
3410
+ }
3411
+ }
3412
+ class qa {
3413
+ constructor() {
3414
+ this.lineStarts = [], this.addNewLine = (t) => this.lineStarts.push(t), this.linePos = (t) => {
3415
+ let n = 0, s = this.lineStarts.length;
3416
+ for (; n < s; ) {
3417
+ const a = n + s >> 1;
3418
+ this.lineStarts[a] < t ? n = a + 1 : s = a;
3419
+ }
3420
+ if (this.lineStarts[n] === t)
3421
+ return { line: n + 1, col: 1 };
3422
+ if (n === 0)
3423
+ return { line: 0, col: t };
3424
+ const i = this.lineStarts[n - 1];
3425
+ return { line: n, col: t - i + 1 };
3426
+ };
3427
+ }
3428
+ }
3429
+ function ce(e, t) {
3430
+ for (let n = 0; n < e.length; ++n)
3431
+ if (e[n].type === t)
3432
+ return !0;
3433
+ return !1;
3434
+ }
3435
+ function dn(e) {
3436
+ for (let t = 0; t < e.length; ++t)
3437
+ switch (e[t].type) {
3438
+ case "space":
3439
+ case "comment":
3440
+ case "newline":
3441
+ break;
3442
+ default:
3443
+ return t;
3444
+ }
3445
+ return -1;
3446
+ }
3447
+ function Yn(e) {
3448
+ switch (e?.type) {
3449
+ case "alias":
3450
+ case "scalar":
3451
+ case "single-quoted-scalar":
3452
+ case "double-quoted-scalar":
3453
+ case "flow-collection":
3454
+ return !0;
3455
+ default:
3456
+ return !1;
3457
+ }
3458
+ }
3459
+ function Ze(e) {
3460
+ switch (e.type) {
3461
+ case "document":
3462
+ return e.start;
3463
+ case "block-map": {
3464
+ const t = e.items[e.items.length - 1];
3465
+ return t.sep ?? t.start;
3466
+ }
3467
+ case "block-seq":
3468
+ return e.items[e.items.length - 1].start;
3469
+ /* istanbul ignore next should not happen */
3470
+ default:
3471
+ return [];
3472
+ }
3473
+ }
3474
+ function Ie(e) {
3475
+ if (e.length === 0)
3476
+ return [];
3477
+ let t = e.length;
3478
+ e: for (; --t >= 0; )
3479
+ switch (e[t].type) {
3480
+ case "doc-start":
3481
+ case "explicit-key-ind":
3482
+ case "map-value-ind":
3483
+ case "seq-item-ind":
3484
+ case "newline":
3485
+ break e;
3486
+ }
3487
+ for (; e[++t]?.type === "space"; )
3488
+ ;
3489
+ return e.splice(t, e.length);
3490
+ }
3491
+ function tt(e, t) {
3492
+ if (t.length < 1e5)
3493
+ Array.prototype.push.apply(e, t);
3494
+ else
3495
+ for (let n = 0; n < t.length; ++n)
3496
+ e.push(t[n]);
3497
+ }
3498
+ function pn(e) {
3499
+ if (e.start.type === "flow-seq-start")
3500
+ for (const t of e.items)
3501
+ t.sep && !t.value && !ce(t.start, "explicit-key-ind") && !ce(t.sep, "map-value-ind") && (t.key && (t.value = t.key), delete t.key, Yn(t.value) ? t.value.end ? tt(t.value.end, t.sep) : t.value.end = t.sep : tt(t.start, t.sep), delete t.sep);
3502
+ }
3503
+ class Ka {
3504
+ /**
3505
+ * @param onNewLine - If defined, called separately with the start position of
3506
+ * each new line (in `parse()`, including the start of input).
3507
+ */
3508
+ constructor(t) {
3509
+ this.atNewLine = !0, this.atScalar = !1, this.indent = 0, this.offset = 0, this.onKeyLine = !1, this.stack = [], this.source = "", this.type = "", this.lexer = new Gs(), this.onNewLine = t;
3510
+ }
3511
+ /**
3512
+ * Parse `source` as a YAML stream.
3513
+ * If `incomplete`, a part of the last line may be left as a buffer for the next call.
3514
+ *
3515
+ * Errors are not thrown, but yielded as `{ type: 'error', message }` tokens.
3516
+ *
3517
+ * @returns A generator of tokens representing each directive, document, and other structure.
3518
+ */
3519
+ *parse(t, n = !1) {
3520
+ this.onNewLine && this.offset === 0 && this.onNewLine(0);
3521
+ for (const s of this.lexer.lex(t, n))
3522
+ yield* this.next(s);
3523
+ n || (yield* this.end());
3524
+ }
3525
+ /**
3526
+ * Advance the parser by the `source` of one lexical token.
3527
+ */
3528
+ *next(t) {
3529
+ if (this.source = t, this.atScalar) {
3530
+ this.atScalar = !1, yield* this.step(), this.offset += t.length;
3531
+ return;
3532
+ }
3533
+ const n = Ws(t);
3534
+ if (n)
3535
+ if (n === "scalar")
3536
+ this.atNewLine = !1, this.atScalar = !0, this.type = "scalar";
3537
+ else {
3538
+ switch (this.type = n, yield* this.step(), n) {
3539
+ case "newline":
3540
+ this.atNewLine = !0, this.indent = 0, this.onNewLine && this.onNewLine(this.offset + t.length);
3541
+ break;
3542
+ case "space":
3543
+ this.atNewLine && t[0] === " " && (this.indent += t.length);
3544
+ break;
3545
+ case "explicit-key-ind":
3546
+ case "map-value-ind":
3547
+ case "seq-item-ind":
3548
+ this.atNewLine && (this.indent += t.length);
3549
+ break;
3550
+ case "doc-mode":
3551
+ case "flow-error-end":
3552
+ return;
3553
+ default:
3554
+ this.atNewLine = !1;
3555
+ }
3556
+ this.offset += t.length;
3557
+ }
3558
+ else {
3559
+ const s = `Not a YAML token: ${t}`;
3560
+ yield* this.pop({ type: "error", offset: this.offset, message: s, source: t }), this.offset += t.length;
3561
+ }
3562
+ }
3563
+ /** Call at end of input to push out any remaining constructions */
3564
+ *end() {
3565
+ for (; this.stack.length > 0; )
3566
+ yield* this.pop();
3567
+ }
3568
+ get sourceToken() {
3569
+ return {
3570
+ type: this.type,
3571
+ offset: this.offset,
3572
+ indent: this.indent,
3573
+ source: this.source
3574
+ };
3575
+ }
3576
+ *step() {
3577
+ const t = this.peek(1);
3578
+ if (this.type === "doc-end" && t?.type !== "doc-end") {
3579
+ for (; this.stack.length > 0; )
3580
+ yield* this.pop();
3581
+ this.stack.push({
3582
+ type: "doc-end",
3583
+ offset: this.offset,
3584
+ source: this.source
3585
+ });
3586
+ return;
3587
+ }
3588
+ if (!t)
3589
+ return yield* this.stream();
3590
+ switch (t.type) {
3591
+ case "document":
3592
+ return yield* this.document(t);
3593
+ case "alias":
3594
+ case "scalar":
3595
+ case "single-quoted-scalar":
3596
+ case "double-quoted-scalar":
3597
+ return yield* this.scalar(t);
3598
+ case "block-scalar":
3599
+ return yield* this.blockScalar(t);
3600
+ case "block-map":
3601
+ return yield* this.blockMap(t);
3602
+ case "block-seq":
3603
+ return yield* this.blockSequence(t);
3604
+ case "flow-collection":
3605
+ return yield* this.flowCollection(t);
3606
+ case "doc-end":
3607
+ return yield* this.documentEnd(t);
3608
+ }
3609
+ yield* this.pop();
3610
+ }
3611
+ peek(t) {
3612
+ return this.stack[this.stack.length - t];
3613
+ }
3614
+ *pop(t) {
3615
+ const n = t ?? this.stack.pop();
3616
+ if (!n)
3617
+ yield { type: "error", offset: this.offset, source: "", message: "Tried to pop an empty stack" };
3618
+ else if (this.stack.length === 0)
3619
+ yield n;
3620
+ else {
3621
+ const s = this.peek(1);
3622
+ switch (n.type === "block-scalar" ? n.indent = "indent" in s ? s.indent : 0 : n.type === "flow-collection" && s.type === "document" && (n.indent = 0), n.type === "flow-collection" && pn(n), s.type) {
3623
+ case "document":
3624
+ s.value = n;
3625
+ break;
3626
+ case "block-scalar":
3627
+ s.props.push(n);
3628
+ break;
3629
+ case "block-map": {
3630
+ const i = s.items[s.items.length - 1];
3631
+ if (i.value) {
3632
+ s.items.push({ start: [], key: n, sep: [] }), this.onKeyLine = !0;
3633
+ return;
3634
+ } else if (i.sep)
3635
+ i.value = n;
3636
+ else {
3637
+ Object.assign(i, { key: n, sep: [] }), this.onKeyLine = !i.explicitKey;
3638
+ return;
3639
+ }
3640
+ break;
3641
+ }
3642
+ case "block-seq": {
3643
+ const i = s.items[s.items.length - 1];
3644
+ i.value ? s.items.push({ start: [], value: n }) : i.value = n;
3645
+ break;
3646
+ }
3647
+ case "flow-collection": {
3648
+ const i = s.items[s.items.length - 1];
3649
+ !i || i.value ? s.items.push({ start: [], key: n, sep: [] }) : i.sep ? i.value = n : Object.assign(i, { key: n, sep: [] });
3650
+ return;
3651
+ }
3652
+ /* istanbul ignore next should not happen */
3653
+ default:
3654
+ yield* this.pop(), yield* this.pop(n);
3655
+ }
3656
+ if ((s.type === "document" || s.type === "block-map" || s.type === "block-seq") && (n.type === "block-map" || n.type === "block-seq")) {
3657
+ const i = n.items[n.items.length - 1];
3658
+ i && !i.sep && !i.value && i.start.length > 0 && dn(i.start) === -1 && (n.indent === 0 || i.start.every((a) => a.type !== "comment" || a.indent < n.indent)) && (s.type === "document" ? s.end = i.start : s.items.push({ start: i.start }), n.items.splice(-1, 1));
3659
+ }
3660
+ }
3661
+ }
3662
+ *stream() {
3663
+ switch (this.type) {
3664
+ case "directive-line":
3665
+ yield { type: "directive", offset: this.offset, source: this.source };
3666
+ return;
3667
+ case "byte-order-mark":
3668
+ case "space":
3669
+ case "comment":
3670
+ case "newline":
3671
+ yield this.sourceToken;
3672
+ return;
3673
+ case "doc-mode":
3674
+ case "doc-start": {
3675
+ const t = {
3676
+ type: "document",
3677
+ offset: this.offset,
3678
+ start: []
3679
+ };
3680
+ this.type === "doc-start" && t.start.push(this.sourceToken), this.stack.push(t);
3681
+ return;
3682
+ }
3683
+ }
3684
+ yield {
3685
+ type: "error",
3686
+ offset: this.offset,
3687
+ message: `Unexpected ${this.type} token in YAML stream`,
3688
+ source: this.source
3689
+ };
3690
+ }
3691
+ *document(t) {
3692
+ if (t.value)
3693
+ return yield* this.lineEnd(t);
3694
+ switch (this.type) {
3695
+ case "doc-start": {
3696
+ dn(t.start) !== -1 ? (yield* this.pop(), yield* this.step()) : t.start.push(this.sourceToken);
3697
+ return;
3698
+ }
3699
+ case "anchor":
3700
+ case "tag":
3701
+ case "space":
3702
+ case "comment":
3703
+ case "newline":
3704
+ t.start.push(this.sourceToken);
3705
+ return;
3706
+ }
3707
+ const n = this.startBlockValue(t);
3708
+ n ? this.stack.push(n) : yield {
3709
+ type: "error",
3710
+ offset: this.offset,
3711
+ message: `Unexpected ${this.type} token in YAML document`,
3712
+ source: this.source
3713
+ };
3714
+ }
3715
+ *scalar(t) {
3716
+ if (this.type === "map-value-ind") {
3717
+ const n = Ze(this.peek(2)), s = Ie(n);
3718
+ let i;
3719
+ t.end ? (i = t.end, i.push(this.sourceToken), delete t.end) : i = [this.sourceToken];
3720
+ const a = {
3721
+ type: "block-map",
3722
+ offset: t.offset,
3723
+ indent: t.indent,
3724
+ items: [{ start: s, key: t, sep: i }]
3725
+ };
3726
+ this.onKeyLine = !0, this.stack[this.stack.length - 1] = a;
3727
+ } else
3728
+ yield* this.lineEnd(t);
3729
+ }
3730
+ *blockScalar(t) {
3731
+ switch (this.type) {
3732
+ case "space":
3733
+ case "comment":
3734
+ case "newline":
3735
+ t.props.push(this.sourceToken);
3736
+ return;
3737
+ case "scalar":
3738
+ if (t.source = this.source, this.atNewLine = !0, this.indent = 0, this.onNewLine) {
3739
+ let n = this.source.indexOf(`
3740
+ `) + 1;
3741
+ for (; n !== 0; )
3742
+ this.onNewLine(this.offset + n), n = this.source.indexOf(`
3743
+ `, n) + 1;
3744
+ }
3745
+ yield* this.pop();
3746
+ break;
3747
+ /* istanbul ignore next should not happen */
3748
+ default:
3749
+ yield* this.pop(), yield* this.step();
3750
+ }
3751
+ }
3752
+ *blockMap(t) {
3753
+ const n = t.items[t.items.length - 1];
3754
+ switch (this.type) {
3755
+ case "newline":
3756
+ if (this.onKeyLine = !1, n.value) {
3757
+ const s = "end" in n.value ? n.value.end : void 0;
3758
+ (Array.isArray(s) ? s[s.length - 1] : void 0)?.type === "comment" ? s?.push(this.sourceToken) : t.items.push({ start: [this.sourceToken] });
3759
+ } else n.sep ? n.sep.push(this.sourceToken) : n.start.push(this.sourceToken);
3760
+ return;
3761
+ case "space":
3762
+ case "comment":
3763
+ if (n.value)
3764
+ t.items.push({ start: [this.sourceToken] });
3765
+ else if (n.sep)
3766
+ n.sep.push(this.sourceToken);
3767
+ else {
3768
+ if (this.atIndentedComment(n.start, t.indent)) {
3769
+ const i = t.items[t.items.length - 2]?.value?.end;
3770
+ if (Array.isArray(i)) {
3771
+ tt(i, n.start), i.push(this.sourceToken), t.items.pop();
3772
+ return;
3773
+ }
3774
+ }
3775
+ n.start.push(this.sourceToken);
3776
+ }
3777
+ return;
3778
+ }
3779
+ if (this.indent >= t.indent) {
3780
+ const s = !this.onKeyLine && this.indent === t.indent, i = s && (n.sep || n.explicitKey) && this.type !== "seq-item-ind";
3781
+ let a = [];
3782
+ if (i && n.sep && !n.value) {
3783
+ const r = [];
3784
+ for (let o = 0; o < n.sep.length; ++o) {
3785
+ const c = n.sep[o];
3786
+ switch (c.type) {
3787
+ case "newline":
3788
+ r.push(o);
3789
+ break;
3790
+ case "space":
3791
+ break;
3792
+ case "comment":
3793
+ c.indent > t.indent && (r.length = 0);
3794
+ break;
3795
+ default:
3796
+ r.length = 0;
3797
+ }
3798
+ }
3799
+ r.length >= 2 && (a = n.sep.splice(r[1]));
3800
+ }
3801
+ switch (this.type) {
3802
+ case "anchor":
3803
+ case "tag":
3804
+ i || n.value ? (a.push(this.sourceToken), t.items.push({ start: a }), this.onKeyLine = !0) : n.sep ? n.sep.push(this.sourceToken) : n.start.push(this.sourceToken);
3805
+ return;
3806
+ case "explicit-key-ind":
3807
+ !n.sep && !n.explicitKey ? (n.start.push(this.sourceToken), n.explicitKey = !0) : i || n.value ? (a.push(this.sourceToken), t.items.push({ start: a, explicitKey: !0 })) : this.stack.push({
3808
+ type: "block-map",
3809
+ offset: this.offset,
3810
+ indent: this.indent,
3811
+ items: [{ start: [this.sourceToken], explicitKey: !0 }]
3812
+ }), this.onKeyLine = !0;
3813
+ return;
3814
+ case "map-value-ind":
3815
+ if (n.explicitKey)
3816
+ if (n.sep)
3817
+ if (n.value)
3818
+ t.items.push({ start: [], key: null, sep: [this.sourceToken] });
3819
+ else if (ce(n.sep, "map-value-ind"))
3820
+ this.stack.push({
3821
+ type: "block-map",
3822
+ offset: this.offset,
3823
+ indent: this.indent,
3824
+ items: [{ start: a, key: null, sep: [this.sourceToken] }]
3825
+ });
3826
+ else if (Yn(n.key) && !ce(n.sep, "newline")) {
3827
+ const r = Ie(n.start), o = n.key, c = n.sep;
3828
+ c.push(this.sourceToken), delete n.key, delete n.sep, this.stack.push({
3829
+ type: "block-map",
3830
+ offset: this.offset,
3831
+ indent: this.indent,
3832
+ items: [{ start: r, key: o, sep: c }]
3833
+ });
3834
+ } else a.length > 0 ? n.sep = n.sep.concat(a, this.sourceToken) : n.sep.push(this.sourceToken);
3835
+ else if (ce(n.start, "newline"))
3836
+ Object.assign(n, { key: null, sep: [this.sourceToken] });
3837
+ else {
3838
+ const r = Ie(n.start);
3839
+ this.stack.push({
3840
+ type: "block-map",
3841
+ offset: this.offset,
3842
+ indent: this.indent,
3843
+ items: [{ start: r, key: null, sep: [this.sourceToken] }]
3844
+ });
3845
+ }
3846
+ else
3847
+ n.sep ? n.value || i ? t.items.push({ start: a, key: null, sep: [this.sourceToken] }) : ce(n.sep, "map-value-ind") ? this.stack.push({
3848
+ type: "block-map",
3849
+ offset: this.offset,
3850
+ indent: this.indent,
3851
+ items: [{ start: [], key: null, sep: [this.sourceToken] }]
3852
+ }) : n.sep.push(this.sourceToken) : Object.assign(n, { key: null, sep: [this.sourceToken] });
3853
+ this.onKeyLine = !0;
3854
+ return;
3855
+ case "alias":
3856
+ case "scalar":
3857
+ case "single-quoted-scalar":
3858
+ case "double-quoted-scalar": {
3859
+ const r = this.flowScalar(this.type);
3860
+ i || n.value ? (t.items.push({ start: a, key: r, sep: [] }), this.onKeyLine = !0) : n.sep ? this.stack.push(r) : (Object.assign(n, { key: r, sep: [] }), this.onKeyLine = !0);
3861
+ return;
3862
+ }
3863
+ default: {
3864
+ const r = this.startBlockValue(t);
3865
+ if (r) {
3866
+ if (r.type === "block-seq") {
3867
+ if (!n.explicitKey && n.sep && !ce(n.sep, "newline")) {
3868
+ yield* this.pop({
3869
+ type: "error",
3870
+ offset: this.offset,
3871
+ message: "Unexpected block-seq-ind on same line with key",
3872
+ source: this.source
3873
+ });
3874
+ return;
3875
+ }
3876
+ } else s && t.items.push({ start: a });
3877
+ this.stack.push(r);
3878
+ return;
3879
+ }
3880
+ }
3881
+ }
3882
+ }
3883
+ yield* this.pop(), yield* this.step();
3884
+ }
3885
+ *blockSequence(t) {
3886
+ const n = t.items[t.items.length - 1];
3887
+ switch (this.type) {
3888
+ case "newline":
3889
+ if (n.value) {
3890
+ const s = "end" in n.value ? n.value.end : void 0;
3891
+ (Array.isArray(s) ? s[s.length - 1] : void 0)?.type === "comment" ? s?.push(this.sourceToken) : t.items.push({ start: [this.sourceToken] });
3892
+ } else
3893
+ n.start.push(this.sourceToken);
3894
+ return;
3895
+ case "space":
3896
+ case "comment":
3897
+ if (n.value)
3898
+ t.items.push({ start: [this.sourceToken] });
3899
+ else {
3900
+ if (this.atIndentedComment(n.start, t.indent)) {
3901
+ const i = t.items[t.items.length - 2]?.value?.end;
3902
+ if (Array.isArray(i)) {
3903
+ tt(i, n.start), i.push(this.sourceToken), t.items.pop();
3904
+ return;
3905
+ }
3906
+ }
3907
+ n.start.push(this.sourceToken);
3908
+ }
3909
+ return;
3910
+ case "anchor":
3911
+ case "tag":
3912
+ if (n.value || this.indent <= t.indent)
3913
+ break;
3914
+ n.start.push(this.sourceToken);
3915
+ return;
3916
+ case "seq-item-ind":
3917
+ if (this.indent !== t.indent)
3918
+ break;
3919
+ n.value || ce(n.start, "seq-item-ind") ? t.items.push({ start: [this.sourceToken] }) : n.start.push(this.sourceToken);
3920
+ return;
3921
+ }
3922
+ if (this.indent > t.indent) {
3923
+ const s = this.startBlockValue(t);
3924
+ if (s) {
3925
+ this.stack.push(s);
3926
+ return;
3927
+ }
3928
+ }
3929
+ yield* this.pop(), yield* this.step();
3930
+ }
3931
+ *flowCollection(t) {
3932
+ const n = t.items[t.items.length - 1];
3933
+ if (this.type === "flow-error-end") {
3934
+ let s;
3935
+ do
3936
+ yield* this.pop(), s = this.peek(1);
3937
+ while (s?.type === "flow-collection");
3938
+ } else if (t.end.length === 0) {
3939
+ switch (this.type) {
3940
+ case "comma":
3941
+ case "explicit-key-ind":
3942
+ !n || n.sep ? t.items.push({ start: [this.sourceToken] }) : n.start.push(this.sourceToken);
3943
+ return;
3944
+ case "map-value-ind":
3945
+ !n || n.value ? t.items.push({ start: [], key: null, sep: [this.sourceToken] }) : n.sep ? n.sep.push(this.sourceToken) : Object.assign(n, { key: null, sep: [this.sourceToken] });
3946
+ return;
3947
+ case "space":
3948
+ case "comment":
3949
+ case "newline":
3950
+ case "anchor":
3951
+ case "tag":
3952
+ !n || n.value ? t.items.push({ start: [this.sourceToken] }) : n.sep ? n.sep.push(this.sourceToken) : n.start.push(this.sourceToken);
3953
+ return;
3954
+ case "alias":
3955
+ case "scalar":
3956
+ case "single-quoted-scalar":
3957
+ case "double-quoted-scalar": {
3958
+ const i = this.flowScalar(this.type);
3959
+ !n || n.value ? t.items.push({ start: [], key: i, sep: [] }) : n.sep ? this.stack.push(i) : Object.assign(n, { key: i, sep: [] });
3960
+ return;
3961
+ }
3962
+ case "flow-map-end":
3963
+ case "flow-seq-end":
3964
+ t.end.push(this.sourceToken);
3965
+ return;
3966
+ }
3967
+ const s = this.startBlockValue(t);
3968
+ s ? this.stack.push(s) : (yield* this.pop(), yield* this.step());
3969
+ } else {
3970
+ const s = this.peek(2);
3971
+ if (s.type === "block-map" && (this.type === "map-value-ind" && s.indent === t.indent || this.type === "newline" && !s.items[s.items.length - 1].sep))
3972
+ yield* this.pop(), yield* this.step();
3973
+ else if (this.type === "map-value-ind" && s.type !== "flow-collection") {
3974
+ const i = Ze(s), a = Ie(i);
3975
+ pn(t);
3976
+ const r = t.end.splice(1, t.end.length);
3977
+ r.push(this.sourceToken);
3978
+ const o = {
3979
+ type: "block-map",
3980
+ offset: t.offset,
3981
+ indent: t.indent,
3982
+ items: [{ start: a, key: t, sep: r }]
3983
+ };
3984
+ this.onKeyLine = !0, this.stack[this.stack.length - 1] = o;
3985
+ } else
3986
+ yield* this.lineEnd(t);
3987
+ }
3988
+ }
3989
+ flowScalar(t) {
3990
+ if (this.onNewLine) {
3991
+ let n = this.source.indexOf(`
3992
+ `) + 1;
3993
+ for (; n !== 0; )
3994
+ this.onNewLine(this.offset + n), n = this.source.indexOf(`
3995
+ `, n) + 1;
3996
+ }
3997
+ return {
3998
+ type: t,
3999
+ offset: this.offset,
4000
+ indent: this.indent,
4001
+ source: this.source
4002
+ };
4003
+ }
4004
+ startBlockValue(t) {
4005
+ switch (this.type) {
4006
+ case "alias":
4007
+ case "scalar":
4008
+ case "single-quoted-scalar":
4009
+ case "double-quoted-scalar":
4010
+ return this.flowScalar(this.type);
4011
+ case "block-scalar-header":
4012
+ return {
4013
+ type: "block-scalar",
4014
+ offset: this.offset,
4015
+ indent: this.indent,
4016
+ props: [this.sourceToken],
4017
+ source: ""
4018
+ };
4019
+ case "flow-map-start":
4020
+ case "flow-seq-start":
4021
+ return {
4022
+ type: "flow-collection",
4023
+ offset: this.offset,
4024
+ indent: this.indent,
4025
+ start: this.sourceToken,
4026
+ items: [],
4027
+ end: []
4028
+ };
4029
+ case "seq-item-ind":
4030
+ return {
4031
+ type: "block-seq",
4032
+ offset: this.offset,
4033
+ indent: this.indent,
4034
+ items: [{ start: [this.sourceToken] }]
4035
+ };
4036
+ case "explicit-key-ind": {
4037
+ this.onKeyLine = !0;
4038
+ const n = Ze(t), s = Ie(n);
4039
+ return s.push(this.sourceToken), {
4040
+ type: "block-map",
4041
+ offset: this.offset,
4042
+ indent: this.indent,
4043
+ items: [{ start: s, explicitKey: !0 }]
4044
+ };
4045
+ }
4046
+ case "map-value-ind": {
4047
+ this.onKeyLine = !0;
4048
+ const n = Ze(t), s = Ie(n);
4049
+ return {
4050
+ type: "block-map",
4051
+ offset: this.offset,
4052
+ indent: this.indent,
4053
+ items: [{ start: s, key: null, sep: [this.sourceToken] }]
4054
+ };
4055
+ }
4056
+ }
4057
+ return null;
4058
+ }
4059
+ atIndentedComment(t, n) {
4060
+ return this.type !== "comment" || this.indent <= n ? !1 : t.every((s) => s.type === "newline" || s.type === "space");
4061
+ }
4062
+ *documentEnd(t) {
4063
+ this.type !== "doc-mode" && (t.end ? t.end.push(this.sourceToken) : t.end = [this.sourceToken], this.type === "newline" && (yield* this.pop()));
4064
+ }
4065
+ *lineEnd(t) {
4066
+ switch (this.type) {
4067
+ case "comma":
4068
+ case "doc-start":
4069
+ case "doc-end":
4070
+ case "flow-seq-end":
4071
+ case "flow-map-end":
4072
+ case "map-value-ind":
4073
+ yield* this.pop(), yield* this.step();
4074
+ break;
4075
+ case "newline":
4076
+ this.onKeyLine = !1;
4077
+ default:
4078
+ t.end ? t.end.push(this.sourceToken) : t.end = [this.sourceToken], this.type === "newline" && (yield* this.pop());
4079
+ }
4080
+ }
4081
+ }
4082
+ function za(e) {
4083
+ const t = e.prettyErrors !== !1;
4084
+ return { lineCounter: e.lineCounter || t && new qa() || null, prettyErrors: t };
4085
+ }
4086
+ function Ha(e, t = {}) {
4087
+ const { lineCounter: n, prettyErrors: s } = za(t), i = new Ka(n?.addNewLine), a = new Ba(t);
4088
+ let r = null;
4089
+ for (const o of a.compose(i.parse(e), !0, e.length))
4090
+ if (!r)
4091
+ r = o;
4092
+ else if (r.options.logLevel !== "silent") {
4093
+ r.errors.push(new Re(o.range.slice(0, 2), "MULTIPLE_DOCS", "Source contains multiple documents; please use YAML.parseAllDocuments()"));
4094
+ break;
4095
+ }
4096
+ return s && n && (r.errors.forEach(cn(e, n)), r.warnings.forEach(cn(e, n))), r;
4097
+ }
4098
+ function Va(e, t, n) {
4099
+ let s;
4100
+ const i = Ha(e, n);
4101
+ if (!i)
4102
+ return null;
4103
+ if (i.warnings.forEach((a) => Js(i.options.logLevel, a)), i.errors.length > 0) {
4104
+ if (i.options.logLevel !== "silent")
4105
+ throw i.errors[0];
4106
+ i.errors = [];
4107
+ }
4108
+ return i.toJS(Object.assign({ reviver: s }, n));
4109
+ }
4110
+ function Jn(e, t, n) {
4111
+ let s = null;
4112
+ if (typeof t == "function" || Array.isArray(t) ? s = t : n === void 0 && t && (n = t), typeof n == "string" && (n = n.length), typeof n == "number") {
4113
+ const i = Math.round(n);
4114
+ n = i < 1 ? void 0 : i > 8 ? { indent: 8 } : { indent: i };
4115
+ }
4116
+ if (e === void 0) {
4117
+ const { keepUndefined: i } = n ?? t ?? {};
4118
+ if (!i)
4119
+ return;
4120
+ }
4121
+ return Ys(e) && !s ? e.toString(n) : new Ke(e, s, n).toString(n);
4122
+ }
4123
+ function ur({ icon: e, size: t }) {
4124
+ const { Icon: n } = At().look;
4125
+ return /* @__PURE__ */ _.jsx(n, { icon: e, size: t });
4126
+ }
4127
+ function fr({ onClick: e }) {
4128
+ const { BackButton: t } = At();
4129
+ return /* @__PURE__ */ _.jsx(t, { onClick: e });
4130
+ }
4131
+ const mn = 50, Xa = 500;
4132
+ function dr({ app: e, networks: t, onCancel: n, onSubmit: s }) {
4133
+ const { t: i } = Zs(), [a] = ee.useForm(), r = At().look, o = !e, c = e ? Qt(e) : void 0, l = [...t.choices];
4134
+ for (const g of e ? [Qt(e), ...e.references ?? []] : [])
4135
+ l.some((p) => p.id === g.id) || l.push(g);
4136
+ const u = (g) => l.find((p) => p.id === g), f = ee.useWatch("network", a) ?? c?.id, d = () => {
4137
+ a.validateFields().then((g) => {
4138
+ const p = o && g.network ? u(g.network) : void 0;
4139
+ o && !p || s(
4140
+ {
4141
+ name: g.name.trim(),
4142
+ description: g.description ?? "",
4143
+ icon: g.icon,
4144
+ color: g.color,
4145
+ tags: g.tags ?? [],
4146
+ references: (g.references ?? []).filter((m) => m !== f).map(u).filter((m) => !!m)
4147
+ },
4148
+ p
4149
+ );
4150
+ });
4151
+ }, h = (g) => l.filter((p) => p.id !== g).map((p) => ({ value: p.id, label: p.name }));
4152
+ return /* @__PURE__ */ _.jsx(
4153
+ si,
4154
+ {
4155
+ open: !0,
4156
+ destroyOnHidden: !0,
4157
+ width: 640,
4158
+ title: i(o ? "workshopLab.list.create" : "workshopLab.list.editTitle"),
4159
+ okText: i(o ? "workshopLab.list.createOk" : "workshopLab.list.save"),
4160
+ onOk: d,
4161
+ onCancel: n,
4162
+ children: /* @__PURE__ */ _.jsxs(
4163
+ ee,
4164
+ {
4165
+ form: a,
4166
+ layout: "vertical",
4167
+ initialValues: {
4168
+ network: c?.id ?? t.initial,
4169
+ references: (e?.references ?? []).map((g) => g.id),
4170
+ name: e?.name ?? "",
4171
+ description: e?.description ?? "",
4172
+ icon: e?.icon ?? r.defaultIcon,
4173
+ color: e?.color ?? r.defaultColor,
4174
+ tags: e?.tags ?? []
4175
+ },
4176
+ children: [
4177
+ t.error && /* @__PURE__ */ _.jsx(
4178
+ ii,
4179
+ {
4180
+ type: "error",
4181
+ showIcon: !0,
4182
+ message: t.error,
4183
+ action: t.reload && /* @__PURE__ */ _.jsx(wt, { size: "small", loading: t.loading, onClick: t.reload, children: i("workshopLab.store.retry") })
4184
+ }
4185
+ ),
4186
+ /* @__PURE__ */ _.jsx(
4187
+ ee.Item,
4188
+ {
4189
+ label: i("workshopLab.list.networkLabel"),
4190
+ name: "network",
4191
+ extra: i(o ? "workshopLab.list.networkHint" : "workshopLab.list.networkFixed"),
4192
+ rules: [{ required: !0, message: i("workshopLab.list.networkPlaceholder") }],
4193
+ children: /* @__PURE__ */ _.jsx(
4194
+ Jt,
4195
+ {
4196
+ showSearch: !0,
4197
+ optionFilterProp: "label",
4198
+ disabled: !o,
4199
+ loading: t.loading,
4200
+ placeholder: i("workshopLab.list.networkPlaceholder"),
4201
+ options: h()
4202
+ }
4203
+ )
4204
+ }
4205
+ ),
4206
+ /* @__PURE__ */ _.jsx(
4207
+ ee.Item,
4208
+ {
4209
+ label: i("workshopLab.list.referencesLabel"),
4210
+ name: "references",
4211
+ extra: i("workshopLab.list.referencesHint"),
4212
+ children: /* @__PURE__ */ _.jsx(
4213
+ Jt,
4214
+ {
4215
+ mode: "multiple",
4216
+ allowClear: !0,
4217
+ showSearch: !0,
4218
+ optionFilterProp: "label",
4219
+ loading: t.loading,
4220
+ placeholder: i("workshopLab.list.referencesPlaceholder"),
4221
+ options: h(f)
4222
+ }
4223
+ )
4224
+ }
4225
+ ),
4226
+ /* @__PURE__ */ _.jsx(
4227
+ ee.Item,
4228
+ {
4229
+ label: i("workshopLab.list.nameLabel"),
4230
+ name: "name",
4231
+ rules: [
4232
+ { required: !0, whitespace: !0, message: i("workshopLab.list.nameRequired") },
4233
+ { max: mn }
4234
+ ],
4235
+ children: /* @__PURE__ */ _.jsx(
4236
+ Zt,
4237
+ {
4238
+ autoFocus: !0,
4239
+ maxLength: mn,
4240
+ showCount: !0,
4241
+ placeholder: i("workshopLab.list.namePlaceholder")
4242
+ }
4243
+ )
4244
+ }
4245
+ ),
4246
+ /* @__PURE__ */ _.jsxs(ai, { gutter: 16, children: [
4247
+ /* @__PURE__ */ _.jsx(en, { span: 12, children: /* @__PURE__ */ _.jsx(ee.Item, { label: i("workshopLab.list.iconLabel"), name: "icon", children: /* @__PURE__ */ _.jsx(r.IconSelect, {}) }) }),
4248
+ /* @__PURE__ */ _.jsx(en, { span: 12, children: /* @__PURE__ */ _.jsx(ee.Item, { label: i("workshopLab.list.colorLabel"), name: "color", children: /* @__PURE__ */ _.jsx(r.ColorSelect, {}) }) })
4249
+ ] }),
4250
+ /* @__PURE__ */ _.jsx(
4251
+ ee.Item,
4252
+ {
4253
+ label: i("workshopLab.list.tagsLabel"),
4254
+ name: "tags",
4255
+ rules: [{ validator: (g, p) => r.validateTags(p) }],
4256
+ children: /* @__PURE__ */ _.jsx(r.TagsSelect, {})
4257
+ }
4258
+ ),
4259
+ /* @__PURE__ */ _.jsx(ee.Item, { label: i("workshopLab.list.descriptionLabel"), name: "description", children: /* @__PURE__ */ _.jsx(
4260
+ Zt.TextArea,
4261
+ {
4262
+ rows: 3,
4263
+ maxLength: Xa,
4264
+ showCount: !0,
4265
+ placeholder: i("workshopLab.list.descriptionPlaceholder")
4266
+ }
4267
+ ) })
4268
+ ]
4269
+ }
4270
+ )
4271
+ }
4272
+ );
4273
+ }
4274
+ const Ga = (() => {
4275
+ const e = new Uint32Array(256);
4276
+ for (let t = 0; t < 256; t++) {
4277
+ let n = t;
4278
+ for (let s = 0; s < 8; s++) n = n & 1 ? 3988292384 ^ n >>> 1 : n >>> 1;
4279
+ e[t] = n >>> 0;
4280
+ }
4281
+ return e;
4282
+ })();
4283
+ function Zn(e) {
4284
+ let t = 4294967295;
4285
+ for (const n of e) t = Ga[(t ^ n) & 255] ^ t >>> 8;
4286
+ return (t ^ 4294967295) >>> 0;
4287
+ }
4288
+ const hn = 33;
4289
+ function Mt(e) {
4290
+ const t = new TextEncoder(), n = [], s = [];
4291
+ let i = 0;
4292
+ for (const [u, f] of Object.entries(e)) {
4293
+ const d = t.encode(u), h = typeof f == "string" ? t.encode(f) : f, g = Zn(h), p = new Uint8Array(30 + d.length + h.length), m = new DataView(p.buffer);
4294
+ m.setUint32(0, 67324752, !0), m.setUint16(4, 20, !0), m.setUint16(6, 2048, !0), m.setUint16(8, 0, !0), m.setUint16(12, hn, !0), m.setUint32(14, g, !0), m.setUint32(18, h.length, !0), m.setUint32(22, h.length, !0), m.setUint16(26, d.length, !0), p.set(d, 30), p.set(h, 30 + d.length), n.push(p);
4295
+ const w = new Uint8Array(46 + d.length), v = new DataView(w.buffer);
4296
+ v.setUint32(0, 33639248, !0), v.setUint16(4, 20, !0), v.setUint16(6, 20, !0), v.setUint16(8, 2048, !0), v.setUint16(10, 0, !0), v.setUint16(14, hn, !0), v.setUint32(16, g, !0), v.setUint32(20, h.length, !0), v.setUint32(24, h.length, !0), v.setUint16(28, d.length, !0), v.setUint32(42, i, !0), w.set(d, 46), s.push(w), i += p.length;
4297
+ }
4298
+ const a = s.reduce((u, f) => u + f.length, 0), r = new Uint8Array(22), o = new DataView(r.buffer);
4299
+ o.setUint32(0, 101010256, !0), o.setUint16(8, s.length, !0), o.setUint16(10, s.length, !0), o.setUint32(12, a, !0), o.setUint32(16, i, !0);
4300
+ const c = new Uint8Array(i + a + r.length);
4301
+ let l = 0;
4302
+ for (const u of [...n, ...s, r])
4303
+ c.set(u, l), l += u.length;
4304
+ return c;
4305
+ }
4306
+ function pr(e) {
4307
+ return new Blob([Mt(e)], { type: "application/zip" });
4308
+ }
4309
+ class le extends Error {
4310
+ constructor(t, n = "") {
4311
+ super(n ? `${t}: ${n}` : t), this.reason = t, this.entry = n;
4312
+ }
4313
+ reason;
4314
+ entry;
4315
+ }
4316
+ async function Wa(e) {
4317
+ const t = new ReadableStream({
4318
+ start(n) {
4319
+ n.enqueue(e.slice()), n.close();
4320
+ }
4321
+ }).pipeThrough(new DecompressionStream("deflate-raw"));
4322
+ return new Uint8Array(await new Response(t).arrayBuffer());
4323
+ }
4324
+ async function Qn(e) {
4325
+ const t = new DataView(e.buffer, e.byteOffset, e.byteLength), n = (l) => l + 4 <= e.length ? t.getUint32(l, !0) : -1, s = (l) => t.getUint16(l, !0);
4326
+ let i = -1;
4327
+ for (let l = e.length - 22; l >= Math.max(0, e.length - 22 - 65535); l--)
4328
+ if (n(l) === 101010256) {
4329
+ i = l;
4330
+ break;
4331
+ }
4332
+ if (i < 0) throw new le("notZip");
4333
+ const a = new TextDecoder(), r = s(i + 10);
4334
+ let o = n(i + 16);
4335
+ const c = [];
4336
+ for (let l = 0; l < r; l++) {
4337
+ if (o + 46 > e.length || n(o) !== 33639248) throw new le("damaged");
4338
+ const u = s(o + 10), f = n(o + 16), d = n(o + 20), h = n(o + 24), g = s(o + 28), p = n(o + 42), m = a.decode(e.subarray(o + 46, o + 46 + g));
4339
+ if (o += 46 + g + s(o + 30) + s(o + 32), m.endsWith("/")) continue;
4340
+ if (p + 30 > e.length || n(p) !== 67324752) throw new le("damaged", m);
4341
+ const w = p + 30 + s(p + 26) + s(p + 28);
4342
+ if (w + d > e.length) throw new le("damaged", m);
4343
+ const v = e.subarray(w, w + d);
4344
+ if (u !== 0 && u !== 8) throw new le("method", m);
4345
+ let $;
4346
+ try {
4347
+ $ = u === 0 ? v.slice() : await Wa(v);
4348
+ } catch {
4349
+ throw new le("damaged", m);
4350
+ }
4351
+ if ($.length !== h || Zn($) !== f) throw new le("damaged", m);
4352
+ c.push({ name: m, data: $ });
4353
+ }
4354
+ return c;
4355
+ }
4356
+ const Ya = "app.yaml", es = "components", gn = (e) => e.replace(/^x-/, "").replace(/[^A-Za-z0-9-]+/g, "-");
4357
+ function mr(e) {
4358
+ return e.draft ? { name: `${e.id}.app.yaml`, text: Jn(e.draft, { lineWidth: 0 }) } : null;
4359
+ }
4360
+ async function hr(e, t) {
4361
+ if (!e.draft) return null;
4362
+ const n = {
4363
+ [Ya]: Jn(e.draft, { lineWidth: 0 })
4364
+ }, s = /* @__PURE__ */ new Set(), i = (e.draft.components ?? []).map((r) => {
4365
+ let o = gn(r.type);
4366
+ for (let c = 2; s.has(o); c++) o = `${gn(r.type)}-${c}`;
4367
+ return s.add(o), { folder: o, id: r.package };
4368
+ }), a = await Promise.all(i.map(async ({ id: r }) => Qn(await t(r))));
4369
+ return i.forEach(({ folder: r }, o) => {
4370
+ for (const c of a[o])
4371
+ n[`${es}/${r}/${c.name}`] = c.data;
4372
+ }), { name: `${e.id}.zip`, bytes: Mt(n) };
4373
+ }
4374
+ function gr(e) {
4375
+ const t = e.files.find((n) => n.name === "manifest.json");
4376
+ if (!t) return null;
4377
+ try {
4378
+ const n = JSON.parse(new TextDecoder().decode(t.data));
4379
+ return typeof n == "object" && n !== null && Qs(n.type) ? n : null;
4380
+ } catch {
4381
+ return null;
4382
+ }
4383
+ }
4384
+ const Ja = (e) => e.length >= 4 && e[0] === 80 && e[1] === 75 && e[2] === 3 && e[3] === 4, Za = (e) => e.split("/").some((t) => t.startsWith(".") || t === "__MACOSX");
4385
+ async function Qa(e) {
4386
+ const t = (await Qn(e)).filter((a) => !Za(a.name)), n = t.filter((a) => /(^|\/|\.)app\.(ya?ml|json)$/i.test(a.name)).sort((a, r) => a.name.split("/").length - r.name.split("/").length)[0];
4387
+ if (!n) return null;
4388
+ const s = `${n.name.slice(0, n.name.lastIndexOf("/") + 1)}${es}/`, i = /* @__PURE__ */ new Map();
4389
+ for (const a of t) {
4390
+ if (!a.name.startsWith(s)) continue;
4391
+ const r = a.name.slice(s.length), o = r.indexOf("/");
4392
+ if (o <= 0) continue;
4393
+ const c = r.slice(0, o);
4394
+ i.set(c, [
4395
+ ...i.get(c) ?? [],
4396
+ { name: r.slice(o + 1), data: a.data }
4397
+ ]);
4398
+ }
4399
+ return {
4400
+ text: new TextDecoder().decode(n.data),
4401
+ packages: [...i].map(([a, r]) => ({ folder: a, files: r }))
4402
+ };
4403
+ }
4404
+ const yr = 64 * 1024 * 1024;
4405
+ class ts extends Error {
4406
+ constructor() {
4407
+ super("no app.yaml in the zip");
4408
+ }
4409
+ }
4410
+ async function br(e) {
4411
+ if (!Ja(new Uint8Array(await e.slice(0, 4).arrayBuffer())))
4412
+ return { text: await e.text(), packages: [], zip: !1 };
4413
+ const t = await Qa(new Uint8Array(await e.arrayBuffer()));
4414
+ if (!t) throw new ts();
4415
+ return { ...t, zip: !0 };
4416
+ }
4417
+ function wr(e, t) {
4418
+ return e instanceof ts ? t("workshopLab.zip.noApp") : e instanceof le ? e.reason === "notZip" ? t("workshopLab.zip.notZip") : e.reason === "method" ? t("workshopLab.zip.method", { entry: e.entry }) : e.entry ? t("workshopLab.zip.damagedEntry", { entry: e.entry }) : t("workshopLab.zip.damaged") : null;
4419
+ }
4420
+ async function vr(e, t) {
4421
+ const n = [], s = [];
4422
+ for (const { folder: i, files: a } of e)
4423
+ try {
4424
+ const r = Mt(Object.fromEntries(a.map((o) => [o.name, o.data])));
4425
+ n.push(await t(new Blob([r], { type: "application/zip" })));
4426
+ } catch (r) {
4427
+ s.push({ folder: i, error: r });
4428
+ }
4429
+ return { uploaded: n, failed: s };
4430
+ }
4431
+ function kr(e, t) {
4432
+ if (t.length === 0) return e;
4433
+ const n = new Map(t.map((a) => [a.type, a.id])), s = Array.isArray(e.components) ? e.components : [], i = new Set(s.map((a) => a.type));
4434
+ return {
4435
+ ...e,
4436
+ components: [
4437
+ ...s.map((a) => {
4438
+ const r = n.get(a.type);
4439
+ return r ? { ...a, package: r } : a;
4440
+ }),
4441
+ ...t.filter((a) => !i.has(a.type)).map((a) => ({ type: a.type, package: a.id, source: "upload" }))
4442
+ ]
4443
+ };
4444
+ }
4445
+ function er(e, t) {
4446
+ return t.find((n) => n.id === e.id) ?? t.find((n) => n.name === e.name);
4447
+ }
4448
+ async function $r(e, t, n, s) {
4449
+ let i;
4450
+ try {
4451
+ i = Va(e);
4452
+ } catch (f) {
4453
+ return { ok: !1, errors: [`不是有效的 YAML 或 JSON:${f.message}`] };
4454
+ }
4455
+ const a = i?.dependencies?.knowledgeNetwork, r = Array.isArray(i?.pages);
4456
+ if (!a?.id && !a?.name)
4457
+ return { ok: !1, errors: ["App Spec 没有写依赖的知识网络"], refit: r };
4458
+ const o = er({ id: a.id ?? "", name: a.name ?? "" }, t);
4459
+ if (!o)
4460
+ return {
4461
+ ok: !1,
4462
+ errors: [`这里没有应用依赖的知识网络「${a.name ?? a.id}」,请先导入或创建它`],
4463
+ refit: r
4464
+ };
4465
+ const c = ri({
4466
+ ...i,
4467
+ dependencies: { ...i.dependencies, knowledgeNetwork: { ...o } }
4468
+ }), [l] = await Promise.all([n(o), s?.(c)]), u = oi(c, l, { allowEmpty: !0 });
4469
+ return u.ok ? { ok: !0, spec: u.app, network: o } : { ok: !1, errors: u.errors, refit: r };
4470
+ }
4471
+ const W = (e) => typeof e == "object" && e !== null && !Array.isArray(e), Y = (e) => typeof e == "string" && e !== "" ? e : void 0, yn = (e) => W(e) && !!Y(e.box) && !!Y(e.tool);
4472
+ function ns(e) {
4473
+ const t = [], n = (a, r) => {
4474
+ const o = a.tool;
4475
+ yn(o) && t.push({
4476
+ kind: "tool",
4477
+ place: r,
4478
+ box: o.box,
4479
+ tool: o.tool,
4480
+ boxName: Y(o.boxName),
4481
+ toolName: Y(o.name),
4482
+ write: (c) => {
4483
+ a.tool = {
4484
+ ...o,
4485
+ box: c.box,
4486
+ tool: c.tool,
4487
+ boxName: c.boxName,
4488
+ name: c.toolName
4489
+ };
4490
+ }
4491
+ });
4492
+ }, s = (a, r) => {
4493
+ if (!W(a) || !yn(a.tool)) return;
4494
+ const o = a.tool, c = Y(a.name);
4495
+ t.push({
4496
+ kind: "tool",
4497
+ place: r(c ?? Y(o.toolName) ?? o.tool),
4498
+ box: o.box,
4499
+ tool: o.tool,
4500
+ boxName: Y(o.boxName),
4501
+ toolName: Y(o.toolName) ?? c,
4502
+ write: (l) => {
4503
+ a.tool = {
4504
+ ...o,
4505
+ box: l.box,
4506
+ tool: l.tool,
4507
+ boxName: l.boxName,
4508
+ toolName: l.toolName
4509
+ };
4510
+ }
4511
+ });
4512
+ };
4513
+ for (const a of Array.isArray(e.sources) ? e.sources : []) {
4514
+ if (!W(a)) continue;
4515
+ const r = Y(a.label) ?? String(a.id);
4516
+ W(a.model) && n(a.model, { in: "source", name: r });
4517
+ for (const o of Array.isArray(a.models) ? a.models : [])
4518
+ W(o) && n(o, { in: "trial", name: `${r}·${Y(o.label) ?? String(o.id)}` });
4519
+ }
4520
+ for (const a of Array.isArray(e.pages) ? e.pages : [])
4521
+ if (!(!W(a) || !W(a.regions)))
4522
+ for (const r of ui(a)) {
4523
+ if (!W(r) || !W(r.config)) continue;
4524
+ const o = r.config, c = `${a.title}·${Y(o.title) ?? r.id}`;
4525
+ if (r.type === "scheduleGantt")
4526
+ for (const l of Array.isArray(o.layers) ? o.layers : [])
4527
+ for (const u of W(l) && Array.isArray(l.ruleTools) ? l.ruleTools : [])
4528
+ s(u, (f) => ({ in: "component", name: `${c}·${f}` }));
4529
+ if (r.type === "agentChat" && o.provider === "mcp" && fi(o.agent)) {
4530
+ const l = o.agent;
4531
+ if (!l.mcp || !l.tool) continue;
4532
+ t.push({
4533
+ kind: "mcp",
4534
+ place: { in: "component", name: c },
4535
+ mcp: l.mcp,
4536
+ tool: l.tool,
4537
+ mcpName: Y(l.mcpName),
4538
+ write: (u) => {
4539
+ o.agent = { ...l, mcp: u.mcp, mcpName: u.mcpName };
4540
+ }
4541
+ });
4542
+ }
4543
+ }
4544
+ const i = e.scheduleModel;
4545
+ for (const a of W(i) && Array.isArray(i.tasks) ? i.tasks : [])
4546
+ for (const r of W(a) && Array.isArray(a.rules) ? a.rules : [])
4547
+ s(r, (o) => ({ in: "schedule", name: o }));
4548
+ return t;
4549
+ }
4550
+ const Sr = (e) => ns(e).length;
4551
+ async function tr(e, t) {
4552
+ const n = (l, u) => ({
4553
+ box: l.boxId,
4554
+ tool: u.toolId,
4555
+ boxName: l.boxName,
4556
+ toolName: u.toolName
4557
+ }), s = t.boxes.find((l) => l.boxId === e.box), i = s && (await t.toolsOf(s.boxId)).find((l) => l.toolId === e.tool);
4558
+ if (s && i) return { status: "same", here: n(s, i) };
4559
+ const a = e.toolName;
4560
+ if (!a) return { status: "missing" };
4561
+ const r = async (l) => pi(
4562
+ (await Promise.all(
4563
+ l.map(
4564
+ async (u) => (await t.toolsOf(u.boxId)).map((f) => ({ box: u, tool: f }))
4565
+ )
4566
+ )).flat(),
4567
+ a
4568
+ ), o = e.boxName ? await r(t.boxes.filter((l) => l.boxName === e.boxName)) : [];
4569
+ if (o.length > 0) return { status: "moved", here: n(o[0].box, o[0].tool) };
4570
+ const c = await r(t.boxes);
4571
+ return c.length === 1 ? { status: "moved", here: n(c[0].box, c[0].tool) } : { status: c.length > 1 ? "ambiguous" : "missing" };
4572
+ }
4573
+ async function nr(e, t) {
4574
+ let n = t.find((i) => i.id === e.mcp);
4575
+ if (!n && e.mcpName) {
4576
+ const i = t.filter((a) => a.name === e.mcpName);
4577
+ if (i.length > 1) return { status: "ambiguous" };
4578
+ n = i[0];
4579
+ }
4580
+ if (!n) return { status: "missing" };
4581
+ const s = await di(n.id).catch(() => null);
4582
+ return s && !s.some((i) => i.name === e.tool) ? { status: "missing" } : {
4583
+ status: n.id === e.mcp ? "same" : "moved",
4584
+ here: { mcp: n.id, mcpName: n.name }
4585
+ };
4586
+ }
4587
+ async function ss(e) {
4588
+ const t = ns(e), n = t.filter((o) => o.kind === "tool"), s = t.filter((o) => o.kind === "mcp"), i = n.length > 0 ? await li().catch(() => null) : null, a = s.length > 0 ? await ci().catch(() => null) : null, r = await Promise.all(
4589
+ t.map(
4590
+ (o) => o.kind === "tool" ? i ? tr(o, i) : Promise.resolve(null) : a ? nr(o, a) : Promise.resolve(null)
4591
+ )
4592
+ );
4593
+ return t.map((o, c) => ({ use: o, found: r[c] }));
4594
+ }
4595
+ const sr = (e) => e.kind === "tool" ? `${e.boxName ?? e.box} / ${e.toolName ?? e.tool}` : `${e.mcpName ?? e.mcp} / ${e.tool}`, ir = (e, t) => "box" in e ? `${e.boxName} / ${e.toolName}` : `${e.mcpName} / ${t.tool}`;
4596
+ function bn(e) {
4597
+ const t = /* @__PURE__ */ new Map();
4598
+ for (const { key: n, note: s } of e) {
4599
+ const i = t.get(n);
4600
+ i ? i.places.push(...s.places) : t.set(n, s);
4601
+ }
4602
+ return [...t.values()];
4603
+ }
4604
+ async function Nr(e) {
4605
+ mi();
4606
+ const t = structuredClone(e), n = await ss(t), s = [], i = [];
4607
+ for (const { use: a, found: r } of n) {
4608
+ const o = `${a.kind}:${a.kind === "tool" ? a.box : a.mcp}/${a.tool}`;
4609
+ r?.status === "moved" ? (a.write(r.here), s.push({ key: o, note: { name: ir(r.here, a), places: [a.place] } })) : r && r.status !== "same" && i.push({
4610
+ key: o,
4611
+ note: { name: sr(a), places: [a.place], ambiguous: r.status === "ambiguous" }
4612
+ });
4613
+ }
4614
+ return {
4615
+ spec: s.length > 0 ? t : e,
4616
+ checked: n.length,
4617
+ moved: bn(s),
4618
+ missing: bn(i),
4619
+ unchecked: n.some(({ found: a }) => a === null)
4620
+ };
4621
+ }
4622
+ async function Ir(e) {
4623
+ const t = structuredClone(e);
4624
+ let n = !1;
4625
+ for (const { use: s, found: i } of await ss(t)) {
4626
+ if (i?.status !== "same") continue;
4627
+ const a = i.here;
4628
+ ("box" in a ? s.kind === "tool" && s.boxName === a.boxName && s.toolName === a.toolName : s.kind === "mcp" && s.mcpName === a.mcpName) || (s.write(a), n = !0);
4629
+ }
4630
+ return n ? t : e;
4631
+ }
4632
+ const is = (e, t, n) => n(e.map((s) => t(`workshopLab.importTools.place.${s.in}`, { name: s.name }))), ar = (e, t, n) => t(e.ambiguous ? "workshopLab.importTools.ambiguousItem" : "workshopLab.importTools.missingItem", {
4633
+ name: e.name,
4634
+ places: is(e.places, t, n)
4635
+ });
4636
+ function Tr(e, t, n) {
4637
+ return [
4638
+ ...e.moved.map(
4639
+ (s) => t("workshopLab.importTools.moved", {
4640
+ name: s.name,
4641
+ places: is(s.places, t, n)
4642
+ })
4643
+ ),
4644
+ ...e.missing.length > 0 ? [
4645
+ t("workshopLab.importTools.missing", { count: e.missing.length }),
4646
+ ...e.missing.map((s) => ar(s, t, n)),
4647
+ t("workshopLab.importTools.missingHint")
4648
+ ] : [],
4649
+ ...e.unchecked ? [t("workshopLab.importTools.unchecked")] : []
4650
+ ];
4651
+ }
4652
+ export {
4653
+ dr as A,
4654
+ fr as B,
4655
+ cr as R,
4656
+ Cn as U,
4657
+ ar as a,
4658
+ ur as b,
4659
+ Ir as c,
4660
+ mr as d,
4661
+ hr as e,
4662
+ gr as f,
4663
+ yr as g,
4664
+ Sr as h,
4665
+ $r as i,
4666
+ pr as j,
4667
+ Nr as m,
4668
+ Va as p,
4669
+ br as r,
4670
+ Jn as s,
4671
+ Tr as t,
4672
+ vr as u,
4673
+ kr as w,
4674
+ wr as z
4675
+ };