@av-pi-studio/web-client 0.0.39 → 0.0.40
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.
- package/dist/.tsbuildinfo +1 -1
- package/dist/web/assets/{BinaryFallbackViewer-Cpu5Tg1C.js → BinaryFallbackViewer-CJ1-OtwU.js} +2 -2
- package/dist/web/assets/{BinaryFallbackViewer-Cpu5Tg1C.js.map → BinaryFallbackViewer-CJ1-OtwU.js.map} +1 -1
- package/dist/web/assets/{ChatPanel-BqI2xnxv.js → ChatPanel-BORrt6x0.js} +2 -2
- package/dist/web/assets/{ChatPanel-BqI2xnxv.js.map → ChatPanel-BORrt6x0.js.map} +1 -1
- package/dist/web/assets/{CodeView-B18owi8N.js → CodeView-Cu2yyMOv.js} +2 -2
- package/dist/web/assets/{CodeView-B18owi8N.js.map → CodeView-Cu2yyMOv.js.map} +1 -1
- package/dist/web/assets/{FilePanel-BBfL4iba.js → FilePanel-CMzv0HtU.js} +3 -3
- package/dist/web/assets/{FilePanel-BBfL4iba.js.map → FilePanel-CMzv0HtU.js.map} +1 -1
- package/dist/web/assets/{ImageViewer-KAEt1ZI8.js → ImageViewer-Cz4spWgk.js} +2 -2
- package/dist/web/assets/{ImageViewer-KAEt1ZI8.js.map → ImageViewer-Cz4spWgk.js.map} +1 -1
- package/dist/web/assets/{MarkdownFileViewer-Cb8Cm1VS.js → MarkdownFileViewer-BJx06RrQ.js} +2 -2
- package/dist/web/assets/{MarkdownFileViewer-Cb8Cm1VS.js.map → MarkdownFileViewer-BJx06RrQ.js.map} +1 -1
- package/dist/web/assets/{TerminalPanel-DyLLAPYP.js → TerminalPanel-Djo6xzYk.js} +2 -2
- package/dist/web/assets/{TerminalPanel-DyLLAPYP.js.map → TerminalPanel-Djo6xzYk.js.map} +1 -1
- package/dist/web/assets/{TextViewer-C4U4WLH6.js → TextViewer-DFEviuBM.js} +2 -2
- package/dist/web/assets/{TextViewer-C4U4WLH6.js.map → TextViewer-DFEviuBM.js.map} +1 -1
- package/dist/web/assets/{VideoViewer-tThxC8b-.js → VideoViewer-Db4EXUHf.js} +2 -2
- package/dist/web/assets/{VideoViewer-tThxC8b-.js.map → VideoViewer-Db4EXUHf.js.map} +1 -1
- package/dist/web/assets/index-Blzywf8O.js +3 -0
- package/dist/web/assets/index-Blzywf8O.js.map +1 -0
- package/dist/web/assets/index-C_fVQpEW.css +1 -0
- package/dist/web/assets/{use-file-download-BPiZ1x6n.js → use-file-download-BBVfhuPL.js} +2 -2
- package/dist/web/assets/{use-file-download-BPiZ1x6n.js.map → use-file-download-BBVfhuPL.js.map} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +3 -3
- package/dist/web/assets/index-BFWpAuBZ.js +0 -3
- package/dist/web/assets/index-BFWpAuBZ.js.map +0 -1
- package/dist/web/assets/index-BMbFIm_9.css +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
html,body{margin:0;padding:0}body{min-height:100vh;overflow:hidden;background:var(--pi-color-background, #0a0a0a);color:var(--pi-color-foreground, #fafafa);font-family:var(--pi-font-ui, system-ui, sans-serif)}#root{display:flex;flex-direction:column;min-height:100vh}*,*:before,*:after{box-sizing:border-box}::-webkit-scrollbar{width:6px;height:6px}::-webkit-scrollbar-track{background:transparent}::-webkit-scrollbar-thumb{background:var(--pi-color-border, #353b46);border-radius:3px}._btn_1chbg_4{display:inline-flex;align-items:center;justify-content:center;gap:8px;border-radius:var(--pi-radius-lg, 8px);border:1px solid transparent;font-family:var(--pi-font-ui, system-ui, sans-serif);font-weight:500;cursor:pointer;-webkit-user-select:none;user-select:none;white-space:nowrap;text-decoration:none;outline:none;transition:opacity .12s ease,background-color .12s ease,border-color .12s ease;box-sizing:border-box}._btn_1chbg_4:focus-visible{outline:2px solid var(--pi-color-accent, #2e5cb8);outline-offset:2px}._btn_1chbg_4:disabled,._btn_1chbg_4[aria-disabled=true]{cursor:not-allowed;pointer-events:none}._default_1chbg_35{background-color:var(--pi-color-accent, #2e5cb8);color:var(--pi-color-accentForeground, #ffffff);border-color:var(--pi-color-accent, #2e5cb8)}._default_1chbg_35:hover:not(:disabled){filter:brightness(1.08)}._secondary_1chbg_44{background-color:var(--pi-color-surface3, #3f3f46);color:var(--pi-color-foreground, #fafafa);border-color:var(--pi-color-border, #3f3f46)}._secondary_1chbg_44:hover:not(:disabled){background-color:var(--pi-color-surface2, #27272a)}._outline_1chbg_53{background-color:transparent;color:var(--pi-color-accentBright, #a2b4d7);border-color:var(--pi-color-accent, #2e5cb8)}._outline_1chbg_53:hover:not(:disabled){background-color:var(--pi-color-surface1, #18181b)}._ghost_1chbg_62{background-color:transparent;color:var(--pi-color-foregroundMuted, #a1a1aa);border-color:transparent}._ghost_1chbg_62:hover:not(:disabled){color:var(--pi-color-foreground, #fafafa);background-color:var(--pi-color-surface1, #18181b)}._destructive_1chbg_72{background-color:var(--pi-color-destructive, #991b1b);color:var(--pi-color-destructiveForeground, #fef2f2);border-color:var(--pi-color-destructive, #991b1b)}._destructive_1chbg_72:hover:not(:disabled){filter:brightness(1.1)}._iconOnly_1chbg_82{padding-left:0!important;padding-right:0!important;aspect-ratio:1}._loadingSpinner_1chbg_89{animation:_piSpin_1chbg_1 .75s linear infinite;flex-shrink:0}@keyframes _piSpin_1chbg_1{0%{transform:rotate(0)}to{transform:rotate(360deg)}}._input_a7qyq_3{width:100%;padding:8px 12px;border-radius:var(--pi-radius-md, 6px);border:1px solid var(--pi-color-border, #3f3f46);background-color:var(--pi-color-surface2, #27272a);color:var(--pi-color-foreground, #fafafa);font-size:var(--pi-font-size-base, 16px);font-family:var(--pi-font-ui, system-ui, sans-serif);outline:none;transition:border-color .12s ease;box-sizing:border-box}._input_a7qyq_3::placeholder{color:var(--pi-color-foregroundMuted, #a1a1aa)}._input_a7qyq_3:focus{border-color:var(--pi-color-accent, #2e5cb8);outline:2px solid var(--pi-color-accent, #2e5cb8);outline-offset:-1px}._input_a7qyq_3:disabled{opacity:.5;cursor:not-allowed}._textarea_a7qyq_32{resize:vertical;min-height:80px}._wrap_emmus_1{display:inline-flex;align-items:center;gap:6px;font-size:12px;color:var(--pi-color-foregroundMuted, #9aa0a6)}._dot_emmus_8{width:8px;height:8px;border-radius:50%;background:var(--pi-color-foregroundMuted, #9aa0a6);flex-shrink:0}._dot_emmus_8._open_emmus_15{background:var(--pi-color-statusSuccess, #3ecf8e)}._dot_emmus_8._connecting_emmus_18{background:var(--pi-color-statusWarning, #e0a030)}._dot_emmus_8._closed_emmus_21,._dot_emmus_8._idle_emmus_22,._dot_emmus_8._closing_emmus_23{background:var(--pi-color-statusDanger, #e5484d)}._toolbar_i9hmh_1{display:flex;align-items:center;gap:10px;padding:6px 10px;border-bottom:1px solid var(--pi-color-border, #353b46);background:var(--pi-color-surface, #16181a);flex-shrink:0}._brand_i9hmh_10{font-weight:600;font-size:13px;letter-spacing:.02em;white-space:nowrap}._version_i9hmh_16{font-size:11px;color:var(--pi-color-foregroundMuted, #7a8394);white-space:nowrap;margin-left:-4px}._sep_i9hmh_22{width:1px;height:18px;background:var(--pi-color-border, #353b46);flex-shrink:0}._host_i9hmh_28{width:190px}._password_i9hmh_31{width:100px}._sidebarToggles_i9hmh_34{display:flex;align-items:center;gap:4px;margin-left:auto}._dot_gfh8u_3{display:inline-block;width:8px;height:8px;border-radius:9999px;flex-shrink:0}._spinner_gfh8u_16{display:inline-block;width:12px;height:12px;border-radius:9999px;border:2px solid var(--pi-color-border, #353b46);flex-shrink:0;animation:_statusSpin_gfh8u_1 .7s linear infinite}@keyframes _statusSpin_gfh8u_1{to{transform:rotate(360deg)}}._wrap_14der_1{display:flex;flex-direction:column;min-height:0;height:100%}._header_14der_7{display:flex;align-items:center;justify-content:space-between;padding:8px 10px;border-bottom:1px solid var(--pi-color-border, #353b46);flex-shrink:0}._header_14der_7 h3{margin:0;font-size:12px;font-weight:600;color:var(--pi-color-foregroundMuted, #9aa0a6);text-transform:uppercase;letter-spacing:.04em}._list_14der_23{flex:1 1 auto;overflow-y:auto;min-height:0}._item_14der_28{position:relative;padding:8px 10px;cursor:pointer;border-bottom:1px solid transparent}._item_14der_28:hover{background:var(--pi-color-surfaceHover, #1e2124)}._item_14der_28._active_14der_37{background:var(--pi-color-surfaceSunken, #111);box-shadow:inset 2px 0 0 var(--pi-color-accent, #2e5cb8)}._title_14der_41{display:flex;align-items:center;gap:6px;font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._meta_14der_50{margin-top:2px;font-size:11px;color:var(--pi-color-foregroundMuted, #9aa0a6);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._menuBtn_14der_58{position:absolute;top:6px;right:6px;opacity:0;padding:2px 4px;background:none;border:none;border-radius:4px;cursor:pointer;color:var(--pi-color-foregroundMuted, #9aa0a6)}._item_14der_28:hover ._menuBtn_14der_58{opacity:1}._menuBtn_14der_58:hover{background:var(--pi-color-surfaceHover, #1e2124)}._workspaceGroup_14der_76{border-bottom:1px solid var(--pi-color-border, #353b46)}._workspaceHeader_14der_79{display:flex;align-items:center;gap:6px;padding:7px 10px;cursor:pointer;font-size:12px;font-weight:600;color:var(--pi-color-foreground, #e6e6e6)}._workspaceHeader_14der_79:hover{background:var(--pi-color-surfaceHover, #1e2124)}._workspaceChevron_14der_92{display:flex;align-items:center;justify-content:center;padding:0;background:none;border:none;cursor:pointer;color:var(--pi-color-foregroundMuted, #9aa0a6);flex-shrink:0}._workspaceIcon_14der_103{color:var(--pi-color-foregroundMuted, #9aa0a6);flex-shrink:0}._workspaceLabel_14der_107{flex:1 1 auto;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._workspaceCount_14der_113{font-size:11px;font-weight:400;color:var(--pi-color-foregroundMuted, #9aa0a6)}._newSessionBtn_14der_118{flex-shrink:0;opacity:0;color:var(--pi-color-foregroundMuted, #9aa0a6)}._workspaceHeader_14der_79:hover ._newSessionBtn_14der_118{opacity:1}._newSessionBtn_14der_118:hover{background:var(--pi-color-surfaceHover, #1e2124);color:var(--pi-color-foreground, #e6e6e6)}._workspaceSessions_14der_130{padding-left:12px}._emptyState_14der_133{padding:12px 10px;font-size:12px;color:var(--pi-color-foregroundMuted, #9aa0a6)}._trigger_16o4s_1{position:fixed;width:1px;height:1px;pointer-events:none}._content_16o4s_7{min-width:160px;padding:4px;border-radius:var(--pi-borderRadius-md, 6px);background:var(--pi-color-surface, #16181a);border:1px solid var(--pi-color-border, #353b46);box-shadow:0 8px 24px #0006;z-index:1000}._item_16o4s_16{display:flex;align-items:center;padding:6px 10px;border-radius:4px;font-size:13px;cursor:pointer;outline:none}._item_16o4s_16:hover,._item_16o4s_16[data-highlighted]{background:var(--pi-color-surfaceHover, #1e2124)}._item_16o4s_16[data-disabled]{opacity:.4;cursor:default}._danger_16o4s_33{color:var(--pi-color-statusDanger, #e5484d)}._sep_16o4s_36{height:1px;margin:4px 0;background:var(--pi-color-border, #353b46)}._strip_8jveh_1{display:flex;align-items:center;gap:2px;padding:4px 6px 0;overflow-x:auto;flex-shrink:0;border-bottom:1px solid var(--pi-color-border, #353b46)}._tab_8jveh_10{display:flex;align-items:center;gap:6px;padding:6px 8px;border-radius:var(--pi-borderRadius-md, 6px) var(--pi-borderRadius-md, 6px) 0 0;font-size:12px;cursor:pointer;color:var(--pi-color-foregroundMuted, #9aa0a6);white-space:nowrap;flex-shrink:0;-webkit-user-select:none;user-select:none}._tab_8jveh_10:hover{background:var(--pi-color-surfaceHover, #1e2124)}._active_8jveh_26{background:var(--pi-color-surfaceSunken, #111);color:var(--pi-color-foreground, #fafafa)}._icon_8jveh_30{display:flex;align-items:center;flex-shrink:0}._label_8jveh_35{max-width:160px;overflow:hidden;text-overflow:ellipsis}._close_8jveh_40{display:flex;align-items:center;border-radius:3px;padding:1px;flex-shrink:0}._close_8jveh_40:hover{background:var(--pi-color-surfaceHover, #1e2124)}._newTab_8jveh_50{position:relative;display:flex;align-items:center;justify-content:center;flex-shrink:0;margin:0 4px;width:20px;height:20px;border-radius:var(--pi-borderRadius-sm, 4px);color:var(--pi-color-foregroundMuted, #9aa0a6);background:transparent;border:none;cursor:pointer}._newTab_8jveh_50:hover:not(:disabled){background:var(--pi-color-surfaceHover, #1e2124);color:var(--pi-color-foreground, #fafafa)}._newTab_8jveh_50:disabled{opacity:.4;cursor:default}._content_8jveh_73{min-width:160px;padding:4px;border-radius:var(--pi-borderRadius-md, 6px);background:var(--pi-color-surface, #16181a);border:1px solid var(--pi-color-border, #353b46);box-shadow:0 8px 24px #0006;z-index:1000}._item_8jveh_82{display:flex;align-items:center;gap:8px;padding:6px 10px;border-radius:4px;font-size:13px;cursor:pointer;outline:none}._item_8jveh_82:hover,._item_8jveh_82[data-highlighted]{background:var(--pi-color-surfaceHover, #1e2124)}._itemIcon_8jveh_96{flex-shrink:0;color:var(--pi-color-foregroundMuted, #9aa0a6)}._spinner_1tgzp_3{display:inline-block;border-radius:9999px;border-style:solid;border-color:currentColor transparent transparent transparent;animation:_piSpinnerRotate_1tgzp_1 .7s linear infinite;flex-shrink:0}@keyframes _piSpinnerRotate_1tgzp_1{0%{transform:rotate(0)}to{transform:rotate(360deg)}}._area_z7u01_1{position:relative;flex:1 1 auto;min-height:0;overflow:hidden}._panel_z7u01_7{position:absolute;top:0;right:0;bottom:0;left:0;display:none;flex-direction:column;min-height:0}._active_z7u01_14{display:flex}._empty_z7u01_17{display:flex;align-items:center;justify-content:center;height:100%;color:var(--pi-color-foregroundMuted, #9aa0a6);font-size:13px}._emptyStack_z7u01_25{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;height:100%;padding:0 16px;text-align:center}._emptyTitle_z7u01_35{font-size:13px;color:var(--pi-color-foreground, #e6e6e6)}._emptyHint_z7u01_39{font-size:12px;color:var(--pi-color-foregroundMuted, #9aa0a6)}._container_1098n_1{position:relative;height:100%;display:flex;flex-direction:column}._header_1098n_7{display:flex;align-items:center;gap:6px;padding:6px 8px;border-bottom:1px solid var(--pi-color-border, #353b46)}._uploadButton_1098n_14{display:inline-flex;align-items:center;gap:5px;font-size:11px;padding:3px 8px;border-radius:4px;border:1px solid var(--pi-color-border, #353b46);background:var(--pi-color-surface, #1e2124);color:var(--pi-color-foreground, #e4e6eb);cursor:pointer}._uploadButton_1098n_14:hover:not(:disabled){background:var(--pi-color-surfaceHover, #2a2e33)}._uploadButton_1098n_14:disabled{opacity:.5;cursor:default}._hiddenInput_1098n_33{display:none}._status_1098n_36,._statusError_1098n_37{font-size:11px;padding:4px 8px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._status_1098n_36{color:var(--pi-color-foregroundMuted, #9aa0a6)}._statusError_1098n_37{color:var(--pi-color-danger, #e5534b)}._rowAction_1098n_50{margin-left:auto;display:none;align-items:center;padding:2px;border:none;background:transparent;color:var(--pi-color-foregroundMuted, #9aa0a6);cursor:pointer;border-radius:3px}._rowAction_1098n_50:hover{color:var(--pi-color-foreground, #e4e6eb);background:var(--pi-color-surface, #1e2124)}._item_1098n_65:hover ._rowAction_1098n_50{display:inline-flex}._dropOverlay_1098n_68{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;align-items:center;justify-content:center;font-size:13px;color:var(--pi-color-accentBright, #a2b4d7);background:color-mix(in srgb,var(--pi-color-surface, #1e2124) 80%,transparent);border:2px dashed var(--pi-color-accentBright, #a2b4d7);border-radius:6px;pointer-events:none;z-index:2}._list_1098n_83{padding:4px 0;flex:1;overflow-y:auto;position:relative}._item_1098n_65{height:24px;padding-right:8px;font-size:12px;border-radius:3px;cursor:pointer;display:flex;align-items:center;gap:6px}._item_1098n_65:hover{background:var(--pi-color-surfaceHover, #1e2124)}._chevronSlot_1098n_102{display:flex;align-items:center;justify-content:center;width:12px;flex-shrink:0;color:var(--pi-color-foregroundMuted, #9aa0a6)}._chevron_1098n_102{transition:transform .1s ease}._chevronOpen_1098n_113{transform:rotate(90deg)}._icon_1098n_116{display:flex;align-items:center;width:16px;flex-shrink:0;color:var(--pi-color-foregroundMuted, #9aa0a6)}._name_1098n_123{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}._dirName_1098n_128{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--pi-color-accentBright, #a2b4d7)}._statusRow_1098n_134{height:24px;display:flex;align-items:center;padding-right:8px;font-size:11px;color:var(--pi-color-foregroundMuted, #9aa0a6);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._statusRowError_1098n_145{color:var(--pi-color-danger, #e5534b)}._emptyState_1098n_148{color:var(--pi-color-foregroundMuted, #9aa0a6);font-size:12px;text-align:center;padding:20px}._draftInput_1098n_154{flex:1;min-width:0;height:18px;font:inherit;font-size:12px;padding:0 4px;color:var(--pi-color-foreground, #e4e6eb);background:var(--pi-color-surfaceSunken, #111);border:1px solid var(--pi-color-accent, #2e5cb8);border-radius:3px;outline:none}._trigger_g81d7_1{position:fixed;width:1px;height:1px;pointer-events:none}._content_g81d7_7{min-width:140px;padding:4px;border-radius:var(--pi-borderRadius-md, 6px);background:var(--pi-color-surface, #16181a);border:1px solid var(--pi-color-border, #353b46);box-shadow:0 8px 24px #0006;z-index:1000}._item_g81d7_16{display:flex;align-items:center;padding:6px 10px;border-radius:4px;font-size:13px;cursor:pointer;outline:none}._item_g81d7_16:hover,._item_g81d7_16[data-highlighted]{background:var(--pi-color-surfaceHover, #1e2124)}._danger_g81d7_29{color:var(--pi-color-statusDanger, #e5484d)}._sep_g81d7_32{height:1px;margin:4px 0;background:var(--pi-color-border, #353b46)}._list_1pgby_1{padding:4px 0}._summary_1pgby_4{padding:4px 8px;font-size:11px;color:var(--pi-color-foregroundMuted, #9aa0a6);border-bottom:1px solid var(--pi-color-border, #353b46);margin-bottom:4px}._item_1pgby_11{padding:4px 8px;font-size:12px;border-radius:3px;cursor:pointer;display:flex;align-items:center;gap:6px}._item_1pgby_11:hover{background:var(--pi-color-surfaceHover, #1e2124)}._badge_1pgby_23{font-size:10px;padding:0 4px;border-radius:3px;font-weight:600;flex-shrink:0}._added_1pgby_30{background:color-mix(in srgb,var(--pi-color-statusSuccess, #4ade80) 20%,transparent);color:var(--pi-color-statusSuccess, #4ade80)}._modified_1pgby_34{background:color-mix(in srgb,var(--pi-color-statusWarning, #facc15) 20%,transparent);color:var(--pi-color-statusWarning, #facc15)}._deleted_1pgby_38{background:color-mix(in srgb,var(--pi-color-statusDanger, #ff8a80) 20%,transparent);color:var(--pi-color-statusDanger, #ff8a80)}._name_1pgby_42{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}._emptyState_1pgby_47{color:var(--pi-color-foregroundMuted, #9aa0a6);font-size:12px;text-align:center;padding:20px}._wrap_r37ok_1{display:flex;flex-direction:column;height:100%;min-height:0}._tabBar_r37ok_7{display:flex;align-items:center;border-bottom:1px solid var(--pi-color-border, #353b46);flex-shrink:0}._tabBtn_r37ok_13{font:inherit;font-size:12px;padding:8px 12px;background:none;border:none;color:var(--pi-color-foregroundMuted, #9aa0a6);cursor:pointer;border-bottom:2px solid transparent}._tabBtn_r37ok_13:hover{color:var(--pi-color-foreground, #fafafa)}._active_r37ok_26{color:var(--pi-color-foreground, #fafafa);border-bottom-color:var(--pi-color-accent, #2e5cb8)}._refreshBtn_r37ok_30{margin-left:auto;margin-right:6px}._content_r37ok_34{flex:1;overflow-y:auto;padding:8px;min-height:0}._content_17y31_4{min-width:240px;padding:4px;border-radius:var(--pi-borderRadius-md, 6px);background:var(--pi-color-surface, #16181a);border:1px solid var(--pi-color-border, #353b46);box-shadow:0 8px 24px #0006;z-index:1000;display:flex;flex-direction:column;gap:4px}._search_17y31_17{width:100%;box-sizing:border-box;padding:6px 8px;border-radius:var(--pi-radius-md, 6px);border:1px solid var(--pi-color-border, #3f3f46);background:var(--pi-color-surface2, #27272a);color:var(--pi-color-foreground, #fafafa);font-size:12px;outline:none}._search_17y31_17::placeholder{color:var(--pi-color-foregroundMuted, #9aa0a6)}._search_17y31_17:focus{border-color:var(--pi-color-accent, #2e5cb8)}._list_17y31_35{max-height:320px;overflow-y:auto}._item_17y31_40{display:flex;align-items:center;gap:6px;padding:6px 8px;border-radius:4px;font-size:13px;cursor:pointer;outline:none}._item_17y31_40:hover,._item_17y31_40[data-highlighted]{background:var(--pi-color-surfaceHover, #1e2124)}._checkSlot_17y31_55{width:16px;flex-shrink:0;display:inline-flex;align-items:center;justify-content:center;color:var(--pi-color-foreground, #fafafa)}._label_17y31_64{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._modelId_17y31_70{color:var(--pi-color-foregroundMuted, #9aa0a6);margin-left:4px;font-size:12px;white-space:nowrap}._state_17y31_77{display:flex;align-items:center;justify-content:center;padding:12px;color:var(--pi-color-foregroundMuted, #9aa0a6);font-size:12px}._stateError_17y31_86{padding:8px;color:var(--pi-color-danger, #e5534b);font-size:12px}._statusBar_tm1j6_1{height:35px;width:100%;flex-shrink:0;display:flex;align-items:center;gap:2px;padding:0 12px;overflow-x:auto;border-top:1px solid var(--pi-color-border, #353b46);background:var(--pi-color-surface, #16181a);font-size:12px;color:var(--pi-color-foreground, #e4e6eb);white-space:nowrap}._segmentGroup_tm1j6_16{display:flex;align-items:center}._chevron_tm1j6_20{color:var(--pi-color-border, #353b46);margin:0 4px;flex-shrink:0}._segment_tm1j6_16{display:flex;align-items:center;gap:6px;padding:2px 8px;border-radius:4px;background:var(--pi-color-surfaceRaised, #1c1f22)}._icon_tm1j6_33{display:flex;align-items:center;color:var(--pi-color-foregroundMuted, #7a8394);flex-shrink:0}._modelSegment_tm1j6_39{display:flex;align-items:center;gap:5px;padding:2px 6px 2px 8px;border-radius:4px;border:1px solid var(--pi-color-border, #353b46);background:var(--pi-color-surfaceRaised, #1c1f22);color:inherit;font:inherit;cursor:pointer}._modelSegment_tm1j6_39:hover:not(:disabled){background:var(--pi-color-surfaceHover, #23262b);border-color:var(--pi-color-foregroundMuted, #7a8394)}._modelSegment_tm1j6_39[data-state=open]{background:var(--pi-color-surfaceHover, #23262b);border-color:var(--pi-color-accent, #2e5cb8)}._modelSegment_tm1j6_39:disabled{cursor:default;opacity:.6}._modelChevron_tm1j6_63{color:var(--pi-color-foregroundMuted, #7a8394);flex-shrink:0;transition:transform .15s ease;transform:rotate(180deg)}._modelSegment_tm1j6_39[data-state=open] ._modelChevron_tm1j6_63{transform:rotate(0)}._text_tm1j6_74{overflow:hidden;text-overflow:ellipsis;max-width:320px}._wrapper_131x2_3{display:inline-flex;align-items:center;gap:8px;cursor:pointer;font-family:var(--pi-font-ui, system-ui);font-size:var(--pi-font-size-sm, 14px);color:var(--pi-color-foreground, #fafafa)}._wrapper_131x2_3[data-disabled=true]{opacity:.5;pointer-events:none}._box_131x2_18{width:16px;height:16px;border-radius:var(--pi-radius-sm, 3px);border:1.5px solid var(--pi-color-border, #3f3f46);background-color:transparent;display:flex;align-items:center;justify-content:center;transition:background-color .1s,border-color .1s;flex-shrink:0}._box_131x2_18[data-checked=true]{background-color:var(--pi-color-accent, #2e5cb8);border-color:var(--pi-color-accent, #2e5cb8)}._checkmark_131x2_36{color:var(--pi-color-accentForeground, #ffffff)}._nativeInput_131x2_41{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}._select_vj45v_3{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:var(--pi-color-surface1, #18181b);border:1px solid var(--pi-color-border, #3f3f46);border-radius:var(--pi-radius-base, 4px);padding:8px 32px 8px 10px;font-family:var(--pi-font-ui, system-ui);font-size:var(--pi-font-size-sm, 14px);color:var(--pi-color-foreground, #fafafa);width:100%;outline:none;transition:border-color .1s;cursor:pointer;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23a1a1aa' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 10px center}._select_vj45v_3:focus{border-color:var(--pi-color-accent, #2e5cb8)}._select_vj45v_3:disabled{opacity:.5;cursor:not-allowed}._comboboxWrapper_vj45v_31{position:relative;width:100%}._comboboxInput_vj45v_36{width:100%;background-color:var(--pi-color-surface1, #18181b);border:1px solid var(--pi-color-border, #3f3f46);border-radius:var(--pi-radius-base, 4px);padding:8px 10px;font-family:var(--pi-font-ui, system-ui);font-size:var(--pi-font-size-sm, 14px);color:var(--pi-color-foreground, #fafafa);outline:none;box-sizing:border-box}._comboboxInput_vj45v_36:focus{border-color:var(--pi-color-accent, #2e5cb8)}._comboboxList_vj45v_53{position:absolute;top:100%;left:0;right:0;z-index:80;max-height:200px;overflow-y:auto;background-color:var(--pi-color-surface1, #18181b);border:1px solid var(--pi-color-border, #3f3f46);border-radius:var(--pi-radius-base, 4px);margin-top:4px;padding:4px;box-shadow:var(--pi-shadow-md, 0 4px 12px rgba(0,0,0,.4))}._comboboxOption_vj45v_69{padding:6px 8px;border-radius:var(--pi-radius-sm, 3px);font-size:var(--pi-font-size-sm, 14px);font-family:var(--pi-font-ui, system-ui);color:var(--pi-color-foreground, #fafafa);cursor:pointer;background:none;border:none;width:100%;text-align:left}._comboboxOption_vj45v_69:hover,._comboboxOptionHighlighted_vj45v_82{background-color:var(--pi-color-surface2, #27272a)}._overlay_1yaef_1{position:fixed;top:0;right:0;bottom:0;left:0;background:#0009;z-index:100}._contentWrapper_1yaef_7{position:fixed;top:0;right:0;bottom:0;left:0;z-index:101;display:flex;align-items:center;justify-content:center;pointer-events:none}._dialog_1yaef_16{pointer-events:auto;width:500px;max-width:90vw;max-height:70vh;background:var(--pi-color-surface, #16181a);border:1px solid var(--pi-color-border, #353b46);border-radius:var(--pi-radius-lg, 8px);display:flex;flex-direction:column;box-shadow:0 8px 32px #00000080}._header_1yaef_28{padding:12px 14px;border-bottom:1px solid var(--pi-color-border, #353b46);display:flex;align-items:center;gap:8px;flex-shrink:0}._title_1yaef_36{font-size:13px;margin:0;flex:1;color:var(--pi-color-foreground, #fafafa);font-weight:600}._closeBtn_1yaef_43{display:flex;align-items:center;background:none;border:none;color:var(--pi-color-foregroundMuted, #9aa0a6);cursor:pointer;padding:4px;border-radius:4px}._closeBtn_1yaef_43:hover{background:var(--pi-color-surfaceHover, #1e2124);color:var(--pi-color-foreground, #fafafa)}._body_1yaef_57{flex:1;display:flex;flex-direction:column;min-height:0}._footer_1yaef_63{padding:10px 14px;border-top:1px solid var(--pi-color-border, #353b46);display:flex;align-items:center;gap:8px;justify-content:flex-end;flex-shrink:0}._bare_1yaef_72{border:none;background:transparent;box-shadow:none;position:relative}._bareBody_1yaef_78{border-radius:var(--pi-radius-lg, 8px);overflow:hidden}._bareCloseBtn_1yaef_82{position:absolute;top:-12px;right:-12px;display:flex;align-items:center;justify-content:center;width:28px;height:28px;background:var(--pi-color-surface, #16181a);border:1px solid var(--pi-color-border, #353b46);border-radius:50%;color:var(--pi-color-foregroundMuted, #9aa0a6);cursor:pointer}._bareCloseBtn_1yaef_82:hover{background:var(--pi-color-surfaceHover, #1e2124);color:var(--pi-color-foreground, #fafafa)}._visuallyHidden_1yaef_101{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}._handle_1ocv1_1{position:absolute;top:0;bottom:0;width:5px;cursor:col-resize;z-index:5;background:transparent;transition:background .12s ease}._handle_1ocv1_1:hover,._handle_1ocv1_1:active{background:var(--pi-color-accent, #2e5cb8)}._pathRow_trimn_1{padding:8px 14px;display:flex;align-items:center;gap:6px;border-bottom:1px solid var(--pi-color-border, #353b46);flex-shrink:0}._pathInput_trimn_9{flex:1;font-size:12px}._createRow_trimn_13{padding:6px 14px;display:flex;align-items:center;gap:6px;border-bottom:1px solid var(--pi-color-border, #353b46);flex-shrink:0}._createInput_trimn_21{flex:1;font-size:12px}._createError_trimn_25{padding:4px 14px 6px;font-size:11px;color:var(--pi-color-danger, #e5534b)}._list_trimn_30{flex:1;overflow-y:auto;padding:4px 0;min-height:200px;max-height:400px}._item_trimn_37{padding:6px 14px;cursor:pointer;display:flex;align-items:center;gap:8px;font-size:12px;color:var(--pi-color-foreground, #fafafa)}._item_trimn_37:hover{background:var(--pi-color-surfaceHover, #1e2124)}._name_trimn_49{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}._emptyState_trimn_54{color:var(--pi-color-foregroundMuted, #9aa0a6);font-size:12px;text-align:center;padding:20px}._shell_1m1nv_1{display:flex;flex-direction:column;height:100vh;min-height:0}._main_1m1nv_7{display:flex;flex:1 1 auto;min-height:0;overflow:hidden}._sidebarLeft_1m1nv_13{position:relative;flex-shrink:0;border-right:1px solid var(--pi-color-border, #353b46);display:flex;flex-direction:column;min-width:0}._leftHandle_1m1nv_21{right:-3px}._center_1m1nv_24{flex:1 1 auto;display:flex;flex-direction:column;min-width:0;min-height:0}._sidebarRight_1m1nv_31{position:relative;flex-shrink:0;border-left:1px solid var(--pi-color-border, #353b46);display:flex;flex-direction:column;min-width:0}._rightHandle_1m1nv_39{left:-3px}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as a}from"./vendor-react-BoIQBqDW.js";import{u as f}from"./vendor-query-AtKBh_Yt.js";import{a as s,d as m,r as y}from"./index-
|
|
2
|
-
//# sourceMappingURL=use-file-download-
|
|
1
|
+
import{r as a}from"./vendor-react-BoIQBqDW.js";import{u as f}from"./vendor-query-AtKBh_Yt.js";import{a as s,d as m,r as y}from"./index-Blzywf8O.js";function p(o,u=!0){var i;const l=s(e=>e.client),n=s(e=>e.daemon),c=f({queryKey:y.fileDownload(o),queryFn:async()=>{if(!l||!n)throw new Error("not connected");const e=await m(n).download(o),t=new Blob([Uint8Array.from(e.bytes)],{type:e.mimeType||"application/octet-stream"});return{objectUrl:URL.createObjectURL(t),mimeType:e.mimeType,fileName:e.fileName}},enabled:!!l&&!!n&&!!o&&u,staleTime:1/0,gcTime:0}),r=a.useRef(null);return a.useEffect(()=>{var t;const e=((t=c.data)==null?void 0:t.objectUrl)??null;e&&r.current&&r.current!==e&&URL.revokeObjectURL(r.current),r.current=e},[(i=c.data)==null?void 0:i.objectUrl]),a.useEffect(()=>()=>{r.current&&URL.revokeObjectURL(r.current)},[]),c}export{p as u};
|
|
2
|
+
//# sourceMappingURL=use-file-download-BBVfhuPL.js.map
|
package/dist/web/assets/{use-file-download-BPiZ1x6n.js.map → use-file-download-BBVfhuPL.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-file-download-
|
|
1
|
+
{"version":3,"file":"use-file-download-BBVfhuPL.js","sources":["../../../src/hooks/use-file-download.ts"],"sourcesContent":["/**\n * `use-file-download` — TanStack Query wrapper over the binary file-transfer download path\n * (`file_download_token_request` → `file_download_request` → chunked `Begin`/`Chunk`/`End`\n * binary frames), for viewers that need raw bytes rather than the UTF-8 preview\n * `file_read_request` returns (images, video — POC_TO_APP_PLAN_UI.md §4.5 follow-up: modular\n * file preview). Resolves to an object URL, revoked once superseded by a new one or once this\n * consumer unmounts.\n */\n\nimport { useEffect, useRef } from \"react\";\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useConnectionStore } from \"@pi-studio-ui/lib/connection/connection-store.js\";\nimport { rpcKeys } from \"@pi-studio-ui/lib/connection/rpc-keys.js\";\nimport { transferFor } from \"./file-transfer-instance.js\";\n\nexport interface FileDownload {\n objectUrl: string;\n mimeType?: string;\n fileName?: string;\n}\n\nexport function useFileDownload(path: string, enabled = true) {\n const client = useConnectionStore((s) => s.client);\n const daemon = useConnectionStore((s) => s.daemon);\n\n const query = useQuery({\n queryKey: rpcKeys.fileDownload(path),\n queryFn: async (): Promise<FileDownload> => {\n if (!client || !daemon) throw new Error(\"not connected\");\n const file = await transferFor(daemon).download(path);\n // `Blob`'s DOM typings require an `ArrayBuffer`-backed view; the assembled `Uint8Array`'s\n // `ArrayBufferLike` backing (a decode-time implementation detail) doesn't satisfy that on\n // its own, so copy into a plain `ArrayBuffer`-backed `Uint8Array` first.\n const blob = new Blob([Uint8Array.from(file.bytes)], {\n type: file.mimeType || \"application/octet-stream\",\n });\n return { objectUrl: URL.createObjectURL(blob), mimeType: file.mimeType, fileName: file.fileName };\n },\n enabled: Boolean(client) && Boolean(daemon) && Boolean(path) && enabled,\n // Object URLs are process-local, non-serializable browser resources — never persist them or\n // silently refetch behind this hook's back (that would leak the previous blob's URL).\n staleTime: Infinity,\n gcTime: 0,\n });\n\n // Revoke the previous object URL once a new one supersedes it, and the current one on unmount\n // — TanStack Query's cache has no notion that this value owns a browser resource to release.\n const urlRef = useRef<string | null>(null);\n useEffect(() => {\n const nextUrl = query.data?.objectUrl ?? null;\n if (nextUrl && urlRef.current && urlRef.current !== nextUrl) {\n URL.revokeObjectURL(urlRef.current);\n }\n urlRef.current = nextUrl;\n }, [query.data?.objectUrl]);\n\n useEffect(() => {\n return () => {\n if (urlRef.current) URL.revokeObjectURL(urlRef.current);\n };\n }, []);\n\n return query;\n}\n"],"names":["useFileDownload","path","enabled","client","useConnectionStore","s","daemon","query","useQuery","rpcKeys","file","transferFor","blob","urlRef","useRef","useEffect","nextUrl","_a"],"mappings":"oJAqBO,SAASA,EAAgBC,EAAcC,EAAU,GAAM,OAC5D,MAAMC,EAASC,EAAoBC,GAAMA,EAAE,MAAM,EAC3CC,EAASF,EAAoBC,GAAMA,EAAE,MAAM,EAE3CE,EAAQC,EAAS,CACrB,SAAUC,EAAQ,aAAaR,CAAI,EACnC,QAAS,SAAmC,CAC1C,GAAI,CAACE,GAAU,CAACG,EAAQ,MAAM,IAAI,MAAM,eAAe,EACvD,MAAMI,EAAO,MAAMC,EAAYL,CAAM,EAAE,SAASL,CAAI,EAI9CW,EAAO,IAAI,KAAK,CAAC,WAAW,KAAKF,EAAK,KAAK,CAAC,EAAG,CACnD,KAAMA,EAAK,UAAY,0BAAA,CACxB,EACD,MAAO,CAAE,UAAW,IAAI,gBAAgBE,CAAI,EAAG,SAAUF,EAAK,SAAU,SAAUA,EAAK,QAAA,CACzF,EACA,QAAS,EAAQP,GAAW,EAAQG,GAAW,EAAQL,GAASC,EAGhE,UAAW,IACX,OAAQ,CAAA,CACT,EAIKW,EAASC,EAAAA,OAAsB,IAAI,EACzCC,OAAAA,EAAAA,UAAU,IAAM,OACd,MAAMC,IAAUC,EAAAV,EAAM,OAAN,YAAAU,EAAY,YAAa,KACrCD,GAAWH,EAAO,SAAWA,EAAO,UAAYG,GAClD,IAAI,gBAAgBH,EAAO,OAAO,EAEpCA,EAAO,QAAUG,CACnB,EAAG,EAACC,EAAAV,EAAM,OAAN,YAAAU,EAAY,SAAS,CAAC,EAE1BF,EAAAA,UAAU,IACD,IAAM,CACPF,EAAO,SAAS,IAAI,gBAAgBA,EAAO,OAAO,CACxD,EACC,CAAA,CAAE,EAEEN,CACT"}
|
package/dist/web/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
6
|
<title>Pi-Studio</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-Blzywf8O.js"></script>
|
|
8
8
|
<link rel="modulepreload" crossorigin href="/assets/vendor-react-BoIQBqDW.js">
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/vendor-query-AtKBh_Yt.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/vendor-markdown-B8HSIhaA.js">
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
<link rel="modulepreload" crossorigin href="/assets/vendor-icons-CX25WOn8.js">
|
|
14
14
|
<link rel="modulepreload" crossorigin href="/assets/vendor-overlays-UwLNGk04.js">
|
|
15
15
|
<link rel="modulepreload" crossorigin href="/assets/vendor-dnd-D9kA7FgH.js">
|
|
16
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
16
|
+
<link rel="stylesheet" crossorigin href="/assets/index-C_fVQpEW.css">
|
|
17
17
|
</head>
|
|
18
18
|
<body>
|
|
19
19
|
<div id="root"></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@av-pi-studio/web-client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.40",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"clean": "rm -rf dist *.tsbuildinfo"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@av-pi-studio/client": "^0.0.
|
|
18
|
-
"@av-pi-studio/protocol": "^0.0.
|
|
17
|
+
"@av-pi-studio/client": "^0.0.40",
|
|
18
|
+
"@av-pi-studio/protocol": "^0.0.40",
|
|
19
19
|
"@codemirror/language": "^6.12.4",
|
|
20
20
|
"@codemirror/language-data": "^6.5.2",
|
|
21
21
|
"@codemirror/state": "^6.7.1",
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ChatPanel-BqI2xnxv.js","assets/vendor-react-BoIQBqDW.js","assets/vendor-query-AtKBh_Yt.js","assets/vendor-icons-CX25WOn8.js","assets/markdown-D9FuaV1m.js","assets/vendor-highlight-DCzuSv8g.js","assets/vendor-markdown-B8HSIhaA.js","assets/vendor--os7hw7d.js","assets/markdown-BQwXm0MF.css","assets/DiffView-DlVCPvLc.js","assets/DiffView-CRbeRztO.css","assets/vendor-overlays-UwLNGk04.js","assets/vendor-dnd-D9kA7FgH.js","assets/ChatPanel-CTnpkb2U.css","assets/FilePanel-BBfL4iba.js","assets/FilePanel-DIInFr3h.css","assets/TerminalPanel-DyLLAPYP.js","assets/vendor-terminal-BhzX2_ts.js","assets/vendor-terminal-DYP7pi_n.css","assets/TerminalPanel-BQj62G6N.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
var Tn=Object.defineProperty;var Nn=(t,e,n)=>e in t?Tn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var I=(t,e,n)=>Nn(t,typeof e!="symbol"?e+"":e,n);import{r as v,j as i,d as En}from"./vendor-react-BoIQBqDW.js";import{Q as Rn,a as qn,u as Ot,b as Mn,c as Re,d as Bn}from"./vendor-query-AtKBh_Yt.js";import{A as l,B as u,C as A,D as Pt,E as q,F as qe,G as ne,H as B,I as w,J as D,K as O,L as Ue,M as _e,N as pe}from"./vendor--os7hw7d.js";import{L as $n,P as An,a as Dn,b as Fn,c as On,E as zt,C as ft,d as Ht,F as Pn,e as Wt,f as Lt,S as Ut,G as zn,g as Hn,M as Kt,X as ot,h as Ee,i as Gt,j as Wn,k as Vt,U as Ln,R as Un,l as Jt,m as Kn,n as Gn,o as Vn,D as Jn,p as Yn,A as Xn}from"./vendor-icons-CX25WOn8.js";import{R as Ke,T as Ge,P as Ve,C as Je,I as G,S as rt,D as Qn,a as Zn,b as es,c as ts,d as wt,e as at}from"./vendor-overlays-UwLNGk04.js";import{u as ns,a as ss,D as os,c as rs,S as as,h as is,P as cs,b as ls,C as ds}from"./vendor-dnd-D9kA7FgH.js";import{_ as ht}from"./vendor-highlight-DCzuSv8g.js";import"./vendor-markdown-B8HSIhaA.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))s(o);new MutationObserver(o=>{for(const r of o)if(r.type==="childList")for(const a of r.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&s(a)}).observe(document,{childList:!0,subtree:!0});function n(o){const r={};return o.integrity&&(r.integrity=o.integrity),o.referrerPolicy&&(r.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?r.credentials="include":o.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function s(o){if(o.ep)return;o.ep=!0;const r=n(o);fetch(o.href,r)}})();const us=new Rn;function Yt(t){const e=t.trim().replace(/^#/,""),n=e.length===3?e.split("").map(s=>s+s).join(""):e;if(n.length!==6||/[^0-9a-fA-F]/.test(n))throw new Error(`Invalid hex color: ${t}`);return{r:parseInt(n.slice(0,2),16),g:parseInt(n.slice(2,4),16),b:parseInt(n.slice(4,6),16)}}function ps(t){return Math.max(0,Math.min(255,Math.round(t)))}function fs({r:t,g:e,b:n}){const s=o=>ps(o).toString(16).padStart(2,"0");return`#${s(t)}${s(e)}${s(n)}`}function hs(t){const{r:e,g:n,b:s}=Yt(t),o=r=>{const a=r/255;return a<=.03928?a/12.92:((a+.055)/1.055)**2.4};return .2126*o(e)+.7152*o(n)+.0722*o(s)}function mt(t,e="#18181b",n="#ffffff"){return hs(t)>.45?e:n}function ms(t,e){const{r:n,g:s,b:o}=Yt(t),r=Math.max(0,Math.min(1,e));return fs({r:n+(255-n)*r,g:s+(255-s)*r,b:o+(255-o)*r})}function De(t){const e=t.trim().replace(/^#/,"");return(e.length===3||e.length===6)&&!/[^0-9a-fA-F]/.test(e)}const L=(t,e,n,s,o,r,a,c,d,f,g)=>({50:t,100:e,200:n,300:s,400:o,500:r,600:a,700:c,800:d,900:f,950:g}),x={zinc:L("#fafafa","#f4f4f5","#e4e4e7","#d4d4d8","#a1a1aa","#71717a","#52525b","#3f3f46","#27272a","#18181b","#09090b"),gray:L("#f9fafb","#f3f4f6","#e5e7eb","#d1d5db","#9ca3af","#6b7280","#4b5563","#374151","#1f2937","#111827","#030712"),slate:L("#f8fafc","#f1f5f9","#e2e8f0","#cbd5e1","#94a3b8","#64748b","#475569","#334155","#1e293b","#0f172a","#020617"),blue:L("#eff6ff","#dbeafe","#bfdbfe","#93c5fd","#60a5fa","#3b82f6","#2563eb","#1d4ed8","#1e40af","#1e3a8a","#172554"),green:L("#f0fdf4","#dcfce7","#bbf7d0","#86efac","#4ade80","#22c55e","#16a34a","#15803d","#166534","#14532d","#052e16"),red:L("#fef2f2","#fee2e2","#fecaca","#fca5a5","#f87171","#ef4444","#dc2626","#b91c1c","#991b1b","#7f1d1d","#450a0a"),teal:L("#f0fdfa","#ccfbf1","#99f6e4","#5eead4","#2dd4bf","#14b8a6","#0d9488","#0f766e","#115e59","#134e4a","#042f2e"),amber:L("#fffbeb","#fef3c7","#fde68a","#fcd34d","#fbbf24","#f59e0b","#d97706","#b45309","#92400e","#78350f","#451a03"),yellow:L("#fefce8","#fef9c3","#fef08a","#fde047","#facc15","#eab308","#ca8a04","#a16207","#854d0e","#713f12","#422006"),purple:L("#faf5ff","#f3e8ff","#e9d5ff","#d8b4fe","#c084fc","#a855f7","#9333ea","#7e22ce","#6b21a8","#581c87","#3b0764"),orange:L("#fff7ed","#ffedd5","#fed7aa","#fdba74","#fb923c","#f97316","#ea580c","#c2410c","#9a3412","#7c2d12","#431407"),white:"#ffffff",black:"#000000"},gs={statusSuccess:"#16a34a",statusDanger:"#dc2626",statusWarning:"#f59e0b",statusMerged:"#9333ea"},_s={statusSuccess:"#15803d",statusDanger:"#b91c1c",statusWarning:"#d97706",statusMerged:"#7c3aed"};function ys(){return{keyword:x.purple[300],string:x.green[300],number:x.orange[300],boolean:x.orange[300],comment:x.zinc[500],function:x.blue[300],variable:x.zinc[200],type:x.teal[300],class:x.amber[300],constant:x.orange[300],operator:x.zinc[400],punctuation:x.zinc[400],tag:x.red[300],attribute:x.amber[300],property:x.blue[200],regexp:x.teal[300],escape:x.orange[200],heading:x.blue[300],link:x.blue[400],deleted:x.red[400],inserted:x.green[400]}}function bs(){return{keyword:x.purple[700],string:x.green[700],number:x.orange[700],boolean:x.orange[700],comment:x.zinc[500],function:x.blue[700],variable:x.zinc[800],type:x.teal[700],class:x.amber[700],constant:x.orange[700],operator:x.zinc[600],punctuation:x.zinc[600],tag:x.red[700],attribute:x.amber[700],property:x.blue[700],regexp:x.teal[700],escape:x.orange[700],heading:x.blue[700],link:x.blue[600],deleted:x.red[700],inserted:x.green[700]}}function Xt(t,e,n){return{background:t,foreground:e,cursor:n,cursorAccent:t,selectionBackground:"rgba(255,255,255,0.18)",black:x.zinc[900],red:x.red[500],green:x.green[500],yellow:x.amber[500],blue:x.blue[500],magenta:x.purple[500],cyan:x.teal[500],white:x.zinc[300],brightBlack:x.zinc[600],brightRed:x.red[400],brightGreen:x.green[400],brightYellow:x.amber[400],brightBlue:x.blue[400],brightMagenta:x.purple[400],brightCyan:x.teal[400],brightWhite:x.zinc[50]}}function xe(t){const e=x.zinc[50],n=mt(t.accent);return{surface0:t.surface0,surface1:t.surface1,surface2:t.surface2,surface3:t.surface3,surface4:t.surface4,surfaceDiffEmpty:t.surfaceDiffEmpty,surfaceSidebar:t.surfaceSidebar,surfaceSidebarHover:t.surfaceSidebarHover,surfaceWorkspace:t.surface1,foreground:e,foregroundMuted:t.mutedForeground,accent:t.accent,accentBright:t.accentBright,accentForeground:n,destructive:t.destructive,destructiveForeground:x.white,success:t.accent,successForeground:x.white,border:t.border,borderAccent:t.borderAccent,...gs,diffAddition:x.green[400],diffDeletion:x.red[500],scrollbarHandle:t.scrollbarHandle,background:t.surface0,popover:t.surface2,popoverForeground:e,primary:t.accent,secondary:t.surface2,muted:t.surface2,mutedForeground:t.mutedForeground,input:t.surface2,ring:t.accent,palette:x,syntax:ys(),terminal:Xt(t.surface0,e,t.accent)}}function ws(){const t="#1a1a1e",e="#253e6f";return{surface0:"#ffffff",surface1:"#fafafa",surface2:"#f4f4f5",surface3:"#e4e4e7",surface4:"#d4d4d8",surfaceDiffEmpty:"#f6f6f6",surfaceSidebar:"#f4f4f5",surfaceSidebarHover:"#e9e9ec",surfaceWorkspace:"#ffffff",foreground:t,foregroundMuted:"#71717a",accent:e,accentBright:"#2f4f8e",accentForeground:mt(e),destructive:"#b04138",destructiveForeground:"#ffffff",success:e,successForeground:"#ffffff",border:"#e4e4e7",borderAccent:"#ececf1",..._s,diffAddition:"#15803d",diffDeletion:"#b91c1c",scrollbarHandle:"#3f3f46",background:"#ffffff",popover:"#ffffff",popoverForeground:t,primary:e,secondary:"#f4f4f5",muted:"#f4f4f5",mutedForeground:"#71717a",input:"#f4f4f5",ring:e,palette:x,syntax:bs(),terminal:{...Xt("#ffffff",t,e),selectionBackground:"rgba(0,0,0,0.15)",white:"#ffffff",brightWhite:"#fafafa"}}}const Ss={light:"#ffffff",dark:"#3b62b0",zinc:"#808080",midnight:"#4A6BA8",claude:"#D97757",ghostty:"#8caaee"},Qt=["light","dark","zinc","midnight","claude","ghostty"];function xs(t){if(t==="light")return ws();switch(t){case"dark":return xe({surface0:"#181B1A",surface1:"#1E2120",surface2:"#272A29",surface3:"#434645",surface4:"#595B5B",surfaceDiffEmpty:"#252827",surfaceSidebar:"#141716",surfaceSidebarHover:"#1c1f1e",mutedForeground:"#A1A5A4",scrollbarHandle:"#717574",border:"#252B2A",borderAccent:"#2f3135",accent:"#2e5cb8",accentBright:"#a2b4d7",destructive:"#c64f43"});case"zinc":return xe({surface0:"#18181b",surface1:"#1f1f22",surface2:"#27272a",surface3:"#3f3f46",surface4:"#52525b",surfaceDiffEmpty:"#242427",surfaceSidebar:"#131316",surfaceSidebarHover:"#1b1b1e",mutedForeground:"#a1a1aa",scrollbarHandle:"#71717a",border:"#27272a",borderAccent:"#303036",accent:"#e4e4e7",accentBright:"#fafafa",destructive:"#c44a4a"});case"midnight":return xe({surface0:"#161820",surface1:"#1c1e27",surface2:"#252731",surface3:"#3c3e4c",surface4:"#535564",surfaceDiffEmpty:"#222430",surfaceSidebar:"#121420",surfaceSidebarHover:"#1a1c28",mutedForeground:"#9a9db0",scrollbarHandle:"#6b6e82",border:"#242636",borderAccent:"#2e3040",accent:"#3b6fcf",accentBright:"#7eaaeb",destructive:"#c44a52"});case"claude":return xe({surface0:"#1f1f1e",surface1:"#262523",surface2:"#2f2d2b",surface3:"#4a4745",surface4:"#605d5b",surfaceDiffEmpty:"#2a2826",surfaceSidebar:"#1a1918",surfaceSidebarHover:"#222120",mutedForeground:"#ada9a5",scrollbarHandle:"#78746f",border:"#2c2a27",borderAccent:"#36332f",accent:"#d97757",accentBright:"#e89a7f",destructive:"#cf513e"});case"ghostty":return xe({surface0:"#282c34",surface1:"#2f333d",surface2:"#383c48",surface3:"#4a4f5e",surface4:"#5b6175",surfaceDiffEmpty:"#323643",surfaceSidebar:"#21252d",surfaceSidebarHover:"#292d36",mutedForeground:"#c8ccd8",scrollbarHandle:"#a0a4b2",border:"#353a47",borderAccent:"#3f4454",accent:"#89b4fa",accentBright:"#b4d0fc",destructive:"#c44a55"})}}const Zt={};for(const t of Qt){const e=t==="light"?"light":"dark";Zt[t]={name:t,colorScheme:e,colors:xs(t),swatch:Ss[t]}}const vs=Zt,ks={0:0,1:4,"1.5":6,2:8,3:12,4:16,6:24,8:32,12:48,16:64,20:80,24:96,32:128},en={xs:12,code:12,sm:14,base:16,lg:18,xl:20,"2xl":22,"3xl":26,"4xl":34},Is={normal:"400",medium:"500",semibold:"600",bold:"700"},js={none:0,sm:2,base:4,md:6,lg:8,xl:12,"2xl":16,full:9999},Cs={0:0,1:1,2:2},Ts={0:0,50:.5,100:1},Ns={xs:12,sm:14,md:16,lg:20},Es={diff:22},tn='system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif',nn='ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace';function Rs(t){const e=t==="dark"?"rgba(0,0,0,0.55)":"rgba(24,24,27,0.12)";return{sm:{color:e,offsetX:0,offsetY:1,radius:2,elevation:1},md:{color:e,offsetX:0,offsetY:3,radius:8,elevation:4},lg:{color:e,offsetX:0,offsetY:10,radius:24,elevation:12}}}function sn(t){const e=vs[t];return{name:t,colorScheme:e.colorScheme,colors:e.colors,spacing:ks,fontSize:{...en},fontFamily:{ui:tn,mono:nn},lineHeight:{...Es},iconSize:Ns,fontWeight:Is,borderRadius:js,borderWidth:Cs,opacity:Ts,shadow:Rs(e.colorScheme),swatch:e.swatch}}const qs=16,Ms=10,Bs=24;function $s(t,e){const n=e.themeName??t.name,s=sn(n),o=e.uiFont&&e.uiFont.trim()!==""?e.uiFont:tn,r=e.monoFont&&e.monoFont.trim()!==""?e.monoFont:nn;let a={...s.fontSize};if(e.fontSize!=null){const d=Math.max(Ms,Math.min(Bs,e.fontSize))/qs,f=["xs","code","sm","base","lg","xl","2xl","3xl","4xl"];for(const g of f){const b=en[g];a[g]=Math.round(b*d)}}return{...s,fontSize:a,fontFamily:{ui:o,mono:r}}}function As(t){return sn(t)}const Ds="dark";function Fs(t){const e={};Os(t.colors,e);for(const[n,s]of Object.entries(t.spacing))e[`--pi-spacing-${n}`]=`${s}px`;for(const[n,s]of Object.entries(t.fontSize))e[`--pi-font-size-${n}`]=`${s}px`;e["--pi-font-ui"]=t.fontFamily.ui,e["--pi-font-mono"]=t.fontFamily.mono,e["--pi-line-height-diff"]=`${t.lineHeight.diff}px`;for(const[n,s]of Object.entries(t.iconSize))e[`--pi-icon-size-${n}`]=`${s}px`;for(const[n,s]of Object.entries(t.fontWeight))e[`--pi-font-weight-${n}`]=String(s);for(const[n,s]of Object.entries(t.borderRadius))e[`--pi-radius-${n}`]=s===9999?"9999px":`${s}px`;for(const[n,s]of Object.entries(t.borderWidth))e[`--pi-border-width-${n}`]=`${s}px`;for(const[n,s]of Object.entries(t.opacity))e[`--pi-opacity-${n}`]=String(s);for(const[n,s]of Object.entries(t.shadow))if(typeof s=="string")e[`--pi-shadow-${n}`]=s;else if(s&&typeof s=="object"){const o=s;e[`--pi-shadow-${n}`]=`${o.offsetX}px ${o.offsetY}px ${o.radius}px ${o.color}`}return e["--pi-color-scheme"]=t.colorScheme,e}function Os(t,e){const{palette:n,syntax:s,terminal:o,...r}=t;for(const[a,c]of Object.entries(r))typeof c=="string"&&(e[`--pi-color-${a}`]=c);s&&Ps(s,e),o&&(e["--pi-terminal-bg"]=o.background,e["--pi-terminal-fg"]=o.foreground)}function Ps(t,e){for(const[n,s]of Object.entries(t))typeof s=="string"&&(e[`--syntax-${zs(n)}`]=s)}function zs(t){return t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function Hs(t){if(typeof document>"u")return;const e=document.documentElement.style;for(const[s,o]of Object.entries(t))e.setProperty(s,o);const n=t["--pi-color-scheme"];n&&document.documentElement.style.setProperty("color-scheme",n)}function Ws(t){const e=Fs(t);Hs(e)}const ve=l().min(1,"Asset path must not be empty"),Ls=u({accent:l().refine(De,{message:"accent must be a valid #rrggbb hex color"}),accentBright:l().refine(De,{message:"accentBright must be a valid #rrggbb hex color"}).optional(),accentForeground:l().refine(De,{message:"accentForeground must be a valid #rrggbb hex color"}).optional(),swatch:l().refine(De,{message:"swatch must be a valid #rrggbb hex color"}).optional()}),Us=u({logoLight:ve,logoDark:ve,logoMark:ve.optional(),icon:ve,splash:ve.optional()}),Ks=u({docs:l().url().optional(),support:l().url().optional(),issues:l().url().optional(),website:l().url().optional()}).optional(),Gs=u({copyright:l().optional(),companyName:l().optional()}).optional();u({productName:l().min(1,"productName is required"),shortName:l().optional(),tagline:l().optional(),colors:Ls,assets:Us,links:Ks,legal:Gs});function Vs(t){const e=t.accent,n=t.accentBright??ms(e,.35),s=t.accentForeground??mt(e),o=t.swatch??e;return{accent:e,accentBright:n,accentForeground:s,swatch:o}}function Js(t,e){return{...t,colors:{...t.colors,accent:e.accent,accentBright:e.accentBright,accentForeground:e.accentForeground,primary:e.accent,ring:e.accent},swatch:e.swatch}}const St="pi-studio-appearance";function Ys(t,e){let n=c(t),s=null;function o(g){return g==="system"?typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":g}function r(g,b){const h=o(g),S=As(h);let m=$s(S,{...b,themeName:h});if(e!=null&&e.colors){const _=Vs(e.colors);m=Js(m,_)}return m}function a(){const g=JSON.stringify({mode:n.mode,settings:n.settings});t.set(St,g)}function c(g){const b=g.get(St);let h=Ds,S={};if(b)try{const _=JSON.parse(b);_.mode&&(Qt.includes(_.mode)||_.mode==="system")&&(h=_.mode),_.settings&&typeof _.settings=="object"&&(S=_.settings)}catch{}const m=r(h,S);return{mode:h,settings:S,resolvedTheme:m}}function d(){n={...n,resolvedTheme:r(n.mode,n.settings)},a()}const f={getState(){return n},setMode(g){n={...n,mode:g},d(),f.apply()},updateSettings(g){n={...n,settings:{...n.settings,...g}},d(),f.apply()},apply(){Ws(n.resolvedTheme)},listen(){if(typeof window>"u")return()=>{};const g=window.matchMedia("(prefers-color-scheme: dark)"),b=()=>{n.mode==="system"&&(d(),f.apply())};return g.addEventListener("change",b),s=()=>g.removeEventListener("change",b),s}};return f}function Xs({store:t,brandConfig:e,children:n}){const s=v.useRef(null);return s.current||(s.current=Ys(t,e),s.current.apply()),v.useEffect(()=>s.current.listen(),[]),i.jsx(i.Fragment,{children:n})}const Qs={get(t){var e;try{return((e=globalThis.localStorage)==null?void 0:e.getItem(t))??null}catch{return null}},set(t,e){var n;try{(n=globalThis.localStorage)==null||n.setItem(t,e)}catch{}}};function Zs({children:t}){return i.jsx(Xs,{store:Qs,children:i.jsx(qn,{client:us,children:t})})}const eo="_btn_1chbg_4",to="_secondary_1chbg_44",no="_outline_1chbg_53",so="_ghost_1chbg_62",oo="_destructive_1chbg_72",ro="_iconOnly_1chbg_82",ao="_loadingSpinner_1chbg_89",io="_piSpin_1chbg_1",Fe={btn:eo,default:"_default_1chbg_35",secondary:to,outline:no,ghost:so,destructive:oo,iconOnly:ro,loadingSpinner:ao,piSpin:io},xt={xs:28,sm:32,md:36,lg:40},co={xs:12,sm:14,md:16,lg:20},vt={xs:8,sm:10,md:12,lg:16},lo={xs:12,sm:13,md:14,lg:15};function uo(t){const{disabled:e,loading:n}=t;return e||n?{opacity:.5,isGhostHover:!1}:{opacity:1,isGhostHover:!1}}function F({variant:t="default",size:e="md",loading:n=!1,disabled:s=!1,leftIcon:o,trailing:r,iconOnly:a=!1,children:c,style:d,className:f,...g}){const{opacity:b}=uo({disabled:s??!1,loading:n}),h=s||n,S=co[e];return i.jsxs("button",{className:A(Fe.btn,Fe[t],a&&Fe.iconOnly,f),disabled:h,"aria-busy":n||void 0,style:{minHeight:xt[e],paddingLeft:a?void 0:vt[e],paddingRight:a?void 0:vt[e],fontSize:lo[e],opacity:b,...a?{width:xt[e]}:{},...d},...g,children:[n?i.jsx($n,{className:Fe.loadingSpinner,size:S,"aria-hidden":!0}):o?i.jsx("span",{"aria-hidden":!0,style:{display:"flex",alignItems:"center",flexShrink:0},children:o}):null,c,r&&!n&&i.jsx("span",{"aria-hidden":!0,style:{display:"flex",alignItems:"center",flexShrink:0},children:r})]})}const po="_input_a7qyq_3",fo="_textarea_a7qyq_32",it={input:po,textarea:fo},Le=v.forwardRef(function({className:e,...n},s){return i.jsx("input",{ref:s,className:A(it.input,e),...n})}),zd=v.forwardRef(function({className:e,...n},s){return i.jsx("textarea",{ref:s,className:A(it.input,it.textarea,e),...n})}),on=l().datetime({offset:!0});l().uuid();l().regex(/^[A-Za-z0-9_-]+$/,"expected base64url");const Ne=Pt([q(),on]),ho=qe(["mobile","browser","cli","mcp"]),mo=u({type:w("hello"),clientId:l(),clientType:ho,protocolVersion:q(),appVersion:l().optional(),capabilities:ne(l(),B()).optional()}),go=u({status:w("server_info"),serverId:l(),hostname:l().optional(),version:l().optional(),capabilities:ne(l(),D()),features:ne(l(),D())}),_o=u({type:w("status"),payload:go}),yo=u({type:w("ping"),requestId:l(),clientSentAt:Ne.optional()}),bo=u({type:w("pong"),requestId:l(),clientSentAt:Ne.optional(),serverReceivedAt:Ne,serverSentAt:Ne}),rn=qe(["initializing","idle","running","error","closed"]),Ye=u({mimeType:l().optional(),data:l().optional()}).passthrough(),wo=u({prs:O(D()).optional(),issues:O(D()).optional()}).passthrough(),So=u({provider:l(),cwd:l(),modeId:l().optional(),model:l().optional(),modelProvider:l().optional(),thinkingOptionId:l().optional(),featureValues:ne(l(),D()).optional(),title:l().nullable().optional(),approvalPolicy:l().optional(),sandboxMode:l().optional(),networkAccess:B().optional(),webSearch:B().optional(),extra:u({pi:D().optional()}).passthrough().optional(),systemPrompt:l().optional(),mcpServers:ne(l(),D()).optional()}),xo=u({type:w("create_agent_request"),requestId:l(),config:So,env:ne(l(),l()).optional(),workspaceId:l().optional(),worktreeName:l().optional(),initialPrompt:l().optional(),clientMessageId:l().optional(),outputSchema:ne(l(),D()).optional(),images:O(Ye).optional(),attachments:wo.optional(),git:D().optional(),worktree:D().optional(),autoArchive:B().optional(),labels:ne(l(),l()).default({})}),vo=u({type:w("create_agent_response"),requestId:l(),payload:u({agentId:l()}).passthrough()}),ko=u({type:w("agent_update"),agentId:l(),status:rn.optional(),title:l().nullable().optional(),labels:ne(l(),l()).optional()}),Io=u({type:w("agent_status"),agentId:l(),status:rn}),jo=u({type:w("agent_list"),agents:O(u({id:l()}).passthrough())}),Co=u({type:w("agent_deleted"),agentId:l()}),To=u({type:w("agent_archived"),agentId:l(),archivedAt:on.optional()}),an=Ue("kind",[u({kind:w("shell"),command:l().optional(),output:l().optional()}),u({kind:w("read"),path:l().optional(),output:l().optional()}),u({kind:w("edit"),path:l().optional(),diff:l().optional(),output:l().optional()}),u({kind:w("write"),path:l().optional(),output:l().optional()}),u({kind:w("search"),query:l().optional(),output:l().optional()}),u({kind:w("fetch"),url:l().optional(),output:l().optional()}),u({kind:w("task"),description:l().optional(),output:l().optional()})]),No=Ue("kind",[u({kind:w("user_message"),messageId:l().optional(),text:l().optional(),images:O(Ye).optional()}),u({kind:w("assistant_message"),messageId:l().optional(),text:l().optional()}),u({kind:w("reasoning"),text:l().optional()}),u({kind:w("tool_call"),callId:l().optional(),tool:an,status:l().optional()}),u({kind:w("turn_started"),turnId:l().optional()}),u({kind:w("turn_completed"),turnId:l().optional()}),u({kind:w("turn_failed"),turnId:l().optional(),error:l().optional()}),u({kind:w("turn_canceled"),turnId:l().optional()}),u({kind:w("error"),message:l().optional()}),u({kind:w("queue_update"),steering:O(l()).optional(),followUp:O(l()).optional()})]),Eo=u({type:w("agent_stream"),agentId:l(),seq:q().optional(),timestamp:Ne.optional(),event:No}),Ro=qe(["before","after"]),qo=u({start:q(),end:q()}),Mo=u({type:w("fetch_agent_timeline_request"),requestId:l(),agentId:l(),cursor:l().nullable().optional(),direction:Ro,limit:q().optional()}),Bo=u({type:w("fetch_agent_timeline_response"),requestId:l(),agentId:l().optional(),items:O(D()),seqStart:q(),seqEnd:q(),sourceSeqRanges:O(qo),collapsed:B(),hasNewer:B(),startCursor:l().nullable().optional(),endCursor:l().nullable().optional()}),$o=u({type:w("agent_permission_request"),requestId:l(),agentId:l(),toolName:l().optional(),tool:an.optional(),action:D().optional(),responses:O(l()).optional()}),Ao=u({type:w("agent_permission_resolved"),requestId:l(),agentId:l(),decision:l().optional()}),Do=u({type:w("agent.permission.respond.request"),requestId:l(),permissionRequestId:l(),response:D()}),Fo=u({type:w("agent.permission.respond.response"),requestId:l(),payload:u({resolved:B()}).passthrough()}),Oo=u({type:w("respond_to_permission"),requestId:l(),permissionRequestId:l(),response:D()}),cn=qe(["conversation","files","both"]),Po=u({type:w("agent.rewind.request"),requestId:l(),agentId:l(),messageId:l(),mode:cn}).passthrough(),zo=u({type:w("agent.rewind.response"),requestId:l(),payload:u({agentId:l(),messageId:l(),mode:cn,truncatedAt:l().optional()}).passthrough()}).passthrough(),Ho=u({input:q().optional(),output:q().optional(),cacheRead:q().optional(),cacheWrite:q().optional(),total:q().optional()}).passthrough(),Wo=u({tokens:q().nullable().optional(),contextWindow:q().optional(),percent:q().nullable().optional()}).passthrough(),Lo=u({type:w("agent_session_stats_request"),requestId:l(),agentId:l()}).passthrough(),Uo=u({type:w("agent_session_stats_response"),requestId:l(),payload:u({sessionId:l().optional(),sessionFile:l().optional(),userMessages:q().optional(),assistantMessages:q().optional(),toolCalls:q().optional(),toolResults:q().optional(),totalMessages:q().optional(),tokens:Ho.optional(),cost:q().optional(),contextUsage:Wo.optional(),model:l().optional()}).passthrough()}).passthrough(),Ko=u({type:w("agent_compact_request"),requestId:l(),agentId:l(),customInstructions:l().optional()}).passthrough(),Go=u({type:w("agent_compact_response"),requestId:l(),payload:u({summary:l().optional(),firstKeptEntryId:l().optional(),tokensBefore:q().optional(),details:D().optional()}).passthrough()}).passthrough(),Vo=u({type:w("agent_new_session_request"),requestId:l(),agentId:l()}).passthrough(),Jo=u({type:w("agent_new_session_response"),requestId:l(),payload:u({cancelled:B()}).passthrough()}).passthrough(),Yo=u({type:w("agent_switch_session_request"),requestId:l(),agentId:l(),sessionPath:l()}).passthrough(),Xo=u({type:w("agent_switch_session_response"),requestId:l(),payload:u({cancelled:B()}).passthrough()}).passthrough(),Qo=u({type:w("agent_fork_request"),requestId:l(),agentId:l(),entryId:l()}).passthrough(),Zo=u({type:w("agent_fork_response"),requestId:l(),payload:u({text:l(),cancelled:B()}).passthrough()}).passthrough(),er=u({type:w("agent_fork_messages_request"),requestId:l(),agentId:l()}).passthrough(),tr=u({type:w("agent_fork_messages_response"),requestId:l(),payload:u({messages:O(u({entryId:l(),text:l()}).passthrough())}).passthrough()}).passthrough(),nr=u({type:w("agent_clone_request"),requestId:l(),agentId:l()}).passthrough(),sr=u({type:w("agent_clone_response"),requestId:l(),payload:u({cancelled:B()}).passthrough()}).passthrough(),or=u({type:w("agent_set_session_name_request"),requestId:l(),agentId:l(),name:l()}).passthrough(),rr=u({type:w("agent_set_session_name_response"),requestId:l(),payload:u({}).passthrough().optional()}).passthrough(),ar=u({type:w("agent_export_html_request"),requestId:l(),agentId:l(),outputPath:l().optional()}).passthrough(),ir=u({type:w("agent_export_html_response"),requestId:l(),payload:u({path:l()}).passthrough()}).passthrough(),cr=u({type:w("agent_set_model_request"),requestId:l(),agentId:l(),provider:l(),modelId:l()}).passthrough(),lr=u({type:w("agent_set_model_response"),requestId:l(),payload:u({}).passthrough()}).passthrough(),dr=u({type:w("agent_cycle_model_request"),requestId:l(),agentId:l()}).passthrough(),ur=u({type:w("agent_cycle_model_response"),requestId:l(),payload:u({model:D().nullable().optional(),thinkingLevel:l().optional(),isScoped:B().optional()}).passthrough()}).passthrough(),pr=u({type:w("agent_last_assistant_text_request"),requestId:l(),agentId:l()}).passthrough(),fr=u({type:w("agent_last_assistant_text_response"),requestId:l(),payload:u({text:l().nullable()}).passthrough()}).passthrough(),hr=u({type:w("steer_agent_request"),requestId:l(),agentId:l(),message:l(),images:O(Ye).optional(),clientMessageId:l().optional()}).passthrough(),mr=u({type:w("steer_agent_response"),requestId:l(),agentId:l(),ok:B()}).passthrough(),gr=u({type:w("follow_up_agent_request"),requestId:l(),agentId:l(),message:l(),images:O(Ye).optional(),clientMessageId:l().optional()}).passthrough(),_r=u({type:w("follow_up_agent_response"),requestId:l(),agentId:l(),ok:B()}).passthrough(),yr=u({type:w("rpc_error"),requestId:l(),code:l().optional(),message:l().optional(),error:l().optional()}),br=Ue("type",[xo,vo,ko,Io,jo,Co,To,Eo,Mo,Bo,$o,Ao,Do,Fo,Oo,Po,zo,Lo,Uo,Ko,Go,Vo,Jo,Yo,Xo,Qo,Zo,er,tr,nr,sr,or,rr,ar,ir,cr,lr,dr,ur,pr,fr,hr,mr,gr,_r,yr]),wr=u({type:l()}).passthrough(),Sr=u({type:w("session"),message:Pt([br,wr])});Ue("type",[mo,_o,yo,bo,Sr]);const he={Output:1,Input:2,Resize:3,Snapshot:4,Restore:5},xr=Object.fromEntries(Object.entries(he).map(([t,e])=>[e,t])),ln=u({rows:q().int().nonnegative(),cols:q().int().nonnegative()});class je extends Error{constructor(e){super(e),this.name="TerminalFrameError"}}const vr=new TextEncoder,kr=new TextDecoder;function Ir(t){if(!Number.isInteger(t)||t<0||t>255)throw new je(`slot must be an integer 0–255, got ${t}`)}function ke(t,e,n){const s=new Uint8Array(2+n.length);return s[0]=t,s[1]=e,s.set(n,2),s}function Hd(t){switch(Ir(t.slot),t.opcode){case"Output":return ke(he.Output,t.slot,t.data);case"Input":return ke(he.Input,t.slot,t.data);case"Snapshot":return ke(he.Snapshot,t.slot,t.data);case"Restore":return ke(he.Restore,t.slot,t.data);case"Resize":{const e=JSON.stringify(ln.parse({rows:t.rows,cols:t.cols}));return ke(he.Resize,t.slot,vr.encode(e))}}}function jr(t){if(t.length<2)throw new je(`frame too short: ${t.length} bytes (need ≥ 2)`);const e=t[0],n=t[1],s=xr[e];if(!s)throw new je(`unknown terminal opcode 0x${e.toString(16)}`);const o=t.subarray(2);if(s==="Resize"){let r;try{r=JSON.parse(kr.decode(o))}catch{throw new je("resize payload is not valid JSON")}const a=ln.safeParse(r);if(!a.success)throw new je("resize payload is not { rows, cols }");return{opcode:"Resize",slot:n,rows:a.data.rows,cols:a.data.cols}}return{opcode:s,slot:n,data:o.slice()}}const ge={Begin:16,Chunk:17,End:18,Error:19},Cr=Object.fromEntries(Object.entries(ge).map(([t,e])=>[e,t])),dn=u({transferId:l(),fileName:l().optional(),mimeType:l().optional(),totalBytes:q().int().nonnegative().optional()});class Ce extends Error{constructor(e){super(e),this.name="FileTransferFrameError"}}const kt=new TextEncoder,It=new TextDecoder;function Tr(t){if(!Number.isInteger(t)||t<0||t>255)throw new Ce(`stream must be an integer 0–255, got ${t}`)}function Oe(t,e,n){const s=new Uint8Array(2+n.length);return s[0]=t,s[1]=e,s.set(n,2),s}function et(t){switch(Tr(t.stream),t.opcode){case"Begin":return Oe(ge.Begin,t.stream,kt.encode(JSON.stringify(dn.parse(t.meta))));case"Chunk":return Oe(ge.Chunk,t.stream,t.data);case"End":return Oe(ge.End,t.stream,new Uint8Array([t.ok?1:0]));case"Error":return Oe(ge.Error,t.stream,kt.encode(t.message))}}function Nr(t){if(t.length<2)throw new Ce(`frame too short: ${t.length} bytes (need ≥ 2)`);const e=t[0],n=t[1],s=Cr[e];if(!s)throw new Ce(`unknown file-transfer opcode 0x${e.toString(16)}`);const o=t.subarray(2);switch(s){case"Begin":{let r;try{r=JSON.parse(It.decode(o))}catch{throw new Ce("begin payload is not valid JSON")}const a=dn.safeParse(r);if(!a.success)throw new Ce("begin payload is not a valid transfer header");return{opcode:"Begin",stream:n,meta:a.data}}case"Chunk":return{opcode:"Chunk",stream:n,data:o.slice()};case"End":return{opcode:"End",stream:n,ok:(o[0]??1)!==0};case"Error":return{opcode:"Error",stream:n,message:It.decode(o)}}}function Er(t){try{return Nr(t)}catch{return null}}const Rr=l().regex(/^[a-z][a-z0-9-]*$/,"invalid provider id"),qr=qe(["safe","moderate","dangerous","planning"]),Mr=u({supportsStreaming:B(),supportsSessionPersistence:B(),supportsDynamicModes:B(),supportsMcpServers:B(),supportsReasoningStream:B(),supportsToolInvocations:B(),supportsRewindConversation:B().optional(),supportsRewindFiles:B().optional(),supportsRewindBoth:B().optional(),supportsSteering:B().optional()}).passthrough(),Br=u({id:l(),label:l().optional(),description:l().optional(),icon:l().optional(),colorTier:qr});u({id:Rr,label:l(),description:l().optional(),extends:l().optional(),modes:O(Br),capabilities:Mr});function ct(t){return typeof t=="string"?t:t instanceof Uint8Array||Buffer.isBuffer(t)?t.toString("utf8"):String(t??"")}function un(t){let e=null;const n={onMessage:null,onClose:null,onError:null,get isOpen(){return e!==null&&e.readyState===1},connect(s){return new Promise((o,r)=>{const a=t??(()=>new WebSocket(s));try{e=t?a(s):new WebSocket(s)}catch(c){r(c);return}e.onopen=()=>o(),e.onerror=c=>{var d;(e==null?void 0:e.readyState)!==1&&r(c),(d=n.onError)==null||d.call(n,c)},e.onclose=c=>{var d;(d=n.onClose)==null||d.call(n,c.code,ct(c.reason))},e.onmessage=c=>{var f,g,b,h;const{data:d}=c;d instanceof ArrayBuffer||d instanceof Uint8Array?(f=n.onMessage)==null||f.call(n,d):typeof d=="string"?(g=n.onMessage)==null||g.call(n,d):typeof Blob<"u"&&d instanceof Blob?(b=n.onMessage)==null||b.call(n,d):Buffer.isBuffer(d)&&((h=n.onMessage)==null||h.call(n,d.buffer.slice(d.byteOffset,d.byteOffset+d.byteLength)))}})},sendText(s){e==null||e.send(s)},sendBinary(s){e==null||e.send(s)},close(s=1e3,o=""){e==null||e.close(s,o),e=null}};return n}const Te="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function pn(t){let e="";for(let n=0;n<t.length;n+=3){const s=t[n],o=n+1<t.length,r=n+2<t.length,a=o?t[n+1]:0,c=r?t[n+2]:0;e+=Te[s>>2],e+=Te[(s&3)<<4|a>>4],e+=o?Te[(a&15)<<2|c>>6]:"=",e+=r?Te[c&63]:"="}return e}function fn(t){const e=t.replace(/=+$/,""),n=[];let s=0,o=0;for(const r of e){const a=Te.indexOf(r);if(a===-1)throw new Error(`invalid base64 character: ${JSON.stringify(r)}`);s=s<<6|a,o+=6,o>=8&&(o-=8,n.push(s>>o&255))}return new Uint8Array(n)}function $r(t){try{const e=JSON.parse(t);return!e||typeof e.type!="string"?null:e}catch{return null}}const He=24;function hn(t,e){const n=_e.randomBytes(He),s=_e.box.after(t,n,e),o=new Uint8Array(n.length+s.length);return o.set(n,0),o.set(s,n.length),pn(o)}function mn(t,e){let n;try{n=fn(t)}catch{return null}if(n.length<He)return null;const s=n.slice(0,He),o=n.slice(He);return _e.box.open.after(o,s,e)}function Ar(t,e){return hn(new TextEncoder().encode(t),e)}function Dr(t,e){const n=mn(t,e);return n?new TextDecoder().decode(n):null}function Fr(t,e,n,s,o,r){let a=!1;return n.onClose(c=>{var d;a=!0,(d=s.onClose)==null||d.call(s,c)}),{handleAppFrame(c){var g,b;if(a)return;const d=o();if(!r()||!d)return;const f=Dr(c.frame,d);if(f===null){(g=s.onAuthError)==null||g.call(s,new Error(`relay ${t} channel: message failed authentication`));return}(b=s.onMessage)==null||b.call(s,f)},handleBinaryFrame(c){var g,b;if(a)return;const d=o();if(!r()||!d)return;const f=mn(c.frame,d);if(f===null){(g=s.onAuthError)==null||g.call(s,new Error(`relay ${t} channel: binary message failed authentication`));return}(b=s.onBinaryMessage)==null||b.call(s,f)},send(c){if(a)throw new Error(`relay ${t} channel: cannot send after close()`);const d=o();if(!r()||!d)throw new Error(`relay ${t} channel: cannot send before the E2EE handshake completes`);n.send(JSON.stringify({type:"e2ee_app",frame:Ar(c,d)}))},sendBinary(c){if(a)throw new Error(`relay ${t} channel: cannot send after close()`);const d=o();if(!r()||!d)throw new Error(`relay ${t} channel: cannot send before the E2EE handshake completes`);n.send(JSON.stringify({type:"e2ee_bin",frame:hn(c,d)}))},close(){a||(a=!0,n.close())}}}function Or(t){const{transport:e,attachment:n,daemonPublicKey:s}=t,o=t.events??{},r=_e.box.keyPair(),a=_e.box.before(s,r.secretKey);let c=!1;const d=Fr("client",n,e,o,()=>a,()=>c);return e.onMessage(f=>{var b;const g=$r(f);if(g){if(g.type==="e2ee_ready"){if(c)return;c=!0,(b=o.onReady)==null||b.call(o);return}if(g.type==="e2ee_app"){d.handleAppFrame(g);return}g.type==="e2ee_bin"&&d.handleBinaryFrame(g)}}),e.send(JSON.stringify({type:"e2ee_hello",ephemeralPublicKey:pn(r.publicKey)})),{role:"client",attachment:n,get ready(){return c},send:d.send,sendBinary:d.sendBinary,close:d.close}}const Pr=16;function zr(t){const e=_e.hash(t);let n="";for(let s=0;s<Pr;s++)n+=e[s].toString(16).padStart(2,"0");return n}function Hr(t){const e=t.useTls?"wss":"ws",n=t.endpoint.replace(/^(?:https?|wss?):\/\//,"").replace(/\/+$/,"");return`${e}://${n}`}function Wr(t){let e=null,n=null;const s=t.sessionId??zr(t.daemonPublicKey),o={onMessage:null,onClose:null,onError:null,get isOpen(){return e!==null&&e.readyState===1&&n!==null&&n.ready},connect(r){return new Promise((a,c)=>{const d=t.factory??(()=>new WebSocket(r));try{e=t.factory?d(r):new WebSocket(r)}catch(h){c(h);return}const f=e,g=[],b=[];f.onopen=()=>{f.send(JSON.stringify({type:"relay_register",sessionId:s})),n=Or({transport:{send:h=>f.send(h),onMessage:h=>g.push(h),onClose:h=>b.push(h),close:()=>f.close()},attachment:{sessionId:s},daemonPublicKey:t.daemonPublicKey,events:{onReady:()=>a(),onMessage:h=>{var S;return(S=o.onMessage)==null?void 0:S.call(o,h)},onBinaryMessage:h=>{var S;return(S=o.onMessage)==null?void 0:S.call(o,h.slice().buffer)},onAuthError:h=>{var S;return(S=o.onError)==null?void 0:S.call(o,h)}}})},f.onerror=h=>{var S;f.readyState!==1&&c(h),(S=o.onError)==null||S.call(o,h)},f.onclose=h=>{var S;for(const m of b)m(ct(h.reason));(S=o.onClose)==null||S.call(o,h.code,ct(h.reason))},f.onmessage=h=>{const{data:S}=h;if(typeof S=="string")for(const m of g)m(S)}})},sendText(r){if(!n||!n.ready)throw new Error("relay transport: cannot send before the E2EE handshake completes");n.send(r)},sendBinary(r){if(!n||!n.ready)throw new Error("relay transport: cannot send before the E2EE handshake completes");n.sendBinary(r)},close(r=1e3,a=""){n==null||n.close(),n=null,e==null||e.close(r,a),e=null}};return o}function Lr(t){const e=t.indexOf("#"),n=e===-1?t:t.slice(e+1),s=new URLSearchParams(n),o=s.get("offer");if(!o)return null;let r;try{r=fn(o)}catch{return null}const a=s.get("relay");if(a){const d={endpoint:a,useTls:s.get("relayTls")==="1"};return{publicKeyB64:o,publicKey:r,relay:d}}const c=s.get("host")??void 0;return{publicKeyB64:o,publicKey:r,...c?{host:c}:{}}}const Ur=1;function lt(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`id-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}class Kr extends Error{constructor(e,n,s){super(e),this.requestId=n,this.code=s,this.name="RpcError"}}class jt extends Error{constructor(e){super(`RPC ${e} timed out`),this.requestId=e,this.name="RpcTimeoutError"}}class Gr{constructor(e){I(this,"transport");I(this,"rpcTimeoutMs");I(this,"now");I(this,"_state","idle");I(this,"_serverId",null);I(this,"_features",{});I(this,"_serverCapabilities",{});I(this,"pending",new Map);I(this,"sessionHandlers",new Set);I(this,"terminalHandlers",new Set);I(this,"fileTransferHandlers",new Set);I(this,"stateHandlers",new Set);I(this,"helloResolve",null);I(this,"helloReject",null);this.options=e,this.transport=e.transport??un(),this.rpcTimeoutMs=e.rpcTimeoutMs??3e4,this.now=e.now??(()=>Date.now()),this.transport.onMessage=n=>this.handleIncoming(n),this.transport.onClose=(n,s)=>this.handleClose(n,s),this.transport.onError=()=>{}}get state(){return this._state}get serverId(){return this._serverId}get features(){return this._features}get serverCapabilities(){return this._serverCapabilities}hasFeature(e){return!!this._features[e]}async connect(){this.setState("connecting"),await this.transport.connect(this.options.url);const e=new Promise((s,o)=>{this.helloResolve=s,this.helloReject=o});this.transport.sendText(JSON.stringify({type:"hello",clientId:this.options.clientId,clientType:this.options.clientType,protocolVersion:this.options.protocolVersion??Ur,appVersion:this.options.appVersion,capabilities:this.options.capabilities}));const n=await e;return this._serverId=n.serverId,this._features=n.features,this._serverCapabilities=n.capabilities,this.setState("open"),n}close(e=1e3,n=""){this.setState("closing"),this.transport.close(e,n)}request(e,n={},s){const o=n.requestId??lt();return new Promise((r,a)=>{const c=s??this.rpcTimeoutMs,d=c>0?setTimeout(()=>{this.pending.delete(o),a(new jt(o))},c):null;this.pending.set(o,{resolve:f=>r(f),reject:a,timer:d}),this.sendSession({type:e,...n,requestId:o})})}sendSession(e){this.transport.sendText(JSON.stringify({type:"session",message:e}))}sendBinary(e){this.transport.sendBinary(e)}ping(e=1e4){const n=lt();return new Promise((s,o)=>{const r=e>0?setTimeout(()=>{this.pending.delete(n),o(new jt(n))},e):null;this.pending.set(n,{resolve:()=>s(),reject:o,timer:r}),this.transport.sendText(JSON.stringify({type:"ping",requestId:n,clientSentAt:this.now()}))})}onSessionMessage(e){return this.sessionHandlers.add(e),()=>this.sessionHandlers.delete(e)}onTerminalFrame(e){return this.terminalHandlers.add(e),()=>this.terminalHandlers.delete(e)}onFileTransferFrame(e){return this.fileTransferHandlers.add(e),()=>this.fileTransferHandlers.delete(e)}onStateChange(e){return this.stateHandlers.add(e),()=>this.stateHandlers.delete(e)}setState(e){if(this._state!==e){this._state=e;for(const n of this.stateHandlers)n(e)}}handleClose(e,n){this.helloReject&&(this.helloReject(new Error(`socket closed during handshake: ${n}`)),this.helloResolve=null,this.helloReject=null);for(const[,s]of this.pending)s.timer&&clearTimeout(s.timer),s.reject(new Error(`socket closed: ${n}`));this.pending.clear(),this.setState("closed")}handleIncoming(e){if(typeof e=="string"){this.handleTextFrame(e);return}if(e instanceof ArrayBuffer){this.handleBinaryFrame(new Uint8Array(e));return}typeof e.arrayBuffer=="function"&&e.arrayBuffer().then(n=>this.handleBinaryFrame(new Uint8Array(n)))}handleBinaryFrame(e){const n=e[0];if(n!==void 0&&Object.values(ge).includes(n)){const r=Er(e);if(!r)return;for(const a of this.fileTransferHandlers)a(r);return}const o=jr(e);for(const r of this.terminalHandlers)r(o)}handleTextFrame(e){let n;try{n=JSON.parse(e)}catch{return}const s=n;switch(s.type){case"status":this.handleStatus(s);return;case"pong":this.resolvePending(s.requestId,void 0);return;case"ping":this.transport.sendText(JSON.stringify({type:"pong",requestId:s.requestId,serverReceivedAt:this.now(),serverSentAt:this.now()}));return;case"session":this.handleSession(s.message);return;default:return}}handleStatus(e){const n=e.payload;(n==null?void 0:n.status)==="server_info"&&this.helloResolve&&(this.helloResolve(n),this.helloResolve=null,this.helloReject=null)}handleSession(e){if(!e||typeof e!="object")return;const n=e;if(n.type==="rpc_error"&&typeof n.requestId=="string"){const s=this.pending.get(n.requestId);s&&(s.timer&&clearTimeout(s.timer),this.pending.delete(n.requestId),s.reject(new Kr(n.message??n.error??"RPC failed",n.requestId,n.code)));return}if(typeof n.requestId=="string"&&this.pending.has(n.requestId)){const s="payload"in n?n.payload:n;this.resolvePending(n.requestId,s)}for(const s of this.sessionHandlers)s(e)}resolvePending(e,n){const s=this.pending.get(e);s&&(s.timer&&clearTimeout(s.timer),this.pending.delete(e),s.resolve(n))}}class Vr{constructor(e){this.daemon=e}get connection(){return this.daemon}async createAgent(e){return await this.daemon.request("create_agent_request",{...e})}agent(e){return new Yr(this.daemon,e)}workspace(e){return new Xr(this.daemon,e)}get providers(){return new Qr(this.daemon)}onAgentUpdate(e){return this.daemon.onSessionMessage(n=>{n.type==="agent_update"&&e(n)})}onWorkspaceUpdate(e){return this.daemon.onSessionMessage(n=>{n.type==="workspace_update"&&e(n)})}}class Jr{constructor(e,n){this.daemon=e,this.agentId=n}fetch(e={}){return this.daemon.request("fetch_agent_timeline_request",{agentId:this.agentId,cursor:e.cursor,direction:e.direction,limit:e.limit})}subscribe(e){return this.daemon.onSessionMessage(n=>{const s=n;s.type==="agent_stream"&&s.agentId===this.agentId&&s.event&&e(s.event)})}}class Yr{constructor(e,n){I(this,"timeline");this.daemon=e,this.agentId=n,this.timeline=new Jr(e,n)}send(e,n={}){return this.daemon.request("send_agent_prompt",{agentId:this.agentId,prompt:e,clientMessageId:n.clientMessageId,images:n.images})}run(e,n){return this.send(e,n)}interrupt(){return this.daemon.request("interrupt_agent",{agentId:this.agentId})}steer(e,n={}){return this.daemon.request("steer_agent_request",{agentId:this.agentId,message:e,clientMessageId:n.clientMessageId,images:n.images})}followUp(e,n={}){return this.daemon.request("follow_up_agent_request",{agentId:this.agentId,message:e,clientMessageId:n.clientMessageId,images:n.images})}update(e){return this.daemon.request("update_agent",{agentId:this.agentId,...e})}resume(){return this.daemon.request("resume_agent",{agentId:this.agentId})}archive(){return this.daemon.request("archive_agent",{agentId:this.agentId})}delete(){return this.daemon.request("delete_agent",{agentId:this.agentId})}onUpdate(e){return this.daemon.onSessionMessage(n=>{const s=n;s.type==="agent_update"&&s.agentId===this.agentId&&e(s)})}sessionStats(){return this.daemon.request("agent_session_stats_request",{agentId:this.agentId})}compact(e){return this.daemon.request("agent_compact_request",{agentId:this.agentId,customInstructions:e})}newSession(){return this.daemon.request("agent_new_session_request",{agentId:this.agentId})}switchSession(e){return this.daemon.request("agent_switch_session_request",{agentId:this.agentId,sessionPath:e})}fork(e){return this.daemon.request("agent_fork_request",{agentId:this.agentId,entryId:e})}forkMessages(){return this.daemon.request("agent_fork_messages_request",{agentId:this.agentId})}clone(){return this.daemon.request("agent_clone_request",{agentId:this.agentId})}setSessionName(e){return this.daemon.request("agent_set_session_name_request",{agentId:this.agentId,name:e})}exportHtml(e){return this.daemon.request("agent_export_html_request",{agentId:this.agentId,outputPath:e})}setModel(e,n){return this.daemon.request("agent_set_model_request",{agentId:this.agentId,provider:e,modelId:n})}cycleModel(){return this.daemon.request("agent_cycle_model_request",{agentId:this.agentId})}lastAssistantText(){return this.daemon.request("agent_last_assistant_text_request",{agentId:this.agentId})}}class Xr{constructor(e,n){this.daemon=e,this.workspaceId=n}onUpdate(e){return this.daemon.onSessionMessage(n=>{const s=n;s.type==="workspace_update"&&s.workspaceId===this.workspaceId&&e(s)})}}class Qr{constructor(e){this.daemon=e}listProviders(){return this.daemon.request("list_providers",{})}listModels(e){return this.daemon.request("list_provider_models",{provider:e})}listModes(e){return this.daemon.request("list_provider_modes",{provider:e})}resolveDefaultModel(e,n){return this.daemon.request("resolve_default_model",{provider:e,...n?{cwd:n}:{}})}refreshSnapshot(){return this.daemon.request("providers.snapshot.refresh.request",{})}}const Ct=32*1024;function Zr(t){const e=t.reduce((o,r)=>o+r.length,0),n=new Uint8Array(e);let s=0;for(const o of t)n.set(o,s),s+=o.length;return n}class ea{constructor(e){I(this,"pending",new Map);I(this,"nextStream",1);I(this,"detach",null);this.daemon=e}start(){this.detach||(this.detach=this.daemon.onFileTransferFrame(e=>this.dispatch(e)))}stop(){var e;(e=this.detach)==null||e.call(this),this.detach=null;for(const[n,s]of this.pending)s.reject(new Error("file transfer router stopped")),this.pending.delete(n)}async download(e){const n=await this.daemon.request("file_download_token_request",{path:e});if(!n.ok||!n.token)throw new Error(n.error??"failed to issue download token");const s=this.nextStream++,o=new Promise((a,c)=>{this.pending.set(s,{chunks:[],meta:{},resolve:a,reject:c})}),r=await this.daemon.request("file_download_request",{token:n.token,stream:s});if(!r.ok)throw this.pending.delete(s),new Error(r.error??"download request failed");return o}async upload(e,n){const s=lt(),o=await this.daemon.request("file_upload_request",{path:e,transferId:s});if(!o.ok||o.stream===void 0)throw new Error(o.error??"upload request failed");const r=o.stream;this.daemon.sendBinary(et({opcode:"Begin",stream:r,meta:{transferId:s}}));for(let a=0;a<n.length;a+=Ct){const c=n.subarray(a,a+Ct);this.daemon.sendBinary(et({opcode:"Chunk",stream:r,data:c}))}this.daemon.sendBinary(et({opcode:"End",stream:r,ok:!0}))}dispatch(e){const n=this.pending.get(e.stream);if(n)switch(e.opcode){case"Begin":n.meta.fileName=e.meta.fileName,n.meta.mimeType=e.meta.mimeType;return;case"Chunk":n.chunks.push(e.data);return;case"End":this.pending.delete(e.stream),e.ok?n.resolve({bytes:Zr(n.chunks),...n.meta}):n.reject(new Error("download failed"));return;case"Error":this.pending.delete(e.stream),n.reject(new Error(e.message));return}}}class ta{constructor(e,n={}){I(this,"initialDelayMs");I(this,"maxDelayMs");I(this,"factor");I(this,"jitter");I(this,"maxAttempts");I(this,"setTimer");I(this,"clearTimer");I(this,"random");I(this,"attempt",0);I(this,"timer",null);I(this,"active",!1);I(this,"detachState",null);I(this,"reconnectedHandlers",new Set);I(this,"failedHandlers",new Set);this.daemon=e,this.initialDelayMs=n.initialDelayMs??500,this.maxDelayMs=n.maxDelayMs??3e4,this.factor=n.factor??2,this.jitter=n.jitter??.2,this.maxAttempts=n.maxAttempts??Number.POSITIVE_INFINITY,this.setTimer=n.setTimer??((s,o)=>setTimeout(s,o)),this.clearTimer=n.clearTimer??(s=>clearTimeout(s)),this.random=n.random??Math.random}delayForAttempt(e){const n=Math.min(this.maxDelayMs,this.initialDelayMs*this.factor**(e-1)),s=n*this.jitter*(this.random()*2-1);return Math.max(0,Math.round(n+s))}onReconnected(e){return this.reconnectedHandlers.add(e),()=>this.reconnectedHandlers.delete(e)}onReconnectFailed(e){return this.failedHandlers.add(e),()=>this.failedHandlers.delete(e)}start(){this.active||(this.active=!0,this.detachState=this.daemon.onStateChange(e=>{e==="closed"&&this.active&&this.scheduleReconnect(),e==="open"&&(this.attempt=0)}))}stop(){var e;this.active=!1,this.timer&&this.clearTimer(this.timer),this.timer=null,(e=this.detachState)==null||e.call(this),this.detachState=null}get attemptCount(){return this.attempt}scheduleReconnect(){if(!this.active||this.attempt>=this.maxAttempts)return;this.attempt+=1;const e=this.delayForAttempt(this.attempt);this.timer=this.setTimer(()=>{this.timer=null,this.tryReconnect()},e)}async tryReconnect(){if(!this.active)return;const e=this.attempt;try{await this.daemon.connect();for(const n of this.reconnectedHandlers)n({attempt:e,serverId:this.daemon.serverId})}catch(n){for(const s of this.failedHandlers)s(n,e);this.scheduleReconnect()}}}function Tt(t){const e=t.trim();if(e==="")return e;const n=e.match(/^([a-z][a-z0-9+.-]*):\/\//i);if(!n)return`ws://${e.replace(/\/+$/,"")}`;const s=n[1].toLowerCase(),o=e.slice(n[0].length).replace(/\/+$/,"");switch(s){case"http":return`ws://${o}`;case"https":return`wss://${o}`;case"ws":case"wss":return`${s}://${o}`;default:return e}}function na(t){const e=Lr(t);return e!=null&&e.relay?{mode:"relay",url:Hr(e.relay),daemonPublicKey:e.publicKey}:e!=null&&e.host?{mode:"direct",url:Tt(e.host)}:{mode:"direct",url:Tt(t)}}function sa(){return"web-"+Math.random().toString(36).slice(2,10)}const C=pe()((t,e)=>({status:"idle",serverInfo:null,error:null,daemon:null,client:null,reconnection:null,async connect(n){e().disconnect();const s=na(n.url);let o;s.mode==="relay"?o=Wr({daemonPublicKey:s.daemonPublicKey}):n.password&&(o=un(d=>new WebSocket(d,[`pi-studio.bearer.${n.password}`])));const r=new Gr({url:s.url,clientId:n.clientId??sa(),clientType:"browser",capabilities:{},transport:o,rpcTimeoutMs:1800*1e3}),a=new Vr(r),c=new ta(r);r.onStateChange(d=>t({status:d})),c.onReconnected(()=>t({error:null})),c.onReconnectFailed(d=>{t({error:d instanceof Error?d.message:String(d)})}),t({daemon:r,client:a,reconnection:c,error:null,status:"connecting"});try{const d=await r.connect();t({serverInfo:d}),c.start()}catch(d){throw t({error:d instanceof Error?d.message:String(d)}),d}},disconnect(){const{daemon:n,reconnection:s}=e();s==null||s.stop(),n==null||n.close(),t({status:"idle",serverInfo:null,daemon:null,client:null,reconnection:null})}})),oa=100,ra=480,aa=220,ia=280;function Pe(t){return Math.min(ra,Math.max(oa,t))}const k=pe()(t=>({host:"ws://127.0.0.1:6767",password:"",cwd:"~",cwdPickerOpen:!1,sessionMenu:null,fileMenu:null,rightSidebarTab:"files",collapsedWorkspaces:new Set,leftSidebarCollapsed:!1,rightSidebarCollapsed:!1,leftSidebarWidth:aa,rightSidebarWidth:ia,setHost:e=>t({host:e}),setPassword:e=>t({password:e}),setCwd:e=>t({cwd:e}),openCwdPicker:()=>t({cwdPickerOpen:!0}),closeCwdPicker:()=>t({cwdPickerOpen:!1}),openSessionMenu:(e,n,s)=>t({sessionMenu:{sessionId:e,x:n,y:s}}),closeSessionMenu:()=>t({sessionMenu:null}),openFileMenu:(e,n,s,o)=>t({fileMenu:{path:e,isDirectory:n,x:s,y:o}}),closeFileMenu:()=>t({fileMenu:null}),setRightSidebarTab:e=>t({rightSidebarTab:e}),toggleWorkspaceCollapsed:e=>t(n=>{const s=new Set(n.collapsedWorkspaces);return s.has(e)?s.delete(e):s.add(e),{collapsedWorkspaces:s}}),toggleLeftSidebar:()=>t(e=>({leftSidebarCollapsed:!e.leftSidebarCollapsed})),toggleRightSidebar:()=>t(e=>({rightSidebarCollapsed:!e.rightSidebarCollapsed})),setLeftSidebarWidth:e=>t({leftSidebarWidth:Pe(e)}),setRightSidebarWidth:e=>t({rightSidebarWidth:Pe(e)}),resizeLeftSidebar:e=>t(n=>({leftSidebarWidth:Pe(n.leftSidebarWidth+e)})),resizeRightSidebar:e=>t(n=>({rightSidebarWidth:Pe(n.rightSidebarWidth+e)}))})),ca="_wrap_emmus_1",la="_dot_emmus_8",da="_open_emmus_15",ua="_connecting_emmus_18",pa="_closed_emmus_21",fa="_idle_emmus_22",ha="_closing_emmus_23",tt={wrap:ca,dot:la,open:da,connecting:ua,closed:pa,idle:fa,closing:ha},ma={idle:"disconnected",connecting:"connecting…",open:"connected",closing:"disconnecting…",closed:"disconnected"};function ga(){const t=C(n=>n.status),e=C(n=>n.error);return i.jsxs("span",{className:tt.wrap,title:e??void 0,children:[i.jsx("span",{className:A(tt.dot,tt[t])}),ma[t]??t]})}const _a="_toolbar_i9hmh_1",ya="_brand_i9hmh_10",ba="_version_i9hmh_16",wa="_sep_i9hmh_22",Sa="_host_i9hmh_28",xa="_password_i9hmh_31",va="_sidebarToggles_i9hmh_34",le={toolbar:_a,brand:ya,version:ba,sep:wa,host:Sa,password:xa,sidebarToggles:va};function ka(){const t=C(h=>h.status),e=C(h=>h.connect),n=C(h=>h.disconnect),s=k(h=>h.host),o=k(h=>h.setHost),r=k(h=>h.password),a=k(h=>h.setPassword),c=k(h=>h.leftSidebarCollapsed),d=k(h=>h.toggleLeftSidebar),f=k(h=>h.rightSidebarCollapsed),g=k(h=>h.toggleRightSidebar),b=t==="open"||t==="connecting";return i.jsxs("div",{className:le.toolbar,children:[i.jsx("span",{className:le.brand,children:"Pi-Studio"}),i.jsxs("span",{className:le.version,children:["v","0.0.39"]}),i.jsx(ga,{}),i.jsx("div",{className:le.sep}),i.jsx(Le,{className:le.host,value:s,onChange:h=>o(h.target.value),placeholder:"host:port, ws://…/http://…, or a pasted pairing link",disabled:b}),i.jsx(Le,{className:le.password,type:"password",value:r,onChange:h=>a(h.target.value),placeholder:"password",disabled:b}),t==="open"||t==="connecting"||t==="closing"?i.jsx(F,{size:"sm",onClick:()=>n(),children:"Disconnect"}):i.jsx(F,{size:"sm",variant:"default",onClick:()=>void e({url:s,password:r||void 0}),children:"Connect"}),i.jsxs("div",{className:le.sidebarToggles,children:[i.jsx(F,{size:"sm",variant:"ghost",iconOnly:!0,title:c?"Show sessions sidebar":"Hide sessions sidebar",onClick:()=>d(),children:c?i.jsx(An,{size:16}):i.jsx(Dn,{size:16})}),i.jsx(F,{size:"sm",variant:"ghost",iconOnly:!0,title:f?"Show files/changes sidebar":"Hide files/changes sidebar",onClick:()=>g(),children:f?i.jsx(Fn,{size:16}):i.jsx(On,{size:16})})]})]})}const dt={rows:[],streamingAssistantIndex:null,streamingReasoningIndex:null,toolIndexByCallId:{}};let Nt=0;function re(){return Nt+=1,`row-${Nt}`}function Ia(t){switch(t.kind){case"shell":return t.command??"";case"read":case"write":return t.path??"";case"edit":return t.path??"";case"search":return t.query??"";case"fetch":return t.url??"";case"task":return t.description??"";default:return""}}function ja(t,e){return t??`${e.kind}:${Ia(e)}`}function Ca(t){return{...t,streamingAssistantIndex:null,streamingReasoningIndex:null}}function Ta(t,e){var r;const n=t.rows.slice();let s=t.streamingAssistantIndex;if(s===null||((r=n[s])==null?void 0:r.kind)!=="assistant"){const a={kind:"assistant",id:re(),text:"",streaming:!0};n.push(a),s=n.length-1}const o=n[s];return!o||o.kind!=="assistant"?t:(n[s]={...o,text:o.text+e},{...t,rows:n,streamingAssistantIndex:s,streamingReasoningIndex:null})}function Na(t,e){var r;const n=t.rows.slice();let s=t.streamingReasoningIndex;if(s===null||((r=n[s])==null?void 0:r.kind)!=="reasoning"){const a={kind:"reasoning",id:re(),text:"",streaming:!0};n.push(a),s=n.length-1}const o=n[s];return!o||o.kind!=="reasoning"?t:(n[s]={...o,text:o.text+e},{...t,rows:n,streamingReasoningIndex:s,streamingAssistantIndex:null})}function Ea(t,e){if(t.kind!==e.kind)return e;const n={...t};for(const[s,o]of Object.entries(e))o!==void 0&&o!==""&&(n[s]=o);return n}function Ra(t,e){var c;const n=ja(e.callId,e.tool),s=e.status==="completed"||e.status==="error"?e.status:"running",o=t.toolIndexByCallId[n],r=t.rows.slice();if(o!==void 0&&((c=r[o])==null?void 0:c.kind)==="tool"){const d=r[o];return d.kind!=="tool"?t:(r[o]={...d,tool:Ea(d.tool,e.tool),status:s},{...t,rows:r,streamingAssistantIndex:null,streamingReasoningIndex:null})}const a={kind:"tool",id:re(),callId:n,tool:e.tool,status:s};return r.push(a),{...t,rows:r,toolIndexByCallId:{...t.toolIndexByCallId,[n]:r.length-1},streamingAssistantIndex:null,streamingReasoningIndex:null}}function gt(t){const e=t.rows.slice();if(t.streamingAssistantIndex!==null){const n=e[t.streamingAssistantIndex];(n==null?void 0:n.kind)==="assistant"&&(e[t.streamingAssistantIndex]={...n,streaming:!1})}if(t.streamingReasoningIndex!==null){const n=e[t.streamingReasoningIndex];(n==null?void 0:n.kind)==="reasoning"&&(e[t.streamingReasoningIndex]={...n,streaming:!1})}return{...t,rows:e,streamingAssistantIndex:null,streamingReasoningIndex:null}}function qa(t,e){const n=gt(t),s={kind:"error",id:re(),text:e||"turn failed"};return{...n,rows:[...n.rows,s]}}function Ma(t){const e=gt(t),n={kind:"system",id:re(),text:"(canceled)"};return{...e,rows:[...e.rows,n]}}function Ba(t,e){const n={kind:"error",id:re(),text:e||"error"};return{...t,rows:[...t.rows,n]}}function $a(t,e,n,s){if(s!==void 0){const r=t.rows.findIndex(a=>a.kind==="user"&&a.pending&&a.clientMessageId===s);if(r!==-1){const a=t.rows.slice(),c=a[r];if((c==null?void 0:c.kind)==="user")return a[r]={...c,text:e,images:n,pending:!1},{...t,rows:a}}}const o={kind:"user",id:re(),text:e,images:n,clientMessageId:s};return{...t,rows:[...t.rows,o]}}function Aa(t,e){let n=!1;const s=t.rows.map(o=>o.kind!=="user"||!o.queued||e.includes(o.text)?o:(n=!0,{...o,queued:!1}));return n?{...t,rows:s}:t}function gn(t,e){switch(e.kind){case"turn_started":return Ca(t);case"user_message":return $a(t,e.text??"",e.images,e.messageId);case"assistant_message":return Ta(t,e.text??"");case"reasoning":return Na(t,e.text??"");case"tool_call":return Ra(t,e);case"turn_completed":return gt(t);case"turn_failed":return qa(t,e.error);case"turn_canceled":return Ma(t);case"error":return Ba(t,e.message);case"queue_update":return Aa(t,e.steering??[]);default:return t}}function Da(t,e,n,s,o){const r={kind:"user",id:re(),text:n,images:s,clientMessageId:e,pending:!0,queued:o};return{...t,rows:[...t.rows,r]}}function Fa(t,e){const n=t.rows.findIndex(r=>r.kind==="user"&&r.pending&&r.clientMessageId===e);if(n===-1)return t;const s=t.rows.slice(),o=s[n];return(o==null?void 0:o.kind)!=="user"?t:(s[n]={...o,pending:!1,failed:!0},{...t,rows:s})}let Et=0;function Oa(){return Et+=1,`s-${Date.now().toString(36)}-${Et}`}const T=pe()((t,e)=>({sessions:{},order:[],activeSessionId:null,createSession(n){const s=Oa(),o={id:s,agentId:null,title:"New chat",status:"idle",cwd:n,timeline:dt,userMessageCount:0};return t(r=>({sessions:{...r.sessions,[s]:o},order:[s,...r.order],activeSessionId:s})),s},hydrate(n){t(s=>s.sessions[n.id]?s:{sessions:{...s.sessions,[n.id]:n},order:[...s.order,n.id]})},bindAgent(n,s){t(o=>{const r=o.sessions[n];return r?{sessions:{...o.sessions,[n]:{...r,agentId:s}}}:o})},setStatus(n,s){t(o=>{const r=o.sessions[n];return r?{sessions:{...o.sessions,[n]:{...r,status:s}}}:o})},setStatusByAgentId(n,s){const o=e().findByAgentId(n);o&&e().setStatus(o.id,s)},setModel(n,s,o){t(r=>{const a=r.sessions[n];return a?{sessions:{...r.sessions,[n]:{...a,model:s,modelProvider:o}}}:r})},setModelByAgentId(n,s,o){const r=e().findByAgentId(n);r&&e().setModel(r.id,s,o)},setTitle(n,s){t(o=>{const r=o.sessions[n];return r?{sessions:{...o.sessions,[n]:{...r,title:s}}}:o})},setCwd(n,s){t(o=>{const r=o.sessions[n];return r?{sessions:{...o.sessions,[n]:{...r,cwd:s}}}:o})},applyStreamEvent(n,s){t(o=>{const r=o.sessions[n];if(!r)return o;const a=gn(r.timeline,s);let c=r.title;if(s.kind==="turn_completed"&&c==="New chat"){const d=a.rows.slice().reverse().find(f=>f.kind==="assistant");d&&d.kind==="assistant"&&d.text&&(c=d.text.slice(0,40)+(d.text.length>40?"…":""))}return{sessions:{...o.sessions,[n]:{...r,timeline:a,title:c}}}})},addOptimisticUserMessage(n,s,o,r,a){t(c=>{const d=c.sessions[n];if(!d)return c;const f=Da(d.timeline,s,o,r,a);return{sessions:{...c.sessions,[n]:{...d,timeline:f,userMessageCount:d.userMessageCount+1}}}})},markUserMessageFailed(n,s){t(o=>{const r=o.sessions[n];if(!r)return o;const a=Fa(r.timeline,s);return{sessions:{...o.sessions,[n]:{...r,timeline:a}}}})},activate(n){t({activeSessionId:n})},remove(n){t(s=>{const{[n]:o,...r}=s.sessions,a=s.order.filter(d=>d!==n),c=s.activeSessionId===n?a[0]??null:s.activeSessionId;return{sessions:r,order:a,activeSessionId:c}})},findByAgentId(n){return Object.values(e().sessions).find(s=>s.agentId===n)}})),Rt=new WeakMap;function Pa(t,e="pi"){const n=Rt.get(t);if(n)return n;const s=t.providers.resolveDefaultModel(e).then(o=>({model:o.model,modelProvider:o.modelProvider})).catch(()=>({}));return Rt.set(t,s),s}const We=new Map;function _n(t,e){const n=T.getState().sessions[e];if(!n)return Promise.reject(new Error(`unknown session: ${e}`));if(n.agentId)return Promise.resolve(n.agentId);const s=We.get(e);if(s)return s;const o=(async()=>{if(!n.model){const d=await Pa(t),f=T.getState().sessions[e];d.model&&f&&!f.model&&T.getState().setModel(e,d.model,d.modelProvider)}const r=T.getState().sessions[e];if(!r)throw new Error(`unknown session: ${e}`);const a={provider:"pi",cwd:r.cwd||"~"};r.model&&(a.model=r.model),r.modelProvider&&(a.modelProvider=r.modelProvider);const c=await t.createAgent({config:a,labels:{}});return T.getState().bindAgent(e,c.agentId),c.agentId})();return We.set(e,o),o.finally(()=>We.delete(e)),o}async function za(t,e){var o;const n=T.getState().sessions[e];if(!n||n.userMessageCount>0||n.timeline.rows.length>0)return!1;await((o=We.get(e))==null?void 0:o.catch(()=>{}));const s=T.getState().sessions[e];return s?(s.agentId&&t&&await t.agent(s.agentId).delete().catch(()=>{}),T.getState().remove(e),!0):!1}function nt(t,e){return t.filter(n=>n.workspaceCwd===e)}const E=pe()((t,e)=>({tabs:[],activeTabId:null,activeWorkspaceCwd:null,lastActiveTabByWorkspace:{},open(n){const s=e().tabs.find(o=>o.id===n.id);if(s){e().activate(s.id);return}t(o=>({tabs:[...o.tabs,n],activeTabId:n.id,activeWorkspaceCwd:n.workspaceCwd,lastActiveTabByWorkspace:{...o.lastActiveTabByWorkspace,[n.workspaceCwd]:n.id}}))},close(n){t(s=>{const o=s.tabs.find(f=>f.id===n);if(!o)return s;const r=s.tabs.findIndex(f=>f.id===n),a=s.tabs.filter(f=>f.id!==n);let c=s.activeTabId;const d={...s.lastActiveTabByWorkspace};if(c===n){const f=nt(a,o.workspaceCwd),g=Math.min(r,f.length-1),b=f[g];c=(b==null?void 0:b.id)??null}if(d[o.workspaceCwd]===n){const f=nt(a,o.workspaceCwd)[0];f?d[o.workspaceCwd]=f.id:delete d[o.workspaceCwd]}return{tabs:a,activeTabId:c,lastActiveTabByWorkspace:d}})},activate(n){t(s=>{const o=s.tabs.find(r=>r.id===n);return o?{activeTabId:n,activeWorkspaceCwd:o.workspaceCwd,lastActiveTabByWorkspace:{...s.lastActiveTabByWorkspace,[o.workspaceCwd]:n}}:s})},switchWorkspace(n){t(s=>{var d;const o=nt(s.tabs,n),r=s.lastActiveTabByWorkspace[n],c=r&&o.some(f=>f.id===r)?r:((d=o[0])==null?void 0:d.id)??null;return{activeWorkspaceCwd:n,activeTabId:c,lastActiveTabByWorkspace:c?{...s.lastActiveTabByWorkspace,[n]:c}:s.lastActiveTabByWorkspace}})},reorder(n,s){t(o=>{const r=o.tabs.findIndex(f=>f.id===n),a=o.tabs.findIndex(f=>f.id===s);if(r===-1||a===-1||r===a)return o;const c=o.tabs.slice(),[d]=c.splice(r,1);return d?(c.splice(a,0,d),{tabs:c}):o})},updateLabel(n,s){t(o=>({tabs:o.tabs.map(r=>r.id===n?{...r,label:s}:r)}))},updateData(n,s){t(o=>({tabs:o.tabs.map(r=>r.id===n?{...r,data:{...r.data,...s}}:r)}))}})),Q={chat:t=>`chat-${t}`,file:t=>`file-${t}`,diff:(t,e)=>`diff-${t}${e?"-staged":""}`,terminal:t=>`term-${t}`};let st=0;function yn(t){st+=1,E.getState().open({id:Q.terminal(`new-${st}`),kind:"terminal",label:`Terminal ${st}`,closable:!0,data:{slot:null,cwd:t},workspaceCwd:t})}function _t(t){const e=T.getState().createSession(t);E.getState().open({id:Q.chat(e),kind:"chat",label:"New chat",closable:!0,data:{sessionId:e},workspaceCwd:t});const n=C.getState().client;n&&_n(n,e).catch(()=>{})}function ut(t){const e=E.getState().tabs.find(s=>s.id===t);if(E.getState().close(t),(e==null?void 0:e.kind)!=="chat")return;const{sessionId:n}=e.data;za(C.getState().client,n)}const oe=pe()(t=>({rootPath:"",expanded:new Set,expandedByRoot:new Map,draft:null,setRoot:e=>t(n=>{const s=new Map(n.expandedByRoot);n.rootPath&&s.set(n.rootPath,n.expanded);const o=s.get(e),r=new Set(o);return r.add(e),{rootPath:e,expanded:r,expandedByRoot:s,draft:null}}),toggle:e=>t(n=>{if(e===n.rootPath)return n;const s=new Set(n.expanded);s.has(e)?s.delete(e):s.add(e);const o=new Map(n.expandedByRoot);return o.set(n.rootPath,s),{expanded:s,expandedByRoot:o}}),startDraft:(e,n)=>t(s=>{const o=new Set(s.expanded);o.add(e);const r=new Map(s.expandedByRoot);return s.rootPath&&r.set(s.rootPath,o),{draft:{parentPath:e,kind:n},expanded:o,expandedByRoot:r}}),cancelDraft:()=>t({draft:null})}));let me=null;const pt=new Set;function Ha(t){return pt.add(t),()=>pt.delete(t)}async function Xe(t){var e;if(me)return me;try{const n=await t.connection.request("file_explorer_request",{path:"/home"}),o=(((e=n.result)==null?void 0:e.entries)??n.entries??[]).find(r=>r.kind==="directory"||r.type==="directory");me="/home/"+((o==null?void 0:o.name)||"user")}catch{return"/tmp"}for(const n of pt)n(me);return me}function Wa(){return me}async function La(t,e){return e==="~"||e.startsWith("~/")?await Xe(t)+e.slice(1):e}function yt(){const t=C(o=>o.client),e=C(o=>o.status),[n,s]=v.useState(Wa());return v.useEffect(()=>Ha(s),[]),v.useEffect(()=>{!t||e!=="open"||n||Xe(t)},[t,e,n]),n}const Ua="_dot_202py_3",Ka={dot:Ua};function Ga(t){const{status:e,requiresAttention:n,attentionReason:s,showInactive:o}=t;if(!e)return null;if(n)switch(s){case"permission":return"statusWarning";case"error":return"statusDanger";case"finished":default:return"statusSuccess"}switch(e){case"running":case"queued":return"accent";case"waiting":return"statusWarning";case"finished":return"statusSuccess";case"error":return"statusDanger";case"idle":case"archived":return o?"foregroundMuted":null}}const qt=8,Va={accent:"var(--pi-color-accent)",statusSuccess:"var(--pi-color-statusSuccess)",statusDanger:"var(--pi-color-statusDanger)",statusWarning:"var(--pi-color-statusWarning)",foregroundMuted:"var(--pi-color-foregroundMuted)"};function Ja({className:t,...e}){const n=Ga(e);return n?i.jsx("span",{className:`${Ka.dot}${t?` ${t}`:""}`,style:{width:qt,height:qt,backgroundColor:Va[n]??"currentColor"},role:"presentation"}):null}const Ya={initializing:"queued",idle:"idle",running:"running",error:"error",closed:"finished"};function Xa(t){return Ya[t]??"idle"}const Qa="_wrap_1pbba_1",Za="_header_1pbba_7",ei="_list_1pbba_23",ti="_item_1pbba_28",ni="_active_1pbba_37",si="_title_1pbba_40",oi="_meta_1pbba_49",ri="_menuBtn_1pbba_57",ai="_workspaceGroup_1pbba_75",ii="_workspaceHeader_1pbba_78",ci="_workspaceChevron_1pbba_91",li="_workspaceIcon_1pbba_102",di="_workspaceLabel_1pbba_106",ui="_workspaceCount_1pbba_112",pi="_newSessionBtn_1pbba_117",fi="_workspaceSessions_1pbba_129",hi="_emptyState_1pbba_132",$={wrap:Qa,header:Za,list:ei,item:ti,active:ni,title:si,meta:oi,menuBtn:ri,workspaceGroup:ai,workspaceHeader:ii,workspaceChevron:ci,workspaceIcon:li,workspaceLabel:di,workspaceCount:ui,newSessionBtn:pi,workspaceSessions:fi,emptyState:hi};function mi({session:t,active:e,onSelect:n,onOpenMenu:s}){return i.jsxs("div",{className:A($.item,e&&$.active),onClick:n,onContextMenu:o=>{o.preventDefault(),s(o.clientX,o.clientY)},children:[i.jsxs("div",{className:$.title,children:[i.jsx(Ja,{status:Xa(t.status),showInactive:!0}),i.jsx("span",{children:t.title})]}),i.jsxs("div",{className:$.meta,children:[t.cwd||"~"," · ",t.agentId?t.agentId.slice(0,8):"new"," ·"," ",t.userMessageCount," msgs"]}),i.jsx("button",{type:"button",className:$.menuBtn,title:"Actions",onClick:o=>{o.stopPropagation();const r=o.currentTarget.getBoundingClientRect();s(r.left,r.bottom)},children:i.jsx(zt,{size:14})})]})}const gi="_trigger_16o4s_1",_i="_content_16o4s_7",yi="_item_16o4s_16",bi="_danger_16o4s_33",wi="_sep_16o4s_36",Z={trigger:gi,content:_i,item:yi,danger:bi,sep:wi};function Si(){const t=k(m=>m.sessionMenu),e=k(m=>m.closeSessionMenu),n=C(m=>m.client),s=v.useRef(null),[o,r]=v.useState(!1);v.useEffect(()=>{r(t!==null)},[t]);const a=T(m=>t?m.sessions[t.sessionId]:void 0);if(!t)return null;const c=!!(a!=null&&a.agentId)&&(a==null?void 0:a.status)==="running";function d(m){r(m),m||e()}function f(){if(!a)return;const m=window.prompt("Rename:",a.title);if(m!=null&&m.trim()){const _=m.trim();T.getState().setTitle(a.id,_),E.getState().updateLabel(Q.chat(a.id),_),a.agentId&&(n==null||n.agent(a.agentId).update({title:_}).catch(()=>{}))}e()}function g(){a!=null&&a.agentId&&(n==null||n.agent(a.agentId).interrupt().catch(()=>{})),e()}function b(m){T.getState().remove(m),E.getState().close(Q.chat(m))}async function h(){if(a){if(!window.confirm("Archive this agent? It can be resumed later."))return e();if(e(),!a.agentId){b(a.id);return}if(!n){window.alert("Not connected — cannot archive remotely.");return}try{await n.agent(a.agentId).archive(),b(a.id)}catch(m){window.alert(`Failed to archive: ${m instanceof Error?m.message:String(m)}`)}}}async function S(){if(a){if(!window.confirm("Permanently delete this agent? This cannot be undone."))return e();if(e(),!a.agentId){b(a.id);return}if(!n){window.alert("Not connected — cannot delete remotely.");return}try{await n.agent(a.agentId).delete(),b(a.id)}catch(m){window.alert(`Failed to delete: ${m instanceof Error?m.message:String(m)}`)}}}return i.jsxs(Ke,{open:o,onOpenChange:d,modal:!1,children:[i.jsx(Ge,{asChild:!0,children:i.jsx("button",{ref:s,type:"button",className:Z.trigger,style:{left:t.x,top:t.y},"aria-hidden":!0,tabIndex:-1})}),i.jsx(Ve,{children:i.jsxs(Je,{className:Z.content,align:"start",sideOffset:2,children:[i.jsx(G,{className:Z.item,onSelect:f,children:"Rename"}),i.jsx(G,{className:Z.item,disabled:!c,onSelect:g,children:"Stop agent"}),i.jsx(rt,{className:Z.sep}),i.jsx(G,{className:`${Z.item} ${Z.danger}`,onSelect:h,children:"Archive"}),i.jsx(G,{className:`${Z.item} ${Z.danger}`,onSelect:S,children:"Delete permanently"})]})})]})}function xi({label:t,cwd:e,sessionCount:n,collapsed:s,onToggleCollapsed:o,onNewSession:r}){return i.jsxs("div",{className:$.workspaceHeader,onClick:o,title:e,children:[i.jsx("button",{type:"button",className:$.workspaceChevron,"aria-label":s?"Expand workspace":"Collapse workspace",onClick:a=>{a.stopPropagation(),o()},children:s?i.jsx(ft,{size:13}):i.jsx(Ht,{size:13})}),i.jsx(Pn,{size:13,className:A($.workspaceIcon)}),i.jsx("span",{className:$.workspaceLabel,children:t}),i.jsx("span",{className:$.workspaceCount,children:n}),i.jsx(F,{size:"xs",variant:"ghost",iconOnly:!0,title:"New conversation",className:$.newSessionBtn,onClick:a=>{a.stopPropagation(),r()},children:i.jsx(Wt,{size:13})})]})}function ye(t,e){return e&&(t==="~"||t.startsWith("~/"))?e+t.slice(1):t}function bn(t,e,n){const s=new Map;for(const o of t){const r=e[o];if(!r)continue;const a=ye(r.cwd||"~",n),c=s.get(a);c?c.push(r):s.set(a,[r])}return Array.from(s,([o,r])=>({cwd:o,sessions:r}))}function vi(t){return!t||t==="~"?"~":t.split("/").filter(Boolean).pop()||t}function ki(){const t=T(_=>_.order),e=T(_=>_.sessions),n=T(_=>_.activeSessionId),s=T(_=>_.activate),o=E(_=>_.open),r=C(_=>_.status),a=k(_=>_.openSessionMenu),c=k(_=>_.setCwd),d=k(_=>_.openCwdPicker),f=k(_=>_.collapsedWorkspaces),g=k(_=>_.toggleWorkspaceCollapsed),b=yt();function h(_){const y=ye(_||"~",b);_t(y)}function S(_){s(_);const y=e[_],M=ye((y==null?void 0:y.cwd)||"~",b);y!=null&&y.cwd&&c(y.cwd),o({id:Q.chat(_),kind:"chat",label:(y==null?void 0:y.title)??"Chat",closable:!0,data:{sessionId:_},workspaceCwd:M})}const m=bn(t,e,b);return i.jsxs("div",{className:$.wrap,children:[i.jsxs("div",{className:$.header,children:[i.jsx("h3",{children:"Workspaces"}),i.jsx(F,{size:"xs",variant:"ghost",iconOnly:!0,title:r!=="open"?"Connect to open a workspace":"Open a workspace folder",disabled:r!=="open",onClick:()=>d(),children:i.jsx(Lt,{size:14})})]}),i.jsxs("div",{className:$.list,children:[m.length===0&&i.jsx("div",{className:$.emptyState,children:r!=="open"?"Not connected":"No workspaces — open a folder to start"}),m.map(_=>{const y=f.has(_.cwd);return i.jsxs("div",{className:$.workspaceGroup,children:[i.jsx(xi,{label:vi(_.cwd),cwd:_.cwd,sessionCount:_.sessions.length,collapsed:y,onToggleCollapsed:()=>g(_.cwd),onNewSession:()=>h(_.cwd)}),!y&&i.jsx("div",{className:$.workspaceSessions,children:_.sessions.map(M=>i.jsx(mi,{session:M,active:M.id===n,onSelect:()=>S(M.id),onOpenMenu:(V,j)=>a(M.id,V,j)},M.id))})]},_.cwd)})]}),i.jsx(Si,{})]})}const Ii="_strip_8jveh_1",ji="_tab_8jveh_10",Ci="_active_8jveh_26",Ti="_icon_8jveh_30",Ni="_label_8jveh_35",Ei="_close_8jveh_40",Ri="_newTab_8jveh_50",qi="_content_8jveh_73",Mi="_item_8jveh_82",Bi="_itemIcon_8jveh_96",H={strip:Ii,tab:ji,active:Ci,icon:Ti,label:Ni,close:Ei,newTab:Ri,content:qi,item:Mi,itemIcon:Bi},$i={chat:Kt,file:Hn,diff:zn,terminal:Ut};function Ai({tab:t}){const e=E(g=>g.activeTabId),n=E(g=>g.activate),s=$i[t.kind],{attributes:o,listeners:r,setNodeRef:a,transform:c,transition:d,isDragging:f}=ls({id:t.id});return i.jsxs("div",{ref:a,className:A(H.tab,t.id===e&&H.active),style:{transform:ds.Transform.toString(c),transition:d,opacity:f?.5:1},onClick:()=>n(t.id),onAuxClick:g=>{g.button===1&&t.closable&&ut(t.id)},title:t.label,...o,...r,children:[i.jsx("span",{className:H.icon,children:i.jsx(s,{size:13})}),i.jsx("span",{className:H.label,children:t.label}),t.closable&&i.jsx("span",{className:H.close,onClick:g=>{g.stopPropagation(),ut(t.id)},children:i.jsx(ot,{size:12})})]})}function Di({workspaceCwd:t}){const e=t??"~";return i.jsxs(Ke,{children:[i.jsx(Ge,{asChild:!0,children:i.jsx("button",{type:"button",className:H.newTab,title:"New tab",disabled:!t,children:i.jsx(Wt,{size:14})})}),i.jsx(Ve,{children:i.jsxs(Je,{className:H.content,align:"start",sideOffset:4,children:[i.jsxs(G,{className:H.item,onSelect:()=>_t(e),children:[i.jsx(Kt,{size:13,className:H.itemIcon}),"New chat"]}),i.jsxs(G,{className:H.item,onSelect:()=>yn(e),children:[i.jsx(Ut,{size:13,className:H.itemIcon}),"New terminal"]})]})})]})}function Fi(){const t=E(a=>a.tabs),e=E(a=>a.activeWorkspaceCwd),n=E(a=>a.reorder),s=t.filter(a=>a.workspaceCwd===e),o=ns(ss(cs,{activationConstraint:{distance:4}}));function r(a){const{active:c,over:d}=a;!d||c.id===d.id||n(String(c.id),String(d.id))}return i.jsxs("div",{className:H.strip,children:[i.jsx(os,{sensors:o,collisionDetection:rs,onDragEnd:r,children:i.jsx(as,{items:s.map(a=>a.id),strategy:is,children:s.map(a=>i.jsx(Ai,{tab:a},a.id))})}),i.jsx(Di,{workspaceCwd:e})]})}const Oi="_spinner_1tgzp_3",Pi={spinner:Oi},zi={xs:12,sm:16,md:20,lg:24},Hi={xs:1,sm:2,md:2,lg:3};function wn({size:t="md",color:e="currentColor",className:n,"aria-label":s="Loading"}){const o=typeof t=="number"?t:zi[t],r=typeof t=="number"?2:Hi[t];return i.jsx("span",{className:`${Pi.spinner}${n?` ${n}`:""}`,role:"status","aria-label":s,style:{width:o,height:o,borderWidth:r,color:e}})}const Wi=v.lazy(()=>ht(()=>import("./ChatPanel-BqI2xnxv.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])).then(t=>({default:t.ChatPanel}))),Mt=v.lazy(()=>ht(()=>import("./FilePanel-BBfL4iba.js").then(t=>t.F),__vite__mapDeps([14,1,7,6,5,2,9,10,15])).then(t=>({default:t.FilePanel}))),Li=v.lazy(()=>ht(()=>import("./TerminalPanel-DyLLAPYP.js"),__vite__mapDeps([16,1,17,18,7,6,5,2,3,11,12,19])).then(t=>({default:t.TerminalPanel}))),Ui={chat:Wi,file:Mt,diff:Mt,terminal:Li},Ki="_area_z7u01_1",Gi="_panel_z7u01_7",Vi="_active_z7u01_14",Ji="_empty_z7u01_17",Yi="_emptyStack_z7u01_25",Xi="_emptyTitle_z7u01_35",Qi="_emptyHint_z7u01_39",ee={area:Ki,panel:Gi,active:Vi,empty:Ji,emptyStack:Yi,emptyTitle:Xi,emptyHint:Qi};function Zi(){const t=E(a=>a.tabs),e=E(a=>a.activeTabId),n=E(a=>a.activeWorkspaceCwd),s=C(a=>a.status),o=k(a=>a.openCwdPicker),r=t.some(a=>a.workspaceCwd===n);return n===null?i.jsx("div",{className:ee.area,children:i.jsxs("div",{className:ee.emptyStack,children:[i.jsx("div",{className:ee.emptyTitle,children:"No workspace open"}),i.jsx("div",{className:ee.emptyHint,children:"Open a project folder to start a chat."}),i.jsx(F,{size:"sm",variant:"secondary",leftIcon:i.jsx(Lt,{size:14}),disabled:s!=="open",title:s!=="open"?"Connect to open a workspace":"Open a workspace folder",onClick:()=>o(),children:"Open Workspace"})]})}):r?i.jsx("div",{className:ee.area,children:t.map(a=>{const c=Ui[a.kind];return i.jsx("div",{className:A(ee.panel,a.id===e&&ee.active),children:i.jsx(v.Suspense,{fallback:i.jsx(wn,{size:"md"}),children:i.jsx(c,{tab:a})})},a.id)})}):i.jsx("div",{className:ee.area,children:i.jsx("div",{className:ee.empty,children:"No open tabs in this workspace"})})}const Me={fileRead:t=>["file","read",t],fileDownload:t=>["file","download",t],fileDiff:(t,e,n)=>["file","diff",t,e,n],explorer:t=>["explorer",t],agentList:()=>["agents","list"],providerModels:t=>["providers","models",t],agentTimeline:t=>["agents","timeline",t]};function ec(t){const e=t.kind==="directory"||t.type==="directory"?"directory":"file";return{name:t.name??"",kind:e,size:t.size,mtimeMs:t.mtimeMs}}function tc(t){return t.slice().sort((e,n)=>e.kind!==n.kind?e.kind==="directory"?-1:1:e.name.localeCompare(n.name))}async function Sn(t,e){const s=(await t.connection.request("file_explorer_request",{path:e})).result;if(!s||s.ok===!1)throw new Error(s&&"error"in s?s.error:"explorer request failed");const o="entries"in s?s.entries??[]:[];return{path:s.resolvedPath??e,entries:tc(o.map(ec))}}function nc(t,e=!0){const n=C(s=>s.client);return Ot({queryKey:Me.explorer(t),queryFn:()=>{if(!n)throw new Error("not connected");return Sn(n,t)},enabled:!!n&&!!t&&e})}function sc(t){const e=C(o=>o.client),n=v.useMemo(()=>Array.from(t),[t]),s=Mn({queries:n.map(o=>({queryKey:Me.explorer(o),queryFn:()=>{if(!e)throw new Error("not connected");return Sn(e,o)},enabled:!!e&&!!o}))});return v.useMemo(()=>{const o=new Map;return n.forEach((r,a)=>{const c=s[a];o.set(r,{listing:c==null?void 0:c.data,isLoading:!!(c!=null&&c.isLoading),isError:!!(c!=null&&c.isError),error:c==null?void 0:c.error})}),o},[n,s])}const Bt=new WeakMap;function $t(t){let e=Bt.get(t);return e||(e=new ea(t),e.start(),Bt.set(t,e)),e}function oc(t,e,n){const s=new Blob([Uint8Array.from(t)],{type:n||"application/octet-stream"}),o=URL.createObjectURL(s),r=document.createElement("a");r.href=o,r.download=e,r.rel="noopener",document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(o),0)}function xn(){const t=C(o=>o.daemon),e=Re(),n=v.useCallback(async(o,r)=>{if(!t)throw new Error("not connected");const a=o?`${o}/${r.name}`:r.name,c=new Uint8Array(await r.arrayBuffer());await $t(t).upload(a,c),await e.invalidateQueries({queryKey:["explorer"]})},[t,e]),s=v.useCallback(async o=>{if(!t)throw new Error("not connected");const r=await $t(t).download(o);oc(r.bytes,r.fileName||o.split("/").pop()||"download",r.mimeType)},[t]);return{upload:n,saveToDisk:s}}function rc(t,e){return t.endsWith("/")?`${t}${e}`:`${t}/${e}`}function vn(t,e,n,s,o,r){var c;(r==null?void 0:r.parentPath)===e&&t.push({kind:"draft",path:`${e}::draft`,depth:n,draftKind:r.kind,parentPath:e});const a=o.get(e);if(!a||a.isLoading){t.push({kind:"loading",path:e,depth:n});return}if(a.isError){const d=a.error instanceof Error?a.error.message:"failed to load";t.push({kind:"error",path:e,depth:n,message:d});return}for(const d of((c=a.listing)==null?void 0:c.entries)??[])ac(t,e,d,n,s,o,r)}function ac(t,e,n,s,o,r,a){const c=rc(e,n.name);if(n.kind!=="directory"){t.push({kind:"file",path:c,name:n.name,depth:s});return}const d=o.has(c);t.push({kind:"directory",path:c,name:n.name,depth:s,expanded:d}),d&&vn(t,c,s+1,o,r,a)}function ic(t,e,n,s){if(!t)return[];const o=[];return vn(o,t,0,e,n,s),o}const cc="_container_1098n_1",lc="_header_1098n_7",dc="_uploadButton_1098n_14",uc="_hiddenInput_1098n_33",pc="_status_1098n_36",fc="_statusError_1098n_37",hc="_rowAction_1098n_50",mc="_item_1098n_65",gc="_dropOverlay_1098n_68",_c="_list_1098n_83",yc="_chevronSlot_1098n_102",bc="_chevron_1098n_102",wc="_chevronOpen_1098n_113",Sc="_icon_1098n_116",xc="_name_1098n_123",vc="_dirName_1098n_128",kc="_statusRow_1098n_134",Ic="_statusRowError_1098n_145",jc="_emptyState_1098n_148",Cc="_draftInput_1098n_154",N={container:cc,header:lc,uploadButton:dc,hiddenInput:uc,status:pc,statusError:fc,rowAction:hc,item:mc,dropOverlay:gc,list:_c,chevronSlot:yc,chevron:bc,chevronOpen:wc,icon:Sc,name:xc,dirName:vc,statusRow:kc,statusRowError:Ic,emptyState:jc,draftInput:Cc};function Tc({draftKind:t,indentStyle:e,onSubmit:n,onCancel:s}){const[o,r]=v.useState("");return i.jsxs("div",{className:N.item,style:e,onClick:a=>a.stopPropagation(),children:[i.jsx("span",{className:N.chevronSlot}),i.jsx("span",{className:N.icon,children:t==="directory"?i.jsx(Ee,{size:14}):i.jsx(Gt,{size:14})}),i.jsx("input",{className:N.draftInput,autoFocus:!0,spellCheck:!1,placeholder:t==="directory"?"New folder":"New file",value:o,onChange:a=>r(a.target.value),onKeyDown:a=>{if(a.key==="Enter"){a.preventDefault();const c=o.trim();c?n(c):s()}else a.key==="Escape"&&(a.preventDefault(),s())},onBlur:s})]})}const Nc=14;function Ec({row:t,onToggle:e,onOpenFile:n,onContextMenu:s,onSubmitDraft:o,onCancelDraft:r}){const a={paddingLeft:8+t.depth*Nc};if(t.kind==="loading")return i.jsx("div",{className:N.statusRow,style:a,children:"Loading…"});if(t.kind==="error")return i.jsx("div",{className:A(N.statusRow,N.statusRowError),style:a,children:t.message??"failed to load"});if(t.kind==="draft")return i.jsx(Tc,{draftKind:t.draftKind,indentStyle:a,onSubmit:d=>o(t.parentPath,d),onCancel:r});const c=t.kind==="directory";return i.jsxs("div",{className:N.item,style:a,onClick:()=>c?e(t.path):n(t.path),onContextMenu:d=>{d.preventDefault(),s(t.path,c,d.clientX,d.clientY)},children:[i.jsx("span",{className:N.chevronSlot,children:c&&i.jsx(ft,{size:12,className:A(N.chevron,t.expanded&&N.chevronOpen)})}),i.jsx("span",{className:N.icon,children:c?i.jsx(Ee,{size:14}):i.jsx(Gt,{size:14})}),i.jsx("span",{className:c?N.dirName:N.name,children:t.name}),i.jsx("button",{type:"button",className:N.rowAction,title:"Actions",onClick:d=>{d.stopPropagation();const f=d.currentTarget.getBoundingClientRect();s(t.path,c,f.left,f.bottom)},children:i.jsx(zt,{size:12})})]})}const Rc="_trigger_g81d7_1",qc="_content_g81d7_7",Mc="_item_g81d7_16",Bc="_danger_g81d7_29",$c="_sep_g81d7_32",te={trigger:Rc,content:qc,item:Mc,danger:Bc,sep:$c};function Ac(){const t=k(m=>m.fileMenu),e=k(m=>m.closeFileMenu),n=C(m=>m.client),s=oe(m=>m.startDraft),{saveToDisk:o}=xn(),r=Re(),a=v.useRef(null),[c,d]=v.useState(!1);if(v.useEffect(()=>{d(t!==null)},[t]),!t)return null;const f=t.path.split("/").pop()||t.path;function g(m){d(m),m||e()}async function b(){if(t){e();try{await o(t.path)}catch(m){window.alert(`Failed to download: ${m instanceof Error?m.message:String(m)}`)}}}async function h(){if(!t)return;const m=t.isDirectory?"folder (and everything inside it)":"file";if(!window.confirm(`Permanently delete this ${m}? "${f}" — this cannot be undone.`))return e();if(e(),!n){window.alert("Not connected — cannot delete remotely.");return}try{const _=await n.connection.request("file_delete_request",{path:t.path});if(!_.ok)throw new Error(_.error??"delete failed");await r.invalidateQueries({queryKey:["explorer"]})}catch(_){window.alert(`Failed to delete: ${_ instanceof Error?_.message:String(_)}`)}}function S(m){if(!t)return;const _=t.isDirectory?t.path:t.path.split("/").slice(0,-1).join("/")||"/";e(),s(_,m)}return i.jsxs(Ke,{open:c,onOpenChange:g,modal:!1,children:[i.jsx(Ge,{asChild:!0,children:i.jsx("button",{ref:a,type:"button",className:te.trigger,style:{left:t.x,top:t.y},"aria-hidden":!0,tabIndex:-1})}),i.jsx(Ve,{children:i.jsxs(Je,{className:te.content,align:"start",sideOffset:2,children:[i.jsx(G,{className:te.item,onSelect:()=>S("file"),children:"New File"}),i.jsx(G,{className:te.item,onSelect:()=>S("directory"),children:"New Folder"}),i.jsx(rt,{className:te.sep}),!t.isDirectory&&i.jsx(G,{className:te.item,onSelect:b,children:"Download"}),i.jsx(rt,{className:te.sep}),i.jsx(G,{className:`${te.item} ${te.danger}`,onSelect:h,children:"Delete"})]})})]})}const Dc={empty_path:"Choose a folder first.",invalid_name:'Invalid name — cannot be empty or contain "/".',exists:"An item with that name already exists here.",not_found:"That folder no longer exists.",not_a_directory:"That path is not a folder.",unreadable:"That folder is not readable."};async function kn(t,e,n,s){const o=await t.connection.request("file_create_request",{path:e,name:n,kind:s});if(!o.ok){const r=o.error??"";throw new Error(Dc[r]??r??"Failed to create")}return o.path??(e.endsWith("/")?`${e}${n}`:`${e}/${n}`)}const Fc=24;function Oc(){const t=C(p=>p.client),e=oe(p=>p.rootPath),n=oe(p=>p.expanded),s=oe(p=>p.setRoot),o=oe(p=>p.toggle),r=oe(p=>p.draft),a=oe(p=>p.startDraft),c=oe(p=>p.cancelDraft),d=E(p=>p.activeWorkspaceCwd),f=E(p=>p.open),{upload:g}=xn(),b=k(p=>p.openFileMenu),h=Re(),[S,m]=v.useState(null),[_,y]=v.useState(!1),[M,V]=v.useState(null),j=v.useRef(null),Be=v.useRef(null),be=v.useRef(null);v.useEffect(()=>{if(!t)return;const p=d||"~";be.current!==p&&(be.current=p,La(t,p).then(R=>s(R)))},[t,d,s]);const fe=sc(n),ae=v.useMemo(()=>ic(e,n,fe,r),[e,n,fe,r]),ie=Bn({count:ae.length,getScrollElement:()=>Be.current,estimateSize:()=>Fc,overscan:12,getItemKey:p=>{var R;return((R=ae[p])==null?void 0:R.path)??p}});function ce(p){f({id:Q.file(p),kind:"file",label:p.split("/").pop()||p,closable:!0,data:{path:p},workspaceCwd:d||"~"})}async function Qe(p,R){const P=(r==null?void 0:r.kind)??"file";if(c(),!!t)try{const W=await kn(t,p,R,P);await h.invalidateQueries({queryKey:Me.explorer(p)}),m({text:`Created ${W}`,error:!1}),P==="file"&&ce(W)}catch(W){m({text:W instanceof Error?W.message:"Failed to create",error:!0})}}async function we(p,R){var Ae;if(!R.length||!p)return;const P=(Ae=fe.get(p))==null?void 0:Ae.listing,W=new Set((P==null?void 0:P.entries.map(J=>J.name))??[]),Se=R.filter(J=>W.has(J.name));if(Se.length>0){const J=Se.map(Cn=>Cn.name).join(", ");if(!window.confirm(`Overwrite ${Se.length>1?"these files":"this file"}? ${J}`))return}m({text:`Uploading ${R.length} file${R.length>1?"s":""}…`,error:!1});try{for(const J of R)await g(p,J);m({text:`Uploaded ${R.length} file${R.length>1?"s":""}`,error:!1})}catch(J){m({text:`Upload failed: ${J instanceof Error?J.message:"unknown"}`,error:!0})}}function $e(p){p.preventDefault(),y(!1);const R=M??e;V(null);const P=Array.from(p.dataTransfer.files);we(R,P)}function Ze(p){p.dataTransfer.types.includes("Files")&&(p.preventDefault(),y(!0))}return t?i.jsxs("div",{className:N.container,onDragOver:Ze,onDragLeave:()=>y(!1),onDrop:$e,children:[i.jsxs("div",{className:N.header,children:[i.jsx("button",{type:"button",className:N.uploadButton,onClick:()=>a(e,"file"),disabled:!e,title:"New file in workspace root",children:i.jsx(Wn,{size:12})}),i.jsx("button",{type:"button",className:N.uploadButton,onClick:()=>a(e,"directory"),disabled:!e,title:"New folder in workspace root",children:i.jsx(Vt,{size:12})}),i.jsxs("button",{type:"button",className:N.uploadButton,onClick:()=>{var p;return(p=j.current)==null?void 0:p.click()},disabled:!e,title:"Upload files to the workspace root",children:[i.jsx(Ln,{size:12}),i.jsx("span",{children:"Upload"})]}),i.jsx("input",{ref:j,type:"file",multiple:!0,className:N.hiddenInput,onChange:p=>{we(e,Array.from(p.target.files??[])),p.target.value=""}})]}),S&&i.jsx("div",{className:S.error?N.statusError:N.status,children:S.text}),i.jsxs("div",{className:N.list,ref:Be,children:[ae.length===0&&i.jsx("div",{className:N.emptyState,children:"No files loaded"}),i.jsx("div",{style:{position:"relative",height:ie.getTotalSize()},children:ie.getVirtualItems().map(p=>{const R=ae[p.index];return R?i.jsx("div",{"data-index":p.index,style:{position:"absolute",top:0,left:0,width:"100%",height:p.size,transform:`translateY(${p.start}px)`},onDragEnter:()=>{R.kind==="directory"&&V(R.path)},children:i.jsx(Ec,{row:R,onToggle:o,onOpenFile:ce,onContextMenu:(P,W,Se,Ae)=>b(P,W,Se,Ae),onSubmitDraft:(P,W)=>void Qe(P,W),onCancelDraft:c})},p.key):null})})]}),_&&i.jsx("div",{className:N.dropOverlay,children:"Drop to upload"}),i.jsx(Ac,{})]}):i.jsx("div",{className:N.emptyState,children:"Connect to browse files"})}const At={available:!1,branch:null,upstream:null,ahead:0,behind:0,detached:!1,conflictCount:0},X=pe()(t=>({subscribedCwd:null,changes:[],...At,setSubscribedCwd:e=>t({subscribedCwd:e}),applyProjection:e=>{if(!e||!e.available){t({changes:[],...At});return}const n=[];for(const s of e.staged)n.push({path:s.path,status:s.indexStatus==="A"?"added":s.indexStatus==="D"?"deleted":"modified",staged:!0});for(const s of e.unstaged)n.push({path:s.path,status:s.worktreeStatus==="D"?"deleted":"modified",staged:!1});for(const s of e.untracked)n.push({path:s,status:"added",staged:!1});t({changes:n,available:!0,branch:e.branch,upstream:e.upstream,ahead:e.ahead,behind:e.behind,detached:e.detached,conflictCount:e.conflicted.length})}})),Pc="_list_1pgby_1",zc="_summary_1pgby_4",Hc="_item_1pgby_11",Wc="_badge_1pgby_23",Lc="_added_1pgby_30",Uc="_modified_1pgby_34",Kc="_deleted_1pgby_38",Gc="_name_1pgby_42",Vc="_emptyState_1pgby_47",de={list:Pc,summary:zc,item:Hc,badge:Wc,added:Lc,modified:Uc,deleted:Kc,name:Gc,emptyState:Vc},Jc={added:"A",modified:"M",deleted:"D"};function Yc(){const e=E(r=>r.activeWorkspaceCwd)||"~",n=X(r=>r.changes),s=E(r=>r.open);function o(r,a){s({id:Q.diff(r,a),kind:"diff",label:r.split("/").pop()||r,closable:!0,data:{path:r,staged:a},workspaceCwd:e})}return n.length===0?i.jsx("div",{className:de.emptyState,children:"No changes detected"}):i.jsxs("div",{className:de.list,children:[i.jsxs("div",{className:de.summary,children:[n.length," changed file",n.length===1?"":"s"]}),n.map((r,a)=>i.jsxs("div",{className:de.item,onClick:()=>o(r.path,r.staged),children:[i.jsx("span",{className:A(de.badge,de[r.status]),children:Jc[r.status]}),i.jsx("span",{className:de.name,children:r.path})]},`${r.path}-${r.staged}-${a}`))]})}const Xc="_wrap_r37ok_1",Qc="_tabBar_r37ok_7",Zc="_tabBtn_r37ok_13",el="_active_r37ok_26",tl="_refreshBtn_r37ok_30",nl="_content_r37ok_34",se={wrap:Xc,tabBar:Qc,tabBtn:Zc,active:el,refreshBtn:tl,content:nl};function sl(){const t=k(c=>c.rightSidebarTab),e=k(c=>c.setRightSidebarTab),s=E(c=>c.activeWorkspaceCwd)||"~",o=C(c=>c.client),r=Re();function a(){r.invalidateQueries({queryKey:["explorer"]}),o&&s&&o.connection.request("checkout_refresh_request",{cwd:s}).catch(()=>{})}return i.jsxs("div",{className:se.wrap,children:[i.jsxs("div",{className:se.tabBar,children:[i.jsx("button",{type:"button",className:A(se.tabBtn,t==="files"&&se.active),onClick:()=>e("files"),children:"Files"}),i.jsx("button",{type:"button",className:A(se.tabBtn,t==="changes"&&se.active),onClick:()=>e("changes"),children:"Changes"}),i.jsx(F,{size:"xs",variant:"ghost",iconOnly:!0,title:"Refresh",className:se.refreshBtn,onClick:a,children:i.jsx(Un,{size:13})})]}),i.jsx("div",{className:se.content,children:t==="files"?i.jsx(Oc,{}):i.jsx(Yc,{})})]})}const In=pe()(t=>({bySession:{},setStats(e,n){t(s=>({bySession:{...s.bySession,[e]:{...s.bySession[e],...n}}}))},clear(e){t(n=>{const{[e]:s,...o}=n.bySession;return{bySession:o}})}})),ol=12e3;function rl(t,e){return t==="running"&&e!=="running"}function Dt(t,e){var s,o,r,a,c,d;const n={};((s=e.contextUsage)==null?void 0:s.tokens)!=null&&(n.contextTokens=e.contextUsage.tokens),((o=e.contextUsage)==null?void 0:o.contextWindow)!==void 0&&(n.contextWindow=e.contextUsage.contextWindow),((r=e.contextUsage)==null?void 0:r.percent)!=null&&(n.contextPercent=e.contextUsage.percent),((a=e.tokens)==null?void 0:a.total)!==void 0&&(n.totalTokens=e.tokens.total),((c=e.tokens)==null?void 0:c.input)!==void 0&&(n.inputTokens=e.tokens.input),((d=e.tokens)==null?void 0:d.output)!==void 0&&(n.outputTokens=e.tokens.output),e.cost!==void 0&&(n.cost=e.cost),e.model!==void 0&&(n.model=e.model,T.getState().setModel(t,e.model)),In.getState().setStats(t,n)}function al(t){const e=C(c=>c.client),n=C(c=>c.status),s=T(c=>{var d;return t?((d=c.sessions[t])==null?void 0:d.agentId)??null:null}),o=T(c=>{var d;return t?(d=c.sessions[t])==null?void 0:d.status:void 0}),r=v.useRef(!1),a=v.useRef(void 0);v.useEffect(()=>{if(n!=="open"||!e||!t||!s)return;let c=!1;const d=async()=>{if(!r.current){r.current=!0;try{const g=await e.agent(s).sessionStats();c||Dt(t,g)}catch{}finally{r.current=!1}}};d();const f=setInterval(()=>void d(),ol);return()=>{c=!0,clearInterval(f)}},[n,e,t,s]),v.useEffect(()=>{const c=a.current;a.current=o,rl(c,o)&&(n!=="open"||!e||!t||!s||(r.current=!1,e.agent(s).sessionStats().then(d=>Dt(t,d)).catch(()=>{})))},[o,n,e,t,s])}function il(t){return typeof t=="object"&&t!==null&&"type"in t&&t.type==="checkout_status_update"&&"cwd"in t&&typeof t.cwd=="string"&&"projection"in t&&typeof t.projection=="object"&&t.projection!==null}function cl(t){const e=C(r=>r.client),n=X(r=>r.applyProjection),s=X(r=>r.setSubscribedCwd),o=v.useRef(e);return o.current=e,v.useEffect(()=>{if(!e||!t)return;let r=!1;e.connection.request("checkout_status_subscribe",{cwd:t}).catch(()=>{}),s(t);const a=e.connection.onSessionMessage(c=>{if(r)return;const d=c;il(d)&&d.cwd===t&&n(d.projection)});return e.connection.request("checkout_refresh_request",{cwd:t}).catch(()=>{}),()=>{r=!0,a(),e.connection.request("checkout_status_unsubscribe",{cwd:t}).catch(()=>{}),s(null)}},[e,t,n,s]),{refresh(){const r=o.current;!r||!t||r.connection.request("checkout_refresh_request",{cwd:t}).catch(()=>{})}}}const bt="--";function Ie(t){return t===void 0?bt:t<1e3?String(t):t<1e6?`${(t/1e3).toFixed(1)}k`:`${(t/1e6).toFixed(1)}M`}function ll(t){if(t==null)return bt;const e=t<=1?t*100:t;return`${Math.round(e)}%`}function dl(t){if(t===void 0)return bt;const e=t<1?4:2;return`$${t.toFixed(e)}`}function ul(t,e){return e?t===e?"~":t.startsWith(`${e}/`)?`~${t.slice(e.length)}`:t:t}function pl(t,e){const n=[];return t>0&&n.push(`↑${t}`),e>0&&n.push(`↓${e}`),n.join(" ")}function fl(t,e=!0){const n=C(s=>s.client);return Ot({queryKey:Me.providerModels(t),queryFn:async()=>{if(!n)throw new Error("not connected");return(await n.providers.listModels(t)).models},enabled:!!n&&!!t&&e})}function hl(t,e){if(e.trim()==="")return t;const n=e.toLowerCase();return t.filter(s=>s.label.toLowerCase().includes(n)||s.description!==void 0&&s.description.toLowerCase().includes(n))}function ml(t,e){if(!e)return t;const n=t.find(s=>s.id===e);return n?[n,...t.filter(s=>s.id!==e)]:t}function gl(t){const e=new Set;return t.filter(n=>e.has(n.id)?!1:(e.add(n.id),!0))}const _l="_content_17y31_4",yl="_search_17y31_17",bl="_list_17y31_35",wl="_item_17y31_40",Sl="_checkSlot_17y31_55",xl="_label_17y31_64",vl="_modelId_17y31_70",kl="_state_17y31_77",Il="_stateError_17y31_86",Y={content:_l,search:yl,list:bl,item:wl,checkSlot:Sl,label:xl,modelId:vl,state:kl,stateError:Il};function jl({currentModel:t,provider:e,onSelect:n,renderTrigger:s}){const[o,r]=v.useState(!1),[a,c]=v.useState(""),d=v.useRef(null),{data:f=[],isLoading:g,isError:b,error:h}=fl(e,o),S=gl(ml(f,t));v.useEffect(()=>{var j;o&&(c(""),(j=d.current)==null||j.focus())},[o]);const m=new Map(S.map(j=>[j.id,j.provider])),_=S.map(j=>({value:j.id,label:j.label??j.id,description:j.id})),y=hl(_,a),M=h instanceof Error?h.message:"Failed to load models";function V(j){j.stopPropagation(),j.key==="Escape"&&r(!1)}return i.jsxs(Ke,{open:o,onOpenChange:r,modal:!1,children:[i.jsx(Ge,{asChild:!0,children:s(t)}),i.jsx(Ve,{children:i.jsxs(Je,{className:Y.content,align:"start",sideOffset:4,children:[i.jsx("input",{ref:d,className:Y.search,placeholder:"Search models…",value:a,onChange:j=>c(j.target.value),onKeyDown:V}),g&&i.jsx("div",{className:Y.state,children:i.jsx(wn,{size:"sm"})}),!g&&b&&i.jsx("div",{className:Y.stateError,children:M}),!g&&!b&&y.length===0&&i.jsx("div",{className:Y.state,children:"No models found"}),!g&&!b&&y.length>0&&i.jsx("div",{className:Y.list,children:y.map(j=>i.jsxs(G,{className:Y.item,onSelect:()=>n(j.value,m.get(j.value)),children:[i.jsx("span",{className:Y.checkSlot,"aria-hidden":!0,children:j.value===t&&i.jsx(Jt,{size:14})}),i.jsx("span",{className:Y.label,children:j.label}),i.jsxs("span",{className:Y.modelId,children:["(",j.value,")"]})]},j.value))})]})})]})}const Cl="_statusBar_tm1j6_1",Tl="_segmentGroup_tm1j6_16",Nl="_chevron_tm1j6_20",El="_segment_tm1j6_16",Rl="_icon_tm1j6_33",ql="_modelSegment_tm1j6_39",Ml="_modelChevron_tm1j6_63",Bl="_text_tm1j6_74",U={statusBar:Cl,segmentGroup:Tl,chevron:Nl,segment:El,icon:Rl,modelSegment:ql,modelChevron:Ml,text:Bl};function $l(){const t=T(y=>y.activeSessionId),e=T(y=>t?y.sessions[t]:void 0),n=C(y=>y.client),s=T(y=>y.setModel),o=yt(),r=E(y=>y.activeWorkspaceCwd);cl(r||"");const a=X(y=>y.available),c=X(y=>y.branch),d=X(y=>y.ahead),f=X(y=>y.behind),g=X(y=>y.detached),b=X(y=>y.conflictCount),h=X(y=>y.changes.length),S=In(y=>t?y.bySession[t]:void 0);al(t);const m=[];if(e){const y=ul(e.cwd,o);m.push({key:"cwd",icon:i.jsx(Ee,{size:13}),text:y,title:e.cwd})}if(a){const y=pl(d,f),M=[g?"(detached)":c??"?"];y&&M.push(y),h>0&&M.push(`●${h}`),b>0&&M.push(`⚠${b}`),m.push({key:"branch",icon:i.jsx(Kn,{size:13}),text:M.join(" ")})}if(e){const y=`${ll(S==null?void 0:S.contextPercent)} (${Ie(S==null?void 0:S.contextTokens)}/${Ie(S==null?void 0:S.contextWindow)})`;m.push({key:"context",icon:i.jsx(Gn,{size:13}),text:y}),m.push({key:"tokens",icon:i.jsx(Vn,{size:13}),text:Ie(S==null?void 0:S.totalTokens),title:`in ${Ie(S==null?void 0:S.inputTokens)} / out ${Ie(S==null?void 0:S.outputTokens)}`}),m.push({key:"cost",icon:i.jsx(Jn,{size:13}),text:dl(S==null?void 0:S.cost)})}function _(y,M){t&&(s(t,y,M),!(!n||!M)&&(async()=>{const V=await _n(n,t);await n.agent(V).setModel(M,y)})().catch(()=>{}))}return i.jsxs("div",{className:U.statusBar,children:[e&&i.jsx("span",{className:U.segmentGroup,children:i.jsx(jl,{currentModel:e.model,provider:"pi",onSelect:_,renderTrigger:y=>i.jsxs("button",{type:"button",className:U.modelSegment,disabled:!n,title:y?`Model: ${y}`:"Select model",children:[i.jsx("span",{className:U.icon,children:i.jsx(Yn,{size:13})}),i.jsx("span",{className:U.text,children:y??"Model"}),i.jsx(Ht,{size:12,className:U.modelChevron,"aria-hidden":"true"})]})})}),m.map((y,M)=>i.jsxs("span",{className:U.segmentGroup,children:[(!!e||M>0)&&i.jsx(ft,{size:12,className:U.chevron,"aria-hidden":"true"}),i.jsxs("span",{className:U.segment,title:y.title,children:[i.jsx("span",{className:U.icon,children:y.icon}),i.jsx("span",{className:U.text,children:y.text})]})]},y.key))]})}const Al="_wrapper_131x2_3",Dl="_box_131x2_18",Fl="_checkmark_131x2_36",Ol="_nativeInput_131x2_41",ze={wrapper:Al,box:Dl,checkmark:Fl,nativeInput:Ol};v.forwardRef(function({label:e,checked:n=!1,disabled:s,className:o,onChange:r,...a},c){return i.jsxs("label",{className:ze.wrapper,"data-disabled":s||void 0,children:[i.jsx("input",{ref:c,type:"checkbox",className:ze.nativeInput,checked:n,disabled:s,onChange:r,...a}),i.jsx("span",{className:ze.box,"data-checked":n,"aria-hidden":!0,children:n&&i.jsx(Jt,{size:12,className:ze.checkmark})}),e&&i.jsx("span",{children:e})]})});const Pl="_select_vj45v_3",zl={select:Pl};v.forwardRef(function({options:e,placeholder:n,className:s,...o},r){return i.jsxs("select",{ref:r,className:A(zl.select,s),...o,children:[n&&i.jsx("option",{value:"",disabled:!0,children:n}),e.map(a=>i.jsx("option",{value:a.value,children:a.label},a.value))]})});const Hl="_overlay_1yaef_1",Wl="_contentWrapper_1yaef_7",Ll="_dialog_1yaef_16",Ul="_header_1yaef_28",Kl="_title_1yaef_36",Gl="_closeBtn_1yaef_43",Vl="_body_1yaef_57",Jl="_footer_1yaef_63",Yl="_bare_1yaef_72",Xl="_bareBody_1yaef_78",Ql="_bareCloseBtn_1yaef_82",Zl="_visuallyHidden_1yaef_101",z={overlay:Hl,contentWrapper:Wl,dialog:Ll,header:Ul,title:Kl,closeBtn:Gl,body:Vl,footer:Jl,bare:Yl,bareBody:Xl,bareCloseBtn:Ql,visuallyHidden:Zl},ed=at;function td({open:t,onOpenChange:e,title:n,children:s,footer:o,width:r,className:a,bare:c=!1}){return i.jsx(Qn,{open:t,onOpenChange:e,children:i.jsxs(Zn,{children:[i.jsx(es,{className:z.overlay}),i.jsx("div",{className:z.contentWrapper,children:i.jsxs(ts,{className:A(z.dialog,c&&z.bare,a),style:r!==void 0?{width:r}:void 0,children:[c?i.jsx(wt,{className:z.visuallyHidden,children:n}):i.jsxs("div",{className:z.header,children:[i.jsx(wt,{className:z.title,children:n}),i.jsx(at,{asChild:!0,children:i.jsx("button",{type:"button",className:z.closeBtn,"aria-label":"Close",children:i.jsx(ot,{size:16})})})]}),i.jsx("div",{className:A(z.body,c&&z.bareBody),children:s}),c&&i.jsx(at,{asChild:!0,children:i.jsx("button",{type:"button",className:z.bareCloseBtn,"aria-label":"Close",children:i.jsx(ot,{size:16})})}),o&&i.jsx("div",{className:z.footer,children:o})]})})]})})}const nd="_handle_1ocv1_1",sd={handle:nd};function Ft({side:t,onResize:e,className:n}){const s=v.useRef(0),o=v.useCallback(c=>{const d=c.clientX-s.current;s.current=c.clientX,e(t==="left"?d:-d)},[e,t]),r=v.useCallback(c=>{var d,f;window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",r),document.body.style.cursor="",document.body.style.userSelect="",(f=(d=c.target)==null?void 0:d.releasePointerCapture)==null||f.call(d,c.pointerId)},[o]);function a(c){c.preventDefault(),s.current=c.clientX,document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("pointermove",o),window.addEventListener("pointerup",r)}return i.jsx("div",{className:A(sd.handle,n),onPointerDown:a,role:"separator","aria-orientation":"vertical"})}function od(t,e){const{order:n,sessions:s}=T.getState(),r=bn(n,s,e).find(a=>a.cwd===t);if(r!=null&&r.sessions[0]){const a=r.sessions[0].id;T.getState().activate(a);const c=T.getState().sessions[a];E.getState().open({id:Q.chat(a),kind:"chat",label:(c==null?void 0:c.title)??"New chat",closable:!0,data:{sessionId:a},workspaceCwd:t})}else _t(t);k.getState().setCwd(t)}const rd="_pathRow_trimn_1",ad="_pathInput_trimn_9",id="_createRow_trimn_13",cd="_createInput_trimn_21",ld="_createError_trimn_25",dd="_list_trimn_30",ud="_item_trimn_37",pd="_name_trimn_49",fd="_emptyState_trimn_54",K={pathRow:rd,pathInput:ad,createRow:id,createInput:cd,createError:ld,list:dd,item:ud,name:pd,emptyState:fd};function hd(){const t=k(p=>p.cwdPickerOpen),e=k(p=>p.closeCwdPicker),n=E(p=>p.activeWorkspaceCwd),s=k(p=>p.cwd),o=C(p=>p.client),r=yt(),[a,c]=v.useState("/"),[d,f]=v.useState("/"),[g,b]=v.useState(!1),[h,S]=v.useState(""),[m,_]=v.useState(null),[y,M]=v.useState(!1),V=Re();v.useEffect(()=>{if(!t)return;const p=ye(n||s||"~",r);c(p),f(p),ie()},[t,o,n,s]);const{data:j,isLoading:Be,isError:be,error:fe}=nc(a,t&&!!o),ae=((j==null?void 0:j.entries)??[]).filter(p=>p.kind==="directory");function ie(){b(!1),S(""),_(null)}function ce(p){c(p),f(p),ie()}function Qe(){ce(a.split("/").slice(0,-1).join("/")||"/")}function we(){ce(d.trim())}async function $e(){const p=h.trim();if(!(!p||!o||y)){M(!0),_(null);try{const R=await kn(o,a,p,"directory");await V.invalidateQueries({queryKey:Me.explorer(a)}),ce(R)}catch(R){_(R instanceof Error?R.message:"Failed to create folder")}finally{M(!1)}}}function Ze(){od(a,r),e()}return i.jsxs(td,{open:t,onOpenChange:p=>!p&&e(),title:"Open Workspace",footer:i.jsxs(i.Fragment,{children:[i.jsx(ed,{asChild:!0,children:i.jsx(F,{size:"sm",variant:"secondary",children:"Cancel"})}),i.jsx(F,{size:"sm",onClick:Ze,children:"Open this folder"})]}),children:[i.jsxs("div",{className:K.pathRow,children:[i.jsx(F,{size:"xs",variant:"ghost",iconOnly:!0,title:"Up",onClick:Qe,children:i.jsx(Xn,{size:13})}),i.jsx(Le,{className:K.pathInput,value:d,onChange:p=>f(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),we())}}),i.jsx(F,{size:"xs",onClick:we,children:"Go"}),i.jsx(F,{size:"xs",variant:"ghost",iconOnly:!0,title:"New folder",disabled:!o||be||g,onClick:()=>{b(!0),S(""),_(null)},children:i.jsx(Vt,{size:13})})]}),g&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:K.createRow,children:[i.jsx(Ee,{size:14}),i.jsx(Le,{className:K.createInput,autoFocus:!0,placeholder:"New folder name",value:h,onChange:p=>S(p.target.value),onKeyDown:p=>{p.key==="Enter"?(p.preventDefault(),$e()):p.key==="Escape"&&(p.preventDefault(),p.stopPropagation(),ie())}}),i.jsx(F,{size:"xs",loading:y,disabled:!h.trim()||y,onClick:()=>void $e(),children:"Create"}),i.jsx(F,{size:"xs",variant:"secondary",onClick:ie,children:"Cancel"})]}),m&&i.jsx("div",{className:K.createError,children:m})]}),i.jsx("div",{className:K.list,children:Be?i.jsx("div",{className:K.emptyState,children:"Loading..."}):be?i.jsxs("div",{className:K.emptyState,children:["Error: ",fe instanceof Error?fe.message:"unknown error"]}):ae.length===0?i.jsx("div",{className:K.emptyState,children:"No subdirectories"}):ae.map(p=>i.jsxs("div",{className:K.item,onClick:()=>ce(a==="/"?`/${p.name}`:`${a}/${p.name}`),children:[i.jsx(Ee,{size:14}),i.jsx("span",{className:K.name,children:p.name})]},p.name))})]})}const md="_shell_1m1nv_1",gd="_main_1m1nv_7",_d="_sidebarLeft_1m1nv_13",yd="_leftHandle_1m1nv_21",bd="_center_1m1nv_24",wd="_sidebarRight_1m1nv_31",Sd="_rightHandle_1m1nv_39",ue={shell:md,main:gd,sidebarLeft:_d,leftHandle:yd,center:bd,sidebarRight:wd,rightHandle:Sd};function xd(){const t=k(a=>a.leftSidebarCollapsed),e=k(a=>a.rightSidebarCollapsed),n=k(a=>a.leftSidebarWidth),s=k(a=>a.rightSidebarWidth),o=k(a=>a.resizeLeftSidebar),r=k(a=>a.resizeRightSidebar);return i.jsxs("div",{className:ue.shell,children:[i.jsx(ka,{}),i.jsxs("div",{className:ue.main,children:[!t&&i.jsxs("aside",{className:ue.sidebarLeft,style:{width:n},children:[i.jsx(ki,{}),i.jsx(Ft,{side:"left",className:ue.leftHandle,onResize:o})]}),i.jsxs("div",{className:ue.center,children:[i.jsx(Fi,{}),i.jsx(Zi,{})]}),!e&&i.jsxs("aside",{className:ue.sidebarRight,style:{width:s},children:[i.jsx(Ft,{side:"right",className:ue.rightHandle,onResize:r}),i.jsx(sl,{})]})]}),i.jsx($l,{}),i.jsx(hd,{})]})}function vd(){const t=v.useRef(!1);v.useEffect(()=>{if(t.current)return;if(t.current=!0,window.location.hash.includes("offer=")){const d=window.location.href;k.getState().setHost(d),C.getState().connect({url:d});return}const e=new URLSearchParams(window.location.search),n=e.get("host"),s=e.get("pair"),o=e.get("password"),r=e.get("cwd"),a=e.get("connect")==="1",c=k.getState();if(s?c.setHost(s):n&&c.setHost(n),o&&c.setPassword(o),r&&c.setCwd(r),s)C.getState().connect({url:s});else if(a){const{host:d,password:f}=k.getState();C.getState().connect({url:d,password:f||void 0})}},[])}function kd(t){return typeof t=="object"&&t!==null&&"kind"in t}function Id(t){const e=[];for(const n of t)if(kd(n))if(n.kind==="other")n.event&&e.push(n.event);else for(const s of n.events??[])e.push(s);return e}function jd(t){return typeof t.model=="string"}function Cd(){const t=C(s=>s.client),e=C(s=>s.status),n=v.useRef(!1);v.useEffect(()=>{e!=="open"||!t||n.current||(n.current=!0,(async()=>{var g;let s=[];try{s=(await t.connection.request("list_agents_request",{all:!1})).agents??[]}catch{s=[]}s.sort((b,h)=>(h.lastActivity??0)-(b.lastActivity??0));const o=T.getState();for(const b of s){if(o.findByAgentId(b.agentId))continue;let h=dt;try{const m=await t.agent(b.agentId).timeline.fetch({direction:"after",limit:200});h=Id(m.items).reduce(gn,dt)}catch{}const S=h.rows.length===0;o.hydrate({id:`s-${b.agentId.slice(0,12)}`,agentId:b.agentId,title:b.title||(S?"New chat":(g=b.cwd)==null?void 0:g.split("/").pop())||"Restored",status:b.status??"idle",cwd:b.cwd||"~",timeline:h,userMessageCount:h.rows.filter(m=>m.kind==="user").length,model:b.model,modelProvider:b.modelProvider})}const{order:r,sessions:a}=T.getState(),c=r.length>0?a[r[0]??""]:void 0;if(!c)return;const d=await Xe(t).catch(()=>null),f=ye(c.cwd||"~",d);T.getState().activate(c.id),k.getState().setCwd(c.cwd),E.getState().open({id:Q.chat(c.id),kind:"chat",label:c.title,closable:!0,data:{sessionId:c.id},workspaceCwd:f})})())},[e,t]),v.useEffect(()=>{if(!(e!=="open"||!t))return t.onAgentUpdate(s=>{if(jd(s)){const o=typeof s.modelProvider=="string"?s.modelProvider:void 0;T.getState().setModelByAgentId(s.agentId,s.model,o)}})},[e,t])}function Td(){const t=C(s=>s.client),e=C(s=>s.status),n=v.useRef(!1);v.useEffect(()=>{e!=="open"||!t||n.current||(n.current=!0,(async()=>{let s=[];try{s=(await t.connection.request("list_terminals_request",{})).terminals??[]}catch{s=[]}if(s.length===0)return;const o=await Xe(t).catch(()=>null),r=E.getState().open;for(const a of s){if(a.closed)continue;const c=ye(a.cwd||"~",o);r({id:Q.terminal(a.slot),kind:"terminal",label:a.name,closable:!0,data:{slot:a.slot,cwd:c},workspaceCwd:c})}})())},[e,t])}function Nd(){v.useEffect(()=>{function t(e){const n=k.getState();if(e.key==="Escape"){n.closeCwdPicker(),n.closeSessionMenu();return}const s=e.ctrlKey||e.metaKey;if(s&&e.key.toLowerCase()==="t"){e.preventDefault(),yn(E.getState().activeWorkspaceCwd||"~");return}if(s&&e.key.toLowerCase()==="w"){const{activeTabId:o,tabs:r}=E.getState();if(!o)return;const a=r.find(c=>c.id===o);(a==null?void 0:a.closable)!==!1&&(e.preventDefault(),ut(o))}}return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[])}function Ed(){return vd(),Cd(),Td(),Nd(),null}function Rd(){return i.jsxs(Zs,{children:[i.jsx(Ed,{}),i.jsx(xd,{})]})}const jn=document.getElementById("root");if(!jn)throw new Error("Missing #root element");En.createRoot(jn).render(i.jsx(v.StrictMode,{children:i.jsx(Rd,{})}));export{F as B,td as D,wn as S,zd as T,C as a,Hd as b,E as c,$t as d,_n as e,Me as r,Ia as t,T as u};
|
|
3
|
-
//# sourceMappingURL=index-BFWpAuBZ.js.map
|