@engenty/wizards-runtime 0.12.0 → 0.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/apps/runtime/dist/agents/space-agent.js +55 -0
  2. package/apps/runtime/dist/agents/studio-assistant.js +22 -11
  3. package/apps/runtime/dist/app.js +4 -2
  4. package/apps/runtime/dist/auth/account.js +3 -0
  5. package/apps/runtime/dist/db/live-triggers.js +13 -3
  6. package/apps/runtime/dist/db/migrations/tenant/0027_space_skill.sql +48 -0
  7. package/apps/runtime/dist/db/migrations/tenant/meta/0027_snapshot.json +4120 -0
  8. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +7 -0
  9. package/apps/runtime/dist/db/schema.js +31 -0
  10. package/apps/runtime/dist/docs/dev/skills.md +116 -0
  11. package/apps/runtime/dist/docs/user-guide/skills.md +85 -0
  12. package/apps/runtime/dist/engine/steps.js +10 -1
  13. package/apps/runtime/dist/env.js +2 -0
  14. package/apps/runtime/dist/features.js +11 -3
  15. package/apps/runtime/dist/harness/model.js +4 -0
  16. package/apps/runtime/dist/live/views.js +2 -0
  17. package/apps/runtime/dist/models.js +4 -0
  18. package/apps/runtime/dist/plugins/pro.js +26 -0
  19. package/apps/runtime/dist/prompts/goose.md +7 -0
  20. package/apps/runtime/dist/prompts/step.md +19 -1
  21. package/apps/runtime/dist/prompts/tools.md +33 -0
  22. package/apps/runtime/dist/routes/skills.js +84 -0
  23. package/apps/runtime/dist/routes/studio.js +12 -1
  24. package/apps/runtime/dist/services/assistant-chats.js +5 -2
  25. package/apps/runtime/dist/services/skills-registry.js +209 -0
  26. package/apps/runtime/dist/services/skills.js +478 -0
  27. package/apps/runtime/dist/sync/records.js +81 -1
  28. package/apps/runtime/dist/texts.js +39 -0
  29. package/apps/runtime/dist/tools/index.js +4 -2
  30. package/apps/runtime/dist/tools/net-guard.js +8 -4
  31. package/apps/runtime/dist/tools/skills.js +197 -0
  32. package/apps/web/dist/assets/{AboutDialog-BOJjBIYk.js → AboutDialog-CLgnoYTI.js} +1 -1
  33. package/apps/web/dist/assets/{ChangelogDialog-I9DEn_ra.js → ChangelogDialog-CKLgFL6r.js} +1 -1
  34. package/apps/web/dist/assets/CodeEditor-B3nto_26.js +2 -0
  35. package/apps/web/dist/assets/EditorPage-D9JDdAAI.js +3 -0
  36. package/apps/web/dist/assets/{FlowPreview-C6DeATyk.js → FlowPreview-zJCtixSi.js} +1 -1
  37. package/apps/web/dist/assets/Marketplace-D4e0Oac9.js +2 -0
  38. package/apps/web/dist/assets/{NewWizardChannels-BrVFc6PV.js → NewWizardChannels-B4N7GIYh.js} +1 -1
  39. package/apps/web/dist/assets/{NewWizardPage-Dl8sMR2e.js → NewWizardPage-Dpt0Mzk8.js} +1 -1
  40. package/apps/web/dist/assets/{OnboardingPage-BN5IfLGL.js → OnboardingPage-CDoYVjRC.js} +1 -1
  41. package/apps/web/dist/assets/PreviewPane-DPB5nEd5.js +10 -0
  42. package/apps/web/dist/assets/ProjectPage-408YOoNa.js +10 -0
  43. package/apps/web/dist/assets/{PublicRunner-bAakEGwv.js → PublicRunner-BZ66xdRX.js} +1 -1
  44. package/apps/web/dist/assets/{ReadOnly-MBVPGEhw.js → ReadOnly-C9oGMkUB.js} +1 -1
  45. package/apps/web/dist/assets/SettingsPage-Dq3AZwJS.js +2 -0
  46. package/apps/web/dist/assets/{SetupPage-CmTC9K8_.js → SetupPage-CP3lbyZc.js} +1 -1
  47. package/apps/web/dist/assets/{SharePage-D9_IxO3M.js → SharePage-DdMm1Y8K.js} +1 -1
  48. package/apps/web/dist/assets/SkillEditor-b5NMFB90.js +1 -0
  49. package/apps/web/dist/assets/changelog-82-DHogQ.js +1 -0
  50. package/apps/web/dist/assets/code-xml-Hx7YxCg0.js +1 -0
  51. package/apps/web/dist/assets/{dist-BwhPmMDu.js → dist-BdDd1FxP.js} +1 -1
  52. package/apps/web/dist/assets/dist-EBVTpvRr.js +10 -0
  53. package/apps/web/dist/assets/dist-GlRRx9Xl.js +1 -0
  54. package/apps/web/dist/assets/dist-H1UN89OA.js +1 -0
  55. package/apps/web/dist/assets/eye-BkMFLnYu.js +1 -0
  56. package/apps/web/dist/assets/i18n-CKKh3Pn0.js +55 -0
  57. package/apps/web/dist/assets/index-Cy2NHzAx.js +49 -0
  58. package/apps/web/dist/assets/index-wR_-1hfN.css +1 -0
  59. package/apps/web/dist/assets/json-CEsfHdlZ.js +1 -0
  60. package/apps/web/dist/assets/{lock-D1093O6-.js → lock-CGXM95Mi.js} +1 -1
  61. package/apps/web/dist/assets/markdown-5-I9_izp.js +29 -0
  62. package/apps/web/dist/assets/oss-credits-DpRWUPjD.js +1 -0
  63. package/apps/web/dist/assets/{phone-YeDiW-kN.js → phone-DMfwuh9V.js} +1 -1
  64. package/apps/web/dist/assets/{runners-DP0vYvTF.js → runners-D5qz6b_s.js} +1 -1
  65. package/apps/web/dist/assets/{session-Bio3Vaq1.js → session-DRy0k0nh.js} +1 -1
  66. package/apps/web/dist/assets/{theme-AlaEfdLQ.js → theme-DNPm6r4e.js} +2 -2
  67. package/apps/web/dist/assets/{ui-CU-cIuyK.js → ui-CwFQAfE-.js} +2 -2
  68. package/apps/web/dist/assets/{upload-DbWtEr1f.js → upload-DQJwLSGj.js} +1 -1
  69. package/apps/web/dist/assets/{useMutation-erJIov3t.js → useMutation-C20c2EH3.js} +1 -1
  70. package/apps/web/dist/assets/{volume-2-V1P9DYWO.js → volume-2-CC5qamYT.js} +1 -1
  71. package/apps/web/dist/index.html +9 -8
  72. package/apps/web/dist/mcp/flow.html +66 -66
  73. package/node_modules/@engenty/wizards/dist/plugin/studio.d.ts +3 -2
  74. package/node_modules/@engenty/wizards-shared/dist/feature-flags.d.ts +6 -0
  75. package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +6 -0
  76. package/node_modules/@engenty/wizards-shared/dist/live.d.ts +1 -1
  77. package/node_modules/@engenty/wizards-shared/dist/run.d.ts +1 -0
  78. package/node_modules/@engenty/wizards-shared/dist/run.js +2 -0
  79. package/node_modules/@engenty/wizards-shared/dist/skills.d.ts +165 -0
  80. package/node_modules/@engenty/wizards-shared/dist/skills.js +346 -0
  81. package/node_modules/@engenty/wizards-shared/dist/sync.d.ts +4 -2
  82. package/node_modules/@engenty/wizards-shared/dist/sync.js +2 -1
  83. package/package.json +11 -11
  84. package/plugin/.claude-plugin/plugin.json +1 -1
  85. package/plugin/plugin.json +1 -1
  86. package/apps/web/dist/assets/CodeEditor-BgUofYLQ.js +0 -2
  87. package/apps/web/dist/assets/EditorPage-DEOxHFXn.js +0 -3
  88. package/apps/web/dist/assets/Marketplace-Dt7ktvc3.js +0 -2
  89. package/apps/web/dist/assets/PreviewPane-BDzDuTz1.js +0 -10
  90. package/apps/web/dist/assets/ProjectPage-BqkkyEpP.js +0 -1
  91. package/apps/web/dist/assets/SettingsPage-DDe1BC-3.js +0 -2
  92. package/apps/web/dist/assets/changelog-iTu1De5h.js +0 -1
  93. package/apps/web/dist/assets/dist-DVpDdhG9.js +0 -1
  94. package/apps/web/dist/assets/dist-DzdNG7Sf.js +0 -10
  95. package/apps/web/dist/assets/i18n-7CvqRUdn.js +0 -55
  96. package/apps/web/dist/assets/index-CNwXyMzH.js +0 -49
  97. package/apps/web/dist/assets/index-Dxwbli0m.css +0 -1
  98. package/apps/web/dist/assets/json-D2GVvTXK.js +0 -1
  99. package/apps/web/dist/assets/markdown-DwdMW7q0.js +0 -29
  100. package/apps/web/dist/assets/oss-credits-Da4KrYmP.js +0 -1
@@ -1,5 +1,6 @@
1
1
  import { validateWizard } from "@engenty/wizards-shared/definition";
2
2
  import { tableColumnsSchema } from "@engenty/wizards-shared/engenty/data-tables";
3
+ import { SKILL_MODES, SKILL_SOURCES, } from "@engenty/wizards-shared/skills";
3
4
  import { themeSchema } from "@engenty/wizards-shared/theme";
4
5
  import { and, asc, eq, inArray, isNull, ne, sql } from "drizzle-orm";
5
6
  import { nanoid } from "nanoid";
@@ -883,6 +884,83 @@ const connector = {
883
884
  },
884
885
  title: (r, item) => str(obj(r?.record).name) ?? splitTwo(item)[1],
885
886
  };
887
+ const skill = {
888
+ async read(id) {
889
+ const k = await db.query.spaceSkill.findFirst({
890
+ where: and(eq(schema.spaceSkill.id, id), eq(schema.spaceSkill.tenantId, currentTenant())),
891
+ });
892
+ if (!k) {
893
+ return null;
894
+ }
895
+ return {
896
+ projectId: k.projectId,
897
+ record: {
898
+ projectId: k.projectId,
899
+ name: k.name,
900
+ description: k.description,
901
+ body: k.body,
902
+ meta: k.meta,
903
+ files: k.files,
904
+ blobFiles: k.blobFiles,
905
+ mode: k.mode,
906
+ runScripts: k.runScripts,
907
+ source: k.source,
908
+ origin: k.origin,
909
+ originHash: k.originHash,
910
+ },
911
+ };
912
+ },
913
+ async write(projectId, id, r) {
914
+ const mode = SKILL_MODES.find((m) => m === r.mode) ?? "demand";
915
+ const source = SKILL_SOURCES.find((m) => m === r.source) ?? "own";
916
+ const values = {
917
+ projectId,
918
+ name: str(r.name) ?? id.toLowerCase(),
919
+ description: str(r.description) ?? "",
920
+ body: str(r.body) ?? "",
921
+ meta: obj(r.meta),
922
+ files: arr(r.files).filter((f) => typeof f?.path === "string" && typeof f?.text === "string"),
923
+ blobFiles: arr(r.blobFiles).filter((f) => typeof f?.path === "string" &&
924
+ /^[a-f0-9]{64}$/.test(String(f?.hash)) &&
925
+ typeof f?.bytes === "number"),
926
+ mode,
927
+ runScripts: r.runScripts === true,
928
+ source,
929
+ origin: str(r.origin),
930
+ originHash: str(r.originHash),
931
+ };
932
+ // Two sides named a skill alike: the one arriving takes the name with its id behind it.
933
+ const clash = await db.query.spaceSkill.findFirst({
934
+ where: and(eq(schema.spaceSkill.projectId, projectId), eq(schema.spaceSkill.name, values.name), ne(schema.spaceSkill.id, id)),
935
+ columns: { id: true },
936
+ });
937
+ if (clash) {
938
+ values.name =
939
+ `${values.name.slice(0, 50)}-${id.toLowerCase().replace(/[^a-z0-9]/g, "")}`.slice(0, 64);
940
+ }
941
+ await db
942
+ .insert(schema.spaceSkill)
943
+ .values({ id, tenantId: currentTenant(), ...values })
944
+ .onConflictDoUpdate({
945
+ target: schema.spaceSkill.id,
946
+ set: { ...values, updatedAt: new Date() },
947
+ });
948
+ return undefined;
949
+ },
950
+ async remove(_projectId, id) {
951
+ await db.delete(schema.spaceSkill).where(eq(schema.spaceSkill.id, id));
952
+ return undefined;
953
+ },
954
+ async list(projectId) {
955
+ const rows = await db
956
+ .select({ id: schema.spaceSkill.id })
957
+ .from(schema.spaceSkill)
958
+ .where(eq(schema.spaceSkill.projectId, projectId));
959
+ return rows.map((r) => r.id);
960
+ },
961
+ title: (r, item) => str(r?.name) ?? item,
962
+ blobs: (r) => arr(r.blobFiles).map((f) => String(f.hash)),
963
+ };
886
964
  export const KINDS = {
887
965
  space,
888
966
  wizard,
@@ -894,10 +972,11 @@ export const KINDS = {
894
972
  category,
895
973
  file,
896
974
  connector,
975
+ skill,
897
976
  };
898
977
  /**
899
978
  * The order items are written in, so what one points to is there first: the space, its files,
900
- * tables and categories, then rows, pages, connectors, wizards and what belongs to them.
979
+ * tables and categories, then rows, pages, connectors, skills, wizards and what belongs to them.
901
980
  */
902
981
  export const KIND_ORDER = [
903
982
  "space",
@@ -907,6 +986,7 @@ export const KIND_ORDER = [
907
986
  "row",
908
987
  "page",
909
988
  "connector",
989
+ "skill",
910
990
  "wizard",
911
991
  "translation",
912
992
  "message",
@@ -45,6 +45,7 @@ const EN = {
45
45
  doingSetFacts: "Entering facts…",
46
46
  doingSetColors: "Entering the colours…",
47
47
  doingLookAtFile: "Looking at a file…",
48
+ doingReadSkill: "Reading the skill {name}…",
48
49
  doingDescribeFile: "Describing a file…",
49
50
  doingWebSearch: "Searching the web…",
50
51
  doingReadSite: "Reading {host}…",
@@ -189,6 +190,25 @@ const EN = {
189
190
  fontRoleAll: "Headings and body text",
190
191
  fontRoleHeadings: "Headings",
191
192
  fontRoleText: "Body text",
193
+ // Skills of a space (services/skills.ts).
194
+ skillName: "A skill’s name has lower-case letters, digits and hyphens, at most 64.",
195
+ skillNameTaken: "The space has a skill named “{name}” already.",
196
+ skillDescription: "A skill needs a description of at most 1024 characters.",
197
+ skillTooLarge: "The skill is too large. Its SKILL.md may have 100 KB, each file 256 KB, all of it 1 MB and 100 files.",
198
+ skillFilePath: "“{path}” is not a path a skill can hold.",
199
+ skillFileText: "“{path}” is not a text file. A skill holds text files only.",
200
+ skillsTooMany: "A space holds at most 100 skills.",
201
+ skillsAlwaysCount: "At most 5 skills can be always on. Switch one to on demand first.",
202
+ skillsAlwaysChars: "Skills that are always on may have 20,000 characters together. With this one it would be {n}. Switch one to on demand or shorten it.",
203
+ skillMdFrontmatter: "The SKILL.md has no front matter. It starts with a line ---, then name and description, then --- again.",
204
+ skillMdName: "The SKILL.md names no skill: its front matter has no name.",
205
+ skillMdDescription: "The SKILL.md has no description in its front matter.",
206
+ skillNoSkillMd: "The upload holds no SKILL.md.",
207
+ skillUploadKind: "Upload a SKILL.md, a .zip or a .skill file.",
208
+ skillReadOnly: "A skill from skills.sh stays as it is. Copy it as your own skill to change it.",
209
+ skillsRegistryDown: "skills.sh did not answer. Try again in a moment.",
210
+ skillsRegistryMissing: "skills.sh has no skill at {ref}.",
211
+ skillUpdateChanged: "skills.sh changed the skill again since you looked. Look at the changes once more.",
192
212
  };
193
213
  const DE = {
194
214
  keyUnknown: "Der Anbieter kennt diesen API-Key nicht.",
@@ -230,6 +250,7 @@ const DE = {
230
250
  doingSetFacts: "Trägt Fakten ein …",
231
251
  doingSetColors: "Trägt die Farben ein …",
232
252
  doingLookAtFile: "Sieht sich eine Datei an …",
253
+ doingReadSkill: "Liest den Skill {name} …",
233
254
  doingDescribeFile: "Beschreibt eine Datei …",
234
255
  doingWebSearch: "Sucht im Web …",
235
256
  doingReadSite: "Liest {host} …",
@@ -372,6 +393,24 @@ const DE = {
372
393
  fontRoleAll: "Überschriften und Fließtext",
373
394
  fontRoleHeadings: "Überschriften",
374
395
  fontRoleText: "Fließtext",
396
+ skillName: "Der Name eines Skills hat Kleinbuchstaben, Ziffern und Bindestriche, höchstens 64.",
397
+ skillNameTaken: "Im Space gibt es schon einen Skill „{name}“.",
398
+ skillDescription: "Ein Skill braucht eine Beschreibung mit höchstens 1024 Zeichen.",
399
+ skillTooLarge: "Der Skill ist zu groß. SKILL.md darf 100 KB haben, jede Datei 256 KB, alles zusammen 1 MB und 100 Dateien.",
400
+ skillFilePath: "„{path}“ ist kein Pfad, den ein Skill haben kann.",
401
+ skillFileText: "„{path}“ ist keine Textdatei. Ein Skill hält nur Textdateien.",
402
+ skillsTooMany: "Ein Space hält höchstens 100 Skills.",
403
+ skillsAlwaysCount: "Höchstens 5 Skills können immer an sein. Stell zuerst einen auf Bei Bedarf.",
404
+ skillsAlwaysChars: "Skills, die immer an sind, dürfen zusammen 20.000 Zeichen haben. Mit diesem wären es {n}. Stell einen auf Bei Bedarf oder kürze ihn.",
405
+ skillMdFrontmatter: "Der SKILL.md fehlt der Kopf. Sie beginnt mit einer Zeile ---, dann name und description, dann wieder ---.",
406
+ skillMdName: "Die SKILL.md nennt keinen Namen: In ihrem Kopf fehlt name.",
407
+ skillMdDescription: "In ihrem Kopf fehlt der SKILL.md die description.",
408
+ skillNoSkillMd: "Im Upload ist keine SKILL.md.",
409
+ skillUploadKind: "Lade eine SKILL.md, eine .zip- oder eine .skill-Datei hoch.",
410
+ skillReadOnly: "Ein Skill von skills.sh bleibt, wie er ist. Kopier ihn als eigenen Skill, um ihn zu ändern.",
411
+ skillsRegistryDown: "skills.sh antwortet nicht. Versuch es gleich noch einmal.",
412
+ skillsRegistryMissing: "Auf skills.sh gibt es keinen Skill unter {ref}.",
413
+ skillUpdateChanged: "skills.sh hat den Skill seitdem wieder geändert. Sieh dir die Änderungen noch einmal an.",
375
414
  };
376
415
  export const SERVER_TEXTS = { en: EN, de: DE };
377
416
  /** A line of the server's table in a language; English where the language lacks it. */
@@ -20,6 +20,7 @@ import { pageTools } from "./pages.js";
20
20
  import { pluginTools, spaceContextOf } from "./plugin.js";
21
21
  import { projectTools } from "./project.js";
22
22
  import { clip, FileKeeper } from "./shared.js";
23
+ import { skillTools } from "./skills.js";
23
24
  import { storeTools } from "./store.js";
24
25
  /**
25
26
  * Whether a fetched body is text a model can read: a text type, or no type and next to no
@@ -157,6 +158,8 @@ export async function buildStepTools(step, ctx, resolved, uploads) {
157
158
  Object.assign(tools, storeTools(ctx, uploads, files));
158
159
  }
159
160
  Object.assign(tools, await projectTools(ctx));
161
+ const sandbox = allowed.has("sandbox") ? sandboxCapabilities() : null;
162
+ Object.assign(tools, await skillTools(ctx, sandbox ? { handle: () => ctx.resources.sandboxHandle(), workdir: sandbox.workdir } : null));
160
163
  Object.assign(tools, mailTools(step, ctx, files));
161
164
  Object.assign(tools, await connectorTools(step, ctx, files));
162
165
  Object.assign(tools, await pluginTools(step, ctx));
@@ -164,8 +167,7 @@ export async function buildStepTools(step, ctx, resolved, uploads) {
164
167
  if (allowed.has("pages")) {
165
168
  Object.assign(tools, pageTools(ctx));
166
169
  }
167
- const sandbox = sandboxCapabilities();
168
- if (allowed.has("sandbox") && sandbox) {
170
+ if (sandbox) {
169
171
  const timeoutMs = (seconds) => Math.min((seconds ?? 120) * 1000, 600_000);
170
172
  const report = (result) => ({
171
173
  exitCode: result.exitCode,
@@ -1,6 +1,6 @@
1
1
  import { lookup } from "node:dns/promises";
2
2
  import { BlockList, isIP } from "node:net";
3
- import { Agent } from "undici";
3
+ import { Agent, fetch as pinnedFetch } from "undici";
4
4
  import { prompt } from "../prompts.js";
5
5
  const ALLOW_PRIVATE = process.env.ALLOW_PRIVATE_FETCH === "1";
6
6
  /** Ranges that are not the public internet: this server, its networks, and special purposes. */
@@ -151,15 +151,19 @@ const pinned = new Agent({
151
151
  },
152
152
  },
153
153
  });
154
- /** fetch that re-checks every redirect hop, so a public URL cannot bounce into the private network. */
154
+ /**
155
+ * fetch that re-checks every redirect hop, so a public URL cannot bounce into the private network.
156
+ * It is undici's own fetch: the global one bundles Node's undici, which cannot drive this
157
+ * version's Agent.
158
+ */
155
159
  export async function safeFetch(raw, init = {}) {
156
160
  let url = await assertPublicUrl(raw);
157
161
  for (let hop = 0; hop < 6; hop++) {
158
- const res = await fetch(url, {
162
+ const res = (await pinnedFetch(url, {
159
163
  ...init,
160
164
  redirect: "manual",
161
165
  dispatcher: pinned,
162
- });
166
+ }));
163
167
  const location = res.headers.get("location");
164
168
  if (res.status < 300 || res.status >= 400 || !location) {
165
169
  return res;
@@ -0,0 +1,197 @@
1
+ import { skillMd } from "@engenty/wizards-shared/skills";
2
+ import { createTool } from "@mastra/core/tools";
3
+ import { z } from "zod";
4
+ import { getBlob } from "../files/blobs.js";
5
+ import { prompt } from "../prompts.js";
6
+ import { activeSkills } from "../services/skills.js";
7
+ import { attempt, clip } from "./shared.js";
8
+ const found = new WeakMap();
9
+ /** The space's skills that count, asked once per step. */
10
+ export function skillsOf(ctx) {
11
+ let skills = found.get(ctx);
12
+ if (!skills) {
13
+ skills = activeSkills(ctx.project.id);
14
+ found.set(ctx, skills);
15
+ }
16
+ return skills;
17
+ }
18
+ /** A skill whose scripts may run, with files for them to be. */
19
+ const runnable = (k) => k.runScripts && (k.files.length > 0 || k.blobFiles.length > 0);
20
+ /** Where a skill's folder goes, from the sandbox's working directory. */
21
+ export const skillFolder = (name) => `skills/${name}`;
22
+ /** A sandbox's skill folders written so far, by name and version: each once per run. */
23
+ const placed = new WeakMap();
24
+ /** Writes a skill's folder, `SKILL.md` and every file, into the sandbox; a few files at a time. */
25
+ async function writeFolder(sandbox, k) {
26
+ const folder = skillFolder(k.name);
27
+ await sandbox.exec(`rm -rf ${folder}`);
28
+ const files = [
29
+ ["SKILL.md", async () => skillMd(k)],
30
+ ...k.files.map((f) => [f.path, async () => f.text]),
31
+ ...k.blobFiles.map((f) => [
32
+ f.path,
33
+ async () => new Uint8Array(await getBlob(f.hash)),
34
+ ]),
35
+ ];
36
+ // Each write is a command or two in the sandbox: eight go at once.
37
+ for (let i = 0; i < files.length; i += 8) {
38
+ await Promise.all(files
39
+ .slice(i, i + 8)
40
+ .map(async ([path, data]) => sandbox.writeFile(`${folder}/${path}`, await data())));
41
+ }
42
+ }
43
+ /** Puts a skill's folder into the sandbox, unless this run has it already as it is now. */
44
+ export function placeSkill(sandbox, k) {
45
+ let done = placed.get(sandbox);
46
+ if (!done) {
47
+ done = new Map();
48
+ placed.set(sandbox, done);
49
+ }
50
+ const key = `${k.name}@${k.updatedAt.getTime()}`;
51
+ let write = done.get(key);
52
+ if (!write) {
53
+ const map = done;
54
+ write = writeFolder(sandbox, k);
55
+ map.set(key, write);
56
+ write.catch(() => map.delete(key));
57
+ }
58
+ return write;
59
+ }
60
+ const filesLine = (k) => k.files.length
61
+ ? prompt("step", "skills.files", { files: k.files.map((f) => f.path).join(", ") })
62
+ : "";
63
+ /**
64
+ * What a step's instructions say of the space's skills: the ones always on whole, then the
65
+ * ones on demand by name and description, then which of them bring scripts that run. `tools`:
66
+ * the model can call tools; a client that cannot (an on-device model) gets the skills always on
67
+ * alone. `sandbox`: the step has the sandbox, where scripts run.
68
+ */
69
+ export function skillsBlock(skills, { tools, sandbox = false }) {
70
+ const parts = [];
71
+ if (skills.always.length) {
72
+ parts.push([
73
+ prompt("step", "skills.always"),
74
+ ...skills.always.map((k) => [`<skill name="${k.name}">`, k.body.trim(), tools ? filesLine(k) : "", "</skill>"]
75
+ .filter(Boolean)
76
+ .join("\n")),
77
+ ].join("\n\n"));
78
+ }
79
+ if (tools && skills.demand.length) {
80
+ parts.push([
81
+ prompt("step", "skills.demand"),
82
+ ...skills.demand.map((k) => `- ${k.name}: ${k.description}`),
83
+ ].join("\n"));
84
+ }
85
+ const scripts = tools && sandbox ? [...skills.always, ...skills.demand].filter(runnable) : [];
86
+ if (scripts.length) {
87
+ parts.push(prompt("step", "skills.scripts", { names: scripts.map((k) => k.name).join(", ") }));
88
+ }
89
+ return parts.join("\n\n");
90
+ }
91
+ const byName = (skills, name) => [...skills.always, ...skills.demand].find((k) => k.name === name.trim().toLowerCase());
92
+ /**
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
+ */
97
+ export function skillToolsOf(skills, onRead, sandbox = null) {
98
+ const readable = [...skills.always, ...skills.demand];
99
+ if (!(skills.demand.length || skills.always.some((k) => k.files.length || (sandbox && runnable(k))))) {
100
+ return {};
101
+ }
102
+ const names = readable.map((k) => k.name).join(", ");
103
+ const runs = Boolean(sandbox && readable.some(runnable));
104
+ /** Where the skill's folder is in the sandbox, or why it isn't: only for a skill that runs. */
105
+ const place = async (k) => {
106
+ if (!(sandbox && runnable(k))) {
107
+ return null;
108
+ }
109
+ const folder = `${sandbox.workdir}/${skillFolder(k.name)}`;
110
+ try {
111
+ await placeSkill(sandbox.handle(), k);
112
+ }
113
+ catch (err) {
114
+ const error = String(err?.message ?? err).slice(0, 300);
115
+ return { scripts: prompt("tools", "note.skill_folder_failed", { error }) };
116
+ }
117
+ return {
118
+ folder,
119
+ scripts: prompt("tools", "note.skill_folder", { folder: skillFolder(k.name) }),
120
+ };
121
+ };
122
+ return {
123
+ skill_load: createTool({
124
+ id: "skill_load",
125
+ 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);
129
+ if (!k) {
130
+ return { error: prompt("tools", "note.skill_unknown", { name, names }) };
131
+ }
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
+ };
142
+ }),
143
+ }),
144
+ skill_read: createTool({
145
+ id: "skill_read",
146
+ description: runs
147
+ ? prompt("tools", "tool.skill_read")
148
+ : `${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 () => {
155
+ const k = byName(skills, name);
156
+ if (!k) {
157
+ return { error: prompt("tools", "note.skill_unknown", { name, names }) };
158
+ }
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
+ };
187
+ }),
188
+ }),
189
+ };
190
+ }
191
+ /**
192
+ * The skill tools of an AI step: what it reads goes into the run's events. `sandbox`: the
193
+ * step's sandbox, where the folders of skills whose scripts may run go.
194
+ */
195
+ export async function skillTools(ctx, sandbox = null) {
196
+ return skillToolsOf(await skillsOf(ctx), (name) => ctx.emit("tool", { code: "readsSkill", params: { name } }), sandbox);
197
+ }
@@ -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{Bn as r,Jt as i,Nn as a,Xt as o,Yt as s,in as c,on as l,qt as u,sn as d,tn as f}from"./ui-CU-cIuyK.js";import{t as p}from"./preload-helper-DpV6A1kQ.js";import{t as m}from"./logo-CGNoptDg.js";import{s as h}from"./i18n-7CvqRUdn.js";import{Mt as g,Nt as _,V as v,et as y,it as b}from"./index-CNwXyMzH.js";import{ReleaseNotes as x,loadReleases as S,releaseDate as C,releaseLabel as w}from"./ChangelogDialog-I9DEn_ra.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:r,description:i}){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)(a,{"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:r})]}),i?(0,O.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-3`,children:i}):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-Da4KrYmP.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)(o,{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)(i,{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 i=e?.mode===`local`,{data:a,latest:o}=g(i&&t),[s,u]=(0,T.useState)(null),[d,p]=(0,T.useState)(n);(0,T.useEffect)(()=>p(n),[n]);let E=b(F.indexOf(d)),D=a?.newer&&o?o:_;(0,T.useEffect)(()=>{if(!t)return;let e=!1;return u(null),S(D===`0.12.0`?void 0:D).then(t=>{e||u(t)}),()=>{e=!0}},[t,D]);let k=s?.find(e=>e.version===`v${D}`)??s?.[0]??null,A=s?.filter(e=>e!==k)??[],j=i?a?.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:_}),j?` · ${h(`about.kind.${j}`)}`:``]})]}),i?(0,O.jsx)(`div`,{className:`mt-5`,children:(0,O.jsx)(v,{enabled:t})}):null,(0,O.jsx)(`div`,{className:`mt-6 flex justify-center`,children:(0,O.jsx)(c,{value:d,onChange:p,options:F.map(e=>({id:e,label:I(e)})),label:h(`about.title`)})}),(0,O.jsxs)(`div`,{className:l(`mt-5`,y(E)),children:[d===`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,d===`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)(r,{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,d===`credits`?(0,O.jsx)(P,{active:!0}):null]},d)]})}function z({open:e,onClose:t,me:n}){return(0,O.jsxs)(u,{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)(s,{label:h(`common.close`),onClick:t,children:(0,O.jsx)(d,{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{Bn as r,Jt as i,Nn as a,Xt as o,Yt as s,in as c,on as l,qt as u,sn as d,tn as f}from"./ui-CwFQAfE-.js";import{t as p}from"./preload-helper-DpV6A1kQ.js";import{t as m}from"./logo-CGNoptDg.js";import{s as h}from"./i18n-CKKh3Pn0.js";import{Mt as g,Nt as _,V as v,et as y,it as b}from"./index-Cy2NHzAx.js";import{ReleaseNotes as x,loadReleases as S,releaseDate as C,releaseLabel as w}from"./ChangelogDialog-CKLgFL6r.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:r,description:i}){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)(a,{"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:r})]}),i?(0,O.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-3`,children:i}):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-DpRWUPjD.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)(o,{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)(i,{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 i=e?.mode===`local`,{data:a,latest:o}=g(i&&t),[s,u]=(0,T.useState)(null),[d,p]=(0,T.useState)(n);(0,T.useEffect)(()=>p(n),[n]);let E=b(F.indexOf(d)),D=a?.newer&&o?o:_;(0,T.useEffect)(()=>{if(!t)return;let e=!1;return u(null),S(D===`0.12.2`?void 0:D).then(t=>{e||u(t)}),()=>{e=!0}},[t,D]);let k=s?.find(e=>e.version===`v${D}`)??s?.[0]??null,A=s?.filter(e=>e!==k)??[],j=i?a?.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:_}),j?` · ${h(`about.kind.${j}`)}`:``]})]}),i?(0,O.jsx)(`div`,{className:`mt-5`,children:(0,O.jsx)(v,{enabled:t})}):null,(0,O.jsx)(`div`,{className:`mt-6 flex justify-center`,children:(0,O.jsx)(c,{value:d,onChange:p,options:F.map(e=>({id:e,label:I(e)})),label:h(`about.title`)})}),(0,O.jsxs)(`div`,{className:l(`mt-5`,y(E)),children:[d===`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,d===`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)(r,{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,d===`credits`?(0,O.jsx)(P,{active:!0}):null]},d)]})}function z({open:e,onClose:t,me:n}){return(0,O.jsxs)(u,{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)(s,{label:h(`common.close`),onClick:t,children:(0,O.jsx)(d,{className:`size-4`})})}),(0,O.jsx)(R,{me:n,active:e})]})}export{z as AboutDialog,R as AboutPanel};
@@ -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{Jt as r,Xt as i,on as a,qt as o,tn as s}from"./ui-CU-cIuyK.js";import{t as c}from"./preload-helper-DpV6A1kQ.js";import{s as l}from"./i18n-7CvqRUdn.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-iTu1De5h.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:a(`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[a,c]=(0,u.useState)(null),[f,h]=(0,u.useState)(``);(0,u.useEffect)(()=>{if(!e||a)return;let t=!1;return _(n).then(e=>{t||c(e)}),()=>{t=!0}},[e,a,n]),(0,u.useEffect)(()=>{e||h(``)},[e]);let y=a?g(a,f):[];return(0,d.jsxs)(o,{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`)}),a===null?(0,d.jsx)(`div`,{className:`flex justify-center py-10 text-ink-3`,children:(0,d.jsx)(s,{})}):a.length===0?(0,d.jsx)(r,{children:l(`about.changelogEmpty`)}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(i,{type:`search`,value:f,placeholder:l(`about.search`),onChange:e=>h(e.target.value)}),y.length===0?(0,d.jsx)(r,{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{Jt as r,Xt as i,on as a,qt as o,tn as s}from"./ui-CwFQAfE-.js";import{t as c}from"./preload-helper-DpV6A1kQ.js";import{s as l}from"./i18n-CKKh3Pn0.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-82-DHogQ.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:a(`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[a,c]=(0,u.useState)(null),[f,h]=(0,u.useState)(``);(0,u.useEffect)(()=>{if(!e||a)return;let t=!1;return _(n).then(e=>{t||c(e)}),()=>{t=!0}},[e,a,n]),(0,u.useEffect)(()=>{e||h(``)},[e]);let y=a?g(a,f):[];return(0,d.jsxs)(o,{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`)}),a===null?(0,d.jsx)(`div`,{className:`flex justify-center py-10 text-ink-3`,children:(0,d.jsx)(s,{})}):a.length===0?(0,d.jsx)(r,{children:l(`about.changelogEmpty`)}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(i,{type:`search`,value:f,placeholder:l(`about.search`),onChange:e=>h(e.target.value)}),y.length===0?(0,d.jsx)(r,{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};
@@ -0,0 +1,2 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{s as r}from"./i18n-CKKh3Pn0.js";import{B as i,D as a,E as o,F as s,I as c,N as l,O as u,R as d,S as f,T as p,U as m,V as h,W as g,_,a as v,b as y,c as b,g as x,h as ee,j as S,k as C,l as w,p as te,r as T,s as ne,t as E,v as re,z as ie}from"./dist-EBVTpvRr.js";import{n as ae}from"./dist-GlRRx9Xl.js";import{n as oe,r as se,t as ce}from"./dist-H1UN89OA.js";var D=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,O=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(D(e)):D,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return ie(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=g(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=i(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n,a=!0;;e++){let n=r.charCodeAt(e),o=this.match(n,i,a,this.bufferPos+this.bufferStart,e==r.length-1);if(o)return this.value=o,this;if(e==r.length-1)break;a&&e<t.length&&t.charCodeAt(e)==n?i++:a=!1}}}match(e,t,n,r,i){let a=null;for(let t=0;t<this.matches.length;){let n=this.matches[t],o=!1;this.query.charCodeAt(n.index)==e&&(n.index==this.query.length-1?a={from:n.from,to:r,precise:i&&n.precise}:(n.index++,o=!0)),o?t++:this.matches.splice(t,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?a={from:t,to:r,precise:n&&i}:this.matches.push({from:t,index:1,precise:n})),a&&this.test&&!this.test(a.from,a.to,this.buffer,this.bufferStart)&&(a=null),a}};typeof Symbol<`u`&&(O.prototype[Symbol.iterator]=function(){return this});var le={from:-1,to:-1,match:/.*/.exec(``),precise:!0},k=`gm`+(/x/.unicode==null?``:`u`),ue=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=le,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new j(e,t,n,r,i);this.re=new RegExp(t,k+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter();let a=e.lineAt(r);this.curLineStart=a.from,this.matchPos=M(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=M(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},A=new WeakMap,de=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=A.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return A.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),A.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},j=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=le,this.matchPos=M(e,r),this.re=new RegExp(t,k+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=de.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,precise:!0,match:t},this.matchPos=M(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=de.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(ue.prototype[Symbol.iterator]=j.prototype[Symbol.iterator]=function(){return this});function fe(e){try{return new RegExp(e,k),!0}catch{return!1}}function M(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var pe=e=>{let t=b(e,`cm-goto-line`);if(t){let e=t.dom.querySelector(`input[type=text]`);return e&&e.select(),!0}let{state:n}=e,r=String(n.doc.lineAt(e.state.selection.main.head).number),{close:i,result:o}=_(e,{class:`cm-goto-line`,label:n.phrase(`Go to line`),input:{type:`text`,name:`line`,value:r},focus:!0,submitLabel:n.phrase(`go`)});return o.then(t=>{let r=t&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.elements.line.value);if(!r){e.dispatch({effects:i});return}let o=n.doc.lineAt(n.selection.main.head),[,s,c,l,u]=r,d=l?+l.slice(1):0,f=c?+c:o.number;if(c&&u){let e=f/100;s&&(e=e*(s==`-`?-1:1)+o.number/n.doc.lines),f=Math.round(n.doc.lines*e)}else c&&s&&(f=f*(s==`-`?-1:1)+o.number);let p=n.doc.line(Math.max(1,Math.min(n.doc.lines,f))),m=a.cursor(p.from+Math.max(0,Math.min(d,p.length)));e.dispatch({effects:[i,T.scrollIntoView(m.from,{y:`center`})],selection:m})}),!0},me={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},he=C.define({combine(e){return h(e,me,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function ge(e){let t=[Se,xe];return e&&t.push(he.of(e)),t}var _e=E.mark({class:`cm-selectionMatch`}),ve=E.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function ye(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=p.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=p.Word)}function be(e,t,n,r){return e(t.sliceDoc(n,n+1))==p.Word&&e(t.sliceDoc(r-1,r))==p.Word}var xe=v.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(he),{state:n}=e,r=n.selection;if(r.ranges.length>1)return E.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return E.none;let e=n.wordAt(i.head);if(!e)return E.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return E.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(ye(o,n,i.from,i.to)&&be(o,n,i.from,i.to)))return E.none}else if(a=n.sliceDoc(i.from,i.to),!a)return E.none}let s=[];for(let r of e.visibleRanges){let e=new O(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||ye(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(ve.range(r,a)):(r>=i.to||a<=i.from)&&s.push(_e.range(r,a)),s.length>t.maxMatches))return E.none}}return E.set(s)}},{decorations:e=>e.decorations}),Se=T.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),Ce=({state:e,dispatch:t})=>{let{selection:n}=e,r=a.create(n.ranges.map(t=>e.wordAt(t.head)||a.cursor(t.head)),n.mainIndex);return!r.eq(n)&&(t(e.update({selection:r})),!0)};function we(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new O(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new O(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var Te=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return Ce({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=we(e,r);return i?(t(e.update({selection:e.selection.addRange(a.range(i.from,i.to),!1),effects:T.scrollIntoView(i.to)})),!0):!1},N=C.define({combine(e){return h(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new qe(e),scrollToMatch:e=>T.scrollIntoView(e)})}});function Ee(e){return e?[N.of(e),Z]:Z}var De=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||fe(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
2
+ `:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new Pe(this):new je(this)}getCursor(e,t=0,n){let r=e.doc?e:u.create({doc:e});return n??=r.doc.length,this.regexp?F(this,r,t,n):P(this,r,t,n)}},Oe=class{constructor(e){this.spec=e}};function ke(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function P(e,t,n,r){let i;return e.wholeWord&&(i=Ae(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=ke(e.test,t,i)),new O(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function Ae(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(I(i,n-a))!=p.Word||t(L(i,n-a))!=p.Word)&&(t(L(i,r-a))!=p.Word||t(I(i,r-a))!=p.Word))}var je=class extends Oe{constructor(e){super(e)}nextMatch(e,t,n){let r=P(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=P(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=P(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=P(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=P(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function Me(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function F(e,t,n,r){let i;return e.wholeWord&&(i=Ne(t.charCategorizer(t.selection.main.head))),e.test&&(i=Me(e.test,t,i)),new ue(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function I(e,t){return e.slice(m(e,t,!1),t)}function L(e,t){return e.slice(t,m(e,t))}function Ne(e){return(t,n,r)=>!r[0].length||(e(I(r.input,r.index))!=p.Word||e(L(r.input,r.index))!=p.Word)&&(e(L(r.input,r.index+r[0].length))!=p.Word||e(I(r.input,r.index+r[0].length))!=p.Word)}var Pe=class extends Oe{nextMatch(e,t,n){let r=F(this.spec,e,n,e.doc.length).next();return r.done&&(r=F(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=F(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=F(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=F(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},R=s.define(),z=s.define(),B=c.define({create(e){return new V(K(e).create(),null)},update(e,t){for(let n of t.effects)n.is(R)?e=new V(n.value.create(),e.panel):n.is(z)&&(e=new V(e.query,n.value?G:null));return e},provide:e=>re.from(e,e=>e.panel)}),V=class{constructor(e,t){this.query=e,this.panel=t}},Fe=E.mark({class:`cm-searchMatch`}),Ie=E.mark({class:`cm-searchMatch cm-searchMatch-selected`}),Le=v.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(B))}update(e){let t=e.state.field(B);(t!=e.startState.field(B)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return E.none;let{view:n}=this,r=new l;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?Ie:Fe)})}return r.finish()}},{decorations:e=>e.decorations});function H(e){return t=>{let n=t.state.field(B,!1);return n&&n.query.spec.valid?e(t,n):We(t)}}var U=H((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=a.single(r.from,r.to),o=e.state.facet(N);return e.dispatch({selection:i,effects:[X(e,r),o.scrollToMatch(i.main,e)],userEvent:`select.search`}),Ue(e),!0}),W=H((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let o=a.single(i.from,i.to),s=e.state.facet(N);return e.dispatch({selection:o,effects:[X(e,i),s.scrollToMatch(o.main,e)],userEvent:`select.search`}),Ue(e),!0}),Re=H((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:a.create(n.map(e=>a.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),ze=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,o=[],s=0;for(let t=new O(e.doc,e.sliceDoc(r,i));!t.next().done;){if(o.length>1e3)return!1;t.value.from==r&&(s=o.length),o.push(a.range(t.value.from,t.value.to))}return t(e.update({selection:a.create(o,s),userEvent:`select.search.matches`})),!0},Be=H((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let o=t.nextMatch(n,r,r);if(!o)return!1;let s=o,c=[],l,u,d=[];s.precise?s.from==r&&s.to==i&&(u=n.toText(t.getReplacement(s)),c.push({from:s.from,to:s.to,insert:u}),s=t.nextMatch(n,s.from,s.to),d.push(T.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`))):s=t.nextMatch(n,s.from,s.to);let f=e.state.changes(c);return s&&(l=a.single(s.from,s.to).map(f),d.push(X(e,s)),d.push(n.facet(N).scrollToMatch(l.main,e))),e.dispatch({changes:f,selection:l,effects:d,userEvent:`input.replace`}),!0}),Ve=H((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let r of t.matchAll(e.state,1e9)){let{from:e,to:i,precise:a}=r;a&&n.push({from:e,to:i,insert:t.getReplacement(r)})}if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:T.announce.of(r),userEvent:`input.replace.all`}),!0});function G(e){return e.state.facet(N).createPanel(e)}function K(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(N);return new De({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function He(e){let t=w(e,G);return t&&t.dom.querySelector(`[main-field]`)}function Ue(e){let t=He(e);t&&t==e.root.activeElement&&t.select()}var We=e=>{let t=e.state.field(B,!1);if(t&&t.panel){let n=He(e);if(n&&n!=e.root.activeElement){let r=K(e.state,t.query.spec);r.valid&&e.dispatch({effects:R.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[z.of(!0),t?R.of(K(e.state,t.query.spec)):s.appendConfig.of(Z)]});return!0},Ge=e=>{let t=e.state.field(B,!1);if(!t||!t.panel)return!1;let n=w(e,G);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:z.of(!1)}),!0},Ke=[{key:`Mod-f`,run:We,scope:`editor search-panel`},{key:`F3`,run:U,shift:W,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:U,shift:W,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:Ge,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:ze},{key:`Mod-Alt-g`,run:pe},{key:`Mod-d`,run:Te,preventDefault:!0}],qe=class{constructor(e){this.view=e;let t=this.query=e.state.field(B).query.spec;this.commit=this.commit.bind(this),this.searchField=y(`input`,{value:t.search,placeholder:q(e,`Find`),"aria-label":q(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=y(`input`,{value:t.replace,placeholder:q(e,`Replace`),"aria-label":q(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=y(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=y(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=y(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return y(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=y(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>U(e),[q(e,`next`)]),n(`prev`,()=>W(e),[q(e,`previous`)]),n(`select`,()=>Re(e),[q(e,`all`)]),y(`label`,null,[this.caseField,q(e,`match case`)]),y(`label`,null,[this.reField,q(e,`regexp`)]),y(`label`,null,[this.wordField,q(e,`by word`)]),...e.state.readOnly?[]:[y(`br`),this.replaceField,n(`replace`,()=>Be(e),[q(e,`replace`)]),n(`replaceAll`,()=>Ve(e),[q(e,`replace all`)])],y(`button`,{name:`close`,onclick:()=>Ge(e),"aria-label":q(e,`close`),type:`button`},[`×`])])}commit(){let e=new De({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:R.of(e)}))}keydown(e){x(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?W:U)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),Be(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(R)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(N).top}};function q(e,t){return e.state.phrase(t)}var J=30,Y=/[\s\.,:;?!]/;function X(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-J),o=Math.min(i,n+J),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<J;e++)if(!Y.test(s[e+1])&&Y.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-J;e--)if(!Y.test(s[e-1])&&Y.test(s[e])){s=s.slice(0,e);break}}return T.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var Je=T.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),Z=[B,S.low(Le),Je],Q=e(t(),1),Ye=e(n(),1),$=f.define();function Xe(e,t){let n=e.state.doc.toString();if(n===t)return;let r=0;for(;r<n.length&&r<t.length&&n[r]===t[r];)r++;let i=n.length,a=t.length;for(;i>r&&a>r&&n[i-1]===t[a-1];)i--,a--;e.dispatch({changes:{from:r,to:i,insert:t.slice(r,a)},annotations:[$.of(!0),d.addToHistory.of(!1)]})}var Ze=(e,t)=>T.theme({"&":{color:e===`dark`?`oklch(92% 0.02 260)`:`var(--ink)`,backgroundColor:`transparent`,fontSize:t===`json`?`0.75rem`:`0.9375rem`},"&.cm-focused":{outline:`none`},".cm-scroller":{fontFamily:t===`json`?`var(--f-mono)`:`var(--f-ui)`,lineHeight:t===`json`?`1.6`:`1.65`},".cm-content":{padding:t===`json`?`0.625rem 0`:`1rem 0`,caretColor:e===`dark`?`white`:`var(--ink)`},".cm-line":{padding:t===`json`?`0 0.75rem`:`0 1rem`},".cm-cursor, .cm-dropCursor":{borderLeftColor:e===`dark`?`white`:`var(--ink)`},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:`color-mix(in oklch, var(--ember) 28%, transparent)`},".cm-placeholder":{color:`var(--ink-4)`},".cm-panels":{backgroundColor:`var(--card)`,color:`var(--ink)`,borderColor:`var(--border)`},".cm-panels.cm-panels-bottom":{borderTop:`1px solid var(--border)`},".cm-search":{fontFamily:`var(--f-ui)`,fontSize:`0.8125rem`},".cm-textfield":{backgroundColor:`var(--paper)`,border:`1px solid var(--input)`,borderRadius:`0.375rem`,color:`var(--ink)`},".cm-button":{backgroundImage:`none`,backgroundColor:`var(--accent)`,border:`1px solid var(--border)`,borderRadius:`0.375rem`,color:`var(--ink)`},".cm-searchMatch":{backgroundColor:`color-mix(in oklch, var(--ember) 22%, transparent)`},".cm-searchMatch-selected":{backgroundColor:`color-mix(in oklch, var(--ember) 45%, transparent)`},".cm-selectionMatch":{backgroundColor:`color-mix(in oklch, var(--ink) 10%, transparent)`},".cm-gutters":{backgroundColor:`transparent`,border:`none`},".cm-lintRange-error":{backgroundImage:`none`,textDecoration:`underline wavy oklch(70% 0.18 25)`},".cm-tooltip.cm-tooltip-autocomplete":{padding:`0.25rem`},".cm-tooltip.cm-tooltip-autocomplete > ul":{fontFamily:`var(--f-ui)`,maxHeight:`16rem`},".cm-tooltip.cm-tooltip-autocomplete > ul > li":{padding:`0.375rem 0.625rem`,borderRadius:`0.375rem`,display:`flex`,gap:`0.75rem`,alignItems:`baseline`},".cm-tooltip.cm-tooltip-autocomplete > ul > li[aria-selected]":{backgroundColor:`var(--accent)`,color:`var(--ink)`},".cm-completionLabel":{fontSize:`0.875rem`},".cm-completionDetail":{fontStyle:`normal`,fontSize:`0.75rem`,color:`var(--ink-3)`,marginLeft:`auto`},".cm-tooltip":{backgroundColor:`var(--card)`,color:`var(--ink)`,border:`1px solid var(--border)`,borderRadius:`0.5rem`}},{dark:e===`dark`}),Qe=()=>u.phrases.of({Find:r(`code.find`),Replace:r(`code.replace`),next:r(`code.next`),previous:r(`code.previous`),all:r(`code.all`),"match case":r(`code.matchCase`),regexp:r(`code.regexp`),"by word":r(`code.byWord`),replace:r(`code.replace`),"replace all":r(`code.replaceAll`),close:r(`code.close`),"Go to line":r(`code.goToLine`),go:r(`code.go`)});function $e(e){return e.length?ae({icons:!1,override:[t=>{let n=t.matchBefore(/\]\([^)\s]*/);if(!n)return null;let r=n.text.slice(2).toLowerCase();return{from:n.from+2,filter:!1,options:e.filter(e=>!r||e.title.toLowerCase().includes(r)||e.path.toLowerCase().includes(r)).slice(0,50).map(e=>({label:e.title,detail:e.path,type:e.kind,apply:e.path}))}}]}):[]}function et(e,t){let n=e.state.doc.lineAt(t);for(let e of n.text.matchAll(/\[[^\]]*\]\(([^)\s]+)\)/g)){let r=n.from+(e.index??0);if(t>=r&&t<=r+e[0].length)return e[1]??null}return null}function tt(e){return T.domEventHandlers({mousedown(t,n){if(!(t.metaKey||t.ctrlKey))return!1;let r=n.posAtCoords({x:t.clientX,y:t.clientY}),i=r===null?null:et(n,r);return i?(t.preventDefault(),e(i),!0):!1}})}function nt(e){if(!e.length)return[];let t=t=>{let n=[];for(let{from:r,to:i}of t.visibleRanges)for(let a=r;a<=i;){let r=t.state.doc.lineAt(a),i=/^#{1,6}\s+(.+?)\s*#*$/.exec(r.text)?.[1]?.toLowerCase(),o=i?e.find(e=>e.heading.toLowerCase()===i):void 0;o&&n.push(E.line({attributes:{title:o.title,style:`box-shadow: inset 3px 0 0 ${o.color}`}}).range(r.from)),a=r.to+1}return E.set(n)};return v.define(e=>({decorations:t(e),update(e){(e.docChanged||e.viewportChanged)&&(this.decorations=t(e.view))}}),{decorations:e=>e.decorations})}function rt({value:e,onChange:t,language:n,ariaLabel:r,placeholder:i,readOnly:a=!1,tone:s=`light`,onCaret:c,onBlur:l,className:d,extensions:f=[],handle:p,marks:m=[],links:h=[],onLink:g,languageParts:_}){let v=(0,Q.useRef)(new o),y=(0,Q.useRef)(new o),b=(0,Q.useRef)(null),x=(0,Q.useRef)(null),S=(0,Q.useRef)({onChange:t,onCaret:c,onBlur:l,onLink:g});S.current={onChange:t,onCaret:c,onBlur:l,onLink:g},(0,Q.useImperativeHandle)(p,()=>({view:()=>x.current}),[]),(0,Q.useEffect)(()=>{if(!b.current)return;let t=new T({parent:b.current,state:u.create({doc:e,extensions:[oe(),ne(),Ee({top:!1}),ge(),te.of([...Ke,...se,...ce]),Qe(),Ze(s,n),..._,u.readOnly.of(a),T.contentAttributes.of({"aria-label":r}),i?ee(i):[],T.updateListener.of(e=>{e.docChanged&&!e.transactions.some(e=>e.annotation($))&&S.current.onChange(e.state.doc.toString()),(e.selectionSet||e.docChanged)&&S.current.onCaret?.(e.state.doc.toString(),e.state.selection.main.head),e.focusChanged&&!e.view.hasFocus&&S.current.onBlur?.()}),v.current.of(nt(m)),y.current.of($e(h)),tt(e=>S.current.onLink?.(e)),...f]})});return x.current=t,()=>{t.destroy(),x.current=null}},[]);let C=JSON.stringify(m);(0,Q.useEffect)(()=>{x.current?.dispatch({effects:v.current.reconfigure(nt(m))})},[C]);let w=JSON.stringify(h);return(0,Q.useEffect)(()=>{x.current?.dispatch({effects:y.current.reconfigure($e(h))})},[w]),(0,Q.useEffect)(()=>{x.current&&Xe(x.current,e)},[e]),(0,Ye.jsx)(`div`,{ref:b,className:d})}export{Xe as applyText,rt as default,$ as remote};