@burdenoff/microfe-timecampus 2026.1124.1 → 2026.1124.2

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.
@@ -2,58 +2,62 @@ import { Modal as e } from "../../components/Modal.js";
2
2
  import { StatusBadge as t } from "../../components/StatusBadge.js";
3
3
  import { formatDate as n } from "../../utils/helpers.js";
4
4
  import { useTimeCampusNavigate as r } from "../../providers/TimeCampusProvider.js";
5
- import { useInstallMarketplaceAppletMutation as i, useInstallThirdPartyAppletMutation as a, useListMarketplaceAppletsQuery as o, useListStoreAppletsQuery as s, useUninstallMarketplaceAppletMutation as c, useUninstallThirdPartyAppletMutation as l } from "../../../generated/wspace-operations.js";
6
- import { appletCategoryLabel as u, catalogueIcon as d } from "./extendHelpers.js";
7
- import { scopeLabel as f } from "./appletBridge.js";
8
- import { errorText as p } from "./appletPublishingHelpers.js";
9
- import { useState as m } from "react";
10
- import { Code as h, Download as g, ShieldCheck as _, Trash2 as v } from "lucide-react";
11
- import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
12
- import { GlassCard as S } from "@burdenoff/fe-libs/ui";
5
+ import { useCancelMarketplaceSubscriptionMutation as i, useCheckoutMarketplaceAppletMutation as a, useInstallMarketplaceAppletMutation as o, useInstallThirdPartyAppletMutation as s, useListMarketplaceAppletsQuery as c, useListStoreAppletsQuery as l, useRequestMarketplaceRefundMutation as u, useSyncMarketplacePurchaseMutation as d, useUninstallMarketplaceAppletMutation as f, useUninstallThirdPartyAppletMutation as p } from "../../../generated/wspace-operations.js";
6
+ import { appletCategoryLabel as m, catalogueIcon as h } from "./extendHelpers.js";
7
+ import { scopeLabel as g } from "./appletBridge.js";
8
+ import { entitlementBadge as _, errorText as v, formatAppletPrice as y, formatUsd as b } from "./appletPublishingHelpers.js";
9
+ import { useState as x } from "react";
10
+ import { Code as S, CreditCard as C, Download as w, ExternalLink as T, RefreshCw as E, RotateCcw as D, ShieldCheck as O, Trash2 as k } from "lucide-react";
11
+ import { Fragment as A, jsx as j, jsxs as M } from "react/jsx-runtime";
12
+ import { GlassCard as N } from "@burdenoff/fe-libs/ui";
13
13
  // src/timecampus/pages/extend/ThirdPartyAppletsSection.tsx
14
- var C = ["ListStoreApplets", "GetWidgetDashboard"], w = ["ListMarketplaceApplets", "GetWidgetDashboard"], T = "inline-flex items-center justify-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-1.5 text-sm font-medium text-action-primary-text hover:bg-action-primary-bg/90 disabled:opacity-50", E = "inline-flex items-center justify-center gap-1.5 rounded-md border border-border-subtle bg-bg-surface px-3 py-1.5 text-sm font-medium text-text-primary hover:bg-bg-surface-hover disabled:opacity-50";
15
- function D({ applet: t, busy: n, onCancel: r, onConfirm: i }) {
16
- let [a, o] = m(() => t.installed ? [...t.grantedScopes] : [...t.requestedScopes]), s = (e) => o((t) => t.includes(e) ? t.filter((t) => t !== e) : [...t, e]);
17
- return /* @__PURE__ */ b(e, {
14
+ var P = ["ListStoreApplets", "GetWidgetDashboard"], F = [
15
+ "ListMarketplaceApplets",
16
+ "ListMarketplacePurchases",
17
+ "GetWidgetDashboard"
18
+ ], I = "inline-flex items-center justify-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-1.5 text-sm font-medium text-action-primary-text hover:bg-action-primary-bg/90 disabled:opacity-50", L = "inline-flex items-center justify-center gap-1.5 rounded-md border border-border-subtle bg-bg-surface px-3 py-1.5 text-sm font-medium text-text-primary hover:bg-bg-surface-hover disabled:opacity-50";
19
+ function R({ applet: t, busy: n, onCancel: r, onConfirm: i }) {
20
+ let [a, o] = x(() => t.installed ? [...t.grantedScopes] : [...t.requestedScopes]), s = (e) => o((t) => t.includes(e) ? t.filter((t) => t !== e) : [...t, e]);
21
+ return /* @__PURE__ */ j(e, {
18
22
  open: !0,
19
23
  onClose: r,
20
24
  title: t.installed ? `Data access for ${t.name}` : `Install ${t.name}`,
21
25
  description: "Third-party widgets run in a sandbox and only receive the data you grant here.",
22
- footer: /* @__PURE__ */ x("div", {
26
+ footer: /* @__PURE__ */ M("div", {
23
27
  className: "flex justify-end gap-2",
24
- children: [/* @__PURE__ */ b("button", {
28
+ children: [/* @__PURE__ */ j("button", {
25
29
  type: "button",
26
- className: E,
30
+ className: L,
27
31
  onClick: r,
28
32
  children: "Cancel"
29
- }), /* @__PURE__ */ b("button", {
33
+ }), /* @__PURE__ */ j("button", {
30
34
  type: "button",
31
- className: T,
35
+ className: I,
32
36
  disabled: n,
33
37
  onClick: () => i(a),
34
38
  children: n ? "Saving…" : t.installed ? "Save access" : "Install"
35
39
  })]
36
40
  }),
37
- children: t.requestedScopes.length === 0 ? /* @__PURE__ */ b("p", {
41
+ children: t.requestedScopes.length === 0 ? /* @__PURE__ */ j("p", {
38
42
  className: "text-sm text-text-secondary",
39
43
  children: "This applet does not ask for any TimeCampus data."
40
- }) : /* @__PURE__ */ x("fieldset", {
44
+ }) : /* @__PURE__ */ M("fieldset", {
41
45
  className: "flex flex-col gap-2",
42
- children: [/* @__PURE__ */ x("legend", {
46
+ children: [/* @__PURE__ */ M("legend", {
43
47
  className: "mb-1 text-sm font-medium text-text-primary",
44
48
  children: [t.name, " asks to read:"]
45
- }), t.requestedScopes.map((e) => /* @__PURE__ */ x("label", {
49
+ }), t.requestedScopes.map((e) => /* @__PURE__ */ M("label", {
46
50
  className: "flex items-start gap-2 text-sm text-text-secondary",
47
- children: [/* @__PURE__ */ b("input", {
51
+ children: [/* @__PURE__ */ j("input", {
48
52
  type: "checkbox",
49
53
  className: "mt-0.5",
50
54
  checked: a.includes(e),
51
55
  onChange: () => s(e),
52
- "aria-label": f(e)
53
- }), /* @__PURE__ */ x("span", { children: [
54
- f(e),
56
+ "aria-label": g(e)
57
+ }), /* @__PURE__ */ M("span", { children: [
58
+ g(e),
55
59
  " ",
56
- /* @__PURE__ */ b("code", {
60
+ /* @__PURE__ */ j("code", {
57
61
  className: "text-xs text-text-tertiary",
58
62
  children: e
59
63
  })
@@ -62,39 +66,136 @@ function D({ applet: t, busy: n, onCancel: r, onConfirm: i }) {
62
66
  })
63
67
  });
64
68
  }
65
- function O({ applet: e, busy: r, onInstall: i, onUninstall: a }) {
66
- let o = d(e.icon);
67
- return /* @__PURE__ */ x(S, {
69
+ function z({ applet: t, busy: n, checkout: r, paidPlanBlocked: i, onCancel: a, onStartCheckout: o, onSyncPurchase: s, onOpenBillingPlans: c }) {
70
+ let l = t.pricingModel === "PER_SEAT_MONTHLY";
71
+ return /* @__PURE__ */ j(e, {
72
+ open: !0,
73
+ onClose: a,
74
+ title: `Buy ${t.name}`,
75
+ description: "Payments are processed through the Burdenoff platform billing module.",
76
+ footer: /* @__PURE__ */ M("div", {
77
+ className: "flex flex-wrap justify-end gap-2",
78
+ children: [/* @__PURE__ */ j("button", {
79
+ type: "button",
80
+ className: L,
81
+ onClick: a,
82
+ children: "Close"
83
+ }), i ? /* @__PURE__ */ M("button", {
84
+ type: "button",
85
+ className: I,
86
+ onClick: c,
87
+ children: [/* @__PURE__ */ j(T, {
88
+ className: "h-4 w-4",
89
+ "aria-hidden": "true"
90
+ }), "Upgrade in Billing"]
91
+ }) : r ? /* @__PURE__ */ M("button", {
92
+ type: "button",
93
+ className: I,
94
+ disabled: n,
95
+ onClick: () => s(r.purchase.id),
96
+ children: [/* @__PURE__ */ j(E, {
97
+ className: "h-4 w-4",
98
+ "aria-hidden": "true"
99
+ }), n ? "Checking payment…" : "Verify payment & unlock"]
100
+ }) : /* @__PURE__ */ M("button", {
101
+ type: "button",
102
+ className: I,
103
+ disabled: n,
104
+ onClick: o,
105
+ children: [/* @__PURE__ */ j(C, {
106
+ className: "h-4 w-4",
107
+ "aria-hidden": "true"
108
+ }), n ? "Starting checkout…" : "Continue to Billing checkout"]
109
+ })]
110
+ }),
111
+ children: /* @__PURE__ */ M("div", {
112
+ className: "flex flex-col gap-3 text-sm text-text-secondary",
113
+ children: [
114
+ /* @__PURE__ */ M("div", {
115
+ className: "rounded-md border border-border-subtle bg-bg-sunken/40 p-3",
116
+ children: [/* @__PURE__ */ j("p", {
117
+ className: "font-medium text-text-primary",
118
+ children: y(t.pricingModel, t.priceUsd)
119
+ }), /* @__PURE__ */ j("p", {
120
+ className: "mt-1 text-xs text-text-tertiary",
121
+ children: l ? "Billed monthly per active workspace member. Cancel anytime; access continues until the end of the paid period." : "One-time charge per workspace. Perpetual license for this major version; full refund available within 14 days."
122
+ })]
123
+ }),
124
+ i && /* @__PURE__ */ j("div", {
125
+ className: "rounded-md border border-status-warning-border bg-status-warning-bg p-3 text-xs text-status-warning-text",
126
+ children: "Paid marketplace applets require an active paid TimeCampus subscription. Upgrade your workspace plan in Billing, then return here to complete purchase."
127
+ }),
128
+ r && /* @__PURE__ */ M("div", {
129
+ className: "rounded-md border border-border-subtle bg-bg-surface p-3 text-xs",
130
+ "data-testid": "marketplace-checkout-summary",
131
+ children: [
132
+ /* @__PURE__ */ M("p", {
133
+ className: "font-medium text-text-primary",
134
+ children: [
135
+ "Order ",
136
+ r.purchase.orderNumber,
137
+ r.testMode ? " (Test mode)" : ""
138
+ ]
139
+ }),
140
+ /* @__PURE__ */ M("p", {
141
+ className: "mt-1",
142
+ children: [
143
+ "Provider: ",
144
+ /* @__PURE__ */ j("code", { children: r.payment?.provider ?? "BILLING" }),
145
+ " · Seats: ",
146
+ r.purchase.seatCount,
147
+ " · Subtotal:",
148
+ " ",
149
+ b(r.payment?.subtotal ?? r.purchase.grossAmount),
150
+ " ",
151
+ "· Total:",
152
+ " ",
153
+ b(r.payment?.total ?? r.purchase.grossAmount)
154
+ ]
155
+ }),
156
+ /* @__PURE__ */ j("p", {
157
+ className: "mt-1 text-text-tertiary",
158
+ children: "Complete payment in Billing, then click “Verify payment & unlock” to issue your workspace's signed license key."
159
+ })
160
+ ]
161
+ })
162
+ ]
163
+ })
164
+ });
165
+ }
166
+ function B({ applet: e, busy: r, onInstall: i, onBuy: a, onUninstall: o, onCancelSubscription: s, onRequestRefund: c }) {
167
+ let l = h(e.icon), u = e.pricingModel !== "FREE" && e.priceUsd > 0, d = e.source === "MARKETPLACE" && u && e.entitlementStatus !== "ACTIVE", f = e.source === "MARKETPLACE" && u && (e.entitlementStatus === "EXPIRED" || e.entitlementStatus === "SUSPENDED" || e.entitlementStatus === "REVOKED" || e.entitlementStatus === "REFUNDED"), p = _(e.entitlementStatus);
168
+ return /* @__PURE__ */ M(N, {
68
169
  treatment: "glass",
69
170
  className: "flex h-full flex-col gap-3 p-5",
70
171
  "data-testid": e.source === "MARKETPLACE" ? `marketplace-applet-card-${e.key}` : `store-applet-card-${e.key}`,
71
172
  children: [
72
- /* @__PURE__ */ x("div", {
173
+ /* @__PURE__ */ M("div", {
73
174
  className: "flex items-start gap-3",
74
175
  children: [
75
- /* @__PURE__ */ b("div", {
176
+ /* @__PURE__ */ j("div", {
76
177
  className: "flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-action-primary-bg/10 text-primary",
77
- children: /* @__PURE__ */ b(o, {
178
+ children: /* @__PURE__ */ j(l, {
78
179
  className: "h-5 w-5",
79
180
  "aria-hidden": "true"
80
181
  })
81
182
  }),
82
- /* @__PURE__ */ x("div", {
183
+ /* @__PURE__ */ M("div", {
83
184
  className: "min-w-0 flex-1",
84
185
  children: [
85
- /* @__PURE__ */ x("p", {
186
+ /* @__PURE__ */ M("p", {
86
187
  className: "text-xs font-medium uppercase tracking-wide text-text-tertiary",
87
188
  children: [
88
- u(e.category),
189
+ m(e.category),
89
190
  " · v",
90
191
  e.version
91
192
  ]
92
193
  }),
93
- /* @__PURE__ */ b("h3", {
194
+ /* @__PURE__ */ j("h3", {
94
195
  className: "truncate text-base font-semibold text-text-primary",
95
196
  children: e.name
96
197
  }),
97
- e.developerName && /* @__PURE__ */ x("p", {
198
+ e.developerName && /* @__PURE__ */ M("p", {
98
199
  className: "text-xs text-text-tertiary",
99
200
  children: [
100
201
  "By ",
@@ -104,18 +205,31 @@ function O({ applet: e, busy: r, onInstall: i, onUninstall: a }) {
104
205
  })
105
206
  ]
106
207
  }),
107
- e.installed && /* @__PURE__ */ b(t, {
108
- label: "Installed",
109
- variant: "success",
110
- dot: !0
208
+ /* @__PURE__ */ M("div", {
209
+ className: "flex flex-col items-end gap-1",
210
+ children: [
211
+ e.source === "MARKETPLACE" && /* @__PURE__ */ j(t, {
212
+ label: y(e.pricingModel, e.priceUsd),
213
+ variant: u ? "info" : "muted"
214
+ }),
215
+ e.installed && /* @__PURE__ */ j(t, {
216
+ label: "Installed",
217
+ variant: "success",
218
+ dot: !0
219
+ }),
220
+ e.source === "MARKETPLACE" && u && /* @__PURE__ */ j(t, {
221
+ label: p.label,
222
+ variant: p.variant
223
+ })
224
+ ]
111
225
  })
112
226
  ]
113
227
  }),
114
- /* @__PURE__ */ b("p", {
228
+ /* @__PURE__ */ j("p", {
115
229
  className: "flex-1 text-sm text-text-secondary",
116
230
  children: e.description
117
231
  }),
118
- /* @__PURE__ */ x("p", {
232
+ /* @__PURE__ */ M("p", {
119
233
  className: "text-xs text-text-tertiary",
120
234
  children: [
121
235
  "Adds ",
@@ -123,42 +237,80 @@ function O({ applet: e, busy: r, onInstall: i, onUninstall: a }) {
123
237
  " widget",
124
238
  e.widgetKeys.length === 1 ? "" : "s",
125
239
  " to My Widgets",
126
- e.installed && e.installedAt ? ` · installed ${n(e.installedAt)}` : ""
240
+ e.installed && e.installedAt ? ` · installed ${n(e.installedAt)}` : "",
241
+ e.seatCount && e.pricingModel === "PER_SEAT_MONTHLY" ? ` · ${e.seatCount} seat${e.seatCount === 1 ? "" : "s"}` : "",
242
+ e.currentPeriodEnd ? ` · ${e.cancelAtPeriodEnd ? "ends" : "renews"} ${n(e.currentPeriodEnd)}` : ""
127
243
  ]
128
244
  }),
129
- e.installed && e.ungrantedScopes.length > 0 && /* @__PURE__ */ b("p", {
245
+ f && e.entitlementReason && /* @__PURE__ */ j("p", {
246
+ className: "text-xs text-status-warning-text",
247
+ children: e.entitlementReason
248
+ }),
249
+ e.installed && e.ungrantedScopes.length > 0 && /* @__PURE__ */ j("p", {
130
250
  className: "text-xs text-status-warning-text",
131
251
  children: "A newer version asks for more data access."
132
252
  }),
133
- /* @__PURE__ */ b("div", {
253
+ /* @__PURE__ */ j("div", {
134
254
  className: "flex flex-wrap gap-2",
135
- children: e.installed ? /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ x("button", {
136
- type: "button",
137
- className: E,
138
- onClick: i,
139
- disabled: r,
140
- "aria-label": `Data access for ${e.name}`,
141
- children: [/* @__PURE__ */ b(_, {
142
- className: "h-4 w-4",
143
- "aria-hidden": "true"
144
- }), "Data access"]
145
- }), /* @__PURE__ */ x("button", {
255
+ children: e.installed ? /* @__PURE__ */ M(A, { children: [
256
+ /* @__PURE__ */ M("button", {
257
+ type: "button",
258
+ className: L,
259
+ onClick: i,
260
+ disabled: r || d,
261
+ "aria-label": `Data access for ${e.name}`,
262
+ children: [/* @__PURE__ */ j(O, {
263
+ className: "h-4 w-4",
264
+ "aria-hidden": "true"
265
+ }), "Data access"]
266
+ }),
267
+ /* @__PURE__ */ M("button", {
268
+ type: "button",
269
+ className: L,
270
+ onClick: o,
271
+ disabled: r,
272
+ "aria-label": `Remove ${e.name}`,
273
+ children: [/* @__PURE__ */ j(k, {
274
+ className: "h-4 w-4",
275
+ "aria-hidden": "true"
276
+ }), "Remove"]
277
+ }),
278
+ u && e.activePurchaseId && e.entitlementStatus === "ACTIVE" && e.pricingModel === "PER_SEAT_MONTHLY" && !e.cancelAtPeriodEnd && /* @__PURE__ */ j("button", {
279
+ type: "button",
280
+ className: L,
281
+ onClick: s,
282
+ disabled: r,
283
+ "aria-label": `Cancel subscription for ${e.name}`,
284
+ children: "Cancel renewal"
285
+ }),
286
+ u && e.activePurchaseId && e.entitlementStatus === "ACTIVE" && e.pricingModel === "ONE_TIME" && /* @__PURE__ */ M("button", {
287
+ type: "button",
288
+ className: L,
289
+ onClick: c,
290
+ disabled: r,
291
+ "aria-label": `Request refund for ${e.name}`,
292
+ children: [/* @__PURE__ */ j(D, {
293
+ className: "h-4 w-4",
294
+ "aria-hidden": "true"
295
+ }), "14-day refund"]
296
+ })
297
+ ] }) : d ? /* @__PURE__ */ M("button", {
146
298
  type: "button",
147
- className: E,
299
+ className: I,
148
300
  onClick: a,
149
301
  disabled: r,
150
- "aria-label": `Remove ${e.name}`,
151
- children: [/* @__PURE__ */ b(v, {
302
+ "aria-label": `Buy ${e.name}`,
303
+ children: [/* @__PURE__ */ j(C, {
152
304
  className: "h-4 w-4",
153
305
  "aria-hidden": "true"
154
- }), "Remove"]
155
- })] }) : /* @__PURE__ */ x("button", {
306
+ }), e.entitlementStatus === "EXPIRED" ? "Renew" : "Buy & Install"]
307
+ }) : /* @__PURE__ */ M("button", {
156
308
  type: "button",
157
- className: T,
309
+ className: I,
158
310
  onClick: i,
159
311
  disabled: r,
160
312
  "aria-label": `Install ${e.name}`,
161
- children: [/* @__PURE__ */ b(g, {
313
+ children: [/* @__PURE__ */ j(w, {
162
314
  className: "h-4 w-4",
163
315
  "aria-hidden": "true"
164
316
  }), "Install"]
@@ -167,15 +319,15 @@ function O({ applet: e, busy: r, onInstall: i, onUninstall: a }) {
167
319
  ]
168
320
  });
169
321
  }
170
- var k = [{
322
+ var V = [{
171
323
  key: "workspace",
172
324
  label: "Workspace applets"
173
325
  }, {
174
326
  key: "marketplace",
175
327
  label: "Marketplace"
176
328
  }];
177
- function A(e) {
178
- let { data: t, loading: n, error: r } = s({ skip: e }), [i] = a({ refetchQueries: C }), [o] = l({ refetchQueries: C });
329
+ function H(e) {
330
+ let { data: t, loading: n, error: r } = l({ skip: e }), [i] = s({ refetchQueries: P }), [a] = p({ refetchQueries: P });
179
331
  return {
180
332
  applets: t?.timeCampusStoreApplets ?? [],
181
333
  loading: n && !t,
@@ -184,146 +336,243 @@ function A(e) {
184
336
  id: e,
185
337
  grantedScopes: t
186
338
  } }),
187
- uninstall: (e) => o({ variables: { id: e } })
339
+ uninstall: (e) => a({ variables: { id: e } })
188
340
  };
189
341
  }
190
- function j(e) {
191
- let { data: t, loading: n, error: r } = o({ skip: e }), [a] = i({ refetchQueries: w }), [s] = c({ refetchQueries: w });
342
+ function U(e) {
343
+ let { data: t, loading: n, error: r } = c({ skip: e }), [i] = o({ refetchQueries: F }), [a] = f({ refetchQueries: F });
192
344
  return {
193
345
  applets: t?.timeCampusMarketplaceApplets ?? [],
194
346
  loading: n && !t,
195
347
  error: r,
196
- install: (e, t) => a({ variables: {
348
+ install: (e, t) => i({ variables: {
197
349
  id: e,
198
350
  grantedScopes: t
199
351
  } }),
200
- uninstall: (e) => s({ variables: { id: e } })
352
+ uninstall: (e) => a({ variables: { id: e } })
201
353
  };
202
354
  }
203
- function M({ workspaceId: e, addToast: t }) {
204
- let n = r(), [i, a] = m("workspace"), [o, s] = m(null), [c, l] = m(null), u = A(!e || i !== "workspace"), d = j(!e || i !== "marketplace"), f = i === "workspace" ? u : d, { applets: g, loading: v, error: y } = f, S = async (e, n) => {
205
- l(e.id);
355
+ function W({ workspaceId: e, addToast: t }) {
356
+ let n = r(), [o, s] = x("workspace"), [c, l] = x(null), [f, p] = x(null), [m, h] = x(null), [g, _] = x(!1), [y, b] = x(null), C = H(!e || o !== "workspace"), w = U(!e || o !== "marketplace"), [T] = a({ refetchQueries: F }), [E] = d({ refetchQueries: F }), [D] = i({ refetchQueries: F }), [k] = u({ refetchQueries: F }), A = o === "workspace" ? C : w, { applets: N, loading: P, error: I } = A, W = async (e, n) => {
357
+ b(e.id);
206
358
  try {
207
- await f.install(e.id, n), s(null), t({
359
+ await A.install(e.id, n), l(null), t({
208
360
  title: e.installed ? `Data access for ${e.name} saved` : `${e.name} installed`,
209
361
  description: "Its widgets are available in My Widgets.",
210
362
  variant: "success"
211
363
  });
212
364
  } catch (e) {
213
365
  t({
214
- title: p(e),
366
+ title: v(e),
215
367
  variant: "error"
216
368
  });
217
369
  } finally {
218
- l(null);
370
+ b(null);
219
371
  }
220
- }, C = async (e) => {
221
- l(e.id);
372
+ }, G = async (e) => {
373
+ b(e.id);
222
374
  try {
223
- await f.uninstall(e.id), t({
375
+ await A.uninstall(e.id), t({
224
376
  title: `${e.name} removed`,
225
377
  variant: "success"
226
378
  });
227
379
  } catch (e) {
228
380
  t({
229
- title: p(e),
381
+ title: v(e),
382
+ variant: "error"
383
+ });
384
+ } finally {
385
+ b(null);
386
+ }
387
+ }, K = (e) => {
388
+ h(null), _(!1), p(e);
389
+ }, q = async (e) => {
390
+ b(e.id), _(!1);
391
+ try {
392
+ let n = (await T({ variables: { listingId: e.id } })).data?.checkoutTimeCampusMarketplaceApplet;
393
+ n && (h(n), t({
394
+ title: `Billing order ${n.purchase.orderNumber} created`,
395
+ description: "Complete payment in Billing, then verify to unlock your signed license.",
396
+ variant: "success"
397
+ }));
398
+ } catch (e) {
399
+ let n = e instanceof Error ? e.message : "";
400
+ /paid.*plan|paid.*subscription/i.test(n) && _(!0), t({
401
+ title: v(e),
402
+ variant: "error"
403
+ });
404
+ } finally {
405
+ b(null);
406
+ }
407
+ }, J = async (e, n) => {
408
+ b(e.id);
409
+ try {
410
+ let r = (await E({ variables: { purchaseId: n } })).data?.syncTimeCampusMarketplacePurchase;
411
+ r?.status === "PAID" && r.hasValidLicense ? (p(null), h(null), l(e), t({
412
+ title: `License activated for ${e.name}`,
413
+ description: "Grant data scopes to complete installation.",
414
+ variant: "success"
415
+ })) : t({
416
+ title: "Payment not confirmed yet",
417
+ description: "Finish payment in Billing and click verify again once settled.",
418
+ variant: "error"
419
+ });
420
+ } catch (e) {
421
+ t({
422
+ title: v(e),
230
423
  variant: "error"
231
424
  });
232
425
  } finally {
233
- l(null);
426
+ b(null);
427
+ }
428
+ }, Y = async (e) => {
429
+ if (e.activePurchaseId && window.confirm(`Cancel automatic renewal for ${e.name}? Access continues until the end of your paid period with no partial-month refund.`)) {
430
+ b(e.id);
431
+ try {
432
+ await D({ variables: { purchaseId: e.activePurchaseId } }), t({
433
+ title: `Renewal canceled for ${e.name}`,
434
+ description: "Access continues until the current paid period ends.",
435
+ variant: "success"
436
+ });
437
+ } catch (e) {
438
+ t({
439
+ title: v(e),
440
+ variant: "error"
441
+ });
442
+ } finally {
443
+ b(null);
444
+ }
234
445
  }
235
- }, w = (e) => {
236
- s(null), a(e);
446
+ }, X = async (e) => {
447
+ if (e.activePurchaseId && window.confirm(`Request a full 14-day refund for ${e.name}? This revokes the license and removes the applet from your workspace.`)) {
448
+ b(e.id);
449
+ try {
450
+ await k({ variables: {
451
+ purchaseId: e.activePurchaseId,
452
+ reason: "Workspace admin 14-day refund request"
453
+ } }), t({
454
+ title: `Refund processed for ${e.name}`,
455
+ description: "The license was revoked and the applet was uninstalled.",
456
+ variant: "success"
457
+ });
458
+ } catch (e) {
459
+ t({
460
+ title: v(e),
461
+ variant: "error"
462
+ });
463
+ } finally {
464
+ b(null);
465
+ }
466
+ }
467
+ }, Z = (e) => {
468
+ l(null), p(null), s(e);
237
469
  };
238
- return /* @__PURE__ */ x("section", {
470
+ return /* @__PURE__ */ M("section", {
239
471
  className: "mt-8",
240
472
  "aria-labelledby": "workspace-applets-heading",
241
473
  children: [
242
- /* @__PURE__ */ x("div", {
474
+ /* @__PURE__ */ M("div", {
243
475
  className: "mb-3 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",
244
- children: [/* @__PURE__ */ x("div", { children: [/* @__PURE__ */ b("h2", {
476
+ children: [/* @__PURE__ */ M("div", { children: [/* @__PURE__ */ j("h2", {
245
477
  id: "workspace-applets-heading",
246
478
  className: "text-base font-semibold text-text-primary",
247
479
  children: "Third-party applets"
248
- }), /* @__PURE__ */ x("p", {
480
+ }), /* @__PURE__ */ M("p", {
249
481
  className: "text-sm text-text-secondary",
250
482
  children: [
251
- i === "workspace" ? "Applets built by developers in this workspace and certified by a reviewer." : "Applets from developers in any workspace, certified by the TimeCampus platform team.",
483
+ o === "workspace" ? "Applets built by developers in this workspace and certified by a reviewer." : "Applets from developers in any workspace, certified by the TimeCampus platform team.",
252
484
  " ",
253
485
  "They run sandboxed and only see the data you grant."
254
486
  ]
255
- })] }), /* @__PURE__ */ x("div", {
487
+ })] }), /* @__PURE__ */ M("div", {
256
488
  className: "flex flex-wrap gap-2",
257
- children: [/* @__PURE__ */ x("button", {
489
+ children: [/* @__PURE__ */ M("button", {
258
490
  type: "button",
259
- className: E,
491
+ className: L,
260
492
  onClick: () => n("/applets/developer"),
261
- children: [/* @__PURE__ */ b(h, {
493
+ children: [/* @__PURE__ */ j(S, {
262
494
  className: "h-4 w-4",
263
495
  "aria-hidden": "true"
264
496
  }), "Build an applet"]
265
- }), /* @__PURE__ */ x("button", {
497
+ }), /* @__PURE__ */ M("button", {
266
498
  type: "button",
267
- className: E,
499
+ className: L,
268
500
  onClick: () => n("/applets/review"),
269
- children: [/* @__PURE__ */ b(_, {
501
+ children: [/* @__PURE__ */ j(O, {
270
502
  className: "h-4 w-4",
271
503
  "aria-hidden": "true"
272
504
  }), "Review queue"]
273
505
  })]
274
506
  })]
275
507
  }),
276
- /* @__PURE__ */ b("div", {
508
+ /* @__PURE__ */ j("div", {
277
509
  className: "mb-4 inline-flex w-fit items-center rounded-lg border border-border-subtle bg-bg-sunken/50 p-0.5",
278
510
  role: "tablist",
279
511
  "aria-label": "Applet source",
280
- children: k.map(({ key: e, label: t }) => {
281
- let n = i === e;
282
- return /* @__PURE__ */ b("button", {
512
+ children: V.map(({ key: e, label: t }) => {
513
+ let n = o === e;
514
+ return /* @__PURE__ */ j("button", {
283
515
  type: "button",
284
516
  role: "tab",
285
517
  "aria-selected": n,
286
- onClick: () => w(e),
518
+ onClick: () => Z(e),
287
519
  "data-testid": `applet-store-tab-${e}`,
288
520
  className: n ? "rounded-md bg-bg-surface px-3 py-1.5 text-sm font-medium text-text-primary shadow-sm" : "rounded-md px-3 py-1.5 text-sm font-medium text-text-secondary transition-colors hover:text-text-primary",
289
521
  children: t
290
522
  }, e);
291
523
  })
292
524
  }),
293
- v ? /* @__PURE__ */ b("p", {
525
+ P ? /* @__PURE__ */ j("p", {
294
526
  className: "text-sm text-text-secondary",
295
527
  children: "Loading…"
296
- }) : y ? /* @__PURE__ */ x("p", {
528
+ }) : I ? /* @__PURE__ */ M("p", {
297
529
  className: "text-sm text-text-secondary",
298
530
  children: [
299
531
  "Couldn't load ",
300
- i === "workspace" ? "workspace" : "marketplace",
532
+ o === "workspace" ? "workspace" : "marketplace",
301
533
  " ",
302
534
  "applets: ",
303
- y.message
535
+ I.message
304
536
  ]
305
- }) : g.length === 0 ? /* @__PURE__ */ b("p", {
537
+ }) : N.length === 0 ? /* @__PURE__ */ j("p", {
306
538
  className: "text-sm text-text-secondary",
307
- "data-testid": `${i}-applets-empty`,
308
- children: i === "workspace" ? "No workspace applets are published yet. Developers can build one from a manifest and submit it for review." : "No marketplace applets are certified yet. A developer can offer a published workspace applet to every workspace from the Applet Developer page."
309
- }) : /* @__PURE__ */ b("div", {
539
+ "data-testid": `${o}-applets-empty`,
540
+ children: o === "workspace" ? "No workspace applets are published yet. Developers can build one from a manifest and submit it for review." : "No marketplace applets are certified yet. A developer can offer a published workspace applet to every workspace from the Applet Developer page."
541
+ }) : /* @__PURE__ */ j("div", {
310
542
  className: "grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4",
311
- children: g.map((e) => /* @__PURE__ */ b(O, {
543
+ children: N.map((e) => /* @__PURE__ */ j(B, {
312
544
  applet: e,
313
- busy: c === e.id,
314
- onInstall: () => s(e),
315
- onUninstall: () => C(e)
545
+ busy: y === e.id,
546
+ onInstall: () => l(e),
547
+ onBuy: () => K(e),
548
+ onUninstall: () => void G(e),
549
+ onCancelSubscription: () => void Y(e),
550
+ onRequestRefund: () => void X(e)
316
551
  }, e.id))
317
552
  }),
318
- o && /* @__PURE__ */ b(D, {
319
- applet: o,
320
- busy: c === o.id,
321
- onCancel: () => s(null),
322
- onConfirm: (e) => S(o, e)
553
+ c && /* @__PURE__ */ j(R, {
554
+ applet: c,
555
+ busy: y === c.id,
556
+ onCancel: () => l(null),
557
+ onConfirm: (e) => void W(c, e)
558
+ }),
559
+ f && /* @__PURE__ */ j(z, {
560
+ applet: f,
561
+ busy: y === f.id,
562
+ checkout: m,
563
+ paidPlanBlocked: g,
564
+ onCancel: () => {
565
+ p(null), h(null);
566
+ },
567
+ onStartCheckout: () => void q(f),
568
+ onSyncPurchase: (e) => void J(f, e),
569
+ onOpenBillingPlans: () => {
570
+ p(null), window.location.assign("/billing/plans");
571
+ }
323
572
  })
324
573
  ]
325
574
  });
326
575
  }
327
- export { M as ThirdPartyAppletsSection };
576
+ export { W as ThirdPartyAppletsSection };
328
577
 
329
578
  //# sourceMappingURL=ThirdPartyAppletsSection.js.map