@kky42/pievo-server 1.0.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.
Files changed (197) hide show
  1. package/.output/nitro.json +17 -0
  2. package/.output/public/assets/CodeField-dOzyFQNH.js +34 -0
  3. package/.output/public/assets/LoopView-B4H9QibC.js +55 -0
  4. package/.output/public/assets/Modal-D33gNSgx.js +1 -0
  5. package/.output/public/assets/SignIn-SHuRRyOv.js +1 -0
  6. package/.output/public/assets/actionUi-ChGGALzg.js +1 -0
  7. package/.output/public/assets/app-DElSo_jy.css +2 -0
  8. package/.output/public/assets/artifactView-DFuubXLJ.js +66 -0
  9. package/.output/public/assets/index-DfpTWRSz.js +12 -0
  10. package/.output/public/assets/invite._token-DJtd-XE2.js +1 -0
  11. package/.output/public/assets/invite._token-T8oo4Qtw.js +1 -0
  12. package/.output/public/assets/jsx-runtime-BseJUIpC.js +1 -0
  13. package/.output/public/assets/lifecycleUi-DKkChdnU.js +1 -0
  14. package/.output/public/assets/loopApi-BM2nj71x.js +3 -0
  15. package/.output/public/assets/loops._loopId-B19Jw7jC.js +5 -0
  16. package/.output/public/assets/loops._loopId_.runs._runId-_CflHV38.js +3 -0
  17. package/.output/public/assets/notifyFns-DCubjpRy.js +1 -0
  18. package/.output/public/assets/preload-helper-CKUiEq3b.js +3 -0
  19. package/.output/public/assets/routes-B9tgli5f.js +1 -0
  20. package/.output/public/assets/routes-CTtlM_qt.js +1 -0
  21. package/.output/public/assets/t._teamId-Bm21mngW.js +1 -0
  22. package/.output/public/assets/t._teamId-gR7BVKkR.js +1 -0
  23. package/.output/public/assets/ui-Dp88qUWh.js +1 -0
  24. package/.output/public/assets/useRouter-DsjH8G0p.js +1 -0
  25. package/.output/public/favicon.svg +12 -0
  26. package/.output/public/fonts/GeistPixel-Square.woff2 +0 -0
  27. package/.output/server/_chunks/ssr-renderer.mjs +26 -0
  28. package/.output/server/_libs/@aws-crypto/crc32+[...].mjs +419 -0
  29. package/.output/server/_libs/@aws-sdk/checksums+[...].mjs +10732 -0
  30. package/.output/server/_libs/@aws-sdk/client-s3+[...].mjs +9475 -0
  31. package/.output/server/_libs/@aws-sdk/credential-provider-http+[...].mjs +137 -0
  32. package/.output/server/_libs/@aws-sdk/credential-provider-ini+[...].mjs +440 -0
  33. package/.output/server/_libs/@aws-sdk/credential-provider-process+[...].mjs +62 -0
  34. package/.output/server/_libs/@aws-sdk/credential-provider-sso+[...].mjs +818 -0
  35. package/.output/server/_libs/@aws-sdk/credential-provider-web-identity+[...].mjs +59 -0
  36. package/.output/server/_libs/@base-ui/react+[...].mjs +11125 -0
  37. package/.output/server/_libs/@codemirror/autocomplete+[...].mjs +19713 -0
  38. package/.output/server/_libs/@codemirror/lang-css+[...].mjs +2636 -0
  39. package/.output/server/_libs/@codemirror/lang-html+[...].mjs +2247 -0
  40. package/.output/server/_libs/@codemirror/lang-json+[...].mjs +79 -0
  41. package/.output/server/_libs/@reduxjs/toolkit+[...].mjs +1736 -0
  42. package/.output/server/_libs/@smithy/credential-provider-imds+[...].mjs +342 -0
  43. package/.output/server/_libs/@tanstack/react-router+[...].mjs +14300 -0
  44. package/.output/server/_libs/@uiw/codemirror-extensions-basic-setup+[...].mjs +76 -0
  45. package/.output/server/_libs/atomic-sleep.mjs +27 -0
  46. package/.output/server/_libs/aws-crypto__crc32c.mjs +314 -0
  47. package/.output/server/_libs/aws-sdk__nested-clients.mjs +2671 -0
  48. package/.output/server/_libs/babel__runtime.mjs +30 -0
  49. package/.output/server/_libs/clsx.mjs +16 -0
  50. package/.output/server/_libs/codemirror__commands.mjs +1725 -0
  51. package/.output/server/_libs/codemirror__lint.mjs +565 -0
  52. package/.output/server/_libs/codemirror__search.mjs +1138 -0
  53. package/.output/server/_libs/codemirror__theme-one-dark.mjs +161 -0
  54. package/.output/server/_libs/colorette.mjs +129 -0
  55. package/.output/server/_libs/croner.mjs +735 -0
  56. package/.output/server/_libs/d3-array.mjs +231 -0
  57. package/.output/server/_libs/d3-color.mjs +330 -0
  58. package/.output/server/_libs/d3-format.mjs +252 -0
  59. package/.output/server/_libs/d3-interpolate.mjs +163 -0
  60. package/.output/server/_libs/d3-path.mjs +77 -0
  61. package/.output/server/_libs/d3-scale+[...].mjs +1907 -0
  62. package/.output/server/_libs/d3-shape.mjs +689 -0
  63. package/.output/server/_libs/dateformat.mjs +341 -0
  64. package/.output/server/_libs/decimal.js-light.mjs +884 -0
  65. package/.output/server/_libs/diff.mjs +732 -0
  66. package/.output/server/_libs/dom-serializer+[...].mjs +708 -0
  67. package/.output/server/_libs/domhandler.mjs +461 -0
  68. package/.output/server/_libs/dompurify.mjs +2111 -0
  69. package/.output/server/_libs/domutils.mjs +868 -0
  70. package/.output/server/_libs/drizzle-orm+postgres.mjs +7689 -0
  71. package/.output/server/_libs/electric-sql__pglite.mjs +14674 -0
  72. package/.output/server/_libs/end-of-stream+once+wrappy.mjs +145 -0
  73. package/.output/server/_libs/es-toolkit.mjs +1737 -0
  74. package/.output/server/_libs/eventemitter3.mjs +236 -0
  75. package/.output/server/_libs/fast-copy.mjs +285 -0
  76. package/.output/server/_libs/fast-safe-stringify.mjs +172 -0
  77. package/.output/server/_libs/h3+rou3+srvx.mjs +1201 -0
  78. package/.output/server/_libs/html-dom-parser+htmlparser2.mjs +1560 -0
  79. package/.output/server/_libs/html-react-parser+[...].mjs +1360 -0
  80. package/.output/server/_libs/initdb.wasm +0 -0
  81. package/.output/server/_libs/marked.mjs +1548 -0
  82. package/.output/server/_libs/on-exit-leak-free.mjs +80 -0
  83. package/.output/server/_libs/pglite.data +37667 -8
  84. package/.output/server/_libs/pglite.wasm +0 -0
  85. package/.output/server/_libs/pino+[...].mjs +3196 -0
  86. package/.output/server/_libs/pino-abstract-transport+split2.mjs +194 -0
  87. package/.output/server/_libs/pino-pretty+[...].mjs +1623 -0
  88. package/.output/server/_libs/pinojs__redact.mjs +280 -0
  89. package/.output/server/_libs/react-redux+[...].mjs +205 -0
  90. package/.output/server/_libs/recharts+victory-vendor.mjs +15875 -0
  91. package/.output/server/_libs/tanstack__history.mjs +342 -0
  92. package/.output/server/_libs/ufo.mjs +64 -0
  93. package/.output/server/_libs/uiw__codemirror-themes.mjs +32 -0
  94. package/.output/server/_libs/uiw__react-codemirror.mjs +354 -0
  95. package/.output/server/_runtime.mjs +37 -0
  96. package/.output/server/_ssr/CodeField-tm4rr6G3.mjs +143 -0
  97. package/.output/server/_ssr/DashboardView-CC7htv28.mjs +2795 -0
  98. package/.output/server/_ssr/LoopPlaybook-BXH8mhiX.mjs +2105 -0
  99. package/.output/server/_ssr/LoopView-DCugEbHx.mjs +1106 -0
  100. package/.output/server/_ssr/Modal-DpKZHLZK.mjs +49 -0
  101. package/.output/server/_ssr/SignIn-dTndU6Hw.mjs +67 -0
  102. package/.output/server/_ssr/actionUi-CZbEixbf.mjs +119 -0
  103. package/.output/server/_ssr/adapters-BS8XosjF.mjs +130 -0
  104. package/.output/server/_ssr/artifactFiles-Cagtj7J0.mjs +61 -0
  105. package/.output/server/_ssr/artifactKind-BW0isV8L.mjs +37 -0
  106. package/.output/server/_ssr/artifactView-DS4O22wl.mjs +304 -0
  107. package/.output/server/_ssr/artifacts-DngKyW2u.mjs +2 -0
  108. package/.output/server/_ssr/auth-DY1DuYZd.mjs +38429 -0
  109. package/.output/server/_ssr/boot-BbtG0ImW.mjs +9010 -0
  110. package/.output/server/_ssr/boot-CMHTxQpJ.mjs +2 -0
  111. package/.output/server/_ssr/bun-sqlite-dialect-BW9W1_Ps-CU1Spd6z.mjs +162 -0
  112. package/.output/server/_ssr/core-RrmWoKne.mjs +5 -0
  113. package/.output/server/_ssr/createServerRpc-BD8Xn_0_.mjs +12 -0
  114. package/.output/server/_ssr/d1-sqlite-dialect-BLC8LXE6-DfG7tB8s.mjs +112 -0
  115. package/.output/server/_ssr/db-DWAuZq1o.mjs +2 -0
  116. package/.output/server/_ssr/dist-BIxFFVZg.mjs +342 -0
  117. package/.output/server/_ssr/empty-plugin-adapters-DKUlnwwl.mjs +5 -0
  118. package/.output/server/_ssr/factory-Blq0DYfT.mjs +6903 -0
  119. package/.output/server/_ssr/invite._token-BRCo9LGB.mjs +36 -0
  120. package/.output/server/_ssr/invite._token-DJxGLILJ.mjs +28 -0
  121. package/.output/server/_ssr/invite._token-NewFt27g.mjs +92 -0
  122. package/.output/server/_ssr/kysely-adapter-D3XTe64J.mjs +2 -0
  123. package/.output/server/_ssr/kysely-migration-tables-JkVUjPF_-bPAX9LR_.mjs +19 -0
  124. package/.output/server/_ssr/lifecycleUi-C9lg1r3r.mjs +38 -0
  125. package/.output/server/_ssr/logger-Dw82jNjH.mjs +2 -0
  126. package/.output/server/_ssr/loopApi-BtfkZQYK.mjs +532 -0
  127. package/.output/server/_ssr/loopApi-Cxe8WyOB.mjs +105 -0
  128. package/.output/server/_ssr/loops._loopId-7NQJPB9W.mjs +30 -0
  129. package/.output/server/_ssr/loops._loopId-DhnArGdL.mjs +1635 -0
  130. package/.output/server/_ssr/loops._loopId_.runs._runId-Bvuo2nki.mjs +29 -0
  131. package/.output/server/_ssr/loops._loopId_.runs._runId-Dip5Xk-q.mjs +674 -0
  132. package/.output/server/_ssr/machineFns-Dvr5ICUy.mjs +266 -0
  133. package/.output/server/_ssr/node-sqlite-dialect-DhyOpJTX.mjs +162 -0
  134. package/.output/server/_ssr/notifyFns-BcMRY5kP.mjs +118 -0
  135. package/.output/server/_ssr/notifyFns-Q458pZmE.mjs +580 -0
  136. package/.output/server/_ssr/router-J8KZ30xw.mjs +678 -0
  137. package/.output/server/_ssr/routes-Bcs4T1ox.mjs +28 -0
  138. package/.output/server/_ssr/routes-BoGrcf-b.mjs +43 -0
  139. package/.output/server/_ssr/routes-D4am3Zff.mjs +28 -0
  140. package/.output/server/_ssr/runDiff-CpEFqo7G.mjs +113 -0
  141. package/.output/server/_ssr/ssr.mjs +5837 -0
  142. package/.output/server/_ssr/start-4ifArtKx.mjs +4 -0
  143. package/.output/server/_ssr/store-b3JcQ08F.mjs +2 -0
  144. package/.output/server/_ssr/t._teamId-CeUhzgzT.mjs +32 -0
  145. package/.output/server/_ssr/t._teamId-DR-hQK7o.mjs +47 -0
  146. package/.output/server/_ssr/t._teamId-Dy_McbRt.mjs +31 -0
  147. package/.output/server/_ssr/teamCookie-B7hLOIie.mjs +10 -0
  148. package/.output/server/_ssr/teamFns-BIDnsg2A.mjs +473 -0
  149. package/.output/server/_ssr/teamFns-DA4ovI5g.mjs +33 -0
  150. package/.output/server/_ssr/tokens-ytd60FUt.mjs +2 -0
  151. package/.output/server/_ssr/ui-Dej2qjuS.mjs +267 -0
  152. package/.output/server/_tanstack-start-manifest_v-CVS6c7re.mjs +95 -0
  153. package/.output/server/drizzle/0000_round_marauders.sql +193 -0
  154. package/.output/server/drizzle/0001_naive_silver_fox.sql +25 -0
  155. package/.output/server/drizzle/0002_funny_sage.sql +12 -0
  156. package/.output/server/drizzle/0003_optimal_slapstick.sql +102 -0
  157. package/.output/server/drizzle/0004_remove_grok_agent.sql +5 -0
  158. package/.output/server/drizzle/0005_heavy_gauntlet.sql +8 -0
  159. package/.output/server/drizzle/0006_tranquil_sharon_carter.sql +1 -0
  160. package/.output/server/drizzle/0007_faulty_starbolt.sql +30 -0
  161. package/.output/server/drizzle/0008_durable_lifecycle_evidence.sql +15 -0
  162. package/.output/server/drizzle/meta/0000_snapshot.json +1333 -0
  163. package/.output/server/drizzle/meta/0001_snapshot.json +1498 -0
  164. package/.output/server/drizzle/meta/0002_snapshot.json +1576 -0
  165. package/.output/server/drizzle/meta/0003_snapshot.json +1666 -0
  166. package/.output/server/drizzle/meta/0005_snapshot.json +1666 -0
  167. package/.output/server/drizzle/meta/0006_snapshot.json +1672 -0
  168. package/.output/server/drizzle/meta/0007_snapshot.json +1787 -0
  169. package/.output/server/drizzle/meta/_journal.json +69 -0
  170. package/.output/server/index.mjs +464 -0
  171. package/.output/server/node_modules/tslib/modules/index.js +70 -0
  172. package/.output/server/node_modules/tslib/modules/package.json +3 -0
  173. package/.output/server/node_modules/tslib/package.json +47 -0
  174. package/.output/server/node_modules/tslib/tslib.js +484 -0
  175. package/.output/server/package.json +9 -0
  176. package/LICENSE +21 -0
  177. package/drizzle/0000_round_marauders.sql +193 -0
  178. package/drizzle/0001_naive_silver_fox.sql +25 -0
  179. package/drizzle/0002_funny_sage.sql +12 -0
  180. package/drizzle/0003_optimal_slapstick.sql +102 -0
  181. package/drizzle/0004_remove_grok_agent.sql +5 -0
  182. package/drizzle/0005_heavy_gauntlet.sql +8 -0
  183. package/drizzle/0006_tranquil_sharon_carter.sql +1 -0
  184. package/drizzle/0007_faulty_starbolt.sql +30 -0
  185. package/drizzle/0008_durable_lifecycle_evidence.sql +15 -0
  186. package/drizzle/meta/0000_snapshot.json +1333 -0
  187. package/drizzle/meta/0001_snapshot.json +1498 -0
  188. package/drizzle/meta/0002_snapshot.json +1576 -0
  189. package/drizzle/meta/0003_snapshot.json +1666 -0
  190. package/drizzle/meta/0005_snapshot.json +1666 -0
  191. package/drizzle/meta/0006_snapshot.json +1672 -0
  192. package/drizzle/meta/0007_snapshot.json +1787 -0
  193. package/drizzle/meta/_journal.json +69 -0
  194. package/package.json +84 -0
  195. package/scripts/pievo-server.mjs +390 -0
  196. package/scripts/prestart.mjs +66 -0
  197. package/scripts/server-cli-lib.mjs +451 -0
@@ -0,0 +1,2795 @@
1
+ import { o as __toESM } from "../_runtime.mjs";
2
+ import { C as require_jsx_runtime, S as require_react, c as TooltipProvider } from "../_libs/@base-ui/react+[...].mjs";
3
+ import { A as selectCls, C as labelCls, E as rel, N as useHydrated, S as isCompleted, _ as fmt, b as inputCls, c as btnDanger, f as btnSm, h as dotLabel, l as btnPrimary, o as btn, p as cronText, r as Pill, t as ErrorBanner, u as btnPrimaryPill, w as lastRunOf, x as isClosed } from "./ui-Dej2qjuS.mjs";
4
+ import { d as useNavigate } from "../_libs/@tanstack/react-router+[...].mjs";
5
+ import { _ as loadOlderRuns, h as listMyTeams, m as listJobs, n as claimStatus, u as getConfig, v as mintClaim } from "./loopApi-Cxe8WyOB.mjs";
6
+ import { n as ModalHead, r as ModalSection, t as Modal } from "./Modal-DpKZHLZK.mjs";
7
+ import { i as PievoLogo, n as GitHubIcon, r as LoopPlaybook, t as GITHUB_URL } from "./LoopPlaybook-BXH8mhiX.mjs";
8
+ import { t as setActiveTeamCookie } from "./teamCookie-B7hLOIie.mjs";
9
+ import { a as getTeamDetail, d as revokeTeamInvite, f as setTeamMemberRole, i as deleteTeam, l as removeTeamMember, n as createTeam, o as leaveTeam, r as createTeamInvite, s as listManagedTeams, t as addTeamMember, u as renameTeam } from "./teamFns-DA4ovI5g.mjs";
10
+ import { r as deriveLoopLifecycle } from "./lifecycleUi-C9lg1r3r.mjs";
11
+ import { a as listChannels, c as testChannel, i as deleteChannel, n as Timeline, o as listMachines, r as createChannel, s as mergeRuns, t as MachinesModal } from "./notifyFns-Q458pZmE.mjs";
12
+ //#region node_modules/.nitro/vite/services/ssr/assets/DashboardView-CC7htv28.js
13
+ var import_react = /* @__PURE__ */ __toESM(require_react());
14
+ var import_jsx_runtime = require_jsx_runtime();
15
+ function LoopCard({ job, onOpen, onPickRun }) {
16
+ const en = job.enabled;
17
+ const last = lastRunOf(job);
18
+ const completed = isCompleted(job);
19
+ const lifecycle = deriveLoopLifecycle(job);
20
+ const closedActive = isClosed(job) && !completed;
21
+ const hydrated = useHydrated();
22
+ const [older, setOlder] = (0, import_react.useState)([]);
23
+ const runs = (0, import_react.useMemo)(() => older.length ? mergeRuns(job.runs ?? [], older) : job.runs ?? [], [job.runs, older]);
24
+ const loadMore = async () => {
25
+ const oldest = runs[0];
26
+ if (!oldest) return 0;
27
+ const more = await loadOlderRuns({ data: {
28
+ loopId: job.id,
29
+ beforeTs: oldest.ts,
30
+ limit: 16
31
+ } });
32
+ if (more.length) setOlder((prev) => mergeRuns(prev, more));
33
+ return more.length;
34
+ };
35
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
36
+ onClick: () => onOpen(job.id),
37
+ className: `mb-[18px] cursor-pointer rounded-card border border-hairline bg-surface px-[26px] pb-5 pt-[22px] shadow-card transition-colors hover:border-wire ${en ? "" : "opacity-60"}`,
38
+ style: { animation: "fadeIn .25s cubic-bezier(0.25,0.1,0.25,1) both" },
39
+ children: [
40
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
41
+ className: "mb-6 flex flex-wrap items-center gap-3",
42
+ children: [
43
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
44
+ type: "button",
45
+ onClick: (e) => {
46
+ e.stopPropagation();
47
+ onOpen(job.id);
48
+ },
49
+ className: "cursor-pointer rounded-sm text-left text-[17px] font-semibold tracking-[-0.01em] text-display outline-none focus-visible:ring-2 focus-visible:ring-interactive focus-visible:ring-offset-4 focus-visible:ring-offset-surface",
50
+ children: job.name
51
+ }),
52
+ lifecycle === "stopping" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pill, {
53
+ tone: "running",
54
+ dot: "pulse",
55
+ children: "Stopping"
56
+ }) : lifecycle === "paused-finishing" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pill, { children: "Paused · current run finishing" }) : lifecycle === "deleting" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pill, { children: "Deleting" }) : job.running ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pill, {
57
+ tone: "running",
58
+ dot: "pulse",
59
+ children: "Running"
60
+ }) : job.queued ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pill, {
61
+ tone: "outline",
62
+ children: "Queued"
63
+ }) : null,
64
+ job.graduation && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pill, { children: job.graduation }),
65
+ completed && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pill, {
66
+ tone: "success",
67
+ dot: "green",
68
+ children: "Completed"
69
+ }),
70
+ !completed && closedActive && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pill, {
71
+ tone: "success",
72
+ title: job.goal ?? void 0,
73
+ children: "Goal"
74
+ }),
75
+ !completed && lifecycle === "paused" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pill, { children: "Paused" }),
76
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
77
+ className: "ml-auto whitespace-nowrap text-meta text-secondary",
78
+ children: [
79
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
80
+ className: "text-primary",
81
+ title: job.cron,
82
+ children: job.scheduleMode === "continuous" ? `continuous · ${job.continuousDelayMinutes}m` : cronText(job.cron)
83
+ }),
84
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
85
+ className: "mx-2.5 text-wire",
86
+ children: "·"
87
+ }),
88
+ job.kind
89
+ ]
90
+ })
91
+ ]
92
+ }),
93
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Timeline, {
94
+ job,
95
+ runs,
96
+ total: job.runCount,
97
+ onLoadMore: loadMore,
98
+ onPickRun: (run) => onPickRun(job.id, run)
99
+ }),
100
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
101
+ className: "mt-[18px] flex items-center gap-2 text-label text-secondary",
102
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [job.runCount, " runs"] }), last && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
103
+ "· last ",
104
+ dotLabel(last),
105
+ hydrated && ` · ${rel(last.ts)}`
106
+ ] })]
107
+ }),
108
+ completed && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
109
+ className: "mt-1.5 text-label text-success",
110
+ children: [
111
+ "Completed",
112
+ job.completedAt ? ` · ${fmt(job.completedAt)}` : "",
113
+ job.completionReason && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
114
+ className: "text-secondary",
115
+ children: [" - ", job.completionReason]
116
+ })
117
+ ]
118
+ })
119
+ ]
120
+ });
121
+ }
122
+ /**
123
+ * Header team entry. Always visible when team data exists: a single-team user
124
+ * sees a quiet pill naming the active team (so the workspace context is never
125
+ * invisible); anyone who can reach more than one team gets the select.
126
+ *
127
+ * Switching NAVIGATES to `/t/<id>` (the explicit team URL — bookmarkable, and
128
+ * each tab keeps its own team). The cookie is still written, now only as the
129
+ * last-used default that the bare `/` redirect falls back to (no longer an
130
+ * authorization key). The navigation (and the route's `key={teamId}` remount) is
131
+ * what re-scopes the dashboard, so no refresh callback is needed.
132
+ */
133
+ function TeamSwitcher({ data }) {
134
+ const navigate = useNavigate();
135
+ if (!data || data.teams.length === 0) return null;
136
+ const selectTeam = (id) => {
137
+ setActiveTeamCookie(id);
138
+ navigate({
139
+ to: "/t/$teamId",
140
+ params: { teamId: id }
141
+ });
142
+ };
143
+ if (data.teams.length === 1) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
144
+ title: "Active team",
145
+ className: "inline-flex items-center rounded-full bg-raised px-3 py-1 text-label font-medium text-secondary",
146
+ children: data.teams[0].name
147
+ });
148
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", {
149
+ "aria-label": "Active team",
150
+ value: data.activeTeamId,
151
+ onChange: (e) => selectTeam(e.target.value),
152
+ className: "lp-select cursor-pointer rounded-full bg-raised py-1 pl-3 text-label font-medium text-secondary outline-none transition-colors hover:text-display",
153
+ children: data.teams.map((t) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
154
+ value: t.id,
155
+ children: t.name
156
+ }, t.id))
157
+ });
158
+ }
159
+ var FORMS = {
160
+ telegram: {
161
+ label: "Telegram",
162
+ help: "Create a bot with @BotFather, then DM it once so it can message you.",
163
+ fields: [{
164
+ key: "botToken",
165
+ label: "Bot token",
166
+ ph: "123456:ABC-DEF…"
167
+ }, {
168
+ key: "chatId",
169
+ label: "Chat id",
170
+ ph: "e.g. 87654321 (message @userinfobot to get yours)"
171
+ }]
172
+ },
173
+ feishu: {
174
+ label: "Feishu",
175
+ help: "In a Feishu group: 设置 → 机器人 → 添加自定义机器人. Pick a security setting (signing recommended; paste the secret below if you enabled 签名校验).",
176
+ fields: [{
177
+ key: "webhookUrl",
178
+ label: "Webhook URL",
179
+ ph: "https://open.feishu.cn/open-apis/bot/v2/hook/…"
180
+ }, {
181
+ key: "secret",
182
+ label: "Signing secret (optional)",
183
+ ph: "only if you enabled 签名校验",
184
+ optional: true
185
+ }]
186
+ }
187
+ };
188
+ var ADDABLE = ["telegram", "feishu"];
189
+ function typeLabel(type) {
190
+ return FORMS[type]?.label ?? (type === "slack" ? "Slack" : type);
191
+ }
192
+ function NotificationsModal({ open, onClose }) {
193
+ const [channels, setChannels] = (0, import_react.useState)([]);
194
+ const [adding, setAdding] = (0, import_react.useState)(null);
195
+ const [name, setName] = (0, import_react.useState)("");
196
+ const [fields, setFields] = (0, import_react.useState)({});
197
+ const [busy, setBusy] = (0, import_react.useState)(false);
198
+ const [err, setErr] = (0, import_react.useState)(null);
199
+ const [test, setTest] = (0, import_react.useState)({});
200
+ const load = (0, import_react.useCallback)(async () => {
201
+ try {
202
+ setChannels(await listChannels());
203
+ } catch {}
204
+ }, []);
205
+ (0, import_react.useEffect)(() => {
206
+ if (!open) {
207
+ setErr(null);
208
+ setAdding(null);
209
+ return;
210
+ }
211
+ load();
212
+ }, [open, load]);
213
+ function startAdd(type) {
214
+ setName("");
215
+ setFields({});
216
+ setErr(null);
217
+ setAdding(type);
218
+ }
219
+ const spec = adding ? FORMS[adding] : null;
220
+ const filled = !!name.trim() && !!spec && spec.fields.every((f) => f.optional || fields[f.key]?.trim());
221
+ async function add() {
222
+ if (!adding || !spec) return;
223
+ setErr(null);
224
+ setBusy(true);
225
+ try {
226
+ const config = Object.fromEntries(spec.fields.filter((f) => fields[f.key]?.trim()).map((f) => [f.key, fields[f.key].trim()]));
227
+ const r = await createChannel({ data: {
228
+ type: adding,
229
+ name: name.trim(),
230
+ config
231
+ } });
232
+ if (!r.ok) {
233
+ setErr(r.error ?? "Could not save this channel.");
234
+ return;
235
+ }
236
+ setAdding(null);
237
+ await load();
238
+ } finally {
239
+ setBusy(false);
240
+ }
241
+ }
242
+ async function remove(id) {
243
+ setErr(null);
244
+ const r = await deleteChannel({ data: id });
245
+ if (!r.ok) {
246
+ setErr(r.error ?? "Could not delete this channel.");
247
+ return;
248
+ }
249
+ await load();
250
+ }
251
+ async function runTest(id) {
252
+ setTest((t) => ({
253
+ ...t,
254
+ [id]: "sending"
255
+ }));
256
+ const r = await testChannel({ data: id });
257
+ setTest((t) => ({
258
+ ...t,
259
+ [id]: r.ok ? "ok" : r.error || "failed"
260
+ }));
261
+ setTimeout(() => setTest((t) => ({
262
+ ...t,
263
+ [id]: ""
264
+ })), 4e3);
265
+ }
266
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Modal, {
267
+ open,
268
+ onClose,
269
+ children: [
270
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalHead, {
271
+ title: "Notifications",
272
+ sub: "Push channels for this team. A loop routes its run messages to the channel you pick on it."
273
+ }),
274
+ err && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorBanner, {
275
+ message: err,
276
+ onDismiss: () => setErr(null),
277
+ className: "mb-2 mt-3"
278
+ }),
279
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalSection, { children: "Channels" }),
280
+ channels.length === 0 && !adding && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
281
+ className: "py-3 text-body text-secondary",
282
+ children: "No channels yet."
283
+ }),
284
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
285
+ className: "flex flex-col gap-2",
286
+ children: channels.map((c) => {
287
+ const t = test[c.id];
288
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
289
+ className: "flex items-center justify-between gap-3 rounded-control border border-hairline bg-surface px-4 py-3",
290
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
291
+ className: "flex min-w-0 items-center gap-2.5",
292
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
293
+ className: "text-[15px] font-medium text-display",
294
+ children: c.name
295
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
296
+ className: "text-label text-secondary",
297
+ children: [
298
+ typeLabel(c.type),
299
+ " · ",
300
+ c.hint
301
+ ]
302
+ })]
303
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
304
+ className: "flex shrink-0 items-center gap-2",
305
+ children: [
306
+ t && t !== "sending" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
307
+ className: `inline-flex h-[22px] items-center gap-1.5 rounded-full px-2.5 text-caption font-medium ${t === "ok" ? "bg-success-soft text-success" : "bg-accent-soft text-accent"}`,
308
+ title: t === "ok" ? void 0 : t,
309
+ children: t === "ok" ? "Sent ✓" : "Failed"
310
+ }),
311
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
312
+ className: btn,
313
+ disabled: t === "sending",
314
+ onClick: () => void runTest(c.id),
315
+ children: t === "sending" ? "Sending…" : "Test"
316
+ }),
317
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
318
+ className: btnDanger,
319
+ onClick: () => void remove(c.id),
320
+ children: "Delete"
321
+ })
322
+ ]
323
+ })]
324
+ }, c.id);
325
+ })
326
+ }),
327
+ adding && spec ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
328
+ className: "mt-4 rounded-control border border-hairline bg-raised px-4 py-3",
329
+ children: [
330
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ModalSection, { children: [
331
+ "New ",
332
+ spec.label,
333
+ " channel"
334
+ ] }),
335
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
336
+ className: labelCls,
337
+ children: "Name"
338
+ }),
339
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
340
+ className: inputCls,
341
+ value: name,
342
+ onChange: (e) => setName(e.target.value),
343
+ placeholder: "e.g. My alerts"
344
+ }),
345
+ spec.fields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
346
+ className: labelCls,
347
+ children: f.label
348
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
349
+ className: `${inputCls} font-mono`,
350
+ value: fields[f.key] ?? "",
351
+ onChange: (e) => setFields((s) => ({
352
+ ...s,
353
+ [f.key]: e.target.value
354
+ })),
355
+ placeholder: f.ph
356
+ })] }, f.key)),
357
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
358
+ className: "mt-1 text-label text-secondary",
359
+ children: spec.help
360
+ }),
361
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
362
+ className: "mt-4 flex justify-end gap-2",
363
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
364
+ className: btn,
365
+ onClick: () => setAdding(null),
366
+ children: "Cancel"
367
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
368
+ className: btnPrimary,
369
+ disabled: busy || !filled,
370
+ onClick: () => void add(),
371
+ children: busy ? "Saving…" : "Save channel"
372
+ })]
373
+ })
374
+ ]
375
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
376
+ className: "mt-6 flex gap-2",
377
+ children: ADDABLE.map((type) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
378
+ className: btnPrimary,
379
+ onClick: () => startAdd(type),
380
+ children: ["+ Add ", FORMS[type]?.label ?? type]
381
+ }, type))
382
+ })
383
+ ]
384
+ });
385
+ }
386
+ function inviteUrl(token) {
387
+ return `${typeof window !== "undefined" ? window.location.origin : ""}/invite/${token}`;
388
+ }
389
+ function CopyLink({ text }) {
390
+ const [done, setDone] = (0, import_react.useState)(false);
391
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
392
+ className: btnSm,
393
+ onClick: () => {
394
+ navigator.clipboard?.writeText(text);
395
+ setDone(true);
396
+ setTimeout(() => setDone(false), 1400);
397
+ },
398
+ children: done ? "Copied ✓" : "Copy link"
399
+ });
400
+ }
401
+ /**
402
+ * Team settings — the owner-facing surface for the full lifecycle: create,
403
+ * rename, members (add-by-email + role + remove), invite links, leave, and
404
+ * delete (with the blocked-while-loops explanation). A master list of the
405
+ * caller's teams on the left; the selected team's detail below. Every action
406
+ * calls an EXPLICIT-teamId server fn (never the active cookie), so managing team
407
+ * B while the dashboard is on team A works. Owner-only controls are hidden for a
408
+ * plain member (the server re-authorizes regardless).
409
+ */
410
+ function TeamsModal({ open, onClose, activeTeamId }) {
411
+ const navigate = useNavigate();
412
+ const [teams, setTeams] = (0, import_react.useState)([]);
413
+ const [selected, setSelected] = (0, import_react.useState)(null);
414
+ const [detail, setDetail] = (0, import_react.useState)(null);
415
+ const [err, setErr] = (0, import_react.useState)(null);
416
+ const [busy, setBusy] = (0, import_react.useState)(false);
417
+ const [newName, setNewName] = (0, import_react.useState)("");
418
+ const [renameVal, setRenameVal] = (0, import_react.useState)("");
419
+ const [email, setEmail] = (0, import_react.useState)("");
420
+ const [addRole, setAddRole] = (0, import_react.useState)("member");
421
+ const [inviteRole, setInviteRole] = (0, import_react.useState)("member");
422
+ const [freshInvite, setFreshInvite] = (0, import_react.useState)(null);
423
+ const loadTeams = (0, import_react.useCallback)(async () => {
424
+ try {
425
+ setTeams(await listManagedTeams());
426
+ } catch {}
427
+ }, []);
428
+ const loadDetail = (0, import_react.useCallback)(async (teamId) => {
429
+ const d = await getTeamDetail({ data: teamId });
430
+ if ("error" in d) {
431
+ setErr(d.error);
432
+ setDetail(null);
433
+ return;
434
+ }
435
+ setDetail(d);
436
+ setRenameVal(d.name);
437
+ }, []);
438
+ (0, import_react.useEffect)(() => {
439
+ if (!open) {
440
+ setErr(null);
441
+ setSelected(null);
442
+ setDetail(null);
443
+ setFreshInvite(null);
444
+ return;
445
+ }
446
+ loadTeams();
447
+ }, [open, loadTeams]);
448
+ (0, import_react.useEffect)(() => {
449
+ if (!open || !selected) return;
450
+ setFreshInvite(null);
451
+ loadDetail(selected);
452
+ }, [
453
+ open,
454
+ selected,
455
+ loadDetail
456
+ ]);
457
+ async function withBusy(fn) {
458
+ setBusy(true);
459
+ setErr(null);
460
+ try {
461
+ return await fn();
462
+ } finally {
463
+ setBusy(false);
464
+ }
465
+ }
466
+ async function doCreate() {
467
+ const name = newName.trim();
468
+ if (!name) return;
469
+ await withBusy(async () => {
470
+ const r = await createTeam({ data: name });
471
+ if (!r.ok) return setErr(r.error);
472
+ setNewName("");
473
+ await loadTeams();
474
+ setSelected(r.id);
475
+ });
476
+ }
477
+ async function doRename() {
478
+ if (!detail) return;
479
+ const name = renameVal.trim();
480
+ if (!name || name === detail.name) return;
481
+ await withBusy(async () => {
482
+ const r = await renameTeam({ data: {
483
+ teamId: detail.id,
484
+ name
485
+ } });
486
+ if (!r.ok) return setErr(r.error);
487
+ await loadTeams();
488
+ await loadDetail(detail.id);
489
+ });
490
+ }
491
+ async function doDelete() {
492
+ if (!detail) return;
493
+ await withBusy(async () => {
494
+ const r = await deleteTeam({ data: detail.id });
495
+ if (!r.ok) return setErr(r.error);
496
+ const removed = detail.id;
497
+ setSelected(null);
498
+ setDetail(null);
499
+ await loadTeams();
500
+ if (removed === activeTeamId) {
501
+ onClose();
502
+ navigate({ to: "/" });
503
+ }
504
+ });
505
+ }
506
+ async function doLeave() {
507
+ if (!detail) return;
508
+ await withBusy(async () => {
509
+ const r = await leaveTeam({ data: detail.id });
510
+ if (!r.ok) return setErr(r.error);
511
+ const left = detail.id;
512
+ setSelected(null);
513
+ setDetail(null);
514
+ await loadTeams();
515
+ if (left === activeTeamId) {
516
+ onClose();
517
+ navigate({ to: "/" });
518
+ }
519
+ });
520
+ }
521
+ async function doAdd() {
522
+ if (!detail) return;
523
+ const addr = email.trim();
524
+ if (!addr) return;
525
+ await withBusy(async () => {
526
+ const r = await addTeamMember({ data: {
527
+ teamId: detail.id,
528
+ email: addr,
529
+ role: addRole
530
+ } });
531
+ if (!r.ok) return setErr(r.error);
532
+ setEmail("");
533
+ await loadDetail(detail.id);
534
+ await loadTeams();
535
+ });
536
+ }
537
+ async function doSetRole(userId, role) {
538
+ if (!detail) return;
539
+ await withBusy(async () => {
540
+ const r = await setTeamMemberRole({ data: {
541
+ teamId: detail.id,
542
+ userId,
543
+ role
544
+ } });
545
+ if (!r.ok) return setErr(r.error);
546
+ await loadDetail(detail.id);
547
+ });
548
+ }
549
+ async function doRemove(userId) {
550
+ if (!detail) return;
551
+ await withBusy(async () => {
552
+ const r = await removeTeamMember({ data: {
553
+ teamId: detail.id,
554
+ userId
555
+ } });
556
+ if (!r.ok) return setErr(r.error);
557
+ await loadDetail(detail.id);
558
+ await loadTeams();
559
+ });
560
+ }
561
+ async function doInvite() {
562
+ if (!detail) return;
563
+ await withBusy(async () => {
564
+ const r = await createTeamInvite({ data: {
565
+ teamId: detail.id,
566
+ role: inviteRole
567
+ } });
568
+ if (!r.ok) return setErr(r.error);
569
+ setFreshInvite(r.token);
570
+ await loadDetail(detail.id);
571
+ });
572
+ }
573
+ async function doRevoke(token) {
574
+ if (!detail) return;
575
+ await withBusy(async () => {
576
+ const r = await revokeTeamInvite({ data: {
577
+ teamId: detail.id,
578
+ token
579
+ } });
580
+ if (!r.ok) return setErr(r.error);
581
+ if (freshInvite === token) setFreshInvite(null);
582
+ await loadDetail(detail.id);
583
+ });
584
+ }
585
+ const isOwner = detail?.role === "owner";
586
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Modal, {
587
+ open,
588
+ onClose,
589
+ wide: true,
590
+ children: [
591
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalHead, {
592
+ title: "Teams",
593
+ sub: "Create teams, manage members and roles, and invite people. Team management is owner-only; any member can create loops."
594
+ }),
595
+ err && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorBanner, {
596
+ message: err,
597
+ onDismiss: () => setErr(null),
598
+ className: "mb-2 mt-3"
599
+ }),
600
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
601
+ className: "mt-3 grid gap-6 md:grid-cols-[minmax(0,18rem)_minmax(0,1fr)]",
602
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
603
+ className: "min-w-0",
604
+ children: [
605
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalSection, { children: "My teams" }),
606
+ teams.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
607
+ className: "py-2 text-body text-secondary",
608
+ children: "No teams yet."
609
+ }),
610
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
611
+ className: "flex flex-col gap-1.5",
612
+ children: teams.map((t) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
613
+ onClick: () => setSelected(t.id),
614
+ className: `flex w-full items-center justify-between gap-2 rounded-control border px-3 py-2 text-left transition-colors ${selected === t.id ? "border-display bg-raised" : "border-hairline bg-surface hover:bg-raised"}`,
615
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
616
+ className: "min-w-0 truncate text-[15px] font-medium text-display",
617
+ children: t.name
618
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
619
+ className: "flex shrink-0 items-center gap-1.5",
620
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pill, {
621
+ tone: t.role === "owner" ? "ink" : "neutral",
622
+ children: t.role
623
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
624
+ className: "text-label text-secondary",
625
+ children: [
626
+ t.memberCount,
627
+ " member",
628
+ t.memberCount === 1 ? "" : "s"
629
+ ]
630
+ })]
631
+ })]
632
+ }) }, t.id))
633
+ }),
634
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
635
+ className: "mt-4 rounded-control border border-hairline bg-raised px-3 py-3",
636
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
637
+ className: `${labelCls} mt-0`,
638
+ children: "New team"
639
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
640
+ className: "flex gap-2",
641
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
642
+ className: inputCls,
643
+ value: newName,
644
+ onChange: (e) => setNewName(e.target.value),
645
+ placeholder: "e.g. Growth Squad",
646
+ onKeyDown: (e) => e.key === "Enter" && void doCreate()
647
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
648
+ className: btnPrimary,
649
+ disabled: busy || !newName.trim(),
650
+ onClick: () => void doCreate(),
651
+ children: "Create"
652
+ })]
653
+ })]
654
+ })
655
+ ]
656
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
657
+ className: "min-w-0",
658
+ children: !detail ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
659
+ className: "flex h-full items-center justify-center py-10 text-body text-secondary",
660
+ children: "Select a team to manage it, or create one."
661
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
662
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ModalSection, {
663
+ action: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
664
+ className: btnSm,
665
+ onClick: () => {
666
+ setActiveTeamCookie(detail.id);
667
+ onClose();
668
+ navigate({
669
+ to: "/t/$teamId",
670
+ params: { teamId: detail.id }
671
+ });
672
+ },
673
+ children: "Open dashboard →"
674
+ }),
675
+ children: [detail.name, detail.personal ? " · personal" : ""]
676
+ }),
677
+ isOwner && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
678
+ className: "mb-4",
679
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
680
+ className: "mb-1.5 mt-3 block text-label font-medium text-secondary",
681
+ children: "Team name"
682
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
683
+ className: "flex gap-2",
684
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
685
+ "aria-label": "Team name",
686
+ className: inputCls,
687
+ value: renameVal,
688
+ onChange: (e) => setRenameVal(e.target.value)
689
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
690
+ className: btn,
691
+ disabled: busy || !renameVal.trim() || renameVal.trim() === detail.name,
692
+ onClick: () => void doRename(),
693
+ children: "Rename"
694
+ })]
695
+ })]
696
+ }),
697
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalSection, { children: "Members" }),
698
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
699
+ className: "flex flex-col gap-2",
700
+ children: detail.members.map((m) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
701
+ className: "flex items-center justify-between gap-3 rounded-control border border-hairline bg-surface px-3 py-2.5",
702
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
703
+ className: "flex min-w-0 flex-col",
704
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
705
+ className: "truncate text-[15px] font-medium text-display",
706
+ children: [m.email ?? m.displayName ?? m.userId, m.isSelf && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
707
+ className: "ml-1.5 text-label text-secondary",
708
+ children: "(you)"
709
+ })]
710
+ })
711
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
712
+ className: "flex shrink-0 items-center gap-2",
713
+ children: isOwner && !m.isSelf ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", {
714
+ "aria-label": "Role",
715
+ className: `${selectCls} w-auto py-1.5`,
716
+ value: m.role,
717
+ onChange: (e) => void doSetRole(m.userId, e.target.value),
718
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
719
+ value: "owner",
720
+ children: "owner"
721
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
722
+ value: "member",
723
+ children: "member"
724
+ })]
725
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
726
+ className: btnDanger,
727
+ disabled: busy,
728
+ onClick: () => void doRemove(m.userId),
729
+ children: "Remove"
730
+ })] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pill, {
731
+ tone: m.role === "owner" ? "ink" : "neutral",
732
+ children: m.role
733
+ })
734
+ })]
735
+ }, m.userId))
736
+ }),
737
+ isOwner && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
738
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
739
+ className: "mt-4 rounded-control border border-hairline bg-raised px-3 py-3",
740
+ children: [
741
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
742
+ className: `mb-1.5 mt-3 block text-label font-medium text-secondary mt-0`,
743
+ children: "Add a member by email"
744
+ }),
745
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
746
+ className: "flex flex-wrap gap-2",
747
+ children: [
748
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
749
+ className: `${inputCls} min-w-[12rem] flex-1`,
750
+ value: email,
751
+ onChange: (e) => setEmail(e.target.value),
752
+ placeholder: "teammate@example.com",
753
+ onKeyDown: (e) => e.key === "Enter" && void doAdd()
754
+ }),
755
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", {
756
+ "aria-label": "Role for new member",
757
+ className: `${selectCls} w-auto`,
758
+ value: addRole,
759
+ onChange: (e) => setAddRole(e.target.value),
760
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
761
+ value: "member",
762
+ children: "member"
763
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
764
+ value: "owner",
765
+ children: "owner"
766
+ })]
767
+ }),
768
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
769
+ className: btnPrimary,
770
+ disabled: busy || !email.trim(),
771
+ onClick: () => void doAdd(),
772
+ children: "Add"
773
+ })
774
+ ]
775
+ }),
776
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
777
+ className: "mt-1.5 text-label text-secondary",
778
+ children: "Adds an existing Pievo account immediately. No account yet? Generate an invite link below."
779
+ })
780
+ ]
781
+ }),
782
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalSection, { children: "Invite links" }),
783
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
784
+ className: "flex flex-wrap items-center gap-2",
785
+ children: [
786
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", {
787
+ "aria-label": "Invite role",
788
+ className: `${selectCls} w-auto`,
789
+ value: inviteRole,
790
+ onChange: (e) => setInviteRole(e.target.value),
791
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
792
+ value: "member",
793
+ children: "as member"
794
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
795
+ value: "owner",
796
+ children: "as owner"
797
+ })]
798
+ }),
799
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
800
+ className: btn,
801
+ disabled: busy,
802
+ onClick: () => void doInvite(),
803
+ children: "Generate invite link"
804
+ }),
805
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
806
+ className: "text-label text-secondary",
807
+ children: "Single-use · expires in 7 days"
808
+ })
809
+ ]
810
+ }),
811
+ detail.invites.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
812
+ className: "mt-3 flex flex-col gap-2",
813
+ children: detail.invites.map((i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
814
+ className: "flex items-center justify-between gap-3 rounded-control border border-hairline bg-surface px-3 py-2.5",
815
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
816
+ className: "flex min-w-0 items-center gap-2",
817
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pill, {
818
+ tone: "neutral",
819
+ children: i.role
820
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
821
+ className: `min-w-0 truncate font-mono text-label ${freshInvite === i.token ? "text-display" : "text-secondary"}`,
822
+ children: inviteUrl(i.token)
823
+ })]
824
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
825
+ className: "flex shrink-0 items-center gap-2",
826
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CopyLink, { text: inviteUrl(i.token) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
827
+ className: btnDanger,
828
+ disabled: busy,
829
+ onClick: () => void doRevoke(i.token),
830
+ children: "Revoke"
831
+ })]
832
+ })]
833
+ }, i.token))
834
+ })
835
+ ] }),
836
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
837
+ className: "mt-6 flex items-center justify-between gap-3 border-t border-hairline pt-4",
838
+ children: [!detail.personal ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
839
+ className: btn,
840
+ disabled: busy,
841
+ onClick: () => void doLeave(),
842
+ children: "Leave team"
843
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
844
+ className: "text-label text-secondary",
845
+ children: "Your personal team can't be left or deleted."
846
+ }), isOwner && !detail.personal && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
847
+ className: btnDanger,
848
+ disabled: busy || detail.loopCount > 0,
849
+ title: detail.loopCount > 0 ? `Move or delete this team's ${detail.loopCount} loop${detail.loopCount === 1 ? "" : "s"} first` : void 0,
850
+ onClick: () => void doDelete(),
851
+ children: ["Delete team", detail.loopCount > 0 ? ` (${detail.loopCount} loop${detail.loopCount === 1 ? "" : "s"})` : ""]
852
+ })]
853
+ })
854
+ ] })
855
+ })]
856
+ })
857
+ ]
858
+ });
859
+ }
860
+ var FLOWS = {
861
+ "react-doctor": {
862
+ worktreeLabel: "Isolated git worktree · off main",
863
+ nodes: [
864
+ {
865
+ id: "tick",
866
+ kicker: "On schedule",
867
+ glyph: "◷",
868
+ title: "Every day · 6am",
869
+ detail: "the loop wakes on cadence"
870
+ },
871
+ {
872
+ id: "scan",
873
+ kicker: "Step 1 · Scan",
874
+ glyph: "⌕",
875
+ title: "Scan the app",
876
+ detail: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { children: "npx react-doctor@latest" })
877
+ },
878
+ {
879
+ id: "prio",
880
+ kicker: "Step 2 · Prioritise",
881
+ glyph: "⚖",
882
+ title: "Pick one issue",
883
+ detail: "the worst, by severity & perf impact"
884
+ },
885
+ {
886
+ id: "fix",
887
+ wt: true,
888
+ kicker: "Step 3 · Fix",
889
+ glyph: "✎",
890
+ title: "Fix in isolation",
891
+ detail: "smallest change, fresh branch"
892
+ },
893
+ {
894
+ id: "verify",
895
+ wt: true,
896
+ kicker: "Step 4 · Verify",
897
+ glyph: "▷",
898
+ title: "Verify the fix",
899
+ detail: "prove it holds before proposing"
900
+ },
901
+ {
902
+ id: "ship",
903
+ wt: true,
904
+ kicker: "Step 5 · Ship",
905
+ glyph: "⑂",
906
+ title: "Open a PR",
907
+ detail: "skip if a prior PR's still open"
908
+ }
909
+ ],
910
+ dashboard: [{
911
+ type: "kanban",
912
+ heading: "PR board",
913
+ sub: "open → merged",
914
+ columns: [["Open", [[
915
+ "#231",
916
+ "Key-less list items in <Feed/>",
917
+ "opened 6h ago"
918
+ ], [
919
+ "#219",
920
+ "Missing memo on heavy list row",
921
+ "opened 1d ago"
922
+ ]]], ["Merged", [
923
+ [
924
+ "#212",
925
+ "Effect re-runs on every render",
926
+ "merged 2d ago"
927
+ ],
928
+ [
929
+ "#205",
930
+ "Unmemoised context value",
931
+ "merged 4d ago"
932
+ ],
933
+ [
934
+ "#198",
935
+ "Inline object prop churn",
936
+ "merged 6d ago"
937
+ ]
938
+ ]]]
939
+ }, {
940
+ type: "metric",
941
+ label: "Health score",
942
+ series: [
943
+ 66,
944
+ 68,
945
+ 67,
946
+ 71,
947
+ 72,
948
+ 71,
949
+ 75,
950
+ 77,
951
+ 76,
952
+ 79,
953
+ 81,
954
+ 80,
955
+ 83,
956
+ 84
957
+ ]
958
+ }]
959
+ },
960
+ "docs-sweep": {
961
+ worktreeLabel: "Isolated git worktree · off main",
962
+ nodes: [
963
+ {
964
+ id: "tick",
965
+ kicker: "On schedule",
966
+ glyph: "◷",
967
+ title: "Every Mon · 6am",
968
+ detail: "weekly · picks up where it left off"
969
+ },
970
+ {
971
+ id: "diff",
972
+ kicker: "Step 1 · Compare",
973
+ glyph: "⌕",
974
+ title: "Diff since last sweep",
975
+ detail: "docs vs. what the code ships now"
976
+ },
977
+ {
978
+ id: "verify",
979
+ kicker: "Step 2 · Verify",
980
+ glyph: "▷",
981
+ title: "Verify for real",
982
+ detail: "run the commands, links & examples"
983
+ },
984
+ {
985
+ id: "fix",
986
+ wt: true,
987
+ kicker: "Step 3 · Fix",
988
+ glyph: "✎",
989
+ title: "Fix real drift only",
990
+ detail: "never rewrite accurate docs"
991
+ },
992
+ {
993
+ id: "ship",
994
+ wt: true,
995
+ kicker: "Step 4 · Ship",
996
+ glyph: "⑂",
997
+ title: "Open a PR",
998
+ detail: "explains the drift · no stacking"
999
+ }
1000
+ ],
1001
+ dashboard: [{
1002
+ type: "embed",
1003
+ heading: "Latest sweep summary",
1004
+ title: "Docs drift — weekly sweep",
1005
+ date: "2026-07-06",
1006
+ lines: [
1007
+ "3 items fixed, each verified by running it",
1008
+ "README — dev server is :3001, not :3000",
1009
+ "Setup guide — dropped a dead /api/v1 link",
1010
+ "Quickstart — refreshed `pievo new` flags"
1011
+ ]
1012
+ }, {
1013
+ type: "metric",
1014
+ label: "Drift count",
1015
+ series: [
1016
+ 6,
1017
+ 4,
1018
+ 5,
1019
+ 3,
1020
+ 2,
1021
+ 3,
1022
+ 1,
1023
+ 2,
1024
+ 1,
1025
+ 0
1026
+ ],
1027
+ note: "0 = docs are honest — a clean stop, no PR.",
1028
+ betterDown: true
1029
+ }]
1030
+ },
1031
+ "error-sweep": {
1032
+ worktreeLabel: "Isolated git worktree · off main",
1033
+ nodes: [
1034
+ {
1035
+ id: "setup",
1036
+ setup: true,
1037
+ kicker: "Before first run",
1038
+ glyph: "⚙",
1039
+ title: "Verify an error source",
1040
+ detail: "smoke-test logs / tracker / gh · confirm window"
1041
+ },
1042
+ {
1043
+ id: "tick",
1044
+ kicker: "On schedule",
1045
+ glyph: "◷",
1046
+ title: "Every day · 6am",
1047
+ detail: "sweeps the agreed window"
1048
+ },
1049
+ {
1050
+ id: "sweep",
1051
+ kicker: "Step 1 · Sweep",
1052
+ glyph: "⌕",
1053
+ title: "Group into incidents",
1054
+ detail: "cluster repeated symptoms"
1055
+ },
1056
+ {
1057
+ id: "triage",
1058
+ kicker: "Step 2 · Triage",
1059
+ glyph: "⚖",
1060
+ title: "Actionable vs. noise",
1061
+ detail: "drop upstream & noise"
1062
+ },
1063
+ {
1064
+ id: "fix",
1065
+ wt: true,
1066
+ kicker: "Step 3 · Fix",
1067
+ glyph: "✎",
1068
+ title: "Root-cause & fix",
1069
+ detail: "smallest verified fix"
1070
+ },
1071
+ {
1072
+ id: "ship",
1073
+ wt: true,
1074
+ kicker: "Step 4 · Ship",
1075
+ glyph: "⑂",
1076
+ title: "One PR per fix",
1077
+ detail: "no stacking · never leak secrets"
1078
+ }
1079
+ ],
1080
+ dashboard: [{
1081
+ type: "embed",
1082
+ heading: "Newest report",
1083
+ title: "Error sweep — daily",
1084
+ date: "2026-07-08",
1085
+ lines: [
1086
+ "2 actionable, 14 noise filtered out",
1087
+ "Checkout 500 — null cart on retry (fixed)",
1088
+ "/api/render timeout — upstream, watching",
1089
+ "No credentials or PII in this report"
1090
+ ]
1091
+ }, {
1092
+ type: "metric",
1093
+ label: "Actionable errors",
1094
+ series: [
1095
+ 5,
1096
+ 3,
1097
+ 4,
1098
+ 2,
1099
+ 3,
1100
+ 1,
1101
+ 2,
1102
+ 1,
1103
+ 0,
1104
+ 1
1105
+ ],
1106
+ note: "0 actionable = a clean stop, no PR.",
1107
+ betterDown: true
1108
+ }]
1109
+ },
1110
+ housekeeper: {
1111
+ worktreeLabel: "Isolated git worktree · off main",
1112
+ nodes: [
1113
+ {
1114
+ id: "tick",
1115
+ kicker: "On schedule",
1116
+ glyph: "◷",
1117
+ title: "Every day · 7am",
1118
+ detail: "one cleanup a day, no more"
1119
+ },
1120
+ {
1121
+ id: "survey",
1122
+ kicker: "Step 1 · Survey",
1123
+ glyph: "⌕",
1124
+ title: "Find housekeeping debt",
1125
+ detail: "dead code, stale files, dupes, unused deps"
1126
+ },
1127
+ {
1128
+ id: "prove",
1129
+ kicker: "Step 2 · Prove",
1130
+ glyph: "⚖",
1131
+ title: "Pick one, prove it safe",
1132
+ detail: "concrete evidence · uncertain → deferred"
1133
+ },
1134
+ {
1135
+ id: "fix",
1136
+ wt: true,
1137
+ kicker: "Step 3 · Fix",
1138
+ glyph: "✎",
1139
+ title: "Smallest change",
1140
+ detail: "keep only if build & tests stay green"
1141
+ },
1142
+ {
1143
+ id: "ship",
1144
+ wt: true,
1145
+ kicker: "Step 4 · Ship",
1146
+ glyph: "⑂",
1147
+ title: "Open a PR",
1148
+ detail: "no stacking on an open PR"
1149
+ }
1150
+ ],
1151
+ dashboard: [{
1152
+ type: "kanban",
1153
+ heading: "Cleanup board",
1154
+ sub: "open → merged",
1155
+ columns: [["Open", [[
1156
+ "#142",
1157
+ "Remove dead export in utils/date",
1158
+ "opened 5h ago"
1159
+ ], [
1160
+ "#138",
1161
+ "Drop unused dep left-pad",
1162
+ "opened 2d ago"
1163
+ ]]], ["Merged", [
1164
+ [
1165
+ "#131",
1166
+ "Delete stale scripts/legacy dir",
1167
+ "merged 1d ago"
1168
+ ],
1169
+ [
1170
+ "#124",
1171
+ "Dedupe two clamp() helpers",
1172
+ "merged 3d ago"
1173
+ ],
1174
+ [
1175
+ "#119",
1176
+ "Rename inconsistent isLoading flags",
1177
+ "merged 5d ago"
1178
+ ]
1179
+ ]]]
1180
+ }, {
1181
+ type: "metric",
1182
+ label: "Cleanups landed",
1183
+ series: [
1184
+ 0,
1185
+ 1,
1186
+ 1,
1187
+ 2,
1188
+ 3,
1189
+ 3,
1190
+ 4,
1191
+ 5,
1192
+ 6,
1193
+ 6,
1194
+ 7,
1195
+ 9,
1196
+ 10,
1197
+ 12
1198
+ ]
1199
+ }]
1200
+ },
1201
+ "dependency-triage": {
1202
+ worktreeLabel: "Isolated git worktree · off main",
1203
+ nodes: [
1204
+ {
1205
+ id: "setup",
1206
+ setup: true,
1207
+ kicker: "Before first run",
1208
+ glyph: "⚙",
1209
+ title: "Confirm merge authority",
1210
+ detail: "smoke-test gh sees Dependabot/Renovate · agree merge policy"
1211
+ },
1212
+ {
1213
+ id: "tick",
1214
+ kicker: "On schedule",
1215
+ glyph: "◷",
1216
+ title: "Every Mon",
1217
+ detail: "weekly · snapshots the open PRs"
1218
+ },
1219
+ {
1220
+ id: "snapshot",
1221
+ kicker: "Step 1 · Snapshot",
1222
+ glyph: "⌕",
1223
+ title: "List open dep PRs",
1224
+ detail: "process each exactly once"
1225
+ },
1226
+ {
1227
+ id: "judge",
1228
+ kicker: "Step 2 · Judge",
1229
+ glyph: "⚖",
1230
+ title: "Weigh real evidence",
1231
+ detail: "diff · release notes · advisories · CI at head"
1232
+ },
1233
+ {
1234
+ id: "test",
1235
+ wt: true,
1236
+ kicker: "Step 3 · Test",
1237
+ glyph: "▷",
1238
+ title: "Run tests in isolation",
1239
+ detail: "at the exact head · checkout untouched"
1240
+ },
1241
+ {
1242
+ id: "merge",
1243
+ wt: true,
1244
+ kicker: "Step 4 · Merge",
1245
+ glyph: "⑂",
1246
+ title: "Merge only what’s authorized",
1247
+ detail: "major/breaking/security → recommend, don’t merge"
1248
+ }
1249
+ ],
1250
+ dashboard: [{
1251
+ type: "kanban",
1252
+ heading: "Dependency PRs",
1253
+ sub: "merged · deferred · blocked",
1254
+ columns: [
1255
+ ["Merged", [[
1256
+ "#412",
1257
+ "bump vite 7.0→7.1 (patch)",
1258
+ "merged 1h ago"
1259
+ ], [
1260
+ "#408",
1261
+ "bump @types/node 20→20.14 (minor)",
1262
+ "merged 3h ago"
1263
+ ]]],
1264
+ ["Deferred", [[
1265
+ "#399",
1266
+ "react 18→19 (major) — review",
1267
+ "deferred 2d ago"
1268
+ ], [
1269
+ "#391",
1270
+ "drizzle-orm 0.30→0.31 — CI red",
1271
+ "deferred 2d ago"
1272
+ ]]],
1273
+ ["Blocked", [[
1274
+ "#405",
1275
+ "lodash advisory GHSA-…-qxrp (high)",
1276
+ "flagged 1h ago"
1277
+ ]]]
1278
+ ]
1279
+ }, {
1280
+ type: "metric",
1281
+ label: "Open dependency PRs",
1282
+ series: [
1283
+ 9,
1284
+ 8,
1285
+ 8,
1286
+ 6,
1287
+ 7,
1288
+ 5,
1289
+ 4,
1290
+ 3,
1291
+ 4,
1292
+ 2
1293
+ ],
1294
+ note: "trends down as PRs are merged or resolved.",
1295
+ betterDown: true
1296
+ }]
1297
+ },
1298
+ "market-research": {
1299
+ worktreeLabel: "",
1300
+ nodes: [
1301
+ {
1302
+ id: "setup",
1303
+ setup: true,
1304
+ kicker: "Before first run",
1305
+ glyph: "⚙",
1306
+ title: "Confirm the research focus",
1307
+ detail: "infer the product & space · propose a focus, confirm"
1308
+ },
1309
+ {
1310
+ id: "tick",
1311
+ kicker: "On schedule",
1312
+ glyph: "◷",
1313
+ title: "Every day · 5am",
1314
+ detail: "the loop wakes on cadence"
1315
+ },
1316
+ {
1317
+ id: "research",
1318
+ kicker: "Step 1 · Research",
1319
+ glyph: "⌕",
1320
+ title: "Scan today's market",
1321
+ detail: "competitors, launches, pricing, ecosystem news"
1322
+ },
1323
+ {
1324
+ id: "report",
1325
+ kicker: "Step 2 · Report",
1326
+ glyph: "✎",
1327
+ title: "One dated report",
1328
+ detail: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { children: "type: report · title · date" })
1329
+ },
1330
+ {
1331
+ id: "sharpen",
1332
+ kicker: "Step 3 · Sharpen",
1333
+ glyph: "✧",
1334
+ title: "Sharpen the focus",
1335
+ detail: "lean into what keeps turning out to matter"
1336
+ }
1337
+ ],
1338
+ dashboard: [{
1339
+ type: "calendar",
1340
+ heading: "Reports calendar",
1341
+ monthLabel: "July 2026",
1342
+ days: 31,
1343
+ firstWeekday: 2,
1344
+ reportDays: [
1345
+ 1,
1346
+ 2,
1347
+ 3,
1348
+ 6,
1349
+ 7,
1350
+ 8
1351
+ ]
1352
+ }, {
1353
+ type: "embed",
1354
+ heading: "Newest report",
1355
+ title: "Market watch — daily digest",
1356
+ date: "2026-07-08",
1357
+ lines: [
1358
+ "Today's signal: two rivals converged on usage-based pricing",
1359
+ "Northwind shipped an AI triage add-on, free in beta",
1360
+ "Acme cut its Team tier 20% and dropped the seat minimum",
1361
+ "Ecosystem: a new OSS connector spec is gaining traction"
1362
+ ]
1363
+ }]
1364
+ },
1365
+ "follow-up-tracker": {
1366
+ worktreeLabel: "",
1367
+ nodes: [
1368
+ {
1369
+ id: "setup",
1370
+ setup: true,
1371
+ kicker: "Before first run",
1372
+ glyph: "⚙",
1373
+ title: "Verify + define the finish",
1374
+ detail: "smoke-test an observation path · set the finish condition"
1375
+ },
1376
+ {
1377
+ id: "tick",
1378
+ kicker: "On cadence",
1379
+ glyph: "◷",
1380
+ title: "A few times a day",
1381
+ detail: "wakes on cadence — no fixed clock time"
1382
+ },
1383
+ {
1384
+ id: "observe",
1385
+ kicker: "Step 1 · Observe",
1386
+ glyph: "⌕",
1387
+ title: "Check the outcome",
1388
+ detail: "through the verified path — logs / URL / gh"
1389
+ },
1390
+ {
1391
+ id: "report",
1392
+ kicker: "Step 2 · Report",
1393
+ glyph: "◈",
1394
+ title: "Report what you find",
1395
+ detail: "one report · a metric when natural"
1396
+ },
1397
+ {
1398
+ id: "check",
1399
+ kicker: "Step 3 · Check",
1400
+ glyph: "⚖",
1401
+ title: "Goal met?",
1402
+ detail: "keep watching until it genuinely holds"
1403
+ },
1404
+ {
1405
+ id: "finish",
1406
+ finish: true,
1407
+ kicker: "When met",
1408
+ glyph: "⚑",
1409
+ title: "Finish the loop",
1410
+ detail: "marks it done — stops watching"
1411
+ }
1412
+ ],
1413
+ dashboard: [{
1414
+ type: "embed",
1415
+ heading: "Latest observation",
1416
+ title: "Checkout fix — follow-up",
1417
+ date: "2026-07-08",
1418
+ lines: [
1419
+ "conversion 29% → 44% over 3 days",
1420
+ "no error spikes since the deploy",
1421
+ "goal: hold ≥ 40% for 48h — 31h in, on track"
1422
+ ]
1423
+ }, {
1424
+ type: "metric",
1425
+ label: "Checkout conversion %",
1426
+ series: [
1427
+ 29,
1428
+ 31,
1429
+ 30,
1430
+ 34,
1431
+ 37,
1432
+ 39,
1433
+ 41,
1434
+ 43,
1435
+ 44
1436
+ ],
1437
+ note: "goal: hold ≥ 40% for 48h, then the loop finishes itself."
1438
+ }]
1439
+ }
1440
+ };
1441
+ /** Whether a template has a preview — drives the modal's two-column layout. */
1442
+ var hasLoopFlow = (name) => name in FLOWS;
1443
+ var VIEW_W = 344;
1444
+ var NODE_X = 68;
1445
+ var NODE_W = 248;
1446
+ var NODE_H = 64;
1447
+ var CX = 192;
1448
+ var TOP = 6;
1449
+ var LANE_X = 30;
1450
+ var WT_X = 48;
1451
+ var WT_W = 280;
1452
+ var WT_PAD_TOP = 18;
1453
+ var WT_PAD_BOT = 16;
1454
+ var hOf = (d) => d.setup ? 78 : NODE_H;
1455
+ function buildGeometry(defs) {
1456
+ const tickIndex = defs.findIndex((d) => !d.setup);
1457
+ const finishIndex = defs.findIndex((d) => d.finish);
1458
+ const closed = finishIndex >= 0;
1459
+ const nodes = [];
1460
+ let y = TOP;
1461
+ defs.forEach((d, i) => {
1462
+ if (i > 0) {
1463
+ const prevWt = !!defs[i - 1].wt;
1464
+ const curWt = !!d.wt;
1465
+ const gap = !prevWt && curWt ? 48 : prevWt && curWt ? 30 : 36;
1466
+ y += hOf(defs[i - 1]) + gap;
1467
+ }
1468
+ const kind = d.finish ? "finish" : d.setup ? "setup" : i === tickIndex ? "tick" : "step";
1469
+ nodes.push({
1470
+ ...d,
1471
+ kind,
1472
+ x: NODE_X,
1473
+ y,
1474
+ w: NODE_W,
1475
+ h: hOf(d)
1476
+ });
1477
+ });
1478
+ const wt = nodes.filter((n) => n.wt);
1479
+ const worktree = wt.length ? {
1480
+ x: WT_X,
1481
+ y: wt[0].y - WT_PAD_TOP,
1482
+ w: WT_W,
1483
+ h: wt[wt.length - 1].y + wt[wt.length - 1].h + WT_PAD_BOT - (wt[0].y - WT_PAD_TOP)
1484
+ } : null;
1485
+ const wires = [];
1486
+ for (let i = 0; i < nodes.length - 1; i++) wires.push(`M${CX} ${nodes[i].y + nodes[i].h} L${CX} ${nodes[i + 1].y - 4}`);
1487
+ const finishWireIndex = closed ? finishIndex - 1 : -1;
1488
+ const tickNode = nodes[tickIndex];
1489
+ const tickMidY = tickNode.y + tickNode.h / 2;
1490
+ const cycleLast = nodes[closed ? finishIndex - 1 : nodes.length - 1];
1491
+ const returnWireIndex = wires.length;
1492
+ let route;
1493
+ let viewH;
1494
+ if (closed) {
1495
+ const midY = cycleLast.y + cycleLast.h / 2;
1496
+ wires.push(`M${NODE_X} ${midY} L36 ${midY} Q${LANE_X} ${midY} ${LANE_X} ${midY - 6} L${LANE_X} ${tickMidY + 6} Q${LANE_X} ${tickMidY} 36 ${tickMidY} L${NODE_X - 4} ${tickMidY}`);
1497
+ route = `M${nodes.slice(tickIndex, finishIndex).map((n) => `${CX} ${n.y + n.h / 2}`).join(" L ")} L${LANE_X} ${midY} L${LANE_X} ${tickMidY} L${NODE_X - 4} ${tickMidY}`;
1498
+ const finishNode = nodes[finishIndex];
1499
+ viewH = finishNode.y + finishNode.h + 14;
1500
+ } else {
1501
+ const laneY = cycleLast.y + cycleLast.h + 28;
1502
+ wires.push(`M${CX} ${cycleLast.y + cycleLast.h} L${CX} ${laneY - 6} Q${CX} ${laneY} ${CX - 6} ${laneY} L36 ${laneY} Q${LANE_X} ${laneY} ${LANE_X} ${laneY - 6} L${LANE_X} ${tickMidY + 6} Q${LANE_X} ${tickMidY} 36 ${tickMidY} L${NODE_X - 4} ${tickMidY}`);
1503
+ route = `M${nodes.slice(tickIndex).map((n) => `${CX} ${n.y + n.h / 2}`).join(" L ")} L${CX} ${laneY} L${LANE_X} ${laneY} L${LANE_X} ${tickMidY} L${NODE_X - 4} ${tickMidY}`;
1504
+ viewH = laneY + 14;
1505
+ }
1506
+ return {
1507
+ nodes,
1508
+ wires,
1509
+ route,
1510
+ worktree,
1511
+ returnWireIndex,
1512
+ finishWireIndex,
1513
+ viewW: VIEW_W,
1514
+ viewH
1515
+ };
1516
+ }
1517
+ function LoopFlow({ template }) {
1518
+ const spec = FLOWS[template.name];
1519
+ const [tab, setTab] = (0, import_react.useState)("flow");
1520
+ if (!spec) return null;
1521
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1522
+ className: "min-w-0",
1523
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1524
+ className: "mb-4 inline-flex rounded-full border border-hairline bg-raised p-0.5 text-label",
1525
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TabBtn, {
1526
+ active: tab === "flow",
1527
+ onClick: () => setTab("flow"),
1528
+ children: "Loop flow"
1529
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TabBtn, {
1530
+ active: tab === "dashboard",
1531
+ onClick: () => setTab("dashboard"),
1532
+ children: "Dashboard"
1533
+ })]
1534
+ }), tab === "flow" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FlowDiagram, { spec }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Dashboard, { spec })]
1535
+ });
1536
+ }
1537
+ function TabBtn({ active, onClick, children }) {
1538
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
1539
+ type: "button",
1540
+ onClick,
1541
+ className: `cursor-pointer rounded-full px-3.5 py-1.5 font-medium transition-colors ${active ? "bg-surface text-display shadow-card" : "text-secondary hover:text-display"}`,
1542
+ children
1543
+ });
1544
+ }
1545
+ function FlowDiagram({ spec }) {
1546
+ const geo = (0, import_react.useMemo)(() => buildGeometry(spec.nodes), [spec]);
1547
+ const rootRef = (0, import_react.useRef)(null);
1548
+ (0, import_react.useEffect)(() => {
1549
+ const root = rootRef.current;
1550
+ if (!root) return;
1551
+ if (window.matchMedia?.("(prefers-reduced-motion: reduce)").matches) return;
1552
+ const route = root.querySelector(".lpf-route");
1553
+ const pulse = root.querySelector(".lpf-pulse");
1554
+ const comet = root.querySelector(".lpf-comet");
1555
+ if (!route || !pulse || !comet) return;
1556
+ const total = route.getTotalLength();
1557
+ const SAMPLES = 600;
1558
+ const samp = [];
1559
+ for (let i = 0; i <= SAMPLES; i++) {
1560
+ const L = total * i / SAMPLES;
1561
+ const p = route.getPointAtLength(L);
1562
+ samp.push([
1563
+ L,
1564
+ p.x,
1565
+ p.y
1566
+ ]);
1567
+ }
1568
+ const lenAt = (x, y) => {
1569
+ let best = 0;
1570
+ let bd = Infinity;
1571
+ for (const s of samp) {
1572
+ const d = (s[1] - x) ** 2 + (s[2] - y) ** 2;
1573
+ if (d < bd) {
1574
+ bd = d;
1575
+ best = s[0];
1576
+ }
1577
+ }
1578
+ return best;
1579
+ };
1580
+ const nodeEls = /* @__PURE__ */ new Map();
1581
+ root.querySelectorAll("[data-lpf]").forEach((el) => nodeEls.set(el.dataset.lpf, el));
1582
+ const order = geo.nodes.filter((n) => n.kind !== "setup" && n.kind !== "finish").map((n) => ({
1583
+ len: lenAt(n.x + n.w / 2, n.y + n.h / 2),
1584
+ el: nodeEls.get(n.id)
1585
+ })).filter((n) => n.el).sort((a, b) => a.len - b.len);
1586
+ const SPEED = 210 / 1e3;
1587
+ const DWELL = 520;
1588
+ const segs = [];
1589
+ const first = order[0];
1590
+ const lastN = order[order.length - 1];
1591
+ segs.push({
1592
+ type: "dwell",
1593
+ at: first,
1594
+ dur: DWELL
1595
+ });
1596
+ for (let i = 0; i < order.length - 1; i++) {
1597
+ const a = order[i];
1598
+ const b = order[i + 1];
1599
+ segs.push({
1600
+ type: "move",
1601
+ from: a.len,
1602
+ to: b.len,
1603
+ dur: Math.max(360, (b.len - a.len) / SPEED)
1604
+ });
1605
+ segs.push({
1606
+ type: "dwell",
1607
+ at: b,
1608
+ dur: DWELL
1609
+ });
1610
+ }
1611
+ segs.push({
1612
+ type: "return",
1613
+ from: lastN.len,
1614
+ to: total,
1615
+ dur: Math.max(720, (total - lastN.len) / SPEED)
1616
+ });
1617
+ segs.push({
1618
+ type: "dwell",
1619
+ at: first,
1620
+ dur: 160,
1621
+ restart: true
1622
+ });
1623
+ const COMET = 52;
1624
+ comet.setAttribute("stroke-dasharray", `${COMET} ${total}`);
1625
+ const place = (L) => {
1626
+ const c = Math.max(0, Math.min(total, L));
1627
+ const p = route.getPointAtLength(c);
1628
+ pulse.setAttribute("cx", p.x.toFixed(2));
1629
+ pulse.setAttribute("cy", p.y.toFixed(2));
1630
+ comet.setAttribute("stroke-dashoffset", (-(L - COMET * .5)).toFixed(2));
1631
+ };
1632
+ const clearActive = () => order.forEach((n) => n.el.classList.remove("active"));
1633
+ const resetPass = () => order.forEach((n) => n.el.classList.remove("visited"));
1634
+ const activate = (n) => {
1635
+ clearActive();
1636
+ n.el.classList.add("active", "visited");
1637
+ };
1638
+ let si = 0;
1639
+ let t0 = performance.now();
1640
+ let raf = 0;
1641
+ const frame = (now) => {
1642
+ let seg = segs[si];
1643
+ const e = now - t0;
1644
+ if (e >= seg.dur) {
1645
+ if ((seg.type === "move" || seg.type === "return") && seg.to != null) place(seg.to);
1646
+ si = (si + 1) % segs.length;
1647
+ t0 = now;
1648
+ seg = segs[si];
1649
+ if (seg.restart) resetPass();
1650
+ if (seg.type === "dwell" && seg.at) {
1651
+ activate(seg.at);
1652
+ place(seg.at.len);
1653
+ }
1654
+ if (seg.type === "return") clearActive();
1655
+ } else if ((seg.type === "move" || seg.type === "return") && seg.from != null && seg.to != null) {
1656
+ const k = e / seg.dur;
1657
+ const ease = k < .5 ? 2 * k * k : 1 - Math.pow(-2 * k + 2, 2) / 2;
1658
+ place(seg.from + (seg.to - seg.from) * ease);
1659
+ } else if (seg.at) place(seg.at.len);
1660
+ raf = requestAnimationFrame(frame);
1661
+ };
1662
+ activate(first);
1663
+ place(first.len);
1664
+ raf = requestAnimationFrame(frame);
1665
+ return () => cancelAnimationFrame(raf);
1666
+ }, [geo]);
1667
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
1668
+ ref: rootRef,
1669
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
1670
+ className: "overflow-x-auto",
1671
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1672
+ className: "relative mx-auto",
1673
+ style: {
1674
+ width: geo.viewW,
1675
+ height: geo.viewH
1676
+ },
1677
+ children: [
1678
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", {
1679
+ className: "absolute inset-0",
1680
+ width: geo.viewW,
1681
+ height: geo.viewH,
1682
+ viewBox: `0 0 ${geo.viewW} ${geo.viewH}`,
1683
+ "aria-hidden": "true",
1684
+ children: [
1685
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("defs", { children: [
1686
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("marker", {
1687
+ id: "lpf-arw",
1688
+ markerUnits: "userSpaceOnUse",
1689
+ viewBox: "0 0 8 8",
1690
+ refX: "6",
1691
+ refY: "4",
1692
+ markerWidth: "9",
1693
+ markerHeight: "9",
1694
+ orient: "auto-start-reverse",
1695
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
1696
+ d: "M1.2 1.2 L7 4 L1.2 6.8 Z",
1697
+ fill: "var(--color-interactive)"
1698
+ })
1699
+ }),
1700
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("marker", {
1701
+ id: "lpf-arw-good",
1702
+ markerUnits: "userSpaceOnUse",
1703
+ viewBox: "0 0 8 8",
1704
+ refX: "6",
1705
+ refY: "4",
1706
+ markerWidth: "9",
1707
+ markerHeight: "9",
1708
+ orient: "auto-start-reverse",
1709
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
1710
+ d: "M1.2 1.2 L7 4 L1.2 6.8 Z",
1711
+ fill: "var(--color-success)"
1712
+ })
1713
+ }),
1714
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("filter", {
1715
+ id: "lpf-glow",
1716
+ x: "-60%",
1717
+ y: "-60%",
1718
+ width: "220%",
1719
+ height: "220%",
1720
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("feGaussianBlur", {
1721
+ stdDeviation: "2.4",
1722
+ result: "b"
1723
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("feMerge", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("feMergeNode", { in: "b" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("feMergeNode", { in: "SourceGraphic" })] })]
1724
+ }),
1725
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
1726
+ className: "lpf-route",
1727
+ fill: "none",
1728
+ d: geo.route
1729
+ })
1730
+ ] }),
1731
+ geo.wires.map((d, i) => {
1732
+ const isFinish = i === geo.finishWireIndex;
1733
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
1734
+ className: isFinish ? "lpf-wire finish" : "lpf-wire",
1735
+ d,
1736
+ fill: "none",
1737
+ strokeWidth: 2,
1738
+ strokeLinecap: "round",
1739
+ strokeDasharray: i === geo.returnWireIndex ? "6 6" : void 0,
1740
+ markerEnd: isFinish ? "url(#lpf-arw-good)" : "url(#lpf-arw)"
1741
+ }, i);
1742
+ }),
1743
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
1744
+ className: "lpf-comet",
1745
+ d: geo.route,
1746
+ fill: "none",
1747
+ strokeWidth: 2.5,
1748
+ strokeLinecap: "round",
1749
+ filter: "url(#lpf-glow)",
1750
+ opacity: .9
1751
+ }),
1752
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", {
1753
+ className: "lpf-pulse",
1754
+ r: 3.8,
1755
+ filter: "url(#lpf-glow)"
1756
+ })
1757
+ ]
1758
+ }),
1759
+ geo.worktree && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
1760
+ className: "absolute rounded-[14px] border border-dashed",
1761
+ style: {
1762
+ left: geo.worktree.x,
1763
+ top: geo.worktree.y,
1764
+ width: geo.worktree.w,
1765
+ height: geo.worktree.h,
1766
+ borderColor: "var(--color-interactive)",
1767
+ background: "var(--color-interactive-soft)"
1768
+ },
1769
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1770
+ className: "absolute px-2 font-mono text-[9.5px] font-semibold uppercase tracking-[0.1em]",
1771
+ style: {
1772
+ top: -9,
1773
+ left: 16,
1774
+ background: "var(--color-surface)",
1775
+ color: "var(--color-interactive)"
1776
+ },
1777
+ children: spec.worktreeLabel
1778
+ })
1779
+ }),
1780
+ geo.nodes.map((n) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1781
+ "data-lpf": n.id,
1782
+ className: `lpf-node${n.kind === "tick" ? " tick" : ""}`,
1783
+ style: {
1784
+ left: n.x,
1785
+ top: n.y,
1786
+ width: n.w,
1787
+ height: n.h
1788
+ },
1789
+ children: [
1790
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1791
+ className: "lpf-k",
1792
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1793
+ className: "g",
1794
+ children: n.glyph
1795
+ }), n.kicker]
1796
+ }),
1797
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
1798
+ className: "lpf-t",
1799
+ children: n.title
1800
+ }),
1801
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
1802
+ className: "lpf-d",
1803
+ children: n.detail
1804
+ })
1805
+ ]
1806
+ }, n.id))
1807
+ ]
1808
+ })
1809
+ })
1810
+ });
1811
+ }
1812
+ function Dashboard({ spec }) {
1813
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1814
+ className: "min-w-0",
1815
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
1816
+ className: "mb-4 text-body leading-snug text-secondary",
1817
+ children: "Pievo sets up a dashboard to track results."
1818
+ }), spec.dashboard.map((w, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
1819
+ className: `min-w-0 ${i > 0 ? "mt-6" : ""}`,
1820
+ children: w.type === "kanban" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(KanbanWidget, { w }) : w.type === "metric" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MetricWidget, { w }) : w.type === "calendar" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CalendarWidget, { w }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EmbedWidget, { w })
1821
+ }, i))]
1822
+ });
1823
+ }
1824
+ var CAL_DOW = [
1825
+ "Mon",
1826
+ "Tue",
1827
+ "Wed",
1828
+ "Thu",
1829
+ "Fri",
1830
+ "Sat",
1831
+ "Sun"
1832
+ ];
1833
+ /** A month grid of report days, matching LoopCalendar's look: Monday-start weekday
1834
+ * headers, mono day numbers top-right, hairline grid, an interactive-ink dot on days
1835
+ * that produced a report. grid-cols-7 fills the ~360px column and reflows (min-w-0). */
1836
+ function CalendarWidget({ w }) {
1837
+ const marked = new Set(w.reportDays);
1838
+ const trail = (7 - (w.firstWeekday + w.days) % 7) % 7;
1839
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1840
+ className: "min-w-0",
1841
+ children: [
1842
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1843
+ className: "mb-2 flex items-baseline gap-2",
1844
+ children: [
1845
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1846
+ className: "text-meta font-medium text-secondary",
1847
+ children: w.heading
1848
+ }),
1849
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1850
+ className: "font-mono text-caption text-disabled",
1851
+ children: w.monthLabel
1852
+ }),
1853
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
1854
+ className: "ml-auto font-mono text-caption text-disabled",
1855
+ children: [
1856
+ w.reportDays.length,
1857
+ " report",
1858
+ w.reportDays.length === 1 ? "" : "s"
1859
+ ]
1860
+ })
1861
+ ]
1862
+ }),
1863
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1864
+ className: "grid min-w-0 grid-cols-7 border-l border-t border-hairline",
1865
+ children: [
1866
+ CAL_DOW.map((d) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
1867
+ className: "border-b border-r border-hairline px-1.5 py-1 text-right text-micro font-medium text-disabled",
1868
+ children: d
1869
+ }, d)),
1870
+ Array.from({ length: w.firstWeekday }, (_, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "border-b border-r border-hairline bg-raised" }, `lead${i}`)),
1871
+ Array.from({ length: w.days }, (_, i) => {
1872
+ const day = i + 1;
1873
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1874
+ className: "relative min-h-[34px] min-w-0 border-b border-r border-hairline bg-surface px-1 pb-1 pt-4",
1875
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1876
+ className: "absolute right-1 top-0.5 font-mono text-micro text-disabled",
1877
+ children: day
1878
+ }), marked.has(day) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1879
+ title: `report · day ${day}`,
1880
+ className: "absolute bottom-1 left-1 inline-block size-1.5 rounded-full",
1881
+ style: { background: "var(--color-interactive)" }
1882
+ })]
1883
+ }, day);
1884
+ }),
1885
+ Array.from({ length: trail }, (_, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "border-b border-r border-hairline bg-raised" }, `trail${i}`))
1886
+ ]
1887
+ }),
1888
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1889
+ className: "mt-2 flex items-center gap-1.5 text-caption font-medium text-secondary",
1890
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1891
+ className: "inline-block size-1.5 rounded-full",
1892
+ style: { background: "var(--color-interactive)" }
1893
+ }), " Day with a report"]
1894
+ })
1895
+ ]
1896
+ });
1897
+ }
1898
+ function KanbanWidget({ w }) {
1899
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1900
+ className: "min-w-0",
1901
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1902
+ className: "mb-2 text-meta font-medium text-secondary",
1903
+ children: [
1904
+ w.heading,
1905
+ " ",
1906
+ w.sub && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1907
+ className: "font-mono text-caption text-disabled",
1908
+ children: w.sub
1909
+ })
1910
+ ]
1911
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
1912
+ className: "flex min-w-0 gap-3 overflow-x-auto pb-1",
1913
+ children: w.columns.map(([name, cards]) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1914
+ className: "flex w-[190px] shrink-0 flex-col",
1915
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1916
+ className: "mb-2 flex items-center gap-2 border-b border-hairline pb-1.5",
1917
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1918
+ className: "text-label font-semibold text-primary",
1919
+ children: name
1920
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1921
+ className: "text-caption text-disabled",
1922
+ children: cards.length
1923
+ })]
1924
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
1925
+ className: "flex flex-col gap-2",
1926
+ children: cards.map(([id, title, when]) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
1927
+ className: "min-w-0 overflow-hidden rounded-control border border-hairline bg-surface shadow-card transition-colors hover:border-wire",
1928
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1929
+ className: "flex flex-col gap-1 px-2.5 py-2",
1930
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1931
+ className: "truncate text-meta text-primary",
1932
+ children: title
1933
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
1934
+ className: "truncate font-mono text-micro text-disabled",
1935
+ children: [
1936
+ id,
1937
+ " · ",
1938
+ when
1939
+ ]
1940
+ })]
1941
+ })
1942
+ }, id))
1943
+ })]
1944
+ }, name))
1945
+ })]
1946
+ });
1947
+ }
1948
+ function EmbedWidget({ w }) {
1949
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1950
+ className: "min-w-0",
1951
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
1952
+ className: "mb-2 text-meta font-medium text-secondary",
1953
+ children: w.heading
1954
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1955
+ className: "rounded-card border border-hairline bg-surface p-3.5 shadow-card",
1956
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1957
+ className: "flex items-start gap-2",
1958
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1959
+ className: "min-w-0 flex-1",
1960
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
1961
+ className: "truncate text-meta font-semibold text-display",
1962
+ children: w.title
1963
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
1964
+ className: "font-mono text-micro text-disabled",
1965
+ children: w.date
1966
+ })]
1967
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1968
+ className: "shrink-0 rounded-full border border-hairline bg-raised px-2 py-0.5 font-mono text-micro text-secondary",
1969
+ children: "report"
1970
+ })]
1971
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
1972
+ className: "mt-3 flex flex-col gap-1.5 border-t border-hairline pt-3",
1973
+ children: w.lines.map((l, i) => i === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
1974
+ className: "text-meta font-medium text-primary",
1975
+ children: l
1976
+ }, i) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1977
+ className: "flex gap-2 text-caption text-secondary",
1978
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1979
+ className: "text-disabled",
1980
+ children: "—"
1981
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1982
+ className: "min-w-0",
1983
+ children: l
1984
+ })]
1985
+ }, i))
1986
+ })]
1987
+ })]
1988
+ });
1989
+ }
1990
+ function MetricWidget({ w }) {
1991
+ const s = w.series;
1992
+ const now = s[s.length - 1] ?? 0;
1993
+ const delta = now - (s[0] ?? 0);
1994
+ const good = w.betterDown ? delta < 0 : delta > 0;
1995
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1996
+ className: "min-w-0 rounded-card border border-hairline bg-surface p-3.5 shadow-card",
1997
+ children: [
1998
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1999
+ className: "mb-3 flex items-baseline gap-2",
2000
+ children: [
2001
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2002
+ className: "text-label font-semibold text-primary",
2003
+ children: w.label
2004
+ }),
2005
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2006
+ className: "ml-auto font-mono text-body font-semibold text-display",
2007
+ children: now
2008
+ }),
2009
+ delta !== 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
2010
+ className: "font-mono text-caption",
2011
+ style: { color: good ? "var(--color-success)" : "var(--color-accent)" },
2012
+ children: [
2013
+ delta > 0 ? "▲" : "▼",
2014
+ " ",
2015
+ Math.abs(delta)
2016
+ ]
2017
+ })
2018
+ ]
2019
+ }),
2020
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AreaTrend, { series: s }),
2021
+ w.note && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
2022
+ className: "mt-2 font-mono text-caption text-secondary",
2023
+ children: w.note
2024
+ })
2025
+ ]
2026
+ });
2027
+ }
2028
+ /** A single-series area trend, drawn like LoopChart: horizontal grid, mono axis
2029
+ * ticks, gradient fill in the chart-1 (display) ink. */
2030
+ function AreaTrend({ series }) {
2031
+ const gid = (0, import_react.useMemo)(() => `lpf-grad-${Math.round(series.reduce((a, b) => a + b, 0))}-${series.length}`, [series]);
2032
+ const W = 320;
2033
+ const H = 150;
2034
+ const padL = 26;
2035
+ const padR = 8;
2036
+ const padT = 10;
2037
+ const padB = 18;
2038
+ const dmin = Math.min(...series);
2039
+ const dmax = Math.max(...series);
2040
+ const span = Math.max(1, dmax - dmin);
2041
+ let lo = Math.floor(dmin - span * .15);
2042
+ const hi = Math.ceil(dmax + span * .15);
2043
+ if (dmin >= 0 && lo < 0) lo = 0;
2044
+ const X = (i) => padL + i * (W - padL - padR) / (series.length - 1);
2045
+ const Y = (v) => padT + (1 - (v - lo) / (hi - lo || 1)) * (H - padT - padB);
2046
+ const f = (n) => Math.round(n * 100) / 100;
2047
+ const line = "M" + series.map((v, i) => `${f(X(i))} ${f(Y(v))}`).join(" L ");
2048
+ const area = `${line} L ${f(X(series.length - 1))} ${H - padB} L ${f(X(0))} ${H - padB} Z`;
2049
+ const ticks = [
2050
+ lo,
2051
+ Math.round((lo + hi) / 2),
2052
+ hi
2053
+ ];
2054
+ const last = series.length - 1;
2055
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", {
2056
+ viewBox: `0 0 ${W} ${H}`,
2057
+ width: "100%",
2058
+ className: "block",
2059
+ role: "img",
2060
+ "aria-label": "metric trend",
2061
+ children: [
2062
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("linearGradient", {
2063
+ id: gid,
2064
+ x1: "0",
2065
+ y1: "0",
2066
+ x2: "0",
2067
+ y2: "1",
2068
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("stop", {
2069
+ offset: "0",
2070
+ stopColor: "var(--color-chart-1)",
2071
+ stopOpacity: "0.16"
2072
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("stop", {
2073
+ offset: "1",
2074
+ stopColor: "var(--color-chart-1)",
2075
+ stopOpacity: "0"
2076
+ })]
2077
+ }) }),
2078
+ ticks.map((v, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", {
2079
+ x1: padL,
2080
+ y1: f(Y(v)),
2081
+ x2: W - padR,
2082
+ y2: f(Y(v)),
2083
+ stroke: "var(--color-hairline)",
2084
+ strokeWidth: 1
2085
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("text", {
2086
+ x: padL - 6,
2087
+ y: f(Y(v)) + 3,
2088
+ textAnchor: "end",
2089
+ fontFamily: "var(--font-mono)",
2090
+ fontSize: 9,
2091
+ fill: "var(--color-disabled)",
2092
+ children: v
2093
+ })] }, i)),
2094
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
2095
+ d: area,
2096
+ fill: `url(#${gid})`
2097
+ }),
2098
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
2099
+ d: line,
2100
+ fill: "none",
2101
+ stroke: "var(--color-chart-1)",
2102
+ strokeWidth: 2,
2103
+ strokeLinecap: "round",
2104
+ strokeLinejoin: "round"
2105
+ }),
2106
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", {
2107
+ cx: f(X(last)),
2108
+ cy: f(Y(series[last] ?? 0)),
2109
+ r: 3,
2110
+ fill: "var(--color-chart-1)",
2111
+ stroke: "var(--color-surface)",
2112
+ strokeWidth: 1.5
2113
+ }),
2114
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("text", {
2115
+ x: padL,
2116
+ y: H - 5,
2117
+ fontFamily: "var(--font-mono)",
2118
+ fontSize: 9,
2119
+ fill: "var(--color-disabled)",
2120
+ children: "older"
2121
+ }),
2122
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("text", {
2123
+ x: W - padR,
2124
+ y: H - 5,
2125
+ textAnchor: "end",
2126
+ fontFamily: "var(--font-mono)",
2127
+ fontSize: 9,
2128
+ fill: "var(--color-disabled)",
2129
+ children: "now"
2130
+ })
2131
+ ]
2132
+ });
2133
+ }
2134
+ var SLOW_WAIT_MS = 1e5;
2135
+ var AGENT_LABEL = {
2136
+ "claude-code": "Claude Code",
2137
+ codex: "Codex"
2138
+ };
2139
+ function ClaudeCodeMark({ size = 14 }) {
2140
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", {
2141
+ "aria-hidden": true,
2142
+ width: size,
2143
+ height: size,
2144
+ viewBox: "0 0 24 24",
2145
+ fill: "#D97757",
2146
+ fillRule: "evenodd",
2147
+ className: "shrink-0",
2148
+ xmlns: "http://www.w3.org/2000/svg",
2149
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
2150
+ clipRule: "evenodd",
2151
+ d: "M20.998 10.949H24v3.102h-3v3.028h-1.487V20H18v-2.921h-1.487V20H15v-2.921H9V20H7.488v-2.921H6V20H4.487v-2.921H3V14.05H0V10.95h3V5h17.998v5.949zM6 10.949h1.488V8.102H6v2.847zm10.51 0H18V8.102h-1.49v2.847z"
2152
+ })
2153
+ });
2154
+ }
2155
+ /** Codex color mark (LobeHub icon set) — verbatim: white app tile + gradient glyph. */
2156
+ function CodexMark({ size = 14 }) {
2157
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", {
2158
+ "aria-hidden": true,
2159
+ width: size,
2160
+ height: size,
2161
+ viewBox: "0 0 24 24",
2162
+ className: "shrink-0",
2163
+ xmlns: "http://www.w3.org/2000/svg",
2164
+ children: [
2165
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
2166
+ d: "M19.503 0H4.496A4.496 4.496 0 000 4.496v15.007A4.496 4.496 0 004.496 24h15.007A4.496 4.496 0 0024 19.503V4.496A4.496 4.496 0 0019.503 0z",
2167
+ fill: "#fff"
2168
+ }),
2169
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
2170
+ d: "M9.064 3.344a4.578 4.578 0 012.285-.312c1 .115 1.891.54 2.673 1.275.01.01.024.017.037.021a.09.09 0 00.043 0 4.55 4.55 0 013.046.275l.047.022.116.057a4.581 4.581 0 012.188 2.399c.209.51.313 1.041.315 1.595a4.24 4.24 0 01-.134 1.223.123.123 0 00.03.115c.594.607.988 1.33 1.183 2.17.289 1.425-.007 2.71-.887 3.854l-.136.166a4.548 4.548 0 01-2.201 1.388.123.123 0 00-.081.076c-.191.551-.383 1.023-.74 1.494-.9 1.187-2.222 1.846-3.711 1.838-1.187-.006-2.239-.44-3.157-1.302a.107.107 0 00-.105-.024c-.388.125-.78.143-1.204.138a4.441 4.441 0 01-1.945-.466 4.544 4.544 0 01-1.61-1.335c-.152-.202-.303-.392-.414-.617a5.81 5.81 0 01-.37-.961 4.582 4.582 0 01-.014-2.298.124.124 0 00.006-.056.085.085 0 00-.027-.048 4.467 4.467 0 01-1.034-1.651 3.896 3.896 0 01-.251-1.192 5.189 5.189 0 01.141-1.6c.337-1.112.982-1.985 1.933-2.618.212-.141.413-.251.601-.33.215-.089.43-.164.646-.227a.098.098 0 00.065-.066 4.51 4.51 0 01.829-1.615 4.535 4.535 0 011.837-1.388zm3.482 10.565a.637.637 0 000 1.272h3.636a.637.637 0 100-1.272h-3.636zM8.462 9.23a.637.637 0 00-1.106.631l1.272 2.224-1.266 2.136a.636.636 0 101.095.649l1.454-2.455a.636.636 0 00.005-.64L8.462 9.23z",
2171
+ fill: "url(#lobe-icons-codex-grad)"
2172
+ }),
2173
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("linearGradient", {
2174
+ gradientUnits: "userSpaceOnUse",
2175
+ id: "lobe-icons-codex-grad",
2176
+ x1: "12",
2177
+ x2: "12",
2178
+ y1: "3",
2179
+ y2: "21",
2180
+ children: [
2181
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("stop", { stopColor: "#B1A7FF" }),
2182
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("stop", {
2183
+ offset: ".5",
2184
+ stopColor: "#7A9DFF"
2185
+ }),
2186
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("stop", {
2187
+ offset: "1",
2188
+ stopColor: "#3941FF"
2189
+ })
2190
+ ]
2191
+ }) })
2192
+ ]
2193
+ });
2194
+ }
2195
+ var instructionFor = (origin) => `Fetch ${origin}/api/bootstrap and help me build a loop.`;
2196
+ /**
2197
+ * New loop = capture-from-Claude-Code (paste-forward, no machine picker). The web
2198
+ * mints a claim token, shows ONE instruction block, and waits. The user pastes it
2199
+ * into their own Claude Code session (where they just did the task); Claude
2200
+ * follows /api/bootstrap — ensures a daemon is running (the token authorizes a new
2201
+ * machine, or the machine's stored token reuses an existing one) and POSTs the
2202
+ * loop to /api/machine/loop with this token as `claim`. We poll the claim until
2203
+ * the loop lands, then close. No machine selection: the binding is decided on the
2204
+ * machine, the claim just correlates the result back to this dialog.
2205
+ *
2206
+ * A `template` (a canned loop intent picked from the dashboard cards) reuses this exact
2207
+ * machinery and appends its `description` under the config lines — bootstrap.md +
2208
+ * create.md then handle cadence/config the same way. Pievo is BYOA-only: every loop runs
2209
+ * on the connected machine; there is no hosted-agent option.
2210
+ */
2211
+ function ComposeModal({ open, onClose, onCreated, template = null, teamId }) {
2212
+ const [token, setToken] = (0, import_react.useState)(null);
2213
+ const [config, setConfig] = (0, import_react.useState)(null);
2214
+ const [created, setCreated] = (0, import_react.useState)(null);
2215
+ const [copied, setCopied] = (0, import_react.useState)(false);
2216
+ const [slow, setSlow] = (0, import_react.useState)(false);
2217
+ const [error, setError] = (0, import_react.useState)(null);
2218
+ const [configError, setConfigError] = (0, import_react.useState)(false);
2219
+ const pollRef = (0, import_react.useRef)(null);
2220
+ const onCreatedRef = (0, import_react.useRef)(onCreated);
2221
+ onCreatedRef.current = onCreated;
2222
+ const origin = typeof window !== "undefined" ? window.location.origin : "";
2223
+ const instruction = instructionFor(origin);
2224
+ const configLines = token && config ? [
2225
+ `server-url: ${origin}`,
2226
+ `connect-key: ${token}`,
2227
+ ...config?.customCli ? [`pievo-cli: ${config.pievoCli}`] : []
2228
+ ].join("\n") : "";
2229
+ const description = template?.description?.trim() ?? "";
2230
+ const snippet = token && config ? [
2231
+ instruction,
2232
+ "",
2233
+ configLines,
2234
+ ...description ? ["", description] : []
2235
+ ].join("\n") : "";
2236
+ (0, import_react.useEffect)(() => {
2237
+ if (!open) return;
2238
+ setToken(null);
2239
+ setConfig(null);
2240
+ setCreated(null);
2241
+ setError(null);
2242
+ setConfigError(false);
2243
+ setCopied(false);
2244
+ setSlow(false);
2245
+ }, [open, template]);
2246
+ (0, import_react.useEffect)(() => {
2247
+ if (!open) return;
2248
+ let active = true;
2249
+ getConfig().then((value) => {
2250
+ if (active) setConfig(value);
2251
+ }).catch(() => {
2252
+ if (active) setConfigError(true);
2253
+ });
2254
+ mintClaim({ data: teamId }).then((r) => {
2255
+ if (active) "token" in r ? setToken(r.token) : setError(r.error);
2256
+ }).catch(() => {
2257
+ if (active) setError("could not mint a connect key");
2258
+ });
2259
+ return () => {
2260
+ active = false;
2261
+ };
2262
+ }, [open, teamId]);
2263
+ (0, import_react.useEffect)(() => {
2264
+ if (!open || created || !token) return;
2265
+ if (pollRef.current) clearInterval(pollRef.current);
2266
+ pollRef.current = setInterval(() => {
2267
+ claimStatus({ data: token }).then((s) => {
2268
+ if (s.done && s.id) {
2269
+ if (pollRef.current) clearInterval(pollRef.current);
2270
+ setCreated({
2271
+ id: s.id,
2272
+ name: s.name ?? "loop",
2273
+ agent: s.agent ?? "claude-code"
2274
+ });
2275
+ onCreatedRef.current();
2276
+ }
2277
+ }).catch(() => {});
2278
+ }, 2500);
2279
+ const slowTimer = setTimeout(() => setSlow(true), SLOW_WAIT_MS);
2280
+ return () => {
2281
+ if (pollRef.current) clearInterval(pollRef.current);
2282
+ clearTimeout(slowTimer);
2283
+ };
2284
+ }, [
2285
+ open,
2286
+ created,
2287
+ token
2288
+ ]);
2289
+ async function copy() {
2290
+ try {
2291
+ await navigator.clipboard.writeText(snippet);
2292
+ setCopied(true);
2293
+ setTimeout(() => setCopied(false), 1500);
2294
+ } catch {
2295
+ setError("could not copy - select the text and copy manually");
2296
+ }
2297
+ }
2298
+ const snippetBox = (showInlineCopy = true) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2299
+ className: "min-w-0 flex-1",
2300
+ children: [
2301
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2302
+ className: "flex items-center justify-between gap-3",
2303
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", {
2304
+ className: "text-label font-semibold text-display",
2305
+ children: "Paste to capture it"
2306
+ }), showInlineCopy && snippet && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
2307
+ className: btnSm,
2308
+ onClick: () => void copy(),
2309
+ children: copied ? "✓ Copied" : "Copy"
2310
+ })]
2311
+ }),
2312
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2313
+ className: "mt-2 overflow-hidden rounded-control border border-hairline bg-raised p-3 font-mono text-label text-primary",
2314
+ children: [
2315
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
2316
+ className: "leading-relaxed",
2317
+ children: instruction
2318
+ }),
2319
+ configLines ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", {
2320
+ className: "mt-3 overflow-x-auto whitespace-pre-wrap border-t border-hairline pt-3 leading-relaxed text-secondary",
2321
+ children: configLines
2322
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
2323
+ className: "mt-3 border-t border-hairline pt-3 leading-relaxed text-secondary",
2324
+ children: configError ? "Could not load the CLI configuration. Close and try again." : token ? "Loading CLI configuration…" : "Minting a connect key…"
2325
+ }),
2326
+ description && configLines && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
2327
+ className: "mt-3 whitespace-pre-wrap border-t border-hairline pt-3 leading-relaxed text-primary",
2328
+ children: description
2329
+ })
2330
+ ]
2331
+ }),
2332
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
2333
+ className: "mt-2 text-body leading-snug text-secondary",
2334
+ children: [
2335
+ "Paste it in that same session - reuses this machine automatically. Your agent will",
2336
+ " ",
2337
+ template ? "set the loop up from here." : "ask what the loop should do."
2338
+ ]
2339
+ })
2340
+ ]
2341
+ });
2342
+ const wait = slow ? {
2343
+ dot: "bg-secondary",
2344
+ text: "Still waiting - check your coding agent is running in the right project, then paste again."
2345
+ } : {
2346
+ dot: "animate-pulse bg-rubik-orange",
2347
+ text: "Waiting for your coding agent…"
2348
+ };
2349
+ const copyPromptButton = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
2350
+ className: `${btnPrimaryPill} ml-auto`,
2351
+ onClick: () => void copy(),
2352
+ disabled: !snippet,
2353
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
2354
+ className: "inline-flex items-center gap-0.5",
2355
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ClaudeCodeMark, {}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CodexMark, {})]
2356
+ }), copied ? "✓ Copied" : "Copy prompt"]
2357
+ });
2358
+ if (created) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Modal, {
2359
+ open,
2360
+ onClose,
2361
+ children: [
2362
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalHead, {
2363
+ title: "Loop created",
2364
+ sub: `${AGENT_LABEL[created.agent]} built and registered it.`
2365
+ }),
2366
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2367
+ className: "mt-5 rounded-card border border-hairline bg-surface p-5 shadow-card",
2368
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2369
+ className: "text-[17px] font-medium text-display",
2370
+ children: ["✓ ", created.name]
2371
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
2372
+ className: "mt-1 text-body text-secondary",
2373
+ children: "It’s scheduled now and will run on the machine."
2374
+ })]
2375
+ }),
2376
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
2377
+ className: "mt-4",
2378
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
2379
+ className: btnPrimary,
2380
+ onClick: onClose,
2381
+ children: "Done"
2382
+ })
2383
+ })
2384
+ ]
2385
+ });
2386
+ if (template) {
2387
+ const showFlow = hasLoopFlow(template.name);
2388
+ const promptCol = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2389
+ className: "min-w-0",
2390
+ children: [
2391
+ snippetBox(false),
2392
+ error && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2393
+ className: "mt-3 text-body text-accent",
2394
+ children: ["Error: ", error]
2395
+ }),
2396
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2397
+ className: "mt-6 flex items-start gap-3",
2398
+ children: [
2399
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: `mt-1 inline-block h-2 w-2 shrink-0 rounded-full ${wait.dot}` }),
2400
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2401
+ className: "text-label leading-relaxed text-secondary",
2402
+ children: wait.text
2403
+ }),
2404
+ copyPromptButton
2405
+ ]
2406
+ })
2407
+ ]
2408
+ });
2409
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Modal, {
2410
+ open,
2411
+ onClose,
2412
+ wide: showFlow,
2413
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalHead, {
2414
+ title: template.label,
2415
+ sub: "Paste this into your coding agent, in the project you want the loop for."
2416
+ }), showFlow ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2417
+ className: "mt-5 grid gap-8 md:grid-cols-[minmax(0,1fr)_400px]",
2418
+ children: [promptCol, /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
2419
+ className: "min-w-0 md:border-l md:border-hairline md:pl-8",
2420
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoopFlow, { template })
2421
+ })]
2422
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
2423
+ className: "mt-6",
2424
+ children: promptCol
2425
+ })]
2426
+ });
2427
+ }
2428
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Modal, {
2429
+ open,
2430
+ onClose,
2431
+ children: [
2432
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalHead, { title: "New loop" }),
2433
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2434
+ className: "mt-6",
2435
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2436
+ className: "flex gap-3.5",
2437
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2438
+ className: "flex flex-col items-center",
2439
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2440
+ className: "flex size-5 shrink-0 items-center justify-center rounded-full border border-display text-micro font-medium leading-none text-display",
2441
+ children: "1"
2442
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "mt-1 w-px flex-1 bg-hairline" })]
2443
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2444
+ className: "pb-6",
2445
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", {
2446
+ className: "text-label font-semibold text-display",
2447
+ children: "Do it once in your coding agent"
2448
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
2449
+ className: "mt-1.5 text-body leading-snug text-secondary",
2450
+ children: "Run the task yourself first, to a real result you’re happy with."
2451
+ })]
2452
+ })]
2453
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2454
+ className: "flex gap-3.5",
2455
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2456
+ className: "flex size-5 shrink-0 items-center justify-center rounded-full border border-display text-micro font-medium leading-none text-display",
2457
+ children: "2"
2458
+ }), snippetBox(false)]
2459
+ })]
2460
+ }),
2461
+ error && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2462
+ className: "mt-3 text-body text-accent",
2463
+ children: ["Error: ", error]
2464
+ }),
2465
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2466
+ className: "mt-6 flex items-start gap-3",
2467
+ children: [
2468
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: `mt-1 inline-block h-2 w-2 shrink-0 rounded-full ${wait.dot}` }),
2469
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2470
+ className: "text-label leading-relaxed text-secondary",
2471
+ children: wait.text
2472
+ }),
2473
+ copyPromptButton
2474
+ ]
2475
+ })
2476
+ ]
2477
+ });
2478
+ }
2479
+ /** The LIVE data fan-out - jobs/machines/teams change between polls. Templates
2480
+ * are static per deploy (a compile-time registry), so only the route loader
2481
+ * fetches them; the poll must not re-ship the thumb SVGs every 3-10s.
2482
+ *
2483
+ * `teamId` (the `/t/<id>` route's team, in id form or undefined in open mode)
2484
+ * scopes every list fn EXPLICITLY - so a tab on /t/A and one on /t/B show
2485
+ * different teams simultaneously, independent of the shared last-used cookie. */
2486
+ async function fetchLiveData(teamId) {
2487
+ const [jobs, machines, teams] = await Promise.all([
2488
+ listJobs({ data: teamId }),
2489
+ listMachines({ data: teamId }),
2490
+ listMyTeams({ data: teamId })
2491
+ ]);
2492
+ return {
2493
+ jobs,
2494
+ machines,
2495
+ teams
2496
+ };
2497
+ }
2498
+ /**
2499
+ * The dashboard body, shared by the `/` (open mode) and `/t/<teamId>` routes. It
2500
+ * renders from its own fetch-then-set poll state, seeded once from the route
2501
+ * loader's data, and scopes every fetch to `teamId` so the view is pinned to the
2502
+ * URL's team (multi-tab safe). The route mounts it with `key={teamId}` so a
2503
+ * team switch (a `/t/<id>` navigation) re-seeds state from the new loader data.
2504
+ */
2505
+ function DashboardView({ teamId, initial }) {
2506
+ const [data, setData] = (0, import_react.useState)(() => ({
2507
+ jobs: initial?.jobs ?? [],
2508
+ templates: initial?.templates ?? [],
2509
+ machines: initial?.machines ?? [],
2510
+ teams: initial?.teams
2511
+ }));
2512
+ const { jobs, templates, machines, teams } = data;
2513
+ const online = machines.filter((m) => m.online).length;
2514
+ const navigate = useNavigate();
2515
+ const [compose, setCompose] = (0, import_react.useState)({
2516
+ open: false,
2517
+ template: null
2518
+ });
2519
+ const [machinesOpen, setMachinesOpen] = (0, import_react.useState)(false);
2520
+ const [notifyOpen, setNotifyOpen] = (0, import_react.useState)(false);
2521
+ const [teamsOpen, setTeamsOpen] = (0, import_react.useState)(false);
2522
+ const refetch = (0, import_react.useCallback)(async () => {
2523
+ try {
2524
+ const live = await fetchLiveData(teamId);
2525
+ setData((prev) => ({
2526
+ ...prev,
2527
+ ...live
2528
+ }));
2529
+ } catch {}
2530
+ }, [teamId]);
2531
+ const openRef = (0, import_react.useRef)(false);
2532
+ openRef.current = compose.open || machinesOpen || notifyOpen || teamsOpen;
2533
+ const anyRunning = jobs.some((j) => j.running);
2534
+ (0, import_react.useEffect)(() => {
2535
+ const t = setInterval(() => {
2536
+ if (!openRef.current) refetch();
2537
+ }, anyRunning ? 3e3 : 1e4);
2538
+ return () => clearInterval(t);
2539
+ }, [refetch, anyRunning]);
2540
+ const refresh = () => void refetch();
2541
+ const completed = jobs.filter(isCompleted);
2542
+ const active = jobs.filter((j) => !isCompleted(j));
2543
+ const activeOn = active.filter((j) => j.enabled).length;
2544
+ const cardProps = () => ({
2545
+ onOpen: (id) => void navigate({
2546
+ to: "/loops/$loopId",
2547
+ params: { loopId: id }
2548
+ }),
2549
+ onPickRun: (jobId, run) => void navigate({
2550
+ to: "/loops/$loopId/runs/$runId",
2551
+ params: {
2552
+ loopId: jobId,
2553
+ runId: run.id
2554
+ }
2555
+ })
2556
+ });
2557
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TooltipProvider, {
2558
+ delay: 120,
2559
+ children: [
2560
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("header", {
2561
+ className: "glass glass-bar sticky top-0 z-50",
2562
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2563
+ className: "mx-auto flex max-w-[1180px] items-center gap-3 px-8 py-2.5",
2564
+ children: [
2565
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PievoLogo, { size: 30 }),
2566
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2567
+ className: "text-[18px] font-semibold tracking-[-0.015em] text-display",
2568
+ children: "Pievo"
2569
+ }),
2570
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TeamSwitcher, { data: teams }),
2571
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex-1" }),
2572
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
2573
+ href: GITHUB_URL,
2574
+ target: "_blank",
2575
+ rel: "noreferrer",
2576
+ "aria-label": "GitHub repository",
2577
+ title: "GitHub",
2578
+ className: headerIconBtn,
2579
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GitHubIcon, { className: "size-[17px]" })
2580
+ }),
2581
+ teams && teams.teams.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
2582
+ onClick: () => setTeamsOpen(true),
2583
+ className: headerBtn,
2584
+ children: "Teams"
2585
+ }),
2586
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
2587
+ onClick: () => setNotifyOpen(true),
2588
+ className: headerBtn,
2589
+ children: "Notifications"
2590
+ }),
2591
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
2592
+ onClick: () => setMachinesOpen(true),
2593
+ className: `${headerBtn} gap-1.5`,
2594
+ children: [
2595
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: `inline-block size-1.5 rounded-full ${online ? "bg-rubik-green" : "bg-disabled"}` }),
2596
+ online,
2597
+ " ",
2598
+ online === 1 ? "machine" : "machines",
2599
+ " online"
2600
+ ]
2601
+ }),
2602
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
2603
+ onClick: () => setCompose({
2604
+ open: true,
2605
+ template: null
2606
+ }),
2607
+ className: "inline-flex shrink-0 cursor-pointer items-center rounded-full bg-display px-3.5 py-1.5 text-meta font-medium text-paper transition-opacity hover:opacity-85",
2608
+ children: "New Loop"
2609
+ })
2610
+ ]
2611
+ })
2612
+ }),
2613
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("main", {
2614
+ className: "mx-auto max-w-[1180px] px-8 pb-24",
2615
+ children: [
2616
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
2617
+ className: "pb-2 pt-14 text-center",
2618
+ children: [
2619
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", {
2620
+ className: "font-pixel text-[clamp(28px,4.5vw,38px)] leading-[1.15] text-display",
2621
+ children: "What should happen while you sleep?"
2622
+ }),
2623
+ templates.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
2624
+ className: "mb-5 mt-2 text-body text-secondary",
2625
+ children: "Start with a template…"
2626
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TemplateFan, {
2627
+ templates,
2628
+ onPick: (t) => setCompose({
2629
+ open: true,
2630
+ template: t
2631
+ })
2632
+ })] }),
2633
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
2634
+ className: "mt-7",
2635
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
2636
+ onClick: () => setCompose({
2637
+ open: true,
2638
+ template: null
2639
+ }),
2640
+ className: "inline-flex cursor-pointer items-center gap-1.5 rounded-full bg-display px-6 py-2.5 text-body font-medium text-paper transition-opacity hover:opacity-85",
2641
+ children: [templates.length ? "Start a blank loop" : "Start your first loop", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2642
+ "aria-hidden": true,
2643
+ children: "→"
2644
+ })]
2645
+ })
2646
+ })
2647
+ ]
2648
+ }),
2649
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2650
+ className: "mb-5 mt-12 flex items-baseline gap-2.5",
2651
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", {
2652
+ className: "text-body font-semibold text-display",
2653
+ children: "Active loops"
2654
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2655
+ className: "text-label text-secondary",
2656
+ children: active.length ? `${activeOn} scheduled · ${active.length} total` : ""
2657
+ })]
2658
+ }),
2659
+ active.length ? active.map((j) => /* @__PURE__ */ (0, import_react.createElement)(LoopCard, {
2660
+ job: j,
2661
+ ...cardProps(),
2662
+ key: j.id
2663
+ })) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2664
+ className: "py-16 text-center",
2665
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
2666
+ className: "text-[15px] text-secondary",
2667
+ children: jobs.length ? "No active loops" : "No loops yet"
2668
+ }), !jobs.length && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
2669
+ className: "mt-1.5 text-body text-disabled",
2670
+ children: "Pick a template above, or start a blank loop."
2671
+ })]
2672
+ }),
2673
+ completed.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2674
+ className: "mb-5 mt-11 flex items-baseline gap-2.5",
2675
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", {
2676
+ className: "text-body font-semibold text-display",
2677
+ children: "Completed"
2678
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
2679
+ className: "text-label text-secondary",
2680
+ children: [completed.length, " total"]
2681
+ })]
2682
+ }), completed.map((j) => /* @__PURE__ */ (0, import_react.createElement)(LoopCard, {
2683
+ job: j,
2684
+ ...cardProps(),
2685
+ key: j.id
2686
+ }))] }),
2687
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoopPlaybook, { onStart: () => setCompose({
2688
+ open: true,
2689
+ template: null
2690
+ }) })
2691
+ ]
2692
+ }),
2693
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ComposeModal, {
2694
+ open: compose.open,
2695
+ template: compose.template,
2696
+ teamId,
2697
+ onClose: () => setCompose({
2698
+ open: false,
2699
+ template: null
2700
+ }),
2701
+ onCreated: refresh
2702
+ }),
2703
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MachinesModal, {
2704
+ open: machinesOpen,
2705
+ onClose: () => setMachinesOpen(false),
2706
+ teamId
2707
+ }),
2708
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NotificationsModal, {
2709
+ open: notifyOpen,
2710
+ onClose: () => setNotifyOpen(false)
2711
+ }),
2712
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TeamsModal, {
2713
+ open: teamsOpen,
2714
+ onClose: () => setTeamsOpen(false),
2715
+ activeTeamId: teamId
2716
+ })
2717
+ ]
2718
+ });
2719
+ }
2720
+ var headerBtn = "inline-flex shrink-0 cursor-pointer items-center rounded-full px-3 py-1.5 text-meta font-medium text-secondary transition-colors hover:bg-raised hover:text-display";
2721
+ var headerIconBtn = "inline-flex shrink-0 cursor-pointer items-center rounded-full p-1.5 text-secondary transition-colors hover:bg-raised hover:text-display";
2722
+ /**
2723
+ * The template fan - a hand of tilted cards (tilt/lift computed from each
2724
+ * card's offset from its ROW's center). Up to 5 cards stay a single hand;
2725
+ * more split into balanced rows of at most 4 (7 -> 4/3, 9 -> 3/3/3), so no
2726
+ * count can flex-wrap into one orphan card stranded under a full row.
2727
+ * Hover/focus straightens a card via the `.fan-card` rules in app.css.
2728
+ * One click carries the template into ComposeModal, same as the old flat cards.
2729
+ */
2730
+ function TemplateFan({ templates, onPick }) {
2731
+ const rowCount = templates.length <= 5 ? 1 : Math.ceil(templates.length / 4);
2732
+ const rows = [];
2733
+ for (let r = 0, at = 0; r < rowCount; r++) {
2734
+ const size = Math.ceil((templates.length - at) / (rowCount - r));
2735
+ rows.push(templates.slice(at, at + size));
2736
+ at += size;
2737
+ }
2738
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
2739
+ className: "pb-3 pt-1",
2740
+ children: rows.map((row, r) => {
2741
+ const center = (row.length - 1) / 2;
2742
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
2743
+ className: "flex flex-wrap items-start justify-center",
2744
+ children: row.map((t, i) => {
2745
+ const off = i - center;
2746
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
2747
+ type: "button",
2748
+ onClick: () => onPick(t),
2749
+ title: t.desc,
2750
+ className: "fan-card relative w-[196px] shrink-0 cursor-pointer rounded-card border border-hairline bg-surface p-3 text-left shadow-[0_12px_28px_-16px_rgba(0,0,0,0.25)] outline-none focus-visible:ring-2 focus-visible:ring-interactive",
2751
+ style: {
2752
+ "--tilt": `${off * 3.5}deg`,
2753
+ "--lift": `${Math.abs(off) * 7}px`,
2754
+ marginInline: row.length > 1 ? "-5px" : void 0
2755
+ },
2756
+ children: [
2757
+ t.thumb ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2758
+ className: "block overflow-hidden rounded-control bg-raised [&_svg]:block [&_svg]:h-auto [&_svg]:w-full",
2759
+ dangerouslySetInnerHTML: { __html: t.thumb }
2760
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2761
+ className: "flex h-[76px] items-center justify-center rounded-control bg-raised text-secondary",
2762
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoopGlyph, {})
2763
+ }),
2764
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2765
+ className: "mt-2.5 block truncate text-center text-meta font-semibold text-primary",
2766
+ children: t.label
2767
+ }),
2768
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2769
+ className: "mt-0.5 line-clamp-3 min-h-[45px] text-center text-caption leading-snug text-secondary",
2770
+ children: t.desc
2771
+ })
2772
+ ]
2773
+ }, t.name);
2774
+ })
2775
+ }, r);
2776
+ })
2777
+ });
2778
+ }
2779
+ /** A circular-arrow "loop" mark - one glyph for every template, tinted per card. */
2780
+ function LoopGlyph() {
2781
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", {
2782
+ "aria-hidden": true,
2783
+ width: "30",
2784
+ height: "30",
2785
+ viewBox: "0 0 30 30",
2786
+ fill: "none",
2787
+ stroke: "currentColor",
2788
+ strokeWidth: "1.8",
2789
+ strokeLinecap: "round",
2790
+ strokeLinejoin: "round",
2791
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M25.5 15a10.5 10.5 0 1 1-3.1-7.4" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M25.5 3.5v5.2h-5.2" })]
2792
+ });
2793
+ }
2794
+ //#endregion
2795
+ export { fetchLiveData as n, DashboardView as t };