@puddle-code/cli 0.3.3 → 0.3.4

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 (73) hide show
  1. package/CHANGELOG.md +9 -8
  2. package/dist/host-control.mjs +57 -3
  3. package/dist/index.js +61 -6
  4. package/dist/public/assets/App-CwV0Dizo.js +2 -0
  5. package/dist/public/assets/Dashboard-fA7E3Mr1.js +1 -0
  6. package/dist/public/assets/EditorTabClose-DNWGZZN8.js +1 -0
  7. package/dist/public/assets/{FindWidget-BsFwo-Vf.js → FindWidget-BSK2PIfO.js} +1 -1
  8. package/dist/public/assets/LazyTerminal-CAvxgexS.js +2 -0
  9. package/dist/public/assets/{ModelRefcount-BdmA-Mgb.js → ModelRefcount-CJK-g5rf.js} +1 -1
  10. package/dist/public/assets/NewProjectDialog-eDAOcbIM.js +1 -0
  11. package/dist/public/assets/PaneEditorBody-Cxn0s84L.js +302 -0
  12. package/dist/public/assets/PdfViewer-BY5xRKk1.js +2 -0
  13. package/dist/public/assets/SettingsDialog-Sd6i7Plz.js +8 -0
  14. package/dist/public/assets/{Terminal-_KJe85Cp.js → Terminal-CqjwbNAI.js} +4 -4
  15. package/dist/public/assets/Workspace-C-M1AjMn.js +20 -0
  16. package/dist/public/assets/auth-cjbSLnao.js +73 -0
  17. package/dist/public/assets/{buffer-store-De6oYRzb.js → buffer-store-BAQjeFXg.js} +2 -2
  18. package/dist/public/assets/button-Chvl9hcE.js +1 -0
  19. package/dist/public/assets/context-menu-DVUv5Z6a.js +1 -0
  20. package/dist/public/assets/{copy-CKvSfzPk.js → copy-Df7qIcX6.js} +1 -1
  21. package/dist/public/assets/dialog-Bnex_wlx.js +1 -0
  22. package/dist/public/assets/disclosure-C2uTs3Vm.js +1 -0
  23. package/dist/public/assets/dist-B67qxih2.js +1 -0
  24. package/dist/public/assets/dist-BCwJL3w9.js +1 -0
  25. package/dist/public/assets/{dist-v3Pwgb3Q.js → dist-Cl5AP2As.js} +1 -1
  26. package/dist/public/assets/dist-DmyIHyF9.js +1 -0
  27. package/dist/public/assets/{errors-BH_S68Hd.js → errors-BiS6nBXL.js} +1 -1
  28. package/dist/public/assets/es2015-CrC2hHeB.js +41 -0
  29. package/dist/public/assets/{index-xDhpMZgv.js → index-CW1P_8TN.js} +3 -3
  30. package/dist/public/assets/index-XBWIhnuP.css +2 -0
  31. package/dist/public/assets/{markdown-mermaid-D0nzztEz.js → markdown-mermaid-JPAETK2Y.js} +1 -1
  32. package/dist/public/assets/media-refresh-store-CHnqDJWI.js +1 -0
  33. package/dist/public/assets/notification-delivery-Lz-hnQG7.js +1 -0
  34. package/dist/public/assets/popover-C-BfSLgw.js +1 -0
  35. package/dist/public/assets/preview-kind-CJ9RTgbs.js +1 -0
  36. package/dist/public/assets/{project-abbrev-Br6sQqPh.js → project-abbrev-Bz8ZEwrb.js} +1 -1
  37. package/dist/public/assets/{protocol-support-CLMCHX8i.js → protocol-support-CJIxbQCB.js} +1 -1
  38. package/dist/public/assets/recipes-K5GH3Kht.js +1 -0
  39. package/dist/public/assets/rotate-ccw-CNjR2LSi.js +1 -0
  40. package/dist/public/assets/scroll-restoration-r--43sOx.js +1 -0
  41. package/dist/public/assets/select-YFIOZ3zx.js +1 -0
  42. package/dist/public/assets/{selection-actions-Bh9Fkkqv.js → selection-actions-C2udLSyj.js} +1 -1
  43. package/dist/public/assets/switch-DwMO1AUH.js +1 -0
  44. package/dist/public/assets/use-ui-state-Crvfdw4F.js +1 -0
  45. package/dist/public/assets/{ws-DNNH0sEH.js → ws-B1kcYo2j.js} +1 -1
  46. package/dist/public/assets/x-DCpy1q13.js +1 -0
  47. package/dist/public/index.html +3 -3
  48. package/dist/pudl.js +58 -4
  49. package/package.json +1 -1
  50. package/dist/public/assets/App-CkunCEjY.js +0 -2
  51. package/dist/public/assets/Dashboard-3XQN7EWB.js +0 -1
  52. package/dist/public/assets/EditorTabClose-CCYbaxcQ.js +0 -1
  53. package/dist/public/assets/LazyTerminal-CRonN-zb.js +0 -2
  54. package/dist/public/assets/NewProjectDialog-Bsp8NGgY.js +0 -1
  55. package/dist/public/assets/PaneEditorBody-MSWyifa9.js +0 -299
  56. package/dist/public/assets/PdfViewer-C3kK31fw.js +0 -2
  57. package/dist/public/assets/SettingsDialog-CGT3gjKB.js +0 -8
  58. package/dist/public/assets/Workspace-ZdFFHXHa.js +0 -20
  59. package/dist/public/assets/auth-C3Hg0pRq.js +0 -73
  60. package/dist/public/assets/button-DkCgQgIz.js +0 -1
  61. package/dist/public/assets/context-menu-0Tb8cG9E.js +0 -1
  62. package/dist/public/assets/dialog-UpZ_vNTE.js +0 -41
  63. package/dist/public/assets/disclosure-D7vpyXdR.js +0 -1
  64. package/dist/public/assets/dist-C2WZA469.js +0 -1
  65. package/dist/public/assets/index-CAvJOpdz.css +0 -2
  66. package/dist/public/assets/media-refresh-store-Ddvr6wz1.js +0 -1
  67. package/dist/public/assets/notification-delivery-CDu_5PS7.js +0 -1
  68. package/dist/public/assets/preview-kind-QJSMKfUN.js +0 -1
  69. package/dist/public/assets/scroll-restoration-hNqYmCAE.js +0 -1
  70. package/dist/public/assets/switch-SW6BMps1.js +0 -1
  71. package/dist/public/assets/use-ui-state-BiAROr3D.js +0 -1
  72. package/dist/public/assets/view-state-store-C6OmciCC.js +0 -1
  73. package/dist/public/assets/x-CZCUod6A.js +0 -1
package/CHANGELOG.md CHANGED
@@ -4,17 +4,18 @@ Archived release changelog. Governance lives in CLAUDE.md §"Changelog disciplin
4
4
 
5
5
  # Changelog
6
6
 
7
- ## [0.3.3] — 2026-10-15
7
+ ## [0.3.4] — 2026-10-23
8
8
 
9
9
  ### Added
10
10
 
11
- - Reveal local files and folders in Finder, File Explorer or the system file manager from file-tree and editor-tab menus, including locally served browser cockpits; SSH and remote hosts omit the action (protocol 24.2).
11
+ - Keep notebook kernels alive across runs and browser reconnects; add notebook header controls for cells, Run All, clearing output, outline navigation, kernel selection, interruption, restart and shutdown.
12
+ - Add language-selectable compilation and execution defaults under Settings → Editor, sharing command controls with per-file overrides.
13
+ - Choose project name colours from the profile palette when creating or editing a project, or from either sidebar's project context menu; retain colours across dashboard cards and project navigation.
14
+ - Add editable `.ipynb` notebook views with saved rich output, a JSON source toggle, and explicit whole-notebook execution through host-installed Jupyter.
15
+ - Run Python, JavaScript, TypeScript, C, C++, Rust, Go, Ruby, Perl, R and shell files with detected host tools, per-file command overrides, bounded output and managed result tabs; keep code execution manual.
12
16
 
13
17
  ### Changed
14
18
 
15
- - Show desktop notifications with host/project, session title and message preview in that order: native text fields on macOS and Windows, and a separate session line above the preview on Linux (protocol 24.1).
16
- - Prefix web/mobile notification titles with the project abbreviation (`[ABBRV] Session title`) for both live alerts and encrypted background push.
17
-
18
- ### Fixed
19
-
20
- - Attach desktop SSH authentication prompts to their host's window, display the target explicitly, and discard pending and late requests when that host closes while retaining at most one request per host.
19
+ - Advance the daemon/cockpit protocol to 24.6 for host kernel discovery, status and explicit notebook lifecycle actions.
20
+ - Advance the daemon/cockpit protocol to 24.5 for optional project colours; hide colour controls on older hosts and preserve existing project styling by default.
21
+ - Advance the daemon/cockpit protocol to 24.4 for profile language command defaults, inherited file commands and an optional compilation-provider action label; retain LaTeX eager controls only for providers that advertise eager support.
@@ -14690,6 +14690,15 @@ ${RULES_TOKEN}
14690
14690
  4. If the user states a standing rule for all future worktrees ("always\u2026", "never\u2026", "from now on\u2026"), write the complete updated rules to \`.puddle/onboarding-notes.md\` in this worktree \u2014 full replacement, user-owned prose; record their decision, don't invent policy.
14691
14691
 
14692
14692
  Then proceed with the task below (or await instructions if none is given).`;
14693
+ var PROFILE_ICON_COLOURS = [
14694
+ "navy",
14695
+ "gold",
14696
+ "blue",
14697
+ "green",
14698
+ "red",
14699
+ "violet",
14700
+ "cyan"
14701
+ ];
14693
14702
  var profileSchema = external_exports.object({
14694
14703
  id: profileId,
14695
14704
  name: fsSafeName,
@@ -15112,12 +15121,14 @@ var archiveRequestSchema = external_exports.object({
15112
15121
 
15113
15122
  // ../shared/src/api/projects.ts
15114
15123
  var projectAbbrev2 = external_exports.string().min(1).max(5);
15124
+ var projectColourSchema = external_exports.enum(PROFILE_ICON_COLOURS);
15115
15125
  var projectSchema = external_exports.object({
15116
15126
  id: projectId,
15117
15127
  profile_id: profileId,
15118
15128
  repo_id: rowId,
15119
15129
  name: external_exports.string(),
15120
15130
  abbrev: projectAbbrev2.nullable().default(null),
15131
+ colour: projectColourSchema.nullable().optional(),
15121
15132
  /**
15122
15133
  * Hidden from the homescreen but never deleted — every session, worktree, and
15123
15134
  * bit of data is retained, and un-archiving restores it all (SPEC §11).
@@ -15131,11 +15142,13 @@ var createProjectRequestSchema = external_exports.object({
15131
15142
  profile_id: profileId,
15132
15143
  repo_id: rowId,
15133
15144
  name: external_exports.string().min(1).max(100),
15134
- abbrev: projectAbbrev2.optional()
15145
+ abbrev: projectAbbrev2.optional(),
15146
+ colour: projectColourSchema.nullable().optional()
15135
15147
  });
15136
15148
  var patchProjectRequestSchema = external_exports.object({
15137
15149
  name: external_exports.string().min(1).max(100).optional(),
15138
15150
  abbrev: projectAbbrev2.optional(),
15151
+ colour: projectColourSchema.nullable().optional(),
15139
15152
  archived: external_exports.boolean().optional()
15140
15153
  });
15141
15154
  var projectDetailSchema = external_exports.object({
@@ -15196,7 +15209,9 @@ var compilationProviderSchema = external_exports.object({
15196
15209
  available: external_exports.boolean(),
15197
15210
  /** The preferred host executable when available, for honest capability UI. */
15198
15211
  executor: external_exports.string().min(1).nullable(),
15199
- eager: external_exports.boolean()
15212
+ eager: external_exports.boolean(),
15213
+ /** Omitted by older providers, whose action remains compilation. */
15214
+ action: external_exports.enum(["compile", "run"]).optional()
15200
15215
  });
15201
15216
  var compilationCapabilitiesResponseSchema = external_exports.object({
15202
15217
  providers: external_exports.array(compilationProviderSchema)
@@ -15265,7 +15280,9 @@ var compilationCommandSlotSchema = external_exports.object({
15265
15280
  /** Stable trigger copy lets a generic dialog explain exactly when this slot runs. */
15266
15281
  run_when: external_exports.enum(["when_clicked", "upon_file_change"]),
15267
15282
  default_command: external_exports.string().min(1).nullable(),
15268
- override_command: external_exports.string().min(1).nullable()
15283
+ override_command: external_exports.string().min(1).nullable(),
15284
+ /** Profile language default inherited by this file (24.4); null uses the provider. */
15285
+ inherited_command: external_exports.string().min(1).nullable().optional()
15269
15286
  });
15270
15287
  var compilationSettingsRequestSchema = compilationTargetRequestSchema.extend({
15271
15288
  profile_id: profileId,
@@ -15285,6 +15302,18 @@ var updateCompilationSettingsRequestSchema = compilationSettingsRequestSchema.ex
15285
15302
  mode: compilationModeSchema,
15286
15303
  command: external_exports.string().trim().min(1).max(16384).nullable()
15287
15304
  });
15305
+ var compilationDefaultsRequestSchema = external_exports.object({
15306
+ profile_id: profileId,
15307
+ provider: compilationProviderIdSchema
15308
+ });
15309
+ var compilationDefaultsResponseSchema = compilationSettingsResponseSchema.omit({
15310
+ file_type: true,
15311
+ file_path: true
15312
+ });
15313
+ var updateCompilationDefaultsRequestSchema = compilationDefaultsRequestSchema.extend({
15314
+ mode: compilationModeSchema,
15315
+ command: updateCompilationSettingsRequestSchema.shape.command
15316
+ });
15288
15317
 
15289
15318
  // ../shared/src/api/ui-state.ts
15290
15319
  var editorTabRefSchema = external_exports.object({
@@ -15451,6 +15480,31 @@ var patchLayoutRequestSchema = external_exports.object({
15451
15480
  active_session: sessionId.nullable().optional()
15452
15481
  });
15453
15482
 
15483
+ // ../shared/src/api/notebooks.ts
15484
+ var notebookKernelSpecSchema = external_exports.object({
15485
+ name: external_exports.string().min(1),
15486
+ display_name: external_exports.string().min(1),
15487
+ language: external_exports.string()
15488
+ });
15489
+ var notebookKernelsResponseSchema = external_exports.object({
15490
+ available: external_exports.boolean(),
15491
+ kernels: external_exports.array(notebookKernelSpecSchema),
15492
+ error: external_exports.string().optional()
15493
+ });
15494
+ var notebookKernelRequestSchema = external_exports.object({ source: compilationFileTargetSchema });
15495
+ var notebookKernelStatusSchema = external_exports.object({
15496
+ state: external_exports.enum(["stopped", "starting", "idle", "busy", "dead"]),
15497
+ kernel: external_exports.string().nullable(),
15498
+ error: external_exports.string().optional()
15499
+ });
15500
+ var notebookKernelActionSchema = external_exports.discriminatedUnion("action", [
15501
+ notebookKernelRequestSchema.extend({
15502
+ action: external_exports.literal("select"),
15503
+ kernel: external_exports.string().min(1).max(256)
15504
+ }),
15505
+ notebookKernelRequestSchema.extend({ action: external_exports.enum(["interrupt", "restart", "shutdown"]) })
15506
+ ]);
15507
+
15454
15508
  // ../shared/src/api/latex.ts
15455
15509
  var latexSynctexRequestSchema = compilationFileTargetSchema.extend({
15456
15510
  root: external_exports.string().min(1),
package/dist/index.js CHANGED
@@ -3925,7 +3925,7 @@ import { createInterface } from "node:readline";
3925
3925
  import { Writable } from "node:stream";
3926
3926
 
3927
3927
  // ../shared/src/protocol.ts
3928
- var PROTOCOL_VERSION = { major: 24, minor: 2 };
3928
+ var PROTOCOL_VERSION = { major: 24, minor: 6 };
3929
3929
 
3930
3930
  // ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/external.js
3931
3931
  var external_exports = {};
@@ -18610,6 +18610,15 @@ ${RULES_TOKEN}
18610
18610
  4. If the user states a standing rule for all future worktrees ("always\u2026", "never\u2026", "from now on\u2026"), write the complete updated rules to \`.puddle/onboarding-notes.md\` in this worktree \u2014 full replacement, user-owned prose; record their decision, don't invent policy.
18611
18611
 
18612
18612
  Then proceed with the task below (or await instructions if none is given).`;
18613
+ var PROFILE_ICON_COLOURS = [
18614
+ "navy",
18615
+ "gold",
18616
+ "blue",
18617
+ "green",
18618
+ "red",
18619
+ "violet",
18620
+ "cyan"
18621
+ ];
18613
18622
  var profileSchema = external_exports.object({
18614
18623
  id: profileId,
18615
18624
  name: fsSafeName,
@@ -19032,12 +19041,14 @@ var archiveRequestSchema = external_exports.object({
19032
19041
 
19033
19042
  // ../shared/src/api/projects.ts
19034
19043
  var projectAbbrev2 = external_exports.string().min(1).max(5);
19044
+ var projectColourSchema = external_exports.enum(PROFILE_ICON_COLOURS);
19035
19045
  var projectSchema = external_exports.object({
19036
19046
  id: projectId,
19037
19047
  profile_id: profileId,
19038
19048
  repo_id: rowId,
19039
19049
  name: external_exports.string(),
19040
19050
  abbrev: projectAbbrev2.nullable().default(null),
19051
+ colour: projectColourSchema.nullable().optional(),
19041
19052
  /**
19042
19053
  * Hidden from the homescreen but never deleted — every session, worktree, and
19043
19054
  * bit of data is retained, and un-archiving restores it all (SPEC §11).
@@ -19051,11 +19062,13 @@ var createProjectRequestSchema = external_exports.object({
19051
19062
  profile_id: profileId,
19052
19063
  repo_id: rowId,
19053
19064
  name: external_exports.string().min(1).max(100),
19054
- abbrev: projectAbbrev2.optional()
19065
+ abbrev: projectAbbrev2.optional(),
19066
+ colour: projectColourSchema.nullable().optional()
19055
19067
  });
19056
19068
  var patchProjectRequestSchema = external_exports.object({
19057
19069
  name: external_exports.string().min(1).max(100).optional(),
19058
19070
  abbrev: projectAbbrev2.optional(),
19071
+ colour: projectColourSchema.nullable().optional(),
19059
19072
  archived: external_exports.boolean().optional()
19060
19073
  });
19061
19074
  var projectDetailSchema = external_exports.object({
@@ -19116,7 +19129,9 @@ var compilationProviderSchema = external_exports.object({
19116
19129
  available: external_exports.boolean(),
19117
19130
  /** The preferred host executable when available, for honest capability UI. */
19118
19131
  executor: external_exports.string().min(1).nullable(),
19119
- eager: external_exports.boolean()
19132
+ eager: external_exports.boolean(),
19133
+ /** Omitted by older providers, whose action remains compilation. */
19134
+ action: external_exports.enum(["compile", "run"]).optional()
19120
19135
  });
19121
19136
  var compilationCapabilitiesResponseSchema = external_exports.object({
19122
19137
  providers: external_exports.array(compilationProviderSchema)
@@ -19185,7 +19200,9 @@ var compilationCommandSlotSchema = external_exports.object({
19185
19200
  /** Stable trigger copy lets a generic dialog explain exactly when this slot runs. */
19186
19201
  run_when: external_exports.enum(["when_clicked", "upon_file_change"]),
19187
19202
  default_command: external_exports.string().min(1).nullable(),
19188
- override_command: external_exports.string().min(1).nullable()
19203
+ override_command: external_exports.string().min(1).nullable(),
19204
+ /** Profile language default inherited by this file (24.4); null uses the provider. */
19205
+ inherited_command: external_exports.string().min(1).nullable().optional()
19189
19206
  });
19190
19207
  var compilationSettingsRequestSchema = compilationTargetRequestSchema.extend({
19191
19208
  profile_id: profileId,
@@ -19205,6 +19222,18 @@ var updateCompilationSettingsRequestSchema = compilationSettingsRequestSchema.ex
19205
19222
  mode: compilationModeSchema,
19206
19223
  command: external_exports.string().trim().min(1).max(16384).nullable()
19207
19224
  });
19225
+ var compilationDefaultsRequestSchema = external_exports.object({
19226
+ profile_id: profileId,
19227
+ provider: compilationProviderIdSchema
19228
+ });
19229
+ var compilationDefaultsResponseSchema = compilationSettingsResponseSchema.omit({
19230
+ file_type: true,
19231
+ file_path: true
19232
+ });
19233
+ var updateCompilationDefaultsRequestSchema = compilationDefaultsRequestSchema.extend({
19234
+ mode: compilationModeSchema,
19235
+ command: updateCompilationSettingsRequestSchema.shape.command
19236
+ });
19208
19237
 
19209
19238
  // ../shared/src/api/ui-state.ts
19210
19239
  var editorTabRefSchema = external_exports.object({
@@ -19371,6 +19400,31 @@ var patchLayoutRequestSchema = external_exports.object({
19371
19400
  active_session: sessionId.nullable().optional()
19372
19401
  });
19373
19402
 
19403
+ // ../shared/src/api/notebooks.ts
19404
+ var notebookKernelSpecSchema = external_exports.object({
19405
+ name: external_exports.string().min(1),
19406
+ display_name: external_exports.string().min(1),
19407
+ language: external_exports.string()
19408
+ });
19409
+ var notebookKernelsResponseSchema = external_exports.object({
19410
+ available: external_exports.boolean(),
19411
+ kernels: external_exports.array(notebookKernelSpecSchema),
19412
+ error: external_exports.string().optional()
19413
+ });
19414
+ var notebookKernelRequestSchema = external_exports.object({ source: compilationFileTargetSchema });
19415
+ var notebookKernelStatusSchema = external_exports.object({
19416
+ state: external_exports.enum(["stopped", "starting", "idle", "busy", "dead"]),
19417
+ kernel: external_exports.string().nullable(),
19418
+ error: external_exports.string().optional()
19419
+ });
19420
+ var notebookKernelActionSchema = external_exports.discriminatedUnion("action", [
19421
+ notebookKernelRequestSchema.extend({
19422
+ action: external_exports.literal("select"),
19423
+ kernel: external_exports.string().min(1).max(256)
19424
+ }),
19425
+ notebookKernelRequestSchema.extend({ action: external_exports.enum(["interrupt", "restart", "shutdown"]) })
19426
+ ]);
19427
+
19374
19428
  // ../shared/src/api/latex.ts
19375
19429
  var latexSynctexRequestSchema = compilationFileTargetSchema.extend({
19376
19430
  root: external_exports.string().min(1),
@@ -21824,7 +21878,7 @@ import { readFileSync as readFileSync4 } from "node:fs";
21824
21878
  import { dirname as dirname4, join as join5 } from "node:path";
21825
21879
  import { fileURLToPath as fileURLToPath2 } from "node:url";
21826
21880
  function cliVersion() {
21827
- if (true) return "0.3.3";
21881
+ if (true) return "0.3.4";
21828
21882
  const here = dirname4(fileURLToPath2(import.meta.url));
21829
21883
  for (const candidate of [
21830
21884
  join5(here, "..", "..", "package.json"),
@@ -22225,7 +22279,8 @@ var RELEASE_PROTOCOLS = {
22225
22279
  "0.3.0": { major: 23, minor: 0 },
22226
22280
  "0.3.1": { major: 23, minor: 0 },
22227
22281
  "0.3.2": { major: 24, minor: 0 },
22228
- "0.3.3": { major: 24, minor: 2 }
22282
+ "0.3.3": { major: 24, minor: 2 },
22283
+ "0.3.4": { major: 24, minor: 6 }
22229
22284
  };
22230
22285
  function validProtocol(value) {
22231
22286
  if (typeof value !== "object" || value === null) return false;
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SettingsDialog-Sd6i7Plz.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/jsx-runtime-ffCh33zF.js","assets/auth-cjbSLnao.js","assets/LazyTerminal-CAvxgexS.js","assets/preload-helper-Czpn1I53.js","assets/es2015-CrC2hHeB.js","assets/x-DCpy1q13.js","assets/createLucideIcon-DyMAgLa3.js","assets/recipes-K5GH3Kht.js","assets/notification-delivery-Lz-hnQG7.js","assets/dist-Cl5AP2As.js","assets/protocol-support-CJIxbQCB.js","assets/switch-DwMO1AUH.js","assets/dist-BCwJL3w9.js","assets/dialog-Bnex_wlx.js","assets/client-settings-CwqpIric.js","assets/index-CW1P_8TN.js","assets/index-XBWIhnuP.css","assets/button-Chvl9hcE.js","assets/select-YFIOZ3zx.js","assets/chevron-down--sjpQEHH.js","assets/dist-DmyIHyF9.js","assets/code-DRWf9a5s.js","assets/rotate-ccw-CNjR2LSi.js","assets/errors-BiS6nBXL.js","assets/use-debounced-value-C86N-mOK.js","assets/popover-C-BfSLgw.js","assets/disclosure-C2uTs3Vm.js","assets/Dashboard-fA7E3Mr1.js","assets/project-abbrev-Bz8ZEwrb.js","assets/context-menu-DVUv5Z6a.js","assets/dist-B67qxih2.js","assets/NewProjectDialog-eDAOcbIM.js","assets/ws-B1kcYo2j.js","assets/Workspace-C-M1AjMn.js","assets/copy-Df7qIcX6.js","assets/media-refresh-store-CHnqDJWI.js","assets/use-ui-state-Crvfdw4F.js","assets/preview-kind-CJ9RTgbs.js","assets/debounce-B9DrqirV.js","assets/whole-word-2m2pmAFT.js","assets/selection-actions-C2udLSyj.js","assets/drafts-B_tChlzR.js","assets/buffer-logic-BAkSBQT7.js","assets/scroll-restoration-r--43sOx.js","assets/Workspace-DdL3ODEC.css"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{n,t as r}from"./jsx-runtime-ffCh33zF.js";import{B as i,O as a,V as o,j as s,l as c,o as l,r as u,v as d}from"./auth-cjbSLnao.js";import{a as f,c as p,l as m,o as h,u as g}from"./LazyTerminal-CAvxgexS.js";import{a as _,d as v,f as y,g as b,h as x,i as S,l as C,m as w,o as T,s as E,t as D,u as O}from"./notification-delivery-Lz-hnQG7.js";import{i as k,r as A,t as j}from"./client-settings-CwqpIric.js";import{t as M}from"./preload-helper-Czpn1I53.js";import{a as ee,n as te,o as ne,r as re,t as N}from"./index-CW1P_8TN.js";import{i as ie,n as ae,t as oe}from"./dist-Cl5AP2As.js";import{$t as se,A as ce,C as le,D as ue,E as de,F as fe,Ft as pe,Gt as me,Ht as he,I as ge,It as _e,Jt as ve,Kt as ye,L as be,Lt as xe,M as Se,N as Ce,O as we,Q as Te,Qt as Ee,R as De,S as Oe,Tt as ke,U as Ae,Ut as P,W as je,Wt as Me,Xt as Ne,Y as Pe,Yt as F,Zt as Fe,_ as Ie,_t as Le,at as Re,b as ze,dt as Be,en as Ve,et as He,ft as Ue,g as We,gt as Ge,ht as Ke,it as qe,j as Je,k as I,kt as Ye,lt as Xe,nn as Ze,o as Qe,ot as $e,q as et,qt as tt,tn as nt,ut as rt,vt as it,w as at,y as ot,yt as st,zt as ct}from"./protocol-support-CJIxbQCB.js";import{n as lt,t as ut}from"./copy-Df7qIcX6.js";import{a as dt,c as ft,d as pt,i as mt,l as ht,n as gt,o as _t,s as vt,t as yt,u as bt}from"./project-abbrev-Bz8ZEwrb.js";import{c as L,p as R}from"./es2015-CrC2hHeB.js";import{n as z,s as xt}from"./x-DCpy1q13.js";import{i as St,n as Ct}from"./recipes-K5GH3Kht.js";import{n as wt,r as Tt}from"./dist-BCwJL3w9.js";import{$ as Et,G as Dt,H as Ot,J as kt,K as At,Q as jt,U as Mt,W as Nt,X as Pt,Y as Ft,at as It,d as Lt,et as Rt,f as zt,h as B,i as Bt,it as V,m as Vt,nt as Ht,ot as H,p as Ut,q as Wt,r as Gt,rt as U,t as Kt,tt as qt}from"./use-ui-state-Crvfdw4F.js";import{t as W}from"./button-Chvl9hcE.js";import{t as G}from"./createLucideIcon-DyMAgLa3.js";import{c as Jt,i as Yt,s as Xt,t as Zt,u as Qt}from"./switch-DwMO1AUH.js";import{t as $t}from"./NewProjectDialog-eDAOcbIM.js";import{n as K}from"./errors-BiS6nBXL.js";import{t as q}from"./ws-B1kcYo2j.js";import{c as en,l as tn,n as nn,s as rn,t as an,u as on}from"./dialog-Bnex_wlx.js";import{n as sn,r as cn,t as ln}from"./popover-C-BfSLgw.js";var J=e(t(),1),Y=r();function un(){let[e,t]=(0,J.useState)(`Opening forwarded application…`);return(0,J.useEffect)(()=>{if(!/^\/forward\/([^/]+)\/(\d+)$/.exec(window.location.pathname)){t(`This forwarding link is invalid.`);return}let e=!0;return lt(new URL(window.location.href)).then(t=>{e&&window.location.replace(t)}).catch(()=>{e&&t(`The application is unavailable. Reconnect to Puddle and open this link again.`)}),()=>{e=!1}},[]),(0,Y.jsx)(`p`,{className:`p-8 text-sm text-fg-secondary`,children:e})}var dn=class extends Ve{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new xe({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=fn(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=fn(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=fn(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=fn(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){P.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>tt(t,e))}findAll(e={}){return this.getAll().filter(t=>tt(e,t))}notify(e){P.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return P.batch(()=>Promise.all(e.map(e=>e.continue().catch(F))))}};function fn(e){return e.options.scope?.id}var pn=class extends Ve{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??ye(r,t),a=this.get(i);return a||(a=new ct({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){P.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>ve(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>ve(e,t)):t}notify(e){P.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){P.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){P.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},mn=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new pn,this.#t=e.mutationCache||new dn,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=se.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=he.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Fe(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=Me(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return P.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;P.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return P.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=P.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(F).catch(F)}invalidateQueries(e,t={}){return P.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=P.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(F)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(F)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(Fe(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(F).catch(F)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(F).catch(F)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return he.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(me(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{Ne(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(me(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{Ne(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=ye(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===Ee&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},hn=class extends J.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidUpdate(e){this.state.error!==null&&e.resetOn!==this.props.resetOn&&this.setState({error:null})}componentDidCatch(e,t){console.error(`Puddle: the ${this.props.scope} crashed`,e,t.componentStack)}render(){let{error:e}=this.state;return e===null?this.props.children:(0,Y.jsxs)(`div`,{className:`flex h-full min-h-40 flex-col items-center justify-center gap-4 px-8 py-10 text-center`,children:[(0,Y.jsxs)(`p`,{className:`text-sm text-fg`,children:[`The `,this.props.scope,` stopped rendering.`]}),(0,Y.jsx)(`p`,{className:`max-w-lg font-mono text-2xs leading-relaxed text-interrupted`,children:e.message||String(e)}),(0,Y.jsx)(`p`,{className:`max-w-sm text-2xs leading-relaxed text-fg-muted`,children:`Your sessions and their worktrees are on the daemon and untouched; the layout is saved. The console has the full stack.`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>this.setState({error:null}),className:`text-2xs font-medium text-fg-gold transition-colors hover:underline`,children:`Try again`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),className:`text-2xs text-fg-muted transition-colors hover:text-fg`,children:`Reload`})]})]})}};function gn(){return(0,Y.jsx)(oe,{theme:(0,J.useSyncExternalStore)(ee,re),position:`bottom-right`,toastOptions:{style:{background:`var(--bg-elevated)`,border:`none`,boxShadow:`0 8px 30px rgb(0 0 0 / 0.25)`,color:`var(--text-primary)`},classNames:{description:`whitespace-pre-wrap break-words font-mono text-2xs leading-snug max-h-40 overflow-y-auto`}}})}function _n(){return(0,Y.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-ground`,children:(0,Y.jsxs)(`div`,{className:`flex w-full max-w-md flex-col gap-10 px-8 pb-24`,children:[(0,Y.jsx)(`h1`,{className:`font-mono text-2xl font-semibold text-fg`,children:`Puddle`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3 text-sm leading-relaxed text-fg-secondary`,children:[(0,Y.jsxs)(`p`,{children:[`Authorise this browser by running`,` `,(0,Y.jsx)(`span`,{className:`font-mono text-accent`,children:`puddle launch`}),` in a terminal.`]}),(0,Y.jsx)(`p`,{children:`Use the link it opens. Your sessions, drafts and layouts stay in place.`})]})]})})}var vn=e(n(),1),yn=`a, button, [role="button"], [role="slider"], input, select, textarea, summary, label, [onclick], .cursor-pointer`,bn=`.monaco-editor`;function xn(e,t){return e?.closest(bn)&&!e.closest(t)?`text`:e?.closest(yn)?`interactive`:`default`}function Sn(e,t=`.no-custom-caret`){(0,J.useEffect)(()=>{let n=e.current;if(!n)return;let r=window.matchMedia(`(pointer: fine)`),i=()=>{n.style.opacity=`0`},a=e=>{if(e.pointerType===`touch`||!r.matches){i();return}n.style.transform=`translate3d(${e.clientX}px, ${e.clientY}px, 0) translate(-50%, -50%)`;let a=e.target instanceof Element?e.target:null;if(a instanceof HTMLIFrameElement){i();return}n.style.opacity=`1`;let o=a?.closest(bn),s=xn(a,t),c=s===`text`,l=s===`interactive`,u=c;if(c&&o){let e=getComputedStyle(o);n.style.setProperty(`--custom-cursor-caret-height`,`${Math.round(Number.parseFloat(e.fontSize)*1.3)}px`)}else if(!l&&a&&!a.closest(t)&&Array.from(a.childNodes).some(e=>e.nodeType===Node.TEXT_NODE&&e.textContent?.trim())){let e=getComputedStyle(a);e.userSelect!==`none`&&(u=!0,n.style.setProperty(`--custom-cursor-caret-height`,`${Math.round(Number.parseFloat(e.fontSize)*1.3)}px`))}n.classList.toggle(`is-interactive`,l),n.classList.toggle(`is-text`,u)};return window.addEventListener(`pointermove`,a,{passive:!0}),document.documentElement.addEventListener(`pointerleave`,i),window.addEventListener(`blur`,i),()=>{window.removeEventListener(`pointermove`,a),document.documentElement.removeEventListener(`pointerleave`,i),window.removeEventListener(`blur`,i)}},[t,e])}var Cn=[`top`,`right`,`bottom`,`left`];function wn(){let e=(0,J.useRef)(null);return Sn(e),(0,Y.jsx)(`div`,{ref:e,className:`custom-cursor drafting-cursor`,"aria-hidden":`true`,children:Cn.map(e=>(0,Y.jsx)(`span`,{className:`drafting-cursor-tick`,"data-side":e},e))})}function Tn(){let e=(0,J.useRef)(null);return Sn(e),(0,Y.jsx)(`div`,{ref:e,className:`custom-cursor invert-cursor`,"aria-hidden":`true`})}var En=`h1, h2, h3, h4, h5, h6, .no-rangefinder-caret`,Dn=40.5,X=4.05,On=X*Math.sqrt(3)/2;function kn(){let e=[],t=[],n=Dn/2,r=Math.ceil(n/On)+1,i=e=>Math.round(e*100)/100,a=e=>`M${e.map(([e,t])=>`${i(e)} ${i(t)}`).join(`L`)}Z`;for(let i=-r;i<r;i+=1){let o=n+i*On,s=o+On,c=(i%2+2)%2*(X/2);for(let i=-r;i<r;i+=1){let r=n+i*X+c,l=[[r+X/2,o],[r,s],[r+X,s]],u=[[r+X/2,o],[r+3*X/2,o],[r+X,s]],d=e=>{let t=e.map(([e])=>e),n=e.map(([,e])=>e);return Math.max(...t)>0&&Math.min(...t)<Dn&&Math.max(...n)>0&&Math.min(...n)<Dn};d(l)&&e.push(a(l)),d(u)&&t.push(a(u))}}return{light:e.join(``),dark:t.join(``)}}var An=kn();function jn(){let e=(0,J.useRef)(null);return Sn(e,En),(0,Y.jsx)(`div`,{ref:e,className:`custom-cursor rangefinder-cursor`,"aria-hidden":`true`,children:(0,Y.jsxs)(`svg`,{className:`rangefinder-cursor-facets`,viewBox:`0 0 ${Dn} ${Dn}`,focusable:`false`,children:[(0,Y.jsx)(`path`,{className:`rangefinder-cursor-facet-light`,d:An.light}),(0,Y.jsx)(`path`,{className:`rangefinder-cursor-facet-dark`,d:An.dark})]})})}function Mn(){let{cursorPackage:e}=k(),t=null;switch(e){case`rangefinder`:t=(0,Y.jsx)(jn,{});break;case`drafting`:t=(0,Y.jsx)(wn,{});break;case`invert`:t=(0,Y.jsx)(Tn,{});break;case`system`:return null}return(0,vn.createPortal)(t,document.body)}var Nn=G(`corner-down-left`,[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}],[`path`,{d:`m9 10-5 5 5 5`,key:`1kshq7`}]]),Pn=G(`layout-template`,[[`rect`,{width:`18`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`f1a2em`}],[`rect`,{width:`9`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`jqznyg`}],[`rect`,{width:`5`,height:`7`,x:`16`,y:`14`,rx:`1`,key:`q5h2i8`}]]),Fn=G(`monitor-cog`,[[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`m14.305 7.53.923-.382`,key:`1mlnsw`}],[`path`,{d:`m15.228 4.852-.923-.383`,key:`82mpwg`}],[`path`,{d:`m16.852 3.228-.383-.924`,key:`ln4sir`}],[`path`,{d:`m16.852 8.772-.383.923`,key:`1dejw0`}],[`path`,{d:`m19.148 3.228.383-.924`,key:`192kgf`}],[`path`,{d:`m19.53 9.696-.382-.924`,key:`fiavlr`}],[`path`,{d:`m20.772 4.852.924-.383`,key:`1j8mgp`}],[`path`,{d:`m20.772 7.148.924.383`,key:`zix9be`}],[`path`,{d:`M22 13v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7`,key:`1tnzv8`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}]]),In=G(`notebook-pen`,[[`path`,{d:`M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4`,key:`re6nr2`}],[`path`,{d:`M2 6h4`,key:`aawbzj`}],[`path`,{d:`M2 10h4`,key:`l0bgd4`}],[`path`,{d:`M2 14h4`,key:`1gsvsf`}],[`path`,{d:`M2 18h4`,key:`1bu2t1`}],[`path`,{d:`M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z`,key:`pqwjuv`}]]),Ln=G(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),Rn=G(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),zn=G(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]);function Bn(){let e=Le(),t=je(),[n,r]=(0,J.useState)(``),[i,a]=(0,J.useState)(s),o=()=>{n.trim()&&t.mutate({name:n.trim(),branch_prefix:i.trim()},{onSuccess:e=>we(e.id)})},c=(e.data?.length??0)>0;return(0,Y.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-ground`,children:(0,Y.jsxs)(`div`,{className:`flex w-full max-w-md flex-col gap-10 px-8 pb-16`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`h1`,{className:`font-mono text-2xl font-semibold text-fg`,children:`Puddle`}),(0,Y.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`Who is working?`})]}),c&&(0,Y.jsx)(`div`,{className:`flex flex-col`,children:e.data.map(e=>(0,Y.jsxs)(`button`,{onClick:()=>we(e.id),className:`flex items-center gap-3 rounded-md px-3 py-2.5 text-left transition-colors hover:bg-elevated active:bg-border/70`,children:[(0,Y.jsx)(y,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,Y.jsx)(`span`,{className:z(`text-base`,f(e.icon_colour)||`text-fg`),children:e.name}),e.branch_prefix&&(0,Y.jsxs)(`span`,{className:`ml-auto text-2xs text-fg-muted`,children:[e.branch_prefix,`…`]})]},e.id))}),(0,Y.jsxs)(`form`,{className:`flex flex-col gap-5`,onSubmit:e=>{e.preventDefault(),o()},children:[c&&(0,Y.jsx)(`p`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:`or create a profile`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(p,{htmlFor:`profile-name`,children:`Name`}),(0,Y.jsx)(m,{id:`profile-name`,placeholder:`e.g. alice`,value:n,onChange:e=>r(e.target.value),className:`h-10`,autoFocus:!c})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(p,{htmlFor:`branch-prefix`,children:`Branch prefix`}),(0,Y.jsx)(m,{id:`branch-prefix`,placeholder:`no prefix`,value:i,onChange:e=>a(e.target.value),className:`h-10`})]}),t.error&&(0,Y.jsx)(`p`,{className:`text-xs text-danger`,children:t.error.message}),(0,Y.jsx)(W,{type:`submit`,size:`lg`,className:`self-start px-6`,disabled:!n.trim()||t.isPending,children:`Create profile`})]})]})})}var Vn=1,Hn=.9,Un=.8,Wn=.17,Gn=.1,Kn=.999,qn=.9999,Jn=.99,Yn=/[\\\/_+.#"@\[\(\{&]/,Xn=/[\\\/_+.#"@\[\(\{&]/g,Zn=/[\s-]/,Qn=/[\s-]/g;function $n(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?Vn:Jn;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=$n(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=Vn:Yn.test(e.charAt(l-1))?(d*=Un,p=e.slice(i,l-1).match(Xn),p&&i>0&&(d*=Kn**+p.length)):Zn.test(e.charAt(l-1))?(d*=Hn,m=e.slice(i,l-1).match(Qn),m&&i>0&&(d*=Kn**+m.length)):(d*=Wn,i>0&&(d*=Kn**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=qn)),(d<Gn&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=$n(e,t,n,r,l+1,a+2,o),f*Gn>d&&(d=f*Gn)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function er(e){return e.toLowerCase().replace(Qn,` `)}function tr(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,$n(e,t,er(e),er(t),0,0,{})}var nr=`[cmdk-group=""]`,rr=`[cmdk-group-items=""]`,ir=`[cmdk-group-heading=""]`,ar=`[cmdk-item=""]`,or=`${ar}:not([aria-disabled="true"])`,sr=`cmdk-item-select`,Z=`data-value`,cr=(e,t,n)=>tr(e,t,n),lr=J.createContext(void 0),ur=()=>J.useContext(lr),dr=J.createContext(void 0),fr=()=>J.useContext(dr),pr=J.createContext(void 0),mr=J.forwardRef((e,t)=>{let n=Dr(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=Dr(()=>new Set),i=Dr(()=>new Map),a=Dr(()=>new Map),o=Dr(()=>new Set),s=Er(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=L(),y=L(),b=L(),x=J.useRef(null),S=kr();Q(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),Q(()=>{S(6,k)},[]);let C=J.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)O(),E(),S(1,D);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=A()?.id,C.emit()}),r||S(5,k),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=J.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{O(),E(),n.current.value||D(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();S(4,()=>{O(),t?.getAttribute(`id`)===e&&D(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??cr;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;j().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(rr);t?t.appendChild(e.parentElement===t?e:e.closest(`${rr} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${rr} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${nr}[${Z}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(Z);C.setState(`value`,e||void 0)}function O(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=T(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function k(){var e;let t=A();t&&(t.parentElement?.firstChild===t&&((e=t.closest(nr)?.querySelector(ir))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${ar}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(or)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(Z))}function ee(e){var t;let n=A(),r=j(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&C.setState(`value`,a.getAttribute(Z))}function te(e){let t=A()?.closest(nr),n;for(;t&&!n;)t=e>0?wr(t,nr):Tr(t,nr),n=t?.querySelector(or);n?C.setState(`value`,n.getAttribute(Z)):ee(e)}let ne=()=>M(j().length-1),re=e=>{e.preventDefault(),e.metaKey?ne():e.altKey?te(1):ee(1)},N=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?te(-1):ee(-1)};return J.createElement(R.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&re(e);break;case`ArrowDown`:re(e);break;case`p`:case`k`:g&&e.ctrlKey&&N(e);break;case`ArrowUp`:N(e);break;case`Home`:e.preventDefault(),M(0);break;case`End`:e.preventDefault(),ne();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(sr);t.dispatchEvent(e)}}}}},J.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:Mr},c),jr(e,e=>J.createElement(dr.Provider,{value:C},J.createElement(lr.Provider,{value:w},e))))}),hr=J.forwardRef((e,t)=>{let n=L(),r=J.useRef(null),i=J.useContext(pr),a=ur(),o=Er(e),s=o.current?.forceMount??i?.forceMount;Q(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=Or(n,r,[e.value,e.children,r],e.keywords),l=fr(),u=$(e=>e.value&&e.value===c.current),d=$(e=>s||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);J.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(sr,f),()=>t.removeEventListener(sr,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return J.createElement(R.div,{ref:xt(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),gr=J.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=L(),s=J.useRef(null),c=J.useRef(null),l=L(),u=ur(),d=$(e=>i||u.filter()===!1?!0:!e.search||e.filtered.groups.has(o));Q(()=>u.group(o),[]),Or(o,s,[e.value,e.heading,c]);let f=J.useMemo(()=>({id:o,forceMount:i}),[i]);return J.createElement(R.div,{ref:xt(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!d||void 0},n&&J.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),jr(e,e=>J.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},J.createElement(pr.Provider,{value:f},e))))}),_r=J.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=J.useRef(null),a=$(e=>!e.search);return!n&&!a?null:J.createElement(R.div,{ref:xt(i,t),...r,"cmdk-separator":``,role:`separator`})}),vr=J.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=fr(),o=$(e=>e.search),s=$(e=>e.selectedItemId),c=ur();return J.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),J.createElement(R.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),yr=J.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=J.useRef(null),o=J.useRef(null),s=$(e=>e.selectedItemId),c=ur();return J.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),J.createElement(R.div,{ref:xt(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},jr(e,e=>J.createElement(`div`,{ref:xt(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),br=J.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return J.createElement(rn,{open:n,onOpenChange:r},J.createElement(on,{container:o},J.createElement(tn,{"cmdk-overlay":``,className:i}),J.createElement(en,{"aria-label":e.label,"cmdk-dialog":``,className:a},J.createElement(mr,{ref:t,...s}))))}),xr=J.forwardRef((e,t)=>$(e=>e.filtered.count===0)?J.createElement(R.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),Sr=J.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return J.createElement(R.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},jr(e,e=>J.createElement(`div`,{"aria-hidden":!0},e)))}),Cr=Object.assign(mr,{List:yr,Item:hr,Input:vr,Group:gr,Separator:_r,Dialog:br,Empty:xr,Loading:Sr});function wr(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Tr(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Er(e){let t=J.useRef(e);return Q(()=>{t.current=e}),t}var Q=typeof window>`u`?J.useEffect:J.useLayoutEffect;function Dr(e){let t=J.useRef();return t.current===void 0&&(t.current=e()),t}function $(e){let t=fr(),n=()=>e(t.snapshot());return J.useSyncExternalStore(t.subscribe,n,n)}function Or(e,t,n,r=[]){let i=J.useRef(),a=ur();return Q(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(Z,s),i.current=s}),i}var kr=()=>{let[e,t]=J.useState(),n=Dr(()=>new Map);return Q(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function Ar(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function jr({asChild:e,children:t},n){return e&&J.isValidElement(t)?J.cloneElement(Ar(t),{ref:t.ref},n(t.props.children)):n(t)}var Mr={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function Nr({className:e,...t}){return(0,Y.jsx)(Cr,{className:z(`flex size-full flex-col overflow-hidden rounded-lg bg-elevated`,e),...t})}function Pr({open:e,onOpenChange:t,children:n}){return(0,Y.jsx)(an,{open:e,onOpenChange:t,children:(0,Y.jsx)(nn,{className:`max-w-lg overflow-hidden p-0 [&>button]:hidden`,children:(0,Y.jsx)(Nr,{loop:!0,children:n})})})}function Fr({className:e,...t}){return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-3 pt-1`,children:[(0,Y.jsx)(Ht,{className:`size-4 shrink-0 text-fg-muted`}),(0,Y.jsx)(Cr.Input,{className:z(`flex h-10 w-full bg-transparent text-sm text-fg outline-none placeholder:text-fg-muted`,e),...t})]})}function Ir({className:e,...t}){return(0,Y.jsx)(Cr.List,{className:z(`max-h-72 overflow-y-auto p-1`,e),...t})}function Lr(e){return(0,Y.jsx)(Cr.Empty,{className:`py-6 text-center text-sm text-fg-muted`,...e})}function Rr({className:e,...t}){return(0,Y.jsx)(Cr.Group,{className:z(`overflow-hidden [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-2xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:uppercase [&_[cmdk-group-heading]]:tracking-wide [&_[cmdk-group-heading]]:text-fg-muted`,e),...t})}function zr({className:e,...t}){return(0,Y.jsx)(Cr.Item,{className:z(St,Ct,`[&_svg]:size-3.5 [&_svg]:text-fg-muted data-[selected=true]:[&_svg]:text-action-ink`,e),...t})}function Br({className:e,...t}){return(0,Y.jsx)(`span`,{className:z(`ml-auto font-mono text-2xs tracking-widest text-fg-muted`,e),...t})}var Vr=new class{transport;reload;pause;phase=`idle`;pending=null;constructor(e=fetch,t=()=>window.location.reload(),n=e=>new Promise(t=>setTimeout(t,e))){this.transport=e,this.reload=t,this.pause=n}refresh(e=12e4){return this.pending||=this.run(e).finally(()=>{this.pending=null}),this.pending}async run(e){this.phase=`requesting`;let t={authorization:`Bearer ${u.get()??``}`,"content-type":`application/json`};try{let n=await this.transport(`/cockpit/refresh`,{method:`POST`,headers:t,signal:AbortSignal.timeout(1e4),body:JSON.stringify({refreshId:crypto.randomUUID()})});if(n.status!==202)throw Error(`refresh rejected`);let r=d.parse(await n.json());this.phase=`waiting`;let i=Date.now()+e;for(;Date.now()<i;){await this.pause(1e3);try{let e=await this.transport(`/cockpit/status`,{headers:t,cache:`no-store`,signal:AbortSignal.timeout(3e3)});if(!e.ok)continue;let n=c.parse(await e.json());if(n.instance===r.instance||n.refreshId!==r.refreshId||n.upstream!==`ready`)continue;return this.phase=`complete`,this.reload(),!0}catch{}}}catch{}return this.phase=`failed`,!1}},Hr=null;function Ur(e){return Hr=e,()=>{Hr===e&&(Hr=null)}}function Wr(){Hr?.()}var Gr=new Set;function Kr(){return[...Gr].flatMap(e=>e())}function qr({onNewSession:e,onNewProject:t}){let[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(`commands`),[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(!1),f=bt(),p=pt(),m=I(),h=p.id,g=st(m??void 0),_=Ye(h),v=Ft();(0,J.useEffect)(()=>le(`palette.toggle`,()=>r(e=>!e)),[]),(0,J.useEffect)(()=>Et(()=>r(!0)),[]),(0,J.useEffect)(()=>{n||(a(`commands`),s(``),l(null),d(!1))},[n]);let y=(0,J.useMemo)(()=>{let n=[];for(let e of g.data??[])n.push({id:`project-${e.id}`,group:`Projects`,label:e.name,icon:gt,keywords:`switch project open`,run:()=>void f(`/project/${e.id}`)});for(let e of _.data??[])e.status!==`archived`&&n.push({id:`session-${e.id}`,group:`Sessions`,label:v(e),icon:yt,keywords:`switch session ${e.branch}`,run:()=>void f(`/project/${e.project_id}/session/${e.id}`)});return h!==void 0&&e&&n.push({id:`new-agent`,group:`Actions`,label:`New agent`,icon:Qt,keywords:`new agent create start session`,run:()=>e()},{id:`new-terminal`,group:`Actions`,label:`New terminal`,icon:yt,keywords:`new terminal create start shell session`,run:()=>e({kind:`terminal`})}),h!==void 0&&n.push({id:`open-path`,group:`Actions`,label:`Open path`,icon:gt,keywords:`open path file directory folder editor tree browse absolute relative home`,closeOnRun:!1,run:()=>{s(``),l(null),a(`path`)}}),t&&n.push({id:`new-project`,group:`Actions`,label:`New project`,icon:Tt,keywords:`new project open create repository repo workspace`,run:t}),n.push({id:`theme-dark`,group:`Theme`,label:`Switch theme: dark`,icon:x,keywords:`switch theme dark appearance`,run:()=>void N(`dark`)},{id:`theme-light`,group:`Theme`,label:`Switch theme: light`,icon:w,keywords:`switch theme light appearance`,run:()=>void N(`light`)},{id:`theme-system`,group:`Theme`,label:`Switch theme: system`,icon:Fn,keywords:`switch theme system appearance`,run:()=>void N(`system`)},{id:`open-settings`,group:`Actions`,label:`Settings`,icon:zn,keywords:`open settings preferences options configure`,run:()=>Yt()},{id:`switch-profile`,group:`Actions`,label:`Switch profile`,icon:Xt,keywords:`switch profile identity user change`,run:()=>ue.set(null)},{id:`refresh-connection`,group:`Actions`,label:`Refresh connection`,icon:Jt,keywords:`refresh connection reconnect restart cockpit tunnel ssh daemon`,run:()=>Wr()}),[...n,...Kr()]},[g.data,_.data,h,f,e,t,v]),b=(0,J.useMemo)(()=>{let e=new Map;for(let t of y){let n=e.get(t.group)??[];n.push(t),e.set(t.group,n)}return[...e.entries()]},[y]),S=async()=>{let e=o.trim();if(!(e===``||u)){d(!0),l(null);try{await Pt(e),r(!1)}catch(e){l(e instanceof Error?e.message:`Could not open that path.`)}finally{d(!1)}}};return(0,Y.jsxs)(Pr,{open:n,onOpenChange:r,children:[(0,Y.jsx)(Fr,{value:o,onValueChange:e=>{s(e),l(null)},placeholder:i===`path`?`Enter a path…`:`Type a command or search…`,onKeyDown:e=>{i===`path`&&(e.key===`Enter`?(e.preventDefault(),e.stopPropagation(),S()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),a(`commands`),s(``),l(null)))}}),i===`path`?(0,Y.jsx)(Ir,{children:(0,Y.jsxs)(`div`,{className:`px-3 py-3 text-xs text-fg-muted`,children:[(0,Y.jsx)(`p`,{children:`Relative paths start from the bound worktree or project. Absolute and ~ paths work too.`}),(0,Y.jsx)(`p`,{className:c?`mt-2 text-danger`:`mt-2`,"aria-live":`polite`,children:c??(u?`Opening…`:`Press Enter to open.`)})]})}):(0,Y.jsxs)(Ir,{children:[(0,Y.jsx)(Lr,{children:`Nothing matches.`}),b.map(([e,t])=>(0,Y.jsx)(Rr,{heading:e,children:t.map(e=>{let t=e.icon;return(0,Y.jsxs)(zr,{value:`${e.label} ${e.keywords??``}`,onSelect:()=>{e.closeOnRun!==!1&&r(!1),e.run()},children:[t&&(0,Y.jsx)(t,{}),e.label,e.shortcut&&(0,Y.jsx)(Br,{children:e.shortcut})]},e.id)})},e))]})]})}function Jr(){let e=document.activeElement;return e instanceof Element&&e.closest(`.xterm`)!==null}function Yr(){let e=document.activeElement;return e instanceof Element&&e.closest(`.monaco-editor`)!==null}function Xr(){let e=Ge(I()??void 0).data?.hotkeys;return(0,J.useEffect)(()=>{at(e&&typeof e==`object`?e:void 0)},[e]),(0,J.useEffect)(()=>le(`window.close`,()=>{let e=nt();e?.closeWindow?e.closeWindow():window.close()}),[]),(0,J.useEffect)(()=>{let e=e=>{let t=Ie(e);if(!t)return;let n=We(t);if(!n)return;let r=ot(n);if(!r||!Oe(r,Yr()))return;let i=ze(n);i&&(e.preventDefault(),e.stopPropagation(),i())},t=e=>{let t=Ie(e);if(!t)return;let n=We(t);if(!n)return;let r=ot(n);if(!r||r.editor&&Yr()||r.deferInTerminal&&Jr())return;let i=ze(n);i&&(e.preventDefault(),i())};return window.addEventListener(`keydown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`keydown`,e,!0),window.removeEventListener(`keydown`,t)}},[]),null}var Zr=4e3;function Qr(){let[e,t]=(0,J.useState)(`hidden`),n=(0,J.useRef)(e);n.current=e,(0,J.useEffect)(()=>{let e=null,r=q.onConnectionChange(r=>{if(r){e!==null&&clearTimeout(e),e=null,n.current===`lost`&&t(`hidden`);return}e!==null||n.current!==`hidden`||(e=setTimeout(()=>{e=null,n.current===`hidden`&&t(`lost`)},Zr))});return()=>{r(),e!==null&&clearTimeout(e)}},[]);let r=(0,J.useCallback)(async()=>{n.current!==`refreshing`&&(t(`refreshing`),await Vr.refresh()||(ae.error(`The cockpit has not come back — it may need a terminal (ssh re-auth): puddle refresh`),t(q.isConnected()?`hidden`:`lost`)))},[]);return(0,J.useEffect)(()=>Ur(()=>void r()),[r]),e===`hidden`?null:(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 bg-elevated px-3 py-2`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-fg-secondary`,children:e===`refreshing`?`Restarting the cockpit.`:`Connection to the daemon lost.`}),e===`lost`&&(0,Y.jsxs)(W,{size:`sm`,className:`ml-auto`,onClick:()=>void r(),children:[(0,Y.jsx)(Jt,{}),`Refresh connection`]})]})}function $r({label:e,percentage:t,hint:n}){let r=Math.max(0,Math.min(100,t));return(0,Y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`w-24 shrink-0 truncate text-2xs text-fg-muted`,title:e,children:e}),(0,Y.jsx)(`span`,{className:`relative h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-border`,children:(0,Y.jsx)(`span`,{className:`absolute inset-y-0 left-0 rounded-full ${r>=90?`bg-danger`:r>=75?`bg-warning`:`bg-action`}`,style:{width:`${r}%`}})}),(0,Y.jsxs)(`span`,{className:`shrink-0 text-2xs tabular-nums text-fg-muted`,children:[Math.round(r),`%`,n?` · ${n}`:``]})]})}function ei(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function ti(e){if(e===null)return`never`;let t=new Date(e).getTime(),n=Math.max(0,Math.round((Date.now()-t)/1e3));if(n<60)return`just now`;let r=Math.round(n/60);if(r<60)return`${r}m ago`;let i=Math.round(r/60);return i<24?`${i}h ago`:`${Math.round(i/24)}d ago`}function ni({account:e,onLogin:t,onStartSession:n,installed:r=!0}){let i=fe(e.id),a=e.logged_in?n:r?t:null,o=i.data?.subscription;return(0,Y.jsxs)(`div`,{className:`rounded-md px-2 py-2 transition-colors hover:bg-elevated`,children:[(0,Y.jsxs)(`button`,{type:`button`,disabled:a===null,onClick:()=>a?.(),className:`flex w-full items-center gap-3 text-left disabled:cursor-default`,children:[(0,Y.jsx)(`span`,{className:`size-2 shrink-0 rounded-full ${e.logged_in?`bg-success`:`bg-idle`}`,"aria-hidden":!0}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate text-sm text-fg`,children:e.label}),(0,Y.jsxs)(`span`,{className:`block text-2xs text-fg-muted`,children:[e.logged_in?`logged in`:`logged out`,i.data&&(0,Y.jsxs)(Y.Fragment,{children:[` · `,i.data.session_count,` session`,i.data.session_count===1?``:`s`,i.data.active_session_count>0&&` (${i.data.active_session_count} active)`,` · `,`last `,ti(i.data.last_activity_at)]})]}),i.data?.agent_usage&&(0,Y.jsxs)(`span`,{className:`block text-2xs text-fg-muted`,children:[ei(i.data.agent_usage.input_tokens),` in ·`,` `,ei(i.data.agent_usage.output_tokens),` out ·`,` `,ei(i.data.agent_usage.cache_read_input_tokens),` cached ·`,` `,i.data.agent_usage.message_count,` msgs`]}),i.data?.live_usage?.context_used_percentage!=null&&(0,Y.jsx)(`span`,{className:`mt-1 block`,children:(0,Y.jsx)($r,{label:`context`,percentage:i.data.live_usage.context_used_percentage})})]}),(0,Y.jsx)(`span`,{className:`shrink-0 text-2xs text-fg-muted`,children:r?e.logged_in?n?`new agent`:``:(0,Y.jsxs)(`span`,{className:`flex items-center gap-1 text-warning`,children:[(0,Y.jsx)(b,{className:`size-3`}),`sign in`]}):`unavailable`})]}),o!=null&&o.windows.length>0&&(0,Y.jsx)(`div`,{className:`mt-2 flex flex-col gap-1 pl-5`,children:o.windows.map(e=>(0,Y.jsx)($r,{label:e.label,percentage:e.used_percentage,hint:e.resets==null?void 0:`resets ${e.resets}`},e.key))})]})}function ri(){let[e,t]=(0,J.useState)(!1),[n,r]=(0,J.useState)(!1),i=I(),a=Le(),o=Be(),s=a.data?.find(e=>e.id===i),c=ge(i??void 0),l=be(),u=$e(),{open:d,handler:p}=kt(),[m,h]=(0,J.useState)(null),g=e=>u.mutate(e.id,{onSuccess:t=>h({stream:t.stream,label:`${e.agent_type}/${e.label}`}),onError:e=>K(e)}),_=e=>{t(!1),d({accountId:e.id})};return n&&s?(0,Y.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-3`,children:[(0,Y.jsx)(y,{icon:s.icon,colour:s.icon_colour}),(0,Y.jsx)(Rt,{initial:s.name,maxLength:100,className:z(`w-32 text-sm`,f(s.icon_colour)),onCommit:e=>{r(!1);let t=e.trim();!i||!t||t===s?.name||o.mutate({id:i,name:t},{onError:e=>K(e)})},onCancel:()=>r(!1)})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(ln,{open:e,onOpenChange:t,children:[(0,Y.jsxs)(U,{children:[(0,Y.jsx)(H,{asChild:!0,children:(0,Y.jsx)(cn,{asChild:!0,children:(0,Y.jsxs)(W,{variant:`ghost`,size:`sm`,className:`font-sans compact:h-7 compact:px-1.5`,children:[(0,Y.jsx)(y,{icon:s?.icon,colour:s?.icon_colour}),(0,Y.jsx)(`span`,{className:f(s?.icon_colour),...qt(()=>{t(!1),r(!0)}),children:s?.name??`…`})]})})}),(0,Y.jsx)(V,{children:`Profile`})]}),(0,Y.jsxs)(sn,{className:`w-[28rem] max-w-[calc(100vw-1rem)]`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(l.data??[]).map(e=>{let t=c.data?.filter(t=>t.agent_type===e.id)??[];if(t.length===0)return null;let n=e.available!==!1;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsxs)(`span`,{className:`px-2 text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:[e.display_name,!n&&(0,Y.jsxs)(`span`,{className:`ml-2 normal-case tracking-normal text-fg-muted`,children:[`not installed — no `,e.binary??e.id,` on PATH`]})]}),t.map(e=>(0,Y.jsx)(ni,{account:e,onLogin:()=>g(e),onStartSession:p&&n?()=>_(e):null,installed:n},e.id))]},e.id)}),c.data?.length===0&&(0,Y.jsx)(`p`,{className:`px-2 text-sm text-fg-muted`,children:`No accounts yet — add one in settings.`})]}),(0,Y.jsxs)(`div`,{className:`mt-4 flex items-center gap-2`,children:[(0,Y.jsxs)(W,{variant:`ghost`,size:`sm`,onClick:()=>{t(!1),Yt(`accounts`)},children:[(0,Y.jsx)(Tt,{}),`Add account`]}),(0,Y.jsxs)(W,{variant:`ghost`,size:`sm`,className:`ml-auto`,onClick:()=>{t(!1),ue.set(null)},children:[(0,Y.jsx)(Rn,{}),`Switch profile`]})]})]})]}),m&&(0,Y.jsx)(v,{stream:m.stream,label:m.label,onClose:()=>h(null)})]})}var ii=`desktop-update`;function ai(){let e=(0,J.useRef)(null);return(0,J.useEffect)(()=>{let t=nt();if(t?.updateReady===void 0||t.onUpdateReady===void 0)return;let n=t=>{e.current!==t&&(e.current=t,ae(`Puddle ${t} is downloaded and ready.`,{id:ii,duration:1/0,closeButton:!0,action:{label:`Restart to update`,onClick:()=>{nt()?.installUpdate?.(),ae.loading(`Restarting into Puddle ${t}…`,{id:`${ii}-restarting`,duration:1/0})}}}))};return t.updateReady().then(e=>{e!==null&&n(e)}),t.onUpdateReady(n)},[]),null}function oi(){let e=I(),t=Le().data?.find(t=>t.id===e),n=Ge(e??void 0),r=ke(e??void 0,void 0),i=k(),a=T(),o=E(),s=Ue(e??``),c=Be(),l=et(),[u,d]=(0,J.useReducer)(e=>e+1,0);(0,J.useEffect)(()=>ee(()=>d()),[]);let f=(0,J.useRef)(null);(0,J.useEffect)(()=>{f.current=null},[t?.name]);let p=a.data?.available===!0?a.data.file:void 0,m=t!==void 0&&e!==null&&n.data!==void 0&&r.data!==void 0&&p!==void 0,h=t&&p?_(p,t.name):void 0,g=s.isPending||c.isPending||l.isPending||o.isPending||n.isFetching||r.isFetching;(0,J.useEffect)(()=>{if(!m||!h?.enabled||g)return;let a={client:i,theme:ne(),profileSettings:n.data,profile:t,scratchpad:r.data},u={setClient:e=>A(e),setTheme:e=>{typeof e==`string`&&N(e)},patchProfileSettings:e=>s.mutate(e),patchProfileColumns:t=>c.mutate({id:e,...t}),createScratchpad:t=>{for(let n of t)l.mutate({profile_id:e,scope:`profile`,title:n.title??void 0,body:n.body,tags:n.tags,agent_type:n.agent_type??void 0})}},d=JSON.stringify(h.doc);if(f.current!==d){f.current=d,C(h.doc,u,a,h.groups);return}let p=O(h.groups,a),_=JSON.stringify(p);_!==d&&(f.current=_,o.mutate({profile:t.name,entry:{...h,doc:p,updatedAt:new Date().toISOString()}}))})}function si(e){let t=t=>{let n=o.safeParse(t);n.success&&e(n.data)},n=nt()?.onNotificationClick?.((e,n)=>t(n)),r=e=>{e.data?.t===`notification-click`&&t(e.data.target)};return navigator.serviceWorker?.addEventListener(`message`,r),()=>{n?.(),navigator.serviceWorker?.removeEventListener(`message`,r)}}var ci=5e3,li=`[data-notification-session]`;function ui(e){let t=null,n=()=>{t=null},r=e=>e.target instanceof Element?e.target.closest(li):null,i=e=>{if(!e.isTrusted)return;let n=r(e),i=n?.dataset.notificationSession;t=n&&i?{element:n,session:i,at:performance.now()}:null},a=e=>{r(e)!==t?.element&&n()},o=[`pointerdown`,`keydown`,`input`,`paste`];for(let t of o)e.addEventListener(t,i,!0);return e.addEventListener(`focusin`,a,!0),e.addEventListener(`visibilitychange`,n),e.defaultView?.addEventListener(`blur`,n),{isInteracting(n){return t!==null&&t.session===n&&performance.now()-t.at<ci&&e.visibilityState===`visible`&&e.hasFocus()&&t.element.isConnected&&t.element.dataset.notificationSession===n&&t.element.getClientRects().length>0},dispose(){n();for(let t of o)e.removeEventListener(t,i,!0);e.removeEventListener(`focusin`,a,!0),e.removeEventListener(`visibilitychange`,n),e.defaultView?.removeEventListener(`blur`,n)}}}var di=new Set,fi=e=>!!e&&di.has(e),pi=i.parse({});function mi(e){return e.prefs.muted_projects.includes(e.projectId)?{desktop:!1,sound:!1}:{desktop:e.prefs.desktop&&(e.permission===`granted`||e.permission===`unverified`)&&(e.prefs.when_focused||!e.sessionFocused),sound:e.prefs.sound}}function hi(e,t){for(let[,n]of e.getQueriesData({queryKey:[`sessions`]})){let e=n?.find(e=>e.id===t);if(e)return e}for(let[,n]of e.getQueriesData({queryKey:[`project`]})){let e=n?.sessions.find(e=>e.id===t);if(e)return e}}function gi(e){return e.title??e.agent_title??e.osc_title??e.id.slice(0,8)}function _i(){try{let e=new AudioContext,t=e.createGain();t.gain.value=.04,t.connect(e.destination);for(let[n,r]of[[880,0],[1318.5,.09]]){let i=e.createOscillator();i.type=`sine`,i.frequency.value=n,i.connect(t),i.start(e.currentTime+r),i.stop(e.currentTime+r+.12)}setTimeout(()=>void e.close(),400)}catch{}}function vi(){let e=bt(),t=(0,J.useRef)(null);(0,J.useEffect)(()=>{let e=ui(document);return t.current=e,()=>{t.current=null,e.dispose()}},[]),(0,J.useEffect)(()=>si(t=>{t.host||e(`/project/${t.project}/session/${t.session}`,{state:{notificationSession:t.session}})}),[e]),yi(t=>{e(`/project/${t.project_id}/session/${t.id}`,{state:{notificationSession:t.id}})},e=>t.current?.isInteracting(e.id)??!1)}function yi(e,t=()=>document.hasFocus()){let n=_e(),r=(0,J.useRef)(e);r.current=e;let a=(0,J.useRef)(t);a.current=t;let o=Se(qe().data)??`Puddle`,s=(0,J.useRef)(o);(0,J.useEffect)(()=>{document.title===s.current&&(document.title=o),s.current=o},[o]),(0,J.useEffect)(()=>{let e=new Set,t=()=>{document.title=e.size>0?`(${e.size}) ${s.current}`:s.current},o=!0,c=async e=>{let t=hi(n,e.session);if(!t)try{t=(await ce(n)).find(t=>t.id===e.session)}catch{return}if(!o||!t)return;let c=t,u,d;try{let e=await n.fetchQuery({queryKey:[`project`,c.project_id],queryFn:()=>ie(`GET`,`/api/projects/${c.project_id}`),staleTime:1e4});if(!o)return;d=e.project;let t=d.profile_id,r=await n.fetchQuery({queryKey:[`profile-settings`,t],queryFn:()=>ie(`GET`,`/api/profiles/${t}/settings`),staleTime:1e4});u=i.catch(pi).parse(r.notifications??{})}catch{return}if(!o)return;let f=mi({prefs:u,projectId:c.project_id,sessionFocused:a.current(c),permission:S()});f.sound&&_i(),f.desktop&&!fi(l()?.scope)&&await D({id:e.id?`puddle-event-${e.id}`:`puddle-agent-${c.id}`,title:e.content?.title??gi(c).slice(0,160),body:e.content?.body??(e.reason===`exited`?`Agent finished running`:`Waiting for your input`),target:{project:c.project_id,session:c.id,...l()?.notificationHost?{host:l().notificationHost}:{}}},()=>{o&&r.current(c)},{host:s.current,project:d})},u=q.onAgentNotification(e=>{c(e)}),d=q.onStatus(r=>{let i=e.has(r.session);r.status===`waiting_input`?e.add(r.session):e.delete(r.session),t(),!(r.status!==`waiting_input`||i)&&n.fetchQuery({queryKey:[`version`],queryFn:()=>ie(`GET`,`/api/version`),staleTime:1/0}).then(e=>{if(!(e.protocol.major>22||e.protocol.major===22&&e.protocol.minor>=3))return c({session:r.session,reason:`waiting_input`})}).catch(()=>{})});return()=>{o=!1,d(),u(),document.title=s.current}},[n])}function bi({initial:e,defaultScope:t,allowProject:n=!0,agents:r,onSave:i,onCancel:a}){let[o,s]=(0,J.useState)(e?.title??``),[c,l]=(0,J.useState)(e?.body??``),[u,d]=(0,J.useState)(n?e?.scope??t:`profile`),[f,p]=(0,J.useState)((e?.tags??[]).join(`, `)),[h,_]=(0,J.useState)(e?.agent_type??null),v=()=>{let e=c.trim();e&&i({title:o.trim()||null,body:e,scope:u,tags:f.split(`,`).map(e=>e.trim()).filter(Boolean),agent_type:h})};return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Y.jsx)(m,{value:o,placeholder:`Title (optional)`,spellCheck:!1,onChange:e=>s(e.target.value),onKeyDown:e=>e.stopPropagation(),className:`h-9 text-sm font-medium`}),(0,Y.jsx)(g,{autoFocus:!0,value:c,placeholder:`Prompt or note…`,spellCheck:!1,rows:10,onChange:e=>l(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`?a():e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&v()},className:`resize-y text-sm leading-relaxed`}),(0,Y.jsx)(m,{value:f,placeholder:`tags, comma, separated`,spellCheck:!1,onChange:e=>p(e.target.value),onKeyDown:e=>e.stopPropagation(),className:`h-8 text-xs`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n&&(0,Y.jsxs)(`label`,{className:`flex items-center gap-1.5 text-2xs text-fg-secondary`,children:[(0,Y.jsx)(Zt,{checked:u===`profile`,onCheckedChange:e=>d(e?`profile`:`project`)}),`Profile-wide`]}),(0,Y.jsx)(`div`,{className:`ml-auto flex items-center gap-1`,children:r.map(e=>(0,Y.jsxs)(`button`,{type:`button`,title:e.display_name,"aria-pressed":h===e.id,onClick:()=>_(t=>t===e.id?null:e.id),className:z(`rounded-md p-1 transition-colors`,h===e.id?`bg-surface text-fg`:`text-fg-gold hover:bg-surface hover:text-fg`),children:[(0,Y.jsx)(At,{type:e.id,className:`size-3.5`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:e.display_name})]},e.id))})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,children:[(0,Y.jsx)(W,{variant:`ghost`,size:`sm`,onClick:a,children:`Cancel`}),(0,Y.jsx)(W,{size:`sm`,disabled:!c.trim(),onClick:v,children:`Save`})]})]})}function xi(){let e=Dt(),t=I(),n=pt().id,r=ke(t??void 0,n).data??[],i=be().data??[],a=et(),o=Ke(),s=He(),c=Nt(),[l,u]=(0,J.useState)(null),[d,f]=(0,J.useState)(null),[p,m]=(0,J.useState)(null),[h,g]=(0,J.useState)(null),[_,v]=(0,J.useState)(null);(0,J.useEffect)(()=>le(`scratchpad.toggle`,Mt),[]),(0,J.useEffect)(()=>{e||(u(null),f(null),m(null))},[e]);let y=(0,J.useMemo)(()=>[...new Set(r.flatMap(e=>e.tags))].sort((e,t)=>e.localeCompare(t)),[r]),b=(0,J.useMemo)(()=>[...new Set(r.map(e=>e.agent_type).filter(e=>e!==null))],[r]),x=d!==null||p!==null,S=r.filter(e=>(d===null||e.tags.includes(d))&&(p===null||e.agent_type===p)),C=x?S:_??r,w=e=>{t&&(a.mutate({profile_id:t,scope:e.scope,project_id:e.scope===`project`?n:void 0,title:e.title??void 0,body:e.body,tags:e.tags,agent_type:e.agent_type??void 0}),u(null))},T=(e,t)=>{o.mutate({id:e,scope:t.scope,project_id:t.scope===`project`?n??null:null,title:t.title,body:t.body,tags:t.tags,agent_type:t.agent_type}),u(null)},E=(e,t)=>{let n=_??r,i=n.findIndex(t=>t.id===e),a=n.findIndex(e=>e.id===t);if(i===-1||a===-1||i===a)return;let o=n.slice(),[s]=o.splice(i,1);o.splice(a,0,s),v(o)},D=()=>{let e=h,t=_;if(g(null),v(null),e===null||!t)return;let n=t.findIndex(t=>t.id===e);if(n===-1)return;let r=t[n-1],i=t[n+1],a=r?i?(r.position+i.position)/2:r.position+1:(i?i.position:0)-1;o.mutate({id:e,position:a})},O=e=>{navigator.clipboard?.writeText(e.body),ae.success(`Copied to clipboard`)};return(0,Y.jsxs)(ln,{open:e,onOpenChange:Ot,children:[(0,Y.jsxs)(U,{children:[(0,Y.jsx)(H,{asChild:!0,children:(0,Y.jsx)(cn,{asChild:!0,children:(0,Y.jsxs)(W,{variant:`ghost`,size:`icon`,className:`compact:h-7 compact:w-7`,children:[(0,Y.jsx)(In,{}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`Scratchpad`})]})})}),(0,Y.jsx)(V,{children:`Scratchpad`})]}),(0,Y.jsxs)(sn,{className:`w-[34rem] max-w-[calc(100vw-1rem)] p-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-5 pb-2 pt-4`,children:[(0,Y.jsx)(`span`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Scratchpad`}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>u(l===`new`?null:`new`),className:`ml-auto flex items-center rounded-md p-1 text-fg-gold transition-colors hover:bg-surface hover:text-fg`,children:[(0,Y.jsx)(Tt,{className:`size-4`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`New entry`})]})]}),(y.length>0||b.length>0)&&(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 px-5 pb-2`,children:[y.map(e=>(0,Y.jsx)(`button`,{type:`button`,onClick:()=>f(t=>t===e?null:e),className:z(`rounded-full px-2 py-0.5 text-2xs transition-colors`,d===e?`bg-action text-action-ink`:`bg-surface text-fg-secondary hover:text-fg`),children:e},e)),b.map(e=>(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":p===e,onClick:()=>m(t=>t===e?null:e),className:z(`rounded-md p-1 transition-colors`,p===e?`bg-action text-action-ink`:`text-fg-gold hover:bg-surface`),children:(0,Y.jsx)(At,{type:e,className:`size-3.5`})},e))]}),(0,Y.jsxs)(`div`,{className:`no-scrollbar max-h-[65vh] overflow-y-auto px-2 pb-3`,children:[l===`new`&&(0,Y.jsx)(`div`,{className:`px-3 py-2`,children:(0,Y.jsx)(bi,{defaultScope:n?`project`:`profile`,allowProject:n!==void 0,agents:i,onSave:w,onCancel:()=>u(null)})}),C.length===0&&l!==`new`&&(0,Y.jsx)(`p`,{className:`px-3 py-3 text-sm text-fg-muted`,children:x?`Nothing matches this filter.`:`No entries yet — press + to add a reusable prompt or note.`}),(0,Y.jsx)(`ul`,{className:`flex flex-col`,children:C.map(e=>l===e.id?(0,Y.jsx)(`li`,{className:`px-3 py-2`,children:(0,Y.jsx)(bi,{initial:e,defaultScope:e.scope,allowProject:n!==void 0||e.scope===`project`,agents:i,onSave:t=>T(e.id,t),onCancel:()=>u(null)})},e.id):(0,Y.jsx)(`li`,{draggable:!x&&l===null,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,g(e.id)},onDragOver:t=>{h!==null&&(t.preventDefault(),h!==e.id&&E(h,e.id))},onDragEnd:D,className:z(`transition-opacity`,h===e.id&&`opacity-50`),children:(0,Y.jsx)(Si,{entry:e,onInsert:c?()=>{c(e.body),Ot(!1)}:null,onCopy:()=>O(e),onEdit:()=>u(e.id),onDelete:()=>s.mutate(e.id)})},e.id))})]})]})]})}function Si({entry:e,onInsert:t,onCopy:n,onEdit:r,onDelete:i}){let[a,o]=(0,J.useState)(!1);return(0,Y.jsxs)(`div`,{onClick:e=>{e.target.closest(`button`)||r()},className:`cursor-pointer rounded-md px-3 py-2.5 transition-colors hover:bg-surface`,children:[e.title&&(0,Y.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.title}),(0,Y.jsx)(`p`,{className:z(`line-clamp-3 whitespace-pre-wrap text-sm text-fg-secondary`,e.title&&`mt-0.5`),children:e.body}),a?(0,Y.jsxs)(`div`,{className:`mt-2 flex items-center gap-3`,children:[(0,Y.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:`Delete this entry? This can’t be undone.`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{o(!1),i()},className:`text-2xs font-medium text-interrupted transition-colors hover:underline`,children:`Delete`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>o(!1),className:`text-2xs text-fg-muted transition-colors hover:text-fg`,children:`Cancel`})]}):(0,Y.jsxs)(`div`,{className:`mt-2 flex items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`text-2xs uppercase tracking-wide text-fg-muted`,children:e.scope===`profile`?`Profile-wide`:`Project`}),e.agent_type&&(0,Y.jsx)(At,{type:e.agent_type,className:`size-3 text-fg-gold`}),e.tags.map(e=>(0,Y.jsx)(`span`,{className:`rounded-full bg-surface px-1.5 text-2xs text-fg-secondary`,children:e},e)),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[t&&(0,Y.jsx)(Ci,{icon:Nn,label:`Insert into focused terminal`,onClick:t}),(0,Y.jsx)(Ci,{icon:ut,label:`Copy`,onClick:n}),(0,Y.jsx)(Ci,{icon:h,label:`Edit`,onClick:r}),(0,Y.jsx)(Ci,{icon:wt,label:`Delete`,onClick:()=>o(!0)})]})]})]})}function Ci({icon:e,label:t,onClick:n}){return(0,Y.jsxs)(U,{children:[(0,Y.jsx)(H,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:n,className:`rounded-md p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,Y.jsx)(e,{className:`size-3.5`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,Y.jsx)(V,{children:t})]})}var wi=a.parse({});function Ti(e,t){let[n,r]=(0,J.useState)(null),i=De(t).data,a=st(e??void 0,t&&e!==null).data;return(0,J.useEffect)(()=>{if(!t||e===null){r(null);return}let n=!1,i;try{i=Kt(sessionStorage.getItem(Gt(e)))}catch{i={kind:`absent`}}if(i.kind===`present`){r(i.snapshot);return}return Je(e).then(e=>{n||r(e?e.ui_state:wi)}).catch(()=>{n||r(wi)}),()=>{n=!0}},[t,e]),(0,J.useMemo)(()=>{if(!t||e===null||n===null)return null;let o=t=>{if(!i||!a)return!1;let{patch:o,projectBased:s}=Bt(n,t,{alive:new Set(i.filter(e=>e.status!==`archived`).map(e=>e.id)),sessionProject:new Map(i.map(e=>[e.id,e.project_id])),projectIds:a.map(e=>e.id),currentProject:null}),c={...n,...o};r(c),Ce(e,c).catch(e=>console.warn(`ui-state save failed: ${e.message}`));try{sessionStorage.setItem(Gt(e),JSON.stringify(c))}catch(e){console.warn(`ui-state write failed: ${e.message}`)}return j().projectBasedLayout!==s&&A({projectBasedLayout:s}),!0},s=Object.fromEntries(Object.entries(n.project_layouts).map(([e,t])=>[e,{layoutRef:t.layout_ref,signature:B(t.layout_tree)}]));return(n.layout_mode??`profile`)===`project`?{headless:!0,scope:`project`,projectId:``,layoutRef:null,signature:B(null),slices:s,capture:()=>({layout_tree:null,active_session:null}),apply:o}:{scope:`profile`,projectId:``,layoutRef:n.layout_ref,signature:B(n.layout_tree),slices:s,capture:()=>({layout_tree:n.layout_tree,active_session:n.active_session}),apply:o}},[t,e,n,i,a])}var Ei=B(null);function Di(){let e=Vt(),t=bt(),n=I(),r=Ut(),i=Ti(n,e&&r===null),a=r??i,o=Re(n??void 0,void 0).data??[],s=st(n??void 0,e&&n!==null).data??[],c=Ae(),l=rt(),u=Te(),[d,f]=(0,J.useState)(``),[p,h]=(0,J.useState)(!1),[g,_]=(0,J.useState)(null);(0,J.useEffect)(()=>le(`layouts.toggle`,zt),[]),(0,J.useEffect)(()=>{e||(f(``),h(!1),_(null))},[e]);let v=a?.headless===!0,y=a===null||v?null:o.find(e=>e.id===a.layoutRef)??null,b=a!==null&&!v&&(y===null?a.signature!==Ei:B(y.layout_tree)!==a.signature),x=e=>{let t=a?.slices?.[e];if(!t)return!1;let n=t.layoutRef===null?null:o.find(e=>e.id===t.layoutRef)??null;return n?B(n.layout_tree)!==t.signature:t.signature!==Ei},S=e=>a===null?!1:e.scope===`profile`?a.scope===`profile`&&b:e.project_id===null?!1:a.scope===`project`?!v&&e.project_id===a.projectId?b:x(e.project_id):b||x(e.project_id),C=e=>y!==null&&e.id===y.id,w=e=>(e===null?void 0:s.find(t=>t.id===e)?.name)??`Project`,T=a!==null&&!v&&a.scope===`project`?o.filter(e=>e.scope===`profile`||e.project_id===a.projectId):o,E=[...T.some(e=>e.scope===`profile`)?[{key:`profile`,name:`Profile-wide`}]:[],...[...new Set(T.flatMap(e=>e.project_id===null?[]:[e.project_id]))].map(e=>({key:e,name:w(e)})).sort((e,t)=>e.name.localeCompare(t.name))],D=g===null?T:g===`profile`?T.filter(e=>e.scope===`profile`):T.filter(e=>e.project_id===g),O=e=>a!==null&&e.scope===a.scope&&(a.scope===`profile`||e.project_id===a.projectId),k=(e,t,r)=>{!a||!n||c.mutate({profile_id:n,scope:a.scope,project_id:a.scope===`project`?a.projectId:void 0,name:e,...t},{onSuccess:e=>{r&&a.apply(e)},onError:e=>K(e)})},A=e=>{if(!a)return;let t=O(e)?e:o.find(t=>t.name===e.name&&O(t));if(!t){k(e.name,a.capture(),!0);return}l.mutate({id:t.id,...a.capture()},{onSuccess:e=>a.apply(e),onError:e=>K(e)})},j=(e,t)=>k(t,{layout_tree:e.layout_tree,active_session:e.active_session},!1),M=e=>{if(a){if(!a.apply(e)){ae.error(`Workspace is still loading — try again in a moment`);return}e.project_id!==null&&e.project_id!==a.projectId&&t(`/project/${e.project_id}`),Lt(!1)}};return(0,Y.jsxs)(ln,{open:e,onOpenChange:Lt,children:[(0,Y.jsxs)(U,{children:[(0,Y.jsx)(H,{asChild:!0,children:(0,Y.jsx)(cn,{asChild:!0,children:(0,Y.jsxs)(W,{variant:`ghost`,size:`icon`,className:`compact:h-7 compact:w-7`,children:[(0,Y.jsx)(Pn,{}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`Layouts`})]})})}),(0,Y.jsx)(V,{children:`Layouts`})]}),(0,Y.jsxs)(sn,{className:`w-[26rem] max-w-[calc(100vw-1rem)] p-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-5 pb-2 pt-4`,children:[(0,Y.jsx)(`span`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Layouts`}),a!==null&&!v&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>h(e=>!e),className:`ml-auto flex items-center rounded-md p-1 text-fg-gold transition-colors hover:bg-surface hover:text-fg`,children:[(0,Y.jsx)(Tt,{className:`size-4`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`Save the current layout as a new layout`})]})]}),a===null?(0,Y.jsx)(`p`,{className:`px-5 pb-3 text-sm text-fg-muted`,children:`Loading the profile’s layout state…`}):v?(0,Y.jsx)(`p`,{className:`px-5 pb-3 text-sm text-fg-muted`,children:`Project-based layout is on — every project keeps its own layout. Open a project to name or save it; loading works from here.`}):(y===null||p)&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 px-5 pb-3`,children:[y===null&&(0,Y.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:`Unnamed layout`}),(0,Y.jsx)(`span`,{className:`text-2xs uppercase tracking-wide text-fg-muted`,children:a.scope===`profile`?`Profile-wide`:`Project`}),(0,Y.jsx)(`span`,{className:`ml-auto text-2xs text-interrupted`,children:`Unsaved`})]}),(0,Y.jsxs)(`form`,{className:`flex items-center gap-1.5`,onSubmit:e=>{e.preventDefault();let t=d.trim();t&&(k(t,a.capture(),!0),f(``),h(!1))},children:[(0,Y.jsx)(m,{autoFocus:p,value:d,placeholder:y===null?`Name this layout…`:`Save as a new layout…`,spellCheck:!1,onChange:e=>f(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&h(!1)},className:`h-8 flex-1 text-sm`}),(0,Y.jsx)(W,{size:`sm`,type:`submit`,disabled:!d.trim(),children:`Save`}),y!==null&&(0,Y.jsx)(W,{variant:`ghost`,size:`sm`,onClick:()=>h(!1),children:`Cancel`})]})]}),E.length>1&&(0,Y.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 px-5 pb-2`,children:E.map(e=>(0,Y.jsx)(Ai,{active:g===e.key,onClick:()=>_(t=>t===e.key?null:e.key),children:e.name},e.key))}),(0,Y.jsxs)(`div`,{className:`no-scrollbar max-h-[60vh] overflow-y-auto px-2 pb-3`,children:[D.length===0&&(0,Y.jsx)(`p`,{className:`px-3 py-3 text-sm text-fg-muted`,children:g===null?`No layouts yet — name and save the current layout to keep it.`:`Nothing matches this filter.`}),(0,Y.jsx)(`ul`,{className:`flex flex-col`,children:D.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(Oi,{layout:e,projectLabel:e.scope===`profile`?null:w(e.project_id),isCurrent:C(e),dirty:b,loadable:a!==null,savable:a!==null&&!v,confirmBeforeLoad:S(e),overwrites:O(e),onLoad:()=>M(e),onRename:t=>l.mutate({id:e.id,name:t}),onDelete:()=>u.mutate(e.id),onSaveAs:()=>A(e),onDuplicate:t=>j(e,t)})},e.id))})]})]})]})}function Oi({layout:e,projectLabel:t,isCurrent:n,dirty:r,loadable:i,savable:a,confirmBeforeLoad:o,overwrites:s,onLoad:c,onRename:l,onDelete:u,onSaveAs:d,onDuplicate:f}){let[p,g]=(0,J.useState)(null),[_,v]=(0,J.useState)(null),[y,b]=(0,J.useState)(e.name),x=()=>{if(!(!i||_!==null)){if(o&&p!==`load`){g(`load`);return}g(null),c()}},S=t=>{g(null),b(t===`rename`?e.name:`${e.name} copy`),v(t)},C=()=>{if(n){d();return}g(`save`)},w=n?r?`unsaved`:`active`:null;return(0,Y.jsxs)(`div`,{onClick:e=>{e.target.closest(`button, input`)||x()},className:z(`rounded-md px-3 py-2.5 transition-colors`,i&&`cursor-pointer hover:bg-surface`),children:[_===null?(0,Y.jsxs)(`p`,{className:z(`flex items-baseline gap-2 text-sm font-medium`,w===`active`?`text-success`:w===`unsaved`?`text-interrupted`:`text-fg`),children:[e.name,w!==null&&(0,Y.jsx)(`span`,{className:`text-2xs font-normal`,children:w===`active`?`Active`:`Unsaved`})]}):(0,Y.jsxs)(`form`,{className:`flex items-center gap-1.5`,onSubmit:t=>{t.preventDefault();let n=y.trim();n&&(_===`rename`?n!==e.name&&l(n):f(n)),v(null)},children:[(0,Y.jsx)(m,{autoFocus:!0,value:y,spellCheck:!1,onChange:e=>b(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&v(null)},className:`h-7 flex-1 text-sm`}),(0,Y.jsx)(W,{size:`sm`,type:`submit`,disabled:!y.trim(),children:_===`rename`?`Rename`:`Save`})]}),p===`save`?(0,Y.jsx)(ki,{question:s?`Overwrite “${e.name}” with the current layout?`:`Save the current layout as “${e.name}” here?`,verb:s?`Overwrite`:`Save`,onConfirm:()=>{g(null),d()},onCancel:()=>g(null)}):p===`delete`?(0,Y.jsx)(ki,{question:`Delete this layout? This can’t be undone.`,verb:`Delete`,onConfirm:()=>{g(null),u()},onCancel:()=>g(null)}):p===`load`?(0,Y.jsx)(ki,{question:`Loading discards unsaved layout changes.`,verb:`Load`,onConfirm:x,onCancel:()=>g(null)}):(0,Y.jsxs)(`div`,{className:`mt-2 flex items-center gap-1.5`,children:[t!==null&&(0,Y.jsx)(`span`,{className:`text-2xs uppercase tracking-wide text-fg-muted`,children:t}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[a&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(ji,{icon:Ln,label:n?`Save`:`Save the current layout as “${e.name}”`,onClick:C}),(0,Y.jsx)(ji,{icon:ut,label:`Duplicate`,onClick:()=>S(`duplicate`)})]}),(0,Y.jsx)(ji,{icon:h,label:`Rename`,onClick:()=>S(`rename`)}),(0,Y.jsx)(ji,{icon:wt,label:`Delete`,onClick:()=>g(`delete`)})]})]})]})}function ki({question:e,verb:t,onConfirm:n,onCancel:r}){return(0,Y.jsxs)(`div`,{className:`mt-2 flex items-center gap-3`,children:[(0,Y.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:e}),(0,Y.jsx)(`button`,{type:`button`,onClick:n,className:`text-2xs font-medium text-interrupted transition-colors hover:underline`,children:t}),(0,Y.jsx)(`button`,{type:`button`,onClick:r,className:`text-2xs text-fg-muted transition-colors hover:text-fg`,children:`Cancel`})]})}function Ai({active:e,onClick:t,children:n}){return(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":e,onClick:t,className:z(`rounded-full px-2 py-0.5 text-2xs transition-colors`,e?`bg-action text-action-ink`:`bg-surface text-fg-secondary hover:text-fg`),children:n})}function ji({icon:e,label:t,onClick:n}){return(0,Y.jsxs)(U,{children:[(0,Y.jsx)(H,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:n,className:`rounded-md p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,Y.jsx)(e,{className:`size-3.5`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,Y.jsx)(V,{children:t})]})}var Mi=nt()!==void 0&&/Mac/.test(navigator.platform),Ni=(0,J.lazy)(()=>M(()=>import(`./SettingsDialog-Sd6i7Plz.js`).then(e=>({default:e.SettingsDialog})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29])));function Pi(){let e=_e();(0,J.useEffect)(()=>{let t=t=>{for(let[n,r]of e.getQueriesData({queryKey:[`sessions`]}))r&&e.setQueryData(n,r.map(t));for(let[n,r]of e.getQueriesData({queryKey:[`project`]}))r&&e.setQueryData(n,{...r,sessions:r.sessions.map(t)})},n=q.onStatus(e=>t(t=>t.id===e.session?{...t,status:e.status,last_activity_at:e.last_activity_at}:t)),r=q.onRenamed(e=>t(t=>t.id===e.session?{...t,title:e.title,agent_title:`agent_title`in e?e.agent_title:t.agent_title,osc_title:`osc_title`in e?e.osc_title:t.osc_title}:t)),i=q.onAccount(t=>{for(let[n,r]of e.getQueriesData({queryKey:[`accounts`]}))r&&e.setQueryData(n,r.map(e=>e.id===t.account_id?{...e,logged_in:t.logged_in}:e))}),a=t=>{e.invalidateQueries({queryKey:[`sessions`]});for(let n of t)e.invalidateQueries({queryKey:[`project`,n]})},o=q.onSessionsChanged(e=>a(e.project_ids)),s=q.onSessionSwitched(e=>a([e.target_project]));return()=>{n(),r(),i(),o(),s()}},[e])}function Fi(){let e=qe(),t=Xe(),[n,r]=(0,J.useState)(!1),i=Se(e.data),a=n=>{r(!1);let a=n.trim();a!==i&&t.mutate({displayName:a===e.data?.hostname?``:a},{onError:e=>K(e)})},o=!Mi&&(0,Y.jsx)(`img`,{src:`/puddle.svg`,alt:`Puddle`,className:`size-4`}),s=z(`flex shrink-0 items-center gap-2`,Mi&&`[-webkit-app-region:no-drag]`),c=`truncate text-sm font-semibold text-fg-secondary`;return n&&i!==void 0?(0,Y.jsxs)(`div`,{className:s,children:[o,(0,Y.jsx)(Rt,{initial:e.data?.displayName??i,maxLength:64,className:z(c,`w-40`),onCommit:a,onCancel:()=>r(!1)})]}):(0,Y.jsxs)(dt,{to:`/`,className:z(s,`transition-opacity hover:opacity-70`),title:`All projects`,children:[o,i!==void 0&&(0,Y.jsx)(`span`,{className:c,...qt(()=>r(!0)),children:i})]})}function Ii(){let e=pt(),t=de(`palette.toggle`),n=it(e.id).data?.project,r=n!==void 0&&n.id===e.id?n.name:void 0;return(0,Y.jsxs)(`button`,{type:`button`,onClick:jt,className:z(`absolute left-1/2 flex h-6 w-[min(30rem,42%)] -translate-x-1/2 items-center justify-center gap-2 rounded-md bg-ground text-fg-muted transition-colors hover:bg-elevated hover:text-fg-secondary`,Mi&&`[-webkit-app-region:no-drag]`),children:[(0,Y.jsx)(`span`,{className:z(`truncate text-xs`,r&&f(n?.colour)),children:r??`Puddle`}),(0,Y.jsx)(`span`,{className:`text-2xs`,children:t})]})}function Li(){let{fullScreen:e,animate:t}=Ze();return(0,Y.jsxs)(`header`,{className:z(`relative flex h-9 shrink-0 items-center gap-3 bg-surface pl-3 pr-3`,Mi&&!e&&`pl-[88px] [-webkit-app-region:drag]`,t&&`transition-[padding] duration-200 ease-out`),children:[(0,Y.jsx)(Fi,{}),(0,Y.jsx)(Ii,{}),(0,Y.jsxs)(`div`,{className:z(`ml-auto flex items-center`,Mi&&`[-webkit-app-region:no-drag]`),children:[(0,Y.jsxs)(U,{children:[(0,Y.jsx)(H,{asChild:!0,children:(0,Y.jsxs)(W,{variant:`ghost`,size:`icon`,className:`compact:h-7 compact:w-7`,onClick:()=>Yt(),children:[(0,Y.jsx)(zn,{}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`Settings`})]})}),(0,Y.jsx)(V,{children:`Settings`})]}),(0,Y.jsx)(Di,{}),(0,Y.jsx)(xi,{}),(0,Y.jsx)(ri,{})]})]})}function Ri(){Pi(),oi(),vi();let{handler:e}=kt(),t=I(),{pathname:n}=ht(),[r,i]=(0,J.useState)(!1),a=Pe(),o=a.data!==void 0&&Qe(a.data.protocol);return(0,J.useEffect)(()=>{if(!o)return;let e=()=>{let e=te();q.reportTheme(e(`--text-primary`),e(`--bg-base`))};return e(),ee(e)},[o]),(0,Y.jsxs)(`div`,{className:`flex h-screen flex-col overflow-hidden overscroll-y-none bg-ground`,children:[(0,Y.jsx)(Li,{}),(0,Y.jsx)(`main`,{className:`min-h-0 flex-1`,children:(0,Y.jsx)(hn,{resetOn:n,scope:n.startsWith(`/project/`)?`workspace`:`view`,children:(0,Y.jsx)(_t,{})})}),(0,Y.jsx)(Qr,{}),(0,Y.jsx)(ai,{}),(0,Y.jsx)(qr,{onNewSession:e??void 0,onNewProject:()=>i(!0)}),t!==null&&(0,Y.jsx)($t,{profileId:t,open:r,onOpenChange:i}),(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)(Ni,{})}),(0,Y.jsx)(Xr,{})]})}function zi(){return(0,Y.jsx)(Wt,{children:(0,Y.jsx)(Ri,{})})}var Bi=(0,J.lazy)(()=>M(()=>import(`./Dashboard-fA7E3Mr1.js`).then(e=>({default:e.Dashboard})),__vite__mapDeps([30,1,2,3,4,5,6,7,8,9,10,13,12,31,20,32,23,33,34,16,27,26,35]))),Vi=(0,J.lazy)(()=>M(()=>import(`./Workspace-C-M1AjMn.js`).then(e=>({default:e.Workspace})),__vite__mapDeps([36,1,2,3,4,5,6,7,8,9,10,17,18,19,12,13,37,38,23,33,31,15,39,14,40,41,20,32,42,21,22,43,35,26,16,44,45,46,29,47]))),Hi=new mn({defaultOptions:{queries:{retry:1,staleTime:5e3}},mutationCache:new dn({onError:e=>K(e)})});function Ui(){let e=I(),t=Le(),n=e!==null&&t.data!==void 0&&!t.data.some(t=>t.id===e);return e===null||n?(0,Y.jsx)(Bn,{}):(0,Y.jsx)(mt,{useTransitions:!1,children:(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)(ft,{children:(0,Y.jsxs)(vt,{element:(0,Y.jsx)(zi,{}),children:[(0,Y.jsx)(vt,{path:`/`,element:(0,Y.jsx)(Bi,{})}),(0,Y.jsx)(vt,{path:`/project/:id`,element:(0,Y.jsx)(Vi,{})}),(0,Y.jsx)(vt,{path:`/project/:id/session/:sid`,element:(0,Y.jsx)(Vi,{})})]})})})})}function Wi(){let e=(0,J.useSyncExternalStore)(u.subscribe,u.get);return(0,Y.jsx)(pe,{client:Hi,children:(0,Y.jsxs)(It,{delayDuration:300,children:[(0,Y.jsx)(Mn,{}),(0,Y.jsx)(hn,{scope:`app`,children:e?window.location.pathname.startsWith(`/forward/`)?(0,Y.jsx)(un,{}):(0,Y.jsx)(Ui,{}):(0,Y.jsx)(_n,{})}),(0,Y.jsx)(gn,{})]})})}export{Wi as App};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{g as r}from"./auth-cjbSLnao.js";import{a as i,c as a,f as o,i as s,l as c,o as l,p as u,s as d,t as f}from"./LazyTerminal-CAvxgexS.js";import{E as p,Y as m,d as h,ft as g,gt as _,k as v,kt as y,pt as b,wt as x,yt as S}from"./protocol-support-CJIxbQCB.js";import{a as C,n as w,t as T}from"./project-abbrev-Bz8ZEwrb.js";import{n as E}from"./x-DCpy1q13.js";import{t as D}from"./button-Chvl9hcE.js";import{c as O,f as k,h as A,m as j,n as M,p as N,r as P,t as F}from"./context-menu-DVUv5Z6a.js";import{r as I}from"./dist-DmyIHyF9.js";import{t as L}from"./NewProjectDialog-eDAOcbIM.js";import{n as R}from"./errors-BiS6nBXL.js";import{t as z}from"./ws-B1kcYo2j.js";import{a as B,i as V,n as H,o as U,t as W}from"./dialog-Bnex_wlx.js";var G=e(t(),1),K=n(),q=!1;function J(){let[e,t]=(0,G.useState)(q),[n,i]=(0,G.useState)(null);(0,G.useEffect)(()=>{if(!e)return;let t=!1;return z.spawnShell(r).then(e=>{t||i(e)}),()=>{t=!0}},[e]);let a=()=>{q=!1,t(!1),i(null)};return{open:e,term:n,toggle:()=>{e?(n&&z.killShell(r,n),a()):(q=!0,t(!0))},onExit:a}}function Y({term:e,onExit:t}){return(0,K.jsx)(`div`,{className:`h-72 shrink-0 pb-6`,children:(0,K.jsx)(`div`,{className:`mx-auto size-full max-w-4xl px-6`,children:e!==null&&(0,K.jsx)(f,{stream:`home`,term:e,onExit:t})})})}var X=`group block w-full rounded-lg bg-surface p-4 text-left transition-colors hover:bg-elevated`,ee=[{status:`running`,colour:`bg-running`},{status:`waiting_input`,colour:`bg-waiting`},{status:`interrupted`,colour:`bg-interrupted`}];function te({project:e,repoPath:t,sessions:n}){let r=n.filter(e=>e.status!==`archived`);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`h2`,{className:E(`truncate pr-16 text-base font-semibold`,i(e.colour)||`text-fg group-hover:text-accent`),children:e.name}),(0,K.jsx)(`p`,{className:`mt-1 truncate text-2xs text-fg-muted`,children:t??`…`}),(0,K.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3 text-2xs text-fg-muted tabular-nums`,children:[(0,K.jsxs)(`span`,{children:[r.length,` session`,r.length===1?``:`s`]}),ee.map(({status:e,colour:t})=>{let n=r.filter(t=>t.status===e).length;return n>0?(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`span`,{className:`size-1.5 rounded-full ${t}`}),n,` `,e.replace(`_`,` `)]},e):null})]})]})}function Z({icon:e,label:t,onClick:n}){return(0,K.jsx)(`button`,{type:`button`,"aria-label":t,title:t,onClick:e=>{e.preventDefault(),e.stopPropagation(),n()},className:`flex items-center rounded-md p-1.5 text-fg-muted transition-colors hover:bg-ground hover:text-fg`,children:(0,K.jsx)(e,{className:`size-4`})})}function Q({project:e,repoPath:t,draggable:n,dragging:r,onDragStart:d,onDragEnd:f,onDragOver:p}){let g=b(),_=h(m().data?.protocol),v=y(e.id),[x,S]=(0,G.useState)(!1),[w,T]=(0,G.useState)(e.name),[k,N]=(0,G.useState)(u(e)),[I,L]=(0,G.useState)(e.colour??null),z=t=>g.mutate({id:e.id,archived:t},{onError:e=>R(e)}),q=()=>{T(e.name),L(e.colour??null),N(u(e)),S(!0)},J=()=>{let t=w.trim(),n=o(k);if(!t){S(!1);return}let r={...t===e.name?{}:{name:t},...n&&n!==u(e)?{abbrev:n}:{},..._&&I!==(e.colour??null)?{colour:I}:{}};if(Object.keys(r).length===0){S(!1);return}g.mutate({id:e.id,...r},{onSuccess:()=>S(!1),onError:e=>R(e)})};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(F,{children:[(0,K.jsx)(O,{asChild:!0,children:(0,K.jsxs)(`div`,{draggable:n,onDragStart:d,onDragEnd:f,onDragOver:p,className:E(`group relative transition-opacity`,r&&`opacity-50`),children:[(0,K.jsx)(C,{draggable:!1,to:`/project/${e.id}`,className:X,children:(0,K.jsx)(te,{project:e,repoPath:t,sessions:v.data??[]})}),(0,K.jsx)(`div`,{className:`absolute right-2 top-2 hidden gap-0.5 group-hover:flex has-[[data-state=open]]:flex pointer-coarse:flex`,children:e.archived?(0,K.jsx)(Z,{icon:A,label:`Reopen project`,onClick:()=>z(!1)}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Z,{icon:l,label:`Edit project`,onClick:q}),(0,K.jsx)(Z,{icon:j,label:`Archive project`,onClick:()=>z(!0)})]})})]})}),(0,K.jsx)(M,{children:e.archived?(0,K.jsxs)(P,{onSelect:()=>z(!1),children:[(0,K.jsx)(A,{}),` Reopen`]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(P,{onSelect:q,children:[(0,K.jsx)(l,{}),` Edit`]}),(0,K.jsxs)(P,{onSelect:()=>z(!0),children:[(0,K.jsx)(j,{}),` Archive`]})]})})]}),(0,K.jsx)(W,{open:x,onOpenChange:S,children:(0,K.jsxs)(H,{children:[(0,K.jsx)(B,{children:(0,K.jsx)(U,{children:`Edit project`})}),(0,K.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),J()},children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsx)(a,{htmlFor:`project-name-${e.id}`,children:`Name`}),(0,K.jsx)(c,{id:`project-name-${e.id}`,value:w,className:i(I),onChange:e=>T(e.target.value),autoFocus:!0})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsx)(a,{htmlFor:`project-abbrev-${e.id}`,children:`Abbreviation`}),(0,K.jsx)(c,{id:`project-abbrev-${e.id}`,maxLength:5,value:k,onChange:e=>N(o(e.target.value)),className:`w-24 uppercase`}),(0,K.jsxs)(`p`,{className:`text-2xs text-fg-muted`,children:[`Up to `,5,` characters — the label on the collapsed sidebar rail.`]})]}),_&&(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`text-xs text-fg-secondary`,children:`Colour`}),(0,K.jsx)(s,{value:I,onChange:L,label:`Project colour`})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(a,{className:`text-fg-muted`,children:`Path`}),(0,K.jsx)(`p`,{className:`truncate text-2xs text-fg-muted`,children:t??`…`})]}),(0,K.jsxs)(V,{children:[(0,K.jsx)(D,{type:`button`,variant:`ghost`,onClick:()=>S(!1),children:`Cancel`}),(0,K.jsx)(D,{type:`submit`,disabled:!w.trim()||g.isPending,children:`Save`})]})]})]})})]})}function $({icon:e,label:t,hint:n,onClick:r}){return(0,K.jsxs)(`button`,{type:`button`,onClick:r,className:`group flex flex-col rounded-lg bg-surface p-4 text-left transition-colors hover:bg-elevated`,children:[(0,K.jsxs)(`h2`,{className:`flex items-center gap-2 truncate text-base font-semibold text-fg group-hover:text-accent`,children:[(0,K.jsx)(e,{className:`size-4 shrink-0`}),t]}),(0,K.jsx)(`p`,{className:`mt-1 truncate text-2xs text-fg-muted`,children:n})]})}function ne(){let e=v(),t=S(e??void 0),n=x(),r=_(e??void 0),i=g(e??``),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(!1),f=J(),m=p(`palette.toggle`),h=e=>n.data?.find(t=>t.id===e)?.path,y=t.data??[],b=r.data?.projectOrder??[],C=k(y.filter(e=>!e.archived),b),D=y.filter(e=>e.archived),O=(e,t)=>{e!==t&&i.mutate({projectOrder:N(C.map(e=>e.id),e,t)})};return(0,K.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,K.jsxs)(`div`,{className:`mx-auto max-w-4xl p-6`,children:[y.length===0&&(0,K.jsxs)(`div`,{className:`mb-8 mt-16 flex flex-col items-center gap-3 text-center`,children:[(0,K.jsx)(d,{className:`size-8 text-fg-muted`}),(0,K.jsxs)(`p`,{className:`text-sm text-fg-secondary`,children:[`No projects yet — open one below, or press `,m,`.`]})]}),(0,K.jsxs)(`div`,{className:`grid auto-rows-fr grid-cols-1 gap-3 sm:grid-cols-2`,children:[C.map(e=>(0,K.jsx)(Q,{project:e,repoPath:h(e.repo_id),draggable:!0,dragging:s===e.id,onDragStart:()=>c(e.id),onDragEnd:()=>c(null),onDragOver:t=>{t.preventDefault(),s&&s!==e.id&&O(s,e.id)}},e.id)),(0,K.jsx)($,{icon:w,label:`Open project`,hint:`Point at a repository on this host`,onClick:()=>o(!0)}),(0,K.jsx)($,{icon:T,label:f.open?`Close terminal`:`Open terminal`,hint:f.open?`End the shell below`:`A shell at ~ for cloning repositories`,onClick:f.toggle})]}),D.length>0&&(0,K.jsxs)(`div`,{className:`mt-6`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>u(e=>!e),className:`flex items-center gap-1.5 px-1 py-1.5 text-2xs uppercase tracking-wide text-fg-muted transition-colors hover:text-fg`,children:[(0,K.jsx)(I,{className:E(`size-3 transition-transform`,l&&`rotate-90`)}),(0,K.jsx)(j,{className:`size-3`}),(0,K.jsx)(`span`,{children:`Archived`}),(0,K.jsx)(`span`,{className:`tabular-nums`,children:D.length})]}),l&&(0,K.jsx)(`div`,{className:`mt-2 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:D.map(e=>(0,K.jsx)(Q,{project:e,repoPath:h(e.repo_id),draggable:!1,dragging:!1,onDragStart:()=>{},onDragEnd:()=>{},onDragOver:()=>{}},e.id))})]})]})}),f.open&&(0,K.jsx)(Y,{term:f.term,onExit:f.onExit}),e!==null&&(0,K.jsx)(L,{profileId:e,open:a,onOpenChange:o})]})}export{ne as Dashboard};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{t as r}from"./x-DCpy1q13.js";import{t as i}from"./button-Chvl9hcE.js";import{t as a}from"./createLucideIcon-DyMAgLa3.js";import{a as o,i as s,n as c,o as l,r as u,t as d}from"./dialog-Bnex_wlx.js";import{t as f}from"./drafts-B_tChlzR.js";import{i as p,t as m,u as h}from"./buffer-store-BAQjeFXg.js";import{t as g}from"./editor-sync-W1bamxAP.js";var _=a(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),v=e(t(),1),y=n();function b(e,t,n){let r=m(e,t,n);return(0,v.useSyncExternalStore)((0,v.useCallback)(e=>h(r,e),[r]),()=>p(r))}function x({session:e,path:t,kind:n,root:r}){return b(e,t,r)&&n!==`commit`?(0,y.jsx)(_,{"aria-hidden":!0,className:`size-2 shrink-0 fill-current text-fg-muted group-hover:hidden`}):null}function S({session:e,path:t,kind:n,root:a,label:p,onClose:m}){let h=b(e,t,a)&&n!==`commit`,[_,x]=(0,v.useState)(!1),S=()=>h?x(!0):m();return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`button`,{onClick:e=>{e.stopPropagation(),S()},className:`hidden size-4 items-center justify-center rounded-sm text-fg-muted transition-colors hover:text-fg group-hover:flex pointer-coarse:flex`,"aria-label":`Close ${p}`,children:(0,y.jsx)(r,{className:`size-3`})}),(0,y.jsx)(d,{open:_,onOpenChange:e=>!e&&x(!1),children:(0,y.jsxs)(c,{children:[(0,y.jsxs)(o,{children:[(0,y.jsxs)(l,{children:[`Discard changes to `,p,`?`]}),(0,y.jsx)(u,{children:`This file has unsaved changes. Closing the tab will discard them.`})]}),(0,y.jsxs)(s,{children:[(0,y.jsx)(i,{variant:`ghost`,onClick:()=>x(!1),children:`Keep editing`}),(0,y.jsx)(i,{variant:`danger`,onClick:()=>{f(e,t,a),g(e,t,a),x(!1),m()},children:`Discard`})]})]})})]})}export{x as EditorDirtyDot,S as EditorTabClose};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{n as r,t as i}from"./x-CZCUod6A.js";import{t as a}from"./createLucideIcon-DyMAgLa3.js";import{n as o,r as s,t as c}from"./whole-word-2m2pmAFT.js";import{t as l}from"./chevron-down--sjpQEHH.js";var u=a(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),d=/[.*+?^${}()|[\]\\]/g;function f(e,t){if(e.length===0)return null;try{let n=t.regex?e:e.replace(d,`\\$&`);return t.wholeWord&&(n=`\\b(?:${n})\\b`),new RegExp(n,t.caseSensitive?`g`:`gi`)}catch{return null}}function p(e,t){return e.length===0||f(e,t)!==null}function m(e,t,n,r=1e3){let i=f(t,n);if(t.length>0&&i===null)return{matches:[],invalid:!0,limited:!1};if(!i)return{matches:[],invalid:!1,limited:!1};let a=[],o;for(;(o=i.exec(e))!==null;){if(o[0].length===0){i.lastIndex++;continue}if(a.length===r)return{matches:a,invalid:!1,limited:!0};a.push({start:o.index,end:o.index+o[0].length})}return{matches:a,invalid:!1,limited:!1}}var h=e(t(),1),g={index:-1,count:0},_={caseSensitive:!1,wholeWord:!1,regex:!1},v=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform);function y(e,t=v){return e.key.toLowerCase()===`f`&&!e.altKey&&!e.shiftKey&&(t?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey)}function b({shortcutEnabled:e,onFind:t,onClear:n,onCloseFocus:r}){let[i,a]=(0,h.useState)(!1),[o,s]=(0,h.useState)(0),[c,l]=(0,h.useState)(``),[u,d]=(0,h.useState)(_),[f,p]=(0,h.useState)(g),m=(0,h.useRef)({open:i,query:c,options:u});m.current={open:i,query:c,options:u};let v=(0,h.useRef)(t);v.current=t;let b=(0,h.useRef)(n);b.current=n;let x=(0,h.useRef)(r);x.current=r;let S=(0,h.useCallback)(e=>{let t=m.current;if(!t.open)return;let n=v.current(t.query,t.options,e);n&&p(n)},[]),C=(0,h.useCallback)(()=>{a(!0),s(e=>e+1)},[]),w=(0,h.useCallback)(()=>{a(!1),b.current(),x.current?.()},[]),T=(0,h.useCallback)(()=>S(`next`),[S]),E=(0,h.useCallback)(()=>S(`previous`),[S]),D=(0,h.useCallback)(()=>S(`reset`),[S]);return(0,h.useEffect)(()=>{i&&S(`reset`)},[i,c,u,S]),(0,h.useEffect)(()=>{if(!e)return;let t=e=>{y(e)&&(e.preventDefault(),e.stopPropagation(),C())};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[e,C]),(0,h.useEffect)(()=>()=>{b.current()},[]),{open:i,focusKey:o,query:c,options:u,result:f,openFind:C,close:w,next:T,previous:E,refresh:D,setQuery:l,setOptions:d,setResult:p}}var x=n();function S({active:e,label:t,onClick:n,children:i}){return(0,x.jsx)(`button`,{type:`button`,"aria-label":t,"aria-pressed":e,title:t,onClick:n,className:r(`rounded-sm p-1 transition-colors`,e?`bg-surface text-accent`:`text-fg-muted hover:bg-surface hover:text-fg`),children:i})}function C({query:e,result:t}){return e.length===0?null:t.invalid?(0,x.jsx)(x.Fragment,{children:`Invalid expression`}):t.count===0?(0,x.jsx)(x.Fragment,{children:`No results`}):t.limited?(0,x.jsxs)(x.Fragment,{children:[t.count,`+ results`]}):t.index<0?(0,x.jsxs)(x.Fragment,{children:[t.count,` results`]}):(0,x.jsxs)(x.Fragment,{children:[t.index+1,` of `,t.count]})}function w({query:e,focusKey:t,options:n,result:r,onQueryChange:a,onOptionsChange:d,onNext:f,onPrevious:p,onClose:m}){let g=(0,h.useRef)(null);(0,h.useEffect)(()=>{g.current?.focus(),g.current?.select()},[t]);let _=r.count>0&&!r.invalid;return(0,x.jsxs)(`div`,{role:`search`,"aria-label":`Find in view`,className:`absolute right-2 top-0 z-30 flex h-10 w-[min(34rem,calc(100%-0.5rem))] items-center gap-1.5 rounded-b-md bg-surface px-1.5 shadow-lg`,onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),m();return}if(e.key===`Enter`){e.preventDefault(),e.stopPropagation(),e.shiftKey?p():f();return}y(e.nativeEvent)&&(e.preventDefault(),e.stopPropagation(),g.current?.select())},children:[(0,x.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center rounded-md bg-elevated pl-2 pr-0.5`,children:[(0,x.jsx)(`input`,{ref:g,value:e,onChange:e=>a(e.target.value),placeholder:`Find`,spellCheck:!1,autoComplete:`off`,"aria-label":`Find`,className:`h-7 min-w-0 flex-1 bg-transparent text-sm text-fg outline-none placeholder:text-fg-muted`}),(0,x.jsx)(S,{active:n.caseSensitive,label:`Match case`,onClick:()=>d({...n,caseSensitive:!n.caseSensitive}),children:(0,x.jsx)(s,{className:`size-3.5`})}),(0,x.jsx)(S,{active:n.wholeWord,label:`Match whole word`,onClick:()=>d({...n,wholeWord:!n.wholeWord}),children:(0,x.jsx)(c,{className:`size-3.5`})}),(0,x.jsx)(S,{active:n.regex,label:`Use regular expression`,onClick:()=>d({...n,regex:!n.regex}),children:(0,x.jsx)(o,{className:`size-3.5`})})]}),(0,x.jsx)(`div`,{className:`w-20 shrink-0 text-center text-xs text-fg-muted`,children:(0,x.jsx)(C,{query:e,result:r})}),(0,x.jsx)(`button`,{type:`button`,"aria-label":`Previous match`,title:`Previous match (Shift+Enter)`,disabled:!_,onClick:p,className:`rounded-sm p-1 text-fg-muted transition-colors hover:bg-elevated hover:text-fg disabled:cursor-default disabled:opacity-40`,children:(0,x.jsx)(u,{className:`size-4`})}),(0,x.jsx)(`button`,{type:`button`,"aria-label":`Next match`,title:`Next match (Enter)`,disabled:!_,onClick:f,className:`rounded-sm p-1 text-fg-muted transition-colors hover:bg-elevated hover:text-fg disabled:cursor-default disabled:opacity-40`,children:(0,x.jsx)(l,{className:`size-4`})}),(0,x.jsx)(`button`,{type:`button`,"aria-label":`Close find`,title:`Close (Escape)`,onClick:m,className:`rounded-sm p-1 text-fg-muted transition-colors hover:bg-elevated hover:text-fg`,children:(0,x.jsx)(i,{className:`size-4`})})]})}export{m as a,g as i,b as n,p as o,y as r,w as t};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{n as r,t as i}from"./x-DCpy1q13.js";import{t as a}from"./createLucideIcon-DyMAgLa3.js";import{n as o,r as s,t as c}from"./whole-word-2m2pmAFT.js";import{t as l}from"./chevron-down--sjpQEHH.js";var u=a(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),d=/[.*+?^${}()|[\]\\]/g;function f(e,t){if(e.length===0)return null;try{let n=t.regex?e:e.replace(d,`\\$&`);return t.wholeWord&&(n=`\\b(?:${n})\\b`),new RegExp(n,t.caseSensitive?`g`:`gi`)}catch{return null}}function p(e,t){return e.length===0||f(e,t)!==null}function m(e,t,n,r=1e3){let i=f(t,n);if(t.length>0&&i===null)return{matches:[],invalid:!0,limited:!1};if(!i)return{matches:[],invalid:!1,limited:!1};let a=[],o;for(;(o=i.exec(e))!==null;){if(o[0].length===0){i.lastIndex++;continue}if(a.length===r)return{matches:a,invalid:!1,limited:!0};a.push({start:o.index,end:o.index+o[0].length})}return{matches:a,invalid:!1,limited:!1}}var h=e(t(),1),g={index:-1,count:0},_={caseSensitive:!1,wholeWord:!1,regex:!1},v=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform);function y(e,t=v){return e.key.toLowerCase()===`f`&&!e.altKey&&!e.shiftKey&&(t?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey)}function b({shortcutEnabled:e,onFind:t,onClear:n,onCloseFocus:r}){let[i,a]=(0,h.useState)(!1),[o,s]=(0,h.useState)(0),[c,l]=(0,h.useState)(``),[u,d]=(0,h.useState)(_),[f,p]=(0,h.useState)(g),m=(0,h.useRef)({open:i,query:c,options:u});m.current={open:i,query:c,options:u};let v=(0,h.useRef)(t);v.current=t;let b=(0,h.useRef)(n);b.current=n;let x=(0,h.useRef)(r);x.current=r;let S=(0,h.useCallback)(e=>{let t=m.current;if(!t.open)return;let n=v.current(t.query,t.options,e);n&&p(n)},[]),C=(0,h.useCallback)(()=>{a(!0),s(e=>e+1)},[]),w=(0,h.useCallback)(()=>{a(!1),b.current(),x.current?.()},[]),T=(0,h.useCallback)(()=>S(`next`),[S]),E=(0,h.useCallback)(()=>S(`previous`),[S]),D=(0,h.useCallback)(()=>S(`reset`),[S]);return(0,h.useEffect)(()=>{i&&S(`reset`)},[i,c,u,S]),(0,h.useEffect)(()=>{if(!e)return;let t=e=>{y(e)&&(e.preventDefault(),e.stopPropagation(),C())};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[e,C]),(0,h.useEffect)(()=>()=>{b.current()},[]),{open:i,focusKey:o,query:c,options:u,result:f,openFind:C,close:w,next:T,previous:E,refresh:D,setQuery:l,setOptions:d,setResult:p}}var x=n();function S({active:e,label:t,onClick:n,children:i}){return(0,x.jsx)(`button`,{type:`button`,"aria-label":t,"aria-pressed":e,title:t,onClick:n,className:r(`rounded-sm p-1 transition-colors`,e?`bg-surface text-accent`:`text-fg-muted hover:bg-surface hover:text-fg`),children:i})}function C({query:e,result:t}){return e.length===0?null:t.invalid?(0,x.jsx)(x.Fragment,{children:`Invalid expression`}):t.count===0?(0,x.jsx)(x.Fragment,{children:`No results`}):t.limited?(0,x.jsxs)(x.Fragment,{children:[t.count,`+ results`]}):t.index<0?(0,x.jsxs)(x.Fragment,{children:[t.count,` results`]}):(0,x.jsxs)(x.Fragment,{children:[t.index+1,` of `,t.count]})}function w({query:e,focusKey:t,options:n,result:r,onQueryChange:a,onOptionsChange:d,onNext:f,onPrevious:p,onClose:m}){let g=(0,h.useRef)(null);(0,h.useEffect)(()=>{g.current?.focus(),g.current?.select()},[t]);let _=r.count>0&&!r.invalid;return(0,x.jsxs)(`div`,{role:`search`,"aria-label":`Find in view`,className:`absolute right-2 top-0 z-30 flex h-10 w-[min(34rem,calc(100%-0.5rem))] items-center gap-1.5 rounded-b-md bg-surface px-1.5 shadow-lg`,onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),m();return}if(e.key===`Enter`){e.preventDefault(),e.stopPropagation(),e.shiftKey?p():f();return}y(e.nativeEvent)&&(e.preventDefault(),e.stopPropagation(),g.current?.select())},children:[(0,x.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center rounded-md bg-elevated pl-2 pr-0.5`,children:[(0,x.jsx)(`input`,{ref:g,value:e,onChange:e=>a(e.target.value),placeholder:`Find`,spellCheck:!1,autoComplete:`off`,"aria-label":`Find`,className:`h-7 min-w-0 flex-1 bg-transparent text-sm text-fg outline-none placeholder:text-fg-muted`}),(0,x.jsx)(S,{active:n.caseSensitive,label:`Match case`,onClick:()=>d({...n,caseSensitive:!n.caseSensitive}),children:(0,x.jsx)(s,{className:`size-3.5`})}),(0,x.jsx)(S,{active:n.wholeWord,label:`Match whole word`,onClick:()=>d({...n,wholeWord:!n.wholeWord}),children:(0,x.jsx)(c,{className:`size-3.5`})}),(0,x.jsx)(S,{active:n.regex,label:`Use regular expression`,onClick:()=>d({...n,regex:!n.regex}),children:(0,x.jsx)(o,{className:`size-3.5`})})]}),(0,x.jsx)(`div`,{className:`w-20 shrink-0 text-center text-xs text-fg-muted`,children:(0,x.jsx)(C,{query:e,result:r})}),(0,x.jsx)(`button`,{type:`button`,"aria-label":`Previous match`,title:`Previous match (Shift+Enter)`,disabled:!_,onClick:p,className:`rounded-sm p-1 text-fg-muted transition-colors hover:bg-elevated hover:text-fg disabled:cursor-default disabled:opacity-40`,children:(0,x.jsx)(u,{className:`size-4`})}),(0,x.jsx)(`button`,{type:`button`,"aria-label":`Next match`,title:`Next match (Enter)`,disabled:!_,onClick:f,className:`rounded-sm p-1 text-fg-muted transition-colors hover:bg-elevated hover:text-fg disabled:cursor-default disabled:opacity-40`,children:(0,x.jsx)(l,{className:`size-4`})}),(0,x.jsx)(`button`,{type:`button`,"aria-label":`Close find`,title:`Close (Escape)`,onClick:m,className:`rounded-sm p-1 text-fg-muted transition-colors hover:bg-elevated hover:text-fg`,children:(0,x.jsx)(i,{className:`size-4`})})]})}export{m as a,g as i,b as n,p as o,y as r,w as t};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Terminal-CqjwbNAI.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/jsx-runtime-ffCh33zF.js","assets/auth-cjbSLnao.js","assets/client-settings-CwqpIric.js","assets/preload-helper-Czpn1I53.js","assets/index-CW1P_8TN.js","assets/index-XBWIhnuP.css","assets/dist-Cl5AP2As.js","assets/protocol-support-CJIxbQCB.js","assets/copy-Df7qIcX6.js","assets/createLucideIcon-DyMAgLa3.js","assets/x-DCpy1q13.js","assets/FindWidget-BSK2PIfO.js","assets/whole-word-2m2pmAFT.js","assets/chevron-down--sjpQEHH.js","assets/selection-actions-C2udLSyj.js","assets/button-Chvl9hcE.js","assets/ws-B1kcYo2j.js","assets/code-DRWf9a5s.js","assets/errors-BiS6nBXL.js","assets/math-delimiters-BCnTi7Ii.js","assets/Terminal-BrP-ENHg.css"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{I as r}from"./auth-cjbSLnao.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{p as a}from"./es2015-CrC2hHeB.js";import{n as o}from"./x-DCpy1q13.js";import{t as s}from"./recipes-K5GH3Kht.js";import{t as c}from"./createLucideIcon-DyMAgLa3.js";function l(e){return e.trim().slice(0,5).toUpperCase()}function u(e){return e.abbrev??l(e.name)}function d(e){return e.trim().toUpperCase().slice(0,5)}var f=e(t(),1),p=n();function m({className:e,type:t,...n}){return(0,p.jsx)(`input`,{type:t,className:o(`flex h-8 w-full px-2.5`,s,e),...n})}function h({className:e,...t}){return(0,p.jsx)(`textarea`,{className:o(`flex min-h-16 w-full px-2.5 py-2`,s,e),...t})}var g=`Label`,_=f.forwardRef((e,t)=>(0,p.jsx)(a.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));_.displayName=g;var v=_;function y({className:e,...t}){return(0,p.jsx)(v,{className:o(`text-xs font-medium text-fg-secondary peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}var b=c(`folder-git-2`,[[`path`,{d:`M18 19a5 5 0 0 1-5-5v8`,key:`sz5oeg`}],[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]),x=c(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),S={navy:`text-fg`,gold:`text-fg-gold`,blue:`text-icon-blue`,green:`text-icon-green`,amber:`text-icon-amber`,red:`text-icon-red`,violet:`text-icon-violet`,cyan:`text-icon-cyan`,accent:`text-accent`};function C(e){return e&&S[e]||``}function w({value:e,onChange:t,disabled:n=!1,label:i=`Colour`}){return(0,p.jsx)(`div`,{role:`group`,"aria-label":i,className:`flex flex-wrap items-center gap-1`,children:[null,...r].map(r=>(0,p.jsx)(`button`,{type:`button`,title:r??`Default`,"aria-label":r??`Default colour`,"aria-pressed":(e??null)===r,disabled:n,onClick:()=>t(r),className:o(`flex size-7 cursor-pointer items-center justify-center rounded-md transition-colors hover:bg-border/50 focus-visible:bg-border/50 disabled:cursor-default disabled:opacity-50`,(e??null)===r&&`bg-border/50`),children:(0,p.jsx)(`span`,{className:o(`size-3.5 rounded-full`,r?o(`bg-current`,C(r)):`bg-fg-muted`)})},r??`default`))})}function T({id:e,value:t,onValueChange:n,onChoose:r,hints:i,placeholder:a,className:s,hintsClassName:c,autoFocus:l}){let[u,d]=(0,f.useState)(!1),[h,g]=(0,f.useState)(0),_=e=>{n(e.value),r?.(e),d(!1)};return(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsx)(m,{id:e,value:t,onChange:e=>{n(e.target.value),d(!0),g(0)},onFocus:()=>d(!0),onBlur:()=>d(!1),onKeyDown:e=>{if(!(!u||i.length===0))if(e.key===`ArrowDown`)e.preventDefault(),g(e=>(e+1)%i.length);else if(e.key===`ArrowUp`)e.preventDefault(),g(e=>(e-1+i.length)%i.length);else if(e.key===`Enter`||e.key===`Tab`){let t=i[h]??i[0];t&&(e.preventDefault(),_(t))}else e.key===`Escape`&&(e.stopPropagation(),d(!1))},placeholder:a,className:s,autoComplete:`off`,spellCheck:!1,autoFocus:l}),u&&i.length>0&&(0,p.jsx)(`ul`,{className:o(`absolute top-full z-10 mt-1 max-h-56 overflow-y-auto rounded-md bg-elevated p-1 shadow-xl`,c??`w-full`),children:i.map((e,t)=>(0,p.jsx)(`li`,{children:(0,p.jsxs)(`button`,{type:`button`,onMouseDown:t=>{t.preventDefault(),_(e)},onMouseEnter:()=>g(t),className:o(`relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-fg outline-none transition-colors`,`data-[selected=true]:bg-action data-[selected=true]:text-action-ink data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50`,`w-full text-xs`),"data-selected":t===h,children:[(0,p.jsx)(`span`,{className:`truncate`,children:e.label??e.value}),e.badge&&(0,p.jsx)(`span`,{className:`ml-auto shrink-0 text-2xs opacity-70`,children:e.badge})]})},e.value))})]})}var E=(0,f.lazy)(()=>i(()=>import(`./Terminal-CqjwbNAI.js`).then(e=>({default:e.Terminal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]))),D=null;async function O(){D=(await i(()=>import(`./Terminal-CqjwbNAI.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]))).Terminal}function k(e){return D?(0,p.jsx)(D,{...e}):(0,p.jsx)(f.Suspense,{fallback:(0,p.jsx)(`div`,{className:`size-full bg-ground`}),children:(0,p.jsx)(E,{...e})})}export{C as a,y as c,l as d,d as f,w as i,m as l,O as n,x as o,u as p,T as r,b as s,k as t,h as u};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{c as n,o as r,t as i}from"./buffer-store-De6oYRzb.js";var a=e(t(),1);function o({buffers:e}){let t=(0,a.useRef)(new Set);return(0,a.useEffect)(()=>{let a=new Set(e.map(e=>i(e.session,e.path,e.root))),o=t.current;for(let e of a)o.has(e)||(n(e),o.add(e));for(let e of[...o])a.has(e)||(r(e),o.delete(e))},[e]),(0,a.useEffect)(()=>()=>{for(let e of t.current)r(e);t.current.clear()},[]),null}export{o as ModelRefcount};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{c as n,o as r,t as i}from"./buffer-store-BAQjeFXg.js";var a=e(t(),1);function o({buffers:e}){let t=(0,a.useRef)(new Set);return(0,a.useEffect)(()=>{let a=new Set(e.map(e=>i(e.session,e.path,e.root))),o=t.current;for(let e of a)o.has(e)||(n(e),o.add(e));for(let e of[...o])a.has(e)||(r(e),o.delete(e))},[e]),(0,a.useEffect)(()=>()=>{for(let e of t.current)r(e);t.current.clear()},[]),null}export{o as ModelRefcount};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{a as r,c as i,d as a,f as o,i as s,l as c,r as ee,s as l}from"./LazyTerminal-CAvxgexS.js";import{G as u,K as d,Y as te,c as ne,d as re,it as ie,tt as f,wt as ae}from"./protocol-support-CJIxbQCB.js";import{r as p,u as m}from"./project-abbrev-Bz8ZEwrb.js";import{t as h}from"./button-Chvl9hcE.js";import{t as g}from"./createLucideIcon-DyMAgLa3.js";import{a as _,i as v,n as y,o as b,r as x,t as S}from"./dialog-Bnex_wlx.js";import{t as oe}from"./use-debounced-value-C86N-mOK.js";var C=g(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),w=e(t(),1),T=n();function E(e){let t=e.trim().replace(/\/+$/,``);return t===``?`/`:t}function D(e){return e.startsWith(`/`)||e.startsWith(`~`)}function O(e){let t=e.replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n<=0?`/`:t.slice(0,n)}function se({dir:e,onNavigate:t,onChoose:n}){let r=f(e.endsWith(`/`)?e:`${e}/`);return(0,T.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,T.jsxs)(`button`,{type:`button`,onClick:()=>t(O(e)),disabled:e===`/`,title:`Parent directory`,className:`shrink-0 rounded-sm p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg disabled:pointer-events-none disabled:opacity-40`,children:[(0,T.jsx)(p,{className:`size-3.5`}),(0,T.jsx)(`span`,{className:`sr-only`,children:`Parent directory`})]}),(0,T.jsx)(`button`,{type:`button`,onClick:()=>n(e),className:`ml-auto shrink-0 text-2xs text-fg-muted transition-colors hover:text-fg`,children:`choose this folder`})]}),(0,T.jsxs)(`div`,{className:`max-h-48 overflow-y-auto`,children:[(r.data?.entries??[]).map(e=>(0,T.jsxs)(`div`,{className:`flex items-center rounded-md transition-colors hover:bg-elevated`,children:[(0,T.jsxs)(`button`,{type:`button`,onClick:()=>t(e.path),className:`flex min-w-0 flex-1 items-center gap-2 px-2 py-1 text-left`,children:[e.is_git?(0,T.jsx)(l,{className:`size-3.5 shrink-0 text-success`}):(0,T.jsx)(C,{className:`size-3.5 shrink-0 text-fg-gold`}),(0,T.jsx)(`span`,{className:`truncate text-xs text-fg`,children:e.name})]}),e.is_git&&(0,T.jsx)(`button`,{type:`button`,onClick:()=>n(e.path),className:`shrink-0 px-2 py-1 text-2xs text-fg-muted transition-colors hover:text-fg`,children:`choose`})]},e.path)),r.data!==void 0&&r.data.entries.length===0&&(0,T.jsx)(`p`,{className:`px-2 py-1 text-xs text-fg-muted`,children:`No subdirectories.`})]})]})}function k({profileId:e,open:t,onOpenChange:n}){let l=ae(),p=te().data?.protocol,g=ne(p),C=re(p),O=d(),k=u(),A=m(),j=ie(),[M,N]=(0,w.useState)(``),[P,F]=(0,w.useState)(``),[I,L]=(0,w.useState)(!1),[R,z]=(0,w.useState)(``),[B,V]=(0,w.useState)(null),[H,U]=(0,w.useState)(!1),[W,G]=(0,w.useState)(null),[K,q]=(0,w.useState)(null),J=j.data?.home,ce=()=>{let e=M.trim(),t=D(e)&&J!==void 0?E(e.replace(/^~(?=\/|$)/,J)):D(e)&&e.startsWith(`/`)?E(e):J??`/`;X(t)},Y=e=>{F(e),H||z(a(e))},X=e=>{q(e),N(e)},le=e=>{N(e),q(null),Y(e.split(`/`).filter(Boolean).pop()??``),L(!0)},Z=f(oe(M,150)),ue=(0,w.useMemo)(()=>{if(!D(M))return(l.data??[]).map(e=>({value:e.path,badge:`registered`,is_git:!0}));let e=new Set((l.data??[]).map(e=>e.path));return(Z.data?.entries??[]).map(t=>({value:t.path,label:t.name,badge:e.has(t.path)?`registered`:t.is_git?`git`:void 0,is_git:t.is_git}))},[M,l.data,Z.data]),Q=async()=>{G(null);try{let t=E(M),r=l.data?.find(e=>e.path===t)?.id??(await O.mutateAsync({path:t,...g?{default_base_branch:``}:{}})).id,i=await k.mutateAsync({profile_id:e,repo_id:r,name:P.trim(),...C?{colour:B}:{},...o(R)?{abbrev:o(R)}:{}});n(!1),A(`/project/${i.id}`)}catch(e){G(e instanceof Error?e.message:String(e))}},$=P.trim()!==``&&D(M.trim());return(0,T.jsx)(S,{open:t,onOpenChange:n,children:(0,T.jsxs)(y,{children:[(0,T.jsxs)(_,{children:[(0,T.jsx)(b,{children:`New project`}),(0,T.jsx)(x,{children:`Point at a git repository on the daemon host — known repositories are reused.`})]}),(0,T.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),$&&Q()},children:[(0,T.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,T.jsx)(i,{htmlFor:`repo-path`,children:`Repository path`}),(0,T.jsx)(`button`,{type:`button`,onClick:()=>K===null?ce():q(null),className:`text-2xs text-fg-muted transition-colors hover:text-fg`,children:K===null?`browse…`:`hide browser`})]}),(0,T.jsx)(ee,{id:`repo-path`,placeholder:`~/src/my-repo`,value:M,onValueChange:N,onChoose:e=>{!I&&e.is_git&&Y(e.value.split(`/`).filter(Boolean).pop()??``)},hints:ue}),K!==null&&(0,T.jsx)(se,{dir:K,onNavigate:X,onChoose:le})]}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,T.jsx)(i,{htmlFor:`project-name`,children:`Project name`}),(0,T.jsx)(c,{id:`project-name`,placeholder:`e.g. checkout-rework`,value:P,className:r(B),onChange:e=>{Y(e.target.value),L(!0)}})]}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,T.jsx)(i,{htmlFor:`project-abbrev`,children:`Abbreviation`}),(0,T.jsx)(c,{id:`project-abbrev`,placeholder:P.trim()?a(P):`ABBRV`,maxLength:5,value:R,onChange:e=>{z(o(e.target.value)),U(!0)},className:`w-24 uppercase`}),(0,T.jsxs)(`p`,{className:`text-2xs text-fg-muted`,children:[`Up to `,5,` characters — the project's label on the collapsed sidebar rail.`]})]}),C&&(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,T.jsx)(`span`,{className:`text-xs text-fg-secondary`,children:`Colour`}),(0,T.jsx)(s,{value:B,onChange:V,label:`Project colour`})]}),W&&(0,T.jsx)(`p`,{className:`text-xs text-danger`,children:W}),(0,T.jsxs)(v,{children:[(0,T.jsx)(h,{type:`button`,variant:`ghost`,onClick:()=>n(!1),children:`Cancel`}),(0,T.jsx)(h,{type:`submit`,disabled:!$||O.isPending||k.isPending,children:`Create project`})]})]})]})})}export{k as t};