@pstdio/workbench 0.11.4 → 0.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2400 +1,2052 @@
1
- import { jsxs as ge, jsx as N } from "react/jsx-runtime";
2
- import { useRef as v, useState as we, useEffect as K, createElement as D } from "react";
3
- import { host as et } from "rimless";
4
- import { ALWAYS_AVAILABLE_WEBVIEW_CAPABILITIES as tt, WEBVIEW_HOST_CAPABILITY_VERSION as ce, WEBVIEW_HOST_CAPABILITIES as nt, WEBVIEW_SCOPED_DECLARABLE_CAPABILITIES as ot, resourceKey as V, isLocalizedString as st, matchesResourceWhen as rt } from "@pstdio/sdk/extensions";
5
- import { b as it, W as _, a as at } from "./workspaces-B9HZHIbz.js";
6
- import { renderBadgeListDisplay as dt } from "@pstdio/ui/kanban-renderer";
7
- import { w as ct } from "./workbench-menu-paths-B_QJzcNU.js";
8
- const lt = (e) => typeof e == "object" && e !== null && "$l10n" in e && typeof e.$l10n == "string", mt = new Set(nt), ut = new Set(ot), Te = (e) => mt.has(e), Pe = (e) => ut.has(e), pt = (e) => {
9
- const [t = "", n] = e.split("@"), o = t.indexOf(":"), r = o === -1 ? t : t.slice(0, o), s = o === -1 ? void 0 : t.slice(o + 1), i = n === void 0 ? ce : Number(n);
10
- return {
11
- capability: e,
12
- name: r,
13
- scope: s,
14
- version: i
15
- };
16
- }, bt = (e) => Pe(e.name) ? !!e.scope : e.scope === void 0, L = (e) => ({
17
- capability: e,
18
- code: "unsupported_webview_capability",
19
- message: `Unsupported webview capability: ${e}`,
20
- severity: "error"
21
- }), ft = (e, t, n) => ({
22
- capability: e,
23
- code: "unsupported_webview_capability_version",
24
- message: `Unsupported webview capability version: ${t}@${n.toString()} (supported: ${ce.toString()})`,
25
- severity: "error"
26
- }), Ie = (e) => ({
27
- capability: e,
28
- code: "undeclared_webview_capability",
29
- message: `Webview did not declare host capability: ${e}`,
30
- severity: "error"
31
- }), ht = (e, t = {}) => {
32
- const n = [], o = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Map();
33
- for (const s of tt)
34
- t[s] && o.add(s);
35
- for (const s of e ?? []) {
36
- const i = pt(s);
37
- if (!Te(i.name) || !bt(i)) {
38
- n.push(L(s));
39
- continue;
40
- }
41
- if (i.version !== ce) {
42
- n.push(ft(s, i.name, i.version));
43
- continue;
44
- }
45
- if (!t[i.name]) {
46
- n.push(L(s));
47
- continue;
48
- }
49
- if (i.scope === void 0) {
50
- o.add(i.name);
51
- continue;
52
- }
53
- const a = r.get(i.name) ?? /* @__PURE__ */ new Set();
54
- a.add(i.scope), r.set(i.name, a);
55
- }
56
- return {
57
- allowed: o,
58
- allowedScopes: r,
59
- diagnostics: n
60
- };
61
- }, gt = (e) => {
62
- const t = e.params;
63
- return typeof t?.mount == "string" && t.mount.length > 0 ? t.mount : void 0;
64
- }, wt = (e) => {
65
- const {
66
- allowed: t,
67
- allowedScopes: n,
68
- diagnostics: o
69
- } = ht(e.declaredCapabilities, e.capabilities), r = (i) => {
70
- e.onDiagnostic?.(i);
71
- }, s = (i) => (r(i), new Error(i.message));
72
- return {
73
- diagnostics: o,
74
- async call(i) {
75
- if (!Te(i.method)) throw s(L(i.method));
76
- if (Pe(i.method)) {
77
- const d = gt(i);
78
- if (!d) throw s(L(i.method));
79
- if (!n.get(i.method)?.has(d))
80
- throw s(Ie(`${i.method}:${d}`));
81
- } else if (!t.has(i.method))
82
- throw s(Ie(i.method));
83
- const a = e.capabilities[i.method];
84
- if (!a) throw s(L(i.method));
85
- return await a(i.params);
86
- }
87
- };
88
- }, It = (e) => typeof e == "object" && e !== null, ye = (e) => {
89
- try {
90
- const t = JSON.stringify(e);
91
- if (typeof t == "string" && t.length > 0) return t;
92
- } catch {
93
- }
94
- try {
95
- return String(e);
96
- } catch {
97
- return "Unknown error";
98
- }
99
- }, yt = (e) => {
100
- if (e instanceof Error) return {
101
- message: e.message,
102
- stack: e.stack
103
- };
104
- if (typeof e == "string") return {
105
- message: e
106
- };
107
- if (It(e)) {
108
- const t = typeof e.message == "string" ? e.message : null, n = typeof e.stack == "string" ? e.stack : void 0;
109
- return t ? n ? {
110
- message: t,
111
- stack: n
112
- } : {
113
- message: t
114
- } : {
115
- message: ye(e)
116
- };
117
- }
118
- return e == null ? {
119
- message: "Unknown error"
120
- } : {
121
- message: ye(e)
122
- };
123
- }, oe = () => {
124
- if (typeof document > "u") return {};
125
- const e = getComputedStyle(document.documentElement), t = {};
126
- for (let n = 0; n < e.length; n += 1) {
127
- const o = e.item(n);
128
- o.startsWith("--chakra-") && (t[o] = e.getPropertyValue(o).trim());
129
- }
130
- return t;
131
- }, se = (e) => {
132
- if (typeof document > "u") return e;
133
- const t = document.documentElement.getAttribute("data-theme");
134
- if (t === "dark" || t === "light") return t;
135
- const n = document.documentElement.getAttribute("data-color-mode");
136
- return n === "dark" || n === "light" ? n : e;
137
- }, vt = {
138
- border: 0,
139
- display: "block",
140
- flex: "1 1 0%",
141
- height: "100%",
142
- minHeight: 0,
143
- width: "100%"
144
- }, kt = {
145
- display: "flex",
146
- height: "100%",
147
- minHeight: 0,
148
- position: "relative",
149
- width: "100%"
150
- }, xt = {
151
- alignItems: "center",
152
- background: "rgba(255, 255, 255, 0.92)",
153
- color: "#7a1f12",
154
- display: "flex",
155
- inset: 0,
156
- justifyContent: "center",
157
- padding: "24px",
158
- position: "absolute",
159
- textAlign: "center",
160
- zIndex: 1
161
- }, Rt = "allow-scripts allow-forms allow-popups", Et = (e) => {
162
- const {
163
- view: t,
164
- props: n,
165
- theme: o,
166
- capabilities: r,
167
- hostEvents: s,
168
- onReady: i,
169
- onError: a,
170
- onDiagnostics: d,
171
- title: m
172
- } = e, l = v(null), c = v(null), p = v(null), u = v(!1), g = v(null), x = v(n), A = v(o), T = v(r), W = v(s), z = v(t.webview.capabilities), te = v(i), j = v(a), f = v(d), [k, w] = we(null), [P, Q] = we(0);
173
- return x.current = n, A.current = o, T.current = r, W.current = s, z.current = t.webview.capabilities, te.current = i, j.current = a, f.current = d, K(() => {
174
- const h = l.current;
175
- if (!h) return;
176
- const C = () => {
177
- c.current === h ? Q((y) => y + 1) : c.current = h;
178
- };
179
- h.addEventListener("load", C);
180
- const S = () => h.removeEventListener("load", C), F = `${P}
181
- ${t.webview.runtimeUrl}
182
- ${t.webview.moduleUrl}`;
183
- if (g.current === F) return S;
184
- g.current = F;
185
- const Ye = t.webview.styles, Xe = t.webview.moduleUrl, fe = (y) => {
186
- y.length > 0 && f.current?.(y);
187
- }, he = () => wt({
188
- capabilities: T.current ?? {},
189
- declaredCapabilities: z.current,
190
- onDiagnostic: (y) => fe([y])
191
- });
192
- fe(he().diagnostics);
193
- const Je = {
194
- ready: () => {
195
- },
196
- runtimeError: (y) => {
197
- w(y.message), j.current?.(y);
198
- },
199
- call: async (y) => await he().call(y)
200
- };
201
- return (() => {
202
- u.current = !1, p.current = null;
203
- const y = et.connect(h, Je);
204
- h.contentWindow?.location.replace(t.webview.runtimeUrl), y.then(async (ne) => {
205
- if (l.current !== h) return;
206
- const M = ne.remote;
207
- p.current = M, W.current?.bind((Ze) => M.hostEvent?.(Ze)), await M.init({
208
- moduleUrl: Xe,
209
- styles: Ye,
210
- props: x.current,
211
- theme: se(A.current),
212
- themeVariables: oe(),
213
- extensionId: t.extensionId
214
- }), l.current === h && (u.current = !0, w(null), te.current?.());
215
- }).catch((ne) => {
216
- if (l.current !== h) return;
217
- const M = yt(ne);
218
- w(M.message), j.current?.(M);
219
- });
220
- })(), S;
221
- }, [P, t.extensionId, t.webview.runtimeUrl, t.webview.moduleUrl, t.webview.styles]), K(() => {
222
- const h = p.current;
223
- if (!(!h || !s))
224
- return s.bind((C) => h.hostEvent?.(C)), () => s.unbind();
225
- }, [s]), K(() => {
226
- u.current && p.current?.propsUpdate({
227
- props: n
228
- });
229
- }, [n]), K(() => {
230
- u.current && p.current?.themeUpdate({
231
- theme: se(o),
232
- variables: oe()
233
- });
234
- }, [o]), K(() => {
235
- if (typeof window > "u" || typeof MutationObserver > "u") return;
236
- let h = null;
237
- const C = () => {
238
- h !== null && cancelAnimationFrame(h), h = requestAnimationFrame(() => {
239
- h = null, u.current && p.current?.themeUpdate({
240
- theme: se(A.current),
241
- variables: oe()
242
- });
243
- });
244
- }, S = new MutationObserver(C), F = {
245
- attributeFilter: ["class", "data-color-mode", "data-theme", "style"],
246
- attributes: !0
247
- };
248
- return S.observe(document.documentElement, F), S.observe(document.body, F), () => {
249
- S.disconnect(), h !== null && cancelAnimationFrame(h);
250
- };
251
- }, []), /* @__PURE__ */ ge("div", { style: kt, children: [
252
- k ? /* @__PURE__ */ N("div", { role: "alert", style: xt, children: /* @__PURE__ */ ge("div", { children: [
253
- /* @__PURE__ */ N("strong", { children: "Extension view failed to load." }),
254
- /* @__PURE__ */ N("div", { children: k })
255
- ] }) }) : null,
256
- /* @__PURE__ */ N(
257
- "iframe",
258
- {
259
- ref: l,
260
- title: m ?? t.label,
261
- allow: "fullscreen",
262
- allowFullScreen: !0,
263
- sandbox: Rt,
264
- style: {
265
- ...vt,
266
- colorScheme: o
267
- },
268
- onError: () => {
269
- const h = `Failed to load extension runtime at ${t.webview.runtimeUrl}`;
270
- w(h), j.current?.({
271
- message: h
272
- });
273
- }
274
- },
275
- `${P}
276
- ${t.webview.runtimeUrl}
277
- ${t.webview.moduleUrl}`
278
- )
279
- ] });
280
- }, At = () => {
281
- let e = null;
282
- const t = [], n = /* @__PURE__ */ new Set();
283
- return {
284
- emit(o) {
285
- e ? e(o) : t.push(o);
286
- },
287
- bind(o) {
288
- for (e = o; t.length > 0; ) o(t.shift());
289
- },
290
- onDisconnect(o) {
291
- return n.add(o), () => n.delete(o);
292
- },
293
- unbind() {
294
- e = null;
295
- for (const o of n) o();
296
- }
297
- };
298
- }, Ct = "terminal.session", St = (e) => {
299
- const {
300
- terminal: t,
301
- hostEvents: n
302
- } = e, o = (r) => {
303
- n.emit({
304
- scope: Ct,
305
- payload: r
306
- });
307
- };
308
- return async (r) => {
309
- const s = r;
310
- switch (s.operation) {
311
- case "open": {
312
- const {
313
- sessionId: i
314
- } = await t.open({
315
- request: s.request
316
- });
317
- return {
318
- operation: "open",
319
- sessionId: i
320
- };
321
- }
322
- case "write":
323
- return t.write({
324
- sessionId: s.sessionId,
325
- data: s.data
326
- }), {
327
- operation: "write",
328
- accepted: !0
329
- };
330
- case "resize":
331
- return t.resize({
332
- sessionId: s.sessionId,
333
- cols: s.cols,
334
- rows: s.rows
335
- }), {
336
- operation: "resize",
337
- accepted: !0
338
- };
339
- case "kill":
340
- return await t.kill({
341
- sessionId: s.sessionId,
342
- signal: s.signal
343
- }), {
344
- operation: "kill",
345
- accepted: !0
346
- };
347
- case "subscribe": {
348
- const {
349
- sessionId: i
350
- } = s;
351
- let a = () => {
352
- }, d = () => {
353
- }, m = !1;
354
- const l = () => {
355
- m || (m = !0, a(), d());
356
- };
357
- return a = t.subscribe(i, {
358
- onData: (c) => o({
359
- sessionId: i,
360
- kind: "data",
361
- chunk: c
362
- }),
363
- onExit: (c) => {
364
- o({
365
- sessionId: i,
366
- kind: "exit",
367
- code: c.code,
368
- signal: c.signal
369
- }), l();
370
- }
371
- }), d = n.onDisconnect(l), {
372
- operation: "subscribe",
373
- accepted: !0
374
- };
375
- }
376
- }
377
- };
378
- }, Tt = (e) => {
379
- if (typeof document > "u") return;
380
- const t = new KeyboardEvent("keydown", {
381
- ...e,
382
- bubbles: !0,
383
- cancelable: !0
384
- });
385
- document.dispatchEvent(t);
386
- }, Pt = (e) => ({
387
- ...e.placement?.placementIdentity ? {
388
- "placement.close": (t) => {
389
- if (t !== void 0 && (typeof t != "object" || t === null || Array.isArray(t) || Object.keys(t).length > 0))
390
- throw new Error("placement.close takes no parameters; the host supplies the calling placement.");
391
- e.workbench.closePlacement(e.placement.placementIdentity);
392
- }
393
- } : {},
394
- "commands.execute": (t) => {
395
- const n = t;
396
- return e.workbench.commands.executeCommand(n.commandId, n.params);
397
- },
398
- "navigation.open": (t) => {
399
- const n = t;
400
- if (!n.target) throw new Error("navigation.open requires a target.");
401
- return e.workbench.navigation.openTarget(n.target);
402
- },
403
- "notification.show": (t) => {
404
- const n = t;
405
- return e.workbench.notifications.show({
406
- level: n.level,
407
- message: n.message,
408
- title: n.title
409
- });
410
- },
411
- "preferences.get": (t) => {
412
- const n = t;
413
- return e.workbench.preferences.getValue(n.name, n.scope);
414
- },
415
- "preferences.set": (t) => {
416
- const n = t;
417
- return e.workbench.preferences.setValue(n.name, n.value, n.scope ?? {
418
- scope: "user"
419
- }), {
420
- name: n.name,
421
- value: n.value
422
- };
423
- },
424
- "host.dispatchKeyboardEvent": (t) => (e.dispatchKeyboardEvent ?? Tt)(t),
425
- ...e.hostEvents ? {
426
- "terminal.session": St({
427
- terminal: e.workbench.terminal,
428
- hostEvents: e.hostEvents
429
- })
430
- } : {}
431
- }), jt = (e, t) => {
432
- for (const n of t)
433
- console.warn(`[workbench.webview:${e}] ${n.code}/${n.capability}: ${n.message}`);
434
- }, $t = (e, t) => {
435
- console.error(`[workbench.webview:${e}] runtime error: ${t}`);
436
- }, Ht = () => "light", ve = /* @__PURE__ */ new WeakMap(), Wt = (e, t) => {
437
- let n = ve.get(e);
438
- n || (n = /* @__PURE__ */ new Map(), ve.set(e, n));
439
- const o = t.instanceId;
440
- let r = n.get(o);
441
- return r || (r = At(), n.set(o, r)), r;
442
- }, Mt = (e) => {
443
- const {
444
- context: t,
445
- createHostCapabilities: n,
446
- createProps: o,
447
- createTheme: r = Ht,
448
- ownerId: s,
449
- title: i,
450
- webview: a
451
- } = e;
452
- return /* @__PURE__ */ N(Et, { view: {
453
- extensionId: s ?? "workbench",
454
- id: t.webviewId,
455
- label: a.title ?? i,
456
- webview: {
457
- capabilities: a.capabilities,
458
- moduleUrl: a.moduleUrl,
459
- runtimeUrl: a.runtimeUrl,
460
- styles: a.styles ?? []
461
- }
462
- }, props: o(t), theme: r(t), capabilities: n(t), hostEvents: t.hostEvents, onDiagnostics: (d) => jt(t.webviewId, d), onError: (d) => $t(t.webviewId, d.message) });
463
- }, b = (e, t = "") => e === void 0 ? t : lt(e) ? e.default ?? e.$l10n : e, R = (e) => !!(e && typeof e == "object" && !Array.isArray(e)), J = (e, t) => R(e) && e.kind === t && typeof e.id == "string", je = (e) => R(e) && typeof e.type == "string" && typeof e.id == "string", $e = (e) => e === void 0 || e === "preview" || e === "pin", le = (e, t = /* @__PURE__ */ new Set()) => {
464
- if (!R(e) || e.kind !== "page" || !J(e.page, "page") || t.has(e) || e.resource !== void 0 && !je(e.resource) || e.section !== void 0 && !R(e.section) || !$e(e.open)) return !1;
465
- if (e.parent === void 0) return !0;
466
- const n = new Set(t);
467
- return n.add(e), le(e.parent, n);
468
- }, He = (e) => {
469
- if (!R(e) || e.kind !== "panel" || !R(e.panel)) return !1;
470
- const t = e.panel;
471
- return (J(t, "placement") || t.kind === "page-slot" && J(t.page, "page") && typeof t.id == "string") && (e.resource === void 0 || je(e.resource)) && $e(e.open);
472
- }, Bt = (e) => R(e) ? e.kind === "page" ? le(e) : e.kind === "panel" ? He(e) : e.kind === "href" ? typeof e.href == "string" : e.kind === "command" && R(e.target) && J(e.target.command, "command") && (e.target.params === void 0 || R(e.target.params)) : !1, We = (e) => Bt(e) ? !0 : !R(e) || e.kind !== "compound" || !Array.isArray(e.targets) || e.targets.length === 0 ? !1 : e.targets.every((t) => le(t) || He(t)), Vt = (e, t) => {
473
- const n = t.commandTargetOf?.(e);
474
- if (n) return n;
475
- const o = e.target.command, r = o.extensionId ?? t.extensionId;
476
- return {
477
- kind: "command",
478
- commandId: t.commandIdOf?.(o) ?? (r && r !== "pstdio" ? `${r}.command.${o.id}` : o.id),
479
- args: e.target.params
480
- };
481
- }, ae = (e, t) => e.extensionId !== void 0 || t === void 0 ? e : {
482
- ...e,
483
- extensionId: t
484
- }, Me = (e, t) => ({
485
- ...e,
486
- page: ae(e.page, t),
487
- ...e.parent ? {
488
- parent: Me(e.parent, t)
489
- } : {}
490
- });
491
- function H(e, t = {}) {
492
- return e.kind === "command" ? Vt(e, t) : e.kind === "href" ? e : e.kind === "page" ? Me(e, t.extensionId) : e.kind === "panel" ? {
493
- ...e,
494
- panel: e.panel.kind === "page-slot" ? {
495
- ...e.panel,
496
- page: ae(e.panel.page, t.extensionId)
497
- } : ae(e.panel, t.extensionId)
498
- } : {
499
- kind: "compound",
500
- targets: e.targets.map((n) => H(n, t))
501
- };
1
+ import { y as e } from "./workbench-renderers-BK6g8mG_.js";
2
+ import { b as t, c as n, rt as r } from "./react-C8jwnIWT.js";
3
+ import { ALWAYS_AVAILABLE_WEBVIEW_CAPABILITIES as i, WEBVIEW_HOST_CAPABILITIES as a, WEBVIEW_HOST_CAPABILITY_VERSION as o, WEBVIEW_SCOPED_DECLARABLE_CAPABILITIES as s, isLocalizedString as c, isNavigationTarget as l, matchesResourceWhen as u, qualifyNavigationTarget as d, resourceKey as f } from "@pstdio/sdk/extensions";
4
+ import { jsx as p, jsxs as m } from "react/jsx-runtime";
5
+ import { createElement as h, useEffect as g, useRef as _, useState as ee } from "react";
6
+ import { renderBadgeListDisplay as v } from "@pstdio/ui/kanban-renderer";
7
+ import { host as te } from "rimless";
8
+ //#region ../pstdio-api-contracts/src/extension-kernel/l10n.ts
9
+ var y = (e) => typeof e == "object" && !!e && "$l10n" in e && typeof e.$l10n == "string", b = new Set(a), x = new Set(s), S = (e) => b.has(e), C = (e) => x.has(e), w = (e) => {
10
+ let [t = "", n] = e.split("@"), r = t.indexOf(":");
11
+ return {
12
+ capability: e,
13
+ name: r === -1 ? t : t.slice(0, r),
14
+ scope: r === -1 ? void 0 : t.slice(r + 1),
15
+ version: n === void 0 ? o : Number(n)
16
+ };
17
+ }, T = (e) => C(e.name) ? !!e.scope : e.scope === void 0, E = (e) => ({
18
+ capability: e,
19
+ code: "unsupported_webview_capability",
20
+ message: `Unsupported webview capability: ${e}`,
21
+ severity: "error"
22
+ }), D = (e, t, n) => ({
23
+ capability: e,
24
+ code: "unsupported_webview_capability_version",
25
+ message: `Unsupported webview capability version: ${t}@${n.toString()} (supported: ${o.toString()})`,
26
+ severity: "error"
27
+ }), O = (e) => ({
28
+ capability: e,
29
+ code: "undeclared_webview_capability",
30
+ message: `Webview did not declare host capability: ${e}`,
31
+ severity: "error"
32
+ }), k = (e, t = {}) => {
33
+ let n = [], r = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map();
34
+ for (let e of i) t[e] && r.add(e);
35
+ for (let i of e ?? []) {
36
+ let e = w(i);
37
+ if (!S(e.name) || !T(e)) {
38
+ n.push(E(i));
39
+ continue;
40
+ }
41
+ if (e.version !== o) {
42
+ n.push(D(i, e.name, e.version));
43
+ continue;
44
+ }
45
+ if (!t[e.name]) {
46
+ n.push(E(i));
47
+ continue;
48
+ }
49
+ if (e.scope === void 0) {
50
+ r.add(e.name);
51
+ continue;
52
+ }
53
+ let s = a.get(e.name) ?? /* @__PURE__ */ new Set();
54
+ s.add(e.scope), a.set(e.name, s);
55
+ }
56
+ return {
57
+ allowed: r,
58
+ allowedScopes: a,
59
+ diagnostics: n
60
+ };
61
+ }, ne = (e) => {
62
+ let t = e.params;
63
+ return typeof t?.mount == "string" && t.mount.length > 0 ? t.mount : void 0;
64
+ }, re = (e) => {
65
+ let { allowed: t, allowedScopes: n, diagnostics: r } = k(e.declaredCapabilities, e.capabilities), i = (t) => {
66
+ e.onDiagnostic?.(t);
67
+ }, a = (e) => (i(e), Error(e.message));
68
+ return {
69
+ diagnostics: r,
70
+ async call(r) {
71
+ if (!S(r.method)) throw a(E(r.method));
72
+ if (C(r.method)) {
73
+ let e = ne(r);
74
+ if (!e) throw a(E(r.method));
75
+ if (!n.get(r.method)?.has(e)) throw a(O(`${r.method}:${e}`));
76
+ } else if (!t.has(r.method)) throw a(O(r.method));
77
+ let i = e.capabilities[r.method];
78
+ if (!i) throw a(E(r.method));
79
+ return await i(r.params);
80
+ }
81
+ };
82
+ }, ie = (e) => typeof e == "object" && !!e, ae = (e) => {
83
+ try {
84
+ let t = JSON.stringify(e);
85
+ if (typeof t == "string" && t.length > 0) return t;
86
+ } catch {}
87
+ try {
88
+ return String(e);
89
+ } catch {
90
+ return "Unknown error";
91
+ }
92
+ }, oe = (e) => {
93
+ if (e instanceof Error) return {
94
+ message: e.message,
95
+ stack: e.stack
96
+ };
97
+ if (typeof e == "string") return { message: e };
98
+ if (ie(e)) {
99
+ let t = typeof e.message == "string" ? e.message : null, n = typeof e.stack == "string" ? e.stack : void 0;
100
+ return t ? n ? {
101
+ message: t,
102
+ stack: n
103
+ } : { message: t } : { message: ae(e) };
104
+ }
105
+ return e == null ? { message: "Unknown error" } : { message: ae(e) };
106
+ }, A = () => {
107
+ if (typeof document > "u") return {};
108
+ let e = getComputedStyle(document.documentElement), t = {};
109
+ for (let n = 0; n < e.length; n += 1) {
110
+ let r = e.item(n);
111
+ r.startsWith("--chakra-") && (t[r] = e.getPropertyValue(r).trim());
112
+ }
113
+ return t;
114
+ }, j = (e) => {
115
+ if (typeof document > "u") return e;
116
+ let t = document.documentElement.getAttribute("data-theme");
117
+ if (t === "dark" || t === "light") return t;
118
+ let n = document.documentElement.getAttribute("data-color-mode");
119
+ return n === "dark" || n === "light" ? n : e;
120
+ }, se = {
121
+ border: 0,
122
+ display: "block",
123
+ flex: "1 1 0%",
124
+ height: "100%",
125
+ minHeight: 0,
126
+ width: "100%"
127
+ }, ce = {
128
+ display: "flex",
129
+ height: "100%",
130
+ minHeight: 0,
131
+ position: "relative",
132
+ width: "100%"
133
+ }, le = {
134
+ alignItems: "center",
135
+ background: "rgba(255, 255, 255, 0.92)",
136
+ color: "#7a1f12",
137
+ display: "flex",
138
+ inset: 0,
139
+ justifyContent: "center",
140
+ padding: "24px",
141
+ position: "absolute",
142
+ textAlign: "center",
143
+ zIndex: 1
144
+ }, ue = "allow-scripts allow-forms allow-popups", de = (e) => {
145
+ let { view: t, props: n, theme: r, capabilities: i, hostEvents: a, onReady: o, onError: s, onDiagnostics: c, title: l } = e, u = _(null), d = _(null), f = _(null), h = _(!1), v = _(null), y = _(n), b = _(r), x = _(i), S = _(a), C = _(t.webview.capabilities), w = _(o), T = _(s), E = _(c), [D, O] = ee(null), [k, ne] = ee(0);
146
+ return y.current = n, b.current = r, x.current = i, S.current = a, C.current = t.webview.capabilities, w.current = o, T.current = s, E.current = c, g(() => {
147
+ let e = u.current;
148
+ if (!e) return;
149
+ let n = () => {
150
+ d.current === e ? ne((e) => e + 1) : d.current = e;
151
+ };
152
+ e.addEventListener("load", n);
153
+ let r = () => e.removeEventListener("load", n), i = `${k}\n${t.webview.runtimeUrl}\n${t.webview.moduleUrl}`;
154
+ if (v.current === i) return r;
155
+ v.current = i;
156
+ let a = t.webview.styles, o = t.webview.moduleUrl, s = (e) => {
157
+ e.length > 0 && E.current?.(e);
158
+ }, c = () => re({
159
+ capabilities: x.current ?? {},
160
+ declaredCapabilities: C.current,
161
+ onDiagnostic: (e) => s([e])
162
+ });
163
+ s(c().diagnostics);
164
+ let l = {
165
+ ready: () => {},
166
+ runtimeError: (e) => {
167
+ O(e.message), T.current?.(e);
168
+ },
169
+ call: async (e) => await c().call(e)
170
+ };
171
+ return (() => {
172
+ h.current = !1, f.current = null;
173
+ let n = te.connect(e, l);
174
+ e.contentWindow?.location.replace(t.webview.runtimeUrl), n.then(async (n) => {
175
+ if (u.current !== e) return;
176
+ let r = n.remote;
177
+ f.current = r, S.current?.bind((e) => r.hostEvent?.(e)), await r.init({
178
+ moduleUrl: o,
179
+ styles: a,
180
+ props: y.current,
181
+ theme: j(b.current),
182
+ themeVariables: A(),
183
+ extensionId: t.extensionId
184
+ }), u.current === e && (h.current = !0, O(null), w.current?.());
185
+ }).catch((t) => {
186
+ if (u.current !== e) return;
187
+ let n = oe(t);
188
+ O(n.message), T.current?.(n);
189
+ });
190
+ })(), r;
191
+ }, [
192
+ k,
193
+ t.extensionId,
194
+ t.webview.runtimeUrl,
195
+ t.webview.moduleUrl,
196
+ t.webview.styles
197
+ ]), g(() => {
198
+ let e = f.current;
199
+ if (e && a) return a.bind((t) => e.hostEvent?.(t)), () => a.unbind();
200
+ }, [a]), g(() => {
201
+ h.current && f.current?.propsUpdate({ props: n });
202
+ }, [n]), g(() => {
203
+ h.current && f.current?.themeUpdate({
204
+ theme: j(r),
205
+ variables: A()
206
+ });
207
+ }, [r]), g(() => {
208
+ if (typeof window > "u" || typeof MutationObserver > "u") return;
209
+ let e = null, t = new MutationObserver(() => {
210
+ e !== null && cancelAnimationFrame(e), e = requestAnimationFrame(() => {
211
+ e = null, h.current && f.current?.themeUpdate({
212
+ theme: j(b.current),
213
+ variables: A()
214
+ });
215
+ });
216
+ }), n = {
217
+ attributeFilter: [
218
+ "class",
219
+ "data-color-mode",
220
+ "data-theme",
221
+ "style"
222
+ ],
223
+ attributes: !0
224
+ };
225
+ return t.observe(document.documentElement, n), t.observe(document.body, n), () => {
226
+ t.disconnect(), e !== null && cancelAnimationFrame(e);
227
+ };
228
+ }, []), /* @__PURE__ */ m("div", {
229
+ style: ce,
230
+ children: [D ? /* @__PURE__ */ p("div", {
231
+ role: "alert",
232
+ style: le,
233
+ children: /* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("strong", { children: "Extension view failed to load." }), /* @__PURE__ */ p("div", { children: D })] })
234
+ }) : null, /* @__PURE__ */ p("iframe", {
235
+ ref: u,
236
+ title: l ?? t.label,
237
+ allow: "fullscreen",
238
+ allowFullScreen: !0,
239
+ sandbox: ue,
240
+ style: {
241
+ ...se,
242
+ colorScheme: r
243
+ },
244
+ onError: () => {
245
+ let e = `Failed to load extension runtime at ${t.webview.runtimeUrl}`;
246
+ O(e), T.current?.({ message: e });
247
+ }
248
+ }, `${k}\n${t.webview.runtimeUrl}\n${t.webview.moduleUrl}`)]
249
+ });
250
+ }, fe = "[pstdio.extension-host] ", pe = (e, t = console.info) => {
251
+ t(`${fe}${JSON.stringify(e)}`);
252
+ }, me = (e, t) => {
253
+ let n = (n) => pe({
254
+ extensionId: e.extensionId,
255
+ contributionId: e.id,
256
+ ...n
257
+ }, t);
258
+ return {
259
+ onReady: () => n({ event: "webview-ready" }),
260
+ onError: (e) => n({
261
+ event: "webview-error",
262
+ ...e
263
+ }),
264
+ onDiagnostics: (e) => {
265
+ for (let t of e) n({
266
+ event: "webview-diagnostic",
267
+ ...t
268
+ });
269
+ }
270
+ };
271
+ }, he = () => {
272
+ let e = null, t = [], n = /* @__PURE__ */ new Set();
273
+ return {
274
+ emit(n) {
275
+ e ? e(n) : t.push(n);
276
+ },
277
+ bind(n) {
278
+ for (e = n; t.length > 0;) n(t.shift());
279
+ },
280
+ onDisconnect(e) {
281
+ return n.add(e), () => n.delete(e);
282
+ },
283
+ unbind() {
284
+ e = null;
285
+ for (let e of n) e();
286
+ }
287
+ };
288
+ }, ge = "terminal.session", _e = (e) => {
289
+ let { terminal: t, hostEvents: n } = e, r = (e) => {
290
+ n.emit({
291
+ scope: ge,
292
+ payload: e
293
+ });
294
+ };
295
+ return async (e) => {
296
+ let i = e;
297
+ switch (i.operation) {
298
+ case "open": {
299
+ let { sessionId: e } = await t.open({ request: i.request });
300
+ return {
301
+ operation: "open",
302
+ sessionId: e
303
+ };
304
+ }
305
+ case "write": return t.write({
306
+ sessionId: i.sessionId,
307
+ data: i.data
308
+ }), {
309
+ operation: "write",
310
+ accepted: !0
311
+ };
312
+ case "resize": return t.resize({
313
+ sessionId: i.sessionId,
314
+ cols: i.cols,
315
+ rows: i.rows
316
+ }), {
317
+ operation: "resize",
318
+ accepted: !0
319
+ };
320
+ case "kill": return await t.kill({
321
+ sessionId: i.sessionId,
322
+ signal: i.signal
323
+ }), {
324
+ operation: "kill",
325
+ accepted: !0
326
+ };
327
+ case "subscribe": {
328
+ let { sessionId: e } = i, a = () => {}, o = () => {}, s = !1, c = () => {
329
+ s || (s = !0, a(), o());
330
+ };
331
+ return a = t.subscribe(e, {
332
+ onData: (t) => r({
333
+ sessionId: e,
334
+ kind: "data",
335
+ chunk: t
336
+ }),
337
+ onExit: (t) => {
338
+ r({
339
+ sessionId: e,
340
+ kind: "exit",
341
+ code: t.code,
342
+ signal: t.signal
343
+ }), c();
344
+ }
345
+ }), o = n.onDisconnect(c), {
346
+ operation: "subscribe",
347
+ accepted: !0
348
+ };
349
+ }
350
+ }
351
+ };
352
+ }, ve = (e) => {
353
+ if (typeof document > "u") return;
354
+ let t = new KeyboardEvent("keydown", {
355
+ ...e,
356
+ bubbles: !0,
357
+ cancelable: !0
358
+ });
359
+ document.dispatchEvent(t);
360
+ }, ye = (e) => ({
361
+ ...e.placement?.placementIdentity ? { "placement.close": (t) => {
362
+ if (t !== void 0 && (typeof t != "object" || !t || Array.isArray(t) || Object.keys(t).length > 0)) throw Error("placement.close takes no parameters; the host supplies the calling placement.");
363
+ e.workbench.closePlacement(e.placement.placementIdentity);
364
+ } } : {},
365
+ "commands.execute": (t) => {
366
+ let n = t;
367
+ return e.workbench.commands.executeCommand(n.commandId, n.params);
368
+ },
369
+ "navigation.open": (t) => {
370
+ let n = t;
371
+ if (!n.target) throw Error("navigation.open requires a target.");
372
+ return e.workbench.navigation.openTarget(n.target);
373
+ },
374
+ "notification.show": (t) => {
375
+ let n = t;
376
+ return e.workbench.notifications.show({
377
+ level: n.level,
378
+ message: n.message,
379
+ title: n.title
380
+ });
381
+ },
382
+ "preferences.get": (t) => {
383
+ let n = t;
384
+ return e.workbench.preferences.getValue(n.name, n.scope);
385
+ },
386
+ "preferences.set": (t) => {
387
+ let n = t;
388
+ return e.workbench.preferences.setValue(n.name, n.value, n.scope ?? { scope: "user" }), {
389
+ name: n.name,
390
+ value: n.value
391
+ };
392
+ },
393
+ "host.dispatchKeyboardEvent": (t) => (e.dispatchKeyboardEvent ?? ve)(t),
394
+ ...e.hostEvents ? { "terminal.session": _e({
395
+ terminal: e.workbench.terminal,
396
+ hostEvents: e.hostEvents
397
+ }) } : {}
398
+ }), be = () => "light", xe = /* @__PURE__ */ new WeakMap(), Se = (e, t) => {
399
+ let n = xe.get(e);
400
+ n || (n = /* @__PURE__ */ new Map(), xe.set(e, n));
401
+ let r = t.instanceId, i = n.get(r);
402
+ return i || (i = he(), n.set(r, i)), i;
403
+ }, Ce = (e) => {
404
+ let { context: t, createHostCapabilities: n, createProps: r, createTheme: i = be, ownerId: a, title: o, webview: s } = e;
405
+ return /* @__PURE__ */ p(de, {
406
+ view: {
407
+ extensionId: a ?? "workbench",
408
+ id: t.webviewId,
409
+ label: s.title ?? o,
410
+ webview: {
411
+ capabilities: s.capabilities,
412
+ moduleUrl: s.moduleUrl,
413
+ runtimeUrl: s.runtimeUrl,
414
+ styles: s.styles ?? []
415
+ }
416
+ },
417
+ props: r(t),
418
+ theme: i(t),
419
+ capabilities: n(t),
420
+ hostEvents: t.hostEvents,
421
+ ...me({
422
+ extensionId: a ?? "workbench",
423
+ id: t.webviewId
424
+ })
425
+ });
426
+ }, M = (e, t = "") => e === void 0 ? t : y(e) ? e.default ?? e.$l10n : e, we = (e, t) => {
427
+ let n = t.commandTargetOf?.(e);
428
+ if (n) return n;
429
+ let r = e.target.command, i = r.extensionId ?? t.extensionId;
430
+ return {
431
+ kind: "command",
432
+ commandId: t.commandIdOf?.(r) ?? (i && i !== "pstdio" ? `${i}.command.${r.id}` : r.id),
433
+ args: e.target.params
434
+ };
435
+ };
436
+ function N(e, t = {}) {
437
+ if (!l(e)) throw Error("Invalid navigation target.");
438
+ return t.extensionId && (e = d(e, t.extensionId, t.projectId)), e.kind === "command" ? we(e, t) : e.kind === "href" || e.kind === "page" || e.kind === "panel" ? e : {
439
+ kind: "compound",
440
+ targets: e.targets.map((e) => N(e, t))
441
+ };
502
442
  }
503
- const me = (e, t = {}) => {
504
- if (e != null) {
505
- if (!We(e)) throw new Error("Renderer callback returned an invalid navigation target.");
506
- return H(e, t);
507
- }
508
- }, ee = (e) => {
509
- const t = e;
510
- if (!t?.outcome) return e;
511
- if (t.outcome.status === "success") return t.outcome.value;
512
- throw new Error(t.outcome.reason ?? t.outcome.error?.message ?? "Extension command failed.");
513
- }, O = (e) => ({
514
- id: e.id,
515
- kind: e.kind,
516
- context: {
517
- projectId: e.projectId,
518
- ...e.context ?? {}
519
- }
520
- }), Dt = (e) => typeof e == "object" && e !== null && !Array.isArray(e), Ot = (e) => {
521
- if (!(!Dt(e) || e.deleted !== !0))
522
- return typeof e.id == "string" ? e.id : void 0;
523
- }, Ft = async (e, t, n) => {
524
- if (!t || Ot(n) !== (t.id ?? V(t)) || V(e.workbench.getPrimaryResource()) !== V(t)) return;
525
- const o = e.workbench.pageLocations.navigateToParent();
526
- if (!o.ok) throw new Error(o.diagnostic.message);
527
- }, E = async (e, t, n = {}) => {
528
- const o = n.resource, r = await e.executeCommand(t, {
529
- projectId: e.projectId,
530
- ...n.params ? {
531
- params: n.params
532
- } : {},
533
- ...o ? {
534
- resource: o
535
- } : {},
536
- ...n.slot ? {
537
- slot: n.slot
538
- } : {},
539
- source: "dashboard",
540
- ...n.metadata ? {
541
- metadata: n.metadata
542
- } : {}
543
- }), s = ee(r);
544
- return await Ft(e, n.resource, s), s;
545
- }, Kt = (e) => typeof e == "object" && e !== null && !Array.isArray(e), Nt = (e, t) => `${e.extensionId ?? t}.command.${e.id}`, Lt = async (e, t, n) => {
546
- const {
547
- target: o
548
- } = n;
549
- if (o.kind === "command") {
550
- await E(e, Nt(o.target.command, t.extensionId), {
551
- params: o.target.params
552
- }), e.workbench.commandPaletteResources.refresh();
553
- return;
554
- }
555
- await e.workbench.navigation.openTarget(H(o, {
556
- extensionId: t.extensionId
557
- }));
558
- }, _t = (e, t, n, o) => ({
559
- id: `${t.id}:${o.id}`,
560
- label: o.label,
561
- description: o.description,
562
- icon: o.icon,
563
- keywords: o.keywords,
564
- group: n,
565
- activate: () => Lt(e, t, o)
566
- }), Ut = (e, t) => {
567
- const n = [];
568
- for (const o of t) {
569
- const r = b(o.title, o.id);
570
- n.push(e.workbench.commandPaletteResources.registerProvider({
571
- id: o.id,
572
- title: r,
573
- refreshEventIds: o.refreshEventIds,
574
- query: async ({
575
- query: s,
576
- limit: i
577
- }) => {
578
- const a = e.workbench.getActiveResource(), d = await E(e, o.queryHandlerId, {
579
- params: {
580
- projectId: e.projectId,
581
- modeId: e.workbench.modes.getActiveModeId(),
582
- activeResource: a,
583
- providerId: o.id,
584
- query: s,
585
- limit: i
586
- }
587
- });
588
- return Kt(d) ? (d.items ?? []).map((m) => _t(e, o, r, m)) : [];
589
- }
590
- }));
591
- }
592
- return {
593
- dispose() {
594
- for (let o = n.length - 1; o >= 0; o -= 1) n[o]?.dispose();
595
- }
596
- };
597
- }, re = (e, t = "") => b(e, t), qt = (e, t, n) => {
598
- const o = O({
599
- id: t.id,
600
- kind: "renderer",
601
- projectId: e.projectId,
602
- context: {
603
- controlsRendererId: t.id
604
- }
605
- }), r = (s, i, a) => s ? E(e, s, {
606
- params: {
607
- renderer: {
608
- rendererId: t.id,
609
- projectId: e.projectId,
610
- ...a ? {
611
- resource: a
612
- } : {},
613
- invocation: {
614
- placement: "visible"
615
- }
616
- },
617
- ...i
618
- },
619
- resource: a,
620
- slot: o,
621
- metadata: {
622
- controlsRendererId: t.id
623
- }
624
- }) : Promise.resolve(void 0);
625
- return e.workbench.views.registerView({
626
- id: t.id,
627
- title: re(t.title, t.id),
628
- icon: t.icon,
629
- body: {
630
- kind: "controls",
631
- emptyTitle: re(t.emptyTitle, ""),
632
- emptyDescription: re(t.emptyDescription, ""),
633
- defaultValues: t.defaultValues,
634
- executeQuery: async (s) => {
635
- const i = await r(t.queryHandlerId, {}, s ?? n.resolveResource?.(t)), a = it.safeParse(i);
636
- if (!a.success) {
637
- const d = a.error.issues.map((m) => `body.query.${m.path.join(".")}: ${m.message}`).join("; ");
638
- throw new Error(`Extension "${t.extensionId}" view "${t.id}" has invalid controls. Expected serializable control declarations. ${d}`);
639
- }
640
- return a.data;
641
- },
642
- updateValue: t.valueChangeHandlerId ? ({
643
- controlId: s,
644
- value: i,
645
- values: a,
646
- resource: d
647
- }) => r(t.valueChangeHandlerId, {
648
- controlId: s,
649
- value: i,
650
- values: a
651
- }, d).then(() => {
652
- }) : void 0,
653
- apply: t.applyHandlerId ? ({
654
- values: s,
655
- resource: i
656
- }) => r(t.applyHandlerId, {
657
- values: s
658
- }, i).then(() => {
659
- }) : void 0,
660
- reset: t.resetHandlerId ? ({
661
- controlIds: s,
662
- resource: i
663
- }) => r(t.resetHandlerId, {
664
- controlIds: s
665
- }, i).then(() => {
666
- }) : void 0
667
- }
668
- });
669
- }, zt = (e, t, n = {}) => {
670
- const o = [];
671
- for (const r of t) o.push(qt(e, r, n));
672
- return {
673
- dispose() {
674
- for (let r = o.length - 1; r >= 0; r -= 1) o[r]?.dispose();
675
- }
676
- };
677
- }, $ = (e, t = "") => b(e, t), ke = (e) => ({
678
- ...e,
679
- label: $(e.label, e.id),
680
- description: e.description ? $(e.description) : void 0,
681
- icon: e.icon ? D(_, {
682
- name: e.icon,
683
- size: 14
684
- }) : void 0
685
- }), Qt = (e) => !!(e && typeof e == "object" && Array.isArray(e.rows)), Gt = (e) => ({
686
- id: e.id,
687
- values: e.values,
688
- resource: e.resource ? e.resource : void 0
689
- }), Yt = (e, t) => {
690
- const n = /* @__PURE__ */ new WeakMap(), o = O({
691
- id: t.id,
692
- kind: "dataTableRenderer",
693
- projectId: e.projectId,
694
- context: {
695
- dataTableRendererId: t.id
696
- }
697
- }), r = (s, i, a, d) => E(e, s, {
698
- params: {
699
- renderer: {
700
- rendererId: t.id,
701
- projectId: e.projectId,
702
- ...d ? {
703
- modeId: d
704
- } : {},
705
- ...a ? {
706
- resource: a
707
- } : {},
708
- invocation: {
709
- placement: "visible"
710
- }
711
- },
712
- ...i
713
- },
714
- resource: a,
715
- slot: o,
716
- metadata: {
717
- dataTableRendererId: t.id
718
- }
719
- });
720
- return e.workbench.views.registerView({
721
- id: t.id,
722
- title: $(t.title, t.id),
723
- icon: t.icon,
724
- body: {
725
- kind: "dataTable",
726
- resourceKind: t.resourceKind,
727
- columns: t.columns?.map(ke),
728
- initialPageSize: t.initialPageSize,
729
- pageSizeOptions: t.pageSizeOptions,
730
- selectionMode: t.selectionMode,
731
- selectionActions: t.selectionActions?.map((s) => ({
732
- id: s.id,
733
- label: $(s.label, s.id),
734
- icon: s.icon ? D(_, {
735
- name: s.icon,
736
- size: 16
737
- }) : void 0,
738
- destructive: s.destructive,
739
- run: (i) => r(s.commandId, {
740
- rowIds: i.map((a) => a.id)
741
- }).then(() => {
742
- })
743
- })),
744
- emptyTitle: t.emptyTitle ? $(t.emptyTitle) : void 0,
745
- emptyDescription: t.emptyDescription ? $(t.emptyDescription) : void 0,
746
- executeQuery: async ({
747
- resource: s,
748
- modeId: i
749
- }) => {
750
- const a = await r(t.queryHandlerId, {}, s, i);
751
- return Qt(a) ? {
752
- rows: a.rows.map((m) => {
753
- const l = Gt(m);
754
- return n.set(l, m), l;
755
- }),
756
- columns: a.columns?.map(ke)
757
- } : {
758
- rows: []
759
- };
760
- },
761
- rowActions: t.rowActions?.map((s) => ({
762
- id: s.id,
763
- label: $(s.label, s.id),
764
- icon: s.icon ? D(_, {
765
- name: s.icon,
766
- size: 16
767
- }) : void 0,
768
- destructive: s.destructive,
769
- run: async (i) => {
770
- await r(s.commandId, {
771
- rowId: i.id
772
- }, i.resource), e.workbench.views.refreshView(t.id);
773
- }
774
- })),
775
- onRowActivate: t.rowActivationHandlerId ? async (s) => {
776
- const i = await r(t.rowActivationHandlerId, {
777
- row: n.get(s) ?? s
778
- }, s.resource), a = me(i, {
779
- extensionId: t.extensionId
780
- });
781
- a && await e.workbench.navigation.openTarget(a);
782
- } : void 0
783
- }
784
- });
785
- }, Xt = (e, t) => {
786
- const n = t.map((o) => Yt(e, o));
787
- return {
788
- dispose() {
789
- for (let o = n.length - 1; o >= 0; o -= 1) n[o]?.dispose();
790
- }
791
- };
792
- }, Jt = {
793
- first: 0,
794
- default: 1,
795
- last: 2
796
- }, qo = {
797
- commands: [],
798
- commandPaletteContributions: [],
799
- diagnostics: [],
800
- extensions: [],
801
- menuContributions: [],
802
- modes: [],
803
- pages: [],
804
- views: [],
805
- viewMenus: [],
806
- placements: [],
807
- resourceKinds: [],
808
- navigationItems: [],
809
- navigationTrees: [],
810
- statusBarItems: [],
811
- statuses: [],
812
- settingsPanels: [],
813
- settingsDefinitions: []
814
- }, Zt = (e) => `workbench.extension.menu.${e.id}`, en = (e) => `workbench.extension.palette.${e.id}`, Be = (e, t) => Jt[e.placement ?? "default"] * 1e3 + t, Ve = (e) => e === void 0 ? "" : st(e) ? e.default ?? e.$l10n : e, tn = (e) => {
815
- const {
816
- commandId: t,
817
- contribution: n,
818
- index: o,
819
- resolveString: r,
820
- slot: s,
821
- when: i
822
- } = e;
823
- return {
824
- commandId: t,
825
- sourceCommandId: n.commandId,
826
- label: r(n.label, n.extensionId),
827
- icon: n.icon,
828
- group: s.group ?? n.group,
829
- args: n.params,
830
- overflowLabel: s.overflowLabel,
831
- order: Be(n, o),
832
- when: i
833
- };
834
- }, nn = (e) => {
835
- const {
836
- commandId: t,
837
- contribution: n,
838
- index: o,
839
- resolveString: r
840
- } = e;
841
- return {
842
- commandId: t,
843
- label: r(n.label, n.extensionId),
844
- icon: n.icon,
845
- group: n.group,
846
- args: n.params,
847
- order: Be(n, o)
848
- };
849
- }, on = (e) => {
850
- const {
851
- createCommandId: t = Zt,
852
- createWhenExpression: n,
853
- menuSlotsById: o,
854
- menuTargetsById: r,
855
- metadata: s,
856
- resolveString: i = Ve
857
- } = e, a = [], d = [];
858
- return s.menuContributions.forEach((m, l) => {
859
- const c = m.target ? r?.get(m.target) : o.get(m.slotId);
860
- if (!c) {
861
- d.push({
862
- contribution: m,
863
- targetId: m.target ?? m.slotId
864
- });
865
- return;
866
- }
867
- const p = t(m), u = s.commands.find((g) => g.id === m.commandId);
868
- a.push({
869
- command: {
870
- id: p,
871
- label: i(m.label, m.extensionId),
872
- category: m.group,
873
- description: u ? i(u.description, u.extensionId) : void 0,
874
- icon: m.icon,
875
- params: u?.params
876
- },
877
- contribution: m,
878
- menuItem: tn({
879
- commandId: p,
880
- contribution: m,
881
- index: l,
882
- resolveString: i,
883
- slot: c,
884
- when: n?.(m)
885
- }),
886
- menuPath: c.menuPath,
887
- targetCommandId: m.commandId
888
- });
889
- }), {
890
- registrations: a,
891
- unresolved: d
892
- };
893
- }, sn = (e) => {
894
- const {
895
- createCommandId: t = en,
896
- metadata: n,
897
- resolveString: o = Ve
898
- } = e, r = [];
899
- return (n.commandPaletteContributions ?? []).forEach((s, i) => {
900
- const a = t(s), d = n.commands.find((m) => m.id === s.commandId);
901
- r.push({
902
- command: {
903
- id: a,
904
- label: o(s.label, s.extensionId),
905
- category: s.group,
906
- description: d ? o(d.description, d.extensionId) : void 0,
907
- icon: s.icon,
908
- params: d?.params
909
- },
910
- contribution: s,
911
- menuItem: nn({
912
- commandId: a,
913
- contribution: s,
914
- index: i,
915
- resolveString: o
916
- }),
917
- targetCommandId: s.commandId
918
- });
919
- }), r;
920
- }, rn = (e) => ({
921
- id: e.rendererId,
922
- kind: "renderer",
923
- context: {
924
- projectId: e.projectId,
925
- ...e.resource ? {
926
- resourceType: e.resource.type,
927
- resourceId: e.resource.id
928
- } : {}
929
- }
930
- }), xe = async (e, t, n, o, r = {}, s) => {
931
- const i = o, a = await e.executeCommand(n, {
932
- projectId: e.projectId,
933
- params: {
934
- renderer: {
935
- rendererId: t,
936
- projectId: e.projectId,
937
- ...i ? {
938
- resource: i
939
- } : {},
940
- invocation: {
941
- placement: "visible"
942
- }
943
- },
944
- ...r
945
- },
946
- resource: i,
947
- slot: rn({
948
- projectId: e.projectId,
949
- rendererId: t,
950
- resource: i
951
- }),
952
- source: "dashboard",
953
- ...s ? {
954
- metadata: s
955
- } : {}
956
- });
957
- return ee(a);
958
- }, De = (e) => {
959
- if (!e || typeof e != "object") return;
960
- const t = e.revision;
961
- return typeof t == "string" ? t : void 0;
962
- }, zo = (e, t) => {
963
- const n = e.metadata, o = n?.fileRendererOrigin;
964
- if (!o || typeof o != "object") return;
965
- const r = o;
966
- if (typeof r.rendererId != "string" || typeof r.instanceId != "string" || typeof r.operationId != "string")
967
- return;
968
- const s = n?.fileRendererResourceKey, i = De(t.outcome.value);
969
- return {
970
- origin: {
971
- rendererId: r.rendererId,
972
- instanceId: r.instanceId,
973
- operationId: r.operationId
974
- },
975
- ...typeof s == "string" ? {
976
- resourceKey: s
977
- } : {},
978
- ...i ? {
979
- revision: i
980
- } : {}
981
- };
982
- }, an = (e, t) => e.workbench.views.registerView({
983
- id: t.id,
984
- title: b(t.title, t.id),
985
- icon: t.icon,
986
- body: {
987
- kind: "file",
988
- resourceKind: t.resourceKind,
989
- load: async (n) => await xe(e, t.id, t.loadHandlerId, n) ?? {},
990
- save: t.saveHandlerId ? async (n, o, r) => {
991
- const s = await xe(e, t.id, t.saveHandlerId, n, {
992
- content: o
993
- }, {
994
- ...r ? {
995
- fileRendererOrigin: r
996
- } : {},
997
- ...V(n) ? {
998
- fileRendererResourceKey: V(n)
999
- } : {}
1000
- }), i = De(s);
1001
- return i ? {
1002
- revision: i
1003
- } : void 0;
1004
- } : void 0
1005
- }
1006
- }), dn = (e) => {
1007
- const t = [];
1008
- for (const n of e.metadata.fileRenderers ?? [])
1009
- t.push(an(e, n));
1010
- return {
1011
- dispose() {
1012
- for (let n = t.length - 1; n >= 0; n -= 1) t[n]?.dispose();
1013
- }
1014
- };
1015
- }, cn = (e) => (n) => D(_, {
1016
- name: e ?? "MoreHorizontal",
1017
- ...n
1018
- }), ln = (e, t) => ({
1019
- color: e?.color,
1020
- canDragIn: e?.canDragIn,
1021
- canDragOut: e?.canDragOut,
1022
- canCreate: e?.canCreate,
1023
- actions: e?.actions?.map((n) => ({
1024
- id: n.id,
1025
- label: t(n.label, n.id),
1026
- icon: cn(n.icon)
1027
- }))
1028
- }), Oe = (e, t) => `${t.extensionId ?? e.extensionId}.status.${t.id}`, mn = (e, t) => {
1029
- const n = /* @__PURE__ */ new Map();
1030
- return (o) => {
1031
- const r = Oe(t, o), s = n.get(r);
1032
- if (s) return s;
1033
- const i = {
1034
- getSnapshot: () => (e.workbench.statuses.getStatuses(r) ?? []).map((a) => ({
1035
- value: a.id,
1036
- label: a.label,
1037
- color: a.color,
1038
- icon: a.icon
1039
- })),
1040
- subscribe: (a) => e.workbench.statuses.store.subscribeSelector((d) => d.values[r], a)
1041
- };
1042
- return n.set(r, i), e.workbench.statuses.load(r).catch(() => {
1043
- }), i;
1044
- };
1045
- }, un = (e, t, n, o, r) => {
1046
- const s = n?.find((d) => d.id === o);
1047
- if (s?.type.kind !== "status") return;
1048
- const i = Oe(t, s.type.statuses), a = e.workbench.statuses.getStatuses(i)?.find((d) => d.id === r);
1049
- return a ? {
1050
- color: a.color
1051
- } : void 0;
1052
- }, pn = (e) => {
1053
- if (e.defaultSettings?.columnGrouping) return e.defaultSettings.columnGrouping;
1054
- const t = e.attributes?.filter((n) => n.type.kind === "status") ?? [];
1055
- return t.length === 1 ? t[0]?.id : void 0;
1056
- }, Re = (e) => typeof e == "object" && e !== null && !Array.isArray(e), Ee = (e, t, n, o, r, s) => (t ?? []).map((i) => {
1057
- const a = i.display, d = a?.kind === "badge-list" && typeof a.itemsAttributeId == "string" ? {
1058
- kind: "badge-list",
1059
- itemsAttributeId: a.itemsAttributeId
1060
- } : void 0;
1061
- a && !d && s?.(i.id, a.kind);
1062
- const m = {
1063
- ...i,
1064
- label: n(i.label, i.id),
1065
- type: i.type.kind === "status" ? {
1066
- kind: "enum",
1067
- options: r(i.type.statuses)
1068
- } : i.type.kind === "enum" || i.type.kind === "enum-multi" ? {
1069
- ...i.type,
1070
- options: Array.isArray(i.type.options) ? i.type.options.map((l) => ({
1071
- ...l,
1072
- label: n(l.label, l.value)
1073
- })) : i.type.options
1074
- } : i.type,
1075
- display: d
1076
- };
1077
- return o(e, m);
1078
- }), bn = (e, t, n, o, r = () => [], s) => {
1079
- let i = Ee(e, t, n, o, r, s);
1080
- const a = /* @__PURE__ */ new Set();
1081
- return {
1082
- source: {
1083
- getSnapshot: () => i,
1084
- subscribe: (d) => (a.add(d), () => a.delete(d))
1085
- },
1086
- set(d) {
1087
- i = Ee(e, d, n, o, r, s);
1088
- for (const m of a) m();
1089
- }
1090
- };
1091
- }, fn = (e) => !!(e && typeof e == "object" && typeof e.type == "string" && typeof e.id == "string"), Fe = (e, t) => {
1092
- const {
1093
- resource: n
1094
- } = t;
1095
- if (fn(n)) return n;
1096
- }, hn = (e, t) => {
1097
- const n = Fe(e, t);
1098
- if (n) return n;
1099
- if (e.resourceKind)
1100
- return {
1101
- type: e.resourceKind,
1102
- id: t.id,
1103
- label: t.title
1104
- };
1105
- }, gn = (e, t) => {
1106
- const n = e, o = t(n);
1107
- return o === void 0 ? n : {
1108
- ...n,
1109
- resource: o
1110
- };
1111
- }, Ke = (...e) => Object.assign({}, ...e.filter((t) => !!t)), wn = (e) => e && typeof e == "object" && !Array.isArray(e) ? e : void 0, In = (e) => Object.keys(e ?? {}).length > 0, yn = /* @__PURE__ */ new Set(["text", "longtext", "markdown", "number", "boolean", "select", "multi-select", "files"]), vn = (e, t, n) => {
1112
- if (!yn.has(t.type)) return;
1113
- const o = "options" in t && Array.isArray(t.options) ? t.options : [], r = t;
1114
- return {
1115
- id: e,
1116
- label: n(t.label, e),
1117
- description: t.description === void 0 ? void 0 : n(t.description),
1118
- placeholder: r.placeholder === void 0 ? void 0 : n(r.placeholder),
1119
- type: t.type,
1120
- required: t.required === !0,
1121
- defaultValue: t.defaultValue,
1122
- options: t.type === "select" || t.type === "multi-select" ? o.map((s) => ({
1123
- value: s.value,
1124
- label: n(s.label, s.value),
1125
- icon: s.icon
1126
- })) : void 0,
1127
- multiple: t.type === "files" ? r.multiple !== !1 : void 0,
1128
- accept: t.type === "files" && typeof r.accept == "string" ? r.accept : void 0
1129
- };
1130
- }, kn = (e, t) => Object.entries(e.createRow?.params ?? {}).flatMap(([n, o]) => {
1131
- const r = vn(n, o, t);
1132
- return r ? [r] : [];
1133
- }), xn = (e, t) => O({
1134
- id: t.id,
1135
- kind: "kanbanRenderer",
1136
- projectId: e.projectId,
1137
- context: {
1138
- kanbanRendererId: t.id
1139
- }
1140
- }), U = (e, t, n, o, r) => {
1141
- const s = r ?? e.workbench.getPrimaryResource();
1142
- return E(e, n, {
1143
- params: {
1144
- renderer: {
1145
- rendererId: t.id,
1146
- projectId: e.projectId,
1147
- ...s ? {
1148
- resource: s
1149
- } : {},
1150
- invocation: {
1151
- placement: "visible"
1152
- }
1153
- },
1154
- ...o
1155
- },
1156
- resource: s,
1157
- slot: xn(e, t),
1158
- metadata: {
1159
- kanbanRendererId: t.id
1160
- }
1161
- });
1162
- }, Ne = (e, t) => `workbench.extension.kanbanRenderer.${e.id}.rowAction.${t.id}`, Rn = (e, t, n) => (t.rowActions ?? []).map((o) => {
1163
- const r = e.workbench.commands.getCommand(o.commandId)?.command;
1164
- return e.workbench.commands.registerCommand({
1165
- id: Ne(t, o),
1166
- label: n(o.label, o.id),
1167
- icon: o.icon,
1168
- params: r?.params
1169
- }, {
1170
- execute: (s, i) => U(e, t, o.commandId, Ke(wn(s)), i?.resource)
1171
- });
1172
- }), En = (e, t, n, o, r, s) => {
1173
- const i = Ne(t, n), a = e.workbench.commands.getCommand(i), d = {
1174
- rowId: o.id
1175
- }, m = r ? {
1176
- resource: r
1177
- } : void 0, l = s(n.label, n.id);
1178
- return a && In(a.command.params) ? (e.workbench.commandPalette.requestParams({
1179
- record: a,
1180
- label: l,
1181
- args: d,
1182
- context: m
1183
- }), Promise.resolve()) : a ? e.workbench.commands.executeCommand(a.command.id, d, m).then(() => {
1184
- }) : U(e, t, n.commandId, d, r).then(() => {
1185
- });
1186
- }, An = (e) => e ? D(_, {
1187
- name: e,
1188
- size: 16
1189
- }) : void 0, Cn = (e, t) => {
1190
- if (e.createRow)
1191
- return {
1192
- title: t(e.createRow.title, "Create row"),
1193
- submitLabel: t(e.createRow.submitLabel, "Create"),
1194
- fields: kn(e, t),
1195
- labels: {
1196
- cancel: t(e.createRow.labels?.cancel, "Cancel"),
1197
- properties: t(e.createRow.labels?.properties, "Properties"),
1198
- submitError: t(e.createRow.labels?.submitError, "Could not create resource."),
1199
- removeFile: t(e.createRow.labels?.removeFile, "Remove file")
1200
- }
1201
- };
1202
- }, Sn = (e, t, n, o, r) => {
1203
- if (t.rowActivationHandlerId)
1204
- return async (s) => {
1205
- const i = o(t, s), a = await U(e, t, t.rowActivationHandlerId, {
1206
- row: r(s)
1207
- }, i), d = me(a, {
1208
- extensionId: t.extensionId
1209
- });
1210
- d && await e.workbench.navigation.openTarget(d);
1211
- };
1212
- if (n.onRowClick)
1213
- return (s) => n.onRowClick?.({
1214
- record: t,
1215
- row: s,
1216
- resource: o(t, s)
1217
- });
1218
- }, Tn = (e, t, n, o) => {
1219
- const r = e.createRow;
1220
- if (r)
1221
- return async (s) => {
1222
- const i = Ke(s.values, r.columnParam ? {
1223
- [r.columnParam]: s.columnId
1224
- } : void 0, r.attributesParam ? {
1225
- [r.attributesParam]: s.attributeValues
1226
- } : void 0), a = await n(e, r.commandId, i);
1227
- if (await t.onAfterCreate?.({
1228
- record: e,
1229
- created: a,
1230
- submission: s
1231
- }), !o || typeof a != "object" || a === null) return;
1232
- const d = a;
1233
- typeof d.id != "string" || typeof d.title != "string" || await o({
1234
- ...d,
1235
- id: d.id,
1236
- title: d.title,
1237
- attributes: d.attributes ?? {}
1238
- });
1239
- };
1240
- }, Pn = (e, t, n, o, r) => {
1241
- const s = t.rowActions;
1242
- if (s?.length)
1243
- return (i) => s.map((a) => {
1244
- const d = r(t, i), m = () => En(e, t, a, i, d, o);
1245
- return {
1246
- key: a.id,
1247
- label: o(a.label, a.id),
1248
- commandId: a.commandId,
1249
- icon: An(a.icon),
1250
- onClick: () => n.executeRowAction ? n.executeRowAction({
1251
- record: t,
1252
- action: a,
1253
- row: i,
1254
- resource: d,
1255
- runDefault: m
1256
- }) : m()
1257
- };
1258
- });
1259
- }, jn = (e, t, n = {}) => {
1260
- const o = [], r = n.resolveLabel ?? ((l, c) => b(l, c)), s = (l, c) => {
1261
- const p = c.display?.kind === "badge-list" ? {
1262
- ...c,
1263
- render: (u, g) => dt(c, u, g)
1264
- } : c;
1265
- return n.decorateAttribute?.(l, p) ?? p;
1266
- }, i = n.resolveRowResource ?? Fe, a = n.resolveRowActionResource ?? hn, d = n.onAfterMutation ?? (() => {
1267
- }), m = (l, c, p) => U(e, l, c, p).then((u) => (d(l), u));
1268
- for (const l of t) {
1269
- const c = mn(e, l), p = (f, k) => e.workbench.notifications.show({
1270
- id: `workbench.extension.${l.extensionId}.kanban.${l.id}.display.${f}`,
1271
- level: "error",
1272
- title: "Extension display is not available",
1273
- message: `Attribute "${f}" in renderer "${l.id}" uses unknown display kind "${k}".`
1274
- }), u = bn(l, l.attributes, r, s, c, p);
1275
- let g = l.attributes, x = pn(l);
1276
- const A = /* @__PURE__ */ new WeakMap();
1277
- let T, W = 0;
1278
- const z = (f) => i(l, f), j = Sn(e, l, n, i, (f) => A.get(f) ?? f);
1279
- o.push(...Rn(e, l, r)), o.push(e.workbench.views.registerView({
1280
- id: l.id,
1281
- title: r(l.title, l.id),
1282
- icon: l.icon,
1283
- body: {
1284
- kind: "kanban",
1285
- resourceKind: l.resourceKind,
1286
- storageScope: e.projectId,
1287
- attributes: u.source,
1288
- defaultSettings: l.defaultSettings,
1289
- defaultFilters: l.defaultFilters,
1290
- defaultViews: l.defaultViews?.map((f) => ({
1291
- ...f,
1292
- title: r(f.title, f.id)
1293
- })),
1294
- defaultActiveViewId: l.defaultActiveViewId,
1295
- emptyTitle: r(l.emptyTitle, ""),
1296
- emptyDescription: r(l.emptyDescription, ""),
1297
- hideToolbar: l.hideToolbar,
1298
- createRow: Cn(l, r),
1299
- getBoardColumnConfig: (f) => ln(T?.[f] ?? un(e, l, g, x, f), r),
1300
- onRowActivate: j,
1301
- executeQuery: async (f) => {
1302
- W += 1;
1303
- const k = W, w = await U(e, l, l.queryHandlerId, {
1304
- settings: f.settings,
1305
- filters: f.filters
1306
- }), P = (h) => h.map((C) => {
1307
- const S = gn(C, z);
1308
- return A.set(S, C), S;
1309
- });
1310
- if (k !== W)
1311
- return Array.isArray(w) ? P(w) : Re(w) ? P(w.rows ?? []) : [];
1312
- if (x = f.settings.columnGrouping, Array.isArray(w)) return P(w);
1313
- if (!Re(w)) return [];
1314
- const Q = w.attributes ?? g;
1315
- return g = Q, u.set(Q), T = w.boardColumnConfigs, P(w.rows ?? []);
1316
- },
1317
- onAttributeChange: l.attributeChangeHandlerId ? (f, k, w) => m(l, l.attributeChangeHandlerId, {
1318
- rowId: f,
1319
- attributeId: k,
1320
- value: w
1321
- }).then(() => {
1322
- }) : void 0,
1323
- onReorder: l.reorderHandlerId ? (f, k) => m(l, l.reorderHandlerId, {
1324
- rowId: f,
1325
- beforeRowId: k
1326
- }).then(() => {
1327
- }) : void 0,
1328
- onCreateRow: Tn(l, n, m, l.rowActivationHandlerId ? j : void 0),
1329
- onColumnAction: l.columnActionHandlerId ? async (f, k) => {
1330
- await m(l, l.columnActionHandlerId, {
1331
- columnId: f,
1332
- actionId: k
1333
- });
1334
- } : void 0,
1335
- getRowContextMenuActions: Pn(e, l, n, r, a)
1336
- }
1337
- }));
1338
- }
1339
- return {
1340
- dispose() {
1341
- for (let l = o.length - 1; l >= 0; l -= 1) o[l]?.dispose();
1342
- }
1343
- };
1344
- }, $n = (e, t) => {
1345
- if (e)
1346
- return Object.fromEntries(Object.entries(e).map(([n, o]) => [n, {
1347
- ...o,
1348
- label: o.label === void 0 ? void 0 : t(o.label, n),
1349
- description: o.description === void 0 ? void 0 : t(o.description)
1350
- }]));
1351
- }, Le = (e) => ({
1352
- id: e.treeId,
1353
- kind: "renderer",
1354
- context: {
1355
- projectId: e.projectId,
1356
- treeId: e.treeId,
1357
- ...e.modeId ? {
1358
- modeId: e.modeId
1359
- } : {},
1360
- ...e.resource ? {
1361
- resourceType: e.resource.type,
1362
- resourceId: e.resource.id
1363
- } : {}
1364
- }
1365
- }), G = (e, t, n, o) => {
1366
- const r = n.resource, s = e.workbench.modes.getActiveModeId();
1367
- return {
1368
- renderer: {
1369
- rendererId: t.id,
1370
- projectId: e.projectId,
1371
- ...s ? {
1372
- modeId: s
1373
- } : {},
1374
- ...r ? {
1375
- resource: r
1376
- } : {},
1377
- invocation: {
1378
- placement: "visible"
1379
- }
1380
- },
1381
- state: n.state,
1382
- ...n.filter ? {
1383
- filter: n.filter
1384
- } : {},
1385
- ...o ? {
1386
- node: o
1387
- } : {}
1388
- };
1389
- }, Y = async (e, t, n, o) => {
1390
- const r = o.renderer, s = r?.resource, i = await e.executeCommand(n, {
1391
- projectId: e.projectId,
1392
- params: o,
1393
- resource: s,
1394
- slot: Le({
1395
- modeId: r?.modeId,
1396
- projectId: e.projectId,
1397
- resource: s,
1398
- treeId: t.id
1399
- }),
1400
- source: "dashboard"
1401
- });
1402
- return ee(i);
1403
- }, _e = async (e, t, n, o, r) => {
1404
- const s = e.workbench.modes.getActiveModeId(), i = {
1405
- ...o ?? {},
1406
- renderer: {
1407
- rendererId: t.id,
1408
- projectId: e.projectId,
1409
- ...s ? {
1410
- modeId: s
1411
- } : {},
1412
- ...r ? {
1413
- resource: r
1414
- } : {},
1415
- invocation: {
1416
- placement: "visible"
1417
- }
1418
- }
1419
- }, a = await e.executeCommand(n, {
1420
- projectId: e.projectId,
1421
- params: i,
1422
- resource: r,
1423
- slot: Le({
1424
- modeId: s,
1425
- projectId: e.projectId,
1426
- resource: r,
1427
- treeId: t.id
1428
- }),
1429
- source: "dashboard",
1430
- metadata: {
1431
- treeId: t.id
1432
- }
1433
- });
1434
- return ee(a);
1435
- }, Hn = (e, t) => e.panels.flatMap((n) => [n, ...n.panelMenus ?? []]).filter((n) => n.renderer?.kind === "tree" && n.renderer.id === t.id), Ue = (e, t) => t.viewId ? e.find((n) => n.id === t.viewId) : e.length === 1 ? e[0] : void 0, Wn = async (e) => {
1436
- const {
1437
- ctx: t,
1438
- getHostTreeHeaderNodes: n,
1439
- record: o,
1440
- treeViews: r
1441
- } = e, s = Ue(r, t);
1442
- return !s || !("hostTreeHeader" in s) || s.hostTreeHeader !== "default" ? [] : await n?.({
1443
- ctx: t,
1444
- record: o,
1445
- panel: s
1446
- }) ?? [];
1447
- }, Mn = async (e) => {
1448
- const {
1449
- ctx: t,
1450
- getHostTreeFooterNodes: n,
1451
- record: o,
1452
- treeViews: r
1453
- } = e, s = Ue(r, t);
1454
- return !s || !("hostTreeFooter" in s) || s.hostTreeFooter !== "default" ? [] : await n?.({
1455
- ctx: t,
1456
- record: o,
1457
- panel: s
1458
- }) ?? [];
1459
- }, Bn = (e, t) => e && typeof e == "object" && !Array.isArray(e) ? e : t, Ae = (e) => e && !Array.isArray(e) ? e : void 0, Vn = (e, t) => {
1460
- const n = /* @__PURE__ */ new WeakMap(), o = `workbench.extensionTreeRenderer.${t.id}.command`, r = (c) => e.resolveNodeResource?.(c) ?? c, s = (c) => {
1461
- if (c.emptyState)
1462
- return {
1463
- title: b(c.emptyState.title),
1464
- description: b(c.emptyState.description),
1465
- icon: c.emptyState.icon
1466
- };
1467
- }, i = (c, p, u) => c ? H(c, {
1468
- commandTargetOf: (x) => ({
1469
- kind: "command",
1470
- commandId: o,
1471
- args: {
1472
- commandId: `${x.target.command.extensionId ?? t.extensionId}.command.${x.target.command.id}`,
1473
- ...p ? {
1474
- nodeId: p.id
1475
- } : {},
1476
- params: x.target.params,
1477
- resource: p?.resource ?? u.resource,
1478
- treeId: t.id
1479
- }
1480
- }),
1481
- extensionId: t.extensionId
1482
- }) : void 0, a = (c, p, u) => {
1483
- const g = c.command ? `${c.command.extensionId ?? t.extensionId}.command.${c.command.id}` : void 0;
1484
- return {
1485
- id: c.id,
1486
- label: b(c.label),
1487
- icon: c.icon,
1488
- args: Ae(c.params),
1489
- params: $n(c.input, b),
1490
- submitLabel: c.submitLabel,
1491
- when: c.when,
1492
- disabled: c.disabled,
1493
- // Actions mutate tree data (create/delete/...), so refresh afterwards. Plain
1494
- // node-target navigation runs through the runner command and must not refetch.
1495
- run: g ? async (x) => {
1496
- const A = await _e(e, t, g, Bn(x, Ae(c.params)), p?.resource ?? u.resource);
1497
- u.refresh();
1498
- const T = We(A) ? i(A, p, u) : void 0;
1499
- T && await e.workbench.navigation.openTarget(T);
1500
- } : void 0
1501
- };
1502
- }, d = (c, p) => {
1503
- const u = {
1504
- id: c.id,
1505
- selected: c.selected,
1506
- label: b(c.label),
1507
- icon: c.icon,
1508
- iconColor: c.iconColor,
1509
- iconTooltip: c.iconTooltip,
1510
- resource: c.resource ? r(c.resource) : void 0,
1511
- target: i(c.target, c, p),
1512
- rowVariant: c.rowVariant,
1513
- actions: c.actions?.map((g) => a(g, c, p)),
1514
- contextMenuActions: c.contextMenuActions?.map((g) => a(g, c, p)),
1515
- collapsible: c.collapsible,
1516
- disabled: c.disabled,
1517
- children: c.children?.map((g) => d(g, p)),
1518
- description: c.description,
1519
- contextValue: c.contextValue,
1520
- hiddenByDefault: c.hiddenByDefault,
1521
- canHide: c.canHide
1522
- };
1523
- return n.set(u, c), u;
1524
- };
1525
- return {
1526
- mapNodes: (c, p) => c.map((u) => d(u, p)),
1527
- mapSections: (c, p) => c.map((u) => ({
1528
- id: u.id,
1529
- label: b(u.label),
1530
- actions: u.actions?.map((g) => a(g, void 0, p)),
1531
- collapsible: u.collapsible,
1532
- emptyState: s(u),
1533
- nodes: u.nodes.map((g) => d(g, p)),
1534
- hiddenByDefault: u.hiddenByDefault,
1535
- canHide: u.canHide
1536
- })),
1537
- originalNodes: n,
1538
- runnerCommandId: o
1539
- };
1540
- }, ie = (e) => Array.isArray(e) && e.every((t) => t && typeof t == "object" && "nodes" in t), Dn = (e) => Array.isArray(e) && e.every((t) => t && typeof t == "object" && "id" in t), X = (e, t) => t.length > 0 ? [{
1541
- id: e,
1542
- nodes: t,
1543
- canReorder: !1
1544
- }] : [], On = (e, t) => {
1545
- const n = Vn(e, t), o = Hn(e.metadata, t), r = e.workbench.commands.registerCommand({
1546
- id: n.runnerCommandId,
1547
- label: `${b(t.title, t.id)} tree command`
1548
- }, {
1549
- execute: async (i) => {
1550
- const a = i, d = await _e(e, t, a.commandId, a.params, a.resource);
1551
- for (const m of e.workbench.views.listViews())
1552
- m.body.kind === "file" && e.workbench.views.refreshView(m.id);
1553
- return d;
1554
- }
1555
- }), s = e.workbench.views.registerView({
1556
- id: t.id,
1557
- title: b(t.title, t.id),
1558
- icon: t.icon,
1559
- body: {
1560
- kind: "tree",
1561
- searchable: t.searchable,
1562
- searchPlaceholder: b(t.searchPlaceholder, "Search files"),
1563
- defaultExpandedNodeIds: t.defaultExpandedNodeIds,
1564
- defaultExpandedSectionIds: t.defaultExpandedSectionIds,
1565
- getHeader: async (i) => {
1566
- const a = await Wn({
1567
- ctx: i,
1568
- getHostTreeHeaderNodes: e.getHostTreeHeaderNodes,
1569
- record: t,
1570
- treeViews: o
1571
- });
1572
- if (!t.headerHandlerId) return X(`${t.id}:host-header`, a);
1573
- const d = await Y(e, t, t.headerHandlerId, G(e, t, i)), m = ie(d) ? n.mapSections(d, i) : [];
1574
- return [...X(`${t.id}:host-header`, a), ...m];
1575
- },
1576
- getBody: async (i) => {
1577
- const a = await Y(e, t, t.bodyHandlerId, G(e, t, i));
1578
- return ie(a) ? n.mapSections(a, i) : [];
1579
- },
1580
- getFooter: async (i) => {
1581
- const a = await Mn({
1582
- ctx: i,
1583
- getHostTreeFooterNodes: e.getHostTreeFooterNodes,
1584
- record: t,
1585
- treeViews: o
1586
- });
1587
- if (!t.footerHandlerId) return X(`${t.id}:host-footer`, a);
1588
- const d = await Y(e, t, t.footerHandlerId, G(e, t, i));
1589
- return [...ie(d) ? n.mapSections(d, i) : [], ...X(`${t.id}:host-footer`, a)];
1590
- },
1591
- getChildren: async (i, a) => {
1592
- if (!t.childrenHandlerId) return i.children ?? [];
1593
- const d = n.originalNodes.get(i);
1594
- if (!d) return i.children ?? [];
1595
- const m = await Y(e, t, t.childrenHandlerId, G(e, t, a, d));
1596
- return Dn(m) ? n.mapNodes(m, a) : [];
1597
- }
1598
- }
1599
- });
1600
- return {
1601
- dispose() {
1602
- s.dispose(), r.dispose();
1603
- }
1604
- };
1605
- }, Fn = (e) => {
1606
- const t = [];
1607
- for (const n of e.metadata.treeRenderers ?? [])
1608
- t.push(On(e, n));
1609
- return {
1610
- dispose() {
1611
- for (let n = t.length - 1; n >= 0; n -= 1) t[n]?.dispose();
1612
- }
1613
- };
1614
- }, I = (e) => e.extensionId === "pstdio" ? e.id : `${e.extensionId}.${e.kind}.${e.id}`, Z = (e) => e.extensionId === "pstdio" ? e.id : `${e.extensionId}.command.${e.id}`, qe = (e) => {
1615
- if (!e) return;
1616
- const t = (n) => {
1617
- if (n)
1618
- return Array.isArray(n) ? n.map(I) : I(n);
1619
- };
1620
- return {
1621
- mode: t(e.mode),
1622
- source: e.source,
1623
- viewId: t(e.view),
1624
- resourceType: e.resourceType?.map((n) => n.id),
1625
- metadata: e.metadata
1626
- };
1627
- }, Qo = qe, ue = (e) => ({
1628
- kind: e.kind,
1629
- id: I(e),
1630
- extensionId: e.extensionId
1631
- }), Kn = (e, t, n) => {
1632
- const o = n?.(t.when);
1633
- return o ? e.context.matches(o) : !0;
1634
- }, Nn = (e) => ({
1635
- id: e.id,
1636
- label: b(e.label, e.id),
1637
- icon: e.icon,
1638
- canHide: !0,
1639
- canReorder: !0,
1640
- target: H(e.action, {
1641
- extensionId: e.extensionId
1642
- })
1643
- }), Ln = (e, t, n) => {
1644
- const o = /* @__PURE__ */ new Map();
1645
- for (const r of t) {
1646
- if (!Kn(e, r, n)) continue;
1647
- const s = r.group || void 0, i = s ? `${r.extensionId}:${s}` : "navigation.root", a = o.get(i) ?? {
1648
- id: i,
1649
- label: s,
1650
- collapsible: !!s,
1651
- canHide: !0,
1652
- canReorder: !0,
1653
- nodes: []
1654
- };
1655
- a.nodes.push(Nn(r)), o.set(i, a);
1656
- }
1657
- return [...o.values()];
1658
- }, _n = (e) => {
1659
- const t = /* @__PURE__ */ new Map();
1660
- for (const n of e) {
1661
- const o = ue(n.owner), r = `${n.extensionId}:${o.kind}:${o.id}:${n.slot}`;
1662
- t.set(r, [...t.get(r) ?? [], n]);
1663
- }
1664
- return [...t.values()];
1665
- }, Un = (e) => [...new Set(e.flatMap((t) => t.group ? [`${t.extensionId}:${t.group}`] : []))], qn = (e) => _n(e.metadata.navigationItems).map((t) => {
1666
- const n = t[0];
1667
- return e.workbench.navigationTrees.registerContribution({
1668
- id: `${n.extensionId}.navigation-items.${n.owner.kind}.${I(n.owner)}.${n.slot}`,
1669
- owner: ue(n.owner),
1670
- sourceExtensionId: n.extensionId,
1671
- declarationIndex: e.metadata.navigationItems.indexOf(n),
1672
- slot: n.slot,
1673
- defaultExpandedSectionIds: Un(t),
1674
- getSections: () => Ln(e.workbench, t, e.createWhenExpression)
1675
- });
1676
- }), zn = (e) => e.metadata.navigationTrees.map((t, n) => {
1677
- const o = I(t.view);
1678
- return e.workbench.navigationTrees.registerContribution({
1679
- id: t.id,
1680
- idScope: t.id,
1681
- owner: ue(t.owner),
1682
- sourceExtensionId: t.extensionId,
1683
- declarationIndex: e.metadata.navigationItems.length + n,
1684
- slot: t.slot,
1685
- viewId: o
1686
- });
1687
- }), Qn = (e) => [...qn(e), ...zn(e)], Gn = () => {
1688
- if (typeof navigator > "u") return;
1689
- const e = `${navigator.platform} ${navigator.userAgent}`.toLowerCase();
1690
- if (e.includes("mac")) return "mac";
1691
- if (e.includes("win")) return "win";
1692
- if (e.includes("linux")) return "linux";
1693
- }, Yn = (e, t = Gn()) => (t ? e.platformOverrides?.[t] : void 0) ?? e.key, Xn = (e) => e.bindings.map((t) => e.workbench.keybindings.registerKeybinding({
1694
- action: H(t.action, {
1695
- commandIdOf: (n) => n.extensionId ? Z({
1696
- extensionId: n.extensionId,
1697
- id: n.id
1698
- }) : void 0
1699
- }),
1700
- keybinding: Yn(t),
1701
- when: e.createWhenExpression?.(t.when)
1702
- })), Jn = (e, t) => ({
1703
- ...e,
1704
- tab: e.tab && t.createTab ? t.createTab({
1705
- ...e.tab,
1706
- extensionId: t.extensionId,
1707
- placementId: t.placementId
1708
- }) : void 0
1709
- }), Zn = (e, t) => e.kind === "panels" ? e : {
1710
- ...e,
1711
- tab: e.tab && t.createTab ? t.createTab({
1712
- ...e.tab,
1713
- extensionId: t.extensionId,
1714
- placementId: t.placementId
1715
- }) : void 0
1716
- }, eo = (e, t) => e.pages.map((n) => ({
1717
- id: n.id,
1718
- ref: {
1719
- extensionId: n.extensionId,
1720
- kind: "page",
1721
- id: n.localId
1722
- },
1723
- title: n.title,
1724
- path: n.path,
1725
- modeId: I(n.mode),
1726
- resource: n.resource,
1727
- main: Zn(n.main, {
1728
- extensionId: n.extensionId,
1729
- placementId: `${n.id}.$main`,
1730
- createTab: t
1731
- }),
1732
- slots: n.slots.map((o) => Jn(o, {
1733
- extensionId: n.extensionId,
1734
- placementId: `${n.id}.${o.id}`,
1735
- createTab: t
1736
- })),
1737
- ...n.icon ? {
1738
- icon: n.icon
1739
- } : {},
1740
- ...n.parent ? {
1741
- parentId: I(n.parent)
1742
- } : {}
1743
- })), q = (e, t) => {
1744
- const n = e.pages.flatMap((o) => [...o.main.kind === "view" && o.resource ? [{
1745
- ...o.resource,
1746
- view: o.main.view
1747
- }] : [], ...o.slots.flatMap((r) => r.item.kind === "binding" ? [r.item.binding] : [])]);
1748
- return n.push(...e.placements.flatMap((o) => o.item.kind === "binding" ? [o.item.binding] : [])), n.find((o) => I(o.view) === t)?.kinds[0]?.id;
1749
- }, ze = (e) => e.body.kind === "webview" ? {
1750
- webview: e.body.webview
1751
- } : {
1752
- renderer: {
1753
- kind: e.body.kind,
1754
- id: e.id
1755
- }
1756
- }, to = (e, t) => e.viewMenus.flatMap((n) => {
1757
- if (I(n.owner) !== t.id) return [];
1758
- const o = e.views.find((r) => r.id === I(n.view));
1759
- return o ? [{
1760
- id: n.id,
1761
- extensionId: n.extensionId,
1762
- ownerPanelId: t.id,
1763
- viewId: o.id,
1764
- title: o.title,
1765
- side: n.side,
1766
- group: n.group,
1767
- placement: n.placement,
1768
- hostTreeHeader: n.hostTreeHeader,
1769
- hostTreeFooter: n.hostTreeFooter,
1770
- ...ze(o)
1771
- }] : [];
1772
- }), no = (e) => e.views.map((t) => {
1773
- const n = to(e, t);
1774
- return {
1775
- id: t.id,
1776
- extensionId: t.extensionId,
1777
- title: t.title,
1778
- icon: t.icon,
1779
- panelMenus: n.length > 0 ? n : void 0,
1780
- ...ze(t)
1781
- };
1782
- }), de = (e) => e?.map(({
1783
- command: t,
1784
- ...n
1785
- }) => ({
1786
- ...n,
1787
- commandId: Z(t)
1788
- })), oo = (e) => e.views.flatMap((t) => {
1789
- const n = t.body;
1790
- return n.kind !== "kanban" ? [] : [{
1791
- ...n,
1792
- id: t.id,
1793
- extensionId: t.extensionId,
1794
- title: t.title,
1795
- icon: t.icon,
1796
- resourceKind: q(e, t.id),
1797
- createRow: n.createRow ? {
1798
- title: n.createRow.title,
1799
- submitLabel: n.createRow.submitLabel,
1800
- columnParam: n.createRow.columnParam,
1801
- params: n.createRow.params,
1802
- attributesParam: n.createRow.attributesParam,
1803
- labels: n.createRow.labels,
1804
- commandId: Z(n.createRow.command),
1805
- attachments: n.createRow.attachments ? {
1806
- resourceParam: n.createRow.attachments.resourceParam,
1807
- fileParam: n.createRow.attachments.fileParam,
1808
- commandId: Z(n.createRow.attachments.command)
1809
- } : void 0
1810
- } : void 0,
1811
- rowActions: de(n.rowActions)
1812
- }];
1813
- }), so = (e) => e.views.flatMap((t) => {
1814
- const n = t.body;
1815
- return n.kind !== "dataTable" ? [] : [{
1816
- ...n,
1817
- id: t.id,
1818
- extensionId: t.extensionId,
1819
- title: t.title,
1820
- icon: t.icon,
1821
- resourceKind: q(e, t.id),
1822
- selectionActions: de(n.selectionActions),
1823
- rowActions: de(n.rowActions)
1824
- }];
1825
- }), ro = (e) => e.views.flatMap((t) => t.body.kind === "tree" ? [{
1826
- ...t.body,
1827
- id: t.id,
1828
- extensionId: t.extensionId,
1829
- title: t.title,
1830
- icon: t.icon,
1831
- resourceKind: q(e, t.id)
1832
- }] : []), io = (e) => e.views.flatMap((t) => t.body.kind === "file" ? [{
1833
- ...t.body,
1834
- id: t.id,
1835
- extensionId: t.extensionId,
1836
- title: t.title,
1837
- icon: t.icon,
1838
- resourceKind: q(e, t.id)
1839
- }] : []), ao = (e) => e.views.flatMap((t) => t.body.kind === "controls" ? [{
1840
- ...t.body,
1841
- id: t.id,
1842
- extensionId: t.extensionId,
1843
- title: t.title,
1844
- icon: t.icon,
1845
- resourceKind: q(e, t.id)
1846
- }] : []), co = (e) => e.modes.map((t) => ({
1847
- id: t.id,
1848
- extensionId: t.extensionId,
1849
- modeId: t.id,
1850
- label: t.label,
1851
- icon: t.icon,
1852
- panelRegions: t.regions,
1853
- regionSettings: t.regionSettings,
1854
- floatingPanels: t.floatingPanels,
1855
- ...t.defaultTheme ? {
1856
- defaultTheme: I(t.defaultTheme)
1857
- } : {},
1858
- ...t.chrome ? {
1859
- chrome: Object.fromEntries(Object.entries(t.chrome).map(([n, o]) => [n, o === !1 ? !1 : I(o)]))
1860
- } : {}
1861
- })), lo = (e, t = {}) => {
1862
- const n = no(e);
1863
- return {
1864
- extensions: e.extensions,
1865
- commands: e.commands,
1866
- menuContributions: e.menuContributions,
1867
- commandPaletteContributions: e.commandPaletteContributions,
1868
- modes: co(e),
1869
- pages: eo(e, t.createTab),
1870
- placements: e.placements.map((o) => ({
1871
- id: o.id,
1872
- ref: {
1873
- extensionId: o.extensionId,
1874
- kind: "placement",
1875
- id: o.localId
1876
- },
1877
- modeId: I(o.mode),
1878
- item: o.item,
1879
- region: o.region,
1880
- order: o.order,
1881
- movableTo: o.movableTo,
1882
- mountStrategy: o.mountStrategy,
1883
- hiddenByDefault: o.hiddenByDefault,
1884
- headerBorderBottom: o.headerBorderBottom,
1885
- tab: o.tab && t.createTab ? t.createTab({
1886
- ...o.tab,
1887
- extensionId: o.extensionId,
1888
- placementId: o.id
1889
- }) : void 0
1890
- })),
1891
- panels: n,
1892
- resourceKinds: e.resourceKinds.map((o) => ({
1893
- id: o.id,
1894
- extensionId: o.extensionId,
1895
- label: o.label,
1896
- icon: o.icon,
1897
- menuSlots: Object.fromEntries((o.menuSlots ?? []).map((r) => [r.id, {
1898
- placement: r.placement,
1899
- label: r.label,
1900
- external: r.access === "public",
1901
- order: r.order
1902
- }]))
1903
- })),
1904
- resourceHierarchyProviders: (e.resourceHierarchyProviders ?? []).map((o) => ({
1905
- id: o.id,
1906
- extensionId: o.extensionId,
1907
- resourceKind: o.resourceKind.id
1908
- })),
1909
- settingsSections: e.settingsSections ?? [],
1910
- settingsPanels: e.settingsPanels.flatMap((o) => {
1911
- const r = e.views.find((s) => s.id === I(o.view));
1912
- return r ? [{
1913
- id: o.id,
1914
- viewId: r.id,
1915
- extensionId: o.extensionId,
1916
- slotId: o.slot.id,
1917
- scope: o.slot.id.includes("global") ? "global" : "project",
1918
- title: r.title,
1919
- icon: r.icon,
1920
- section: o.section ? I(o.section) : void 0
1921
- }] : [];
1922
- }),
1923
- kanbanRenderers: oo(e),
1924
- dataTableRenderers: so(e),
1925
- commandPaletteResources: e.commandPaletteResources ?? [],
1926
- treeRenderers: ro(e),
1927
- fileRenderers: io(e),
1928
- controlsRenderers: ao(e),
1929
- keybindings: e.keybindings ?? [],
1930
- settingsDefinitions: e.settingsDefinitions ?? [],
1931
- statuses: e.statuses,
1932
- statusBarItems: e.statusBarItems.map((o) => ({
1933
- id: o.id,
1934
- extensionId: o.extensionId,
1935
- viewId: I(o.view),
1936
- slot: o.slot.id.endsWith("leading") ? "leading" : "trailing",
1937
- order: o.order,
1938
- when: qe(o.when)
1939
- })),
1940
- diagnostics: e.diagnostics
1941
- };
1942
- }, mo = (e, t, n = {}) => {
1943
- e.views.refreshView(t.id, t.kind === "file" ? n : void 0);
1944
- }, uo = (e) => {
1945
- const t = /* @__PURE__ */ new Map(), n = (o, r) => {
1946
- for (const s of new Set(r.refreshEventIds ?? [])) {
1947
- const i = t.get(s) ?? [];
1948
- i.some((a) => a.kind === o && a.id === r.id) || i.push({
1949
- id: r.id,
1950
- kind: o
1951
- }), t.set(s, i);
1952
- }
1953
- };
1954
- for (const o of e.views)
1955
- o.body.kind !== "webview" && n(o.body.kind, {
1956
- id: o.id,
1957
- refreshEventIds: o.body.refreshEventIds
1958
- });
1959
- return t;
1960
- }, po = (e) => {
1961
- const t = uo(e.metadata);
1962
- return e.subscribe((n) => {
1963
- const {
1964
- id: o,
1965
- ...r
1966
- } = n;
1967
- for (const s of t.get(o) ?? []) mo(e.workbench, s, r);
1968
- });
1969
- }, Go = (e, t) => {
1970
- for (const n of t.views)
1971
- n.body.kind === "webview" && e.views.getView(n.id) && e.views.refreshView(n.id);
1972
- }, bo = (e) => (t) => ({
1973
- ...Pt({
1974
- workbench: t.workbench,
1975
- placement: t.placement,
1976
- hostEvents: t.hostEvents
1977
- }),
1978
- "navigation.open": (o) => {
1979
- const r = o;
1980
- if (!r.target) throw new Error("navigation.open requires a target.");
1981
- return t.workbench.navigation.openTarget(H(r.target, {
1982
- extensionId: e.extensionIdForWebview(t.webviewId)
1983
- }));
1984
- },
1985
- "commands.execute": async (o) => {
1986
- const r = o, s = r.resource ?? t.placement.resource;
1987
- return e.executeCommand(r.commandId, {
1988
- projectId: e.projectId,
1989
- ...r.params ? {
1990
- params: r.params
1991
- } : {},
1992
- ...s ? {
1993
- resource: s
1994
- } : {},
1995
- slot: O({
1996
- id: t.webviewId,
1997
- kind: e.slotKind,
1998
- projectId: e.projectId,
1999
- context: {
2000
- panelId: t.webviewId
2001
- }
2002
- }),
2003
- source: "dashboard"
2004
- });
2005
- },
2006
- ...e.files ? {
2007
- "files.upload": e.files.upload,
2008
- "files.list": e.files.list,
2009
- "files.delete": e.files.delete
2010
- } : {},
2011
- ...e.artifacts ? {
2012
- // The image-url grant is bound to the requesting webview, so the host
2013
- // resolves the webview id instead of trusting the guest to name one.
2014
- "artifacts.read": (o) => e.artifacts.read(o, {
2015
- webviewId: t.webviewId
2016
- })
2017
- } : {}
2018
- }), fo = (e) => ({
2019
- title: b(e.title) || void 0,
2020
- runtimeUrl: e.runtimeUrl,
2021
- moduleUrl: e.moduleUrl,
2022
- styles: e.styles,
2023
- capabilities: e.capabilities
2024
- }), Qe = "extensions", ho = 1e3, go = 25, wo = (e) => e === void 0 ? void 0 : e, Io = (e) => e === "global" ? "user" : "project", yo = (e, t) => t ? (n) => ({
2025
- ...e(n),
2026
- ...t(n)
2027
- }) : e, vo = (e, t) => {
2028
- const n = e.createWebviewHostCapabilities ?? bo({
2029
- artifacts: e.webviewArtifacts,
2030
- executeCommand: e.executeCommand,
2031
- extensionIdForWebview: (o) => e.metadata.panels.find((r) => r.id === o)?.extensionId,
2032
- files: e.webviewFiles,
2033
- projectId: e.projectId,
2034
- slotKind: t
2035
- });
2036
- return yo(n, e.createWebviewHostCapabilityOverrides);
2037
- }, ko = (e) => e.metadata.panels.flatMap((t) => {
2038
- if (!t.webview) return [];
2039
- const n = fo(t.webview);
2040
- return [e.workbench.views.registerView({
2041
- id: t.id,
2042
- title: b(t.title, t.id),
2043
- icon: t.icon,
2044
- body: {
2045
- kind: "react",
2046
- render: (o) => {
2047
- const r = e.metadata.settingsPanels.some((s) => s.id === o.instance.panelId && s.viewId === t.id) ? "settings" : "panel";
2048
- return e.renderWebview?.(o) ?? Mt({
2049
- context: {
2050
- workbench: o.workbench,
2051
- webviewId: t.id,
2052
- placement: o.instance,
2053
- hostEvents: Wt(o.workbench, o.instance)
2054
- },
2055
- createHostCapabilities: vo(e, r),
2056
- createProps: e.createWebviewProps ?? (({
2057
- placement: s
2058
- }) => ({
2059
- placement: s,
2060
- resource: s.resource
2061
- })),
2062
- createTheme: e.createWebviewTheme,
2063
- ownerId: t.extensionId,
2064
- title: b(t.title, t.id),
2065
- webview: n
2066
- });
2067
- }
2068
- }
2069
- })];
2070
- }), xo = {
2071
- first: 1e6,
2072
- default: 0,
2073
- last: -1e6
2074
- }, Ro = (e) => e.metadata.panels.flatMap((t) => t.panelMenus ?? []).map((t, n) => e.workbench.viewMenus.registerViewMenu({
2075
- id: t.id,
2076
- ownerViewId: t.ownerPanelId,
2077
- viewId: t.viewId,
2078
- side: t.side,
2079
- priority: xo[t.placement ?? "default"] - n
2080
- })), Ce = (e) => {
2081
- if (!e || typeof e != "object" || !("statuses" in e) || !Array.isArray(e.statuses))
2082
- throw new Error("Status provider returned an invalid response");
2083
- return e.statuses;
2084
- }, Eo = (e, t) => {
2085
- const n = e.metadata.statuses ?? [];
2086
- if (n.length === 0) return [];
2087
- const o = "workbench.extension-statuses.settings", r = n.map((s, i) => e.workbench.statuses.registerStatusSet({
2088
- id: s.id,
2089
- title: b(s.title, s.id),
2090
- actions: s.actions?.map((a) => ({
2091
- id: a.id,
2092
- label: b(a.label, a.id),
2093
- icon: a.icon
2094
- })),
2095
- query: async () => Ce(await E(t, s.queryHandlerId, {
2096
- params: {}
2097
- })),
2098
- save: s.saveHandlerId ? async (a) => Ce(await E(t, s.saveHandlerId, {
2099
- params: {
2100
- statuses: a
2101
- }
2102
- })) : void 0
2103
- }, {
2104
- ownerId: s.extensionId,
2105
- priority: -i
2106
- }));
2107
- return r.push(e.workbench.views.registerView({
2108
- id: o,
2109
- title: "Statuses",
2110
- body: {
2111
- kind: "react",
2112
- render: () => D(at, {
2113
- workbench: e.workbench
2114
- })
2115
- }
2116
- })), r.push(e.workbench.settings.registerPanel({
2117
- id: "workbench.statuses",
2118
- title: "Statuses",
2119
- icon: "list-checks",
2120
- kind: "view",
2121
- order: go,
2122
- section: e.settingsSectionId ?? Qe,
2123
- scope: "project",
2124
- viewId: o
2125
- })), r;
2126
- }, Ao = (e) => {
2127
- const t = [], n = e.settingsSectionId ?? Qe;
2128
- e.workbench.settings.getSection(n) || t.push(e.workbench.settings.registerSection({
2129
- id: n,
2130
- title: e.settingsSectionTitle ?? "Extensions"
2131
- }));
2132
- const o = [...e.metadata.settingsSections].sort((i, a) => (i.order ?? 0) - (a.order ?? 0) || i.extensionId.localeCompare(a.extensionId) || i.id.localeCompare(a.id));
2133
- for (const i of o)
2134
- t.push(e.workbench.settings.registerSection({
2135
- id: i.id,
2136
- title: b(i.title, i.id),
2137
- order: i.order,
2138
- scope: i.scope
2139
- }));
2140
- const r = Object.fromEntries((e.metadata.settingsDefinitions ?? []).map((i) => [i.key, {
2141
- type: i.type,
2142
- scope: Io(i.scope),
2143
- default: wo(i.default),
2144
- enum: i.enum,
2145
- description: b(i.description)
2146
- }]));
2147
- Object.keys(r).length > 0 && t.push(e.workbench.preferences.registerSchema({
2148
- properties: r
2149
- }));
2150
- const s = [...e.metadata.settingsPanels].sort((i, a) => i.extensionId.localeCompare(a.extensionId) || i.id.localeCompare(a.id));
2151
- for (const [i, a] of s.entries())
2152
- t.push(e.workbench.settings.registerPanel({
2153
- id: a.id,
2154
- title: b(a.title, a.id),
2155
- icon: a.icon,
2156
- kind: "view",
2157
- order: ho + i,
2158
- section: a.section ?? n,
2159
- scope: a.scope,
2160
- viewId: a.viewId
2161
- }));
2162
- return t;
2163
- }, B = (e) => !!(e && typeof e == "object" && !Array.isArray(e)), Co = (e, t) => {
2164
- if (!B(e)) return {};
2165
- const n = B(e.indicator) ? {
2166
- icon: String(e.indicator.icon ?? ""),
2167
- color: typeof e.indicator.color == "string" ? e.indicator.color : void 0,
2168
- label: b(e.indicator.label)
2169
- } : void 0, o = Array.isArray(e.menu) ? e.menu.flatMap((r) => !B(r) || typeof r.id != "string" || !Array.isArray(r.rows) ? [] : [{
2170
- id: r.id,
2171
- rows: r.rows.flatMap((s) => {
2172
- if (!B(s) || typeof s.id != "string") return [];
2173
- const i = me(s.action, {
2174
- extensionId: t
2175
- });
2176
- return [{
2177
- id: s.id,
2178
- label: b(s.label, s.id),
2179
- icon: typeof s.icon == "string" ? s.icon : void 0,
2180
- iconColor: typeof s.iconColor == "string" ? s.iconColor : void 0,
2181
- selected: s.selected === !0,
2182
- disabled: s.disabled === !0,
2183
- action: i ? {
2184
- kind: "navigation",
2185
- target: i
2186
- } : void 0
2187
- }];
2188
- })
2189
- }]) : void 0;
2190
- return {
2191
- label: b(e.label),
2192
- icon: typeof e.icon == "string" ? e.icon : void 0,
2193
- indicator: n?.icon ? n : void 0,
2194
- menu: o
2195
- };
2196
- }, So = (e, t) => {
2197
- const n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = new Set(t.refreshEventIds ?? []), i = (a) => {
2198
- if (o.has(a.instanceId)) return;
2199
- o.add(a.instanceId);
2200
- const d = a.resource ? {
2201
- type: a.resource.type,
2202
- id: a.resource.id ?? V(a.resource),
2203
- label: a.resource.label,
2204
- metadata: a.resource.metadata
2205
- } : void 0;
2206
- Promise.resolve(e.executeCommand(t.queryHandlerId, {
2207
- projectId: e.projectId,
2208
- source: "dashboard",
2209
- resource: d,
2210
- params: {
2211
- renderer: {
2212
- rendererId: t.placementId,
2213
- projectId: e.projectId,
2214
- ...d ? {
2215
- resource: d
2216
- } : {},
2217
- invocation: {
2218
- placement: "visible"
2219
- }
2220
- }
2221
- }
2222
- })).then((m) => {
2223
- const l = B(m) && B(m.outcome) ? m.outcome.value : m;
2224
- n.set(a.instanceId, Co(l, t.extensionId));
2225
- for (const c of r) c();
2226
- }).finally(() => o.delete(a.instanceId));
2227
- };
2228
- return {
2229
- refreshEvents: t.refreshEventIds,
2230
- getSnapshot(a) {
2231
- return i(a), n.get(a.instanceId) ?? {};
2232
- },
2233
- subscribe(a) {
2234
- r.add(a);
2235
- const d = e.subscribeRefreshEvents?.((l) => {
2236
- s.has(l.id) && (n.clear(), a());
2237
- });
2238
- return {
2239
- dispose() {
2240
- r.delete(a), d?.dispose();
2241
- }
2242
- };
2243
- }
2244
- };
2245
- }, Se = (e) => {
2246
- for (let t = e.length - 1; t >= 0; t -= 1) e[t]?.dispose();
2247
- }, pe = (e) => e && typeof e == "object" && !Array.isArray(e) ? e : void 0, be = (e, t, n, o, r) => e.prepareCommandArgs?.(t, n, o, r) ?? n, To = (e, t) => t.commands.map((n) => e.workbench.commands.registerCommand({
2248
- id: n.id,
2249
- label: b(n.title, n.id),
2250
- description: b(n.description),
2251
- params: n.params
443
+ var P = l, F = (e, t = {}) => {
444
+ if (e != null) {
445
+ if (!P(e)) throw Error("Renderer callback returned an invalid navigation target.");
446
+ return N(e, t);
447
+ }
448
+ }, Te = (e) => {
449
+ let t = e;
450
+ if (!t?.outcome) return e;
451
+ if (t.outcome.status === "success") return t.outcome.value;
452
+ throw Error(t.outcome.reason ?? t.outcome.error?.message ?? "Extension command failed.");
453
+ }, I = (e) => ({
454
+ id: e.id,
455
+ kind: e.kind,
456
+ context: {
457
+ projectId: e.projectId,
458
+ ...e.context ?? {}
459
+ }
460
+ }), Ee = (e) => typeof e == "object" && !!e && !Array.isArray(e), De = (e) => {
461
+ if (Ee(e) && e.deleted === !0) return typeof e.id == "string" ? e.id : void 0;
462
+ }, Oe = async (e, t, n) => {
463
+ if (!t || De(n) !== (t.id ?? f(t)) || f(e.workbench.getPrimaryResource()) !== f(t)) return;
464
+ let r = e.workbench.pageLocations.navigateToParent();
465
+ if (!r.ok) throw Error(r.diagnostic.message);
466
+ }, L = async (e, t, n = {}) => {
467
+ let r = n.resource, i = await e.executeCommand(t, {
468
+ projectId: e.projectId,
469
+ ...n.workspaceId ? { workspaceId: n.workspaceId } : {},
470
+ ...n.params ? { params: n.params } : {},
471
+ ...r ? { resource: r } : {},
472
+ ...n.slot ? { slot: n.slot } : {},
473
+ source: "dashboard",
474
+ ...n.metadata ? { metadata: n.metadata } : {}
475
+ });
476
+ Te(i);
477
+ let a = i?.outcome;
478
+ if (a?.status === "success") for (let t of a.navigationRequests ?? []) try {
479
+ await e.workbench.navigation.openTarget(N(t));
480
+ } catch (t) {
481
+ e.workbench.notifications.show({
482
+ level: "warning",
483
+ title: "Command completed, but navigation failed",
484
+ message: t instanceof Error ? t.message : String(t)
485
+ });
486
+ }
487
+ return i;
488
+ }, R = async (e, t, n = {}) => {
489
+ let r = Te(await L(e, t, n));
490
+ return await Oe(e, n.resource, r), r;
491
+ }, ke = (e) => typeof e == "object" && !!e && !Array.isArray(e), Ae = (e, t) => `${e.extensionId ?? t}.command.${e.id}`, je = async (e, t, n) => {
492
+ let { target: r } = n;
493
+ if (r.kind === "command") {
494
+ await R(e, Ae(r.target.command, t.extensionId), { params: r.target.params }), e.workbench.commandPaletteResources.refresh();
495
+ return;
496
+ }
497
+ await e.workbench.navigation.openTarget(N(r, { extensionId: t.extensionId }));
498
+ }, Me = (e, t, n, r) => ({
499
+ id: `${t.id}:${r.id}`,
500
+ label: r.label,
501
+ description: r.description,
502
+ icon: r.icon,
503
+ keywords: r.keywords,
504
+ group: n,
505
+ activate: () => je(e, t, r)
506
+ }), Ne = (e, t) => {
507
+ let n = [];
508
+ for (let r of t) {
509
+ let t = M(r.title, r.id);
510
+ n.push(e.workbench.commandPaletteResources.registerProvider({
511
+ id: r.id,
512
+ title: t,
513
+ refreshEventIds: r.refreshEventIds,
514
+ query: async ({ query: n, limit: i }) => {
515
+ let a = e.workbench.getActiveResource(), o = await R(e, r.queryHandlerId, { params: {
516
+ projectId: e.projectId,
517
+ modeId: e.workbench.modes.getActiveModeId(),
518
+ activeResource: a,
519
+ providerId: r.id,
520
+ query: n,
521
+ limit: i
522
+ } });
523
+ return ke(o) ? (o.items ?? []).map((n) => Me(e, r, t, n)) : [];
524
+ }
525
+ }));
526
+ }
527
+ return { dispose() {
528
+ for (let e = n.length - 1; e >= 0; --e) n[e]?.dispose();
529
+ } };
530
+ }, z = (e, t = "") => M(e, t), Pe = (e, t, r) => {
531
+ let i = I({
532
+ id: t.id,
533
+ kind: "renderer",
534
+ projectId: e.projectId,
535
+ context: { controlsRendererId: t.id }
536
+ }), a = (n, r, a) => n ? R(e, n, {
537
+ params: {
538
+ renderer: {
539
+ rendererId: t.id,
540
+ projectId: e.projectId,
541
+ ...a ? { resource: a } : {},
542
+ invocation: { placement: "visible" }
543
+ },
544
+ ...r
545
+ },
546
+ resource: a,
547
+ slot: i,
548
+ metadata: { controlsRendererId: t.id }
549
+ }) : Promise.resolve(void 0);
550
+ return e.workbench.views.registerView({
551
+ id: t.id,
552
+ title: z(t.title, t.id),
553
+ icon: t.icon,
554
+ body: {
555
+ kind: "controls",
556
+ emptyTitle: z(t.emptyTitle, ""),
557
+ emptyDescription: z(t.emptyDescription, ""),
558
+ defaultValues: t.defaultValues,
559
+ executeQuery: async (e) => {
560
+ let i = await a(t.queryHandlerId, {}, e ?? r.resolveResource?.(t)), o = n.safeParse(i);
561
+ if (!o.success) {
562
+ let e = o.error.issues.map((e) => `body.query.${e.path.join(".")}: ${e.message}`).join("; ");
563
+ throw Error(`Extension "${t.extensionId}" view "${t.id}" has invalid controls. Expected serializable control declarations. ${e}`);
564
+ }
565
+ return o.data;
566
+ },
567
+ updateValue: t.valueChangeHandlerId ? ({ controlId: e, value: n, values: r, resource: i }) => a(t.valueChangeHandlerId, {
568
+ controlId: e,
569
+ value: n,
570
+ values: r
571
+ }, i).then(() => void 0) : void 0,
572
+ apply: t.applyHandlerId ? ({ values: e, resource: n }) => a(t.applyHandlerId, { values: e }, n).then(() => void 0) : void 0,
573
+ reset: t.resetHandlerId ? ({ controlIds: e, resource: n }) => a(t.resetHandlerId, { controlIds: e }, n).then(() => void 0) : void 0
574
+ }
575
+ });
576
+ }, Fe = (e, t, n = {}) => {
577
+ let r = [];
578
+ for (let i of t) r.push(Pe(e, i, n));
579
+ return { dispose() {
580
+ for (let e = r.length - 1; e >= 0; --e) r[e]?.dispose();
581
+ } };
582
+ }, B = (e, t = "") => M(e, t), Ie = (e) => ({
583
+ ...e,
584
+ label: B(e.label, e.id),
585
+ description: e.description ? B(e.description) : void 0,
586
+ icon: e.icon ? h(r, {
587
+ name: e.icon,
588
+ size: 14
589
+ }) : void 0
590
+ }), Le = (e) => !!(e && typeof e == "object" && Array.isArray(e.rows)), Re = (e) => ({
591
+ id: e.id,
592
+ values: e.values,
593
+ resource: e.resource ? e.resource : void 0
594
+ }), ze = (e, t) => {
595
+ let n = /* @__PURE__ */ new WeakMap(), i = I({
596
+ id: t.id,
597
+ kind: "dataTableRenderer",
598
+ projectId: e.projectId,
599
+ context: { dataTableRendererId: t.id }
600
+ }), a = (n, r, a, o) => R(e, n, {
601
+ params: {
602
+ renderer: {
603
+ rendererId: t.id,
604
+ projectId: e.projectId,
605
+ ...o ? { modeId: o } : {},
606
+ ...a ? { resource: a } : {},
607
+ invocation: { placement: "visible" }
608
+ },
609
+ ...r
610
+ },
611
+ resource: a,
612
+ slot: i,
613
+ metadata: { dataTableRendererId: t.id }
614
+ });
615
+ return e.workbench.views.registerView({
616
+ id: t.id,
617
+ title: B(t.title, t.id),
618
+ icon: t.icon,
619
+ body: {
620
+ kind: "dataTable",
621
+ resourceKind: t.resourceKind,
622
+ columns: t.columns?.map(Ie),
623
+ initialPageSize: t.initialPageSize,
624
+ pageSizeOptions: t.pageSizeOptions,
625
+ selectionMode: t.selectionMode,
626
+ selectionActions: t.selectionActions?.map((e) => ({
627
+ id: e.id,
628
+ label: B(e.label, e.id),
629
+ icon: e.icon ? h(r, {
630
+ name: e.icon,
631
+ size: 16
632
+ }) : void 0,
633
+ destructive: e.destructive,
634
+ run: (t) => a(e.commandId, { rowIds: t.map((e) => e.id) }).then(() => void 0)
635
+ })),
636
+ emptyTitle: t.emptyTitle ? B(t.emptyTitle) : void 0,
637
+ emptyDescription: t.emptyDescription ? B(t.emptyDescription) : void 0,
638
+ executeQuery: async ({ resource: e, modeId: r }) => {
639
+ let i = await a(t.queryHandlerId, {}, e, r);
640
+ return Le(i) ? {
641
+ rows: i.rows.map((e) => {
642
+ let t = Re(e);
643
+ return n.set(t, e), t;
644
+ }),
645
+ columns: i.columns?.map(Ie)
646
+ } : { rows: [] };
647
+ },
648
+ rowActions: t.rowActions?.map((n) => ({
649
+ id: n.id,
650
+ label: B(n.label, n.id),
651
+ icon: n.icon ? h(r, {
652
+ name: n.icon,
653
+ size: 16
654
+ }) : void 0,
655
+ destructive: n.destructive,
656
+ run: async (r) => {
657
+ await a(n.commandId, { rowId: r.id }, r.resource), e.workbench.views.refreshView(t.id);
658
+ }
659
+ })),
660
+ onRowActivate: t.rowActivationHandlerId ? async (r) => {
661
+ let i = F(await a(t.rowActivationHandlerId, { row: n.get(r) ?? r }, r.resource), { extensionId: t.extensionId });
662
+ i && await e.workbench.navigation.openTarget(i);
663
+ } : void 0
664
+ }
665
+ });
666
+ }, Be = (e, t) => {
667
+ let n = t.map((t) => ze(e, t));
668
+ return { dispose() {
669
+ for (let e = n.length - 1; e >= 0; --e) n[e]?.dispose();
670
+ } };
671
+ }, Ve = {
672
+ first: 0,
673
+ default: 1,
674
+ last: 2
675
+ }, He = {
676
+ commands: [],
677
+ commandPaletteContributions: [],
678
+ diagnostics: [],
679
+ extensions: [],
680
+ menuContributions: [],
681
+ modes: [],
682
+ pages: [],
683
+ views: [],
684
+ viewMenus: [],
685
+ placements: [],
686
+ resourceKinds: [],
687
+ navigationItems: [],
688
+ navigationTrees: [],
689
+ statusBarItems: [],
690
+ statuses: [],
691
+ settingsPanels: [],
692
+ settingsDefinitions: []
693
+ }, Ue = (e) => `workbench.extension.menu.${e.id}`, We = (e) => `workbench.extension.palette.${e.id}`, Ge = (e, t) => Ve[e.placement ?? "default"] * 1e3 + t, Ke = (e) => e === void 0 ? "" : c(e) ? e.default ?? e.$l10n : e, qe = (e) => {
694
+ let { commandId: t, contribution: n, index: r, resolveString: i, slot: a, when: o } = e;
695
+ return {
696
+ commandId: t,
697
+ sourceCommandId: n.commandId,
698
+ label: i(n.label, n.extensionId),
699
+ icon: n.icon,
700
+ group: a.group ?? n.group,
701
+ args: n.params,
702
+ overflowLabel: a.overflowLabel,
703
+ order: Ge(n, r),
704
+ when: o
705
+ };
706
+ }, Je = (e) => {
707
+ let { commandId: t, contribution: n, index: r, resolveString: i } = e;
708
+ return {
709
+ commandId: t,
710
+ label: i(n.label, n.extensionId),
711
+ icon: n.icon,
712
+ group: n.group,
713
+ args: n.params,
714
+ order: Ge(n, r)
715
+ };
716
+ }, Ye = (e) => {
717
+ let { createCommandId: t = Ue, createWhenExpression: n, menuSlotsById: r, menuTargetsById: i, metadata: a, resolveString: o = Ke } = e, s = [], c = [];
718
+ return a.menuContributions.forEach((e, l) => {
719
+ let u = e.target ? i?.get(e.target) : r.get(e.slotId);
720
+ if (!u) {
721
+ c.push({
722
+ contribution: e,
723
+ targetId: e.target ?? e.slotId
724
+ });
725
+ return;
726
+ }
727
+ let d = t(e), f = a.commands.find((t) => t.id === e.commandId);
728
+ s.push({
729
+ command: {
730
+ id: d,
731
+ label: o(e.label, e.extensionId),
732
+ category: e.group,
733
+ description: f ? o(f.description, f.extensionId) : void 0,
734
+ icon: e.icon,
735
+ params: f?.params
736
+ },
737
+ contribution: e,
738
+ menuItem: qe({
739
+ commandId: d,
740
+ contribution: e,
741
+ index: l,
742
+ resolveString: o,
743
+ slot: u,
744
+ when: n?.(e)
745
+ }),
746
+ menuPath: u.menuPath,
747
+ targetCommandId: e.commandId
748
+ });
749
+ }), {
750
+ registrations: s,
751
+ unresolved: c
752
+ };
753
+ }, Xe = (e) => {
754
+ let { createCommandId: t = We, metadata: n, resolveString: r = Ke } = e, i = [];
755
+ return (n.commandPaletteContributions ?? []).forEach((e, a) => {
756
+ let o = t(e), s = n.commands.find((t) => t.id === e.commandId);
757
+ i.push({
758
+ command: {
759
+ id: o,
760
+ label: r(e.label, e.extensionId),
761
+ category: e.group,
762
+ description: s ? r(s.description, s.extensionId) : void 0,
763
+ icon: e.icon,
764
+ params: s?.params
765
+ },
766
+ contribution: e,
767
+ menuItem: Je({
768
+ commandId: o,
769
+ contribution: e,
770
+ index: a,
771
+ resolveString: r
772
+ }),
773
+ targetCommandId: e.commandId
774
+ });
775
+ }), i;
776
+ }, Ze = (e) => ({
777
+ id: e.rendererId,
778
+ kind: "renderer",
779
+ context: {
780
+ projectId: e.projectId,
781
+ ...e.resource ? {
782
+ resourceType: e.resource.type,
783
+ resourceId: e.resource.id
784
+ } : {}
785
+ }
786
+ }), Qe = async (e, t, n, r, i = {}, a) => {
787
+ let o = r;
788
+ return R(e, n, {
789
+ params: {
790
+ renderer: {
791
+ rendererId: t,
792
+ projectId: e.projectId,
793
+ ...o ? { resource: o } : {},
794
+ invocation: { placement: "visible" }
795
+ },
796
+ ...i
797
+ },
798
+ resource: o,
799
+ slot: Ze({
800
+ projectId: e.projectId,
801
+ rendererId: t,
802
+ resource: o
803
+ }),
804
+ ...a ? { metadata: a } : {}
805
+ });
806
+ }, $e = (e) => {
807
+ if (!e || typeof e != "object") return;
808
+ let t = e.revision;
809
+ return typeof t == "string" ? t : void 0;
810
+ }, et = (e, t) => {
811
+ let n = e.metadata, r = n?.fileRendererOrigin;
812
+ if (!r || typeof r != "object") return;
813
+ let i = r;
814
+ if (typeof i.rendererId != "string" || typeof i.instanceId != "string" || typeof i.operationId != "string") return;
815
+ let a = n?.fileRendererResourceKey, o = $e(t.outcome.value);
816
+ return {
817
+ origin: {
818
+ rendererId: i.rendererId,
819
+ instanceId: i.instanceId,
820
+ operationId: i.operationId
821
+ },
822
+ ...typeof a == "string" ? { resourceKey: a } : {},
823
+ ...o ? { revision: o } : {}
824
+ };
825
+ }, tt = (e, t) => e.workbench.views.registerView({
826
+ id: t.id,
827
+ title: M(t.title, t.id),
828
+ icon: t.icon,
829
+ body: {
830
+ kind: "file",
831
+ resourceKind: t.resourceKind,
832
+ load: async (n) => await Qe(e, t.id, t.loadHandlerId, n) ?? {},
833
+ save: t.saveHandlerId ? async (n, r, i) => {
834
+ let a = $e(await Qe(e, t.id, t.saveHandlerId, n, { content: r }, {
835
+ ...i ? { fileRendererOrigin: i } : {},
836
+ ...f(n) ? { fileRendererResourceKey: f(n) } : {}
837
+ }));
838
+ return a ? { revision: a } : void 0;
839
+ } : void 0
840
+ }
841
+ }), nt = (e) => {
842
+ let t = [];
843
+ for (let n of e.metadata.fileRenderers ?? []) t.push(tt(e, n));
844
+ return { dispose() {
845
+ for (let e = t.length - 1; e >= 0; --e) t[e]?.dispose();
846
+ } };
847
+ }, rt = (e) => (t) => h(r, {
848
+ name: e ?? "MoreHorizontal",
849
+ ...t
850
+ }), it = (e, t) => ({
851
+ color: e?.color,
852
+ canDragIn: e?.canDragIn,
853
+ canDragOut: e?.canDragOut,
854
+ canCreate: e?.canCreate,
855
+ actions: e?.actions?.map((e) => ({
856
+ id: e.id,
857
+ label: t(e.label, e.id),
858
+ icon: rt(e.icon)
859
+ }))
860
+ }), at = (e, t) => `${t.extensionId ?? e.extensionId}.status.${t.id}`, ot = (e, t) => {
861
+ let n = /* @__PURE__ */ new Map();
862
+ return (r) => {
863
+ let i = at(t, r), a = n.get(i);
864
+ if (a) return a;
865
+ let o = {
866
+ getSnapshot: () => (e.workbench.statuses.getStatuses(i) ?? []).map((e) => ({
867
+ value: e.id,
868
+ label: e.label,
869
+ color: e.color,
870
+ icon: e.icon
871
+ })),
872
+ subscribe: (t) => e.workbench.statuses.store.subscribeSelector((e) => e.values[i], t)
873
+ };
874
+ return n.set(i, o), e.workbench.statuses.load(i).catch(() => void 0), o;
875
+ };
876
+ }, st = (e, t, n, r, i) => {
877
+ let a = n?.find((e) => e.id === r);
878
+ if (a?.type.kind !== "status") return;
879
+ let o = at(t, a.type.statuses), s = e.workbench.statuses.getStatuses(o)?.find((e) => e.id === i);
880
+ return s ? { color: s.color } : void 0;
881
+ }, ct = (e) => {
882
+ if (e.defaultSettings?.columnGrouping) return e.defaultSettings.columnGrouping;
883
+ let t = e.attributes?.filter((e) => e.type.kind === "status") ?? [];
884
+ return t.length === 1 ? t[0]?.id : void 0;
885
+ }, lt = (e) => typeof e == "object" && !!e && !Array.isArray(e), ut = (e, t, n, r, i, a) => (t ?? []).map((t) => {
886
+ let o = t.display, s = o?.kind === "badge-list" && typeof o.itemsAttributeId == "string" ? {
887
+ kind: "badge-list",
888
+ itemsAttributeId: o.itemsAttributeId
889
+ } : void 0;
890
+ return o && !s && a?.(t.id, o.kind), r(e, {
891
+ ...t,
892
+ label: n(t.label, t.id),
893
+ type: t.type.kind === "status" ? {
894
+ kind: "enum",
895
+ options: i(t.type.statuses)
896
+ } : t.type.kind === "enum" || t.type.kind === "enum-multi" ? {
897
+ ...t.type,
898
+ options: Array.isArray(t.type.options) ? t.type.options.map((e) => ({
899
+ ...e,
900
+ label: n(e.label, e.value)
901
+ })) : t.type.options
902
+ } : t.type,
903
+ display: s
904
+ });
905
+ }), dt = (e, t, n, r, i = () => [], a) => {
906
+ let o = ut(e, t, n, r, i, a), s = /* @__PURE__ */ new Set();
907
+ return {
908
+ source: {
909
+ getSnapshot: () => o,
910
+ subscribe: (e) => (s.add(e), () => s.delete(e))
911
+ },
912
+ set(t) {
913
+ o = ut(e, t, n, r, i, a);
914
+ for (let e of s) e();
915
+ }
916
+ };
917
+ }, ft = (e) => !!(e && typeof e == "object" && typeof e.type == "string" && typeof e.id == "string"), pt = (e, t) => {
918
+ let { resource: n } = t;
919
+ if (ft(n)) return n;
920
+ }, mt = (e, t) => {
921
+ let n = pt(e, t);
922
+ if (n) return n;
923
+ if (e.resourceKind) return {
924
+ type: e.resourceKind,
925
+ id: t.id,
926
+ label: t.title
927
+ };
928
+ }, ht = (e, t) => {
929
+ let n = e, r = t(n);
930
+ return r === void 0 ? n : {
931
+ ...n,
932
+ resource: r
933
+ };
934
+ }, gt = (...e) => Object.assign({}, ...e.filter((e) => !!e)), _t = (e) => e && typeof e == "object" && !Array.isArray(e) ? e : void 0, vt = (e) => Object.keys(e ?? {}).length > 0, yt = /* @__PURE__ */ new Set([
935
+ "text",
936
+ "longtext",
937
+ "markdown",
938
+ "number",
939
+ "boolean",
940
+ "select",
941
+ "multi-select",
942
+ "files"
943
+ ]), bt = (e, t, n) => {
944
+ if (!yt.has(t.type)) return;
945
+ let r = "options" in t && Array.isArray(t.options) ? t.options : [], i = t;
946
+ return {
947
+ id: e,
948
+ label: n(t.label, e),
949
+ description: t.description === void 0 ? void 0 : n(t.description),
950
+ placeholder: i.placeholder === void 0 ? void 0 : n(i.placeholder),
951
+ type: t.type,
952
+ required: t.required === !0,
953
+ defaultValue: t.defaultValue,
954
+ options: t.type === "select" || t.type === "multi-select" ? r.map((e) => ({
955
+ value: e.value,
956
+ label: n(e.label, e.value),
957
+ icon: e.icon
958
+ })) : void 0,
959
+ multiple: t.type === "files" ? i.multiple !== !1 : void 0,
960
+ accept: t.type === "files" && typeof i.accept == "string" ? i.accept : void 0
961
+ };
962
+ }, xt = (e, t) => Object.entries(e.createRow?.params ?? {}).flatMap(([e, n]) => {
963
+ let r = bt(e, n, t);
964
+ return r ? [r] : [];
965
+ }), St = (e, t) => I({
966
+ id: t.id,
967
+ kind: "kanbanRenderer",
968
+ projectId: e.projectId,
969
+ context: { kanbanRendererId: t.id }
970
+ }), V = (e, t, n, r, i) => {
971
+ let a = i ?? e.workbench.getPrimaryResource();
972
+ return R(e, n, {
973
+ params: {
974
+ renderer: {
975
+ rendererId: t.id,
976
+ projectId: e.projectId,
977
+ ...a ? { resource: a } : {},
978
+ invocation: { placement: "visible" }
979
+ },
980
+ ...r
981
+ },
982
+ resource: a,
983
+ slot: St(e, t),
984
+ metadata: { kanbanRendererId: t.id }
985
+ });
986
+ }, Ct = (e, t) => `workbench.extension.kanbanRenderer.${e.id}.rowAction.${t.id}`, wt = (e, t, n) => (t.rowActions ?? []).map((r) => {
987
+ let i = e.workbench.commands.getCommand(r.commandId)?.command;
988
+ return e.workbench.commands.registerCommand({
989
+ id: Ct(t, r),
990
+ label: n(r.label, r.id),
991
+ icon: r.icon,
992
+ params: i?.params
993
+ }, { execute: (n, i) => V(e, t, r.commandId, gt(_t(n)), i?.resource) });
994
+ }), Tt = (e, t, n, r, i, a) => {
995
+ let o = Ct(t, n), s = e.workbench.commands.getCommand(o), c = { rowId: r.id }, l = i ? { resource: i } : void 0, u = a(n.label, n.id);
996
+ return s && vt(s.command.params) ? (e.workbench.commandPalette.requestParams({
997
+ record: s,
998
+ label: u,
999
+ args: c,
1000
+ context: l
1001
+ }), Promise.resolve()) : s ? e.workbench.commands.executeCommand(s.command.id, c, l).then(() => void 0) : V(e, t, n.commandId, c, i).then(() => void 0);
1002
+ }, Et = (e) => e ? h(r, {
1003
+ name: e,
1004
+ size: 16
1005
+ }) : void 0, Dt = (e, t) => {
1006
+ if (e.createRow) return {
1007
+ title: t(e.createRow.title, "Create row"),
1008
+ submitLabel: t(e.createRow.submitLabel, "Create"),
1009
+ fields: xt(e, t),
1010
+ labels: {
1011
+ cancel: t(e.createRow.labels?.cancel, "Cancel"),
1012
+ properties: t(e.createRow.labels?.properties, "Properties"),
1013
+ submitError: t(e.createRow.labels?.submitError, "Could not create resource."),
1014
+ removeFile: t(e.createRow.labels?.removeFile, "Remove file")
1015
+ }
1016
+ };
1017
+ }, Ot = (e, t, n, r, i) => {
1018
+ if (t.rowActivationHandlerId) return async (n) => {
1019
+ let a = r(t, n), o = F(await V(e, t, t.rowActivationHandlerId, { row: i(n) }, a), { extensionId: t.extensionId });
1020
+ o && await e.workbench.navigation.openTarget(o);
1021
+ };
1022
+ if (n.onRowClick) return (e) => n.onRowClick?.({
1023
+ record: t,
1024
+ row: e,
1025
+ resource: r(t, e)
1026
+ });
1027
+ }, kt = (e, t, n, r) => {
1028
+ let i = e.createRow;
1029
+ if (i) return async (a) => {
1030
+ let o = gt(a.values, i.columnParam ? { [i.columnParam]: a.columnId } : void 0, i.attributesParam ? { [i.attributesParam]: a.attributeValues } : void 0), s = await n(e, i.commandId, o);
1031
+ if (await t.onAfterCreate?.({
1032
+ record: e,
1033
+ created: s,
1034
+ submission: a
1035
+ }), !r || typeof s != "object" || !s) return;
1036
+ let c = s;
1037
+ typeof c.id == "string" && typeof c.title == "string" && await r({
1038
+ ...c,
1039
+ id: c.id,
1040
+ title: c.title,
1041
+ attributes: c.attributes ?? {}
1042
+ });
1043
+ };
1044
+ }, At = (e, t, n, r, i) => {
1045
+ let a = t.rowActions;
1046
+ if (a?.length) return (o) => a.map((a) => {
1047
+ let s = i(t, o), c = () => Tt(e, t, a, o, s, r);
1048
+ return {
1049
+ key: a.id,
1050
+ label: r(a.label, a.id),
1051
+ commandId: a.commandId,
1052
+ icon: Et(a.icon),
1053
+ onClick: () => n.executeRowAction ? n.executeRowAction({
1054
+ record: t,
1055
+ action: a,
1056
+ row: o,
1057
+ resource: s,
1058
+ runDefault: c
1059
+ }) : c()
1060
+ };
1061
+ });
1062
+ }, jt = (e, t, n = {}) => {
1063
+ let r = [], i = n.resolveLabel ?? ((e, t) => M(e, t)), a = (e, t) => {
1064
+ let r = t.display?.kind === "badge-list" ? {
1065
+ ...t,
1066
+ render: (e, n) => v(t, e, n)
1067
+ } : t;
1068
+ return n.decorateAttribute?.(e, r) ?? r;
1069
+ }, o = n.resolveRowResource ?? pt, s = n.resolveRowActionResource ?? mt, c = n.onAfterMutation ?? (() => {}), l = (t, n, r) => V(e, t, n, r).then((e) => (c(t), e));
1070
+ for (let c of t) {
1071
+ let t = ot(e, c), u = dt(c, c.attributes, i, a, t, (t, n) => e.workbench.notifications.show({
1072
+ id: `workbench.extension.${c.extensionId}.kanban.${c.id}.display.${t}`,
1073
+ level: "error",
1074
+ title: "Extension display is not available",
1075
+ message: `Attribute "${t}" in renderer "${c.id}" uses unknown display kind "${n}".`
1076
+ })), d = c.attributes, f = ct(c), p = /* @__PURE__ */ new WeakMap(), m, h = 0, g = (e) => o(c, e), _ = Ot(e, c, n, o, (e) => p.get(e) ?? e);
1077
+ r.push(...wt(e, c, i)), r.push(e.workbench.views.registerView({
1078
+ id: c.id,
1079
+ title: i(c.title, c.id),
1080
+ icon: c.icon,
1081
+ body: {
1082
+ kind: "kanban",
1083
+ resourceKind: c.resourceKind,
1084
+ storageScope: e.projectId,
1085
+ attributes: u.source,
1086
+ defaultSettings: c.defaultSettings,
1087
+ defaultFilters: c.defaultFilters,
1088
+ defaultViews: c.defaultViews?.map((e) => ({
1089
+ ...e,
1090
+ title: i(e.title, e.id)
1091
+ })),
1092
+ defaultActiveViewId: c.defaultActiveViewId,
1093
+ emptyTitle: i(c.emptyTitle, ""),
1094
+ emptyDescription: i(c.emptyDescription, ""),
1095
+ hideToolbar: c.hideToolbar,
1096
+ createRow: Dt(c, i),
1097
+ getBoardColumnConfig: (t) => it(m?.[t] ?? st(e, c, d, f, t), i),
1098
+ onRowActivate: _,
1099
+ executeQuery: async (t) => {
1100
+ h += 1;
1101
+ let n = h, r = await V(e, c, c.queryHandlerId, {
1102
+ settings: t.settings,
1103
+ filters: t.filters
1104
+ }), i = (e) => e.map((e) => {
1105
+ let t = ht(e, g);
1106
+ return p.set(t, e), t;
1107
+ });
1108
+ if (n !== h) return Array.isArray(r) ? i(r) : lt(r) ? i(r.rows ?? []) : [];
1109
+ if (f = t.settings.columnGrouping, Array.isArray(r)) return i(r);
1110
+ if (!lt(r)) return [];
1111
+ let a = r.attributes ?? d;
1112
+ return d = a, u.set(a), m = r.boardColumnConfigs, i(r.rows ?? []);
1113
+ },
1114
+ onAttributeChange: c.attributeChangeHandlerId ? (e, t, n) => l(c, c.attributeChangeHandlerId, {
1115
+ rowId: e,
1116
+ attributeId: t,
1117
+ value: n
1118
+ }).then(() => void 0) : void 0,
1119
+ onReorder: c.reorderHandlerId ? (e, t) => l(c, c.reorderHandlerId, {
1120
+ rowId: e,
1121
+ beforeRowId: t
1122
+ }).then(() => void 0) : void 0,
1123
+ onCreateRow: kt(c, n, l, c.rowActivationHandlerId ? _ : void 0),
1124
+ onColumnAction: c.columnActionHandlerId ? async (e, t) => {
1125
+ await l(c, c.columnActionHandlerId, {
1126
+ columnId: e,
1127
+ actionId: t
1128
+ });
1129
+ } : void 0,
1130
+ getRowContextMenuActions: At(e, c, n, i, s)
1131
+ }
1132
+ }));
1133
+ }
1134
+ return { dispose() {
1135
+ for (let e = r.length - 1; e >= 0; --e) r[e]?.dispose();
1136
+ } };
1137
+ }, H = (e) => e.extensionId === "pstdio" ? e.id : `${e.extensionId}.${e.kind}.${e.id}`, U = (e) => e.extensionId === "pstdio" ? e.id : `${e.extensionId}.command.${e.id}`, Mt = (e) => {
1138
+ if (!e) return;
1139
+ let t = (e) => {
1140
+ if (e) return Array.isArray(e) ? e.map(H) : H(e);
1141
+ };
1142
+ return {
1143
+ mode: t(e.mode),
1144
+ source: e.source,
1145
+ viewId: t(e.view),
1146
+ resourceType: e.resourceType?.map((e) => e.id),
1147
+ metadata: e.metadata
1148
+ };
1149
+ }, Nt = Mt, Pt = (e, t) => {
1150
+ if (e) return Object.fromEntries(Object.entries(e).map(([e, n]) => [e, {
1151
+ ...n,
1152
+ label: n.label === void 0 ? void 0 : t(n.label, e),
1153
+ description: n.description === void 0 ? void 0 : t(n.description)
1154
+ }]));
1155
+ }, Ft = (e) => ({
1156
+ id: e.treeId,
1157
+ kind: "renderer",
1158
+ context: {
1159
+ projectId: e.projectId,
1160
+ treeId: e.treeId,
1161
+ ...e.modeId ? { modeId: e.modeId } : {},
1162
+ ...e.resource ? {
1163
+ resourceType: e.resource.type,
1164
+ resourceId: e.resource.id
1165
+ } : {}
1166
+ }
1167
+ }), W = (e, t, n, r) => {
1168
+ let i = n.resource, a = e.workbench.modes.getActiveModeId();
1169
+ return {
1170
+ renderer: {
1171
+ rendererId: t.id,
1172
+ projectId: e.projectId,
1173
+ ...a ? { modeId: a } : {},
1174
+ ...i ? { resource: i } : {},
1175
+ invocation: { placement: "visible" }
1176
+ },
1177
+ state: n.state,
1178
+ ...n.filter ? { filter: n.filter } : {},
1179
+ ...r ? { node: r } : {}
1180
+ };
1181
+ }, G = async (e, t, n, r) => {
1182
+ let i = r.renderer, a = i?.resource;
1183
+ return R(e, n, {
1184
+ params: r,
1185
+ resource: a,
1186
+ slot: Ft({
1187
+ modeId: i?.modeId,
1188
+ projectId: e.projectId,
1189
+ resource: a,
1190
+ treeId: t.id
1191
+ })
1192
+ });
1193
+ }, It = async (e, t, n, r, i) => {
1194
+ let a = e.workbench.modes.getActiveModeId();
1195
+ return R(e, n, {
1196
+ params: {
1197
+ ...r ?? {},
1198
+ renderer: {
1199
+ rendererId: t.id,
1200
+ projectId: e.projectId,
1201
+ ...a ? { modeId: a } : {},
1202
+ ...i ? { resource: i } : {},
1203
+ invocation: { placement: "visible" }
1204
+ }
1205
+ },
1206
+ resource: i,
1207
+ slot: Ft({
1208
+ modeId: a,
1209
+ projectId: e.projectId,
1210
+ resource: i,
1211
+ treeId: t.id
1212
+ }),
1213
+ metadata: { treeId: t.id }
1214
+ });
1215
+ }, Lt = (e, t) => e.panels.flatMap((e) => [e, ...e.panelMenus ?? []]).filter((e) => e.renderer?.kind === "tree" && e.renderer.id === t.id), Rt = (e, t) => t.viewId ? e.find((e) => e.id === t.viewId) : e.length === 1 ? e[0] : void 0, zt = async (e) => {
1216
+ let { ctx: t, getHostTreeHeaderNodes: n, record: r, treeViews: i } = e, a = Rt(i, t);
1217
+ return !a || !("hostTreeHeader" in a) || a.hostTreeHeader !== "default" ? [] : await n?.({
1218
+ ctx: t,
1219
+ record: r,
1220
+ panel: a
1221
+ }) ?? [];
1222
+ }, Bt = async (e) => {
1223
+ let { ctx: t, getHostTreeFooterNodes: n, record: r, treeViews: i } = e, a = Rt(i, t);
1224
+ return !a || !("hostTreeFooter" in a) || a.hostTreeFooter !== "default" ? [] : await n?.({
1225
+ ctx: t,
1226
+ record: r,
1227
+ panel: a
1228
+ }) ?? [];
1229
+ }, Vt = (e, t) => e && typeof e == "object" && !Array.isArray(e) ? e : t, Ht = (e) => e && !Array.isArray(e) ? e : void 0, Ut = (e, t) => {
1230
+ let n = /* @__PURE__ */ new WeakMap(), r = `workbench.extensionTreeRenderer.${t.id}.command`, i = (t) => e.resolveNodeResource?.(t) ?? t, a = (e) => {
1231
+ if (e.emptyState) return {
1232
+ title: M(e.emptyState.title),
1233
+ description: M(e.emptyState.description),
1234
+ icon: e.emptyState.icon
1235
+ };
1236
+ }, o = (n, i, a) => n ? N(n, {
1237
+ commandTargetOf: (e) => ({
1238
+ kind: "command",
1239
+ commandId: r,
1240
+ args: {
1241
+ commandId: `${e.target.command.extensionId ?? t.extensionId}.command.${e.target.command.id}`,
1242
+ ...i ? { nodeId: i.id } : {},
1243
+ params: e.target.params,
1244
+ resource: i?.resource ?? a.resource,
1245
+ treeId: t.id
1246
+ }
1247
+ }),
1248
+ extensionId: t.extensionId,
1249
+ projectId: e.projectId
1250
+ }) : void 0, s = (n, r, i) => {
1251
+ let a = n.command ? U({
1252
+ ...n.command,
1253
+ extensionId: n.command.extensionId ?? t.extensionId
1254
+ }) : void 0;
1255
+ return {
1256
+ id: n.id,
1257
+ label: M(n.label),
1258
+ icon: n.icon,
1259
+ args: Ht(n.params),
1260
+ params: Pt(n.input, M),
1261
+ submitLabel: n.submitLabel,
1262
+ when: n.when,
1263
+ disabled: n.disabled,
1264
+ run: a ? async (s) => {
1265
+ let c = Vt(s, Ht(n.params));
1266
+ if (n.command?.extensionId === "pstdio") {
1267
+ await e.workbench.commands.executeCommand(a, c, { resource: r?.resource ?? i.resource });
1268
+ return;
1269
+ }
1270
+ let l = await It(e, t, a, c, r?.resource ?? i.resource);
1271
+ i.refresh();
1272
+ let u = P(l) ? o(l, r, i) : void 0;
1273
+ u && await e.workbench.navigation.openTarget(u);
1274
+ } : void 0
1275
+ };
1276
+ }, c = (e, t) => {
1277
+ let r = {
1278
+ id: e.id,
1279
+ selected: e.selected,
1280
+ label: M(e.label),
1281
+ icon: e.icon,
1282
+ iconColor: e.iconColor,
1283
+ iconTooltip: e.iconTooltip,
1284
+ resource: e.resource ? i(e.resource) : void 0,
1285
+ target: o(e.target, e, t),
1286
+ rowVariant: e.rowVariant,
1287
+ actions: e.actions?.map((n) => s(n, e, t)),
1288
+ contextMenuActions: e.contextMenuActions?.map((n) => s(n, e, t)),
1289
+ collapsible: e.collapsible,
1290
+ disabled: e.disabled,
1291
+ children: e.children?.map((e) => c(e, t)),
1292
+ description: e.description,
1293
+ contextValue: e.contextValue,
1294
+ hiddenByDefault: e.hiddenByDefault,
1295
+ canHide: e.canHide
1296
+ };
1297
+ return n.set(r, e), r;
1298
+ };
1299
+ return {
1300
+ mapNodes: (e, t) => e.map((e) => c(e, t)),
1301
+ mapSections: (e, t) => e.map((e) => ({
1302
+ id: e.id,
1303
+ label: M(e.label),
1304
+ actions: e.actions?.map((e) => s(e, void 0, t)),
1305
+ collapsible: e.collapsible,
1306
+ emptyState: a(e),
1307
+ nodes: e.nodes.map((e) => c(e, t)),
1308
+ hiddenByDefault: e.hiddenByDefault,
1309
+ canHide: e.canHide
1310
+ })),
1311
+ originalNodes: n,
1312
+ runnerCommandId: r
1313
+ };
1314
+ }, K = (e) => Array.isArray(e) && e.every((e) => e && typeof e == "object" && "nodes" in e), Wt = (e) => Array.isArray(e) && e.every((e) => e && typeof e == "object" && "id" in e), q = (e, t) => t.length > 0 ? [{
1315
+ id: e,
1316
+ nodes: t,
1317
+ canReorder: !1
1318
+ }] : [], Gt = (e, t) => {
1319
+ let n = Ut(e, t), r = Lt(e.metadata, t), i = e.workbench.commands.registerCommand({
1320
+ id: n.runnerCommandId,
1321
+ label: `${M(t.title, t.id)} tree command`
1322
+ }, { execute: async (n) => {
1323
+ let r = n, i = await It(e, t, r.commandId, r.params, r.resource);
1324
+ for (let t of e.workbench.views.listViews()) t.body.kind === "file" && e.workbench.views.refreshView(t.id);
1325
+ return i;
1326
+ } }), a = e.workbench.views.registerView({
1327
+ id: t.id,
1328
+ title: M(t.title, t.id),
1329
+ icon: t.icon,
1330
+ body: {
1331
+ kind: "tree",
1332
+ searchable: t.searchable,
1333
+ searchPlaceholder: M(t.searchPlaceholder, "Search files"),
1334
+ defaultExpandedNodeIds: t.defaultExpandedNodeIds,
1335
+ defaultExpandedSectionIds: t.defaultExpandedSectionIds,
1336
+ getHeader: async (i) => {
1337
+ let a = await zt({
1338
+ ctx: i,
1339
+ getHostTreeHeaderNodes: e.getHostTreeHeaderNodes,
1340
+ record: t,
1341
+ treeViews: r
1342
+ });
1343
+ if (!t.headerHandlerId) return q(`${t.id}:host-header`, a);
1344
+ let o = await G(e, t, t.headerHandlerId, W(e, t, i)), s = K(o) ? n.mapSections(o, i) : [];
1345
+ return [...q(`${t.id}:host-header`, a), ...s];
1346
+ },
1347
+ getBody: async (r) => {
1348
+ let i = await G(e, t, t.bodyHandlerId, W(e, t, r));
1349
+ return K(i) ? n.mapSections(i, r) : [];
1350
+ },
1351
+ getFooter: async (i) => {
1352
+ let a = await Bt({
1353
+ ctx: i,
1354
+ getHostTreeFooterNodes: e.getHostTreeFooterNodes,
1355
+ record: t,
1356
+ treeViews: r
1357
+ });
1358
+ if (!t.footerHandlerId) return q(`${t.id}:host-footer`, a);
1359
+ let o = await G(e, t, t.footerHandlerId, W(e, t, i));
1360
+ return [...K(o) ? n.mapSections(o, i) : [], ...q(`${t.id}:host-footer`, a)];
1361
+ },
1362
+ getChildren: async (r, i) => {
1363
+ if (!t.childrenHandlerId) return r.children ?? [];
1364
+ let a = n.originalNodes.get(r);
1365
+ if (!a) return r.children ?? [];
1366
+ let o = await G(e, t, t.childrenHandlerId, W(e, t, i, a));
1367
+ return Wt(o) ? n.mapNodes(o, i) : [];
1368
+ }
1369
+ }
1370
+ });
1371
+ return { dispose() {
1372
+ a.dispose(), i.dispose();
1373
+ } };
1374
+ }, Kt = (e) => {
1375
+ let t = [];
1376
+ for (let n of e.metadata.treeRenderers ?? []) t.push(Gt(e, n));
1377
+ return { dispose() {
1378
+ for (let e = t.length - 1; e >= 0; --e) t[e]?.dispose();
1379
+ } };
1380
+ }, J = (e) => ({
1381
+ kind: e.kind,
1382
+ id: H(e),
1383
+ extensionId: e.extensionId
1384
+ }), qt = (e, t, n) => {
1385
+ let r = n?.(t.when);
1386
+ return !r || e.context.matches(r);
1387
+ }, Jt = (e) => ({
1388
+ id: e.id,
1389
+ label: M(e.label, e.id),
1390
+ icon: e.icon,
1391
+ canHide: !0,
1392
+ canReorder: !0,
1393
+ target: N(e.action, { extensionId: e.extensionId })
1394
+ }), Yt = (e, t, n) => {
1395
+ let r = /* @__PURE__ */ new Map();
1396
+ for (let i of t) {
1397
+ if (!qt(e, i, n)) continue;
1398
+ let t = i.group || void 0, a = t ? `${i.extensionId}:${t}` : "navigation.root", o = r.get(a) ?? {
1399
+ id: a,
1400
+ label: t,
1401
+ collapsible: !!t,
1402
+ canHide: !0,
1403
+ canReorder: !0,
1404
+ nodes: []
1405
+ };
1406
+ o.nodes.push(Jt(i)), r.set(a, o);
1407
+ }
1408
+ return [...r.values()];
1409
+ }, Xt = (e) => {
1410
+ let t = /* @__PURE__ */ new Map();
1411
+ for (let n of e) {
1412
+ let e = J(n.owner), r = `${n.extensionId}:${e.kind}:${e.id}:${n.slot}`;
1413
+ t.set(r, [...t.get(r) ?? [], n]);
1414
+ }
1415
+ return [...t.values()];
1416
+ }, Zt = (e) => [...new Set(e.flatMap((e) => e.group ? [`${e.extensionId}:${e.group}`] : []))], Qt = (e) => Xt(e.metadata.navigationItems).map((t) => {
1417
+ let n = t[0];
1418
+ return e.workbench.navigationTrees.registerContribution({
1419
+ id: `${n.extensionId}.navigation-items.${n.owner.kind}.${H(n.owner)}.${n.slot}`,
1420
+ owner: J(n.owner),
1421
+ sourceExtensionId: n.extensionId,
1422
+ declarationIndex: e.metadata.navigationItems.indexOf(n),
1423
+ slot: n.slot,
1424
+ defaultExpandedSectionIds: Zt(t),
1425
+ getSections: () => Yt(e.workbench, t, e.createWhenExpression)
1426
+ });
1427
+ }), $t = (e) => e.metadata.navigationTrees.map((t, n) => {
1428
+ let r = H(t.view);
1429
+ return e.workbench.navigationTrees.registerContribution({
1430
+ id: t.id,
1431
+ idScope: t.id,
1432
+ owner: J(t.owner),
1433
+ sourceExtensionId: t.extensionId,
1434
+ declarationIndex: e.metadata.navigationItems.length + n,
1435
+ slot: t.slot,
1436
+ viewId: r
1437
+ });
1438
+ }), en = (e) => [...Qt(e), ...$t(e)], tn = () => {
1439
+ if (typeof navigator > "u") return;
1440
+ let e = `${navigator.platform} ${navigator.userAgent}`.toLowerCase();
1441
+ if (e.includes("mac")) return "mac";
1442
+ if (e.includes("win")) return "win";
1443
+ if (e.includes("linux")) return "linux";
1444
+ }, nn = (e, t = tn()) => (t ? e.platformOverrides?.[t] : void 0) ?? e.key, rn = (e) => e.bindings.map((t) => e.workbench.keybindings.registerKeybinding({
1445
+ action: N(t.action, { commandIdOf: (e) => e.extensionId ? U({
1446
+ extensionId: e.extensionId,
1447
+ id: e.id
1448
+ }) : void 0 }),
1449
+ keybinding: nn(t),
1450
+ when: e.createWhenExpression?.(t.when)
1451
+ })), an = (e, t) => ({
1452
+ ...e,
1453
+ tab: e.tab && t.createTab ? t.createTab({
1454
+ ...e.tab,
1455
+ extensionId: t.extensionId,
1456
+ placementId: t.placementId
1457
+ }) : void 0
1458
+ }), on = (e, t) => e.kind === "panels" ? e : {
1459
+ ...e,
1460
+ tab: e.tab && t.createTab ? t.createTab({
1461
+ ...e.tab,
1462
+ extensionId: t.extensionId,
1463
+ placementId: t.placementId
1464
+ }) : void 0
1465
+ }, sn = (e, t) => e.pages.map((e) => ({
1466
+ id: e.id,
1467
+ ref: {
1468
+ extensionId: e.extensionId,
1469
+ kind: "page",
1470
+ id: e.localId
1471
+ },
1472
+ title: e.title,
1473
+ path: e.path,
1474
+ modeId: H(e.mode),
1475
+ resource: e.resource,
1476
+ main: on(e.main, {
1477
+ extensionId: e.extensionId,
1478
+ placementId: `${e.id}.$main`,
1479
+ createTab: t
1480
+ }),
1481
+ slots: e.slots.map((n) => an(n, {
1482
+ extensionId: e.extensionId,
1483
+ placementId: `${e.id}.${n.id}`,
1484
+ createTab: t
1485
+ })),
1486
+ ...e.icon ? { icon: e.icon } : {},
1487
+ ...e.parent ? { parentId: H(e.parent) } : {}
1488
+ })), Y = (e, t) => {
1489
+ let n = e.pages.flatMap((e) => [...e.main.kind === "view" && e.resource ? [{
1490
+ ...e.resource,
1491
+ view: e.main.view
1492
+ }] : [], ...e.slots.flatMap((e) => e.item.kind === "binding" ? [e.item.binding] : [])]);
1493
+ return n.push(...e.placements.flatMap((e) => e.item.kind === "binding" ? [e.item.binding] : [])), n.find((e) => H(e.view) === t)?.kinds[0]?.id;
1494
+ }, cn = (e) => e.body.kind === "webview" ? { webview: e.body.webview } : { renderer: {
1495
+ kind: e.body.kind,
1496
+ id: e.id
1497
+ } }, ln = (e, t) => e.viewMenus.flatMap((n) => {
1498
+ if (H(n.owner) !== t.id) return [];
1499
+ let r = e.views.find((e) => e.id === H(n.view));
1500
+ return r ? [{
1501
+ id: n.id,
1502
+ extensionId: n.extensionId,
1503
+ ownerPanelId: t.id,
1504
+ viewId: r.id,
1505
+ title: r.title,
1506
+ side: n.side,
1507
+ group: n.group,
1508
+ placement: n.placement,
1509
+ hostTreeHeader: n.hostTreeHeader,
1510
+ hostTreeFooter: n.hostTreeFooter,
1511
+ ...cn(r)
1512
+ }] : [];
1513
+ }), un = (e) => e.views.map((t) => {
1514
+ let n = ln(e, t);
1515
+ return {
1516
+ id: t.id,
1517
+ extensionId: t.extensionId,
1518
+ title: t.title,
1519
+ icon: t.icon,
1520
+ panelMenus: n.length > 0 ? n : void 0,
1521
+ ...cn(t)
1522
+ };
1523
+ }), X = (e) => e?.map(({ command: e, ...t }) => ({
1524
+ ...t,
1525
+ commandId: U(e)
1526
+ })), dn = (e) => e.views.flatMap((t) => {
1527
+ let n = t.body;
1528
+ return n.kind === "kanban" ? [{
1529
+ ...n,
1530
+ id: t.id,
1531
+ extensionId: t.extensionId,
1532
+ title: t.title,
1533
+ icon: t.icon,
1534
+ resourceKind: Y(e, t.id),
1535
+ createRow: n.createRow ? {
1536
+ title: n.createRow.title,
1537
+ submitLabel: n.createRow.submitLabel,
1538
+ columnParam: n.createRow.columnParam,
1539
+ params: n.createRow.params,
1540
+ attributesParam: n.createRow.attributesParam,
1541
+ labels: n.createRow.labels,
1542
+ commandId: U(n.createRow.command),
1543
+ attachments: n.createRow.attachments ? {
1544
+ resourceParam: n.createRow.attachments.resourceParam,
1545
+ fileParam: n.createRow.attachments.fileParam,
1546
+ commandId: U(n.createRow.attachments.command)
1547
+ } : void 0
1548
+ } : void 0,
1549
+ rowActions: X(n.rowActions)
1550
+ }] : [];
1551
+ }), fn = (e) => e.views.flatMap((t) => {
1552
+ let n = t.body;
1553
+ return n.kind === "dataTable" ? [{
1554
+ ...n,
1555
+ id: t.id,
1556
+ extensionId: t.extensionId,
1557
+ title: t.title,
1558
+ icon: t.icon,
1559
+ resourceKind: Y(e, t.id),
1560
+ selectionActions: X(n.selectionActions),
1561
+ rowActions: X(n.rowActions)
1562
+ }] : [];
1563
+ }), pn = (e) => e.views.flatMap((t) => t.body.kind === "tree" ? [{
1564
+ ...t.body,
1565
+ id: t.id,
1566
+ extensionId: t.extensionId,
1567
+ title: t.title,
1568
+ icon: t.icon,
1569
+ resourceKind: Y(e, t.id)
1570
+ }] : []), mn = (e) => e.views.flatMap((t) => t.body.kind === "file" ? [{
1571
+ ...t.body,
1572
+ id: t.id,
1573
+ extensionId: t.extensionId,
1574
+ title: t.title,
1575
+ icon: t.icon,
1576
+ resourceKind: Y(e, t.id)
1577
+ }] : []), hn = (e) => e.views.flatMap((t) => t.body.kind === "controls" ? [{
1578
+ ...t.body,
1579
+ id: t.id,
1580
+ extensionId: t.extensionId,
1581
+ title: t.title,
1582
+ icon: t.icon,
1583
+ resourceKind: Y(e, t.id)
1584
+ }] : []), gn = (e) => e.modes.map((e) => ({
1585
+ id: e.id,
1586
+ extensionId: e.extensionId,
1587
+ modeId: e.id,
1588
+ label: e.label,
1589
+ icon: e.icon,
1590
+ panelRegions: e.regions,
1591
+ regionSettings: e.regionSettings,
1592
+ floatingPanels: e.floatingPanels,
1593
+ ...e.defaultTheme ? { defaultTheme: H(e.defaultTheme) } : {},
1594
+ ...e.chrome ? { chrome: Object.fromEntries(Object.entries(e.chrome).map(([e, t]) => [e, t !== !1 && H(t)])) } : {}
1595
+ })), _n = (e, t = {}) => {
1596
+ let n = un(e);
1597
+ return {
1598
+ extensions: e.extensions,
1599
+ commands: e.commands,
1600
+ menuContributions: e.menuContributions,
1601
+ commandPaletteContributions: e.commandPaletteContributions,
1602
+ modes: gn(e),
1603
+ pages: sn(e, t.createTab),
1604
+ placements: e.placements.map((e) => ({
1605
+ id: e.id,
1606
+ ref: {
1607
+ extensionId: e.extensionId,
1608
+ kind: "placement",
1609
+ id: e.localId
1610
+ },
1611
+ modeId: H(e.mode),
1612
+ item: e.item,
1613
+ region: e.region,
1614
+ order: e.order,
1615
+ movableTo: e.movableTo,
1616
+ mountStrategy: e.mountStrategy,
1617
+ hiddenByDefault: e.hiddenByDefault,
1618
+ headerBorderBottom: e.headerBorderBottom,
1619
+ tab: e.tab && t.createTab ? t.createTab({
1620
+ ...e.tab,
1621
+ extensionId: e.extensionId,
1622
+ placementId: e.id
1623
+ }) : void 0
1624
+ })),
1625
+ panels: n,
1626
+ resourceKinds: e.resourceKinds.map((e) => ({
1627
+ id: e.id,
1628
+ extensionId: e.extensionId,
1629
+ label: e.label,
1630
+ icon: e.icon,
1631
+ menuSlots: Object.fromEntries((e.menuSlots ?? []).map((e) => [e.id, {
1632
+ placement: e.placement,
1633
+ label: e.label,
1634
+ external: e.access === "public",
1635
+ order: e.order
1636
+ }]))
1637
+ })),
1638
+ resourceHierarchyProviders: (e.resourceHierarchyProviders ?? []).map((e) => ({
1639
+ id: e.id,
1640
+ extensionId: e.extensionId,
1641
+ resourceKind: e.resourceKind.id
1642
+ })),
1643
+ settingsSections: e.settingsSections ?? [],
1644
+ settingsPanels: e.settingsPanels.flatMap((t) => {
1645
+ let n = e.views.find((e) => e.id === H(t.view));
1646
+ return n ? [{
1647
+ id: t.id,
1648
+ viewId: n.id,
1649
+ extensionId: t.extensionId,
1650
+ slotId: t.slot.id,
1651
+ scope: t.slot.id.includes("global") ? "global" : "project",
1652
+ title: n.title,
1653
+ icon: n.icon,
1654
+ section: t.section ? H(t.section) : void 0
1655
+ }] : [];
1656
+ }),
1657
+ kanbanRenderers: dn(e),
1658
+ dataTableRenderers: fn(e),
1659
+ commandPaletteResources: e.commandPaletteResources ?? [],
1660
+ treeRenderers: pn(e),
1661
+ fileRenderers: mn(e),
1662
+ controlsRenderers: hn(e),
1663
+ keybindings: e.keybindings ?? [],
1664
+ settingsDefinitions: e.settingsDefinitions ?? [],
1665
+ statuses: e.statuses,
1666
+ statusBarItems: e.statusBarItems.map((e) => ({
1667
+ id: e.id,
1668
+ extensionId: e.extensionId,
1669
+ viewId: H(e.view),
1670
+ slot: e.slot.id.endsWith("leading") ? "leading" : "trailing",
1671
+ order: e.order,
1672
+ when: Mt(e.when)
1673
+ })),
1674
+ diagnostics: e.diagnostics
1675
+ };
1676
+ }, vn = (e, t, n = {}) => {
1677
+ e.views.refreshView(t.id, t.kind === "file" ? n : void 0);
1678
+ }, yn = (e) => {
1679
+ let t = /* @__PURE__ */ new Map(), n = (e, n) => {
1680
+ for (let r of new Set(n.refreshEventIds ?? [])) {
1681
+ let i = t.get(r) ?? [];
1682
+ i.some((t) => t.kind === e && t.id === n.id) || i.push({
1683
+ id: n.id,
1684
+ kind: e
1685
+ }), t.set(r, i);
1686
+ }
1687
+ };
1688
+ for (let t of e.views) t.body.kind !== "webview" && n(t.body.kind, {
1689
+ id: t.id,
1690
+ refreshEventIds: t.body.refreshEventIds
1691
+ });
1692
+ return t;
1693
+ }, bn = (e) => {
1694
+ let t = yn(e.metadata);
1695
+ return e.subscribe((n) => {
1696
+ let { id: r, ...i } = n;
1697
+ for (let n of t.get(r) ?? []) vn(e.workbench, n, i);
1698
+ });
1699
+ }, xn = (e, t) => {
1700
+ for (let n of t.views) n.body.kind === "webview" && e.views.getView(n.id) && e.views.refreshView(n.id);
1701
+ }, Sn = (e) => (t) => ({
1702
+ ...ye({
1703
+ workbench: t.workbench,
1704
+ placement: t.placement,
1705
+ hostEvents: t.hostEvents
1706
+ }),
1707
+ "navigation.open": (n) => {
1708
+ let r = n;
1709
+ if (!r.target) throw Error("navigation.open requires a target.");
1710
+ return t.workbench.navigation.openTarget(N(r.target, {
1711
+ extensionId: e.extensionIdForWebview(t.webviewId),
1712
+ projectId: e.projectId
1713
+ }));
1714
+ },
1715
+ "commands.execute": async (n) => {
1716
+ let r = n, i = r.resource ?? t.placement.resource;
1717
+ return L({
1718
+ ...e,
1719
+ workbench: t.workbench
1720
+ }, r.commandId, {
1721
+ ...r.params ? { params: r.params } : {},
1722
+ ...r.workspaceId ? { workspaceId: r.workspaceId } : {},
1723
+ ...r.metadata ? { metadata: r.metadata } : {},
1724
+ ...i ? { resource: i } : {},
1725
+ slot: I({
1726
+ id: t.webviewId,
1727
+ kind: e.slotKind,
1728
+ projectId: e.projectId,
1729
+ context: { panelId: t.webviewId }
1730
+ })
1731
+ });
1732
+ },
1733
+ ...e.files ? {
1734
+ "files.upload": e.files.upload,
1735
+ "files.list": e.files.list,
1736
+ "files.delete": e.files.delete
1737
+ } : {},
1738
+ ...e.artifacts ? { "artifacts.read": (n) => e.artifacts.read(n, { webviewId: t.webviewId }) } : {}
1739
+ }), Cn = (e) => ({
1740
+ title: M(e.title) || void 0,
1741
+ runtimeUrl: e.runtimeUrl,
1742
+ moduleUrl: e.moduleUrl,
1743
+ styles: e.styles,
1744
+ capabilities: e.capabilities
1745
+ }), wn = "extensions", Tn = 1e3, En = 25, Dn = (e) => e === void 0 ? void 0 : e, On = (e) => e === "global" ? "user" : "project", kn = (e, t) => t ? (n) => ({
1746
+ ...e(n),
1747
+ ...t(n)
1748
+ }) : e, An = (e, t) => kn(e.createWebviewHostCapabilities ?? Sn({
1749
+ artifacts: e.webviewArtifacts,
1750
+ executeCommand: e.executeCommand,
1751
+ extensionIdForWebview: (t) => e.metadata.panels.find((e) => e.id === t)?.extensionId,
1752
+ files: e.webviewFiles,
1753
+ projectId: e.projectId,
1754
+ slotKind: t
1755
+ }), e.createWebviewHostCapabilityOverrides), jn = (e) => e.metadata.panels.flatMap((t) => {
1756
+ if (!t.webview) return [];
1757
+ let n = Cn(t.webview);
1758
+ return [e.workbench.views.registerView({
1759
+ id: t.id,
1760
+ title: M(t.title, t.id),
1761
+ icon: t.icon,
1762
+ body: {
1763
+ kind: "react",
1764
+ render: (r) => {
1765
+ let i = e.metadata.settingsPanels.some((e) => e.id === r.instance.panelId && e.viewId === t.id) ? "settings" : "panel";
1766
+ return e.renderWebview?.(r) ?? Ce({
1767
+ context: {
1768
+ workbench: r.workbench,
1769
+ webviewId: t.id,
1770
+ placement: r.instance,
1771
+ hostEvents: Se(r.workbench, r.instance)
1772
+ },
1773
+ createHostCapabilities: An(e, i),
1774
+ createProps: e.createWebviewProps ?? (({ placement: e }) => ({
1775
+ placement: e,
1776
+ resource: e.resource
1777
+ })),
1778
+ createTheme: e.createWebviewTheme,
1779
+ ownerId: t.extensionId,
1780
+ title: M(t.title, t.id),
1781
+ webview: n
1782
+ });
1783
+ }
1784
+ }
1785
+ })];
1786
+ }), Mn = {
1787
+ first: 1e6,
1788
+ default: 0,
1789
+ last: -1e6
1790
+ }, Nn = (e) => e.metadata.panels.flatMap((e) => e.panelMenus ?? []).map((t, n) => e.workbench.viewMenus.registerViewMenu({
1791
+ id: t.id,
1792
+ ownerViewId: t.ownerPanelId,
1793
+ viewId: t.viewId,
1794
+ side: t.side,
1795
+ priority: Mn[t.placement ?? "default"] - n
1796
+ })), Pn = (e) => {
1797
+ if (!e || typeof e != "object" || !("statuses" in e) || !Array.isArray(e.statuses)) throw Error("Status provider returned an invalid response");
1798
+ return e.statuses;
1799
+ }, Fn = (e, n) => {
1800
+ let r = e.metadata.statuses ?? [];
1801
+ if (r.length === 0) return [];
1802
+ let i = "workbench.extension-statuses.settings", a = r.map((t, r) => e.workbench.statuses.registerStatusSet({
1803
+ id: t.id,
1804
+ title: M(t.title, t.id),
1805
+ actions: t.actions?.map((e) => ({
1806
+ id: e.id,
1807
+ label: M(e.label, e.id),
1808
+ icon: e.icon
1809
+ })),
1810
+ query: async () => Pn(await R(n, t.queryHandlerId, { params: {} })),
1811
+ save: t.saveHandlerId ? async (e) => Pn(await R(n, t.saveHandlerId, { params: { statuses: e } })) : void 0
1812
+ }, {
1813
+ ownerId: t.extensionId,
1814
+ priority: -r
1815
+ }));
1816
+ return a.push(e.workbench.views.registerView({
1817
+ id: i,
1818
+ title: "Statuses",
1819
+ body: {
1820
+ kind: "react",
1821
+ render: () => h(t, { workbench: e.workbench })
1822
+ }
1823
+ })), a.push(e.workbench.settings.registerPanel({
1824
+ id: "workbench.statuses",
1825
+ title: "Statuses",
1826
+ icon: "list-checks",
1827
+ kind: "view",
1828
+ order: En,
1829
+ section: e.settingsSectionId ?? wn,
1830
+ scope: "project",
1831
+ viewId: i
1832
+ })), a;
1833
+ }, In = (e) => {
1834
+ let t = [], n = e.settingsSectionId ?? wn;
1835
+ e.workbench.settings.getSection(n) || t.push(e.workbench.settings.registerSection({
1836
+ id: n,
1837
+ title: e.settingsSectionTitle ?? "Extensions"
1838
+ }));
1839
+ let r = [...e.metadata.settingsSections].sort((e, t) => (e.order ?? 0) - (t.order ?? 0) || e.extensionId.localeCompare(t.extensionId) || e.id.localeCompare(t.id));
1840
+ for (let n of r) t.push(e.workbench.settings.registerSection({
1841
+ id: n.id,
1842
+ title: M(n.title, n.id),
1843
+ order: n.order,
1844
+ scope: n.scope
1845
+ }));
1846
+ let i = Object.fromEntries((e.metadata.settingsDefinitions ?? []).map((e) => [e.key, {
1847
+ type: e.type,
1848
+ scope: On(e.scope),
1849
+ default: Dn(e.default),
1850
+ enum: e.enum,
1851
+ description: M(e.description)
1852
+ }]));
1853
+ Object.keys(i).length > 0 && t.push(e.workbench.preferences.registerSchema({ properties: i }));
1854
+ let a = [...e.metadata.settingsPanels].sort((e, t) => e.extensionId.localeCompare(t.extensionId) || e.id.localeCompare(t.id));
1855
+ for (let [r, i] of a.entries()) t.push(e.workbench.settings.registerPanel({
1856
+ id: i.id,
1857
+ title: M(i.title, i.id),
1858
+ icon: i.icon,
1859
+ kind: "view",
1860
+ order: Tn + r,
1861
+ section: i.section ?? n,
1862
+ scope: i.scope,
1863
+ viewId: i.viewId
1864
+ }));
1865
+ return t;
1866
+ }, Z = (e) => !(!e || typeof e != "object" || Array.isArray(e)), Ln = (e, t, n) => l(e) ? N(e, {
1867
+ extensionId: t,
1868
+ projectId: n
1869
+ }) : void 0, Rn = (e, t, n) => {
1870
+ if (!Z(e)) return {};
1871
+ let r = Z(e.indicator) ? {
1872
+ icon: String(e.indicator.icon ?? ""),
1873
+ color: typeof e.indicator.color == "string" ? e.indicator.color : void 0,
1874
+ label: M(e.indicator.label)
1875
+ } : void 0, i = Array.isArray(e.menu) ? e.menu.flatMap((e) => !Z(e) || typeof e.id != "string" || !Array.isArray(e.rows) ? [] : [{
1876
+ id: e.id,
1877
+ rows: e.rows.flatMap((e) => {
1878
+ if (!Z(e) || typeof e.id != "string") return [];
1879
+ let r = Ln(e.action, t, n);
1880
+ return [{
1881
+ id: e.id,
1882
+ label: M(e.label, e.id),
1883
+ icon: typeof e.icon == "string" ? e.icon : void 0,
1884
+ iconColor: typeof e.iconColor == "string" ? e.iconColor : void 0,
1885
+ selected: e.selected === !0,
1886
+ disabled: e.disabled === !0,
1887
+ action: r ? {
1888
+ kind: "navigation",
1889
+ target: r
1890
+ } : void 0
1891
+ }];
1892
+ })
1893
+ }]) : void 0;
1894
+ return {
1895
+ label: M(e.label),
1896
+ icon: typeof e.icon == "string" ? e.icon : void 0,
1897
+ indicator: r?.icon ? r : void 0,
1898
+ menu: i
1899
+ };
1900
+ }, zn = (e, t) => {
1901
+ let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = new Set(t.refreshEventIds ?? []), o = (a) => {
1902
+ if (r.has(a.instanceId)) return;
1903
+ r.add(a.instanceId);
1904
+ let o = a.resource ? {
1905
+ type: a.resource.type,
1906
+ id: a.resource.id ?? f(a.resource),
1907
+ label: a.resource.label,
1908
+ metadata: a.resource.metadata
1909
+ } : void 0;
1910
+ Promise.resolve(R(e, t.queryHandlerId, {
1911
+ resource: o,
1912
+ params: { renderer: {
1913
+ rendererId: t.placementId,
1914
+ projectId: e.projectId,
1915
+ ...o ? { resource: o } : {},
1916
+ invocation: { placement: "visible" }
1917
+ } }
1918
+ })).then((r) => {
1919
+ n.set(a.instanceId, Rn(r, t.extensionId, e.projectId));
1920
+ for (let e of i) e();
1921
+ }).finally(() => r.delete(a.instanceId));
1922
+ };
1923
+ return {
1924
+ refreshEvents: t.refreshEventIds,
1925
+ getSnapshot(e) {
1926
+ return o(e), n.get(e.instanceId) ?? {};
1927
+ },
1928
+ subscribe(t) {
1929
+ i.add(t);
1930
+ let r = e.subscribeRefreshEvents?.((e) => {
1931
+ a.has(e.id) && (n.clear(), t());
1932
+ });
1933
+ return { dispose() {
1934
+ i.delete(t), r?.dispose();
1935
+ } };
1936
+ }
1937
+ };
1938
+ }, Bn = (e) => {
1939
+ for (let t = e.length - 1; t >= 0; --t) e[t]?.dispose();
1940
+ }, Q = (e) => e && typeof e == "object" && !Array.isArray(e) ? e : void 0, $ = (e, t, n, r, i) => e.prepareCommandArgs?.(t, n, r, i) ?? n, Vn = (e, t) => t.commands.map((t) => e.workbench.commands.registerCommand({
1941
+ id: t.id,
1942
+ label: M(t.title, t.id),
1943
+ description: M(t.description),
1944
+ params: t.params
2252
1945
  }, {
2253
- prepareArgs: (o, r, s) => be(e, n.id, o, r, s),
2254
- execute: (o, r) => E(e, n.id, {
2255
- params: pe(o),
2256
- resource: r?.resource
2257
- })
2258
- })), Ge = (e, t) => t?.resource ?? e.workbench.getPrimaryResource(), Po = (e, t) => {
2259
- if (!e.menuSlotsById) return [];
2260
- const {
2261
- registrations: n
2262
- } = on({
2263
- metadata: e.metadata,
2264
- menuSlotsById: e.menuSlotsById,
2265
- menuTargetsById: e.menuTargetsById,
2266
- createWhenExpression: e.createMenuWhenExpression
2267
- }), o = n.map(({
2268
- menuItem: s,
2269
- menuPath: i,
2270
- ...a
2271
- }) => ({
2272
- ...a,
2273
- menuItems: [{
2274
- menuItem: s,
2275
- menuPath: i
2276
- }]
2277
- }));
2278
- return (e.menuRegistrations ?? o).flatMap((s) => [e.workbench.commands.registerCommand(s.command, {
2279
- prepareArgs: (i, a, d) => be(t, s.targetCommandId, i, a, d),
2280
- execute: (i, a) => E(t, s.targetCommandId, {
2281
- params: {
2282
- ...s.contribution.params ?? {},
2283
- ...pe(i) ?? {}
2284
- },
2285
- resource: Ge(e, a),
2286
- slot: O({
2287
- id: s.contribution.slotId,
2288
- kind: "menu",
2289
- projectId: e.projectId,
2290
- context: {
2291
- panelId: s.contribution.id
2292
- }
2293
- })
2294
- })
2295
- }), ...s.menuItems.map(({
2296
- menuPath: i,
2297
- menuItem: a
2298
- }) => e.workbench.layout.registerMenuItem(i, a))]);
2299
- }, jo = (e, t) => sn({
2300
- metadata: e.metadata
2301
- }).flatMap((o) => [e.workbench.commands.registerCommand(o.command, {
2302
- prepareArgs: (r, s, i) => be(t, o.targetCommandId, r, s, i),
2303
- execute: (r, s) => E(t, o.targetCommandId, {
2304
- params: {
2305
- ...o.contribution.params ?? {},
2306
- ...pe(r) ?? {}
2307
- },
2308
- resource: Ge(e, s),
2309
- slot: O({
2310
- id: "workbench.commandPalette",
2311
- kind: "menu",
2312
- projectId: e.projectId,
2313
- context: {
2314
- panelId: o.contribution.id
2315
- }
2316
- })
2317
- }),
2318
- isVisible: () => rt(o.contribution.when, e.workbench.getPrimaryResource()?.type)
2319
- }), e.workbench.layout.registerMenuItem(ct, o.menuItem)]), $o = (e, t) => {
2320
- const n = t?.mode;
2321
- if (!n) return !0;
2322
- const o = e.workbench.modes.getActiveModeId() ?? "";
2323
- return Array.isArray(n) ? n.includes(o) : n === o;
2324
- }, Ho = (e) => (e.metadata.statusBarItems ?? []).map((t) => e.workbench.statusBar.registerItem({
2325
- id: t.id,
2326
- viewId: t.viewId,
2327
- slot: t.slot,
2328
- order: t.order,
2329
- isVisible: () => $o(e, t.when)
2330
- })), Wo = (e) => e.metadata.pages.map((t) => e.workbench.pages.registerPage(t)), Mo = (e) => e.metadata.resourceKinds.map((t) => e.workbench.resources.registerKind({
2331
- kind: t.id,
2332
- label: b(t.label, t.id),
2333
- icon: t.icon ?? "FileText"
2334
- })), Bo = (e) => e.metadata.modes.map((t) => e.workbench.modes.registerMode({
2335
- id: t.modeId,
2336
- label: b(t.label, t.modeId),
2337
- panels: t.panelRegions,
2338
- regionSettings: t.regionSettings,
2339
- floatingPanels: t.floatingPanels,
2340
- defaultTheme: t.defaultTheme,
2341
- chrome: t.chrome,
2342
- activate: () => {
2343
- }
2344
- })), Vo = (e) => e.metadata.placements.map((t) => e.workbench.modePlacements.registerPlacement(t)), Yo = (e) => {
2345
- const t = {
2346
- ...e,
2347
- metadata: lo(e.metadata, {
2348
- createTab: (r) => So(e, r)
2349
- })
2350
- }, n = [], o = t;
2351
- try {
2352
- return n.push(...To(o, t.metadata)), n.push(...Xn({
2353
- bindings: t.metadata.keybindings,
2354
- createWhenExpression: t.createKeybindingWhenExpression,
2355
- workbench: t.workbench
2356
- })), n.push(...Po(t, o)), n.push(...jo(t, o)), n.push(Fn({
2357
- ...t,
2358
- resolveNodeResource: t.resolveTreeNodeResource
2359
- })), n.push(dn(t)), n.push(zt(o, t.metadata.controlsRenderers ?? [])), n.push(...ko(t)), n.push(...Ao(t)), n.push(...Eo(t, o)), n.push(jn(o, t.metadata.kanbanRenderers ?? [], t.kanbanAdapter)), n.push(Xt(o, t.metadata.dataTableRenderers ?? [])), n.push(...Ro(t)), n.push(Ut(o, t.metadata.commandPaletteResources ?? [])), n.push(...Qn({
2360
- createWhenExpression: e.createNavigationWhenExpression,
2361
- metadata: e.metadata,
2362
- workbench: e.workbench
2363
- })), e.subscribeRefreshEvents && n.push(po({
2364
- metadata: e.metadata,
2365
- subscribe: e.subscribeRefreshEvents,
2366
- workbench: e.workbench
2367
- })), n.push(...Ho(t)), n.push(...Mo(t)), n.push(...Wo(t)), n.push(...Bo(t)), n.push(...Vo(t)), {
2368
- dispose() {
2369
- Se(n);
2370
- }
2371
- };
2372
- } catch (r) {
2373
- throw Se(n), r;
2374
- }
2375
- };
2376
- export {
2377
- sn as buildWorkbenchExtensionCommandPaletteRegistrations,
2378
- on as buildWorkbenchExtensionMenuRegistrations,
2379
- St as createTerminalSessionCapability,
2380
- Pt as createWorkbenchWebviewHostCapabilities,
2381
- qo as emptyWorkbenchExtensionMetadata,
2382
- zo as fileRendererRefreshEnvelopeFromCommand,
2383
- Wt as getBridgeWebviewHostEventPublisher,
2384
- We as isExtensionNavigationTarget,
2385
- Go as refreshOpenWorkbenchExtensionWebviews,
2386
- mo as refreshWorkbenchExtensionRenderer,
2387
- Ut as registerWorkbenchExtensionCommandPaletteResources,
2388
- Yo as registerWorkbenchExtensionContributions,
2389
- zt as registerWorkbenchExtensionControlsRenderers,
2390
- Xt as registerWorkbenchExtensionDataTableRenderers,
2391
- dn as registerWorkbenchExtensionFileRenderers,
2392
- jn as registerWorkbenchExtensionKanbanRenderers,
2393
- po as registerWorkbenchExtensionRendererRefreshEvents,
2394
- Fn as registerWorkbenchExtensionTreeRenderers,
2395
- Mt as renderBridgeWebviewFrame,
2396
- H as toWorkbenchNavigationTarget,
2397
- me as toWorkbenchNavigationTargetResult,
2398
- Qo as toWorkbenchWhenExpression
1946
+ prepareArgs: (n, r, i) => $(e, t.id, n, r, i),
1947
+ execute: (n, r) => R(e, t.id, {
1948
+ params: Q(n),
1949
+ resource: r?.resource
1950
+ })
1951
+ })), Hn = (e, t) => t?.resource ?? e.workbench.getPrimaryResource(), Un = (e, t) => {
1952
+ if (!e.menuSlotsById) return [];
1953
+ let { registrations: n } = Ye({
1954
+ metadata: e.metadata,
1955
+ menuSlotsById: e.menuSlotsById,
1956
+ menuTargetsById: e.menuTargetsById,
1957
+ createWhenExpression: e.createMenuWhenExpression
1958
+ }), r = n.map(({ menuItem: e, menuPath: t, ...n }) => ({
1959
+ ...n,
1960
+ menuItems: [{
1961
+ menuItem: e,
1962
+ menuPath: t
1963
+ }]
1964
+ }));
1965
+ return (e.menuRegistrations ?? r).flatMap((n) => [e.workbench.commands.registerCommand(n.command, {
1966
+ prepareArgs: (e, r, i) => $(t, n.targetCommandId, e, r, i),
1967
+ execute: (r, i) => R(t, n.targetCommandId, {
1968
+ params: {
1969
+ ...n.contribution.params ?? {},
1970
+ ...Q(r) ?? {}
1971
+ },
1972
+ resource: Hn(e, i),
1973
+ slot: I({
1974
+ id: n.contribution.slotId,
1975
+ kind: "menu",
1976
+ projectId: e.projectId,
1977
+ context: { panelId: n.contribution.id }
1978
+ })
1979
+ })
1980
+ }), ...n.menuItems.map(({ menuPath: t, menuItem: n }) => e.workbench.layout.registerMenuItem(t, n))]);
1981
+ }, Wn = (t, n) => Xe({ metadata: t.metadata }).flatMap((r) => [t.workbench.commands.registerCommand(r.command, {
1982
+ prepareArgs: (e, t, i) => $(n, r.targetCommandId, e, t, i),
1983
+ execute: (e, i) => R(n, r.targetCommandId, {
1984
+ params: {
1985
+ ...r.contribution.params ?? {},
1986
+ ...Q(e) ?? {}
1987
+ },
1988
+ resource: Hn(t, i),
1989
+ slot: I({
1990
+ id: "workbench.commandPalette",
1991
+ kind: "menu",
1992
+ projectId: t.projectId,
1993
+ context: { panelId: r.contribution.id }
1994
+ })
1995
+ }),
1996
+ isVisible: () => u(r.contribution.when, t.workbench.getPrimaryResource()?.type)
1997
+ }), t.workbench.layout.registerMenuItem(e, r.menuItem)]), Gn = (e, t) => {
1998
+ let n = t?.mode;
1999
+ if (!n) return !0;
2000
+ let r = e.workbench.modes.getActiveModeId() ?? "";
2001
+ return Array.isArray(n) ? n.includes(r) : n === r;
2002
+ }, Kn = (e) => (e.metadata.statusBarItems ?? []).map((t) => e.workbench.statusBar.registerItem({
2003
+ id: t.id,
2004
+ viewId: t.viewId,
2005
+ slot: t.slot,
2006
+ order: t.order,
2007
+ isVisible: () => Gn(e, t.when)
2008
+ })), qn = (e) => e.metadata.pages.map((t) => e.workbench.pages.registerPage(t)), Jn = (e) => e.metadata.resourceKinds.map((t) => e.workbench.resources.registerKind({
2009
+ kind: t.id,
2010
+ label: M(t.label, t.id),
2011
+ icon: t.icon ?? "FileText"
2012
+ })), Yn = (e) => e.metadata.modes.map((t) => e.workbench.modes.registerMode({
2013
+ id: t.modeId,
2014
+ label: M(t.label, t.modeId),
2015
+ panels: t.panelRegions,
2016
+ regionSettings: t.regionSettings,
2017
+ floatingPanels: t.floatingPanels,
2018
+ defaultTheme: t.defaultTheme,
2019
+ chrome: t.chrome,
2020
+ activate: () => void 0
2021
+ })), Xn = (e) => e.metadata.placements.map((t) => e.workbench.modePlacements.registerPlacement(t)), Zn = (e) => {
2022
+ let t = {
2023
+ ...e,
2024
+ metadata: _n(e.metadata, { createTab: (t) => zn(e, t) })
2025
+ }, n = [], r = t;
2026
+ try {
2027
+ return n.push(...Vn(r, t.metadata)), n.push(...rn({
2028
+ bindings: t.metadata.keybindings,
2029
+ createWhenExpression: t.createKeybindingWhenExpression,
2030
+ workbench: t.workbench
2031
+ })), n.push(...Un(t, r)), n.push(...Wn(t, r)), n.push(Kt({
2032
+ ...t,
2033
+ resolveNodeResource: t.resolveTreeNodeResource
2034
+ })), n.push(nt(t)), n.push(Fe(r, t.metadata.controlsRenderers ?? [])), n.push(...jn(t)), n.push(...In(t)), n.push(...Fn(t, r)), n.push(jt(r, t.metadata.kanbanRenderers ?? [], t.kanbanAdapter)), n.push(Be(r, t.metadata.dataTableRenderers ?? [])), n.push(...Nn(t)), n.push(Ne(r, t.metadata.commandPaletteResources ?? [])), n.push(...en({
2035
+ createWhenExpression: e.createNavigationWhenExpression,
2036
+ metadata: e.metadata,
2037
+ workbench: e.workbench
2038
+ })), e.subscribeRefreshEvents && n.push(bn({
2039
+ metadata: e.metadata,
2040
+ subscribe: e.subscribeRefreshEvents,
2041
+ workbench: e.workbench
2042
+ })), n.push(...Kn(t)), n.push(...Jn(t)), n.push(...qn(t)), n.push(...Yn(t)), n.push(...Xn(t)), { dispose() {
2043
+ Bn(n);
2044
+ } };
2045
+ } catch (e) {
2046
+ throw Bn(n), e;
2047
+ }
2399
2048
  };
2400
- //# sourceMappingURL=extensions.js.map
2049
+ //#endregion
2050
+ export { Xe as buildWorkbenchExtensionCommandPaletteRegistrations, Ye as buildWorkbenchExtensionMenuRegistrations, _e as createTerminalSessionCapability, ye as createWorkbenchWebviewHostCapabilities, He as emptyWorkbenchExtensionMetadata, L as executeWorkbenchExtensionCommandResponse, et as fileRendererRefreshEnvelopeFromCommand, Se as getBridgeWebviewHostEventPublisher, P as isExtensionNavigationTarget, xn as refreshOpenWorkbenchExtensionWebviews, vn as refreshWorkbenchExtensionRenderer, Ne as registerWorkbenchExtensionCommandPaletteResources, Zn as registerWorkbenchExtensionContributions, Fe as registerWorkbenchExtensionControlsRenderers, Be as registerWorkbenchExtensionDataTableRenderers, nt as registerWorkbenchExtensionFileRenderers, jt as registerWorkbenchExtensionKanbanRenderers, bn as registerWorkbenchExtensionRendererRefreshEvents, Kt as registerWorkbenchExtensionTreeRenderers, Ce as renderBridgeWebviewFrame, N as toWorkbenchNavigationTarget, F as toWorkbenchNavigationTargetResult, Nt as toWorkbenchWhenExpression };
2051
+
2052
+ //# sourceMappingURL=extensions.js.map