@engenty/wizards-runtime 0.14.1 → 0.15.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 (89) hide show
  1. package/apps/runtime/dist/agents/studio-assistant.js +50 -3
  2. package/apps/runtime/dist/app.js +9 -2
  3. package/apps/runtime/dist/broker/call.js +2 -0
  4. package/apps/runtime/dist/broker/host.js +1 -0
  5. package/apps/runtime/dist/broker/rwx.js +38 -4
  6. package/apps/runtime/dist/db/client.js +12 -1
  7. package/apps/runtime/dist/db/migrations/tenant/0040_rwx_elements.sql +21 -0
  8. package/apps/runtime/dist/db/migrations/tenant/0041_broker_log_client.sql +1 -0
  9. package/apps/runtime/dist/db/migrations/tenant/meta/0040_snapshot.json +5153 -0
  10. package/apps/runtime/dist/db/migrations/tenant/meta/0041_snapshot.json +5160 -0
  11. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +14 -0
  12. package/apps/runtime/dist/db/schema.js +2 -0
  13. package/apps/runtime/dist/docs/dev/api.md +24 -2
  14. package/apps/runtime/dist/docs/dev/architecture.md +13 -2
  15. package/apps/runtime/dist/elements/caller.js +45 -0
  16. package/apps/runtime/dist/elements/catalogue.js +14 -0
  17. package/apps/runtime/dist/elements/connections.js +60 -0
  18. package/apps/runtime/dist/elements/gate.js +81 -0
  19. package/apps/runtime/dist/elements/knowledge.js +139 -0
  20. package/apps/runtime/dist/elements/outside.js +103 -0
  21. package/apps/runtime/dist/elements/specs.js +102 -0
  22. package/apps/runtime/dist/elements/wizards.js +59 -0
  23. package/apps/runtime/dist/env.js +5 -2
  24. package/apps/runtime/dist/health.js +50 -1
  25. package/apps/runtime/dist/mcp/elements.js +88 -0
  26. package/apps/runtime/dist/mcp/handler.js +2 -0
  27. package/apps/runtime/dist/mcp/scopes.js +5 -0
  28. package/apps/runtime/dist/prompts/authoring.md +2 -2
  29. package/apps/runtime/dist/prompts/tools.md +3 -0
  30. package/apps/runtime/dist/routes/api.js +2 -2
  31. package/apps/runtime/dist/routes/elements.js +76 -0
  32. package/apps/runtime/dist/services/work-ai.js +27 -19
  33. package/apps/runtime/dist/services/work-connections.js +2 -2
  34. package/apps/runtime/dist/tools/index.js +5 -4
  35. package/apps/runtime/dist/tools/skills.js +80 -54
  36. package/apps/runtime/dist/tools/space.js +8 -152
  37. package/apps/web/dist/assets/{AboutDialog-SpDcn8VZ.js → AboutDialog-DaWEIHFN.js} +1 -1
  38. package/apps/web/dist/assets/{CapabilitiesPage-Bgnm_3dk.js → CapabilitiesPage-Dt91U_sK.js} +2 -2
  39. package/apps/web/dist/assets/{ChangelogDialog-DAnjV6cZ.js → ChangelogDialog-Do7pwmFv.js} +1 -1
  40. package/apps/web/dist/assets/{CodeEditor-nxoOt8ge.js → CodeEditor-Cdox-51M.js} +1 -1
  41. package/apps/web/dist/assets/{EditorPage-B98C-9Nv.js → EditorPage-DS_a5K3s.js} +1 -1
  42. package/apps/web/dist/assets/{FlowPreview-aMfwcPul.js → FlowPreview-BPS86xzA.js} +1 -1
  43. package/apps/web/dist/assets/{LangSwitch-DpD0inR4.js → LangSwitch-BRHbi_Sd.js} +1 -1
  44. package/apps/web/dist/assets/{Marketplace-CpzD9pNQ.js → Marketplace-CS7JTgiv.js} +2 -2
  45. package/apps/web/dist/assets/{NewWizardChannels-D8IYLg_S.js → NewWizardChannels-D-OLsex6.js} +1 -1
  46. package/apps/web/dist/assets/{NewWizardPage-DlBt0Mfq.js → NewWizardPage-BM_pkk41.js} +1 -1
  47. package/apps/web/dist/assets/{OnboardingPage-ztHT01ah.js → OnboardingPage-Cpn5pubC.js} +1 -1
  48. package/apps/web/dist/assets/{PreviewPane-DC1kAi3x.js → PreviewPane-BOk1-yO4.js} +1 -1
  49. package/apps/web/dist/assets/{PublicRunner-D6lKP0j8.js → PublicRunner-CgzMZb0r.js} +1 -1
  50. package/apps/web/dist/assets/{ReadOnly-DFsuKPCw.js → ReadOnly-8DEx-ly3.js} +1 -1
  51. package/apps/web/dist/assets/{SettingsPage-DkHeCO2c.js → SettingsPage-CcrknFcI.js} +2 -2
  52. package/apps/web/dist/assets/{SetupPage-DZ8xRkfS.js → SetupPage-D5nzjgPU.js} +1 -1
  53. package/apps/web/dist/assets/{SharePage-494ZPsjQ.js → SharePage-PKHX8a8a.js} +1 -1
  54. package/apps/web/dist/assets/{SkillEditor-CqQMg2MC.js → SkillEditor-BsXTqNli.js} +1 -1
  55. package/apps/web/dist/assets/{Skills-CnhpgoOA.js → Skills-C_X1ZsKg.js} +1 -1
  56. package/apps/web/dist/assets/{SpacePage-CWlU_BZP.js → SpacePage-wZGqUoSQ.js} +2 -2
  57. package/apps/web/dist/assets/{UpdateCheck-BKNkNJyG.js → UpdateCheck-D6x7MqEl.js} +2 -2
  58. package/apps/web/dist/assets/changelog-M-eOBqgu.js +1 -0
  59. package/apps/web/dist/assets/{circle-alert-C8Ma-bPY.js → circle-alert-DJbCyxcg.js} +1 -1
  60. package/apps/web/dist/assets/{circle-check-Bu9Z3mlJ.js → circle-check-jqtsKi_b.js} +1 -1
  61. package/apps/web/dist/assets/{code-editor-CfTGqOpp.js → code-editor-BpCEnf8H.js} +2 -2
  62. package/apps/web/dist/assets/{code-xml-B4kLFZSj.js → code-xml-q88cSTV8.js} +1 -1
  63. package/apps/web/dist/assets/{connection-sign-in-Cngd_QDO.js → connection-sign-in-UJ6xk-TD.js} +1 -1
  64. package/apps/web/dist/assets/{eye-BpoKpIdt.js → eye-CgkvVlba.js} +1 -1
  65. package/apps/web/dist/assets/{host-C0WQlRKB.js → host-Bd_bon_c.js} +7 -7
  66. package/apps/web/dist/assets/{i18n-BJ7Ld6O6.js → i18n-0fUKyVRE.js} +1 -1
  67. package/apps/web/dist/assets/{index-ClVtdDUZ.js → index-DOgwxnto.js} +3 -3
  68. package/apps/web/dist/assets/{phone-Ctvf-Am-.js → phone-CjPvZ0nk.js} +1 -1
  69. package/apps/web/dist/assets/{read-aloud-Da_RSm2S.js → read-aloud-CLXo_asN.js} +1 -1
  70. package/apps/web/dist/assets/{runners-CyIvJIHr.js → runners-BoPaPsjN.js} +1 -1
  71. package/apps/web/dist/assets/{scroll-text-ChrjRu9Y.js → scroll-text-2BhJO_W7.js} +1 -1
  72. package/apps/web/dist/assets/{session-SXPtTWRK.js → session-CpYa5hwd.js} +1 -1
  73. package/apps/web/dist/assets/{theme-BCau3f6O.js → theme-Bj3wNQR0.js} +1 -1
  74. package/apps/web/dist/assets/{ui-Uqnx1UpK.js → ui-CktezodE.js} +1 -1
  75. package/apps/web/dist/assets/{upload-BchUnQGV.js → upload-CHGCFVZK.js} +1 -1
  76. package/apps/web/dist/assets/{useMutation-DEkZhp5c.js → useMutation-7_FOHoEl.js} +1 -1
  77. package/apps/web/dist/assets/{volume-2-CU_oy81Z.js → volume-2-Bw5KASy8.js} +1 -1
  78. package/apps/web/dist/index.html +13 -13
  79. package/apps/web/dist/mcp/flow.html +1 -1
  80. package/node_modules/@engenty/wizards-shared/dist/run.d.ts +3 -0
  81. package/node_modules/@engenty/wizards-shared/dist/run.js +6 -0
  82. package/node_modules/@engenty/wizards-shared/dist/rwx.d.ts +1 -1
  83. package/node_modules/@engenty/wizards-shared/dist/rwx.js +3 -0
  84. package/package.json +1 -1
  85. package/plugin/.claude-plugin/plugin.json +1 -1
  86. package/plugin/README.md +3 -0
  87. package/plugin/plugin.json +1 -1
  88. package/plugin/skills/work-in-space/SKILL.md +16 -0
  89. package/apps/web/dist/assets/changelog-BhMZS-rs.js +0 -1
@@ -1,6 +1,9 @@
1
1
  import { skillMd } from "@engenty/wizards-shared/skills";
2
2
  import { createTool } from "@mastra/core/tools";
3
- import { z } from "zod";
3
+ import { readableIds } from "../broker/rwx.js";
4
+ import { stepCaller } from "../elements/caller.js";
5
+ import { elementCall, mayDo } from "../elements/gate.js";
6
+ import { ELEMENT_SPECS } from "../elements/specs.js";
4
7
  import { getBlob } from "../files/blobs.js";
5
8
  import { prompt } from "../prompts.js";
6
9
  import { activeSkills } from "../services/skills.js";
@@ -90,11 +93,15 @@ export function skillsBlock(skills, { tools, sandbox = false }) {
90
93
  }
91
94
  const byName = (skills, name) => [...skills.always, ...skills.demand].find((k) => k.name === name.trim().toLowerCase());
92
95
  /**
93
- * `skill_load` and `skill_read` over the skills that count. `onRead` says what is read, for the
94
- * run's events or Goose's line; none when the space has no skill a model could read. With
95
- * `sandbox`, loading a skill whose scripts may run writes its folder there.
96
+ * `skill_load` and `skill_read` over the skills that count, for the caller of the tool catalogue
97
+ * (elements/): reading a skill is `r` on it, its folder placed in the caller's sandbox for its
98
+ * scripts to run is `x` (docs/plans/modular.md). Each call is a line of the broker's log. None
99
+ * when the space has no skill a model could read.
96
100
  */
97
- export function skillToolsOf(skills, onRead, sandbox = null) {
101
+ export function skillToolsOf(skills, caller) {
102
+ const sandbox = caller.sandbox ?? null;
103
+ const onRead = (name) => caller.note?.({ code: "readsSkill", params: { name } });
104
+ const asSkill = (k) => ({ kind: "skill", id: k.id });
98
105
  const readable = [...skills.always, ...skills.demand];
99
106
  if (!(skills.demand.length || skills.always.some((k) => k.files.length || (sandbox && runnable(k))))) {
100
107
  return {};
@@ -106,6 +113,9 @@ export function skillToolsOf(skills, onRead, sandbox = null) {
106
113
  if (!(sandbox && runnable(k))) {
107
114
  return null;
108
115
  }
116
+ if (!(await mayDo(caller, asSkill(k), "x"))) {
117
+ return { scripts: prompt("tools", "note.skill_scripts_refused") };
118
+ }
109
119
  const folder = `${sandbox.workdir}/${skillFolder(k.name)}`;
110
120
  try {
111
121
  await placeSkill(sandbox.handle(), k);
@@ -120,25 +130,40 @@ export function skillToolsOf(skills, onRead, sandbox = null) {
120
130
  };
121
131
  };
122
132
  return {
133
+ skill_list: createTool({
134
+ id: "skill_list",
135
+ description: ELEMENT_SPECS.skill_list.description(),
136
+ inputSchema: ELEMENT_SPECS.skill_list.input,
137
+ execute: (input) => attempt(() => elementCall(caller, { action: "skill_list", about: "skills", perm: "r", input }, async () => {
138
+ const ok = new Set(await readableIds(caller.space.id, caller.subjects, "skill", readable.map((k) => k.id)));
139
+ return {
140
+ skills: readable
141
+ .filter((k) => ok.has(k.id))
142
+ .map((k) => ({ name: k.name, description: k.description })),
143
+ };
144
+ })),
145
+ }),
123
146
  skill_load: createTool({
124
147
  id: "skill_load",
125
148
  description: prompt("tools", "tool.skill_load", { names }),
126
- inputSchema: z.object({ name: z.string().describe("The skill's name, as listed") }),
127
- execute: ({ name }) => attempt(async () => {
128
- const k = byName(skills, name);
149
+ inputSchema: ELEMENT_SPECS.skill_load.input,
150
+ execute: (input) => attempt(async () => {
151
+ const k = byName(skills, input.name);
129
152
  if (!k) {
130
- return { error: prompt("tools", "note.skill_unknown", { name, names }) };
153
+ return { error: prompt("tools", "note.skill_unknown", { name: input.name, names }) };
131
154
  }
132
- await onRead(k.name);
133
- const placed = await place(k);
134
- // In the sandbox, the files for its scripts are there too.
135
- const files = placed?.folder ? [...k.files, ...k.blobFiles] : k.files;
136
- return {
137
- name: k.name,
138
- instructions: clip(k.body, 60_000),
139
- files: files.map((f) => f.path).sort(),
140
- ...placed,
141
- };
155
+ return elementCall(caller, { action: "skill_load", resource: asSkill(k), perm: "r", input }, async () => {
156
+ await onRead(k.name);
157
+ const placed = await place(k);
158
+ // In the sandbox, the files for its scripts are there too.
159
+ const files = placed?.folder ? [...k.files, ...k.blobFiles] : k.files;
160
+ return {
161
+ name: k.name,
162
+ instructions: clip(k.body, 60_000),
163
+ files: files.map((f) => f.path).sort(),
164
+ ...placed,
165
+ };
166
+ });
142
167
  }),
143
168
  }),
144
169
  skill_read: createTool({
@@ -146,52 +171,53 @@ export function skillToolsOf(skills, onRead, sandbox = null) {
146
171
  description: runs
147
172
  ? prompt("tools", "tool.skill_read")
148
173
  : `${prompt("tools", "tool.skill_read")} ${prompt("tools", "tool.skill_read.text_only")}`,
149
- inputSchema: z.object({
150
- name: z.string().describe("The skill's name"),
151
- path: z.string().describe("The file's path in the skill, e.g. references/forms.md"),
152
- from: z.number().int().min(0).optional().describe("Character to continue a long file at"),
153
- }),
154
- execute: ({ name, path, from }) => attempt(async () => {
174
+ inputSchema: ELEMENT_SPECS.skill_read.input,
175
+ execute: (input) => attempt(async () => {
176
+ const { name, path, from } = input;
155
177
  const k = byName(skills, name);
156
178
  if (!k) {
157
179
  return { error: prompt("tools", "note.skill_unknown", { name, names }) };
158
180
  }
159
- if (path === "SKILL.md") {
160
- return { path, text: clip(skillMd(k), 60_000) };
161
- }
162
- const wanted = path.replace(/^\.?\//, "");
163
- const file = k.files.find((f) => f.path === wanted);
164
- if (!file && k.blobFiles.some((f) => f.path === wanted)) {
165
- return { error: prompt("tools", "note.skill_blob", { path: wanted }) };
166
- }
167
- if (!file) {
168
- return {
169
- error: prompt("tools", "note.skill_no_file", {
170
- path,
171
- skill: k.name,
172
- files: k.files.map((f) => f.path).join(", ") || "none",
173
- }),
174
- };
175
- }
176
- await onRead(`${k.name}/${file.path}`);
177
- const start = from ?? 0;
178
- const part = file.text.slice(start, start + 30_000);
179
- const rest = file.text.length - start - part.length;
180
- return {
181
- path: file.path,
182
- text: part,
183
- ...(rest > 0
184
- ? { more: prompt("tools", "note.skill_more", { rest, from: start + part.length }) }
185
- : {}),
186
- };
181
+ return elementCall(caller, { action: "skill_read", resource: asSkill(k), perm: "r", input }, () => readSkillFile(k, path, from, onRead));
187
182
  }),
188
183
  }),
189
184
  };
190
185
  }
186
+ /** A file of a skill, in parts: `SKILL.md` whole, a text file from `from`. */
187
+ async function readSkillFile(k, path, from, onRead) {
188
+ if (path === "SKILL.md") {
189
+ return { path, text: clip(skillMd(k), 60_000) };
190
+ }
191
+ const wanted = path.replace(/^\.?\//, "");
192
+ const file = k.files.find((f) => f.path === wanted);
193
+ if (!file && k.blobFiles.some((f) => f.path === wanted)) {
194
+ return { error: prompt("tools", "note.skill_blob", { path: wanted }) };
195
+ }
196
+ if (!file) {
197
+ return {
198
+ error: prompt("tools", "note.skill_no_file", {
199
+ path,
200
+ skill: k.name,
201
+ files: k.files.map((f) => f.path).join(", ") || "none",
202
+ }),
203
+ };
204
+ }
205
+ await onRead(`${k.name}/${file.path}`);
206
+ const start = from ?? 0;
207
+ const part = file.text.slice(start, start + 30_000);
208
+ const rest = file.text.length - start - part.length;
209
+ return {
210
+ path: file.path,
211
+ text: part,
212
+ ...(rest > 0
213
+ ? { more: prompt("tools", "note.skill_more", { rest, from: start + part.length }) }
214
+ : {}),
215
+ };
216
+ }
191
217
  /**
192
218
  * The skill tools of an AI step: what it reads goes into the run's events. `sandbox`: the
193
219
  * step's sandbox, where the folders of skills whose scripts may run go.
194
220
  */
195
221
  export async function skillTools(ctx, sandbox = null) {
196
- return skillToolsOf(await skillsOf(ctx), (name) => ctx.emit("tool", { code: "readsSkill", params: { name } }), sandbox);
222
+ return skillToolsOf(await skillsOf(ctx), stepCaller(ctx, sandbox));
197
223
  }
@@ -1,158 +1,14 @@
1
- import { whereSchema } from "@engenty/wizards-shared/knowledge";
2
- import { createTool } from "@mastra/core/tools";
3
- import { and, eq } from "drizzle-orm";
4
- import { z } from "zod";
5
- import { assertRwx, subjectsOf } from "../broker/rwx.js";
6
- import { db, schema } from "../db/client.js";
7
- import { prompt } from "../prompts.js";
8
- import { filePaths, knowledgeCounts, listForStep, readPage, readTable, resolvePath, } from "../services/knowledge.js";
9
- import { documentText, hasIndexEntries, searchKnowledge } from "../services/space-index.js";
10
- import { attempt, clip } from "./shared.js";
1
+ import { stepCaller } from "../elements/caller.js";
2
+ import { knowledgeTools, readKnowledgePage as readPageAs } from "../elements/knowledge.js";
11
3
  /**
12
- * Knowledge, for every agent step of the space's wizards: search it (a question, filtered by
13
- * categories first, checked by a classifier after), list it by categories, read a page, a table
14
- * or a file whole by its path. Hits and reads look like files — a path, front matter, Markdown or
15
- * CSV — so a model reads them as it reads files. The search also finds what the space's plugins
16
- * put into the index. Every read is the run's: its holder and its wizard ask the broker
17
- * (broker/rwx.ts) before anything is handed out.
4
+ * Knowledge, for every agent step of the space's wizards: the catalogue's Knowledge tools
5
+ * (elements/knowledge.ts) for the run's holder and its wizard.
18
6
  */
19
- const where = whereSchema.optional().describe(prompt("tools", "tool.space.where"));
20
- export const pageReadInput = {
21
- path: z.string().describe("The page's path, as space_search or space_list give it: pages/…"),
22
- section: z
23
- .string()
24
- .optional()
25
- .describe("Only this section: a heading of the page, or the start of one"),
26
- from: z.number().int().min(0).optional().describe("Character to continue a long page at"),
27
- };
7
+ export { pageReadInput } from "../elements/specs.js";
28
8
  /** A page of Knowledge by its path, for a step: its front matter and Markdown, in parts. */
29
9
  export function readKnowledgePage(ctx, input) {
30
- return attempt(async () => {
31
- const read = await readPage(ctx.space.id, input.path, input, subjectsOf(ctx));
32
- await ctx.emit("tool", { code: "reads", params: { name: read.path } });
33
- return read;
34
- });
10
+ return readPageAs(stepCaller(ctx), input);
35
11
  }
36
- export async function spaceTools(ctx) {
37
- const spaceId = ctx.space.id;
38
- const who = subjectsOf(ctx);
39
- const counts = await knowledgeCounts(spaceId);
40
- const entries = await hasIndexEntries(spaceId);
41
- if (!(counts.pages || counts.tables || counts.files || entries)) {
42
- return {};
43
- }
44
- const tools = {
45
- space_search: createTool({
46
- id: "space_search",
47
- description: prompt("tools", "tool.space_search"),
48
- inputSchema: z.object({
49
- query: z.string().describe("What to look for: a question or keywords"),
50
- where,
51
- limit: z.number().int().min(1).max(12).optional().describe("Items to get, 6 by default"),
52
- }),
53
- execute: (input) => attempt(async () => {
54
- const found = await searchKnowledge(spaceId, input.query, {
55
- where: input.where,
56
- limit: input.limit,
57
- signal: ctx.signal,
58
- who,
59
- });
60
- await ctx.emit("tool", {
61
- code: "searchesKnowledge",
62
- params: {
63
- query: input.query.slice(0, 60),
64
- relevant: found.hits.length,
65
- candidates: found.candidates,
66
- },
67
- });
68
- return {
69
- hits: found.hits.map((h) => ({
70
- ...(h.path ? { path: h.path } : {}),
71
- title: h.title,
72
- ...(h.categories.length ? { categories: h.categories } : {}),
73
- ...(h.heading ? { section: h.heading } : {}),
74
- ...(h.sheet ? { page: h.sheet } : {}),
75
- ...(h.relevance !== null ? { relevance: h.relevance } : {}),
76
- text: clip(h.text, 1500),
77
- })),
78
- checked: found.checked,
79
- candidates: found.candidates,
80
- ...(found.filtered !== null ? { filtered: found.filtered } : {}),
81
- };
82
- }),
83
- }),
84
- space_list: createTool({
85
- id: "space_list",
86
- description: prompt("tools", "tool.space_list"),
87
- inputSchema: z.object({ where }),
88
- execute: (input) => attempt(async () => {
89
- const listed = await listForStep(spaceId, input.where, who);
90
- await ctx.emit("tool", { code: "listsKnowledge" });
91
- return listed;
92
- }),
93
- }),
94
- };
95
- if (counts.pages) {
96
- tools.page_read = createTool({
97
- id: "page_read",
98
- description: prompt("tools", "tool.page_read.knowledge"),
99
- inputSchema: z.object(pageReadInput),
100
- execute: (input) => readKnowledgePage(ctx, input),
101
- });
102
- }
103
- if (counts.tables) {
104
- tools.table_read = createTool({
105
- id: "table_read",
106
- description: prompt("tools", "tool.table_read"),
107
- inputSchema: z.object({
108
- path: z.string().describe("The table's path: tables/…"),
109
- where: whereSchema.optional().describe("Filter by columns, by their names"),
110
- columns: z.array(z.string()).max(40).optional().describe("Only these columns"),
111
- limit: z.number().int().min(1).max(1000).optional(),
112
- offset: z.number().int().min(0).optional(),
113
- }),
114
- execute: (input) => attempt(async () => {
115
- const read = await readTable(spaceId, input.path, input, who);
116
- await ctx.emit("tool", { code: "reads", params: { name: read.path } });
117
- return read;
118
- }),
119
- });
120
- }
121
- if (counts.files) {
122
- tools.space_document = createTool({
123
- id: "space_document",
124
- description: prompt("tools", "tool.space_document"),
125
- inputSchema: z.object({
126
- path: z
127
- .string()
128
- .describe("The file's path: files/…, as the page's front matter or a hit names it"),
129
- from: z.number().int().min(0).optional().describe("Character to start at"),
130
- }),
131
- execute: ({ path, from }) => attempt(async () => {
132
- const found = await resolvePath(spaceId, path.startsWith("files/") ? path : `files/${path}`);
133
- if (found?.kind !== "file") {
134
- const there = [...(await filePaths(spaceId)).values()].slice(0, 40);
135
- throw new Error(`No file "${path}". There are: ${there.join(", ")}`);
136
- }
137
- const file = await db.query.spaceFile.findFirst({
138
- where: and(eq(schema.spaceFile.id, found.id), eq(schema.spaceFile.spaceId, spaceId)),
139
- });
140
- if (!file) {
141
- throw new Error(`No file "${path}".`);
142
- }
143
- await assertRwx(spaceId, who, { kind: "document", id: file.id }, "r");
144
- await ctx.emit("tool", { code: "reads", params: { name: file.name } });
145
- const text = (await documentText(file)) || file.description;
146
- const start = Math.min(from ?? 0, text.length);
147
- const part = text.slice(start, start + 12_000);
148
- return {
149
- path: found.path,
150
- text: clip(part, 12_000),
151
- next: start + part.length < text.length ? start + part.length : null,
152
- length: text.length,
153
- };
154
- }),
155
- });
156
- }
157
- return tools;
12
+ export function spaceTools(ctx) {
13
+ return knowledgeTools(stepCaller(ctx));
158
14
  }
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{Hn as r,Qt as i,Xn as a,Xt as o,Yt as s,Zt as c,cn as l,ln as u,on as d,rn as f}from"./ui-Uqnx1UpK.js";import{t as p}from"./preload-helper-DpV6A1kQ.js";import{t as m}from"./logo-BpnjXTRy.js";import{s as h}from"./i18n-BJ7Ld6O6.js";import{g,h as _,m as v,t as y,u as b}from"./UpdateCheck-BKNkNJyG.js";import{ReleaseNotes as x,loadReleases as S,releaseDate as C,releaseLabel as w}from"./ChangelogDialog-DAnjV6cZ.js";var T=e(t(),1),E=[{name:`engenty wizards`,description:`credit.engenty-wizards`,homepage:`https://github.com/engenty/wizards`,license:`FSL-1.1-MIT`},{name:`engenty`,description:`credit.engenty`,homepage:`https://github.com/engenty/engenty`,license:`FSL-1.1-MIT`}],D=[{name:`Mastra`,description:`credit.mastra`,homepage:`https://github.com/mastra-ai/mastra`,license:`Apache-2.0`},{name:`AI SDK`,description:`credit.ai-sdk`,homepage:`https://github.com/vercel/ai`,license:`Apache-2.0`},{name:`Model Context Protocol`,description:`credit.model-context-protocol`,homepage:`https://github.com/modelcontextprotocol/typescript-sdk`,license:`MIT`},{name:`Hono`,description:`credit.hono`,homepage:`https://github.com/honojs/hono`,license:`MIT`},{name:`Drizzle ORM`,description:`credit.drizzle-orm`,homepage:`https://github.com/drizzle-team/drizzle-orm`,license:`Apache-2.0`},{name:`libSQL`,description:`credit.libsql`,homepage:`https://github.com/tursodatabase/libsql`,license:`MIT`},{name:`Playwright`,description:`credit.playwright`,homepage:`https://github.com/microsoft/playwright`,license:`Apache-2.0`},{name:`React`,description:`credit.react`,homepage:`https://github.com/facebook/react`,license:`MIT`},{name:`Vite`,description:`credit.vite`,homepage:`https://github.com/vitejs/vite`,license:`MIT`},{name:`Tailwind CSS`,description:`credit.tailwind-css`,homepage:`https://github.com/tailwindlabs/tailwindcss`,license:`MIT`},{name:`React Flow`,description:`credit.react-flow`,homepage:`https://github.com/xyflow/xyflow`,license:`MIT`},{name:`TanStack Query`,description:`credit.tanstack-query`,homepage:`https://github.com/TanStack/query`,license:`MIT`},{name:`xterm.js`,description:`credit.xterm-js`,homepage:`https://github.com/xtermjs/xterm.js`,license:`MIT`},{name:`Lucide`,description:`credit.lucide`,homepage:`https://github.com/lucide-icons/lucide`,license:`ISC`},{name:`Geist & Geist Mono`,description:`credit.geist-geist-mono`,homepage:`https://github.com/vercel/geist-font`,license:`OFL-1.1`},{name:`Space Grotesk`,description:`credit.space-grotesk`,homepage:`https://github.com/floriankarsten/space-grotesk`,license:`OFL-1.1`},{name:`git-cliff`,description:`credit.git-cliff`,homepage:`https://github.com/orhun/git-cliff`,license:`MIT OR Apache-2.0`}],O=e(n(),1),k=(e,...t)=>t.some(t=>t?.toLowerCase().includes(e));function A({name:e,homepage:t,version:n,license:i,description:a}){return(0,O.jsxs)(`li`,{className:`py-2.5`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2.5 gap-y-0.5`,children:[t?(0,O.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 font-medium text-[0.875rem] text-ink underline-offset-4 hover:underline`,children:[e,(0,O.jsx)(r,{"aria-hidden":!0,className:`size-3 text-ink-4`})]}):(0,O.jsx)(`span`,{className:`font-medium text-[0.875rem] text-ink`,children:e}),n?(0,O.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:n}):null,(0,O.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:i})]}),a?(0,O.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-3`,children:a}):null]})}function j({title:e,hint:t,children:n}){return(0,O.jsxs)(`section`,{className:`mt-6`,children:[(0,O.jsx)(`h3`,{className:`border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:e}),t?(0,O.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-ink-3`,children:t}):null,n]})}function M({credits:e}){return(0,O.jsx)(`ul`,{className:`divide-y divide-border-soft`,children:e.map(e=>(0,O.jsx)(A,{name:e.name,homepage:e.homepage,license:e.license,description:h(e.description)},e.name))})}function N({label:e,packages:t}){return(0,O.jsxs)(`div`,{className:`mt-4`,children:[(0,O.jsx)(`h4`,{className:`font-medium text-[0.75rem] text-ink-3 tracking-wide`,children:e}),(0,O.jsx)(`ul`,{className:`divide-y divide-border-soft`,children:t.map(e=>(0,O.jsx)(A,{...e},e.name))})]})}function P({active:e}){let[t,n]=(0,T.useState)(null),[r,a]=(0,T.useState)(``);(0,T.useEffect)(()=>{if(!e||t)return;let r=!1;return p(()=>import(`./oss-credits-IdX5bc71.js`).then(e=>{r||n(e.default)}),[]),()=>{r=!0}},[e,t]),(0,T.useEffect)(()=>{e||a(``)},[e]);let s=r.trim().toLowerCase(),c=e=>s?e.filter(e=>k(s,e.name,e.license,h(e.description))):e,l=e=>s?e.filter(e=>k(s,e.name,e.license,e.version)):e,u=c(E),d=c(D),m=t?[{id:`shared`,label:h(`about.creditsShared`),packages:l(t.shared)},...t.groups.map(e=>({id:e.id,label:e.label,packages:l(e.packages)}))].filter(e=>e.packages.length>0):[],g=u.length===0&&d.length===0&&m.length===0;return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`p`,{className:`mb-4 text-[0.875rem] text-ink-3`,children:h(`about.creditsHint`)}),(0,O.jsx)(i,{type:`search`,value:r,placeholder:h(`about.search`),onChange:e=>a(e.target.value)}),u.length>0?(0,O.jsx)(j,{title:h(`about.creditsProduct`),children:(0,O.jsx)(M,{credits:u})}):null,d.length>0?(0,O.jsx)(j,{title:h(`about.creditsBuiltWith`),children:(0,O.jsx)(M,{credits:d})}):null,t===null?(0,O.jsx)(`div`,{className:`flex justify-center py-10 text-ink-3`,children:(0,O.jsx)(f,{})}):m.length>0?(0,O.jsx)(j,{title:h(`about.creditsDeps`),hint:s?void 0:h(`about.creditsDepsHint`),children:m.map(e=>(0,O.jsx)(N,{label:e.label,packages:e.packages},e.id))}):null,t!==null&&g?(0,O.jsx)(o,{children:h(`about.noMatches`)}):null]})}var F=[`new`,`earlier`,`credits`],I=e=>h(e===`new`?`about.tab.new`:e===`earlier`?`about.tab.earlier`:`about.credits`),L=e=>e===1?h(`about.change`):h(`about.changes`,{n:e});function R({me:e,active:t,initialTab:n=`new`}){let r=e?.mode===`local`,{data:i,latest:o}=_(r&&t),[s,c]=(0,T.useState)(null),[u,p]=(0,T.useState)(n);(0,T.useEffect)(()=>p(n),[n]);let E=v(F.indexOf(u)),D=i?.newer&&o?o:g;(0,T.useEffect)(()=>{if(!t)return;let e=!1;return c(null),S(D===`0.14.1`?void 0:D).then(t=>{e||c(t)}),()=>{e=!0}},[t,D]);let k=s?.find(e=>e.version===`v${D}`)??s?.[0]??null,A=s?.filter(e=>e!==k)??[],j=r?i?.kind??null:`cloud`;return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`flex flex-col items-center pt-4 text-center`,children:[(0,O.jsx)(m,{size:96}),(0,O.jsxs)(`div`,{className:`mt-4 font-display font-semibold text-[1.5rem] tracking-tight`,children:[`engenty`,(0,O.jsx)(`span`,{className:`text-ember`,children:`.`}),(0,O.jsx)(`span`,{className:`ml-1.5 font-normal text-ink-3`,children:`wizards`})]}),(0,O.jsxs)(`div`,{className:`mt-1 text-[0.9375rem] text-ink-3 tabular-nums`,children:[h(`about.version`,{v:g}),j?` · ${h(`about.kind.${j}`)}`:``]})]}),r?(0,O.jsx)(`div`,{className:`mt-5`,children:(0,O.jsx)(y,{enabled:t})}):null,(0,O.jsx)(`div`,{className:`mt-6 flex justify-center`,children:(0,O.jsx)(d,{value:u,onChange:p,options:F.map(e=>({id:e,label:I(e)})),label:h(`about.title`)})}),(0,O.jsxs)(`div`,{className:l(`mt-5`,b(E)),children:[u===`new`?s===null?(0,O.jsx)(`div`,{className:`flex justify-center py-6 text-ink-3`,children:(0,O.jsx)(f,{})}):k?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`h3`,{className:`flex items-baseline gap-3 border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:[w(k),(0,O.jsx)(`span`,{className:`font-normal font-sans text-[0.8125rem] text-ink-3 tabular-nums`,children:C(k)})]}),(0,O.jsx)(`div`,{className:`mt-3`,children:(0,O.jsx)(x,{release:k})})]}):(0,O.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:h(`about.changelogEmpty`)}):null,u===`earlier`?(0,O.jsx)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:A.map(e=>(0,O.jsxs)(`details`,{className:`group/r py-2`,children:[(0,O.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-baseline gap-3 text-[0.875rem] [&::-webkit-details-marker]:hidden`,children:[(0,O.jsx)(a,{className:`size-3.5 shrink-0 self-center text-ink-4 transition group-open/r:rotate-90`}),(0,O.jsx)(`span`,{className:`font-medium text-ink tabular-nums`,children:w(e)}),(0,O.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:C(e)}),(0,O.jsx)(`span`,{className:`ml-auto text-[0.8125rem] text-ink-4`,children:L(e.commits.length)})]}),(0,O.jsx)(`div`,{className:`mt-2 pl-6`,children:(0,O.jsx)(x,{release:e})})]},e.version??`unreleased`))}):null,u===`credits`?(0,O.jsx)(P,{active:!0}):null]},u)]})}function z({open:e,onClose:t,me:n}){return(0,O.jsxs)(s,{open:e,onClose:t,wide:!0,height:`tall`,children:[(0,O.jsx)(`div`,{className:`-mt-2 -mr-2 sticky top-0 z-10 flex h-0 justify-end`,children:(0,O.jsx)(c,{label:h(`common.close`),onClick:t,children:(0,O.jsx)(u,{className:`size-4`})})}),(0,O.jsx)(R,{me:n,active:e})]})}export{z as AboutDialog,R as AboutPanel};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{Hn as r,Qt as i,Xn as a,Xt as o,Yt as s,Zt as c,cn as l,ln as u,on as d,rn as f}from"./ui-CktezodE.js";import{t as p}from"./preload-helper-DpV6A1kQ.js";import{t as m}from"./logo-BpnjXTRy.js";import{s as h}from"./i18n-0fUKyVRE.js";import{g,h as _,m as v,t as y,u as b}from"./UpdateCheck-D6x7MqEl.js";import{ReleaseNotes as x,loadReleases as S,releaseDate as C,releaseLabel as w}from"./ChangelogDialog-Do7pwmFv.js";var T=e(t(),1),E=[{name:`engenty wizards`,description:`credit.engenty-wizards`,homepage:`https://github.com/engenty/wizards`,license:`FSL-1.1-MIT`},{name:`engenty`,description:`credit.engenty`,homepage:`https://github.com/engenty/engenty`,license:`FSL-1.1-MIT`}],D=[{name:`Mastra`,description:`credit.mastra`,homepage:`https://github.com/mastra-ai/mastra`,license:`Apache-2.0`},{name:`AI SDK`,description:`credit.ai-sdk`,homepage:`https://github.com/vercel/ai`,license:`Apache-2.0`},{name:`Model Context Protocol`,description:`credit.model-context-protocol`,homepage:`https://github.com/modelcontextprotocol/typescript-sdk`,license:`MIT`},{name:`Hono`,description:`credit.hono`,homepage:`https://github.com/honojs/hono`,license:`MIT`},{name:`Drizzle ORM`,description:`credit.drizzle-orm`,homepage:`https://github.com/drizzle-team/drizzle-orm`,license:`Apache-2.0`},{name:`libSQL`,description:`credit.libsql`,homepage:`https://github.com/tursodatabase/libsql`,license:`MIT`},{name:`Playwright`,description:`credit.playwright`,homepage:`https://github.com/microsoft/playwright`,license:`Apache-2.0`},{name:`React`,description:`credit.react`,homepage:`https://github.com/facebook/react`,license:`MIT`},{name:`Vite`,description:`credit.vite`,homepage:`https://github.com/vitejs/vite`,license:`MIT`},{name:`Tailwind CSS`,description:`credit.tailwind-css`,homepage:`https://github.com/tailwindlabs/tailwindcss`,license:`MIT`},{name:`React Flow`,description:`credit.react-flow`,homepage:`https://github.com/xyflow/xyflow`,license:`MIT`},{name:`TanStack Query`,description:`credit.tanstack-query`,homepage:`https://github.com/TanStack/query`,license:`MIT`},{name:`xterm.js`,description:`credit.xterm-js`,homepage:`https://github.com/xtermjs/xterm.js`,license:`MIT`},{name:`Lucide`,description:`credit.lucide`,homepage:`https://github.com/lucide-icons/lucide`,license:`ISC`},{name:`Geist & Geist Mono`,description:`credit.geist-geist-mono`,homepage:`https://github.com/vercel/geist-font`,license:`OFL-1.1`},{name:`Space Grotesk`,description:`credit.space-grotesk`,homepage:`https://github.com/floriankarsten/space-grotesk`,license:`OFL-1.1`},{name:`git-cliff`,description:`credit.git-cliff`,homepage:`https://github.com/orhun/git-cliff`,license:`MIT OR Apache-2.0`}],O=e(n(),1),k=(e,...t)=>t.some(t=>t?.toLowerCase().includes(e));function A({name:e,homepage:t,version:n,license:i,description:a}){return(0,O.jsxs)(`li`,{className:`py-2.5`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2.5 gap-y-0.5`,children:[t?(0,O.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 font-medium text-[0.875rem] text-ink underline-offset-4 hover:underline`,children:[e,(0,O.jsx)(r,{"aria-hidden":!0,className:`size-3 text-ink-4`})]}):(0,O.jsx)(`span`,{className:`font-medium text-[0.875rem] text-ink`,children:e}),n?(0,O.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:n}):null,(0,O.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:i})]}),a?(0,O.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-3`,children:a}):null]})}function j({title:e,hint:t,children:n}){return(0,O.jsxs)(`section`,{className:`mt-6`,children:[(0,O.jsx)(`h3`,{className:`border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:e}),t?(0,O.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-ink-3`,children:t}):null,n]})}function M({credits:e}){return(0,O.jsx)(`ul`,{className:`divide-y divide-border-soft`,children:e.map(e=>(0,O.jsx)(A,{name:e.name,homepage:e.homepage,license:e.license,description:h(e.description)},e.name))})}function N({label:e,packages:t}){return(0,O.jsxs)(`div`,{className:`mt-4`,children:[(0,O.jsx)(`h4`,{className:`font-medium text-[0.75rem] text-ink-3 tracking-wide`,children:e}),(0,O.jsx)(`ul`,{className:`divide-y divide-border-soft`,children:t.map(e=>(0,O.jsx)(A,{...e},e.name))})]})}function P({active:e}){let[t,n]=(0,T.useState)(null),[r,a]=(0,T.useState)(``);(0,T.useEffect)(()=>{if(!e||t)return;let r=!1;return p(()=>import(`./oss-credits-IdX5bc71.js`).then(e=>{r||n(e.default)}),[]),()=>{r=!0}},[e,t]),(0,T.useEffect)(()=>{e||a(``)},[e]);let s=r.trim().toLowerCase(),c=e=>s?e.filter(e=>k(s,e.name,e.license,h(e.description))):e,l=e=>s?e.filter(e=>k(s,e.name,e.license,e.version)):e,u=c(E),d=c(D),m=t?[{id:`shared`,label:h(`about.creditsShared`),packages:l(t.shared)},...t.groups.map(e=>({id:e.id,label:e.label,packages:l(e.packages)}))].filter(e=>e.packages.length>0):[],g=u.length===0&&d.length===0&&m.length===0;return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`p`,{className:`mb-4 text-[0.875rem] text-ink-3`,children:h(`about.creditsHint`)}),(0,O.jsx)(i,{type:`search`,value:r,placeholder:h(`about.search`),onChange:e=>a(e.target.value)}),u.length>0?(0,O.jsx)(j,{title:h(`about.creditsProduct`),children:(0,O.jsx)(M,{credits:u})}):null,d.length>0?(0,O.jsx)(j,{title:h(`about.creditsBuiltWith`),children:(0,O.jsx)(M,{credits:d})}):null,t===null?(0,O.jsx)(`div`,{className:`flex justify-center py-10 text-ink-3`,children:(0,O.jsx)(f,{})}):m.length>0?(0,O.jsx)(j,{title:h(`about.creditsDeps`),hint:s?void 0:h(`about.creditsDepsHint`),children:m.map(e=>(0,O.jsx)(N,{label:e.label,packages:e.packages},e.id))}):null,t!==null&&g?(0,O.jsx)(o,{children:h(`about.noMatches`)}):null]})}var F=[`new`,`earlier`,`credits`],I=e=>h(e===`new`?`about.tab.new`:e===`earlier`?`about.tab.earlier`:`about.credits`),L=e=>e===1?h(`about.change`):h(`about.changes`,{n:e});function R({me:e,active:t,initialTab:n=`new`}){let r=e?.mode===`local`,{data:i,latest:o}=_(r&&t),[s,c]=(0,T.useState)(null),[u,p]=(0,T.useState)(n);(0,T.useEffect)(()=>p(n),[n]);let E=v(F.indexOf(u)),D=i?.newer&&o?o:g;(0,T.useEffect)(()=>{if(!t)return;let e=!1;return c(null),S(D===`0.15.0`?void 0:D).then(t=>{e||c(t)}),()=>{e=!0}},[t,D]);let k=s?.find(e=>e.version===`v${D}`)??s?.[0]??null,A=s?.filter(e=>e!==k)??[],j=r?i?.kind??null:`cloud`;return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`flex flex-col items-center pt-4 text-center`,children:[(0,O.jsx)(m,{size:96}),(0,O.jsxs)(`div`,{className:`mt-4 font-display font-semibold text-[1.5rem] tracking-tight`,children:[`engenty`,(0,O.jsx)(`span`,{className:`text-ember`,children:`.`}),(0,O.jsx)(`span`,{className:`ml-1.5 font-normal text-ink-3`,children:`wizards`})]}),(0,O.jsxs)(`div`,{className:`mt-1 text-[0.9375rem] text-ink-3 tabular-nums`,children:[h(`about.version`,{v:g}),j?` · ${h(`about.kind.${j}`)}`:``]})]}),r?(0,O.jsx)(`div`,{className:`mt-5`,children:(0,O.jsx)(y,{enabled:t})}):null,(0,O.jsx)(`div`,{className:`mt-6 flex justify-center`,children:(0,O.jsx)(d,{value:u,onChange:p,options:F.map(e=>({id:e,label:I(e)})),label:h(`about.title`)})}),(0,O.jsxs)(`div`,{className:l(`mt-5`,b(E)),children:[u===`new`?s===null?(0,O.jsx)(`div`,{className:`flex justify-center py-6 text-ink-3`,children:(0,O.jsx)(f,{})}):k?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`h3`,{className:`flex items-baseline gap-3 border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:[w(k),(0,O.jsx)(`span`,{className:`font-normal font-sans text-[0.8125rem] text-ink-3 tabular-nums`,children:C(k)})]}),(0,O.jsx)(`div`,{className:`mt-3`,children:(0,O.jsx)(x,{release:k})})]}):(0,O.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:h(`about.changelogEmpty`)}):null,u===`earlier`?(0,O.jsx)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:A.map(e=>(0,O.jsxs)(`details`,{className:`group/r py-2`,children:[(0,O.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-baseline gap-3 text-[0.875rem] [&::-webkit-details-marker]:hidden`,children:[(0,O.jsx)(a,{className:`size-3.5 shrink-0 self-center text-ink-4 transition group-open/r:rotate-90`}),(0,O.jsx)(`span`,{className:`font-medium text-ink tabular-nums`,children:w(e)}),(0,O.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:C(e)}),(0,O.jsx)(`span`,{className:`ml-auto text-[0.8125rem] text-ink-4`,children:L(e.commits.length)})]}),(0,O.jsx)(`div`,{className:`mt-2 pl-6`,children:(0,O.jsx)(x,{release:e})})]},e.version??`unreleased`))}):null,u===`credits`?(0,O.jsx)(P,{active:!0}):null]},u)]})}function z({open:e,onClose:t,me:n}){return(0,O.jsxs)(s,{open:e,onClose:t,wide:!0,height:`tall`,children:[(0,O.jsx)(`div`,{className:`-mt-2 -mr-2 sticky top-0 z-10 flex h-0 justify-end`,children:(0,O.jsx)(c,{label:h(`common.close`),onClick:t,children:(0,O.jsx)(u,{className:`size-4`})})}),(0,O.jsx)(R,{me:n,active:e})]})}export{z as AboutDialog,R as AboutPanel};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SkillEditor-CqQMg2MC.js","assets/rolldown-runtime-hePW80VL.js","assets/jsx-runtime-BNakU3Ej.js","assets/ui-Uqnx1UpK.js","assets/preload-helper-DpV6A1kQ.js","assets/i18n-BJ7Ld6O6.js","assets/useMutation-DEkZhp5c.js","assets/Skills-CnhpgoOA.js","assets/circle-check-Bu9Z3mlJ.js","assets/upload-BchUnQGV.js","assets/code-xml-B4kLFZSj.js","assets/scroll-text-ChrjRu9Y.js","assets/eye-BpoKpIdt.js","assets/code-editor-CfTGqOpp.js","assets/dist-EBVTpvRr.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$n as r,$t as i,G as a,Jt as o,Kt as s,Qn as c,Qt as l,Wr as u,Xn as d,Xt as f,Yt as p,_r as m,b as h,bn as g,cn as _,dr as v,fr as y,gr as b,lr as x,m as S,nn as C,on as w,q as T,qt as E,rn as D,sr as O,vn as k,vr as A,wn as j,yr as M}from"./ui-Uqnx1UpK.js";import{t as N}from"./useMutation-DEkZhp5c.js";import{t as P}from"./preload-helper-DpV6A1kQ.js";import{Lt as F,Nt as I,Pt as ee,Qt as te,Rt as ne,a as re,l as ie,m as ae,p as L,t as oe,un as se}from"./host-C0WQlRKB.js";import{a as ce,f as le,o as ue,r as de,s as R}from"./Skills-CnhpgoOA.js";import{n as z}from"./volume-2-CU_oy81Z.js";import{i as B,n as V,o as fe,r as pe,s as me,t as H}from"./connection-sign-in-Cngd_QDO.js";import{t as U}from"./scroll-text-ChrjRu9Y.js";import{b as he,d as W,n as ge,u as G}from"./session-SXPtTWRK.js";import{n as K,s as q}from"./i18n-BJ7Ld6O6.js";import{a as _e,c as ve,d as ye,f as be,i as xe,m as Se,p as Ce,r as we,u as Te}from"./UpdateCheck-BKNkNJyG.js";var Ee={name:`compass`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z`,key:`9ktpf1`}]]};Ee.node;var De=O(Ee),J=e(t(),1),Oe=[`admins`,`members`,`all`],ke=[`read`,`write`,`destructive`,`send`],Ae=[`allow`,`ask`,`deny`],je={name:80,perSpace:200},Y=e(n(),1),X=e=>[`space-connections`,e];function Me(e){return M({enabled:!!e,queryKey:X(e),queryFn:()=>T.get(`/api/studio/spaces/${e}/connections`)})}function Ne(e){return M({enabled:!!e,queryKey:a.connectors(e),queryFn:()=>T.get(`/api/studio/spaces/${e}/connectors`)})}function Pe(e,t,n){let r=new Set(t.map(e=>e.connectorId));return e.filter(e=>e.sourceKind===`builtin`&&!r.has(e.id)&&(e.usable||n))}var Z={admins:`connection.audience.admins`,members:`connection.audience.members`,all:`connection.audience.all`},Fe={admins:`connection.audience.adminsHint`,members:`connection.audience.membersHint`,all:`connection.audience.allHint`},Ie={read:`connection.kind.read`,write:`connection.kind.write`,destructive:`connection.kind.destructive`,send:`connection.kind.send`},Le={read:`connection.kind.readHint`,write:`connection.kind.writeHint`,destructive:`connection.kind.destructiveHint`,send:`connection.kind.sendHint`},Re={allow:`connection.outcome.allow`,ask:`connection.outcome.ask`,deny:`connection.outcome.deny`},ze={space:`connection.signIn.space`,person:`connection.signIn.person`},Be={space:`connection.signIn.spaceHint`,person:`connection.signIn.personHint`},Ve=e=>new Intl.DateTimeFormat(K,{dateStyle:`medium`}).format(new Date(e));function He(e){let t=Math.round((Date.parse(e)-Date.now())/1e3),n=new Intl.RelativeTimeFormat(K,{numeric:`auto`});for(let[e,r]of[[`day`,86400],[`hour`,3600],[`minute`,60]])if(Math.abs(t)>=r)return n.format(Math.round(t/r),e);return n.format(0,`minute`)}function Q(e){let t=e.connector?.name??e.connectorId;return e.name===t?e.name:`${t} · ${e.name}`}function Ue(e){return e.signIn===`space`?e.account?q(`connection.asSpaceAccount`,{label:e.account.label}):q(`connection.asSpaceNotYet`):q(`connection.eachPersonCount`,{n:e.signedIn})}function We(e){return e.lastUsedAt?q(`connection.lastUsed`,{when:He(e.lastUsedAt)}):q(`connection.neverUsed`)}function Ge(e){let t=e.toLowerCase().replace(/^https?:\/\//,``).split(`/`)[0].split(`.`);return t.length>1?t[t.length-2]:t[0]}function Ke(e,t){if(!e)return null;let n=t.find(t=>t.id===e);if(n)return{connectorId:n.id};let r=t.find(t=>t.domain&&t.domain===e.toLowerCase());if(r)return{connectorId:r.id};let i=Ge(e),a=t.find(e=>e.sourceKind===`builtin`&&(e.id===i||e.id.endsWith(`-${i}`)||e.name.toLowerCase()===i));return a?{connectorId:a.id}:e.includes(`.`)?{domain:e}:null}function qe({name:e,large:t}){return(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:_(`flex shrink-0 items-center justify-center rounded-lg bg-paper-2 font-semibold text-ink-2`,t?`size-12 text-[0.9375rem]`:`size-9 text-[0.75rem]`),children:ge(e)||`?`})}function Je(){let[e,t]=v(),{space:n}=G(),r=W(),{narrow:i}=Ce(),a=u(),o=n?.id??``,s=e.get(`show`),c=e.get(`setup`),l=r&&!n?.readOnly,d=Me(o),f=Ne(o),p=d.data?.connections??[],m=p.find(e=>e.id===s)??null;ye(m?Q(m):null),pe((0,J.useCallback)(()=>{a.invalidateQueries({queryKey:[`space-connections`]}),a.invalidateQueries({queryKey:[`person-sign-ins`]})},[a])),(0,J.useEffect)(()=>{i||L().scrollTo({top:0})},[i,s]);let h=e=>i?t({show:e}):t(e===`all`?{}:{show:e},{replace:!0});return(0,Y.jsx)(Y.Fragment,{children:n?(0,Y.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:m?(0,Y.jsx)(Qe,{connection:m,connector:f.data?.find(e=>e.id===m.connectorId),writable:l,onGone:()=>h(`all`)},m.id):(0,Y.jsx)(Ye,{spaceId:n.id,connections:p,loading:d.isPending,error:d.error,connectors:f.data??[],writable:l,setup:c,onOpen:h,onSetUp:e=>{t({setup:e},{replace:!i}),i||L().scrollTo({top:0,behavior:`smooth`})},onSetUpDone:()=>t({},{replace:!0})})}):null})}function Ye({spaceId:e,connections:t,loading:n,error:r,connectors:i,writable:a,setup:o,onOpen:c,onSetUp:l,onSetUpDone:u}){let d=I(`unsetConnectors`),p=(0,J.useRef)(null),m=o&&i.length?Ke(o,i):null,g=m&&`domain`in m?m.domain:null;(0,J.useEffect)(()=>{g&&p.current?.scrollIntoView({block:`start`,behavior:`smooth`})},[g]);let v=Pe(i,t,d);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(h,{title:q(`capabilities.connectors`),hint:q(`capabilities.connectors.hint`),plain:!0,action:a&&o===null?(0,Y.jsxs)(s,{size:`sm`,onClick:()=>l(``),children:[(0,Y.jsx)(j,{className:`size-4`}),` `,q(`capabilities.connectors.add`)]}):null,children:[a&&o!==null?(0,Y.jsx)(Ze,{spaceId:e,connectors:i,initial:m&&`connectorId`in m?m.connectorId:``,onCancel:u,onDone:c},m&&`connectorId`in m?m.connectorId:`new`):null,(0,Y.jsx)(`h3`,{className:`px-1 pt-2 font-display font-semibold text-base`,children:q(`capabilities.inSpace`)}),r?(0,Y.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:r.message}):t.length?(0,Y.jsx)(E,{className:`flex flex-col divide-y divide-border-soft p-0`,children:t.map(e=>(0,Y.jsx)(Xe,{connection:e,onOpen:()=>c(e.id)},e.id))}):n?null:(0,Y.jsx)(E,{children:(0,Y.jsx)(f,{children:q(a?`capabilities.connectors.noneAdmin`:`capabilities.connectors.none`)})})]}),v.length?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 px-1`,children:[(0,Y.jsx)(`h3`,{className:`font-semibold text-[0.875rem]`,children:q(`capabilities.connectors.builtin`)}),(0,Y.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:q(a?`capabilities.connectors.builtinHint`:`capabilities.connectors.builtinHintMember`)}),(0,Y.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,children:v.map(e=>(0,Y.jsx)(`li`,{children:a&&e.usable?(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>l(e.id),title:q(`capabilities.connectors.setUpNamed`,{name:e.name}),className:`inline-flex h-8 items-center gap-1.5 rounded-full bg-paper-2 px-3 text-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:[(0,Y.jsx)(j,{className:`size-3.5`,"aria-hidden":`true`}),e.name]}):(0,Y.jsx)(`span`,{title:e.missingSetup??void 0,className:_(`inline-flex h-8 items-center rounded-full bg-paper-2 px-3 text-[0.8125rem] text-ink-3`,!e.usable&&`opacity-60`),children:e.name})},e.id))})]}):null,(0,Y.jsx)(`div`,{ref:p,className:`scroll-mt-6`,children:(0,Y.jsx)(h,{title:q(`capabilities.connectors.more`),hint:q(`capabilities.connectors.moreHint`),children:(0,Y.jsx)(me,{spaceId:e,readOnly:!a,embedded:!0,onSetUp:a?l:void 0,domain:g})})})]})}function Xe({connection:e,onOpen:t}){let n=u(),r=B(`/api/studio/connections/${encodeURIComponent(e.id)}/my-sign-in`,()=>n.invalidateQueries({queryKey:X(e.spaceId)})),i=Object.values(e.rules).includes(`ask`),a=e.signIn===`person`;return(0,Y.jsxs)(`div`,{className:`px-3.5 py-3 sm:px-5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:t,className:`-my-1 -ml-1 flex min-w-0 flex-1 items-center gap-3 rounded-lg p-1 text-left transition hover:bg-paper-2`,children:[(0,Y.jsx)(qe,{name:e.connector?.name??e.connectorId}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`truncate text-[0.9375rem]`,children:Q(e)}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[0.8125rem] text-ink-3`,children:[a?(0,Y.jsx)(F,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}):(0,Y.jsx)(se,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`truncate`,children:[Ue(e),` · `,We(e)]})]})]}),(0,Y.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 max-sm:hidden`,children:[i?(0,Y.jsx)(o,{tone:`warn`,children:q(`connection.outcome.ask`)}):null,(0,Y.jsx)(o,{children:q(Z[e.audience])})]})]}),a?(0,Y.jsx)(H,{s:r,auth:e.connector?.auth,signedIn:!!e.mySignIn}):null]}),a?(0,Y.jsx)(V,{s:r,fields:e.connector?.fields??[],signedIn:!!e.mySignIn,confirmText:q(`konto.connectionSignOutConfirm`,{name:Q(e)}),className:`ml-12`}):null]})}function Ze({spaceId:e,connectors:t,initial:n,onCancel:r,onDone:a}){let o=u(),c=t.filter(e=>e.usable),[d,f]=(0,J.useState)(c.some(e=>e.id===n)?n:``),p=c.find(e=>e.id===d),[m,h]=(0,J.useState)(p?.name??``),[g,_]=(0,J.useState)(p?.auth===`oauth2`?`person`:`space`),[v,y]=(0,J.useState)(`members`),b=N({mutationFn:()=>T.post(`/api/studio/spaces/${e}/connections`,{connectorId:d,name:m.trim()||p?.name,signIn:g,audience:v}),onSuccess:async t=>{await o.invalidateQueries({queryKey:X(e)}),await o.invalidateQueries({queryKey:[`person-sign-ins`]}),a(t.id)}});return(0,Y.jsx)(E,{className:`p-3.5 sm:p-5`,children:(0,Y.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),d&&b.mutate()},className:`flex flex-col gap-5`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h3`,{className:`font-display font-semibold text-base`,children:q(`capabilities.connectors.add`)}),(0,Y.jsx)(`p`,{className:`mt-1 text-[0.8125rem] text-ink-3`,children:q(`connection.setupHint`)})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(i,{children:q(`connection.connector`)}),(0,Y.jsx)(C,{value:d,onChange:e=>{let t=c.find(t=>t.id===e);(!m.trim()||m===p?.name)&&h(t?.name??``),f(e)},placeholder:q(`connection.connectorPick`),options:c.map(e=>({value:e.id,label:e.name}))})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(i,{hint:q(`connection.nameHint`),children:q(`connection.name`)}),(0,Y.jsx)(l,{value:m,maxLength:je.name,placeholder:q(`connection.namePlaceholder`),onChange:e=>h(e.target.value)})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(i,{hint:q(Be[g]),children:q(`connection.signIn`)}),(0,Y.jsx)(w,{label:q(`connection.signIn`),value:g,onChange:_,options:[`space`,`person`].map(e=>({id:e,label:q(ze[e])}))}),(0,Y.jsx)(`p`,{className:`mt-2 text-[0.75rem] text-ink-3`,children:q(`connection.signInFixed`)})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(i,{hint:q(Fe[v]),children:q(`connection.audience`)}),(0,Y.jsx)(w,{label:q(`connection.audience`),value:v,onChange:y,options:Oe.map(e=>({id:e,label:q(Z[e])}))})]}),b.error?(0,Y.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:b.error.message}):null,(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(s,{type:`submit`,busy:b.isPending,disabled:!d,children:q(`capabilities.connectors.setUp`)}),(0,Y.jsx)(s,{type:`button`,variant:`ghost`,onClick:r,children:q(`orgSettings.cancel`)})]})]})})}function Qe({connection:e,connector:t,writable:n,onGone:r}){let i=u(),a=X(e.spaceId),c=()=>i.invalidateQueries({queryKey:a}),[d,f]=(0,J.useState)(e.name),[p,m]=(0,J.useState)(!1),h=`/api/studio/connections/${encodeURIComponent(e.id)}`,g=N({mutationFn:e=>T.patch(h,e),onSuccess:e=>{i.setQueryData(a,t=>t&&{connections:t.connections.map(t=>t.id===e.id?e:t)}),i.invalidateQueries({queryKey:[`person-sign-ins`]})}}),_=N({mutationFn:()=>T.del(h),onSuccess:async()=>{await c(),i.invalidateQueries({queryKey:[`person-sign-ins`]}),r()}}),v=B(`${h}/sign-in`,c),y=B(`${h}/my-sign-in`,c),b=()=>{let t=d.trim();t&&t!==e.name?g.mutate({name:t}):f(e.name)},x=e.connector?.name??e.connectorId,S=e.connector?.fields??[],C=e.setUpByName?q(`konto.connectionSetUpBy`,{name:e.setUpByName,when:Ve(e.setUpAt)}):q(`konto.connectionSetUpAt`,{when:Ve(e.setUpAt)}),D=n=>(t?.actions??[]).filter(e=>e.group===n).filter(t=>!e.actions.length||e.actions.includes(t.id));return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-4 px-1`,children:[(0,Y.jsx)(qe,{name:x,large:!0}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`h2`,{className:`font-display font-semibold text-lg leading-tight`,children:x}),e.connector?.description?(0,Y.jsx)(`p`,{className:`mt-1 line-clamp-2 text-[0.875rem] text-ink-3`,children:e.connector.description}):null]})]}),(0,Y.jsxs)(E,{className:`flex flex-col gap-5 p-3.5 sm:p-5`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1`,children:[n?(0,Y.jsx)(l,{"aria-label":q(`connection.name`),className:`max-w-sm font-semibold`,value:d,maxLength:je.name,onChange:e=>f(e.target.value),onBlur:b,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),b())}}):(0,Y.jsx)(`b`,{className:`text-[0.9375rem]`,children:e.name}),(0,Y.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:n?C:q(`connection.adminsManage`)})]}),(0,Y.jsx)($,{label:q(`connection.signIn`),children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[0.875rem]`,children:[e.signIn===`space`?(0,Y.jsx)(se,{className:`size-4 text-ink-3`,"aria-hidden":`true`}):(0,Y.jsx)(F,{className:`size-4 text-ink-3`,"aria-hidden":`true`}),q(ze[e.signIn])]}),(0,Y.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:q(Be[e.signIn])})]})}),e.signIn===`space`?(0,Y.jsx)($,{label:q(`connection.account`),children:(0,Y.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Y.jsx)(`span`,{className:`text-[0.875rem]`,children:e.account?q(`connection.accountSignedIn`,{label:e.account.label}):q(n?`connection.accountNotYetAdmin`:`connection.accountNotYet`)}),n?(0,Y.jsx)(H,{s:v,auth:e.connector?.auth,signedIn:!!e.account}):null]}),n?(0,Y.jsx)(V,{s:v,fields:S,signedIn:!!e.account,confirmText:q(`connection.signOutSpaceConfirm`,{name:Q(e)})}):null]})}):(0,Y.jsx)($,{label:q(`connection.people`),children:(0,Y.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Y.jsxs)(`span`,{className:`text-[0.875rem]`,children:[q(`connection.peopleSignedIn`,{n:e.signedIn}),` · `,e.mySignIn?q(`connection.youSignedIn`,{label:e.mySignIn.label}):q(`connection.youNotYet`)]}),(0,Y.jsx)(H,{s:y,auth:e.connector?.auth,signedIn:!!e.mySignIn})]}),(0,Y.jsx)(V,{s:y,fields:S,signedIn:!!e.mySignIn,confirmText:q(`konto.connectionSignOutConfirm`,{name:Q(e)})})]})}),(0,Y.jsx)($,{label:q(`connection.audience`),children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[n?(0,Y.jsx)(`div`,{children:(0,Y.jsx)(w,{label:q(`connection.audience`),value:e.audience,onChange:e=>g.mutate({audience:e}),options:Oe.map(e=>({id:e,label:q(Z[e])}))})}):(0,Y.jsx)(`span`,{children:(0,Y.jsx)(o,{children:q(Z[e.audience])})}),(0,Y.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:q(Fe[e.audience])})]})}),(0,Y.jsx)(`div`,{className:`border-border-soft border-t`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Y.jsx)(`h3`,{className:`font-semibold text-[0.875rem]`,children:q(`connection.rules`)}),ke.map(t=>{let r=D(t);return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between sm:gap-4`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`div`,{className:`font-medium text-[0.875rem]`,children:q(Ie[t])}),(0,Y.jsx)(`div`,{className:`text-[0.8125rem] text-ink-3`,children:q(Le[t])}),r.length?(0,Y.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[0.6875rem] text-ink-4`,children:r.map(e=>e.id).join(` · `)}):null]}),(0,Y.jsx)(`div`,{className:`shrink-0`,children:n?(0,Y.jsx)(w,{label:q(Ie[t]),value:e.rules[t],onChange:n=>g.mutate({rules:{...e.rules,[t]:n}}),options:Ae.map(e=>({id:e,label:q(Re[e])}))}):(0,Y.jsx)(o,{tone:e.rules[t]===`ask`?`warn`:`neutral`,children:q(Re[e.rules[t]])})})]},t)}),(0,Y.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:q(n?`connection.askHint`:`connection.askHintMember`)})]}),g.error?(0,Y.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:g.error.message}):null]}),(0,Y.jsx)(E,{className:`flex flex-col gap-1 p-3.5 sm:p-5`,children:(0,Y.jsx)($,{label:q(`connection.use`),children:(0,Y.jsx)(`span`,{className:`text-[0.875rem]`,children:We(e)})})}),n?(0,Y.jsxs)(`div`,{className:`px-1`,children:[p?(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-lg bg-paper p-3 text-[0.875rem] ring-1 ring-border-soft`,children:[(0,Y.jsx)(`p`,{className:`min-w-48 flex-1`,children:q(`connection.removeConfirm`,{name:Q(e)})}),(0,Y.jsx)(s,{variant:`ghost`,onClick:()=>m(!1),children:q(`orgSettings.cancel`)}),(0,Y.jsx)(s,{variant:`danger`,busy:_.isPending,onClick:()=>_.mutate(),children:q(`connection.remove`)})]}):(0,Y.jsx)(s,{variant:`danger`,size:`sm`,onClick:()=>m(!0),children:q(`connection.remove`)}),_.error?(0,Y.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-rose`,children:_.error.message}):null]}):null]})}function $({label:e,children:t}){return(0,Y.jsxs)(`div`,{className:`grid gap-1.5 sm:grid-cols-[11rem_minmax(0,1fr)] sm:gap-4`,children:[(0,Y.jsx)(`span`,{className:`pt-0.5 text-[0.8125rem] text-ink-3`,children:e}),t]})}var $e=[`discover.example1`,`discover.example2`,`discover.example3`],et=(e,t)=>t===void 0?[`discover`,e]:[`discover`,e,t];function tt(){let[e,t]=v(),n=e.get(`q`)??``,[r,i]=(0,J.useState)(n);return(0,J.useEffect)(()=>i(e=>e.trim()===n.trim()?e:n),[n]),(0,J.useEffect)(()=>{let e=r.trim();if(e===n.trim())return;let i=setTimeout(()=>t(t=>{let n=new URLSearchParams(t);return e?n.set(`q`,e):n.delete(`q`),n},{replace:!0}),350);return()=>clearTimeout(i)},[r,n,t]),[r,i,n.trim()]}function nt({asked:e,onExample:t}){let{space:n}=G(),r=W(),i=I(`skills`),o=u(),[c,l]=(0,J.useState)(null),d=n?.id??``,f=M({queryKey:et(d,e),queryFn:()=>T.get(`/api/studio/spaces/${d}/discover?q=${encodeURIComponent(e)}`),enabled:!!d&&e.length>=2,staleTime:6e4}),m=e=>{o.setQueriesData({queryKey:et(d)},t=>t&&{...t,skills:t.skills.map(t=>t.ref===e?{...t,added:!0}:t)}),o.invalidateQueries({queryKey:a.skills(d)})},h=N({mutationFn:e=>T.post(`/api/studio/spaces/${d}/skills/registry`,{ref:e,mode:`demand`}),onSuccess:(e,t)=>m(t)}),_=f.data,v=_&&!_.skills.length&&!_.connectors.length&&!_.errors.skills&&!_.errors.connectors;return n?(0,Y.jsxs)(Y.Fragment,{children:[e.length<2?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3 px-1 text-[0.875rem] text-ink-3`,children:[(0,Y.jsx)(`p`,{children:q(`discover.start`)}),(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:$e.map(e=>(0,Y.jsxs)(s,{variant:`secondary`,size:`sm`,onClick:()=>t(q(e)),children:[(0,Y.jsx)(g,{className:`size-3.5`}),` `,q(e)]},e))})]}):f.error?(0,Y.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:f.error.message}):_?v?(0,Y.jsx)(`p`,{className:`px-1 text-[0.875rem] text-ink-3`,children:q(`discover.none`,{q:e})}):(0,Y.jsxs)(Y.Fragment,{children:[i?(0,Y.jsx)(rt,{title:q(`space.skills`),count:_.skills.length,error:_.errors.skills,empty:q(`discover.groupNone`,{directory:`skills.sh`}),children:_.skills.map(e=>(0,Y.jsx)(ot,{hit:e,adding:h.isPending&&h.variables===e.ref,failed:h.isError&&h.variables===e.ref?h.error:null,onLook:()=>l(e.ref),onAdd:()=>h.mutate(e.ref)},e.ref))}):null,(0,Y.jsx)(rt,{title:q(`capabilities.connectors`),count:_.connectors.length,error:_.errors.connectors,empty:q(`discover.groupNone`,{directory:`integrations.sh`}),children:_.connectors.map(e=>(0,Y.jsx)(st,{hit:e,admin:r},e.domain))})]}):(0,Y.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,Y.jsx)(D,{className:`size-5`})}),(0,Y.jsx)(p,{open:c!==null,onClose:()=>l(null),wide:!0,height:`tall`,title:q(`skills.registryTitle`),children:c?(0,Y.jsx)(de,{spaceId:d,skillRef:c,onAdded:()=>{m(c),l(null)}},c):null})]}):null}function rt({title:e,count:t,error:n,empty:r,children:i}){return(0,Y.jsxs)(`section`,{className:`flex flex-col gap-2.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-baseline gap-2 px-1`,children:[(0,Y.jsx)(`h2`,{className:`font-display font-semibold text-lg leading-tight`,children:e}),t?(0,Y.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:t}):null]}),n?(0,Y.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:n}):t?(0,Y.jsx)(E,{className:`divide-y divide-border-soft`,children:i}):(0,Y.jsx)(`p`,{className:`px-1 text-[0.875rem] text-ink-3`,children:r})]})}function it({icon:e,name:t,mono:n,chip:r,line:i,source:a,error:o,children:s}){return(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 px-3 py-3 sm:flex-nowrap`,children:[(0,Y.jsx)(`span`,{className:`grid size-9 shrink-0 place-items-center rounded-lg bg-paper-2 text-ink-3`,children:(0,Y.jsx)(e,{className:`size-4`})}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 max-sm:basis-[calc(100%-3.25rem)]`,children:[(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:n?`font-medium font-mono text-[0.8125rem]`:`font-medium`,children:t}),r]}),i?(0,Y.jsx)(`span`,{className:`mt-0.5 block truncate text-[0.8125rem] text-ink-2`,children:i}):null,(0,Y.jsx)(`span`,{className:`mt-0.5 block truncate text-[0.75rem] text-ink-3`,children:a}),o?(0,Y.jsx)(`span`,{className:`mt-1 block text-[0.8125rem] text-rose`,children:o}):null]}),(0,Y.jsx)(`span`,{className:`flex shrink-0 items-center gap-2 max-sm:ml-[3.25rem]`,children:s})]})}function at(){return(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[0.8125rem] text-moss`,children:[(0,Y.jsx)(r,{className:`size-4`}),` `,q(`capabilities.inSpace`)]})}function ot({hit:e,adding:t,failed:n,onLook:r,onAdd:i}){return(0,Y.jsxs)(it,{icon:U,name:e.name,mono:!0,chip:e.official?(0,Y.jsx)(o,{tone:`live`,icon:(0,Y.jsx)(le,{className:`size-3`}),children:q(`skills.official`)}):(0,Y.jsx)(o,{tone:`warn`,children:q(`skills.unchecked`)}),error:n?.message,source:[`skills.sh`,e.source,q(`skills.installs`,{n:e.installs.toLocaleString(K)})].join(` · `),children:[(0,Y.jsx)(s,{variant:`ghost`,size:`sm`,onClick:r,children:q(`skills.open`)}),e.added?(0,Y.jsx)(at,{}):(0,Y.jsx)(s,{variant:`secondary`,size:`sm`,busy:t,onClick:i,children:q(`skills.add`)})]})}function st({hit:e,admin:t}){let n=m(),r=e.kinds.map(e=>e===`mcp`?`MCP`:`OpenAPI`);return(0,Y.jsx)(it,{icon:z,name:e.name,line:e.description||void 0,source:[`integrations.sh`,e.domain,...r].join(` · `),children:e.setUp?(0,Y.jsx)(at,{}):t?(0,Y.jsx)(s,{variant:`secondary`,size:`sm`,onClick:()=>n(`/capabilities/connectors?setup=${encodeURIComponent(e.domain)}`),children:q(`discover.setUp`)}):null})}var ct={skills:4,connections:5};function lt(){let{space:e}=G(),t=W(),n=m(),r=I(`skills`),i=I(`unsetConnectors`),[a,o]=v(),s=a.get(`tab`)===`discover`?`discover`:`space`,[c,l,u]=tt(),d=e?.id??``,p=R(r?e?.id:void 0),_=Me(d),y=Ne(d);if(!e)return null;let b=t&&!e.readOnly,S=c.trim().toLowerCase(),C=p.data?.skills??[],T=_.data?.connections??[],D=C.filter(e=>e.mode!==`off`).sort((e,t)=>e.mode===t.mode?0:e.mode===`always`?-1:1),O=S?C.filter(e=>e.name.includes(S)||e.description.toLowerCase().includes(S)):D,k=S?T.filter(e=>`${e.name} ${e.connector?.name??e.connectorId}`.toLowerCase().includes(S)):T,A=Pe(y.data??[],T,i),j=e=>o(t=>{let n=new URLSearchParams(t);return e===`discover`?n.set(`tab`,`discover`):n.delete(`tab`),n},{replace:!0});return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[(0,Y.jsx)(h,{title:q(`nav.capabilities`),hint:q(`capabilities.overview.hint`),plain:!0,action:(0,Y.jsx)(ft,{entries:[...r&&!p.data?.readOnly?[{icon:U,label:q(`capabilities.overview.addSkill`),hint:q(`capabilities.overview.addSkillHint`),to:`/capabilities/skills`}]:[],...b?[{icon:z,label:q(`capabilities.overview.addConnection`),hint:q(`capabilities.overview.addConnectionHint`),to:`/capabilities/connectors?setup=`}]:[],{icon:De,label:q(`capabilities.discover`),hint:q(`capabilities.overview.discoverHint`),to:`/capabilities/overview?tab=discover`}]}),children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Y.jsx)(w,{value:s,onChange:j,options:[{id:`space`,label:q(`capabilities.inSpace`)},{id:`discover`,label:q(`capabilities.discover`)}],label:q(`nav.capabilities`)}),(0,Y.jsxs)(`form`,{className:`flex h-10 min-w-0 flex-1 basis-60 items-center gap-2 rounded-full border border-input bg-card px-4 focus-within:border-focus focus-within:ring-4 focus-within:ring-focus-glow`,onSubmit:e=>{e.preventDefault(),s===`space`&&S&&!O.length&&!k.length&&j(`discover`)},children:[(0,Y.jsx)(g,{className:`size-4 shrink-0 text-ink-3`}),(0,Y.jsx)(`input`,{type:`search`,value:c,"aria-label":q(s===`discover`?`discover.searchLabel`:`capabilities.overview.search`),placeholder:q(s===`discover`?`discover.search`:`capabilities.overview.search`),onChange:e=>l(e.target.value),className:`min-w-0 flex-1 bg-transparent text-[0.875rem] text-ink outline-none placeholder:text-ink-4`})]})]})}),(0,Y.jsx)(`div`,{className:`flex animate-rise flex-col gap-9`,children:s===`discover`?(0,Y.jsx)(nt,{asked:u,onExample:l}):(0,Y.jsxs)(Y.Fragment,{children:[r?(0,Y.jsx)(ut,{icon:U,title:q(`space.skills`),all:C.length,to:`/capabilities/skills`,children:p.error?(0,Y.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:p.error.message}):O.length?(0,Y.jsx)(`div`,{className:`grid gap-2.5 sm:grid-cols-2`,children:O.slice(0,ct.skills).map(e=>(0,Y.jsx)(dt,{skill:e,onOpen:()=>n(`/capabilities/skills?show=k:${e.id}`)},e.id))}):p.isPending?null:(0,Y.jsx)(E,{children:(0,Y.jsx)(f,{children:S?q(`capabilities.overview.nothing`,{q:c.trim()}):q(`capabilities.overview.noSkills`)})})}):null,(0,Y.jsxs)(ut,{icon:z,title:q(`capabilities.connectors`),all:T.length,to:`/capabilities/connectors`,children:[_.error?(0,Y.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:_.error.message}):k.length?(0,Y.jsx)(E,{className:`flex flex-col divide-y divide-border-soft p-0`,children:k.slice(0,ct.connections).map(e=>(0,Y.jsx)(Xe,{connection:e,onOpen:()=>n(`/capabilities/connectors?show=${encodeURIComponent(e.id)}`)},e.id))}):_.isPending?null:(0,Y.jsx)(E,{children:(0,Y.jsx)(f,{children:S?q(`capabilities.overview.nothing`,{q:c.trim()}):q(`capabilities.overview.noConnections`)})}),A.length&&!S?(0,Y.jsxs)(`p`,{className:`px-1 text-[0.8125rem] text-ink-3`,children:[q(`capabilities.connectors.builtin`),`:`,` `,A.map((e,t)=>(0,Y.jsxs)(`span`,{children:[t?` · `:null,b&&e.usable?(0,Y.jsx)(x,{to:`/capabilities/connectors?setup=${encodeURIComponent(e.id)}`,className:`text-ink-2 hover:text-ink hover:underline`,children:e.name}):(0,Y.jsx)(`span`,{className:`text-ink-2`,children:e.name})]},e.id))]}):null]})]})},s)]})}function ut({icon:e,title:t,all:n,to:r,children:i}){return(0,Y.jsxs)(`section`,{className:`flex flex-col gap-2.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-1`,children:[(0,Y.jsxs)(`h3`,{className:`flex items-center gap-2 font-semibold text-[0.9375rem]`,children:[(0,Y.jsx)(e,{className:`size-4 text-ember-strong`,"aria-hidden":`true`}),t]}),(0,Y.jsxs)(x,{to:r,className:`inline-flex items-center gap-0.5 text-[0.8125rem] text-ink-3 transition hover:text-ink`,children:[q(`capabilities.overview.all`,{n}),(0,Y.jsx)(d,{className:`size-3.5`,"aria-hidden":`true`})]})]}),i]})}function dt({skill:e,onOpen:t}){return(0,Y.jsxs)(`button`,{type:`button`,onClick:t,className:`flex min-w-0 flex-col gap-1.5 rounded-xl bg-card px-4 py-3 text-left shadow-soft ring-1 ring-border-soft transition hover:ring-border`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(`span`,{className:_(`truncate font-medium font-mono text-[0.8125rem]`,e.mode===`off`&&`text-ink-3`),children:e.name}),(0,Y.jsx)(o,{tone:e.mode===`always`?`live`:`neutral`,children:q(`skills.mode.${e.mode}`)})]}),(0,Y.jsx)(`span`,{className:`line-clamp-2 text-[0.8125rem] text-ink-2`,children:e.description}),(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-[0.75rem] text-ink-3`,children:[(0,Y.jsx)(ue,{skill:e}),e.runScripts?q(`capabilities.overview.scripts`):null]})]})}function ft({entries:e}){let[t,n]=(0,J.useState)(!1),r=(0,J.useRef)(null);return(0,J.useEffect)(()=>{if(!t)return;let e=e=>{r.current?.contains(e.target)||n(!1)},i=e=>e.key===`Escape`&&n(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,i)}},[t]),(0,Y.jsxs)(`div`,{className:`relative`,ref:r,children:[(0,Y.jsxs)(s,{size:`sm`,"aria-haspopup":`menu`,"aria-expanded":t,onClick:()=>n(e=>!e),children:[(0,Y.jsx)(j,{className:`size-4`}),` `,q(`skills.add`),(0,Y.jsx)(c,{className:`-mr-1 size-4`})]}),t?(0,Y.jsx)(`div`,{role:`menu`,className:`absolute top-10 right-0 z-50 w-72 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,children:e.map(e=>(0,Y.jsxs)(x,{to:e.to,role:`menuitem`,onClick:()=>n(!1),className:`flex w-full items-start gap-2.5 rounded-lg px-2.5 py-2 text-left transition hover:bg-accent`,children:[(0,Y.jsx)(e.icon,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`block font-medium text-[0.875rem]`,children:e.label}),(0,Y.jsx)(`span`,{className:`block text-[0.8125rem] text-ink-3`,children:e.hint})]})]},e.to))}):null]})}var pt=(0,J.lazy)(()=>P(()=>import(`./SkillEditor-CqQMg2MC.js`).then(e=>({default:e.SkillEditor})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14])));function mt(){let[e,t]=v(),{space:n}=G(),r=re(),{narrow:i}=Ce(),a=e.get(`show`),o=a?.startsWith(`k:`)?a:null,s=R(n?.id),c=ie(`skills`,r).filter(e=>e.plugin);ye(s.data?.skills.find(e=>`k:${e.id}`===o)?.name??null),(0,J.useEffect)(()=>{i||L().scrollTo({top:0})},[i,o]);let l=e=>i?t({show:e}):t(e===`all`?{}:{show:e},{replace:!0});return(0,Y.jsx)(Y.Fragment,{children:n?(0,Y.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:o?(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)(pt,{skillId:o.slice(2),onGone:()=>l(`all`),onOpen:l,filesFirst:!0},o)}):s.data?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(ce,{spaceId:n.id,data:s.data,onOpen:l,heading:q(`capabilities.inSpace`)}),c.flatMap(e=>e.sections).map(e=>r.spaceSections.find(t=>t.id===e.id)).filter(e=>e!==void 0).map(e=>(0,Y.jsx)(S,{id:e.id,children:(0,Y.jsx)(h,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,Y.jsx)(oe,{of:e,children:(0,Y.jsx)(e.component,{})})})},e.serial))]}):s.error?(0,Y.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s.error.message}):null}):null})}var ht=[{id:`overview`,label:`capabilities.overview`,icon:te,element:lt,menu:!1},{id:`skills`,label:`space.skills`,icon:U,element:mt,feature:`skills`,menu:!1},{id:`connectors`,label:`capabilities.connectors`,icon:z,element:Je,menu:!1},{id:`protocol`,label:`capabilities.protocol`,icon:k,element:fe,admins:!0,menu:!1}];function gt(e,t=!0){return ht.filter(n=>n.element&&(!n.feature||e(n.feature))&&(t||!n.admins))}function _t(){let[e,t]=(0,J.useState)(null);return(0,J.useEffect)(()=>{let e=L(),n=()=>t(e.clientHeight);n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[]),e}function vt(){let e=I(`capabilities`),t=ee(),{section:n}=A(),[r]=v(),i=m(),a=b(),{space:o,loading:s}=G(),c=be(),[l,u]=(0,J.useState)(null),[d,p]=(0,J.useState)(null),[h,g]=(0,J.useState)(null),x=gt(e=>he(t,e),W()),S=x.find(e=>e.id===n),C=R(x.some(e=>e.id===`skills`)?o?.id:void 0),w=Me(o?.id??``),T={skills:C.data?.skills.length,connectors:w.data?.connections.length},E=x.map(e=>({id:e.id,label:q(e.label),icon:e.icon,to:e.menu===!1&&c?`/capabilities/${e.id}?show=page`:`/capabilities/${e.id}`,count:T[e.id]})),D=E.find(e=>e.id===S?.id),O=r.get(`show`)||r.has(`setup`)?2:1,k=S&&S.menu!==!1&&h!==S.id?1:0,j=Se(k),M=Se(O),N=(0,J.useMemo)(()=>({slot:l,narrow:c,setDetail:p}),[l,c]),P=_t();if(ae([{label:q(`nav.capabilities`),to:`/capabilities`},...D?[{label:D.label,to:D.to}]:[],...D&&d?[{label:d}]:[]]),!e)return(0,Y.jsx)(y,{to:`/`,replace:!0});if(n===`discover`){let e=new URLSearchParams(a.search);return e.set(`tab`,`discover`),(0,Y.jsx)(y,{to:{pathname:`/capabilities/overview`,search:`?${e}`},replace:!0})}if(!S&&x[0])return(0,Y.jsx)(y,{to:{pathname:`/capabilities/${x[0].id}`,search:a.search},replace:!0});let F=S?.element;return(0,Y.jsx)(ve.Provider,{value:N,children:(0,Y.jsx)(`div`,{className:`animate-rise`,children:(0,Y.jsxs)(`div`,{className:`grid gap-6 md:grid-cols-[10.5rem_minmax(0,1fr)] md:gap-5 lg:grid-cols-[15rem_minmax(0,1fr)] lg:gap-10`,children:[(0,Y.jsxs)(`aside`,{className:_(`menu-scroll min-w-0 md:sticky md:top-6 md:self-start md:overflow-y-auto md:overscroll-contain`,c&&O===2&&`hidden`,c&&M===`back`&&Te(`back`)),style:!c&&P?{maxHeight:P-48,paddingBottom:`var(--assistant-dock, 0px)`}:void 0,children:[(0,Y.jsx)(xe,{title:q(`nav.capabilities`),open:k===1?D??null:null,onBack:x.length>1?()=>g(S?.id??null):void 0,root:{icon:ne,label:q(`nav.capabilities`),onOpen:()=>i(c?`/capabilities/overview?show=page`:`/capabilities/overview`),current:S?.id===`overview`}}),(0,Y.jsx)(`div`,{className:_(Te(j)),children:k===0?(0,Y.jsx)(_e,{entries:E.filter(e=>e.id!==`overview`),current:D,onPick:e=>{g(null),S?.menu===!1&&i(e.to)}}):(0,Y.jsx)(`div`,{ref:u})},k)]}),(0,Y.jsxs)(`div`,{className:_(`min-w-0`,c&&O<2&&`hidden`,c&&M===`deeper`&&Te(`deeper`)),children:[c&&D?(0,Y.jsx)(`div`,{className:`mb-3`,children:(0,Y.jsx)(we,{label:D.label,onBack:()=>i(D.to)})}):null,F?(0,Y.jsx)(F,{}):null,o||s?null:(0,Y.jsx)(f,{children:q(`settings.noSpace`)})]})]})})})}export{vt as CapabilitiesPage};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SkillEditor-BsXTqNli.js","assets/rolldown-runtime-hePW80VL.js","assets/jsx-runtime-BNakU3Ej.js","assets/ui-CktezodE.js","assets/preload-helper-DpV6A1kQ.js","assets/i18n-0fUKyVRE.js","assets/useMutation-7_FOHoEl.js","assets/Skills-C_X1ZsKg.js","assets/circle-check-jqtsKi_b.js","assets/upload-CHGCFVZK.js","assets/code-xml-q88cSTV8.js","assets/scroll-text-2BhJO_W7.js","assets/eye-CgkvVlba.js","assets/code-editor-BpCEnf8H.js","assets/dist-EBVTpvRr.js"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$n as r,$t as i,G as a,Jt as o,Kt as s,Qn as c,Qt as l,Wr as u,Xn as d,Xt as f,Yt as p,_r as m,b as h,bn as g,cn as _,dr as v,fr as y,gr as b,lr as x,m as S,nn as C,on as w,q as T,qt as E,rn as D,sr as O,vn as k,vr as A,wn as j,yr as M}from"./ui-CktezodE.js";import{t as N}from"./useMutation-7_FOHoEl.js";import{t as P}from"./preload-helper-DpV6A1kQ.js";import{Lt as F,Nt as I,Pt as ee,Qt as te,Rt as ne,a as re,l as ie,m as ae,p as L,t as oe,un as se}from"./host-Bd_bon_c.js";import{a as ce,f as le,o as ue,r as de,s as R}from"./Skills-C_X1ZsKg.js";import{n as z}from"./volume-2-Bw5KASy8.js";import{i as B,n as V,o as fe,r as pe,s as me,t as H}from"./connection-sign-in-UJ6xk-TD.js";import{t as U}from"./scroll-text-2BhJO_W7.js";import{b as he,d as W,n as ge,u as G}from"./session-CpYa5hwd.js";import{n as K,s as q}from"./i18n-0fUKyVRE.js";import{a as _e,c as ve,d as ye,f as be,i as xe,m as Se,p as Ce,r as we,u as Te}from"./UpdateCheck-D6x7MqEl.js";var Ee={name:`compass`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z`,key:`9ktpf1`}]]};Ee.node;var De=O(Ee),J=e(t(),1),Oe=[`admins`,`members`,`all`],ke=[`read`,`write`,`destructive`,`send`],Ae=[`allow`,`ask`,`deny`],je={name:80,perSpace:200},Y=e(n(),1),X=e=>[`space-connections`,e];function Me(e){return M({enabled:!!e,queryKey:X(e),queryFn:()=>T.get(`/api/studio/spaces/${e}/connections`)})}function Ne(e){return M({enabled:!!e,queryKey:a.connectors(e),queryFn:()=>T.get(`/api/studio/spaces/${e}/connectors`)})}function Pe(e,t,n){let r=new Set(t.map(e=>e.connectorId));return e.filter(e=>e.sourceKind===`builtin`&&!r.has(e.id)&&(e.usable||n))}var Z={admins:`connection.audience.admins`,members:`connection.audience.members`,all:`connection.audience.all`},Fe={admins:`connection.audience.adminsHint`,members:`connection.audience.membersHint`,all:`connection.audience.allHint`},Ie={read:`connection.kind.read`,write:`connection.kind.write`,destructive:`connection.kind.destructive`,send:`connection.kind.send`},Le={read:`connection.kind.readHint`,write:`connection.kind.writeHint`,destructive:`connection.kind.destructiveHint`,send:`connection.kind.sendHint`},Re={allow:`connection.outcome.allow`,ask:`connection.outcome.ask`,deny:`connection.outcome.deny`},ze={space:`connection.signIn.space`,person:`connection.signIn.person`},Be={space:`connection.signIn.spaceHint`,person:`connection.signIn.personHint`},Ve=e=>new Intl.DateTimeFormat(K,{dateStyle:`medium`}).format(new Date(e));function He(e){let t=Math.round((Date.parse(e)-Date.now())/1e3),n=new Intl.RelativeTimeFormat(K,{numeric:`auto`});for(let[e,r]of[[`day`,86400],[`hour`,3600],[`minute`,60]])if(Math.abs(t)>=r)return n.format(Math.round(t/r),e);return n.format(0,`minute`)}function Q(e){let t=e.connector?.name??e.connectorId;return e.name===t?e.name:`${t} · ${e.name}`}function Ue(e){return e.signIn===`space`?e.account?q(`connection.asSpaceAccount`,{label:e.account.label}):q(`connection.asSpaceNotYet`):q(`connection.eachPersonCount`,{n:e.signedIn})}function We(e){return e.lastUsedAt?q(`connection.lastUsed`,{when:He(e.lastUsedAt)}):q(`connection.neverUsed`)}function Ge(e){let t=e.toLowerCase().replace(/^https?:\/\//,``).split(`/`)[0].split(`.`);return t.length>1?t[t.length-2]:t[0]}function Ke(e,t){if(!e)return null;let n=t.find(t=>t.id===e);if(n)return{connectorId:n.id};let r=t.find(t=>t.domain&&t.domain===e.toLowerCase());if(r)return{connectorId:r.id};let i=Ge(e),a=t.find(e=>e.sourceKind===`builtin`&&(e.id===i||e.id.endsWith(`-${i}`)||e.name.toLowerCase()===i));return a?{connectorId:a.id}:e.includes(`.`)?{domain:e}:null}function qe({name:e,large:t}){return(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:_(`flex shrink-0 items-center justify-center rounded-lg bg-paper-2 font-semibold text-ink-2`,t?`size-12 text-[0.9375rem]`:`size-9 text-[0.75rem]`),children:ge(e)||`?`})}function Je(){let[e,t]=v(),{space:n}=G(),r=W(),{narrow:i}=Ce(),a=u(),o=n?.id??``,s=e.get(`show`),c=e.get(`setup`),l=r&&!n?.readOnly,d=Me(o),f=Ne(o),p=d.data?.connections??[],m=p.find(e=>e.id===s)??null;ye(m?Q(m):null),pe((0,J.useCallback)(()=>{a.invalidateQueries({queryKey:[`space-connections`]}),a.invalidateQueries({queryKey:[`person-sign-ins`]})},[a])),(0,J.useEffect)(()=>{i||L().scrollTo({top:0})},[i,s]);let h=e=>i?t({show:e}):t(e===`all`?{}:{show:e},{replace:!0});return(0,Y.jsx)(Y.Fragment,{children:n?(0,Y.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:m?(0,Y.jsx)(Qe,{connection:m,connector:f.data?.find(e=>e.id===m.connectorId),writable:l,onGone:()=>h(`all`)},m.id):(0,Y.jsx)(Ye,{spaceId:n.id,connections:p,loading:d.isPending,error:d.error,connectors:f.data??[],writable:l,setup:c,onOpen:h,onSetUp:e=>{t({setup:e},{replace:!i}),i||L().scrollTo({top:0,behavior:`smooth`})},onSetUpDone:()=>t({},{replace:!0})})}):null})}function Ye({spaceId:e,connections:t,loading:n,error:r,connectors:i,writable:a,setup:o,onOpen:c,onSetUp:l,onSetUpDone:u}){let d=I(`unsetConnectors`),p=(0,J.useRef)(null),m=o&&i.length?Ke(o,i):null,g=m&&`domain`in m?m.domain:null;(0,J.useEffect)(()=>{g&&p.current?.scrollIntoView({block:`start`,behavior:`smooth`})},[g]);let v=Pe(i,t,d);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(h,{title:q(`capabilities.connectors`),hint:q(`capabilities.connectors.hint`),plain:!0,action:a&&o===null?(0,Y.jsxs)(s,{size:`sm`,onClick:()=>l(``),children:[(0,Y.jsx)(j,{className:`size-4`}),` `,q(`capabilities.connectors.add`)]}):null,children:[a&&o!==null?(0,Y.jsx)(Ze,{spaceId:e,connectors:i,initial:m&&`connectorId`in m?m.connectorId:``,onCancel:u,onDone:c},m&&`connectorId`in m?m.connectorId:`new`):null,(0,Y.jsx)(`h3`,{className:`px-1 pt-2 font-display font-semibold text-base`,children:q(`capabilities.inSpace`)}),r?(0,Y.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:r.message}):t.length?(0,Y.jsx)(E,{className:`flex flex-col divide-y divide-border-soft p-0`,children:t.map(e=>(0,Y.jsx)(Xe,{connection:e,onOpen:()=>c(e.id)},e.id))}):n?null:(0,Y.jsx)(E,{children:(0,Y.jsx)(f,{children:q(a?`capabilities.connectors.noneAdmin`:`capabilities.connectors.none`)})})]}),v.length?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 px-1`,children:[(0,Y.jsx)(`h3`,{className:`font-semibold text-[0.875rem]`,children:q(`capabilities.connectors.builtin`)}),(0,Y.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:q(a?`capabilities.connectors.builtinHint`:`capabilities.connectors.builtinHintMember`)}),(0,Y.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,children:v.map(e=>(0,Y.jsx)(`li`,{children:a&&e.usable?(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>l(e.id),title:q(`capabilities.connectors.setUpNamed`,{name:e.name}),className:`inline-flex h-8 items-center gap-1.5 rounded-full bg-paper-2 px-3 text-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:[(0,Y.jsx)(j,{className:`size-3.5`,"aria-hidden":`true`}),e.name]}):(0,Y.jsx)(`span`,{title:e.missingSetup??void 0,className:_(`inline-flex h-8 items-center rounded-full bg-paper-2 px-3 text-[0.8125rem] text-ink-3`,!e.usable&&`opacity-60`),children:e.name})},e.id))})]}):null,(0,Y.jsx)(`div`,{ref:p,className:`scroll-mt-6`,children:(0,Y.jsx)(h,{title:q(`capabilities.connectors.more`),hint:q(`capabilities.connectors.moreHint`),children:(0,Y.jsx)(me,{spaceId:e,readOnly:!a,embedded:!0,onSetUp:a?l:void 0,domain:g})})})]})}function Xe({connection:e,onOpen:t}){let n=u(),r=B(`/api/studio/connections/${encodeURIComponent(e.id)}/my-sign-in`,()=>n.invalidateQueries({queryKey:X(e.spaceId)})),i=Object.values(e.rules).includes(`ask`),a=e.signIn===`person`;return(0,Y.jsxs)(`div`,{className:`px-3.5 py-3 sm:px-5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:t,className:`-my-1 -ml-1 flex min-w-0 flex-1 items-center gap-3 rounded-lg p-1 text-left transition hover:bg-paper-2`,children:[(0,Y.jsx)(qe,{name:e.connector?.name??e.connectorId}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`truncate text-[0.9375rem]`,children:Q(e)}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[0.8125rem] text-ink-3`,children:[a?(0,Y.jsx)(F,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}):(0,Y.jsx)(se,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`truncate`,children:[Ue(e),` · `,We(e)]})]})]}),(0,Y.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 max-sm:hidden`,children:[i?(0,Y.jsx)(o,{tone:`warn`,children:q(`connection.outcome.ask`)}):null,(0,Y.jsx)(o,{children:q(Z[e.audience])})]})]}),a?(0,Y.jsx)(H,{s:r,auth:e.connector?.auth,signedIn:!!e.mySignIn}):null]}),a?(0,Y.jsx)(V,{s:r,fields:e.connector?.fields??[],signedIn:!!e.mySignIn,confirmText:q(`konto.connectionSignOutConfirm`,{name:Q(e)}),className:`ml-12`}):null]})}function Ze({spaceId:e,connectors:t,initial:n,onCancel:r,onDone:a}){let o=u(),c=t.filter(e=>e.usable),[d,f]=(0,J.useState)(c.some(e=>e.id===n)?n:``),p=c.find(e=>e.id===d),[m,h]=(0,J.useState)(p?.name??``),[g,_]=(0,J.useState)(p?.auth===`oauth2`?`person`:`space`),[v,y]=(0,J.useState)(`members`),b=N({mutationFn:()=>T.post(`/api/studio/spaces/${e}/connections`,{connectorId:d,name:m.trim()||p?.name,signIn:g,audience:v}),onSuccess:async t=>{await o.invalidateQueries({queryKey:X(e)}),await o.invalidateQueries({queryKey:[`person-sign-ins`]}),a(t.id)}});return(0,Y.jsx)(E,{className:`p-3.5 sm:p-5`,children:(0,Y.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),d&&b.mutate()},className:`flex flex-col gap-5`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h3`,{className:`font-display font-semibold text-base`,children:q(`capabilities.connectors.add`)}),(0,Y.jsx)(`p`,{className:`mt-1 text-[0.8125rem] text-ink-3`,children:q(`connection.setupHint`)})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(i,{children:q(`connection.connector`)}),(0,Y.jsx)(C,{value:d,onChange:e=>{let t=c.find(t=>t.id===e);(!m.trim()||m===p?.name)&&h(t?.name??``),f(e)},placeholder:q(`connection.connectorPick`),options:c.map(e=>({value:e.id,label:e.name}))})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(i,{hint:q(`connection.nameHint`),children:q(`connection.name`)}),(0,Y.jsx)(l,{value:m,maxLength:je.name,placeholder:q(`connection.namePlaceholder`),onChange:e=>h(e.target.value)})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(i,{hint:q(Be[g]),children:q(`connection.signIn`)}),(0,Y.jsx)(w,{label:q(`connection.signIn`),value:g,onChange:_,options:[`space`,`person`].map(e=>({id:e,label:q(ze[e])}))}),(0,Y.jsx)(`p`,{className:`mt-2 text-[0.75rem] text-ink-3`,children:q(`connection.signInFixed`)})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(i,{hint:q(Fe[v]),children:q(`connection.audience`)}),(0,Y.jsx)(w,{label:q(`connection.audience`),value:v,onChange:y,options:Oe.map(e=>({id:e,label:q(Z[e])}))})]}),b.error?(0,Y.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:b.error.message}):null,(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(s,{type:`submit`,busy:b.isPending,disabled:!d,children:q(`capabilities.connectors.setUp`)}),(0,Y.jsx)(s,{type:`button`,variant:`ghost`,onClick:r,children:q(`orgSettings.cancel`)})]})]})})}function Qe({connection:e,connector:t,writable:n,onGone:r}){let i=u(),a=X(e.spaceId),c=()=>i.invalidateQueries({queryKey:a}),[d,f]=(0,J.useState)(e.name),[p,m]=(0,J.useState)(!1),h=`/api/studio/connections/${encodeURIComponent(e.id)}`,g=N({mutationFn:e=>T.patch(h,e),onSuccess:e=>{i.setQueryData(a,t=>t&&{connections:t.connections.map(t=>t.id===e.id?e:t)}),i.invalidateQueries({queryKey:[`person-sign-ins`]})}}),_=N({mutationFn:()=>T.del(h),onSuccess:async()=>{await c(),i.invalidateQueries({queryKey:[`person-sign-ins`]}),r()}}),v=B(`${h}/sign-in`,c),y=B(`${h}/my-sign-in`,c),b=()=>{let t=d.trim();t&&t!==e.name?g.mutate({name:t}):f(e.name)},x=e.connector?.name??e.connectorId,S=e.connector?.fields??[],C=e.setUpByName?q(`konto.connectionSetUpBy`,{name:e.setUpByName,when:Ve(e.setUpAt)}):q(`konto.connectionSetUpAt`,{when:Ve(e.setUpAt)}),D=n=>(t?.actions??[]).filter(e=>e.group===n).filter(t=>!e.actions.length||e.actions.includes(t.id));return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-4 px-1`,children:[(0,Y.jsx)(qe,{name:x,large:!0}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`h2`,{className:`font-display font-semibold text-lg leading-tight`,children:x}),e.connector?.description?(0,Y.jsx)(`p`,{className:`mt-1 line-clamp-2 text-[0.875rem] text-ink-3`,children:e.connector.description}):null]})]}),(0,Y.jsxs)(E,{className:`flex flex-col gap-5 p-3.5 sm:p-5`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1`,children:[n?(0,Y.jsx)(l,{"aria-label":q(`connection.name`),className:`max-w-sm font-semibold`,value:d,maxLength:je.name,onChange:e=>f(e.target.value),onBlur:b,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),b())}}):(0,Y.jsx)(`b`,{className:`text-[0.9375rem]`,children:e.name}),(0,Y.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:n?C:q(`connection.adminsManage`)})]}),(0,Y.jsx)($,{label:q(`connection.signIn`),children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[0.875rem]`,children:[e.signIn===`space`?(0,Y.jsx)(se,{className:`size-4 text-ink-3`,"aria-hidden":`true`}):(0,Y.jsx)(F,{className:`size-4 text-ink-3`,"aria-hidden":`true`}),q(ze[e.signIn])]}),(0,Y.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:q(Be[e.signIn])})]})}),e.signIn===`space`?(0,Y.jsx)($,{label:q(`connection.account`),children:(0,Y.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Y.jsx)(`span`,{className:`text-[0.875rem]`,children:e.account?q(`connection.accountSignedIn`,{label:e.account.label}):q(n?`connection.accountNotYetAdmin`:`connection.accountNotYet`)}),n?(0,Y.jsx)(H,{s:v,auth:e.connector?.auth,signedIn:!!e.account}):null]}),n?(0,Y.jsx)(V,{s:v,fields:S,signedIn:!!e.account,confirmText:q(`connection.signOutSpaceConfirm`,{name:Q(e)})}):null]})}):(0,Y.jsx)($,{label:q(`connection.people`),children:(0,Y.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Y.jsxs)(`span`,{className:`text-[0.875rem]`,children:[q(`connection.peopleSignedIn`,{n:e.signedIn}),` · `,e.mySignIn?q(`connection.youSignedIn`,{label:e.mySignIn.label}):q(`connection.youNotYet`)]}),(0,Y.jsx)(H,{s:y,auth:e.connector?.auth,signedIn:!!e.mySignIn})]}),(0,Y.jsx)(V,{s:y,fields:S,signedIn:!!e.mySignIn,confirmText:q(`konto.connectionSignOutConfirm`,{name:Q(e)})})]})}),(0,Y.jsx)($,{label:q(`connection.audience`),children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[n?(0,Y.jsx)(`div`,{children:(0,Y.jsx)(w,{label:q(`connection.audience`),value:e.audience,onChange:e=>g.mutate({audience:e}),options:Oe.map(e=>({id:e,label:q(Z[e])}))})}):(0,Y.jsx)(`span`,{children:(0,Y.jsx)(o,{children:q(Z[e.audience])})}),(0,Y.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:q(Fe[e.audience])})]})}),(0,Y.jsx)(`div`,{className:`border-border-soft border-t`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Y.jsx)(`h3`,{className:`font-semibold text-[0.875rem]`,children:q(`connection.rules`)}),ke.map(t=>{let r=D(t);return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between sm:gap-4`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`div`,{className:`font-medium text-[0.875rem]`,children:q(Ie[t])}),(0,Y.jsx)(`div`,{className:`text-[0.8125rem] text-ink-3`,children:q(Le[t])}),r.length?(0,Y.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[0.6875rem] text-ink-4`,children:r.map(e=>e.id).join(` · `)}):null]}),(0,Y.jsx)(`div`,{className:`shrink-0`,children:n?(0,Y.jsx)(w,{label:q(Ie[t]),value:e.rules[t],onChange:n=>g.mutate({rules:{...e.rules,[t]:n}}),options:Ae.map(e=>({id:e,label:q(Re[e])}))}):(0,Y.jsx)(o,{tone:e.rules[t]===`ask`?`warn`:`neutral`,children:q(Re[e.rules[t]])})})]},t)}),(0,Y.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:q(n?`connection.askHint`:`connection.askHintMember`)})]}),g.error?(0,Y.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:g.error.message}):null]}),(0,Y.jsx)(E,{className:`flex flex-col gap-1 p-3.5 sm:p-5`,children:(0,Y.jsx)($,{label:q(`connection.use`),children:(0,Y.jsx)(`span`,{className:`text-[0.875rem]`,children:We(e)})})}),n?(0,Y.jsxs)(`div`,{className:`px-1`,children:[p?(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-lg bg-paper p-3 text-[0.875rem] ring-1 ring-border-soft`,children:[(0,Y.jsx)(`p`,{className:`min-w-48 flex-1`,children:q(`connection.removeConfirm`,{name:Q(e)})}),(0,Y.jsx)(s,{variant:`ghost`,onClick:()=>m(!1),children:q(`orgSettings.cancel`)}),(0,Y.jsx)(s,{variant:`danger`,busy:_.isPending,onClick:()=>_.mutate(),children:q(`connection.remove`)})]}):(0,Y.jsx)(s,{variant:`danger`,size:`sm`,onClick:()=>m(!0),children:q(`connection.remove`)}),_.error?(0,Y.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-rose`,children:_.error.message}):null]}):null]})}function $({label:e,children:t}){return(0,Y.jsxs)(`div`,{className:`grid gap-1.5 sm:grid-cols-[11rem_minmax(0,1fr)] sm:gap-4`,children:[(0,Y.jsx)(`span`,{className:`pt-0.5 text-[0.8125rem] text-ink-3`,children:e}),t]})}var $e=[`discover.example1`,`discover.example2`,`discover.example3`],et=(e,t)=>t===void 0?[`discover`,e]:[`discover`,e,t];function tt(){let[e,t]=v(),n=e.get(`q`)??``,[r,i]=(0,J.useState)(n);return(0,J.useEffect)(()=>i(e=>e.trim()===n.trim()?e:n),[n]),(0,J.useEffect)(()=>{let e=r.trim();if(e===n.trim())return;let i=setTimeout(()=>t(t=>{let n=new URLSearchParams(t);return e?n.set(`q`,e):n.delete(`q`),n},{replace:!0}),350);return()=>clearTimeout(i)},[r,n,t]),[r,i,n.trim()]}function nt({asked:e,onExample:t}){let{space:n}=G(),r=W(),i=I(`skills`),o=u(),[c,l]=(0,J.useState)(null),d=n?.id??``,f=M({queryKey:et(d,e),queryFn:()=>T.get(`/api/studio/spaces/${d}/discover?q=${encodeURIComponent(e)}`),enabled:!!d&&e.length>=2,staleTime:6e4}),m=e=>{o.setQueriesData({queryKey:et(d)},t=>t&&{...t,skills:t.skills.map(t=>t.ref===e?{...t,added:!0}:t)}),o.invalidateQueries({queryKey:a.skills(d)})},h=N({mutationFn:e=>T.post(`/api/studio/spaces/${d}/skills/registry`,{ref:e,mode:`demand`}),onSuccess:(e,t)=>m(t)}),_=f.data,v=_&&!_.skills.length&&!_.connectors.length&&!_.errors.skills&&!_.errors.connectors;return n?(0,Y.jsxs)(Y.Fragment,{children:[e.length<2?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3 px-1 text-[0.875rem] text-ink-3`,children:[(0,Y.jsx)(`p`,{children:q(`discover.start`)}),(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:$e.map(e=>(0,Y.jsxs)(s,{variant:`secondary`,size:`sm`,onClick:()=>t(q(e)),children:[(0,Y.jsx)(g,{className:`size-3.5`}),` `,q(e)]},e))})]}):f.error?(0,Y.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:f.error.message}):_?v?(0,Y.jsx)(`p`,{className:`px-1 text-[0.875rem] text-ink-3`,children:q(`discover.none`,{q:e})}):(0,Y.jsxs)(Y.Fragment,{children:[i?(0,Y.jsx)(rt,{title:q(`space.skills`),count:_.skills.length,error:_.errors.skills,empty:q(`discover.groupNone`,{directory:`skills.sh`}),children:_.skills.map(e=>(0,Y.jsx)(ot,{hit:e,adding:h.isPending&&h.variables===e.ref,failed:h.isError&&h.variables===e.ref?h.error:null,onLook:()=>l(e.ref),onAdd:()=>h.mutate(e.ref)},e.ref))}):null,(0,Y.jsx)(rt,{title:q(`capabilities.connectors`),count:_.connectors.length,error:_.errors.connectors,empty:q(`discover.groupNone`,{directory:`integrations.sh`}),children:_.connectors.map(e=>(0,Y.jsx)(st,{hit:e,admin:r},e.domain))})]}):(0,Y.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,Y.jsx)(D,{className:`size-5`})}),(0,Y.jsx)(p,{open:c!==null,onClose:()=>l(null),wide:!0,height:`tall`,title:q(`skills.registryTitle`),children:c?(0,Y.jsx)(de,{spaceId:d,skillRef:c,onAdded:()=>{m(c),l(null)}},c):null})]}):null}function rt({title:e,count:t,error:n,empty:r,children:i}){return(0,Y.jsxs)(`section`,{className:`flex flex-col gap-2.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-baseline gap-2 px-1`,children:[(0,Y.jsx)(`h2`,{className:`font-display font-semibold text-lg leading-tight`,children:e}),t?(0,Y.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:t}):null]}),n?(0,Y.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:n}):t?(0,Y.jsx)(E,{className:`divide-y divide-border-soft`,children:i}):(0,Y.jsx)(`p`,{className:`px-1 text-[0.875rem] text-ink-3`,children:r})]})}function it({icon:e,name:t,mono:n,chip:r,line:i,source:a,error:o,children:s}){return(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 px-3 py-3 sm:flex-nowrap`,children:[(0,Y.jsx)(`span`,{className:`grid size-9 shrink-0 place-items-center rounded-lg bg-paper-2 text-ink-3`,children:(0,Y.jsx)(e,{className:`size-4`})}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 max-sm:basis-[calc(100%-3.25rem)]`,children:[(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:n?`font-medium font-mono text-[0.8125rem]`:`font-medium`,children:t}),r]}),i?(0,Y.jsx)(`span`,{className:`mt-0.5 block truncate text-[0.8125rem] text-ink-2`,children:i}):null,(0,Y.jsx)(`span`,{className:`mt-0.5 block truncate text-[0.75rem] text-ink-3`,children:a}),o?(0,Y.jsx)(`span`,{className:`mt-1 block text-[0.8125rem] text-rose`,children:o}):null]}),(0,Y.jsx)(`span`,{className:`flex shrink-0 items-center gap-2 max-sm:ml-[3.25rem]`,children:s})]})}function at(){return(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[0.8125rem] text-moss`,children:[(0,Y.jsx)(r,{className:`size-4`}),` `,q(`capabilities.inSpace`)]})}function ot({hit:e,adding:t,failed:n,onLook:r,onAdd:i}){return(0,Y.jsxs)(it,{icon:U,name:e.name,mono:!0,chip:e.official?(0,Y.jsx)(o,{tone:`live`,icon:(0,Y.jsx)(le,{className:`size-3`}),children:q(`skills.official`)}):(0,Y.jsx)(o,{tone:`warn`,children:q(`skills.unchecked`)}),error:n?.message,source:[`skills.sh`,e.source,q(`skills.installs`,{n:e.installs.toLocaleString(K)})].join(` · `),children:[(0,Y.jsx)(s,{variant:`ghost`,size:`sm`,onClick:r,children:q(`skills.open`)}),e.added?(0,Y.jsx)(at,{}):(0,Y.jsx)(s,{variant:`secondary`,size:`sm`,busy:t,onClick:i,children:q(`skills.add`)})]})}function st({hit:e,admin:t}){let n=m(),r=e.kinds.map(e=>e===`mcp`?`MCP`:`OpenAPI`);return(0,Y.jsx)(it,{icon:z,name:e.name,line:e.description||void 0,source:[`integrations.sh`,e.domain,...r].join(` · `),children:e.setUp?(0,Y.jsx)(at,{}):t?(0,Y.jsx)(s,{variant:`secondary`,size:`sm`,onClick:()=>n(`/capabilities/connectors?setup=${encodeURIComponent(e.domain)}`),children:q(`discover.setUp`)}):null})}var ct={skills:4,connections:5};function lt(){let{space:e}=G(),t=W(),n=m(),r=I(`skills`),i=I(`unsetConnectors`),[a,o]=v(),s=a.get(`tab`)===`discover`?`discover`:`space`,[c,l,u]=tt(),d=e?.id??``,p=R(r?e?.id:void 0),_=Me(d),y=Ne(d);if(!e)return null;let b=t&&!e.readOnly,S=c.trim().toLowerCase(),C=p.data?.skills??[],T=_.data?.connections??[],D=C.filter(e=>e.mode!==`off`).sort((e,t)=>e.mode===t.mode?0:e.mode===`always`?-1:1),O=S?C.filter(e=>e.name.includes(S)||e.description.toLowerCase().includes(S)):D,k=S?T.filter(e=>`${e.name} ${e.connector?.name??e.connectorId}`.toLowerCase().includes(S)):T,A=Pe(y.data??[],T,i),j=e=>o(t=>{let n=new URLSearchParams(t);return e===`discover`?n.set(`tab`,`discover`):n.delete(`tab`),n},{replace:!0});return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[(0,Y.jsx)(h,{title:q(`nav.capabilities`),hint:q(`capabilities.overview.hint`),plain:!0,action:(0,Y.jsx)(ft,{entries:[...r&&!p.data?.readOnly?[{icon:U,label:q(`capabilities.overview.addSkill`),hint:q(`capabilities.overview.addSkillHint`),to:`/capabilities/skills`}]:[],...b?[{icon:z,label:q(`capabilities.overview.addConnection`),hint:q(`capabilities.overview.addConnectionHint`),to:`/capabilities/connectors?setup=`}]:[],{icon:De,label:q(`capabilities.discover`),hint:q(`capabilities.overview.discoverHint`),to:`/capabilities/overview?tab=discover`}]}),children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Y.jsx)(w,{value:s,onChange:j,options:[{id:`space`,label:q(`capabilities.inSpace`)},{id:`discover`,label:q(`capabilities.discover`)}],label:q(`nav.capabilities`)}),(0,Y.jsxs)(`form`,{className:`flex h-10 min-w-0 flex-1 basis-60 items-center gap-2 rounded-full border border-input bg-card px-4 focus-within:border-focus focus-within:ring-4 focus-within:ring-focus-glow`,onSubmit:e=>{e.preventDefault(),s===`space`&&S&&!O.length&&!k.length&&j(`discover`)},children:[(0,Y.jsx)(g,{className:`size-4 shrink-0 text-ink-3`}),(0,Y.jsx)(`input`,{type:`search`,value:c,"aria-label":q(s===`discover`?`discover.searchLabel`:`capabilities.overview.search`),placeholder:q(s===`discover`?`discover.search`:`capabilities.overview.search`),onChange:e=>l(e.target.value),className:`min-w-0 flex-1 bg-transparent text-[0.875rem] text-ink outline-none placeholder:text-ink-4`})]})]})}),(0,Y.jsx)(`div`,{className:`flex animate-rise flex-col gap-9`,children:s===`discover`?(0,Y.jsx)(nt,{asked:u,onExample:l}):(0,Y.jsxs)(Y.Fragment,{children:[r?(0,Y.jsx)(ut,{icon:U,title:q(`space.skills`),all:C.length,to:`/capabilities/skills`,children:p.error?(0,Y.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:p.error.message}):O.length?(0,Y.jsx)(`div`,{className:`grid gap-2.5 sm:grid-cols-2`,children:O.slice(0,ct.skills).map(e=>(0,Y.jsx)(dt,{skill:e,onOpen:()=>n(`/capabilities/skills?show=k:${e.id}`)},e.id))}):p.isPending?null:(0,Y.jsx)(E,{children:(0,Y.jsx)(f,{children:S?q(`capabilities.overview.nothing`,{q:c.trim()}):q(`capabilities.overview.noSkills`)})})}):null,(0,Y.jsxs)(ut,{icon:z,title:q(`capabilities.connectors`),all:T.length,to:`/capabilities/connectors`,children:[_.error?(0,Y.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:_.error.message}):k.length?(0,Y.jsx)(E,{className:`flex flex-col divide-y divide-border-soft p-0`,children:k.slice(0,ct.connections).map(e=>(0,Y.jsx)(Xe,{connection:e,onOpen:()=>n(`/capabilities/connectors?show=${encodeURIComponent(e.id)}`)},e.id))}):_.isPending?null:(0,Y.jsx)(E,{children:(0,Y.jsx)(f,{children:S?q(`capabilities.overview.nothing`,{q:c.trim()}):q(`capabilities.overview.noConnections`)})}),A.length&&!S?(0,Y.jsxs)(`p`,{className:`px-1 text-[0.8125rem] text-ink-3`,children:[q(`capabilities.connectors.builtin`),`:`,` `,A.map((e,t)=>(0,Y.jsxs)(`span`,{children:[t?` · `:null,b&&e.usable?(0,Y.jsx)(x,{to:`/capabilities/connectors?setup=${encodeURIComponent(e.id)}`,className:`text-ink-2 hover:text-ink hover:underline`,children:e.name}):(0,Y.jsx)(`span`,{className:`text-ink-2`,children:e.name})]},e.id))]}):null]})]})},s)]})}function ut({icon:e,title:t,all:n,to:r,children:i}){return(0,Y.jsxs)(`section`,{className:`flex flex-col gap-2.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-1`,children:[(0,Y.jsxs)(`h3`,{className:`flex items-center gap-2 font-semibold text-[0.9375rem]`,children:[(0,Y.jsx)(e,{className:`size-4 text-ember-strong`,"aria-hidden":`true`}),t]}),(0,Y.jsxs)(x,{to:r,className:`inline-flex items-center gap-0.5 text-[0.8125rem] text-ink-3 transition hover:text-ink`,children:[q(`capabilities.overview.all`,{n}),(0,Y.jsx)(d,{className:`size-3.5`,"aria-hidden":`true`})]})]}),i]})}function dt({skill:e,onOpen:t}){return(0,Y.jsxs)(`button`,{type:`button`,onClick:t,className:`flex min-w-0 flex-col gap-1.5 rounded-xl bg-card px-4 py-3 text-left shadow-soft ring-1 ring-border-soft transition hover:ring-border`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(`span`,{className:_(`truncate font-medium font-mono text-[0.8125rem]`,e.mode===`off`&&`text-ink-3`),children:e.name}),(0,Y.jsx)(o,{tone:e.mode===`always`?`live`:`neutral`,children:q(`skills.mode.${e.mode}`)})]}),(0,Y.jsx)(`span`,{className:`line-clamp-2 text-[0.8125rem] text-ink-2`,children:e.description}),(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-[0.75rem] text-ink-3`,children:[(0,Y.jsx)(ue,{skill:e}),e.runScripts?q(`capabilities.overview.scripts`):null]})]})}function ft({entries:e}){let[t,n]=(0,J.useState)(!1),r=(0,J.useRef)(null);return(0,J.useEffect)(()=>{if(!t)return;let e=e=>{r.current?.contains(e.target)||n(!1)},i=e=>e.key===`Escape`&&n(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,i)}},[t]),(0,Y.jsxs)(`div`,{className:`relative`,ref:r,children:[(0,Y.jsxs)(s,{size:`sm`,"aria-haspopup":`menu`,"aria-expanded":t,onClick:()=>n(e=>!e),children:[(0,Y.jsx)(j,{className:`size-4`}),` `,q(`skills.add`),(0,Y.jsx)(c,{className:`-mr-1 size-4`})]}),t?(0,Y.jsx)(`div`,{role:`menu`,className:`absolute top-10 right-0 z-50 w-72 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,children:e.map(e=>(0,Y.jsxs)(x,{to:e.to,role:`menuitem`,onClick:()=>n(!1),className:`flex w-full items-start gap-2.5 rounded-lg px-2.5 py-2 text-left transition hover:bg-accent`,children:[(0,Y.jsx)(e.icon,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`block font-medium text-[0.875rem]`,children:e.label}),(0,Y.jsx)(`span`,{className:`block text-[0.8125rem] text-ink-3`,children:e.hint})]})]},e.to))}):null]})}var pt=(0,J.lazy)(()=>P(()=>import(`./SkillEditor-BsXTqNli.js`).then(e=>({default:e.SkillEditor})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14])));function mt(){let[e,t]=v(),{space:n}=G(),r=re(),{narrow:i}=Ce(),a=e.get(`show`),o=a?.startsWith(`k:`)?a:null,s=R(n?.id),c=ie(`skills`,r).filter(e=>e.plugin);ye(s.data?.skills.find(e=>`k:${e.id}`===o)?.name??null),(0,J.useEffect)(()=>{i||L().scrollTo({top:0})},[i,o]);let l=e=>i?t({show:e}):t(e===`all`?{}:{show:e},{replace:!0});return(0,Y.jsx)(Y.Fragment,{children:n?(0,Y.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:o?(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)(pt,{skillId:o.slice(2),onGone:()=>l(`all`),onOpen:l,filesFirst:!0},o)}):s.data?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(ce,{spaceId:n.id,data:s.data,onOpen:l,heading:q(`capabilities.inSpace`)}),c.flatMap(e=>e.sections).map(e=>r.spaceSections.find(t=>t.id===e.id)).filter(e=>e!==void 0).map(e=>(0,Y.jsx)(S,{id:e.id,children:(0,Y.jsx)(h,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,Y.jsx)(oe,{of:e,children:(0,Y.jsx)(e.component,{})})})},e.serial))]}):s.error?(0,Y.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s.error.message}):null}):null})}var ht=[{id:`overview`,label:`capabilities.overview`,icon:te,element:lt,menu:!1},{id:`skills`,label:`space.skills`,icon:U,element:mt,feature:`skills`,menu:!1},{id:`connectors`,label:`capabilities.connectors`,icon:z,element:Je,menu:!1},{id:`protocol`,label:`capabilities.protocol`,icon:k,element:fe,admins:!0,menu:!1}];function gt(e,t=!0){return ht.filter(n=>n.element&&(!n.feature||e(n.feature))&&(t||!n.admins))}function _t(){let[e,t]=(0,J.useState)(null);return(0,J.useEffect)(()=>{let e=L(),n=()=>t(e.clientHeight);n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[]),e}function vt(){let e=I(`capabilities`),t=ee(),{section:n}=A(),[r]=v(),i=m(),a=b(),{space:o,loading:s}=G(),c=be(),[l,u]=(0,J.useState)(null),[d,p]=(0,J.useState)(null),[h,g]=(0,J.useState)(null),x=gt(e=>he(t,e),W()),S=x.find(e=>e.id===n),C=R(x.some(e=>e.id===`skills`)?o?.id:void 0),w=Me(o?.id??``),T={skills:C.data?.skills.length,connectors:w.data?.connections.length},E=x.map(e=>({id:e.id,label:q(e.label),icon:e.icon,to:e.menu===!1&&c?`/capabilities/${e.id}?show=page`:`/capabilities/${e.id}`,count:T[e.id]})),D=E.find(e=>e.id===S?.id),O=r.get(`show`)||r.has(`setup`)?2:1,k=S&&S.menu!==!1&&h!==S.id?1:0,j=Se(k),M=Se(O),N=(0,J.useMemo)(()=>({slot:l,narrow:c,setDetail:p}),[l,c]),P=_t();if(ae([{label:q(`nav.capabilities`),to:`/capabilities`},...D?[{label:D.label,to:D.to}]:[],...D&&d?[{label:d}]:[]]),!e)return(0,Y.jsx)(y,{to:`/`,replace:!0});if(n===`discover`){let e=new URLSearchParams(a.search);return e.set(`tab`,`discover`),(0,Y.jsx)(y,{to:{pathname:`/capabilities/overview`,search:`?${e}`},replace:!0})}if(!S&&x[0])return(0,Y.jsx)(y,{to:{pathname:`/capabilities/${x[0].id}`,search:a.search},replace:!0});let F=S?.element;return(0,Y.jsx)(ve.Provider,{value:N,children:(0,Y.jsx)(`div`,{className:`animate-rise`,children:(0,Y.jsxs)(`div`,{className:`grid gap-6 md:grid-cols-[10.5rem_minmax(0,1fr)] md:gap-5 lg:grid-cols-[15rem_minmax(0,1fr)] lg:gap-10`,children:[(0,Y.jsxs)(`aside`,{className:_(`menu-scroll min-w-0 md:sticky md:top-6 md:self-start md:overflow-y-auto md:overscroll-contain`,c&&O===2&&`hidden`,c&&M===`back`&&Te(`back`)),style:!c&&P?{maxHeight:P-48,paddingBottom:`var(--assistant-dock, 0px)`}:void 0,children:[(0,Y.jsx)(xe,{title:q(`nav.capabilities`),open:k===1?D??null:null,onBack:x.length>1?()=>g(S?.id??null):void 0,root:{icon:ne,label:q(`nav.capabilities`),onOpen:()=>i(c?`/capabilities/overview?show=page`:`/capabilities/overview`),current:S?.id===`overview`}}),(0,Y.jsx)(`div`,{className:_(Te(j)),children:k===0?(0,Y.jsx)(_e,{entries:E.filter(e=>e.id!==`overview`),current:D,onPick:e=>{g(null),S?.menu===!1&&i(e.to)}}):(0,Y.jsx)(`div`,{ref:u})},k)]}),(0,Y.jsxs)(`div`,{className:_(`min-w-0`,c&&O<2&&`hidden`,c&&M===`deeper`&&Te(`deeper`)),children:[c&&D?(0,Y.jsx)(`div`,{className:`mb-3`,children:(0,Y.jsx)(we,{label:D.label,onBack:()=>i(D.to)})}):null,F?(0,Y.jsx)(F,{}):null,o||s?null:(0,Y.jsx)(f,{children:q(`settings.noSpace`)})]})]})})})}export{vt as CapabilitiesPage};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{Qt as r,Xt as i,Yt as a,cn as o,rn as s}from"./ui-Uqnx1UpK.js";import{t as c}from"./preload-helper-DpV6A1kQ.js";import{s as l}from"./i18n-BJ7Ld6O6.js";var u=e(t(),1),d=e(n(),1);function f(e){switch(e.group){case`Added`:return{label:`NEW`,dot:`bg-moss`};case`Fixed`:return{label:`FIXED`,dot:`bg-amber`};case`Changed`:return{label:`CHANGED`,dot:`bg-cobalt`};case`Performance`:return{label:`PERFORMANCE`,dot:`bg-ember`};case`Deploy`:return{label:`DEPLOY`,dot:`bg-ink-4`};case`Docs`:return{label:`DOCS`,dot:`bg-ink-4`};default:return{label:`OTHER`,dot:`bg-ink-4`}}}var p=e=>e.version?e.version.replace(/^v/,``):l(`about.unreleased`),m=e=>e.timestamp?new Date(e.timestamp*1e3).toISOString().slice(0,10):``,h=e=>e.charAt(0).toUpperCase()+e.slice(1);function g(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=[];for(let t of e){if(`${p(t)} ${m(t)}`.toLowerCase().includes(n)){r.push(t);continue}let e=t.commits.filter(e=>`${f(e).label} ${e.scope??``} ${e.message}`.toLowerCase().includes(n));e.length>0&&r.push({...t,commits:e})}return r}async function _(e){if(e)try{let t=await fetch(`https://raw.githubusercontent.com/engenty/wizards/v${e}/apps/web/src/about/changelog.json`,{signal:AbortSignal.timeout(5e3)});if(t.ok)return await t.json()}catch{}return(await c(async()=>{let{default:e}=await import(`./changelog-BhMZS-rs.js`);return{default:e}},[])).default}function v({release:e}){return(0,d.jsx)(`ul`,{className:`flex flex-col gap-2`,children:e.commits.map(e=>{let t=f(e);return(0,d.jsxs)(`li`,{className:`flex items-start gap-2.5 text-[0.875rem]`,children:[(0,d.jsx)(`span`,{className:o(`mt-[7px] size-1.5 shrink-0 rounded-full`,t.dot)}),(0,d.jsxs)(`span`,{className:`min-w-0 text-ink-2`,children:[(0,d.jsxs)(`span`,{className:`font-semibold text-[0.75rem] text-ink tracking-wide`,children:[t.label,e.scope?` [${e.scope}]`:``]}),` `,h(e.message),e.breaking?(0,d.jsx)(`span`,{className:`ml-1.5 rounded-full bg-rose-tint px-1.5 py-0.5 font-medium text-[0.75rem] text-rose`,children:l(`about.breaking`)}):null]})]},e.id)})})}function y({open:e,onClose:t,version:n}){let[o,c]=(0,u.useState)(null),[f,h]=(0,u.useState)(``);(0,u.useEffect)(()=>{if(!e||o)return;let t=!1;return _(n).then(e=>{t||c(e)}),()=>{t=!0}},[e,o,n]),(0,u.useEffect)(()=>{e||h(``)},[e]);let y=o?g(o,f):[];return(0,d.jsxs)(a,{open:e,onClose:t,title:l(`about.changelog`),wide:!0,height:`tall`,children:[(0,d.jsx)(`p`,{className:`-mt-3 mb-4 text-[0.875rem] text-ink-3`,children:l(`about.changelogHint`)}),o===null?(0,d.jsx)(`div`,{className:`flex justify-center py-10 text-ink-3`,children:(0,d.jsx)(s,{})}):o.length===0?(0,d.jsx)(i,{children:l(`about.changelogEmpty`)}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(r,{type:`search`,value:f,placeholder:l(`about.search`),onChange:e=>h(e.target.value)}),y.length===0?(0,d.jsx)(i,{children:l(`about.noMatches`)}):null,y.map(e=>(0,d.jsxs)(`section`,{className:`mt-6`,children:[(0,d.jsxs)(`h3`,{className:`flex items-baseline gap-3 border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:[p(e),(0,d.jsx)(`span`,{className:`font-normal font-sans text-[0.8125rem] text-ink-3 tabular-nums`,children:m(e)})]}),(0,d.jsx)(`div`,{className:`mt-3`,children:(0,d.jsx)(v,{release:e})})]},e.version??`unreleased`))]})]})}export{y as ChangelogDialog,v as ReleaseNotes,_ as loadReleases,m as releaseDate,p as releaseLabel};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{Qt as r,Xt as i,Yt as a,cn as o,rn as s}from"./ui-CktezodE.js";import{t as c}from"./preload-helper-DpV6A1kQ.js";import{s as l}from"./i18n-0fUKyVRE.js";var u=e(t(),1),d=e(n(),1);function f(e){switch(e.group){case`Added`:return{label:`NEW`,dot:`bg-moss`};case`Fixed`:return{label:`FIXED`,dot:`bg-amber`};case`Changed`:return{label:`CHANGED`,dot:`bg-cobalt`};case`Performance`:return{label:`PERFORMANCE`,dot:`bg-ember`};case`Deploy`:return{label:`DEPLOY`,dot:`bg-ink-4`};case`Docs`:return{label:`DOCS`,dot:`bg-ink-4`};default:return{label:`OTHER`,dot:`bg-ink-4`}}}var p=e=>e.version?e.version.replace(/^v/,``):l(`about.unreleased`),m=e=>e.timestamp?new Date(e.timestamp*1e3).toISOString().slice(0,10):``,h=e=>e.charAt(0).toUpperCase()+e.slice(1);function g(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=[];for(let t of e){if(`${p(t)} ${m(t)}`.toLowerCase().includes(n)){r.push(t);continue}let e=t.commits.filter(e=>`${f(e).label} ${e.scope??``} ${e.message}`.toLowerCase().includes(n));e.length>0&&r.push({...t,commits:e})}return r}async function _(e){if(e)try{let t=await fetch(`https://raw.githubusercontent.com/engenty/wizards/v${e}/apps/web/src/about/changelog.json`,{signal:AbortSignal.timeout(5e3)});if(t.ok)return await t.json()}catch{}return(await c(async()=>{let{default:e}=await import(`./changelog-M-eOBqgu.js`);return{default:e}},[])).default}function v({release:e}){return(0,d.jsx)(`ul`,{className:`flex flex-col gap-2`,children:e.commits.map(e=>{let t=f(e);return(0,d.jsxs)(`li`,{className:`flex items-start gap-2.5 text-[0.875rem]`,children:[(0,d.jsx)(`span`,{className:o(`mt-[7px] size-1.5 shrink-0 rounded-full`,t.dot)}),(0,d.jsxs)(`span`,{className:`min-w-0 text-ink-2`,children:[(0,d.jsxs)(`span`,{className:`font-semibold text-[0.75rem] text-ink tracking-wide`,children:[t.label,e.scope?` [${e.scope}]`:``]}),` `,h(e.message),e.breaking?(0,d.jsx)(`span`,{className:`ml-1.5 rounded-full bg-rose-tint px-1.5 py-0.5 font-medium text-[0.75rem] text-rose`,children:l(`about.breaking`)}):null]})]},e.id)})})}function y({open:e,onClose:t,version:n}){let[o,c]=(0,u.useState)(null),[f,h]=(0,u.useState)(``);(0,u.useEffect)(()=>{if(!e||o)return;let t=!1;return _(n).then(e=>{t||c(e)}),()=>{t=!0}},[e,o,n]),(0,u.useEffect)(()=>{e||h(``)},[e]);let y=o?g(o,f):[];return(0,d.jsxs)(a,{open:e,onClose:t,title:l(`about.changelog`),wide:!0,height:`tall`,children:[(0,d.jsx)(`p`,{className:`-mt-3 mb-4 text-[0.875rem] text-ink-3`,children:l(`about.changelogHint`)}),o===null?(0,d.jsx)(`div`,{className:`flex justify-center py-10 text-ink-3`,children:(0,d.jsx)(s,{})}):o.length===0?(0,d.jsx)(i,{children:l(`about.changelogEmpty`)}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(r,{type:`search`,value:f,placeholder:l(`about.search`),onChange:e=>h(e.target.value)}),y.length===0?(0,d.jsx)(i,{children:l(`about.noMatches`)}):null,y.map(e=>(0,d.jsxs)(`section`,{className:`mt-6`,children:[(0,d.jsxs)(`h3`,{className:`flex items-baseline gap-3 border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:[p(e),(0,d.jsx)(`span`,{className:`font-normal font-sans text-[0.8125rem] text-ink-3 tabular-nums`,children:m(e)})]}),(0,d.jsx)(`div`,{className:`mt-3`,children:(0,d.jsx)(v,{release:e})})]},e.version??`unreleased`))]})]})}export{y as ChangelogDialog,v as ReleaseNotes,_ as loadReleases,m as releaseDate,p as releaseLabel};