ccdeck 4.0.1 → 4.0.3

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 (34) hide show
  1. package/README.md +5 -5
  2. package/dist/web/assets/AccountBridge-CmB2ClCh.js +1 -0
  3. package/dist/web/assets/{AccountSection-Cu-96Q00.js → AccountSection-C0_ISsSw.js} +1 -1
  4. package/dist/web/assets/BrowserWatchModal-C4G5G12x.js +1 -0
  5. package/dist/web/assets/{FeedbackConversations-BgVk0nkA.js → FeedbackConversations-Bqqn0VaM.js} +1 -1
  6. package/dist/web/assets/{IntegrationModal-CEj5oJg4.js → IntegrationModal-CKgtTF3f.js} +1 -1
  7. package/dist/web/assets/{IntegrationSkeleton-DD7YiFgd.js → IntegrationSkeleton-WE6DOfez.js} +1 -1
  8. package/dist/web/assets/{RadioPanel-BhnzWRCT.js → RadioPanel-j_p9qx4L.js} +1 -1
  9. package/dist/web/assets/{StageShell-DmJu3dU1.js → StageShell-Bl0ddeiL.js} +3 -3
  10. package/dist/web/assets/{TrafficRadar-C8-ieIw5.js → TrafficRadar-CTGz345C.js} +1 -1
  11. package/dist/web/assets/{UsageHistoryModal-BThv9Kja.js → UsageHistoryModal-C2IDurbk.js} +1 -1
  12. package/dist/web/assets/app-82JtqhPe.css +1 -0
  13. package/dist/web/assets/{app-ZMmmEHxF.js → app-CdRq5GPP.js} +74 -74
  14. package/dist/web/assets/{index-zSxC5ueJ.js → index-pIus964m.js} +1 -1
  15. package/dist/web/assets/{inspector-status-pane-BgQG0bQi.js → inspector-status-pane-BY6DHEeo.js} +1 -1
  16. package/dist/web/assets/{screens-DD0uCtat.js → screens-BMLZR8WS.js} +1 -1
  17. package/dist/web/assets/{stage-board-J2rKA9Pg.js → stage-board-6RJd7VXM.js} +1 -1
  18. package/dist/web/assets/{use-account-DvFObI4M.js → use-account-t_qL6ab-.js} +1 -1
  19. package/dist/web/index.html +3 -3
  20. package/package.json +6 -6
  21. package/release-notes.json +34 -0
  22. package/src/server/command-panel-engine.mjs +2 -2
  23. package/src/server/command-panel-platform.mjs +2 -2
  24. package/src/server/engine-package.mjs +2 -1
  25. package/src/server/pro-engine-install.mjs +2 -1
  26. package/src/server/pro-engine-terminal.mjs +25 -4
  27. package/src/server/terminal-js-routes.mjs +16 -3
  28. package/src/server/terminal-routes.mjs +45 -3
  29. package/src/server/terminal-sessions.mjs +2 -1
  30. package/src/server/tmux-download.mjs +21 -1
  31. package/src/server/tmux.mjs +144 -27
  32. package/dist/web/assets/AccountBridge-fp-fsMx-.js +0 -1
  33. package/dist/web/assets/BrowserWatchModal-CvUx07C6.js +0 -1
  34. package/dist/web/assets/app-DtosBis5.css +0 -1
package/README.md CHANGED
@@ -59,11 +59,11 @@ The deck opens on these seven pictures the first time it runs — they are the w
59
59
  <table>
60
60
  <tr>
61
61
  <td><img src="assets/guide/welcome-1.svg" width="440" alt="Sessions waiting on you lead the session list, under Needs you."></td>
62
- <td><img src="assets/guide/welcome-2.svg" width="440" alt="Click a card: its terminal opens beside the board, so you can answer there."></td>
62
+ <td><img src="assets/guide/welcome-2.svg" width="440" alt="Click a card: its terminal opens in Workspace, so you can answer there."></td>
63
63
  </tr>
64
64
  <tr>
65
65
  <td align="center"><sub>Sessions waiting on you lead the session list, under Needs you.</sub></td>
66
- <td align="center"><sub>Click a card: its terminal opens beside the board, so you can answer there.</sub></td>
66
+ <td align="center"><sub>Click a card: its terminal opens in Workspace, so you can answer there.</sub></td>
67
67
  </tr>
68
68
  <tr>
69
69
  <td><img src="assets/guide/welcome-3.svg" width="440" alt="Workspace puts up to four sessions side by side. Ctrl+` switches to it."></td>
@@ -92,7 +92,7 @@ The deck opens on these seven pictures the first time it runs — they are the w
92
92
  | | |
93
93
  |---|---|
94
94
  | **Blocked on you** | A permission prompt, or a finished turn waiting for your next instruction, sorts that session to the top of the Sessions list with how long it has been stuck — longest wait first, so the oldest block is the first row. A permission prompt also puts a count in the topbar that jumps straight to it, and the session's name beside it, with how long it has waited and on what — one click from its card. Claude Code only — the deck reads Codex from its rollout log, and a rollout carries no such signal. |
95
- | **Its terminal, in the deck** | Click a session's card and its terminal opens in a pane beside the board: type to Claude Code or Codex there, resume a session that ended, or start a new one in any folder. **Workspace** puts up to four side by side. See [Terminal](#terminal) and [Workspace](#workspace). |
95
+ | **Its terminal, in the deck** | Click a session's card and its terminal opens in Workspace: type to Claude Code or Codex there, resume a session that ended, or start a new one in any folder. **Workspace** puts up to four side by side. See [Terminal](#terminal) and [Workspace](#workspace). |
96
96
  | **What each session is doing** | The note tied to each session's card — and the line under its row in the Sessions list — says it while it works: the sentence the newest reply wrote, or the description on the command it ran. Once the turn is over it keeps the last thing the session did, until Claude Code's recap takes its place. A background session (`claude --bg`, or one started from `claude agents`) shows Claude Code's own line instead, read from its job folder in `~/.claude/jobs`: the question it is stuck on and the reply Claude Code suggests, or the headline of what it got done. No model is called for any of it. A Codex session, read from its rollout log, has the note only while a turn runs, and it says the first line of the prompt that began the turn: no line is taken from a Codex reply, and no recap follows. |
97
97
  | **Live DAG** | Nodes are agents and edges are spawns; each agent's latest tool calls sit beside its node and light up while they run. In-flight edges animate, settled ones dim. |
98
98
  | **Both providers, one canvas** | Claude Code through hooks, Codex through its rollout log. The card names a Codex session, and the Inspector shows each session's model (`Opus 5`, `GPT-5.5`). Codex child sessions are connected when their rollout records an explicit parent. Each thread keeps its own tool calls and token totals. |
@@ -112,7 +112,7 @@ Step by step: [See which Claude Code session is waiting for input](https://ccdec
112
112
 
113
113
  ## Terminal
114
114
 
115
- Your sessions' terminals are inside the deck, for Claude Code and Codex alike, on Linux, macOS and Windows. Click a session's card on the board, or **Open** under its title in the Inspector, and its terminal opens in a pane beside the board, with the keys in it: type to the agent as you would in any terminal. **✕** closes the pane, and the session keeps running.
115
+ Your sessions' terminals are inside the deck, for Claude Code and Codex alike, on Linux, macOS and Windows. Click a session's card on the board and its terminal opens in Workspace, or press **Open** under its title in the Inspector to open it in a pane beside the board, with the keys in it either way: type to the agent as you would in any terminal. **✕** closes the pane, and the session keeps running.
116
116
 
117
117
  What the pane does depends on where the session runs:
118
118
 
@@ -134,7 +134,7 @@ Ending an agent yourself (`/exit` or `Ctrl+D`) closes its pane, and the session
134
134
 
135
135
  | Key | Does |
136
136
  |---|---|
137
- | click a card | open its session's terminal pane, with the keys in it |
137
+ | click a card | open its session's terminal pane in Workspace, with the keys in it |
138
138
  | `J` `K`, then `Enter` | with a pane open: step through the sessions beside it, then type into one |
139
139
  | `N` | with a pane open: the next session waiting on you |
140
140
  | `Ctrl+Shift+X` (`⌃⇧X` on a Mac) | give the keys back to the board |
@@ -0,0 +1 @@
1
+ import{r as e,p as t}from"./app-CdRq5GPP.js";import{u as o,a as s,f as n}from"./use-account-t_qL6ab-.js";function r({appliers:u}){o(u);const{view:c}=s();return e.useEffect(()=>{t(n(c))},[c]),e.useEffect(()=>()=>t(null),[]),null}export{r as default};
@@ -1 +1 @@
1
- import{u as V,r as d,j as e,k as a,b_ as I,s as K,b$ as w,c0 as u,t as A,g as q}from"./app-ZMmmEHxF.js";import{b as m,o as _,a as z}from"./use-account-DvFObI4M.js";function L(n,s,o){return o==null?n("settings.account.notSet"):typeof o=="boolean"?n(o?"settings.claude.effect.on":"settings.claude.effect.off"):s==="hideFinishedAfter"?o===0?n("settings.board.never"):n("settings.board.minutes",{n:String(o)}):String(o)}const C={loading:"settings.account.preview.loading",failed:"settings.account.preview.failed",none:"settings.account.preview.none",same:"settings.account.preview.same",stale:"settings.account.preview.stale"};function H({onDone:n}){var S;const s=V(),[o,R]=d.useState(null),[t,f]=d.useState(!1),[x,r]=d.useState(!1),v=d.useRef(!1),[y,M]=d.useState(""),N=()=>{f(!1),m.preview().then(i=>{i!=null&&i.error?f(!0):R(i)}).catch(()=>f(!0))};d.useEffect(N,[]);const k=async i=>{if(K(v.current)){v.current=!0,r(!0);try{const h=await m.setMode(i);if((h==null?void 0:h.error)==="revision_conflict"){M(C.stale),N();return}if(h!=null&&h.error){M(C.failed);return}n()}finally{v.current=!1,r(!1)}}};if(t)return e.jsxs("div",{className:"account-preview",role:"group","aria-label":s("settings.account.shareLabel"),children:[e.jsx("p",{className:"settings-row-note",children:s(C.failed)}),e.jsx("div",{className:"account-actions",children:e.jsx("button",{type:"button",className:"btn",onClick:n,children:s("common.close")})})]});if(!o)return e.jsx("p",{className:"settings-row-note account-preview",children:s(C.loading)});const p=o.shared;return e.jsxs("div",{className:"account-preview",role:"group","aria-label":s("settings.account.shareLabel"),children:[y&&e.jsx("p",{className:"settings-row-said",role:"status",children:s(y)}),p?e.jsxs(e.Fragment,{children:[o.differences.length===0?e.jsx("p",{className:"settings-row-note",children:s(C.same)}):e.jsxs("table",{className:"account-diff",children:[e.jsx("caption",{className:"settings-row-note",children:(S=p.updatedBy)!=null&&S.name?s("settings.account.sharedRevisionBy",{revision:p.revision,name:p.updatedBy.name}):s("settings.account.sharedRevision",{revision:p.revision})}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:s("settings.account.colSetting")}),e.jsx("th",{scope:"col",children:s("settings.account.colThisDeck")}),e.jsx("th",{scope:"col",children:s("settings.account.colShared")})]})}),e.jsx("tbody",{children:o.differences.map(i=>e.jsxs("tr",{children:[e.jsx("th",{scope:"row",children:I(s,i.key)??i.key}),e.jsx("td",{children:L(s,i.key,i.local)}),e.jsx("td",{children:L(s,i.key,i.shared)})]},i.key))})]}),e.jsxs("div",{className:"account-actions",children:[e.jsx("button",{type:"button",className:"btn",onClick:n,...a(x),children:s("common.cancel")}),e.jsx("button",{type:"button",className:"btn",...a(x),onClick:()=>k({mode:"shared",join:"publish",previewRevision:p.revision}),children:s("settings.account.useDeckForAll")}),e.jsx("button",{type:"button",className:"btn primary",...a(x),onClick:()=>k({mode:"shared",join:"use-shared"}),children:s("settings.account.useShared")})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"settings-row-note",children:s(C.none)}),e.jsxs("div",{className:"account-actions",children:[e.jsx("button",{type:"button",className:"btn",onClick:n,...a(x),children:s("common.cancel")}),e.jsx("button",{type:"button",className:"btn primary",...a(x),onClick:()=>k({mode:"shared",join:"publish",previewRevision:0}),children:s("settings.account.publishDeck")})]})]})]})}const g={vetoed:"settings.account.copy.vetoed",loading:"settings.account.copy.loading",unreachable:"settings.account.copy.unreachable",explain:"settings.account.copy.explain",sent:"settings.account.copy.sent",nameNote:"settings.account.copy.nameNote",connecting:"settings.account.copy.connecting",revoked:"settings.account.copy.revoked",accountGone:"settings.account.copy.accountGone",disconnectNote:"settings.account.copy.disconnectNote",tokenMissing:"settings.account.copy.tokenMissing"},Q={"api-disabled":"settings.account.problem.apiDisabled",offline:"settings.account.problem.offline","rate-limited":"settings.account.problem.rateLimited","connect-denied":"settings.account.problem.connectDenied","connect-expired":"settings.account.problem.connectExpired","connect-failed":"settings.account.problem.connectFailed","keychain-locked":"settings.account.problem.keychainLocked","token-missing":g.tokenMissing},X={keychain:"settings.account.storage.keychain",dpapi:"settings.account.storage.dpapi","secret-service":"settings.account.storage.secretService",file:"settings.account.storage.file"},Z={keychain:"settings.account.signIn.keychain",dpapi:"settings.account.signIn.dpapi","secret-service":"settings.account.signIn.secretService",file:"settings.account.signIn.file"},G=n=>{if(!n)return"";const s=new Date(n);return Number.isFinite(s.getTime())?s.toLocaleTimeString(q(),{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""};function ee(n){const s=n.status;return!s||!s.lastSentAt?A("settings.account.status.notSent"):s.lastResult==="offline"?A("settings.account.status.offline",{time:G(s.lastSentAt)}):s.lastResult==="rejected"?A("settings.account.status.refused",{time:G(s.lastSentAt)}):A("settings.account.status.sent",{time:G(s.lastSentAt),seconds:s.everySec})}function $(n){const s=n.sync;return s?s.appliedRevision==null?A("settings.account.revisionsNotYet",{saved:s.savedRevision}):A("settings.account.revisions",{saved:s.savedRevision,applied:s.appliedRevision}):""}function te(n,s){const o=Math.max(0,Math.round((Date.parse(n)-s)/1e3));return`${Math.floor(o/60)}:${String(o%60).padStart(2,"0")}`}function Y({view:n,failed:s=!1,vetoed:o,now:R=Date.now()}){var T,U,O;const t=V(),[f,x]=d.useState(null),[r,v]=d.useState(!1),y=d.useRef(!1),[M,N]=d.useState(!1),[k,p]=d.useState(!1),[S,i]=d.useState(!1);if(o)return e.jsx(w,{id:"settings-account-caption",title:t("settings.account.title"),children:e.jsx(u,{as:"div",name:t("settings.section.account.label"),note:t(g.vetoed)})});if(!n)return e.jsx("p",{className:"settings-row-note",children:t(s?g.unreachable:g.loading)});const h=n.problem?Q[n.problem]:void 0,B=h?t(h):null,D=X[n.tokenStorage??""],b=async c=>{if(K(y.current)){y.current=!0,v(!0);try{await c()}catch{}finally{y.current=!1,v(!1)}}},J=()=>b(async()=>{var l;const c=await m.connect(f??n.suggestedName),j=(l=c==null?void 0:c.connect)==null?void 0:l.verificationUriComplete;j&&_(j)&&window.open(j,"_blank","noopener,noreferrer")});if(n.state==="connecting"&&n.connect){const c=n.connect;return e.jsxs(w,{id:"settings-account-caption",title:t("settings.account.connecting"),children:[e.jsx(u,{as:"div",name:t("settings.account.code"),note:t(g.connecting),control:e.jsx("span",{className:"account-code",children:c.userCode})}),e.jsx(u,{as:"div",name:t("settings.account.waiting"),note:t("settings.account.expiresIn",{time:te(c.expiresAt,R)}),control:e.jsxs("span",{className:"account-actions",children:[_(c.verificationUriComplete)&&e.jsx("a",{className:"settings-link",href:c.verificationUriComplete,target:"_blank",rel:"noopener noreferrer",children:t("settings.account.openAgain")}),e.jsx("button",{type:"button",className:"btn",...a(r),onClick:()=>b(m.cancel),children:t("common.cancel")})]})})]})}if(n.state==="connected"&&n.device){const c=n.sync,j=((T=n.account)==null?void 0:T.email)??t("settings.account.yourAccount");return e.jsxs(e.Fragment,{children:[e.jsxs(w,{id:"settings-account-caption",title:t("settings.account.title"),children:[e.jsx(u,{as:"div",name:j,note:ee(n),control:n.device.consoleUrl&&_(n.device.consoleUrl)?e.jsx("a",{className:"settings-link",href:n.device.consoleUrl,target:"_blank",rel:"noopener noreferrer",children:t("settings.account.openMachines")}):void 0}),e.jsx(u,{as:"div",name:t("settings.account.thisDeck",{name:n.device.name}),note:B??(D?t(D):"")})]}),c&&e.jsxs(w,{id:"settings-account-sync-caption",title:t("settings.account.syncTitle"),children:[e.jsx(u,{as:"div",name:t(c.mode==="shared"?"settings.account.sharedName":"settings.account.deckOnlyName"),note:c.mode==="shared"?t("settings.account.sharedNote",{stays:c.overrides.map(l=>{var P;return((P=I(t,l))==null?void 0:P.toLowerCase())??l}).join(", ")||t("settings.account.nothing"),revisions:$(n)}):t("settings.account.deckOnlyNote",{revisions:$(n)}),control:c.mode==="shared"?e.jsx("button",{type:"button",className:"btn",...a(r),onClick:()=>b(()=>m.setMode({mode:"independent"})),children:t("settings.account.stopSharing")}):e.jsx("button",{type:"button",className:"btn",...a(r,k),onClick:()=>p(!0),children:t("settings.account.shareSettings")})}),k&&e.jsx(u,{as:"div",className:"settings-row-wide",name:t("settings.account.joinName"),children:e.jsx(H,{onDone:()=>p(!1)})}),c.pending&&!c.conflict&&e.jsx(u,{as:"div",name:t("settings.account.pending"),note:t("settings.account.pendingNote",{keys:c.pending.keys.map(l=>I(t,l)??l).join(", "),state:t(c.saving==="offline"?"settings.account.pendingOffline":c.saving==="refused"?"settings.account.pendingRefused":"settings.account.pendingSaving")})}),c.conflict&&e.jsx(u,{as:"div",className:S?"settings-row-wide":void 0,name:t("settings.account.changedElsewhere"),note:(U=c.conflict.latest.updatedBy)!=null&&U.name?t("settings.account.changedElsewhereBy",{revision:c.conflict.latest.revision,name:c.conflict.latest.updatedBy.name}):t("settings.account.changedElsewhereNote",{revision:c.conflict.latest.revision}),control:S?void 0:e.jsxs("span",{className:"account-actions",children:[e.jsx("button",{type:"button",className:"btn",...a(r),onClick:()=>i(!0),children:t("settings.account.review")}),e.jsx("button",{type:"button",className:"btn primary",...a(r),onClick:()=>b(()=>m.resolve("use-latest")),children:t("settings.account.useLatest")})]}),children:S&&e.jsxs("div",{className:"account-preview",children:[e.jsxs("table",{className:"account-diff",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:t("settings.account.colSetting")}),e.jsx("th",{scope:"col",children:t("settings.account.colYours")}),e.jsx("th",{scope:"col",children:`r${c.conflict.latest.revision}`})]})}),e.jsx("tbody",{children:Object.keys(c.conflict.mine).map(l=>e.jsxs("tr",{children:[e.jsx("th",{scope:"row",children:I(t,l)??l}),e.jsx("td",{children:L(t,l,c.conflict.mine[l])}),e.jsx("td",{children:L(t,l,c.conflict.latest.values[l])})]},l))})]}),e.jsxs("div",{className:"account-actions",children:[e.jsx("button",{type:"button",className:"btn",...a(r),onClick:()=>i(!1),children:t("settings.account.back")}),e.jsx("button",{type:"button",className:"btn",...a(r),onClick:()=>b(()=>m.resolve("use-latest")),children:t("settings.account.useLatest")}),e.jsx("button",{type:"button",className:"btn primary",...a(r),onClick:()=>b(async()=>{await m.resolve("reapply"),i(!1)}),children:t("settings.account.saveMine",{revision:c.conflict.latest.revision})})]})]})}),c.askUploadForNewAccount&&e.jsx(u,{as:"div",name:t("settings.account.notSavedName"),note:t("settings.account.notSavedNote",{email:j}),control:e.jsx("button",{type:"button",className:"btn",...a(r),onClick:()=>b(m.upload),children:t("settings.account.saveToAccount",{email:j})})}),((O=c.skipped)==null?void 0:O.theme)&&e.jsx(u,{as:"div",name:t("settings.account.themeKept"),note:t("settings.account.themeKeptNote",{theme:c.skipped.theme})})]}),e.jsx(w,{id:"settings-account-leave-caption",title:t("settings.account.disconnectTitle"),children:e.jsx(u,{as:"div",name:t("settings.account.disconnectName"),note:t(g.disconnectNote),control:M?e.jsxs("span",{className:"account-actions",children:[e.jsx("button",{type:"button",className:"btn",...a(r),onClick:()=>N(!1),children:t("common.cancel")}),e.jsx("button",{type:"button",className:"btn danger",...a(r),onClick:()=>b(async()=>{await m.disconnect(),N(!1)}),children:t("settings.account.disconnect")})]}):e.jsx("button",{type:"button",className:"btn",...a(r),onClick:()=>N(!0),children:t("settings.account.disconnectAsk")})})})]})}const E=n.state==="revoked",W=E?n.revokedReason==="account_gone"?g.accountGone:g.revoked:n.state==="error"?g.tokenMissing:g.explain,F=Z[n.tokenStorage??""];return e.jsxs(w,{id:"settings-account-caption",title:t("settings.account.title"),note:t(W),children:[e.jsx(u,{as:"div",name:t("settings.account.whatIsSent"),note:t(g.sent)}),e.jsx(u,{name:t("settings.account.appearAs"),nameId:"settings-account-name-label",note:t(g.nameNote),noteId:"settings-account-name-note",control:e.jsx("input",{className:"ap-manage-input account-name",type:"text",value:f??n.suggestedName,maxLength:48,spellCheck:!1,autoComplete:"off","aria-labelledby":"settings-account-name-label","aria-describedby":"settings-account-name-note",onChange:c=>x(c.target.value)})}),e.jsx(u,{as:"div",name:t(E?"settings.account.connectAgain":"settings.account.connect"),note:B??(F?t(F):void 0),control:e.jsx("button",{type:"button",className:"btn primary",...a(r),onClick:J,children:t(E?"settings.account.connectAgain":"settings.account.connect")})})]})}function oe({vetoed:n}){return n?e.jsx(Y,{view:null,vetoed:!0}):e.jsx(ne,{})}function ne(){const{view:n,failed:s}=z(),[o,R]=d.useState(()=>Date.now()),t=(n==null?void 0:n.state)==="connecting";return d.useEffect(()=>{if(!t)return;const f=window.setInterval(()=>R(Date.now()),1e3);return()=>window.clearInterval(f)},[t]),d.useEffect(()=>{m.refresh()},[]),e.jsx(Y,{view:n,failed:s,vetoed:!1,now:o})}export{g as ACCOUNT_MSGS,Y as AccountPanel,Q as PROBLEM_MSGS,X as STORAGE_MSGS,oe as default,te as expiresIn,$ as revisionsLine,ee as statusLine};
1
+ import{u as V,r as d,j as e,k as a,b_ as I,s as K,b$ as w,c0 as u,t as A,g as q}from"./app-CdRq5GPP.js";import{b as m,o as _,a as z}from"./use-account-t_qL6ab-.js";function L(n,s,o){return o==null?n("settings.account.notSet"):typeof o=="boolean"?n(o?"settings.claude.effect.on":"settings.claude.effect.off"):s==="hideFinishedAfter"?o===0?n("settings.board.never"):n("settings.board.minutes",{n:String(o)}):String(o)}const C={loading:"settings.account.preview.loading",failed:"settings.account.preview.failed",none:"settings.account.preview.none",same:"settings.account.preview.same",stale:"settings.account.preview.stale"};function H({onDone:n}){var S;const s=V(),[o,R]=d.useState(null),[t,f]=d.useState(!1),[x,r]=d.useState(!1),v=d.useRef(!1),[y,M]=d.useState(""),N=()=>{f(!1),m.preview().then(i=>{i!=null&&i.error?f(!0):R(i)}).catch(()=>f(!0))};d.useEffect(N,[]);const k=async i=>{if(K(v.current)){v.current=!0,r(!0);try{const h=await m.setMode(i);if((h==null?void 0:h.error)==="revision_conflict"){M(C.stale),N();return}if(h!=null&&h.error){M(C.failed);return}n()}finally{v.current=!1,r(!1)}}};if(t)return e.jsxs("div",{className:"account-preview",role:"group","aria-label":s("settings.account.shareLabel"),children:[e.jsx("p",{className:"settings-row-note",children:s(C.failed)}),e.jsx("div",{className:"account-actions",children:e.jsx("button",{type:"button",className:"btn",onClick:n,children:s("common.close")})})]});if(!o)return e.jsx("p",{className:"settings-row-note account-preview",children:s(C.loading)});const p=o.shared;return e.jsxs("div",{className:"account-preview",role:"group","aria-label":s("settings.account.shareLabel"),children:[y&&e.jsx("p",{className:"settings-row-said",role:"status",children:s(y)}),p?e.jsxs(e.Fragment,{children:[o.differences.length===0?e.jsx("p",{className:"settings-row-note",children:s(C.same)}):e.jsxs("table",{className:"account-diff",children:[e.jsx("caption",{className:"settings-row-note",children:(S=p.updatedBy)!=null&&S.name?s("settings.account.sharedRevisionBy",{revision:p.revision,name:p.updatedBy.name}):s("settings.account.sharedRevision",{revision:p.revision})}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:s("settings.account.colSetting")}),e.jsx("th",{scope:"col",children:s("settings.account.colThisDeck")}),e.jsx("th",{scope:"col",children:s("settings.account.colShared")})]})}),e.jsx("tbody",{children:o.differences.map(i=>e.jsxs("tr",{children:[e.jsx("th",{scope:"row",children:I(s,i.key)??i.key}),e.jsx("td",{children:L(s,i.key,i.local)}),e.jsx("td",{children:L(s,i.key,i.shared)})]},i.key))})]}),e.jsxs("div",{className:"account-actions",children:[e.jsx("button",{type:"button",className:"btn",onClick:n,...a(x),children:s("common.cancel")}),e.jsx("button",{type:"button",className:"btn",...a(x),onClick:()=>k({mode:"shared",join:"publish",previewRevision:p.revision}),children:s("settings.account.useDeckForAll")}),e.jsx("button",{type:"button",className:"btn primary",...a(x),onClick:()=>k({mode:"shared",join:"use-shared"}),children:s("settings.account.useShared")})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"settings-row-note",children:s(C.none)}),e.jsxs("div",{className:"account-actions",children:[e.jsx("button",{type:"button",className:"btn",onClick:n,...a(x),children:s("common.cancel")}),e.jsx("button",{type:"button",className:"btn primary",...a(x),onClick:()=>k({mode:"shared",join:"publish",previewRevision:0}),children:s("settings.account.publishDeck")})]})]})]})}const g={vetoed:"settings.account.copy.vetoed",loading:"settings.account.copy.loading",unreachable:"settings.account.copy.unreachable",explain:"settings.account.copy.explain",sent:"settings.account.copy.sent",nameNote:"settings.account.copy.nameNote",connecting:"settings.account.copy.connecting",revoked:"settings.account.copy.revoked",accountGone:"settings.account.copy.accountGone",disconnectNote:"settings.account.copy.disconnectNote",tokenMissing:"settings.account.copy.tokenMissing"},Q={"api-disabled":"settings.account.problem.apiDisabled",offline:"settings.account.problem.offline","rate-limited":"settings.account.problem.rateLimited","connect-denied":"settings.account.problem.connectDenied","connect-expired":"settings.account.problem.connectExpired","connect-failed":"settings.account.problem.connectFailed","keychain-locked":"settings.account.problem.keychainLocked","token-missing":g.tokenMissing},X={keychain:"settings.account.storage.keychain",dpapi:"settings.account.storage.dpapi","secret-service":"settings.account.storage.secretService",file:"settings.account.storage.file"},Z={keychain:"settings.account.signIn.keychain",dpapi:"settings.account.signIn.dpapi","secret-service":"settings.account.signIn.secretService",file:"settings.account.signIn.file"},G=n=>{if(!n)return"";const s=new Date(n);return Number.isFinite(s.getTime())?s.toLocaleTimeString(q(),{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""};function ee(n){const s=n.status;return!s||!s.lastSentAt?A("settings.account.status.notSent"):s.lastResult==="offline"?A("settings.account.status.offline",{time:G(s.lastSentAt)}):s.lastResult==="rejected"?A("settings.account.status.refused",{time:G(s.lastSentAt)}):A("settings.account.status.sent",{time:G(s.lastSentAt),seconds:s.everySec})}function $(n){const s=n.sync;return s?s.appliedRevision==null?A("settings.account.revisionsNotYet",{saved:s.savedRevision}):A("settings.account.revisions",{saved:s.savedRevision,applied:s.appliedRevision}):""}function te(n,s){const o=Math.max(0,Math.round((Date.parse(n)-s)/1e3));return`${Math.floor(o/60)}:${String(o%60).padStart(2,"0")}`}function Y({view:n,failed:s=!1,vetoed:o,now:R=Date.now()}){var T,U,O;const t=V(),[f,x]=d.useState(null),[r,v]=d.useState(!1),y=d.useRef(!1),[M,N]=d.useState(!1),[k,p]=d.useState(!1),[S,i]=d.useState(!1);if(o)return e.jsx(w,{id:"settings-account-caption",title:t("settings.account.title"),children:e.jsx(u,{as:"div",name:t("settings.section.account.label"),note:t(g.vetoed)})});if(!n)return e.jsx("p",{className:"settings-row-note",children:t(s?g.unreachable:g.loading)});const h=n.problem?Q[n.problem]:void 0,B=h?t(h):null,D=X[n.tokenStorage??""],b=async c=>{if(K(y.current)){y.current=!0,v(!0);try{await c()}catch{}finally{y.current=!1,v(!1)}}},J=()=>b(async()=>{var l;const c=await m.connect(f??n.suggestedName),j=(l=c==null?void 0:c.connect)==null?void 0:l.verificationUriComplete;j&&_(j)&&window.open(j,"_blank","noopener,noreferrer")});if(n.state==="connecting"&&n.connect){const c=n.connect;return e.jsxs(w,{id:"settings-account-caption",title:t("settings.account.connecting"),children:[e.jsx(u,{as:"div",name:t("settings.account.code"),note:t(g.connecting),control:e.jsx("span",{className:"account-code",children:c.userCode})}),e.jsx(u,{as:"div",name:t("settings.account.waiting"),note:t("settings.account.expiresIn",{time:te(c.expiresAt,R)}),control:e.jsxs("span",{className:"account-actions",children:[_(c.verificationUriComplete)&&e.jsx("a",{className:"settings-link",href:c.verificationUriComplete,target:"_blank",rel:"noopener noreferrer",children:t("settings.account.openAgain")}),e.jsx("button",{type:"button",className:"btn",...a(r),onClick:()=>b(m.cancel),children:t("common.cancel")})]})})]})}if(n.state==="connected"&&n.device){const c=n.sync,j=((T=n.account)==null?void 0:T.email)??t("settings.account.yourAccount");return e.jsxs(e.Fragment,{children:[e.jsxs(w,{id:"settings-account-caption",title:t("settings.account.title"),children:[e.jsx(u,{as:"div",name:j,note:ee(n),control:n.device.consoleUrl&&_(n.device.consoleUrl)?e.jsx("a",{className:"settings-link",href:n.device.consoleUrl,target:"_blank",rel:"noopener noreferrer",children:t("settings.account.openMachines")}):void 0}),e.jsx(u,{as:"div",name:t("settings.account.thisDeck",{name:n.device.name}),note:B??(D?t(D):"")})]}),c&&e.jsxs(w,{id:"settings-account-sync-caption",title:t("settings.account.syncTitle"),children:[e.jsx(u,{as:"div",name:t(c.mode==="shared"?"settings.account.sharedName":"settings.account.deckOnlyName"),note:c.mode==="shared"?t("settings.account.sharedNote",{stays:c.overrides.map(l=>{var P;return((P=I(t,l))==null?void 0:P.toLowerCase())??l}).join(", ")||t("settings.account.nothing"),revisions:$(n)}):t("settings.account.deckOnlyNote",{revisions:$(n)}),control:c.mode==="shared"?e.jsx("button",{type:"button",className:"btn",...a(r),onClick:()=>b(()=>m.setMode({mode:"independent"})),children:t("settings.account.stopSharing")}):e.jsx("button",{type:"button",className:"btn",...a(r,k),onClick:()=>p(!0),children:t("settings.account.shareSettings")})}),k&&e.jsx(u,{as:"div",className:"settings-row-wide",name:t("settings.account.joinName"),children:e.jsx(H,{onDone:()=>p(!1)})}),c.pending&&!c.conflict&&e.jsx(u,{as:"div",name:t("settings.account.pending"),note:t("settings.account.pendingNote",{keys:c.pending.keys.map(l=>I(t,l)??l).join(", "),state:t(c.saving==="offline"?"settings.account.pendingOffline":c.saving==="refused"?"settings.account.pendingRefused":"settings.account.pendingSaving")})}),c.conflict&&e.jsx(u,{as:"div",className:S?"settings-row-wide":void 0,name:t("settings.account.changedElsewhere"),note:(U=c.conflict.latest.updatedBy)!=null&&U.name?t("settings.account.changedElsewhereBy",{revision:c.conflict.latest.revision,name:c.conflict.latest.updatedBy.name}):t("settings.account.changedElsewhereNote",{revision:c.conflict.latest.revision}),control:S?void 0:e.jsxs("span",{className:"account-actions",children:[e.jsx("button",{type:"button",className:"btn",...a(r),onClick:()=>i(!0),children:t("settings.account.review")}),e.jsx("button",{type:"button",className:"btn primary",...a(r),onClick:()=>b(()=>m.resolve("use-latest")),children:t("settings.account.useLatest")})]}),children:S&&e.jsxs("div",{className:"account-preview",children:[e.jsxs("table",{className:"account-diff",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:t("settings.account.colSetting")}),e.jsx("th",{scope:"col",children:t("settings.account.colYours")}),e.jsx("th",{scope:"col",children:`r${c.conflict.latest.revision}`})]})}),e.jsx("tbody",{children:Object.keys(c.conflict.mine).map(l=>e.jsxs("tr",{children:[e.jsx("th",{scope:"row",children:I(t,l)??l}),e.jsx("td",{children:L(t,l,c.conflict.mine[l])}),e.jsx("td",{children:L(t,l,c.conflict.latest.values[l])})]},l))})]}),e.jsxs("div",{className:"account-actions",children:[e.jsx("button",{type:"button",className:"btn",...a(r),onClick:()=>i(!1),children:t("settings.account.back")}),e.jsx("button",{type:"button",className:"btn",...a(r),onClick:()=>b(()=>m.resolve("use-latest")),children:t("settings.account.useLatest")}),e.jsx("button",{type:"button",className:"btn primary",...a(r),onClick:()=>b(async()=>{await m.resolve("reapply"),i(!1)}),children:t("settings.account.saveMine",{revision:c.conflict.latest.revision})})]})]})}),c.askUploadForNewAccount&&e.jsx(u,{as:"div",name:t("settings.account.notSavedName"),note:t("settings.account.notSavedNote",{email:j}),control:e.jsx("button",{type:"button",className:"btn",...a(r),onClick:()=>b(m.upload),children:t("settings.account.saveToAccount",{email:j})})}),((O=c.skipped)==null?void 0:O.theme)&&e.jsx(u,{as:"div",name:t("settings.account.themeKept"),note:t("settings.account.themeKeptNote",{theme:c.skipped.theme})})]}),e.jsx(w,{id:"settings-account-leave-caption",title:t("settings.account.disconnectTitle"),children:e.jsx(u,{as:"div",name:t("settings.account.disconnectName"),note:t(g.disconnectNote),control:M?e.jsxs("span",{className:"account-actions",children:[e.jsx("button",{type:"button",className:"btn",...a(r),onClick:()=>N(!1),children:t("common.cancel")}),e.jsx("button",{type:"button",className:"btn danger",...a(r),onClick:()=>b(async()=>{await m.disconnect(),N(!1)}),children:t("settings.account.disconnect")})]}):e.jsx("button",{type:"button",className:"btn",...a(r),onClick:()=>N(!0),children:t("settings.account.disconnectAsk")})})})]})}const E=n.state==="revoked",W=E?n.revokedReason==="account_gone"?g.accountGone:g.revoked:n.state==="error"?g.tokenMissing:g.explain,F=Z[n.tokenStorage??""];return e.jsxs(w,{id:"settings-account-caption",title:t("settings.account.title"),note:t(W),children:[e.jsx(u,{as:"div",name:t("settings.account.whatIsSent"),note:t(g.sent)}),e.jsx(u,{name:t("settings.account.appearAs"),nameId:"settings-account-name-label",note:t(g.nameNote),noteId:"settings-account-name-note",control:e.jsx("input",{className:"ap-manage-input account-name",type:"text",value:f??n.suggestedName,maxLength:48,spellCheck:!1,autoComplete:"off","aria-labelledby":"settings-account-name-label","aria-describedby":"settings-account-name-note",onChange:c=>x(c.target.value)})}),e.jsx(u,{as:"div",name:t(E?"settings.account.connectAgain":"settings.account.connect"),note:B??(F?t(F):void 0),control:e.jsx("button",{type:"button",className:"btn primary",...a(r),onClick:J,children:t(E?"settings.account.connectAgain":"settings.account.connect")})})]})}function oe({vetoed:n}){return n?e.jsx(Y,{view:null,vetoed:!0}):e.jsx(ne,{})}function ne(){const{view:n,failed:s}=z(),[o,R]=d.useState(()=>Date.now()),t=(n==null?void 0:n.state)==="connecting";return d.useEffect(()=>{if(!t)return;const f=window.setInterval(()=>R(Date.now()),1e3);return()=>window.clearInterval(f)},[t]),d.useEffect(()=>{m.refresh()},[]),e.jsx(Y,{view:n,failed:s,vetoed:!1,now:o})}export{g as ACCOUNT_MSGS,Y as AccountPanel,Q as PROBLEM_MSGS,X as STORAGE_MSGS,oe as default,te as expiresIn,$ as revisionsLine,ee as statusLine};
@@ -0,0 +1 @@
1
+ import{u as P,j as e,r as h,ak as Z,al as ee,g as V,t as I,am as se,h as te,an as ne,y as ae,ao as ie,s as re,ap as U,o as H,G as le,J as ce,Q as oe,R as de,k as he,aq as we}from"./app-CdRq5GPP.js";function be({snap:s}){const a=P();return e.jsxs("section",{className:"bw-feed",children:[e.jsxs("h4",{className:"bw-sec-head bw-head-row",children:[a("settings.bw.feed"),e.jsx("span",{className:"bw-feed-count",children:a("settings.bw.feed.count",{count:s.log.length})})]}),e.jsx("p",{className:"bw-since bw-feed-note",children:a("settings.bw.feed.note")}),e.jsx("div",{className:"bw-log","aria-live":"polite","aria-relevant":"additions",children:s.log.length===0?e.jsx("p",{className:"bw-note",children:a("settings.bw.feed.empty")}):s.log.map(t=>e.jsxs("div",{className:`bw-log-line ${t.level}${t.parts?"":" sys"}`,children:[e.jsx("span",{className:"bw-log-time",children:new Date(t.atMs).toLocaleTimeString("en-GB",{hour12:!1})}),t.parts?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bw-log-browser",children:t.parts.browser}),e.jsx("span",{className:"bw-log-profile",title:t.parts.profile,children:t.parts.profile}),e.jsxs("span",{className:"bw-log-value",children:[t.parts.value,t.parts.flagged>0&&e.jsx("span",{className:"bw-log-flag",children:a("settings.bw.feed.flagged",{count:t.parts.flagged})})]})]}):e.jsx("span",{className:"bw-log-sys",children:t.text})]},`${t.atMs}-${t.level}-${t.text}`))})]})}const D=s=>`${s.host}-${s.startMs}`;function ue(s){const a=t=>new Date(t).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",hour12:!1});return s.count===1||s.endMs-s.startMs<6e4?a(s.startMs):`${a(s.startMs)} → ${a(s.endMs)}`}function ge(s){return new Date(s).toLocaleDateString(V(),{weekday:"short",day:"numeric",month:"short"})}function _(s,a){const t=Math.round((s.endMs-s.startMs)/6e4);return t<1?"":a("settings.bw.findings.minutes",{n:t})}function me({snap:s,dismiss:a,refreshRef:t}){const i=P(),[l,d]=h.useState(null),o=h.useRef(new Map),n=h.useRef(null);h.useEffect(()=>{var c,u;const b=n.current;!b||s.episodes.some(g=>D(g)===b.id)||(n.current=null,Z(((c=document.activeElement)==null?void 0:c.tagName)??null)&&((u=(b.next?o.current.get(b.next):void 0)??t.current)==null||u.focus()))},[s]);const r=b=>{n.current={id:D(b),next:ee(s.episodes.map(D),D(b))},a(b)},w=h.useMemo(()=>{const b=[];for(const c of s.episodes){const u=ge(c.startMs),g=b[b.length-1];g&&g.label===u?g.episodes.push(c):b.push({label:u,episodes:[c]})}return b},[s]);return e.jsxs("section",{className:"bw-findings",children:[e.jsxs("h4",{className:"bw-sec-head bw-head-row",children:[i("settings.bw.findings"),s.episodes.length>0&&e.jsx("span",{className:"bw-feed-count",children:i("settings.bw.findings.count",{count:s.episodes.length})})]}),e.jsx("div",{className:"bw-eps",children:w.length===0?e.jsxs("div",{className:"bw-empty",children:[e.jsx("p",{className:"bw-empty-head",children:i("settings.bw.findings.none")}),e.jsx("p",{className:"bw-empty-note",children:i("settings.bw.findings.noneNote",{count:s.settings.quietMinutes})}),!s.settings.enabled&&e.jsx("p",{className:"bw-empty-note",children:i("settings.bw.findings.offNote")})]}):w.map(b=>e.jsxs("div",{className:"bw-day",children:[e.jsx("h4",{className:"bw-sec-head",children:b.label}),b.episodes.map(c=>{const u=D(c),g=l===u;return e.jsxs("div",{className:`bw-ep${g?" open":""}`,children:[e.jsxs("div",{className:"bw-ep-row",children:[e.jsxs("button",{className:"bw-ep-head",ref:p=>{p?o.current.set(u,p):o.current.delete(u)},onClick:()=>d(g?null:u),"aria-expanded":g,children:[e.jsx("span",{className:"bw-chev","aria-hidden":!0,children:g?"▾":"▸"}),e.jsx("span",{className:"bw-ep-host",children:c.host}),e.jsxs("span",{className:"bw-ep-meta",children:[ue(c),_(c,i)&&e.jsxs(e.Fragment,{children:[" · ",_(c,i)]}),c.provisional&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{title:i("settings.bw.findings.provisionalTip"),children:i("settings.bw.findings.provisional")})]})]}),e.jsx("span",{className:"bw-ep-count",children:i("settings.bw.findings.pages",{count:c.count})})]}),e.jsx("button",{className:"glyph-btn bw-ep-x",onClick:()=>r(c),"aria-label":i("settings.bw.findings.dismissHost",{host:c.host}),title:i("settings.bw.findings.dismissTip"),children:"×"})]}),g&&e.jsx("ul",{className:"bw-urls",children:c.urls.map((p,f)=>e.jsxs("li",{children:[e.jsx("span",{className:"bw-url-time",children:new Date(p.timeMs).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",hour12:!1})}),e.jsx("span",{className:"bw-url",children:p.url})]},`${p.url}-${p.timeMs}-${f}`))})]},u)})]},b.label))})]})}function fe(s){const a=/^#?([0-9a-f]{6})$/i.exec((s??"").trim());if(!a)return!1;const t=parseInt(a[1],16),i=[t>>16&255,t>>8&255,t&255].map(l=>{const d=l/255;return d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4)});return .2126*i[0]+.7152*i[1]+.0722*i[2]>.5}const z=1e4,xe=12e3;function pe({browsers:s,findings:a,watching:t,palette:i}){const l=P(),d=h.useRef(null),o=h.useRef(null);return o.current={browsers:s,findings:a,watching:t},h.useEffect(()=>{var g;const n=d.current;if(!n)return;const r=n.getContext("2d");if(!r)return;const w=((g=window.matchMedia)==null?void 0:g.call(window,"(prefers-reduced-motion: reduce)").matches)??!1;let b=0,c=!1;const u=()=>{var J;if(c)return;const p=o.current;if(!p)return;const{browsers:f,findings:W,watching:T}=p,m=i["--accent"]||"#7dd3fc",k=i["--line"]||"#1f2229",A=i["--text-dim"]||"#6e727c",M=fe(i["--bg"]),v=M?42:26,F=M?.85:.65,R=Date.now(),C=Math.min(window.devicePixelRatio||1,2),S=n.clientWidth,$=n.clientHeight;(n.width!==S*C||n.height!==$*C)&&(n.width=S*C,n.height=$*C),r.setTransform(C,0,0,C,0,0),r.clearRect(0,0,S,$);const x=S/2,N=$/2,y=Math.min(S,$)/2-6;if(y<=0){b=requestAnimationFrame(u);return}r.strokeStyle=k,r.lineWidth=1,r.globalAlpha=M?1:.9;for(const j of[.4,.7,1])r.beginPath(),r.arc(x,N,y*j,0,Math.PI*2),r.stroke();r.beginPath(),r.moveTo(x-y,N),r.lineTo(x+y,N),r.moveTo(x,N-y),r.lineTo(x,N+y),r.stroke(),r.globalAlpha=1;const B=(T&&!w?R%z/z:0)*Math.PI*2-Math.PI/2;if(T){const j=(J=r.createConicGradient)==null?void 0:J.call(r,B-.85,x,N);j&&(j.addColorStop(0,"transparent"),j.addColorStop(.85/(Math.PI*2),`color-mix(in srgb, ${m} ${v}%, transparent)`),j.addColorStop(1,"transparent"),r.fillStyle=j,r.beginPath(),r.moveTo(x,N),r.arc(x,N,y,B-.85,B),r.closePath(),r.fill()),r.strokeStyle=m,r.globalAlpha=F,r.beginPath(),r.moveTo(x,N),r.lineTo(x+Math.cos(B)*y,N+Math.sin(B)*y),r.stroke(),r.globalAlpha=1}f.forEach((j,E)=>{const O=E/Math.max(f.length,1)*Math.PI*2-Math.PI/2,q=j.lastReadMs===null?1:Math.min(1,(R-j.lastReadMs)/12e4),L=y*(.42+q*.5),G=x+Math.cos(O)*L,K=N+Math.sin(O)*L,Y=Math.abs((B-O+Math.PI*3)%(Math.PI*2)-Math.PI),Q=T?Math.max(0,1-Y/.55):0;r.beginPath(),r.arc(G,K,3+Q*1.6,0,Math.PI*2),r.fillStyle=j.running?m:A,r.globalAlpha=j.running?.55+Q*.45:.35,r.fill(),r.globalAlpha=1});for(const j of W){const E=(R-j.atMs)/xe;if(E<0||E>1)continue;const q=Math.max(0,f.findIndex(K=>K.key===j.browser))/Math.max(f.length,1)*Math.PI*2-Math.PI/2,L=x+Math.cos(q)*y*.6,G=N+Math.sin(q)*y*.6;r.beginPath(),r.arc(L,G,4+E*22,0,Math.PI*2),r.strokeStyle=m,r.globalAlpha=(1-E)*.8,r.lineWidth=1.5,r.stroke(),r.globalAlpha=1}b=requestAnimationFrame(u)};return u(),()=>{c=!0,cancelAnimationFrame(b)}},[i]),e.jsx("canvas",{ref:d,className:"bw-radar",role:"img","aria-label":t?l("radar.watch.watching",{count:s.length}):l("radar.watch.idle")})}function je(s,a,t){if(s===null)return null;const i=s+a-t;return i>0?i:null}function Ne(s){const a=Math.ceil(s/1e3),t=Math.floor(a/60),i=a%60;return t>0?`${t}m ${i}s`:`${i}s`}function X(s){return(s??[]).filter(a=>a.installed&&a.profiles>0)}function ve(s,a=I){return!Number.isFinite(s)||s<=0?a("settings.bw.logEmpty"):se(s)}function ye(s,a){return s.map(t=>({key:t.key,name:t.name,running:t.running,visits:a.filter(i=>i.browser===t.key).reduce((i,l)=>i+l.programVisits,0)}))}function ke(s,a,t=I){if(s===null)return null;const i=Math.max(0,Math.round((a-s)/1e3));if(i<5)return t("settings.bw.ago.now");if(i<60)return t("settings.bw.ago.sec",{n:i});const l=Math.round(i/60);return l<60?t("settings.bw.ago.min",{n:l}):t("settings.bw.ago.hr",{n:Math.round(l/60)})}function Me(s,a=I){const t=s.profiles.filter(l=>l.degraded);if(t.length>0){const l=t[0],d=t.length-1;return{kind:"unreadable",text:a(d>0?"settings.bw.trouble.unreadableMore":"settings.bw.trouble.unreadable",{browser:l.name,profile:l.profile,reason:l.reason??a("settings.bw.trouble.noReason"),more:d})}}const i=X(s.browsers);return i.length===0?{kind:"no-profiles",text:a("settings.bw.trouble.noProfiles")}:i.some(l=>l.running)?null:{kind:"none-running",text:a("settings.bw.trouble.noneRunning")}}function Se({snap:s,watching:a,palette:t}){const i=P(),[l,d]=h.useState(!1),[o,n]=h.useState(()=>Date.now());h.useEffect(()=>{const w=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(w)},[]);const r=je(s.coverage.lastHumanMs,s.coverage.quietMs,o);return e.jsxs("section",{className:"bw-sec",children:[e.jsxs("h4",{className:"bw-sec-head",children:[i("settings.bw.overview"),e.jsx("button",{className:"bw-help",onClick:()=>d(w=>!w),"aria-expanded":l,"aria-label":i("settings.bw.overview.help"),children:"?"})]}),e.jsxs("div",{className:"bw-glance",children:[e.jsx(pe,{browsers:a.map(w=>{var b;return{key:w.key,name:w.name,running:w.running,lastReadMs:((b=s.profiles.find(c=>c.browser===w.key))==null?void 0:b.lastWrittenMs)??null}}),findings:s.episodes.slice(0,6).map(w=>({browser:w.browser??null,atMs:w.endMs})),watching:s.settings.enabled,palette:t}),e.jsx("ul",{className:"bw-counts",children:ye(a,s.profiles).map(w=>e.jsxs("li",{children:[e.jsx("span",{className:"bw-count-n",children:te(w.visits,0)}),e.jsx("span",{className:"bw-count-of",children:w.name})]},w.key))})]}),e.jsx("p",{className:"bw-since",children:i("settings.bw.overview.since")}),s.coverage.checkedMs>0&&e.jsxs("p",{className:"bw-since",children:[i("settings.bw.overview.checked",{ago:ke(s.coverage.checkedMs,o,i)??""}),s.coverage.checks>0&&e.jsxs(e.Fragment,{children:[" · ",i("settings.bw.overview.checks",{count:s.coverage.checks})]})]}),r!==null&&e.jsx("p",{className:"bw-gate",children:i("settings.bw.overview.gate",{time:Ne(r)})}),l&&e.jsxs("dl",{className:"bw-key",children:[e.jsx("dt",{children:i("settings.bw.key.sweep")}),e.jsx("dd",{children:i("settings.bw.key.sweepText")}),e.jsx("dt",{children:i("settings.bw.key.dot")}),e.jsx("dd",{children:i("settings.bw.key.dotText")}),e.jsx("dt",{children:i("settings.bw.key.ring")}),e.jsx("dd",{children:i("settings.bw.key.ringText")})]})]})}function Pe({watching:s,rest:a}){const t=P(),[i,l]=h.useState(!1),[d,o]=h.useState(!1);return e.jsxs("section",{className:"bw-sec",children:[e.jsxs("h4",{className:"bw-sec-head",children:[t("settings.bw.profiles"),e.jsx("button",{className:"bw-help",onClick:()=>l(n=>!n),"aria-expanded":i,"aria-label":t("settings.bw.profiles.help"),children:"?"})]}),i&&e.jsxs("dl",{className:"bw-key",children:[e.jsx("dt",{children:t("settings.bw.key.running")}),e.jsx("dd",{children:t("settings.bw.key.runningText")}),e.jsx("dt",{children:t("settings.bw.key.connected")}),e.jsx("dd",{children:t("settings.bw.key.connectedText")})]}),e.jsx("ul",{className:"bw-profiles",children:s.map(n=>e.jsxs("li",{children:[e.jsx("span",{className:`bw-prof-dot${n.running?" on":""}`,"aria-hidden":!0}),e.jsx("span",{className:"bw-prof-name",children:n.name}),e.jsx("span",{className:"bw-prof-state",children:n.running?t("settings.bw.running"):t("settings.bw.idle")}),n.running&&n.relay.state==="live"&&e.jsx("span",{className:"bw-relay",children:t("settings.bw.relay")})]},n.key))}),a.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"bw-why bw-rest-head",onClick:()=>o(n=>!n),"aria-expanded":d,children:[e.jsx("span",{className:"bw-chev","aria-hidden":!0,children:d?"▾":"▸"})," ",t("settings.bw.notWatched",{count:a.length})]}),d&&e.jsx("p",{className:"bw-rest",children:t("settings.bw.notWatchedText",{names:a.map(n=>n.name).join(", ")})})]})]})}function Te({snap:s,quiet:a,setQuiet:t,save:i,access:l,setAccess:d}){const o=P();return e.jsxs("div",{className:"bw-settings",children:[e.jsxs("label",{title:o("settings.bw.quiet.tip"),children:[e.jsx("span",{children:o("settings.bw.quiet.label")}),e.jsx("select",{value:a??s.settings.quietMinutes,onChange:n=>{t(Number(n.target.value)),i({quietMinutes:Number(n.target.value)})},children:[1,5,15,30,60].map(n=>e.jsx("option",{value:n,children:o("settings.bw.minutes",{n})},n))})]}),e.jsxs("label",{children:[e.jsx("span",{children:o("settings.bw.reaction.label")}),e.jsx("select",{value:s.settings.reaction,onChange:n=>void i({reaction:n.target.value}),disabled:!s.settings.enabled,title:s.settings.enabled?o("settings.bw.reaction.hintOn"):o("settings.bw.reaction.hintOff"),children:(s.reactions??["notify"]).map(n=>e.jsx("option",{value:n,children:o(n==="notify"?"settings.bw.reaction.notify":n==="close-tab"?"settings.bw.reaction.closeTab":"settings.bw.reaction.quit")},n))})]}),e.jsxs("div",{className:"bw-settings-note",children:[e.jsxs("p",{children:[o("settings.bw.note.chrome")," ",e.jsx("strong",{children:o("settings.bw.note.usually")})]}),e.jsxs("button",{className:"bw-why",onClick:()=>d(n=>!n),"aria-expanded":l,children:[e.jsx("span",{className:"bw-chev","aria-hidden":!0,children:l?"▾":"▸"})," ",o("settings.bw.access.toggle")]}),l&&e.jsxs("dl",{className:"bw-access",children:[e.jsx("dt",{children:o("settings.bw.access.reads")}),e.jsx("dd",{children:o("settings.bw.access.readsText",{when:new Date(s.coverage.startedMs).toLocaleString(V())})}),e.jsx("dt",{children:o("settings.bw.access.keeps")}),e.jsx("dd",{children:ne(o("settings.bw.access.keepsText",{path:"{path}",size:typeof s.coverage.logBytes=="number"?` (${ve(s.coverage.logBytes)})`:""}),{path:e.jsx("code",{className:"bw-path",children:s.coverage.logPath})})}),e.jsx("dt",{children:o("settings.bw.access.sends")}),e.jsx("dd",{children:o("settings.bw.access.sendsText")}),e.jsx("dt",{children:o("settings.bw.access.never")}),e.jsx("dd",{children:o("settings.bw.access.neverText")})]})]})]})}function Ce(s,a,t){return a?{kind:"saving",word:t("settings.bw.mode.saving")}:s.settings.enabled?{kind:"on",word:t("settings.bw.mode.watching")}:{kind:"off",word:t("settings.bw.mode.paused")}}function Re({snap:s,saving:a,save:t,why:i,setWhy:l}){const d=P(),o=Ce(s,a,d);return e.jsxs("footer",{className:"bw-status",children:[e.jsx("span",{className:`bw-mode-dot${s.settings.enabled?" on":""}`,"aria-hidden":!0}),e.jsx("span",{className:"bw-mode-word",children:o.word},o.kind),e.jsx("span",{className:"bw-status-text",children:s.coverage.archived===0?s.settings.enabled?d("settings.bw.disk.none"):d("settings.bw.disk.noneOff"):d("settings.bw.disk.some",{count:s.coverage.archived})}),e.jsx("button",{className:`glyph-btn bw-gear${i?" on":""}`,onClick:()=>l(n=>!n),"aria-expanded":i,"aria-label":d("settings.bw.settings"),title:d("settings.bw.settings"),children:e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3","aria-hidden":!0,children:[e.jsx("circle",{cx:"7",cy:"7",r:"2.1"}),e.jsx("path",{d:"M7 1.2v1.6M7 11.2v1.6M1.2 7h1.6M11.2 7h1.6M2.9 2.9l1.1 1.1M10 10l1.1 1.1M11.1 2.9L10 4M4 10l-1.1 1.1"})]})}),e.jsxs("label",{className:"bw-switch",htmlFor:"bw-enabled",children:[e.jsx("span",{className:"bw-switch-label",id:"bw-enabled-label",children:d("settings.bw.switch")}),e.jsx("button",{id:"bw-enabled",type:"button",role:"switch","aria-checked":s.settings.enabled,"aria-labelledby":"bw-enabled-label",className:"switch",onClick:()=>void t({enabled:!s.settings.enabled}),title:s.settings.enabled?d("settings.bw.switch.on"):d("settings.bw.switch.off"),children:e.jsx("span",{className:"switch-knob"})})]})]})}function $e({relay:s}){const a=P(),[t,i]=h.useState(!1),[l,d]=h.useState(!1),o=s.killswitch.blocked?"unblock":"block",n=s.command[o],r=h.useCallback(async()=>{await ae(n.command)&&(d(!0),window.setTimeout(()=>d(!1),1600))},[n.command]),w=s.profiles.filter(c=>{var u;return(u=c.report)==null?void 0:u.present}),b=s.profiles.filter(c=>c.report===null);return e.jsxs("section",{className:"bw-sec",children:[e.jsx("h4",{className:"bw-sec-head",children:a("shell.remote.title")}),e.jsx("p",{className:`bw-rc-verdict ${s.verdict}`,role:"status",children:s.verdict==="exposed"?a("shell.remote.exposed"):s.verdict==="protected"?a("shell.remote.protected",{path:s.hostsPath}):a("shell.remote.nothing")}),s.killswitch.foreign.length>0&&e.jsxs("p",{className:"bw-rc-foreign",children:[a("shell.remote.foreign",{path:s.hostsPath}),s.killswitch.foreign.map(c=>e.jsx("code",{className:"bw-path",children:c},c))]}),e.jsxs("button",{className:"bw-why",onClick:()=>i(c=>!c),"aria-expanded":t,children:[e.jsx("span",{className:"bw-chev","aria-hidden":!0,children:t?"▾":"▸"})," ",s.verdict==="protected"?a("shell.remote.undo"):a("shell.remote.reach")]}),t&&e.jsxs("div",{className:"bw-rc-body",children:[w.length>0&&e.jsx("dl",{className:"bw-key",children:w.map(c=>e.jsxs(h.Fragment,{children:[e.jsxs("dt",{children:[c.name,c.profile==="Default"?"":` · ${c.profile}`]}),e.jsxs("dd",{children:[a("shell.remote.detail",{state:c.report.enabled?a("shell.remote.enabled"):a("shell.remote.switchedOff"),scope:c.report.allUrls?a("shell.remote.allSites"):a("shell.remote.limited")}),c.report.sensitiveApis.length>0&&e.jsxs(e.Fragment,{children:[" — ",c.report.sensitiveApis.join(", ")]})]})]},`${c.browser}/${c.profile}`))}),b.length>0&&e.jsx("p",{className:"bw-rc-note",children:a("shell.remote.unreadable",{names:b.map(c=>c.name).join(", ")})}),!s.hostsRead&&e.jsx("p",{className:"bw-rc-note",children:a("shell.remote.hostsUnread",{path:s.hostsPath})}),w.some(c=>c.report.allUrls)&&e.jsx("p",{className:"bw-rc-note",children:ie(a("shell.remote.narrow"),"code",e.jsx("code",{className:"bw-path",children:"chrome://extensions"}))}),e.jsxs("div",{className:"bw-rc-cmd",children:[e.jsx("code",{children:n.command}),e.jsx("button",{className:"btn bw-rc-copy",onClick:r,children:a(l?"shell.copied":"shell.copy")})]}),e.jsx("p",{className:"bw-rc-note",children:n.note})]})]})}function Ie(s){const[a,t]=h.useState(null),[i,l]=h.useState(null),[d,o]=h.useState(null),[n,r]=h.useState(!1),w=h.useRef(!1),[b,c]=h.useState(null),[u,g]=h.useState(!1),p=h.useRef(!1),f=h.useCallback(async m=>{var k,A;if(!(m&&!re(w.current))){m&&(w.current=!0,r(!0));try{const M=await fetch(`/api/browser-watch${m?"?refresh=1":""}`);if(!M.ok)throw new U(I("settings.bw.deckAnswered",{status:M.status}));const v=await M.json();t(v),p.current||c(((k=v==null?void 0:v.settings)==null?void 0:k.quietMinutes)??15),s(((A=v==null?void 0:v.settings)==null?void 0:A.enabled)===!0),l(null)}catch(M){l(H(M,I("settings.bw.noAnswer")))}finally{m&&(w.current=!1,r(!1))}}},[s]);h.useEffect(()=>{f(!1)},[f]),h.useEffect(()=>{const m=setInterval(()=>{f(!1)},1e4);return()=>clearInterval(m)},[f]);const W=h.useCallback(async m=>{try{await fetch("/api/browser-watch/dismiss",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:m.host,startMs:m.startMs})})}finally{await f(!1)}},[f]),T=h.useCallback(async m=>{p.current=!0,g(!0);try{const k=await fetch("/api/browser-watch",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(m)});if(!k.ok)throw new U(I("settings.bw.deckAnswered",{status:k.status}));await f(!1),o(null)}catch(k){o(H(k,I("settings.bw.noAnswer")))}finally{p.current=!1,g(!1)}},[f]);return{snap:a,error:i,writeError:d,setWriteError:o,busy:n,quiet:b,setQuiet:c,saving:u,load:f,dismiss:W,save:T}}function Ee({onClose:s,onSeen:a,onWatching:t,palette:i}){const l=P(),d=le(s),o=ce(s),{snap:n,error:r,writeError:w,setWriteError:b,busy:c,quiet:u,setQuiet:g,saving:p,load:f,dismiss:W,save:T}=Ie(t),[m,k]=h.useState(!1),[A,M]=h.useState(!1),v=h.useRef(null),F=h.useRef(a);F.current=a,h.useEffect(()=>()=>F.current(Date.now()),[]);const R=X(n==null?void 0:n.browsers),C=((n==null?void 0:n.browsers)??[]).filter(x=>!(x.installed&&x.profiles>0)),S=n?Me(n,l):null,$=R.reduce((x,N)=>x+N.profiles,0);return e.jsxs(oe,{scrim:o,dialogRef:d,className:"bw-modal",labelledBy:"bw-title",children:[e.jsxs("header",{className:"modal-head",children:[e.jsxs("div",{className:"modal-title",children:[e.jsx("span",{className:"modal-tool-name",id:"bw-title",children:l("settings.bw.title")}),e.jsx("span",{className:"modal-tool-id",children:n?l("settings.bw.scope.profiles",{count:$}):l("settings.bw.scope.localOnly")})]}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{ref:v,className:"glyph-btn",onClick:()=>void f(!0),...he(c),"aria-label":l("settings.bw.reread"),title:l("settings.bw.reread"),children:e.jsx(de,{})}),e.jsx(we,{onClick:s,label:l("settings.bw.close")})]})]}),e.jsxs("div",{className:"modal-body bw-body",children:[!n&&!r&&e.jsxs("div",{className:"bw-loading",children:[e.jsx("span",{className:"bw-loading-bar","aria-hidden":!0}),e.jsx("p",{children:l("settings.bw.loading")})]}),r&&e.jsx("div",{className:"bw-state",children:e.jsxs("div",{className:"bw-row err",children:[e.jsx("span",{className:"bw-dot","aria-hidden":!0}),e.jsx("span",{className:"bw-row-label",children:l("settings.bw.readFail")}),e.jsx("span",{className:"bw-row-detail",children:r})]})}),n&&S&&e.jsx("p",{className:`bw-trouble ${S.kind}`,role:"status",children:S.text}),n&&e.jsxs("div",{className:"bw-work",children:[e.jsxs("aside",{className:"bw-side",children:[e.jsx(Se,{snap:n,watching:R,palette:i}),e.jsx(Pe,{watching:R,rest:C}),n.relay&&e.jsx($e,{relay:n.relay})]}),e.jsxs("div",{className:"bw-main",children:[e.jsx(me,{snap:n,dismiss:W,refreshRef:v}),e.jsx(be,{snap:n})]})]}),n&&m&&e.jsx(Te,{snap:n,quiet:u,setQuiet:g,save:T,access:A,setAccess:M}),w&&e.jsx("div",{className:"bw-state bw-write-err",role:"alert",children:e.jsxs("div",{className:"bw-row err",children:[e.jsx("span",{className:"bw-dot","aria-hidden":!0}),e.jsx("span",{className:"bw-row-label",children:l("settings.bw.saveFail")}),e.jsx("span",{className:"bw-row-detail",children:l("settings.bw.saveFailDetail",{error:w})}),e.jsx("button",{className:"glyph-btn bw-write-err-x",onClick:()=>b(null),"aria-label":l("settings.bw.dismiss"),title:l("settings.bw.dismiss"),children:"×"})]})}),n&&e.jsx(Re,{snap:n,saving:p,save:T,why:m,setWhy:k})]})]})}export{Ee as default};
@@ -1 +1 @@
1
- import{t as S,g as ue,r as c,s as de,c1 as fe,u as $,j as l,k as V,c2 as me,c3 as he}from"./app-ZMmmEHxF.js";import{o as Z}from"./use-account-DvFObI4M.js";const _=e=>!!e&&typeof e=="object"&&!Array.isArray(e),f=e=>typeof e=="string",R=e=>Number.isInteger(e)&&e>=0,v=e=>e==="user"||e==="team";function ee(e){return!_(e)||!f(e.code)||!f(e.label)?null:{code:e.code,label:e.label,fixedIn:f(e.fixedIn)?e.fixedIn:null,reason:f(e.reason)?e.reason:null,released:e.released===!0}}function te(e){return _(e)&&R(e.number)&&f(e.url)?{number:e.number,url:e.url}:null}function w(e){if(!_(e)||!f(e.id)||!f(e.title)||!f(e.createdAt)||!f(e.lastActivityAt))return null;const t=ee(e.status),s=_(e.preview)&&v(e.preview.side)&&f(e.preview.text)?{side:e.preview.side,text:e.preview.text}:null;return!t||!s||!R(e.lastSeq)||!R(e.readSeq)?null:{id:e.id,kind:f(e.kind)?e.kind:"other",title:e.title,status:t,createdAt:e.createdAt,lastActivityAt:e.lastActivityAt,lastSeq:e.lastSeq,readSeq:e.readSeq,hasUnread:e.hasUnread===!0,preview:s,trackedIssue:te(e.trackedIssue),images:R(e.images)?e.images:0,webUrl:f(e.webUrl)?e.webUrl:""}}function se(e){if(!_(e)||!R(e.seq)||!f(e.at)||!f(e.type)||!v(e.side)||!f(e.text))return null;const t={seq:e.seq,at:e.at,type:e.type,side:e.side,text:e.text};f(e.via)&&(t.via=e.via),f(e.signature)&&(t.signature=e.signature);const s=ee(e.status);s&&(t.status=s);const n=te(e.issue);return n&&(t.issue=n),f(e.version)&&(t.version=e.version),Array.isArray(e.images)&&(t.images=e.images.filter(r=>_(r)&&f(r.id)&&f(r.type)&&R(r.width)&&R(r.height)&&R(r.bytes))),t}const pe=e=>Array.isArray(e)?e.map(se).filter(t=>t!==null):[];function K(e){if(!_(e))return null;const t=w(e.thread);return t?{thread:t,items:pe(e.items).sort((s,n)=>s.seq-n.seq),earlier:R(e.earlier)?e.earlier:null}:null}function X(e){return!_(e)||!Array.isArray(e.threads)?null:{threads:e.threads.map(w).filter(t=>t!==null),next:f(e.next)&&/^[A-Za-z0-9_-]{1,64}$/.test(e.next)?e.next:null,unread:R(e.unread)?e.unread:0,latestAt:f(e.latestAt)?e.latestAt:null}}function be(e){if(!_(e))return null;const t=se(e.item),s=w(e.thread);return t&&s?{item:t,thread:s}:null}function P(e,t){const s=new Map;for(const n of e)s.set(n.seq,n);for(const n of t)s.set(n.seq,n);return[...s.values()].sort((n,r)=>n.seq-r.seq)}const ne=e=>e.reduce((t,s)=>Math.max(t,s.seq),-1),ye=/https?:\/\/[^\s<>"'\x60]+/g,ge=`.,;:!?'"`,xe={")":"(","]":"[","}":"{"},Ne=2048,ke="noopener noreferrer nofollow ugc",z=(e,t,s)=>{let n=0;for(let r=0;r<t;r++)e[r]===s&&n++;return n};function Se(e){let t=e.length;for(;t>0;){const s=e[t-1];if(ge.includes(s)){t--;continue}const n=xe[s];if(n&&z(e,t,s)>z(e,t,n)){t--;continue}break}return e.slice(0,t)}function je(e){const t=[];if(!e)return t;let s="",n=0;for(const r of e.matchAll(ye)){const a=Se(r[0]),i=a.startsWith("https://")?8:7;a.length<=i||a.length>Ne||(s+=e.slice(n,r.index),s&&(t.push({text:s}),s=""),t.push({url:a,text:a}),n=r.index+a.length)}return s+=e.slice(n),s&&t.push({text:s}),t}const Ae=300*1e3,Ee=new Set(["status","issue","duplicate","released","reopened"]);function M(e,t){return new Intl.DateTimeFormat("en-CA",{year:"numeric",month:"2-digit",day:"2-digit",timeZone:t}).format(e)}function B(e,t,s){const n=M(Date.parse(e),s);if(n===M(t,s))return"today";const r=M(t,s),[a,i,m]=r.split("-").map(Number),o=M(Date.UTC(a,i-1,m-1,12),"UTC");return n===o?"yesterday":"date"}function H(e,t,s){const n=B(e,t,s);if(n==="today")return S("insights.audit.today");if(n==="yesterday")return S("insights.audit.yesterday");const r=Date.parse(e),a=M(r,s).slice(0,4)===M(t,s).slice(0,4);return new Intl.DateTimeFormat(ue(),{month:"short",day:"numeric",...a?{}:{year:"numeric"},timeZone:s}).format(r)}function G(e,t){return new Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",hourCycle:"h23",timeZone:t}).format(Date.parse(e))}function Re(e,t,s){return B(e,t,s)==="today"?G(e,s):H(e,t,s)}function _e(e,t,s){const n=[];let r="",a=null;for(const i of e){const m=Date.parse(i.at),o=M(m,s);if(o!==r&&(r=o,a=null,n.push({kind:"day",key:`day-${o}`,label:H(i.at,t,s)})),i.type!=="message"){a=null,n.push({kind:"event",key:`item-${i.seq}`,item:i,time:G(i.at,s),known:Ee.has(i.type)});continue}const b=i.side==="team"?i.signature??null:null,u=a==null?void 0:a.messages[a.messages.length-1];if(a&&u&&a.side===i.side&&a.signature===b&&m-Date.parse(u.at)<Ae){a.messages.push(i),a.time=G(i.at,s);continue}a={kind:"run",key:`run-${i.seq}`,side:i.side,signature:b,messages:[i],time:G(i.at,s)},n.push(a)}return n}function Te(e){return e.preview.side==="user"?S("shell.feedback.previewYou",{text:e.preview.text}):e.preview.text}function Le(e){return e==="looking"||e==="planned"?"progress":e==="fixed"?"done":e==="wont_do"?"closed":"open"}const Ie="shell.feedback.allConversations",Ce="shell.feedback.noConversations",De="shell.feedback.loadingConversations",Me="shell.feedback.loadingConversation",qe="board.rail.more",Oe="shell.feedback.showEarlier",re="board.stage.tryAgain",Ge="shell.feedback.replyPlaceholder",Ue="shell.feedback.replySend",Pe="shell.feedback.sending",Fe="shell.feedback.replyLabel",Ve="shell.feedback.replySent",Ye="shell.feedback.newReply",ae="shell.feedback.conversationGone",le="shell.feedback.conversationsUnavailable",$e="shell.feedback.replyUnavailable",we="shell.feedback.replyRefused",Be=e=>S("shell.feedback.trackedPublicly",{number:e.number});function He(e){return S("shell.feedback.imagesOnWeb",{count:e})}function We(e,t,s,n){const r=H(e,s,n),i=B(e,s,n)==="date"?r:r.toLowerCase();return S(t==="web"?"shell.feedback.startedWeb":t==="deck"?"shell.feedback.startedDeck":"shell.feedback.started",{when:i})}const Y="/api/account/feedback/threads",O=e=>`${Y}/${encodeURIComponent(e)}`;async function q(e,t){try{const s=await fetch(e,{headers:{accept:"application/json",...t!=null&&t.body?{"content-type":"application/json"}:{}},...t});return{status:s.status,body:await s.json().catch(()=>null)}}catch{return{status:0,body:null}}}const J=(e,t)=>q(e,{method:"POST",body:JSON.stringify(t)}),F=new Map;function Ke(e,t,s=Date.now()){const n=t==null?void 0:t.reason;return n==="too_many"&&Number.isInteger(t==null?void 0:t.limit)&&Number.isInteger(t==null?void 0:t.retryAfterSec)?fe("replies",t.limit,new Date(s+t.retryAfterSec*1e3)):n==="not_found"||e===404?S(ae):n==="invalid"||n==="too_large"||n==="bad_request"?S(we):S($e)}function Xe(e,t){const[s,n]=c.useState([]),[r,a]=c.useState(null),[i,m]=c.useState("loading"),[o,b]=c.useState(!1),u=c.useRef(0),A=c.useCallback(async()=>{const D=++u.current,{status:T,body:E}=await q(Y);if(D!==u.current)return;const x=T===200?X(E):null;if(!x){m(N=>N==="ready"?N:"failed");return}n(x.threads),a(x.next),m("ready")},[]);c.useEffect(()=>{e&&A()},[e,t,A]);const C=c.useCallback(async()=>{if(!r||o)return;b(!0);const D=u.current,{status:T,body:E}=await q(`${Y}?before=${encodeURIComponent(r)}`);if(b(!1),D!==u.current)return;const x=T===200?X(E):null;x&&(n(N=>[...N,...x.threads.filter(d=>!N.some(y=>y.id===d.id))]),a(x.next))},[r,o]);return{threads:s,next:r,state:i,loadingMore:o,more:C,reload:A}}function ze(e,t,s){const[n,r]=c.useState(null),[a,i]=c.useState("loading"),[m,o]=c.useState(!1),[b,u]=c.useState(()=>F.get(e)??""),[A,C]=c.useState(!1),[D,T]=c.useState(""),E=c.useRef(!1),x=c.useRef(0),N=c.useRef(-1),d=c.useRef(-1),y=c.useRef(s);y.current=s;const L=c.useCallback(async()=>{const h=++x.current,{status:g,body:j}=await q(O(e));if(h!==x.current)return;if(g===404&&(j==null?void 0:j.reason)==="not_found"){i("gone");return}const k=g===200?K(j):null;if(!k){i(p=>p==="ready"?p:"failed");return}r(p=>p?{thread:k.thread,items:P(p.items,k.items),earlier:p.earlier}:k),i("ready")},[e]);c.useEffect(()=>{L()},[L,t]);const I=n==null?void 0:n.items,W=(n==null?void 0:n.thread.readSeq)??-1;c.useEffect(()=>{if(!I)return;const h=I.reduce((g,j)=>j.side==="team"?Math.max(g,j.seq):g,-1);N.current>=0&&h>N.current&&y.current(S(Ye)),N.current=Math.max(N.current,h,0)},[I]),c.useEffect(()=>{if(!I||I.length===0)return;const h=ne(I),g=()=>{document.visibilityState==="visible"&&(h<=Math.max(W,d.current)||(d.current=h,J(`${O(e)}/read`,{seq:h})))};return g(),document.addEventListener("visibilitychange",g),()=>document.removeEventListener("visibilitychange",g)},[e,I,W]);const ce=c.useCallback(async()=>{const h=n==null?void 0:n.earlier;if(h==null||m)return;o(!0);const{status:g,body:j}=await q(`${O(e)}?before=${h}`);o(!1);const k=g===200?K(j):null;k&&r(p=>p?{...p,items:P(k.items,p.items),earlier:k.earlier}:k)},[e,n==null?void 0:n.earlier,m]),U=c.useCallback(h=>{u(h),h?F.set(e,h):F.delete(e)},[e]),oe=c.useCallback(async()=>{if(!de(E.current))return!1;const h=b.trim();if(!h)return!1;E.current=!0,C(!0),T("");const{status:g,body:j}=await J(`${O(e)}/replies`,{body:h});E.current=!1,C(!1);const k=g===201?be(j):null;return k?(U(""),r(p=>p&&{...p,thread:k.thread,items:P(p.items,[k.item])}),y.current(S(Ve)),L(),!0):(T(Ke(g,j)),!1)},[b,e,L,U]);return{view:n,state:a,items:I??[],loadingEarlier:m,earlier:ce,reload:L,draft:b,setDraft:U,sending:A,failure:D,reply:oe,problem:a==="gone"?S(ae):a==="failed"?S(le):""}}function ie({status:e}){return l.jsx("span",{className:"fc-pill","data-tone":Le(e.code),children:e.label})}function Q({text:e}){return l.jsx(l.Fragment,{children:je(e).map((t,s)=>t.url?l.jsx("a",{className:"fc-link",href:t.url,rel:ke,target:"_blank",children:t.text},s):l.jsx(c.Fragment,{children:t.text},s))})}function Je({item:e,webUrl:t}){var n;const s=((n=e.images)==null?void 0:n.length)??0;return s===0||!Z(t)?null:l.jsx("a",{className:"fc-link fc-images",href:t,target:"_blank",rel:"noopener noreferrer",children:He(s)})}function Qe({items:e,webUrl:t,now:s}){const n=$();return l.jsx(l.Fragment,{children:_e(e,s).map(r=>{if(r.kind==="day")return l.jsx("p",{className:"fc-day",children:l.jsx("span",{children:r.label})},r.key);if(r.kind==="event")return l.jsxs("p",{className:"fc-event","data-type":r.known?r.item.type:"other",children:[l.jsx("span",{children:l.jsx(Q,{text:r.item.text})}),l.jsx("time",{className:"fc-time",dateTime:r.item.at,children:r.time})]},r.key);const a=r.messages[r.messages.length-1];return l.jsxs("div",{className:"fc-run","data-side":r.side,children:[r.side==="team"?l.jsx("p",{className:"fc-signature",children:r.signature??n("shell.feedback.teamSignature")}):l.jsx("p",{className:"vis-hidden",children:n("shell.feedback.you")}),r.messages.map(i=>l.jsxs("div",{className:"fc-message",children:[l.jsx("p",{className:"fc-bubble",children:l.jsx(Q,{text:i.text})}),l.jsx(Je,{item:i,webUrl:t})]},i.seq)),l.jsx("time",{className:"fc-time",dateTime:a.at,children:r.time})]},r.key)})})}function Ze({summary:e,latestAt:t,announce:s,onBack:n}){var x,N;const r=$(),a=ze(e.id,t,s),i=((x=a.view)==null?void 0:x.thread)??e,m=c.useRef(null),o=c.useRef(null),b=c.useRef(-1),u=c.useRef(-1),A=c.useRef(0),C=Date.now();c.useEffect(()=>{var d;(d=m.current)==null||d.focus()},[]),c.useLayoutEffect(()=>{const d=o.current;if(!d||a.items.length===0)return;const y=ne(a.items),L=a.items[0].seq;y>b.current?d.scrollTop=d.scrollHeight:L<u.current&&(d.scrollTop=d.scrollHeight-A.current),b.current=y,u.current=L,A.current=d.scrollHeight-d.scrollTop},[a.items]);function D(d){var y;if(d.preventDefault(),!a.draft.trim()){(y=m.current)==null||y.focus();return}a.reply()}function T(d){var y;he(d.nativeEvent)&&(d.preventDefault(),(y=d.currentTarget.form)==null||y.requestSubmit())}const E=a.items.find(d=>d.seq===0);return l.jsxs("div",{className:"fc-thread",children:[l.jsxs("div",{className:"fc-thread-head",children:[l.jsxs("button",{type:"button",className:"fb-tool fc-back",onClick:n,children:[l.jsx("span",{"aria-hidden":"true",children:"←"})," ",r(Ie)]}),l.jsx("h3",{className:"fc-thread-title",children:i.title}),l.jsxs("p",{className:"fc-thread-meta",children:[l.jsx(ie,{status:i.status}),i.trackedIssue&&Z(i.trackedIssue.url)&&l.jsx("a",{className:"fc-link",href:i.trackedIssue.url,target:"_blank",rel:"noopener noreferrer",children:Be(i.trackedIssue)}),l.jsx("span",{children:We(i.createdAt,E==null?void 0:E.via,C)})]})]}),l.jsxs("div",{ref:o,className:"fc-timeline",children:[((N=a.view)==null?void 0:N.earlier)!=null&&l.jsx("button",{type:"button",className:"btn fc-earlier",onClick:()=>void a.earlier(),...V(a.loadingEarlier),children:r(Oe)}),a.state==="loading"&&l.jsx("p",{className:"fc-note",children:r(Me)}),a.problem&&l.jsxs("div",{className:"fc-missing",children:[l.jsx("p",{className:"fc-note",children:a.problem}),a.state==="failed"&&l.jsx("button",{type:"button",className:"btn",onClick:()=>void a.reload(),children:r(re)})]}),l.jsx(Qe,{items:a.items,webUrl:i.webUrl,now:C})]}),l.jsxs("form",{className:"fc-composer",onSubmit:D,noValidate:!0,children:[l.jsx("label",{className:"vis-hidden",htmlFor:"fc-reply",children:r(Fe)}),l.jsx("textarea",{ref:m,id:"fc-reply",className:"ap-manage-input fc-reply",value:a.draft,maxLength:me,rows:1,placeholder:r(Ge),onChange:d=>a.setDraft(d.target.value),onKeyDown:T,"aria-describedby":a.failure?"fc-reply-error":void 0}),l.jsx("button",{type:"submit",className:"btn primary fc-send","aria-keyshortcuts":"Meta+Enter Control+Enter",...V(a.sending),children:l.jsxs("span",{className:"fb-send-label",children:[l.jsx("span",{className:"fb-send-idle",children:r(Ue)}),l.jsx("span",{className:"fb-send-busy",children:r(Pe)})]})})]}),a.failure&&l.jsx("p",{id:"fc-reply-error",className:"fb-error fc-reply-error",role:"alert",children:a.failure})]})}function tt({account:e,active:t,announce:s}){const[n,r]=c.useState(null),a=$(),i=c.useRef(null),m=c.useRef(null),o=Xe(t&&n===null,e.latestAt),b=Date.now();return n?l.jsx(Ze,{summary:n,latestAt:e.latestAt,announce:s,onBack:()=>{i.current=n.id,r(null),requestAnimationFrame(()=>{var u,A;(A=(u=m.current)==null?void 0:u.querySelector(`[data-thread="${CSS.escape(i.current??"")}"]`))==null||A.focus()})}},n.id):l.jsxs("div",{ref:m,className:"fc-list-view",children:[o.state==="loading"&&o.threads.length===0&&l.jsx("p",{className:"fc-note",children:a(De)}),o.state==="failed"&&l.jsxs("div",{className:"fc-missing",children:[l.jsx("p",{className:"fc-note",children:a(le)}),l.jsx("button",{type:"button",className:"btn",onClick:()=>void o.reload(),children:a(re)})]}),o.state==="ready"&&o.threads.length===0&&l.jsx("p",{className:"fc-note",children:a(Ce)}),o.threads.length>0&&l.jsx("ul",{className:"fc-list",children:o.threads.map(u=>l.jsx("li",{children:l.jsxs("button",{type:"button",className:"fc-row","data-thread":u.id,onClick:()=>r(u),children:[l.jsxs("span",{className:"fc-row-head",children:[l.jsx("span",{className:"fc-row-title",children:u.title}),l.jsx("time",{className:"fc-row-time",dateTime:u.lastActivityAt,children:Re(u.lastActivityAt,b)})]}),l.jsxs("span",{className:"fc-row-foot",children:[l.jsx(ie,{status:u.status}),l.jsx("span",{className:"fc-row-preview",children:Te(u)}),u.hasUnread&&l.jsx("span",{className:"fc-dot","aria-hidden":"true"}),u.hasUnread&&l.jsx("span",{className:"vis-hidden",children:a("shell.feedback.unreadSuffix")})]})]})},u.id))}),o.next&&l.jsx("button",{type:"button",className:"btn fc-more",onClick:()=>void o.more(),...V(o.loadingMore),children:a(qe)})]})}export{tt as default};
1
+ import{t as S,g as ue,r as c,s as de,c1 as fe,u as $,j as l,k as V,c2 as me,c3 as he}from"./app-CdRq5GPP.js";import{o as Z}from"./use-account-t_qL6ab-.js";const _=e=>!!e&&typeof e=="object"&&!Array.isArray(e),f=e=>typeof e=="string",R=e=>Number.isInteger(e)&&e>=0,v=e=>e==="user"||e==="team";function ee(e){return!_(e)||!f(e.code)||!f(e.label)?null:{code:e.code,label:e.label,fixedIn:f(e.fixedIn)?e.fixedIn:null,reason:f(e.reason)?e.reason:null,released:e.released===!0}}function te(e){return _(e)&&R(e.number)&&f(e.url)?{number:e.number,url:e.url}:null}function w(e){if(!_(e)||!f(e.id)||!f(e.title)||!f(e.createdAt)||!f(e.lastActivityAt))return null;const t=ee(e.status),s=_(e.preview)&&v(e.preview.side)&&f(e.preview.text)?{side:e.preview.side,text:e.preview.text}:null;return!t||!s||!R(e.lastSeq)||!R(e.readSeq)?null:{id:e.id,kind:f(e.kind)?e.kind:"other",title:e.title,status:t,createdAt:e.createdAt,lastActivityAt:e.lastActivityAt,lastSeq:e.lastSeq,readSeq:e.readSeq,hasUnread:e.hasUnread===!0,preview:s,trackedIssue:te(e.trackedIssue),images:R(e.images)?e.images:0,webUrl:f(e.webUrl)?e.webUrl:""}}function se(e){if(!_(e)||!R(e.seq)||!f(e.at)||!f(e.type)||!v(e.side)||!f(e.text))return null;const t={seq:e.seq,at:e.at,type:e.type,side:e.side,text:e.text};f(e.via)&&(t.via=e.via),f(e.signature)&&(t.signature=e.signature);const s=ee(e.status);s&&(t.status=s);const n=te(e.issue);return n&&(t.issue=n),f(e.version)&&(t.version=e.version),Array.isArray(e.images)&&(t.images=e.images.filter(r=>_(r)&&f(r.id)&&f(r.type)&&R(r.width)&&R(r.height)&&R(r.bytes))),t}const pe=e=>Array.isArray(e)?e.map(se).filter(t=>t!==null):[];function K(e){if(!_(e))return null;const t=w(e.thread);return t?{thread:t,items:pe(e.items).sort((s,n)=>s.seq-n.seq),earlier:R(e.earlier)?e.earlier:null}:null}function X(e){return!_(e)||!Array.isArray(e.threads)?null:{threads:e.threads.map(w).filter(t=>t!==null),next:f(e.next)&&/^[A-Za-z0-9_-]{1,64}$/.test(e.next)?e.next:null,unread:R(e.unread)?e.unread:0,latestAt:f(e.latestAt)?e.latestAt:null}}function be(e){if(!_(e))return null;const t=se(e.item),s=w(e.thread);return t&&s?{item:t,thread:s}:null}function P(e,t){const s=new Map;for(const n of e)s.set(n.seq,n);for(const n of t)s.set(n.seq,n);return[...s.values()].sort((n,r)=>n.seq-r.seq)}const ne=e=>e.reduce((t,s)=>Math.max(t,s.seq),-1),ye=/https?:\/\/[^\s<>"'\x60]+/g,ge=`.,;:!?'"`,xe={")":"(","]":"[","}":"{"},Ne=2048,ke="noopener noreferrer nofollow ugc",z=(e,t,s)=>{let n=0;for(let r=0;r<t;r++)e[r]===s&&n++;return n};function Se(e){let t=e.length;for(;t>0;){const s=e[t-1];if(ge.includes(s)){t--;continue}const n=xe[s];if(n&&z(e,t,s)>z(e,t,n)){t--;continue}break}return e.slice(0,t)}function je(e){const t=[];if(!e)return t;let s="",n=0;for(const r of e.matchAll(ye)){const a=Se(r[0]),i=a.startsWith("https://")?8:7;a.length<=i||a.length>Ne||(s+=e.slice(n,r.index),s&&(t.push({text:s}),s=""),t.push({url:a,text:a}),n=r.index+a.length)}return s+=e.slice(n),s&&t.push({text:s}),t}const Ae=300*1e3,Ee=new Set(["status","issue","duplicate","released","reopened"]);function M(e,t){return new Intl.DateTimeFormat("en-CA",{year:"numeric",month:"2-digit",day:"2-digit",timeZone:t}).format(e)}function B(e,t,s){const n=M(Date.parse(e),s);if(n===M(t,s))return"today";const r=M(t,s),[a,i,m]=r.split("-").map(Number),o=M(Date.UTC(a,i-1,m-1,12),"UTC");return n===o?"yesterday":"date"}function H(e,t,s){const n=B(e,t,s);if(n==="today")return S("insights.audit.today");if(n==="yesterday")return S("insights.audit.yesterday");const r=Date.parse(e),a=M(r,s).slice(0,4)===M(t,s).slice(0,4);return new Intl.DateTimeFormat(ue(),{month:"short",day:"numeric",...a?{}:{year:"numeric"},timeZone:s}).format(r)}function G(e,t){return new Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",hourCycle:"h23",timeZone:t}).format(Date.parse(e))}function Re(e,t,s){return B(e,t,s)==="today"?G(e,s):H(e,t,s)}function _e(e,t,s){const n=[];let r="",a=null;for(const i of e){const m=Date.parse(i.at),o=M(m,s);if(o!==r&&(r=o,a=null,n.push({kind:"day",key:`day-${o}`,label:H(i.at,t,s)})),i.type!=="message"){a=null,n.push({kind:"event",key:`item-${i.seq}`,item:i,time:G(i.at,s),known:Ee.has(i.type)});continue}const b=i.side==="team"?i.signature??null:null,u=a==null?void 0:a.messages[a.messages.length-1];if(a&&u&&a.side===i.side&&a.signature===b&&m-Date.parse(u.at)<Ae){a.messages.push(i),a.time=G(i.at,s);continue}a={kind:"run",key:`run-${i.seq}`,side:i.side,signature:b,messages:[i],time:G(i.at,s)},n.push(a)}return n}function Te(e){return e.preview.side==="user"?S("shell.feedback.previewYou",{text:e.preview.text}):e.preview.text}function Le(e){return e==="looking"||e==="planned"?"progress":e==="fixed"?"done":e==="wont_do"?"closed":"open"}const Ie="shell.feedback.allConversations",Ce="shell.feedback.noConversations",De="shell.feedback.loadingConversations",Me="shell.feedback.loadingConversation",qe="board.rail.more",Oe="shell.feedback.showEarlier",re="board.stage.tryAgain",Ge="shell.feedback.replyPlaceholder",Ue="shell.feedback.replySend",Pe="shell.feedback.sending",Fe="shell.feedback.replyLabel",Ve="shell.feedback.replySent",Ye="shell.feedback.newReply",ae="shell.feedback.conversationGone",le="shell.feedback.conversationsUnavailable",$e="shell.feedback.replyUnavailable",we="shell.feedback.replyRefused",Be=e=>S("shell.feedback.trackedPublicly",{number:e.number});function He(e){return S("shell.feedback.imagesOnWeb",{count:e})}function We(e,t,s,n){const r=H(e,s,n),i=B(e,s,n)==="date"?r:r.toLowerCase();return S(t==="web"?"shell.feedback.startedWeb":t==="deck"?"shell.feedback.startedDeck":"shell.feedback.started",{when:i})}const Y="/api/account/feedback/threads",O=e=>`${Y}/${encodeURIComponent(e)}`;async function q(e,t){try{const s=await fetch(e,{headers:{accept:"application/json",...t!=null&&t.body?{"content-type":"application/json"}:{}},...t});return{status:s.status,body:await s.json().catch(()=>null)}}catch{return{status:0,body:null}}}const J=(e,t)=>q(e,{method:"POST",body:JSON.stringify(t)}),F=new Map;function Ke(e,t,s=Date.now()){const n=t==null?void 0:t.reason;return n==="too_many"&&Number.isInteger(t==null?void 0:t.limit)&&Number.isInteger(t==null?void 0:t.retryAfterSec)?fe("replies",t.limit,new Date(s+t.retryAfterSec*1e3)):n==="not_found"||e===404?S(ae):n==="invalid"||n==="too_large"||n==="bad_request"?S(we):S($e)}function Xe(e,t){const[s,n]=c.useState([]),[r,a]=c.useState(null),[i,m]=c.useState("loading"),[o,b]=c.useState(!1),u=c.useRef(0),A=c.useCallback(async()=>{const D=++u.current,{status:T,body:E}=await q(Y);if(D!==u.current)return;const x=T===200?X(E):null;if(!x){m(N=>N==="ready"?N:"failed");return}n(x.threads),a(x.next),m("ready")},[]);c.useEffect(()=>{e&&A()},[e,t,A]);const C=c.useCallback(async()=>{if(!r||o)return;b(!0);const D=u.current,{status:T,body:E}=await q(`${Y}?before=${encodeURIComponent(r)}`);if(b(!1),D!==u.current)return;const x=T===200?X(E):null;x&&(n(N=>[...N,...x.threads.filter(d=>!N.some(y=>y.id===d.id))]),a(x.next))},[r,o]);return{threads:s,next:r,state:i,loadingMore:o,more:C,reload:A}}function ze(e,t,s){const[n,r]=c.useState(null),[a,i]=c.useState("loading"),[m,o]=c.useState(!1),[b,u]=c.useState(()=>F.get(e)??""),[A,C]=c.useState(!1),[D,T]=c.useState(""),E=c.useRef(!1),x=c.useRef(0),N=c.useRef(-1),d=c.useRef(-1),y=c.useRef(s);y.current=s;const L=c.useCallback(async()=>{const h=++x.current,{status:g,body:j}=await q(O(e));if(h!==x.current)return;if(g===404&&(j==null?void 0:j.reason)==="not_found"){i("gone");return}const k=g===200?K(j):null;if(!k){i(p=>p==="ready"?p:"failed");return}r(p=>p?{thread:k.thread,items:P(p.items,k.items),earlier:p.earlier}:k),i("ready")},[e]);c.useEffect(()=>{L()},[L,t]);const I=n==null?void 0:n.items,W=(n==null?void 0:n.thread.readSeq)??-1;c.useEffect(()=>{if(!I)return;const h=I.reduce((g,j)=>j.side==="team"?Math.max(g,j.seq):g,-1);N.current>=0&&h>N.current&&y.current(S(Ye)),N.current=Math.max(N.current,h,0)},[I]),c.useEffect(()=>{if(!I||I.length===0)return;const h=ne(I),g=()=>{document.visibilityState==="visible"&&(h<=Math.max(W,d.current)||(d.current=h,J(`${O(e)}/read`,{seq:h})))};return g(),document.addEventListener("visibilitychange",g),()=>document.removeEventListener("visibilitychange",g)},[e,I,W]);const ce=c.useCallback(async()=>{const h=n==null?void 0:n.earlier;if(h==null||m)return;o(!0);const{status:g,body:j}=await q(`${O(e)}?before=${h}`);o(!1);const k=g===200?K(j):null;k&&r(p=>p?{...p,items:P(k.items,p.items),earlier:k.earlier}:k)},[e,n==null?void 0:n.earlier,m]),U=c.useCallback(h=>{u(h),h?F.set(e,h):F.delete(e)},[e]),oe=c.useCallback(async()=>{if(!de(E.current))return!1;const h=b.trim();if(!h)return!1;E.current=!0,C(!0),T("");const{status:g,body:j}=await J(`${O(e)}/replies`,{body:h});E.current=!1,C(!1);const k=g===201?be(j):null;return k?(U(""),r(p=>p&&{...p,thread:k.thread,items:P(p.items,[k.item])}),y.current(S(Ve)),L(),!0):(T(Ke(g,j)),!1)},[b,e,L,U]);return{view:n,state:a,items:I??[],loadingEarlier:m,earlier:ce,reload:L,draft:b,setDraft:U,sending:A,failure:D,reply:oe,problem:a==="gone"?S(ae):a==="failed"?S(le):""}}function ie({status:e}){return l.jsx("span",{className:"fc-pill","data-tone":Le(e.code),children:e.label})}function Q({text:e}){return l.jsx(l.Fragment,{children:je(e).map((t,s)=>t.url?l.jsx("a",{className:"fc-link",href:t.url,rel:ke,target:"_blank",children:t.text},s):l.jsx(c.Fragment,{children:t.text},s))})}function Je({item:e,webUrl:t}){var n;const s=((n=e.images)==null?void 0:n.length)??0;return s===0||!Z(t)?null:l.jsx("a",{className:"fc-link fc-images",href:t,target:"_blank",rel:"noopener noreferrer",children:He(s)})}function Qe({items:e,webUrl:t,now:s}){const n=$();return l.jsx(l.Fragment,{children:_e(e,s).map(r=>{if(r.kind==="day")return l.jsx("p",{className:"fc-day",children:l.jsx("span",{children:r.label})},r.key);if(r.kind==="event")return l.jsxs("p",{className:"fc-event","data-type":r.known?r.item.type:"other",children:[l.jsx("span",{children:l.jsx(Q,{text:r.item.text})}),l.jsx("time",{className:"fc-time",dateTime:r.item.at,children:r.time})]},r.key);const a=r.messages[r.messages.length-1];return l.jsxs("div",{className:"fc-run","data-side":r.side,children:[r.side==="team"?l.jsx("p",{className:"fc-signature",children:r.signature??n("shell.feedback.teamSignature")}):l.jsx("p",{className:"vis-hidden",children:n("shell.feedback.you")}),r.messages.map(i=>l.jsxs("div",{className:"fc-message",children:[l.jsx("p",{className:"fc-bubble",children:l.jsx(Q,{text:i.text})}),l.jsx(Je,{item:i,webUrl:t})]},i.seq)),l.jsx("time",{className:"fc-time",dateTime:a.at,children:r.time})]},r.key)})})}function Ze({summary:e,latestAt:t,announce:s,onBack:n}){var x,N;const r=$(),a=ze(e.id,t,s),i=((x=a.view)==null?void 0:x.thread)??e,m=c.useRef(null),o=c.useRef(null),b=c.useRef(-1),u=c.useRef(-1),A=c.useRef(0),C=Date.now();c.useEffect(()=>{var d;(d=m.current)==null||d.focus()},[]),c.useLayoutEffect(()=>{const d=o.current;if(!d||a.items.length===0)return;const y=ne(a.items),L=a.items[0].seq;y>b.current?d.scrollTop=d.scrollHeight:L<u.current&&(d.scrollTop=d.scrollHeight-A.current),b.current=y,u.current=L,A.current=d.scrollHeight-d.scrollTop},[a.items]);function D(d){var y;if(d.preventDefault(),!a.draft.trim()){(y=m.current)==null||y.focus();return}a.reply()}function T(d){var y;he(d.nativeEvent)&&(d.preventDefault(),(y=d.currentTarget.form)==null||y.requestSubmit())}const E=a.items.find(d=>d.seq===0);return l.jsxs("div",{className:"fc-thread",children:[l.jsxs("div",{className:"fc-thread-head",children:[l.jsxs("button",{type:"button",className:"fb-tool fc-back",onClick:n,children:[l.jsx("span",{"aria-hidden":"true",children:"←"})," ",r(Ie)]}),l.jsx("h3",{className:"fc-thread-title",children:i.title}),l.jsxs("p",{className:"fc-thread-meta",children:[l.jsx(ie,{status:i.status}),i.trackedIssue&&Z(i.trackedIssue.url)&&l.jsx("a",{className:"fc-link",href:i.trackedIssue.url,target:"_blank",rel:"noopener noreferrer",children:Be(i.trackedIssue)}),l.jsx("span",{children:We(i.createdAt,E==null?void 0:E.via,C)})]})]}),l.jsxs("div",{ref:o,className:"fc-timeline",children:[((N=a.view)==null?void 0:N.earlier)!=null&&l.jsx("button",{type:"button",className:"btn fc-earlier",onClick:()=>void a.earlier(),...V(a.loadingEarlier),children:r(Oe)}),a.state==="loading"&&l.jsx("p",{className:"fc-note",children:r(Me)}),a.problem&&l.jsxs("div",{className:"fc-missing",children:[l.jsx("p",{className:"fc-note",children:a.problem}),a.state==="failed"&&l.jsx("button",{type:"button",className:"btn",onClick:()=>void a.reload(),children:r(re)})]}),l.jsx(Qe,{items:a.items,webUrl:i.webUrl,now:C})]}),l.jsxs("form",{className:"fc-composer",onSubmit:D,noValidate:!0,children:[l.jsx("label",{className:"vis-hidden",htmlFor:"fc-reply",children:r(Fe)}),l.jsx("textarea",{ref:m,id:"fc-reply",className:"ap-manage-input fc-reply",value:a.draft,maxLength:me,rows:1,placeholder:r(Ge),onChange:d=>a.setDraft(d.target.value),onKeyDown:T,"aria-describedby":a.failure?"fc-reply-error":void 0}),l.jsx("button",{type:"submit",className:"btn primary fc-send","aria-keyshortcuts":"Meta+Enter Control+Enter",...V(a.sending),children:l.jsxs("span",{className:"fb-send-label",children:[l.jsx("span",{className:"fb-send-idle",children:r(Ue)}),l.jsx("span",{className:"fb-send-busy",children:r(Pe)})]})})]}),a.failure&&l.jsx("p",{id:"fc-reply-error",className:"fb-error fc-reply-error",role:"alert",children:a.failure})]})}function tt({account:e,active:t,announce:s}){const[n,r]=c.useState(null),a=$(),i=c.useRef(null),m=c.useRef(null),o=Xe(t&&n===null,e.latestAt),b=Date.now();return n?l.jsx(Ze,{summary:n,latestAt:e.latestAt,announce:s,onBack:()=>{i.current=n.id,r(null),requestAnimationFrame(()=>{var u,A;(A=(u=m.current)==null?void 0:u.querySelector(`[data-thread="${CSS.escape(i.current??"")}"]`))==null||A.focus()})}},n.id):l.jsxs("div",{ref:m,className:"fc-list-view",children:[o.state==="loading"&&o.threads.length===0&&l.jsx("p",{className:"fc-note",children:a(De)}),o.state==="failed"&&l.jsxs("div",{className:"fc-missing",children:[l.jsx("p",{className:"fc-note",children:a(le)}),l.jsx("button",{type:"button",className:"btn",onClick:()=>void o.reload(),children:a(re)})]}),o.state==="ready"&&o.threads.length===0&&l.jsx("p",{className:"fc-note",children:a(Ce)}),o.threads.length>0&&l.jsx("ul",{className:"fc-list",children:o.threads.map(u=>l.jsx("li",{children:l.jsxs("button",{type:"button",className:"fc-row","data-thread":u.id,onClick:()=>r(u),children:[l.jsxs("span",{className:"fc-row-head",children:[l.jsx("span",{className:"fc-row-title",children:u.title}),l.jsx("time",{className:"fc-row-time",dateTime:u.lastActivityAt,children:Re(u.lastActivityAt,b)})]}),l.jsxs("span",{className:"fc-row-foot",children:[l.jsx(ie,{status:u.status}),l.jsx("span",{className:"fc-row-preview",children:Te(u)}),u.hasUnread&&l.jsx("span",{className:"fc-dot","aria-hidden":"true"}),u.hasUnread&&l.jsx("span",{className:"vis-hidden",children:a("shell.feedback.unreadSuffix")})]})]})},u.id))}),o.next&&l.jsx("button",{type:"button",className:"btn fc-more",onClick:()=>void o.more(),...V(o.loadingMore),children:a(qe)})]})}export{tt as default};