cli-jaw 2.17.63 → 2.17.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/src/code-mode/store.js +35 -6
  2. package/dist/src/code-mode/store.js.map +1 -1
  3. package/dist/src/routes/code-native.js +11 -2
  4. package/dist/src/routes/code-native.js.map +1 -1
  5. package/package.json +1 -1
  6. package/public/dist/.vite/manifest.json +21 -9
  7. package/public/dist/assets/CodeCanvas-c_omHvtV.js +3 -0
  8. package/public/dist/assets/FolderPanel-DOLT_syh.js +3 -0
  9. package/public/dist/assets/{FolderPanel-BHEYcjea.css → FolderPanel-DgoqN1cX.css} +1 -1
  10. package/public/dist/assets/icons-QgChTDzZ.js +1 -0
  11. package/public/dist/assets/manager-Bq8-tr-M.js +5 -0
  12. package/public/dist/assets/manager-C6UJc985.css +1 -0
  13. package/public/dist/manager/index.html +2 -2
  14. package/public/manager/src/App.tsx +3 -3
  15. package/public/manager/src/AppChrome.tsx +1 -1
  16. package/public/manager/src/background-tasks/BackgroundTaskMonitorPanel.tsx +41 -7
  17. package/public/manager/src/background-tasks/background-task-monitor.css +1 -4
  18. package/public/manager/src/code/CodeSessionList.tsx +95 -35
  19. package/public/manager/src/code/code-controller-runtime.ts +66 -8
  20. package/public/manager/src/code/code-controller-types.ts +4 -0
  21. package/public/manager/src/code/code-session-client.ts +1 -1
  22. package/public/manager/src/code/code-session-sidebar.css +32 -0
  23. package/public/manager/src/code/code.css +2 -4
  24. package/public/manager/src/code/session-order.ts +9 -0
  25. package/public/manager/src/components/CommandBar.tsx +0 -10
  26. package/public/manager/src/components/InstanceGroups.tsx +2 -0
  27. package/public/manager/src/components/InstanceListContent.tsx +2 -0
  28. package/public/manager/src/components/InstanceRow.tsx +146 -89
  29. package/public/manager/src/components/SidebarRail.tsx +6 -5
  30. package/public/manager/src/components/ThemeSwitch.tsx +46 -22
  31. package/public/manager/src/components/context-menu/ContextMenu.tsx +207 -0
  32. package/public/manager/src/components/context-menu/context-menu.css +111 -0
  33. package/public/manager/src/components/context-menu/icons.tsx +48 -0
  34. package/public/manager/src/folder-panel/FolderContextMenu.tsx +43 -17
  35. package/public/manager/src/folder-panel/FolderPanel.tsx +9 -1
  36. package/public/manager/src/folder-panel/FolderPanelOverlays.tsx +2 -0
  37. package/public/manager/src/folder-panel/FolderTreeRows.tsx +6 -1
  38. package/public/manager/src/folder-panel/folder-panel.css +0 -33
  39. package/public/manager/src/folder-panel/use-folder-context-menu.ts +6 -19
  40. package/public/manager/src/hooks/useDashboardRegistry.ts +24 -1
  41. package/public/manager/src/jaw-ceo/JawCeoConsolePanels.tsx +71 -9
  42. package/public/manager/src/jaw-ceo/jaw-ceo-console.css +5 -7
  43. package/public/manager/src/main.tsx +2 -0
  44. package/public/manager/src/manager-components.css +1 -34
  45. package/public/manager/src/manager-desktop-titlebar.css +117 -0
  46. package/public/manager/src/manager-layout.css +0 -1
  47. package/public/manager/src/manager-p0-1-1.css +0 -42
  48. package/public/manager/src/manager-polish.css +0 -88
  49. package/public/dist/assets/CodeCanvas-CVbdp0S-.js +0 -3
  50. package/public/dist/assets/FolderPanel-CJvwRwIV.js +0 -3
  51. package/public/dist/assets/manager-CCXm5Yfe.js +0 -5
  52. package/public/dist/assets/manager-D9rhKFKc.css +0 -1
@@ -1,5 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-render-DSSkXCir.css","assets/TerminalPanel-CdfhZ2mu.css","assets/DiffPanel-C_OzH7Q2.css","assets/FolderPanel-BHEYcjea.css","assets/DocPanel-DZKPTOm8.css","assets/BrowserPanel-D7SnTts8.css","assets/DesignPanel-3XpGjuEW.css"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import"./vendor-render-Cmfl_oW8.js";import{t}from"./preload-helper-CfbQpVni.js";import{a as n,i as r,n as i,r as a,t as o}from"./esm-Q6VOkDbn.js";import{n as s,t as c}from"./settings-embedding-BRW0WZvh.js";import{n as l,t as u}from"./jsx-runtime-CkEUZM6i.js";import{t as d}from"./react-dom-URBLzV3w.js";import{C as f,D as p,E as m,O as h,S as g,T as _,_ as v,a as y,b,c as x,d as S,f as C,g as w,h as T,i as E,k as D,l as O,m as k,n as A,o as ee,p as j,r as M,s as te,t as ne,u as re,v as ie,w as ae,x as oe,y as se}from"./api-B9RiiOMM.js";import{n as ce,t as N}from"./desktop-bridge-DbRfkg8l.js";import{n as le}from"./terminal-shortcut-queue-B_AyW1hN.js";import{a as ue,c as de,i as fe,l as P,n as F,o as pe,r as me,s as he,t as ge,u as _e}from"./PanelLayoutProvider-DRZ4QkBC.js";import{n as ve,t as ye}from"./client-platform-WO8m6kPQ.js";import{a as be,i as xe,o as Se,r as Ce,t as I}from"./manager-shortcuts-Cqmr0mEq.js";import{t as L}from"./copy-text-WsUHYigB.js";import{i as R,r as we}from"./folder-drag-payload-BhV9yzhH.js";import{$ as Te,At as Ee,Ct as z,D as De,Et as Oe,It as ke,L as B,N as V,Ot as H,Q as Ae,St as U,Y as W,Z as je,_t as G,a as K,at as Me,c as Ne,ct as Pe,dt as Fe,et as q,ft as Ie,ht as Le,it as Re,jt as ze,k as Be,lt as Ve,nt as He,o as Ue,ot as We,p as Ge,q as J,st as Ke,t as qe,u as Je,vt as Ye,wt as Xe,x as Ze,y as Qe}from"./dist-D011G-p-.js";import{d as $e,f as et,g as tt,i as nt,r as rt,u as it}from"./dist-CcmA2WLJ.js";import{c as at,i as ot,l as st,n as ct,o as lt,r as ut}from"./dist-DBpt7gM8.js";import{a as dt}from"./dist-DBX5LjYY.js";import{t as ft}from"./MarkdownRenderer-DzN66XVb.js";import{a as pt,i as mt,n as ht,r as gt,t as _t}from"./wiki-link-suggestions-BcEfThgf.js";import{i as vt,t as yt}from"./notes-graph-settings-BUoTzvqs.js";var Y=e(l(),1),bt=s();async function xt(e){let t=Math.max(1,e.maxAttempts??16),n=Math.max(50,e.intervalMs??500),r=null;for(let i=1;i<=t;i+=1){if(e.signal?.aborted)return{settled:!1,attempts:i-1,instance:r};let a=new AbortController,o=()=>a.abort();e.signal?.addEventListener(`abort`,o,{once:!0});try{r=await e.fetchOnce(e.port,a.signal)}catch{r=null}finally{e.signal?.removeEventListener(`abort`,o)}if(e.onAttempt?.(r,i),St(r,e))return{settled:!0,attempts:i,instance:r};if(i===t)break;await Ct(n,e.signal)}return{settled:!1,attempts:t,instance:r}}function St(e,t){return t.expected===`online`?e?.status===`online`:t.expected===`offline`?!e||e.status!==`online`:t.expected===`restart-detected`?!e||e.status!==`online`||typeof e.uptime!=`number`?!1:typeof t.previousUptime!=`number`||e.uptime<t.previousUptime:!1}function Ct(e,t){return new Promise(n=>{let r=setTimeout(()=>{i(),n()},e);function i(){clearTimeout(r),t?.removeEventListener(`abort`,a)}function a(){i(),n()}if(t?.aborted){i(),n();return}t?.addEventListener(`abort`,a,{once:!0})})}var X=u();function wt(){let[e,t]=(0,Y.useState)(null),[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(null),o=e?.managed.length||0;(0,Y.useEffect)(()=>{s()},[]);async function s(){try{t(await v())}catch(e){a(e.message)}}async function c(e,n){r(e),a(null);try{let r=await n();t(r),a(`${e} complete.`)}catch(e){a(e.message)}finally{r(null)}}function l(){o!==0&&window.confirm(`Stop ${o} dashboard-managed server${o===1?``:`s`}?`)&&c(`Stop all managed`,p)}return(0,X.jsxs)(`section`,{className:`process-control-panel`,"aria-label":`Process control`,children:[(0,X.jsxs)(`div`,{className:`process-control-header`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{children:`Process control`}),(0,X.jsxs)(`strong`,{children:[o,` managed`]})]}),(0,X.jsx)(`button`,{type:`button`,onClick:s,disabled:n!=null,children:`Refresh`})]}),(0,X.jsxs)(`div`,{className:`process-control-actions`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:l,disabled:n!=null||o===0,children:`Stop all managed`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void c(`Adopt/recover managed`,A),disabled:n!=null,children:`Adopt/recover`}),(0,X.jsx)(`button`,{type:`button`,disabled:!0,title:e?.unsupported.reason||`Planned`,children:`Force release port`})]}),(0,X.jsx)(`p`,{className:`process-control-hint`,children:`Stop all affects only dashboard-managed servers. Adopt/recover reconnects known managed process records without stopping external instances.`}),(0,X.jsxs)(`div`,{className:`process-control-list`,children:[e?.managed.map(e=>(0,X.jsxs)(`div`,{className:`process-control-row`,children:[(0,X.jsxs)(`span`,{children:[`:`,e.port]}),(0,X.jsx)(`strong`,{children:e.pid?`pid ${e.pid}`:`pid n/a`}),(0,X.jsx)(`em`,{children:e.proof})]},e.port)),o===0&&(0,X.jsx)(`p`,{children:`No dashboard-managed servers are registered.`})]}),i&&(0,X.jsx)(`p`,{className:`process-control-message`,children:i})]})}var Tt=4e3,Et={info:`log-level-info`,warn:`log-level-warn`,error:`log-level-error`};function Dt(e){try{return new Date(e).toLocaleTimeString(`en-GB`,{hour12:!1})}catch{return e.slice(11,19)}}function Ot({port:e}){let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(!0),[s,c]=(0,Y.useState)(`all`),l=(0,Y.useRef)(null),u=(0,Y.useRef)(null),d=(0,Y.useCallback)(async()=>{try{let t=await fetch(`/api/manager/instance-logs/${e}`);if(!t.ok){i(`HTTP ${t.status}`);return}let r=await t.json();r.ok&&r.snapshot?(n(r.snapshot),i(null)):i(r.error||`Unknown error`)}catch(e){i(e.message)}},[e]);(0,Y.useEffect)(()=>(d(),u.current=setInterval(d,Tt),()=>{u.current&&clearInterval(u.current)}),[d]),(0,Y.useEffect)(()=>{a&&l.current&&(l.current.scrollTop=l.current.scrollHeight)},[t,a]);let f=t?.lines.filter(e=>s===`all`||e.level===s)??[];return r&&!t?(0,X.jsxs)(`div`,{className:`detail-empty`,children:[`Failed to load logs: `,r]}):t?.source===`none`?(0,X.jsx)(`div`,{className:`detail-empty`,children:t.reason||`No log source reachable for this instance.`}):(0,X.jsxs)(`div`,{className:`logs-panel`,children:[(0,X.jsxs)(`div`,{className:`logs-toolbar`,children:[(0,X.jsxs)(`select`,{className:`logs-filter`,value:s,onChange:e=>c(e.target.value),children:[(0,X.jsx)(`option`,{value:`all`,children:`All levels`}),(0,X.jsx)(`option`,{value:`info`,children:`Info`}),(0,X.jsx)(`option`,{value:`warn`,children:`Warn`}),(0,X.jsx)(`option`,{value:`error`,children:`Error`})]}),(0,X.jsxs)(`label`,{className:`logs-autoscroll`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked)}),`Auto-scroll`]}),(0,X.jsxs)(`span`,{className:`logs-meta`,children:[t?`${t.lines.length} lines · source: ${t.source}`:`Loading…`,t?.truncated&&` · truncated`]})]}),(0,X.jsx)(`div`,{className:`logs-container`,ref:l,children:f.length===0?(0,X.jsx)(`div`,{className:`logs-empty`,children:`No log lines available.`}):f.map((e,t)=>(0,X.jsxs)(`div`,{className:`log-line ${Et[e.level]}`,children:[(0,X.jsx)(`span`,{className:`log-ts`,children:Dt(e.ts)}),(0,X.jsx)(`span`,{className:`log-level`,children:e.level.toUpperCase()}),(0,X.jsx)(`span`,{className:`log-text`,children:e.text})]},t))})]})}function kt(e){let t=e.instance;return(0,X.jsxs)(`section`,{className:`detail-panel`,"aria-label":`Selected instance detail`,children:[e.activeTab===`overview`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`overview-grid`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{children:`Status`}),(0,X.jsx)(`strong`,{children:t?.status||`n/a`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{children:`CLI`}),(0,X.jsx)(`strong`,{children:t?.currentCli||`n/a`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{children:`Model`}),(0,X.jsx)(`strong`,{children:t?.currentModel||`n/a`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{children:`Owner`}),(0,X.jsx)(`strong`,{children:t?.lifecycle?.owner||`n/a`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{children:`Version`}),(0,X.jsx)(`strong`,{children:t?.version||`n/a`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{children:`Group`}),(0,X.jsx)(`strong`,{children:t?.group||`ungrouped`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{children:`Reason`}),(0,X.jsx)(`strong`,{children:t?.lifecycle?.reason||t?.healthReason||`ok`})]})]}),(0,X.jsx)(wt,{})]}),e.activeTab===`logs`&&t&&(0,X.jsx)(Ot,{port:t.port}),e.activeTab===`logs`&&!t&&(0,X.jsx)(`div`,{className:`detail-empty`,children:`Select an instance to view its logs.`})]})}function At(e){return(0,X.jsxs)(`div`,{className:`empty-navigator`,role:`status`,"aria-live":`polite`,children:[(0,X.jsx)(`p`,{className:`empty-navigator-headline`,children:`No Jaw instances detected on the scanned range.`}),(0,X.jsxs)(`p`,{className:`empty-navigator-subline`,children:[`Currently scanning ports `,e.rangeFrom,`–`,e.rangeTo,`. Try widening the range, or start a Jaw with the command below.`]}),(0,X.jsxs)(`code`,{className:`empty-navigator-code`,"aria-label":`Suggested command`,children:[`jaw serve --port `,e.rangeFrom]})]})}function jt(e,t={}){return t.transitioning?`transitioning`:t.busy?`working`:e.status===`offline`?`offline`:e.status===`online`?`online`:`attention`}function Mt(e){let t=Number.isFinite(e)?Math.max(0,Math.floor(e/1e3)):0;if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}function Nt(e){return[`:${e.port}`,e.homeDisplay||`home n/a`,e.currentCli||`cli n/a`,e.currentModel||`model n/a`,`v${e.version||`n/a`}`].join(` · `)}function Pt(e,t){let n=Number(!!t.favorite)-Number(!!e.favorite);return n===0?e.port-t.port:n}var Ft={start:`starting…`,stop:`stopping…`,restart:`restarting…`,perm:`registering…`,unperm:`unregistering…`};function It(e){return`instance-status status-${e}`}var Lt=()=>(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`12`,height:`12`,fill:`currentColor`,"aria-hidden":`true`,children:(0,X.jsx)(`rect`,{x:`3`,y:`3`,width:`10`,height:`10`,rx:`1.5`})}),Rt=()=>(0,X.jsxs)(`svg`,{viewBox:`0 0 16 16`,width:`12`,height:`12`,stroke:`currentColor`,strokeWidth:`1.5`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,X.jsx)(`path`,{d:`M6.5 3.5H4a1 1 0 0 0-1 1V12a1 1 0 0 0 1 1h7.5a1 1 0 0 0 1-1V9.5`}),(0,X.jsx)(`path`,{d:`M9.5 2.5h4v4`}),(0,X.jsx)(`path`,{d:`M13.5 2.5 8 8`})]}),zt=({open:e})=>(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`12`,height:`12`,stroke:`currentColor`,strokeWidth:`1.5`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,style:{transform:e?`rotate(180deg)`:void 0,transition:`transform 0.12s`},children:(0,X.jsx)(`path`,{d:`M3.5 6l4.5 4.5L12.5 6`})});function Bt(e){let[,t]=(0,Y.useState)(0);return(0,Y.useEffect)(()=>{if(e.startedAtMs==null)return;let n=window.setInterval(()=>t(e=>e+1),1e3);return()=>window.clearInterval(n)},[e.startedAtMs]),e.startedAtMs==null?null:(0,X.jsx)(`span`,{className:`instance-row-working-duration`,children:Mt(Date.now()-e.startedAtMs)})}function Vt(e){let t=e.instance.lifecycle,n=t?.reason||e.instance.healthReason||`ok`,[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(e.instance.label||e.profile?.label||e.label),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(null);function d(e){e.stopPropagation()}let f=e.transitioning?Ft[e.transitioning]:null,p=jt(e.instance,{busy:!!e.agentBusy,transitioning:e.transitioning||null}),m=(0,Y.useRef)(null);p===`working`?m.current??=Date.now():m.current=null;let h=p===`transitioning`&&f?f:p===`working`?`Working`:p===`offline`?`Offline`:p===`attention`?`Attention`:`Online`,g=e.density===`compact`||e.density===`rail`,_=`${It(e.instance.status)}${f?` is-transitioning`:``}${e.agentBusy?` is-busy`:``} is-${p}`,v=e.instance.label||e.profile?.label||e.label;async function y(t){t.preventDefault(),t.stopPropagation(),c(!0),u(null);try{await e.onInstanceLabelSave(e.instance.port,a),i(!1)}catch(e){u(e.message)}finally{c(!1)}}return(0,X.jsxs)(`article`,{className:`instance-row density-${e.density||`comfortable`} priority-${e.priority||`normal`} ${e.selected?`is-selected`:``}${f?` is-transitioning-row`:``} is-${p}`,title:Nt(e.instance),"aria-current":e.selected?`true`:void 0,children:[(0,X.jsxs)(`div`,{className:`instance-row-body`,children:[(0,X.jsxs)(`button`,{className:`instance-row-select`,type:`button`,"data-instance-port":e.instance.port,"aria-pressed":e.selected,onClick:()=>{e.onSelect(e.instance)},children:[(0,X.jsxs)(`span`,{className:`instance-row-main`,children:[(0,X.jsx)(`span`,{className:_,"aria-label":e.instance.status}),(0,X.jsxs)(`span`,{className:`instance-row-title`,children:[g?null:(0,X.jsxs)(`span`,{className:`instance-row-status-line`,"data-status":p,children:[(0,X.jsx)(`span`,{className:`instance-row-status-pill is-${p} health-${e.instance.status}`,title:h,children:h}),p===`working`?(0,X.jsx)(Bt,{startedAtMs:m.current}):null]}),(0,X.jsxs)(`span`,{className:`instance-row-title-line`,children:[(0,X.jsx)(`strong`,{children:e.instance.favorite?`Pinned ${v}`:v}),e.activityUnreadCount?(0,X.jsxs)(`span`,{className:`instance-unread-badge`,"aria-label":`${e.activityUnreadCount} unread activity`,children:[`(`,e.activityUnreadCount>99?`99+`:e.activityUnreadCount,`)`]}):null]}),f&&(0,X.jsx)(`span`,{className:`instance-row-secondary`,children:(0,X.jsx)(`em`,{className:`instance-row-transition`,children:f})})]})]}),(0,X.jsxs)(`span`,{className:`instance-row-meta`,children:[e.priority!==`active`&&e.showLatestActivityTitle!==!1&&e.latestActivityTitle&&(0,X.jsx)(`span`,{className:`instance-row-activity-title`,children:e.latestActivityTitle}),e.showRuntimeLine!==!1&&(0,X.jsxs)(`span`,{className:`instance-row-runtime`,children:[e.instance.currentCli||`cli n/a`,` / `,e.instance.currentModel||`model n/a`]}),e.priority!==`active`&&(0,X.jsxs)(`span`,{className:`instance-row-version`,children:[`v`,e.instance.version||`n/a`,` · `,e.uptime]}),e.priority!==`active`&&(0,X.jsxs)(`span`,{className:`instance-row-reason`,children:[new Date(e.instance.lastCheckedAt).toLocaleTimeString(),` · `,n]})]})]}),(0,X.jsxs)(`div`,{className:`instance-row-quick`,onClick:d,children:[e.priority===`active`&&e.instance.ok&&(e.sessionCount??0)>=1&&e.onToggleSessions?(0,X.jsx)(`button`,{type:`button`,className:`quick-btn action-sessions`,"aria-controls":e.sessionListId,"aria-expanded":e.sessionsOpen===!0,"aria-label":`Sessions (${e.sessionCount})`,title:`Sessions (${e.sessionCount})`,onClick:t=>{d(t),e.onToggleSessions?.(e.instance.port)},children:(0,X.jsx)(zt,{open:e.sessionsOpen===!0})}):null,(0,X.jsx)(`button`,{type:`button`,className:`quick-btn action-stop`,onClick:t=>{d(t),e.onLifecycle(`stop`,e.instance)},disabled:!t?.canStop||e.busy,title:`Stop`,"aria-label":`Stop`,children:(0,X.jsx)(Lt,{})}),(0,X.jsx)(`a`,{className:`quick-btn action-open${e.instance.ok?``:` is-disabled`}`,href:e.instance.ok?e.instance.url:void 0,target:e.instance.ok?`_blank`:void 0,rel:e.instance.ok?`noreferrer`:void 0,title:`Open in new tab`,"aria-label":`Open`,"aria-disabled":!e.instance.ok||void 0,tabIndex:e.instance.ok?void 0:-1,onClick:t=>{if(!e.instance.ok){t.preventDefault();return}d(t),e.onMarkActivitySeen(e.instance.port)},children:(0,X.jsx)(Rt,{})}),(0,X.jsxs)(`span`,{className:`port`,children:[`:`,e.instance.port]})]})]}),e.showInlineLabelEditor!==!1&&r?(0,X.jsxs)(`form`,{className:`instance-label-edit-form`,onSubmit:e=>void y(e),onClick:d,children:[(0,X.jsx)(`input`,{className:`instance-label-input`,value:a,maxLength:120,"aria-label":`Rename ${v}`,onChange:e=>o(e.target.value)}),(0,X.jsx)(`button`,{className:`instance-label-save`,type:`submit`,disabled:s,children:`Save`}),(0,X.jsx)(`button`,{className:`instance-label-cancel`,type:`button`,disabled:s,onClick:()=>{o(e.instance.label||e.profile?.label||e.label),u(null),i(!1)},children:`Cancel`}),l&&(0,X.jsx)(`span`,{className:`instance-label-error`,children:l})]}):e.showInlineLabelEditor===!1?null:(0,X.jsx)(`button`,{className:`instance-label-edit-button`,type:`button`,"aria-label":`Rename ${v}`,title:`Rename`,onClick:t=>{d(t),o(e.instance.label||e.profile?.label||e.label),u(null),i(!0)},children:(0,X.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`13`,height:`13`,stroke:`currentColor`,strokeWidth:`2`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,X.jsx)(`path`,{d:`M12 20h9`}),(0,X.jsx)(`path`,{d:`M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z`})]})}),e.jumpHint?(0,X.jsx)(`span`,{className:`instance-jump-hint`,"aria-hidden":`true`,children:e.jumpHint}):null,e.showSelectedActions!==!1&&(0,X.jsxs)(`div`,{className:`instance-actions`,children:[(0,X.jsx)(`button`,{type:`button`,"aria-label":`Preview`,title:`Preview`,onClick:t=>{d(t),e.onPreview(e.instance)},disabled:!e.instance.ok,children:`Prev`}),(0,X.jsx)(`button`,{type:`button`,className:`action-start`,"aria-label":`Start`,onClick:t=>{d(t),e.onLifecycle(`start`,e.instance)},disabled:!t?.canStart||e.busy,title:t?.commandPreview?.join(` `),children:`Start`}),(0,X.jsx)(`button`,{type:`button`,"aria-label":`Register as persistent service`,onClick:t=>{d(t),e.onLifecycle(`perm`,e.instance)},disabled:!t?.canPerm||e.busy,title:`Register as persistent service`,children:`Perm`}),(0,X.jsx)(`button`,{type:`button`,"aria-label":`Restart`,title:`Restart`,onClick:t=>{d(t),e.onLifecycle(`restart`,e.instance)},disabled:!t?.canRestart||e.busy,children:`Res`})]})]})}var Ht=`jaw.sidebarGroupCollapsed`;function Ut(){try{if(typeof localStorage>`u`)return{};let e=localStorage.getItem(Ht);if(!e)return{};let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))return{};let n={};for(let[e,r]of Object.entries(t))typeof r==`boolean`&&(n[e]=r);return n}catch{return{}}}function Wt(e){try{if(typeof localStorage>`u`)return;localStorage.setItem(Ht,JSON.stringify(e))}catch{}}function Gt(){let[e,t]=(0,Y.useState)(Ut),n=(0,Y.useCallback)(t=>e[t]===!0,[e]),r=(0,Y.useCallback)(e=>{t(t=>{let n={...t,[e]:!t[e]};return Wt(n),n})},[]);return{isCollapsed:n,toggle:r,toggleGroup:r}}function Kt(e,t,n){if(e.length===0)return null;if(t==null)return n===`previous`?e[e.length-1]??null:e[0]??null;let r=e.indexOf(t);return r===-1?null:n===`previous`?r>0?e[r-1]??null:null:r<e.length-1?e[r+1]??null:null}function qt(e){let t=/^jumpInstance([1-9])$/.exec(e);return t?Number(t[1])-1:null}function Jt(e){return e===`offline`||e===`unknown`||e===`timeout`}function Yt(e,t,n){let r=e.slice(0,Math.max(0,t));return n!=null&&e.includes(n)&&!r.includes(n)?[...r,n]:r}function Xt(e){let t=e.setTimeoutFn??setTimeout,n=e.clearTimeoutFn??clearTimeout,r=!1,i=null,a=()=>{i!=null&&(n(i),i=null)};return{sync(n){if(!n){a(),r&&(r=!1,e.onVisibilityChange(!1));return}r||i!=null||(i=t(()=>{i=null,r=!0,e.onVisibilityChange(!0)},e.delayMs))},dispose(){a()}}}var Zt=!1,Qt=new Set;function $t(e){return Qt.add(e),()=>{Qt.delete(e)}}function en(){return Zt}function tn(e){Zt!==e&&(Zt=e,Qt.forEach(e=>e()))}function nn(e){return e.altKey&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey}function rn(e){return Array.from(e.querySelectorAll(`[data-instance-port]`)).map(e=>Number(e.dataset.instancePort)).filter(e=>Number.isInteger(e))}function an(e,t,n){if(e.isComposing||e.keyCode===229)return;let r=Array.from(t.querySelectorAll(`[data-instance-port]`));if(r.length===0)return;let i=r.map(e=>Number(e.dataset.instancePort)),a=document.activeElement instanceof HTMLElement?document.activeElement:null;if(!a||!r.includes(a)||e.target!==a)return;let o=Number(a.dataset.instancePort),s=null;if(e.key===`ArrowDown`)s=Kt(i,o,`next`);else if(e.key===`ArrowUp`)s=Kt(i,o,`previous`);else if(e.key===`Home`)s=i[0]??null;else if(e.key===`End`)s=i[i.length-1]??null;else if(e.key===`Enter`&&o!=null){e.preventDefault(),n(o);return}s!=null&&(e.preventDefault(),r.find(e=>Number(e.dataset.instancePort)===s)?.focus())}var on=null;function sn(e){on=e}function cn(){return on}function ln(e,t){return e.filter(e=>!t.has(e.port))}function un(e,t){let n=new Set,r=t==null?[]:e.filter(e=>e.port===t),i=ln(e,n).filter(e=>e.favorite);i.forEach(e=>n.add(e.port));let a=new Map;for(let t of ln(e,n)){if(!t.group)continue;let e=a.get(t.group)||[];e.push(t),a.set(t.group,e),n.add(t.port)}let o=ln(e,n),s=o.filter(e=>e.status===`online`),c=o.filter(e=>e.status===`error`),l=o.filter(e=>Jt(e.status));i.sort(Pt),s.sort(Pt),c.sort(Pt),l.sort(Pt);for(let e of a.values())e.sort(Pt);return[{id:`active`,label:`Selected`,instances:r},{id:`favorites`,label:`Pinned`,instances:i},...Array.from(a.entries()).map(([e,t])=>({id:`group-${e}`,label:e,instances:t})),{id:`running`,label:`Running`,instances:s},{id:`attention`,label:`Attention`,instances:c},{id:`settled`,label:`Settled`,instances:l}].filter(e=>e.instances.length>0)}function dn(e,t,n,r=`normal`,i,a){return(0,X.jsx)(Vt,{instance:t,...n===void 0?{}:{profile:n},selected:e.selectedPort===t.port,busy:e.lifecycleBusyPort===t.port,transitioning:e.transitioningPort===t.port&&e.transitionAction||null,activityUnreadCount:e.activityUnreadByPort?.[t.port]||0,latestActivityTitle:e.latestTitleByPort?.[t.port]||null,agentBusy:e.busyPorts?.has(t.port)||!1,...e.showLatestActivityTitles===void 0?{}:{showLatestActivityTitle:e.showLatestActivityTitles},...e.showInlineLabelEditor===void 0?{}:{showInlineLabelEditor:e.showInlineLabelEditor},...e.showSidebarRuntimeLine===void 0?{}:{showRuntimeLine:e.showSidebarRuntimeLine},...e.showSelectedRowActions===void 0?{}:{showSelectedActions:e.showSelectedRowActions},...e.density===void 0?{}:{density:e.density},...r===`active`&&e.activeSessionCount!==void 0?{sessionCount:e.activeSessionCount}:{},...r===`active`&&e.activeSessionsOpen!==void 0?{sessionsOpen:e.activeSessionsOpen}:{},...r===`active`&&e.onToggleActiveSessions?{onToggleSessions:e.onToggleActiveSessions}:{},...a===void 0?{}:{sessionListId:a},priority:r,label:e.getLabel(t),uptime:e.formatUptime(t.uptime),onSelect:e.onSelect,onPreview:e.onPreview,onMarkActivitySeen:e.onMarkActivitySeen,onInstanceLabelSave:e.onInstanceLabelSave,onLifecycle:e.onLifecycle,jumpHint:i??null},t.port)}function fn(e,t,n,r){let i=e.instances.find(e=>e.port===t),a=e.id===`settled`?Yt(e.instances.map(e=>e.port),r,t):[],o=new Map(e.instances.map(e=>[e.port,e])),s=e.id===`settled`?a.map(e=>o.get(e)).filter(e=>e!=null):e.instances;return e.id===`active`||!n?s:i?[i]:[]}function pn(e){let t=(0,Y.useId)(),{group:n,props:r,profileMap:i,collapsed:a,onToggle:o,jumpStartIndex:s,showJumpHints:c,settledVisibleCount:l,onShowMoreSettled:u}=e,d=n.id!==`settled`||!a,f=fn(n,r.selectedPort,a,l),p=`instance-group-body-${t}`,m=n.id===`active`&&f[0]?.ok?`instance-sessions-${t}-${f[0].port}`:void 0,h=n.id===`settled`&&d?Math.max(0,n.instances.length-l):0,g=n.id===`active`?(0,X.jsxs)(`div`,{className:`instance-group-header`,children:[(0,X.jsx)(`span`,{children:n.label}),(0,X.jsx)(`strong`,{children:n.instances.length})]}):(0,X.jsxs)(`button`,{type:`button`,className:`instance-group-header instance-group-toggle`,"aria-expanded":!a,"aria-controls":p,onClick:o,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`svg`,{className:`instance-group-chevron`,viewBox:`0 0 16 16`,width:`12`,height:`12`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{d:`M3.5 6l4.5 4.5L12.5 6`})}),` `,n.label]}),(0,X.jsx)(`strong`,{children:n.instances.length})]});return(0,X.jsxs)(`section`,{className:`instance-group`,"aria-label":`${n.label} instances`,children:[g,(0,X.jsxs)(`div`,{id:p,hidden:a&&f.length===0,children:[f.map((e,t)=>{let a=s+t,o=c&&a<9?String(a+1):null;return dn(r,e,e.profileId?i.get(e.profileId):void 0,n.id===`active`?`active`:`normal`,o,m)}),n.id===`active`&&f[0]?.ok?(0,X.jsx)(`div`,{id:m,children:r.renderActiveSessionList?.(f[0].port)}):null,n.id===`settled`&&d&&h>0?(0,X.jsxs)(`button`,{type:`button`,className:`instance-settled-more`,onClick:u,children:[`Show `,Math.min(h,25),` more`]}):null]})]},n.id)}function mn(e){let t=un(e.instances,e.selectedPort),n=new Map((e.profiles||[]).map(e=>[e.profileId,e])),{isCollapsed:r,toggle:i}=Gt(),a=(0,Y.useSyncExternalStore)($t,en),[o,s]=(0,Y.useState)(10);if((0,Y.useEffect)(()=>{s(10)},[e.instances]),t.length===0&&n.size===0)return(0,X.jsx)(`section`,{className:`state`,children:`No matching instances found.`});let c=0,l=t.map(t=>{let l=t.id!==`active`&&r(t.id),u=fn(t,e.selectedPort,l,o).length,d=c;return c+=u,(0,X.jsx)(pn,{group:t,props:e,profileMap:n,collapsed:l,onToggle:()=>i(t.id),jumpStartIndex:d,showJumpHints:a,settledVisibleCount:o,onShowMoreSettled:()=>s(e=>e+25)},t.id)});return n.size>0?(0,X.jsx)(`div`,{className:`instance-groups profile-instance-groups is-profile-merged`,children:l}):(0,X.jsx)(`div`,{className:`instance-groups`,children:l})}var hn=2,gn=500,_n=1e4;function vn(e){let t=e?.trim();if(!t)return null;if(/^\d+$/.test(t)){let e=Number(t)*1e3;return Number.isSafeInteger(e)?e:null}let n=Date.parse(t);if(!Number.isFinite(n))return null;let r=n-Date.now();return r>0?r:null}function yn(){return new DOMException(`The operation was aborted.`,`AbortError`)}function bn(e,t){return new Promise((n,r)=>{if(t?.aborted){r(yn());return}let i=()=>{clearTimeout(a),r(yn())},a=setTimeout(()=>{t?.removeEventListener(`abort`,i),n()},e);t?.addEventListener(`abort`,i,{once:!0})})}function xn(e,t){return e===void 0||!Number.isFinite(e)?t:Math.max(0,Math.floor(e))}async function Sn(e,t={}){let n=xn(t.retries,hn),r=xn(t.baseDelayMs,gn),i=t.fetchImpl??fetch,a=t.delay??bn,o=t.random??Math.random,s={method:`GET`,...t.signal?{signal:t.signal}:{}},c=0,l=await i(e,s);for(let u=0;l.status===429&&u<n;u++){let n=_n-c;if(n<=0)return l;let d=vn(l.headers.get(`Retry-After`)),f=Math.min(r*2**u,_n),p=Math.min(1,Math.max(0,o()))*f,m=Math.min(d??p,n);await a(m,t.signal),c+=m,l=await i(e,s)}return l}var Cn=2e3,wn=new Map,Tn=(...e)=>fetch(...e),En=()=>Date.now();function Dn(e){let t=null;return e.lastError?.kind===`load`?t={kind:`load`,message:e.errorMessage??`sessions load failed`}:e.lastError?.kind===`switch`&&(t={kind:`switch`,seq:e.lastError.seq,message:e.errorMessage??`session switch failed`}),{data:e.data,switching:e.switching,error:t,count:e.data?.sessions.length??0}}function On(){return{generation:0,at:0,promise:null,data:null,switching:!1,lastError:null,errorMessage:null,snapshot:{data:null,switching:!1,error:null,count:0},listeners:new Set}}function kn(e){let t=wn.get(e);return t||(t=On(),wn.set(e,t)),t}function An(e){return e instanceof Error?e.message:String(e)}function jn(e){e.snapshot=Dn(e);for(let t of[...e.listeners])t()}async function Mn(e){let t=await Sn(`/i/${e}/api/chat-sessions`,{fetchImpl:Tn});if(!t.ok)throw Error(`sessions fetch failed: ${t.status}`);let n=(await t.json()).data??{};return{sessions:Array.isArray(n.sessions)?n.sessions:[],activeId:typeof n.active==`string`?n.active:null}}async function Nn(e,t){let n=await Tn(`/i/${e}/api/chat-sessions/${t}/switch`,{method:`POST`});if(n.ok)return;let r=await n.json().catch(()=>({}));throw Error(r.error||`switch failed: ${n.status}`)}function Pn(e,t){let n=kn(e);return n.listeners.add(t),()=>{n.listeners.delete(t)}}function Fn(e){return kn(e).snapshot}async function In(e){let t=kn(e);if(t.promise){await t.promise;return}if(t.data&&En()-t.at<Cn)return;let n=t.generation,r=Mn(e);t.promise=r;try{let e=await r;if(t.generation!==n)return;t.data=e,t.at=En(),t.lastError=null,t.errorMessage=null,jn(t)}catch(e){throw t.promise===r&&(t.promise=null),t.generation===n&&(t.lastError={kind:`load`},t.errorMessage=An(e),jn(t)),e}finally{t.promise===r&&(t.promise=null)}}async function Ln(e,t){let n=kn(e);if(!n.switching){n.switching=!0,n.lastError=null,n.errorMessage=null,jn(n);try{try{await Nn(e,t)}catch(e){throw n.lastError={kind:`switch`,seq:t},n.errorMessage=An(e),jn(n),e}n.generation++,n.at=-1/0,n.promise=null,await In(e)}finally{n.switching=!1,jn(n)}}}async function Rn(e){let t=kn(e).lastError;if(t?.kind===`switch`){await Ln(e,t.seq);return}await In(e)}function zn(e){let t=e.split(`:`);if(t.length>=4&&t[0]===`jaw`){let e=t[3]||``,n=t.includes(`thread`);return`${t[1]} ${e.slice(0,11)}${n?` · thread`:``}`}return e.slice(0,32)}function Bn(e){return e.label&&!e.label.startsWith(`jaw:`)?e.label:e.remoteKey?zn(e.remoteKey):e.label?zn(e.label):e.seq===0?`Default session`:`Session #${e.seq}`}function Vn(e){if(!e)return null;let t=new Date(e.replace(` `,`T`)).getTime();if(Number.isNaN(t))return null;let n=Math.floor((Date.now()-t)/6e4);if(n<1)return`now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function Hn(e){let t=(0,Y.useCallback)(t=>Pn(e.port,t),[e.port]),n=(0,Y.useSyncExternalStore)(t,()=>Fn(e.port));if((0,Y.useEffect)(()=>{e.open&&In(e.port).catch(()=>{})},[e.open,e.port]),!e.open)return null;async function r(t,r){if(t.stopPropagation(),!(r.id===n.data?.activeId||n.switching))try{await Ln(e.port,r.seq),e.onSessionSwitched?.()}catch{}}let i=t=>{t.stopPropagation(),Rn(e.port).catch(()=>{})};if(n.error?.kind===`load`)return(0,X.jsx)(`div`,{className:`instance-session-list`,role:`list`,"aria-label":`Chat sessions`,children:(0,X.jsxs)(`div`,{className:`instance-session-error`,children:[(0,X.jsx)(`span`,{children:n.error.message}),(0,X.jsx)(`button`,{type:`button`,className:`instance-session-retry`,onClick:i,children:`Retry`})]})});if(n.data===null)return(0,X.jsx)(`div`,{className:`instance-session-list`,role:`list`,"aria-label":`Chat sessions`,children:(0,X.jsx)(`div`,{className:`instance-session-empty`,children:`Loading sessions…`})});let a=n.data.sessions;if(a.length===0)return null;let o=n.data?.activeId??null;return(0,X.jsxs)(`div`,{className:`instance-session-list`,role:`list`,"aria-label":`Chat sessions`,children:[n.error?.kind===`switch`&&(0,X.jsxs)(`div`,{className:`instance-session-error`,children:[(0,X.jsx)(`span`,{children:n.error.message}),(0,X.jsx)(`button`,{type:`button`,className:`instance-session-retry`,onClick:i,children:`Retry`})]}),a.map(e=>{let t=e.id===o,i=Vn(e.lastActivityAt);return(0,X.jsxs)(`button`,{type:`button`,role:`listitem`,className:`instance-session-row${t?` is-active`:``}`,disabled:n.switching,"aria-current":t||void 0,onClick:t=>void r(t,e),children:[(0,X.jsxs)(`span`,{className:`instance-session-title`,children:[Bn(e),e.source&&(0,X.jsx)(`span`,{className:`session-source-badge`,children:e.source})]}),(0,X.jsx)(`span`,{className:`instance-session-meta`,children:n.switching?`switching…`:`${e.message_count} msg${i?` · ${i}`:``}`})]},e.id)})]})}var Un={data:null,switching:!1,error:null,count:0};function Wn(e){let[t,n]=(0,Y.useState)(!0),r=(0,Y.useCallback)(t=>e==null?()=>{}:Pn(e,t),[e]),i=(0,Y.useCallback)(()=>e==null?Un:Fn(e),[e]),a=(0,Y.useSyncExternalStore)(r,i);return(0,Y.useEffect)(()=>{n(!0),e!=null&&In(e).catch(()=>{})},[e]),{activeSessionCount:a.count,sessionsOpen:t,setSessionsOpen:n}}function Gn(e){let{activeSessionCount:t,sessionsOpen:n,setSessionsOpen:r}=Wn(e.selectedInstance?.ok?e.selectedInstance.port:null),i=!e.error&&!e.loading&&e.instances.length===0&&!e.instances.some(e=>e.hidden),a=e.selectedInstance&&!e.filtered.some(t=>t.port===e.selectedInstance?.port)?[e.selectedInstance,...e.filtered]:e.filtered,o=t=>{if(t.ok){e.onPreview(t);return}e.onSelect(t)},s=e=>(0,X.jsx)(Hn,{port:e,open:n},e);return(0,X.jsxs)(X.Fragment,{children:[e.error&&(0,X.jsxs)(`section`,{className:`state error-state`,children:[`Scan failed: `,e.error]}),!e.error&&e.loading&&(0,X.jsx)(`section`,{className:`state`,children:`Scanning local Jaw instances...`}),i&&e.data?.manager&&(0,X.jsx)(At,{rangeFrom:e.data.manager.rangeFrom,rangeTo:e.data.manager.rangeTo}),!e.error&&!i&&(0,X.jsx)(mn,{instances:a,selectedPort:e.selectedInstance?.port||null,lifecycleBusyPort:e.lifecycleBusyPort,transitioningPort:e.transitioningPort,transitionAction:e.transitionAction,activityUnreadByPort:e.activityUnreadByPort,latestTitleByPort:e.latestTitleByPort,...e.busyPorts===void 0?{}:{busyPorts:e.busyPorts},showLatestActivityTitles:e.showLatestActivityTitles,showInlineLabelEditor:e.showInlineLabelEditor,showSidebarRuntimeLine:e.showSidebarRuntimeLine,showSelectedRowActions:e.showSelectedRowActions,activeSessionCount:t,activeSessionsOpen:n,onToggleActiveSessions:()=>r(e=>!e),renderActiveSessionList:s,profiles:e.profiles,getLabel:e.getLabel,formatUptime:e.formatUptime,onSelect:o,onPreview:e.onPreview,onMarkActivitySeen:e.onMarkActivitySeen,onInstanceLabelSave:e.onInstanceLabelSave,onLifecycle:e.onLifecycle})]})}function Kn(e){let t=e.count==null?``:` ${e.count}`;return(0,X.jsxs)(`button`,{type:`button`,className:`profile-chip ${e.active?`is-active`:``}`,onClick:()=>e.onToggle(e.profile.profileId),"aria-pressed":e.active,title:e.profile.homePath,children:[(0,X.jsx)(`span`,{children:e.profile.label}),t&&(0,X.jsx)(`strong`,{children:t})]})}async function qn(){let e=await fetch(`/api/dashboard/desktop-status`);if(!e.ok)throw Error(`desktop status failed: ${e.status}`);return await e.json()}function Jn(){let e=window.location.pathname+window.location.search;window.location.href=`jaw://open?path=${encodeURIComponent(e)}`}function Yn(){let e=ce(),[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(!1);return(0,Y.useEffect)(()=>{if(e)return;let t=!1;return qn().then(e=>{t||n(e)}).catch(()=>{t||i(!0)}),()=>{t=!0}},[e]),e?null:t?.inDesktop?(0,X.jsx)(`span`,{className:`desktop-status-badge`,title:`cli-jaw Desktop ${t.version}`,children:`Running in cli-jaw Desktop`}):!t&&!r?null:(0,X.jsx)(`button`,{type:`button`,className:`desktop-open-button`,onClick:Jn,title:t?.downloadUrl||`Open this dashboard path in cli-jaw Desktop`,children:`Open in Desktop App`})}function Xn(e){let t=ce(),n=e.actions;return(0,X.jsx)(`div`,{className:`command-center command-bar${t?` is-electron-titlebar`:``}`,children:(0,X.jsxs)(`div`,{className:`command-primary`,children:[e.mobileMenuButton,(0,X.jsx)(`div`,{className:`command-title`,children:e.title}),(0,X.jsx)(`div`,{className:`command-search`,children:e.search}),(0,X.jsx)(`div`,{className:`command-actions`,children:n})]})})}function Zn(e,t,n){return{feature:e,state:t,...n?{reason:n}:{}}}function Qn(){return ce()?`electron`:`web`}function $n(e){return e===`electron`?{terminal:Zn(`terminal`,`enabled`),browser:Zn(`browser`,`enabled`),folder:Zn(`folder`,`enabled`),doc:Zn(`doc`,`enabled`),diff:Zn(`diff`,`enabled`)}:{terminal:Zn(`terminal`,`disabled`,`Terminal requires the desktop PTY bridge.`),browser:Zn(`browser`,`disabled`,`Browser side panel is available in the desktop app.`),folder:Zn(`folder`,`disabled`,`Folder side panel is available in the desktop app; use the Jawsidian Notes tab on web.`),doc:Zn(`doc`,`disabled`,`Document side panel is available in the desktop app; use the Jawsidian document tab on web.`),diff:Zn(`diff`,`disabled`,`Diff side panel is available in the desktop app.`)}}function er(e){return e.state===`enabled`||e.state===`limited`}function tr(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`rect`,{x:`3`,y:`4`,width:`14`,height:`12`,rx:`1.5`}),(0,X.jsx)(`path`,{d:`M6 9l3 2-3 2`}),(0,X.jsx)(`path`,{d:`M11 13h3`})]})}function nr(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`rect`,{x:`3`,y:`4`,width:`14`,height:`12`,rx:`1.5`}),(0,X.jsx)(`path`,{d:`M13 4v12`})]})}function rr(){let e=fe(),t=me(),n=Qn();if(n!==`electron`)return null;let r=$n(n),i=r.terminal,a=r.folder,o=er(i),s=er(a),c=e.state.bottomPanel,l=c.open&&(c.activeTab??c.tabs[0])===`terminal`,u=e.effectiveRightOpen;return(0,X.jsxs)(`div`,{className:`command-panel-controls`,"aria-label":`Desktop panels`,children:[(0,X.jsx)(`button`,{className:`command-panel-toggle${l?` is-active`:``}`,type:`button`,disabled:!o,onClick:()=>{o&&(l?t.toggleBottomPanel():(t.openBottomTab(`terminal`),document.dispatchEvent(new CustomEvent(`jaw:shortcut-action`,{detail:`focusTerminal`}))))},id:le,"aria-label":`Toggle terminal panel`,"aria-pressed":l,title:i.reason??"Terminal (Ctrl+`)",children:(0,X.jsx)(tr,{})}),(0,X.jsx)(`button`,{className:`command-panel-toggle${u?` is-active`:``}`,type:`button`,disabled:!s,onClick:()=>{s&&(u?t.toggleRightPanel():t.focusOrCreateFirstRightSidebarTab(`files`))},"aria-label":`Toggle right panel`,"aria-pressed":u,title:a.reason??`Side panel (Command+B)`,children:(0,X.jsx)(nr,{})})]})}var ir=[{value:`auto`,label:`Auto`,hint:`Follow OS preference`},{value:`light`,label:`Light`,hint:`Always light theme`},{value:`dark`,label:`Dark`,hint:`Always dark theme`}];function ar(e){return(0,X.jsx)(`div`,{className:`theme-switch`,role:`radiogroup`,"aria-label":`Theme`,children:ir.map(t=>{let n=e.theme===t.value;return(0,X.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":n,title:t.hint,className:n?`is-active`:``,onClick:()=>e.onChange(t.value),children:t.label},t.value)})})}function or(e){return(0,X.jsx)(Xn,{mobileMenuButton:(0,X.jsx)(`button`,{className:`drawer-trigger command-icon-button`,type:`button`,onClick:e.onOpenDrawer,"aria-label":`Open sidebar`,children:(0,X.jsx)(`svg`,{viewBox:`0 0 20 20`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,"aria-hidden":`true`,focusable:`false`,children:(0,X.jsx)(`path`,{d:`M4 6h12M4 10h12M4 14h12`})})}),title:(0,X.jsxs)(`h1`,{className:`manager-brand-heading`,"aria-label":`CLI-JAW Dashboard`,children:[(0,X.jsx)(`img`,{className:`manager-brand-mark`,src:`/icons/mascot.png`,alt:``,width:20,height:20,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`manager-brand-wordmark`,children:`CLI-JAW`}),(0,X.jsx)(`span`,{className:`manager-brand-dash`,children:`DASH`})]}),search:(0,X.jsxs)(`div`,{className:`search-input-wrapper is-ghost`,children:[(0,X.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,stroke:`currentColor`,strokeWidth:`2`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,X.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,X.jsx)(`line`,{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`})]}),(0,X.jsx)(`input`,{value:e.query,onChange:t=>e.onQueryChange(t.target.value),placeholder:`Search port, home, CLI, model`,"aria-label":`Search instances`})]}),actions:(0,X.jsxs)(`div`,{className:`command-actions-group`,children:[(0,X.jsx)(rr,{}),(0,X.jsx)(Yn,{}),(0,X.jsx)(`button`,{type:`button`,className:`command-palette-trigger`,onClick:e.onOpenPalette,"aria-label":`Open command palette`,title:`Open command palette (⌘K / Ctrl+K)`,children:(0,X.jsx)(`span`,{"aria-hidden":`true`,children:`⌘K`})}),(0,X.jsx)(ar,{theme:e.theme,onChange:e.onThemeChange}),(0,X.jsx)(`button`,{type:`button`,className:`command-icon-button`,onClick:e.onRefresh,disabled:e.loading,"aria-label":e.loading?`Scanning`:`Refresh`,title:e.loading?`Scanning`:`Refresh`,children:(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`path`,{d:`M16 10a6 6 0 1 1-2-4.5`}),(0,X.jsx)(`path`,{d:`M16 4v4h-4`})]})})]})})}function sr(e,t){return(e.split(`/`).filter(Boolean).pop()||e).replace(/^\.?cli-jaw-(\d+)-[a-f0-9]{7,}$/i,`cli-jaw $1`).replace(/^\.?cli-jaw-(\d+)$/i,`cli-jaw $1`)||`cli-jaw ${t}`}function cr(e){if(e.label)return e.label;let t=e.instanceId||e.homeDisplay||``;return sr(t.split(`/`).filter(Boolean).pop()||t,e.port)}function lr(e){if(e==null)return`n/a`;let t=Math.floor(e/60);if(t<1)return`${Math.round(e)}s`;let n=Math.floor(t/60);return n<1?`${t}m`:`${n}h ${t%60}m`}function ur(e){let t=e.className?`help-topic-button ${e.className}`:`help-topic-button`;return(0,X.jsx)(`button`,{type:`button`,className:t,"aria-label":e.label,title:e.label,onClick:()=>e.onOpen(e.topic),children:`?`})}function dr(e){let t=e.split(/[/\\]/).filter(Boolean);return t.length<=2?e:`…/${t.slice(-2).join(`/`)}`}function fr(e){let t=e.instance,n=!!t?.ok,r=e.previewEnabled?`Preview on`:`Preview off`,i=!!(t||e.onOpenHelpTopic),a=t?.projectDirs?.filter(Boolean)??[];return(0,X.jsxs)(`div`,{className:`detail-header`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`eyebrow`,children:`Selected instance`}),(0,X.jsx)(`h2`,{children:t?cr(t):`No instance selected`}),t?(0,X.jsxs)(`div`,{className:`project-dirs${a.length?``:` is-empty`}`,children:[(0,X.jsx)(`span`,{className:`label`,children:`Project`}),a.length?a.map((e,t)=>(0,X.jsx)(`span`,{className:`project-dir`,title:e,children:dr(e)},t)):(0,X.jsx)(`span`,{className:`project-dir`,children:`Not set`}),e.onPickProject&&t.ok?(0,X.jsx)(`button`,{type:`button`,className:`project-pick-button`,disabled:e.projectPickBusy,title:`Open the folder chooser on this machine and set the project root`,onClick:()=>e.onPickProject?.(t.port),children:e.projectPickBusy?`Choosing…`:a.length?`Change`:`Choose…`}):null]}):(0,X.jsx)(`span`,{children:`Select an online instance to inspect it.`})]}),i&&(0,X.jsxs)(`div`,{className:`detail-header-actions`,children:[e.onOpenHelpTopic?(0,X.jsx)(ur,{topic:`instances`,label:`Open Instances help`,onOpen:e.onOpenHelpTopic}):null,t?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`preview-inline-status ${t.ok&&e.previewEnabled?`is-ready`:`is-unavailable`}`,"aria-label":t.ok&&e.previewEnabled?`Preview ready`:`Preview unavailable`,title:t.ok&&e.previewEnabled?`Preview ready`:`Preview unavailable`}),(0,X.jsxs)(`button`,{type:`button`,className:`preview-switch ${e.previewEnabled?`is-on`:`is-off`}`,role:`switch`,"aria-checked":e.previewEnabled,disabled:!n,onClick:()=>e.onPreviewEnabledChange(!e.previewEnabled),children:[(0,X.jsx)(`span`,{className:`preview-switch-track`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:r})]}),(0,X.jsx)(`button`,{type:`button`,className:`preview-refresh-button`,disabled:!n||!e.previewEnabled,onClick:e.onPreviewRefresh,children:`Refresh`}),(0,X.jsxs)(`a`,{className:`open-link`,href:t.url,target:`_blank`,rel:`noreferrer`,children:[(0,X.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`12`,height:`12`,stroke:`currentColor`,strokeWidth:`2`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,X.jsx)(`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`}),(0,X.jsx)(`polyline`,{points:`15 3 21 3 21 9`}),(0,X.jsx)(`line`,{x1:`10`,y1:`14`,x2:`21`,y2:`3`})]}),`Open`]})]}):null]})]})}var pr=8,mr=5;function hr(e,t,n){if(!n)return!0;let r=n.toLowerCase();return[String(e.port),t,e.url,e.workingDir,e.currentCli].some(e=>{if(!e)return!1;let t=String(e).toLowerCase();return t.startsWith(r)?!0:RegExp(`(^|[^\\p{L}\\p{N}])${gr(r)}`,`u`).test(t)})}function gr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function _r(e){let[t,n]=(0,Y.useState)(``),[r,i]=(0,Y.useState)(0),a=(0,Y.useRef)(null),o=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{e.open&&(n(``),i(0),requestAnimationFrame(()=>a.current?.focus()))},[e.open]),(0,Y.useEffect)(()=>{if(!e.open)return;function t(t){t.key===`Escape`&&(t.preventDefault(),e.onClose())}return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e.open,e.onClose]);let s=(0,Y.useMemo)(()=>e.instances.filter(n=>hr(n,e.getLabel(n),t)).slice(0,pr),[e.instances,e.getLabel,t]),c=(0,Y.useMemo)(()=>[{id:`refresh`,label:`Refresh scan`,hint:`Re-scan local ports`,run:e.onRefresh},{id:`theme`,label:`Theme: cycle (current ${e.theme})`,hint:`Auto → Light → Dark`,run:e.onCycleTheme},{id:`hidden`,label:e.showHidden?`Hide hidden instances`:`Show hidden instances`,run:e.onToggleHidden},...e.selectedInstance?[{id:`open`,label:`Open ${e.selectedInstance.url} in new tab`,run:e.onOpenSelected}]:[]].slice(0,mr),[e.onRefresh,e.theme,e.onCycleTheme,e.showHidden,e.onToggleHidden,e.selectedInstance,e.onOpenSelected]),l=(0,Y.useMemo)(()=>{let e=[];for(let t of s)e.push({kind:`instance`,instance:t});for(let t of c)e.push({kind:`action`,action:t});return e},[s,c]);(0,Y.useEffect)(()=>{r>=l.length&&i(Math.max(0,l.length-1))},[l.length,r]);function u(t){let n=l[t];n&&(n.kind===`instance`?e.onSelectInstance(n.instance):n.action.run(),e.onClose())}function d(e){e.key===`ArrowDown`?(e.preventDefault(),i(e=>Math.min(l.length-1,e+1))):e.key===`ArrowUp`?(e.preventDefault(),i(e=>Math.max(0,e-1))):e.key===`Enter`&&(e.preventDefault(),u(r))}return e.open?(0,X.jsx)(`div`,{className:`command-palette-backdrop`,role:`presentation`,onClick:e.onClose,children:(0,X.jsxs)(`div`,{className:`command-palette`,role:`dialog`,"aria-modal":`true`,"aria-label":`Command palette`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`input`,{ref:a,className:`command-palette-input`,placeholder:`Go to instance, or run an action…`,value:t,onChange:e=>{n(e.target.value),i(0)},onKeyDown:d,"aria-label":`Command query`}),(0,X.jsxs)(`div`,{className:`command-palette-list`,ref:o,children:[s.length>0&&(0,X.jsxs)(`div`,{className:`command-palette-section`,role:`group`,"aria-label":`Go to instance`,children:[(0,X.jsx)(`header`,{className:`command-palette-section-header`,children:`Go to instance`}),s.map((t,n)=>{let a=n;return(0,X.jsxs)(`button`,{type:`button`,className:a===r?`command-palette-item is-active`:`command-palette-item`,onMouseEnter:()=>i(a),onClick:()=>u(a),children:[(0,X.jsxs)(`span`,{className:`command-palette-port`,children:[`:`,t.port]}),(0,X.jsx)(`span`,{className:`command-palette-label`,children:e.getLabel(t)})]},t.port)})]}),c.length>0&&(0,X.jsxs)(`div`,{className:`command-palette-section`,role:`group`,"aria-label":`Actions`,children:[(0,X.jsx)(`header`,{className:`command-palette-section-header`,children:`Actions`}),c.map((e,t)=>{let n=s.length+t;return(0,X.jsxs)(`button`,{type:`button`,className:n===r?`command-palette-item is-active`:`command-palette-item`,onMouseEnter:()=>i(n),onClick:()=>u(n),children:[(0,X.jsx)(`span`,{className:`command-palette-label`,children:e.label}),e.hint&&(0,X.jsx)(`span`,{className:`command-palette-hint`,children:e.hint})]},e.id)})]}),l.length===0&&(0,X.jsx)(`p`,{className:`command-palette-empty`,children:`No matches.`})]}),(0,X.jsxs)(`footer`,{className:`command-palette-footer`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`kbd`,{children:`↑↓`}),` navigate`]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`kbd`,{children:`Enter`}),` select`]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`kbd`,{children:`Esc`}),` close`]})]})]})}):null}function vr(e){let t={"--activity-dock-height":`${e.activityHeight}px`};return(0,X.jsxs)(`main`,{className:`dashboard-shell manager-shell${e.sidebarCollapsed?` is-sidebar-collapsed`:``}`,style:t,children:[(0,X.jsx)(`header`,{className:`manager-command`,children:e.commandBar}),e.workspace]})}var yr=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`help-lead`,children:`실행 중인 jaw 인스턴스를 보고, 미리보기·로그·설정을 다루는 곳이에요.`}),(0,X.jsxs)(`ul`,{className:`help-bullets`,children:[(0,X.jsx)(`li`,{children:`좌측 네비게이터에서 인스턴스를 골라 우측 Workbench(Overview / Preview / Logs / Settings)에서 작업하실 수 있어요.`}),(0,X.jsx)(`li`,{children:`우측 상단 상태 점이 초록이면 온라인, 회색이면 오프라인이에요.`}),(0,X.jsx)(`li`,{children:`인스턴스에 직접 메시지를 보내실 땐 Preview 탭의 채팅 입력을 쓰세요.`}),(0,X.jsx)(`li`,{children:`Preview 채팅에 나온 Notes vault 경로를 클릭하면 Notes workspace로 이동해 해당 파일을 열 수 있어요.`})]}),(0,X.jsxs)(`div`,{className:`help-deep`,children:[(0,X.jsx)(`h4`,{children:`빠른 판단 기준`}),(0,X.jsx)(`table`,{className:`help-table`,children:(0,X.jsxs)(`tbody`,{children:[(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Preview`}),(0,X.jsx)(`td`,{children:`실제 인스턴스 화면을 보거나 메시지를 보낼 때`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Logs`}),(0,X.jsx)(`td`,{children:`응답이 멈췄거나 dispatch 실패 원인을 확인할 때`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Settings`}),(0,X.jsx)(`td`,{children:`해당 인스턴스의 CLI, 모델, 권한을 조정할 때`})]})]})})]}),(0,X.jsxs)(`p`,{className:`help-tip`,children:[`인스턴스가 안 보이시면 터미널에서 `,(0,X.jsx)(`code`,{children:`cli-jaw start`}),`로 새 jaw를 띄워보세요. 자동으로 목록에 떠요.`]})]}),br=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`help-lead`,children:`사람이 먼저 일반 칸반 블럭을 만들고, 실행 인스턴스 블럭을 그 안에 붙이는 계층형 보드예요.`}),(0,X.jsxs)(`ul`,{className:`help-bullets`,children:[(0,X.jsxs)(`li`,{children:[`레인 5개는 `,(0,X.jsx)(`strong`,{children:`Backlog / Ready / In Progress / Review / Done`}),` 순서예요. Backlog는 아직 commit 전 옵션, Ready는 바로 pull 가능한 작업이에요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`Overall`}),`은 5열 전체 보드이고, 사이드바에서 각 레인을 누르면 해당 레인만 보는 detail 화면으로 전환돼요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`Done`}),`은 Overall에서 최근 4개만 full card로 보여주고, 나머지는 `,(0,X.jsx)(`strong`,{children:`+ N more`}),`를 눌러 Done detail 화면에서 2줄 row로 확인해요.`]}),(0,X.jsxs)(`li`,{children:[`각 레인 하단의 `,(0,X.jsx)(`strong`,{children:`+ Add task`}),`로 일반 칸반 블럭을 만들고, 그 블럭 제목에 쿼리나 작업 메모를 적으시면 돼요.`]}),(0,X.jsxs)(`li`,{children:[`좌측 `,(0,X.jsx)(`strong`,{children:`Running`}),` 섹션에는 현재 실행 중인 인스턴스만 인스턴스 블럭으로 보여요.`]}),(0,X.jsx)(`li`,{children:`인스턴스 블럭을 일반 칸반 블럭 안의 드롭 영역으로 끌어 넣으면 내부 자식 블럭으로 병합돼요. 인스턴스 실행에는 영향 없어요.`}),(0,X.jsxs)(`li`,{children:[`일반 칸반 블럭은 직접 드래그해서 다른 레인으로 옮길 수 있고, `,(0,X.jsx)(`strong`,{children:`Move`}),` / `,(0,X.jsx)(`strong`,{children:`Delete`}),`도 유지돼요.`]})]}),(0,X.jsxs)(`div`,{className:`help-deep`,children:[(0,X.jsx)(`h4`,{children:`상태를 나눠 쓰는 법`}),(0,X.jsx)(`table`,{className:`help-table`,children:(0,X.jsxs)(`tbody`,{children:[(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Ready`}),(0,X.jsx)(`td`,{children:`바로 구현하거나 검증할 수 있는 작업`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Review`}),(0,X.jsx)(`td`,{children:`직원 감사, Pro 검증, 수동 smoke가 필요한 작업`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Done`}),(0,X.jsx)(`td`,{children:`커밋, 푸시, 이슈 close까지 끝난 작업`})]})]})})]}),(0,X.jsx)(`p`,{className:`help-tip`,children:`인스턴스가 없어도 일반 칸반 블럭은 계속 남아요. 쿼리·아이디어·작업 단위를 먼저 적고, 필요할 때만 실행 인스턴스를 붙이면 돼요.`})]}),xr=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`help-lead`,children:`매니저가 1분마다 틱을 돌면서 대시보드에 등록된 자동화 작업을 일괄 dispatch 해주는 곳이에요.`}),(0,X.jsxs)(`ul`,{className:`help-bullets`,children:[(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`Today / Upcoming / Recurring / Blocked`}),` 그룹으로 정리되고, `,(0,X.jsx)(`code`,{children:`cron`}),`·`,(0,X.jsx)(`code`,{children:`runAt`}),`·target port를 함께 저장해요.`]}),(0,X.jsx)(`li`,{children:`Run 버튼으로 즉시 dispatch, 대상 인스턴스가 바쁘면 자동 큐잉이에요. last/next 컬럼으로 실행 이력이 보여요.`}),(0,X.jsxs)(`li`,{children:[`예전엔 인스턴스마다 자기 `,(0,X.jsx)(`code`,{children:`heartbeat.json`}),`을 setInterval로 돌리던 구조였는데, 지금은 `,(0,X.jsx)(`strong`,{children:`매니저가 단일 ticker`}),`로 돌려요. heartbeat.json은 legacy로만 표시되고 자동 실행은 안 돼요.`]})]}),(0,X.jsxs)(`div`,{className:`help-deep`,children:[(0,X.jsx)(`h4`,{children:`실패를 볼 때`}),(0,X.jsx)(`table`,{className:`help-table`,children:(0,X.jsxs)(`tbody`,{children:[(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`queued`}),(0,X.jsx)(`td`,{children:`대상 인스턴스가 바빠서 대기 중`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`blocked`}),(0,X.jsx)(`td`,{children:`비활성화했거나 실행 조건이 아직 맞지 않음`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`last/next`}),(0,X.jsx)(`td`,{children:`최근 실행 결과와 다음 실행 예측을 확인하는 기준`})]})]})})]}),(0,X.jsx)(`p`,{className:`help-tip`,children:`새 작업은 여기서 만들고, 기존 heartbeat job은 같은 cron으로 옮겨 등록하시면 돼요. 마이그레이션 자동화는 추후 추가됩니다.`})]}),Sr=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`help-lead`,children:[(0,X.jsx)(`code`,{children:`~/.cli-jaw-dashboard/notes/`}),`의 마크다운 파일을 직접 편집하는 노트장이에요.`]}),(0,X.jsxs)(`ul`,{className:`help-bullets`,children:[(0,X.jsxs)(`li`,{children:[`좌측 트리에서 파일 선택, 우측에서 `,(0,X.jsx)(`strong`,{children:`Raw / Preview / WYSIWYG`}),` 모드로 편집하실 수 있어요.`]}),(0,X.jsxs)(`li`,{children:[`Instances Preview 채팅에서 vault 경로(예: `,(0,X.jsx)(`code`,{children:`~/.cli-jaw-dashboard/notes/foo.md`}),` 또는 `,(0,X.jsx)(`code`,{children:`daily/foo.md`}),`)를 `,(0,X.jsx)(`strong`,{children:`클릭`}),`하면 Notes 탭으로 이동하고 해당 파일이 열려요. 자동 전환은 없고 클릭할 때만 이동합니다.`]}),(0,X.jsxs)(`li`,{children:[`vault 밖 경로(예: 프로젝트 `,(0,X.jsx)(`code`,{children:`.ts`}),` 파일)는 기존처럼 Finder로 열려요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`kbd`,{children:`⌘/Ctrl + S`}),`로 저장, `,(0,X.jsx)(`kbd`,{children:`⌘/Ctrl + E`}),`로 모드 순환 전환이에요.`]}),(0,X.jsx)(`li`,{children:`파일이 외부에서 바뀌면 충돌 알림이 떠요 — Reload / Overwrite / Keep local 중 선택하세요.`})]}),(0,X.jsxs)(`p`,{className:`help-tip`,children:[`💡 좌측 트리 상단 `,(0,X.jsx)(`strong`,{children:`+ New`}),`로 첫 노트를 만들어 보세요. 폴더는 `,(0,X.jsx)(`code`,{children:`folder/note.md`}),` 처럼 한 번에 만드실 수 있어요.`]})]}),Cr=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`help-lead`,children:`Jaw Reminders 스냅샷을 대시보드에서 읽고 확인하는 미러 화면이에요.`}),(0,X.jsxs)(`ul`,{className:`help-bullets`,children:[(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`All / Focused / Scheduled / High / Done`}),` 보기로 현재 reminder 상태를 훑어볼 수 있어요.`]}),(0,X.jsx)(`li`,{children:`Refresh는 외부 Jaw Reminders 스냅샷을 다시 읽어서 대시보드용 row로 반영해요.`}),(0,X.jsx)(`li`,{children:`원본 reminder 저장소가 없거나 형식이 맞지 않아도 대시보드는 기존 미러 데이터를 유지하고 상태 메시지만 보여줘요.`})]}),(0,X.jsxs)(`div`,{className:`help-deep`,children:[(0,X.jsx)(`h4`,{children:`Matrix 보기`}),(0,X.jsx)(`table`,{className:`help-table`,children:(0,X.jsxs)(`tbody`,{children:[(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Top Priority`}),(0,X.jsx)(`td`,{children:`지금 먼저 처리할 3개를 따로 고정`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Important`}),(0,X.jsx)(`td`,{children:`중요하지만 급하지 않은 장기 작업`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Waiting`}),(0,X.jsx)(`td`,{children:`다른 사람, 직원, 외부 검증을 기다리는 작업`})]})]})})]}),(0,X.jsx)(`p`,{className:`help-tip`,children:`Reminders는 실험 기능이라 개발 모드 또는 실험 플래그가 켜진 빌드에서만 보여요.`})]}),wr=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`help-lead`,children:`대시보드 외형과 동작 옵션을 조정하는 곳이에요.`}),(0,X.jsxs)(`ul`,{className:`help-bullets`,children:[(0,X.jsx)(`li`,{children:`사이드바 폭, 워드랩, 테마 같은 표시 옵션을 바꾸실 수 있어요.`}),(0,X.jsxs)(`li`,{children:[`인스턴스 자체 설정이 아니라 `,(0,X.jsx)(`strong`,{children:`이 대시보드 UI의 환경설정`}),`이에요.`]}),(0,X.jsx)(`li`,{children:`변경 사항은 즉시 저장돼요.`})]}),(0,X.jsxs)(`div`,{className:`help-deep`,children:[(0,X.jsx)(`h4`,{children:`설정 범위`}),(0,X.jsx)(`table`,{className:`help-table`,children:(0,X.jsxs)(`tbody`,{children:[(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Display`}),(0,X.jsx)(`td`,{children:`목록, 언어, 단축키 같은 dashboard UI 선호도`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Activity`}),(0,X.jsx)(`td`,{children:`최근 작업 제목이 어떤 인스턴스에서 준비됐는지 확인`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Instance settings`}),(0,X.jsx)(`td`,{children:`개별 인스턴스 동작은 Instances workspace에서 수정`})]})]})})]}),(0,X.jsxs)(`p`,{className:`help-tip`,children:[`인스턴스 동작을 바꾸시려면 여기가 아니라 `,(0,X.jsx)(`strong`,{children:`Instances → 해당 인스턴스 → Settings 탭`}),`으로 가세요.`]})]}),Tr=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`help-lead`,children:`반복 작업을 줄이는 Manager 전역 단축키예요.`}),(0,X.jsxs)(`ul`,{className:`help-bullets`,children:[(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`kbd`,{children:`?`}),`는 이 도움말을 열어요. 입력창, 노트 에디터, WYSIWYG 편집 중에는 글자 입력을 방해하지 않아요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`kbd`,{children:xe(I.focusInstances)}),`는 Instances workspace로 이동해요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`kbd`,{children:xe(I.focusActiveSession)}),`는 선택된 인스턴스의 Preview 탭으로 이동해요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`kbd`,{children:xe(I.focusNotes)}),`는 Notes workspace로 이동해요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`kbd`,{children:xe(I.previousInstance)}),` / `,(0,X.jsx)(`kbd`,{children:xe(I.nextInstance)}),`는 현재 필터된 인스턴스 목록에서 이전/다음 행을 선택해요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`kbd`,{children:`Alt+1`}),` … `,(0,X.jsx)(`kbd`,{children:`Alt+9`}),`는 렌더된 사이드바 행으로 점프하고, Alt를 200ms 누르면 행 오른쪽에 점프 힌트가 떠요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`kbd`,{children:`⌘/Ctrl + S`}),`는 Notes와 Settings처럼 저장 가능한 화면에서 현재 편집 내용을 저장해요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`kbd`,{children:`⌘/Ctrl + E`}),`는 Notes 편집 모드를 순환해요.`]}),(0,X.jsx)(`li`,{children:`Manager 단축키는 Dashboard settings에서 켜고 끄거나 keymap을 바꿀 수 있어요.`}),(0,X.jsx)(`li`,{children:`Preview 탭을 보는 동안 새 activity는 읽음으로 처리되고, 다른 탭에 있을 때는 Activity Dock에 쌓여요.`})]}),(0,X.jsxs)(`div`,{className:`help-deep`,children:[(0,X.jsx)(`h4`,{children:`충돌이 날 때`}),(0,X.jsx)(`table`,{className:`help-table`,children:(0,X.jsxs)(`tbody`,{children:[(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`입력 중`}),(0,X.jsx)(`td`,{children:`글자 입력을 우선하고 전역 shortcut은 실행하지 않음`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`브라우저 충돌`}),(0,X.jsx)(`td`,{children:`Dashboard settings에서 keymap을 바꾸는 것이 안전함`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`도움말`}),(0,X.jsxs)(`td`,{children:[(0,X.jsx)(`kbd`,{children:`?`}),`는 현재 workspace 도움말과 shortcut 도움말의 진입점`]})]})]})})]}),(0,X.jsx)(`p`,{className:`help-tip`,children:`단축키는 브라우저 기본 단축키와 에디터 입력을 우선합니다.`})]}),Er=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`help-lead`,children:`jaw는 Boss가 직접 처리할지, Employee에게 보낼지 상황에 따라 나눠요.`}),(0,X.jsxs)(`ul`,{className:`help-bullets`,children:[(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`Boss`}),`는 현재 대화의 주 작업자예요. 단일 파일 수정, 상태 확인, GitHub 정리는 보통 Boss가 직접 처리해요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`Employee`}),`는 `,(0,X.jsx)(`code`,{children:`cli-jaw dispatch`}),`로 보내는 독립 작업자예요. Backend, Frontend, Docs 같은 역할별 검증에 씁니다.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`PABCD`}),`에서는 A phase가 plan audit, B phase가 read-only verification 중심이에요. 구현은 Boss가 직접 합니다.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`$computer-use`}),` 요청은 desktop-control 규칙을 따라 real desktop 또는 browser automation 경로로 라우팅돼요.`]})]}),(0,X.jsx)(`p`,{className:`help-tip`,children:`직원이 다른 repo로 착각하지 않도록 dispatch task에는 현재 repo 절대경로를 함께 넣는 게 원칙이에요.`})]}),Dr=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`help-lead`,children:`Process 상태는 인스턴스 실행과 Manager가 관리하는 preview/runtime 상태를 구분해서 봐야 해요.`}),(0,X.jsxs)(`ul`,{className:`help-bullets`,children:[(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`online`}),`은 인스턴스 health check가 통과한 상태예요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`offline / timeout / error`}),`는 프로세스가 없거나, 응답이 늦거나, health check가 실패한 상태예요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`managed`}),`는 Manager가 띄우거나 복구 대상으로 추적하는 서버예요.`]}),(0,X.jsx)(`li`,{children:`탭 전환 후 Preview가 다시 붙을 수 있지만, 인스턴스의 실제 실행 여부는 health/status 쪽을 기준으로 보세요.`})]}),(0,X.jsx)(`p`,{className:`help-tip`,children:`Process UI가 비어 보이면 먼저 Refresh로 registry와 health 상태를 다시 읽어보세요.`})]}),Or=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`help-lead`,children:`실행 상태를 바꾸는 버튼은 현재 선택한 인스턴스나 Manager-managed 프로세스에 영향을 줘요.`}),(0,X.jsxs)(`ul`,{className:`help-bullets`,children:[(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`Stop`}),`은 대상 인스턴스를 중지해요. service-owned 인스턴스는 persistent service 제거까지 포함될 수 있어요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`Restart`}),`는 새 실행으로 바뀌므로 uptime과 elapsed time 판단 기준이 다시 시작돼요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`Stop all managed`}),`는 Manager가 추적 중인 서버들을 한 번에 중지해요. 외부에서 직접 띄운 프로세스는 대상으로 삼지 않아요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`Adopt/recover`}),`는 남아 있는 managed process 기록을 다시 연결하려는 복구 작업이에요.`]})]}),(0,X.jsx)(`p`,{className:`help-tip`,children:`위험 작업은 가능한 한 확인창을 거치며, 진행 후 상태가 애매하면 Refresh로 실제 health를 확인하세요.`})]}),kr={instances:{title:`Instances`,subtitle:`인스턴스 운영`,body:yr},board:{title:`Board`,subtitle:`Cross-instance Kanban`,body:br},schedule:{title:`Schedule`,subtitle:`시간 기반 작업`,body:xr},reminders:{title:`Reminders`,subtitle:`Jaw Reminders mirror`,body:Cr},notes:{title:`Notes`,subtitle:`마크다운 노트`,body:Sr},settings:{title:`Settings`,subtitle:`대시보드 설정`,body:wr},shortcuts:{title:`Shortcuts`,subtitle:`전역 키보드 도움말`,body:Tr},routing:{title:`Routing`,subtitle:`Boss / Employee 작업 흐름`,body:Er},processLifecycle:{title:`Process lifecycle`,subtitle:`인스턴스와 managed process 상태`,body:Dr},dangerousActions:{title:`Dangerous actions`,subtitle:`중지·재시작·복구 작업 영향`,body:Or}};function Ar({open:e,topic:t,onClose:n}){let r=(0,Y.useRef)(null);if((0,Y.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&n()};return document.addEventListener(`keydown`,t),r.current?.focus(),()=>document.removeEventListener(`keydown`,t)},[e,n]),!e)return null;let i=kr[t];return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`help-drawer-overlay`,onClick:n,"aria-hidden":`true`}),(0,X.jsxs)(`aside`,{className:`help-drawer`,role:`dialog`,"aria-modal":`true`,"aria-label":`${i.title} help`,children:[(0,X.jsxs)(`header`,{className:`help-drawer-header`,children:[(0,X.jsxs)(`div`,{className:`help-drawer-title`,children:[(0,X.jsx)(`span`,{className:`help-drawer-eyebrow`,children:`현재 모드`}),(0,X.jsx)(`h3`,{children:i.title}),(0,X.jsx)(`span`,{className:`help-drawer-subtitle`,children:i.subtitle})]}),(0,X.jsx)(`button`,{ref:r,type:`button`,className:`help-drawer-close`,onClick:n,"aria-label":`Close help`,children:`×`})]}),(0,X.jsx)(`div`,{className:`help-drawer-body`,children:i.body}),(0,X.jsx)(`footer`,{className:`help-drawer-footer`,children:(0,X.jsx)(`span`,{children:`사이드바 도움말은 현재 모드를 따르고, ? 키는 단축키 도움말을 열어요.`})})]})]})}function jr(e){switch(e.kind){case`scan-completed`:return{at:e.at,source:`scan`,message:`range ${e.from}-${e.to}, ${e.reachable} reachable`};case`scan-failed`:return{at:e.at,source:`error`,message:e.reason};case`lifecycle-result`:return{at:e.at,source:e.action,message:`:${e.port} ${e.status}`};case`health-changed`:return{at:e.at,source:`health`,message:`:${e.port} ${e.from} → ${e.to}`};case`instance-message`:{let t=e.title?.trim();return{at:e.at,source:`:${e.port}`,message:`${e.role}: ${t||`message #${e.messageId}`}`}}case`version-mismatch`:return{at:e.at,source:`version`,message:`:${e.port} ${e.expected||`?`} → ${e.seen}`};case`port-collision`:return{at:e.at,source:`collision`,message:`:${e.port} pids ${e.pids.join(`, `)}`};default:return{at:new Date().toISOString(),source:`event`,message:`unknown event`}}}var Mr={now:`Now`,earlier:`Earlier today`,yesterday:`Yesterday`,older:`Older`},Nr=[`now`,`earlier`,`yesterday`,`older`],Pr=3e5;function Fr(e,t){return typeof e==`string`?{at:t,message:e}:`kind`in e?jr(e):e}function Ir(e,t){let n=Date.parse(e);if(Number.isNaN(n))return`older`;if(t.getTime()-n<=Pr)return`now`;let r=new Date(t);if(r.setHours(0,0,0,0),n>=r.getTime())return`earlier`;let i=new Date(r);return i.setDate(i.getDate()-1),n>=i.getTime()?`yesterday`:`older`}function Lr(e,t){let n=new Date(e);return Number.isNaN(n.getTime())?`—`:t===`now`||t===`earlier`?n.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):t===`yesterday`?`Yesterday ${n.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`:n.toLocaleDateString([],{month:`short`,day:`numeric`})}function Rr(e){let t=(0,Y.useMemo)(()=>{let t=new Date,n=t.toISOString(),r={now:[],earlier:[],yesterday:[],older:[]};for(let i of e.entries){let e=Fr(i,n),a=Ir(e.at,t);r[a].push({...e,_bucket:a})}return r},[e.entries]);return e.entries.length===0?(0,X.jsx)(`div`,{className:`activity-list activity-list-empty`,role:`status`,children:(0,X.jsx)(`p`,{children:e.emptyMessage||`Activity will appear here as scans, lifecycle changes, and registry updates happen.`})}):(0,X.jsx)(`div`,{className:`activity-list`,role:`list`,"aria-label":`Recent activity grouped by time`,children:Nr.map(e=>{let n=t[e];return n.length===0?null:(0,X.jsxs)(`section`,{className:`activity-group`,"aria-label":Mr[e],children:[(0,X.jsx)(`header`,{className:`activity-group-header`,children:Mr[e]}),n.map((t,n)=>(0,X.jsxs)(`article`,{className:`activity-entry`,role:`listitem`,children:[(0,X.jsx)(`time`,{className:`activity-entry-time`,dateTime:t.at,children:Lr(t.at,t._bucket)}),t.source&&(0,X.jsx)(`span`,{className:`activity-entry-source`,children:t.source}),(0,X.jsx)(`p`,{className:`activity-entry-message`,children:t.message})]},`${e}-${n}`))]},e)})})}var zr=88,Br=320;function Vr(e){return Math.min(Br,Math.max(zr,Math.round(e)))}function Hr(e){let t=(0,Y.useRef)(null),{onHeightChange:n}=e,r=Ur(e);(0,Y.useEffect)(()=>{function e(e){let r=t.current;r&&n(Vr(r.startHeight+r.startY-e.clientY))}function r(){t.current=null,document.body.classList.remove(`is-resizing-activity`)}return document.addEventListener(`pointermove`,e),document.addEventListener(`pointerup`,r),()=>{document.removeEventListener(`pointermove`,e),document.removeEventListener(`pointerup`,r),document.body.classList.remove(`is-resizing-activity`)}},[n]);function i(n){e.collapsed||(n.preventDefault(),t.current={startY:n.clientY,startHeight:e.height},document.body.classList.add(`is-resizing-activity`))}return(0,X.jsxs)(`aside`,{className:`activity-dock ${e.collapsed?`is-collapsed`:``}`,"aria-label":`Activity dock`,children:[(0,X.jsx)(`button`,{className:`activity-resize-handle`,type:`button`,"aria-label":`Resize activity dock`,title:`Resize activity dock`,onPointerDown:i,disabled:e.collapsed}),(0,X.jsxs)(`div`,{className:`activity-header`,children:[(0,X.jsx)(`span`,{children:`Activity`}),(0,X.jsx)(`button`,{type:`button`,onClick:e.onToggle,children:e.collapsed?`Expand`:`Collapse`})]}),!e.collapsed&&(0,X.jsx)(Rr,{entries:r})]})}function Ur(e){return(0,Y.useMemo)(()=>{let t=[];if(e.events&&e.events.length>0)for(let n of e.events)t.push(n);let n=new Date().toISOString();return e.error&&t.push({at:n,source:`error`,message:e.error}),e.registryMessage&&t.push({at:n,source:`registry`,message:e.registryMessage}),e.lifecycleMessage&&t.push({at:n,source:`lifecycle`,message:e.lifecycleMessage}),t.length===0&&t.push({at:n,source:`scan`,message:e.loading?`scanning local ports`:`no recent activity`}),t},[e.events,e.loading,e.error,e.registryMessage,e.lifecycleMessage])}function Wr(e){let{children:t,onClose:n,open:r}=e,i=(0,Y.useRef)(null),a=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{if(r)return a.current=document.activeElement,i.current?.focus(),()=>a.current?.focus()},[r]),(0,Y.useEffect)(()=>{if(!r)return;function e(e){e.key===`Escape`&&n()}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[n,r]),r?(0,X.jsx)(`div`,{className:`drawer-backdrop`,onClick:n,children:(0,X.jsxs)(`aside`,{className:`instance-drawer`,role:`dialog`,"aria-modal":`true`,"aria-label":`Instance drawer`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`drawer-header`,children:[(0,X.jsx)(`span`,{children:`Instances`}),(0,X.jsx)(`button`,{ref:i,type:`button`,onClick:n,children:`Close`})]}),(0,X.jsxs)(`div`,{className:`drawer-body`,children:[e.profileFilters&&(0,X.jsx)(`div`,{className:`drawer-profile-filters`,children:e.profileFilters}),t]})]})}):null}function Gr(e){return(0,Y.useEffect)(()=>{let e=Xt({delayMs:200,onVisibilityChange:tn}),t=t=>{e.sync(nn(t))},n=t=>{e.sync(nn(t))};return window.addEventListener(`keydown`,t),window.addEventListener(`keyup`,n),()=>{window.removeEventListener(`keydown`,t),window.removeEventListener(`keyup`,n),e.dispose(),tn(!1)}},[]),e.collapsed?(0,X.jsx)(`div`,{className:`instance-navigator is-collapsed`,children:e.children}):(0,X.jsxs)(`section`,{className:`instance-navigator`,"aria-label":`Instance navigator`,children:[(0,X.jsxs)(`header`,{className:`instance-navigator-header`,children:[(0,X.jsx)(`strong`,{children:`Instances`}),e.hiddenCount>0?(0,X.jsxs)(`span`,{children:[e.hiddenCount,` hidden`]}):null,(0,X.jsxs)(`label`,{className:`instance-navigator-search`,children:[(0,X.jsx)(`span`,{className:`visually-hidden`,children:`Search instances`}),(0,X.jsx)(`input`,{id:`manager-sidebar-search`,value:e.query,placeholder:`Search instances`,"aria-label":`Search instances`,onChange:t=>e.onQueryChange(t.currentTarget.value),onKeyDown:t=>{t.nativeEvent.isComposing||t.keyCode===229||t.key===`Escape`&&(t.preventDefault(),e.onQueryChange(``))}})]})]}),(0,X.jsx)(`div`,{className:`instance-navigator-scroll`,onKeyDown:t=>an(t.nativeEvent,t.currentTarget,e.onSelectPort),children:e.children})]})}function Kr(e){return(0,X.jsxs)(`div`,{className:`mobile-nav-actions`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:e.onOpenInstances,children:`Instances`}),(0,X.jsx)(`button`,{type:`button`,className:e.activeTab===`preview`?`is-active`:``,onClick:()=>e.onSelectTab(`preview`),children:`Preview`}),(0,X.jsx)(`button`,{type:`button`,onClick:e.onToggleActivity,children:`Activity`}),(0,X.jsx)(`button`,{type:`button`,className:e.activeTab===`settings`?`is-active`:``,onClick:()=>e.onSelectTab(`settings`),children:`More`})]})}function qr({direction:e}){return(0,X.jsx)(`svg`,{className:`rail-collapse-chevron`,viewBox:`0 0 16 20`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:(0,X.jsx)(`polyline`,{points:e===`left`?`11 4 5 10 11 16`:`5 4 11 10 5 16`})})}function Jr(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`rect`,{x:`3`,y:`4`,width:`14`,height:`10`,rx:`1.5`}),(0,X.jsx)(`path`,{d:`M8 17h4M10 14v3`})]})}function Yr(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`path`,{d:`M6 3h6l3 3v11H6z`}),(0,X.jsx)(`path`,{d:`M12 3v4h3M8 10h5M8 13h5`})]})}function Xr(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`rect`,{x:`3`,y:`4`,width:`14`,height:`12`,rx:`1.5`}),(0,X.jsx)(`path`,{d:`M7 4v12M13 4v12`})]})}function Zr(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`rect`,{x:`3`,y:`5`,width:`14`,height:`12`,rx:`1.5`}),(0,X.jsx)(`path`,{d:`M3 9h14M7 3v4M13 3v4`})]})}function Qr(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`path`,{d:`M5 4h10v13H5z`}),(0,X.jsx)(`path`,{d:`M8 2v4M12 2v4M8 10h4M8 13h3`})]})}function $r(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`}),(0,X.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`})]})}function ei(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`circle`,{cx:`10`,cy:`10`,r:`7`}),(0,X.jsx)(`path`,{d:`M7.6 7.6a2.4 2.4 0 0 1 4.8 0c0 1.4-1.6 1.7-2.2 2.5-.3.4-.3.8-.3 1.2`}),(0,X.jsx)(`circle`,{cx:`10`,cy:`14.2`,r:`0.6`,fill:`currentColor`,stroke:`none`})]})}function ti(e){let t=!e.collapsed,n=t?`Collapse navigation`:`Expand navigation`;return(0,X.jsxs)(`div`,{className:`sidebar-rail`,children:[(0,X.jsx)(`button`,{className:`rail-collapse-button`,type:`button`,onClick:e.onToggleSidebar,"aria-label":n,"aria-expanded":t,"aria-pressed":e.collapsed,"aria-controls":`manager-sidebar-list`,title:n,children:(0,X.jsx)(qr,{direction:t?`left`:`right`})}),(0,X.jsx)(`button`,{className:`rail-button rail-workspace-button${e.mode===`instances`?` is-active`:``}`,type:`button`,onClick:()=>e.onModeChange(`instances`),"aria-label":`Instances`,"aria-pressed":e.mode===`instances`,title:`Instances`,children:(0,X.jsx)(Jr,{})}),(0,X.jsx)(`button`,{className:`rail-button rail-workspace-button${e.mode===`board`?` is-active`:``}`,type:`button`,onClick:()=>e.onModeChange(`board`),"aria-label":`Board`,"aria-pressed":e.mode===`board`,title:`Board`,children:(0,X.jsx)(Xr,{})}),e.scheduleWorkspaceEnabled?(0,X.jsx)(`button`,{className:`rail-button rail-workspace-button${e.mode===`schedule`?` is-active`:``}`,type:`button`,onClick:()=>e.onModeChange(`schedule`),"aria-label":`Schedule`,"aria-pressed":e.mode===`schedule`,title:`Schedule`,children:(0,X.jsx)(Zr,{})}):null,e.remindersWorkspaceEnabled?(0,X.jsx)(`button`,{className:`rail-button rail-workspace-button${e.mode===`reminders`?` is-active`:``}`,type:`button`,onClick:()=>e.onModeChange(`reminders`),"aria-label":`Reminders`,"aria-pressed":e.mode===`reminders`,title:`Reminders`,children:(0,X.jsx)(Qr,{})}):null,(0,X.jsx)(`button`,{className:`rail-button rail-workspace-button${e.mode===`notes`?` is-active`:``}`,type:`button`,onClick:()=>e.onModeChange(`notes`),"aria-label":`Notes`,"aria-pressed":e.mode===`notes`,title:`Notes`,children:(0,X.jsx)(Yr,{})}),(0,X.jsx)(`button`,{className:`rail-button rail-workspace-button${e.mode===`settings`?` is-active`:``}`,type:`button`,onClick:()=>e.onModeChange(`settings`),"aria-label":`Dashboard settings`,"aria-pressed":e.mode===`settings`,title:`Dashboard settings`,children:(0,X.jsx)($r,{})}),(0,X.jsx)(`div`,{className:`rail-spacer`,"aria-hidden":`true`}),(0,X.jsx)(`button`,{className:`rail-button rail-help-button${e.helpOpen?` is-active`:``}`,type:`button`,onClick:e.onToggleHelp,"aria-label":`Help guide`,"aria-pressed":e.helpOpen,"aria-expanded":e.helpOpen,title:`Help (?)`,children:(0,X.jsx)(ei,{})}),(0,X.jsx)(`span`,{className:`rail-status-dot`,"aria-label":`${e.onlineCount} online instances`})]})}var ni=[`overview`,`preview`,`logs`];function ri(e){return e[0].toUpperCase()+e.slice(1)}function ii(e){return(0,X.jsxs)(`section`,{className:`workbench workbench-${e.mode}`,"aria-label":`Selected instance workbench`,children:[(0,X.jsxs)(`div`,{className:`workbench-header`,children:[e.header,(0,X.jsxs)(`div`,{className:`workbench-mode-bar`,children:[(0,X.jsx)(`div`,{className:`workbench-mode-tabs`,role:`tablist`,"aria-label":`Workbench modes`,onKeyDown:t=>{if(t.key!==`ArrowRight`&&t.key!==`ArrowLeft`)return;let n=ni[(ni.indexOf(e.mode)+(t.key===`ArrowRight`?1:ni.length-1))%ni.length];t.preventDefault(),e.onModeChange(n),t.currentTarget.querySelector(`[data-mode="${n}"]`)?.focus()},children:ni.map(t=>(0,X.jsx)(`button`,{type:`button`,role:`tab`,id:`workbench-tab-${t}`,"data-mode":t,"aria-selected":e.mode===t,"aria-controls":`workbench-panel-${t}`,tabIndex:e.mode===t?0:-1,className:e.mode===t?`is-active`:``,onClick:()=>e.onModeChange(t),children:ri(t)},t))}),e.modeActions]})]}),(0,X.jsxs)(`div`,{className:`workbench-body`,children:[e.mode===`overview`&&(0,X.jsx)(`div`,{id:`workbench-panel-overview`,role:`tabpanel`,"aria-labelledby":`workbench-tab-overview`,className:`workbench-panel workbench-panel-overview`,children:e.overview},`overview`),(0,X.jsx)(`div`,{id:`workbench-panel-preview`,role:`tabpanel`,"aria-labelledby":`workbench-tab-preview`,className:`workbench-panel workbench-panel-preview`,hidden:e.mode!==`preview`,"aria-hidden":e.mode!==`preview`,"data-preview-host":`persistent`,children:e.preview},`preview`),e.mode===`logs`&&(0,X.jsx)(`div`,{id:`workbench-panel-logs`,role:`tabpanel`,"aria-labelledby":`workbench-tab-logs`,className:`workbench-panel workbench-panel-logs`,children:e.logs},`logs`)]})]})}function ai(e){let t=(0,Y.useRef)(!1),n=(0,Y.useRef)(0),r=(0,Y.useRef)(0),i=(0,Y.useRef)(!1),a=(0,Y.useRef)(e.onDelta),o=(0,Y.useRef)(e.onEnd),[s,c]=(0,Y.useState)(!1),{direction:l}=e;(0,Y.useEffect)(()=>{a.current=e.onDelta,o.current=e.onEnd},[e.onDelta,e.onEnd]);let u=(0,Y.useCallback)((e,o)=>{if(!t.current)return;let s=l===`horizontal`?e:o;if(!i.current){if(Math.abs(s-r.current)<=2)return;i.current=!0}let c=s-n.current;n.current=s,c!==0&&a.current(c)},[l]),d=(0,Y.useCallback)(e=>{t.current&&(e.preventDefault(),u(e.clientX,e.clientY))},[u]),f=(0,Y.useCallback)(e=>{t.current&&(e.preventDefault(),u(e.clientX,e.clientY))},[u]),p=(0,Y.useCallback)(()=>{t.current&&(t.current=!1,c(!1),document.body.classList.remove(`is-resizing-horizontal`,`is-resizing-vertical`),o.current?.())},[]);(0,Y.useEffect)(()=>{let e={capture:!0};return document.addEventListener(`pointermove`,d,e),document.addEventListener(`pointerup`,p,e),document.addEventListener(`pointercancel`,p,e),document.addEventListener(`mousemove`,f,e),document.addEventListener(`mouseup`,p,e),window.addEventListener(`pointermove`,d,e),window.addEventListener(`pointerup`,p,e),window.addEventListener(`pointercancel`,p,e),window.addEventListener(`mousemove`,f,e),window.addEventListener(`mouseup`,p,e),window.addEventListener(`blur`,p),()=>{document.removeEventListener(`pointermove`,d,e),document.removeEventListener(`pointerup`,p,e),document.removeEventListener(`pointercancel`,p,e),document.removeEventListener(`mousemove`,f,e),document.removeEventListener(`mouseup`,p,e),window.removeEventListener(`pointermove`,d,e),window.removeEventListener(`pointerup`,p,e),window.removeEventListener(`pointercancel`,p,e),window.removeEventListener(`mousemove`,f,e),window.removeEventListener(`mouseup`,p,e),window.removeEventListener(`blur`,p),document.body.classList.remove(`is-resizing-horizontal`,`is-resizing-vertical`)}},[f,d,p]);function m(e){e.preventDefault(),e.stopPropagation(),e.currentTarget.setPointerCapture(e.pointerId),g(e.clientX,e.clientY)}function h(e){e.preventDefault(),e.stopPropagation(),g(e.clientX,e.clientY)}function g(e,a){t.current=!0,i.current=!1,c(!0),r.current=l===`horizontal`?e:a,n.current=r.current,document.body.classList.add(l===`horizontal`?`is-resizing-horizontal`:`is-resizing-vertical`)}function _(e){e.preventDefault(),u(e.clientX,e.clientY)}function v(e){e.preventDefault(),p()}function y(e){e.preventDefault(),u(e.clientX,e.clientY)}function b(e){e.preventDefault(),p()}function x(e){if(e.nativeEvent.isComposing||e.keyCode===229||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return;let t=l===`horizontal`?`ArrowLeft`:`ArrowUp`,n=l===`horizontal`?`ArrowRight`:`ArrowDown`;(e.key===t||e.key===n)&&(e.preventDefault(),a.current(e.key===t?-10:10),o.current?.())}return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{role:`separator`,tabIndex:0,className:`panel-resizer panel-resizer-${l} ${e.className??``}`,"aria-label":e.ariaLabel??`Resize ${l===`horizontal`?`width`:`height`}`,"aria-valuenow":e.ariaValueNow,"aria-valuetext":e.ariaValueNow===void 0?void 0:`${e.ariaValueNow}px`,"aria-orientation":l===`horizontal`?`vertical`:`horizontal`,onPointerDown:m,onMouseDown:h,onLostPointerCapture:p,onKeyDown:x,onDoubleClick:e.onDoubleClick}),s&&(0,X.jsx)(`div`,{"aria-hidden":`true`,className:`panel-resize-overlay panel-resize-overlay-${l}`,onPointerMove:_,onPointerUp:v,onPointerCancel:v,onMouseMove:y,onMouseUp:b})]})}function oi(e){return(0,X.jsx)(ai,{direction:`horizontal`,onDelta:e.onDelta,onEnd:e.onEnd,onDoubleClick:e.onDoubleClick,className:`sidebar-resize-handle`,ariaLabel:`Resize sidebar`,ariaValueNow:e.width})}var si=`jaw.sidebarWidth`;function ci(e){let t=640+(e.rightPanelOpen?Math.max(0,e.rightPanelWidth):0);return Math.max(220,Math.floor(e.viewportWidth)-t)}function li(e,t){let n=ci(t);return Math.min(n,Math.max(220,Number.isFinite(e)?Math.round(e):300))}function ui(){try{if(typeof localStorage>`u`)return null;let e=localStorage.getItem(si);if(e==null||e.trim()===``)return null;let t=Number(e);return Number.isFinite(t)?t:null}catch{return null}}function di(e){try{localStorage.setItem(si,String(e))}catch{}}function fi(){try{localStorage.removeItem(si)}catch{}}function pi(e){return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)}function mi(){return typeof window>`u`?1440:window.innerWidth}function hi(e){let t=(0,Y.useSyncExternalStore)(pi,mi,()=>1440),n={viewportWidth:t,rightPanelOpen:e.rightPanelOpen,rightPanelWidth:e.rightPanelWidth},[r,i]=(0,Y.useState)(()=>Math.max(220,ui()??300)),a=(0,Y.useRef)(r);return{width:li(r,n),addDelta:(0,Y.useCallback)(e=>{let t=li(li(a.current,n)+e,n);a.current=t,i(t)},[n.viewportWidth,n.rightPanelOpen,n.rightPanelWidth]),persist:(0,Y.useCallback)(()=>{di(a.current)},[]),reset:(0,Y.useCallback)(()=>{fi(),a.current=300,i(300)},[]),viewportWidth:t}}var gi=260,_i=200;function vi(){return typeof window>`u`?1440:window.innerWidth}function yi(){let[e,t]=(0,Y.useState)(vi);return(0,Y.useEffect)(()=>{let e=()=>t(vi());return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),e}function bi(e,t,n){let r=typeof e==`number`&&Number.isFinite(e)?Math.round(e):480,i=Math.max(gi,n-t-_i);return Math.max(gi,Math.min(r,i))}function xi(e){let t=yi(),n=e.sidebarCollapsed?44:e.sidebarWidth,r=e.rightPanelOpen?bi(e.rightPanelWidth,n,t):0,i={"--activity-dock-height":`${e.inspectorHeight}px`,"--sidebar-width":e.sidebarCollapsed?`44px`:`${e.sidebarWidth}px`,"--right-panel-width":e.rightPanelOpen?`${r}px`:e.sidePanel?void 0:`0px`,"--bottom-panel-height":e.bottomPanelOpen?`${e.bottomPanelHeight??0}px`:void 0},a=[`manager-workspace`,e.sidebarCollapsed&&`is-sidebar-collapsed`,e.inspectorCollapsed&&`is-inspector-collapsed`,e.rightPanelOpen&&`is-right-panel-open`,!e.rightPanelOpen&&!e.sidePanel&&`is-right-panel-closed`,e.bottomPanelOpen&&`is-bottom-panel-open`,!e.bottomPanelOpen&&`is-bottom-panel-closed`,e.sidePanel&&`is-side-panel-open`,e.drawerOpen&&`is-drawer-open`].filter(Boolean).join(` `);return(0,X.jsxs)(`div`,{className:a,style:i,children:[e.drawerOpen&&(0,X.jsx)(`div`,{className:`drawer-backdrop`,onClick:e.onCloseDrawer}),(0,X.jsx)(`aside`,{className:`manager-sidebar`,"aria-label":e.navigatorLabel??`Jaw instances`,children:e.navigator}),!e.sidebarCollapsed&&t>=1024&&(0,X.jsx)(oi,{width:e.sidebarWidth,onDelta:e.onSidebarWidthDelta,onEnd:e.onSidebarWidthEnd,onDoubleClick:e.onSidebarWidthReset}),(0,X.jsx)(`section`,{className:`manager-detail`,"aria-label":`Manager workbench`,children:e.workbench}),(0,X.jsx)(`section`,{className:`manager-activity`,"aria-label":`Manager inspector`,children:e.inspector}),e.sidePanel&&(0,X.jsx)(`aside`,{className:`manager-ceo-panel`,"aria-label":`Jaw CEO console`,children:e.sidePanel}),e.rightPanelContent,e.bottomPanelContent,(0,X.jsx)(`nav`,{className:`manager-mobile-nav`,"aria-label":`Mobile dashboard navigation`,children:e.mobileNav}),e.drawer]})}function Si(e){let t=P[e.kind],n=e.sourceLabel??e.specificName;return{visibleLabel:e.specificName,title:`${t}: ${n}`,ariaLabel:`${t} tab, ${n}`}}function Ci(e){return e<=2?`comfortable`:e<=4?`compact`:`mini`}var wi=class extends Y.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[panel-error] ${this.props.label}:`,e,t.componentStack)}handleRetry=()=>{this.setState({error:null})};render(){return this.state.error?(0,X.jsxs)(`div`,{className:`panel-error-boundary`,role:`alert`,children:[(0,X.jsxs)(`div`,{className:`panel-error-title`,children:[this.props.label,` panel crashed`]}),(0,X.jsx)(`pre`,{className:`panel-error-message`,children:this.state.error.message}),(0,X.jsx)(`button`,{type:`button`,className:`panel-error-retry`,onClick:this.handleRetry,children:`Retry`})]}):this.props.children}};function Ti(){return(0,X.jsx)(`svg`,{viewBox:`0 0 20 20`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,"aria-hidden":`true`,focusable:`false`,children:(0,X.jsx)(`path`,{d:`M6 6l8 8M14 6l-8 8`})})}function Ei(){return(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`11`,height:`11`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,"aria-hidden":`true`,focusable:`false`,children:(0,X.jsx)(`path`,{d:`M4 4l8 8M12 4l-8 8`})})}function Di(){return(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,"aria-hidden":`true`,focusable:`false`,children:(0,X.jsx)(`path`,{d:`M8 3v10M3 8h10`})})}function Oi(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`path`,{d:`M2 4.5h4.5L8 6h6v6.5a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V4.5Z`}),(0,X.jsx)(`path`,{d:`M2 4.5V3.5a1 1 0 0 1 1-1h2.5L7 4h5a1 1 0 0 1 1 1v1`})]})}function ki(){return(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:(0,X.jsx)(`path`,{d:`M4 3v10M12 3v10M4 8h8`})})}function Ai(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`rect`,{x:`2`,y:`2`,width:`12`,height:`12`,rx:`1.5`}),(0,X.jsx)(`path`,{d:`M2 5.5h12`})]})}function ji(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`path`,{d:`M9.5 3.5l3 3L6 13H3v-3Z`}),(0,X.jsx)(`path`,{d:`M8 5l3 3`}),(0,X.jsx)(`path`,{d:`M12.5 6.5l1-1a1.4 1.4 0 0 0 0-2l-1-1a1.4 1.4 0 0 0-2 0l-1 1`})]})}function Mi(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`path`,{d:`M3 6.5h5l1.4 1.8H17v6.2A1.5 1.5 0 0 1 15.5 16h-11A1.5 1.5 0 0 1 3 14.5v-8Z`}),(0,X.jsx)(`path`,{d:`M3 6.5V5a1.5 1.5 0 0 1 1.5-1.5h3L9 5.5h6.5A1.5 1.5 0 0 1 17 7v1.3`})]})}function Ni(){return(0,X.jsx)(`span`,{className:`right-breadcrumb-sep`,"aria-hidden":`true`,children:`>`})}var Pi={files:Oi,diff:ki,browser:Ai,design:ji};function Fi(e){if(!e)return[];let t=e.replace(/\\/g,`/`).split(`/`).filter(Boolean);return t.length>0&&t[0]===``&&t.shift(),t}var Ii=[`files`,`diff`,`browser`,`design`];function Li(e){let{state:t,dispatch:n,effectiveRightOpen:r,activeRightTabKind:i}=fe(),a=t.rightPanel,o=(0,Y.useRef)(a.width);(0,Y.useEffect)(()=>{o.current=a.width},[a.width]);let s=(0,Y.useCallback)(e=>{let t=o.current-e;o.current=t,n({type:`SET_RIGHT_WIDTH`,width:t})},[n]),c=(0,Y.useCallback)(()=>{},[]),[l,u]=(0,Y.useState)(!1),d=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{if(!l)return;function e(e){d.current&&!d.current.contains(e.target)&&u(!1)}return document.addEventListener(`click`,e,!0),()=>document.removeEventListener(`click`,e,!0)},[l]);let f=a.tabs.openTabs,p=a.tabs.activeTabId,m=f.find(e=>e.id===p)??null,h=a.fileFolderLayout,g=m?.kind===`files`?m.files?.activeFilePath??null:null,_=Ci(f.length),v=f.some(e=>e.kind===`diff`),y=Ii.filter(e=>!(e===`diff`&&v)),b=h.mode!==`file-only`,x=b?`Hide folder pane`:`Show folder pane`,S=(0,Y.useCallback)(()=>{h.mode===`file-only`?n({type:`RESTORE_FILE_FOLDER_SPLIT`}):n({type:`SET_FILE_FOLDER_VIEW_MODE`,mode:`file-only`})},[n,h.mode]),C=(0,Y.useCallback)(()=>{let e=N()?.folder;(async()=>{if(e?.pickFile){let t=await e.pickFile();t?.ok&&t.path&&n({type:`OPEN_FILE_IN_FILES_TAB`,path:t.path});return}e?.pickFolder&&await e.pickFolder()})()},[n]),w=(0,Y.useCallback)(e=>{n({type:`FOCUS_OR_CREATE_FIRST_RIGHT_SIDEBAR_TAB`,kind:e})},[n]),T=(0,Y.useCallback)(e=>{n({type:`CREATE_RIGHT_SIDEBAR_TAB`,kind:e}),u(!1)},[n]),E=(0,Y.useCallback)((e,t)=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n({type:`ACTIVATE_RIGHT_SIDEBAR_TAB`,tabId:t}))},[n]),D=Fi(g),O=l?(0,X.jsx)(`div`,{className:`right-sidebar-plus-menu`,role:`menu`,children:y.map(e=>(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`right-sidebar-plus-menu-item`,onClick:()=>T(e),children:[Pi[e](),(0,X.jsx)(`span`,{children:P[e]})]},e))}):null;return!r||f.length===0?a.open&&f.length===0?(0,X.jsxs)(`aside`,{className:`right-panel`,"aria-label":`Right sidebar`,children:[(0,X.jsx)(ai,{direction:`horizontal`,onDelta:s,onEnd:c}),(0,X.jsxs)(`div`,{className:`right-panel-shell`,children:[(0,X.jsx)(`div`,{className:`right-panel-toolbar`,children:(0,X.jsx)(`button`,{type:`button`,className:`right-panel-close`,"aria-label":`Close right sidebar`,title:`Close`,onClick:()=>n({type:`SET_RIGHT_OPEN`,open:!1}),children:(0,X.jsx)(Ti,{})})}),(0,X.jsx)(`div`,{className:`right-panel-body is-single-panel`,children:(0,X.jsx)(`div`,{className:`right-sidebar-empty-state`,"aria-label":`No open tabs`,children:(0,X.jsxs)(`div`,{className:`right-sidebar-empty-plus-wrap`,ref:d,children:[(0,X.jsx)(`button`,{type:`button`,className:`right-sidebar-empty-plus`,"aria-label":`Open panel tab`,"aria-haspopup":`menu`,"aria-expanded":l,title:`Open panel tab`,onClick:()=>u(e=>!e),children:(0,X.jsx)(Di,{})}),O]})})})]})]}):null:(0,X.jsxs)(`aside`,{className:`right-panel`,"aria-label":`Right sidebar`,children:[(0,X.jsx)(ai,{direction:`horizontal`,onDelta:s,onEnd:c}),(0,X.jsxs)(`div`,{className:`right-panel-shell`,children:[(0,X.jsxs)(`div`,{className:`right-launcher-row`,"aria-label":`Panel launchers`,children:[(0,X.jsx)(`div`,{className:`right-launcher-group`,children:Ii.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`right-launcher-button${i===e?` is-active`:``}`,"aria-label":P[e],"aria-pressed":i===e,title:P[e],onClick:()=>w(e),children:Pi[e]()},e))}),(0,X.jsx)(`button`,{type:`button`,className:`right-panel-close`,"aria-label":`Close right sidebar`,title:`Close`,onClick:()=>n({type:`SET_RIGHT_OPEN`,open:!1}),children:(0,X.jsx)(Ti,{})})]}),(0,X.jsxs)(`div`,{className:`right-sidebar-tab-strip`,"data-density":_,children:[(0,X.jsx)(`div`,{className:`right-sidebar-tabs`,role:`tablist`,"aria-label":`Open panel tabs`,children:f.map(e=>{let t=e.id===p,r=Pi[e.kind],i=Si(e);return(0,X.jsxs)(`div`,{role:`tab`,tabIndex:0,className:`right-sidebar-tab${t?` is-active`:``}`,"aria-selected":t,"aria-label":i.ariaLabel,title:i.title,onClick:()=>n({type:`ACTIVATE_RIGHT_SIDEBAR_TAB`,tabId:e.id}),onKeyDown:t=>E(t,e.id),children:[(0,X.jsx)(r,{}),(0,X.jsx)(`span`,{className:`right-sidebar-tab-label`,children:i.visibleLabel}),(0,X.jsx)(`button`,{type:`button`,className:`right-sidebar-tab-close`,"aria-label":`Close ${i.ariaLabel}`,title:`Close ${i.visibleLabel}`,onClick:t=>{t.stopPropagation(),n({type:`CLOSE_RIGHT_SIDEBAR_TAB`,tabId:e.id})},children:(0,X.jsx)(Ei,{})})]},e.id)})}),(0,X.jsxs)(`div`,{className:`right-sidebar-plus-wrap`,ref:d,children:[(0,X.jsx)(`button`,{type:`button`,className:`right-sidebar-plus`,"aria-label":`Open panel tab`,"aria-haspopup":`menu`,"aria-expanded":l,title:`Open panel tab`,onClick:()=>u(e=>!e),children:(0,X.jsx)(Di,{})}),O]})]}),i===`files`&&(0,X.jsx)(`div`,{className:`right-files-chrome`,"aria-label":`Files tab chrome`,children:(0,X.jsxs)(`div`,{className:`right-files-toolbar`,children:[(0,X.jsx)(`nav`,{className:`right-breadcrumb`,"aria-label":`File path breadcrumb`,children:D.map((e,t)=>{let n=t===D.length-1;return(0,X.jsxs)(`span`,{className:`right-breadcrumb-item`,children:[t>0&&(0,X.jsx)(Ni,{}),(0,X.jsx)(`span`,{className:`right-breadcrumb-segment${n?` is-final`:``}`,title:e,children:e})]},t)})}),e.onLoadProjectFolder&&(0,X.jsx)(`button`,{type:`button`,className:`right-files-load-folder`,title:`Load project folder`,disabled:e.loadProjectFolderDisabled===!0,onClick:e.onLoadProjectFolder,children:`불러오기`}),(0,X.jsx)(`button`,{type:`button`,className:`right-files-open-file`,title:`Open file`,onClick:C,children:`Open file`}),(0,X.jsx)(`button`,{type:`button`,className:`right-files-folder-toggle`,"aria-pressed":b,title:x,onClick:S,children:(0,X.jsx)(Mi,{})})]})}),(0,X.jsx)(`div`,{className:`right-panel-body is-single-panel`,children:m&&(0,X.jsx)(`div`,{className:`right-sub-panel`,"aria-label":Si(m).ariaLabel,children:(0,X.jsx)(`div`,{className:`right-sub-content`,children:(0,X.jsx)(wi,{label:P[m.kind],children:e.renderPanel(m.kind,m)})})},m.id)})]})]})}var Ri={activity:`Activity`,terminal:`Terminal`,browser:`Browser`,logs:`Logs`};function zi(e){function t(t){let n=e.tabs,r=e.activeTab?n.indexOf(e.activeTab):-1;if(t.key===`ArrowRight`||t.key===`ArrowLeft`){t.preventDefault();let i=n[(r+(t.key===`ArrowRight`?1:-1)+n.length)%n.length];i&&e.onActivate(i)}else if(t.key===`Home`)t.preventDefault(),n[0]&&e.onActivate(n[0]);else if(t.key===`End`){t.preventDefault();let r=n[n.length-1];r&&e.onActivate(r)}}return(0,X.jsxs)(`div`,{className:`bottom-tab-bar`,role:`tablist`,onKeyDown:t,children:[e.tabs.map(t=>(0,X.jsxs)(`div`,{className:`bottom-tab-item ${t===e.activeTab?`is-active`:``}`,role:`presentation`,children:[(0,X.jsx)(`button`,{type:`button`,role:`tab`,className:`bottom-tab ${t===e.activeTab?`is-active`:``}`,"aria-selected":t===e.activeTab,tabIndex:t===e.activeTab?0:-1,onClick:()=>e.onActivate(t),children:(0,X.jsx)(`span`,{children:Ri[t]})}),(0,X.jsx)(`button`,{type:`button`,className:`bottom-tab-close`,"aria-label":`Close ${Ri[t]}`,title:`Close ${Ri[t]}`,onClick:()=>e.onClose(t),children:`×`})]},t)),(0,X.jsx)(`button`,{type:`button`,className:`bottom-collapse-button`,"aria-label":`Collapse panel`,onClick:e.onCollapse,children:`▼`})]})}var Bi=[`terminal`,`browser`];function Vi(e){let{state:t,dispatch:n}=fe(),r=t.bottomPanel,i=(0,Y.useCallback)(e=>{n({type:`SET_BOTTOM_HEIGHT`,height:r.height-e})},[n,r.height]),a=(0,Y.useCallback)(()=>{n({type:`SET_BOTTOM_OPEN`,open:!1})},[n]),o=r.activeTab??r.tabs[0]??null,s=o!==null&&Bi.includes(o);return r.tabs.length===0?null:(0,X.jsxs)(`div`,{className:`bottom-panel ${s?`has-content-owned-chrome`:``}`,"aria-label":`Bottom panel`,"aria-hidden":!r.open,children:[(0,X.jsx)(ai,{direction:`vertical`,onDelta:i,ariaLabel:`Resize bottom panel height`,ariaValueNow:r.height}),!s&&(0,X.jsx)(zi,{tabs:r.tabs,activeTab:r.activeTab,onActivate:e=>n({type:`SET_BOTTOM_ACTIVE_TAB`,tab:e}),onClose:e=>n({type:`CLOSE_BOTTOM_TAB`,tab:e}),onCollapse:a}),(0,X.jsx)(`div`,{className:`bottom-panel-content`,children:o&&e.renderTab(o,{onCollapse:a,onCloseTab:()=>n({type:`CLOSE_BOTTOM_TAB`,tab:o}),ownsChrome:s})})]})}function Hi(e){let{state:t,dispatch:n}=fe(),r=t.rightPanel.fileFolderLayout,i=r.mode,a=r.splitRatio,o=(0,Y.useRef)(null),s=(0,Y.useCallback)(e=>{let r=o.current;if(!r)return;let i=r.offsetWidth;if(i<=0)return;let a=e/i,s=t.rightPanel.fileFolderLayout.splitRatio,c=Math.max(0,Math.min(1,s+a));n({type:`SET_FILE_FOLDER_SPLIT_RATIO`,ratio:c})},[n,t.rightPanel.fileFolderLayout.splitRatio]),c=(0,Y.useCallback)(()=>{},[]),l=i===`folder-only`?{display:`none`}:i===`file-only`?{flex:`1 1 100%`,minWidth:0}:{flex:`0 0 ${(a*100).toFixed(2)}%`,minWidth:0},u=i===`file-only`?{display:`none`}:i===`folder-only`?{flex:`1 1 100%`,minWidth:0}:{flex:`1 1 0%`,minWidth:0},d=i===`split`;return(0,X.jsxs)(`div`,{className:`file-folder-split-panel`,ref:o,"data-mode":i,children:[(0,X.jsx)(`div`,{className:`file-folder-split-file-pane`,style:l,children:e.filePane}),d&&(0,X.jsx)(ai,{direction:`horizontal`,onDelta:s,onEnd:c,className:`file-folder-split-resizer`}),(0,X.jsx)(`div`,{className:`file-folder-split-folder-pane`,style:u,children:e.folderPane})]})}function Ui(e){return e===`127.0.0.1`||e===`localhost`||e===`::1`||e===`[::1]`}function Wi(e=typeof navigator<`u`?navigator.userAgent:``){return/Safari/i.test(e)&&!/Chrome|Chromium|CriOS|Edg|OPR|Android/i.test(e)}function Gi(e){return e===`dark`||e===`light`}function Ki(e){return e&&typeof e==`object`?{theme:e.theme===`dark`||e.theme===`light`?e.theme:null,transport:e.transport===`legacy-path`||e.transport===`origin-port`?e.transport:null,desktop:e.desktop===!0}:{theme:Gi(e)?e:null,transport:e===`proxy`?`legacy-path`:null,desktop:!1}}function qi(e,t){let n=t||(typeof window<`u`?window.location.href:``);if(!n||e.startsWith(`/`))return e;try{let t=new URL(e),r=new URL(n);return Ui(t.hostname)&&Ui(r.hostname)&&(t.hostname=r.hostname),t.toString()}catch{return e}}function Ji(e,t){if(!t)return e;let n=e.startsWith(`/`),r=new URL(e,`http://jaw.local`);return r.searchParams.set(`jawTheme`,t),n?`${r.pathname}${r.search}${r.hash}`:r.toString()}function Yi(e,t){if(!t)return e;let n=e.startsWith(`/`),r=new URL(e,`http://jaw.local`);return r.searchParams.set(`jawDesktop`,`1`),n?`${r.pathname}${r.search}${r.hash}`:r.toString()}function Xi(e,t,n){if(!e)return{canPreview:!1,src:null,reason:`Select an online instance to preview.`,transport:`none`,warning:null};if(!e.ok)return{canPreview:!1,src:null,reason:`Preview is only available for online instances.`,transport:`none`,warning:null};let r=t?.manager.proxy;if(!r?.enabled)return{canPreview:!1,src:null,reason:`Proxy preview is not available.`,transport:`none`,warning:null};if(e.port<r.allowedFrom||e.port>r.allowedTo)return{canPreview:!1,src:null,reason:`This port is outside the proxy allowlist.`,transport:`none`,warning:null};let i=r.preview?.instances[String(e.port)],{theme:a,transport:o,desktop:s}=Ki(n);if(o!==`legacy-path`&&r.preview?.enabled&&i?.status===`ready`&&i.url&&!Wi()){let e=new URL(qi(i.url));return e.pathname=`${e.pathname.replace(/\/?$/,`/`)}0`,{canPreview:!0,src:Yi(Ji(e.toString(),a),s),reason:null,transport:`origin-port`,warning:`origin proxy ready`}}return{canPreview:!0,src:Yi(Ji(`${r.basePath||`/i`}/${e.port}/0`,a),s),reason:null,transport:`legacy-path`,warning:`legacy proxy fallback`}}var Zi=`allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-downloads`;function Qi(e){return e.replace(/^\[|\]$/g,``).toLowerCase()}function $i(e){let t=Qi(e);return t===`127.0.0.1`||t===`localhost`||t===`::1`}function ea(e,t){if(e===t)return!0;try{let n=new URL(e),r=new URL(t);return n.protocol!==r.protocol||n.port!==r.port?!1:$i(n.hostname)&&$i(r.hostname)}catch{return!1}}function ta(e,t,n){if(!e||e===`null`)return!1;let r=ia(t,n);return!!(r&&ea(r,e))}function na(e,t,n){return ta(e.origin,t,n)}function ra(e,t,n,r){if(e&&t&&t!==`null`)try{e.postMessage({type:`jaw-preview-send-result`,requestId:n,...r},t)}catch(e){console.warn(`[manager-preview] send relay result skipped`,e)}}function ia(e,t){if(typeof window>`u`)return`http://localhost`;try{let e=t?.contentWindow?.location.origin;if(e&&e!==`null`)return e}catch{}let n=new URL(e,window.location.href).origin;return n===`null`?null:n}function aa(e,t,n){let r=e?.contentWindow;if(!r)return;let i=ia(t,e);if(i&&i!==`null`)try{r.postMessage({type:`jaw-preview-theme-sync`,theme:n},i)}catch(e){console.warn(`[manager-preview] theme sync skipped`,e)}}function oa(e,t){let n=e?.contentWindow;if(!n)return;let r=ia(t,e);if(r&&r!==`null`)try{n.postMessage({type:`jaw-preview-stt-toggle`},r)}catch(e){console.warn(`[manager-preview] STT shortcut sync skipped`,e)}}function sa(e,t){let n=e?.contentWindow;if(!n)return;let r=ia(t,e);if(r&&r!==`null`)try{n.postMessage({type:`jaw-preview-settings-open`},r)}catch(e){console.warn(`[manager-preview] settings open request skipped`,e)}}function ca(e,t){let n=e?.contentWindow;if(!n)return;let r=ia(t,e);if(r&&r!==`null`)try{n.postMessage({type:`jaw-preview-visibility`,visible:!0},r)}catch(e){console.warn(`[manager-preview] visibility sync skipped`,e)}}function la(e,t,n){let r=e?.contentWindow;if(!r)return;let i=ia(t,e);if(i&&i!==`null`)try{r.postMessage({type:`jaw-preview-capabilities`,docPanel:n},i)}catch(e){console.warn(`[manager-preview] capability sync skipped`,e)}}function ua(e,t,n){if(e&&t&&t!==`null`)try{e.postMessage({type:`jaw-preview-capabilities`,docPanel:n},t)}catch(e){console.warn(`[manager-preview] capability reply skipped`,e)}}function da(e,t,n,r=800){let i=e?.contentWindow;if(!i)return Promise.resolve({ok:!1,error:`preview is unavailable`});let a=ia(t,e);if(!a||a===`null`)return Promise.resolve({ok:!1,error:`preview origin is unavailable`});let o=crypto.randomUUID();return new Promise(s=>{let c=!1,l=e=>{c||(c=!0,window.removeEventListener(`message`,u),window.clearTimeout(d),s(e))},u=n=>{if(n.source!==i||!ta(n.origin,t,e))return;let r=n.data;r&&r.type===`jaw-preview-insert-text-result`&&r.requestId===o&&(r.ok===!0?l({ok:!0}):l({ok:!1,error:typeof r.error==`string`?r.error:`preview rejected insert`}))},d=window.setTimeout(()=>l({ok:!1,error:`preview insert timed out`}),r);window.addEventListener(`message`,u);try{i.postMessage({type:`jaw-preview-insert-text`,requestId:o,text:n},a)}catch(e){l({ok:!1,error:e.message})}})}function fa(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;let t=e.tagName.toLowerCase();return t===`input`||t===`textarea`||t===`select`||!!e.closest(`[contenteditable="true"], .cm-editor, .ProseMirror, [data-milkdown-root]`)}function pa(e){let t=(e.ctrlKey||e.metaKey)&&e.shiftKey&&e.code===`Space`,n=e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&e.code===`KeyM`;return t||n}function ma(e){return!e||e.type!==`jaw-preview-dropped-files`||!Array.isArray(e.files)?[]:e.files.filter(e=>e instanceof File)}function ha(e){let t=(0,Y.useRef)(null),n=(0,Y.useRef)(null),r=(0,Y.useRef)(null),i=(0,Y.useRef)(null),[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(!1),l=Xi(e.instance,e.data,{theme:e.theme,desktop:ce()}),u=e.instance?.ok?`Preview is off. Turn it on from the header to mount the iframe.`:l.reason,d=(0,Y.useCallback)(()=>{e.enabled&&l.canPreview&&l.src&&n.current===l.src&&aa(t.current,l.src,e.theme)},[e.enabled,e.theme,l.canPreview,l.src]);(0,Y.useEffect)(()=>{let i=e.previewInsertTextRequest;if(!i||r.current===i.id)return;r.current=i.id;let a=t=>{e.onPreviewInsertTextResult?.(i.id,t)};if(!e.instance?.ok||e.instance.port!==i.port){a({ok:!1,error:`selected instance preview is not mounted`});return}if(!e.enabled||!l.canPreview||!l.src){a({ok:!1,error:u||`selected instance preview is unavailable`});return}if(n.current!==l.src){a({ok:!1,error:`selected instance preview is still loading`});return}da(t.current,l.src,i.text).then(a).catch(e=>a({ok:!1,error:e.message}))},[u,e.enabled,e.instance,e.onPreviewInsertTextResult,e.previewInsertTextRequest,l.canPreview,l.src]),(0,Y.useEffect)(()=>{let r=e.previewSettingsOpenRequest;if(!r||i.current===r)return;i.current=r;let a=t=>{e.onPreviewSettingsOpenResult?.(r,t)};if(!e.instance?.ok){a({ok:!1,error:`selected instance is not online`});return}if(!e.enabled||!l.canPreview||!l.src){a({ok:!1,error:u||`turn Preview on to open this instance’s settings`});return}if(n.current!==l.src){a({ok:!1,error:`selected instance preview is still loading`});return}sa(t.current,l.src),a({ok:!0})},[u,e.enabled,e.instance,e.onPreviewSettingsOpenResult,e.previewSettingsOpenRequest,l.canPreview,l.src]);let f=(0,Y.useCallback)(async e=>{if(!we(e.dataTransfer))return;e.preventDefault(),e.stopPropagation(),c(!1);let n=R(e.dataTransfer),r=e.dataTransfer.getData(`text/plain`),i=n?.entries?.length?n.entries.map(e=>e.path).join(`
3
- `):n?.path||r;if(!i||!l.src)return;let a=await da(t.current,l.src,i);if(a.ok){o(`Inserted path into preview`);return}let s=await L(i);o(s.ok?`Preview did not accept text. Copied path instead.`:s.error??a.error)},[l.src]);(0,Y.useEffect)(()=>{d()},[d]),(0,Y.useEffect)(()=>{let e=e=>{let t=e.detail;c(!!t?.active)};return window.addEventListener(`jaw-folder-panel-drag`,e),()=>window.removeEventListener(`jaw-folder-panel-drag`,e)},[]),(0,Y.useEffect)(()=>{if(!e.enabled||!l.canPreview||!l.src||!e.instance?.ok)return;function n(n){if(n.source!==t.current?.contentWindow||!l.src||!ta(n.origin,l.src,t.current))return;let r=n.data;if(!r||r.type!==`jaw-preview-send-message`)return;let i=typeof r.requestId==`string`?r.requestId:``,a=typeof r.prompt==`string`?r.prompt.trim():``;if(!i)return;if(!a){ra(n.source,n.origin,i,{ok:!1,status:400,error:`prompt must be a non-empty string`});return}let o=typeof r.sessionId==`string`?r.sessionId:void 0;_(e.instance.port,a,o).then(e=>{ra(n.source,n.origin,i,{ok:e.ok,status:e.status,data:e.data,...e.data.error?{error:e.data.error}:{}})}).catch(e=>{ra(n.source,n.origin,i,{ok:!1,status:502,error:e.message})})}window.addEventListener(`message`,n);function r(n){if(!l.src||!na(n,l.src,t.current))return;let r=n.data;if(!r||r.type!==`jaw-preview-open-notes`)return;let i=typeof r.path==`string`?r.path.trim():``;i&&e.onOpenNotesFromPreview?.(i)}window.addEventListener(`message`,r);function i(n){if(!l.src||!na(n,l.src,t.current))return;let r=n.data;if(!r||r.type!==`jaw-preview-open-doc`)return;let i=typeof r.path==`string`?r.path.trim():``;i&&e.onOpenDocFromPreview?.(i)}window.addEventListener(`message`,i);function a(n){if(!l.src||!na(n,l.src,t.current))return;let r=n.data;r&&r.type===`jaw-preview-capabilities-request`&&ua(n.source,n.origin,e.docPanelCapable===!0)}window.addEventListener(`message`,a);function o(n){if(n.source!==t.current?.contentWindow||!l.src||!ta(n.origin,l.src,t.current))return;let r=ma(n.data);r.length!==0&&e.onPreviewDroppedFiles?.(r)}return window.addEventListener(`message`,o),()=>{window.removeEventListener(`message`,n),window.removeEventListener(`message`,r),window.removeEventListener(`message`,i),window.removeEventListener(`message`,a),window.removeEventListener(`message`,o)}},[e.enabled,e.instance,e.onOpenNotesFromPreview,e.onOpenDocFromPreview,e.onPreviewDroppedFiles,e.docPanelCapable,l.canPreview,l.src]),(0,Y.useEffect)(()=>{if(!e.active||!e.enabled||!l.canPreview||!l.src)return;function n(e){e.defaultPrevented||fa(e.target)||pa(e)&&(e.preventDefault(),oa(t.current,l.src||``))}return document.addEventListener(`keydown`,n,!0),()=>document.removeEventListener(`keydown`,n,!0)},[e.active,e.enabled,l.canPreview,l.src]);let p=(0,Y.useRef)(!1);return(0,Y.useEffect)(()=>{let n=p.current;p.current=e.active,!n&&e.active&&l.src&&(ca(t.current,l.src),la(t.current,l.src,e.docPanelCapable===!0))},[e.active,l.src,e.docPanelCapable]),(0,Y.useEffect)(()=>{e.enabled&&l.canPreview&&l.src&&n.current===l.src&&la(t.current,l.src,e.docPanelCapable===!0)},[e.enabled,e.docPanelCapable,l.canPreview,l.src]),(0,X.jsxs)(`aside`,{className:`preview-panel`,"aria-label":`Instance preview`,onDragOver:e=>{we(e.dataTransfer)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)},onDrop:e=>{f(e)},children:[(!e.enabled||!l.canPreview)&&(0,X.jsx)(`div`,{className:`preview-empty`,children:u}),a&&(0,X.jsxs)(`div`,{className:`preview-path-drop-status`,role:`status`,children:[a,(0,X.jsx)(`button`,{type:`button`,"aria-label":`Dismiss path drop status`,onClick:()=>o(null),children:`x`})]}),e.enabled&&l.canPreview&&l.src&&(0,X.jsx)(`iframe`,{title:`Jaw instance ${e.instance?.port} preview`,ref:t,className:`preview-frame`,src:l.src,sandbox:ce()?void 0:Zi,allow:`clipboard-read; clipboard-write; microphone`,onLoad:()=>{n.current=l.src,d(),l.src&&(ca(t.current,l.src),la(t.current,l.src,e.docPanelCapable===!0))}},`${e.instance?.port||`none`}:${e.refreshKey}`),s&&(0,X.jsx)(`div`,{className:`preview-path-drop-overlay`,onDragOver:e=>{we(e.dataTransfer)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)},onDragLeave:()=>c(!1),onDrop:e=>void f(e)})]})}var ga=/\{\{(\w+)\}\}/g;function _a(){let e=new Date,t=e=>String(e).padStart(2,`0`),n=e.getFullYear(),r=t(e.getMonth()+1),i=t(e.getDate()),a=t(e.getHours()),o=t(e.getMinutes());return{date:`${n}-${r}-${i}`,time:`${a}:${o}`,year:String(n),month:r,day:i}}function va(e,t={}){let n={..._a(),...t};return e.replace(ga,(e,t)=>Object.hasOwn(n,t)?n[t]:e)}function ya({expanded:e}){return(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`notes-tree-chevron`,children:(0,X.jsx)(`path`,{d:e?`M4 6l4 4 4-4`:`M6 4l4 4-4 4`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function ba({open:e}){return(0,X.jsxs)(`svg`,{viewBox:`0 0 18 18`,"aria-hidden":`true`,className:`notes-tree-icon`,children:[(0,X.jsx)(`path`,{d:`M2.5 5.2h5.1l1.2 1.5h6.7v6.7a1.4 1.4 0 0 1-1.4 1.4H3.9a1.4 1.4 0 0 1-1.4-1.4V5.2Z`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinejoin:`round`}),(0,X.jsx)(`path`,{d:e?`M2.8 7.1h12.7`:`M2.8 5.2h4.8`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})]})}function xa(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 18 18`,"aria-hidden":`true`,className:`notes-tree-icon`,children:[(0,X.jsx)(`path`,{d:`M5 2.8h5.2L13.5 6v9.2H5V2.8Z`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinejoin:`round`}),(0,X.jsx)(`path`,{d:`M10.2 2.8V6h3.3M6.9 9h4.4M6.9 11.5h3.3`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})]})}function Sa(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 18 18`,"aria-hidden":`true`,className:`notes-tree-action-icon`,children:[(0,X.jsx)(`path`,{d:`M5 2.8h5.2L13.5 6v9.2H5V2.8Z`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinejoin:`round`}),(0,X.jsx)(`path`,{d:`M9.2 8.1v4.2M7.1 10.2h4.2`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})]})}function Ca(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 18 18`,"aria-hidden":`true`,className:`notes-tree-action-icon`,children:[(0,X.jsx)(`path`,{d:`M2.5 5.2h5.1l1.2 1.5h6.7v6.7a1.4 1.4 0 0 1-1.4 1.4H3.9a1.4 1.4 0 0 1-1.4-1.4V5.2Z`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinejoin:`round`}),(0,X.jsx)(`path`,{d:`M9 8.3v4M7 10.3h4`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})]})}function wa(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 18 18`,"aria-hidden":`true`,className:`notes-tree-action-icon`,children:[(0,X.jsx)(`path`,{d:`M14.2 6.3A5.5 5.5 0 0 0 4 5.2L3 6.6M3.8 11.7A5.5 5.5 0 0 0 14 12.8l1-1.4`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,X.jsx)(`path`,{d:`M3 3.5v3.1h3.1M15 14.5v-3.1h-3.1`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`})]})}function Ta(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 18 18`,"aria-hidden":`true`,className:`notes-tree-action-icon`,children:[(0,X.jsx)(`path`,{d:`M4 12.8 3.5 15l2.2-.5 7.7-7.7-1.7-1.7L4 12.8Z`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,X.jsx)(`path`,{d:`m10.9 5.9 1.7 1.7`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})]})}function Ea(e){return e.dataTransfer.getData(`application/x-cli-jaw-note-path`)||e.dataTransfer.getData(`text/plain`)||null}function Da(e){return Array.from(e.dataTransfer.types).some(e=>e===`application/x-cli-jaw-note-path`||e===`text/plain`)}function Oa(e,t){let n=[];for(let r of e)n.push(r.path),r.kind===`folder`&&t.has(r.path)&&r.children&&n.push(...Oa(r.children,t));return n}function ka(e,t){for(let n of e)t.set(n.path,n.kind),n.kind===`folder`&&n.children&&ka(n.children,t)}function Aa(e,t){let n=[];for(let r of e){let e=t.get(r);e&&n.push({path:r,kind:e})}return n}function ja(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase();return e.isContentEditable||t===`input`||t===`textarea`||t===`select`}function Ma(e,t,n){let r=e.indexOf(t),i=e.indexOf(n);if(r===-1||i===-1)return new Set([n]);let a=Math.min(r,i),o=Math.max(r,i);return new Set(e.slice(a,o+1))}function Na(e,t,n){if(e.key===`F2`){e.preventDefault(),n.onRenamePath(t.path,t.kind);return}if(e.key===`Delete`||e.key===`Backspace`){if(e.preventDefault(),n.multiSelected.size>1&&n.multiSelected.has(t.path)){let e=Aa(n.multiSelected,n.pathKindLookup);e.length>0&&n.onTrashPaths(e);return}n.onTrashPath(t.path,t.kind);return}if(e.key===`Enter`){if(e.preventDefault(),t.kind===`folder`){n.onSelectFolder?.(t.path),n.toggleFolder?.(t.path);return}n.onSelectPath(t.path)}}function Pa(e,t,n,r,i,a,o,s,c){let l=e.path===t.selectedPath,u=o.has(e.path);if(e.kind===`folder`){let l=n.has(e.path),d=e.path===t.selectedFolderPath,f=e.children||[];return(0,X.jsxs)(`li`,{className:`notes-tree-folder`,children:[(0,X.jsxs)(`div`,{className:`notes-tree-folder-row ${d?`is-folder-selected`:``} ${i===e.path?`is-drop-target`:``} ${u?`is-multi-selected`:``}`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`notes-tree-folder-button`,"aria-expanded":l,draggable:!0,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`application/x-cli-jaw-note-path`,e.path),t.dataTransfer.setData(`text/plain`,e.path)},onClick:n=>{if(n.shiftKey||n.metaKey||n.ctrlKey){c(e.path,n);return}c(e.path,n),t.onSelectFolder(e.path),r(e.path)},onDragOver:t=>{t.preventDefault(),t.stopPropagation(),a(e.path)},onDragLeave:e=>{e.stopPropagation(),a(null)},onDrop:n=>{n.preventDefault(),n.stopPropagation();let r=Ea(n);a(null),r&&r!==e.path&&!e.path.startsWith(`${r}/`)&&t.onMovePath(r,e.path)},onKeyDown:n=>{if(n.key===`ArrowRight`&&!l){n.preventDefault(),r(e.path);return}if(n.key===`ArrowLeft`&&l){n.preventDefault(),r(e.path);return}Na(n,e,{toggleFolder:r,onSelectPath:t.onSelectPath,onSelectFolder:t.onSelectFolder,onRenamePath:t.onRenamePath,onTrashPath:t.onTrashPath,onTrashPaths:t.onTrashPaths,multiSelected:o,pathKindLookup:s})},children:[(0,X.jsx)(ya,{expanded:l}),(0,X.jsx)(ba,{open:l}),(0,X.jsx)(`span`,{children:e.name})]}),(0,X.jsx)(`button`,{type:`button`,className:`notes-tree-inline-action`,title:`Rename folder`,"aria-label":`Rename folder ${e.name}`,onClick:n=>{n.stopPropagation(),t.onRenamePath(e.path,e.kind)},children:(0,X.jsx)(Ta,{})})]}),l&&f.length>0&&(0,X.jsx)(`ul`,{children:f.map(e=>Pa(e,t,n,r,i,a,o,s,c))})]},e.path)}let d=e.path===t.dirtyPath,f=e.path===t.highlightedPath;return(0,X.jsx)(`li`,{children:(0,X.jsxs)(`div`,{className:`notes-tree-file-row ${l?`is-selected`:``} ${d?`is-dirty`:``} ${u?`is-multi-selected`:``} ${f?`is-highlighted`:``}`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`notes-tree-file-button`,"aria-current":l?`page`:void 0,draggable:!0,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`application/x-cli-jaw-note-path`,e.path),t.dataTransfer.setData(`text/plain`,e.path)},onClick:n=>{if(n.shiftKey||n.metaKey||n.ctrlKey){c(e.path,n);return}c(e.path,n),t.onSelectPath(e.path)},onKeyDown:n=>Na(n,e,{onSelectPath:t.onSelectPath,onRenamePath:t.onRenamePath,onTrashPath:t.onTrashPath,onTrashPaths:t.onTrashPaths,multiSelected:o,pathKindLookup:s}),children:[(0,X.jsx)(xa,{}),(0,X.jsx)(`span`,{children:e.name}),d&&(0,X.jsx)(`span`,{className:`notes-tree-dirty-dot`,"aria-label":`Unsaved changes`})]}),(0,X.jsx)(`button`,{type:`button`,className:`notes-tree-inline-action`,title:`Rename`,"aria-label":`Rename ${e.name}`,onClick:n=>{n.stopPropagation(),t.onRenamePath(e.path,e.kind)},children:(0,X.jsx)(Ta,{})})]})},e.path)}function Fa(e){let[t,n]=(0,Y.useState)(()=>new Set),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(()=>new Set),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{let t=e.externalFocusPath??e.highlightedPath;if(!t)return;let r=t.split(`/`).filter(Boolean);if(r.length<=1)return;let i=[];for(let e=1;e<r.length;e++)i.push(r.slice(0,e).join(`/`));n(e=>{let t=new Set(e);for(let e of i)t.add(e);return t})},[e.externalFocusPath,e.highlightedPath]);function d(e){n(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}let f=Oa(e.entries,t),p=(0,Y.useMemo)(()=>{let t=new Map;return ka(e.entries,t),t},[e.entries]);function m(){if(a.size===0)return;let t=Aa(a,p);t.length!==0&&e.onTrashPaths(t)}let h=(0,Y.useCallback)((t,n)=>{if(u(t),n.shiftKey&&s){let e=Ma(f,s,t);o(e)}else n.metaKey||n.ctrlKey?(o(n=>{let r=new Set(n);return r.size===0&&e.selectedPath&&r.add(e.selectedPath),r.has(t)?r.delete(t):r.add(t),r}),c(t)):(a.size>0&&o(new Set),c(t))},[s,f,a.size,e.selectedPath]);return(0,Y.useEffect)(()=>{e.selectedPath&&c(e.selectedPath)},[e.selectedPath]),(0,Y.useEffect)(()=>{l&&!p.has(l)&&u(null),a.size!==0&&o(e=>{let t=!1,n=new Set;for(let r of e)p.has(r)?n.add(r):t=!0;return t?n:e})},[l,a.size,p]),(0,Y.useEffect)(()=>{function t(t){if(!(t.metaKey||t.ctrlKey)||!t.shiftKey||t.key.toLowerCase()!==`c`||ja(t.target))return;let n=e.notesRoot;if(!n)return;let r=a.size>0?Array.from(a):l&&p.has(l)?[l]:e.selectedPath?[e.selectedPath]:[];if(r.length===0)return;t.preventDefault();let i=r.map(e=>`${n}/${e}`).join(`
4
- `);L(i).then(e=>{e.ok||console.error(`[notes:path-copy]`,e.error)})}return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[l,a,p,e.selectedPath,e.notesRoot]),(0,Y.useEffect)(()=>{function t(t){if(t.defaultPrevented||!(t.metaKey||t.ctrlKey)||t.key!==`Delete`&&t.key!==`Backspace`||ja(t.target))return;let n=a.size>0?Aa(a,p):e.selectedFolderPath&&p.get(e.selectedFolderPath)===`folder`?[{path:e.selectedFolderPath,kind:`folder`}]:e.selectedPath&&p.get(e.selectedPath)===`file`?[{path:e.selectedPath,kind:`file`}]:[];n.length!==0&&(t.preventDefault(),n.length>1?e.onTrashPaths(n):e.onTrashPath(n[0].path,n[0].kind))}return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[a,p,e]),(0,X.jsxs)(`div`,{className:`notes-tree-body ${r===null?`is-root-drop-target`:``}`,onDragOver:e=>{Da(e)&&(e.preventDefault(),i(null))},onDrop:t=>{let n=Ea(t);n&&(t.preventDefault(),e.onMovePath(n,null))},children:[a.size>0&&(0,X.jsxs)(`div`,{className:`notes-tree-selection-info`,children:[a.size,` selected`,(0,X.jsx)(`button`,{type:`button`,className:`notes-tree-selection-delete`,onClick:m,disabled:a.size===0,children:`Delete`}),(0,X.jsx)(`button`,{type:`button`,className:`notes-tree-clear-selection`,onClick:()=>o(new Set),children:`Clear`})]}),e.loading&&(0,X.jsx)(`div`,{className:`notes-tree-state`,children:`Loading notes...`}),!e.loading&&e.entries.length===0&&(0,X.jsx)(`div`,{className:`notes-tree-state`,children:`No notes or folders`}),!e.loading&&e.entries.length>0&&(0,X.jsx)(`ul`,{className:`notes-tree-list`,children:e.entries.map(n=>Pa(n,e,t,d,r,i,a,p,h))})]})}var Ia=2,La=275,Ra=20;function za(e){return e instanceof DOMException&&e.name===`AbortError`}function Ba(e){let[t,n]=(0,Y.useState)(``),[r,i]=(0,Y.useState)([]),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(null),l=(0,Y.useRef)(null),u=(0,Y.useRef)(null),d=(0,Y.useRef)(null),f=(0,Y.useCallback)(()=>{u.current&&clearTimeout(u.current),u.current=null,d.current?.abort(),d.current=null},[]);(0,Y.useEffect)(()=>{l.current?.focus()},[e.focusToken]),(0,Y.useEffect)(()=>()=>f(),[f]);let p=(0,Y.useCallback)(e=>{let t=e.trim();if(f(),c(null),t.length<Ia){i([]),o(!1);return}let n=new AbortController;d.current=n,o(!0),ae(t,{limit:Ra,signal:n.signal}).then(e=>{n.signal.aborted||i(e)}).catch(e=>{n.signal.aborted||za(e)||(i([]),c(e.message||`Search failed`))}).finally(()=>{n.signal.aborted||o(!1)})},[f]);function m(e){n(e),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>p(e),La)}function h(t){t.key===`Escape`&&(t.preventDefault(),e.onModeChange(`files`))}return(0,X.jsxs)(`section`,{className:`notes-search-sidebar`,"aria-label":`Search notes`,onKeyDown:h,children:[(0,X.jsx)(`div`,{className:`notes-search-sidebar-header`,children:(0,X.jsx)(`input`,{ref:l,className:`notes-search-input`,type:`search`,placeholder:`Search notes`,value:t,onChange:e=>m(e.currentTarget.value),"aria-label":`Search notes`})}),(0,X.jsxs)(`div`,{className:`notes-search-sidebar-results`,"aria-live":`polite`,children:[a&&(0,X.jsx)(`div`,{className:`notes-search-loading`,children:`Searching...`}),s&&(0,X.jsx)(`div`,{className:`notes-search-error`,children:s}),!s&&r.map(t=>(0,X.jsxs)(`button`,{type:`button`,className:`notes-search-result`,onClick:()=>e.onSelect(t.path),children:[(0,X.jsx)(`span`,{className:`notes-search-result-path`,children:t.path}),(0,X.jsx)(`span`,{className:`notes-search-result-line`,children:t.kind===`path`?`Path match`:`Line ${t.line}`}),(0,X.jsx)(`span`,{className:`notes-search-result-context`,children:t.context})]},`${t.kind}:${t.path}:${t.line}:${t.context}`)),!a&&!s&&t.trim().length>=Ia&&r.length===0&&(0,X.jsx)(`div`,{className:`notes-search-empty`,children:`No results`})]})]})}var Va=(0,Y.createContext)(null);function Ha(e){let[t,n]=(0,Y.useState)(()=>new Map),r=(0,Y.useCallback)(e=>{let t=new Map(e.map(e=>[e.id,e]));return n(t=>{let n=new Map(t);for(let t of e){let e=n.get(t.id);e&&e!==t&&console.warn(`[notes-command-palette] duplicate command id: ${t.id}`),n.set(t.id,t)}return n}),()=>{n(e=>{let n=new Map(e);for(let[e,r]of t)n.get(e)===r&&n.delete(e);return n})}},[]),i=(0,Y.useMemo)(()=>[...t.values()].sort((e,t)=>{let n=e.section.localeCompare(t.section);return n===0?e.label.localeCompare(t.label):n}),[t]),a=(0,Y.useMemo)(()=>({commands:i,register:r}),[i,r]);return(0,X.jsx)(Va.Provider,{value:a,children:e.children})}function Ua(){let e=(0,Y.useContext)(Va);if(!e)throw Error(`useNoteCommands must be used inside NotesCommandProvider`);return e.commands}function Wa(e,t=!0){let n=(0,Y.useContext)(Va);if(!n)throw Error(`useRegisterNoteCommands must be used inside NotesCommandProvider`);let r=n.register;(0,Y.useEffect)(()=>{if(t&&e.length!==0)return r(e)},[t,e,r])}var Ga=new EventTarget,Ka=`dashboard:invalidate`;function Z(e){Ga.dispatchEvent(new CustomEvent(Ka,{detail:e}))}function qa(e,t,n){function r(r){let i=r.detail;i.topics.includes(e)&&(n&&i.sourceId===n||t(i))}return Ga.addEventListener(Ka,r),()=>Ga.removeEventListener(Ka,r)}function Ja(e,t){let n=e.split(`/`).filter(Boolean),r=n[n.length-1];return r?t?`${t}/${r}`:r:e}function Ya(e){let t=e.split(`/`).filter(Boolean);return t[t.length-1]||e}function Xa(e){let t=e.split(`/`).filter(Boolean);return t.length<=1?null:t.slice(0,-1).join(`/`)}function Za(e,t,n){let r=n===`file`&&!t.endsWith(`.md`)?`${t}.md`:t;if(r.includes(`/`))return r;let i=Xa(e);return i?`${i}/${r}`:r}function Qa(e,t,n){return e?e===t?n:e.startsWith(`${t}/`)?`${n}/${e.slice(t.length+1)}`:e:null}function $a(e,t){return t?t===e||t.startsWith(`${e}/`):!1}function eo(e,t,n){return n?t===`folder`?$a(e,n):n===e:!1}function to(e,t,n){let r=t===`folder`?`Move folder "${e}" and all child notes to trash?`:`Move note "${e}" to trash?`;return n?`${r}\n\nThere are unsaved changes inside this target.`:r}function no(e,t){let n=e.filter(e=>e.kind===`file`).length,r=e.length-n,i=[];r>0&&i.push(`${r} folder${r===1?``:`s`}`),n>0&&i.push(`${n} note${n===1?``:`s`}`);let a=`Move ${i.length>0?i.join(` + `):`${e.length} items`} to trash?`;return t?`${a}\n\nThere are unsaved changes inside this selection.`:a}function ro(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 18 18`,"aria-hidden":`true`,className:`notes-tree-action-icon`,children:[(0,X.jsx)(`path`,{d:`M7.8 3.2a4.6 4.6 0 1 1 0 9.2 4.6 4.6 0 0 1 0-9.2Z`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,X.jsx)(`path`,{d:`m11.3 11.3 3.2 3.2`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})]})}function io(e,t){return e.some(e=>e.kind===`file`&&e.name===t)}function ao(e){let t={"--notes-tree-width":`${e.treeWidth}px`},[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(null),[c,l]=(0,Y.useState)([]),[u,d]=(0,Y.useState)(`pending`),[f,p]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{C().then(e=>{l(e),d(`ok`)}).catch(()=>{d(`error`)})},[]);async function m(){let t=new Date,n=e=>String(e).padStart(2,`0`),i=`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}.md`;if(io(e.tree,i)){e.onSelectedPathChange(i),r(null);return}if(u===`pending`){r(`Templates are still loading. Please try again.`);return}if(u===`error`){r(`Template list failed to load. Cannot determine daily template.`);return}try{a(null),r(null);let t=c.find(e=>e.name===`daily`),n=``;if(t)try{n=va((await S(t.name)).content,{title:i.replace(/\.md$/,``)})}catch{r(`Daily template failed to load. Note was not created.`);return}let o=await M(i,n);e.onSelectedPathChange(o.path),await e.onRefreshTree(o.path),Z({topics:[`notes`],reason:`note:created`,source:`ui`,sourceId:`notes-sidebar`})}catch(t){if(t instanceof ne&&t.status===409&&t.code===`note_path_exists`){r(null),e.onSelectedPathChange(i),await e.onRefreshTree(i);return}r(t.message)}}async function h(){if(u===`pending`){r(`Templates are still loading. Please try again.`);return}if(u===`error`){r(`Template list failed to load. Cannot offer template picker.`);return}let e=o?`${o}/untitled.md`:`untitled.md`,t=window.prompt(`Note path`,e);if(!t)return;let n=t.endsWith(`.md`)?t:`${t}.md`;if(c.length>0){p(n);return}await g(n,null)}async function g(t,n){p(null);let i=``;if(n)try{let e=await S(n),r=(t.endsWith(`.md`)?t.slice(0,-3):t).split(`/`).pop()??``;i=va(e.content,{title:r})}catch{r(`Template "${n}" failed to load. Note was not created.`);return}try{a(null),r(null);let n=await M(t,i);e.onSelectedPathChange(n.path),await e.onRefreshTree(n.path),Z({topics:[`notes`],reason:`note:created`,source:`ui`,sourceId:`notes-sidebar`})}catch(e){r(e.message)}}(0,Y.useEffect)(()=>{function e(e){!e.altKey||e.metaKey||e.ctrlKey||e.shiftKey||e.key.toLowerCase()!==`n`||(e.preventDefault(),h())}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)});async function _(){let t=o?`${o}/new-folder`:`new-folder`,n=window.prompt(`Folder path`,t);if(n)try{a(null);let t=await E(n);s(t.path),await e.onRefreshTree(),Z({topics:[`notes`],reason:`folder:created`,source:`ui`,sourceId:`notes-sidebar`})}catch(e){r(e.message)}}async function v(t,n){let i=Ja(t,n);if(t!==i)try{a(null);let n=await oe(t,i);e.selectedPath===t&&e.onSelectedPathChange(n.to),await e.onRefreshTree(n.to),Z({topics:[`notes`],reason:`note:moved`,source:`ui`,sourceId:`notes-sidebar`})}catch(e){r(e.message)}}async function y(t,n){let i=n===`folder`?`Rename folder`:`Rename note`,c=window.prompt(i,Ya(t));if(!c)return;let l=Za(t,c,n);if(l!==t)try{a(null);let n=await oe(t,l),r=Qa(e.selectedPath,n.from,n.to),i=Qa(o,n.from,n.to);i!==o&&s(i),r!==e.selectedPath&&e.onSelectedPathChange(r),await e.onRefreshTree(r),Z({topics:[`notes`],reason:`note:renamed`,source:`ui`,sourceId:`notes-sidebar`})}catch(e){r(e.message)}}async function b(t){if(t.length===0)return;if(t.length===1){await x(t[0].path,t[0].kind);return}let n=t.some(t=>eo(t.path,t.kind,e.dirtyPath));if(!window.confirm(no(t,n)))return;a(null);let i=0,c=!1,l=!1,u=null;for(let n of t)try{await D(n.path,n.kind),i+=1,c||(n.kind===`folder`?$a(n.path,e.selectedPath):e.selectedPath===n.path)&&(c=!0),!l&&n.kind===`folder`&&$a(n.path,o)&&(l=!0)}catch(e){u=`Failed at ${n.path}: ${e.message}`;break}c&&e.onSelectedPathChange(null),l&&s(null),u?(r(u),a(i>0?`Moved ${i} of ${t.length} to trash before stopping.`:null)):a(`Moved ${i} item${i===1?``:`s`} to trash.`),await e.onRefreshTree(c?null:e.selectedPath),Z({topics:[`notes`],reason:`notes:batch-trashed`,source:`ui`,sourceId:`notes-sidebar`})}async function x(t,n){let i=eo(t,n,e.dirtyPath);if(window.confirm(to(t,n,i)))try{a(null);let r=await D(t,n),i=n===`folder`?$a(t,e.selectedPath):e.selectedPath===t,c=n===`folder`&&$a(t,o);i&&e.onSelectedPathChange(null),c&&s(null);let l=r.deletedTo===`os-trash`?`OS trash`:`dashboard trash`,u=r.deletedTo===`dashboard-trash`&&r.restoreHint?` Restore from: ${r.restoreHint}`:``;a(`Moved ${r.path} to ${l}.${u}`),await e.onRefreshTree(i?null:e.selectedPath),Z({topics:[`notes`],reason:`note:trashed`,source:`ui`,sourceId:`notes-sidebar`})}catch(e){r(e.message)}}let w=u===`pending`?`Templates are still loading`:u===`error`?`Templates failed to load`:void 0;return Wa((0,Y.useMemo)(()=>[{id:`sidebar:new-note`,section:`Create`,label:`New note`,shortcut:`Alt+N`,keywords:[`create`,`file`],disabled:u!==`ok`,disabledReason:w,run:()=>void h()},{id:`sidebar:new-folder`,section:`Create`,label:`New folder`,keywords:[`directory`],run:()=>void _()},{id:`sidebar:today`,section:`Create`,label:`Open today`,keywords:[`daily`,`journal`],disabled:u!==`ok`,disabledReason:w,run:()=>void m()},{id:`sidebar:search`,section:`Navigate`,label:`Search notes`,shortcut:`Cmd+Shift+F`,run:e.onOpenSearch},{id:`sidebar:refresh`,section:`File`,label:`Refresh notes`,disabled:e.loading,disabledReason:`Refresh already running`,run:()=>void e.onRefreshTree()},{id:`sidebar:clear-tag-filter`,section:`Navigate`,label:`Clear tag filter`,disabled:!e.tagFilter,disabledReason:`No active tag filter`,run:e.onClearTagFilter}],[e.loading,e.onClearTagFilter,e.onOpenSearch,e.onRefreshTree,e.onSelectedPathChange,e.selectedPath,e.tagFilter,e.tree,o,w,c,u])),(0,X.jsxs)(`aside`,{className:`notes-tree`,style:t,children:[(e.error||n)&&(0,X.jsx)(`section`,{className:`state error-state`,children:e.error||n}),i&&(0,X.jsx)(`section`,{className:`state notes-status-state`,children:i}),(0,X.jsxs)(`div`,{className:`notes-tree-header`,children:[(0,X.jsx)(`strong`,{children:`Notes`}),(0,X.jsxs)(`div`,{className:`notes-tree-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:e.mode===`search`?`is-active`:``,onClick:()=>{e.mode===`search`?e.onModeChange(`files`):e.onOpenSearch()},title:`Search notes`,"aria-label":`Search notes`,"aria-pressed":e.mode===`search`,children:(0,X.jsx)(ro,{})}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void h(),title:`New note`,"aria-label":`New note`,children:(0,X.jsx)(Sa,{})}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void _(),title:`New folder`,"aria-label":`New folder`,children:(0,X.jsx)(Ca,{})}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void e.onRefreshTree(),disabled:e.loading,title:`Refresh notes`,"aria-label":`Refresh notes`,children:(0,X.jsx)(wa,{})})]})]}),e.mode===`files`?(0,X.jsxs)(X.Fragment,{children:[e.tagFilter&&(0,X.jsxs)(`div`,{className:`notes-tag-filter-banner`,role:`status`,children:[(0,X.jsxs)(`span`,{className:`notes-tag-filter-banner-meta`,children:[(0,X.jsxs)(`span`,{children:[`Tag: #`,e.tagFilter]}),e.selectedHiddenByFilter&&(0,X.jsx)(`span`,{className:`notes-tag-filter-banner-hint`,children:`Selected note hidden by filter`})]}),(0,X.jsx)(`button`,{type:`button`,className:`notes-tag-filter-clear`,onClick:e.onClearTagFilter,children:`Clear`})]}),f&&(0,X.jsxs)(`div`,{className:`notes-template-picker`,children:[(0,X.jsxs)(`div`,{className:`notes-template-picker-label`,children:[`Template for `,Ya(f)]}),(0,X.jsxs)(`div`,{className:`notes-template-picker-options`,children:[(0,X.jsx)(`button`,{type:`button`,className:`notes-template-picker-option`,onClick:()=>void g(f,null),children:`Blank`}),c.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`notes-template-picker-option`,onClick:()=>void g(f,e.name),children:e.name},e.name))]}),(0,X.jsx)(`button`,{type:`button`,className:`notes-template-picker-cancel`,onClick:()=>p(null),children:`Cancel`})]}),(0,X.jsx)(`div`,{className:`notes-today-bar`,children:(0,X.jsx)(`button`,{type:`button`,className:`notes-today-button`,onClick:()=>void m(),children:`Today`})}),(0,X.jsx)(Fa,{entries:e.tree,selectedPath:e.selectedPath,selectedFolderPath:o,dirtyPath:e.dirtyPath,highlightedPath:e.highlightedPath??null,externalFocusPath:e.externalFocusPath??null,loading:e.loading,notesRoot:e.notesRoot,onSelectPath:e.onSelectedPathChange,onSelectFolder:s,onMovePath:(e,t)=>void v(e,t),onRenamePath:(e,t)=>void y(e,t),onTrashPath:(e,t)=>void x(e,t),onTrashPaths:e=>void b(e)})]}):(0,X.jsx)(Ba,{focusToken:e.searchFocusToken,onSelect:e.onSelectedPathChange,onModeChange:e.onModeChange})]})}var oo=[`default`,`sepia`,`nord`,`solarized-dark`];function so(){let[e,t]=(0,Y.useState)([]),[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(!0);(0,Y.useEffect)(()=>{re().then(e=>{t(e.snippets),r(e.activeTheme),a(!1)}).catch(()=>a(!1))},[]);async function o(e){let t=e==="default"?null:e;r(t),await m(t)}async function s(e,n){t(t=>t.map(t=>t.name===e?{...t,enabled:n}:t)),await h(e,n)}return i?(0,X.jsx)(`div`,{className:`notes-theme-loading`,children:`Loading theme settings...`}):(0,X.jsxs)(`div`,{className:`notes-theme-settings`,children:[(0,X.jsxs)(`fieldset`,{className:`notes-theme-fieldset`,children:[(0,X.jsx)(`legend`,{children:`Theme`}),(0,X.jsx)(`select`,{value:n??`default`,onChange:e=>void o(e.target.value),children:oo.map(e=>(0,X.jsx)(`option`,{value:e,children:e},e))})]}),e.length>0&&(0,X.jsxs)(`fieldset`,{className:`notes-theme-fieldset`,children:[(0,X.jsx)(`legend`,{children:`CSS Snippets`}),(0,X.jsx)(`div`,{className:`notes-theme-warning`,children:`CSS snippets run trusted local code.`}),e.map(e=>(0,X.jsxs)(`label`,{className:`notes-snippet-toggle`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:t=>void s(e.name,t.target.checked)}),e.name]},e.name))]})]})}function co(){let[e,t]=(0,Y.useState)(null),[n,r]=(0,Y.useState)([]),[i,a]=(0,Y.useState)(new Map);(0,Y.useEffect)(()=>{re().then(e=>{t(e.activeTheme),r(e.snippets.filter(e=>e.enabled).map(e=>e.name))})},[]),(0,Y.useEffect)(()=>{for(let e of n)i.has(e)||O(e).then(t=>{a(n=>new Map(n).set(e,t))})},[n]),(0,Y.useEffect)(()=>{let t=document.documentElement;return e?t.setAttribute(`data-notes-theme`,e):t.removeAttribute(`data-notes-theme`),()=>t.removeAttribute(`data-notes-theme`)},[e]);let o=n.map(e=>i.get(e)).filter(e=>!!e).join(`
5
- `);return o?(0,X.jsx)(`style`,{dangerouslySetInnerHTML:{__html:o}}):null}function lo(){return lo=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},lo.apply(null,arguments)}function uo(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var fo=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},po=class e{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(t,n,r){let i=r.facet(Eo).markerFilter;i&&(t=i(t,r));let a=t.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new H,s=[],c=0,l=r.doc.iter(),u=0,d=r.doc.length;for(let e=0;;){let t=e==a.length?null:a[e];if(!t&&!s.length)break;let n,r;if(s.length)n=c,r=s.reduce((e,t)=>Math.min(e,t.to),t&&t.from>n?t.from:1e8);else{if(n=t.from,n>d)break;r=t.to,s.push(t),e++}for(;e<a.length;){let t=a[e];if(t.from==n&&(t.to>t.from||t.to==n))s.push(t),e++,r=Math.min(t.to,r);else{r=Math.min(t.from,r);break}}r=Math.min(r,d);let i=!1;if(s.some(e=>e.from==n&&(e.to==r||r==d))&&(i=n==r,!i&&r-n<10)){let e=n-(u+l.value.length);e>0&&(l.next(e),u=n);for(let e=n;;){if(e>=r){i=!0;break}if(!l.lineBreak&&u+l.value.length>e)break;e=u+l.value.length,u+=l.value.length,l.next()}}let f=Lo(s);if(i)o.add(n,n,J.widget({widget:new Ao(f),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);o.add(n,r,J.mark({class:`cm-lintRange cm-lintRange-`+f+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>r)}))}if(c=r,c==d)break;for(let e=0;e<s.length;e++)s[e].to<=c&&s.splice(e--,1)}let f=o.finish();return new e(f,n,mo(f))}};function mo(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0)){if(!r)r=new fo(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new fo(r.from,n,r.diagnostic)}}),r}function ho(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(Eo).hideOn(e,n,r);if(i!=null)return i;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(_o))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function go(e,t){return e.field(Q,!1)?t:t.concat(Ee.appendConfig.of(Ro))}var _o=Ee.define(),vo=Ee.define(),yo=Ee.define(),Q=ze.define({create(){return new po(J.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=mo(n,e.selected.diagnostic,i)||mo(n,null,i)}!n.size&&i&&t.state.facet(Eo).autoPanel&&(i=null),e=new po(n,i,r)}for(let n of t.effects)if(n.is(_o)){let r=t.state.facet(Eo).autoPanel?n.value.length?Mo.open:null:e.panel;e=po.init(n.value,r,t.state)}else n.is(vo)?e=new po(e.diagnostics,n.value?Mo.open:null,e.selected):n.is(yo)&&(e=new po(e.diagnostics,e.panel,n.value));return e},provide:e=>[Le.from(e,e=>e.panel),W.decorations.from(e,e=>e.diagnostics)]}),bo=J.mark({class:`cm-lintRange cm-lintRange-active`});function xo(e,t,n){let{diagnostics:r}=e.state.field(Q),i,a=-1,o=-1;r.between(t-+(n<0),t+ +(n>0),(e,r,{spec:s})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0)))return i=s.diagnostics,a=e,o=r,!1});let s=e.state.facet(Eo).tooltipFilter;return i&&s&&(i=s(i,e.state)),i?{pos:a,end:o,above:e.state.doc.lineAt(a).to<o,create(){return{dom:So(e,i)}}}:null}function So(e,t){return G(`ul`,{class:`cm-tooltip-lint`},t.map(t=>ko(e,t,!1)))}var Co=e=>{let t=e.state.field(Q,!1);(!t||!t.panel)&&e.dispatch({effects:go(e.state,[vo.of(!0)])});let n=He(e,Mo.open);return n&&n.dom.querySelector(`.cm-panel-lint ul`).focus(),!0},wo=e=>{let t=e.state.field(Q,!1);return!t||!t.panel?!1:(e.dispatch({effects:vo.of(!1)}),!0)},To=[{key:`Mod-Shift-m`,run:Co,preventDefault:!0},{key:`F8`,run:e=>{let t=e.state.field(Q,!1);if(!t)return!1;let n=e.state.selection.main,r=mo(t.diagnostics,null,n.to+1);return!r&&(r=mo(t.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],Eo=Xe.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),...ke(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Do,tooltipFilter:Do,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})}}});function Do(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function Oo(e){let t=[];if(e)actions:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue actions}}t.push(``)}return t}function ko(e,t,n){let r=n?Oo(t.actions):[];return G(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},G(`span`,{class:`cm-diagnosticText`},t.renderMessage?t.renderMessage(e):t.message),t.actions?.map((n,i)=>{let a=!1,o=r=>{if(r.preventDefault(),a)return;a=!0;let i=mo(e.state.field(Q).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:s}=n,c=r[i]?s.indexOf(r[i]):-1,l=c<0?s:[s.slice(0,c),G(`u`,s.slice(c,c+1)),s.slice(c+1)],u=n.markClass?` `+n.markClass:``;return G(`button`,{type:`button`,class:`cm-diagnosticAction`+u,onclick:o,onmousedown:o,"aria-label":` Action: ${s}${c<0?``:` (access key "${r[i]})"`}.`},l)}),t.source&&G(`div`,{class:`cm-diagnosticSource`},t.source))}var Ao=class extends je{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return G(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},jo=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=ko(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},Mo=class e{constructor(e){this.view=e,this.items=[];let t=t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.keyCode==27)wo(this.view),this.view.focus();else if(t.keyCode==38||t.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(t.keyCode==40||t.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(t.keyCode==36)this.moveSelection(0);else if(t.keyCode==35)this.moveSelection(this.items.length-1);else if(t.keyCode==13)this.view.focus();else if(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],r=Oo(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=mo(this.view.state.field(Q).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}else return;t.preventDefault()}},n=e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)};this.list=G(`ul`,{tabIndex:0,role:`listbox`,"aria-label":this.view.state.phrase(`Diagnostics`),onkeydown:t,onclick:n}),this.dom=G(`div`,{class:`cm-panel-lint`},this.list,G(`button`,{type:`button`,name:`close`,"aria-label":this.view.state.phrase(`close`),onclick:()=>wo(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field(Q).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(Q),n=0,r=!1,i=null,a=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:s})=>{for(let e of s.diagnostics){if(a.has(e))continue;a.add(e);let o=-1,s;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(s=new jo(this.view,e),this.items.splice(n,0,s),r=!0):(s=this.items[o],o>n&&(this.items.splice(n,o-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute(`aria-selected`)||(s.dom.setAttribute(`aria-selected`,`true`),i=s):s.dom.hasAttribute(`aria-selected`)&&s.dom.removeAttribute(`aria-selected`),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new jo(this.view,{from:-1,to:-1,severity:`info`,message:this.view.state.phrase(`No diagnostics`)})),r=!0),i?(this.list.setAttribute(`aria-activedescendant`,i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute(`aria-activedescendant`),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=mo(this.view.state.field(Q).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:yo.of(t)})}static open(t){return new e(t)}};function No(e,t=`viewBox="0 0 40 40"`){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function Po(e){return No(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,`width="6" height="3"`)}var Fo=W.baseTheme({".cm-diagnostic":{padding:`3px 6px 3px 8px`,marginLeft:`-1px`,display:`block`,whiteSpace:`pre-wrap`},".cm-diagnostic-error":{borderLeft:`5px solid #d11`},".cm-diagnostic-warning":{borderLeft:`5px solid orange`},".cm-diagnostic-info":{borderLeft:`5px solid #999`},".cm-diagnostic-hint":{borderLeft:`5px solid #66d`},".cm-diagnosticAction":{font:`inherit`,border:`none`,padding:`2px 4px`,backgroundColor:`#444`,color:`white`,borderRadius:`3px`,marginLeft:`8px`,cursor:`pointer`},".cm-diagnosticSource":{fontSize:`70%`,opacity:.7},".cm-lintRange":{backgroundPosition:`left bottom`,backgroundRepeat:`repeat-x`,paddingBottom:`0.7px`},".cm-lintRange-error":{backgroundImage:Po(`#d11`)},".cm-lintRange-warning":{backgroundImage:Po(`orange`)},".cm-lintRange-info":{backgroundImage:Po(`#999`)},".cm-lintRange-hint":{backgroundImage:Po(`#66d`)},".cm-lintRange-active":{backgroundColor:`#ffdd9980`},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:`relative`,"&:after":{content:`""`,position:`absolute`,bottom:0,left:`-2px`,borderLeft:`3px solid transparent`,borderRight:`3px solid transparent`,borderBottom:`4px solid #d11`}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:`orange`}},".cm-lintPoint-info":{"&:after":{borderBottomColor:`#999`}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:`#66d`}},".cm-panel.cm-panel-lint":{position:`relative`,"& ul":{maxHeight:`100px`,overflowY:`auto`,"& [aria-selected]":{backgroundColor:`#ddd`,"& u":{textDecoration:`underline`}},"&:focus [aria-selected]":{background_fallback:`#bdf`,backgroundColor:`Highlight`,color_fallback:`white`,color:`HighlightText`},"& u":{textDecoration:`none`},padding:0,margin:0},"& [name=close]":{position:`absolute`,top:`0`,right:`2px`,background:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:`#86714a80`},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:`#2e343e`}}});function Io(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function Lo(e){let t=`hint`,n=1;for(let r of e){let e=Io(r.severity);e>n&&(n=e,t=r.severity)}return t}var Ro=[Q,W.decorations.compute([Q],e=>{let{selected:t,panel:n}=e.field(Q);return!t||!n||t.from==t.to?J.none:J.set([bo.range(t.from,t.to)])}),Ke(xo,{hideOn:ho}),Fo],zo=function(e){e===void 0&&(e={});var{crosshairCursor:t=!1}=e,n=[];e.closeBracketsKeymap!==!1&&(n=n.concat(ot)),e.defaultKeymap!==!1&&(n=n.concat(it)),e.searchKeymap!==!1&&(n=n.concat(nt)),e.historyKeymap!==!1&&(n=n.concat(et)),e.foldKeymap!==!1&&(n=n.concat(Ze)),e.completionKeymap!==!1&&(n=n.concat(lt)),e.lintKeymap!==!1&&(n=n.concat(To));var r=[];return e.lineNumbers!==!1&&r.push(Ve()),e.highlightActiveLineGutter!==!1&&r.push(Me()),e.highlightSpecialChars!==!1&&r.push(We()),e.history!==!1&&r.push($e()),e.foldGutter!==!1&&r.push(Qe()),e.drawSelection!==!1&&r.push(Te()),e.dropCursor!==!1&&r.push(q()),e.allowMultipleSelections!==!1&&r.push(z.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&r.push(De()),e.syntaxHighlighting!==!1&&r.push(V(Ge,{fallback:!0})),e.bracketMatching!==!1&&r.push(Je()),e.closeBrackets!==!1&&r.push(ut()),e.autocompletion!==!1&&r.push(ct()),e.rectangularSelection!==!1&&r.push(Ie()),t!==!1&&r.push(Ae()),e.highlightActiveLine!==!1&&r.push(Re()),e.highlightSelectionMatches!==!1&&r.push(rt()),e.tabSize&&typeof e.tabSize==`number`&&r.push(Be.of(` `.repeat(e.tabSize))),r.concat([Pe.of(n.flat())]).filter(Boolean)},Bo=`#e5c07b`,Vo=`#e06c75`,Ho=`#56b6c2`,Uo=`#ffffff`,Wo=`#abb2bf`,Go=`#7d8799`,Ko=`#61afef`,qo=`#98c379`,Jo=`#d19a66`,Yo=`#c678dd`,Xo=`#21252b`,Zo=`#2c313a`,Qo=`#282c34`,$o=`#353a42`,es=`#3E4451`,ts=`#528bff`,ns=W.theme({"&":{color:Wo,backgroundColor:Qo},".cm-content":{caretColor:ts},".cm-cursor, .cm-dropCursor":{borderLeftColor:ts},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:es},".cm-panels":{backgroundColor:Xo,color:Wo},".cm-panels.cm-panels-top":{borderBottom:`2px solid black`},".cm-panels.cm-panels-bottom":{borderTop:`2px solid black`},".cm-searchMatch":{backgroundColor:`#72a1ff59`,outline:`1px solid #457dff`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:`#6199ff2f`},".cm-activeLine":{backgroundColor:`#6699ff0b`},".cm-selectionMatch":{backgroundColor:`#aafe661a`},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bad0f847`},".cm-gutters":{backgroundColor:Qo,color:Go,border:`none`},".cm-activeLineGutter":{backgroundColor:Zo},".cm-foldPlaceholder":{backgroundColor:`transparent`,border:`none`,color:`#ddd`},".cm-tooltip":{border:`none`,backgroundColor:$o},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:`transparent`,borderBottomColor:`transparent`},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:$o,borderBottomColor:$o},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Zo,color:Wo}}},{dark:!0}),rs=qe.define([{tag:B.keyword,color:Yo},{tag:[B.name,B.deleted,B.character,B.propertyName,B.macroName],color:Vo},{tag:[B.function(B.variableName),B.labelName],color:Ko},{tag:[B.color,B.constant(B.name),B.standard(B.name)],color:Jo},{tag:[B.definition(B.name),B.separator],color:Wo},{tag:[B.typeName,B.className,B.number,B.changed,B.annotation,B.modifier,B.self,B.namespace],color:Bo},{tag:[B.operator,B.operatorKeyword,B.url,B.escape,B.regexp,B.link,B.special(B.string)],color:Ho},{tag:[B.meta,B.comment],color:Go},{tag:B.strong,fontWeight:`bold`},{tag:B.emphasis,fontStyle:`italic`},{tag:B.strikethrough,textDecoration:`line-through`},{tag:B.link,color:Go,textDecoration:`underline`},{tag:B.heading,fontWeight:`bold`,color:Vo},{tag:[B.atom,B.bool,B.special(B.variableName)],color:Jo},{tag:[B.processingInstruction,B.string,B.inserted],color:qo},{tag:B.invalid,color:Uo}]),is=[ns,V(rs)],as=W.theme({"&":{backgroundColor:`#fff`}},{dark:!1}),os=function(e){e===void 0&&(e={});var{indentWithTab:t=!0,editable:n=!0,readOnly:r=!1,theme:i=`light`,placeholder:a=``,basicSetup:o=!0}=e,s=[];switch(t&&s.unshift(Pe.of([tt])),o&&(typeof o==`boolean`?s.unshift(zo()):s.unshift(zo(o))),a&&s.unshift(Fe(a)),i){case`light`:s.push(as);break;case`dark`:s.push(is);break;case`none`:break;default:s.push(i)}return n===!1&&s.push(W.editable.of(!1)),r&&s.push(z.readOnly.of(!0)),[...s]},ss=e=>({line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map(t=>e.state.sliceDoc(t.from,t.to)),selectedText:e.state.selection.ranges.some(e=>!e.empty)}),cs=class{constructor(e,t){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=t,this.timeoutMS=t,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(e=>{try{e()}catch(e){console.error(`TimeoutLatch callback error:`,e)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}},ls=class{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}},us=null,ds=()=>typeof window>`u`?new ls:(us||=new ls,us),fs=Ye.define(),ps=200,ms=[];function hs(e){var{value:t,selection:n,onChange:r,onStatistics:i,onCreateEditor:a,onUpdate:o,extensions:s=ms,autoFocus:c,theme:l=`light`,height:u=null,minHeight:d=null,maxHeight:f=null,width:p=null,minWidth:m=null,maxWidth:h=null,placeholder:g=``,editable:_=!0,readOnly:v=!1,indentWithTab:y=!0,basicSetup:b=!0,root:x,initialState:S}=e,[C,w]=(0,Y.useState)(),[T,E]=(0,Y.useState)(),[D,O]=(0,Y.useState)(),k=(0,Y.useState)(()=>({current:null}))[0],A=(0,Y.useState)(()=>({current:null}))[0],ee=W.theme({"&":{height:u,minHeight:d,maxHeight:f,width:p,minWidth:m,maxWidth:h},"& .cm-scroller":{height:`100% !important`}}),j=[W.updateListener.of(e=>{e.docChanged&&typeof r==`function`&&!e.transactions.some(e=>e.annotation(fs))&&(k.current?k.current.reset():(k.current=new cs(()=>{if(A.current){var e=A.current;A.current=null,e()}k.current=null},ps),ds().add(k.current)),r(e.state.doc.toString(),e)),i&&i(ss(e))}),ee,...os({theme:l,editable:_,readOnly:v,placeholder:g,indentWithTab:y,basicSetup:b})];return o&&typeof o==`function`&&j.push(W.updateListener.of(o)),j=j.concat(s),(0,Y.useLayoutEffect)(()=>{if(C&&!D){var e={doc:t,selection:n,extensions:j},r=S?z.fromJSON(S.json,e,S.fields):z.create(e);if(O(r),!T){var i=new W({state:r,parent:C,root:x});E(i),a&&a(i,r)}}return()=>{T&&(O(void 0),E(void 0))}},[C,D]),(0,Y.useEffect)(()=>{e.container&&w(e.container)},[e.container]),(0,Y.useEffect)(()=>()=>{T&&(T.destroy(),E(void 0)),k.current&&=(k.current.cancel(),null)},[T]),(0,Y.useEffect)(()=>{c&&T&&T.focus()},[c,T]),(0,Y.useEffect)(()=>{T&&T.dispatch({effects:Ee.reconfigure.of(j)})},[l,s,u,d,f,p,m,h,g,_,v,y,b,r,o]),(0,Y.useEffect)(()=>{if(t!==void 0){var e=T?T.state.doc.toString():``;if(T&&t!==e){var n=k.current&&!k.current.isDone,r=()=>{T&&t!==T.state.doc.toString()&&T.dispatch({changes:{from:0,to:T.state.doc.toString().length,insert:t||``},annotations:[fs.of(!0)]})};n?A.current=r:r()}}},[t,T]),{state:D,setState:O,view:T,setView:E,container:C,setContainer:w}}var gs=[`className`,`value`,`selection`,`extensions`,`onChange`,`onStatistics`,`onCreateEditor`,`onUpdate`,`autoFocus`,`theme`,`height`,`minHeight`,`maxHeight`,`width`,`minWidth`,`maxWidth`,`basicSetup`,`placeholder`,`indentWithTab`,`editable`,`readOnly`,`root`,`initialState`],_s=(0,Y.forwardRef)((e,t)=>{var{className:n,value:r=``,selection:i,extensions:a=[],onChange:o,onStatistics:s,onCreateEditor:c,onUpdate:l,autoFocus:u,theme:d=`light`,height:f,minHeight:p,maxHeight:m,width:h,minWidth:g,maxWidth:_,basicSetup:v,placeholder:y,indentWithTab:b,editable:x,readOnly:S,root:C,initialState:w}=e,T=uo(e,gs),E=(0,Y.useRef)(null),{state:D,view:O,container:k,setContainer:A}=hs({root:C,value:r,autoFocus:u,theme:d,height:f,minHeight:p,maxHeight:m,width:h,minWidth:g,maxWidth:_,basicSetup:v,placeholder:y,indentWithTab:b,editable:x,readOnly:S,selection:i,onChange:o,onStatistics:s,onCreateEditor:c,onUpdate:l,extensions:a,initialState:w});(0,Y.useImperativeHandle)(t,()=>({editor:E.current,state:D,view:O}),[E,k,D,O]);var ee=(0,Y.useCallback)(e=>{E.current=e,A(e)},[A]);if(typeof r!=`string`)throw Error(`value must be typeof string but got `+typeof r);var j=typeof d==`string`?`cm-theme-`+d:`cm-theme`;return(0,X.jsx)(`div`,lo({ref:ee,className:``+j+(n?` `+n:``)},T))});_s.displayName=`CodeMirror`;function $(e){return new Ue(Ne.define(e))}function vs(e){return t(()=>import(`./dist-TN2_Nms3.js`).then(t=>t.sql({dialect:t[e]})),[])}var ys=[K.of({name:`C`,extensions:[`c`,`h`,`ino`],load(){return t(()=>import(`./dist-ClT6EIJP.js`).then(e=>e.cpp()),[])}}),K.of({name:`C++`,alias:[`cpp`],extensions:[`cpp`,`c++`,`cc`,`cxx`,`hpp`,`h++`,`hh`,`hxx`],load(){return t(()=>import(`./dist-ClT6EIJP.js`).then(e=>e.cpp()),[])}}),K.of({name:`CQL`,alias:[`cassandra`],extensions:[`cql`],load(){return vs(`Cassandra`)}}),K.of({name:`CSS`,extensions:[`css`],load(){return t(()=>import(`./dist-Y0iINzVl.js`).then(e=>e.css()),[])}}),K.of({name:`Go`,extensions:[`go`],load(){return t(()=>import(`./dist-Ohtnri73.js`).then(e=>e.go()),[])}}),K.of({name:`HTML`,alias:[`xhtml`],extensions:[`html`,`htm`,`handlebars`,`hbs`],load(){return t(()=>import(`./dist-Dxy8kUAu.js`).then(e=>e.html()),[])}}),K.of({name:`Java`,extensions:[`java`],load(){return t(()=>import(`./dist-DJGc9cyj.js`).then(e=>e.java()),[])}}),K.of({name:`JavaScript`,alias:[`ecmascript`,`js`,`node`],extensions:[`js`,`mjs`,`cjs`],load(){return t(()=>import(`./dist-C9i-hLBK.js`).then(e=>e.javascript()),[])}}),K.of({name:`Jinja`,extensions:[`j2`,`jinja`,`jinja2`],load(){return t(()=>import(`./dist-XM8qpb8C.js`).then(e=>e.jinja()),[])}}),K.of({name:`JSON`,alias:[`json5`],extensions:[`json`,`map`],load(){return t(()=>import(`./dist-CGUtB2hn.js`).then(e=>e.json()),[])}}),K.of({name:`JSX`,extensions:[`jsx`],load(){return t(()=>import(`./dist-C9i-hLBK.js`).then(e=>e.javascript({jsx:!0})),[])}}),K.of({name:`LESS`,extensions:[`less`],load(){return t(()=>import(`./dist-lsEiXLAb.js`).then(e=>e.less()),[])}}),K.of({name:`Liquid`,extensions:[`liquid`],load(){return t(()=>import(`./dist-CJNnOuaA.js`).then(e=>e.liquid()),[])}}),K.of({name:`MariaDB SQL`,load(){return vs(`MariaSQL`)}}),K.of({name:`Markdown`,extensions:[`md`,`markdown`,`mkd`],load(){return t(()=>import(`./dist-CPYD5RoF.js`).then(e=>e.markdown()),[])}}),K.of({name:`MS SQL`,load(){return vs(`MSSQL`)}}),K.of({name:`MySQL`,load(){return vs(`MySQL`)}}),K.of({name:`PHP`,extensions:[`php`,`php3`,`php4`,`php5`,`php7`,`phtml`],load(){return t(()=>import(`./dist-B2ugUS7T.js`).then(e=>e.php()),[])}}),K.of({name:`PLSQL`,extensions:[`pls`],load(){return vs(`PLSQL`)}}),K.of({name:`PostgreSQL`,load(){return vs(`PostgreSQL`)}}),K.of({name:`Python`,extensions:[`BUILD`,`bzl`,`py`,`pyw`],filename:/^(BUCK|BUILD)$/,load(){return t(()=>import(`./dist--wUCkuiC.js`).then(e=>e.python()),[])}}),K.of({name:`Rust`,extensions:[`rs`],load(){return t(()=>import(`./dist-Cbkb9LHa.js`).then(e=>e.rust()),[])}}),K.of({name:`Sass`,extensions:[`sass`],load(){return t(()=>import(`./dist-Box-O1ow.js`).then(e=>e.sass({indented:!0})),[])}}),K.of({name:`SCSS`,extensions:[`scss`],load(){return t(()=>import(`./dist-Box-O1ow.js`).then(e=>e.sass()),[])}}),K.of({name:`SQL`,extensions:[`sql`],load(){return vs(`StandardSQL`)}}),K.of({name:`SQLite`,load(){return vs(`SQLite`)}}),K.of({name:`TSX`,extensions:[`tsx`],load(){return t(()=>import(`./dist-C9i-hLBK.js`).then(e=>e.javascript({jsx:!0,typescript:!0})),[])}}),K.of({name:`TypeScript`,alias:[`ts`],extensions:[`ts`,`mts`,`cts`],load(){return t(()=>import(`./dist-C9i-hLBK.js`).then(e=>e.javascript({typescript:!0})),[])}}),K.of({name:`WebAssembly`,extensions:[`wat`,`wast`],load(){return t(()=>import(`./dist-Ds6qQDMC.js`).then(e=>e.wast()),[])}}),K.of({name:`XML`,alias:[`rss`,`wsdl`,`xsd`],extensions:[`xml`,`xsl`,`xsd`,`svg`],load(){return t(()=>import(`./dist-B_o5XbiL.js`).then(e=>e.xml()),[])}}),K.of({name:`YAML`,alias:[`yml`],extensions:[`yaml`,`yml`],load(){return t(()=>import(`./dist-CW1HDUim.js`).then(e=>e.yaml()),[])}}),K.of({name:`APL`,extensions:[`dyalog`,`apl`],load(){return t(()=>import(`./apl-gfMMiTNf.js`).then(e=>$(e.apl)),[])}}),K.of({name:`PGP`,alias:[`asciiarmor`],extensions:[`asc`,`pgp`,`sig`],load(){return t(()=>import(`./asciiarmor-C_eisQCp.js`).then(e=>$(e.asciiArmor)),[])}}),K.of({name:`ASN.1`,extensions:[`asn`,`asn1`],load(){return t(()=>import(`./asn1-DCl_8MCW.js`).then(e=>$(e.asn1({}))),[])}}),K.of({name:`Asterisk`,filename:/^extensions\.conf$/i,load(){return t(()=>import(`./asterisk-BEn0Cwpx.js`).then(e=>$(e.asterisk)),[])}}),K.of({name:`Brainfuck`,extensions:[`b`,`bf`],load(){return t(()=>import(`./brainfuck-D5EjA2JK.js`).then(e=>$(e.brainfuck)),[])}}),K.of({name:`Cobol`,extensions:[`cob`,`cpy`],load(){return t(()=>import(`./cobol-DHLQUbN7.js`).then(e=>$(e.cobol)),[])}}),K.of({name:`C#`,alias:[`csharp`,`cs`],extensions:[`cs`],load(){return t(()=>import(`./clike-D_6L3tnO.js`).then(e=>$(e.csharp)),[])}}),K.of({name:`Clojure`,extensions:[`clj`,`cljc`,`cljx`],load(){return t(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[])}}),K.of({name:`ClojureScript`,extensions:[`cljs`],load(){return t(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[])}}),K.of({name:`Closure Stylesheets (GSS)`,extensions:[`gss`],load(){return t(()=>import(`./css-CnaYoQib.js`).then(e=>$(e.gss)),[])}}),K.of({name:`CMake`,extensions:[`cmake`,`cmake.in`],filename:/^CMakeLists\.txt$/,load(){return t(()=>import(`./cmake-84nbDH0I.js`).then(e=>$(e.cmake)),[])}}),K.of({name:`CoffeeScript`,alias:[`coffee`,`coffee-script`],extensions:[`coffee`],load(){return t(()=>import(`./coffeescript-De_zI4J0.js`).then(e=>$(e.coffeeScript)),[])}}),K.of({name:`Common Lisp`,alias:[`lisp`],extensions:[`cl`,`lisp`,`el`],load(){return t(()=>import(`./commonlisp-DgAKBe0r.js`).then(e=>$(e.commonLisp)),[])}}),K.of({name:`Cypher`,extensions:[`cyp`,`cypher`],load(){return t(()=>import(`./cypher-p9eYesGn.js`).then(e=>$(e.cypher)),[])}}),K.of({name:`Cython`,extensions:[`pyx`,`pxd`,`pxi`],load(){return t(()=>import(`./python-B_1Jd8HM.js`).then(e=>$(e.cython)),[])}}),K.of({name:`Crystal`,extensions:[`cr`],load(){return t(()=>import(`./crystal-Bsdphhtm.js`).then(e=>$(e.crystal)),[])}}),K.of({name:`D`,extensions:[`d`],load(){return t(()=>import(`./d-DWkQyNnU.js`).then(e=>$(e.d)),[])}}),K.of({name:`Dart`,extensions:[`dart`],load(){return t(()=>import(`./clike-D_6L3tnO.js`).then(e=>$(e.dart)),[])}}),K.of({name:`diff`,extensions:[`diff`,`patch`],load(){return t(()=>import(`./diff-ChtP43wD.js`).then(e=>$(e.diff)),[])}}),K.of({name:`Dockerfile`,filename:/^Dockerfile$/,load(){return t(()=>import(`./dockerfile-DJkHQgkl.js`).then(e=>$(e.dockerFile)),[])}}),K.of({name:`DTD`,extensions:[`dtd`],load(){return t(()=>import(`./dtd-DTF72YNO.js`).then(e=>$(e.dtd)),[])}}),K.of({name:`Dylan`,extensions:[`dylan`,`dyl`,`intr`],load(){return t(()=>import(`./dylan-BCDoL_-p.js`).then(e=>$(e.dylan)),[])}}),K.of({name:`EBNF`,load(){return t(()=>import(`./ebnf-D4c0_ac3.js`).then(e=>$(e.ebnf)),[])}}),K.of({name:`ECL`,extensions:[`ecl`],load(){return t(()=>import(`./ecl-BVIeWmwY.js`).then(e=>$(e.ecl)),[])}}),K.of({name:`edn`,extensions:[`edn`],load(){return t(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[])}}),K.of({name:`Eiffel`,extensions:[`e`],load(){return t(()=>import(`./eiffel-BEjRio4Q.js`).then(e=>$(e.eiffel)),[])}}),K.of({name:`Elm`,extensions:[`elm`],load(){return t(()=>import(`./elm-Cshzl8qu.js`).then(e=>$(e.elm)),[])}}),K.of({name:`Erlang`,extensions:[`erl`],load(){return t(()=>import(`./erlang-BV0c4Hdn.js`).then(e=>$(e.erlang)),[])}}),K.of({name:`Esper`,load(){return t(()=>import(`./sql-DuQMFDvy.js`).then(e=>$(e.esper)),[])}}),K.of({name:`Factor`,extensions:[`factor`],load(){return t(()=>import(`./factor-LKH5gN8L.js`).then(e=>$(e.factor)),[])}}),K.of({name:`FCL`,load(){return t(()=>import(`./fcl-ClOhbFR7.js`).then(e=>$(e.fcl)),[])}}),K.of({name:`Forth`,extensions:[`forth`,`fth`,`4th`],load(){return t(()=>import(`./forth-D6RzAl64.js`).then(e=>$(e.forth)),[])}}),K.of({name:`Fortran`,extensions:[`f`,`for`,`f77`,`f90`,`f95`],load(){return t(()=>import(`./fortran-Bt6PBEDR.js`).then(e=>$(e.fortran)),[])}}),K.of({name:`F#`,alias:[`fsharp`],extensions:[`fs`],load(){return t(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.fSharp)),[])}}),K.of({name:`Gas`,extensions:[`s`],load(){return t(()=>import(`./gas-BHEdbvp9.js`).then(e=>$(e.gas)),[])}}),K.of({name:`Gherkin`,extensions:[`feature`],load(){return t(()=>import(`./gherkin-oBAE_ms0.js`).then(e=>$(e.gherkin)),[])}}),K.of({name:`Groovy`,extensions:[`groovy`,`gradle`],filename:/^Jenkinsfile$/,load(){return t(()=>import(`./groovy-CUpZ7dEl.js`).then(e=>$(e.groovy)),[])}}),K.of({name:`Haskell`,extensions:[`hs`],load(){return t(()=>import(`./haskell-BRsoo5mP.js`).then(e=>$(e.haskell)),[])}}),K.of({name:`Haxe`,extensions:[`hx`],load(){return t(()=>import(`./haxe-DjVOVvNP.js`).then(e=>$(e.haxe)),[])}}),K.of({name:`HXML`,extensions:[`hxml`],load(){return t(()=>import(`./haxe-DjVOVvNP.js`).then(e=>$(e.hxml)),[])}}),K.of({name:`HTTP`,load(){return t(()=>import(`./http-CLVgA2GD.js`).then(e=>$(e.http)),[])}}),K.of({name:`IDL`,extensions:[`pro`],load(){return t(()=>import(`./idl-BUZw3wgd.js`).then(e=>$(e.idl)),[])}}),K.of({name:`JSON-LD`,alias:[`jsonld`],extensions:[`jsonld`],load(){return t(()=>import(`./javascript-DctB8BJo.js`).then(e=>$(e.jsonld)),[])}}),K.of({name:`Julia`,extensions:[`jl`],load(){return t(()=>import(`./julia-CQfgDRfP.js`).then(e=>$(e.julia)),[])}}),K.of({name:`Kotlin`,extensions:[`kt`,`kts`],load(){return t(()=>import(`./clike-D_6L3tnO.js`).then(e=>$(e.kotlin)),[])}}),K.of({name:`LiveScript`,alias:[`ls`],extensions:[`ls`],load(){return t(()=>import(`./livescript-BXxG0Yva.js`).then(e=>$(e.liveScript)),[])}}),K.of({name:`Lua`,extensions:[`lua`],load(){return t(()=>import(`./lua-zbJo2mq3.js`).then(e=>$(e.lua)),[])}}),K.of({name:`mIRC`,extensions:[`mrc`],load(){return t(()=>import(`./mirc-C9zpzAZU.js`).then(e=>$(e.mirc)),[])}}),K.of({name:`Mathematica`,extensions:[`m`,`nb`,`wl`,`wls`],load(){return t(()=>import(`./mathematica-u8YMmbU0.js`).then(e=>$(e.mathematica)),[])}}),K.of({name:`Modelica`,extensions:[`mo`],load(){return t(()=>import(`./modelica-CqHI_q-D.js`).then(e=>$(e.modelica)),[])}}),K.of({name:`MUMPS`,extensions:[`mps`],load(){return t(()=>import(`./mumps-BSzj6Xyz.js`).then(e=>$(e.mumps)),[])}}),K.of({name:`Mbox`,extensions:[`mbox`],load(){return t(()=>import(`./mbox-BEMVcqjs.js`).then(e=>$(e.mbox)),[])}}),K.of({name:`Nginx`,filename:/nginx.*\.conf$/i,load(){return t(()=>import(`./nginx-8H7HVH4w.js`).then(e=>$(e.nginx)),[])}}),K.of({name:`NSIS`,extensions:[`nsh`,`nsi`],load(){return t(()=>import(`./nsis-CfSuhXs5.js`).then(e=>$(e.nsis)),[])}}),K.of({name:`NTriples`,extensions:[`nt`,`nq`],load(){return t(()=>import(`./ntriples-B9h1VB_g.js`).then(e=>$(e.ntriples)),[])}}),K.of({name:`Objective-C`,alias:[`objective-c`,`objc`],extensions:[`m`],load(){return t(()=>import(`./clike-D_6L3tnO.js`).then(e=>$(e.objectiveC)),[])}}),K.of({name:`Objective-C++`,alias:[`objective-c++`,`objc++`],extensions:[`mm`],load(){return t(()=>import(`./clike-D_6L3tnO.js`).then(e=>$(e.objectiveCpp)),[])}}),K.of({name:`OCaml`,extensions:[`ml`,`mli`,`mll`,`mly`],load(){return t(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.oCaml)),[])}}),K.of({name:`Octave`,extensions:[`m`],load(){return t(()=>import(`./octave-D2Q8cUp1.js`).then(e=>$(e.octave)),[])}}),K.of({name:`Oz`,extensions:[`oz`],load(){return t(()=>import(`./oz-BwTct_5T.js`).then(e=>$(e.oz)),[])}}),K.of({name:`Pascal`,extensions:[`p`,`pas`],load(){return t(()=>import(`./pascal-Dp_KdFgX.js`).then(e=>$(e.pascal)),[])}}),K.of({name:`Perl`,extensions:[`pl`,`pm`],load(){return t(()=>import(`./perl-BkSkiI9m.js`).then(e=>$(e.perl)),[])}}),K.of({name:`Pig`,extensions:[`pig`],load(){return t(()=>import(`./pig-AF4Hwhju.js`).then(e=>$(e.pig)),[])}}),K.of({name:`PowerShell`,extensions:[`ps1`,`psd1`,`psm1`],load(){return t(()=>import(`./powershell-BcIto6Sf.js`).then(e=>$(e.powerShell)),[])}}),K.of({name:`Properties files`,alias:[`ini`,`properties`],extensions:[`properties`,`ini`,`in`],load(){return t(()=>import(`./properties-C357ku5U.js`).then(e=>$(e.properties)),[])}}),K.of({name:`ProtoBuf`,extensions:[`proto`],load(){return t(()=>import(`./protobuf-D1ij_kNL.js`).then(e=>$(e.protobuf)),[])}}),K.of({name:`Pug`,alias:[`jade`],extensions:[`pug`,`jade`],load(){return t(()=>import(`./pug-CqqUmdG7.js`).then(e=>$(e.pug)),[])}}),K.of({name:`Puppet`,extensions:[`pp`],load(){return t(()=>import(`./puppet-BZyAS7I4.js`).then(e=>$(e.puppet)),[])}}),K.of({name:`Q`,extensions:[`q`],load(){return t(()=>import(`./q-B9NhS7L_.js`).then(e=>$(e.q)),[])}}),K.of({name:`R`,alias:[`rscript`],extensions:[`r`,`R`],load(){return t(()=>import(`./r-CxDmU1I4.js`).then(e=>$(e.r)),[])}}),K.of({name:`RPM Changes`,load(){return t(()=>import(`./rpm-gpDK5sbt.js`).then(e=>$(e.rpmChanges)),[])}}),K.of({name:`RPM Spec`,extensions:[`spec`],load(){return t(()=>import(`./rpm-gpDK5sbt.js`).then(e=>$(e.rpmSpec)),[])}}),K.of({name:`Ruby`,alias:[`jruby`,`macruby`,`rake`,`rb`,`rbx`],extensions:[`rb`],filename:/^(Gemfile|Rakefile)$/,load(){return t(()=>import(`./ruby-BjXV7-Qa.js`).then(e=>$(e.ruby)),[])}}),K.of({name:`SAS`,extensions:[`sas`],load(){return t(()=>import(`./sas-C2OyD2Y6.js`).then(e=>$(e.sas)),[])}}),K.of({name:`Scala`,extensions:[`scala`],load(){return t(()=>import(`./clike-D_6L3tnO.js`).then(e=>$(e.scala)),[])}}),K.of({name:`Scheme`,extensions:[`scm`,`ss`],load(){return t(()=>import(`./scheme-D9qYN0V5.js`).then(e=>$(e.scheme)),[])}}),K.of({name:`Shell`,alias:[`bash`,`sh`,`zsh`],extensions:[`sh`,`ksh`,`bash`],filename:/^PKGBUILD$/,load(){return t(()=>import(`./shell-DwuoZtxw.js`).then(e=>$(e.shell)),[])}}),K.of({name:`Sieve`,extensions:[`siv`,`sieve`],load(){return t(()=>import(`./sieve-tLWDfEkZ.js`).then(e=>$(e.sieve)),[])}}),K.of({name:`Smalltalk`,extensions:[`st`],load(){return t(()=>import(`./smalltalk-BLp5-jwC.js`).then(e=>$(e.smalltalk)),[])}}),K.of({name:`Solr`,load(){return t(()=>import(`./solr-B78wSQJQ.js`).then(e=>$(e.solr)),[])}}),K.of({name:`SML`,extensions:[`sml`,`sig`,`fun`,`smackspec`],load(){return t(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.sml)),[])}}),K.of({name:`SPARQL`,alias:[`sparul`],extensions:[`rq`,`sparql`],load(){return t(()=>import(`./sparql-Dz-mlCAC.js`).then(e=>$(e.sparql)),[])}}),K.of({name:`Spreadsheet`,alias:[`excel`,`formula`],load(){return t(()=>import(`./spreadsheet-CTIncYxj.js`).then(e=>$(e.spreadsheet)),[])}}),K.of({name:`Squirrel`,extensions:[`nut`],load(){return t(()=>import(`./clike-D_6L3tnO.js`).then(e=>$(e.squirrel)),[])}}),K.of({name:`Stylus`,extensions:[`styl`],load(){return t(()=>import(`./stylus-BOVgKnng.js`).then(e=>$(e.stylus)),[])}}),K.of({name:`Swift`,extensions:[`swift`],load(){return t(()=>import(`./swift-DKB6_1j6.js`).then(e=>$(e.swift)),[])}}),K.of({name:`sTeX`,load(){return t(()=>import(`./stex-DNzd62Q_.js`).then(e=>$(e.stex)),[])}}),K.of({name:`LaTeX`,alias:[`tex`],extensions:[`text`,`ltx`,`tex`],load(){return t(()=>import(`./stex-DNzd62Q_.js`).then(e=>$(e.stex)),[])}}),K.of({name:`SystemVerilog`,extensions:[`v`,`sv`,`svh`],load(){return t(()=>import(`./verilog-CjI9Y6RI.js`).then(e=>$(e.verilog)),[])}}),K.of({name:`Tcl`,extensions:[`tcl`],load(){return t(()=>import(`./tcl-BGfruO1u.js`).then(e=>$(e.tcl)),[])}}),K.of({name:`Textile`,extensions:[`textile`],load(){return t(()=>import(`./textile-C4jVoHG1.js`).then(e=>$(e.textile)),[])}}),K.of({name:`TiddlyWiki`,load(){return t(()=>import(`./tiddlywiki-VlUiK86J.js`).then(e=>$(e.tiddlyWiki)),[])}}),K.of({name:`Tiki wiki`,load(){return t(()=>import(`./tiki-AK6FwT8q.js`).then(e=>$(e.tiki)),[])}}),K.of({name:`TOML`,extensions:[`toml`],load(){return t(()=>import(`./toml-BPTmHmyx.js`).then(e=>$(e.toml)),[])}}),K.of({name:`Troff`,extensions:[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`],load(){return t(()=>import(`./troff-C2dAgh7P.js`).then(e=>$(e.troff)),[])}}),K.of({name:`TTCN`,extensions:[`ttcn`,`ttcn3`,`ttcnpp`],load(){return t(()=>import(`./ttcn-PPSTk1ow.js`).then(e=>$(e.ttcn)),[])}}),K.of({name:`TTCN_CFG`,extensions:[`cfg`],load(){return t(()=>import(`./ttcn-cfg-2b4Gb5sE.js`).then(e=>$(e.ttcnCfg)),[])}}),K.of({name:`Turtle`,extensions:[`ttl`],load(){return t(()=>import(`./turtle-Cx3rYX2g.js`).then(e=>$(e.turtle)),[])}}),K.of({name:`Web IDL`,extensions:[`webidl`],load(){return t(()=>import(`./webidl-D5jiJvOU.js`).then(e=>$(e.webIDL)),[])}}),K.of({name:`VB.NET`,extensions:[`vb`],load(){return t(()=>import(`./vb-BthdM_4N.js`).then(e=>$(e.vb)),[])}}),K.of({name:`VBScript`,extensions:[`vbs`],load(){return t(()=>import(`./vbscript-D9f6rSsU.js`).then(e=>$(e.vbScript)),[])}}),K.of({name:`Velocity`,extensions:[`vtl`],load(){return t(()=>import(`./velocity-CqftRsjg.js`).then(e=>$(e.velocity)),[])}}),K.of({name:`Verilog`,extensions:[`v`],load(){return t(()=>import(`./verilog-CjI9Y6RI.js`).then(e=>$(e.verilog)),[])}}),K.of({name:`VHDL`,extensions:[`vhd`,`vhdl`],load(){return t(()=>import(`./vhdl-kS471soi.js`).then(e=>$(e.vhdl)),[])}}),K.of({name:`XQuery`,extensions:[`xy`,`xquery`,`xq`,`xqm`,`xqy`],load(){return t(()=>import(`./xquery-BKJx4mf9.js`).then(e=>$(e.xQuery)),[])}}),K.of({name:`Yacas`,extensions:[`ys`],load(){return t(()=>import(`./yacas-CXXgtw0p.js`).then(e=>$(e.yacas)),[])}}),K.of({name:`Z80`,extensions:[`z80`],load(){return t(()=>import(`./z80-Co3PbHdE.js`).then(e=>$(e.z80)),[])}}),K.of({name:`MscGen`,extensions:[`mscgen`,`mscin`,`msc`],load(){return t(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.mscgen)),[])}}),K.of({name:`Xù`,extensions:[`xu`],load(){return t(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.xu)),[])}}),K.of({name:`MsGenny`,extensions:[`msgenny`],load(){return t(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.msgenny)),[])}}),K.of({name:`Vue`,extensions:[`vue`],load(){return t(()=>import(`./dist-DUl4SBwX.js`).then(e=>e.vue()),[])}}),K.of({name:`Angular Template`,load(){return t(()=>import(`./dist-B6-H00Bu.js`).then(e=>e.angular()),[])}})],bs=W.theme({"&":{height:`100%`,color:`var(--text-primary)`,backgroundColor:`var(--canvas-deep)`},".cm-editor":{height:`100%`,color:`var(--text-primary)`,backgroundColor:`var(--canvas-deep)`},".cm-scroller":{fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,backgroundColor:`var(--canvas-deep)`},".cm-content":{caretColor:`var(--text-primary)`},".cm-gutters":{color:`var(--text-tertiary, var(--text-secondary))`,backgroundColor:`var(--canvas-deep)`,borderRight:`1px solid var(--border-subtle)`},".cm-activeLine":{backgroundColor:`var(--canvas-soft)`},".cm-activeLineGutter":{color:`var(--text-primary)`,backgroundColor:`var(--canvas-soft)`},".cm-cursor, .cm-dropCursor":{borderLeftColor:`var(--text-primary)`},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:`var(--selection-bg)`},"&.cm-focused":{outline:`1px solid var(--border-strong)`},".cm-line":{color:`var(--text-primary)`},".cm-panels":{color:`var(--text-primary)`,backgroundColor:`var(--bg-panel)`,borderColor:`var(--border-subtle)`},".cm-tooltip":{color:`var(--text-primary)`,backgroundColor:`var(--bg-panel)`,border:`1px solid var(--border-subtle)`},".cm-matchingBracket, .cm-nonmatchingBracket":{outline:`1px solid var(--accent)`,backgroundColor:`var(--accent-soft)`},".cm-rich-widget":{color:`var(--text-primary)`,backgroundColor:`var(--canvas-soft)`,border:`1px solid var(--border-subtle)`,borderRadius:`6px`},".cm-rich-block":{display:`block`,margin:`6px 0`,padding:`8px 10px`,overflowX:`auto`},".cm-rich-inline":{display:`inline-flex`,alignItems:`center`,maxWidth:`100%`,padding:`0 4px`,verticalAlign:`baseline`},".cm-rich-source-muted":{color:`var(--text-tertiary, var(--text-secondary))`},".cm-rich-widget-error":{color:`var(--danger-strong, var(--text-primary))`,borderColor:`var(--danger-strong, var(--border-subtle))`}},{dark:!0}),xs=qe.define([{tag:B.heading,color:`var(--text-primary)`,fontWeight:`650`},{tag:[B.strong,B.emphasis],color:`var(--text-primary)`},{tag:B.link,color:`var(--accent-strong, var(--accent))`,textDecoration:`underline`},{tag:B.url,color:`var(--accent-strong, var(--accent))`},{tag:[B.keyword,B.atom,B.bool],color:`var(--accent-strong, var(--accent))`},{tag:[B.string,B.special(B.string)],color:`var(--success-strong, var(--text-primary))`},{tag:[B.comment,B.quote],color:`var(--text-tertiary, var(--text-secondary))`},{tag:[B.number,B.integer,B.float],color:`var(--warning-strong, var(--text-primary))`},{tag:[B.variableName,B.propertyName],color:`var(--text-primary)`},{tag:[B.definition(B.variableName),B.function(B.variableName)],color:`var(--accent)`},{tag:[B.punctuation,B.bracket],color:`var(--text-secondary)`},{tag:B.invalid,color:`var(--danger-strong, var(--text-primary))`}]),Ss=V(xs);function Cs(e,t=e){return n=>{let{state:r}=n,i=!1,a=r.changeByRange(n=>{i=!0;let a=r.sliceDoc(n.from,n.to),o=`${e}${a}${t}`,s=n.from+e.length,c=s+a.length;return{changes:{from:n.from,to:n.to,insert:o},range:n.empty?U.cursor(s):U.range(s,c)}});return i?(n.dispatch(a),!0):!1}}var ws=[{key:`Mod-b`,run:Cs(`**`),preventDefault:!0},{key:`Mod-i`,run:Cs(`*`),preventDefault:!0},{key:`Mod-e`,run:Cs("`"),preventDefault:!0},{key:`Mod-k`,run:e=>{let{state:t}=e,n=!1,r=t.changeByRange(e=>{n=!0;let r=t.sliceDoc(e.from,e.to);if(e.empty)return{changes:{from:e.from,insert:`[](url)`},range:U.cursor(e.from+1)};let i=`[${r}](url)`,a=e.from+1+r.length+2,o=a+3;return{changes:{from:e.from,to:e.to,insert:i},range:U.range(a,o)}});return n?(e.dispatch(r),!0):!1},preventDefault:!0}],Ts=d();function Es(e){return(0,X.jsx)(X.Fragment,{children:e.widgets.map(e=>(0,Ts.createPortal)((0,X.jsx)(ft,{markdown:e.markdown}),e.shell,e.id))})}function Ds(e,t,n){return n.selectionFrom<=t&&n.selectionTo>=e}function Os(e,t){return new TextEncoder().encode(e).byteLength<=t.maxSnippetBytes}function ks(e,t,n){e.length>=n.maxWidgets||Ds(t.from,t.to,n)||Os(t.markdown,n)&&e.push(t)}function As(e,t){if(e.length>t.largeNoteDisableThreshold)return[];let n=[],r=0;for(let i of e.matchAll(/^```([^\n`]*)\n[\s\S]*?\n```[ \t]*$/gm)){if(n.length>=t.maxWidgets)break;let e=i.index||0,a=e+i[0].length,o=(i[1]||``).trim().toLowerCase();if(o===`mermaid`){if(r>=t.maxMermaidWidgets)continue;r+=1}ks(n,{from:e,to:a,kind:o===`mermaid`?`mermaid`:`code`,markdown:i[0],block:!0},t)}for(let r of e.matchAll(/^\$\$\n[\s\S]*?\n\$\$[ \t]*$/gm)){if(n.length>=t.maxWidgets)break;let e=r.index||0;ks(n,{from:e,to:e+r[0].length,kind:`math-block`,markdown:r[0],block:!0},t)}for(let r of e.matchAll(/(^|[^$\\])(\$[^$\n]+\$)/g)){if(n.length>=t.maxWidgets)break;let e=r[1].length,i=(r.index||0)+e,a=r[2];ks(n,{from:i,to:i+a.length,kind:`math-inline`,markdown:a,block:!1},t)}return n.sort((e,t)=>e.from-t.from||e.to-t.to)}var js=class e extends je{options;constructor(e){super(),this.options=e}eq(t){return t instanceof e&&this.options.id===t.options.id&&this.options.kind===t.options.kind&&this.options.markdown===t.options.markdown}toDOM(){let e=document.createElement(this.options.block?`div`:`span`);return e.className=this.options.block?`cm-rich-widget cm-rich-block`:`cm-rich-widget cm-rich-inline`,e.dataset.richWidgetId=this.options.id,e.dataset.richWidgetKind=this.options.kind,this.options.registerWidget({id:this.options.id,kind:this.options.kind,markdown:this.options.markdown,shell:e}),queueMicrotask(this.options.requestMeasure),e}updateDOM(e){return this.options.registerWidget({id:this.options.id,kind:this.options.kind,markdown:this.options.markdown,shell:e}),queueMicrotask(this.options.requestMeasure),!0}destroy(){this.options.unregisterWidget(this.options.id)}get estimatedHeight(){return this.options.block?96:20}ignoreEvent(){return!1}},Ms=50,Ns=100,Ps=5e4,Fs=5,Is=1e6,Ls=/^([ \t]*[-*+][ \t]+)\[([ xX])\]([ \t]*)(.*)$/,Rs=class e extends je{range;constructor(e){super(),this.range=e}eq(t){return t instanceof e&&t.range.markerFrom===this.range.markerFrom&&t.range.checked===this.range.checked&&t.range.text===this.range.text}toDOM(e){let t=document.createElement(`label`);t.className=`cm-rich-task-widget`;let n=document.createElement(`input`);n.type=`checkbox`;let r=document.createElement(`span`);return t.append(n,r),this.syncDOM(t,e),t}updateDOM(e,t){return e.classList.contains(`cm-rich-task-widget`)?(this.syncDOM(e,t),!0):!1}destroy(e){let t=e.querySelector(`input[type="checkbox"]`);t&&(t.onchange=null)}ignoreEvent(e){return e.type===`mousedown`||e.type===`click`||e.type===`change`||e.type===`input`||e.type===`keydown`}syncDOM(e,t){let n=e.querySelector(`input[type="checkbox"]`),r=e.querySelector(`span`);n&&r&&(n.checked=this.range.checked,n.setAttribute(`aria-label`,this.range.text||(this.range.checked?`Checked task`:`Unchecked task`)),n.setAttribute(`aria-checked`,this.range.checked?`true`:`false`),n.onchange=()=>{t.dispatch({changes:{from:this.range.markerFrom,to:this.range.markerFrom+3,insert:n.checked?`[x]`:`[ ]`},userEvent:`input.task-toggle`})},r.textContent=this.range.text||`Task`)}};function zs(e){return`rich-${e.kind}-${e.from}-${e.to}-${e.markdown.length}`}function Bs(e){let t=[],n=e.selection.main,r=!1;for(let i=1;i<=e.doc.lines&&!(t.length>=Ns);i+=1){let a=e.doc.line(i);if(/^```/.test(a.text.trim())){r=!r;continue}if(r||n.from<=a.to&&n.to>=a.from)continue;let o=a.text.match(Ls);o&&t.push({from:a.from,to:a.to,markerFrom:a.from+o[1].length,checked:o[2].toLowerCase()===`x`,text:o[4].trim()})}return t}function Vs(e,t){if(!t.enabled||!t.active)return J.none;let n=e.selection.main,r=As(e.doc.toString(),{selectionFrom:n.from,selectionTo:n.to,maxWidgets:Ms,maxSnippetBytes:Ps,maxMermaidWidgets:Fs,largeNoteDisableThreshold:Is}),i=[];for(let t of Bs(e))i.push({from:t.from,to:t.to,decoration:J.replace({widget:new Rs(t)})});for(let e of r)i.push({from:e.from,to:e.to,decoration:J.replace({block:e.block,widget:new js({id:zs(e),kind:e.kind,markdown:e.markdown,block:e.block,registerWidget:t.registerWidget,unregisterWidget:t.unregisterWidget,requestMeasure:t.requestMeasure})})});i.sort((e,t)=>{let n=e.from-t.from;if(n!==0)return n;let r=e.decoration.startSide-t.decoration.startSide;return r===0?e.to-t.to:r});let a=new H;for(let e of i)a.add(e.from,e.to,e.decoration);return a.finish()}function Hs(e){return ze.define({create(t){return Vs(t,e)},update(t,n){return n.docChanged||n.selection?Vs(n.state,e):t.map(n.changes)},provide(e){return[W.decorations.from(e),W.atomicRanges.of(t=>t.state.field(e,!1)??J.none)]}})}function Us(e){let t=document.createElement(`template`);return t.innerHTML=e,t.content.textContent||``}function Ws(e){return W.domEventHandlers({paste(t,n){if(e&&mt(t,n,e))return!0;if(t.clipboardData?.getData(`text/plain`))return!1;let r=t.clipboardData?.getData(`text/html`);return r?(t.preventDefault(),n.dispatch(n.state.replaceSelection(Us(r))),!0):!1},drop(t,n){return!!(e&&pt(t,n,e))}})}function Gs(e){return(t,n,r,i)=>{let a=t.state.sliceDoc(i,i+2)===`]]`?i+2:i;t.dispatch({...at(t.state,_t(e),r,a),annotations:st.of(n)})}}function Ks(e){function t(t){let n=t.state.doc.lineAt(t.pos),r=t.state.sliceDoc(n.from,n.to),i=ht(r,t.pos-n.from);if(!i)return null;let a=n.from+i.to-(i.hasClosingSuffix?2:0),o=gt(e,i.query).map(e=>({label:e.title||e.path,detail:e.path,info:e.matchKind===`alias`?`Alias: ${e.aliases.join(`, `)}`:e.matchKind,type:`text`,apply:Gs(e),boost:e.score}));return o.length===0?null:{from:n.from+i.from,to:a,options:o,validFor:/^[^\]\n]*$/}}return ct({activateOnTyping:!0,override:[t]})}var qs=null;async function Js(){if(qs)return qs;let{vim:e}=await t(async()=>{let{vim:e}=await import(`./dist-Bp7q5-Qc.js`);return{vim:e}},[]);return qs=e(),qs}var Ys=(0,Y.lazy)(async()=>({default:(await t(()=>import(`./MilkdownWysiwygEditor-xObhviw7.js`),__vite__mapDeps([0]))).MilkdownWysiwygEditor}));function Xs(e){let[t,n]=(0,Y.useState)(()=>new Map),[r,i]=(0,Y.useState)(null),a=e.authoringMode===`wysiwyg`;(0,Y.useEffect)(()=>{if(!e.vimMode){i(null);return}let t=!1;return Js().then(e=>{t||i(e)}),()=>{t=!0}},[e.vimMode]);let o=(0,Y.useCallback)(e=>{n(t=>{let n=new Map(t);return n.set(e.id,e),n})},[]),s=(0,Y.useCallback)(e=>{n(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),c=(0,Y.useCallback)(()=>{window.dispatchEvent(new Event(`resize`))},[]),l=(0,Y.useMemo)(()=>{let t=[Oe.highest(Pe.of(ws)),bs,Ss,dt({codeLanguages:ys}),Ks(e.notes),Ws({notePath:e.notePath,onError:e=>console.warn(`[notes-image-paste]`,e)}),Hs({enabled:e.authoringMode===`rich`||e.authoringMode===`wysiwyg`,active:e.active,registerWidget:o,unregisterWidget:s,requestMeasure:c})];return e.wordWrap&&t.push(W.lineWrapping),r&&t.unshift(r),t},[e.active,e.authoringMode,e.notePath,e.notes,e.wordWrap,r,o,c,s]);return a?(0,X.jsx)(`div`,{className:`notes-editor notes-wysiwyg-editor`,children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(`div`,{className:`notes-wysiwyg-loading`,children:`Loading WYSIWYG editor...`}),children:(0,X.jsx)(Ys,{active:e.active,content:e.content,notePath:e.notePath,outgoing:e.outgoing,notes:e.notes,activeTag:e.activeTag,onChange:e.onChange,onTagSelect:e.onTagSelect,onWikiLinkNavigate:e.onWikiLinkNavigate})})}):(0,X.jsxs)(`div`,{className:`notes-editor`,children:[(0,X.jsx)(Es,{widgets:[...t.values()]}),(0,X.jsx)(_s,{value:e.content,extensions:l,onChange:e.onChange,height:`100%`,basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!0}})]})}function Zs(e){return(0,X.jsx)(`article`,{className:`notes-preview`,children:(0,X.jsx)(ft,{markdown:e.markdown,outgoing:e.outgoing,notes:e.notes,onWikiLinkNavigate:e.onWikiLinkNavigate})})}function Qs(e){let t=e.split(`/`).pop()??e;return t.endsWith(`.md`)?t.slice(0,-3):t}function $s(e){let t=[],n=/\[\[([^\]]+)\]\]/g,r=0,i,a=0;for(;(i=n.exec(e))!==null;)i.index>r&&t.push(e.slice(r,i.index)),t.push((0,X.jsx)(`mark`,{className:`backlink-highlight`,children:`[[`+i[1]+`]]`},a++)),r=n.lastIndex;return r<e.length&&t.push(e.slice(r)),t}function ec(e){let[t,n]=(0,Y.useState)(!1),r=(0,Y.useCallback)(t=>{e.onNavigate(t)},[e.onNavigate]),i=e.backlinks.length;return(0,X.jsxs)(`div`,{className:`notes-backlinks-panel`,children:[(0,X.jsxs)(`button`,{className:`notes-backlinks-header`,onClick:()=>n(e=>!e),children:[(0,X.jsx)(`span`,{className:`notes-backlinks-chevron`,children:t?`▶`:`▼`}),(0,X.jsx)(`span`,{children:`Backlinks`}),(0,X.jsx)(`span`,{className:`notes-backlinks-count`,children:i})]}),!t&&(0,X.jsxs)(`div`,{className:`notes-backlinks-list`,children:[i===0&&(0,X.jsx)(`div`,{className:`notes-backlinks-empty`,children:`No backlinks found`}),e.backlinks.map((e,t)=>{let n=e.raw.length>120?e.raw.slice(0,120)+`...`:e.raw;return(0,X.jsxs)(`button`,{className:`notes-backlink-entry`,onClick:()=>r(e.sourcePath),children:[(0,X.jsx)(`span`,{className:`notes-backlink-title`,children:Qs(e.sourcePath)}),(0,X.jsxs)(`span`,{className:`notes-backlink-line`,children:[`L`,e.line]}),(0,X.jsx)(`span`,{className:`notes-backlink-context`,children:$s(n)})]},`${e.sourcePath}:${e.line}:${t}`)})]})]})}function tc(){return(0,X.jsxs)(`section`,{className:`notes-empty-state`,children:[(0,X.jsx)(`strong`,{children:`No notes yet`}),(0,X.jsx)(`span`,{children:`Create a markdown note from the file tree.`})]})}function nc(e){let t=e.note;if(!t)return null;let n=t.aliases||[],r=t.tags||[],i=t.created,a=t.frontmatterError;return!a&&n.length===0&&r.length===0&&!i?null:(0,X.jsxs)(`div`,{className:`notes-frontmatter-strip`,"aria-label":`Note frontmatter`,children:[a&&(0,X.jsxs)(`span`,{className:`notes-frontmatter-error`,role:`alert`,children:[`Frontmatter: `,a]}),n.length>0&&(0,X.jsxs)(`span`,{className:`notes-frontmatter-section`,children:[(0,X.jsx)(`span`,{className:`notes-frontmatter-label`,children:`Aliases`}),(0,X.jsx)(`span`,{className:`notes-frontmatter-value`,children:n.join(`, `)})]}),i&&(0,X.jsxs)(`span`,{className:`notes-frontmatter-section`,children:[(0,X.jsx)(`span`,{className:`notes-frontmatter-label`,children:`Created`}),(0,X.jsx)(`span`,{className:`notes-frontmatter-value`,children:i})]}),r.length>0&&(0,X.jsx)(`span`,{className:`notes-frontmatter-section notes-frontmatter-tags`,children:r.map(t=>{let n=t===e.activeTag;return(0,X.jsxs)(`button`,{type:`button`,className:n?`notes-tag-chip is-active`:`notes-tag-chip`,"aria-pressed":n,title:n?`Clear filter: #${t}`:`Filter notes by #${t}`,onClick:()=>e.onTagClick(n?null:t),children:[`#`,t]},t)})})]})}var rc=50;function ic(e){return e.trim().toLowerCase()}function ac(e,t){let n=ic(e),r=ic(t);if(!r)return 1;if(n.startsWith(r))return 1e3-n.length;let i=n.indexOf(r);if(i>=0)return 700-i;let a=-1,o=0,s=0;for(let e of r){let t=n.indexOf(e,a+1);if(t<0)return null;o=t===a+1?o+1:0,s+=4+o*3-Math.min(t,40)*.1,a=t}return s}function oc(e,t){let n=[{value:e.title,reason:`title`,boost:120},{value:e.path,reason:`path`,boost:40},...e.aliases.map(e=>({value:e,reason:`alias`,boost:80}))],r=null;for(let i of n){let n=ac(i.value,t);if(n==null)continue;let a=n+i.boost;(!r||a>r.score)&&(r={note:e,score:a,reason:i.reason})}return r}function sc(e,t,n=rc){let r=t.trim();return e.map(e=>oc(e,r)).filter(e=>!!e).sort((e,t)=>t.score===e.score?e.note.path.localeCompare(t.note.path):t.score-e.score).slice(0,n)}function cc(e){let[t,n]=(0,Y.useState)(``),[r,i]=(0,Y.useState)(0),a=(0,Y.useRef)(null),o=(0,Y.useRef)(null),s=(0,Y.useMemo)(()=>sc(e.notes,t),[e.notes,t]),c=s[r]?`notes-quick-switcher-option-${r}`:void 0;(0,Y.useEffect)(()=>{e.open&&(n(``),i(0),requestAnimationFrame(()=>a.current?.focus()))},[e.open]),(0,Y.useEffect)(()=>{r>=s.length&&i(Math.max(0,s.length-1))},[r,s.length]),(0,Y.useEffect)(()=>{(c?document.getElementById(c):null)?.scrollIntoView({block:`nearest`})},[c]);function l(){let t=s[r];t&&e.onSelect(t.note.path)}function u(t){t.key===`ArrowDown`?(t.preventDefault(),i(e=>Math.min(s.length-1,e+1))):t.key===`ArrowUp`?(t.preventDefault(),i(e=>Math.max(0,e-1))):t.key===`Enter`?(t.preventDefault(),l()):t.key===`Escape`&&(t.preventDefault(),e.onClose())}return e.open?(0,X.jsx)(`div`,{className:`notes-quick-switcher-backdrop`,role:`presentation`,onClick:e.onClose,children:(0,X.jsxs)(`section`,{className:`notes-quick-switcher`,role:`dialog`,"aria-modal":`true`,"aria-label":`Quick switch note`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`input`,{ref:a,className:`notes-quick-switcher-input`,type:`search`,placeholder:`Go to note`,value:t,onChange:e=>{n(e.currentTarget.value),i(0)},onKeyDown:u,"aria-label":`Quick switch note`,"aria-controls":`notes-quick-switcher-results`,"aria-activedescendant":c}),(0,X.jsxs)(`div`,{id:`notes-quick-switcher-results`,className:`notes-quick-switcher-list`,role:`listbox`,"aria-label":`Matching notes`,ref:o,children:[s.map((t,n)=>{let a=n===r,o=t.note.path===e.selectedPath;return(0,X.jsxs)(`button`,{id:`notes-quick-switcher-option-${n}`,type:`button`,role:`option`,"aria-selected":a,className:`notes-quick-switcher-item${a?` is-active`:``}${o?` is-current`:``}`,onMouseEnter:()=>i(n),onClick:()=>e.onSelect(t.note.path),children:[(0,X.jsx)(`span`,{className:`notes-quick-switcher-title`,children:t.note.title||t.note.path}),(0,X.jsx)(`span`,{className:`notes-quick-switcher-path`,children:t.note.path}),(0,X.jsx)(`span`,{className:`notes-quick-switcher-alias`,children:o?`Current note`:t.reason===`alias`?`Alias match`:t.reason===`path`?`Path match`:`Title match`})]},t.note.path)}),s.length===0&&(0,X.jsx)(`p`,{className:`notes-quick-switcher-empty`,children:`No matching notes.`})]}),(0,X.jsxs)(`footer`,{className:`notes-quick-switcher-footer`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`kbd`,{children:`Up/Down`}),` move`]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`kbd`,{children:`Enter`}),` open`]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`kbd`,{children:`Esc`}),` close`]})]})]})}):null}function lc(e){return e instanceof ne&&e.status===409&&e.code===`note_revision_conflict`}function uc(e){return e?e.split(`/`).filter(Boolean).at(-1)||e:`No note selected`}function dc(e,t,n){return!!e&&t&&!n}var fc=[`raw`,`split`,`preview`,`wysiwyg`,`graph`];function pc(e){return e===`raw`?`Raw`:e===`split`?`Split`:e===`preview`?`Preview`:e===`graph`?`Graph`:`WYSIWYG`}function mc(e,t){return e===`settings`?null:e===`graph`?`graph`:e===`split`?`split`:e===`preview`?`preview`:t===`wysiwyg`?`wysiwyg`:`raw`}function hc(e){function t(t){if(t===`graph`){e.onViewModeChange(`graph`);return}if(t===`split`){e.onViewModeChange(`split`),e.onAuthoringModeChange(`plain`);return}if(t===`preview`){e.onViewModeChange(`preview`);return}e.onViewModeChange(`raw`),e.onAuthoringModeChange(t===`wysiwyg`?`wysiwyg`:`plain`)}let n=mc(e.viewMode,e.authoringMode);return(0,X.jsxs)(`div`,{className:`notes-toolbar`,children:[(0,X.jsxs)(`div`,{className:`notes-toolbar-title`,children:[(0,X.jsx)(`strong`,{children:uc(e.selectedPath)}),(0,X.jsx)(`span`,{children:e.conflict?`Conflict`:e.dirty?`Unsaved`:`Saved`})]}),(0,X.jsxs)(`div`,{className:`notes-toolbar-actions`,children:[(0,X.jsx)(`div`,{className:`notes-view-tabs`,role:`tablist`,"aria-label":`Notes view`,children:fc.map(r=>(0,X.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":n===r,className:n===r?`is-active`:``,disabled:r!==`graph`&&!e.selectedPath,onClick:()=>t(r),children:pc(r)},r))}),(0,X.jsx)(`button`,{type:`button`,className:e.viewMode===`settings`?`is-active`:``,onClick:()=>e.onViewModeChange(`settings`),children:`Settings`}),(0,X.jsx)(`button`,{type:`button`,onClick:e.onReload,disabled:!e.selectedPath||e.loading,children:`Refresh`}),(0,X.jsx)(`button`,{type:`button`,className:`notes-save-button`,onClick:e.onSave,disabled:!dc(e.selectedPath,e.dirty,e.saving),children:e.saving?`Saving`:`Save`})]})]})}function gc(e){return(e.metaKey||e.ctrlKey)&&!e.altKey}function _c(e){return typeof HTMLElement>`u`||!(e instanceof HTMLElement)?!1:!!e.closest(`[data-notes-palette]`)}function vc(e){return gc(e)&&!e.shiftKey&&e.key.toLowerCase()===`p`&&!_c(e.target)}function yc(e){return gc(e)&&e.shiftKey&&e.key.toLowerCase()===`p`}async function bc(){await Promise.resolve(),await new Promise(e=>setTimeout(e,0))}function xc(){let[e,t]=(0,Y.useState)(null),[n,r]=(0,Y.useState)(``),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(null),h=(0,Y.useRef)(``),g=(0,Y.useRef)(!1),_=(0,Y.useRef)(!1),v=(0,Y.useCallback)(async e=>{s(!0),d(null),m(null);try{let n=await x(e);t(n),h.current=n.content,g.current=!1,r(n.content),a(!1)}catch(e){d(e.message)}finally{s(!1)}},[]);function y(e){h.current=e,g.current=!0,r(e),a(!0)}return{file:e,content:n,dirty:i,loading:o,saving:c,error:u,conflict:p,setContent:y,load:v,save:(0,Y.useCallback)(async()=>{if(await bc(),!e||!g.current||_.current)return;let n=h.current;_.current=!0,l(!0),d(null),m(null);try{let i=await f({path:e.path,content:n,baseRevision:e.revision});t(i),h.current===n&&(h.current=i.content,g.current=!1,r(i.content),a(!1))}catch(r){if(lc(r)){let i=e.revision;try{let n=await x(e.path);i=n.revision,t(n)}catch{i=e.revision}m({localContent:n,remoteRevision:i,message:r.message})}else d(r.message)}finally{_.current=!1,l(!1)}},[e]),reloadFromDisk:(0,Y.useCallback)(async()=>{e&&await v(e.path)},[e,v]),overwrite:(0,Y.useCallback)(async()=>{if(await bc(),!e||_.current)return;let n=h.current;_.current=!0,l(!0),d(null);try{let i=await f({path:e.path,content:n});t(i),h.current===n&&(h.current=i.content,g.current=!1,r(i.content),a(!1)),m(null)}catch(e){d(e.message)}finally{_.current=!1,l(!1)}},[e]),clearConflict:()=>m(null)}}var Sc=(0,Y.lazy)(async()=>({default:(await t(()=>import(`./NotesGraphWorkspace-DO9LtVGF.js`),[])).NotesGraphWorkspace})),Cc=[`raw`,`preview`,`wysiwyg`],wc=/[/\\]/g;function Tc(e){let t=e.split(`/`).pop()??e;return t.endsWith(`.md`)?t.slice(0,-3):t}function Ec(e,t){return e===`preview`?`preview`:t===`wysiwyg`?`wysiwyg`:`raw`}function Dc(e){let t=xc(),n=(0,Y.useRef)(!1),[r,i]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{e.selectedPath&&t.load(e.selectedPath)},[e.selectedPath]),(0,Y.useEffect)(()=>{e.onDirtyPathChange(t.dirty?e.selectedPath:null)},[t.dirty,e.selectedPath]),(0,Y.useEffect)(()=>{if(!e.active)return;function n(e){(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`s`&&(e.preventDefault(),t.save())}return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[t.save,e.active]),(0,Y.useEffect)(()=>{if(!e.active)return;function t(t){if(!(t.metaKey||t.ctrlKey)||t.key.toLowerCase()!==`e`)return;t.preventDefault();let n=Ec(e.viewMode,e.authoringMode),r=Cc[(Cc.indexOf(n)+1)%Cc.length];if(r===`preview`){e.onViewModeChange(`preview`);return}e.onViewModeChange(`raw`),e.onAuthoringModeChange(r===`wysiwyg`?`wysiwyg`:`plain`)}return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e.active,e.viewMode,e.authoringMode,e.onViewModeChange,e.onAuthoringModeChange]),(0,Y.useEffect)(()=>{if(!e.active)return;function t(t){(t.metaKey||t.ctrlKey)&&t.shiftKey&&t.key.toLowerCase()===`f`&&(t.preventDefault(),e.onOpenSidebarSearch())}return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e.active,e.onOpenSidebarSearch]),(0,Y.useEffect)(()=>{if(!e.active)return;function t(e){vc(e)&&(e.preventDefault(),i(e=>!e))}return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e.active]);let a=e.selectedPath?t.saving?`Save in progress`:t.dirty?void 0:`No unsaved changes`:`No note selected`;Wa((0,Y.useMemo)(()=>[{id:`workspace:save`,section:`File`,label:`Save note`,shortcut:`Cmd+S`,disabled:!dc(e.selectedPath,t.dirty,t.saving),disabledReason:a,keywords:[`write`,`persist`],run:()=>void t.save()},{id:`workspace:reload`,section:`File`,label:`Reload note from disk`,keywords:[`refresh`,`discard`],disabled:!e.selectedPath,disabledReason:`No note selected`,run:()=>void t.reloadFromDisk()},{id:`workspace:view-raw`,section:`View`,label:`Switch to raw editor`,run:()=>{e.onViewModeChange(`raw`),e.onAuthoringModeChange(`plain`)}},{id:`workspace:view-split`,section:`View`,label:`Switch to split view`,run:()=>{e.onViewModeChange(`split`),e.onAuthoringModeChange(`plain`)}},{id:`workspace:view-preview`,section:`View`,label:`Switch to preview`,shortcut:`Cmd+E`,run:()=>e.onViewModeChange(`preview`)},{id:`workspace:view-wysiwyg`,section:`View`,label:`Switch to WYSIWYG editor`,run:()=>{e.onViewModeChange(`raw`),e.onAuthoringModeChange(`wysiwyg`)}},{id:`workspace:view-graph`,section:`View`,label:`Open graph view`,run:()=>e.onViewModeChange(`graph`)},{id:`workspace:open-settings`,section:`View`,label:`Open Notes settings`,run:()=>e.onViewModeChange(`settings`)},{id:`workspace:toggle-word-wrap`,section:`Editor`,label:e.wordWrap?`Disable word wrap`:`Enable word wrap`,run:()=>e.onWordWrapChange(!e.wordWrap)},{id:`workspace:toggle-vim-mode`,section:`Editor`,label:e.vimMode?`Disable Vim mode`:`Enable Vim mode`,keywords:[`vim`,`keybindings`,`editor`],run:()=>e.onVimModeChange(!e.vimMode)},{id:`workspace:open-search`,section:`Navigate`,label:`Search notes`,shortcut:`Cmd+Shift+F`,run:e.onOpenSidebarSearch},{id:`workspace:quick-switch-note`,section:`Navigate`,label:`Quick switch note`,shortcut:`Cmd+P`,run:()=>i(!0)}],[t.dirty,t.reloadFromDisk,t.save,t.saving,e.onAuthoringModeChange,e.onOpenSidebarSearch,e.onViewModeChange,e.onVimModeChange,e.onWordWrapChange,e.selectedPath,e.vimMode,e.wordWrap,a]),e.active);async function o(t){if(n.current||!e.selectedPath)return;let r=t.currentTarget.value.trim().replace(wc,``),i=Tc(e.selectedPath);if(!r||r===i){t.currentTarget.value=i;return}let a=e.selectedPath.split(`/`);a[a.length-1]=r.endsWith(`.md`)?r:`${r}.md`;let o=a.join(`/`);if(o===e.selectedPath){t.currentTarget.value=i;return}n.current=!0;try{await oe(e.selectedPath,o),e.onSelectedPathChange(o),Z({topics:[`notes`],reason:`note:title-renamed`,source:`ui`})}catch(e){console.warn(`[notes-rename]`,e),t.currentTarget.value=i}finally{n.current=!1}}let s=e.viewMode===`raw`||e.viewMode===`split`,c=e.viewMode===`preview`||e.viewMode===`split`,l=e.selectedPath&&e.vaultIndex?.outgoingLinks?.[e.selectedPath]||[],u=e.selectedPath&&e.vaultIndex?.backlinks?.[e.selectedPath]||[],d=e.vaultIndex?.notes||[],f=e.authoringMode===`wysiwyg`&&s;return(0,X.jsxs)(`section`,{className:`notes-workspace`,"aria-label":`Notes workspace`,children:[(0,X.jsx)(co,{}),(0,X.jsxs)(`main`,{className:`notes-main notes-mode-${e.viewMode}`,children:[(0,X.jsx)(hc,{selectedPath:e.selectedPath,viewMode:e.viewMode,authoringMode:e.authoringMode,dirty:t.dirty,saving:t.saving,loading:t.loading,conflict:!!t.conflict,onViewModeChange:e.onViewModeChange,onAuthoringModeChange:e.onAuthoringModeChange,onSave:()=>void t.save(),onReload:()=>void t.reloadFromDisk()}),(0,X.jsxs)(`div`,{className:`notes-content`,children:[t.error&&(0,X.jsx)(`section`,{className:`state error-state`,children:t.error}),t.conflict&&(0,X.jsxs)(`section`,{className:`notes-conflict`,children:[(0,X.jsx)(`span`,{children:t.conflict.message}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void t.reloadFromDisk(),children:`Reload`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void t.overwrite(),children:`Overwrite`}),(0,X.jsx)(`button`,{type:`button`,onClick:t.clearConflict,children:`Keep local`})]}),e.viewMode===`settings`&&(0,X.jsxs)(`section`,{className:`notes-settings`,children:[(0,X.jsxs)(`label`,{children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:e.wordWrap,onChange:t=>e.onWordWrapChange(t.currentTarget.checked)}),`Word wrap`]}),(0,X.jsxs)(`label`,{children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:e.vimMode,onChange:t=>e.onVimModeChange(t.currentTarget.checked)}),`Vim mode`]}),(0,X.jsxs)(`label`,{children:[`Tree width`,(0,X.jsx)(`input`,{type:`range`,min:`220`,max:`420`,value:e.treeWidth,onChange:t=>e.onTreeWidthChange(Number(t.currentTarget.value))})]}),(0,X.jsx)(so,{})]}),e.viewMode===`graph`&&(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(`div`,{className:`notes-graph-loading`,children:`Loading graph...`}),children:(0,X.jsx)(Sc,{vaultIndex:e.vaultIndex,selectedPath:e.selectedPath,settings:e.notesGraphSettings,onSettingsChange:e.onNotesGraphSettingsChange,onNavigate:t=>{e.onSelectedPathChange(t),e.onViewModeChange(`raw`)}})}),!e.selectedPath&&e.viewMode!==`settings`&&e.viewMode!==`graph`&&(0,X.jsx)(tc,{}),e.selectedPath&&e.viewMode!==`settings`&&e.viewMode!==`graph`&&(0,X.jsxs)(`div`,{className:`notes-document-grid`,children:[(0,X.jsx)(`input`,{className:`notes-inline-title`,defaultValue:Tc(e.selectedPath),onBlur:o,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},spellCheck:!1,"aria-label":`Note title`},e.selectedPath),!f&&(0,X.jsx)(nc,{note:e.selectedNote,activeTag:e.tagFilter,onTagClick:e.onTagSelect}),s&&(0,X.jsx)(`div`,{className:`notes-editor-pane`,children:(0,X.jsx)(Xs,{active:e.active&&s,authoringMode:e.authoringMode,content:t.content,notePath:e.selectedPath,outgoing:l,notes:d,activeTag:e.tagFilter,wordWrap:e.wordWrap,vimMode:e.vimMode,onChange:t.setContent,onTagSelect:e.onTagSelect,onWikiLinkNavigate:e.onWikiLinkNavigate},e.selectedPath)}),c&&(0,X.jsx)(Zs,{markdown:t.content,outgoing:l,notes:d,onWikiLinkNavigate:e.onWikiLinkNavigate})]})]}),e.viewMode!==`graph`&&e.viewMode!==`settings`&&e.selectedPath&&(0,X.jsx)(ec,{backlinks:u,onNavigate:e.onWikiLinkNavigate})]}),(0,X.jsx)(cc,{open:r,notes:e.vaultIndex?.notes||[],selectedPath:e.selectedPath,onClose:()=>i(!1),onSelect:t=>{e.onSelectedPathChange(t),i(!1)}})]})}var Oc=`application/x-jaw-running-chip`;function kc(e,t,n){let r=[],i=new Set;for(let a of e){if(a.hidden)continue;let e=a.port;if(i.has(e))continue;i.add(e);let o=n.has(e),s=a.status===`online`,c=a.status===`error`;(o||s||c)&&r.push({port:e,label:a.label||a.instanceId||`Port ${e}`,activity:t[e]||null,state:o?`busy`:c?`error`:`online`})}return r}function Ac(e){return JSON.stringify({port:e.port,label:e.label,activity:e.activity,state:e.state})}function jc(e){let t=e.dataTransfer.getData(Oc);if(!t)return null;try{let e=JSON.parse(t);return typeof e.port==`number`?{port:e.port,label:typeof e.label==`string`?e.label:`Port ${e.port}`,activity:typeof e.activity==`string`?e.activity:null,state:e.state===`busy`||e.state===`error`?e.state:`online`}:null}catch{return null}}var Mc=[{id:`backlog`,label:`Backlog`,policy:`Options not yet committed`},{id:`ready`,label:`Ready`,policy:`Pullable, clear enough to start`},{id:`active`,label:`In Progress`,policy:`Current WIP, keep starts limited`},{id:`review`,label:`Review`,policy:`Check output before delivery`},{id:`done`,label:`Done`,policy:`Delivered or no longer active`}];function Nc(e){let t=(0,Y.useMemo)(()=>kc(e.instances,e.titlesByPort,e.busyPorts),[e.instances,e.titlesByPort,e.busyPorts]);return(0,X.jsxs)(`nav`,{className:`dashboard-board-sidebar`,"aria-label":`Board lanes`,children:[(0,X.jsxs)(`header`,{className:`dashboard-board-sidebar-header`,children:[(0,X.jsx)(`span`,{className:`dashboard-board-sidebar-title`,children:`Board`}),(0,X.jsxs)(`span`,{className:`dashboard-board-sidebar-count`,children:[t.length,` running`]})]}),(0,X.jsxs)(`section`,{className:`dashboard-board-sidebar-running`,"aria-label":`Running instances`,children:[(0,X.jsx)(`div`,{className:`dashboard-board-sidebar-section-title`,children:`Running`}),t.length===0?(0,X.jsx)(`p`,{className:`dashboard-board-sidebar-empty`,children:`No running instances`}):(0,X.jsx)(`div`,{className:`dashboard-board-sidebar-running-list`,children:t.map(e=>(0,X.jsxs)(`div`,{className:`dashboard-board-running-chip`,"data-state":e.state,draggable:!0,onDragStart:t=>{t.dataTransfer.effectAllowed=`copy`,t.dataTransfer.setData(Oc,Ac(e))},"aria-label":e.activity?`${e.label} — ${e.activity}`:e.label,children:[(0,X.jsxs)(`span`,{className:`dashboard-board-running-chip-port`,children:[`:`,e.port]}),(0,X.jsx)(`span`,{className:`dashboard-board-running-chip-label`,children:e.label}),e.activity?(0,X.jsx)(`span`,{className:`dashboard-board-running-chip-activity`,children:e.activity}):null,(0,X.jsx)(`span`,{className:`dashboard-board-running-chip-state`,"data-state":e.state,children:e.state})]},e.port))})]}),(0,X.jsx)(`div`,{className:`dashboard-board-sidebar-section-title`,children:`Lanes`}),(0,X.jsxs)(`ul`,{className:`dashboard-board-sidebar-list`,children:[(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,className:`dashboard-board-sidebar-item${e.view.kind===`overall`?` is-active`:``}`,onClick:()=>e.onViewChange({kind:`overall`}),"aria-pressed":e.view.kind===`overall`,children:[(0,X.jsx)(`span`,{children:`Overall`}),(0,X.jsx)(`small`,{children:`Five-column workflow`})]})}),Mc.map(t=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,className:`dashboard-board-sidebar-item${e.view.kind===`lane`&&e.view.lane===t.id?` is-active`:``}`,onClick:()=>e.onViewChange({kind:`lane`,lane:t.id}),"aria-pressed":e.view.kind===`lane`&&e.view.lane===t.id,children:[(0,X.jsx)(`span`,{children:t.label}),(0,X.jsx)(`small`,{children:t.policy})]})},t.id))]})]})}function Pc(e,t){if(e.port===null)return`no instance`;let n=t.get(e.port);return n?`:${n.port} ${n.label}`:`:${e.port}`}function Fc(e){let t=Mc.find(t=>t.id===e.lane),n=t?.label??`Lane`,r=t?.policy??``,i=e.cards.filter(e=>e.port!==null).length,a=e.cards.length-i;return(0,X.jsxs)(`div`,{className:`dashboard-board-lane-detail-shell`,"data-lane":e.lane,children:[(0,X.jsxs)(`aside`,{className:`dashboard-board-lane-detail-sidebar`,"aria-label":`${n} filters`,children:[(0,X.jsxs)(`header`,{children:[(0,X.jsx)(`span`,{children:n}),(0,X.jsx)(`small`,{children:r})]}),(0,X.jsxs)(`div`,{className:`dashboard-board-lane-detail-counts`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`strong`,{children:e.cards.length}),` all`]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`strong`,{children:i}),` with instance`]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`strong`,{children:a}),` no instance`]})]}),(0,X.jsx)(`button`,{type:`button`,onClick:e.onBackToOverall,children:`Overall`})]}),(0,X.jsxs)(`section`,{className:`dashboard-board-lane-detail-content`,"aria-label":`${n} cards`,children:[(0,X.jsxs)(`header`,{className:`dashboard-board-lane-detail-header`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`h2`,{children:[`Board / `,n]}),(0,X.jsx)(`p`,{children:e.lane===`done`?`Done archive, shown as compact two-line rows.`:`Lane detail, shown as compact rows for scan and reuse.`})]}),(0,X.jsx)(`button`,{type:`button`,onClick:e.onBackToOverall,children:`Close`})]}),e.cards.length===0?(0,X.jsx)(`p`,{className:`dashboard-board-lane-detail-empty`,children:`No items in this lane`}):(0,X.jsx)(`ul`,{className:`dashboard-board-compact-list`,children:e.cards.map(t=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,className:`dashboard-board-compact-row`,onClick:()=>e.onOpenCard(t.id),children:[(0,X.jsx)(`span`,{className:`dashboard-board-compact-row-title`,children:t.summary||t.title}),(0,X.jsx)(`span`,{className:`dashboard-board-compact-row-instance`,children:Pc(t,e.runningChipByPort)})]})},t.id))})]})]})}var Ic=`/api/dashboard/board`;function Lc(e){return{...e,summary:e.summary??null,detail:e.detail??null}}async function Rc(e){if(!e.ok){let t=await e.text().catch(()=>``);throw Error(`${e.status} ${t||e.statusText}`)}return await e.json()}async function zc(){let e=await Rc(await fetch(`${Ic}/tasks`,{credentials:`same-origin`,cache:`no-store`}));return Array.isArray(e.tasks)?e.tasks.map(Lc):[]}async function Bc(e){return Lc((await Rc(await fetch(`${Ic}/tasks`,{method:`POST`,headers:{"content-type":`application/json`},credentials:`same-origin`,body:JSON.stringify(e)}))).task)}async function Vc(e,t){return Lc((await Rc(await fetch(`${Ic}/tasks/${encodeURIComponent(e)}`,{method:`PATCH`,headers:{"content-type":`application/json`},credentials:`same-origin`,body:JSON.stringify(t)}))).task)}async function Hc(e){await Rc(await fetch(`${Ic}/tasks/${encodeURIComponent(e)}`,{method:`DELETE`,credentials:`same-origin`}))}function Uc(e){let[t,n]=(0,Y.useState)(``),[r,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(``);if((0,Y.useEffect)(()=>{n(e.card?.title??``),i(e.card?.summary??``),o(e.card?.detail??``)},[e.card]),!e.card)return null;function s(n){if(n.preventDefault(),!e.card)return;let i=t.trim();i&&e.onSave(e.card.id,{title:i,summary:r,detail:a})}return(0,X.jsx)(`div`,{className:`dashboard-board-dialog-backdrop`,role:`presentation`,onMouseDown:t=>{t.target===t.currentTarget&&e.onClose()},children:(0,X.jsxs)(`form`,{className:`dashboard-board-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`dashboard-board-dialog-title`,onSubmit:s,onKeyDown:t=>{t.key===`Escape`&&e.onClose()},children:[(0,X.jsxs)(`header`,{className:`dashboard-board-dialog-header`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`dashboard-board-dialog-kicker`,children:`Kanban block`}),(0,X.jsx)(`h3`,{id:`dashboard-board-dialog-title`,children:`Edit card`})]}),(0,X.jsx)(`button`,{type:`button`,className:`dashboard-board-dialog-icon-button`,onClick:e.onClose,"aria-label":`Close card editor`,children:`×`})]}),(0,X.jsxs)(`label`,{className:`dashboard-board-dialog-field`,children:[(0,X.jsx)(`span`,{children:`Title`}),(0,X.jsx)(`input`,{autoFocus:!0,type:`text`,value:t,onChange:e=>n(e.currentTarget.value),maxLength:500,required:!0})]}),(0,X.jsxs)(`label`,{className:`dashboard-board-dialog-field`,children:[(0,X.jsx)(`span`,{children:`One-line note`}),(0,X.jsx)(`input`,{type:`text`,value:r,onChange:e=>i(e.currentTarget.value),maxLength:500,placeholder:`Short visible memo for the card`})]}),(0,X.jsxs)(`label`,{className:`dashboard-board-dialog-field`,children:[(0,X.jsx)(`span`,{children:`Details`}),(0,X.jsx)(`textarea`,{value:a,onChange:e=>o(e.currentTarget.value),maxLength:2e4,rows:10,placeholder:`Write Markdown here. It is stored as raw text for now.`})]}),(0,X.jsxs)(`footer`,{className:`dashboard-board-dialog-footer`,children:[(0,X.jsx)(`span`,{className:`dashboard-board-dialog-storage`,children:`Markdown`}),(0,X.jsxs)(`div`,{className:`dashboard-board-dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:e.onClose,children:`Cancel`}),(0,X.jsx)(`button`,{type:`submit`,disabled:e.busy||!t.trim(),children:`Save`})]})]})]})})}var Wc=`application/x-jaw-board-task`;function Gc(e){return e.kind===`open`?(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`path`,{d:`M7 4h-2.5a1.5 1.5 0 0 0-1.5 1.5v10a1.5 1.5 0 0 0 1.5 1.5h10a1.5 1.5 0 0 0 1.5-1.5V13`}),(0,X.jsx)(`path`,{d:`M10 3h7v7`}),(0,X.jsx)(`path`,{d:`M9 11 17 3`})]}):e.kind===`move`?(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`path`,{d:`M10 2v16`}),(0,X.jsx)(`path`,{d:`M6 6 10 2l4 4`}),(0,X.jsx)(`path`,{d:`m6 14 4 4 4-4`}),(0,X.jsx)(`path`,{d:`M2 10h16`}),(0,X.jsx)(`path`,{d:`m6 6-4 4 4 4`}),(0,X.jsx)(`path`,{d:`m14 6 4 4-4 4`})]}):(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`path`,{d:`M3 5h14`}),(0,X.jsx)(`path`,{d:`M8 5V3h4v2`}),(0,X.jsx)(`path`,{d:`M6 8v8`}),(0,X.jsx)(`path`,{d:`M10 8v8`}),(0,X.jsx)(`path`,{d:`M14 8v8`}),(0,X.jsx)(`path`,{d:`M5 5l1 13h8l1-13`})]})}function Kc(e){return JSON.stringify({id:e.id,lane:e.lane})}function qc(e){let t=e.dataTransfer.getData(Wc);if(!t)return null;try{let e=JSON.parse(t);if(typeof e.id!=`string`)return null;let n=Mc.find(t=>t.id===e.lane)?.id;return n?{id:e.id,lane:n}:null}catch{return null}}function Jc(e,t){return Array.from(e.dataTransfer.types).includes(t)}function Yc(e){return{id:e.id,title:e.title,summary:e.summary??null,detail:e.detail??null,lane:e.lane,port:e.port,source:e.source,persisted:!0}}function Xc(e){return e==null?null:e.trim()||null}function Zc(e){let[t,n]=(0,Y.useState)([]),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(!1),y=(0,Y.useRef)(null),b=(0,Y.useCallback)(async()=>{try{n(await zc())}catch{}},[]);(0,Y.useEffect)(()=>{e.active&&b()},[e.active,b]),(0,Y.useEffect)(()=>{if(!l)return;let e=e=>{y.current&&(y.current.contains(e.target)||u(null))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[l]);let x=(0,Y.useCallback)(async e=>{let t=a.trim();if(t&&!s){c(!0);try{await Bc({title:t,lane:e}),o(``),i(null),await b()}catch{}finally{c(!1)}}},[a,s,b]),S=(0,Y.useCallback)(async(e,t)=>{u(null);try{await Vc(e,{lane:t}),await b()}catch{}},[b]),C=(0,Y.useCallback)(async e=>{try{await Hc(e),await b()}catch{}},[b]),w=(0,Y.useCallback)(async(e,t)=>{if(!_){v(!0);try{let r=await Vc(e,t);n(n=>n.map(n=>n.id===e?{...n,...r,summary:t.summary===void 0?r.summary??n.summary:Xc(t.summary),detail:t.detail===void 0?r.detail??n.detail:Xc(t.detail)}:n)),g(null)}catch{}finally{v(!1)}}},[_]),T=(0,Y.useCallback)(async(e,t)=>{try{await Vc(e,{port:t}),await b()}catch{}},[b]),E=(0,Y.useCallback)(async e=>{try{await Vc(e,{port:null}),await b()}catch{}},[b]),D=(0,Y.useCallback)((e,t)=>{t.preventDefault(),f(null);let n=qc(t);n&&n.lane!==e&&S(n.id,e)},[S]),O=(0,Y.useCallback)((e,t)=>{if(!Jc(t,`application/x-jaw-running-chip`))return;t.preventDefault(),t.stopPropagation(),m(null);let n=jc(t);n&&T(e,n.port)},[T]),k=(0,Y.useMemo)(()=>t.map(Yc),[t]),A=(0,Y.useMemo)(()=>{let e=h?k.find(e=>e.id===h):null;return e?{id:e.id,title:e.title,summary:e.summary,detail:e.detail}:null},[k,h]),ee=(0,Y.useMemo)(()=>kc(e.instances,e.titlesByPort,e.busyPorts),[e.instances,e.titlesByPort,e.busyPorts]),j=(0,Y.useMemo)(()=>new Map(ee.map(e=>[e.port,e])),[ee]),M=e.view.kind===`lane`?e.view.lane:null;return(0,X.jsxs)(`section`,{className:`dashboard-board-workspace`,"aria-hidden":!e.active,children:[(0,X.jsxs)(`header`,{className:`dashboard-board-workspace-header`,children:[(0,X.jsxs)(`div`,{className:`dashboard-board-workspace-header-text`,children:[(0,X.jsx)(`h2`,{children:`Board`}),(0,X.jsx)(`p`,{className:`dashboard-board-workspace-subtitle`,children:`Create human-owned kanban blocks, then drag running instance blocks into a card to attach context without touching the instance itself.`})]}),(0,X.jsx)(`div`,{className:`dashboard-board-workspace-controls`,children:(0,X.jsx)(ur,{topic:`board`,label:`Open Board help`,onOpen:e.onOpenHelpTopic})})]}),M===null?(0,X.jsx)(`div`,{className:`dashboard-board-lanes`,children:Mc.map(t=>{let n=k.filter(e=>e.lane===t.id),c=t.id===`done`?n.slice(0,4):n,h=t.id===`done`?Math.max(0,n.length-4):0,_=r===t.id,v=d===t.id;return(0,X.jsxs)(`div`,{className:`dashboard-board-lane${v?` is-drop-target`:``}`,"data-lane":t.id,onDragOver:e=>{Jc(e,Wc)&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,d!==t.id&&f(t.id))},onDragLeave:()=>{d===t.id&&f(null)},onDrop:e=>D(t.id,e),children:[(0,X.jsxs)(`header`,{className:`dashboard-board-lane-header`,children:[(0,X.jsx)(`span`,{className:`dashboard-board-lane-title`,children:t.label}),(0,X.jsx)(`span`,{className:`dashboard-board-lane-policy`,children:t.policy}),(0,X.jsx)(`span`,{className:`dashboard-board-lane-count`,children:n.length})]}),(0,X.jsxs)(`ul`,{className:`dashboard-board-lane-cards`,children:[n.length===0?(0,X.jsx)(`li`,{className:`dashboard-board-lane-empty`,children:`No items`}):c.map(e=>{let t=e.port===null?null:j.get(e.port)??null,n=p===e.id;return(0,X.jsxs)(`li`,{className:`dashboard-board-card${n?` is-instance-drop-target`:``}`,"data-lane":e.lane,"data-source":e.source,"data-persisted":e.persisted?`true`:`false`,draggable:!0,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(Wc,Kc(e))},onDragOver:t=>{Jc(t,`application/x-jaw-running-chip`)&&(t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect=`copy`,p!==e.id&&m(e.id))},onDragLeave:()=>{p===e.id&&m(null)},onDrop:t=>O(e.id,t),children:[(0,X.jsx)(`span`,{className:`dashboard-board-card-title`,children:e.title}),e.summary?(0,X.jsx)(`span`,{className:`dashboard-board-card-summary`,title:e.summary,children:e.summary}):null,(0,X.jsx)(`div`,{className:`dashboard-board-card-instance-slot`,"data-empty":t?`false`:`true`,children:t?(0,X.jsxs)(`div`,{className:`dashboard-board-card-instance`,"data-state":t.state,draggable:!0,onDragStart:e=>{e.stopPropagation(),e.dataTransfer.effectAllowed=`copy`,e.dataTransfer.setData(Oc,Ac(t))},title:t.activity?`${t.label} — ${t.activity}`:t.label,children:[(0,X.jsxs)(`span`,{className:`dashboard-board-card-instance-port`,children:[`:`,t.port]}),(0,X.jsx)(`span`,{className:`dashboard-board-card-instance-label`,children:t.label}),(0,X.jsx)(`button`,{type:`button`,className:`dashboard-board-card-instance-detach`,onClick:()=>void E(e.id),"aria-label":`Detach :${t.port} from card`,title:`Detach instance`,children:`-`}),t.activity?(0,X.jsx)(`span`,{className:`dashboard-board-card-instance-activity`,title:t.activity,children:t.activity}):null]}):(0,X.jsx)(`span`,{className:`dashboard-board-card-instance-empty`,children:`Drop a running instance here`})}),e.persisted?(0,X.jsxs)(`span`,{className:`dashboard-board-card-actions`,"data-open":l===e.id?`true`:`false`,children:[(0,X.jsx)(`button`,{type:`button`,className:`dashboard-board-card-action`,onMouseDown:e=>e.stopPropagation(),onClick:()=>g(e.id),"aria-label":`Open card details`,title:`Open`,children:(0,X.jsx)(Gc,{kind:`open`})}),(0,X.jsx)(`button`,{type:`button`,className:`dashboard-board-card-action`,onMouseDown:e=>e.stopPropagation(),onClick:()=>u(t=>t===e.id?null:e.id),"aria-haspopup":`menu`,"aria-expanded":l===e.id,"aria-label":`Move card`,title:`Move`,children:(0,X.jsx)(Gc,{kind:`move`})}),(0,X.jsx)(`button`,{type:`button`,className:`dashboard-board-card-action`,"data-danger":`true`,onClick:()=>void C(e.id),"aria-label":`Delete card`,title:`Delete`,children:(0,X.jsx)(Gc,{kind:`delete`})}),l===e.id&&(0,X.jsx)(`div`,{ref:y,className:`dashboard-board-popover`,role:`menu`,children:Mc.map(t=>(0,X.jsxs)(`button`,{type:`button`,className:`dashboard-board-popover-item${t.id===e.lane?` is-current`:``}`,role:`menuitem`,disabled:t.id===e.lane,onClick:()=>void S(e.id,t.id),children:[t.label,t.id===e.lane?` ✓`:``]},t.id))})]}):null]},e.id)}),h>0?(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,className:`dashboard-board-done-more`,onClick:()=>e.onViewChange({kind:`lane`,lane:`done`}),children:[(0,X.jsxs)(`span`,{children:[`+ `,h,` more done`]}),(0,X.jsx)(`small`,{children:`Open archive`})]})}):null]}),(0,X.jsx)(`div`,{className:`dashboard-board-lane-add`,children:_?(0,X.jsxs)(`form`,{className:`dashboard-board-add-composer`,onSubmit:e=>{e.preventDefault(),x(t.id)},children:[(0,X.jsx)(`input`,{autoFocus:!0,type:`text`,value:a,onChange:e=>o(e.target.value),placeholder:`New ${t.label} task`,disabled:s,"aria-label":`New task for ${t.label}`,onKeyDown:e=>{e.key===`Escape`&&(i(null),o(``))}}),(0,X.jsx)(`button`,{type:`submit`,disabled:s||!a.trim(),children:`Add`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>{i(null),o(``)},"aria-label":`Cancel`,children:`×`})]}):(0,X.jsx)(`button`,{type:`button`,className:`dashboard-board-add-trigger`,onClick:()=>{i(t.id),o(``)},children:`+ Add task`})})]},t.id)})}):(0,X.jsx)(Fc,{lane:M,cards:k.filter(e=>e.lane===M),runningChipByPort:j,onBackToOverall:()=>e.onViewChange({kind:`overall`}),onOpenCard:g}),(0,X.jsx)(Uc,{card:A,busy:_,onClose:()=>g(null),onSave:w})]})}var Qc=[{id:`today`,label:`Today`},{id:`upcoming`,label:`Upcoming`},{id:`recurring`,label:`Recurring`},{id:`blocked`,label:`Blocked`}];function $c(e){return(0,X.jsxs)(`nav`,{className:`dashboard-schedule-sidebar`,"aria-label":`Schedule groups`,children:[(0,X.jsx)(`header`,{className:`dashboard-schedule-sidebar-header`,children:(0,X.jsx)(`span`,{className:`dashboard-schedule-sidebar-title`,children:`Schedule`})}),(0,X.jsx)(`ul`,{className:`dashboard-schedule-sidebar-list`,children:Qc.map(t=>(0,X.jsx)(`li`,{children:(0,X.jsx)(`button`,{type:`button`,className:`dashboard-schedule-sidebar-item${e.activeGroup===t.id?` is-active`:``}`,onClick:()=>e.onGroupChange(t.id),"aria-pressed":e.activeGroup===t.id,children:(0,X.jsx)(`span`,{children:t.label})})},t.id))})]})}var el=`/api/dashboard/schedule`;async function tl(e){if(!e.ok){let t=await e.text().catch(()=>``);throw Error(`${e.status} ${t||e.statusText}`)}return await e.json()}async function nl(){let e=await tl(await fetch(`${el}/work`,{credentials:`same-origin`}));return Array.isArray(e.items)?e.items:[]}async function rl(e){return(await tl(await fetch(`${el}/work`,{method:`POST`,headers:{"content-type":`application/json`},credentials:`same-origin`,body:JSON.stringify(e)}))).item}async function il(e,t){return(await tl(await fetch(`${el}/work/${encodeURIComponent(e)}`,{method:`PATCH`,headers:{"content-type":`application/json`},credentials:`same-origin`,body:JSON.stringify(t)}))).item}async function al(e){await tl(await fetch(`${el}/work/${encodeURIComponent(e)}`,{method:`DELETE`,credentials:`same-origin`}))}async function ol(e,t=[]){let n=await tl(await fetch(`${el}/work/${encodeURIComponent(e)}/dispatch`,{method:`POST`,headers:{"content-type":`application/json`},credentials:`same-origin`,body:JSON.stringify({busyPorts:t})}));return{result:n.result,item:n.item}}async function sl(){try{let e=await fetch(`/api/heartbeat`,{credentials:`same-origin`});if(!e.ok)return[];let t=await e.json();return Array.isArray(t.jobs)?t.jobs:[]}catch{return[]}}function cl(e){return e.cron?`cron ${e.cron}`:e.runAt?`at ${e.runAt}`:e.enabled?`manual`:`disabled`}function ll(e){let[t,n]=(0,Y.useState)([]),[r,i]=(0,Y.useState)([]),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)({}),[h,g]=(0,Y.useState)(null),_=(0,Y.useRef)(null),v=(0,Y.useCallback)(async()=>{try{i(await nl())}catch{}},[]);(0,Y.useEffect)(()=>{if(!e.active)return;let t=!1;return Promise.all([sl(),nl().catch(()=>[])]).then(([e,r])=>{t||(n(e),i(r),o(!0))}),()=>{t=!0}},[e.active]),(0,Y.useEffect)(()=>{if(!h)return;let e=e=>{_.current&&(_.current.contains(e.target)||g(null))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[h]);let y=(0,Y.useCallback)(async e=>{let t=l.trim();if(t&&!d){f(!0);try{await rl({title:t,group:e}),u(``),c(null),await v()}catch{}finally{f(!1)}}},[l,d,v]),b=(0,Y.useCallback)(async(e,t)=>{g(null);try{await il(e,{group:t}),await v()}catch{}},[v]),x=(0,Y.useCallback)(async e=>{try{await al(e),await v()}catch{}},[v]),S=(0,Y.useCallback)(async t=>{try{let n=e.busyPorts,{result:r}=await ol(t,Array.isArray(n)?n:n?Array.from(n):[]);m(e=>({...e,[t]:r})),await v()}catch{}},[e.busyPorts,v]);return(0,X.jsxs)(`section`,{className:`dashboard-schedule-workspace`,"aria-hidden":!e.active,children:[(0,X.jsxs)(`header`,{className:`dashboard-schedule-workspace-header`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{children:`Automations`}),(0,X.jsx)(`p`,{className:`dashboard-schedule-workspace-subtitle`,children:`Manager-owned scheduled work. The dashboard ticks once a minute and dispatches due items.`})]}),(0,X.jsx)(ur,{topic:`schedule`,label:`Open Automations help`,onOpen:e.onOpenHelpTopic}),t.length>0?(0,X.jsxs)(`p`,{className:`dashboard-schedule-legacy-notice`,role:`note`,children:[`⚠️ `,t.length,` legacy heartbeat job(s) detected in this instance's `,(0,X.jsx)(`code`,{children:`heartbeat.json`}),`. They are no longer auto-fired by the manager — migrate them into Automations.`]}):null]}),(0,X.jsx)(`div`,{className:`dashboard-schedule-groups`,children:Qc.map(t=>{let n=r.filter(e=>e.group===t.id).filter(e=>e.enabled),i=n.length,o=s===t.id;return(0,X.jsxs)(`div`,{className:`dashboard-schedule-group${e.activeGroup===t.id?` is-focused`:``}`,children:[(0,X.jsxs)(`header`,{className:`dashboard-schedule-group-header`,children:[(0,X.jsx)(`span`,{className:`dashboard-schedule-group-title`,children:t.label}),(0,X.jsx)(`span`,{className:`dashboard-schedule-group-count`,children:i})]}),(0,X.jsx)(`ul`,{className:`dashboard-schedule-items`,children:a?i===0?(0,X.jsx)(`li`,{className:`dashboard-schedule-empty`,children:`No items`}):(0,X.jsx)(X.Fragment,{children:n.map(e=>{let t=p[e.id],n=e.lastRunAt?`last ${e.lastRunAt.slice(11,16)}`:null,r=e.lastStatus||null;return(0,X.jsxs)(`li`,{className:`dashboard-schedule-item`,"data-persisted":`true`,"data-dispatch-status":t?.status||``,children:[(0,X.jsx)(`span`,{className:`dashboard-schedule-item-name`,children:e.title}),(0,X.jsxs)(`span`,{className:`dashboard-schedule-item-meta`,children:[cl(e),` • saved`,e.targetPort==null?``:` • :${e.targetPort}`,n?` • ${n}`:``,r?` • ${r}`:``,t?` • ${t.status}`:``]}),(0,X.jsxs)(`span`,{className:`dashboard-schedule-item-actions`,"data-open":h===e.id?`true`:`false`,children:[(0,X.jsx)(`button`,{type:`button`,className:`dashboard-schedule-run-now`,onClick:()=>void S(e.id),"aria-label":`Run now`,title:`Dispatch to target instance (queued if busy)`,children:`Run`}),(0,X.jsx)(`button`,{type:`button`,className:`dashboard-schedule-item-action`,onMouseDown:e=>e.stopPropagation(),onClick:()=>g(t=>t===e.id?null:e.id),"aria-haspopup":`menu`,"aria-expanded":h===e.id,"aria-label":`Move scheduled work`,children:`Move`}),(0,X.jsx)(`button`,{type:`button`,className:`dashboard-schedule-item-action`,"data-danger":`true`,onClick:()=>void x(e.id),"aria-label":`Delete`,children:`Delete`}),h===e.id&&(0,X.jsx)(`div`,{ref:_,className:`dashboard-schedule-popover`,role:`menu`,children:Qc.map(t=>(0,X.jsxs)(`button`,{type:`button`,className:`dashboard-schedule-popover-item${t.id===e.group?` is-current`:``}`,role:`menuitem`,disabled:t.id===e.group,onClick:()=>void b(e.id,t.id),children:[t.label,t.id===e.group?` ✓`:``]},t.id))})]})]},e.id)})}):(0,X.jsx)(`li`,{className:`dashboard-schedule-empty`,children:`Loading…`})}),(0,X.jsx)(`div`,{className:`dashboard-schedule-group-add`,children:o?(0,X.jsxs)(`form`,{className:`dashboard-schedule-add-composer`,onSubmit:e=>{e.preventDefault(),y(t.id)},children:[(0,X.jsx)(`input`,{autoFocus:!0,type:`text`,value:l,onChange:e=>u(e.target.value),placeholder:`New ${t.label} item`,disabled:d,"aria-label":`New scheduled work for ${t.label}`,onKeyDown:e=>{e.key===`Escape`&&(c(null),u(``))}}),(0,X.jsx)(`button`,{type:`submit`,disabled:d||!l.trim(),children:`Add`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>{c(null),u(``)},"aria-label":`Cancel`,children:`×`})]}):(0,X.jsx)(`button`,{type:`button`,className:`dashboard-schedule-add-trigger`,onClick:()=>{c(t.id),u(``)},children:`+ Add scheduled work`})})]},t.id)})})]})}var ul=1e3;function dl(e,t){return pl(e)-pl(t)||gl(e)-gl(t)||ml(e)-ml(t)||hl(e)-hl(t)||Date.parse(e.sourceCreatedAt)-Date.parse(t.sourceCreatedAt)}function fl(e,t){let n=e?.manualRank??null,r=t?.manualRank??null;return n===null&&r===null?ul:n===null&&r!==null?r-ul:n!==null&&r===null?n+ul:n!==null&&r!==null?(n+r)/2:ul}function pl(e){return e.status===`focused`?0:1}function ml(e){return e.manualRank??2**53-1}function hl(e){let t=[e.remindAt,e.dueAt].filter(e=>!!e).map(e=>Date.parse(e)).filter(e=>Number.isFinite(e));return t.length>0?Math.min(...t):2**53-1}function gl(e){return e.priority===`high`?0:e.priority===`normal`?1:2}function _l(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t}function vl(e,t){let n=_l(e.dueAt);return n!==null&&n.getTime()<t.getTime()}function yl(e,t){let n=_l(e.dueAt);return n!==null&&n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()&&n.getDate()===t.getDate()}function bl(e,t){return e.filter(e=>e.status!==`done`&&(vl(e,t)||yl(e,t))).length}var xl=[{id:`urgentImportant`,title:`Important and Urgent`,tone:`red`},{id:`important`,title:`Important, Not Urgent`,tone:`green`},{id:`waiting`,title:`Waiting / Delegated`,tone:`amber`},{id:`later`,title:`Later`,tone:`blue`}],Sl={urgentImportant:{listId:`today`,status:`open`,priority:`high`},important:{listId:`today`,status:`open`,priority:`normal`},waiting:{listId:`waiting`,status:`waiting`,priority:`normal`},later:{listId:`later`,status:`open`,priority:`low`}};function Cl(e){return Sl[e]}function wl(e){return e.status===`done`?null:e.status===`focused`?`urgentImportant`:e.status===`waiting`?`waiting`:e.listId===`later`||e.priority===`low`?`later`:e.priority===`high`?`urgentImportant`:`important`}function Tl(e,t){return t.filter(t=>wl(t)===e).sort(dl)}function El(e,t){return e===`matrix`?t.filter(e=>e.status!==`done`).sort(dl):e===`done`?t.filter(e=>e.status===`done`).sort(dl):e===`focused`?Tl(`urgentImportant`,t):e===`important`?Tl(`important`,t):e===`waiting`?Tl(`waiting`,t):e===`later`?Tl(`later`,t):t.filter(e=>e.status!==`done`).sort(dl)}function Dl(e,t){return El(e,t).length}function Ol(e,t=3){return e.filter(e=>e.status!==`done`).sort(dl).slice(0,t)}function kl(e,t,n=3){let r=e.filter(e=>e.status!==`done`),i=r.filter(e=>vl(e,t)).sort(dl),a=new Set(i.map(e=>e.id)),o=r.filter(e=>!a.has(e.id)),s=Ol(o,3),c=new Set([...i,...s].map(e=>e.id)),l=o.filter(e=>yl(e,t)).sort(dl).filter(e=>!c.has(e.id)).slice(0,n);for(let e of l)c.add(e.id);return{overdue:i,priority:s,today:l,upcomingCount:r.filter(e=>!c.has(e.id)).length,badgeCount:bl(e,t)}}var Al=`application/x-jaw-dashboard-reminder`;function jl(e){return Array.from(e.dataTransfer.types).includes(Al)}function Ml(e){let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(null);function a(e,t){if(t.target instanceof HTMLElement&&t.target.closest(`input, textarea, button, [data-reminder-inline-edit="true"]`)){t.preventDefault();return}t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(Al,e.id),n(e.id)}function o(e,t){jl(t)&&(t.preventDefault(),t.dataTransfer.dropEffect=`move`,i(e))}function s(){i(null)}function c(t,r){if(!jl(r))return;r.preventDefault();let a=r.dataTransfer.getData(Al);n(null),i(null),a&&e(a,t)}function l(){n(null),i(null)}return{draggedId:t,dropTarget:r,start:a,over:o,leave:s,drop:c,end:l}}var Nl=[{id:`matrix`,label:`Matrix`,detail:`Priority board`},{id:`focused`,label:`Focus`,detail:`Current item`},{id:`important`,label:`Important`,detail:`Not urgent`},{id:`waiting`,label:`Waiting`,detail:`Delegated`},{id:`later`,label:`Later`,detail:`Low urgency`},{id:`done`,label:`Done`,detail:`Completed items`}];function Pl(e,t){return!!(e&&e.kind===t.kind&&e.beforeId===t.beforeId&&e.afterId===t.afterId)}function Fl(e){return e.length>0?e[e.length-1]??null:null}function Il(e,t){return{kind:`priority`,beforeId:e[t-1]?.id??null,afterId:e[t]?.id??null}}function Ll(e){return{kind:`priority`,beforeId:Fl(e)?.id??null,afterId:null}}function Rl(e,t,n){let r=e.filter(e=>e.id!==t),i=n.beforeId?r.find(e=>e.id===n.beforeId)??null:null,a=n.afterId?r.find(e=>e.id===n.afterId)??null:null;return i||a?{previous:i,next:a}:n.beforeId&&!n.afterId?{previous:Fl(r),next:null}:!n.beforeId&&n.afterId?{previous:null,next:r[0]??null}:{previous:Fl(r),next:null}}function zl(e){let t=Ll(e.items),n=(t,n)=>e.drag.over(t,n),r=(t,n)=>e.drag.drop(t,n);return(0,X.jsxs)(`section`,{className:`dashboard-reminders-sidebar-priority`,"data-drop-target":e.drag.dropTarget?.kind===`priority`?`true`:`false`,onDragOver:e=>n(t,e),onDragLeave:e.drag.leave,onDrop:e=>r(t,e),children:[(0,X.jsxs)(`header`,{children:[(0,X.jsx)(`span`,{children:`Priority Order`}),(0,X.jsx)(`small`,{children:`drag to rank`})]}),(0,X.jsxs)(`ol`,{children:[e.items.map((t,i)=>{let a=Il(e.items,i);return(0,X.jsxs)(`li`,{draggable:!e.loading&&t.status!==`done`,"data-drop-target":Pl(e.drag.dropTarget,a)?`true`:void 0,"data-reminder-drop-before-id":a.beforeId??void 0,"data-reminder-drop-after-id":a.afterId??void 0,onDragStart:n=>e.drag.start(t,n),onDragEnd:e.drag.end,onDragOver:e=>{e.stopPropagation(),n(a,e)},onDragLeave:t=>{t.stopPropagation(),e.drag.leave()},onDrop:e=>{e.stopPropagation(),r(a,e)},children:[(0,X.jsx)(`span`,{className:`dashboard-reminders-sidebar-priority-index`,children:i+1}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`b`,{children:t.title}),(0,X.jsxs)(`small`,{children:[t.status,` • `,t.priority]})]})]},t.id)}),e.items.length===0?(0,X.jsx)(`li`,{className:`dashboard-reminders-sidebar-priority-empty`,children:`No open reminders`}):null]})]})}function Bl(e){let t=e.items.filter(e=>e.status!==`done`).length,n=Ol(e.items,5),r=Ml((t,n)=>{if(n.kind!==`priority`)return;let{previous:r,next:i}=Rl(Ol(e.items,e.items.length),t,n);e.onUpdate(t,{manualRank:fl(r,i)})});return(0,X.jsxs)(`nav`,{className:`dashboard-reminders-sidebar`,"aria-label":`Reminders views`,children:[(0,X.jsxs)(`header`,{className:`dashboard-reminders-sidebar-header`,children:[(0,X.jsx)(`span`,{className:`dashboard-reminders-sidebar-title`,children:`Reminders`}),(0,X.jsx)(`button`,{type:`button`,className:`dashboard-reminders-refresh`,onClick:e.onRefresh,disabled:e.loading,children:e.loading?`Loading`:`Refresh`})]}),(0,X.jsxs)(`div`,{className:`dashboard-reminders-source`,"data-state":`ok`,children:[t,` open / `,e.items.length,` total`]}),(0,X.jsx)(zl,{items:n,loading:e.loading,drag:r}),(0,X.jsx)(`ul`,{className:`dashboard-reminders-sidebar-list`,children:Nl.map(t=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,className:`dashboard-reminders-sidebar-item${e.view===t.id?` is-active`:``}`,onClick:()=>e.onViewChange(t.id),"aria-pressed":e.view===t.id,children:[(0,X.jsx)(`span`,{children:t.label}),(0,X.jsx)(`small`,{children:t.detail}),(0,X.jsx)(`b`,{children:Dl(t.id,e.items)})]})},t.id))})]})}function Vl(e){let[t,n]=(0,Y.useState)(!1),[r,i]=(0,Y.useState)(e.item.title),a=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{t||i(e.item.title)},[t,e.item.title]),(0,Y.useEffect)(()=>{t&&a.current?.select()},[t]);function o(){let t=r.trim();if(n(!1),!t||t===e.item.title){i(e.item.title);return}e.onRename(e.item.id,t)}function s(){i(e.item.title),n(!1)}function c(e){e.key===`Enter`?(e.preventDefault(),o()):e.key===`Escape`&&(e.preventDefault(),s())}return t?(0,X.jsx)(`input`,{ref:a,"data-reminder-inline-edit":`true`,className:`dashboard-reminders-inline-title-input`,"aria-label":`Reminder title`,disabled:e.busy,value:r,onChange:e=>i(e.target.value),onBlur:o,onClick:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),onKeyDown:c}):(0,X.jsx)(`span`,{className:`dashboard-reminders-inline-title`,onDoubleClick:e=>{e.preventDefault(),e.stopPropagation(),n(!0)},children:e.item.title})}function Hl(e){let[t,n]=(0,Y.useState)(``),[r,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(``);(0,Y.useEffect)(()=>{n(e.item?.title??``),i(e.item?.notes??``),o(Ul(e.item?.dueAt??null)),c(Ul(e.item?.remindAt??null))},[e.item]),(0,Y.useEffect)(()=>{if(!e.item)return;let t=t=>{t.key===`Escape`&&e.onClose()};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e]);let l=(0,Y.useMemo)(()=>e.item?t.trim()!==e.item.title||r!==e.item.notes||a!==Ul(e.item.dueAt)||s!==Ul(e.item.remindAt):!1,[a,r,e.item,s,t]);if(!e.item)return null;let u=e.item;return(0,X.jsx)(`div`,{className:`dashboard-reminder-popover-scrim`,role:`presentation`,onMouseDown:e.onClose,children:(0,X.jsx)(`section`,{className:`dashboard-reminder-popover`,role:`dialog`,"aria-modal":`true`,"aria-label":`Reminder details`,onMouseDown:e=>e.stopPropagation(),children:(0,X.jsxs)(`form`,{onSubmit:n=>{if(n.preventDefault(),!u)return;let i=t.trim();if(!i)return;let o={};if(i!==u.title&&(o.title=i),r!==u.notes&&(o.notes=r),a!==Ul(u.dueAt)&&(o.dueAt=Wl(a)),s!==Ul(u.remindAt)&&(o.remindAt=Wl(s)),Object.keys(o).length===0){e.onClose();return}e.onSave(u.id,o)},children:[(0,X.jsxs)(`header`,{children:[(0,X.jsx)(`span`,{children:`Reminder details`}),(0,X.jsx)(`button`,{type:`button`,"aria-label":`Close reminder details`,onClick:e.onClose,children:`×`})]}),(0,X.jsxs)(`label`,{children:[(0,X.jsx)(`span`,{children:`Title`}),(0,X.jsx)(`input`,{value:t,onChange:e=>n(e.target.value),"aria-label":`Reminder title`})]}),(0,X.jsxs)(`label`,{children:[(0,X.jsx)(`span`,{children:`Notes`}),(0,X.jsx)(`textarea`,{value:r,onChange:e=>i(e.target.value),"aria-label":`Reminder notes`,rows:6})]}),(0,X.jsxs)(`div`,{className:`dashboard-reminder-popover-grid`,children:[(0,X.jsxs)(`label`,{children:[(0,X.jsx)(`span`,{children:`Due`}),(0,X.jsx)(`input`,{type:`datetime-local`,value:a,onChange:e=>o(e.target.value),"aria-label":`Reminder due date`})]}),(0,X.jsxs)(`label`,{children:[(0,X.jsx)(`span`,{children:`Remind`}),(0,X.jsx)(`input`,{type:`datetime-local`,value:s,onChange:e=>c(e.target.value),"aria-label":`Reminder notification date`})]})]}),(0,X.jsxs)(`footer`,{children:[(0,X.jsx)(`button`,{type:`button`,onClick:e.onClose,children:`Cancel`}),(0,X.jsx)(`button`,{type:`submit`,disabled:e.busy||!t.trim()||!l,children:`Save`})]})]})})})}function Ul(e){if(!e)return``;let t=new Date(e);if(Number.isNaN(t.getTime()))return``;let n=t.getTimezoneOffset()*6e4;return new Date(t.getTime()-n).toISOString().slice(0,16)}function Wl(e){if(!e.trim())return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toISOString()}var Gl={matrix:`Priority Matrix`,focused:`Focus`,important:`Important, Not Urgent`,waiting:`Waiting / Delegated`,later:`Later`,done:`Done`};function Kl(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString([],{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function ql(e){let t=[e.status,e.priority],n=Kl(e.remindAt),r=Kl(e.dueAt);return r&&t.push(`due ${r}`),n&&t.push(`remind ${n}`),e.linkedInstance&&t.push(e.linkedInstance),e.notificationStatus!==`pending`&&t.push(e.notificationStatus),t.join(` • `)}function Jl(e,t){return!e||e.kind!==t.kind||e.beforeId!==t.beforeId||e.afterId!==t.afterId?!1:e.kind===`bucket`&&t.kind===`bucket`?e.bucket===t.bucket:!0}function Yl(e,t,n){return{kind:`bucket`,bucket:e,beforeId:t[n-1]?.id??null,afterId:t[n]?.id??null}}function Xl(e,t,n){return{kind:`bucket`,bucket:e,beforeId:t[n]?.id??null,afterId:t[n+1]?.id??null}}function Zl(e,t){return{kind:`bucket`,bucket:e,beforeId:ru(t)?.id??null,afterId:null}}function Ql(e,t){return{kind:`priority`,beforeId:e[t-1]?.id??null,afterId:e[t]?.id??null}}function $l(e,t){return{kind:`priority`,beforeId:e[t]?.id??null,afterId:e[t+1]?.id??null}}function eu(e){return{kind:`priority`,beforeId:ru(e)?.id??null,afterId:null}}function tu(e){let t=e.currentTarget.getBoundingClientRect();return e.clientY>t.top+t.height/2}function nu(e,t){return t.kind===`priority`?Ol(e,e.length):Tl(t.bucket,e)}function ru(e){return e.length>0?e[e.length-1]??null:null}function iu(e,t,n){let r=e.filter(e=>e.id!==t),i=n.beforeId?r.find(e=>e.id===n.beforeId)??null:null,a=n.afterId?r.find(e=>e.id===n.afterId)??null:null;return i||a?{previous:i,next:a}:n.beforeId&&!n.afterId?{previous:ru(r),next:null}:!n.beforeId&&n.afterId?{previous:null,next:r[0]??null}:{previous:ru(r),next:null}}function au(e){return e.feed.error?(0,X.jsx)(`p`,{className:`dashboard-reminders-status`,"data-state":`error`,children:e.feed.error}):(0,X.jsxs)(`p`,{className:`dashboard-reminders-status`,children:[e.feed.items.length,` reminder(s) stored in the dashboard database`]})}function ou(e){let t=e.item.status===`done`,n=e.dropTarget?Jl(e.activeDropTarget??null,e.dropTarget):!1;return(0,X.jsxs)(`li`,{className:`dashboard-reminders-row`,"data-priority":e.item.priority,"data-status":e.item.status,"data-drop-target":n?`true`:void 0,"data-reminder-drop-before-id":e.dropTarget?.beforeId??void 0,"data-reminder-drop-after-id":e.dropTarget?.afterId??void 0,draggable:!t&&!e.busy,onDragStart:t=>e.onDragStart?.(e.item,t),onDragEnd:e.onDragEnd,onDragOver:t=>{let n=e.resolveDropTarget?.(t)??e.dropTarget;n&&(t.stopPropagation(),e.onDragOverTarget?.(n,t))},onDragLeave:t=>{e.dropTarget&&(t.stopPropagation(),e.onDragLeaveTarget?.())},onDrop:t=>{let n=e.resolveDropTarget?.(t)??e.dropTarget;n&&(t.stopPropagation(),e.onDropTarget?.(n,t))},children:[(0,X.jsx)(`button`,{type:`button`,className:`dashboard-reminders-row-check`,"aria-label":t?`Mark open`:`Mark done`,onClick:()=>e.onToggleDone(e.item),children:t?`✓`:``}),(0,X.jsxs)(`span`,{className:`dashboard-reminders-row-content`,children:[(0,X.jsx)(Vl,{item:e.item,busy:e.busy,onRename:e.onRename}),(0,X.jsx)(`small`,{children:ql(e.item)})]}),(0,X.jsx)(`button`,{type:`button`,className:`dashboard-reminders-row-more`,"aria-label":`Open reminder details`,onClick:()=>e.onOpenDetails(e.item),children:`•••`}),e.item.priority===`high`?(0,X.jsx)(`span`,{className:`dashboard-reminders-row-flag`,"aria-label":`high priority`,children:`!`}):null]})}function su(e){let[t,n]=(0,Y.useState)(``);return(0,X.jsxs)(`li`,{className:`dashboard-reminders-create-row`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`}),(0,X.jsx)(`form`,{onSubmit:r=>{r.preventDefault();let i=t.trim();i&&(e.onCreate({title:i,...Sl[e.bucket]}),n(``))},children:(0,X.jsx)(`input`,{"aria-label":`Create ${e.bucket} reminder`,placeholder:`New reminder`,value:t,onChange:e=>n(e.target.value)})})]})}function cu(e){let t=Zl(e.section.id,e.items);return(0,X.jsxs)(`section`,{className:`dashboard-reminders-quadrant`,"data-tone":e.section.tone,"data-drop-target":e.dropTarget?.kind===`bucket`&&e.dropTarget.bucket===e.section.id?`true`:`false`,onDragOver:n=>e.onDragOver(t,n),onDragLeave:e.onDragLeave,onDrop:n=>e.onDrop(t,n),children:[(0,X.jsxs)(`header`,{children:[(0,X.jsx)(`h3`,{children:e.section.title}),(0,X.jsx)(`span`,{children:e.items.length})]}),(0,X.jsxs)(`ul`,{children:[e.items.map((t,n)=>{let r=Yl(e.section.id,e.items,n);return(0,X.jsx)(ou,{item:t,busy:e.busy,onToggleDone:e.onToggleDone,onRename:e.onRename,onOpenDetails:e.onOpenDetails,onDragStart:e.onDragStart,onDragEnd:e.onDragEnd,dropTarget:r,resolveDropTarget:t=>tu(t)?Xl(e.section.id,e.items,n):r,activeDropTarget:e.dropTarget,onDragOverTarget:e.onDragOver,onDragLeaveTarget:e.onDragLeave,onDropTarget:e.onDrop},t.id)}),(0,X.jsx)(su,{bucket:e.section.id,onCreate:e.onCreate}),e.items.length===0?(0,X.jsx)(`li`,{className:`dashboard-reminders-empty-row`,children:`No reminders`}):null]})]})}function lu(e){return(0,X.jsxs)(`div`,{className:`dashboard-reminders-matrix-wrap`,children:[(0,X.jsx)(`span`,{className:`dashboard-reminders-axis dashboard-reminders-axis-importance`,children:`Importance`}),(0,X.jsx)(`span`,{className:`dashboard-reminders-axis dashboard-reminders-axis-urgency`,children:`Urgency`}),(0,X.jsx)(`div`,{className:`dashboard-reminders-matrix-board`,children:xl.map(t=>(0,X.jsx)(cu,{section:t,items:Tl(t.id,e.items),busy:e.busy,dropTarget:e.dropTarget,onCreate:e.onCreate,onToggleDone:e.onToggleDone,onRename:e.onRename,onOpenDetails:e.onOpenDetails,onDragStart:e.onDragStart,onDragEnd:e.onDragEnd,onDragOver:e.onDragOver,onDragLeave:e.onDragLeave,onDrop:e.onDrop},t.id))})]})}function uu(e){let t=eu(e.items);return(0,X.jsxs)(`section`,{className:`dashboard-reminders-top-priority`,"aria-label":`Top priority reminders`,"data-drop-target":e.dropTarget?.kind===`priority`?`true`:`false`,onDragOver:n=>e.onDragOver(t,n),onDragLeave:e.onDragLeave,onDrop:n=>e.onDrop(t,n),children:[(0,X.jsxs)(`header`,{children:[(0,X.jsx)(`span`,{children:`Top Priority 3`}),(0,X.jsxs)(`small`,{children:[e.items.length,`/3`]})]}),(0,X.jsxs)(`ol`,{children:[e.items.map((t,n)=>{let r=Ql(e.items,n);return(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`span`,{className:`dashboard-reminders-top-index`,children:n+1}),(0,X.jsx)(ou,{item:t,busy:e.busy,onToggleDone:e.onToggleDone,onRename:e.onRename,onOpenDetails:e.onOpenDetails,onDragStart:e.onDragStart,onDragEnd:e.onDragEnd,dropTarget:r,resolveDropTarget:t=>tu(t)?$l(e.items,n):r,activeDropTarget:e.dropTarget,onDragOverTarget:e.onDragOver,onDragLeaveTarget:e.onDragLeave,onDropTarget:e.onDrop})]},t.id)}),e.items.length===0?(0,X.jsx)(`li`,{className:`dashboard-reminders-top-empty`,children:`No top priority reminders`}):null]})]})}function du(e){return(0,X.jsxs)(`div`,{className:`dashboard-reminders-smart-list`,"aria-busy":e.loading,children:[(0,X.jsxs)(`header`,{children:[(0,X.jsx)(`h3`,{children:e.title}),(0,X.jsx)(`span`,{children:e.items.length})]}),(0,X.jsx)(`ul`,{children:e.loading&&e.items.length===0?(0,X.jsx)(`li`,{className:`dashboard-reminders-empty-row`,children:`Loading reminders...`}):e.items.length===0?(0,X.jsx)(`li`,{className:`dashboard-reminders-empty-row`,children:`No reminders`}):e.items.map(t=>(0,X.jsx)(ou,{item:t,busy:e.loading,onToggleDone:e.onToggleDone,onRename:e.onRename,onOpenDetails:e.onOpenDetails,onDragStart:e.onDragStart,onDragEnd:e.onDragEnd},t.id))})]})}function fu(e){let[t,n]=(0,Y.useState)(null),r=El(e.view,e.feed.items),i=Gl[e.view],a=Ol(e.feed.items,3),o=Ml((t,n)=>{let r=e.feed.items.find(e=>e.id===t);if(!r)return;let{previous:i,next:a}=iu(nu(e.feed.items,n),t,n),o=fl(i,a);if(n.kind===`priority`){e.onUpdate(t,{manualRank:o});return}let s=wl(r)===n.bucket?{}:Cl(n.bucket);e.onUpdate(t,{...s,manualRank:o})}),s=t=>{e.onUpdate(t.id,{status:t.status===`done`?`open`:`done`})},c=(t,n)=>{e.onUpdate(t,{title:n})};return(0,X.jsxs)(`section`,{className:`dashboard-reminders-workspace`,"aria-hidden":!e.active,children:[(0,X.jsxs)(`header`,{className:`dashboard-reminders-workspace-header`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{children:i}),(0,X.jsx)(au,{feed:e.feed})]}),(0,X.jsxs)(`div`,{className:`dashboard-reminders-workspace-actions`,children:[(0,X.jsx)(ur,{topic:`reminders`,label:`Open Reminders help`,onOpen:e.onOpenHelpTopic}),(0,X.jsx)(`button`,{type:`button`,className:`dashboard-reminders-sync-button`,onClick:e.onRefresh,disabled:e.feed.loading,children:e.feed.loading?`Loading...`:`Refresh`})]})]}),e.view===`matrix`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(uu,{items:a,busy:e.feed.loading,dropTarget:o.dropTarget,onToggleDone:s,onRename:c,onOpenDetails:n,onDragStart:o.start,onDragEnd:o.end,onDragOver:o.over,onDragLeave:o.leave,onDrop:o.drop}),(0,X.jsx)(lu,{items:r,busy:e.feed.loading,dropTarget:o.dropTarget,onCreate:e.onCreate,onToggleDone:s,onRename:c,onOpenDetails:n,onDragStart:o.start,onDragEnd:o.end,onDragOver:o.over,onDragLeave:o.leave,onDrop:o.drop})]}):(0,X.jsx)(du,{title:i,items:r,loading:e.feed.loading,onToggleDone:s,onRename:c,onOpenDetails:n,onDragStart:o.start,onDragEnd:o.end}),(0,X.jsx)(Hl,{item:t,busy:e.feed.loading,onClose:()=>n(null),onSave:(t,r)=>{e.onUpdate(t,r),n(null)}})]})}var pu=`/api/dashboard/reminders`;async function mu(e){if(!e.ok){let t=await e.text().catch(()=>``);throw Error(`${e.status} ${t||e.statusText}`)}if(!(e.headers.get(`content-type`)||``).includes(`application/json`))throw Error(`Reminders API is not available in the running dashboard server. Rebuild and restart the dashboard backend to enable sync.`);return await e.json()}function hu(e){return{...e,notes:e.notes??``,manualRank:typeof e.manualRank==`number`&&Number.isFinite(e.manualRank)?e.manualRank:null,dueAt:e.dueAt??null,remindAt:e.remindAt??null,linkedInstance:e.linkedInstance??null,subtasks:Array.isArray(e.subtasks)?e.subtasks:[],notificationAttemptedAt:e.notificationAttemptedAt??null,notificationError:e.notificationError??null,instanceId:e.instanceId??null,messageId:e.messageId??null,turnIndex:e.turnIndex??null,port:e.port??null,threadKey:e.threadKey??null,sourceText:e.sourceText??null}}function gu(e,t){if(`manualRank`in e&&!Object.hasOwn(t,`manualRank`))throw Error(`Manual reminder ordering requires the dashboard backend to be rebuilt and restarted.`)}async function _u(){let e=await mu(await fetch(pu,{credentials:`same-origin`,cache:`no-store`}));return{...e,items:Array.isArray(e.items)?e.items.map(hu):[]}}async function vu(e){return hu((await mu(await fetch(pu,{method:`POST`,credentials:`same-origin`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}))).item)}async function yu(e,t){let n=await mu(await fetch(`${pu}/${encodeURIComponent(e)}`,{method:`PATCH`,credentials:`same-origin`,headers:{"content-type":`application/json`},body:JSON.stringify(t)}));return gu(t,n.item),hu(n.item)}async function bu(e){return await yu(e,{status:`done`})}async function xu(e,t){return await yu(e,{remindAt:t})}function Su(e){let[t,n]=(0,Y.useState)([]),[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(null),s=(0,Y.useCallback)(async()=>{i(!0),o(null);try{let e=await _u();n(e.items||[])}catch(e){o(e.message)}finally{i(!1)}},[]),c=(0,Y.useCallback)(async()=>{await s()},[s]),l=(0,Y.useCallback)(async e=>{o(null);try{let t=await vu(e);n(e=>[t,...e.filter(e=>e.id!==t.id)])}catch(e){throw o(e.message),e}},[]),u=(0,Y.useCallback)(async(e,t)=>{o(null);try{let r=await yu(e,t);n(t=>t.map(t=>t.id===e?r:t))}catch(e){o(e.message)}},[]),d=(0,Y.useCallback)(async e=>{o(null);let t=[];n(n=>(t=n,n.map(t=>t.id===e?{...t,status:`done`}:t)));try{let t=await bu(e);n(n=>n.map(n=>n.id===e?t:n))}catch(e){n(t),o(e.message)}},[]),f=(0,Y.useCallback)(async(e,t)=>{o(null);try{let r=await xu(e,t);n(t=>t.map(t=>t.id===e?r:t))}catch(e){o(e.message)}},[]);return(0,Y.useEffect)(()=>{e.active&&s()},[e.active,s]),(0,Y.useEffect)(()=>{if(!e.active||!e.pollWhileActiveMs)return;let t=window.setInterval(()=>{document.hidden||s()},e.pollWhileActiveMs);return()=>window.clearInterval(t)},[e.active,e.pollWhileActiveMs,s]),(0,Y.useEffect)(()=>{if(!e.active||!e.pollWhileActiveMs)return;let t=()=>{document.hidden||s()};return window.addEventListener(`focus`,t),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`focus`,t),document.removeEventListener(`visibilitychange`,t)}},[e.active,e.pollWhileActiveMs,s]),{items:t,loading:r,error:a,refresh:c,create:l,update:u,markDone:d,snooze:f}}var Cu=400,wu=6e4,Tu=25e3,Eu=3e3;async function Du(){let e=N()?.browser;if(!e?.getWebviewTabs)return null;let t=await e.getWebviewTabs();return t?.ok?(t.tabs??[]).filter(e=>e.sharedWithAgent===!0).map(e=>({targetId:e.tabId,url:e.url,title:e.title,devToolsOpen:e.devToolsOpen===!0,sharedWithAgent:!0,actionsEnabled:!0})):null}function Ou(e,t){let n=(0,Y.useRef)(null),r=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{if(!e)return;let i=N()?.browser;if(!i?.getWebviewTabs||!i.onWebviewState)return;let a=!1,o=new AbortController;async function s(e,t){try{await fetch(`/api/dashboard/instances/${e}/embedded-browser/targets`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({targets:t})})}catch{}}async function c(){if(a)return;let e=await Du().catch(()=>null);if(a||e===null)return;try{await fetch(`/api/manager/embedded-browser/targets`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({targets:e})})}catch{}if(a)return;let n=r.current;n!==null&&n!==t&&(await s(n,[]),a)||t!==null&&(await s(t,e),a)||(r.current=t)}function l(){n.current!==null&&window.clearTimeout(n.current),n.current=window.setTimeout(()=>{c()},Cu)}async function u(e){let t=N()?.browser;if(!t?.performWebviewAction)return{ok:!1,error:`bridge unavailable`};if(!(await Du().catch(()=>null)??[]).find(t=>t.targetId===e.targetId))return{ok:!1,error:`target is no longer available in Manager Browser`};let n=e.targetId;if(e.kind===`screenshot`){let e=await t.performWebviewAction({kind:`captureScreenshot`,tabId:n});return e?.ok&&e.screenshot?{ok:!0,screenshot:e.screenshot}:{ok:!1,error:e?.error??`capture failed`}}if(e.kind===`snapshot`){let e=await t.performWebviewAction({kind:`getDomSnapshot`,tabId:n});return e?.ok&&e.snapshot?{ok:!0,snapshot:e.snapshot}:{ok:!1,error:e?.error??`snapshot failed`}}if(e.kind===`act`){let r=e.act;if(!r)return{ok:!1,error:`act payload missing`};let i=await t.performWebviewAction({kind:`act`,tabId:n,act:r});return i?.ok?{ok:!0,acted:!0}:{ok:!1,error:i?.error??`act failed`}}return{ok:!1,error:`unknown command kind: ${e.kind}`}}async function d(){for(;!a;){let e=Date.now();try{let e=await fetch(`/api/manager/embedded-browser/commands?wait=${Tu}`,{signal:o.signal});if(!e.ok)throw Error(`commands poll ${e.status}`);let t=await e.json();for(let e of t.commands??[]){if(a)return;let t=await u(e);await fetch(`/api/manager/embedded-browser/commands/${encodeURIComponent(e.id)}/result`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...t,settleToken:e.settleToken})}).catch(()=>void 0)}}catch{await new Promise(e=>setTimeout(e,Eu))}let t=Date.now()-e;!a&&t<1e3&&await new Promise(e=>setTimeout(e,1e3-t))}}let f=i.onWebviewState(()=>l()),p=0,m=window.setInterval(()=>{if(typeof document<`u`&&document.hidden){if(Date.now()-p<24e4)return;p=Date.now(),c();return}p=0,c()},wu);return c(),d(),()=>{a=!0,o.abort(),f(),window.clearInterval(m),n.current!==null&&window.clearTimeout(n.current);let e=r.current;r.current=null,e!==null&&fetch(`/api/dashboard/instances/${e}/embedded-browser/targets`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({targets:[]})}).catch(()=>void 0)}},[e,t])}function ku(e){let t=e;return typeof t?.closest==`function`&&!!t.closest(`.preview-panel, .preview-frame`)}function Au(e){return!ku(e)}function ju(e){return e.find(e=>e.kind===`directory`)??null}function Mu(e){return e.find(e=>e.kind===`file`)??null}function Nu(e){let t=e.rejected?.length??0,n=t>0?` ${t} rejected.`:``;if(e.entries.length===0)return e.error?`Drop failed: ${e.error}`:t>0?`Drop rejected: ${e.rejected?.[0]?.reason??`path not allowed`}`:null;if(e.source===`preview`)return`Captured ${e.entries.length} dropped item${e.entries.length===1?``:`s`} from preview.${n}`;let r=ju(e.entries);if(r)return`Opened dropped folder: ${r.name}.${n}`;let i=Mu(e.entries);return i?`Opened dropped file: ${i.name}.${n}`:`Opened ${e.entries.length} dropped item${e.entries.length===1?``:`s`}.${n}`}function Pu(e){return e?e.files.length>0||Array.from(e.types).includes(`Files`):!1}function Fu(e){let{onDroppedPaths:t}=e,n=(0,Y.useCallback)(async(e,n)=>{let r=N()?.dragDrop;if(!r||e.length===0)return[];try{let i=await r.resolveDroppedItems(e),a=i.entries??[],o=i.rejected??[];return(a.length>0||o.length>0||i.error)&&t({source:n,entries:a,...o.length>0?{rejected:o}:{},...i.error?{error:i.error}:{}}),a}catch(e){return console.warn(`[electron-drop] failed to resolve dropped files`,e),t({source:n,entries:[],error:e.message}),[]}},[t]);return(0,Y.useEffect)(()=>{if(!ce()||!N()?.dragDrop)return;function e(e){let t=e.dataTransfer;t&&Pu(t)&&Au(e.target)&&(e.preventDefault(),t.dropEffect=`copy`)}function t(e){let t=e.dataTransfer?.files?Array.from(e.dataTransfer.files):[];t.length!==0&&Au(e.target)&&(e.preventDefault(),e.stopPropagation(),n(t,`manager`))}return document.addEventListener(`dragover`,e,!0),document.addEventListener(`drop`,t,!0),()=>{document.removeEventListener(`dragover`,e,!0),document.removeEventListener(`drop`,t,!0)}},[n]),{resolveDroppedFiles:n}}function Iu(e){return e.trim().toLowerCase()}function Lu(e,t){let n=Iu(e),r=Iu(t);if(!r)return 1;if(n.startsWith(r))return 1e3-n.length;let i=n.indexOf(r);if(i>=0)return 700-i;let a=-1,o=0,s=0;for(let e of r){let t=n.indexOf(e,a+1);if(t<0)return null;o=t===a+1?o+1:0,s+=4+o*3-Math.min(t,40)*.1,a=t}return s}function Ru(e,t){let n=[{value:e.label,boost:120},{value:e.section,boost:40},...(e.keywords||[]).map(e=>({value:e,boost:80}))],r=null;for(let i of n){let n=Lu(i.value,t);if(n==null)continue;let a=n+i.boost;(!r||a>r.score)&&(r={command:e,score:a})}return r}function zu(e,t){return e.map(e=>Ru(e,t.trim())).filter(e=>!!e).sort((e,t)=>{if(t.score!==e.score)return t.score-e.score;let n=e.command.section.localeCompare(t.command.section);return n===0?e.command.label.localeCompare(t.command.label):n})}function Bu(e,t,n){return n<=0?0:Math.max(0,Math.min(n-1,e+t))}function Vu(e){let t=Ua(),[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(``),[o,s]=(0,Y.useState)(0),c=(0,Y.useRef)(null),l=(0,Y.useMemo)(()=>zu(t,i),[t,i]),u=l[o]?`notes-command-palette-option-${o}`:void 0;(0,Y.useEffect)(()=>{if(!e.active){r(!1);return}function t(e){yc(e)&&(e.preventDefault(),r(e=>!e))}return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e.active]),(0,Y.useEffect)(()=>{n&&(a(``),s(0),requestAnimationFrame(()=>c.current?.focus()))},[n]),(0,Y.useEffect)(()=>{o>=l.length&&s(Math.max(0,l.length-1))},[o,l.length]),(0,Y.useEffect)(()=>{(u?document.getElementById(u):null)?.scrollIntoView({block:`nearest`})},[u]);function d(e){if(!e.disabled){r(!1);try{Promise.resolve(e.run()).catch(e=>{console.warn(`[notes-command-palette]`,e)})}catch(e){console.warn(`[notes-command-palette]`,e)}}}function f(){let e=l[o]?.command;e&&d(e)}function p(e){if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`p`){e.preventDefault(),e.stopPropagation();return}e.key===`ArrowDown`?(e.preventDefault(),s(e=>Bu(e,1,l.length))):e.key===`ArrowUp`?(e.preventDefault(),s(e=>Bu(e,-1,l.length))):e.key===`Enter`?(e.preventDefault(),f()):e.key===`Escape`&&(e.preventDefault(),r(!1))}return n?(0,X.jsx)(`div`,{className:`notes-command-palette-backdrop`,role:`presentation`,onClick:()=>r(!1),"data-notes-palette":!0,children:(0,X.jsxs)(`section`,{className:`notes-command-palette`,role:`dialog`,"aria-modal":`true`,"aria-label":`Notes command palette`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:[(0,X.jsx)(`input`,{ref:c,className:`notes-command-palette-input`,type:`search`,placeholder:`Run command`,value:i,onChange:e=>{a(e.currentTarget.value),s(0)},onKeyDown:p,"aria-label":`Run Notes command`,"aria-controls":`notes-command-palette-results`,"aria-activedescendant":u}),(0,X.jsxs)(`div`,{id:`notes-command-palette-results`,className:`notes-command-palette-list`,role:`listbox`,"aria-label":`Matching commands`,children:[l.map((e,t)=>{let n=e.command,r=t===o;return(0,X.jsxs)(`button`,{id:`notes-command-palette-option-${t}`,type:`button`,role:`option`,"aria-selected":r,"aria-disabled":n.disabled||void 0,className:`notes-command-palette-item${r?` is-active`:``}${n.disabled?` is-disabled`:``}`,onMouseEnter:()=>s(t),onClick:()=>d(n),children:[(0,X.jsx)(`span`,{className:`notes-command-palette-title`,children:n.label}),(0,X.jsx)(`span`,{className:`notes-command-palette-meta`,children:n.disabledReason||n.section}),n.shortcut&&(0,X.jsx)(`kbd`,{className:`notes-command-palette-shortcut`,children:n.shortcut})]},n.id)}),l.length===0&&(0,X.jsx)(`p`,{className:`notes-command-palette-empty`,children:`No matching commands.`})]}),(0,X.jsxs)(`footer`,{className:`notes-command-palette-footer`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`kbd`,{children:`Up/Down`}),` move`]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`kbd`,{children:`Enter`}),` run`]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`kbd`,{children:`Esc`}),` close`]})]})]})}):null}var Hu=76,Uu=8,Wu=96;function Gu(e){return!e||e.scrollHeight-e.scrollTop-e.clientHeight<Wu}function Ku(e){let t=(0,Y.useRef)(null),s=(0,Y.useRef)(!0),c=(0,Y.useRef)(e.count),[{virtualItems:l,totalSize:u},d]=(0,Y.useState)({virtualItems:[],totalSize:0}),f=(0,Y.useRef)(null);f.current||=new o({count:e.count,getScrollElement:()=>t.current,estimateSize:e.estimateSize||(()=>Hu),overscan:Uu,getItemKey:e.getItemKey,indexAttribute:`data-jaw-ceo-idx`,useAnimationFrameWithResizeObserver:!0,observeElementRect:n,observeElementOffset:r,scrollToFn:i,measureElement:a,onChange:e=>{d({virtualItems:e.getVirtualItems(),totalSize:e.getTotalSize()})}});let p=f.current,m=(0,Y.useCallback)(e=>{t.current=e,s.current=Gu(e),p._willUpdate()},[p]),h=(0,Y.useCallback)(()=>{s.current=Gu(t.current)},[]),g=(0,Y.useCallback)(e=>{e&&p.measureElement(e)},[p]);return(0,Y.useEffect)(()=>p._didMount(),[p]),(0,Y.useEffect)(()=>()=>{f.current=null},[]),(0,Y.useLayoutEffect)(()=>{p.setOptions({...p.options,count:e.count,getItemKey:e.getItemKey,estimateSize:e.estimateSize||(()=>Hu)}),p._willUpdate(),d({virtualItems:p.getVirtualItems(),totalSize:p.getTotalSize()})},[e.count,e.estimateSize,e.getItemKey,p]),(0,Y.useLayoutEffect)(()=>{let t=c.current;c.current=e.count,e.count!==0&&(t>0&&!s.current||requestAnimationFrame(()=>{p.scrollToIndex(e.count-1,{align:`end`})}))},[e.count,p]),{scrollRef:m,onScroll:h,measureElement:g,virtualItems:l,totalSize:u}}async function qu(e,t){let n=await e.text(),r=null;if(n.trim())try{r=JSON.parse(n)}catch{throw Error(`${t}: endpoint returned non-JSON; restart the dashboard server to load the Jaw CEO API`)}if(!e.ok||!r||r.ok===!1){let e=r&&r.ok===!1&&(r.error||r.message)||t;throw Error(e)}return r.data}async function Ju(e,t){return await qu(await fetch(e),t)}async function Yu(e,t={},n=`Jaw CEO request failed`){return await qu(await fetch(e,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)}),n)}async function Xu(e,t={},n=`Jaw CEO request failed`){return await qu(await fetch(e,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(t)}),n)}async function Zu(){return await Ju(`/api/jaw-ceo/state`,`Jaw CEO state fetch failed`)}async function Qu(){return await Ju(`/api/jaw-ceo/settings`,`Jaw CEO settings fetch failed`)}async function $u(e){return await Xu(`/api/jaw-ceo/settings`,e,`Jaw CEO settings save failed`)}async function ed(e){let t={text:e.text,selectedPort:e.selectedPort,inputMode:e.inputMode||`text`,responseMode:e.responseMode||`text`};return e.sessionId&&(t.sessionId=e.sessionId),await Yu(`/api/jaw-ceo/message`,t,`Jaw CEO message failed`)}async function td(e){let t={};return e.ports!==void 0&&(t.ports=e.ports),e.events!==void 0&&(t.events=e.events),e.sinceCursor!==void 0&&(t.sinceCursor=e.sinceCursor),await Yu(`/api/jaw-ceo/events/refresh`,t,`Jaw CEO event refresh failed`)}async function nd(e,t){return await Yu(`/api/jaw-ceo/pending/${encodeURIComponent(e)}/continue`,{mode:t},`Jaw CEO continue failed`)}async function rd(e,t=`short`){return await Yu(`/api/jaw-ceo/pending/${encodeURIComponent(e)}/summarize`,{format:t},`Jaw CEO summarize failed`)}async function id(e,t){return await Yu(`/api/jaw-ceo/pending/${encodeURIComponent(e)}/${t}`,{},`Jaw CEO pending update failed`)}async function ad(e){let t={offerSdp:e.offerSdp,selectedPort:e.selectedPort,responseMode:e.responseMode||`voice`};return e.sessionId&&(t.sessionId=e.sessionId),await Yu(`/api/jaw-ceo/voice/connect`,t,`Jaw CEO voice connect failed`)}async function od(e){return await Yu(`/api/jaw-ceo/voice/${encodeURIComponent(e)}/close`,{},`Jaw CEO voice close failed`)}function sd(e){if(e?.openaiKeyInvalid)return`Invalid saved key`;if(!e?.openaiKeySet)return`No key saved`;let t=e.openaiKeyLast4?`•••• ${e.openaiKeyLast4}`:`saved`;return e.openaiKeySource===`env`?`Env key ${t}`:e.openaiKeySource===`deps`?`Runtime key ${t}`:`Saved key ${t}`}function cd(){let[e,t]=(0,Y.useState)(null),[n,r]=(0,Y.useState)(``),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(null),c=!!(e?.openaiKeyInvalid||e?.openaiKeySet&&e.openaiKeySource!==`env`);(0,Y.useEffect)(()=>{let e=!1;return Qu().then(n=>{e||t(n)}).catch(t=>{e||s(t.message)}),()=>{e=!0}},[]);async function l(){let e=n.trim();if(e){a(!0);try{let n=await $u({openaiApiKey:e});t(n),r(``),s(null)}catch(e){s(e.message)}finally{a(!1)}}}async function u(){a(!0);try{let e=await $u({clearOpenAiApiKey:!0});t(e),r(``),s(null)}catch(e){s(e.message)}finally{a(!1)}}return(0,X.jsx)(`section`,{className:`jaw-ceo-settings-panel`,"aria-label":`Jaw CEO settings`,children:(0,X.jsxs)(`form`,{className:`jaw-ceo-settings-form`,onSubmit:e=>{e.preventDefault(),l()},children:[(0,X.jsxs)(`div`,{className:`jaw-ceo-settings-status`,children:[(0,X.jsx)(`strong`,{children:`Realtime voice`}),(0,X.jsx)(`span`,{children:sd(e)})]}),(0,X.jsxs)(`label`,{children:[(0,X.jsx)(`span`,{children:`OpenAI API key`}),(0,X.jsx)(`input`,{value:n,type:`password`,autoComplete:`off`,spellCheck:!1,placeholder:e?.openaiKeySet?`sk-... replace saved key`:`sk-...`,onChange:e=>r(e.target.value)})]}),(0,X.jsxs)(`div`,{className:`jaw-ceo-settings-meta`,children:[(0,X.jsx)(`span`,{children:e?.model||`gpt-realtime-2`}),(0,X.jsx)(`span`,{children:e?.voice||`marin`})]}),e?.openaiKeyInvalid?(0,X.jsx)(`p`,{className:`jaw-ceo-inline-error`,children:`Saved value is not an OpenAI API key. Paste a key that starts with sk-.`}):null,o?(0,X.jsx)(`p`,{className:`jaw-ceo-inline-error`,children:o}):null,(0,X.jsxs)(`div`,{className:`jaw-ceo-form-row`,children:[(0,X.jsx)(`button`,{type:`button`,disabled:i||!c,onClick:()=>void u(),children:`Clear saved`}),(0,X.jsx)(`button`,{type:`submit`,disabled:i||!n.trim(),children:i?`Saving`:`Save key`})]})]})})}function ld(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()}function ud(e){return e.summary||`Worker :${e.port} has a result ready.`}function dd(e){return[{label:e==null?`Inspect dashboard`:`Inspect :${e}`,text:e==null?`What needs attention on this dashboard right now?`:`What is worker :${e} doing right now?`},{label:`Summarize results`,text:`Summarize the worker results and tell me what needs action.`},{label:e==null?`Route work`:`Send to :${e}`,text:e==null?`Create or choose the right worker for this task: `:`Send this task to worker :${e}: `}]}function fd(e){let t=Array.isArray(e.ceo.state.transcript)?e.ceo.state.transcript:[],n=Array.isArray(e.ceo.state.watches)?e.ceo.state.watches:[],r=Array.isArray(e.ceo.audit)?e.ceo.audit:[],i=[...t.map(e=>({kind:`chat`,id:e.id,at:e.at,role:e.role,text:e.text})),...e.ceo.pending.filter(e=>e.status===`pending`||e.status===`spoken`).map(e=>({kind:`result`,id:`result-${e.completionKey}`,at:e.detectedAt,completion:e})),...n.map(e=>({kind:`watch`,id:`watch-${e.watchId}`,at:e.createdAt,watch:e})),...r.slice(-24).map(e=>({kind:`tool`,id:`audit-${e.id}`,at:e.at,record:e}))];return i.sort((e,t)=>{let n=Date.parse(e.at)-Date.parse(t.at);return n===0?e.id.localeCompare(t.id):n}),e.voice.lastTranscript&&i.push({kind:`live`,id:`live-voice-transcript`,at:new Date().toISOString(),text:e.voice.lastTranscript,eventType:e.voice.lastEventType}),i}function pd(e){if(!e)return 76;if(e.kind===`activity-group`)return 52;let t=Math.max(1,e.text.split(/\r?\n/).filter(Boolean).length);return Math.min(220,54+t*18)}function md(e){let t=[],n=[];function r(){n.length!==0&&(t.push({kind:`activity-group`,id:`activity-${n[0].id}-${n.length}`,at:n[0].at,entries:n}),n=[])}for(let i of e)i.kind===`chat`||i.kind===`live`?(r(),t.push(i)):n.push(i);return r(),t}function hd(e){return e.kind===`result`?`subagent`:e.kind===`watch`?`thinking`:e.record.kind===`tool`?`tool`:e.record.kind===`completion`?`subagent`:`thinking`}function gd(e){return e.kind===`result`?`Worker :${e.completion.port} result`:e.kind===`watch`?`Listening to worker :${e.watch.port}`:e.record.kind===`completion`?`Worker completion`:e.record.kind===`docs_edit`?`Docs edit`:e.record.kind===`lifecycle`?`Lifecycle`:e.record.kind===`policy`?`Policy check`:e.record.action||`Tool use`}function _d(e){return e.kind===`result`?e.completion.resultText||ud(e.completion):e.kind===`watch`?`${e.watch.reason} · fallback ${e.watch.latestMessageFallback.mode}`:e.record.message}function vd(e){return e.kind===`result`?e.completion.detectedAt:e.kind===`watch`?e.watch.createdAt:e.record.at}function yd(e){return e.kind===`tool`&&!e.record.ok}function bd(e){let t=e.reduce((e,t)=>(e[hd(t)]+=1,e),{tool:0,thinking:0,subagent:0});return[t.tool>0?`Tool×${t.tool}`:null,t.thinking>0?`Thinking×${t.thinking}`:null,t.subagent>0?`Subagent×${t.subagent}`:null].filter(Boolean).join(` + `)}function xd(e){let t=e.text.split(/\r?\n/).map(e=>e.trim()).filter(Boolean);if(t.length===0)return(0,X.jsx)(`p`,{children:`...`});let n=[],r=[];function i(){r.length!==0&&(n.push((0,X.jsx)(`ul`,{children:r.map((e,t)=>(0,X.jsx)(`li`,{children:e},`${e}-${t}`))},`ul-${n.length}`)),r=[])}return t.forEach((e,t)=>{let a=e.match(/^[-*]\s+(.+)$/);if(a){r.push(a[1]);return}i(),n.push((0,X.jsx)(`p`,{children:e},`p-${t}`))}),i(),(0,X.jsx)(X.Fragment,{children:n})}function Sd(e){return e.tone===`tool`?(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{d:`M10.5 2.5 13 5l-2.4 2.4-1.2-1.2-4.8 4.8-1.7.2.2-1.7 4.8-4.8-1.1-1.1L9.2 1.2l1.3 1.3Z`})}):e.tone===`subagent`?(0,X.jsxs)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,X.jsx)(`path`,{d:`M3 4.5h10v7H3z`}),(0,X.jsx)(`path`,{d:`M6 4.5V3h4v1.5M5.2 8h.1M10.7 8h.1`})]}):(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{d:`M3 4.5h10v7H5.7L3 13.4z`})})}function Cd(e){return(0,X.jsxs)(`section`,{className:`jaw-ceo-activity-shell`,"aria-label":`CEO activity`,children:[(0,X.jsx)(`span`,{className:`jaw-ceo-activity-avatar`,"aria-hidden":`true`,children:`CEO`}),(0,X.jsxs)(`details`,{className:`jaw-ceo-activity-group`,children:[(0,X.jsxs)(`summary`,{children:[(0,X.jsx)(`span`,{className:`jaw-ceo-activity-status`,"aria-hidden":`true`}),(0,X.jsx)(`strong`,{children:bd(e.entries)||`Activity`})]}),(0,X.jsx)(`div`,{className:`jaw-ceo-activity-list`,children:e.entries.map(t=>{let n=hd(t);return(0,X.jsxs)(`article`,{className:`jaw-ceo-activity-row tone-${n}${yd(t)?` is-error`:``}`,children:[(0,X.jsx)(`span`,{className:`jaw-ceo-activity-dot`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`jaw-ceo-activity-icon`,children:(0,X.jsx)(Sd,{tone:n})}),(0,X.jsx)(`span`,{className:`jaw-ceo-activity-badge`,children:n}),(0,X.jsxs)(`div`,{className:`jaw-ceo-activity-copy`,children:[(0,X.jsx)(`strong`,{children:gd(t)}),(0,X.jsx)(`p`,{children:_d(t)}),(0,X.jsx)(`small`,{children:ld(vd(t))})]}),t.kind===`result`?(0,X.jsxs)(`div`,{className:`jaw-ceo-activity-actions`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>e.onOpenWorker(t.completion.port,t.completion.messageId),children:`Open`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void e.model.summarize(t.completion),children:`Summary`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void e.model.continueCompletion(t.completion),children:`Continue`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void e.voice.speakCompletion(t.completion),children:`Speak`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void e.ceo.ackCompletion(t.completion.completionKey),children:`Ack`})]}):(0,X.jsx)(`span`,{className:`jaw-ceo-trace-chip`,children:`Trace`})]},t.id)})})]})]})}function wd(e){let t=e.entry;return t.kind===`activity-group`?(0,X.jsx)(Cd,{entries:t.entries,model:e.model,ceo:e.ceo,voice:e.voice,onOpenWorker:e.onOpenWorker}):t.kind===`chat`?(0,X.jsxs)(`article`,{className:`jaw-ceo-message-row role-${t.role}`,children:[(0,X.jsx)(`span`,{className:`jaw-ceo-message-avatar`,"aria-hidden":`true`,children:t.role===`user`?`You`:t.role===`ceo`?`CEO`:`Log`}),(0,X.jsxs)(`div`,{className:`jaw-ceo-message-bubble`,children:[(0,X.jsxs)(`div`,{className:`jaw-ceo-message-meta`,children:[(0,X.jsx)(`strong`,{children:t.role===`user`?`You`:t.role===`ceo`?`Jaw CEO`:`Tool output`}),(0,X.jsx)(`small`,{children:ld(t.at)})]}),(0,X.jsx)(`div`,{className:`jaw-ceo-message-text`,children:(0,X.jsx)(xd,{text:t.text})})]})]}):t.kind===`live`?(0,X.jsxs)(`article`,{className:`jaw-ceo-message-row role-ceo is-live`,"aria-live":`polite`,children:[(0,X.jsx)(`span`,{className:`jaw-ceo-message-avatar is-live`,"aria-hidden":`true`,children:`CEO`}),(0,X.jsxs)(`div`,{className:`jaw-ceo-message-bubble`,children:[(0,X.jsxs)(`div`,{className:`jaw-ceo-message-meta`,children:[(0,X.jsx)(`strong`,{children:`Jaw CEO live`}),(0,X.jsx)(`small`,{children:t.eventType||`realtime`})]}),(0,X.jsx)(`div`,{className:`jaw-ceo-message-text`,children:(0,X.jsx)(xd,{text:t.text})})]})]}):null}function Td(e){let t=(0,Y.useMemo)(()=>md(fd({model:e.model,ceo:e.ceo,voice:e.voice})),[e.model,e.ceo.state.transcript,e.ceo.pending,e.ceo.state.watches,e.ceo.audit,e.voice.lastTranscript,e.voice.lastEventType]),n=(0,Y.useCallback)(e=>t[e]?.id||e,[t]),r=(0,Y.useCallback)(e=>pd(t[e]),[t]),i=Ku({count:t.length,getItemKey:n,estimateSize:r});return(0,X.jsxs)(`section`,{className:`jaw-ceo-chat-panel`,"aria-label":`Jaw CEO chat`,children:[(0,X.jsx)(`div`,{ref:i.scrollRef,onScroll:i.onScroll,className:`jaw-ceo-chat-log jaw-ceo-timeline is-virtual`,"aria-live":`polite`,children:t.length===0?(0,X.jsxs)(`div`,{className:`jaw-ceo-empty-state`,children:[(0,X.jsx)(`span`,{className:`jaw-ceo-empty-kicker`,children:`Ready`}),(0,X.jsx)(`strong`,{children:e.selectedPort==null?`Dashboard context`:`Worker :${e.selectedPort} selected`}),(0,X.jsx)(`div`,{className:`jaw-ceo-quick-prompts`,children:dd(e.selectedPort).map(t=>(0,X.jsx)(`button`,{type:`button`,onClick:()=>e.model.setMessage(t.text),children:t.label},t.label))})]}):(0,X.jsx)(`div`,{className:`jaw-ceo-virtual-spacer`,style:{height:`${i.totalSize}px`},children:i.virtualItems.map(n=>{let r=t[n.index];return r?(0,X.jsx)(`div`,{ref:i.measureElement,className:`jaw-ceo-virtual-row`,"data-jaw-ceo-idx":n.index,style:{transform:`translateY(${n.start}px)`},children:(0,X.jsx)(wd,{entry:r,model:e.model,ceo:e.ceo,voice:e.voice,onOpenWorker:e.onOpenWorker})},n.key):null})})}),(0,X.jsxs)(`form`,{className:`jaw-ceo-message-form`,onSubmit:t=>void e.model.submitMessage(t),children:[(0,X.jsx)(`textarea`,{value:e.model.message,rows:3,placeholder:`Send a task to the selected worker or ask about the dashboard.`,onChange:t=>e.model.setMessage(t.target.value)}),(0,X.jsxs)(`div`,{className:`jaw-ceo-form-row`,children:[(0,X.jsxs)(`select`,{value:e.model.responseMode,"aria-label":`Response mode`,onChange:t=>e.model.setResponseMode(t.target.value),children:[(0,X.jsx)(`option`,{value:`text`,children:`Text`}),(0,X.jsx)(`option`,{value:`voice`,children:`Voice`}),(0,X.jsx)(`option`,{value:`both`,children:`Both`}),(0,X.jsx)(`option`,{value:`silent`,children:`Silent`})]}),(0,X.jsx)(`button`,{type:`submit`,disabled:e.ceo.busy||!e.model.message.trim(),children:`Send`})]})]})]})}function Ed(e){return e.model.tab===`settings`?(0,X.jsx)(cd,{}):(0,X.jsx)(Td,{model:e.model,ceo:e.ceo,voice:e.voice,selectedPort:e.selectedPort,onOpenWorker:e.onOpenWorker})}var Dd=[{id:`chat`,label:`Chat`},{id:`settings`,label:`Settings`}];function Od(e){return(0,X.jsx)(`div`,{className:`jaw-ceo-tabs`,role:`tablist`,"aria-label":`Jaw CEO console tabs`,children:Dd.map(t=>(0,X.jsx)(`button`,{type:`button`,role:`tab`,className:e.active===t.id?`is-active`:``,"aria-selected":e.active===t.id,onClick:()=>e.onChange(t.id),children:(0,X.jsx)(`span`,{children:t.label})},t.id))})}function kd(e){return async t=>{t.preventDefault();let n=e.message.trim();if(n){e.setMessage(``);try{await e.ceo.sendText(n,e.responseMode),e.setTab(`chat`)}catch{}}}}function Ad(e){return{summarize:async t=>{await e.ceo.summarizeCompletion(t.completionKey,`short`),await e.ceo.refresh(),e.setTab(`chat`)},continueCompletion:async t=>{let n=e.responseMode===`voice`||e.responseMode===`both`||e.responseMode===`silent`?e.responseMode:`text`;await e.ceo.continueCompletion(t.completionKey,n),await e.ceo.refresh(),e.setTab(`chat`)}}}function jd(e){let[t,n]=(0,Y.useState)(`chat`),[r,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(`text`),s=Ad({ceo:e.ceo,responseMode:a,setTab:n});return{tab:t,setTab:n,message:r,setMessage:i,responseMode:a,setResponseMode:o,submitMessage:kd({ceo:e.ceo,message:r,responseMode:a,setMessage:i,setTab:n}),...s}}var Md=()=>(0,X.jsxs)(`svg`,{viewBox:`0 0 16 16`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,X.jsx)(`path`,{d:`M13.2 8a5.2 5.2 0 1 1-1.5-3.7`}),(0,X.jsx)(`path`,{d:`M13.2 3.2v3.2H10`})]}),Nd=()=>(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`17`,height:`17`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{d:`M4 4l8 8M12 4l-8 8`})});function Pd(e){return e===`connecting`?`connecting`:e===`active`?`listening`:e===`silent`?`silent`:e===`paused`?`paused`:e===`sleeping`?`sleeping`:e===`disabled`?`disabled`:e===`error`?`error`:`idle`}function Fd(e){return e===`active`||e===`connecting`||e===`silent`}function Id(e){return e===`active`||e===`connecting`||e===`silent`?`live`:e===`paused`||e===`sleeping`?`paused`:e===`disabled`||e===`error`?`issue`:`idle`}function Ld(e){let t=(0,Y.useRef)(null),n=jd({ceo:e.ceo});if((0,Y.useEffect)(()=>{if(!e.open)return;t.current?.focus();function n(t){if(t.key===`Escape`){if(Fd(e.voice.status)){t.preventDefault(),e.voice.stop();return}e.onClose()}}return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e]),!e.open)return null;let r=e.selectedPort==null?`Dashboard`:`Worker :${e.selectedPort}`,i=Pd(e.voice.status);return(0,X.jsxs)(`div`,{className:`jaw-ceo-console`,role:`region`,"aria-label":`Jaw CEO console`,"data-surface-owner":`ceo-orchestration-control`,children:[(0,X.jsxs)(`header`,{className:`jaw-ceo-console-header`,children:[(0,X.jsxs)(`div`,{className:`jaw-ceo-console-titlebar`,children:[(0,X.jsx)(`span`,{className:`jaw-ceo-console-mark status-${e.voice.status}`,"aria-hidden":`true`,children:`CEO`}),(0,X.jsxs)(`div`,{className:`jaw-ceo-console-heading`,children:[(0,X.jsx)(`span`,{children:`Dashboard coordinator`}),(0,X.jsx)(`h3`,{children:`Jaw CEO`})]})]}),(0,X.jsxs)(`div`,{className:`jaw-ceo-console-header-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`jaw-ceo-icon-btn`,onClick:()=>void e.ceo.refresh(),"aria-label":`Refresh Jaw CEO`,children:(0,X.jsx)(Md,{})}),(0,X.jsx)(`button`,{ref:t,type:`button`,className:`jaw-ceo-console-close`,onClick:e.onClose,"aria-label":`Close Jaw CEO`,children:(0,X.jsx)(Nd,{})})]}),(0,X.jsxs)(`div`,{className:`jaw-ceo-console-summary`,"aria-label":`Jaw CEO status summary`,children:[(0,X.jsx)(`span`,{children:r}),(0,X.jsx)(`span`,{children:`Single session`}),(0,X.jsxs)(`span`,{className:`voice-tone-${Id(e.voice.status)}`,children:[`Voice `,i]})]})]}),(0,X.jsx)(Od,{active:n.tab,onChange:n.setTab}),(0,X.jsx)(`div`,{className:`jaw-ceo-console-body`,children:(0,X.jsx)(Ed,{model:n,ceo:e.ceo,voice:e.voice,selectedPort:e.selectedPort,onOpenWorker:e.onOpenWorker})}),(0,X.jsxs)(`footer`,{className:`jaw-ceo-console-footer voice-${e.voice.status}`,children:[(0,X.jsxs)(`div`,{className:`jaw-ceo-realtime-status`,children:[(0,X.jsx)(`span`,{className:`jaw-ceo-realtime-dot`,"aria-hidden":`true`}),(0,X.jsxs)(`span`,{children:[`Voice: `,i,e.voice.error?` - ${e.voice.error}`:``]}),e.voice.lastTranscript?(0,X.jsx)(`small`,{children:e.voice.lastTranscript}):e.voice.lastEventType?(0,X.jsx)(`small`,{children:e.voice.lastEventType}):null]}),(0,X.jsx)(`button`,{type:`button`,className:`jaw-ceo-voice-action`,onClick:()=>Fd(e.voice.status)?void e.voice.stop():void e.voice.talk(),children:Fd(e.voice.status)?`Stop voice`:`Start voice`})]})]})}function Rd({codeMode:e,onChange:t}){return(0,X.jsxs)(`div`,{className:`mode-switch`,role:`tablist`,"aria-label":`Jaw / Code mode`,children:[(0,X.jsx)(`button`,{type:`button`,role:`tab`,className:`mode-switch-tab ${e?``:`active`}`,"aria-selected":!e,onClick:()=>t(!1),children:`Jaw`}),(0,X.jsx)(`button`,{type:`button`,role:`tab`,className:`mode-switch-tab ${e?`active`:``}`,"aria-selected":e,onClick:()=>t(!0),children:`Code`})]})}var zd=(0,Y.lazy)(()=>t(()=>import(`./TerminalPanel-c1xhiy53.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([1]))),Bd=(0,Y.lazy)(()=>t(()=>import(`./DiffPanel-D9Cch5FG.js`).then(e=>({default:e.DiffPanel})),__vite__mapDeps([2]))),Vd=(0,Y.lazy)(()=>t(()=>import(`./FolderPanel-CJvwRwIV.js`).then(e=>({default:e.FolderPanel})),__vite__mapDeps([3]))),Hd=(0,Y.lazy)(()=>t(()=>import(`./DocPanel-DvtFw8AP.js`).then(e=>({default:e.DocPanel})),__vite__mapDeps([0,4]))),Ud=(0,Y.lazy)(()=>t(()=>import(`./BrowserPanel-Bb-Bge6B.js`).then(e=>({default:e.BrowserPanel})),__vite__mapDeps([5]))),Wd=(0,Y.lazy)(()=>t(()=>import(`./DesignPanel-BOb-HMbl.js`).then(e=>({default:e.DesignPanel})),__vite__mapDeps([6]))),Gd=(0,Y.lazy)(()=>t(()=>import(`./CodeCanvas-CVbdp0S-.js`).then(e=>({default:e.CodeCanvas})),[]));function Kd(e){return(0,X.jsx)(`section`,{className:`workspace-surface${e.active?` is-active`:``}`,hidden:!e.active,"aria-hidden":!e.active,children:e.children})}function qd(e){if(!e.startsWith(`~/`))return e;let t=N()?.getHomePath?.()?.replace(/\/+$/,``);return t?`${t}/${e.slice(2)}`:e}function Jd(e,t,n){let r=(0,X.jsx)(`div`,{style:{padding:`12px`,color:`var(--text-dim)`,fontSize:`12px`},children:`Loading...`});switch(e){case`diff`:{let e=n.diffFilesTab,t=e?.files??{};return(0,X.jsx)(Y.Suspense,{fallback:r,children:(0,X.jsx)(Bd,{selectedInstance:n.selectedInstance,settings:n.dashboardSettingsUi,folderRootPath:t.folderRootPath??n.fallbackFolderRootPath,repoRootPath:t.repoRootPath??null,repoRootMode:t.repoRootMode??`instance`,selectedFilePath:t.activeFilePath??null,onRepoRootChange:(t,r)=>{e&&n.onTabRepoRootChange(e.id,t,r)},onFollowInstanceRepoRoot:t=>n.onFollowInstanceRepoRoot(e?.id??null,t),onPreviewFile:n.onOpenFileGlobal,onGitRefresh:n.onGitRefresh,onSettingsPatch:n.onDashboardSettingsPatch})})}case`files`:{let e=t.files??{},i=e.folderRootPath??n.fallbackFolderRootPath,a=e.repoRootMode??`instance`;return(0,X.jsx)(Hi,{filePane:(0,X.jsx)(Y.Suspense,{fallback:r,children:(0,X.jsx)(Hd,{filePath:e.activeFilePath??void 0,onOpenLocalFile:e=>n.onTabPreviewFile(t.id,e)})}),folderPane:(0,X.jsx)(Y.Suspense,{fallback:r,children:(0,X.jsx)(Vd,{selectedFilePath:e.activeFilePath??null,externalRootPath:i,repoRootPath:a===`instance`?e.repoRootPath??null:null,gitRefreshVersion:n.gitRefreshVersion,notesTree:n.notesModel.tree,notesRoot:n.notesModel.notesRoot,onRootChange:e=>n.onTabRootChange(t.id,e),onRepoRootChange:e=>n.onTabRepoRootChange(t.id,e),onGitRefresh:n.onGitRefresh,onPreviewFile:e=>n.onTabPreviewFile(t.id,e),sessionState:n.folderSessions[t.id]??null,onSessionStateChange:e=>n.onFolderSessionChange(t.id,e)})})})}case`browser`:return(0,X.jsx)(Y.Suspense,{fallback:r,children:(0,X.jsx)(Ud,{singlePage:!0,initialUrl:t.browser?.url,isActivePanel:t.id===n.activeTabId,moduleTabId:t.id,selectedInstancePort:n.selectedInstance?.port??null,onInsertCommentIntoPreview:n.onInsertCommentIntoPreview,onPageStateChange:e=>n.onBrowserPageState(t.id,e),onOpenNewWindow:n.onOpenBrowserWindow})});case`design`:return(0,X.jsx)(Y.Suspense,{fallback:r,children:(0,X.jsx)(Wd,{tab:t,primaryProjectDir:n.primaryProjectDir,selectedInstancePort:n.selectedInstance?.port??null,onOpenInBrowser:n.onOpenBrowserWindow})});default:return null}}function Yd(e,t,n,r){let i=(0,X.jsx)(`div`,{style:{padding:`12px`,color:`var(--text-dim)`,fontSize:`12px`},children:`Loading...`});switch(e){case`terminal`:return(0,X.jsx)(Y.Suspense,{fallback:i,children:(0,X.jsx)(zd,{onCollapse:t.onCollapse,onEmptySessions:t.onCloseTab})});case`browser`:return(0,X.jsx)(Y.Suspense,{fallback:i,children:(0,X.jsx)(Ud,{onCollapse:t.onCollapse,selectedInstancePort:n,onInsertCommentIntoPreview:r})});default:return null}}function Xd(e){let t=(0,Y.useCallback)(t=>e.onSettingsDirtyChange(`dashboard`,t),[e.onSettingsDirtyChange]),n=e.selectedInstance,r=n?{port:n.port,instanceUrl:n.url}:{},i={ui:e.dashboardSettingsUi,titleSupport:e.titleSupport,onUiPatch:e.onDashboardSettingsPatch},a=e.sidebarMode===`settings`,o=fe(),s=e.dashboardSettingsUi.rightFolderRootPath,l=o.state.rightPanel.tabs.openTabs,u=o.state.rightPanel.tabs.activeTabId,d=l.find(e=>e.id===u)??null,f=d?.kind===`files`?d:l.find(e=>e.kind===`files`)??null,[p,m]=(0,Y.useState)(0),h=(0,Y.useCallback)(()=>m(e=>e+1),[]),[g,_]=(0,Y.useState)({}),[,v]=(0,Y.useState)(null),[y,b]=(0,Y.useState)(null),[x,S]=(0,Y.useState)(`matrix`),C=Su({active:e.sidebarMode===`reminders`}),w=Qn()===`electron`,T=w,[E,D]=(0,Y.useState)(null),O=(0,Y.useRef)(0),k=(0,Y.useRef)(new Map),[A,ee]=(0,Y.useState)(null),j=(0,Y.useRef)(0),[M,te]=(0,Y.useState)(null);Ou(w,e.selectedInstance?.port??null);let ne=T&&o.effectiveRightOpen,re=f?.files?.folderRootPath||s||e.workingDir||``,ie=(0,Y.useCallback)((t,n)=>{if(e.selectedInstance?.port!==t)return Promise.resolve({ok:!1,error:`selected instance changed before preview insert`});if(!e.previewEnabled)return Promise.resolve({ok:!1,error:`Preview is off. Turn it on before inserting a browser comment.`});if(e.sidebarMode!==`instances`||e.viewMode!==`jaw`||e.activeDetailTab!==`preview`)return Promise.resolve({ok:!1,error:`Open the selected instance Preview tab before inserting a browser comment.`});let r=`browser-comment-${Date.now()}-${++O.current}`;return D({id:r,port:t,text:n}),new Promise(e=>{let t=window.setTimeout(()=>{k.current.delete(r),D(e=>e?.id===r?null:e),e({ok:!1,error:`preview insert timed out; reopen the selected instance Preview tab and try again`})},1400);k.current.set(r,n=>{window.clearTimeout(t),e(n)})})},[e.activeDetailTab,e.previewEnabled,e.selectedInstance?.port,e.sidebarMode,e.viewMode]),ae=(0,Y.useCallback)((e,t)=>{let n=k.current.get(e);n&&(k.current.delete(e),D(t=>t?.id===e?null:t),n(t))},[]),oe=(0,Y.useCallback)(()=>{te(null),j.current+=1,ee(`settings-open-${j.current}`)},[]),se=(0,Y.useCallback)((e,t)=>{ee(t=>t===e?null:t),te(t.ok?null:t.error)},[]),ce=!w&&e.jawCeoOpen,N=(0,Y.useCallback)(()=>{e.onJawCeoOpenChange?.(!1)},[e.onJawCeoOpenChange]),le=ce&&e.jawCeo&&e.jawCeoVoice?(0,X.jsx)(Ld,{open:!0,selectedPort:e.jawCeoSelectedPort??null,ceo:e.jawCeo,voice:e.jawCeoVoice,onClose:N,onOpenWorker:e.onJawCeoOpenWorker??(()=>{})}):null,ue=T&&o.state.bottomPanel.open,de=!!(e.notesModel.tagFilter&&e.notesSelectedPath&&e.notesSelectedNote&&!e.notesSelectedNote.tags?.includes(e.notesModel.tagFilter));(0,Y.useEffect)(()=>(sn(t=>{let n=e.instances.find(e=>e.port===t)??(e.selectedInstance?.port===t?e.selectedInstance:null);n&&e.onSelectInstance(n)}),()=>{sn(null)}),[e.instances,e.selectedInstance,e.onSelectInstance]);let P=o.dispatch,F=(0,Y.useCallback)(e=>{let t=qd(e.trim());t&&P({type:`OPEN_FILE_IN_FILES_TAB`,path:t})},[P]),pe=(0,Y.useCallback)((e,t)=>{let n=qd(t.trim());n&&o.dispatch({type:`SET_FILES_TAB_FILE`,tabId:e,path:n})},[o]),me=(0,Y.useCallback)((t,n)=>{_(e=>e[t]?{...e,[t]:null}:e),o.dispatch({type:`SET_FILES_TAB_ROOT`,tabId:t,path:n}),e.onDashboardSettingsPatch({rightFolderRootPath:n})},[o,e.onDashboardSettingsPatch]),he=(0,Y.useCallback)((e,t,n=`instance`)=>{o.dispatch({type:`SET_FILES_TAB_REPO_ROOT`,tabId:e,path:t,mode:n})},[o]),ge=(0,Y.useCallback)((e,t)=>{e&&o.dispatch({type:`SET_FILES_TAB_REPO_ROOT`,tabId:e,path:t,mode:`follow-instance`})},[o]),_e=(0,Y.useCallback)((e,t)=>{_(n=>({...n,[e]:t}))},[]),ve=(0,Y.useCallback)((e,t)=>{o.dispatch({type:`SET_BROWSER_TAB_STATE`,tabId:e,url:t.url,title:t.title})},[o]),ye=(0,Y.useCallback)(e=>{o.dispatch({type:`OPEN_BROWSER_MODULE_TAB`,url:e})},[o]),be=f?.id??null,xe=(0,Y.useCallback)(t=>{be&&o.dispatch({type:`SET_FILES_TAB_ROOT`,tabId:be,path:t}),e.onDashboardSettingsPatch({rightFolderRootPath:t})},[o,e.onDashboardSettingsPatch,be]),Se=Fu({onDroppedPaths:(0,Y.useCallback)(t=>{if(v(t),b(Nu(t)),t.source===`preview`)return;let n=ju(t.entries);if(n){o.dispatch({type:`OPEN_FOLDER_IN_FILES_TAB`,path:n.path}),e.onDashboardSettingsPatch({rightFolderRootPath:n.path});return}let r=Mu(t.entries);r&&F(r.path)},[o,e.onDashboardSettingsPatch])}),Ce=(0,Y.useCallback)(e=>{Se.resolveDroppedFiles(e,`preview`)},[Se]),I=e.selectedInstance?.projectDirs?.[0]?.trim()||null,L=(0,Y.useCallback)(()=>{I&&(o.dispatch({type:`OPEN_FOLDER_IN_FILES_TAB`,path:I}),e.onDashboardSettingsPatch({rightFolderRootPath:I}))},[o,I,e.onDashboardSettingsPatch]),R=hi({rightPanelOpen:ne,rightPanelWidth:o.state.rightPanel.width});return(0,Y.useEffect)(()=>{function e(e){e.detail===`resetSidebarWidth`&&R.reset()}return document.addEventListener(`jaw:shortcut-action`,e),()=>document.removeEventListener(`jaw:shortcut-action`,e)},[R.reset]),(0,X.jsxs)(Ha,{children:[e.jawCeoVoiceOverlay,(0,X.jsx)(xi,{navigatorLabel:e.viewMode===`code`&&e.sidebarMode===`instances`?`Code sessions`:void 0,sidebarCollapsed:a||e.sidebarCollapsed,sidebarWidth:R.width,onSidebarWidthDelta:R.addDelta,onSidebarWidthEnd:R.persist,onSidebarWidthReset:R.reset,inspectorCollapsed:e.activityDockCollapsed,inspectorHeight:e.activityDockCollapsed?48:e.activityDockHeight,drawerOpen:e.drawerOpen,onCloseDrawer:e.onCloseDrawer,rightPanelOpen:ne,rightPanelWidth:o.state.rightPanel.width,rightPanelContent:ne?(0,X.jsx)(Li,{onLoadProjectFolder:L,loadProjectFolderDisabled:!I||(f?.files?.folderRootPath??s)===I,renderPanel:(t,n)=>Jd(t,n,{activeTabId:u,primaryProjectDir:I,fallbackFolderRootPath:s,diffFilesTab:f,gitRefreshVersion:p,onOpenFileGlobal:F,onTabPreviewFile:pe,onTabRootChange:me,onTabRepoRootChange:he,onFollowInstanceRepoRoot:ge,onBrowserPageState:ve,onOpenBrowserWindow:ye,onInsertCommentIntoPreview:ie,onGitRefresh:h,selectedInstance:e.selectedInstance,dashboardSettingsUi:e.dashboardSettingsUi,onDashboardSettingsPatch:e.onDashboardSettingsPatch,notesModel:e.notesModel,folderSessions:g,onFolderSessionChange:_e})}):void 0,bottomPanelOpen:ue,bottomPanelHeight:o.state.bottomPanel.height,bottomPanelContent:o.state.bottomPanel.tabs.length>0?(0,X.jsx)(Vi,{renderTab:(t,n)=>Yd(t,n,e.selectedInstance?.port??null,ie)}):void 0,navigator:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ti,{onlineCount:e.onlineCount,collapsed:a||e.sidebarCollapsed,mode:e.sidebarMode,scheduleWorkspaceEnabled:e.scheduleWorkspaceEnabled,remindersWorkspaceEnabled:e.remindersWorkspaceEnabled,onModeChange:e.onSidebarModeChange,onToggleSidebar:e.onToggleSidebar,helpOpen:e.helpOpen,onToggleHelp:e.onToggleHelp}),!a&&(0,X.jsx)(Rd,{codeMode:e.viewMode===`code`,onChange:t=>{e.onViewModeChange(t?`code`:`jaw`),t&&e.sidebarMode!==`instances`&&e.onSidebarModeChange(`instances`)}}),(0,X.jsx)(`div`,{id:`manager-sidebar-list`,className:`manager-sidebar-list`,hidden:a,children:e.sidebarMode===`settings`?null:e.sidebarMode===`notes`?(0,X.jsx)(ao,{tree:e.notesModel.filteredTree,loading:e.notesModel.loading,error:e.notesModel.error,notesRoot:e.notesModel.notesRoot,selectedPath:e.notesSelectedPath,dirtyPath:e.notesDirtyPath,highlightedPath:e.notesHighlightedPath,externalFocusPath:e.notesSelectedPath,treeWidth:e.notesTreeWidth,mode:e.notesSidebarMode,searchFocusToken:e.notesSearchFocusToken,tagFilter:e.notesModel.tagFilter,selectedHiddenByFilter:de,onModeChange:e.onNotesSidebarModeChange,onOpenSearch:e.onOpenNotesSearch,onSelectedPathChange:e.onNotesSelectedPathChange,onRefreshTree:e.notesModel.refresh,onClearTagFilter:()=>e.notesModel.setTagFilter(null)}):e.sidebarMode===`board`?(0,X.jsx)(Nc,{view:e.boardView,onViewChange:e.onBoardViewChange,instances:e.instances,titlesByPort:e.titlesByPort,busyPorts:e.busyPorts}):e.scheduleWorkspaceEnabled&&e.sidebarMode===`schedule`?(0,X.jsx)($c,{activeGroup:e.scheduleGroup,onGroupChange:e.onScheduleGroupChange}):e.remindersWorkspaceEnabled&&e.sidebarMode===`reminders`?(0,X.jsx)(Bl,{view:x,onViewChange:S,items:C.items,loading:C.loading,onRefresh:()=>void C.refresh(),onUpdate:(e,t)=>void C.update(e,t)}):e.viewMode===`code`?(0,X.jsx)(`section`,{className:`code-manager-session-navigator`,"aria-label":`Code sessions`,children:(0,X.jsx)(`div`,{id:`code-session-sidebar-host`,className:`code-session-sidebar-host`})}):(0,X.jsx)(Gr,{active:e.selectedInstance,hiddenCount:e.instances.filter(e=>e.hidden).length,collapsed:e.sidebarCollapsed,query:e.query,onQueryChange:e.onQueryChange,onSelectPort:t=>{let n=e.instances.find(e=>e.port===t)??(e.selectedInstance?.port===t?e.selectedInstance:null);n&&e.onSelectInstance(n)},children:e.instanceListContent})})]}),workbench:(0,X.jsxs)(`div`,{className:`workspace-surface-stack`,children:[(0,X.jsx)(Vu,{active:e.sidebarMode===`notes`}),e.lifecycleMessage&&(0,X.jsxs)(`section`,{className:`state lifecycle-state`,role:`status`,children:[(0,X.jsx)(`span`,{children:e.lifecycleMessage}),(0,X.jsx)(`button`,{type:`button`,className:`state-dismiss`,"aria-label":`Dismiss lifecycle message`,onClick:e.onDismissLifecycleMessage,children:`X`})]}),y&&(0,X.jsxs)(`section`,{className:`state lifecycle-state`,role:`status`,children:[(0,X.jsx)(`span`,{children:y}),(0,X.jsx)(`button`,{type:`button`,className:`state-dismiss`,"aria-label":`Dismiss dropped file message`,onClick:()=>b(null),children:`X`})]}),M&&(0,X.jsxs)(`section`,{className:`state lifecycle-state`,role:`status`,children:[(0,X.jsx)(`span`,{children:M}),(0,X.jsx)(`button`,{type:`button`,className:`state-dismiss`,"aria-label":`Dismiss instance settings message`,onClick:()=>te(null),children:`X`})]}),(0,X.jsxs)(`div`,{className:`workspace-surface-layer`,children:[(0,X.jsx)(Kd,{active:e.sidebarMode===`instances`&&e.viewMode===`jaw`,children:(0,X.jsx)(ii,{mode:e.activeDetailTab,onModeChange:e.onDetailTabChange,header:e.workbenchHeader,modeActions:(0,X.jsxs)(X.Fragment,{children:[e.jawCeoWorkbenchButton,(0,X.jsx)(`button`,{type:`button`,className:`workbench-instance-settings-request`,"aria-label":`Instance settings`,title:`Open this instance's own settings page`,disabled:!e.selectedInstance?.ok,onClick:oe,children:`Settings`})]}),active:e.sidebarMode===`instances`&&e.viewMode===`jaw`,overview:e.detailContent(`overview`),preview:(0,X.jsx)(ha,{instance:e.selectedInstance,data:e.data,enabled:e.previewEnabled,active:e.sidebarMode===`instances`&&e.activeDetailTab===`preview`,refreshKey:e.previewRefreshKey,theme:e.previewTheme,...e.onOpenNotesFromPreview?{onOpenNotesFromPreview:e.onOpenNotesFromPreview}:{},onOpenDocFromPreview:F,onPreviewDroppedFiles:Ce,docPanelCapable:T,previewInsertTextRequest:E,onPreviewInsertTextResult:ae,previewSettingsOpenRequest:A,onPreviewSettingsOpenResult:se}),logs:e.detailContent(`logs`)})}),e.viewMode===`code`&&e.sidebarMode===`instances`?(0,X.jsx)(Kd,{active:!0,children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(`div`,{style:{padding:`24px`,color:`var(--text-dim)`,fontSize:`13px`},children:`Loading Code workspace...`}),children:(0,X.jsx)(Gd,{port:e.port,workingDir:re,onWorkingDirChange:xe,onOpenLocalFile:F,newSessionShortcut:e.codeNewSessionShortcut})})}):null,(0,X.jsx)(Kd,{active:e.sidebarMode===`notes`,children:(0,X.jsx)(Dc,{active:e.sidebarMode===`notes`,selectedPath:e.notesSelectedPath,selectedNote:e.notesSelectedNote,vaultIndex:e.notesModel.index,viewMode:e.notesViewMode,authoringMode:e.notesAuthoringMode,wordWrap:e.notesWordWrap,vimMode:e.notesVimMode,treeWidth:e.notesTreeWidth,notesGraphSettings:e.notesGraphSettings,tagFilter:e.notesModel.tagFilter,onOpenSidebarSearch:e.onOpenNotesSearch,onSelectedPathChange:e.onNotesSelectedPathChange,onDirtyPathChange:e.onNotesDirtyPathChange,onViewModeChange:e.onNotesViewModeChange,onAuthoringModeChange:e.onNotesAuthoringModeChange,onWordWrapChange:e.onNotesWordWrapChange,onVimModeChange:e.onNotesVimModeChange,onTreeWidthChange:e.onNotesTreeWidthChange,onNotesGraphSettingsChange:e.onNotesGraphSettingsChange,onTagSelect:e.notesModel.setTagFilter,onWikiLinkNavigate:e.onNotesSelectedPathChange})}),(0,X.jsx)(Kd,{active:e.sidebarMode===`settings`,children:e.sidebarMode===`settings`&&(0,X.jsx)(c,{...r,onBack:()=>e.onSidebarModeChange(`instances`),title:`Dashboard settings`,initialId:{display:`manager-display`,activity:`manager-activity`,developer:`manager-developer`,embedding:`manager-embedding`,telegramHub:`telegram-hub`}[e.settingsSection],manager:i,scopes:[`manager`],onDirtyChange:t,...e.onSettingsSaved?{onSaved:e.onSettingsSaved}:{}},n?.port??`manager-only`)}),(0,X.jsx)(Kd,{active:e.sidebarMode===`board`,children:(0,X.jsx)(Zc,{active:e.sidebarMode===`board`,view:e.boardView,onViewChange:e.onBoardViewChange,instances:e.instances,selectedPort:e.selectedInstance?.port??null,titlesByPort:e.titlesByPort,busyPorts:e.busyPorts,onOpenHelpTopic:e.onOpenHelpTopic})}),e.scheduleWorkspaceEnabled?(0,X.jsx)(Kd,{active:e.sidebarMode===`schedule`,children:(0,X.jsx)(ll,{active:e.sidebarMode===`schedule`,activeGroup:e.scheduleGroup,busyPorts:e.busyPorts,onOpenHelpTopic:e.onOpenHelpTopic})}):null,e.remindersWorkspaceEnabled?(0,X.jsx)(Kd,{active:e.sidebarMode===`reminders`,children:(0,X.jsx)(fu,{active:e.sidebarMode===`reminders`,view:x,feed:C,onRefresh:()=>void C.refresh(),onCreate:e=>void C.create(e).catch(()=>{}),onUpdate:(e,t)=>void C.update(e,t),onOpenHelpTopic:e.onOpenHelpTopic})}):null]})]}),inspector:(0,X.jsx)(Hr,{collapsed:e.activityDockCollapsed,height:e.activityDockHeight,loading:e.loading,error:e.error,lifecycleMessage:e.lifecycleMessage,selectedInstance:e.selectedInstance,registryMessage:e.registryMessage,events:e.managerEvents,onToggle:e.onToggleActivity,onHeightChange:e.onActivityHeightChange}),sidePanel:!w&&ce?le:void 0,mobileNav:(0,X.jsx)(Kr,{activeTab:e.activeDetailTab,onOpenInstances:e.onOpenDrawer,onSelectTab:e.onSelectTab,onToggleActivity:e.onToggleActivityFromMobile}),drawer:(0,X.jsx)(Wr,{open:e.drawerOpen,profileFilters:e.drawerProfileFilters,onClose:e.onCloseDrawer,children:e.instanceListContent})})]})}var Zd=5e3,Qd=1572864,$d=24,ef=`jaw.metricsPanelCollapsed`;async function tf(){let e=await fetch(`/api/dashboard/electron-metrics`);if(!e.ok)throw Error(`electron-metrics failed: ${e.status}`);return await e.json()}function nf(e){return e>=1048576?`${(e/1024/1024).toFixed(2)} GB`:`${(e/1024).toFixed(1)} MB`}function rf(e){return e.length>$d?`${e.slice(0,23)}…`:e}function af(){if(typeof localStorage>`u`)return!1;try{return localStorage.getItem(ef)===`true`}catch{return!1}}function of(e){if(!(typeof localStorage>`u`))try{localStorage.setItem(ef,e?`true`:`false`)}catch{}}function sf(e={}){let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(()=>af());if((0,Y.useEffect)(()=>{of(a)},[a]),(0,Y.useEffect)(()=>{let e=!1,t=null,r=async()=>{if(typeof document<`u`&&document.hidden){e||(t=setTimeout(r,Zd));return}try{let t=await tf();if(e)return;t.available?(n(!0),i(t.snapshot)):(n(!1),i(null))}catch{e||n(!1)}e||(t=setTimeout(r,Zd))};return r(),()=>{e=!0,t&&clearTimeout(t)}},[]),t!==!0)return null;if(!r)return(0,X.jsxs)(`div`,{className:`electron-metrics-panel electron-metrics-panel--empty`,"aria-label":`Electron process metrics`,children:[(0,X.jsx)(`div`,{className:`electron-metrics-header`,children:(0,X.jsx)(`span`,{className:`electron-metrics-title`,children:`Desktop metrics`})}),(0,X.jsx)(`div`,{className:`electron-metrics-empty`,children:`awaiting first sample…`})]});let s=[...r.processes].sort((e,t)=>t.rssKb-e.rssKb).slice(0,3),c=r.rssTotalKb>=Qd;return(0,X.jsxs)(`div`,{className:`electron-metrics-panel${c?` electron-metrics-panel--warn`:``}`,"aria-label":`Electron process metrics`,children:[(0,X.jsxs)(`div`,{className:`electron-metrics-header`,children:[(0,X.jsx)(`span`,{className:`electron-metrics-title`,children:`Desktop metrics`}),(0,X.jsx)(`button`,{type:`button`,className:`electron-metrics-toggle`,onClick:()=>o(e=>!e),"aria-expanded":!a,"aria-label":a?`Expand metrics panel`:`Collapse metrics panel`,children:a?`▸`:`▾`})]}),!a&&(0,X.jsxs)(`div`,{className:`electron-metrics-body`,children:[c&&(0,X.jsxs)(`div`,{className:`electron-metrics-warn`,children:[(0,X.jsxs)(`span`,{role:`alert`,children:[`Electron RSS total exceeds `,nf(1572864),`.`]}),e.onUnloadPreview&&(0,X.jsx)(`button`,{type:`button`,className:`electron-metrics-unload-btn`,onClick:()=>e.onUnloadPreview?.(),children:`Unload preview`})]}),(0,X.jsxs)(`div`,{className:`electron-metrics-row`,children:[(0,X.jsx)(`span`,{children:`renderers`}),(0,X.jsx)(`span`,{children:r.rendererCount})]}),(0,X.jsxs)(`div`,{className:`electron-metrics-row`,children:[(0,X.jsx)(`span`,{children:`processes`}),(0,X.jsx)(`span`,{children:r.processes.length})]}),(0,X.jsxs)(`div`,{className:`electron-metrics-row`,children:[(0,X.jsx)(`span`,{children:`RSS total`}),(0,X.jsx)(`span`,{children:nf(r.rssTotalKb)})]}),(0,X.jsx)(`div`,{className:`electron-metrics-divider`,"aria-hidden":`true`}),(0,X.jsx)(`div`,{className:`electron-metrics-subtitle`,children:`top by RSS`}),(0,X.jsx)(`ul`,{className:`electron-metrics-list`,children:s.map(e=>(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`span`,{className:`electron-metrics-proc`,children:rf(e.name?`${e.type} · ${e.name}`:e.type)}),(0,X.jsx)(`span`,{className:`electron-metrics-proc-rss`,children:nf(e.rssKb)})]},e.pid))})]})]})}var cf=new Set([`notes`,`instances`]);function lf(e){let t=e;return t?.type===`dashboard.invalidate`&&Array.isArray(t.topics)&&t.topics.every(e=>cf.has(e))}function uf(){return(0,Y.useEffect)(()=>{function e(e){lf(e.data)&&Z({...e.data,source:`iframe`})}return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[]),null}var df=3e4;function ff(){let e=(0,Y.useRef)(Date.now());return(0,Y.useEffect)(()=>{function t(){document.visibilityState===`visible`&&(Date.now()-e.current<df||(e.current=Date.now(),Z({topics:[`notes`,`instances`],reason:`visibility:tab-returned`,source:`visibility`})))}return document.addEventListener(`visibilitychange`,t),()=>document.removeEventListener(`visibilitychange`,t)},[]),null}var pf=new Set([`schedule`]),mf={BASE_URL:`/dist/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_CLI_JAW_EXPERIMENTAL_DASHBOARD===`1`;function hf(e){return pf.has(e)}function gf(e){return e===`schedule`&&mf||e===`reminders`?e:hf(e)?`instances`:e}function _f(){return N()?.window?.getFullscreenState?.()===!0}function vf(){return(0,Y.useEffect)(()=>{let e=document.documentElement,t=t=>{t?e.dataset.windowFullscreen=`true`:delete e.dataset.windowFullscreen};t(_f());let n=N()?.window?.onFullscreenStateChange?.(t);return()=>{n?.(),delete e.dataset.windowFullscreen}},[]),_f()}function yf(e,t){if(e===`toggleInstanceSettings`){t.toggleInstanceSettings();return}if(_e.dispatch(e))return;let n=qt(e);if(n!=null){let e=document.getElementById(`manager-sidebar-list`);if(!e)return;let t=rn(e)[n];t!=null&&cn()?.(t);return}if(e===`focusInstances`){t.handleSidebarModeChange(`instances`),t.setDrawerOpen(!1);return}if(e===`focusActiveSession`){let e=t.selectedInstance?.ok?t.selectedInstance:t.filtered.find(e=>e.ok)||null;e?t.handlePreview(e):t.handleSidebarModeChange(`instances`);return}if(e===`focusNotes`){t.handleSidebarModeChange(`notes`),t.setDrawerOpen(!1);return}if(e===`previousInstance`){t.selectRelativeInstance(-1);return}if(e===`nextInstance`){t.selectRelativeInstance(1);return}if(e===`closeFocusedTab`){let e=document.activeElement;e?.closest(`.browser-webview-stack, .browser-tab-strip`)?document.dispatchEvent(new CustomEvent(`jaw:shortcut-action`,{detail:`closeBrowserTab`})):e?.closest(`.terminal-panel, .xterm`)?document.dispatchEvent(new CustomEvent(`jaw:shortcut-action`,{detail:`closeTerminalTab`})):e?.closest(`.bottom-panel`)?_e.dispatch(`closeActiveBottomTab`):e?.closest(`.right-panel`)&&_e.dispatch(`toggleRightPanel`);return}if(e===`switchTab1`){t.handleTabChange(`overview`);return}if(e===`switchTab2`){t.handleTabChange(`preview`);return}if(e===`switchTab3`){t.handleTabChange(`logs`);return}if(e===`previousTab`||e===`nextTab`){let n=[`overview`,`preview`,`logs`],r=n.indexOf(t.activeDetailTab),i=e===`nextTab`?1:-1;t.handleTabChange(n[(r+i+n.length)%n.length]);return}if(e===`browserReload`||e===`browserHardReload`||e===`browserFocusUrl`||e===`browserBack`||e===`browserForward`){let n=document.activeElement;if(n?.closest(`.browser-webview-stack, .browser-tab-strip, .browser-panel`)){document.dispatchEvent(new CustomEvent(`jaw:shortcut-action`,{detail:e}));return}(e===`browserReload`||e===`browserHardReload`)&&(n?.closest(`.preview-panel`)?t.setPreviewRefreshKey(e=>e+1):e===`browserReload`?N()?.reloadWindow?.():N()?.hardReloadWindow?.());return}if(e===`terminalClear`){document.dispatchEvent(new CustomEvent(`jaw:shortcut-action`,{detail:e}));return}if(e===`newCodeSession`){document.dispatchEvent(new CustomEvent(`jaw:shortcut-action`,{detail:e}));return}if(e===`terminalNewTab`){document.activeElement?.closest(`.terminal-panel, .xterm`)?document.dispatchEvent(new CustomEvent(`jaw:shortcut-action`,{detail:e})):_e.dispatch(`newTerminalSession`);return}if(e===`toggleLeftSidebar`){t.handleSidebarToggle();return}if(e===`resetSidebarWidth`){document.dispatchEvent(new CustomEvent(`jaw:shortcut-action`,{detail:`resetSidebarWidth`}));return}}var bf=new Set([`toggleInstanceSettings`,`toggleLeftSidebar`,`toggleRightPanel`,`resetSidebarWidth`]);function xf(e,t,n={}){return r=>{if(r.defaultPrevented)return;let i=r.target;if(i instanceof Element&&i.closest(`[data-keybinding-capture]`))return;let a=Ce(r,e(),n);a&&bf.has(a)&&(r.preventDefault(),r.stopPropagation(),t(a))}}function Sf(e){return vf(),(0,Y.useEffect)(()=>{if(!e.view.dashboardShortcutsEnabled)return;let t=xf(()=>e.view.dashboardShortcutKeymap,e.onShortcutAction);return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[e.view.dashboardShortcutsEnabled,e.view.dashboardShortcutKeymap,e.onShortcutAction]),(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(uf,{}),(0,X.jsx)(ff,{}),(0,X.jsx)(ge,{initialPanelState:e.panelInitialState,onStateChange:e.onPanelStateChange,children:(0,X.jsx)(vr,{sidebarCollapsed:e.view.sidebarCollapsed,commandBar:(0,X.jsx)(or,{query:e.query,loading:e.loading,onQueryChange:e.setQuery,onRefresh:()=>void e.load(),onOpenDrawer:()=>e.view.setDrawerOpen(!0),theme:e.theme.theme,onThemeChange:e.theme.setTheme,onOpenPalette:e.palette.toggle}),workspace:(0,X.jsx)(Xd,{sidebarCollapsed:e.view.sidebarCollapsed,activityDockCollapsed:e.view.activityDockCollapsed,activityDockHeight:e.view.activityDockHeight,drawerOpen:e.view.drawerOpen,onCloseDrawer:()=>e.view.setDrawerOpen(!1),onlineCount:e.summary.online||0,sidebarMode:e.view.sidebarMode,scheduleWorkspaceEnabled:mf,remindersWorkspaceEnabled:!0,onSidebarModeChange:e.handleSidebarModeChange,onToggleSidebar:e.handleSidebarToggle,helpOpen:e.helpOpen,onToggleHelp:()=>{e.setHelpTopic(null),e.setHelpOpen(e=>!e)},onOpenHelpTopic:e.onOpenHelpTopic,settingsSection:e.settingsSection,locale:e.view.locale,onSettingsSectionChange:e.setDashboardSettingsSection,notesModel:e.notesModel,notesSelectedPath:e.view.notesSelectedPath,notesSelectedNote:e.notesSelectedNote,notesDirtyPath:e.notesDirtyPath,notesHighlightedPath:e.notesHighlightedPath,notesTreeWidth:e.view.notesTreeWidth,notesGraphSettings:e.view.notesGraphSettings,notesSidebarMode:e.notesSidebarMode,notesSearchFocusToken:e.notesSearchFocusToken,notesViewMode:e.view.notesViewMode,notesAuthoringMode:e.view.notesAuthoringMode,notesWordWrap:e.view.notesWordWrap,notesVimMode:e.view.notesVimMode,onNotesSidebarModeChange:e.setNotesSidebarMode,onOpenNotesSearch:e.openNotesSidebarSearch,onNotesSelectedPathChange:e.handleNotesSelectedPathChange,onNotesDirtyPathChange:e.setNotesDirtyPath,onNotesViewModeChange:e.handleNotesViewModeChange,onNotesAuthoringModeChange:e.handleNotesAuthoringModeChange,onNotesWordWrapChange:e.handleNotesWordWrapChange,onNotesVimModeChange:e.handleNotesVimModeChange,onNotesTreeWidthChange:e.handleNotesTreeWidthChange,onNotesGraphSettingsChange:e.handleNotesGraphSettingsChange,boardView:e.boardView,onBoardViewChange:e.setBoardView,scheduleGroup:e.scheduleGroup,onScheduleGroupChange:e.setScheduleGroup,instances:e.instances,selectedInstance:e.selectedInstance,data:e.data,titlesByPort:e.titlesByPort,busyPorts:e.busyPorts,activeDetailTab:e.view.activeDetailTab,onDetailTabChange:e.handleTabChange,workbenchHeader:(0,X.jsx)(fr,{instance:e.selectedInstance,previewEnabled:e.previewEnabled,onPreviewEnabledChange:e.setPreviewEnabled,onPreviewRefresh:e.onRefreshPreview,onOpenHelpTopic:e.onOpenHelpTopic,onPickProject:e.onPickProject,projectPickBusy:e.projectPickBusy}),onSettingsDirtyChange:e.onSettingsDirtyChange,detailContent:e.detailContent,previewEnabled:e.previewEnabled,previewRefreshKey:e.previewRefreshKey,previewTheme:e.theme.resolved,onOpenNotesFromPreview:e.openNotesFromPreview,lifecycleMessage:e.lifecycleMessage,onDismissLifecycleMessage:e.onDismissLifecycleMessage,instanceListContent:e.instanceListContent,loading:e.loading,jawCeoWorkbenchButton:e.jawCeoWorkbenchButton,jawCeoVoiceOverlay:e.jawCeoVoiceOverlay,jawCeo:e.jawCeo,jawCeoVoice:e.jawCeoVoice,jawCeoOpen:e.jawCeoOpen,jawCeoSelectedPort:e.jawCeoSelectedPort,onJawCeoOpenChange:e.onJawCeoOpenChange,onJawCeoOpenWorker:e.onJawCeoOpenWorker,error:e.error,registryMessage:e.registryMessage,managerEvents:e.activityEvents,onToggleActivity:e.handleActivityToggle,onActivityHeightChange:e.handleActivityHeight,onOpenDrawer:()=>e.view.setDrawerOpen(!0),onSelectTab:e.handleTabChange,onToggleActivityFromMobile:e.activityUnreadOpenAndMarkSeen,drawerProfileFilters:e.drawerProfileFilters,dashboardSettingsUi:e.dashboardSettingsUi,titleSupport:e.titleSupport,onDashboardSettingsPatch:e.handleDashboardSettingsPatch,viewMode:e.view.viewMode,onViewModeChange:e.view.setViewMode,port:Number(window.location.port)||3457,workingDir:e.view.rightFolderRootPath||``,codeNewSessionShortcut:Se(e.view.dashboardShortcutKeymap).newCodeSession,query:e.query,onQueryChange:e.setQuery,onSelectInstance:e.handleSelectInstance}),activityHeight:e.view.activityDockCollapsed?48:e.view.activityDockHeight})}),(0,X.jsx)(_r,{open:e.palette.open,onClose:e.palette.close,instances:e.instances,getLabel:cr,onSelectInstance:e.handleSelectInstance,theme:e.theme.theme,onCycleTheme:e.cycleTheme,onRefresh:()=>void e.load(),onToggleHidden:()=>{let t=!e.showHidden;e.setShowHidden(t),e.load(t)},showHidden:e.showHidden,onOpenSelected:e.openSelectedInBrowser,selectedInstance:e.selectedInstance}),(0,X.jsx)(sf,{onUnloadPreview:()=>e.setPreviewEnabled(!1)}),(0,X.jsx)(Ar,{open:e.helpOpen,topic:e.helpTopic??e.view.sidebarMode,onClose:()=>e.setHelpOpen(!1)}),e.autoUnloadNotice&&(0,X.jsxs)(`div`,{className:`preview-auto-unload-notice`,role:`status`,children:[`Preview was unloaded after 5 minutes of inactivity. Toggle the preview switch to re-enable.`,(0,X.jsx)(`button`,{type:`button`,className:`preview-auto-unload-dismiss`,"aria-label":`Dismiss preview auto-unload notice`,onClick:()=>e.setAutoUnloadNotice(!1),children:`x`})]})]})}function Cf(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;let t=e.tagName.toLowerCase();return t===`input`||t===`textarea`||t===`select`||!!e.closest(`[contenteditable="true"], .cm-editor, .ProseMirror, [data-milkdown-root]`)}var wf=`jaw.previewEnabled`;function Tf(){if(typeof localStorage>`u`)return!1;try{let e=localStorage.getItem(wf);return e!==null&&e===`true`}catch{return!1}}function Ef(e){if(!(typeof localStorage>`u`))try{localStorage.setItem(wf,e?`true`:`false`)}catch{}}var Df=3e5;function Of(e){let{onUnload:t,idleMs:n,doc:r,setTimeout:i,clearTimeout:a,now:o}=e,s=null,c=null,l=!1,u=()=>{l||(l=!0,t())},d=()=>{c=o(),s=i(()=>{s=null,u()},n)},f=()=>{s!==null&&(a(s),s=null)},p=()=>{if(l)return;if(r.hidden){c===null&&d();return}let e=c===null?0:o()-c;f(),c=null,e>=n&&u()};return r.hidden&&d(),r.addEventListener(`visibilitychange`,p),r.addEventListener(`resume`,p),()=>{r.removeEventListener(`visibilitychange`,p),r.removeEventListener(`resume`,p),f()}}function kf(e){let{enabled:t,onUnload:n,idleMs:r=Df}=e,i=(0,Y.useRef)(n);i.current=n,(0,Y.useEffect)(()=>{if(t&&!(typeof document>`u`))return Of({onUnload:()=>i.current(),idleMs:r,doc:document,setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),now:()=>Date.now()})},[t,r])}function Af(e){let t={ready:0,legacy:0,offline:0,byPort:e};for(let n of Object.values(e))t[n]+=1;return t}function jf(e,t){return{selectedPort:e.selectedPort,selectedTab:e.activeDetailTab,instanceSettingsOpen:!1,sidebarCollapsed:e.sidebarCollapsed,activityDockCollapsed:e.activityDockCollapsed,activityDockHeight:e.activityDockHeight,activitySeenAt:null,activitySeenByPort:{},uiTheme:t,locale:e.locale,sidebarMode:e.sidebarMode,notesSelectedPath:e.notesSelectedPath,notesViewMode:e.notesViewMode,notesAuthoringMode:e.notesAuthoringMode,notesWordWrap:e.notesWordWrap,notesVimMode:e.notesVimMode,notesTreeWidth:e.notesTreeWidth,notesGraphSettings:e.notesGraphSettings??vt(yt),showLatestActivityTitles:e.showLatestActivityTitles,showInlineLabelEditor:e.showInlineLabelEditor,showSidebarRuntimeLine:e.showSidebarRuntimeLine,showSelectedRowActions:e.showSelectedRowActions,dashboardShortcutsEnabled:e.dashboardShortcutsEnabled,dashboardShortcutKeymap:e.dashboardShortcutKeymap,diffRootPolicy:e.diffRootPolicy,diffPinnedRootByPort:e.diffPinnedRootByPort,diffRecentRepoRoots:e.diffRecentRepoRoots,diffDefaultMode:e.diffDefaultMode,diffBaseRef:e.diffBaseRef,diffIncludeUntracked:e.diffIncludeUntracked,rightFolderRootPath:e.rightFolderRootPath}}function Mf(e,t,n){let r=(0,Y.useRef)(t);r.current=t;let i=(0,Y.useRef)(void 0);(0,Y.useEffect)(()=>qa(e,()=>{clearTimeout(i.current),i.current=setTimeout(()=>r.current(),100)},n),[e,n])}var Nf=5e3;function Pf(e){let t=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{if(!e)return;let n=!1;async function r(){try{let e=await w();if(n)return;t.current!==null&&e!==t.current&&Z({topics:[`notes`],reason:`notes:external-change`,source:`visibility`,sourceId:`external-sync`}),t.current=e}catch{}}r();let i=setInterval(()=>{typeof document<`u`&&document.hidden||r()},Nf);return()=>{n=!0,clearInterval(i)}},[e])}function Ff(e){for(let t of e){if(t.kind===`file`)return t.path;let e=Ff(t.children||[]);if(e)return e}return null}function If(e,t){for(let n of e)if(n.kind===`file`&&n.path===t||If(n.children||[],t))return!0;return!1}function Lf(e,t){let n=[];for(let r of e){if(r.kind===`file`){t.has(r.path)&&n.push(r);continue}let e=Lf(r.children||[],t);e.length>0&&n.push({...r,children:e})}return n}function Rf(e){let[t,n]=(0,Y.useState)([]),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(null),p=(0,Y.useRef)(0),m=(0,Y.useRef)(e.selectedPath),h=(0,Y.useRef)(e.onSelectedPathChange);m.current=e.selectedPath,h.current=e.onSelectedPathChange,Pf(e.active),(0,Y.useEffect)(()=>{e.active&&!l&&k().then(e=>u(e.root)).catch(()=>{})},[e.active,l]);let g=(0,Y.useCallback)(async(e=m.current)=>{let t=p.current+1;p.current=t,o(!0),c(null);try{let[r,a]=await Promise.all([T(),j()]);if(t!==p.current)return;n(r),i(a);let o=e&&If(r,e)?e:Ff(r);o!==m.current&&h.current(o)}catch(e){t===p.current&&c(e.message)}finally{t===p.current&&o(!1)}},[]);return Mf(`notes`,()=>{e.active&&g()},`notes-sidebar`),(0,Y.useEffect)(()=>{e.active&&g()},[e.active,g]),{tree:t,filteredTree:(0,Y.useMemo)(()=>{if(!d||!r)return t;let e=new Set;for(let t of r.notes)t.tags&&t.tags.includes(d)&&e.add(t.path);return e.size===0?[]:Lf(t,e)},[d,t,r]),index:r,loading:a,error:s,notesRoot:l,tagFilter:d,setTagFilter:f,refresh:g}}var zf=new Set([`instances`,`board`,`schedule`,`reminders`,`notes`,`settings`]);function Bf(e){let t=new URLSearchParams(e).get(`sidebar`);return zf.has(t)?t:null}function Vf(e){return new URLSearchParams(e).get(`tray`)===`1`}function Hf(e){let t=new URLSearchParams(e).get(`port`);if(t===null||!/^\d{1,5}$/.test(t))return null;let n=Number(t);return n>=1&&n<=65535?n:null}var Uf=/^([01]\d|2[0-3]):([0-5]\d)$/;function Wf(e){return String(e).padStart(2,`0`)}function Gf(e){let t=new Date(e);return t.setHours(t.getHours()+1,0,0,0),t.getDate()===e.getDate()?`${Wf(t.getHours())}:00`:`23:59`}function Kf(e,t){let n=Uf.exec(t??``);if(!n)return null;let r=new Date(e);return r.setHours(Number(n[1]),Number(n[2]),0,0),r}function qf(e,t){let n=e.title.trim();if(!n)return{ok:!1,error:`Enter a reminder title.`};let r={title:n,status:`open`,priority:e.mode===`important`||e.mode===`important-urgent`?`high`:`normal`};if(e.mode!==`important-urgent`&&e.mode!==`urgent`)return{ok:!0,input:r};let i=Kf(Jf(t),e.timeValue);if(!i)return{ok:!1,error:`Pick a valid time.`};let a=i.toISOString();return{ok:!0,input:{...r,dueAt:a,remindAt:a}}}function Jf(e){return new Date(e.getTime())}var Yf={overdue:`Overdue`,priority:`Priority`,today:`Today`},Xf=[{id:`important-urgent`,label:`ImpUrg`},{id:`important`,label:`Imp`},{id:`urgent`,label:`Urg`},{id:`later`,label:`Later`}];function Zf(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString([],{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function Qf(e){let t=[e.priority],n=Zf(e.dueAt),r=Zf(e.remindAt);return n&&t.push(`due ${n}`),r&&t.push(`remind ${r}`),t.join(` / `)}function $f(){let e=N()?.trayReminders;if(e?.openDashboard){e.openDashboard();return}window.location.assign(`/?sidebar=reminders`)}function ep(e){let t=new Date;return e===`later-today`?(t.setHours(t.getHours()+3,0,0,0),t.toISOString()):e===`tomorrow`?(t.setDate(t.getDate()+1),t.setHours(9,0,0,0),t.toISOString()):e===`next-week`?(t.setDate(t.getDate()+7),t.setHours(9,0,0,0),t.toISOString()):null}function tp(e){return(0,X.jsxs)(`li`,{className:`tray-reminders-row`,"data-section":e.section,"data-priority":e.item.priority,children:[(0,X.jsxs)(`span`,{className:`tray-reminders-row-main`,children:[(0,X.jsx)(`b`,{children:e.item.title}),(0,X.jsx)(`small`,{children:Qf(e.item)})]}),(0,X.jsxs)(`span`,{className:`tray-reminders-row-actions`,children:[e.item.priority===`high`?(0,X.jsx)(`span`,{className:`tray-reminders-priority-pill`,children:`High`}):null,(0,X.jsx)(`button`,{type:`button`,"aria-label":`Mark done`,onClick:()=>e.onMarkDone(e.item.id),disabled:e.busy,children:`Done`}),(0,X.jsxs)(`select`,{"aria-label":`Snooze reminder`,value:``,disabled:e.busy,onChange:t=>{let n=ep(t.target.value);t.currentTarget.value=``,n&&e.onSnooze(e.item.id,n)},children:[(0,X.jsx)(`option`,{value:``,disabled:!0,children:`Snooze`}),(0,X.jsx)(`option`,{value:`later-today`,children:`Later today`}),(0,X.jsx)(`option`,{value:`tomorrow`,children:`Tomorrow`}),(0,X.jsx)(`option`,{value:`next-week`,children:`Next week`})]})]})]})}function np(e){return(0,X.jsxs)(`section`,{className:`tray-reminders-section`,"data-section":e.id,children:[(0,X.jsxs)(`header`,{children:[(0,X.jsx)(`h2`,{children:Yf[e.id]}),(0,X.jsx)(`span`,{children:e.items.length})]}),(0,X.jsxs)(`ol`,{children:[e.items.map(t=>(0,X.jsx)(tp,{item:t,section:e.id,busy:e.busy,onMarkDone:e.onMarkDone,onSnooze:e.onSnooze},t.id)),e.items.length===0?(0,X.jsx)(`li`,{className:`tray-reminders-empty-row`,children:`No reminders`}):null]})]})}function rp(e){let t=(0,Y.useMemo)(()=>new Date,[]),n=(0,Y.useRef)(null),[r,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(`later`),[s,c]=(0,Y.useState)(Gf(t)),[l,u]=(0,Y.useState)(null),d={title:r,mode:a,timeValue:s},f=qf(d,new Date).ok&&!e.busy,p=async()=>{let t=qf(d,new Date);if(!t.ok){u(t.error);return}u(null);try{await e.onCreate(t.input),i(``),n.current?.focus()}catch(e){u(e.message)}};return(0,X.jsxs)(`section`,{className:`tray-reminders-composer`,"aria-label":`Add reminder`,children:[(0,X.jsx)(`div`,{className:`tray-reminders-composer-modes`,role:`group`,"aria-label":`Quick add mode`,children:Xf.map(e=>(0,X.jsx)(`button`,{type:`button`,"aria-pressed":a===e.id,onClick:()=>{o(e.id),u(null)},children:e.label},e.id))}),(0,X.jsxs)(`form`,{className:`tray-reminders-composer-form`,onSubmit:e=>{e.preventDefault(),p()},children:[(0,X.jsx)(`input`,{ref:n,"aria-label":`Reminder title`,placeholder:`Add reminder...`,value:r,onChange:e=>{i(e.target.value),u(null)},onKeyDown:e=>{e.key===`Escape`&&(r||l)&&(e.preventDefault(),i(``),u(null))}}),(0,X.jsx)(`button`,{type:`submit`,disabled:!f,children:`Add`})]}),(0,X.jsx)(`div`,{className:`tray-reminders-composer-date-row`,"data-mode":a,children:a===`important-urgent`||a===`urgent`?(0,X.jsxs)(`label`,{children:[(0,X.jsx)(`span`,{children:`Due`}),(0,X.jsx)(`input`,{"aria-label":`Urgent reminder time`,type:`time`,value:s,onChange:e=>c(e.target.value)})]}):(0,X.jsx)(`span`,{"aria-hidden":`true`})}),l?(0,X.jsx)(`p`,{className:`tray-reminders-composer-error`,children:l}):null]})}function ip(){let e=Su({active:!0,pollWhileActiveMs:3e4}),t=(0,Y.useMemo)(()=>new Date,[e.items]),n=(0,Y.useMemo)(()=>kl(e.items,t),[e.items,t]),r=Math.max(0,n.badgeCount-n.overdue.length),i=n.overdue.length>0||n.priority.length>0||n.today.length>0,a=t=>{e.markDone(t).then(()=>e.refresh())},o=(t,n)=>{e.snooze(t,n).then(()=>e.refresh())};return(0,X.jsxs)(`main`,{className:`tray-reminders-app`,"aria-label":`Tray reminders`,children:[(0,X.jsxs)(`header`,{className:`tray-reminders-header`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`b`,{children:`Reminders`}),(0,X.jsxs)(`small`,{children:[`overdue `,n.overdue.length,` / today `,r]})]}),(0,X.jsx)(`button`,{type:`button`,className:`tray-reminders-menu-button`,"aria-label":`Open tray menu`,onClick:()=>N()?.trayReminders?.popUpMenu(),children:`...`})]}),e.error?(0,X.jsx)(`p`,{className:`tray-reminders-status`,"data-state":`error`,children:e.error}):null,e.loading&&e.items.length===0?(0,X.jsx)(`p`,{className:`tray-reminders-status`,children:`Loading reminders`}):null,!e.loading&&!e.error&&!i?(0,X.jsx)(`p`,{className:`tray-reminders-empty`,children:`No urgent reminders`}):null,(0,X.jsxs)(`div`,{className:`tray-reminders-sections`,children:[(0,X.jsx)(np,{id:`overdue`,items:n.overdue,busy:e.loading,onMarkDone:a,onSnooze:o}),(0,X.jsx)(np,{id:`priority`,items:n.priority,busy:e.loading,onMarkDone:a,onSnooze:o}),(0,X.jsx)(np,{id:`today`,items:n.today,busy:e.loading,onMarkDone:a,onSnooze:o})]}),(0,X.jsx)(rp,{busy:e.loading,onCreate:t=>e.create(t).then(()=>e.refresh())}),(0,X.jsxs)(`footer`,{className:`tray-reminders-footer`,children:[(0,X.jsxs)(`span`,{children:[n.upcomingCount,` upcoming`]}),(0,X.jsx)(`button`,{type:`button`,onClick:$f,children:`Open Dashboard`})]})]})}function ap(){let[e,t]=(0,Y.useState)(null),[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(null),c=(0,Y.useCallback)(e=>(t(e.registry),r(e.status),s(e.status.error),e),[]);return{registry:e,status:n,saving:i,error:o,apply:c,refresh:(0,Y.useCallback)(async()=>{try{return c(await ie())}catch(e){throw s(e.message),e}},[c]),save:(0,Y.useCallback)(async e=>{a(!0);try{return c(await se(e))}catch(e){return s(e.message),null}finally{a(!1)}},[c])}}function op(){let[e,t]=(0,Y.useState)(null),[n,r]=(0,Y.useState)(`overview`),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(150),[f,p]=(0,Y.useState)(`instances`),[m,h]=(0,Y.useState)(`jaw`),[g,_]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(`raw`),[b,x]=(0,Y.useState)(`plain`),[S,C]=(0,Y.useState)(!0),[w,T]=(0,Y.useState)(!1),[E,D]=(0,Y.useState)(280),[O,k]=(0,Y.useState)(void 0),[A,ee]=(0,Y.useState)(!0),[j,M]=(0,Y.useState)(!0),[te,ne]=(0,Y.useState)(!0),[re,ie]=(0,Y.useState)(!0),[ae,oe]=(0,Y.useState)(!0),[se,ce]=(0,Y.useState)({...I}),[N,le]=(0,Y.useState)(`project-first`),[ue,de]=(0,Y.useState)({}),[fe,P]=(0,Y.useState)([]),[F,pe]=(0,Y.useState)(`unstaged`),[me,he]=(0,Y.useState)(`HEAD`),[ge,_e]=(0,Y.useState)(!0),[ve,ye]=(0,Y.useState)(null),[be,xe]=(0,Y.useState)(`ko`);function Ce(e){ce(Se(e))}return{selectedPort:e,setSelectedPort:t,activeDetailTab:n,setActiveDetailTab:r,drawerOpen:i,setDrawerOpen:a,sidebarCollapsed:o,setSidebarCollapsed:s,activityDockCollapsed:c,setActivityDockCollapsed:l,activityDockHeight:u,setActivityDockHeight:d,sidebarMode:f,setSidebarMode:p,viewMode:m,setViewMode:h,notesSelectedPath:g,setNotesSelectedPath:_,notesViewMode:v,setNotesViewMode:y,notesAuthoringMode:b,setNotesAuthoringMode:x,notesWordWrap:S,setNotesWordWrap:C,notesVimMode:w,setNotesVimMode:T,notesTreeWidth:E,setNotesTreeWidth:D,notesGraphSettings:O,setNotesGraphSettings:k,showLatestActivityTitles:A,setShowLatestActivityTitles:ee,showInlineLabelEditor:j,setShowInlineLabelEditor:M,showSidebarRuntimeLine:te,setShowSidebarRuntimeLine:ne,showSelectedRowActions:re,setShowSelectedRowActions:ie,dashboardShortcutsEnabled:ae,setDashboardShortcutsEnabled:oe,dashboardShortcutKeymap:se,setDashboardShortcutKeymap:Ce,diffRootPolicy:N,setDiffRootPolicy:le,diffPinnedRootByPort:ue,setDiffPinnedRootByPort:de,diffRecentRepoRoots:fe,setDiffRecentRepoRoots:P,diffDefaultMode:F,setDiffDefaultMode:pe,diffBaseRef:me,setDiffBaseRef:he,diffIncludeUntracked:ge,setDiffIncludeUntracked:_e,rightFolderRootPath:ve,setRightFolderRootPath:ye,locale:be,setLocale:xe}}function sp(e){let t=e.selectedTab===`settings`||e.instanceSettingsOpen===!0;return{selectedTab:e.selectedTab===`settings`?`overview`:e.selectedTab,sidebarMode:t?`settings`:e.sidebarMode}}function cp(e){let{view:t,selectedPort:n}=e;function r(){return!e.settingsDirty||(e.confirmDiscard??(()=>window.confirm(`Discard unsaved Settings changes?`)))()}function i(r){let i=r.selectedPort!==void 0&&r.selectedPort!==n,a=t.sidebarMode===`settings`&&(r.sidebarMode??t.sidebarMode)!==`settings`;return i||a?e.dashboardSettingsDirty&&!(e.confirmDiscard??(()=>window.confirm(`Discard unsaved Settings changes?`)))()?!1:(e.clearDirty(`dashboard`),!0):!0}function a(n){let r=n?`settings`:`instances`;t.sidebarMode!==r&&i({sidebarMode:r})&&(n&&(t.setViewMode(`jaw`),t.setDrawerOpen(!1)),t.setSidebarMode(r),e.saveUi({sidebarMode:r,selectedTab:t.activeDetailTab===`settings`?`overview`:t.activeDetailTab}))}return{canLeaveDirtySettings:r,guardSettingsTransition:i,setDashboardSettingsOpen:a}}function lp(e,t,n){return{...e,[t]:n}}function up(){let[e,t]=(0,Y.useState)({dashboard:!1}),n=(0,Y.useCallback)((e,n)=>{t(t=>lp(t,e,n))},[]),r=(0,Y.useCallback)(e=>{t({dashboard:e})},[]);return{settingsDirty:e.dashboard,dashboardSettingsDirty:e.dashboard,setSettingsDirty:r,onSettingsDirtyChange:n}}function dp(e){return e.kind===`instance-message`&&e.role===`assistant`}function fp(e){if(e.kind===`instance-message`)return[e.kind,e.port,e.messageId].join(`|`);let t=`port`in e?String(e.port):``,n=`message`in e?e.message:`reason`in e&&typeof e.reason==`string`?e.reason:``;return[e.kind,t,e.at,n].join(`|`)}function pp(e){return e.reduce((e,t)=>e?Date.parse(t.at)>Date.parse(e)?t.at:e:t.at,null)}function mp(e,t){return pp(e.filter(e=>`port`in e&&e.port===t))}function hp(e,t,n={},r=null){let i=new Set,a={};for(let t of e){if(!(`port`in t)||r!=null&&t.port===r||!dp(t))continue;let e=n[t.port]||null;if(e&&Date.parse(t.at)<=Date.parse(e))continue;let o=fp(t);i.has(o)||(i.add(o),a[t.port]=(a[t.port]||0)+1)}return a}function gp(e){let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)({}),a=(0,Y.useMemo)(()=>hp(e.events,t,r,e.activePreviewPort),[e.events,t,r,e.activePreviewPort]);function o(e,t){n(e),i(Object.fromEntries(Object.entries(t).map(([e,t])=>[Number(e),t])))}function s(t){let n=mp(e.events,t);if(!n)return;let a=r[t]||null;if(a&&Date.parse(n)<=Date.parse(a))return;let o={...r,[t]:n};i(o),e.saveUi({activitySeenByPort:Object.fromEntries(Object.entries(o).map(([e,t])=>[String(e),t]))})}function c(){let t=pp(e.events),a={...r};for(let t of e.events){if(!(`port`in t))continue;let e=a[t.port];(!e||Date.parse(t.at)>Date.parse(e))&&(a[t.port]=t.at)}n(t),i(a),e.setActivityDockCollapsed(!1),e.saveUi({activityDockCollapsed:!1,activitySeenAt:t,activitySeenByPort:Object.fromEntries(Object.entries(a).map(([e,t])=>[String(e),t]))})}function l(){e.setActivityDockCollapsed(!0),e.saveUi({activityDockCollapsed:!0,activitySeenAt:t,activitySeenByPort:Object.fromEntries(Object.entries(r).map(([e,t])=>[String(e),t]))})}return{unreadByPort:a,hydrateSeenAt:o,markPortSeen:s,openAndMarkSeen:c,closeAndPersistSeen:l}}var _p=[`auto`,`dark`,`light`];function vp(e){return typeof e==`string`&&_p.includes(e)}function yp(){if(typeof document>`u`)return`auto`;let e=document.documentElement.getAttribute(`data-theme`);return vp(e)?e:`auto`}var bp=`jaw.uiTheme`;function xp(e){if(!(typeof document>`u`)){document.documentElement.setAttribute(`data-theme`,e);try{typeof localStorage<`u`&&localStorage.setItem(bp,e)}catch{}}}function Sp(e){let[t,n]=(0,Y.useState)(yp),[r,i]=(0,Y.useState)(()=>Cp(t));return(0,Y.useEffect)(()=>{xp(t),i(Cp(t))},[t]),(0,Y.useEffect)(()=>{if(t!==`auto`||typeof window>`u`||!window.matchMedia)return;let e=window.matchMedia(`(prefers-color-scheme: light)`),n=()=>i(e.matches?`light`:`dark`);return typeof e.addEventListener==`function`?(e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)):(e.addListener(n),()=>e.removeListener(n))},[t]),{theme:t,resolved:r,setTheme:(0,Y.useCallback)(t=>{vp(t)&&(n(t),xp(t),i(Cp(t)),e(t))},[e]),syncFromRegistry:(0,Y.useCallback)(e=>{vp(e)&&(n(e),xp(e),i(Cp(e)))},[])}}function Cp(e){return e===`dark`?`dark`:e===`light`||typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: light)`).matches?`light`:`dark`}function wp(e,t=ye()){return e.key!==`k`&&e.key!==`K`?!1:ve(t)?e.metaKey:e.ctrlKey}function Tp(){let[e,t]=(0,Y.useState)(!1),n=(0,Y.useCallback)(()=>t(e=>!e),[]),r=(0,Y.useCallback)(()=>t(!1),[]);return(0,Y.useEffect)(()=>{function e(e){wp(e)&&(e.preventDefault(),t(e=>!e))}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),{open:e,setOpen:t,toggle:n,close:r}}function Ep(e,t){let[n,r]=(0,Y.useState)(null);return{error:n,saveInstanceLabel:(0,Y.useCallback)(async(n,i)=>{let a=i?.trim()||null;if(!await e({instances:{[String(n)]:{label:a}}})){let e=`instance label save failed`;throw r(e),Error(e)}r(null),t(e=>e&&{...e,instances:e.instances.map(e=>e.port===n?{...e,label:a}:e)})},[e,t])}}var Dp=5e3,Op=200;function kp(e){if(!e)return null;if(`latestAssistant`in e){let t=e.latestAssistant,n=e.activity;return!t||!n||n.role!==`assistant`||n.messageId!==t.id?null:t}return e.role===`assistant`&&Number.isInteger(e.id)?e:null}function Ap(e){return!e||!(`activity`in e)?null:e.activity?.title||null}function jp(e){return e&&(`activity`in e||`latestAssistant`in e)?`ready`:`legacy`}function Mp(e){return!e||typeof e!=`object`?!1:`processBusy`in e&&e.processBusy===!0}async function Np(e){let t=await fetch(`/i/${e}/api/messages/latest?includeContent=1`);if(!t.ok)return{latest:null,title:null,support:`offline`,busy:!1};let n=await t.json();return{latest:kp(n.data),title:Ap(n.data),support:jp(n.data),busy:Mp(n.data)}}function Pp(e){let[t,n]=(0,Y.useState)([]),[r,i]=(0,Y.useState)({}),[a,o]=(0,Y.useState)({}),[s,c]=(0,Y.useState)(new Set),l=(0,Y.useRef)({}),u=(0,Y.useMemo)(()=>e.filter(e=>e.ok).map(e=>e.port).sort((e,t)=>e-t),[e]),d=u.join(`,`),f=(0,Y.useMemo)(()=>e.map(e=>`${e.port}:${e.ok?`online`:`offline`}`).sort().join(`,`),[e]);return(0,Y.useEffect)(()=>{let t=!1,r=null;async function a(){if(t)return;let r=new Set(e.map(e=>e.port)),a={};for(let t of e)t.ok||(a[t.port]=`offline`);if(u.length===0){o(a),i(e=>Object.fromEntries(Object.entries(e).filter(([e])=>r.has(Number(e)))));return}let s=await Promise.allSettled(u.map(async e=>({port:e,...await Np(e)}))),d=[],f={},p=new Set;for(let e of s){if(e.status!==`fulfilled`)continue;let{port:t,latest:n,title:r,support:i,busy:o}=e.value;if(o&&p.add(t),a[t]=i,r&&(f[t]=r),!n)continue;let s=l.current[t];l.current[t]=n.id,!(s==null||n.id<=s)&&d.push({kind:`instance-message`,port:t,messageId:n.id,role:n.role,at:n.created_at&&!Number.isNaN(Date.parse(n.created_at))?n.created_at:new Date().toISOString(),...r?{title:r}:{}})}if(!t){for(let e of u)a[e]||(a[e]=`offline`);o(a),c(p),i(e=>{let t={};for(let[n,i]of Object.entries(e)){let e=Number(n);r.has(e)&&a[e]===`ready`&&(t[e]=i)}return{...t,...f}}),d.length>0&&n(e=>{let t=[...e,...d];return t.length>Op&&t.splice(0,t.length-Op),t})}}function s(){r||=setInterval(()=>{a()},Dp)}function d(){r&&clearInterval(r),r=null}function f(){document.visibilityState===`visible`?(a(),s()):d()}return a(),s(),document.addEventListener(`visibilitychange`,f),()=>{t=!0,d(),document.removeEventListener(`visibilitychange`,f)}},[d,f]),{events:t,titlesByPort:r,titleSupportByPort:a,busyPorts:s}}var Fp=1e4,Ip=200;function Lp(){let[e,t]=(0,Y.useState)([]),[n,r]=(0,Y.useState)(null),i=(0,Y.useRef)(null);async function a(){try{let e=await te(i.current);if(r(null),e.length===0)return;i.current=e[e.length-1].at,t(t=>{let n=[...t,...e];return n.length>Ip&&n.splice(0,n.length-Ip),n})}catch(e){r(e.message)}}return(0,Y.useEffect)(()=>{let e=!1,t=null;async function n(){e||await a()}function r(){t||=setInterval(()=>{n()},Fp)}function i(){t&&clearInterval(t),t=null}function o(){document.visibilityState===`visible`?(n(),r()):i()}return n(),r(),document.addEventListener(`visibilitychange`,o),()=>{e=!0,i(),document.removeEventListener(`visibilitychange`,o)}},[]),{events:e,error:n,refresh:a}}function Rp(e){let t=(0,Y.useRef)(e);t.current=e,(0,Y.useEffect)(()=>{let e=null,n=()=>{e?.close(),e=null},r=()=>{e||document.hidden||(e=new EventSource(`/api/manager/events/stream`),e.onmessage=e=>{let n;try{n=JSON.parse(String(e.data))}catch{return}if(n.topic!==`worker`||n.event!==`worker_settings_change`)return;let r=n.data?.port;typeof r==`number`&&Number.isInteger(r)&&t.current(r)})},i=()=>{if(document.hidden){n();return}r()};return r(),document.addEventListener(`visibilitychange`,i),()=>{document.removeEventListener(`visibilitychange`,i),n()}},[])}function zp(e,t){let[n,r]=(0,Y.useState)(null);async function i(i){if(n==null){r(i);try{(await b(i)).cancelled||await e(i)}catch(e){t(e.message)}finally{r(null)}}}return{busyPort:n,pick:i}}function Bp(e){if(e===window.location.origin)return!0;try{let t=new URL(e).hostname;return t===`localhost`||t===`127.0.0.1`||t===`::1`||t===`[::1]`}catch{return!1}}function Vp(e){(0,Y.useEffect)(()=>{function t(t){let n=t.data;n?.type===`jaw-preview-stt-recording`&&n.action===`request`&&Bp(t.origin)&&(e.status===`active`||e.status===`silent`||e.status===`paused`||e.status===`connecting`)&&e.end()}return window.addEventListener(`message`,t),()=>window.removeEventListener(`message`,t)},[e.status,e.end])}function Hp(e){(0,Y.useEffect)(()=>{function t(t){if(!e.enabled)return;let n=t.data;if(!n||n.type!==`jaw-preview-shortcut`)return;let r={key:n.key,code:n.code,altKey:!!n.altKey,ctrlKey:!!n.ctrlKey,metaKey:!!n.metaKey,shiftKey:!!n.shiftKey},i=Ce(r,e.keymap,{menuOwned:e.menuOwned===!0});i&&e.onAction(i)}return window.addEventListener(`message`,t),()=>window.removeEventListener(`message`,t)},[e])}function Up(e){return e===`connecting`?`Connecting voice`:e===`silent`?`Listening`:`Voice active`}function Wp(e){if(e.status!==`connecting`&&e.status!==`active`&&e.status!==`silent`)return null;let t=Up(e.status),n=e.selectedPort==null?`Dashboard`:`Worker :${e.selectedPort}`;return(0,X.jsx)(`div`,{className:`jaw-ceo-voice-overlay status-${e.status}`,role:`status`,"aria-live":`polite`,children:(0,X.jsxs)(`div`,{className:`jaw-ceo-voice-overlay-card`,children:[(0,X.jsxs)(`div`,{className:`jaw-ceo-voice-wave`,"aria-hidden":`true`,children:[(0,X.jsx)(`span`,{}),(0,X.jsx)(`span`,{}),(0,X.jsx)(`span`,{})]}),(0,X.jsxs)(`div`,{className:`jaw-ceo-voice-overlay-copy`,children:[(0,X.jsx)(`strong`,{children:t}),(0,X.jsx)(`span`,{children:e.status===`silent`?`No speech detected. Session is still open.`:n}),e.lastTranscript?(0,X.jsx)(`small`,{children:e.lastTranscript}):e.lastEventType?(0,X.jsx)(`small`,{children:e.lastEventType}):null]}),(0,X.jsx)(`button`,{type:`button`,className:`jaw-ceo-voice-stop`,"aria-label":`Stop Jaw CEO voice`,onClick:e.onStop,children:`Stop`})]})})}function Gp(e,t,n){for(e.add(t);e.size>n;){let t=e.values().next();if(t.done)return;e.delete(t.value)}}var Kp=5e3;function qp(){return new Date().toISOString()}function Jp(e){return{session:{sessionId:`pending`,inputMode:`text`,responseMode:`text`,selectedPort:e,openedAt:qp(),lastUserActivityAt:qp(),voiceArmed:!1,frontendPresence:`visible`,autoRead:!1},transcript:[],watches:[],pending:[],auditTail:[],voice:{status:`idle`,sessionId:null,model:`gpt-realtime-2`,voice:`marin`,error:null}}}function Yp(e,t){let n=Jp(t);return{...n,...e,session:{...n.session,...e.session??{},selectedPort:e.session?.selectedPort??t},transcript:Array.isArray(e.transcript)?e.transcript:[],watches:Array.isArray(e.watches)?e.watches:[],pending:Array.isArray(e.pending)?e.pending:[],auditTail:Array.isArray(e.auditTail)?e.auditTail:[],voice:{...n.voice,...e.voice??{}}}}function Xp(e){return e.kind===`instance-completed`?`${e.kind}:${e.port}:${e.requestId||``}:${e.messageId||``}:${e.at}`:`${e.kind}:${e.port}:${e.messageId}:${e.role}:${e.at}`}function Zp(e){return e.kind===`instance-message`?{kind:`instance-message`,port:e.port,messageId:e.messageId,role:e.role,at:e.at}:null}var Qp=2e3;function $p(e){let[t,n]=(0,Y.useState)(()=>Jp(e.selectedPort)),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(null),l=(0,Y.useRef)(new Set),u=(0,Y.useRef)(t);(0,Y.useEffect)(()=>{u.current=t},[t]);let d=(0,Y.useCallback)(async()=>{i(e=>e||`refresh`);try{let t=Yp(await Zu(),e.selectedPort),r=Array.from(new Set(t.watches.map(e=>e.port)));r.length>0&&await td({ports:r});let i=Yp(await Zu(),e.selectedPort);n(i),o(null)}catch(e){o(e.message)}finally{i(e=>e===`refresh`?null:e)}},[e.selectedPort]);(0,Y.useEffect)(()=>{if(!e.documentVisible)return;let t=!1,n=null;async function r(){t||await d()}return r(),n=setInterval(()=>{r()},Kp),()=>{t=!0,n&&clearInterval(n)}},[e.documentVisible,d]),(0,Y.useEffect)(()=>{let t=[];for(let n of e.managerEvents){let e=Zp(n);if(!e)continue;let r=Xp(e);l.current.has(r)||(Gp(l.current,r,Qp),t.push(e))}t.length!==0&&(async()=>{try{await td({events:t}),await d()}catch(e){o(e.message)}})()},[e.managerEvents,d]);let f=(0,Y.useCallback)(async(t,n=`text`)=>{i(`message`);try{let r=await ed({text:t,responseMode:n,selectedPort:e.selectedPort,...u.current.session.sessionId===`pending`?{}:{sessionId:u.current.session.sessionId}}),i=r.data?.response||r.error?.message||r.message||`Jaw CEO message completed.`;return c(i),await d(),r}catch(e){let t=e.message;throw o(t),e}finally{i(null)}},[e.selectedPort,d]),p=(0,Y.useCallback)(async e=>{i(`ack:${e}`);try{await id(e,`ack`),await d()}finally{i(null)}},[d]),m=(0,Y.useCallback)(async e=>{i(`dismiss:${e}`);try{await id(e,`dismiss`),await d()}finally{i(null)}},[d]);return{state:t,pending:t.pending,audit:t.auditTail,busy:r!==null,error:a,lastResponse:s,refresh:d,sendText:f,continueCompletion:nd,summarizeCompletion:rd,ackCompletion:p,dismissCompletion:m}}var em={start:[523.25,659.25],silent:[392],stop:[659.25,392],error:[220,196]};function tm(e){let t=window.AudioContext||window.webkitAudioContext;if(t)try{let n=new t,r=n.currentTime;em[e].forEach((t,i)=>{let a=n.createOscillator(),o=n.createGain(),s=r+i*.085;a.type=e===`silent`?`sine`:`triangle`,a.frequency.setValueAtTime(t,s),o.gain.setValueAtTime(1e-4,s),o.gain.exponentialRampToValueAtTime(e===`silent`?.015:.024,s+.012),o.gain.exponentialRampToValueAtTime(1e-4,s+.105),a.connect(o),o.connect(n.destination),a.start(s),a.stop(s+.12)}),window.setTimeout(()=>void n.close().catch(()=>void 0),420)}catch{}}async function nm(e){if(!navigator.mediaDevices?.getUserMedia)throw Error(`Microphone capture is not available in this browser.`);let t=new RTCPeerConnection,n=t.createDataChannel(`oai-events`);n.onmessage=t=>{try{e.onRealtimeEvent(JSON.parse(t.data))}catch{e.onRealtimeEvent({type:`raw`,text:String(t.data)})}};let r=new MediaStream,i=document.createElement(`audio`);i.autoplay=!0,i.setAttribute(`playsinline`,``),i.srcObject=r,i.className=`jaw-ceo-voice-audio`,i.setAttribute(`aria-hidden`,`true`),document.body.appendChild(i),t.ontrack=e=>{for(let t of e.streams[0]?.getTracks()||[e.track])r.getTracks().includes(t)||r.addTrack(t)};let a=await navigator.mediaDevices.getUserMedia({audio:{noiseSuppression:!0,echoCancellation:!0,autoGainControl:!0}});for(let e of a.getTracks())t.addTrack(e,a);let o=await t.createOffer();if(await t.setLocalDescription(o),!o.sdp)throw Error(`Browser did not create a voice SDP offer.`);let s=await ad({offerSdp:o.sdp,selectedPort:e.selectedPort,...e.sessionId?{sessionId:e.sessionId}:{},responseMode:`voice`});await t.setRemoteDescription({type:`answer`,sdp:s.answerSdp});function c(){n.close();for(let e of a.getTracks())e.stop();t.close(),i.remove()}function l(e){for(let t of a.getAudioTracks())t.enabled=e}return{sessionId:s.sessionId,peer:t,dataChannel:n,micStream:a,audio:i,setMicEnabled:l,close:c}}var rm=4e3,im=3e4;function am(e){if(!e||typeof e!=`object`)return null;let t=e,n=String(t.type||``);return typeof t.delta==`string`&&(n===`response.audio_transcript.delta`||n===`response.text.delta`||n===`response.output_text.delta`)?t.delta:typeof t.transcript==`string`?t.transcript:typeof t.text==`string`&&(n.includes(`transcript`)||n.includes(`text`))?t.text:typeof t.output==`string`?t.output:null}function om(e){return e===`response.audio_transcript.delta`||e===`response.text.delta`||e===`response.output_text.delta`}function sm(e){if(!e||typeof e!=`object`)return null;let t=e.type;return typeof t==`string`?t:null}function cm(e){let[t,n]=(0,Y.useState)(`idle`),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(null),l=(0,Y.useRef)(null),u=(0,Y.useRef)(e),d=(0,Y.useRef)(0),f=(0,Y.useRef)(Date.now()),p=(0,Y.useRef)(0),m=(0,Y.useRef)(``);(0,Y.useEffect)(()=>{u.current=e},[e]);function h(e,t){f.current=Date.now(),e&&o(e),t&&c(t.length>180?`${t.slice(0,177)}...`:t),n(e=>e===`silent`?`active`:e)}let g=(0,Y.useCallback)(async()=>{d.current+=1;let e=l.current;l.current=null,e&&(e.close(),await od(e.sessionId).catch(()=>void 0)),n(`sleeping`)},[]),_=(0,Y.useCallback)(async()=>{if(t===`connecting`&&!l.current){d.current+=1,tm(`stop`),n(`paused`);return}l.current?.setMicEnabled(!1),tm(`stop`),n(`paused`)},[t]),v=(0,Y.useCallback)(async()=>{await g(),tm(`stop`)},[g]),y=(0,Y.useCallback)(async()=>{if(l.current){l.current.setMicEnabled(!0),f.current=Date.now(),i(null),tm(`start`),n(`active`);return}if(t===`connecting`)return;let e=d.current+1;d.current=e,n(`connecting`),i(null),o(null),c(null),m.current=``,tm(`start`);try{let t=await nm({selectedPort:u.current.selectedPort,...u.current.sessionId?{sessionId:u.current.sessionId}:{},onRealtimeEvent:e=>{let t=sm(e),n=am(e),r=n&&om(t)?`${m.current}${n}`:n;n&&om(t)&&(m.current=r||``),t===`response.created`&&(m.current=``),h(t,r),r&&u.current.onTranscript(r)}});if(d.current!==e){t.close(),await od(t.sessionId).catch(()=>void 0);return}l.current=t,f.current=Date.now(),n(`active`)}catch(t){if(d.current!==e)return;i(t.message),tm(`error`),n(t.message.includes(`OPENAI_API_KEY`)?`disabled`:`error`),l.current?.close(),l.current=null}},[t]),b=(0,Y.useCallback)(async(e,t)=>{let n=e.trim();n&&await ed({text:n,selectedPort:u.current.selectedPort,...u.current.sessionId?{sessionId:u.current.sessionId}:{},inputMode:`voice`,responseMode:t})},[]),x=(0,Y.useCallback)(async e=>{await nd(e.completionKey,`voice`),u.current.onSpokenCompletion(e.completionKey)},[]);return(0,Y.useEffect)(()=>()=>{d.current+=1;let e=l.current;l.current=null,e&&(e.close(),od(e.sessionId).catch(()=>void 0))},[]),(0,Y.useEffect)(()=>{if(e.documentVisible)return;let t=l.current;t&&(d.current+=1,l.current=null,t.close(),od(t.sessionId).catch(()=>void 0),n(`sleeping`))},[e.documentVisible]),(0,Y.useEffect)(()=>{if(t!==`active`&&t!==`silent`)return;let e=window.setInterval(()=>{if(!l.current)return;let e=Date.now();e-f.current<rm||(n(`silent`),e-p.current>=im&&(tm(`silent`),p.current=e))},1e3);return()=>window.clearInterval(e)},[t]),e.autoRead,{status:t,error:r,lastEventType:a,lastTranscript:s,talk:y,stop:_,end:v,sendText:b,speakCompletion:x}}function lm(){let[e,t]=(0,Y.useState)(()=>typeof document>`u`||document.visibilityState===`visible`);return(0,Y.useEffect)(()=>{function e(){t(document.visibilityState===`visible`)}return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]),e}function um(e){let[t,n]=(0,Y.useState)(!1),r=lm(),i=(0,Y.useMemo)(()=>[...e.managerEvents,...e.messageEvents],[e.managerEvents,e.messageEvents]),a=$p({selectedPort:e.selectedPort,documentVisible:r,managerEvents:i}),o=a.state.session.sessionId===`pending`?null:a.state.session.sessionId,s=cm({selectedPort:e.selectedPort,...o?{sessionId:o}:{},autoRead:a.state.session.autoRead,documentVisible:r,onTranscript:()=>void 0,onSpokenCompletion:e=>{a.ackCompletion(e)}});return s.status===`active`||s.status===`connecting`||s.status,{ceo:a,voice:s,open:t,setOpen:n,workbenchButton:null,voiceOverlay:(0,X.jsx)(Wp,{status:s.status,selectedPort:e.selectedPort,lastEventType:s.lastEventType,lastTranscript:s.lastTranscript,onStop:()=>void s.stop()})}}function dm(e,t){if(e.length===0)return e;let n=new Set(t.map(e=>e.profileId)),r=e.filter(e=>n.has(e));return r.length===e.length?e:r}function fm(e){if(!e)return null;switch(e){case`folder`:case`doc`:case`ceo`:return`files`;case`diff`:return`diff`;case`browser`:return`browser`;default:return null}}function pm(e,t){return e===`diff`?`right-diff`:`right-${e}-${t??1}`}function mm(e,t){return e===`diff`?pe:`${P[e]} ${t??1}`}function hm(e){return e===`diff`?{id:pm(`diff`),kind:e,title:P.diff,specificName:pe}:{id:pm(e,1),kind:e,title:P[e],specificName:mm(e,1),ordinal:1}}function gm(e,t){let n={};for(let r of he){let i=e.filter(e=>e.kind===r).reduce((e,t)=>Math.max(e,t.ordinal??1),0),a=typeof t?.[r]==`number`&&Number.isFinite(t[r])?t[r]:0,o=Math.max(a,i+1);(o>1||i>0)&&(n[r]=o)}return n}function _m(e,t){let n=new Set,r=[],i=null;for(let a of[e,t]){let e=fm(a);e&&!n.has(e)&&(n.add(e),r.push(hm(e)),i||=e)}return{openTabs:r,activeTabId:i?r.find(e=>e.kind===i)?.id??null:null,nextOrdinalByKind:gm(r)}}function vm(e){if(!e||typeof e!=`object`)return;let t=e,n={};return typeof t.pageId==`string`&&t.pageId.length>0&&(n.pageId=t.pageId),typeof t.projectKey==`string`&&t.projectKey.length>0&&(n.projectKey=t.projectKey),typeof t.zoom==`number`&&Number.isFinite(t.zoom)&&t.zoom>0&&(n.zoom=t.zoom),Object.keys(n).length>0?n:void 0}function ym(e){if(!e||typeof e!=`object`)return;let t=e;if(typeof t.url==`string`&&t.url.length>0)return{url:t.url}}function bm(e){if(!e||typeof e!=`object`)return;let t=e,n={};return typeof t.activeFilePath==`string`&&t.activeFilePath.length>0&&(n.activeFilePath=t.activeFilePath),typeof t.folderRootPath==`string`&&t.folderRootPath.length>0&&(n.folderRootPath=t.folderRootPath),typeof t.repoRootPath==`string`&&t.repoRootPath.length>0&&(n.repoRootPath=t.repoRootPath),(t.repoRootMode===`instance`||t.repoRootMode===`manual`)&&(n.repoRootMode=t.repoRootMode),Object.keys(n).length>0?n:void 0}function xm(e){let t=/-(\d+)$/.exec(e);if(!t)return;let n=Number.parseInt(t[1],10);return Number.isFinite(n)&&n>0?n:void 0}function Sm(e){if(!e||typeof e.id!=`string`||e.id.length===0||typeof e.kind!=`string`||!de.includes(e.kind))return null;let t=e.kind,n=typeof e.ordinal==`number`&&Number.isFinite(e.ordinal)&&e.ordinal>0?Math.floor(e.ordinal):xm(e.id),r=typeof e.title==`string`&&e.title.length>0?e.title:P[t],i=typeof e.specificName==`string`&&e.specificName.length>0?e.specificName:mm(t,n),a=t===`files`?bm(e.files):void 0,o=t===`browser`?ym(e.browser):void 0,s=t===`design`?vm(e.design):void 0;return{id:e.id,kind:t,title:r,specificName:i,...typeof e.sourceLabel==`string`&&e.sourceLabel.length>0?{sourceLabel:e.sourceLabel}:{},...t!==`diff`&&n!==void 0?{ordinal:n}:{},...e.pinned===!0?{pinned:!0}:{},...a?{files:a}:{},...o?{browser:o}:{},...s?{design:s}:{}}}function Cm(e){if(e.rightSidebarOpenTabs){let t=e.rightSidebarOpenTabs,n=[],r=new Set,i=!1;for(let e of t){let t=Sm(e);if(t&&!r.has(t.id)){if(t.kind===`diff`){if(i)continue;i=!0}r.add(t.id),n.push(t)}}return{openTabs:n,activeTabId:typeof e.rightSidebarActiveTabId==`string`&&n.find(t=>t.id===e.rightSidebarActiveTabId)?e.rightSidebarActiveTabId:n[0]?.id??null,nextOrdinalByKind:gm(n,e.rightSidebarNextOrdinalByKind)}}return e.rightPanelTopMode!==void 0||e.rightPanelBottomMode!==void 0?_m(e.rightPanelTopMode,e.rightPanelBottomMode):{openTabs:[],activeTabId:null,nextOrdinalByKind:{}}}function wm(e){let t=e.fileFolderLayout;if(t&&typeof t==`object`){let e=typeof t.splitRatio==`number`&&Number.isFinite(t.splitRatio)?Math.max(0,Math.min(1,t.splitRatio)):ue,n=typeof t.lastSplitRatio==`number`&&Number.isFinite(t.lastSplitRatio)?Math.max(0,Math.min(1,t.lastSplitRatio)):ue;return{mode:t.mode===`split`||t.mode===`folder-only`||t.mode===`file-only`?t.mode:F(e),splitRatio:e,lastSplitRatio:n}}return{mode:`split`,splitRatio:ue,lastSplitRatio:ue}}function Tm(e){if(!e.panelLayoutVersion)return{};let t=Cm(e),n=wm(e);return{rightPanel:{open:e.rightPanelOpen??!1,width:e.rightPanelWidth??480,tabs:t,fileFolderLayout:n},bottomPanel:{open:e.bottomPanelOpen??!1,height:e.bottomPanelHeight??320,tabs:e.bottomPanelTabs??[],activeTab:e.bottomPanelActiveTab??null}}}function Em(e){return{panelLayoutVersion:2,rightPanelOpen:e.rightPanel.open,rightPanelWidth:e.rightPanel.width,rightSidebarOpenTabs:e.rightPanel.tabs.openTabs,rightSidebarActiveTabId:e.rightPanel.tabs.activeTabId,rightSidebarNextOrdinalByKind:e.rightPanel.tabs.nextOrdinalByKind,fileFolderLayout:e.rightPanel.fileFolderLayout,rightPanelTopMode:void 0,rightPanelBottomMode:void 0,rightPanelSplitRatio:void 0,rightSidebarLastActiveByKind:void 0,bottomPanelOpen:e.bottomPanel.open,bottomPanelHeight:e.bottomPanel.height,bottomPanelTabs:e.bottomPanel.tabs,bottomPanelActiveTab:e.bottomPanel.activeTab}}function Dm(){if(Vf(window.location.search))return(0,X.jsx)(ip,{});let[e,t]=(0,Y.useState)(null),[n,r]=(0,Y.useState)(!0),[i,a]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(`all`),[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(!1),[_,v]=(0,Y.useState)(void 0),[b,x]=(0,Y.useState)(null),[S,C]=(0,Y.useState)(null),[w,T]=(0,Y.useState)(null),[E,D]=(0,Y.useState)(null),[O,k]=(0,Y.useState)([]),{settingsDirty:A,dashboardSettingsDirty:j,setSettingsDirty:M,onSettingsDirtyChange:te}=up(),[ne,re]=(0,Y.useState)(null),[ie,ae]=(0,Y.useState)(`files`),[oe,se]=(0,Y.useState)(0),[ce,le]=(0,Y.useState)(`display`),[ue,de]=(0,Y.useState)({kind:`overall`}),[fe,P]=(0,Y.useState)(`today`),[F,pe]=(0,Y.useState)(()=>Tf()),[me,he]=(0,Y.useState)(0),[ge,_e]=(0,Y.useState)(!1),[ve,ye]=(0,Y.useState)(!1),[xe,Se]=(0,Y.useState)(null),I=(0,Y.useCallback)(e=>{Se(e),ye(!0)},[]);(0,Y.useEffect)(()=>{Ef(F)},[F]),kf({enabled:F,onUnload:()=>{pe(!1),_e(!0)}}),(0,Y.useEffect)(()=>{if(!ge||typeof document>`u`||document.hidden)return;let e=setTimeout(()=>_e(!1),8e3);return()=>clearTimeout(e)},[ge]);let L=ap(),R=op(),we=Sp(e=>{m&&L.save({ui:{uiTheme:e}})}),Te=Tp(),Ee=Lp(),z=e?.instances||[],De=Pp(z),Oe=Ep(L.save,t),ke=(0,Y.useMemo)(()=>e?.manager.profiles||[],[e]),B=(0,Y.useMemo)(()=>{let e=new Set(ke.map(e=>e.profileId));return O.filter(t=>e.has(t))},[O,ke]),V=(0,Y.useMemo)(()=>{let e=o.trim().toLowerCase();return z.filter(t=>c!==`all`&&t.status!==c||B.length>0&&(!t.profileId||!B.includes(t.profileId))?!1:!e||[String(t.port),t.url,cr(t),t.version,t.workingDir,t.currentCli,t.currentModel,t.healthReason,t.label,t.group,t.profileId].some(t=>String(t||``).toLowerCase().includes(e)))},[B,z,o,c]),H=(0,Y.useMemo)(()=>R.selectedPort==null?V.find(e=>e.ok)||null:z.find(e=>e.port===R.selectedPort)||null,[V,z,R.selectedPort]),Ae=H?.port??R.selectedPort??null,U=um({selectedPort:Ae,managerEvents:Ee.events,messageEvents:De.events,onOpenWorker:We});Vp(U.voice),Hp({enabled:R.dashboardShortcutsEnabled,keymap:R.dashboardShortcutKeymap,menuOwned:N()!=null,onAction:pt});let W=R.activeDetailTab===`preview`&&R.sidebarMode===`instances`?H?.port??null:null,je=(0,Y.useMemo)(()=>[...Ee.events,...De.events],[Ee.events,De.events]),G=gp({events:je,activityDockCollapsed:R.activityDockCollapsed,setActivityDockCollapsed:R.setActivityDockCollapsed,saveUi:q,activePreviewPort:W});function K(){let e=[`auto`,`light`,`dark`],t=e[(e.indexOf(we.theme)+1)%e.length];we.setTheme(t)}function Me(){H&&window.open(H.url,`_blank`,`noopener,noreferrer`)}(0,Y.useEffect)(()=>{document.documentElement.lang=R.locale},[R.locale]),(0,Y.useEffect)(()=>{function e(e){e.key!==`?`||e.metaKey||e.ctrlKey||e.altKey||Cf(e.target)||(e.preventDefault(),I(`shortcuts`))}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[I]);async function Ne(e=f,n=!1){r(!0),a(null);try{let r=await ee(e,{fresh:n}),i=dm(O,r.manager.profiles||[]);i!==O&&(k(i),L.save({activeProfileFilter:i})),t(r)}catch(e){a(e.message)}finally{r(!1)}}async function Pe(e){let n=await y(e);n&&t(t=>t&&{...t,instances:t.instances.map(t=>t.port===e?n:t)})}Mf(`instances`,()=>void Ne(),`app`),Rp(e=>{Pe(e),Z({topics:[`instances`],reason:`instance:settings-change`,source:`ui`,sourceId:`app`})});let Fe=zp(async e=>{await Pe(e),Z({topics:[`instances`],reason:`instance:project-picked`,source:`ui`,sourceId:`app`})},e=>C(`Project pick failed: ${e}`));(0,Y.useEffect)(()=>{async function e(){try{let e=await L.refresh(),t=e.registry.ui,n=sp(t);R.setSelectedPort(t.selectedPort),R.setActiveDetailTab(n.selectedTab),R.setSidebarCollapsed(t.sidebarCollapsed);let r=Hf(window.location.search);r!==null&&R.setSelectedPort(r),R.setActivityDockCollapsed(t.activityDockCollapsed),R.setActivityDockHeight(t.activityDockHeight);let i=gf(Bf(window.location.search)??n.sidebarMode);R.setSidebarMode(i),i!==t.sidebarMode&&q({sidebarMode:i}),R.setNotesSelectedPath(t.notesSelectedPath),R.setNotesViewMode(t.notesViewMode),R.setNotesAuthoringMode(t.notesAuthoringMode??`plain`),R.setNotesWordWrap(t.notesWordWrap),R.setNotesVimMode(t.notesVimMode),R.setNotesTreeWidth(t.notesTreeWidth),R.setNotesGraphSettings(t.notesGraphSettings),R.setShowLatestActivityTitles(t.showLatestActivityTitles),R.setShowInlineLabelEditor(t.showInlineLabelEditor),R.setShowSidebarRuntimeLine(t.showSidebarRuntimeLine),R.setShowSelectedRowActions(t.showSelectedRowActions),R.setDashboardShortcutsEnabled(t.dashboardShortcutsEnabled),R.setDashboardShortcutKeymap(t.dashboardShortcutKeymap),R.setDiffRootPolicy(t.diffRootPolicy),R.setDiffPinnedRootByPort(t.diffPinnedRootByPort),R.setDiffRecentRepoRoots(t.diffRecentRepoRoots),R.setDiffDefaultMode(t.diffDefaultMode),R.setDiffBaseRef(t.diffBaseRef),R.setDiffIncludeUntracked(t.diffIncludeUntracked),R.setRightFolderRootPath(t.rightFolderRootPath),R.setLocale(t.locale),G.hydrateSeenAt(t.activitySeenAt??null,t.activitySeenByPort||{}),k(e.registry.activeProfileFilter||[]),we.syncFromRegistry(t.uiTheme),v(Tm(t))}finally{h(!0),await Ne()}}e()},[]);async function q(e){m&&e!==void 0&&await L.save({ui:e})}function Ie(e){q(Em(e))}let Le=(0,Y.useMemo)(()=>z.reduce((e,t)=>(t.profileId&&(e[t.profileId]=(e[t.profileId]||0)+1),e),{}),[z]),Re=(0,Y.useMemo)(()=>z.reduce((e,t)=>(e.total+=1,e[t.status]=(e[t.status]||0)+1,e),{total:0}),[z]);function ze(e){let t=O.includes(e)?O.filter(t=>t!==e):[...O,e];k(t),L.save({activeProfileFilter:t})}let{canLeaveDirtySettings:Be,guardSettingsTransition:Ve,setDashboardSettingsOpen:He}=cp({view:R,settingsDirty:A,dashboardSettingsDirty:j,clearDirty:e=>te(e,!1),saveUi:q,selectedPort:H?.port??null});function Ue(e,t=!1){(e.port===H?.port||Be())&&(t&&(pe(!0),_e(!1),he(e=>e+1)),e.port!==H?.port&&M(!1),G.markPortSeen(e.port),R.setSelectedPort(e.port),R.setActiveDetailTab(`preview`),R.setActivityDockCollapsed(!0),R.setDrawerOpen(!1),q({selectedPort:e.port,selectedTab:`preview`,activityDockCollapsed:!0}))}function We(e){let t=z.find(t=>t.port===e);t&&Ue(t)}function Ge(e){(e.port===H?.port||Be())&&(e.port!==H?.port&&M(!1),G.markPortSeen(e.port),R.setSelectedPort(e.port),R.setDrawerOpen(!1),q({selectedPort:e.port}))}function J(e){if(e===`settings`){He(!0);return}if(R.activeDetailTab===`preview`&&e!==`preview`){let e=R.selectedPort;e!=null&&G.markPortSeen(e)}if(R.setActiveDetailTab(e),e===`preview`){let t=R.selectedPort;t!=null&&G.markPortSeen(t),R.setActivityDockCollapsed(!0),q({selectedTab:e,activityDockCollapsed:!0});return}q({selectedTab:e})}function Ke(){let e=!R.sidebarCollapsed;R.setSidebarCollapsed(e),q({sidebarCollapsed:e})}function qe(){if(R.activityDockCollapsed){G.openAndMarkSeen();return}G.closeAndPersistSeen()}function Je(e){R.setActivityDockHeight(e),q({activityDockHeight:e})}function Ye(e){let t=gf(e);if(Ve({sidebarMode:t})){if(R.sidebarMode===`instances`&&e!==`instances`&&R.activeDetailTab===`preview`){let e=R.selectedPort;e!=null&&G.markPortSeen(e)}R.setSidebarMode(t),q({sidebarMode:t})}}function Xe(e){R.setNotesSelectedPath(e),q({notesSelectedPath:e})}let[Ze,Qe]=(0,Y.useState)(null),$e=(0,Y.useRef)(null);function et(e){Qe(e),$e.current&&clearTimeout($e.current),$e.current=setTimeout(()=>Qe(null),2500)}function tt(e){let t=e.trim();t&&(R.sidebarMode!==`notes`&&Ye(`notes`),Xe(t),et(t))}(0,Y.useEffect)(()=>()=>{$e.current&&clearTimeout($e.current)},[]);function nt(){ae(`search`),se(e=>e+1)}function rt(e){R.setNotesViewMode(e),q({notesViewMode:e})}function it(e){R.setNotesAuthoringMode(e),q({notesAuthoringMode:e})}function at(e){R.setNotesWordWrap(e),q({notesWordWrap:e})}function ot(e){R.setNotesVimMode(e),q({notesVimMode:e})}function st(e){R.setNotesTreeWidth(e),q({notesTreeWidth:e})}function ct(e){R.setNotesGraphSettings(e),q({notesGraphSettings:e})}let lt=Rf({active:R.sidebarMode===`notes`,selectedPath:R.notesSelectedPath,onSelectedPathChange:Xe}),ut=R.notesSelectedPath?lt.index?.notes.find(e=>e.path===R.notesSelectedPath)??null:null;function dt(e){e.showLatestActivityTitles!==void 0&&R.setShowLatestActivityTitles(e.showLatestActivityTitles),e.showInlineLabelEditor!==void 0&&R.setShowInlineLabelEditor(e.showInlineLabelEditor),e.showSidebarRuntimeLine!==void 0&&R.setShowSidebarRuntimeLine(e.showSidebarRuntimeLine),e.showSelectedRowActions!==void 0&&R.setShowSelectedRowActions(e.showSelectedRowActions),e.dashboardShortcutsEnabled!==void 0&&R.setDashboardShortcutsEnabled(e.dashboardShortcutsEnabled),e.dashboardShortcutKeymap!==void 0&&R.setDashboardShortcutKeymap(e.dashboardShortcutKeymap),e.diffRootPolicy!==void 0&&R.setDiffRootPolicy(e.diffRootPolicy),e.diffPinnedRootByPort!==void 0&&R.setDiffPinnedRootByPort(e.diffPinnedRootByPort),e.diffRecentRepoRoots!==void 0&&R.setDiffRecentRepoRoots(e.diffRecentRepoRoots),e.diffDefaultMode!==void 0&&R.setDiffDefaultMode(e.diffDefaultMode),e.diffBaseRef!==void 0&&R.setDiffBaseRef(e.diffBaseRef),e.diffIncludeUntracked!==void 0&&R.setDiffIncludeUntracked(e.diffIncludeUntracked),e.rightFolderRootPath!==void 0&&R.setRightFolderRootPath(e.rightFolderRootPath),e.locale!==void 0&&R.setLocale(e.locale),q(e)}function ft(e){if(V.length===0)return;let t=H?.port??null,n=t==null?-1:V.findIndex(e=>e.port===t),r=((n>=0?n:e>0?-1:0)+e+V.length)%V.length,i=V[r];i&&Ge(i)}function pt(e){yf(e,{selectedInstance:H,filtered:V,activeDetailTab:R.activeDetailTab,setDrawerOpen:R.setDrawerOpen,handleSidebarModeChange:Ye,handlePreview:Ue,selectRelativeInstance:ft,handleTabChange:J,setPreviewRefreshKey:he,handleSidebarToggle:Ke,toggleInstanceSettings:()=>He(R.sidebarMode!==`settings`)})}(0,Y.useEffect)(()=>{if(R.dashboardShortcutsEnabled)return N()?.shortcuts?.onAction?.(e=>{pt(e)})},[V,H,R.dashboardShortcutsEnabled,R.sidebarMode,R.activeDetailTab,A,j]),(0,Y.useEffect)(()=>{function e(e){if((e.ctrlKey||e.metaKey)&&e.key===`f`){let t=document.querySelector(`.preview-frame`);if(t?.contentWindow){e.preventDefault(),t.contentWindow.postMessage({type:`jaw-preview-search`},`*`);return}}if(!R.dashboardShortcutsEnabled||be(e.target))return;let t=Ce(e,R.dashboardShortcutKeymap,{menuOwned:N()!=null});t&&(e.preventDefault(),pt(t))}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[V,H,R.dashboardShortcutsEnabled,R.dashboardShortcutKeymap,R.sidebarMode,R.activeDetailTab,A,j]);async function mt(e,n){let r=n.lifecycle;if(!r||e===`perm`&&!window.confirm(`Register :${n.port} as a persistent system service? It will auto-start on login and auto-restart on crash.`)||e===`unperm`&&!window.confirm(`Remove persistent service for :${n.port}? The instance will stop and won't auto-start.`))return;if(e===`stop`&&r.owner===`service`){if(!window.confirm(`Stop :${n.port}? This will also remove the persistent service.`))return}else if((e===`stop`||e===`restart`)&&!window.confirm(`${e} :${n.port}?`))return;if(!Be())return;M(!1);let i=n.uptime;R.setSelectedPort(n.port),q({selectedPort:n.port}),x(n.port),C(null),T(n.port),D(e);try{let r=e===`start`?u:void 0,a=await g(e,n.port,r),o=a.expectedStateAfter||(e===`start`||e===`perm`?`online`:e===`stop`||e===`unperm`?`offline`:`restart-detected`),s=await xt({port:n.port,expected:o,previousUptime:i,fetchOnce:(e,t)=>y(e,{signal:t})});s.settled||C(`${a.message} (not yet reachable, refresh manually if needed)`),s.instance&&t(e=>e&&{...e,instances:e.instances.map(e=>e.port===n.port?s.instance:e)}),await Ne(f,!0),Z({topics:[`instances`],reason:`instance:lifecycle`,source:`ui`,sourceId:`app`})}catch(e){C(e.message)}finally{x(null),T(null),D(null)}}let ht=(0,X.jsx)(Gn,{error:i,loading:n,instances:z,filtered:V,selectedInstance:H,data:e,lifecycleBusyPort:b,transitioningPort:w,transitionAction:E,activityUnreadByPort:G.unreadByPort,latestTitleByPort:De.titlesByPort,busyPorts:De.busyPorts,showLatestActivityTitles:R.showLatestActivityTitles,showInlineLabelEditor:R.showInlineLabelEditor,showSidebarRuntimeLine:R.showSidebarRuntimeLine,showSelectedRowActions:R.showSelectedRowActions,profiles:ke,getLabel:cr,formatUptime:lr,onSelect:Ge,onPreview:e=>Ue(e,!0),onMarkActivitySeen:G.markPortSeen,onInstanceLabelSave:Oe.saveInstanceLabel,onLifecycle:(e,t)=>void mt(e,t)}),gt=jf(R,we.theme),_t=Af(De.titleSupportByPort);return(0,X.jsx)(Sf,{view:R,palette:Te,theme:we,query:o,loading:n,showHidden:f,instances:z,selectedInstance:H,data:e,summary:Re,scheduleGroup:fe,boardView:ue,notesModel:lt,notesSelectedNote:ut,notesDirtyPath:ne,notesHighlightedPath:Ze,notesSidebarMode:ie,notesSearchFocusToken:oe,settingsSection:ce,dashboardSettingsUi:gt,titleSupport:_t,activityEvents:je,busyPorts:De.busyPorts,titlesByPort:De.titlesByPort,lifecycleMessage:S,error:i,registryMessage:L.error||Oe.error||Ee.error,onPickProject:e=>void Fe.pick(e),projectPickBusy:Fe.busyPort!=null,onRefreshPreview:()=>he(e=>e+1),onSettingsDirtyChange:te,detailContent:t=>(0,X.jsx)(kt,{instance:H,data:e,activeTab:t,onRegistryPatch:(e,t)=>{L.save({instances:{[String(e)]:t}}).then(()=>{Ne(),Z({topics:[`instances`],reason:`instance:registry-patched`,source:`ui`,sourceId:`app`})})}}),instanceListContent:ht,drawerProfileFilters:(e=>e.length>0?(0,X.jsx)(`div`,{className:`profile-chip-strip drawer-chip-strip`,"aria-label":`Profile filters`,children:e.map(e=>(0,X.jsx)(Kn,{profile:e,active:O.includes(e.profileId),count:Le[e.profileId]||0,onToggle:ze},e.profileId))}):null)(ke),jawCeoWorkbenchButton:U.workbenchButton,jawCeoVoiceOverlay:U.voiceOverlay,jawCeo:U.ceo,jawCeoVoice:U.voice,jawCeoOpen:U.open,jawCeoSelectedPort:Ae,onJawCeoOpenChange:U.setOpen,onJawCeoOpenWorker:We,previewEnabled:F,previewRefreshKey:me,autoUnloadNotice:ge,helpOpen:ve,helpTopic:xe,setQuery:s,setShowHidden:p,setPreviewEnabled:pe,setAutoUnloadNotice:_e,setHelpOpen:ye,setHelpTopic:Se,onOpenHelpTopic:I,setNotesSidebarMode:ae,setBoardView:de,setScheduleGroup:P,setDashboardSettingsSection:le,load:Ne,cycleTheme:K,openSelectedInBrowser:Me,handleSelectInstance:Ge,handleSidebarModeChange:Ye,handleSidebarToggle:Ke,handleNotesSelectedPathChange:Xe,openNotesFromPreview:tt,handleNotesViewModeChange:rt,handleNotesAuthoringModeChange:it,handleNotesWordWrapChange:at,handleNotesVimModeChange:ot,handleNotesTreeWidthChange:st,handleNotesGraphSettingsChange:ct,openNotesSidebarSearch:nt,setNotesDirtyPath:re,handleTabChange:J,handleActivityToggle:qe,handleActivityHeight:Je,onDismissLifecycleMessage:()=>C(null),handleDashboardSettingsPatch:dt,activityUnreadOpenAndMarkSeen:G.openAndMarkSeen,panelInitialState:_,onPanelStateChange:Ie,onShortcutAction:pt})}var Om=document.getElementById(`manager-root`);if(!Om)throw Error(`manager-root not found`);(0,bt.createRoot)(Om).render((0,X.jsx)(Dm,{}));